@trellixio/roaster-react 0.0.0-stage → 1.1.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/LICENSE.md +4 -0
- package/README.md +101 -2
- package/cjs/components/ActionCard/ActionCard.js +27 -0
- package/cjs/components/ActionCard/ActionCard.js.map +1 -0
- package/cjs/components/ActionList/ActionList.context.js +32 -0
- package/cjs/components/ActionList/ActionList.context.js.map +1 -0
- package/cjs/components/ActionList/ActionList.js +37 -0
- package/cjs/components/ActionList/ActionList.js.map +1 -0
- package/cjs/components/ActionList/components/ActionListDivider.js +24 -0
- package/cjs/components/ActionList/components/ActionListDivider.js.map +1 -0
- package/cjs/components/ActionList/components/ActionListDropdown.js +46 -0
- package/cjs/components/ActionList/components/ActionListDropdown.js.map +1 -0
- package/cjs/components/ActionList/components/ActionListGroup.js +25 -0
- package/cjs/components/ActionList/components/ActionListGroup.js.map +1 -0
- package/cjs/components/ActionList/components/ActionListItem.js +25 -0
- package/cjs/components/ActionList/components/ActionListItem.js.map +1 -0
- package/cjs/components/ActionList/components/ActionListTrigger.js +44 -0
- package/cjs/components/ActionList/components/ActionListTrigger.js.map +1 -0
- package/cjs/components/ActionList/useDropdown.js +47 -0
- package/cjs/components/ActionList/useDropdown.js.map +1 -0
- package/cjs/components/Alert/Alert.js +28 -0
- package/cjs/components/Alert/Alert.js.map +1 -0
- package/cjs/components/Avatar/Avatar.js +30 -0
- package/cjs/components/Avatar/Avatar.js.map +1 -0
- package/cjs/components/BlockCard/BlockCard.js +27 -0
- package/cjs/components/BlockCard/BlockCard.js.map +1 -0
- package/cjs/components/Button/Button.js +50 -0
- package/cjs/components/Button/Button.js.map +1 -0
- package/cjs/components/ButtonIcon/ButtonIcon.js +38 -0
- package/cjs/components/ButtonIcon/ButtonIcon.js.map +1 -0
- package/cjs/components/Checkbox/Checkbox.js +77 -0
- package/cjs/components/Checkbox/Checkbox.js.map +1 -0
- package/cjs/components/Checkbox/CheckboxGroup/CheckboxGroup.context.js +12 -0
- package/cjs/components/Checkbox/CheckboxGroup/CheckboxGroup.context.js.map +1 -0
- package/cjs/components/Checkbox/CheckboxGroup/CheckboxGroup.js +48 -0
- package/cjs/components/Checkbox/CheckboxGroup/CheckboxGroup.js.map +1 -0
- package/cjs/components/ColorField/ColorField.js +50 -0
- package/cjs/components/ColorField/ColorField.js.map +1 -0
- package/cjs/components/DatePicker/DatePicker.js +144 -0
- package/cjs/components/DatePicker/DatePicker.js.map +1 -0
- package/cjs/components/DatePicker/components/Calendar/Calendar.js +56 -0
- package/cjs/components/DatePicker/components/Calendar/Calendar.js.map +1 -0
- package/cjs/components/DatePicker/components/Day/Day.js +41 -0
- package/cjs/components/DatePicker/components/Day/Day.js.map +1 -0
- package/cjs/components/DatePicker/components/Month/Month.js +55 -0
- package/cjs/components/DatePicker/components/Month/Month.js.map +1 -0
- package/cjs/components/DatePicker/components/Weekday/Weekday.js +23 -0
- package/cjs/components/DatePicker/components/Weekday/Weekday.js.map +1 -0
- package/cjs/components/DatePicker/utils/index.js +186 -0
- package/cjs/components/DatePicker/utils/index.js.map +1 -0
- package/cjs/components/DescriptiveList/DescriptiveList.js +28 -0
- package/cjs/components/DescriptiveList/DescriptiveList.js.map +1 -0
- package/cjs/components/DescriptiveList/DescriptiveListItem.js +24 -0
- package/cjs/components/DescriptiveList/DescriptiveListItem.js.map +1 -0
- package/cjs/components/DropdownCard/DropdownCard.context.js +32 -0
- package/cjs/components/DropdownCard/DropdownCard.context.js.map +1 -0
- package/cjs/components/DropdownCard/DropdownCard.js +36 -0
- package/cjs/components/DropdownCard/DropdownCard.js.map +1 -0
- package/cjs/components/DropdownCard/components/DropdownCardActions.js +12 -0
- package/cjs/components/DropdownCard/components/DropdownCardActions.js.map +1 -0
- package/cjs/components/DropdownCard/components/DropdownCardContent.js +25 -0
- package/cjs/components/DropdownCard/components/DropdownCardContent.js.map +1 -0
- package/cjs/components/DropdownCard/components/DropdownCardDropdown.js +46 -0
- package/cjs/components/DropdownCard/components/DropdownCardDropdown.js.map +1 -0
- package/cjs/components/DropdownCard/components/DropdownCardTrigger.js +42 -0
- package/cjs/components/DropdownCard/components/DropdownCardTrigger.js.map +1 -0
- package/cjs/components/FileField/FileField.js +81 -0
- package/cjs/components/FileField/FileField.js.map +1 -0
- package/cjs/components/HyperlinkCard/HyperlinkCard.js +15 -0
- package/cjs/components/HyperlinkCard/HyperlinkCard.js.map +1 -0
- package/cjs/components/Icon/Icon.js +35 -0
- package/cjs/components/Icon/Icon.js.map +1 -0
- package/cjs/components/Loader/Loader.js +12 -0
- package/cjs/components/Loader/Loader.js.map +1 -0
- package/cjs/components/Modal/Modal.js +28 -0
- package/cjs/components/Modal/Modal.js.map +1 -0
- package/cjs/components/Modal/ModalProvider/ModalProviderFooter.js +33 -0
- package/cjs/components/Modal/ModalProvider/ModalProviderFooter.js.map +1 -0
- package/cjs/components/Modal/ModalProvider/index.js +85 -0
- package/cjs/components/Modal/ModalProvider/index.js.map +1 -0
- package/cjs/components/Modal/utils/events.js +19 -0
- package/cjs/components/Modal/utils/events.js.map +1 -0
- package/cjs/components/Modal/utils/reducer.js +42 -0
- package/cjs/components/Modal/utils/reducer.js.map +1 -0
- package/cjs/components/Modal/utils/useModal.js +32 -0
- package/cjs/components/Modal/utils/useModal.js.map +1 -0
- package/cjs/components/Page/Page.js +38 -0
- package/cjs/components/Page/Page.js.map +1 -0
- package/cjs/components/Pagination/Pagination.js +35 -0
- package/cjs/components/Pagination/Pagination.js.map +1 -0
- package/cjs/components/Progress/Progress.js +13 -0
- package/cjs/components/Progress/Progress.js.map +1 -0
- package/cjs/components/Radio/Radio.js +65 -0
- package/cjs/components/Radio/Radio.js.map +1 -0
- package/cjs/components/Radio/RadioGroup/RadioGroup.context.js +12 -0
- package/cjs/components/Radio/RadioGroup/RadioGroup.context.js.map +1 -0
- package/cjs/components/Radio/RadioGroup/RadioGroup.js +58 -0
- package/cjs/components/Radio/RadioGroup/RadioGroup.js.map +1 -0
- package/cjs/components/RangeField/RangeField.js +76 -0
- package/cjs/components/RangeField/RangeField.js.map +1 -0
- package/cjs/components/Select/Select.js +72 -0
- package/cjs/components/Select/Select.js.map +1 -0
- package/cjs/components/Sidebar/Sidebar.js +144 -0
- package/cjs/components/Sidebar/Sidebar.js.map +1 -0
- package/cjs/components/Sidebar/components/Menu.js +17 -0
- package/cjs/components/Sidebar/components/Menu.js.map +1 -0
- package/cjs/components/Sidebar/components/MenuItem.js +15 -0
- package/cjs/components/Sidebar/components/MenuItem.js.map +1 -0
- package/cjs/components/Sidebar/components/Section.js +12 -0
- package/cjs/components/Sidebar/components/Section.js.map +1 -0
- package/cjs/components/Sidebar/components/SubMenu.js +12 -0
- package/cjs/components/Sidebar/components/SubMenu.js.map +1 -0
- package/cjs/components/Spinner/Spinner.js +12 -0
- package/cjs/components/Spinner/Spinner.js.map +1 -0
- package/cjs/components/StatCard/StatCard.js +36 -0
- package/cjs/components/StatCard/StatCard.js.map +1 -0
- package/cjs/components/Switch/Switch.js +63 -0
- package/cjs/components/Switch/Switch.js.map +1 -0
- package/cjs/components/Table/Table.js +93 -0
- package/cjs/components/Table/Table.js.map +1 -0
- package/cjs/components/Table/components/Checkbox/index.js +40 -0
- package/cjs/components/Table/components/Checkbox/index.js.map +1 -0
- package/cjs/components/Table/components/TableBody.js +24 -0
- package/cjs/components/Table/components/TableBody.js.map +1 -0
- package/cjs/components/Table/components/TableCell.js +25 -0
- package/cjs/components/Table/components/TableCell.js.map +1 -0
- package/cjs/components/Table/components/TableHead.js +43 -0
- package/cjs/components/Table/components/TableHead.js.map +1 -0
- package/cjs/components/Table/components/TableHeadCell.js +32 -0
- package/cjs/components/Table/components/TableHeadCell.js.map +1 -0
- package/cjs/components/Table/components/TablePagination.js +26 -0
- package/cjs/components/Table/components/TablePagination.js.map +1 -0
- package/cjs/components/Table/components/TableProvider/TableProvider.js +42 -0
- package/cjs/components/Table/components/TableProvider/TableProvider.js.map +1 -0
- package/cjs/components/Table/components/TableRow.js +46 -0
- package/cjs/components/Table/components/TableRow.js.map +1 -0
- package/cjs/components/Table/utils/rows/context.js +9 -0
- package/cjs/components/Table/utils/rows/context.js.map +1 -0
- package/cjs/components/Table/utils/table/context.js +13 -0
- package/cjs/components/Table/utils/table/context.js.map +1 -0
- package/cjs/components/Table/utils/table/hooks.js +64 -0
- package/cjs/components/Table/utils/table/hooks.js.map +1 -0
- package/cjs/components/Table/utils/table/types.js +14 -0
- package/cjs/components/Table/utils/table/types.js.map +1 -0
- package/cjs/components/Table/utils/useSelectableResourceState/index.js +85 -0
- package/cjs/components/Table/utils/useSelectableResourceState/index.js.map +1 -0
- package/cjs/components/Tag/Tag.js +31 -0
- package/cjs/components/Tag/Tag.js.map +1 -0
- package/cjs/components/Tag/TagGroup.js +27 -0
- package/cjs/components/Tag/TagGroup.js.map +1 -0
- package/cjs/components/TextField/TextField.js +85 -0
- package/cjs/components/TextField/TextField.js.map +1 -0
- package/cjs/components/Textarea/Textarea.js +60 -0
- package/cjs/components/Textarea/Textarea.js.map +1 -0
- package/cjs/components/Thumbnail/Thumbnail.js +30 -0
- package/cjs/components/Thumbnail/Thumbnail.js.map +1 -0
- package/cjs/components/Toast/Toast.js +28 -0
- package/cjs/components/Toast/Toast.js.map +1 -0
- package/cjs/components/Toast/Toasts.context.js +10 -0
- package/cjs/components/Toast/Toasts.context.js.map +1 -0
- package/cjs/components/Toast/ToastsContainer/index.js +47 -0
- package/cjs/components/Toast/ToastsContainer/index.js.map +1 -0
- package/cjs/components/Toast/ToastsProvider/index.js +39 -0
- package/cjs/components/Toast/ToastsProvider/index.js.map +1 -0
- package/cjs/components/Toast/ToastsProvider/useToastsState/useToastsState.js +55 -0
- package/cjs/components/Toast/ToastsProvider/useToastsState/useToastsState.js.map +1 -0
- package/cjs/components/Toast/events.js +20 -0
- package/cjs/components/Toast/events.js.map +1 -0
- package/cjs/components/Tooltip/Tooltip.js +81 -0
- package/cjs/components/Tooltip/Tooltip.js.map +1 -0
- package/cjs/components/Tooltip/useTooltip.js +63 -0
- package/cjs/components/Tooltip/useTooltip.js.map +1 -0
- package/cjs/components/Visualizer/Visualizer.context.js +12 -0
- package/cjs/components/Visualizer/Visualizer.context.js.map +1 -0
- package/cjs/components/Visualizer/Visualizer.js +36 -0
- package/cjs/components/Visualizer/Visualizer.js.map +1 -0
- package/cjs/components/Visualizer/VisualizerMobileOpener.js +28 -0
- package/cjs/components/Visualizer/VisualizerMobileOpener.js.map +1 -0
- package/cjs/index.js +106 -0
- package/cjs/index.js.map +1 -0
- package/cjs/utils/classNames/index.js +28 -0
- package/cjs/utils/classNames/index.js.map +1 -0
- package/cjs/utils/createUseExternalEvents/index.js +32 -0
- package/cjs/utils/createUseExternalEvents/index.js.map +1 -0
- package/cjs/utils/guid/index.js +12 -0
- package/cjs/utils/guid/index.js.map +1 -0
- package/cjs/utils/useDropdown/index.js +47 -0
- package/cjs/utils/useDropdown/index.js.map +1 -0
- package/cjs/utils/useIsomorphicEffect/index.js +22 -0
- package/cjs/utils/useIsomorphicEffect/index.js.map +1 -0
- package/cjs/utils/useQueue/index.js +36 -0
- package/cjs/utils/useQueue/index.js.map +1 -0
- package/cjs/utils/useUid/index.js +25 -0
- package/cjs/utils/useUid/index.js.map +1 -0
- package/cjs/utils/useUncontrolled/index.js +25 -0
- package/cjs/utils/useUncontrolled/index.js.map +1 -0
- package/esm/components/ActionCard/ActionCard.js +12 -0
- package/esm/components/ActionCard/ActionCard.js.map +1 -0
- package/esm/components/ActionList/ActionList.context.js +15 -0
- package/esm/components/ActionList/ActionList.context.js.map +1 -0
- package/esm/components/ActionList/ActionList.js +22 -0
- package/esm/components/ActionList/ActionList.js.map +1 -0
- package/esm/components/ActionList/components/ActionListDivider.js +9 -0
- package/esm/components/ActionList/components/ActionListDivider.js.map +1 -0
- package/esm/components/ActionList/components/ActionListDropdown.js +31 -0
- package/esm/components/ActionList/components/ActionListDropdown.js.map +1 -0
- package/esm/components/ActionList/components/ActionListGroup.js +10 -0
- package/esm/components/ActionList/components/ActionListGroup.js.map +1 -0
- package/esm/components/ActionList/components/ActionListItem.js +10 -0
- package/esm/components/ActionList/components/ActionListItem.js.map +1 -0
- package/esm/components/ActionList/components/ActionListTrigger.js +29 -0
- package/esm/components/ActionList/components/ActionListTrigger.js.map +1 -0
- package/esm/components/ActionList/useDropdown.js +45 -0
- package/esm/components/ActionList/useDropdown.js.map +1 -0
- package/esm/components/Alert/Alert.js +13 -0
- package/esm/components/Alert/Alert.js.map +1 -0
- package/esm/components/Avatar/Avatar.js +15 -0
- package/esm/components/Avatar/Avatar.js.map +1 -0
- package/esm/components/BlockCard/BlockCard.js +12 -0
- package/esm/components/BlockCard/BlockCard.js.map +1 -0
- package/esm/components/Button/Button.js +35 -0
- package/esm/components/Button/Button.js.map +1 -0
- package/esm/components/ButtonIcon/ButtonIcon.js +23 -0
- package/esm/components/ButtonIcon/ButtonIcon.js.map +1 -0
- package/esm/components/Checkbox/Checkbox.js +62 -0
- package/esm/components/Checkbox/Checkbox.js.map +1 -0
- package/esm/components/Checkbox/CheckboxGroup/CheckboxGroup.context.js +9 -0
- package/esm/components/Checkbox/CheckboxGroup/CheckboxGroup.context.js.map +1 -0
- package/esm/components/Checkbox/CheckboxGroup/CheckboxGroup.js +33 -0
- package/esm/components/Checkbox/CheckboxGroup/CheckboxGroup.js.map +1 -0
- package/esm/components/ColorField/ColorField.js +35 -0
- package/esm/components/ColorField/ColorField.js.map +1 -0
- package/esm/components/DatePicker/DatePicker.js +129 -0
- package/esm/components/DatePicker/DatePicker.js.map +1 -0
- package/esm/components/DatePicker/components/Calendar/Calendar.js +41 -0
- package/esm/components/DatePicker/components/Calendar/Calendar.js.map +1 -0
- package/esm/components/DatePicker/components/Day/Day.js +26 -0
- package/esm/components/DatePicker/components/Day/Day.js.map +1 -0
- package/esm/components/DatePicker/components/Month/Month.js +40 -0
- package/esm/components/DatePicker/components/Month/Month.js.map +1 -0
- package/esm/components/DatePicker/components/Weekday/Weekday.js +8 -0
- package/esm/components/DatePicker/components/Weekday/Weekday.js.map +1 -0
- package/esm/components/DatePicker/utils/index.js +166 -0
- package/esm/components/DatePicker/utils/index.js.map +1 -0
- package/esm/components/DescriptiveList/DescriptiveList.js +13 -0
- package/esm/components/DescriptiveList/DescriptiveList.js.map +1 -0
- package/esm/components/DescriptiveList/DescriptiveListItem.js +9 -0
- package/esm/components/DescriptiveList/DescriptiveListItem.js.map +1 -0
- package/esm/components/DropdownCard/DropdownCard.context.js +15 -0
- package/esm/components/DropdownCard/DropdownCard.context.js.map +1 -0
- package/esm/components/DropdownCard/DropdownCard.js +21 -0
- package/esm/components/DropdownCard/DropdownCard.js.map +1 -0
- package/esm/components/DropdownCard/components/DropdownCardActions.js +10 -0
- package/esm/components/DropdownCard/components/DropdownCardActions.js.map +1 -0
- package/esm/components/DropdownCard/components/DropdownCardContent.js +10 -0
- package/esm/components/DropdownCard/components/DropdownCardContent.js.map +1 -0
- package/esm/components/DropdownCard/components/DropdownCardDropdown.js +31 -0
- package/esm/components/DropdownCard/components/DropdownCardDropdown.js.map +1 -0
- package/esm/components/DropdownCard/components/DropdownCardTrigger.js +27 -0
- package/esm/components/DropdownCard/components/DropdownCardTrigger.js.map +1 -0
- package/esm/components/FileField/FileField.js +66 -0
- package/esm/components/FileField/FileField.js.map +1 -0
- package/esm/components/HyperlinkCard/HyperlinkCard.js +13 -0
- package/esm/components/HyperlinkCard/HyperlinkCard.js.map +1 -0
- package/esm/components/Icon/Icon.js +20 -0
- package/esm/components/Icon/Icon.js.map +1 -0
- package/esm/components/Loader/Loader.js +10 -0
- package/esm/components/Loader/Loader.js.map +1 -0
- package/esm/components/Modal/Modal.js +13 -0
- package/esm/components/Modal/Modal.js.map +1 -0
- package/esm/components/Modal/ModalProvider/ModalProviderFooter.js +31 -0
- package/esm/components/Modal/ModalProvider/ModalProviderFooter.js.map +1 -0
- package/esm/components/Modal/ModalProvider/index.js +70 -0
- package/esm/components/Modal/ModalProvider/index.js.map +1 -0
- package/esm/components/Modal/utils/events.js +13 -0
- package/esm/components/Modal/utils/events.js.map +1 -0
- package/esm/components/Modal/utils/reducer.js +39 -0
- package/esm/components/Modal/utils/reducer.js.map +1 -0
- package/esm/components/Modal/utils/useModal.js +15 -0
- package/esm/components/Modal/utils/useModal.js.map +1 -0
- package/esm/components/Page/Page.js +23 -0
- package/esm/components/Page/Page.js.map +1 -0
- package/esm/components/Pagination/Pagination.js +20 -0
- package/esm/components/Pagination/Pagination.js.map +1 -0
- package/esm/components/Progress/Progress.js +11 -0
- package/esm/components/Progress/Progress.js.map +1 -0
- package/esm/components/Radio/Radio.js +50 -0
- package/esm/components/Radio/Radio.js.map +1 -0
- package/esm/components/Radio/RadioGroup/RadioGroup.context.js +9 -0
- package/esm/components/Radio/RadioGroup/RadioGroup.context.js.map +1 -0
- package/esm/components/Radio/RadioGroup/RadioGroup.js +43 -0
- package/esm/components/Radio/RadioGroup/RadioGroup.js.map +1 -0
- package/esm/components/RangeField/RangeField.js +61 -0
- package/esm/components/RangeField/RangeField.js.map +1 -0
- package/esm/components/Select/Select.js +57 -0
- package/esm/components/Select/Select.js.map +1 -0
- package/esm/components/Sidebar/Sidebar.js +129 -0
- package/esm/components/Sidebar/Sidebar.js.map +1 -0
- package/esm/components/Sidebar/components/Menu.js +15 -0
- package/esm/components/Sidebar/components/Menu.js.map +1 -0
- package/esm/components/Sidebar/components/MenuItem.js +13 -0
- package/esm/components/Sidebar/components/MenuItem.js.map +1 -0
- package/esm/components/Sidebar/components/Section.js +10 -0
- package/esm/components/Sidebar/components/Section.js.map +1 -0
- package/esm/components/Sidebar/components/SubMenu.js +10 -0
- package/esm/components/Sidebar/components/SubMenu.js.map +1 -0
- package/esm/components/Spinner/Spinner.js +10 -0
- package/esm/components/Spinner/Spinner.js.map +1 -0
- package/esm/components/StatCard/StatCard.js +21 -0
- package/esm/components/StatCard/StatCard.js.map +1 -0
- package/esm/components/Switch/Switch.js +48 -0
- package/esm/components/Switch/Switch.js.map +1 -0
- package/esm/components/Table/Table.js +78 -0
- package/esm/components/Table/Table.js.map +1 -0
- package/esm/components/Table/components/Checkbox/index.js +25 -0
- package/esm/components/Table/components/Checkbox/index.js.map +1 -0
- package/esm/components/Table/components/TableBody.js +9 -0
- package/esm/components/Table/components/TableBody.js.map +1 -0
- package/esm/components/Table/components/TableCell.js +10 -0
- package/esm/components/Table/components/TableCell.js.map +1 -0
- package/esm/components/Table/components/TableHead.js +28 -0
- package/esm/components/Table/components/TableHead.js.map +1 -0
- package/esm/components/Table/components/TableHeadCell.js +17 -0
- package/esm/components/Table/components/TableHeadCell.js.map +1 -0
- package/esm/components/Table/components/TablePagination.js +11 -0
- package/esm/components/Table/components/TablePagination.js.map +1 -0
- package/esm/components/Table/components/TableProvider/TableProvider.js +40 -0
- package/esm/components/Table/components/TableProvider/TableProvider.js.map +1 -0
- package/esm/components/Table/components/TableRow.js +31 -0
- package/esm/components/Table/components/TableRow.js.map +1 -0
- package/esm/components/Table/utils/rows/context.js +7 -0
- package/esm/components/Table/utils/rows/context.js.map +1 -0
- package/esm/components/Table/utils/table/context.js +9 -0
- package/esm/components/Table/utils/table/context.js.map +1 -0
- package/esm/components/Table/utils/table/hooks.js +58 -0
- package/esm/components/Table/utils/table/hooks.js.map +1 -0
- package/esm/components/Table/utils/table/types.js +11 -0
- package/esm/components/Table/utils/table/types.js.map +1 -0
- package/esm/components/Table/utils/useSelectableResourceState/index.js +70 -0
- package/esm/components/Table/utils/useSelectableResourceState/index.js.map +1 -0
- package/esm/components/Tag/Tag.js +16 -0
- package/esm/components/Tag/Tag.js.map +1 -0
- package/esm/components/Tag/TagGroup.js +12 -0
- package/esm/components/Tag/TagGroup.js.map +1 -0
- package/esm/components/TextField/TextField.js +70 -0
- package/esm/components/TextField/TextField.js.map +1 -0
- package/esm/components/Textarea/Textarea.js +45 -0
- package/esm/components/Textarea/Textarea.js.map +1 -0
- package/esm/components/Thumbnail/Thumbnail.js +15 -0
- package/esm/components/Thumbnail/Thumbnail.js.map +1 -0
- package/esm/components/Toast/Toast.js +13 -0
- package/esm/components/Toast/Toast.js.map +1 -0
- package/esm/components/Toast/Toasts.context.js +8 -0
- package/esm/components/Toast/Toasts.context.js.map +1 -0
- package/esm/components/Toast/ToastsContainer/index.js +44 -0
- package/esm/components/Toast/ToastsContainer/index.js.map +1 -0
- package/esm/components/Toast/ToastsProvider/index.js +24 -0
- package/esm/components/Toast/ToastsProvider/index.js.map +1 -0
- package/esm/components/Toast/ToastsProvider/useToastsState/useToastsState.js +51 -0
- package/esm/components/Toast/ToastsProvider/useToastsState/useToastsState.js.map +1 -0
- package/esm/components/Toast/events.js +12 -0
- package/esm/components/Toast/events.js.map +1 -0
- package/esm/components/Tooltip/Tooltip.js +66 -0
- package/esm/components/Tooltip/Tooltip.js.map +1 -0
- package/esm/components/Tooltip/useTooltip.js +48 -0
- package/esm/components/Tooltip/useTooltip.js.map +1 -0
- package/esm/components/Visualizer/Visualizer.context.js +9 -0
- package/esm/components/Visualizer/Visualizer.context.js.map +1 -0
- package/esm/components/Visualizer/Visualizer.js +21 -0
- package/esm/components/Visualizer/Visualizer.js.map +1 -0
- package/esm/components/Visualizer/VisualizerMobileOpener.js +13 -0
- package/esm/components/Visualizer/VisualizerMobileOpener.js.map +1 -0
- package/esm/index.js +46 -0
- package/esm/index.js.map +1 -0
- package/esm/package.json +3 -0
- package/esm/utils/classNames/index.js +26 -0
- package/esm/utils/classNames/index.js.map +1 -0
- package/esm/utils/createUseExternalEvents/index.js +30 -0
- package/esm/utils/createUseExternalEvents/index.js.map +1 -0
- package/esm/utils/guid/index.js +10 -0
- package/esm/utils/guid/index.js.map +1 -0
- package/esm/utils/useDropdown/index.js +45 -0
- package/esm/utils/useDropdown/index.js.map +1 -0
- package/esm/utils/useIsomorphicEffect/index.js +7 -0
- package/esm/utils/useIsomorphicEffect/index.js.map +1 -0
- package/esm/utils/useQueue/index.js +34 -0
- package/esm/utils/useQueue/index.js.map +1 -0
- package/esm/utils/useUid/index.js +10 -0
- package/esm/utils/useUid/index.js.map +1 -0
- package/esm/utils/useUncontrolled/index.js +23 -0
- package/esm/utils/useUncontrolled/index.js.map +1 -0
- package/lib/components/ActionCard/ActionCard.d.ts +19 -0
- package/lib/components/ActionCard/ActionCard.d.ts.map +1 -0
- package/lib/components/ActionCard/index.d.ts +3 -0
- package/lib/components/ActionCard/index.d.ts.map +1 -0
- package/lib/components/ActionList/ActionList.context.d.ts +53 -0
- package/lib/components/ActionList/ActionList.context.d.ts.map +1 -0
- package/lib/components/ActionList/ActionList.d.ts +25 -0
- package/lib/components/ActionList/ActionList.d.ts.map +1 -0
- package/lib/components/ActionList/components/ActionListDivider.d.ts +7 -0
- package/lib/components/ActionList/components/ActionListDivider.d.ts.map +1 -0
- package/lib/components/ActionList/components/ActionListDropdown.d.ts +3 -0
- package/lib/components/ActionList/components/ActionListDropdown.d.ts.map +1 -0
- package/lib/components/ActionList/components/ActionListGroup.d.ts +9 -0
- package/lib/components/ActionList/components/ActionListGroup.d.ts.map +1 -0
- package/lib/components/ActionList/components/ActionListItem.d.ts +11 -0
- package/lib/components/ActionList/components/ActionListItem.d.ts.map +1 -0
- package/lib/components/ActionList/components/ActionListTrigger.d.ts +7 -0
- package/lib/components/ActionList/components/ActionListTrigger.d.ts.map +1 -0
- package/lib/components/ActionList/index.d.ts +3 -0
- package/lib/components/ActionList/index.d.ts.map +1 -0
- package/lib/components/ActionList/useDropdown.d.ts +57 -0
- package/lib/components/ActionList/useDropdown.d.ts.map +1 -0
- package/lib/components/Alert/Alert.d.ts +16 -0
- package/lib/components/Alert/Alert.d.ts.map +1 -0
- package/lib/components/Alert/index.d.ts +3 -0
- package/lib/components/Alert/index.d.ts.map +1 -0
- package/lib/components/Avatar/Avatar.d.ts +14 -0
- package/lib/components/Avatar/Avatar.d.ts.map +1 -0
- package/lib/components/Avatar/index.d.ts +3 -0
- package/lib/components/Avatar/index.d.ts.map +1 -0
- package/lib/components/BlockCard/BlockCard.d.ts +20 -0
- package/lib/components/BlockCard/BlockCard.d.ts.map +1 -0
- package/lib/components/BlockCard/index.d.ts +3 -0
- package/lib/components/BlockCard/index.d.ts.map +1 -0
- package/lib/components/Button/Button.d.ts +37 -0
- package/lib/components/Button/Button.d.ts.map +1 -0
- package/lib/components/Button/index.d.ts +3 -0
- package/lib/components/Button/index.d.ts.map +1 -0
- package/lib/components/ButtonIcon/ButtonIcon.d.ts +24 -0
- package/lib/components/ButtonIcon/ButtonIcon.d.ts.map +1 -0
- package/lib/components/ButtonIcon/index.d.ts +3 -0
- package/lib/components/ButtonIcon/index.d.ts.map +1 -0
- package/lib/components/Checkbox/Checkbox.d.ts +42 -0
- package/lib/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/lib/components/Checkbox/CheckboxGroup/CheckboxGroup.context.d.ts +7 -0
- package/lib/components/Checkbox/CheckboxGroup/CheckboxGroup.context.d.ts.map +1 -0
- package/lib/components/Checkbox/CheckboxGroup/CheckboxGroup.d.ts +12 -0
- package/lib/components/Checkbox/CheckboxGroup/CheckboxGroup.d.ts.map +1 -0
- package/lib/components/Checkbox/index.d.ts +4 -0
- package/lib/components/Checkbox/index.d.ts.map +1 -0
- package/lib/components/CodeBlock/CodeBlock.d.ts +16 -0
- package/lib/components/CodeBlock/CodeBlock.d.ts.map +1 -0
- package/lib/components/CodeBlock/index.d.ts +2 -0
- package/lib/components/CodeBlock/index.d.ts.map +1 -0
- package/lib/components/ColorField/ColorField.d.ts +28 -0
- package/lib/components/ColorField/ColorField.d.ts.map +1 -0
- package/lib/components/ColorField/index.d.ts +3 -0
- package/lib/components/ColorField/index.d.ts.map +1 -0
- package/lib/components/DatePicker/DatePicker.d.ts +25 -0
- package/lib/components/DatePicker/DatePicker.d.ts.map +1 -0
- package/lib/components/DatePicker/components/Calendar/Calendar.d.ts +26 -0
- package/lib/components/DatePicker/components/Calendar/Calendar.d.ts.map +1 -0
- package/lib/components/DatePicker/components/Calendar/index.d.ts +2 -0
- package/lib/components/DatePicker/components/Calendar/index.d.ts.map +1 -0
- package/lib/components/DatePicker/components/Day/Day.d.ts +16 -0
- package/lib/components/DatePicker/components/Day/Day.d.ts.map +1 -0
- package/lib/components/DatePicker/components/Day/index.d.ts +2 -0
- package/lib/components/DatePicker/components/Day/index.d.ts.map +1 -0
- package/lib/components/DatePicker/components/Month/Month.d.ts +28 -0
- package/lib/components/DatePicker/components/Month/Month.d.ts.map +1 -0
- package/lib/components/DatePicker/components/Month/index.d.ts +2 -0
- package/lib/components/DatePicker/components/Month/index.d.ts.map +1 -0
- package/lib/components/DatePicker/components/Weekday/Weekday.d.ts +7 -0
- package/lib/components/DatePicker/components/Weekday/Weekday.d.ts.map +1 -0
- package/lib/components/DatePicker/components/Weekday/index.d.ts +2 -0
- package/lib/components/DatePicker/components/Weekday/index.d.ts.map +1 -0
- package/lib/components/DatePicker/components/index.d.ts +5 -0
- package/lib/components/DatePicker/components/index.d.ts.map +1 -0
- package/lib/components/DatePicker/index.d.ts +2 -0
- package/lib/components/DatePicker/index.d.ts.map +1 -0
- package/lib/components/DatePicker/utils/index.d.ts +48 -0
- package/lib/components/DatePicker/utils/index.d.ts.map +1 -0
- package/lib/components/DatePicker/utils/types.d.ts +10 -0
- package/lib/components/DatePicker/utils/types.d.ts.map +1 -0
- package/lib/components/DescriptiveList/DescriptiveList.d.ts +17 -0
- package/lib/components/DescriptiveList/DescriptiveList.d.ts.map +1 -0
- package/lib/components/DescriptiveList/DescriptiveListItem.d.ts +9 -0
- package/lib/components/DescriptiveList/DescriptiveListItem.d.ts.map +1 -0
- package/lib/components/DescriptiveList/index.d.ts +3 -0
- package/lib/components/DescriptiveList/index.d.ts.map +1 -0
- package/lib/components/DropdownCard/DropdownCard.context.d.ts +53 -0
- package/lib/components/DropdownCard/DropdownCard.context.d.ts.map +1 -0
- package/lib/components/DropdownCard/DropdownCard.d.ts +21 -0
- package/lib/components/DropdownCard/DropdownCard.d.ts.map +1 -0
- package/lib/components/DropdownCard/components/DropdownCardActions.d.ts +7 -0
- package/lib/components/DropdownCard/components/DropdownCardActions.d.ts.map +1 -0
- package/lib/components/DropdownCard/components/DropdownCardContent.d.ts +7 -0
- package/lib/components/DropdownCard/components/DropdownCardContent.d.ts.map +1 -0
- package/lib/components/DropdownCard/components/DropdownCardDropdown.d.ts +6 -0
- package/lib/components/DropdownCard/components/DropdownCardDropdown.d.ts.map +1 -0
- package/lib/components/DropdownCard/components/DropdownCardTrigger.d.ts +7 -0
- package/lib/components/DropdownCard/components/DropdownCardTrigger.d.ts.map +1 -0
- package/lib/components/DropdownCard/components/index.d.ts +5 -0
- package/lib/components/DropdownCard/components/index.d.ts.map +1 -0
- package/lib/components/DropdownCard/index.d.ts +3 -0
- package/lib/components/DropdownCard/index.d.ts.map +1 -0
- package/lib/components/FileField/FileField.d.ts +43 -0
- package/lib/components/FileField/FileField.d.ts.map +1 -0
- package/lib/components/FileField/index.d.ts +3 -0
- package/lib/components/FileField/index.d.ts.map +1 -0
- package/lib/components/HyperlinkCard/HyperlinkCard.d.ts +11 -0
- package/lib/components/HyperlinkCard/HyperlinkCard.d.ts.map +1 -0
- package/lib/components/HyperlinkCard/index.d.ts +3 -0
- package/lib/components/HyperlinkCard/index.d.ts.map +1 -0
- package/lib/components/Icon/Icon.d.ts +16 -0
- package/lib/components/Icon/Icon.d.ts.map +1 -0
- package/lib/components/Icon/index.d.ts +3 -0
- package/lib/components/Icon/index.d.ts.map +1 -0
- package/lib/components/Loader/Loader.d.ts +8 -0
- package/lib/components/Loader/Loader.d.ts.map +1 -0
- package/lib/components/Loader/index.d.ts +3 -0
- package/lib/components/Loader/index.d.ts.map +1 -0
- package/lib/components/Modal/Modal.d.ts +11 -0
- package/lib/components/Modal/Modal.d.ts.map +1 -0
- package/lib/components/Modal/ModalProvider/ModalProviderFooter.d.ts +4 -0
- package/lib/components/Modal/ModalProvider/ModalProviderFooter.d.ts.map +1 -0
- package/lib/components/Modal/ModalProvider/index.d.ts +4 -0
- package/lib/components/Modal/ModalProvider/index.d.ts.map +1 -0
- package/lib/components/Modal/index.d.ts +5 -0
- package/lib/components/Modal/index.d.ts.map +1 -0
- package/lib/components/Modal/types/index.d.ts +56 -0
- package/lib/components/Modal/types/index.d.ts.map +1 -0
- package/lib/components/Modal/utils/events.d.ts +9 -0
- package/lib/components/Modal/utils/events.d.ts.map +1 -0
- package/lib/components/Modal/utils/index.d.ts +4 -0
- package/lib/components/Modal/utils/index.d.ts.map +1 -0
- package/lib/components/Modal/utils/reducer.d.ts +37 -0
- package/lib/components/Modal/utils/reducer.d.ts.map +1 -0
- package/lib/components/Modal/utils/useModal.d.ts +6 -0
- package/lib/components/Modal/utils/useModal.d.ts.map +1 -0
- package/lib/components/Page/Page.d.ts +40 -0
- package/lib/components/Page/Page.d.ts.map +1 -0
- package/lib/components/Page/index.d.ts +3 -0
- package/lib/components/Page/index.d.ts.map +1 -0
- package/lib/components/Pagination/Pagination.d.ts +24 -0
- package/lib/components/Pagination/Pagination.d.ts.map +1 -0
- package/lib/components/Pagination/index.d.ts +3 -0
- package/lib/components/Pagination/index.d.ts.map +1 -0
- package/lib/components/Progress/Progress.d.ts +11 -0
- package/lib/components/Progress/Progress.d.ts.map +1 -0
- package/lib/components/Progress/index.d.ts +3 -0
- package/lib/components/Progress/index.d.ts.map +1 -0
- package/lib/components/Radio/Radio.d.ts +39 -0
- package/lib/components/Radio/Radio.d.ts.map +1 -0
- package/lib/components/Radio/RadioGroup/RadioGroup.context.d.ts +15 -0
- package/lib/components/Radio/RadioGroup/RadioGroup.context.d.ts.map +1 -0
- package/lib/components/Radio/RadioGroup/RadioGroup.d.ts +28 -0
- package/lib/components/Radio/RadioGroup/RadioGroup.d.ts.map +1 -0
- package/lib/components/Radio/index.d.ts +4 -0
- package/lib/components/Radio/index.d.ts.map +1 -0
- package/lib/components/RangeField/RangeField.d.ts +36 -0
- package/lib/components/RangeField/RangeField.d.ts.map +1 -0
- package/lib/components/RangeField/index.d.ts +3 -0
- package/lib/components/RangeField/index.d.ts.map +1 -0
- package/lib/components/Select/Select.d.ts +56 -0
- package/lib/components/Select/Select.d.ts.map +1 -0
- package/lib/components/Select/index.d.ts +3 -0
- package/lib/components/Select/index.d.ts.map +1 -0
- package/lib/components/Sidebar/Sidebar.d.ts +40 -0
- package/lib/components/Sidebar/Sidebar.d.ts.map +1 -0
- package/lib/components/Sidebar/components/Menu.d.ts +17 -0
- package/lib/components/Sidebar/components/Menu.d.ts.map +1 -0
- package/lib/components/Sidebar/components/MenuItem.d.ts +18 -0
- package/lib/components/Sidebar/components/MenuItem.d.ts.map +1 -0
- package/lib/components/Sidebar/components/Section.d.ts +9 -0
- package/lib/components/Sidebar/components/Section.d.ts.map +1 -0
- package/lib/components/Sidebar/components/SubMenu.d.ts +11 -0
- package/lib/components/Sidebar/components/SubMenu.d.ts.map +1 -0
- package/lib/components/Sidebar/index.d.ts +3 -0
- package/lib/components/Sidebar/index.d.ts.map +1 -0
- package/lib/components/Spinner/Spinner.d.ts +7 -0
- package/lib/components/Spinner/Spinner.d.ts.map +1 -0
- package/lib/components/Spinner/index.d.ts +3 -0
- package/lib/components/Spinner/index.d.ts.map +1 -0
- package/lib/components/StatCard/StatCard.d.ts +20 -0
- package/lib/components/StatCard/StatCard.d.ts.map +1 -0
- package/lib/components/StatCard/index.d.ts +3 -0
- package/lib/components/StatCard/index.d.ts.map +1 -0
- package/lib/components/Switch/Switch.d.ts +33 -0
- package/lib/components/Switch/Switch.d.ts.map +1 -0
- package/lib/components/Switch/index.d.ts +3 -0
- package/lib/components/Switch/index.d.ts.map +1 -0
- package/lib/components/Table/Table.d.ts +85 -0
- package/lib/components/Table/Table.d.ts.map +1 -0
- package/lib/components/Table/Table.types.d.ts +3 -0
- package/lib/components/Table/Table.types.d.ts.map +1 -0
- package/lib/components/Table/components/Checkbox/index.d.ts +11 -0
- package/lib/components/Table/components/Checkbox/index.d.ts.map +1 -0
- package/lib/components/Table/components/TableBody.d.ts +6 -0
- package/lib/components/Table/components/TableBody.d.ts.map +1 -0
- package/lib/components/Table/components/TableCell.d.ts +8 -0
- package/lib/components/Table/components/TableCell.d.ts.map +1 -0
- package/lib/components/Table/components/TableHead.d.ts +6 -0
- package/lib/components/Table/components/TableHead.d.ts.map +1 -0
- package/lib/components/Table/components/TableHeadCell.d.ts +19 -0
- package/lib/components/Table/components/TableHeadCell.d.ts.map +1 -0
- package/lib/components/Table/components/TablePagination.d.ts +7 -0
- package/lib/components/Table/components/TablePagination.d.ts.map +1 -0
- package/lib/components/Table/components/TableProvider/TableProvider.d.ts +4 -0
- package/lib/components/Table/components/TableProvider/TableProvider.d.ts.map +1 -0
- package/lib/components/Table/components/TableProvider/index.d.ts +2 -0
- package/lib/components/Table/components/TableProvider/index.d.ts.map +1 -0
- package/lib/components/Table/components/TableRow.d.ts +9 -0
- package/lib/components/Table/components/TableRow.d.ts.map +1 -0
- package/lib/components/Table/index.d.ts +6 -0
- package/lib/components/Table/index.d.ts.map +1 -0
- package/lib/components/Table/utils/rows/context.d.ts +16 -0
- package/lib/components/Table/utils/rows/context.d.ts.map +1 -0
- package/lib/components/Table/utils/rows/hooks.d.ts +2 -0
- package/lib/components/Table/utils/rows/hooks.d.ts.map +1 -0
- package/lib/components/Table/utils/rows/index.d.ts +3 -0
- package/lib/components/Table/utils/rows/index.d.ts.map +1 -0
- package/lib/components/Table/utils/table/context.d.ts +29 -0
- package/lib/components/Table/utils/table/context.d.ts.map +1 -0
- package/lib/components/Table/utils/table/hooks.d.ts +11 -0
- package/lib/components/Table/utils/table/hooks.d.ts.map +1 -0
- package/lib/components/Table/utils/table/index.d.ts +4 -0
- package/lib/components/Table/utils/table/index.d.ts.map +1 -0
- package/lib/components/Table/utils/table/types.d.ts +53 -0
- package/lib/components/Table/utils/table/types.d.ts.map +1 -0
- package/lib/components/Table/utils/useSelectableResourceState/index.d.ts +20 -0
- package/lib/components/Table/utils/useSelectableResourceState/index.d.ts.map +1 -0
- package/lib/components/Tag/Tag.d.ts +22 -0
- package/lib/components/Tag/Tag.d.ts.map +1 -0
- package/lib/components/Tag/TagGroup.d.ts +9 -0
- package/lib/components/Tag/TagGroup.d.ts.map +1 -0
- package/lib/components/Tag/index.d.ts +3 -0
- package/lib/components/Tag/index.d.ts.map +1 -0
- package/lib/components/TextField/TextField.d.ts +42 -0
- package/lib/components/TextField/TextField.d.ts.map +1 -0
- package/lib/components/TextField/index.d.ts +3 -0
- package/lib/components/TextField/index.d.ts.map +1 -0
- package/lib/components/Textarea/Textarea.d.ts +31 -0
- package/lib/components/Textarea/Textarea.d.ts.map +1 -0
- package/lib/components/Textarea/index.d.ts +3 -0
- package/lib/components/Textarea/index.d.ts.map +1 -0
- package/lib/components/Thumbnail/Thumbnail.d.ts +14 -0
- package/lib/components/Thumbnail/Thumbnail.d.ts.map +1 -0
- package/lib/components/Thumbnail/index.d.ts +3 -0
- package/lib/components/Thumbnail/index.d.ts.map +1 -0
- package/lib/components/Toast/Toast.d.ts +23 -0
- package/lib/components/Toast/Toast.d.ts.map +1 -0
- package/lib/components/Toast/Toasts.context.d.ts +3 -0
- package/lib/components/Toast/Toasts.context.d.ts.map +1 -0
- package/lib/components/Toast/ToastsContainer/index.d.ts +23 -0
- package/lib/components/Toast/ToastsContainer/index.d.ts.map +1 -0
- package/lib/components/Toast/ToastsProvider/index.d.ts +22 -0
- package/lib/components/Toast/ToastsProvider/index.d.ts.map +1 -0
- package/lib/components/Toast/ToastsProvider/useToastsState/useToastsState.d.ts +13 -0
- package/lib/components/Toast/ToastsProvider/useToastsState/useToastsState.d.ts.map +1 -0
- package/lib/components/Toast/events.d.ts +37 -0
- package/lib/components/Toast/events.d.ts.map +1 -0
- package/lib/components/Toast/index.d.ts +11 -0
- package/lib/components/Toast/index.d.ts.map +1 -0
- package/lib/components/Toast/types.d.ts +12 -0
- package/lib/components/Toast/types.d.ts.map +1 -0
- package/lib/components/Tooltip/Tooltip.d.ts +34 -0
- package/lib/components/Tooltip/Tooltip.d.ts.map +1 -0
- package/lib/components/Tooltip/index.d.ts +3 -0
- package/lib/components/Tooltip/index.d.ts.map +1 -0
- package/lib/components/Tooltip/useTooltip.d.ts +39 -0
- package/lib/components/Tooltip/useTooltip.d.ts.map +1 -0
- package/lib/components/Visualizer/Visualizer.context.d.ts +14 -0
- package/lib/components/Visualizer/Visualizer.context.d.ts.map +1 -0
- package/lib/components/Visualizer/Visualizer.d.ts +12 -0
- package/lib/components/Visualizer/Visualizer.d.ts.map +1 -0
- package/lib/components/Visualizer/VisualizerMobileOpener.d.ts +7 -0
- package/lib/components/Visualizer/VisualizerMobileOpener.d.ts.map +1 -0
- package/lib/components/Visualizer/index.d.ts +3 -0
- package/lib/components/Visualizer/index.d.ts.map +1 -0
- package/lib/components/index.d.ts +36 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/types.d.ts +44 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/utils/classNames/index.d.ts +38 -0
- package/lib/utils/classNames/index.d.ts.map +1 -0
- package/lib/utils/createUseExternalEvents/index.d.ts +14 -0
- package/lib/utils/createUseExternalEvents/index.d.ts.map +1 -0
- package/lib/utils/guid/index.d.ts +10 -0
- package/lib/utils/guid/index.d.ts.map +1 -0
- package/lib/utils/index.d.ts +12 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/useDidUpdate/index.d.ts +30 -0
- package/lib/utils/useDidUpdate/index.d.ts.map +1 -0
- package/lib/utils/useDropdown/index.d.ts +57 -0
- package/lib/utils/useDropdown/index.d.ts.map +1 -0
- package/lib/utils/useEventListener/index.d.ts +7 -0
- package/lib/utils/useEventListener/index.d.ts.map +1 -0
- package/lib/utils/useForceUpdate/index.d.ts +28 -0
- package/lib/utils/useForceUpdate/index.d.ts.map +1 -0
- package/lib/utils/useIsomorphicEffect/index.d.ts +21 -0
- package/lib/utils/useIsomorphicEffect/index.d.ts.map +1 -0
- package/lib/utils/useQueue/index.d.ts +65 -0
- package/lib/utils/useQueue/index.d.ts.map +1 -0
- package/lib/utils/useUid/index.d.ts +10 -0
- package/lib/utils/useUid/index.d.ts.map +1 -0
- package/lib/utils/useUncontrolled/index.d.ts +38 -0
- package/lib/utils/useUncontrolled/index.d.ts.map +1 -0
- package/package.json +47 -3
- package/theme.css +1 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useUncontrolled } from '../../utils/useUncontrolled/index.js';
|
|
4
|
+
import { useUid } from '../../utils/useUid/index.js';
|
|
5
|
+
import { classNames } from '../../utils/classNames/index.js';
|
|
6
|
+
|
|
7
|
+
const Switch = React.forwardRef((props, ref) => {
|
|
8
|
+
const {
|
|
9
|
+
id,
|
|
10
|
+
label,
|
|
11
|
+
name,
|
|
12
|
+
disabled,
|
|
13
|
+
checked: checkedProp,
|
|
14
|
+
defaultChecked = false,
|
|
15
|
+
helpText,
|
|
16
|
+
labelClassName,
|
|
17
|
+
inputClassName,
|
|
18
|
+
onChange,
|
|
19
|
+
...others
|
|
20
|
+
} = props;
|
|
21
|
+
const [checked, setChecked] = useUncontrolled({
|
|
22
|
+
value: checkedProp,
|
|
23
|
+
defaultValue: defaultChecked,
|
|
24
|
+
finalValue: false,
|
|
25
|
+
onChange
|
|
26
|
+
});
|
|
27
|
+
const uid = useUid(id);
|
|
28
|
+
const handleChange = (event) => {
|
|
29
|
+
setChecked(event.currentTarget.checked);
|
|
30
|
+
};
|
|
31
|
+
return /* @__PURE__ */ React.createElement("label", { htmlFor: uid }, label && /* @__PURE__ */ React.createElement("p", { className: labelClassName }, label), /* @__PURE__ */ React.createElement("span", { className: classNames("switch", inputClassName) }, /* @__PURE__ */ React.createElement(
|
|
32
|
+
"input",
|
|
33
|
+
{
|
|
34
|
+
...others,
|
|
35
|
+
ref,
|
|
36
|
+
type: "checkbox",
|
|
37
|
+
name,
|
|
38
|
+
id: uid,
|
|
39
|
+
checked,
|
|
40
|
+
disabled,
|
|
41
|
+
onChange: handleChange
|
|
42
|
+
}
|
|
43
|
+
), /* @__PURE__ */ React.createElement("figure", null)), helpText && /* @__PURE__ */ React.createElement("small", null, helpText));
|
|
44
|
+
});
|
|
45
|
+
Switch.displayName = "Switch";
|
|
46
|
+
|
|
47
|
+
export { Switch };
|
|
48
|
+
//# sourceMappingURL=Switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.js","sources":["../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useUid, useUncontrolled } from '@/utils';\n\n/** Every native `<input>` prop (`aria-*`, `data-*`, ...) is accepted and forwarded to the switch input. */\nexport interface SwitchProps extends Omit<React.ComponentPropsWithoutRef<'input'>, 'onChange' | 'type'> {\n /** The HTML ID attribute to be applied to the switch element (optional). */\n id?: string;\n /** The name attribute to be applied to the switch element (optional). */\n name?: string;\n /** Whether the switch toggle should be disabled (optional). */\n disabled?: boolean;\n /** The checked state of the switch toggle, for a controlled switch (optional). */\n checked?: boolean;\n /** The default checked state of the switch toggle, for an uncontrolled switch (optional). */\n defaultChecked?: boolean;\n /**\n * A function that is called when the state of the switch toggle changes (optional).\n * This function accepts the new state of the switch toggle as input.\n */\n onChange?(value: boolean): void;\n /** The label to be displayed next to the switch toggle (optional). */\n label?: React.ReactNode;\n /** The help text to be displayed below the switch toggle (optional). */\n helpText?: React.ReactNode;\n /** CSS class names to be applied to the label element (optional). */\n labelClassName?: string;\n /** CSS class names to be applied to the switch input element (optional). */\n inputClassName?: string;\n}\n\n/**\n * A toggle switch with a label. Control it with checked and onChange, or leave it uncontrolled with\n * defaultChecked.\n */\nexport const Switch = React.forwardRef<HTMLInputElement, SwitchProps>((props, ref) => {\n const {\n id,\n label,\n name,\n disabled,\n checked: checkedProp,\n defaultChecked = false,\n helpText,\n labelClassName,\n inputClassName,\n onChange,\n ...others\n } = props;\n const [checked, setChecked] = useUncontrolled<boolean>({\n value: checkedProp,\n defaultValue: defaultChecked,\n finalValue: false,\n onChange,\n });\n\n const uid = useUid(id);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n setChecked(event.currentTarget.checked);\n };\n\n return (\n <label htmlFor={uid}>\n {label && <p className={labelClassName}>{label}</p>}\n <span className={classNames('switch', inputClassName)}>\n <input\n {...others}\n ref={ref}\n type=\"checkbox\"\n name={name}\n id={uid}\n checked={checked}\n disabled={disabled}\n onChange={handleChange}\n />\n <figure />\n </span>\n {helpText && <small>{helpText}</small>}\n </label>\n );\n});\n\nSwitch.displayName = 'Switch';\n"],"names":[],"mappings":";;;;;;AAEY,MAAC,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACvD,EAAE,MAAM;AACR,IAAI,EAAE;AACN,IAAI,KAAK;AACT,IAAI,IAAI;AACR,IAAI,QAAQ;AACZ,IAAI,OAAO,EAAE,WAAW;AACxB,IAAI,cAAc,GAAG,KAAK;AAC1B,IAAI,QAAQ;AACZ,IAAI,cAAc;AAClB,IAAI,cAAc;AAClB,IAAI,QAAQ;AACZ,IAAI,GAAG;AACP,GAAG,GAAG,KAAK;AACX,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,eAAe,CAAC;AAChD,IAAI,KAAK,EAAE,WAAW;AACtB,IAAI,YAAY,EAAE,cAAc;AAChC,IAAI,UAAU,EAAE,KAAK;AACrB,IAAI;AACJ,GAAG,CAAC;AACJ,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC;AACxB,EAAE,MAAM,YAAY,GAAG,CAAC,KAAK,KAAK;AAClC,IAAI,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;AAC3C,EAAE,CAAC;AACH,EAAE,uBAAuB,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,KAAK,oBAAoB,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,EAAE,KAAK,CAAC,kBAAkB,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,cAAc,CAAC,EAAE,kBAAkB,KAAK,CAAC,aAAa;AACrS,IAAI,OAAO;AACX,IAAI;AACJ,MAAM,GAAG,MAAM;AACf,MAAM,GAAG;AACT,MAAM,IAAI,EAAE,UAAU;AACtB,MAAM,IAAI;AACV,MAAM,EAAE,EAAE,GAAG;AACb,MAAM,OAAO;AACb,MAAM,QAAQ;AACd,MAAM,QAAQ,EAAE;AAChB;AACA,GAAG,kBAAkB,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,EAAE,QAAQ,oBAAoB,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AACpI,CAAC;AACD,MAAM,CAAC,WAAW,GAAG,QAAQ;;"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Button } from '../Button/Button.js';
|
|
4
|
+
import { Checkbox } from './components/Checkbox/index.js';
|
|
5
|
+
import { TableBody } from './components/TableBody.js';
|
|
6
|
+
import { TableCell } from './components/TableCell.js';
|
|
7
|
+
import { TableHead } from './components/TableHead.js';
|
|
8
|
+
import { TableHeadCell } from './components/TableHeadCell.js';
|
|
9
|
+
import { TablePagination } from './components/TablePagination.js';
|
|
10
|
+
import { TableProvider } from './components/TableProvider/TableProvider.js';
|
|
11
|
+
import { TableRow } from './components/TableRow.js';
|
|
12
|
+
import { useTableValue, useTableSelectionChange } from './utils/table/hooks.js';
|
|
13
|
+
import './utils/table/context.js';
|
|
14
|
+
import { SelectionType, SELECT_ALL_ITEMS } from './utils/table/types.js';
|
|
15
|
+
import { classNames } from '../../utils/classNames/index.js';
|
|
16
|
+
|
|
17
|
+
const TableBase = React.forwardRef((props, ref) => {
|
|
18
|
+
const { children, showPagination, selectActions, browsable = false } = props;
|
|
19
|
+
const { bulkSelectState, itemCount, selectedItemsCount, selectable } = useTableValue();
|
|
20
|
+
const handleSelectionChange = useTableSelectionChange();
|
|
21
|
+
const handleSelectAllItems = React.useCallback(() => {
|
|
22
|
+
handleSelectionChange(selectedItemsCount === SELECT_ALL_ITEMS ? SelectionType.Page : SelectionType.All);
|
|
23
|
+
}, [handleSelectionChange, selectedItemsCount]);
|
|
24
|
+
const handleTogglePage = React.useCallback(() => {
|
|
25
|
+
handleSelectionChange(SelectionType.Page);
|
|
26
|
+
}, [bulkSelectState, handleSelectionChange]);
|
|
27
|
+
const bodyMarkup = /* @__PURE__ */ React.createElement("div", { className: "table-container" }, /* @__PURE__ */ React.createElement("table", { ref, className: classNames("datatable", { selectable, browsable }) }, children));
|
|
28
|
+
return /* @__PURE__ */ React.createElement("section", { className: "table-section" }, /* @__PURE__ */ React.createElement("form", null, bulkSelectState && /* @__PURE__ */ React.createElement("div", { className: "table-actions visible" }, /* @__PURE__ */ React.createElement("div", { className: "items-group justify", style: { alignItems: "center" } }, /* @__PURE__ */ React.createElement("div", { className: "items-group" }, /* @__PURE__ */ React.createElement(
|
|
29
|
+
Checkbox,
|
|
30
|
+
{
|
|
31
|
+
labelClassName: "items-group",
|
|
32
|
+
onChange: () => handleTogglePage(),
|
|
33
|
+
className: selectedItemsCount !== SELECT_ALL_ITEMS && selectedItemsCount < itemCount ? "neutral" : "",
|
|
34
|
+
checked: true,
|
|
35
|
+
label: /* @__PURE__ */ React.createElement("p", { "data-role": "input-value" }, `${selectedItemsCount} ${selectedItemsCount === SELECT_ALL_ITEMS || selectedItemsCount > 1 ? "items" : "item"} selected`)
|
|
36
|
+
}
|
|
37
|
+
), selectActions), /* @__PURE__ */ React.createElement("div", { className: "action" }, /* @__PURE__ */ React.createElement(Button, { variant: "inline", onClick: () => handleSelectAllItems() }, "Select all items")))), bodyMarkup, showPagination && /* @__PURE__ */ React.createElement(
|
|
38
|
+
TablePagination,
|
|
39
|
+
{
|
|
40
|
+
hasNext: props.hasNextPage,
|
|
41
|
+
hasPrevious: props.hasPreviousPage,
|
|
42
|
+
onNext: props.onNextPage,
|
|
43
|
+
onPrevious: props.onPreviousPage,
|
|
44
|
+
nextButtonProps: props.nextPageButtonProps,
|
|
45
|
+
previousButtonProps: props.previousPageButtonProps,
|
|
46
|
+
className: props.paginationClassName
|
|
47
|
+
}
|
|
48
|
+
)));
|
|
49
|
+
});
|
|
50
|
+
TableBase.displayName = "TableBase";
|
|
51
|
+
function Table({
|
|
52
|
+
children,
|
|
53
|
+
selectable = false,
|
|
54
|
+
itemCount,
|
|
55
|
+
selectedItemsCount = 0,
|
|
56
|
+
onSelectionChange,
|
|
57
|
+
...tableBaseProps
|
|
58
|
+
}) {
|
|
59
|
+
return /* @__PURE__ */ React.createElement(
|
|
60
|
+
TableProvider,
|
|
61
|
+
{
|
|
62
|
+
selectable,
|
|
63
|
+
itemCount,
|
|
64
|
+
selectedItemsCount,
|
|
65
|
+
onSelectionChange
|
|
66
|
+
},
|
|
67
|
+
/* @__PURE__ */ React.createElement(TableBase, { ...tableBaseProps }, children)
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
Table.displayName = "Table";
|
|
71
|
+
Table.Head = TableHead;
|
|
72
|
+
Table.Body = TableBody;
|
|
73
|
+
Table.Row = TableRow;
|
|
74
|
+
Table.HeadCell = TableHeadCell;
|
|
75
|
+
Table.Cell = TableCell;
|
|
76
|
+
|
|
77
|
+
export { Table };
|
|
78
|
+
//# sourceMappingURL=Table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.js","sources":["../../../../src/components/Table/Table.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Button, ButtonProps } from '@/components/Button';\nimport { PaginationProps } from '@/components/Pagination';\n\nimport { Checkbox } from './components/Checkbox';\nimport { TableBody } from './components/TableBody';\nimport { TableCell } from './components/TableCell';\nimport { TableHead } from './components/TableHead';\nimport { TableHeadCell } from './components/TableHeadCell';\nimport { TablePagination, TablePaginationProps } from './components/TablePagination';\nimport { TableProvider } from './components/TableProvider';\nimport { TableRow } from './components/TableRow';\nimport {\n TableProviderProps,\n SelectionType,\n SELECT_ALL_ITEMS,\n useTableSelectionChange,\n useTableValue,\n} from './utils/table';\nimport { classNames } from '@/utils';\n\nexport interface NativeTableProps extends React.ComponentProps<'table'> {\n /** The table content (optional). */\n children?: React.ReactNode;\n /** Whether the table rows should be selectable (optional). */\n selectable?: boolean;\n /** Whether the table is browsable (optional). */\n browsable?: boolean;\n /** The actions to be displayed when a row in the table is selected (optional). */\n selectActions?: React.ReactNode;\n}\n\n/**\n * This interface defines the props that can be passed to a table component that includes pagination.\n * It extends the `NativeTableProps` interface, and includes additional props related to pagination.\n */\ninterface TableBaseWithPagination extends NativeTableProps, Omit<TablePaginationProps, keyof PaginationProps> {\n /** A boolean indicating whether pagination should be displayed (required). */\n showPagination: true;\n /** A function that is called when the \"Next\" button is clicked (required). */\n onNextPage: () => void;\n /** A function that is called when the \"Previous\" button is clicked (required). */\n onPreviousPage: () => void;\n /** A boolean indicating whether there is a next page (required). */\n hasNextPage: boolean;\n /** A boolean indicating whether there is a previous page (required). */\n hasPreviousPage: boolean;\n /** The props to be applied to the \"Next\" button (optional). */\n nextPageButtonProps?: Partial<ButtonProps>;\n /** The props to be applied to the \"Previous\" button (optional). */\n previousPageButtonProps?: Partial<ButtonProps>;\n /** CSS class names to be applied to the pagination element (optional). */\n paginationClassName?: string;\n}\n\n/**\n * This interface defines the props that can be passed to a table component that does not include pagination.\n * It extends the `NativeTableProps` interface, and does not include any additional props.\n */\ninterface TableBaseWithoutPagination extends NativeTableProps {\n /** A boolean indicating whether pagination should be displayed (optional). */\n showPagination?: never;\n /** A function that is called when the \"Next\" button is clicked (optional). */\n onNextPage?: never;\n /** A function that is called when the \"Previous\" button is clicked (optional). */\n onPreviousPage?: never;\n /** A boolean indicating whether there is a next page (optional). */\n hasNextPage?: never;\n /** A boolean indicating whether there is a previous page (optional). */\n hasPreviousPage?: never;\n /** The props to be applied to the \"Next\" button (optional). */\n nextPageButtonProps?: never;\n /** The props to be applied to the \"Previous\" button (optional). */\n previousPageButtonProps?: never;\n /** CSS class names to be applied to the pagination element (optional). */\n paginationClassName?: never;\n}\n\n/**\n * This type defines the props that can be passed to a table component.\n * It includes the `TableBaseWithPagination` and `TableBaseWithoutPagination` interfaces,\n * and ensures that only one set of props is used at a time.\n */\nexport type TableBaseProps = TableBaseWithPagination | TableBaseWithoutPagination;\n\nconst TableBase = React.forwardRef<HTMLTableElement, TableBaseProps>((props, ref) => {\n const { children, showPagination, selectActions, browsable = false } = props;\n const { bulkSelectState, itemCount, selectedItemsCount, selectable } = useTableValue();\n const handleSelectionChange = useTableSelectionChange();\n\n const handleSelectAllItems = React.useCallback(() => {\n handleSelectionChange(selectedItemsCount === SELECT_ALL_ITEMS ? SelectionType.Page : SelectionType.All);\n }, [handleSelectionChange, selectedItemsCount]);\n\n const handleTogglePage = React.useCallback(() => {\n handleSelectionChange(SelectionType.Page);\n }, [bulkSelectState, handleSelectionChange]);\n\n const bodyMarkup = (\n <div className=\"table-container\">\n <table ref={ref} className={classNames('datatable', { selectable, browsable })}>\n {children}\n </table>\n </div>\n );\n return (\n <section className=\"table-section\">\n <form>\n {bulkSelectState && (\n <div className=\"table-actions visible\">\n <div className=\"items-group justify\" style={{ alignItems: 'center' }}>\n <div className=\"items-group\">\n <Checkbox\n labelClassName=\"items-group\"\n onChange={() => handleTogglePage()}\n className={selectedItemsCount !== SELECT_ALL_ITEMS && selectedItemsCount < itemCount ? 'neutral' : ''}\n checked\n label={\n <p data-role=\"input-value\">{`${selectedItemsCount} ${\n selectedItemsCount === SELECT_ALL_ITEMS || selectedItemsCount > 1 ? 'items' : 'item'\n } selected`}</p>\n }\n />\n {selectActions}\n </div>\n\n <div className=\"action\">\n <Button variant=\"inline\" onClick={() => handleSelectAllItems()}>\n Select all items\n </Button>\n </div>\n </div>\n </div>\n )}\n {bodyMarkup}\n {showPagination && (\n <TablePagination\n hasNext={props.hasNextPage}\n hasPrevious={props.hasPreviousPage}\n onNext={props.onNextPage}\n onPrevious={props.onPreviousPage}\n nextButtonProps={props.nextPageButtonProps}\n previousButtonProps={props.previousPageButtonProps}\n className={props.paginationClassName}\n />\n )}\n </form>\n </section>\n );\n}) as any;\n\nTableBase.displayName = 'TableBase';\n\nexport type TableProps = TableBaseProps & TableProviderProps;\n\n/**\n * A data table with typed columns, optional row selection, and pagination. Compose it with Table.Head, HeadCell,\n * Body, Row and Cell.\n */\nexport function Table({\n children,\n selectable = false,\n itemCount,\n selectedItemsCount = 0,\n onSelectionChange,\n ...tableBaseProps\n}: TableProps) {\n return (\n <TableProvider\n selectable={selectable}\n itemCount={itemCount}\n selectedItemsCount={selectedItemsCount}\n onSelectionChange={onSelectionChange}\n >\n <TableBase {...tableBaseProps}>{children}</TableBase>\n </TableProvider>\n );\n}\n\nTable.displayName = 'Table';\n\nTable.Head = TableHead;\nTable.Body = TableBody;\nTable.Row = TableRow;\nTable.HeadCell = TableHeadCell;\nTable.Cell = TableCell;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACnD,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,GAAG,KAAK,EAAE,GAAG,KAAK;AAC9E,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,kBAAkB,EAAE,UAAU,EAAE,GAAG,aAAa,EAAE;AACxF,EAAE,MAAM,qBAAqB,GAAG,uBAAuB,EAAE;AACzD,EAAE,MAAM,oBAAoB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM;AACvD,IAAI,qBAAqB,CAAC,kBAAkB,KAAK,gBAAgB,GAAG,aAAa,CAAC,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC;AAC3G,EAAE,CAAC,EAAE,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,CAAC;AACjD,EAAE,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM;AACnD,IAAI,qBAAqB,CAAC,aAAa,CAAC,IAAI,CAAC;AAC7C,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAC;AAC9C,EAAE,MAAM,UAAU,mBAAmB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE,kBAAkB,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;AACjO,EAAE,uBAAuB,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,kBAAkB,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,eAAe,oBAAoB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE,kBAAkB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,qBAAqB,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,kBAAkB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,KAAK,CAAC,aAAa;AAC9c,IAAI,QAAQ;AACZ,IAAI;AACJ,MAAM,cAAc,EAAE,aAAa;AACnC,MAAM,QAAQ,EAAE,MAAM,gBAAgB,EAAE;AACxC,MAAM,SAAS,EAAE,kBAAkB,KAAK,gBAAgB,IAAI,kBAAkB,GAAG,SAAS,GAAG,SAAS,GAAG,EAAE;AAC3G,MAAM,OAAO,EAAE,IAAI;AACnB,MAAM,KAAK,kBAAkB,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,kBAAkB,KAAK,gBAAgB,IAAI,kBAAkB,GAAG,CAAC,GAAG,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC;AAC9M;AACA,GAAG,EAAE,aAAa,CAAC,kBAAkB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,oBAAoB,EAAE,EAAE,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,cAAc,oBAAoB,KAAK,CAAC,aAAa;AAC5R,IAAI,eAAe;AACnB,IAAI;AACJ,MAAM,OAAO,EAAE,KAAK,CAAC,WAAW;AAChC,MAAM,WAAW,EAAE,KAAK,CAAC,eAAe;AACxC,MAAM,MAAM,EAAE,KAAK,CAAC,UAAU;AAC9B,MAAM,UAAU,EAAE,KAAK,CAAC,cAAc;AACtC,MAAM,eAAe,EAAE,KAAK,CAAC,mBAAmB;AAChD,MAAM,mBAAmB,EAAE,KAAK,CAAC,uBAAuB;AACxD,MAAM,SAAS,EAAE,KAAK,CAAC;AACvB;AACA,GAAG,CAAC,CAAC;AACL,CAAC,CAAC;AACF,SAAS,CAAC,WAAW,GAAG,WAAW;AAC5B,SAAS,KAAK,CAAC;AACtB,EAAE,QAAQ;AACV,EAAE,UAAU,GAAG,KAAK;AACpB,EAAE,SAAS;AACX,EAAE,kBAAkB,GAAG,CAAC;AACxB,EAAE,iBAAiB;AACnB,EAAE,GAAG;AACL,CAAC,EAAE;AACH,EAAE,uBAAuB,KAAK,CAAC,aAAa;AAC5C,IAAI,aAAa;AACjB,IAAI;AACJ,MAAM,UAAU;AAChB,MAAM,SAAS;AACf,MAAM,kBAAkB;AACxB,MAAM;AACN,KAAK;AACL,oBAAoB,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,EAAE,GAAG,cAAc,EAAE,EAAE,QAAQ;AAClF,GAAG;AACH;AACA,KAAK,CAAC,WAAW,GAAG,OAAO;AAC3B,KAAK,CAAC,IAAI,GAAG,SAAS;AACtB,KAAK,CAAC,IAAI,GAAG,SAAS;AACtB,KAAK,CAAC,GAAG,GAAG,QAAQ;AACpB,KAAK,CAAC,QAAQ,GAAG,aAAa;AAC9B,KAAK,CAAC,IAAI,GAAG,SAAS;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Checkbox as Checkbox$1 } from '../../../Checkbox/Checkbox.js';
|
|
4
|
+
import '../../../Checkbox/CheckboxGroup/CheckboxGroup.context.js';
|
|
5
|
+
import { RowContext } from '../../utils/rows/context.js';
|
|
6
|
+
|
|
7
|
+
function Checkbox({ className, label, labelClassName, onChange, checked }) {
|
|
8
|
+
const { itemId, selected, disabled } = React.useContext(RowContext);
|
|
9
|
+
return /* @__PURE__ */ React.createElement(
|
|
10
|
+
Checkbox$1,
|
|
11
|
+
{
|
|
12
|
+
id: itemId,
|
|
13
|
+
checked: selected || checked,
|
|
14
|
+
disabled,
|
|
15
|
+
value: itemId ?? "",
|
|
16
|
+
inputClassName: className,
|
|
17
|
+
labelClassName,
|
|
18
|
+
label,
|
|
19
|
+
onChange
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { Checkbox };
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/components/Table/components/Checkbox/index.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Checkbox as DefaultCheckbox } from '@/components/Checkbox';\nimport { RowContext } from '../../utils/rows';\n\ntype CheckboxProps = {\n className?: string;\n labelClassName?: string;\n label?: React.ReactNode;\n onChange?: () => void;\n checked?: boolean;\n};\n\nexport function Checkbox({ className, label, labelClassName, onChange, checked }: CheckboxProps) {\n const { itemId, selected, disabled } = React.useContext(RowContext);\n\n return (\n <DefaultCheckbox\n id={itemId}\n checked={selected || checked}\n disabled={disabled}\n value={itemId ?? ''}\n inputClassName={className}\n labelClassName={labelClassName}\n label={label}\n onChange={onChange}\n />\n );\n}\n"],"names":["DefaultCheckbox"],"mappings":";;;;;;AAGO,SAAS,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;AAClF,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC;AACrE,EAAE,uBAAuB,KAAK,CAAC,aAAa;AAC5C,IAAIA,UAAe;AACnB,IAAI;AACJ,MAAM,EAAE,EAAE,MAAM;AAChB,MAAM,OAAO,EAAE,QAAQ,IAAI,OAAO;AAClC,MAAM,QAAQ;AACd,MAAM,KAAK,EAAE,MAAM,IAAI,EAAE;AACzB,MAAM,cAAc,EAAE,SAAS;AAC/B,MAAM,cAAc;AACpB,MAAM,KAAK;AACX,MAAM;AACN;AACA,GAAG;AACH;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableBody.js","sources":["../../../../../src/components/Table/components/TableBody.tsx"],"sourcesContent":["import * as React from 'react';\n\nexport interface TableBodyProps extends React.ComponentProps<'tbody'> {\n children?: React.ReactNode;\n}\n\nexport function TableBody({ children, ...props }: TableBodyProps) {\n return <tbody {...props}>{children}</tbody>;\n}\n"],"names":[],"mappings":";;;AACO,SAAS,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE;AAClD,EAAE,uBAAuB,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,QAAQ,CAAC;AAC7E;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { classNames } from '../../../utils/classNames/index.js';
|
|
4
|
+
|
|
5
|
+
function TableCell({ children, className, type, ...props }) {
|
|
6
|
+
return /* @__PURE__ */ React.createElement("td", { className: classNames(type, className), ...props }, type === "paragraph" ? /* @__PURE__ */ React.createElement("p", null, children) : children);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { TableCell };
|
|
10
|
+
//# sourceMappingURL=TableCell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableCell.js","sources":["../../../../../src/components/Table/components/TableCell.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\nimport type { TableDataType } from '../Table.types';\n\nexport interface TableCellProps extends React.ComponentProps<'td'> {\n type: TableDataType | string;\n children?: React.ReactNode;\n}\n\nexport function TableCell({ children, className, type, ...props }: TableCellProps) {\n return (\n <td className={classNames(type, className)} {...props}>\n {type === 'paragraph' ? <p>{children}</p> : children}\n </td>\n );\n}\n"],"names":[],"mappings":";;;;AAEO,SAAS,SAAS,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE;AACnE,EAAE,uBAAuB,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,IAAI,KAAK,WAAW,mBAAmB,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC;AACpM;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useTableValue, useTableSelectionChange } from '../utils/table/hooks.js';
|
|
4
|
+
import '../utils/table/context.js';
|
|
5
|
+
import { SelectionType } from '../utils/table/types.js';
|
|
6
|
+
import { Checkbox } from './Checkbox/index.js';
|
|
7
|
+
|
|
8
|
+
function TableHead({ children, className, ...props }) {
|
|
9
|
+
const { bulkSelectState, selectable } = useTableValue();
|
|
10
|
+
const handleSelectionChange = useTableSelectionChange();
|
|
11
|
+
const handleTogglePage = React.useCallback(() => {
|
|
12
|
+
handleSelectionChange(SelectionType.Page);
|
|
13
|
+
}, [bulkSelectState, handleSelectionChange]);
|
|
14
|
+
const checkboxMarkup = selectable ? /* @__PURE__ */ React.createElement("th", { className: "selector" }, /* @__PURE__ */ React.createElement(
|
|
15
|
+
Checkbox,
|
|
16
|
+
{
|
|
17
|
+
onChange: handleTogglePage,
|
|
18
|
+
className: bulkSelectState === true || bulkSelectState === "indeterminate" ? "neutral" : ""
|
|
19
|
+
}
|
|
20
|
+
)) : null;
|
|
21
|
+
if (bulkSelectState === true || bulkSelectState === "indeterminate") {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return /* @__PURE__ */ React.createElement("thead", { className, ...props }, /* @__PURE__ */ React.createElement("tr", { className: "thead-titles" }, checkboxMarkup, children));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { TableHead };
|
|
28
|
+
//# sourceMappingURL=TableHead.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableHead.js","sources":["../../../../../src/components/Table/components/TableHead.tsx"],"sourcesContent":["import * as React from 'react';\nimport { SelectionType, useTableSelectionChange, useTableValue } from '../utils/table';\nimport { Checkbox } from './Checkbox';\n\nexport interface TableHeadProps extends React.ComponentProps<'thead'> {\n children?: React.ReactNode;\n}\n\nexport function TableHead({ children, className, ...props }: TableHeadProps) {\n const { bulkSelectState, selectable } = useTableValue();\n const handleSelectionChange = useTableSelectionChange();\n\n const handleTogglePage = React.useCallback(() => {\n handleSelectionChange(SelectionType.Page);\n }, [bulkSelectState, handleSelectionChange]);\n\n const checkboxMarkup = selectable ? (\n <th className=\"selector\">\n <Checkbox\n onChange={handleTogglePage}\n className={bulkSelectState === true || bulkSelectState === 'indeterminate' ? 'neutral' : ''}\n />\n </th>\n ) : null;\n\n if (bulkSelectState === true || bulkSelectState === 'indeterminate') {\n return null;\n }\n return (\n <thead className={className} {...props}>\n <tr className=\"thead-titles\">\n {checkboxMarkup}\n {children}\n </tr>\n </thead>\n );\n}\n"],"names":[],"mappings":";;;;;;;AAGO,SAAS,SAAS,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE;AAC7D,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,aAAa,EAAE;AACzD,EAAE,MAAM,qBAAqB,GAAG,uBAAuB,EAAE;AACzD,EAAE,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM;AACnD,IAAI,qBAAqB,CAAC,aAAa,CAAC,IAAI,CAAC;AAC7C,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAC;AAC9C,EAAE,MAAM,cAAc,GAAG,UAAU,mBAAmB,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,KAAK,CAAC,aAAa;AAC9I,IAAI,QAAQ;AACZ,IAAI;AACJ,MAAM,QAAQ,EAAE,gBAAgB;AAChC,MAAM,SAAS,EAAE,eAAe,KAAK,IAAI,IAAI,eAAe,KAAK,eAAe,GAAG,SAAS,GAAG;AAC/F;AACA,GAAG,CAAC,GAAG,IAAI;AACX,EAAE,IAAI,eAAe,KAAK,IAAI,IAAI,eAAe,KAAK,eAAe,EAAE;AACvE,IAAI,OAAO,IAAI;AACf,EAAE;AACF,EAAE,uBAAuB,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,kBAAkB,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;AAClL;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Tooltip } from '../../Tooltip/Tooltip.js';
|
|
4
|
+
import { classNames } from '../../../utils/classNames/index.js';
|
|
5
|
+
|
|
6
|
+
const TableHeadCell = React.forwardRef(
|
|
7
|
+
({ title, className, type, hasTooltip, tooltipProps, children, ...props }, ref) => {
|
|
8
|
+
if (hasTooltip) {
|
|
9
|
+
return /* @__PURE__ */ React.createElement(Tooltip, { ...tooltipProps ?? {} }, /* @__PURE__ */ React.createElement("th", { ref, className: classNames(type, className, "has-tooltip"), ...props }, React.isValidElement(title) || React.isValidElement(children) ? /* @__PURE__ */ React.createElement(React.Fragment, null, title, children) : /* @__PURE__ */ React.createElement("span", null, title, children)));
|
|
10
|
+
}
|
|
11
|
+
return /* @__PURE__ */ React.createElement("th", { ref, className: classNames(type, className), ...props }, title, children);
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
TableHeadCell.displayName = "TableHeadCell";
|
|
15
|
+
|
|
16
|
+
export { TableHeadCell };
|
|
17
|
+
//# sourceMappingURL=TableHeadCell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableHeadCell.js","sources":["../../../../../src/components/Table/components/TableHeadCell.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Tooltip, TooltipProps } from '@/components/Tooltip';\nimport { classNames } from '@/utils';\nimport type { TableDataType } from '../Table.types';\n\nexport interface TableHeadCellBaseProps extends Omit<React.ComponentProps<'th'>, 'title'> {\n hasTooltip?: boolean;\n tooltipProps?: Omit<TooltipProps, 'children'>;\n type: TableDataType | string;\n}\n\nexport interface TableHeadCellPropsWithChildren extends TableHeadCellBaseProps {\n children?: React.ReactNode;\n title?: never;\n}\n\nexport interface TableHeadCellPropsWithTitle extends TableHeadCellBaseProps {\n children?: never;\n title?: React.ReactNode;\n}\n\nexport type TableHeadCellProps = TableHeadCellPropsWithChildren | TableHeadCellPropsWithTitle;\n\nexport const TableHeadCell = React.forwardRef<HTMLTableCellElement, TableHeadCellProps>(\n ({ title, className, type, hasTooltip, tooltipProps, children, ...props }, ref) => {\n if (hasTooltip) {\n return (\n <Tooltip {...((tooltipProps ?? {}) as Omit<TooltipProps, 'children'>)}>\n <th ref={ref} className={classNames(type, className, 'has-tooltip')} {...props}>\n {React.isValidElement(title) || React.isValidElement(children) ? (\n <>\n {title}\n {children}\n </>\n ) : (\n <span>\n {title}\n {children}\n </span>\n )}\n </th>\n </Tooltip>\n );\n }\n\n return (\n <th ref={ref} className={classNames(type, className)} {...props}>\n {title}\n {children}\n </th>\n );\n }\n);\n\nTableHeadCell.displayName = 'TableHeadCell';\n"],"names":[],"mappings":";;;;;AAGY,MAAC,aAAa,GAAG,KAAK,CAAC,UAAU;AAC7C,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAK;AACrF,IAAI,IAAI,UAAU,EAAE;AACpB,MAAM,uBAAuB,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,GAAG,YAAY,IAAI,EAAE,EAAE,kBAAkB,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,aAAa,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,mBAAmB,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,mBAAmB,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC1Z,IAAI;AACJ,IAAI,uBAAuB,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC;AAChI,EAAE;AACF;AACA,aAAa,CAAC,WAAW,GAAG,eAAe;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Pagination } from '../../Pagination/Pagination.js';
|
|
4
|
+
import { classNames } from '../../../utils/classNames/index.js';
|
|
5
|
+
|
|
6
|
+
function TablePagination({ className, ...rest }) {
|
|
7
|
+
return /* @__PURE__ */ React.createElement("div", { className: classNames("table-pagination", className) }, /* @__PURE__ */ React.createElement(Pagination, { ...rest }));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { TablePagination };
|
|
11
|
+
//# sourceMappingURL=TablePagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TablePagination.js","sources":["../../../../../src/components/Table/components/TablePagination.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Pagination, PaginationProps } from '@/components/Pagination';\nimport { classNames } from '@/utils';\n\nexport interface TablePaginationProps extends PaginationProps {\n className?: string;\n}\n\nexport function TablePagination({ className, ...rest }: TablePaginationProps) {\n return (\n <div className={classNames('table-pagination', className)}>\n <Pagination {...rest} />\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;AAGO,SAAS,eAAe,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE;AACxD,EAAE,uBAAuB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,kBAAkB,EAAE,SAAS,CAAC,EAAE,kBAAkB,KAAK,CAAC,aAAa,CAAC,UAAU,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AAC3K;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React__default, { useMemo } from 'react';
|
|
3
|
+
import { useHandleBulkSelection, useBulkSelectionData } from '../../utils/table/hooks.js';
|
|
4
|
+
import { TableContext, TableRowContext, TableSelectionChangeContext } from '../../utils/table/context.js';
|
|
5
|
+
|
|
6
|
+
function TableProvider({
|
|
7
|
+
children,
|
|
8
|
+
onSelectionChange,
|
|
9
|
+
selectedItemsCount = 0,
|
|
10
|
+
itemCount = 0,
|
|
11
|
+
hasMoreItems,
|
|
12
|
+
selectable: isSelectableTable = true
|
|
13
|
+
}) {
|
|
14
|
+
const { selectMode, bulkSelectState } = useBulkSelectionData({
|
|
15
|
+
selectedItemsCount,
|
|
16
|
+
itemCount
|
|
17
|
+
});
|
|
18
|
+
const handleSelectionChange = useHandleBulkSelection({ onSelectionChange });
|
|
19
|
+
const contextValue = useMemo(
|
|
20
|
+
() => ({
|
|
21
|
+
itemCount,
|
|
22
|
+
selectMode: selectMode && isSelectableTable,
|
|
23
|
+
selectable: isSelectableTable,
|
|
24
|
+
bulkSelectState,
|
|
25
|
+
selectedItemsCount
|
|
26
|
+
}),
|
|
27
|
+
[itemCount, selectMode, isSelectableTable, hasMoreItems, bulkSelectState, selectedItemsCount]
|
|
28
|
+
);
|
|
29
|
+
const rowContextValue = useMemo(
|
|
30
|
+
() => ({
|
|
31
|
+
selectable: isSelectableTable,
|
|
32
|
+
selectMode: selectMode && isSelectableTable
|
|
33
|
+
}),
|
|
34
|
+
[selectMode, isSelectableTable]
|
|
35
|
+
);
|
|
36
|
+
return /* @__PURE__ */ React__default.createElement(TableContext.Provider, { value: contextValue }, /* @__PURE__ */ React__default.createElement(TableRowContext.Provider, { value: rowContextValue }, /* @__PURE__ */ React__default.createElement(TableSelectionChangeContext.Provider, { value: handleSelectionChange }, children)));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { TableProvider };
|
|
40
|
+
//# sourceMappingURL=TableProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableProvider.js","sources":["../../../../../../src/components/Table/components/TableProvider/TableProvider.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\n\nimport {\n TableContext,\n TableProviderProps,\n TableRowContext,\n TableSelectionChangeContext,\n useBulkSelectionData,\n useHandleBulkSelection,\n} from '../../utils/table';\n\nexport function TableProvider({\n children,\n onSelectionChange,\n selectedItemsCount = 0,\n itemCount = 0,\n hasMoreItems,\n selectable: isSelectableTable = true,\n}: TableProviderProps) {\n const { selectMode, bulkSelectState } = useBulkSelectionData({\n selectedItemsCount,\n itemCount,\n });\n const handleSelectionChange = useHandleBulkSelection({ onSelectionChange });\n\n const contextValue = useMemo(\n () => ({\n itemCount,\n selectMode: selectMode && isSelectableTable,\n selectable: isSelectableTable,\n bulkSelectState,\n selectedItemsCount,\n }),\n [itemCount, selectMode, isSelectableTable, hasMoreItems, bulkSelectState, selectedItemsCount]\n );\n\n const rowContextValue = useMemo(\n () => ({\n selectable: isSelectableTable,\n selectMode: selectMode && isSelectableTable,\n }),\n [selectMode, isSelectableTable]\n );\n\n return (\n <TableContext.Provider value={contextValue}>\n <TableRowContext.Provider value={rowContextValue}>\n <TableSelectionChangeContext.Provider value={handleSelectionChange}>\n {children}\n </TableSelectionChangeContext.Provider>\n </TableRowContext.Provider>\n </TableContext.Provider>\n );\n}\n"],"names":["React"],"mappings":";;;;;AAQO,SAAS,aAAa,CAAC;AAC9B,EAAE,QAAQ;AACV,EAAE,iBAAiB;AACnB,EAAE,kBAAkB,GAAG,CAAC;AACxB,EAAE,SAAS,GAAG,CAAC;AACf,EAAE,YAAY;AACd,EAAE,UAAU,EAAE,iBAAiB,GAAG;AAClC,CAAC,EAAE;AACH,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,oBAAoB,CAAC;AAC/D,IAAI,kBAAkB;AACtB,IAAI;AACJ,GAAG,CAAC;AACJ,EAAE,MAAM,qBAAqB,GAAG,sBAAsB,CAAC,EAAE,iBAAiB,EAAE,CAAC;AAC7E,EAAE,MAAM,YAAY,GAAG,OAAO;AAC9B,IAAI,OAAO;AACX,MAAM,SAAS;AACf,MAAM,UAAU,EAAE,UAAU,IAAI,iBAAiB;AACjD,MAAM,UAAU,EAAE,iBAAiB;AACnC,MAAM,eAAe;AACrB,MAAM;AACN,KAAK,CAAC;AACN,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB;AAChG,GAAG;AACH,EAAE,MAAM,eAAe,GAAG,OAAO;AACjC,IAAI,OAAO;AACX,MAAM,UAAU,EAAE,iBAAiB;AACnC,MAAM,UAAU,EAAE,UAAU,IAAI;AAChC,KAAK,CAAC;AACN,IAAI,CAAC,UAAU,EAAE,iBAAiB;AAClC,GAAG;AACH,EAAE,uBAAuBA,cAAK,CAAC,aAAa,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,kBAAkBA,cAAK,CAAC,aAAa,CAAC,eAAe,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,kBAAkBA,cAAK,CAAC,aAAa,CAAC,2BAA2B,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC9S;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { RowContext } from '../utils/rows/context.js';
|
|
4
|
+
import { useTableRow, useTableSelectionChange, useTableValue } from '../utils/table/hooks.js';
|
|
5
|
+
import '../utils/table/context.js';
|
|
6
|
+
import { SelectionType } from '../utils/table/types.js';
|
|
7
|
+
import { Checkbox } from './Checkbox/index.js';
|
|
8
|
+
import { classNames } from '../../../utils/classNames/index.js';
|
|
9
|
+
|
|
10
|
+
function TableRow({ children, className, selected, id, disabled, ...props }) {
|
|
11
|
+
const { selectable } = useTableRow();
|
|
12
|
+
const onSelectionChange = useTableSelectionChange();
|
|
13
|
+
const { selectedItemsCount } = useTableValue();
|
|
14
|
+
const handleInteraction = React.useCallback(() => {
|
|
15
|
+
onSelectionChange(SelectionType.Single, id);
|
|
16
|
+
}, [id, onSelectionChange, selected]);
|
|
17
|
+
const contextValue = React.useMemo(
|
|
18
|
+
() => ({
|
|
19
|
+
itemId: id,
|
|
20
|
+
selected: selected || selectedItemsCount === "All",
|
|
21
|
+
onInteraction: handleInteraction,
|
|
22
|
+
disabled
|
|
23
|
+
}),
|
|
24
|
+
[id, selected, selectedItemsCount, disabled, handleInteraction]
|
|
25
|
+
);
|
|
26
|
+
const checkboxMarkup = selectable ? /* @__PURE__ */ React.createElement("td", { className: "selector" }, /* @__PURE__ */ React.createElement(Checkbox, { onChange: handleInteraction })) : null;
|
|
27
|
+
return /* @__PURE__ */ React.createElement(RowContext.Provider, { value: contextValue }, /* @__PURE__ */ React.createElement("tr", { className: classNames(className, { selected: contextValue.selected }), ...props }, checkboxMarkup, children));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { TableRow };
|
|
31
|
+
//# sourceMappingURL=TableRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableRow.js","sources":["../../../../../src/components/Table/components/TableRow.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\nimport { RowContext } from '../utils/rows';\nimport { SelectionType, useTableRow, useTableSelectionChange, useTableValue } from '../utils/table';\nimport { Checkbox } from './Checkbox';\n\nexport interface TableRowProps extends React.ComponentProps<'tr'> {\n children?: React.ReactNode;\n selected?: boolean;\n disabled?: boolean;\n id?: string;\n}\n\nexport function TableRow({ children, className, selected, id, disabled, ...props }: TableRowProps) {\n const { selectable } = useTableRow();\n const onSelectionChange = useTableSelectionChange();\n const { selectedItemsCount } = useTableValue();\n\n const handleInteraction = React.useCallback(() => {\n onSelectionChange(SelectionType.Single, id);\n }, [id, onSelectionChange, selected]);\n\n const contextValue = React.useMemo(\n () => ({\n itemId: id,\n selected: selected || selectedItemsCount === 'All',\n onInteraction: handleInteraction,\n disabled,\n }),\n [id, selected, selectedItemsCount, disabled, handleInteraction]\n );\n\n const checkboxMarkup = selectable ? (\n <td className=\"selector\">\n <Checkbox onChange={handleInteraction} />\n </td>\n ) : null;\n\n return (\n <RowContext.Provider value={contextValue}>\n <tr className={classNames(className, { selected: contextValue.selected })} {...props}>\n {checkboxMarkup}\n {children}\n </tr>\n </RowContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;AAKO,SAAS,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE;AACpF,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,WAAW,EAAE;AACtC,EAAE,MAAM,iBAAiB,GAAG,uBAAuB,EAAE;AACrD,EAAE,MAAM,EAAE,kBAAkB,EAAE,GAAG,aAAa,EAAE;AAChD,EAAE,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM;AACpD,IAAI,iBAAiB,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC;AAC/C,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,iBAAiB,EAAE,QAAQ,CAAC,CAAC;AACvC,EAAE,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO;AACpC,IAAI,OAAO;AACX,MAAM,MAAM,EAAE,EAAE;AAChB,MAAM,QAAQ,EAAE,QAAQ,IAAI,kBAAkB,KAAK,KAAK;AACxD,MAAM,aAAa,EAAE,iBAAiB;AACtC,MAAM;AACN,KAAK,CAAC;AACN,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,kBAAkB,EAAE,QAAQ,EAAE,iBAAiB;AAClE,GAAG;AACH,EAAE,MAAM,cAAc,GAAG,UAAU,mBAAmB,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC,CAAC,GAAG,IAAI;AACjM,EAAE,uBAAuB,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,kBAAkB,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,YAAY,CAAC,QAAQ,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;AACpP;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../../../../../src/components/Table/utils/rows/context.ts"],"sourcesContent":["import { createContext } from 'react';\n\ninterface RowContextType {\n /** The unique identifier of the row item. */\n itemId?: string;\n /** Indicates whether the row is selected. */\n selected?: boolean;\n /** Indicates whether the row is disabled. */\n disabled?: boolean;\n /**\n * A callback function that is called when the row is interacted with.\n * The function receives the `event` object as an argument.\n */\n onInteraction?: (event: React.MouseEvent) => void;\n}\n\nexport const RowContext = createContext<RowContextType>({});\n"],"names":[],"mappings":";;;AACY,MAAC,UAAU,GAAG,aAAa,CAAC,EAAE;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext } from 'react';
|
|
3
|
+
|
|
4
|
+
const TableContext = createContext(void 0);
|
|
5
|
+
const TableSelectionChangeContext = createContext(void 0);
|
|
6
|
+
const TableRowContext = createContext(void 0);
|
|
7
|
+
|
|
8
|
+
export { TableContext, TableRowContext, TableSelectionChangeContext };
|
|
9
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../../../../../src/components/Table/utils/table/context.ts"],"sourcesContent":["import { createContext } from 'react';\n\nimport type { SelectionType, SELECT_ALL_ITEMS } from './types';\n\nexport interface TableContextType {\n /**\n * Indicates the bulk selection state of the table.\n * It can be a boolean or the string 'indeterminate'.\n */\n bulkSelectState?: boolean | 'indeterminate';\n /**\n * The number of selected items in the table.\n * This can be a number or the string 'All' (which means that all items are selected).\n */\n selectedItemsCount: typeof SELECT_ALL_ITEMS | number;\n /** Indicates whether the table is in select mode. */\n selectMode: boolean;\n /** The total number of items in the table. */\n itemCount: number;\n /** Indicates whether the table is selectable. */\n selectable?: boolean;\n}\n\nexport const TableContext = createContext<TableContextType | undefined>(undefined);\n\nexport const TableSelectionChangeContext = createContext<\n ((selectionType: SelectionType, selection?: string) => void) | undefined\n>(undefined);\n\nexport interface TableRowContextType {\n /** Indicates whether the table is selectable. */\n selectable: boolean;\n /** Indicates whether the table is in select mode. */\n selectMode: boolean;\n}\n\nexport const TableRowContext = createContext<TableRowContextType | undefined>(undefined);\n"],"names":[],"mappings":";;;AACY,MAAC,YAAY,GAAG,aAAa,CAAC,MAAM;AACpC,MAAC,2BAA2B,GAAG,aAAa,CAAC,MAAM;AACnD,MAAC,eAAe,GAAG,aAAa,CAAC,MAAM;;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useContext, useCallback } from 'react';
|
|
3
|
+
import { SelectionType, SELECT_ALL_ITEMS } from './types.js';
|
|
4
|
+
import { TableContext, TableSelectionChangeContext, TableRowContext } from './context.js';
|
|
5
|
+
|
|
6
|
+
function useTableSelectionChange() {
|
|
7
|
+
const onSelectionChange = useContext(TableSelectionChangeContext);
|
|
8
|
+
if (!onSelectionChange) {
|
|
9
|
+
throw new Error(`Missing TableProvider context`);
|
|
10
|
+
}
|
|
11
|
+
return onSelectionChange;
|
|
12
|
+
}
|
|
13
|
+
function useTableRow() {
|
|
14
|
+
const tableRow = useContext(TableRowContext);
|
|
15
|
+
if (!tableRow) {
|
|
16
|
+
throw new Error(`Missing TableProvider context`);
|
|
17
|
+
}
|
|
18
|
+
return tableRow;
|
|
19
|
+
}
|
|
20
|
+
function useTableValue() {
|
|
21
|
+
const table = useContext(TableContext);
|
|
22
|
+
if (!table) {
|
|
23
|
+
throw new Error(`Missing TableProvider context`);
|
|
24
|
+
}
|
|
25
|
+
return table;
|
|
26
|
+
}
|
|
27
|
+
function useBulkSelectionData({ selectedItemsCount, itemCount }) {
|
|
28
|
+
const selectable = Boolean(selectedItemsCount);
|
|
29
|
+
const selectMode = selectedItemsCount === "All" || selectedItemsCount > 0;
|
|
30
|
+
let bulkSelectState = "indeterminate";
|
|
31
|
+
if (!selectedItemsCount || selectedItemsCount === 0) {
|
|
32
|
+
bulkSelectState = void 0;
|
|
33
|
+
} else if (selectedItemsCount === SELECT_ALL_ITEMS || selectedItemsCount === itemCount) {
|
|
34
|
+
bulkSelectState = true;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
selectMode,
|
|
38
|
+
bulkSelectState,
|
|
39
|
+
selectable
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function useHandleBulkSelection({ onSelectionChange = () => {
|
|
43
|
+
} }) {
|
|
44
|
+
const handleSelectionChange = useCallback(
|
|
45
|
+
(selectionType, selection) => {
|
|
46
|
+
if (selectionType === SelectionType.Single) {
|
|
47
|
+
onSelectionChange(SelectionType.Single, selection);
|
|
48
|
+
} else if (selectionType === SelectionType.Page || selectionType === SelectionType.All) {
|
|
49
|
+
onSelectionChange(selectionType, SELECT_ALL_ITEMS);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
[onSelectionChange]
|
|
53
|
+
);
|
|
54
|
+
return handleSelectionChange;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { useBulkSelectionData, useHandleBulkSelection, useTableRow, useTableSelectionChange, useTableValue };
|
|
58
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../../../../../../src/components/Table/utils/table/hooks.ts"],"sourcesContent":["import { useContext, useCallback } from 'react';\n\nimport {\n SELECT_ALL_ITEMS,\n SelectionType,\n HandleSelectionChange,\n BulkSelectionDataOptions,\n HandleBulkSelectionOptions,\n} from './types';\nimport { TableContext, TableRowContext, TableSelectionChangeContext } from './context';\n\nexport function useTableSelectionChange() {\n const onSelectionChange = useContext(TableSelectionChangeContext);\n if (!onSelectionChange) {\n throw new Error(`Missing TableProvider context`);\n }\n return onSelectionChange;\n}\n\nexport function useTableRow() {\n const tableRow = useContext(TableRowContext);\n if (!tableRow) {\n throw new Error(`Missing TableProvider context`);\n }\n return tableRow;\n}\n\nexport function useTableValue() {\n const table = useContext(TableContext);\n if (!table) {\n throw new Error(`Missing TableProvider context`);\n }\n return table;\n}\n\nexport function useBulkSelectionData({ selectedItemsCount, itemCount }: BulkSelectionDataOptions) {\n const selectable = Boolean(selectedItemsCount);\n const selectMode = selectedItemsCount === 'All' || selectedItemsCount > 0;\n\n let bulkSelectState: boolean | 'indeterminate' | undefined = 'indeterminate';\n if (!selectedItemsCount || selectedItemsCount === 0) {\n bulkSelectState = undefined;\n } else if (selectedItemsCount === SELECT_ALL_ITEMS || selectedItemsCount === itemCount) {\n bulkSelectState = true;\n }\n\n return {\n selectMode,\n bulkSelectState,\n selectable,\n };\n}\n\nexport function useHandleBulkSelection({ onSelectionChange = () => {} }: HandleBulkSelectionOptions) {\n const handleSelectionChange: HandleSelectionChange = useCallback(\n (selectionType: SelectionType, selection?: string) => {\n if (selectionType === SelectionType.Single) {\n onSelectionChange(SelectionType.Single, selection);\n } else if (selectionType === SelectionType.Page || selectionType === SelectionType.All) {\n onSelectionChange(selectionType, SELECT_ALL_ITEMS);\n }\n },\n [onSelectionChange]\n );\n\n return handleSelectionChange;\n}\n"],"names":[],"mappings":";;;;;AAMO,SAAS,uBAAuB,GAAG;AAC1C,EAAE,MAAM,iBAAiB,GAAG,UAAU,CAAC,2BAA2B,CAAC;AACnE,EAAE,IAAI,CAAC,iBAAiB,EAAE;AAC1B,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC,6BAA6B,CAAC,CAAC;AACpD,EAAE;AACF,EAAE,OAAO,iBAAiB;AAC1B;AACO,SAAS,WAAW,GAAG;AAC9B,EAAE,MAAM,QAAQ,GAAG,UAAU,CAAC,eAAe,CAAC;AAC9C,EAAE,IAAI,CAAC,QAAQ,EAAE;AACjB,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC,6BAA6B,CAAC,CAAC;AACpD,EAAE;AACF,EAAE,OAAO,QAAQ;AACjB;AACO,SAAS,aAAa,GAAG;AAChC,EAAE,MAAM,KAAK,GAAG,UAAU,CAAC,YAAY,CAAC;AACxC,EAAE,IAAI,CAAC,KAAK,EAAE;AACd,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC,6BAA6B,CAAC,CAAC;AACpD,EAAE;AACF,EAAE,OAAO,KAAK;AACd;AACO,SAAS,oBAAoB,CAAC,EAAE,kBAAkB,EAAE,SAAS,EAAE,EAAE;AACxE,EAAE,MAAM,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC;AAChD,EAAE,MAAM,UAAU,GAAG,kBAAkB,KAAK,KAAK,IAAI,kBAAkB,GAAG,CAAC;AAC3E,EAAE,IAAI,eAAe,GAAG,eAAe;AACvC,EAAE,IAAI,CAAC,kBAAkB,IAAI,kBAAkB,KAAK,CAAC,EAAE;AACvD,IAAI,eAAe,GAAG,MAAM;AAC5B,EAAE,CAAC,MAAM,IAAI,kBAAkB,KAAK,gBAAgB,IAAI,kBAAkB,KAAK,SAAS,EAAE;AAC1F,IAAI,eAAe,GAAG,IAAI;AAC1B,EAAE;AACF,EAAE,OAAO;AACT,IAAI,UAAU;AACd,IAAI,eAAe;AACnB,IAAI;AACJ,GAAG;AACH;AACO,SAAS,sBAAsB,CAAC,EAAE,iBAAiB,GAAG,MAAM;AACnE,CAAC,EAAE,EAAE;AACL,EAAE,MAAM,qBAAqB,GAAG,WAAW;AAC3C,IAAI,CAAC,aAAa,EAAE,SAAS,KAAK;AAClC,MAAM,IAAI,aAAa,KAAK,aAAa,CAAC,MAAM,EAAE;AAClD,QAAQ,iBAAiB,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC;AAC1D,MAAM,CAAC,MAAM,IAAI,aAAa,KAAK,aAAa,CAAC,IAAI,IAAI,aAAa,KAAK,aAAa,CAAC,GAAG,EAAE;AAC9F,QAAQ,iBAAiB,CAAC,aAAa,EAAE,gBAAgB,CAAC;AAC1D,MAAM;AACN,IAAI,CAAC;AACL,IAAI,CAAC,iBAAiB;AACtB,GAAG;AACH,EAAE,OAAO,qBAAqB;AAC9B;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
const SELECT_ALL_ITEMS = "All";
|
|
3
|
+
var SelectionType = /* @__PURE__ */ ((SelectionType2) => {
|
|
4
|
+
SelectionType2["All"] = "all";
|
|
5
|
+
SelectionType2["Page"] = "page";
|
|
6
|
+
SelectionType2["Single"] = "single";
|
|
7
|
+
return SelectionType2;
|
|
8
|
+
})(SelectionType || {});
|
|
9
|
+
|
|
10
|
+
export { SELECT_ALL_ITEMS, SelectionType };
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../../../src/components/Table/utils/table/types.ts"],"sourcesContent":["/** This constant defines the value of the 'All' option used in the `TableSelectedItems` type. */\nexport const SELECT_ALL_ITEMS = 'All';\n\n/**\n * This type defines the possible values for the selected items in the table.\n * It can be an array of strings, or the string 'All' (which means that all items are selected).\n */\nexport type TableSelectedItems = string[] | 'All';\n\n/**\n * This enum defines the possible types of selection in the table.\n */\nexport enum SelectionType {\n All = 'all',\n Page = 'page',\n Single = 'single',\n}\n\nexport interface TableProviderProps {\n /** The children to be rendered within the table provider. */\n children?: React.ReactNode;\n /** Indicates whether the table is selectable. */\n selectable?: boolean;\n /** The total number of items in the table. */\n itemCount?: number;\n /**\n * The number of selected items in the table.\n * This can be a number or the string 'All' (which means that all items are selected).\n */\n selectedItemsCount?: typeof SELECT_ALL_ITEMS | number;\n /** Indicates whether there are more items that can be loaded in the table. */\n hasMoreItems?: boolean;\n /**\n * A callback function that is called when the selection changes in the table.\n * The function receives the `selectionType` and `selection` as arguments.\n */\n onSelectionChange?(selectionType: SelectionType, selection?: string): void;\n}\n\n/* This type defines the signature of the `onSelectionChange` callback function */\nexport type HandleSelectionChange = (selectionType: SelectionType, selection?: string) => void;\n\nexport interface BulkSelectionDataOptions {\n /**\n * The number of selected items in the table.\n * This can be a number or the string 'All' (which means that all items are selected).\n */\n selectedItemsCount: number | typeof SELECT_ALL_ITEMS;\n /** The total number of items in the table. */\n itemCount: number;\n}\n\nexport interface HandleBulkSelectionOptions {\n /**\n * A callback function that is called when the selection changes in the table.\n * The function receives the `selectionType` and `selection` as arguments.\n */\n onSelectionChange?(selectionType: SelectionType, selection?: string): void;\n}\n"],"names":[],"mappings":";AAAY,MAAC,gBAAgB,GAAG;AACtB,IAAC,aAAa,mBAAmB,CAAC,CAAC,cAAc,KAAK;AAChE,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,KAAK;AAC/B,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM;AACjC,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,QAAQ;AACrC,EAAE,OAAO,cAAc;AACvB,CAAC,EAAE,aAAa,IAAI,EAAE;;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { SelectionType } from '../table/types.js';
|
|
4
|
+
|
|
5
|
+
function defaultResourceIDResolver(resource) {
|
|
6
|
+
if ("id" in resource) {
|
|
7
|
+
return resource.id.toString();
|
|
8
|
+
}
|
|
9
|
+
throw new Error(
|
|
10
|
+
"Your resource does not directly contain an `id`. Pass a `resourceIDResolver` to `useSelectableResourceState`"
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
function useSelectableResourceState(resources, {
|
|
14
|
+
selectedResources: initSelectedResources = [],
|
|
15
|
+
allResourcesSelected: initAllResourcesSelected = false,
|
|
16
|
+
resourceIDResolver = defaultResourceIDResolver
|
|
17
|
+
} = {
|
|
18
|
+
selectedResources: [],
|
|
19
|
+
allResourcesSelected: false,
|
|
20
|
+
resourceIDResolver: defaultResourceIDResolver
|
|
21
|
+
}) {
|
|
22
|
+
const [selectedResources, setSelectedResources] = React.useState(initSelectedResources);
|
|
23
|
+
const [allResourcesSelected, setAllResourcesSelected] = React.useState(initAllResourcesSelected);
|
|
24
|
+
const removeResource = React.useCallback(
|
|
25
|
+
(resource) => {
|
|
26
|
+
const selectedResourcesCopy = [...selectedResources];
|
|
27
|
+
const newSelectedResources = selectedResourcesCopy.filter((currentResource) => currentResource !== resource);
|
|
28
|
+
setSelectedResources(newSelectedResources);
|
|
29
|
+
if (newSelectedResources.length === 0) {
|
|
30
|
+
setAllResourcesSelected(false);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
[selectedResources]
|
|
34
|
+
);
|
|
35
|
+
const clearSelection = React.useCallback(() => {
|
|
36
|
+
setSelectedResources([]);
|
|
37
|
+
setAllResourcesSelected(false);
|
|
38
|
+
}, []);
|
|
39
|
+
const handleSelectionChange = React.useCallback(
|
|
40
|
+
(selectionType, selection) => {
|
|
41
|
+
if (selection !== void 0 && selectedResources.includes(selection)) {
|
|
42
|
+
removeResource(selection);
|
|
43
|
+
setAllResourcesSelected(false);
|
|
44
|
+
} else {
|
|
45
|
+
if (selectionType === SelectionType.Single && selection !== void 0) {
|
|
46
|
+
setSelectedResources((newSelectedResources) => [...newSelectedResources, selection.toString()]);
|
|
47
|
+
}
|
|
48
|
+
if (selectionType === SelectionType.All || selectionType === SelectionType.Page) {
|
|
49
|
+
if (allResourcesSelected) {
|
|
50
|
+
clearSelection();
|
|
51
|
+
} else {
|
|
52
|
+
setSelectedResources(resources.map(resourceIDResolver));
|
|
53
|
+
setAllResourcesSelected(true);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
[allResourcesSelected, selectedResources.length, resources, resourceIDResolver]
|
|
59
|
+
);
|
|
60
|
+
return {
|
|
61
|
+
selectedResources,
|
|
62
|
+
allResourcesSelected,
|
|
63
|
+
handleSelectionChange,
|
|
64
|
+
clearSelection,
|
|
65
|
+
removeResource
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { useSelectableResourceState };
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/components/Table/utils/useSelectableResourceState/index.ts"],"sourcesContent":["import * as React from 'react';\nimport { SelectionType } from '../table/types';\n\n/** A type alias for a function that takes a resource of type `T` and returns a string representing its ID. */\ntype ResourceIDResolver<T extends { [key: string]: unknown }> = (resource: T) => string;\n\nfunction defaultResourceIDResolver(resource: { [key: string]: any }): string {\n if ('id' in resource) {\n return resource.id.toString();\n }\n\n throw new Error(\n 'Your resource does not directly contain an `id`. Pass a `resourceIDResolver` to `useSelectableResourceState`'\n );\n}\n\nexport function useSelectableResourceState<T extends { [key: string]: unknown }>(\n resources: T[],\n {\n selectedResources: initSelectedResources = [],\n allResourcesSelected: initAllResourcesSelected = false,\n resourceIDResolver = defaultResourceIDResolver,\n }: {\n selectedResources?: string[];\n allResourcesSelected?: boolean;\n resourceIDResolver?: ResourceIDResolver<T>;\n } = {\n selectedResources: [],\n allResourcesSelected: false,\n resourceIDResolver: defaultResourceIDResolver,\n }\n) {\n const [selectedResources, setSelectedResources] = React.useState(initSelectedResources);\n const [allResourcesSelected, setAllResourcesSelected] = React.useState(initAllResourcesSelected);\n\n const removeResource = React.useCallback(\n (resource: string) => {\n const selectedResourcesCopy = [...selectedResources];\n\n const newSelectedResources = selectedResourcesCopy.filter((currentResource) => currentResource !== resource);\n\n setSelectedResources(newSelectedResources);\n\n if (newSelectedResources.length === 0) {\n setAllResourcesSelected(false);\n }\n },\n [selectedResources]\n );\n\n const clearSelection = React.useCallback(() => {\n setSelectedResources([]);\n setAllResourcesSelected(false);\n }, []);\n\n const handleSelectionChange = React.useCallback(\n (selectionType: SelectionType, selection?: string) => {\n if (selection !== undefined && selectedResources.includes(selection)) {\n removeResource(selection);\n setAllResourcesSelected(false);\n } else {\n if (selectionType === SelectionType.Single && selection !== undefined) {\n setSelectedResources((newSelectedResources) => [...newSelectedResources, selection.toString()]);\n }\n\n if (selectionType === SelectionType.All || selectionType === SelectionType.Page) {\n if (allResourcesSelected) {\n clearSelection();\n } else {\n setSelectedResources(resources.map(resourceIDResolver));\n setAllResourcesSelected(true);\n }\n }\n }\n },\n [allResourcesSelected, selectedResources.length, resources, resourceIDResolver]\n );\n\n return {\n selectedResources,\n allResourcesSelected,\n handleSelectionChange,\n clearSelection,\n removeResource,\n };\n}\n"],"names":[],"mappings":";;;;AAEA,SAAS,yBAAyB,CAAC,QAAQ,EAAE;AAC7C,EAAE,IAAI,IAAI,IAAI,QAAQ,EAAE;AACxB,IAAI,OAAO,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE;AACjC,EAAE;AACF,EAAE,MAAM,IAAI,KAAK;AACjB,IAAI;AACJ,GAAG;AACH;AACO,SAAS,0BAA0B,CAAC,SAAS,EAAE;AACtD,EAAE,iBAAiB,EAAE,qBAAqB,GAAG,EAAE;AAC/C,EAAE,oBAAoB,EAAE,wBAAwB,GAAG,KAAK;AACxD,EAAE,kBAAkB,GAAG;AACvB,CAAC,GAAG;AACJ,EAAE,iBAAiB,EAAE,EAAE;AACvB,EAAE,oBAAoB,EAAE,KAAK;AAC7B,EAAE,kBAAkB,EAAE;AACtB,CAAC,EAAE;AACH,EAAE,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,qBAAqB,CAAC;AACzF,EAAE,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,wBAAwB,CAAC;AAClG,EAAE,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW;AAC1C,IAAI,CAAC,QAAQ,KAAK;AAClB,MAAM,MAAM,qBAAqB,GAAG,CAAC,GAAG,iBAAiB,CAAC;AAC1D,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC,eAAe,KAAK,eAAe,KAAK,QAAQ,CAAC;AAClH,MAAM,oBAAoB,CAAC,oBAAoB,CAAC;AAChD,MAAM,IAAI,oBAAoB,CAAC,MAAM,KAAK,CAAC,EAAE;AAC7C,QAAQ,uBAAuB,CAAC,KAAK,CAAC;AACtC,MAAM;AACN,IAAI,CAAC;AACL,IAAI,CAAC,iBAAiB;AACtB,GAAG;AACH,EAAE,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM;AACjD,IAAI,oBAAoB,CAAC,EAAE,CAAC;AAC5B,IAAI,uBAAuB,CAAC,KAAK,CAAC;AAClC,EAAE,CAAC,EAAE,EAAE,CAAC;AACR,EAAE,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW;AACjD,IAAI,CAAC,aAAa,EAAE,SAAS,KAAK;AAClC,MAAM,IAAI,SAAS,KAAK,MAAM,IAAI,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;AACzE,QAAQ,cAAc,CAAC,SAAS,CAAC;AACjC,QAAQ,uBAAuB,CAAC,KAAK,CAAC;AACtC,MAAM,CAAC,MAAM;AACb,QAAQ,IAAI,aAAa,KAAK,aAAa,CAAC,MAAM,IAAI,SAAS,KAAK,MAAM,EAAE;AAC5E,UAAU,oBAAoB,CAAC,CAAC,oBAAoB,KAAK,CAAC,GAAG,oBAAoB,EAAE,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;AACzG,QAAQ;AACR,QAAQ,IAAI,aAAa,KAAK,aAAa,CAAC,GAAG,IAAI,aAAa,KAAK,aAAa,CAAC,IAAI,EAAE;AACzF,UAAU,IAAI,oBAAoB,EAAE;AACpC,YAAY,cAAc,EAAE;AAC5B,UAAU,CAAC,MAAM;AACjB,YAAY,oBAAoB,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;AACnE,YAAY,uBAAuB,CAAC,IAAI,CAAC;AACzC,UAAU;AACV,QAAQ;AACR,MAAM;AACN,IAAI,CAAC;AACL,IAAI,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,kBAAkB;AAClF,GAAG;AACH,EAAE,OAAO;AACT,IAAI,iBAAiB;AACrB,IAAI,oBAAoB;AACxB,IAAI,qBAAqB;AACzB,IAAI,cAAc;AAClB,IAAI;AACJ,GAAG;AACH;;"}
|