@soyfri/shared-library 2.0.0-beta.2 → 2.0.0-beta.21
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 +117 -0
- package/chromatic.config.json +5 -0
- package/cleanDirectories.js +40 -0
- package/dist/Autocomplete-C_lW1VER.js +337 -0
- package/dist/Autocomplete-C_lW1VER.js.map +1 -0
- package/dist/Autocomplete-CejWztBY.cjs +336 -0
- package/dist/Autocomplete-CejWztBY.cjs.map +1 -0
- package/dist/Avatar-CgT7955R.js +162 -0
- package/dist/Avatar-CgT7955R.js.map +1 -0
- package/dist/Avatar-CuSrK8Wn.cjs +161 -0
- package/dist/Avatar-CuSrK8Wn.cjs.map +1 -0
- package/dist/Button-C17mExpd.cjs.map +1 -1
- package/dist/Button-UkkP-bNw.js.map +1 -1
- package/dist/Card-B1wtavyl.js +98 -0
- package/dist/Card-B1wtavyl.js.map +1 -0
- package/dist/Card-DfdU610V.cjs +97 -0
- package/dist/Card-DfdU610V.cjs.map +1 -0
- package/dist/Checkbox-BCqMFWt4.cjs +187 -0
- package/dist/Checkbox-BCqMFWt4.cjs.map +1 -0
- package/dist/Checkbox-gB5YKkVo.js +188 -0
- package/dist/Checkbox-gB5YKkVo.js.map +1 -0
- package/dist/{components/DateRangePicker/DateRangePicker.js → Chip-OPYQ1uQ_.js} +33 -35
- package/dist/Chip-OPYQ1uQ_.js.map +1 -0
- package/dist/{components/DateRangePicker/DateRangePicker.cjs → Chip-qoJLDiva.cjs} +33 -36
- package/dist/Chip-qoJLDiva.cjs.map +1 -0
- package/dist/DatePicker-_IGWc3I5.js +178 -0
- package/dist/DatePicker-_IGWc3I5.js.map +1 -0
- package/dist/DatePicker-t7uDTZMl.cjs +177 -0
- package/dist/DatePicker-t7uDTZMl.cjs.map +1 -0
- package/dist/DateTimePicker-BxQyjTCY.cjs +229 -0
- package/dist/DateTimePicker-BxQyjTCY.cjs.map +1 -0
- package/dist/DateTimePicker-CrmWav_j.js +230 -0
- package/dist/DateTimePicker-CrmWav_j.js.map +1 -0
- package/dist/Input-CScC87J5.cjs +185 -0
- package/dist/Input-CScC87J5.cjs.map +1 -0
- package/dist/Input-DP_fKl38.js +186 -0
- package/dist/Input-DP_fKl38.js.map +1 -0
- package/dist/Modal-BN5s-Tfk.cjs +347 -0
- package/dist/Modal-BN5s-Tfk.cjs.map +1 -0
- package/dist/Modal-BRZMPwDj.js +348 -0
- package/dist/Modal-BRZMPwDj.js.map +1 -0
- package/dist/README.md +243 -0
- package/dist/RadioGroup-Dd0rHXSX.cjs +202 -0
- package/dist/RadioGroup-Dd0rHXSX.cjs.map +1 -0
- package/dist/RadioGroup-bO-ahP9T.js +203 -0
- package/dist/RadioGroup-bO-ahP9T.js.map +1 -0
- package/dist/Select-Dycmh9vt.js +256 -0
- package/dist/Select-Dycmh9vt.js.map +1 -0
- package/dist/Select-kqR48jZU.cjs +255 -0
- package/dist/Select-kqR48jZU.cjs.map +1 -0
- package/dist/Stat-BUcFCGrz.cjs +83 -0
- package/dist/Stat-BUcFCGrz.cjs.map +1 -0
- package/dist/Stat-C06A_izS.js +84 -0
- package/dist/Stat-C06A_izS.js.map +1 -0
- package/dist/StatusMessage-B3nXpuRl.cjs +88 -0
- package/dist/StatusMessage-B3nXpuRl.cjs.map +1 -0
- package/dist/StatusMessage-D0WgSBx7.js +89 -0
- package/dist/StatusMessage-D0WgSBx7.js.map +1 -0
- package/dist/Step-BArsou1V.js +301 -0
- package/dist/Step-BArsou1V.js.map +1 -0
- package/dist/Step-Nd7SJbRZ.cjs +300 -0
- package/dist/Step-Nd7SJbRZ.cjs.map +1 -0
- package/dist/Switch-CQFOopYy.cjs +182 -0
- package/dist/Switch-CQFOopYy.cjs.map +1 -0
- package/dist/Switch-D72dpkH2.js +183 -0
- package/dist/Switch-D72dpkH2.js.map +1 -0
- package/dist/Tab-BbP8jBcK.cjs +110 -0
- package/dist/Tab-BbP8jBcK.cjs.map +1 -0
- package/dist/Tab-BxSxKJsP.js +111 -0
- package/dist/Tab-BxSxKJsP.js.map +1 -0
- package/dist/Table-C2LbW0B1.js +531 -0
- package/dist/Table-C2LbW0B1.js.map +1 -0
- package/dist/Table-C4OM6rrC.cjs +530 -0
- package/dist/Table-C4OM6rrC.cjs.map +1 -0
- package/dist/components/ActionMenu/ActionMenu.cjs +52 -52
- package/dist/components/ActionMenu/ActionMenu.cjs.map +1 -1
- package/dist/components/ActionMenu/ActionMenu.d.ts +20 -36
- package/dist/components/ActionMenu/ActionMenu.js +55 -55
- package/dist/components/ActionMenu/ActionMenu.js.map +1 -1
- package/dist/components/ActionMenu/index.d.ts +2 -2
- package/dist/components/AppBar/AppBar.cjs +3 -220
- package/dist/components/AppBar/AppBar.cjs.map +1 -1
- package/dist/components/AppBar/AppBar.d.ts +6 -6
- package/dist/components/AppBar/AppBar.js +6 -223
- package/dist/components/AppBar/AppBar.js.map +1 -1
- package/dist/components/AppBar/index.d.ts +0 -6
- package/dist/components/Autocomplete/Autocomplete.cjs +4 -311
- package/dist/components/Autocomplete/Autocomplete.cjs.map +1 -1
- package/dist/components/Autocomplete/Autocomplete.d.ts +8 -6
- package/dist/components/Autocomplete/Autocomplete.helpers.d.ts +8 -4
- package/dist/components/Autocomplete/Autocomplete.js +4 -311
- package/dist/components/Autocomplete/Autocomplete.js.map +1 -1
- package/dist/components/Autocomplete/_parts/AutocompleteOption.d.ts +5 -8
- package/dist/components/Autocomplete/index.d.ts +1 -1
- package/dist/components/Avatar/Avatar.cjs +2 -160
- package/dist/components/Avatar/Avatar.cjs.map +1 -1
- package/dist/components/Avatar/Avatar.js +2 -160
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Button/Button.d.ts +5 -5
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Card/Card.cjs +4 -184
- package/dist/components/Card/Card.cjs.map +1 -1
- package/dist/components/Card/Card.d.ts +3 -50
- package/dist/components/Card/Card.js +4 -184
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Card/Card.sx.d.ts +3 -6
- package/dist/components/Card/index.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.cjs +6 -0
- package/dist/components/Checkbox/Checkbox.cjs.map +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +55 -0
- package/dist/components/Checkbox/Checkbox.js +6 -0
- package/dist/components/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.sx.d.ts +13 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/Checkbox.d.ts +6 -0
- package/dist/components/Chip/Chip.cjs +4 -72
- package/dist/components/Chip/Chip.cjs.map +1 -1
- package/dist/components/Chip/Chip.js +3 -71
- package/dist/components/Chip/Chip.js.map +1 -1
- package/dist/components/Chip/index.d.ts +2 -1
- package/dist/components/Chip.d.ts +4 -0
- package/dist/components/Column/Column.cjs +1 -1
- package/dist/components/Column/Column.cjs.map +1 -1
- package/dist/components/Column/Column.d.ts +1 -1
- package/dist/components/Column/Column.js +1 -1
- package/dist/components/Column/Column.js.map +1 -1
- package/dist/components/Column/index.d.ts +1 -0
- package/dist/components/DatePicker/DatePicker.cjs +3 -200
- package/dist/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +1 -13
- package/dist/components/DatePicker/DatePicker.js +3 -200
- package/dist/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/DatePicker/index.d.ts +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.cjs +3 -219
- package/dist/components/DateTimePicker/DateTimePicker.cjs.map +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +10 -6
- package/dist/components/DateTimePicker/DateTimePicker.definitions.d.ts +2 -0
- package/dist/components/DateTimePicker/DateTimePicker.helpers.d.ts +4 -2
- package/dist/components/DateTimePicker/DateTimePicker.js +3 -219
- package/dist/components/DateTimePicker/DateTimePicker.js.map +1 -1
- package/dist/components/DateTimePicker/index.d.ts +1 -1
- package/dist/components/Drawer/Drawer.cjs +25 -24
- package/dist/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/components/Drawer/Drawer.d.ts +8 -1
- package/dist/components/Drawer/Drawer.js +26 -25
- package/dist/components/Drawer/Drawer.js.map +1 -1
- package/dist/components/Drawer/DrawerItem.d.ts +6 -1
- package/dist/components/Gallery/Gallery.cjs +154 -79
- package/dist/components/Gallery/Gallery.cjs.map +1 -1
- package/dist/components/Gallery/Gallery.d.ts +25 -9
- package/dist/components/Gallery/Gallery.js +154 -79
- package/dist/components/Gallery/Gallery.js.map +1 -1
- package/dist/components/Gallery/GalleryLightbox.d.ts +6 -10
- package/dist/components/Gallery/GalleryMain.d.ts +3 -7
- package/dist/components/Gallery/GalleryThumbnails.d.ts +7 -11
- package/dist/components/Gallery/index.d.ts +2 -1
- package/dist/components/Gallery.d.ts +4 -0
- package/dist/components/Icon/Icon.cjs +6 -8
- package/dist/components/Icon/Icon.cjs.map +1 -1
- package/dist/components/Icon/Icon.d.ts +11 -17
- package/dist/components/Icon/Icon.js +7 -9
- package/dist/components/Icon/Icon.js.map +1 -1
- package/dist/components/Icon/index.d.ts +2 -1
- package/dist/components/Icon.d.ts +4 -0
- package/dist/components/Input/Input.cjs +3 -172
- package/dist/components/Input/Input.cjs.map +1 -1
- package/dist/components/Input/Input.d.ts +9 -2
- package/dist/components/Input/Input.definitions.d.ts +1 -0
- package/dist/components/Input/Input.helpers.d.ts +3 -3
- package/dist/components/Input/Input.js +3 -172
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/InputGroup/InputGroup.cjs +23 -22
- package/dist/components/InputGroup/InputGroup.cjs.map +1 -1
- package/dist/components/InputGroup/InputGroup.d.ts +4 -4
- package/dist/components/InputGroup/InputGroup.js +22 -21
- package/dist/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/components/InputGroup/index.d.ts +2 -1
- package/dist/components/InputGroup.d.ts +4 -0
- package/dist/components/Modal/Modal.cjs +7 -317
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.d.ts +20 -5
- package/dist/components/Modal/Modal.js +6 -316
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/Modal/ModalBody.d.ts +6 -1
- package/dist/components/Modal/ModalFooter.d.ts +4 -4
- package/dist/components/Modal/ModalHeader.d.ts +6 -1
- package/dist/components/Modal/index.d.ts +4 -1
- package/dist/components/Modal.d.ts +4 -0
- package/dist/components/RadioGroup/RadioGroup.cjs +6 -0
- package/dist/components/RadioGroup/RadioGroup.cjs.map +1 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +59 -0
- package/dist/components/RadioGroup/RadioGroup.definitions.d.ts +6 -0
- package/dist/components/RadioGroup/RadioGroup.js +6 -0
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -0
- package/dist/components/RadioGroup/RadioGroup.sx.d.ts +20 -0
- package/dist/components/RadioGroup/index.d.ts +2 -0
- package/dist/components/RadioGroup.d.ts +6 -0
- package/dist/components/Select/Select.cjs +4 -445
- package/dist/components/Select/Select.cjs.map +1 -1
- package/dist/components/Select/Select.d.ts +15 -18
- package/dist/components/Select/Select.helpers.d.ts +5 -19
- package/dist/components/Select/Select.js +4 -445
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Stat/Stat.cjs +4 -83
- package/dist/components/Stat/Stat.cjs.map +1 -1
- package/dist/components/Stat/Stat.js +3 -82
- package/dist/components/Stat/Stat.js.map +1 -1
- package/dist/components/Stat/index.d.ts +2 -1
- package/dist/components/Stat.d.ts +4 -0
- package/dist/components/StatusMessage/StatusMessage.cjs +4 -77
- package/dist/components/StatusMessage/StatusMessage.cjs.map +1 -1
- package/dist/components/StatusMessage/StatusMessage.d.ts +20 -36
- package/dist/components/StatusMessage/StatusMessage.js +3 -76
- package/dist/components/StatusMessage/StatusMessage.js.map +1 -1
- package/dist/components/StatusMessage/index.d.ts +2 -1
- package/dist/components/StatusMessage.d.ts +4 -0
- package/dist/components/Stepper/Stepper.cjs +8 -47
- package/dist/components/Stepper/Stepper.cjs.map +1 -1
- package/dist/components/Stepper/Stepper.d.ts +9 -8
- package/dist/components/Stepper/Stepper.js +7 -46
- package/dist/components/Stepper/Stepper.js.map +1 -1
- package/dist/{hooks/Wizard/WizardContext.d.ts → components/Stepper/StepperContext.d.ts} +29 -23
- package/dist/components/Stepper/_hooks/useHorizontalScroll.d.ts +19 -0
- package/dist/components/Stepper/_parts/StepperScrollArrow.d.ts +19 -0
- package/dist/components/Stepper/index.d.ts +6 -2
- package/dist/components/Stepper.d.ts +4 -0
- package/dist/components/Switch/Switch.cjs +6 -0
- package/dist/components/Switch/Switch.cjs.map +1 -0
- package/dist/components/Switch/Switch.d.ts +48 -0
- package/dist/components/Switch/Switch.definitions.d.ts +7 -0
- package/dist/components/Switch/Switch.js +6 -0
- package/dist/components/Switch/Switch.js.map +1 -0
- package/dist/components/Switch/Switch.sx.d.ts +22 -0
- package/dist/components/Switch/Switch.types.d.ts +1 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switch.d.ts +6 -0
- package/dist/components/Table/Table.cjs +2 -528
- package/dist/components/Table/Table.cjs.map +1 -1
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Table/Table.js +2 -528
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Tabs/Tabs.cjs +5 -94
- package/dist/components/Tabs/Tabs.cjs.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +21 -16
- package/dist/components/Tabs/Tabs.js +4 -93
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +4 -2
- package/dist/components/Tabs.d.ts +4 -0
- package/dist/components/Timeline/Timeline.cjs +3 -2
- package/dist/components/Timeline/Timeline.cjs.map +1 -1
- package/dist/components/Timeline/Timeline.d.ts +4 -8
- package/dist/components/Timeline/Timeline.js +3 -2
- package/dist/components/Timeline/Timeline.js.map +1 -1
- package/dist/components/Timeline/index.d.ts +4 -2
- package/dist/components/Timeline.d.ts +4 -0
- package/dist/components/_shared/mergeSx.d.ts +7 -0
- package/dist/{formField.sx-DfVbMe0V.js → formField.sx-8_QRnKxv.js} +2 -11
- package/dist/formField.sx-8_QRnKxv.js.map +1 -0
- package/dist/{formField.sx-CQ1mbk9M.cjs → formField.sx-BAX7KwMR.cjs} +10 -19
- package/dist/formField.sx-BAX7KwMR.cjs.map +1 -0
- package/dist/index.cjs +92 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +32 -0
- package/dist/index.js +66 -3
- package/dist/index.js.map +1 -1
- package/dist/mergeSx-BXoNZjB_.js +10 -0
- package/dist/mergeSx-BXoNZjB_.js.map +1 -0
- package/dist/mergeSx-Dbccoo_H.cjs +9 -0
- package/dist/mergeSx-Dbccoo_H.cjs.map +1 -0
- package/dist/mui.d.ts +3 -1
- package/dist/package.json +190 -0
- package/dist/{resolvePreset-CT3kU-K2.cjs → resolvePreset-CxTI6_Ln.cjs} +3 -3
- package/dist/{resolvePreset-CT3kU-K2.cjs.map → resolvePreset-CxTI6_Ln.cjs.map} +1 -1
- package/dist/{resolvePreset-B-IB0ehH.js → resolvePreset-K6_BfWHD.js} +3 -3
- package/dist/{resolvePreset-B-IB0ehH.js.map → resolvePreset-K6_BfWHD.js.map} +1 -1
- package/dist/theme/componentStyles.d.ts +1 -1
- package/dist/tokens-BRrcP_p_.js +21 -0
- package/dist/tokens-BRrcP_p_.js.map +1 -0
- package/dist/tokens-jaWWNk39.cjs +20 -0
- package/dist/tokens-jaWWNk39.cjs.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/{components/ScrollTopButton → utils}/scrollToTop.d.ts +6 -7
- package/package.json +25 -48
- package/rollup.config.cjs +87 -0
- package/scripts/gen-dist-pkg.mjs +15 -0
- package/shared-library-comercios-MUI.code-workspace +10 -0
- package/src/components/ActionMenu/ActionMenu.stories.tsx +427 -0
- package/src/components/ActionMenu/ActionMenu.tsx +153 -0
- package/src/components/ActionMenu/index.ts +2 -0
- package/src/components/AppBar/AppBar.stories.tsx +316 -0
- package/src/components/AppBar/AppBar.sx.ts +32 -0
- package/src/components/AppBar/AppBar.tsx +119 -0
- package/src/components/AppBar/AppBarContext.ts +25 -0
- package/src/components/AppBar/AppBarMenuToggle.tsx +90 -0
- package/src/components/AppBar/index.ts +12 -0
- package/src/components/Autocomplete/Autocomplete.definitions.ts +477 -0
- package/src/components/Autocomplete/Autocomplete.helpers.ts +80 -0
- package/src/components/Autocomplete/Autocomplete.stories.tsx +784 -0
- package/src/components/Autocomplete/Autocomplete.sx.ts +30 -0
- package/src/components/Autocomplete/Autocomplete.tsx +393 -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 +29 -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 +2 -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 +66 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Card/Card.definition.ts +5 -0
- package/src/components/Card/Card.stories.tsx +102 -0
- package/src/components/Card/Card.sx.ts +58 -0
- package/src/components/Card/Card.tsx +85 -0
- package/src/components/Card/index.ts +4 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +212 -0
- package/src/components/Checkbox/Checkbox.sx.ts +67 -0
- package/src/components/Checkbox/Checkbox.tsx +208 -0
- package/src/components/Checkbox/index.ts +10 -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 +2 -0
- package/src/components/Column/Column.tsx +29 -0
- package/src/components/Column/index.ts +2 -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 +133 -0
- package/src/components/DatePicker/index.ts +7 -0
- package/src/components/DateTimePicker/DateTimePicker.definitions.ts +317 -0
- package/src/components/DateTimePicker/DateTimePicker.helpers.ts +45 -0
- package/src/components/DateTimePicker/DateTimePicker.stories.tsx +415 -0
- package/src/components/DateTimePicker/DateTimePicker.sx.ts +30 -0
- package/src/components/DateTimePicker/DateTimePicker.tsx +240 -0
- package/src/components/DateTimePicker/index.ts +9 -0
- package/src/components/Drawer/Drawer.stories.tsx +438 -0
- package/src/components/Drawer/Drawer.sx.ts +106 -0
- package/src/components/Drawer/Drawer.tsx +224 -0
- package/src/components/Drawer/DrawerContext.ts +26 -0
- package/src/components/Drawer/DrawerItem.tsx +120 -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 +158 -0
- package/src/components/Gallery/GalleryLightbox.tsx +186 -0
- package/src/components/Gallery/GalleryMain.tsx +87 -0
- package/src/components/Gallery/GalleryThumbnails.tsx +122 -0
- package/src/components/Gallery/index.ts +2 -0
- package/src/components/Icon/Icon.stories.tsx +121 -0
- package/src/components/Icon/Icon.tsx +163 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Input/Input.definitions.ts +348 -0
- package/src/components/Input/Input.helpers.ts +50 -0
- package/src/components/Input/Input.stories.tsx +528 -0
- package/src/components/Input/Input.sx.ts +42 -0
- package/src/components/Input/Input.tsx +162 -0
- package/src/components/Input/index.ts +10 -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 +180 -0
- package/src/components/InputGroup/index.ts +2 -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 +407 -0
- package/src/components/Modal/ModalBody.tsx +23 -0
- package/src/components/Modal/ModalFooter.tsx +83 -0
- package/src/components/Modal/ModalHeader.tsx +33 -0
- package/src/components/Modal/index.ts +11 -0
- package/src/components/RadioGroup/RadioGroup.definitions.ts +177 -0
- package/src/components/RadioGroup/RadioGroup.stories.tsx +231 -0
- package/src/components/RadioGroup/RadioGroup.sx.ts +75 -0
- package/src/components/RadioGroup/RadioGroup.tsx +207 -0
- package/src/components/RadioGroup/index.ts +10 -0
- package/src/components/Select/Select.helpers.ts +31 -0
- package/src/components/Select/Select.stories.tsx +393 -0
- package/src/components/Select/Select.sx.ts +14 -0
- package/src/components/Select/Select.tsx +332 -0
- package/src/components/Select/_parts/SelectMenuItem.tsx +40 -0
- package/src/components/Select/_parts/SelectValue.tsx +95 -0
- package/src/components/Select/index.ts +12 -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 +159 -0
- package/src/components/StatusMessage/StatusMessage.tsx +143 -0
- package/src/components/StatusMessage/index.ts +3 -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 +194 -0
- package/src/components/Stepper/Stepper.tsx +194 -0
- package/src/components/Stepper/StepperContext.tsx +176 -0
- package/src/components/Stepper/StepperProvider.stories.tsx +286 -0
- package/src/components/Stepper/_hooks/useHorizontalScroll.ts +56 -0
- package/src/components/Stepper/_parts/StepperScrollArrow.tsx +50 -0
- package/src/components/Stepper/index.ts +15 -0
- package/src/components/Switch/Switch.definitions.ts +134 -0
- package/src/components/Switch/Switch.stories.tsx +213 -0
- package/src/components/Switch/Switch.sx.ts +81 -0
- package/src/components/Switch/Switch.tsx +188 -0
- package/src/components/Switch/Switch.types.ts +10 -0
- package/src/components/Switch/index.ts +9 -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 +494 -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 +163 -0
- package/src/components/Tabs/_tabUtils.tsx +4 -0
- package/src/components/Tabs/index.ts +5 -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 +44 -0
- package/src/components/Timeline/TimelineItem.tsx +31 -0
- package/src/components/Timeline/index.ts +5 -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/mergeSx.ts +16 -0
- package/src/components/_shared/resolvePreset.ts +38 -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/index.ts +51 -0
- package/src/mui.ts +57 -0
- package/src/styles.css +3 -0
- package/src/theme/componentStyles.ts +50 -0
- package/src/theme/tokens.ts +43 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/scrollToTop.ts +36 -0
- package/storybook-static/addon-visual-tests-assets/visual-test-illustration.mp4 +0 -0
- package/storybook-static/assets/AccountCircle-BDZFsbTw.js +1 -0
- package/storybook-static/assets/ActionMenu-EynP8yU1.js +19 -0
- package/storybook-static/assets/ActionMenu.stories-DqSqRGix.js +185 -0
- package/storybook-static/assets/Alert-3zvTPc0p.js +1 -0
- package/storybook-static/assets/AppBar.stories-DcX3M5th.js +172 -0
- package/storybook-static/assets/Autocomplete.stories-CXJm8FOT.js +788 -0
- package/storybook-static/assets/Avatar-NbFfkZws.js +1 -0
- package/storybook-static/assets/Avatar.stories-CwOYCzqU.js +390 -0
- package/storybook-static/assets/Box-BnhEcfFm.js +1 -0
- package/storybook-static/assets/Button-D9h7OggD.js +1 -0
- package/storybook-static/assets/Button-DBpqmVB_.js +1 -0
- package/storybook-static/assets/Button.stories-F20dmnjq.js +320 -0
- package/storybook-static/assets/ButtonBase-qyaMEhe4.js +74 -0
- package/storybook-static/assets/Card.stories-B3NpAhO0.js +154 -0
- package/storybook-static/assets/CheckCircleOutline-CEj5mDsl.js +1 -0
- package/storybook-static/assets/Chip-C3vKPpzR.js +1 -0
- package/storybook-static/assets/Chip.stories-sxcfHVo9.js +333 -0
- package/storybook-static/assets/CircularProgress-DC7ZNWwl.js +28 -0
- package/storybook-static/assets/Clear-4kYcKvT3.js +1 -0
- package/storybook-static/assets/ClipBoard-DvLBdNHe.js +1 -0
- package/storybook-static/assets/ClipBoard.stories-BGUo47r6.js +108 -0
- package/storybook-static/assets/Close-CgHeRgmh.js +1 -0
- package/storybook-static/assets/Close-Cy8nELYU.js +1 -0
- package/storybook-static/assets/Color-AVL7NMMY-BJKvwERm.js +1 -0
- package/storybook-static/assets/ContentCopy-BfLTDb10.js +1 -0
- package/storybook-static/assets/DatePicker-Clkpr-Ku.js +1 -0
- package/storybook-static/assets/DatePicker.stories-EaUCMkh3.js +444 -0
- package/storybook-static/assets/DateRangePicker.stories-BMlkj-8K.js +390 -0
- package/storybook-static/assets/DateTimePicker.stories-B6gdzKq5.js +555 -0
- package/storybook-static/assets/DefaultPropsProvider-BGoQxtDa.js +16 -0
- package/storybook-static/assets/Delete-D2SMMmIA.js +1 -0
- package/storybook-static/assets/DialogContent-BeCDKgax.js +1 -0
- package/storybook-static/assets/Divider-BbCj9wT4.js +1 -0
- package/storybook-static/assets/DocsRenderer-PQXLIZUC-BebLK5Y_.js +1243 -0
- package/storybook-static/assets/Drawer-DcFwy73r.js +1 -0
- package/storybook-static/assets/Drawer.stories-C5AZkJBk.js +173 -0
- package/storybook-static/assets/EmptyTable-B-RKtgVs.png +0 -0
- package/storybook-static/assets/ErrorOutline-D9gM7ART.js +1 -0
- package/storybook-static/assets/Fade-Ll96CvH8.js +1 -0
- package/storybook-static/assets/Flyout.stories-Cf7z6MNw.js +163 -0
- package/storybook-static/assets/Gallery.stories-DdpWVTF6.js +127 -0
- package/storybook-static/assets/Grow-8y4FglGK.js +1 -0
- package/storybook-static/assets/Home-BRvJEp2L.js +1 -0
- package/storybook-static/assets/Icon.stories-D0mUiW_t.js +78 -0
- package/storybook-static/assets/IconButton-9OYSTH58.js +1 -0
- package/storybook-static/assets/Input-CjX0t4h-.js +1 -0
- package/storybook-static/assets/Input.stories-BRxekliy.js +650 -0
- package/storybook-static/assets/InputGroup.stories-DH6gUfmn.js +306 -0
- package/storybook-static/assets/KeyboardArrowRight-WO_attK2.js +1 -0
- package/storybook-static/assets/KeyboardArrowUp-DsyVef-i.js +1 -0
- package/storybook-static/assets/ListItem-D3O0103N.js +1 -0
- package/storybook-static/assets/ListItemIcon-hca6xN79.js +1 -0
- package/storybook-static/assets/ListItemText-BFLAwLdl.js +1 -0
- package/storybook-static/assets/Logout-gj-P3AfU.js +1 -0
- package/storybook-static/assets/Menu-ClzfjLc3.js +1 -0
- package/storybook-static/assets/MenuButton.stories-B-W_QVDt.js +162 -0
- package/storybook-static/assets/MenuItem-iU6tAqJI.js +1 -0
- package/storybook-static/assets/Modal-3okp9H2i.js +1 -0
- package/storybook-static/assets/Modal.stories-DIWzm4qR.js +468 -0
- package/storybook-static/assets/MoreVert-BoIVG4gh.js +1 -0
- package/storybook-static/assets/Notifications-DY_A-Sho.js +1 -0
- package/storybook-static/assets/PageLoader.stories-DmtO1mlm.js +158 -0
- package/storybook-static/assets/Paper-SwQBhqI7.js +1 -0
- package/storybook-static/assets/Person-CkQl-mpq.js +1 -0
- package/storybook-static/assets/PickersModalDialog-Tjnr_cu5.js +10 -0
- package/storybook-static/assets/PickersToolbarButton-Tt185-si.js +1 -0
- package/storybook-static/assets/Popper-CnCTYXxy.js +1 -0
- package/storybook-static/assets/Portal-Cj8XF9Lf.js +1 -0
- package/storybook-static/assets/ScrollTopButton.stories-BflQCwNP.js +90 -0
- package/storybook-static/assets/Select-CjcuMAY0.js +4 -0
- package/storybook-static/assets/Select-DJh2biEb.js +3 -0
- package/storybook-static/assets/Select.stories-DU1Gb3I2.js +1103 -0
- package/storybook-static/assets/Settings-BLKc1CnO.js +1 -0
- package/storybook-static/assets/Snackbar-BtVeKTw6.js +1 -0
- package/storybook-static/assets/Stack-D01OUIXi.js +1 -0
- package/storybook-static/assets/Stat.stories-Bn9-iuPT.js +60 -0
- package/storybook-static/assets/StatusMessage.stories-hnfX8FeU.js +73 -0
- package/storybook-static/assets/Stepper-BtKB5ykn.js +2 -0
- package/storybook-static/assets/Stepper.stories-CTEZbgPc.js +165 -0
- package/storybook-static/assets/Table.stories-CTn2Ktmn.js +1260 -0
- package/storybook-static/assets/TableContainer-CzLNaEU-.js +1 -0
- package/storybook-static/assets/TableRow-CS88-1HF.js +2 -0
- package/storybook-static/assets/Tabs-DLpDOu_n.js +1 -0
- package/storybook-static/assets/Tabs.stories-BFVuFy_5.js +159 -0
- package/storybook-static/assets/TextField-22T-xHBm.js +1 -0
- package/storybook-static/assets/Timeline.stories-DJU_U2Hv.js +97 -0
- package/storybook-static/assets/Tooltip-DbnHUxNj.js +1 -0
- package/storybook-static/assets/Tooltip.stories-B7tA3dnV.js +66 -0
- package/storybook-static/assets/Typography-BgntX2Ep.js +1 -0
- package/storybook-static/assets/Wizard.stories-CVrJLK_D.js +23 -0
- package/storybook-static/assets/createSimplePaletteValueFilter-bm0fmN_7.js +1 -0
- package/storybook-static/assets/createSvgIcon-D_Gca4vA.js +1 -0
- package/storybook-static/assets/debounce-Be36O1Ab.js +1 -0
- package/storybook-static/assets/emotion-react.browser.esm--g-C9cX9.js +8 -0
- package/storybook-static/assets/extendSxProp-CEpa30hT.js +1 -0
- package/storybook-static/assets/formField.sx-DMCmZIAa.js +1 -0
- package/storybook-static/assets/getReactElementRef-BQ3ANZdy.js +1 -0
- package/storybook-static/assets/iframe-BAJnc_4n.js +1079 -0
- package/storybook-static/assets/index-B1tlhOpe.js +240 -0
- package/storybook-static/assets/index-BF3FAXTk.js +9 -0
- package/storybook-static/assets/index-CIeucmOB.js +2 -0
- package/storybook-static/assets/index-CY7j4a7o.js +1 -0
- package/storybook-static/assets/index-CxkKctw5.js +1 -0
- package/storybook-static/assets/isFocusVisible-B8k4qzLc.js +1 -0
- package/storybook-static/assets/isMuiElement-CTZSFcY5.js +1 -0
- package/storybook-static/assets/jsx-runtime-D_zvdyIk.js +9 -0
- package/storybook-static/assets/listItemTextClasses-CC_rwJam.js +1 -0
- package/storybook-static/assets/mergeSlotProps-B0UBKBMe.js +1 -0
- package/storybook-static/assets/ownerDocument-DW-IO8s5.js +1 -0
- package/storybook-static/assets/ownerWindow-HkKU3E4x.js +1 -0
- package/storybook-static/assets/preload-helper-PPVm8Dsz.js +1 -0
- package/storybook-static/assets/react-18-BUJ64QCV.js +25 -0
- package/storybook-static/assets/resolvePreset-CN2aOJJr.js +1 -0
- package/storybook-static/assets/useControlled-DsVh1a5j.js +1 -0
- package/storybook-static/assets/useForkRef-0ANIrxcF.js +1 -0
- package/storybook-static/assets/useId-b4fZxjOL.js +1 -0
- package/storybook-static/assets/useMobilePicker-DK-c8xbD.js +1 -0
- package/storybook-static/assets/usePreviousProps-WR0rG4aR.js +1 -0
- package/storybook-static/assets/useSlot-b6pXgp5_.js +1 -0
- package/storybook-static/assets/useSlotProps-C0uMfuBt.js +1 -0
- package/storybook-static/assets/useTheme-BmOJK7ra.js +1 -0
- package/storybook-static/assets/useThemeProps-DYtxXiUU.js +1 -0
- package/storybook-static/assets/useThemeProps-U4yXiZ_5.js +1 -0
- package/storybook-static/assets/useTimeout-DNjRaOWc.js +1 -0
- package/storybook-static/assets/visuallyHidden-Dan1xhjv.js +1 -0
- package/storybook-static/favicon-wrapper.svg +46 -0
- package/storybook-static/favicon.svg +1 -0
- package/storybook-static/iframe.html +686 -0
- package/storybook-static/index.html +160 -0
- package/storybook-static/index.json +1 -0
- package/storybook-static/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/project.json +1 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-2/manager-bundle.js +356 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-2/manager-bundle.js.LEGAL.txt +40 -0
- package/storybook-static/sb-addons/docs-4/manager-bundle.js +151 -0
- package/storybook-static/sb-addons/onboarding-1/manager-bundle.js +127 -0
- package/storybook-static/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +971 -0
- package/storybook-static/sb-addons/vitest-3/manager-bundle.js +3 -0
- package/storybook-static/sb-common-assets/favicon-wrapper.svg +46 -0
- package/storybook-static/sb-common-assets/favicon.svg +1 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/sb-manager/globals-module-info.js +797 -0
- package/storybook-static/sb-manager/globals-runtime.js +69679 -0
- package/storybook-static/sb-manager/globals.js +34 -0
- package/storybook-static/sb-manager/runtime.js +13195 -0
- package/storybook-static/vite-inject-mocker-entry.js +18 -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/dist/components/AppBar/AppBarBrand.d.ts +0 -31
- package/dist/components/AppBar/AppBarUserMenu.d.ts +0 -65
- package/dist/components/Autocomplete/Autocomplete.types.d.ts +0 -1
- package/dist/components/DatePicker/DatePicker.types.d.ts +0 -1
- package/dist/components/DateRangePicker/DateRangePicker.cjs.map +0 -1
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +0 -15
- package/dist/components/DateRangePicker/DateRangePicker.definitions.d.ts +0 -6
- package/dist/components/DateRangePicker/DateRangePicker.js.map +0 -1
- package/dist/components/DateRangePicker/index.d.ts +0 -1
- package/dist/components/DateRangePicker.d.ts +0 -2
- package/dist/components/DateTimePicker/DateTimePicker.types.d.ts +0 -1
- package/dist/components/Input/Input.types.d.ts +0 -1
- package/dist/components/PageLoader/PageLoader.cjs +0 -61
- package/dist/components/PageLoader/PageLoader.cjs.map +0 -1
- package/dist/components/PageLoader/PageLoader.d.ts +0 -38
- package/dist/components/PageLoader/PageLoader.js +0 -61
- package/dist/components/PageLoader/PageLoader.js.map +0 -1
- package/dist/components/PageLoader/index.d.ts +0 -2
- package/dist/components/PageLoader.d.ts +0 -6
- package/dist/components/ScrollTopButton/ScrollTopButton.cjs +0 -79
- package/dist/components/ScrollTopButton/ScrollTopButton.cjs.map +0 -1
- package/dist/components/ScrollTopButton/ScrollTopButton.d.ts +0 -48
- package/dist/components/ScrollTopButton/ScrollTopButton.js +0 -79
- package/dist/components/ScrollTopButton/ScrollTopButton.js.map +0 -1
- package/dist/components/ScrollTopButton/index.d.ts +0 -4
- package/dist/components/ScrollTopButton.d.ts +0 -6
- package/dist/components/Select/Select.definitions.d.ts +0 -17
- package/dist/components/Select/Select.types.d.ts +0 -1
- package/dist/components/Select/_parts/SelectSearchHeader.d.ts +0 -15
- package/dist/formField.sx-CQ1mbk9M.cjs.map +0 -1
- package/dist/formField.sx-DfVbMe0V.js.map +0 -1
- package/dist/hooks/Wizard/Wizard.cjs +0 -7
- package/dist/hooks/Wizard/Wizard.cjs.map +0 -1
- package/dist/hooks/Wizard/Wizard.js +0 -7
- package/dist/hooks/Wizard/Wizard.js.map +0 -1
- package/dist/hooks/Wizard/index.d.ts +0 -3
- package/dist/hooks/Wizard/useWizard.d.ts +0 -9
- package/dist/hooks/Wizard.d.ts +0 -2
- package/dist/useWizard-CWdIxZzX.cjs +0 -94
- package/dist/useWizard-CWdIxZzX.cjs.map +0 -1
- package/dist/useWizard-CWq--C3o.js +0 -95
- package/dist/useWizard-CWq--C3o.js.map +0 -1
- /package/dist/{styles.css → index.css} +0 -0
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
isValidElement,
|
|
4
|
+
useMemo,
|
|
5
|
+
useState,
|
|
6
|
+
type ReactElement,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
} from 'react';
|
|
9
|
+
import {
|
|
10
|
+
FilledInput,
|
|
11
|
+
FormControl,
|
|
12
|
+
FormHelperText,
|
|
13
|
+
InputLabel,
|
|
14
|
+
ListSubheader,
|
|
15
|
+
OutlinedInput,
|
|
16
|
+
Select as MuiSelect,
|
|
17
|
+
Typography,
|
|
18
|
+
type SelectChangeEvent,
|
|
19
|
+
type SelectProps as MuiSelectProps,
|
|
20
|
+
} from '@mui/material';
|
|
21
|
+
import { useTheme } from '@mui/material/styles';
|
|
22
|
+
import { Controller, type Control, type RegisterOptions } from 'react-hook-form';
|
|
23
|
+
|
|
24
|
+
import { buildSelectSx } from './Select.sx';
|
|
25
|
+
import { resolvePreset } from '../_shared/resolvePreset';
|
|
26
|
+
import {
|
|
27
|
+
groupOptions,
|
|
28
|
+
isSelectValueEmpty,
|
|
29
|
+
normalizeSelectValue,
|
|
30
|
+
} from './Select.helpers';
|
|
31
|
+
import { renderSelectMenuItem } from './_parts/SelectMenuItem';
|
|
32
|
+
|
|
33
|
+
// ── Tipos de dominio ─────────────────────────────────────────────────────
|
|
34
|
+
export interface SelectOption {
|
|
35
|
+
value: string | number;
|
|
36
|
+
label: string;
|
|
37
|
+
img?: string;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
group?: string;
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type LabelPosition = 'outside' | 'floating';
|
|
44
|
+
export type SelectSize = 'small' | 'medium';
|
|
45
|
+
|
|
46
|
+
// ── Render slots ─────────────────────────────────────────────────────────
|
|
47
|
+
export type RenderOptionItem = (item: SelectOption) => ReactNode;
|
|
48
|
+
|
|
49
|
+
// ── Sub-componente declarativo <Option> ──────────────────────────────────
|
|
50
|
+
export interface OptionProps {
|
|
51
|
+
children: RenderOptionItem;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ── Props base ───────────────────────────────────────────────────────────
|
|
55
|
+
export interface BaseSelectProps<
|
|
56
|
+
TValue extends SelectOption['value'] = SelectOption['value'],
|
|
57
|
+
> {
|
|
58
|
+
label?: string;
|
|
59
|
+
options?: SelectOption[];
|
|
60
|
+
defaultValue?: TValue;
|
|
61
|
+
size?: SelectSize;
|
|
62
|
+
placeholder?: string;
|
|
63
|
+
children?: ReactElement<{ children: RenderOptionItem }>;
|
|
64
|
+
maxHeight?: number | string;
|
|
65
|
+
maxWidth?: number | string;
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
error?: boolean;
|
|
68
|
+
helperText?: string;
|
|
69
|
+
/** Border radius del input (px o string CSS). Default: 10 */
|
|
70
|
+
borderRadius?: number | string;
|
|
71
|
+
/**
|
|
72
|
+
* Posición del label.
|
|
73
|
+
* - "outside" (default): label arriba del input, sin animación.
|
|
74
|
+
* - "floating": label clásico de MUI (flota dentro del notched outline).
|
|
75
|
+
*/
|
|
76
|
+
labelPosition?: LabelPosition;
|
|
77
|
+
/**
|
|
78
|
+
* Nombre del preset de estilo registrado en `theme.styles.Select`.
|
|
79
|
+
* - `"default"` (o ausente) = estilo built-in del paquete.
|
|
80
|
+
* - Cualquier otro string = mergea el preset encima del estilo built-in.
|
|
81
|
+
*/
|
|
82
|
+
preset?: string;
|
|
83
|
+
/** MUI input variant. Default: 'outlined'. */
|
|
84
|
+
variant?: 'outlined' | 'filled';
|
|
85
|
+
sx?: MuiSelectProps['sx'];
|
|
86
|
+
className?: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ── Variantes discriminadas (RHF vs controlado) ──────────────────────────
|
|
90
|
+
export interface RHFSelectProps<
|
|
91
|
+
TValue extends SelectOption['value'] = SelectOption['value'],
|
|
92
|
+
> extends BaseSelectProps<TValue> {
|
|
93
|
+
name: string;
|
|
94
|
+
// `any` plano (no `Control<any>`): RHF tipa `Control<T>` con generics en
|
|
95
|
+
// posiciones tanto contravariantes como covariantes (ej. `_subjects.state`).
|
|
96
|
+
// Cuando el componente tiene generics propios (como `TValue` acá), TS se
|
|
97
|
+
// confunde narroweando el discriminated union y `Control<any>` no logra
|
|
98
|
+
// absorber `Control<MyForm>` en la comparación estructural profunda.
|
|
99
|
+
// El `any` plano elimina ese ruido. RHF adentro sigue teniendo sus tipos
|
|
100
|
+
// fuertes — solo degradamos la superficie del prop del Select.
|
|
101
|
+
control: any;
|
|
102
|
+
validation?: RegisterOptions;
|
|
103
|
+
/**
|
|
104
|
+
* Side-effect que corre después de que RHF actualiza el form state.
|
|
105
|
+
* Útil para cascadas entre campos (ej. reset de municipio al cambiar
|
|
106
|
+
* departamento). NO reemplaza al handler de RHF.
|
|
107
|
+
*/
|
|
108
|
+
onValueChange?: (value: TValue) => void;
|
|
109
|
+
value?: never;
|
|
110
|
+
onChange?: never;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface StandardSelectProps<
|
|
114
|
+
TValue extends SelectOption['value'] = SelectOption['value'],
|
|
115
|
+
> extends BaseSelectProps<TValue> {
|
|
116
|
+
name?: string;
|
|
117
|
+
control?: never;
|
|
118
|
+
validation?: never;
|
|
119
|
+
value: TValue;
|
|
120
|
+
onChange: (val: TValue) => void;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ── API pública final ────────────────────────────────────────────────────
|
|
124
|
+
export type SelectProps<
|
|
125
|
+
TValue extends SelectOption['value'] = SelectOption['value'],
|
|
126
|
+
> = RHFSelectProps<TValue> | StandardSelectProps<TValue>;
|
|
127
|
+
|
|
128
|
+
// ── Sub-componente declarativo <Option> ──────────────────────────────────
|
|
129
|
+
export function Option(_props: OptionProps) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
Option.displayName = 'Option';
|
|
133
|
+
|
|
134
|
+
// ── Componente ───────────────────────────────────────────────────────────
|
|
135
|
+
export function Select<
|
|
136
|
+
TValue extends SelectOption['value'] = SelectOption['value'],
|
|
137
|
+
>(props: SelectProps<TValue>) {
|
|
138
|
+
const {
|
|
139
|
+
label,
|
|
140
|
+
options = [],
|
|
141
|
+
defaultValue,
|
|
142
|
+
size = 'small',
|
|
143
|
+
placeholder,
|
|
144
|
+
children,
|
|
145
|
+
maxHeight = 300,
|
|
146
|
+
maxWidth,
|
|
147
|
+
disabled = false,
|
|
148
|
+
error = false,
|
|
149
|
+
helperText,
|
|
150
|
+
borderRadius = 10,
|
|
151
|
+
labelPosition = 'outside',
|
|
152
|
+
preset,
|
|
153
|
+
variant = 'outlined',
|
|
154
|
+
sx,
|
|
155
|
+
className,
|
|
156
|
+
// Separamos estos aunque no se usen directamente acá — evita que lleguen
|
|
157
|
+
// al DOM del MuiSelect via `{...rest}` y generen warnings de React.
|
|
158
|
+
name: _nameIgnored,
|
|
159
|
+
control: _controlIgnored,
|
|
160
|
+
validation: _validationIgnored,
|
|
161
|
+
value: _valueIgnored,
|
|
162
|
+
onChange: _onChangeIgnored,
|
|
163
|
+
...rest
|
|
164
|
+
} = props as StandardSelectProps<TValue> & {
|
|
165
|
+
name?: string;
|
|
166
|
+
control?: Control<any>;
|
|
167
|
+
validation?: RegisterOptions;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const theme = useTheme();
|
|
171
|
+
const presetSx = resolvePreset('Select', preset, theme);
|
|
172
|
+
|
|
173
|
+
const isRHFMode = 'control' in props && (props as RHFSelectProps<TValue>).control !== undefined;
|
|
174
|
+
|
|
175
|
+
// Custom render opcional vía <Option>{item => ...}</Option>
|
|
176
|
+
const customRender: RenderOptionItem | null = useMemo(() => {
|
|
177
|
+
if (Children.count(children) === 1) {
|
|
178
|
+
const child = Children.only(children);
|
|
179
|
+
if (isValidElement(child) && (child.type as any)?.displayName === 'Option') {
|
|
180
|
+
return (child.props as OptionProps).children;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}, [children]);
|
|
185
|
+
|
|
186
|
+
// Focus/open tracking para el comportamiento del label "outside".
|
|
187
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
188
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
189
|
+
|
|
190
|
+
const groupedOptions = useMemo(() => groupOptions(options), [options]);
|
|
191
|
+
|
|
192
|
+
// Items del menú (grupos + opciones). Un solo memoizado — sin search/async.
|
|
193
|
+
const buildMenuItems = (currentValue: TValue | '') => {
|
|
194
|
+
const items: ReactNode[] = [];
|
|
195
|
+
Object.entries(groupedOptions).forEach(([group, opts]) => {
|
|
196
|
+
if (group !== '__default') {
|
|
197
|
+
items.push(
|
|
198
|
+
<ListSubheader key={group} disableSticky>
|
|
199
|
+
{group}
|
|
200
|
+
</ListSubheader>,
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
opts.forEach((opt) => {
|
|
204
|
+
const selected = currentValue === opt.value;
|
|
205
|
+
items.push(
|
|
206
|
+
renderSelectMenuItem({
|
|
207
|
+
option: opt,
|
|
208
|
+
selected,
|
|
209
|
+
customRender,
|
|
210
|
+
}),
|
|
211
|
+
);
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
return items;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const mergedSx = [
|
|
218
|
+
...(presetSx ? [presetSx] : [buildSelectSx(borderRadius, labelPosition)]),
|
|
219
|
+
...(Array.isArray(sx) ? sx : sx ? [sx] : []),
|
|
220
|
+
];
|
|
221
|
+
|
|
222
|
+
// Render base (común a RHF y controlled)
|
|
223
|
+
const renderSelect = (
|
|
224
|
+
selectValue: TValue | null | undefined,
|
|
225
|
+
selectOnChange: (event: SelectChangeEvent<TValue>) => void,
|
|
226
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void,
|
|
227
|
+
inputRef?: React.Ref<HTMLInputElement>,
|
|
228
|
+
rhfError?: boolean,
|
|
229
|
+
rhfHelperText?: string,
|
|
230
|
+
) => {
|
|
231
|
+
const finalError = !!rhfError || !!error;
|
|
232
|
+
const finalHelperText = rhfHelperText ?? helperText;
|
|
233
|
+
|
|
234
|
+
const inputElement =
|
|
235
|
+
variant === 'filled'
|
|
236
|
+
? <FilledInput />
|
|
237
|
+
: labelPosition === 'floating'
|
|
238
|
+
? <OutlinedInput label={label} />
|
|
239
|
+
: <OutlinedInput />;
|
|
240
|
+
|
|
241
|
+
const normalizedValue = normalizeSelectValue(selectValue);
|
|
242
|
+
const isEmpty = isSelectValueEmpty(normalizedValue);
|
|
243
|
+
|
|
244
|
+
// Shrink cuando hay valor, foco, o dropdown abierto.
|
|
245
|
+
const shouldShrink = !isEmpty || isFocused || isOpen;
|
|
246
|
+
// Placeholder solo cuando el label ya subió.
|
|
247
|
+
const shouldDisplayPlaceholder =
|
|
248
|
+
isEmpty && (isFocused || isOpen) && !!placeholder;
|
|
249
|
+
|
|
250
|
+
return (
|
|
251
|
+
<FormControl
|
|
252
|
+
fullWidth
|
|
253
|
+
size={size}
|
|
254
|
+
variant={variant}
|
|
255
|
+
error={finalError}
|
|
256
|
+
disabled={disabled}
|
|
257
|
+
className={className}
|
|
258
|
+
sx={mergedSx}
|
|
259
|
+
>
|
|
260
|
+
{label && <InputLabel shrink={shouldShrink}>{label}</InputLabel>}
|
|
261
|
+
<MuiSelect<TValue>
|
|
262
|
+
value={normalizedValue as TValue}
|
|
263
|
+
onChange={selectOnChange}
|
|
264
|
+
onBlur={(e) => {
|
|
265
|
+
setIsFocused(false);
|
|
266
|
+
onBlur?.(e);
|
|
267
|
+
}}
|
|
268
|
+
onFocus={() => setIsFocused(true)}
|
|
269
|
+
onOpen={() => setIsOpen(true)}
|
|
270
|
+
onClose={() => setIsOpen(false)}
|
|
271
|
+
renderValue={(selected) => {
|
|
272
|
+
if (isSelectValueEmpty(selected)) {
|
|
273
|
+
return (
|
|
274
|
+
<Typography sx={{ color: 'text.disabled' }}>
|
|
275
|
+
{placeholder ?? ''}
|
|
276
|
+
</Typography>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
const item = options.find((opt) => opt.value === selected);
|
|
280
|
+
return item?.label ?? String(selected);
|
|
281
|
+
}}
|
|
282
|
+
displayEmpty={shouldDisplayPlaceholder}
|
|
283
|
+
input={inputElement}
|
|
284
|
+
disabled={disabled}
|
|
285
|
+
MenuProps={{
|
|
286
|
+
PaperProps: {
|
|
287
|
+
style: { maxHeight, maxWidth },
|
|
288
|
+
},
|
|
289
|
+
}}
|
|
290
|
+
inputRef={inputRef}
|
|
291
|
+
{...(rest as any)}
|
|
292
|
+
>
|
|
293
|
+
{buildMenuItems(normalizedValue as TValue | '')}
|
|
294
|
+
</MuiSelect>
|
|
295
|
+
{finalHelperText && <FormHelperText>{finalHelperText}</FormHelperText>}
|
|
296
|
+
</FormControl>
|
|
297
|
+
);
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// ── RHF mode ──────────────────────────────────────────────────────────
|
|
301
|
+
if (isRHFMode) {
|
|
302
|
+
const { name, control, validation, onValueChange } = props as RHFSelectProps<TValue>;
|
|
303
|
+
return (
|
|
304
|
+
<Controller
|
|
305
|
+
name={name}
|
|
306
|
+
control={control}
|
|
307
|
+
rules={validation}
|
|
308
|
+
defaultValue={defaultValue}
|
|
309
|
+
render={({ field, fieldState: { error: fieldError } }) =>
|
|
310
|
+
renderSelect(
|
|
311
|
+
field.value ?? null,
|
|
312
|
+
(e) => {
|
|
313
|
+
const next = e.target.value as TValue;
|
|
314
|
+
field.onChange(next);
|
|
315
|
+
onValueChange?.(next);
|
|
316
|
+
},
|
|
317
|
+
field.onBlur,
|
|
318
|
+
field.ref,
|
|
319
|
+
!!fieldError,
|
|
320
|
+
fieldError?.message,
|
|
321
|
+
)
|
|
322
|
+
}
|
|
323
|
+
/>
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// ── Controlled mode ───────────────────────────────────────────────────
|
|
328
|
+
const { value, onChange } = props as StandardSelectProps<TValue>;
|
|
329
|
+
return renderSelect(value, (e) => onChange(e.target.value as TValue));
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export default Select;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ListItemIcon, MenuItem } from '@mui/material';
|
|
3
|
+
import CheckIcon from '@mui/icons-material/Check';
|
|
4
|
+
|
|
5
|
+
import type { SelectOption, RenderOptionItem } from '../Select';
|
|
6
|
+
|
|
7
|
+
interface RenderSelectMenuItemArgs {
|
|
8
|
+
option: SelectOption;
|
|
9
|
+
selected: boolean;
|
|
10
|
+
customRender?: RenderOptionItem | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Render helper (no componente) que devuelve un <MenuItem> listo para
|
|
15
|
+
* colocarse como hijo directo del <MuiSelect>. Se implementa como función
|
|
16
|
+
* y no como componente porque MUI Select inspecciona `props.value` de sus
|
|
17
|
+
* children para resolver la selección, y envolverlo en un componente extra
|
|
18
|
+
* rompe esa detección.
|
|
19
|
+
*
|
|
20
|
+
* Incluye el icono de check a la izquierda cuando `selected` es true. Si el
|
|
21
|
+
* consumer pasó un `<Option>{(opt) => ...}</Option>`, usa ese render para el
|
|
22
|
+
* contenido principal; de lo contrario muestra `option.label`.
|
|
23
|
+
*/
|
|
24
|
+
export const renderSelectMenuItem = ({
|
|
25
|
+
option,
|
|
26
|
+
selected,
|
|
27
|
+
customRender,
|
|
28
|
+
}: RenderSelectMenuItemArgs): React.ReactElement => (
|
|
29
|
+
<MenuItem
|
|
30
|
+
key={String(option.value)}
|
|
31
|
+
value={option.value}
|
|
32
|
+
disabled={option.disabled}
|
|
33
|
+
selected={selected}
|
|
34
|
+
>
|
|
35
|
+
<ListItemIcon sx={{ minWidth: 32 }}>
|
|
36
|
+
{selected && <CheckIcon color="success" fontSize="small" />}
|
|
37
|
+
</ListItemIcon>
|
|
38
|
+
{customRender ? customRender(option) : option.label}
|
|
39
|
+
</MenuItem>
|
|
40
|
+
);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Avatar, Box, Chip, Typography } from '@mui/material';
|
|
2
|
+
import ClearIcon from '@mui/icons-material/Clear';
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
SelectOption,
|
|
6
|
+
RenderChipLabel,
|
|
7
|
+
ChipVariant,
|
|
8
|
+
} from '../Select';
|
|
9
|
+
|
|
10
|
+
interface SelectValueProps<TValue extends SelectOption['value']> {
|
|
11
|
+
selected: TValue | TValue[] | null | undefined;
|
|
12
|
+
options: SelectOption[];
|
|
13
|
+
multiple: boolean;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
maxChipsToShow: number;
|
|
16
|
+
chipVariant: ChipVariant;
|
|
17
|
+
renderChipLabel?: RenderChipLabel;
|
|
18
|
+
/** Solo relevante en modo multiple. Recibe el nuevo array de valores. */
|
|
19
|
+
onDeleteChip?: (nextValues: TValue[]) => void;
|
|
20
|
+
/** Array de valores actuales (para componer el nuevo array al borrar chips). */
|
|
21
|
+
currentValues?: TValue[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Render del valor seleccionado del Select.
|
|
26
|
+
* - single: texto (label) o lo que devuelva `renderChipLabel`.
|
|
27
|
+
* - multiple: chips con delete. Trunca después de `maxChipsToShow` mostrando "+N más".
|
|
28
|
+
* - empty: placeholder en color disabled.
|
|
29
|
+
*/
|
|
30
|
+
export function SelectValue<TValue extends SelectOption['value']>(
|
|
31
|
+
props: SelectValueProps<TValue>,
|
|
32
|
+
) {
|
|
33
|
+
const {
|
|
34
|
+
selected,
|
|
35
|
+
options,
|
|
36
|
+
multiple,
|
|
37
|
+
placeholder,
|
|
38
|
+
maxChipsToShow,
|
|
39
|
+
chipVariant,
|
|
40
|
+
renderChipLabel,
|
|
41
|
+
onDeleteChip,
|
|
42
|
+
currentValues,
|
|
43
|
+
} = props;
|
|
44
|
+
|
|
45
|
+
const isEmpty =
|
|
46
|
+
!selected || (Array.isArray(selected) && selected.length === 0);
|
|
47
|
+
|
|
48
|
+
if (isEmpty) {
|
|
49
|
+
return (
|
|
50
|
+
<Typography sx={{ color: 'text.disabled' }}>{placeholder || ''}</Typography>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!multiple) {
|
|
55
|
+
const item = options.find((opt) => opt.value === selected);
|
|
56
|
+
if (renderChipLabel && item) return <>{renderChipLabel(item)}</>;
|
|
57
|
+
return <>{item?.label ?? String(selected)}</>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const selectedValuesArray = selected as TValue[];
|
|
61
|
+
const displayedChips = selectedValuesArray.slice(0, maxChipsToShow);
|
|
62
|
+
const hiddenChipsCount = selectedValuesArray.length - maxChipsToShow;
|
|
63
|
+
|
|
64
|
+
const handleDelete = (chipValue: TValue) => {
|
|
65
|
+
if (!onDeleteChip || !currentValues) return;
|
|
66
|
+
onDeleteChip(currentValues.filter((v) => v !== chipValue));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.5 }}>
|
|
71
|
+
{displayedChips.map((val) => {
|
|
72
|
+
const item = options.find((o) => o.value === val);
|
|
73
|
+
if (!item) return null;
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Chip
|
|
77
|
+
variant={chipVariant}
|
|
78
|
+
color="primary"
|
|
79
|
+
size="small"
|
|
80
|
+
key={String(val)}
|
|
81
|
+
label={renderChipLabel ? renderChipLabel(item) : item.label}
|
|
82
|
+
avatar={item.img ? <Avatar src={item.img} /> : undefined}
|
|
83
|
+
onDelete={() => handleDelete(val)}
|
|
84
|
+
deleteIcon={<ClearIcon fontSize="small" />}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
})}
|
|
88
|
+
{hiddenChipsCount > 0 && (
|
|
89
|
+
<Chip size="small" variant={chipVariant} label={`+${hiddenChipsCount} más`} />
|
|
90
|
+
)}
|
|
91
|
+
</Box>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default SelectValue;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Stat, StatChip } from './Stat';
|
|
3
|
+
import { Typography } from '@mui/material';
|
|
4
|
+
import { expect, within } from 'storybook/test';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Stat> = {
|
|
7
|
+
title: 'Components/Stat',
|
|
8
|
+
component: Stat,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
},
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof Stat>;
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
stat: 100,
|
|
21
|
+
label: 'Total Sales',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Simple: Story = {
|
|
26
|
+
args: {
|
|
27
|
+
stat: 75,
|
|
28
|
+
stat2: 'Last Week',
|
|
29
|
+
label: 'Completed Orders',
|
|
30
|
+
simple: true,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const Chip: Story = {
|
|
35
|
+
args: {
|
|
36
|
+
stat: 42,
|
|
37
|
+
label: 'New Users',
|
|
38
|
+
chip: true,
|
|
39
|
+
chipColor: '#673AB7',
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const ChipList: Story = {
|
|
44
|
+
args: {
|
|
45
|
+
label: 'Status',
|
|
46
|
+
chipList: true,
|
|
47
|
+
chips: [
|
|
48
|
+
{ stat: 'Active', chipColor: '#4CAF50' },
|
|
49
|
+
{ stat: 'Pending', chipColor: '#FFC107' },
|
|
50
|
+
{ stat: 'Blocked', chipColor: '#F44336' },
|
|
51
|
+
] as StatChip[],
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const WithCustomDisplay: Story = {
|
|
56
|
+
args: {
|
|
57
|
+
stat: 350,
|
|
58
|
+
label: 'Revenue',
|
|
59
|
+
chip: true,
|
|
60
|
+
chipColor: '#2E7D32',
|
|
61
|
+
statDisplay: (stat: any) => (
|
|
62
|
+
<Typography variant="h6" fontWeight="bold">
|
|
63
|
+
${stat.toLocaleString()}
|
|
64
|
+
</Typography>
|
|
65
|
+
),
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const aStat: Story = {
|
|
70
|
+
args: {
|
|
71
|
+
stat: 42,
|
|
72
|
+
label: 'New Users',
|
|
73
|
+
chip: true,
|
|
74
|
+
chipColor: '#673AB7',
|
|
75
|
+
},
|
|
76
|
+
play: async ({ canvasElement }) => {
|
|
77
|
+
const canvas = within(canvasElement);
|
|
78
|
+
|
|
79
|
+
const stat = canvas.getByTestId('chip-template-option-outlet');
|
|
80
|
+
expect(stat).toBeInTheDocument();
|
|
81
|
+
|
|
82
|
+
expect(canvas.getByText('42')).toBeInTheDocument();
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Chip, Stack, Typography, Box } from '@mui/material';
|
|
3
|
+
|
|
4
|
+
export interface StatChip {
|
|
5
|
+
stat: any;
|
|
6
|
+
chipColor: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface StatProps {
|
|
10
|
+
stat: any; // Replace 'any' with the actual type of 'stat'
|
|
11
|
+
stat2?: any; // Replace 'any' with the actual type of'stat2'
|
|
12
|
+
label: string; // Replace 'any' with the actual type of'label'
|
|
13
|
+
color?: string;
|
|
14
|
+
chipColor?: string;
|
|
15
|
+
chips?: StatChip[]; // Replace 'any' with the actual type of'chips'
|
|
16
|
+
simple?: boolean;
|
|
17
|
+
chip?: boolean;
|
|
18
|
+
chipList?: boolean;
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
statDisplay?: (stat: any) => React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const Stat: React.FC<StatProps> = ({
|
|
24
|
+
stat,
|
|
25
|
+
stat2,
|
|
26
|
+
label,
|
|
27
|
+
color = '#1469B8',
|
|
28
|
+
chipColor = '#1469B8',
|
|
29
|
+
chips = [],
|
|
30
|
+
simple = false,
|
|
31
|
+
chip = false,
|
|
32
|
+
chipList = false,
|
|
33
|
+
children,
|
|
34
|
+
statDisplay,
|
|
35
|
+
}) => {
|
|
36
|
+
const selectedTemplate = useMemo(() => {
|
|
37
|
+
if (simple) return 'simple';
|
|
38
|
+
if (chip) return 'chip';
|
|
39
|
+
if (chipList) return 'chipList';
|
|
40
|
+
return 'default';
|
|
41
|
+
}, [simple, chip, chipList]);
|
|
42
|
+
|
|
43
|
+
const renderStatDisplay = () => {
|
|
44
|
+
return statDisplay ? statDisplay(stat) : stat;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
{selectedTemplate === 'default' && (
|
|
50
|
+
<Box className="stat">
|
|
51
|
+
<Typography variant="h4" data-testid="selection-template-option-outlet">
|
|
52
|
+
{renderStatDisplay()}
|
|
53
|
+
</Typography>
|
|
54
|
+
<Box className="stat__label" display="flex" alignItems="center" gap={1}>
|
|
55
|
+
<Typography variant="body1">{label}</Typography>
|
|
56
|
+
<Box
|
|
57
|
+
width={40}
|
|
58
|
+
height={4}
|
|
59
|
+
bgcolor={color}
|
|
60
|
+
data-testid="stat-border"
|
|
61
|
+
borderRadius={2}
|
|
62
|
+
/>
|
|
63
|
+
</Box>
|
|
64
|
+
</Box>
|
|
65
|
+
)}
|
|
66
|
+
|
|
67
|
+
{selectedTemplate === 'simple' && (
|
|
68
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
69
|
+
<Typography variant="body1">{label}</Typography>
|
|
70
|
+
<Typography variant="h6" data-testid="selection-template-option-outlet">
|
|
71
|
+
{renderStatDisplay()}
|
|
72
|
+
</Typography>
|
|
73
|
+
{stat2 && <Typography>{stat2}</Typography>}
|
|
74
|
+
</Stack>
|
|
75
|
+
)}
|
|
76
|
+
|
|
77
|
+
{selectedTemplate === 'chip' && (
|
|
78
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
79
|
+
<Typography variant="body1">{label}</Typography>
|
|
80
|
+
<Chip
|
|
81
|
+
data-testid="chip-template-option-outlet"
|
|
82
|
+
label={renderStatDisplay()}
|
|
83
|
+
sx={{
|
|
84
|
+
backgroundColor: chipColor,
|
|
85
|
+
color: '#fff',
|
|
86
|
+
fontWeight: 'bold',
|
|
87
|
+
}}
|
|
88
|
+
/>
|
|
89
|
+
</Stack>
|
|
90
|
+
)}
|
|
91
|
+
|
|
92
|
+
{selectedTemplate === 'chipList' && (
|
|
93
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
94
|
+
<Typography variant="body1">{label}</Typography>
|
|
95
|
+
<Stack direction="row" spacing={1}>
|
|
96
|
+
{chips.map((chip, i) => (
|
|
97
|
+
<Chip
|
|
98
|
+
key={i}
|
|
99
|
+
label={chip.stat}
|
|
100
|
+
sx={{
|
|
101
|
+
backgroundColor: chip.chipColor,
|
|
102
|
+
color: '#fff',
|
|
103
|
+
fontWeight: 'bold',
|
|
104
|
+
}}
|
|
105
|
+
/>
|
|
106
|
+
))}
|
|
107
|
+
</Stack>
|
|
108
|
+
</Stack>
|
|
109
|
+
)}
|
|
110
|
+
|
|
111
|
+
{/* Content projection (similar to ng-content) */}
|
|
112
|
+
{children}
|
|
113
|
+
</>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export default Stat;
|