polpo 0.1.7 → 0.1.9
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/dist/components.cjs +3 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.css +2 -0
- package/dist/components.css.map +1 -0
- package/dist/components.d.cts +1866 -0
- package/dist/components.d.ts +1866 -0
- package/dist/components.js +3 -0
- package/dist/components.js.map +1 -0
- package/dist/{get-modal-position-drle0OjP.d.cts → get-modal-position-C5jQsaGx.d.cts} +1 -1
- package/dist/{get-modal-position-drle0OjP.d.ts → get-modal-position-C5jQsaGx.d.ts} +1 -1
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/helpers.js +1 -1
- package/dist/helpers.js.map +1 -1
- package/dist/hooks.cjs +1 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +15 -13
- package/dist/hooks.d.ts +15 -13
- package/dist/hooks.js +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/layouts.cjs +3 -0
- package/dist/layouts.cjs.map +1 -0
- package/dist/layouts.css +2 -0
- package/dist/layouts.css.map +1 -0
- package/dist/{ui.d.cts → layouts.d.cts} +237 -2202
- package/dist/{ui.d.ts → layouts.d.ts} +237 -2202
- package/dist/layouts.js +3 -0
- package/dist/layouts.js.map +1 -0
- package/dist/types.cjs +3 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +8 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/{use-modal-transition-XQHye62R.d.cts → use-modal-transition-C0lyjvkD.d.ts} +4 -4
- package/dist/{use-modal-transition-DPZFWFFf.d.ts → use-modal-transition-C7DzbnY5.d.cts} +4 -4
- package/package.json +76 -76
- package/.eslintrc.cjs +0 -9
- package/.storybook/decorators.tsx +0 -61
- package/.storybook/main.ts +0 -47
- package/.storybook/manager-head.html +0 -2
- package/.storybook/manager.ts +0 -7
- package/.storybook/preview-head.html +0 -2
- package/.storybook/preview.ts +0 -38
- package/.storybook/theme.ts +0 -47
- package/.turbo/turbo-lint.log +0 -4
- package/README.md +0 -65
- package/dist/chunk-CF5MBMWG.js +0 -3
- package/dist/chunk-CF5MBMWG.js.map +0 -1
- package/dist/chunk-MAWW6AA7.js +0 -3
- package/dist/chunk-MAWW6AA7.js.map +0 -1
- package/dist/ui.cjs +0 -2279
- package/dist/ui.cjs.map +0 -1
- package/dist/ui.js +0 -2279
- package/dist/ui.js.map +0 -1
- package/src/components/accordion/accordion-item.stories.tsx +0 -128
- package/src/components/accordion/accordion-item.tsx +0 -119
- package/src/components/accordion/accordion.stories.tsx +0 -74
- package/src/components/accordion/accordion.style.ts +0 -42
- package/src/components/accordion/accordion.tsx +0 -74
- package/src/components/accordion/index.ts +0 -2
- package/src/components/buttons/button/button.stories.tsx +0 -103
- package/src/components/buttons/button/button.style.ts +0 -152
- package/src/components/buttons/button/button.tsx +0 -107
- package/src/components/buttons/button/index.ts +0 -1
- package/src/components/buttons/index.ts +0 -1
- package/src/components/cards/flip-card/flip-card.stories.tsx +0 -61
- package/src/components/cards/flip-card/flip-card.style.ts +0 -45
- package/src/components/cards/flip-card/flip-card.tsx +0 -55
- package/src/components/cards/flip-card/index.ts +0 -1
- package/src/components/cards/hover-card/hover-card.stories.tsx +0 -45
- package/src/components/cards/hover-card/hover-card.style.ts +0 -13
- package/src/components/cards/hover-card/hover-card.tsx +0 -71
- package/src/components/cards/hover-card/index.ts +0 -1
- package/src/components/cards/index.ts +0 -3
- package/src/components/cards/slide-card/index.ts +0 -1
- package/src/components/cards/slide-card/slide-card.stories.tsx +0 -47
- package/src/components/cards/slide-card/slide-card.tsx +0 -42
- package/src/components/cursor/cursor.stories.tsx +0 -36
- package/src/components/cursor/cursor.style.ts +0 -73
- package/src/components/cursor/cursor.tsx +0 -49
- package/src/components/cursor/index.ts +0 -1
- package/src/components/form/checkbox/checkbox.stories.tsx +0 -85
- package/src/components/form/checkbox/checkbox.style.ts +0 -109
- package/src/components/form/checkbox/checkbox.tsx +0 -120
- package/src/components/form/checkbox/index.ts +0 -1
- package/src/components/form/controller/controller.tsx +0 -42
- package/src/components/form/controller/index.ts +0 -1
- package/src/components/form/date-picker/date-picker.stories.tsx +0 -38
- package/src/components/form/date-picker/date-picker.tsx +0 -67
- package/src/components/form/date-picker/index.ts +0 -1
- package/src/components/form/field/field.stories.tsx +0 -52
- package/src/components/form/field/field.style.ts +0 -94
- package/src/components/form/field/field.tsx +0 -86
- package/src/components/form/field/field.types.ts +0 -34
- package/src/components/form/field/index.ts +0 -2
- package/src/components/form/form.stories.types.tsx +0 -50
- package/src/components/form/form.types.ts +0 -37
- package/src/components/form/index.ts +0 -14
- package/src/components/form/input/index.ts +0 -1
- package/src/components/form/input/input.stories.tsx +0 -41
- package/src/components/form/input/input.tsx +0 -73
- package/src/components/form/input-color/index.ts +0 -1
- package/src/components/form/input-color/input-color.stories.tsx +0 -46
- package/src/components/form/input-color/input-color.style.ts +0 -94
- package/src/components/form/input-color/input-color.tsx +0 -162
- package/src/components/form/input-file/index.ts +0 -1
- package/src/components/form/input-file/input-file.stories.tsx +0 -40
- package/src/components/form/input-file/input-file.style.ts +0 -143
- package/src/components/form/input-file/input-file.tsx +0 -214
- package/src/components/form/input-password/index.ts +0 -1
- package/src/components/form/input-password/input-password.stories.tsx +0 -37
- package/src/components/form/input-password/input-password.tsx +0 -83
- package/src/components/form/radio/index.ts +0 -1
- package/src/components/form/radio/radio.stories.tsx +0 -68
- package/src/components/form/radio/radio.style.ts +0 -79
- package/src/components/form/radio/radio.tsx +0 -106
- package/src/components/form/select/data.stories.json +0 -452
- package/src/components/form/select/index.ts +0 -1
- package/src/components/form/select/option.tsx +0 -101
- package/src/components/form/select/options.tsx +0 -161
- package/src/components/form/select/select.stories.tsx +0 -369
- package/src/components/form/select/select.style.ts +0 -116
- package/src/components/form/select/select.tsx +0 -312
- package/src/components/form/select/select.types.ts +0 -97
- package/src/components/form/slider/index.ts +0 -1
- package/src/components/form/slider/slider.stories.tsx +0 -40
- package/src/components/form/slider/slider.style.ts +0 -92
- package/src/components/form/slider/slider.tsx +0 -108
- package/src/components/form/switch/index.ts +0 -1
- package/src/components/form/switch/switch.stories.tsx +0 -88
- package/src/components/form/switch/switch.style.ts +0 -137
- package/src/components/form/switch/switch.tsx +0 -177
- package/src/components/form/textarea/index.ts +0 -1
- package/src/components/form/textarea/textarea.stories.tsx +0 -43
- package/src/components/form/textarea/textarea.style.ts +0 -7
- package/src/components/form/textarea/textarea.tsx +0 -76
- package/src/components/icon/icon.stories.tsx +0 -63
- package/src/components/icon/icon.tsx +0 -64
- package/src/components/icon/icons/index.ts +0 -18
- package/src/components/icon/icons/object.tsx +0 -482
- package/src/components/icon/icons/social.tsx +0 -88
- package/src/components/icon/icons/symbol.tsx +0 -776
- package/src/components/icon/index.ts +0 -5
- package/src/components/image/image.stories.tsx +0 -25
- package/src/components/image/image.tsx +0 -7
- package/src/components/image/index.ts +0 -1
- package/src/components/index.ts +0 -17
- package/src/components/infinity-scroll/index.ts +0 -1
- package/src/components/infinity-scroll/infinity-scroll.stories.tsx +0 -118
- package/src/components/infinity-scroll/infinity-scroll.style.ts +0 -30
- package/src/components/infinity-scroll/infinity-scroll.tsx +0 -53
- package/src/components/line/index.ts +0 -1
- package/src/components/line/line.stories.tsx +0 -66
- package/src/components/line/line.style.ts +0 -57
- package/src/components/line/line.tsx +0 -76
- package/src/components/loaders/icons/box-1.tsx +0 -31
- package/src/components/loaders/icons/box-2.tsx +0 -30
- package/src/components/loaders/icons/box-3.tsx +0 -66
- package/src/components/loaders/icons/clock-1.tsx +0 -25
- package/src/components/loaders/icons/clock-2.tsx +0 -58
- package/src/components/loaders/icons/dots-1.tsx +0 -194
- package/src/components/loaders/icons/dots-2.tsx +0 -15
- package/src/components/loaders/icons/dots-3.tsx +0 -38
- package/src/components/loaders/icons/dots-4.tsx +0 -90
- package/src/components/loaders/icons/dots-5.tsx +0 -30
- package/src/components/loaders/icons/dots-6.tsx +0 -72
- package/src/components/loaders/icons/dots-7.tsx +0 -51
- package/src/components/loaders/icons/dots-8.tsx +0 -42
- package/src/components/loaders/icons/dots-9.tsx +0 -27
- package/src/components/loaders/icons/lines-1.tsx +0 -96
- package/src/components/loaders/icons/lines-2.tsx +0 -48
- package/src/components/loaders/icons/pulse-1.tsx +0 -69
- package/src/components/loaders/icons/pulse-2.tsx +0 -69
- package/src/components/loaders/icons/pulse-3.tsx +0 -105
- package/src/components/loaders/icons/pulse-4.tsx +0 -105
- package/src/components/loaders/icons/pulse-5.tsx +0 -56
- package/src/components/loaders/icons/spinner-1.tsx +0 -162
- package/src/components/loaders/icons/spinner-2.tsx +0 -147
- package/src/components/loaders/icons/spinner-3.tsx +0 -35
- package/src/components/loaders/icons/spinner-4.tsx +0 -16
- package/src/components/loaders/index.ts +0 -1
- package/src/components/loaders/simple-loader/index.ts +0 -1
- package/src/components/loaders/simple-loader/simple-loader.stories.tsx +0 -42
- package/src/components/loaders/simple-loader/simple-loader.style.ts +0 -12
- package/src/components/loaders/simple-loader/simple-loader.tsx +0 -99
- package/src/components/modals/action-modal/action-modal.stories.tsx +0 -157
- package/src/components/modals/action-modal/action-modal.style.ts +0 -117
- package/src/components/modals/action-modal/action-modal.tsx +0 -148
- package/src/components/modals/action-modal/index.ts +0 -1
- package/src/components/modals/aside-modal/aside-modal.stories.tsx +0 -81
- package/src/components/modals/aside-modal/aside-modal.style.ts +0 -88
- package/src/components/modals/aside-modal/aside-modal.tsx +0 -64
- package/src/components/modals/aside-modal/index.ts +0 -1
- package/src/components/modals/confirmation-modal/confirmation-modal.stories.tsx +0 -62
- package/src/components/modals/confirmation-modal/confirmation-modal.style.ts +0 -17
- package/src/components/modals/confirmation-modal/confirmation-modal.tsx +0 -43
- package/src/components/modals/confirmation-modal/index.ts +0 -1
- package/src/components/modals/index.ts +0 -6
- package/src/components/modals/menu/index.ts +0 -1
- package/src/components/modals/menu/menu.stories.tsx +0 -79
- package/src/components/modals/menu/menu.style.ts +0 -103
- package/src/components/modals/menu/menu.tsx +0 -186
- package/src/components/modals/modal/backdrop.tsx +0 -70
- package/src/components/modals/modal/index.ts +0 -2
- package/src/components/modals/modal/modal.stories.tsx +0 -328
- package/src/components/modals/modal/modal.style.ts +0 -70
- package/src/components/modals/modal/modal.tsx +0 -106
- package/src/components/modals/portal/index.ts +0 -1
- package/src/components/modals/portal/portal.tsx +0 -21
- package/src/components/ripple/index.ts +0 -1
- package/src/components/ripple/ripple.stories.tsx +0 -38
- package/src/components/ripple/ripple.style.ts +0 -33
- package/src/components/ripple/ripple.tsx +0 -65
- package/src/components/smart-table/index.ts +0 -1
- package/src/components/smart-table/smart-table.column.tsx +0 -63
- package/src/components/smart-table/smart-table.helpers.tsx +0 -59
- package/src/components/smart-table/smart-table.hooks.ts +0 -27
- package/src/components/smart-table/smart-table.row.tsx +0 -29
- package/src/components/smart-table/smart-table.stories.tsx +0 -301
- package/src/components/smart-table/smart-table.style.ts +0 -102
- package/src/components/smart-table/smart-table.tsx +0 -112
- package/src/components/smart-table/smart-table.types.ts +0 -41
- package/src/components/tabs/index.ts +0 -1
- package/src/components/tabs/tabs-container.stories.tsx +0 -159
- package/src/components/tabs/tabs-list.tsx +0 -134
- package/src/components/tabs/tabs.stories.tsx +0 -68
- package/src/components/tabs/tabs.style.ts +0 -137
- package/src/components/tabs/tabs.tsx +0 -117
- package/src/components/tag/index.ts +0 -1
- package/src/components/tag/tag.stories.tsx +0 -48
- package/src/components/tag/tag.style.ts +0 -29
- package/src/components/tag/tag.tsx +0 -34
- package/src/components/tooltips/click-to-copy/click-to-copy.stories.tsx +0 -39
- package/src/components/tooltips/click-to-copy/click-to-copy.tsx +0 -41
- package/src/components/tooltips/click-to-copy/index.ts +0 -1
- package/src/components/tooltips/index.ts +0 -2
- package/src/components/tooltips/tooltip/index.ts +0 -1
- package/src/components/tooltips/tooltip/tooltip.stories.tsx +0 -38
- package/src/components/tooltips/tooltip/tooltip.style.ts +0 -93
- package/src/components/tooltips/tooltip/tooltip.tsx +0 -59
- package/src/components/typography/index.ts +0 -2
- package/src/components/typography/typography.constants.ts +0 -43
- package/src/components/typography/typography.stories.tsx +0 -108
- package/src/components/typography/typography.style.ts +0 -76
- package/src/components/typography/typography.tsx +0 -100
- package/src/contexts/fetch-context/fetch-context.tsx +0 -114
- package/src/contexts/fetch-context/index.ts +0 -1
- package/src/contexts/form-context/form-context.tsx +0 -43
- package/src/contexts/form-context/index.ts +0 -1
- package/src/contexts/index.ts +0 -3
- package/src/contexts/theme-context/index.ts +0 -3
- package/src/contexts/theme-context/theme-context.tsx +0 -158
- package/src/contexts/theme-context/theme.animations.ts +0 -269
- package/src/contexts/theme-context/theme.defaults.ts +0 -209
- package/src/contexts/theme-context/theme.style.ts +0 -78
- package/src/contexts/theme-context/themes.ts +0 -98
- package/src/core/http-client.d.ts +0 -11
- package/src/core/http-client.d.ts.map +0 -1
- package/src/core/http-client.ts +0 -49
- package/src/core/index.d.ts +0 -2
- package/src/core/index.d.ts.map +0 -1
- package/src/core/index.ts +0 -1
- package/src/core/variants/color.ts +0 -9
- package/src/core/variants/index.ts +0 -3
- package/src/core/variants/radius.ts +0 -27
- package/src/core/variants/size.ts +0 -19
- package/src/helpers/format-bytes.ts +0 -11
- package/src/helpers/format-dates.ts +0 -11
- package/src/helpers/get-modal-position-relative-to-screen.ts +0 -86
- package/src/helpers/get-modal-position.ts +0 -211
- package/src/helpers/index.ts +0 -5
- package/src/helpers/text/index.ts +0 -1
- package/src/helpers/text/to-capitalize.ts +0 -17
- package/src/hooks/index.ts +0 -29
- package/src/hooks/use-async.ts +0 -88
- package/src/hooks/use-classnames.ts +0 -13
- package/src/hooks/use-click-outside.ts +0 -32
- package/src/hooks/use-constant.ts +0 -3
- package/src/hooks/use-cookie.ts +0 -124
- package/src/hooks/use-debounce.ts +0 -15
- package/src/hooks/use-dimensions.ts +0 -19
- package/src/hooks/use-dom-container.ts +0 -35
- package/src/hooks/use-event-listener.ts +0 -71
- package/src/hooks/use-file-reader.ts +0 -69
- package/src/hooks/use-geolocation.ts +0 -63
- package/src/hooks/use-hover.ts +0 -17
- package/src/hooks/use-in-view.ts +0 -18
- package/src/hooks/use-input-handlers.ts +0 -49
- package/src/hooks/use-intersection-observer.ts +0 -19
- package/src/hooks/use-media-query.ts +0 -25
- package/src/hooks/use-modal-in-container.ts +0 -85
- package/src/hooks/use-modal-transition.ts +0 -64
- package/src/hooks/use-modal.ts +0 -21
- package/src/hooks/use-mouse-position.ts +0 -64
- package/src/hooks/use-online-status.ts +0 -12
- package/src/hooks/use-render-count.ts +0 -11
- package/src/hooks/use-resize-observer.ts +0 -18
- package/src/hooks/use-safe-dispatch.ts +0 -22
- package/src/hooks/use-scroll.ts +0 -31
- package/src/hooks/use-state-history.ts +0 -22
- package/src/hooks/use-toggle-values.ts +0 -14
- package/src/hooks/use-toggle.ts +0 -11
- package/src/hooks/use-viewport.ts +0 -38
- package/src/index.ts +0 -5
- package/src/layouts/flex/flex.tsx +0 -75
- package/src/layouts/flex/index.ts +0 -1
- package/src/layouts/grid/grid.tsx +0 -86
- package/src/layouts/grid/index.ts +0 -1
- package/src/layouts/index.ts +0 -3
- package/src/layouts/section-layout/index.ts +0 -1
- package/src/layouts/section-layout/section-layout.stories.tsx +0 -55
- package/src/layouts/section-layout/section-layout.style.ts +0 -21
- package/src/layouts/section-layout/section-layout.tsx +0 -46
- package/src/stories/GettingStarted.mdx +0 -62
- package/src/types/generics.ts +0 -68
- package/src/types/index.ts +0 -1
- package/svg/Name=airplane, Category=object.svg +0 -3
- package/svg/Name=arrow-circle, Category=symbol.svg +0 -3
- package/svg/Name=arrow-down, Category=symbol.svg +0 -3
- package/svg/Name=arrow-left, Category=symbol.svg +0 -3
- package/svg/Name=arrow-right, Category=symbol.svg +0 -3
- package/svg/Name=arrow-up, Category=symbol.svg +0 -3
- package/svg/Name=bell, Category=object.svg +0 -3
- package/svg/Name=bicycle, Category=object.svg +0 -3
- package/svg/Name=book-open, Category=object.svg +0 -3
- package/svg/Name=book-solid, Category=object.svg +0 -6
- package/svg/Name=box-shadow, Category=symbol.svg +0 -5
- package/svg/Name=calendar, Category=object.svg +0 -3
- package/svg/Name=camera, Category=object.svg +0 -3
- package/svg/Name=caret-down, Category=symbol.svg +0 -3
- package/svg/Name=caret-left, Category=symbol.svg +0 -3
- package/svg/Name=caret-right, Category=symbol.svg +0 -3
- package/svg/Name=caret-up, Category=symbol.svg +0 -3
- package/svg/Name=checkmark, Category=symbol.svg +0 -3
- package/svg/Name=clean-computer, Category=object.svg +0 -10
- package/svg/Name=codepen, Category=social.svg +0 -3
- package/svg/Name=creative, Category=symbol.svg +0 -5
- package/svg/Name=cross, Category=symbol.svg +0 -4
- package/svg/Name=crossed-flags, Category=object.svg +0 -4
- package/svg/Name=cv, Category=symbol.svg +0 -5
- package/svg/Name=design-ui, Category=symbol.svg +0 -9
- package/svg/Name=document, Category=object.svg +0 -3
- package/svg/Name=door-closed, Category=object.svg +0 -3
- package/svg/Name=door-open, Category=object.svg +0 -3
- package/svg/Name=double-caret-down, Category=symbol.svg +0 -4
- package/svg/Name=double-caret-left, Category=symbol.svg +0 -4
- package/svg/Name=double-caret-righ, Category=symbol.svg +0 -4
- package/svg/Name=double-caret-up, Category=symbol.svg +0 -4
- package/svg/Name=download, Category=symbol.svg +0 -5
- package/svg/Name=dropper, Category=object.svg +0 -5
- package/svg/Name=envelope, Category=object.svg +0 -3
- package/svg/Name=exclamation-close, Category=symbol.svg +0 -4
- package/svg/Name=exclamation-open, Category=symbol.svg +0 -4
- package/svg/Name=external-link, Category=symbol.svg +0 -3
- package/svg/Name=eye, Category=object.svg +0 -4
- package/svg/Name=eye-hidden, Category=object.svg +0 -7
- package/svg/Name=facebook, Category=social.svg +0 -3
- package/svg/Name=form, Category=symbol.svg +0 -8
- package/svg/Name=game-control, Category=object.svg +0 -3
- package/svg/Name=gear, Category=object.svg +0 -3
- package/svg/Name=github, Category=social.svg +0 -3
- package/svg/Name=house, Category=object.svg +0 -3
- package/svg/Name=hyphen, Category=symbol.svg +0 -3
- package/svg/Name=info, Category=symbol.svg +0 -3
- package/svg/Name=instagram, Category=social.svg +0 -3
- package/svg/Name=link, Category=symbol.svg +0 -5
- package/svg/Name=linkedin, Category=social.svg +0 -3
- package/svg/Name=magnifying-glass, Category=object.svg +0 -3
- package/svg/Name=message, Category=symbol.svg +0 -4
- package/svg/Name=moon, Category=object.svg +0 -5
- package/svg/Name=npm, Category=social.svg +0 -3
- package/svg/Name=order-list, Category=symbol.svg +0 -7
- package/svg/Name=pencil, Category=object.svg +0 -3
- package/svg/Name=pin-location, Category=symbol.svg +0 -3
- package/svg/Name=question-mark-close, Category=symbol.svg +0 -3
- package/svg/Name=question-mark-open, Category=symbol.svg +0 -3
- package/svg/Name=share, Category=symbol.svg +0 -5
- package/svg/Name=spinner, Category=symbol.svg +0 -9
- package/svg/Name=star, Category=object.svg +0 -3
- package/svg/Name=star-empty, Category=object.svg +0 -3
- package/svg/Name=sun, Category=object.svg +0 -11
- package/svg/Name=text-shadow, Category=symbol.svg +0 -4
- package/svg/Name=thinking, Category=symbol.svg +0 -3
- package/svg/Name=trash-can, Category=object.svg +0 -4
- package/svg/Name=upload, Category=symbol.svg +0 -5
- package/svg/Name=user, Category=symbol.svg +0 -4
- package/svg/Name=warning, Category=symbol.svg +0 -5
- package/svg/Name=whatsapp, Category=social.svg +0 -3
- package/svgconfig.json +0 -4
- package/tsconfig.json +0 -15
- package/tsup.config.cjs +0 -21
- package/vite.config.ts +0 -14
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import React, { ForwardedRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Icon, IconNameT } from '../../icon';
|
|
4
|
-
import { Typography } from '../../typography';
|
|
5
|
-
|
|
6
|
-
import { FieldStyle } from './field.style';
|
|
7
|
-
import { FieldOrientation, FieldProps, FieldVariant } from './field.types';
|
|
8
|
-
|
|
9
|
-
import { useClassNames } from '@polpo/hooks';
|
|
10
|
-
|
|
11
|
-
type GetIconParams = {
|
|
12
|
-
iconName?: IconNameT;
|
|
13
|
-
onClick: (e: React.MouseEvent) => void;
|
|
14
|
-
className: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const getIcon = ({ iconName, className, onClick }: GetIconParams) =>
|
|
18
|
-
iconName ? <Icon className={className} name={iconName} onClick={onClick} /> : <span />;
|
|
19
|
-
|
|
20
|
-
const FieldComponent = (
|
|
21
|
-
{
|
|
22
|
-
id,
|
|
23
|
-
label,
|
|
24
|
-
leftIcon,
|
|
25
|
-
rightIcon,
|
|
26
|
-
errorIcon = 'cross',
|
|
27
|
-
error,
|
|
28
|
-
onClickLeftIcon,
|
|
29
|
-
onClickRightIcon,
|
|
30
|
-
fieldOrientation = FieldOrientation.VERTICAL,
|
|
31
|
-
children,
|
|
32
|
-
isFocus = false,
|
|
33
|
-
variant,
|
|
34
|
-
}: FieldProps,
|
|
35
|
-
ref: ForwardedRef<HTMLElement>,
|
|
36
|
-
) => {
|
|
37
|
-
const fieldClassName = useClassNames({
|
|
38
|
-
focus: isFocus,
|
|
39
|
-
error: !!error,
|
|
40
|
-
'variant-content-border': variant === FieldVariant.CONTENT_BORDER,
|
|
41
|
-
'variant-content-line': variant === FieldVariant.CONTENT_LINE,
|
|
42
|
-
'variant-full-border': variant === FieldVariant.FULL_BORDER,
|
|
43
|
-
'variant-inline': fieldOrientation === FieldOrientation.HORIZONTAL,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const handleClick = (callback?: () => void) => (e: React.MouseEvent) => {
|
|
47
|
-
e.stopPropagation();
|
|
48
|
-
const input = document.getElementById(id);
|
|
49
|
-
input?.focus();
|
|
50
|
-
input?.click();
|
|
51
|
-
callback && callback();
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<FieldStyle className={fieldClassName} ref={ref}>
|
|
56
|
-
{label ? (
|
|
57
|
-
<Typography className='field-label' noPadding variant='label-form' htmlFor={id}>
|
|
58
|
-
{label}
|
|
59
|
-
</Typography>
|
|
60
|
-
) : null}
|
|
61
|
-
<section className='field-content'>
|
|
62
|
-
{getIcon({
|
|
63
|
-
className: 'field-left-icon',
|
|
64
|
-
iconName: leftIcon,
|
|
65
|
-
onClick: handleClick(onClickLeftIcon),
|
|
66
|
-
})}
|
|
67
|
-
<section className='field-children'>{children}</section>
|
|
68
|
-
{getIcon({
|
|
69
|
-
className: 'field-right-icon',
|
|
70
|
-
iconName: rightIcon,
|
|
71
|
-
onClick: handleClick(onClickRightIcon),
|
|
72
|
-
})}
|
|
73
|
-
</section>
|
|
74
|
-
{Boolean(error) && (
|
|
75
|
-
<section className='field-message'>
|
|
76
|
-
{errorIcon ? <Icon name={errorIcon} size={10} /> : <span />}
|
|
77
|
-
<Typography noPadding variant='small'>
|
|
78
|
-
{error}
|
|
79
|
-
</Typography>
|
|
80
|
-
</section>
|
|
81
|
-
)}
|
|
82
|
-
</FieldStyle>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export const Field = React.forwardRef(FieldComponent);
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { IconNameT } from '../../icon';
|
|
4
|
-
|
|
5
|
-
export enum FieldVariant {
|
|
6
|
-
FULL_BORDER = 'full-border',
|
|
7
|
-
CONTENT_BORDER = 'content-border',
|
|
8
|
-
CONTENT_LINE = 'line',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export enum FieldOrientation {
|
|
12
|
-
HORIZONTAL = 'horizontal',
|
|
13
|
-
VERTICAL = 'vertical',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type FieldSharedProps = {
|
|
17
|
-
rightIcon?: IconNameT;
|
|
18
|
-
leftIcon?: IconNameT;
|
|
19
|
-
errorIcon?: IconNameT;
|
|
20
|
-
onClickLeftIcon?: () => void;
|
|
21
|
-
onClickRightIcon?: () => void;
|
|
22
|
-
label?: string;
|
|
23
|
-
variant?: `${FieldVariant}`;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type FieldProps = FieldSharedProps & {
|
|
27
|
-
children: React.ReactNode;
|
|
28
|
-
id: string;
|
|
29
|
-
error?: string;
|
|
30
|
-
isFocus?: boolean;
|
|
31
|
-
fieldOrientation?: `${FieldOrientation}`;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type InputFieldProps<T> = T & FieldSharedProps;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryFn } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { Grid } from '../../layouts';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
ControlledComponentProps,
|
|
7
|
-
ControlledProps,
|
|
8
|
-
SharedProps,
|
|
9
|
-
UnControlledComponentProps,
|
|
10
|
-
UnControlledProps,
|
|
11
|
-
} from './form.types';
|
|
12
|
-
|
|
13
|
-
export const SharedArgTypes: Meta<SharedProps>['argTypes'] = {
|
|
14
|
-
name: { control: false },
|
|
15
|
-
className: { control: false },
|
|
16
|
-
style: { control: false },
|
|
17
|
-
autoComplete: { control: false },
|
|
18
|
-
autoFocus: { control: 'boolean' },
|
|
19
|
-
placeholder: { control: 'text' },
|
|
20
|
-
disabled: { control: 'boolean' },
|
|
21
|
-
readOnly: { control: 'boolean' },
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const UnControlledArgTypes: Meta<UnControlledProps<unknown>>['argTypes'] = {
|
|
25
|
-
value: { control: false },
|
|
26
|
-
invalid: { control: 'boolean' },
|
|
27
|
-
isTouched: { control: 'boolean' },
|
|
28
|
-
isDirty: { control: 'boolean' },
|
|
29
|
-
error: { control: 'text' },
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const ControlledArgTypes: Meta<ControlledProps<unknown>>['argTypes'] = {
|
|
33
|
-
defaultValue: { control: false },
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const UnControlledComponentArgTypes: Meta<UnControlledComponentProps<{}, unknown>>['argTypes'] = {
|
|
37
|
-
...SharedArgTypes,
|
|
38
|
-
...UnControlledArgTypes,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const ControlledComponentArgTypes: Meta<ControlledComponentProps<{}, unknown>>['argTypes'] = {
|
|
42
|
-
...SharedArgTypes,
|
|
43
|
-
...ControlledArgTypes,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const ContainerDecorator = (Story: StoryFn) => (
|
|
47
|
-
<Grid gtc='300px'>
|
|
48
|
-
<Story />
|
|
49
|
-
</Grid>
|
|
50
|
-
);
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { UseControllerProps } from 'react-hook-form';
|
|
3
|
-
|
|
4
|
-
export type Props = { [key: string]: unknown };
|
|
5
|
-
|
|
6
|
-
export type SharedProps = {
|
|
7
|
-
name: string;
|
|
8
|
-
className?: string;
|
|
9
|
-
style?: React.CSSProperties;
|
|
10
|
-
autoComplete?: string;
|
|
11
|
-
autoFocus?: boolean;
|
|
12
|
-
placeholder?: string;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
readOnly?: boolean;
|
|
15
|
-
onBlur?: (e: React.FocusEvent<unknown>) => void;
|
|
16
|
-
onFocus?: (e: React.FocusEvent<unknown>) => void;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type UnControlledProps<V> = {
|
|
20
|
-
value: V;
|
|
21
|
-
setValue: (value: V) => void;
|
|
22
|
-
invalid?: boolean;
|
|
23
|
-
isTouched?: boolean;
|
|
24
|
-
isDirty?: boolean;
|
|
25
|
-
error?: string;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type ControlledProps<V> = {
|
|
29
|
-
defaultValue?: V;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type UnControlledComponentProps<T extends Props, V> = T & SharedProps & UnControlledProps<V>;
|
|
33
|
-
|
|
34
|
-
export type ControlledComponentProps<T extends Props, V> = T & SharedProps & ControlledProps<V>;
|
|
35
|
-
|
|
36
|
-
export type ControllerGeneratorProps<T extends Props, V> = ControlledComponentProps<T, V> &
|
|
37
|
-
Partial<Pick<UseControllerProps, 'rules'>>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from './checkbox';
|
|
2
|
-
export * from './controller';
|
|
3
|
-
export * from './date-picker';
|
|
4
|
-
export * from './field';
|
|
5
|
-
export * from './input';
|
|
6
|
-
export * from './input-password';
|
|
7
|
-
export * from './input-color';
|
|
8
|
-
export * from './input-file';
|
|
9
|
-
export * from './field';
|
|
10
|
-
export * from './radio';
|
|
11
|
-
export * from './select';
|
|
12
|
-
export * from './slider';
|
|
13
|
-
export * from './textarea';
|
|
14
|
-
export * from './switch';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './input';
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { FieldSharedArgs, FieldSharedArgTypes } from '../field/field.stories';
|
|
4
|
-
import { ContainerDecorator, UnControlledComponentArgTypes } from '../form.stories.types';
|
|
5
|
-
|
|
6
|
-
import { Input } from './input';
|
|
7
|
-
|
|
8
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
9
|
-
|
|
10
|
-
const meta: Meta<typeof Input> = {
|
|
11
|
-
title: 'Form/Input',
|
|
12
|
-
component: Input,
|
|
13
|
-
argTypes: {
|
|
14
|
-
...FieldSharedArgTypes,
|
|
15
|
-
...UnControlledComponentArgTypes,
|
|
16
|
-
type: { control: 'select', options: ['email', 'number', 'search', 'tel', 'text', 'url'] },
|
|
17
|
-
min: { control: { type: 'range' }, if: { arg: 'type', eq: 'number' } },
|
|
18
|
-
max: { control: { type: 'range' }, if: { arg: 'type', eq: 'number' } },
|
|
19
|
-
},
|
|
20
|
-
args: {
|
|
21
|
-
label: 'Input',
|
|
22
|
-
type: 'text',
|
|
23
|
-
min: 0,
|
|
24
|
-
max: 0,
|
|
25
|
-
placeholder: 'Input',
|
|
26
|
-
...FieldSharedArgs,
|
|
27
|
-
},
|
|
28
|
-
decorators: [ContainerDecorator],
|
|
29
|
-
render: args => {
|
|
30
|
-
const [value, setValue] = useState('');
|
|
31
|
-
|
|
32
|
-
return <Input {...args} value={value} setValue={setValue} />;
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default meta;
|
|
37
|
-
type Story = StoryObj<typeof Input>;
|
|
38
|
-
|
|
39
|
-
export const Default: Story = {
|
|
40
|
-
args: {},
|
|
41
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Controller } from '../controller';
|
|
4
|
-
import { Field, InputFieldProps } from '../field';
|
|
5
|
-
import { ControllerGeneratorProps, UnControlledComponentProps } from '../form.types';
|
|
6
|
-
|
|
7
|
-
import { useInputHandlers } from '@polpo/hooks';
|
|
8
|
-
|
|
9
|
-
type IProps = InputFieldProps<{
|
|
10
|
-
type?: 'email' | 'number' | 'search' | 'tel' | 'text' | 'url';
|
|
11
|
-
min?: number;
|
|
12
|
-
max?: number;
|
|
13
|
-
}>;
|
|
14
|
-
|
|
15
|
-
export const Input = ({
|
|
16
|
-
name,
|
|
17
|
-
value,
|
|
18
|
-
setValue,
|
|
19
|
-
onBlur,
|
|
20
|
-
onFocus,
|
|
21
|
-
type = 'text',
|
|
22
|
-
className = '',
|
|
23
|
-
style = {},
|
|
24
|
-
autoFocus = false,
|
|
25
|
-
readOnly = false,
|
|
26
|
-
disabled = false,
|
|
27
|
-
placeholder = '',
|
|
28
|
-
autoComplete = 'off',
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
30
|
-
isDirty = false,
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
|
-
isTouched = false,
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
34
|
-
invalid = false,
|
|
35
|
-
error,
|
|
36
|
-
min,
|
|
37
|
-
max,
|
|
38
|
-
...fieldProps
|
|
39
|
-
}: UnControlledComponentProps<IProps, string>) => {
|
|
40
|
-
const id = useMemo(() => crypto.randomUUID(), []);
|
|
41
|
-
const { handlers, isFocus } = useInputHandlers({
|
|
42
|
-
onChange: e => setValue(e.target.value),
|
|
43
|
-
onBlur: onBlur,
|
|
44
|
-
onFocus: onFocus,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<Field id={id} error={error} isFocus={isFocus} {...fieldProps}>
|
|
49
|
-
<input
|
|
50
|
-
id={id}
|
|
51
|
-
type={type}
|
|
52
|
-
name={name}
|
|
53
|
-
className={className}
|
|
54
|
-
style={style}
|
|
55
|
-
value={value}
|
|
56
|
-
autoFocus={autoFocus}
|
|
57
|
-
autoComplete={autoComplete}
|
|
58
|
-
placeholder={placeholder}
|
|
59
|
-
disabled={disabled}
|
|
60
|
-
readOnly={readOnly}
|
|
61
|
-
min={min}
|
|
62
|
-
max={max}
|
|
63
|
-
{...handlers}
|
|
64
|
-
/>
|
|
65
|
-
</Field>
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const InputController = ({ rules, ...props }: ControllerGeneratorProps<IProps, string>) => {
|
|
70
|
-
return <Controller Component={Input} defaultValue='' inputProps={props} rules={rules} />;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
Input.Controller = InputController;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './input-color';
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { FieldSharedArgs, FieldSharedArgTypes } from '../field/field.stories';
|
|
4
|
-
import { ContainerDecorator, UnControlledComponentArgTypes } from '../form.stories.types';
|
|
5
|
-
|
|
6
|
-
import { InputColor } from './input-color';
|
|
7
|
-
|
|
8
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
9
|
-
|
|
10
|
-
const meta: Meta<typeof InputColor> = {
|
|
11
|
-
title: 'Form/InputColor',
|
|
12
|
-
component: InputColor,
|
|
13
|
-
argTypes: {
|
|
14
|
-
...FieldSharedArgTypes,
|
|
15
|
-
...UnControlledComponentArgTypes,
|
|
16
|
-
showValueText: { control: 'boolean' },
|
|
17
|
-
},
|
|
18
|
-
args: {
|
|
19
|
-
label: 'Input Color',
|
|
20
|
-
showValueText: true,
|
|
21
|
-
rightIcon: undefined,
|
|
22
|
-
leftIcon: undefined,
|
|
23
|
-
...FieldSharedArgs,
|
|
24
|
-
},
|
|
25
|
-
decorators: [ContainerDecorator],
|
|
26
|
-
render: args => {
|
|
27
|
-
const [value, setValue] = useState('#147EFB');
|
|
28
|
-
|
|
29
|
-
return <InputColor {...args} value={value} setValue={setValue} />;
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default meta;
|
|
34
|
-
type Story = StoryObj<typeof InputColor>;
|
|
35
|
-
|
|
36
|
-
export const Default: Story = {
|
|
37
|
-
args: {},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const Box: Story = {
|
|
41
|
-
args: {
|
|
42
|
-
label: '',
|
|
43
|
-
showValueText: false,
|
|
44
|
-
variant: undefined,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { Modal } from '../../modals';
|
|
4
|
-
|
|
5
|
-
export const InputColorStyle = styled.section`
|
|
6
|
-
display: grid;
|
|
7
|
-
grid-auto-flow: column;
|
|
8
|
-
align-items: center;
|
|
9
|
-
justify-content: start;
|
|
10
|
-
gap: 0.5em;
|
|
11
|
-
|
|
12
|
-
.input-color-value {
|
|
13
|
-
margin-left: 10px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.color-input {
|
|
17
|
-
padding-right: 1em;
|
|
18
|
-
border-radius: inherit;
|
|
19
|
-
width: 100%;
|
|
20
|
-
font-size: ${props => props.theme.constants.typography.label.fontSize};
|
|
21
|
-
font-family: ${props => props.theme.constants.fontFamily};
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
export const InputColorBoxStyle = styled.section`
|
|
26
|
-
background: white;
|
|
27
|
-
border-radius: 5px;
|
|
28
|
-
border: 2px solid;
|
|
29
|
-
width: 25px;
|
|
30
|
-
height: 25px;
|
|
31
|
-
position: relative;
|
|
32
|
-
cursor: pointer;
|
|
33
|
-
|
|
34
|
-
&::before {
|
|
35
|
-
content: '';
|
|
36
|
-
position: absolute;
|
|
37
|
-
border-radius: inherit;
|
|
38
|
-
top: 0;
|
|
39
|
-
left: 0;
|
|
40
|
-
width: 100%;
|
|
41
|
-
height: 100%;
|
|
42
|
-
background: repeating-conic-gradient(#cccccc 0% 25%, white 0% 50%) 50% / 8px 8px;
|
|
43
|
-
z-index: -1;
|
|
44
|
-
}
|
|
45
|
-
`;
|
|
46
|
-
|
|
47
|
-
export const InputColorSelectorStyle = styled(Modal)`
|
|
48
|
-
display: grid;
|
|
49
|
-
gap: 10px;
|
|
50
|
-
background: ${props => props.theme.colors.background.main};
|
|
51
|
-
color: ${props => props.theme.colors.text.main};
|
|
52
|
-
padding: 10px;
|
|
53
|
-
border-radius: 0 18px 18px 18px;
|
|
54
|
-
border: 1px solid;
|
|
55
|
-
box-shadow: 0 5px 30px -5px ${props => props.theme.colors.gray1};
|
|
56
|
-
|
|
57
|
-
.react-colorful__pointer {
|
|
58
|
-
width: 1em;
|
|
59
|
-
height: 1em;
|
|
60
|
-
border-radius: 50%;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.react-colorful__hue-pointer,
|
|
64
|
-
.react-colorful__alpha-pointer {
|
|
65
|
-
width: 8px;
|
|
66
|
-
height: 100%;
|
|
67
|
-
border-radius: 4px;
|
|
68
|
-
border-width: 2px;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.color-input-container {
|
|
72
|
-
display: grid;
|
|
73
|
-
grid-template-columns: 16px 1fr 16px;
|
|
74
|
-
align-items: center;
|
|
75
|
-
gap: 10px;
|
|
76
|
-
border: 1px solid;
|
|
77
|
-
border-radius: 8px;
|
|
78
|
-
padding: 0.5em;
|
|
79
|
-
width: 100%;
|
|
80
|
-
max-width: 200px;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.color-input {
|
|
84
|
-
padding: 0;
|
|
85
|
-
border-radius: inherit;
|
|
86
|
-
background: ${props => props.theme.colors.background.main};
|
|
87
|
-
color: ${props => props.theme.colors.text.main};
|
|
88
|
-
width: 100%;
|
|
89
|
-
font-size: ${props => props.theme.constants.typography.label.fontSize};
|
|
90
|
-
font-family: ${props => props.theme.constants.fontFamily};
|
|
91
|
-
letter-spacing: 2px;
|
|
92
|
-
text-align: center;
|
|
93
|
-
}
|
|
94
|
-
`;
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import Color from 'color';
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { HexAlphaColorPicker, HexColorInput } from 'react-colorful';
|
|
4
|
-
import useEyeDropper from 'use-eye-dropper';
|
|
5
|
-
|
|
6
|
-
import { Icon } from '../../icon';
|
|
7
|
-
import { Controller } from '../controller';
|
|
8
|
-
import { Field, InputFieldProps } from '../field';
|
|
9
|
-
import { ControllerGeneratorProps, UnControlledComponentProps } from '../form.types';
|
|
10
|
-
|
|
11
|
-
import { InputColorBoxStyle, InputColorSelectorStyle, InputColorStyle } from './input-color.style';
|
|
12
|
-
|
|
13
|
-
import { useInputHandlers } from '@polpo/hooks';
|
|
14
|
-
|
|
15
|
-
type ColorProps = InputFieldProps<{
|
|
16
|
-
showValueText?: boolean;
|
|
17
|
-
}>;
|
|
18
|
-
|
|
19
|
-
export const InputColor = ({
|
|
20
|
-
name,
|
|
21
|
-
value,
|
|
22
|
-
setValue,
|
|
23
|
-
onBlur,
|
|
24
|
-
onFocus,
|
|
25
|
-
showValueText = false,
|
|
26
|
-
className = '',
|
|
27
|
-
style = {},
|
|
28
|
-
autoFocus = false,
|
|
29
|
-
readOnly = false,
|
|
30
|
-
disabled = false,
|
|
31
|
-
placeholder = '',
|
|
32
|
-
autoComplete = 'off',
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
34
|
-
isDirty = false,
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
36
|
-
isTouched = false,
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
38
|
-
invalid = false,
|
|
39
|
-
error,
|
|
40
|
-
...fieldProps
|
|
41
|
-
}: UnControlledComponentProps<ColorProps, string>) => {
|
|
42
|
-
const { open, isSupported } = useEyeDropper();
|
|
43
|
-
const [inputValue, setInputValue] = useState<string>(value);
|
|
44
|
-
const id = useMemo(() => crypto.randomUUID(), []);
|
|
45
|
-
const containerRef = useRef<HTMLElement>(null);
|
|
46
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
47
|
-
const { handlers, isFocus } = useInputHandlers({
|
|
48
|
-
onChange: e => setInputValue(e.target.value),
|
|
49
|
-
onBlur: e => {
|
|
50
|
-
setInputColor();
|
|
51
|
-
onBlur && onBlur(e);
|
|
52
|
-
},
|
|
53
|
-
onFocus: e => {
|
|
54
|
-
setInputColor();
|
|
55
|
-
onFocus && onFocus(e);
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const borderColor = useMemo(() => {
|
|
60
|
-
const color = Color(value === '' ? '#000000' : value);
|
|
61
|
-
|
|
62
|
-
if (color.isLight() || color.alpha() < 0.5) {
|
|
63
|
-
return '#000000';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return '#FFFFFF';
|
|
67
|
-
}, [value]);
|
|
68
|
-
|
|
69
|
-
const openEyeDropper = async () => {
|
|
70
|
-
const { sRGBHex } = await open();
|
|
71
|
-
setValue(sRGBHex);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
setInputValue(value);
|
|
76
|
-
}, [value]);
|
|
77
|
-
|
|
78
|
-
const setInputColor = useCallback(() => {
|
|
79
|
-
if (inputValue.match(/^#(?:(?:[\da-f]{3}){1,2}|(?:[\da-f]{4}){1,2})$/i)) {
|
|
80
|
-
setValue(inputValue);
|
|
81
|
-
} else {
|
|
82
|
-
setInputValue(value);
|
|
83
|
-
}
|
|
84
|
-
}, [inputValue, setValue, value]);
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<Field id={id} error={error} isFocus={isFocus} {...fieldProps}>
|
|
88
|
-
<InputColorStyle
|
|
89
|
-
onClick={e => {
|
|
90
|
-
e.stopPropagation();
|
|
91
|
-
setIsOpen(true);
|
|
92
|
-
}}
|
|
93
|
-
ref={containerRef}
|
|
94
|
-
>
|
|
95
|
-
<InputColorBoxStyle
|
|
96
|
-
className={className}
|
|
97
|
-
style={{
|
|
98
|
-
borderColor,
|
|
99
|
-
background: value,
|
|
100
|
-
color: value,
|
|
101
|
-
...style,
|
|
102
|
-
}}
|
|
103
|
-
/>
|
|
104
|
-
{showValueText ? (
|
|
105
|
-
<input
|
|
106
|
-
id={id}
|
|
107
|
-
name={name}
|
|
108
|
-
value={inputValue}
|
|
109
|
-
placeholder={placeholder}
|
|
110
|
-
readOnly={readOnly}
|
|
111
|
-
autoFocus={autoFocus}
|
|
112
|
-
disabled={disabled}
|
|
113
|
-
autoComplete={autoComplete}
|
|
114
|
-
className='color-input'
|
|
115
|
-
{...handlers}
|
|
116
|
-
/>
|
|
117
|
-
) : null}
|
|
118
|
-
</InputColorStyle>
|
|
119
|
-
|
|
120
|
-
<InputColorSelectorStyle
|
|
121
|
-
id='input-color'
|
|
122
|
-
isOpen={isOpen}
|
|
123
|
-
onClose={() => setIsOpen(false)}
|
|
124
|
-
position='bottom right'
|
|
125
|
-
offset={5}
|
|
126
|
-
backdrop='transparent'
|
|
127
|
-
containerRef={containerRef}
|
|
128
|
-
>
|
|
129
|
-
<HexAlphaColorPicker id={id} color={value} onChange={setValue} />
|
|
130
|
-
<section className='color-input-container'>
|
|
131
|
-
{isSupported() ? (
|
|
132
|
-
<Icon
|
|
133
|
-
name='dropper'
|
|
134
|
-
onClick={() => {
|
|
135
|
-
void openEyeDropper();
|
|
136
|
-
}}
|
|
137
|
-
/>
|
|
138
|
-
) : (
|
|
139
|
-
<span />
|
|
140
|
-
)}
|
|
141
|
-
<HexColorInput
|
|
142
|
-
className='color-input'
|
|
143
|
-
id={id}
|
|
144
|
-
name={name}
|
|
145
|
-
color={value}
|
|
146
|
-
placeholder='Type a color'
|
|
147
|
-
prefixed
|
|
148
|
-
alpha
|
|
149
|
-
onChange={setValue}
|
|
150
|
-
/>
|
|
151
|
-
<span />
|
|
152
|
-
</section>
|
|
153
|
-
</InputColorSelectorStyle>
|
|
154
|
-
</Field>
|
|
155
|
-
);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const InputColorController = ({ rules, ...props }: ControllerGeneratorProps<ColorProps, string>) => {
|
|
159
|
-
return <Controller Component={InputColor} defaultValue='#147EFB' inputProps={props} rules={rules} />;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
InputColor.Controller = InputColorController;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './input-file';
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { ContainerDecorator, UnControlledComponentArgTypes } from '../form.stories.types';
|
|
4
|
-
|
|
5
|
-
import { InputFile } from './input-file';
|
|
6
|
-
|
|
7
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
8
|
-
|
|
9
|
-
const meta: Meta<typeof InputFile> = {
|
|
10
|
-
title: 'Form/InputFile',
|
|
11
|
-
component: InputFile,
|
|
12
|
-
argTypes: {
|
|
13
|
-
...UnControlledComponentArgTypes,
|
|
14
|
-
label: { control: 'text' },
|
|
15
|
-
accept: { control: 'text' },
|
|
16
|
-
multiple: { control: 'boolean' },
|
|
17
|
-
limitSize: { control: 'number' },
|
|
18
|
-
errorTimeout: { control: 'number' },
|
|
19
|
-
},
|
|
20
|
-
args: {
|
|
21
|
-
label: 'Input File',
|
|
22
|
-
accept: 'image/*',
|
|
23
|
-
multiple: false,
|
|
24
|
-
limitSize: 5000000,
|
|
25
|
-
errorTimeout: 3000,
|
|
26
|
-
},
|
|
27
|
-
decorators: [ContainerDecorator],
|
|
28
|
-
render: args => {
|
|
29
|
-
const [value, setValue] = useState<{ [key: string]: File }>({});
|
|
30
|
-
|
|
31
|
-
return <InputFile {...args} value={value} setValue={setValue} />;
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export default meta;
|
|
36
|
-
type Story = StoryObj<typeof InputFile>;
|
|
37
|
-
|
|
38
|
-
export const Default: Story = {
|
|
39
|
-
args: {},
|
|
40
|
-
};
|