@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.
- package/CHANGELOG.md +33 -0
- package/dist/DateRangeInput/DateRangeInput.d.ts +3 -0
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +16 -9
- package/dist/Dialog/DialogHeader.d.ts +1 -1
- package/dist/Dialog/DialogHeader.d.ts.map +1 -1
- package/dist/Dialog/DialogHeader.js +10 -7
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +9 -3
- package/dist/Markdown/Markdown.d.ts +10 -2
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +58 -14
- package/dist/Markdown/index.d.ts +1 -1
- package/dist/Markdown/index.d.ts.map +1 -1
- package/dist/Markdown/parser.d.ts +126 -12
- package/dist/Markdown/parser.d.ts.map +1 -1
- package/dist/Markdown/parser.js +369 -34
- package/dist/Markdown/utils.d.ts +1 -1
- package/dist/Markdown/utils.d.ts.map +1 -1
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +5 -2
- package/dist/Spinner/Spinner.d.ts +1 -1
- package/dist/Spinner/Spinner.d.ts.map +1 -1
- package/dist/Spinner/Spinner.js +23 -15
- package/dist/astryx.css +2 -1
- package/locales/en.json +16 -0
- package/locales/pseudo.json +12 -0
- package/package.json +6 -4
- package/scripts/agent-doc-state.mjs +1 -1
- package/src/DateRangeInput/DateRangeInput.doc.mjs +35 -7
- package/src/DateRangeInput/DateRangeInput.spec.md +203 -0
- package/src/DateRangeInput/DateRangeInput.test.tsx +100 -4
- package/src/DateRangeInput/DateRangeInput.tsx +29 -20
- package/src/Dialog/Dialog.doc.mjs +3 -0
- package/src/Dialog/Dialog.spec.md +1 -1
- package/src/Dialog/DialogHeader.doc.mjs +38 -0
- package/src/Dialog/DialogHeader.test.tsx +49 -0
- package/src/Dialog/DialogHeader.tsx +23 -4
- package/src/Dialog/modules/DialogHeader.spec.md +152 -0
- package/src/FileInput/FileInput.doc.mjs +2 -0
- package/src/FileInput/FileInput.spec.md +199 -0
- package/src/FileInput/FileInput.test.tsx +14 -0
- package/src/FileInput/FileInput.tsx +13 -3
- package/src/Markdown/Markdown.doc.mjs +167 -42
- package/src/Markdown/Markdown.public.test.ts +157 -0
- package/src/Markdown/Markdown.spec.md +149 -70
- package/src/Markdown/Markdown.test.tsx +107 -3
- package/src/Markdown/Markdown.tsx +116 -35
- package/src/Markdown/incremental.test.ts +175 -7
- package/src/Markdown/index.ts +6 -0
- package/src/Markdown/parser.perf.test.ts +3 -1
- package/src/Markdown/parser.test.ts +122 -0
- package/src/Markdown/parser.ts +609 -81
- package/src/Markdown/utils.ts +6 -0
- package/src/Slider/Slider.doc.mjs +16 -0
- package/src/Slider/Slider.spec.md +61 -47
- package/src/Slider/Slider.test.tsx +18 -0
- package/src/Slider/Slider.tsx +12 -6
- package/src/Spinner/Spinner.doc.mjs +6 -3
- package/src/Spinner/Spinner.test.tsx +37 -0
- package/src/Spinner/Spinner.tsx +31 -14
- package/src/theme/derivedVarRegistry.test.ts +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @xds/core
|
|
2
2
|
|
|
3
|
+
# 0.6.2
|
|
4
|
+
|
|
5
|
+
#### New Features
|
|
6
|
+
|
|
7
|
+
- Markdown: add an opt-in math renderer (#6312)
|
|
8
|
+
Supply `components.math` to parse `$…$` inline math and `$$…$$` display math. The renderer receives the delimiter-free expression as `value` and its placement as `display: 'inline' | 'block'`, so applications can connect their preferred math typesetter without preprocessing Markdown or accepting raw HTML.
|
|
9
|
+
|
|
10
|
+
Math is off unless the renderer is present. Direct parser callers can opt in with `MathParseOptions` (`{math: true}`) and incremental callers create `IncrementalParseState<true>` via `createIncrementalState<true>()`. Those overloads return `InlineNodeWithMath` or `BlockNodeWithMath`; default, legacy-set, `math: false`, and `ParseOptions`- annotated calls retain the existing `InlineNode` and `BlockNode` unions, so exhaustive consumers do not gain a case unless they opt in. Existing Markdown parsing and rendering stay unchanged by default; code stays opaque, escaped and unmatched delimiters stay literal, and inline plugins skip math. Incremental parsing preserves full-parse results when display math is nested in ordinary or task lists and blockquotes, including quote-depth transitions, with LF or CRLF and with source ranges enabled.
|
|
11
|
+
|
|
12
|
+
- DialogHeader exposes theme targets for its header gap, title/subtitle gap, and close-icon size. (#6240)
|
|
13
|
+
- Expose DateRangeInput preset theming targets (#6223)
|
|
14
|
+
- Expose the Slider interactive control as a theme target (#6225)
|
|
15
|
+
- Expose FileInput's upload icon as a mode-aware theme target (#5417)
|
|
16
|
+
- Add a `--spinner-arc-fraction` public var to Spinner, so a theme can change how much of the ring the moving arc covers (defaults to 0.375, a 135deg sweep), the same way it already retheme diameter, stroke width, and color. (#5845)
|
|
17
|
+
|
|
18
|
+
#### Fixes
|
|
19
|
+
|
|
20
|
+
- Adds the `@astryx.chatTypingIndicator.*` catalog keys so the lab ChatTypingIndicator can build its typing status from the translation runtime instead of English literals, joining names with `Intl.ListFormat` for the active locale. English output is unchanged. (#6220)
|
|
21
|
+
- Spinner: the default assistive label now comes from the translation catalog (`@astryx.spinner.loading`) instead of a literal `"Loading"` in component source, so a localized app translates the status. An explicit `aria-label` and a visible string label still take precedence, in that order. (#6217)
|
|
22
|
+
|
|
23
|
+
#### Contributors
|
|
24
|
+
|
|
25
|
+
Thanks to everyone who contributed to this release:
|
|
26
|
+
|
|
27
|
+
- @athz
|
|
28
|
+
- @cixzhang
|
|
29
|
+
- @freddymeta
|
|
30
|
+
- @HelloOjasMutreja
|
|
31
|
+
- @ksying
|
|
32
|
+
- @Kyujenius
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
3
36
|
# 0.6.1
|
|
4
37
|
|
|
5
38
|
#### New Features
|
|
@@ -119,6 +119,9 @@ export interface DateRangeInputProps extends Omit<BaseProps, 'onChange' | 'defau
|
|
|
119
119
|
minRangeSpan?: number;
|
|
120
120
|
/**
|
|
121
121
|
* Preset date ranges shown as quick-select options beside the calendar.
|
|
122
|
+
* A preset is disabled when either endpoint violates `min`, `max`, or
|
|
123
|
+
* `dateConstraints`, or when its span violates `minRangeSpan` or
|
|
124
|
+
* `maxRangeSpan`.
|
|
122
125
|
*/
|
|
123
126
|
presets?: ReadonlyArray<DateRangePreset>;
|
|
124
127
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangeInput.d.ts","sourceRoot":"","sources":["../../src/DateRangeInput/DateRangeInput.tsx"],"names":[],"mappings":"AAqCA,OAAO,EAGL,KAAK,WAAW,EAKhB,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"DateRangeInput.d.ts","sourceRoot":"","sources":["../../src/DateRangeInput/DateRangeInput.tsx"],"names":[],"mappings":"AAqCA,OAAO,EAGL,KAAK,WAAW,EAKhB,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAKrB,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAU9C,YAAY,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAE3C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,SAAS,CAAC;CAC3B;AAED,MAAM,MAAM,kBAAkB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEpD,YAAY,EACV,WAAW,IAAI,oBAAoB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,OAAO,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAEzC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;IAEnC;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAEvB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,aAAqB,EACrB,WAAW,EACX,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,eAAe,EACf,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,SAAiB,EACjB,GAAG,EACH,GAAG,EACH,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,QAAe,EACf,WAAW,EAAE,oBAAoB,EACjC,IAAI,EAAE,QAAQ,EACd,MAAM,EACN,aAA0B,EAC1B,YAAY,EACZ,cAAkB,EAClB,YAAY,EACZ,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,IAAI,EACR,EAAE,mBAAmB,+BA+RrB;yBA/Te,cAAc"}
|
|
@@ -24,6 +24,7 @@ import { Field, InputClearButton, inputWrapperStyles, inputStatusBorderStyles, i
|
|
|
24
24
|
import { Icon } from "../Icon/index.js";
|
|
25
25
|
import { Spinner } from "../Spinner/index.js";
|
|
26
26
|
import { Calendar } from "../Calendar/index.js";
|
|
27
|
+
import { useCalendarConstraints } from "../Calendar/hooks/index.js";
|
|
27
28
|
import { usePopover } from "../Popover/index.js";
|
|
28
29
|
import { useTooltip } from "../Tooltip/index.js";
|
|
29
30
|
import { mergeProps } from "../utils/index.js";
|
|
@@ -232,6 +233,13 @@ export function DateRangeInput({
|
|
|
232
233
|
dialogLabel: t('@astryx.dateRangeInput.dialogLabel'),
|
|
233
234
|
closeButtonLabel: t('@astryx.dateInput.closeCalendar')
|
|
234
235
|
});
|
|
236
|
+
const {
|
|
237
|
+
isDateDisabled
|
|
238
|
+
} = useCalendarConstraints({
|
|
239
|
+
min,
|
|
240
|
+
max,
|
|
241
|
+
dateConstraints
|
|
242
|
+
});
|
|
235
243
|
const fireChange = useCallback(newValue => {
|
|
236
244
|
if (isBusy) {
|
|
237
245
|
return;
|
|
@@ -257,10 +265,6 @@ export function DateRangeInput({
|
|
|
257
265
|
fireChange(range);
|
|
258
266
|
popover.hide();
|
|
259
267
|
}, [fireChange, popover]);
|
|
260
|
-
const handlePresetClick = useCallback(preset => {
|
|
261
|
-
fireChange(preset.getRange());
|
|
262
|
-
popover.hide();
|
|
263
|
-
}, [fireChange, popover]);
|
|
264
268
|
const handleClear = useCallback(e => {
|
|
265
269
|
e.stopPropagation();
|
|
266
270
|
fireChange(null);
|
|
@@ -362,13 +366,13 @@ export function DateRangeInput({
|
|
|
362
366
|
children: [presets && presets.length > 0 && /*#__PURE__*/_jsx("div", {
|
|
363
367
|
role: "group",
|
|
364
368
|
"aria-label": t('@astryx.dateRangeInput.presetDateRanges'),
|
|
365
|
-
...{
|
|
369
|
+
...mergeProps(themeProps('date-range-input-presets'), {
|
|
366
370
|
className: "x78zum5 xdt5ytf xzye2dw x1b2ylru xw8tdv1 x18b5jzi xl0t3rv x1d77m7x"
|
|
367
|
-
},
|
|
371
|
+
}),
|
|
368
372
|
children: presets.map(preset => {
|
|
369
373
|
const presetRange = preset.getRange();
|
|
370
374
|
const isActive = isRangeEqual(value, presetRange);
|
|
371
|
-
const isPresetDisabled = !isRangeWithinSpan(presetRange, maxRangeSpan, minRangeSpan);
|
|
375
|
+
const isPresetDisabled = !isRangeWithinSpan(presetRange, maxRangeSpan, minRangeSpan) || isDateDisabled(plainDateFromISO(presetRange.start)) || isDateDisabled(plainDateFromISO(presetRange.end));
|
|
372
376
|
return /*#__PURE__*/_jsx("button", {
|
|
373
377
|
type: "button"
|
|
374
378
|
// These presets are independent action buttons navigated by
|
|
@@ -379,8 +383,11 @@ export function DateRangeInput({
|
|
|
379
383
|
,
|
|
380
384
|
"aria-current": isActive ? 'true' : undefined,
|
|
381
385
|
disabled: isPresetDisabled,
|
|
382
|
-
onClick: () =>
|
|
383
|
-
...
|
|
386
|
+
onClick: () => handleRangeSelect(presetRange),
|
|
387
|
+
...mergeProps(themeProps('date-range-input-preset', {
|
|
388
|
+
selected: isActive ? 'selected' : null,
|
|
389
|
+
disabled: isPresetDisabled ? 'disabled' : null
|
|
390
|
+
}), stylex.props(focusOutlineStyles.focusVisible, styles.presetButton, isActive && styles.presetButtonActive, isPresetDisabled && styles.presetButtonDisabled)),
|
|
384
391
|
children: preset.label
|
|
385
392
|
}, preset.label);
|
|
386
393
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file DialogHeader.tsx
|
|
3
|
-
* @input Uses React,
|
|
3
|
+
* @input Uses React, StyleX, LayoutHeader, Button, Icon, Heading, Text, DialogContext, mergeProps, themeProps
|
|
4
4
|
* @output Exports DialogHeader component and DialogHeaderProps
|
|
5
5
|
* @position Dialog header component; used with Dialog and Layout
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogHeader.d.ts","sourceRoot":"","sources":["../../src/Dialog/DialogHeader.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAoB,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAQxD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"DialogHeader.d.ts","sourceRoot":"","sources":["../../src/Dialog/DialogHeader.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAoB,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAQxD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAyC5C,MAAM,WAAW,iBAAkB,SAAQ,SAAS,CAAC,cAAc,CAAC;IAClE,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;IAE5C;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IAEzB;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IAEvB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,IAAI,EACR,EAAE,iBAAiB,+BAmFnB;yBA/Fe,YAAY"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file DialogHeader.tsx
|
|
7
|
-
* @input Uses React,
|
|
7
|
+
* @input Uses React, StyleX, LayoutHeader, Button, Icon, Heading, Text, DialogContext, mergeProps, themeProps
|
|
8
8
|
* @output Exports DialogHeader component and DialogHeaderProps
|
|
9
9
|
* @position Dialog header component; used with Dialog and Layout
|
|
10
10
|
*
|
|
@@ -24,6 +24,8 @@ import { Button } from "../Button/index.js";
|
|
|
24
24
|
import { Icon } from "../Icon/index.js";
|
|
25
25
|
import { Heading } from "../Heading/Heading.js";
|
|
26
26
|
import { Text } from "../Text/Text.js";
|
|
27
|
+
import { mergeProps } from "../utils/index.js";
|
|
28
|
+
import { themeProps } from "../utils/themeProps.js";
|
|
27
29
|
import { useDialogContext } from "./DialogContext.js";
|
|
28
30
|
import { useTranslator } from "../i18n/index.js";
|
|
29
31
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -92,18 +94,18 @@ export function DialogHeader({
|
|
|
92
94
|
style: style,
|
|
93
95
|
...rest,
|
|
94
96
|
children: /*#__PURE__*/_jsxs("div", {
|
|
95
|
-
...{
|
|
97
|
+
...mergeProps(themeProps('dialog-header'), {
|
|
96
98
|
className: "x78zum5 x1cy8zhl x1qughib xjcht0a"
|
|
97
|
-
},
|
|
99
|
+
}),
|
|
98
100
|
children: [startContent && /*#__PURE__*/_jsx("div", {
|
|
99
101
|
...{
|
|
100
102
|
className: "x78zum5 x6s0dn4 x1txdalj x2lah0s"
|
|
101
103
|
},
|
|
102
104
|
children: startContent
|
|
103
105
|
}), /*#__PURE__*/_jsxs("div", {
|
|
104
|
-
...{
|
|
105
|
-
className: "x98rzlu xeuugli xqixskq"
|
|
106
|
-
},
|
|
106
|
+
...mergeProps(themeProps('dialog-header-title-block'), {
|
|
107
|
+
className: "x78zum5 xdt5ytf xsn7fz1 x98rzlu xeuugli xqixskq"
|
|
108
|
+
}),
|
|
107
109
|
children: [/*#__PURE__*/_jsx(Heading, {
|
|
108
110
|
ref: titleRef,
|
|
109
111
|
id: titleId,
|
|
@@ -132,7 +134,8 @@ export function DialogHeader({
|
|
|
132
134
|
tooltip: t('@astryx.dialog.close'),
|
|
133
135
|
icon: /*#__PURE__*/_jsx(Icon, {
|
|
134
136
|
icon: "close",
|
|
135
|
-
color: "inherit"
|
|
137
|
+
color: "inherit",
|
|
138
|
+
...themeProps('dialog-header-close-icon')
|
|
136
139
|
}),
|
|
137
140
|
onClick: () => {
|
|
138
141
|
onOpenChange?.(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../src/FileInput/FileInput.tsx"],"names":[],"mappings":"AAsCA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;AASlB,YAAY,EACV,WAAW,IAAI,eAAe,EAC9B,eAAe,IAAI,mBAAmB,GACvC,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAgO9C,MAAM,WAAW,cAAe,SAAQ,IAAI,CAC1C,SAAS,EACT,UAAU,GAAG,cAAc,GAAG,OAAO,CACtC;IACC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IAC5B;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC;IAChD;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IAC5B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,aAAqB,EACrB,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,UAAkB,EAClB,OAAO,EACP,QAAQ,EACR,UAAkB,EAClB,eAAe,EACf,UAAkB,EAClB,SAAiB,EACjB,MAAM,EAAE,UAAU,EAClB,aAA0B,EAC1B,WAAW,EACX,WAAW,EACX,IAAc,EACd,UAAkB,EAClB,YAAY,EACZ,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,IAAI,EACR,EAAE,cAAc,+
|
|
1
|
+
{"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../src/FileInput/FileInput.tsx"],"names":[],"mappings":"AAsCA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;AASlB,YAAY,EACV,WAAW,IAAI,eAAe,EAC9B,eAAe,IAAI,mBAAmB,GAC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W,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IAC5B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,aAAqB,EACrB,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,UAAkB,EAClB,OAAO,EACP,QAAQ,EACR,UAAkB,EAClB,eAAe,EACf,UAAkB,EAClB,SAAiB,EACjB,MAAM,EAAE,UAAU,EAClB,aAA0B,EAC1B,WAAW,EACX,WAAW,EACX,IAAc,EACd,UAAkB,EAClB,YAAY,EACZ,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,IAAI,EACR,EAAE,cAAc,+BAkbhB;yBA7ce,SAAS"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @file FileInput.tsx
|
|
7
7
|
* @input Uses React, useId, Field, Icon, Spinner, VisuallyHidden
|
|
8
|
-
* @output Exports FileInput component,
|
|
8
|
+
* @output Exports FileInput component, public types, and its root/icon theme targets
|
|
9
9
|
* @position Core implementation; consumed by index.ts, tested by FileInput.test.tsx
|
|
10
10
|
*
|
|
11
11
|
* SYNC: When modified, update these files to stay in sync:
|
|
@@ -406,7 +406,10 @@ export function FileInput({
|
|
|
406
406
|
children: [/*#__PURE__*/_jsx(Icon, {
|
|
407
407
|
icon: "arrowUp",
|
|
408
408
|
size: "md",
|
|
409
|
-
color: "secondary"
|
|
409
|
+
color: "secondary",
|
|
410
|
+
...themeProps('file-input-icon', {
|
|
411
|
+
mode
|
|
412
|
+
})
|
|
410
413
|
}), /*#__PURE__*/_jsx("span", {
|
|
411
414
|
...{
|
|
412
415
|
className: "x9ynric xjm74w1 x6pjikd xw6l6zx xv1l7n4 x2b8uid x87ps6o"
|
|
@@ -432,7 +435,10 @@ export function FileInput({
|
|
|
432
435
|
children: [/*#__PURE__*/_jsx(Icon, {
|
|
433
436
|
icon: "arrowUp",
|
|
434
437
|
size: "sm",
|
|
435
|
-
color: "secondary"
|
|
438
|
+
color: "secondary",
|
|
439
|
+
...themeProps('file-input-icon', {
|
|
440
|
+
mode
|
|
441
|
+
})
|
|
436
442
|
}), /*#__PURE__*/_jsx("span", {
|
|
437
443
|
...{
|
|
438
444
|
0: {
|
|
@@ -5,7 +5,7 @@ import type { CitationSource } from '../Citation/Citation';
|
|
|
5
5
|
/**
|
|
6
6
|
* A plugin that transforms text patterns into custom React elements
|
|
7
7
|
* inside Markdown. Applied to parsed text nodes only — code blocks,
|
|
8
|
-
* inline code, and other non-prose contexts are unaffected.
|
|
8
|
+
* inline code, math, and other non-prose contexts are unaffected.
|
|
9
9
|
*
|
|
10
10
|
* Follows Lexical's TextMatchTransformer architecture:
|
|
11
11
|
* - `pattern` for initial regex matching
|
|
@@ -38,6 +38,14 @@ export interface MarkdownComponents {
|
|
|
38
38
|
inlineCode?: React.ComponentType<{
|
|
39
39
|
children: string;
|
|
40
40
|
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Renders opt-in `$…$` and `$$…$$` math. Supplying this renderer enables
|
|
43
|
+
* math parsing; Astryx passes the raw expression and does not execute it.
|
|
44
|
+
*/
|
|
45
|
+
math?: React.ComponentType<{
|
|
46
|
+
value: string;
|
|
47
|
+
display: 'inline' | 'block';
|
|
48
|
+
}>;
|
|
41
49
|
citation?: React.ComponentType<{
|
|
42
50
|
source: CitationSource;
|
|
43
51
|
number: number;
|
|
@@ -125,7 +133,7 @@ export interface MarkdownProps extends BaseProps<HTMLElement> {
|
|
|
125
133
|
components?: Partial<MarkdownComponents>;
|
|
126
134
|
/**
|
|
127
135
|
* Plugins that transform text patterns into custom React elements.
|
|
128
|
-
* Applied to text nodes after parsing — code blocks
|
|
136
|
+
* Applied to text nodes after parsing — code blocks, inline code, and math
|
|
129
137
|
* are unaffected. Patterns are matched in order; first match wins
|
|
130
138
|
* for overlapping ranges.
|
|
131
139
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../src/Markdown/Markdown.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAgBhD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAG5C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../src/Markdown/Markdown.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAgBhD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAG5C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AA6BzD;;;;;;;;;GASG;AACH,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,KAAK,MAAM,GAAG,KAAK,CAAC;IAExE,2CAA2C;IAC3C,MAAM,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CACnE;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC;AAE5C,MAAM,WAAW,kBAAkB;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EACvB,GAAG,EACH,QAAQ,EACR,OAAiB,EACjB,OAAmB,EACnB,iBAAqB,EACrB,WAAmB,EACnB,WAAW,EACX,OAAO,EACP,aAAuB,EACvB,YAAkB,EAClB,YAAsB,EACtB,UAAU,EACV,aAAa,EACb,QAAQ,EACR,MAAM,EACN,SAAS,EACT,KAAK,EACL,aAAa,EAAE,MAAM,EACrB,GAAG,KAAK,EACT,EAAE,aAAa,GAAG,KAAK,CAAC,YAAY,CAgPpC;yBApQe,QAAQ"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file Markdown.tsx
|
|
7
|
-
* @input Markdown string, parser AST types
|
|
8
|
-
* @output Exports Markdown component and
|
|
7
|
+
* @input Markdown string, parser AST types, optional custom renderers
|
|
8
|
+
* @output Exports Markdown component, MarkdownProps, and renderer contracts
|
|
9
9
|
* @position Core implementation; renders markdown as Astryx components
|
|
10
10
|
*/
|
|
11
11
|
import { useMemo, useRef } from 'react';
|
|
@@ -42,7 +42,7 @@ import { useTranslator } from "../i18n/index.js";
|
|
|
42
42
|
/**
|
|
43
43
|
* A plugin that transforms text patterns into custom React elements
|
|
44
44
|
* inside Markdown. Applied to parsed text nodes only — code blocks,
|
|
45
|
-
* inline code, and other non-prose contexts are unaffected.
|
|
45
|
+
* inline code, math, and other non-prose contexts are unaffected.
|
|
46
46
|
*
|
|
47
47
|
* Follows Lexical's TextMatchTransformer architecture:
|
|
48
48
|
* - `pattern` for initial regex matching
|
|
@@ -336,6 +336,9 @@ function countInlineTextLength(nodes) {
|
|
|
336
336
|
case 'code':
|
|
337
337
|
len += node.content.length;
|
|
338
338
|
break;
|
|
339
|
+
case 'math':
|
|
340
|
+
len += node.value.length;
|
|
341
|
+
break;
|
|
339
342
|
case 'image':
|
|
340
343
|
len += node.alt.length;
|
|
341
344
|
break;
|
|
@@ -370,6 +373,9 @@ function countBlockTextLength(nodes) {
|
|
|
370
373
|
case 'codeblock':
|
|
371
374
|
len += node.content.length;
|
|
372
375
|
break;
|
|
376
|
+
case 'math':
|
|
377
|
+
len += node.value.length;
|
|
378
|
+
break;
|
|
373
379
|
case 'blockquote':
|
|
374
380
|
len += countBlockTextLength(node.children);
|
|
375
381
|
break;
|
|
@@ -625,6 +631,18 @@ function renderInline(node, index, onLinkClick, cursor, citationCtx, linkCompone
|
|
|
625
631
|
}, index);
|
|
626
632
|
return codeEl;
|
|
627
633
|
}
|
|
634
|
+
case 'math':
|
|
635
|
+
{
|
|
636
|
+
const MathComp = components?.math;
|
|
637
|
+
if (MathComp == null) {
|
|
638
|
+
return wrapTextWithFade(`$${node.value}$`, cursor, index);
|
|
639
|
+
}
|
|
640
|
+
cursor.offset += node.value.length;
|
|
641
|
+
return /*#__PURE__*/_jsx(MathComp, {
|
|
642
|
+
value: node.value,
|
|
643
|
+
display: "inline"
|
|
644
|
+
}, index);
|
|
645
|
+
}
|
|
628
646
|
case 'link':
|
|
629
647
|
{
|
|
630
648
|
const safeHref = sanitizeUrl(node.href);
|
|
@@ -732,6 +750,7 @@ function getElementSpacing(node, density) {
|
|
|
732
750
|
case 'paragraph':
|
|
733
751
|
return compact ? styles.spacingParagraphCompact : styles.spacingParagraphDefault;
|
|
734
752
|
case 'codeblock':
|
|
753
|
+
case 'math':
|
|
735
754
|
return compact ? styles.spacingCodeblockCompact : styles.spacingCodeblockDefault;
|
|
736
755
|
case 'blockquote':
|
|
737
756
|
return compact ? styles.spacingBlockquoteCompact : styles.spacingBlockquoteDefault;
|
|
@@ -851,6 +870,21 @@ function renderBlock(node, index, blockCount, density, headingLevelStart, onLink
|
|
|
851
870
|
})
|
|
852
871
|
}, index);
|
|
853
872
|
}
|
|
873
|
+
case 'math':
|
|
874
|
+
{
|
|
875
|
+
cursor.offset += node.value.length;
|
|
876
|
+
const MathComp = components?.math;
|
|
877
|
+
if (MathComp == null) {
|
|
878
|
+
return /*#__PURE__*/_jsx("div", {
|
|
879
|
+
role: "paragraph",
|
|
880
|
+
children: `$$${node.value}$$`
|
|
881
|
+
}, index);
|
|
882
|
+
}
|
|
883
|
+
return /*#__PURE__*/_jsx(MathComp, {
|
|
884
|
+
value: node.value,
|
|
885
|
+
display: "block"
|
|
886
|
+
}, index);
|
|
887
|
+
}
|
|
854
888
|
case 'blockquote':
|
|
855
889
|
{
|
|
856
890
|
const BlockquoteComp = components?.blockquote;
|
|
@@ -1071,21 +1105,29 @@ export function Markdown({
|
|
|
1071
1105
|
const LinkComponent = useLinkComponent();
|
|
1072
1106
|
// Derive the set of source IDs for the parser (stable across renders when sources don't change)
|
|
1073
1107
|
const sourceIds = useMemo(() => sources ? new Set(Object.keys(sources)) : undefined, [sources]);
|
|
1074
|
-
const
|
|
1108
|
+
const hasMathRenderer = components?.math != null;
|
|
1109
|
+
const legacyParseOptions = useMemo(() => ({
|
|
1075
1110
|
sourceIds,
|
|
1076
1111
|
autolink
|
|
1077
1112
|
}), [sourceIds, autolink]);
|
|
1113
|
+
const mathParseOptions = useMemo(() => ({
|
|
1114
|
+
sourceIds,
|
|
1115
|
+
autolink,
|
|
1116
|
+
math: true
|
|
1117
|
+
}), [sourceIds, autolink]);
|
|
1078
1118
|
|
|
1079
1119
|
// Smooth bursty streamed chunks into a steady character-by-character reveal.
|
|
1080
1120
|
// When not streaming, the hook returns children unchanged (no-op).
|
|
1081
1121
|
const smoothedText = useStreamingText(children, isStreaming);
|
|
1082
1122
|
const incrementalStateRef = useRef(createIncrementalState());
|
|
1083
|
-
// Reset incremental cache when
|
|
1084
|
-
// settled blocks were parsed with the previous setting.
|
|
1123
|
+
// Reset incremental cache when parser-affecting component options toggle —
|
|
1124
|
+
// cached settled blocks were parsed with the previous setting.
|
|
1085
1125
|
const prevAutolinkRef = useRef(autolink);
|
|
1086
|
-
|
|
1126
|
+
const prevMathRef = useRef(hasMathRenderer);
|
|
1127
|
+
if (prevAutolinkRef.current !== autolink || prevMathRef.current !== hasMathRenderer) {
|
|
1087
1128
|
incrementalStateRef.current = createIncrementalState();
|
|
1088
1129
|
prevAutolinkRef.current = autolink;
|
|
1130
|
+
prevMathRef.current = hasMathRenderer;
|
|
1089
1131
|
}
|
|
1090
1132
|
const blocks = useMemo(() => {
|
|
1091
1133
|
if (display === 'inline') {
|
|
@@ -1096,11 +1138,12 @@ export function Markdown({
|
|
|
1096
1138
|
incrementalStateRef.current = createIncrementalState();
|
|
1097
1139
|
return [];
|
|
1098
1140
|
}
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1141
|
+
const options = hasMathRenderer ? mathParseOptions : legacyParseOptions;
|
|
1142
|
+
const input = trimStreamingArtifacts(smoothedText, options);
|
|
1143
|
+
return hasMathRenderer ? parseMarkdownIncremental(input, incrementalStateRef.current, mathParseOptions) : parseMarkdownIncremental(input, incrementalStateRef.current, legacyParseOptions);
|
|
1101
1144
|
}
|
|
1102
|
-
return parseMarkdown(children,
|
|
1103
|
-
}, [display, smoothedText, children, isStreaming,
|
|
1145
|
+
return hasMathRenderer ? parseMarkdown(children, mathParseOptions) : parseMarkdown(children, legacyParseOptions);
|
|
1146
|
+
}, [display, smoothedText, children, isStreaming, hasMathRenderer, mathParseOptions, legacyParseOptions]);
|
|
1104
1147
|
|
|
1105
1148
|
// Assign each top-level heading the slug that parseOutlineFromMarkdown
|
|
1106
1149
|
// would derive for it, so Outline hash links built from the same source
|
|
@@ -1126,9 +1169,10 @@ export function Markdown({
|
|
|
1126
1169
|
if (display !== 'inline') {
|
|
1127
1170
|
return [];
|
|
1128
1171
|
}
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1131
|
-
|
|
1172
|
+
const options = hasMathRenderer ? mathParseOptions : legacyParseOptions;
|
|
1173
|
+
const input = isStreaming ? trimStreamingArtifacts(smoothedText, options) : children;
|
|
1174
|
+
return hasMathRenderer ? parseInline(input, mathParseOptions) : parseInline(input, legacyParseOptions);
|
|
1175
|
+
}, [display, smoothedText, children, isStreaming, hasMathRenderer, mathParseOptions, legacyParseOptions]);
|
|
1132
1176
|
|
|
1133
1177
|
// Track recent boundaries for stacked fade-in animation.
|
|
1134
1178
|
// The number of spans needed = ceil(animationDuration / tickInterval).
|
package/dist/Markdown/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
export { Markdown } from './Markdown';
|
|
7
7
|
export type { MarkdownProps, MarkdownSource, MarkdownComponents, MarkdownInlinePlugin, } from './Markdown';
|
|
8
8
|
export { parseMarkdown, parseMarkdownIncremental, createIncrementalState, parseInline, } from './parser';
|
|
9
|
-
export type { BlockNode, InlineNode, SourceRange, ListItemNode, TableCellNode, TableAlignment, IncrementalState as IncrementalParseState, } from './parser';
|
|
9
|
+
export type { BlockNode, BlockNodeWithMath, MathBlockNode, InlineNode, InlineNodeWithMath, MathInlineNode, SourceRange, ListItemNode, TableCellNode, TableAlignment, ParseOptions, MathParseOptions, IncrementalState as IncrementalParseState, } from './parser';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Markdown/index.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,YAAY,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,sBAAsB,EACtB,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,SAAS,EACT,UAAU,EACV,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,gBAAgB,IAAI,qBAAqB,GAC1C,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Markdown/index.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,YAAY,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,sBAAsB,EACtB,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,IAAI,qBAAqB,GAC1C,MAAM,UAAU,CAAC"}
|