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,211 +0,0 @@
|
|
|
1
|
-
export enum PositionContainer {
|
|
2
|
-
CENTER = 'center',
|
|
3
|
-
TOP = 'top',
|
|
4
|
-
TOP_LEFT = 'top left',
|
|
5
|
-
TOP_RIGHT = 'top right',
|
|
6
|
-
TOP_CENTER = 'top center',
|
|
7
|
-
LEFT = 'left',
|
|
8
|
-
LEFT_TOP = 'left top',
|
|
9
|
-
LEFT_BOTTOM = 'left bottom',
|
|
10
|
-
LEFT_CENTER = 'left center',
|
|
11
|
-
RIGHT = 'right',
|
|
12
|
-
RIGHT_TOP = 'right top',
|
|
13
|
-
RIGHT_BOTTOM = 'right bottom',
|
|
14
|
-
RIGHT_CENTER = 'right center',
|
|
15
|
-
BOTTOM = 'bottom',
|
|
16
|
-
BOTTOM_LEFT = 'bottom left',
|
|
17
|
-
BOTTOM_RIGHT = 'bottom right',
|
|
18
|
-
BOTTOM_CENTER = 'bottom center',
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type PositionObject = {
|
|
22
|
-
x: number;
|
|
23
|
-
y: number;
|
|
24
|
-
top: number;
|
|
25
|
-
left: number;
|
|
26
|
-
w: number;
|
|
27
|
-
h: number;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type ModalPosition = {
|
|
31
|
-
left: number;
|
|
32
|
-
top: number;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type GetModalPositionParams = {
|
|
36
|
-
c: PositionObject;
|
|
37
|
-
m: PositionObject;
|
|
38
|
-
offset: number;
|
|
39
|
-
position: PositionContainer;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/*
|
|
43
|
-
* @description Calculates the position of the modal relative to the container
|
|
44
|
-
*
|
|
45
|
-
* @param c - The container's position object
|
|
46
|
-
* @param m - The modal's position object
|
|
47
|
-
* @param offset - The offset between the container and the modal
|
|
48
|
-
* @param position - The position of the modal
|
|
49
|
-
*
|
|
50
|
-
* -----------------------------------------------------------------------------
|
|
51
|
-
* @returns The position of the modal relative to the container
|
|
52
|
-
*/
|
|
53
|
-
export const getModalPosition = ({ c, m, offset, position }: GetModalPositionParams): ModalPosition => {
|
|
54
|
-
// Default bottom
|
|
55
|
-
let top = c.y + c.h + offset;
|
|
56
|
-
let left = c.x - (m.w - c.w) * (50 / 100);
|
|
57
|
-
|
|
58
|
-
switch (position) {
|
|
59
|
-
case PositionContainer.TOP:
|
|
60
|
-
case PositionContainer.TOP_CENTER:
|
|
61
|
-
top = c.y - m.h - offset;
|
|
62
|
-
left = c.x - (m.w - c.w) / 2;
|
|
63
|
-
|
|
64
|
-
break;
|
|
65
|
-
case PositionContainer.TOP_LEFT:
|
|
66
|
-
top = c.y - m.h - offset;
|
|
67
|
-
left = c.x - m.w + c.w;
|
|
68
|
-
|
|
69
|
-
break;
|
|
70
|
-
|
|
71
|
-
case PositionContainer.TOP_RIGHT:
|
|
72
|
-
top = c.y - m.h - offset;
|
|
73
|
-
left = c.x;
|
|
74
|
-
|
|
75
|
-
break;
|
|
76
|
-
|
|
77
|
-
case PositionContainer.BOTTOM:
|
|
78
|
-
case PositionContainer.BOTTOM_CENTER:
|
|
79
|
-
top = c.y + c.h + offset;
|
|
80
|
-
left = c.x - (m.w - c.w) / 2;
|
|
81
|
-
|
|
82
|
-
break;
|
|
83
|
-
|
|
84
|
-
case PositionContainer.BOTTOM_LEFT:
|
|
85
|
-
top = c.y + c.h + offset;
|
|
86
|
-
left = c.x - m.w + c.w;
|
|
87
|
-
|
|
88
|
-
break;
|
|
89
|
-
|
|
90
|
-
case PositionContainer.BOTTOM_RIGHT:
|
|
91
|
-
top = c.y + c.h + offset;
|
|
92
|
-
left = c.x;
|
|
93
|
-
|
|
94
|
-
break;
|
|
95
|
-
|
|
96
|
-
case PositionContainer.LEFT:
|
|
97
|
-
case PositionContainer.LEFT_CENTER:
|
|
98
|
-
top = c.y - (m.h - c.h) / 2;
|
|
99
|
-
left = c.x - m.w - offset;
|
|
100
|
-
|
|
101
|
-
break;
|
|
102
|
-
|
|
103
|
-
case PositionContainer.LEFT_TOP:
|
|
104
|
-
top = c.y - m.h + c.h;
|
|
105
|
-
left = c.x - m.w - offset;
|
|
106
|
-
|
|
107
|
-
break;
|
|
108
|
-
|
|
109
|
-
case PositionContainer.LEFT_BOTTOM:
|
|
110
|
-
top = c.y;
|
|
111
|
-
left = c.x - m.w - offset;
|
|
112
|
-
|
|
113
|
-
break;
|
|
114
|
-
|
|
115
|
-
case PositionContainer.RIGHT:
|
|
116
|
-
case PositionContainer.RIGHT_CENTER:
|
|
117
|
-
top = c.y - (m.h - c.h) / 2;
|
|
118
|
-
left = c.x + c.w + offset;
|
|
119
|
-
|
|
120
|
-
break;
|
|
121
|
-
|
|
122
|
-
case PositionContainer.RIGHT_TOP:
|
|
123
|
-
top = c.y - m.h + c.h;
|
|
124
|
-
left = c.x + c.w + offset;
|
|
125
|
-
|
|
126
|
-
break;
|
|
127
|
-
|
|
128
|
-
case PositionContainer.RIGHT_BOTTOM:
|
|
129
|
-
top = c.y;
|
|
130
|
-
left = c.x + c.w + offset;
|
|
131
|
-
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return {
|
|
136
|
-
left: Math.round(left),
|
|
137
|
-
top: Math.round(top),
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
export const getOppositePosition = (
|
|
142
|
-
{ top, left }: ModalPosition,
|
|
143
|
-
position: PositionContainer,
|
|
144
|
-
windowOffset: number,
|
|
145
|
-
m: PositionObject,
|
|
146
|
-
) => {
|
|
147
|
-
const positions = position.split(' ');
|
|
148
|
-
const newPosition = [];
|
|
149
|
-
const rightOffset = left + m.w + windowOffset - window.innerWidth;
|
|
150
|
-
const bottomOffset = top + m.h + windowOffset - window.innerHeight;
|
|
151
|
-
|
|
152
|
-
for (const p of positions) {
|
|
153
|
-
if (p === PositionContainer.TOP && top < windowOffset) {
|
|
154
|
-
newPosition.push(PositionContainer.BOTTOM);
|
|
155
|
-
} else if (p === PositionContainer.LEFT && left < windowOffset) {
|
|
156
|
-
newPosition.push(PositionContainer.RIGHT);
|
|
157
|
-
} else if (p === PositionContainer.BOTTOM && bottomOffset > 0) {
|
|
158
|
-
newPosition.push(PositionContainer.TOP);
|
|
159
|
-
} else if (p === PositionContainer.RIGHT && rightOffset > 0) {
|
|
160
|
-
newPosition.push(PositionContainer.LEFT);
|
|
161
|
-
} else {
|
|
162
|
-
newPosition.push(p);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return newPosition.join(' ') as PositionContainer;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
export const fixModalPosition = ({ top, left }: ModalPosition, m: PositionObject, windowOffset: number) => {
|
|
170
|
-
const rightOffset = left + m.w + windowOffset - window.innerWidth;
|
|
171
|
-
const bottomOffset = top + m.h + windowOffset - window.innerHeight;
|
|
172
|
-
|
|
173
|
-
left = rightOffset > 0 ? left - rightOffset : left;
|
|
174
|
-
top = bottomOffset > 0 ? top - bottomOffset : top;
|
|
175
|
-
|
|
176
|
-
left = left < windowOffset ? windowOffset : left;
|
|
177
|
-
top = top < windowOffset ? windowOffset : top;
|
|
178
|
-
|
|
179
|
-
return { top, left };
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
type getModalPositionRelativeToContainerParams = GetModalPositionParams & {
|
|
183
|
-
windowOffset: number;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
export const getModalPositionRelativeToContainer = ({
|
|
187
|
-
c,
|
|
188
|
-
m,
|
|
189
|
-
offset,
|
|
190
|
-
windowOffset,
|
|
191
|
-
position,
|
|
192
|
-
}: getModalPositionRelativeToContainerParams): Record<string, string> => {
|
|
193
|
-
const params = { c, m, offset, position };
|
|
194
|
-
let modalContainerStyle = getModalPosition(params);
|
|
195
|
-
|
|
196
|
-
const oppositePosition = getOppositePosition(modalContainerStyle, position, windowOffset, m);
|
|
197
|
-
|
|
198
|
-
if (oppositePosition !== position) {
|
|
199
|
-
modalContainerStyle = getModalPosition({
|
|
200
|
-
...params,
|
|
201
|
-
position: oppositePosition,
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const fixedPosition = fixModalPosition(modalContainerStyle, m, windowOffset);
|
|
206
|
-
|
|
207
|
-
return {
|
|
208
|
-
left: `${fixedPosition.left}px`,
|
|
209
|
-
top: `${fixedPosition.top}px`,
|
|
210
|
-
};
|
|
211
|
-
};
|
package/src/helpers/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './to-capitalize';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type ToCapitalizeOptions = Partial<{
|
|
2
|
-
separator: string;
|
|
3
|
-
join: string;
|
|
4
|
-
variant: 'first-word' | 'each-word';
|
|
5
|
-
}>;
|
|
6
|
-
|
|
7
|
-
export const toCapitalize = (text: string, options: ToCapitalizeOptions = {}) => {
|
|
8
|
-
const { separator = ' ', variant = 'each-word', join = separator } = options;
|
|
9
|
-
|
|
10
|
-
if (variant === 'first-word') {
|
|
11
|
-
return text[0].toUpperCase() + text.slice(1);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const words = text.split(separator);
|
|
15
|
-
|
|
16
|
-
return words.map(word => word[0].toUpperCase() + word.slice(1)).join(join);
|
|
17
|
-
};
|
package/src/hooks/index.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export * from './use-async';
|
|
2
|
-
export * from './use-classnames';
|
|
3
|
-
export * from './use-click-outside';
|
|
4
|
-
export * from './use-constant';
|
|
5
|
-
export * from './use-cookie';
|
|
6
|
-
export * from './use-debounce';
|
|
7
|
-
export * from './use-dimensions';
|
|
8
|
-
export * from './use-dom-container';
|
|
9
|
-
export * from './use-event-listener';
|
|
10
|
-
export * from './use-file-reader';
|
|
11
|
-
export * from './use-geolocation';
|
|
12
|
-
export * from './use-hover';
|
|
13
|
-
export * from './use-in-view';
|
|
14
|
-
export * from './use-input-handlers';
|
|
15
|
-
export * from './use-intersection-observer';
|
|
16
|
-
export * from './use-media-query';
|
|
17
|
-
export * from './use-modal';
|
|
18
|
-
export * from './use-modal-in-container';
|
|
19
|
-
export * from './use-modal-transition';
|
|
20
|
-
export * from './use-mouse-position';
|
|
21
|
-
export * from './use-online-status';
|
|
22
|
-
export * from './use-render-count';
|
|
23
|
-
export * from './use-resize-observer';
|
|
24
|
-
export * from './use-safe-dispatch';
|
|
25
|
-
export * from './use-scroll';
|
|
26
|
-
export * from './use-state-history';
|
|
27
|
-
export * from './use-toggle';
|
|
28
|
-
export * from './use-toggle-values';
|
|
29
|
-
export * from './use-viewport';
|
package/src/hooks/use-async.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useMemo, useReducer } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useSafeDispatch } from './use-safe-dispatch';
|
|
4
|
-
|
|
5
|
-
type AsyncState<T> =
|
|
6
|
-
| {
|
|
7
|
-
status: 'idle' | 'pending';
|
|
8
|
-
data?: null;
|
|
9
|
-
error?: null;
|
|
10
|
-
}
|
|
11
|
-
| {
|
|
12
|
-
status: 'resolved';
|
|
13
|
-
data: T;
|
|
14
|
-
error: null;
|
|
15
|
-
}
|
|
16
|
-
| {
|
|
17
|
-
status: 'rejected';
|
|
18
|
-
data: null;
|
|
19
|
-
error: Error;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
type AsyncAction<T> =
|
|
23
|
-
| { type: 'reset' }
|
|
24
|
-
| { type: 'pending' }
|
|
25
|
-
| { type: 'resolved'; data: T }
|
|
26
|
-
| { type: 'rejected'; error: Error };
|
|
27
|
-
|
|
28
|
-
const asyncReducer = <T>(_state: AsyncState<T>, action: AsyncAction<T>): AsyncState<T> => {
|
|
29
|
-
switch (action.type) {
|
|
30
|
-
case 'pending': {
|
|
31
|
-
return { status: 'pending' as const, data: null, error: null };
|
|
32
|
-
}
|
|
33
|
-
case 'resolved': {
|
|
34
|
-
return { status: 'resolved' as const, data: action.data, error: null };
|
|
35
|
-
}
|
|
36
|
-
case 'rejected': {
|
|
37
|
-
return { status: 'rejected' as const, data: null, error: action.error };
|
|
38
|
-
}
|
|
39
|
-
default: {
|
|
40
|
-
throw new Error(`Unhandled action: ${JSON.stringify(action)}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const useAsync = <T>(
|
|
46
|
-
initialState?: AsyncState<T>,
|
|
47
|
-
): AsyncState<T> & {
|
|
48
|
-
setData: (data: T) => void;
|
|
49
|
-
setError: (error: Error) => void;
|
|
50
|
-
run: (promise: Promise<T>) => void;
|
|
51
|
-
} => {
|
|
52
|
-
const [asyncState, unsafeDispatch] = useReducer<React.Reducer<AsyncState<T>, AsyncAction<T>>>(asyncReducer, {
|
|
53
|
-
status: 'idle',
|
|
54
|
-
data: null,
|
|
55
|
-
error: null,
|
|
56
|
-
...initialState,
|
|
57
|
-
});
|
|
58
|
-
const dispatch = useSafeDispatch(unsafeDispatch);
|
|
59
|
-
|
|
60
|
-
const run = useCallback(
|
|
61
|
-
(promise: Promise<T>) => {
|
|
62
|
-
dispatch({ type: 'pending' });
|
|
63
|
-
promise.then(
|
|
64
|
-
data => {
|
|
65
|
-
dispatch({ type: 'resolved', data });
|
|
66
|
-
},
|
|
67
|
-
(error: Error) => {
|
|
68
|
-
dispatch({ type: 'rejected', error });
|
|
69
|
-
},
|
|
70
|
-
);
|
|
71
|
-
},
|
|
72
|
-
[dispatch],
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const setData = useCallback((data: T) => dispatch({ type: 'resolved', data }), [dispatch]);
|
|
76
|
-
|
|
77
|
-
const setError = useCallback((error: Error) => dispatch({ type: 'rejected', error }), [dispatch]);
|
|
78
|
-
|
|
79
|
-
return useMemo(
|
|
80
|
-
() => ({
|
|
81
|
-
setData,
|
|
82
|
-
setError,
|
|
83
|
-
run,
|
|
84
|
-
...asyncState,
|
|
85
|
-
}),
|
|
86
|
-
[asyncState, run, setData, setError],
|
|
87
|
-
);
|
|
88
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
export const useClassNames = (classes: Record<string, boolean>): string =>
|
|
4
|
-
useMemo<string>(
|
|
5
|
-
() =>
|
|
6
|
-
Object.entries(classes)
|
|
7
|
-
.reduce<Array<string>>(
|
|
8
|
-
(compiledClassNames, [classname, value]) => (value ? [...compiledClassNames, classname] : compiledClassNames),
|
|
9
|
-
[],
|
|
10
|
-
)
|
|
11
|
-
.join(' '),
|
|
12
|
-
[classes],
|
|
13
|
-
);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { RefObject } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useEventListener } from './use-event-listener';
|
|
4
|
-
|
|
5
|
-
const checkIsOutside = (ref: RefObject<HTMLElement>, target: Node) => {
|
|
6
|
-
return ref.current && !ref.current.contains(target);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const useClickOutside = <T extends HTMLElement>(
|
|
10
|
-
ref: RefObject<T> | Array<RefObject<T>>,
|
|
11
|
-
callback: () => void,
|
|
12
|
-
) => {
|
|
13
|
-
useEventListener('keydown', e => {
|
|
14
|
-
if (e.key === 'Escape') {
|
|
15
|
-
callback();
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
useEventListener('mousedown', event => {
|
|
20
|
-
const target = event.target as Node;
|
|
21
|
-
|
|
22
|
-
if (!target?.isConnected) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const isOutside = (Array.isArray(ref) ? ref : [ref]).every(r => checkIsOutside(r, target));
|
|
27
|
-
|
|
28
|
-
if (isOutside) {
|
|
29
|
-
callback();
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
};
|
package/src/hooks/use-cookie.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { useState, useCallback } from 'react';
|
|
2
|
-
|
|
3
|
-
export type CookieOptions = {
|
|
4
|
-
days?: number;
|
|
5
|
-
expires?: Date;
|
|
6
|
-
maxAge?: number;
|
|
7
|
-
path?: string;
|
|
8
|
-
domain?: string;
|
|
9
|
-
secure?: boolean;
|
|
10
|
-
sameSite?: 'strict' | 'lax' | 'none';
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const generateCookieAttributes = (options: CookieOptions): string => {
|
|
14
|
-
const parts: Array<string> = [];
|
|
15
|
-
|
|
16
|
-
if (options.expires instanceof Date) {
|
|
17
|
-
parts.push(`expires=${options.expires.toUTCString()}`);
|
|
18
|
-
} else if (typeof options.days === 'number') {
|
|
19
|
-
const date = new Date();
|
|
20
|
-
date.setTime(date.getTime() + options.days * 24 * 60 * 60 * 1000);
|
|
21
|
-
parts.push(`expires=${date.toUTCString()}`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (typeof options.maxAge === 'number') {
|
|
25
|
-
parts.push(`max-age=${options.maxAge}`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
parts.push(`path=${options.path ?? '/'}`);
|
|
29
|
-
|
|
30
|
-
if (options.domain) {
|
|
31
|
-
parts.push(`domain=${options.domain}`);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (options.secure) {
|
|
35
|
-
parts.push('secure');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (options.sameSite) {
|
|
39
|
-
parts.push(`SameSite=${options.sameSite}`);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return parts.length > 0 ? `; ${parts.join('; ')}` : '';
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const setCookie = (name: string, value: string, options: CookieOptions = {}): void => {
|
|
46
|
-
if (typeof document === 'undefined') {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const encodedValue = encodeURIComponent(value);
|
|
51
|
-
const attributes = generateCookieAttributes(options);
|
|
52
|
-
document.cookie = `${name}=${encodedValue}${attributes}`;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const getCookie = (name: string): string | null => {
|
|
56
|
-
if (typeof document === 'undefined') {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const nameEq = `${name}=`;
|
|
61
|
-
const cookies = document.cookie ? document.cookie.split(';') : [];
|
|
62
|
-
|
|
63
|
-
for (const cookie of cookies) {
|
|
64
|
-
const cookieTrimmed = cookie.trim();
|
|
65
|
-
|
|
66
|
-
if (cookieTrimmed.indexOf(nameEq) === 0) {
|
|
67
|
-
return decodeURIComponent(cookieTrimmed.substring(nameEq.length));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return null;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const deleteCookie = (name: string, options: CookieOptions = {}) => {
|
|
75
|
-
if (typeof document === 'undefined') {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Ensure the same path/domain so that the deletion matches the existing cookie.
|
|
80
|
-
setCookie(name, '', {
|
|
81
|
-
...options,
|
|
82
|
-
days: -1,
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
type UpdateCookie<T> = (value: T, overrideOptions?: CookieOptions) => void;
|
|
87
|
-
type RemoveCookie = () => void;
|
|
88
|
-
|
|
89
|
-
export const useCookie = <T = unknown>(
|
|
90
|
-
cookieName: string,
|
|
91
|
-
defaultValue?: T,
|
|
92
|
-
options: CookieOptions = {},
|
|
93
|
-
): [T, UpdateCookie<T>, RemoveCookie] => {
|
|
94
|
-
const [cookieValue, setCookieValue] = useState<T>(() => {
|
|
95
|
-
const rawCookie = getCookie(cookieName);
|
|
96
|
-
|
|
97
|
-
if (rawCookie !== null) {
|
|
98
|
-
try {
|
|
99
|
-
return JSON.parse(rawCookie) as T;
|
|
100
|
-
} catch {
|
|
101
|
-
return defaultValue as T;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return defaultValue as T;
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const updateCookie = useCallback<UpdateCookie<T>>(
|
|
109
|
-
(value: T, overrideOptions: CookieOptions = {}) => {
|
|
110
|
-
const mergedOptions = { ...options, ...overrideOptions };
|
|
111
|
-
const stringValue = JSON.stringify(value);
|
|
112
|
-
setCookie(cookieName, stringValue, mergedOptions);
|
|
113
|
-
setCookieValue(value);
|
|
114
|
-
},
|
|
115
|
-
[cookieName, options],
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
const removeCookie = useCallback<RemoveCookie>(() => {
|
|
119
|
-
deleteCookie(cookieName, options);
|
|
120
|
-
setCookieValue(defaultValue as T);
|
|
121
|
-
}, [cookieName, defaultValue, options]);
|
|
122
|
-
|
|
123
|
-
return [cookieValue, updateCookie, removeCookie];
|
|
124
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
export const useDebounce = <T>(value: T, delay: number = 500): T => {
|
|
4
|
-
const [debouncedValue, setDebouncedValue] = useState<T>(value);
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const timer = setTimeout(() => setDebouncedValue(value), delay);
|
|
8
|
-
|
|
9
|
-
return () => {
|
|
10
|
-
clearTimeout(timer);
|
|
11
|
-
};
|
|
12
|
-
}, [value, delay]);
|
|
13
|
-
|
|
14
|
-
return debouncedValue;
|
|
15
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useResizeObserver } from './use-resize-observer';
|
|
4
|
-
|
|
5
|
-
export const useDimensions = (ref: React.RefObject<HTMLElement>) => {
|
|
6
|
-
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
|
|
7
|
-
|
|
8
|
-
useResizeObserver(ref, ([entry]) => {
|
|
9
|
-
if ((entry?.borderBoxSize ?? [])[0]) {
|
|
10
|
-
const { inlineSize: width, blockSize: height } = entry.borderBoxSize[0];
|
|
11
|
-
setDimensions({ width, height });
|
|
12
|
-
} else if (entry.contentRect) {
|
|
13
|
-
const { width, height } = entry.contentRect;
|
|
14
|
-
setDimensions({ width, height });
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return dimensions;
|
|
19
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
const createContainer = (containerID: string) => {
|
|
4
|
-
let domContainer = document.getElementById(containerID);
|
|
5
|
-
|
|
6
|
-
if (domContainer === null) {
|
|
7
|
-
domContainer = document.createElement('div');
|
|
8
|
-
domContainer.setAttribute('id', containerID);
|
|
9
|
-
document.body.appendChild(domContainer);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return domContainer;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const useDomContainer = (containerID: string) => {
|
|
16
|
-
const [container, setContainer] = useState<HTMLElement | null>(() => createContainer(containerID));
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
const domContainer = document.getElementById(containerID);
|
|
20
|
-
|
|
21
|
-
if (container === null || domContainer === null) {
|
|
22
|
-
const domContainer = createContainer(containerID);
|
|
23
|
-
|
|
24
|
-
setContainer(domContainer);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return () => {
|
|
28
|
-
if (container && container.parentNode && process.env.NODE_ENV === 'production') {
|
|
29
|
-
document.body.removeChild(container);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}, [container, containerID]);
|
|
33
|
-
|
|
34
|
-
return container;
|
|
35
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { RefObject, useEffect, useLayoutEffect, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
function useEventListener<EventName extends keyof MediaQueryListEventMap>(
|
|
4
|
-
eventName: EventName,
|
|
5
|
-
callback: (event: MediaQueryListEventMap[EventName]) => void,
|
|
6
|
-
element: RefObject<MediaQueryList> | undefined,
|
|
7
|
-
options?: boolean | AddEventListenerOptions,
|
|
8
|
-
): void;
|
|
9
|
-
|
|
10
|
-
function useEventListener<EventName extends keyof WindowEventMap>(
|
|
11
|
-
eventName: EventName,
|
|
12
|
-
callback: (event: WindowEventMap[EventName]) => void,
|
|
13
|
-
element?: undefined,
|
|
14
|
-
options?: boolean | AddEventListenerOptions,
|
|
15
|
-
): void;
|
|
16
|
-
|
|
17
|
-
function useEventListener<EventName extends keyof HTMLElementEventMap, ElementRef extends HTMLElement = HTMLDivElement>(
|
|
18
|
-
eventName: EventName,
|
|
19
|
-
callback: (event: HTMLElementEventMap[EventName]) => void,
|
|
20
|
-
element: RefObject<ElementRef> | undefined,
|
|
21
|
-
options?: boolean | AddEventListenerOptions,
|
|
22
|
-
): void;
|
|
23
|
-
|
|
24
|
-
function useEventListener<EventName extends keyof DocumentEventMap>(
|
|
25
|
-
eventName: EventName,
|
|
26
|
-
callback: (event: DocumentEventMap[EventName]) => void,
|
|
27
|
-
element: RefObject<Document> | undefined,
|
|
28
|
-
options?: boolean | AddEventListenerOptions,
|
|
29
|
-
): void;
|
|
30
|
-
|
|
31
|
-
function useEventListener<
|
|
32
|
-
MediaQueryEventName extends keyof MediaQueryListEventMap,
|
|
33
|
-
WindowEventName extends keyof WindowEventMap,
|
|
34
|
-
ElementEventName extends keyof HTMLElementEventMap,
|
|
35
|
-
DocumentEventName extends keyof DocumentEventMap,
|
|
36
|
-
ElementRef extends HTMLElement | MediaQueryList | Document | Window | void = void,
|
|
37
|
-
>(
|
|
38
|
-
eventName: WindowEventName | DocumentEventName | ElementEventName | MediaQueryEventName,
|
|
39
|
-
callback: (
|
|
40
|
-
event:
|
|
41
|
-
| MediaQueryListEventMap[MediaQueryEventName]
|
|
42
|
-
| WindowEventMap[WindowEventName]
|
|
43
|
-
| HTMLElementEventMap[ElementEventName]
|
|
44
|
-
| DocumentEventMap[DocumentEventName]
|
|
45
|
-
| Event,
|
|
46
|
-
) => void,
|
|
47
|
-
element?: RefObject<ElementRef> | undefined,
|
|
48
|
-
options?: boolean | AddEventListenerOptions,
|
|
49
|
-
) {
|
|
50
|
-
const callbackRef = useRef<EventListener>(callback);
|
|
51
|
-
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
callbackRef.current = callback;
|
|
54
|
-
}, [callback]);
|
|
55
|
-
|
|
56
|
-
useLayoutEffect(() => {
|
|
57
|
-
const targetElement = element?.current ?? window;
|
|
58
|
-
|
|
59
|
-
if (!(targetElement && targetElement.addEventListener)) return;
|
|
60
|
-
|
|
61
|
-
const listener: typeof callback = event => callbackRef.current(event);
|
|
62
|
-
|
|
63
|
-
targetElement.addEventListener(eventName, listener, options);
|
|
64
|
-
|
|
65
|
-
return () => {
|
|
66
|
-
targetElement.removeEventListener(eventName, listener, options);
|
|
67
|
-
};
|
|
68
|
-
}, [eventName, element, options]);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export { useEventListener };
|