@dbcdk/react-components 0.0.103 → 0.0.104
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/dist/assets/logo.cjs +87 -0
- package/dist/assets/logo.js +85 -0
- package/dist/client.cjs +587 -0
- package/dist/client.d.ts +83 -0
- package/dist/client.js +84 -0
- package/dist/components/accordion/Accordion.cjs +103 -0
- package/dist/components/accordion/Accordion.js +97 -0
- package/dist/components/accordion/Accordion.module.css +41 -0
- package/dist/components/accordion/components/AccordionRow.cjs +115 -0
- package/dist/components/accordion/components/AccordionRow.js +109 -0
- package/dist/components/accordion/components/AccordionRow.module.css +99 -0
- package/dist/components/alert/Alert.cjs +52 -0
- package/dist/components/alert/Alert.d.ts +2 -1
- package/dist/components/alert/Alert.js +46 -0
- package/dist/components/alert/Alert.module.css +97 -0
- package/dist/components/app-header/AppHeader.cjs +14 -0
- package/dist/components/app-header/AppHeader.js +8 -0
- package/dist/components/app-header/AppHeader.module.css +74 -0
- package/dist/components/attribute-chip/AttributeChip.cjs +22 -0
- package/dist/components/attribute-chip/AttributeChip.js +16 -0
- package/dist/components/attribute-chip/AttributeChip.module.css +65 -0
- package/dist/components/avatar/Avatar.cjs +111 -0
- package/dist/components/avatar/Avatar.js +86 -0
- package/dist/components/avatar/Avatar.module.css +91 -0
- package/dist/components/breadcrumbs/Breadcrumbs.cjs +24 -0
- package/dist/components/breadcrumbs/Breadcrumbs.js +18 -0
- package/dist/components/breadcrumbs/Breadcrumbs.module.css +80 -0
- package/dist/components/button/Button.cjs +149 -0
- package/dist/components/button/Button.js +124 -0
- package/dist/components/button/Button.module.css +260 -0
- package/dist/components/button-select/ButtonSelect.cjs +35 -0
- package/dist/components/button-select/ButtonSelect.js +29 -0
- package/dist/components/button-select/ButtonSelect.module.css +40 -0
- package/dist/components/card/Card.cjs +112 -0
- package/dist/components/card/Card.d.ts +2 -1
- package/dist/components/card/Card.js +106 -0
- package/dist/components/card/Card.module.css +187 -0
- package/dist/components/card/components/CardMeta.cjs +62 -0
- package/dist/components/card/components/CardMeta.js +55 -0
- package/dist/components/card/components/CardMeta.module.css +55 -0
- package/dist/components/card-container/CardContainer.cjs +34 -0
- package/dist/components/card-container/CardContainer.js +28 -0
- package/dist/components/card-container/CardContainer.module.css +63 -0
- package/dist/components/chip/Chip.cjs +65 -0
- package/dist/components/chip/Chip.js +59 -0
- package/dist/components/chip/Chip.module.css +236 -0
- package/dist/components/circle/Circle.cjs +33 -0
- package/dist/components/circle/Circle.js +27 -0
- package/dist/components/circle/Circle.module.css +128 -0
- package/dist/components/clear-button/ClearButton.cjs +33 -0
- package/dist/components/clear-button/ClearButton.d.ts +2 -1
- package/dist/components/clear-button/ClearButton.js +27 -0
- package/dist/components/clear-button/ClearButton.module.css +26 -0
- package/dist/components/code-block/CodeBlock.cjs +97 -0
- package/dist/components/code-block/CodeBlock.js +91 -0
- package/dist/components/code-block/CodeBlock.module.css +124 -0
- package/dist/components/copy-button/CopyButton.cjs +139 -0
- package/dist/components/copy-button/CopyButton.js +133 -0
- package/dist/components/copy-button/CopyButton.module.css +22 -0
- package/dist/components/datetime-picker/DateTimePicker.cjs +559 -0
- package/dist/components/datetime-picker/DateTimePicker.js +553 -0
- package/dist/components/datetime-picker/DateTimePicker.module.css +155 -0
- package/dist/components/datetime-picker/dateTimeHelpers.cjs +179 -0
- package/dist/components/datetime-picker/dateTimeHelpers.js +160 -0
- package/dist/components/divider/Divider.cjs +22 -0
- package/dist/components/divider/Divider.js +20 -0
- package/dist/components/filter-field/FilterField.cjs +296 -0
- package/dist/components/filter-field/FilterField.js +289 -0
- package/dist/components/filter-field/FilterField.module.css +379 -0
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.cjs +115 -0
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +108 -0
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +59 -0
- package/dist/components/forms/checkbox/Checkbox.cjs +88 -0
- package/dist/components/forms/checkbox/Checkbox.js +82 -0
- package/dist/components/forms/checkbox/Checkbox.module.css +104 -0
- package/dist/components/forms/checkbox-group/CheckboxGroup.cjs +121 -0
- package/dist/components/forms/checkbox-group/CheckboxGroup.js +115 -0
- package/dist/components/forms/checkbox-group/CheckboxGroup.module.css +115 -0
- package/dist/components/forms/form-select/FormSelect.cjs +191 -0
- package/dist/components/forms/form-select/FormSelect.js +166 -0
- package/dist/components/forms/form-select/FormSelect.module.css +236 -0
- package/dist/components/forms/input/Input.cjs +188 -0
- package/dist/components/forms/input/Input.d.ts +1 -0
- package/dist/components/forms/input/Input.js +182 -0
- package/dist/components/forms/input/Input.module.css +468 -0
- package/dist/components/forms/input-container/InputContainer.cjs +72 -0
- package/dist/components/forms/input-container/InputContainer.js +66 -0
- package/dist/components/forms/input-container/InputContainer.module.css +59 -0
- package/dist/components/forms/multi-select/MultiSelect.cjs +227 -0
- package/dist/components/forms/multi-select/MultiSelect.js +225 -0
- package/dist/components/forms/radio-buttons/RadioButton.cjs +91 -0
- package/dist/components/forms/radio-buttons/RadioButton.js +85 -0
- package/dist/components/forms/radio-buttons/RadioButtonGroup.cjs +74 -0
- package/dist/components/forms/radio-buttons/RadioButtonGroup.js +72 -0
- package/dist/components/forms/radio-buttons/RadioButtons.module.css +118 -0
- package/dist/components/forms/select/Select.cjs +286 -0
- package/dist/components/forms/select/Select.js +280 -0
- package/dist/components/forms/select/Select.module.css +32 -0
- package/dist/components/forms/text-area/Textarea.cjs +116 -0
- package/dist/components/forms/text-area/Textarea.js +110 -0
- package/dist/components/forms/text-area/Textarea.module.css +70 -0
- package/dist/components/forms/typeahead/Typeahead.cjs +792 -0
- package/dist/components/forms/typeahead/Typeahead.js +768 -0
- package/dist/components/forms/typeahead/Typeahead.module.css +38 -0
- package/dist/components/grid/Grid.cjs +45 -0
- package/dist/components/grid/Grid.js +38 -0
- package/dist/components/grid/Grid.module.css +35 -0
- package/dist/components/headline/CollapsibleHeadline.cjs +80 -0
- package/dist/components/headline/CollapsibleHeadline.js +74 -0
- package/dist/components/headline/Headline.cjs +59 -0
- package/dist/components/headline/Headline.js +53 -0
- package/dist/components/headline/Headline.module.css +185 -0
- package/dist/components/hyperlink/Hyperlink.cjs +107 -0
- package/dist/components/hyperlink/Hyperlink.js +82 -0
- package/dist/components/hyperlink/Hyperlink.module.css +121 -0
- package/dist/components/icon/Icon.cjs +27 -0
- package/dist/components/icon/Icon.js +20 -0
- package/dist/components/icon/Icon.module.css +36 -0
- package/dist/components/inline-status/InlineStatus.cjs +39 -0
- package/dist/components/inline-status/InlineStatus.js +33 -0
- package/dist/components/inline-status/InlineStatus.module.css +92 -0
- package/dist/components/interval-select/IntervalSelect.cjs +203 -0
- package/dist/components/interval-select/IntervalSelect.js +201 -0
- package/dist/components/json-viewer/HighlightedText.cjs +13 -0
- package/dist/components/json-viewer/HighlightedText.js +11 -0
- package/dist/components/json-viewer/JsonNode.cjs +124 -0
- package/dist/components/json-viewer/JsonNode.js +118 -0
- package/dist/components/json-viewer/JsonViewer.cjs +164 -0
- package/dist/components/json-viewer/JsonViewer.js +158 -0
- package/dist/components/json-viewer/JsonViewer.module.css +346 -0
- package/dist/components/json-viewer/types.cjs +2 -0
- package/dist/components/json-viewer/types.js +1 -0
- package/dist/components/json-viewer/useClipboardStatus.cjs +15 -0
- package/dist/components/json-viewer/useClipboardStatus.js +13 -0
- package/dist/components/json-viewer/utils.cjs +126 -0
- package/dist/components/json-viewer/utils.js +111 -0
- package/dist/components/media-card/MediaCard.cjs +60 -0
- package/dist/components/media-card/MediaCard.d.ts +19 -0
- package/dist/components/media-card/MediaCard.js +54 -0
- package/dist/components/media-card/MediaCard.module.css +92 -0
- package/dist/components/menu/Menu.cjs +287 -0
- package/dist/components/menu/Menu.js +262 -0
- package/dist/components/menu/Menu.module.css +220 -0
- package/dist/components/meta-bar/MetaBar.cjs +28 -0
- package/dist/components/meta-bar/MetaBar.js +22 -0
- package/dist/components/meta-bar/MetaBar.module.css +27 -0
- package/dist/components/nav-bar/NavBar.cjs +95 -0
- package/dist/components/nav-bar/NavBar.d.ts +1 -1
- package/dist/components/nav-bar/NavBar.js +89 -0
- package/dist/components/nav-bar/NavBar.module.css +225 -0
- package/dist/components/overlay/fade-overlay/FadeOverlay.cjs +30 -0
- package/dist/components/overlay/fade-overlay/FadeOverlay.js +24 -0
- package/dist/components/overlay/fade-overlay/FadeOverlay.module.css +54 -0
- package/dist/components/overlay/modal/Modal.cjs +189 -0
- package/dist/components/overlay/modal/Modal.d.ts +2 -1
- package/dist/components/overlay/modal/Modal.js +183 -0
- package/dist/components/overlay/modal/Modal.module.css +112 -0
- package/dist/components/overlay/modal/provider/ModalProvider.cjs +98 -0
- package/dist/components/overlay/modal/provider/ModalProvider.js +95 -0
- package/dist/components/overlay/side-panel/SidePanel.cjs +173 -0
- package/dist/components/overlay/side-panel/SidePanel.js +167 -0
- package/dist/components/overlay/side-panel/SidePanel.module.css +177 -0
- package/dist/components/overlay/side-panel/useSidePanel.cjs +16 -0
- package/dist/components/overlay/side-panel/useSidePanel.js +14 -0
- package/dist/components/overlay/tooltip/Tooltip.cjs +34 -0
- package/dist/components/overlay/tooltip/Tooltip.js +32 -0
- package/dist/components/overlay/tooltip/Tooltip.module.css +104 -0
- package/dist/components/overlay/tooltip/TooltipProvider.cjs +238 -0
- package/dist/components/overlay/tooltip/TooltipProvider.js +231 -0
- package/dist/components/overlay/tooltip/useTooltipTrigger.cjs +117 -0
- package/dist/components/overlay/tooltip/useTooltipTrigger.js +115 -0
- package/dist/components/page/Page.cjs +63 -0
- package/dist/components/page/Page.js +57 -0
- package/dist/components/page/Page.module.css +95 -0
- package/dist/components/page-layout/PageLayout.cjs +97 -0
- package/dist/components/page-layout/PageLayout.d.ts +0 -5
- package/dist/components/page-layout/PageLayout.js +91 -0
- package/dist/components/page-layout/PageLayout.module.css +236 -0
- package/dist/components/page-layout/components/footer/Footer.cjs +53 -0
- package/dist/components/page-layout/components/footer/Footer.js +47 -0
- package/dist/components/page-layout/components/footer/Footer.module.css +89 -0
- package/dist/components/pagination/Pagination.cjs +160 -0
- package/dist/components/pagination/Pagination.js +154 -0
- package/dist/components/pagination/Pagination.module.css +25 -0
- package/dist/components/panel/Panel.cjs +38 -0
- package/dist/components/panel/Panel.js +32 -0
- package/dist/components/panel/Panel.module.css +30 -0
- package/dist/components/popover/Popover.cjs +331 -0
- package/dist/components/popover/Popover.js +307 -0
- package/dist/components/popover/Popover.module.css +52 -0
- package/dist/components/search-box/SearchBox.cjs +274 -0
- package/dist/components/search-box/SearchBox.js +268 -0
- package/dist/components/search-box/SearchBox.module.css +27 -0
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.cjs +127 -0
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +121 -0
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.module.css +174 -0
- package/dist/components/sidebar/Sidebar.cjs +39 -0
- package/dist/components/sidebar/Sidebar.js +37 -0
- package/dist/components/sidebar/components/SidebarItem.cjs +29 -0
- package/dist/components/sidebar/components/SidebarItem.js +27 -0
- package/dist/components/sidebar/components/SidebarItem.module.css +0 -0
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.cjs +133 -0
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +127 -0
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +29 -0
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.cjs +214 -0
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +207 -0
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +260 -0
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.cjs +54 -0
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +47 -0
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.module.css +106 -0
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.cjs +61 -0
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +55 -0
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.module.css +20 -0
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.cjs +97 -0
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +91 -0
- package/dist/components/sidebar/providers/SidebarProvider.cjs +223 -0
- package/dist/components/sidebar/providers/SidebarProvider.js +220 -0
- package/dist/components/skeleton-loader/SkeletonLoader.cjs +442 -0
- package/dist/components/skeleton-loader/SkeletonLoader.js +440 -0
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.cjs +42 -0
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +36 -0
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.module.css +51 -0
- package/dist/components/split-button/SplitButton.cjs +46 -0
- package/dist/components/split-button/SplitButton.js +40 -0
- package/dist/components/split-button/SplitButton.module.css +32 -0
- package/dist/components/split-pane/SplitPane.cjs +177 -0
- package/dist/components/split-pane/SplitPane.js +168 -0
- package/dist/components/split-pane/SplitPane.module.css +111 -0
- package/dist/components/split-pane/provider/SplitPaneContext.cjs +129 -0
- package/dist/components/split-pane/provider/SplitPaneContext.js +121 -0
- package/dist/components/stack/Stack.cjs +47 -0
- package/dist/components/stack/Stack.d.ts +1 -1
- package/dist/components/stack/Stack.js +41 -0
- package/dist/components/stack/Stack.module.css +61 -0
- package/dist/components/state-page/StatePage.cjs +48 -0
- package/dist/components/state-page/StatePage.js +42 -0
- package/dist/components/state-page/StatePage.module.css +9 -0
- package/dist/components/state-page/empty.cjs +664 -0
- package/dist/components/state-page/empty.js +662 -0
- package/dist/components/state-page/error.cjs +310 -0
- package/dist/components/state-page/error.js +308 -0
- package/dist/components/state-page/notFound.cjs +243 -0
- package/dist/components/state-page/notFound.js +241 -0
- package/dist/components/sticky-footer-layout/StickyFooterLayout.cjs +98 -0
- package/dist/components/sticky-footer-layout/StickyFooterLayout.js +96 -0
- package/dist/components/table/Table.cjs +216 -0
- package/dist/components/table/Table.js +210 -0
- package/dist/components/table/Table.module.css +534 -0
- package/dist/components/table/Table.types.cjs +2 -0
- package/dist/components/table/Table.types.js +1 -0
- package/dist/components/table/TanstackTable.cjs +172 -0
- package/dist/components/table/TanstackTable.js +147 -0
- package/dist/components/table/components/TableBody.cjs +50 -0
- package/dist/components/table/components/TableBody.js +44 -0
- package/dist/components/table/components/TableHeader.cjs +56 -0
- package/dist/components/table/components/TableHeader.js +50 -0
- package/dist/components/table/components/TableHeaderCell.cjs +69 -0
- package/dist/components/table/components/TableHeaderCell.js +63 -0
- package/dist/components/table/components/TableLoadingBody.cjs +35 -0
- package/dist/components/table/components/TableLoadingBody.js +29 -0
- package/dist/components/table/components/TablePagination.cjs +2 -0
- package/dist/components/table/components/TablePagination.js +1 -0
- package/dist/components/table/components/TableRow.cjs +151 -0
- package/dist/components/table/components/TableRow.js +145 -0
- package/dist/components/table/components/TableSelectionCell.cjs +41 -0
- package/dist/components/table/components/TableSelectionCell.js +35 -0
- package/dist/components/table/components/column-resizer/ColumnResizer.cjs +25 -0
- package/dist/components/table/components/column-resizer/ColumnResizer.js +19 -0
- package/dist/components/table/components/column-resizer/ColumnResizer.module.css +22 -0
- package/dist/components/table/components/empty-state/EmptyState.cjs +33 -0
- package/dist/components/table/components/empty-state/EmptyState.js +31 -0
- package/dist/components/table/components/empty-state/EmptyState.module.css +4 -0
- package/dist/components/table/components/table-settings/TableSettings.cjs +139 -0
- package/dist/components/table/components/table-settings/TableSettings.js +137 -0
- package/dist/components/table/hooks/useTableRowInteractions.cjs +46 -0
- package/dist/components/table/hooks/useTableRowInteractions.js +44 -0
- package/dist/components/table/table.classes.cjs +49 -0
- package/dist/components/table/table.classes.js +40 -0
- package/dist/components/table/table.utils.cjs +57 -0
- package/dist/components/table/table.utils.js +45 -0
- package/dist/components/table/tanstackTable.utils.cjs +166 -0
- package/dist/components/table/tanstackTable.utils.js +159 -0
- package/dist/components/tabs/Tabs.cjs +172 -0
- package/dist/components/tabs/Tabs.js +166 -0
- package/dist/components/tabs/Tabs.module.css +261 -0
- package/dist/components/theme-button/ThemeButton.cjs +78 -0
- package/dist/components/theme-button/ThemeButton.js +75 -0
- package/dist/components/toast/Toast.cjs +68 -0
- package/dist/components/toast/Toast.js +62 -0
- package/dist/components/toast/Toast.module.css +161 -0
- package/dist/components/toast/provider/ToastProvider.cjs +105 -0
- package/dist/components/toast/provider/ToastProvider.js +97 -0
- package/dist/components/user-display/UserDisplay.cjs +22 -0
- package/dist/components/user-display/UserDisplay.js +16 -0
- package/dist/components/user-display/UserDisplay.module.css +25 -0
- package/dist/constants/chart-colors.cjs +10 -0
- package/dist/constants/chart-colors.js +8 -0
- package/dist/constants/chart-colors.types.cjs +2 -0
- package/dist/constants/chart-colors.types.js +1 -0
- package/dist/constants/severity.cjs +30 -0
- package/dist/constants/severity.js +26 -0
- package/dist/constants/severity.types.cjs +2 -0
- package/dist/constants/severity.types.js +1 -0
- package/dist/constants/sizes.cjs +11 -0
- package/dist/constants/sizes.js +9 -0
- package/dist/hooks/useDeviceSize.cjs +35 -0
- package/dist/hooks/useDeviceSize.js +33 -0
- package/dist/hooks/useListNavigation.cjs +237 -0
- package/dist/hooks/useListNavigation.js +235 -0
- package/dist/hooks/usePagination.cjs +144 -0
- package/dist/hooks/usePagination.js +142 -0
- package/dist/hooks/useSorting.cjs +119 -0
- package/dist/hooks/useSorting.js +117 -0
- package/dist/hooks/useTableData.cjs +53 -0
- package/dist/hooks/useTableData.js +51 -0
- package/dist/hooks/useTableSelection.cjs +172 -0
- package/dist/hooks/useTableSelection.js +170 -0
- package/dist/hooks/useTableSettings.cjs +90 -0
- package/dist/hooks/useTableSettings.js +87 -0
- package/dist/hooks/useTheme.cjs +64 -0
- package/dist/hooks/useTheme.js +62 -0
- package/dist/hooks/useTimeDuration.cjs +72 -0
- package/dist/hooks/useTimeDuration.js +70 -0
- package/dist/hooks/useViewportFill.cjs +82 -0
- package/dist/hooks/useViewportFill.js +80 -0
- package/dist/index.cjs +161 -12908
- package/dist/index.css +67 -7357
- package/dist/index.d.ts +0 -58
- package/dist/index.js +24 -12809
- package/dist/styles/animation.cjs +9 -0
- package/dist/styles/animation.js +7 -0
- package/dist/styles/themes/dbc/colors.css +5 -0
- package/dist/styles/themes/types.cjs +2 -0
- package/dist/styles/themes/types.js +1 -0
- package/dist/tanstack.cjs +18 -2717
- package/dist/tanstack.js +3 -2701
- package/dist/types/a11y-props.types.cjs +2 -0
- package/dist/types/a11y-props.types.js +1 -0
- package/dist/types/assets.d.cjs +2 -0
- package/dist/types/assets.d.js +1 -0
- package/dist/types/css.d.cjs +2 -0
- package/dist/types/css.d.js +1 -0
- package/dist/types/sizes.types.cjs +2 -0
- package/dist/types/sizes.types.js +1 -0
- package/dist/utils/arrays/nested-filtering.cjs +40 -0
- package/dist/utils/arrays/nested-filtering.js +38 -0
- package/dist/utils/date/formatDate.cjs +35 -0
- package/dist/utils/date/formatDate.js +33 -0
- package/dist/utils/localStorage.utils.cjs +53 -0
- package/dist/utils/localStorage.utils.js +49 -0
- package/dist/utils/text/get-highlighted-segments.cjs +49 -0
- package/dist/utils/text/get-highlighted-segments.js +47 -0
- package/package.json +8 -3
- package/dist/tanstack.css +0 -1385
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const normalize = (s) => s.normalize("NFKC").toLowerCase().trim();
|
|
4
|
+
const toTerms = (q) => (Array.isArray(q) ? q : q.split(/\s+/)).map(normalize).filter(Boolean);
|
|
5
|
+
const valueToSearchable = (value) => typeof value === "string" ? value : Array.isArray(value) || typeof value === "object" ? JSON.stringify(value) : value == null ? "" : String(value);
|
|
6
|
+
const itemMatches = (item, keys, terms, mode) => {
|
|
7
|
+
if (terms.length === 0) return true;
|
|
8
|
+
const haystack = keys.map((k) => valueToSearchable(item[k])).join(" ").toString();
|
|
9
|
+
const h = normalize(haystack);
|
|
10
|
+
const hit = (t) => h.includes(t);
|
|
11
|
+
return mode === "AND" ? terms.every(hit) : terms.some(hit);
|
|
12
|
+
};
|
|
13
|
+
function nestedFiltering(items, opts) {
|
|
14
|
+
const { keys, query, includeParents = true, childrenKey, mode = "AND" } = opts;
|
|
15
|
+
const ck = childrenKey != null ? childrenKey : "children";
|
|
16
|
+
const terms = toTerms(query);
|
|
17
|
+
const searchNested = (list) => {
|
|
18
|
+
const out = [];
|
|
19
|
+
for (const item of list) {
|
|
20
|
+
const children = item[ck] || [];
|
|
21
|
+
const filteredChildren = searchNested(children);
|
|
22
|
+
const matchedSelf = itemMatches(item, keys, terms, mode);
|
|
23
|
+
if (matchedSelf) {
|
|
24
|
+
const clone = { ...item, [ck]: filteredChildren };
|
|
25
|
+
out.push(clone);
|
|
26
|
+
} else if (filteredChildren.length) {
|
|
27
|
+
if (includeParents) {
|
|
28
|
+
const clone = { ...item, [ck]: filteredChildren };
|
|
29
|
+
out.push(clone);
|
|
30
|
+
} else {
|
|
31
|
+
out.push(...filteredChildren);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
};
|
|
37
|
+
return searchNested(items);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
exports.nestedFiltering = nestedFiltering;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const normalize = (s) => s.normalize("NFKC").toLowerCase().trim();
|
|
2
|
+
const toTerms = (q) => (Array.isArray(q) ? q : q.split(/\s+/)).map(normalize).filter(Boolean);
|
|
3
|
+
const valueToSearchable = (value) => typeof value === "string" ? value : Array.isArray(value) || typeof value === "object" ? JSON.stringify(value) : value == null ? "" : String(value);
|
|
4
|
+
const itemMatches = (item, keys, terms, mode) => {
|
|
5
|
+
if (terms.length === 0) return true;
|
|
6
|
+
const haystack = keys.map((k) => valueToSearchable(item[k])).join(" ").toString();
|
|
7
|
+
const h = normalize(haystack);
|
|
8
|
+
const hit = (t) => h.includes(t);
|
|
9
|
+
return mode === "AND" ? terms.every(hit) : terms.some(hit);
|
|
10
|
+
};
|
|
11
|
+
function nestedFiltering(items, opts) {
|
|
12
|
+
const { keys, query, includeParents = true, childrenKey, mode = "AND" } = opts;
|
|
13
|
+
const ck = childrenKey != null ? childrenKey : "children";
|
|
14
|
+
const terms = toTerms(query);
|
|
15
|
+
const searchNested = (list) => {
|
|
16
|
+
const out = [];
|
|
17
|
+
for (const item of list) {
|
|
18
|
+
const children = item[ck] || [];
|
|
19
|
+
const filteredChildren = searchNested(children);
|
|
20
|
+
const matchedSelf = itemMatches(item, keys, terms, mode);
|
|
21
|
+
if (matchedSelf) {
|
|
22
|
+
const clone = { ...item, [ck]: filteredChildren };
|
|
23
|
+
out.push(clone);
|
|
24
|
+
} else if (filteredChildren.length) {
|
|
25
|
+
if (includeParents) {
|
|
26
|
+
const clone = { ...item, [ck]: filteredChildren };
|
|
27
|
+
out.push(clone);
|
|
28
|
+
} else {
|
|
29
|
+
out.push(...filteredChildren);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
};
|
|
35
|
+
return searchNested(items);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { nestedFiltering };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function formatDate(date, options = {}) {
|
|
4
|
+
const d = date instanceof Date ? date : new Date(date);
|
|
5
|
+
if (isNaN(d.getTime())) return "";
|
|
6
|
+
const { showTime = false, showSeconds = false, userFriendlyLabel = false } = options;
|
|
7
|
+
const pad = (n) => n.toString().padStart(2, "0");
|
|
8
|
+
const formatTime = () => {
|
|
9
|
+
const hours = pad(d.getHours());
|
|
10
|
+
const minutes = pad(d.getMinutes());
|
|
11
|
+
if (!showSeconds) return `${hours}:${minutes}`;
|
|
12
|
+
const seconds = pad(d.getSeconds());
|
|
13
|
+
return `${hours}:${minutes}:${seconds}`;
|
|
14
|
+
};
|
|
15
|
+
const isSameCalendarDay = (a, b) => a.getDate() === b.getDate() && a.getMonth() === b.getMonth() && a.getFullYear() === b.getFullYear();
|
|
16
|
+
if (userFriendlyLabel) {
|
|
17
|
+
const now = /* @__PURE__ */ new Date();
|
|
18
|
+
const yesterday = new Date(now);
|
|
19
|
+
yesterday.setDate(now.getDate() - 1);
|
|
20
|
+
if (isSameCalendarDay(d, now)) {
|
|
21
|
+
return showTime ? `I dag, kl. ${formatTime()}` : "I dag";
|
|
22
|
+
}
|
|
23
|
+
if (isSameCalendarDay(d, yesterday)) {
|
|
24
|
+
return showTime ? `I g\xE5r, kl. ${formatTime()}` : "I g\xE5r";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const day = pad(d.getDate());
|
|
28
|
+
const month = pad(d.getMonth() + 1);
|
|
29
|
+
const year = d.getFullYear();
|
|
30
|
+
const base = `${day}.${month}.${year}`;
|
|
31
|
+
if (!showTime) return base;
|
|
32
|
+
return `${base} ${formatTime()}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.formatDate = formatDate;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function formatDate(date, options = {}) {
|
|
2
|
+
const d = date instanceof Date ? date : new Date(date);
|
|
3
|
+
if (isNaN(d.getTime())) return "";
|
|
4
|
+
const { showTime = false, showSeconds = false, userFriendlyLabel = false } = options;
|
|
5
|
+
const pad = (n) => n.toString().padStart(2, "0");
|
|
6
|
+
const formatTime = () => {
|
|
7
|
+
const hours = pad(d.getHours());
|
|
8
|
+
const minutes = pad(d.getMinutes());
|
|
9
|
+
if (!showSeconds) return `${hours}:${minutes}`;
|
|
10
|
+
const seconds = pad(d.getSeconds());
|
|
11
|
+
return `${hours}:${minutes}:${seconds}`;
|
|
12
|
+
};
|
|
13
|
+
const isSameCalendarDay = (a, b) => a.getDate() === b.getDate() && a.getMonth() === b.getMonth() && a.getFullYear() === b.getFullYear();
|
|
14
|
+
if (userFriendlyLabel) {
|
|
15
|
+
const now = /* @__PURE__ */ new Date();
|
|
16
|
+
const yesterday = new Date(now);
|
|
17
|
+
yesterday.setDate(now.getDate() - 1);
|
|
18
|
+
if (isSameCalendarDay(d, now)) {
|
|
19
|
+
return showTime ? `I dag, kl. ${formatTime()}` : "I dag";
|
|
20
|
+
}
|
|
21
|
+
if (isSameCalendarDay(d, yesterday)) {
|
|
22
|
+
return showTime ? `I g\xE5r, kl. ${formatTime()}` : "I g\xE5r";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const day = pad(d.getDate());
|
|
26
|
+
const month = pad(d.getMonth() + 1);
|
|
27
|
+
const year = d.getFullYear();
|
|
28
|
+
const base = `${day}.${month}.${year}`;
|
|
29
|
+
if (!showTime) return base;
|
|
30
|
+
return `${base} ${formatTime()}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { formatDate };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isBrowser() {
|
|
4
|
+
return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
|
|
5
|
+
}
|
|
6
|
+
function readLocalStorage(key) {
|
|
7
|
+
if (!isBrowser()) return void 0;
|
|
8
|
+
try {
|
|
9
|
+
const raw = window.localStorage.getItem(key);
|
|
10
|
+
if (raw == null) return void 0;
|
|
11
|
+
try {
|
|
12
|
+
const parsed = JSON.parse(raw);
|
|
13
|
+
if (typeof parsed === "string") {
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(parsed);
|
|
16
|
+
} catch {
|
|
17
|
+
return parsed;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return parsed;
|
|
21
|
+
} catch {
|
|
22
|
+
return raw;
|
|
23
|
+
}
|
|
24
|
+
} catch {
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function writeLocalStorage(key, value) {
|
|
29
|
+
if (!isBrowser()) return;
|
|
30
|
+
try {
|
|
31
|
+
if (value === void 0) {
|
|
32
|
+
window.localStorage.removeItem(key);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (typeof value === "string") {
|
|
36
|
+
window.localStorage.setItem(key, value);
|
|
37
|
+
} else {
|
|
38
|
+
window.localStorage.setItem(key, JSON.stringify(value));
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function removeLocalStorage(key) {
|
|
44
|
+
if (!isBrowser()) return;
|
|
45
|
+
try {
|
|
46
|
+
window.localStorage.removeItem(key);
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
exports.readLocalStorage = readLocalStorage;
|
|
52
|
+
exports.removeLocalStorage = removeLocalStorage;
|
|
53
|
+
exports.writeLocalStorage = writeLocalStorage;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
function isBrowser() {
|
|
2
|
+
return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
|
|
3
|
+
}
|
|
4
|
+
function readLocalStorage(key) {
|
|
5
|
+
if (!isBrowser()) return void 0;
|
|
6
|
+
try {
|
|
7
|
+
const raw = window.localStorage.getItem(key);
|
|
8
|
+
if (raw == null) return void 0;
|
|
9
|
+
try {
|
|
10
|
+
const parsed = JSON.parse(raw);
|
|
11
|
+
if (typeof parsed === "string") {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(parsed);
|
|
14
|
+
} catch {
|
|
15
|
+
return parsed;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return parsed;
|
|
19
|
+
} catch {
|
|
20
|
+
return raw;
|
|
21
|
+
}
|
|
22
|
+
} catch {
|
|
23
|
+
return void 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function writeLocalStorage(key, value) {
|
|
27
|
+
if (!isBrowser()) return;
|
|
28
|
+
try {
|
|
29
|
+
if (value === void 0) {
|
|
30
|
+
window.localStorage.removeItem(key);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (typeof value === "string") {
|
|
34
|
+
window.localStorage.setItem(key, value);
|
|
35
|
+
} else {
|
|
36
|
+
window.localStorage.setItem(key, JSON.stringify(value));
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function removeLocalStorage(key) {
|
|
42
|
+
if (!isBrowser()) return;
|
|
43
|
+
try {
|
|
44
|
+
window.localStorage.removeItem(key);
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { readLocalStorage, removeLocalStorage, writeLocalStorage };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function normalizeTerms(query) {
|
|
4
|
+
const terms = Array.isArray(query) ? query : [query];
|
|
5
|
+
return [...new Set(terms.map((term) => term.trim().toLowerCase()).filter(Boolean))].sort(
|
|
6
|
+
(a, b) => b.length - a.length
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
function getHighlightedSegments(text, query) {
|
|
10
|
+
const terms = normalizeTerms(query);
|
|
11
|
+
if (!text || terms.length === 0) return [{ text, matched: false }];
|
|
12
|
+
const lower = text.toLowerCase();
|
|
13
|
+
const ranges = [];
|
|
14
|
+
for (const term of terms) {
|
|
15
|
+
let startIndex = 0;
|
|
16
|
+
while (startIndex < lower.length) {
|
|
17
|
+
const matchIndex = lower.indexOf(term, startIndex);
|
|
18
|
+
if (matchIndex === -1) break;
|
|
19
|
+
ranges.push({ start: matchIndex, end: matchIndex + term.length });
|
|
20
|
+
startIndex = matchIndex + term.length;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (ranges.length === 0) return [{ text, matched: false }];
|
|
24
|
+
ranges.sort((a, b) => a.start - b.start || a.end - b.end);
|
|
25
|
+
const mergedRanges = [];
|
|
26
|
+
for (const range of ranges) {
|
|
27
|
+
const previous = mergedRanges[mergedRanges.length - 1];
|
|
28
|
+
if (!previous || range.start > previous.end) {
|
|
29
|
+
mergedRanges.push({ ...range });
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
previous.end = Math.max(previous.end, range.end);
|
|
33
|
+
}
|
|
34
|
+
const segments = [];
|
|
35
|
+
let cursor = 0;
|
|
36
|
+
for (const range of mergedRanges) {
|
|
37
|
+
if (range.start > cursor) {
|
|
38
|
+
segments.push({ text: text.slice(cursor, range.start), matched: false });
|
|
39
|
+
}
|
|
40
|
+
segments.push({ text: text.slice(range.start, range.end), matched: true });
|
|
41
|
+
cursor = range.end;
|
|
42
|
+
}
|
|
43
|
+
if (cursor < text.length) {
|
|
44
|
+
segments.push({ text: text.slice(cursor), matched: false });
|
|
45
|
+
}
|
|
46
|
+
return segments.length > 0 ? segments : [{ text, matched: false }];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
exports.getHighlightedSegments = getHighlightedSegments;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function normalizeTerms(query) {
|
|
2
|
+
const terms = Array.isArray(query) ? query : [query];
|
|
3
|
+
return [...new Set(terms.map((term) => term.trim().toLowerCase()).filter(Boolean))].sort(
|
|
4
|
+
(a, b) => b.length - a.length
|
|
5
|
+
);
|
|
6
|
+
}
|
|
7
|
+
function getHighlightedSegments(text, query) {
|
|
8
|
+
const terms = normalizeTerms(query);
|
|
9
|
+
if (!text || terms.length === 0) return [{ text, matched: false }];
|
|
10
|
+
const lower = text.toLowerCase();
|
|
11
|
+
const ranges = [];
|
|
12
|
+
for (const term of terms) {
|
|
13
|
+
let startIndex = 0;
|
|
14
|
+
while (startIndex < lower.length) {
|
|
15
|
+
const matchIndex = lower.indexOf(term, startIndex);
|
|
16
|
+
if (matchIndex === -1) break;
|
|
17
|
+
ranges.push({ start: matchIndex, end: matchIndex + term.length });
|
|
18
|
+
startIndex = matchIndex + term.length;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (ranges.length === 0) return [{ text, matched: false }];
|
|
22
|
+
ranges.sort((a, b) => a.start - b.start || a.end - b.end);
|
|
23
|
+
const mergedRanges = [];
|
|
24
|
+
for (const range of ranges) {
|
|
25
|
+
const previous = mergedRanges[mergedRanges.length - 1];
|
|
26
|
+
if (!previous || range.start > previous.end) {
|
|
27
|
+
mergedRanges.push({ ...range });
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
previous.end = Math.max(previous.end, range.end);
|
|
31
|
+
}
|
|
32
|
+
const segments = [];
|
|
33
|
+
let cursor = 0;
|
|
34
|
+
for (const range of mergedRanges) {
|
|
35
|
+
if (range.start > cursor) {
|
|
36
|
+
segments.push({ text: text.slice(cursor, range.start), matched: false });
|
|
37
|
+
}
|
|
38
|
+
segments.push({ text: text.slice(range.start, range.end), matched: true });
|
|
39
|
+
cursor = range.end;
|
|
40
|
+
}
|
|
41
|
+
if (cursor < text.length) {
|
|
42
|
+
segments.push({ text: text.slice(cursor), matched: false });
|
|
43
|
+
}
|
|
44
|
+
return segments.length > 0 ? segments : [{ text, matched: false }];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { getHighlightedSegments };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbcdk/react-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.104",
|
|
4
4
|
"description": "Reusable React components for DBC projects",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -24,6 +24,12 @@
|
|
|
24
24
|
"require": "./dist/index.cjs",
|
|
25
25
|
"default": "./dist/index.js"
|
|
26
26
|
},
|
|
27
|
+
"./client": {
|
|
28
|
+
"types": "./dist/client.d.ts",
|
|
29
|
+
"import": "./dist/client.js",
|
|
30
|
+
"require": "./dist/client.cjs",
|
|
31
|
+
"default": "./dist/client.js"
|
|
32
|
+
},
|
|
27
33
|
"./themes/*": "./dist/themes/*",
|
|
28
34
|
"./styles/themes/*": "./dist/styles/themes/*",
|
|
29
35
|
"./styles.css": "./dist/styles/styles.css",
|
|
@@ -48,8 +54,7 @@
|
|
|
48
54
|
"rewrite:paths": "tsc-alias -p tsconfig.build.json",
|
|
49
55
|
"dev": "tsup --config tsup.config.ts --watch",
|
|
50
56
|
"test": "vitest run",
|
|
51
|
-
"
|
|
52
|
-
"format:fix": "prettier . --write",
|
|
57
|
+
"prettier": "prettier . --write",
|
|
53
58
|
"lint": "eslint \"src/**/*.{ts,tsx}\" --max-warnings=0",
|
|
54
59
|
"lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix",
|
|
55
60
|
"storybook": "storybook dev -p 6006 --no-open",
|