@eifi1/ui-kit 0.34.0 → 0.35.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.
- package/README.md +82 -38
- package/dist/billing/billing-banner.d.ts +5 -2
- package/dist/billing/billing-banner.js.map +1 -1
- package/dist/billing/plan-limit-notice.d.ts +5 -2
- package/dist/billing/plan-limit-notice.js.map +1 -1
- package/dist/chart.js.map +1 -1
- package/dist/components/amount-input.d.ts +0 -3
- package/dist/components/amount-input.js +2 -2
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/calculator.d.ts +1 -4
- package/dist/components/calculator.js +1 -3
- package/dist/components/calculator.js.map +1 -1
- package/dist/components/chart-zoom.d.ts +0 -37
- package/dist/components/chart-zoom.js +1 -28
- package/dist/components/chart-zoom.js.map +1 -1
- package/dist/components/chip-input.d.ts +0 -4
- package/dist/components/chip-input.js +1 -5
- package/dist/components/chip-input.js.map +1 -1
- package/dist/components/combobox.d.ts +1 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/copy-button.d.ts +5 -1
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/currency-option-list.d.ts +3 -8
- package/dist/components/currency-option-list.js +1 -29
- package/dist/components/currency-option-list.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +3 -3
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filter-popover.js +1 -1
- package/dist/components/data-table-filter-popover.js.map +1 -1
- package/dist/components/data-table-labels.d.ts +1 -42
- package/dist/components/data-table-labels.js +2 -31
- package/dist/components/data-table-labels.js.map +1 -1
- package/dist/components/data-table-shared.d.ts +17 -1
- package/dist/components/data-table-shared.js +22 -0
- package/dist/components/data-table-shared.js.map +1 -1
- package/dist/components/data-table.d.ts +12 -2
- package/dist/components/data-table.js +18 -14
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +3 -1
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/dropdown.d.ts +18 -15
- package/dist/components/dropdown.js +11 -3
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +1 -1
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/field-base.d.ts +0 -5
- package/dist/components/field-base.js +0 -5
- package/dist/components/field-base.js.map +1 -1
- package/dist/components/field-parts.d.ts +3 -11
- package/dist/components/field-parts.js +1 -9
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/field-strip.d.ts +8 -23
- package/dist/components/field-strip.js +24 -22
- package/dist/components/field-strip.js.map +1 -1
- package/dist/components/field-sync.d.ts +0 -4
- package/dist/components/field-sync.js +0 -4
- package/dist/components/field-sync.js.map +1 -1
- package/dist/components/field.d.ts +4 -4
- package/dist/components/field.js.map +1 -1
- package/dist/components/full-bleed-dialog.js +2 -2
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/hover-menu.d.ts +6 -13
- package/dist/components/hover-menu.js +3 -3
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/inline-entity-combobox.d.ts +1 -1
- package/dist/components/inline-entity-combobox.js.map +1 -1
- package/dist/components/modal.d.ts +9 -1
- package/dist/components/modal.js +7 -4
- package/dist/components/modal.js.map +1 -1
- package/dist/components/multi-select.d.ts +5 -16
- package/dist/components/multi-select.js +5 -10
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/number-input.d.ts +0 -3
- package/dist/components/number-input.js +2 -4
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/popover.js +2 -2
- package/dist/components/popover.js.map +1 -1
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/server-wake.d.ts +0 -6
- package/dist/components/server-wake.js.map +1 -1
- package/dist/components/settings-fields.d.ts +4 -2
- package/dist/components/settings-fields.js.map +1 -1
- package/dist/components/stat-tile.d.ts +8 -2
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/swipeable-row.d.ts +2 -17
- package/dist/components/swipeable-row.js +11 -16
- package/dist/components/swipeable-row.js.map +1 -1
- package/dist/components/tooltip.d.ts +9 -1
- package/dist/components/tooltip.js +20 -5
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/translation-review.d.ts +10 -2
- package/dist/components/translation-review.js +11 -3
- package/dist/components/translation-review.js.map +1 -1
- package/dist/components/use-table-state.d.ts +31 -3
- package/dist/components/use-table-state.js +53 -8
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/components/user-avatar.d.ts +2 -2
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/components/wizard-stepper.d.ts +1 -4
- package/dist/components/wizard-stepper.js +2 -3
- package/dist/components/wizard-stepper.js.map +1 -1
- package/dist/currencies.d.ts +23 -0
- package/dist/currencies.js +38 -0
- package/dist/currencies.js.map +1 -0
- package/dist/demo/demo-banner.d.ts +7 -2
- package/dist/demo/demo-banner.js.map +1 -1
- package/dist/eslint/index.d.ts +83 -0
- package/dist/eslint/index.js +69 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/eslint/role-utilities.d.ts +48 -0
- package/dist/eslint/role-utilities.generated.d.ts +2 -0
- package/dist/eslint/role-utilities.generated.js +143 -0
- package/dist/eslint/role-utilities.generated.js.map +1 -0
- package/dist/eslint/role-utilities.js +43 -0
- package/dist/eslint/role-utilities.js.map +1 -0
- package/dist/feedback/feedback-menu.d.ts +2 -2
- package/dist/feedback/feedback-menu.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +3 -8
- package/dist/feedback/feedback-thread.js +0 -2
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/hooks/use-dismiss.d.ts +16 -3
- package/dist/hooks/use-dismiss.js +14 -2
- package/dist/hooks/use-dismiss.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +14 -4
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +1 -1
- package/dist/i18n/locales/en.js.map +2 -2
- package/dist/i18n/locales/fr.js +3 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/it.js +3 -2
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/refs.d.ts +13 -0
- package/dist/lib/refs.js +15 -0
- package/dist/lib/refs.js.map +1 -0
- package/dist/rhf/fields.d.ts +10 -10
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form-core.d.ts +5 -4
- package/dist/rhf/form-core.js.map +1 -1
- package/dist/rhf/form.d.ts +7 -36
- package/dist/rhf/form.js +1 -16
- package/dist/rhf/form.js.map +1 -1
- package/dist/rhf/line-items.d.ts +1 -1
- package/dist/rhf/line-items.js.map +1 -1
- package/dist/rhf/use-rhf-wizard-step.js.map +1 -1
- package/dist/rhf.js.map +1 -1
- package/dist/shell/option-switcher-menu.d.ts +5 -17
- package/dist/shell/option-switcher-menu.js +1 -3
- package/dist/shell/option-switcher-menu.js.map +1 -1
- package/dist/shell/role-switcher.d.ts +1 -4
- package/dist/shell/role-switcher.js +2 -3
- package/dist/shell/role-switcher.js.map +1 -1
- package/dist/shell/topbar-action-menu.d.ts +7 -19
- package/dist/shell/topbar-action-menu.js +1 -3
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell/topbar-controls.d.ts +3 -12
- package/dist/shell/topbar-controls.js +6 -9
- package/dist/shell/topbar-controls.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/viewport.d.ts +25 -2
- package/dist/testing/viewport.js +61 -10
- package/dist/testing/viewport.js.map +1 -1
- package/dist/theme/palette-presets.d.ts +0 -7
- package/dist/theme/palette-presets.js +0 -279
- package/dist/theme/palette-presets.js.map +1 -1
- package/dist/wizard/types.d.ts +0 -5
- package/dist/wizard/types.js +1 -5
- package/dist/wizard/types.js.map +1 -1
- package/package.json +9 -1
- package/src/billing/billing-banner.tsx +5 -2
- package/src/billing/plan-limit-notice.tsx +5 -2
- package/src/chart.ts +5 -3
- package/src/components/amount-input.tsx +2 -6
- package/src/components/calculator.tsx +2 -7
- package/src/components/chart-zoom.tsx +4 -47
- package/src/components/chip-input.tsx +0 -7
- package/src/components/combobox.tsx +1 -1
- package/src/components/copy-button.tsx +5 -1
- package/src/components/currency-option-list.tsx +8 -42
- package/src/components/danger-confirm.tsx +3 -3
- package/src/components/data-table-filter-popover.tsx +2 -1
- package/src/components/data-table-labels.ts +2 -84
- package/src/components/data-table-shared.tsx +55 -2
- package/src/components/data-table.tsx +29 -17
- package/src/components/dialog-frame.tsx +3 -1
- package/src/components/dropdown.tsx +42 -18
- package/src/components/entity-combobox.tsx +1 -1
- package/src/components/field-base.tsx +0 -11
- package/src/components/field-parts.tsx +5 -19
- package/src/components/field-strip.tsx +9 -25
- package/src/components/field-sync.tsx +0 -7
- package/src/components/field.tsx +4 -4
- package/src/components/full-bleed-dialog.tsx +4 -3
- package/src/components/hover-menu.tsx +12 -16
- package/src/components/inline-entity-combobox.tsx +1 -1
- package/src/components/modal.tsx +20 -4
- package/src/components/multi-select.tsx +13 -30
- package/src/components/number-input.tsx +3 -8
- package/src/components/popover.tsx +5 -3
- package/src/components/series-chart.tsx +1 -1
- package/src/components/server-wake.tsx +0 -6
- package/src/components/settings-fields.tsx +4 -2
- package/src/components/stat-tile.tsx +8 -2
- package/src/components/swipeable-row.tsx +15 -37
- package/src/components/tooltip.tsx +37 -6
- package/src/components/translation-review.tsx +25 -7
- package/src/components/use-table-state.ts +91 -10
- package/src/components/user-avatar.tsx +2 -2
- package/src/components/wizard-stepper.tsx +2 -6
- package/src/currencies.ts +70 -0
- package/src/demo/demo-banner.tsx +7 -2
- package/src/eslint/index.ts +161 -0
- package/src/eslint/role-utilities.generated.ts +146 -0
- package/src/eslint/role-utilities.ts +99 -0
- package/src/feedback/feedback-menu.tsx +2 -2
- package/src/feedback/feedback-thread.tsx +3 -8
- package/src/hooks/use-dismiss.ts +39 -4
- package/src/i18n/kit-labels.tsx +15 -5
- package/src/i18n/locales/fr.ts +3 -2
- package/src/i18n/locales/it.ts +3 -2
- package/src/index.ts +3 -1
- package/src/lib/refs.ts +22 -0
- package/src/rhf/fields.tsx +10 -10
- package/src/rhf/form-core.tsx +5 -4
- package/src/rhf/form.tsx +7 -43
- package/src/rhf/line-items.tsx +1 -1
- package/src/rhf/use-rhf-wizard-step.ts +4 -4
- package/src/rhf.ts +3 -2
- package/src/shell/option-switcher-menu.tsx +5 -22
- package/src/shell/role-switcher.tsx +2 -6
- package/src/shell/topbar-action-menu.tsx +7 -24
- package/src/shell/topbar-controls.tsx +6 -18
- package/src/testing/index.ts +3 -1
- package/src/testing/viewport.ts +125 -19
- package/src/theme/palette-presets.ts +7 -293
- package/src/wizard/types.ts +0 -8
|
@@ -7,29 +7,23 @@ export declare const TOPBAR_TRIGGER_CLASS = "size-9 rounded-md flex items-center
|
|
|
7
7
|
* wraps aligns to the reading edge in RTL too. */
|
|
8
8
|
export declare const TOPBAR_MENU_ITEM_CLASS = "flex w-full items-center justify-between gap-3 px-3 py-2 text-sm text-start text-secondary hover:bg-hover";
|
|
9
9
|
/** Sun/Moon toggle for the light/dark theme. Controlled: the app owns the mode. */
|
|
10
|
-
export declare function ThemeToggle({ mode, onToggle, "aria-label":
|
|
10
|
+
export declare function ThemeToggle({ mode, onToggle, "aria-label": ariaLabel, title, className, }: {
|
|
11
11
|
mode: ThemeMode;
|
|
12
12
|
onToggle: () => void;
|
|
13
13
|
/** Default: `topBar.theme` from the {@link UiKitProvider}, else English. */
|
|
14
14
|
"aria-label"?: string;
|
|
15
|
-
/** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).
|
|
16
|
-
* Names the control only when `aria-label` is absent. */
|
|
17
|
-
ariaLabel?: string;
|
|
18
15
|
title?: string;
|
|
19
16
|
className?: string;
|
|
20
17
|
}): import("react").JSX.Element;
|
|
21
18
|
/** Appearance-preset switcher: a hover menu of palette presets with per-theme
|
|
22
19
|
* colour swatches. Controlled — the app owns the active id and applies it. */
|
|
23
|
-
export declare function PaletteMenu({ palettes, activeId, mode, onSelect, "aria-label":
|
|
20
|
+
export declare function PaletteMenu({ palettes, activeId, mode, onSelect, "aria-label": ariaLabel, heading, }: {
|
|
24
21
|
palettes: PalettePreset[];
|
|
25
22
|
activeId: string;
|
|
26
23
|
mode: ThemeMode;
|
|
27
24
|
onSelect: (id: string) => void;
|
|
28
25
|
/** Default: `topBar.palette` from the {@link UiKitProvider}, else English. */
|
|
29
26
|
"aria-label"?: string;
|
|
30
|
-
/** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).
|
|
31
|
-
* Names the control only when `aria-label` is absent. */
|
|
32
|
-
ariaLabel?: string;
|
|
33
27
|
/** Optional small heading row above the list. */
|
|
34
28
|
heading?: string;
|
|
35
29
|
}): import("react").JSX.Element;
|
|
@@ -48,15 +42,12 @@ export interface LanguageOption {
|
|
|
48
42
|
* (Keksdose feedback #121). The flag also shows which language is currently on,
|
|
49
43
|
* which no icon can, and costs the same width on a crowded mobile bar. A globe
|
|
50
44
|
* covers the case where `current` matches nothing in `options`. */
|
|
51
|
-
export declare function LanguageMenu({ options, current, onChange, "aria-label":
|
|
45
|
+
export declare function LanguageMenu({ options, current, onChange, "aria-label": ariaLabel, heading, }: {
|
|
52
46
|
options: LanguageOption[];
|
|
53
47
|
current: string | undefined;
|
|
54
48
|
onChange: (code: string) => void;
|
|
55
49
|
/** Default: `topBar.language` from the {@link UiKitProvider}, else English. */
|
|
56
50
|
"aria-label"?: string;
|
|
57
|
-
/** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).
|
|
58
|
-
* Names the control only when `aria-label` is absent. */
|
|
59
|
-
ariaLabel?: string;
|
|
60
51
|
/** Optional small heading row above the list — as on `TopBarActionMenu`,
|
|
61
52
|
* `OptionSwitcherMenu` and `PaletteMenu`. */
|
|
62
53
|
heading?: string;
|
|
@@ -13,12 +13,11 @@ function MenuHeading({ children }) {
|
|
|
13
13
|
function ThemeToggle({
|
|
14
14
|
mode,
|
|
15
15
|
onToggle,
|
|
16
|
-
"aria-label":
|
|
17
|
-
ariaLabel,
|
|
16
|
+
"aria-label": ariaLabel,
|
|
18
17
|
title,
|
|
19
18
|
className
|
|
20
19
|
}) {
|
|
21
|
-
const labels = useKitLabels("topBar", DEFAULT_TOP_BAR_LABELS, { theme:
|
|
20
|
+
const labels = useKitLabels("topBar", DEFAULT_TOP_BAR_LABELS, { theme: ariaLabel });
|
|
22
21
|
const Icon = mode === "dark" ? Moon : Sun;
|
|
23
22
|
return /* @__PURE__ */ jsx(Tooltip, { label: title, portal: true, children: /* @__PURE__ */ jsx(
|
|
24
23
|
"button",
|
|
@@ -36,11 +35,10 @@ function PaletteMenu({
|
|
|
36
35
|
activeId,
|
|
37
36
|
mode,
|
|
38
37
|
onSelect,
|
|
39
|
-
"aria-label":
|
|
40
|
-
ariaLabel,
|
|
38
|
+
"aria-label": ariaLabel,
|
|
41
39
|
heading
|
|
42
40
|
}) {
|
|
43
|
-
const labels = useKitLabels("topBar", DEFAULT_TOP_BAR_LABELS, { palette:
|
|
41
|
+
const labels = useKitLabels("topBar", DEFAULT_TOP_BAR_LABELS, { palette: ariaLabel });
|
|
44
42
|
const activeName = palettes.find((p) => p.id === activeId)?.name ?? activeId;
|
|
45
43
|
return /* @__PURE__ */ jsx(
|
|
46
44
|
HoverMenu,
|
|
@@ -98,11 +96,10 @@ function LanguageMenu({
|
|
|
98
96
|
options,
|
|
99
97
|
current,
|
|
100
98
|
onChange,
|
|
101
|
-
"aria-label":
|
|
102
|
-
ariaLabel,
|
|
99
|
+
"aria-label": ariaLabel,
|
|
103
100
|
heading
|
|
104
101
|
}) {
|
|
105
|
-
const labels = useKitLabels("topBar", DEFAULT_TOP_BAR_LABELS, { language:
|
|
102
|
+
const labels = useKitLabels("topBar", DEFAULT_TOP_BAR_LABELS, { language: ariaLabel });
|
|
106
103
|
const active = options.find((o) => o.code === current);
|
|
107
104
|
return /* @__PURE__ */ jsx(
|
|
108
105
|
HoverMenu,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/shell/topbar-controls.tsx"],"sourcesContent":["import { Check, Globe, Moon, Palette, Sun } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { HoverMenu } from \"../components/hover-menu\";\nimport type { PalettePreset } from \"../theme/palette-presets\";\nimport type { ThemeMode } from \"../theme/theme-store\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { DEFAULT_TOP_BAR_LABELS, useKitLabels } from \"../i18n/kit-labels\";\n\n/** Shared square icon-button styling for top-bar triggers, so app-owned controls\n * (account/feedback menus) line up with the shared ones. */\nexport const TOPBAR_TRIGGER_CLASS =\n \"size-9 rounded-md flex items-center justify-center text-secondary hover:text-primary hover:bg-hover\";\n\n/** Shared row styling for the top-bar hover-menu items. `text-start`, so a label that\n * wraps aligns to the reading edge in RTL too. */\nexport const TOPBAR_MENU_ITEM_CLASS =\n \"flex w-full items-center justify-between gap-3 px-3 py-2 text-sm text-start text-secondary hover:bg-hover\";\n\n/** The small uppercase heading row the top-bar menus share (`heading`). */\nfunction MenuHeading({ children }: { children: string }) {\n return (\n <li className=\"px-3 py-1 text-micro font-semibold uppercase tracking-wide text-placeholder\">\n {children}\n </li>\n );\n}\n\n/** Sun/Moon toggle for the light/dark theme. Controlled: the app owns the mode. */\nexport function ThemeToggle({\n mode,\n onToggle,\n \"aria-label\": ariaLabelAttr,\n ariaLabel,\n title,\n className,\n}: {\n mode: ThemeMode;\n onToggle: () => void;\n /** Default: `topBar.theme` from the {@link UiKitProvider}, else English. */\n \"aria-label\"?: string;\n /** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).\n * Names the control only when `aria-label` is absent. */\n ariaLabel?: string;\n title?: string;\n className?: string;\n}) {\n // This had no default at all, so a toggle rendered without `aria-label` was an\n // icon button with no name — a reader heard \"button\" and nothing else.\n const labels = useKitLabels(\"topBar\", DEFAULT_TOP_BAR_LABELS, { theme: ariaLabelAttr ?? ariaLabel });\n const Icon = mode === \"dark\" ? Moon : Sun;\n return (\n <Tooltip label={title} portal>\n <button\n type=\"button\"\n onClick={onToggle}\n aria-label={labels.theme}\n className={cn(TOPBAR_TRIGGER_CLASS, className)}\n >\n <Icon className=\"size-5\" />\n </button>\n </Tooltip>\n );\n}\n\n/** Appearance-preset switcher: a hover menu of palette presets with per-theme\n * colour swatches. Controlled — the app owns the active id and applies it. */\nexport function PaletteMenu({\n palettes,\n activeId,\n mode,\n onSelect,\n \"aria-label\": ariaLabelAttr,\n ariaLabel,\n heading,\n}: {\n palettes: PalettePreset[];\n activeId: string;\n mode: ThemeMode;\n onSelect: (id: string) => void;\n /** Default: `topBar.palette` from the {@link UiKitProvider}, else English. */\n \"aria-label\"?: string;\n /** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).\n * Names the control only when `aria-label` is absent. */\n ariaLabel?: string;\n /** Optional small heading row above the list. */\n heading?: string;\n}) {\n const labels = useKitLabels(\"topBar\", DEFAULT_TOP_BAR_LABELS, { palette: ariaLabelAttr ?? ariaLabel });\n const activeName = palettes.find((p) => p.id === activeId)?.name ?? activeId;\n return (\n <HoverMenu\n aria-label={labels.palette}\n trigger={({ toggle }) => (\n <Tooltip label={activeName} portal>\n <button\n type=\"button\"\n onClick={toggle}\n aria-label={labels.palette}\n className={TOPBAR_TRIGGER_CLASS}\n >\n {/* A DATA colour, not a semantic one: the palette mark is the\n \"colour\" control, so it carries a colour, and which hue is\n arbitrary. `--chart-1` is the violet end of the CVD-safe\n categorical ramp and flips per theme — a fixed `violet-500` did\n not, and stayed a cool violet island on a warm page. */}\n <Palette className=\"size-5 text-[var(--chart-1)]\" />\n </button>\n </Tooltip>\n )}\n >\n {(close) => (\n <ul className=\"w-60 py-1\">\n {heading && <MenuHeading>{heading}</MenuHeading>}\n {palettes.map((p) => {\n const ts = p[mode];\n const swatches = [ts.bgPage, ts.brand, ts.moneyIncome, ts.moneyExpense, ts.moneyNet];\n return (\n <li key={p.id}>\n <button\n type=\"button\"\n onClick={() => {\n onSelect(p.id);\n close();\n }}\n className={TOPBAR_MENU_ITEM_CLASS}\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n <span className=\"flex shrink-0 gap-0.5\">\n {/* Deliberately a neutral at 10% and not a token: this hairline\n sits on an ARBITRARY preset colour, so it has to read against\n whatever that preset paints, which no themed border does. */}\n {swatches.map((c, i) => (\n <span\n key={i}\n className=\"size-3.5 rounded-sm ring-1 ring-inset ring-black/10 dark:ring-white/10\"\n style={{ background: c }}\n />\n ))}\n </span>\n <span className=\"flex min-w-0 flex-col text-start\">\n <span className=\"truncate\">{p.name}</span>\n <span className=\"truncate text-caption text-placeholder\">\n {p.blurb}\n </span>\n </span>\n </span>\n {activeId === p.id && (\n <Check className=\"size-4 shrink-0 text-secondary\" />\n )}\n </button>\n </li>\n );\n })}\n </ul>\n )}\n </HoverMenu>\n );\n}\n\nexport interface LanguageOption {\n code: string;\n label: string;\n /** ISO 3166-1 alpha-2 country code (lowercase) for the flag-icons flag. */\n country: string;\n}\n\n/** Language switcher: a hover menu of options with flags and a check on the\n * active one. Controlled — the app owns the current code and change handler.\n *\n * The trigger is the *active* option's flag, not an icon: lucide's `Languages`\n * glyph (文A) is the same mark Chrome puts in the omnibox for \"translate this\n * page\", so it read as machine-translation rather than \"pick the UI language\"\n * (Keksdose feedback #121). The flag also shows which language is currently on,\n * which no icon can, and costs the same width on a crowded mobile bar. A globe\n * covers the case where `current` matches nothing in `options`. */\nexport function LanguageMenu({\n options,\n current,\n onChange,\n \"aria-label\": ariaLabelAttr,\n ariaLabel,\n heading,\n}: {\n options: LanguageOption[];\n current: string | undefined;\n onChange: (code: string) => void;\n /** Default: `topBar.language` from the {@link UiKitProvider}, else English. */\n \"aria-label\"?: string;\n /** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).\n * Names the control only when `aria-label` is absent. */\n ariaLabel?: string;\n /** Optional small heading row above the list — as on `TopBarActionMenu`,\n * `OptionSwitcherMenu` and `PaletteMenu`. */\n heading?: string;\n}) {\n const labels = useKitLabels(\"topBar\", DEFAULT_TOP_BAR_LABELS, { language: ariaLabelAttr ?? ariaLabel });\n const active = options.find((o) => o.code === current);\n return (\n <HoverMenu\n aria-label={labels.language}\n trigger={({ toggle }) => (\n <Tooltip label={active?.label ?? labels.language} portal>\n <button\n type=\"button\"\n onClick={toggle}\n aria-label={labels.language}\n className={TOPBAR_TRIGGER_CLASS}\n >\n {active ? (\n <span\n aria-hidden\n className={`fi fi-${active.country} inline-block h-[0.9375rem] w-5 shrink-0 rounded-sm shadow-[0_0_0_1px_rgba(0,0,0,0.08)]`}\n />\n ) : (\n <Globe className=\"size-5\" />\n )}\n </button>\n </Tooltip>\n )}\n >\n {(close) => (\n <ul className=\"py-1\">\n {heading && <MenuHeading>{heading}</MenuHeading>}\n {options.map((lang) => {\n const isActive = lang.code === current;\n return (\n <li key={lang.code}>\n <button\n type=\"button\"\n onClick={() => {\n onChange(lang.code);\n close();\n }}\n className={TOPBAR_MENU_ITEM_CLASS}\n >\n <span className=\"flex items-center gap-2\">\n <span\n aria-hidden\n className={`fi fi-${lang.country} inline-block h-[0.9375rem] w-5 shrink-0 rounded-sm shadow-[0_0_0_1px_rgba(0,0,0,0.08)]`}\n />\n {lang.label}\n </span>\n {isActive && <Check className=\"size-4 text-secondary\" />}\n </button>\n </li>\n );\n })}\n </ul>\n )}\n </HoverMenu>\n );\n}\n"],"mappings":";AAqBI,cAsHgB,YAtHhB;AArBJ,SAAS,OAAO,OAAO,MAAM,SAAS,WAAW;AACjD,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAG1B,SAAS,eAAe;AACxB,SAAS,wBAAwB,oBAAoB;AAI9C,MAAM,uBACX;AAIK,MAAM,yBACX;AAGF,SAAS,YAAY,EAAE,SAAS,GAAyB;AACvD,SACE,oBAAC,QAAG,WAAU,+EACX,UACH;AAEJ;AAG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O,OAAO;AAAA;AAAA,UACpC,IAEA,oBAAC,SAAM,WAAU,UAAS;AAAA;AAAA,MAE9B,GACF;AAAA,MAGD,WAAC,UACA,qBAAC,QAAG,WAAU,QACX;AAAA,mBAAW,oBAAC,eAAa,mBAAQ;AAAA,QACjC,QAAQ,IAAI,CAAC,SAAS;AACrB,gBAAM,WAAW,KAAK,SAAS;AAC/B,iBACE,oBAAC,QACC;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS,MAAM;AACb,yBAAS,KAAK,IAAI;AAClB,sBAAM;AAAA,cACR;AAAA,cACA,WAAW;AAAA,cAEX;AAAA,qCAAC,UAAK,WAAU,2BACd;AAAA;AAAA,oBAAC;AAAA;AAAA,sBACC,eAAW;AAAA,sBACX,WAAW,SAAS,KAAK,OAAO;AAAA;AAAA,kBAClC;AAAA,kBACC,KAAK;AAAA,mBACR;AAAA,gBACC,YAAY,oBAAC,SAAM,WAAU,yBAAwB;AAAA;AAAA;AAAA,UACxD,KAjBO,KAAK,IAkBd;AAAA,QAEJ,CAAC;AAAA,SACH;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/shell/topbar-controls.tsx"],"sourcesContent":["import { Check, Globe, Moon, Palette, Sun } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { HoverMenu } from \"../components/hover-menu\";\nimport type { PalettePreset } from \"../theme/palette-presets\";\nimport type { ThemeMode } from \"../theme/theme-store\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { DEFAULT_TOP_BAR_LABELS, useKitLabels } from \"../i18n/kit-labels\";\n\n/** Shared square icon-button styling for top-bar triggers, so app-owned controls\n * (account/feedback menus) line up with the shared ones. */\nexport const TOPBAR_TRIGGER_CLASS =\n \"size-9 rounded-md flex items-center justify-center text-secondary hover:text-primary hover:bg-hover\";\n\n/** Shared row styling for the top-bar hover-menu items. `text-start`, so a label that\n * wraps aligns to the reading edge in RTL too. */\nexport const TOPBAR_MENU_ITEM_CLASS =\n \"flex w-full items-center justify-between gap-3 px-3 py-2 text-sm text-start text-secondary hover:bg-hover\";\n\n/** The small uppercase heading row the top-bar menus share (`heading`). */\nfunction MenuHeading({ children }: { children: string }) {\n return (\n <li className=\"px-3 py-1 text-micro font-semibold uppercase tracking-wide text-placeholder\">\n {children}\n </li>\n );\n}\n\n/** Sun/Moon toggle for the light/dark theme. Controlled: the app owns the mode. */\nexport function ThemeToggle({\n mode,\n onToggle,\n \"aria-label\": ariaLabel,\n title,\n className,\n}: {\n mode: ThemeMode;\n onToggle: () => void;\n /** Default: `topBar.theme` from the {@link UiKitProvider}, else English. */\n \"aria-label\"?: string;\n title?: string;\n className?: string;\n}) {\n // This had no default at all, so a toggle rendered without `aria-label` was an\n // icon button with no name — a reader heard \"button\" and nothing else.\n const labels = useKitLabels(\"topBar\", DEFAULT_TOP_BAR_LABELS, { theme: ariaLabel });\n const Icon = mode === \"dark\" ? Moon : Sun;\n return (\n <Tooltip label={title} portal>\n <button\n type=\"button\"\n onClick={onToggle}\n aria-label={labels.theme}\n className={cn(TOPBAR_TRIGGER_CLASS, className)}\n >\n <Icon className=\"size-5\" />\n </button>\n </Tooltip>\n );\n}\n\n/** Appearance-preset switcher: a hover menu of palette presets with per-theme\n * colour swatches. Controlled — the app owns the active id and applies it. */\nexport function PaletteMenu({\n palettes,\n activeId,\n mode,\n onSelect,\n \"aria-label\": ariaLabel,\n heading,\n}: {\n palettes: PalettePreset[];\n activeId: string;\n mode: ThemeMode;\n onSelect: (id: string) => void;\n /** Default: `topBar.palette` from the {@link UiKitProvider}, else English. */\n \"aria-label\"?: string;\n /** Optional small heading row above the list. */\n heading?: string;\n}) {\n const labels = useKitLabels(\"topBar\", DEFAULT_TOP_BAR_LABELS, { palette: ariaLabel });\n const activeName = palettes.find((p) => p.id === activeId)?.name ?? activeId;\n return (\n <HoverMenu\n aria-label={labels.palette}\n trigger={({ toggle }) => (\n <Tooltip label={activeName} portal>\n <button\n type=\"button\"\n onClick={toggle}\n aria-label={labels.palette}\n className={TOPBAR_TRIGGER_CLASS}\n >\n {/* A DATA colour, not a semantic one: the palette mark is the\n \"colour\" control, so it carries a colour, and which hue is\n arbitrary. `--chart-1` is the violet end of the CVD-safe\n categorical ramp and flips per theme — a fixed `violet-500` did\n not, and stayed a cool violet island on a warm page. */}\n <Palette className=\"size-5 text-[var(--chart-1)]\" />\n </button>\n </Tooltip>\n )}\n >\n {(close) => (\n <ul className=\"w-60 py-1\">\n {heading && <MenuHeading>{heading}</MenuHeading>}\n {palettes.map((p) => {\n const ts = p[mode];\n const swatches = [ts.bgPage, ts.brand, ts.moneyIncome, ts.moneyExpense, ts.moneyNet];\n return (\n <li key={p.id}>\n <button\n type=\"button\"\n onClick={() => {\n onSelect(p.id);\n close();\n }}\n className={TOPBAR_MENU_ITEM_CLASS}\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n <span className=\"flex shrink-0 gap-0.5\">\n {/* Deliberately a neutral at 10% and not a token: this hairline\n sits on an ARBITRARY preset colour, so it has to read against\n whatever that preset paints, which no themed border does. */}\n {swatches.map((c, i) => (\n <span\n key={i}\n className=\"size-3.5 rounded-sm ring-1 ring-inset ring-black/10 dark:ring-white/10\"\n style={{ background: c }}\n />\n ))}\n </span>\n <span className=\"flex min-w-0 flex-col text-start\">\n <span className=\"truncate\">{p.name}</span>\n <span className=\"truncate text-caption text-placeholder\">\n {p.blurb}\n </span>\n </span>\n </span>\n {activeId === p.id && (\n <Check className=\"size-4 shrink-0 text-secondary\" />\n )}\n </button>\n </li>\n );\n })}\n </ul>\n )}\n </HoverMenu>\n );\n}\n\nexport interface LanguageOption {\n code: string;\n label: string;\n /** ISO 3166-1 alpha-2 country code (lowercase) for the flag-icons flag. */\n country: string;\n}\n\n/** Language switcher: a hover menu of options with flags and a check on the\n * active one. Controlled — the app owns the current code and change handler.\n *\n * The trigger is the *active* option's flag, not an icon: lucide's `Languages`\n * glyph (文A) is the same mark Chrome puts in the omnibox for \"translate this\n * page\", so it read as machine-translation rather than \"pick the UI language\"\n * (Keksdose feedback #121). The flag also shows which language is currently on,\n * which no icon can, and costs the same width on a crowded mobile bar. A globe\n * covers the case where `current` matches nothing in `options`. */\nexport function LanguageMenu({\n options,\n current,\n onChange,\n \"aria-label\": ariaLabel,\n heading,\n}: {\n options: LanguageOption[];\n current: string | undefined;\n onChange: (code: string) => void;\n /** Default: `topBar.language` from the {@link UiKitProvider}, else English. */\n \"aria-label\"?: string;\n /** Optional small heading row above the list — as on `TopBarActionMenu`,\n * `OptionSwitcherMenu` and `PaletteMenu`. */\n heading?: string;\n}) {\n const labels = useKitLabels(\"topBar\", DEFAULT_TOP_BAR_LABELS, { language: ariaLabel });\n const active = options.find((o) => o.code === current);\n return (\n <HoverMenu\n aria-label={labels.language}\n trigger={({ toggle }) => (\n <Tooltip label={active?.label ?? labels.language} portal>\n <button\n type=\"button\"\n onClick={toggle}\n aria-label={labels.language}\n className={TOPBAR_TRIGGER_CLASS}\n >\n {active ? (\n <span\n aria-hidden\n className={`fi fi-${active.country} inline-block h-[0.9375rem] w-5 shrink-0 rounded-sm shadow-[0_0_0_1px_rgba(0,0,0,0.08)]`}\n />\n ) : (\n <Globe className=\"size-5\" />\n )}\n </button>\n </Tooltip>\n )}\n >\n {(close) => (\n <ul className=\"py-1\">\n {heading && <MenuHeading>{heading}</MenuHeading>}\n {options.map((lang) => {\n const isActive = lang.code === current;\n return (\n <li key={lang.code}>\n <button\n type=\"button\"\n onClick={() => {\n onChange(lang.code);\n close();\n }}\n className={TOPBAR_MENU_ITEM_CLASS}\n >\n <span className=\"flex items-center gap-2\">\n <span\n aria-hidden\n className={`fi fi-${lang.country} inline-block h-[0.9375rem] w-5 shrink-0 rounded-sm shadow-[0_0_0_1px_rgba(0,0,0,0.08)]`}\n />\n {lang.label}\n </span>\n {isActive && <Check className=\"size-4 text-secondary\" />}\n </button>\n </li>\n );\n })}\n </ul>\n )}\n </HoverMenu>\n );\n}\n"],"mappings":";AAqBI,cA8Gg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AQ,SAAS,OAAO,UAAU,QAAM,MACtD;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAS;AAAA,UACT,cAAY,OAAO;AAAA,UACnB,WAAW;AAAA,UAEV,mBACC;AAAA,YAAC;AAAA;AAAA,cACC,eAAW;AAAA,cACX,WAAW,SAAS,OAAO,OAAO;AAAA;AAAA,UACpC,IAEA,oBAAC,SAAM,WAAU,UAAS;AAAA;AAAA,MAE9B,GACF;AAAA,MAGD,WAAC,UACA,qBAAC,QAAG,WAAU,QACX;AAAA,mBAAW,oBAAC,eAAa,mBAAQ;AAAA,QACjC,QAAQ,IAAI,CAAC,SAAS;AACrB,gBAAM,WAAW,KAAK,SAAS;AAC/B,iBACE,oBAAC,QACC;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS,MAAM;AACb,yBAAS,KAAK,IAAI;AAClB,sBAAM;AAAA,cACR;AAAA,cACA,WAAW;AAAA,cAEX;AAAA,qCAAC,UAAK,WAAU,2BACd;AAAA;AAAA,oBAAC;AAAA;AAAA,sBACC,eAAW;AAAA,sBACX,WAAW,SAAS,KAAK,OAAO;AAAA;AAAA,kBAClC;AAAA,kBACC,KAAK;AAAA,mBACR;AAAA,gBACC,YAAY,oBAAC,SAAM,WAAU,yBAAwB;AAAA;AAAA;AAAA,UACxD,KAjBO,KAAK,IAkBd;AAAA,QAEJ,CAAC;AAAA,SACH;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { KIT_CSS_VARIABLES, declaredCustomProperties, undeclaredCssVariables, type UndeclaredCssVariablesOptions, } from "./css-variables.js";
|
|
2
|
-
export { stubResizeObserver, stubViewportWidth, viewportMatchMedia, type ResizeObserverStub, type StubbedBoxSize, type ViewportOptions, } from "./viewport.js";
|
|
2
|
+
export { setViewportWidth, stubResizeObserver, stubViewportWidth, viewportMatchMedia, type ResizeObserverStub, type StubbedBoxSize, type ViewportOptions, } from "./viewport.js";
|
package/dist/testing/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
undeclaredCssVariables
|
|
6
6
|
} from "./css-variables.js";
|
|
7
7
|
import {
|
|
8
|
+
setViewportWidth,
|
|
8
9
|
stubResizeObserver,
|
|
9
10
|
stubViewportWidth,
|
|
10
11
|
viewportMatchMedia
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
export {
|
|
13
14
|
KIT_CSS_VARIABLES,
|
|
14
15
|
declaredCustomProperties,
|
|
16
|
+
setViewportWidth,
|
|
15
17
|
stubResizeObserver,
|
|
16
18
|
stubViewportWidth,
|
|
17
19
|
undeclaredCssVariables,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/testing/index.ts"],"sourcesContent":["// `@eifi1/ui-kit/testing` — helpers an app runs from its OWN test suite (0.33).\n//\n// Not part of the main barrel: nothing here renders, and an app's production bundle has\n// no business carrying it. Browser-safe like the rest of the kit (no `node:fs`): each\n// helper takes texts, so an app collects them with `import.meta.glob` or `node:fs`, as\n// its setup allows. The first content is the guard against undeclared CSS custom\n// properties (docs/colour-roles-harmonization.md §8).\nexport {\n KIT_CSS_VARIABLES,\n declaredCustomProperties,\n undeclaredCssVariables,\n type UndeclaredCssVariablesOptions,\n} from \"./css-variables\";\n// 0.34 (refactor audit 2026-10, TST-10): the environment jsdom lacks — a `matchMedia`\n// that answers from a viewport width (right at every text size) and a `ResizeObserver`\n// the test drives. Framework-free: each returns its own undo.\nexport {\n stubResizeObserver,\n stubViewportWidth,\n viewportMatchMedia,\n type ResizeObserverStub,\n type StubbedBoxSize,\n type ViewportOptions,\n} from \"./viewport\";\n"],"mappings":";AAOA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;
|
|
1
|
+
{"version":3,"sources":["../../src/testing/index.ts"],"sourcesContent":["// `@eifi1/ui-kit/testing` — helpers an app runs from its OWN test suite (0.33).\n//\n// Not part of the main barrel: nothing here renders, and an app's production bundle has\n// no business carrying it. Browser-safe like the rest of the kit (no `node:fs`): each\n// helper takes texts, so an app collects them with `import.meta.glob` or `node:fs`, as\n// its setup allows. The first content is the guard against undeclared CSS custom\n// properties (docs/colour-roles-harmonization.md §8).\nexport {\n KIT_CSS_VARIABLES,\n declaredCustomProperties,\n undeclaredCssVariables,\n type UndeclaredCssVariablesOptions,\n} from \"./css-variables\";\n// 0.34 (refactor audit 2026-10, TST-10): the environment jsdom lacks — a `matchMedia`\n// that answers from a viewport width (right at every text size) and a `ResizeObserver`\n// the test drives. Framework-free: each returns its own undo. 0.35: `setViewportWidth`,\n// a live resize of the stub in force — its lists flip and fire `change` (keksdose).\nexport {\n setViewportWidth,\n stubResizeObserver,\n stubViewportWidth,\n viewportMatchMedia,\n type ResizeObserverStub,\n type StubbedBoxSize,\n type ViewportOptions,\n} from \"./viewport\";\n"],"mappings":";AAOA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAKP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;","names":[]}
|
|
@@ -34,14 +34,37 @@ export interface ViewportOptions {
|
|
|
34
34
|
* Width queries answer from `width`: the range syntax the kit writes for `max-*`
|
|
35
35
|
* (`(width < 768px)`) and every other comparison, `(min-width: …)` and `(max-width: …)`,
|
|
36
36
|
* in px or rem; `and` and comma lists combine as in CSS. The features in `options` answer
|
|
37
|
-
* as set there; every other query is false. The lists
|
|
38
|
-
*
|
|
37
|
+
* as set there; every other query is false. The lists keep their listeners, and
|
|
38
|
+
* {@link setViewportWidth} resizes the viewport under them the way a browser window
|
|
39
|
+
* does: each list whose answer flips fires `change`.
|
|
39
40
|
*
|
|
40
41
|
* Hand it to the runner's own global stub where the suite undoes stubs that way —
|
|
41
42
|
* `vi.stubGlobal("matchMedia", viewportMatchMedia(375))` — or use
|
|
42
43
|
* {@link stubViewportWidth}.
|
|
43
44
|
*/
|
|
44
45
|
export declare function viewportMatchMedia(width: number, options?: ViewportOptions): (query: string) => MediaQueryList;
|
|
46
|
+
/**
|
|
47
|
+
* Resize the stubbed viewport to `width` CSS px, live — the window being dragged narrower,
|
|
48
|
+
* a phone turned (0.35, keksdose's 0.34 report). Every list the stub in force has handed
|
|
49
|
+
* out answers from the new width, and each one whose answer flipped fires `change` to its
|
|
50
|
+
* `addEventListener` listeners, its legacy `addListener` ones and its `onchange`, as in a
|
|
51
|
+
* browser; a list whose answer stayed the same tells nobody. So a mounted component that
|
|
52
|
+
* listens to a breakpoint (`usePhoneLayout()`, `useBreakpoint()`) switches without being
|
|
53
|
+
* rendered again.
|
|
54
|
+
*
|
|
55
|
+
* The stub in force is whatever `window.matchMedia` is now — one {@link stubViewportWidth}
|
|
56
|
+
* or `vi.stubGlobal("matchMedia", viewportMatchMedia(…))` put in; its features
|
|
57
|
+
* (`options`) stay as they were. Throws when `matchMedia` is not one of these stubs, rather
|
|
58
|
+
* than resize nothing. Synchronous: wrap it in `act()` when a listener sets state.
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* undo = stubViewportWidth(1280);
|
|
62
|
+
* render(<Page />);
|
|
63
|
+
* act(() => setViewportWidth(375));
|
|
64
|
+
* expect(screen.getByRole("list")).toBeInTheDocument(); // the cards
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function setViewportWidth(width: number): void;
|
|
45
68
|
/**
|
|
46
69
|
* Make `window.matchMedia` answer as a viewport `width` CSS px wide (see
|
|
47
70
|
* {@link viewportMatchMedia}), and return the undo: it puts back what was there, which
|
package/dist/testing/viewport.js
CHANGED
|
@@ -48,24 +48,74 @@ function condition(part, width, options) {
|
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
51
|
+
function answer(query, width, options) {
|
|
52
|
+
return query.split(",").some(
|
|
53
53
|
(alternative) => alternative.split(/\s+and\s+/).every((part) => condition(part, width, options))
|
|
54
54
|
);
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
}
|
|
56
|
+
const VIEWPORTS = /* @__PURE__ */ new WeakMap();
|
|
57
|
+
function mediaQueryList(query, viewport) {
|
|
58
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
59
|
+
const list = {
|
|
60
|
+
matches: answer(query, viewport.width, viewport.options),
|
|
57
61
|
media: query,
|
|
58
62
|
onchange: null,
|
|
59
|
-
addEventListener
|
|
63
|
+
addEventListener(type, listener) {
|
|
64
|
+
if (type === "change" && listener) listeners.add(listener);
|
|
60
65
|
},
|
|
61
|
-
removeEventListener
|
|
66
|
+
removeEventListener(type, listener) {
|
|
67
|
+
if (type === "change" && listener) listeners.delete(listener);
|
|
62
68
|
},
|
|
63
|
-
addListener
|
|
69
|
+
addListener(listener) {
|
|
70
|
+
if (listener) listeners.add(listener);
|
|
64
71
|
},
|
|
65
|
-
removeListener
|
|
72
|
+
removeListener(listener) {
|
|
73
|
+
if (listener) listeners.delete(listener);
|
|
66
74
|
},
|
|
67
|
-
dispatchEvent
|
|
68
|
-
|
|
75
|
+
dispatchEvent(event) {
|
|
76
|
+
if (event.type !== "change") return true;
|
|
77
|
+
const self = list;
|
|
78
|
+
list.onchange?.call(self, event);
|
|
79
|
+
for (const listener of [...listeners]) {
|
|
80
|
+
if (typeof listener === "function") listener.call(self, event);
|
|
81
|
+
else listener.handleEvent(event);
|
|
82
|
+
}
|
|
83
|
+
return !event.defaultPrevented;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return list;
|
|
87
|
+
}
|
|
88
|
+
function changeEvent(list) {
|
|
89
|
+
const event = new Event("change");
|
|
90
|
+
for (const [key, value] of Object.entries({ matches: list.matches, media: list.media, target: list, currentTarget: list })) {
|
|
91
|
+
Object.defineProperty(event, key, { value, enumerable: true });
|
|
92
|
+
}
|
|
93
|
+
return event;
|
|
94
|
+
}
|
|
95
|
+
function viewportMatchMedia(width, options = {}) {
|
|
96
|
+
const viewport = { width, options, lists: /* @__PURE__ */ new Set() };
|
|
97
|
+
const matchMedia = (query) => {
|
|
98
|
+
const list = mediaQueryList(query, viewport);
|
|
99
|
+
viewport.lists.add(list);
|
|
100
|
+
return list;
|
|
101
|
+
};
|
|
102
|
+
VIEWPORTS.set(matchMedia, viewport);
|
|
103
|
+
return matchMedia;
|
|
104
|
+
}
|
|
105
|
+
function setViewportWidth(width) {
|
|
106
|
+
const viewport = typeof window === "undefined" ? void 0 : VIEWPORTS.get(window.matchMedia);
|
|
107
|
+
if (!viewport) {
|
|
108
|
+
throw new Error(
|
|
109
|
+
'setViewportWidth: no viewport stub is in force \u2014 put one in first with stubViewportWidth(width), or vi.stubGlobal("matchMedia", viewportMatchMedia(width)).'
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
viewport.width = width;
|
|
113
|
+
for (const list of [...viewport.lists]) {
|
|
114
|
+
const matches = answer(list.media, width, viewport.options);
|
|
115
|
+
if (matches === list.matches) continue;
|
|
116
|
+
list.matches = matches;
|
|
117
|
+
list.dispatchEvent(changeEvent(list));
|
|
118
|
+
}
|
|
69
119
|
}
|
|
70
120
|
function stubViewportWidth(width, options = {}) {
|
|
71
121
|
const before = Object.getOwnPropertyDescriptor(window, "matchMedia");
|
|
@@ -145,6 +195,7 @@ function stubResizeObserver() {
|
|
|
145
195
|
};
|
|
146
196
|
}
|
|
147
197
|
export {
|
|
198
|
+
setViewportWidth,
|
|
148
199
|
stubResizeObserver,
|
|
149
200
|
stubViewportWidth,
|
|
150
201
|
viewportMatchMedia
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/testing/viewport.ts"],"sourcesContent":["/**\n * Environment stubs for an app's own tests (0.34, refactor audit 2026-10, TST-10): the\n * two browser APIs jsdom does not have and the kit's layout reads — `matchMedia` and\n * `ResizeObserver`.\n *\n * Every suite rebuilt them by hand: the kit stubbed `matchMedia` in 25 files and defined\n * the same `stubPhone()` eight times, keksdose stubs it in 41, and most copies answer\n * one literal string. That breaks quietly at Large text, where `md` is 960 px and the\n * phone query the kit writes is `(width < 960px)`, not `(width < 768px)`. These answer\n * every width query from a WIDTH, as a browser does, so they stay right at every text\n * size (docs/text-size-harmonization.md §3.3). The reference is keksdose's\n * `frontend/src/test/viewport.ts`, which this generalises.\n *\n * Framework-free, like the rest of `@eifi1/ui-kit/testing`: nothing here imports vitest\n * or jest. Each stub returns its own undo, so it works under either runner, and a suite\n * that prefers `vi.stubGlobal` passes it {@link viewportMatchMedia} instead.\n */\n\n/** The media features a test may want besides the width. Each is off by default. */\nexport interface ViewportOptions {\n /** The primary pointer is a finger: `(pointer: coarse)`, `(any-pointer: coarse)` and\n * `(hover: none)` match; `(pointer: fine)` and `(hover: hover)` do not. */\n coarse?: boolean;\n /** The person asked for less motion: `(prefers-reduced-motion: reduce)` matches, and\n * the kit's overlays skip their exit animations. */\n reducedMotion?: boolean;\n /** `(prefers-color-scheme: dark)` matches (`light` does not). */\n dark?: boolean;\n /** `(prefers-contrast: more)` matches. */\n moreContrast?: boolean;\n}\n\n/** One length in CSS px. A media query's `rem`/`em` is the browser's default font size,\n * 16 px, never `<html>`'s — the kit's own `breakpointQuery` writes px. */\nfunction lengthPx(value: string, unit: string): number {\n return unit === \"px\" ? Number(value) : Number(value) * 16;\n}\n\nconst RANGE = /^\\(\\s*width\\s*(<=|>=|<|>)\\s*([\\d.]+)(px|r?em)\\s*\\)$/;\nconst MIN_MAX = /^\\(\\s*(min|max)-width\\s*:\\s*([\\d.]+)(px|r?em)\\s*\\)$/;\nconst FEATURE = /^\\(\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*\\)$/;\n\n/** One `(…)` condition, or a media type. */\nfunction condition(part: string, width: number, options: ViewportOptions): boolean {\n const q = part.trim();\n if (q === \"all\" || q === \"screen\") return true;\n const range = RANGE.exec(q);\n if (range) {\n const px = lengthPx(range[2], range[3]);\n switch (range[1]) {\n case \"<\":\n return width < px;\n case \"<=\":\n return width <= px;\n case \">\":\n return width > px;\n default:\n return width >= px;\n }\n }\n const minMax = MIN_MAX.exec(q);\n if (minMax) {\n const px = lengthPx(minMax[2], minMax[3]);\n return minMax[1] === \"min\" ? width >= px : width <= px;\n }\n const feature = FEATURE.exec(q);\n if (!feature) return false;\n const [, name, value] = feature;\n const coarse = Boolean(options.coarse);\n switch (name) {\n case \"pointer\":\n case \"any-pointer\":\n return value === (coarse ? \"coarse\" : \"fine\");\n case \"hover\":\n case \"any-hover\":\n return value === (coarse ? \"none\" : \"hover\");\n case \"prefers-reduced-motion\":\n return value === (options.reducedMotion ? \"reduce\" : \"no-preference\");\n case \"prefers-color-scheme\":\n return value === (options.dark ? \"dark\" : \"light\");\n case \"prefers-contrast\":\n return value === (options.moreContrast ? \"more\" : \"no-preference\");\n default:\n return false;\n }\n}\n\n/**\n * A `window.matchMedia` for a viewport `width` CSS px wide.\n *\n * Width queries answer from `width`: the range syntax the kit writes for `max-*`\n * (`(width < 768px)`) and every other comparison, `(min-width: …)` and `(max-width: …)`,\n * in px or rem; `and` and comma lists combine as in CSS. The features in `options` answer\n * as set there; every other query is false. The lists it returns never change, so\n * nothing fires `change`: a test that changes the width stubs again and renders again.\n *\n * Hand it to the runner's own global stub where the suite undoes stubs that way —\n * `vi.stubGlobal(\"matchMedia\", viewportMatchMedia(375))` — or use\n * {@link stubViewportWidth}.\n */\nexport function viewportMatchMedia(\n width: number,\n options: ViewportOptions = {},\n): (query: string) => MediaQueryList {\n const answer = (query: string) =>\n query\n .split(\",\")\n .some((alternative) =>\n alternative.split(/\\s+and\\s+/).every((part) => condition(part, width, options)),\n );\n return (query: string) =>\n ({\n matches: answer(query),\n media: query,\n onchange: null,\n addEventListener: () => {},\n removeEventListener: () => {},\n addListener: () => {},\n removeListener: () => {},\n dispatchEvent: () => false,\n }) as unknown as MediaQueryList;\n}\n\n/**\n * Make `window.matchMedia` answer as a viewport `width` CSS px wide (see\n * {@link viewportMatchMedia}), and return the undo: it puts back what was there, which\n * in jsdom is nothing — no `matchMedia` at all, the desktop fallback of every kit hook.\n *\n * ```ts\n * let undo = () => {};\n * afterEach(() => undo());\n * it(\"shows cards on a phone\", () => {\n * undo = stubViewportWidth(375);\n * …\n * });\n * ```\n *\n * Right at every text size: at Large the kit's phone query is `(width < 960px)`, which a\n * 375 px viewport matches and a 1280 px one does not, as in a browser.\n */\nexport function stubViewportWidth(width: number, options: ViewportOptions = {}): () => void {\n const before = Object.getOwnPropertyDescriptor(window, \"matchMedia\");\n Object.defineProperty(window, \"matchMedia\", {\n configurable: true,\n writable: true,\n value: viewportMatchMedia(width, options),\n });\n return () => {\n if (before) Object.defineProperty(window, \"matchMedia\", before);\n else Reflect.deleteProperty(window, \"matchMedia\");\n };\n}\n\n/** A box size for {@link ResizeObserverStub.resize}, in CSS px. */\nexport interface StubbedBoxSize {\n width: number;\n height: number;\n}\n\n/** What {@link stubResizeObserver} returns: the test drives the observers. */\nexport interface ResizeObserverStub {\n /**\n * Report `target` at `size` to every live observer watching it, as a browser does once\n * layout settles: one entry, with `contentRect` and the three box sizes all `size`.\n * Synchronous; wrap it in `act()` when the callback sets state.\n */\n resize(target: Element, size: StubbedBoxSize): void;\n /** The elements some live observer watches now, each once. */\n observed(): Element[];\n /** Put back the `ResizeObserver` that was there before — in jsdom, none. */\n restore(): void;\n}\n\n/**\n * Install a `ResizeObserver` the test drives. jsdom has none, and lays nothing out, so a\n * component that measures itself (a windowed list, a fitted chart, a measured grid)\n * either crashes on the missing global or never learns a size. Observers here record\n * what they watch and are called only by {@link ResizeObserverStub.resize}.\n *\n * ```ts\n * const ro = stubResizeObserver();\n * afterEach(() => ro.restore());\n * act(() => ro.resize(screen.getByRole(\"list\"), { width: 400, height: 320 }));\n * ```\n */\nexport function stubResizeObserver(): ResizeObserverStub {\n const live = new Set<StubResizeObserver>();\n\n class StubResizeObserver {\n readonly targets = new Set<Element>();\n constructor(readonly callback: ResizeObserverCallback) {\n live.add(this);\n }\n observe(target: Element) {\n this.targets.add(target);\n }\n unobserve(target: Element) {\n this.targets.delete(target);\n }\n disconnect() {\n this.targets.clear();\n live.delete(this);\n }\n }\n\n const before = Object.getOwnPropertyDescriptor(globalThis, \"ResizeObserver\");\n Object.defineProperty(globalThis, \"ResizeObserver\", {\n configurable: true,\n writable: true,\n value: StubResizeObserver,\n });\n\n return {\n resize(target, { width, height }) {\n const box = [{ inlineSize: width, blockSize: height }];\n const contentRect = {\n x: 0,\n y: 0,\n top: 0,\n left: 0,\n width,\n height,\n right: width,\n bottom: height,\n toJSON: () => ({ x: 0, y: 0, width, height }),\n };\n const entry = {\n target,\n contentRect,\n borderBoxSize: box,\n contentBoxSize: box,\n devicePixelContentBoxSize: box,\n } as unknown as ResizeObserverEntry;\n for (const observer of [...live]) {\n if (observer.targets.has(target)) {\n observer.callback([entry], observer as unknown as ResizeObserver);\n }\n }\n },\n observed() {\n const all: Element[] = [];\n for (const observer of live) for (const target of observer.targets) if (!all.includes(target)) all.push(target);\n return all;\n },\n restore() {\n live.clear();\n if (before) Object.defineProperty(globalThis, \"ResizeObserver\", before);\n else Reflect.deleteProperty(globalThis, \"ResizeObserver\");\n },\n };\n}\n"],"mappings":";AAkCA,SAAS,SAAS,OAAe,MAAsB;AACrD,SAAO,SAAS,OAAO,OAAO,KAAK,IAAI,OAAO,KAAK,IAAI;AACzD;AAEA,MAAM,QAAQ;AACd,MAAM,UAAU;AAChB,MAAM,UAAU;AAGhB,SAAS,UAAU,MAAc,OAAe,SAAmC;AACjF,QAAM,IAAI,KAAK,KAAK;AACpB,MAAI,MAAM,SAAS,MAAM,SAAU,QAAO;AAC1C,QAAM,QAAQ,MAAM,KAAK,CAAC;AAC1B,MAAI,OAAO;AACT,UAAM,KAAK,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;AACtC,YAAQ,MAAM,CAAC,GAAG;AAAA,MAChB,KAAK;AACH,eAAO,QAAQ;AAAA,MACjB,KAAK;AACH,eAAO,SAAS;AAAA,MAClB,KAAK;AACH,eAAO,QAAQ;AAAA,MACjB;AACE,eAAO,SAAS;AA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;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf,gBAAgB;AAAA,QAChB,2BAA2B;AAAA,MAC7B;AACA,iBAAW,YAAY,CAAC,GAAG,IAAI,GAAG;AAChC,YAAI,SAAS,QAAQ,IAAI,MAAM,GAAG;AAChC,mBAAS,SAAS,CAAC,KAAK,GAAG,QAAqC;AAAA,QAClE;AAAA,MACF;AAAA,IACF;AAAA,IACA,WAAW;AACT,YAAM,MAAiB,CAAC;AACxB,iBAAW,YAAY,KAAM,YAAW,UAAU,SAAS,QAAS,KAAI,CAAC,IAAI,SAAS,MAAM,EAAG,KAAI,KAAK,MAAM;AAC9G,aAAO;AAAA,IACT;AAAA,IACA,UAAU;AACR,WAAK,MAAM;AACX,UAAI,OAAQ,QAAO,eAAe,YAAY,kBAAkB,MAAM;AAAA,UACjE,SAAQ,eAAe,YAAY,gBAAgB;AAAA,IAC1D;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/testing/viewport.ts"],"sourcesContent":["/**\n * Environment stubs for an app's own tests (0.34, refactor audit 2026-10, TST-10): the\n * two browser APIs jsdom does not have and the kit's layout reads — `matchMedia` and\n * `ResizeObserver`.\n *\n * Every suite rebuilt them by hand: the kit stubbed `matchMedia` in 25 files and defined\n * the same `stubPhone()` eight times, keksdose stubs it in 41, and most copies answer\n * one literal string. That breaks quietly at Large text, where `md` is 960 px and the\n * phone query the kit writes is `(width < 960px)`, not `(width < 768px)`. These answer\n * every width query from a WIDTH, as a browser does, so they stay right at every text\n * size (docs/text-size-harmonization.md §3.3). The reference is keksdose's\n * `frontend/src/test/viewport.ts`, which this generalises.\n *\n * Framework-free, like the rest of `@eifi1/ui-kit/testing`: nothing here imports vitest\n * or jest. Each stub returns its own undo, so it works under either runner, and a suite\n * that prefers `vi.stubGlobal` passes it {@link viewportMatchMedia} instead.\n */\n\n/** The media features a test may want besides the width. Each is off by default. */\nexport interface ViewportOptions {\n /** The primary pointer is a finger: `(pointer: coarse)`, `(any-pointer: coarse)` and\n * `(hover: none)` match; `(pointer: fine)` and `(hover: hover)` do not. */\n coarse?: boolean;\n /** The person asked for less motion: `(prefers-reduced-motion: reduce)` matches, and\n * the kit's overlays skip their exit animations. */\n reducedMotion?: boolean;\n /** `(prefers-color-scheme: dark)` matches (`light` does not). */\n dark?: boolean;\n /** `(prefers-contrast: more)` matches. */\n moreContrast?: boolean;\n}\n\n/** One length in CSS px. A media query's `rem`/`em` is the browser's default font size,\n * 16 px, never `<html>`'s — the kit's own `breakpointQuery` writes px. */\nfunction lengthPx(value: string, unit: string): number {\n return unit === \"px\" ? Number(value) : Number(value) * 16;\n}\n\nconst RANGE = /^\\(\\s*width\\s*(<=|>=|<|>)\\s*([\\d.]+)(px|r?em)\\s*\\)$/;\nconst MIN_MAX = /^\\(\\s*(min|max)-width\\s*:\\s*([\\d.]+)(px|r?em)\\s*\\)$/;\nconst FEATURE = /^\\(\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*\\)$/;\n\n/** One `(…)` condition, or a media type. */\nfunction condition(part: string, width: number, options: ViewportOptions): boolean {\n const q = part.trim();\n if (q === \"all\" || q === \"screen\") return true;\n const range = RANGE.exec(q);\n if (range) {\n const px = lengthPx(range[2], range[3]);\n switch (range[1]) {\n case \"<\":\n return width < px;\n case \"<=\":\n return width <= px;\n case \">\":\n return width > px;\n default:\n return width >= px;\n }\n }\n const minMax = MIN_MAX.exec(q);\n if (minMax) {\n const px = lengthPx(minMax[2], minMax[3]);\n return minMax[1] === \"min\" ? width >= px : width <= px;\n }\n const feature = FEATURE.exec(q);\n if (!feature) return false;\n const [, name, value] = feature;\n const coarse = Boolean(options.coarse);\n switch (name) {\n case \"pointer\":\n case \"any-pointer\":\n return value === (coarse ? \"coarse\" : \"fine\");\n case \"hover\":\n case \"any-hover\":\n return value === (coarse ? \"none\" : \"hover\");\n case \"prefers-reduced-motion\":\n return value === (options.reducedMotion ? \"reduce\" : \"no-preference\");\n case \"prefers-color-scheme\":\n return value === (options.dark ? \"dark\" : \"light\");\n case \"prefers-contrast\":\n return value === (options.moreContrast ? \"more\" : \"no-preference\");\n default:\n return false;\n }\n}\n\n/** A whole query: comma lists are alternatives, `and` joins conditions, as in CSS. */\nfunction answer(query: string, width: number, options: ViewportOptions): boolean {\n return query\n .split(\",\")\n .some((alternative) =>\n alternative.split(/\\s+and\\s+/).every((part) => condition(part, width, options)),\n );\n}\n\n/** A list {@link viewportMatchMedia} handed out: what {@link setViewportWidth} flips. */\ninterface StubMediaQueryList {\n matches: boolean;\n readonly media: string;\n onchange: ((this: MediaQueryList, event: MediaQueryListEvent) => unknown) | null;\n addEventListener(type: string, listener: EventListenerOrEventListenerObject | null): void;\n removeEventListener(type: string, listener: EventListenerOrEventListenerObject | null): void;\n addListener(listener: EventListenerOrEventListenerObject | null): void;\n removeListener(listener: EventListenerOrEventListenerObject | null): void;\n dispatchEvent(event: Event): boolean;\n}\n\n/** One stub's viewport: its width now, and every list it has handed out. */\ninterface StubViewport {\n width: number;\n readonly options: ViewportOptions;\n readonly lists: Set<StubMediaQueryList>;\n}\n\n/** Each `matchMedia` {@link viewportMatchMedia} made → its viewport. Keyed by the function,\n * so {@link setViewportWidth} finds whichever stub is in force however it was put in. */\nconst VIEWPORTS = new WeakMap<object, StubViewport>();\n\nfunction mediaQueryList(query: string, viewport: StubViewport): StubMediaQueryList {\n // One set for both APIs: in a browser `addListener(fn)` IS `addEventListener(\"change\",\n // fn)`, so adding the same function through both registers it once.\n const listeners = new Set<EventListenerOrEventListenerObject>();\n const list: StubMediaQueryList = {\n matches: answer(query, viewport.width, viewport.options),\n media: query,\n onchange: null,\n addEventListener(type, listener) {\n if (type === \"change\" && listener) listeners.add(listener);\n },\n removeEventListener(type, listener) {\n if (type === \"change\" && listener) listeners.delete(listener);\n },\n addListener(listener) {\n if (listener) listeners.add(listener);\n },\n removeListener(listener) {\n if (listener) listeners.delete(listener);\n },\n dispatchEvent(event) {\n if (event.type !== \"change\") return true;\n const self = list as unknown as MediaQueryList;\n list.onchange?.call(self, event as MediaQueryListEvent);\n for (const listener of [...listeners]) {\n if (typeof listener === \"function\") listener.call(self, event);\n else listener.handleEvent(event);\n }\n return !event.defaultPrevented;\n },\n };\n return list;\n}\n\n/** The `change` a browser fires at a list whose answer flipped: a `MediaQueryListEvent`'s\n * `matches` and `media`, on an `Event` (jsdom has no `MediaQueryListEvent`). */\nfunction changeEvent(list: StubMediaQueryList): Event {\n const event = new Event(\"change\");\n for (const [key, value] of Object.entries({ matches: list.matches, media: list.media, target: list, currentTarget: list })) {\n Object.defineProperty(event, key, { value, enumerable: true });\n }\n return event;\n}\n\n/**\n * A `window.matchMedia` for a viewport `width` CSS px wide.\n *\n * Width queries answer from `width`: the range syntax the kit writes for `max-*`\n * (`(width < 768px)`) and every other comparison, `(min-width: …)` and `(max-width: …)`,\n * in px or rem; `and` and comma lists combine as in CSS. The features in `options` answer\n * as set there; every other query is false. The lists keep their listeners, and\n * {@link setViewportWidth} resizes the viewport under them the way a browser window\n * does: each list whose answer flips fires `change`.\n *\n * Hand it to the runner's own global stub where the suite undoes stubs that way —\n * `vi.stubGlobal(\"matchMedia\", viewportMatchMedia(375))` — or use\n * {@link stubViewportWidth}.\n */\nexport function viewportMatchMedia(\n width: number,\n options: ViewportOptions = {},\n): (query: string) => MediaQueryList {\n const viewport: StubViewport = { width, options, lists: new Set() };\n const matchMedia = (query: string) => {\n const list = mediaQueryList(query, viewport);\n viewport.lists.add(list);\n return list as unknown as MediaQueryList;\n };\n VIEWPORTS.set(matchMedia, viewport);\n return matchMedia;\n}\n\n/**\n * Resize the stubbed viewport to `width` CSS px, live — the window being dragged narrower,\n * a phone turned (0.35, keksdose's 0.34 report). Every list the stub in force has handed\n * out answers from the new width, and each one whose answer flipped fires `change` to its\n * `addEventListener` listeners, its legacy `addListener` ones and its `onchange`, as in a\n * browser; a list whose answer stayed the same tells nobody. So a mounted component that\n * listens to a breakpoint (`usePhoneLayout()`, `useBreakpoint()`) switches without being\n * rendered again.\n *\n * The stub in force is whatever `window.matchMedia` is now — one {@link stubViewportWidth}\n * or `vi.stubGlobal(\"matchMedia\", viewportMatchMedia(…))` put in; its features\n * (`options`) stay as they were. Throws when `matchMedia` is not one of these stubs, rather\n * than resize nothing. Synchronous: wrap it in `act()` when a listener sets state.\n *\n * ```ts\n * undo = stubViewportWidth(1280);\n * render(<Page />);\n * act(() => setViewportWidth(375));\n * expect(screen.getByRole(\"list\")).toBeInTheDocument(); // the cards\n * ```\n */\nexport function setViewportWidth(width: number): void {\n const viewport = typeof window === \"undefined\" ? undefined : VIEWPORTS.get(window.matchMedia);\n if (!viewport) {\n throw new Error(\n \"setViewportWidth: no viewport stub is in force — put one in first with \" +\n \"stubViewportWidth(width), or vi.stubGlobal(\\\"matchMedia\\\", viewportMatchMedia(width)).\",\n );\n }\n viewport.width = width;\n for (const list of [...viewport.lists]) {\n const matches = answer(list.media, width, viewport.options);\n if (matches === list.matches) continue;\n list.matches = matches;\n list.dispatchEvent(changeEvent(list));\n }\n}\n\n/**\n * Make `window.matchMedia` answer as a viewport `width` CSS px wide (see\n * {@link viewportMatchMedia}), and return the undo: it puts back what was there, which\n * in jsdom is nothing — no `matchMedia` at all, the desktop fallback of every kit hook.\n *\n * ```ts\n * let undo = () => {};\n * afterEach(() => undo());\n * it(\"shows cards on a phone\", () => {\n * undo = stubViewportWidth(375);\n * …\n * });\n * ```\n *\n * Right at every text size: at Large the kit's phone query is `(width < 960px)`, which a\n * 375 px viewport matches and a 1280 px one does not, as in a browser.\n */\nexport function stubViewportWidth(width: number, options: ViewportOptions = {}): () => void {\n const before = Object.getOwnPropertyDescriptor(window, \"matchMedia\");\n Object.defineProperty(window, \"matchMedia\", {\n configurable: true,\n writable: true,\n value: viewportMatchMedia(width, options),\n });\n return () => {\n if (before) Object.defineProperty(window, \"matchMedia\", before);\n else Reflect.deleteProperty(window, \"matchMedia\");\n };\n}\n\n/** A box size for {@link ResizeObserverStub.resize}, in CSS px. */\nexport interface StubbedBoxSize {\n width: number;\n height: number;\n}\n\n/** What {@link stubResizeObserver} returns: the test drives the observers. */\nexport interface ResizeObserverStub {\n /**\n * Report `target` at `size` to every live observer watching it, as a browser does once\n * layout settles: one entry, with `contentRect` and the three box sizes all `size`.\n * Synchronous; wrap it in `act()` when the callback sets state.\n */\n resize(target: Element, size: StubbedBoxSize): void;\n /** The elements some live observer watches now, each once. */\n observed(): Element[];\n /** Put back the `ResizeObserver` that was there before — in jsdom, none. */\n restore(): void;\n}\n\n/**\n * Install a `ResizeObserver` the test drives. jsdom has none, and lays nothing out, so a\n * component that measures itself (a windowed list, a fitted chart, a measured grid)\n * either crashes on the missing global or never learns a size. Observers here record\n * what they watch and are called only by {@link ResizeObserverStub.resize}.\n *\n * ```ts\n * const ro = stubResizeObserver();\n * afterEach(() => ro.restore());\n * act(() => ro.resize(screen.getByRole(\"list\"), { width: 400, height: 320 }));\n * ```\n */\nexport function stubResizeObserver(): ResizeObserverStub {\n const live = new Set<StubResizeObserver>();\n\n class StubResizeObserver {\n readonly targets = new Set<Element>();\n constructor(readonly callback: ResizeObserverCallback) {\n live.add(this);\n }\n observe(target: Element) {\n this.targets.add(target);\n }\n unobserve(target: Element) {\n this.targets.delete(target);\n }\n disconnect() {\n this.targets.clear();\n live.delete(this);\n }\n }\n\n const before = Object.getOwnPropertyDescriptor(globalThis, \"ResizeObserver\");\n Object.defineProperty(globalThis, \"ResizeObserver\", {\n configurable: true,\n writable: true,\n value: StubResizeObserver,\n });\n\n return {\n resize(target, { width, height }) {\n const box = [{ inlineSize: width, blockSize: height }];\n const contentRect = {\n x: 0,\n y: 0,\n top: 0,\n left: 0,\n width,\n height,\n right: width,\n bottom: height,\n toJSON: () => ({ x: 0, y: 0, width, height }),\n };\n const entry = {\n target,\n contentRect,\n borderBoxSize: box,\n contentBoxSize: box,\n devicePixelContentBoxSize: box,\n } as unknown as ResizeObserverEntry;\n for (const observer of [...live]) {\n if (observer.targets.has(target)) {\n observer.callback([entry], observer as unknown as ResizeObserver);\n }\n }\n },\n observed() {\n const all: Element[] = [];\n for (const observer of live) for (const target of observer.targets) if (!all.includes(target)) all.push(target);\n return all;\n },\n restore() {\n live.clear();\n if (before) Object.defineProperty(globalThis, \"ResizeObserver\", before);\n else Reflect.deleteProperty(globalThis, \"ResizeObserver\");\n },\n };\n}\n"],"mappings":";AAkCA,SAAS,SAAS,OAAe,MAAsB;AACrD,SAAO,SAAS,OAAO,OAAO,KAAK,IAAI,OAAO,KAAK,IAAI;AACzD;AAEA,MAAM,QAAQ;AACd,MAAM,UAAU;AAChB,MAAM,UAAU;AAGhB,SAAS,UAAU,MAAc,OAAe,SAAmC;AACjF,QAAM,IAAI,KAAK,KAAK;AACpB,MAAI,MAAM,SAAS,MAAM,SAAU,QAAO;AAC1C,QAAM,QAAQ,MAAM,KAAK,CAAC;AAC1B,MAAI,OAAO;AACT,UAAM,KAAK,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;AACtC,YAAQ,MAAM,CAAC,GAAG;AAAA,MAChB,KAAK;AACH,eAAO,QAAQ;AAAA,MACjB,KAAK;AACH,eAAO,SAAS;AAAA,MAClB,KAAK;AACH,eAAO,QAAQ;AAAA,MACjB;AACE,eAAO,SAAS;AAAA,IACpB;AAAA,EACF;AACA,QAAM,SAAS,QAAQ,KAAK,CAAC;AAC7B,MAAI,QAAQ;AACV,UAAM,KAAK,SAAS,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AACxC,WAAO,OAAO,CAAC,MAAM,QAAQ,SAAS,KAAK,SAAS;AAAA,EACtD;AACA,QAAM,UAAU,QAAQ,KAAK,CAAC;AAC9B,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,CAAC,EAAE,MAAM,KAAK,IAAI;AACxB,QAAM,SAAS,QAAQ,QAAQ,MAAM;AACrC,UAAQ,MAAM;AAAA,IACZ,KAAK;AAAA,IACL,KAAK;AACH,aAAO,WAAW,SAAS,WAAW;AAAA,IACxC,KAAK;AAAA,IACL,KAAK;AACH,aAAO,WAAW,SA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G,QAAqC;AAAA,QAClE;AAAA,MACF;AAAA,IACF;AAAA,IACA,WAAW;AACT,YAAM,MAAiB,CAAC;AACxB,iBAAW,YAAY,KAAM,YAAW,UAAU,SAAS,QAAS,KAAI,CAAC,IAAI,SAAS,MAAM,EAAG,KAAI,KAAK,MAAM;AAC9G,aAAO;AAAA,IACT;AAAA,IACA,UAAU;AACR,WAAK,MAAM;AACX,UAAI,OAAQ,QAAO,eAAe,YAAY,kBAAkB,MAAM;AAAA,UACjE,SAAQ,eAAe,YAAY,gBAAgB;AAAA,IAC1D;AAAA,EACF;AACF;","names":[]}
|
|
@@ -25,13 +25,6 @@ export interface PalettePreset {
|
|
|
25
25
|
dark: TokenSet;
|
|
26
26
|
}
|
|
27
27
|
export declare const DEFAULT_PRESET: PalettePreset;
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated 0.34 — `PALETTES`, the presets `presetById` and the palette store know, or
|
|
30
|
-
* `derivePalette` for a palette of the app's own; removed in 0.35 (refactor audit 2026-10,
|
|
31
|
-
* API-6c). A reference bank only: `presetById` resolves none of these ids, and no app
|
|
32
|
-
* imports it (deferred since the 2026-09-22 audit).
|
|
33
|
-
*/
|
|
34
|
-
export declare const ALTERNATIVE_PRESETS: PalettePreset[];
|
|
35
28
|
export declare const IMPRINT_PRESET: PalettePreset;
|
|
36
29
|
/**
|
|
37
30
|
* Presets DERIVED rather than picked, by `derivePalette` from one brand colour each.
|