@invoiceonline/ui-react 0.0.0-stage → 0.1.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/AGENTS.md +99 -0
- package/CHANGELOG.md +131 -0
- package/LICENSE +9 -0
- package/README.md +78 -2
- package/dist/assets/label-brush-1.svg +6 -0
- package/dist/assets/pattern-dark.svg +113 -0
- package/dist/components/action-row/ActionRow.d.ts +178 -0
- package/dist/components/action-row/ActionRow.js +340 -0
- package/dist/components/action-row/index.d.ts +2 -0
- package/dist/components/action-row/index.js +1 -0
- package/dist/components/alert/Alert.d.ts +314 -0
- package/dist/components/alert/Alert.js +446 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +1 -0
- package/dist/components/anchored-panel/AnchoredPanel.d.ts +41 -0
- package/dist/components/anchored-panel/AnchoredPanel.js +72 -0
- package/dist/components/anchored-panel/index.d.ts +3 -0
- package/dist/components/anchored-panel/index.js +3 -0
- package/dist/components/badge/Badge.d.ts +146 -0
- package/dist/components/badge/Badge.js +258 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/banner/Banner.d.ts +209 -0
- package/dist/components/banner/Banner.js +339 -0
- package/dist/components/banner/index.d.ts +2 -0
- package/dist/components/banner/index.js +1 -0
- package/dist/components/button/Button.d.ts +54 -0
- package/dist/components/button/Button.js +312 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/button-group/ButtonGroup.d.ts +187 -0
- package/dist/components/button-group/ButtonGroup.js +217 -0
- package/dist/components/button-group/index.d.ts +2 -0
- package/dist/components/button-group/index.js +1 -0
- package/dist/components/card-select/CardSelect.d.ts +274 -0
- package/dist/components/card-select/CardSelect.js +561 -0
- package/dist/components/card-select/CardSelectGroup.d.ts +92 -0
- package/dist/components/card-select/CardSelectGroup.js +72 -0
- package/dist/components/card-select/index.d.ts +3 -0
- package/dist/components/card-select/index.js +3 -0
- package/dist/components/checkbox/Checkbox.d.ts +104 -0
- package/dist/components/checkbox/Checkbox.js +194 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/chip/Chip.d.ts +250 -0
- package/dist/components/chip/Chip.js +441 -0
- package/dist/components/chip/index.d.ts +2 -0
- package/dist/components/chip/index.js +1 -0
- package/dist/components/column-header/ColumnHeader.d.ts +144 -0
- package/dist/components/column-header/ColumnHeader.js +209 -0
- package/dist/components/column-header/index.d.ts +2 -0
- package/dist/components/column-header/index.js +1 -0
- package/dist/components/combobox-field/Combobox.d.ts +104 -0
- package/dist/components/combobox-field/Combobox.js +355 -0
- package/dist/components/combobox-field/ComboboxField.d.ts +76 -0
- package/dist/components/combobox-field/ComboboxField.js +98 -0
- package/dist/components/combobox-field/index.d.ts +3 -0
- package/dist/components/combobox-field/index.js +3 -0
- package/dist/components/date-field/DateField.d.ts +52 -0
- package/dist/components/date-field/DateField.js +45 -0
- package/dist/components/date-field/index.d.ts +2 -0
- package/dist/components/date-field/index.js +1 -0
- package/dist/components/date-picker/DatePicker.d.ts +53 -0
- package/dist/components/date-picker/DatePicker.js +329 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/divider/Divider.d.ts +81 -0
- package/dist/components/divider/Divider.js +93 -0
- package/dist/components/divider/index.d.ts +2 -0
- package/dist/components/divider/index.js +1 -0
- package/dist/components/drawer/Drawer.d.ts +128 -0
- package/dist/components/drawer/Drawer.js +367 -0
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/dropdown-button/DropdownButton.d.ts +72 -0
- package/dist/components/dropdown-button/DropdownButton.js +122 -0
- package/dist/components/dropdown-button/index.d.ts +2 -0
- package/dist/components/dropdown-button/index.js +1 -0
- package/dist/components/faq/FAQ.d.ts +135 -0
- package/dist/components/faq/FAQ.js +258 -0
- package/dist/components/faq/index.d.ts +2 -0
- package/dist/components/faq/index.js +1 -0
- package/dist/components/field/Field.d.ts +118 -0
- package/dist/components/field/Field.js +327 -0
- package/dist/components/field/index.d.ts +2 -0
- package/dist/components/field/index.js +1 -0
- package/dist/components/field-pair/FieldPair.d.ts +194 -0
- package/dist/components/field-pair/FieldPair.js +321 -0
- package/dist/components/field-pair/index.d.ts +2 -0
- package/dist/components/field-pair/index.js +1 -0
- package/dist/components/file-upload/FileUpload.d.ts +137 -0
- package/dist/components/file-upload/FileUpload.js +434 -0
- package/dist/components/file-upload/index.d.ts +2 -0
- package/dist/components/file-upload/index.js +1 -0
- package/dist/components/filter-chip/FilterChip.d.ts +373 -0
- package/dist/components/filter-chip/FilterChip.js +517 -0
- package/dist/components/filter-chip/index.d.ts +2 -0
- package/dist/components/filter-chip/index.js +1 -0
- package/dist/components/filter-facet/FilterFacet.d.ts +116 -0
- package/dist/components/filter-facet/FilterFacet.js +632 -0
- package/dist/components/filter-facet/index.d.ts +2 -0
- package/dist/components/filter-facet/index.js +1 -0
- package/dist/components/firm-avatar/FirmAvatar.d.ts +75 -0
- package/dist/components/firm-avatar/FirmAvatar.js +119 -0
- package/dist/components/firm-avatar/index.d.ts +2 -0
- package/dist/components/firm-avatar/index.js +1 -0
- package/dist/components/form-actions/FormActions.d.ts +123 -0
- package/dist/components/form-actions/FormActions.js +195 -0
- package/dist/components/form-actions/index.d.ts +2 -0
- package/dist/components/form-actions/index.js +1 -0
- package/dist/components/form-block/FormBlock.d.ts +252 -0
- package/dist/components/form-block/FormBlock.js +420 -0
- package/dist/components/form-block/index.d.ts +3 -0
- package/dist/components/form-block/index.js +3 -0
- package/dist/components/form-section/FormSection.d.ts +130 -0
- package/dist/components/form-section/FormSection.js +206 -0
- package/dist/components/form-section/index.d.ts +2 -0
- package/dist/components/form-section/index.js +1 -0
- package/dist/components/heading/Heading.d.ts +69 -0
- package/dist/components/heading/Heading.js +79 -0
- package/dist/components/heading/index.d.ts +2 -0
- package/dist/components/heading/index.js +1 -0
- package/dist/components/heading-group/HeadingGroup.d.ts +258 -0
- package/dist/components/heading-group/HeadingGroup.js +255 -0
- package/dist/components/heading-group/index.d.ts +2 -0
- package/dist/components/heading-group/index.js +1 -0
- package/dist/components/hero/Hero.d.ts +268 -0
- package/dist/components/hero/Hero.js +316 -0
- package/dist/components/hero/index.d.ts +2 -0
- package/dist/components/hero/index.js +1 -0
- package/dist/components/icon/Icon.d.ts +27 -0
- package/dist/components/icon/Icon.js +30 -0
- package/dist/components/icon/index.d.ts +3 -0
- package/dist/components/icon/index.js +3 -0
- package/dist/components/icon-button/IconButton.d.ts +75 -0
- package/dist/components/icon-button/IconButton.js +151 -0
- package/dist/components/icon-button/index.d.ts +2 -0
- package/dist/components/icon-button/index.js +1 -0
- package/dist/components/item-row/ItemRow.d.ts +253 -0
- package/dist/components/item-row/ItemRow.js +496 -0
- package/dist/components/item-row/index.d.ts +2 -0
- package/dist/components/item-row/index.js +1 -0
- package/dist/components/list-row/ListRow.d.ts +165 -0
- package/dist/components/list-row/ListRow.js +233 -0
- package/dist/components/list-row/index.d.ts +2 -0
- package/dist/components/list-row/index.js +1 -0
- package/dist/components/menu/Menu.d.ts +64 -0
- package/dist/components/menu/Menu.js +186 -0
- package/dist/components/menu/index.d.ts +2 -0
- package/dist/components/menu/index.js +1 -0
- package/dist/components/modal/Modal.d.ts +272 -0
- package/dist/components/modal/Modal.js +788 -0
- package/dist/components/modal/index.d.ts +2 -0
- package/dist/components/modal/index.js +1 -0
- package/dist/components/nav-link/NavLink.d.ts +123 -0
- package/dist/components/nav-link/NavLink.js +157 -0
- package/dist/components/nav-link/index.d.ts +2 -0
- package/dist/components/nav-link/index.js +1 -0
- package/dist/components/number-field/NumberField.d.ts +62 -0
- package/dist/components/number-field/NumberField.js +210 -0
- package/dist/components/number-field/index.d.ts +2 -0
- package/dist/components/number-field/index.js +1 -0
- package/dist/components/pagination/Pagination.d.ts +133 -0
- package/dist/components/pagination/Pagination.js +217 -0
- package/dist/components/pagination/index.d.ts +3 -0
- package/dist/components/pagination/index.js +3 -0
- package/dist/components/popover-surface/index.d.ts +2 -0
- package/dist/components/popover-surface/index.js +1 -0
- package/dist/components/progress-bar/ProgressBar.d.ts +260 -0
- package/dist/components/progress-bar/ProgressBar.js +470 -0
- package/dist/components/progress-bar/index.d.ts +2 -0
- package/dist/components/progress-bar/index.js +1 -0
- package/dist/components/promo-sticker/PromoSticker.d.ts +204 -0
- package/dist/components/promo-sticker/PromoSticker.js +177 -0
- package/dist/components/promo-sticker/index.d.ts +2 -0
- package/dist/components/promo-sticker/index.js +1 -0
- package/dist/components/promo-surface/PromoSurface.d.ts +94 -0
- package/dist/components/promo-surface/PromoSurface.js +119 -0
- package/dist/components/promo-surface/index.d.ts +2 -0
- package/dist/components/promo-surface/index.js +1 -0
- package/dist/components/radio/Radio.d.ts +92 -0
- package/dist/components/radio/Radio.js +171 -0
- package/dist/components/radio/index.d.ts +2 -0
- package/dist/components/radio/index.js +1 -0
- package/dist/components/radio-group/RadioGroup.d.ts +61 -0
- package/dist/components/radio-group/RadioGroup.js +51 -0
- package/dist/components/radio-group/index.d.ts +2 -0
- package/dist/components/radio-group/index.js +1 -0
- package/dist/components/select/Select.d.ts +65 -0
- package/dist/components/select/Select.js +176 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/select-field/SelectField.d.ts +16 -0
- package/dist/components/select-field/SelectField.js +55 -0
- package/dist/components/select-field/index.d.ts +2 -0
- package/dist/components/select-field/index.js +1 -0
- package/dist/components/skeleton/Skeleton.d.ts +64 -0
- package/dist/components/skeleton/Skeleton.js +65 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/split-button/SplitButton.d.ts +80 -0
- package/dist/components/split-button/SplitButton.js +182 -0
- package/dist/components/split-button/index.d.ts +2 -0
- package/dist/components/split-button/index.js +1 -0
- package/dist/components/status-summary-bar/StatusSummaryBar.d.ts +118 -0
- package/dist/components/status-summary-bar/StatusSummaryBar.js +278 -0
- package/dist/components/status-summary-bar/index.d.ts +2 -0
- package/dist/components/status-summary-bar/index.js +1 -0
- package/dist/components/subject-lookup-field/SubjectLookupField.d.ts +157 -0
- package/dist/components/subject-lookup-field/SubjectLookupField.js +663 -0
- package/dist/components/subject-lookup-field/index.d.ts +2 -0
- package/dist/components/subject-lookup-field/index.js +1 -0
- package/dist/components/switch/Switch.d.ts +152 -0
- package/dist/components/switch/Switch.js +307 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/table/Table.d.ts +5 -0
- package/dist/components/table/Table.js +601 -0
- package/dist/components/table/index.d.ts +6 -0
- package/dist/components/table/index.js +6 -0
- package/dist/components/text-field/TextField.d.ts +65 -0
- package/dist/components/text-field/TextField.js +173 -0
- package/dist/components/text-field/index.d.ts +2 -0
- package/dist/components/text-field/index.js +1 -0
- package/dist/components/text-link/TextLink.d.ts +260 -0
- package/dist/components/text-link/TextLink.js +303 -0
- package/dist/components/text-link/index.d.ts +2 -0
- package/dist/components/text-link/index.js +1 -0
- package/dist/components/textarea/Textarea.d.ts +93 -0
- package/dist/components/textarea/Textarea.js +256 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/tooltip/Tooltip.d.ts +129 -0
- package/dist/components/tooltip/Tooltip.js +457 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/unit-field/UnitField.d.ts +46 -0
- package/dist/components/unit-field/UnitField.js +133 -0
- package/dist/components/unit-field/index.d.ts +2 -0
- package/dist/components/unit-field/index.js +1 -0
- package/dist/icons/icon-registry.generated.js +500 -0
- package/dist/icons/icon-types.generated.d.ts +2 -0
- package/dist/icons/icon-types.generated.js +126 -0
- package/dist/index.d.ts +132 -0
- package/dist/index.js +75 -0
- package/dist/internal/BottomSheet.js +496 -0
- package/dist/internal/FodsProvider.d.ts +25 -0
- package/dist/internal/FodsProvider.js +32 -0
- package/dist/internal/MotionCaret.js +35 -0
- package/dist/internal/NumberFormatInput.d.ts +21 -0
- package/dist/internal/NumberFormatInput.js +126 -0
- package/dist/internal/SummaryDonut.d.ts +3 -0
- package/dist/internal/SummaryDonut.js +300 -0
- package/dist/internal/buttonSegment.d.ts +44 -0
- package/dist/internal/buttonSegment.js +126 -0
- package/dist/internal/collapseRoom.js +128 -0
- package/dist/internal/comboboxKeys.js +44 -0
- package/dist/internal/contentPresence.js +46 -0
- package/dist/internal/dayCell.js +95 -0
- package/dist/internal/dialogPortal.d.ts +2 -0
- package/dist/internal/dialogPortal.js +21 -0
- package/dist/internal/donutSweeps.js +65 -0
- package/dist/internal/enterOnViewGeometry.js +46 -0
- package/dist/internal/faqItem.js +80 -0
- package/dist/internal/floatingLabelMotion.js +68 -0
- package/dist/internal/formBlockContext.d.ts +22 -0
- package/dist/internal/formBlockContext.js +20 -0
- package/dist/internal/heightRoom.js +87 -0
- package/dist/internal/numberSeparators.js +62 -0
- package/dist/internal/overlayMotion.js +48 -0
- package/dist/internal/paginationItem.d.ts +8 -0
- package/dist/internal/paginationItem.js +22 -0
- package/dist/internal/popoverSurface.d.ts +8 -0
- package/dist/internal/popoverSurface.js +23 -0
- package/dist/internal/portalContainer.d.ts +1 -0
- package/dist/internal/portalContainer.js +6 -0
- package/dist/internal/progressBarItem.d.ts +207 -0
- package/dist/internal/progressBarItem.js +264 -0
- package/dist/internal/selectionControlText.js +12 -0
- package/dist/internal/statusSummaryParts.js +371 -0
- package/dist/internal/summaryMotion.js +75 -0
- package/dist/internal/table/ChildConnector.js +62 -0
- package/dist/internal/table/ChildRowPrefix.d.ts +9 -0
- package/dist/internal/table/ChildRowPrefix.js +27 -0
- package/dist/internal/table/ColumnSettings.js +135 -0
- package/dist/internal/table/ScrollRegion.js +114 -0
- package/dist/internal/table/TableEmpty.js +93 -0
- package/dist/internal/table/TableLayout.d.ts +17 -0
- package/dist/internal/table/TableLayout.js +29 -0
- package/dist/internal/table/TableLoadStatus.js +56 -0
- package/dist/internal/table/TableMobile.js +488 -0
- package/dist/internal/table/TruncatedCell.js +33 -0
- package/dist/internal/table/emptyValue.js +10 -0
- package/dist/internal/table/features.d.ts +41 -0
- package/dist/internal/table/features.js +31 -0
- package/dist/internal/table/recipes.js +227 -0
- package/dist/internal/table/rowClick.js +9 -0
- package/dist/internal/table/types.d.ts +325 -0
- package/dist/internal/table/types.js +13 -0
- package/dist/internal/tailwind-variants.d.ts +3 -0
- package/dist/internal/tailwind-variants.js +37 -0
- package/dist/internal/tooltipContext.js +5 -0
- package/dist/internal/tw-merge-config.generated.js +314 -0
- package/dist/internal/useAnchoredPanel.d.ts +87 -0
- package/dist/internal/useAnchoredPanel.js +108 -0
- package/dist/internal/useCountUp.js +53 -0
- package/dist/internal/useDateFieldTrigger.js +183 -0
- package/dist/internal/useEChart.js +59 -0
- package/dist/internal/useEnterOnView.js +42 -0
- package/dist/internal/useFloatingBar.js +100 -0
- package/dist/internal/useFormReset.js +37 -0
- package/dist/internal/useIsMobile.js +44 -0
- package/dist/internal/useOneRowOverflow.js +88 -0
- package/dist/internal/usePrefersReducedMotion.js +25 -0
- package/dist/internal/useReturnFocus.js +26 -0
- package/dist/internal/utils.d.ts +7 -0
- package/dist/internal/utils.js +58 -0
- package/dist/node_modules/@tanstack/store/dist/store.d.ts +29 -0
- package/dist/node_modules/@tanstack/store/dist/types.d.ts +38 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/cells/coreCellsFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/cells/coreCellsFeature.types.d.ts +53 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/columns/coreColumnsFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/columns/coreColumnsFeature.types.d.ts +90 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/coreFeatures.d.ts +17 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/headers/coreHeadersFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/headers/coreHeadersFeature.types.d.ts +114 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/reactivity/coreReactivityFeature.types.d.ts +51 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/row-models/coreRowModelsFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/row-models/coreRowModelsFeature.types.d.ts +29 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/rows/coreRowsFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/rows/coreRowsFeature.types.d.ts +129 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/table/coreTablesFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/core/table/coreTablesFeature.types.d.ts +203 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/cell-selection/cellSelectionFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/cell-selection/cellSelectionFeature.types.d.ts +294 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/cell-spanning/cellSpanningFeature.d.ts +11 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/cell-spanning/cellSpanningFeature.types.d.ts +148 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-faceting/columnFacetingFeature.d.ts +12 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-faceting/columnFacetingFeature.types.d.ts +63 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-filtering/columnFilteringFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-filtering/columnFilteringFeature.types.d.ts +209 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-filtering/filterFns.d.ts +35 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-grouping/columnGroupingFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-grouping/columnGroupingFeature.types.d.ts +128 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-ordering/columnOrderingFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-ordering/columnOrderingFeature.types.d.ts +82 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-pinning/columnPinningFeature.d.ts +11 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-pinning/columnPinningFeature.types.d.ts +195 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-resizing/columnResizingFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-resizing/columnResizingFeature.types.d.ts +73 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-sizing/columnSizingFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-sizing/columnSizingFeature.types.d.ts +134 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-visibility/columnVisibilityFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +92 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/global-filtering/globalFilteringFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/global-filtering/globalFilteringFeature.types.d.ts +67 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-aggregation/aggregationFns.d.ts +23 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-aggregation/rowAggregationFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-aggregation/rowAggregationFeature.types.d.ts +183 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-aggregation/rowAggregationFeature.utils.d.ts +18 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-expanding/rowExpandingFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-expanding/rowExpandingFeature.types.d.ts +125 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-pagination/rowPaginationFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-pagination/rowPaginationFeature.types.d.ts +135 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-pinning/rowPinningFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-pinning/rowPinningFeature.types.d.ts +76 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-selection/rowSelectionFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-selection/rowSelectionFeature.types.d.ts +187 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-sorting/rowSortingFeature.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-sorting/rowSortingFeature.types.d.ts +236 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/row-sorting/sortFns.d.ts +23 -0
- package/dist/node_modules/@tanstack/table-core/dist/features/stockFeatures.d.ts +37 -0
- package/dist/node_modules/@tanstack/table-core/dist/helpers/columnHelper.d.ts +47 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/Cell.d.ts +16 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/Column.d.ts +30 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/ColumnDef.d.ts +123 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/Header.d.ts +12 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/HeaderGroup.d.ts +6 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/Row.d.ts +24 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/RowModel.d.ts +19 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/RowModelFns.d.ts +11 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/Table.d.ts +53 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/TableFeatures.d.ts +416 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/TableOptions.d.ts +78 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/TableState.d.ts +46 -0
- package/dist/node_modules/@tanstack/table-core/dist/types/type-utils.d.ts +25 -0
- package/dist/shared.css +179 -0
- package/dist/styles.css +5467 -0
- package/dist/theme.css +314 -0
- package/dist/theme.map.json +278 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +1 -0
- package/dist/tokens/tokens.generated.d.ts +2040 -0
- package/dist/tokens/tokens.generated.js +2053 -0
- package/dist/tokens.css +484 -0
- package/dist/tokens.flat.json +429 -0
- package/docs/Consuming.mdx +379 -0
- package/docs/Contributing.mdx +78 -0
- package/docs/ForAgents.mdx +53 -0
- package/docs/Introduction.mdx +54 -0
- package/llms.txt +556 -0
- package/package.json +357 -4
- package/src/components/action-row/ActionRow.mdx +686 -0
- package/src/components/action-row/ActionRow.stories.tsx +669 -0
- package/src/components/action-row/ActionRow.tsx +632 -0
- package/src/components/action-row/index.ts +9 -0
- package/src/components/alert/Alert.mdx +377 -0
- package/src/components/alert/Alert.stories.tsx +674 -0
- package/src/components/alert/Alert.tsx +579 -0
- package/src/components/alert/index.ts +13 -0
- package/src/components/anchored-panel/AnchoredPanel.mdx +381 -0
- package/src/components/anchored-panel/AnchoredPanel.stories.tsx +593 -0
- package/src/components/anchored-panel/AnchoredPanel.tsx +176 -0
- package/src/components/anchored-panel/index.ts +15 -0
- package/src/components/badge/Badge.mdx +487 -0
- package/src/components/badge/Badge.stories.tsx +375 -0
- package/src/components/badge/Badge.tsx +360 -0
- package/src/components/badge/index.ts +10 -0
- package/src/components/banner/Banner.mdx +704 -0
- package/src/components/banner/Banner.stories.tsx +448 -0
- package/src/components/banner/Banner.tsx +602 -0
- package/src/components/banner/index.ts +14 -0
- package/src/components/button/Button.mdx +286 -0
- package/src/components/button/Button.stories.tsx +381 -0
- package/src/components/button/Button.tsx +384 -0
- package/src/components/button/index.ts +1 -0
- package/src/components/button-group/ButtonGroup.mdx +512 -0
- package/src/components/button-group/ButtonGroup.stories.tsx +714 -0
- package/src/components/button-group/ButtonGroup.tsx +491 -0
- package/src/components/button-group/index.ts +10 -0
- package/src/components/card-select/CardSelect.mdx +662 -0
- package/src/components/card-select/CardSelect.stories.tsx +784 -0
- package/src/components/card-select/CardSelect.tsx +783 -0
- package/src/components/card-select/CardSelectGroup.tsx +169 -0
- package/src/components/card-select/index.ts +18 -0
- package/src/components/checkbox/Checkbox.mdx +269 -0
- package/src/components/checkbox/Checkbox.stories.tsx +306 -0
- package/src/components/checkbox/Checkbox.tsx +343 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/chip/Chip.mdx +683 -0
- package/src/components/chip/Chip.stories.tsx +734 -0
- package/src/components/chip/Chip.tsx +732 -0
- package/src/components/chip/index.ts +9 -0
- package/src/components/column-header/ColumnHeader.mdx +301 -0
- package/src/components/column-header/ColumnHeader.stories.tsx +319 -0
- package/src/components/column-header/ColumnHeader.tsx +287 -0
- package/src/components/column-header/index.ts +7 -0
- package/src/components/combobox-field/Combobox.tsx +693 -0
- package/src/components/combobox-field/ComboboxField.mdx +525 -0
- package/src/components/combobox-field/ComboboxField.stories.tsx +502 -0
- package/src/components/combobox-field/ComboboxField.tsx +259 -0
- package/src/components/combobox-field/index.ts +12 -0
- package/src/components/date-field/DateField.mdx +340 -0
- package/src/components/date-field/DateField.stories.tsx +221 -0
- package/src/components/date-field/DateField.tsx +176 -0
- package/src/components/date-field/index.ts +1 -0
- package/src/components/date-picker/DatePicker.mdx +436 -0
- package/src/components/date-picker/DatePicker.stories.tsx +458 -0
- package/src/components/date-picker/DatePicker.tsx +688 -0
- package/src/components/date-picker/index.ts +9 -0
- package/src/components/divider/Divider.mdx +256 -0
- package/src/components/divider/Divider.stories.tsx +177 -0
- package/src/components/divider/Divider.tsx +193 -0
- package/src/components/divider/index.ts +1 -0
- package/src/components/drawer/Drawer.mdx +518 -0
- package/src/components/drawer/Drawer.stories.tsx +392 -0
- package/src/components/drawer/Drawer.tsx +683 -0
- package/src/components/drawer/index.ts +1 -0
- package/src/components/dropdown-button/DropdownButton.mdx +285 -0
- package/src/components/dropdown-button/DropdownButton.stories.tsx +398 -0
- package/src/components/dropdown-button/DropdownButton.tsx +198 -0
- package/src/components/dropdown-button/index.ts +7 -0
- package/src/components/faq/FAQ.mdx +364 -0
- package/src/components/faq/FAQ.stories.tsx +343 -0
- package/src/components/faq/FAQ.tsx +337 -0
- package/src/components/faq/index.ts +1 -0
- package/src/components/field/Field.mdx +129 -0
- package/src/components/field/Field.stories.tsx +461 -0
- package/src/components/field/Field.tsx +765 -0
- package/src/components/field/index.ts +20 -0
- package/src/components/field-pair/FieldPair.mdx +308 -0
- package/src/components/field-pair/FieldPair.stories.tsx +530 -0
- package/src/components/field-pair/FieldPair.tsx +796 -0
- package/src/components/field-pair/index.ts +9 -0
- package/src/components/file-upload/FileUpload.mdx +345 -0
- package/src/components/file-upload/FileUpload.stories.tsx +698 -0
- package/src/components/file-upload/FileUpload.tsx +802 -0
- package/src/components/file-upload/index.ts +6 -0
- package/src/components/filter-chip/FilterChip.mdx +778 -0
- package/src/components/filter-chip/FilterChip.stories.tsx +827 -0
- package/src/components/filter-chip/FilterChip.tsx +881 -0
- package/src/components/filter-chip/index.ts +11 -0
- package/src/components/filter-facet/FilterFacet.mdx +536 -0
- package/src/components/filter-facet/FilterFacet.stories.tsx +506 -0
- package/src/components/filter-facet/FilterFacet.tsx +1160 -0
- package/src/components/filter-facet/index.ts +7 -0
- package/src/components/firm-avatar/FirmAvatar.mdx +280 -0
- package/src/components/firm-avatar/FirmAvatar.stories.tsx +147 -0
- package/src/components/firm-avatar/FirmAvatar.tsx +172 -0
- package/src/components/firm-avatar/index.ts +7 -0
- package/src/components/form-actions/FormActions.mdx +518 -0
- package/src/components/form-actions/FormActions.stories.tsx +621 -0
- package/src/components/form-actions/FormActions.tsx +273 -0
- package/src/components/form-actions/index.ts +6 -0
- package/src/components/form-block/FormBlock.mdx +728 -0
- package/src/components/form-block/FormBlock.stories.tsx +813 -0
- package/src/components/form-block/FormBlock.tsx +679 -0
- package/src/components/form-block/index.ts +13 -0
- package/src/components/form-section/FormSection.mdx +436 -0
- package/src/components/form-section/FormSection.stories.tsx +407 -0
- package/src/components/form-section/FormSection.tsx +290 -0
- package/src/components/form-section/index.ts +17 -0
- package/src/components/heading/Heading.mdx +206 -0
- package/src/components/heading/Heading.stories.tsx +169 -0
- package/src/components/heading/Heading.tsx +124 -0
- package/src/components/heading/index.ts +8 -0
- package/src/components/heading-group/HeadingGroup.mdx +521 -0
- package/src/components/heading-group/HeadingGroup.stories.tsx +353 -0
- package/src/components/heading-group/HeadingGroup.tsx +396 -0
- package/src/components/heading-group/index.ts +7 -0
- package/src/components/hero/Hero.mdx +742 -0
- package/src/components/hero/Hero.stories.tsx +527 -0
- package/src/components/hero/Hero.tsx +807 -0
- package/src/components/hero/index.ts +1 -0
- package/src/components/icon/Icon.mdx +329 -0
- package/src/components/icon/Icon.stories.tsx +398 -0
- package/src/components/icon/Icon.tsx +97 -0
- package/src/components/icon/index.ts +2 -0
- package/src/components/icon-button/IconButton.mdx +206 -0
- package/src/components/icon-button/IconButton.stories.tsx +341 -0
- package/src/components/icon-button/IconButton.tsx +273 -0
- package/src/components/icon-button/index.ts +1 -0
- package/src/components/item-row/ItemRow.mdx +533 -0
- package/src/components/item-row/ItemRow.stories.tsx +434 -0
- package/src/components/item-row/ItemRow.tsx +676 -0
- package/src/components/item-row/index.ts +9 -0
- package/src/components/list-row/ListRow.mdx +404 -0
- package/src/components/list-row/ListRow.stories.tsx +404 -0
- package/src/components/list-row/ListRow.tsx +424 -0
- package/src/components/list-row/index.ts +1 -0
- package/src/components/menu/Menu.mdx +268 -0
- package/src/components/menu/Menu.stories.tsx +455 -0
- package/src/components/menu/Menu.tsx +452 -0
- package/src/components/menu/index.ts +1 -0
- package/src/components/modal/Modal.mdx +854 -0
- package/src/components/modal/Modal.stories.tsx +881 -0
- package/src/components/modal/Modal.tsx +1434 -0
- package/src/components/modal/index.ts +1 -0
- package/src/components/nav-link/NavLink.mdx +196 -0
- package/src/components/nav-link/NavLink.stories.tsx +243 -0
- package/src/components/nav-link/NavLink.tsx +222 -0
- package/src/components/nav-link/index.ts +1 -0
- package/src/components/number-field/NumberField.mdx +223 -0
- package/src/components/number-field/NumberField.stories.tsx +291 -0
- package/src/components/number-field/NumberField.tsx +388 -0
- package/src/components/number-field/index.ts +6 -0
- package/src/components/pagination/Pagination.mdx +305 -0
- package/src/components/pagination/Pagination.stories.tsx +333 -0
- package/src/components/pagination/Pagination.tsx +343 -0
- package/src/components/pagination/index.ts +8 -0
- package/src/components/popover-surface/PopoverSurface.mdx +158 -0
- package/src/components/popover-surface/PopoverSurface.stories.tsx +421 -0
- package/src/components/popover-surface/index.ts +1 -0
- package/src/components/progress-bar/ProgressBar.mdx +802 -0
- package/src/components/progress-bar/ProgressBar.stories.tsx +533 -0
- package/src/components/progress-bar/ProgressBar.tsx +654 -0
- package/src/components/progress-bar/index.ts +9 -0
- package/src/components/promo-sticker/PromoSticker.mdx +436 -0
- package/src/components/promo-sticker/PromoSticker.stories.tsx +363 -0
- package/src/components/promo-sticker/PromoSticker.tsx +313 -0
- package/src/components/promo-sticker/index.ts +7 -0
- package/src/components/promo-surface/PromoSurface.mdx +399 -0
- package/src/components/promo-surface/PromoSurface.stories.tsx +270 -0
- package/src/components/promo-surface/PromoSurface.tsx +305 -0
- package/src/components/promo-surface/index.ts +7 -0
- package/src/components/radio/Radio.mdx +243 -0
- package/src/components/radio/Radio.stories.tsx +307 -0
- package/src/components/radio/Radio.tsx +288 -0
- package/src/components/radio/index.ts +1 -0
- package/src/components/radio-group/RadioGroup.mdx +119 -0
- package/src/components/radio-group/RadioGroup.stories.tsx +225 -0
- package/src/components/radio-group/RadioGroup.tsx +139 -0
- package/src/components/radio-group/index.ts +1 -0
- package/src/components/select/Select.mdx +241 -0
- package/src/components/select/Select.stories.tsx +404 -0
- package/src/components/select/Select.tsx +381 -0
- package/src/components/select/index.ts +1 -0
- package/src/components/select-field/SelectField.mdx +324 -0
- package/src/components/select-field/SelectField.stories.tsx +460 -0
- package/src/components/select-field/SelectField.tsx +138 -0
- package/src/components/select-field/index.ts +1 -0
- package/src/components/skeleton/Skeleton.mdx +194 -0
- package/src/components/skeleton/Skeleton.stories.tsx +260 -0
- package/src/components/skeleton/Skeleton.tsx +107 -0
- package/src/components/skeleton/index.ts +1 -0
- package/src/components/split-button/SplitButton.mdx +445 -0
- package/src/components/split-button/SplitButton.stories.tsx +465 -0
- package/src/components/split-button/SplitButton.tsx +361 -0
- package/src/components/split-button/index.ts +7 -0
- package/src/components/status-summary-bar/StatusSummaryBar.mdx +338 -0
- package/src/components/status-summary-bar/StatusSummaryBar.stories.tsx +408 -0
- package/src/components/status-summary-bar/StatusSummaryBar.tsx +428 -0
- package/src/components/status-summary-bar/index.ts +8 -0
- package/src/components/subject-lookup-field/SubjectLookupField.mdx +378 -0
- package/src/components/subject-lookup-field/SubjectLookupField.stories.tsx +393 -0
- package/src/components/subject-lookup-field/SubjectLookupField.tsx +1079 -0
- package/src/components/subject-lookup-field/index.ts +11 -0
- package/src/components/switch/Switch.mdx +376 -0
- package/src/components/switch/Switch.stories.tsx +296 -0
- package/src/components/switch/Switch.tsx +483 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/table/Table.mdx +575 -0
- package/src/components/table/Table.stories.tsx +1049 -0
- package/src/components/table/Table.tsx +745 -0
- package/src/components/table/TableConsumers.stories.tsx +195 -0
- package/src/components/table/_tableFixtures.ts +1189 -0
- package/src/components/table/index.ts +22 -0
- package/src/components/text-field/TextField.mdx +479 -0
- package/src/components/text-field/TextField.stories.tsx +366 -0
- package/src/components/text-field/TextField.tsx +391 -0
- package/src/components/text-field/index.ts +8 -0
- package/src/components/text-link/TextLink.mdx +353 -0
- package/src/components/text-link/TextLink.stories.tsx +458 -0
- package/src/components/text-link/TextLink.tsx +504 -0
- package/src/components/text-link/index.ts +10 -0
- package/src/components/textarea/Textarea.mdx +244 -0
- package/src/components/textarea/Textarea.stories.tsx +371 -0
- package/src/components/textarea/Textarea.tsx +489 -0
- package/src/components/textarea/index.ts +9 -0
- package/src/components/tooltip/Tooltip.mdx +462 -0
- package/src/components/tooltip/Tooltip.stories.tsx +500 -0
- package/src/components/tooltip/Tooltip.tsx +756 -0
- package/src/components/tooltip/index.ts +13 -0
- package/src/components/unit-field/UnitField.mdx +215 -0
- package/src/components/unit-field/UnitField.stories.tsx +291 -0
- package/src/components/unit-field/UnitField.tsx +255 -0
- package/src/components/unit-field/index.ts +7 -0
- package/src/icons/icon-registry.generated.ts +510 -0
- package/src/icons/icon-types.generated.ts +256 -0
- package/src/index.ts +71 -0
- package/src/internal/BottomSheet.tsx +714 -0
- package/src/internal/FodsProvider.tsx +36 -0
- package/src/internal/MotionCaret.tsx +53 -0
- package/src/internal/NumberFormatInput.tsx +276 -0
- package/src/internal/SummaryDonut.tsx +359 -0
- package/src/internal/buttonSegment.ts +241 -0
- package/src/internal/collapseRoom.ts +130 -0
- package/src/internal/comboboxKeys.ts +90 -0
- package/src/internal/contentPresence.ts +46 -0
- package/src/internal/dayCell.ts +274 -0
- package/src/internal/dialogPortal.ts +50 -0
- package/src/internal/donutSweeps.ts +77 -0
- package/src/internal/enterOnViewGeometry.ts +53 -0
- package/src/internal/faqItem.ts +104 -0
- package/src/internal/floatingLabelMotion.tsx +109 -0
- package/src/internal/formBlockContext.ts +27 -0
- package/src/internal/heightRoom.ts +135 -0
- package/src/internal/numberSeparators.ts +93 -0
- package/src/internal/overlayMotion.tsx +32 -0
- package/src/internal/paginationItem.ts +106 -0
- package/src/internal/popoverSurface.ts +78 -0
- package/src/internal/portalContainer.ts +11 -0
- package/src/internal/progressBarItem.ts +356 -0
- package/src/internal/selectionControlText.ts +42 -0
- package/src/internal/statusSummaryParts.tsx +475 -0
- package/src/internal/summaryMotion.ts +111 -0
- package/src/internal/table/ChildConnector.tsx +57 -0
- package/src/internal/table/ChildRowPrefix.tsx +21 -0
- package/src/internal/table/ColumnSettings.tsx +194 -0
- package/src/internal/table/ScrollRegion.tsx +176 -0
- package/src/internal/table/TableEmpty.tsx +99 -0
- package/src/internal/table/TableLayout.tsx +29 -0
- package/src/internal/table/TableLoadStatus.tsx +60 -0
- package/src/internal/table/TableMobile.tsx +582 -0
- package/src/internal/table/TruncatedCell.tsx +35 -0
- package/src/internal/table/emptyValue.ts +11 -0
- package/src/internal/table/features.ts +44 -0
- package/src/internal/table/recipes.ts +263 -0
- package/src/internal/table/rowClick.ts +8 -0
- package/src/internal/table/types.ts +342 -0
- package/src/internal/tailwind-variants.ts +65 -0
- package/src/internal/tooltipContext.ts +15 -0
- package/src/internal/tw-merge-config.generated.ts +275 -0
- package/src/internal/useAnchoredPanel.ts +340 -0
- package/src/internal/useCountUp.ts +65 -0
- package/src/internal/useDateFieldTrigger.tsx +357 -0
- package/src/internal/useEChart.ts +88 -0
- package/src/internal/useEnterOnView.ts +80 -0
- package/src/internal/useFloatingBar.ts +125 -0
- package/src/internal/useFormReset.ts +47 -0
- package/src/internal/useIsMobile.ts +64 -0
- package/src/internal/useNoImplicitSubmit.ts +41 -0
- package/src/internal/useOneRowOverflow.ts +103 -0
- package/src/internal/usePrefersReducedMotion.ts +27 -0
- package/src/internal/useReturnFocus.ts +34 -0
- package/src/internal/utils.ts +58 -0
- package/src/recipes/EmptyState.stories.tsx +105 -0
- package/src/recipes/Form.stories.tsx +355 -0
- package/src/recipes/ModalWithForm.stories.tsx +219 -0
- package/src/recipes/Recipes.mdx +61 -0
- package/src/recipes/TableWithFilters.stories.tsx +278 -0
- package/src/storybook/FodsFamily.tsx +39 -0
- package/src/storybook/Section.tsx +36 -0
- package/src/storybook/a11y.ts +24 -0
- package/src/storybook/assets/banner-character-bartender.webp +0 -0
- package/src/storybook/assets/banner-invoice-sheet-left.webp +0 -0
- package/src/storybook/assets/banner-invoice-sheet-right.webp +0 -0
- package/src/storybook/assets/invoice-hero.webp +0 -0
- package/src/storybook/assets/invoice.webp +0 -0
- package/src/storybook/assets/section-document-info.svg +21 -0
- package/src/storybook/assets/section-gear-checklist.svg +11 -0
- package/src/storybook/assets/section-person-arrow-in.svg +15 -0
- package/src/storybook/assets/section-person-arrow-out.svg +22 -0
- package/src/storybook/assets/section-receipt-dollar.svg +23 -0
- package/src/storybook/assets/table-empty-folder-empty.png +0 -0
- package/src/storybook/assets/table-empty-folder-magnifying-glass.png +0 -0
- package/src/storybook/assets/table-empty-funnel.png +0 -0
- package/src/storybook/assets/table-empty-load-failed.png +0 -0
- package/src/storybook/assets/wallet-spot.png +0 -0
- package/src/storybook/assets.d.ts +17 -0
- package/src/storybook/componentDoc.ts +41 -0
- package/src/storybook/fitFrame.tsx +70 -0
- package/src/storybook/forceStates.tsx +647 -0
- package/src/storybook/illustrations.tsx +66 -0
- package/src/storybook/viewportFrame.tsx +58 -0
- package/src/styles/assets/label-brush-1.svg +6 -0
- package/src/styles/assets/pattern-dark.svg +113 -0
- package/src/styles/base.css +106 -0
- package/src/styles/index.css +15 -0
- package/src/styles/motion.css +157 -0
- package/src/styles/promo-sticker.css +27 -0
- package/src/styles/promo-surface.css +49 -0
- package/src/styles/shared.css +11 -0
- package/src/styles/theme.generated.css +314 -0
- package/src/styles/theme.map.json +278 -0
- package/src/styles/tracking.generated.css +12 -0
- package/src/tokens/index.ts +4 -0
- package/src/tokens/tokens.generated.ts +542 -0
|
@@ -0,0 +1,1079 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { tv } from '../../internal/tailwind-variants';
|
|
4
|
+
import { Icon } from '../icon/Icon';
|
|
5
|
+
import { cn } from '../../internal/utils';
|
|
6
|
+
import { textFieldShellVariants, textFieldValueVariants } from '../text-field/TextField';
|
|
7
|
+
import { Field } from '../field/Field';
|
|
8
|
+
import { ListRow } from '../list-row/ListRow';
|
|
9
|
+
import { Divider } from '../divider/Divider';
|
|
10
|
+
import { AnchoredPanel } from '../anchored-panel/AnchoredPanel';
|
|
11
|
+
import { useAnchoredPanel } from '../../internal/useAnchoredPanel';
|
|
12
|
+
import { comboboxKeyDown } from '../../internal/comboboxKeys';
|
|
13
|
+
import {
|
|
14
|
+
BottomSheet,
|
|
15
|
+
BottomSheetSearch,
|
|
16
|
+
SHEET_ROW_FOCUS_RING,
|
|
17
|
+
resolveFieldLabel,
|
|
18
|
+
useSheetPresentation,
|
|
19
|
+
} from '../../internal/BottomSheet';
|
|
20
|
+
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// SubjectLookupField — the ARES subject-lookup trigger (manifest
|
|
23
|
+
// `subject-lookup-field` 2.3.0, spec 04-molecules/subject-lookup-field.md) plus the
|
|
24
|
+
// Subject Lookup panel it opens (spec 06-patterns/popover-patterns.md § Subject
|
|
25
|
+
// Lookup). The spec calls the panel a composition, not a component; it is composed
|
|
26
|
+
// HERE from AnchoredPanel + ListRow + Divider (and BottomSheet below `sm`) the same
|
|
27
|
+
// way `Combobox` composes its own, so a host gets one component.
|
|
28
|
+
//
|
|
29
|
+
// The host owns the data: it debounces `query`, runs contacts + ARES, caps each
|
|
30
|
+
// group and passes `groups` / `loading`. The component owns the field flow, the
|
|
31
|
+
// trailing group, the single status node, the panel and the ↑/↓ ring.
|
|
32
|
+
//
|
|
33
|
+
// Flow (manifest `axes.state`): default → focused (empty) → searching → found |
|
|
34
|
+
// no-match. Derived from props at runtime; `state` is a STATIC override for stories
|
|
35
|
+
// and the verifier only.
|
|
36
|
+
// =============================================================================
|
|
37
|
+
|
|
38
|
+
export type SubjectLookupFieldState = 'default' | 'focused' | 'searching' | 'found' | 'no-match';
|
|
39
|
+
export type SubjectLookupSource = 'contacts' | 'registry';
|
|
40
|
+
|
|
41
|
+
export interface SubjectLookupItem {
|
|
42
|
+
id: string;
|
|
43
|
+
/** Subject name — the row label; the matched substring is bolded. */
|
|
44
|
+
label: string;
|
|
45
|
+
companyNumber?: string | null;
|
|
46
|
+
taxNumber?: string | null;
|
|
47
|
+
/** Second description line — rendered on registry rows only. */
|
|
48
|
+
address?: string | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface SubjectLookupGroup<T extends SubjectLookupItem = SubjectLookupItem> {
|
|
52
|
+
source: SubjectLookupSource;
|
|
53
|
+
/** Already capped by the host — the component renders what it gets. */
|
|
54
|
+
items: T[];
|
|
55
|
+
/** Total match count; `total - items.length > 0` draws the „Dalších N" row. */
|
|
56
|
+
total: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface SubjectLookupFieldLabels {
|
|
60
|
+
/** Clear × accessible name — „Vymazat hledání". */
|
|
61
|
+
clear: string;
|
|
62
|
+
/** Panel toggle accessible name — „Skrýt výsledky". */
|
|
63
|
+
hidePanel: string;
|
|
64
|
+
/** „Zadám vše o {query} ručně". */
|
|
65
|
+
manualEntry: (query: string) => string;
|
|
66
|
+
/** „Zadám vše o subjektu ručně" — empty query. */
|
|
67
|
+
manualEntryEmpty: string;
|
|
68
|
+
/** „{query} nenalezen, údaje zadám ručně" — the whole No match panel. */
|
|
69
|
+
noMatch: (query: string) => string;
|
|
70
|
+
/** „Nalezeno v kontaktech (N)". */
|
|
71
|
+
contactsGroup: (n: number) => string;
|
|
72
|
+
/** „Nalezeno v rejstříku (N)". */
|
|
73
|
+
registryGroup: (n: number) => string;
|
|
74
|
+
/** „Vyberte ze svých kontaktů (N)" — empty query (browse). */
|
|
75
|
+
browseContacts: (n: number) => string;
|
|
76
|
+
/** „Dalších N". */
|
|
77
|
+
showMore: (n: number) => string;
|
|
78
|
+
/** „IČO". */
|
|
79
|
+
companyNumber: string;
|
|
80
|
+
/** „DIČ". */
|
|
81
|
+
taxNumber: string;
|
|
82
|
+
/** Status node while searching — „Vyhledávám…". */
|
|
83
|
+
statusSearching: string;
|
|
84
|
+
/** Status node on resolve — „Počet výsledků: N". */
|
|
85
|
+
statusFound: (n: number) => string;
|
|
86
|
+
/** Status node on no match — „Žádné výsledky". */
|
|
87
|
+
statusNoMatch: string;
|
|
88
|
+
/** Mobile sheet title; defaults to the field label. */
|
|
89
|
+
sheetTitle?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface SubjectLookupFieldProps<T extends SubjectLookupItem = SubjectLookupItem> {
|
|
93
|
+
/** The text in the input. Controlled — the host debounces off it. */
|
|
94
|
+
query: string;
|
|
95
|
+
onQueryChange: (query: string) => void;
|
|
96
|
+
/** Result groups, already capped. For an empty query: the saved contacts (browse). */
|
|
97
|
+
groups: SubjectLookupGroup<T>[];
|
|
98
|
+
/**
|
|
99
|
+
* The request is in flight (Searching): spinner, `aria-busy`, the start string in
|
|
100
|
+
* the status node. Set it on the first keystroke so it covers the debounce too —
|
|
101
|
+
* one Searching state serves typing and fetching (manifest notes[5]).
|
|
102
|
+
*/
|
|
103
|
+
loading?: boolean;
|
|
104
|
+
/** A result row was picked — the host collapses the field into the summary card. */
|
|
105
|
+
onSelect: (item: T) => void;
|
|
106
|
+
/** The manual-entry row ran. */
|
|
107
|
+
onManualEntry: () => void;
|
|
108
|
+
/** A „Dalších N" row ran; the panel stays open. */
|
|
109
|
+
onShowMore?: (source: SubjectLookupSource) => void;
|
|
110
|
+
placeholder?: string;
|
|
111
|
+
/** Every string the component renders — it has no locale of its own. */
|
|
112
|
+
labels: SubjectLookupFieldLabels;
|
|
113
|
+
/**
|
|
114
|
+
* Floating label (the shell's `Show label`). When set, the component wraps its
|
|
115
|
+
* shell in `Field` itself, which is what lets the Found label take the Success ink
|
|
116
|
+
* (manifest parts.label.found) — a `Field` wrapped around the component from the
|
|
117
|
+
* outside cannot see the runtime flow. Prefer it over an outer `Field`.
|
|
118
|
+
*/
|
|
119
|
+
label?: string;
|
|
120
|
+
/** Helper line under the shell (the shell's `Helper`) — host content, never an outcome. */
|
|
121
|
+
helperText?: string;
|
|
122
|
+
/**
|
|
123
|
+
* A situational hint that pre-empts the search outcome — e.g. „Rejstřík se prohledá od 3 znaků"
|
|
124
|
+
* while the host skips the registry for a short query (spec § Copy → Helper).
|
|
125
|
+
* While it is set and the resolved query has no results, the flow stays `focused`
|
|
126
|
+
* instead of `no-match`: the panel shows only the manual-entry row (never the
|
|
127
|
+
* no-match line) and the status node announces the hint. It replaces `helperText`
|
|
128
|
+
* on the helper line (when `label` is set). Results, when there are any, still win.
|
|
129
|
+
*/
|
|
130
|
+
hint?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Host-owned error message on the helper line (`Field`'s `error`, with `label`) — manifest
|
|
133
|
+
* 2.1.0 `properties[error]`, families `host-error`. Text Field Error recipe: label and helper
|
|
134
|
+
* --status-danger, border --status-danger thickened to --border-width-200 while focused
|
|
135
|
+
* (`focus.errorFocus`); the message replaces any hint; the input gets `aria-invalid` and
|
|
136
|
+
* `aria-describedby` → helper. The trailing keeps the flow glyphs. Not a flow state — use it
|
|
137
|
+
* for the host form's validation (e.g. a required supplier), never for registry validation,
|
|
138
|
+
* which the spec keeps on the manual-entry TextFields. There is no host success: Found is
|
|
139
|
+
* the only success signal.
|
|
140
|
+
*/
|
|
141
|
+
error?: string;
|
|
142
|
+
/** The shell's `Optional` tag. */
|
|
143
|
+
optionalLabel?: string;
|
|
144
|
+
/**
|
|
145
|
+
* STATIC override of the flow state — Storybook and the FODS verifier only
|
|
146
|
+
* Leave it unset in the product.
|
|
147
|
+
*/
|
|
148
|
+
state?: SubjectLookupFieldState;
|
|
149
|
+
/**
|
|
150
|
+
* STATIC override of the Panel axis on the trigger — stories / verifier only. Drives
|
|
151
|
+
* `aria-expanded` and the trailing (caret vs wand / clear ×); it does NOT mount a
|
|
152
|
+
* panel, so several Open cells can sit in one Matrix.
|
|
153
|
+
*/
|
|
154
|
+
panelOpen?: boolean;
|
|
155
|
+
/** Open the real panel on mount (stories). */
|
|
156
|
+
defaultOpen?: boolean;
|
|
157
|
+
id?: string;
|
|
158
|
+
className?: string;
|
|
159
|
+
disabled?: boolean;
|
|
160
|
+
/** md (48) only — the manifest has no other size. */
|
|
161
|
+
size?: 'md';
|
|
162
|
+
/** Id of the visible text naming the panel's listbox. */
|
|
163
|
+
panelLabelledBy?: string;
|
|
164
|
+
/** Fallback listbox name when nothing visible names the field. */
|
|
165
|
+
panelLabel?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Accessible name of the visually hidden close button of the mobile bottom sheet.
|
|
168
|
+
* Defaults to «Zavřít» (Czech); an app with more language versions passes it from
|
|
169
|
+
* its translations.
|
|
170
|
+
*/
|
|
171
|
+
sheetCloseLabel?: string;
|
|
172
|
+
'aria-label'?: string;
|
|
173
|
+
'aria-describedby'?: string;
|
|
174
|
+
'aria-invalid'?: boolean;
|
|
175
|
+
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
|
176
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
|
177
|
+
'data-testid'?: string;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const FLOW_STATES: readonly SubjectLookupFieldState[] = [
|
|
181
|
+
'default',
|
|
182
|
+
'focused',
|
|
183
|
+
'searching',
|
|
184
|
+
'found',
|
|
185
|
+
'no-match',
|
|
186
|
+
];
|
|
187
|
+
|
|
188
|
+
// Trailing glyph box — every glyph sits in the standard --size-icon (24) box
|
|
189
|
+
// (manifest sizes[].icon). Ink per family state (families[].states.*.icon).
|
|
190
|
+
const subjectLookupGlyphVariants = tv({
|
|
191
|
+
base: 'inline-flex size-icon shrink-0 items-center justify-center',
|
|
192
|
+
variants: {
|
|
193
|
+
tone: {
|
|
194
|
+
brand: 'text-icon-brand',
|
|
195
|
+
progress: 'text-text-secondary',
|
|
196
|
+
success: 'text-status-success-solid',
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// The two trailing BUTTONS (manifest parts.clear-button / parts.panel-toggle): the full
|
|
202
|
+
// 24×24 icon box is the target (sizes[].hitArea). Nested sub-controls take the normal
|
|
203
|
+
// offset ring, not the shell's border swap (manifest-first.md § 2 precedent).
|
|
204
|
+
const subjectLookupButtonVariants = tv({
|
|
205
|
+
base: [
|
|
206
|
+
'inline-flex size-icon shrink-0 cursor-pointer items-center justify-center rounded-200',
|
|
207
|
+
'outline-none focus-visible:ring-200 focus-visible:ring-outline-focus',
|
|
208
|
+
'disabled:cursor-not-allowed disabled:text-disabled-foreground',
|
|
209
|
+
],
|
|
210
|
+
variants: {
|
|
211
|
+
control: {
|
|
212
|
+
clear: 'text-text-secondary',
|
|
213
|
+
toggle: 'text-icon-muted',
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// The one visually-hidden live region (spec § Accessibility → Announcement).
|
|
219
|
+
const subjectLookupStatusVariants = tv({ base: 'sr-only' });
|
|
220
|
+
|
|
221
|
+
// Scroll cap of the results run (popover-patterns.md § Subject Lookup → Scroll cap):
|
|
222
|
+
// a row count times the List Row Medium height, derived from the same tokens the row
|
|
223
|
+
// is built from — pad-Y --space-400 ×2, Body/M label line, --space-200 gap, Body/S
|
|
224
|
+
// description lines. 4 registry rows (88.8) or 5 contact rows (66.4), never rounded.
|
|
225
|
+
const ROW_LABEL_LINE = 'var(--font-size-base) * var(--leading-relaxed)';
|
|
226
|
+
const ROW_DESCRIPTION_LINE = 'var(--font-size-sm) * var(--leading-loose)';
|
|
227
|
+
const ROW_CHROME = '2 * var(--space-400) + var(--space-200)';
|
|
228
|
+
const REGISTRY_RUN_CAP = `calc(4 * (${ROW_CHROME} + ${ROW_LABEL_LINE} + 2 * ${ROW_DESCRIPTION_LINE}))`;
|
|
229
|
+
const CONTACT_RUN_CAP = `calc(5 * (${ROW_CHROME} + ${ROW_LABEL_LINE} + ${ROW_DESCRIPTION_LINE}))`;
|
|
230
|
+
|
|
231
|
+
const SPARK_ANGLES = [0, 60, 120, 180, 240, 300];
|
|
232
|
+
|
|
233
|
+
// Found check-circle, drawn ONCE on mount (manifest motion.enter; the 0.8 s timeline is
|
|
234
|
+
// motion.enter.duration `--duration-draw`, which the `animate-lookup-check-*`
|
|
235
|
+
// theme utilities run):
|
|
236
|
+
// ring stroke 0.35–0.65 s, burst ring + 6 sparks 0.50–0.75 s (from the ring's midpoint),
|
|
237
|
+
// tick 0.60–0.80 s. The
|
|
238
|
+
// resting shape is the `check-circle` icon (circle + tick, 1.5 stroke, 24 box); the
|
|
239
|
+
// burst and sparks rest at opacity 0. Reduced motion: no animation, the resting check.
|
|
240
|
+
const FoundCheckGlyph = () => (
|
|
241
|
+
<svg
|
|
242
|
+
viewBox="0 0 24 24"
|
|
243
|
+
fill="none"
|
|
244
|
+
stroke="currentColor"
|
|
245
|
+
aria-hidden="true"
|
|
246
|
+
focusable="false"
|
|
247
|
+
data-fods-motion="found-draw"
|
|
248
|
+
className="size-icon overflow-visible"
|
|
249
|
+
>
|
|
250
|
+
<circle
|
|
251
|
+
cx="12"
|
|
252
|
+
cy="12"
|
|
253
|
+
r="9"
|
|
254
|
+
strokeWidth="1.5"
|
|
255
|
+
pathLength={1}
|
|
256
|
+
strokeDasharray="1"
|
|
257
|
+
strokeDashoffset="0"
|
|
258
|
+
transform="rotate(-90 12 12)"
|
|
259
|
+
className="animate-lookup-check-ring motion-reduce:animate-none"
|
|
260
|
+
/>
|
|
261
|
+
<circle
|
|
262
|
+
cx="12"
|
|
263
|
+
cy="12"
|
|
264
|
+
r="9"
|
|
265
|
+
strokeWidth="1"
|
|
266
|
+
opacity="0"
|
|
267
|
+
className="origin-center [transform-box:fill-box] animate-lookup-check-burst motion-reduce:animate-none"
|
|
268
|
+
/>
|
|
269
|
+
{SPARK_ANGLES.map(angle => (
|
|
270
|
+
<g key={angle} transform={`rotate(${angle} 12 12)`}>
|
|
271
|
+
<line
|
|
272
|
+
x1="12"
|
|
273
|
+
y1="1.5"
|
|
274
|
+
x2="12"
|
|
275
|
+
y2="-0.5"
|
|
276
|
+
strokeWidth="1.5"
|
|
277
|
+
strokeLinecap="round"
|
|
278
|
+
opacity="0"
|
|
279
|
+
className="animate-lookup-check-spark motion-reduce:animate-none"
|
|
280
|
+
/>
|
|
281
|
+
</g>
|
|
282
|
+
))}
|
|
283
|
+
<path
|
|
284
|
+
d="M8.25 12.75 10.5 15l5.25-5.25"
|
|
285
|
+
strokeWidth="1.5"
|
|
286
|
+
strokeLinecap="round"
|
|
287
|
+
strokeLinejoin="round"
|
|
288
|
+
pathLength={1}
|
|
289
|
+
strokeDasharray="1"
|
|
290
|
+
strokeDashoffset="0"
|
|
291
|
+
className="animate-lookup-check-tick motion-reduce:animate-none"
|
|
292
|
+
/>
|
|
293
|
+
</svg>
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
/** Case- and diacritics-insensitive fold of one string. */
|
|
297
|
+
const fold = (value: string) => value.normalize('NFD').replace(/\p{M}/gu, '').toLowerCase();
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Splits `label` around the first diacritics- and case-insensitive occurrence of
|
|
301
|
+
* `query`, mapping the folded match back onto the ORIGINAL characters — so „cesk"
|
|
302
|
+
* bolds „Česk" in „Česká", not a shifted range.
|
|
303
|
+
*/
|
|
304
|
+
export function splitMatch(label: string, query: string): [string, string, string] | null {
|
|
305
|
+
const needle = fold(query.trim());
|
|
306
|
+
if (!needle) return null;
|
|
307
|
+
let folded = '';
|
|
308
|
+
const origin: number[] = [];
|
|
309
|
+
let offset = 0;
|
|
310
|
+
for (const char of label) {
|
|
311
|
+
const part = fold(char);
|
|
312
|
+
for (let i = 0; i < part.length; i += 1) {
|
|
313
|
+
folded += part[i];
|
|
314
|
+
origin.push(offset);
|
|
315
|
+
}
|
|
316
|
+
offset += char.length;
|
|
317
|
+
}
|
|
318
|
+
const at = folded.indexOf(needle);
|
|
319
|
+
if (at < 0) return null;
|
|
320
|
+
const start = origin[at];
|
|
321
|
+
const last = origin[at + needle.length - 1];
|
|
322
|
+
let end = last + String.fromCodePoint(label.codePointAt(last) ?? 0).length;
|
|
323
|
+
// A decomposed label carries its combining marks after the base letter.
|
|
324
|
+
while (end < label.length && /\p{M}/u.test(label[end])) end += 1;
|
|
325
|
+
return [label.slice(0, start), label.slice(start, end), label.slice(end)];
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const HighlightedLabel = ({ label, query }: { label: string; query: string }) => {
|
|
329
|
+
const parts = splitMatch(label, query);
|
|
330
|
+
if (!parts) return <>{label}</>;
|
|
331
|
+
return (
|
|
332
|
+
<>
|
|
333
|
+
{parts[0]}
|
|
334
|
+
<strong className="font-semibold">{parts[1]}</strong>
|
|
335
|
+
{parts[2]}
|
|
336
|
+
</>
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
type RingEntry<T> =
|
|
341
|
+
| { kind: 'manual' }
|
|
342
|
+
| { kind: 'item'; item: T; source: SubjectLookupSource }
|
|
343
|
+
| { kind: 'more'; source: SubjectLookupSource; remaining: number };
|
|
344
|
+
|
|
345
|
+
interface SubjectLookupShellProps
|
|
346
|
+
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'children'> {
|
|
347
|
+
/**
|
|
348
|
+
* The status `Field` reads off its child: `success` paints the Found label ink.
|
|
349
|
+
* Consumed here, never forwarded to the input.
|
|
350
|
+
*/
|
|
351
|
+
state?: string;
|
|
352
|
+
shellState: 'default' | 'focused' | 'success' | 'error' | 'disabled';
|
|
353
|
+
/** Found only: the success border survives focus. Consumed here, never forwarded. */
|
|
354
|
+
holdsSuccessOnFocus: boolean;
|
|
355
|
+
shellRef: React.Ref<HTMLDivElement>;
|
|
356
|
+
inputRef: React.Ref<HTMLInputElement>;
|
|
357
|
+
trailing: React.ReactNode;
|
|
358
|
+
onShellPointerDown: React.PointerEventHandler<HTMLDivElement>;
|
|
359
|
+
onShellMouseDown: React.MouseEventHandler<HTMLDivElement>;
|
|
360
|
+
onShellClick: React.MouseEventHandler<HTMLDivElement>;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// The shell + input, split out so `Field` can clone it: Field reads `id`, `value`,
|
|
364
|
+
// `placeholder`, `disabled` and `state` off it and injects focus handlers and
|
|
365
|
+
// `aria-describedby`, which land on the input through the rest props.
|
|
366
|
+
const SubjectLookupShell = ({
|
|
367
|
+
state: _fieldState,
|
|
368
|
+
shellState,
|
|
369
|
+
holdsSuccessOnFocus,
|
|
370
|
+
shellRef,
|
|
371
|
+
inputRef,
|
|
372
|
+
trailing,
|
|
373
|
+
onShellPointerDown,
|
|
374
|
+
onShellMouseDown,
|
|
375
|
+
onShellClick,
|
|
376
|
+
disabled,
|
|
377
|
+
...inputProps
|
|
378
|
+
}: SubjectLookupShellProps) => (
|
|
379
|
+
<div
|
|
380
|
+
ref={shellRef}
|
|
381
|
+
// data-fods-* mark the parts the FODS verifier measures in the browser
|
|
382
|
+
// (the subject-lookup-field parts map). Not inert in this package: `styles/base.css`
|
|
383
|
+
// scopes its reset to these attributes.
|
|
384
|
+
data-fods-component="subject-lookup-field"
|
|
385
|
+
data-fods-part="root"
|
|
386
|
+
onPointerDown={onShellPointerDown}
|
|
387
|
+
onMouseDown={onShellMouseDown}
|
|
388
|
+
onClick={onShellClick}
|
|
389
|
+
className={cn(
|
|
390
|
+
textFieldShellVariants({ inputSize: 'md', state: shellState }),
|
|
391
|
+
// Found keeps the success border while the input holds focus (manifest
|
|
392
|
+
// families[].found.border) — the shell recipe would swap it to --outline-focus.
|
|
393
|
+
holdsSuccessOnFocus && 'focus-within:border-status-success-solid',
|
|
394
|
+
)}
|
|
395
|
+
>
|
|
396
|
+
<input
|
|
397
|
+
ref={inputRef}
|
|
398
|
+
type="text"
|
|
399
|
+
data-fods-part="value"
|
|
400
|
+
disabled={disabled}
|
|
401
|
+
className={textFieldValueVariants({ state: disabled ? 'disabled' : 'default' })}
|
|
402
|
+
{...inputProps}
|
|
403
|
+
/>
|
|
404
|
+
{trailing}
|
|
405
|
+
</div>
|
|
406
|
+
);
|
|
407
|
+
SubjectLookupShell.displayName = 'SubjectLookupShell';
|
|
408
|
+
|
|
409
|
+
function SubjectLookupFieldInner<T extends SubjectLookupItem = SubjectLookupItem>(
|
|
410
|
+
{
|
|
411
|
+
query,
|
|
412
|
+
onQueryChange,
|
|
413
|
+
groups,
|
|
414
|
+
loading = false,
|
|
415
|
+
onSelect,
|
|
416
|
+
onManualEntry,
|
|
417
|
+
onShowMore,
|
|
418
|
+
placeholder,
|
|
419
|
+
labels,
|
|
420
|
+
label,
|
|
421
|
+
helperText,
|
|
422
|
+
hint,
|
|
423
|
+
error,
|
|
424
|
+
optionalLabel,
|
|
425
|
+
state: stateProp,
|
|
426
|
+
panelOpen,
|
|
427
|
+
defaultOpen = false,
|
|
428
|
+
id: idProp,
|
|
429
|
+
className,
|
|
430
|
+
disabled = false,
|
|
431
|
+
panelLabelledBy,
|
|
432
|
+
panelLabel,
|
|
433
|
+
sheetCloseLabel,
|
|
434
|
+
'aria-label': ariaLabel,
|
|
435
|
+
'aria-describedby': ariaDescribedby,
|
|
436
|
+
'aria-invalid': ariaInvalid,
|
|
437
|
+
onFocus,
|
|
438
|
+
onBlur,
|
|
439
|
+
'data-testid': dataTestid,
|
|
440
|
+
}: SubjectLookupFieldProps<T>,
|
|
441
|
+
forwardedRef: React.ForwardedRef<HTMLInputElement>,
|
|
442
|
+
) {
|
|
443
|
+
const reactId = React.useId();
|
|
444
|
+
const id = idProp ?? `${reactId}-input`;
|
|
445
|
+
const optionId = (index: number) => `${reactId}-option-${index}`;
|
|
446
|
+
const sheetListboxId = `${reactId}-sheet-listbox`;
|
|
447
|
+
const sheetTitleId = `${reactId}-sheet-title`;
|
|
448
|
+
|
|
449
|
+
// An outer `Field` injects its own status here (e.g. 'error'); only the
|
|
450
|
+
// five flow values count as the static override.
|
|
451
|
+
const forcedState = stateProp && FLOW_STATES.includes(stateProp) ? stateProp : undefined;
|
|
452
|
+
|
|
453
|
+
const [open, setOpen] = React.useState(defaultOpen && !disabled);
|
|
454
|
+
const [focused, setFocused] = React.useState(false);
|
|
455
|
+
const [activeIndex, setActiveIndex] = React.useState<number | null>(null);
|
|
456
|
+
const [fieldLabel, setFieldLabel] = React.useState('');
|
|
457
|
+
const isSheet = useSheetPresentation();
|
|
458
|
+
const sheetSearchRef = React.useRef<HTMLInputElement>(null);
|
|
459
|
+
|
|
460
|
+
const panelName = panelLabelledBy ? undefined : panelLabel ?? label ?? ariaLabel;
|
|
461
|
+
const panelUnnamed = !panelLabelledBy && !panelName;
|
|
462
|
+
React.useEffect(() => {
|
|
463
|
+
if (process.env.NODE_ENV !== 'production' && panelUnnamed) {
|
|
464
|
+
// eslint-disable-next-line no-console
|
|
465
|
+
console.warn(
|
|
466
|
+
'SubjectLookupField: the result listbox has no accessible name — pass `label`, ' +
|
|
467
|
+
'`panelLabelledBy` or `panelLabel`.',
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
}, [panelUnnamed]);
|
|
471
|
+
|
|
472
|
+
const inputRef = React.useRef<HTMLInputElement>(null);
|
|
473
|
+
const setInputRef = React.useCallback(
|
|
474
|
+
(node: HTMLInputElement | null) => {
|
|
475
|
+
inputRef.current = node;
|
|
476
|
+
if (typeof forwardedRef === 'function') forwardedRef(node);
|
|
477
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
478
|
+
},
|
|
479
|
+
[forwardedRef],
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
const panel = useAnchoredPanel({
|
|
483
|
+
open: open && !isSheet,
|
|
484
|
+
onOpenChange: setOpen,
|
|
485
|
+
role: 'listbox',
|
|
486
|
+
// Focus never leaves the input (manifest intent.rules[5]); the cursor is
|
|
487
|
+
// `aria-activedescendant`, owned here like Combobox does.
|
|
488
|
+
focusModel: 'virtual',
|
|
489
|
+
widthPolicy: 'trigger',
|
|
490
|
+
navigation: 'none',
|
|
491
|
+
itemCount: 0,
|
|
492
|
+
typeahead: false,
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
const hasQuery = query.trim().length > 0;
|
|
496
|
+
const contacts = groups.find(group => group.source === 'contacts' && group.items.length > 0);
|
|
497
|
+
const registry = groups.find(group => group.source === 'registry' && group.items.length > 0);
|
|
498
|
+
// Contacts above registry whatever order the host passes them in (pattern anatomy).
|
|
499
|
+
const sections = [contacts, registry].filter(
|
|
500
|
+
(group): group is SubjectLookupGroup<T> => group !== undefined,
|
|
501
|
+
);
|
|
502
|
+
const resultCount = sections.reduce((sum, group) => sum + group.total, 0);
|
|
503
|
+
|
|
504
|
+
// A host hint stands in for the outcome of a search it did not fully run.
|
|
505
|
+
const hintPreempts = Boolean(hint) && hasQuery && !loading && sections.length === 0;
|
|
506
|
+
|
|
507
|
+
// Runtime flow (manifest axes.state) — the static override wins when set.
|
|
508
|
+
const derivedState: SubjectLookupFieldState = !hasQuery || hintPreempts
|
|
509
|
+
? focused || open
|
|
510
|
+
? 'focused'
|
|
511
|
+
: 'default'
|
|
512
|
+
: loading
|
|
513
|
+
? 'searching'
|
|
514
|
+
: sections.length > 0
|
|
515
|
+
? 'found'
|
|
516
|
+
: 'no-match';
|
|
517
|
+
const flow = forcedState ?? derivedState;
|
|
518
|
+
const isPanelOpen = panelOpen ?? (forcedState === 'default' ? false : open);
|
|
519
|
+
const queryFlow = flow === 'searching' || flow === 'found' || flow === 'no-match';
|
|
520
|
+
|
|
521
|
+
// ↑/↓ ring (popover-patterns.md § Subject Lookup → Keyboard): manual entry first,
|
|
522
|
+
// the results in visual order, „Dalších N" last. On the sheet the manual entry is a
|
|
523
|
+
// footer button reached with Tab, so it leaves the ring there.
|
|
524
|
+
const ring = React.useMemo<RingEntry<T>[]>(() => {
|
|
525
|
+
const entries: RingEntry<T>[] = [];
|
|
526
|
+
if (!isSheet) entries.push({ kind: 'manual' });
|
|
527
|
+
if (flow === 'no-match') return entries;
|
|
528
|
+
sections.forEach(group =>
|
|
529
|
+
group.items.forEach(item => entries.push({ kind: 'item', item, source: group.source })),
|
|
530
|
+
);
|
|
531
|
+
sections.forEach((group) => {
|
|
532
|
+
const remaining = group.total - group.items.length;
|
|
533
|
+
if (remaining > 0 && onShowMore) entries.push({ kind: 'more', source: group.source, remaining });
|
|
534
|
+
});
|
|
535
|
+
return entries;
|
|
536
|
+
// `sections` is rebuilt from `groups` on every render; keyed on its inputs.
|
|
537
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
538
|
+
}, [groups, isSheet, flow, onShowMore]);
|
|
539
|
+
|
|
540
|
+
// Results are replaced on every search: never let the cursor point past the ring.
|
|
541
|
+
React.useEffect(() => {
|
|
542
|
+
setActiveIndex(current => (current != null && current < ring.length ? current : null));
|
|
543
|
+
}, [ring]);
|
|
544
|
+
React.useEffect(() => {
|
|
545
|
+
if (!open) setActiveIndex(null);
|
|
546
|
+
}, [open]);
|
|
547
|
+
React.useEffect(() => {
|
|
548
|
+
if (!open || activeIndex == null) return;
|
|
549
|
+
panel.listRef.current[activeIndex]?.scrollIntoView({ block: 'nearest' });
|
|
550
|
+
}, [open, activeIndex, panel.listRef]);
|
|
551
|
+
React.useEffect(() => {
|
|
552
|
+
if (disabled) setOpen(false);
|
|
553
|
+
}, [disabled]);
|
|
554
|
+
|
|
555
|
+
const closePanel = React.useCallback(() => {
|
|
556
|
+
setOpen(false);
|
|
557
|
+
setActiveIndex(null);
|
|
558
|
+
}, []);
|
|
559
|
+
|
|
560
|
+
const runManualEntry = React.useCallback(() => {
|
|
561
|
+
closePanel();
|
|
562
|
+
onManualEntry();
|
|
563
|
+
}, [closePanel, onManualEntry]);
|
|
564
|
+
|
|
565
|
+
const activate = (index: number) => {
|
|
566
|
+
const entry = ring[index];
|
|
567
|
+
if (!entry) return;
|
|
568
|
+
if (entry.kind === 'manual') runManualEntry();
|
|
569
|
+
else if (entry.kind === 'item') {
|
|
570
|
+
closePanel();
|
|
571
|
+
onSelect(entry.item);
|
|
572
|
+
} else {
|
|
573
|
+
// The panel stays open — the rest unfolds in place (pattern § Keyboard).
|
|
574
|
+
onShowMore?.(entry.source);
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
const openSheet = () => {
|
|
579
|
+
setFieldLabel(resolveFieldLabel(inputRef.current));
|
|
580
|
+
setOpen(true);
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
584
|
+
onQueryChange(event.target.value);
|
|
585
|
+
setOpen(true);
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {
|
|
589
|
+
setFocused(true);
|
|
590
|
+
// Focused (empty) opens the panel on the saved contacts (spec § States 2).
|
|
591
|
+
if (!isSheet && !disabled) setOpen(true);
|
|
592
|
+
onFocus?.(event);
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
const handleBlur = (event: React.FocusEvent<HTMLInputElement>) => {
|
|
596
|
+
setFocused(false);
|
|
597
|
+
onBlur?.(event);
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
601
|
+
if (isSheet) {
|
|
602
|
+
if (['ArrowDown', 'ArrowUp', 'Enter', ' '].includes(event.key)) {
|
|
603
|
+
event.preventDefault();
|
|
604
|
+
openSheet();
|
|
605
|
+
}
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
// Tab leaves the combobox and closes the popup (WAI-ARIA APG); not prevented, so
|
|
609
|
+
// focus moves on — to the clear ×, which the closed panel now draws.
|
|
610
|
+
if (event.key === 'Tab') {
|
|
611
|
+
if (open) closePanel();
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
comboboxKeyDown(event, {
|
|
615
|
+
open,
|
|
616
|
+
activeIndex,
|
|
617
|
+
count: ring.length,
|
|
618
|
+
isDisabled: () => false,
|
|
619
|
+
setActiveIndex,
|
|
620
|
+
onOpen: () => setOpen(true),
|
|
621
|
+
onCommit: activate,
|
|
622
|
+
// Esc closes and stays in the input; the query is kept (spec § Keyboard).
|
|
623
|
+
onEscape: closePanel,
|
|
624
|
+
});
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
const handleSheetKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
628
|
+
if (event.key === 'Escape' || event.key === 'Tab') return;
|
|
629
|
+
comboboxKeyDown(event, {
|
|
630
|
+
open,
|
|
631
|
+
activeIndex,
|
|
632
|
+
count: ring.length,
|
|
633
|
+
isDisabled: () => false,
|
|
634
|
+
setActiveIndex,
|
|
635
|
+
onOpen: () => setOpen(true),
|
|
636
|
+
onCommit: activate,
|
|
637
|
+
onEscape: closePanel,
|
|
638
|
+
});
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
// The shell padding is part of the trigger; the two trailing buttons are not.
|
|
642
|
+
const handleShellPointerDown = (event: React.PointerEvent<HTMLDivElement>) => {
|
|
643
|
+
if (disabled || isSheet || event.target !== inputRef.current) return;
|
|
644
|
+
setOpen(true);
|
|
645
|
+
};
|
|
646
|
+
// A press on the padding or a trailing glyph is handled on mouse-down, whose default
|
|
647
|
+
// would move focus from the input to <body>. Not on pointer-down: preventing that does
|
|
648
|
+
// not stop the focus move, and the re-render it triggers swaps the wand for the state
|
|
649
|
+
// glyph, so the mouse-down would land on a detached node.
|
|
650
|
+
const handleShellMouseDown = (event: React.MouseEvent<HTMLDivElement>) => {
|
|
651
|
+
if (disabled || isSheet || event.target === inputRef.current) return;
|
|
652
|
+
if ((event.target as HTMLElement).closest('button')) return;
|
|
653
|
+
event.preventDefault();
|
|
654
|
+
inputRef.current?.focus();
|
|
655
|
+
setOpen(true);
|
|
656
|
+
};
|
|
657
|
+
const handleShellClick = (event: React.MouseEvent<HTMLDivElement>) => {
|
|
658
|
+
if (disabled || !isSheet || (event.target as HTMLElement).closest('button')) return;
|
|
659
|
+
openSheet();
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
const handleClear = () => {
|
|
663
|
+
// Focus first: the focus event fires synchronously with the pre-render closures, so a host
|
|
664
|
+
// that re-syncs its search on focus must see it before the cleared query — after it, the
|
|
665
|
+
// stale closure would re-search the old query and cancel the empty one. The host still
|
|
666
|
+
// cancels its debounce / in-flight request on '' (manifest `loading`).
|
|
667
|
+
inputRef.current?.focus();
|
|
668
|
+
onQueryChange('');
|
|
669
|
+
setActiveIndex(null);
|
|
670
|
+
if (!isSheet) setOpen(true);
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
const panelId = panel.isMounted ? panel.context.floatingId : undefined;
|
|
674
|
+
|
|
675
|
+
// Trailing group: the state glyph (left) and the slot (right-most), exactly one slot
|
|
676
|
+
// glyph at a time (manifest slots.trailing-icon / slots.trailing-state).
|
|
677
|
+
let stateGlyph: React.ReactNode = null;
|
|
678
|
+
// The wand moves to the state position only beside the caret toggle. The sheet draws
|
|
679
|
+
// no toggle, so there the wand stays in the slot — never two wands side by side.
|
|
680
|
+
if (flow === 'focused' && isPanelOpen && !isSheet) {
|
|
681
|
+
stateGlyph = (
|
|
682
|
+
<span data-fods-part="trailing-state" aria-hidden="true" className={subjectLookupGlyphVariants({ tone: 'brand' })}>
|
|
683
|
+
<Icon name="magic-wand" size="default" />
|
|
684
|
+
</span>
|
|
685
|
+
);
|
|
686
|
+
} else if (flow === 'searching') {
|
|
687
|
+
stateGlyph = (
|
|
688
|
+
<span data-fods-part="trailing-state" aria-hidden="true" className={subjectLookupGlyphVariants({ tone: 'progress' })}>
|
|
689
|
+
{/* Keeps turning under reduced motion — the only sign of the request (motion.reducedMotion). */}
|
|
690
|
+
<Icon name="spinner" size="default" className="animate-spin" />
|
|
691
|
+
</span>
|
|
692
|
+
);
|
|
693
|
+
} else if (flow === 'found') {
|
|
694
|
+
stateGlyph = (
|
|
695
|
+
<span data-fods-part="trailing-state" aria-hidden="true" className={subjectLookupGlyphVariants({ tone: 'success' })}>
|
|
696
|
+
<FoundCheckGlyph />
|
|
697
|
+
</span>
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
let slotGlyph: React.ReactNode;
|
|
702
|
+
if (isPanelOpen && !isSheet) {
|
|
703
|
+
slotGlyph = (
|
|
704
|
+
<button
|
|
705
|
+
type="button"
|
|
706
|
+
tabIndex={-1}
|
|
707
|
+
data-fods-part="panel-toggle"
|
|
708
|
+
aria-label={labels.hidePanel}
|
|
709
|
+
aria-controls={panelId}
|
|
710
|
+
disabled={disabled}
|
|
711
|
+
// Focus stays in the input (manifest delivery.react).
|
|
712
|
+
onMouseDown={event => event.preventDefault()}
|
|
713
|
+
onClick={closePanel}
|
|
714
|
+
className={subjectLookupButtonVariants({ control: 'toggle' })}
|
|
715
|
+
>
|
|
716
|
+
<Icon name="caret-up-small" size="default" />
|
|
717
|
+
</button>
|
|
718
|
+
);
|
|
719
|
+
} else if (queryFlow || hasQuery) {
|
|
720
|
+
slotGlyph = (
|
|
721
|
+
<button
|
|
722
|
+
type="button"
|
|
723
|
+
data-fods-part="clear-button"
|
|
724
|
+
aria-label={labels.clear}
|
|
725
|
+
disabled={disabled}
|
|
726
|
+
onClick={handleClear}
|
|
727
|
+
className={subjectLookupButtonVariants({ control: 'clear' })}
|
|
728
|
+
>
|
|
729
|
+
<Icon name="x-small" size="default" />
|
|
730
|
+
</button>
|
|
731
|
+
);
|
|
732
|
+
} else {
|
|
733
|
+
slotGlyph = (
|
|
734
|
+
<span data-fods-part="trailing-icon" aria-hidden="true" className={subjectLookupGlyphVariants({ tone: 'brand' })}>
|
|
735
|
+
<Icon name="magic-wand" size="default" />
|
|
736
|
+
</span>
|
|
737
|
+
);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
const trailing = (
|
|
741
|
+
<span className="inline-flex shrink-0 items-center gap-400">
|
|
742
|
+
{stateGlyph}
|
|
743
|
+
{slotGlyph}
|
|
744
|
+
</span>
|
|
745
|
+
);
|
|
746
|
+
|
|
747
|
+
// A host error (families host-error) wins over every flow look; Found is the only success.
|
|
748
|
+
const shellState = disabled
|
|
749
|
+
? 'disabled'
|
|
750
|
+
: error
|
|
751
|
+
? 'error'
|
|
752
|
+
: flow === 'found'
|
|
753
|
+
? 'success'
|
|
754
|
+
: flow === 'focused' || flow === 'searching' || (flow === 'no-match' && isPanelOpen)
|
|
755
|
+
? 'focused'
|
|
756
|
+
: 'default';
|
|
757
|
+
|
|
758
|
+
// One status node, the only place the outcome is announced (manifest `loading`).
|
|
759
|
+
const outcomeText =
|
|
760
|
+
flow === 'searching'
|
|
761
|
+
? labels.statusSearching
|
|
762
|
+
: flow === 'found'
|
|
763
|
+
? labels.statusFound(resultCount)
|
|
764
|
+
: flow === 'no-match'
|
|
765
|
+
? labels.statusNoMatch
|
|
766
|
+
: '';
|
|
767
|
+
const statusText = hintPreempts && !forcedState ? hint : outcomeText;
|
|
768
|
+
const statusNode = (
|
|
769
|
+
<span role="status" aria-live="polite" data-fods-part="status" className={subjectLookupStatusVariants()}>
|
|
770
|
+
{statusText}
|
|
771
|
+
</span>
|
|
772
|
+
);
|
|
773
|
+
|
|
774
|
+
// Below `sm` the field is a read-only trigger that opens a dialog. It stays a
|
|
775
|
+
// `combobox` (as Combobox and DateField do): a plain text input supports neither
|
|
776
|
+
// `aria-expanded` nor a dialog popup, so without the role the open state would be
|
|
777
|
+
// invalid ARIA. The sheet's own search input owns the listbox contract.
|
|
778
|
+
const fieldInteraction = isSheet
|
|
779
|
+
? ({ role: 'combobox', readOnly: true, 'aria-haspopup': 'dialog', 'aria-expanded': open } as const)
|
|
780
|
+
: {
|
|
781
|
+
role: 'combobox',
|
|
782
|
+
'aria-autocomplete': 'list' as const,
|
|
783
|
+
onChange: handleChange,
|
|
784
|
+
'aria-expanded': isPanelOpen,
|
|
785
|
+
'aria-controls': panelId,
|
|
786
|
+
'aria-activedescendant': open && activeIndex != null ? optionId(activeIndex) : undefined,
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
const shell = (
|
|
790
|
+
<SubjectLookupShell
|
|
791
|
+
id={id}
|
|
792
|
+
// Read by `Field`: Found takes the shell's Success label ink; focused floats it.
|
|
793
|
+
state={flow === 'found' ? 'success' : flow === 'focused' ? 'focused' : 'default'}
|
|
794
|
+
shellState={shellState}
|
|
795
|
+
holdsSuccessOnFocus={!disabled && !error && flow === 'found'}
|
|
796
|
+
shellRef={panel.refs.setReference}
|
|
797
|
+
inputRef={setInputRef}
|
|
798
|
+
trailing={trailing}
|
|
799
|
+
onShellPointerDown={handleShellPointerDown}
|
|
800
|
+
onShellMouseDown={handleShellMouseDown}
|
|
801
|
+
onShellClick={handleShellClick}
|
|
802
|
+
value={query}
|
|
803
|
+
placeholder={placeholder}
|
|
804
|
+
disabled={disabled}
|
|
805
|
+
autoComplete="off"
|
|
806
|
+
aria-busy={flow === 'searching' || undefined}
|
|
807
|
+
aria-label={ariaLabel}
|
|
808
|
+
aria-invalid={ariaInvalid}
|
|
809
|
+
aria-describedby={ariaDescribedby}
|
|
810
|
+
onFocus={handleFocus}
|
|
811
|
+
onBlur={handleBlur}
|
|
812
|
+
onKeyDown={handleKeyDown}
|
|
813
|
+
{...fieldInteraction}
|
|
814
|
+
/>
|
|
815
|
+
);
|
|
816
|
+
|
|
817
|
+
const renderRow = (entry: RingEntry<T>, index: number, rowSize: 'md' | 'mobile') => {
|
|
818
|
+
const common = {
|
|
819
|
+
id: optionId(index),
|
|
820
|
+
role: 'option',
|
|
821
|
+
size: rowSize,
|
|
822
|
+
highlighted: activeIndex === index,
|
|
823
|
+
onPointerEnter: () => setActiveIndex(index),
|
|
824
|
+
// Focus stays in the input — „Dalších N" keeps the panel open under it.
|
|
825
|
+
onMouseDown: (event: React.MouseEvent) => event.preventDefault(),
|
|
826
|
+
onClick: () => activate(index),
|
|
827
|
+
ref: (node: HTMLDivElement | null) => {
|
|
828
|
+
panel.listRef.current[index] = node;
|
|
829
|
+
},
|
|
830
|
+
} as const;
|
|
831
|
+
if (entry.kind === 'manual') {
|
|
832
|
+
return (
|
|
833
|
+
<ListRow key="manual" {...common} variant="link" data-fods-part="manual-entry">
|
|
834
|
+
{flow === 'no-match'
|
|
835
|
+
? labels.noMatch(query)
|
|
836
|
+
: hasQuery
|
|
837
|
+
? labels.manualEntry(query)
|
|
838
|
+
: labels.manualEntryEmpty}
|
|
839
|
+
</ListRow>
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
if (entry.kind === 'more') {
|
|
843
|
+
return (
|
|
844
|
+
<ListRow
|
|
845
|
+
key={`more-${entry.source}`}
|
|
846
|
+
{...common}
|
|
847
|
+
variant="link"
|
|
848
|
+
data-fods-part="show-more"
|
|
849
|
+
trailing={<Icon name="caret-down-small" />}
|
|
850
|
+
>
|
|
851
|
+
{labels.showMore(entry.remaining)}
|
|
852
|
+
</ListRow>
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
const { item, source } = entry;
|
|
856
|
+
const identifiers = [
|
|
857
|
+
item.companyNumber ? (
|
|
858
|
+
<React.Fragment key="ico">
|
|
859
|
+
{labels.companyNumber}: <span className="font-semibold">{item.companyNumber}</span>
|
|
860
|
+
</React.Fragment>
|
|
861
|
+
) : null,
|
|
862
|
+
item.taxNumber ? (
|
|
863
|
+
<React.Fragment key="dic">
|
|
864
|
+
{labels.taxNumber}: <span className="font-semibold">{item.taxNumber}</span>
|
|
865
|
+
</React.Fragment>
|
|
866
|
+
) : null,
|
|
867
|
+
].filter(Boolean);
|
|
868
|
+
const identifierLine =
|
|
869
|
+
identifiers.length > 0
|
|
870
|
+
? identifiers.flatMap((node, i) => (i === 0 ? [node] : [' · ', node]))
|
|
871
|
+
: undefined;
|
|
872
|
+
// Missing parts are omitted, never placeholdered; a contact with no identifiers is
|
|
873
|
+
// a plain single-line row (list-row.md § Copy).
|
|
874
|
+
const description = [
|
|
875
|
+
identifierLine ? <>{identifierLine}</> : undefined,
|
|
876
|
+
source === 'registry' && item.address ? item.address : undefined,
|
|
877
|
+
].filter(line => line !== undefined);
|
|
878
|
+
return (
|
|
879
|
+
<ListRow
|
|
880
|
+
key={`${source}-${item.id}`}
|
|
881
|
+
{...common}
|
|
882
|
+
data-fods-part="option"
|
|
883
|
+
// An option that is never selected: on pick the field collapses.
|
|
884
|
+
aria-selected={false}
|
|
885
|
+
description={description.length > 0 ? description : undefined}
|
|
886
|
+
>
|
|
887
|
+
<HighlightedLabel label={item.label} query={query} />
|
|
888
|
+
</ListRow>
|
|
889
|
+
);
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
// Ring index of each entry, to keep ids and refs aligned across the sections.
|
|
893
|
+
const ringIndex = (predicate: (entry: RingEntry<T>) => boolean) => ring.findIndex(predicate);
|
|
894
|
+
const itemIndex = (item: T) => ringIndex(entry => entry.kind === 'item' && entry.item === item);
|
|
895
|
+
const showTitles = sections.length > 1 || (!hasQuery && sections.length > 0);
|
|
896
|
+
const groupTitle = (group: SubjectLookupGroup<T>) =>
|
|
897
|
+
group.source === 'registry'
|
|
898
|
+
? labels.registryGroup(group.total)
|
|
899
|
+
: hasQuery
|
|
900
|
+
? labels.contactsGroup(group.total)
|
|
901
|
+
: labels.browseContacts(group.total);
|
|
902
|
+
|
|
903
|
+
const moreEntries = ring
|
|
904
|
+
.map((entry, index) => ({ entry, index }))
|
|
905
|
+
.filter(({ entry }) => entry.kind === 'more');
|
|
906
|
+
|
|
907
|
+
// ---- Anchored panel ---------------------------------------------------------
|
|
908
|
+
const hasResults = flow !== 'no-match' && sections.length > 0;
|
|
909
|
+
const runCap = registry ? REGISTRY_RUN_CAP : CONTACT_RUN_CAP;
|
|
910
|
+
const cappedPanel = {
|
|
911
|
+
...panel,
|
|
912
|
+
bodyStyle: { maxHeight: `min(${runCap}, var(--panel-available-height, 100vh))` },
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
const anchoredSections = sections.map((group, sectionIndex) => {
|
|
916
|
+
const titleId = `${reactId}-group-${group.source}`;
|
|
917
|
+
return (
|
|
918
|
+
<React.Fragment key={group.source}>
|
|
919
|
+
{sectionIndex > 0 && <Divider variant="line" aria-hidden="true" />}
|
|
920
|
+
{showTitles && (
|
|
921
|
+
// `aria-hidden`: a separator is not an owned child of a listbox; the title
|
|
922
|
+
// still names its group through `aria-labelledby` below.
|
|
923
|
+
<Divider variant="line-label" label={groupTitle(group)} labelId={titleId} aria-hidden="true" />
|
|
924
|
+
)}
|
|
925
|
+
<AnchoredPanel.Group
|
|
926
|
+
{...(showTitles ? { role: 'group', 'aria-labelledby': titleId } : null)}
|
|
927
|
+
>
|
|
928
|
+
{group.items.map(item => renderRow({ kind: 'item', item, source: group.source }, itemIndex(item), 'md'))}
|
|
929
|
+
</AnchoredPanel.Group>
|
|
930
|
+
</React.Fragment>
|
|
931
|
+
);
|
|
932
|
+
});
|
|
933
|
+
|
|
934
|
+
const manualRow = !isSheet ? renderRow({ kind: 'manual' }, 0, 'md') : null;
|
|
935
|
+
|
|
936
|
+
const panelBody = hasResults ? (
|
|
937
|
+
anchoredSections
|
|
938
|
+
) : (
|
|
939
|
+
// No match, or nothing yet: the manual-entry line is the whole panel.
|
|
940
|
+
<AnchoredPanel.Group>{manualRow}</AnchoredPanel.Group>
|
|
941
|
+
);
|
|
942
|
+
|
|
943
|
+
// ---- Bottom sheet -----------------------------------------------------------
|
|
944
|
+
const sheetTitleText = labels.sheetTitle || label || fieldLabel || ariaLabel || panelLabel || '';
|
|
945
|
+
const sheetSections = sections.map((group) => {
|
|
946
|
+
const titleId = `${reactId}-sheet-group-${group.source}`;
|
|
947
|
+
return (
|
|
948
|
+
<BottomSheet.Group
|
|
949
|
+
key={group.source}
|
|
950
|
+
label={showTitles ? groupTitle(group) : undefined}
|
|
951
|
+
labelId={titleId}
|
|
952
|
+
{...(showTitles ? { role: 'group', 'aria-labelledby': titleId } : null)}
|
|
953
|
+
>
|
|
954
|
+
{group.items.map(item =>
|
|
955
|
+
renderRow({ kind: 'item', item, source: group.source }, itemIndex(item), 'mobile'),
|
|
956
|
+
)}
|
|
957
|
+
</BottomSheet.Group>
|
|
958
|
+
);
|
|
959
|
+
});
|
|
960
|
+
|
|
961
|
+
return (
|
|
962
|
+
<div className={cn('relative w-full', className)} data-testid={dataTestid}>
|
|
963
|
+
{label ? (
|
|
964
|
+
<Field
|
|
965
|
+
label={label}
|
|
966
|
+
helperText={hint || helperText}
|
|
967
|
+
error={error}
|
|
968
|
+
optionalLabel={optionalLabel}
|
|
969
|
+
>
|
|
970
|
+
{shell}
|
|
971
|
+
</Field>
|
|
972
|
+
) : (
|
|
973
|
+
shell
|
|
974
|
+
)}
|
|
975
|
+
|
|
976
|
+
{/* The sheet makes the page inert, so the one status node moves into it. */}
|
|
977
|
+
{!(isSheet && open) && statusNode}
|
|
978
|
+
|
|
979
|
+
{isSheet && (
|
|
980
|
+
<BottomSheet
|
|
981
|
+
open={open}
|
|
982
|
+
onOpenChange={(next) => {
|
|
983
|
+
setOpen(next);
|
|
984
|
+
if (!next) setActiveIndex(null);
|
|
985
|
+
}}
|
|
986
|
+
title={sheetTitleText}
|
|
987
|
+
titleId={sheetTitleId}
|
|
988
|
+
closeLabel={sheetCloseLabel}
|
|
989
|
+
initialFocus={() => sheetSearchRef.current}
|
|
990
|
+
returnFocusRef={inputRef}
|
|
991
|
+
owner="subject-lookup-field"
|
|
992
|
+
search={
|
|
993
|
+
<BottomSheetSearch
|
|
994
|
+
ref={sheetSearchRef}
|
|
995
|
+
role="combobox"
|
|
996
|
+
aria-autocomplete="list"
|
|
997
|
+
aria-expanded={open}
|
|
998
|
+
aria-controls={sheetListboxId}
|
|
999
|
+
aria-activedescendant={activeIndex != null ? optionId(activeIndex) : undefined}
|
|
1000
|
+
aria-busy={flow === 'searching' || undefined}
|
|
1001
|
+
aria-labelledby={sheetTitleId}
|
|
1002
|
+
value={query}
|
|
1003
|
+
placeholder={placeholder}
|
|
1004
|
+
onChange={handleChange}
|
|
1005
|
+
onKeyDown={handleSheetKeyDown}
|
|
1006
|
+
/>
|
|
1007
|
+
}
|
|
1008
|
+
footer={
|
|
1009
|
+
/* The footer has no padding of its own except --space-400 + the bottom
|
|
1010
|
+
safe-area inset (overlay-behavior.md § Mobile → Footer); the body stops
|
|
1011
|
+
paying the inset when a footer exists. */
|
|
1012
|
+
<BottomSheet.Group className="pb-[calc(var(--space-400)+env(safe-area-inset-bottom))]">
|
|
1013
|
+
{open && statusNode}
|
|
1014
|
+
<ListRow
|
|
1015
|
+
variant="link"
|
|
1016
|
+
size="mobile"
|
|
1017
|
+
role="button"
|
|
1018
|
+
tabIndex={0}
|
|
1019
|
+
data-fods-part="manual-entry"
|
|
1020
|
+
className={SHEET_ROW_FOCUS_RING}
|
|
1021
|
+
onClick={runManualEntry}
|
|
1022
|
+
onKeyDown={(event) => {
|
|
1023
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
1024
|
+
event.preventDefault();
|
|
1025
|
+
runManualEntry();
|
|
1026
|
+
}
|
|
1027
|
+
}}
|
|
1028
|
+
>
|
|
1029
|
+
{flow === 'no-match'
|
|
1030
|
+
? labels.noMatch(query)
|
|
1031
|
+
: hasQuery
|
|
1032
|
+
? labels.manualEntry(query)
|
|
1033
|
+
: labels.manualEntryEmpty}
|
|
1034
|
+
</ListRow>
|
|
1035
|
+
</BottomSheet.Group>
|
|
1036
|
+
}
|
|
1037
|
+
>
|
|
1038
|
+
<div id={sheetListboxId} role="listbox" aria-labelledby={sheetTitleId}>
|
|
1039
|
+
{hasResults && sheetSections}
|
|
1040
|
+
{hasResults && moreEntries.length > 0 && (
|
|
1041
|
+
<BottomSheet.Group>
|
|
1042
|
+
{moreEntries.map(({ entry, index }) => renderRow(entry, index, 'mobile'))}
|
|
1043
|
+
</BottomSheet.Group>
|
|
1044
|
+
)}
|
|
1045
|
+
</div>
|
|
1046
|
+
</BottomSheet>
|
|
1047
|
+
)}
|
|
1048
|
+
|
|
1049
|
+
<AnchoredPanel
|
|
1050
|
+
panel={cappedPanel}
|
|
1051
|
+
size="md"
|
|
1052
|
+
focusModel="virtual"
|
|
1053
|
+
panelProps={panelLabelledBy ? { 'aria-labelledby': panelLabelledBy } : { 'aria-label': panelName }}
|
|
1054
|
+
// Pinned above the results run, so the list never scrolls it away; the panel
|
|
1055
|
+
// draws the plain divider under it.
|
|
1056
|
+
header={hasResults ? <AnchoredPanel.Group>{manualRow}</AnchoredPanel.Group> : undefined}
|
|
1057
|
+
// „Dalších N" stays reachable while the results scroll (owner decision 2026-08-12).
|
|
1058
|
+
footer={
|
|
1059
|
+
hasResults && moreEntries.length > 0 ? (
|
|
1060
|
+
<AnchoredPanel.Group>
|
|
1061
|
+
{moreEntries.map(({ entry, index }) => renderRow(entry, index, 'md'))}
|
|
1062
|
+
</AnchoredPanel.Group>
|
|
1063
|
+
) : undefined
|
|
1064
|
+
}
|
|
1065
|
+
>
|
|
1066
|
+
{panelBody}
|
|
1067
|
+
</AnchoredPanel>
|
|
1068
|
+
</div>
|
|
1069
|
+
);
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
const SubjectLookupField = React.forwardRef(SubjectLookupFieldInner) as (<
|
|
1073
|
+
T extends SubjectLookupItem = SubjectLookupItem,
|
|
1074
|
+
>(
|
|
1075
|
+
props: SubjectLookupFieldProps<T> & { ref?: React.Ref<HTMLInputElement> },
|
|
1076
|
+
) => React.ReactElement) & { displayName?: string };
|
|
1077
|
+
SubjectLookupField.displayName = 'SubjectLookupField';
|
|
1078
|
+
|
|
1079
|
+
export { SubjectLookupField, subjectLookupGlyphVariants, subjectLookupButtonVariants };
|