@adminiumjs/ui 0.1.0 → 0.2.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/dist/components/auth-layout/AuthLayout.d.ts +3 -3
- package/dist/components/auth-layout/AuthLayout.js +4 -4
- package/dist/components/auth-screens/ForgotPasswordForm.d.ts +3 -3
- package/dist/components/auth-screens/ForgotPasswordForm.js +2 -2
- package/dist/components/auth-screens/ResetPasswordForm.d.ts +1 -1
- package/dist/components/auth-screens/ResetPasswordForm.js +1 -1
- package/dist/components/auth-screens/SignInForm.d.ts +1 -1
- package/dist/components/auth-screens/SignInForm.js +1 -1
- package/dist/components/auth-screens/TwoFactorForm.d.ts +1 -1
- package/dist/components/auth-screens/TwoFactorForm.js +1 -1
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/button/Button.d.ts.map +1 -1
- package/dist/components/button/Button.js +5 -2
- package/dist/components/button/Button.js.map +1 -1
- package/dist/components/empty-state/EmptyState.js +1 -1
- package/dist/components/mono-text/MonoText.d.ts +1 -1
- package/dist/components/mono-text/MonoText.js +1 -1
- package/dist/components/otp-input/OtpInput.d.ts +1 -1
- package/dist/components/otp-input/OtpInput.js +1 -1
- package/dist/components/permission-matrix/PermissionMatrix.d.ts +1 -1
- package/dist/components/permission-matrix/PermissionMatrix.js +1 -1
- package/dist/components/runtime-chip/RuntimeChip.js +1 -1
- package/dist/components/skeleton/Skeleton.d.ts +1 -1
- package/dist/components/skeleton/Skeleton.js +1 -1
- package/dist/components/stepper/Stepper.d.ts.map +1 -1
- package/dist/components/stepper/Stepper.js +34 -3
- package/dist/components/stepper/Stepper.js.map +1 -1
- package/dist/components/success-state/SuccessState.d.ts +1 -1
- package/dist/components/success-state/SuccessState.js +1 -1
- package/dist/components/toast/useToastQueue.d.ts +2 -2
- package/dist/components/toast/useToastQueue.d.ts.map +1 -1
- package/dist/components/toast/useToastQueue.js +2 -2
- package/dist/components/toast/useToastQueue.js.map +1 -1
- package/dist/components/toggle-matrix/ToggleMatrix.d.ts +1 -1
- package/dist/components/toggle-matrix/ToggleMatrix.js +1 -1
- package/dist/components/two-phase-modal/TwoPhaseModal.d.ts +2 -2
- package/dist/components/two-phase-modal/TwoPhaseModal.d.ts.map +1 -1
- package/dist/components/two-phase-modal/TwoPhaseModal.js +10 -3
- package/dist/components/two-phase-modal/TwoPhaseModal.js.map +1 -1
- package/dist/hooks/useUndoableAction.d.ts +2 -2
- package/dist/hooks/useUndoableAction.js +2 -2
- package/dist/lib/cn.d.ts +2 -2
- package/dist/lib/cn.js +2 -2
- package/dist/lib/tones.d.ts +17 -4
- package/dist/lib/tones.d.ts.map +1 -1
- package/dist/lib/tones.js +21 -8
- package/dist/lib/tones.js.map +1 -1
- package/dist/theme/ThemeProvider.d.ts +10 -1
- package/dist/theme/ThemeProvider.d.ts.map +1 -1
- package/dist/theme/ThemeProvider.js +33 -6
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/subscribe.d.ts +12 -2
- package/dist/theme/subscribe.d.ts.map +1 -1
- package/dist/theme/subscribe.js +19 -3
- package/dist/theme/subscribe.js.map +1 -1
- package/dist/theme/types.d.ts +35 -6
- package/dist/theme/types.d.ts.map +1 -1
- package/dist/theme/types.js +24 -5
- package/dist/theme/types.js.map +1 -1
- package/dist/theme/useTheme.js +1 -1
- package/package.json +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { Modal } from '../modal/Modal.js';
|
|
4
4
|
import { SuccessState } from '../success-state/SuccessState.js';
|
|
5
5
|
/**
|
|
6
6
|
* useModalFlow — state machine for the canonical two-phase (form → success)
|
|
7
|
-
* modal (
|
|
7
|
+
* modal (03-component-library.md §7.1, research/ia-mapping.md §5.3).
|
|
8
8
|
*/
|
|
9
9
|
export function useModalFlow() {
|
|
10
10
|
const [state, setState] = useState({
|
|
@@ -30,10 +30,17 @@ function resolve(value, payload) {
|
|
|
30
30
|
* preserving focus; harvested inputs echo into the success copy; Done and
|
|
31
31
|
* Esc/backdrop close, and `flow.reset()` runs after the exit animation so the
|
|
32
32
|
* success phase never flashes back to the form while closing
|
|
33
|
-
* (
|
|
33
|
+
* (03-component-library.md §7.1).
|
|
34
34
|
*/
|
|
35
35
|
export function TwoPhaseModal({ flow, children, successTitle, successBody, doneLabel, successProps, onOpenChange, ...modalProps }) {
|
|
36
36
|
const resetTimer = useRef(null);
|
|
37
|
+
// Unmounting before the deferred reset fires would otherwise leave the timer
|
|
38
|
+
// to call `flow.reset()` against a dead component (a setState-after-unmount
|
|
39
|
+
// in the app; in tests, a callback that can outlive the environment teardown).
|
|
40
|
+
useEffect(() => () => {
|
|
41
|
+
if (resetTimer.current !== null)
|
|
42
|
+
clearTimeout(resetTimer.current);
|
|
43
|
+
}, []);
|
|
37
44
|
const handleOpenChange = (open) => {
|
|
38
45
|
onOpenChange?.(open);
|
|
39
46
|
if (!open) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TwoPhaseModal.js","sourceRoot":"","sources":["../../../src/components/two-phase-modal/TwoPhaseModal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TwoPhaseModal.js","sourceRoot":"","sources":["../../../src/components/two-phase-modal/TwoPhaseModal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAE,KAAK,EAAmB,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAA0B,MAAM,kCAAkC,CAAC;AAexF;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,CAAC,KAAK,EAAE,QA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,MAAM,gBAAgB,GAAG,CAAC,IAAa,EAAE,EAAE;QACzC,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI;gBAAE,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAClE,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBACnC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACb,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;YAC5B,CAAC,EAAE,aAAa,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,KAAK,OAAK,UAAU,EAAE,YAAY,EAAE,gBAAgB,YAClD,IAAI,CAAC,KAAK,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,CAChD,QAAQ,CACT,CAAC,CAAC,CAAC,CACF,KAAC,YAAY,OACP,YAAY,EAChB,KAAK,EAAE,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,EAC1C,IAAI,EAAE,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,EAChF,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,GACrC,CACH,GACK,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Duration of the undo window, matching the undo-toast auto-dismiss
|
|
3
|
-
* (
|
|
3
|
+
* (03-component-library.md §7.2 — action/Undo 5200ms).
|
|
4
4
|
*/
|
|
5
5
|
export declare const UNDO_WINDOW_MS = 5200;
|
|
6
6
|
export type UndoableState = 'idle' | 'pending' | 'committed' | 'undone';
|
|
@@ -43,7 +43,7 @@ export interface UseUndoableActionReturn<T> {
|
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* useUndoableAction — the perform-with-undo primitive behind destructive
|
|
46
|
-
* mutations (
|
|
46
|
+
* mutations (03-component-library.md §7.2 Undo pattern): `run()`
|
|
47
47
|
* applies the mutation optimistically, then either `undo()` reverts it within
|
|
48
48
|
* the window or `commit()` finalizes it (called automatically when the window
|
|
49
49
|
* elapses, and on unmount while pending).
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Duration of the undo window, matching the undo-toast auto-dismiss
|
|
4
|
-
* (
|
|
4
|
+
* (03-component-library.md §7.2 — action/Undo 5200ms).
|
|
5
5
|
*/
|
|
6
6
|
export const UNDO_WINDOW_MS = 5200;
|
|
7
7
|
/**
|
|
8
8
|
* useUndoableAction — the perform-with-undo primitive behind destructive
|
|
9
|
-
* mutations (
|
|
9
|
+
* mutations (03-component-library.md §7.2 Undo pattern): `run()`
|
|
10
10
|
* applies the mutation optimistically, then either `undo()` reverts it within
|
|
11
11
|
* the window or `commit()` finalizes it (called automatically when the window
|
|
12
12
|
* elapses, and on unmount while pending).
|
package/dist/lib/cn.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `cn()` — the single class-composition utility for `@adminium/ui`
|
|
3
|
-
* (
|
|
3
|
+
* (03-component-library.md §2, §3.1).
|
|
4
4
|
*
|
|
5
5
|
* clsx handles conditional/array inputs; tailwind-merge resolves conflicting
|
|
6
6
|
* Tailwind utilities so the consumer `className` (always passed last by
|
|
@@ -18,7 +18,7 @@ export declare function cn(...inputs: ClassValue[]): string;
|
|
|
18
18
|
export type CssVarMap = Record<`--${string}`, string | number | null | undefined>;
|
|
19
19
|
/**
|
|
20
20
|
* `cssVars()` — typed builder for CSS-custom-property bags
|
|
21
|
-
* (
|
|
21
|
+
* (03-component-library.md §3.4).
|
|
22
22
|
*
|
|
23
23
|
* The JSX `style` prop is banned (`adminium/no-style-prop`); its single
|
|
24
24
|
* sanctioned escape hatch is an INLINE object literal whose every key is a
|
package/dist/lib/cn.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `cn()` — the single class-composition utility for `@adminium/ui`
|
|
3
|
-
* (
|
|
3
|
+
* (03-component-library.md §2, §3.1).
|
|
4
4
|
*
|
|
5
5
|
* clsx handles conditional/array inputs; tailwind-merge resolves conflicting
|
|
6
6
|
* Tailwind utilities so the consumer `className` (always passed last by
|
|
@@ -37,7 +37,7 @@ export function cn(...inputs) {
|
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* `cssVars()` — typed builder for CSS-custom-property bags
|
|
40
|
-
* (
|
|
40
|
+
* (03-component-library.md §3.4).
|
|
41
41
|
*
|
|
42
42
|
* The JSX `style` prop is banned (`adminium/no-style-prop`); its single
|
|
43
43
|
* sanctioned escape hatch is an INLINE object literal whose every key is a
|
package/dist/lib/tones.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* lib/tones.ts — the canonical home of the semantic tone vocabulary and the
|
|
3
|
-
* status→tone registry (
|
|
3
|
+
* status→tone registry (03-component-library.md §3.3, §7.6).
|
|
4
4
|
*
|
|
5
5
|
* The SINGLE source of truth: components/icon-tile, components/badge and
|
|
6
6
|
* components/status-pill re-export from here (their wave-1 local copies are
|
|
@@ -13,7 +13,20 @@ export type Tone = 'neutral' | 'accent' | 'pos' | 'warn' | 'danger' | 'info';
|
|
|
13
13
|
export declare const TONES: readonly Tone[];
|
|
14
14
|
/** Tone → soft background + strong tone foreground utility pairs. */
|
|
15
15
|
export declare const toneSoftClasses: Record<Tone, string>;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Tone → solid background + on-tone foreground utility pairs.
|
|
18
|
+
*
|
|
19
|
+
* Every filled tone takes `text-accent-fg`, not `text-white`. `--accent-fg` is
|
|
20
|
+
* the theme's single inverted foreground (#ffffff light, #0f0f14 dark — see the
|
|
21
|
+
* "One --accent-fg per theme" note in tokens/src/accents.css), so it is the
|
|
22
|
+
* on-filled-surface colour for ALL solid fills, not just the accent one.
|
|
23
|
+
* Hardcoding white here failed the dark theme outright: white measures 2.00:1
|
|
24
|
+
* on --pos #3ecf8e, 2.18:1 on --warn #e0a458, 2.78:1 on --danger #ff6b6b and
|
|
25
|
+
* 2.41:1 on --info #6ea8ff, against a WCAG 2.1 AA floor of 4.5:1.
|
|
26
|
+
* `text-accent-fg` measures 5.13-5.91:1 light and 6.89-9.58:1 dark on the same
|
|
27
|
+
* four fills, and stays correct inside the `.adm-always-dark` /
|
|
28
|
+
* `.adm-always-light` exception scopes, which re-declare both sides together.
|
|
29
|
+
*/
|
|
17
30
|
export declare const toneSolidClasses: Record<Tone, string>;
|
|
18
31
|
/**
|
|
19
32
|
* Tone → `color-mix` border utilities used by Alert/Banner callouts
|
|
@@ -21,13 +34,13 @@ export declare const toneSolidClasses: Record<Tone, string>;
|
|
|
21
34
|
*/
|
|
22
35
|
export declare const toneMixBorderClasses: Record<Tone, string>;
|
|
23
36
|
/**
|
|
24
|
-
* Sticky translucent bar recipe (
|
|
37
|
+
* Sticky translucent bar recipe (03-component-library.md §7.5) —
|
|
25
38
|
* used by `Topbar`, `WizardLayout` footer and sticky table headers. Exported
|
|
26
39
|
* from here so the color-mix recipe lives in exactly one place.
|
|
27
40
|
*/
|
|
28
41
|
export declare const glassBar = "sticky top-0 z-40 border-b border-border bg-[color-mix(in_srgb,var(--surface)_82%,transparent)] backdrop-blur-[8px]";
|
|
29
42
|
/**
|
|
30
|
-
* Default status→tone registry (
|
|
43
|
+
* Default status→tone registry (03-component-library.md §7.6).
|
|
31
44
|
* Extended at runtime via `registerStatusTones` (widgets/manifests register
|
|
32
45
|
* domain statuses); tints always derive from the tone — never hardcoded per
|
|
33
46
|
* feature (the "Ticket Queue hardcoded priority tint" defect fix).
|
package/dist/lib/tones.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tones.d.ts","sourceRoot":"","sources":["../../src/lib/tones.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,0DAA0D;AAC1D,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE7E,kEAAkE;AAClE,eAAO,MAAM,KAAK,EAAE,SAAS,IAAI,EAA2D,CAAC;AAE7F,qEAAqE;AACrE,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAOhD,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"tones.d.ts","sourceRoot":"","sources":["../../src/lib/tones.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,0DAA0D;AAC1D,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE7E,kEAAkE;AAClE,eAAO,MAAM,KAAK,EAAE,SAAS,IAAI,EAA2D,CAAC;AAE7F,qEAAqE;AACrE,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAOhD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAOjD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAOrD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,wHACkG,CAAC;AAExH;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAyB9D,CAAC;AAIH,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,IAAI,CAInE;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,IAAgB,GAAG,IAAI,CAE3E"}
|
package/dist/lib/tones.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* lib/tones.ts — the canonical home of the semantic tone vocabulary and the
|
|
3
|
-
* status→tone registry (
|
|
3
|
+
* status→tone registry (03-component-library.md §3.3, §7.6).
|
|
4
4
|
*
|
|
5
5
|
* The SINGLE source of truth: components/icon-tile, components/badge and
|
|
6
6
|
* components/status-pill re-export from here (their wave-1 local copies are
|
|
@@ -18,14 +18,27 @@ export const toneSoftClasses = {
|
|
|
18
18
|
danger: 'bg-danger-soft text-danger',
|
|
19
19
|
info: 'bg-info-soft text-info',
|
|
20
20
|
};
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Tone → solid background + on-tone foreground utility pairs.
|
|
23
|
+
*
|
|
24
|
+
* Every filled tone takes `text-accent-fg`, not `text-white`. `--accent-fg` is
|
|
25
|
+
* the theme's single inverted foreground (#ffffff light, #0f0f14 dark — see the
|
|
26
|
+
* "One --accent-fg per theme" note in tokens/src/accents.css), so it is the
|
|
27
|
+
* on-filled-surface colour for ALL solid fills, not just the accent one.
|
|
28
|
+
* Hardcoding white here failed the dark theme outright: white measures 2.00:1
|
|
29
|
+
* on --pos #3ecf8e, 2.18:1 on --warn #e0a458, 2.78:1 on --danger #ff6b6b and
|
|
30
|
+
* 2.41:1 on --info #6ea8ff, against a WCAG 2.1 AA floor of 4.5:1.
|
|
31
|
+
* `text-accent-fg` measures 5.13-5.91:1 light and 6.89-9.58:1 dark on the same
|
|
32
|
+
* four fills, and stays correct inside the `.adm-always-dark` /
|
|
33
|
+
* `.adm-always-light` exception scopes, which re-declare both sides together.
|
|
34
|
+
*/
|
|
22
35
|
export const toneSolidClasses = {
|
|
23
36
|
neutral: 'bg-surface-3 text-fg',
|
|
24
37
|
accent: 'bg-accent text-accent-fg',
|
|
25
|
-
pos: 'bg-pos text-
|
|
26
|
-
warn: 'bg-warn text-
|
|
27
|
-
danger: 'bg-danger text-
|
|
28
|
-
info: 'bg-info text-
|
|
38
|
+
pos: 'bg-pos text-accent-fg',
|
|
39
|
+
warn: 'bg-warn text-accent-fg',
|
|
40
|
+
danger: 'bg-danger text-accent-fg',
|
|
41
|
+
info: 'bg-info text-accent-fg',
|
|
29
42
|
};
|
|
30
43
|
/**
|
|
31
44
|
* Tone → `color-mix` border utilities used by Alert/Banner callouts
|
|
@@ -40,13 +53,13 @@ export const toneMixBorderClasses = {
|
|
|
40
53
|
info: 'border-[color-mix(in_srgb,var(--info)_30%,transparent)]',
|
|
41
54
|
};
|
|
42
55
|
/**
|
|
43
|
-
* Sticky translucent bar recipe (
|
|
56
|
+
* Sticky translucent bar recipe (03-component-library.md §7.5) —
|
|
44
57
|
* used by `Topbar`, `WizardLayout` footer and sticky table headers. Exported
|
|
45
58
|
* from here so the color-mix recipe lives in exactly one place.
|
|
46
59
|
*/
|
|
47
60
|
export const glassBar = 'sticky top-0 z-40 border-b border-border bg-[color-mix(in_srgb,var(--surface)_82%,transparent)] backdrop-blur-[8px]';
|
|
48
61
|
/**
|
|
49
|
-
* Default status→tone registry (
|
|
62
|
+
* Default status→tone registry (03-component-library.md §7.6).
|
|
50
63
|
* Extended at runtime via `registerStatusTones` (widgets/manifests register
|
|
51
64
|
* domain statuses); tints always derive from the tone — never hardcoded per
|
|
52
65
|
* feature (the "Ticket Queue hardcoded priority tint" defect fix).
|
package/dist/lib/tones.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tones.js","sourceRoot":"","sources":["../../src/lib/tones.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,kEAAkE;AAClE,MAAM,CAAC,MAAM,KAAK,GAAoB,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE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ACxD,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Dir } from '@adminium/tokens';
|
|
3
|
+
import { type Locale, type ThemePrefs } from './types.js';
|
|
3
4
|
/** Called after each `setPref` with the axis, the new value, and the next full prefs. */
|
|
4
5
|
export type ThemePrefChangeHandler = <K extends keyof ThemePrefs>(key: K, value: ThemePrefs[K], prefs: ThemePrefs) => void;
|
|
5
6
|
export interface ThemeProviderProps {
|
|
@@ -9,6 +10,14 @@ export interface ThemeProviderProps {
|
|
|
9
10
|
userPrefs?: Partial<ThemePrefs>;
|
|
10
11
|
/** Persistence hook for `setPref` (M8 wires `PATCH /api/v1/me/prefs` here). */
|
|
11
12
|
onPrefChange?: ThemePrefChangeHandler;
|
|
13
|
+
/**
|
|
14
|
+
* Direction resolver for locales this package cannot know about
|
|
15
|
+
* (23 §5.4). The app injects one backed by `@adminium/i18n`'s runtime
|
|
16
|
+
* registry; return `null` to defer to the compiled table and the cached
|
|
17
|
+
* axis. Absent in Storybook and in tests, where only the eight compiled
|
|
18
|
+
* locales exist.
|
|
19
|
+
*/
|
|
20
|
+
resolveDir?: (locale: Locale) => Dir | null;
|
|
12
21
|
children: ReactNode;
|
|
13
22
|
}
|
|
14
23
|
export declare function ThemeProvider(props: ThemeProviderProps): ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeProvider.tsx"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeProvider.tsx"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EASL,KAAK,GAAG,EACT,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAIL,KAAK,MAAM,EAEX,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AAIpB,yFAAyF;AACzF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,SAAS,MAAM,UAAU,EAC9D,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,EACpB,KAAK,EAAE,UAAU,KACd,IAAI,CAAC;AAEV,MAAM,WAAW,kBAAkB;IACjC,yFAAyF;IACzF,cAAc,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,2EAA2E;IAC3E,SAAS,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAChC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,GAAG,GAAG,IAAI,CAAC;IAC5C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAqFD,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAmHlE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* ThemeProvider — runtime for the four theming axes (theme/accent/density/locale→dir),
|
|
4
|
-
* per
|
|
4
|
+
* per 02-design-system.md §4 and 03-component-library.md §3.6.
|
|
5
5
|
*
|
|
6
6
|
* Responsibilities:
|
|
7
7
|
* 1. Resolve effective prefs per-axis (§4.2): baseline ← localStorage pre-paint
|
|
@@ -36,7 +36,7 @@ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } fr
|
|
|
36
36
|
import { ACCENTS, DENSITIES, STORAGE_KEYS, THEMES, THEME_ATTRIBUTES, } from '@adminium/tokens';
|
|
37
37
|
import { ThemeContext, } from './context.js';
|
|
38
38
|
import { emitTheme } from './subscribe.js';
|
|
39
|
-
import { BASELINE_PREFS,
|
|
39
|
+
import { BASELINE_PREFS, dirForLocale, langForLocale, } from './types.js';
|
|
40
40
|
const DARK_QUERY = '(prefers-color-scheme: dark)';
|
|
41
41
|
/** Read the localStorage pre-paint cache, ignoring unknown/invalid values. */
|
|
42
42
|
function readStorageCache() {
|
|
@@ -55,8 +55,11 @@ function readStorageCache() {
|
|
|
55
55
|
if (density !== null && DENSITIES.includes(density)) {
|
|
56
56
|
cache.density = density;
|
|
57
57
|
}
|
|
58
|
+
// SHAPE check, not membership (23 §5.2): a cached preference may name an
|
|
59
|
+
// admin-created locale this build does not compile in, and dropping it
|
|
60
|
+
// would strand that user on en-US on every cold load.
|
|
58
61
|
const locale = window.localStorage.getItem(STORAGE_KEYS.locale);
|
|
59
|
-
if (locale !== null &&
|
|
62
|
+
if (locale !== null && LOCALE_ID_SHAPE.test(locale)) {
|
|
60
63
|
cache.locale = locale;
|
|
61
64
|
}
|
|
62
65
|
}
|
|
@@ -65,6 +68,29 @@ function readStorageCache() {
|
|
|
65
68
|
}
|
|
66
69
|
return cache;
|
|
67
70
|
}
|
|
71
|
+
/** Mirrors `LOCALE_ID_RE` in `@adminium/i18n` (this package cannot import it). */
|
|
72
|
+
const LOCALE_ID_SHAPE = /^[a-z]{2,3}(_[A-Za-z0-9]{2,8}){0,2}$/;
|
|
73
|
+
/**
|
|
74
|
+
* The `dir` the last resolved paint cached — an INDEPENDENT axis, not
|
|
75
|
+
* re-derived from the locale (23 §5.4).
|
|
76
|
+
*
|
|
77
|
+
* Without this, a custom RTL locale paints `rtl` from the pre-hydration
|
|
78
|
+
* script and snaps to `ltr` at hydration on every signed-out screen: this
|
|
79
|
+
* provider is the sole writer of the attribute, it recomputes direction on
|
|
80
|
+
* every commit, and on pre-auth surfaces there is no `userPrefs` and no
|
|
81
|
+
* locale registry to compute it from.
|
|
82
|
+
*/
|
|
83
|
+
function readCachedDir() {
|
|
84
|
+
if (typeof window === 'undefined')
|
|
85
|
+
return undefined;
|
|
86
|
+
try {
|
|
87
|
+
const dir = window.localStorage.getItem(STORAGE_KEYS.dir);
|
|
88
|
+
return dir === 'rtl' || dir === 'ltr' ? dir : undefined;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
68
94
|
function systemPrefersDark() {
|
|
69
95
|
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')
|
|
70
96
|
return false;
|
|
@@ -93,9 +119,10 @@ function reconcileSessionPrefs(session, propsResolved) {
|
|
|
93
119
|
return next;
|
|
94
120
|
}
|
|
95
121
|
export function ThemeProvider(props) {
|
|
96
|
-
const { globalDefaults, userPrefs, onPrefChange, children } = props;
|
|
122
|
+
const { globalDefaults, userPrefs, onPrefChange, resolveDir, children } = props;
|
|
97
123
|
// Read once per mount — the cache is a boot-time fallback, not a live source.
|
|
98
124
|
const [storageCache] = useState(readStorageCache);
|
|
125
|
+
const [cachedDir] = useState(readCachedDir);
|
|
99
126
|
// Axes changed via setPref during this session (optimistic layer, wins over props).
|
|
100
127
|
const [sessionPrefs, setSessionPrefs] = useState({});
|
|
101
128
|
const [prefersDark, setPrefersDark] = useState(systemPrefersDark);
|
|
@@ -139,8 +166,8 @@ export function ThemeProvider(props) {
|
|
|
139
166
|
accent: prefs.accent,
|
|
140
167
|
density: prefs.density,
|
|
141
168
|
locale: prefs.locale,
|
|
142
|
-
dir: dirForLocale(prefs.locale),
|
|
143
|
-
}), [prefs, prefersDark]);
|
|
169
|
+
dir: dirForLocale(prefs.locale, { resolve: resolveDir, cached: cachedDir }),
|
|
170
|
+
}), [prefs, prefersDark, resolveDir, cachedDir]);
|
|
144
171
|
// Stamp <html>, write the cache back, then notify listeners (§4 behaviors 1/3/5).
|
|
145
172
|
useLayoutEffect(() => {
|
|
146
173
|
const el = document.documentElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.js","sourceRoot":"","sources":["../../src/theme/ThemeProvider.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;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C,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACvD,eAAe,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/E,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,8EAA8E;IAC9E,4EAA4E;IAC5E,MAAM,gBAAgB,GAAqB,WAAW,CAAC,CAAC,GAAG,EAAE,EAAE;QAC7D,eAAe,CAAC,CAAC,IAAI,EAAE,EAAE;YACvB,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAC;YAChC,MAAM,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,YAAY,GAAsB,OAAO,CAC7C,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,EACtD,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAC7C,CAAC;IAEF,OAAO,CACL,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YACxC,KAAC,iBAAiB,IAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,YAAG,QAAQ,GAAqB,GAC9C,CACzB,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Non-React theme subscription (
|
|
2
|
+
* Non-React theme subscription (02-design-system.md §4.1) — for
|
|
3
3
|
* Leaflet tile swaps, chart re-tints, Electron `nativeTheme` mirroring.
|
|
4
4
|
* ThemeProvider emits AFTER the DOM attributes are committed (§4 behavior 5).
|
|
5
5
|
*/
|
|
@@ -7,6 +7,16 @@ import type { ResolvedTheme } from './types.js';
|
|
|
7
7
|
export type ThemeListener = (theme: ResolvedTheme) => void;
|
|
8
8
|
/** Subscribe to resolved-theme changes; returns an unsubscribe function. */
|
|
9
9
|
export declare function subscribeTheme(listener: ThemeListener): () => void;
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* @internal Called by ThemeProvider after stamping `<html>`. Not part of the
|
|
12
|
+
* public API.
|
|
13
|
+
*
|
|
14
|
+
* Each listener is isolated (23 §4.4). This runs inside ThemeProvider's
|
|
15
|
+
* `useLayoutEffect`, so an unguarded throw from ONE subscriber does not just
|
|
16
|
+
* lose that subscriber — it skips every listener after it (the i18n language
|
|
17
|
+
* bridge, the chart-direction bridge, the Electron `nativeTheme` mirror) and
|
|
18
|
+
* errors the React commit. That is a white screen. A subscriber must not be
|
|
19
|
+
* able to abort the theme commit, so failures are reported and swallowed.
|
|
20
|
+
*/
|
|
11
21
|
export declare function emitTheme(theme: ResolvedTheme): void;
|
|
12
22
|
//# sourceMappingURL=subscribe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/theme/subscribe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAI3D,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI,CAKlE;AAED
|
|
1
|
+
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/theme/subscribe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAI3D,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI,CAKlE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAQpD"}
|
package/dist/theme/subscribe.js
CHANGED
|
@@ -6,9 +6,25 @@ export function subscribeTheme(listener) {
|
|
|
6
6
|
listeners.delete(listener);
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @internal Called by ThemeProvider after stamping `<html>`. Not part of the
|
|
11
|
+
* public API.
|
|
12
|
+
*
|
|
13
|
+
* Each listener is isolated (23 §4.4). This runs inside ThemeProvider's
|
|
14
|
+
* `useLayoutEffect`, so an unguarded throw from ONE subscriber does not just
|
|
15
|
+
* lose that subscriber — it skips every listener after it (the i18n language
|
|
16
|
+
* bridge, the chart-direction bridge, the Electron `nativeTheme` mirror) and
|
|
17
|
+
* errors the React commit. That is a white screen. A subscriber must not be
|
|
18
|
+
* able to abort the theme commit, so failures are reported and swallowed.
|
|
19
|
+
*/
|
|
10
20
|
export function emitTheme(theme) {
|
|
11
|
-
for (const listener of [...listeners])
|
|
12
|
-
|
|
21
|
+
for (const listener of [...listeners]) {
|
|
22
|
+
try {
|
|
23
|
+
listener(theme);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error('[theme] subscriber threw; continuing with the remaining listeners', error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
13
29
|
}
|
|
14
30
|
//# sourceMappingURL=subscribe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../src/theme/subscribe.ts"],"names":[],"mappings":"AASA,MAAM,SAAS,GAAG,IAAI,GAAG,EAAiB,CAAC;AAE3C,4EAA4E;AAC5E,MAAM,UAAU,cAAc,CAAC,QAAuB;IACpD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxB,OAAO,GAAG,EAAE;QACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../src/theme/subscribe.ts"],"names":[],"mappings":"AASA,MAAM,SAAS,GAAG,IAAI,GAAG,EAAiB,CAAC;AAE3C,4EAA4E;AAC5E,MAAM,UAAU,cAAc,CAAC,QAAuB;IACpD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxB,OAAO,GAAG,EAAE;QACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAC,KAAoB;IAC5C,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;QACtC,IAAI,CAAC;YACH,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,mEAAmE,EAAE,KAAK,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/theme/types.d.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Theming axis types for ThemeProvider (
|
|
2
|
+
* Theming axis types for ThemeProvider (02-design-system.md §4.1).
|
|
3
3
|
* Axis value unions come from `@adminium/tokens` so the DOM attributes,
|
|
4
4
|
* Storybook toolbar and provider can never drift apart; the locale union and
|
|
5
5
|
* the pref/resolved shapes live here because they are UI-runtime concerns.
|
|
6
6
|
*/
|
|
7
7
|
import type { Accent, Density, Dir, ResolvedTheme as ResolvedThemeMode, ThemePref } from '@adminium/tokens';
|
|
8
|
-
/** The 8
|
|
8
|
+
/** The 8 COMPILED locales (02-design-system.md §4.1). */
|
|
9
9
|
export declare const LOCALES: readonly ["en_US", "de_DE", "ar_EG", "zh_CN", "zh_TW", "cs_CZ", "da_DK", "fr_FR"];
|
|
10
|
-
export type
|
|
10
|
+
export type BuiltinLocale = (typeof LOCALES)[number];
|
|
11
|
+
/**
|
|
12
|
+
* Any locale the instance may resolve to — the compiled eight plus whatever
|
|
13
|
+
* an admin created at runtime (23-runtime-translations.md §5). `(string & {})`
|
|
14
|
+
* keeps literal autocomplete for the eight.
|
|
15
|
+
*
|
|
16
|
+
* This package deliberately does NOT depend on `@adminium/i18n`, so it cannot
|
|
17
|
+
* look a custom locale up. Direction therefore arrives one of two ways — an
|
|
18
|
+
* injected `resolveDir` (from the app, which does have the registry) or the
|
|
19
|
+
* cached `dir` axis — see {@link dirForLocale} and ThemeProvider.
|
|
20
|
+
*/
|
|
21
|
+
export type Locale = BuiltinLocale | (string & {});
|
|
11
22
|
/** User-facing preferences: `theme` may be `system`; `dir` is derived, not a pref. */
|
|
12
23
|
export interface ThemePrefs {
|
|
13
24
|
theme: ThemePref;
|
|
@@ -25,8 +36,26 @@ export interface ResolvedTheme {
|
|
|
25
36
|
}
|
|
26
37
|
/** Baseline of the resolution order (BRIEF §7 via `@adminium/tokens`). */
|
|
27
38
|
export declare const BASELINE_PREFS: ThemePrefs;
|
|
28
|
-
/**
|
|
29
|
-
export declare function
|
|
30
|
-
/**
|
|
39
|
+
/** Direction of the COMPILED locales; `null` for anything else. */
|
|
40
|
+
export declare function builtinLocaleDir(locale: string): Dir | null;
|
|
41
|
+
/**
|
|
42
|
+
* Direction for a locale, best-effort and total.
|
|
43
|
+
*
|
|
44
|
+
* A hardcoded `locale === 'ar_EG'` test cannot answer for an admin-created
|
|
45
|
+
* RTL locale, and this package cannot import the runtime registry. So the
|
|
46
|
+
* order is: an injected resolver (the app has the registry) → the compiled
|
|
47
|
+
* table → the cached `dir` axis from the last resolved paint → `ltr`. The
|
|
48
|
+
* cached axis is what keeps a custom RTL locale from flashing on pre-auth
|
|
49
|
+
* screens, where no bootstrap payload exists yet (23 §5.4).
|
|
50
|
+
*/
|
|
51
|
+
export declare function dirForLocale(locale: Locale, opts?: {
|
|
52
|
+
resolve?: ((locale: Locale) => Dir | null) | undefined;
|
|
53
|
+
cached?: Dir | undefined;
|
|
54
|
+
}): Dir;
|
|
55
|
+
/**
|
|
56
|
+
* BCP-47 form of a locale for the `lang` attribute (`ar_EG` → `ar-EG`).
|
|
57
|
+
* Replaces EVERY underscore: a single replacement leaves `zh-Hant_TW`, which
|
|
58
|
+
* is not a valid tag (23 §5.5).
|
|
59
|
+
*/
|
|
31
60
|
export declare function langForLocale(locale: Locale): string;
|
|
32
61
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/theme/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,MAAM,EACN,OAAO,EACP,GAAG,EACH,aAAa,IAAI,iBAAiB,EAClC,SAAS,EACV,MAAM,kBAAkB,CAAC;AAG1B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/theme/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,MAAM,EACN,OAAO,EACP,GAAG,EACH,aAAa,IAAI,iBAAiB,EAClC,SAAS,EACV,MAAM,kBAAkB,CAAC;AAG1B,yDAAyD;AACzD,eAAO,MAAM,OAAO,mFASV,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD;;;;;;;;;GASG;AACH,MAAM,MAAM,MAAM,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEnD,sFAAsF;AACtF,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qFAAqF;AACrF,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,iBAAiB,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,GAAG,CAAC;CACV;AAED,0EAA0E;AAC1E,eAAO,MAAM,cAAc,EAAE,UAAiC,CAAC;AAE/D,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAG3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,GAAG,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,GAAG,GAAG,SAAS,CAAA;CAAO,GAC9F,GAAG,CAEL;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
package/dist/theme/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_PREFS } from '@adminium/tokens';
|
|
2
|
-
/** The 8
|
|
2
|
+
/** The 8 COMPILED locales (02-design-system.md §4.1). */
|
|
3
3
|
export const LOCALES = [
|
|
4
4
|
'en_US',
|
|
5
5
|
'de_DE',
|
|
@@ -12,12 +12,31 @@ export const LOCALES = [
|
|
|
12
12
|
];
|
|
13
13
|
/** Baseline of the resolution order (BRIEF §7 via `@adminium/tokens`). */
|
|
14
14
|
export const BASELINE_PREFS = { ...DEFAULT_PREFS };
|
|
15
|
-
/**
|
|
16
|
-
export function
|
|
15
|
+
/** Direction of the COMPILED locales; `null` for anything else. */
|
|
16
|
+
export function builtinLocaleDir(locale) {
|
|
17
|
+
if (!LOCALES.includes(locale))
|
|
18
|
+
return null;
|
|
17
19
|
return locale === 'ar_EG' ? 'rtl' : 'ltr';
|
|
18
20
|
}
|
|
19
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Direction for a locale, best-effort and total.
|
|
23
|
+
*
|
|
24
|
+
* A hardcoded `locale === 'ar_EG'` test cannot answer for an admin-created
|
|
25
|
+
* RTL locale, and this package cannot import the runtime registry. So the
|
|
26
|
+
* order is: an injected resolver (the app has the registry) → the compiled
|
|
27
|
+
* table → the cached `dir` axis from the last resolved paint → `ltr`. The
|
|
28
|
+
* cached axis is what keeps a custom RTL locale from flashing on pre-auth
|
|
29
|
+
* screens, where no bootstrap payload exists yet (23 §5.4).
|
|
30
|
+
*/
|
|
31
|
+
export function dirForLocale(locale, opts = {}) {
|
|
32
|
+
return opts.resolve?.(locale) ?? builtinLocaleDir(locale) ?? opts.cached ?? 'ltr';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* BCP-47 form of a locale for the `lang` attribute (`ar_EG` → `ar-EG`).
|
|
36
|
+
* Replaces EVERY underscore: a single replacement leaves `zh-Hant_TW`, which
|
|
37
|
+
* is not a valid tag (23 §5.5).
|
|
38
|
+
*/
|
|
20
39
|
export function langForLocale(locale) {
|
|
21
|
-
return locale.
|
|
40
|
+
return locale.replaceAll('_', '-');
|
|
22
41
|
}
|
|
23
42
|
//# sourceMappingURL=types.js.map
|
package/dist/theme/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/theme/types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/theme/types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,yDAAyD;AACzD,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;CACC,CAAC;AAgCX,0EAA0E;AAC1E,MAAM,CAAC,MAAM,cAAc,GAAe,EAAE,GAAG,aAAa,EAAE,CAAC;AAE/D,mEAAmE;AACnE,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,IAAI,CAAE,OAA6B,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAClE,OAAO,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AAC5C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAc,EACd,OAA6F,EAAE;IAE/F,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC;AACpF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAO,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/theme/useTheme.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminiumjs/ui",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@adminium/tokens": "npm:@adminiumjs/tokens@0.1
|
|
26
|
+
"@adminium/tokens": "npm:@adminiumjs/tokens@0.2.1",
|
|
27
27
|
"@radix-ui/react-checkbox": "^1.3.3",
|
|
28
28
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
29
29
|
"@radix-ui/react-direction": "^1.1.1",
|