@soyfri/shared-library 1.5.0-beta.4 → 1.5.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/Autocomplete/Autocomplete.cjs +109 -0
- package/dist/components/Autocomplete/Autocomplete.cjs.map +1 -0
- package/dist/components/Autocomplete/Autocomplete.js +109 -0
- package/dist/components/Autocomplete/Autocomplete.js.map +1 -0
- package/dist/styles.css +112 -0
- package/package.json +43 -134
- package/rollup.config.cjs +87 -0
- package/src/components/Autocomplete/Autocomplete.definitions.ts +254 -0
- package/src/components/Autocomplete/Autocomplete.stories.tsx +387 -0
- package/src/components/Autocomplete/Autocomplete.tsx +139 -0
- package/src/components/Autocomplete/index.ts +1 -0
- package/src/components/Avatar/Avatar.stories.tsx +54 -0
- package/src/components/Avatar/Avatar.tsx +143 -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 +32 -0
- package/src/components/Card/Card.tsx +44 -0
- package/src/components/Card/index.ts +1 -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 +205 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +282 -0
- package/src/components/DatePicker/DatePicker.tsx +165 -0
- package/src/components/DatePicker/index.ts +1 -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 +232 -0
- package/src/components/DateTimePicker/DateTimePicker.stories.tsx +390 -0
- package/src/components/DateTimePicker/DateTimePicker.tsx +191 -0
- package/src/components/DateTimePicker/index.ts +1 -0
- package/src/components/Flyout/Flyout.stories.tsx +274 -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 +54 -0
- package/src/components/Icon/Icon.tsx +94 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Input/Input.definitions.ts +252 -0
- package/src/components/Input/Input.stories.tsx +387 -0
- package/src/components/Input/Input.tsx +186 -0
- package/src/components/Input/index.ts +1 -0
- package/src/components/InputGroup/InputGroup.stories.tsx +136 -0
- package/src/components/InputGroup/InputGroup.tsx +136 -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 +293 -0
- package/src/components/Modal/Modal.tsx +173 -0
- package/src/components/Modal/ModalBody.tsx +16 -0
- package/src/components/Modal/ModalFooter.tsx +61 -0
- package/src/components/Modal/ModalHeader.tsx +18 -0
- package/src/components/Modal/index.ts +1 -0
- package/src/components/Select/Select.definitions.ts +488 -0
- package/src/components/Select/Select.stories.tsx +569 -0
- package/src/components/Select/Select.tsx +468 -0
- package/src/components/Select/index.ts +1 -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 +59 -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 +117 -0
- package/src/components/Tooltip/Tooltip.tsx +58 -0
- package/src/components/Tooltip/index.ts +1 -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 +1 -0
- package/src/styles.css +3 -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/components/Autocomplete/Autocomplete.cjs +0 -132
- package/components/Autocomplete/Autocomplete.cjs.map +0 -1
- package/components/Autocomplete/Autocomplete.js +0 -132
- package/components/Autocomplete/Autocomplete.js.map +0 -1
- /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/{DatePicker-BSNboVhN.js → dist/DatePicker-BSNboVhN.js} +0 -0
- /package/{DatePicker-BSNboVhN.js.map → dist/DatePicker-BSNboVhN.js.map} +0 -0
- /package/{DatePicker-BoqxWAhj.cjs → dist/DatePicker-BoqxWAhj.cjs} +0 -0
- /package/{DatePicker-BoqxWAhj.cjs.map → dist/DatePicker-BoqxWAhj.cjs.map} +0 -0
- /package/{Input-DFHs7cJ_.js → dist/Input-DFHs7cJ_.js} +0 -0
- /package/{Input-DFHs7cJ_.js.map → dist/Input-DFHs7cJ_.js.map} +0 -0
- /package/{Input-c8MwNNPg.cjs → dist/Input-c8MwNNPg.cjs} +0 -0
- /package/{Input-c8MwNNPg.cjs.map → dist/Input-c8MwNNPg.cjs.map} +0 -0
- /package/{Select-BO2N56sm.cjs → dist/Select-BO2N56sm.cjs} +0 -0
- /package/{Select-BO2N56sm.cjs.map → dist/Select-BO2N56sm.cjs.map} +0 -0
- /package/{Select-BcLkyHSE.js → dist/Select-BcLkyHSE.js} +0 -0
- /package/{Select-BcLkyHSE.js.map → dist/Select-BcLkyHSE.js.map} +0 -0
- /package/{components → dist/components}/Autocomplete/Autocomplete.d.ts +0 -0
- /package/{components → dist/components}/Autocomplete/Autocomplete.definitions.d.ts +0 -0
- /package/{components → dist/components}/Autocomplete/index.d.ts +0 -0
- /package/{components → dist/components}/Autocomplete.d.ts +0 -0
- /package/{components → dist/components}/Avatar/Avatar.cjs +0 -0
- /package/{components → dist/components}/Avatar/Avatar.cjs.map +0 -0
- /package/{components → dist/components}/Avatar/Avatar.d.ts +0 -0
- /package/{components → dist/components}/Avatar/Avatar.js +0 -0
- /package/{components → dist/components}/Avatar/Avatar.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.cjs +0 -0
- /package/{components → dist/components}/Card/Card.cjs.map +0 -0
- /package/{components → dist/components}/Card/Card.d.ts +0 -0
- /package/{components → dist/components}/Card/Card.definition.d.ts +0 -0
- /package/{components → dist/components}/Card/Card.js +0 -0
- /package/{components → dist/components}/Card/Card.js.map +0 -0
- /package/{components → dist/components}/Card/index.d.ts +0 -0
- /package/{components → dist/components}/Card.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}/DatePicker/DatePicker.cjs +0 -0
- /package/{components → dist/components}/DatePicker/DatePicker.cjs.map +0 -0
- /package/{components → dist/components}/DatePicker/DatePicker.d.ts +0 -0
- /package/{components → dist/components}/DatePicker/DatePicker.definitions.d.ts +0 -0
- /package/{components → dist/components}/DatePicker/DatePicker.js +0 -0
- /package/{components → dist/components}/DatePicker/DatePicker.js.map +0 -0
- /package/{components → dist/components}/DatePicker/index.d.ts +0 -0
- /package/{components → dist/components}/DatePicker.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}/DateTimePicker/DateTimePicker.cjs +0 -0
- /package/{components → dist/components}/DateTimePicker/DateTimePicker.cjs.map +0 -0
- /package/{components → dist/components}/DateTimePicker/DateTimePicker.d.ts +0 -0
- /package/{components → dist/components}/DateTimePicker/DateTimePicker.definitions.d.ts +0 -0
- /package/{components → dist/components}/DateTimePicker/DateTimePicker.js +0 -0
- /package/{components → dist/components}/DateTimePicker/DateTimePicker.js.map +0 -0
- /package/{components → dist/components}/DateTimePicker/index.d.ts +0 -0
- /package/{components → dist/components}/DateTimePicker.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/Icon.cjs +0 -0
- /package/{components → dist/components}/Icon/Icon.cjs.map +0 -0
- /package/{components → dist/components}/Icon/Icon.d.ts +0 -0
- /package/{components → dist/components}/Icon/Icon.js +0 -0
- /package/{components → dist/components}/Icon/Icon.js.map +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}/Input/Input.cjs +0 -0
- /package/{components → dist/components}/Input/Input.cjs.map +0 -0
- /package/{components → dist/components}/Input/Input.d.ts +0 -0
- /package/{components → dist/components}/Input/Input.definitions.d.ts +0 -0
- /package/{components → dist/components}/Input/Input.js +0 -0
- /package/{components → dist/components}/Input/Input.js.map +0 -0
- /package/{components → dist/components}/Input/index.d.ts +0 -0
- /package/{components → dist/components}/Input.d.ts +0 -0
- /package/{components → dist/components}/InputGroup/InputGroup.cjs +0 -0
- /package/{components → dist/components}/InputGroup/InputGroup.cjs.map +0 -0
- /package/{components → dist/components}/InputGroup/InputGroup.d.ts +0 -0
- /package/{components → dist/components}/InputGroup/InputGroup.js +0 -0
- /package/{components → dist/components}/InputGroup/InputGroup.js.map +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/Modal.cjs +0 -0
- /package/{components → dist/components}/Modal/Modal.cjs.map +0 -0
- /package/{components → dist/components}/Modal/Modal.d.ts +0 -0
- /package/{components → dist/components}/Modal/Modal.js +0 -0
- /package/{components → dist/components}/Modal/Modal.js.map +0 -0
- /package/{components → dist/components}/Modal/ModalBody.d.ts +0 -0
- /package/{components → dist/components}/Modal/ModalFooter.d.ts +0 -0
- /package/{components → dist/components}/Modal/ModalHeader.d.ts +0 -0
- /package/{components → dist/components}/Modal/index.d.ts +0 -0
- /package/{components → dist/components}/Modal.d.ts +0 -0
- /package/{components → dist/components}/Select/Select.cjs +0 -0
- /package/{components → dist/components}/Select/Select.cjs.map +0 -0
- /package/{components → dist/components}/Select/Select.d.ts +0 -0
- /package/{components → dist/components}/Select/Select.definitions.d.ts +0 -0
- /package/{components → dist/components}/Select/Select.js +0 -0
- /package/{components → dist/components}/Select/Select.js.map +0 -0
- /package/{components → dist/components}/Select/index.d.ts +0 -0
- /package/{components → dist/components}/Select.d.ts +0 -0
- /package/{components → dist/components}/Stat/Stat.cjs +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 +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.cjs +0 -0
- /package/{components → dist/components}/Stepper/Stepper.cjs.map +0 -0
- /package/{components → dist/components}/Stepper/Stepper.d.ts +0 -0
- /package/{components → dist/components}/Stepper/Stepper.definition.d.ts +0 -0
- /package/{components → dist/components}/Stepper/Stepper.js +0 -0
- /package/{components → dist/components}/Stepper/Stepper.js.map +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.cjs → dist/index.cjs} +0 -0
- /package/{index.cjs.map → dist/index.cjs.map} +0 -0
- /package/{index.css → dist/index.css} +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{index.js.map → dist/index.js.map} +0 -0
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
import React, { ReactElement, useMemo, useState, Children, isValidElement, useEffect, useRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
FormControl,
|
|
4
|
+
InputLabel,
|
|
5
|
+
MenuItem,
|
|
6
|
+
Select as MuiSelect,
|
|
7
|
+
Chip,
|
|
8
|
+
Avatar,
|
|
9
|
+
Box,
|
|
10
|
+
Typography,
|
|
11
|
+
OutlinedInput,
|
|
12
|
+
TextField,
|
|
13
|
+
ListSubheader,
|
|
14
|
+
CircularProgress,
|
|
15
|
+
ListItemIcon,
|
|
16
|
+
SelectChangeEvent,
|
|
17
|
+
} from '@mui/material';
|
|
18
|
+
import { styled } from '@mui/system';
|
|
19
|
+
import ClearIcon from '@mui/icons-material/Clear';
|
|
20
|
+
import CheckIcon from '@mui/icons-material/Check';
|
|
21
|
+
import { Controller, Control, RegisterOptions } from 'react-hook-form';
|
|
22
|
+
|
|
23
|
+
export interface SelectOption {
|
|
24
|
+
value: string | number;
|
|
25
|
+
label: string;
|
|
26
|
+
img?: string;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
group?: string;
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type RenderOptionItem = (item: SelectOption) => React.ReactNode;
|
|
33
|
+
type RenderChipLabel = (item: SelectOption) => React.ReactNode;
|
|
34
|
+
|
|
35
|
+
// --- Definición de Props con Union Type ---
|
|
36
|
+
|
|
37
|
+
// Props comunes para ambos modos
|
|
38
|
+
interface BaseSelectProps<TValue extends SelectOption['value'] = SelectOption['value']> {
|
|
39
|
+
label?: string;
|
|
40
|
+
options?: SelectOption[];
|
|
41
|
+
defaultValue?: TValue | TValue[];
|
|
42
|
+
size?: 'small' | 'medium';
|
|
43
|
+
multiple?: boolean;
|
|
44
|
+
filterable?: boolean;
|
|
45
|
+
placeholder?: string;
|
|
46
|
+
children?: ReactElement<{ children: RenderOptionItem }>;
|
|
47
|
+
maxHeight?: number | string;
|
|
48
|
+
maxWidth?: number | string;
|
|
49
|
+
maxChipsToShow?: number;
|
|
50
|
+
renderChipLabel?: RenderChipLabel;
|
|
51
|
+
chipVariant?: 'outlined' | 'filled';
|
|
52
|
+
loadOptions?: (inputValue: string) => Promise<SelectOption[]>;
|
|
53
|
+
loadingMessage?: React.ReactNode;
|
|
54
|
+
noOptionsMessage?: React.ReactNode;
|
|
55
|
+
debounceTimeout?: number;
|
|
56
|
+
disabled?: boolean;
|
|
57
|
+
error?: boolean;
|
|
58
|
+
helperText?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Props para el modo React Hook Form
|
|
62
|
+
interface RHFSelectProps<TValue extends SelectOption['value'] = SelectOption['value']> extends BaseSelectProps<TValue> {
|
|
63
|
+
name: string;
|
|
64
|
+
control: Control<any>;
|
|
65
|
+
validation?: RegisterOptions;
|
|
66
|
+
value?: TValue | TValue[];
|
|
67
|
+
onChange?: (val: TValue | TValue[]) => void;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Props para el modo controlado estándar
|
|
71
|
+
interface StandardSelectProps<TValue extends SelectOption['value'] = SelectOption['value']> extends BaseSelectProps<TValue> {
|
|
72
|
+
name?: string;
|
|
73
|
+
control?: never;
|
|
74
|
+
validation?: never;
|
|
75
|
+
value: TValue | TValue[];
|
|
76
|
+
onChange: (val: TValue | TValue[]) => void;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type SelectProps<TValue extends SelectOption['value'] = SelectOption['value']> = RHFSelectProps<TValue> | StandardSelectProps<TValue>;
|
|
80
|
+
|
|
81
|
+
export interface OptionProps {
|
|
82
|
+
children: RenderOptionItem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function Option(_props: OptionProps) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
Option.displayName = 'Option';
|
|
89
|
+
|
|
90
|
+
const StyledSelect = styled(MuiSelect)(({ theme }) => ({
|
|
91
|
+
'& .MuiInputBase-root': {
|
|
92
|
+
maxHeight: '4px',
|
|
93
|
+
padding: '8px 10px',
|
|
94
|
+
borderRadius: '10px',
|
|
95
|
+
display: 'flex',
|
|
96
|
+
alignItems: 'center',
|
|
97
|
+
fontSize: '14px',
|
|
98
|
+
},
|
|
99
|
+
'& .MuiSelect-select': {
|
|
100
|
+
padding: '0 !important',
|
|
101
|
+
height: '28px !important',
|
|
102
|
+
display: 'flex',
|
|
103
|
+
alignItems: 'center',
|
|
104
|
+
marginLeft: '8px'
|
|
105
|
+
},
|
|
106
|
+
'& .MuiOutlinedInput-notchedOutline': {
|
|
107
|
+
marginBottom: '-4px !important',
|
|
108
|
+
borderRadius: '10px',
|
|
109
|
+
},
|
|
110
|
+
'& .MuiSelect-icon': {
|
|
111
|
+
top: '50%',
|
|
112
|
+
transform: 'translateY(-50%)',
|
|
113
|
+
},
|
|
114
|
+
'& .MuiOutlinedInput-notchedOutline > legend':{
|
|
115
|
+
display: 'none',
|
|
116
|
+
},
|
|
117
|
+
}));
|
|
118
|
+
|
|
119
|
+
const StyledLabel = styled(InputLabel)(({theme}) =>({
|
|
120
|
+
'&.MuiInputLabel-root': {
|
|
121
|
+
top: '50%',
|
|
122
|
+
transform: 'translate(14px, -50%)',
|
|
123
|
+
},
|
|
124
|
+
'&.MuiInputLabel-shrink': {
|
|
125
|
+
transform: 'translate(1px, -200%) scale(0.75)',
|
|
126
|
+
fontSize: '16px',
|
|
127
|
+
'> legend': {
|
|
128
|
+
display: 'none',
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
'&.MuiInputLabel-animated': {
|
|
132
|
+
'&.MuiInputLabel-shrink': {
|
|
133
|
+
display: 'block'
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}));
|
|
137
|
+
|
|
138
|
+
const StyledOutlinedInput = styled(OutlinedInput)(({ theme }) => ({
|
|
139
|
+
'& .MuiInputBase-root': {
|
|
140
|
+
maxHeight: '34px',
|
|
141
|
+
padding: '8px 10px',
|
|
142
|
+
borderRadius: '10px',
|
|
143
|
+
display: 'flex',
|
|
144
|
+
alignItems: 'center',
|
|
145
|
+
fontSize: '14px',
|
|
146
|
+
' & > .MuiAvatar-img': {
|
|
147
|
+
width: '14px',
|
|
148
|
+
height: '14px',
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
'& .MuiInputBase-input': {
|
|
152
|
+
padding: '0 !important',
|
|
153
|
+
height: '18px',
|
|
154
|
+
display: 'flex',
|
|
155
|
+
alignItems: 'center',
|
|
156
|
+
},
|
|
157
|
+
'& .MuiOutlinedInput-notchedOutline': {
|
|
158
|
+
border: '0.7px solid',
|
|
159
|
+
borderColor: '#e0e0e0',
|
|
160
|
+
},
|
|
161
|
+
}));
|
|
162
|
+
|
|
163
|
+
export function Select<TValue extends SelectOption['value'] = SelectOption['value']>(props: SelectProps<TValue>) {
|
|
164
|
+
const {
|
|
165
|
+
label,
|
|
166
|
+
options = [],
|
|
167
|
+
value,
|
|
168
|
+
onChange,
|
|
169
|
+
defaultValue,
|
|
170
|
+
size = 'medium',
|
|
171
|
+
multiple = false,
|
|
172
|
+
filterable = false,
|
|
173
|
+
placeholder,
|
|
174
|
+
children,
|
|
175
|
+
maxHeight = 300,
|
|
176
|
+
maxWidth,
|
|
177
|
+
maxChipsToShow = 3,
|
|
178
|
+
renderChipLabel,
|
|
179
|
+
chipVariant = 'outlined',
|
|
180
|
+
loadOptions,
|
|
181
|
+
loadingMessage = 'Cargando opciones...',
|
|
182
|
+
noOptionsMessage = 'No hay opciones',
|
|
183
|
+
debounceTimeout = 300,
|
|
184
|
+
disabled = false,
|
|
185
|
+
error = false,
|
|
186
|
+
helperText,
|
|
187
|
+
...rest
|
|
188
|
+
} = props;
|
|
189
|
+
|
|
190
|
+
const isRHFMode = 'control' in rest && rest.control !== undefined;
|
|
191
|
+
|
|
192
|
+
const customRender: RenderOptionItem | null = useMemo(() => {
|
|
193
|
+
if (React.Children.count(children) === 1) {
|
|
194
|
+
const child = React.Children.only(children);
|
|
195
|
+
if (isValidElement(child) && (child.type as any)?.displayName === 'Option') {
|
|
196
|
+
return (child.props as OptionProps).children;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
}, [children]);
|
|
201
|
+
|
|
202
|
+
const [search, setSearch] = useState('');
|
|
203
|
+
const [asyncOptions, setAsyncOptions] = useState<SelectOption[]>([]);
|
|
204
|
+
const [loading, setLoading] = useState(false);
|
|
205
|
+
const debounceTimerRef = useRef<number | null>(null);
|
|
206
|
+
|
|
207
|
+
const searchInputRef = useRef<HTMLInputElement>(null);
|
|
208
|
+
|
|
209
|
+
const isAsync = typeof loadOptions === 'function';
|
|
210
|
+
const currentOptions = isAsync ? asyncOptions : options;
|
|
211
|
+
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
if (isAsync) {
|
|
214
|
+
if (debounceTimerRef.current) {
|
|
215
|
+
clearTimeout(debounceTimerRef.current);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (search) {
|
|
219
|
+
setLoading(true);
|
|
220
|
+
debounceTimerRef.current = window.setTimeout(() => {
|
|
221
|
+
loadOptions(search)
|
|
222
|
+
.then(loadedOpts => {
|
|
223
|
+
setAsyncOptions(loadedOpts);
|
|
224
|
+
})
|
|
225
|
+
.finally(() => {
|
|
226
|
+
setLoading(false);
|
|
227
|
+
if (searchInputRef.current) {
|
|
228
|
+
searchInputRef.current.focus();
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}, debounceTimeout);
|
|
232
|
+
} else {
|
|
233
|
+
setAsyncOptions([]);
|
|
234
|
+
setLoading(false);
|
|
235
|
+
if (searchInputRef.current) {
|
|
236
|
+
searchInputRef.current.focus();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}, [search, isAsync, loadOptions, debounceTimeout]);
|
|
241
|
+
|
|
242
|
+
const filteredOptions = useMemo(() => {
|
|
243
|
+
if (isAsync) {
|
|
244
|
+
return currentOptions;
|
|
245
|
+
}
|
|
246
|
+
if (!filterable || !search) return currentOptions;
|
|
247
|
+
return currentOptions.filter(opt =>
|
|
248
|
+
opt.label.toLowerCase().includes(search.toLowerCase())
|
|
249
|
+
);
|
|
250
|
+
}, [search, filterable, currentOptions, isAsync]);
|
|
251
|
+
|
|
252
|
+
const groupedOptions = useMemo(() => {
|
|
253
|
+
const groups: Record<string, SelectOption[]> = {};
|
|
254
|
+
filteredOptions.forEach(opt => {
|
|
255
|
+
const group = opt.group || '__default';
|
|
256
|
+
if (!groups[group]) groups[group] = [];
|
|
257
|
+
groups[group].push(opt);
|
|
258
|
+
});
|
|
259
|
+
return groups;
|
|
260
|
+
}, [filteredOptions]);
|
|
261
|
+
|
|
262
|
+
const renderValue = (selected: any) => {
|
|
263
|
+
if (!selected || (Array.isArray(selected) && selected.length === 0)) {
|
|
264
|
+
return <Typography sx={{ color: 'text.disabled' }}>{placeholder || ''}</Typography>;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (!multiple) {
|
|
268
|
+
const item = currentOptions.find((opt) => opt.value === selected);
|
|
269
|
+
return renderChipLabel && item ? renderChipLabel(item) : (item?.label ?? String(selected));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const selectedValuesArray = selected as TValue[];
|
|
273
|
+
const displayedChips = selectedValuesArray.slice(0, maxChipsToShow);
|
|
274
|
+
const hiddenChipsCount = selectedValuesArray.length - maxChipsToShow;
|
|
275
|
+
|
|
276
|
+
return (
|
|
277
|
+
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.5 }}>
|
|
278
|
+
{displayedChips.map((val) => {
|
|
279
|
+
const item = currentOptions.find((o) => o.value === val);
|
|
280
|
+
if (!item) return null;
|
|
281
|
+
|
|
282
|
+
const handleDelete = (chipValue: TValue) => {
|
|
283
|
+
const newSelected = (value as TValue[]).filter(v => v !== chipValue);
|
|
284
|
+
(onChange as (val: TValue | TValue[]) => void)?.(newSelected);
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
return (
|
|
288
|
+
<Chip
|
|
289
|
+
variant={chipVariant}
|
|
290
|
+
color="primary"
|
|
291
|
+
key={val}
|
|
292
|
+
label={renderChipLabel ? renderChipLabel(item) : item.label}
|
|
293
|
+
avatar={item.img ?
|
|
294
|
+
<Avatar
|
|
295
|
+
sx={
|
|
296
|
+
{
|
|
297
|
+
'& > .MuiAvatar-root, .MuiChip-avatar': {
|
|
298
|
+
backgroundColor: 'red',
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
src={item.img}
|
|
303
|
+
/> : undefined}
|
|
304
|
+
onDelete={() => handleDelete(val)}
|
|
305
|
+
deleteIcon={<ClearIcon sx={{ fontSize: '12px !important' }} />}
|
|
306
|
+
sx={
|
|
307
|
+
{
|
|
308
|
+
height: '27px',
|
|
309
|
+
marginTop: '1px',
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/>
|
|
313
|
+
);
|
|
314
|
+
})}
|
|
315
|
+
{hiddenChipsCount > 0 && (
|
|
316
|
+
<Chip
|
|
317
|
+
sx={{
|
|
318
|
+
height: '27px',
|
|
319
|
+
marginTop: '0px',
|
|
320
|
+
}}
|
|
321
|
+
label={`+${hiddenChipsCount} más`} variant={chipVariant} />
|
|
322
|
+
)}
|
|
323
|
+
</Box>
|
|
324
|
+
);
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
const menuItems = useMemo(() => {
|
|
328
|
+
const items: React.ReactNode[] = [];
|
|
329
|
+
|
|
330
|
+
if (filterable || isAsync) {
|
|
331
|
+
items.push(
|
|
332
|
+
<ListSubheader key="search-header" sx={{ px: 2, pt: 1, pb: 1, backgroundColor: 'background.paper', zIndex: 1, position: 'sticky', top: 0 }}>
|
|
333
|
+
<TextField
|
|
334
|
+
inputRef={searchInputRef}
|
|
335
|
+
placeholder="Buscar..."
|
|
336
|
+
variant="standard"
|
|
337
|
+
size="small"
|
|
338
|
+
fullWidth
|
|
339
|
+
value={search}
|
|
340
|
+
onChange={(e) => setSearch(e.target.value)}
|
|
341
|
+
inputProps={{ autoFocus: true }}
|
|
342
|
+
onClick={(e) => e.stopPropagation()}
|
|
343
|
+
onKeyDown={(e) => e.stopPropagation()}
|
|
344
|
+
/>
|
|
345
|
+
</ListSubheader>
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (loading) {
|
|
350
|
+
items.push(
|
|
351
|
+
<MenuItem key="loading-message" disabled>
|
|
352
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
353
|
+
<CircularProgress size={20} />
|
|
354
|
+
<Typography>{loadingMessage}</Typography>
|
|
355
|
+
</Box>
|
|
356
|
+
</MenuItem>
|
|
357
|
+
);
|
|
358
|
+
} else if (Object.keys(groupedOptions).length === 0 || (Object.keys(groupedOptions).length === 1 && groupedOptions['__default'] && groupedOptions['__default'].length === 0)) {
|
|
359
|
+
items.push(
|
|
360
|
+
<MenuItem key="no-options-message" disabled>
|
|
361
|
+
<Typography>{noOptionsMessage}</Typography>
|
|
362
|
+
</MenuItem>
|
|
363
|
+
);
|
|
364
|
+
} else {
|
|
365
|
+
Object.entries(groupedOptions).forEach(([group, opts]) => {
|
|
366
|
+
if (group !== '__default') {
|
|
367
|
+
items.push(
|
|
368
|
+
<ListSubheader key={group} disableSticky>{group}</ListSubheader>
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
opts.forEach((opt) => {
|
|
372
|
+
const isSelected = multiple
|
|
373
|
+
? (value as TValue[] | undefined)?.includes(opt.value as TValue)
|
|
374
|
+
: value === opt.value;
|
|
375
|
+
|
|
376
|
+
items.push(
|
|
377
|
+
<MenuItem key={opt.value} value={opt.value} disabled={opt.disabled} selected={isSelected}>
|
|
378
|
+
<ListItemIcon sx={{ minWidth: 32 }}>
|
|
379
|
+
{isSelected && (
|
|
380
|
+
<CheckIcon sx={{ color: 'green' }} />
|
|
381
|
+
)}
|
|
382
|
+
</ListItemIcon>
|
|
383
|
+
{customRender ? customRender(opt) : opt.label}
|
|
384
|
+
</MenuItem>
|
|
385
|
+
);
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
return items;
|
|
390
|
+
}, [groupedOptions, customRender, filterable, isAsync, search, loading, loadingMessage, noOptionsMessage, multiple, value]);
|
|
391
|
+
|
|
392
|
+
const showLabel = label && !placeholder;
|
|
393
|
+
|
|
394
|
+
// Lógica para manejar el cambio de valor
|
|
395
|
+
const handleChangeInternal = (event: SelectChangeEvent<any>, rhfOnChange?: (...event: any[]) => void) => {
|
|
396
|
+
const newValue = event.target.value;
|
|
397
|
+
if (isRHFMode) {
|
|
398
|
+
rhfOnChange?.(newValue);
|
|
399
|
+
} else {
|
|
400
|
+
(onChange as (val: TValue | TValue[]) => void)?.(newValue);
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
// Renderizado condicional basado en el modo
|
|
405
|
+
const isRHFModeRender = 'control' in rest && rest.control !== undefined;
|
|
406
|
+
|
|
407
|
+
const renderSelect = (selectValue: any, selectOnChange: any, onBlur?: any, inputRef?: any) => (
|
|
408
|
+
<FormControl fullWidth size={size} error={error} disabled={disabled}>
|
|
409
|
+
{showLabel && <StyledLabel>{label}</StyledLabel>}
|
|
410
|
+
<Box
|
|
411
|
+
sx={{
|
|
412
|
+
width: '100%',
|
|
413
|
+
display: 'grid',
|
|
414
|
+
marginBottom: '10px',
|
|
415
|
+
marginTop: '10px'
|
|
416
|
+
}}>
|
|
417
|
+
<StyledSelect
|
|
418
|
+
label={label}
|
|
419
|
+
value={selectValue ?? (multiple ? [] : '')}
|
|
420
|
+
defaultValue={defaultValue}
|
|
421
|
+
multiple={multiple}
|
|
422
|
+
onChange={selectOnChange}
|
|
423
|
+
onBlur={onBlur}
|
|
424
|
+
renderValue={renderValue}
|
|
425
|
+
displayEmpty
|
|
426
|
+
input={<StyledOutlinedInput label={label} />}
|
|
427
|
+
disabled={disabled}
|
|
428
|
+
MenuProps={{
|
|
429
|
+
PaperProps: {
|
|
430
|
+
style: {
|
|
431
|
+
maxHeight: maxHeight,
|
|
432
|
+
maxWidth: maxWidth,
|
|
433
|
+
},
|
|
434
|
+
},
|
|
435
|
+
}}
|
|
436
|
+
inputRef={inputRef}
|
|
437
|
+
{...rest}
|
|
438
|
+
>
|
|
439
|
+
{menuItems}
|
|
440
|
+
</StyledSelect>
|
|
441
|
+
{helperText && <Typography variant="caption" color="error" sx={{ mt: 1 }}>{helperText}</Typography>}
|
|
442
|
+
</Box>
|
|
443
|
+
</FormControl>
|
|
444
|
+
);
|
|
445
|
+
|
|
446
|
+
if (isRHFModeRender) {
|
|
447
|
+
const rhfProps = rest as RHFSelectProps<TValue>;
|
|
448
|
+
return (
|
|
449
|
+
<Controller
|
|
450
|
+
name={rhfProps.name}
|
|
451
|
+
control={rhfProps.control}
|
|
452
|
+
rules={rhfProps.validation}
|
|
453
|
+
render={({ field, fieldState: { error } }) => (
|
|
454
|
+
renderSelect(
|
|
455
|
+
field.value,
|
|
456
|
+
(e: SelectChangeEvent<any>) => handleChangeInternal(e, field.onChange),
|
|
457
|
+
field.onBlur,
|
|
458
|
+
field.ref
|
|
459
|
+
)
|
|
460
|
+
)}
|
|
461
|
+
/>
|
|
462
|
+
);
|
|
463
|
+
} else {
|
|
464
|
+
return renderSelect(value, (e: SelectChangeEvent<any>) => handleChangeInternal(e));
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export default Select;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Select, Option } from './Select'
|
|
@@ -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) : <Typography variant="h6">{stat}</Typography>;
|
|
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 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;
|