@efolusi/meridian 1.9.2 → 1.11.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.
@@ -3,10 +3,17 @@ export interface ConfirmationProps {
3
3
  description?: React.ReactNode;
4
4
  /** 'danger' for destructive approvals @default 'default' */
5
5
  tone?: 'default' | 'danger';
6
- /** Controlled state */
6
+ /** Controlled status */
7
+ status?: 'pending' | 'approved' | 'rejected';
8
+ /** @deprecated use `status` */
7
9
  state?: 'pending' | 'approved' | 'rejected';
8
10
  /** @default 'pending' */
11
+ /** @default 'pending' */
12
+ defaultStatus?: 'pending' | 'approved' | 'rejected';
13
+ /** @deprecated use `defaultStatus` */
9
14
  defaultState?: 'pending' | 'approved' | 'rejected';
15
+ onStatusChange?: (status: 'pending' | 'approved' | 'rejected') => void;
16
+ /** @deprecated use `onStatusChange` */
10
17
  onStateChange?: (state: 'pending' | 'approved' | 'rejected') => void;
11
18
  /** Lucide icon; defaults by tone */
12
19
  icon?: string;
@@ -6,8 +6,11 @@ export function Confirmation({
6
6
  title,
7
7
  description,
8
8
  tone = 'default',
9
+ status,
9
10
  state,
10
- defaultState = 'pending',
11
+ defaultStatus,
12
+ defaultState,
13
+ onStatusChange,
11
14
  onStateChange,
12
15
  icon,
13
16
  approveLabel = 'Approve',
@@ -19,11 +22,12 @@ export function Confirmation({
19
22
  className,
20
23
  ...rest
21
24
  }) {
22
- const [un, setUn] = React.useState(defaultState);
23
- const cur = state !== undefined ? state : un;
25
+ const [un, setUn] = React.useState(defaultStatus ?? defaultState ?? 'pending'); // `defaultState`/`state`/`onStateChange` are deprecated aliases
26
+ const controlled = status ?? state;
27
+ const cur = controlled !== undefined ? controlled : un;
24
28
  const set = next => {
25
- if (state === undefined) setUn(next);
26
- if (onStateChange) onStateChange(next);
29
+ if (controlled === undefined) setUn(next);
30
+ if (onStatusChange) onStatusChange(next);else if (onStateChange) onStateChange(next);
27
31
  };
28
32
  const settled = cur !== 'pending';
29
33
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
@@ -5,6 +5,9 @@ export interface GeneratedImageAction {
5
5
  }
6
6
  export interface GeneratedImageProps {
7
7
  /** 'queued' | 'generating' | 'complete' | 'error' */
8
+ /** @default 'complete' */
9
+ status?: 'queued' | 'generating' | 'complete' | 'error';
10
+ /** @deprecated use `status` */
8
11
  state?: 'queued' | 'generating' | 'complete' | 'error';
9
12
  src?: string;
10
13
  alt?: string;
@@ -3,7 +3,8 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
3
3
  import React from 'react';
4
4
  import { Icon } from "../icons/Icon.js";
5
5
  export function GeneratedImage({
6
- state = 'complete',
6
+ status,
7
+ state,
7
8
  src,
8
9
  alt,
9
10
  prompt,
@@ -15,31 +16,33 @@ export function GeneratedImage({
15
16
  className,
16
17
  ...rest
17
18
  }) {
19
+ const s = status ?? state ?? 'complete'; // `state` is a deprecated alias for `status`
20
+
18
21
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
19
- className: `ef-genimg ef-genimg--${aspect} ef-genimg--${state}${className ? ' ' + className : ''}`,
22
+ className: `ef-genimg ef-genimg--${aspect} ef-genimg--${s}${className ? ' ' + className : ''}`,
20
23
  style: style,
21
- "data-state": state
22
- }), src && (state === 'complete' || state === 'error') ? /*#__PURE__*/React.createElement("img", {
24
+ "data-state": s
25
+ }), src && (s === 'complete' || s === 'error') ? /*#__PURE__*/React.createElement("img", {
23
26
  className: "ef-genimg__img",
24
27
  src: src,
25
28
  alt: alt || prompt || ''
26
29
  }) : null, /*#__PURE__*/React.createElement("div", {
27
30
  className: "ef-genimg__dark"
28
- }, state === 'generating' ? /*#__PURE__*/React.createElement("div", {
31
+ }, s === 'generating' ? /*#__PURE__*/React.createElement("div", {
29
32
  className: "ef-genimg__dots"
30
33
  }) : null), /*#__PURE__*/React.createElement("div", {
31
34
  className: "ef-genimg__scrim ef-genimg__scrim--top",
32
35
  "aria-hidden": "true"
33
36
  }), prompt ? /*#__PURE__*/React.createElement("div", {
34
37
  className: "ef-genimg__prompt"
35
- }, prompt) : null, state === 'queued' ? /*#__PURE__*/React.createElement("div", {
38
+ }, prompt) : null, s === 'queued' ? /*#__PURE__*/React.createElement("div", {
36
39
  className: "ef-genimg__center"
37
40
  }, /*#__PURE__*/React.createElement(Icon, {
38
41
  name: "image",
39
42
  size: 20
40
- }), /*#__PURE__*/React.createElement("span", null, "Queued\u2026")) : null, state === 'generating' ? /*#__PURE__*/React.createElement("div", {
43
+ }), /*#__PURE__*/React.createElement("span", null, "Queued\u2026")) : null, s === 'generating' ? /*#__PURE__*/React.createElement("div", {
41
44
  className: "ef-genimg__status"
42
- }, "Generating\u2026") : null, state === 'error' ? /*#__PURE__*/React.createElement("div", {
45
+ }, "Generating\u2026") : null, s === 'error' ? /*#__PURE__*/React.createElement("div", {
43
46
  className: "ef-genimg__center"
44
47
  }, /*#__PURE__*/React.createElement("span", {
45
48
  className: "ef-genimg__err"
package/ai/Sandbox.d.ts CHANGED
@@ -8,6 +8,9 @@ export interface SandboxProps {
8
8
  /** Command or filename, mono */
9
9
  title: React.ReactNode;
10
10
  /** 'running' | 'success' | 'error' */
11
+ /** @default 'success' */
12
+ status?: 'running' | 'success' | 'error';
13
+ /** @deprecated use `status` */
11
14
  state?: 'running' | 'success' | 'error';
12
15
  /** Right-side meta, e.g. duration */
13
16
  meta?: React.ReactNode;
package/ai/Sandbox.js CHANGED
@@ -9,7 +9,8 @@ const STATES = {
9
9
  };
10
10
  export function Sandbox({
11
11
  title,
12
- state = 'success',
12
+ status,
13
+ state,
13
14
  meta,
14
15
  tabs = [],
15
16
  defaultOpen,
@@ -18,13 +19,15 @@ export function Sandbox({
18
19
  className,
19
20
  ...rest
20
21
  }) {
21
- const [open, setOpen] = React.useState(defaultOpen !== undefined ? !!defaultOpen : state === 'error');
22
+ const s = status ?? state ?? 'success'; // `state` is a deprecated alias for `status`
23
+
24
+ const [open, setOpen] = React.useState(defaultOpen !== undefined ? !!defaultOpen : s === 'error');
22
25
  const [tab, setTab] = React.useState(defaultTab || tabs[0] && tabs[0].id);
23
26
  const active = tabs.find(t => t.id === tab) || tabs[0];
24
27
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
25
- className: `ef-sandbox ef-sandbox--${state}${open ? ' ef-sandbox--open' : ''}${className ? ' ' + className : ''}`,
28
+ className: `ef-sandbox ef-sandbox--${s}${open ? ' ef-sandbox--open' : ''}${className ? ' ' + className : ''}`,
26
29
  style: style,
27
- "data-state": state
30
+ "data-state": s
28
31
  }), /*#__PURE__*/React.createElement("button", {
29
32
  type: "button",
30
33
  className: "ef-sandbox__head",
@@ -39,12 +42,12 @@ export function Sandbox({
39
42
  className: "ef-sandbox__title"
40
43
  }, title), /*#__PURE__*/React.createElement("span", {
41
44
  className: "ef-sandbox__meta"
42
- }, state === 'running' ? /*#__PURE__*/React.createElement("span", {
45
+ }, s === 'running' ? /*#__PURE__*/React.createElement("span", {
43
46
  className: "ef-sandbox__spin"
44
47
  }, /*#__PURE__*/React.createElement(Icon, {
45
48
  name: "loader-circle",
46
49
  size: 13
47
- })) : null, meta || STATES[state])), /*#__PURE__*/React.createElement("div", {
50
+ })) : null, meta || STATES[s])), /*#__PURE__*/React.createElement("div", {
48
51
  className: "ef-sandbox__body"
49
52
  }, /*#__PURE__*/React.createElement("div", {
50
53
  className: "ef-sandbox__clip"
package/code/EnvList.d.ts CHANGED
@@ -7,6 +7,9 @@ export interface EnvVar {
7
7
  export interface EnvListProps {
8
8
  title?: string;
9
9
  vars: EnvVar[];
10
+ /** Reveal secret values on mount. @default false */
11
+ defaultOpen?: boolean;
12
+ /** @deprecated use `defaultOpen` */
10
13
  defaultVisible?: boolean;
11
14
  style?: React.CSSProperties;
12
15
  className?: string;
package/code/EnvList.js CHANGED
@@ -33,12 +33,13 @@ function Row({
33
33
  export function EnvList({
34
34
  title = 'Environment',
35
35
  vars = [],
36
- defaultVisible = false,
36
+ defaultOpen,
37
+ defaultVisible,
37
38
  style,
38
39
  className,
39
40
  ...rest
40
41
  }) {
41
- const [visible, setVisible] = React.useState(!!defaultVisible);
42
+ const [visible, setVisible] = React.useState(!!(defaultOpen ?? defaultVisible ?? false));
42
43
  const hasSecrets = vars.some(v => v.secret);
43
44
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
44
45
  className: `ef-env${className ? ' ' + className : ''}`,
@@ -1,8 +1,12 @@
1
1
  export interface StatusDotProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'children'> {
2
2
  /** @default 'ok' */
3
+ status?: 'ok' | 'warn' | 'err' | 'busy' | 'off';
4
+ /** @deprecated use `status` */
3
5
  state?: 'ok' | 'warn' | 'err' | 'busy' | 'off';
4
6
  label?: React.ReactNode;
5
- /** Text announced for the state; defaults to OK / Warning / Error / Busy / Offline */
7
+ /** Text announced for the status; defaults to OK / Warning / Error / Busy / Offline */
8
+ statusLabel?: string;
9
+ /** @deprecated use `statusLabel` */
6
10
  stateLabel?: string;
7
11
  /** Radiating pulse for live states */
8
12
  pulse?: boolean;
package/data/StatusDot.js CHANGED
@@ -9,20 +9,24 @@ const STATE_TEXT = {
9
9
  off: 'Offline'
10
10
  };
11
11
  export function StatusDot({
12
- state = 'ok',
13
- label,
12
+ status,
13
+ state,
14
+ statusLabel,
14
15
  stateLabel,
16
+ label,
15
17
  pulse,
16
18
  style,
17
19
  className,
18
20
  ...rest
19
21
  }) {
22
+ const s = status ?? state ?? 'ok'; // `state` is a deprecated alias for `status`
23
+
20
24
  // The dot itself is colour-only, so the state must also exist as text. With a
21
25
  // visible label the state rides along visually hidden ("Error: API"); without
22
26
  // one the whole span becomes an image whose accessible name is the state.
23
- const stateText = stateLabel || STATE_TEXT[state] || state;
27
+ const stateText = (statusLabel ?? stateLabel) || STATE_TEXT[s] || s;
24
28
  return /*#__PURE__*/React.createElement("span", _extends({}, rest, {
25
- className: `ef-status ef-status--${state}${pulse ? ' ef-status--pulse' : ''}${className ? ' ' + className : ''}`,
29
+ className: `ef-status ef-status--${s}${pulse ? ' ef-status--pulse' : ''}${className ? ' ' + className : ''}`,
26
30
  style: style,
27
31
  role: label ? undefined : 'img',
28
32
  "aria-label": label ? undefined : stateText
@@ -10,6 +10,8 @@ export interface CalendarProps extends Omit<React.HTMLAttributes<HTMLDivElement>
10
10
  /** Selected date as YYYY-MM-DD */
11
11
  value?: string;
12
12
  onChange?: (date: string) => void;
13
+ /** BCP 47 locale for month and weekday names via Intl (e.g. 'id', 'en'); omit for English. The grid stays Monday-first for every locale. */
14
+ locale?: string;
13
15
  style?: React.CSSProperties;
14
16
  className?: string;
15
17
  }
@@ -18,6 +20,8 @@ export interface CalendarRangeProps extends Omit<React.HTMLAttributes<HTMLDivEle
18
20
  range: true;
19
21
  value?: DateRange;
20
22
  onChange?: (range: DateRange) => void;
23
+ /** BCP 47 locale for month and weekday names via Intl (e.g. 'id', 'en'); omit for English. The grid stays Monday-first for every locale. */
24
+ locale?: string;
21
25
  style?: React.CSSProperties;
22
26
  className?: string;
23
27
  }
package/dates/Calendar.js CHANGED
@@ -6,14 +6,63 @@ const DOW = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
6
6
  const DOW_FULL = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
7
7
  const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
8
8
  const iso = d => d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');
9
+ // Month, weekday and full-date names for a locale, from Intl. Reference dates:
10
+ // 2024-01-01 is a Monday, so index 0..6 is Monday..Sunday — matching the grid,
11
+ // which stays Monday-first for every locale (week-start localisation depends on
12
+ // Intl.Locale weekInfo, which is not portable, so it is deliberately out of scope).
13
+ const EN = {
14
+ months: MONTHS,
15
+ dow: DOW,
16
+ dowFull: DOW_FULL,
17
+ dayLabel: d => `${d.getDate()} ${MONTHS[d.getMonth()]} ${d.getFullYear()}`
18
+ };
19
+ function localeNames(locale) {
20
+ if (!locale) return EN;
21
+ const mLong = new Intl.DateTimeFormat(locale, {
22
+ month: 'long'
23
+ });
24
+ const dShort = new Intl.DateTimeFormat(locale, {
25
+ weekday: 'short'
26
+ });
27
+ const dLong = new Intl.DateTimeFormat(locale, {
28
+ weekday: 'long'
29
+ });
30
+ const dayFmt = new Intl.DateTimeFormat(locale, {
31
+ day: 'numeric',
32
+ month: 'long',
33
+ year: 'numeric'
34
+ });
35
+ return {
36
+ months: Array.from({
37
+ length: 12
38
+ }, (_, i) => mLong.format(new Date(2024, i, 1))),
39
+ dow: Array.from({
40
+ length: 7
41
+ }, (_, i) => dShort.format(new Date(2024, 0, 1 + i))),
42
+ dowFull: Array.from({
43
+ length: 7
44
+ }, (_, i) => dLong.format(new Date(2024, 0, 1 + i))),
45
+ dayLabel: d => dayFmt.format(d)
46
+ };
47
+ }
9
48
  export function Calendar({
10
49
  value,
11
50
  onChange,
12
51
  range,
52
+ locale,
13
53
  style,
14
54
  className,
15
55
  ...rest
16
56
  }) {
57
+ // Names localise when `locale` is set; without it the English constants are
58
+ // used unchanged, so this is additive.
59
+ const L = React.useMemo(() => localeNames(locale), [locale]);
60
+ const {
61
+ months: MONTHS_L,
62
+ dow: DOW_L,
63
+ dowFull: DOW_FULL_L,
64
+ dayLabel
65
+ } = L;
17
66
  // In range mode value is { from, to } of ISO strings (either may be null);
18
67
  // without the prop everything below behaves exactly as before.
19
68
  const from = range && value ? value.from || null : null;
@@ -114,7 +163,7 @@ export function Calendar({
114
163
  }), /*#__PURE__*/React.createElement("span", {
115
164
  className: "ef-cal__month",
116
165
  "aria-live": "polite"
117
- }, MONTHS[m], " ", y), /*#__PURE__*/React.createElement(IconButton, {
166
+ }, MONTHS_L[m], " ", y), /*#__PURE__*/React.createElement(IconButton, {
118
167
  icon: "chevron-right",
119
168
  label: "Next month",
120
169
  size: "sm",
@@ -123,15 +172,15 @@ export function Calendar({
123
172
  role: "grid",
124
173
  ref: gridRef,
125
174
  onKeyDown: onGridKey,
126
- "aria-label": `${MONTHS[m]} ${y}`,
175
+ "aria-label": `${MONTHS_L[m]} ${y}`,
127
176
  className: "ef-cal__grid"
128
177
  }, /*#__PURE__*/React.createElement("div", {
129
178
  role: "row",
130
179
  className: "ef-cal__row"
131
- }, DOW.map((d, i) => /*#__PURE__*/React.createElement("span", {
132
- key: d,
180
+ }, DOW_L.map((d, i) => /*#__PURE__*/React.createElement("span", {
181
+ key: i,
133
182
  role: "columnheader",
134
- "aria-label": DOW_FULL[i],
183
+ "aria-label": DOW_FULL_L[i],
135
184
  className: "ef-cal__dow"
136
185
  }, d))), rows.map((row, ri) => /*#__PURE__*/React.createElement("div", {
137
186
  role: "row",
@@ -148,7 +197,7 @@ export function Calendar({
148
197
  tabIndex: id === focusTarget ? 0 : -1,
149
198
  "aria-selected": range ? from || to ? isEnd : undefined : sel ? id === iso(sel) : undefined,
150
199
  "aria-current": id === today ? 'date' : undefined,
151
- "aria-label": `${d.getDate()} ${MONTHS[d.getMonth()]} ${d.getFullYear()}`,
200
+ "aria-label": dayLabel(d),
152
201
  className: `ef-cal__day${d.getMonth() !== m ? ' ef-cal__day--out' : ''}${id === today ? ' ef-cal__day--today' : ''}${(range ? isEnd : sel && id === iso(sel)) ? ' ef-cal__day--sel' : ''}${inBand ? ' ef-cal__day--band' : ''}`,
153
202
  onClick: () => pick(id)
154
203
  }, d.getDate());
@@ -6,6 +6,8 @@ export interface DatePickerProps {
6
6
  onChange?: (date: string) => void;
7
7
  /** @default 'Pick a date' */
8
8
  placeholder?: string;
9
+ /** BCP 47 locale for the trigger's date label and the calendar's names via Intl (e.g. 'id', 'en'); omit for en-US. */
10
+ locale?: string;
9
11
  style?: React.CSSProperties;
10
12
  className?: string;
11
13
  }
@@ -5,10 +5,12 @@ import { Icon } from "../icons/Icon.js";
5
5
  import { Calendar } from "./Calendar.js";
6
6
  import { useFieldProps } from "../forms/FormField.js";
7
7
  import { Portal, useAnchoredStyle } from "../overlay/Portal.js";
8
- const fmt = v => {
8
+ // The trigger's date label; locale defaults to en-US so the display is unchanged
9
+ // unless a locale is passed.
10
+ const fmt = (v, locale) => {
9
11
  if (!v) return null;
10
12
  const d = new Date(v + 'T00:00:00');
11
- return d.toLocaleDateString('en-US', {
13
+ return d.toLocaleDateString(locale || 'en-US', {
12
14
  month: 'short',
13
15
  day: 'numeric',
14
16
  year: 'numeric'
@@ -20,6 +22,7 @@ export function DatePicker({
20
22
  defaultValue,
21
23
  onChange,
22
24
  placeholder = 'Pick a date',
25
+ locale,
23
26
  style,
24
27
  className,
25
28
  ...rest
@@ -84,7 +87,7 @@ export function DatePicker({
84
87
  style: {
85
88
  color: 'var(--text-muted)'
86
89
  }
87
- }), fmt(v) || placeholder, /*#__PURE__*/React.createElement(Icon, {
90
+ }), fmt(v, locale) || placeholder, /*#__PURE__*/React.createElement(Icon, {
88
91
  name: "chevron-down",
89
92
  size: 14,
90
93
  style: {
@@ -97,6 +100,7 @@ export function DatePicker({
97
100
  style: anchored
98
101
  }, /*#__PURE__*/React.createElement(Calendar, {
99
102
  value: v || undefined,
103
+ locale: locale,
100
104
  onChange: d => {
101
105
  if (value == null) setInner(d);
102
106
  if (onChange) onChange(d);
@@ -15,6 +15,8 @@ export interface DateRangePickerProps extends Omit<React.HTMLAttributes<HTMLSpan
15
15
  /** @default 'Pick a date range' */
16
16
  placeholder?: string;
17
17
  disabled?: boolean;
18
+ /** BCP 47 locale for the trigger's date labels and the calendar's names via Intl (e.g. 'id', 'en'); omit for en-US. */
19
+ locale?: string;
18
20
  style?: React.CSSProperties;
19
21
  className?: string;
20
22
  }
@@ -5,10 +5,10 @@ import { Icon } from "../icons/Icon.js";
5
5
  import { Calendar } from "./Calendar.js";
6
6
  import { useFieldProps } from "../forms/FormField.js";
7
7
  import { Portal, useAnchoredStyle } from "../overlay/Portal.js";
8
- const fmt = v => {
8
+ const fmt = (v, locale) => {
9
9
  if (!v) return null;
10
10
  const d = new Date(v + 'T00:00:00');
11
- return d.toLocaleDateString('en-US', {
11
+ return d.toLocaleDateString(locale || 'en-US', {
12
12
  month: 'short',
13
13
  day: 'numeric',
14
14
  year: 'numeric'
@@ -27,6 +27,7 @@ export function DateRangePicker({
27
27
  max,
28
28
  placeholder = 'Pick a date range',
29
29
  disabled,
30
+ locale,
30
31
  style,
31
32
  className,
32
33
  ...rest
@@ -94,7 +95,7 @@ export function DateRangePicker({
94
95
  commit(EMPTY);
95
96
  if (btnRef.current) btnRef.current.focus();
96
97
  };
97
- const text = from || to ? `${fmt(from) || '…'} — ${fmt(to) || '…'}` : null;
98
+ const text = from || to ? `${fmt(from, locale) || '…'} — ${fmt(to, locale) || '…'}` : null;
98
99
  return /*#__PURE__*/React.createElement("span", _extends({}, rest, {
99
100
  ref: rootRef,
100
101
  className: `ef-daterange${className ? ' ' + className : ''}`,
@@ -143,6 +144,7 @@ export function DateRangePicker({
143
144
  from,
144
145
  to
145
146
  },
147
+ locale: locale,
146
148
  onChange: handlePick
147
149
  }))));
148
150
  }
@@ -3,8 +3,9 @@ export interface BannerProps {
3
3
  tone?: 'neutral' | 'brand' | 'warning' | 'danger';
4
4
  /** Lucide icon name */
5
5
  icon?: string;
6
- /** Underlined action label */
7
- action?: string;
6
+ /** Action slot: a node (rendered as-is) or, deprecated, a string label used with `onAction`. */
7
+ action?: React.ReactNode;
8
+ /** @deprecated pass a node to `action` instead */
8
9
  onAction?: () => void;
9
10
  /** Shows a dismiss ✕ */
10
11
  onDismiss?: () => void;
@@ -25,7 +25,7 @@ export function Banner({
25
25
  size: 15
26
26
  })) : null, /*#__PURE__*/React.createElement("span", {
27
27
  className: "ef-banner__text"
28
- }, children), action ? /*#__PURE__*/React.createElement("button", {
28
+ }, children), action ? /*#__PURE__*/React.isValidElement(action) ? action : /*#__PURE__*/React.createElement("button", {
29
29
  className: "ef-banner__action",
30
30
  onClick: onAction
31
31
  }, action) : null, onDismiss ? /*#__PURE__*/React.createElement(IconButton, {
@@ -3,7 +3,11 @@ export interface ToastProps {
3
3
  tone?: 'info' | 'success' | 'warning' | 'danger';
4
4
  title: React.ReactNode;
5
5
  description?: React.ReactNode;
6
+ /** Action slot, a node rendered as-is (prevents auto-dismiss per WCAG 2.2.1). */
7
+ action?: React.ReactNode;
8
+ /** @deprecated pass a node to `action` instead */
6
9
  actionLabel?: string;
10
+ /** @deprecated pass a node to `action` instead */
7
11
  onAction?: () => void;
8
12
  /** Shows a dismiss ✕ */
9
13
  onClose?: () => void;
@@ -31,11 +35,15 @@ export interface ToastOptions {
31
35
  description?: React.ReactNode;
32
36
  /** @default 'info' */
33
37
  tone?: 'info' | 'success' | 'warning' | 'danger';
38
+ /** Action slot, a node rendered as-is (prevents auto-dismiss per WCAG 2.2.1). */
39
+ action?: React.ReactNode;
40
+ /** @deprecated pass a node to `action` instead */
34
41
  actionLabel?: string;
42
+ /** @deprecated pass a node to `action` instead */
35
43
  onAction?: () => void;
36
44
  /**
37
45
  * ms before auto-dismiss; 0 never dismisses.
38
- * @default the Toaster's `duration`, or 0 when `actionLabel` is set — a
46
+ * @default the Toaster's `duration`, or 0 when `action`/`actionLabel` is set — a
39
47
  * control must not vanish on a timer the user cannot adjust (WCAG 2.2.1).
40
48
  */
41
49
  duration?: number;
package/feedback/Toast.js CHANGED
@@ -14,6 +14,7 @@ export function Toast({
14
14
  tone = 'info',
15
15
  title,
16
16
  description,
17
+ action,
17
18
  actionLabel,
18
19
  onAction,
19
20
  onClose,
@@ -39,7 +40,7 @@ export function Toast({
39
40
  className: "ef-toast__title"
40
41
  }, title), description ? /*#__PURE__*/React.createElement("div", {
41
42
  className: "ef-toast__desc"
42
- }, description) : null, actionLabel ? /*#__PURE__*/React.createElement("button", {
43
+ }, description) : null, action ? action : actionLabel ? /*#__PURE__*/React.createElement("button", {
43
44
  className: "ef-toast__action",
44
45
  onClick: onAction
45
46
  }, actionLabel) : null), onClose ? /*#__PURE__*/React.createElement(IconButton, {
@@ -118,7 +119,7 @@ export function Toaster({
118
119
  } = options || {};
119
120
  // A toast carrying an action must not time out: WCAG 2.2.1 does not allow a
120
121
  // control to disappear on a timer the user cannot adjust.
121
- const ms = own != null ? own : props.actionLabel ? 0 : duration;
122
+ const ms = own != null ? own : props.action || props.actionLabel ? 0 : duration;
122
123
  setToasts(list => [...list, {
123
124
  id,
124
125
  props
@@ -22,9 +22,16 @@ export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
22
22
  size?: 'sm' | 'md' | 'lg';
23
23
  disabled?: boolean;
24
24
  placeholder?: string;
25
- /** Display formatting for the committed value, e.g. n => n + ' GB' */
25
+ /**
26
+ * BCP 47 locale (e.g. 'id', 'en-US') for locale-aware display and parsing via
27
+ * Intl.NumberFormat — 'id' groups with '.' and decimals with ',', 'en' the
28
+ * reverse. Ignored when both `format` and `parse` are given. Omit for plain,
29
+ * ungrouped formatting (the default).
30
+ */
31
+ locale?: string;
32
+ /** Display formatting for the committed value, e.g. n => n + ' GB'. Wins over `locale`. */
26
33
  format?: (value: number) => string;
27
- /** Turn typed text back into a number; pair it with `format`. Return null for unparseable. */
34
+ /** Turn typed text back into a number; pair it with `format`. Return null for unparseable. Wins over `locale`. */
28
35
  parse?: (text: string) => number | null;
29
36
  style?: React.CSSProperties;
30
37
  className?: string;
@@ -17,6 +17,28 @@ const defaultParse = t => {
17
17
  const n = Number(t.replace(/,/g, ''));
18
18
  return Number.isFinite(n) ? n : null;
19
19
  };
20
+ // A locale's own format and parse, derived from Intl so the two always agree:
21
+ // 'en' groups with ',' and points with '.', 'id' the other way round. Parsing
22
+ // reads the locale's real separators (via formatToParts) rather than assuming,
23
+ // so a value the field displayed round-trips back to the same number.
24
+ function localeNumber(locale) {
25
+ const nf = new Intl.NumberFormat(locale, {
26
+ maximumFractionDigits: 20
27
+ });
28
+ const parts = nf.formatToParts(12345.6);
29
+ const group = (parts.find(p => p.type === 'group') || {}).value || '';
30
+ const decimal = (parts.find(p => p.type === 'decimal') || {}).value || '.';
31
+ return {
32
+ format: n => nf.format(n),
33
+ parse: t => {
34
+ let s = t.trim();
35
+ if (group) s = s.split(group).join('');
36
+ if (decimal !== '.') s = s.split(decimal).join('.');
37
+ const n = Number(s);
38
+ return Number.isFinite(n) ? n : null;
39
+ }
40
+ };
41
+ }
20
42
  /**
21
43
  * A numeric field with stepper buttons — a text input with inputmode="decimal"
22
44
  * rather than type=number, so typing stays free-form and the value only
@@ -37,12 +59,17 @@ export function NumberInput({
37
59
  size = 'md',
38
60
  disabled,
39
61
  placeholder,
62
+ locale,
40
63
  format,
41
64
  parse,
42
65
  style,
43
66
  className,
44
67
  ...rest
45
68
  }) {
69
+ // locale supplies a format/parse pair when neither is given explicitly; an
70
+ // explicit format or parse always wins over it, and no locale keeps the old
71
+ // plain behaviour, so this is additive.
72
+ const loc = locale && !(format && parse) ? localeNumber(locale) : null;
46
73
  // Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
47
74
  const field = useFieldProps({
48
75
  invalid,
@@ -57,11 +84,11 @@ export function NumberInput({
57
84
  const v = value !== undefined ? value : inner;
58
85
  // The text being edited; null means "not editing, show the formatted value".
59
86
  const [draft, setDraft] = React.useState(null);
60
- const fmt = n => format ? format(n) : String(n);
87
+ const fmt = n => format ? format(n) : loc ? loc.format(n) : String(n);
61
88
  const parseText = t => {
62
89
  const s = t.trim();
63
90
  if (s === '') return null;
64
- const n = (parse || defaultParse)(s);
91
+ const n = (parse || loc && loc.parse || defaultParse)(s);
65
92
  return n != null && Number.isFinite(n) ? n : undefined; // undefined = unparseable
66
93
  };
67
94
  const normalize = n => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efolusi/meridian",
3
- "version": "1.9.2",
3
+ "version": "1.11.0",
4
4
  "description": "A general-purpose open-source design system by Efolusi: accessible React components, design tokens, blocks and example apps.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://meridian.efolusi.com",