@stacksjs/components 0.2.854 → 0.2.857
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CodeEditor-jg4w7e15.stx +497 -0
- package/dist/ContextMenu-43g3w5tp.stx +188 -0
- package/dist/DataGrid-7rt7v865.stx +376 -0
- package/dist/GraphView-0t3t9mec.stx +320 -0
- package/dist/JsonTree-satc4010.stx +317 -0
- package/dist/PreviewFrame-erbgvzj8.stx +257 -0
- package/dist/SplitPane-7sqfdwqa.stx +159 -0
- package/dist/code-editor/editor.js +2166 -0
- package/dist/component-api/component-api.js +36 -0
- package/dist/components/CodeBlock.d.ts +12 -5
- package/dist/context-menu/context-menu.js +575 -0
- package/dist/data-grid/data-grid.js +1244 -0
- package/dist/graph-view/graph-view.js +1408 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +34 -15
- package/dist/json-tree/json-tree.js +1121 -0
- package/dist/preview-frame/preview-frame.js +356 -0
- package/dist/split-pane/split-pane.js +364 -0
- package/dist/ui/code-editor/CodeEditor.d.ts +46 -0
- package/dist/ui/code-editor/controller.d.ts +103 -0
- package/dist/ui/code-editor/core/commands.d.ts +55 -0
- package/dist/ui/code-editor/core/completion.d.ts +40 -0
- package/dist/ui/code-editor/core/editor.d.ts +69 -0
- package/dist/ui/code-editor/core/highlight.d.ts +61 -0
- package/dist/ui/code-editor/core/history.d.ts +27 -0
- package/dist/ui/code-editor/core/index.d.ts +13 -0
- package/dist/ui/code-editor/core/keymap.d.ts +38 -0
- package/dist/ui/code-editor/core/selection.d.ts +30 -0
- package/dist/ui/code-editor/core/text.d.ts +64 -0
- package/dist/ui/code-editor/editor.d.ts +15 -0
- package/dist/ui/code-editor/index.d.ts +29 -0
- package/dist/ui/code-editor/tokenizer.d.ts +18 -0
- package/dist/ui/code-editor/view.d.ts +59 -0
- package/dist/ui/context-menu/ContextMenu.d.ts +14 -0
- package/dist/ui/context-menu/context-menu.d.ts +8 -0
- package/dist/ui/context-menu/core.d.ts +74 -0
- package/dist/ui/context-menu/index.d.ts +11 -0
- package/dist/ui/context-menu/view.d.ts +36 -0
- package/dist/ui/data-grid/DataGrid.d.ts +30 -0
- package/dist/ui/data-grid/core.d.ts +141 -0
- package/dist/ui/data-grid/data-grid.d.ts +9 -0
- package/dist/ui/data-grid/index.d.ts +20 -0
- package/dist/ui/data-grid/view.d.ts +56 -0
- package/dist/ui/graph-view/GraphView.d.ts +21 -0
- package/dist/ui/graph-view/core/edges.d.ts +34 -0
- package/dist/ui/graph-view/core/force.d.ts +10 -0
- package/dist/ui/graph-view/core/graph.d.ts +83 -0
- package/dist/ui/graph-view/core/index.d.ts +5 -0
- package/dist/ui/graph-view/core/layered.d.ts +24 -0
- package/dist/ui/graph-view/core/viewport.d.ts +34 -0
- package/dist/ui/graph-view/graph-view.d.ts +9 -0
- package/dist/ui/graph-view/index.d.ts +21 -0
- package/dist/ui/graph-view/view.d.ts +51 -0
- package/dist/ui/json-tree/JsonTree.d.ts +18 -0
- package/dist/ui/json-tree/core.d.ts +108 -0
- package/dist/ui/json-tree/index.d.ts +18 -0
- package/dist/ui/json-tree/json-tree.d.ts +10 -0
- package/dist/ui/json-tree/tinker.d.ts +84 -0
- package/dist/ui/json-tree/view.d.ts +59 -0
- package/dist/ui/preview-frame/PreviewFrame.d.ts +44 -0
- package/dist/ui/preview-frame/core.d.ts +81 -0
- package/dist/ui/preview-frame/index.d.ts +19 -0
- package/dist/ui/preview-frame/preview-frame.d.ts +8 -0
- package/dist/ui/preview-frame/view.d.ts +37 -0
- package/dist/ui/split-pane/SplitPane.d.ts +18 -0
- package/dist/ui/split-pane/core.d.ts +58 -0
- package/dist/ui/split-pane/index.d.ts +15 -0
- package/dist/ui/split-pane/split-pane.d.ts +8 -0
- package/dist/ui/split-pane/view.d.ts +27 -0
- package/dist/ui/virtual-table/index.d.ts +6 -0
- package/dist/utils/component-api.d.ts +4 -0
- package/dist/utils/highlighter.d.ts +19 -1
- package/dist/utils/highlighter.js +24 -7
- package/dist/utils/syntax-theme.d.ts +44 -0
- package/package.json +44 -4
- package/src/components/CodeBlock.stx +195 -17
- package/src/index.ts +10 -0
- package/src/ui/code-editor/CodeEditor.stx +497 -0
- package/src/ui/code-editor/README.md +135 -0
- package/src/ui/code-editor/controller.ts +517 -0
- package/src/ui/code-editor/core/commands.ts +381 -0
- package/src/ui/code-editor/core/completion.ts +212 -0
- package/src/ui/code-editor/core/editor.ts +319 -0
- package/src/ui/code-editor/core/highlight.ts +203 -0
- package/src/ui/code-editor/core/history.ts +190 -0
- package/src/ui/code-editor/core/index.ts +14 -0
- package/src/ui/code-editor/core/keymap.ts +125 -0
- package/src/ui/code-editor/core/selection.ts +104 -0
- package/src/ui/code-editor/core/text.ts +252 -0
- package/src/ui/code-editor/editor.ts +16 -0
- package/src/ui/code-editor/index.ts +46 -0
- package/src/ui/code-editor/tokenizer.ts +74 -0
- package/src/ui/code-editor/view.ts +1066 -0
- package/src/ui/context-menu/ContextMenu.stx +188 -0
- package/src/ui/context-menu/README.md +117 -0
- package/src/ui/context-menu/context-menu.ts +8 -0
- package/src/ui/context-menu/core.ts +250 -0
- package/src/ui/context-menu/index.ts +16 -0
- package/src/ui/context-menu/view.ts +540 -0
- package/src/ui/data-grid/DataGrid.stx +376 -0
- package/src/ui/data-grid/README.md +204 -0
- package/src/ui/data-grid/core.ts +813 -0
- package/src/ui/data-grid/data-grid.ts +9 -0
- package/src/ui/data-grid/index.ts +34 -0
- package/src/ui/data-grid/view.ts +806 -0
- package/src/ui/graph-view/GraphView.stx +320 -0
- package/src/ui/graph-view/README.md +210 -0
- package/src/ui/graph-view/core/edges.ts +180 -0
- package/src/ui/graph-view/core/force.ts +237 -0
- package/src/ui/graph-view/core/graph.ts +277 -0
- package/src/ui/graph-view/core/index.ts +5 -0
- package/src/ui/graph-view/core/layered.ts +256 -0
- package/src/ui/graph-view/core/viewport.ts +141 -0
- package/src/ui/graph-view/graph-view.ts +9 -0
- package/src/ui/graph-view/index.ts +35 -0
- package/src/ui/graph-view/view.ts +809 -0
- package/src/ui/json-tree/JsonTree.stx +317 -0
- package/src/ui/json-tree/README.md +193 -0
- package/src/ui/json-tree/core.ts +588 -0
- package/src/ui/json-tree/index.ts +28 -0
- package/src/ui/json-tree/json-tree.ts +10 -0
- package/src/ui/json-tree/tinker.ts +349 -0
- package/src/ui/json-tree/view.ts +665 -0
- package/src/ui/preview-frame/PreviewFrame.stx +257 -0
- package/src/ui/preview-frame/README.md +107 -0
- package/src/ui/preview-frame/core.ts +195 -0
- package/src/ui/preview-frame/index.ts +31 -0
- package/src/ui/preview-frame/preview-frame.ts +8 -0
- package/src/ui/preview-frame/view.ts +336 -0
- package/src/ui/split-pane/README.md +87 -0
- package/src/ui/split-pane/SplitPane.stx +159 -0
- package/src/ui/split-pane/core.ts +200 -0
- package/src/ui/split-pane/index.ts +24 -0
- package/src/ui/split-pane/split-pane.ts +8 -0
- package/src/ui/split-pane/view.ts +305 -0
- package/src/ui/virtual-table/index.ts +6 -0
- package/src/utils/component-api.ts +72 -0
- package/src/utils/highlighter.ts +121 -218
- package/src/utils/syntax-theme.ts +144 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<script server>
|
|
2
|
+
export const direction = $props.direction === 'vertical' ? 'vertical' : 'horizontal'
|
|
3
|
+
/*
|
|
4
|
+
* Shares, one per pane: `[30, 70]`, `[1, 2, 1]`, or the text `30,70`. Left
|
|
5
|
+
* out, each pane's own `data-size` is used, and equal shares after that.
|
|
6
|
+
*/
|
|
7
|
+
export const sizes = Array.isArray($props.sizes)
|
|
8
|
+
? $props.sizes
|
|
9
|
+
: (typeof $props.sizes === 'string' && $props.sizes.trim() !== '' ? $props.sizes : null)
|
|
10
|
+
export const minSize = $num($props.minSize, 48)
|
|
11
|
+
export const step = $num($props.step, 16)
|
|
12
|
+
export const storageKey = $props.storageKey || ''
|
|
13
|
+
export const label = $props.label || 'Resize panes'
|
|
14
|
+
/* A CSS length. A split fills the box it is given, so the box needs a height. */
|
|
15
|
+
export const height = $props.height || '100%'
|
|
16
|
+
export const className = $props.className || ''
|
|
17
|
+
export const splitId = $props.id || `split-pane-${$uid}`
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script client>
|
|
21
|
+
/*
|
|
22
|
+
* <SplitPane>: panes side by side, or stacked, with a separator to drag
|
|
23
|
+
* between each pair. The children of the tag are the panes.
|
|
24
|
+
*
|
|
25
|
+
* The arithmetic is in ./core and the DOM in ./view; this is the wiring.
|
|
26
|
+
*/
|
|
27
|
+
import { parseSizes } from './core'
|
|
28
|
+
import { SplitPaneView } from './view'
|
|
29
|
+
|
|
30
|
+
const emit = defineEmits(['resize', 'resize-end'])
|
|
31
|
+
|
|
32
|
+
const asDirection = value => (value === 'vertical' ? 'vertical' : 'horizontal')
|
|
33
|
+
const liveDirection = useReactiveProp('direction', {{ direction }}, { parse: asDirection })
|
|
34
|
+
const liveSizes = useReactiveProp('sizes', {{ sizes }}, { parse: parseSizes })
|
|
35
|
+
|
|
36
|
+
const rootRef = useRef('split-pane')
|
|
37
|
+
let split = null
|
|
38
|
+
|
|
39
|
+
onMount(() => {
|
|
40
|
+
const root = rootRef()
|
|
41
|
+
if (!root) return
|
|
42
|
+
|
|
43
|
+
split = new SplitPaneView(root, {
|
|
44
|
+
direction: asDirection(liveDirection()),
|
|
45
|
+
sizes: parseSizes(liveSizes()),
|
|
46
|
+
minSize: {{ minSize }},
|
|
47
|
+
step: {{ step }},
|
|
48
|
+
storageKey: {{ storageKey }},
|
|
49
|
+
label: {{ label }},
|
|
50
|
+
}, {
|
|
51
|
+
onResize(detail) { emit('resize', detail) },
|
|
52
|
+
onResizeEnd(detail) { emit('resize-end', detail) },
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// The first run of each finds the layout the view was just built with, and
|
|
56
|
+
// must leave a stored layout alone; only a later change is a new instruction.
|
|
57
|
+
let sizesSeen = false
|
|
58
|
+
effect(() => {
|
|
59
|
+
const next = parseSizes(liveSizes())
|
|
60
|
+
if (sizesSeen && next) split.setSizes(next)
|
|
61
|
+
sizesSeen = true
|
|
62
|
+
})
|
|
63
|
+
effect(() => split.setDirection(asDirection(liveDirection())))
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
onDestroy(() => {
|
|
67
|
+
if (split) split.destroy()
|
|
68
|
+
split = null
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
defineExpose({
|
|
72
|
+
getSizes: () => (split ? split.getSizes() : []),
|
|
73
|
+
setSizes: (next) => { if (split) split.setSizes(parseSizes(next)) },
|
|
74
|
+
reset: () => { if (split) split.reset() },
|
|
75
|
+
})
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<div
|
|
79
|
+
ref="split-pane"
|
|
80
|
+
id="{{ splitId }}"
|
|
81
|
+
data-stx-split-pane
|
|
82
|
+
data-direction="{{ direction }}"
|
|
83
|
+
class="stx-split {{ className }}"
|
|
84
|
+
style="height: {{ height }}"
|
|
85
|
+
>
|
|
86
|
+
<slot />
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<style>
|
|
90
|
+
/*
|
|
91
|
+
* A separator is drawn as a hairline and grabbed by a wider strip around it,
|
|
92
|
+
* so it does not have to be thick to be easy to hit. Every colour falls back
|
|
93
|
+
* to a role token.
|
|
94
|
+
*/
|
|
95
|
+
:where([data-stx-split-pane]) {
|
|
96
|
+
--stx-split-line: var(--stx-line, #e5e5e5);
|
|
97
|
+
--stx-split-line-active: var(--stx-accent, #2563eb);
|
|
98
|
+
--stx-split-line-size: 1px;
|
|
99
|
+
--stx-split-grab: 9px;
|
|
100
|
+
display: flex;
|
|
101
|
+
flex-direction: row;
|
|
102
|
+
width: 100%;
|
|
103
|
+
min-width: 0;
|
|
104
|
+
min-height: 0;
|
|
105
|
+
}
|
|
106
|
+
:where([data-stx-split-pane][data-direction="vertical"]) { flex-direction: column; }
|
|
107
|
+
|
|
108
|
+
:where([data-stx-split-pane]) > :where([data-split-pane]) {
|
|
109
|
+
min-width: 0;
|
|
110
|
+
min-height: 0;
|
|
111
|
+
overflow: auto;
|
|
112
|
+
}
|
|
113
|
+
/* Before the view has run, the panes still share the space rather than stack. */
|
|
114
|
+
:where([data-stx-split-pane]:not([data-split-ready])) > * { flex: 1 1 0px; min-width: 0; min-height: 0; }
|
|
115
|
+
|
|
116
|
+
[data-stx-split-pane] > .stx-split-separator {
|
|
117
|
+
position: relative;
|
|
118
|
+
flex: 0 0 var(--stx-split-line-size);
|
|
119
|
+
background: var(--stx-split-line);
|
|
120
|
+
cursor: col-resize;
|
|
121
|
+
touch-action: none;
|
|
122
|
+
outline: none;
|
|
123
|
+
transition: background-color 120ms ease;
|
|
124
|
+
}
|
|
125
|
+
[data-stx-split-pane][data-direction="vertical"] > .stx-split-separator { cursor: row-resize; }
|
|
126
|
+
|
|
127
|
+
[data-stx-split-pane] > .stx-split-separator::after {
|
|
128
|
+
content: '';
|
|
129
|
+
position: absolute;
|
|
130
|
+
z-index: 1;
|
|
131
|
+
top: 0;
|
|
132
|
+
bottom: 0;
|
|
133
|
+
left: calc((var(--stx-split-grab) - var(--stx-split-line-size)) / -2);
|
|
134
|
+
width: var(--stx-split-grab);
|
|
135
|
+
}
|
|
136
|
+
[data-stx-split-pane][data-direction="vertical"] > .stx-split-separator::after {
|
|
137
|
+
left: 0;
|
|
138
|
+
right: 0;
|
|
139
|
+
top: calc((var(--stx-split-grab) - var(--stx-split-line-size)) / -2);
|
|
140
|
+
bottom: auto;
|
|
141
|
+
width: auto;
|
|
142
|
+
height: var(--stx-split-grab);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
[data-stx-split-pane] > .stx-split-separator:is(:hover, [data-active]) { background: var(--stx-split-line-active); }
|
|
146
|
+
[data-stx-split-pane] > .stx-split-separator:focus-visible {
|
|
147
|
+
background: var(--stx-split-line-active);
|
|
148
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--stx-split-line-active) 40%, transparent);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* A drag must not select the text it passes over, or lose the pointer to a frame. */
|
|
152
|
+
[data-stx-split-pane][data-dragging] { user-select: none; -webkit-user-select: none; cursor: col-resize; }
|
|
153
|
+
[data-stx-split-pane][data-dragging][data-direction="vertical"] { cursor: row-resize; }
|
|
154
|
+
[data-stx-split-pane][data-dragging] iframe { pointer-events: none; }
|
|
155
|
+
|
|
156
|
+
@media (prefers-reduced-motion: reduce) {
|
|
157
|
+
[data-stx-split-pane] > .stx-split-separator { transition: none; }
|
|
158
|
+
}
|
|
159
|
+
</style>
|