polpo 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +9 -0
- package/.storybook/decorators.tsx +61 -0
- package/.storybook/main.ts +47 -0
- package/.storybook/manager-head.html +2 -0
- package/.storybook/manager.ts +7 -0
- package/.storybook/preview-head.html +2 -0
- package/.storybook/preview.ts +38 -0
- package/.storybook/theme.ts +47 -0
- package/.turbo/daemon/f5c5c8fb195b01d0-turbo.log.2024-05-26 +0 -0
- package/.turbo/turbo-build$colon$watch.log +96 -0
- package/.turbo/turbo-build-storybook.log +0 -0
- package/.turbo/turbo-build.log +77 -0
- package/.turbo/turbo-lint$colon$fix.log +2 -0
- package/.turbo/turbo-lint.log +4 -0
- package/README.md +68 -0
- package/dist/chunk-M4KRSYE7.js +3 -0
- package/dist/chunk-M4KRSYE7.js.map +1 -0
- package/dist/chunk-U5XSMSKZ.js +3 -0
- package/dist/chunk-U5XSMSKZ.js.map +1 -0
- package/dist/get-modal-position-DPftPoU2.d.cts +28 -0
- package/dist/get-modal-position-DPftPoU2.d.ts +28 -0
- package/dist/helpers.cjs +3 -0
- package/dist/helpers.cjs.map +1 -0
- package/dist/helpers.d.cts +15 -0
- package/dist/helpers.d.ts +15 -0
- package/dist/helpers.js +3 -0
- package/dist/helpers.js.map +1 -0
- package/dist/hooks.cjs +3 -0
- package/dist/hooks.cjs.map +1 -0
- package/dist/hooks.d.cts +121 -0
- package/dist/hooks.d.ts +121 -0
- package/dist/hooks.js +3 -0
- package/dist/hooks.js.map +1 -0
- package/dist/ui.cjs +1987 -0
- package/dist/ui.cjs.map +1 -0
- package/dist/ui.d.cts +3932 -0
- package/dist/ui.d.ts +3932 -0
- package/dist/ui.js +1987 -0
- package/dist/ui.js.map +1 -0
- package/package.json +98 -0
- package/src/components/accordion/accordion-item.stories.tsx +128 -0
- package/src/components/accordion/accordion-item.tsx +119 -0
- package/src/components/accordion/accordion.stories.tsx +74 -0
- package/src/components/accordion/accordion.style.ts +42 -0
- package/src/components/accordion/accordion.tsx +56 -0
- package/src/components/accordion/index.ts +2 -0
- package/src/components/buttons/button/button.stories.tsx +103 -0
- package/src/components/buttons/button/button.style.ts +147 -0
- package/src/components/buttons/button/button.tsx +119 -0
- package/src/components/buttons/button/index.ts +1 -0
- package/src/components/buttons/index.ts +1 -0
- package/src/components/cards/flip-card/flip-card.stories.tsx +61 -0
- package/src/components/cards/flip-card/flip-card.style.ts +45 -0
- package/src/components/cards/flip-card/flip-card.tsx +55 -0
- package/src/components/cards/flip-card/index.ts +1 -0
- package/src/components/cards/hover-card/hover-card.stories.tsx +45 -0
- package/src/components/cards/hover-card/hover-card.style.ts +13 -0
- package/src/components/cards/hover-card/hover-card.tsx +71 -0
- package/src/components/cards/hover-card/index.ts +1 -0
- package/src/components/cards/index.ts +3 -0
- package/src/components/cards/slide-card/index.ts +1 -0
- package/src/components/cards/slide-card/slide-card.stories.tsx +47 -0
- package/src/components/cards/slide-card/slide-card.tsx +42 -0
- package/src/components/form/checkbox/checkbox.stories.tsx +34 -0
- package/src/components/form/checkbox/checkbox.style.ts +75 -0
- package/src/components/form/checkbox/checkbox.tsx +76 -0
- package/src/components/form/checkbox/index.ts +1 -0
- package/src/components/form/controller/controller.tsx +42 -0
- package/src/components/form/controller/index.ts +1 -0
- package/src/components/form/date-picker/date-picker.stories.tsx +38 -0
- package/src/components/form/date-picker/date-picker.tsx +67 -0
- package/src/components/form/date-picker/index.ts +1 -0
- package/src/components/form/field/field.stories.tsx +49 -0
- package/src/components/form/field/field.style.ts +79 -0
- package/src/components/form/field/field.tsx +83 -0
- package/src/components/form/field/field.types.ts +28 -0
- package/src/components/form/field/index.ts +2 -0
- package/src/components/form/form.stories.types.tsx +50 -0
- package/src/components/form/form.types.ts +37 -0
- package/src/components/form/index.ts +14 -0
- package/src/components/form/input/index.ts +1 -0
- package/src/components/form/input/input.stories.tsx +41 -0
- package/src/components/form/input/input.tsx +73 -0
- package/src/components/form/input-color/index.ts +1 -0
- package/src/components/form/input-color/input-color.stories.tsx +46 -0
- package/src/components/form/input-color/input-color.style.ts +93 -0
- package/src/components/form/input-color/input-color.tsx +159 -0
- package/src/components/form/input-file/index.ts +1 -0
- package/src/components/form/input-file/input-file.stories.tsx +40 -0
- package/src/components/form/input-file/input-file.style.ts +143 -0
- package/src/components/form/input-file/input-file.tsx +214 -0
- package/src/components/form/input-password/index.ts +1 -0
- package/src/components/form/input-password/input-password.stories.tsx +37 -0
- package/src/components/form/input-password/input-password.tsx +83 -0
- package/src/components/form/radio/index.ts +1 -0
- package/src/components/form/radio/radio.stories.tsx +43 -0
- package/src/components/form/radio/radio.style.ts +58 -0
- package/src/components/form/radio/radio.tsx +76 -0
- package/src/components/form/select/index.ts +1 -0
- package/src/components/form/select/options.tsx +140 -0
- package/src/components/form/select/select-option.tsx +84 -0
- package/src/components/form/select/select.stories.tsx +89 -0
- package/src/components/form/select/select.style.ts +164 -0
- package/src/components/form/select/select.tsx +327 -0
- package/src/components/form/select/select.types.ts +93 -0
- package/src/components/form/slider/index.ts +1 -0
- package/src/components/form/slider/slider.stories.tsx +40 -0
- package/src/components/form/slider/slider.style.ts +90 -0
- package/src/components/form/slider/slider.tsx +108 -0
- package/src/components/form/switch/index.ts +1 -0
- package/src/components/form/switch/switch.stories.tsx +38 -0
- package/src/components/form/switch/switch.style.ts +120 -0
- package/src/components/form/switch/switch.tsx +111 -0
- package/src/components/form/textarea/index.ts +1 -0
- package/src/components/form/textarea/textarea.stories.tsx +43 -0
- package/src/components/form/textarea/textarea.style.ts +7 -0
- package/src/components/form/textarea/textarea.tsx +76 -0
- package/src/components/icon/icon.stories.tsx +63 -0
- package/src/components/icon/icon.tsx +64 -0
- package/src/components/icon/icons/index.ts +18 -0
- package/src/components/icon/icons/object.tsx +482 -0
- package/src/components/icon/icons/social.tsx +72 -0
- package/src/components/icon/icons/symbol.tsx +776 -0
- package/src/components/icon/index.ts +5 -0
- package/src/components/image/image.stories.tsx +25 -0
- package/src/components/image/image.tsx +7 -0
- package/src/components/image/index.ts +1 -0
- package/src/components/index.ts +16 -0
- package/src/components/infinity-scroll/index.ts +1 -0
- package/src/components/infinity-scroll/infinity-scroll.stories.tsx +75 -0
- package/src/components/infinity-scroll/infinity-scroll.style.ts +30 -0
- package/src/components/infinity-scroll/infinity-scroll.tsx +56 -0
- package/src/components/line/index.ts +1 -0
- package/src/components/line/line.stories.tsx +67 -0
- package/src/components/line/line.style.ts +57 -0
- package/src/components/line/line.tsx +76 -0
- package/src/components/loaders/index.ts +1 -0
- package/src/components/loaders/simple-loader/index.ts +1 -0
- package/src/components/loaders/simple-loader/simple-loader.stories.tsx +21 -0
- package/src/components/loaders/simple-loader/simple-loader.style.ts +13 -0
- package/src/components/loaders/simple-loader/simple-loader.tsx +15 -0
- package/src/components/modals/action-modal/action-modal.stories.tsx +134 -0
- package/src/components/modals/action-modal/action-modal.style.ts +129 -0
- package/src/components/modals/action-modal/action-modal.tsx +150 -0
- package/src/components/modals/action-modal/index.ts +1 -0
- package/src/components/modals/aside-modal/aside-modal.stories.tsx +82 -0
- package/src/components/modals/aside-modal/aside-modal.style.ts +108 -0
- package/src/components/modals/aside-modal/aside-modal.tsx +66 -0
- package/src/components/modals/aside-modal/index.ts +1 -0
- package/src/components/modals/confirmation-modal/confirmation-modal.stories.tsx +50 -0
- package/src/components/modals/confirmation-modal/confirmation-modal.style.ts +17 -0
- package/src/components/modals/confirmation-modal/confirmation-modal.tsx +43 -0
- package/src/components/modals/confirmation-modal/index.ts +1 -0
- package/src/components/modals/index.ts +4 -0
- package/src/components/modals/modal/index.ts +1 -0
- package/src/components/modals/modal/modal.style.ts +10 -0
- package/src/components/modals/modal/modal.tsx +132 -0
- package/src/components/ripple/index.ts +1 -0
- package/src/components/ripple/ripple.stories.tsx +38 -0
- package/src/components/ripple/ripple.style.ts +33 -0
- package/src/components/ripple/ripple.tsx +63 -0
- package/src/components/smart-table/index.ts +1 -0
- package/src/components/smart-table/smart-table.column.tsx +63 -0
- package/src/components/smart-table/smart-table.helpers.tsx +59 -0
- package/src/components/smart-table/smart-table.hooks.ts +27 -0
- package/src/components/smart-table/smart-table.row.tsx +29 -0
- package/src/components/smart-table/smart-table.stories.tsx +301 -0
- package/src/components/smart-table/smart-table.style.ts +102 -0
- package/src/components/smart-table/smart-table.tsx +112 -0
- package/src/components/smart-table/smart-table.types.ts +41 -0
- package/src/components/tabs/index.ts +1 -0
- package/src/components/tabs/tabs-container.stories.tsx +159 -0
- package/src/components/tabs/tabs-list.tsx +131 -0
- package/src/components/tabs/tabs.stories.tsx +68 -0
- package/src/components/tabs/tabs.style.ts +132 -0
- package/src/components/tabs/tabs.tsx +117 -0
- package/src/components/tag/index.ts +1 -0
- package/src/components/tag/tag.stories.tsx +49 -0
- package/src/components/tag/tag.style.ts +24 -0
- package/src/components/tag/tag.tsx +44 -0
- package/src/components/tooltips/click-to-copy/click-to-copy.stories.tsx +39 -0
- package/src/components/tooltips/click-to-copy/click-to-copy.tsx +41 -0
- package/src/components/tooltips/click-to-copy/index.ts +1 -0
- package/src/components/tooltips/index.ts +2 -0
- package/src/components/tooltips/tooltip/index.ts +1 -0
- package/src/components/tooltips/tooltip/tooltip.stories.tsx +35 -0
- package/src/components/tooltips/tooltip/tooltip.style.ts +62 -0
- package/src/components/tooltips/tooltip/tooltip.tsx +45 -0
- package/src/components/typography/index.ts +2 -0
- package/src/components/typography/typography.constants.ts +43 -0
- package/src/components/typography/typography.stories.tsx +106 -0
- package/src/components/typography/typography.style.ts +76 -0
- package/src/components/typography/typography.tsx +79 -0
- package/src/contexts/fetch-context/fetch-context.tsx +114 -0
- package/src/contexts/fetch-context/index.ts +1 -0
- package/src/contexts/form-context/form-context.tsx +43 -0
- package/src/contexts/form-context/index.ts +1 -0
- package/src/contexts/index.ts +3 -0
- package/src/contexts/theme-context/index.ts +3 -0
- package/src/contexts/theme-context/theme-context.tsx +158 -0
- package/src/contexts/theme-context/theme.animations.ts +180 -0
- package/src/contexts/theme-context/theme.defaults.ts +205 -0
- package/src/contexts/theme-context/theme.style.ts +78 -0
- package/src/contexts/theme-context/themes.ts +96 -0
- package/src/core/http-client.d.ts +11 -0
- package/src/core/http-client.d.ts.map +1 -0
- package/src/core/http-client.ts +47 -0
- package/src/core/index.d.ts +2 -0
- package/src/core/index.d.ts.map +1 -0
- package/src/core/index.ts +1 -0
- package/src/core/variants/color.ts +36 -0
- package/src/core/variants/index.ts +3 -0
- package/src/core/variants/radius.ts +56 -0
- package/src/core/variants/size.ts +44 -0
- package/src/helpers/format-bytes.ts +11 -0
- package/src/helpers/format-dates.ts +11 -0
- package/src/helpers/get-modal-position.ts +66 -0
- package/src/helpers/index.ts +4 -0
- package/src/helpers/text/index.ts +1 -0
- package/src/helpers/text/to-capitalize.ts +17 -0
- package/src/hooks/index.ts +23 -0
- package/src/hooks/use-async.ts +88 -0
- package/src/hooks/use-classnames.ts +13 -0
- package/src/hooks/use-constant.ts +3 -0
- package/src/hooks/use-debounce.ts +15 -0
- package/src/hooks/use-dimensions.ts +22 -0
- package/src/hooks/use-event-listener.ts +71 -0
- package/src/hooks/use-file-reader.ts +69 -0
- package/src/hooks/use-hover.ts +17 -0
- package/src/hooks/use-in-view.ts +20 -0
- package/src/hooks/use-input-handlers.ts +49 -0
- package/src/hooks/use-media-query.ts +25 -0
- package/src/hooks/use-modal-in-container.ts +94 -0
- package/src/hooks/use-mouse-position.ts +16 -0
- package/src/hooks/use-observer.ts +18 -0
- package/src/hooks/use-on-click-outside-ref.ts +17 -0
- package/src/hooks/use-online-status.ts +12 -0
- package/src/hooks/use-render-count.ts +11 -0
- package/src/hooks/use-safe-dispatch.ts +22 -0
- package/src/hooks/use-scroll.ts +31 -0
- package/src/hooks/use-state-history.ts +22 -0
- package/src/hooks/use-toggle-values.ts +14 -0
- package/src/hooks/use-toggle.ts +11 -0
- package/src/hooks/use-viewport.ts +38 -0
- package/src/index.ts +5 -0
- package/src/layouts/flex/flex.tsx +75 -0
- package/src/layouts/flex/index.ts +1 -0
- package/src/layouts/grid/grid.tsx +86 -0
- package/src/layouts/grid/index.ts +1 -0
- package/src/layouts/index.ts +3 -0
- package/src/layouts/section-layout/index.ts +1 -0
- package/src/layouts/section-layout/section-layout.stories.tsx +55 -0
- package/src/layouts/section-layout/section-layout.style.ts +21 -0
- package/src/layouts/section-layout/section-layout.tsx +46 -0
- package/src/stories/GettingStarted.mdx +66 -0
- package/src/types/generics.ts +68 -0
- package/src/types/index.ts +1 -0
- package/svg/Name=airplane, Category=object.svg +3 -0
- package/svg/Name=arrow-circle, Category=symbol.svg +3 -0
- package/svg/Name=arrow-down, Category=symbol.svg +3 -0
- package/svg/Name=arrow-left, Category=symbol.svg +3 -0
- package/svg/Name=arrow-right, Category=symbol.svg +3 -0
- package/svg/Name=arrow-up, Category=symbol.svg +3 -0
- package/svg/Name=bell, Category=object.svg +3 -0
- package/svg/Name=bicycle, Category=object.svg +3 -0
- package/svg/Name=book-open, Category=object.svg +3 -0
- package/svg/Name=book-solid, Category=object.svg +6 -0
- package/svg/Name=box-shadow, Category=symbol.svg +5 -0
- package/svg/Name=calendar, Category=object.svg +3 -0
- package/svg/Name=camera, Category=object.svg +3 -0
- package/svg/Name=caret-down, Category=symbol.svg +3 -0
- package/svg/Name=caret-left, Category=symbol.svg +3 -0
- package/svg/Name=caret-right, Category=symbol.svg +3 -0
- package/svg/Name=caret-up, Category=symbol.svg +3 -0
- package/svg/Name=checkmark, Category=symbol.svg +3 -0
- package/svg/Name=clean-computer, Category=object.svg +10 -0
- package/svg/Name=codepen, Category=social.svg +3 -0
- package/svg/Name=creative, Category=symbol.svg +5 -0
- package/svg/Name=cross, Category=symbol.svg +4 -0
- package/svg/Name=crossed-flags, Category=object.svg +4 -0
- package/svg/Name=cv, Category=symbol.svg +5 -0
- package/svg/Name=design-ui, Category=symbol.svg +9 -0
- package/svg/Name=document, Category=object.svg +3 -0
- package/svg/Name=door-closed, Category=object.svg +3 -0
- package/svg/Name=door-open, Category=object.svg +3 -0
- package/svg/Name=double-caret-down, Category=symbol.svg +4 -0
- package/svg/Name=double-caret-left, Category=symbol.svg +4 -0
- package/svg/Name=double-caret-righ, Category=symbol.svg +4 -0
- package/svg/Name=double-caret-up, Category=symbol.svg +4 -0
- package/svg/Name=download, Category=symbol.svg +5 -0
- package/svg/Name=dropper, Category=object.svg +5 -0
- package/svg/Name=envelope, Category=object.svg +3 -0
- package/svg/Name=exclamation-close, Category=symbol.svg +4 -0
- package/svg/Name=exclamation-open, Category=symbol.svg +4 -0
- package/svg/Name=external-link, Category=symbol.svg +3 -0
- package/svg/Name=eye, Category=object.svg +4 -0
- package/svg/Name=eye-hidden, Category=object.svg +7 -0
- package/svg/Name=facebook, Category=social.svg +3 -0
- package/svg/Name=form, Category=symbol.svg +8 -0
- package/svg/Name=game-control, Category=object.svg +3 -0
- package/svg/Name=gear, Category=object.svg +3 -0
- package/svg/Name=github, Category=social.svg +3 -0
- package/svg/Name=house, Category=object.svg +3 -0
- package/svg/Name=hyphen, Category=symbol.svg +3 -0
- package/svg/Name=info, Category=symbol.svg +3 -0
- package/svg/Name=instagram, Category=social.svg +3 -0
- package/svg/Name=link, Category=symbol.svg +5 -0
- package/svg/Name=linkedin, Category=social.svg +3 -0
- package/svg/Name=magnifying-glass, Category=object.svg +3 -0
- package/svg/Name=message, Category=symbol.svg +4 -0
- package/svg/Name=moon, Category=object.svg +5 -0
- package/svg/Name=order-list, Category=symbol.svg +7 -0
- package/svg/Name=pencil, Category=object.svg +3 -0
- package/svg/Name=pin-location, Category=symbol.svg +3 -0
- package/svg/Name=question-mark-close, Category=symbol.svg +3 -0
- package/svg/Name=question-mark-open, Category=symbol.svg +3 -0
- package/svg/Name=share, Category=symbol.svg +5 -0
- package/svg/Name=spinner, Category=symbol.svg +9 -0
- package/svg/Name=star, Category=object.svg +3 -0
- package/svg/Name=star-empty, Category=object.svg +3 -0
- package/svg/Name=sun, Category=object.svg +11 -0
- package/svg/Name=text-shadow, Category=symbol.svg +4 -0
- package/svg/Name=thinking, Category=symbol.svg +3 -0
- package/svg/Name=trash-can, Category=object.svg +4 -0
- package/svg/Name=upload, Category=symbol.svg +5 -0
- package/svg/Name=user, Category=symbol.svg +4 -0
- package/svg/Name=warning, Category=symbol.svg +5 -0
- package/svg/Name=whatsapp, Category=social.svg +3 -0
- package/svgconfig.json +4 -0
- package/tsconfig.json +14 -0
- package/tsup.config.cjs +21 -0
- package/vite.config.ts +13 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { InputFieldProps } from '../field';
|
|
4
|
+
import { ControllerGeneratorProps, UnControlledComponentProps } from '../form.types';
|
|
5
|
+
|
|
6
|
+
export type SelectItem = string | number | Record<string, unknown> | unknown;
|
|
7
|
+
|
|
8
|
+
export type MultiValue<T extends SelectItem> = Array<T>;
|
|
9
|
+
|
|
10
|
+
export type SingleValue<T extends SelectItem> = T | null;
|
|
11
|
+
|
|
12
|
+
export type SelectValue<T extends SelectItem> = SingleValue<T> | MultiValue<T>;
|
|
13
|
+
|
|
14
|
+
// SELECT
|
|
15
|
+
|
|
16
|
+
export type SharedSelectProps<T extends SelectItem> = InputFieldProps<{
|
|
17
|
+
options: Array<T>;
|
|
18
|
+
renderOption: (item: T) => React.ReactNode;
|
|
19
|
+
isEqualComparator?: (a: T, b: T) => boolean;
|
|
20
|
+
searchQueryValue?: string;
|
|
21
|
+
searchQueryPlaceholder?: string;
|
|
22
|
+
onSearchQuery?: (value: string) => void;
|
|
23
|
+
loadMore?: () => void;
|
|
24
|
+
isLoading?: boolean;
|
|
25
|
+
hasNextPage?: boolean;
|
|
26
|
+
maxOptions?: number;
|
|
27
|
+
showClearOption?: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
|
|
30
|
+
export type MultiSelectProps<T extends SelectItem> = SharedSelectProps<T> & {
|
|
31
|
+
multiselect: true;
|
|
32
|
+
optionVariant?: `${SelectOptionVariant}`;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type SingleSelectProps<T extends SelectItem> = SharedSelectProps<T> & {
|
|
36
|
+
multiselect?: false;
|
|
37
|
+
optionVariant?: never;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type UnControlledSelectProps<T extends SelectItem> =
|
|
41
|
+
| UnControlledComponentProps<MultiSelectProps<T>, MultiValue<T>>
|
|
42
|
+
| UnControlledComponentProps<SingleSelectProps<T>, SingleValue<T>>;
|
|
43
|
+
|
|
44
|
+
export type ControllerGeneratorSelectProps<T extends SelectItem> =
|
|
45
|
+
| ControllerGeneratorProps<MultiSelectProps<T>, MultiValue<T>>
|
|
46
|
+
| ControllerGeneratorProps<SingleSelectProps<T>, SingleValue<T>>;
|
|
47
|
+
|
|
48
|
+
// SELECT OPTIONS
|
|
49
|
+
|
|
50
|
+
export type OptionsProps<T extends SelectItem> = {
|
|
51
|
+
isOpen: boolean;
|
|
52
|
+
style?: React.CSSProperties;
|
|
53
|
+
onSearchQuery?: (value: string) => void;
|
|
54
|
+
searchQueryValue?: string;
|
|
55
|
+
searchQueryPlaceholder?: string;
|
|
56
|
+
compareValueOrValuesAreEqual: (a: T, b: SelectValue<T>) => boolean;
|
|
57
|
+
loadMore?: () => void;
|
|
58
|
+
isLoading?: boolean;
|
|
59
|
+
hasNextPage?: boolean;
|
|
60
|
+
options: Array<T>;
|
|
61
|
+
selectOption: (option: T) => void;
|
|
62
|
+
unselectOption: (option: T) => void;
|
|
63
|
+
modalRef: React.RefObject<HTMLElement>;
|
|
64
|
+
Component: React.FC<OptionComponentProps<T>>;
|
|
65
|
+
multiselect?: boolean;
|
|
66
|
+
value: SelectValue<T>;
|
|
67
|
+
variant: `${SelectOptionVariant}`;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// SELECT OPTION
|
|
71
|
+
|
|
72
|
+
export enum SelectOptionVariant {
|
|
73
|
+
CHECKBOX = 'checkbox',
|
|
74
|
+
ICON = 'icon',
|
|
75
|
+
DEFAULT = 'default',
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type OptionComponentProps<T extends SelectItem> = {
|
|
79
|
+
data: T;
|
|
80
|
+
isSelected: boolean;
|
|
81
|
+
multiselect: boolean;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type SelectOptionProps<T extends SelectItem> = {
|
|
85
|
+
id: string;
|
|
86
|
+
selected: boolean;
|
|
87
|
+
selectOption: (value: T) => void;
|
|
88
|
+
unselectOption: (value: T) => void;
|
|
89
|
+
data: T;
|
|
90
|
+
multiselect: boolean;
|
|
91
|
+
Component: React.FC<OptionComponentProps<T>>;
|
|
92
|
+
variant: `${SelectOptionVariant}`;
|
|
93
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './slider';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { FieldSharedArgs, FieldSharedArgTypes } from '../field/field.stories';
|
|
4
|
+
import { ContainerDecorator, UnControlledComponentArgTypes } from '../form.stories.types';
|
|
5
|
+
|
|
6
|
+
import { Slider } from './slider';
|
|
7
|
+
|
|
8
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof Slider> = {
|
|
11
|
+
title: 'Form/Slider',
|
|
12
|
+
component: Slider,
|
|
13
|
+
argTypes: {
|
|
14
|
+
...FieldSharedArgTypes,
|
|
15
|
+
...UnControlledComponentArgTypes,
|
|
16
|
+
min: { control: 'number' },
|
|
17
|
+
max: { control: 'number' },
|
|
18
|
+
step: { control: 'number' },
|
|
19
|
+
},
|
|
20
|
+
args: {
|
|
21
|
+
label: 'Slider',
|
|
22
|
+
min: 0,
|
|
23
|
+
max: 100,
|
|
24
|
+
step: 1,
|
|
25
|
+
...FieldSharedArgs,
|
|
26
|
+
},
|
|
27
|
+
decorators: [ContainerDecorator],
|
|
28
|
+
render: args => {
|
|
29
|
+
const [value, setValue] = useState(0);
|
|
30
|
+
|
|
31
|
+
return <Slider {...args} value={value} setValue={setValue} />;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default meta;
|
|
36
|
+
type Story = StoryObj<typeof Slider>;
|
|
37
|
+
|
|
38
|
+
export const Default: Story = {
|
|
39
|
+
args: {},
|
|
40
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
type SliderStyleProps = {
|
|
4
|
+
$isFocus: boolean;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const SliderStyle = styled.section<SliderStyleProps>`
|
|
8
|
+
display: grid;
|
|
9
|
+
grid-template-columns: 1fr 50px;
|
|
10
|
+
align-items: center;
|
|
11
|
+
gap: 10px;
|
|
12
|
+
|
|
13
|
+
.slider {
|
|
14
|
+
appearance: none;
|
|
15
|
+
-webkit-appearance: none;
|
|
16
|
+
-moz-appearance: none;
|
|
17
|
+
display: grid;
|
|
18
|
+
align-items: center;
|
|
19
|
+
|
|
20
|
+
&:focus {
|
|
21
|
+
outline: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&::-webkit-slider-thumb {
|
|
25
|
+
-webkit-appearance: none;
|
|
26
|
+
width: 20px;
|
|
27
|
+
height: 20px;
|
|
28
|
+
border-radius: 1em;
|
|
29
|
+
background: ${props => props.theme.colors.primary.main};
|
|
30
|
+
box-shadow: 0 0 0 0 ${props => props.theme.colors.gray5};
|
|
31
|
+
margin-top: -8px;
|
|
32
|
+
transition: all 300ms ease;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&::-webkit-slider-runnable-track {
|
|
37
|
+
height: 4px;
|
|
38
|
+
border-radius: 1em;
|
|
39
|
+
background: ${props => props.theme.colors.primary.light}88;
|
|
40
|
+
transition: all 300ms ease;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&:focus,
|
|
44
|
+
&:hover {
|
|
45
|
+
&::-webkit-slider-thumb {
|
|
46
|
+
background: ${props => props.theme.colors.primary.main};
|
|
47
|
+
box-shadow: 0 0 0 6px ${props => props.theme.colors.primary.main}88;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&:active {
|
|
52
|
+
&::-webkit-slider-thumb {
|
|
53
|
+
box-shadow: 0 0 0 12px ${props => props.theme.colors.primary.main}55;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:focus {
|
|
58
|
+
&::-webkit-slider-runnable-track {
|
|
59
|
+
background: ${props => props.theme.colors.primary.light};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&:has(.slider-number:focus) .slider::-webkit-slider-thumb,
|
|
65
|
+
&:has(.slider-number:hover) .slider::-webkit-slider-thumb {
|
|
66
|
+
background: ${props => props.theme.colors.primary.main};
|
|
67
|
+
box-shadow: 0 0 0 6px ${props => props.theme.colors.primary.main}55;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.slider-number {
|
|
71
|
+
transition: all 300ms ease;
|
|
72
|
+
border: 1px solid;
|
|
73
|
+
border-radius: 5px;
|
|
74
|
+
text-align: center;
|
|
75
|
+
font-size: ${props => props.theme.constants.typography.label.fontSize};
|
|
76
|
+
appearance: none;
|
|
77
|
+
-webkit-appearance: none;
|
|
78
|
+
-moz-appearance: none;
|
|
79
|
+
width: 100%;
|
|
80
|
+
padding: 4px 8px;
|
|
81
|
+
font-weight: bold;
|
|
82
|
+
color: ${props => (props.$isFocus ? props.theme.colors.primary : 'inherit')};
|
|
83
|
+
|
|
84
|
+
&::-webkit-outer-spin-button,
|
|
85
|
+
&::-webkit-inner-spin-button {
|
|
86
|
+
-webkit-appearance: none;
|
|
87
|
+
margin: 0;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Controller } from '../controller';
|
|
4
|
+
import { Field, InputFieldProps } from '../field';
|
|
5
|
+
import { ControllerGeneratorProps, UnControlledComponentProps } from '../form.types';
|
|
6
|
+
|
|
7
|
+
import { SliderStyle } from './slider.style';
|
|
8
|
+
|
|
9
|
+
import { useInputHandlers } from '@polpo/hooks';
|
|
10
|
+
|
|
11
|
+
type SliderProps = InputFieldProps<{
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
step?: number;
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
export const Slider = ({
|
|
18
|
+
name,
|
|
19
|
+
value,
|
|
20
|
+
setValue,
|
|
21
|
+
onBlur,
|
|
22
|
+
onFocus,
|
|
23
|
+
min,
|
|
24
|
+
max,
|
|
25
|
+
step,
|
|
26
|
+
className = '',
|
|
27
|
+
style = {},
|
|
28
|
+
autoFocus = false,
|
|
29
|
+
readOnly = false,
|
|
30
|
+
disabled = false,
|
|
31
|
+
placeholder = '',
|
|
32
|
+
autoComplete = 'off',
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
34
|
+
isDirty = false,
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
36
|
+
isTouched = false,
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
38
|
+
invalid = false,
|
|
39
|
+
error,
|
|
40
|
+
...fieldProps
|
|
41
|
+
}: UnControlledComponentProps<SliderProps, number>) => {
|
|
42
|
+
const id = useMemo(() => crypto.randomUUID(), []);
|
|
43
|
+
const onBlurInput = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
44
|
+
onBlur && onBlur(e);
|
|
45
|
+
const parsedValue = parseInt(`${value}`);
|
|
46
|
+
|
|
47
|
+
if (min !== undefined && parsedValue < min) {
|
|
48
|
+
setValue(min);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (max !== undefined && parsedValue > max) {
|
|
52
|
+
setValue(max);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setValue(parsedValue);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const { isFocus, handlers } = useInputHandlers({
|
|
59
|
+
onBlur: onBlurInput,
|
|
60
|
+
onChange: e => setValue(+e.target.value),
|
|
61
|
+
onFocus: onFocus,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<Field id={id} error={error} isFocus={isFocus} {...fieldProps}>
|
|
66
|
+
<SliderStyle $isFocus={isFocus}>
|
|
67
|
+
<input
|
|
68
|
+
id={id}
|
|
69
|
+
type='range'
|
|
70
|
+
name={name}
|
|
71
|
+
className={`slider ${className}`}
|
|
72
|
+
style={style}
|
|
73
|
+
value={value}
|
|
74
|
+
autoFocus={autoFocus}
|
|
75
|
+
autoComplete={autoComplete}
|
|
76
|
+
placeholder={placeholder}
|
|
77
|
+
disabled={disabled}
|
|
78
|
+
readOnly={readOnly}
|
|
79
|
+
min={min}
|
|
80
|
+
max={max}
|
|
81
|
+
step={step}
|
|
82
|
+
{...handlers}
|
|
83
|
+
/>
|
|
84
|
+
<input
|
|
85
|
+
id={id}
|
|
86
|
+
type='number'
|
|
87
|
+
name={name}
|
|
88
|
+
className={`slider-number ${className}`}
|
|
89
|
+
style={style}
|
|
90
|
+
value={value}
|
|
91
|
+
autoComplete={autoComplete}
|
|
92
|
+
disabled={disabled}
|
|
93
|
+
readOnly={readOnly}
|
|
94
|
+
min={min}
|
|
95
|
+
max={max}
|
|
96
|
+
step={step}
|
|
97
|
+
{...handlers}
|
|
98
|
+
/>
|
|
99
|
+
</SliderStyle>
|
|
100
|
+
</Field>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const SliderController = ({ rules, ...props }: ControllerGeneratorProps<SliderProps, number>) => {
|
|
105
|
+
return <Controller Component={Slider} defaultValue={0} inputProps={props} rules={rules} />;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
Slider.Controller = SliderController;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './switch';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { IconNames } from '../../icon';
|
|
4
|
+
import { UnControlledComponentArgTypes } from '../form.stories.types';
|
|
5
|
+
|
|
6
|
+
import { Switch } from './switch';
|
|
7
|
+
|
|
8
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof Switch> = {
|
|
11
|
+
title: 'Form/Switch',
|
|
12
|
+
component: Switch,
|
|
13
|
+
argTypes: {
|
|
14
|
+
...UnControlledComponentArgTypes,
|
|
15
|
+
label: { control: 'text' },
|
|
16
|
+
width: { control: { type: 'range', min: 3, max: 5, step: 0.05 } },
|
|
17
|
+
dotSize: { control: { type: 'range', min: 1, max: 5, step: 0.05 } },
|
|
18
|
+
dotHoverSize: { control: { type: 'range', min: 1, max: 2, step: 0.05 } },
|
|
19
|
+
padding: { control: { type: 'range', min: 0, max: 5, step: 0.05 } },
|
|
20
|
+
leftIcon: { control: 'select', options: [undefined, ...IconNames.toSorted()] },
|
|
21
|
+
rightIcon: { control: 'select', options: [undefined, ...IconNames.toSorted()] },
|
|
22
|
+
},
|
|
23
|
+
args: {
|
|
24
|
+
label: 'Switch',
|
|
25
|
+
},
|
|
26
|
+
render: args => {
|
|
27
|
+
const [value, setValue] = useState(false);
|
|
28
|
+
|
|
29
|
+
return <Switch {...args} value={value} setValue={setValue} />;
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default meta;
|
|
34
|
+
type Story = StoryObj<typeof Switch>;
|
|
35
|
+
|
|
36
|
+
export const Default: Story = {
|
|
37
|
+
args: {},
|
|
38
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
type SwitchStyleProps = {
|
|
4
|
+
$padding: number;
|
|
5
|
+
$width: number;
|
|
6
|
+
$dotSize: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const SwitchStyle = styled.section<SwitchStyleProps>(
|
|
10
|
+
({ $width, $dotSize, $padding, theme }) => css`
|
|
11
|
+
width: ${$width}em;
|
|
12
|
+
border-radius: 100em;
|
|
13
|
+
background: ${theme.colors.background.paper};
|
|
14
|
+
padding: ${$padding}em;
|
|
15
|
+
transition: all 300ms ease;
|
|
16
|
+
position: relative;
|
|
17
|
+
|
|
18
|
+
.switch-dot {
|
|
19
|
+
width: ${$dotSize}em;
|
|
20
|
+
height: ${$dotSize}em;
|
|
21
|
+
border-radius: 100em;
|
|
22
|
+
background: ${theme.colors.white};
|
|
23
|
+
display: block;
|
|
24
|
+
transition: all 300ms ease;
|
|
25
|
+
margin-left: 0;
|
|
26
|
+
position: relative;
|
|
27
|
+
z-index: 1;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.switch-left-icon,
|
|
31
|
+
.switch-right-icon {
|
|
32
|
+
width: ${$dotSize}em;
|
|
33
|
+
height: ${$dotSize}em;
|
|
34
|
+
position: absolute;
|
|
35
|
+
top: ${$padding}em;
|
|
36
|
+
display: grid;
|
|
37
|
+
place-content: center;
|
|
38
|
+
color: ${theme.colors.white};
|
|
39
|
+
transition: all 300ms ease;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.switch-left-icon {
|
|
43
|
+
left: ${$padding}em;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.switch-right-icon {
|
|
47
|
+
right: ${$padding}em;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&.is-checked {
|
|
51
|
+
background: ${theme.colors.primary.main};
|
|
52
|
+
|
|
53
|
+
.switch-dot {
|
|
54
|
+
margin-left: ${$width - $dotSize - $padding * 2}em;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&:not(.is-readonly):has(input:disabled) {
|
|
59
|
+
background: ${theme.colors.background.disabled};
|
|
60
|
+
|
|
61
|
+
.switch-dot {
|
|
62
|
+
background: ${theme.colors.text.disabled};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.switch-left-icon,
|
|
66
|
+
.switch-right-icon {
|
|
67
|
+
color: ${theme.colors.text.disabled};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&.is-checked {
|
|
71
|
+
background: ${theme.colors.primary.dark};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.switch-checkbox {
|
|
76
|
+
position: absolute;
|
|
77
|
+
top: 0;
|
|
78
|
+
left: 0;
|
|
79
|
+
width: 100%;
|
|
80
|
+
height: 100%;
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
opacity: 0;
|
|
83
|
+
z-index: 3;
|
|
84
|
+
}
|
|
85
|
+
`,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
type SwitchContainerStyle = {
|
|
89
|
+
$padding: number;
|
|
90
|
+
$width: number;
|
|
91
|
+
$dotHoverSize: number;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const SwitchContainerStyle = styled.section<SwitchContainerStyle>(
|
|
95
|
+
({ $padding, $width, $dotHoverSize }) => css`
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
gap: 1em;
|
|
99
|
+
width: fit-content;
|
|
100
|
+
|
|
101
|
+
.switch-label {
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
user-select: none;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
${SwitchStyle}:hover .switch-dot {
|
|
107
|
+
box-shadow: 0 0 0 0.4em ${props => props.theme.colors.primary.main}88;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
${SwitchStyle}:active .switch-dot,
|
|
111
|
+
&:has(.switch-label:active) .switch-dot {
|
|
112
|
+
width: ${$dotHoverSize}em;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
${SwitchStyle}.is-checked:active .switch-dot,
|
|
116
|
+
&:has(.switch-label:active) ${SwitchStyle}.is-checked .switch-dot {
|
|
117
|
+
margin-left: ${$width - $dotHoverSize - $padding * 2}em;
|
|
118
|
+
}
|
|
119
|
+
`,
|
|
120
|
+
);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Icon, IconNameT } from '../../icon';
|
|
4
|
+
import { Typography } from '../../typography';
|
|
5
|
+
import { Controller } from '../controller';
|
|
6
|
+
import { ControllerGeneratorProps, UnControlledComponentProps } from '../form.types';
|
|
7
|
+
|
|
8
|
+
import { SwitchContainerStyle, SwitchStyle } from './switch.style';
|
|
9
|
+
|
|
10
|
+
import { useClassNames, useInputHandlers } from '@polpo/hooks';
|
|
11
|
+
|
|
12
|
+
type SwitchProps = {
|
|
13
|
+
label?: string;
|
|
14
|
+
width?: number;
|
|
15
|
+
dotSize?: number;
|
|
16
|
+
dotHoverSize?: number;
|
|
17
|
+
padding?: number;
|
|
18
|
+
leftIcon?: IconNameT;
|
|
19
|
+
rightIcon?: IconNameT;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const Switch = ({
|
|
23
|
+
name,
|
|
24
|
+
value,
|
|
25
|
+
setValue,
|
|
26
|
+
onBlur,
|
|
27
|
+
onFocus,
|
|
28
|
+
className = '',
|
|
29
|
+
style = {},
|
|
30
|
+
autoFocus = false,
|
|
31
|
+
readOnly = false,
|
|
32
|
+
disabled = false,
|
|
33
|
+
placeholder = '',
|
|
34
|
+
autoComplete = 'off',
|
|
35
|
+
label,
|
|
36
|
+
width = 3,
|
|
37
|
+
dotSize = 1.2,
|
|
38
|
+
dotHoverSize = 1.2,
|
|
39
|
+
padding = 0.25,
|
|
40
|
+
leftIcon,
|
|
41
|
+
rightIcon,
|
|
42
|
+
/*
|
|
43
|
+
* isDirty = false,
|
|
44
|
+
* isTouched = false,
|
|
45
|
+
* invalid = false,
|
|
46
|
+
* error,
|
|
47
|
+
*/
|
|
48
|
+
}: UnControlledComponentProps<SwitchProps, boolean>) => {
|
|
49
|
+
const id = useMemo(() => crypto.randomUUID(), []);
|
|
50
|
+
const { handlers } = useInputHandlers<HTMLInputElement>({
|
|
51
|
+
onChange: e => setValue(e.target.checked),
|
|
52
|
+
onBlur: onBlur,
|
|
53
|
+
onFocus: onFocus,
|
|
54
|
+
});
|
|
55
|
+
const swicthClassName = useClassNames({
|
|
56
|
+
'is-checked': value,
|
|
57
|
+
'is-readonly': !disabled && readOnly,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const _width = Math.max(width, 3) * dotSize;
|
|
61
|
+
const _dotHoverSize = Math.min(Math.max(dotHoverSize, 1), 2) * dotSize;
|
|
62
|
+
const _padding = Math.min(padding, (_width - 0.5 - dotSize * 2) / 2);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<SwitchContainerStyle
|
|
66
|
+
$width={_width}
|
|
67
|
+
$padding={_padding}
|
|
68
|
+
$dotHoverSize={_dotHoverSize}
|
|
69
|
+
className={className}
|
|
70
|
+
style={style}
|
|
71
|
+
>
|
|
72
|
+
<SwitchStyle $width={_width} $padding={_padding} $dotSize={dotSize} className={swicthClassName}>
|
|
73
|
+
{leftIcon !== undefined && (
|
|
74
|
+
<span className='switch-left-icon'>
|
|
75
|
+
<Icon name={leftIcon} size={`${dotSize * 0.7}em`} />
|
|
76
|
+
</span>
|
|
77
|
+
)}
|
|
78
|
+
{rightIcon !== undefined && (
|
|
79
|
+
<span className='switch-right-icon'>
|
|
80
|
+
<Icon name={rightIcon} size={`${dotSize * 0.7}em`} />
|
|
81
|
+
</span>
|
|
82
|
+
)}
|
|
83
|
+
<span className='switch-dot' />
|
|
84
|
+
<input
|
|
85
|
+
id={id}
|
|
86
|
+
type='checkbox'
|
|
87
|
+
name={name}
|
|
88
|
+
className={`switch-checkbox ${className}`}
|
|
89
|
+
style={style}
|
|
90
|
+
checked={value}
|
|
91
|
+
autoFocus={autoFocus}
|
|
92
|
+
autoComplete={autoComplete}
|
|
93
|
+
placeholder={placeholder}
|
|
94
|
+
disabled={disabled || readOnly}
|
|
95
|
+
{...handlers}
|
|
96
|
+
/>
|
|
97
|
+
</SwitchStyle>
|
|
98
|
+
{label ? (
|
|
99
|
+
<Typography variant='label-form' className='switch-label' htmlFor={id}>
|
|
100
|
+
{label}
|
|
101
|
+
</Typography>
|
|
102
|
+
) : null}
|
|
103
|
+
</SwitchContainerStyle>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const SwitchController = ({ rules, ...props }: ControllerGeneratorProps<SwitchProps, boolean>) => {
|
|
108
|
+
return <Controller Component={Switch} defaultValue={false} inputProps={props} rules={rules} />;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
Switch.Controller = SwitchController;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './textarea';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { FieldSharedArgs, FieldSharedArgTypes } from '../field/field.stories';
|
|
4
|
+
import { ContainerDecorator, UnControlledComponentArgTypes } from '../form.stories.types';
|
|
5
|
+
|
|
6
|
+
import { Textarea } from './textarea';
|
|
7
|
+
|
|
8
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof Textarea> = {
|
|
11
|
+
title: 'Form/Textarea',
|
|
12
|
+
component: Textarea,
|
|
13
|
+
argTypes: {
|
|
14
|
+
...FieldSharedArgTypes,
|
|
15
|
+
...UnControlledComponentArgTypes,
|
|
16
|
+
rows: { control: 'number' },
|
|
17
|
+
resize: { control: 'select', options: ['none', 'vertical', 'horizontal', 'both'] },
|
|
18
|
+
rightIcon: { table: { disable: true } },
|
|
19
|
+
leftIcon: { table: { disable: true } },
|
|
20
|
+
},
|
|
21
|
+
args: {
|
|
22
|
+
label: 'Textarea',
|
|
23
|
+
rows: 4,
|
|
24
|
+
resize: 'vertical',
|
|
25
|
+
placeholder: 'Textarea',
|
|
26
|
+
...FieldSharedArgs,
|
|
27
|
+
leftIcon: undefined,
|
|
28
|
+
rightIcon: undefined,
|
|
29
|
+
},
|
|
30
|
+
decorators: [ContainerDecorator],
|
|
31
|
+
render: args => {
|
|
32
|
+
const [value, setValue] = useState('');
|
|
33
|
+
|
|
34
|
+
return <Textarea {...args} value={value} setValue={setValue} />;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default meta;
|
|
39
|
+
type Story = StoryObj<typeof Textarea>;
|
|
40
|
+
|
|
41
|
+
export const Default: Story = {
|
|
42
|
+
args: {},
|
|
43
|
+
};
|