@fusion.dev/helix-headless 0.215.3 → 0.216.0

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 (113) hide show
  1. package/api.json +1 -1
  2. package/custom-elements.json +1 -1
  3. package/dist/area-chart/root/area-chart-root.d.ts +1 -0
  4. package/dist/area-chart/root/area-chart-root.js +1 -1
  5. package/dist/bar-chart/root/bar-chart-root.d.ts +1 -0
  6. package/dist/bar-chart/root/bar-chart-root.js +1 -1
  7. package/dist/button/root/button-root.d.ts +3 -1
  8. package/dist/button/root/button-root.js +2 -1
  9. package/dist/chat/composer/chat-composer.d.ts +18 -1
  10. package/dist/chat/composer/chat-composer.js +8 -3
  11. package/dist/checkbox/root/checkbox-root.d.ts +3 -1
  12. package/dist/checkbox/root/checkbox-root.js +2 -1
  13. package/dist/code-block/highlight.d.ts +9 -0
  14. package/dist/code-block/highlight.js +39 -0
  15. package/dist/code-block/highlighter.d.ts +44 -0
  16. package/dist/code-block/highlighter.js +44 -0
  17. package/dist/code-block/index.d.ts +1 -0
  18. package/dist/code-block/index.js +1 -0
  19. package/dist/code-block/keyed-lines.d.ts +23 -0
  20. package/dist/code-block/keyed-lines.js +75 -0
  21. package/dist/code-block/root/code-block-root.d.ts +6 -23
  22. package/dist/code-block/root/code-block-root.js +8 -25
  23. package/dist/code-editor/index.d.ts +1 -0
  24. package/dist/code-editor/index.js +1 -0
  25. package/dist/code-editor/root/code-editor-root.d.ts +367 -0
  26. package/dist/code-editor/root/code-editor-root.js +746 -0
  27. package/dist/code-input/index.d.ts +1 -0
  28. package/dist/code-input/index.js +1 -0
  29. package/dist/code-input/root/code-input-root.d.ts +119 -0
  30. package/dist/code-input/root/code-input-root.js +142 -0
  31. package/dist/combobox/root/combobox-root.d.ts +6 -1
  32. package/dist/combobox/root/combobox-root.js +4 -2
  33. package/dist/command/root/command-root.d.ts +61 -11
  34. package/dist/command/root/command-root.js +88 -3
  35. package/dist/donut-chart/root/donut-chart-root.d.ts +1 -0
  36. package/dist/donut-chart/root/donut-chart-root.js +1 -1
  37. package/dist/element-events.generated.js +36 -3
  38. package/dist/filter-input/root/filter-input-root.d.ts +9 -1
  39. package/dist/filter-input/root/filter-input-root.js +7 -3
  40. package/dist/heatmap/root/heatmap-root.d.ts +1 -0
  41. package/dist/heatmap/root/heatmap-root.js +1 -1
  42. package/dist/index.d.ts +4 -0
  43. package/dist/index.js +4 -0
  44. package/dist/input/root/input-root.d.ts +14 -2
  45. package/dist/input/root/input-root.js +11 -3
  46. package/dist/kbd/root/kbd-root.js +9 -2
  47. package/dist/line-chart/root/line-chart-root.d.ts +1 -0
  48. package/dist/line-chart/root/line-chart-root.js +1 -1
  49. package/dist/listbox/root/listbox-root.d.ts +8 -1
  50. package/dist/listbox/root/listbox-root.js +7 -4
  51. package/dist/markdown/blocks.d.ts +66 -0
  52. package/dist/markdown/blocks.js +326 -0
  53. package/dist/markdown/index.d.ts +6 -0
  54. package/dist/markdown/index.js +5 -0
  55. package/dist/markdown/inline.d.ts +57 -0
  56. package/dist/markdown/inline.js +483 -0
  57. package/dist/markdown/root/markdown-root.d.ts +99 -0
  58. package/dist/markdown/root/markdown-root.js +93 -0
  59. package/dist/markdown/stream.d.ts +47 -0
  60. package/dist/markdown/stream.js +62 -0
  61. package/dist/markdown/tree.d.ts +57 -0
  62. package/dist/markdown/tree.js +144 -0
  63. package/dist/markdown/writer.d.ts +33 -0
  64. package/dist/markdown/writer.js +139 -0
  65. package/dist/menu/root/menu-root.d.ts +53 -0
  66. package/dist/menu/root/menu-root.js +92 -15
  67. package/dist/pagination/size/pagination-size.d.ts +3 -0
  68. package/dist/pagination/size/pagination-size.js +2 -1
  69. package/dist/scatter-chart/root/scatter-chart-root.d.ts +1 -0
  70. package/dist/scatter-chart/root/scatter-chart-root.js +1 -1
  71. package/dist/select/root/select-root.d.ts +6 -1
  72. package/dist/select/root/select-root.js +4 -2
  73. package/dist/shortcut-overlay/index.d.ts +1 -0
  74. package/dist/shortcut-overlay/index.js +1 -0
  75. package/dist/shortcut-overlay/root/shortcut-overlay-root.d.ts +128 -0
  76. package/dist/shortcut-overlay/root/shortcut-overlay-root.js +275 -0
  77. package/dist/slider/root/slider-root.d.ts +3 -1
  78. package/dist/slider/root/slider-root.js +2 -1
  79. package/dist/spatial-bar-chart/root/spatial-bar-chart-root.d.ts +1 -0
  80. package/dist/spatial-bar-chart/root/spatial-bar-chart-root.js +1 -1
  81. package/dist/spatial-heatmap/root/spatial-heatmap-root.d.ts +1 -0
  82. package/dist/spatial-heatmap/root/spatial-heatmap-root.js +1 -1
  83. package/dist/spatial-ribbon-chart/root/spatial-ribbon-chart-root.d.ts +1 -0
  84. package/dist/spatial-ribbon-chart/root/spatial-ribbon-chart-root.js +1 -1
  85. package/dist/spatial-scatter-chart/root/spatial-scatter-chart-root.d.ts +1 -0
  86. package/dist/spatial-scatter-chart/root/spatial-scatter-chart-root.js +1 -1
  87. package/dist/spatial-surface-chart/root/spatial-surface-chart-root.d.ts +1 -0
  88. package/dist/spatial-surface-chart/root/spatial-surface-chart-root.js +1 -1
  89. package/dist/spatial-treemap/root/spatial-treemap-root.d.ts +1 -0
  90. package/dist/spatial-treemap/root/spatial-treemap-root.js +1 -1
  91. package/dist/switch/root/switch-root.d.ts +3 -1
  92. package/dist/switch/root/switch-root.js +2 -1
  93. package/dist/tabs/tab/tab.d.ts +3 -1
  94. package/dist/tabs/tab/tab.js +2 -1
  95. package/dist/textarea/root/textarea-root.d.ts +20 -4
  96. package/dist/textarea/root/textarea-root.js +31 -23
  97. package/dist/time-input/root/time-input-root.d.ts +6 -0
  98. package/dist/time-input/root/time-input-root.js +4 -2
  99. package/dist/time-picker/root/time-picker-root.d.ts +6 -0
  100. package/dist/time-picker/root/time-picker-root.js +4 -2
  101. package/dist/toast/root/toast-root.d.ts +64 -0
  102. package/dist/toast/root/toast-root.js +128 -3
  103. package/dist/toggle/root/toggle-root.d.ts +3 -1
  104. package/dist/toggle/root/toggle-root.js +2 -1
  105. package/dist/virtual-list/root/virtual-list-root.d.ts +18 -2
  106. package/dist/virtual-list/root/virtual-list-root.js +103 -5
  107. package/examples.json +1 -1
  108. package/lint.json +1 -1
  109. package/package.json +6 -6
  110. package/types/jsx.d.ts +5315 -596
  111. package/types/svelte.d.ts +4 -0
  112. package/types/vue.d.ts +1085 -4
  113. package/types/words.d.ts +491 -0
@@ -0,0 +1,326 @@
1
+ const BLANK = /^[ \t]*$/;
2
+ const FENCE = /^( {0,3})(`{3,}|~{3,})(.*)$/;
3
+ const HEADING = /^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/;
4
+ const RULE = /^ {0,3}(?:(?:\*[ \t]*){3,}|(?:-[ \t]*){3,}|(?:_[ \t]*){3,})$/;
5
+ const QUOTE = /^ {0,3}> ?/;
6
+ const MARKER = /^( {0,3})([-+*]|(\d{1,9})([.)]))(?=[ \t]|$)([ \t]*)(.*)$/;
7
+ const DELIMITER = /^:?-+:?$/;
8
+ const ALERT = /^\[!(caution|important|note|tip|warning)\][ \t]*$/i;
9
+ const TASK = /^\[([ xX])\](?:[ \t]+|$)/;
10
+ const blank = (line) => BLANK.test(line);
11
+ export const indentOf = (line) => {
12
+ let columns = 0;
13
+ for (const character of line) {
14
+ if (character === ' ') {
15
+ columns += 1;
16
+ }
17
+ else if (character === '\t') {
18
+ columns += 4 - (columns % 4);
19
+ }
20
+ else {
21
+ break;
22
+ }
23
+ }
24
+ return columns;
25
+ };
26
+ const stripIndent = (line, columns) => {
27
+ let taken = 0;
28
+ let at = 0;
29
+ while (at < line.length && taken < columns) {
30
+ const character = line[at];
31
+ if (character === ' ') {
32
+ taken += 1;
33
+ }
34
+ else if (character === '\t') {
35
+ const width = 4 - (taken % 4);
36
+ if (taken + width > columns) {
37
+ return ' '.repeat(taken + width - columns) + line.slice(at + 1);
38
+ }
39
+ taken += width;
40
+ }
41
+ else {
42
+ break;
43
+ }
44
+ at += 1;
45
+ }
46
+ return line.slice(at);
47
+ };
48
+ const markerOf = (line) => {
49
+ const match = MARKER.exec(line);
50
+ if (!match) {
51
+ return undefined;
52
+ }
53
+ const [, lead = '', marker = '', digits, delimiter, gap = '', rest = ''] = match;
54
+ const width = lead.length + marker.length;
55
+ const spaces = indentOf(`${' '.repeat(width)}${gap}`) - width;
56
+ const content = rest === '' || spaces > 4 ? width + 1 : width + spaces;
57
+ return {
58
+ bullet: delimiter ?? marker,
59
+ content,
60
+ number: digits === undefined ? undefined : Number(digits),
61
+ rest: spaces > 4 ? `${' '.repeat(spaces - 1)}${rest}` : rest,
62
+ };
63
+ };
64
+ export const cellsOf = (line) => {
65
+ let row = line.trim();
66
+ if (row.startsWith('|')) {
67
+ row = row.slice(1);
68
+ }
69
+ if (row.endsWith('|') && !row.endsWith('\\|')) {
70
+ row = row.slice(0, -1);
71
+ }
72
+ const cells = [];
73
+ let cell = '';
74
+ for (let at = 0; at < row.length; at += 1) {
75
+ const character = row[at];
76
+ if (character === '\\' && row[at + 1] === '|') {
77
+ cell += '|';
78
+ at += 1;
79
+ }
80
+ else if (character === '|') {
81
+ cells.push(cell.trim());
82
+ cell = '';
83
+ }
84
+ else {
85
+ cell += character;
86
+ }
87
+ }
88
+ cells.push(cell.trim());
89
+ return cells;
90
+ };
91
+ const delimiterOf = (line, count) => {
92
+ if (line === undefined || !line.includes('-') || indentOf(line) > 3) {
93
+ return undefined;
94
+ }
95
+ const cells = cellsOf(line);
96
+ if (cells.length !== count || !cells.every((cell) => DELIMITER.test(cell))) {
97
+ return undefined;
98
+ }
99
+ return cells.map((cell) => {
100
+ const left = cell.startsWith(':');
101
+ const right = cell.endsWith(':');
102
+ return left && right ? 'center' : right ? 'end' : left ? 'start' : undefined;
103
+ });
104
+ };
105
+ const startsTable = (line, next) => line.includes('|') && indentOf(line) < 4 && delimiterOf(next, cellsOf(line).length) !== undefined;
106
+ const interrupts = (line) => {
107
+ if (indentOf(line) > 3) {
108
+ return false;
109
+ }
110
+ if (FENCE.test(line) || HEADING.test(line) || RULE.test(line) || QUOTE.test(line)) {
111
+ return true;
112
+ }
113
+ const marker = markerOf(line);
114
+ return marker !== undefined && marker.rest.trim() !== '' && (marker.number ?? 1) === 1;
115
+ };
116
+ const endsInParagraph = (blocks) => {
117
+ const last = blocks.at(-1);
118
+ if (last?.kind === 'paragraph') {
119
+ return true;
120
+ }
121
+ if (last?.kind === 'quote') {
122
+ return endsInParagraph(last.children);
123
+ }
124
+ if (last?.kind === 'list') {
125
+ return endsInParagraph(last.items.at(-1)?.children ?? []);
126
+ }
127
+ return false;
128
+ };
129
+ const lazy = (inner, line, next) => !blank(line) &&
130
+ !interrupts(line) &&
131
+ !startsTable(line, next) &&
132
+ inner.length > 0 &&
133
+ !blank(inner.at(-1) ?? '') &&
134
+ endsInParagraph(parseBlocks(inner).blocks);
135
+ const readFence = (lines, at) => {
136
+ const match = FENCE.exec(lines[at] ?? '');
137
+ const indent = (match[1] ?? '').length;
138
+ const fence = match[2] ?? '```';
139
+ const info = (match[3] ?? '').trim();
140
+ const closing = new RegExp(`^ {0,3}${fence[0] === '`' ? '`' : '~'}{${fence.length},}[ \\t]*$`);
141
+ const body = [];
142
+ let line = at + 1;
143
+ let open = true;
144
+ while (line < lines.length) {
145
+ const text = lines[line] ?? '';
146
+ line += 1;
147
+ if (closing.test(text)) {
148
+ open = false;
149
+ break;
150
+ }
151
+ body.push(stripIndent(text, indent));
152
+ }
153
+ return [{ info, kind: 'code', open, text: body.join('\n') }, line];
154
+ };
155
+ const readQuote = (lines, at) => {
156
+ const inner = [];
157
+ let line = at;
158
+ while (line < lines.length) {
159
+ const text = lines[line] ?? '';
160
+ const marker = QUOTE.exec(text);
161
+ if (marker && indentOf(text) < 4) {
162
+ inner.push(text.slice(marker[0].length));
163
+ }
164
+ else if (lazy(inner, text, lines[line + 1])) {
165
+ inner.push(text);
166
+ }
167
+ else {
168
+ break;
169
+ }
170
+ line += 1;
171
+ }
172
+ const children = parseBlocks(inner).blocks;
173
+ const first = children[0];
174
+ const firstLine = first?.kind === 'paragraph' ? (first.text.split('\n')[0] ?? '') : '';
175
+ const alert = ALERT.exec(firstLine.trim());
176
+ if (alert && first?.kind === 'paragraph') {
177
+ const rest = first.text.split('\n').slice(1).join('\n');
178
+ return [
179
+ {
180
+ alert: (alert[1] ?? 'note').toLowerCase(),
181
+ children: rest.trim() === ''
182
+ ? children.slice(1)
183
+ : [{ kind: 'paragraph', text: rest }, ...children.slice(1)],
184
+ kind: 'quote',
185
+ },
186
+ line,
187
+ ];
188
+ }
189
+ return [{ children, kind: 'quote' }, line];
190
+ };
191
+ const readList = (lines, at) => {
192
+ const first = markerOf(lines[at] ?? '');
193
+ const ordered = first.number !== undefined;
194
+ const items = [];
195
+ let line = at;
196
+ while (line < lines.length) {
197
+ const marker = markerOf(lines[line] ?? '');
198
+ if (!marker || marker.bullet !== first.bullet || indentOf(lines[line] ?? '') > 3) {
199
+ break;
200
+ }
201
+ const inner = [marker.rest];
202
+ line += 1;
203
+ while (line < lines.length) {
204
+ const text = lines[line] ?? '';
205
+ if (blank(text)) {
206
+ let ahead = line;
207
+ while (ahead < lines.length && blank(lines[ahead] ?? '')) {
208
+ ahead += 1;
209
+ }
210
+ if (ahead < lines.length && indentOf(lines[ahead] ?? '') >= marker.content) {
211
+ inner.push('');
212
+ line += 1;
213
+ continue;
214
+ }
215
+ break;
216
+ }
217
+ if (indentOf(text) >= marker.content) {
218
+ inner.push(stripIndent(text, marker.content));
219
+ }
220
+ else if (!markerOf(text) && lazy(inner, text, lines[line + 1])) {
221
+ inner.push(text);
222
+ }
223
+ else {
224
+ break;
225
+ }
226
+ line += 1;
227
+ }
228
+ const task = TASK.exec(inner[0] ?? '');
229
+ if (task) {
230
+ inner[0] = (inner[0] ?? '').slice(task[0].length);
231
+ }
232
+ const item = { children: parseBlocks(inner).blocks };
233
+ if (task) {
234
+ item.checked = task[1] !== ' ';
235
+ }
236
+ items.push(item);
237
+ let ahead = line;
238
+ while (ahead < lines.length && blank(lines[ahead] ?? '')) {
239
+ ahead += 1;
240
+ }
241
+ const next = markerOf(lines[ahead] ?? '');
242
+ if (ahead === line || !next || next.bullet !== first.bullet) {
243
+ if (ahead === line) {
244
+ continue;
245
+ }
246
+ break;
247
+ }
248
+ line = ahead;
249
+ }
250
+ return [{ items, kind: 'list', ordered, start: first.number ?? 1 }, line];
251
+ };
252
+ const readTable = (lines, at) => {
253
+ const head = cellsOf(lines[at] ?? '');
254
+ const align = delimiterOf(lines[at + 1], head.length) ?? [];
255
+ const rows = [];
256
+ let line = at + 2;
257
+ while (line < lines.length) {
258
+ const text = lines[line] ?? '';
259
+ if (blank(text) || interrupts(text)) {
260
+ break;
261
+ }
262
+ const cells = cellsOf(text);
263
+ rows.push(head.map((_, column) => cells[column] ?? ''));
264
+ line += 1;
265
+ }
266
+ return [{ align, head, kind: 'table', rows }, line];
267
+ };
268
+ const readParagraph = (lines, at) => {
269
+ const body = [(lines[at] ?? '').replace(/^[ \t]+/, '')];
270
+ let line = at + 1;
271
+ while (line < lines.length) {
272
+ const text = lines[line] ?? '';
273
+ if (blank(text) || interrupts(text) || startsTable(text, lines[line + 1])) {
274
+ break;
275
+ }
276
+ body.push(text.replace(/^[ \t]+/, ''));
277
+ line += 1;
278
+ }
279
+ return [{ kind: 'paragraph', text: body.join('\n').replace(/[ \t]+$/, '') }, line];
280
+ };
281
+ export const parseBlocks = (lines) => {
282
+ const blocks = [];
283
+ const starts = [];
284
+ let line = 0;
285
+ while (line < lines.length) {
286
+ const text = lines[line] ?? '';
287
+ if (blank(text)) {
288
+ line += 1;
289
+ continue;
290
+ }
291
+ starts.push(line);
292
+ let read;
293
+ if (indentOf(text) > 3) {
294
+ read = readParagraph(lines, line);
295
+ }
296
+ else if (FENCE.test(text) &&
297
+ !(text.trimStart().startsWith('`') && /`/.test(FENCE.exec(text)?.[3] ?? ''))) {
298
+ read = readFence(lines, line);
299
+ }
300
+ else if (HEADING.test(text)) {
301
+ const match = HEADING.exec(text);
302
+ read = [
303
+ { kind: 'heading', level: (match[1] ?? '#').length, text: (match[2] ?? '').trim() },
304
+ line + 1,
305
+ ];
306
+ }
307
+ else if (RULE.test(text)) {
308
+ read = [{ kind: 'rule' }, line + 1];
309
+ }
310
+ else if (QUOTE.test(text)) {
311
+ read = readQuote(lines, line);
312
+ }
313
+ else if (markerOf(text)) {
314
+ read = readList(lines, line);
315
+ }
316
+ else if (startsTable(text, lines[line + 1])) {
317
+ read = readTable(lines, line);
318
+ }
319
+ else {
320
+ read = readParagraph(lines, line);
321
+ }
322
+ blocks.push(read[0]);
323
+ line = read[1];
324
+ }
325
+ return { blocks, starts };
326
+ };
@@ -0,0 +1,6 @@
1
+ export type { MarkdownAlertKind, MarkdownAlign, MarkdownBlock, MarkdownItem } from './blocks.js';
2
+ export { type InlineOptions, type MarkdownInline, parseInline } from './inline.js';
3
+ export * from './root/markdown-root.js';
4
+ export { type MarkdownRead, MarkdownStream, visibleText } from './stream.js';
5
+ export { type MarkdownElement, type MarkdownNode, type MarkdownOptions, type MarkdownTags, markdownNodes, markdownToHtml, safeUrl, } from './tree.js';
6
+ export { MarkdownWriter } from './writer.js';
@@ -0,0 +1,5 @@
1
+ export { parseInline } from './inline.js';
2
+ export * from './root/markdown-root.js';
3
+ export { MarkdownStream, visibleText } from './stream.js';
4
+ export { markdownNodes, markdownToHtml, safeUrl, } from './tree.js';
5
+ export { MarkdownWriter } from './writer.js';
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Markdown's inline marks: code, emphasis, strong, strikethrough, links,
3
+ * images, autolinks, and line breaks, by CommonMark's delimiter rules and
4
+ * GitHub's extensions.
5
+ *
6
+ * **An open block is read as if it ended where the text so far ends.** While a
7
+ * reply streams, the last block is still arriving, and reading `**bold` as
8
+ * two asterisks would draw them and then take them back when the closing pair
9
+ * arrives, moving every word after them. So in an open block:
10
+ *
11
+ * - an opening delimiter with no closer yet is drawn as if it closed at the end,
12
+ * - a delimiter run, a backslash, a `!`, or part of an entity or an autolink at
13
+ * the very end is held back, since the next character decides what it is,
14
+ * - a code span with no closing backticks yet runs to the end,
15
+ * - a link whose `]` or `)` has not arrived drops its brackets and its address
16
+ * and draws its text as a link with no address yet.
17
+ *
18
+ * Once a block closes it is read strictly, so a mark that never closed is
19
+ * drawn as the characters it is. That is the one change a closed block can
20
+ * see, and only text that was never valid Markdown makes it.
21
+ */
22
+ /** An inline node. */
23
+ export type MarkdownInline = {
24
+ kind: 'break';
25
+ } | {
26
+ kind: 'code';
27
+ text: string;
28
+ } | {
29
+ children: MarkdownInline[];
30
+ kind: 'del' | 'em' | 'strong';
31
+ } | {
32
+ alt: string;
33
+ kind: 'image';
34
+ src: string;
35
+ title?: string;
36
+ } | {
37
+ children: MarkdownInline[];
38
+ href?: string;
39
+ kind: 'link';
40
+ title?: string;
41
+ } | {
42
+ kind: 'text';
43
+ text: string;
44
+ };
45
+ /** How the text is read: strictly, or as the open end of a block still arriving. */
46
+ export interface InlineOptions {
47
+ open?: boolean | undefined;
48
+ }
49
+ /**
50
+ * The text's inline nodes.
51
+ *
52
+ * With `open`, the end of the text is read as the end of a block still
53
+ * arriving, as the module's description sets out.
54
+ */
55
+ export declare const parseInline: (text: string, options?: InlineOptions) => MarkdownInline[];
56
+ /** The plain text of some inline nodes, as an image's alternative text reads it. */
57
+ export declare const textOf: (nodes: MarkdownInline[]) => string;