@servicetitan/anvil2 1.49.4 → 1.49.6
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/CHANGELOG.md +34 -0
- package/dist/{Breadcrumbs-DjR-2OEH.js → Breadcrumbs-Y6IaMoi5.js} +2 -2
- package/dist/{Breadcrumbs-DjR-2OEH.js.map → Breadcrumbs-Y6IaMoi5.js.map} +1 -1
- package/dist/Breadcrumbs.js +1 -1
- package/dist/{Calendar-BkJs1qTF.js → Calendar-B5Ednjem.js} +2 -2
- package/dist/{Calendar-BkJs1qTF.js.map → Calendar-B5Ednjem.js.map} +1 -1
- package/dist/{Calendar-WHERvu2Y.js → Calendar-Ce08LvdP.js} +2 -2
- package/dist/{Calendar-WHERvu2Y.js.map → Calendar-Ce08LvdP.js.map} +1 -1
- package/dist/Calendar.js +2 -2
- package/dist/{Checkbox-C5Qjq_tU.js → Checkbox-ByaZv8wu.js} +2 -2
- package/dist/{Checkbox-C5Qjq_tU.js.map → Checkbox-ByaZv8wu.js.map} +1 -1
- package/dist/{Checkbox-Bhjj-jM4.js → Checkbox-nE-_tWmc.js} +4 -3
- package/dist/{Checkbox-Bhjj-jM4.js.map → Checkbox-nE-_tWmc.js.map} +1 -1
- package/dist/Checkbox.js +2 -2
- package/dist/Checkbox.module-D4EgXL0i.js +27 -0
- package/dist/Checkbox.module-D4EgXL0i.js.map +1 -0
- package/dist/{Chip-X2EwdZ97.js → Chip-UqdorCE2.js} +23 -17
- package/dist/Chip-UqdorCE2.js.map +1 -0
- package/dist/Chip.js +1 -1
- package/dist/Combobox-Dy4IZDg1.js +4281 -0
- package/dist/Combobox-Dy4IZDg1.js.map +1 -0
- package/dist/Combobox.js +1 -1
- package/dist/{DataTable--vA-HttA.js → DataTable-D6MmOQF2.js} +8 -8
- package/dist/{DataTable--vA-HttA.js.map → DataTable-D6MmOQF2.js.map} +1 -1
- package/dist/{DateField-BNleIuS8.js → DateField-BxS9LZG7.js} +6 -6
- package/dist/{DateField-BNleIuS8.js.map → DateField-BxS9LZG7.js.map} +1 -1
- package/dist/DateField.js +1 -1
- package/dist/{DateFieldRange-BBgvno-_.js → DateFieldRange-BdDiHUfv.js} +7 -7
- package/dist/{DateFieldRange-BBgvno-_.js.map → DateFieldRange-BdDiHUfv.js.map} +1 -1
- package/dist/DateFieldRange.js +1 -1
- package/dist/{DateFieldSingle-Bcwkxogy.js → DateFieldSingle-CuQO3LH9.js} +7 -7
- package/dist/{DateFieldSingle-Bcwkxogy.js.map → DateFieldSingle-CuQO3LH9.js.map} +1 -1
- package/dist/DateFieldSingle.js +1 -1
- package/dist/{DateFieldYearless-DnVJaBBq.js → DateFieldYearless-2YhZmNYg.js} +3 -3
- package/dist/{DateFieldYearless-DnVJaBBq.js.map → DateFieldYearless-2YhZmNYg.js.map} +1 -1
- package/dist/DateFieldYearless.js +1 -1
- package/dist/{DateFieldYearlessRange-BivGidsU.js → DateFieldYearlessRange-CgCmvHLs.js} +3 -3
- package/dist/{DateFieldYearlessRange-BivGidsU.js.map → DateFieldYearlessRange-CgCmvHLs.js.map} +1 -1
- package/dist/DateFieldYearlessRange.js +1 -1
- package/dist/{DaysOfTheWeek-Dn6zHxpt.js → DaysOfTheWeek-DlIka9b_.js} +3 -3
- package/dist/{DaysOfTheWeek-Dn6zHxpt.js.map → DaysOfTheWeek-DlIka9b_.js.map} +1 -1
- package/dist/DaysOfTheWeek.js +1 -1
- package/dist/{Dialog-3ptbLquZ.js → Dialog-DSwvbfdW.js} +21 -62
- package/dist/Dialog-DSwvbfdW.js.map +1 -0
- package/dist/Dialog.css +29 -29
- package/dist/Dialog.js +2 -1
- package/dist/Dialog.js.map +1 -1
- package/dist/DialogCancelButton-sTEfx5kf.js +50 -0
- package/dist/DialogCancelButton-sTEfx5kf.js.map +1 -0
- package/dist/{Drawer-plkbENfI.js → Drawer-CGYcEj6d.js} +5 -4
- package/dist/{Drawer-plkbENfI.js.map → Drawer-CGYcEj6d.js.map} +1 -1
- package/dist/Drawer.js +1 -1
- package/dist/{DrawerContext-D4tWTLVf.js → DrawerContext-Cs3k160L.js} +127 -2
- package/dist/{DrawerContext-D4tWTLVf.js.map → DrawerContext-Cs3k160L.js.map} +1 -1
- package/dist/{FieldLabel-CHMCV9wX.js → FieldLabel-jqlQ1Ldh.js} +2 -2
- package/dist/{FieldLabel-CHMCV9wX.js.map → FieldLabel-jqlQ1Ldh.js.map} +1 -1
- package/dist/FieldLabel.js +1 -1
- package/dist/{InputMask-Cd01c3Tj.js → InputMask-DaN_Adz6.js} +3 -3
- package/dist/{InputMask-Cd01c3Tj.js.map → InputMask-DaN_Adz6.js.map} +1 -1
- package/dist/InputMask.js +1 -1
- package/dist/{Link-DuYh7Xl2.js → Link-DqZxs0kQ.js} +13 -4
- package/dist/Link-DqZxs0kQ.js.map +1 -0
- package/dist/Link.css +27 -19
- package/dist/Link.js +1 -1
- package/dist/Link.module-CjeOl2NH.js +14 -0
- package/dist/Link.module-CjeOl2NH.js.map +1 -0
- package/dist/{LinkButton-pIUNATNE.js → LinkButton-jb2Gc3hC.js} +5 -2
- package/dist/LinkButton-jb2Gc3hC.js.map +1 -0
- package/dist/LinkButton.js +1 -1
- package/dist/{ListView-CZ5T8bR1.js → ListView-B1I7Ii3g.js} +2 -2
- package/dist/{ListView-CZ5T8bR1.js.map → ListView-B1I7Ii3g.js.map} +1 -1
- package/dist/ListView.js +1 -1
- package/dist/{Menu-DUAfSImY.js → Menu-Cn2JJe1Y.js} +2 -2
- package/dist/{Menu-DUAfSImY.js.map → Menu-Cn2JJe1Y.js.map} +1 -1
- package/dist/Menu.js +1 -1
- package/dist/{NumberField-C62E56_v.js → NumberField-BdK4U9mW.js} +2 -2
- package/dist/{NumberField-C62E56_v.js.map → NumberField-BdK4U9mW.js.map} +1 -1
- package/dist/NumberField.js +1 -1
- package/dist/{Page-Bc8ko-eM.js → Page-C-yMjgoO.js} +7 -7
- package/dist/{Page-Bc8ko-eM.js.map → Page-C-yMjgoO.js.map} +1 -1
- package/dist/Page.js +1 -1
- package/dist/{Pagination-BHEEnNas.js → Pagination-CnF6yBr5.js} +2 -2
- package/dist/{Pagination-BHEEnNas.js.map → Pagination-CnF6yBr5.js.map} +1 -1
- package/dist/Pagination.js +1 -1
- package/dist/{Popover-CIPg_ZgX.js → Popover-CcMDyKTj.js} +2 -2
- package/dist/{Popover-CIPg_ZgX.js.map → Popover-CcMDyKTj.js.map} +1 -1
- package/dist/Popover.js +1 -1
- package/dist/{ProgressBar-CUpF9fFW.js → ProgressBar-CufkbVu5.js} +2 -2
- package/dist/{ProgressBar-CUpF9fFW.js.map → ProgressBar-CufkbVu5.js.map} +1 -1
- package/dist/ProgressBar.js +1 -1
- package/dist/{Radio-CyCFna1X.js → Radio-BeBG7Ksw.js} +2 -2
- package/dist/{Radio-CyCFna1X.js.map → Radio-BeBG7Ksw.js.map} +1 -1
- package/dist/Radio.js +2 -2
- package/dist/{RadioGroup-DRS2EjVH.js → RadioGroup-BAjpkCjp.js} +2 -2
- package/dist/{RadioGroup-DRS2EjVH.js.map → RadioGroup-BAjpkCjp.js.map} +1 -1
- package/dist/{SearchField-DrgNbG3I.js → SearchField-D6bICv4b.js} +36 -7
- package/dist/SearchField-D6bICv4b.js.map +1 -0
- package/dist/SearchField.css +13 -8
- package/dist/SearchField.js +1 -1
- package/dist/{SelectCard-lBcnP5j5.js → SelectCard-DDN7qqHv.js} +3 -3
- package/dist/{SelectCard-lBcnP5j5.js.map → SelectCard-DDN7qqHv.js.map} +1 -1
- package/dist/SelectCard.js +1 -1
- package/dist/SelectField.d.ts +2 -0
- package/dist/SelectField.js +2 -0
- package/dist/SelectField.js.map +1 -0
- package/dist/SelectFieldSync-DQm3_D0v.js +1122 -0
- package/dist/SelectFieldSync-DQm3_D0v.js.map +1 -0
- package/dist/SelectFieldSync.css +168 -0
- package/dist/{SelectTrigger-DdsBqEtU.js → SelectTrigger-CNEhRluU.js} +2 -2
- package/dist/{SelectTrigger-DdsBqEtU.js.map → SelectTrigger-CNEhRluU.js.map} +1 -1
- package/dist/SelectTrigger.js +1 -1
- package/dist/{SelectTriggerBase-BkVt3IP4.js → SelectTriggerBase-Cv6hGsrC.js} +5 -35
- package/dist/{SelectTriggerBase-BkVt3IP4.js.map → SelectTriggerBase-Cv6hGsrC.js.map} +1 -1
- package/dist/SelectTriggerBase.css +59 -59
- package/dist/SelectTriggerBase.module-Ce49lamD.js +35 -0
- package/dist/SelectTriggerBase.module-Ce49lamD.js.map +1 -0
- package/dist/Table.js +1 -1
- package/dist/{TextField-CpVkZxMT.js → TextField--y8q4R2H.js} +2 -2
- package/dist/{TextField-CpVkZxMT.js.map → TextField--y8q4R2H.js.map} +1 -1
- package/dist/{TextField-CygbgVVt.js → TextField-aMwSN1iP.js} +2 -2
- package/dist/{TextField-CygbgVVt.js.map → TextField-aMwSN1iP.js.map} +1 -1
- package/dist/TextField.js +1 -1
- package/dist/{Textarea-DacevzmW.js → Textarea-D1zwX2h6.js} +2 -2
- package/dist/{Textarea-DacevzmW.js.map → Textarea-D1zwX2h6.js.map} +1 -1
- package/dist/Textarea.js +1 -1
- package/dist/{TimeField-BkOB5ESa.js → TimeField-BHxXbOfe.js} +4 -4
- package/dist/{TimeField-BkOB5ESa.js.map → TimeField-BHxXbOfe.js.map} +1 -1
- package/dist/TimeField.js +1 -1
- package/dist/Toast.js +2 -2
- package/dist/{Toaster-nFhRAJc8.js → Toaster-CRp3nf4U.js} +2 -2
- package/dist/{Toaster-nFhRAJc8.js.map → Toaster-CRp3nf4U.js.map} +1 -1
- package/dist/{Toaster-Dx0cFQwb.js → Toaster-qPt6zb6F.js} +3 -3
- package/dist/{Toaster-Dx0cFQwb.js.map → Toaster-qPt6zb6F.js.map} +1 -1
- package/dist/{Toolbar-DuuaM0Cz.js → Toolbar-XJrmS4v4.js} +13 -13
- package/dist/{Toolbar-DuuaM0Cz.js.map → Toolbar-XJrmS4v4.js.map} +1 -1
- package/dist/Toolbar.js +1 -1
- package/dist/{Tooltip-CZsoFe6C.js → Tooltip-CBy7srE2.js} +3 -3
- package/dist/Tooltip-CBy7srE2.js.map +1 -0
- package/dist/Tooltip.js +1 -1
- package/dist/{YearlessDateInputWithPicker-MHLlAdrH.js → YearlessDateInputWithPicker-LiMI-Oer.js} +4 -4
- package/dist/{YearlessDateInputWithPicker-MHLlAdrH.js.map → YearlessDateInputWithPicker-LiMI-Oer.js.map} +1 -1
- package/dist/assets/icons/st/titan_intelligence.svg +1 -1
- package/dist/assets/icons/st/transactional.svg +1 -0
- package/dist/assets/icons/st.ts +1 -0
- package/dist/beta/components/SelectField/SelectField.d.ts +2 -0
- package/dist/beta/components/SelectField/SelectFieldSync.d.ts +39 -0
- package/dist/beta/components/SelectField/index.d.ts +3 -0
- package/dist/beta/components/SelectField/internal/FieldDialog/FieldDialog.d.ts +8 -0
- package/dist/beta/components/SelectField/internal/FieldPopover/FieldPopover.d.ts +8 -0
- package/dist/beta/components/SelectField/internal/InView.d.ts +34 -0
- package/dist/beta/components/SelectField/internal/SelectFieldInput.d.ts +64 -0
- package/dist/beta/components/SelectField/internal/SelectFieldLabel.d.ts +39 -0
- package/dist/beta/components/SelectField/internal/SelectFieldList.d.ts +26 -0
- package/dist/beta/components/SelectField/internal/SelectFieldListItem.d.ts +14 -0
- package/dist/beta/components/SelectField/internal/useCombo.d.ts +31 -0
- package/dist/beta/components/SelectField/stories/SelectField.stories.data.d.ts +32 -0
- package/dist/beta/components/SelectField/types.d.ts +275 -0
- package/dist/beta/components/Table/types.d.ts +1 -1
- package/dist/beta/components/index.d.ts +1 -0
- package/dist/beta/hooks/index.d.ts +1 -0
- package/dist/beta/hooks/useAdaptiveView.d.ts +50 -0
- package/dist/beta/index.d.ts +1 -0
- package/dist/beta.js +5 -4
- package/dist/beta.js.map +1 -1
- package/dist/components/ButtonToggle/ButtonToggle.d.ts +1 -1
- package/dist/components/Chip/Chip.d.ts +2 -1
- package/dist/components/Chip/internal/Chip.d.ts +2 -1
- package/dist/components/DateFieldRange/internal/MaskedDateRangeInput.d.ts +1 -1
- package/dist/components/DateFieldSingle/internal/MaskedDateInput.d.ts +1 -1
- package/dist/components/Link/internal/Link.d.ts +21 -2
- package/dist/components/Link/useLinkStyles.d.ts +1 -1
- package/dist/components/LinkButton/LinkButton.d.ts +13 -1
- package/dist/components/SearchField/SearchField.d.ts +6 -3
- package/dist/components/Stepper/Stepper.d.ts +1 -1
- package/dist/components/Stepper/StepperStep.d.ts +1 -1
- package/dist/components/Tab/Tab.d.ts +1 -1
- package/dist/components/Tab/TabButton.d.ts +1 -1
- package/dist/{indeterminate_check_box-RY9zr3xS.js → indeterminate_check_box-B4zobNlt.js} +2 -27
- package/dist/{indeterminate_check_box-RY9zr3xS.js.map → indeterminate_check_box-B4zobNlt.js.map} +1 -1
- package/dist/index.js +39 -38
- package/dist/index.js.map +1 -1
- package/dist/internal/hooks/index.d.ts +1 -0
- package/dist/internal/hooks/useDebouncedCallback/index.d.ts +1 -0
- package/dist/internal/hooks/useDebouncedCallback/useDebouncedCallback.d.ts +28 -0
- package/dist/internal/hooks/useSelectFieldLoading/index.d.ts +1 -0
- package/dist/internal/hooks/useSelectFieldLoading/useSelectFieldLoading.d.ts +102 -0
- package/dist/{Combobox-BO-k4QZE.js → match-sorter.esm-CtBw0MrM.js} +4 -4278
- package/dist/match-sorter.esm-CtBw0MrM.js.map +1 -0
- package/dist/useDialogScrollLock-BW-aVboo.js +41 -0
- package/dist/useDialogScrollLock-BW-aVboo.js.map +1 -0
- package/dist/{useInitialFocus-Cl_Txu7W.js → useInitialFocus-BpmW7pDB.js} +4 -41
- package/dist/useInitialFocus-BpmW7pDB.js.map +1 -0
- package/dist/{usePopoverSupport-CWTCDfN2.js → usePopoverSupport-CCSCHnit.js} +2 -2
- package/dist/{usePopoverSupport-CWTCDfN2.js.map → usePopoverSupport-CCSCHnit.js.map} +1 -1
- package/dist/{utils-aSAOVHjX.js → utils-C-hkPwMi.js} +2 -2
- package/dist/{utils-aSAOVHjX.js.map → utils-C-hkPwMi.js.map} +1 -1
- package/package.json +1 -1
- package/dist/Chip-X2EwdZ97.js.map +0 -1
- package/dist/Combobox-BO-k4QZE.js.map +0 -1
- package/dist/Dialog-3ptbLquZ.js.map +0 -1
- package/dist/Link-DuYh7Xl2.js.map +0 -1
- package/dist/Link.module-Cf17JWod.js +0 -12
- package/dist/Link.module-Cf17JWod.js.map +0 -1
- package/dist/LinkButton-pIUNATNE.js.map +0 -1
- package/dist/SearchField-DrgNbG3I.js.map +0 -1
- package/dist/Tooltip-CZsoFe6C.js.map +0 -1
- package/dist/useInitialFocus-Cl_Txu7W.js.map +0 -1
- /package/dist/{indeterminate_check_box.css → Checkbox.css} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { MatchSorterOptions } from 'match-sorter';
|
|
2
|
+
import { SelectFieldProps, SelectFieldOption } from './types';
|
|
3
|
+
export type SelectFieldSyncProps = Omit<SelectFieldProps, "loadOptions" | "lazy" | "debounceMs" | "cache" | "initialLoad"> & {
|
|
4
|
+
/**
|
|
5
|
+
* The options to display in the select field.
|
|
6
|
+
*/
|
|
7
|
+
options: SelectFieldOption[];
|
|
8
|
+
/**
|
|
9
|
+
* The filter to use to filter the options.
|
|
10
|
+
* Can be a function to filter the options, or a MatchSorterOptions object to customize the default filtering.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <SelectFieldSync
|
|
14
|
+
* options={options}
|
|
15
|
+
* filter={(options, searchValue) => {
|
|
16
|
+
* return options.filter((option) => {
|
|
17
|
+
* return option.label?.toLowerCase().includes(searchValue.toLowerCase());
|
|
18
|
+
* });
|
|
19
|
+
* }}
|
|
20
|
+
* />
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <SelectFieldSync
|
|
24
|
+
* options={options}
|
|
25
|
+
* filter={{ keys: ["label"] }}
|
|
26
|
+
* />
|
|
27
|
+
*/
|
|
28
|
+
filter?: ((options: SelectFieldOption[], searchValue: string) => SelectFieldOption[]) | MatchSorterOptions;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* SelectFieldSync is a simplified version of SelectField that is used to display a list of options in a select field.
|
|
32
|
+
*
|
|
33
|
+
* Features:
|
|
34
|
+
* - Accepts `options` instead of `loadOptions` and `lazy`.
|
|
35
|
+
* - Performs client-side filtering of the options.
|
|
36
|
+
* - Optionally accepts a function to filter the options, or a MatchSorterOptions object to customize the default filtering.
|
|
37
|
+
* - Supports all the other props of SelectField.
|
|
38
|
+
*/
|
|
39
|
+
export declare const SelectFieldSync: (props: SelectFieldSyncProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode, RefObject } from 'react';
|
|
2
|
+
export type FieldPopoverProps = {
|
|
3
|
+
id: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
referenceElement: RefObject<HTMLElement>;
|
|
6
|
+
open: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const FieldPopover: (props: FieldPopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the InView component
|
|
4
|
+
* @property {ReactNode} children - The content to render inside the visibility-tracked container
|
|
5
|
+
* @property {(isVisible: boolean) => void} [onVisibilityChange] - Callback fired when visibility changes
|
|
6
|
+
*/
|
|
7
|
+
type InViewProps = {
|
|
8
|
+
/**
|
|
9
|
+
* The content to render inside the visibility-tracked container
|
|
10
|
+
*/
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Callback fired when the element's visibility in the viewport changes
|
|
14
|
+
*/
|
|
15
|
+
onVisibilityChange?: (isVisible: boolean) => void;
|
|
16
|
+
/**
|
|
17
|
+
* The root margin for the intersection observer
|
|
18
|
+
*/
|
|
19
|
+
rootMargin?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Internal component that detects when its content is visible in the viewport.
|
|
23
|
+
*
|
|
24
|
+
* Features:
|
|
25
|
+
* - Uses Intersection Observer API for efficient visibility detection
|
|
26
|
+
* - Fires callback when visibility state changes
|
|
27
|
+
* - Handles browser compatibility gracefully
|
|
28
|
+
* - Automatically cleans up observer on unmount
|
|
29
|
+
*
|
|
30
|
+
* @param props - Component props
|
|
31
|
+
* @returns Wrapped children with visibility detection
|
|
32
|
+
*/
|
|
33
|
+
export declare const InView: ({ children, onVisibilityChange, rootMargin, }: InViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { PassThroughProps, Size } from '../../../../types';
|
|
2
|
+
import { ReactElement, RefObject } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the SelectFieldInput component
|
|
5
|
+
* @property {string} [placeholder] - Placeholder text displayed when input is empty
|
|
6
|
+
* @property {Extract<Size, "small" | "medium" | "large">} [size] - Size variant of the input
|
|
7
|
+
* @property {boolean} [disableClearButton] - Hides the clear button when true
|
|
8
|
+
* @property {boolean} [disableToggleButton] - Hides the toggle button when true
|
|
9
|
+
* @property {boolean} [disabled] - Disables the input entirely
|
|
10
|
+
* @property {boolean} [readOnly] - Cannot be modified but remains interactive
|
|
11
|
+
* @property {boolean} [error] - Shows error styling on the input when true
|
|
12
|
+
* @property {() => void} [onClear] - Callback fired when the clear button is clicked
|
|
13
|
+
* @property {string} [id] - HTML id attribute for the input element
|
|
14
|
+
* @property {string} [popoverTarget] - Target identifier for popover association
|
|
15
|
+
* @property {RefObject<HTMLDivElement>} [inputWrapperRef] - Ref for the input wrapper div element
|
|
16
|
+
* @property {PassThroughProps<"div">} [htmlInputWrapperProps] - Additional props passed to the wrapper div
|
|
17
|
+
* @property {PassThroughProps<"input">} [inputProps] - Additional props passed to the input element
|
|
18
|
+
* @property {PassThroughProps<"button">} [toggleButtonProps] - Additional props passed to the toggle button
|
|
19
|
+
* @property {string | ReactElement} [prefix] - Content to display before the input
|
|
20
|
+
* @property {string | ReactElement} [suffix] - Content to display after the input
|
|
21
|
+
*/
|
|
22
|
+
export type SelectFieldInputProps = {
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
size?: Extract<Size, "small" | "medium" | "large">;
|
|
25
|
+
disableClearButton?: boolean;
|
|
26
|
+
disableToggleButton?: boolean;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
readOnly?: boolean;
|
|
29
|
+
error?: boolean;
|
|
30
|
+
onClear?: () => void;
|
|
31
|
+
id?: string;
|
|
32
|
+
popoverTarget?: string;
|
|
33
|
+
inputWrapperRef?: RefObject<HTMLDivElement>;
|
|
34
|
+
htmlInputWrapperProps?: PassThroughProps<"div">;
|
|
35
|
+
inputProps?: PassThroughProps<"input">;
|
|
36
|
+
toggleButtonProps?: PassThroughProps<"button">;
|
|
37
|
+
prefix?: string | ReactElement;
|
|
38
|
+
suffix?: string | ReactElement;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Internal input component for the SelectField that provides the text input and action buttons.
|
|
42
|
+
*
|
|
43
|
+
* Features:
|
|
44
|
+
* - Text input for filtering and displaying selected values
|
|
45
|
+
* - Optional clear button for removing the current selection
|
|
46
|
+
* - Optional toggle button for opening/closing the dropdown menu
|
|
47
|
+
* - Supports multiple size variants (small, medium, large)
|
|
48
|
+
* - Fully accessible with proper ARIA labels on buttons
|
|
49
|
+
* - Supports pass-through props for customization of internal elements
|
|
50
|
+
* - Optional prefix and suffix content
|
|
51
|
+
* - Error state styling
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* <SelectFieldInput
|
|
55
|
+
* placeholder="Search..."
|
|
56
|
+
* size="medium"
|
|
57
|
+
* onClear={() => handleClear()}
|
|
58
|
+
* prefix="$"
|
|
59
|
+
* />
|
|
60
|
+
*/
|
|
61
|
+
export declare const SelectFieldInput: {
|
|
62
|
+
({ placeholder, size, disableClearButton, disableToggleButton, disabled, readOnly, error, onClear, id, inputWrapperRef, htmlInputWrapperProps, inputProps, toggleButtonProps, prefix, suffix, }: SelectFieldInputProps): import("react/jsx-runtime").JSX.Element;
|
|
63
|
+
displayName: string;
|
|
64
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { UseComboboxPropGetters } from 'downshift';
|
|
3
|
+
import { SelectFieldDownshiftItem } from '../types';
|
|
4
|
+
type GetLabelProps = UseComboboxPropGetters<SelectFieldDownshiftItem>["getLabelProps"];
|
|
5
|
+
/**
|
|
6
|
+
* Props for the SelectFieldLabel component
|
|
7
|
+
* @property {string} label - The text content to display as the label
|
|
8
|
+
* @property {GetLabelProps} getLabelProps - Downshift getter function that returns accessibility props for the label
|
|
9
|
+
* @property {boolean} [required] - Whether the field is required. Shows a red asterisk (*) when true.
|
|
10
|
+
* @property {ReactNode} [moreInfo] - Additional information to display in a tooltip
|
|
11
|
+
* @property {boolean} [openMoreInfo] - Controls the open state of the more info tooltip
|
|
12
|
+
*/
|
|
13
|
+
export type SelectFieldLabelProps = {
|
|
14
|
+
label: string;
|
|
15
|
+
getLabelProps: GetLabelProps;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
moreInfo?: ReactNode;
|
|
18
|
+
openMoreInfo?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Internal label component for the SelectField that renders an accessible label element.
|
|
22
|
+
*
|
|
23
|
+
* Features:
|
|
24
|
+
* - Renders a FieldLabel with proper accessibility attributes from Downshift
|
|
25
|
+
* - Automatically associates the label with the combobox input
|
|
26
|
+
* - Supports screen readers with proper labeling
|
|
27
|
+
* - Optional required field indicator with red asterisk
|
|
28
|
+
* - Help tooltip with info icon for additional context
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* <SelectFieldLabel
|
|
32
|
+
* label="Select an option"
|
|
33
|
+
* getLabelProps={getLabelProps}
|
|
34
|
+
* required
|
|
35
|
+
* moreInfo="Choose from available options"
|
|
36
|
+
* />
|
|
37
|
+
*/
|
|
38
|
+
export declare const SelectFieldLabel: ({ label, getLabelProps, required, moreInfo, openMoreInfo, }: SelectFieldLabelProps) => import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SelectFieldDownshiftItem, SelectFieldOption } from '../types';
|
|
2
|
+
import { UseComboboxPropGetters } from 'downshift';
|
|
3
|
+
import { CSSProperties } from 'react';
|
|
4
|
+
type GetMenuProps = UseComboboxPropGetters<SelectFieldDownshiftItem>["getMenuProps"];
|
|
5
|
+
type GetItemProps = UseComboboxPropGetters<SelectFieldDownshiftItem>["getItemProps"];
|
|
6
|
+
export type SelectFieldListProps = {
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
items: SelectFieldDownshiftItem[];
|
|
9
|
+
getMenuProps: GetMenuProps;
|
|
10
|
+
getItemProps: GetItemProps;
|
|
11
|
+
highlightedIndex: number;
|
|
12
|
+
selectedOption: SelectFieldOption | null;
|
|
13
|
+
hasMore: boolean;
|
|
14
|
+
onLoadMore: () => void;
|
|
15
|
+
loading: boolean;
|
|
16
|
+
loadingMore: boolean;
|
|
17
|
+
disableAutoLoadMore?: boolean;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
className?: string;
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
};
|
|
22
|
+
export declare const SelectFieldList: {
|
|
23
|
+
({ isOpen, items, getMenuProps, getItemProps, highlightedIndex, selectedOption, hasMore, onLoadMore, loading, loadingMore, disableAutoLoadMore, disabled, className, style, }: SelectFieldListProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
displayName: string;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { UseComboboxPropGetters } from 'downshift';
|
|
2
|
+
import { SelectFieldDownshiftItem } from '../types';
|
|
3
|
+
type GetItemProps = UseComboboxPropGetters<SelectFieldDownshiftItem>["getItemProps"];
|
|
4
|
+
export type SelectFieldListItemProps = {
|
|
5
|
+
item: SelectFieldDownshiftItem;
|
|
6
|
+
index: number;
|
|
7
|
+
highlighted: boolean;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
getItemProps: GetItemProps;
|
|
10
|
+
selectionType: "single" | "multiple";
|
|
11
|
+
checked: boolean | "indeterminate";
|
|
12
|
+
};
|
|
13
|
+
export declare const SelectFieldListItem: ({ item, index, highlighted, disabled, getItemProps, selectionType, checked, }: SelectFieldListItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { UseComboboxProps } from 'downshift';
|
|
2
|
+
import { SelectFieldDownshiftItem, SelectFieldOption } from '../types';
|
|
3
|
+
export type UseComboOptions = {
|
|
4
|
+
options: SelectFieldOption[];
|
|
5
|
+
pinnedOptions?: unknown;
|
|
6
|
+
selectAll?: {
|
|
7
|
+
label: string;
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
};
|
|
10
|
+
selectedOption: SelectFieldOption | null;
|
|
11
|
+
onSelectedOptionChange: (option: SelectFieldOption | null) => void;
|
|
12
|
+
displayAs: "popover" | "dialog";
|
|
13
|
+
disableHighlightOnOpen?: boolean;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
} & Pick<UseComboboxProps<SelectFieldDownshiftItem>, "onInputValueChange" | "onIsOpenChange">;
|
|
16
|
+
/**
|
|
17
|
+
* The purpose of useCombo is to provide an abstraction over the downshift combobox hook.
|
|
18
|
+
*/
|
|
19
|
+
export declare const useCombo: ({ options, pinnedOptions, selectAll, selectedOption, onSelectedOptionChange, onInputValueChange, onIsOpenChange, displayAs, disableHighlightOnOpen, disabled, }: UseComboOptions) => {
|
|
20
|
+
inputValue: string;
|
|
21
|
+
getToggleButtonProps: <Options>(options?: import('downshift').UseComboboxGetToggleButtonPropsOptions & Options) => import('downshift').Overwrite<import('downshift').UseComboboxGetToggleButtonPropsReturnValue, Options>;
|
|
22
|
+
getLabelProps: <Options>(options?: import('downshift').UseComboboxGetLabelPropsOptions & Options) => import('downshift').Overwrite<import('downshift').UseComboboxGetLabelPropsReturnValue, Options>;
|
|
23
|
+
getMenuProps: <Options>(options?: import('downshift').UseComboboxGetMenuPropsOptions & Options, otherOptions?: import('downshift').GetPropsCommonOptions) => import('downshift').Overwrite<import('downshift').UseComboboxGetMenuPropsReturnValue, Options>;
|
|
24
|
+
getInputProps: <Options>(options?: import('downshift').UseComboboxGetInputPropsOptions & Options, otherOptions?: import('downshift').GetPropsCommonOptions) => import('downshift').Overwrite<import('downshift').UseComboboxGetInputPropsReturnValue, Options>;
|
|
25
|
+
getItemProps: <Options>(options: import('downshift').UseComboboxGetItemPropsOptions<SelectFieldDownshiftItem> & Options) => Omit<import('downshift').Overwrite<import('downshift').UseComboboxGetItemPropsReturnValue, Options>, "item" | "index">;
|
|
26
|
+
highlightedIndex: number;
|
|
27
|
+
isOpen: boolean;
|
|
28
|
+
downshiftItems: SelectFieldDownshiftItem[];
|
|
29
|
+
closeMenu: () => void;
|
|
30
|
+
openMenu: () => void;
|
|
31
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SelectFieldOption, SelectFieldUngroupedOption, SelectFieldGroupedOption, SelectFieldGroupByValue } from '../types';
|
|
2
|
+
export type Book = {
|
|
3
|
+
id: string;
|
|
4
|
+
author: string;
|
|
5
|
+
title: string;
|
|
6
|
+
genre: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Small curated list of diverse books for simple examples
|
|
10
|
+
*/
|
|
11
|
+
export declare const books: Book[];
|
|
12
|
+
/**
|
|
13
|
+
* Large dataset of 300 unique books for lazy loading demonstrations
|
|
14
|
+
*/
|
|
15
|
+
export declare const allBooks: Book[];
|
|
16
|
+
export declare const sourceOptions: SelectFieldOption[];
|
|
17
|
+
export declare function filterBooks(bookList: Book[], searchValue: string): Book[];
|
|
18
|
+
export declare function mapBookToOption(book: Book): SelectFieldUngroupedOption;
|
|
19
|
+
export declare const simulateFetchingPagedBooks: (searchValue: string, pageNumber: number, pageSize: number) => Promise<{
|
|
20
|
+
data: Book[];
|
|
21
|
+
count: number;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const simulateFetchingOffsetBooks: (searchValue: string, offset: number, limit: number) => Promise<{
|
|
24
|
+
data: Book[];
|
|
25
|
+
count: number;
|
|
26
|
+
}>;
|
|
27
|
+
export type GroupByField = "genre" | "author";
|
|
28
|
+
export declare function mapBookToGroupedOption(book: Book, groupBy: GroupByField): SelectFieldGroupedOption;
|
|
29
|
+
export declare const simulateFetchingGroupedBooks: (groupBy: GroupByField) => (searchValue: string, previousGroupKey: SelectFieldGroupByValue | null) => Promise<{
|
|
30
|
+
options: SelectFieldGroupedOption[];
|
|
31
|
+
hasMore: boolean;
|
|
32
|
+
}>;
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { AriaAttributes, ReactElement } from 'react';
|
|
2
|
+
import { LayoutUtilProps, Size } from '../../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the SelectField cache.
|
|
5
|
+
* @property enabled - Whether caching is enabled. Defaults to true.
|
|
6
|
+
* @property maxSize - Maximum number of cached entries before clearing the cache. Defaults to 50.
|
|
7
|
+
*/
|
|
8
|
+
export type SelectFieldCacheOptions = {
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
maxSize?: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Imperative handle for the SelectField component.
|
|
14
|
+
* @property clearCache - Clears the options cache.
|
|
15
|
+
*/
|
|
16
|
+
export type SelectFieldHandle = {
|
|
17
|
+
clearCache: () => void;
|
|
18
|
+
};
|
|
19
|
+
export type SelectFieldGroupByValue = string | number;
|
|
20
|
+
export type SelectFieldOption = {
|
|
21
|
+
id: string | number;
|
|
22
|
+
label: string;
|
|
23
|
+
searchText?: string;
|
|
24
|
+
group?: SelectFieldGroupByValue;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
content?: {
|
|
27
|
+
title?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type SelectFieldGroupedOption = SelectFieldOption & {
|
|
32
|
+
group: SelectFieldGroupByValue;
|
|
33
|
+
};
|
|
34
|
+
export type SelectFieldUngroupedOption = Omit<SelectFieldOption, "group"> & {
|
|
35
|
+
group?: never;
|
|
36
|
+
};
|
|
37
|
+
export type SelectFieldOptionsResult = SelectFieldOption[] | Promise<SelectFieldOption[]>;
|
|
38
|
+
export type SelectFieldEagerLoader = (searchValue: string) => SelectFieldOptionsResult;
|
|
39
|
+
export type SelectFieldOffsetLazyResult = {
|
|
40
|
+
options: SelectFieldUngroupedOption[];
|
|
41
|
+
hasMore?: boolean;
|
|
42
|
+
};
|
|
43
|
+
export type SelectFieldOffsetLazyLoader = (searchValue: string, offset: number, limit: number) => SelectFieldOffsetLazyResult | Promise<SelectFieldOffsetLazyResult>;
|
|
44
|
+
export type SelectFieldPageLazyResult = {
|
|
45
|
+
options: SelectFieldUngroupedOption[];
|
|
46
|
+
hasMore?: boolean;
|
|
47
|
+
};
|
|
48
|
+
export type SelectFieldPageLazyLoader = (searchValue: string, pageNumber: number, pageSize: number) => SelectFieldPageLazyResult | Promise<SelectFieldPageLazyResult>;
|
|
49
|
+
export type SelectFieldGroupLazyResult = {
|
|
50
|
+
options: SelectFieldGroupedOption[];
|
|
51
|
+
hasMore?: boolean;
|
|
52
|
+
};
|
|
53
|
+
export type SelectFieldGroupLazyLoader = (searchValue: string, previousGroupKey: SelectFieldGroupByValue | null) => SelectFieldGroupLazyResult | Promise<SelectFieldGroupLazyResult>;
|
|
54
|
+
export type SelectFieldSearchProps = {
|
|
55
|
+
/**
|
|
56
|
+
* The current search value.
|
|
57
|
+
* Not a preferred usage. You likely don't need to control the searchValue yourself.
|
|
58
|
+
*/
|
|
59
|
+
searchValue?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Callback when the search value changes.
|
|
62
|
+
* Not a preferred usage. Lean on the searchValue in the loadOptions function instead.
|
|
63
|
+
*/
|
|
64
|
+
onSearchChange?: (searchValue: string) => void;
|
|
65
|
+
/**
|
|
66
|
+
* The number of milliseconds to debounce the search input.
|
|
67
|
+
*/
|
|
68
|
+
debounceMs?: number;
|
|
69
|
+
};
|
|
70
|
+
type SelectFieldAddNewOptionProps = {
|
|
71
|
+
/**
|
|
72
|
+
* The configuration for the add new option.
|
|
73
|
+
*/
|
|
74
|
+
addNewOption?: {
|
|
75
|
+
/**
|
|
76
|
+
* The label to display for the add new option.
|
|
77
|
+
*/
|
|
78
|
+
label: string;
|
|
79
|
+
/**
|
|
80
|
+
* The content to display in the add new option dialog.
|
|
81
|
+
*/
|
|
82
|
+
renderDialogContent: (searchValue: string) => React.ReactNode;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export type SelectFieldLabeledPinnedOptions = {
|
|
86
|
+
options: SelectFieldOption[] | ((searchValue: string) => SelectFieldOption[] | Promise<SelectFieldOption[]>);
|
|
87
|
+
label: string;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* There are a number of ways to configure pinned options.
|
|
91
|
+
* 1. An array of options
|
|
92
|
+
* 2. A function that returns a list of options (or Promise thereof) based on the search value
|
|
93
|
+
* 3. A labeled pinned options object (e.g. "Favorites", "Recent", "AI Suggestions", etc.)
|
|
94
|
+
* 4. An array of labeled pinned options objects (e.g. [{"label": "Favorites", "options": [...]}])
|
|
95
|
+
*/
|
|
96
|
+
export type SelectFieldPinnedOptions = SelectFieldOption[] | ((searchValue: string) => SelectFieldOption[] | Promise<SelectFieldOption[]>) | SelectFieldLabeledPinnedOptions | SelectFieldLabeledPinnedOptions[];
|
|
97
|
+
type SelectFieldCommonSelectFieldProps = {
|
|
98
|
+
/**
|
|
99
|
+
* The id of the select field.
|
|
100
|
+
*/
|
|
101
|
+
id?: string;
|
|
102
|
+
/**
|
|
103
|
+
* The label of the select field.
|
|
104
|
+
*/
|
|
105
|
+
label: string;
|
|
106
|
+
/**
|
|
107
|
+
* The placeholder of the select field.
|
|
108
|
+
*/
|
|
109
|
+
placeholder?: string;
|
|
110
|
+
/**
|
|
111
|
+
* The size of the select field.
|
|
112
|
+
*/
|
|
113
|
+
size?: Extract<Size, "small" | "medium" | "large">;
|
|
114
|
+
/**
|
|
115
|
+
* The value of the select field. Must be controlled state.
|
|
116
|
+
*/
|
|
117
|
+
value: SelectFieldOption | null;
|
|
118
|
+
/**
|
|
119
|
+
* The callback to call when an item is clicked.
|
|
120
|
+
* @param option - The option that was selected.
|
|
121
|
+
*/
|
|
122
|
+
onSelectedOptionChange: (option: SelectFieldOption | null) => void;
|
|
123
|
+
/**
|
|
124
|
+
* Defines the initial loading behavior of the options. Controls when loadOptions is called.
|
|
125
|
+
* @default "auto"
|
|
126
|
+
* @description "auto" default behavior, currently equivalent to "immediate".
|
|
127
|
+
* @description "immediate" will load the initial options when the component is mounted.
|
|
128
|
+
* @description "open" will load the initial options if/when the user opens the dropdown.
|
|
129
|
+
*/
|
|
130
|
+
initialLoad?: "auto" | "immediate" | "open";
|
|
131
|
+
/**
|
|
132
|
+
* The options to pin to the top of the list.
|
|
133
|
+
*/
|
|
134
|
+
pinned?: SelectFieldPinnedOptions;
|
|
135
|
+
/**
|
|
136
|
+
* Whether to disable the clear button.
|
|
137
|
+
* @default false
|
|
138
|
+
*/
|
|
139
|
+
disableClearButton?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Configuration for caching loadOptions results.
|
|
142
|
+
* Caching is enabled by default. Set `{ enabled: false }` to disable.
|
|
143
|
+
*/
|
|
144
|
+
cache?: SelectFieldCacheOptions;
|
|
145
|
+
/**
|
|
146
|
+
* The way to display the menu.
|
|
147
|
+
* @default "auto"
|
|
148
|
+
* @description "auto" will display the menu as a popover on mobile and a dialog on desktop.
|
|
149
|
+
* @description "popover" will always display the menu as a popover.
|
|
150
|
+
* @description "dialog" will always display the menu as a dialog.
|
|
151
|
+
*/
|
|
152
|
+
displayMenuAs?: "auto" | "popover" | "dialog";
|
|
153
|
+
/**
|
|
154
|
+
* Error state for the field. Can be a boolean, string message, or ReactElement.
|
|
155
|
+
* When truthy, displays error styling and message.
|
|
156
|
+
*/
|
|
157
|
+
error?: ReactElement | string | boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Hint text displayed below the input field.
|
|
160
|
+
*/
|
|
161
|
+
hint?: ReactElement | string;
|
|
162
|
+
/**
|
|
163
|
+
* Description text displayed below the input field.
|
|
164
|
+
*/
|
|
165
|
+
description?: ReactElement | string;
|
|
166
|
+
/**
|
|
167
|
+
* aria-live behavior for error messages.
|
|
168
|
+
* @default "assertive"
|
|
169
|
+
*/
|
|
170
|
+
errorAriaLive?: AriaAttributes["aria-live"];
|
|
171
|
+
/**
|
|
172
|
+
* Whether the field is required. Shows a red asterisk (*) next to the label.
|
|
173
|
+
*/
|
|
174
|
+
required?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Whether the field is disabled.
|
|
177
|
+
* When disabled, the input is still focusable but menu items cannot be selected.
|
|
178
|
+
*/
|
|
179
|
+
disabled?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Whether the field is read-only.
|
|
182
|
+
* When read-only, the input is still focusable but menu items cannot be selected.
|
|
183
|
+
*/
|
|
184
|
+
readOnly?: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Content to display before the input field.
|
|
187
|
+
*/
|
|
188
|
+
prefix?: string | ReactElement;
|
|
189
|
+
/**
|
|
190
|
+
* Content to display after the input field.
|
|
191
|
+
*/
|
|
192
|
+
suffix?: string | ReactElement;
|
|
193
|
+
} & SelectFieldSearchProps & SelectFieldAddNewOptionProps & LayoutUtilProps;
|
|
194
|
+
type SelectFieldGroupingProps = {
|
|
195
|
+
/**
|
|
196
|
+
* Function to convert a group value to a display label.
|
|
197
|
+
* Only used when options have a `group` property.
|
|
198
|
+
* @param groupValue - The group value from the option's `group` property
|
|
199
|
+
* @returns The formatted group label
|
|
200
|
+
*/
|
|
201
|
+
groupToString?: (groupValue: SelectFieldGroupByValue) => string;
|
|
202
|
+
};
|
|
203
|
+
type SelectFieldNonGroupingProps = {
|
|
204
|
+
/**
|
|
205
|
+
* Incompatible with non-group lazy loading.
|
|
206
|
+
*/
|
|
207
|
+
groupToString?: never;
|
|
208
|
+
/**
|
|
209
|
+
* Incompatible with non-group lazy loading.
|
|
210
|
+
*/
|
|
211
|
+
groupSorter?: never;
|
|
212
|
+
};
|
|
213
|
+
export type SelectFieldPropsLazyPage = SelectFieldCommonSelectFieldProps & {
|
|
214
|
+
/**
|
|
215
|
+
* Lazy loading mode using page-based pagination.
|
|
216
|
+
* Options will be loaded on demand when the user scrolls to the bottom of the list.
|
|
217
|
+
* This mode only supports flat options (i.e. cannot be used with grouped options).
|
|
218
|
+
*/
|
|
219
|
+
lazy: "page";
|
|
220
|
+
lazyOptions?: {
|
|
221
|
+
pageSize?: number;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Function to load the options.
|
|
225
|
+
*/
|
|
226
|
+
loadOptions: SelectFieldPageLazyLoader;
|
|
227
|
+
} & SelectFieldNonGroupingProps;
|
|
228
|
+
export type SelectFieldPropsLazyOffset = SelectFieldCommonSelectFieldProps & {
|
|
229
|
+
/**
|
|
230
|
+
* Lazy loading mode using offset-based pagination.
|
|
231
|
+
* Options will be loaded on demand when the user scrolls to the bottom of the list.
|
|
232
|
+
* This mode only supports flat options (i.e. cannot be used with grouped options).
|
|
233
|
+
*/
|
|
234
|
+
lazy: "offset";
|
|
235
|
+
lazyOptions?: {
|
|
236
|
+
limit?: number;
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Function to load the options.
|
|
240
|
+
*/
|
|
241
|
+
loadOptions: SelectFieldOffsetLazyLoader;
|
|
242
|
+
} & SelectFieldNonGroupingProps;
|
|
243
|
+
export type SelectFieldPropsLazyGroup = SelectFieldCommonSelectFieldProps & {
|
|
244
|
+
/**
|
|
245
|
+
* Lazy loading mode using incremental group loading.
|
|
246
|
+
* Groups will be loaded on demand when the user scrolls to the bottom of the list.
|
|
247
|
+
* This mode supports grouped options.
|
|
248
|
+
*/
|
|
249
|
+
lazy: "group";
|
|
250
|
+
lazyOptions?: object;
|
|
251
|
+
/**
|
|
252
|
+
* Function to load the options.
|
|
253
|
+
*/
|
|
254
|
+
loadOptions: SelectFieldGroupLazyLoader;
|
|
255
|
+
} & SelectFieldGroupingProps;
|
|
256
|
+
export type SelectFieldPropsEager = SelectFieldCommonSelectFieldProps & {
|
|
257
|
+
/**
|
|
258
|
+
* Whether the options are lazy loaded. If true, the options will be loaded on demand when the user scrolls to the bottom of the list.
|
|
259
|
+
* @default false
|
|
260
|
+
*/
|
|
261
|
+
lazy?: false;
|
|
262
|
+
/**
|
|
263
|
+
* Function to load the options.
|
|
264
|
+
*/
|
|
265
|
+
loadOptions: SelectFieldEagerLoader;
|
|
266
|
+
};
|
|
267
|
+
export type SelectFieldPropsLazy = SelectFieldPropsLazyPage | SelectFieldPropsLazyOffset | SelectFieldPropsLazyGroup;
|
|
268
|
+
export type SelectFieldProps = SelectFieldPropsLazy | SelectFieldPropsEager;
|
|
269
|
+
export type SelectFieldDownshiftItem = {
|
|
270
|
+
id: string | number;
|
|
271
|
+
type: "option" | "pinned-option" | "select-all";
|
|
272
|
+
original: SelectFieldOption;
|
|
273
|
+
disabled?: boolean;
|
|
274
|
+
};
|
|
275
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useAdaptiveView';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The type of view to render based on device characteristics.
|
|
3
|
+
*/
|
|
4
|
+
export type AdaptiveView = "mobile" | "desktop";
|
|
5
|
+
/**
|
|
6
|
+
* Return type for the useAdaptiveView hook.
|
|
7
|
+
*/
|
|
8
|
+
export interface UseAdaptiveViewReturn {
|
|
9
|
+
/**
|
|
10
|
+
* The current adaptive view type.
|
|
11
|
+
*/
|
|
12
|
+
view: AdaptiveView;
|
|
13
|
+
/**
|
|
14
|
+
* True when the device should use mobile-optimized UI (Dialog).
|
|
15
|
+
*/
|
|
16
|
+
isMobile: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* True when the device should use desktop-optimized UI (Popover).
|
|
19
|
+
*/
|
|
20
|
+
isDesktop: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Custom hook for detecting whether to use mobile or desktop UI patterns.
|
|
24
|
+
*
|
|
25
|
+
* This hook determines the optimal UI pattern (e.g., Dialog vs Popover) by combining:
|
|
26
|
+
* - Screen size via useBreakpoint (viewport width)
|
|
27
|
+
* - Pointer precision via CSS media query (pointer: coarse)
|
|
28
|
+
*
|
|
29
|
+
* A device is considered "mobile" when it has both:
|
|
30
|
+
* - A small screen (below md breakpoint, < 768px)
|
|
31
|
+
* - A coarse pointer (touch-primary input)
|
|
32
|
+
*
|
|
33
|
+
* This approach correctly identifies:
|
|
34
|
+
* - Mobile phones → mobile view (Dialog)
|
|
35
|
+
* - iPads/tablets → desktop view (Popover) due to larger screens
|
|
36
|
+
* - Touch laptops → desktop view (Popover) due to fine pointer primary
|
|
37
|
+
* - Desktop → desktop view (Popover)
|
|
38
|
+
*
|
|
39
|
+
* @returns Object containing view type and boolean flags for mobile/desktop
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const { isMobile } = useAdaptiveView();
|
|
43
|
+
*
|
|
44
|
+
* return isMobile ? (
|
|
45
|
+
* <Dialog>{children}</Dialog>
|
|
46
|
+
* ) : (
|
|
47
|
+
* <Popover>{children}</Popover>
|
|
48
|
+
* );
|
|
49
|
+
*/
|
|
50
|
+
export declare function useAdaptiveView(): UseAdaptiveViewReturn;
|
package/dist/beta/index.d.ts
CHANGED