@eifi1/ui-kit 0.54.0 → 0.55.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 +90 -76
- package/dist/admin/plan-change.js +2 -2
- package/dist/admin/plan-change.js.map +1 -1
- package/dist/admin/user-roster.d.ts +6 -0
- package/dist/admin/user-roster.js +4 -0
- package/dist/admin/user-roster.js.map +1 -1
- package/dist/billing/billing-labels.d.ts +26 -0
- package/dist/billing/billing-labels.js +9 -0
- package/dist/billing/billing-labels.js.map +1 -1
- package/dist/billing/subscription-standing.d.ts +61 -0
- package/dist/billing/subscription-standing.js +51 -0
- package/dist/billing/subscription-standing.js.map +1 -0
- package/dist/billing/usage-meter.d.ts +52 -0
- package/dist/billing/usage-meter.js +52 -0
- package/dist/billing/usage-meter.js.map +1 -0
- package/dist/chart.d.ts +1 -0
- package/dist/chart.js +4 -0
- package/dist/chart.js.map +1 -1
- package/dist/components/alert-banner.js +2 -3
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.js +3 -15
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.js +2 -2
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/bulk-action-bar.js +2 -1
- package/dist/components/bulk-action-bar.js.map +1 -1
- package/dist/components/button.d.ts +35 -1
- package/dist/components/button.js +5 -9
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar-heatmap.js +2 -2
- package/dist/components/calendar-heatmap.js.map +1 -1
- package/dist/components/camera-button.d.ts +89 -0
- package/dist/components/camera-button.js +122 -0
- package/dist/components/camera-button.js.map +1 -0
- package/dist/components/camera-capture.d.ts +66 -0
- package/dist/components/camera-capture.js +190 -0
- package/dist/components/camera-capture.js.map +1 -0
- package/dist/components/camera-labels.d.ts +20 -0
- package/dist/components/camera-labels.js +15 -0
- package/dist/components/camera-labels.js.map +1 -0
- package/dist/components/chart-edge.d.ts +9 -0
- package/dist/components/chart-edge.js +14 -3
- package/dist/components/chart-edge.js.map +1 -1
- package/dist/components/chart-zoom-core.js +34 -29
- package/dist/components/chart-zoom-core.js.map +1 -1
- package/dist/components/checkbox-group.js +1 -1
- package/dist/components/checkbox-group.js.map +1 -1
- package/dist/components/combobox-core.js +3 -2
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.js +2 -2
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/consent-again-notice-labels.d.ts +25 -0
- package/dist/components/consent-again-notice-labels.js +15 -0
- package/dist/components/consent-again-notice-labels.js.map +1 -0
- package/dist/components/consent-again-notice.d.ts +85 -0
- package/dist/components/consent-again-notice.js +94 -0
- package/dist/components/consent-again-notice.js.map +1 -0
- package/dist/components/country-select.js +2 -7
- package/dist/components/country-select.js.map +1 -1
- package/dist/components/currency-select.js +2 -2
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.js +2 -2
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-column-settings.js +2 -2
- package/dist/components/data-table-column-settings.js.map +1 -1
- package/dist/components/data-table-fit.js.map +1 -1
- package/dist/components/data-table-virtual.js +13 -3
- package/dist/components/data-table-virtual.js.map +1 -1
- package/dist/components/date-field.js +2 -2
- package/dist/components/date-field.js.map +1 -1
- package/dist/components/date-picker.js +2 -2
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/date-range-picker.js +2 -6
- package/dist/components/date-range-picker.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +3 -1
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/dropdown.js +7 -3
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/entity-combobox.js +2 -2
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/field-parts.d.ts +108 -6
- package/dist/components/field-parts.js +59 -6
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/field-suggestion-labels.d.ts +2 -0
- package/dist/components/field-suggestion-labels.js +10 -0
- package/dist/components/field-suggestion-labels.js.map +1 -0
- package/dist/components/field.js +1 -1
- package/dist/components/field.js.map +1 -1
- package/dist/components/file-button.d.ts +1 -1
- package/dist/components/file-button.js.map +1 -1
- package/dist/components/floating-panel.d.ts +7 -6
- package/dist/components/floating-panel.js +3 -17
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/form-actions.d.ts +3 -2
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/hover-menu.js +3 -2
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/icon-button.d.ts +23 -5
- package/dist/components/icon-button.js +6 -8
- package/dist/components/icon-button.js.map +1 -1
- package/dist/components/inline-confirm.js +2 -1
- package/dist/components/inline-confirm.js.map +1 -1
- package/dist/components/inline-entity-combobox.js +2 -2
- package/dist/components/inline-entity-combobox.js.map +1 -1
- package/dist/components/input.js +2 -2
- package/dist/components/input.js.map +1 -1
- package/dist/components/jump-calendar.js +3 -3
- package/dist/components/jump-calendar.js.map +1 -1
- package/dist/components/legal.d.ts +13 -1
- package/dist/components/legal.js +12 -0
- package/dist/components/legal.js.map +1 -1
- package/dist/components/legended-series-chart.d.ts +80 -0
- package/dist/components/legended-series-chart.js +70 -0
- package/dist/components/legended-series-chart.js.map +1 -0
- package/dist/components/lightbox.js +2 -1
- package/dist/components/lightbox.js.map +1 -1
- package/dist/components/mini-calendar.js +13 -5
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +23 -2
- package/dist/components/modal.js +24 -6
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.d.ts +1 -1
- package/dist/components/month-picker.js +6 -6
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.js +2 -2
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/multi-select.js +2 -6
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/number-input.js +2 -2
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/page-header-layout.d.ts +18 -0
- package/dist/components/page-header-layout.js +23 -0
- package/dist/components/page-header-layout.js.map +1 -0
- package/dist/components/page-header-skeleton.d.ts +41 -0
- package/dist/components/page-header-skeleton.js +52 -0
- package/dist/components/page-header-skeleton.js.map +1 -0
- package/dist/components/page-header.js +4 -17
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/popover.js +7 -2
- package/dist/components/popover.js.map +1 -1
- package/dist/components/release-notes-labels.d.ts +16 -0
- package/dist/components/release-notes-labels.js +18 -0
- package/dist/components/release-notes-labels.js.map +1 -0
- package/dist/components/release-notes.d.ts +65 -0
- package/dist/components/release-notes.js +65 -0
- package/dist/components/release-notes.js.map +1 -0
- package/dist/components/select.js +2 -2
- package/dist/components/select.js.map +1 -1
- package/dist/components/series-chart-labels.d.ts +9 -0
- package/dist/components/series-chart-labels.js +3 -1
- package/dist/components/series-chart-labels.js.map +1 -1
- package/dist/components/series-chart.d.ts +5 -0
- package/dist/components/series-chart.js +89 -36
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/toggle-group.js +3 -2
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/treemap-layout.js.map +1 -1
- package/dist/components/treemap.d.ts +17 -15
- package/dist/components/treemap.js +167 -85
- package/dist/components/treemap.js.map +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/eslint/role-utilities.d.ts +2 -2
- package/dist/eslint/role-utilities.js.map +1 -1
- package/dist/feedback/feedback-inbox-page.d.ts +260 -0
- package/dist/feedback/feedback-inbox-page.js +207 -0
- package/dist/feedback/feedback-inbox-page.js.map +1 -0
- package/dist/feedback/feedback-vocabulary.js +2 -2
- package/dist/feedback/feedback-vocabulary.js.map +1 -1
- package/dist/feedback.d.ts +1 -0
- package/dist/feedback.js +6 -0
- package/dist/feedback.js.map +1 -1
- package/dist/hooks/use-debounce.d.ts +32 -5
- package/dist/hooks/use-debounce.js +6 -5
- package/dist/hooks/use-debounce.js.map +1 -1
- package/dist/hooks/use-file-picker.d.ts +3 -1
- package/dist/hooks/use-file-picker.js.map +1 -1
- package/dist/hooks/use-focus-trap.d.ts +19 -3
- package/dist/hooks/use-focus-trap.js +15 -5
- package/dist/hooks/use-focus-trap.js.map +1 -1
- package/dist/hooks/use-has-camera.d.ts +36 -0
- package/dist/hooks/use-has-camera.js +53 -0
- package/dist/hooks/use-has-camera.js.map +1 -0
- package/dist/hooks/use-hotkey.js +1 -10
- package/dist/hooks/use-hotkey.js.map +1 -1
- package/dist/hooks/use-overlay-history.d.ts +6 -1
- package/dist/hooks/use-overlay-history.js +10 -2
- package/dist/hooks/use-overlay-history.js.map +1 -1
- package/dist/i18n/defaults.js +11 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.js +75 -3
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +20 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +92 -4
- package/dist/i18n/locales/en.js.map +3 -3
- package/dist/i18n/locales/es.js +71 -3
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +72 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +74 -3
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +74 -3
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js +71 -3
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.js +22 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +24 -5
- package/dist/index.js +35 -1
- package/dist/index.js.map +1 -1
- package/dist/landing/landing-labels.d.ts +8 -0
- package/dist/landing/landing-labels.js +2 -1
- package/dist/landing/landing-labels.js.map +1 -1
- package/dist/lib/changelog.d.ts +130 -0
- package/dist/lib/changelog.js +137 -0
- package/dist/lib/changelog.js.map +1 -0
- package/dist/lib/clipboard-minus.js +2 -2
- package/dist/lib/clipboard-minus.js.map +1 -1
- package/dist/lib/dates.d.ts +29 -3
- package/dist/lib/dates.js +41 -12
- package/dist/lib/dates.js.map +1 -1
- package/dist/lib/editable-content.d.ts +33 -0
- package/dist/lib/editable-content.js +15 -0
- package/dist/lib/editable-content.js.map +1 -0
- package/dist/lib/focus-left.d.ts +47 -1
- package/dist/lib/focus-left.js +11 -2
- package/dist/lib/focus-left.js.map +1 -1
- package/dist/lib/server-wake.d.ts +49 -9
- package/dist/lib/server-wake.js +25 -14
- package/dist/lib/server-wake.js.map +1 -1
- package/dist/lib/session-refresh.d.ts +53 -0
- package/dist/lib/session-refresh.js +27 -1
- package/dist/lib/session-refresh.js.map +1 -1
- package/dist/rhf/fields.js +3 -3
- package/dist/rhf/fields.js.map +1 -1
- package/dist/shell/app-shell.d.ts +25 -1
- package/dist/shell/app-shell.js +3 -1
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/dev-menu.d.ts +3 -0
- package/dist/shell/dev-menu.js +4 -2
- package/dist/shell/dev-menu.js.map +1 -1
- package/dist/shell/held-changes-banner-labels.d.ts +23 -0
- package/dist/shell/held-changes-banner-labels.js +14 -0
- package/dist/shell/held-changes-banner-labels.js.map +1 -0
- package/dist/shell/held-changes-banner.d.ts +75 -0
- package/dist/shell/held-changes-banner.js +106 -0
- package/dist/shell/held-changes-banner.js.map +1 -0
- package/dist/shell/sync-status-indicator.d.ts +27 -12
- package/dist/shell/sync-status-indicator.js +13 -4
- package/dist/shell/sync-status-indicator.js.map +1 -1
- package/dist/shell/top-bar-parts-labels.d.ts +5 -0
- package/dist/shell/top-bar-parts-labels.js +3 -1
- package/dist/shell/top-bar-parts-labels.js.map +1 -1
- package/dist/shell.d.ts +2 -0
- package/dist/shell.js +3 -0
- package/dist/shell.js.map +1 -1
- package/dist/sync/engine.d.ts +11 -2
- package/dist/sync/engine.js +13 -5
- package/dist/sync/engine.js.map +1 -1
- package/dist/sync/hooks.d.ts +3 -2
- package/dist/sync/hooks.js +4 -2
- package/dist/sync/hooks.js.map +1 -1
- package/dist/testing/css-variables.generated.d.ts +2 -2
- package/dist/testing/css-variables.generated.js +1 -1
- package/dist/testing/css-variables.generated.js.map +1 -1
- package/dist/theme/chart-palette.d.ts +18 -0
- package/dist/theme/chart-palette.js +17 -1
- package/dist/theme/chart-palette.js.map +1 -1
- package/dist/theme/contrast-tokens.d.ts +3 -3
- package/dist/theme/contrast-tokens.js.map +1 -1
- package/dist/theme/contrast.d.ts +4 -4
- package/dist/theme/contrast.js.map +1 -1
- package/dist/tour/tour-overlay.js +2 -1
- package/dist/tour/tour-overlay.js.map +1 -1
- package/package.json +5 -9
- package/tokens.css +19 -54
- package/src/account/account-parts.ts +0 -47
- package/src/account/account-settings-labels.ts +0 -240
- package/src/account/account-settings.tsx +0 -698
- package/src/account/data-export-setting-labels.ts +0 -20
- package/src/account/data-export-setting.tsx +0 -200
- package/src/account/delete-account-setting-labels.ts +0 -33
- package/src/account/delete-account-setting.tsx +0 -342
- package/src/account/email-change-setting-labels.ts +0 -31
- package/src/account/email-change-setting.tsx +0 -443
- package/src/account/passkeys-setting.tsx +0 -445
- package/src/account/sessions-setting-labels.ts +0 -24
- package/src/account/sessions-setting.tsx +0 -283
- package/src/admin/admin-action-confirm-labels.ts +0 -19
- package/src/admin/admin-action-confirm.tsx +0 -509
- package/src/admin/admin-action-log-labels.ts +0 -83
- package/src/admin/admin-action-log.tsx +0 -464
- package/src/admin/admin-area-labels.ts +0 -114
- package/src/admin/admin-forbidden.tsx +0 -75
- package/src/admin/admin-overview.tsx +0 -258
- package/src/admin/admin-parts.ts +0 -68
- package/src/admin/admin-sections.tsx +0 -208
- package/src/admin/admin-tool-links.tsx +0 -90
- package/src/admin/invitations-panel-labels.ts +0 -31
- package/src/admin/invitations-panel.tsx +0 -516
- package/src/admin/mail-test-card-labels.ts +0 -19
- package/src/admin/mail-test-card.tsx +0 -189
- package/src/admin/plan-change-labels.ts +0 -5
- package/src/admin/plan-change.tsx +0 -474
- package/src/admin/reviewer-scope-editor-labels.ts +0 -16
- package/src/admin/reviewer-scope-editor.tsx +0 -224
- package/src/admin/role-select-labels.ts +0 -16
- package/src/admin/role-select.tsx +0 -282
- package/src/admin/transfer-ownership-dialog-labels.ts +0 -20
- package/src/admin/transfer-ownership-dialog.tsx +0 -162
- package/src/admin/user-roster-labels.ts +0 -17
- package/src/admin/user-roster.tsx +0 -559
- package/src/auth/accept-invitation-labels.ts +0 -21
- package/src/auth/accept-invitation.tsx +0 -210
- package/src/auth/auth-errors-labels.ts +0 -23
- package/src/auth/auth-errors.ts +0 -439
- package/src/auth/complete-name-dialog-labels.ts +0 -16
- package/src/auth/complete-name-dialog.tsx +0 -253
- package/src/auth/email-tag.ts +0 -75
- package/src/auth/forgot-password-form-labels.ts +0 -20
- package/src/auth/forgot-password-form.tsx +0 -221
- package/src/auth/form-rules.ts +0 -40
- package/src/auth/new-password-fields.tsx +0 -85
- package/src/auth/not-found-page-labels.ts +0 -12
- package/src/auth/not-found-page.tsx +0 -95
- package/src/auth/register-form-labels.ts +0 -31
- package/src/auth/register-form.tsx +0 -456
- package/src/auth/reset-password-form-labels.ts +0 -27
- package/src/auth/reset-password-form.tsx +0 -341
- package/src/auth/sign-in-form-labels.ts +0 -44
- package/src/auth/sign-in-form.tsx +0 -858
- package/src/auth/status-parts.tsx +0 -132
- package/src/auth/verify-email-labels.ts +0 -26
- package/src/auth/verify-email.tsx +0 -445
- package/src/billing/billing-banner.tsx +0 -258
- package/src/billing/billing-labels.ts +0 -381
- package/src/billing/billing-lock.ts +0 -108
- package/src/billing/billing-overview.ts +0 -157
- package/src/billing/billing-standing.ts +0 -80
- package/src/billing/cancel-request.ts +0 -97
- package/src/billing/cancel-subscription.tsx +0 -98
- package/src/billing/checkout-processing.ts +0 -394
- package/src/billing/checkout-return.ts +0 -90
- package/src/billing/pay-page.ts +0 -330
- package/src/billing/plan-card.tsx +0 -562
- package/src/billing/plan-change-labels.ts +0 -66
- package/src/billing/plan-limit-notice.tsx +0 -148
- package/src/billing/plan-limit-toast.tsx +0 -90
- package/src/billing/plan-limit.ts +0 -52
- package/src/billing/plan-price.ts +0 -98
- package/src/billing/plan-switch.tsx +0 -216
- package/src/billing/provider-page.ts +0 -84
- package/src/billing/subscription-actions.tsx +0 -247
- package/src/billing/subscription-status-chip.tsx +0 -95
- package/src/chart.ts +0 -103
- package/src/components/account-chips-labels.ts +0 -16
- package/src/components/account-chips.tsx +0 -474
- package/src/components/alert-banner.tsx +0 -670
- package/src/components/amount-input.tsx +0 -816
- package/src/components/appearance-labels.ts +0 -63
- package/src/components/authed-image-labels.ts +0 -11
- package/src/components/authed-image.tsx +0 -209
- package/src/components/autocomplete.tsx +0 -645
- package/src/components/breadcrumbs-labels.ts +0 -10
- package/src/components/breadcrumbs.tsx +0 -205
- package/src/components/bulk-action-bar-labels.ts +0 -11
- package/src/components/bulk-action-bar.tsx +0 -443
- package/src/components/button-group.tsx +0 -223
- package/src/components/button-look.ts +0 -256
- package/src/components/button.tsx +0 -339
- package/src/components/calculator.tsx +0 -341
- package/src/components/calendar-heatmap-labels.ts +0 -15
- package/src/components/calendar-heatmap.tsx +0 -600
- package/src/components/card.tsx +0 -377
- package/src/components/chart-edge.ts +0 -106
- package/src/components/chart-figure.tsx +0 -35
- package/src/components/chart-height.ts +0 -30
- package/src/components/chart-zoom-core.tsx +0 -627
- package/src/components/chart-zoom.tsx +0 -22
- package/src/components/chart.tsx +0 -554
- package/src/components/checkbox-group.tsx +0 -247
- package/src/components/checkbox.tsx +0 -346
- package/src/components/chip-input.tsx +0 -370
- package/src/components/chip-labels.ts +0 -13
- package/src/components/chip.tsx +0 -843
- package/src/components/choice-card.tsx +0 -544
- package/src/components/column-mapper-labels.ts +0 -38
- package/src/components/column-mapper.tsx +0 -655
- package/src/components/combobox-core.tsx +0 -1321
- package/src/components/combobox-suggestions.tsx +0 -131
- package/src/components/combobox.tsx +0 -716
- package/src/components/confirm-context.ts +0 -7
- package/src/components/confirm-dialog-labels.ts +0 -13
- package/src/components/confirm-dialog.tsx +0 -341
- package/src/components/copy-button-labels.ts +0 -13
- package/src/components/copy-button.tsx +0 -192
- package/src/components/country-select-labels.ts +0 -11
- package/src/components/country-select.tsx +0 -539
- package/src/components/currency-option-list.tsx +0 -188
- package/src/components/currency-select.tsx +0 -343
- package/src/components/danger-confirm-labels.ts +0 -20
- package/src/components/danger-confirm.tsx +0 -987
- package/src/components/data-table-cells.tsx +0 -118
- package/src/components/data-table-column-settings.tsx +0 -198
- package/src/components/data-table-filter-popover.tsx +0 -289
- package/src/components/data-table-filters.ts +0 -315
- package/src/components/data-table-fit.ts +0 -301
- package/src/components/data-table-groups.tsx +0 -288
- package/src/components/data-table-head.tsx +0 -280
- package/src/components/data-table-labels.ts +0 -198
- package/src/components/data-table-leading-row.tsx +0 -58
- package/src/components/data-table-mobile.tsx +0 -1117
- package/src/components/data-table-pagination.tsx +0 -202
- package/src/components/data-table-resize.ts +0 -188
- package/src/components/data-table-row-actions.tsx +0 -302
- package/src/components/data-table-row.tsx +0 -496
- package/src/components/data-table-selection.ts +0 -71
- package/src/components/data-table-shared.tsx +0 -287
- package/src/components/data-table-sort.ts +0 -163
- package/src/components/data-table-virtual.ts +0 -576
- package/src/components/data-table.tsx +0 -2598
- package/src/components/date-field.tsx +0 -684
- package/src/components/date-format-setting.tsx +0 -64
- package/src/components/date-picker.tsx +0 -404
- package/src/components/date-range-picker.tsx +0 -518
- package/src/components/description-list-labels.ts +0 -9
- package/src/components/description-list.tsx +0 -386
- package/src/components/dialog-frame-labels.ts +0 -7
- package/src/components/dialog-frame.tsx +0 -284
- package/src/components/disclosure.tsx +0 -476
- package/src/components/dropdown.tsx +0 -461
- package/src/components/empty-state.tsx +0 -136
- package/src/components/entity-combobox.tsx +0 -422
- package/src/components/error-boundary-labels.ts +0 -20
- package/src/components/error-boundary.tsx +0 -675
- package/src/components/facing-pair.ts +0 -93
- package/src/components/field-base-labels.ts +0 -20
- package/src/components/field-base.tsx +0 -656
- package/src/components/field-parts.tsx +0 -825
- package/src/components/field-strip.tsx +0 -129
- package/src/components/field.tsx +0 -206
- package/src/components/file-button.tsx +0 -295
- package/src/components/file-dropzone.tsx +0 -559
- package/src/components/floating-panel-labels.ts +0 -10
- package/src/components/floating-panel.tsx +0 -828
- package/src/components/focus-ring.ts +0 -16
- package/src/components/form-actions-labels.ts +0 -11
- package/src/components/form-actions.tsx +0 -578
- package/src/components/full-bleed-dialog.tsx +0 -294
- package/src/components/grouped-picker.tsx +0 -184
- package/src/components/help-popover.tsx +0 -117
- package/src/components/hover-menu.tsx +0 -343
- package/src/components/iban-input-labels.ts +0 -14
- package/src/components/iban-input.tsx +0 -236
- package/src/components/icon-button.tsx +0 -959
- package/src/components/icon-picker-labels.ts +0 -13
- package/src/components/icon-picker.tsx +0 -232
- package/src/components/image-grid-labels.ts +0 -11
- package/src/components/image-grid.tsx +0 -202
- package/src/components/inline-confirm.tsx +0 -116
- package/src/components/inline-edit-field-labels.ts +0 -11
- package/src/components/inline-edit-field.tsx +0 -552
- package/src/components/inline-entity-combobox.tsx +0 -849
- package/src/components/input.tsx +0 -394
- package/src/components/jump-calendar.tsx +0 -265
- package/src/components/language-select.tsx +0 -93
- package/src/components/legal-labels.ts +0 -105
- package/src/components/legal-page.tsx +0 -711
- package/src/components/legal.tsx +0 -668
- package/src/components/lightbox-labels.ts +0 -18
- package/src/components/lightbox.tsx +0 -399
- package/src/components/line-items-labels.ts +0 -14
- package/src/components/line-items.tsx +0 -602
- package/src/components/list-labels.ts +0 -12
- package/src/components/list.tsx +0 -870
- package/src/components/loading-state.tsx +0 -78
- package/src/components/measured-grid-labels.ts +0 -25
- package/src/components/measured-grid.tsx +0 -837
- package/src/components/menu-item.tsx +0 -241
- package/src/components/mini-calendar-labels.ts +0 -17
- package/src/components/mini-calendar.tsx +0 -792
- package/src/components/modal.tsx +0 -534
- package/src/components/money-draft.ts +0 -83
- package/src/components/money-field.tsx +0 -76
- package/src/components/month-grid.tsx +0 -229
- package/src/components/month-picker-labels.ts +0 -22
- package/src/components/month-picker.tsx +0 -1087
- package/src/components/multi-entity-combobox.tsx +0 -369
- package/src/components/multi-select.tsx +0 -376
- package/src/components/nav-pills.tsx +0 -198
- package/src/components/number-field.tsx +0 -327
- package/src/components/number-input.tsx +0 -559
- package/src/components/numeric-field.ts +0 -169
- package/src/components/numpad-sheet.tsx +0 -285
- package/src/components/one-time-code-input.tsx +0 -270
- package/src/components/page-contents-labels.ts +0 -9
- package/src/components/page-contents.tsx +0 -282
- package/src/components/page-header-context.ts +0 -8
- package/src/components/page-header.tsx +0 -298
- package/src/components/password-strength-labels.ts +0 -22
- package/src/components/password-strength.tsx +0 -241
- package/src/components/phone-input-labels.ts +0 -10
- package/src/components/phone-input.tsx +0 -282
- package/src/components/picker-sheet.tsx +0 -330
- package/src/components/pie-chart-labels.ts +0 -40
- package/src/components/pie-chart.tsx +0 -480
- package/src/components/popover-labels.ts +0 -14
- package/src/components/popover.tsx +0 -268
- package/src/components/progress-bar-labels.ts +0 -10
- package/src/components/progress-bar.tsx +0 -479
- package/src/components/qr-code.tsx +0 -76
- package/src/components/reauth-dialog-labels.ts +0 -13
- package/src/components/reauth-dialog.tsx +0 -265
- package/src/components/row-actions-labels.ts +0 -12
- package/src/components/row-actions.tsx +0 -795
- package/src/components/scroll-area.tsx +0 -123
- package/src/components/search-field.tsx +0 -192
- package/src/components/select.tsx +0 -294
- package/src/components/separator.tsx +0 -33
- package/src/components/series-chart-axes.ts +0 -342
- package/src/components/series-chart-budget.ts +0 -150
- package/src/components/series-chart-labels.ts +0 -33
- package/src/components/series-chart-thin.ts +0 -180
- package/src/components/series-chart-ticks.ts +0 -194
- package/src/components/series-chart.tsx +0 -1906
- package/src/components/server-wake-labels.ts +0 -11
- package/src/components/server-wake.tsx +0 -129
- package/src/components/settings-fields.tsx +0 -237
- package/src/components/share-card-labels.ts +0 -30
- package/src/components/share-card.tsx +0 -675
- package/src/components/signature-pad-labels.ts +0 -24
- package/src/components/signature-pad.tsx +0 -747
- package/src/components/signed-amount-labels.ts +0 -10
- package/src/components/signed-amount.tsx +0 -336
- package/src/components/skeleton.tsx +0 -80
- package/src/components/slider.tsx +0 -338
- package/src/components/sparkline-labels.ts +0 -14
- package/src/components/sparkline.tsx +0 -322
- package/src/components/spinner.tsx +0 -81
- package/src/components/stat-tile-labels.ts +0 -15
- package/src/components/stat-tile.tsx +0 -754
- package/src/components/status-dot.tsx +0 -170
- package/src/components/swatch-picker-labels.ts +0 -10
- package/src/components/swatch-picker.tsx +0 -283
- package/src/components/swipeable-row.tsx +0 -386
- package/src/components/switch.tsx +0 -273
- package/src/components/table-skeleton.tsx +0 -136
- package/src/components/table.tsx +0 -647
- package/src/components/tabs-labels.ts +0 -13
- package/src/components/tabs.tsx +0 -693
- package/src/components/text-link.tsx +0 -359
- package/src/components/text.tsx +0 -150
- package/src/components/textarea.tsx +0 -330
- package/src/components/tile-radio.tsx +0 -332
- package/src/components/time-input.tsx +0 -121
- package/src/components/toast-labels.ts +0 -12
- package/src/components/toast.tsx +0 -519
- package/src/components/toggle-group.tsx +0 -752
- package/src/components/toggle-legend.tsx +0 -394
- package/src/components/tooltip.tsx +0 -1149
- package/src/components/translation-review-editor.tsx +0 -290
- package/src/components/translation-review-labels.ts +0 -181
- package/src/components/translation-review-parts.tsx +0 -272
- package/src/components/translation-review.tsx +0 -1240
- package/src/components/tree-view.tsx +0 -589
- package/src/components/treemap-labels.ts +0 -47
- package/src/components/treemap-layout.ts +0 -210
- package/src/components/treemap.tsx +0 -1184
- package/src/components/trigger-aria.ts +0 -44
- package/src/components/use-anchor-dir.ts +0 -20
- package/src/components/use-mobile-reveal.ts +0 -62
- package/src/components/use-table-state.ts +0 -753
- package/src/components/user-avatar.tsx +0 -116
- package/src/components/wizard-stepper.tsx +0 -42
- package/src/components/write-lock-labels.ts +0 -10
- package/src/components/write-lock.tsx +0 -253
- package/src/currencies.ts +0 -90
- package/src/data-table.ts +0 -42
- package/src/demo/demo-banner.tsx +0 -153
- package/src/demo/demo-countdown.ts +0 -136
- package/src/demo/demo-ended.tsx +0 -90
- package/src/demo/demo-labels.ts +0 -78
- package/src/demo/demo-session.ts +0 -32
- package/src/demo/demo-start.tsx +0 -156
- package/src/eslint/index.ts +0 -161
- package/src/eslint/role-utilities.generated.ts +0 -146
- package/src/eslint/role-utilities.ts +0 -233
- package/src/feedback/feedback-attachment-download.tsx +0 -77
- package/src/feedback/feedback-attachment-labels.ts +0 -37
- package/src/feedback/feedback-attachment.tsx +0 -1239
- package/src/feedback/feedback-capture.ts +0 -287
- package/src/feedback/feedback-comment-thread.tsx +0 -353
- package/src/feedback/feedback-context-labels.ts +0 -11
- package/src/feedback/feedback-context.tsx +0 -245
- package/src/feedback/feedback-crash.ts +0 -547
- package/src/feedback/feedback-diagnostics.tsx +0 -41
- package/src/feedback/feedback-dialog-labels.ts +0 -29
- package/src/feedback/feedback-dialog.tsx +0 -452
- package/src/feedback/feedback-entry-file.tsx +0 -150
- package/src/feedback/feedback-inbox.tsx +0 -552
- package/src/feedback/feedback-labels.ts +0 -144
- package/src/feedback/feedback-menu-labels.ts +0 -12
- package/src/feedback/feedback-menu.tsx +0 -177
- package/src/feedback/feedback-mutation.ts +0 -20
- package/src/feedback/feedback-page-link.ts +0 -90
- package/src/feedback/feedback-public-labels.ts +0 -81
- package/src/feedback/feedback-public-list.tsx +0 -524
- package/src/feedback/feedback-public-switch.tsx +0 -102
- package/src/feedback/feedback-public-types.ts +0 -101
- package/src/feedback/feedback-record.ts +0 -428
- package/src/feedback/feedback-replies-context.ts +0 -9
- package/src/feedback/feedback-replies.tsx +0 -343
- package/src/feedback/feedback-rework-entry-chip.tsx +0 -18
- package/src/feedback/feedback-row-detail-labels.ts +0 -31
- package/src/feedback/feedback-row-detail.tsx +0 -871
- package/src/feedback/feedback-status-undo.ts +0 -109
- package/src/feedback/feedback-submit-dialog.tsx +0 -131
- package/src/feedback/feedback-submit.tsx +0 -270
- package/src/feedback/feedback-swipe.tsx +0 -192
- package/src/feedback/feedback-table-labels.ts +0 -27
- package/src/feedback/feedback-table.tsx +0 -912
- package/src/feedback/feedback-thread-labels.ts +0 -22
- package/src/feedback/feedback-thread-parts-labels.ts +0 -41
- package/src/feedback/feedback-thread.tsx +0 -905
- package/src/feedback/feedback-vocabulary.ts +0 -263
- package/src/feedback/feedback-vote-button.tsx +0 -124
- package/src/feedback.ts +0 -116
- package/src/hooks/use-anchored-panel.ts +0 -396
- package/src/hooks/use-anchored-rect.ts +0 -77
- package/src/hooks/use-announce.ts +0 -85
- package/src/hooks/use-authed-src.ts +0 -167
- package/src/hooks/use-body-scroll-lock.ts +0 -119
- package/src/hooks/use-breakpoint.ts +0 -133
- package/src/hooks/use-close-transition.ts +0 -107
- package/src/hooks/use-copy-to-clipboard.ts +0 -122
- package/src/hooks/use-debounce.ts +0 -114
- package/src/hooks/use-dismiss.ts +0 -371
- package/src/hooks/use-document-title.ts +0 -33
- package/src/hooks/use-file-drop.ts +0 -121
- package/src/hooks/use-file-picker-labels.ts +0 -28
- package/src/hooks/use-file-picker.tsx +0 -359
- package/src/hooks/use-focus-trap.ts +0 -199
- package/src/hooks/use-hotkey.ts +0 -212
- package/src/hooks/use-large-text.ts +0 -41
- package/src/hooks/use-long-press.ts +0 -140
- package/src/hooks/use-media-query.ts +0 -39
- package/src/hooks/use-mounted.ts +0 -39
- package/src/hooks/use-noindex.ts +0 -37
- package/src/hooks/use-overlay-history.ts +0 -714
- package/src/hooks/use-row-swipe.ts +0 -207
- package/src/hooks/use-search-param-state.ts +0 -434
- package/src/hooks/use-windowed-rows.ts +0 -225
- package/src/i18n/defaults.ts +0 -267
- package/src/i18n/german.ts +0 -2059
- package/src/i18n/kit-labels.tsx +0 -1003
- package/src/i18n/languages.ts +0 -349
- package/src/i18n/locales/de-CH.ts +0 -24
- package/src/i18n/locales/en.ts +0 -267
- package/src/i18n/locales/es.ts +0 -1999
- package/src/i18n/locales/fr.ts +0 -2037
- package/src/i18n/locales/hu.ts +0 -2004
- package/src/i18n/locales/it.ts +0 -2014
- package/src/i18n/locales/zh.ts +0 -1912
- package/src/i18n/plurals.ts +0 -86
- package/src/i18n/review.ts +0 -475
- package/src/i18n/shared-labels.ts +0 -138
- package/src/i18n/swiss.ts +0 -29
- package/src/index.ts +0 -1191
- package/src/landing/access.ts +0 -93
- package/src/landing/landing-actions.tsx +0 -97
- package/src/landing/landing-labels.ts +0 -59
- package/src/landing/landing-sections.tsx +0 -341
- package/src/landing/page-seo.ts +0 -261
- package/src/landing/public-header.tsx +0 -121
- package/src/landing/public-page.tsx +0 -106
- package/src/landing/routing.tsx +0 -225
- package/src/lib/broadcast.ts +0 -52
- package/src/lib/calc.ts +0 -323
- package/src/lib/chip-edge-snap.ts +0 -212
- package/src/lib/clipboard-minus.ts +0 -107
- package/src/lib/clipping.ts +0 -34
- package/src/lib/cn.ts +0 -28
- package/src/lib/column-mapping.ts +0 -234
- package/src/lib/countries.ts +0 -91
- package/src/lib/data-attributes.ts +0 -14
- package/src/lib/date-format.ts +0 -227
- package/src/lib/dates.ts +0 -288
- package/src/lib/day-format.ts +0 -96
- package/src/lib/decimal-marks.ts +0 -108
- package/src/lib/describe-failure.ts +0 -18
- package/src/lib/device-settings.ts +0 -147
- package/src/lib/direction.ts +0 -74
- package/src/lib/document-navigation.ts +0 -17
- package/src/lib/document-title.ts +0 -41
- package/src/lib/download.ts +0 -172
- package/src/lib/float-clearance.ts +0 -70
- package/src/lib/floating-stack.ts +0 -70
- package/src/lib/focus-left.ts +0 -156
- package/src/lib/format.ts +0 -585
- package/src/lib/http-status.ts +0 -38
- package/src/lib/iban.ts +0 -251
- package/src/lib/ime.ts +0 -24
- package/src/lib/intl-cache.ts +0 -27
- package/src/lib/iso-day.ts +0 -13
- package/src/lib/lazy-with-fallback.ts +0 -82
- package/src/lib/logger.ts +0 -69
- package/src/lib/minus.ts +0 -50
- package/src/lib/path-pattern.ts +0 -55
- package/src/lib/person-name.ts +0 -155
- package/src/lib/phone.ts +0 -208
- package/src/lib/plain-text.ts +0 -22
- package/src/lib/presence.ts +0 -18
- package/src/lib/qr-encode.ts +0 -444
- package/src/lib/quiet-focus.ts +0 -32
- package/src/lib/reduced-motion.ts +0 -22
- package/src/lib/refs.ts +0 -22
- package/src/lib/round.ts +0 -43
- package/src/lib/safe-storage.ts +0 -119
- package/src/lib/server-wake.ts +0 -315
- package/src/lib/session-refresh.ts +0 -472
- package/src/lib/share-format.ts +0 -18
- package/src/lib/status-tone.ts +0 -43
- package/src/lib/strip-fade.ts +0 -287
- package/src/lib/table-text.ts +0 -554
- package/src/lib/text-case.ts +0 -19
- package/src/lib/text-match.ts +0 -169
- package/src/lib/thenable.ts +0 -19
- package/src/lib/translation-review.ts +0 -769
- package/src/notifications/device-zone-report.ts +0 -67
- package/src/notifications/feedback-notification-types-labels.ts +0 -33
- package/src/notifications/feedback-notification-types.ts +0 -71
- package/src/notifications/notification-bell.tsx +0 -119
- package/src/notifications/notification-inbox.tsx +0 -309
- package/src/notifications/notification-parts.tsx +0 -81
- package/src/notifications/notification-types-setting.tsx +0 -406
- package/src/notifications/notification-types.ts +0 -89
- package/src/notifications/notifications-labels.ts +0 -287
- package/src/notifications/push-device-setting.tsx +0 -230
- package/src/notifications/push-devices-setting.tsx +0 -374
- package/src/notifications/push-worker.ts +0 -168
- package/src/notifications/quiet-hours-setting.tsx +0 -238
- package/src/notifications/unsubscribe-panel.tsx +0 -200
- package/src/notifications/use-push-device.ts +0 -448
- package/src/offline/local-first.ts +0 -100
- package/src/offline/pwa-update-prompt-labels.ts +0 -9
- package/src/offline/pwa-update-prompt.tsx +0 -78
- package/src/offline/query-persistence.ts +0 -391
- package/src/offline/service-worker-updates.ts +0 -81
- package/src/offline/shared-computer-labels.ts +0 -8
- package/src/offline/shared-computer.tsx +0 -87
- package/src/offline/sign-out-pending-dialog-labels.ts +0 -21
- package/src/offline/sign-out-pending-dialog.tsx +0 -135
- package/src/offline.ts +0 -37
- package/src/push-worker.ts +0 -25
- package/src/rhf/fields.tsx +0 -2187
- package/src/rhf/form-core.tsx +0 -324
- package/src/rhf/form.tsx +0 -12
- package/src/rhf/line-items.tsx +0 -135
- package/src/rhf/use-rhf-wizard-step.ts +0 -104
- package/src/rhf.ts +0 -21
- package/src/search/command-palette-labels.ts +0 -16
- package/src/search/command-palette.tsx +0 -624
- package/src/search/global-search-labels.ts +0 -13
- package/src/search/global-search.tsx +0 -660
- package/src/search/search-index.ts +0 -283
- package/src/search/use-command-key.ts +0 -23
- package/src/search.ts +0 -14
- package/src/settings/device-reset-setting-labels.ts +0 -20
- package/src/settings/device-reset-setting.tsx +0 -116
- package/src/settings/settings-card-classes.ts +0 -11
- package/src/settings/settings-catalogue.ts +0 -150
- package/src/settings/settings-context.ts +0 -33
- package/src/settings/settings-heading.tsx +0 -67
- package/src/settings/settings-labels.ts +0 -87
- package/src/settings/settings-layout.tsx +0 -471
- package/src/settings/settings-section.tsx +0 -108
- package/src/settings/use-account-appearance.ts +0 -148
- package/src/settings/use-account-language.ts +0 -146
- package/src/settings/use-settings-focus.ts +0 -128
- package/src/settings/use-settings-route.ts +0 -258
- package/src/shell/account-menu-language.tsx +0 -130
- package/src/shell/account-menu-text-size.tsx +0 -80
- package/src/shell/admin-menu.tsx +0 -183
- package/src/shell/app-shell-labels.ts +0 -11
- package/src/shell/app-shell.tsx +0 -1560
- package/src/shell/auth-layout.tsx +0 -186
- package/src/shell/company-switcher-labels.ts +0 -13
- package/src/shell/company-switcher.tsx +0 -136
- package/src/shell/dev-menu.tsx +0 -257
- package/src/shell/fill-height.tsx +0 -45
- package/src/shell/language-code.ts +0 -5
- package/src/shell/option-switcher-menu.tsx +0 -84
- package/src/shell/sync-status-indicator.tsx +0 -303
- package/src/shell/top-bar-actions.tsx +0 -87
- package/src/shell/top-bar-brand.tsx +0 -78
- package/src/shell/top-bar-parts-labels.ts +0 -148
- package/src/shell/top-bar.tsx +0 -40
- package/src/shell/topbar-action-menu.tsx +0 -567
- package/src/shell/topbar-controls.tsx +0 -269
- package/src/shell/tour-menu.tsx +0 -187
- package/src/shell.ts +0 -108
- package/src/sync/db.ts +0 -129
- package/src/sync/engine.ts +0 -1011
- package/src/sync/hooks.ts +0 -98
- package/src/sync/testing.ts +0 -73
- package/src/sync/wire.ts +0 -61
- package/src/sync.ts +0 -37
- package/src/table-text.ts +0 -8
- package/src/testing/css-variables.generated.ts +0 -112
- package/src/testing/css-variables.ts +0 -189
- package/src/testing/index.ts +0 -29
- package/src/testing/react.ts +0 -58
- package/src/testing/tour.ts +0 -41
- package/src/testing/viewport.ts +0 -357
- package/src/theme/chart-palette.ts +0 -232
- package/src/theme/color.ts +0 -272
- package/src/theme/contrast-tokens.ts +0 -268
- package/src/theme/contrast.ts +0 -250
- package/src/theme/palette-derive.ts +0 -825
- package/src/theme/palette-presets.ts +0 -544
- package/src/theme/palette-store.ts +0 -108
- package/src/theme/text-size.ts +0 -289
- package/src/theme/theme-store.ts +0 -157
- package/src/tour/tour-catalogue-labels.ts +0 -75
- package/src/tour/tour-catalogue.tsx +0 -335
- package/src/tour/tour-dock.ts +0 -134
- package/src/tour/tour-engine.ts +0 -37
- package/src/tour/tour-gates.ts +0 -218
- package/src/tour/tour-guide-button.tsx +0 -64
- package/src/tour/tour-guide-labels.ts +0 -15
- package/src/tour/tour-info.ts +0 -144
- package/src/tour/tour-labels.ts +0 -23
- package/src/tour/tour-overlay.tsx +0 -1170
- package/src/tour/tour.tsx +0 -750
- package/src/tour/use-tour-progress.ts +0 -671
- package/src/tour/use-tour-url-sync.ts +0 -266
- package/src/tour.ts +0 -21
- package/src/vite-env.d.ts +0 -23
- package/src/wizard/stepper-nav.tsx +0 -360
- package/src/wizard/types.ts +0 -275
- package/src/wizard/use-wizard.ts +0 -560
- package/src/wizard/validation.ts +0 -39
- package/src/wizard/wizard-context.tsx +0 -74
- package/src/wizard/wizard-labels.ts +0 -29
- package/src/wizard/wizard-step.tsx +0 -76
- package/src/wizard/wizard-summary.tsx +0 -84
- package/src/wizard.ts +0 -15
|
@@ -7,6 +7,7 @@ import { anchoredInline, useAnchoredPanel } from "../hooks/use-anchored-panel.js
|
|
|
7
7
|
import { pressInside, runOwnKeyDown, takeEscape, useDismissLayer, useOutsideClick } from "../hooks/use-dismiss.js";
|
|
8
8
|
import { useOverlayHistory } from "../hooks/use-overlay-history.js";
|
|
9
9
|
import { cn } from "../lib/cn.js";
|
|
10
|
+
import { returnFocus } from "../lib/focus-left.js";
|
|
10
11
|
import { FIELD_TOUCH_TEXT } from "./field-base.js";
|
|
11
12
|
import { mergeRefs } from "./field-parts.js";
|
|
12
13
|
import { FOCUS_RING } from "./focus-ring.js";
|
|
@@ -23,15 +24,18 @@ function useDropdown({
|
|
|
23
24
|
const panelRef = useRef(null);
|
|
24
25
|
const openerRef = useRef(null);
|
|
25
26
|
useEffect(() => {
|
|
26
|
-
if (!open)
|
|
27
|
+
if (!open) {
|
|
28
|
+
openerRef.current = null;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
27
31
|
const el = document.activeElement;
|
|
28
32
|
openerRef.current = el instanceof HTMLElement && el !== document.body ? el : null;
|
|
29
33
|
}, [open]);
|
|
30
34
|
const close = useCallback(() => setOpen(false), []);
|
|
31
35
|
const closeToTrigger = useCallback(() => {
|
|
36
|
+
const closing = panelRef.current ?? wrapperRef.current;
|
|
37
|
+
returnFocus({ opener: triggerRef.current, fallback: [openerRef.current], closing });
|
|
32
38
|
setOpen(false);
|
|
33
|
-
const back = triggerRef.current ?? openerRef.current;
|
|
34
|
-
if (back?.isConnected) back.focus();
|
|
35
39
|
}, []);
|
|
36
40
|
useOutsideClick([wrapperRef, panelRef], close, open && !panelIsSheet);
|
|
37
41
|
const layer = useDismissLayer(open && escapeLayer, closeToTrigger);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/dropdown.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n ComponentPropsWithoutRef,\n ComponentPropsWithRef,\n KeyboardEvent as ReactKeyboardEvent,\n PointerEvent as ReactPointerEvent,\n ReactNode,\n Ref,\n RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Search } from \"lucide-react\";\nimport { anchoredInline, useAnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { pressInside, runOwnKeyDown, takeEscape, useDismissLayer, useOutsideClick } from \"../hooks/use-dismiss\";\nimport type { DismissLayer } from \"../hooks/use-dismiss\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { cn } from \"../lib/cn\";\nimport { FIELD_TOUCH_TEXT } from \"./field-base\";\nimport { mergeRefs } from \"./field-parts\";\nimport { FOCUS_RING } from \"./focus-ring\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\n\n/** Each list's Escape layer, filed under the refs {@link useDropdown} and\n * {@link useDropdownSearch} hand out (`panelRef`, `inputRef`), for the panel and the\n * search box those refs are passed to — see \"The caller's own handler\" on\n * {@link useDropdown} (round 0.35 R2). Weak: a list's refs go with its component. */\nconst listLayers = new WeakMap<object, DismissLayer>();\n\n/**\n * Open state + close-on-outside-click for a custom dropdown — the two input-shaped\n * comboboxes, and an app's own panel. (MultiSelect, CurrencySelect, GroupedPicker and\n * AmountInput's currency picker moved onto `useComboboxCore` + `ComboboxPanel` in round\n * 0.34, Wave 2 DUP-4, for the phone sheet and the portal.) Attach `wrapperRef`\n * to the relatively-positioned container; the popover lives inside it so a click\n * anywhere else closes it.\n *\n * ## Back closes the list, not the page behind it\n *\n * Keksdose live #309 rework: *\"It shall only close it if it is prior open, and not\n * when I am seeing the dialog.\"* Round one wired {@link PickerSheet} — the shape\n * these lists take on a PHONE — into {@link useOverlayHistory}, and left the pointer\n * shape out. So on a desktop one Back press over an open list still went past it to\n * the dialog underneath: measured on his own budget, the transfer form's account list\n * was showing and Back took the entire add card, amount and all. That is the same\n * loss round one called *\"discarding an edit in progress in order to dismiss a\n * list\"*, in the other shell.\n *\n * Every dropdown built on this hook is dismissible and is the topmost thing on screen\n * while it is up, so the rule is the hook's rather than each caller's. `backCloses`\n * is for the ONE case where a second entry would be wrong: a caller whose panel is\n * itself a `PickerSheet`, which already registers one — both comboboxes swap shape at\n * the phone layout (`usePhoneLayout()`), and two entries would cost two Back presses to close one sheet.\n *\n * ## One outside-click rule for the whole package\n *\n * This hand-rolled a second document listener, on `mousedown`, months after\n * {@link useOutsideClick} — the hook the entity pickers dismiss through — was moved to\n * `pointerdown` for a reason that applies here word for word: on a touch platform\n * `mousedown` is SYNTHESISED, the browser emits it for most taps but is not obliged\n * to, and MultiSelect, CurrencySelect, GroupedPicker, AmountInput's currency picker\n * and both comboboxes all dismiss through this. Two copies of one rule is one copy\n * too many; this now delegates, so the package has a single answer to \"what is an\n * outside press\".\n *\n * `panelIsSheet` is what that delegation needs. A {@link PickerSheet} is modal and\n * fills the screen, so it has no outside — and being portalled to `<body>`, it is\n * inside neither `wrapperRef` nor `panelRef`, so a listener left running would read\n * every tap in it as a press outside and close it at finger-down. The sheet's own\n * `onMouseDown` stopPropagation guard used to hide that from this hook; it cannot\n * stop a `pointerdown`. It defaults to `!backCloses` because the two ask the same\n * question — \"is this caller's panel a sheet?\" — and the one caller that answers yes\n * already says so; they are separate props so a future caller can answer them apart.\n *\n * ## Escape, and where focus lands after it\n *\n * This hook had no Escape at all (the audit's §a11y): Back closed these lists, an\n * outside press closed them, and the one key every other dismissible surface in the\n * package answers to did nothing — so a keyboard user who opened a list had no way\n * out of it that did not also choose something. An open list is a layer on the kit's\n * one Escape stack ({@link useDismissLayer}), as `Modal`, `Popover` and\n * `useComboboxCore` are, so the package keeps one answer to \"what does Escape do\".\n *\n * Escape RESTORES FOCUS; an outside press does not. A press has already put focus\n * where the user pointed, and dragging it back from there would be the bug. Attach\n * `triggerRef` to the control that opens the panel and the keyboard paths — Escape,\n * Tab, a commit — hand focus back to it; leave it unattached and they hand it back to\n * whatever held focus when the list opened, which is the control that was pressed.\n *\n * ## Escape inside a dialog (round 0.34 BUG-1, Wave 2 DUP-1)\n *\n * One press in an open list inside a `Modal` or a `FullBleedDialog` used to close the\n * DIALOG, form and all, and leave the list open: the dialog took Escape in its own\n * `onKeyDown` before a document listener could. On the stack the list is above the\n * dialog, so the list closes and the dialog stays. {@link DropdownPanel} and\n * {@link DropdownSearchHeader} take the key on their own elements, where focus is,\n * and stop it there — so a caller passes nothing new, AmountInput's currency chip\n * included.\n *\n * ## The caller's own handler (round 0.35 R2)\n *\n * A caller's `onKeyDown` on {@link DropdownPanel} or {@link DropdownSearchHeader} hears\n * Escape only while this list is the layer on top — the rule the dialogs got first. A\n * tooltip over a row takes that press first, and the next one is the handler's, whose\n * `preventDefault()` still keeps the list. The two find the list's layer through the\n * refs this hook hands out — the panel through `panelRef`, the search box through\n * {@link useDropdownSearch}'s `inputRef` — so a caller passes nothing new. One handed\n * neither (an un-anchored panel may leave `panelRef` off) hears every key, as before.\n *\n * `escapeLayer: false` is for a caller that registers its own layer: the editable\n * comboboxes, whose list can be \"open\" with nothing in it to show — an Escape there\n * belongs to the dialog.\n */\nexport function useDropdown<T extends HTMLElement = HTMLDivElement>({\n backCloses = true,\n panelIsSheet = !backCloses,\n escapeLayer = true,\n}: { backCloses?: boolean; panelIsSheet?: boolean; escapeLayer?: boolean } = {}) {\n const [open, setOpen] = useState(false);\n const wrapperRef = useRef<T>(null);\n // The control that opens the panel — see the note above on why only the keyboard\n // paths read it, and why attaching it is the caller's choice.\n const triggerRef = useRef<HTMLButtonElement>(null);\n // The panel, once it is PORTALLED (see {@link DropdownPanel}'s `anchorRef`): it is\n // then a child of <body> rather than of the wrapper, so \"did the click land inside\n // the wrapper\" answers no for every click on the list itself and the first option a\n // user picked closed the dropdown without picking anything.\n const panelRef = useRef<HTMLDivElement>(null);\n // Where focus was as the list opened — the trigger focus goes back to when the\n // caller attached none. Read in an effect, before `useDropdownSearch`'s frame moves\n // focus into the search box.\n const openerRef = useRef<HTMLElement | null>(null);\n useEffect(() => {\n if (!open) return;\n const el = document.activeElement;\n openerRef.current = el instanceof HTMLElement && el !== document.body ? el : null;\n }, [open]);\n const close = useCallback(() => setOpen(false), []);\n // Closing unmounts whatever held focus — the search box, the row the keyboard was\n // on — and the browser then drops focus on <body>: the caret vanishes and the next\n // Tab restarts at the top of the document, and inside a dialog the next Escape goes\n // nowhere. Whoever closed the list with a key gets focus handed back to the trigger\n // they opened it from.\n const closeToTrigger = useCallback(() => {\n setOpen(false);\n const back = triggerRef.current ?? openerRef.current;\n if (back?.isConnected) back.focus();\n }, []);\n useOutsideClick([wrapperRef, panelRef], close, open && !panelIsSheet);\n // See \"Escape inside a dialog\" above.\n const layer = useDismissLayer(open && escapeLayer, closeToTrigger);\n // Filed under `panelRef` for the panel's own handler — \"The caller's own handler\" above.\n useEffect(() => {\n listLayers.set(panelRef, layer);\n }, [panelRef, layer]);\n // Same close path Escape and an outside click take, so a list dismissed by Back\n // cannot end up in a different state from one dismissed any other way.\n useOverlayHistory(open && backCloses, close);\n return { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger };\n}\n\n/**\n * {@link useDropdown} plus a search box: clears the query and focuses the search\n * input each time the panel opens, so typing filters immediately.\n */\nexport function useDropdownSearch<T extends HTMLElement = HTMLDivElement>() {\n const { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger } = useDropdown<T>();\n const [query, setQuery] = useState(\"\");\n const inputRef = useRef<HTMLInputElement>(null);\n // The list's layer again, under `inputRef` for the search box's handler (round 0.35\n // R2). `useDropdown`'s effect, which runs first, has filed it under `panelRef`.\n useEffect(() => {\n const layer = listLayers.get(panelRef);\n if (layer) listLayers.set(inputRef, layer);\n }, [panelRef]);\n useEffect(() => {\n if (open) {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- reset the query on open\n setQuery(\"\");\n requestAnimationFrame(() => inputRef.current?.focus());\n }\n }, [open]);\n return {\n open,\n setOpen,\n wrapperRef,\n panelRef,\n triggerRef,\n closeToTrigger,\n query,\n setQuery,\n inputRef,\n };\n}\n\n/** `onKeyDown` is the INPUT's, not the wrapper's — the list's keyboard is handled\n * where the focus is (see the note above), so the div's own handler signature is\n * omitted in favour of it. */\nexport interface DropdownSearchHeaderProps extends Omit<ComponentPropsWithRef<\"div\">, \"onKeyDown\"> {\n query: string;\n onQueryChange: (v: string) => void;\n inputRef: RefObject<HTMLInputElement | null>;\n placeholder?: string;\n /** The `<ul role=\"listbox\">` this box filters. */\n listboxId?: string;\n /** The id of the option the arrow keys are currently on, if any. */\n activeId?: string;\n /** Arrow/Home/End/Enter/Tab — the list's keyboard, handled where the focus is.\n * Escape closes the list (the topmost layer on the kit's Escape stack); call\n * `preventDefault()` on it here to keep it. */\n onKeyDown?: (e: ReactKeyboardEvent<HTMLInputElement>) => void;\n}\n\n/** The search row (magnifier + text input) shared by the searchable dropdowns.\n *\n * The input had `outline-none` and nothing in its place (the audit's §a11y, the same\n * finding as the numpad's keys). That mattered more here than the bare class suggests:\n * {@link useDropdownSearch} focuses this box the moment a panel opens, so the caret is\n * the ONLY evidence of where the next keystroke goes — and a caret in an empty field\n * showing a placeholder is a single blinking pixel column. The ring is what says \"this\n * list is being typed into\"; it appears whenever the field holds focus, which for a\n * text input is exactly when it is true.\n *\n * ## Why this box is a plain textbox and the TRIGGER is the combobox\n *\n * The panels this header sits in are opened by a field-shaped trigger, and that\n * trigger is what carries `role=\"combobox\"` (see {@link MultiSelect},\n * {@link EntityCombobox}). Two comboboxes for one list would be one too many — a\n * reader tabbing back to the field would meet a second one describing the same\n * choice. So this stays a textbox, which ARIA lets own `aria-activedescendant` and\n * `aria-controls` exactly as a combobox does: focus is HERE while the list is up, so\n * this is what has to say which option the arrow keys are on.\n *\n * Pass `listboxId` and the wiring appears; omit it and the box is what it always\n * was, for the callers that have no listbox to point at. */\nexport function DropdownSearchHeader({\n query,\n onQueryChange,\n inputRef,\n placeholder,\n listboxId,\n activeId,\n onKeyDown,\n \"aria-label\": ariaLabel,\n className,\n ...rest\n}: DropdownSearchHeaderProps) {\n return (\n // `rest` dresses the header row; the NAME goes on the box below it. A search\n // input whose only name is its placeholder has none the moment a character is\n // typed into it — the placeholder disappears — which is why this is worth a prop\n // at all rather than something a caller could add from outside.\n <div {...rest} className={cn(\"flex items-center gap-2 border-b border-subtle px-2 py-1.5\", className)}>\n <Search className=\"size-4 text-placeholder\" />\n <input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={(e) => onQueryChange(e.target.value)}\n onKeyDown={(e) => {\n // The caller's handler hears Escape only while the list is on top (round 0.35\n // R2) — the layer filed under `inputRef`, when {@link useDropdownSearch} made it.\n runOwnKeyDown(e, onKeyDown, listLayers.get(inputRef));\n // Focus is in this box while the list is up, so this is where Escape lands\n // first — see \"Escape inside a dialog\" on {@link useDropdown}.\n takeEscape(e);\n }}\n placeholder={placeholder}\n aria-label={ariaLabel}\n aria-controls={listboxId}\n aria-activedescendant={activeId}\n aria-autocomplete={listboxId ? \"list\" : undefined}\n // FIELD_TOUCH_TEXT: a search box is a field — at least 16 px on touch, or iOS zooms\n // the page the moment a picker opens and focuses it (§10.1).\n className={cn(\n \"w-full rounded-sm bg-transparent text-sm outline-none placeholder:text-placeholder text-primary\",\n FOCUS_RING,\n FIELD_TOUCH_TEXT,\n )}\n />\n </div>\n );\n}\n\nexport interface DropdownPanelProps extends ComponentPropsWithoutRef<\"div\"> {\n header?: ReactNode;\n empty?: boolean;\n /** Attributes for the `<ul>` itself — how a caller whose children are options\n * gives the list its `role=\"listbox\"`, its id and `aria-multiselectable`. The\n * panel owns the scrolling and the padding, so `className` here is merged rather\n * than replaced. */\n listProps?: ComponentPropsWithoutRef<\"ul\">;\n /** The trigger to hang off. Given, the panel portals and goes `fixed`. */\n anchorRef?: RefObject<HTMLElement | null>;\n /** {@link useDropdown}'s `panelRef`, so an outside-click sees this as inside. Escape\n * anywhere in the panel, on a row as in the search box, closes the list rather than\n * a dialog around it. It is also how the panel finds the list's Escape layer, for\n * its `onKeyDown` (round 0.35 R2: see \"The caller's own handler\" there). */\n panelRef?: RefObject<HTMLDivElement | null>;\n /** Panel width in px, for the anchored form (the CSS `w-*` cannot be measured). */\n width?: number;\n /** Which of the panel's edges lines up with the trigger's, room permitting, by the\n * trigger's reading direction — `end` is the right edge in a left-to-right form and\n * the left one in a right-to-left form. Default `end`. The physical `left` / `right`\n * went in 0.35 (round 0.35 R1, refactor audit 2026-10, API-6e): `right` is `end` in a\n * left-to-right page, `left` is `start`. */\n align?: \"start\" | \"end\";\n children: ReactNode;\n /** The panel, where the rest of the props go (0.34, API-2, refactor audit 2026-10) —\n * merged with `panelRef`, so the outside-click still sees it. */\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * The floating popover surface for the searchable dropdowns: bordered/shadowed\n * panel, an optional `header` slot (search box, plus any actions), and a\n * scrollable `<ul>` of `children` with an \"empty\" row when nothing matches.\n *\n * ## Anchored, or merely absolute\n *\n * Without `anchorRef` the panel is `position: absolute` inside whatever relative box\n * the caller put it in, and the caller places it with `className` (`w-64`,\n * `end-0 top-full`). That is fine in a page that does not scroll around it, and\n * wrong the moment an ancestor has `overflow` — the panel is then CLIPPED by that\n * ancestor's box, with no error and no scrollbar, just a list with its side sliced\n * off. Keksdose dev#548 is what that looks like in practice: the app's own content\n * scroller starts 280px from the left, the amount field's currency picker opens\n * right-aligned and 256px wide, and in the transaction row editor its left third —\n * the search box's first letter, and every row's currency symbol — was cut away.\n *\n * With `anchorRef` the panel is PORTALLED to `<body>` and positioned `fixed` against\n * that trigger's rect, so no ancestor can clip it: the same treatment {@link Popover}\n * already gives the calculator, and the same reason. It re-aligns on scroll and\n * resize, flips above the trigger when the room is there instead (a phone keyboard\n * eats the bottom of the screen), and is clamped to the viewport's edges so a trigger\n * near either side cannot push it off-screen.\n *\n * Pass `panelRef` from {@link useDropdown} along with it: once portalled the panel is\n * no longer inside the wrapper, so the outside-click handler has to be told about it\n * or the first click on an option closes the list instead of choosing from it.\n */\nexport function DropdownPanel({\n header,\n empty,\n className,\n listProps,\n anchorRef,\n panelRef,\n width = 256,\n align = \"end\",\n children,\n style,\n onKeyDown,\n ref,\n ...rest\n}: DropdownPanelProps) {\n const setPanel = useMemo(() => mergeRefs(panelRef, ref), [panelRef, ref]);\n const anchored = useAnchoredPanel(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n const dir = useAnchorDir(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n // A row the keyboard reached by Tab holds focus too, and its Escape has to close the\n // list as the search box's does (BUG-1). The caller's handler first, as everywhere.\n const handleKeyDown = (e: ReactKeyboardEvent<HTMLDivElement>) => {\n // It hears Escape only while the list is on top, a tooltip over a row taking the\n // press first (round 0.35 R2) — the layer filed under `panelRef`, when handed one.\n runOwnKeyDown(e, onKeyDown, panelRef && listLayers.get(panelRef));\n takeEscape(e);\n };\n // A press in a panel opened from a row (a popover, its lists) is inside the list for\n // `useDropdown`'s outside press, though portalled elsewhere (dev#623).\n const markInside = pressInside(panelRef);\n const handlePointerDownCapture = (e: ReactPointerEvent<HTMLDivElement>) => {\n rest.onPointerDownCapture?.(e);\n markInside?.(e);\n };\n const body = (\n <>\n {header}\n {/* The anchored form caps its own height against the VISIBLE viewport and lets\n this list have the rest; the absolute form keeps the fixed `max-h-64` it has\n always had, applied by the wrapper below. */}\n <ul {...listProps} className={cn(\"overflow-y-auto py-1\", listProps?.className)}>\n {children}\n {/* `presentation`, so that a caller who made this list a `listbox` does not\n end up with one child that is not an option. The em dash still reads — it\n is the row's semantics that are dropped, not its text. */}\n {empty && (\n <li role=\"presentation\" className=\"px-3 py-2 text-sm text-muted\">\n —\n </li>\n )}\n </ul>\n </>\n );\n\n if (!anchorRef) {\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused itself: it catches Escape bubbling from the search box or a row inside it.\n <div\n {...rest}\n style={style}\n ref={setPanel}\n onKeyDown={handleKeyDown}\n onPointerDownCapture={handlePointerDownCapture}\n className={cn(\n \"absolute z-30 mt-1 rounded-md border border-subtle bg-surface shadow-lg\",\n \"[&>ul]:max-h-64\",\n className,\n )}\n >\n {body}\n </div>\n );\n }\n\n const rect = anchored.rect;\n if (!rect) return null;\n // Clamped to the glass as `Popover` is (Wave 2, DUP-7): the panel may leave the\n // trigger's edge to stay on screen, because a list half off the viewport is the bug\n // this exists for. The portal leaves the subtree the trigger's `dir` came from, so it\n // is read off the trigger — for the alignment here, and for the panel's own `dir`\n // below, without which a right-to-left form got a left-to-right list.\n const { left } = anchoredInline(rect, width, { dir, align });\n return createPortal(\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused itself: it catches Escape bubbling from the search box or a row inside it.\n <div\n {...rest}\n ref={setPanel}\n // A kit layer, for the tour's layer order (0.50, docs/tours-harmonization.md §11.6).\n data-kit-layer=\"\"\n dir={dir}\n onKeyDown={handleKeyDown}\n onPointerDownCapture={handlePointerDownCapture}\n // The caller's `style` is kept underneath, but the placement is measured rather\n // than chosen (dev#548: an `overflow` ancestor clipped a third of this panel\n // away), so these values are the panel's own. Flipped above, it hangs from its\n // bottom edge, so a list shorter than its cap still meets the trigger (keksdose\n // K1); the edge not in use is cleared, a caller's included.\n style={{\n ...style,\n position: \"fixed\",\n top: anchored.above ? undefined : anchored.top,\n bottom: anchored.above ? anchored.bottom : undefined,\n left,\n width,\n maxHeight: anchored.maxHeight,\n }}\n className={cn(\n \"z-50 flex flex-col overflow-hidden rounded-md border border-subtle bg-surface shadow-lg\",\n // The list, not the panel, is what scrolls: the search header has to stay put\n // while the options move under it.\n \"[&>ul]:min-h-0 [&>ul]:flex-1\",\n className,\n )}\n >\n {body}\n </div>,\n document.body,\n );\n}\n\n/** A ref that is always null, for the un-anchored form — hooks may not be conditional. */\nconst EMPTY_REF: RefObject<HTMLElement | null> = { current: null };\n"],"mappings":";AA2PI,SA2HA,UA1HE,KADF;AA3PJ,SAAS,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AAUlE,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,aAAa,eAAe,YAAY,iBAAiB,uBAAuB;AAEzF,SAAS,yBAAyB;AAClC,SAAS,UAAU;AACnB,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAM7B,MAAM,aAAa,oBAAI,QAA8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,UACV,KAAK,SAAS,QAAQ,SAAY,SAAS;AAAA,UAC3C,QAAQ,SAAS,QAAQ,SAAS,SAAS;AAAA,UAC3C;AAAA,UACA;AAAA,UACA,WAAW,SAAS;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACT;AAAA;AAAA;AAAA,UAGA;AAAA,UACA;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAGA,MAAM,YAA2C,EAAE,SAAS,KAAK;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/dropdown.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n ComponentPropsWithoutRef,\n ComponentPropsWithRef,\n KeyboardEvent as ReactKeyboardEvent,\n PointerEvent as ReactPointerEvent,\n ReactNode,\n Ref,\n RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Search } from \"lucide-react\";\nimport { anchoredInline, useAnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { pressInside, runOwnKeyDown, takeEscape, useDismissLayer, useOutsideClick } from \"../hooks/use-dismiss\";\nimport type { DismissLayer } from \"../hooks/use-dismiss\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { cn } from \"../lib/cn\";\nimport { returnFocus } from \"../lib/focus-left\";\nimport { FIELD_TOUCH_TEXT } from \"./field-base\";\nimport { mergeRefs } from \"./field-parts\";\nimport { FOCUS_RING } from \"./focus-ring\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\n\n/** Each list's Escape layer, filed under the refs {@link useDropdown} and\n * {@link useDropdownSearch} hand out (`panelRef`, `inputRef`), for the panel and the\n * search box those refs are passed to — see \"The caller's own handler\" on\n * {@link useDropdown} (round 0.35 R2). Weak: a list's refs go with its component. */\nconst listLayers = new WeakMap<object, DismissLayer>();\n\n/**\n * Open state + close-on-outside-click for a custom dropdown — the two input-shaped\n * comboboxes, and an app's own panel. (MultiSelect, CurrencySelect, GroupedPicker and\n * AmountInput's currency picker moved onto `useComboboxCore` + `ComboboxPanel` in round\n * 0.34, Wave 2 DUP-4, for the phone sheet and the portal.) Attach `wrapperRef`\n * to the relatively-positioned container; the popover lives inside it so a click\n * anywhere else closes it.\n *\n * ## Back closes the list, not the page behind it\n *\n * Keksdose live #309 rework: *\"It shall only close it if it is prior open, and not\n * when I am seeing the dialog.\"* Round one wired {@link PickerSheet} — the shape\n * these lists take on a PHONE — into {@link useOverlayHistory}, and left the pointer\n * shape out. So on a desktop one Back press over an open list still went past it to\n * the dialog underneath: measured on his own budget, the transfer form's account list\n * was showing and Back took the entire add card, amount and all. That is the same\n * loss round one called *\"discarding an edit in progress in order to dismiss a\n * list\"*, in the other shell.\n *\n * Every dropdown built on this hook is dismissible and is the topmost thing on screen\n * while it is up, so the rule is the hook's rather than each caller's. `backCloses`\n * is for the ONE case where a second entry would be wrong: a caller whose panel is\n * itself a `PickerSheet`, which already registers one — both comboboxes swap shape at\n * the phone layout (`usePhoneLayout()`), and two entries would cost two Back presses to close one sheet.\n *\n * ## One outside-click rule for the whole package\n *\n * This hand-rolled a second document listener, on `mousedown`, months after\n * {@link useOutsideClick} — the hook the entity pickers dismiss through — was moved to\n * `pointerdown` for a reason that applies here word for word: on a touch platform\n * `mousedown` is SYNTHESISED, the browser emits it for most taps but is not obliged\n * to, and MultiSelect, CurrencySelect, GroupedPicker, AmountInput's currency picker\n * and both comboboxes all dismiss through this. Two copies of one rule is one copy\n * too many; this now delegates, so the package has a single answer to \"what is an\n * outside press\".\n *\n * `panelIsSheet` is what that delegation needs. A {@link PickerSheet} is modal and\n * fills the screen, so it has no outside — and being portalled to `<body>`, it is\n * inside neither `wrapperRef` nor `panelRef`, so a listener left running would read\n * every tap in it as a press outside and close it at finger-down. The sheet's own\n * `onMouseDown` stopPropagation guard used to hide that from this hook; it cannot\n * stop a `pointerdown`. It defaults to `!backCloses` because the two ask the same\n * question — \"is this caller's panel a sheet?\" — and the one caller that answers yes\n * already says so; they are separate props so a future caller can answer them apart.\n *\n * ## Escape, and where focus lands after it\n *\n * This hook had no Escape at all (the audit's §a11y): Back closed these lists, an\n * outside press closed them, and the one key every other dismissible surface in the\n * package answers to did nothing — so a keyboard user who opened a list had no way\n * out of it that did not also choose something. An open list is a layer on the kit's\n * one Escape stack ({@link useDismissLayer}), as `Modal`, `Popover` and\n * `useComboboxCore` are, so the package keeps one answer to \"what does Escape do\".\n *\n * Escape RESTORES FOCUS; an outside press does not. A press has already put focus\n * where the user pointed, and dragging it back from there would be the bug. Attach\n * `triggerRef` to the control that opens the panel and the keyboard paths — Escape,\n * Tab, a commit — hand focus back to it; leave it unattached and they hand it back to\n * whatever held focus when the list opened, which is the control that was pressed.\n *\n * ## Escape inside a dialog (round 0.34 BUG-1, Wave 2 DUP-1)\n *\n * One press in an open list inside a `Modal` or a `FullBleedDialog` used to close the\n * DIALOG, form and all, and leave the list open: the dialog took Escape in its own\n * `onKeyDown` before a document listener could. On the stack the list is above the\n * dialog, so the list closes and the dialog stays. {@link DropdownPanel} and\n * {@link DropdownSearchHeader} take the key on their own elements, where focus is,\n * and stop it there — so a caller passes nothing new, AmountInput's currency chip\n * included.\n *\n * ## The caller's own handler (round 0.35 R2)\n *\n * A caller's `onKeyDown` on {@link DropdownPanel} or {@link DropdownSearchHeader} hears\n * Escape only while this list is the layer on top — the rule the dialogs got first. A\n * tooltip over a row takes that press first, and the next one is the handler's, whose\n * `preventDefault()` still keeps the list. The two find the list's layer through the\n * refs this hook hands out — the panel through `panelRef`, the search box through\n * {@link useDropdownSearch}'s `inputRef` — so a caller passes nothing new. One handed\n * neither (an un-anchored panel may leave `panelRef` off) hears every key, as before.\n *\n * `escapeLayer: false` is for a caller that registers its own layer: the editable\n * comboboxes, whose list can be \"open\" with nothing in it to show — an Escape there\n * belongs to the dialog.\n */\nexport function useDropdown<T extends HTMLElement = HTMLDivElement>({\n backCloses = true,\n panelIsSheet = !backCloses,\n escapeLayer = true,\n}: { backCloses?: boolean; panelIsSheet?: boolean; escapeLayer?: boolean } = {}) {\n const [open, setOpen] = useState(false);\n const wrapperRef = useRef<T>(null);\n // The control that opens the panel — see the note above on why only the keyboard\n // paths read it, and why attaching it is the caller's choice.\n const triggerRef = useRef<HTMLButtonElement>(null);\n // The panel, once it is PORTALLED (see {@link DropdownPanel}'s `anchorRef`): it is\n // then a child of <body> rather than of the wrapper, so \"did the click land inside\n // the wrapper\" answers no for every click on the list itself and the first option a\n // user picked closed the dropdown without picking anything.\n const panelRef = useRef<HTMLDivElement>(null);\n // Where focus was as the list opened — the trigger focus goes back to when the\n // caller attached none. Read in an effect, before `useDropdownSearch`'s frame moves\n // focus into the search box.\n // Dropped on close: a note of where to go must not outlive the list it was for (0.52\n // code review 2026-10-31, held to 0.55).\n const openerRef = useRef<HTMLElement | null>(null);\n useEffect(() => {\n if (!open) {\n openerRef.current = null;\n return;\n }\n const el = document.activeElement;\n openerRef.current = el instanceof HTMLElement && el !== document.body ? el : null;\n }, [open]);\n const close = useCallback(() => setOpen(false), []);\n // Closing unmounts whatever held focus — the search box, the row the keyboard was\n // on — and the browser then drops focus on <body>: the caret vanishes and the next\n // Tab restarts at the top of the document, and inside a dialog the next Escape goes\n // nowhere. Whoever closed the list with a key gets focus handed back to the trigger\n // they opened it from — by the kit's one rule (lib/focus-left `returnFocus`, 0.55):\n // only from inside the list or from nowhere, so an Escape pressed with the focus in the\n // page leaves it there, and to where the focus was as the list opened when the\n // trigger cannot take it.\n const closeToTrigger = useCallback(() => {\n // The panel, or — not portalled, with no `panelRef` — the wrapper it sits in.\n const closing = panelRef.current ?? wrapperRef.current;\n returnFocus({ opener: triggerRef.current, fallback: [openerRef.current], closing });\n setOpen(false);\n }, []);\n useOutsideClick([wrapperRef, panelRef], close, open && !panelIsSheet);\n // See \"Escape inside a dialog\" above.\n const layer = useDismissLayer(open && escapeLayer, closeToTrigger);\n // Filed under `panelRef` for the panel's own handler — \"The caller's own handler\" above.\n useEffect(() => {\n listLayers.set(panelRef, layer);\n }, [panelRef, layer]);\n // Same close path Escape and an outside click take, so a list dismissed by Back\n // cannot end up in a different state from one dismissed any other way.\n useOverlayHistory(open && backCloses, close);\n return { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger };\n}\n\n/**\n * {@link useDropdown} plus a search box: clears the query and focuses the search\n * input each time the panel opens, so typing filters immediately.\n */\nexport function useDropdownSearch<T extends HTMLElement = HTMLDivElement>() {\n const { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger } = useDropdown<T>();\n const [query, setQuery] = useState(\"\");\n const inputRef = useRef<HTMLInputElement>(null);\n // The list's layer again, under `inputRef` for the search box's handler (round 0.35\n // R2). `useDropdown`'s effect, which runs first, has filed it under `panelRef`.\n useEffect(() => {\n const layer = listLayers.get(panelRef);\n if (layer) listLayers.set(inputRef, layer);\n }, [panelRef]);\n useEffect(() => {\n if (open) {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- reset the query on open\n setQuery(\"\");\n requestAnimationFrame(() => inputRef.current?.focus());\n }\n }, [open]);\n return {\n open,\n setOpen,\n wrapperRef,\n panelRef,\n triggerRef,\n closeToTrigger,\n query,\n setQuery,\n inputRef,\n };\n}\n\n/** `onKeyDown` is the INPUT's, not the wrapper's — the list's keyboard is handled\n * where the focus is (see the note above), so the div's own handler signature is\n * omitted in favour of it. */\nexport interface DropdownSearchHeaderProps extends Omit<ComponentPropsWithRef<\"div\">, \"onKeyDown\"> {\n query: string;\n onQueryChange: (v: string) => void;\n inputRef: RefObject<HTMLInputElement | null>;\n placeholder?: string;\n /** The `<ul role=\"listbox\">` this box filters. */\n listboxId?: string;\n /** The id of the option the arrow keys are currently on, if any. */\n activeId?: string;\n /** Arrow/Home/End/Enter/Tab — the list's keyboard, handled where the focus is.\n * Escape closes the list (the topmost layer on the kit's Escape stack); call\n * `preventDefault()` on it here to keep it. */\n onKeyDown?: (e: ReactKeyboardEvent<HTMLInputElement>) => void;\n}\n\n/** The search row (magnifier + text input) shared by the searchable dropdowns.\n *\n * The input had `outline-none` and nothing in its place (the audit's §a11y, the same\n * finding as the numpad's keys). That mattered more here than the bare class suggests:\n * {@link useDropdownSearch} focuses this box the moment a panel opens, so the caret is\n * the ONLY evidence of where the next keystroke goes — and a caret in an empty field\n * showing a placeholder is a single blinking pixel column. The ring is what says \"this\n * list is being typed into\"; it appears whenever the field holds focus, which for a\n * text input is exactly when it is true.\n *\n * ## Why this box is a plain textbox and the TRIGGER is the combobox\n *\n * The panels this header sits in are opened by a field-shaped trigger, and that\n * trigger is what carries `role=\"combobox\"` (see {@link MultiSelect},\n * {@link EntityCombobox}). Two comboboxes for one list would be one too many — a\n * reader tabbing back to the field would meet a second one describing the same\n * choice. So this stays a textbox, which ARIA lets own `aria-activedescendant` and\n * `aria-controls` exactly as a combobox does: focus is HERE while the list is up, so\n * this is what has to say which option the arrow keys are on.\n *\n * Pass `listboxId` and the wiring appears; omit it and the box is what it always\n * was, for the callers that have no listbox to point at. */\nexport function DropdownSearchHeader({\n query,\n onQueryChange,\n inputRef,\n placeholder,\n listboxId,\n activeId,\n onKeyDown,\n \"aria-label\": ariaLabel,\n className,\n ...rest\n}: DropdownSearchHeaderProps) {\n return (\n // `rest` dresses the header row; the NAME goes on the box below it. A search\n // input whose only name is its placeholder has none the moment a character is\n // typed into it — the placeholder disappears — which is why this is worth a prop\n // at all rather than something a caller could add from outside.\n <div {...rest} className={cn(\"flex items-center gap-2 border-b border-subtle px-2 py-1.5\", className)}>\n <Search className=\"size-4 text-placeholder\" />\n <input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={(e) => onQueryChange(e.target.value)}\n onKeyDown={(e) => {\n // The caller's handler hears Escape only while the list is on top (round 0.35\n // R2) — the layer filed under `inputRef`, when {@link useDropdownSearch} made it.\n runOwnKeyDown(e, onKeyDown, listLayers.get(inputRef));\n // Focus is in this box while the list is up, so this is where Escape lands\n // first — see \"Escape inside a dialog\" on {@link useDropdown}.\n takeEscape(e);\n }}\n placeholder={placeholder}\n aria-label={ariaLabel}\n aria-controls={listboxId}\n aria-activedescendant={activeId}\n aria-autocomplete={listboxId ? \"list\" : undefined}\n // FIELD_TOUCH_TEXT: a search box is a field — at least 16 px on touch, or iOS zooms\n // the page the moment a picker opens and focuses it (§10.1).\n className={cn(\n \"w-full rounded-sm bg-transparent text-sm outline-none placeholder:text-placeholder text-primary\",\n FOCUS_RING,\n FIELD_TOUCH_TEXT,\n )}\n />\n </div>\n );\n}\n\nexport interface DropdownPanelProps extends ComponentPropsWithoutRef<\"div\"> {\n header?: ReactNode;\n empty?: boolean;\n /** Attributes for the `<ul>` itself — how a caller whose children are options\n * gives the list its `role=\"listbox\"`, its id and `aria-multiselectable`. The\n * panel owns the scrolling and the padding, so `className` here is merged rather\n * than replaced. */\n listProps?: ComponentPropsWithoutRef<\"ul\">;\n /** The trigger to hang off. Given, the panel portals and goes `fixed`. */\n anchorRef?: RefObject<HTMLElement | null>;\n /** {@link useDropdown}'s `panelRef`, so an outside-click sees this as inside. Escape\n * anywhere in the panel, on a row as in the search box, closes the list rather than\n * a dialog around it. It is also how the panel finds the list's Escape layer, for\n * its `onKeyDown` (round 0.35 R2: see \"The caller's own handler\" there). */\n panelRef?: RefObject<HTMLDivElement | null>;\n /** Panel width in px, for the anchored form (the CSS `w-*` cannot be measured). */\n width?: number;\n /** Which of the panel's edges lines up with the trigger's, room permitting, by the\n * trigger's reading direction — `end` is the right edge in a left-to-right form and\n * the left one in a right-to-left form. Default `end`. The physical `left` / `right`\n * went in 0.35 (round 0.35 R1, refactor audit 2026-10, API-6e): `right` is `end` in a\n * left-to-right page, `left` is `start`. */\n align?: \"start\" | \"end\";\n children: ReactNode;\n /** The panel, where the rest of the props go (0.34, API-2, refactor audit 2026-10) —\n * merged with `panelRef`, so the outside-click still sees it. */\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * The floating popover surface for the searchable dropdowns: bordered/shadowed\n * panel, an optional `header` slot (search box, plus any actions), and a\n * scrollable `<ul>` of `children` with an \"empty\" row when nothing matches.\n *\n * ## Anchored, or merely absolute\n *\n * Without `anchorRef` the panel is `position: absolute` inside whatever relative box\n * the caller put it in, and the caller places it with `className` (`w-64`,\n * `end-0 top-full`). That is fine in a page that does not scroll around it, and\n * wrong the moment an ancestor has `overflow` — the panel is then CLIPPED by that\n * ancestor's box, with no error and no scrollbar, just a list with its side sliced\n * off. Keksdose dev#548 is what that looks like in practice: the app's own content\n * scroller starts 280px from the left, the amount field's currency picker opens\n * right-aligned and 256px wide, and in the transaction row editor its left third —\n * the search box's first letter, and every row's currency symbol — was cut away.\n *\n * With `anchorRef` the panel is PORTALLED to `<body>` and positioned `fixed` against\n * that trigger's rect, so no ancestor can clip it: the same treatment {@link Popover}\n * already gives the calculator, and the same reason. It re-aligns on scroll and\n * resize, flips above the trigger when the room is there instead (a phone keyboard\n * eats the bottom of the screen), and is clamped to the viewport's edges so a trigger\n * near either side cannot push it off-screen.\n *\n * Pass `panelRef` from {@link useDropdown} along with it: once portalled the panel is\n * no longer inside the wrapper, so the outside-click handler has to be told about it\n * or the first click on an option closes the list instead of choosing from it.\n */\nexport function DropdownPanel({\n header,\n empty,\n className,\n listProps,\n anchorRef,\n panelRef,\n width = 256,\n align = \"end\",\n children,\n style,\n onKeyDown,\n ref,\n ...rest\n}: DropdownPanelProps) {\n const setPanel = useMemo(() => mergeRefs(panelRef, ref), [panelRef, ref]);\n const anchored = useAnchoredPanel(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n const dir = useAnchorDir(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n // A row the keyboard reached by Tab holds focus too, and its Escape has to close the\n // list as the search box's does (BUG-1). The caller's handler first, as everywhere.\n const handleKeyDown = (e: ReactKeyboardEvent<HTMLDivElement>) => {\n // It hears Escape only while the list is on top, a tooltip over a row taking the\n // press first (round 0.35 R2) — the layer filed under `panelRef`, when handed one.\n runOwnKeyDown(e, onKeyDown, panelRef && listLayers.get(panelRef));\n takeEscape(e);\n };\n // A press in a panel opened from a row (a popover, its lists) is inside the list for\n // `useDropdown`'s outside press, though portalled elsewhere (dev#623).\n const markInside = pressInside(panelRef);\n const handlePointerDownCapture = (e: ReactPointerEvent<HTMLDivElement>) => {\n rest.onPointerDownCapture?.(e);\n markInside?.(e);\n };\n const body = (\n <>\n {header}\n {/* The anchored form caps its own height against the VISIBLE viewport and lets\n this list have the rest; the absolute form keeps the fixed `max-h-64` it has\n always had, applied by the wrapper below. */}\n <ul {...listProps} className={cn(\"overflow-y-auto py-1\", listProps?.className)}>\n {children}\n {/* `presentation`, so that a caller who made this list a `listbox` does not\n end up with one child that is not an option. The em dash still reads — it\n is the row's semantics that are dropped, not its text. */}\n {empty && (\n <li role=\"presentation\" className=\"px-3 py-2 text-sm text-muted\">\n —\n </li>\n )}\n </ul>\n </>\n );\n\n if (!anchorRef) {\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused itself: it catches Escape bubbling from the search box or a row inside it.\n <div\n {...rest}\n style={style}\n ref={setPanel}\n onKeyDown={handleKeyDown}\n onPointerDownCapture={handlePointerDownCapture}\n className={cn(\n \"absolute z-30 mt-1 rounded-md border border-subtle bg-surface shadow-lg\",\n \"[&>ul]:max-h-64\",\n className,\n )}\n >\n {body}\n </div>\n );\n }\n\n const rect = anchored.rect;\n if (!rect) return null;\n // Clamped to the glass as `Popover` is (Wave 2, DUP-7): the panel may leave the\n // trigger's edge to stay on screen, because a list half off the viewport is the bug\n // this exists for. The portal leaves the subtree the trigger's `dir` came from, so it\n // is read off the trigger — for the alignment here, and for the panel's own `dir`\n // below, without which a right-to-left form got a left-to-right list.\n const { left } = anchoredInline(rect, width, { dir, align });\n return createPortal(\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused itself: it catches Escape bubbling from the search box or a row inside it.\n <div\n {...rest}\n ref={setPanel}\n // A kit layer, for the tour's layer order (0.50, docs/tours-harmonization.md §11.6).\n data-kit-layer=\"\"\n dir={dir}\n onKeyDown={handleKeyDown}\n onPointerDownCapture={handlePointerDownCapture}\n // The caller's `style` is kept underneath, but the placement is measured rather\n // than chosen (dev#548: an `overflow` ancestor clipped a third of this panel\n // away), so these values are the panel's own. Flipped above, it hangs from its\n // bottom edge, so a list shorter than its cap still meets the trigger (keksdose\n // K1); the edge not in use is cleared, a caller's included.\n style={{\n ...style,\n position: \"fixed\",\n top: anchored.above ? undefined : anchored.top,\n bottom: anchored.above ? anchored.bottom : undefined,\n left,\n width,\n maxHeight: anchored.maxHeight,\n }}\n className={cn(\n \"z-50 flex flex-col overflow-hidden rounded-md border border-subtle bg-surface shadow-lg\",\n // The list, not the panel, is what scrolls: the search header has to stay put\n // while the options move under it.\n \"[&>ul]:min-h-0 [&>ul]:flex-1\",\n className,\n )}\n >\n {body}\n </div>,\n document.body,\n );\n}\n\n/** A ref that is always null, for the un-anchored form — hooks may not be conditional. */\nconst EMPTY_REF: RefObject<HTMLElement | null> = { current: null };\n"],"mappings":";AAqQI,SA2HA,UA1HE,KADF;AArQJ,SAAS,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AAUlE,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,aAAa,eAAe,YAAY,iBAAiB,uBAAuB;AAEzF,SAAS,yBAAyB;AAClC,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAM7B,MAAM,aAAa,oBAAI,QAA8B;AAsF9C,SAAS,YAAoD;AAAA,EAClE,aAAa;AAAA,EACb,eAAe,CAAC;AAAA,EAChB,cAAc;AAChB,IAA6E,CAAC,GAAG;AAC/E,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AACtC,QAAM,aAAa,OAAU,IAAI;AAGjC,QAAM,aAAa,OAA0B,IAAI;AAKjD,QAAM,WAAW,OAAuB,IAAI;AAM5C,QAAM,YAAY,OAA2B,IAAI;AACjD,YAAU,MAAM;AACd,QAA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A;AAAA,IACH;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAGA,MAAM,YAA2C,EAAE,SAAS,KAAK;","names":[]}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
EndHintRow,
|
|
18
18
|
FieldCaption,
|
|
19
19
|
LABEL_IN_ROW,
|
|
20
|
-
|
|
20
|
+
LockFrame,
|
|
21
21
|
mergeDescribedBy,
|
|
22
22
|
StaticLabelRow,
|
|
23
23
|
useFieldError,
|
|
@@ -113,7 +113,7 @@ function EntityCombobox(props) {
|
|
|
113
113
|
);
|
|
114
114
|
const showClear = Boolean(clearable && chosen != null && !inert);
|
|
115
115
|
const triggerText = selectedOption?.label ?? placeholder ?? "";
|
|
116
|
-
const withLock = (trigger) =>
|
|
116
|
+
const withLock = (trigger) => /* @__PURE__ */ jsx(LockFrame, { lock, display: disabledReasonDisplay, children: trigger });
|
|
117
117
|
const choose = (o) => {
|
|
118
118
|
if (lock.locked) return;
|
|
119
119
|
rememberOption(o);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/entity-combobox.tsx"],"sourcesContent":["import { useCallback, useId } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport { X } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { FieldChevron, FIELD_TRIGGER, FIELD_FLOATING_PAD, FIELD_INVALID } from \"./field-base\";\nimport { FieldLabel } from \"./field-parts\";\nimport {\n ComboboxPanel,\n endHintRowProps,\n offersCreate,\n useComboboxCore,\n type ComboClearValue,\n type ComboOption,\n} from \"./combobox-core\";\nimport { DEFAULT_COMBOBOX_LABELS, DEFAULT_COMMON_LABELS, useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport {\n assignRef,\n EndHintRow,\n FieldCaption,\n LABEL_IN_ROW,\n LockedReason,\n mergeDescribedBy,\n StaticLabelRow,\n useFieldError,\n useFieldHint,\n useLockReason,\n type DisabledReasonDisplay,\n type FieldHelpProps,\n} from \"./field-parts\";\nimport { useCommitReason, type CommitScope } from \"./write-lock\";\n\nexport type { ComboClearValue, ComboOption } from \"./combobox-core\";\n\n/** `onChange` is the kit's — \"a selection was made\", carrying values — rather\n * than the div's form event, so the DOM's spelling of it is omitted. */\nexport interface EntityComboboxProps<V extends string | number, C extends ComboClearValue = null>\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\">, FieldHelpProps {\n /** Selected id; `null`, `undefined` or `clearValue` when nothing is selected. */\n value: V | C | null | undefined;\n /** Selecting an option emits its value; the clear button emits `clearValue`. */\n onChange: (value: V | C) => void;\n /**\n * What the clear button emits. Default `null`. Pass `\"\"` for a form whose schema\n * wants an empty string for \"no choice\" (a zod `z.string()` field), rather than\n * mapping `null` in every `onChange` — the type of `onChange` follows it, so the\n * mapping cannot be forgotten on one field and not another. The picker also reads\n * the value back as empty, so `value=\"\"` shows the placeholder and no \"×\".\n * See {@link ComboClearValue} for why the choice is closed.\n */\n clearValue?: C;\n /** Already-loaded options (client-side filtered). Also used to resolve the\n * trigger label for the current `value`. */\n options?: ComboOption<V>[];\n /** Async option source, debounced and called on open + as the query changes\n * (at `minChars` and up). Stale responses are ignored; a rejection empties the\n * list and says `loadErrorLabel` instead of leaving the last query's rows up. When set, `options` is used only for label\n * resolution, not as the result list. */\n loadOptions?: (query: string) => Promise<ComboOption<V>[]>;\n /** External loading flag (OR-ed with the internal async state). */\n loading?: boolean;\n label?: ReactNode;\n placeholder?: string;\n searchPlaceholder?: string;\n emptyLabel?: string;\n /** Offer a clear \"×\" in place of the chevron while something is chosen; it emits\n * `clearValue`. A pointer shortcut inside the trigger, out of the tab order — the\n * keyboard's way is Delete or Backspace on the CLOSED trigger (0.23, as\n * {@link CountrySelect}). Not offered while `disabled` or locked. */\n clearable?: boolean;\n clearLabel?: string;\n /** The phone sheet's close button. Its own prop rather than a reuse of\n * `clearLabel`: \"clear the selection\" and \"close this screen\" are different\n * actions, and on a full-screen sheet the close button is the only way out —\n * so it is the one control here that MUST be in the reader's language. */\n closeLabel?: string;\n /** The phone sheet's heading (and, as a string, its accessible name) for a picker\n * whose label is drawn by someone else — a bound field's label; `RhfCombobox`\n * hands its label over here (0.24). Default: `label`, then `placeholder`. */\n sheetTitle?: ReactNode;\n disabled?: boolean;\n /**\n * Why the choice cannot be changed — {@link Button}'s `disabledReason`, for a picker\n * that SAVES on change (keksdose G2: the statement's account, where picking IS the\n * write). The trigger stays focusable and `aria-disabled`, the list does not open,\n * the clear \"×\" is gone and `onChange` never fires; the reason is in the kit\n * {@link Tooltip} and on the trigger's `aria-describedby`. Wins over `disabled`.\n * {@link CountrySelect}'s lock, which is built on the same core.\n */\n disabledReason?: ReactNode;\n /**\n * This picker COMMITS — choosing saves. Under a locked {@link WriteLockProvider} it is\n * locked the `disabledReason` way with the lock's reason (which wins over its own).\n * A picker inside a form with its own Save stays editable under the lock: leave this\n * off there and put `commit` on the Save. No provider, or an unlocked one: no effect.\n */\n commit?: CommitScope;\n /** Where the reason shows — {@link Button}'s `disabledReasonDisplay`: a line under the\n * field at Large and on a touch screen by default, the tooltip otherwise (DUP-3). */\n disabledReasonDisplay?: DisabledReasonDisplay;\n /** When set, a \"create\" row appears for a non-empty query with no exact match. */\n onCreate?: (query: string) => void;\n createLabel?: (query: string) => string;\n /**\n * Offer the create row with NOTHING typed too, worded as this — keksdose G9's\n * \"Create cash account\", which mints a record under a default name and so needs no\n * query. `onCreate` then receives `\"\"`. Left out, the row needs a query, as before.\n * See {@link InlineEntityCombobox}'s `createEmptyLabel`.\n */\n createEmptyLabel?: string;\n /**\n * The create row WRITES (it mints the record on the server) while picking does not.\n * Under a locked {@link WriteLockProvider} the row stays in the list but cannot be\n * taken, with the lock's reason as its second line — the picker itself stays live.\n * keksdose dev#496: on the read-only demo choosing is draft state, minting is not.\n */\n createCommit?: CommitScope;\n /** Required and unanswered — {@link FIELD_INVALID}. See {@link Input}'s `invalid`. */\n invalid?: boolean;\n /** What is wrong with the value, as {@link Input}'s `error`: rendered under the\n * field, on the trigger's `aria-describedby`, and implies `invalid`. */\n error?: ReactNode;\n /**\n * Standing advice — {@link Combobox}'s `hint`, so the pickers read like every other\n * field (keksdose K4): plain TEXT is a caption under the field on the trigger's\n * `aria-describedby`, before any error; a {@link FieldHint} \"?\" rides the label line,\n * or with no label sits at the trigger's end edge, outside the box.\n */\n hint?: ReactNode;\n /** Narrow `options` client-side by the query. Default `true`; `false` shows them\n * as given (a server-ranked list). */\n filter?: boolean;\n /** Offer nothing, and call no `loadOptions`, below this many characters. Default\n * `0`, i.e. the list loads as the panel opens. */\n minChars?: number;\n /** `loadOptions` debounce. Default 150 ms. */\n debounceMs?: number;\n /** Shown when `loadOptions` rejects. Default: `combobox.loadError`. */\n loadErrorLabel?: string;\n /**\n * The TRIGGER — the focusable `<button>` a reader meets — as a React 19 ref prop, as\n * on {@link CountrySelect}, which is built on the same core (0.24, kastlan: react-hook-\n * form's focus-on-error calls `focus()` on whatever `field.ref` is handed, and a\n * picker with no ref gave it nothing to focus). Not the wrapper: focus belongs on the\n * trigger, which is also where the panel hands it back after a pick.\n */\n ref?: Ref<HTMLButtonElement>;\n}\n\n/**\n * An id-keyed, searchable entity picker: a field-styled trigger showing the\n * selected item's label, and a portalled dropdown of `{label, sublabel, icon}`\n * options — loaded up front via `options` or lazily via `loadOptions`. Built on\n * the shared field/anchor/dismiss/search primitives (no cmdk/Radix). For picking\n * several entities use {@link MultiEntityCombobox}.\n */\nexport function EntityCombobox<V extends string | number, C extends ComboClearValue = null>(\n props: EntityComboboxProps<V, C>,\n) {\n const {\n value,\n onChange,\n clearValue = null as C,\n options,\n loadOptions,\n loading,\n label,\n placeholder,\n searchPlaceholder,\n emptyLabel,\n clearable,\n clearLabel,\n closeLabel,\n sheetTitle,\n disabled,\n disabledReason,\n disabledReasonDisplay,\n commit,\n onCreate,\n createLabel,\n createEmptyLabel,\n createCommit,\n className,\n invalid,\n error,\n hint,\n help,\n filter,\n minChars,\n debounceMs,\n loadErrorLabel,\n ref,\n \"aria-label\": ariaLabel,\n // The control's own wiring, taken off `rest` so it lands on the TRIGGER rather than\n // the wrapper — see MultiEntityCombobox: `Field`'s render-prop spreads `{ id,\n // aria-describedby, aria-invalid, aria-required }`, and on the role-less wrapper\n // div the label's `htmlFor` named nothing and the hint described nothing.\n id,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": ariaInvalid,\n \"aria-required\": ariaRequired,\n ...rest\n } = props;\n const core = useComboboxCore<V>({\n options,\n loadOptions,\n loading,\n filter,\n minChars,\n debounceMs,\n });\n const hintParts = useFieldHint(hint, ariaDescribedBy, { help, name: label ?? ariaLabel });\n const field = useFieldError(error, invalid, hintParts.describedBy, ariaInvalid);\n // The props are the per-instance overrides, the provider the app-wide ones; a\n // prop left `undefined` falls through to the provider rather than masking it.\n const labels = useKitLabels(\"combobox\", DEFAULT_COMBOBOX_LABELS, {\n search: searchPlaceholder,\n noResults: emptyLabel,\n clear: clearLabel,\n create: createLabel,\n });\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const { open, results, resolve, setOpen, rememberOption, query, triggerRef } = core;\n // The core anchors the panel to the trigger and hands focus back to it; the caller's\n // `ref` wants the same element. One callback feeds both — CountrySelect's.\n const setTrigger = useCallback(\n (el: HTMLButtonElement | null) => {\n triggerRef.current = el;\n assignRef(ref, el);\n },\n [ref, triggerRef],\n );\n // The lock: this picker's own reason, or the provider's under `commit`.\n const lock = useLockReason(commit, disabledReason);\n const inert = lock.locked || Boolean(disabled);\n // A lock arriving while the list is up closes it — adjusted while\n // rendering, as the core adjusts its own query, so no frame offers a pick that would\n // be thrown away.\n if (lock.locked && open) setOpen(false);\n // The create row's own lock, for a picker whose choosing is draft and whose create\n // is the write (`createCommit`).\n const createReason = useCommitReason(createCommit, undefined);\n // One id per instance, generated here rather than in the core: `aria-controls` on\n // the trigger has to name the list while the list is still closed, so the id\n // belongs to whoever renders both ends of it.\n const listboxId = useId();\n\n // The clear value is \"nothing selected\" too, whichever one the caller picked.\n const chosen: V | null = value == null || value === clearValue ? null : (value as V);\n const selectedOption = chosen == null ? null : resolve(chosen);\n const q = query.trim();\n // The create row's \"is this name already listed\" folds as the list's match does (DUP-5).\n const locale = useKitLocale();\n const showCreate = offersCreate(\n onCreate,\n q,\n results.map((o) => o.label),\n createEmptyLabel,\n locale,\n );\n const showClear = Boolean(clearable && chosen != null && !inert);\n /** What the closed control is showing — the second half of its accessible name. */\n const triggerText = selectedOption?.label ?? placeholder ?? \"\";\n // While locked the trigger sits in the reason's Tooltip — in a fragment with a hidden\n // copy of the reason, Button's anatomy — `block` so a full-width field stays full width.\n const withLock = (trigger: ReactNode) =>\n lock.locked ? (\n <LockedReason lock={lock} display={disabledReasonDisplay} className=\"block\">\n {trigger}\n </LockedReason>\n ) : (\n trigger\n );\n\n const choose = (o: ComboOption<V>) => {\n if (lock.locked) return;\n rememberOption(o);\n onChange(o.value);\n // Back to the trigger, not to <body>: the panel that held focus is about to\n // unmount, and a keyboard user who just answered this field should be standing\n // on it, ready to Tab to the next one.\n core.closeToTrigger();\n };\n\n return (\n // `rest` dresses the wrapper, which has no role; the accessible NAME — and the\n // id, description, invalid and required state above — go on the trigger, which\n // has one. Spread FIRST so the trigger's ARIA and the\n // handlers that open the panel cannot be clobbered from outside.\n <div {...rest} className={cn(\"relative\", className)}>\n {label !== undefined && hintParts.labelHint === undefined && <FieldLabel>{label}</FieldLabel>}\n <EndHintRow {...endHintRowProps(\"hint\" in props, label !== undefined, hintParts.labelHint)}>\n {withLock(\n <button\n ref={setTrigger}\n id={id}\n type=\"button\"\n // A combobox, not a button. The distinction is not pedantry: this control\n // carried `aria-invalid`, which `button` does not support, so a required\n // field left empty painted a rose border and told a reader nothing at all —\n // and ESLint flagged it as exactly that (`role-supports-aria-props`). The\n // fix the audit asked for is the role that describes what this IS: a closed\n // choice that expands into the list named below. `combobox` supports\n // `aria-invalid`, so the border and the announcement finally agree.\n role=\"combobox\"\n aria-expanded={open}\n aria-controls={listboxId}\n aria-haspopup=\"listbox\"\n // The label is a floating <span>, not a <label for>, so without this the\n // trigger's accessible name is whatever value happens to be selected —\n // \"Checking\" with nothing saying it is the account. The label AND the\n // value, because `aria-label` replaces the content rather than adding to\n // it, and a control that announces only its name has lost the answer.\n // A caller's own name wins over the composition: two fields labelled\n // \"Account\" on a transfer form are the from and the to, and only the\n // caller knows which is which.\n aria-label={ariaLabel ?? (typeof label === \"string\" ? common.fieldValue(label, triggerText) : undefined)}\n // The focusable kind of disabled while locked (Button's rule): a native\n // `disabled` would take the field out of the tab order, and the reason with it.\n disabled={lock.locked ? undefined : disabled}\n aria-disabled={lock.locked || undefined}\n aria-invalid={field.isInvalid || undefined}\n aria-describedby={mergeDescribedBy(field.describedBy, lock.locked && lock.reasonId)}\n aria-required={ariaRequired}\n onClick={() => !inert && setOpen((o) => !o)}\n // Down/Up opens the list from the closed trigger, per the APG. Enter and\n // Space already do it through the button's own click.\n onKeyDown={(e) => {\n if (inert) return;\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n setOpen(true);\n } else if (showClear && !open && (e.key === \"Delete\" || e.key === \"Backspace\")) {\n // The keyboard's clear: the \"×\" is a pointer shortcut out of the tab\n // order, so without this a cleared-by-mouse field was set-only from the\n // keyboard. The closed trigger only — CountrySelect's rule (0.23).\n e.preventDefault();\n onChange(clearValue);\n }\n }}\n className={cn(\n FIELD_TRIGGER,\n \"pe-9\",\n label !== undefined && FIELD_FLOATING_PAD,\n inert && \"cursor-not-allowed opacity-50\",\n field.isInvalid && FIELD_INVALID,\n )}\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n {selectedOption?.icon && <span className=\"shrink-0\">{selectedOption.icon}</span>}\n <span\n className={cn(\n // One line at Normal; from Large up the value wraps and the trigger\n // grows, as DatePicker's does (text size §10.17, round 0.34 T1).\n \"truncate-until-large\",\n // A chosen value is the field's VALUE, so it is set in the same ink an\n // <input>'s value is — FIELD_BASE's own text colour, inherited rather\n // than restated (Keksdose dev#477). It used to be one notch lighter\n // than the typeahead fields beside it, which is visible when a picker\n // and a text field share a form row. Nothing selected keeps the\n // placeholder tone (`--text-placeholder`), which every field here\n // agrees on.\n !selectedOption && \"text-placeholder\",\n )}\n >\n {selectedOption?.label ?? placeholder ?? \"\"}\n </span>\n </span>\n {showClear ? (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events -- tabIndex -1 inside\n the trigger <button>, so it never holds focus and a key handler here could\n never fire; the keys go to the trigger, where Delete and Backspace clear. */\n <span\n role=\"button\"\n tabIndex={-1}\n aria-label={labels.clear}\n onClick={(e) => {\n e.stopPropagation();\n onChange(clearValue);\n }}\n className=\"absolute end-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-placeholder hover:text-secondary\"\n >\n <X className=\"size-4\" />\n </span>\n ) : (\n <FieldChevron />\n )}\n </button>,\n )}\n </EndHintRow>\n {/* With a \"?\" the label shares the top strip with it — after the trigger, so the\n \"?\" follows the control in the tab order, as on Input and Select. */}\n {label !== undefined && hintParts.labelHint !== undefined && (\n <StaticLabelRow hint={hintParts.labelHint}>\n <FieldLabel className={LABEL_IN_ROW}>{label}</FieldLabel>\n </StaticLabelRow>\n )}\n <ComboboxPanel\n core={core}\n listboxId={listboxId}\n // On a phone the panel becomes a full-screen sheet, which needs the field's\n // own label to say what it is asking for (live #200).\n sheetTitle={sheetTitle ?? label ?? placeholder}\n searchPlaceholder={labels.search}\n emptyLabel={labels.noResults}\n closeLabel={closeLabel}\n loadErrorLabel={loadErrorLabel}\n isSelected={(v) => v === value}\n onChoose={choose}\n showCreate={showCreate}\n onCreate={() => {\n if (lock.locked) return;\n onCreate?.(q);\n core.closeToTrigger();\n }}\n createContent={q ? labels.create(q) : createEmptyLabel}\n createDisabledReason={createReason}\n />\n <FieldCaption parts={hintParts} />\n {field.errorEl}\n </div>\n );\n}\n"],"mappings":";AA0QM,cAiFM,YAjFN;AA1QN,SAAS,aAAa,aAAa;AAEnC,SAAS,SAAS;AAClB,SAAS,UAAU;AACnB,SAAS,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ACC;AAAA;AAAA;AAAA;AAAA,gBAIC;AAAA,kBAAC;AAAA;AAAA,oBACC,MAAK;AAAA,oBACL,UAAU;AAAA,oBACV,cAAY,OAAO;AAAA,oBACnB,SAAS,CAAC,MAAM;AACd,wBAAE,gBAAgB;AAClB,+BAAS,UAAU;AAAA,oBACrB;AAAA,oBACA,WAAU;AAAA,oBAEV,8BAAC,KAAE,WAAU,UAAS;AAAA;AAAA,gBACxB;AAAA,kBAEA,oBAAC,gBAAa;AAAA;AAAA;AAAA,QAElB;AAAA,MACF,GACF;AAAA,MAGC,UAAU,UAAa,UAAU,cAAc,UAC9C,oBAAC,kBAAe,MAAM,UAAU,WAC9B,8BAAC,cAAW,WAAW,cAAe,iBAAM,GAC9C;AAAA,MAEF;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UAGA,YAAY,cAAc,SAAS;AAAA,UACnC,mBAAmB,OAAO;AAAA,UAC1B,YAAY,OAAO;AAAA,UACnB;AAAA,UACA;AAAA,UACA,YAAY,CAAC,MAAM,MAAM;AAAA,UACzB,UAAU;AAAA,UACV;AAAA,UACA,UAAU,MAAM;AACd,gBAAI,KAAK,OAAQ;AACjB,uBAAW,CAAC;AACZ,iBAAK,eAAe;AAAA,UACtB;AAAA,UACA,eAAe,IAAI,OAAO,OAAO,CAAC,IAAI;AAAA,UACtC,sBAAsB;AAAA;AAAA,MACxB;AAAA,MACA,oBAAC,gBAAa,OAAO,WAAW;AAAA,MAC/B,MAAM;AAAA,OACT;AAAA;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/entity-combobox.tsx"],"sourcesContent":["import { useCallback, useId } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport { X } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { FieldChevron, FIELD_TRIGGER, FIELD_FLOATING_PAD, FIELD_INVALID } from \"./field-base\";\nimport { FieldLabel } from \"./field-parts\";\nimport {\n ComboboxPanel,\n endHintRowProps,\n offersCreate,\n useComboboxCore,\n type ComboClearValue,\n type ComboOption,\n} from \"./combobox-core\";\nimport { DEFAULT_COMBOBOX_LABELS, DEFAULT_COMMON_LABELS, useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport {\n assignRef,\n EndHintRow,\n FieldCaption,\n LABEL_IN_ROW,\n LockFrame,\n mergeDescribedBy,\n StaticLabelRow,\n useFieldError,\n useFieldHint,\n useLockReason,\n type DisabledReasonDisplay,\n type FieldHelpProps,\n} from \"./field-parts\";\nimport { useCommitReason, type CommitScope } from \"./write-lock\";\n\nexport type { ComboClearValue, ComboOption } from \"./combobox-core\";\n\n/** `onChange` is the kit's — \"a selection was made\", carrying values — rather\n * than the div's form event, so the DOM's spelling of it is omitted. */\nexport interface EntityComboboxProps<V extends string | number, C extends ComboClearValue = null>\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\">, FieldHelpProps {\n /** Selected id; `null`, `undefined` or `clearValue` when nothing is selected. */\n value: V | C | null | undefined;\n /** Selecting an option emits its value; the clear button emits `clearValue`. */\n onChange: (value: V | C) => void;\n /**\n * What the clear button emits. Default `null`. Pass `\"\"` for a form whose schema\n * wants an empty string for \"no choice\" (a zod `z.string()` field), rather than\n * mapping `null` in every `onChange` — the type of `onChange` follows it, so the\n * mapping cannot be forgotten on one field and not another. The picker also reads\n * the value back as empty, so `value=\"\"` shows the placeholder and no \"×\".\n * See {@link ComboClearValue} for why the choice is closed.\n */\n clearValue?: C;\n /** Already-loaded options (client-side filtered). Also used to resolve the\n * trigger label for the current `value`. */\n options?: ComboOption<V>[];\n /** Async option source, debounced and called on open + as the query changes\n * (at `minChars` and up). Stale responses are ignored; a rejection empties the\n * list and says `loadErrorLabel` instead of leaving the last query's rows up. When set, `options` is used only for label\n * resolution, not as the result list. */\n loadOptions?: (query: string) => Promise<ComboOption<V>[]>;\n /** External loading flag (OR-ed with the internal async state). */\n loading?: boolean;\n label?: ReactNode;\n placeholder?: string;\n searchPlaceholder?: string;\n emptyLabel?: string;\n /** Offer a clear \"×\" in place of the chevron while something is chosen; it emits\n * `clearValue`. A pointer shortcut inside the trigger, out of the tab order — the\n * keyboard's way is Delete or Backspace on the CLOSED trigger (0.23, as\n * {@link CountrySelect}). Not offered while `disabled` or locked. */\n clearable?: boolean;\n clearLabel?: string;\n /** The phone sheet's close button. Its own prop rather than a reuse of\n * `clearLabel`: \"clear the selection\" and \"close this screen\" are different\n * actions, and on a full-screen sheet the close button is the only way out —\n * so it is the one control here that MUST be in the reader's language. */\n closeLabel?: string;\n /** The phone sheet's heading (and, as a string, its accessible name) for a picker\n * whose label is drawn by someone else — a bound field's label; `RhfCombobox`\n * hands its label over here (0.24). Default: `label`, then `placeholder`. */\n sheetTitle?: ReactNode;\n disabled?: boolean;\n /**\n * Why the choice cannot be changed — {@link Button}'s `disabledReason`, for a picker\n * that SAVES on change (keksdose G2: the statement's account, where picking IS the\n * write). The trigger stays focusable and `aria-disabled`, the list does not open,\n * the clear \"×\" is gone and `onChange` never fires; the reason is in the kit\n * {@link Tooltip} and on the trigger's `aria-describedby`. Wins over `disabled`.\n * {@link CountrySelect}'s lock, which is built on the same core.\n */\n disabledReason?: ReactNode;\n /**\n * This picker COMMITS — choosing saves. Under a locked {@link WriteLockProvider} it is\n * locked the `disabledReason` way with the lock's reason (which wins over its own).\n * A picker inside a form with its own Save stays editable under the lock: leave this\n * off there and put `commit` on the Save. No provider, or an unlocked one: no effect.\n */\n commit?: CommitScope;\n /** Where the reason shows — {@link Button}'s `disabledReasonDisplay`: a line under the\n * field at Large and on a touch screen by default, the tooltip otherwise (DUP-3). */\n disabledReasonDisplay?: DisabledReasonDisplay;\n /** When set, a \"create\" row appears for a non-empty query with no exact match. */\n onCreate?: (query: string) => void;\n createLabel?: (query: string) => string;\n /**\n * Offer the create row with NOTHING typed too, worded as this — keksdose G9's\n * \"Create cash account\", which mints a record under a default name and so needs no\n * query. `onCreate` then receives `\"\"`. Left out, the row needs a query, as before.\n * See {@link InlineEntityCombobox}'s `createEmptyLabel`.\n */\n createEmptyLabel?: string;\n /**\n * The create row WRITES (it mints the record on the server) while picking does not.\n * Under a locked {@link WriteLockProvider} the row stays in the list but cannot be\n * taken, with the lock's reason as its second line — the picker itself stays live.\n * keksdose dev#496: on the read-only demo choosing is draft state, minting is not.\n */\n createCommit?: CommitScope;\n /** Required and unanswered — {@link FIELD_INVALID}. See {@link Input}'s `invalid`. */\n invalid?: boolean;\n /** What is wrong with the value, as {@link Input}'s `error`: rendered under the\n * field, on the trigger's `aria-describedby`, and implies `invalid`. */\n error?: ReactNode;\n /**\n * Standing advice — {@link Combobox}'s `hint`, so the pickers read like every other\n * field (keksdose K4): plain TEXT is a caption under the field on the trigger's\n * `aria-describedby`, before any error; a {@link FieldHint} \"?\" rides the label line,\n * or with no label sits at the trigger's end edge, outside the box.\n */\n hint?: ReactNode;\n /** Narrow `options` client-side by the query. Default `true`; `false` shows them\n * as given (a server-ranked list). */\n filter?: boolean;\n /** Offer nothing, and call no `loadOptions`, below this many characters. Default\n * `0`, i.e. the list loads as the panel opens. */\n minChars?: number;\n /** `loadOptions` debounce. Default 150 ms. */\n debounceMs?: number;\n /** Shown when `loadOptions` rejects. Default: `combobox.loadError`. */\n loadErrorLabel?: string;\n /**\n * The TRIGGER — the focusable `<button>` a reader meets — as a React 19 ref prop, as\n * on {@link CountrySelect}, which is built on the same core (0.24, kastlan: react-hook-\n * form's focus-on-error calls `focus()` on whatever `field.ref` is handed, and a\n * picker with no ref gave it nothing to focus). Not the wrapper: focus belongs on the\n * trigger, which is also where the panel hands it back after a pick.\n */\n ref?: Ref<HTMLButtonElement>;\n}\n\n/**\n * An id-keyed, searchable entity picker: a field-styled trigger showing the\n * selected item's label, and a portalled dropdown of `{label, sublabel, icon}`\n * options — loaded up front via `options` or lazily via `loadOptions`. Built on\n * the shared field/anchor/dismiss/search primitives (no cmdk/Radix). For picking\n * several entities use {@link MultiEntityCombobox}.\n */\nexport function EntityCombobox<V extends string | number, C extends ComboClearValue = null>(\n props: EntityComboboxProps<V, C>,\n) {\n const {\n value,\n onChange,\n clearValue = null as C,\n options,\n loadOptions,\n loading,\n label,\n placeholder,\n searchPlaceholder,\n emptyLabel,\n clearable,\n clearLabel,\n closeLabel,\n sheetTitle,\n disabled,\n disabledReason,\n disabledReasonDisplay,\n commit,\n onCreate,\n createLabel,\n createEmptyLabel,\n createCommit,\n className,\n invalid,\n error,\n hint,\n help,\n filter,\n minChars,\n debounceMs,\n loadErrorLabel,\n ref,\n \"aria-label\": ariaLabel,\n // The control's own wiring, taken off `rest` so it lands on the TRIGGER rather than\n // the wrapper — see MultiEntityCombobox: `Field`'s render-prop spreads `{ id,\n // aria-describedby, aria-invalid, aria-required }`, and on the role-less wrapper\n // div the label's `htmlFor` named nothing and the hint described nothing.\n id,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": ariaInvalid,\n \"aria-required\": ariaRequired,\n ...rest\n } = props;\n const core = useComboboxCore<V>({\n options,\n loadOptions,\n loading,\n filter,\n minChars,\n debounceMs,\n });\n const hintParts = useFieldHint(hint, ariaDescribedBy, { help, name: label ?? ariaLabel });\n const field = useFieldError(error, invalid, hintParts.describedBy, ariaInvalid);\n // The props are the per-instance overrides, the provider the app-wide ones; a\n // prop left `undefined` falls through to the provider rather than masking it.\n const labels = useKitLabels(\"combobox\", DEFAULT_COMBOBOX_LABELS, {\n search: searchPlaceholder,\n noResults: emptyLabel,\n clear: clearLabel,\n create: createLabel,\n });\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const { open, results, resolve, setOpen, rememberOption, query, triggerRef } = core;\n // The core anchors the panel to the trigger and hands focus back to it; the caller's\n // `ref` wants the same element. One callback feeds both — CountrySelect's.\n const setTrigger = useCallback(\n (el: HTMLButtonElement | null) => {\n triggerRef.current = el;\n assignRef(ref, el);\n },\n [ref, triggerRef],\n );\n // The lock: this picker's own reason, or the provider's under `commit`.\n const lock = useLockReason(commit, disabledReason);\n const inert = lock.locked || Boolean(disabled);\n // A lock arriving while the list is up closes it — adjusted while\n // rendering, as the core adjusts its own query, so no frame offers a pick that would\n // be thrown away.\n if (lock.locked && open) setOpen(false);\n // The create row's own lock, for a picker whose choosing is draft and whose create\n // is the write (`createCommit`).\n const createReason = useCommitReason(createCommit, undefined);\n // One id per instance, generated here rather than in the core: `aria-controls` on\n // the trigger has to name the list while the list is still closed, so the id\n // belongs to whoever renders both ends of it.\n const listboxId = useId();\n\n // The clear value is \"nothing selected\" too, whichever one the caller picked.\n const chosen: V | null = value == null || value === clearValue ? null : (value as V);\n const selectedOption = chosen == null ? null : resolve(chosen);\n const q = query.trim();\n // The create row's \"is this name already listed\" folds as the list's match does (DUP-5).\n const locale = useKitLocale();\n const showCreate = offersCreate(\n onCreate,\n q,\n results.map((o) => o.label),\n createEmptyLabel,\n locale,\n );\n const showClear = Boolean(clearable && chosen != null && !inert);\n /** What the closed control is showing — the second half of its accessible name. */\n const triggerText = selectedOption?.label ?? placeholder ?? \"\";\n // While locked the trigger sits in the reason's Tooltip — in a fragment with a hidden\n // copy of the reason, Button's anatomy — `block` so a full-width field stays full width.\n const withLock = (trigger: ReactNode) => (\n <LockFrame lock={lock} display={disabledReasonDisplay}>\n {trigger}\n </LockFrame>\n );\n\n const choose = (o: ComboOption<V>) => {\n if (lock.locked) return;\n rememberOption(o);\n onChange(o.value);\n // Back to the trigger, not to <body>: the panel that held focus is about to\n // unmount, and a keyboard user who just answered this field should be standing\n // on it, ready to Tab to the next one.\n core.closeToTrigger();\n };\n\n return (\n // `rest` dresses the wrapper, which has no role; the accessible NAME — and the\n // id, description, invalid and required state above — go on the trigger, which\n // has one. Spread FIRST so the trigger's ARIA and the\n // handlers that open the panel cannot be clobbered from outside.\n <div {...rest} className={cn(\"relative\", className)}>\n {label !== undefined && hintParts.labelHint === undefined && <FieldLabel>{label}</FieldLabel>}\n <EndHintRow {...endHintRowProps(\"hint\" in props, label !== undefined, hintParts.labelHint)}>\n {withLock(\n <button\n ref={setTrigger}\n id={id}\n type=\"button\"\n // A combobox, not a button. The distinction is not pedantry: this control\n // carried `aria-invalid`, which `button` does not support, so a required\n // field left empty painted a rose border and told a reader nothing at all —\n // and ESLint flagged it as exactly that (`role-supports-aria-props`). The\n // fix the audit asked for is the role that describes what this IS: a closed\n // choice that expands into the list named below. `combobox` supports\n // `aria-invalid`, so the border and the announcement finally agree.\n role=\"combobox\"\n aria-expanded={open}\n aria-controls={listboxId}\n aria-haspopup=\"listbox\"\n // The label is a floating <span>, not a <label for>, so without this the\n // trigger's accessible name is whatever value happens to be selected —\n // \"Checking\" with nothing saying it is the account. The label AND the\n // value, because `aria-label` replaces the content rather than adding to\n // it, and a control that announces only its name has lost the answer.\n // A caller's own name wins over the composition: two fields labelled\n // \"Account\" on a transfer form are the from and the to, and only the\n // caller knows which is which.\n aria-label={ariaLabel ?? (typeof label === \"string\" ? common.fieldValue(label, triggerText) : undefined)}\n // The focusable kind of disabled while locked (Button's rule): a native\n // `disabled` would take the field out of the tab order, and the reason with it.\n disabled={lock.locked ? undefined : disabled}\n aria-disabled={lock.locked || undefined}\n aria-invalid={field.isInvalid || undefined}\n aria-describedby={mergeDescribedBy(field.describedBy, lock.locked && lock.reasonId)}\n aria-required={ariaRequired}\n onClick={() => !inert && setOpen((o) => !o)}\n // Down/Up opens the list from the closed trigger, per the APG. Enter and\n // Space already do it through the button's own click.\n onKeyDown={(e) => {\n if (inert) return;\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n setOpen(true);\n } else if (showClear && !open && (e.key === \"Delete\" || e.key === \"Backspace\")) {\n // The keyboard's clear: the \"×\" is a pointer shortcut out of the tab\n // order, so without this a cleared-by-mouse field was set-only from the\n // keyboard. The closed trigger only — CountrySelect's rule (0.23).\n e.preventDefault();\n onChange(clearValue);\n }\n }}\n className={cn(\n FIELD_TRIGGER,\n \"pe-9\",\n label !== undefined && FIELD_FLOATING_PAD,\n inert && \"cursor-not-allowed opacity-50\",\n field.isInvalid && FIELD_INVALID,\n )}\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n {selectedOption?.icon && <span className=\"shrink-0\">{selectedOption.icon}</span>}\n <span\n className={cn(\n // One line at Normal; from Large up the value wraps and the trigger\n // grows, as DatePicker's does (text size §10.17, round 0.34 T1).\n \"truncate-until-large\",\n // A chosen value is the field's VALUE, so it is set in the same ink an\n // <input>'s value is — FIELD_BASE's own text colour, inherited rather\n // than restated (Keksdose dev#477). It used to be one notch lighter\n // than the typeahead fields beside it, which is visible when a picker\n // and a text field share a form row. Nothing selected keeps the\n // placeholder tone (`--text-placeholder`), which every field here\n // agrees on.\n !selectedOption && \"text-placeholder\",\n )}\n >\n {selectedOption?.label ?? placeholder ?? \"\"}\n </span>\n </span>\n {showClear ? (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events -- tabIndex -1 inside\n the trigger <button>, so it never holds focus and a key handler here could\n never fire; the keys go to the trigger, where Delete and Backspace clear. */\n <span\n role=\"button\"\n tabIndex={-1}\n aria-label={labels.clear}\n onClick={(e) => {\n e.stopPropagation();\n onChange(clearValue);\n }}\n className=\"absolute end-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-placeholder hover:text-secondary\"\n >\n <X className=\"size-4\" />\n </span>\n ) : (\n <FieldChevron />\n )}\n </button>,\n )}\n </EndHintRow>\n {/* With a \"?\" the label shares the top strip with it — after the trigger, so the\n \"?\" follows the control in the tab order, as on Input and Select. */}\n {label !== undefined && hintParts.labelHint !== undefined && (\n <StaticLabelRow hint={hintParts.labelHint}>\n <FieldLabel className={LABEL_IN_ROW}>{label}</FieldLabel>\n </StaticLabelRow>\n )}\n <ComboboxPanel\n core={core}\n listboxId={listboxId}\n // On a phone the panel becomes a full-screen sheet, which needs the field's\n // own label to say what it is asking for (live #200).\n sheetTitle={sheetTitle ?? label ?? placeholder}\n searchPlaceholder={labels.search}\n emptyLabel={labels.noResults}\n closeLabel={closeLabel}\n loadErrorLabel={loadErrorLabel}\n isSelected={(v) => v === value}\n onChoose={choose}\n showCreate={showCreate}\n onCreate={() => {\n if (lock.locked) return;\n onCreate?.(q);\n core.closeToTrigger();\n }}\n createContent={q ? labels.create(q) : createEmptyLabel}\n createDisabledReason={createReason}\n />\n <FieldCaption parts={hintParts} />\n {field.errorEl}\n </div>\n );\n}\n"],"mappings":";AAyQI,cA+EQ,YA/ER;AAzQJ,SAAS,aAAa,aAAa;AAEnC,SAAS,SAAS;AAClB,SAAS,UAAU;AACnB,SAAS,cAAc,eAAe,oBAAoB,qBAAqB;AAC/E,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,yBAAyB,uBAAuB,cAAc,oBAAoB;AAC3F;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,uBAAyC;AA8H3C,SAAS,eACd,OACA;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA,IAKd;AAAA,IACA,oBAAoB;AAAA,IACpB,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,OAAO,gBAAmB;AAAA,IAC9B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;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|
1
1
|
import type { ComponentPropsWithoutRef, ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
import { type LabelOverride } from "../i18n/kit-labels.js";
|
|
2
3
|
import { type TooltipSide } from "./tooltip.js";
|
|
3
4
|
import { type CommitScope } from "./write-lock.js";
|
|
5
|
+
import { DEFAULT_FIELD_SUGGESTION_LABELS } from "./field-suggestion-labels.js";
|
|
4
6
|
/**
|
|
5
7
|
* The pieces of a field's anatomy the kit's fields share — the static label, the hint
|
|
6
8
|
* (caption or "?"), the caption and the error under a field, the label strip over a
|
|
7
9
|
* bare group, the write lock on a control that saves itself, and the wiring under them
|
|
8
10
|
* (`aria-describedby`, refs). Private to the package — not re-exported from the barrel,
|
|
9
|
-
* except `FieldLabel
|
|
10
|
-
* 0.34 split it).
|
|
11
|
+
* except `FieldLabel`, `FLOATING_LABEL_STATIC`, `FieldHint` and (0.55) `FieldSuggestion`,
|
|
12
|
+
* which the barrel names (ui.tsx did until 0.34 split it).
|
|
11
13
|
*
|
|
12
14
|
* One file since 0.23: until then the pickers' half (`field-anatomy.tsx`: the date and
|
|
13
15
|
* month pickers, whose trigger is a button in a wrapper of their own, and the groups
|
|
@@ -115,7 +117,67 @@ export declare function FieldHint({ label, side, className, "aria-label": ariaLa
|
|
|
115
117
|
* ({@link fieldHelpMark}) — so a FieldHint is its words at EVERY size, not only at Large
|
|
116
118
|
* and on touch.
|
|
117
119
|
*/
|
|
118
|
-
export declare function useInlineHint(hint: ReactNode, withHelp?: boolean): ReactNode;
|
|
120
|
+
export declare function useInlineHint(hint: ReactNode, withHelp?: boolean, name?: ReactNode): ReactNode;
|
|
121
|
+
export interface FieldSuggestionLabels {
|
|
122
|
+
/** The caption when the field names no source: the value was filled in for the user. */
|
|
123
|
+
suggested: string;
|
|
124
|
+
/** The button after the caption that takes the suggested value back out. */
|
|
125
|
+
clear: string;
|
|
126
|
+
/** That button's accessible name — with the field's name when it has one ("Clear the
|
|
127
|
+
* suggestion for “Category”"), else alone. It holds `clear`'s word, the one a voice
|
|
128
|
+
* user says to press it (WCAG 2.5.3), first where the language allows. */
|
|
129
|
+
clearName: (field?: string) => string;
|
|
130
|
+
}
|
|
131
|
+
export { DEFAULT_FIELD_SUGGESTION_LABELS };
|
|
132
|
+
export interface FieldSuggestionProps {
|
|
133
|
+
/**
|
|
134
|
+
* Where the value came from, in the app's words: "From the memo", "Last used",
|
|
135
|
+
* "From the receipt". Default the kit's "Suggested" (`fieldSuggestion.suggested`).
|
|
136
|
+
*/
|
|
137
|
+
from?: ReactNode;
|
|
138
|
+
/**
|
|
139
|
+
* Take the suggestion back: the app empties the field (or restores what was there), and
|
|
140
|
+
* stops passing the caption. With it, a "Clear" button follows the words; without it,
|
|
141
|
+
* the caption is words alone and the field's own editing is the way to change it.
|
|
142
|
+
*/
|
|
143
|
+
onClear?: () => void;
|
|
144
|
+
/** The field's name in the button's accessible name. The kit's fields fill it in from
|
|
145
|
+
* their label (else `aria-label`); set it for a caption drawn outside a field. */
|
|
146
|
+
field?: string;
|
|
147
|
+
/** Prop > `<UiKitProvider labels={{ fieldSuggestion }}>` > English. */
|
|
148
|
+
labels?: LabelOverride<FieldSuggestionLabels>;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* A field's "suggested from" caption (0.55, keksdose dev #638): the line under a field
|
|
152
|
+
* the app filled in for the user, saying where the value came from — "From the memo",
|
|
153
|
+
* "Last used" — and, with `onClear`, a button that takes it back out.
|
|
154
|
+
*
|
|
155
|
+
* keksdose drew it by hand twice: the memo's category under the category field (a `<p>`
|
|
156
|
+
* of the caption's type, wired to the field's `aria-describedby` by its own id) and the
|
|
157
|
+
* create card's "Last used account" as a plain `hint`. The kit's fields take it as their
|
|
158
|
+
* `hint`, so the wiring is theirs:
|
|
159
|
+
*
|
|
160
|
+
* ```tsx
|
|
161
|
+
* <CategoryCombobox
|
|
162
|
+
* hint={fromMemo ? <FieldSuggestion from={t("from_memo")} onClear={clearCategory} /> : undefined}
|
|
163
|
+
* />
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* It is a CAPTION at every size, as a text hint is — under the field, on its
|
|
167
|
+
* `aria-describedby`, never a "?" on the label line — in every field that takes a `hint`
|
|
168
|
+
* (Input, Select, Textarea, the comboboxes, the pickers, the number fields, `Field`,
|
|
169
|
+
* `RhfField` and the bound fields, the groups). The hint slot is one: while the value is
|
|
170
|
+
* the suggestion, the caption takes the place of the field's own hint, and the app passes
|
|
171
|
+
* its hint back once the user has chosen. A fact that must stay beside it goes in `help`.
|
|
172
|
+
*
|
|
173
|
+
* The button is part of the caption, so the field's description is the words and then the
|
|
174
|
+
* button ("From the memo … Clear"; the "·" between them is not read): a screen reader
|
|
175
|
+
* learns there is a way back, and the button is the next tab stop after the field.
|
|
176
|
+
*/
|
|
177
|
+
export declare function FieldSuggestion({ from, onClear, field, labels: labelsProp }: FieldSuggestionProps): import("react").JSX.Element;
|
|
178
|
+
/** Whether a `hint` is a {@link FieldSuggestion} — a caption under the field at every
|
|
179
|
+
* size, as text is (0.55). */
|
|
180
|
+
export declare function isSuggestionHint(hint: ReactNode): boolean;
|
|
119
181
|
/**
|
|
120
182
|
* The doc every field's `help` prop points at.
|
|
121
183
|
*
|
|
@@ -187,8 +249,8 @@ export interface FieldHintParts {
|
|
|
187
249
|
}
|
|
188
250
|
/**
|
|
189
251
|
* Whether a resolved `hint` goes under the field as its caption: text always (see
|
|
190
|
-
* {@link isTextHint}); with a `help` beside it,
|
|
191
|
-
* is the help's (round 0.36, §4).
|
|
252
|
+
* {@link isTextHint}), and a {@link FieldSuggestion} (0.55); with a `help` beside it,
|
|
253
|
+
* whatever it is — the label line's "?" is the help's (round 0.36, §4).
|
|
192
254
|
*/
|
|
193
255
|
export declare function isHintCaption(hint: ReactNode, withHelp: boolean): boolean;
|
|
194
256
|
/**
|
|
@@ -291,9 +353,23 @@ export interface LockReason {
|
|
|
291
353
|
* The lock's reason wins over the control's own (`useCommitReason`).
|
|
292
354
|
*/
|
|
293
355
|
export declare function useLockReason(commit: CommitScope | undefined, disabledReason: ReactNode): LockReason;
|
|
356
|
+
/** {@link useRefusal}'s answer: the lock's, and whether the button refuses at all. */
|
|
357
|
+
export interface Refusal extends LockReason {
|
|
358
|
+
/** The button refuses: it has a reason (`locked`), or `refused` was given as `true`. */
|
|
359
|
+
refused: boolean;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Button's and IconButton's `refused`, `disabledReason` and `commit`, read as one (0.52
|
|
363
|
+
* code review 2026-10-31, held to 0.55). `refused` as words is the reason, the path
|
|
364
|
+
* `disabledReason` has always taken, and its words win over `disabledReason`'s;
|
|
365
|
+
* `refused={true}` refuses with no words of its own; a lock's reason wins over both, as
|
|
366
|
+
* {@link useLockReason} has it.
|
|
367
|
+
*/
|
|
368
|
+
export declare function useRefusal(refused: ReactNode, disabledReason: ReactNode, commit: CommitScope | undefined): Refusal;
|
|
294
369
|
/**
|
|
295
370
|
* A locked control and its reason — the kit's ONE frame for it, used by Button,
|
|
296
|
-
* IconButton, Chip, Checkbox, Switch and every field that locks (
|
|
371
|
+
* IconButton, Chip, Checkbox, Switch and every field that locks (the fields through
|
|
372
|
+
* {@link LockFrame} since 0.55) (DUP-3, refactor audit
|
|
297
373
|
* 2026-10: Button's `ReasonFrame` and Chip's `ChipReasonFrame` were copies of it, and
|
|
298
374
|
* only those two drew the line, so a field locked through `commit` kept its reason in a
|
|
299
375
|
* tooltip on a phone while the Save beside it said it in words). Where it shows is
|
|
@@ -329,6 +405,32 @@ export declare function LockedReason({ lock, display, line: lineProp, side, port
|
|
|
329
405
|
lineClassName?: string;
|
|
330
406
|
children: ReactNode;
|
|
331
407
|
}): import("react").JSX.Element;
|
|
408
|
+
/**
|
|
409
|
+
* A field in its lock's frame: in {@link LockedReason} while `lock` holds (a write lock's
|
|
410
|
+
* reason through `commit`, or the field's own `disabledReason`), else the field as it is —
|
|
411
|
+
* no element and no hook added.
|
|
412
|
+
*
|
|
413
|
+
* The fields' ONE helper for it, held back from 0.53 (0.52 code review,
|
|
414
|
+
* date-picker.tsx:300). Fifteen fields wrote the same ternary around the same frame:
|
|
415
|
+
* `withReason` in DatePicker, MonthPicker, Input and Select, `withLock` in Combobox,
|
|
416
|
+
* InlineEntityCombobox, EntityCombobox, MultiEntityCombobox and Autocomplete, one inline in
|
|
417
|
+
* DateRangePicker, NumberInput, MultiSelect, CountrySelect and CurrencySelect, and
|
|
418
|
+
* AmountInput's `LockedOrNot` — so a change to the frame's box had to be made in each.
|
|
419
|
+
*
|
|
420
|
+
* The frame is `block`, so a full-width field stays full width in it, then `className`. A
|
|
421
|
+
* field whose root it is while locked moves the caller's layout classes (a width, a grid
|
|
422
|
+
* cell) here, so a lock does not reflow the form; a display class there replaces `block`
|
|
423
|
+
* (CountrySelect's `flex w-full items-stretch`, so its trigger keeps the full width).
|
|
424
|
+
*/
|
|
425
|
+
export declare function LockFrame({ lock, display, className, children, }: {
|
|
426
|
+
/** The field's lock (`useLockReason`): framed only while `locked`. */
|
|
427
|
+
lock: Pick<LockReason, "locked" | "reason" | "reasonId">;
|
|
428
|
+
/** Where the reason shows — the field's `disabledReasonDisplay`. Default `"auto"`. */
|
|
429
|
+
display?: DisabledReasonDisplay;
|
|
430
|
+
/** The frame's classes, after `block`. */
|
|
431
|
+
className?: string;
|
|
432
|
+
children: ReactNode;
|
|
433
|
+
}): import("react").JSX.Element;
|
|
332
434
|
/**
|
|
333
435
|
* Where a control's `disabledReason` is shown (§4 "No fact only in a tooltip"):
|
|
334
436
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, isValidElement, useContext, useId } from "react";
|
|
3
|
+
import { cloneElement, createContext, isValidElement, useContext, useId } from "react";
|
|
4
4
|
import { HelpCircle } from "lucide-react";
|
|
5
5
|
import { cn } from "../lib/cn.js";
|
|
6
6
|
import { hasContent } from "../lib/presence.js";
|
|
@@ -11,6 +11,7 @@ import { FOCUS_RING } from "./focus-ring.js";
|
|
|
11
11
|
import { HelpPopover } from "./help-popover.js";
|
|
12
12
|
import { Tooltip } from "./tooltip.js";
|
|
13
13
|
import { useCommitReason } from "./write-lock.js";
|
|
14
|
+
import { DEFAULT_FIELD_SUGGESTION_LABELS } from "./field-suggestion-labels.js";
|
|
14
15
|
function mergeDescribedBy(...ids) {
|
|
15
16
|
const list = ids.filter(Boolean);
|
|
16
17
|
return list.length ? list.join(" ") : void 0;
|
|
@@ -55,13 +56,47 @@ function FieldHint({ label, side = "start", className, "aria-label": ariaLabel,
|
|
|
55
56
|
) })
|
|
56
57
|
);
|
|
57
58
|
}
|
|
58
|
-
function useInlineHint(hint, withHelp = false) {
|
|
59
|
+
function useInlineHint(hint, withHelp = false, name) {
|
|
59
60
|
const inline = useInlineFacts();
|
|
60
61
|
if ((inline || withHelp) && isValidElement(hint) && hint.type === FieldHint) {
|
|
61
62
|
const words = hint.props.label;
|
|
62
63
|
if (words) return words;
|
|
63
64
|
}
|
|
64
|
-
return hint;
|
|
65
|
+
return namedSuggestion(hint, name);
|
|
66
|
+
}
|
|
67
|
+
function FieldSuggestion({ from, onClear, field, labels: labelsProp }) {
|
|
68
|
+
const labels = useKitLabels("fieldSuggestion", DEFAULT_FIELD_SUGGESTION_LABELS, labelsProp);
|
|
69
|
+
return (
|
|
70
|
+
// Inline: the field's caption (`<p>`) holds it, and a `<p>` holds no block.
|
|
71
|
+
/* @__PURE__ */ jsxs("span", { "data-slot": "field-suggestion", children: [
|
|
72
|
+
hasContent(from) ? from : labels.suggested,
|
|
73
|
+
onClear && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
74
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
"button",
|
|
77
|
+
{
|
|
78
|
+
type: "button",
|
|
79
|
+
onClick: onClear,
|
|
80
|
+
"aria-label": labels.clearName(field),
|
|
81
|
+
className: cn(
|
|
82
|
+
"rounded-sm font-medium text-secondary underline underline-offset-2 transition-colors hover:text-primary",
|
|
83
|
+
"focus-visible:outline-focus focus-visible:outline-offset-2 focus-visible:outline-brand"
|
|
84
|
+
),
|
|
85
|
+
children: labels.clear
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
] })
|
|
89
|
+
] })
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
function isSuggestionHint(hint) {
|
|
93
|
+
return isValidElement(hint) && hint.type === FieldSuggestion;
|
|
94
|
+
}
|
|
95
|
+
function namedSuggestion(hint, name) {
|
|
96
|
+
if (!isValidElement(hint) || hint.type !== FieldSuggestion) return hint;
|
|
97
|
+
if (hint.props.field !== void 0) return hint;
|
|
98
|
+
const field = plainText(name);
|
|
99
|
+
return field === void 0 ? hint : cloneElement(hint, { field });
|
|
65
100
|
}
|
|
66
101
|
function FieldHelp({ name, children }) {
|
|
67
102
|
const common = useKitLabels("common", DEFAULT_COMMON_LABELS);
|
|
@@ -78,12 +113,12 @@ function isTextHint(hint) {
|
|
|
78
113
|
}
|
|
79
114
|
const FIELD_CAPTION_CLASS = "mt-1 text-caption leading-tight text-muted";
|
|
80
115
|
function isHintCaption(hint, withHelp) {
|
|
81
|
-
return isTextHint(hint) || withHelp && hasContent(hint);
|
|
116
|
+
return isTextHint(hint) || isSuggestionHint(hint) || withHelp && hasContent(hint);
|
|
82
117
|
}
|
|
83
118
|
function useFieldHint(hintProp, describedBy, { help, name } = {}) {
|
|
84
119
|
const helpMark = fieldHelpMark(help, name);
|
|
85
120
|
const withHelp = helpMark !== void 0;
|
|
86
|
-
const hint = useInlineHint(hintProp, withHelp);
|
|
121
|
+
const hint = useInlineHint(hintProp, withHelp, name);
|
|
87
122
|
const captionId = useId();
|
|
88
123
|
const caption = isHintCaption(hint, withHelp);
|
|
89
124
|
return {
|
|
@@ -141,6 +176,10 @@ function useLockReason(commit, disabledReason) {
|
|
|
141
176
|
const reasonId = useId();
|
|
142
177
|
return { reason, locked: hasContent(reason), reasonId };
|
|
143
178
|
}
|
|
179
|
+
function useRefusal(refused, disabledReason, commit) {
|
|
180
|
+
const lock = useLockReason(commit, refused !== true && hasContent(refused) ? refused : disabledReason);
|
|
181
|
+
return { ...lock, refused: lock.locked || refused === true };
|
|
182
|
+
}
|
|
144
183
|
function LockedReason({
|
|
145
184
|
lock,
|
|
146
185
|
display,
|
|
@@ -160,6 +199,15 @@ function LockedReason({
|
|
|
160
199
|
/* @__PURE__ */ jsx("span", { id: lock.reasonId, hidden: true, children: lock.reason })
|
|
161
200
|
] }) });
|
|
162
201
|
}
|
|
202
|
+
function LockFrame({
|
|
203
|
+
lock,
|
|
204
|
+
display,
|
|
205
|
+
className,
|
|
206
|
+
children
|
|
207
|
+
}) {
|
|
208
|
+
if (!lock.locked) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
209
|
+
return /* @__PURE__ */ jsx(LockedReason, { lock, display, className: cn("block", className), children });
|
|
210
|
+
}
|
|
163
211
|
const CompactControlsContext = createContext(false);
|
|
164
212
|
function CompactControls({ children, compact = true }) {
|
|
165
213
|
return /* @__PURE__ */ jsx(CompactControlsContext.Provider, { value: compact, children });
|
|
@@ -267,6 +315,7 @@ function LabelStrip({
|
|
|
267
315
|
export {
|
|
268
316
|
CompactControls,
|
|
269
317
|
CompactControlsContext,
|
|
318
|
+
DEFAULT_FIELD_SUGGESTION_LABELS,
|
|
270
319
|
DISABLED_REASON_LINE_CLASS,
|
|
271
320
|
DisabledReasonLine,
|
|
272
321
|
EndHintRow,
|
|
@@ -278,11 +327,13 @@ export {
|
|
|
278
327
|
FieldHint,
|
|
279
328
|
FieldLabel,
|
|
280
329
|
FieldLabelLine,
|
|
330
|
+
FieldSuggestion,
|
|
281
331
|
LABEL_ABOVE_AT_LARGE,
|
|
282
332
|
LABEL_ABOVE_BOX,
|
|
283
333
|
LABEL_IN_ROW,
|
|
284
334
|
LABEL_STRIP_PAD,
|
|
285
335
|
LabelStrip,
|
|
336
|
+
LockFrame,
|
|
286
337
|
LockedReason,
|
|
287
338
|
RequiredStarOnLegend,
|
|
288
339
|
STATIC_LABEL_TYPE,
|
|
@@ -290,6 +341,7 @@ export {
|
|
|
290
341
|
assignRef,
|
|
291
342
|
fieldHelpMark,
|
|
292
343
|
isHintCaption,
|
|
344
|
+
isSuggestionHint,
|
|
293
345
|
isTextHint,
|
|
294
346
|
mergeDescribedBy,
|
|
295
347
|
mergeRefs,
|
|
@@ -298,6 +350,7 @@ export {
|
|
|
298
350
|
useFieldHint,
|
|
299
351
|
useFieldMessages,
|
|
300
352
|
useInlineHint,
|
|
301
|
-
useLockReason
|
|
353
|
+
useLockReason,
|
|
354
|
+
useRefusal
|
|
302
355
|
};
|
|
303
356
|
//# sourceMappingURL=field-parts.js.map
|