polpo 0.1.6 → 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 -2133
- package/dist/{ui.d.ts → layouts.d.ts} +237 -2133
- 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-C0lyjvkD.d.ts +29 -0
- package/dist/use-modal-transition-C7DzbnY5.d.cts +29 -0
- 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-LJM5NQBY.js +0 -3
- package/dist/chunk-LJM5NQBY.js.map +0 -1
- package/dist/chunk-MAWW6AA7.js +0 -3
- package/dist/chunk-MAWW6AA7.js.map +0 -1
- package/dist/ui.cjs +0 -2197
- package/dist/ui.cjs.map +0 -1
- package/dist/ui.js +0 -2197
- package/dist/ui.js.map +0 -1
- package/dist/use-modal-transition-C6mR_NZh.d.cts +0 -32
- package/dist/use-modal-transition-DBAyFSqW.d.ts +0 -32
- 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 -56
- 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 -84
- package/src/components/form/checkbox/checkbox.style.ts +0 -109
- package/src/components/form/checkbox/checkbox.tsx +0 -110
- 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 -91
- package/src/components/form/field/field.tsx +0 -85
- 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 -67
- package/src/components/form/radio/radio.style.ts +0 -79
- package/src/components/form/radio/radio.tsx +0 -95
- package/src/components/form/select/index.ts +0 -1
- package/src/components/form/select/options.tsx +0 -203
- package/src/components/form/select/select.stories.tsx +0 -150
- package/src/components/form/select/select.style.ts +0 -82
- package/src/components/form/select/select.tsx +0 -304
- package/src/components/form/select/select.types.ts +0 -76
- 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 -38
- package/src/components/form/switch/switch.style.ts +0 -120
- package/src/components/form/switch/switch.tsx +0 -111
- 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 -75
- package/src/components/infinity-scroll/infinity-scroll.style.ts +0 -30
- package/src/components/infinity-scroll/infinity-scroll.tsx +0 -56
- 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/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 -21
- package/src/components/loaders/simple-loader/simple-loader.style.ts +0 -13
- package/src/components/loaders/simple-loader/simple-loader.tsx +0 -15
- 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 -69
- package/src/components/modals/menu/menu.style.ts +0 -62
- package/src/components/modals/menu/menu.tsx +0 -144
- 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 -96
- 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 -63
- 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 -205
- package/src/contexts/theme-context/theme.style.ts +0 -78
- package/src/contexts/theme-context/themes.ts +0 -96
- 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 -96
- package/src/hooks/use-modal-transition.ts +0 -66
- 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 -14
- package/tsup.config.cjs +0 -21
- package/vite.config.ts +0 -14
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import { Icon } from '../icon';
|
|
2
|
-
|
|
3
|
-
import { SmartTable } from './smart-table';
|
|
4
|
-
|
|
5
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
6
|
-
|
|
7
|
-
const users = [
|
|
8
|
-
{
|
|
9
|
-
age: '25',
|
|
10
|
-
gender: 'male',
|
|
11
|
-
occupation: 'Software engineer',
|
|
12
|
-
hobbies: ['Reading', 'Hiking'],
|
|
13
|
-
email: 'john@example.com',
|
|
14
|
-
phone: '123-456-7890',
|
|
15
|
-
username: 'johnny25',
|
|
16
|
-
name: 'John Doe',
|
|
17
|
-
country: 'USA',
|
|
18
|
-
id: '1',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
age: '30',
|
|
22
|
-
gender: 'female',
|
|
23
|
-
occupation: 'Graphic designer',
|
|
24
|
-
hobbies: ['Painting', 'Yoga'],
|
|
25
|
-
email: 'jane@example.com',
|
|
26
|
-
phone: '987-654-3210',
|
|
27
|
-
username: 'janeD30',
|
|
28
|
-
name: 'Jane Smith',
|
|
29
|
-
country: 'Canada',
|
|
30
|
-
id: '2',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
age: '28',
|
|
34
|
-
gender: 'male',
|
|
35
|
-
occupation: 'Data analyst',
|
|
36
|
-
hobbies: ['Gaming', 'Cycling'],
|
|
37
|
-
email: 'mike@example.com',
|
|
38
|
-
phone: '555-123-4567',
|
|
39
|
-
username: 'mikeA28',
|
|
40
|
-
name: 'Mike Johnson',
|
|
41
|
-
country: 'UK',
|
|
42
|
-
id: '3',
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
age: '35',
|
|
46
|
-
gender: 'female',
|
|
47
|
-
occupation: 'Marketing manager',
|
|
48
|
-
hobbies: ['Traveling', 'Cooking'],
|
|
49
|
-
email: 'sara@example.com',
|
|
50
|
-
phone: '444-987-6543',
|
|
51
|
-
username: 'saraM35',
|
|
52
|
-
name: 'Sara Wilson',
|
|
53
|
-
country: 'Australia',
|
|
54
|
-
id: '4',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
age: '22',
|
|
58
|
-
gender: 'male',
|
|
59
|
-
occupation: 'Web developer',
|
|
60
|
-
hobbies: ['Programming', 'Photography'],
|
|
61
|
-
email: 'alex@example.com',
|
|
62
|
-
phone: '333-555-1234',
|
|
63
|
-
username: 'alexD22',
|
|
64
|
-
name: 'Alex Brown',
|
|
65
|
-
country: 'Germany',
|
|
66
|
-
id: '5',
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
age: '27',
|
|
70
|
-
gender: 'female',
|
|
71
|
-
occupation: 'HR specialist',
|
|
72
|
-
hobbies: ['Dancing', 'Reading'],
|
|
73
|
-
email: 'lisa@example.com',
|
|
74
|
-
phone: '222-444-9876',
|
|
75
|
-
username: 'lisaS27',
|
|
76
|
-
name: 'Lisa Davis',
|
|
77
|
-
country: 'France',
|
|
78
|
-
id: '6',
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
age: '31',
|
|
82
|
-
gender: 'male',
|
|
83
|
-
occupation: 'Financial analyst',
|
|
84
|
-
hobbies: ['Investing', 'Golfing'],
|
|
85
|
-
email: 'tom@example.com',
|
|
86
|
-
phone: '111-333-5555',
|
|
87
|
-
username: 'tomA31',
|
|
88
|
-
name: 'Tom Miller',
|
|
89
|
-
country: 'Japan',
|
|
90
|
-
id: '7',
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
age: '29',
|
|
94
|
-
gender: 'female',
|
|
95
|
-
occupation: 'Sales executive',
|
|
96
|
-
hobbies: ['Shopping', 'Running'],
|
|
97
|
-
email: 'anna@example.com',
|
|
98
|
-
phone: '666-222-4444',
|
|
99
|
-
username: 'annaE29',
|
|
100
|
-
name: 'Anna Taylor',
|
|
101
|
-
country: 'Brazil',
|
|
102
|
-
id: '8',
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
age: '26',
|
|
106
|
-
gender: 'male',
|
|
107
|
-
occupation: 'IT support',
|
|
108
|
-
hobbies: ['Gaming', 'Watching movies'],
|
|
109
|
-
email: 'jake@example.com',
|
|
110
|
-
phone: '777-111-3333',
|
|
111
|
-
username: 'jakeS26',
|
|
112
|
-
name: 'Jake Anderson',
|
|
113
|
-
country: 'India',
|
|
114
|
-
id: '9',
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
age: '33',
|
|
118
|
-
gender: 'female',
|
|
119
|
-
occupation: 'Nurse',
|
|
120
|
-
hobbies: ['Cooking', 'Painting'],
|
|
121
|
-
email: 'kate@example.com',
|
|
122
|
-
phone: '888-666-2222',
|
|
123
|
-
username: 'kateN33',
|
|
124
|
-
name: 'Kate Thomas',
|
|
125
|
-
country: 'Italy',
|
|
126
|
-
id: '10',
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
age: '24',
|
|
130
|
-
gender: 'male',
|
|
131
|
-
occupation: 'Teacher',
|
|
132
|
-
hobbies: ['Reading', 'Traveling'],
|
|
133
|
-
email: 'ryan@example.com',
|
|
134
|
-
phone: '999-777-1111',
|
|
135
|
-
username: 'ryanT24',
|
|
136
|
-
name: 'Ryan Jackson',
|
|
137
|
-
country: 'Mexico',
|
|
138
|
-
id: '11',
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
age: '32',
|
|
142
|
-
gender: 'female',
|
|
143
|
-
occupation: 'Lawyer',
|
|
144
|
-
hobbies: ['Running', 'Yoga'],
|
|
145
|
-
email: 'lily@example.com',
|
|
146
|
-
phone: '000-888-6666',
|
|
147
|
-
username: 'lilyL32',
|
|
148
|
-
name: 'Lily White',
|
|
149
|
-
country: 'South Africa',
|
|
150
|
-
id: '12',
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
age: '23',
|
|
154
|
-
gender: 'male',
|
|
155
|
-
occupation: 'Mechanic',
|
|
156
|
-
hobbies: ['Fixing cars', 'Fishing'],
|
|
157
|
-
email: 'matt@example.com',
|
|
158
|
-
phone: '111-999-7777',
|
|
159
|
-
username: 'mattM23',
|
|
160
|
-
name: 'Matt Harris',
|
|
161
|
-
country: 'Russia',
|
|
162
|
-
id: '13',
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
age: '34',
|
|
166
|
-
gender: 'female',
|
|
167
|
-
occupation: 'Architect',
|
|
168
|
-
hobbies: ['Designing', 'Hiking'],
|
|
169
|
-
email: 'sophia@example.com',
|
|
170
|
-
phone: '222-000-8888',
|
|
171
|
-
username: 'sophiaA34',
|
|
172
|
-
name: 'Sophia Clark',
|
|
173
|
-
country: 'Spain',
|
|
174
|
-
id: '14',
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
age: '21',
|
|
178
|
-
gender: 'male',
|
|
179
|
-
occupation: 'Intern',
|
|
180
|
-
hobbies: ['Learning', 'Reading'],
|
|
181
|
-
email: 'chris@example.com',
|
|
182
|
-
phone: '333-111-9999',
|
|
183
|
-
username: 'chrisI21',
|
|
184
|
-
name: 'Chris Lewis',
|
|
185
|
-
country: 'Netherlands',
|
|
186
|
-
id: '15',
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
age: '36',
|
|
190
|
-
gender: 'female',
|
|
191
|
-
occupation: 'CEO',
|
|
192
|
-
hobbies: ['Gambling', 'Traveling'],
|
|
193
|
-
email: 'emily@example.com',
|
|
194
|
-
phone: '444-222-0000',
|
|
195
|
-
username: 'emilyC36',
|
|
196
|
-
name: 'Emily Robinson',
|
|
197
|
-
country: 'Sweden',
|
|
198
|
-
id: '16',
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
age: '37',
|
|
202
|
-
gender: 'male',
|
|
203
|
-
occupation: 'Doctor',
|
|
204
|
-
hobbies: ['Helping others', 'Running'],
|
|
205
|
-
email: 'david@example.com',
|
|
206
|
-
phone: '555-333-1111',
|
|
207
|
-
username: 'davidD37',
|
|
208
|
-
name: 'David Hall',
|
|
209
|
-
country: 'Norway',
|
|
210
|
-
id: '17',
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
age: '38',
|
|
214
|
-
gender: 'female',
|
|
215
|
-
occupation: 'Accountant',
|
|
216
|
-
hobbies: ['Calculating', 'Reading'],
|
|
217
|
-
email: 'olivia@example.com',
|
|
218
|
-
phone: '666-444-2222',
|
|
219
|
-
username: 'oliviaA38',
|
|
220
|
-
name: 'Olivia Young',
|
|
221
|
-
country: 'Finland',
|
|
222
|
-
id: '18',
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
age: '39',
|
|
226
|
-
gender: 'male',
|
|
227
|
-
occupation: 'Plumber',
|
|
228
|
-
hobbies: ['Fixing pipes', 'Fishing'],
|
|
229
|
-
email: 'noah@example.com',
|
|
230
|
-
phone: '777-555-3333',
|
|
231
|
-
username: 'noahP39',
|
|
232
|
-
name: 'Noah King',
|
|
233
|
-
country: 'Denmark',
|
|
234
|
-
id: '19',
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
age: '40',
|
|
238
|
-
gender: 'female',
|
|
239
|
-
occupation: 'Teacher',
|
|
240
|
-
hobbies: ['Teaching', 'Traveling'],
|
|
241
|
-
email: 'ava@example.com',
|
|
242
|
-
phone: '888-666-4444',
|
|
243
|
-
username: 'avaT40',
|
|
244
|
-
name: 'Ava Scott',
|
|
245
|
-
country: 'Belgium',
|
|
246
|
-
id: '20',
|
|
247
|
-
},
|
|
248
|
-
];
|
|
249
|
-
|
|
250
|
-
const meta: Meta<typeof SmartTable> = {
|
|
251
|
-
title: 'Smart Table',
|
|
252
|
-
component: SmartTable,
|
|
253
|
-
argTypes: {
|
|
254
|
-
columns: { control: false },
|
|
255
|
-
data: { control: false },
|
|
256
|
-
width: { control: 'inline-radio', options: ['scroll', 'content'] },
|
|
257
|
-
selectable: { control: 'boolean' },
|
|
258
|
-
rowId: { control: false },
|
|
259
|
-
},
|
|
260
|
-
args: {},
|
|
261
|
-
decorators: [
|
|
262
|
-
Story => (
|
|
263
|
-
<div style={{ width: '100%', maxHeight: '500px', overflow: 'auto' }}>
|
|
264
|
-
<Story />
|
|
265
|
-
</div>
|
|
266
|
-
),
|
|
267
|
-
],
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
export default meta;
|
|
271
|
-
type Story = StoryObj<typeof SmartTable>;
|
|
272
|
-
|
|
273
|
-
export const Users: Story = {
|
|
274
|
-
args: {
|
|
275
|
-
// @ts-expect-error Storybook doesn't recognize the rowId prop
|
|
276
|
-
rowId: 'id',
|
|
277
|
-
data: users,
|
|
278
|
-
columns: [
|
|
279
|
-
// @ts-expect-error Storybook doesn't recognize props
|
|
280
|
-
{ header: 'Name', field: 'name' },
|
|
281
|
-
// @ts-expect-error Storybook doesn't recognize props
|
|
282
|
-
{ header: 'Age', field: 'age' },
|
|
283
|
-
// @ts-expect-error Storybook doesn't recognize props
|
|
284
|
-
{ header: 'Email', field: 'email' },
|
|
285
|
-
// @ts-expect-error Storybook doesn't recognize props
|
|
286
|
-
{ header: 'Username', field: 'username' },
|
|
287
|
-
// @ts-expect-error Storybook doesn't recognize props
|
|
288
|
-
{ header: 'Phone', field: 'phone' },
|
|
289
|
-
{
|
|
290
|
-
header: 'Gender',
|
|
291
|
-
render: data => <Icon name={data.gender === 'male' ? 'user' : 'camera'} />,
|
|
292
|
-
// @ts-expect-error Storybook doesn't recognize props
|
|
293
|
-
sortBy: 'gender',
|
|
294
|
-
},
|
|
295
|
-
// @ts-expect-error Storybook doesn't recognize props
|
|
296
|
-
{ header: 'Country', field: 'country' },
|
|
297
|
-
// @ts-expect-error Storybook doesn't recognize props
|
|
298
|
-
{ header: 'Occupation', field: 'occupation' },
|
|
299
|
-
],
|
|
300
|
-
},
|
|
301
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { styled } from 'styled-components';
|
|
2
|
-
|
|
3
|
-
export const SmartTableContainerStyle = styled.section`
|
|
4
|
-
border: 1px solid ${props => props.theme.colors.primary.main};
|
|
5
|
-
border-radius: 10px;
|
|
6
|
-
overflow: auto;
|
|
7
|
-
height: 100%;
|
|
8
|
-
width: 100%;
|
|
9
|
-
margin: auto;
|
|
10
|
-
`;
|
|
11
|
-
|
|
12
|
-
export const SmartTableStyle = styled.table`
|
|
13
|
-
border-collapse: collapse;
|
|
14
|
-
position: relative;
|
|
15
|
-
|
|
16
|
-
&.layout-fixed {
|
|
17
|
-
table-layout: fixed;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&.layout-scrollable {
|
|
21
|
-
table-layout: auto;
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
export const SmartHeaderStyle = styled.thead`
|
|
26
|
-
position: sticky;
|
|
27
|
-
z-index: 10;
|
|
28
|
-
top: 0;
|
|
29
|
-
box-shadow:
|
|
30
|
-
0 3px 5px 0 rgba(0, 0, 0, 0.2),
|
|
31
|
-
0 1px 10px 0 rgba(0, 0, 0, 0.12);
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
export const SmartBodyStyle = styled.tbody``;
|
|
35
|
-
|
|
36
|
-
export const SmartColumnStyle = styled.th`
|
|
37
|
-
padding: 0.8em 1.2em;
|
|
38
|
-
user-select: none;
|
|
39
|
-
|
|
40
|
-
&.sort-on-click {
|
|
41
|
-
cursor: pointer;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.sort-icon {
|
|
45
|
-
width: 1em;
|
|
46
|
-
display: block;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
svg {
|
|
50
|
-
animation: fadeIn 300ms ease;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
path {
|
|
54
|
-
transition: all 300ms ease;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&:first-child {
|
|
58
|
-
padding-left: 2em;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
&:last-child {
|
|
62
|
-
padding-right: 2em;
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
65
|
-
|
|
66
|
-
export const SmartHeaderRowStyle = styled.tr`
|
|
67
|
-
background: ${props => props.theme.colors.primary.main};
|
|
68
|
-
color: ${props => props.theme.colors.primary.contrast};
|
|
69
|
-
transition: all 300ms ease;
|
|
70
|
-
`;
|
|
71
|
-
|
|
72
|
-
export const SmartRowStyle = styled.tr`
|
|
73
|
-
background: ${props => props.theme.colors.background.main};
|
|
74
|
-
box-shadow: inset 0 0 0 0 ${props => props.theme.colors.primary.main};
|
|
75
|
-
transition: box-shadow 300ms ease;
|
|
76
|
-
|
|
77
|
-
&.row-selected,
|
|
78
|
-
&:hover {
|
|
79
|
-
background: ${props => props.theme.colors.background.paper};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
&.row-selected {
|
|
83
|
-
box-shadow: inset 10px 0 0 -5px ${props => props.theme.colors.primary.main};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&:not(:last-child) {
|
|
87
|
-
border-bottom: 1px solid ${props => props.theme.colors.border.main};
|
|
88
|
-
}
|
|
89
|
-
`;
|
|
90
|
-
|
|
91
|
-
export const SmartCellStyle = styled.td`
|
|
92
|
-
transition: all 300ms ease;
|
|
93
|
-
padding: 0.6em 1em;
|
|
94
|
-
|
|
95
|
-
&:first-child {
|
|
96
|
-
padding-left: 2em;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
&:last-child {
|
|
100
|
-
padding-right: 2em;
|
|
101
|
-
}
|
|
102
|
-
`;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { useMemo, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { KeyValuesOf } from '../../types';
|
|
4
|
-
import { Checkbox } from '../form';
|
|
5
|
-
|
|
6
|
-
import { SmartTableColumn } from './smart-table.column';
|
|
7
|
-
import { sortData } from './smart-table.helpers';
|
|
8
|
-
import { useSort } from './smart-table.hooks';
|
|
9
|
-
import { SmartTableRow } from './smart-table.row';
|
|
10
|
-
import {
|
|
11
|
-
SmartBodyStyle,
|
|
12
|
-
SmartHeaderStyle,
|
|
13
|
-
SmartTableStyle,
|
|
14
|
-
SmartHeaderRowStyle,
|
|
15
|
-
SmartTableContainerStyle,
|
|
16
|
-
} from './smart-table.style';
|
|
17
|
-
import { ColumnData, RowDataObject } from './smart-table.types';
|
|
18
|
-
|
|
19
|
-
import { useClassNames } from '@polpo/hooks';
|
|
20
|
-
|
|
21
|
-
type SmartTableProps<RowData extends RowDataObject> = {
|
|
22
|
-
columns: Array<ColumnData<RowData>>;
|
|
23
|
-
data: Array<RowData>;
|
|
24
|
-
width?: 'scroll' | 'content';
|
|
25
|
-
selectable?: boolean;
|
|
26
|
-
rowId: KeyValuesOf<RowData, React.Key>;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const SmartTable = <RowData extends RowDataObject>({
|
|
30
|
-
columns: initialColumns,
|
|
31
|
-
data,
|
|
32
|
-
width,
|
|
33
|
-
selectable = false,
|
|
34
|
-
rowId,
|
|
35
|
-
}: SmartTableProps<RowData>) => {
|
|
36
|
-
const [selected, setSelected] = useState<{ [key: string]: RowData }>({});
|
|
37
|
-
|
|
38
|
-
const tableClassName = useClassNames({
|
|
39
|
-
'layout-fixed': width === 'content',
|
|
40
|
-
'layout-scrollable': width === 'scroll',
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const { sortBy, order, toggleSortField } = useSort<RowData>();
|
|
44
|
-
|
|
45
|
-
const columns = useMemo(() => {
|
|
46
|
-
let finalColumns = [...initialColumns];
|
|
47
|
-
|
|
48
|
-
if (selectable) {
|
|
49
|
-
finalColumns = [
|
|
50
|
-
{
|
|
51
|
-
header: `${Object.values(selected).length}`,
|
|
52
|
-
render: (data, rowKey) => (
|
|
53
|
-
<Checkbox
|
|
54
|
-
name={`selected-${rowKey}`}
|
|
55
|
-
value={`${rowKey}` in selected}
|
|
56
|
-
setValue={isSelected => {
|
|
57
|
-
setSelected(prev => {
|
|
58
|
-
const copy = { ...prev };
|
|
59
|
-
|
|
60
|
-
if (isSelected) {
|
|
61
|
-
copy[`${rowKey}`] = data;
|
|
62
|
-
} else {
|
|
63
|
-
delete copy[`${rowKey}`];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return copy;
|
|
67
|
-
});
|
|
68
|
-
}}
|
|
69
|
-
/>
|
|
70
|
-
),
|
|
71
|
-
},
|
|
72
|
-
...finalColumns,
|
|
73
|
-
];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return finalColumns;
|
|
77
|
-
}, [initialColumns, selectable, selected]);
|
|
78
|
-
|
|
79
|
-
const rows = useMemo(() => sortData<RowData>(data, sortBy, order), [data, sortBy, order]);
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<SmartTableContainerStyle>
|
|
83
|
-
<SmartTableStyle className={tableClassName}>
|
|
84
|
-
<SmartHeaderStyle>
|
|
85
|
-
<SmartHeaderRowStyle>
|
|
86
|
-
{columns.map((column, key) => (
|
|
87
|
-
<SmartTableColumn
|
|
88
|
-
key={key}
|
|
89
|
-
toggleSortField={toggleSortField}
|
|
90
|
-
sortField={sortBy}
|
|
91
|
-
orderField={order}
|
|
92
|
-
{...column}
|
|
93
|
-
/>
|
|
94
|
-
))}
|
|
95
|
-
</SmartHeaderRowStyle>
|
|
96
|
-
</SmartHeaderStyle>
|
|
97
|
-
<SmartBodyStyle>
|
|
98
|
-
{rows.map(row => (
|
|
99
|
-
<SmartTableRow
|
|
100
|
-
key={row[rowId] as React.Key}
|
|
101
|
-
rowKey={row[rowId] as React.Key}
|
|
102
|
-
data={row}
|
|
103
|
-
columns={columns}
|
|
104
|
-
isSelected={`${row[rowId] as React.Key}` in selected}
|
|
105
|
-
selectable={selectable}
|
|
106
|
-
/>
|
|
107
|
-
))}
|
|
108
|
-
</SmartBodyStyle>
|
|
109
|
-
</SmartTableStyle>
|
|
110
|
-
</SmartTableContainerStyle>
|
|
111
|
-
);
|
|
112
|
-
};
|
|
@@ -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';
|