@astryxdesign/core 0.6.1 → 0.6.2

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 (62) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/DateRangeInput/DateRangeInput.d.ts +3 -0
  3. package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
  4. package/dist/DateRangeInput/DateRangeInput.js +16 -9
  5. package/dist/Dialog/DialogHeader.d.ts +1 -1
  6. package/dist/Dialog/DialogHeader.d.ts.map +1 -1
  7. package/dist/Dialog/DialogHeader.js +10 -7
  8. package/dist/FileInput/FileInput.d.ts.map +1 -1
  9. package/dist/FileInput/FileInput.js +9 -3
  10. package/dist/Markdown/Markdown.d.ts +10 -2
  11. package/dist/Markdown/Markdown.d.ts.map +1 -1
  12. package/dist/Markdown/Markdown.js +58 -14
  13. package/dist/Markdown/index.d.ts +1 -1
  14. package/dist/Markdown/index.d.ts.map +1 -1
  15. package/dist/Markdown/parser.d.ts +126 -12
  16. package/dist/Markdown/parser.d.ts.map +1 -1
  17. package/dist/Markdown/parser.js +369 -34
  18. package/dist/Markdown/utils.d.ts +1 -1
  19. package/dist/Markdown/utils.d.ts.map +1 -1
  20. package/dist/Slider/Slider.d.ts.map +1 -1
  21. package/dist/Slider/Slider.js +5 -2
  22. package/dist/Spinner/Spinner.d.ts +1 -1
  23. package/dist/Spinner/Spinner.d.ts.map +1 -1
  24. package/dist/Spinner/Spinner.js +23 -15
  25. package/dist/astryx.css +2 -1
  26. package/locales/en.json +16 -0
  27. package/locales/pseudo.json +12 -0
  28. package/package.json +6 -4
  29. package/scripts/agent-doc-state.mjs +1 -1
  30. package/src/DateRangeInput/DateRangeInput.doc.mjs +35 -7
  31. package/src/DateRangeInput/DateRangeInput.spec.md +203 -0
  32. package/src/DateRangeInput/DateRangeInput.test.tsx +100 -4
  33. package/src/DateRangeInput/DateRangeInput.tsx +29 -20
  34. package/src/Dialog/Dialog.doc.mjs +3 -0
  35. package/src/Dialog/Dialog.spec.md +1 -1
  36. package/src/Dialog/DialogHeader.doc.mjs +38 -0
  37. package/src/Dialog/DialogHeader.test.tsx +49 -0
  38. package/src/Dialog/DialogHeader.tsx +23 -4
  39. package/src/Dialog/modules/DialogHeader.spec.md +152 -0
  40. package/src/FileInput/FileInput.doc.mjs +2 -0
  41. package/src/FileInput/FileInput.spec.md +199 -0
  42. package/src/FileInput/FileInput.test.tsx +14 -0
  43. package/src/FileInput/FileInput.tsx +13 -3
  44. package/src/Markdown/Markdown.doc.mjs +167 -42
  45. package/src/Markdown/Markdown.public.test.ts +157 -0
  46. package/src/Markdown/Markdown.spec.md +149 -70
  47. package/src/Markdown/Markdown.test.tsx +107 -3
  48. package/src/Markdown/Markdown.tsx +116 -35
  49. package/src/Markdown/incremental.test.ts +175 -7
  50. package/src/Markdown/index.ts +6 -0
  51. package/src/Markdown/parser.perf.test.ts +3 -1
  52. package/src/Markdown/parser.test.ts +122 -0
  53. package/src/Markdown/parser.ts +609 -81
  54. package/src/Markdown/utils.ts +6 -0
  55. package/src/Slider/Slider.doc.mjs +16 -0
  56. package/src/Slider/Slider.spec.md +61 -47
  57. package/src/Slider/Slider.test.tsx +18 -0
  58. package/src/Slider/Slider.tsx +12 -6
  59. package/src/Spinner/Spinner.doc.mjs +6 -3
  60. package/src/Spinner/Spinner.test.tsx +37 -0
  61. package/src/Spinner/Spinner.tsx +31 -14
  62. package/src/theme/derivedVarRegistry.test.ts +6 -4
@@ -42,6 +42,73 @@ describe('parseInline', () => {
42
42
  expect(result).toEqual([{type: 'code', content: 'const x'}]);
43
43
  });
44
44
 
45
+ it('leaves math delimiters as literal text by default', () => {
46
+ expect(parseInline('Euler: $e^{i * pi} + 1 = 0$.')).toEqual([
47
+ {type: 'text', content: 'Euler: $e^{i * pi} + 1 = 0$.'},
48
+ ]);
49
+ });
50
+
51
+ it('parses inline math before Markdown formatting when explicitly enabled', () => {
52
+ expect(parseInline('Euler: $e^{i * pi} + 1 = 0$.', {math: true})).toEqual([
53
+ {type: 'text', content: 'Euler: '},
54
+ {type: 'math', value: 'e^{i * pi} + 1 = 0'},
55
+ {type: 'text', content: '.'},
56
+ ]);
57
+ });
58
+
59
+ it('preserves escaped delimiters inside math and leaves escaped openers literal', () => {
60
+ expect(
61
+ parseInline('Price: \\$5; formula: $x \\$ y$.', {math: true}),
62
+ ).toEqual([
63
+ {type: 'text', content: 'Price: '},
64
+ {type: 'text', content: '$5; formula: '},
65
+ {type: 'math', value: 'x \\$ y'},
66
+ {type: 'text', content: '.'},
67
+ ]);
68
+ });
69
+
70
+ it('leaves an unmatched inline math delimiter literal', () => {
71
+ expect(parseInline('The value is $x + 1.', {math: true})).toEqual([
72
+ {type: 'text', content: 'The value is $x + 1.'},
73
+ ]);
74
+ });
75
+
76
+ it('does not mistake paired currency amounts for inline math', () => {
77
+ expect(
78
+ parseInline('Tickets cost $20 and $30 today.', {math: true}),
79
+ ).toEqual([{type: 'text', content: 'Tickets cost $20 and $30 today.'}]);
80
+ expect(parseInline('$x$5 and $y$', {math: true})).toEqual([
81
+ {type: 'text', content: '$x$5 and '},
82
+ {type: 'math', value: 'y'},
83
+ ]);
84
+ });
85
+
86
+ it('allows an inline expression to begin with a number', () => {
87
+ expect(parseInline('Result: $2 + 2$.', {math: true})).toEqual([
88
+ {type: 'text', content: 'Result: '},
89
+ {type: 'math', value: '2 + 2'},
90
+ {type: 'text', content: '.'},
91
+ ]);
92
+ });
93
+
94
+ it('does not treat non-block double-dollar runs as inline math', () => {
95
+ expect(parseInline('Keep $$x + y$$ literal.', {math: true})).toEqual([
96
+ {type: 'text', content: 'Keep $$x + y$$ literal.'},
97
+ ]);
98
+ });
99
+
100
+ it('keeps code and link destinations opaque while parsing math in link labels', () => {
101
+ expect(parseInline('`$code$` [$label$](/price/$5)', {math: true})).toEqual([
102
+ {type: 'code', content: '$code$'},
103
+ {type: 'text', content: ' '},
104
+ {
105
+ type: 'link',
106
+ href: '/price/$5',
107
+ children: [{type: 'math', value: 'label'}],
108
+ },
109
+ ]);
110
+ });
111
+
45
112
  it('parses links', () => {
46
113
  const result = parseInline('[click](https://example.com)');
47
114
  expect(result[0].type).toBe('link');
@@ -270,6 +337,61 @@ describe('parseMarkdown', () => {
270
337
  }
271
338
  });
272
339
 
340
+ it('parses display math only when explicitly enabled', () => {
341
+ const source = '$$\n\\int_0^1 x^2 \\, dx\n$$';
342
+ expect(parseMarkdown(source)).not.toContainEqual({
343
+ type: 'math',
344
+ value: '\\int_0^1 x^2 \\, dx',
345
+ });
346
+ expect(parseMarkdown(source, {math: true})).toEqual([
347
+ {type: 'math', value: '\\int_0^1 x^2 \\, dx'},
348
+ ]);
349
+ });
350
+
351
+ it('parses a same-line display math block', () => {
352
+ expect(parseMarkdown('$$E = mc^2$$', {math: true})).toEqual([
353
+ {type: 'math', value: 'E = mc^2'},
354
+ ]);
355
+ });
356
+
357
+ it('keeps empty display delimiters literal', () => {
358
+ const source = '$$\n$$';
359
+ expect(parseMarkdown(source, {math: true})).toEqual(parseMarkdown(source));
360
+ });
361
+
362
+ it('leaves unmatched display math delimiters literal', () => {
363
+ const source = '$$\nx + y';
364
+ expect(parseMarkdown(source, {math: true})).toEqual(parseMarkdown(source));
365
+ });
366
+
367
+ it('leaves escaped display delimiters literal', () => {
368
+ const blocks = parseMarkdown('\\$\\$\nx + y\n\\$\\$', {math: true});
369
+ expect(blocks.some(block => block.type === 'math')).toBe(false);
370
+ });
371
+
372
+ it('reports a display-math source range including its delimiters', () => {
373
+ const source = 'Before.\n\n$$\nx + y\n$$\n\nAfter.';
374
+ const blocks = parseMarkdown(source, {math: true, sourceRanges: true});
375
+ expect(blocks[1]?.range).toEqual({start: 9, end: 20});
376
+ expect(source.slice(blocks[1].range?.start, blocks[1].range?.end)).toBe(
377
+ '$$\nx + y\n$$',
378
+ );
379
+ });
380
+
381
+ it('keeps fenced code opaque when math parsing is enabled', () => {
382
+ expect(parseMarkdown('```tex\n$x$\n$$y$$\n```', {math: true})).toEqual([
383
+ {type: 'codeblock', language: 'tex', content: '$x$\n$$y$$'},
384
+ ]);
385
+ });
386
+
387
+ it('does not collect link definitions from display math', () => {
388
+ const blocks = parseMarkdown('$$\n[x]: /not-a-link\n$$\n\n[x]', {
389
+ math: true,
390
+ });
391
+ expect(blocks[0]).toEqual({type: 'math', value: '[x]: /not-a-link'});
392
+ expect(JSON.stringify(blocks[1])).not.toContain('"type":"link"');
393
+ });
394
+
273
395
  it('parses blockquotes', () => {
274
396
  const result = parseMarkdown('> This is a quote');
275
397
  expect(result[0].type).toBe('blockquote');