@soyfri/shared-library 1.5.0-beta.3 → 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/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/{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.cjs +0 -0
- /package/{components → dist/components}/Autocomplete/Autocomplete.cjs.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/Autocomplete.js +0 -0
- /package/{components → dist/components}/Autocomplete/Autocomplete.js.map +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,387 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
Box,
|
|
5
|
+
Typography,
|
|
6
|
+
} from '@mui/material';
|
|
7
|
+
|
|
8
|
+
// Importa el componente Input (asumiendo que está en el mismo directorio o ruta definida)
|
|
9
|
+
import { Input } from './Input';
|
|
10
|
+
|
|
11
|
+
// Importa las definiciones de las historias
|
|
12
|
+
import {
|
|
13
|
+
BasicTextInputDefinition,
|
|
14
|
+
NumberInputDefinition,
|
|
15
|
+
EmailInputDefinition,
|
|
16
|
+
PasswordInputDefinition,
|
|
17
|
+
InputWithPlaceholderDefinition,
|
|
18
|
+
InputWithErrorDefinition,
|
|
19
|
+
DisabledInputDefinition,
|
|
20
|
+
ReadOnlyInputDefinition,
|
|
21
|
+
InputVariantsDefinition,
|
|
22
|
+
InputSizesDefinition,
|
|
23
|
+
FullWidthInputDefinition,
|
|
24
|
+
} from './Input.definitions';
|
|
25
|
+
|
|
26
|
+
// =============================================================================
|
|
27
|
+
// Definición de las meta-propiedades para Storybook
|
|
28
|
+
// =============================================================================
|
|
29
|
+
const meta: Meta<typeof Input> = {
|
|
30
|
+
title: 'Components/Input',
|
|
31
|
+
component: Input,
|
|
32
|
+
tags: ['autodocs'],
|
|
33
|
+
parameters: {
|
|
34
|
+
layout: 'centered',
|
|
35
|
+
docs: {
|
|
36
|
+
description: {
|
|
37
|
+
component: 'Un componente `Input` personalizado basado en `TextField` de Material UI, que soporta varios tipos de entrada HTML y propiedades de `TextField`.',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
argTypes: {
|
|
42
|
+
label: { control: 'text', description: 'Etiqueta flotante para el campo de entrada.' },
|
|
43
|
+
value: { control: 'text', description: 'El valor actual del campo de entrada.', type: { name: 'string', required: true } },
|
|
44
|
+
onChange: { action: 'valueChanged', description: 'Callback que se dispara cuando el valor del campo de entrada cambia.' },
|
|
45
|
+
type: {
|
|
46
|
+
control: 'select',
|
|
47
|
+
options: ['text', 'number', 'email', 'password', 'tel', 'url', 'search', 'date', 'datetime-local', 'month', 'week', 'time', 'color'],
|
|
48
|
+
description: 'El tipo HTML del campo de entrada (controla el teclado en móviles, etc.).',
|
|
49
|
+
defaultValue: 'text',
|
|
50
|
+
},
|
|
51
|
+
placeholder: { control: 'text', description: 'Texto de marcador de posición cuando el campo está vacío.' },
|
|
52
|
+
disabled: { control: 'boolean', description: 'Si es verdadero, el campo de entrada estará deshabilitado.' },
|
|
53
|
+
// readOnly: { control: 'boolean', description: 'Si es verdadero, el campo de entrada estará en modo de solo lectura.' },
|
|
54
|
+
error: { control: 'boolean', description: 'Si es verdadero, el campo de entrada estará en estado de error.' },
|
|
55
|
+
helperText: { control: 'text', description: 'Texto auxiliar que se muestra debajo del campo de entrada.' },
|
|
56
|
+
variant: {
|
|
57
|
+
control: 'radio',
|
|
58
|
+
options: ['outlined', 'filled', 'standard'],
|
|
59
|
+
description: 'La variante de diseño del campo de entrada.',
|
|
60
|
+
defaultValue: 'outlined',
|
|
61
|
+
},
|
|
62
|
+
size: {
|
|
63
|
+
control: 'radio',
|
|
64
|
+
options: ['small', 'medium'],
|
|
65
|
+
description: 'El tamaño del campo de entrada.',
|
|
66
|
+
defaultValue: 'medium',
|
|
67
|
+
},
|
|
68
|
+
fullWidth: { control: 'boolean', description: 'Si es verdadero, el campo de entrada ocupará todo el ancho disponible.', defaultValue: false },
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default meta;
|
|
73
|
+
type Story = StoryObj<typeof Input>;
|
|
74
|
+
|
|
75
|
+
// =============================================================================
|
|
76
|
+
// Historias
|
|
77
|
+
// =============================================================================
|
|
78
|
+
|
|
79
|
+
export const BasicTextInput: Story = {
|
|
80
|
+
render: () => {
|
|
81
|
+
const [value, setValue] = useState('Texto de ejemplo');
|
|
82
|
+
return (
|
|
83
|
+
<Box sx={{ width: 300 }}>
|
|
84
|
+
<Input
|
|
85
|
+
label="Nombre"
|
|
86
|
+
value={value}
|
|
87
|
+
onChange={(value) => setValue(value.toString())}
|
|
88
|
+
/>
|
|
89
|
+
<Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>
|
|
90
|
+
</Box>
|
|
91
|
+
);
|
|
92
|
+
},
|
|
93
|
+
parameters: {
|
|
94
|
+
docs: {
|
|
95
|
+
description: {
|
|
96
|
+
story: "Un campo de entrada de texto básico con una etiqueta."
|
|
97
|
+
},
|
|
98
|
+
source: { code: BasicTextInputDefinition.trim() }
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const NumberInput: Story = {
|
|
104
|
+
render: () => {
|
|
105
|
+
const [value, setValue] = useState(123);
|
|
106
|
+
return (
|
|
107
|
+
<Box sx={{ width: 300 }}>
|
|
108
|
+
<Input
|
|
109
|
+
label="Cantidad"
|
|
110
|
+
type="number"
|
|
111
|
+
value={value.toString()}
|
|
112
|
+
onChange={(value) => setValue(Number(value))}
|
|
113
|
+
/>
|
|
114
|
+
<Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>
|
|
115
|
+
</Box>
|
|
116
|
+
);
|
|
117
|
+
},
|
|
118
|
+
parameters: {
|
|
119
|
+
docs: {
|
|
120
|
+
description: {
|
|
121
|
+
story: "Un campo de entrada numérico. Permite solo números y controla el teclado numérico en dispositivos móviles."
|
|
122
|
+
},
|
|
123
|
+
source: { code: NumberInputDefinition.trim() }
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const EmailInput: Story = {
|
|
129
|
+
render: () => {
|
|
130
|
+
const [value, setValue] = useState('ejemplo@dominio.com');
|
|
131
|
+
return (
|
|
132
|
+
<Box sx={{ width: 300 }}>
|
|
133
|
+
<Input
|
|
134
|
+
label="Correo Electrónico"
|
|
135
|
+
type="email"
|
|
136
|
+
value={value.toString()}
|
|
137
|
+
onChange={(value) => setValue(value.toString())}
|
|
138
|
+
/>
|
|
139
|
+
<Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>
|
|
140
|
+
</Box>
|
|
141
|
+
);
|
|
142
|
+
},
|
|
143
|
+
parameters: {
|
|
144
|
+
docs: {
|
|
145
|
+
description: {
|
|
146
|
+
story: "Un campo de entrada para correo electrónico. Proporciona validación básica del navegador y sugiere correos electrónicos."
|
|
147
|
+
},
|
|
148
|
+
source: { code: EmailInputDefinition.trim() }
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const PasswordInput: Story = {
|
|
154
|
+
render: () => {
|
|
155
|
+
const [value, setValue] = useState('micontraseña');
|
|
156
|
+
return (
|
|
157
|
+
<Box sx={{ width: 300 }}>
|
|
158
|
+
<Input
|
|
159
|
+
label="Contraseña"
|
|
160
|
+
type="password"
|
|
161
|
+
value={value.toString()}
|
|
162
|
+
onChange={(value) => setValue(value.toString())}
|
|
163
|
+
/>
|
|
164
|
+
<Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>
|
|
165
|
+
</Box>
|
|
166
|
+
);
|
|
167
|
+
},
|
|
168
|
+
parameters: {
|
|
169
|
+
docs: {
|
|
170
|
+
description: {
|
|
171
|
+
story: "Un campo de entrada de contraseña. Oculta los caracteres a medida que se escriben."
|
|
172
|
+
},
|
|
173
|
+
source: { code: PasswordInputDefinition.trim() }
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export const InputWithPlaceholder: Story = {
|
|
179
|
+
render: () => {
|
|
180
|
+
const [value, setValue] = useState('');
|
|
181
|
+
return (
|
|
182
|
+
<Box sx={{ width: 300 }}>
|
|
183
|
+
<Input
|
|
184
|
+
label="Búsqueda"
|
|
185
|
+
placeholder="Escribe tu término de búsqueda..."
|
|
186
|
+
value={value.toString()}
|
|
187
|
+
onChange={(value) => setValue(value.toString())}
|
|
188
|
+
/>
|
|
189
|
+
<Typography sx={{ mt: 2 }}>Valor actual: {value || 'Vacío'}</Typography>
|
|
190
|
+
</Box>
|
|
191
|
+
);
|
|
192
|
+
},
|
|
193
|
+
parameters: {
|
|
194
|
+
docs: {
|
|
195
|
+
description: {
|
|
196
|
+
story: "Un campo de entrada con un texto de marcador de posición visible cuando el campo está vacío."
|
|
197
|
+
},
|
|
198
|
+
source: { code: InputWithPlaceholderDefinition.trim() }
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export const InputWithError: Story = {
|
|
204
|
+
render: () => {
|
|
205
|
+
const [value, setValue] = useState('invalido');
|
|
206
|
+
// Lógica simple de error para la demostración
|
|
207
|
+
const hasError = value.length < 5 && value.length > 0;
|
|
208
|
+
return (
|
|
209
|
+
<Box sx={{ width: 300 }}>
|
|
210
|
+
<Input
|
|
211
|
+
label="Nombre de usuario"
|
|
212
|
+
value={value.toString()}
|
|
213
|
+
onChange={(value) => setValue(value.toString())}
|
|
214
|
+
error={hasError}
|
|
215
|
+
helperText={hasError ? 'Mínimo 5 caracteres' : ''}
|
|
216
|
+
/>
|
|
217
|
+
<Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>
|
|
218
|
+
</Box>
|
|
219
|
+
);
|
|
220
|
+
},
|
|
221
|
+
parameters: {
|
|
222
|
+
docs: {
|
|
223
|
+
description: {
|
|
224
|
+
story: "Un campo de entrada que muestra un estado de error y un texto de ayuda cuando la validación falla."
|
|
225
|
+
},
|
|
226
|
+
source: { code: InputWithErrorDefinition.trim() }
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export const DisabledInput: Story = {
|
|
232
|
+
render: () => {
|
|
233
|
+
const [value, setValue] = useState('Campo deshabilitado');
|
|
234
|
+
return (
|
|
235
|
+
<Box sx={{ width: 300 }}>
|
|
236
|
+
<Input
|
|
237
|
+
label="Estado"
|
|
238
|
+
value={value.toString()}
|
|
239
|
+
onChange={(value) => setValue(value.toString())}
|
|
240
|
+
disabled
|
|
241
|
+
/>
|
|
242
|
+
<Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>
|
|
243
|
+
</Box>
|
|
244
|
+
);
|
|
245
|
+
},
|
|
246
|
+
parameters: {
|
|
247
|
+
docs: {
|
|
248
|
+
story: "Un campo de entrada deshabilitado, lo que impide la interacción del usuario."
|
|
249
|
+
},
|
|
250
|
+
source: { code: DisabledInputDefinition.trim() }
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export const ReadOnlyInput: Story = {
|
|
255
|
+
render: () => {
|
|
256
|
+
const [value, setValue] = useState('Valor de solo lectura');
|
|
257
|
+
return (
|
|
258
|
+
<Box sx={{ width: 300 }}>
|
|
259
|
+
<Input
|
|
260
|
+
label="Información"
|
|
261
|
+
value={value.toString()}
|
|
262
|
+
onChange={(value) => setValue(value.toString())}
|
|
263
|
+
readOnly
|
|
264
|
+
/>
|
|
265
|
+
<Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>
|
|
266
|
+
</Box>
|
|
267
|
+
);
|
|
268
|
+
},
|
|
269
|
+
parameters: {
|
|
270
|
+
docs: {
|
|
271
|
+
story: "Un campo de entrada de solo lectura, el usuario puede ver el valor pero no modificarlo."
|
|
272
|
+
},
|
|
273
|
+
source: { code: ReadOnlyInputDefinition.trim() }
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
export const InputVariants: Story = {
|
|
278
|
+
render: () => {
|
|
279
|
+
const [valueOutlined, setValueOutlined] = useState('Outlined');
|
|
280
|
+
const [valueFilled, setValueFilled] = useState('Filled');
|
|
281
|
+
const [valueStandard, setValueStandard] = useState('Standard');
|
|
282
|
+
return (
|
|
283
|
+
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 3, width: 300 }}>
|
|
284
|
+
<Input
|
|
285
|
+
label="Esquema Outlined"
|
|
286
|
+
value={valueOutlined.toString()}
|
|
287
|
+
onChange={(value) => setValueOutlined(value.toString())}
|
|
288
|
+
variant="outlined"
|
|
289
|
+
/>
|
|
290
|
+
<Input
|
|
291
|
+
label="Esquema Filled"
|
|
292
|
+
value={valueFilled.toString()}
|
|
293
|
+
onChange={(value) => setValueFilled(value.toString())}
|
|
294
|
+
variant="filled"
|
|
295
|
+
/>
|
|
296
|
+
<Input
|
|
297
|
+
label="Esquema Standard"
|
|
298
|
+
value={valueStandard.toString()}
|
|
299
|
+
onChange={(value) => setValueStandard(value.toString())}
|
|
300
|
+
variant="standard"
|
|
301
|
+
/>
|
|
302
|
+
</Box>
|
|
303
|
+
);
|
|
304
|
+
},
|
|
305
|
+
parameters: {
|
|
306
|
+
docs: {
|
|
307
|
+
story: "Demuestra las diferentes variantes de diseño: `outlined`, `filled` y `standard`."
|
|
308
|
+
},
|
|
309
|
+
source: { code: InputVariantsDefinition.trim() }
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export const InputSizes: Story = {
|
|
314
|
+
render: () => {
|
|
315
|
+
const [valueMedium, setValueMedium] = useState('Tamaño Mediano');
|
|
316
|
+
const [valueSmall, setValueSmall] = useState('Tamaño Pequeño');
|
|
317
|
+
return (
|
|
318
|
+
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 3, width: 300 }}>
|
|
319
|
+
<Input
|
|
320
|
+
label="Input Mediano"
|
|
321
|
+
value={valueMedium.toString()}
|
|
322
|
+
onChange={(value) => setValueMedium(value.toString())}
|
|
323
|
+
size="medium"
|
|
324
|
+
/>
|
|
325
|
+
<Input
|
|
326
|
+
label="Input Pequeño"
|
|
327
|
+
value={valueSmall.toString()}
|
|
328
|
+
onChange={(value) => setValueSmall(value.toString())}
|
|
329
|
+
size="small"
|
|
330
|
+
/>
|
|
331
|
+
</Box>
|
|
332
|
+
);
|
|
333
|
+
},
|
|
334
|
+
parameters: {
|
|
335
|
+
docs: {
|
|
336
|
+
story: "Demuestra los diferentes tamaños del campo de entrada: `medium` (por defecto) y `small`."
|
|
337
|
+
},
|
|
338
|
+
source: { code: InputSizesDefinition.trim() }
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
export const FullWidthInput: Story = {
|
|
343
|
+
render: () => {
|
|
344
|
+
const [value, setValue] = useState('Ocupa todo el ancho');
|
|
345
|
+
return (
|
|
346
|
+
<Box sx={{ width: '100%' }}>
|
|
347
|
+
<Input
|
|
348
|
+
label="Input de Ancho Completo"
|
|
349
|
+
value={value.toString()}
|
|
350
|
+
onChange={(value) => setValue(value.toString())}
|
|
351
|
+
fullWidth
|
|
352
|
+
/>
|
|
353
|
+
<Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>
|
|
354
|
+
</Box>
|
|
355
|
+
);
|
|
356
|
+
},
|
|
357
|
+
parameters: {
|
|
358
|
+
docs: {
|
|
359
|
+
story: "Un campo de entrada que ocupa todo el ancho disponible de su contenedor."
|
|
360
|
+
},
|
|
361
|
+
source: { code: FullWidthInputDefinition.trim() }
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
export const StandardVariant : Story = {
|
|
366
|
+
render: () => {
|
|
367
|
+
const [value, setValue] = useState('Ocupa todo el ancho');
|
|
368
|
+
return (
|
|
369
|
+
<Box sx={{ width: '100%' }}>
|
|
370
|
+
<Input
|
|
371
|
+
|
|
372
|
+
value={value.toString()}
|
|
373
|
+
variant='standard'
|
|
374
|
+
onChange={(value) => setValue(value.toString())}
|
|
375
|
+
fullWidth
|
|
376
|
+
/>
|
|
377
|
+
<Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>
|
|
378
|
+
</Box>
|
|
379
|
+
);
|
|
380
|
+
},
|
|
381
|
+
parameters: {
|
|
382
|
+
docs: {
|
|
383
|
+
story: "Un campo de entrada que ocupa todo el ancho disponible de su contenedor."
|
|
384
|
+
},
|
|
385
|
+
|
|
386
|
+
}
|
|
387
|
+
};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { TextField, TextFieldProps } from '@mui/material';
|
|
3
|
+
import { styled } from '@mui/system';
|
|
4
|
+
import { Controller, Control, RegisterOptions } from 'react-hook-form';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
interface BaseInputProps extends Omit<TextFieldProps, 'value' | 'onChange' | 'variant' | 'type' | 'inputProps' | 'slotProps' | 'error' | 'helperText'> {
|
|
10
|
+
type?: 'text' | 'number' | 'email' | 'password' | 'tel' | 'url' | 'search' | 'date' | 'datetime-local' | 'month' | 'week' | 'time' | 'color';
|
|
11
|
+
variant?: 'outlined' | 'filled' | 'standard';
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
|
15
|
+
slotProps?: TextFieldProps['slotProps'];
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
readOnly?: boolean;
|
|
18
|
+
error?: boolean;
|
|
19
|
+
helperText?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface RHFInputProps extends BaseInputProps {
|
|
23
|
+
name: string;
|
|
24
|
+
control: Control<any>;
|
|
25
|
+
validation?: RegisterOptions;
|
|
26
|
+
value?: string | number;
|
|
27
|
+
onChange?: (value: string | number) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface StandardInputPropsWithOptionalName extends BaseInputProps {
|
|
31
|
+
name?: string;
|
|
32
|
+
control?: never;
|
|
33
|
+
validation?: never;
|
|
34
|
+
value: string | number;
|
|
35
|
+
onChange: (value: string | number) => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type InputProps = RHFInputProps | StandardInputPropsWithOptionalName;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const StyledTextField = styled(TextField)(({ theme }) => ({
|
|
42
|
+
'& .MuiInputBase-root': {
|
|
43
|
+
maxHeight: '34px',
|
|
44
|
+
padding: '8px 10px',
|
|
45
|
+
borderRadius: '10px',
|
|
46
|
+
display: 'flex',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
fontSize: '14px',
|
|
49
|
+
},
|
|
50
|
+
'& .MuiInputBase-input': {
|
|
51
|
+
padding: '0 !important',
|
|
52
|
+
height: '18px',
|
|
53
|
+
display: 'flex',
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
marginTop: '-4px'
|
|
56
|
+
},
|
|
57
|
+
'& .MuiInputLabel-root': {
|
|
58
|
+
top: '50%',
|
|
59
|
+
transform: 'translate(14px, -50%)',
|
|
60
|
+
'&.MuiInputLabel-shrink': {
|
|
61
|
+
transform: 'translate(1px, -200%) scale(0.75)',
|
|
62
|
+
fontSize: '16px !important',
|
|
63
|
+
'> legend': {
|
|
64
|
+
display: 'none',
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
'& .MuiInputLabel-root.Mui-error': {
|
|
69
|
+
top: '25%'
|
|
70
|
+
|
|
71
|
+
},
|
|
72
|
+
'& .MuiInputBase-root > fieldset > legend':{
|
|
73
|
+
display: 'none',
|
|
74
|
+
},
|
|
75
|
+
'& .MuiOutlinedInput-notchedOutline': {
|
|
76
|
+
border: '0.7px solid',
|
|
77
|
+
borderColor: '#e0e0e0',
|
|
78
|
+
},
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
export const Input = forwardRef<HTMLInputElement, InputProps>(({
|
|
83
|
+
type = 'text',
|
|
84
|
+
variant = 'outlined',
|
|
85
|
+
min,
|
|
86
|
+
max,
|
|
87
|
+
inputProps: customInputProps,
|
|
88
|
+
slotProps: customSlotProps,
|
|
89
|
+
|
|
90
|
+
value,
|
|
91
|
+
onChange,
|
|
92
|
+
...rest
|
|
93
|
+
}, ref) => {
|
|
94
|
+
const isRHFMode = 'control' in rest && rest.control !== undefined;
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
const htmlInputProps: React.InputHTMLAttributes<HTMLInputElement> = {
|
|
98
|
+
...customInputProps,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
if (type === 'number') {
|
|
102
|
+
htmlInputProps.min = min !== undefined ? min : Number.NEGATIVE_INFINITY;
|
|
103
|
+
if (max !== undefined) {
|
|
104
|
+
htmlInputProps.max = max;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
const finalSlotProps: TextFieldProps['slotProps'] = {
|
|
110
|
+
...customSlotProps,
|
|
111
|
+
htmlInput: {
|
|
112
|
+
...customSlotProps?.htmlInput,
|
|
113
|
+
...htmlInputProps,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
const handleChangeInternal = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, rhfOnChange?: (...event: any[]) => void) => {
|
|
119
|
+
const rawValue = event.target.value;
|
|
120
|
+
let newValue: string | number;
|
|
121
|
+
|
|
122
|
+
if (type === 'number') {
|
|
123
|
+
newValue = rawValue === '' || rawValue === '-' ? rawValue : parseFloat(rawValue);
|
|
124
|
+
|
|
125
|
+
if (isNaN(newValue as number) && rawValue !== '' && rawValue !== '-') newValue = rawValue;
|
|
126
|
+
} else {
|
|
127
|
+
newValue = rawValue;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (isRHFMode) {
|
|
131
|
+
rhfOnChange?.(newValue);
|
|
132
|
+
} else {
|
|
133
|
+
|
|
134
|
+
(onChange as (value: string | number) => void)?.(newValue);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
if (isRHFMode) {
|
|
140
|
+
const rhfProps = rest as RHFInputProps;
|
|
141
|
+
return (
|
|
142
|
+
<Controller
|
|
143
|
+
name={rhfProps.name}
|
|
144
|
+
control={rhfProps.control}
|
|
145
|
+
rules={rhfProps.validation}
|
|
146
|
+
render={({ field, fieldState: { error } }) => {
|
|
147
|
+
return (
|
|
148
|
+
<StyledTextField
|
|
149
|
+
fullWidth={true}
|
|
150
|
+
value={field.value ?? ''}
|
|
151
|
+
onChange={(e) => handleChangeInternal(e, field.onChange)}
|
|
152
|
+
onBlur={field.onBlur}
|
|
153
|
+
type={type}
|
|
154
|
+
variant={variant}
|
|
155
|
+
slotProps={finalSlotProps}
|
|
156
|
+
inputRef={field.ref}
|
|
157
|
+
error={!!error}
|
|
158
|
+
helperText={error?.message}
|
|
159
|
+
{...rest}
|
|
160
|
+
/>
|
|
161
|
+
);
|
|
162
|
+
}}
|
|
163
|
+
/>
|
|
164
|
+
);
|
|
165
|
+
} else {
|
|
166
|
+
|
|
167
|
+
const standardProps = rest as StandardInputPropsWithOptionalName;
|
|
168
|
+
return (
|
|
169
|
+
<StyledTextField
|
|
170
|
+
fullWidth={true}
|
|
171
|
+
name={standardProps.name}
|
|
172
|
+
value={value ?? ''}
|
|
173
|
+
onChange={(e) => handleChangeInternal(e)}
|
|
174
|
+
type={type}
|
|
175
|
+
variant={variant}
|
|
176
|
+
slotProps={finalSlotProps}
|
|
177
|
+
inputRef={ref}
|
|
178
|
+
error={standardProps.error}
|
|
179
|
+
helperText={standardProps.helperText}
|
|
180
|
+
{...rest}
|
|
181
|
+
/>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
export default Input;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Input } from './Input';
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { Box, Typography } from '@mui/material';
|
|
4
|
+
import InputGroup from './InputGroup'; // Asegúrate de tener este componente
|
|
5
|
+
|
|
6
|
+
import dayjs, { Dayjs } from 'dayjs';
|
|
7
|
+
import Select, { SelectOption } from '@soyfri/shared-library/components/Select/Select';
|
|
8
|
+
import { Input } from '@soyfri/shared-library/components/Input';
|
|
9
|
+
import { Button } from "@soyfri/shared-library/components/Button";
|
|
10
|
+
import { DatePicker } from '@soyfri/shared-library/components/DatePicker';
|
|
11
|
+
|
|
12
|
+
const meta: Meta<typeof InputGroup> = {
|
|
13
|
+
title: 'InputGroup',
|
|
14
|
+
component: InputGroup,
|
|
15
|
+
tags: ['autodocs'],
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: 'centered',
|
|
18
|
+
},
|
|
19
|
+
decorators: [
|
|
20
|
+
(Story) => (
|
|
21
|
+
<Box sx={{ width: 600, maxWidth: '100%' }}>
|
|
22
|
+
<Story />
|
|
23
|
+
</Box>
|
|
24
|
+
),
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default meta;
|
|
29
|
+
type Story = StoryObj<typeof InputGroup>;
|
|
30
|
+
|
|
31
|
+
const basicOptions: SelectOption[] = [
|
|
32
|
+
{ value: '10', label: '10' },
|
|
33
|
+
{ value: '25', label: '25' },
|
|
34
|
+
{ value: '50', label: '50' },
|
|
35
|
+
{ value: '100', label: '100' },
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
export const BasicInputGroup: Story = {
|
|
39
|
+
render: () => {
|
|
40
|
+
const [text, setText] = useState('');
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Box>
|
|
44
|
+
<Typography variant="h6" sx={{ mb: 2 }}>
|
|
45
|
+
Grupo de entrada básico
|
|
46
|
+
</Typography>
|
|
47
|
+
<InputGroup>
|
|
48
|
+
<Input
|
|
49
|
+
label="Buscar"
|
|
50
|
+
value={text}
|
|
51
|
+
onChange={(val) => setText(val as string)}
|
|
52
|
+
/>
|
|
53
|
+
<Button variant="outlined">
|
|
54
|
+
Buscar
|
|
55
|
+
</Button>
|
|
56
|
+
</InputGroup>
|
|
57
|
+
</Box>
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
parameters: {
|
|
61
|
+
docs: {
|
|
62
|
+
description: {
|
|
63
|
+
story: 'Un grupo de entrada simple que combina un campo de texto y un botón.'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const CombinedInputGroup: Story = {
|
|
70
|
+
render: () => {
|
|
71
|
+
const [text, setText] = useState('');
|
|
72
|
+
const [selectValue, setSelectValue] = useState('25');
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<Box>
|
|
76
|
+
<Typography variant="h6" sx={{ mb: 2 }}>
|
|
77
|
+
Grupo de entrada combinado
|
|
78
|
+
</Typography>
|
|
79
|
+
<InputGroup>
|
|
80
|
+
<Select
|
|
81
|
+
label="Registros"
|
|
82
|
+
options={basicOptions}
|
|
83
|
+
value={selectValue}
|
|
84
|
+
onChange={(val) => setSelectValue(val as string)}
|
|
85
|
+
/>
|
|
86
|
+
<Input
|
|
87
|
+
label="Filtrar por nombre"
|
|
88
|
+
value={text}
|
|
89
|
+
onChange={(val) => setText(val as string)}
|
|
90
|
+
/>
|
|
91
|
+
<Button variant="contained">
|
|
92
|
+
Aplicar
|
|
93
|
+
</Button>
|
|
94
|
+
</InputGroup>
|
|
95
|
+
</Box>
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
parameters: {
|
|
99
|
+
docs: {
|
|
100
|
+
description: {
|
|
101
|
+
story: 'Un ejemplo más complejo que agrupa un `Select`, un `Input` y un `Button` en una sola fila.'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const DatePickerInputGroup: Story = {
|
|
108
|
+
render: () => {
|
|
109
|
+
const [selectedDate, setSelectedDate] = useState<Dayjs | null>(dayjs());
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<Box>
|
|
113
|
+
<Typography variant="h6" sx={{ mb: 2 }}>
|
|
114
|
+
Grupo de entrada con DatePicker
|
|
115
|
+
</Typography>
|
|
116
|
+
<InputGroup>
|
|
117
|
+
<DatePicker
|
|
118
|
+
label="Fecha de inicio"
|
|
119
|
+
selectedDate={selectedDate}
|
|
120
|
+
onDateChange={(date) => setSelectedDate(date)}
|
|
121
|
+
/>
|
|
122
|
+
<Button variant="contained">
|
|
123
|
+
Ver calendario
|
|
124
|
+
</Button>
|
|
125
|
+
</InputGroup>
|
|
126
|
+
</Box>
|
|
127
|
+
);
|
|
128
|
+
},
|
|
129
|
+
parameters: {
|
|
130
|
+
docs: {
|
|
131
|
+
description: {
|
|
132
|
+
story: 'Un grupo de entrada que combina un `DatePicker` con un botón de acción.'
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|