@soyfri/shared-library 1.5.0-beta.4 → 2.0.0-beta.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/.dockerignore +8 -0
- package/.github/workflows/publish.yml +107 -0
- package/.prettierrc +3 -0
- package/.storybook/main.ts +19 -0
- package/.storybook/preview.ts +14 -0
- package/.storybook/vitest.setup.ts +9 -0
- package/Dockerfile +37 -0
- package/build.js +102 -0
- package/chromatic.config.json +5 -0
- package/cleanDirectories.js +40 -0
- package/dist/components/ActionMenu/ActionMenu.cjs +107 -0
- package/dist/components/ActionMenu/ActionMenu.cjs.map +1 -0
- package/dist/components/ActionMenu/ActionMenu.d.ts +60 -0
- package/dist/components/ActionMenu/ActionMenu.js +107 -0
- package/dist/components/ActionMenu/ActionMenu.js.map +1 -0
- package/dist/components/ActionMenu/index.d.ts +2 -0
- package/dist/components/ActionMenu.d.ts +6 -0
- package/dist/components/AppBar/AppBar.cjs +346 -0
- package/dist/components/AppBar/AppBar.cjs.map +1 -0
- package/dist/components/AppBar/AppBar.d.ts +55 -0
- package/dist/components/AppBar/AppBar.js +346 -0
- package/dist/components/AppBar/AppBar.js.map +1 -0
- package/dist/components/AppBar/AppBar.sx.d.ts +12 -0
- package/dist/components/AppBar/AppBarBrand.d.ts +31 -0
- package/dist/components/AppBar/AppBarContext.d.ts +18 -0
- package/dist/components/AppBar/AppBarMenuToggle.d.ts +39 -0
- package/dist/components/AppBar/AppBarUserMenu.d.ts +65 -0
- package/dist/components/AppBar/index.d.ts +12 -0
- package/dist/components/AppBar.d.ts +6 -0
- package/dist/components/Autocomplete/Autocomplete.cjs +314 -0
- package/dist/components/Autocomplete/Autocomplete.cjs.map +1 -0
- package/dist/components/Autocomplete/Autocomplete.d.ts +83 -0
- package/{components → dist/components}/Autocomplete/Autocomplete.definitions.d.ts +6 -0
- package/dist/components/Autocomplete/Autocomplete.helpers.d.ts +18 -0
- package/dist/components/Autocomplete/Autocomplete.js +314 -0
- package/dist/components/Autocomplete/Autocomplete.js.map +1 -0
- package/dist/components/Autocomplete/Autocomplete.sx.d.ts +7 -0
- package/dist/components/Autocomplete/Autocomplete.types.d.ts +1 -0
- package/dist/components/Autocomplete/_parts/AutocompleteChips.d.ts +19 -0
- package/dist/components/Autocomplete/_parts/AutocompleteLoader.d.ts +9 -0
- package/dist/components/Autocomplete/_parts/AutocompleteOption.d.ts +19 -0
- package/dist/components/Autocomplete/index.d.ts +2 -0
- package/dist/components/Autocomplete.d.ts +6 -0
- package/dist/components/Avatar/Avatar.cjs +163 -0
- package/dist/components/Avatar/Avatar.cjs.map +1 -0
- package/dist/components/Avatar/Avatar.d.ts +33 -0
- package/dist/components/Avatar/Avatar.definitions.d.ts +11 -0
- package/dist/components/Avatar/Avatar.js +163 -0
- package/dist/components/Avatar/Avatar.js.map +1 -0
- package/dist/components/Card/Card.cjs +187 -0
- package/dist/components/Card/Card.cjs.map +1 -0
- package/dist/components/Card/Card.d.ts +83 -0
- package/dist/components/Card/Card.js +187 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/Card/Card.sx.d.ts +17 -0
- package/dist/components/Card/index.d.ts +4 -0
- package/dist/components/Card.d.ts +6 -0
- package/dist/components/DatePicker/DatePicker.cjs +203 -0
- package/dist/components/DatePicker/DatePicker.cjs.map +1 -0
- package/dist/components/DatePicker/DatePicker.d.ts +56 -0
- package/{components → dist/components}/DatePicker/DatePicker.definitions.d.ts +1 -0
- package/dist/components/DatePicker/DatePicker.helpers.d.ts +7 -0
- package/dist/components/DatePicker/DatePicker.js +203 -0
- package/dist/components/DatePicker/DatePicker.js.map +1 -0
- package/dist/components/DatePicker/DatePicker.sx.d.ts +9 -0
- package/dist/components/DatePicker/DatePicker.types.d.ts +1 -0
- package/dist/components/DatePicker/index.d.ts +2 -0
- package/dist/components/DatePicker.d.ts +6 -0
- package/dist/components/DateTimePicker/DateTimePicker.cjs +222 -0
- package/dist/components/DateTimePicker/DateTimePicker.cjs.map +1 -0
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +65 -0
- package/{components → dist/components}/DateTimePicker/DateTimePicker.definitions.d.ts +1 -0
- package/dist/components/DateTimePicker/DateTimePicker.helpers.d.ts +11 -0
- package/dist/components/DateTimePicker/DateTimePicker.js +222 -0
- package/dist/components/DateTimePicker/DateTimePicker.js.map +1 -0
- package/dist/components/DateTimePicker/DateTimePicker.sx.d.ts +7 -0
- package/dist/components/DateTimePicker/DateTimePicker.types.d.ts +1 -0
- package/dist/components/DateTimePicker/index.d.ts +2 -0
- package/dist/components/DateTimePicker.d.ts +6 -0
- package/dist/components/Drawer/Drawer.cjs +271 -0
- package/dist/components/Drawer/Drawer.cjs.map +1 -0
- package/dist/components/Drawer/Drawer.d.ts +51 -0
- package/dist/components/Drawer/Drawer.js +271 -0
- package/dist/components/Drawer/Drawer.js.map +1 -0
- package/dist/components/Drawer/Drawer.sx.d.ts +23 -0
- package/dist/components/Drawer/DrawerContext.d.ts +18 -0
- package/dist/components/Drawer/DrawerItem.d.ts +35 -0
- package/dist/components/Drawer/index.d.ts +6 -0
- package/dist/components/Drawer.d.ts +6 -0
- package/{components → dist/components}/Icon/Icon.cjs +44 -3
- package/dist/components/Icon/Icon.cjs.map +1 -0
- package/dist/components/Icon/Icon.d.ts +54 -0
- package/{components → dist/components}/Icon/Icon.js +44 -3
- package/dist/components/Icon/Icon.js.map +1 -0
- package/dist/components/Input/Input.cjs +175 -0
- package/dist/components/Input/Input.cjs.map +1 -0
- package/dist/components/Input/Input.d.ts +37 -0
- package/{components → dist/components}/Input/Input.definitions.d.ts +5 -2
- package/dist/components/Input/Input.helpers.d.ts +14 -0
- package/dist/components/Input/Input.js +175 -0
- package/dist/components/Input/Input.js.map +1 -0
- package/dist/components/Input/Input.sx.d.ts +8 -0
- package/dist/components/Input/Input.types.d.ts +1 -0
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/Input.d.ts +6 -0
- package/dist/components/InputGroup/InputGroup.cjs +139 -0
- package/dist/components/InputGroup/InputGroup.cjs.map +1 -0
- package/dist/components/InputGroup/InputGroup.d.ts +42 -0
- package/dist/components/InputGroup/InputGroup.definitions.d.ts +6 -0
- package/dist/components/InputGroup/InputGroup.js +139 -0
- package/dist/components/InputGroup/InputGroup.js.map +1 -0
- package/dist/components/Modal/Modal.cjs +319 -0
- package/dist/components/Modal/Modal.cjs.map +1 -0
- package/dist/components/Modal/Modal.d.ts +65 -0
- package/dist/components/Modal/Modal.js +319 -0
- package/dist/components/Modal/Modal.js.map +1 -0
- package/{components → dist/components}/Modal/ModalFooter.d.ts +9 -1
- package/dist/components/Modal/index.d.ts +6 -0
- package/dist/components/PageLoader/PageLoader.cjs +61 -0
- package/dist/components/PageLoader/PageLoader.cjs.map +1 -0
- package/dist/components/PageLoader/PageLoader.d.ts +38 -0
- package/dist/components/PageLoader/PageLoader.js +61 -0
- package/dist/components/PageLoader/PageLoader.js.map +1 -0
- package/dist/components/PageLoader/index.d.ts +2 -0
- package/dist/components/PageLoader.d.ts +6 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.cjs +79 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.cjs.map +1 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.d.ts +48 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.js +79 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.js.map +1 -0
- package/dist/components/ScrollTopButton/index.d.ts +4 -0
- package/dist/components/ScrollTopButton/scrollToTop.d.ts +29 -0
- package/dist/components/ScrollTopButton.d.ts +6 -0
- package/dist/components/Select/Select.cjs +448 -0
- package/dist/components/Select/Select.cjs.map +1 -0
- package/{components → dist/components}/Select/Select.d.ts +33 -13
- package/{components → dist/components}/Select/Select.definitions.d.ts +3 -0
- package/dist/components/Select/Select.helpers.d.ts +28 -0
- package/dist/components/Select/Select.js +448 -0
- package/dist/components/Select/Select.js.map +1 -0
- package/dist/components/Select/Select.sx.d.ts +7 -0
- package/dist/components/Select/Select.types.d.ts +1 -0
- package/dist/components/Select/_parts/SelectMenuItem.d.ts +20 -0
- package/dist/components/Select/_parts/SelectSearchHeader.d.ts +15 -0
- package/dist/components/Select/_parts/SelectValue.d.ts +22 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Select.d.ts +6 -0
- package/{components → dist/components}/Stat/Stat.cjs +1 -1
- package/{components → dist/components}/Stat/Stat.js +1 -1
- package/{components → dist/components}/Stepper/Stepper.cjs +4 -1
- package/dist/components/Stepper/Stepper.cjs.map +1 -0
- package/{components → dist/components}/Stepper/Stepper.d.ts +5 -0
- package/{components → dist/components}/Stepper/Stepper.js +4 -1
- package/dist/components/Stepper/Stepper.js.map +1 -0
- package/dist/components/_shared/formField.sx.d.ts +33 -0
- package/dist/components/_shared/resolvePreset.d.ts +18 -0
- package/dist/formField.sx-CQ1mbk9M.cjs +76 -0
- package/dist/formField.sx-CQ1mbk9M.cjs.map +1 -0
- package/dist/formField.sx-DfVbMe0V.js +77 -0
- package/dist/formField.sx-DfVbMe0V.js.map +1 -0
- package/dist/hooks/Wizard/Wizard.cjs +7 -0
- package/dist/hooks/Wizard/Wizard.cjs.map +1 -0
- package/dist/hooks/Wizard/Wizard.js +7 -0
- package/dist/hooks/Wizard/Wizard.js.map +1 -0
- package/dist/hooks/Wizard/WizardContext.d.ts +67 -0
- package/dist/hooks/Wizard/index.d.ts +3 -0
- package/dist/hooks/Wizard/useWizard.d.ts +9 -0
- package/dist/hooks/Wizard.d.ts +2 -0
- package/dist/index.cjs +100 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +31 -0
- package/{index.js.map → dist/index.js.map} +1 -1
- package/dist/mui.d.ts +5 -0
- package/dist/resolvePreset-B-IB0ehH.js +15 -0
- package/dist/resolvePreset-B-IB0ehH.js.map +1 -0
- package/dist/resolvePreset-CT3kU-K2.cjs +14 -0
- package/dist/resolvePreset-CT3kU-K2.cjs.map +1 -0
- package/dist/theme/componentStyles.d.ts +32 -0
- package/dist/theme/tokens.d.ts +28 -0
- package/dist/useWizard-CWdIxZzX.cjs +94 -0
- package/dist/useWizard-CWdIxZzX.cjs.map +1 -0
- package/dist/useWizard-CWq--C3o.js +95 -0
- package/dist/useWizard-CWq--C3o.js.map +1 -0
- package/package.json +43 -134
- package/rollup.config.cjs +87 -0
- package/src/components/ActionMenu/ActionMenu.stories.tsx +230 -0
- package/src/components/ActionMenu/ActionMenu.tsx +174 -0
- package/src/components/ActionMenu/index.ts +2 -0
- package/src/components/AppBar/AppBar.stories.tsx +272 -0
- package/src/components/AppBar/AppBar.sx.ts +32 -0
- package/src/components/AppBar/AppBar.tsx +123 -0
- package/src/components/AppBar/AppBarBrand.tsx +120 -0
- package/src/components/AppBar/AppBarContext.ts +25 -0
- package/src/components/AppBar/AppBarMenuToggle.tsx +90 -0
- package/src/components/AppBar/AppBarUserMenu.tsx +217 -0
- package/src/components/AppBar/index.ts +25 -0
- package/src/components/Autocomplete/Autocomplete.definitions.ts +477 -0
- package/src/components/Autocomplete/Autocomplete.helpers.ts +60 -0
- package/src/components/Autocomplete/Autocomplete.stories.tsx +748 -0
- package/src/components/Autocomplete/Autocomplete.sx.ts +30 -0
- package/src/components/Autocomplete/Autocomplete.tsx +361 -0
- package/src/components/Autocomplete/Autocomplete.types.ts +13 -0
- package/src/components/Autocomplete/_parts/AutocompleteChips.tsx +55 -0
- package/src/components/Autocomplete/_parts/AutocompleteLoader.tsx +17 -0
- package/src/components/Autocomplete/_parts/AutocompleteOption.tsx +31 -0
- package/src/components/Autocomplete/index.ts +12 -0
- package/src/components/Avatar/Avatar.definitions.ts +162 -0
- package/src/components/Avatar/Avatar.stories.tsx +258 -0
- package/src/components/Avatar/Avatar.tsx +206 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Button/Button.definition.ts +97 -0
- package/src/components/Button/Button.stories.tsx +285 -0
- package/src/components/Button/Button.tsx +67 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Card/Card.definition.ts +5 -0
- package/src/components/Card/Card.stories.tsx +221 -0
- package/src/components/Card/Card.sx.ts +104 -0
- package/src/components/Card/Card.tsx +200 -0
- package/src/components/Card/index.ts +9 -0
- package/src/components/Chip/Chip.definitions.ts +167 -0
- package/src/components/Chip/Chip.stories.tsx +265 -0
- package/src/components/Chip/Chip.tsx +61 -0
- package/src/components/Chip/index.ts +1 -0
- package/src/components/Column/Column.tsx +29 -0
- package/src/components/Column/index.ts +1 -0
- package/src/components/DatePicker/DatePicker.definitions.ts +228 -0
- package/src/components/DatePicker/DatePicker.helpers.ts +24 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +309 -0
- package/src/components/DatePicker/DatePicker.sx.ts +33 -0
- package/src/components/DatePicker/DatePicker.tsx +189 -0
- package/src/components/DatePicker/DatePicker.types.ts +10 -0
- package/src/components/DatePicker/index.ts +9 -0
- package/src/components/DateRangePicker/DateRangePicker.definitions.ts +191 -0
- package/src/components/DateRangePicker/DateRangePicker.stories.tsx +252 -0
- package/src/components/DateRangePicker/DateRangePicker.tsx +56 -0
- package/src/components/DateRangePicker/index.ts +1 -0
- package/src/components/DateTimePicker/DateTimePicker.definitions.ts +256 -0
- package/src/components/DateTimePicker/DateTimePicker.helpers.ts +38 -0
- package/src/components/DateTimePicker/DateTimePicker.stories.tsx +418 -0
- package/src/components/DateTimePicker/DateTimePicker.sx.ts +30 -0
- package/src/components/DateTimePicker/DateTimePicker.tsx +225 -0
- package/src/components/DateTimePicker/DateTimePicker.types.ts +10 -0
- package/src/components/DateTimePicker/index.ts +9 -0
- package/src/components/Drawer/Drawer.stories.tsx +270 -0
- package/src/components/Drawer/Drawer.sx.ts +106 -0
- package/src/components/Drawer/Drawer.tsx +214 -0
- package/src/components/Drawer/DrawerContext.ts +26 -0
- package/src/components/Drawer/DrawerItem.tsx +110 -0
- package/src/components/Drawer/index.ts +10 -0
- package/src/components/Flyout/Flyout.stories.tsx +282 -0
- package/src/components/Flyout/Flyout.tsx +122 -0
- package/src/components/Flyout/index.ts +1 -0
- package/src/components/Gallery/Gallery.definition.tsx +37 -0
- package/src/components/Gallery/Gallery.stories.tsx +82 -0
- package/src/components/Gallery/Gallery.tsx +118 -0
- package/src/components/Gallery/GalleryLightbox.tsx +170 -0
- package/src/components/Gallery/GalleryMain.tsx +84 -0
- package/src/components/Gallery/GalleryThumbnails.tsx +106 -0
- package/src/components/Gallery/index.ts +1 -0
- package/src/components/Icon/Icon.stories.tsx +121 -0
- package/src/components/Icon/Icon.tsx +175 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Input/Input.definitions.ts +324 -0
- package/src/components/Input/Input.helpers.ts +49 -0
- package/src/components/Input/Input.stories.tsx +499 -0
- package/src/components/Input/Input.sx.ts +42 -0
- package/src/components/Input/Input.tsx +141 -0
- package/src/components/Input/Input.types.ts +10 -0
- package/src/components/Input/index.ts +9 -0
- package/src/components/InputGroup/InputGroup.definitions.ts +158 -0
- package/src/components/InputGroup/InputGroup.stories.tsx +267 -0
- package/src/components/InputGroup/InputGroup.tsx +179 -0
- package/src/components/InputGroup/index.ts +1 -0
- package/src/components/MenuButton/MenuButton.stories.tsx +197 -0
- package/src/components/MenuButton/MenuButton.tsx +100 -0
- package/src/components/MenuButton/index.ts +1 -0
- package/src/components/Modal/Modal.stories.tsx +721 -0
- package/src/components/Modal/Modal.tsx +355 -0
- package/src/components/Modal/ModalBody.tsx +16 -0
- package/src/components/Modal/ModalFooter.tsx +71 -0
- package/src/components/Modal/ModalHeader.tsx +18 -0
- package/src/components/Modal/index.ts +6 -0
- package/src/components/PageLoader/PageLoader.stories.tsx +217 -0
- package/src/components/PageLoader/PageLoader.tsx +96 -0
- package/src/components/PageLoader/index.ts +2 -0
- package/src/components/ScrollTopButton/ScrollTopButton.stories.tsx +158 -0
- package/src/components/ScrollTopButton/ScrollTopButton.tsx +135 -0
- package/src/components/ScrollTopButton/index.ts +8 -0
- package/src/components/ScrollTopButton/scrollToTop.ts +37 -0
- package/src/components/Select/Select.definitions.ts +602 -0
- package/src/components/Select/Select.helpers.ts +71 -0
- package/src/components/Select/Select.stories.tsx +687 -0
- package/src/components/Select/Select.sx.ts +14 -0
- package/src/components/Select/Select.tsx +429 -0
- package/src/components/Select/Select.types.ts +15 -0
- package/src/components/Select/_parts/SelectMenuItem.tsx +40 -0
- package/src/components/Select/_parts/SelectSearchHeader.tsx +51 -0
- package/src/components/Select/_parts/SelectValue.tsx +96 -0
- package/src/components/Select/index.ts +14 -0
- package/src/components/Stat/Stat.stories.tsx +85 -0
- package/src/components/Stat/Stat.tsx +117 -0
- package/src/components/Stat/index.ts +2 -0
- package/src/components/StatusMessage/StatusMessage.stories.tsx +130 -0
- package/src/components/StatusMessage/StatusMessage.tsx +162 -0
- package/src/components/StatusMessage/index.ts +2 -0
- package/src/components/Stepper/Step.tsx +21 -0
- package/src/components/Stepper/Stepper.definition.ts +75 -0
- package/src/components/Stepper/Stepper.stories.tsx +122 -0
- package/src/components/Stepper/Stepper.tsx +75 -0
- package/src/components/Stepper/index.ts +2 -0
- package/src/components/Table/EmptyTable.png +0 -0
- package/src/components/Table/Table.definition.ts +580 -0
- package/src/components/Table/Table.stories.tsx +853 -0
- package/src/components/Table/Table.tsx +495 -0
- package/src/components/Table/data.ts +134 -0
- package/src/components/Table/exportsUtils.ts +195 -0
- package/src/components/Table/index.ts +3 -0
- package/src/components/Table/types.ts +34 -0
- package/src/components/Tabs/Tab.definition.ts +53 -0
- package/src/components/Tabs/Tab.tsx +19 -0
- package/src/components/Tabs/Tabs.stories.tsx +118 -0
- package/src/components/Tabs/Tabs.tsx +99 -0
- package/src/components/Tabs/_tabUtils.tsx +4 -0
- package/src/components/Tabs/index.ts +2 -0
- package/src/components/Timeline/Timeline.definition.ts +43 -0
- package/src/components/Timeline/Timeline.stories.tsx +108 -0
- package/src/components/Timeline/Timeline.tsx +49 -0
- package/src/components/Timeline/TimelineItem.tsx +31 -0
- package/src/components/Timeline/index.ts +2 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +129 -0
- package/src/components/Tooltip/Tooltip.tsx +58 -0
- package/src/components/Tooltip/index.ts +1 -0
- package/src/components/_shared/formField.sx.ts +118 -0
- package/src/components/_shared/resolvePreset.ts +35 -0
- package/src/hooks/ClipBoard/ClipBoard.stories.tsx +168 -0
- package/src/hooks/ClipBoard/ClipBoard.tsx +131 -0
- package/src/hooks/ClipBoard/ClipboardUnifiedDemo.tsx +111 -0
- package/src/hooks/ClipBoard/index.ts +1 -0
- package/src/hooks/Wizard/Wizard.stories.tsx +301 -0
- package/src/hooks/Wizard/WizardContext.tsx +166 -0
- package/src/hooks/Wizard/index.ts +6 -0
- package/src/hooks/Wizard/useWizard.ts +13 -0
- package/src/index.ts +17 -0
- package/src/mui.ts +44 -0
- package/src/styles.css +3 -0
- package/src/theme/componentStyles.ts +47 -0
- package/src/theme/tokens.ts +43 -0
- package/tailwind.config.js +10 -0
- package/tsconfig.json +48 -0
- package/tsup.config.js +41 -0
- package/vite.config.js +132 -0
- package/vitest.config.ts +35 -0
- package/DatePicker-BSNboVhN.js +0 -201
- package/DatePicker-BSNboVhN.js.map +0 -1
- package/DatePicker-BoqxWAhj.cjs +0 -200
- package/DatePicker-BoqxWAhj.cjs.map +0 -1
- package/Input-DFHs7cJ_.js +0 -171
- package/Input-DFHs7cJ_.js.map +0 -1
- package/Input-c8MwNNPg.cjs +0 -170
- package/Input-c8MwNNPg.cjs.map +0 -1
- package/Select-BO2N56sm.cjs +0 -411
- package/Select-BO2N56sm.cjs.map +0 -1
- package/Select-BcLkyHSE.js +0 -412
- package/Select-BcLkyHSE.js.map +0 -1
- package/components/Autocomplete/Autocomplete.cjs +0 -132
- package/components/Autocomplete/Autocomplete.cjs.map +0 -1
- package/components/Autocomplete/Autocomplete.d.ts +0 -28
- package/components/Autocomplete/Autocomplete.js +0 -132
- package/components/Autocomplete/Autocomplete.js.map +0 -1
- package/components/Autocomplete/index.d.ts +0 -1
- package/components/Autocomplete.d.ts +0 -2
- package/components/Avatar/Avatar.cjs +0 -126
- package/components/Avatar/Avatar.cjs.map +0 -1
- package/components/Avatar/Avatar.d.ts +0 -19
- package/components/Avatar/Avatar.js +0 -126
- package/components/Avatar/Avatar.js.map +0 -1
- package/components/Card/Card.cjs +0 -28
- package/components/Card/Card.cjs.map +0 -1
- package/components/Card/Card.d.ts +0 -13
- package/components/Card/Card.js +0 -28
- package/components/Card/Card.js.map +0 -1
- package/components/Card/index.d.ts +0 -1
- package/components/Card.d.ts +0 -2
- package/components/DatePicker/DatePicker.cjs +0 -5
- package/components/DatePicker/DatePicker.cjs.map +0 -1
- package/components/DatePicker/DatePicker.d.ts +0 -18
- package/components/DatePicker/DatePicker.js +0 -5
- package/components/DatePicker/DatePicker.js.map +0 -1
- package/components/DatePicker/index.d.ts +0 -1
- package/components/DatePicker.d.ts +0 -2
- package/components/DateTimePicker/DateTimePicker.cjs +0 -208
- package/components/DateTimePicker/DateTimePicker.cjs.map +0 -1
- package/components/DateTimePicker/DateTimePicker.d.ts +0 -28
- package/components/DateTimePicker/DateTimePicker.js +0 -208
- package/components/DateTimePicker/DateTimePicker.js.map +0 -1
- package/components/DateTimePicker/index.d.ts +0 -1
- package/components/DateTimePicker.d.ts +0 -2
- package/components/Icon/Icon.cjs.map +0 -1
- package/components/Icon/Icon.d.ts +0 -21
- package/components/Icon/Icon.js.map +0 -1
- package/components/Input/Input.cjs +0 -5
- package/components/Input/Input.cjs.map +0 -1
- package/components/Input/Input.d.ts +0 -32
- package/components/Input/Input.js +0 -5
- package/components/Input/Input.js.map +0 -1
- package/components/Input/index.d.ts +0 -1
- package/components/Input.d.ts +0 -2
- package/components/InputGroup/InputGroup.cjs +0 -126
- package/components/InputGroup/InputGroup.cjs.map +0 -1
- package/components/InputGroup/InputGroup.d.ts +0 -6
- package/components/InputGroup/InputGroup.js +0 -126
- package/components/InputGroup/InputGroup.js.map +0 -1
- package/components/Modal/Modal.cjs +0 -209
- package/components/Modal/Modal.cjs.map +0 -1
- package/components/Modal/Modal.d.ts +0 -29
- package/components/Modal/Modal.js +0 -209
- package/components/Modal/Modal.js.map +0 -1
- package/components/Modal/index.d.ts +0 -1
- package/components/Select/Select.cjs +0 -6
- package/components/Select/Select.cjs.map +0 -1
- package/components/Select/Select.js +0 -6
- package/components/Select/Select.js.map +0 -1
- package/components/Select/index.d.ts +0 -1
- package/components/Select.d.ts +0 -2
- package/components/Stepper/Stepper.cjs.map +0 -1
- package/components/Stepper/Stepper.js.map +0 -1
- package/index.cjs +0 -2
- package/index.cjs.map +0 -1
- package/index.d.ts +0 -0
- package/index.js +0 -2
- /package/{README.md → Readme.md} +0 -0
- /package/{Button-C17mExpd.cjs → dist/Button-C17mExpd.cjs} +0 -0
- /package/{Button-C17mExpd.cjs.map → dist/Button-C17mExpd.cjs.map} +0 -0
- /package/{Button-UkkP-bNw.js → dist/Button-UkkP-bNw.js} +0 -0
- /package/{Button-UkkP-bNw.js.map → dist/Button-UkkP-bNw.js.map} +0 -0
- /package/{components → dist/components}/Avatar/index.d.ts +0 -0
- /package/{components → dist/components}/Avatar.d.ts +0 -0
- /package/{components → dist/components}/Button/Button.cjs +0 -0
- /package/{components → dist/components}/Button/Button.cjs.map +0 -0
- /package/{components → dist/components}/Button/Button.d.ts +0 -0
- /package/{components → dist/components}/Button/Button.definition.d.ts +0 -0
- /package/{components → dist/components}/Button/Button.js +0 -0
- /package/{components → dist/components}/Button/Button.js.map +0 -0
- /package/{components → dist/components}/Button/index.d.ts +0 -0
- /package/{components → dist/components}/Button.d.ts +0 -0
- /package/{components → dist/components}/Card/Card.definition.d.ts +0 -0
- /package/{components → dist/components}/Chip/Chip.cjs +0 -0
- /package/{components → dist/components}/Chip/Chip.cjs.map +0 -0
- /package/{components → dist/components}/Chip/Chip.d.ts +0 -0
- /package/{components → dist/components}/Chip/Chip.definitions.d.ts +0 -0
- /package/{components → dist/components}/Chip/Chip.js +0 -0
- /package/{components → dist/components}/Chip/Chip.js.map +0 -0
- /package/{components → dist/components}/Chip/index.d.ts +0 -0
- /package/{components → dist/components}/Chip.d.ts +0 -0
- /package/{components → dist/components}/Column/Column.cjs +0 -0
- /package/{components → dist/components}/Column/Column.cjs.map +0 -0
- /package/{components → dist/components}/Column/Column.d.ts +0 -0
- /package/{components → dist/components}/Column/Column.js +0 -0
- /package/{components → dist/components}/Column/Column.js.map +0 -0
- /package/{components → dist/components}/Column/index.d.ts +0 -0
- /package/{components → dist/components}/Column.d.ts +0 -0
- /package/{components → dist/components}/DateRangePicker/DateRangePicker.cjs +0 -0
- /package/{components → dist/components}/DateRangePicker/DateRangePicker.cjs.map +0 -0
- /package/{components → dist/components}/DateRangePicker/DateRangePicker.d.ts +0 -0
- /package/{components → dist/components}/DateRangePicker/DateRangePicker.definitions.d.ts +0 -0
- /package/{components → dist/components}/DateRangePicker/DateRangePicker.js +0 -0
- /package/{components → dist/components}/DateRangePicker/DateRangePicker.js.map +0 -0
- /package/{components → dist/components}/DateRangePicker/index.d.ts +0 -0
- /package/{components → dist/components}/DateRangePicker.d.ts +0 -0
- /package/{components → dist/components}/Flyout/Flyout.cjs +0 -0
- /package/{components → dist/components}/Flyout/Flyout.cjs.map +0 -0
- /package/{components → dist/components}/Flyout/Flyout.d.ts +0 -0
- /package/{components → dist/components}/Flyout/Flyout.js +0 -0
- /package/{components → dist/components}/Flyout/Flyout.js.map +0 -0
- /package/{components → dist/components}/Flyout/index.d.ts +0 -0
- /package/{components → dist/components}/Flyout.d.ts +0 -0
- /package/{components → dist/components}/Gallery/Gallery.cjs +0 -0
- /package/{components → dist/components}/Gallery/Gallery.cjs.map +0 -0
- /package/{components → dist/components}/Gallery/Gallery.d.ts +0 -0
- /package/{components → dist/components}/Gallery/Gallery.definition.d.ts +0 -0
- /package/{components → dist/components}/Gallery/Gallery.js +0 -0
- /package/{components → dist/components}/Gallery/Gallery.js.map +0 -0
- /package/{components → dist/components}/Gallery/GalleryLightbox.d.ts +0 -0
- /package/{components → dist/components}/Gallery/GalleryMain.d.ts +0 -0
- /package/{components → dist/components}/Gallery/GalleryThumbnails.d.ts +0 -0
- /package/{components → dist/components}/Gallery/index.d.ts +0 -0
- /package/{components → dist/components}/Gallery.d.ts +0 -0
- /package/{components → dist/components}/Icon/index.d.ts +0 -0
- /package/{components → dist/components}/Icon.d.ts +0 -0
- /package/{components → dist/components}/InputGroup/index.d.ts +0 -0
- /package/{components → dist/components}/InputGroup.d.ts +0 -0
- /package/{components → dist/components}/MenuButton/MenuButton.cjs +0 -0
- /package/{components → dist/components}/MenuButton/MenuButton.cjs.map +0 -0
- /package/{components → dist/components}/MenuButton/MenuButton.d.ts +0 -0
- /package/{components → dist/components}/MenuButton/MenuButton.js +0 -0
- /package/{components → dist/components}/MenuButton/MenuButton.js.map +0 -0
- /package/{components → dist/components}/MenuButton/index.d.ts +0 -0
- /package/{components → dist/components}/MenuButton.d.ts +0 -0
- /package/{components → dist/components}/Modal/ModalBody.d.ts +0 -0
- /package/{components → dist/components}/Modal/ModalHeader.d.ts +0 -0
- /package/{components → dist/components}/Modal.d.ts +0 -0
- /package/{components → dist/components}/Stat/Stat.cjs.map +0 -0
- /package/{components → dist/components}/Stat/Stat.d.ts +0 -0
- /package/{components → dist/components}/Stat/Stat.js.map +0 -0
- /package/{components → dist/components}/Stat/index.d.ts +0 -0
- /package/{components → dist/components}/Stat.d.ts +0 -0
- /package/{components → dist/components}/StatusMessage/StatusMessage.cjs +0 -0
- /package/{components → dist/components}/StatusMessage/StatusMessage.cjs.map +0 -0
- /package/{components → dist/components}/StatusMessage/StatusMessage.d.ts +0 -0
- /package/{components → dist/components}/StatusMessage/StatusMessage.js +0 -0
- /package/{components → dist/components}/StatusMessage/StatusMessage.js.map +0 -0
- /package/{components → dist/components}/StatusMessage/index.d.ts +0 -0
- /package/{components → dist/components}/StatusMessage.d.ts +0 -0
- /package/{components → dist/components}/Stepper/Step.d.ts +0 -0
- /package/{components → dist/components}/Stepper/Stepper.definition.d.ts +0 -0
- /package/{components → dist/components}/Stepper/index.d.ts +0 -0
- /package/{components → dist/components}/Stepper.d.ts +0 -0
- /package/{components → dist/components}/Table/Table.cjs +0 -0
- /package/{components → dist/components}/Table/Table.cjs.map +0 -0
- /package/{components → dist/components}/Table/Table.d.ts +0 -0
- /package/{components → dist/components}/Table/Table.definition.d.ts +0 -0
- /package/{components → dist/components}/Table/Table.js +0 -0
- /package/{components → dist/components}/Table/Table.js.map +0 -0
- /package/{components → dist/components}/Table/data.d.ts +0 -0
- /package/{components → dist/components}/Table/exportsUtils.d.ts +0 -0
- /package/{components → dist/components}/Table/index.d.ts +0 -0
- /package/{components → dist/components}/Table/types.d.ts +0 -0
- /package/{components → dist/components}/Table.d.ts +0 -0
- /package/{components → dist/components}/Tabs/Tab.d.ts +0 -0
- /package/{components → dist/components}/Tabs/Tab.definition.d.ts +0 -0
- /package/{components → dist/components}/Tabs/Tabs.cjs +0 -0
- /package/{components → dist/components}/Tabs/Tabs.cjs.map +0 -0
- /package/{components → dist/components}/Tabs/Tabs.d.ts +0 -0
- /package/{components → dist/components}/Tabs/Tabs.js +0 -0
- /package/{components → dist/components}/Tabs/Tabs.js.map +0 -0
- /package/{components → dist/components}/Tabs/_tabUtils.d.ts +0 -0
- /package/{components → dist/components}/Tabs/index.d.ts +0 -0
- /package/{components → dist/components}/Tabs.d.ts +0 -0
- /package/{components → dist/components}/Timeline/Timeline.cjs +0 -0
- /package/{components → dist/components}/Timeline/Timeline.cjs.map +0 -0
- /package/{components → dist/components}/Timeline/Timeline.d.ts +0 -0
- /package/{components → dist/components}/Timeline/Timeline.definition.d.ts +0 -0
- /package/{components → dist/components}/Timeline/Timeline.js +0 -0
- /package/{components → dist/components}/Timeline/Timeline.js.map +0 -0
- /package/{components → dist/components}/Timeline/TimelineItem.d.ts +0 -0
- /package/{components → dist/components}/Timeline/index.d.ts +0 -0
- /package/{components → dist/components}/Timeline.d.ts +0 -0
- /package/{components → dist/components}/Tooltip/Tooltip.cjs +0 -0
- /package/{components → dist/components}/Tooltip/Tooltip.cjs.map +0 -0
- /package/{components → dist/components}/Tooltip/Tooltip.d.ts +0 -0
- /package/{components → dist/components}/Tooltip/Tooltip.js +0 -0
- /package/{components → dist/components}/Tooltip/Tooltip.js.map +0 -0
- /package/{components → dist/components}/Tooltip/index.d.ts +0 -0
- /package/{components → dist/components}/Tooltip.d.ts +0 -0
- /package/{hooks → dist/hooks}/ClipBoard/ClipBoard.cjs +0 -0
- /package/{hooks → dist/hooks}/ClipBoard/ClipBoard.cjs.map +0 -0
- /package/{hooks → dist/hooks}/ClipBoard/ClipBoard.d.ts +0 -0
- /package/{hooks → dist/hooks}/ClipBoard/ClipBoard.js +0 -0
- /package/{hooks → dist/hooks}/ClipBoard/ClipBoard.js.map +0 -0
- /package/{hooks → dist/hooks}/ClipBoard/ClipboardUnifiedDemo.d.ts +0 -0
- /package/{hooks → dist/hooks}/ClipBoard/index.d.ts +0 -0
- /package/{hooks → dist/hooks}/ClipBoard.d.ts +0 -0
- /package/{index.css → dist/styles.css} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollTopButton.cjs","sources":["../../../src/components/ScrollTopButton/scrollToTop.ts","../../../src/components/ScrollTopButton/ScrollTopButton.tsx"],"sourcesContent":["export interface ScrollToTopOptions {\n /** Comportamiento del scroll. Default: `'smooth'`. */\n behavior?: ScrollBehavior;\n /**\n * Elemento target del scroll. Default: `window`. Útil cuando el contenedor\n * scrolleable NO es `window` (p.ej. un `<Box>` con `overflow: auto`).\n */\n target?: Window | HTMLElement;\n /** Offset desde el top. Default: `0`. */\n top?: number;\n}\n\n/**\n * Reemplaza imperativamente a `ScrollTopComponent.goTop()` de Metronic.\n *\n * Llamar tras mutaciones / cambios de filtros / apertura de modales para\n * asegurar que el usuario vea el mensaje de confirmación en la parte\n * superior de la página.\n *\n * ```ts\n * // Reemplazo directo del legacy:\n * // Antes: ScrollTopComponent.goTop()\n * scrollToTop();\n *\n * // Con opciones:\n * scrollToTop({ behavior: 'auto' });\n * scrollToTop({ target: myScrollableRef.current });\n * ```\n */\nexport function scrollToTop({\n behavior = 'smooth',\n target = typeof window !== 'undefined' ? window : undefined,\n top = 0,\n}: ScrollToTopOptions = {}): void {\n if (!target) return;\n target.scrollTo({ top, left: 0, behavior });\n}\n","import React, { useEffect, useState, type ReactNode } from 'react';\nimport { Fab, Zoom, useTheme } from '@mui/material';\nimport KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';\nimport type { SxProps, Theme } from '@mui/material/styles';\n\nimport { resolvePreset } from '../_shared/resolvePreset';\nimport { scrollToTop } from './scrollToTop';\n\nexport type ScrollTopButtonPosition =\n | 'bottom-right'\n | 'bottom-left'\n | 'bottom-center';\n\nexport interface ScrollTopButtonProps {\n /**\n * Distancia en px que hay que scrollear antes de mostrar el botón.\n * Default: `300`.\n */\n threshold?: number;\n /**\n * Posición del botón en la pantalla. Default: `'bottom-right'`.\n */\n position?: ScrollTopButtonPosition;\n /**\n * Elemento scrolleable a observar y al que se hace scrollTop. Si se omite,\n * se usa `window` (caso más común).\n */\n scrollTarget?: Window | HTMLElement | null;\n /** Tamaño del FAB. Default: `'medium'`. */\n size?: 'small' | 'medium' | 'large';\n /**\n * Color del FAB. Default: `'default'`.\n */\n color?: 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error';\n /** Icono custom. Default: `<KeyboardArrowUpIcon />`. */\n icon?: ReactNode;\n /** Texto accesible (aria-label). Default: `\"Subir al inicio\"`. */\n ariaLabel?: string;\n /** Preset registrado en `theme.styles.ScrollTopButton`. */\n preset?: string;\n /** sx del Fab. Se compone sobre la posición + preset. */\n sx?: SxProps<Theme>;\n className?: string;\n}\n\nconst positionSx: Record<ScrollTopButtonPosition, SxProps<Theme>> = {\n 'bottom-right': { position: 'fixed', bottom: 24, right: 24 },\n 'bottom-left': { position: 'fixed', bottom: 24, left: 24 },\n 'bottom-center': {\n position: 'fixed',\n bottom: 24,\n left: '50%',\n transform: 'translateX(-50%)',\n },\n};\n\n/**\n * Botón flotante que aparece tras scrollear más de `threshold` px y, al\n * clickearse, hace scroll suave hasta el tope. Reemplaza al componente\n * visible de `ScrollTopComponent` de Metronic.\n *\n * Para el caso imperativo (llamar `goTop()` tras una mutación), usar el\n * helper `scrollToTop()` directamente.\n *\n * ```tsx\n * <ScrollTopButton threshold={400} position=\"bottom-right\" />\n * ```\n */\nexport function ScrollTopButton({\n threshold = 300,\n position = 'bottom-right',\n scrollTarget,\n size = 'medium',\n color = 'default',\n icon,\n ariaLabel = 'Subir al inicio',\n preset,\n sx,\n className,\n}: ScrollTopButtonProps) {\n const theme = useTheme();\n const [visible, setVisible] = useState(false);\n\n useEffect(() => {\n // Si viene scrollTarget explícito, usarlo; si no, window.\n const target: Window | HTMLElement | null =\n scrollTarget ?? (typeof window !== 'undefined' ? window : null);\n if (!target) return;\n\n const readScrollTop = () =>\n target === window\n ? window.scrollY || document.documentElement.scrollTop\n : (target as HTMLElement).scrollTop;\n\n const handleScroll = () => {\n setVisible(readScrollTop() > threshold);\n };\n\n handleScroll(); // check inicial por si ya estamos scrolleados\n target.addEventListener('scroll', handleScroll, { passive: true });\n return () => target.removeEventListener('scroll', handleScroll);\n }, [threshold, scrollTarget]);\n\n const handleClick = () => {\n scrollToTop({\n target: scrollTarget ?? (typeof window !== 'undefined' ? window : undefined),\n });\n };\n\n const presetSx = resolvePreset('ScrollTopButton', preset, theme);\n\n const mergedSx: SxProps<Theme> = [\n positionSx[position],\n { zIndex: theme.zIndex.speedDial },\n ...(presetSx ? [presetSx] : []),\n ...(Array.isArray(sx) ? sx : sx ? [sx] : []),\n ];\n\n return (\n <Zoom in={visible} unmountOnExit>\n <Fab\n size={size}\n color={color}\n aria-label={ariaLabel}\n onClick={handleClick}\n className={className}\n sx={mergedSx}\n >\n {icon ?? <KeyboardArrowUpIcon />}\n </Fab>\n </Zoom>\n );\n}\n\nexport default ScrollTopButton;\n"],"names":["useTheme","useState","useEffect","resolvePreset","jsx","Zoom","Fab"],"mappings":";;;;;;;AA6BO,SAAS,YAAY;AAAA,EAC1B,WAAW;AAAA,EACX,SAAS,OAAO,WAAW,cAAc,SAAS;AAAA,EAClD,MAAM;AACR,IAAwB,IAAU;AAChC,MAAI,CAAC,OAAQ;AACb,SAAO,SAAS,EAAE,KAAK,MAAM,GAAG,UAAU;AAC5C;ACSA,MAAM,aAA8D;AAAA,EAClE,gBAAgB,EAAE,UAAU,SAAS,QAAQ,IAAI,OAAO,GAAA;AAAA,EACxD,eAAe,EAAE,UAAU,SAAS,QAAQ,IAAI,MAAM,GAAA;AAAA,EACtD,iBAAiB;AAAA,IACf,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,WAAW;AAAA,EAAA;AAEf;AAcO,SAAS,gBAAgB;AAAA,EAC9B,YAAY;AAAA,EACZ,WAAW;AAAA,EACX;AAAA,EACA,OAAO;AAAA,EACP,QAAQ;AAAA,EACR;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,QAAQA,SAAAA,SAAA;AACd,QAAM,CAAC,SAAS,UAAU,IAAIC,MAAAA,SAAS,KAAK;AAE5CC,QAAAA,UAAU,MAAM;AAEd,UAAM,SACJ,sCAAiB,OAAO,WAAW,cAAc,SAAS;AAC5D,QAAI,CAAC,OAAQ;AAEb,UAAM,gBAAgB,MACpB,WAAW,SACP,OAAO,WAAW,SAAS,gBAAgB,YAC1C,OAAuB;AAE9B,UAAM,eAAe,MAAM;AACzB,iBAAW,cAAA,IAAkB,SAAS;AAAA,IACxC;AAEA,iBAAA;AACA,WAAO,iBAAiB,UAAU,cAAc,EAAE,SAAS,MAAM;AACjE,WAAO,MAAM,OAAO,oBAAoB,UAAU,YAAY;AAAA,EAChE,GAAG,CAAC,WAAW,YAAY,CAAC;AAE5B,QAAM,cAAc,MAAM;AACxB,gBAAY;AAAA,MACV,QAAQ,sCAAiB,OAAO,WAAW,cAAc,SAAS;AAAA,IAAA,CACnE;AAAA,EACH;AAEA,QAAM,WAAWC,cAAAA,cAAc,mBAAmB,QAAQ,KAAK;AAE/D,QAAM,WAA2B;AAAA,IAC/B,WAAW,QAAQ;AAAA,IACnB,EAAE,QAAQ,MAAM,OAAO,UAAA;AAAA,IACvB,GAAI,WAAW,CAAC,QAAQ,IAAI,CAAA;AAAA,IAC5B,GAAI,MAAM,QAAQ,EAAE,IAAI,KAAK,KAAK,CAAC,EAAE,IAAI,CAAA;AAAA,EAAC;AAG5C,SACEC,2BAAAA,IAACC,SAAAA,MAAA,EAAK,IAAI,SAAS,eAAa,MAC9B,UAAAD,2BAAAA;AAAAA,IAACE,SAAAA;AAAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,cAAY;AAAA,MACZ,SAAS;AAAA,MACT;AAAA,MACA,IAAI;AAAA,MAEH,UAAA,qDAAS,qBAAA,CAAA,CAAoB;AAAA,IAAA;AAAA,EAAA,GAElC;AAEJ;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
export type ScrollTopButtonPosition = 'bottom-right' | 'bottom-left' | 'bottom-center';
|
|
4
|
+
export interface ScrollTopButtonProps {
|
|
5
|
+
/**
|
|
6
|
+
* Distancia en px que hay que scrollear antes de mostrar el botón.
|
|
7
|
+
* Default: `300`.
|
|
8
|
+
*/
|
|
9
|
+
threshold?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Posición del botón en la pantalla. Default: `'bottom-right'`.
|
|
12
|
+
*/
|
|
13
|
+
position?: ScrollTopButtonPosition;
|
|
14
|
+
/**
|
|
15
|
+
* Elemento scrolleable a observar y al que se hace scrollTop. Si se omite,
|
|
16
|
+
* se usa `window` (caso más común).
|
|
17
|
+
*/
|
|
18
|
+
scrollTarget?: Window | HTMLElement | null;
|
|
19
|
+
/** Tamaño del FAB. Default: `'medium'`. */
|
|
20
|
+
size?: 'small' | 'medium' | 'large';
|
|
21
|
+
/**
|
|
22
|
+
* Color del FAB. Default: `'default'`.
|
|
23
|
+
*/
|
|
24
|
+
color?: 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error';
|
|
25
|
+
/** Icono custom. Default: `<KeyboardArrowUpIcon />`. */
|
|
26
|
+
icon?: ReactNode;
|
|
27
|
+
/** Texto accesible (aria-label). Default: `"Subir al inicio"`. */
|
|
28
|
+
ariaLabel?: string;
|
|
29
|
+
/** Preset registrado en `theme.styles.ScrollTopButton`. */
|
|
30
|
+
preset?: string;
|
|
31
|
+
/** sx del Fab. Se compone sobre la posición + preset. */
|
|
32
|
+
sx?: SxProps<Theme>;
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Botón flotante que aparece tras scrollear más de `threshold` px y, al
|
|
37
|
+
* clickearse, hace scroll suave hasta el tope. Reemplaza al componente
|
|
38
|
+
* visible de `ScrollTopComponent` de Metronic.
|
|
39
|
+
*
|
|
40
|
+
* Para el caso imperativo (llamar `goTop()` tras una mutación), usar el
|
|
41
|
+
* helper `scrollToTop()` directamente.
|
|
42
|
+
*
|
|
43
|
+
* ```tsx
|
|
44
|
+
* <ScrollTopButton threshold={400} position="bottom-right" />
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function ScrollTopButton({ threshold, position, scrollTarget, size, color, icon, ariaLabel, preset, sx, className, }: ScrollTopButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
export default ScrollTopButton;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
import { useTheme, Zoom, Fab } from "@mui/material";
|
|
4
|
+
import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";
|
|
5
|
+
import { r as resolvePreset } from "../../resolvePreset-B-IB0ehH.js";
|
|
6
|
+
function scrollToTop({
|
|
7
|
+
behavior = "smooth",
|
|
8
|
+
target = typeof window !== "undefined" ? window : void 0,
|
|
9
|
+
top = 0
|
|
10
|
+
} = {}) {
|
|
11
|
+
if (!target) return;
|
|
12
|
+
target.scrollTo({ top, left: 0, behavior });
|
|
13
|
+
}
|
|
14
|
+
const positionSx = {
|
|
15
|
+
"bottom-right": { position: "fixed", bottom: 24, right: 24 },
|
|
16
|
+
"bottom-left": { position: "fixed", bottom: 24, left: 24 },
|
|
17
|
+
"bottom-center": {
|
|
18
|
+
position: "fixed",
|
|
19
|
+
bottom: 24,
|
|
20
|
+
left: "50%",
|
|
21
|
+
transform: "translateX(-50%)"
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
function ScrollTopButton({
|
|
25
|
+
threshold = 300,
|
|
26
|
+
position = "bottom-right",
|
|
27
|
+
scrollTarget,
|
|
28
|
+
size = "medium",
|
|
29
|
+
color = "default",
|
|
30
|
+
icon,
|
|
31
|
+
ariaLabel = "Subir al inicio",
|
|
32
|
+
preset,
|
|
33
|
+
sx,
|
|
34
|
+
className
|
|
35
|
+
}) {
|
|
36
|
+
const theme = useTheme();
|
|
37
|
+
const [visible, setVisible] = useState(false);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const target = scrollTarget != null ? scrollTarget : typeof window !== "undefined" ? window : null;
|
|
40
|
+
if (!target) return;
|
|
41
|
+
const readScrollTop = () => target === window ? window.scrollY || document.documentElement.scrollTop : target.scrollTop;
|
|
42
|
+
const handleScroll = () => {
|
|
43
|
+
setVisible(readScrollTop() > threshold);
|
|
44
|
+
};
|
|
45
|
+
handleScroll();
|
|
46
|
+
target.addEventListener("scroll", handleScroll, { passive: true });
|
|
47
|
+
return () => target.removeEventListener("scroll", handleScroll);
|
|
48
|
+
}, [threshold, scrollTarget]);
|
|
49
|
+
const handleClick = () => {
|
|
50
|
+
scrollToTop({
|
|
51
|
+
target: scrollTarget != null ? scrollTarget : typeof window !== "undefined" ? window : void 0
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const presetSx = resolvePreset("ScrollTopButton", preset, theme);
|
|
55
|
+
const mergedSx = [
|
|
56
|
+
positionSx[position],
|
|
57
|
+
{ zIndex: theme.zIndex.speedDial },
|
|
58
|
+
...presetSx ? [presetSx] : [],
|
|
59
|
+
...Array.isArray(sx) ? sx : sx ? [sx] : []
|
|
60
|
+
];
|
|
61
|
+
return /* @__PURE__ */ jsx(Zoom, { in: visible, unmountOnExit: true, children: /* @__PURE__ */ jsx(
|
|
62
|
+
Fab,
|
|
63
|
+
{
|
|
64
|
+
size,
|
|
65
|
+
color,
|
|
66
|
+
"aria-label": ariaLabel,
|
|
67
|
+
onClick: handleClick,
|
|
68
|
+
className,
|
|
69
|
+
sx: mergedSx,
|
|
70
|
+
children: icon != null ? icon : /* @__PURE__ */ jsx(KeyboardArrowUpIcon, {})
|
|
71
|
+
}
|
|
72
|
+
) });
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
ScrollTopButton,
|
|
76
|
+
ScrollTopButton as default,
|
|
77
|
+
scrollToTop
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=ScrollTopButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollTopButton.js","sources":["../../../src/components/ScrollTopButton/scrollToTop.ts","../../../src/components/ScrollTopButton/ScrollTopButton.tsx"],"sourcesContent":["export interface ScrollToTopOptions {\n /** Comportamiento del scroll. Default: `'smooth'`. */\n behavior?: ScrollBehavior;\n /**\n * Elemento target del scroll. Default: `window`. Útil cuando el contenedor\n * scrolleable NO es `window` (p.ej. un `<Box>` con `overflow: auto`).\n */\n target?: Window | HTMLElement;\n /** Offset desde el top. Default: `0`. */\n top?: number;\n}\n\n/**\n * Reemplaza imperativamente a `ScrollTopComponent.goTop()` de Metronic.\n *\n * Llamar tras mutaciones / cambios de filtros / apertura de modales para\n * asegurar que el usuario vea el mensaje de confirmación en la parte\n * superior de la página.\n *\n * ```ts\n * // Reemplazo directo del legacy:\n * // Antes: ScrollTopComponent.goTop()\n * scrollToTop();\n *\n * // Con opciones:\n * scrollToTop({ behavior: 'auto' });\n * scrollToTop({ target: myScrollableRef.current });\n * ```\n */\nexport function scrollToTop({\n behavior = 'smooth',\n target = typeof window !== 'undefined' ? window : undefined,\n top = 0,\n}: ScrollToTopOptions = {}): void {\n if (!target) return;\n target.scrollTo({ top, left: 0, behavior });\n}\n","import React, { useEffect, useState, type ReactNode } from 'react';\nimport { Fab, Zoom, useTheme } from '@mui/material';\nimport KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';\nimport type { SxProps, Theme } from '@mui/material/styles';\n\nimport { resolvePreset } from '../_shared/resolvePreset';\nimport { scrollToTop } from './scrollToTop';\n\nexport type ScrollTopButtonPosition =\n | 'bottom-right'\n | 'bottom-left'\n | 'bottom-center';\n\nexport interface ScrollTopButtonProps {\n /**\n * Distancia en px que hay que scrollear antes de mostrar el botón.\n * Default: `300`.\n */\n threshold?: number;\n /**\n * Posición del botón en la pantalla. Default: `'bottom-right'`.\n */\n position?: ScrollTopButtonPosition;\n /**\n * Elemento scrolleable a observar y al que se hace scrollTop. Si se omite,\n * se usa `window` (caso más común).\n */\n scrollTarget?: Window | HTMLElement | null;\n /** Tamaño del FAB. Default: `'medium'`. */\n size?: 'small' | 'medium' | 'large';\n /**\n * Color del FAB. Default: `'default'`.\n */\n color?: 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error';\n /** Icono custom. Default: `<KeyboardArrowUpIcon />`. */\n icon?: ReactNode;\n /** Texto accesible (aria-label). Default: `\"Subir al inicio\"`. */\n ariaLabel?: string;\n /** Preset registrado en `theme.styles.ScrollTopButton`. */\n preset?: string;\n /** sx del Fab. Se compone sobre la posición + preset. */\n sx?: SxProps<Theme>;\n className?: string;\n}\n\nconst positionSx: Record<ScrollTopButtonPosition, SxProps<Theme>> = {\n 'bottom-right': { position: 'fixed', bottom: 24, right: 24 },\n 'bottom-left': { position: 'fixed', bottom: 24, left: 24 },\n 'bottom-center': {\n position: 'fixed',\n bottom: 24,\n left: '50%',\n transform: 'translateX(-50%)',\n },\n};\n\n/**\n * Botón flotante que aparece tras scrollear más de `threshold` px y, al\n * clickearse, hace scroll suave hasta el tope. Reemplaza al componente\n * visible de `ScrollTopComponent` de Metronic.\n *\n * Para el caso imperativo (llamar `goTop()` tras una mutación), usar el\n * helper `scrollToTop()` directamente.\n *\n * ```tsx\n * <ScrollTopButton threshold={400} position=\"bottom-right\" />\n * ```\n */\nexport function ScrollTopButton({\n threshold = 300,\n position = 'bottom-right',\n scrollTarget,\n size = 'medium',\n color = 'default',\n icon,\n ariaLabel = 'Subir al inicio',\n preset,\n sx,\n className,\n}: ScrollTopButtonProps) {\n const theme = useTheme();\n const [visible, setVisible] = useState(false);\n\n useEffect(() => {\n // Si viene scrollTarget explícito, usarlo; si no, window.\n const target: Window | HTMLElement | null =\n scrollTarget ?? (typeof window !== 'undefined' ? window : null);\n if (!target) return;\n\n const readScrollTop = () =>\n target === window\n ? window.scrollY || document.documentElement.scrollTop\n : (target as HTMLElement).scrollTop;\n\n const handleScroll = () => {\n setVisible(readScrollTop() > threshold);\n };\n\n handleScroll(); // check inicial por si ya estamos scrolleados\n target.addEventListener('scroll', handleScroll, { passive: true });\n return () => target.removeEventListener('scroll', handleScroll);\n }, [threshold, scrollTarget]);\n\n const handleClick = () => {\n scrollToTop({\n target: scrollTarget ?? (typeof window !== 'undefined' ? window : undefined),\n });\n };\n\n const presetSx = resolvePreset('ScrollTopButton', preset, theme);\n\n const mergedSx: SxProps<Theme> = [\n positionSx[position],\n { zIndex: theme.zIndex.speedDial },\n ...(presetSx ? [presetSx] : []),\n ...(Array.isArray(sx) ? sx : sx ? [sx] : []),\n ];\n\n return (\n <Zoom in={visible} unmountOnExit>\n <Fab\n size={size}\n color={color}\n aria-label={ariaLabel}\n onClick={handleClick}\n className={className}\n sx={mergedSx}\n >\n {icon ?? <KeyboardArrowUpIcon />}\n </Fab>\n </Zoom>\n );\n}\n\nexport default ScrollTopButton;\n"],"names":[],"mappings":";;;;;AA6BO,SAAS,YAAY;AAAA,EAC1B,WAAW;AAAA,EACX,SAAS,OAAO,WAAW,cAAc,SAAS;AAAA,EAClD,MAAM;AACR,IAAwB,IAAU;AAChC,MAAI,CAAC,OAAQ;AACb,SAAO,SAAS,EAAE,KAAK,MAAM,GAAG,UAAU;AAC5C;ACSA,MAAM,aAA8D;AAAA,EAClE,gBAAgB,EAAE,UAAU,SAAS,QAAQ,IAAI,OAAO,GAAA;AAAA,EACxD,eAAe,EAAE,UAAU,SAAS,QAAQ,IAAI,MAAM,GAAA;AAAA,EACtD,iBAAiB;AAAA,IACf,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,WAAW;AAAA,EAAA;AAEf;AAcO,SAAS,gBAAgB;AAAA,EAC9B,YAAY;AAAA,EACZ,WAAW;AAAA,EACX;AAAA,EACA,OAAO;AAAA,EACP,QAAQ;AAAA,EACR;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,QAAQ,SAAA;AACd,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAE5C,YAAU,MAAM;AAEd,UAAM,SACJ,sCAAiB,OAAO,WAAW,cAAc,SAAS;AAC5D,QAAI,CAAC,OAAQ;AAEb,UAAM,gBAAgB,MACpB,WAAW,SACP,OAAO,WAAW,SAAS,gBAAgB,YAC1C,OAAuB;AAE9B,UAAM,eAAe,MAAM;AACzB,iBAAW,cAAA,IAAkB,SAAS;AAAA,IACxC;AAEA,iBAAA;AACA,WAAO,iBAAiB,UAAU,cAAc,EAAE,SAAS,MAAM;AACjE,WAAO,MAAM,OAAO,oBAAoB,UAAU,YAAY;AAAA,EAChE,GAAG,CAAC,WAAW,YAAY,CAAC;AAE5B,QAAM,cAAc,MAAM;AACxB,gBAAY;AAAA,MACV,QAAQ,sCAAiB,OAAO,WAAW,cAAc,SAAS;AAAA,IAAA,CACnE;AAAA,EACH;AAEA,QAAM,WAAW,cAAc,mBAAmB,QAAQ,KAAK;AAE/D,QAAM,WAA2B;AAAA,IAC/B,WAAW,QAAQ;AAAA,IACnB,EAAE,QAAQ,MAAM,OAAO,UAAA;AAAA,IACvB,GAAI,WAAW,CAAC,QAAQ,IAAI,CAAA;AAAA,IAC5B,GAAI,MAAM,QAAQ,EAAE,IAAI,KAAK,KAAK,CAAC,EAAE,IAAI,CAAA;AAAA,EAAC;AAG5C,SACE,oBAAC,MAAA,EAAK,IAAI,SAAS,eAAa,MAC9B,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,cAAY;AAAA,MACZ,SAAS;AAAA,MACT;AAAA,MACA,IAAI;AAAA,MAEH,UAAA,0CAAS,qBAAA,CAAA,CAAoB;AAAA,IAAA;AAAA,EAAA,GAElC;AAEJ;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface ScrollToTopOptions {
|
|
2
|
+
/** Comportamiento del scroll. Default: `'smooth'`. */
|
|
3
|
+
behavior?: ScrollBehavior;
|
|
4
|
+
/**
|
|
5
|
+
* Elemento target del scroll. Default: `window`. Útil cuando el contenedor
|
|
6
|
+
* scrolleable NO es `window` (p.ej. un `<Box>` con `overflow: auto`).
|
|
7
|
+
*/
|
|
8
|
+
target?: Window | HTMLElement;
|
|
9
|
+
/** Offset desde el top. Default: `0`. */
|
|
10
|
+
top?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reemplaza imperativamente a `ScrollTopComponent.goTop()` de Metronic.
|
|
14
|
+
*
|
|
15
|
+
* Llamar tras mutaciones / cambios de filtros / apertura de modales para
|
|
16
|
+
* asegurar que el usuario vea el mensaje de confirmación en la parte
|
|
17
|
+
* superior de la página.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* // Reemplazo directo del legacy:
|
|
21
|
+
* // Antes: ScrollTopComponent.goTop()
|
|
22
|
+
* scrollToTop();
|
|
23
|
+
*
|
|
24
|
+
* // Con opciones:
|
|
25
|
+
* scrollToTop({ behavior: 'auto' });
|
|
26
|
+
* scrollToTop({ target: myScrollableRef.current });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function scrollToTop({ behavior, target, top, }?: ScrollToTopOptions): void;
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
34
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
35
|
+
const React = require("react");
|
|
36
|
+
const material = require("@mui/material");
|
|
37
|
+
const styles = require("@mui/material/styles");
|
|
38
|
+
const reactHookForm = require("react-hook-form");
|
|
39
|
+
const formField_sx = require("../../formField.sx-CQ1mbk9M.cjs");
|
|
40
|
+
const resolvePreset = require("../../resolvePreset-CT3kU-K2.cjs");
|
|
41
|
+
const ClearIcon = require("@mui/icons-material/Clear");
|
|
42
|
+
const CheckIcon = require("@mui/icons-material/Check");
|
|
43
|
+
const buildSelectSx = (borderRadius, labelPosition) => formField_sx.buildFormFieldSx({ borderRadius, labelPosition });
|
|
44
|
+
const filterOptionsByLabel = (options, search) => {
|
|
45
|
+
if (!search) return options;
|
|
46
|
+
const needle = search.toLowerCase();
|
|
47
|
+
return options.filter((opt) => opt.label.toLowerCase().includes(needle));
|
|
48
|
+
};
|
|
49
|
+
const groupOptions = (options) => {
|
|
50
|
+
const groups = {};
|
|
51
|
+
options.forEach((opt) => {
|
|
52
|
+
const group = opt.group || "__default";
|
|
53
|
+
if (!groups[group]) groups[group] = [];
|
|
54
|
+
groups[group].push(opt);
|
|
55
|
+
});
|
|
56
|
+
return groups;
|
|
57
|
+
};
|
|
58
|
+
const isGroupedOptionsEmpty = (groups) => {
|
|
59
|
+
const keys = Object.keys(groups);
|
|
60
|
+
if (keys.length === 0) return true;
|
|
61
|
+
if (keys.length === 1 && groups["__default"] && groups["__default"].length === 0) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
};
|
|
66
|
+
const normalizeSelectValue = (value, multiple) => {
|
|
67
|
+
if (multiple) return value != null ? value : [];
|
|
68
|
+
return value != null ? value : "";
|
|
69
|
+
};
|
|
70
|
+
const isSelectValueEmpty = (normalizedValue, multiple) => {
|
|
71
|
+
if (multiple) return Array.isArray(normalizedValue) && normalizedValue.length === 0;
|
|
72
|
+
return normalizedValue === "" || normalizedValue === null || normalizedValue === void 0;
|
|
73
|
+
};
|
|
74
|
+
const SelectSearchHeader = ({
|
|
75
|
+
value,
|
|
76
|
+
onChange,
|
|
77
|
+
placeholder = "Buscar...",
|
|
78
|
+
inputRef
|
|
79
|
+
}) => {
|
|
80
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
81
|
+
material.ListSubheader,
|
|
82
|
+
{
|
|
83
|
+
sx: {
|
|
84
|
+
px: 2,
|
|
85
|
+
pt: 1,
|
|
86
|
+
pb: 1,
|
|
87
|
+
backgroundColor: "background.paper",
|
|
88
|
+
zIndex: 1,
|
|
89
|
+
position: "sticky",
|
|
90
|
+
top: 0
|
|
91
|
+
},
|
|
92
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
93
|
+
material.TextField,
|
|
94
|
+
{
|
|
95
|
+
inputRef,
|
|
96
|
+
placeholder,
|
|
97
|
+
variant: "standard",
|
|
98
|
+
size: "small",
|
|
99
|
+
fullWidth: true,
|
|
100
|
+
value,
|
|
101
|
+
onChange: (e) => onChange(e.target.value),
|
|
102
|
+
slotProps: { htmlInput: { autoFocus: true } },
|
|
103
|
+
onClick: (e) => e.stopPropagation(),
|
|
104
|
+
onKeyDown: (e) => e.stopPropagation()
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
function SelectValue(props) {
|
|
111
|
+
var _a;
|
|
112
|
+
const {
|
|
113
|
+
selected,
|
|
114
|
+
options,
|
|
115
|
+
multiple,
|
|
116
|
+
placeholder,
|
|
117
|
+
maxChipsToShow,
|
|
118
|
+
chipVariant,
|
|
119
|
+
renderChipLabel,
|
|
120
|
+
onDeleteChip,
|
|
121
|
+
currentValues
|
|
122
|
+
} = props;
|
|
123
|
+
const isEmpty = !selected || Array.isArray(selected) && selected.length === 0;
|
|
124
|
+
if (isEmpty) {
|
|
125
|
+
return /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { sx: { color: "text.disabled" }, children: placeholder || "" });
|
|
126
|
+
}
|
|
127
|
+
if (!multiple) {
|
|
128
|
+
const item = options.find((opt) => opt.value === selected);
|
|
129
|
+
if (renderChipLabel && item) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderChipLabel(item) });
|
|
130
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: (_a = item == null ? void 0 : item.label) != null ? _a : String(selected) });
|
|
131
|
+
}
|
|
132
|
+
const selectedValuesArray = selected;
|
|
133
|
+
const displayedChips = selectedValuesArray.slice(0, maxChipsToShow);
|
|
134
|
+
const hiddenChipsCount = selectedValuesArray.length - maxChipsToShow;
|
|
135
|
+
const handleDelete = (chipValue) => {
|
|
136
|
+
if (!onDeleteChip || !currentValues) return;
|
|
137
|
+
onDeleteChip(currentValues.filter((v) => v !== chipValue));
|
|
138
|
+
};
|
|
139
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { display: "flex", flexWrap: "wrap", gap: 0.5 }, children: [
|
|
140
|
+
displayedChips.map((val) => {
|
|
141
|
+
const item = options.find((o) => o.value === val);
|
|
142
|
+
if (!item) return null;
|
|
143
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
144
|
+
material.Chip,
|
|
145
|
+
{
|
|
146
|
+
variant: chipVariant,
|
|
147
|
+
color: "primary",
|
|
148
|
+
size: "small",
|
|
149
|
+
label: renderChipLabel ? renderChipLabel(item) : item.label,
|
|
150
|
+
avatar: item.img ? /* @__PURE__ */ jsxRuntime.jsx(material.Avatar, { src: item.img }) : void 0,
|
|
151
|
+
onDelete: () => handleDelete(val),
|
|
152
|
+
deleteIcon: /* @__PURE__ */ jsxRuntime.jsx(ClearIcon, { fontSize: "small" })
|
|
153
|
+
},
|
|
154
|
+
String(val)
|
|
155
|
+
);
|
|
156
|
+
}),
|
|
157
|
+
hiddenChipsCount > 0 && /* @__PURE__ */ jsxRuntime.jsx(material.Chip, { size: "small", variant: chipVariant, label: `+${hiddenChipsCount} más` })
|
|
158
|
+
] });
|
|
159
|
+
}
|
|
160
|
+
const renderSelectMenuItem = ({
|
|
161
|
+
option,
|
|
162
|
+
selected,
|
|
163
|
+
customRender
|
|
164
|
+
}) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
165
|
+
material.MenuItem,
|
|
166
|
+
{
|
|
167
|
+
value: option.value,
|
|
168
|
+
disabled: option.disabled,
|
|
169
|
+
selected,
|
|
170
|
+
children: [
|
|
171
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.ListItemIcon, { sx: { minWidth: 32 }, children: selected && /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { color: "success", fontSize: "small" }) }),
|
|
172
|
+
customRender ? customRender(option) : option.label
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
String(option.value)
|
|
176
|
+
);
|
|
177
|
+
function Option(_props) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
Option.displayName = "Option";
|
|
181
|
+
function Select(props) {
|
|
182
|
+
const _a = props, {
|
|
183
|
+
label,
|
|
184
|
+
options = [],
|
|
185
|
+
value,
|
|
186
|
+
onChange,
|
|
187
|
+
defaultValue,
|
|
188
|
+
size = "small",
|
|
189
|
+
multiple = false,
|
|
190
|
+
filterable = false,
|
|
191
|
+
placeholder,
|
|
192
|
+
children,
|
|
193
|
+
maxHeight = 300,
|
|
194
|
+
maxWidth,
|
|
195
|
+
maxChipsToShow = 3,
|
|
196
|
+
renderChipLabel,
|
|
197
|
+
chipVariant = "outlined",
|
|
198
|
+
loadOptions,
|
|
199
|
+
loadingMessage = "Cargando opciones...",
|
|
200
|
+
noOptionsMessage = "No hay opciones",
|
|
201
|
+
debounceTimeout = 300,
|
|
202
|
+
disabled = false,
|
|
203
|
+
error = false,
|
|
204
|
+
helperText,
|
|
205
|
+
borderRadius = 10,
|
|
206
|
+
labelPosition = "outside",
|
|
207
|
+
preset,
|
|
208
|
+
sx,
|
|
209
|
+
className
|
|
210
|
+
} = _a, rest = __objRest(_a, [
|
|
211
|
+
"label",
|
|
212
|
+
"options",
|
|
213
|
+
"value",
|
|
214
|
+
"onChange",
|
|
215
|
+
"defaultValue",
|
|
216
|
+
"size",
|
|
217
|
+
"multiple",
|
|
218
|
+
"filterable",
|
|
219
|
+
"placeholder",
|
|
220
|
+
"children",
|
|
221
|
+
"maxHeight",
|
|
222
|
+
"maxWidth",
|
|
223
|
+
"maxChipsToShow",
|
|
224
|
+
"renderChipLabel",
|
|
225
|
+
"chipVariant",
|
|
226
|
+
"loadOptions",
|
|
227
|
+
"loadingMessage",
|
|
228
|
+
"noOptionsMessage",
|
|
229
|
+
"debounceTimeout",
|
|
230
|
+
"disabled",
|
|
231
|
+
"error",
|
|
232
|
+
"helperText",
|
|
233
|
+
"borderRadius",
|
|
234
|
+
"labelPosition",
|
|
235
|
+
"preset",
|
|
236
|
+
"sx",
|
|
237
|
+
"className"
|
|
238
|
+
]);
|
|
239
|
+
const theme = styles.useTheme();
|
|
240
|
+
const presetSx = resolvePreset.resolvePreset("Select", preset, theme);
|
|
241
|
+
const isRHFMode = "control" in rest && rest.control !== void 0;
|
|
242
|
+
const customRender = React.useMemo(() => {
|
|
243
|
+
var _a2;
|
|
244
|
+
if (React.Children.count(children) === 1) {
|
|
245
|
+
const child = React.Children.only(children);
|
|
246
|
+
if (React.isValidElement(child) && ((_a2 = child.type) == null ? void 0 : _a2.displayName) === "Option") {
|
|
247
|
+
return child.props.children;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
}, [children]);
|
|
252
|
+
const [search, setSearch] = React.useState("");
|
|
253
|
+
const [asyncOptions, setAsyncOptions] = React.useState([]);
|
|
254
|
+
const [loading, setLoading] = React.useState(false);
|
|
255
|
+
const debounceTimerRef = React.useRef(null);
|
|
256
|
+
const searchInputRef = React.useRef(null);
|
|
257
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
258
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
259
|
+
const isAsync = typeof loadOptions === "function";
|
|
260
|
+
const currentOptions = isAsync ? asyncOptions : options;
|
|
261
|
+
React.useEffect(() => {
|
|
262
|
+
var _a2;
|
|
263
|
+
if (!isAsync) return;
|
|
264
|
+
if (debounceTimerRef.current) clearTimeout(debounceTimerRef.current);
|
|
265
|
+
if (search) {
|
|
266
|
+
setLoading(true);
|
|
267
|
+
debounceTimerRef.current = window.setTimeout(() => {
|
|
268
|
+
loadOptions(search).then(setAsyncOptions).finally(() => {
|
|
269
|
+
var _a3;
|
|
270
|
+
setLoading(false);
|
|
271
|
+
(_a3 = searchInputRef.current) == null ? void 0 : _a3.focus();
|
|
272
|
+
});
|
|
273
|
+
}, debounceTimeout);
|
|
274
|
+
} else {
|
|
275
|
+
setAsyncOptions([]);
|
|
276
|
+
setLoading(false);
|
|
277
|
+
(_a2 = searchInputRef.current) == null ? void 0 : _a2.focus();
|
|
278
|
+
}
|
|
279
|
+
}, [search, isAsync, loadOptions, debounceTimeout]);
|
|
280
|
+
const filteredOptions = React.useMemo(() => {
|
|
281
|
+
if (isAsync) return currentOptions;
|
|
282
|
+
if (!filterable) return currentOptions;
|
|
283
|
+
return filterOptionsByLabel(currentOptions, search);
|
|
284
|
+
}, [search, filterable, currentOptions, isAsync]);
|
|
285
|
+
const groupedOptions = React.useMemo(() => groupOptions(filteredOptions), [filteredOptions]);
|
|
286
|
+
const menuItems = React.useMemo(() => {
|
|
287
|
+
const items = [];
|
|
288
|
+
if (filterable || isAsync) {
|
|
289
|
+
items.push(
|
|
290
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
291
|
+
SelectSearchHeader,
|
|
292
|
+
{
|
|
293
|
+
value: search,
|
|
294
|
+
onChange: setSearch,
|
|
295
|
+
inputRef: searchInputRef
|
|
296
|
+
},
|
|
297
|
+
"search-header"
|
|
298
|
+
)
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
const noOptions = isGroupedOptionsEmpty(groupedOptions);
|
|
302
|
+
if (loading) {
|
|
303
|
+
items.push(
|
|
304
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.MenuItem, { disabled: true, children: /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
305
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 20 }),
|
|
306
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Typography, { children: loadingMessage })
|
|
307
|
+
] }) }, "loading-message")
|
|
308
|
+
);
|
|
309
|
+
} else if (noOptions) {
|
|
310
|
+
items.push(
|
|
311
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.MenuItem, { disabled: true, children: /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { children: noOptionsMessage }) }, "no-options-message")
|
|
312
|
+
);
|
|
313
|
+
} else {
|
|
314
|
+
Object.entries(groupedOptions).forEach(([group, opts]) => {
|
|
315
|
+
if (group !== "__default") {
|
|
316
|
+
items.push(
|
|
317
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.ListSubheader, { disableSticky: true, children: group }, group)
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
opts.forEach((opt) => {
|
|
321
|
+
var _a2;
|
|
322
|
+
const isSelected = multiple ? (_a2 = value == null ? void 0 : value.includes(opt.value)) != null ? _a2 : false : value === opt.value;
|
|
323
|
+
items.push(
|
|
324
|
+
renderSelectMenuItem({
|
|
325
|
+
option: opt,
|
|
326
|
+
selected: isSelected,
|
|
327
|
+
customRender
|
|
328
|
+
})
|
|
329
|
+
);
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
return items;
|
|
334
|
+
}, [
|
|
335
|
+
groupedOptions,
|
|
336
|
+
customRender,
|
|
337
|
+
filterable,
|
|
338
|
+
isAsync,
|
|
339
|
+
search,
|
|
340
|
+
loading,
|
|
341
|
+
loadingMessage,
|
|
342
|
+
noOptionsMessage,
|
|
343
|
+
multiple,
|
|
344
|
+
value
|
|
345
|
+
]);
|
|
346
|
+
const handleChangeInternal = (event, rhfOnChange) => {
|
|
347
|
+
const newValue = event.target.value;
|
|
348
|
+
if (isRHFMode) {
|
|
349
|
+
rhfOnChange == null ? void 0 : rhfOnChange(newValue);
|
|
350
|
+
} else {
|
|
351
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
const mergedSx = [
|
|
355
|
+
buildSelectSx(borderRadius, labelPosition),
|
|
356
|
+
...presetSx ? [presetSx] : [],
|
|
357
|
+
...Array.isArray(sx) ? sx : [sx]
|
|
358
|
+
];
|
|
359
|
+
const renderSelect = (selectValue, selectOnChange, onBlur, inputRef, rhfError, rhfHelperText) => {
|
|
360
|
+
const finalError = rhfError != null ? rhfError : error;
|
|
361
|
+
const finalHelperText = rhfHelperText != null ? rhfHelperText : helperText;
|
|
362
|
+
const inputElement = labelPosition === "floating" ? /* @__PURE__ */ jsxRuntime.jsx(material.OutlinedInput, { label }) : /* @__PURE__ */ jsxRuntime.jsx(material.OutlinedInput, {});
|
|
363
|
+
const normalizedValue = normalizeSelectValue(selectValue, multiple);
|
|
364
|
+
const isEmpty = isSelectValueEmpty(normalizedValue, multiple);
|
|
365
|
+
const shouldShrink = !isEmpty || isFocused || isOpen;
|
|
366
|
+
const shouldDisplayPlaceholder = isEmpty && (isFocused || isOpen) && !!placeholder;
|
|
367
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
368
|
+
material.FormControl,
|
|
369
|
+
{
|
|
370
|
+
fullWidth: true,
|
|
371
|
+
size,
|
|
372
|
+
error: finalError,
|
|
373
|
+
disabled,
|
|
374
|
+
className,
|
|
375
|
+
sx: mergedSx,
|
|
376
|
+
children: [
|
|
377
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(material.InputLabel, { shrink: shouldShrink, children: label }),
|
|
378
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
379
|
+
material.Select,
|
|
380
|
+
__spreadProps(__spreadValues({
|
|
381
|
+
value: normalizedValue,
|
|
382
|
+
defaultValue,
|
|
383
|
+
multiple,
|
|
384
|
+
onChange: selectOnChange,
|
|
385
|
+
onBlur: (e) => {
|
|
386
|
+
setIsFocused(false);
|
|
387
|
+
onBlur == null ? void 0 : onBlur(e);
|
|
388
|
+
},
|
|
389
|
+
onFocus: () => setIsFocused(true),
|
|
390
|
+
onOpen: () => setIsOpen(true),
|
|
391
|
+
onClose: () => setIsOpen(false),
|
|
392
|
+
renderValue: (selected) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
393
|
+
SelectValue,
|
|
394
|
+
{
|
|
395
|
+
selected,
|
|
396
|
+
options: currentOptions,
|
|
397
|
+
multiple,
|
|
398
|
+
placeholder,
|
|
399
|
+
maxChipsToShow,
|
|
400
|
+
chipVariant,
|
|
401
|
+
renderChipLabel,
|
|
402
|
+
currentValues: value != null ? value : [],
|
|
403
|
+
onDeleteChip: (next) => onChange == null ? void 0 : onChange(next)
|
|
404
|
+
}
|
|
405
|
+
),
|
|
406
|
+
displayEmpty: shouldDisplayPlaceholder,
|
|
407
|
+
input: inputElement,
|
|
408
|
+
disabled,
|
|
409
|
+
MenuProps: {
|
|
410
|
+
PaperProps: {
|
|
411
|
+
style: { maxHeight, maxWidth }
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
inputRef
|
|
415
|
+
}, rest), {
|
|
416
|
+
children: menuItems
|
|
417
|
+
})
|
|
418
|
+
),
|
|
419
|
+
finalHelperText && /* @__PURE__ */ jsxRuntime.jsx(material.FormHelperText, { children: finalHelperText })
|
|
420
|
+
]
|
|
421
|
+
}
|
|
422
|
+
);
|
|
423
|
+
};
|
|
424
|
+
if (isRHFMode) {
|
|
425
|
+
const rhfProps = rest;
|
|
426
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
427
|
+
reactHookForm.Controller,
|
|
428
|
+
{
|
|
429
|
+
name: rhfProps.name,
|
|
430
|
+
control: rhfProps.control,
|
|
431
|
+
rules: rhfProps.validation,
|
|
432
|
+
render: ({ field, fieldState: { error: fieldError } }) => renderSelect(
|
|
433
|
+
field.value,
|
|
434
|
+
(e) => handleChangeInternal(e, field.onChange),
|
|
435
|
+
field.onBlur,
|
|
436
|
+
field.ref,
|
|
437
|
+
!!fieldError,
|
|
438
|
+
fieldError == null ? void 0 : fieldError.message
|
|
439
|
+
)
|
|
440
|
+
}
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
return renderSelect(value, (e) => handleChangeInternal(e));
|
|
444
|
+
}
|
|
445
|
+
exports.Option = Option;
|
|
446
|
+
exports.Select = Select;
|
|
447
|
+
exports.default = Select;
|
|
448
|
+
//# sourceMappingURL=Select.cjs.map
|