@flipdish/ui-library 0.41.2 → 0.43.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/dist/components/atoms/Dot/Dot.styles.cjs +1 -0
- package/dist/components/atoms/Dot/Dot.styles.cjs.map +1 -1
- package/dist/components/atoms/Dot/Dot.styles.d.ts +4 -0
- package/dist/components/atoms/Dot/Dot.styles.d.ts.map +1 -1
- package/dist/components/atoms/Dot/Dot.styles.js +1 -0
- package/dist/components/atoms/Dot/Dot.styles.js.map +1 -1
- package/dist/components/atoms/LoadingIndicator/index.cjs +5 -0
- package/dist/components/atoms/LoadingIndicator/index.cjs.map +1 -1
- package/dist/components/atoms/LoadingIndicator/index.d.ts +1 -1
- package/dist/components/atoms/LoadingIndicator/index.d.ts.map +1 -1
- package/dist/components/atoms/LoadingIndicator/index.js +5 -0
- package/dist/components/atoms/LoadingIndicator/index.js.map +1 -1
- package/dist/components/atoms/SearchInput/index.cjs +28 -2
- package/dist/components/atoms/SearchInput/index.cjs.map +1 -1
- package/dist/components/atoms/SearchInput/index.d.ts +8 -1
- package/dist/components/atoms/SearchInput/index.d.ts.map +1 -1
- package/dist/components/atoms/SearchInput/index.js +28 -2
- package/dist/components/atoms/SearchInput/index.js.map +1 -1
- package/dist/components/atoms/SocialButton/index.cjs +11 -7
- package/dist/components/atoms/SocialButton/index.cjs.map +1 -1
- package/dist/components/atoms/SocialButton/index.d.ts.map +1 -1
- package/dist/components/atoms/SocialButton/index.js +11 -7
- package/dist/components/atoms/SocialButton/index.js.map +1 -1
- package/dist/components/atoms/Tooltip/index.cjs +8 -1
- package/dist/components/atoms/Tooltip/index.cjs.map +1 -1
- package/dist/components/atoms/Tooltip/index.d.ts.map +1 -1
- package/dist/components/atoms/Tooltip/index.js +8 -1
- package/dist/components/atoms/Tooltip/index.js.map +1 -1
- package/dist/components/atoms/UtilityButton/index.cjs.map +1 -1
- package/dist/components/atoms/UtilityButton/index.d.ts +2 -0
- package/dist/components/atoms/UtilityButton/index.d.ts.map +1 -1
- package/dist/components/atoms/UtilityButton/index.js.map +1 -1
- package/dist/components/molecules/Breadcrumbs/components/BreadcrumbItem.cjs +16 -4
- package/dist/components/molecules/Breadcrumbs/components/BreadcrumbItem.cjs.map +1 -1
- package/dist/components/molecules/Breadcrumbs/components/BreadcrumbItem.d.ts.map +1 -1
- package/dist/components/molecules/Breadcrumbs/components/BreadcrumbItem.js +17 -5
- package/dist/components/molecules/Breadcrumbs/components/BreadcrumbItem.js.map +1 -1
- package/dist/components/molecules/ButtonGroup/index.cjs +8 -1
- package/dist/components/molecules/ButtonGroup/index.cjs.map +1 -1
- package/dist/components/molecules/ButtonGroup/index.d.ts.map +1 -1
- package/dist/components/molecules/ButtonGroup/index.js +9 -2
- package/dist/components/molecules/ButtonGroup/index.js.map +1 -1
- package/dist/components/molecules/CodeSnippet/index.cjs +8 -1
- package/dist/components/molecules/CodeSnippet/index.cjs.map +1 -1
- package/dist/components/molecules/CodeSnippet/index.d.ts.map +1 -1
- package/dist/components/molecules/CodeSnippet/index.js +8 -1
- package/dist/components/molecules/CodeSnippet/index.js.map +1 -1
- package/dist/components/molecules/Dropdown/index.cjs +10 -7
- package/dist/components/molecules/Dropdown/index.cjs.map +1 -1
- package/dist/components/molecules/Dropdown/index.d.ts.map +1 -1
- package/dist/components/molecules/Dropdown/index.js +11 -8
- package/dist/components/molecules/Dropdown/index.js.map +1 -1
- package/dist/components/molecules/EmptyState/index.cjs +3 -2
- 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 +3 -2
- package/dist/components/molecules/EmptyState/index.js.map +1 -1
- package/dist/components/molecules/Select/components/Combobox.cjs +8 -1
- package/dist/components/molecules/Select/components/Combobox.cjs.map +1 -1
- package/dist/components/molecules/Select/components/Combobox.js +8 -1
- package/dist/components/molecules/Select/components/Combobox.js.map +1 -1
- package/dist/components/molecules/Select/components/SelectItem.cjs +10 -1
- package/dist/components/molecules/Select/components/SelectItem.cjs.map +1 -1
- package/dist/components/molecules/Select/components/SelectItem.d.ts.map +1 -1
- package/dist/components/molecules/Select/components/SelectItem.js +10 -1
- package/dist/components/molecules/Select/components/SelectItem.js.map +1 -1
- package/dist/components/molecules/Select/index.cjs +11 -1
- package/dist/components/molecules/Select/index.cjs.map +1 -1
- package/dist/components/molecules/Select/index.d.ts.map +1 -1
- package/dist/components/molecules/Select/index.js +11 -1
- package/dist/components/molecules/Select/index.js.map +1 -1
- package/dist/components/molecules/Select/multiSelect.utils.cjs +5 -1
- package/dist/components/molecules/Select/multiSelect.utils.cjs.map +1 -1
- package/dist/components/molecules/Select/multiSelect.utils.d.ts.map +1 -1
- package/dist/components/molecules/Select/multiSelect.utils.js +5 -1
- package/dist/components/molecules/Select/multiSelect.utils.js.map +1 -1
- package/dist/components/molecules/Tabs/index.cjs +14 -9
- package/dist/components/molecules/Tabs/index.cjs.map +1 -1
- package/dist/components/molecules/Tabs/index.d.ts +5 -3
- package/dist/components/molecules/Tabs/index.d.ts.map +1 -1
- package/dist/components/molecules/Tabs/index.js +15 -10
- package/dist/components/molecules/Tabs/index.js.map +1 -1
- package/dist/components/molecules/Tags/Tags.styles.cjs +66 -0
- package/dist/components/molecules/Tags/Tags.styles.cjs.map +1 -0
- package/dist/components/molecules/Tags/Tags.styles.d.ts +141 -0
- package/dist/components/molecules/Tags/Tags.styles.d.ts.map +1 -0
- package/dist/components/molecules/Tags/Tags.styles.js +64 -0
- package/dist/components/molecules/Tags/Tags.styles.js.map +1 -0
- package/dist/components/molecules/Tags/components/TagCheckbox.cjs +2 -1
- package/dist/components/molecules/Tags/components/TagCheckbox.cjs.map +1 -1
- package/dist/components/molecules/Tags/components/TagCheckbox.d.ts +2 -1
- package/dist/components/molecules/Tags/components/TagCheckbox.d.ts.map +1 -1
- package/dist/components/molecules/Tags/components/TagCheckbox.js +2 -1
- package/dist/components/molecules/Tags/components/TagCheckbox.js.map +1 -1
- package/dist/components/molecules/Tags/components/TagCloseX.cjs +2 -6
- package/dist/components/molecules/Tags/components/TagCloseX.cjs.map +1 -1
- package/dist/components/molecules/Tags/components/TagCloseX.d.ts +2 -1
- package/dist/components/molecules/Tags/components/TagCloseX.d.ts.map +1 -1
- package/dist/components/molecules/Tags/components/TagCloseX.js +2 -6
- package/dist/components/molecules/Tags/components/TagCloseX.js.map +1 -1
- package/dist/components/molecules/Tags/index.cjs +18 -48
- package/dist/components/molecules/Tags/index.cjs.map +1 -1
- package/dist/components/molecules/Tags/index.d.ts +12 -3
- package/dist/components/molecules/Tags/index.d.ts.map +1 -1
- package/dist/components/molecules/Tags/index.js +18 -48
- package/dist/components/molecules/Tags/index.js.map +1 -1
- package/dist/components/molecules/VerificationCodeInput/index.cjs +1 -1
- package/dist/components/molecules/VerificationCodeInput/index.cjs.map +1 -1
- package/dist/components/molecules/VerificationCodeInput/index.js +1 -1
- package/dist/components/molecules/VerificationCodeInput/index.js.map +1 -1
- package/dist/components/organisms/ApplicationHeader/index.cjs +4 -1
- package/dist/components/organisms/ApplicationHeader/index.cjs.map +1 -1
- package/dist/components/organisms/ApplicationHeader/index.d.ts.map +1 -1
- package/dist/components/organisms/ApplicationHeader/index.js +4 -1
- package/dist/components/organisms/ApplicationHeader/index.js.map +1 -1
- package/dist/components/organisms/Calendar/calendar.utils.cjs +14 -0
- package/dist/components/organisms/Calendar/calendar.utils.cjs.map +1 -1
- package/dist/components/organisms/Calendar/calendar.utils.d.ts +7 -0
- package/dist/components/organisms/Calendar/calendar.utils.d.ts.map +1 -1
- package/dist/components/organisms/Calendar/calendar.utils.js +14 -1
- package/dist/components/organisms/Calendar/calendar.utils.js.map +1 -1
- package/dist/components/organisms/Calendar/components/CalendarDayView.cjs +1 -1
- package/dist/components/organisms/Calendar/components/CalendarDayView.cjs.map +1 -1
- package/dist/components/organisms/Calendar/components/CalendarDayView.d.ts.map +1 -1
- package/dist/components/organisms/Calendar/components/CalendarDayView.js +2 -2
- package/dist/components/organisms/Calendar/components/CalendarDayView.js.map +1 -1
- package/dist/components/organisms/Calendar/components/CalendarMonthView.cjs +12 -5
- package/dist/components/organisms/Calendar/components/CalendarMonthView.cjs.map +1 -1
- package/dist/components/organisms/Calendar/components/CalendarMonthView.d.ts.map +1 -1
- package/dist/components/organisms/Calendar/components/CalendarMonthView.js +13 -6
- package/dist/components/organisms/Calendar/components/CalendarMonthView.js.map +1 -1
- package/dist/components/organisms/Calendar/components/CalendarWeekView.cjs +1 -1
- package/dist/components/organisms/Calendar/components/CalendarWeekView.cjs.map +1 -1
- package/dist/components/organisms/Calendar/components/CalendarWeekView.d.ts.map +1 -1
- package/dist/components/organisms/Calendar/components/CalendarWeekView.js +2 -2
- package/dist/components/organisms/Calendar/components/CalendarWeekView.js.map +1 -1
- package/dist/components/organisms/Charts/components/ChartsBase.cjs +28 -13
- package/dist/components/organisms/Charts/components/ChartsBase.cjs.map +1 -1
- package/dist/components/organisms/Charts/components/ChartsBase.d.ts.map +1 -1
- package/dist/components/organisms/Charts/components/ChartsBase.js +28 -13
- package/dist/components/organisms/Charts/components/ChartsBase.js.map +1 -1
- package/dist/components/organisms/Charts/components/Metrics.cjs +1 -1
- package/dist/components/organisms/Charts/components/Metrics.cjs.map +1 -1
- package/dist/components/organisms/Charts/components/Metrics.d.ts.map +1 -1
- package/dist/components/organisms/Charts/components/Metrics.js +1 -1
- package/dist/components/organisms/Charts/components/Metrics.js.map +1 -1
- package/dist/components/organisms/ColorPicker/index.cjs +8 -5
- package/dist/components/organisms/ColorPicker/index.cjs.map +1 -1
- package/dist/components/organisms/ColorPicker/index.d.ts.map +1 -1
- package/dist/components/organisms/ColorPicker/index.js +8 -5
- package/dist/components/organisms/ColorPicker/index.js.map +1 -1
- package/dist/components/organisms/Messaging/index.cjs +23 -5
- package/dist/components/organisms/Messaging/index.cjs.map +1 -1
- package/dist/components/organisms/Messaging/index.d.ts.map +1 -1
- package/dist/components/organisms/Messaging/index.js +24 -6
- package/dist/components/organisms/Messaging/index.js.map +1 -1
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.cjs +7 -2
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.cjs.map +1 -1
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.d.ts +3 -1
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.d.ts.map +1 -1
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.js +8 -3
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.js.map +1 -1
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.cjs +121 -0
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.cjs.map +1 -0
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.d.ts +30 -0
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.d.ts.map +1 -0
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.js +119 -0
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.js.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.cjs +39 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.cjs.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.d.ts +23 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.d.ts.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.js +37 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.js.map +1 -0
- package/dist/components/organisms/SlideoutMenu/index.cjs +34 -37
- package/dist/components/organisms/SlideoutMenu/index.cjs.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.d.ts +52 -41
- package/dist/components/organisms/SlideoutMenu/index.d.ts.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.js +35 -38
- package/dist/components/organisms/SlideoutMenu/index.js.map +1 -1
- package/dist/components/organisms/SlideoutMenu/providers/OverlayBounds.context.cjs +13 -0
- package/dist/components/organisms/SlideoutMenu/providers/OverlayBounds.context.cjs.map +1 -0
- package/dist/components/organisms/SlideoutMenu/providers/OverlayBounds.context.d.ts +14 -0
- package/dist/components/organisms/SlideoutMenu/providers/OverlayBounds.context.d.ts.map +1 -0
- package/dist/components/organisms/SlideoutMenu/providers/OverlayBounds.context.js +11 -0
- package/dist/components/organisms/SlideoutMenu/providers/OverlayBounds.context.js.map +1 -0
- package/dist/components/organisms/SlideoutMenu/providers/SlideoutMenu.context.cjs +9 -0
- package/dist/components/organisms/SlideoutMenu/providers/SlideoutMenu.context.cjs.map +1 -0
- package/dist/components/organisms/SlideoutMenu/providers/SlideoutMenu.context.d.ts +13 -0
- package/dist/components/organisms/SlideoutMenu/providers/SlideoutMenu.context.d.ts.map +1 -0
- package/dist/components/organisms/SlideoutMenu/providers/SlideoutMenu.context.js +7 -0
- package/dist/components/organisms/SlideoutMenu/providers/SlideoutMenu.context.js.map +1 -0
- package/dist/components/organisms/SlideoutMenu/utilities/slideoutMenu.utils.cjs +52 -0
- package/dist/components/organisms/SlideoutMenu/utilities/slideoutMenu.utils.cjs.map +1 -0
- package/dist/components/organisms/SlideoutMenu/utilities/slideoutMenu.utils.d.ts +26 -0
- package/dist/components/organisms/SlideoutMenu/utilities/slideoutMenu.utils.d.ts.map +1 -0
- package/dist/components/organisms/SlideoutMenu/utilities/slideoutMenu.utils.js +47 -0
- package/dist/components/organisms/SlideoutMenu/utilities/slideoutMenu.utils.js.map +1 -0
- package/dist/components/organisms/Table/index.cjs +35 -5
- package/dist/components/organisms/Table/index.cjs.map +1 -1
- package/dist/components/organisms/Table/index.d.ts +8 -2
- package/dist/components/organisms/Table/index.d.ts.map +1 -1
- package/dist/components/organisms/Table/index.js +36 -6
- package/dist/components/organisms/Table/index.js.map +1 -1
- package/dist/components/organisms/Table/table.utils.cjs +37 -0
- package/dist/components/organisms/Table/table.utils.cjs.map +1 -0
- package/dist/components/organisms/Table/table.utils.d.ts +22 -0
- package/dist/components/organisms/Table/table.utils.d.ts.map +1 -0
- package/dist/components/organisms/Table/table.utils.js +33 -0
- package/dist/components/organisms/Table/table.utils.js.map +1 -0
- package/dist/components/organisms/TreeView/index.cjs +14 -7
- package/dist/components/organisms/TreeView/index.cjs.map +1 -1
- package/dist/components/organisms/TreeView/index.d.ts.map +1 -1
- package/dist/components/organisms/TreeView/index.js +14 -7
- package/dist/components/organisms/TreeView/index.js.map +1 -1
- package/dist/components/organisms/TreeView/treeView.utils.cjs +4 -1
- package/dist/components/organisms/TreeView/treeView.utils.cjs.map +1 -1
- package/dist/components/organisms/TreeView/treeView.utils.d.ts.map +1 -1
- package/dist/components/organisms/TreeView/treeView.utils.js +4 -1
- package/dist/components/organisms/TreeView/treeView.utils.js.map +1 -1
- package/dist/components/templates/AppShell/hooks/usePageAreaBounds.cjs +43 -0
- package/dist/components/templates/AppShell/hooks/usePageAreaBounds.cjs.map +1 -0
- package/dist/components/templates/AppShell/hooks/usePageAreaBounds.d.ts +12 -0
- package/dist/components/templates/AppShell/hooks/usePageAreaBounds.d.ts.map +1 -0
- package/dist/components/templates/AppShell/hooks/usePageAreaBounds.js +41 -0
- package/dist/components/templates/AppShell/hooks/usePageAreaBounds.js.map +1 -0
- package/dist/components/templates/AppShell/index.cjs +10 -6
- package/dist/components/templates/AppShell/index.cjs.map +1 -1
- package/dist/components/templates/AppShell/index.d.ts +1 -1
- package/dist/components/templates/AppShell/index.d.ts.map +1 -1
- package/dist/components/templates/AppShell/index.js +11 -7
- package/dist/components/templates/AppShell/index.js.map +1 -1
- package/dist/hooks/__internal__/useDebouncedSearch/useDebouncedSearch.cjs +56 -0
- package/dist/hooks/__internal__/useDebouncedSearch/useDebouncedSearch.cjs.map +1 -0
- package/dist/hooks/__internal__/useDebouncedSearch/useDebouncedSearch.d.ts +26 -0
- package/dist/hooks/__internal__/useDebouncedSearch/useDebouncedSearch.d.ts.map +1 -0
- package/dist/hooks/__internal__/useDebouncedSearch/useDebouncedSearch.js +54 -0
- package/dist/hooks/__internal__/useDebouncedSearch/useDebouncedSearch.js.map +1 -0
- package/dist/hooks/useDebouncedCallback/index.cjs +45 -0
- package/dist/hooks/useDebouncedCallback/index.cjs.map +1 -0
- package/dist/hooks/useDebouncedCallback/index.d.ts +18 -0
- package/dist/hooks/useDebouncedCallback/index.d.ts.map +1 -0
- package/dist/hooks/useDebouncedCallback/index.js +43 -0
- package/dist/hooks/useDebouncedCallback/index.js.map +1 -0
- package/dist/native/components/atoms/Checkbox/index.d.ts.map +1 -1
- package/dist/native/components/atoms/Checkbox/index.js +1 -1
- package/dist/native/components/atoms/Checkbox/index.js.map +1 -1
- package/dist/native/components/atoms/Dot/Dot.styles.d.ts +4 -0
- package/dist/native/components/atoms/Dot/Dot.styles.d.ts.map +1 -1
- package/dist/native/components/atoms/Dot/Dot.styles.js +1 -0
- package/dist/native/components/atoms/Dot/Dot.styles.js.map +1 -1
- package/dist/native/components/molecules/Tags/Tags.styles.d.ts +141 -0
- package/dist/native/components/molecules/Tags/Tags.styles.d.ts.map +1 -0
- package/dist/native/components/molecules/Tags/Tags.styles.js +92 -0
- package/dist/native/components/molecules/Tags/Tags.styles.js.map +1 -0
- package/dist/native/components/molecules/Tags/index.d.ts +95 -8
- package/dist/native/components/molecules/Tags/index.d.ts.map +1 -0
- package/dist/native/components/molecules/Tags/index.js +105 -0
- package/dist/native/components/molecules/Tags/index.js.map +1 -0
- package/dist/native/hooks/useDebouncedCallback/index.d.ts +18 -0
- package/dist/native/hooks/useDebouncedCallback/index.d.ts.map +1 -0
- package/dist/native/hooks/useDebouncedCallback/index.js +43 -0
- package/dist/native/hooks/useDebouncedCallback/index.js.map +1 -0
- package/dist/native/utilities/searchParamsUtils/index.d.ts +12 -0
- package/dist/utilities/searchParamsUtils/index.cjs +71 -0
- package/dist/utilities/searchParamsUtils/index.cjs.map +1 -0
- package/dist/utilities/searchParamsUtils/index.d.ts +61 -0
- package/dist/utilities/searchParamsUtils/index.d.ts.map +1 -0
- package/dist/utilities/searchParamsUtils/index.js +64 -0
- package/dist/utilities/searchParamsUtils/index.js.map +1 -0
- package/package.json +4 -2
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { Check, X, User01 } from '@flipdish/ui-icons';
|
|
3
|
+
import { Dot } from '../../atoms/Dot/index.js';
|
|
4
|
+
import { cx } from '../../../utilities/cx/index.js';
|
|
5
|
+
import { useTestIdPrefix, slugifyTestId, useResolvedTestId, TestIdProvider, joinTestId } from '../../../utilities/testIdUtils/index.js';
|
|
6
|
+
import { createContext, useContext, useState } from 'react';
|
|
7
|
+
import { Text, View, Pressable, Image } from 'react-native';
|
|
8
|
+
import { styles } from './Tags.styles.js';
|
|
9
|
+
|
|
10
|
+
/** Grows the close target outward only — a left slop would cover the end of the label. */
|
|
11
|
+
const CLOSE_HIT_SLOP = { top: 8, bottom: 8, right: 8 };
|
|
12
|
+
const TagGroupContext = createContext({
|
|
13
|
+
selectionMode: 'none',
|
|
14
|
+
size: 'sm',
|
|
15
|
+
selectedKeys: new Set(),
|
|
16
|
+
toggle: () => undefined,
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Small round avatar at the start of a native `Tag`. Same fallback behaviour as web;
|
|
20
|
+
* contrast border uses a `border` rather than CSS `outline`.
|
|
21
|
+
*
|
|
22
|
+
* @summary small round avatar for a tag (React Native)
|
|
23
|
+
*/
|
|
24
|
+
const TagAvatar = ({ src, alt, contrastBorder = true, className }) => {
|
|
25
|
+
const [isFailed, setIsFailed] = useState(false);
|
|
26
|
+
const size = styles.native.avatarSize;
|
|
27
|
+
return (jsx(View, { className: cx(styles.avatar, contrastBorder && 'border border-black/16', className), style: { width: size, height: size, borderRadius: size / 2 }, children: src && !isFailed ? (jsx(Image, { source: { uri: src }, accessibilityLabel: alt, onError: () => setIsFailed(true), style: { width: size, height: size, borderRadius: size / 2 } })) : (jsx(User01, { size: styles.native.avatarIconSize, color: styles.native.closeIconColor })) }));
|
|
28
|
+
};
|
|
29
|
+
const toKeySet = (keys) => new Set(keys ?? []);
|
|
30
|
+
/**
|
|
31
|
+
* React Native `TagGroup` — display-only, single-select, multi-select and removable
|
|
32
|
+
* tags built from `View` / `Pressable` instead of react-aria. Keyboard Backspace/Delete
|
|
33
|
+
* removal (`onRemove`) and `dotClassName` are web-only; use `onClose` per tag and
|
|
34
|
+
* `dotColor` for status-dot colour.
|
|
35
|
+
*
|
|
36
|
+
* @summary group of tags for filtering, selection or categorisation (React Native)
|
|
37
|
+
*/
|
|
38
|
+
const TagGroup = ({ label, selectionMode = 'none', size = 'sm', selectedKeys: selectedKeysProp, defaultSelectedKeys, onSelectionChange, children, className, 'data-testid': dataTestId, }) => {
|
|
39
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'tag-group', rootName: 'tag-group' });
|
|
40
|
+
const [uncontrolledKeys, setUncontrolledKeys] = useState(() => toKeySet(defaultSelectedKeys));
|
|
41
|
+
const selectedKeys = selectedKeysProp !== undefined ? toKeySet(selectedKeysProp) : uncontrolledKeys;
|
|
42
|
+
const toggle = (id) => {
|
|
43
|
+
if (selectionMode === 'none')
|
|
44
|
+
return;
|
|
45
|
+
const next = new Set(selectedKeys);
|
|
46
|
+
if (selectionMode === 'single') {
|
|
47
|
+
if (next.has(id) && next.size === 1)
|
|
48
|
+
return;
|
|
49
|
+
next.clear();
|
|
50
|
+
next.add(id);
|
|
51
|
+
}
|
|
52
|
+
else if (next.has(id)) {
|
|
53
|
+
next.delete(id);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
next.add(id);
|
|
57
|
+
}
|
|
58
|
+
if (selectedKeysProp === undefined)
|
|
59
|
+
setUncontrolledKeys(next);
|
|
60
|
+
onSelectionChange?.(next);
|
|
61
|
+
};
|
|
62
|
+
return (jsx(TagGroupContext.Provider, { value: { selectionMode, size, selectedKeys, toggle }, children: jsx(TestIdProvider, { value: rootTestId, children: jsx(View, { testID: rootTestId, accessibilityLabel: label, className: className, children: children }) }) }));
|
|
63
|
+
};
|
|
64
|
+
/** Horizontal wrapping row of tags inside a `TagGroup`. */
|
|
65
|
+
const TagList = ({ children, className }) => jsx(View, { className: cx('flex flex-row flex-wrap gap-2', className), children: children });
|
|
66
|
+
// Check icon is authored at 24px; web's 14px viewBox used stroke 2 → 24/7 for equivalent weight.
|
|
67
|
+
const CHECK_STROKE = 24 / 7;
|
|
68
|
+
/**
|
|
69
|
+
* React Native `Tag` — optional avatar or status dot, count, selection checkbox and
|
|
70
|
+
* remove button. Selection and close use `Pressable`; label colour is a light-mode hex
|
|
71
|
+
* because `Text` ignores `className` under the current `react-native-css` preview.
|
|
72
|
+
*
|
|
73
|
+
* @summary single tag with optional adornments and selection (React Native)
|
|
74
|
+
*/
|
|
75
|
+
const Tag = ({ id, avatarSrc, avatarContrastBorder = true, dot, dotColor = 'fg-success-secondary', isDisabled, count, className, children, onClose, 'data-testid': dataTestId, }) => {
|
|
76
|
+
const context = useContext(TagGroupContext);
|
|
77
|
+
const prefix = useTestIdPrefix();
|
|
78
|
+
const idPart = slugifyTestId(String(id));
|
|
79
|
+
const tagTestId = dataTestId ?? (prefix ? joinTestId(prefix, `tag-${idPart}`) : undefined);
|
|
80
|
+
const closeTestId = tagTestId ? `${tagTestId}-close` : undefined;
|
|
81
|
+
const isSelected = context.selectedKeys.has(id);
|
|
82
|
+
const inSelectionGroup = context.selectionMode !== 'none';
|
|
83
|
+
const sizeStyles = styles.sizes[context.size];
|
|
84
|
+
const [closePressed, setClosePressed] = useState(false);
|
|
85
|
+
const renderLeadingContent = () => {
|
|
86
|
+
if (avatarSrc)
|
|
87
|
+
return jsx(TagAvatar, { src: avatarSrc, alt: "Avatar", contrastBorder: avatarContrastBorder });
|
|
88
|
+
if (dot)
|
|
89
|
+
return jsx(Dot, { color: dotColor, size: "sm" });
|
|
90
|
+
return null;
|
|
91
|
+
};
|
|
92
|
+
const leadingContent = renderLeadingContent();
|
|
93
|
+
const labelNode = typeof children === 'string' || typeof children === 'number' ? (jsx(Text, { style: { color: styles.native.labelColor, fontWeight: '500', ...styles.native.labelText[context.size] }, children: children })) : (children);
|
|
94
|
+
const body = (jsxs(Fragment, { children: [jsxs(View, { className: cx('flex flex-row items-center gap-1', sizeStyles.content), children: [context.selectionMode !== 'none' && (jsx(View, { className: cx('items-center justify-center rounded border border-primary bg-primary', styles.checkbox[context.size].root, isSelected && 'border-brand-solid bg-brand-solid', isDisabled && 'opacity-50', isDisabled && !isSelected && 'bg-tertiary'), children: isSelected ? (jsx(Check, { size: styles.native.checkIconSize[context.size], color: styles.native.checkColor, strokeWidth: CHECK_STROKE })) : null })), leadingContent, labelNode, typeof count === 'number' && (jsx(View, { className: cx(styles.count, sizeStyles.count), children: jsx(Text, { style: { color: styles.native.labelColor, fontWeight: '500', ...styles.native.countText[context.size] }, children: count }) }))] }), onClose && (jsx(Pressable, { testID: closeTestId, accessibilityRole: "button", accessibilityLabel: "Remove this tag", disabled: isDisabled, hitSlop: CLOSE_HIT_SLOP, onPress: () => onClose(String(id)), onPressIn: () => setClosePressed(true), onPressOut: () => setClosePressed(false), className: cx('items-center justify-center rounded-[3px]', styles.close[context.size].root, closePressed && 'bg-primary_hover'), children: jsx(X, { size: styles.native.closeIconSize[context.size], color: closePressed ? styles.native.closeIconColorPressed : styles.native.closeIconColor, strokeWidth: styles.native.closeIconStroke[context.size] }) }))] }));
|
|
95
|
+
const rootClassName = cx(styles.rootNative, sizeStyles.root.base, avatarSrc && sizeStyles.root.withAvatar, onClose && sizeStyles.root.withClose, dot && sizeStyles.root.withDot, typeof count === 'number' && sizeStyles.root.withCount, inSelectionGroup && sizeStyles.root.withCheckbox, className);
|
|
96
|
+
// Keep Pressable (with `disabled`) for any selectable group so a disabled+selected tag
|
|
97
|
+
// still exposes checkbox role and checked state; plain View only when display-only.
|
|
98
|
+
if (inSelectionGroup) {
|
|
99
|
+
return (jsx(Pressable, { testID: tagTestId, disabled: isDisabled, onPress: () => context.toggle(id), accessibilityRole: "checkbox", accessibilityState: { checked: isSelected, disabled: Boolean(isDisabled) }, className: rootClassName, children: body }));
|
|
100
|
+
}
|
|
101
|
+
return (jsx(View, { testID: tagTestId, accessibilityState: { disabled: Boolean(isDisabled) }, className: rootClassName, children: body }));
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export { Tag, TagAvatar, TagGroup, TagList };
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/components/molecules/Tags/index.native.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","_Fragment","XClose"],"mappings":";;;;;;;;;AAQA;AACA,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;AA4BtD,MAAM,eAAe,GAAG,aAAa,CAAuB;AAC1D,IAAA,aAAa,EAAE,MAAM;AACrB,IAAA,IAAI,EAAE,IAAI;IACV,YAAY,EAAE,IAAI,GAAG,EAAE;AACvB,IAAA,MAAM,EAAE,MAAM,SAAS;AACxB,CAAA,CAAC;AAaF;;;;;AAKG;AACI,MAAM,SAAS,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,EAAE,SAAS,EAAkB,KAAI;IAC1F,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AAC/C,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU;IAErC,QACEA,GAAA,CAAC,IAAI,EAAA,EACH,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,IAAI,wBAAwB,EAAE,SAAS,CAAC,EACnF,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,GAAG,CAAC,EAAE,EAAA,QAAA,EAE3D,GAAG,IAAI,CAAC,QAAQ,IACfA,GAAA,CAAC,KAAK,EAA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AAC,IAAI,CAAC,SAAS,EACtD,gBAAgB,IAAI,UAAU,CAAC,IAAI,CAAC,YAAY,EAChD,SAAS,CACV;;;IAID,IAAI,gBAAgB,EAAE;QACpB,QACEH,IAAC,SAAS,EAAA,EACR,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EACjC,iBAAiB,EAAC,UAAU,EAC5B,kBAAkB,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,EAC1E,SAAS,EAAE,aAAa,EAAA,QAAA,EAEvB,IAAI,EAAA,CACK;IAEhB;IAEA,QACEA,GAAA,CAAC,IAAI,EAAA,EAAC,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,aAAa,EAAA,QAAA,EACrG,IAAI,EAAA,CACA;AAEX;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The debounced function, plus controls for the call it is holding back. */
|
|
2
|
+
export type DebouncedCallback<Args extends unknown[]> = ((...args: Args) => void) & {
|
|
3
|
+
/** Runs the pending call now, if there is one. */
|
|
4
|
+
flush: () => void;
|
|
5
|
+
/** Drops the pending call. */
|
|
6
|
+
cancel: () => void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Delays a callback until calls stop for `delay` milliseconds, so only the last of a burst runs, such as a search request
|
|
10
|
+
* after typing pauses. The returned function keeps its identity across renders and always calls the latest `callback`.
|
|
11
|
+
*
|
|
12
|
+
* @param callback - What to run with the last call's arguments once the calls stop.
|
|
13
|
+
* @param delay - How long the calls must stop for, in milliseconds.
|
|
14
|
+
* @returns The debounced function, with `flush` to run the pending call at once and `cancel` to drop it. A pending call is
|
|
15
|
+
* dropped on unmount.
|
|
16
|
+
*/
|
|
17
|
+
export declare const useDebouncedCallback: <Args extends unknown[]>(callback: (...args: Args) => void, delay?: number) => DebouncedCallback<Args>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDebouncedCallback/index.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,MAAM,MAAM,iBAAiB,CAAC,IAAI,SAAS,OAAO,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,GAAG;IAClF,kDAAkD;IAClD,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,8BAA8B;IAC9B,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAAI,IAAI,SAAS,OAAO,EAAE,EAAE,UAAU,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,EAAE,cAAW,KAAG,iBAAiB,CAAC,IAAI,CA8BnI,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useRef, useMemo, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Delays a callback until calls stop for `delay` milliseconds, so only the last of a burst runs, such as a search request
|
|
5
|
+
* after typing pauses. The returned function keeps its identity across renders and always calls the latest `callback`.
|
|
6
|
+
*
|
|
7
|
+
* @param callback - What to run with the last call's arguments once the calls stop.
|
|
8
|
+
* @param delay - How long the calls must stop for, in milliseconds.
|
|
9
|
+
* @returns The debounced function, with `flush` to run the pending call at once and `cancel` to drop it. A pending call is
|
|
10
|
+
* dropped on unmount.
|
|
11
|
+
*/
|
|
12
|
+
const useDebouncedCallback = (callback, delay = 300) => {
|
|
13
|
+
const callbackRef = useRef(callback);
|
|
14
|
+
callbackRef.current = callback;
|
|
15
|
+
const delayRef = useRef(delay);
|
|
16
|
+
delayRef.current = delay;
|
|
17
|
+
const timer = useRef(undefined);
|
|
18
|
+
const pending = useRef(undefined);
|
|
19
|
+
const debounced = useMemo(() => {
|
|
20
|
+
const cancel = () => {
|
|
21
|
+
clearTimeout(timer.current);
|
|
22
|
+
timer.current = undefined;
|
|
23
|
+
pending.current = undefined;
|
|
24
|
+
};
|
|
25
|
+
const flush = () => {
|
|
26
|
+
const args = pending.current;
|
|
27
|
+
cancel();
|
|
28
|
+
if (args)
|
|
29
|
+
callbackRef.current(...args);
|
|
30
|
+
};
|
|
31
|
+
const call = (...args) => {
|
|
32
|
+
pending.current = args;
|
|
33
|
+
clearTimeout(timer.current);
|
|
34
|
+
timer.current = setTimeout(flush, delayRef.current);
|
|
35
|
+
};
|
|
36
|
+
return Object.assign(call, { flush, cancel });
|
|
37
|
+
}, []);
|
|
38
|
+
useEffect(() => debounced.cancel, [debounced]);
|
|
39
|
+
return debounced;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { useDebouncedCallback };
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/hooks/useDebouncedCallback/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAUA;;;;;;;;AAQG;AACI,MAAM,oBAAoB,GAAG,CAAyB,QAAiC,EAAE,KAAK,GAAG,GAAG,KAA6B;AACtI,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC;AACpC,IAAA,WAAW,CAAC,OAAO,GAAG,QAAQ;AAC9B,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC;AAC9B,IAAA,QAAQ,CAAC,OAAO,GAAG,KAAK;AACxB,IAAA,MAAM,KAAK,GAAG,MAAM,CAA4C,SAAS,CAAC;AAC1E,IAAA,MAAM,OAAO,GAAG,MAAM,CAAmB,SAAS,CAAC;AAEnD,IAAA,MAAM,SAAS,GAAG,OAAO,CAAC,MAAK;QAC7B,MAAM,MAAM,GAAG,MAAK;AAClB,YAAA,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC;AAC3B,YAAA,KAAK,CAAC,OAAO,GAAG,SAAS;AACzB,YAAA,OAAO,CAAC,OAAO,GAAG,SAAS;AAC7B,QAAA,CAAC;QACD,MAAM,KAAK,GAAG,MAAK;AACjB,YAAA,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO;AAC5B,YAAA,MAAM,EAAE;AACR,YAAA,IAAI,IAAI;AAAE,gBAAA,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;AACxC,QAAA,CAAC;AACD,QAAA,MAAM,IAAI,GAAG,CAAC,GAAG,IAAU,KAAI;AAC7B,YAAA,OAAO,CAAC,OAAO,GAAG,IAAI;AACtB,YAAA,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC;YAC3B,KAAK,CAAC,OAAO,GAAG,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC;AACrD,QAAA,CAAC;AACD,QAAA,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC/C,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,SAAS,CAAC,MAAM,SAAS,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC;AAE9C,IAAA,OAAO,SAAS;AAClB;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `searchParamsUtils` has no React Native implementation.
|
|
3
|
+
*
|
|
4
|
+
* This is a generated types-only stub (scripts/emit-native-stubs.mjs). It exists so
|
|
5
|
+
* that importing `@flipdish/ui-library/utilities/searchParamsUtils` from React Native fails at
|
|
6
|
+
* compile time rather than resolving to the web build's types. There is no
|
|
7
|
+
* matching `index.js`, so Metro cannot bundle this module either.
|
|
8
|
+
*
|
|
9
|
+
* To make `searchParamsUtils` available on React Native, add an `index.native.tsx` beside
|
|
10
|
+
* its `index.tsx` — the build picks it up automatically and this stub disappears.
|
|
11
|
+
*/
|
|
12
|
+
export declare const __NO_REACT_NATIVE_IMPLEMENTATION__: never;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The search param names every list page uses for its view tab, search, table sort, page and page size, so links and
|
|
5
|
+
* analytics read the same across apps. A page adds its own params, such as a filter or the open record, beside them.
|
|
6
|
+
*/
|
|
7
|
+
const LIST_PARAMS = {
|
|
8
|
+
view: 'view',
|
|
9
|
+
search: 'q',
|
|
10
|
+
sort: 'sort',
|
|
11
|
+
page: 'page',
|
|
12
|
+
pageSize: 'pageSize',
|
|
13
|
+
};
|
|
14
|
+
function parseEnumParam(value, allowed, fallback) {
|
|
15
|
+
return value !== null && allowed.includes(value) ? value : fallback;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Reads a page number out of a search param.
|
|
19
|
+
* @param value - The param's value, `null` when it is absent.
|
|
20
|
+
* @returns A whole number of at least 1; anything absent, fractional, negative or not a number is page 1.
|
|
21
|
+
*/
|
|
22
|
+
const parsePageParam = (value) => {
|
|
23
|
+
const page = Number(value);
|
|
24
|
+
return Number.isInteger(page) && page > 1 ? page : 1;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Reads a page size out of a search param, accepting only the sizes the page offers.
|
|
28
|
+
* @param value - The param's value, `null` when it is absent.
|
|
29
|
+
* @param allowed - The page sizes the pager's selector offers.
|
|
30
|
+
* @param fallback - The size to use when the value is absent or not one of `allowed`.
|
|
31
|
+
* @returns The page size.
|
|
32
|
+
*/
|
|
33
|
+
const parsePageSizeParam = (value, allowed, fallback) => {
|
|
34
|
+
const size = Number(value);
|
|
35
|
+
return value !== null && allowed.includes(size) ? size : fallback;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Reads a table sort out of a search param written by `sortToParam`: the column id, with a leading `-` for descending.
|
|
39
|
+
* @param value - The param's value, `null` when it is absent.
|
|
40
|
+
* @param columns - The columns that can be sorted.
|
|
41
|
+
* @param fallback - The sort to use when the value is absent or names a column that cannot be sorted.
|
|
42
|
+
* @returns The sort the value describes, or `fallback`.
|
|
43
|
+
*/
|
|
44
|
+
const parseSortParam = (value, columns, fallback) => {
|
|
45
|
+
if (!value)
|
|
46
|
+
return fallback;
|
|
47
|
+
const descending = value.startsWith('-');
|
|
48
|
+
const column = parseEnumParam(descending ? value.slice(1) : value, columns, null);
|
|
49
|
+
return column === null ? fallback : { column, direction: descending ? 'descending' : 'ascending' };
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Writes a table sort as a search param value: the column id, with a leading `-` for descending, e.g. `-name`.
|
|
53
|
+
* @param sort - The table's sort; any `{ column, direction }`, such as react-aria's `SortDescriptor`.
|
|
54
|
+
* @param fallback - The page's default sort, which stays out of the URL.
|
|
55
|
+
* @returns The param value, or `null` when the sort is the default and the param should be left out.
|
|
56
|
+
*/
|
|
57
|
+
const sortToParam = (sort, fallback) => {
|
|
58
|
+
if (sort.column === undefined)
|
|
59
|
+
return null;
|
|
60
|
+
if (fallback && sort.column === fallback.column && sort.direction === fallback.direction)
|
|
61
|
+
return null;
|
|
62
|
+
return `${sort.direction === 'descending' ? '-' : ''}${String(sort.column)}`;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.LIST_PARAMS = LIST_PARAMS;
|
|
66
|
+
exports.parseEnumParam = parseEnumParam;
|
|
67
|
+
exports.parsePageParam = parsePageParam;
|
|
68
|
+
exports.parsePageSizeParam = parsePageSizeParam;
|
|
69
|
+
exports.parseSortParam = parseSortParam;
|
|
70
|
+
exports.sortToParam = sortToParam;
|
|
71
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/searchParamsUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;AACI,MAAM,WAAW,GAAG;AACzB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,MAAM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AAW,GAAG,CAAC,IAA8C,EAAE,QAAiD,KAAmB;AAC9I,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;AAAE,QAAA,OAAO,IAAI;AAC1C,IAAA,IAAI,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,SAAS;AAAE,QAAA,OAAO,IAAI;IACrG,OAAO,CAAA,EAAG,IAAI,CAAC,SAAS,KAAK,YAAY,GAAG,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,CAAE;AAC9E;;;;;;;"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The search param names every list page uses for its view tab, search, table sort, page and page size, so links and
|
|
3
|
+
* analytics read the same across apps. A page adds its own params, such as a filter or the open record, beside them.
|
|
4
|
+
*/
|
|
5
|
+
export declare const LIST_PARAMS: {
|
|
6
|
+
readonly view: "view";
|
|
7
|
+
readonly search: "q";
|
|
8
|
+
readonly sort: "sort";
|
|
9
|
+
readonly page: "page";
|
|
10
|
+
readonly pageSize: "pageSize";
|
|
11
|
+
};
|
|
12
|
+
/** A table sort, the same shape as react-aria's `SortDescriptor`, so a parsed value can go straight to `Table` `sortDescriptor`. */
|
|
13
|
+
export interface SortParam<Column extends string> {
|
|
14
|
+
column: Column;
|
|
15
|
+
direction: 'ascending' | 'descending';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Reads one of a fixed set of values, such as a view tab or a role, out of a search param.
|
|
19
|
+
* @param value - The param's value, `null` when it is absent.
|
|
20
|
+
* @param allowed - Every value the page understands.
|
|
21
|
+
* @param fallback - What to use when the value is absent or not one of `allowed`.
|
|
22
|
+
* @returns The value when it is allowed, else `fallback`. A URL is user input, so nothing else gets through.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseEnumParam<T extends string>(value: string | null, allowed: readonly T[], fallback: T): T;
|
|
25
|
+
export declare function parseEnumParam<T extends string>(value: string | null, allowed: readonly T[], fallback: null): T | null;
|
|
26
|
+
/**
|
|
27
|
+
* Reads a page number out of a search param.
|
|
28
|
+
* @param value - The param's value, `null` when it is absent.
|
|
29
|
+
* @returns A whole number of at least 1; anything absent, fractional, negative or not a number is page 1.
|
|
30
|
+
*/
|
|
31
|
+
export declare const parsePageParam: (value: string | null) => number;
|
|
32
|
+
/**
|
|
33
|
+
* Reads a page size out of a search param, accepting only the sizes the page offers.
|
|
34
|
+
* @param value - The param's value, `null` when it is absent.
|
|
35
|
+
* @param allowed - The page sizes the pager's selector offers.
|
|
36
|
+
* @param fallback - The size to use when the value is absent or not one of `allowed`.
|
|
37
|
+
* @returns The page size.
|
|
38
|
+
*/
|
|
39
|
+
export declare const parsePageSizeParam: (value: string | null, allowed: readonly number[], fallback: number) => number;
|
|
40
|
+
/**
|
|
41
|
+
* Reads a table sort out of a search param written by `sortToParam`: the column id, with a leading `-` for descending.
|
|
42
|
+
* @param value - The param's value, `null` when it is absent.
|
|
43
|
+
* @param columns - The columns that can be sorted.
|
|
44
|
+
* @param fallback - The sort to use when the value is absent or names a column that cannot be sorted.
|
|
45
|
+
* @returns The sort the value describes, or `fallback`.
|
|
46
|
+
*/
|
|
47
|
+
export declare const parseSortParam: <Column extends string>(value: string | null, columns: readonly Column[], fallback: SortParam<Column>) => SortParam<Column>;
|
|
48
|
+
/**
|
|
49
|
+
* Writes a table sort as a search param value: the column id, with a leading `-` for descending, e.g. `-name`.
|
|
50
|
+
* @param sort - The table's sort; any `{ column, direction }`, such as react-aria's `SortDescriptor`.
|
|
51
|
+
* @param fallback - The page's default sort, which stays out of the URL.
|
|
52
|
+
* @returns The param value, or `null` when the sort is the default and the param should be left out.
|
|
53
|
+
*/
|
|
54
|
+
export declare const sortToParam: (sort: {
|
|
55
|
+
column?: unknown;
|
|
56
|
+
direction?: string;
|
|
57
|
+
}, fallback?: {
|
|
58
|
+
column: unknown;
|
|
59
|
+
direction: string;
|
|
60
|
+
}) => string | null;
|
|
61
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/searchParamsUtils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;CAMd,CAAC;AAEX,oIAAoI;AACpI,MAAM,WAAW,SAAS,CAAC,MAAM,SAAS,MAAM;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,WAAW,GAAG,YAAY,CAAC;CACvC;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;AAC9G,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC;AAKxH;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,GAAG,IAAI,KAAG,MAGrD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,GAAG,IAAI,EAAE,SAAS,SAAS,MAAM,EAAE,EAAE,UAAU,MAAM,KAAG,MAGvG,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,SAAS,MAAM,EAClD,OAAO,MAAM,GAAG,IAAI,EACpB,SAAS,SAAS,MAAM,EAAE,EAC1B,UAAU,SAAS,CAAC,MAAM,CAAC,KAC1B,SAAS,CAAC,MAAM,CAKlB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,WAAW;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,KAAG,MAAM,GAAG,IAIxI,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The search param names every list page uses for its view tab, search, table sort, page and page size, so links and
|
|
3
|
+
* analytics read the same across apps. A page adds its own params, such as a filter or the open record, beside them.
|
|
4
|
+
*/
|
|
5
|
+
const LIST_PARAMS = {
|
|
6
|
+
view: 'view',
|
|
7
|
+
search: 'q',
|
|
8
|
+
sort: 'sort',
|
|
9
|
+
page: 'page',
|
|
10
|
+
pageSize: 'pageSize',
|
|
11
|
+
};
|
|
12
|
+
function parseEnumParam(value, allowed, fallback) {
|
|
13
|
+
return value !== null && allowed.includes(value) ? value : fallback;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Reads a page number out of a search param.
|
|
17
|
+
* @param value - The param's value, `null` when it is absent.
|
|
18
|
+
* @returns A whole number of at least 1; anything absent, fractional, negative or not a number is page 1.
|
|
19
|
+
*/
|
|
20
|
+
const parsePageParam = (value) => {
|
|
21
|
+
const page = Number(value);
|
|
22
|
+
return Number.isInteger(page) && page > 1 ? page : 1;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Reads a page size out of a search param, accepting only the sizes the page offers.
|
|
26
|
+
* @param value - The param's value, `null` when it is absent.
|
|
27
|
+
* @param allowed - The page sizes the pager's selector offers.
|
|
28
|
+
* @param fallback - The size to use when the value is absent or not one of `allowed`.
|
|
29
|
+
* @returns The page size.
|
|
30
|
+
*/
|
|
31
|
+
const parsePageSizeParam = (value, allowed, fallback) => {
|
|
32
|
+
const size = Number(value);
|
|
33
|
+
return value !== null && allowed.includes(size) ? size : fallback;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Reads a table sort out of a search param written by `sortToParam`: the column id, with a leading `-` for descending.
|
|
37
|
+
* @param value - The param's value, `null` when it is absent.
|
|
38
|
+
* @param columns - The columns that can be sorted.
|
|
39
|
+
* @param fallback - The sort to use when the value is absent or names a column that cannot be sorted.
|
|
40
|
+
* @returns The sort the value describes, or `fallback`.
|
|
41
|
+
*/
|
|
42
|
+
const parseSortParam = (value, columns, fallback) => {
|
|
43
|
+
if (!value)
|
|
44
|
+
return fallback;
|
|
45
|
+
const descending = value.startsWith('-');
|
|
46
|
+
const column = parseEnumParam(descending ? value.slice(1) : value, columns, null);
|
|
47
|
+
return column === null ? fallback : { column, direction: descending ? 'descending' : 'ascending' };
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Writes a table sort as a search param value: the column id, with a leading `-` for descending, e.g. `-name`.
|
|
51
|
+
* @param sort - The table's sort; any `{ column, direction }`, such as react-aria's `SortDescriptor`.
|
|
52
|
+
* @param fallback - The page's default sort, which stays out of the URL.
|
|
53
|
+
* @returns The param value, or `null` when the sort is the default and the param should be left out.
|
|
54
|
+
*/
|
|
55
|
+
const sortToParam = (sort, fallback) => {
|
|
56
|
+
if (sort.column === undefined)
|
|
57
|
+
return null;
|
|
58
|
+
if (fallback && sort.column === fallback.column && sort.direction === fallback.direction)
|
|
59
|
+
return null;
|
|
60
|
+
return `${sort.direction === 'descending' ? '-' : ''}${String(sort.column)}`;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export { LIST_PARAMS, parseEnumParam, parsePageParam, parsePageSizeParam, parseSortParam, sortToParam };
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utilities/searchParamsUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;AAGG;AACI,MAAM,WAAW,GAAG;AACzB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,MAAM,EAAE,GAAG;AACX,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,IAAI,EA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,IAAI,CAAC,MAAM,KAAK,SAAS;AAAE,QAAA,OAAO,IAAI;AAC1C,IAAA,IAAI,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,SAAS;AAAE,QAAA,OAAO,IAAI;IACrG,OAAO,CAAA,EAAG,IAAI,CAAC,SAAS,KAAK,YAAY,GAAG,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,CAAE;AAC9E;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flipdish/ui-library",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"description": "Flipdish Design System — atomic-design component library (Tailwind v4 + UntitledUI + React Aria).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"imports": {
|
|
@@ -230,9 +230,10 @@
|
|
|
230
230
|
"@storybook/addon-a11y": "^10.5.8",
|
|
231
231
|
"@storybook/addon-docs": "^10.5.8",
|
|
232
232
|
"@storybook/addon-mcp": "^0.7.0",
|
|
233
|
-
"@storybook/addon-vitest": "10.6.
|
|
233
|
+
"@storybook/addon-vitest": "10.6.3",
|
|
234
234
|
"@storybook/react-vite": "^10.5.8",
|
|
235
235
|
"@tailwindcss/vite": "^4.3.1",
|
|
236
|
+
"@tanstack/react-query": "^5.104.3",
|
|
236
237
|
"@testing-library/jest-dom": "^6.9.1",
|
|
237
238
|
"@testing-library/react": "^16.3.2",
|
|
238
239
|
"@tiptap/core": "^3.27.1",
|
|
@@ -258,6 +259,7 @@
|
|
|
258
259
|
"motion": "^12.40.0",
|
|
259
260
|
"nativewind": "^5.0.0-rc.0",
|
|
260
261
|
"playwright": "^1.61.1",
|
|
262
|
+
"prettier": "^3.9.10",
|
|
261
263
|
"qr-code-styling": "^1.9.2",
|
|
262
264
|
"react": "^19.0.0",
|
|
263
265
|
"react-aria": "3.50.0",
|