@efolusi/meridian 1.10.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/code/EnvList.d.ts +3 -0
- package/code/EnvList.js +3 -2
- package/dates/Calendar.d.ts +4 -0
- package/dates/Calendar.js +55 -6
- package/dates/DatePicker.d.ts +2 -0
- package/dates/DatePicker.js +7 -3
- package/dates/DateRangePicker.d.ts +2 -0
- package/dates/DateRangePicker.js +5 -3
- package/forms/NumberInput.d.ts +9 -2
- package/forms/NumberInput.js +29 -2
- package/package.json +1 -1
- package/tokens/base.css +1 -1
- package/tokens/colors.css +1 -1
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
|
-
|
|
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 : ''}`,
|
package/dates/Calendar.d.ts
CHANGED
|
@@ -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
|
-
},
|
|
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": `${
|
|
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
|
-
},
|
|
132
|
-
key:
|
|
180
|
+
}, DOW_L.map((d, i) => /*#__PURE__*/React.createElement("span", {
|
|
181
|
+
key: i,
|
|
133
182
|
role: "columnheader",
|
|
134
|
-
"aria-label":
|
|
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":
|
|
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());
|
package/dates/DatePicker.d.ts
CHANGED
|
@@ -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
|
}
|
package/dates/DatePicker.js
CHANGED
|
@@ -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
|
-
|
|
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
|
}
|
package/dates/DateRangePicker.js
CHANGED
|
@@ -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
|
}
|
package/forms/NumberInput.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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;
|
package/forms/NumberInput.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "1.11.1",
|
|
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",
|
package/tokens/base.css
CHANGED
|
@@ -5,6 +5,6 @@ a{color:var(--text-link);text-decoration:none;transition:color var(--dur-fast) v
|
|
|
5
5
|
a:hover{color:var(--accent-hover);text-decoration:underline;text-underline-offset:3px}
|
|
6
6
|
a:focus-visible{outline:none;box-shadow:var(--focus-ring);border-radius:var(--radius-sm)}
|
|
7
7
|
code,pre,kbd{font-family:var(--font-mono)}
|
|
8
|
-
::selection{background:var(--brand-100)}
|
|
8
|
+
::selection{background:var(--brand-100);color:var(--cocoa-900)}
|
|
9
9
|
*,*::before,*::after{box-sizing:border-box}
|
|
10
10
|
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important}}
|
package/tokens/colors.css
CHANGED
|
@@ -45,4 +45,4 @@
|
|
|
45
45
|
--danger-100:#321B18;--danger-300:#54291F;--danger-600:#E85D4A;--danger-contrast:#1E1A14;--success-contrast:#1E1A14;--warning-contrast:#1E1A14;
|
|
46
46
|
--focus-ring-color:var(--brand-400);/* offset + composite inherit from :root and re-resolve here */
|
|
47
47
|
}
|
|
48
|
-
[data-theme="dark"] ::selection{background:#453728}
|
|
48
|
+
[data-theme="dark"] ::selection{background:#453728;color:#F3EFE7}
|