@flipdish/ui-library 0.42.0 → 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/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/index.cjs +8 -1
- package/dist/components/molecules/Tags/index.cjs.map +1 -1
- package/dist/components/molecules/Tags/index.d.ts.map +1 -1
- package/dist/components/molecules/Tags/index.js +8 -1
- 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/molecules/Tags/index.d.ts.map +1 -1
- package/dist/native/components/molecules/Tags/index.js +8 -1
- package/dist/native/components/molecules/Tags/index.js.map +1 -1
- 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 +3 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useDebouncedCallback } from '@flipdish/ui-library/hooks/useDebouncedCallback';
|
|
2
|
+
import { useState, useRef, useLayoutEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Keeps a search box's own draft so typing stays instant, and commits it to the owner once typing pauses, on submit, or on
|
|
6
|
+
* clear. A `value` changed elsewhere, by Back or a reset, replaces the draft; the box's own commits coming back from the owner
|
|
7
|
+
* leave it alone, so typing carries on while a router applies a navigation as a transition.
|
|
8
|
+
*
|
|
9
|
+
* @param options The committed value, what the draft starts as, where to send commits, and the pause to wait for.
|
|
10
|
+
* @returns The draft to show, with `change` for every keystroke, `submit` to commit at once and `clear` to commit an empty search.
|
|
11
|
+
*/
|
|
12
|
+
const useDebouncedSearch = ({ value, initialValue, onChange, delay }) => {
|
|
13
|
+
const [draft, setDraft] = useState(initialValue ?? value);
|
|
14
|
+
// The last `value` reconciled, so only a change to it is acted on and the initial draft is never overwritten.
|
|
15
|
+
const committed = useRef(value);
|
|
16
|
+
// What has been sent and not yet seen come back; an array, since two commits can be in flight at once.
|
|
17
|
+
const sent = useRef([]);
|
|
18
|
+
const send = (next) => {
|
|
19
|
+
sent.current.push(next);
|
|
20
|
+
onChange(next);
|
|
21
|
+
};
|
|
22
|
+
const commit = useDebouncedCallback(send, delay);
|
|
23
|
+
// An effect, not the render body: a render React discards would still have moved the refs and dropped a pending commit.
|
|
24
|
+
// Layout timing so a reset lands before the old draft is painted.
|
|
25
|
+
useLayoutEffect(() => {
|
|
26
|
+
if (value === committed.current)
|
|
27
|
+
return;
|
|
28
|
+
committed.current = value;
|
|
29
|
+
const acknowledged = sent.current.indexOf(value);
|
|
30
|
+
if (acknowledged >= 0) {
|
|
31
|
+
// The box's own commit: the draft already shows it, or something newer typed since.
|
|
32
|
+
sent.current.splice(0, acknowledged + 1);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// Changed elsewhere: a commit still pending from typing would overwrite it.
|
|
36
|
+
commit.cancel();
|
|
37
|
+
sent.current = [];
|
|
38
|
+
setDraft(value);
|
|
39
|
+
}, [value, commit]);
|
|
40
|
+
const change = (next) => {
|
|
41
|
+
setDraft(next);
|
|
42
|
+
commit(next);
|
|
43
|
+
};
|
|
44
|
+
const submit = () => commit.flush();
|
|
45
|
+
const clear = () => {
|
|
46
|
+
commit.cancel();
|
|
47
|
+
setDraft('');
|
|
48
|
+
send('');
|
|
49
|
+
};
|
|
50
|
+
return { draft, change, submit, clear };
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { useDebouncedSearch };
|
|
54
|
+
//# sourceMappingURL=useDebouncedSearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebouncedSearch.js","sources":["../../../../src/hooks/__internal__/useDebouncedSearch/useDebouncedSearch.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAcA;;;;;;;AAOG;AACI,MAAM,kBAAkB,GAAG,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAA6B,KAAI;AACxG,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAS,YAAY,IAAI,KAAK,CAAC;;AAEjE,IAAA,MAAM,SAAS,GAAG,MAAM,CAAS,KAAK,CAAC;;AAEvC,IAAA,MAAM,IAAI,GAAG,MAAM,CAAW,EAAE,CAAC;AACjC,IAAA,MAAM,IAAI,GAAG,CAAC,IAAY,KAAI;AAC5B,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;QACvB,QAAQ,CAAC,IAAI,CAAC;AAChB,IAAA,CAAC;IACD,MAAM,MAAM,GAAG,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAC;;;IAIhD,eAAe,CAAC,MAAK;AACnB,QAAA,IAAI,KAAK,KAAK,SAAS,CAAC,OAAO;YAAE;AACjC,QAAA,SAAS,CAAC,OAAO,GAAG,KAAK;QACzB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;AAChD,QAAA,IAAI,YAAY,IAAI,CAAC,EAAE;;YAErB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC;YACxC;QACF;;QAEA,MAAM,CAAC,MAAM,EAAE;AACf,QAAA,IAAI,CAAC,OAAO,GAAG,EAAE;QACjB,QAAQ,CAAC,KAAK,CAAC;AACjB,IAAA,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEnB,IAAA,MAAM,MAAM,GAAG,CAAC,IAAY,KAAI;QAC9B,QAAQ,CAAC,IAAI,CAAC;QACd,MAAM,CAAC,IAAI,CAAC;AACd,IAAA,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,EAAE;IACnC,MAAM,KAAK,GAAG,MAAK;QACjB,MAAM,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,EAAE,CAAC;QACZ,IAAI,CAAC,EAAE,CAAC;AACV,IAAA,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE;AACzC;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Delays a callback until calls stop for `delay` milliseconds, so only the last of a burst runs, such as a search request
|
|
7
|
+
* after typing pauses. The returned function keeps its identity across renders and always calls the latest `callback`.
|
|
8
|
+
*
|
|
9
|
+
* @param callback - What to run with the last call's arguments once the calls stop.
|
|
10
|
+
* @param delay - How long the calls must stop for, in milliseconds.
|
|
11
|
+
* @returns The debounced function, with `flush` to run the pending call at once and `cancel` to drop it. A pending call is
|
|
12
|
+
* dropped on unmount.
|
|
13
|
+
*/
|
|
14
|
+
const useDebouncedCallback = (callback, delay = 300) => {
|
|
15
|
+
const callbackRef = React.useRef(callback);
|
|
16
|
+
callbackRef.current = callback;
|
|
17
|
+
const delayRef = React.useRef(delay);
|
|
18
|
+
delayRef.current = delay;
|
|
19
|
+
const timer = React.useRef(undefined);
|
|
20
|
+
const pending = React.useRef(undefined);
|
|
21
|
+
const debounced = React.useMemo(() => {
|
|
22
|
+
const cancel = () => {
|
|
23
|
+
clearTimeout(timer.current);
|
|
24
|
+
timer.current = undefined;
|
|
25
|
+
pending.current = undefined;
|
|
26
|
+
};
|
|
27
|
+
const flush = () => {
|
|
28
|
+
const args = pending.current;
|
|
29
|
+
cancel();
|
|
30
|
+
if (args)
|
|
31
|
+
callbackRef.current(...args);
|
|
32
|
+
};
|
|
33
|
+
const call = (...args) => {
|
|
34
|
+
pending.current = args;
|
|
35
|
+
clearTimeout(timer.current);
|
|
36
|
+
timer.current = setTimeout(flush, delayRef.current);
|
|
37
|
+
};
|
|
38
|
+
return Object.assign(call, { flush, cancel });
|
|
39
|
+
}, []);
|
|
40
|
+
React.useEffect(() => debounced.cancel, [debounced]);
|
|
41
|
+
return debounced;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.useDebouncedCallback = useDebouncedCallback;
|
|
45
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/hooks/useDebouncedCallback/index.ts"],"sourcesContent":[null],"names":["useRef","useMemo","useEffect"],"mappings":";;;;AAUA;;;;;;;;AAQG;AACI,MAAM,oBAAoB,GAAG,CAAyB,QAAiC,EAAE,KAAK,GAAG,GAAG,KAA6B;AACtI,IAAA,MAAM,WAAW,GAAGA,YAAM,CAAC,QAAQ,CAAC;AACpC,IAAA,WAAW,CAAC,OAAO,GAAG,QAAQ;AAC9B,IAAA,MAAM,QAAQ,GAAGA,YAAM,CAAC,KAAK,CAAC;AAC9B,IAAA,QAAQ,CAAC,OAAO,GAAG,KAAK;AACxB,IAAA,MAAM,KAAK,GAAGA,YAAM,CAA4C,SAAS,CAAC;AAC1E,IAAA,MAAM,OAAO,GAAGA,YAAM,CAAmB,SAAS,CAAC;AAEnD,IAAA,MAAM,SAAS,GAAGC,aAAO,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,IAAAC,eAAS,CAAC,MAAM,SAAS,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC;AAE9C,IAAA,OAAO,SAAS;AAClB;;"}
|
|
@@ -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,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Aa;IAC5B,0DAA0D;IAC1D,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,mEAAmE;IACnE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,oEAAoE;IACpE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oDAAoD;IACpD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uFAAuF;IACvF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,8DAA8D;IAC9D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2GAA2G;IAC3G,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AASD;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,2KAYtB,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/Checkbox/index.native.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAMjD,MAAM,WAAW,aAAa;IAC5B,0DAA0D;IAC1D,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,mEAAmE;IACnE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,oEAAoE;IACpE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oDAAoD;IACpD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uFAAuF;IACvF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,8DAA8D;IAC9D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2GAA2G;IAC3G,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AASD;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,2KAYtB,aAAa,gCAyCf,CAAC"}
|
|
@@ -32,7 +32,7 @@ const Checkbox = ({ label, hint, size = 'sm', className, isSelected: isSelectedP
|
|
|
32
32
|
setUncontrolledSelected(next);
|
|
33
33
|
onChange?.(next);
|
|
34
34
|
};
|
|
35
|
-
return (jsxs(Pressable, { testID: checkboxTestId, disabled: isDisabled, onPress: handlePress, accessibilityRole: "checkbox", hitSlop: SELECTION_CONTROL_HIT_SLOP, accessibilityLabel: getAccessibleName(ariaLabel, label), accessibilityHint: getAccessibleHint(hint), accessibilityState: { checked: isIndeterminate ? 'mixed' : isSelected, disabled: Boolean(isDisabled) }, className: cx('relative flex flex-row items-start self-start', selectionControlSizes[size].root, className), children: [
|
|
35
|
+
return (jsxs(Pressable, { testID: checkboxTestId, disabled: isDisabled, onPress: handlePress, accessibilityRole: "checkbox", hitSlop: SELECTION_CONTROL_HIT_SLOP, accessibilityLabel: getAccessibleName(ariaLabel, label), accessibilityHint: getAccessibleHint(hint), accessibilityState: { checked: isIndeterminate ? 'mixed' : isSelected, disabled: Boolean(isDisabled) }, className: cx('relative flex flex-row items-start self-start', selectionControlSizes[size].root, className), children: [jsxs(View, { className: cx('size-4 shrink-0 items-center justify-center rounded border border-primary bg-primary', size === 'md' && 'size-5 rounded-md', isFilled && 'border-brand-solid bg-brand-solid', isDisabled && 'opacity-50', isDisabled && !isFilled && 'bg-tertiary', (label || hint) && 'mt-0.5'), children: [isIndeterminate && jsx(Minus, { size: DASH_SIZE[size], color: GLYPH_COLOR, strokeWidth: GLYPH_STROKE }), !isIndeterminate && isSelected && jsx(Check, { size: CHECK_SIZE[size], color: GLYPH_COLOR, strokeWidth: GLYPH_STROKE })] }), jsx(SelectionControlText, { size: size, label: label, hint: hint })] }));
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
export { Checkbox };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../src/components/atoms/Checkbox/index.native.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AAkCA;AACA,MAAM,YAAY,GAAG,EAAE,GAAG,CAAC;AAC3B,MAAM,UAAU,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAW;AAC9C,MAAM,SAAS,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAW;AAC7C;AACA,MAAM,WAAW,GAAG,SAAS;AAE7B;;;;;;AAMG;AACI,MAAM,QAAQ,GAAG,CAAC,EACvB,KAAK,EACL,IAAI,EACJ,IAAI,GAAG,IAAI,EACX,SAAS,EACT,UAAU,EAAE,cAAc,EAC1B,eAAe,GAAG,KAAK,EACvB,eAAe,EACf,UAAU,EACV,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,aAAa,EAAE,UAAU,GACX,KAAI;AAClB,IAAA,MAAM,cAAc,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IAC3G,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC;AACjF,IAAA,MAAM,UAAU,GAAG,cAAc,IAAI,oBAAoB;AACzD,IAAA,MAAM,QAAQ,GAAG,UAAU,IAAI,eAAe;IAE9C,MAAM,WAAW,GAAG,MAAK;AACvB,QAAA,MAAM,IAAI,GAAG,CAAC,UAAU;QACxB,IAAI,cAAc,KAAK,SAAS;YAAE,uBAAuB,CAAC,IAAI,CAAC;AAC/D,QAAA,QAAQ,GAAG,IAAI,CAAC;AAClB,IAAA,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/components/atoms/Checkbox/index.native.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AAkCA;AACA,MAAM,YAAY,GAAG,EAAE,GAAG,CAAC;AAC3B,MAAM,UAAU,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAW;AAC9C,MAAM,SAAS,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAW;AAC7C;AACA,MAAM,WAAW,GAAG,SAAS;AAE7B;;;;;;AAMG;AACI,MAAM,QAAQ,GAAG,CAAC,EACvB,KAAK,EACL,IAAI,EACJ,IAAI,GAAG,IAAI,EACX,SAAS,EACT,UAAU,EAAE,cAAc,EAC1B,eAAe,GAAG,KAAK,EACvB,eAAe,EACf,UAAU,EACV,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,aAAa,EAAE,UAAU,GACX,KAAI;AAClB,IAAA,MAAM,cAAc,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IAC3G,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC;AACjF,IAAA,MAAM,UAAU,GAAG,cAAc,IAAI,oBAAoB;AACzD,IAAA,MAAM,QAAQ,GAAG,UAAU,IAAI,eAAe;IAE9C,MAAM,WAAW,GAAG,MAAK;AACvB,QAAA,MAAM,IAAI,GAAG,CAAC,UAAU;QACxB,IAAI,cAAc,KAAK,SAAS;YAAE,uBAAuB,CAAC,IAAI,CAAC;AAC/D,QAAA,QAAQ,GAAG,IAAI,CAAC;AAClB,IAAA,CAAC;AAED,IAAA,QACEA,IAAA,CAAC,SAAS,I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gCAAgC;IAChC,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAChC,gDAAgD;IAChD,mBAAmB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvC,iDAAiD;IACjD,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IAChD,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAID;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GAAI,yJAUtB,aAAa,gCAgCf,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,uBAAuB;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,2DAA2D;AAC3D,eAAO,MAAM,OAAO,GAAI,yBAAyB,YAAY,gCAAuF,CAAC;AAErJ,MAAM,WAAW,QAAS,SAAQ,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7D,sEAAsE;IACtE,EAAE,EAAE,MAAM,CAAC;IACX,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAKD;;;;;;GAMG;AACH,eAAO,MAAM,GAAG,GAAI,qIAYjB,QAAQ,gCA8GV,CAAC"}
|
|
@@ -82,7 +82,14 @@ const Tag = ({ id, avatarSrc, avatarContrastBorder = true, dot, dotColor = 'fg-s
|
|
|
82
82
|
const inSelectionGroup = context.selectionMode !== 'none';
|
|
83
83
|
const sizeStyles = styles.sizes[context.size];
|
|
84
84
|
const [closePressed, setClosePressed] = useState(false);
|
|
85
|
-
const
|
|
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();
|
|
86
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);
|
|
87
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] }) }))] }));
|
|
88
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);
|
|
@@ -1 +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,EAAA,EACJ,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EACpB,kBAAkB,EAAE,GAAG,EACvB,OAAO,EAAE,MAAM,WAAW,CAAC,IAAI,C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C,eAAe,CAAC;AAC3C,IAAA,MAAM,MAAM,GAAG,eAAe,EAAE;IAChC,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACxC,MAAM,SAAS,GAAG,UAAU,KAAK,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,CAAA,IAAA,EAAO,MAAM,CAAA,CAAE,CAAC,GAAG,SAAS,CAAC;AAC1F,IAAA,MAAM,WAAW,GAAG,SAAS,GAAG,CAAA,EAAG,SAAS,CAAA,MAAA,CAAQ,GAAG,SAAS;IAEhE,MAAM,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;AAC/C,IAAA,MAAM,gBAAgB,GAAG,OAAO,CAAC,aAAa,KAAK,MAAM;IACzD,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;IAC7C,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAEvD,MAAM,
|
|
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,CA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,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,EAAA,CACxD,EAAA,CACQ,CACb,CAAA,EAAA,CACA,CACJ;IAED,MAAM,aAAa,GAAG,EAAE,CACtB,MAAM,CAAC,UAAU,EACjB,UAAU,CAAC,IAAI,CAAC,IAAI,EACpB,SAAS,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,EACvC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,EACpC,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAC9B,OAAO,KAAK,KAAK,QAAQ,IAAI,UAAU,CAAC,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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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,EAAE,GAAG;AACX,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,QAAQ,EAAE,UAAU;;SAkBN,cAAc,CAAmB,KAAoB,EAAE,OAAqB,EAAE,QAAkB,EAAA;AAC9G,IAAA,OAAO,KAAK,KAAK,IAAI,IAAK,OAA6B,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAI,KAAW,GAAG,QAAQ;AACnG;AAEA;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,KAAoB,KAAY;AAC7D,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC;AAC1B,IAAA,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC;AACtD;AAEA;;;;;;AAMG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAoB,EAAE,OAA0B,EAAE,QAAgB,KAAY;AAC/G,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC;AAC1B,IAAA,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,QAAQ;AACnE;AAEA;;;;;;AAMG;AACI,MAAM,cAAc,GAAG,CAC5B,KAAoB,EACpB,OAA0B,EAC1B,QAA2B,KACN;AACrB,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,QAAQ;IAC3B,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;IACxC,MAAM,MAAM,GAAG,cAAc,CAAC,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC;IACjF,OAAO,MAAM,KAAK,IAAI,GAAG,QAAQ,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,YAAY,GAAG,WAAW,EAAE;AACpG;AAEA;;;;;AAKG;MACU,WAAW,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,EAAE,MAAM;AACZ,IAAA,QAAQ,EAAE,UAAU;;SAkBN,cAAc,CAAmB,KAAoB,EAAE,OAAqB,EAAE,QAAkB,EAAA;AAC9G,IAAA,OAAO,KAAK,KAAK,IAAI,IAAK,OAA6B,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAI,KAAW,GAAG,QAAQ;AACnG;AAEA;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,KAAoB,KAAY;AAC7D,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC;AAC1B,IAAA,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC;AACtD;AAEA;;;;;;AAMG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAoB,EAAE,OAA0B,EAAE,QAAgB,KAAY;AAC/G,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC;AAC1B,IAAA,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,QAAQ;AACnE;AAEA;;;;;;AAMG;AACI,MAAM,cAAc,GAAG,CAC5B,KAAoB,EACpB,OAA0B,EAC1B,QAA2B,KACN;AACrB,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,QAAQ;IAC3B,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;IACxC,MAAM,MAAM,GAAG,cAAc,CAAC,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC;IACjF,OAAO,MAAM,KAAK,IAAI,GAAG,QAAQ,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,YAAY,GAAG,WAAW,EAAE;AACpG;AAEA;;;;;AAKG;MACU,WAAW,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;;"}
|
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": {
|
|
@@ -233,6 +233,7 @@
|
|
|
233
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",
|