@mechane-ai/elements 0.44.0 → 0.46.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 (117) hide show
  1. package/README.md +48 -18
  2. package/bin/mechane-elements-catalog.mjs +42 -4
  3. package/dist/ai.js +268 -202
  4. package/dist/catalog.json +95 -31
  5. package/dist/categorical-values-BXi-rJuv.js +74 -0
  6. package/dist/chart-cursor-1mFd48Jc.js +23 -0
  7. package/dist/chart-data-CIJVWCYt.js +21 -0
  8. package/dist/chart-frame-BaxKn_MB.js +236 -0
  9. package/dist/{chart-input-B6_HXFDP.js → chart-input-Bm82_9Rd.js} +2 -2
  10. package/dist/chart-theme-4zprJ3rW.js +404 -0
  11. package/dist/charts/cartesian.js +1624 -1442
  12. package/dist/charts/distribution.js +486 -409
  13. package/dist/charts/graph.js +383 -358
  14. package/dist/charts/hierarchy.js +103 -94
  15. package/dist/charts/matrix.js +340 -333
  16. package/dist/charts/timeline.js +167 -134
  17. package/dist/charts.js +3 -3
  18. package/dist/{code-block-Cpfr7B6a.js → code-block-DioAM2bZ.js} +67 -52
  19. package/dist/collections.js +1648 -1188
  20. package/dist/{constants.stylex-CaVa9yGN.js → constants.stylex-CqhVl0uU.js} +9 -9
  21. package/dist/content/code.js +1 -1
  22. package/dist/content/diff.js +67 -66
  23. package/dist/content/link.js +1 -1
  24. package/dist/content/markdown.js +2 -2
  25. package/dist/content/tree.js +3 -3
  26. package/dist/{content-link-CGeFFb9F.js → content-link-NWuHp5rC.js} +1 -1
  27. package/dist/content.js +1 -1
  28. package/dist/csp.js +6 -11
  29. package/dist/feedback.js +1 -1
  30. package/dist/forms/dates.js +274 -214
  31. package/dist/{forms-DeU0Tiv3.js → forms-CEbwzlRR.js} +50 -41
  32. package/dist/forms.js +3 -3
  33. package/dist/index.js +1 -1
  34. package/dist/layout.js +207 -207
  35. package/dist/navigation.js +4 -3
  36. package/dist/packages/ai/src/conversation.d.ts +2 -0
  37. package/dist/packages/ai/src/prompt-input.d.ts +7 -2
  38. package/dist/packages/charts/src/cartesian/composition-bars.d.ts +2 -2
  39. package/dist/packages/charts/src/cartesian/index.d.ts +3 -2
  40. package/dist/packages/charts/src/cartesian/scatter-plot.d.ts +8 -2
  41. package/dist/packages/charts/src/cartesian/time-series.d.ts +11 -1
  42. package/dist/packages/charts/src/categorical-values.d.ts +14 -9
  43. package/dist/packages/charts/src/chart-frame.d.ts +7 -9
  44. package/dist/packages/charts/src/chart-inspection.d.ts +1 -2
  45. package/dist/packages/charts/src/chart-range.d.ts +33 -0
  46. package/dist/packages/charts/src/chart-rows.d.ts +20 -0
  47. package/dist/packages/charts/src/chart-theme.d.ts +25 -1
  48. package/dist/packages/charts/src/chart.d.ts +81 -0
  49. package/dist/packages/charts/src/distribution/distribution-plot.d.ts +6 -4
  50. package/dist/packages/charts/src/index.d.ts +2 -1
  51. package/dist/packages/charts/src/matrix/matrix-strip.d.ts +3 -3
  52. package/dist/packages/charts/src/plot-width.d.ts +0 -1
  53. package/dist/packages/charts/src/timeline/index.d.ts +1 -1
  54. package/dist/packages/charts/src/timeline/waterfall.d.ts +6 -2
  55. package/dist/packages/collections/src/collection-controls.d.ts +5 -1
  56. package/dist/packages/collections/src/collection-filters.d.ts +4 -1
  57. package/dist/packages/collections/src/control-toolbar.d.ts +13 -0
  58. package/dist/packages/collections/src/data-table-layout.d.ts +78 -0
  59. package/dist/packages/collections/src/data-table-rows.d.ts +54 -0
  60. package/dist/packages/collections/src/data-table-styles.d.ts +340 -0
  61. package/dist/packages/collections/src/data-table-text.d.ts +13 -0
  62. package/dist/packages/collections/src/data-table-trigger.d.ts +23 -0
  63. package/dist/packages/collections/src/data-table.d.ts +3 -85
  64. package/dist/packages/collections/src/index.d.ts +11 -6
  65. package/dist/packages/collections/src/query-controls.d.ts +6 -2
  66. package/dist/packages/collections/src/table-results.d.ts +47 -13
  67. package/dist/packages/collections/src/timeline.d.ts +1 -0
  68. package/dist/packages/collections/src/use-collection-controls.d.ts +2 -1
  69. package/dist/packages/collections/src/use-table-window.d.ts +25 -0
  70. package/dist/packages/content/src/viewer.d.ts +8 -0
  71. package/dist/packages/core/src/disclosure.d.ts +9 -1
  72. package/dist/packages/core/src/index.d.ts +1 -0
  73. package/dist/packages/core/src/route-link.d.ts +11 -0
  74. package/dist/packages/forms/src/dates/date-inputs.d.ts +3 -1
  75. package/dist/packages/forms/src/file-picker.d.ts +15 -0
  76. package/dist/packages/forms/src/form-controls.d.ts +1 -6
  77. package/dist/packages/forms/src/forms.d.ts +4 -1
  78. package/dist/packages/forms/src/index.d.ts +4 -2
  79. package/dist/packages/forms/src/selection.d.ts +14 -0
  80. package/dist/packages/foundations/src/chart-tones.d.ts +5 -0
  81. package/dist/packages/foundations/src/csp/index.d.ts +1 -1
  82. package/dist/packages/foundations/src/csp/provider.d.ts +7 -2
  83. package/dist/packages/navigation/src/index.d.ts +1 -1
  84. package/dist/{pierre-diff-B3tD3-6z.js → pierre-diff-DlvjyuJn.js} +1 -1
  85. package/dist/plot-width-v2c_rA20.js +63 -0
  86. package/dist/{src-gqEebHEa.js → src-1EHkSFS-.js} +395 -274
  87. package/dist/{src-DBNncL7_.js → src-BPTDJqt0.js} +48 -68
  88. package/dist/src-CGc_hjxJ.js +409 -0
  89. package/dist/{src-DcW_gMX8.js → src-CpdJlDhO.js} +480 -362
  90. package/dist/{src-CDp1JtwC.js → src-DVHlknB6.js} +135 -120
  91. package/dist/styles2.css +167 -132
  92. package/dist/tokens.js +1 -1
  93. package/package.json +1 -4
  94. package/packages/foundations/src/constants.stylex.ts +9 -9
  95. package/packages/foundations/src/tokens.stylex.ts +9 -9
  96. package/skills/extend-elements/SKILL.md +74 -0
  97. package/skills/review-elements/SKILL.md +76 -0
  98. package/skills/upgrade-elements/SKILL.md +34 -0
  99. package/skills/upgrade-elements/references/releases.md +58 -0
  100. package/skills/use-elements/SKILL.md +64 -13
  101. package/skills/use-elements/references/agent.md +57 -0
  102. package/skills/use-elements/references/charts.md +63 -0
  103. package/skills/use-elements/references/collections.md +89 -0
  104. package/skills/use-elements/references/conversations.md +47 -0
  105. package/skills/use-elements/references/forms.md +81 -0
  106. package/skills/use-elements/references/reports.md +6 -4
  107. package/skills/use-elements/references/styling.md +70 -0
  108. package/skills/use-elements/references/workspace.md +3 -3
  109. package/dist/categorical-values-ByvFLaNE.js +0 -59
  110. package/dist/chart-frame-Bcd9Tpt5.js +0 -251
  111. package/dist/chart-navigation-BAbb5PV9.js +0 -154
  112. package/dist/header-styles-COxCYFZx.js +0 -90
  113. package/dist/packages/charts/src/chart-navigation.d.ts +0 -39
  114. package/dist/packages/charts/src/chart-surface.d.ts +0 -27
  115. package/dist/packages/navigation/src/route-link.d.ts +0 -2
  116. package/dist/plot-width-8cXdAjoD.js +0 -96
  117. package/dist/src-Bk7M67zy.js +0 -396
@@ -0,0 +1,81 @@
1
+ # Forms
2
+
3
+ Import controls from `@mechane-ai/elements/forms` and date controls from `/forms/dates`. The application supplies
4
+ values, labels, validation, permissions and the save.
5
+
6
+ ## Choose the control
7
+
8
+ | The reader | Use |
9
+ | ------------------------------------------------- | ------------------------------------------------------------------ |
10
+ | Types a line or several lines | `Input`, `Textarea` |
11
+ | Types a number with steps, or drags a bound | `NumberField`, `Slider`, both with a `locale` |
12
+ | Ticks a choice that a later save submits | `Checkbox` |
13
+ | Turns on a setting that applies at once | `Switch` |
14
+ | Picks one value in a form | `RadioGroup` |
15
+ | Switches between a few views, one always checked | `SegmentedControl` |
16
+ | Presses independent options, such as formatting | `ToggleGroup` |
17
+ | Picks one of several labeled strings | `SelectControl` |
18
+ | Needs rich options, object values or many choices | compound `Select` |
19
+ | Searches a finite or remote set of options | `Combobox` |
20
+ | Chooses, drops or pastes files | `FilePicker` |
21
+ | Picks a date, a day range, a month or months | `DatePicker`, `DateRangePicker`, `MonthPicker`, `MonthRangePicker` |
22
+
23
+ ```tsx
24
+ <SegmentedControl.Root value={view} onValueChange={setView} aria-label="View">
25
+ <SegmentedControl.Item value="table">Table</SegmentedControl.Item>
26
+ <SegmentedControl.Item value="chart">Chart</SegmentedControl.Item>
27
+ </SegmentedControl.Root>
28
+ ```
29
+
30
+ Use `Menu` from `/overlays` for commands and immediate choices, not for a form value.
31
+
32
+ ## Label and validate
33
+
34
+ `Field.Root` associates `Field.Label`, `Field.Description` and `Field.Error` with its control. Validation text stays
35
+ beside its field. Use `Fieldset` to name a group of fields, and `InputGroup` for a prefix, suffix or action beside an
36
+ `Input`.
37
+
38
+ ```tsx
39
+ <Field.Root name="reason" invalid={isInvalid}>
40
+ <Field.Label>Reason</Field.Label>
41
+ <Input required value={reason} onValueChange={setReason} />
42
+ <Field.Error match={isInvalid}>Enter a reason.</Field.Error>
43
+ </Field.Root>
44
+ ```
45
+
46
+ - `Input` and `Textarea` report edits through `onValueChange`, from a person or an agent.
47
+ - Set `isSensitive` on `Field.Root` for credentials and private drafts. The value, label and validation then stay out of
48
+ what an agent can read. Password inputs do this already.
49
+ - A disabled control is unavailable. A read-only value stays selectable.
50
+
51
+ ## Save
52
+
53
+ Put the submit row in `FormActions`. Pass `isPending` to the button while the request runs; it keeps focus and prevents
54
+ a second activation. Show the outcome with `FormStatus` in its pending, error or success state.
55
+
56
+ For a change that is hard to undo, use `ConfirmButton` with a `confirmation` sentence that names the record, usually
57
+ inside an `AlertDialog`. Keep the safe action first, keep the dialog open with an inline error until the server
58
+ acknowledges success, and keep the draft when the save fails. The **Consequential form** recipe shows the whole flow.
59
+
60
+ ## Files
61
+
62
+ `FilePicker` takes `accept`, `multiple`, `maxFiles`, `maxSize` and `minSize`, and reports
63
+ `onValueChange(files, details)`. It lists the chosen files and says why one was refused. It never uploads or reads a
64
+ file. The application owns storage and progress, and the server still enforces every limit. State the formats and limits
65
+ in `Field.Description`.
66
+
67
+ ## Dates
68
+
69
+ Dates are civil values, `{ year, month, day }` with one-based months. Supply the locale, time zone, today, bounds and
70
+ presets explicitly; a picker reads no clock. The app converts an inclusive range to its API's timestamps.
71
+
72
+ - The day pickers take a typed date, one field per unit. Digits fill a unit and the arrow keys step it.
73
+ - A picker keeps a draft in its popup. Apply commits one complete value. Escape and Cancel discard it.
74
+ - Use `isClearable={false}` for a required reporting period, and `validateRange` to refuse an unsupported interval.
75
+ - `parseCalendarDate`, `serializeCalendarDate`, `addCalendarDays` and their month forms convert and step values.
76
+ - `Calendar` is an inline calendar with immediate selection. `EventMonth` is a month grid of the app's own events.
77
+
78
+ ## Settings pages
79
+
80
+ `SettingsSection` groups settings and `SettingsRow` binds a real `controlId` to its label and description. Settings that
81
+ apply at once use `Switch` or a select. Settings saved together use a form with `FormActions`.
@@ -10,10 +10,12 @@ values a reader compares together. Keep available filters usable and preserve us
10
10
  selection. Use the component's delay and reduced-motion behavior. On a cold document, wait for session resolution before
11
11
  showing account navigation or sign-in.
12
12
 
13
- For a custom plot, start with `ChartFrame` and chart tones from `/charts`. Keep data meaning in the caller. For a
14
- calendar heatmap, give each date a square cell, align week columns and day rows to one gap, and distinguish a missing
15
- observation from the lowest score. A visible readout should provide the date and value on hover and selection. Give
16
- keyboard users one tab stop with arrows in the plotted directions. Pointer exit restores the selected reading.
13
+ For a custom plot, start with `ChartFrame` and chart tones from `/charts`. Outline filled marks with
14
+ `chartToneOutlines`, draw the zero baseline and axes in ink, and set tick text in the mono face, as the shared charts
15
+ do. Keep data meaning in the caller. For a calendar heatmap, give each date a square cell, align week columns and day
16
+ rows to one gap, and distinguish a missing observation from the lowest score. A visible readout should provide the date
17
+ and value on hover and selection. Give keyboard users one tab stop with arrows in the plotted directions. Pointer exit
18
+ restores the selected reading.
17
19
 
18
20
  Inspect a fast cached navigation, hold and release a slow read, then navigate away mid-read. Check that the shell and
19
21
  filters stay usable, the skeleton reserves the relevant space, and late responses belong to the active selection. Check
@@ -0,0 +1,70 @@
1
+ # Themes, tokens and styles
2
+
3
+ ## The default setup
4
+
5
+ Import `@mechane-ai/elements/styles.css` once. The package ships compiled ESM, declarations and CSS, so an ordinary
6
+ React app needs no StyleX compiler. The light theme works with no class. The application installs its own reset and
7
+ fonts.
8
+
9
+ ```tsx
10
+ import { themeProps } from '@mechane-ai/elements/theme';
11
+ import type { ReactNode } from 'react';
12
+
13
+ export function Document({ isDark, children }: { readonly isDark: boolean; readonly children: ReactNode }) {
14
+ return <html {...(isDark ? themeProps.dark : themeProps.light)}>{children}</html>;
15
+ }
16
+ ```
17
+
18
+ Apply the theme to the document root so portaled menus, dialogs and tooltips inherit it. The application stores the
19
+ preference; there is no theme provider. A themed wrapper suits an isolated preview only.
20
+
21
+ ## Appearance comes from the components
22
+
23
+ - Choose a named `variant`, `tone` or `density`. There is no size, padding or radius prop.
24
+ - `xstyle`, where a part supports it, accepts placement such as width or alignment.
25
+ - Compose another element through `render`, as in `<Dialog.Trigger render={<Button />}>`. The rendered element keeps its
26
+ own semantics, so a link stays a link.
27
+ - Do not restyle a control with a class that targets its internals. Fix spacing in the layout that places it.
28
+ - Text fields use 16px text on a coarse pointer and standalone controls give 44px targets. Leave both alone.
29
+
30
+ ## CSS layers
31
+
32
+ Put reset rules in the `reset` layer. Elements rules use the StyleX `priority` layers. Keep those layers at the top
33
+ level: wrapping the Elements stylesheet in another layer lets a base rule override hover and focus states. Ordinary
34
+ unlayered application rules override the package.
35
+
36
+ ## Tokens in your own styles
37
+
38
+ `@mechane-ai/elements/tokens` exports runtime references for colors, spacing, type, radii, motion and chart colors. Use
39
+ them in inline styles or any CSS-in-JS.
40
+
41
+ For StyleX authoring, import variables from `/tokens.stylex` and compile-time constants, such as
42
+ `conditions.coarsePointer`, from `/constants.stylex`. With Vite and StyleX 0.19.1:
43
+
44
+ ```ts
45
+ import stylex from '@stylexjs/unplugin/vite';
46
+ import { defineConfig } from 'vite';
47
+
48
+ export default defineConfig({
49
+ plugins: [
50
+ stylex({
51
+ useCSSLayers: true,
52
+ debug: false,
53
+ runtimeInjection: false,
54
+ unstable_moduleResolution: { type: 'commonJS' },
55
+ externalPackages: ['@mechane-ai/elements'],
56
+ }),
57
+ ],
58
+ resolve: { alias: [{ find: /^@mechane-ai\/elements\/tokens\.stylex$/, replacement: '@mechane-ai/elements/tokens' }] },
59
+ });
60
+ ```
61
+
62
+ The alias uses the compiled variable references without emitting the defaults again over the selected theme. Keep
63
+ `/constants.stylex` direct. Override roles with `stylex.createTheme(colors, ...)` using `colors` from `/tokens.stylex`.
64
+
65
+ Derive a CSS dimension from a token with CSS `calc()`. JavaScript arithmetic on a token produces an invalid declaration.
66
+
67
+ ## A nonce policy
68
+
69
+ When the Content Security Policy requires nonces, wrap the tree in `CSPProvider` from `@mechane-ai/elements/csp` with
70
+ the request's nonce, and keep that nonce through hydration. The application generates the nonce and owns the policy.
@@ -11,9 +11,9 @@ At a wide desktop viewport, compare the right edge of a report header with its t
11
11
  Give repeatable tasks such as reviewing a queue a named navigation link with deep-link and Back support. Put filters in
12
12
  the toolbar. Keep drill-down on the data mark or row it explains.
13
13
 
14
- Use `ToggleGroup` from `/forms` for short sets of pressed choices. For a required selection, keep the active value when
15
- pressing the selected item returns an empty array. Put the group beside a native Elements field and select. Compare
16
- their outer heights with a fine pointer and a coarse pointer, and check wrapping at phone width.
14
+ Use `SegmentedControl` from `/forms` to switch between a few views; one item is always checked. Use `ToggleGroup` for
15
+ independent pressed choices. Both size to their content. Put either beside an Elements field and select, compare their
16
+ outer heights with a fine pointer and a coarse pointer, and check wrapping at phone width.
17
17
 
18
18
  Use the shell's `railFooter.navigation` and `railFooter.menu` for persistent settings and account controls. Let the
19
19
  shell space and position both groups. Put route tabs and their actions in `PageLayout.navigation`. Wrap each report
@@ -1,59 +0,0 @@
1
- import { c as e } from "./src-CDp1JtwC.js";
2
- import { t } from "./chart-frame-Bcd9Tpt5.js";
3
- import { n } from "./chart-input-B6_HXFDP.js";
4
- import * as r from "@stylexjs/stylex";
5
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
- // packages/charts/src/categorical-values.tsx
7
- var o = {
8
- kzqmXN: "x1xc55vz",
9
- kZKoxP: "xdk7pt",
10
- kmuXW: "x2lah0s",
11
- $$css: !0
12
- }, s = { swatch: (e) => [
13
- o,
14
- {
15
- kWkggS: e == null ? e : "xl8spv7",
16
- $$css: !0
17
- },
18
- { "--x-backgroundColor": e ?? void 0 }
19
- ] }, c = {
20
- items: 200,
21
- series: 12
22
- }, l = [
23
- "series1",
24
- "series2",
25
- "series3",
26
- "series4",
27
- "series5",
28
- "series6"
29
- ];
30
- function u(e, t) {
31
- return e ?? l[t % l.length] ?? "series1";
32
- }
33
- function d(e) {
34
- if (e.length > c.items) return `Choose a window with at most ${c.items} items.`;
35
- if (!n(e)) return "Every breakdown item needs a unique identifier.";
36
- if (e.some((e) => e.value !== null && (!Number.isFinite(e.value) || e.value < 0))) return "Breakdown values must be finite and nonnegative, or explicitly missing.";
37
- if (!Number.isFinite(e.reduce((e, t) => e + (t.value ?? 0), 0))) return "The sum of recorded values must be finite.";
38
- }
39
- function f({ items: n, selection: o }) {
40
- return /* @__PURE__ */ i("ul", {
41
- className: "xrvj5dj x1ghz6dp x1717udv xe8uvvx",
42
- children: n.map((n) => /* @__PURE__ */ i("li", { children: /* @__PURE__ */ a(t, {
43
- label: `${n.label}: ${n.valueLabel}`,
44
- isSelected: o?.selectedId === n.id,
45
- onSelect: o === void 0 ? void 0 : () => o.onSelect(n.id),
46
- children: [/* @__PURE__ */ a("span", {
47
- className: "x78zum5 x6s0dn4 x1hnptsi x1slnebi xeuugli",
48
- children: [/* @__PURE__ */ i("span", {
49
- "aria-hidden": !0,
50
- ...r.props(s.swatch(e[n.tone]))
51
- }), n.label]
52
- }), /* @__PURE__ */ i("span", {
53
- className: "x153jb6y xp4054r xeuugli x193iq5w",
54
- children: n.valueLabel
55
- })]
56
- }) }, n.id))
57
- });
58
- }
59
- export { d as i, c as n, u as r, f as t };
@@ -1,251 +0,0 @@
1
- import { t as e } from "./header-styles-COxCYFZx.js";
2
- import { c as t, f as n, h as r } from "./src-CDp1JtwC.js";
3
- import * as i from "@stylexjs/stylex";
4
- import { Button as a } from "@ui-sdk/react/button";
5
- import { Children as o, useId as s } from "react";
6
- import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
7
- // packages/charts/src/chart-heading.tsx
8
- var d = { root: {
9
- k1C7PZ: "x8zbtdt",
10
- khm7nJ: "x1gkm1c7",
11
- kMwMTN: "xbixft",
12
- kMv6JI: "x1hz01jw",
13
- kGuDYH: "xtqrqnz",
14
- kLWn49: "x1778rvt",
15
- $$css: !0
16
- } };
17
- function f({ title: t, id: n, meta: r, actions: a }) {
18
- let s = o.toArray(r).length > 0, c = o.toArray(a).length > 0, f = s || c, p = s && /* @__PURE__ */ l("div", {
19
- ...i.props(e.meta),
20
- children: r
21
- }), m = c && /* @__PURE__ */ l("div", {
22
- ...i.props(e.actions),
23
- children: a
24
- });
25
- return /* @__PURE__ */ u("div", {
26
- ...i.props(e.row, e.reportRow, d.root),
27
- children: [/* @__PURE__ */ l("p", {
28
- id: n,
29
- ...i.props(e.title),
30
- children: t
31
- }), f && /* @__PURE__ */ u("div", {
32
- ...i.props(e.trailing),
33
- children: [p, m]
34
- })]
35
- });
36
- }
37
- // packages/charts/src/chart-series-marker.tsx
38
- var p = {
39
- root: {
40
- k1xSpc: "x3nfvp2",
41
- kGNEyG: "x6s0dn4",
42
- kjj79g: "xl56j7k",
43
- kmuXW: "x2lah0s",
44
- $$css: !0
45
- },
46
- color: (e) => [{
47
- kMwMTN: e == null ? e : "x14rh7hd",
48
- $$css: !0
49
- }, { "--x-color": e ?? void 0 }],
50
- icon: {
51
- kzqmXN: "x1kky2od",
52
- kZKoxP: "xlup9mm",
53
- $$css: !0
54
- },
55
- swatch: {
56
- kzqmXN: "x1xc55vz",
57
- kZKoxP: "xdk7pt",
58
- kWkggS: "xtwfq29",
59
- $$css: !0
60
- },
61
- transparent: {
62
- kWkggS: "xjbqb8w",
63
- $$css: !0
64
- }
65
- }, m = 8, h = .3;
66
- function g({ shape: e }) {
67
- switch (e) {
68
- case "line": return /* @__PURE__ */ l("path", {
69
- d: "M0 4 H8",
70
- stroke: "currentColor",
71
- strokeWidth: 2
72
- });
73
- case "band": return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("rect", {
74
- width: 8,
75
- height: 8,
76
- fill: "currentColor",
77
- opacity: h
78
- }), /* @__PURE__ */ l("path", {
79
- d: "M0 4 H8",
80
- stroke: "currentColor",
81
- strokeWidth: 1.5
82
- })] });
83
- case "tick": return /* @__PURE__ */ l("path", {
84
- d: "M0 4 H8",
85
- stroke: "currentColor",
86
- strokeWidth: 3
87
- });
88
- case "range": return /* @__PURE__ */ l("path", {
89
- d: "M1.5 0.75 H6.5 M4 0.75 V7.25 M1.5 7.25 H6.5",
90
- stroke: "currentColor",
91
- strokeWidth: 1.5,
92
- fill: "none"
93
- });
94
- case "dashed": return /* @__PURE__ */ l("path", {
95
- d: "M0 4 H3 M5 4 H8",
96
- stroke: "currentColor",
97
- strokeWidth: 1.5
98
- });
99
- }
100
- }
101
- function _({ tone: e, shape: n = "swatch", children: r }) {
102
- let a = o.toArray(r).length > 0, s = !a && n !== "swatch", c = a || n === "swatch" ? r : /* @__PURE__ */ l("svg", {
103
- width: m,
104
- height: m,
105
- viewBox: `0 0 ${m} ${m}`,
106
- focusable: "false",
107
- className: "x1lliihq x1xc55vz xdk7pt x1rea2x4",
108
- children: /* @__PURE__ */ l(g, { shape: n })
109
- });
110
- return /* @__PURE__ */ l("span", {
111
- "aria-hidden": !0,
112
- inert: !0,
113
- ...i.props(p.root, p.color(t[e]), a ? p.icon : p.swatch, s && p.transparent),
114
- children: c
115
- });
116
- }
117
- // packages/charts/src/chart-series-summary.tsx
118
- function v({ series: e, values: t }) {
119
- return Object.keys(t).length === e.length && e.every((e) => Object.hasOwn(t, e.id)) ? /* @__PURE__ */ l("dl", {
120
- "aria-label": "Period summary",
121
- className: "x78zum5 x1a02dak xaml1ju x1ghz6dp xeuugli",
122
- children: e.map((e, r) => /* @__PURE__ */ u("div", {
123
- ...{
124
- 0: { className: "xeuugli" },
125
- 1: { className: "xeuugli xo02m6d xpilrb4 x1t7ytsu x97x49r" }
126
- }[r > 0 | 0],
127
- children: [/* @__PURE__ */ u("dt", {
128
- className: "x78zum5 x6s0dn4 xunmzkg x153jb6y xy8obcc",
129
- children: [/* @__PURE__ */ l(_, {
130
- tone: e.tone,
131
- shape: e.shape
132
- }), e.label]
133
- }), /* @__PURE__ */ l("dd", {
134
- className: "x1ghz6dp xbixft x71lla1 xgkpprq xk4h15q x1wjjqco xss6m8b xj0a0fe",
135
- children: t[e.id] === void 0 ? /* @__PURE__ */ l(n, { width: "6ch" }) : t[e.id]
136
- })]
137
- }, e.id))
138
- }) : /* @__PURE__ */ l(r, {
139
- hasError: !0,
140
- children: "Period values must match the chart series identifiers."
141
- });
142
- }
143
- // packages/charts/src/chart-frame.tsx
144
- function y({ title: t, description: n, children: r, actions: a, footer: d, report: p, series: m = [] }) {
145
- let h = s();
146
- if (p !== void 0) {
147
- let e = p.seriesValues === void 0 ? p.summary : /* @__PURE__ */ l(v, {
148
- series: m,
149
- values: p.seriesValues
150
- }), i = e != null && e !== !1, s = o.toArray([p.actions, a]).length > 0, g = /* @__PURE__ */ u(c, { children: [p.actions, a] });
151
- return /* @__PURE__ */ u("figure", {
152
- "aria-labelledby": h,
153
- className: "xeuugli x1ghz6dp xbixft xpvm0e4 x1hz01jw xtqrqnz xj57cvi x1778rvt xmkeg23 x1y0btm7 x1ey3b81",
154
- children: [/* @__PURE__ */ l("figcaption", { children: /* @__PURE__ */ l(f, {
155
- id: h,
156
- title: t,
157
- meta: p.meta,
158
- actions: s && g
159
- }) }), /* @__PURE__ */ u("div", {
160
- className: "xeuugli xg7ukam",
161
- children: [
162
- i && /* @__PURE__ */ l("div", {
163
- className: "x1xxlxpq xeuugli",
164
- children: e
165
- }),
166
- n !== void 0 && /* @__PURE__ */ l("p", {
167
- className: "x1ghz6dp x1c87qhr x153jb6y xy8obcc xas2l8k",
168
- children: n
169
- }),
170
- r,
171
- d !== void 0 && /* @__PURE__ */ l("div", {
172
- className: "x1xxf3xd xeuugli x153jb6y xy8obcc xas2l8k xj0a0fe",
173
- children: d
174
- })
175
- ]
176
- })]
177
- });
178
- }
179
- return /* @__PURE__ */ u("figure", {
180
- "aria-labelledby": h,
181
- className: "xeuugli x1ghz6dp xbixft xpvm0e4 x1hz01jw xtqrqnz xj57cvi x1778rvt",
182
- children: [
183
- /* @__PURE__ */ u("figcaption", {
184
- className: "x78zum5 x1a02dak x1qughib x7a106z x1n8ia3y x1wv5www",
185
- children: [/* @__PURE__ */ u("div", {
186
- className: "x1cqoux5 xeuugli xj0a0fe",
187
- children: [/* @__PURE__ */ l("p", {
188
- id: h,
189
- className: "x1ghz6dp x12myhf4 x1778rvt x1b5ytql",
190
- children: t
191
- }), n !== void 0 && /* @__PURE__ */ l("p", {
192
- className: "x1ghz6dp x1c87qhr x153jb6y xy8obcc xas2l8k",
193
- children: n
194
- })]
195
- }), a !== void 0 && /* @__PURE__ */ l("div", {
196
- ...i.props(e.actions),
197
- children: a
198
- })]
199
- }),
200
- r,
201
- d !== void 0 && /* @__PURE__ */ l("div", {
202
- className: "x1xxf3xd xeuugli x153jb6y xy8obcc xas2l8k xj0a0fe",
203
- children: d
204
- })
205
- ]
206
- });
207
- }
208
- function b({ items: e, label: t = "Legend", isScrollable: n = !1 }) {
209
- return /* @__PURE__ */ l("ul", {
210
- "aria-label": t,
211
- ...{
212
- 0: { className: "x78zum5 x1a02dak x8zbtdt x1gkm1c7 xe8uvvx x1ghz6dp x1717udv x153jb6y x1hz01jw xy8obcc xas2l8k" },
213
- 1: { className: "x78zum5 x8zbtdt x1gkm1c7 xe8uvvx x1ghz6dp x1717udv x153jb6y x1hz01jw xy8obcc xas2l8k xozqiw3 xw2csxc x1mqbd49" }
214
- }[!!n | 0],
215
- children: e.map((e) => /* @__PURE__ */ u("li", {
216
- ...{
217
- 0: { className: "x3nfvp2 x6s0dn4 xunmzkg xeuugli x193iq5w xj0a0fe" },
218
- 1: { className: "x3nfvp2 x6s0dn4 xunmzkg xeuugli xj0a0fe x2lah0s x1x1rfll xuxw1ft" }
219
- }[!!n | 0],
220
- children: [/* @__PURE__ */ l(_, {
221
- tone: e.tone,
222
- shape: e.shape
223
- }), e.label]
224
- }, e.id))
225
- });
226
- }
227
- function x({ label: e, isSelected: t = !1, onSelect: n, children: r }) {
228
- return n === void 0 ? /* @__PURE__ */ l("div", {
229
- className: "x78zum5 x1a02dak x6s0dn4 x1qughib x8zbtdt x1gkm1c7 xeuugli x17tes2r x17oiadl x9f619 xh8yej3 xc342km x1hmw7ec x5g2kb4 x1hz01jw xtqrqnz xj57cvi x1778rvt x1yc453h xj0a0fe xbixft xpvm0e4 xss6m8b",
230
- children: r
231
- }) : /* @__PURE__ */ l(a, {
232
- type: "button",
233
- "aria-label": e,
234
- "aria-pressed": t,
235
- onClick: n,
236
- ...{
237
- 0: { className: "x78zum5 x1a02dak x6s0dn4 x1qughib x8zbtdt x1gkm1c7 xeuugli x17tes2r x17oiadl x9f619 xh8yej3 xc342km x1hmw7ec x5g2kb4 x1hz01jw xtqrqnz xj57cvi x1778rvt x1yc453h xj0a0fe xbixft xpvm0e4 xss6m8b x1ypdohk x1t137rt xif5pkx x1ecmtor x19rmrnh x9v5kkp x13qnu6 x1bqaal" },
238
- 1: { className: "x78zum5 x1a02dak x6s0dn4 x1qughib x8zbtdt x1gkm1c7 xeuugli x17tes2r x17oiadl x9f619 xh8yej3 xc342km x1hmw7ec x5g2kb4 x1hz01jw xtqrqnz xj57cvi x1778rvt x1yc453h xj0a0fe xbixft xss6m8b x1ypdohk x1t137rt xif5pkx x1ecmtor x19rmrnh x9v5kkp x13qnu6 x1bqaal x1r7kqkb xh3r7i3" }
239
- }[!!t | 0],
240
- children: r
241
- });
242
- }
243
- function S({ children: e, id: t }) {
244
- return /* @__PURE__ */ l("p", {
245
- id: t,
246
- "aria-live": "polite",
247
- className: "x1ghz6dp xeuugli x1mqbd49 xbixft xy8obcc xas2l8k xss6m8b xj0a0fe",
248
- children: e
249
- });
250
- }
251
- export { _ as a, S as i, y as n, b as r, x as t };
@@ -1,154 +0,0 @@
1
- import { t as e } from "./accessibility-P89UG9-r.js";
2
- import * as t from "@stylexjs/stylex";
3
- import { createParts as n } from "@ui-sdk/react/primitive";
4
- import { useId as r, useState as i } from "react";
5
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
- import { definePrimitive as s } from "@ui-sdk/core";
7
- // packages/charts/src/chart-data.tsx
8
- function c({ label: n, columns: r, rows: i }) {
9
- return /* @__PURE__ */ a("div", {
10
- ...t.props(e.hidden),
11
- children: /* @__PURE__ */ o("table", { children: [
12
- /* @__PURE__ */ a("caption", { children: n }),
13
- /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: r.map((e) => /* @__PURE__ */ a("th", {
14
- scope: "col",
15
- children: e.label
16
- }, e.id)) }) }),
17
- /* @__PURE__ */ a("tbody", { children: i.map((e) => /* @__PURE__ */ a("tr", { children: r.map((t, n) => n === 0 ? /* @__PURE__ */ a("th", {
18
- scope: "row",
19
- children: e.values[n]
20
- }, t.id) : /* @__PURE__ */ a("td", { children: e.values[n] }, t.id)) }, e.id)) })
21
- ] })
22
- });
23
- }
24
- // packages/charts/src/chart-surface.tsx
25
- var l = /* @__PURE__ */ new Set([" ", "Enter"]);
26
- function u({ index: e, last: t, allowVerticalNavigation: n }) {
27
- let r = Math.max(0, e - 1), i = Math.min(t, e + 1);
28
- return {
29
- Home: 0,
30
- End: t,
31
- ArrowLeft: r,
32
- ArrowRight: i,
33
- ArrowUp: n ? r : void 0,
34
- ArrowDown: n ? i : void 0
35
- };
36
- }
37
- function d({ index: e, last: t, columnCount: n }) {
38
- let r = Math.max(0, e), i = r - r % n, a = Math.min(t, i + n - 1), o = r - n, s = r + n;
39
- return {
40
- Home: i,
41
- End: a,
42
- ArrowLeft: Math.max(i, r - 1),
43
- ArrowRight: Math.min(a, r + 1),
44
- ArrowUp: o < 0 ? r : o,
45
- ArrowDown: s > t ? r : s
46
- };
47
- }
48
- function f({ controls: e }) {
49
- return {
50
- value: e.inspected ?? null,
51
- readout: e.readout ?? null,
52
- selected: e.selected ?? null
53
- };
54
- }
55
- var p = s({
56
- name: "chart-inspection",
57
- options: { controls: "value" },
58
- state: f,
59
- sync: f,
60
- controlled: [
61
- "value",
62
- "readout",
63
- "selected"
64
- ],
65
- api: ({ options: e }) => {
66
- function t(t) {
67
- let { items: n, onInspect: r } = e().controls;
68
- return n.some((e) => e.id === t) ? (r(t), !0) : !1;
69
- }
70
- function n(t) {
71
- let { items: n, onSelect: r } = e().controls;
72
- return r === void 0 || !n.some((e) => e.id === t) ? !1 : (r(t), !0);
73
- }
74
- function r(t) {
75
- let { items: r, cursor: i, allowVerticalNavigation: a, onDismiss: o } = e().controls, s = t.altKey || t.ctrlKey || t.metaKey;
76
- if (t.defaultPrevented || s || r.length === 0) return;
77
- if (t.key === "Escape") {
78
- t.preventDefault(), t.stopPropagation(), o();
79
- return;
80
- }
81
- if (l.has(t.key)) {
82
- if (t.target instanceof Element && t.target.closest("button, a, input, select, textarea") !== null) return;
83
- i !== void 0 && n(i) && t.preventDefault();
84
- return;
85
- }
86
- let c = r.findIndex((e) => e.id === i), f = r.length - 1, { columnCount: p } = e().controls, m = (p === void 0 || p < 1 ? u({
87
- index: c,
88
- last: f,
89
- allowVerticalNavigation: a === !0
90
- }) : d({
91
- index: c,
92
- last: f,
93
- columnCount: p
94
- }))[t.key], h = m === void 0 ? void 0 : r[m];
95
- h !== void 0 && (t.preventDefault(), e().controls.onInspect(h.id));
96
- }
97
- return {
98
- setValue: t,
99
- get selectItem() {
100
- return e().controls.onSelect === void 0 ? void 0 : n;
101
- },
102
- clear: () => e().controls.onDismiss(),
103
- items: () => e().controls.items.map(({ id: e, label: t }) => ({
104
- value: e,
105
- label: t
106
- })),
107
- onKeyDown: r
108
- };
109
- },
110
- slots: (e) => ({ root: e({ on: { keydown: (e, { api: t }) => t.onKeyDown(e) } }) }),
111
- agent: {
112
- items: (e) => e.items(),
113
- closed: !0
114
- }
115
- }), m = n(p, { root: "div" }).Root, h = n(p, { root: "p" }).Root, g = n(p, { root: "svg" }).Root;
116
- // packages/charts/src/chart-navigation.tsx
117
- function _({ title: e, items: t, selection: n, columnCount: a }) {
118
- let o = r(), [s, c] = i(void 0), [l, u] = i(!1), d = t[Math.max(0, t.findIndex((e) => e.id === (s ?? n?.selectedId)))];
119
- function f(e) {
120
- c(e), u(!0);
121
- }
122
- return {
123
- id: o,
124
- props: {
125
- controls: {
126
- items: t,
127
- cursor: d?.id,
128
- inspected: l ? d?.id : void 0,
129
- readout: l ? d?.label : void 0,
130
- selected: t.find((e) => e.id === n?.selectedId)?.id,
131
- allowVerticalNavigation: !0,
132
- columnCount: a,
133
- onInspect: f,
134
- onDismiss: () => u(!1),
135
- onSelect: n?.onSelect
136
- },
137
- role: "group",
138
- tabIndex: t.length > 0 ? 0 : void 0,
139
- "aria-label": `${e}. Use arrow keys to inspect.${n === void 0 ? "" : " Press Enter to select."}`,
140
- "aria-describedby": o,
141
- onFocus: () => u(!0),
142
- onBlur: (e) => {
143
- e.currentTarget.contains(e.relatedTarget) || u(!1);
144
- },
145
- onPointerLeave: (e) => {
146
- e.currentTarget.contains(document.activeElement) || u(!1);
147
- }
148
- },
149
- activeId: d?.id,
150
- label: l ? d?.label : void 0,
151
- inspect: f
152
- };
153
- }
154
- export { c as a, h as i, m as n, g as r, _ as t };