@efolusi/meridian 1.21.10 → 1.23.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 (147) hide show
  1. package/LICENSE +201 -21
  2. package/THIRD_PARTY_NOTICES.md +3 -3
  3. package/ai/AgentRun.js +1 -0
  4. package/ai/Bubble.js +1 -0
  5. package/ai/ChatMessage.js +1 -0
  6. package/ai/Citation.js +45 -22
  7. package/ai/Confirmation.js +3 -2
  8. package/ai/Conversation.js +1 -0
  9. package/ai/DocumentCard.js +1 -0
  10. package/ai/FeedbackBar.js +1 -0
  11. package/ai/GeneratedImage.js +1 -0
  12. package/ai/Marker.js +1 -0
  13. package/ai/Message.js +1 -0
  14. package/ai/MessageScroller.js +1 -0
  15. package/ai/ModelSelector.js +1 -0
  16. package/ai/Player.js +1 -0
  17. package/ai/PromptComposer.d.ts +4 -0
  18. package/ai/PromptComposer.js +8 -1
  19. package/ai/PromptSteps.js +1 -0
  20. package/ai/Reasoning.js +1 -0
  21. package/ai/RichComposer.js +4 -0
  22. package/ai/Sandbox.js +1 -0
  23. package/ai/SelectionQuote.js +1 -0
  24. package/ai/SourceCard.js +13 -4
  25. package/ai/Suggestions.js +1 -0
  26. package/ai/Task.js +1 -0
  27. package/ai/Todo.js +1 -0
  28. package/ai/ToolCall.js +1 -0
  29. package/ai/Transcript.js +1 -0
  30. package/ai/UsageMeter.d.ts +3 -1
  31. package/ai/UsageMeter.js +9 -2
  32. package/ai/WebPreview.js +13 -4
  33. package/code/CodeBlock.js +27 -7
  34. package/code/Console.js +1 -0
  35. package/code/CopyField.js +25 -9
  36. package/code/Diff.js +1 -0
  37. package/code/EnvList.js +1 -0
  38. package/code/Exception.js +1 -0
  39. package/code/Terminal.js +1 -0
  40. package/components.css +139 -56
  41. package/data/BarChart.d.ts +4 -0
  42. package/data/BarChart.js +29 -4
  43. package/data/Chart.d.ts +1 -1
  44. package/data/Chart.js +10 -4
  45. package/data/DonutChart.d.ts +4 -0
  46. package/data/DonutChart.js +38 -8
  47. package/data/EmptyState.js +1 -0
  48. package/data/KeyValueList.js +1 -0
  49. package/data/LineChart.d.ts +4 -0
  50. package/data/LineChart.js +30 -7
  51. package/data/Skeleton.js +1 -0
  52. package/data/Sparkline.js +1 -0
  53. package/data/Stat.js +1 -0
  54. package/data/StatusDot.js +1 -0
  55. package/data/Table.d.ts +1 -0
  56. package/data/Table.js +36 -19
  57. package/dates/Calendar.js +44 -15
  58. package/dates/TimePicker.js +19 -3
  59. package/display/Accordion.js +1 -0
  60. package/display/AspectRatio.js +1 -0
  61. package/display/Avatar.js +1 -0
  62. package/display/Badge.js +1 -0
  63. package/display/Card.js +1 -0
  64. package/display/Carousel.js +24 -6
  65. package/display/Collapsible.js +1 -0
  66. package/display/Direction.js +1 -0
  67. package/display/Divider.js +1 -0
  68. package/display/Item.js +1 -0
  69. package/display/Kbd.js +1 -0
  70. package/display/Link.js +1 -0
  71. package/display/Resizable.js +5 -4
  72. package/display/ScrollArea.js +4 -2
  73. package/display/Separator.js +1 -0
  74. package/display/Tag.js +1 -0
  75. package/display/Timeline.js +1 -0
  76. package/display/Toolbar.js +2 -0
  77. package/display/TreeList.js +21 -13
  78. package/feedback/Alert.js +1 -0
  79. package/feedback/AlertDialog.js +31 -18
  80. package/feedback/Banner.js +1 -0
  81. package/feedback/ConfirmDialog.js +1 -0
  82. package/feedback/Dialog.js +37 -18
  83. package/feedback/Loader.js +1 -0
  84. package/feedback/Progress.js +1 -0
  85. package/feedback/Spinner.js +1 -0
  86. package/feedback/Toast.js +10 -3
  87. package/feedback/Tooltip.js +25 -6
  88. package/files/Attachment.js +1 -0
  89. package/files/FileDrop.d.ts +5 -1
  90. package/files/FileDrop.js +29 -1
  91. package/files/FileTile.js +1 -0
  92. package/files/FileTypeIcon.js +1 -0
  93. package/finance/PaymentCard.js +1 -0
  94. package/forms/Button.js +55 -0
  95. package/forms/ButtonGroup.js +1 -0
  96. package/forms/ButtonTile.js +3 -0
  97. package/forms/Checkbox.js +1 -0
  98. package/forms/Combobox.js +31 -9
  99. package/forms/Field.js +1 -0
  100. package/forms/IconButton.js +1 -0
  101. package/forms/Input.js +1 -0
  102. package/forms/InputGroup.js +1 -0
  103. package/forms/InputOTP.js +1 -0
  104. package/forms/Label.js +1 -0
  105. package/forms/NativeSelect.js +1 -0
  106. package/forms/NumberInput.js +22 -4
  107. package/forms/Questionnaire.js +2 -1
  108. package/forms/Radio.js +1 -0
  109. package/forms/Select.js +7 -4
  110. package/forms/Slider.js +26 -3
  111. package/forms/Switch.js +15 -3
  112. package/forms/Textarea.js +1 -0
  113. package/forms/Toggle.js +1 -0
  114. package/icons/Icon.js +6 -0
  115. package/icons/_svg.js +1 -1
  116. package/index.js +3 -3
  117. package/navigation/Breadcrumbs.js +1 -0
  118. package/navigation/Menubar.js +1 -0
  119. package/navigation/NavigationMenu.js +18 -5
  120. package/navigation/PageControl.js +2 -0
  121. package/navigation/Pagination.js +1 -0
  122. package/navigation/SegmentedControl.js +2 -0
  123. package/navigation/SideNav.js +3 -0
  124. package/navigation/Sidebar.js +75 -11
  125. package/navigation/SkipLink.d.ts +2 -1
  126. package/navigation/SkipLink.js +17 -4
  127. package/navigation/Steps.js +1 -0
  128. package/navigation/Tabs.js +1 -0
  129. package/navigation/TopNav.js +1 -0
  130. package/overlay/Command.js +2 -0
  131. package/overlay/ContextMenu.js +40 -13
  132. package/overlay/Drawer.d.ts +4 -0
  133. package/overlay/Drawer.js +24 -3
  134. package/overlay/DropdownMenu.js +40 -13
  135. package/overlay/HoverCard.js +29 -19
  136. package/overlay/Popover.js +67 -16
  137. package/overlay/Portal.js +97 -2
  138. package/overlay/Sheet.js +1 -0
  139. package/package.json +2 -2
  140. package/tailwind.preset.cjs +60 -28
  141. package/tokens/base.css +19 -3
  142. package/tokens/colors.css +248 -46
  143. package/tokens/effects.css +33 -20
  144. package/tokens/fonts.css +7 -0
  145. package/tokens/spacing.css +42 -17
  146. package/tokens/typography.css +29 -8
  147. package/tokens.json +689 -115
@@ -9,6 +9,10 @@ export interface BarChartProps {
9
9
  labels?: string[];
10
10
  /** Hover value formatter */
11
11
  format?: (v: number) => string;
12
+ /** BCP 47 locale for number formatting (fixed default keeps server and browser output identical) @default 'en-US' */
13
+ locale?: string;
14
+ /** Accessible name for the chart (role=img); defaults to a summary of the series. A visually hidden table carries every value. */
15
+ 'aria-label'?: string;
12
16
  style?: React.CSSProperties;
13
17
  className?: string;
14
18
  }
package/data/BarChart.js CHANGED
@@ -1,24 +1,38 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { cssPct } from "../forms/Button.js";
6
+ // Fixed default locale: the runtime default would differ between server and browser.
5
7
  export function BarChart({
6
8
  data = [],
7
9
  height = 140,
8
10
  highlightLast = 0,
9
11
  labels,
10
12
  format,
13
+ locale = 'en-US',
14
+ 'aria-label': ariaLabel,
11
15
  style,
12
16
  className,
13
17
  ...rest
14
18
  }) {
15
19
  const vals = data.map(d => typeof d === 'number' ? d : d.value);
16
20
  const max = Math.max(...vals, 1);
21
+ const nf = new Intl.NumberFormat(locale);
22
+ const fmt = v => format ? format(v) : nf.format(v);
23
+ const name = i => data[i] && data[i].label || labels && labels[i] || String(i + 1);
24
+ const top = vals.reduce((best, v, i) => v > vals[best] ? i : best, 0);
25
+ const summary = ariaLabel || (vals.length ? `Bar chart, ${vals.length} bar${vals.length === 1 ? '' : 's'}, highest ${name(top)} ${fmt(vals[top])}` : 'Bar chart, no data');
17
26
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
18
27
  className: className,
19
- style: style
28
+ style: {
29
+ position: 'relative',
30
+ ...style
31
+ }
20
32
  }), /*#__PURE__*/React.createElement("div", {
21
33
  className: "ef-bars",
34
+ role: "img",
35
+ "aria-label": summary,
22
36
  style: {
23
37
  height
24
38
  }
@@ -28,9 +42,20 @@ export function BarChart({
28
42
  style: {
29
43
  height: cssPct(Math.max(2, v / max * 100))
30
44
  },
31
- title: (data[i] && data[i].label ? data[i].label + ' · ' : '') + (format ? format(v) : v.toLocaleString())
32
- }))), labels && labels.length ? /*#__PURE__*/React.createElement("div", {
33
- className: "ef-bars__labels"
45
+ title: (data[i] && data[i].label ? data[i].label + ' · ' : '') + fmt(v)
46
+ }))), vals.length ? /*#__PURE__*/React.createElement("table", {
47
+ className: "ef-bars__sr"
48
+ }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
49
+ scope: "col"
50
+ }, "Label"), /*#__PURE__*/React.createElement("th", {
51
+ scope: "col"
52
+ }, "Value"))), /*#__PURE__*/React.createElement("tbody", null, vals.map((v, i) => /*#__PURE__*/React.createElement("tr", {
53
+ key: i
54
+ }, /*#__PURE__*/React.createElement("th", {
55
+ scope: "row"
56
+ }, name(i)), /*#__PURE__*/React.createElement("td", null, fmt(v)))))) : null, labels && labels.length ? /*#__PURE__*/React.createElement("div", {
57
+ className: "ef-bars__labels",
58
+ "aria-hidden": "true"
34
59
  }, labels.map((l, i) => /*#__PURE__*/React.createElement("span", {
35
60
  key: i
36
61
  }, l))) : null);
package/data/Chart.d.ts CHANGED
@@ -7,7 +7,7 @@ export interface ChartContainerProps extends React.HTMLAttributes<HTMLDivElement
7
7
  export declare const ChartContainer: React.ForwardRefExoticComponent<ChartContainerProps & React.RefAttributes<HTMLDivElement>>;
8
8
  export declare function ChartStyle(props: { id: string; config: ChartConfig }): React.JSX.Element | null;
9
9
  export declare function ChartTooltip(props: TooltipProps<any, any>): React.JSX.Element | null;
10
- export interface ChartTooltipContentProps extends Omit<DefaultTooltipContentProps<TooltipValueType, string | number>, 'accessibilityLayer'> { active?: boolean; className?: string; hideLabel?: boolean; hideIndicator?: boolean; indicator?: 'line' | 'dot' | 'dashed'; nameKey?: string; labelKey?: string; color?: string }
10
+ export interface ChartTooltipContentProps extends Omit<DefaultTooltipContentProps<TooltipValueType, string | number>, 'accessibilityLayer'> { active?: boolean; className?: string; hideLabel?: boolean; hideIndicator?: boolean; indicator?: 'line' | 'dot' | 'dashed'; nameKey?: string; labelKey?: string; color?: string; /** Number formatting locale @default 'en-US' */ locale?: string }
11
11
  export declare function ChartTooltipContent(props: ChartTooltipContentProps): React.JSX.Element | null;
12
12
  export declare function ChartLegend(props: LegendProps): React.JSX.Element | null;
13
13
  export interface ChartLegendContentProps extends DefaultLegendContentProps { className?: string; hideIcon?: boolean; nameKey?: string }
package/data/Chart.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import * as RechartsPrimitive from 'recharts';
@@ -22,13 +23,17 @@ export function ChartStyle({
22
23
  }) {
23
24
  const colors = Object.entries(config || {}).filter(([, item]) => item.theme || item.color);
24
25
  if (!colors.length) return null;
25
- const css = Object.entries(THEMES).map(([theme, prefix]) => `${prefix} [data-chart="${id}"]{\n${colors.map(([key, item]) => {
26
+ const vars = theme => colors.map(([key, item]) => {
26
27
  const value = item.theme ? item.theme[theme] : item.color;
27
28
  return value ? `--color-${key}:${value};` : '';
28
- }).join('\n')}\n}`).join('\n');
29
+ }).join('\n');
30
+ // With no data-theme on <html>, a dark OS means dark, as in tokens/colors.css.
31
+ const css = Object.entries(THEMES).map(([theme, prefix]) => `${prefix} [data-chart="${id}"]{\n${vars(theme)}\n}`).join('\n') + `\n@media (prefers-color-scheme:dark){:root:not(:where([data-theme="light"])) [data-chart="${id}"]{\n${vars('dark')}\n}}`;
32
+ // Raw text inside <style>: server-rendered, a `<` in a config value could
33
+ // close the element and open a script. CSS never needs a literal `<` here.
29
34
  return /*#__PURE__*/React.createElement("style", {
30
35
  dangerouslySetInnerHTML: {
31
- __html: css
36
+ __html: css.replace(/</g, '\\3c ')
32
37
  }
33
38
  });
34
39
  }
@@ -72,6 +77,7 @@ function payloadConfig(config, payload, key) {
72
77
  export function ChartTooltipContent({
73
78
  active,
74
79
  payload,
80
+ locale = 'en-US',
75
81
  className,
76
82
  indicator = 'dot',
77
83
  hideLabel = false,
@@ -114,7 +120,7 @@ export function ChartTooltipContent({
114
120
  className: "ef-chart-tooltip__name"
115
121
  }, nestLabel ? labelNode : null, configItem?.label || item.name), item.value != null ? /*#__PURE__*/React.createElement("span", {
116
122
  className: "ef-chart-tooltip__value"
117
- }, typeof item.value === 'number' ? item.value.toLocaleString() : String(item.value)) : null));
123
+ }, typeof item.value === 'number' ? new Intl.NumberFormat(locale).format(item.value) : String(item.value)) : null));
118
124
  })));
119
125
  }
120
126
  export function ChartLegend(props) {
@@ -11,6 +11,10 @@ export interface DonutChartProps {
11
11
  centerValue?: React.ReactNode;
12
12
  /** Hover value formatter */
13
13
  format?: (value: number) => string;
14
+ /** BCP 47 locale for number formatting (fixed default keeps server and browser output identical) @default 'en-US' */
15
+ locale?: string;
16
+ /** Accessible name for the chart (role=img); defaults to a summary of the series. A visually hidden table carries every value. */
17
+ 'aria-label'?: string;
14
18
  style?: React.CSSProperties;
15
19
  className?: string;
16
20
  }
@@ -1,29 +1,41 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
- const PALETTE = ['var(--brand-950)', 'var(--brand-500)', 'var(--brand-200)', 'var(--sand-400)', 'var(--sand-200)'];
5
+ // Categorical slots from tokens/colors.css, in fixed order. A sixth slice reuses
6
+ // slot 1, so keep a donut to five slices or fold the rest into "Other".
7
+ const PALETTE = [1, 2, 3, 4, 5].map(n => `var(--chart-${n})`);
8
+ // Fixed default locale: the runtime default would differ between server and browser.
5
9
  export function DonutChart({
6
- data,
10
+ data = [],
7
11
  size = 140,
8
12
  thickness = 16,
9
13
  centerLabel,
10
14
  centerValue,
11
15
  format,
16
+ locale = 'en-US',
17
+ 'aria-label': ariaLabel,
12
18
  style,
13
19
  className,
14
20
  ...rest
15
21
  }) {
16
22
  const [hov, setHov] = React.useState(null);
17
23
  const total = data.reduce((s, d) => s + d.value, 0) || 1;
24
+ const nf = new Intl.NumberFormat(locale);
25
+ const fmt = v => format ? format(v) : nf.format(v);
26
+ const pct = v => Math.round(v / total * 100) + '%';
27
+ const summary = ariaLabel || (data.length ? 'Donut chart' + (centerLabel ? ', ' + centerLabel : '') + ': ' + data.map(d => `${d.label} ${pct(d.value)}`).join(', ') : 'Donut chart, no data');
18
28
  const R = 50 - thickness / 100 * 50;
19
29
  const C = 2 * Math.PI * R;
30
+ // A 2px surface gap between segments at any size (viewBox is 100 units wide).
31
+ const gap = 2 * 100 / size;
20
32
  let acc = 0;
21
33
  const segs = data.map((d, i) => {
22
34
  const frac = d.value / total;
23
35
  const seg = {
24
36
  ...d,
25
37
  i,
26
- dash: `${Math.max(frac * C - 1.5, 0.5)} ${C}`,
38
+ dash: `${Math.max(frac * C - gap, 0.5)} ${C}`,
27
39
  offset: -acc * C,
28
40
  color: d.color || PALETTE[i % PALETTE.length]
29
41
  };
@@ -32,8 +44,13 @@ export function DonutChart({
32
44
  });
33
45
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
34
46
  className: `ef-donut${className ? ' ' + className : ''}`,
35
- style: style
47
+ style: {
48
+ position: 'relative',
49
+ ...style
50
+ }
36
51
  }), /*#__PURE__*/React.createElement("div", {
52
+ role: "img",
53
+ "aria-label": summary,
37
54
  style: {
38
55
  position: 'relative',
39
56
  width: size,
@@ -80,13 +97,26 @@ export function DonutChart({
80
97
  fontWeight: 600,
81
98
  color: 'var(--text-primary)'
82
99
  }
83
- }, hov != null ? format ? format(segs[hov].value) : segs[hov].value.toLocaleString() : centerValue), /*#__PURE__*/React.createElement("span", {
100
+ }, hov != null ? fmt(segs[hov].value) : centerValue), /*#__PURE__*/React.createElement("span", {
84
101
  style: {
85
102
  fontSize: 11,
86
103
  color: 'var(--text-muted)'
87
104
  }
88
- }, hov != null ? segs[hov].label : centerLabel))), /*#__PURE__*/React.createElement("div", {
89
- className: "ef-donut__legend"
105
+ }, hov != null ? segs[hov].label : centerLabel))), data.length ? /*#__PURE__*/React.createElement("table", {
106
+ className: "ef-donut__sr"
107
+ }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
108
+ scope: "col"
109
+ }, "Label"), /*#__PURE__*/React.createElement("th", {
110
+ scope: "col"
111
+ }, "Value"), /*#__PURE__*/React.createElement("th", {
112
+ scope: "col"
113
+ }, "Share"))), /*#__PURE__*/React.createElement("tbody", null, segs.map(sg => /*#__PURE__*/React.createElement("tr", {
114
+ key: sg.i
115
+ }, /*#__PURE__*/React.createElement("th", {
116
+ scope: "row"
117
+ }, sg.label), /*#__PURE__*/React.createElement("td", null, fmt(sg.value)), /*#__PURE__*/React.createElement("td", null, pct(sg.value)))))) : null, /*#__PURE__*/React.createElement("div", {
118
+ className: "ef-donut__legend",
119
+ "aria-hidden": "true"
90
120
  }, segs.map(s => /*#__PURE__*/React.createElement("span", {
91
121
  key: s.i,
92
122
  className: "ef-donut__item",
@@ -103,5 +133,5 @@ export function DonutChart({
103
133
  }
104
134
  }), s.label, /*#__PURE__*/React.createElement("span", {
105
135
  className: "ef-donut__val"
106
- }, Math.round(s.value / total * 100), "%")))));
136
+ }, pct(s.value))))));
107
137
  }
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  function cx(base, className) {
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  export function KeyValueList({
@@ -9,6 +9,10 @@ export interface LineChartProps {
9
9
  showDots?: boolean;
10
10
  /** Tooltip value formatter */
11
11
  format?: (value: number) => string;
12
+ /** BCP 47 locale for number formatting (fixed default keeps server and browser output identical) @default 'en-US' */
13
+ locale?: string;
14
+ /** Accessible name for the chart (role=img); defaults to a summary of the series. A visually hidden table carries every value. */
15
+ 'aria-label'?: string;
12
16
  style?: React.CSSProperties;
13
17
  className?: string;
14
18
  }
package/data/LineChart.js CHANGED
@@ -1,13 +1,18 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { cssPct } from "../forms/Button.js";
6
+ // A fixed default locale: the runtime default differs between server and
7
+ // browser and would make the first render mismatch on hydration.
5
8
  export function LineChart({
6
- data,
9
+ data = [],
7
10
  height = 150,
8
11
  showArea = true,
9
12
  showDots = false,
10
13
  format,
14
+ locale = 'en-US',
15
+ 'aria-label': ariaLabel,
11
16
  style,
12
17
  className,
13
18
  ...rest
@@ -22,13 +27,18 @@ export function LineChart({
22
27
  min = Math.min(...vals);
23
28
  const span = max - min || 1;
24
29
  const n = data.length;
30
+ const nf = new Intl.NumberFormat(locale);
31
+ const fmt = v => format ? format(v) : nf.format(v);
32
+ const name = (d, i) => d.label != null && d.label !== '' ? d.label : String(i + 1);
33
+ const summary = ariaLabel || (n ? `Line chart, ${n} point${n === 1 ? '' : 's'}: ${name(data[0], 0)} ${fmt(data[0].value)} to ${name(data[n - 1], n - 1)} ${fmt(data[n - 1].value)}, low ${fmt(min)}, high ${fmt(max)}` : 'Line chart, no data');
25
34
  const x = i => PAD + (n === 1 ? 0.5 : i / (n - 1)) * (W - PAD * 2);
26
35
  const y = v => n === 1 ? H / 2 : H - PAD - (v - min) / span * (H - PAD * 2);
27
36
  // One reading has no left-to-right span; draw it as a flat line across the
28
37
  // middle instead of dividing by zero, which put NaN in the path.
29
- const path = n === 1 ? `M${PAD.toFixed(1)},${y(data[0].value).toFixed(1)} L${(W - PAD).toFixed(1)},${y(data[0].value).toFixed(1)}` : data.map((d, i) => (i ? 'L' : 'M') + x(i).toFixed(1) + ',' + y(d.value).toFixed(1)).join(' ');
30
- const area = n === 1 ? `${path} L${(W - PAD).toFixed(1)},${(H - PAD).toFixed(1)} L${PAD.toFixed(1)},${(H - PAD).toFixed(1)} Z` : path + ` L${x(data.length - 1).toFixed(1)},${H - PAD} L${x(0).toFixed(1)},${H - PAD} Z`;
38
+ const path = n === 0 ? '' : n === 1 ? `M${PAD.toFixed(1)},${y(data[0].value).toFixed(1)} L${(W - PAD).toFixed(1)},${y(data[0].value).toFixed(1)}` : data.map((d, i) => (i ? 'L' : 'M') + x(i).toFixed(1) + ',' + y(d.value).toFixed(1)).join(' ');
39
+ const area = n === 0 ? '' : n === 1 ? `${path} L${(W - PAD).toFixed(1)},${(H - PAD).toFixed(1)} L${PAD.toFixed(1)},${(H - PAD).toFixed(1)} Z` : path + ` L${x(data.length - 1).toFixed(1)},${H - PAD} L${x(0).toFixed(1)},${H - PAD} Z`;
31
40
  const move = e => {
41
+ if (!n) return;
32
42
  const r = ref.current.getBoundingClientRect();
33
43
  const i = Math.round((e.clientX - r.left) / r.width * (data.length - 1));
34
44
  setHov(Math.max(0, Math.min(data.length - 1, i)));
@@ -40,6 +50,8 @@ export function LineChart({
40
50
  onMouseMove: move,
41
51
  onMouseLeave: () => setHov(null)
42
52
  }), /*#__PURE__*/React.createElement("svg", {
53
+ role: "img",
54
+ "aria-label": summary,
43
55
  viewBox: `0 0 ${W} ${H}`,
44
56
  width: "100%",
45
57
  height: H,
@@ -47,11 +59,11 @@ export function LineChart({
47
59
  style: {
48
60
  display: 'block'
49
61
  }
50
- }, showArea && /*#__PURE__*/React.createElement("path", {
62
+ }, showArea && area && /*#__PURE__*/React.createElement("path", {
51
63
  d: area,
52
64
  fill: "var(--accent)",
53
65
  opacity: ".07"
54
- }), /*#__PURE__*/React.createElement("path", {
66
+ }), path && /*#__PURE__*/React.createElement("path", {
55
67
  d: path,
56
68
  fill: "none",
57
69
  stroke: "var(--accent)",
@@ -74,11 +86,22 @@ export function LineChart({
74
86
  stroke: "var(--border-strong)",
75
87
  strokeDasharray: "3 3",
76
88
  vectorEffect: "non-scaling-stroke"
77
- })), hov != null && /*#__PURE__*/React.createElement("div", {
89
+ })), n ? /*#__PURE__*/React.createElement("table", {
90
+ className: "ef-linechart__sr"
91
+ }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
92
+ scope: "col"
93
+ }, "Label"), /*#__PURE__*/React.createElement("th", {
94
+ scope: "col"
95
+ }, "Value"))), /*#__PURE__*/React.createElement("tbody", null, data.map((d, i) => /*#__PURE__*/React.createElement("tr", {
96
+ key: i
97
+ }, /*#__PURE__*/React.createElement("th", {
98
+ scope: "row"
99
+ }, name(d, i)), /*#__PURE__*/React.createElement("td", null, fmt(d.value)))))) : null, hov != null && /*#__PURE__*/React.createElement("div", {
100
+ "aria-hidden": "true",
78
101
  className: "ef-linechart__tip",
79
102
  style: {
80
103
  left: cssPct(x(hov) / W * 100),
81
104
  top: cssPct(y(data[hov].value) / H * 100)
82
105
  }
83
- }, data[hov].label, data[hov].label ? ' · ' : '', format ? format(data[hov].value) : data[hov].value.toLocaleString()));
106
+ }, data[hov].label, data[hov].label ? ' · ' : '', fmt(data[hov].value)));
84
107
  }
package/data/Skeleton.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  export const Skeleton = /*#__PURE__*/React.forwardRef(function Skeleton({
package/data/Sparkline.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  export function Sparkline({
package/data/Stat.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  export function Stat({
package/data/StatusDot.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  const STATE_TEXT = {
package/data/Table.d.ts CHANGED
@@ -22,6 +22,7 @@ export interface TableProps extends React.TableHTMLAttributes<HTMLTableElement>
22
22
  rows?: any[];
23
23
  /** Field name or fn for React keys @default index */
24
24
  rowKey?: string | ((row: any) => string);
25
+ /** Makes rows clickable and focusable (tabIndex 0); Enter or Space on a focused row also calls it. */
25
26
  onRowClick?: (row: any) => void;
26
27
  dense?: boolean;
27
28
  /** Controlled sort. Omit and the table sorts itself. */
package/data/Table.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Checkbox } from "../forms/Checkbox.js";
@@ -36,19 +37,9 @@ export const Table = /*#__PURE__*/React.forwardRef(function Table({
36
37
  className,
37
38
  ...rest
38
39
  }, ref) {
39
- if (!columns || !rows) {
40
- return /*#__PURE__*/React.createElement("div", {
41
- "data-slot": "table-container",
42
- className: "ef-table-wrap"
43
- }, /*#__PURE__*/React.createElement("table", _extends({
44
- ref: ref
45
- }, rest, {
46
- "data-slot": "table",
47
- className: `ef-table${dense ? ' ef-table--dense' : ''}${className ? ' ' + className : ''}`,
48
- style: style
49
- }), children));
50
- }
51
- const key = (row, i) => rowKey ? typeof rowKey === 'function' ? rowKey(row) : row[rowKey] : i;
40
+ // Hooks first: the composition branch below returns early, and hooks after
41
+ // it would drop sort and selection state whenever a table passes through it.
42
+
52
43
  const [innerSort, setInnerSort] = React.useState(defaultSort || null);
53
44
  const sort = sortProp !== undefined ? sortProp : innerSort;
54
45
  const applySort = next => {
@@ -71,14 +62,33 @@ export const Table = /*#__PURE__*/React.forwardRef(function Table({
71
62
 
72
63
  // Sorting is applied here, not expected of the caller: a table that renders
73
64
  // a sort affordance it does not honour is worse than one with no affordance.
74
- const sorted = React.useMemo(() => {
75
- if (!sort || !sort.key) return rows;
65
+ // Sort positions, not row objects: without rowKey a row's key is its index in
66
+ // `rows`, so a selection stays on the same row when the sort changes, and a
67
+ // row object listed twice still gets two keys.
68
+ const order = React.useMemo(() => {
69
+ const idx = (rows || []).map((_, i) => i);
70
+ if (!rows || !columns || !sort || !sort.key) return idx;
76
71
  const col = columns.find(c => c.key === sort.key);
77
- if (!col) return rows;
72
+ if (!col) return idx;
78
73
  const get = col.sortAccessor || (row => row[col.key]);
79
- const out = rows.slice().sort((x, y) => compare(get(x), get(y)));
80
- return sort.direction === 'desc' ? out.reverse() : out;
74
+ // Negate rather than reverse, so rows with equal keys keep their order.
75
+ const sign = sort.direction === 'desc' ? -1 : 1;
76
+ return idx.sort((x, y) => sign * compare(get(rows[x]), get(rows[y])));
81
77
  }, [rows, columns, sort]);
78
+ const sorted = rows ? order.map(i => rows[i]) : rows;
79
+ const key = (row, pos) => rowKey ? typeof rowKey === 'function' ? rowKey(row) : row[rowKey] : order[pos];
80
+ if (!columns || !rows) {
81
+ return /*#__PURE__*/React.createElement("div", {
82
+ "data-slot": "table-container",
83
+ className: "ef-table-wrap"
84
+ }, /*#__PURE__*/React.createElement("table", _extends({
85
+ ref: ref
86
+ }, rest, {
87
+ "data-slot": "table",
88
+ className: `ef-table${dense ? ' ef-table--dense' : ''}${className ? ' ' + className : ''}`,
89
+ style: style
90
+ }), children));
91
+ }
82
92
  const allKeys = sorted.map((r, i) => key(r, i));
83
93
  const allOn = allKeys.length > 0 && allKeys.every(k => selected.includes(k));
84
94
  const someOn = !allOn && allKeys.some(k => selected.includes(k));
@@ -141,7 +151,14 @@ export const Table = /*#__PURE__*/React.forwardRef(function Table({
141
151
  return /*#__PURE__*/React.createElement("tr", {
142
152
  key: k,
143
153
  className: `${onRowClick ? 'ef-table__row--click' : ''}${isSel ? ' ef-table__row--sel' : ''}`.trim() || undefined,
144
- onClick: onRowClick ? () => onRowClick(row) : undefined
154
+ onClick: onRowClick ? () => onRowClick(row) : undefined,
155
+ tabIndex: onRowClick ? 0 : undefined,
156
+ onKeyDown: onRowClick ? e => {
157
+ // Only the row itself: Enter on a button or link inside it is that control's.
158
+ if (e.target !== e.currentTarget || e.key !== 'Enter' && e.key !== ' ') return;
159
+ e.preventDefault();
160
+ onRowClick(row);
161
+ } : undefined
145
162
  }, selectable ? /*#__PURE__*/React.createElement("td", {
146
163
  className: "ef-table__sel",
147
164
  onClick: e => e.stopPropagation()
package/dates/Calendar.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { IconButton } from "../forms/IconButton.js";
@@ -76,7 +77,10 @@ export function Calendar({
76
77
  const [innerMonth, setInnerMonth] = React.useState(() => new Date(initial.getFullYear(), initial.getMonth(), 1));
77
78
  const visibleMonth = controlledMonth || innerMonth;
78
79
  const DayButton = components.DayButton || CalendarDayButton;
79
- const gridRef = React.useRef(null);
80
+ const monthsRef = React.useRef(null);
81
+ // Set by keyboard navigation only, so the calendar never pulls focus to
82
+ // itself on mount or when a month button changes the view.
83
+ const keyboardMove = React.useRef(false);
80
84
  const selectedStart = mode === 'range' ? selected?.from : mode === 'multiple' ? selected?.[0] : selected;
81
85
  const [focusDate, setFocusDate] = React.useState(() => startDay(selectedStart || new Date()));
82
86
  const setMonth = next => {
@@ -110,16 +114,41 @@ export function Calendar({
110
114
  const monthViews = Array.from({
111
115
  length: numberOfMonths
112
116
  }, (_, index) => addMonths(visibleMonth, index));
113
- const moveFocus = amount => {
114
- const next = addDays(focusDate, amount);
117
+ const monthIndex = date => date.getFullYear() * 12 + date.getMonth();
118
+ const firstShown = monthIndex(visibleMonth);
119
+ const lastShown = firstShown + numberOfMonths - 1;
120
+ const isShown = date => monthIndex(date) >= firstShown && monthIndex(date) <= lastShown;
121
+ const usable = date => isShown(date) && !matcherHit(disabled, date);
122
+ // The one day that carries tabIndex=0. It has to be a real, enabled day in
123
+ // a shown month, or the grid drops out of the tab order altogether.
124
+ const tabDate = (() => {
125
+ if (usable(focusDate)) return focusDate;
126
+ const picked = mode === 'range' ? [selected?.from, selected?.to] : mode === 'multiple' ? selected || [] : [selected];
127
+ const candidate = picked.filter(Boolean).map(startDay).find(usable) || [startDay(new Date())].find(usable);
128
+ if (candidate) return candidate;
129
+ for (let day = new Date(visibleMonth.getFullYear(), visibleMonth.getMonth(), 1); isShown(day); day = addDays(day, 1)) if (!matcherHit(disabled, day)) return day;
130
+ return focusDate;
131
+ })();
132
+ const inBounds = date => (!startMonth || monthIndex(date) >= monthIndex(startMonth)) && (!endMonth || monthIndex(date) <= monthIndex(endMonth));
133
+ // Move to `target`, stepping on by `skip` days past disabled ones, and page
134
+ // the view only when the day falls outside every shown month.
135
+ const focusOn = (target, skip) => {
136
+ let next = target;
137
+ for (let tries = 0; matcherHit(disabled, next) && tries < 62; tries += 1) next = addDays(next, skip);
138
+ if (matcherHit(disabled, next) || !inBounds(next)) return;
139
+ keyboardMove.current = true;
115
140
  setFocusDate(next);
116
- if (next.getMonth() !== visibleMonth.getMonth() || next.getFullYear() !== visibleMonth.getFullYear()) setMonth(new Date(next.getFullYear(), next.getMonth(), 1));
141
+ if (monthIndex(next) < firstShown) setMonth(new Date(next.getFullYear(), next.getMonth(), 1));else if (monthIndex(next) > lastShown) setMonth(new Date(next.getFullYear(), next.getMonth() - numberOfMonths + 1, 1));
117
142
  };
118
143
  React.useEffect(() => {
119
- const target = gridRef.current?.querySelector(`[data-key="${dayKey(focusDate)}"]`);
120
- if (target && (gridRef.current.contains(document.activeElement) || document.activeElement === document.body)) target.focus();
144
+ if (!keyboardMove.current) return;
145
+ keyboardMove.current = false;
146
+ const key = dayKey(focusDate);
147
+ const target = monthsRef.current?.querySelector(`[data-key="${key}"]:not([data-outside="true"])`) || monthsRef.current?.querySelector(`[data-key="${key}"]`);
148
+ target?.focus();
121
149
  }, [focusDate, visibleMonth]);
122
150
  const keydown = event => {
151
+ const from = tabDate;
123
152
  const horizontal = direction === 'rtl' ? {
124
153
  ArrowLeft: 1,
125
154
  ArrowRight: -1
@@ -129,18 +158,18 @@ export function Calendar({
129
158
  };
130
159
  if (horizontal[event.key]) {
131
160
  event.preventDefault();
132
- moveFocus(horizontal[event.key]);
161
+ focusOn(addDays(from, horizontal[event.key]), horizontal[event.key]);
133
162
  } else if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
163
+ const amount = event.key === 'ArrowUp' ? -7 : 7;
134
164
  event.preventDefault();
135
- moveFocus(event.key === 'ArrowUp' ? -7 : 7);
165
+ focusOn(addDays(from, amount), amount);
136
166
  } else if (event.key === 'Home' || event.key === 'End') {
137
167
  event.preventDefault();
138
- moveFocus((event.key === 'Home' ? 0 : 6) - focusDate.getDay());
168
+ focusOn(addDays(from, (event.key === 'Home' ? 0 : 6) - from.getDay()), event.key === 'Home' ? 1 : -1);
139
169
  } else if (event.key === 'PageUp' || event.key === 'PageDown') {
140
170
  event.preventDefault();
141
- const next = addMonths(focusDate, event.key === 'PageUp' ? -1 : 1);
142
- setFocusDate(new Date(next.getFullYear(), next.getMonth(), Math.min(focusDate.getDate(), new Date(next.getFullYear(), next.getMonth() + 1, 0).getDate())));
143
- setMonth(next);
171
+ const next = addMonths(from, event.key === 'PageUp' ? -1 : 1);
172
+ focusOn(new Date(next.getFullYear(), next.getMonth(), Math.min(from.getDate(), new Date(next.getFullYear(), next.getMonth() + 1, 0).getDate())), 1);
144
173
  }
145
174
  };
146
175
  const monthLabel = date => formatters.formatCaption?.(date) || new Intl.DateTimeFormat(localeCode, {
@@ -159,6 +188,7 @@ export function Calendar({
159
188
  className: `ef-cal${className ? ` ${className}` : ''}`,
160
189
  style: style
161
190
  }), /*#__PURE__*/React.createElement("div", {
191
+ ref: monthsRef,
162
192
  className: `ef-cal__months${classNames.months ? ` ${classNames.months}` : ''}`
163
193
  }, monthViews.map((view, viewIndex) => {
164
194
  const first = new Date(view.getFullYear(), view.getMonth(), 1);
@@ -210,7 +240,6 @@ export function Calendar({
210
240
  onClick: () => setMonth(addMonths(visibleMonth, 1))
211
241
  }) : null), /*#__PURE__*/React.createElement("div", {
212
242
  role: "grid",
213
- ref: viewIndex === 0 ? gridRef : undefined,
214
243
  onKeyDown: keydown,
215
244
  "aria-label": monthLabel(view),
216
245
  className: "ef-cal__grid"
@@ -239,7 +268,7 @@ export function Calendar({
239
268
  });
240
269
  const rangeStart = mode === 'range' && sameDay(date, selected?.from);
241
270
  const rangeEnd = mode === 'range' && sameDay(date, selected?.to);
242
- const rangeMiddle = mode === 'range' && selected?.from && selected?.to && date > selected.from && date < selected.to;
271
+ const rangeMiddle = mode === 'range' && selected?.from && selected?.to && date > startDay(selected.from) && date < startDay(selected.to);
243
272
  const modifiers = {
244
273
  selected: isSelected(date),
245
274
  today: sameDay(date, new Date()),
@@ -258,7 +287,7 @@ export function Calendar({
258
287
  locale: locale,
259
288
  role: "gridcell",
260
289
  "data-key": dayKey(date),
261
- tabIndex: sameDay(date, focusDate) ? 0 : -1,
290
+ tabIndex: !outside && sameDay(date, tabDate) ? 0 : -1,
262
291
  "aria-label": date.toLocaleDateString(localeCode, {
263
292
  dateStyle: 'long'
264
293
  }),