x-workspace
Workspace Web Component.
npm i x-workspace
|
pnpm add x-workspace
|
yarn add x-workspace
|
Examples
# web
# view source
example/web.tsx
/** @jsxImportSource sigl */
import $ from 'sigl'
import { Rect } from 'sigl'
import { ContextMenuOption, WorkspaceElement, WorkspaceWindowElement } from 'x-workspace'
interface WindowItemElement extends $.Element<WindowItemElement> {}
@$.element()
class WindowItemElement extends $(WorkspaceWindowElement) {
mounted($: WindowItemElement['$']) {
$.Controls = $.part(() => <div></div>)
$.ContextMenu = $.part(() => (
<>
<ContextMenuOption keyboard={['Ctrl', 'N']}>New</ContextMenuOption>
<ContextMenuOption keyboard={['Alt', 'R']}>Remove the thing</ContextMenuOption>
<ContextMenuOption>and another</ContextMenuOption>
<hr />
<ContextMenuOption disabled>and another</ContextMenuOption>
<ContextMenuOption>and another</ContextMenuOption>
</>
))
$.Item = $.part(() => <div>hello this is a window</div>)
}
}
interface SceneElement extends $.Element<SceneElement> {}
@$.element()
class SceneElement extends HTMLElement {
Workspace = $.element(WorkspaceElement)
WindowItem = $.element(WindowItemElement)
items = new $.RefSet<WindowItemElement>([
{ rect: new Rect(0, 0, 200, 200), label: 'one' },
{ rect: new Rect(300, 0, 200, 200), label: 'two' },
])
mounted($: SceneElement['$']) {
$.render(({ Workspace, WindowItem, items }) => (
<>
<style>
{/*css*/ `
${Workspace} {
position: absolute;
display: flex;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
${WindowItem} {
border: 5px solid pink;
}
`}
</style>
<Workspace>
{items.map(item => <WindowItem {x-workspace.item} />)}
</Workspace>
</>
))
}
}
const Scene = $.element(SceneElement)
$.render(<Scene />, document.body)
API
# PopupElement
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # context
ContextClass<PopupElement & JsxContext<PopupElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # onmounted
EventHandler<PopupElement, CustomEvent<any>>
# onunmounted
EventHandler<PopupElement, CustomEvent<any>>
# created
(ctx)
# ctx
Context<PopupElement & JsxContext<PopupElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> created(ctx) =>
- void
# mounted
($)
# $
Context<PopupElement & JsxContext<PopupElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> mounted($) =>
- void
# SurfaceElement
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # centerView
# context
ContextClass<SurfaceElement & JsxContext<SurfaceElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # cursorState
State<SurfaceElement, {
},
"copy"
| "default"
| "grabbing"
| "ew-resize"
| "ns-resize"
| "nwse-resize"
> & EventMethods<SurfaceElement, {}> & InlineEventMap<SurfaceElement, {
}>
# onconnectend
EventHandler<SurfaceElement, CustomEvent<any>>
# onconnectstart
EventHandler<SurfaceElement, CustomEvent<any>>
# onmounted
EventHandler<SurfaceElement, CustomEvent<any>>
# onstatechange
EventHandler<SurfaceElement, CustomEvent<any>>
# onsurfacemoveitemmove
EventHandler<SurfaceElement, CustomEvent<SurfaceMoveDetail>>
# onsurfacemoveitemmoveend
EventHandler<SurfaceElement, CustomEvent<SurfaceMoveDetail>>
# onsurfacemoveitemmovestart
EventHandler<SurfaceElement, CustomEvent<SurfaceMoveDetail>>
# onsurfaceresizeitemresize
EventHandler<SurfaceElement, CustomEvent<SurfaceResizeDetail>>
# onsurfaceresizeitemresizeend
EventHandler<SurfaceElement, CustomEvent<SurfaceResizeDetail>>
# onsurfaceresizeitemresizestart
EventHandler<SurfaceElement, CustomEvent<SurfaceResizeDetail>>
# onsurfaceselecting
EventHandler<SurfaceElement, CustomEvent<{
}>>
# onunmounted
EventHandler<SurfaceElement, CustomEvent<any>>
# state
State<SurfaceElement, {
},
"surfaceselecting"
| "surfaceidle"
| "surfaceoverlay"
| "surfacecenteringitem"
| "surfacecenteringview"
| "surfaceconnecting"
| "surfacefullsize"
| "surfaceminimappanning"
| "surfacepanning"
| "surfacepinching"
| "surfacewheeling"
> & EventMethods<SurfaceElement, {}> & InlineEventMap<SurfaceElement, {
}>
# transition
Transition<States, "surfaceselecting"
| "surfaceidle"
| "surfaceoverlay"
| "surfacecenteringitem"
| "surfacecenteringview"
| "surfaceconnecting"
| "surfacefullsize"
| "surfaceminimappanning"
| "surfacepanning"
| "surfacepinching"
| "surfacewheeling"
>
# created
(ctx)
# ctx
Context<SurfaceElement & JsxContext<SurfaceElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> created(ctx) =>
- void
# mounted
($)
# $
Context<SurfaceElement & JsxContext<SurfaceElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> mounted($) =>
- void
# on
(name)
on<K>(name) =>
-
On<Fn<[ EventHandler<SurfaceElement, LifecycleEvents & {
# SurfaceGridElement
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # context
ContextClass<SurfaceGridElement & JsxContext<SurfaceGridElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # onmounted
EventHandler<SurfaceGridElement, CustomEvent<any>>
# onunmounted
EventHandler<SurfaceGridElement, CustomEvent<any>>
# created
(ctx)
# ctx
Context<SurfaceGridElement & JsxContext<SurfaceGridElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> created(ctx) =>
- void
# mounted
($)
# $
Context<SurfaceGridElement & JsxContext<SurfaceGridElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> mounted($) =>
- void
# on
(name)
on<K>(name) =>
-
On<Fn<[ EventHandler<SurfaceGridElement, LifecycleEvents & object [K]> ], Off>>
# SurfaceItemElement
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # context
ContextClass<SurfaceItemElement & JsxContext<SurfaceItemElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # onmounted
EventHandler<SurfaceItemElement, CustomEvent<any>>
# onunmounted
EventHandler<SurfaceItemElement, CustomEvent<any>>
# created
(ctx)
# ctx
Context<SurfaceItemElement & JsxContext<SurfaceItemElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> created(ctx) =>
- void
# mounted
($)
# $
Context<SurfaceItemElement & JsxContext<SurfaceItemElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> mounted($) =>
- void
# on
(name)
on<K>(name) =>
-
On<Fn<[ EventHandler<SurfaceItemElement, LifecycleEvents & object [K]> ], Off>>
# SurfaceMinimapElement
# $
Context<SurfaceMinimapElement & JsxContext<SurfaceMinimapElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # context
ContextClass<SurfaceMinimapElement & JsxContext<SurfaceMinimapElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # onmounted
EventHandler<SurfaceMinimapElement, CustomEvent<any>>
# onunmounted
EventHandler<SurfaceMinimapElement, CustomEvent<any>>
# created
(ctx)
# ctx
Context<SurfaceMinimapElement & JsxContext<SurfaceMinimapElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> created(ctx) =>
- void
# mounted
($)
# $
Context<SurfaceMinimapElement & JsxContext<SurfaceMinimapElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> mounted($) =>
- void
# on
(name)
on<K>(name) =>
-
On<Fn<[ EventHandler<SurfaceMinimapElement, LifecycleEvents & object [K]> ], Off>>
# SurfaceMoveElement
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # context
ContextClass<SurfaceMoveElement & JsxContext<SurfaceMoveElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # onmounted
EventHandler<SurfaceMoveElement, CustomEvent<any>>
# onsurfacemoveitemmove
EventHandler<SurfaceMoveElement, CustomEvent<SurfaceMoveDetail>>
# onsurfacemoveitemmoveend
EventHandler<SurfaceMoveElement, CustomEvent<SurfaceMoveDetail>>
# onsurfacemoveitemmovestart
EventHandler<SurfaceMoveElement, CustomEvent<SurfaceMoveDetail>>
# onunmounted
EventHandler<SurfaceMoveElement, CustomEvent<any>>
# state
State<SurfaceMoveElement, {
},
"surfacemoveitemmove"
| "surfacemoveidle"
> & EventMethods<SurfaceMoveElement, {}> & InlineEventMap<SurfaceMoveElement, {
}>
# created
(ctx)
# ctx
Context<SurfaceMoveElement & JsxContext<SurfaceMoveElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> created(ctx) =>
- void
# mounted
($)
# $
Context<SurfaceMoveElement & JsxContext<SurfaceMoveElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> mounted($) =>
- void
# on
(name)
on<K>(name) =>
-
On<Fn<[ EventHandler<SurfaceMoveElement, LifecycleEvents & SurfaceMoveEvents [K]> ], Off>>
# SurfaceResizeElement
# $
Context<SurfaceResizeElement & JsxContext<SurfaceResizeElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # context
ContextClass<SurfaceResizeElement & JsxContext<SurfaceResizeElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # onmounted
EventHandler<SurfaceResizeElement, CustomEvent<any>>
# onsurfaceresizeitemresize
EventHandler<SurfaceResizeElement, CustomEvent<SurfaceResizeDetail>>
# onsurfaceresizeitemresizeend
EventHandler<SurfaceResizeElement, CustomEvent<SurfaceResizeDetail>>
# onsurfaceresizeitemresizestart
EventHandler<SurfaceResizeElement, CustomEvent<SurfaceResizeDetail>>
# onunmounted
EventHandler<SurfaceResizeElement, CustomEvent<any>>
# state
State<SurfaceResizeElement, {
},
"surfaceresizeitemresize"
| "surfaceresizeidle"
> & EventMethods<SurfaceResizeElement, {}> & InlineEventMap<SurfaceResizeElement, {
}>
# created
(ctx)
# ctx
Context<SurfaceResizeElement & JsxContext<SurfaceResizeElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> created(ctx) =>
- void
# mounted
($)
# $
Context<SurfaceResizeElement & JsxContext<SurfaceResizeElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> mounted($) =>
- void
# on
(name)
on<K>(name) =>
-
On<Fn<[ EventHandler<SurfaceResizeElement, LifecycleEvents & SurfaceResizeEvents [K]> ], Off>>
# WorkspaceElement
src/x-workspace.tsx#L35
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # context
ContextClass<WorkspaceElement & JsxContext<WorkspaceElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> # onContextMenu
src/x-workspace.tsx#L61 (Options) =>
-
EventHandler<any, MouseEvent>
# onmounted
EventHandler<WorkspaceElement, CustomEvent<any>>
# onunmounted
EventHandler<WorkspaceElement, CustomEvent<any>>
# created
(ctx)
# ctx
Context<WorkspaceElement & JsxContext<WorkspaceElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> created(ctx) =>
- void
# mounted
($)
src/x-workspace.tsx#L66
# $
Context<WorkspaceElement & JsxContext<WorkspaceElement> & Omit<{
<T>(ctor) =>
-
CleanClass<T>
<T>(ctx) =>
-
Wrapper<T>
},
"transition"
>> mounted<