@eifi1/ui-kit 0.10.0 → 0.12.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 +66 -37
- package/dist/chart.d.ts +3 -1
- package/dist/chart.js +2 -0
- package/dist/chart.js.map +1 -1
- package/dist/components/account-settings-labels.d.ts +105 -0
- package/dist/components/account-settings-labels.js +81 -0
- package/dist/components/account-settings-labels.js.map +1 -0
- package/dist/components/account-settings.d.ts +36 -52
- package/dist/components/account-settings.js +44 -8
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/alert-banner.d.ts +26 -1
- package/dist/components/alert-banner.js +10 -7
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +26 -4
- package/dist/components/amount-input.js +5 -2
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/authed-image.d.ts +68 -0
- package/dist/components/authed-image.js +117 -0
- package/dist/components/authed-image.js.map +1 -0
- package/dist/components/breadcrumbs.d.ts +2 -1
- package/dist/components/breadcrumbs.js +5 -2
- package/dist/components/breadcrumbs.js.map +1 -1
- package/dist/components/bulk-action-bar.d.ts +51 -5
- package/dist/components/bulk-action-bar.js +88 -41
- package/dist/components/bulk-action-bar.js.map +1 -1
- package/dist/components/button-group.d.ts +107 -3
- package/dist/components/button-group.js +60 -5
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/calculator.d.ts +17 -4
- package/dist/components/calendar-heatmap.d.ts +162 -0
- package/dist/components/calendar-heatmap.js +336 -0
- package/dist/components/calendar-heatmap.js.map +1 -0
- package/dist/components/chip.d.ts +2 -1
- package/dist/components/chip.js +6 -3
- package/dist/components/chip.js.map +1 -1
- package/dist/components/choice-card.d.ts +66 -2
- package/dist/components/choice-card.js +108 -1
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/combobox-core.js +2 -0
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +2 -2
- package/dist/components/combobox.js +31 -9
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/copy-button.d.ts +52 -70
- package/dist/components/copy-button.js +1 -1
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/data-table-cells.d.ts +63 -0
- package/dist/components/data-table-cells.js +64 -0
- package/dist/components/data-table-cells.js.map +1 -0
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filters.d.ts +1 -1
- package/dist/components/data-table-filters.js +31 -1
- package/dist/components/data-table-filters.js.map +1 -1
- package/dist/components/data-table-labels.d.ts +13 -0
- package/dist/components/data-table-labels.js +8 -1
- package/dist/components/data-table-labels.js.map +1 -1
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/data-table.js +104 -12
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +3 -1
- package/dist/components/date-picker.js +15 -2
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/description-list.d.ts +23 -3
- package/dist/components/description-list.js +23 -3
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +1 -0
- package/dist/components/entity-combobox.d.ts +1 -1
- package/dist/components/entity-combobox.js +18 -3
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/error-boundary.d.ts +92 -0
- package/dist/components/error-boundary.js +111 -0
- package/dist/components/error-boundary.js.map +1 -0
- package/dist/components/field.d.ts +69 -0
- package/dist/components/field.js +75 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/file-button.d.ts +51 -208
- package/dist/components/file-dropzone.d.ts +50 -2
- package/dist/components/floating-panel.d.ts +156 -4
- package/dist/components/floating-panel.js +193 -29
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/form-actions.d.ts +53 -0
- package/dist/components/form-actions.js +98 -0
- package/dist/components/form-actions.js.map +1 -0
- package/dist/components/image-grid.d.ts +67 -0
- package/dist/components/image-grid.js +112 -0
- package/dist/components/image-grid.js.map +1 -0
- package/dist/components/lightbox.d.ts +104 -0
- package/dist/components/lightbox.js +229 -0
- package/dist/components/lightbox.js.map +1 -0
- package/dist/components/line-items.d.ts +114 -0
- package/dist/components/line-items.js +238 -0
- package/dist/components/line-items.js.map +1 -0
- package/dist/components/list.d.ts +37 -3
- package/dist/components/list.js +39 -14
- package/dist/components/list.js.map +1 -1
- package/dist/components/loading-state.d.ts +24 -0
- package/dist/components/loading-state.js +32 -0
- package/dist/components/loading-state.js.map +1 -0
- package/dist/components/menu-item.d.ts +13 -2
- package/dist/components/menu-item.js +11 -2
- package/dist/components/menu-item.js.map +1 -1
- package/dist/components/mini-calendar.d.ts +82 -5
- package/dist/components/mini-calendar.js +212 -64
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +20 -1
- package/dist/components/modal.js +26 -2
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.d.ts +21 -1
- package/dist/components/month-picker.js +139 -26
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.d.ts +1 -1
- package/dist/components/multi-entity-combobox.js +19 -3
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/nav-pills.d.ts +67 -0
- package/dist/components/nav-pills.js +69 -0
- package/dist/components/nav-pills.js.map +1 -0
- package/dist/components/number-field.d.ts +26 -5
- package/dist/components/number-field.js +5 -7
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/number-input.d.ts +27 -5
- package/dist/components/number-input.js +7 -1
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +17 -4
- package/dist/components/passkeys-setting.d.ts +67 -0
- package/dist/components/passkeys-setting.js +214 -0
- package/dist/components/passkeys-setting.js.map +1 -0
- package/dist/components/picker-sheet.js +2 -1
- package/dist/components/picker-sheet.js.map +1 -1
- package/dist/components/pie-chart-labels.d.ts +20 -0
- package/dist/components/pie-chart-labels.js +12 -0
- package/dist/components/pie-chart-labels.js.map +1 -0
- package/dist/components/pie-chart.d.ts +101 -0
- package/dist/components/pie-chart.js +283 -0
- package/dist/components/pie-chart.js.map +1 -0
- package/dist/components/progress-bar.d.ts +73 -3
- package/dist/components/progress-bar.js +110 -8
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/qr-code.d.ts +34 -0
- package/dist/components/qr-code.js +57 -0
- package/dist/components/qr-code.js.map +1 -0
- package/dist/components/search-field.d.ts +15 -3
- package/dist/components/search-field.js +5 -1
- package/dist/components/search-field.js.map +1 -1
- package/dist/components/series-chart.d.ts +16 -0
- package/dist/components/series-chart.js +4 -1
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/settings-fields.d.ts +50 -1
- package/dist/components/signed-amount.d.ts +121 -0
- package/dist/components/signed-amount.js +152 -0
- package/dist/components/signed-amount.js.map +1 -0
- package/dist/components/skeleton.d.ts +10 -3
- package/dist/components/skeleton.js +12 -2
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/stat-tile.d.ts +2 -1
- package/dist/components/stat-tile.js +5 -2
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/status-dot.d.ts +6 -2
- package/dist/components/status-dot.js +6 -1
- package/dist/components/status-dot.js.map +1 -1
- package/dist/components/table.d.ts +77 -11
- package/dist/components/table.js +85 -17
- package/dist/components/table.js.map +1 -1
- package/dist/components/text-link.d.ts +176 -0
- package/dist/components/text-link.js +109 -0
- package/dist/components/text-link.js.map +1 -0
- package/dist/components/text.d.ts +8 -1
- package/dist/components/text.js +1 -0
- package/dist/components/text.js.map +1 -1
- package/dist/components/time-input.d.ts +50 -1
- package/dist/components/toggle-group.d.ts +28 -0
- package/dist/components/toggle-group.js +58 -9
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle-legend.d.ts +36 -3
- package/dist/components/toggle-legend.js +49 -0
- package/dist/components/toggle-legend.js.map +1 -1
- package/dist/components/tooltip.d.ts +11 -3
- package/dist/components/tooltip.js +2 -0
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/ui.d.ts +52 -729
- package/dist/components/ui.js +296 -27
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-table-state.d.ts +3 -52
- package/dist/components/use-table-state.js +128 -30
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/components/user-avatar.d.ts +25 -3
- package/dist/components/user-avatar.js +32 -3
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/{data-table-filters-Dh9uF_S-.d.ts → data-table-Drun8Fk9.d.ts} +305 -61
- package/dist/data-table.d.ts +2 -1
- package/dist/data-table.js +5 -1
- package/dist/data-table.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +26 -3
- package/dist/feedback/feedback-dialog.js +16 -2
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +133 -0
- package/dist/feedback/feedback-thread.js +237 -0
- package/dist/feedback/feedback-thread.js.map +1 -0
- package/dist/feedback.d.ts +2 -1
- package/dist/feedback.js +1 -0
- package/dist/feedback.js.map +1 -1
- package/dist/hooks/use-authed-src.d.ts +71 -0
- package/dist/hooks/use-authed-src.js +63 -0
- package/dist/hooks/use-authed-src.js.map +1 -0
- package/dist/hooks/use-file-drop.d.ts +50 -2
- package/dist/hooks/use-hotkey.d.ts +59 -0
- package/dist/hooks/use-hotkey.js +105 -0
- package/dist/hooks/use-hotkey.js.map +1 -0
- package/dist/hooks/use-search-param-state.d.ts +83 -0
- package/dist/hooks/use-search-param-state.js +94 -0
- package/dist/hooks/use-search-param-state.js.map +1 -0
- package/dist/i18n/defaults.d.ts +17 -4
- package/dist/i18n/defaults.js +33 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +47 -310
- package/dist/i18n/kit-labels.js +20 -5
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/de-CH-informal.d.ts +17 -4
- package/dist/i18n/locales/de-CH.d.ts +17 -4
- package/dist/i18n/locales/de-informal.d.ts +17 -4
- package/dist/i18n/locales/de.d.ts +17 -4
- package/dist/i18n/locales/de.js +165 -4
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +17 -4
- package/dist/i18n/locales/es.js +162 -4
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +17 -4
- package/dist/i18n/locales/fr.js +162 -4
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +17 -4
- package/dist/i18n/locales/hu.js +162 -4
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +17 -4
- package/dist/i18n/locales/it.js +162 -4
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +17 -4
- package/dist/i18n/locales/zh.js +162 -4
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +45 -21
- package/dist/index.js +43 -1
- package/dist/index.js.map +1 -1
- package/dist/kit-labels-v3biUF1L.d.ts +1645 -0
- package/dist/lib/clipping.d.ts +21 -5
- package/dist/lib/clipping.js +3 -0
- package/dist/lib/clipping.js.map +1 -1
- package/dist/lib/dates.d.ts +17 -1
- package/dist/lib/dates.js +19 -0
- package/dist/lib/dates.js.map +1 -1
- package/dist/lib/format.d.ts +144 -0
- package/dist/lib/format.js +149 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/qr-encode.d.ts +44 -0
- package/dist/lib/qr-encode.js +338 -0
- package/dist/lib/qr-encode.js.map +1 -0
- package/dist/rhf/fields.d.ts +241 -0
- package/dist/rhf/fields.js +601 -0
- package/dist/rhf/fields.js.map +1 -0
- package/dist/rhf/form.d.ts +50 -1
- package/dist/rhf/line-items.d.ts +31 -0
- package/dist/rhf/line-items.js +59 -0
- package/dist/rhf/line-items.js.map +1 -0
- package/dist/rhf/use-rhf-wizard-step.d.ts +22 -0
- package/dist/rhf/use-rhf-wizard-step.js +38 -0
- package/dist/rhf/use-rhf-wizard-step.js.map +1 -0
- package/dist/rhf.d.ts +63 -1
- package/dist/rhf.js +3 -0
- package/dist/rhf.js.map +1 -1
- package/dist/shell/app-shell.d.ts +99 -2
- package/dist/shell/app-shell.js +58 -3
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/auth-layout.d.ts +74 -0
- package/dist/shell/auth-layout.js +97 -0
- package/dist/shell/auth-layout.js.map +1 -0
- package/dist/shell/top-bar-brand.d.ts +81 -0
- package/dist/shell/top-bar-brand.js +47 -0
- package/dist/shell/top-bar-brand.js.map +1 -0
- package/dist/shell/topbar-action-menu.d.ts +84 -3
- package/dist/shell/topbar-action-menu.js +115 -27
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell.d.ts +58 -2
- package/dist/shell.js +2 -0
- package/dist/shell.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +49 -1
- package/dist/wizard/wizard-context.d.ts +30 -1
- package/dist/wizard/wizard-context.js +23 -2
- package/dist/wizard/wizard-context.js.map +1 -1
- package/dist/wizard/wizard-step.d.ts +20 -5
- package/dist/wizard/wizard-step.js +16 -3
- package/dist/wizard/wizard-step.js.map +1 -1
- package/dist/wizard.d.ts +51 -3
- package/package.json +1 -1
- package/src/chart.ts +4 -0
- package/src/components/account-settings-labels.ts +190 -0
- package/src/components/account-settings.tsx +110 -63
- package/src/components/alert-banner.tsx +36 -7
- package/src/components/amount-input.tsx +13 -1
- package/src/components/authed-image.tsx +190 -0
- package/src/components/breadcrumbs.tsx +8 -2
- package/src/components/bulk-action-bar.tsx +163 -57
- package/src/components/button-group.tsx +129 -4
- package/src/components/calendar-heatmap.tsx +599 -0
- package/src/components/chip.tsx +8 -4
- package/src/components/choice-card.tsx +208 -1
- package/src/components/combobox-core.tsx +5 -0
- package/src/components/combobox.tsx +31 -9
- package/src/components/copy-button.tsx +3 -2
- package/src/components/data-table-cells.tsx +119 -0
- package/src/components/data-table-filters.ts +77 -0
- package/src/components/data-table-labels.ts +23 -0
- package/src/components/data-table.tsx +231 -13
- package/src/components/date-picker.tsx +19 -3
- package/src/components/description-list.tsx +52 -3
- package/src/components/entity-combobox.tsx +18 -3
- package/src/components/error-boundary.tsx +216 -0
- package/src/components/field.tsx +188 -0
- package/src/components/floating-panel.tsx +380 -16
- package/src/components/form-actions.tsx +191 -0
- package/src/components/image-grid.tsx +181 -0
- package/src/components/lightbox.tsx +374 -0
- package/src/components/line-items.tsx +385 -0
- package/src/components/list.tsx +93 -18
- package/src/components/loading-state.tsx +47 -0
- package/src/components/menu-item.tsx +29 -3
- package/src/components/mini-calendar.tsx +317 -57
- package/src/components/modal.tsx +61 -3
- package/src/components/month-picker.tsx +181 -26
- package/src/components/multi-entity-combobox.tsx +19 -3
- package/src/components/nav-pills.tsx +152 -0
- package/src/components/number-field.tsx +15 -10
- package/src/components/number-input.tsx +16 -1
- package/src/components/passkeys-setting.tsx +331 -0
- package/src/components/picker-sheet.tsx +7 -1
- package/src/components/pie-chart-labels.ts +32 -0
- package/src/components/pie-chart.tsx +479 -0
- package/src/components/progress-bar.tsx +241 -13
- package/src/components/qr-code.tsx +83 -0
- package/src/components/search-field.tsx +20 -4
- package/src/components/series-chart.tsx +21 -0
- package/src/components/signed-amount.tsx +286 -0
- package/src/components/skeleton.tsx +21 -3
- package/src/components/stat-tile.tsx +8 -2
- package/src/components/status-dot.tsx +10 -2
- package/src/components/table.tsx +186 -23
- package/src/components/text-link.tsx +248 -0
- package/src/components/text.tsx +9 -1
- package/src/components/toggle-group.tsx +106 -13
- package/src/components/toggle-legend.tsx +87 -2
- package/src/components/tooltip.tsx +17 -3
- package/src/components/ui.tsx +572 -44
- package/src/components/use-table-state.ts +265 -33
- package/src/components/user-avatar.tsx +57 -3
- package/src/data-table.ts +10 -0
- package/src/feedback/feedback-dialog.tsx +42 -3
- package/src/feedback/feedback-thread.tsx +434 -0
- package/src/feedback.ts +1 -0
- package/src/hooks/use-authed-src.ts +161 -0
- package/src/hooks/use-hotkey.ts +172 -0
- package/src/hooks/use-search-param-state.ts +187 -0
- package/src/i18n/defaults.ts +32 -0
- package/src/i18n/kit-labels.tsx +104 -8
- package/src/i18n/locales/de.ts +162 -0
- package/src/i18n/locales/es.ts +159 -0
- package/src/i18n/locales/fr.ts +162 -0
- package/src/i18n/locales/hu.ts +160 -0
- package/src/i18n/locales/it.ts +160 -0
- package/src/i18n/locales/zh.ts +159 -0
- package/src/index.ts +64 -0
- package/src/lib/clipping.ts +22 -4
- package/src/lib/dates.ts +37 -0
- package/src/lib/format.ts +325 -0
- package/src/lib/qr-encode.ts +420 -0
- package/src/rhf/fields.tsx +1054 -0
- package/src/rhf/line-items.tsx +130 -0
- package/src/rhf/use-rhf-wizard-step.ts +113 -0
- package/src/rhf.ts +8 -0
- package/src/shell/app-shell.tsx +147 -2
- package/src/shell/auth-layout.tsx +190 -0
- package/src/shell/top-bar-brand.tsx +76 -0
- package/src/shell/topbar-action-menu.tsx +260 -49
- package/src/shell.ts +2 -0
- package/src/wizard/wizard-context.tsx +50 -1
- package/src/wizard/wizard-step.tsx +43 -6
- package/tokens.css +12 -0
|
@@ -15,5 +15,34 @@ interface WizardContextValue {
|
|
|
15
15
|
}
|
|
16
16
|
declare const WizardContextProvider: react.Provider<WizardContextValue | null>;
|
|
17
17
|
declare function useWizardContext(): WizardContextValue;
|
|
18
|
+
/**
|
|
19
|
+
* The wizard context, or `null` outside a `<StepperNav>`. For a hook that registers
|
|
20
|
+
* with the wizard when there is one and works without it — `useRhfWizardStep` in
|
|
21
|
+
* `@eifi1/ui-kit/rhf`, whose returned `validate` a custom nav can call itself.
|
|
22
|
+
*/
|
|
23
|
+
declare function useOptionalWizardContext(): WizardContextValue | null;
|
|
24
|
+
/**
|
|
25
|
+
* Registers a plain validator for the mounted step — the counterpart to
|
|
26
|
+
* `useRhfWizardStep` (in `@eifi1/ui-kit/rhf`) for a step that gates on its own state
|
|
27
|
+
* (a hand-managed list of lines, a sum that has to balance) rather than a form.
|
|
28
|
+
*
|
|
29
|
+
* ```tsx
|
|
30
|
+
* useWizardStepValidate(() => ({ ok: lines.length >= 2, errors: { lines: t("…") } }));
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* Next (and Finish) run it with the step's other validators; a `false` or a result
|
|
34
|
+
* with `ok: false` keeps the wizard where it is. `validate` is read through a ref, so
|
|
35
|
+
* an inline closure over the latest state registers exactly once. Throws outside a
|
|
36
|
+
* `<StepperNav>`, like {@link useWizardContext}: a validator with nothing to run it is
|
|
37
|
+
* a bug to hear about.
|
|
38
|
+
*/
|
|
39
|
+
declare function useWizardStepValidate(validate: () => ValidateResult | Promise<ValidateResult>): void;
|
|
40
|
+
/**
|
|
41
|
+
* Disables the wizard's Next and Skip while `blocked` holds (tenant shares that do not
|
|
42
|
+
* add up to 100 %). Unlike {@link useWizardStepValidate}, which answers a click, this
|
|
43
|
+
* greys the button out before one. The gate is lifted again when the step unmounts, so
|
|
44
|
+
* the next step starts unblocked.
|
|
45
|
+
*/
|
|
46
|
+
declare function useWizardNextGate(blocked: boolean): void;
|
|
18
47
|
|
|
19
|
-
export { WizardContextProvider, type WizardContextValue, useWizardContext };
|
|
48
|
+
export { WizardContextProvider, type WizardContextValue, useOptionalWizardContext, useWizardContext, useWizardNextGate, useWizardStepValidate };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
2
|
+
import { createContext, useContext, useEffect, useRef } from "react";
|
|
3
3
|
const WizardContext = createContext(null);
|
|
4
4
|
const WizardContextProvider = WizardContext.Provider;
|
|
5
5
|
function useWizardContext() {
|
|
@@ -9,8 +9,29 @@ function useWizardContext() {
|
|
|
9
9
|
}
|
|
10
10
|
return ctx;
|
|
11
11
|
}
|
|
12
|
+
function useOptionalWizardContext() {
|
|
13
|
+
return useContext(WizardContext);
|
|
14
|
+
}
|
|
15
|
+
function useWizardStepValidate(validate) {
|
|
16
|
+
const { registerStepValidate } = useWizardContext();
|
|
17
|
+
const ref = useRef(validate);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
ref.current = validate;
|
|
20
|
+
});
|
|
21
|
+
useEffect(() => registerStepValidate(() => ref.current()), [registerStepValidate]);
|
|
22
|
+
}
|
|
23
|
+
function useWizardNextGate(blocked) {
|
|
24
|
+
const { setNextBlocked } = useWizardContext();
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setNextBlocked(blocked);
|
|
27
|
+
return () => setNextBlocked(false);
|
|
28
|
+
}, [blocked, setNextBlocked]);
|
|
29
|
+
}
|
|
12
30
|
export {
|
|
13
31
|
WizardContextProvider,
|
|
14
|
-
|
|
32
|
+
useOptionalWizardContext,
|
|
33
|
+
useWizardContext,
|
|
34
|
+
useWizardNextGate,
|
|
35
|
+
useWizardStepValidate
|
|
15
36
|
};
|
|
16
37
|
//# sourceMappingURL=wizard-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/wizard/wizard-context.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { ValidateResult } from \"./types\";\n\nexport interface WizardContextValue {\n /**\n * Register a validator for the currently-mounted step. Returns an unregister\n * fn (call it in a useEffect cleanup). `goNext` runs every registered\n * validator for the active step (plus the step config's own `validate`),\n * AND-combining the results — this replaces the per-page `useRef` +\n * `validate: () => ref.current?.()` bridge each RHF step used to wire.\n */\n registerStepValidate: (\n fn: () => ValidateResult | Promise<ValidateResult>,\n ) => () => void;\n /** Lets the mounted step disable Next/Skip (e.g. invalid tenant shares). */\n setNextBlocked: (blocked: boolean) => void;\n}\n\nconst WizardContext = createContext<WizardContextValue | null>(null);\n\nexport const WizardContextProvider = WizardContext.Provider;\n\nexport function useWizardContext(): WizardContextValue {\n const ctx = useContext(WizardContext);\n if (!ctx) {\n throw new Error(\"useWizardContext must be used within a <StepperNav>\");\n }\n return ctx;\n}\n"],"mappings":";AAAA,SAAS,eAAe,
|
|
1
|
+
{"version":3,"sources":["../../src/wizard/wizard-context.tsx"],"sourcesContent":["import { createContext, useContext, useEffect, useRef } from \"react\";\nimport type { ValidateResult } from \"./types\";\n\nexport interface WizardContextValue {\n /**\n * Register a validator for the currently-mounted step. Returns an unregister\n * fn (call it in a useEffect cleanup). `goNext` runs every registered\n * validator for the active step (plus the step config's own `validate`),\n * AND-combining the results — this replaces the per-page `useRef` +\n * `validate: () => ref.current?.()` bridge each RHF step used to wire.\n */\n registerStepValidate: (\n fn: () => ValidateResult | Promise<ValidateResult>,\n ) => () => void;\n /** Lets the mounted step disable Next/Skip (e.g. invalid tenant shares). */\n setNextBlocked: (blocked: boolean) => void;\n}\n\nconst WizardContext = createContext<WizardContextValue | null>(null);\n\nexport const WizardContextProvider = WizardContext.Provider;\n\nexport function useWizardContext(): WizardContextValue {\n const ctx = useContext(WizardContext);\n if (!ctx) {\n throw new Error(\"useWizardContext must be used within a <StepperNav>\");\n }\n return ctx;\n}\n\n/**\n * The wizard context, or `null` outside a `<StepperNav>`. For a hook that registers\n * with the wizard when there is one and works without it — `useRhfWizardStep` in\n * `@eifi1/ui-kit/rhf`, whose returned `validate` a custom nav can call itself.\n */\nexport function useOptionalWizardContext(): WizardContextValue | null {\n return useContext(WizardContext);\n}\n\n/**\n * Registers a plain validator for the mounted step — the counterpart to\n * `useRhfWizardStep` (in `@eifi1/ui-kit/rhf`) for a step that gates on its own state\n * (a hand-managed list of lines, a sum that has to balance) rather than a form.\n *\n * ```tsx\n * useWizardStepValidate(() => ({ ok: lines.length >= 2, errors: { lines: t(\"…\") } }));\n * ```\n *\n * Next (and Finish) run it with the step's other validators; a `false` or a result\n * with `ok: false` keeps the wizard where it is. `validate` is read through a ref, so\n * an inline closure over the latest state registers exactly once. Throws outside a\n * `<StepperNav>`, like {@link useWizardContext}: a validator with nothing to run it is\n * a bug to hear about.\n */\nexport function useWizardStepValidate(\n validate: () => ValidateResult | Promise<ValidateResult>,\n): void {\n const { registerStepValidate } = useWizardContext();\n const ref = useRef(validate);\n useEffect(() => {\n ref.current = validate;\n });\n useEffect(() => registerStepValidate(() => ref.current()), [registerStepValidate]);\n}\n\n/**\n * Disables the wizard's Next and Skip while `blocked` holds (tenant shares that do not\n * add up to 100 %). Unlike {@link useWizardStepValidate}, which answers a click, this\n * greys the button out before one. The gate is lifted again when the step unmounts, so\n * the next step starts unblocked.\n */\nexport function useWizardNextGate(blocked: boolean): void {\n const { setNextBlocked } = useWizardContext();\n useEffect(() => {\n setNextBlocked(blocked);\n return () => setNextBlocked(false);\n }, [blocked, setNextBlocked]);\n}\n"],"mappings":";AAAA,SAAS,eAAe,YAAY,WAAW,cAAc;AAkB7D,MAAM,gBAAgB,cAAyC,IAAI;AAE5D,MAAM,wBAAwB,cAAc;AAE5C,SAAS,mBAAuC;AACrD,QAAM,MAAM,WAAW,aAAa;AACpC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;AAOO,SAAS,2BAAsD;AACpE,SAAO,WAAW,aAAa;AACjC;AAiBO,SAAS,sBACd,UACM;AACN,QAAM,EAAE,qBAAqB,IAAI,iBAAiB;AAClD,QAAM,MAAM,OAAO,QAAQ;AAC3B,YAAU,MAAM;AACd,QAAI,UAAU;AAAA,EAChB,CAAC;AACD,YAAU,MAAM,qBAAqB,MAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,oBAAoB,CAAC;AACnF;AAQO,SAAS,kBAAkB,SAAwB;AACxD,QAAM,EAAE,eAAe,IAAI,iBAAiB;AAC5C,YAAU,MAAM;AACd,mBAAe,OAAO;AACtB,WAAO,MAAM,eAAe,KAAK;AAAA,EACnC,GAAG,CAAC,SAAS,cAAc,CAAC;AAC9B;","names":[]}
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
* than a class string so every step in every app spaces its fields the same. */
|
|
6
|
-
declare function WizardStep({ children, className, }: {
|
|
4
|
+
interface WizardStepProps {
|
|
7
5
|
children: ReactNode;
|
|
8
6
|
className?: string;
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The step's heading ("Choose a unit"), drawn in the one style every step shares.
|
|
9
|
+
* kastlan's steps each hand-wrote `<h3 className="text-lg font-semibold">` (about
|
|
10
|
+
* sixteen of them: lease-picker-step, lease-unit-step, …), and a hand-written
|
|
11
|
+
* heading is one that drifts — a size here, a colour there. Omitted: no heading.
|
|
12
|
+
*/
|
|
13
|
+
title?: ReactNode;
|
|
14
|
+
/** The line under the title: what the step asks for, or why. Rendered only with a
|
|
15
|
+
* `title` or on its own when there is none. */
|
|
16
|
+
description?: ReactNode;
|
|
17
|
+
/** The heading's level. Default 3: the page has its `h1` and the wizard's own
|
|
18
|
+
* chrome sits at `h2` (the review step, the cancel dialog), so a step is under it. */
|
|
19
|
+
headingLevel?: 2 | 3 | 4;
|
|
20
|
+
}
|
|
21
|
+
/** The vertical rhythm one wizard step's content sits on. A component rather
|
|
22
|
+
* than a class string so every step in every app spaces its fields the same —
|
|
23
|
+
* and, with `title` / `description`, heads them the same. */
|
|
24
|
+
declare function WizardStep({ children, className, title, description, headingLevel, }: WizardStepProps): react.JSX.Element;
|
|
10
25
|
|
|
11
|
-
export { WizardStep };
|
|
26
|
+
export { WizardStep, type WizardStepProps };
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cn } from "../lib/cn.js";
|
|
4
|
+
const HEADING = { 2: "h2", 3: "h3", 4: "h4" };
|
|
4
5
|
function WizardStep({
|
|
5
6
|
children,
|
|
6
|
-
className
|
|
7
|
+
className,
|
|
8
|
+
title,
|
|
9
|
+
description,
|
|
10
|
+
headingLevel = 3
|
|
7
11
|
}) {
|
|
8
|
-
|
|
12
|
+
const hasTitle = title !== void 0 && title !== null && title !== false && title !== "";
|
|
13
|
+
const hasDescription = description !== void 0 && description !== null && description !== false && description !== "";
|
|
14
|
+
const Heading = HEADING[headingLevel];
|
|
15
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("space-y-6", className), children: [
|
|
16
|
+
(hasTitle || hasDescription) && /* @__PURE__ */ jsxs("div", { "data-slot": "wizard-step-header", className: "space-y-1", children: [
|
|
17
|
+
hasTitle && /* @__PURE__ */ jsx(Heading, { className: "text-lg font-semibold text-[var(--text-primary)]", children: title }),
|
|
18
|
+
hasDescription && /* @__PURE__ */ jsx("p", { className: "text-sm text-[var(--text-muted)]", children: description })
|
|
19
|
+
] }),
|
|
20
|
+
children
|
|
21
|
+
] });
|
|
9
22
|
}
|
|
10
23
|
export {
|
|
11
24
|
WizardStep
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/wizard/wizard-step.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\n\n/** The vertical rhythm one wizard step's content sits on. A component rather\n * than a class string so every step in every app spaces its fields the same. */\nexport function WizardStep({\n children,\n className,\n}: {\n
|
|
1
|
+
{"version":3,"sources":["../../src/wizard/wizard-step.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\n\nexport interface WizardStepProps {\n children: ReactNode;\n className?: string;\n /**\n * The step's heading (\"Choose a unit\"), drawn in the one style every step shares.\n * kastlan's steps each hand-wrote `<h3 className=\"text-lg font-semibold\">` (about\n * sixteen of them: lease-picker-step, lease-unit-step, …), and a hand-written\n * heading is one that drifts — a size here, a colour there. Omitted: no heading.\n */\n title?: ReactNode;\n /** The line under the title: what the step asks for, or why. Rendered only with a\n * `title` or on its own when there is none. */\n description?: ReactNode;\n /** The heading's level. Default 3: the page has its `h1` and the wizard's own\n * chrome sits at `h2` (the review step, the cancel dialog), so a step is under it. */\n headingLevel?: 2 | 3 | 4;\n}\n\nconst HEADING = { 2: \"h2\", 3: \"h3\", 4: \"h4\" } as const;\n\n/** The vertical rhythm one wizard step's content sits on. A component rather\n * than a class string so every step in every app spaces its fields the same —\n * and, with `title` / `description`, heads them the same. */\nexport function WizardStep({\n children,\n className,\n title,\n description,\n headingLevel = 3,\n}: WizardStepProps) {\n const hasTitle = title !== undefined && title !== null && title !== false && title !== \"\";\n const hasDescription =\n description !== undefined && description !== null && description !== false && description !== \"\";\n const Heading = HEADING[headingLevel];\n return (\n <div className={cn(\"space-y-6\", className)}>\n {(hasTitle || hasDescription) && (\n <div data-slot=\"wizard-step-header\" className=\"space-y-1\">\n {hasTitle && (\n <Heading className=\"text-lg font-semibold text-[var(--text-primary)]\">{title}</Heading>\n )}\n {hasDescription && <p className=\"text-sm text-[var(--text-muted)]\">{description}</p>}\n </div>\n )}\n {children}\n </div>\n );\n}\n"],"mappings":";AAwCQ,SAEI,KAFJ;AAvCR,SAAS,UAAU;AAoBnB,MAAM,UAAU,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK;AAKrC,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AACjB,GAAoB;AAClB,QAAM,WAAW,UAAU,UAAa,UAAU,QAAQ,UAAU,SAAS,UAAU;AACvF,QAAM,iBACJ,gBAAgB,UAAa,gBAAgB,QAAQ,gBAAgB,SAAS,gBAAgB;AAChG,QAAM,UAAU,QAAQ,YAAY;AACpC,SACE,qBAAC,SAAI,WAAW,GAAG,aAAa,SAAS,GACrC;AAAA,iBAAY,mBACZ,qBAAC,SAAI,aAAU,sBAAqB,WAAU,aAC3C;AAAA,kBACC,oBAAC,WAAQ,WAAU,oDAAoD,iBAAM;AAAA,MAE9E,kBAAkB,oBAAC,OAAE,WAAU,oCAAoC,uBAAY;AAAA,OAClF;AAAA,IAED;AAAA,KACH;AAEJ;","names":[]}
|
package/dist/wizard.d.ts
CHANGED
|
@@ -1,11 +1,59 @@
|
|
|
1
1
|
export { DEFAULT_WIZARD_LABELS, FieldErrors, StepStatus, SummaryItem, SummarySection, UseWizardOptions, UseWizardReturn, ValidateResult, WizardLabels, WizardStepConfig, WizardUrlSync, resolveWizardLabels } from './wizard/types.js';
|
|
2
2
|
export { useWizard } from './wizard/use-wizard.js';
|
|
3
|
-
export { WizardContextProvider, WizardContextValue, useWizardContext } from './wizard/wizard-context.js';
|
|
3
|
+
export { WizardContextProvider, WizardContextValue, useOptionalWizardContext, useWizardContext, useWizardNextGate, useWizardStepValidate } from './wizard/wizard-context.js';
|
|
4
4
|
export { RequiredFieldSpec, requiredFieldsValidator } from './wizard/validation.js';
|
|
5
|
-
export { WizardStep } from './wizard/wizard-step.js';
|
|
5
|
+
export { WizardStep, WizardStepProps } from './wizard/wizard-step.js';
|
|
6
6
|
export { WizardSummary } from './wizard/wizard-summary.js';
|
|
7
7
|
export { StepperNav } from './wizard/stepper-nav.js';
|
|
8
8
|
import 'react';
|
|
9
|
-
import './
|
|
9
|
+
import './kit-labels-v3biUF1L.js';
|
|
10
|
+
import './components/data-table-labels.js';
|
|
11
|
+
import './components/mini-calendar.js';
|
|
12
|
+
import './components/calendar-heatmap.js';
|
|
13
|
+
import './components/popover.js';
|
|
14
|
+
import './components/chip.js';
|
|
15
|
+
import 'lucide-react';
|
|
16
|
+
import './components/field-sync.js';
|
|
10
17
|
import './components/tooltip.js';
|
|
11
18
|
import './hooks/use-anchored-rect.js';
|
|
19
|
+
import './lib/clipping.js';
|
|
20
|
+
import './tour/tour.js';
|
|
21
|
+
import './search/command-palette.js';
|
|
22
|
+
import './search/global-search.js';
|
|
23
|
+
import './search/search-index.js';
|
|
24
|
+
import './components/month-picker.js';
|
|
25
|
+
import './components/page-contents.js';
|
|
26
|
+
import './components/series-chart-labels.js';
|
|
27
|
+
import './components/pie-chart-labels.js';
|
|
28
|
+
import './components/sparkline.js';
|
|
29
|
+
import './components/stat-tile.js';
|
|
30
|
+
import './components/signature-pad.js';
|
|
31
|
+
import './components/password-strength.js';
|
|
32
|
+
import './components/danger-confirm.js';
|
|
33
|
+
import './components/swatch-picker.js';
|
|
34
|
+
import './components/tile-radio.js';
|
|
35
|
+
import './components/icon-picker.js';
|
|
36
|
+
import './components/dialog-frame.js';
|
|
37
|
+
import './components/modal.js';
|
|
38
|
+
import './hooks/use-search-param-state.js';
|
|
39
|
+
import './components/measured-grid.js';
|
|
40
|
+
import './feedback/feedback-attachment.js';
|
|
41
|
+
import './feedback/feedback-dialog.js';
|
|
42
|
+
import './feedback/feedback-thread.js';
|
|
43
|
+
import './feedback/feedback-inbox.js';
|
|
44
|
+
import './components/account-settings-labels.js';
|
|
45
|
+
import './components/confirm-dialog.js';
|
|
46
|
+
import './components/floating-panel.js';
|
|
47
|
+
import './components/bulk-action-bar.js';
|
|
48
|
+
import './components/list.js';
|
|
49
|
+
import './components/breadcrumbs.js';
|
|
50
|
+
import './components/toast.js';
|
|
51
|
+
import './components/description-list.js';
|
|
52
|
+
import './components/line-items.js';
|
|
53
|
+
import './components/progress-bar.js';
|
|
54
|
+
import './components/signed-amount.js';
|
|
55
|
+
import './components/error-boundary.js';
|
|
56
|
+
import './components/authed-image.js';
|
|
57
|
+
import './hooks/use-authed-src.js';
|
|
58
|
+
import './components/image-grid.js';
|
|
59
|
+
import './components/lightbox.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eifi1/ui-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "App-agnostic shared design system: domain-free React components, theme and tokens.",
|
|
6
6
|
"_sideEffects": "The barrel (src/index.ts) re-exports EVERY component, including components/chart, which statically imports recharts. Without this field a bundler must assume each of those modules has side effects, so it cannot drop the unused ones: importing a Button from '@eifi1/ui-kit' dragged all 433KB of recharts into the consumer's ENTRY chunk, and Keksdose was preloading it on every page load, login included. Nothing in src/ imports for side effects (no bare imports, no CSS imports from JS, no module-level global writes) — the token stylesheet is its own './tokens.css' export — so this is safe. CSS is still listed so any future stylesheet survives. Re-checked when `flag-icons` left `dependencies` and tsup started emitting a `\"use client\"` banner: neither touches this. The flag stylesheet was never imported from JS in the first place (that was the finding), and a directive prologue is a string literal every bundler lifts out before it decides whether a module is inert.",
|
package/src/chart.ts
CHANGED
|
@@ -20,3 +20,7 @@ export * from "./components/chart-zoom";
|
|
|
20
20
|
export * from "./components/toggle-legend";
|
|
21
21
|
export * from "./components/facing-pair";
|
|
22
22
|
export * from "./components/series-chart-labels";
|
|
23
|
+
|
|
24
|
+
// The part-to-whole chart (donut / pie) — moved here from kastlan's dashboard and reports.
|
|
25
|
+
export * from "./components/pie-chart";
|
|
26
|
+
export * from "./components/pie-chart-labels";
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useKitLabelOverrides } from "../i18n/kit-labels";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The `accountSettings` namespace of `<UiKitProvider labels>`: one record per section —
|
|
6
|
+
* `profile`, `password`, `twoFactor`, `passkeys` — each merged key by key, so an app
|
|
7
|
+
* can translate `accountSettings.twoFactor.scanHint` alone.
|
|
8
|
+
*
|
|
9
|
+
* Before 0.12.0 every section took a REQUIRED `labels` prop and had no English of its
|
|
10
|
+
* own, so each app spelled out 30-odd keys at the call site and still hard-coded some
|
|
11
|
+
* (kastlan's profile page passed `email: "Email"` in English to a German page). The
|
|
12
|
+
* prop stays, now partial, and wins over the provider as everywhere else in the kit.
|
|
13
|
+
*
|
|
14
|
+
* Its own module, beside the components rather than in them, so `PasskeysSetting`
|
|
15
|
+
* (its own file) and the older three read one tree without importing each other.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export interface ProfileSettingLabels {
|
|
19
|
+
title: string;
|
|
20
|
+
email: string;
|
|
21
|
+
role: string;
|
|
22
|
+
memberSince: string;
|
|
23
|
+
displayName: string;
|
|
24
|
+
save: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface PasswordSettingLabels {
|
|
28
|
+
title: string;
|
|
29
|
+
current: string;
|
|
30
|
+
next: string;
|
|
31
|
+
confirm: string;
|
|
32
|
+
submit: string;
|
|
33
|
+
tooShort: string;
|
|
34
|
+
mismatch: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface TwoFactorSettingLabels {
|
|
38
|
+
status: string;
|
|
39
|
+
enabledText: string;
|
|
40
|
+
disabledText: string;
|
|
41
|
+
enable: string;
|
|
42
|
+
scanHint: string;
|
|
43
|
+
codeLabel: string;
|
|
44
|
+
verify: string;
|
|
45
|
+
disableSection: string;
|
|
46
|
+
password: string;
|
|
47
|
+
disable: string;
|
|
48
|
+
/**
|
|
49
|
+
* Alt text for the setup QR code, which shipped as a hardcoded `alt="QR"`.
|
|
50
|
+
*
|
|
51
|
+
* OPTIONAL, like the two keys below, and not because it matters less: this interface
|
|
52
|
+
* is annotated at consumer call sites (`const LABELS: TwoFactorSettingLabels = {…}`),
|
|
53
|
+
* so a new REQUIRED key is a compile error in every app on the next `npm update` —
|
|
54
|
+
* the additive-API rule in the README. Each falls back to the provider's
|
|
55
|
+
* `accountSettings.twoFactor`, then English.
|
|
56
|
+
*/
|
|
57
|
+
qrAlt?: string;
|
|
58
|
+
/** The line over the manual-entry key, for a phone that cannot scan its own screen. */
|
|
59
|
+
secretHint?: string;
|
|
60
|
+
/** The copy button beside that key. */
|
|
61
|
+
copySecret?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface PasskeysSettingLabels {
|
|
65
|
+
title: string;
|
|
66
|
+
/** The line under the title saying what a passkey is for. */
|
|
67
|
+
description: string;
|
|
68
|
+
empty: string;
|
|
69
|
+
loading: string;
|
|
70
|
+
/** Accessible name of the list. */
|
|
71
|
+
list: string;
|
|
72
|
+
nameLabel: string;
|
|
73
|
+
namePlaceholder: string;
|
|
74
|
+
add: string;
|
|
75
|
+
/** The add button while the app's WebAuthn ceremony runs — the OS prompt is open. */
|
|
76
|
+
adding: string;
|
|
77
|
+
rename: string;
|
|
78
|
+
/** The row's rename button, named for its passkey — it starts with `rename`, the
|
|
79
|
+
* visible text, so voice control finds it by what it says. */
|
|
80
|
+
renameItem: (name: string) => string;
|
|
81
|
+
/** Accessible name of the inline rename field. */
|
|
82
|
+
renameField: (name: string) => string;
|
|
83
|
+
save: string;
|
|
84
|
+
cancel: string;
|
|
85
|
+
delete: string;
|
|
86
|
+
/** The row's delete button, named for its passkey (see `renameItem`). */
|
|
87
|
+
deleteItem: (name: string) => string;
|
|
88
|
+
/** The inline question a delete asks first. */
|
|
89
|
+
deleteConfirm: (name: string) => string;
|
|
90
|
+
/** The destructive button that answers it. */
|
|
91
|
+
confirmDelete: string;
|
|
92
|
+
/** `date` arrives formatted in the provider's locale. */
|
|
93
|
+
created: (date: string) => string;
|
|
94
|
+
lastUsed: (date: string) => string;
|
|
95
|
+
neverUsed: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface AccountSettingsLabels {
|
|
99
|
+
profile: ProfileSettingLabels;
|
|
100
|
+
password: PasswordSettingLabels;
|
|
101
|
+
twoFactor: Required<TwoFactorSettingLabels>;
|
|
102
|
+
passkeys: PasskeysSettingLabels;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const DEFAULT_ACCOUNT_SETTINGS_LABELS: AccountSettingsLabels = {
|
|
106
|
+
profile: {
|
|
107
|
+
title: "Profile",
|
|
108
|
+
email: "Email",
|
|
109
|
+
role: "Role",
|
|
110
|
+
memberSince: "Member since",
|
|
111
|
+
displayName: "Display name",
|
|
112
|
+
save: "Save",
|
|
113
|
+
},
|
|
114
|
+
password: {
|
|
115
|
+
title: "Change password",
|
|
116
|
+
current: "Current password",
|
|
117
|
+
next: "New password",
|
|
118
|
+
confirm: "Confirm new password",
|
|
119
|
+
submit: "Change password",
|
|
120
|
+
tooShort: "The new password is too short.",
|
|
121
|
+
mismatch: "The passwords don’t match.",
|
|
122
|
+
},
|
|
123
|
+
twoFactor: {
|
|
124
|
+
status: "Two-factor authentication",
|
|
125
|
+
enabledText: "On",
|
|
126
|
+
disabledText: "Off",
|
|
127
|
+
enable: "Set up two-factor authentication",
|
|
128
|
+
scanHint: "Scan this code with your authenticator app, then enter the code it shows.",
|
|
129
|
+
codeLabel: "Verification code",
|
|
130
|
+
verify: "Verify and turn on",
|
|
131
|
+
disableSection: "Turn off two-factor authentication",
|
|
132
|
+
password: "Current password",
|
|
133
|
+
disable: "Turn off",
|
|
134
|
+
// Unchanged from the fallback it had before the namespace (i18n-labels.test pins it).
|
|
135
|
+
qrAlt: "QR code",
|
|
136
|
+
secretHint: "Can’t scan it? Enter this key in the app instead:",
|
|
137
|
+
copySecret: "Copy key",
|
|
138
|
+
},
|
|
139
|
+
passkeys: {
|
|
140
|
+
title: "Passkeys",
|
|
141
|
+
description: "Sign in with your fingerprint, face or device PIN instead of a password.",
|
|
142
|
+
empty: "No passkeys yet",
|
|
143
|
+
loading: "Loading passkeys…",
|
|
144
|
+
list: "Your passkeys",
|
|
145
|
+
nameLabel: "Name (optional)",
|
|
146
|
+
namePlaceholder: "e.g. Laptop, Phone",
|
|
147
|
+
add: "Add passkey",
|
|
148
|
+
adding: "Waiting for your device…",
|
|
149
|
+
rename: "Rename",
|
|
150
|
+
renameItem: (name) => `Rename ${name}`,
|
|
151
|
+
renameField: (name) => `New name for ${name}`,
|
|
152
|
+
save: "Save",
|
|
153
|
+
cancel: "Cancel",
|
|
154
|
+
delete: "Delete",
|
|
155
|
+
deleteItem: (name) => `Delete ${name}`,
|
|
156
|
+
deleteConfirm: (name) => `Delete “${name}”? It can no longer be used to sign in.`,
|
|
157
|
+
confirmDelete: "Delete passkey",
|
|
158
|
+
created: (date) => `Added ${date}`,
|
|
159
|
+
lastUsed: (date) => `Last used ${date}`,
|
|
160
|
+
neverUsed: "Never used",
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* One section of the namespace, resolved: English, then the provider's
|
|
166
|
+
* `accountSettings.<section>`, then the component's own `labels` prop. An `undefined`
|
|
167
|
+
* in either source is skipped, so a prop object built from optional values cannot
|
|
168
|
+
* blank out a default.
|
|
169
|
+
*/
|
|
170
|
+
export function useAccountSettingsLabels<K extends keyof AccountSettingsLabels>(
|
|
171
|
+
section: K,
|
|
172
|
+
prop?: Partial<AccountSettingsLabels[K]>,
|
|
173
|
+
): AccountSettingsLabels[K] {
|
|
174
|
+
const fromProvider = useKitLabelOverrides("accountSettings")?.[section] as
|
|
175
|
+
| Partial<AccountSettingsLabels[K]>
|
|
176
|
+
| undefined;
|
|
177
|
+
return useMemo(
|
|
178
|
+
() => ({
|
|
179
|
+
...DEFAULT_ACCOUNT_SETTINGS_LABELS[section],
|
|
180
|
+
...definedOnly(fromProvider),
|
|
181
|
+
...definedOnly(prop),
|
|
182
|
+
}),
|
|
183
|
+
[section, fromProvider, prop],
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function definedOnly<T extends object>(value: T | undefined): Partial<T> {
|
|
188
|
+
if (!value) return {};
|
|
189
|
+
return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined)) as Partial<T>;
|
|
190
|
+
}
|