@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.
Files changed (139) hide show
  1. package/dist/CodeEditor-jg4w7e15.stx +497 -0
  2. package/dist/ContextMenu-43g3w5tp.stx +188 -0
  3. package/dist/DataGrid-7rt7v865.stx +376 -0
  4. package/dist/GraphView-0t3t9mec.stx +320 -0
  5. package/dist/JsonTree-satc4010.stx +317 -0
  6. package/dist/PreviewFrame-erbgvzj8.stx +257 -0
  7. package/dist/SplitPane-7sqfdwqa.stx +159 -0
  8. package/dist/code-editor/editor.js +2166 -0
  9. package/dist/component-api/component-api.js +36 -0
  10. package/dist/components/CodeBlock.d.ts +12 -5
  11. package/dist/context-menu/context-menu.js +575 -0
  12. package/dist/data-grid/data-grid.js +1244 -0
  13. package/dist/graph-view/graph-view.js +1408 -0
  14. package/dist/index.d.ts +10 -0
  15. package/dist/index.js +34 -15
  16. package/dist/json-tree/json-tree.js +1121 -0
  17. package/dist/preview-frame/preview-frame.js +356 -0
  18. package/dist/split-pane/split-pane.js +364 -0
  19. package/dist/ui/code-editor/CodeEditor.d.ts +46 -0
  20. package/dist/ui/code-editor/controller.d.ts +103 -0
  21. package/dist/ui/code-editor/core/commands.d.ts +55 -0
  22. package/dist/ui/code-editor/core/completion.d.ts +40 -0
  23. package/dist/ui/code-editor/core/editor.d.ts +69 -0
  24. package/dist/ui/code-editor/core/highlight.d.ts +61 -0
  25. package/dist/ui/code-editor/core/history.d.ts +27 -0
  26. package/dist/ui/code-editor/core/index.d.ts +13 -0
  27. package/dist/ui/code-editor/core/keymap.d.ts +38 -0
  28. package/dist/ui/code-editor/core/selection.d.ts +30 -0
  29. package/dist/ui/code-editor/core/text.d.ts +64 -0
  30. package/dist/ui/code-editor/editor.d.ts +15 -0
  31. package/dist/ui/code-editor/index.d.ts +29 -0
  32. package/dist/ui/code-editor/tokenizer.d.ts +18 -0
  33. package/dist/ui/code-editor/view.d.ts +59 -0
  34. package/dist/ui/context-menu/ContextMenu.d.ts +14 -0
  35. package/dist/ui/context-menu/context-menu.d.ts +8 -0
  36. package/dist/ui/context-menu/core.d.ts +74 -0
  37. package/dist/ui/context-menu/index.d.ts +11 -0
  38. package/dist/ui/context-menu/view.d.ts +36 -0
  39. package/dist/ui/data-grid/DataGrid.d.ts +30 -0
  40. package/dist/ui/data-grid/core.d.ts +141 -0
  41. package/dist/ui/data-grid/data-grid.d.ts +9 -0
  42. package/dist/ui/data-grid/index.d.ts +20 -0
  43. package/dist/ui/data-grid/view.d.ts +56 -0
  44. package/dist/ui/graph-view/GraphView.d.ts +21 -0
  45. package/dist/ui/graph-view/core/edges.d.ts +34 -0
  46. package/dist/ui/graph-view/core/force.d.ts +10 -0
  47. package/dist/ui/graph-view/core/graph.d.ts +83 -0
  48. package/dist/ui/graph-view/core/index.d.ts +5 -0
  49. package/dist/ui/graph-view/core/layered.d.ts +24 -0
  50. package/dist/ui/graph-view/core/viewport.d.ts +34 -0
  51. package/dist/ui/graph-view/graph-view.d.ts +9 -0
  52. package/dist/ui/graph-view/index.d.ts +21 -0
  53. package/dist/ui/graph-view/view.d.ts +51 -0
  54. package/dist/ui/json-tree/JsonTree.d.ts +18 -0
  55. package/dist/ui/json-tree/core.d.ts +108 -0
  56. package/dist/ui/json-tree/index.d.ts +18 -0
  57. package/dist/ui/json-tree/json-tree.d.ts +10 -0
  58. package/dist/ui/json-tree/tinker.d.ts +84 -0
  59. package/dist/ui/json-tree/view.d.ts +59 -0
  60. package/dist/ui/preview-frame/PreviewFrame.d.ts +44 -0
  61. package/dist/ui/preview-frame/core.d.ts +81 -0
  62. package/dist/ui/preview-frame/index.d.ts +19 -0
  63. package/dist/ui/preview-frame/preview-frame.d.ts +8 -0
  64. package/dist/ui/preview-frame/view.d.ts +37 -0
  65. package/dist/ui/split-pane/SplitPane.d.ts +18 -0
  66. package/dist/ui/split-pane/core.d.ts +58 -0
  67. package/dist/ui/split-pane/index.d.ts +15 -0
  68. package/dist/ui/split-pane/split-pane.d.ts +8 -0
  69. package/dist/ui/split-pane/view.d.ts +27 -0
  70. package/dist/ui/virtual-table/index.d.ts +6 -0
  71. package/dist/utils/component-api.d.ts +4 -0
  72. package/dist/utils/highlighter.d.ts +19 -1
  73. package/dist/utils/highlighter.js +24 -7
  74. package/dist/utils/syntax-theme.d.ts +44 -0
  75. package/package.json +44 -4
  76. package/src/components/CodeBlock.stx +195 -17
  77. package/src/index.ts +10 -0
  78. package/src/ui/code-editor/CodeEditor.stx +497 -0
  79. package/src/ui/code-editor/README.md +135 -0
  80. package/src/ui/code-editor/controller.ts +517 -0
  81. package/src/ui/code-editor/core/commands.ts +381 -0
  82. package/src/ui/code-editor/core/completion.ts +212 -0
  83. package/src/ui/code-editor/core/editor.ts +319 -0
  84. package/src/ui/code-editor/core/highlight.ts +203 -0
  85. package/src/ui/code-editor/core/history.ts +190 -0
  86. package/src/ui/code-editor/core/index.ts +14 -0
  87. package/src/ui/code-editor/core/keymap.ts +125 -0
  88. package/src/ui/code-editor/core/selection.ts +104 -0
  89. package/src/ui/code-editor/core/text.ts +252 -0
  90. package/src/ui/code-editor/editor.ts +16 -0
  91. package/src/ui/code-editor/index.ts +46 -0
  92. package/src/ui/code-editor/tokenizer.ts +74 -0
  93. package/src/ui/code-editor/view.ts +1066 -0
  94. package/src/ui/context-menu/ContextMenu.stx +188 -0
  95. package/src/ui/context-menu/README.md +117 -0
  96. package/src/ui/context-menu/context-menu.ts +8 -0
  97. package/src/ui/context-menu/core.ts +250 -0
  98. package/src/ui/context-menu/index.ts +16 -0
  99. package/src/ui/context-menu/view.ts +540 -0
  100. package/src/ui/data-grid/DataGrid.stx +376 -0
  101. package/src/ui/data-grid/README.md +204 -0
  102. package/src/ui/data-grid/core.ts +813 -0
  103. package/src/ui/data-grid/data-grid.ts +9 -0
  104. package/src/ui/data-grid/index.ts +34 -0
  105. package/src/ui/data-grid/view.ts +806 -0
  106. package/src/ui/graph-view/GraphView.stx +320 -0
  107. package/src/ui/graph-view/README.md +210 -0
  108. package/src/ui/graph-view/core/edges.ts +180 -0
  109. package/src/ui/graph-view/core/force.ts +237 -0
  110. package/src/ui/graph-view/core/graph.ts +277 -0
  111. package/src/ui/graph-view/core/index.ts +5 -0
  112. package/src/ui/graph-view/core/layered.ts +256 -0
  113. package/src/ui/graph-view/core/viewport.ts +141 -0
  114. package/src/ui/graph-view/graph-view.ts +9 -0
  115. package/src/ui/graph-view/index.ts +35 -0
  116. package/src/ui/graph-view/view.ts +809 -0
  117. package/src/ui/json-tree/JsonTree.stx +317 -0
  118. package/src/ui/json-tree/README.md +193 -0
  119. package/src/ui/json-tree/core.ts +588 -0
  120. package/src/ui/json-tree/index.ts +28 -0
  121. package/src/ui/json-tree/json-tree.ts +10 -0
  122. package/src/ui/json-tree/tinker.ts +349 -0
  123. package/src/ui/json-tree/view.ts +665 -0
  124. package/src/ui/preview-frame/PreviewFrame.stx +257 -0
  125. package/src/ui/preview-frame/README.md +107 -0
  126. package/src/ui/preview-frame/core.ts +195 -0
  127. package/src/ui/preview-frame/index.ts +31 -0
  128. package/src/ui/preview-frame/preview-frame.ts +8 -0
  129. package/src/ui/preview-frame/view.ts +336 -0
  130. package/src/ui/split-pane/README.md +87 -0
  131. package/src/ui/split-pane/SplitPane.stx +159 -0
  132. package/src/ui/split-pane/core.ts +200 -0
  133. package/src/ui/split-pane/index.ts +24 -0
  134. package/src/ui/split-pane/split-pane.ts +8 -0
  135. package/src/ui/split-pane/view.ts +305 -0
  136. package/src/ui/virtual-table/index.ts +6 -0
  137. package/src/utils/component-api.ts +72 -0
  138. package/src/utils/highlighter.ts +121 -218
  139. 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>