polpo 0.1.7 → 0.1.8
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 +31 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.d.cts +1866 -0
- package/dist/components.d.ts +1866 -0
- package/dist/components.js +31 -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 +4 -0
- package/dist/layouts.cjs.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 +4 -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,41 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { KeyValuesOf } from '../../types';
|
|
4
|
-
import { IconNameT } from '../icon';
|
|
5
|
-
|
|
6
|
-
export type Primitive = string | number | boolean;
|
|
7
|
-
|
|
8
|
-
export type RowDataObject = { [key: string]: Primitive | object };
|
|
9
|
-
|
|
10
|
-
export type Order = 'asc' | 'desc';
|
|
11
|
-
|
|
12
|
-
type ColumnDataCommon<RowData extends RowDataObject> = {
|
|
13
|
-
header: React.ReactNode;
|
|
14
|
-
sortBy?: KeyValuesOf<RowData, Primitive>;
|
|
15
|
-
icon?: IconNameT;
|
|
16
|
-
width?: `${number}px` | `${number}em` | `${number}%`;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type ColumnDataField<RowData extends RowDataObject> = ColumnDataCommon<RowData> & {
|
|
20
|
-
field: KeyValuesOf<RowData, Primitive>;
|
|
21
|
-
sortBy?: never;
|
|
22
|
-
render?: never;
|
|
23
|
-
Component?: never;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
type ColumnDataRender<RowData extends RowDataObject> = ColumnDataCommon<RowData> & {
|
|
27
|
-
field?: never;
|
|
28
|
-
render: (row: RowData, rowKey: React.Key) => React.ReactNode;
|
|
29
|
-
Component?: never;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type ColumnDataComponent<RowData extends RowDataObject> = ColumnDataCommon<RowData> & {
|
|
33
|
-
field?: never;
|
|
34
|
-
render?: never;
|
|
35
|
-
Component: React.FC<{ data: RowData; rowKey: React.Key }>;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type ColumnData<RowData extends RowDataObject> =
|
|
39
|
-
| ColumnDataField<RowData>
|
|
40
|
-
| ColumnDataRender<RowData>
|
|
41
|
-
| ColumnDataComponent<RowData>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './tabs';
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { RadiusVariants, SizeVariants } from '../../core/variants';
|
|
2
|
-
import { Grid } from '../../layouts';
|
|
3
|
-
import { Typography } from '../typography';
|
|
4
|
-
|
|
5
|
-
import { Tabs } from './tabs';
|
|
6
|
-
import { TabListColor, TabListVariant } from './tabs-list';
|
|
7
|
-
|
|
8
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
9
|
-
|
|
10
|
-
const meta: Meta<typeof Tabs.TabList> = {
|
|
11
|
-
title: 'Tabs/Tab List',
|
|
12
|
-
component: Tabs.TabList,
|
|
13
|
-
argTypes: {
|
|
14
|
-
variant: { control: 'inline-radio', options: Object.values(TabListVariant) },
|
|
15
|
-
size: { control: 'inline-radio', options: Object.values(SizeVariants) },
|
|
16
|
-
color: { control: 'inline-radio', options: [undefined, ...Object.values(TabListColor)] },
|
|
17
|
-
radius: { control: 'inline-radio', options: Object.values(RadiusVariants) },
|
|
18
|
-
direction: { control: false },
|
|
19
|
-
tabs: { control: false },
|
|
20
|
-
className: { control: false },
|
|
21
|
-
style: { control: false },
|
|
22
|
-
},
|
|
23
|
-
args: {
|
|
24
|
-
tabs: [
|
|
25
|
-
{ id: 'home', label: 'Home' },
|
|
26
|
-
{ id: 'about', label: 'About us' },
|
|
27
|
-
{ id: 'products', label: 'Products' },
|
|
28
|
-
{ id: 'categories', label: 'Categories' },
|
|
29
|
-
{ id: 'services', label: 'Services' },
|
|
30
|
-
],
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export default meta;
|
|
35
|
-
type Story = StoryObj<typeof Tabs.TabList>;
|
|
36
|
-
|
|
37
|
-
export const Default: Story = {
|
|
38
|
-
args: {},
|
|
39
|
-
decorators: [
|
|
40
|
-
Story => (
|
|
41
|
-
<Grid gap='1em'>
|
|
42
|
-
<Tabs defaultOpenTab='home'>
|
|
43
|
-
<Story />
|
|
44
|
-
|
|
45
|
-
<Tabs.TabPanel id='home'>
|
|
46
|
-
<Typography variant='header4' align='center'>
|
|
47
|
-
Home
|
|
48
|
-
</Typography>
|
|
49
|
-
</Tabs.TabPanel>
|
|
50
|
-
<Tabs.TabPanel id='about'>
|
|
51
|
-
<Typography variant='header4' align='center'>
|
|
52
|
-
About us
|
|
53
|
-
</Typography>
|
|
54
|
-
</Tabs.TabPanel>
|
|
55
|
-
<Tabs.TabPanel id='products'>
|
|
56
|
-
<Typography variant='header4' align='center'>
|
|
57
|
-
Products
|
|
58
|
-
</Typography>
|
|
59
|
-
</Tabs.TabPanel>
|
|
60
|
-
<Tabs.TabPanel id='categories'>
|
|
61
|
-
<Typography variant='header4' align='center'>
|
|
62
|
-
Categories
|
|
63
|
-
</Typography>
|
|
64
|
-
</Tabs.TabPanel>
|
|
65
|
-
<Tabs.TabPanel id='services'>
|
|
66
|
-
<Typography variant='header4' align='center'>
|
|
67
|
-
Services
|
|
68
|
-
</Typography>
|
|
69
|
-
</Tabs.TabPanel>
|
|
70
|
-
</Tabs>
|
|
71
|
-
</Grid>
|
|
72
|
-
),
|
|
73
|
-
],
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const Vertical: Story = {
|
|
77
|
-
args: {
|
|
78
|
-
direction: 'vertical',
|
|
79
|
-
},
|
|
80
|
-
decorators: [
|
|
81
|
-
Story => (
|
|
82
|
-
<Grid gtc='auto 1fr' gap='2em' style={{ width: 700 }}>
|
|
83
|
-
<Tabs defaultOpenTab='home'>
|
|
84
|
-
<Story />
|
|
85
|
-
|
|
86
|
-
<Tabs.TabPanel id='home'>
|
|
87
|
-
<section>
|
|
88
|
-
<Typography variant='header4'>Home</Typography>
|
|
89
|
-
<Typography>
|
|
90
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. At blanditiis, dolorem eius incidunt ipsum
|
|
91
|
-
labore maiores, modi nemo nisi nulla quia sunt, tenetur veritatis? Architecto asperiores excepturi quo.
|
|
92
|
-
Magni, maxime possimus! Adipisci facere laborum modi quod unde, velit veritatis! Voluptate!
|
|
93
|
-
</Typography>
|
|
94
|
-
</section>
|
|
95
|
-
</Tabs.TabPanel>
|
|
96
|
-
<Tabs.TabPanel id='about'>
|
|
97
|
-
<section>
|
|
98
|
-
<Typography variant='header4'>About us</Typography>
|
|
99
|
-
<Typography>
|
|
100
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. At, debitis eligendi est eum, facere inventore
|
|
101
|
-
iste neque nobis, rerum tempore vel voluptas voluptates. Maiores minima molestias mollitia nisi quidem
|
|
102
|
-
unde voluptatibus. Aliquam assumenda dolores earum ex laboriosam quidem quod repellendus!
|
|
103
|
-
</Typography>
|
|
104
|
-
</section>
|
|
105
|
-
</Tabs.TabPanel>
|
|
106
|
-
<Tabs.TabPanel id='products'>
|
|
107
|
-
<section>
|
|
108
|
-
<Typography variant='header4'>Products</Typography>
|
|
109
|
-
<Typography>
|
|
110
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Amet cumque cupiditate dolorum exercitationem
|
|
111
|
-
in laboriosam maxime, odio odit quod vitae. Autem consequuntur doloremque dolores, doloribus excepturi
|
|
112
|
-
fuga molestias natus nesciunt nulla obcaecati, odio quaerat quisquam reprehenderit sit tempore ullam
|
|
113
|
-
voluptas.
|
|
114
|
-
</Typography>
|
|
115
|
-
</section>
|
|
116
|
-
</Tabs.TabPanel>
|
|
117
|
-
<Tabs.TabPanel id='categories'>
|
|
118
|
-
<section>
|
|
119
|
-
<Typography variant='header4'>Categories</Typography>
|
|
120
|
-
<Typography>
|
|
121
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Autem cupiditate eius maxime repudiandae unde.
|
|
122
|
-
Ducimus eius eos illo incidunt qui! Dicta doloremque ea eaque earum error impedit iure, laboriosam
|
|
123
|
-
magnam maiores, odit quaerat quidem quos repudiandae sed temporibus ut voluptates.
|
|
124
|
-
</Typography>
|
|
125
|
-
</section>
|
|
126
|
-
</Tabs.TabPanel>
|
|
127
|
-
<Tabs.TabPanel id='services'>
|
|
128
|
-
<section>
|
|
129
|
-
<Typography variant='header4'>Services</Typography>
|
|
130
|
-
<Typography>
|
|
131
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam amet aperiam architecto autem
|
|
132
|
-
blanditiis cupiditate dicta eius et facere in incidunt laborum libero, maiores nam nulla odit
|
|
133
|
-
praesentium, quae quis sapiente sed tenetur ullam ut. Deleniti optio possimus quae sequi!
|
|
134
|
-
</Typography>
|
|
135
|
-
</section>
|
|
136
|
-
</Tabs.TabPanel>
|
|
137
|
-
</Tabs>
|
|
138
|
-
</Grid>
|
|
139
|
-
),
|
|
140
|
-
],
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export const Variants: Story = {
|
|
144
|
-
argTypes: {
|
|
145
|
-
variant: { control: false },
|
|
146
|
-
},
|
|
147
|
-
args: {},
|
|
148
|
-
decorators: Default.decorators,
|
|
149
|
-
render: args => {
|
|
150
|
-
return (
|
|
151
|
-
<Grid gap='1em'>
|
|
152
|
-
<Tabs.TabList {...args} variant='solid' />
|
|
153
|
-
<Tabs.TabList {...args} variant='ghost' />
|
|
154
|
-
<Tabs.TabList {...args} variant='flat' />
|
|
155
|
-
<Tabs.TabList {...args} variant='line' />
|
|
156
|
-
</Grid>
|
|
157
|
-
);
|
|
158
|
-
},
|
|
159
|
-
};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { useTheme } from 'styled-components';
|
|
3
|
-
|
|
4
|
-
import { ThemeColor } from '../../contexts';
|
|
5
|
-
import { RadiusVariants, SizeVariants } from '../../core/variants';
|
|
6
|
-
|
|
7
|
-
import { Tabs } from './tabs';
|
|
8
|
-
import { TabListStyle, TabListColorStyle } from './tabs.style';
|
|
9
|
-
|
|
10
|
-
import { useClassNames } from '@polpo/hooks';
|
|
11
|
-
|
|
12
|
-
const DefaultRect = {
|
|
13
|
-
top: 0,
|
|
14
|
-
left: 0,
|
|
15
|
-
width: 0,
|
|
16
|
-
height: 0,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export enum TabListVariant {
|
|
20
|
-
SOLID = 'solid',
|
|
21
|
-
GHOST = 'ghost',
|
|
22
|
-
FLAT = 'flat',
|
|
23
|
-
LINE = 'line',
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export enum TabListColor {
|
|
27
|
-
PRIMARY = 'primary',
|
|
28
|
-
SECONDARY = 'secondary',
|
|
29
|
-
TERTIARY = 'tertiary',
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export enum TabListDirection {
|
|
33
|
-
HORIZONTAL = 'horizontal',
|
|
34
|
-
VERTICAL = 'vertical',
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const getColor = (color?: ThemeColor): TabListColorStyle | null => {
|
|
38
|
-
if (color) {
|
|
39
|
-
return {
|
|
40
|
-
$color: color.main,
|
|
41
|
-
$colorContrast: color.contrast,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return null;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export type TabListProps = {
|
|
49
|
-
openTab: string;
|
|
50
|
-
variant?: `${TabListVariant}`;
|
|
51
|
-
children?: React.ReactNode;
|
|
52
|
-
size?: `${SizeVariants}`;
|
|
53
|
-
color?: `${TabListColor}`;
|
|
54
|
-
radius?: `${RadiusVariants}`;
|
|
55
|
-
direction?: `${TabListDirection}`;
|
|
56
|
-
className?: string;
|
|
57
|
-
style?: React.CSSProperties;
|
|
58
|
-
tabs?: Array<{
|
|
59
|
-
id: string;
|
|
60
|
-
label: React.ReactNode;
|
|
61
|
-
}>;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const TabsList = ({
|
|
65
|
-
tabs = [],
|
|
66
|
-
variant = TabListVariant.SOLID,
|
|
67
|
-
radius = RadiusVariants.Full,
|
|
68
|
-
direction = TabListDirection.HORIZONTAL,
|
|
69
|
-
color,
|
|
70
|
-
children,
|
|
71
|
-
openTab,
|
|
72
|
-
size = SizeVariants.Medium,
|
|
73
|
-
className = '',
|
|
74
|
-
style = {},
|
|
75
|
-
}: TabListProps) => {
|
|
76
|
-
const theme = useTheme();
|
|
77
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
78
|
-
const selectedTabRef = useRef<HTMLSpanElement>(null);
|
|
79
|
-
const [isSelectorActive, setIsSelectorActive] = useState(false);
|
|
80
|
-
const [selector, setSelector] = useState(DefaultRect);
|
|
81
|
-
const containerClassNames = useClassNames({
|
|
82
|
-
'solid-variant': variant === TabListVariant.SOLID,
|
|
83
|
-
'ghost-variant': variant === TabListVariant.GHOST,
|
|
84
|
-
'flat-variant': variant === TabListVariant.FLAT,
|
|
85
|
-
'line-variant': variant === TabListVariant.LINE,
|
|
86
|
-
'vertical-direction': direction === TabListDirection.VERTICAL,
|
|
87
|
-
[className]: Boolean(className),
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
const selectedRect = selectedTabRef.current?.getBoundingClientRect() ?? DefaultRect;
|
|
92
|
-
const containerRect = containerRef.current?.getBoundingClientRect() ?? DefaultRect;
|
|
93
|
-
|
|
94
|
-
const width = selectedRect.width;
|
|
95
|
-
const height = variant === TabListVariant.LINE ? 2 : selectedRect.height;
|
|
96
|
-
const left = selectedRect.left - containerRect.left;
|
|
97
|
-
const top =
|
|
98
|
-
variant === TabListVariant.LINE
|
|
99
|
-
? selectedRect.top + selectedRect.height - containerRect.top
|
|
100
|
-
: selectedRect.top - containerRect.top;
|
|
101
|
-
|
|
102
|
-
setSelector({ left, top, width, height });
|
|
103
|
-
|
|
104
|
-
if (!isSelectorActive) {
|
|
105
|
-
setTimeout(() => {
|
|
106
|
-
setIsSelectorActive(true);
|
|
107
|
-
}, 100);
|
|
108
|
-
}
|
|
109
|
-
}, [isSelectorActive, variant, openTab]);
|
|
110
|
-
|
|
111
|
-
const containerColors: TabListColorStyle = (color && getColor(theme.colors[color])) || {
|
|
112
|
-
$color: theme.colors.text.main,
|
|
113
|
-
$colorContrast: theme.colors.background.main,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<TabListStyle
|
|
118
|
-
{...containerColors}
|
|
119
|
-
className={containerClassNames}
|
|
120
|
-
ref={containerRef}
|
|
121
|
-
style={style}
|
|
122
|
-
$size={size}
|
|
123
|
-
$radius={radius}
|
|
124
|
-
>
|
|
125
|
-
{Boolean(variant) && <span className={`tabs-selector ${isSelectorActive ? 'active' : ''}`} style={selector} />}
|
|
126
|
-
{tabs.map(({ id, label }) => (
|
|
127
|
-
<Tabs.Tab key={id} id={id} ref={id === openTab ? selectedTabRef : null}>
|
|
128
|
-
{label}
|
|
129
|
-
</Tabs.Tab>
|
|
130
|
-
))}
|
|
131
|
-
{children}
|
|
132
|
-
</TabListStyle>
|
|
133
|
-
);
|
|
134
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Grid } from '../../layouts';
|
|
4
|
-
import { Button } from '../buttons';
|
|
5
|
-
import { Typography } from '../typography';
|
|
6
|
-
|
|
7
|
-
import { Tabs } from './tabs';
|
|
8
|
-
|
|
9
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
10
|
-
|
|
11
|
-
const meta: Meta<typeof Tabs> = {
|
|
12
|
-
title: 'Tabs/Custom Tabs',
|
|
13
|
-
component: Tabs,
|
|
14
|
-
argTypes: {},
|
|
15
|
-
args: {},
|
|
16
|
-
render: () => {
|
|
17
|
-
const [selected, setSelected] = useState('');
|
|
18
|
-
|
|
19
|
-
const getButtonVariant = (id: string) => {
|
|
20
|
-
return selected === id ? 'solid' : 'ghost';
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<Tabs defaultOpenTab='tab-1' onChange={setSelected}>
|
|
25
|
-
<Grid flow='column' gap='1em' ai='center'>
|
|
26
|
-
<Tabs.Tab id='tab-1'>
|
|
27
|
-
<Button color='primary' variant={getButtonVariant('tab-1')}>
|
|
28
|
-
Tab 1
|
|
29
|
-
</Button>
|
|
30
|
-
</Tabs.Tab>
|
|
31
|
-
<Tabs.Tab id='tab-2'>
|
|
32
|
-
<Button color='primary' variant={getButtonVariant('tab-2')}>
|
|
33
|
-
Tab 2
|
|
34
|
-
</Button>
|
|
35
|
-
</Tabs.Tab>
|
|
36
|
-
<Tabs.Tab id='tab-3'>
|
|
37
|
-
<Button color='primary' variant={getButtonVariant('tab-3')}>
|
|
38
|
-
Tab 3
|
|
39
|
-
</Button>
|
|
40
|
-
</Tabs.Tab>
|
|
41
|
-
</Grid>
|
|
42
|
-
|
|
43
|
-
<Tabs.TabPanel id='tab-1'>
|
|
44
|
-
<Typography variant='header4' align='center'>
|
|
45
|
-
Tab 1 content
|
|
46
|
-
</Typography>
|
|
47
|
-
</Tabs.TabPanel>
|
|
48
|
-
<Tabs.TabPanel id='tab-2'>
|
|
49
|
-
<Typography variant='header4' align='center'>
|
|
50
|
-
Tab 2 content
|
|
51
|
-
</Typography>
|
|
52
|
-
</Tabs.TabPanel>
|
|
53
|
-
<Tabs.TabPanel id='tab-3'>
|
|
54
|
-
<Typography variant='header4' align='center'>
|
|
55
|
-
Tab 3 content
|
|
56
|
-
</Typography>
|
|
57
|
-
</Tabs.TabPanel>
|
|
58
|
-
</Tabs>
|
|
59
|
-
);
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export default meta;
|
|
64
|
-
type Story = StoryObj<typeof Tabs>;
|
|
65
|
-
|
|
66
|
-
export const Default: Story = {
|
|
67
|
-
args: {},
|
|
68
|
-
};
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { RadiusVariants, SizeStyles, SizeVariants } from '../../core/variants';
|
|
4
|
-
|
|
5
|
-
export const TabStyle = styled.span`
|
|
6
|
-
cursor: pointer;
|
|
7
|
-
user-select: none;
|
|
8
|
-
transition: all 300ms ease;
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
const RadiusStyles: Record<RadiusVariants, ReturnType<typeof css>> = {
|
|
12
|
-
[RadiusVariants.None]: css`
|
|
13
|
-
border-radius: 0;
|
|
14
|
-
|
|
15
|
-
${TabStyle}, .tabs-selector {
|
|
16
|
-
border-radius: 0;
|
|
17
|
-
}
|
|
18
|
-
`,
|
|
19
|
-
[RadiusVariants.Small]: css`
|
|
20
|
-
border-radius: 0.5em;
|
|
21
|
-
|
|
22
|
-
${TabStyle}, .tabs-selector {
|
|
23
|
-
border-radius: 0.3em;
|
|
24
|
-
}
|
|
25
|
-
`,
|
|
26
|
-
[RadiusVariants.Medium]: css`
|
|
27
|
-
border-radius: 1em;
|
|
28
|
-
|
|
29
|
-
${TabStyle}, .tabs-selector {
|
|
30
|
-
border-radius: 0.8em;
|
|
31
|
-
}
|
|
32
|
-
`,
|
|
33
|
-
[RadiusVariants.Large]: css`
|
|
34
|
-
border-radius: 1.5em;
|
|
35
|
-
|
|
36
|
-
${TabStyle}, .tabs-selector {
|
|
37
|
-
border-radius: 1.3em;
|
|
38
|
-
}
|
|
39
|
-
`,
|
|
40
|
-
[RadiusVariants.Full]: css`
|
|
41
|
-
border-radius: 1.8em;
|
|
42
|
-
|
|
43
|
-
${TabStyle}, .tabs-selector {
|
|
44
|
-
border-radius: 1.6em;
|
|
45
|
-
}
|
|
46
|
-
`,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type TabListColorStyle = {
|
|
50
|
-
$color: string;
|
|
51
|
-
$colorContrast: string;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export type TabListStyleProps = TabListColorStyle & {
|
|
55
|
-
$size: `${SizeVariants}`;
|
|
56
|
-
$radius: `${RadiusVariants}`;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const TabListStyle = styled.section<TabListStyleProps>`
|
|
60
|
-
display: grid;
|
|
61
|
-
grid-auto-flow: column;
|
|
62
|
-
gap: 1em;
|
|
63
|
-
align-items: center;
|
|
64
|
-
position: relative;
|
|
65
|
-
font-size: ${props => props.theme.constants.typography.label.fontSize};
|
|
66
|
-
border-radius: 2em;
|
|
67
|
-
|
|
68
|
-
${props => SizeStyles[props.$size]}
|
|
69
|
-
|
|
70
|
-
.tabs-selector {
|
|
71
|
-
position: absolute;
|
|
72
|
-
background: ${props => props.$color};
|
|
73
|
-
color: ${props => props.$colorContrast};
|
|
74
|
-
border-radius: 1.5em;
|
|
75
|
-
|
|
76
|
-
&.active {
|
|
77
|
-
transition: all 300ms ease;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
${TabStyle} {
|
|
82
|
-
border-radius: 1.5em;
|
|
83
|
-
padding: 0.5em 1em;
|
|
84
|
-
z-index: 1;
|
|
85
|
-
text-align: center;
|
|
86
|
-
|
|
87
|
-
&.is-open {
|
|
88
|
-
color: ${props => props.$colorContrast};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
&:not(.is-open):hover {
|
|
92
|
-
color: ${props => props.theme.colors.text.dark};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
${props => RadiusStyles[props.$radius]}
|
|
97
|
-
|
|
98
|
-
&.vertical-direction {
|
|
99
|
-
grid-auto-flow: row;
|
|
100
|
-
align-items: unset;
|
|
101
|
-
align-content: start;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
&.solid-variant {
|
|
105
|
-
background: ${props => props.theme.colors.background.paper};
|
|
106
|
-
color: ${props => props.theme.colors.text.main};
|
|
107
|
-
padding: 0.5em;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
&.ghost-variant {
|
|
111
|
-
border: 1px solid ${props => props.$color};
|
|
112
|
-
padding: 0.5em;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
&.flat-variant {
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
&.line-variant {
|
|
119
|
-
border-radius: 0;
|
|
120
|
-
|
|
121
|
-
&:not(.vertical-direction) {
|
|
122
|
-
border-bottom: 2px solid ${props => props.theme.colors.border.main};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.tabs-selector {
|
|
126
|
-
border-radius: 0;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
${TabStyle} {
|
|
130
|
-
border-radius: 0;
|
|
131
|
-
|
|
132
|
-
&.is-open {
|
|
133
|
-
color: ${props => props.$color};
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
`;
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { TabsList as TabListComponent, TabListProps } from './tabs-list';
|
|
4
|
-
import { TabStyle } from './tabs.style';
|
|
5
|
-
|
|
6
|
-
import { useClassNames } from '@polpo/hooks';
|
|
7
|
-
|
|
8
|
-
type TabsContextState = {
|
|
9
|
-
openTab: string;
|
|
10
|
-
changeOpenTab: (id: string) => void;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const TabsContext = createContext<TabsContextState | null>(null);
|
|
14
|
-
|
|
15
|
-
const useTab = (id: string): [boolean, () => void] => {
|
|
16
|
-
const context = useContext(TabsContext);
|
|
17
|
-
|
|
18
|
-
if (!context) {
|
|
19
|
-
throw new Error('You cant use this component out off an Tabs component');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const { openTab, changeOpenTab } = context;
|
|
23
|
-
|
|
24
|
-
return [openTab === id, () => changeOpenTab(id)];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const useTabsContext = (): TabsContextState => {
|
|
28
|
-
const context = useContext(TabsContext);
|
|
29
|
-
|
|
30
|
-
if (!context) {
|
|
31
|
-
throw new Error('You cant use this component out off an Tabs component');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return context;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
type TabsProps = {
|
|
38
|
-
children: React.ReactNode;
|
|
39
|
-
defaultOpenTab: string;
|
|
40
|
-
onChange?: (id: string) => void;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const Tabs = ({ children, defaultOpenTab, onChange }: TabsProps) => {
|
|
44
|
-
const [openTab, setOpenTab] = useState(defaultOpenTab);
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
onChange && onChange(openTab);
|
|
48
|
-
}, [openTab, onChange]);
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<TabsContext.Provider
|
|
52
|
-
value={{
|
|
53
|
-
openTab,
|
|
54
|
-
changeOpenTab: id => setOpenTab(id),
|
|
55
|
-
}}
|
|
56
|
-
>
|
|
57
|
-
{children}
|
|
58
|
-
</TabsContext.Provider>
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
type TabProps = {
|
|
63
|
-
id: string;
|
|
64
|
-
children: React.ReactNode;
|
|
65
|
-
className?: string;
|
|
66
|
-
style?: React.CSSProperties;
|
|
67
|
-
onClick?: (e: React.MouseEvent<HTMLSpanElement>) => void;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const TabComponent = (
|
|
71
|
-
{ id, children, className = '', style = {}, onClick }: TabProps,
|
|
72
|
-
ref: React.ForwardedRef<HTMLSpanElement>,
|
|
73
|
-
) => {
|
|
74
|
-
const [isOpen, openTab] = useTab(id);
|
|
75
|
-
const tabClassNames = useClassNames({
|
|
76
|
-
[className]: !!className,
|
|
77
|
-
'is-open': isOpen,
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const handleClick = (e: React.MouseEvent<HTMLSpanElement>) => {
|
|
81
|
-
openTab();
|
|
82
|
-
onClick && onClick(e);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<TabStyle className={tabClassNames} style={style} onClick={handleClick} ref={ref}>
|
|
87
|
-
{children}
|
|
88
|
-
</TabStyle>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const Tab = React.forwardRef(TabComponent);
|
|
93
|
-
|
|
94
|
-
type TabPanelProps = {
|
|
95
|
-
id: string;
|
|
96
|
-
children: React.ReactNode;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const TabPanel = ({ id, children }: TabPanelProps) => {
|
|
100
|
-
const [isOpen] = useTab(id);
|
|
101
|
-
|
|
102
|
-
return isOpen ? children : null;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const TabList = ({ children, ...props }: Omit<TabListProps, 'openTab'>) => {
|
|
106
|
-
const { openTab } = useTabsContext();
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<TabListComponent {...props} openTab={openTab}>
|
|
110
|
-
{children}
|
|
111
|
-
</TabListComponent>
|
|
112
|
-
);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
Tabs.Tab = Tab;
|
|
116
|
-
Tabs.TabPanel = TabPanel;
|
|
117
|
-
Tabs.TabList = TabList;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './tag';
|