@flipdish/ui-library 0.69.0 → 0.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/components/__internal__/controlFill/controlFill.context.cjs +13 -0
- package/dist/components/__internal__/controlFill/controlFill.context.cjs.map +1 -0
- package/dist/components/__internal__/controlFill/controlFill.context.d.ts +7 -0
- package/dist/components/__internal__/controlFill/controlFill.context.d.ts.map +1 -0
- package/dist/components/__internal__/controlFill/controlFill.context.js +11 -0
- package/dist/components/__internal__/controlFill/controlFill.context.js.map +1 -0
- package/dist/components/__internal__/focusHandOff/focusHandOff.context.cjs +13 -0
- package/dist/components/__internal__/focusHandOff/focusHandOff.context.cjs.map +1 -0
- package/dist/components/__internal__/focusHandOff/focusHandOff.context.d.ts +8 -0
- package/dist/components/__internal__/focusHandOff/focusHandOff.context.d.ts.map +1 -0
- package/dist/components/__internal__/focusHandOff/focusHandOff.context.js +11 -0
- package/dist/components/__internal__/focusHandOff/focusHandOff.context.js.map +1 -0
- package/dist/components/atoms/Buttons/Button/hooks/useLoadingLinkPress.d.ts +1 -1
- package/dist/components/atoms/Buttons/IconButton/IconButton.cjs +1 -1
- package/dist/components/atoms/Buttons/IconButton/IconButton.cjs.map +1 -1
- package/dist/components/atoms/Buttons/IconButton/IconButton.d.ts.map +1 -1
- package/dist/components/atoms/Buttons/IconButton/IconButton.js +1 -1
- package/dist/components/atoms/Buttons/IconButton/IconButton.js.map +1 -1
- package/dist/components/atoms/LiveStatus/index.cjs +18 -0
- package/dist/components/atoms/LiveStatus/index.cjs.map +1 -0
- package/dist/components/atoms/LiveStatus/index.d.ts +17 -0
- package/dist/components/atoms/LiveStatus/index.d.ts.map +1 -0
- package/dist/components/atoms/LiveStatus/index.js +16 -0
- package/dist/components/atoms/LiveStatus/index.js.map +1 -0
- package/dist/components/forms/Form/index.cjs +1 -1
- package/dist/components/forms/Form/index.js +1 -1
- package/dist/components/molecules/Dropdown/index.d.ts +2 -2
- package/dist/components/molecules/EmptyState/index.cjs +9 -1
- package/dist/components/molecules/EmptyState/index.cjs.map +1 -1
- package/dist/components/molecules/EmptyState/index.d.ts.map +1 -1
- package/dist/components/molecules/EmptyState/index.js +11 -3
- package/dist/components/molecules/EmptyState/index.js.map +1 -1
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.cjs +13 -0
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.cjs.map +1 -1
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.d.ts +8 -0
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.d.ts.map +1 -1
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.js +13 -1
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.js.map +1 -1
- package/dist/components/molecules/Modals/Modal/Modal.cjs +6 -5
- package/dist/components/molecules/Modals/Modal/Modal.cjs.map +1 -1
- package/dist/components/molecules/Modals/Modal/Modal.d.ts.map +1 -1
- package/dist/components/molecules/Modals/Modal/Modal.js +6 -5
- package/dist/components/molecules/Modals/Modal/Modal.js.map +1 -1
- package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.cjs +1 -1
- package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.d.ts +1 -1
- package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.d.ts.map +1 -1
- package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.js +1 -1
- package/dist/components/molecules/Tags/TagGroup/TagGroup.d.ts +1 -1
- package/dist/components/molecules/Tags/TagGroup/TagGroup.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs +4 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js +5 -2
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/organisms/FilterBar/components/FilterDropdownMenu.cjs +11 -6
- package/dist/components/organisms/FilterBar/components/FilterDropdownMenu.cjs.map +1 -1
- package/dist/components/organisms/FilterBar/components/FilterDropdownMenu.d.ts +4 -2
- package/dist/components/organisms/FilterBar/components/FilterDropdownMenu.d.ts.map +1 -1
- package/dist/components/organisms/FilterBar/components/FilterDropdownMenu.js +12 -7
- package/dist/components/organisms/FilterBar/components/FilterDropdownMenu.js.map +1 -1
- package/dist/components/organisms/FilterBar/hooks/useFilterDraft.cjs +53 -0
- package/dist/components/organisms/FilterBar/hooks/useFilterDraft.cjs.map +1 -0
- package/dist/components/organisms/FilterBar/hooks/useFilterDraft.d.ts +41 -0
- package/dist/components/organisms/FilterBar/hooks/useFilterDraft.d.ts.map +1 -0
- package/dist/components/organisms/FilterBar/hooks/useFilterDraft.js +51 -0
- package/dist/components/organisms/FilterBar/hooks/useFilterDraft.js.map +1 -0
- package/dist/components/organisms/FilterBar/index.cjs +19 -7
- package/dist/components/organisms/FilterBar/index.cjs.map +1 -1
- package/dist/components/organisms/FilterBar/index.d.ts +1 -0
- package/dist/components/organisms/FilterBar/index.d.ts.map +1 -1
- package/dist/components/organisms/FilterBar/index.js +18 -7
- package/dist/components/organisms/FilterBar/index.js.map +1 -1
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.cjs +2 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.cjs.map +1 -1
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.d.ts +10 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.d.ts.map +1 -1
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.js +2 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.js.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.cjs +3 -1
- package/dist/components/organisms/SlideoutMenu/index.cjs.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.d.ts.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.js +3 -1
- package/dist/components/organisms/SlideoutMenu/index.js.map +1 -1
- package/dist/components/organisms/Table/index.cjs +14 -244
- package/dist/components/organisms/Table/index.cjs.map +1 -1
- package/dist/components/organisms/Table/index.d.ts +29 -124
- package/dist/components/organisms/Table/index.d.ts.map +1 -1
- package/dist/components/organisms/Table/index.js +13 -243
- package/dist/components/organisms/Table/index.js.map +1 -1
- package/dist/components/organisms/Tables/Table/Table.cjs +305 -0
- package/dist/components/organisms/Tables/Table/Table.cjs.map +1 -0
- package/dist/components/organisms/Tables/Table/Table.d.ts +146 -0
- package/dist/components/organisms/Tables/Table/Table.d.ts.map +1 -0
- package/dist/components/organisms/Tables/Table/Table.js +301 -0
- package/dist/components/organisms/Tables/Table/Table.js.map +1 -0
- package/dist/components/organisms/Tables/Table/Table.styles.cjs +29 -0
- package/dist/components/organisms/Tables/Table/Table.styles.cjs.map +1 -0
- package/dist/components/organisms/Tables/Table/Table.styles.d.ts +16 -0
- package/dist/components/organisms/Tables/Table/Table.styles.d.ts.map +1 -0
- package/dist/components/organisms/Tables/Table/Table.styles.js +27 -0
- package/dist/components/organisms/Tables/Table/Table.styles.js.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/components/TableCardList.cjs +2 -2
- package/dist/components/organisms/Tables/Table/components/TableCardList.cjs.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/components/TableCardList.d.ts +1 -1
- package/dist/components/organisms/Tables/Table/components/TableCardList.d.ts.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/components/TableCardList.js +2 -2
- package/dist/components/organisms/Tables/Table/components/TableCardList.js.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/components/TableCardRow.cjs +10 -5
- package/dist/components/organisms/Tables/Table/components/TableCardRow.cjs.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/components/TableCardRow.d.ts +1 -1
- package/dist/components/organisms/Tables/Table/components/TableCardRow.d.ts.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/components/TableCardRow.js +11 -6
- package/dist/components/organisms/Tables/Table/components/TableCardRow.js.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/components/TableCardsSelectAll.cjs +2 -2
- package/dist/components/organisms/Tables/Table/components/TableCardsSelectAll.cjs.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/components/TableCardsSelectAll.d.ts +3 -1
- package/dist/components/organisms/Tables/Table/components/TableCardsSelectAll.d.ts.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/components/TableCardsSelectAll.js +2 -2
- package/dist/components/organisms/Tables/Table/components/TableCardsSelectAll.js.map +1 -0
- package/dist/components/organisms/Tables/Table/components/TableEmptyState.cjs +17 -0
- package/dist/components/organisms/Tables/Table/components/TableEmptyState.cjs.map +1 -0
- package/dist/components/organisms/Tables/Table/components/TableEmptyState.d.ts +5 -0
- package/dist/components/organisms/Tables/Table/components/TableEmptyState.d.ts.map +1 -0
- package/dist/components/organisms/Tables/Table/components/TableEmptyState.js +15 -0
- package/dist/components/organisms/Tables/Table/components/TableEmptyState.js.map +1 -0
- package/dist/components/organisms/Tables/Table/components/TableFallbackCard.cjs.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/components/TableFallbackCard.d.ts +1 -1
- package/dist/components/organisms/Tables/Table/components/TableFallbackCard.d.ts.map +1 -0
- package/dist/components/organisms/Tables/Table/components/TableFallbackCard.js.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/components/TableRowCard.cjs +6 -5
- package/dist/components/organisms/Tables/Table/components/TableRowCard.cjs.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/components/TableRowCard.d.ts +1 -1
- package/dist/components/organisms/Tables/Table/components/TableRowCard.d.ts.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/components/TableRowCard.js +6 -5
- package/dist/components/organisms/Tables/Table/components/TableRowCard.js.map +1 -0
- package/dist/components/organisms/Tables/Table/components/TableSortIcon.cjs.map +1 -0
- package/dist/components/organisms/Tables/Table/components/TableSortIcon.d.ts.map +1 -0
- package/dist/components/organisms/Tables/Table/components/TableSortIcon.js.map +1 -0
- package/dist/components/organisms/Tables/Table/hooks/useBusyCount.cjs +22 -0
- package/dist/components/organisms/Tables/Table/hooks/useBusyCount.cjs.map +1 -0
- package/dist/components/organisms/Tables/Table/hooks/useBusyCount.d.ts +12 -0
- package/dist/components/organisms/Tables/Table/hooks/useBusyCount.d.ts.map +1 -0
- package/dist/components/organisms/Tables/Table/hooks/useBusyCount.js +20 -0
- package/dist/components/organisms/Tables/Table/hooks/useBusyCount.js.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/hooks/useFirstSortDirection.cjs +1 -1
- package/dist/components/organisms/Tables/Table/hooks/useFirstSortDirection.cjs.map +1 -0
- package/dist/components/organisms/Tables/Table/hooks/useFirstSortDirection.d.ts.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/hooks/useFirstSortDirection.js +1 -1
- package/dist/components/organisms/Tables/Table/hooks/useFirstSortDirection.js.map +1 -0
- package/dist/components/organisms/Tables/Table/hooks/useIsPlaceholderPage.cjs +42 -0
- package/dist/components/organisms/Tables/Table/hooks/useIsPlaceholderPage.cjs.map +1 -0
- package/dist/components/organisms/Tables/Table/hooks/useIsPlaceholderPage.d.ts +14 -0
- package/dist/components/organisms/Tables/Table/hooks/useIsPlaceholderPage.d.ts.map +1 -0
- package/dist/components/organisms/Tables/Table/hooks/useIsPlaceholderPage.js +40 -0
- package/dist/components/organisms/Tables/Table/hooks/useIsPlaceholderPage.js.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/hooks/usePlaceholderRows.cjs +8 -11
- package/dist/components/organisms/Tables/Table/hooks/usePlaceholderRows.cjs.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/hooks/usePlaceholderRows.d.ts +10 -3
- package/dist/components/organisms/Tables/Table/hooks/usePlaceholderRows.d.ts.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/hooks/usePlaceholderRows.js +9 -12
- package/dist/components/organisms/Tables/Table/hooks/usePlaceholderRows.js.map +1 -0
- package/dist/components/organisms/Tables/Table/hooks/useSelectableRowRegistry.cjs.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/hooks/useSelectableRowRegistry.d.ts +1 -1
- package/dist/components/organisms/Tables/Table/hooks/useSelectableRowRegistry.d.ts.map +1 -0
- package/dist/components/organisms/Tables/Table/hooks/useSelectableRowRegistry.js.map +1 -0
- package/dist/components/organisms/Tables/Table/hooks/useTableFocusHandOff.cjs +83 -0
- package/dist/components/organisms/Tables/Table/hooks/useTableFocusHandOff.cjs.map +1 -0
- package/dist/components/organisms/Tables/Table/hooks/useTableFocusHandOff.d.ts +23 -0
- package/dist/components/organisms/Tables/Table/hooks/useTableFocusHandOff.d.ts.map +1 -0
- package/dist/components/organisms/Tables/Table/hooks/useTableFocusHandOff.js +81 -0
- package/dist/components/organisms/Tables/Table/hooks/useTableFocusHandOff.js.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/hooks/useTableSelection.cjs +12 -4
- package/dist/components/organisms/Tables/Table/hooks/useTableSelection.cjs.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/hooks/useTableSelection.d.ts +5 -3
- package/dist/components/organisms/Tables/Table/hooks/useTableSelection.d.ts.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/hooks/useTableSelection.js +12 -4
- package/dist/components/organisms/Tables/Table/hooks/useTableSelection.js.map +1 -0
- package/dist/components/organisms/Tables/Table/providers/Table.context.cjs.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/providers/Table.context.d.ts +14 -2
- package/dist/components/organisms/Tables/Table/providers/Table.context.d.ts.map +1 -0
- package/dist/components/organisms/Tables/Table/providers/Table.context.js.map +1 -0
- package/dist/components/organisms/Tables/Table/utilities/tableFocusHandOff.utils.cjs +55 -0
- package/dist/components/organisms/Tables/Table/utilities/tableFocusHandOff.utils.cjs.map +1 -0
- package/dist/components/organisms/Tables/Table/utilities/tableFocusHandOff.utils.d.ts +25 -0
- package/dist/components/organisms/Tables/Table/utilities/tableFocusHandOff.utils.d.ts.map +1 -0
- package/dist/components/organisms/Tables/Table/utilities/tableFocusHandOff.utils.js +51 -0
- package/dist/components/organisms/Tables/Table/utilities/tableFocusHandOff.utils.js.map +1 -0
- package/dist/components/organisms/Tables/Table/utilities/tableLoading.utils.cjs +57 -0
- package/dist/components/organisms/Tables/Table/utilities/tableLoading.utils.cjs.map +1 -0
- package/dist/components/organisms/Tables/Table/utilities/tableLoading.utils.d.ts +66 -0
- package/dist/components/organisms/Tables/Table/utilities/tableLoading.utils.d.ts.map +1 -0
- package/dist/components/organisms/Tables/Table/utilities/tableLoading.utils.js +52 -0
- package/dist/components/organisms/Tables/Table/utilities/tableLoading.utils.js.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/utilities/tableSelection.utils.cjs +21 -21
- package/dist/components/organisms/Tables/Table/utilities/tableSelection.utils.cjs.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/utilities/tableSelection.utils.d.ts +29 -19
- package/dist/components/organisms/Tables/Table/utilities/tableSelection.utils.d.ts.map +1 -0
- package/dist/components/organisms/{Table → Tables/Table}/utilities/tableSelection.utils.js +20 -21
- package/dist/components/organisms/Tables/Table/utilities/tableSelection.utils.js.map +1 -0
- package/dist/components/organisms/Tables/TableLayoutToggle/TableLayoutToggle.cjs +34 -0
- package/dist/components/organisms/Tables/TableLayoutToggle/TableLayoutToggle.cjs.map +1 -0
- package/dist/components/organisms/Tables/TableLayoutToggle/TableLayoutToggle.d.ts +37 -0
- package/dist/components/organisms/Tables/TableLayoutToggle/TableLayoutToggle.d.ts.map +1 -0
- package/dist/components/organisms/Tables/TableLayoutToggle/TableLayoutToggle.js +32 -0
- package/dist/components/organisms/Tables/TableLayoutToggle/TableLayoutToggle.js.map +1 -0
- package/dist/components/organisms/Tables/TableLayoutToggle/hooks/useTableLayoutToggle.cjs +32 -0
- package/dist/components/organisms/Tables/TableLayoutToggle/hooks/useTableLayoutToggle.cjs.map +1 -0
- package/dist/components/organisms/Tables/TableLayoutToggle/hooks/useTableLayoutToggle.d.ts +21 -0
- package/dist/components/organisms/Tables/TableLayoutToggle/hooks/useTableLayoutToggle.d.ts.map +1 -0
- package/dist/components/organisms/Tables/TableLayoutToggle/hooks/useTableLayoutToggle.js +30 -0
- package/dist/components/organisms/Tables/TableLayoutToggle/hooks/useTableLayoutToggle.js.map +1 -0
- package/dist/components/organisms/{Table/components → Tables/TableSortMenu}/TableSortMenu.cjs +12 -5
- package/dist/components/organisms/Tables/TableSortMenu/TableSortMenu.cjs.map +1 -0
- package/dist/components/organisms/Tables/TableSortMenu/TableSortMenu.d.ts +47 -0
- package/dist/components/organisms/Tables/TableSortMenu/TableSortMenu.d.ts.map +1 -0
- package/dist/components/organisms/{Table/components → Tables/TableSortMenu}/TableSortMenu.js +12 -5
- package/dist/components/organisms/Tables/TableSortMenu/TableSortMenu.js.map +1 -0
- package/dist/components/organisms/Tables/hooks/useIsAtLeastMd.cjs.map +1 -0
- package/dist/components/organisms/Tables/hooks/useIsAtLeastMd.d.ts.map +1 -0
- package/dist/components/organisms/Tables/hooks/useIsAtLeastMd.js.map +1 -0
- package/dist/components/organisms/Tables/hooks/useStoredTableLayout.cjs +84 -0
- package/dist/components/organisms/Tables/hooks/useStoredTableLayout.cjs.map +1 -0
- package/dist/components/organisms/Tables/hooks/useStoredTableLayout.d.ts +20 -0
- package/dist/components/organisms/Tables/hooks/useStoredTableLayout.d.ts.map +1 -0
- package/dist/components/organisms/Tables/hooks/useStoredTableLayout.js +81 -0
- package/dist/components/organisms/Tables/hooks/useStoredTableLayout.js.map +1 -0
- package/dist/components/organisms/Tables/index.cjs +14 -0
- package/dist/components/organisms/Tables/index.cjs.map +1 -0
- package/dist/components/organisms/Tables/index.d.ts +19 -0
- package/dist/components/organisms/Tables/index.d.ts.map +1 -0
- package/dist/components/organisms/Tables/index.js +4 -0
- package/dist/components/organisms/Tables/index.js.map +1 -0
- package/dist/components/organisms/{Table/table.types.d.ts → Tables/tables.types.d.ts} +12 -2
- package/dist/components/organisms/Tables/tables.types.d.ts.map +1 -0
- package/dist/components/organisms/Tables/utilities/tableCard.utils.cjs.map +1 -0
- package/dist/components/organisms/{Table → Tables}/utilities/tableCard.utils.d.ts +2 -2
- package/dist/components/organisms/Tables/utilities/tableCard.utils.d.ts.map +1 -0
- package/dist/components/organisms/Tables/utilities/tableCard.utils.js.map +1 -0
- package/dist/components/organisms/{Table → Tables}/utilities/tableChildren.utils.cjs +7 -4
- package/dist/components/organisms/Tables/utilities/tableChildren.utils.cjs.map +1 -0
- package/dist/components/organisms/{Table → Tables}/utilities/tableChildren.utils.d.ts +5 -3
- package/dist/components/organisms/Tables/utilities/tableChildren.utils.d.ts.map +1 -0
- package/dist/components/organisms/{Table → Tables}/utilities/tableChildren.utils.js +7 -4
- package/dist/components/organisms/Tables/utilities/tableChildren.utils.js.map +1 -0
- package/dist/components/organisms/Tables/utilities/tableIterable.utils.cjs +23 -0
- package/dist/components/organisms/Tables/utilities/tableIterable.utils.cjs.map +1 -0
- package/dist/components/organisms/Tables/utilities/tableIterable.utils.d.ts +8 -0
- package/dist/components/organisms/Tables/utilities/tableIterable.utils.d.ts.map +1 -0
- package/dist/components/organisms/Tables/utilities/tableIterable.utils.js +21 -0
- package/dist/components/organisms/Tables/utilities/tableIterable.utils.js.map +1 -0
- package/dist/components/organisms/{Table → Tables}/utilities/tableSort.utils.cjs +1 -1
- package/dist/components/organisms/Tables/utilities/tableSort.utils.cjs.map +1 -0
- package/dist/components/organisms/{Table → Tables}/utilities/tableSort.utils.d.ts +1 -1
- package/dist/components/organisms/Tables/utilities/tableSort.utils.d.ts.map +1 -0
- package/dist/components/organisms/{Table → Tables}/utilities/tableSort.utils.js +1 -1
- package/dist/components/organisms/Tables/utilities/tableSort.utils.js.map +1 -0
- package/dist/hooks/useFocusAfterRetry/index.cjs +21 -19
- package/dist/hooks/useFocusAfterRetry/index.cjs.map +1 -1
- package/dist/hooks/useFocusAfterRetry/index.d.ts +15 -5
- package/dist/hooks/useFocusAfterRetry/index.d.ts.map +1 -1
- package/dist/hooks/useFocusAfterRetry/index.js +21 -19
- package/dist/hooks/useFocusAfterRetry/index.js.map +1 -1
- package/dist/hooks/useFocusHandOff/index.cjs +67 -0
- package/dist/hooks/useFocusHandOff/index.cjs.map +1 -0
- package/dist/hooks/useFocusHandOff/index.d.ts +17 -0
- package/dist/hooks/useFocusHandOff/index.d.ts.map +1 -0
- package/dist/hooks/useFocusHandOff/index.js +65 -0
- package/dist/hooks/useFocusHandOff/index.js.map +1 -0
- package/dist/hooks/useListQueryParams/index.cjs +238 -0
- package/dist/hooks/useListQueryParams/index.cjs.map +1 -0
- package/dist/hooks/useListQueryParams/index.d.ts +77 -0
- package/dist/hooks/useListQueryParams/index.d.ts.map +1 -0
- package/dist/hooks/useListQueryParams/index.js +236 -0
- package/dist/hooks/useListQueryParams/index.js.map +1 -0
- package/dist/hooks/useLoadState/index.cjs +69 -0
- package/dist/hooks/useLoadState/index.cjs.map +1 -0
- package/dist/hooks/useLoadState/index.d.ts +44 -0
- package/dist/hooks/useLoadState/index.d.ts.map +1 -0
- package/dist/hooks/useLoadState/index.js +67 -0
- package/dist/hooks/useLoadState/index.js.map +1 -0
- package/dist/hooks/usePagedList/index.cjs +61 -0
- package/dist/hooks/usePagedList/index.cjs.map +1 -0
- package/dist/hooks/usePagedList/index.d.ts +56 -0
- package/dist/hooks/usePagedList/index.d.ts.map +1 -0
- package/dist/hooks/usePagedList/index.js +59 -0
- package/dist/hooks/usePagedList/index.js.map +1 -0
- package/dist/native/components/atoms/LiveStatus/index.d.ts +12 -0
- package/dist/native/components/organisms/Tables/index.d.ts +12 -0
- package/dist/native/hooks/useFocusHandOff/index.d.ts +12 -0
- package/dist/native/hooks/useListQueryParams/index.d.ts +12 -0
- package/dist/native/hooks/useLoadState/index.d.ts +12 -0
- package/dist/native/hooks/usePagedList/index.d.ts +12 -0
- package/dist/native/utilities/listQueryUtils/index.d.ts +12 -0
- package/dist/styles.css +12 -0
- package/dist/{components/forms/Form/utilities → utilities/__internal__/focusUtils}/focusFromCode.utils.cjs +9 -0
- package/dist/utilities/__internal__/focusUtils/focusFromCode.utils.cjs.map +1 -0
- package/dist/{components/forms/Form/utilities → utilities/__internal__/focusUtils}/focusFromCode.utils.d.ts +8 -0
- package/dist/utilities/__internal__/focusUtils/focusFromCode.utils.d.ts.map +1 -0
- package/dist/{components/forms/Form/utilities → utilities/__internal__/focusUtils}/focusFromCode.utils.js +9 -1
- package/dist/utilities/__internal__/focusUtils/focusFromCode.utils.js.map +1 -0
- package/dist/utilities/__internal__/listStateUtils/listState.utils.cjs +47 -0
- package/dist/utilities/__internal__/listStateUtils/listState.utils.cjs.map +1 -0
- package/dist/utilities/__internal__/listStateUtils/listState.utils.d.ts +51 -0
- package/dist/utilities/__internal__/listStateUtils/listState.utils.d.ts.map +1 -0
- package/dist/utilities/__internal__/listStateUtils/listState.utils.js +43 -0
- package/dist/utilities/__internal__/listStateUtils/listState.utils.js.map +1 -0
- package/dist/utilities/__internal__/stableKeyUtils/stableKey.utils.cjs +67 -0
- package/dist/utilities/__internal__/stableKeyUtils/stableKey.utils.cjs.map +1 -0
- package/dist/utilities/__internal__/stableKeyUtils/stableKey.utils.d.ts +27 -0
- package/dist/utilities/__internal__/stableKeyUtils/stableKey.utils.d.ts.map +1 -0
- package/dist/utilities/__internal__/stableKeyUtils/stableKey.utils.js +64 -0
- package/dist/utilities/__internal__/stableKeyUtils/stableKey.utils.js.map +1 -0
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.cjs +28 -0
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.cjs.map +1 -1
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.d.ts +10 -0
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.d.ts.map +1 -1
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.js +28 -1
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.js.map +1 -1
- package/dist/utilities/listQueryUtils/index.cjs +59 -0
- package/dist/utilities/listQueryUtils/index.cjs.map +1 -0
- package/dist/utilities/listQueryUtils/index.d.ts +46 -0
- package/dist/utilities/listQueryUtils/index.d.ts.map +1 -0
- package/dist/utilities/listQueryUtils/index.js +55 -0
- package/dist/utilities/listQueryUtils/index.js.map +1 -0
- package/dist/utilities/localStorageUtils/localStorageUtils.constants.cjs +2 -0
- package/dist/utilities/localStorageUtils/localStorageUtils.constants.cjs.map +1 -1
- package/dist/utilities/localStorageUtils/localStorageUtils.constants.d.ts +2 -0
- package/dist/utilities/localStorageUtils/localStorageUtils.constants.d.ts.map +1 -1
- package/dist/utilities/localStorageUtils/localStorageUtils.constants.js +2 -0
- package/dist/utilities/localStorageUtils/localStorageUtils.constants.js.map +1 -1
- package/package.json +9 -9
- package/dist/components/forms/Form/utilities/focusFromCode.utils.cjs.map +0 -1
- package/dist/components/forms/Form/utilities/focusFromCode.utils.d.ts.map +0 -1
- package/dist/components/forms/Form/utilities/focusFromCode.utils.js.map +0 -1
- package/dist/components/organisms/Table/components/TableCardList.cjs.map +0 -1
- package/dist/components/organisms/Table/components/TableCardList.d.ts.map +0 -1
- package/dist/components/organisms/Table/components/TableCardList.js.map +0 -1
- package/dist/components/organisms/Table/components/TableCardRow.cjs.map +0 -1
- package/dist/components/organisms/Table/components/TableCardRow.d.ts.map +0 -1
- package/dist/components/organisms/Table/components/TableCardRow.js.map +0 -1
- package/dist/components/organisms/Table/components/TableCardsSelectAll.cjs.map +0 -1
- package/dist/components/organisms/Table/components/TableCardsSelectAll.d.ts.map +0 -1
- package/dist/components/organisms/Table/components/TableCardsSelectAll.js.map +0 -1
- package/dist/components/organisms/Table/components/TableFallbackCard.cjs.map +0 -1
- package/dist/components/organisms/Table/components/TableFallbackCard.d.ts.map +0 -1
- package/dist/components/organisms/Table/components/TableFallbackCard.js.map +0 -1
- package/dist/components/organisms/Table/components/TableFocusGuard.cjs +0 -23
- package/dist/components/organisms/Table/components/TableFocusGuard.cjs.map +0 -1
- package/dist/components/organisms/Table/components/TableFocusGuard.d.ts +0 -2
- package/dist/components/organisms/Table/components/TableFocusGuard.d.ts.map +0 -1
- package/dist/components/organisms/Table/components/TableFocusGuard.js +0 -21
- package/dist/components/organisms/Table/components/TableFocusGuard.js.map +0 -1
- package/dist/components/organisms/Table/components/TableLayoutToggle.cjs +0 -27
- package/dist/components/organisms/Table/components/TableLayoutToggle.cjs.map +0 -1
- package/dist/components/organisms/Table/components/TableLayoutToggle.d.ts +0 -17
- package/dist/components/organisms/Table/components/TableLayoutToggle.d.ts.map +0 -1
- package/dist/components/organisms/Table/components/TableLayoutToggle.js +0 -25
- package/dist/components/organisms/Table/components/TableLayoutToggle.js.map +0 -1
- package/dist/components/organisms/Table/components/TableRowCard.cjs.map +0 -1
- package/dist/components/organisms/Table/components/TableRowCard.d.ts.map +0 -1
- package/dist/components/organisms/Table/components/TableRowCard.js.map +0 -1
- package/dist/components/organisms/Table/components/TableSortIcon.cjs.map +0 -1
- package/dist/components/organisms/Table/components/TableSortIcon.d.ts.map +0 -1
- package/dist/components/organisms/Table/components/TableSortIcon.js.map +0 -1
- package/dist/components/organisms/Table/components/TableSortMenu.cjs.map +0 -1
- package/dist/components/organisms/Table/components/TableSortMenu.d.ts +0 -35
- package/dist/components/organisms/Table/components/TableSortMenu.d.ts.map +0 -1
- package/dist/components/organisms/Table/components/TableSortMenu.js.map +0 -1
- package/dist/components/organisms/Table/hooks/useFirstSortDirection.cjs.map +0 -1
- package/dist/components/organisms/Table/hooks/useFirstSortDirection.d.ts.map +0 -1
- package/dist/components/organisms/Table/hooks/useFirstSortDirection.js.map +0 -1
- package/dist/components/organisms/Table/hooks/useIsAtLeastMd.cjs.map +0 -1
- package/dist/components/organisms/Table/hooks/useIsAtLeastMd.d.ts.map +0 -1
- package/dist/components/organisms/Table/hooks/useIsAtLeastMd.js.map +0 -1
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.cjs.map +0 -1
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.d.ts.map +0 -1
- package/dist/components/organisms/Table/hooks/usePlaceholderRows.js.map +0 -1
- package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.cjs.map +0 -1
- package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.d.ts.map +0 -1
- package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.js.map +0 -1
- package/dist/components/organisms/Table/hooks/useTableSelection.cjs.map +0 -1
- package/dist/components/organisms/Table/hooks/useTableSelection.d.ts.map +0 -1
- package/dist/components/organisms/Table/hooks/useTableSelection.js.map +0 -1
- package/dist/components/organisms/Table/providers/Table.context.cjs.map +0 -1
- package/dist/components/organisms/Table/providers/Table.context.d.ts.map +0 -1
- package/dist/components/organisms/Table/providers/Table.context.js.map +0 -1
- package/dist/components/organisms/Table/table.types.d.ts.map +0 -1
- package/dist/components/organisms/Table/utilities/tableCard.utils.cjs.map +0 -1
- package/dist/components/organisms/Table/utilities/tableCard.utils.d.ts.map +0 -1
- package/dist/components/organisms/Table/utilities/tableCard.utils.js.map +0 -1
- package/dist/components/organisms/Table/utilities/tableChildren.utils.cjs.map +0 -1
- package/dist/components/organisms/Table/utilities/tableChildren.utils.d.ts.map +0 -1
- package/dist/components/organisms/Table/utilities/tableChildren.utils.js.map +0 -1
- package/dist/components/organisms/Table/utilities/tableSelection.utils.cjs.map +0 -1
- package/dist/components/organisms/Table/utilities/tableSelection.utils.d.ts.map +0 -1
- package/dist/components/organisms/Table/utilities/tableSelection.utils.js.map +0 -1
- package/dist/components/organisms/Table/utilities/tableSort.utils.cjs.map +0 -1
- package/dist/components/organisms/Table/utilities/tableSort.utils.d.ts.map +0 -1
- package/dist/components/organisms/Table/utilities/tableSort.utils.js.map +0 -1
- /package/dist/components/organisms/{Table → Tables/Table}/components/TableFallbackCard.cjs +0 -0
- /package/dist/components/organisms/{Table → Tables/Table}/components/TableFallbackCard.js +0 -0
- /package/dist/components/organisms/{Table → Tables/Table}/components/TableSortIcon.cjs +0 -0
- /package/dist/components/organisms/{Table → Tables/Table}/components/TableSortIcon.d.ts +0 -0
- /package/dist/components/organisms/{Table → Tables/Table}/components/TableSortIcon.js +0 -0
- /package/dist/components/organisms/{Table → Tables/Table}/hooks/useFirstSortDirection.d.ts +0 -0
- /package/dist/components/organisms/{Table → Tables/Table}/hooks/useSelectableRowRegistry.cjs +0 -0
- /package/dist/components/organisms/{Table → Tables/Table}/hooks/useSelectableRowRegistry.js +0 -0
- /package/dist/components/organisms/{Table → Tables/Table}/providers/Table.context.cjs +0 -0
- /package/dist/components/organisms/{Table → Tables/Table}/providers/Table.context.js +0 -0
- /package/dist/components/organisms/{Table → Tables}/hooks/useIsAtLeastMd.cjs +0 -0
- /package/dist/components/organisms/{Table → Tables}/hooks/useIsAtLeastMd.d.ts +0 -0
- /package/dist/components/organisms/{Table → Tables}/hooks/useIsAtLeastMd.js +0 -0
- /package/dist/components/organisms/{Table → Tables}/utilities/tableCard.utils.cjs +0 -0
- /package/dist/components/organisms/{Table → Tables}/utilities/tableCard.utils.js +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var stableKey_utils = require('../stableKeyUtils/stableKey.utils.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The state helpers under `useLoadState` and `usePagedList`: what a load shows, which result set a page belongs to, and its
|
|
7
|
+
* page count. INTERNAL: import as `#internal/utilities/listStateUtils/listState.utils`.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Names the result set a page of rows belongs to, so a row total can outlive page and page-size changes.
|
|
11
|
+
*
|
|
12
|
+
* @param query Any query object with a `page` and `pageSize`, plus whatever else the list filters on.
|
|
13
|
+
* @returns A string that is the same for every page and page size of one result set, and different once anything else changes.
|
|
14
|
+
*/
|
|
15
|
+
const resultSetKeyOf = ({ page: _page, pageSize: _pageSize, ...rest }) => stableKey_utils.stableKeyOf(rest);
|
|
16
|
+
/**
|
|
17
|
+
* Decides what a load shows. An error always shows as one: TanStack Query keeps a failed refetch's cached data, and drops the
|
|
18
|
+
* error as soon as a retry fetches again, so the error and the button that started a retry hold until it succeeds.
|
|
19
|
+
*
|
|
20
|
+
* @param state The query's result and whether a retry is running; see `LoadStateInput`.
|
|
21
|
+
* @returns At most one of `isLoading` (loading rows), `isSearching` (stand-in rows) and `isError`, which wins over the others
|
|
22
|
+
* while the query is in error or a retry runs; and `showData`, which is `false` exactly while `isError` is `true`, so cached or
|
|
23
|
+
* stand-in rows stay hidden behind the error.
|
|
24
|
+
*/
|
|
25
|
+
const loadStateOf = ({ isPending, isError, isPreviousData, isRetrying }) => {
|
|
26
|
+
if (isError || isRetrying)
|
|
27
|
+
return { isLoading: false, isSearching: false, isError: true, showData: false };
|
|
28
|
+
// Rows standing in are data to show, so they are not also a load.
|
|
29
|
+
return { isLoading: isPending && !isPreviousData, isSearching: isPreviousData, isError: false, showData: true };
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Counts the pages a result set spans.
|
|
33
|
+
*
|
|
34
|
+
* @param total The row total from the API, `undefined` while it is not known.
|
|
35
|
+
* @param pageSize Rows per page.
|
|
36
|
+
* @returns `Math.ceil(total / pageSize)`; `0` when `total` is unknown or zero, or `pageSize` is not a positive number.
|
|
37
|
+
*/
|
|
38
|
+
const pageCountOf = (total, pageSize) => {
|
|
39
|
+
if (!total || !(pageSize > 0))
|
|
40
|
+
return 0;
|
|
41
|
+
return Math.ceil(total / pageSize);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.loadStateOf = loadStateOf;
|
|
45
|
+
exports.pageCountOf = pageCountOf;
|
|
46
|
+
exports.resultSetKeyOf = resultSetKeyOf;
|
|
47
|
+
//# sourceMappingURL=listState.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listState.utils.cjs","sources":["../../../../src/utilities/__internal__/listStateUtils/listState.utils.ts"],"sourcesContent":[null],"names":["stableKeyOf"],"mappings":";;;;AAAA;;;AAGG;AAGH;;;;;AAKG;AACI,MAAM,cAAc,GAAG,CAAmD,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAAS,KACnIA,2BAAW,CAAC,IAAI;AA0BlB;;;;;;;;AAQG;AACI,MAAM,WAAW,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAkB,KAAqB;IACjH,IAAI,OAAO,IAAI,UAAU;AAAE,QAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE;;IAE1G,OAAO,EAAE,SAAS,EAAE,SAAS,IAAI,CAAC,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE;AACjH;AAEA;;;;;;AAMG;MACU,WAAW,GAAG,CAAC,KAAyB,EAAE,QAAgB,KAAY;IACjF,IAAI,CAAC,KAAK,IAAI,EAAE,QAAQ,GAAG,CAAC,CAAC;AAAE,QAAA,OAAO,CAAC;IACvC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;AACpC;;;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names the result set a page of rows belongs to, so a row total can outlive page and page-size changes.
|
|
3
|
+
*
|
|
4
|
+
* @param query Any query object with a `page` and `pageSize`, plus whatever else the list filters on.
|
|
5
|
+
* @returns A string that is the same for every page and page size of one result set, and different once anything else changes.
|
|
6
|
+
*/
|
|
7
|
+
export declare const resultSetKeyOf: <Query extends {
|
|
8
|
+
page: number;
|
|
9
|
+
pageSize: number;
|
|
10
|
+
}>({ page: _page, pageSize: _pageSize, ...rest }: Query) => string;
|
|
11
|
+
/** A query's result as TanStack's `useQuery` reports it, and whether the page's `retry` is still running for it. */
|
|
12
|
+
export interface LoadStateInput {
|
|
13
|
+
/** The query has no data yet. */
|
|
14
|
+
isPending: boolean;
|
|
15
|
+
/** The query failed, a refetch with data cached included. */
|
|
16
|
+
isError: boolean;
|
|
17
|
+
/** TanStack Query's `isPlaceholderData`, when `placeholderData` keeps the previous rows standing in, as for a search. */
|
|
18
|
+
isPreviousData: boolean;
|
|
19
|
+
/** `retry` was called for this query and its fetch has not settled. */
|
|
20
|
+
isRetrying: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** What `loadStateOf` decides a load shows. */
|
|
23
|
+
export interface LoadStateResult {
|
|
24
|
+
/** Draw loading rows. */
|
|
25
|
+
isLoading: boolean;
|
|
26
|
+
/** The previous rows stand in while a search lands. */
|
|
27
|
+
isSearching: boolean;
|
|
28
|
+
/** Show the error and its retry button. */
|
|
29
|
+
isError: boolean;
|
|
30
|
+
/** The data may be drawn; `false` while the error shows. */
|
|
31
|
+
showData: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Decides what a load shows. An error always shows as one: TanStack Query keeps a failed refetch's cached data, and drops the
|
|
35
|
+
* error as soon as a retry fetches again, so the error and the button that started a retry hold until it succeeds.
|
|
36
|
+
*
|
|
37
|
+
* @param state The query's result and whether a retry is running; see `LoadStateInput`.
|
|
38
|
+
* @returns At most one of `isLoading` (loading rows), `isSearching` (stand-in rows) and `isError`, which wins over the others
|
|
39
|
+
* while the query is in error or a retry runs; and `showData`, which is `false` exactly while `isError` is `true`, so cached or
|
|
40
|
+
* stand-in rows stay hidden behind the error.
|
|
41
|
+
*/
|
|
42
|
+
export declare const loadStateOf: ({ isPending, isError, isPreviousData, isRetrying }: LoadStateInput) => LoadStateResult;
|
|
43
|
+
/**
|
|
44
|
+
* Counts the pages a result set spans.
|
|
45
|
+
*
|
|
46
|
+
* @param total The row total from the API, `undefined` while it is not known.
|
|
47
|
+
* @param pageSize Rows per page.
|
|
48
|
+
* @returns `Math.ceil(total / pageSize)`; `0` when `total` is unknown or zero, or `pageSize` is not a positive number.
|
|
49
|
+
*/
|
|
50
|
+
export declare const pageCountOf: (total: number | undefined, pageSize: number) => number;
|
|
51
|
+
//# sourceMappingURL=listState.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listState.utils.d.ts","sourceRoot":"","sources":["../../../../src/utilities/__internal__/listStateUtils/listState.utils.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAAE,+CAA+C,KAAK,KAAG,MACrH,CAAC;AAEpB,oHAAoH;AACpH,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,6DAA6D;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,yHAAyH;IACzH,cAAc,EAAE,OAAO,CAAC;IACxB,uEAAuE;IACvE,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,+CAA+C;AAC/C,MAAM,WAAW,eAAe;IAC9B,yBAAyB;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,uDAAuD;IACvD,WAAW,EAAE,OAAO,CAAC;IACrB,2CAA2C;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,4DAA4D;IAC5D,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,oDAAoD,cAAc,KAAG,eAIhG,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,GAAG,SAAS,EAAE,UAAU,MAAM,KAAG,MAGzE,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { stableKeyOf } from '../stableKeyUtils/stableKey.utils.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The state helpers under `useLoadState` and `usePagedList`: what a load shows, which result set a page belongs to, and its
|
|
5
|
+
* page count. INTERNAL: import as `#internal/utilities/listStateUtils/listState.utils`.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Names the result set a page of rows belongs to, so a row total can outlive page and page-size changes.
|
|
9
|
+
*
|
|
10
|
+
* @param query Any query object with a `page` and `pageSize`, plus whatever else the list filters on.
|
|
11
|
+
* @returns A string that is the same for every page and page size of one result set, and different once anything else changes.
|
|
12
|
+
*/
|
|
13
|
+
const resultSetKeyOf = ({ page: _page, pageSize: _pageSize, ...rest }) => stableKeyOf(rest);
|
|
14
|
+
/**
|
|
15
|
+
* Decides what a load shows. An error always shows as one: TanStack Query keeps a failed refetch's cached data, and drops the
|
|
16
|
+
* error as soon as a retry fetches again, so the error and the button that started a retry hold until it succeeds.
|
|
17
|
+
*
|
|
18
|
+
* @param state The query's result and whether a retry is running; see `LoadStateInput`.
|
|
19
|
+
* @returns At most one of `isLoading` (loading rows), `isSearching` (stand-in rows) and `isError`, which wins over the others
|
|
20
|
+
* while the query is in error or a retry runs; and `showData`, which is `false` exactly while `isError` is `true`, so cached or
|
|
21
|
+
* stand-in rows stay hidden behind the error.
|
|
22
|
+
*/
|
|
23
|
+
const loadStateOf = ({ isPending, isError, isPreviousData, isRetrying }) => {
|
|
24
|
+
if (isError || isRetrying)
|
|
25
|
+
return { isLoading: false, isSearching: false, isError: true, showData: false };
|
|
26
|
+
// Rows standing in are data to show, so they are not also a load.
|
|
27
|
+
return { isLoading: isPending && !isPreviousData, isSearching: isPreviousData, isError: false, showData: true };
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Counts the pages a result set spans.
|
|
31
|
+
*
|
|
32
|
+
* @param total The row total from the API, `undefined` while it is not known.
|
|
33
|
+
* @param pageSize Rows per page.
|
|
34
|
+
* @returns `Math.ceil(total / pageSize)`; `0` when `total` is unknown or zero, or `pageSize` is not a positive number.
|
|
35
|
+
*/
|
|
36
|
+
const pageCountOf = (total, pageSize) => {
|
|
37
|
+
if (!total || !(pageSize > 0))
|
|
38
|
+
return 0;
|
|
39
|
+
return Math.ceil(total / pageSize);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { loadStateOf, pageCountOf, resultSetKeyOf };
|
|
43
|
+
//# sourceMappingURL=listState.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listState.utils.js","sources":["../../../../src/utilities/__internal__/listStateUtils/listState.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;AAGH;;;;;AAKG;AACI,MAAM,cAAc,GAAG,CAAmD,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAAS,KACnI,WAAW,CAAC,IAAI;AA0BlB;;;;;;;;AAQG;AACI,MAAM,WAAW,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAkB,KAAqB;IACjH,IAAI,OAAO,IAAI,UAAU;AAAE,QAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE;;IAE1G,OAAO,EAAE,SAAS,EAAE,SAAS,IAAI,CAAC,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE;AACjH;AAEA;;;;;;AAMG;MACU,WAAW,GAAG,CAAC,KAAyB,EAAE,QAAgB,KAAY;IACjF,IAAI,CAAC,KAAK,IAAI,EAAE,QAAQ,GAAG,CAAC,CAAC;AAAE,QAAA,OAAO,CAAC;IACvC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;AACpC;;"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cache-key helpers that give equal values equal strings, whatever their key order, `Set` order or `Map` order.
|
|
5
|
+
* INTERNAL: import as `#internal/utilities/stableKeyUtils/stableKey.utils`.
|
|
6
|
+
*/
|
|
7
|
+
// Plain UTF-16 code-unit order: `localeCompare` depends on the runtime's locale and can rank distinct strings as equal.
|
|
8
|
+
const byCodeUnit = (a, b) => {
|
|
9
|
+
if (a < b)
|
|
10
|
+
return -1;
|
|
11
|
+
return a > b ? 1 : 0;
|
|
12
|
+
};
|
|
13
|
+
// Object keys are sorted at every depth so insertion order never changes the string.
|
|
14
|
+
const sortedKeys = (_key, value) => {
|
|
15
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
16
|
+
return value;
|
|
17
|
+
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => byCodeUnit(a, b)));
|
|
18
|
+
};
|
|
19
|
+
const keyOfSafe = (safe) => JSON.stringify(safe, sortedKeys) ?? 'undefined';
|
|
20
|
+
const sortedByKey = (members) => members
|
|
21
|
+
.map((member) => ({ member, key: keyOfSafe(member) }))
|
|
22
|
+
.sort((a, b) => byCodeUnit(a.key, b.key))
|
|
23
|
+
.map(({ member }) => member);
|
|
24
|
+
// A primitive member becomes a string, so the id `1` and the `'1'` a URL reads back key the same.
|
|
25
|
+
const setMemberOf = (member) => (member !== null && typeof member === 'object' ? jsonSafeOf(member) : String(member));
|
|
26
|
+
/**
|
|
27
|
+
* Copies a value into plain JSON data, so equal values serialise the same. TanStack Query hashes every `Set` and `Map` as
|
|
28
|
+
* `{}`, so two selections would otherwise share a cache entry.
|
|
29
|
+
*
|
|
30
|
+
* @param value The value to copy: a primitive, array, `Set`, `Map`, object or class instance, nested to any depth.
|
|
31
|
+
* @returns A `Set` becomes an array of its members, each primitive as a string and each object copied like any other value,
|
|
32
|
+
* sorted by their keys, so it keys the same as that array; a `Map` becomes `{ $map: [key, value][] }`, sorted by key, so it
|
|
33
|
+
* never keys like a plain object or array of the same entries; an array keeps its order; a value with `toJSON`, such as a
|
|
34
|
+
* `Date`, becomes its result; an object or class instance becomes a plain object of its own enumerable keys, without the
|
|
35
|
+
* members that are `undefined` or functions. Primitives and `null` pass through.
|
|
36
|
+
*/
|
|
37
|
+
function jsonSafeOf(value) {
|
|
38
|
+
if (value === null || typeof value !== 'object')
|
|
39
|
+
return value;
|
|
40
|
+
if (value instanceof Set)
|
|
41
|
+
return sortedByKey([...value].map(setMemberOf));
|
|
42
|
+
if (value instanceof Map)
|
|
43
|
+
return { $map: sortedByKey([...value].map(([key, member]) => [jsonSafeOf(key), jsonSafeOf(member)])) };
|
|
44
|
+
const withToJson = value;
|
|
45
|
+
if (typeof withToJson.toJSON === 'function')
|
|
46
|
+
return jsonSafeOf(withToJson.toJSON.call(value));
|
|
47
|
+
if (Array.isArray(value))
|
|
48
|
+
return value.map((member) => jsonSafeOf(member));
|
|
49
|
+
// Built from entries rather than by assignment, so an own `__proto__` field stays a field instead of setting a prototype.
|
|
50
|
+
return Object.fromEntries(Object.entries(value)
|
|
51
|
+
.filter(([, member]) => member !== undefined && typeof member !== 'function')
|
|
52
|
+
.map(([key, member]) => [key, jsonSafeOf(member)]));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Turns a value into a string that is the same for every equal value.
|
|
56
|
+
*
|
|
57
|
+
* Limits, as JSON has them: `NaN` and `Infinity` key as `null`, and so does `undefined` in an array; a cyclic value throws, and
|
|
58
|
+
* so does a `BigInt` anywhere but in a `Set`.
|
|
59
|
+
*
|
|
60
|
+
* @param value The value to key, as `jsonSafeOf` accepts it.
|
|
61
|
+
* @returns The JSON of `jsonSafeOf(value)` with object keys sorted at every depth.
|
|
62
|
+
*/
|
|
63
|
+
const stableKeyOf = (value) => keyOfSafe(jsonSafeOf(value));
|
|
64
|
+
|
|
65
|
+
exports.jsonSafeOf = jsonSafeOf;
|
|
66
|
+
exports.stableKeyOf = stableKeyOf;
|
|
67
|
+
//# sourceMappingURL=stableKey.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stableKey.utils.cjs","sources":["../../../../src/utilities/__internal__/stableKeyUtils/stable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+1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache-key helpers that give equal values equal strings, whatever their key order, `Set` order or `Map` order.
|
|
3
|
+
* INTERNAL: import as `#internal/utilities/stableKeyUtils/stableKey.utils`.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Copies a value into plain JSON data, so equal values serialise the same. TanStack Query hashes every `Set` and `Map` as
|
|
7
|
+
* `{}`, so two selections would otherwise share a cache entry.
|
|
8
|
+
*
|
|
9
|
+
* @param value The value to copy: a primitive, array, `Set`, `Map`, object or class instance, nested to any depth.
|
|
10
|
+
* @returns A `Set` becomes an array of its members, each primitive as a string and each object copied like any other value,
|
|
11
|
+
* sorted by their keys, so it keys the same as that array; a `Map` becomes `{ $map: [key, value][] }`, sorted by key, so it
|
|
12
|
+
* never keys like a plain object or array of the same entries; an array keeps its order; a value with `toJSON`, such as a
|
|
13
|
+
* `Date`, becomes its result; an object or class instance becomes a plain object of its own enumerable keys, without the
|
|
14
|
+
* members that are `undefined` or functions. Primitives and `null` pass through.
|
|
15
|
+
*/
|
|
16
|
+
export declare function jsonSafeOf(value: unknown): unknown;
|
|
17
|
+
/**
|
|
18
|
+
* Turns a value into a string that is the same for every equal value.
|
|
19
|
+
*
|
|
20
|
+
* Limits, as JSON has them: `NaN` and `Infinity` key as `null`, and so does `undefined` in an array; a cyclic value throws, and
|
|
21
|
+
* so does a `BigInt` anywhere but in a `Set`.
|
|
22
|
+
*
|
|
23
|
+
* @param value The value to key, as `jsonSafeOf` accepts it.
|
|
24
|
+
* @returns The JSON of `jsonSafeOf(value)` with object keys sorted at every depth.
|
|
25
|
+
*/
|
|
26
|
+
export declare const stableKeyOf: (value: unknown) => string;
|
|
27
|
+
//# sourceMappingURL=stableKey.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stableKey.utils.d.ts","sourceRoot":"","sources":["../../../../src/utilities/__internal__/stableKeyUtils/stableKey.utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAyBH;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAalD;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,MAAsC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache-key helpers that give equal values equal strings, whatever their key order, `Set` order or `Map` order.
|
|
3
|
+
* INTERNAL: import as `#internal/utilities/stableKeyUtils/stableKey.utils`.
|
|
4
|
+
*/
|
|
5
|
+
// Plain UTF-16 code-unit order: `localeCompare` depends on the runtime's locale and can rank distinct strings as equal.
|
|
6
|
+
const byCodeUnit = (a, b) => {
|
|
7
|
+
if (a < b)
|
|
8
|
+
return -1;
|
|
9
|
+
return a > b ? 1 : 0;
|
|
10
|
+
};
|
|
11
|
+
// Object keys are sorted at every depth so insertion order never changes the string.
|
|
12
|
+
const sortedKeys = (_key, value) => {
|
|
13
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
14
|
+
return value;
|
|
15
|
+
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => byCodeUnit(a, b)));
|
|
16
|
+
};
|
|
17
|
+
const keyOfSafe = (safe) => JSON.stringify(safe, sortedKeys) ?? 'undefined';
|
|
18
|
+
const sortedByKey = (members) => members
|
|
19
|
+
.map((member) => ({ member, key: keyOfSafe(member) }))
|
|
20
|
+
.sort((a, b) => byCodeUnit(a.key, b.key))
|
|
21
|
+
.map(({ member }) => member);
|
|
22
|
+
// A primitive member becomes a string, so the id `1` and the `'1'` a URL reads back key the same.
|
|
23
|
+
const setMemberOf = (member) => (member !== null && typeof member === 'object' ? jsonSafeOf(member) : String(member));
|
|
24
|
+
/**
|
|
25
|
+
* Copies a value into plain JSON data, so equal values serialise the same. TanStack Query hashes every `Set` and `Map` as
|
|
26
|
+
* `{}`, so two selections would otherwise share a cache entry.
|
|
27
|
+
*
|
|
28
|
+
* @param value The value to copy: a primitive, array, `Set`, `Map`, object or class instance, nested to any depth.
|
|
29
|
+
* @returns A `Set` becomes an array of its members, each primitive as a string and each object copied like any other value,
|
|
30
|
+
* sorted by their keys, so it keys the same as that array; a `Map` becomes `{ $map: [key, value][] }`, sorted by key, so it
|
|
31
|
+
* never keys like a plain object or array of the same entries; an array keeps its order; a value with `toJSON`, such as a
|
|
32
|
+
* `Date`, becomes its result; an object or class instance becomes a plain object of its own enumerable keys, without the
|
|
33
|
+
* members that are `undefined` or functions. Primitives and `null` pass through.
|
|
34
|
+
*/
|
|
35
|
+
function jsonSafeOf(value) {
|
|
36
|
+
if (value === null || typeof value !== 'object')
|
|
37
|
+
return value;
|
|
38
|
+
if (value instanceof Set)
|
|
39
|
+
return sortedByKey([...value].map(setMemberOf));
|
|
40
|
+
if (value instanceof Map)
|
|
41
|
+
return { $map: sortedByKey([...value].map(([key, member]) => [jsonSafeOf(key), jsonSafeOf(member)])) };
|
|
42
|
+
const withToJson = value;
|
|
43
|
+
if (typeof withToJson.toJSON === 'function')
|
|
44
|
+
return jsonSafeOf(withToJson.toJSON.call(value));
|
|
45
|
+
if (Array.isArray(value))
|
|
46
|
+
return value.map((member) => jsonSafeOf(member));
|
|
47
|
+
// Built from entries rather than by assignment, so an own `__proto__` field stays a field instead of setting a prototype.
|
|
48
|
+
return Object.fromEntries(Object.entries(value)
|
|
49
|
+
.filter(([, member]) => member !== undefined && typeof member !== 'function')
|
|
50
|
+
.map(([key, member]) => [key, jsonSafeOf(member)]));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Turns a value into a string that is the same for every equal value.
|
|
54
|
+
*
|
|
55
|
+
* Limits, as JSON has them: `NaN` and `Infinity` key as `null`, and so does `undefined` in an array; a cyclic value throws, and
|
|
56
|
+
* so does a `BigInt` anywhere but in a `Set`.
|
|
57
|
+
*
|
|
58
|
+
* @param value The value to key, as `jsonSafeOf` accepts it.
|
|
59
|
+
* @returns The JSON of `jsonSafeOf(value)` with object keys sorted at every depth.
|
|
60
|
+
*/
|
|
61
|
+
const stableKeyOf = (value) => keyOfSafe(jsonSafeOf(value));
|
|
62
|
+
|
|
63
|
+
export { jsonSafeOf, stableKeyOf };
|
|
64
|
+
//# sourceMappingURL=stableKey.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stableKey.utils.js","sources":["../../../../src/utilities/__internal__/stableKeyUtils/stableKey.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;AAGG;AAEH;AACA,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS,KAAY;IAClD,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE;IACpB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;AACtB,CAAC;AAED;AACA,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,KAAc,KAAa;AAC3D,IAAA,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;AACrF,IAAA,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACvF,CAAC;AAED,MAAM,SAAS,GAAG,CAAC,IAAa,KAAa,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,WAAW;AAE5F,MAAM,WAAW,GAAG,CAAC,OAAkB,KACrC;AACG,KAAA,GAAG,CAAC,CAAC,MAAM,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;AACpD,KAAA,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,EA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MAAM,KAAK,UAAU;SAC3E,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CACrD;AACH;AAEA;;;;;;;;AAQG;AACI,MAAM,WAAW,GAAG,CAAC,KAAc,KAAa,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC;;"}
|
|
@@ -118,9 +118,37 @@ const createWebStorageItem = (getStorage, key, options = {}) => {
|
|
|
118
118
|
},
|
|
119
119
|
};
|
|
120
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* Calls `onChange` when another document of the same origin, such as another tab, writes or clears `key` in the watched
|
|
123
|
+
* storage: the browser's `storage` event, which never fires for a write in this document.
|
|
124
|
+
*
|
|
125
|
+
* @param storageName The storage the key lives in; the same event reports writes to the other one, which are ignored.
|
|
126
|
+
* @param key The storage key to watch.
|
|
127
|
+
* @param onChange Called after each such write, or after the other document clears that whole storage.
|
|
128
|
+
* @returns Stops watching. Without `window`, as on the server, nothing is watched.
|
|
129
|
+
*/
|
|
130
|
+
const subscribeToOtherDocumentWrites = (storageName, key, onChange) => {
|
|
131
|
+
if (typeof window === 'undefined')
|
|
132
|
+
return () => { };
|
|
133
|
+
const handleStorage = (event) => {
|
|
134
|
+
let storage;
|
|
135
|
+
try {
|
|
136
|
+
storage = window[storageName];
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
// A `null` key is a `clear()` of the whole storage, which only counts for the storage watched.
|
|
142
|
+
if (event.storageArea === storage && (event.key === key || event.key === null))
|
|
143
|
+
onChange();
|
|
144
|
+
};
|
|
145
|
+
window.addEventListener('storage', handleStorage);
|
|
146
|
+
return () => window.removeEventListener('storage', handleStorage);
|
|
147
|
+
};
|
|
121
148
|
|
|
122
149
|
exports.createWebStorageItem = createWebStorageItem;
|
|
123
150
|
exports.isBoolean = isBoolean;
|
|
124
151
|
exports.isString = isString;
|
|
125
152
|
exports.parseBooleanString = parseBooleanString;
|
|
153
|
+
exports.subscribeToOtherDocumentWrites = subscribeToOtherDocumentWrites;
|
|
126
154
|
//# sourceMappingURL=webStorage.utils.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webStorage.utils.cjs","sources":["../../../../src/utilities/__internal__/webStorageUtils/webStorage.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;AAUG;AAKH,MAAM,OAAO,GAAG,CAAC,UAA2B,EAAE,GAAW,KAAmB;IAC1E,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,IAAI;AAC9C,IAAA,IAAI;AACF,QAAA,OAAO,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAClC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,UAA2B,EAAE,GAAW,EAAE,KAAa,KAAa;IACnF,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,KAAK;AAC/C,IAAA,IAAI;QACF,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;AAChC,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,UAA2B,EAAE,GAAW,KAAa;IACvE,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,KAAK;AAC/C,IAAA,IAAI;AACF,QAAA,UAAU,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;AAC5B,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAoBD;;;;;AAKG;AACI,MAAM,SAAS,GAAG,CAAC,KAAc,KAAuB,OAAO,KAAK,KAAK;AAEhF;;;;;AAKG;AACI,MAAM,QAAQ,GAAG,CA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KACF;AACH
|
|
1
|
+
{"version":3,"file":"webStorage.utils.cjs","sources":["../../../../src/utilities/__internal__/webStorageUtils/webStorage.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;AAUG;AAKH,MAAM,OAAO,GAAG,CAAC,UAA2B,EAAE,GAAW,KAAmB;IAC1E,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,IAAI;AAC9C,IAAA,IAAI;AACF,QAAA,OAAO,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAClC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,UAA2B,EAAE,GAAW,EAAE,KAAa,KAAa;IACnF,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,KAAK;AAC/C,IAAA,IAAI;QACF,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;AAChC,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,UAA2B,EAAE,GAAW,KAAa;IACvE,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,KAAK;AAC/C,IAAA,IAAI;AACF,QAAA,UAAU,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;AAC5B,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAoBD;;;;;AAKG;AACI,MAAM,SAAS,GAAG,CAAC,KAAc,KAAuB,OAAO,KAAK,KAAK;AAEhF;;;;;AAKG;AACI,MAAM,QAAQ,GAAG,CAAC,KAAc,KAAsB,OAAO,KAAK,KAAK;AAE9E;;;;;;;;AAQG;MACU,kBAAkB,GAAG,CAAC,GAAW,EAAE,YAAoB,KAAa;IAC/E,IAAI,GAAG,KAAK,MAAM;AAA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E,QAAA,OAAO,MAAK,EAAE,CAAC;AAClD,IAAA,MAAM,aAAa,GAAG,CAAC,KAAmB,KAAI;AAC5C,QAAA,IAAI,OAAgB;AACpB,QAAA,IAAI;AACF,YAAA,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC;QAC/B;AAAE,QAAA,MAAM;YACN;QACF;;AAEA,QAAA,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,KAAK,KAAK,CAAC,GAAG,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC;AAAE,YAAA,QAAQ,EAAE;AAC5F,IAAA,CAAC;AACD,IAAA,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC;IACjD,OAAO,MAAM,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC;AACnE;;;;;;"}
|
|
@@ -60,5 +60,15 @@ export declare const parseBooleanString: (raw: string, errorMessage: string) =>
|
|
|
60
60
|
* @returns An accessor whose `get`, `set` and `clear` never throw.
|
|
61
61
|
*/
|
|
62
62
|
export declare const createWebStorageItem: <T>(getStorage: StorageAccessor, key: string, options?: WebStorageItemOptions<T>) => WebStorageItem<T>;
|
|
63
|
+
/**
|
|
64
|
+
* Calls `onChange` when another document of the same origin, such as another tab, writes or clears `key` in the watched
|
|
65
|
+
* storage: the browser's `storage` event, which never fires for a write in this document.
|
|
66
|
+
*
|
|
67
|
+
* @param storageName The storage the key lives in; the same event reports writes to the other one, which are ignored.
|
|
68
|
+
* @param key The storage key to watch.
|
|
69
|
+
* @param onChange Called after each such write, or after the other document clears that whole storage.
|
|
70
|
+
* @returns Stops watching. Without `window`, as on the server, nothing is watched.
|
|
71
|
+
*/
|
|
72
|
+
export declare const subscribeToOtherDocumentWrites: (storageName: "localStorage" | "sessionStorage", key: string, onChange: () => void) => (() => void);
|
|
63
73
|
export {};
|
|
64
74
|
//# sourceMappingURL=webStorage.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webStorage.utils.d.ts","sourceRoot":"","sources":["../../../../src/utilities/__internal__/webStorageUtils/webStorage.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,qFAAqF;AACrF,KAAK,eAAe,GAAG,MAAM,OAAO,CAAC;AA+BrC,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,gFAAgF;IAChF,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAChB,wEAAwE;IACxE,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,mDAAmD;IACnD,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,8DAA8D;IAC9D,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACjC,2DAA2D;IAC3D,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,CAAC;IACjC,oEAAoE;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;CAC3C;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,OAAqC,CAAC;AAE1F;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAmC,CAAC;AAEvF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,EAAE,cAAc,MAAM,KAAG,OAItE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,YAAY,eAAe,EAAE,KAAK,MAAM,EAAE,UAAS,qBAAqB,CAAC,CAAC,CAAM,KAAG,cAAc,CAAC,CAAC,CAgC1I,CAAC"}
|
|
1
|
+
{"version":3,"file":"webStorage.utils.d.ts","sourceRoot":"","sources":["../../../../src/utilities/__internal__/webStorageUtils/webStor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|
@@ -116,6 +116,33 @@ const createWebStorageItem = (getStorage, key, options = {}) => {
|
|
|
116
116
|
},
|
|
117
117
|
};
|
|
118
118
|
};
|
|
119
|
+
/**
|
|
120
|
+
* Calls `onChange` when another document of the same origin, such as another tab, writes or clears `key` in the watched
|
|
121
|
+
* storage: the browser's `storage` event, which never fires for a write in this document.
|
|
122
|
+
*
|
|
123
|
+
* @param storageName The storage the key lives in; the same event reports writes to the other one, which are ignored.
|
|
124
|
+
* @param key The storage key to watch.
|
|
125
|
+
* @param onChange Called after each such write, or after the other document clears that whole storage.
|
|
126
|
+
* @returns Stops watching. Without `window`, as on the server, nothing is watched.
|
|
127
|
+
*/
|
|
128
|
+
const subscribeToOtherDocumentWrites = (storageName, key, onChange) => {
|
|
129
|
+
if (typeof window === 'undefined')
|
|
130
|
+
return () => { };
|
|
131
|
+
const handleStorage = (event) => {
|
|
132
|
+
let storage;
|
|
133
|
+
try {
|
|
134
|
+
storage = window[storageName];
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
// A `null` key is a `clear()` of the whole storage, which only counts for the storage watched.
|
|
140
|
+
if (event.storageArea === storage && (event.key === key || event.key === null))
|
|
141
|
+
onChange();
|
|
142
|
+
};
|
|
143
|
+
window.addEventListener('storage', handleStorage);
|
|
144
|
+
return () => window.removeEventListener('storage', handleStorage);
|
|
145
|
+
};
|
|
119
146
|
|
|
120
|
-
export { createWebStorageItem, isBoolean, isString, parseBooleanString };
|
|
147
|
+
export { createWebStorageItem, isBoolean, isString, parseBooleanString, subscribeToOtherDocumentWrites };
|
|
121
148
|
//# sourceMappingURL=webStorage.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webStorage.utils.js","sources":["../../../../src/utilities/__internal__/webStorageUtils/webStorage.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;AAUG;AAKH,MAAM,OAAO,GAAG,CAAC,UAA2B,EA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2B,EAAE,GAAW,EAAE,OAAA,GAAoC,EAAE,KAAuB;AAC7I,IAAA,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC,KAA2B,EAAE,QAAQ,EAAE,GAAG,OAAO;IAExG,OAAO;QACL,GAAG,GAAA;YACD,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;YACpC,IAAI,GAAG,IAAI,IAAI;AAAE,gBAAA,OAAO,IAAI;AAC5B,YAAA,IAAI;AACF,gBAAA,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC;AAC9B,gBAAA,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAE,oBAAA,OAAO,IAAI;AAC7C,gBAAA,OAAO,KAAK;YACd;AAAE,YAAA,MAAM;AACN,gBAAA,OAAO,IAAI;YACb;QACF,CAAC;AACD,QAAA,GAAG,CAAC,KAAK,EAAA;AACP,YAAA,IAAI;AACF,gBAAA,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC;;;;gBAInC,IAAI,OAAO,UAAU,KAAK,QAAQ;oBAAE;AACpC,gBAAA,OAAO,CAAC,UAAU,EAAE,GAAG,EAAE,UAAU,CAAC;YACtC;AAAE,YAAA,MAAM;;;YAGR;QACF,CAAC;QACD,KAAK,GAAA;AACH,YAAA,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC;QAC7B,CAAC;KACF;AACH;;"}
|
|
1
|
+
{"version":3,"file":"webStorage.utils.js","sources":["../../../../src/utilities/__internal__/webStorageUtils/webStorage.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;AAUG;AAKH,MAAM,OAAO,GAAG,CAAC,UAA2B,EAAE,GAAW,KAAmB;IAC1E,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,IAAI;AAC9C,IAAA,IAAI;AACF,QAAA,OAAO,UAAU,EAAE,CAAC,OAAO,CA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AI,CAAC;AAAE,YAAA,QAAQ,EAAE;AAC5F,IAAA,CAAC;AACD,IAAA,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC;IACjD,OAAO,MAAM,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC;AACnE;;"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var stableKey_utils = require('../__internal__/stableKeyUtils/stableKey.utils.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Turns a list query into a cache key. TanStack Query hashes every `Set` and `Map` as `{}`, so two selections would share an
|
|
7
|
+
* entry.
|
|
8
|
+
*
|
|
9
|
+
* Limits, as JSON has them: `NaN` and `Infinity` key as `null`, and so does `undefined` in an array; a cyclic value throws, and
|
|
10
|
+
* so does a `BigInt` anywhere but in a `Set`.
|
|
11
|
+
*
|
|
12
|
+
* @param query The page's query object: search, filters, sort, page and so on, with `Set` and `Map` fields allowed at any depth.
|
|
13
|
+
* @returns A deep copy that is safe to hash: each `Set` as an array of its members sorted by their keys, primitives as strings,
|
|
14
|
+
* and each `Map` as `{ $map: [key, value][] }` sorted by key, so neither depends on the order it was filled in. Use it
|
|
15
|
+
* directly as a TanStack `queryKey` or SWR key.
|
|
16
|
+
*/
|
|
17
|
+
const listQueryKeyOf = (query) => stableKey_utils.jsonSafeOf(query);
|
|
18
|
+
/**
|
|
19
|
+
* Tells a search refining the rows apart from a change that replaces them.
|
|
20
|
+
*
|
|
21
|
+
* @param previous The query, or its `listQueryKeyOf` key, of the rows on screen.
|
|
22
|
+
* @param next The query, or key, of the rows being fetched.
|
|
23
|
+
* @param searchField The field holding the search term.
|
|
24
|
+
* @returns `true` when the search differs and nothing else but `page` does, counting the page reset a new search causes; the
|
|
25
|
+
* previous rows can stand in.
|
|
26
|
+
*/
|
|
27
|
+
const isSearchOnlyChange = (previous, next, searchField = 'search') => {
|
|
28
|
+
const split = (query) => {
|
|
29
|
+
const { [searchField]: search, page: _page, ...rest } = query;
|
|
30
|
+
return { search: stableKey_utils.stableKeyOf(search), rest: stableKey_utils.stableKeyOf(rest) };
|
|
31
|
+
};
|
|
32
|
+
const before = split(previous);
|
|
33
|
+
const after = split(next);
|
|
34
|
+
return before.search !== after.search && before.rest === after.rest;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Counts the filter fields that differ from their cleared value, for the badge on a "Filters" trigger. Each field is compared by
|
|
38
|
+
* value, so a `Set`, an array, a date range, a string or a boolean counts once with no rule per type.
|
|
39
|
+
*
|
|
40
|
+
* @param filters The applied filters, such as those parsed from the URL.
|
|
41
|
+
* @param empty The same fields with every one cleared; a key missing from either object compares as `undefined`.
|
|
42
|
+
* @returns How many keys of either object hold a different value in `filters` than in `empty`.
|
|
43
|
+
*/
|
|
44
|
+
const countAppliedFilters = (filters, empty) => {
|
|
45
|
+
const applied = filters;
|
|
46
|
+
const cleared = empty;
|
|
47
|
+
const keys = new Set([...Object.keys(applied), ...Object.keys(cleared)]);
|
|
48
|
+
let count = 0;
|
|
49
|
+
for (const key of keys) {
|
|
50
|
+
if (stableKey_utils.stableKeyOf(applied[key]) !== stableKey_utils.stableKeyOf(cleared[key]))
|
|
51
|
+
count++;
|
|
52
|
+
}
|
|
53
|
+
return count;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.countAppliedFilters = countAppliedFilters;
|
|
57
|
+
exports.isSearchOnlyChange = isSearchOnlyChange;
|
|
58
|
+
exports.listQueryKeyOf = listQueryKeyOf;
|
|
59
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/listQueryUtils/index.ts"],"sourcesContent":[null],"names":["jsonSafeOf","stableKeyOf"],"mappings":";;;;AA4BA;;;;;;;;;;;AAWG;AACI,MAAM,cAAc,GAAG,CAAQ,KAAY,KAA0BA,0BAAU,CAAC,KAAK;AAE5F;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|
|
2
|
+
/**
|
|
3
|
+
* What `listQueryKeyOf` makes of a query: a `Set` becomes an array of its members, primitives as strings; a `Map` becomes
|
|
4
|
+
* `{ $map: [key, value][] }`; a `toJSON` value becomes its result; an object keeps its fields but not its methods.
|
|
5
|
+
*/
|
|
6
|
+
export type ListQueryKey<Query> = Query extends ReadonlyMap<infer Key, infer Value> ? {
|
|
7
|
+
$map: [ListQueryKey<Key>, ListQueryKey<Value>][];
|
|
8
|
+
} : Query extends ReadonlySet<infer Member> ? ListQuerySetMember<Member>[] : Query extends {
|
|
9
|
+
toJSON(): infer Json;
|
|
10
|
+
} ? ListQueryKey<Json> : Query extends readonly (infer Member)[] ? ListQueryKey<Member>[] : Query extends object ? {
|
|
11
|
+
[Field in keyof Query as Query[Field] extends ((...args: never[]) => unknown) | undefined ? never : Field]: ListQueryKey<Query[Field]>;
|
|
12
|
+
} : Query;
|
|
13
|
+
/**
|
|
14
|
+
* Turns a list query into a cache key. TanStack Query hashes every `Set` and `Map` as `{}`, so two selections would share an
|
|
15
|
+
* entry.
|
|
16
|
+
*
|
|
17
|
+
* Limits, as JSON has them: `NaN` and `Infinity` key as `null`, and so does `undefined` in an array; a cyclic value throws, and
|
|
18
|
+
* so does a `BigInt` anywhere but in a `Set`.
|
|
19
|
+
*
|
|
20
|
+
* @param query The page's query object: search, filters, sort, page and so on, with `Set` and `Map` fields allowed at any depth.
|
|
21
|
+
* @returns A deep copy that is safe to hash: each `Set` as an array of its members sorted by their keys, primitives as strings,
|
|
22
|
+
* and each `Map` as `{ $map: [key, value][] }` sorted by key, so neither depends on the order it was filled in. Use it
|
|
23
|
+
* directly as a TanStack `queryKey` or SWR key.
|
|
24
|
+
*/
|
|
25
|
+
export declare const listQueryKeyOf: <Query>(query: Query) => ListQueryKey<Query>;
|
|
26
|
+
/**
|
|
27
|
+
* Tells a search refining the rows apart from a change that replaces them.
|
|
28
|
+
*
|
|
29
|
+
* @param previous The query, or its `listQueryKeyOf` key, of the rows on screen.
|
|
30
|
+
* @param next The query, or key, of the rows being fetched.
|
|
31
|
+
* @param searchField The field holding the search term.
|
|
32
|
+
* @returns `true` when the search differs and nothing else but `page` does, counting the page reset a new search causes; the
|
|
33
|
+
* previous rows can stand in.
|
|
34
|
+
*/
|
|
35
|
+
export declare const isSearchOnlyChange: (previous: object, next: object, searchField?: string) => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Counts the filter fields that differ from their cleared value, for the badge on a "Filters" trigger. Each field is compared by
|
|
38
|
+
* value, so a `Set`, an array, a date range, a string or a boolean counts once with no rule per type.
|
|
39
|
+
*
|
|
40
|
+
* @param filters The applied filters, such as those parsed from the URL.
|
|
41
|
+
* @param empty The same fields with every one cleared; a key missing from either object compares as `undefined`.
|
|
42
|
+
* @returns How many keys of either object hold a different value in `filters` than in `empty`.
|
|
43
|
+
*/
|
|
44
|
+
export declare const countAppliedFilters: <Filters extends object>(filters: Filters, empty: Filters) => number;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/listQueryUtils/index.ts"],"names":[],"mappings":"AAGA,KAAK,kBAAkB,CAAC,MAAM,IAAI,MAAM,SAAS,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAExF;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,KAAK,IAE5B,KAAK,SAAS,WAAW,CAAC,MAAM,GAAG,EAAE,MAAM,KAAK,CAAC,GAC7C;IAAE,IAAI,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAA;CAAE,GACpD,KAAK,SAAS,WAAW,CAAC,MAAM,MAAM,CAAC,GACrC,kBAAkB,CAAC,MAAM,CAAC,EAAE,GAC5B,KAAK,SAAS;IAAE,MAAM,IAAI,MAAM,IAAI,CAAA;CAAE,GACpC,YAAY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