@eifi1/ui-kit 0.46.1 → 0.48.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 +8 -6
- package/dist/admin/admin-sections.d.ts +8 -0
- package/dist/admin/admin-sections.js +2 -1
- package/dist/admin/admin-sections.js.map +1 -1
- package/dist/auth/verify-email.d.ts +9 -1
- package/dist/auth/verify-email.js +22 -13
- package/dist/auth/verify-email.js.map +1 -1
- package/dist/components/alert-banner.d.ts +29 -1
- package/dist/components/alert-banner.js +84 -7
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/button-look.d.ts +4 -0
- package/dist/components/button-look.js +2 -0
- package/dist/components/button-look.js.map +1 -1
- package/dist/components/combobox-core.js +5 -1
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/data-table-column-settings.d.ts +6 -1
- package/dist/components/data-table-column-settings.js +12 -2
- package/dist/components/data-table-column-settings.js.map +1 -1
- package/dist/components/data-table-fit.d.ts +44 -0
- package/dist/components/data-table-fit.js +103 -0
- package/dist/components/data-table-fit.js.map +1 -0
- package/dist/components/data-table-groups.d.ts +95 -0
- package/dist/components/data-table-groups.js +165 -0
- package/dist/components/data-table-groups.js.map +1 -0
- package/dist/components/data-table-head.js +3 -1
- package/dist/components/data-table-head.js.map +1 -1
- package/dist/components/data-table-labels.d.ts +7 -0
- package/dist/components/data-table-labels.js +3 -0
- package/dist/components/data-table-labels.js.map +1 -1
- package/dist/components/data-table-leading-row.d.ts +17 -0
- package/dist/components/data-table-leading-row.js +41 -0
- package/dist/components/data-table-leading-row.js.map +1 -0
- package/dist/components/data-table-resize.js +1 -1
- package/dist/components/data-table-resize.js.map +1 -1
- package/dist/components/data-table.d.ts +78 -2
- package/dist/components/data-table.js +355 -247
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/disclosure.d.ts +3 -1
- package/dist/components/disclosure.js +10 -4
- package/dist/components/disclosure.js.map +1 -1
- package/dist/components/dropdown.js +8 -1
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/floating-panel.d.ts +14 -1
- package/dist/components/floating-panel.js +7 -2
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/hover-menu.js +5 -1
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/icon-button.js +2 -1
- package/dist/components/icon-button.js.map +1 -1
- package/dist/components/popover.js +5 -1
- package/dist/components/popover.js.map +1 -1
- package/dist/components/row-actions.d.ts +25 -0
- package/dist/components/row-actions.js +13 -3
- package/dist/components/row-actions.js.map +1 -1
- package/dist/components/table-skeleton.d.ts +35 -0
- package/dist/components/table-skeleton.js +75 -0
- package/dist/components/table-skeleton.js.map +1 -0
- package/dist/components/tabs.d.ts +22 -16
- package/dist/components/tabs.js +47 -31
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/ui-labels.js +1 -1
- package/dist/components/ui-labels.js.map +1 -1
- package/dist/components/use-table-state.d.ts +8 -7
- package/dist/components/use-table-state.js +37 -3
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/data-table.d.ts +1 -0
- package/dist/data-table.js.map +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/feedback/feedback-attachment-download.d.ts +19 -0
- package/dist/feedback/feedback-attachment-download.js +59 -0
- package/dist/feedback/feedback-attachment-download.js.map +1 -0
- package/dist/feedback/feedback-comment-thread.d.ts +17 -6
- package/dist/feedback/feedback-comment-thread.js +21 -2
- package/dist/feedback/feedback-comment-thread.js.map +1 -1
- package/dist/feedback/feedback-entry-file.d.ts +61 -0
- package/dist/feedback/feedback-entry-file.js +76 -0
- package/dist/feedback/feedback-entry-file.js.map +1 -0
- package/dist/feedback/feedback-public-list.d.ts +18 -5
- package/dist/feedback/feedback-public-list.js +8 -0
- package/dist/feedback/feedback-public-list.js.map +1 -1
- package/dist/feedback/feedback-public-types.d.ts +7 -2
- package/dist/feedback/feedback-replies.d.ts +26 -9
- package/dist/feedback/feedback-replies.js +20 -10
- package/dist/feedback/feedback-replies.js.map +1 -1
- package/dist/feedback/feedback-row-detail-labels.js +0 -1
- package/dist/feedback/feedback-row-detail-labels.js.map +1 -1
- package/dist/feedback/feedback-row-detail.d.ts +23 -10
- package/dist/feedback/feedback-row-detail.js +10 -54
- package/dist/feedback/feedback-row-detail.js.map +1 -1
- package/dist/feedback/feedback-table.d.ts +5 -0
- package/dist/feedback/feedback-table.js +30 -7
- package/dist/feedback/feedback-table.js.map +1 -1
- package/dist/feedback.d.ts +1 -0
- package/dist/feedback.js +1 -0
- package/dist/feedback.js.map +1 -1
- package/dist/hooks/use-dismiss.d.ts +30 -1
- package/dist/hooks/use-dismiss.js +30 -2
- package/dist/hooks/use-dismiss.js.map +1 -1
- package/dist/i18n/german.js +7 -7
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +4 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +7 -7
- package/dist/i18n/locales/en.js.map +2 -2
- package/dist/i18n/locales/es.js +7 -7
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +7 -7
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +7 -7
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +7 -7
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js +7 -7
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.js +0 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/i18n/shared-labels.js +3 -1
- package/dist/i18n/shared-labels.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/float-clearance.d.ts +8 -0
- package/dist/lib/float-clearance.js +29 -0
- package/dist/lib/float-clearance.js.map +1 -0
- package/dist/notifications/device-zone-report.d.ts +1 -1
- package/dist/notifications/device-zone-report.js.map +1 -1
- package/dist/notifications/notification-types.d.ts +0 -3
- package/dist/notifications/notifications-labels.d.ts +2 -15
- package/dist/notifications/notifications-labels.js +0 -4
- package/dist/notifications/notifications-labels.js.map +1 -1
- package/dist/notifications/quiet-hours-setting.d.ts +3 -8
- package/dist/notifications/quiet-hours-setting.js +8 -3
- package/dist/notifications/quiet-hours-setting.js.map +1 -1
- package/dist/settings/settings-catalogue.d.ts +10 -0
- package/dist/settings/settings-catalogue.js.map +1 -1
- package/dist/settings/settings-layout.js +10 -3
- package/dist/settings/settings-layout.js.map +1 -1
- package/dist/shell/app-shell.d.ts +5 -0
- package/dist/shell/app-shell.js +5 -3
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/option-switcher-menu.d.ts +2 -0
- package/dist/shell/option-switcher-menu.js +6 -2
- package/dist/shell/option-switcher-menu.js.map +1 -1
- package/dist/shell/topbar-action-menu.js +2 -1
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell/topbar-controls.js +5 -3
- package/dist/shell/topbar-controls.js.map +1 -1
- package/dist/theme/theme-store.d.ts +4 -4
- package/dist/theme/theme-store.js +1 -0
- package/dist/theme/theme-store.js.map +1 -1
- package/dist/tour/tour.js +1 -0
- package/dist/tour/tour.js.map +1 -1
- package/package.json +2 -2
- package/src/admin/admin-sections.tsx +8 -0
- package/src/auth/verify-email.tsx +34 -9
- package/src/components/alert-banner.tsx +131 -7
- package/src/components/button-look.ts +6 -0
- package/src/components/combobox-core.tsx +7 -1
- package/src/components/data-table-column-settings.tsx +23 -2
- package/src/components/data-table-fit.ts +187 -0
- package/src/components/data-table-groups.tsx +275 -0
- package/src/components/data-table-head.tsx +4 -1
- package/src/components/data-table-labels.ts +13 -0
- package/src/components/data-table-leading-row.tsx +55 -0
- package/src/components/data-table-resize.ts +2 -1
- package/src/components/data-table.tsx +274 -45
- package/src/components/disclosure.tsx +22 -5
- package/src/components/dropdown.tsx +11 -1
- package/src/components/floating-panel.tsx +24 -1
- package/src/components/hover-menu.tsx +6 -1
- package/src/components/icon-button.tsx +3 -3
- package/src/components/popover.tsx +7 -1
- package/src/components/row-actions.tsx +42 -3
- package/src/components/table-skeleton.tsx +133 -0
- package/src/components/tabs.tsx +102 -50
- package/src/components/ui-labels.ts +1 -1
- package/src/components/use-table-state.ts +54 -3
- package/src/data-table.ts +2 -0
- package/src/feedback/feedback-attachment-download.tsx +77 -0
- package/src/feedback/feedback-comment-thread.tsx +42 -7
- package/src/feedback/feedback-entry-file.tsx +150 -0
- package/src/feedback/feedback-public-list.tsx +25 -4
- package/src/feedback/feedback-public-types.ts +7 -2
- package/src/feedback/feedback-replies.tsx +46 -19
- package/src/feedback/feedback-row-detail-labels.ts +0 -1
- package/src/feedback/feedback-row-detail.tsx +35 -86
- package/src/feedback/feedback-table.tsx +33 -1
- package/src/feedback.ts +1 -0
- package/src/hooks/use-dismiss.ts +65 -3
- package/src/i18n/german.ts +6 -6
- package/src/i18n/kit-labels.tsx +4 -0
- package/src/i18n/locales/es.ts +6 -6
- package/src/i18n/locales/fr.ts +6 -6
- package/src/i18n/locales/hu.ts +6 -6
- package/src/i18n/locales/it.ts +6 -6
- package/src/i18n/locales/zh.ts +6 -6
- package/src/i18n/review.ts +0 -1
- package/src/i18n/shared-labels.ts +2 -0
- package/src/index.ts +13 -3
- package/src/lib/float-clearance.ts +54 -0
- package/src/notifications/device-zone-report.ts +1 -1
- package/src/notifications/notification-types.ts +0 -3
- package/src/notifications/notifications-labels.ts +2 -19
- package/src/notifications/quiet-hours-setting.tsx +16 -11
- package/src/settings/settings-catalogue.ts +10 -0
- package/src/settings/settings-layout.tsx +18 -4
- package/src/shell/app-shell.tsx +17 -3
- package/src/shell/option-switcher-menu.tsx +16 -4
- package/src/shell/topbar-action-menu.tsx +22 -10
- package/src/shell/topbar-controls.tsx +18 -12
- package/src/theme/theme-store.ts +13 -5
- package/src/tour/tour.tsx +5 -0
- package/dist/notifications/time-zone-select.d.ts +0 -54
- package/dist/notifications/time-zone-select.js +0 -71
- package/dist/notifications/time-zone-select.js.map +0 -1
- package/src/notifications/time-zone-select.tsx +0 -125
|
@@ -7,10 +7,6 @@ export interface QuietHoursSettingProps extends Omit<ComponentPropsWithRef<"div"
|
|
|
7
7
|
start: string | null;
|
|
8
8
|
/** The `GET`'s `quiet_hours_end`. */
|
|
9
9
|
end: string | null;
|
|
10
|
-
/** The zone the 0.36 card showed, an IANA name, or `null`.
|
|
11
|
-
* @deprecated 0.46 — pass `zone` (§10.3: the zone is the account's, automatic only); removed in 0.47.
|
|
12
|
-
* Shown read-only while `zone` is left out; the card no longer offers a picker. */
|
|
13
|
-
timezone?: string | null;
|
|
14
10
|
/**
|
|
15
11
|
* 0.46 (§10.3, amended 2026-10-20: automatic only): the account's zone — `/auth/me`'s
|
|
16
12
|
* `device_timezone`, the zone of the device last used; `null` while no device has
|
|
@@ -28,7 +24,7 @@ export interface QuietHoursSettingProps extends Omit<ComponentPropsWithRef<"div"
|
|
|
28
24
|
* rejects.
|
|
29
25
|
*/
|
|
30
26
|
onChange: (patch: NotificationSettingsPatch) => Promise<unknown> | void;
|
|
31
|
-
/** The zone named while
|
|
27
|
+
/** The zone named while `zone` names none: the one the server
|
|
32
28
|
* applies. Default `"Europe/Zurich"`, every app's. */
|
|
33
29
|
fallbackZone?: string;
|
|
34
30
|
/** The app keeps an inbox, and the description says a held push still reaches it. */
|
|
@@ -51,9 +47,8 @@ export interface QuietHoursSettingProps extends Omit<ComponentPropsWithRef<"div"
|
|
|
51
47
|
*
|
|
52
48
|
* - **Two times**, each saved as it is entered; a cleared time sends `null`. While only
|
|
53
49
|
* one is set the card says so: the window fails open until both are.
|
|
54
|
-
* - **The zone** shows while a time is set: `zone`, else
|
|
55
|
-
* `fallbackZone`.
|
|
50
|
+
* - **The zone** shows while a time is set: `zone`, else `fallbackZone`.
|
|
56
51
|
*
|
|
57
52
|
* Under a write lock the fields are `commit` controls exempt from billing.
|
|
58
53
|
*/
|
|
59
|
-
export declare function QuietHoursSetting({ start, end,
|
|
54
|
+
export declare function QuietHoursSetting({ start, end, zone, held, onChange, fallbackZone, inbox, disabled, describeError, labels: labelsProp, className, ...rest }: QuietHoursSettingProps): import("react").JSX.Element;
|
|
@@ -9,12 +9,17 @@ import { CARD_DESCRIPTION_CLASS } from "../settings/settings-card-classes.js";
|
|
|
9
9
|
import { SettingsCardTitle } from "../settings/settings-heading.js";
|
|
10
10
|
import { settle, useMounted } from "../account/account-parts.js";
|
|
11
11
|
import { describeFailure, FailureLine, useNotificationsLabels, useWriteOverlay } from "./notification-parts.js";
|
|
12
|
-
import { zoneName } from "./time-zone-select.js";
|
|
13
12
|
const DEFAULT_FALLBACK_ZONE = "Europe/Zurich";
|
|
13
|
+
function zoneName(zone, regions) {
|
|
14
|
+
const slash = zone.indexOf("/");
|
|
15
|
+
if (slash < 0) return zone;
|
|
16
|
+
const region = zone.slice(0, slash);
|
|
17
|
+
const named = Object.prototype.hasOwnProperty.call(regions, region) ? regions[region] : region;
|
|
18
|
+
return `${named} / ${zone.slice(slash + 1).replace(/_/g, " ").replace(/\//g, " / ")}`;
|
|
19
|
+
}
|
|
14
20
|
function QuietHoursSetting({
|
|
15
21
|
start,
|
|
16
22
|
end,
|
|
17
|
-
timezone = null,
|
|
18
23
|
zone,
|
|
19
24
|
held = false,
|
|
20
25
|
onChange,
|
|
@@ -34,7 +39,7 @@ function QuietHoursSetting({
|
|
|
34
39
|
const shown = (field, server) => overlay.has(field) ? overlay.get(field) ?? null : server;
|
|
35
40
|
const startShown = shown("quiet_hours_start", start);
|
|
36
41
|
const endShown = shown("quiet_hours_end", end);
|
|
37
|
-
const accountZone =
|
|
42
|
+
const accountZone = zone ?? fallbackZone;
|
|
38
43
|
const save = (patch) => {
|
|
39
44
|
const fields = Object.keys(patch);
|
|
40
45
|
setFailure(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/notifications/quiet-hours-setting.tsx"],"sourcesContent":["import { useId, useState } from \"react\";\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\n\nimport type { LabelOverride } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { Card } from \"../components/card\";\nimport { TimeInput } from \"../components/time-input\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { CARD_DESCRIPTION_CLASS } from \"../settings/settings-card-classes\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { settle, useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels, useWriteOverlay } from \"./notification-parts\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\nimport type { NotificationSettingsPatch } from \"./notification-types\";\nimport { zoneName } from \"./time-zone-select\";\n\n/** The zone the server applies while no device ever reported one (§10.3): every app's. */\nconst DEFAULT_FALLBACK_ZONE = \"Europe/Zurich\";\n\nexport interface QuietHoursSettingProps extends Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"onChange\"> {\n /** The `GET`'s `quiet_hours_start`, `\"HH:MM\"`, or `null`. */\n start: string | null;\n /** The `GET`'s `quiet_hours_end`. */\n end: string | null;\n /** The zone the 0.36 card showed, an IANA name, or `null`.\n * @deprecated 0.46 — pass `zone` (§10.3: the zone is the account's, automatic only); removed in 0.47.\n * Shown read-only while `zone` is left out; the card no longer offers a picker. */\n timezone?: string | null;\n /**\n * 0.46 (§10.3, amended 2026-10-20: automatic only): the account's zone — `/auth/me`'s\n * `device_timezone`, the zone of the device last used; `null` while no device has\n * reported one, and the card then names `fallbackZone`, the zone the server applies.\n * Shown read-only once a time is set (\"In your time zone (Europe / Zurich), which follows\n * the device you last used.\"). No picker: the zone is never chosen.\n */\n zone?: string | null;\n /** 0.46 (§10.4): the app queues a held push and sends it when the window ends (it runs\n * the notifications tick); the description says so. Default `false`: dropped. */\n held?: boolean;\n /**\n * Save one change — `PATCH /notifications/settings`: a time, or `null` when cleared.\n * Never a zone. The field shows the new value while the call runs and goes back if it\n * rejects.\n */\n onChange: (patch: NotificationSettingsPatch) => Promise<unknown> | void;\n /** The zone named while neither `zone` nor `timezone` names one: the one the server\n * applies. Default `\"Europe/Zurich\"`, every app's. */\n fallbackZone?: string;\n /** The app keeps an inbox, and the description says a held push still reaches it. */\n inbox?: boolean;\n disabled?: boolean;\n /** The app's own words for a failed save, or `undefined` for the kit's `failed`. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\ntype QuietField = \"quiet_hours_start\" | \"quiet_hours_end\";\n\n/**\n * Quiet hours (docs/notifications-harmonization.md §2.4, §2.6, §4.2): a window of local\n * times in the account's zone, which may cross midnight, when no push of a machine-sent\n * type is sent. A held push is dropped — or, with `held` (0.46, §10.4), sent when the\n * window ends; the inbox row and the mail go as usual. keksdose's block, as a card of its\n * own.\n *\n * **0.46 (§10.3, amended 2026-10-20, Marcel): the zone is the account's, automatic\n * only** — the zone of the device last used, else `Europe/Zurich`. The card names it\n * read-only and never sends one; there is no picker and no \"Use it\".\n *\n * - **Two times**, each saved as it is entered; a cleared time sends `null`. While only\n * one is set the card says so: the window fails open until both are.\n * - **The zone** shows while a time is set: `zone`, else the deprecated `timezone`, else\n * `fallbackZone`.\n *\n * Under a write lock the fields are `commit` controls exempt from billing.\n */\nexport function QuietHoursSetting({\n start,\n end,\n timezone = null,\n zone,\n held = false,\n onChange,\n fallbackZone = DEFAULT_FALLBACK_ZONE,\n inbox = false,\n disabled = false,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: QuietHoursSettingProps) {\n const labels = useNotificationsLabels(labelsProp);\n const overlay = useWriteOverlay<string | null>(`${start}|${end}`);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n const id = useId();\n\n const shown = (field: QuietField, server: string | null) =>\n overlay.has(field) ? (overlay.get(field) ?? null) : server;\n const startShown = shown(\"quiet_hours_start\", start);\n const endShown = shown(\"quiet_hours_end\", end);\n const accountZone = (zone === undefined ? timezone : zone) ?? fallbackZone;\n\n const save = (patch: NotificationSettingsPatch) => {\n const fields = Object.keys(patch) as QuietField[];\n setFailure(null);\n for (const field of fields) overlay.set(field, patch[field] ?? null);\n settle(() => onChange(patch)).then(\n () => {\n if (mounted.current) for (const field of fields) overlay.settle(field, true);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n for (const field of fields) overlay.settle(field, false);\n setFailure(describeFailure(describeError?.(error), labels.failed));\n },\n );\n };\n\n const saveTime = (field: \"quiet_hours_start\" | \"quiet_hours_end\", value: string) => {\n const next = value || null;\n if (next === shown(field, field === \"quiet_hours_start\" ? start : end)) return;\n save({ [field]: next });\n };\n\n const anySet = Boolean(startShown || endShown);\n const halfSet = Boolean(startShown) !== Boolean(endShown);\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle>{labels.quietTitle}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.quietDescription(inbox, held)}</div>\n </div>\n <div className=\"flex flex-wrap items-end gap-3\">\n <TimeInput\n id={`${id}-start`}\n label={labels.quietFrom}\n value={startShown ?? \"\"}\n disabled={disabled}\n commit={COMMIT_EXCEPT_BILLING}\n onValueChange={(value) => saveTime(\"quiet_hours_start\", value)}\n className=\"w-36\"\n />\n <TimeInput\n id={`${id}-end`}\n label={labels.quietUntil}\n value={endShown ?? \"\"}\n disabled={disabled}\n commit={COMMIT_EXCEPT_BILLING}\n onValueChange={(value) => saveTime(\"quiet_hours_end\", value)}\n className=\"w-36\"\n />\n </div>\n {halfSet && (\n <p className=\"text-xs text-warning\" data-quiet-incomplete=\"\">\n {labels.quietIncomplete}\n </p>\n )}\n {anySet && (\n <p className={CARD_DESCRIPTION_CLASS} data-quiet-zone=\"\">\n {labels.quietZone(zoneName(accountZone, labels.regions))}\n </p>\n )}\n <FailureLine>{failure}</FailureLine>\n </Card>\n );\n}\n"],"mappings":";AAkIM,SACE,KADF;AAlIN,SAAS,OAAO,gBAAgB;AAIhC,SAAS,UAAU;AACnB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AACvC,SAAS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|
+
{"version":3,"sources":["../../src/notifications/quiet-hours-setting.tsx"],"sourcesContent":["import { useId, useState } from \"react\";\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\n\nimport type { LabelOverride } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { Card } from \"../components/card\";\nimport { TimeInput } from \"../components/time-input\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { CARD_DESCRIPTION_CLASS } from \"../settings/settings-card-classes\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { settle, useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels, useWriteOverlay } from \"./notification-parts\";\nimport type { NotificationRegionLabels, NotificationsLabels } from \"./notifications-labels\";\nimport type { NotificationSettingsPatch } from \"./notification-types\";\n\n/** The zone the server applies while no device ever reported one (§10.3): every app's. */\nconst DEFAULT_FALLBACK_ZONE = \"Europe/Zurich\";\n\n/** A zone for a sentence: \"Europe / Zurich\", the region in the kit's words (`labels.regions`);\n * a region the labels do not know keeps its IANA name, a zone with none (\"UTC\") is itself. */\nfunction zoneName(zone: string, regions: NotificationRegionLabels): string {\n const slash = zone.indexOf(\"/\");\n if (slash < 0) return zone;\n const region = zone.slice(0, slash);\n const named = Object.prototype.hasOwnProperty.call(regions, region)\n ? regions[region as keyof NotificationRegionLabels]\n : region;\n return `${named} / ${zone.slice(slash + 1).replace(/_/g, \" \").replace(/\\//g, \" / \")}`;\n}\n\nexport interface QuietHoursSettingProps extends Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"onChange\"> {\n /** The `GET`'s `quiet_hours_start`, `\"HH:MM\"`, or `null`. */\n start: string | null;\n /** The `GET`'s `quiet_hours_end`. */\n end: string | null;\n /**\n * 0.46 (§10.3, amended 2026-10-20: automatic only): the account's zone — `/auth/me`'s\n * `device_timezone`, the zone of the device last used; `null` while no device has\n * reported one, and the card then names `fallbackZone`, the zone the server applies.\n * Shown read-only once a time is set (\"In your time zone (Europe / Zurich), which follows\n * the device you last used.\"). No picker: the zone is never chosen.\n */\n zone?: string | null;\n /** 0.46 (§10.4): the app queues a held push and sends it when the window ends (it runs\n * the notifications tick); the description says so. Default `false`: dropped. */\n held?: boolean;\n /**\n * Save one change — `PATCH /notifications/settings`: a time, or `null` when cleared.\n * Never a zone. The field shows the new value while the call runs and goes back if it\n * rejects.\n */\n onChange: (patch: NotificationSettingsPatch) => Promise<unknown> | void;\n /** The zone named while `zone` names none: the one the server\n * applies. Default `\"Europe/Zurich\"`, every app's. */\n fallbackZone?: string;\n /** The app keeps an inbox, and the description says a held push still reaches it. */\n inbox?: boolean;\n disabled?: boolean;\n /** The app's own words for a failed save, or `undefined` for the kit's `failed`. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\ntype QuietField = \"quiet_hours_start\" | \"quiet_hours_end\";\n\n/**\n * Quiet hours (docs/notifications-harmonization.md §2.4, §2.6, §4.2): a window of local\n * times in the account's zone, which may cross midnight, when no push of a machine-sent\n * type is sent. A held push is dropped — or, with `held` (0.46, §10.4), sent when the\n * window ends; the inbox row and the mail go as usual. keksdose's block, as a card of its\n * own.\n *\n * **0.46 (§10.3, amended 2026-10-20, Marcel): the zone is the account's, automatic\n * only** — the zone of the device last used, else `Europe/Zurich`. The card names it\n * read-only and never sends one; there is no picker and no \"Use it\".\n *\n * - **Two times**, each saved as it is entered; a cleared time sends `null`. While only\n * one is set the card says so: the window fails open until both are.\n * - **The zone** shows while a time is set: `zone`, else `fallbackZone`.\n *\n * Under a write lock the fields are `commit` controls exempt from billing.\n */\nexport function QuietHoursSetting({\n start,\n end,\n zone,\n held = false,\n onChange,\n fallbackZone = DEFAULT_FALLBACK_ZONE,\n inbox = false,\n disabled = false,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: QuietHoursSettingProps) {\n const labels = useNotificationsLabels(labelsProp);\n const overlay = useWriteOverlay<string | null>(`${start}|${end}`);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n const id = useId();\n\n const shown = (field: QuietField, server: string | null) =>\n overlay.has(field) ? (overlay.get(field) ?? null) : server;\n const startShown = shown(\"quiet_hours_start\", start);\n const endShown = shown(\"quiet_hours_end\", end);\n const accountZone = zone ?? fallbackZone;\n\n const save = (patch: NotificationSettingsPatch) => {\n const fields = Object.keys(patch) as QuietField[];\n setFailure(null);\n for (const field of fields) overlay.set(field, patch[field] ?? null);\n settle(() => onChange(patch)).then(\n () => {\n if (mounted.current) for (const field of fields) overlay.settle(field, true);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n for (const field of fields) overlay.settle(field, false);\n setFailure(describeFailure(describeError?.(error), labels.failed));\n },\n );\n };\n\n const saveTime = (field: \"quiet_hours_start\" | \"quiet_hours_end\", value: string) => {\n const next = value || null;\n if (next === shown(field, field === \"quiet_hours_start\" ? start : end)) return;\n save({ [field]: next });\n };\n\n const anySet = Boolean(startShown || endShown);\n const halfSet = Boolean(startShown) !== Boolean(endShown);\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle>{labels.quietTitle}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.quietDescription(inbox, held)}</div>\n </div>\n <div className=\"flex flex-wrap items-end gap-3\">\n <TimeInput\n id={`${id}-start`}\n label={labels.quietFrom}\n value={startShown ?? \"\"}\n disabled={disabled}\n commit={COMMIT_EXCEPT_BILLING}\n onValueChange={(value) => saveTime(\"quiet_hours_start\", value)}\n className=\"w-36\"\n />\n <TimeInput\n id={`${id}-end`}\n label={labels.quietUntil}\n value={endShown ?? \"\"}\n disabled={disabled}\n commit={COMMIT_EXCEPT_BILLING}\n onValueChange={(value) => saveTime(\"quiet_hours_end\", value)}\n className=\"w-36\"\n />\n </div>\n {halfSet && (\n <p className=\"text-xs text-warning\" data-quiet-incomplete=\"\">\n {labels.quietIncomplete}\n </p>\n )}\n {anySet && (\n <p className={CARD_DESCRIPTION_C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A,UACR,eAAe,CAAC,UAAU,SAAS,qBAAqB,KAAK;AAAA,UAC7D,WAAU;AAAA;AAAA,MACZ;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,IAAI,GAAG,EAAE;AAAA,UACT,OAAO,OAAO;AAAA,UACd,OAAO,YAAY;AAAA,UACnB;AAAA,UACA,QAAQ;AAAA,UACR,eAAe,CAAC,UAAU,SAAS,mBAAmB,KAAK;AAAA,UAC3D,WAAU;AAAA;AAAA,MACZ;AAAA,OACF;AAAA,IACC,WACC,oBAAC,OAAE,WAAU,wBAAuB,yBAAsB,IACvD,iBAAO,iBACV;AAAA,IAED,UACC,oBAAC,OAAE,WAAW,wBAAwB,mBAAgB,IACnD,iBAAO,UAAU,SAAS,aAAa,OAAO,OAAO,CAAC,GACzD;AAAA,IAEF,oBAAC,eAAa,mBAAQ;AAAA,KACxB;AAEJ;","names":[]}
|
|
@@ -21,6 +21,16 @@ export interface SettingsGroup<G extends string = string> {
|
|
|
21
21
|
title: string;
|
|
22
22
|
/** One line under the heading and in the phone list, where it is cut to one line. */
|
|
23
23
|
help: string;
|
|
24
|
+
/**
|
|
25
|
+
* 0.48 (keksdose live #450): a count or a mark drawn on the group's ROW — at the end of
|
|
26
|
+
* its desktop sidebar row and before the chevron of its phone list row — never on the
|
|
27
|
+
* heading over its cards. The admin area's waiting work: `<AdminWaitingBadge count={n} />`
|
|
28
|
+
* (nothing for 0), so the account menu's badge leads to the section that holds it. It
|
|
29
|
+
* sits inside the row's link and is read with its name, so say what the number is (the
|
|
30
|
+
* waiting pill does: "3, 3 waiting"). While the page is searched the sidebar shows the
|
|
31
|
+
* hit count in its place. Default: none.
|
|
32
|
+
*/
|
|
33
|
+
badge?: ReactNode;
|
|
24
34
|
/**
|
|
25
35
|
* `false` hides the group: no row, no hits, and its path acts as an unknown one — it
|
|
26
36
|
* lands on the default group (desktop) or the list (phone), never on a 404 (§3.1).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/settings/settings-catalogue.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { SearchEntry } from \"../search/search-index\";\n\n/**\n * The settings catalogue (docs/settings-harmonization.md §4.1), lifted from keksdose's\n * `settings-index.ts`: the groups a settings page is split into, and one entry per\n * SETTING — not per card — so a search for \"quiet hours\" finds the field inside the\n * notifications card. One list feeds the sidebar, the phone list, the in-page search and\n * ⌘K ({@link settingsSearchEntries}); keksdose's page and its palette drifted when they\n * had one each.\n *\n * The kit resolves no words: `title`, `help` and `keywords` arrive translated (an app's\n * own, or the core groups' from `DEFAULT_SETTINGS_LABELS.groups`).\n */\n\n/** One group of the page: a sidebar row on a desktop, a list row on a phone (§3.2, §3.3). */\nexport interface SettingsGroup<G extends string = string> {\n /** The path segment, `/settings/<id>`: lowercase, a–z and \"-\". */\n id: G;\n /** The row's icon — a lucide icon at the row's size is sized by the row. */\n icon: ReactNode;\n /** The group's name: the sidebar row, the heading over its cards, the phone list. */\n title: string;\n /** One line under the heading and in the phone list, where it is cut to one line. */\n help: string;\n /**\n * `false` hides the group: no row, no hits, and its path acts as an unknown one — it\n * lands on the default group (desktop) or the list (phone), never on a 404 (§3.1).\n * kastlan's `/admin/billing` while billing is off. Default: visible.\n */\n visible?: boolean;\n /**\n * 0.43: the group shows with no visible entry — a page of its own rather than of setting\n * cards (the admin area's Overview, whose tiles are no settings; `adminSections` sets\n * it). `visible: false` still hides it. Default: a group shows only with an entry once\n * `entries` are given (§4.1).\n */\n standalone?: boolean;\n}\n\n/** One setting, and the card that holds it (§4.1). */\nexport interface SettingsEntry<G extends string = string> {\n /** Unique within the catalogue. */\n id: string;\n /** The group whose page shows the card. */\n group: G;\n /** The card's DOM id, unique on the page — the `?focus=` target. Several entries may\n * share one: a card that holds four settings has four entries. */\n anchor: string;\n /** What a search hit says. */\n title: string;\n /** Localized, space-separated words people type that the title does not contain\n * (\"dark night\" for the theme, \"2fa totp\" for two-factor). Never shown. */\n keywords?: string;\n /**\n * `false` drops the entry from the page's search and ⌘K. A group whose entries are\n * ALL hidden is hidden with them (§4.1): a demo session marks every card it is refused\n * (passkeys, 2FA, export, deletion …) and so never sees a page of cards that each\n * answer 403. Default: visible.\n */\n visible?: boolean;\n}\n\n/**\n * The groups that show, in their order: not `visible: false`, and — when `entries` is\n * given — holding at least one visible entry (§4.1: Kurvenschmiede's notifications group\n * stays hidden until it has a card) or `standalone` (0.43). Without `entries` only the\n * groups' own flag counts.\n */\nexport function visibleSettingsGroups<G extends string>(\n groups: readonly SettingsGroup<G>[],\n entries?: readonly SettingsEntry<G>[],\n): SettingsGroup<G>[] {\n if (!entries) return groups.filter((g) => g.visible !== false);\n const filled = new Set<G>();\n for (const e of entries) if (e.visible !== false) filled.add(e.group);\n return groups.filter((g) => g.visible !== false && (g.standalone === true || filled.has(g.id)));\n}\n\n/** The visible entries of the visible groups — what search may find. */\nexport function visibleSettingsEntries<G extends string>(\n groups: readonly SettingsGroup<G>[],\n entries: readonly SettingsEntry<G>[],\n): SettingsEntry<G>[] {\n const shown = new Set(visibleSettingsGroups(groups, entries).map((g) => g.id));\n return entries.filter((e) => e.visible !== false && shown.has(e.group));\n}\n\n/** `basePath` without a trailing slash: \"/settings/\" and \"/settings\" are one page. */\nexport function normalizeSettingsBase(basePath: string): string {\n const trimmed = basePath.replace(/\\/+$/, \"\");\n return trimmed.startsWith(\"/\") || trimmed === \"\" ? trimmed : `/${trimmed}`;\n}\n\n/** `/settings/<group>`, and `?focus=<anchor>` when a card is named (§3.4). */\nexport function settingsHref(basePath: string, group: string, anchor?: string): string {\n const path = `${normalizeSettingsBase(basePath)}/${group}`;\n return anchor ? `${path}?focus=${encodeURIComponent(anchor)}` : path;\n}\n\n/** \"dark night\" → [\"dark\", \"night\"]. */\nexport function settingsKeywords(keywords: string | undefined): string[] {\n return keywords ? keywords.split(/\\s+/).filter(Boolean) : [];\n}\n\nexport interface SettingsSearchEntriesOptions {\n /** `/settings` or `/admin` — the hits link to `<basePath>/<group>?focus=<anchor>`. */\n basePath: string;\n}\n\n/**\n * The catalogue as {@link GlobalSearch} entries (§3.4): each visible setting, under its\n * group's name as the palette's section, linking to `/settings/<group>?focus=<anchor>` —\n * the same link the page's own search hit is, so ⌘K, a tour and a mail all land the\n * same way (§3.5). The group's name is a keyword too, as on the page: \"security\" lists\n * the security group's settings.\n *\n * Ids are prefixed with the base path (\"settings:theme\", \"admin:users\") so a palette\n * that also holds pages and actions keeps them unique.\n */\nexport function settingsSearchEntries<G extends string>(\n groups: readonly SettingsGroup<G>[],\n entries: readonly SettingsEntry<G>[],\n options: SettingsSearchEntriesOptions,\n): SearchEntry[] {\n const base = normalizeSettingsBase(options.basePath);\n const prefix = base.replace(/^\\//, \"\").replace(/\\//g, \":\") || \"settings\";\n const byId = new Map(visibleSettingsGroups(groups, entries).map((g) => [g.id, g]));\n return visibleSettingsEntries(groups, entries).map((e) => {\n const group = byId.get(e.group)!;\n return {\n id: `${prefix}:${e.id}`,\n title: e.title,\n keywords: [group.title, ...settingsKeywords(e.keywords)],\n group: group.title,\n icon: group.icon,\n href: settingsHref(base, e.group, e.anchor),\n };\n });\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../src/settings/settings-catalogue.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { SearchEntry } from \"../search/search-index\";\n\n/**\n * The settings catalogue (docs/settings-harmonization.md §4.1), lifted from keksdose's\n * `settings-index.ts`: the groups a settings page is split into, and one entry per\n * SETTING — not per card — so a search for \"quiet hours\" finds the field inside the\n * notifications card. One list feeds the sidebar, the phone list, the in-page search and\n * ⌘K ({@link settingsSearchEntries}); keksdose's page and its palette drifted when they\n * had one each.\n *\n * The kit resolves no words: `title`, `help` and `keywords` arrive translated (an app's\n * own, or the core groups' from `DEFAULT_SETTINGS_LABELS.groups`).\n */\n\n/** One group of the page: a sidebar row on a desktop, a list row on a phone (§3.2, §3.3). */\nexport interface SettingsGroup<G extends string = string> {\n /** The path segment, `/settings/<id>`: lowercase, a–z and \"-\". */\n id: G;\n /** The row's icon — a lucide icon at the row's size is sized by the row. */\n icon: ReactNode;\n /** The group's name: the sidebar row, the heading over its cards, the phone list. */\n title: string;\n /** One line under the heading and in the phone list, where it is cut to one line. */\n help: string;\n /**\n * 0.48 (keksdose live #450): a count or a mark drawn on the group's ROW — at the end of\n * its desktop sidebar row and before the chevron of its phone list row — never on the\n * heading over its cards. The admin area's waiting work: `<AdminWaitingBadge count={n} />`\n * (nothing for 0), so the account menu's badge leads to the section that holds it. It\n * sits inside the row's link and is read with its name, so say what the number is (the\n * waiting pill does: \"3, 3 waiting\"). While the page is searched the sidebar shows the\n * hit count in its place. Default: none.\n */\n badge?: ReactNode;\n /**\n * `false` hides the group: no row, no hits, and its path acts as an unknown one — it\n * lands on the default group (desktop) or the list (phone), never on a 404 (§3.1).\n * kastlan's `/admin/billing` while billing is off. Default: visible.\n */\n visible?: boolean;\n /**\n * 0.43: the group shows with no visible entry — a page of its own rather than of setting\n * cards (the admin area's Overview, whose tiles are no settings; `adminSections` sets\n * it). `visible: false` still hides it. Default: a group shows only with an entry once\n * `entries` are given (§4.1).\n */\n standalone?: boolean;\n}\n\n/** One setting, and the card that holds it (§4.1). */\nexport interface SettingsEntry<G extends string = string> {\n /** Unique within the catalogue. */\n id: string;\n /** The group whose page shows the card. */\n group: G;\n /** The card's DOM id, unique on the page — the `?focus=` target. Several entries may\n * share one: a card that holds four settings has four entries. */\n anchor: string;\n /** What a search hit says. */\n title: string;\n /** Localized, space-separated words people type that the title does not contain\n * (\"dark night\" for the theme, \"2fa totp\" for two-factor). Never shown. */\n keywords?: string;\n /**\n * `false` drops the entry from the page's search and ⌘K. A group whose entries are\n * ALL hidden is hidden with them (§4.1): a demo session marks every card it is refused\n * (passkeys, 2FA, export, deletion …) and so never sees a page of cards that each\n * answer 403. Default: visible.\n */\n visible?: boolean;\n}\n\n/**\n * The groups that show, in their order: not `visible: false`, and — when `entries` is\n * given — holding at least one visible entry (§4.1: Kurvenschmiede's notifications group\n * stays hidden until it has a card) or `standalone` (0.43). Without `entries` only the\n * groups' own flag counts.\n */\nexport function visibleSettingsGroups<G extends string>(\n groups: readonly SettingsGroup<G>[],\n entries?: readonly SettingsEntry<G>[],\n): SettingsGroup<G>[] {\n if (!entries) return groups.filter((g) => g.visible !== false);\n const filled = new Set<G>();\n for (const e of entries) if (e.visible !== false) filled.add(e.group);\n return groups.filter((g) => g.visible !== false && (g.standalone === true || filled.has(g.id)));\n}\n\n/** The visible entries of the visible groups — what search may find. */\nexport function visibleSettingsEntries<G extends string>(\n groups: readonly SettingsGroup<G>[],\n entries: readonly SettingsEntry<G>[],\n): SettingsEntry<G>[] {\n const shown = new Set(visibleSettingsGroups(groups, entries).map((g) => g.id));\n return entries.filter((e) => e.visible !== false && shown.has(e.group));\n}\n\n/** `basePath` without a trailing slash: \"/settings/\" and \"/settings\" are one page. */\nexport function normalizeSettingsBase(basePath: string): string {\n const trimmed = basePath.replace(/\\/+$/, \"\");\n return trimmed.startsWith(\"/\") || trimmed === \"\" ? trimmed : `/${trimmed}`;\n}\n\n/** `/settings/<group>`, and `?focus=<anchor>` when a card is named (§3.4). */\nexport function settingsHref(basePath: string, group: string, anchor?: string): string {\n const path = `${normalizeSettingsBase(basePath)}/${group}`;\n return anchor ? `${path}?focus=${encodeURIComponent(anchor)}` : path;\n}\n\n/** \"dark night\" → [\"dark\", \"night\"]. */\nexport function settingsKeywords(keywords: string | undefined): string[] {\n return keywords ? keywords.split(/\\s+/).filter(Boolean) : [];\n}\n\nexport interface SettingsSearchEntriesOptions {\n /** `/settings` or `/admin` — the hits link to `<basePath>/<group>?focus=<anchor>`. */\n basePath: string;\n}\n\n/**\n * The catalogue as {@link GlobalSearch} entries (§3.4): each visible setting, under its\n * group's name as the palette's section, linking to `/settings/<group>?focus=<anchor>` —\n * the same link the page's own search hit is, so ⌘K, a tour and a mail all land the\n * same way (§3.5). The group's name is a keyword too, as on the page: \"security\" lists\n * the security group's settings.\n *\n * Ids are prefixed with the base path (\"settings:theme\", \"admin:users\") so a palette\n * that also holds pages and actions keeps them unique.\n */\nexport function settingsSearchEntries<G extends string>(\n groups: readonly SettingsGroup<G>[],\n entries: readonly SettingsEntry<G>[],\n options: SettingsSearchEntriesOptions,\n): SearchEntry[] {\n const base = normalizeSettingsBase(options.basePath);\n const prefix = base.replace(/^\\//, \"\").replace(/\\//g, \":\") || \"settings\";\n const byId = new Map(visibleSettingsGroups(groups, entries).map((g) => [g.id, g]));\n return visibleSettingsEntries(groups, entries).map((e) => {\n const group = byId.get(e.group)!;\n return {\n id: `${prefix}:${e.id}`,\n title: e.title,\n keywords: [group.title, ...settingsKeywords(e.keywords)],\n group: group.title,\n icon: group.icon,\n href: settingsHref(base, e.group, e.anchor),\n };\n });\n}\n"],"mappings":";AA+EO,SAAS,sBACd,QACA,SACoB;AACpB,MAAI,CAAC,QAAS,QAAO,OAAO,OAAO,CAAC,MAAM,EAAE,YAAY,KAAK;AAC7D,QAAM,SAAS,oBAAI,IAAO;AAC1B,aAAW,KAAK,QAAS,KAAI,EAAE,YAAY,MAAO,QAAO,IAAI,EAAE,KAAK;AACpE,SAAO,OAAO,OAAO,CAAC,MAAM,EAAE,YAAY,UAAU,EAAE,eAAe,QAAQ,OAAO,IAAI,EAAE,EAAE,EAAE;AAChG;AAGO,SAAS,uBACd,QACA,SACoB;AACpB,QAAM,QAAQ,IAAI,IAAI,sBAAsB,QAAQ,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AAC7E,SAAO,QAAQ,OAAO,CAAC,MAAM,EAAE,YAAY,SAAS,MAAM,IAAI,EAAE,KAAK,CAAC;AACxE;AAGO,SAAS,sBAAsB,UAA0B;AAC9D,QAAM,UAAU,SAAS,QAAQ,QAAQ,EAAE;AAC3C,SAAO,QAAQ,WAAW,GAAG,KAAK,YAAY,KAAK,UAAU,IAAI,OAAO;AAC1E;AAGO,SAAS,aAAa,UAAkB,OAAe,QAAyB;AACrF,QAAM,OAAO,GAAG,sBAAsB,QAAQ,CAAC,IAAI,KAAK;AACxD,SAAO,SAAS,GAAG,IAAI,UAAU,mBAAmB,MAAM,CAAC,KAAK;AAClE;AAGO,SAAS,iBAAiB,UAAwC;AACvE,SAAO,WAAW,SAAS,MAAM,KAAK,EAAE,OAAO,OAAO,IAAI,CAAC;AAC7D;AAiBO,SAAS,sBACd,QACA,SACA,SACe;AACf,QAAM,OAAO,sBAAsB,QAAQ,QAAQ;AACnD,QAAM,SAAS,KAAK,QAAQ,OAAO,EAAE,EAAE,QAAQ,OAAO,GAAG,KAAK;AAC9D,QAAM,OAAO,IAAI,IAAI,sBAAsB,QAAQ,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACjF,SAAO,uBAAuB,QAAQ,OAAO,EAAE,IAAI,CAAC,MAAM;AACxD,UAAM,QAAQ,KAAK,IAAI,EAAE,KAAK;AAC9B,WAAO;AAAA,MACL,IAAI,GAAG,MAAM,IAAI,EAAE,EAAE;AAAA,MACrB,OAAO,EAAE;AAAA,MACT,UAAU,CAAC,MAAM,OAAO,GAAG,iBAAiB,EAAE,QAAQ,CAAC;AAAA,MACvD,OAAO,MAAM;AAAA,MACb,MAAM,MAAM;AAAA,MACZ,MAAM,aAAa,MAAM,EAAE,OAAO,EAAE,MAAM;AAAA,IAC5C;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -200,7 +200,13 @@ function SettingsLayout({
|
|
|
200
200
|
),
|
|
201
201
|
title: g.title,
|
|
202
202
|
subtitle: g.help,
|
|
203
|
-
trailing: /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true, className: "size-4 rtl:-scale-x-100" })
|
|
203
|
+
trailing: g.badge == null ? /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true, className: "size-4 rtl:-scale-x-100" }) : (
|
|
204
|
+
// The group's badge (0.48) before the chevron, the two as one end.
|
|
205
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
206
|
+
g.badge,
|
|
207
|
+
/* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true, className: "size-4 rtl:-scale-x-100" })
|
|
208
|
+
] })
|
|
209
|
+
)
|
|
204
210
|
},
|
|
205
211
|
g.id
|
|
206
212
|
)) }) }),
|
|
@@ -233,10 +239,11 @@ function SettingsLayout({
|
|
|
233
239
|
name: g.title,
|
|
234
240
|
label: /* @__PURE__ */ jsx("span", { className: cn(dim && "opacity-40"), children: g.title }),
|
|
235
241
|
icon: /* @__PURE__ */ jsx("span", { className: cn("inline-flex [&_svg]:size-4", dim && "opacity-40"), children: g.icon }),
|
|
236
|
-
|
|
242
|
+
// While searching, the hit count; otherwise the group's own badge (0.48).
|
|
243
|
+
badge: searching ? count > 0 ? /* @__PURE__ */ jsxs(Chip, { size: "sm", tone: "brand", children: [
|
|
237
244
|
/* @__PURE__ */ jsx("span", { "aria-hidden": true, children: count }),
|
|
238
245
|
/* @__PURE__ */ jsx("span", { className: "sr-only-fixed", children: labels.matchCount(count) })
|
|
239
|
-
] }) : void 0
|
|
246
|
+
] }) : void 0 : g.badge
|
|
240
247
|
};
|
|
241
248
|
}),
|
|
242
249
|
active: open?.id ?? route.groups[0]?.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/settings/settings-layout.tsx"],"sourcesContent":["import { useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport { Link, useHref, useLocation } from \"react-router\";\nimport { ChevronLeft, ChevronRight } from \"lucide-react\";\nimport { Button } from \"../components/button\";\nimport { Card } from \"../components/card\";\nimport { EmptyState } from \"../components/empty-state\";\nimport { Tabs } from \"../components/tabs\";\nimport { FOCUS_RING } from \"../components/focus-ring\";\nimport { Chip } from \"../components/chip\";\nimport { List, ListItem } from \"../components/list\";\nimport type { ListItemLinkProps } from \"../components/list\";\nimport { PageHeader } from \"../components/page-header\";\nimport { SearchField } from \"../components/search-field\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { createSearchIndex } from \"../search/search-index\";\nimport type { SearchEntry } from \"../search/search-index\";\nimport {\n normalizeSettingsBase,\n settingsHref,\n settingsKeywords,\n visibleSettingsEntries,\n} from \"./settings-catalogue\";\nimport type { SettingsEntry, SettingsGroup } from \"./settings-catalogue\";\nimport { SettingsLayoutContext } from \"./settings-context\";\nimport type { SettingsLayoutContextValue } from \"./settings-context\";\nimport { SettingsHeadingLevel } from \"./settings-heading\";\nimport { DEFAULT_SETTINGS_LABELS } from \"./settings-labels\";\nimport type { SettingsLabels } from \"./settings-labels\";\nimport { settingsFromListState, useSettingsRoute } from \"./use-settings-route\";\nimport type { SettingsLayoutMode } from \"./use-settings-route\";\nimport { useSettingsFocus } from \"./use-settings-focus\";\n\n/** The page's width cap (§3.2): `6xl` for settings, `7xl` for keksdose's admin, whose\n * user table scrolled sideways at 6xl (dev#488). */\nexport type SettingsLayoutWidth = \"6xl\" | \"7xl\";\n\n/** More entries than this and the search field shows by itself (§3.4): Kurvenschmiede has\n * about twelve, keksdose 26; a page of six needs none. */\nexport const SETTINGS_SEARCH_THRESHOLD = 8;\n\n/** The desktop sidebar's column: sticky beside a long group (§3.2). */\nconst SIDEBAR_COLUMN = \"mb-4 md:sticky md:top-6 md:mb-0 md:self-start\";\n\nexport interface SettingsLayoutProps<G extends string> {\n /** The page's `h1`: \"Settings\", \"Administration\". Default: `labels.title`. */\n title?: ReactNode;\n /** The groups, in order (§4.2). */\n groups: readonly SettingsGroup<G>[];\n /** One entry per setting (§4.1). Hidden entries leave search; a group left without a\n * visible one is hidden. */\n entries: readonly SettingsEntry<G>[];\n /** `/settings` or `/admin`. The layout owns every path below it. */\n basePath: string;\n /** The group `/settings` opens on a desktop. Default: the first visible one. */\n defaultGroup?: G;\n /** Retired group ids and their successors, replaced in the address (§3.1). */\n aliases?: Readonly<Partial<Record<string, G>>>;\n /**\n * The search field. Left out, it shows once more than {@link SETTINGS_SEARCH_THRESHOLD}\n * entries are visible; `true` or `false` wins over the count — keksdose's admin keeps\n * none (§3.4, §10.3). ⌘K gets the entries either way ({@link settingsSearchEntries}).\n */\n search?: boolean;\n /** See {@link SettingsLayoutWidth}. Default `\"6xl\"`. */\n width?: SettingsLayoutWidth;\n /** The group's cards, in one column. `sub` is the path segment after the group, which\n * a card owns (`useSettingsLayout().selectSub`). */\n renderGroup: (group: G, sub: string | null) => ReactNode;\n /**\n * Rows under the phone's group list that LEAVE settings — kastlan's \"Administration\",\n * its import page (§3.3, §5). `ListItem`s with an `href`; the layout puts them in a list\n * of their own, so they never read as a group. Not shown on a desktop, where the app's\n * own navigation carries them.\n */\n phoneFooter?: ReactNode;\n /**\n * 0.42.0 (docs/admin-harmonization.md §2.5 decision 16): content under the section\n * list on a desktop, in the same sticky column — the admin area's Tools list\n * (`AdminToolLinks`). Not shown on a phone, where `phoneFooter` carries the same links.\n */\n sidebarFooter?: ReactNode;\n /** Prop > `<UiKitProvider labels={{ settings }}>` > English. */\n labels?: LabelOverride<SettingsLabels>;\n /** See {@link SettingsLayoutMode}. Default `\"auto\"`: the screen decides. */\n layout?: SettingsLayoutMode;\n /**\n * The app's name, the last part of the window's title: \"Security · Settings ·\n * Kastlan\" (§3.1). Left out, the title ends at the page: \"Security · Settings\".\n */\n appName?: string;\n /**\n * The window's title (`document.title`, §3.1) — round 0.34 C8, KS U7. By default the\n * layout writes \"<group> · <page> · <appName>\" while a group is open and\n * \"<page> · <appName>\" on the phone's list, and puts back the title it found when it\n * unmounts. `<page>` is `title` when that is a string, else `labels.title`.\n *\n * A function writes another order or another separator from the same parts; `false`\n * leaves `document.title` to the app. Kastlan's `SettingsChrome` and Kurvenschmiede's\n * `GroupTitle` were this effect written by hand, and Kurvenschmiede's admin page, on\n * the same layout, had none — every admin section was titled \"Kurvenschmiede\".\n */\n documentTitle?: false | ((parts: SettingsDocumentTitleParts) => string);\n className?: string;\n}\n\n/** What {@link SettingsLayoutProps.documentTitle} is given to write the window's title. */\nexport interface SettingsDocumentTitleParts {\n /** The open group's name, or `null` on the phone's list of groups. */\n group: string | null;\n /** The page: `title` when it is a string, else `labels.title` (\"Settings\"). */\n page: string;\n /** The `appName` prop, or `undefined`. */\n appName: string | undefined;\n}\n\n/** \"Security · Settings · Kastlan\" (§3.1); a part that is missing is left out. */\nfunction defaultDocumentTitle({ group, page, appName }: SettingsDocumentTitleParts): string {\n return [group, page, appName].filter((part): part is string => Boolean(part)).join(\" · \");\n}\n\ninterface Searchable<G extends string> extends SearchEntry {\n anchor: string;\n settingsGroup: G;\n}\n\n/**\n * The settings page (docs/settings-harmonization.md §3), and the admin page built the\n * same way (§5). keksdose's page is the reference for the desktop; the phone pattern and\n * the path segments are new for all three apps.\n *\n * **Desktop** (§3.2): the page's `PageHeader`, the search field, then a 14rem sidebar —\n * the kit's vertical `Tabs`, a link per group, sticky so a long group keeps the list in\n * view — beside the open group: its heading (`h2`), its help line and its cards in ONE\n * column, never a masonry (keksdose dev#490/#493).\n *\n * **Phone** (§3.3, below `md`): a drill-down. `/settings` is a list of the groups (icon,\n * name, help line, chevron) with `phoneFooter` under it; a group is a page of its own with\n * a back link, its name as the `h1` and the cards under it. It replaces keksdose's chip\n * strip.\n *\n * **Routes, history and `?focus=`** are {@link useSettingsRoute}'s and\n * {@link useSettingsFocus}'s. **Search** (§3.4) runs the kit's matcher over the catalogue:\n * accents folded, ranked, over the title, the group's name and the keywords. On a desktop\n * the sidebar dims the groups without hits and counts the others' while the hits replace\n * the group; on a phone they replace the list. A hit is a link to its card.\n *\n * The cards inside read {@link useSettingsLayout} for `selectSub`, and their titles are\n * headings under the group's ({@link SettingsHeadingLevel}).\n */\nexport function SettingsLayout<G extends string>({\n title,\n groups,\n entries,\n basePath,\n defaultGroup,\n aliases,\n search,\n width = \"6xl\",\n renderGroup,\n phoneFooter,\n sidebarFooter,\n labels: labelsProp,\n layout = \"auto\",\n appName,\n documentTitle,\n className,\n}: SettingsLayoutProps<G>): ReactElement {\n const labels = useKitLabels(\"settings\", DEFAULT_SETTINGS_LABELS, labelsProp);\n const base = normalizeSettingsBase(basePath);\n const route = useSettingsRoute({ groups, entries, basePath: base, defaultGroup, aliases, layout });\n const location = useLocation();\n // The browser URL of an app path, for the sidebar's real links (a middle click opens a\n // tab): `#/settings/…` under a hash router, the basename in front under a browser one.\n const root = useHref(\"/\").replace(/\\/$/, \"\");\n const panelId = useId();\n const searchRef = useRef<HTMLInputElement>(null);\n const [query, setQuery] = useState(\"\");\n\n const visibleEntries = useMemo(() => visibleSettingsEntries(groups, entries), [groups, entries]);\n const showSearch = search ?? visibleEntries.length > SETTINGS_SEARCH_THRESHOLD;\n const trimmed = query.trim();\n const searching = showSearch && trimmed !== \"\";\n\n const groupById = useMemo(() => new Map(route.groups.map((g) => [g.id, g])), [route.groups]);\n const index = useMemo(\n () =>\n createSearchIndex<Searchable<G>>(\n visibleEntries.map((e) => ({\n id: e.id,\n title: e.title,\n keywords: [groupById.get(e.group)?.title ?? e.group, ...settingsKeywords(e.keywords)],\n group: e.group,\n anchor: e.anchor,\n settingsGroup: e.group,\n })),\n // Every hit: the list is the page's whole answer, not a palette's top few.\n { groupLimit: Infinity },\n ),\n [visibleEntries, groupById],\n );\n const hits = useMemo(() => (searching ? index.search(trimmed).map((h) => h.entry) : []), [searching, index, trimmed]);\n const hitsByGroup = useMemo(() => {\n const counts = new Map<G, number>();\n for (const hit of hits) counts.set(hit.settingsGroup, (counts.get(hit.settingsGroup) ?? 0) + 1);\n return counts;\n }, [hits]);\n\n const anchors = useMemo(() => new Set(entries.map((e) => e.anchor)), [entries]);\n const { phone, group, sub, selectSub, select } = route;\n const headingLevel = phone ? \"h2\" : \"h3\";\n const context = useMemo<SettingsLayoutContextValue>(\n () => ({\n basePath: base,\n group,\n sub,\n selectSub,\n headingLevel,\n hasAnchor: (anchor) => anchors.has(anchor),\n }),\n [base, group, sub, selectSub, headingLevel, anchors],\n );\n\n // Not while the address is about to be replaced (its removal of `focus` would undo the\n // replace), not on the list, and not while the hits stand where the cards would be (a\n // phone's group page has no search: a query left from its list does not count there).\n const hitsShown = searching && (!phone || group === null);\n useSettingsFocus(route.redirecting || group === null || hitsShown ? null : route.focus);\n\n // A link inside the page. On a phone it opens a page of its own — a push that marks the\n // list as the entry before it, so the group page's back is a real back. On a desktop\n // it switches the group in place — a replace.\n const { state } = location;\n const renderLink = useCallback(\n ({ href, ...props }: ListItemLinkProps) => (\n <Link to={href} replace={!phone} state={phone ? settingsFromListState() : state} {...props} />\n ),\n [phone, state],\n );\n\n const clearSearch = () => {\n setQuery(\"\");\n // The button that was pressed goes with the empty state; the field is where the\n // next query is typed.\n searchRef.current?.focus();\n };\n\n const pageTitle = title ?? labels.title;\n\n // The window's title (§3.1). Computed to a string during render so the effect below\n // runs when the words change, not whenever an inline `documentTitle` function is new.\n // Each run puts back the title it found before writing its own, so a group switch\n // ends where it began and the unmount leaves the title the page had before settings.\n const windowTitle =\n documentTitle === false\n ? null\n : (documentTitle ?? defaultDocumentTitle)({\n group: group === null ? null : (groupById.get(group)?.title ?? null),\n page: typeof title === \"string\" ? title : labels.title,\n appName,\n });\n useEffect(() => {\n if (windowTitle === null) return;\n const before = document.title;\n document.title = windowTitle;\n return () => {\n document.title = before;\n };\n }, [windowTitle]);\n\n const pageClass = cn(\"mx-auto w-full space-y-4 p-4 md:p-6\", width === \"7xl\" ? \"max-w-7xl\" : \"max-w-6xl\", className);\n\n const searchField = showSearch ? (\n <SearchField\n ref={searchRef}\n className=\"max-w-md\"\n value={query}\n onChange={setQuery}\n aria-label={labels.search}\n placeholder={labels.searchPlaceholder}\n />\n ) : null;\n\n const results =\n hits.length === 0 ? (\n <EmptyState\n title={labels.noMatches(trimmed)}\n action={\n <Button variant=\"secondary\" size=\"sm\" onClick={clearSearch}>\n {labels.clearSearch}\n </Button>\n }\n />\n ) : (\n <Card className=\"p-1\">\n <List separator=\"divider\" density=\"comfortable\" aria-label={labels.results}>\n {hits.map((hit) => (\n <ListItem\n key={hit.id}\n title={hit.title}\n trailing={groupById.get(hit.settingsGroup)?.title}\n href={settingsHref(base, hit.settingsGroup, hit.anchor)}\n renderLink={renderLink}\n // Leave search on the way: the hit's card is what the user asked for.\n onClick={() => setQuery(\"\")}\n />\n ))}\n </List>\n </Card>\n );\n\n const cards = (open: G) => (\n <SettingsHeadingLevel level={headingLevel}>\n <div className=\"space-y-4\">{renderGroup(open, sub)}</div>\n </SettingsHeadingLevel>\n );\n\n let body: ReactNode;\n if (phone) {\n const open = group === null ? undefined : groupById.get(group);\n body = open ? (\n <div className={pageClass} data-settings-view=\"group\">\n <PageHeader\n size=\"compact\"\n title={open.title}\n description={open.help}\n breadcrumbs={\n <Link\n to={base || \"/\"}\n aria-label={labels.back}\n onClick={(e) => {\n // A real link for a middle click; a plain click is the page's own back,\n // which is `navigate(-1)` when the list is the entry before this one.\n if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n e.preventDefault();\n route.back();\n }}\n className={cn(\"-ms-1 inline-flex items-center gap-0.5 self-start rounded-md pe-1 text-sm font-medium text-muted hover:text-primary\", FOCUS_RING)}\n >\n <ChevronLeft aria-hidden className=\"size-4 rtl:-scale-x-100\" />\n {pageTitle}\n </Link>\n }\n />\n {cards(open.id)}\n </div>\n ) : (\n <div className={pageClass} data-settings-view=\"list\">\n <PageHeader size=\"compact\" title={pageTitle} />\n {searchField}\n {searching ? (\n results\n ) : (\n <Card className=\"p-1\">\n <List separator=\"divider\" density=\"comfortable\" aria-label={labels.sections}>\n {route.groups.map((g) => (\n <ListItem\n key={g.id}\n href={settingsHref(base, g.id)}\n renderLink={renderLink}\n leading={\n <span\n aria-hidden\n className=\"flex size-8 shrink-0 items-center justify-center rounded-md bg-surface-2 text-secondary [&_svg]:size-4\"\n >\n {g.icon}\n </span>\n }\n title={g.title}\n subtitle={g.help}\n trailing={<ChevronRight aria-hidden className=\"size-4 rtl:-scale-x-100\" />}\n />\n ))}\n </List>\n </Card>\n )}\n {!searching && phoneFooter != null && (\n <Card className=\"p-1\">\n <List separator=\"divider\" density=\"comfortable\">\n {phoneFooter}\n </List>\n </Card>\n )}\n </div>\n );\n } else {\n const open = group === null ? undefined : groupById.get(group);\n // The section list alone, or (0.42) with the app's `sidebarFooter` under it in one\n // sticky column.\n const withSidebarFooter = (tabs: ReactNode) =>\n sidebarFooter == null ? (\n tabs\n ) : (\n <div className={cn(SIDEBAR_COLUMN, \"space-y-6\")}>\n {tabs}\n <div data-slot=\"settings-sidebar-footer\">{sidebarFooter}</div>\n </div>\n );\n body = (\n <div className={pageClass} data-settings-view=\"desktop\">\n <PageHeader size=\"compact\" title={pageTitle} />\n {searchField}\n <div className=\"md:grid md:grid-cols-[14rem_minmax(0,1fr)] md:gap-6\">\n {withSidebarFooter(\n <Tabs<G>\n orientation=\"vertical\"\n aria-label={labels.sections}\n // Sticky (new in the harmonisation, §3.2): keksdose's notifications group\n // scrolls for screens, and the list should stay in view beside it. With a\n // `sidebarFooter` the column round both is the sticky one.\n className={sidebarFooter == null ? SIDEBAR_COLUMN : undefined}\n panelId={open && !searching ? panelId : undefined}\n tabs={route.groups.map((g) => {\n const count = hitsByGroup.get(g.id) ?? 0;\n // While searching, the groups with nothing to show step back (keksdose).\n const dim = searching && count === 0;\n return {\n id: g.id,\n href: `${root}${settingsHref(base, g.id)}`,\n name: g.title,\n label: <span className={cn(dim && \"opacity-40\")}>{g.title}</span>,\n icon: <span className={cn(\"inline-flex [&_svg]:size-4\", dim && \"opacity-40\")}>{g.icon}</span>,\n badge:\n searching && count > 0 ? (\n <Chip size=\"sm\" tone=\"brand\">\n <span aria-hidden>{count}</span>\n <span className=\"sr-only-fixed\">{labels.matchCount(count)}</span>\n </Chip>\n ) : undefined,\n };\n })}\n active={(open?.id ?? route.groups[0]?.id) as G}\n onChange={(id) => {\n // While searching the hits stand where the group would; a click on a group\n // means \"go there\", so the search makes way (keksdose).\n setQuery(\"\");\n select(id);\n }}\n />,\n )}\n <div className=\"min-w-0 space-y-4\">\n {searching ? (\n results\n ) : open ? (\n <div\n id={panelId}\n role=\"tabpanel\"\n aria-labelledby={`${panelId}-tab`}\n className=\"space-y-4\"\n >\n <PageHeader as=\"h2\" size=\"sm\" title={open.title} description={open.help} />\n {cards(open.id)}\n </div>\n ) : null}\n </div>\n </div>\n </div>\n );\n }\n\n return <SettingsLayoutContext.Provider value={context}>{body}</SettingsLayoutContext.Provider>;\n}\n"],"mappings":";AA4OM,cA4FM,YA5FN;AA5ON,SAAS,aAAa,WAAW,OAAO,SAAS,QAAQ,gBAAgB;AAEzE,SAAS,MAAM,SAAS,mBAAmB;AAC3C,SAAS,aAAa,oBAAoB;AAC1C,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,MAAM,gBAAgB;AAE/B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,oBAAwC;AACjD,SAAS,yBAAyB;AAElC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,6BAA6B;AAEtC,SAAS,4BAA4B;AACrC,SAAS,+BAA+B;AAExC,SAAS,uBAAuB,wBAAwB;AAExD,SAAS,wBAAwB;AAQ1B,MAAM,4BAA4B;AAGzC,MAAM,iBAAiB;AA2EvB,SAAS,qBAAqB,EAAE,OAAO,MAAM,QAAQ,GAAuC;AAC1F,SAAO,CAAC,OAAO,MAAM,OAAO,EAAE,OAAO,CAAC,SAAyB,QAAQ,IAAI,CAAC,EAAE,KAAK,QAAK;AAC1F;AA+BO,SAAS,eAAiC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AACF,GAA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C,GAAG;AAAA,cACtC,UAAU,CAAC,OAAO;AAGhB,yBAAS,EAAE;AACX,uBAAO,EAAE;AAAA,cACX;AAAA;AAAA,UACF;AAAA,QACF;AAAA,QACA,oBAAC,SAAI,WAAU,qBACZ,sBACC,UACE,OACF;AAAA,UAAC;AAAA;AAAA,YACC,IAAI;AAAA,YACJ,MAAK;AAAA,YACL,mBAAiB,GAAG,OAAO;AAAA,YAC3B,WAAU;AAAA,YAEV;AAAA,kCAAC,cAAW,IAAG,MAAK,MAAK,MAAK,OAAO,KAAK,OAAO,aAAa,KAAK,MAAM;AAAA,cACxE,MAAM,KAAK,EAAE;AAAA;AAAA;AAAA,QAChB,IACE,MACN;AAAA,SACF;AAAA,OACF;AAAA,EAEJ;AAEA,SAAO,oBAAC,sBAAsB,UAAtB,EAA+B,OAAO,SAAU,gBAAK;AAC/D;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/settings/settings-layout.tsx"],"sourcesContent":["import { useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport { Link, useHref, useLocation } from \"react-router\";\nimport { ChevronLeft, ChevronRight } from \"lucide-react\";\nimport { Button } from \"../components/button\";\nimport { Card } from \"../components/card\";\nimport { EmptyState } from \"../components/empty-state\";\nimport { Tabs } from \"../components/tabs\";\nimport { FOCUS_RING } from \"../components/focus-ring\";\nimport { Chip } from \"../components/chip\";\nimport { List, ListItem } from \"../components/list\";\nimport type { ListItemLinkProps } from \"../components/list\";\nimport { PageHeader } from \"../components/page-header\";\nimport { SearchField } from \"../components/search-field\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { createSearchIndex } from \"../search/search-index\";\nimport type { SearchEntry } from \"../search/search-index\";\nimport {\n normalizeSettingsBase,\n settingsHref,\n settingsKeywords,\n visibleSettingsEntries,\n} from \"./settings-catalogue\";\nimport type { SettingsEntry, SettingsGroup } from \"./settings-catalogue\";\nimport { SettingsLayoutContext } from \"./settings-context\";\nimport type { SettingsLayoutContextValue } from \"./settings-context\";\nimport { SettingsHeadingLevel } from \"./settings-heading\";\nimport { DEFAULT_SETTINGS_LABELS } from \"./settings-labels\";\nimport type { SettingsLabels } from \"./settings-labels\";\nimport { settingsFromListState, useSettingsRoute } from \"./use-settings-route\";\nimport type { SettingsLayoutMode } from \"./use-settings-route\";\nimport { useSettingsFocus } from \"./use-settings-focus\";\n\n/** The page's width cap (§3.2): `6xl` for settings, `7xl` for keksdose's admin, whose\n * user table scrolled sideways at 6xl (dev#488). */\nexport type SettingsLayoutWidth = \"6xl\" | \"7xl\";\n\n/** More entries than this and the search field shows by itself (§3.4): Kurvenschmiede has\n * about twelve, keksdose 26; a page of six needs none. */\nexport const SETTINGS_SEARCH_THRESHOLD = 8;\n\n/** The desktop sidebar's column: sticky beside a long group (§3.2). */\nconst SIDEBAR_COLUMN = \"mb-4 md:sticky md:top-6 md:mb-0 md:self-start\";\n\nexport interface SettingsLayoutProps<G extends string> {\n /** The page's `h1`: \"Settings\", \"Administration\". Default: `labels.title`. */\n title?: ReactNode;\n /** The groups, in order (§4.2). */\n groups: readonly SettingsGroup<G>[];\n /** One entry per setting (§4.1). Hidden entries leave search; a group left without a\n * visible one is hidden. */\n entries: readonly SettingsEntry<G>[];\n /** `/settings` or `/admin`. The layout owns every path below it. */\n basePath: string;\n /** The group `/settings` opens on a desktop. Default: the first visible one. */\n defaultGroup?: G;\n /** Retired group ids and their successors, replaced in the address (§3.1). */\n aliases?: Readonly<Partial<Record<string, G>>>;\n /**\n * The search field. Left out, it shows once more than {@link SETTINGS_SEARCH_THRESHOLD}\n * entries are visible; `true` or `false` wins over the count — keksdose's admin keeps\n * none (§3.4, §10.3). ⌘K gets the entries either way ({@link settingsSearchEntries}).\n */\n search?: boolean;\n /** See {@link SettingsLayoutWidth}. Default `\"6xl\"`. */\n width?: SettingsLayoutWidth;\n /** The group's cards, in one column. `sub` is the path segment after the group, which\n * a card owns (`useSettingsLayout().selectSub`). */\n renderGroup: (group: G, sub: string | null) => ReactNode;\n /**\n * Rows under the phone's group list that LEAVE settings — kastlan's \"Administration\",\n * its import page (§3.3, §5). `ListItem`s with an `href`; the layout puts them in a list\n * of their own, so they never read as a group. Not shown on a desktop, where the app's\n * own navigation carries them.\n */\n phoneFooter?: ReactNode;\n /**\n * 0.42.0 (docs/admin-harmonization.md §2.5 decision 16): content under the section\n * list on a desktop, in the same sticky column — the admin area's Tools list\n * (`AdminToolLinks`). Not shown on a phone, where `phoneFooter` carries the same links.\n */\n sidebarFooter?: ReactNode;\n /** Prop > `<UiKitProvider labels={{ settings }}>` > English. */\n labels?: LabelOverride<SettingsLabels>;\n /** See {@link SettingsLayoutMode}. Default `\"auto\"`: the screen decides. */\n layout?: SettingsLayoutMode;\n /**\n * The app's name, the last part of the window's title: \"Security · Settings ·\n * Kastlan\" (§3.1). Left out, the title ends at the page: \"Security · Settings\".\n */\n appName?: string;\n /**\n * The window's title (`document.title`, §3.1) — round 0.34 C8, KS U7. By default the\n * layout writes \"<group> · <page> · <appName>\" while a group is open and\n * \"<page> · <appName>\" on the phone's list, and puts back the title it found when it\n * unmounts. `<page>` is `title` when that is a string, else `labels.title`.\n *\n * A function writes another order or another separator from the same parts; `false`\n * leaves `document.title` to the app. Kastlan's `SettingsChrome` and Kurvenschmiede's\n * `GroupTitle` were this effect written by hand, and Kurvenschmiede's admin page, on\n * the same layout, had none — every admin section was titled \"Kurvenschmiede\".\n */\n documentTitle?: false | ((parts: SettingsDocumentTitleParts) => string);\n className?: string;\n}\n\n/** What {@link SettingsLayoutProps.documentTitle} is given to write the window's title. */\nexport interface SettingsDocumentTitleParts {\n /** The open group's name, or `null` on the phone's list of groups. */\n group: string | null;\n /** The page: `title` when it is a string, else `labels.title` (\"Settings\"). */\n page: string;\n /** The `appName` prop, or `undefined`. */\n appName: string | undefined;\n}\n\n/** \"Security · Settings · Kastlan\" (§3.1); a part that is missing is left out. */\nfunction defaultDocumentTitle({ group, page, appName }: SettingsDocumentTitleParts): string {\n return [group, page, appName].filter((part): part is string => Boolean(part)).join(\" · \");\n}\n\ninterface Searchable<G extends string> extends SearchEntry {\n anchor: string;\n settingsGroup: G;\n}\n\n/**\n * The settings page (docs/settings-harmonization.md §3), and the admin page built the\n * same way (§5). keksdose's page is the reference for the desktop; the phone pattern and\n * the path segments are new for all three apps.\n *\n * **Desktop** (§3.2): the page's `PageHeader`, the search field, then a 14rem sidebar —\n * the kit's vertical `Tabs`, a link per group, sticky so a long group keeps the list in\n * view — beside the open group: its heading (`h2`), its help line and its cards in ONE\n * column, never a masonry (keksdose dev#490/#493).\n *\n * **Phone** (§3.3, below `md`): a drill-down. `/settings` is a list of the groups (icon,\n * name, help line, chevron) with `phoneFooter` under it; a group is a page of its own with\n * a back link, its name as the `h1` and the cards under it. It replaces keksdose's chip\n * strip.\n *\n * **Routes, history and `?focus=`** are {@link useSettingsRoute}'s and\n * {@link useSettingsFocus}'s. **Search** (§3.4) runs the kit's matcher over the catalogue:\n * accents folded, ranked, over the title, the group's name and the keywords. On a desktop\n * the sidebar dims the groups without hits and counts the others' while the hits replace\n * the group; on a phone they replace the list. A hit is a link to its card.\n *\n * The cards inside read {@link useSettingsLayout} for `selectSub`, and their titles are\n * headings under the group's ({@link SettingsHeadingLevel}).\n */\nexport function SettingsLayout<G extends string>({\n title,\n groups,\n entries,\n basePath,\n defaultGroup,\n aliases,\n search,\n width = \"6xl\",\n renderGroup,\n phoneFooter,\n sidebarFooter,\n labels: labelsProp,\n layout = \"auto\",\n appName,\n documentTitle,\n className,\n}: SettingsLayoutProps<G>): ReactElement {\n const labels = useKitLabels(\"settings\", DEFAULT_SETTINGS_LABELS, labelsProp);\n const base = normalizeSettingsBase(basePath);\n const route = useSettingsRoute({ groups, entries, basePath: base, defaultGroup, aliases, layout });\n const location = useLocation();\n // The browser URL of an app path, for the sidebar's real links (a middle click opens a\n // tab): `#/settings/…` under a hash router, the basename in front under a browser one.\n const root = useHref(\"/\").replace(/\\/$/, \"\");\n const panelId = useId();\n const searchRef = useRef<HTMLInputElement>(null);\n const [query, setQuery] = useState(\"\");\n\n const visibleEntries = useMemo(() => visibleSettingsEntries(groups, entries), [groups, entries]);\n const showSearch = search ?? visibleEntries.length > SETTINGS_SEARCH_THRESHOLD;\n const trimmed = query.trim();\n const searching = showSearch && trimmed !== \"\";\n\n const groupById = useMemo(() => new Map(route.groups.map((g) => [g.id, g])), [route.groups]);\n const index = useMemo(\n () =>\n createSearchIndex<Searchable<G>>(\n visibleEntries.map((e) => ({\n id: e.id,\n title: e.title,\n keywords: [groupById.get(e.group)?.title ?? e.group, ...settingsKeywords(e.keywords)],\n group: e.group,\n anchor: e.anchor,\n settingsGroup: e.group,\n })),\n // Every hit: the list is the page's whole answer, not a palette's top few.\n { groupLimit: Infinity },\n ),\n [visibleEntries, groupById],\n );\n const hits = useMemo(() => (searching ? index.search(trimmed).map((h) => h.entry) : []), [searching, index, trimmed]);\n const hitsByGroup = useMemo(() => {\n const counts = new Map<G, number>();\n for (const hit of hits) counts.set(hit.settingsGroup, (counts.get(hit.settingsGroup) ?? 0) + 1);\n return counts;\n }, [hits]);\n\n const anchors = useMemo(() => new Set(entries.map((e) => e.anchor)), [entries]);\n const { phone, group, sub, selectSub, select } = route;\n const headingLevel = phone ? \"h2\" : \"h3\";\n const context = useMemo<SettingsLayoutContextValue>(\n () => ({\n basePath: base,\n group,\n sub,\n selectSub,\n headingLevel,\n hasAnchor: (anchor) => anchors.has(anchor),\n }),\n [base, group, sub, selectSub, headingLevel, anchors],\n );\n\n // Not while the address is about to be replaced (its removal of `focus` would undo the\n // replace), not on the list, and not while the hits stand where the cards would be (a\n // phone's group page has no search: a query left from its list does not count there).\n const hitsShown = searching && (!phone || group === null);\n useSettingsFocus(route.redirecting || group === null || hitsShown ? null : route.focus);\n\n // A link inside the page. On a phone it opens a page of its own — a push that marks the\n // list as the entry before it, so the group page's back is a real back. On a desktop\n // it switches the group in place — a replace.\n const { state } = location;\n const renderLink = useCallback(\n ({ href, ...props }: ListItemLinkProps) => (\n <Link to={href} replace={!phone} state={phone ? settingsFromListState() : state} {...props} />\n ),\n [phone, state],\n );\n\n const clearSearch = () => {\n setQuery(\"\");\n // The button that was pressed goes with the empty state; the field is where the\n // next query is typed.\n searchRef.current?.focus();\n };\n\n const pageTitle = title ?? labels.title;\n\n // The window's title (§3.1). Computed to a string during render so the effect below\n // runs when the words change, not whenever an inline `documentTitle` function is new.\n // Each run puts back the title it found before writing its own, so a group switch\n // ends where it began and the unmount leaves the title the page had before settings.\n const windowTitle =\n documentTitle === false\n ? null\n : (documentTitle ?? defaultDocumentTitle)({\n group: group === null ? null : (groupById.get(group)?.title ?? null),\n page: typeof title === \"string\" ? title : labels.title,\n appName,\n });\n useEffect(() => {\n if (windowTitle === null) return;\n const before = document.title;\n document.title = windowTitle;\n return () => {\n document.title = before;\n };\n }, [windowTitle]);\n\n const pageClass = cn(\"mx-auto w-full space-y-4 p-4 md:p-6\", width === \"7xl\" ? \"max-w-7xl\" : \"max-w-6xl\", className);\n\n const searchField = showSearch ? (\n <SearchField\n ref={searchRef}\n className=\"max-w-md\"\n value={query}\n onChange={setQuery}\n aria-label={labels.search}\n placeholder={labels.searchPlaceholder}\n />\n ) : null;\n\n const results =\n hits.length === 0 ? (\n <EmptyState\n title={labels.noMatches(trimmed)}\n action={\n <Button variant=\"secondary\" size=\"sm\" onClick={clearSearch}>\n {labels.clearSearch}\n </Button>\n }\n />\n ) : (\n <Card className=\"p-1\">\n <List separator=\"divider\" density=\"comfortable\" aria-label={labels.results}>\n {hits.map((hit) => (\n <ListItem\n key={hit.id}\n title={hit.title}\n trailing={groupById.get(hit.settingsGroup)?.title}\n href={settingsHref(base, hit.settingsGroup, hit.anchor)}\n renderLink={renderLink}\n // Leave search on the way: the hit's card is what the user asked for.\n onClick={() => setQuery(\"\")}\n />\n ))}\n </List>\n </Card>\n );\n\n const cards = (open: G) => (\n <SettingsHeadingLevel level={headingLevel}>\n <div className=\"space-y-4\">{renderGroup(open, sub)}</div>\n </SettingsHeadingLevel>\n );\n\n let body: ReactNode;\n if (phone) {\n const open = group === null ? undefined : groupById.get(group);\n body = open ? (\n <div className={pageClass} data-settings-view=\"group\">\n <PageHeader\n size=\"compact\"\n title={open.title}\n description={open.help}\n breadcrumbs={\n <Link\n to={base || \"/\"}\n aria-label={labels.back}\n onClick={(e) => {\n // A real link for a middle click; a plain click is the page's own back,\n // which is `navigate(-1)` when the list is the entry before this one.\n if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n e.preventDefault();\n route.back();\n }}\n className={cn(\"-ms-1 inline-flex items-center gap-0.5 self-start rounded-md pe-1 text-sm font-medium text-muted hover:text-primary\", FOCUS_RING)}\n >\n <ChevronLeft aria-hidden className=\"size-4 rtl:-scale-x-100\" />\n {pageTitle}\n </Link>\n }\n />\n {cards(open.id)}\n </div>\n ) : (\n <div className={pageClass} data-settings-view=\"list\">\n <PageHeader size=\"compact\" title={pageTitle} />\n {searchField}\n {searching ? (\n results\n ) : (\n <Card className=\"p-1\">\n <List separator=\"divider\" density=\"comfortable\" aria-label={labels.sections}>\n {route.groups.map((g) => (\n <ListItem\n key={g.id}\n href={settingsHref(base, g.id)}\n renderLink={renderLink}\n leading={\n <span\n aria-hidden\n className=\"flex size-8 shrink-0 items-center justify-center rounded-md bg-surface-2 text-secondary [&_svg]:size-4\"\n >\n {g.icon}\n </span>\n }\n title={g.title}\n subtitle={g.help}\n trailing={\n g.badge == null ? (\n <ChevronRight aria-hidden className=\"size-4 rtl:-scale-x-100\" />\n ) : (\n // The group's badge (0.48) before the chevron, the two as one end.\n <span className=\"flex items-center gap-2\">\n {g.badge}\n <ChevronRight aria-hidden className=\"size-4 rtl:-scale-x-100\" />\n </span>\n )\n }\n />\n ))}\n </List>\n </Card>\n )}\n {!searching && phoneFooter != null && (\n <Card className=\"p-1\">\n <List separator=\"divider\" density=\"comfortable\">\n {phoneFooter}\n </List>\n </Card>\n )}\n </div>\n );\n } else {\n const open = group === null ? undefined : groupById.get(group);\n // The section list alone, or (0.42) with the app's `sidebarFooter` under it in one\n // sticky column.\n const withSidebarFooter = (tabs: ReactNode) =>\n sidebarFooter == null ? (\n tabs\n ) : (\n <div className={cn(SIDEBAR_COLUMN, \"space-y-6\")}>\n {tabs}\n <div data-slot=\"settings-sidebar-footer\">{sidebarFooter}</div>\n </div>\n );\n body = (\n <div className={pageClass} data-settings-view=\"desktop\">\n <PageHeader size=\"compact\" title={pageTitle} />\n {searchField}\n <div className=\"md:grid md:grid-cols-[14rem_minmax(0,1fr)] md:gap-6\">\n {withSidebarFooter(\n <Tabs<G>\n orientation=\"vertical\"\n aria-label={labels.sections}\n // Sticky (new in the harmonisation, §3.2): keksdose's notifications group\n // scrolls for screens, and the list should stay in view beside it. With a\n // `sidebarFooter` the column round both is the sticky one.\n className={sidebarFooter == null ? SIDEBAR_COLUMN : undefined}\n panelId={open && !searching ? panelId : undefined}\n tabs={route.groups.map((g) => {\n const count = hitsByGroup.get(g.id) ?? 0;\n // While searching, the groups with nothing to show step back (keksdose).\n const dim = searching && count === 0;\n return {\n id: g.id,\n href: `${root}${settingsHref(base, g.id)}`,\n name: g.title,\n label: <span className={cn(dim && \"opacity-40\")}>{g.title}</span>,\n icon: <span className={cn(\"inline-flex [&_svg]:size-4\", dim && \"opacity-40\")}>{g.icon}</span>,\n // While searching, the hit count; otherwise the group's own badge (0.48).\n badge: searching ? (\n count > 0 ? (\n <Chip size=\"sm\" tone=\"brand\">\n <span aria-hidden>{count}</span>\n <span className=\"sr-only-fixed\">{labels.matchCount(count)}</span>\n </Chip>\n ) : undefined\n ) : (\n g.badge\n ),\n };\n })}\n active={(open?.id ?? route.groups[0]?.id) as G}\n onChange={(id) => {\n // While searching the hits stand where the group would; a click on a group\n // means \"go there\", so the search makes way (keksdose).\n setQuery(\"\");\n select(id);\n }}\n />,\n )}\n <div className=\"min-w-0 space-y-4\">\n {searching ? (\n results\n ) : open ? (\n <div\n id={panelId}\n role=\"tabpanel\"\n aria-labelledby={`${panelId}-tab`}\n className=\"space-y-4\"\n >\n <PageHeader as=\"h2\" size=\"sm\" title={open.title} description={open.help} />\n {cards(open.id)}\n </div>\n ) : null}\n </div>\n </div>\n </div>\n );\n }\n\n return <SettingsLayoutContext.Provider value={context}>{body}</SettingsLayoutContext.Provider>;\n}\n"],"mappings":";AA4OM,cA4FM,YA5FN;AA5ON,SAAS,aAAa,WAAW,OAAO,SAAS,QAAQ,gBAAgB;AAEzE,SAAS,MAAM,SAAS,mBAAmB;AAC3C,SAAS,aAAa,oBAAoB;AAC1C,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,MAAM,gBAAgB;AAE/B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,oBAAwC;AACjD,SAAS,yBAAyB;AAElC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,6BAA6B;AAEtC,SAAS,4BAA4B;AACrC,SAAS,+BAA+B;AAExC,SAAS,uBAAuB,wBAAwB;AAExD,SAAS,wBAAwB;AAQ1B,MAAM,4BAA4B;AAGzC,MAAM,iBAAiB;AA2EvB,SAAS,qBAAqB,EAAE,OAAO,MAAM,QAAQ,GAAuC;AAC1F,SAAO,CAAC,OAAO,MAAM,OAAO,EAAE,OAAO,CAAC,SAAyB,QAAQ,IAAI,CAAC,EAAE,KAAK,QAAK;AAC1F;AA+BO,SAAS,eAAiC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AACF,GAAyC;AACvC,QAAM,SAAS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U,iBAAiB,iBAAO,WAAW,KAAK,GAAE;AAAA,qBAC5D,IACE,SAEJ,EAAE;AAAA,gBAEN;AAAA,cACF,CAAC;AAAA,cACD,QAAS,MAAM,MAAM,MAAM,OAAO,CAAC,GAAG;AAAA,cACtC,UAAU,CAAC,OAAO;AAGhB,yBAAS,EAAE;AACX,uBAAO,EAAE;AAAA,cACX;AAAA;AAAA,UACF;AAAA,QACF;AAAA,QACA,oBAAC,SAAI,WAAU,qBACZ,sBACC,UACE,OACF;AAAA,UAAC;AAAA;AAAA,YACC,IAAI;AAAA,YACJ,MAAK;AAAA,YACL,mBAAiB,GAAG,OAAO;AAAA,YAC3B,WAAU;AAAA,YAEV;AAAA,kCAAC,cAAW,IAAG,MAAK,MAAK,MAAK,OAAO,KAAK,OAAO,aAAa,KAAK,MAAM;AAAA,cACxE,MAAM,KAAK,EAAE;AAAA;AAAA;AAAA,QAChB,IACE,MACN;AAAA,SACF;AAAA,OACF;AAAA,EAEJ;AAEA,SAAO,oBAAC,sBAAsB,UAAtB,EAA+B,OAAO,SAAU,gBAAK;AAC/D;","names":[]}
|
|
@@ -23,6 +23,11 @@ export interface AppShellNavItem {
|
|
|
23
23
|
* shortening the real label, which the sidebar has ample room for and which is the
|
|
24
24
|
* name the rest of the product uses. */
|
|
25
25
|
shortLabel?: string;
|
|
26
|
+
/** 0.48: the text size from which the bar uses {@link shortLabel} — `"large"` keeps the
|
|
27
|
+
* full label at Normal, where five cells hold "Transactions" whole, and shortens it
|
|
28
|
+
* from Large up (keksdose dev#613, which read `useTextSize()` in its layout to decide).
|
|
29
|
+
* Default `"normal"`: the short label at every size, as before. */
|
|
30
|
+
shortLabelFrom?: TextSize;
|
|
26
31
|
/** 0.31.0: leave this entry out of the MOBILE BOTTOM BAR; the sidebar keeps it.
|
|
27
32
|
* For an entry a phone reaches another way — the brand link to the start page —
|
|
28
33
|
* when one cell fewer is what keeps the others' labels whole (the bar divides its
|
package/dist/shell/app-shell.js
CHANGED
|
@@ -18,7 +18,7 @@ import { useAnchoredRect } from "../hooks/use-anchored-rect.js";
|
|
|
18
18
|
import { anchoredInline } from "../hooks/use-anchored-panel.js";
|
|
19
19
|
import { useDismissLayer } from "../hooks/use-dismiss.js";
|
|
20
20
|
import { useBreakpoint } from "../hooks/use-breakpoint.js";
|
|
21
|
-
import { useTextSize } from "../theme/text-size.js";
|
|
21
|
+
import { TEXT_SIZES, useTextSize } from "../theme/text-size.js";
|
|
22
22
|
import { DEFAULT_APP_SHELL_LABELS, useKitLabels, useKitLink } from "../i18n/kit-labels.js";
|
|
23
23
|
import { DEFAULT_APP_SHELL_MORE_LABELS } from "./app-shell-labels.js";
|
|
24
24
|
const DEFAULT_MOBILE_BAR_MAX = {
|
|
@@ -186,7 +186,7 @@ function AppShell({
|
|
|
186
186
|
"main",
|
|
187
187
|
{
|
|
188
188
|
className: cn(
|
|
189
|
-
"relative flex-1 max-w-full overflow-x-clip pb-[calc(var(--app-nav-h,4rem)+1.5rem)] md:pb-0 md:min-h-0 md:overflow-y-auto md:[scrollbar-gutter:stable_both-edges]",
|
|
189
|
+
"relative flex-1 max-w-full overflow-x-clip pb-[calc(var(--app-nav-h,4rem)+max(1.5rem,var(--app-float-clearance,0px)))] md:pb-0 md:min-h-0 md:overflow-y-auto md:[scrollbar-gutter:stable_both-edges]",
|
|
190
190
|
// The list page's fill (0.40, docs/page-layout-harmonization.md §1.3): while
|
|
191
191
|
// a `fillHeight` DataTable is inside, a flex column — a banner above the
|
|
192
192
|
// page keeps its own height and the page (a `FillHeight`) takes the rest,
|
|
@@ -320,6 +320,8 @@ function MobileCellLabel({ children }) {
|
|
|
320
320
|
}
|
|
321
321
|
function MobileNavItem({ item }) {
|
|
322
322
|
const subActive = useSubItemActive(item);
|
|
323
|
+
const { size } = useTextSize();
|
|
324
|
+
const short = item.shortLabel !== void 0 && TEXT_SIZES.indexOf(size) >= TEXT_SIZES.indexOf(item.shortLabelFrom ?? "normal") ? item.shortLabel : void 0;
|
|
323
325
|
return /* @__PURE__ */ jsxs(
|
|
324
326
|
NavLink,
|
|
325
327
|
{
|
|
@@ -329,7 +331,7 @@ function MobileNavItem({ item }) {
|
|
|
329
331
|
className: ({ isActive }) => mobileCellClass(isActive || subActive),
|
|
330
332
|
children: [
|
|
331
333
|
/* @__PURE__ */ jsx("span", { className: "relative", children: /* @__PURE__ */ jsx(item.icon, { className: "size-5" }) }),
|
|
332
|
-
/* @__PURE__ */ jsx(MobileCellLabel, { children:
|
|
334
|
+
/* @__PURE__ */ jsx(MobileCellLabel, { children: short ?? item.label })
|
|
333
335
|
]
|
|
334
336
|
}
|
|
335
337
|
);
|