@scbt-ecom/ui 0.4.0 → 0.4.2
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/.env +3 -0
- package/.github/workflows/publish.yml +61 -0
- package/.github/workflows/setup-node/action.yml +22 -0
- package/.husky/pre-commit +1 -0
- package/.prettierignore +1 -0
- package/.prettierrc +20 -0
- package/.releaserc +18 -0
- package/.storybook/main.ts +44 -0
- package/.storybook/preview.tsx +37 -0
- package/chromatic.config.json +5 -0
- package/eslint.config.mjs +193 -0
- package/index.html +13 -0
- package/lib/client.ts +12 -0
- package/lib/configs/index.ts +2 -0
- package/lib/configs/tailwindConfigBase.ts +110 -0
- package/lib/configs/tailwindPresets/extendsPreset.ts +43 -0
- package/lib/configs/tailwindPresets/index.ts +2 -0
- package/lib/configs/tailwindPresets/resetPreset.ts +71 -0
- package/lib/hybrid.ts +25 -0
- package/lib/shared/constants/api.ts +2 -0
- package/lib/shared/constants/designSystem/colors.ts +121 -0
- package/lib/shared/constants/designSystem/index.ts +3 -0
- package/lib/shared/constants/designSystem/others.ts +30 -0
- package/lib/shared/constants/designSystem/typography.ts +88 -0
- package/lib/shared/constants/index.ts +2 -0
- package/lib/shared/hooks/index.ts +5 -0
- package/lib/shared/hooks/useBoolean.ts +12 -0
- package/lib/shared/hooks/useClickOutside.ts +22 -0
- package/lib/shared/hooks/useCombineRef.ts +23 -0
- package/lib/shared/hooks/useControlledForm.ts +16 -0
- package/lib/shared/hooks/useDebounce.ts +38 -0
- package/lib/shared/hooks/useMediaQuery.tsx +42 -0
- package/lib/shared/style.css +118 -0
- package/lib/shared/ui/Badge.tsx +20 -0
- package/lib/shared/ui/Breadcrumbs.tsx +57 -0
- package/lib/shared/ui/ButtonIcon.tsx +50 -0
- package/lib/shared/ui/CustomLink.tsx +76 -0
- package/lib/shared/ui/Document.tsx +51 -0
- package/lib/shared/ui/Heading.tsx +33 -0
- package/lib/shared/ui/Hint.tsx +72 -0
- package/lib/shared/ui/Loader.tsx +58 -0
- package/lib/shared/ui/PhoneView.tsx +23 -0
- package/lib/shared/ui/ProgressBar.tsx +43 -0
- package/lib/shared/ui/ResponsiveContainer.tsx +15 -0
- package/lib/shared/ui/Section.tsx +15 -0
- package/lib/shared/ui/Skeleton.tsx +9 -0
- package/lib/shared/ui/TabsSwitcher.tsx +87 -0
- package/lib/shared/ui/accordion/Accordion.tsx +36 -0
- package/lib/shared/ui/accordion/index.ts +1 -0
- package/lib/shared/ui/accordion/model/types.ts +20 -0
- package/lib/shared/ui/accordion/ui/AccordionHeader.tsx +35 -0
- package/lib/shared/ui/brandLogos.tsx +14 -0
- package/lib/shared/ui/button/Button.tsx +117 -0
- package/lib/shared/ui/button/index.ts +1 -0
- package/lib/shared/ui/button/model/helpers.ts +16 -0
- package/lib/shared/ui/formControlElements/CheckboxControl.tsx +92 -0
- package/lib/shared/ui/formControlElements/FormControl.tsx +5 -0
- package/lib/shared/ui/formControlElements/InputControlMask.tsx +90 -0
- package/lib/shared/ui/formControlElements/RadioControl.tsx +130 -0
- package/lib/shared/ui/formControlElements/SwitchControl.tsx +79 -0
- package/lib/shared/ui/formControlElements/TextareaControl.tsx +96 -0
- package/lib/shared/ui/formControlElements/calendarControl/CalendarControl.tsx +178 -0
- package/lib/shared/ui/formControlElements/calendarControl/hooks/index.ts +2 -0
- package/lib/shared/ui/formControlElements/calendarControl/hooks/useCalendar.tsx +86 -0
- package/lib/shared/ui/formControlElements/calendarControl/hooks/useCalendarDropdowns.ts +38 -0
- package/lib/shared/ui/formControlElements/calendarControl/index.ts +1 -0
- package/lib/shared/ui/formControlElements/calendarControl/model/helpers.ts +60 -0
- package/lib/shared/ui/formControlElements/calendarControl/model/types.ts +44 -0
- package/lib/shared/ui/formControlElements/calendarControl/ui/DaysOfMonth.tsx +53 -0
- package/lib/shared/ui/formControlElements/calendarControl/ui/DaysOfWeek.tsx +28 -0
- package/lib/shared/ui/formControlElements/calendarControl/ui/Dropdown.tsx +62 -0
- package/lib/shared/ui/formControlElements/calendarControl/ui/Header.tsx +51 -0
- package/lib/shared/ui/formControlElements/calendarControl/ui/Navigation.tsx +32 -0
- package/lib/shared/ui/formControlElements/calendarControl/ui/OptionsList.tsx +44 -0
- package/lib/shared/ui/formControlElements/calendarControl/ui/index.ts +4 -0
- package/lib/shared/ui/formControlElements/comboboxControl/ComboboxControl.tsx +134 -0
- package/lib/shared/ui/formControlElements/comboboxControl/index.ts +1 -0
- package/lib/shared/ui/formControlElements/comboboxControl/model/selectClassnames.ts +51 -0
- package/lib/shared/ui/formControlElements/comboboxControl/model/types.ts +42 -0
- package/lib/shared/ui/formControlElements/comboboxControl/ui/ComboboxOption.tsx +38 -0
- package/lib/shared/ui/formControlElements/comboboxControl/ui/DropdownIndicator.tsx +23 -0
- package/lib/shared/ui/formControlElements/comboboxControl/ui/MultiValueRemove.tsx +16 -0
- package/lib/shared/ui/formControlElements/comboboxControl/ui/index.ts +3 -0
- package/lib/shared/ui/formControlElements/dadata/DadataInputControl.tsx +137 -0
- package/lib/shared/ui/formControlElements/dadata/index.ts +1 -0
- package/lib/shared/ui/formControlElements/dadata/model/api.ts +25 -0
- package/lib/shared/ui/formControlElements/dadata/model/helpers.ts +76 -0
- package/lib/shared/ui/formControlElements/dadata/model/types.ts +52 -0
- package/lib/shared/ui/formControlElements/dadata/model/useDadata.ts +25 -0
- package/lib/shared/ui/formControlElements/editorControl/EditorControl.tsx +82 -0
- package/lib/shared/ui/formControlElements/editorControl/components/conrols.tsx +136 -0
- package/lib/shared/ui/formControlElements/editorControl/components/menu.tsx +107 -0
- package/lib/shared/ui/formControlElements/editorControl/index.ts +60 -0
- package/lib/shared/ui/formControlElements/editorControl/ui/RemoveBlockButton.tsx +23 -0
- package/lib/shared/ui/formControlElements/editorControl/ui/ResetBlockType.tsx +17 -0
- package/lib/shared/ui/formControlElements/index.ts +14 -0
- package/lib/shared/ui/formControlElements/inputControl/InputControl.tsx +87 -0
- package/lib/shared/ui/formControlElements/inputControl/index.ts +1 -0
- package/lib/shared/ui/formControlElements/inputControl/model/hooks.tsx +26 -0
- package/lib/shared/ui/formControlElements/inputControlUploader/InputControlUploader.tsx +47 -0
- package/lib/shared/ui/formControlElements/inputControlUploader/index.ts +1 -0
- package/lib/shared/ui/formControlElements/inputControlUploader/model/helpers.ts +18 -0
- package/lib/shared/ui/formControlElements/inputControlUploader/model/hooks/useUploader.tsx +66 -0
- package/lib/shared/ui/formControlElements/inputControlUploader/model/index.ts +1 -0
- package/lib/shared/ui/formControlElements/inputControlUploader/model/types.ts +22 -0
- package/lib/shared/ui/formControlElements/inputControlUploader/ui/File.tsx +35 -0
- package/lib/shared/ui/formControlElements/inputControlUploader/ui/Filename.tsx +40 -0
- package/lib/shared/ui/formControlElements/inputControlUploader/ui/Files.tsx +30 -0
- package/lib/shared/ui/formControlElements/inputControlUploader/ui/Input.tsx +48 -0
- package/lib/shared/ui/formControlElements/inputControlUploader/ui/Uploader.tsx +58 -0
- package/lib/shared/ui/formControlElements/inputControlUploader/ui/index.ts +3 -0
- package/lib/shared/ui/formControlElements/inputCurrencyControl/InputCurrencyControl.tsx +88 -0
- package/lib/shared/ui/formControlElements/inputCurrencyControl/index.ts +1 -0
- package/lib/shared/ui/formControlElements/inputCurrencyControl/model/helpers.ts +46 -0
- package/lib/shared/ui/formControlElements/inputCurrencyControl/model/useInputCurrency.tsx +33 -0
- package/lib/shared/ui/formControlElements/inputCurrencyControl/ui/MenuTrigger.tsx +20 -0
- package/lib/shared/ui/formControlElements/inputCurrencyControl/ui/OptionList.tsx +29 -0
- package/lib/shared/ui/formControlElements/inputCurrencyControl/ui/index.ts +2 -0
- package/lib/shared/ui/formControlElements/inputSliderControl/InputSliderControl.tsx +144 -0
- package/lib/shared/ui/formControlElements/inputSliderControl/index.ts +1 -0
- package/lib/shared/ui/formControlElements/inputSliderControl/model/helpers/dates/getEndWordMonth.ts +14 -0
- package/lib/shared/ui/formControlElements/inputSliderControl/model/helpers/dates/getYearEnding.ts +13 -0
- package/lib/shared/ui/formControlElements/inputSliderControl/model/helpers/dates/index.ts +2 -0
- package/lib/shared/ui/formControlElements/inputSliderControl/model/helpers/formatNumber.ts +6 -0
- package/lib/shared/ui/formControlElements/inputSliderControl/model/helpers/getInputSliderSuffix.ts +20 -0
- package/lib/shared/ui/formControlElements/inputSliderControl/model/helpers/getStepByVariant.ts +29 -0
- package/lib/shared/ui/formControlElements/inputSliderControl/model/helpers/index.ts +4 -0
- package/lib/shared/ui/formControlElements/inputSliderControl/model/types.ts +1 -0
- package/lib/shared/ui/formControlElements/inputSliderControl/model/useSlider.ts +26 -0
- package/lib/shared/ui/formControlElements/inputSliderControl/ui/SliderControl.tsx +47 -0
- package/lib/shared/ui/formControlElements/inputSliderControl/ui/index.ts +1 -0
- package/lib/shared/ui/formControlElements/model/classes-types.ts +22 -0
- package/lib/shared/ui/formControlElements/model/index.ts +2 -0
- package/lib/shared/ui/formControlElements/model/message-view-animation.ts +6 -0
- package/lib/shared/ui/formControlElements/model/props-types.ts +31 -0
- package/lib/shared/ui/formControlElements/ui/FieldAttachment.tsx +76 -0
- package/lib/shared/ui/formControlElements/ui/FieldContainer.tsx +37 -0
- package/lib/shared/ui/formControlElements/ui/FieldWrapper.tsx +33 -0
- package/lib/shared/ui/formControlElements/ui/Label.tsx +32 -0
- package/lib/shared/ui/formControlElements/ui/MessageView.tsx +41 -0
- package/lib/shared/ui/formControlElements/ui/index.ts +4 -0
- package/lib/shared/ui/icon/Icon.tsx +41 -0
- package/lib/shared/ui/icon/index.ts +2 -0
- package/lib/shared/ui/icon/sprite.gen.ts +177 -0
- package/lib/shared/ui/index.ts +68 -0
- package/lib/shared/ui/modal/Modal.tsx +68 -0
- package/lib/shared/ui/modal/index.ts +1 -0
- package/lib/shared/ui/modal/model/helpers.ts +13 -0
- package/lib/shared/ui/modal/ui/ModalHeader.tsx +33 -0
- package/lib/shared/ui/notification/Notification.tsx +31 -0
- package/lib/shared/ui/notification/index.ts +1 -0
- package/lib/shared/ui/notification/ui/CustomToast.tsx +42 -0
- package/lib/shared/ui/popover/Popover.tsx +74 -0
- package/lib/shared/ui/popover/index.ts +1 -0
- package/lib/shared/ui/providers/NotificationProvider.tsx +29 -0
- package/lib/shared/ui/providers/index.ts +1 -0
- package/lib/shared/ui/table/Table.tsx +144 -0
- package/lib/shared/ui/table/index.ts +1 -0
- package/lib/shared/ui/table/type.ts +30 -0
- package/lib/shared/utils/capitalize.ts +6 -0
- package/lib/shared/utils/cn.ts +6 -0
- package/lib/shared/utils/deepCompare.ts +1 -0
- package/lib/shared/utils/formatToDate.ts +5 -0
- package/lib/shared/utils/index.ts +5 -0
- package/lib/shared/utils/isClient.ts +1 -0
- package/lib/shared/validation/index.ts +3 -0
- package/lib/shared/validation/messages.ts +12 -0
- package/lib/shared/validation/regExp.ts +5 -0
- package/lib/shared/validation/zodValidation/calendar.ts +32 -0
- package/lib/shared/validation/zodValidation/dadataFio.ts +67 -0
- package/lib/shared/validation/zodValidation/index.ts +2 -0
- package/lib/vite-env.d.ts +2 -0
- package/lib/widgets/Advantages.tsx +45 -0
- package/lib/widgets/banner/Banner.tsx +74 -0
- package/lib/widgets/banner/index.ts +1 -0
- package/lib/widgets/banner/model/helpers.ts +159 -0
- package/lib/widgets/banner/money.png +0 -0
- package/lib/widgets/banner/saif.jpg +0 -0
- package/lib/widgets/banner/saifMob.jpg +0 -0
- package/lib/widgets/banner/seif.jpg +0 -0
- package/lib/widgets/banner/shield.jpg +0 -0
- package/lib/widgets/banner/shield.png +0 -0
- package/lib/widgets/banner/ui/BannerButtonsGroup.tsx +44 -0
- package/lib/widgets/banner/ui/banners/BannerImageFull.tsx +82 -0
- package/lib/widgets/banner/ui/banners/BannerWithSeparateImg.tsx +60 -0
- package/lib/widgets/banner/ui/banners/index.ts +1 -0
- package/lib/widgets/footer/Footer.tsx +95 -0
- package/lib/widgets/footer/index.ts +1 -0
- package/lib/widgets/footer/model/defaultValues.tsx +105 -0
- package/lib/widgets/footer/model/types.ts +19 -0
- package/lib/widgets/footer/ui/Copyright.tsx +15 -0
- package/lib/widgets/footer/ui/Ligal.tsx +50 -0
- package/lib/widgets/footer/ui/NavLinks.tsx +41 -0
- package/lib/widgets/footer/ui/PhonesBlock.tsx +34 -0
- package/lib/widgets/footer/ui/SocialLinks.tsx +30 -0
- package/lib/widgets/footer/ui/index.ts +5 -0
- package/lib/widgets/index.ts +5 -0
- package/lib/widgets/pageHeader/PageHeader.tsx +54 -0
- package/lib/widgets/pageHeader/index.ts +1 -0
- package/lib/widgets/stepper/Stepper.tsx +43 -0
- package/lib/widgets/stepper/index.ts +1 -0
- package/lib/widgets/stepper/ui/SingleStep.tsx +42 -0
- package/package.json +1 -4
- package/postcss.config.mjs +8 -0
- package/public/sprites/arrows.svg +1 -0
- package/public/sprites/brandLogos.svg +1 -0
- package/public/sprites/files.svg +1 -0
- package/public/sprites/general.svg +1 -0
- package/public/sprites/info.svg +1 -0
- package/public/sprites/social.svg +1 -0
- package/src/App.tsx +9 -0
- package/src/app/providers/RootProvider.tsx +11 -0
- package/src/app/providers/index.ts +1 -0
- package/src/app/providers/model/types.ts +5 -0
- package/src/configs/setup.ts +9 -0
- package/src/configs/storybook.config.ts +23 -0
- package/src/main.tsx +10 -0
- package/src/stories/primitives/Accordion.stories.tsx +66 -0
- package/src/stories/primitives/Badge.stories.tsx +28 -0
- package/src/stories/primitives/Breadcrumbs.stories.tsx +29 -0
- package/src/stories/primitives/Button/Button.stories.tsx +149 -0
- package/src/stories/primitives/Button/Button.test.tsx +150 -0
- package/src/stories/primitives/ButtonIcon.stories.tsx +75 -0
- package/src/stories/primitives/CustomLink.stories.tsx +64 -0
- package/src/stories/primitives/Document.stories.tsx +36 -0
- package/src/stories/primitives/Heading.stories.tsx +29 -0
- package/src/stories/primitives/Hint.stories.tsx +82 -0
- package/src/stories/primitives/Icon.stories.tsx +36 -0
- package/src/stories/primitives/Loader.stories.tsx +39 -0
- package/src/stories/primitives/Modal.stories.tsx +106 -0
- package/src/stories/primitives/Notification.stories.tsx +102 -0
- package/src/stories/primitives/PhoneView.stories.tsx +22 -0
- package/src/stories/primitives/Popover.stories.tsx +41 -0
- package/src/stories/primitives/ProgressBar.stories.tsx +68 -0
- package/src/stories/primitives/Skeleton.stories.tsx +21 -0
- package/src/stories/primitives/Table.stories.tsx +44 -0
- package/src/stories/primitives/TabsSwitcher.stories.tsx +45 -0
- package/src/stories/primitives/formControl/CalendarControl.stories.tsx +45 -0
- package/src/stories/primitives/formControl/CheckboxControl.stories.tsx +64 -0
- package/src/stories/primitives/formControl/ComboboxControl.stories.tsx +67 -0
- package/src/stories/primitives/formControl/DadataInputControl.stories.tsx +79 -0
- package/src/stories/primitives/formControl/EditorControl.stories.tsx +31 -0
- package/src/stories/primitives/formControl/FormControlAllFields.stories.tsx +25 -0
- package/src/stories/primitives/formControl/InputControl.stories.tsx +84 -0
- package/src/stories/primitives/formControl/InputControlPassword.stories.tsx +38 -0
- package/src/stories/primitives/formControl/InputControlUploader.stories.tsx +44 -0
- package/src/stories/primitives/formControl/InputCurrencyControl.stories.tsx +73 -0
- package/src/stories/primitives/formControl/InputSliderControl.stories.tsx +62 -0
- package/src/stories/primitives/formControl/RadioContol.stories.tsx +61 -0
- package/src/stories/primitives/formControl/SwitchControl.stories.tsx +51 -0
- package/src/stories/primitives/formControl/TextareaControl.stories.tsx +55 -0
- package/src/stories/primitives/formControl/inputControlMask.stories.tsx +67 -0
- package/src/stories/widgets/Advantages.stories.tsx +42 -0
- package/src/stories/widgets/Banner.stories.tsx +94 -0
- package/src/stories/widgets/Footer.stories.tsx +36 -0
- package/src/stories/widgets/PageHeader.stories.tsx +33 -0
- package/src/stories/widgets/Stepper.stories.tsx +24 -0
- package/src/storybookHelpers/actions.tsx +5 -0
- package/src/storybookHelpers/index.ts +2 -0
- package/src/storybookHelpers/reactHookForm/index.ts +3 -0
- package/src/storybookHelpers/reactHookForm/model/mockData.ts +19 -0
- package/src/storybookHelpers/reactHookForm/model/mocks.tsx +105 -0
- package/src/storybookHelpers/reactHookForm/model/renderFields.tsx +58 -0
- package/src/storybookHelpers/reactHookForm/model/types.ts +86 -0
- package/src/storybookHelpers/reactHookForm/ui/StorybookFieldsMapper.tsx +32 -0
- package/src/storybookHelpers/reactHookForm/ui/StorybookFormProvider.tsx +43 -0
- package/src/storybookHelpers/reactHookForm/ui/index.ts +2 -0
- package/src/storybookHelpers/table/utils/defaultValue.ts +51 -0
- package/static/arrows/arrowCircle.svg +18 -0
- package/static/arrows/arrowLink.svg +3 -0
- package/static/arrows/arrowRight.svg +3 -0
- package/static/brandLogos/logoBlack.svg +14 -0
- package/static/brandLogos/logoBusiness.svg +80 -0
- package/static/brandLogos/logoGray.svg +56 -0
- package/static/brandLogos/logoInsurance.svg +124 -0
- package/static/brandLogos/logoMain.svg +14 -0
- package/static/brandLogos/logoWhite.svg +56 -0
- package/static/files/border.svg +6 -0
- package/static/files/borderError.svg +6 -0
- package/static/files/documentFilled.svg +4 -0
- package/static/files/documentOutline.svg +4 -0
- package/static/files/upload.svg +3 -0
- package/static/general/calendar.svg +3 -0
- package/static/general/check.svg +6 -0
- package/static/general/close.svg +12 -0
- package/static/general/edit.svg +4 -0
- package/static/general/hiddenEye.svg +4 -0
- package/static/general/plus.svg +3 -0
- package/static/general/showEye.svg +4 -0
- package/static/info/warningCircle.svg +5 -0
- package/static/social/classmates.svg +3 -0
- package/static/social/telegram.svg +3 -0
- package/static/social/vk.svg +3 -0
- package/tailwind.config.ts +10 -0
- package/tsconfig.json +33 -0
- package/tsconfig.node.json +11 -0
- package/vite.config.ts +68 -0
- package/vitest.config.mjs +12 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
export interface SpritesMap {
|
|
2
|
+
arrows: 'arrowCircle' | 'arrowLink' | 'arrowRight'
|
|
3
|
+
brandLogos: 'logoBlack' | 'logoBusiness' | 'logoGray' | 'logoInsurance' | 'logoMain' | 'logoWhite'
|
|
4
|
+
files: 'border' | 'borderError' | 'documentFilled' | 'documentOutline' | 'upload'
|
|
5
|
+
general: 'calendar' | 'check' | 'close' | 'edit' | 'hiddenEye' | 'plus' | 'showEye'
|
|
6
|
+
info: 'warningCircle'
|
|
7
|
+
social: 'classmates' | 'telegram' | 'vk'
|
|
8
|
+
}
|
|
9
|
+
export const SPRITES_META: {
|
|
10
|
+
[Key in keyof SpritesMap]: {
|
|
11
|
+
filePath: string
|
|
12
|
+
items: Record<
|
|
13
|
+
SpritesMap[Key],
|
|
14
|
+
{
|
|
15
|
+
viewBox: string
|
|
16
|
+
width: number
|
|
17
|
+
height: number
|
|
18
|
+
}
|
|
19
|
+
>
|
|
20
|
+
}
|
|
21
|
+
} = {
|
|
22
|
+
arrows: {
|
|
23
|
+
filePath: 'arrows.svg',
|
|
24
|
+
items: {
|
|
25
|
+
arrowCircle: {
|
|
26
|
+
viewBox: '0 0 32 32',
|
|
27
|
+
width: 32,
|
|
28
|
+
height: 32
|
|
29
|
+
},
|
|
30
|
+
arrowLink: {
|
|
31
|
+
viewBox: '0 0 24 24',
|
|
32
|
+
width: 24,
|
|
33
|
+
height: 24
|
|
34
|
+
},
|
|
35
|
+
arrowRight: {
|
|
36
|
+
viewBox: '0 0 16 17',
|
|
37
|
+
width: 16,
|
|
38
|
+
height: 17
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
brandLogos: {
|
|
43
|
+
filePath: 'brandLogos.svg',
|
|
44
|
+
items: {
|
|
45
|
+
logoBlack: {
|
|
46
|
+
viewBox: '0 0 194 32',
|
|
47
|
+
width: 194,
|
|
48
|
+
height: 32
|
|
49
|
+
},
|
|
50
|
+
logoBusiness: {
|
|
51
|
+
viewBox: '0 0 192 32',
|
|
52
|
+
width: 192,
|
|
53
|
+
height: 32
|
|
54
|
+
},
|
|
55
|
+
logoGray: {
|
|
56
|
+
viewBox: '0 0 194 32',
|
|
57
|
+
width: 194,
|
|
58
|
+
height: 32
|
|
59
|
+
},
|
|
60
|
+
logoInsurance: {
|
|
61
|
+
viewBox: '0 0 193 32',
|
|
62
|
+
width: 193,
|
|
63
|
+
height: 32
|
|
64
|
+
},
|
|
65
|
+
logoMain: {
|
|
66
|
+
viewBox: '0 0 192 32',
|
|
67
|
+
width: 192,
|
|
68
|
+
height: 32
|
|
69
|
+
},
|
|
70
|
+
logoWhite: {
|
|
71
|
+
viewBox: '0 0 194 32',
|
|
72
|
+
width: 194,
|
|
73
|
+
height: 32
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
files: {
|
|
78
|
+
filePath: 'files.svg',
|
|
79
|
+
items: {
|
|
80
|
+
border: {
|
|
81
|
+
viewBox: '0 0 476 64',
|
|
82
|
+
width: 476,
|
|
83
|
+
height: 64
|
|
84
|
+
},
|
|
85
|
+
borderError: {
|
|
86
|
+
viewBox: '0 0 476 64',
|
|
87
|
+
width: 476,
|
|
88
|
+
height: 64
|
|
89
|
+
},
|
|
90
|
+
documentFilled: {
|
|
91
|
+
viewBox: '0 0 22 28',
|
|
92
|
+
width: 22,
|
|
93
|
+
height: 28
|
|
94
|
+
},
|
|
95
|
+
documentOutline: {
|
|
96
|
+
viewBox: '0 0 22 28',
|
|
97
|
+
width: 22,
|
|
98
|
+
height: 28
|
|
99
|
+
},
|
|
100
|
+
upload: {
|
|
101
|
+
viewBox: '0 0 23 20',
|
|
102
|
+
width: 23,
|
|
103
|
+
height: 20
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
general: {
|
|
108
|
+
filePath: 'general.svg',
|
|
109
|
+
items: {
|
|
110
|
+
calendar: {
|
|
111
|
+
viewBox: '0 0 19 20',
|
|
112
|
+
width: 19,
|
|
113
|
+
height: 20
|
|
114
|
+
},
|
|
115
|
+
check: {
|
|
116
|
+
viewBox: '0 0 24 24',
|
|
117
|
+
width: 800,
|
|
118
|
+
height: 800
|
|
119
|
+
},
|
|
120
|
+
close: {
|
|
121
|
+
viewBox: '0 0 24 24',
|
|
122
|
+
width: 24,
|
|
123
|
+
height: 24
|
|
124
|
+
},
|
|
125
|
+
edit: {
|
|
126
|
+
viewBox: '0 0 19 19',
|
|
127
|
+
width: 19,
|
|
128
|
+
height: 19
|
|
129
|
+
},
|
|
130
|
+
hiddenEye: {
|
|
131
|
+
viewBox: '0 0 20 18',
|
|
132
|
+
width: 20,
|
|
133
|
+
height: 18
|
|
134
|
+
},
|
|
135
|
+
plus: {
|
|
136
|
+
viewBox: '0 0 16 16',
|
|
137
|
+
width: 16,
|
|
138
|
+
height: 16
|
|
139
|
+
},
|
|
140
|
+
showEye: {
|
|
141
|
+
viewBox: '0 0 20 14',
|
|
142
|
+
width: 20,
|
|
143
|
+
height: 14
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
info: {
|
|
148
|
+
filePath: 'info.svg',
|
|
149
|
+
items: {
|
|
150
|
+
warningCircle: {
|
|
151
|
+
viewBox: '0 0 20 20',
|
|
152
|
+
width: 20,
|
|
153
|
+
height: 20
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
social: {
|
|
158
|
+
filePath: 'social.svg',
|
|
159
|
+
items: {
|
|
160
|
+
classmates: {
|
|
161
|
+
viewBox: '0 0 9 15',
|
|
162
|
+
width: 9,
|
|
163
|
+
height: 15
|
|
164
|
+
},
|
|
165
|
+
telegram: {
|
|
166
|
+
viewBox: '0 0 15 13',
|
|
167
|
+
width: 15,
|
|
168
|
+
height: 13
|
|
169
|
+
},
|
|
170
|
+
vk: {
|
|
171
|
+
viewBox: '0 0 16 9',
|
|
172
|
+
width: 16,
|
|
173
|
+
height: 9
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// # BASE
|
|
2
|
+
export { Section, type ISectionProps } from './Section'
|
|
3
|
+
export { ResponsiveContainer, type IResponsiveContainerProps } from './ResponsiveContainer'
|
|
4
|
+
export { Button, type IButtonProps } from './button'
|
|
5
|
+
export { ButtonIcon, type IButtonIconProps } from './ButtonIcon'
|
|
6
|
+
export { PhoneView } from './PhoneView'
|
|
7
|
+
export { Badge, type IBadgeProps } from './Badge'
|
|
8
|
+
export { Loader, type ILoaderProps } from './Loader'
|
|
9
|
+
export { Skeleton, type ISkeletonProps } from './Skeleton'
|
|
10
|
+
export { Table } from './table'
|
|
11
|
+
|
|
12
|
+
// # INTERACTIVE
|
|
13
|
+
export { Accordion, type IAccordionProps } from './accordion'
|
|
14
|
+
export { Hint, type IHintProps } from './Hint'
|
|
15
|
+
export { Popover } from './popover'
|
|
16
|
+
export { ProgressBar, type IProgressBarProps } from './ProgressBar'
|
|
17
|
+
export { TabsSwitcher, type ITabsSwitcherProps, type ITabRenderContent } from './TabsSwitcher'
|
|
18
|
+
export { Modal } from './modal'
|
|
19
|
+
export { type INotificationProps, Notification } from './notification'
|
|
20
|
+
|
|
21
|
+
// # PROVIDERS
|
|
22
|
+
export { NotificationProvider, type INotificationProviderProps } from './providers'
|
|
23
|
+
|
|
24
|
+
// # TYPOGRAPHY
|
|
25
|
+
export { Heading, type IHeadingProps } from './Heading'
|
|
26
|
+
|
|
27
|
+
// # ICONS
|
|
28
|
+
export { Icon, type IconProps, type TAllowedIcons, type SpritesMap } from './icon'
|
|
29
|
+
export { brandLogos, type TBrandLogoVariant } from './brandLogos'
|
|
30
|
+
|
|
31
|
+
// # NAVIGATION
|
|
32
|
+
export { Breadcrumbs, type IBreadcrumbsProps } from './Breadcrumbs'
|
|
33
|
+
export { CustomLink, type ICustomLinkProps } from './CustomLink'
|
|
34
|
+
|
|
35
|
+
// # FILES
|
|
36
|
+
export { Document, type IDocumentProps } from './Document'
|
|
37
|
+
|
|
38
|
+
// # CONTROLLED FORM UI
|
|
39
|
+
export {
|
|
40
|
+
InputControl,
|
|
41
|
+
type InputControlProps,
|
|
42
|
+
InputControlMask,
|
|
43
|
+
type InputControlMaskProps,
|
|
44
|
+
InputSliderControl,
|
|
45
|
+
type InputSliderControlProps,
|
|
46
|
+
FormControl,
|
|
47
|
+
DadataInputControl,
|
|
48
|
+
type IDadataInputControlProps,
|
|
49
|
+
CheckboxControl,
|
|
50
|
+
type ICheckboxControlProps,
|
|
51
|
+
RadioControl,
|
|
52
|
+
type IRadioControlProps,
|
|
53
|
+
type IRadioGroupOption,
|
|
54
|
+
SwitchControl,
|
|
55
|
+
type ISwitchControlProps,
|
|
56
|
+
TextareaControl,
|
|
57
|
+
type ITextareaControlProps,
|
|
58
|
+
type IInputControlUploaderProps,
|
|
59
|
+
InputControlUploader,
|
|
60
|
+
type ICalendarControlProps,
|
|
61
|
+
CalendarControl,
|
|
62
|
+
type IEditorControlProps,
|
|
63
|
+
EditorControl,
|
|
64
|
+
InputCurrencyControl,
|
|
65
|
+
type InputCurrencyControlProps,
|
|
66
|
+
ComboboxControl,
|
|
67
|
+
type IComboboxControlProps
|
|
68
|
+
} from './formControlElements'
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { createPortal } from 'react-dom'
|
|
5
|
+
import { AnimatePresence, motion } from 'framer-motion'
|
|
6
|
+
import { modalContentAnimation, modalOverlayAnimation } from './model/helpers'
|
|
7
|
+
import { type IModalHeaderProps, ModalHeader, type TModalHeaderClasses } from './ui/ModalHeader'
|
|
8
|
+
import { cn } from '$/shared/utils'
|
|
9
|
+
|
|
10
|
+
type IModalClasses = TModalHeaderClasses & {
|
|
11
|
+
overlay: string
|
|
12
|
+
modal: string
|
|
13
|
+
content: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface IModalProps extends IModalHeaderProps {
|
|
17
|
+
children: React.ReactElement
|
|
18
|
+
isModalOpen: boolean
|
|
19
|
+
classes?: Partial<IModalClasses>
|
|
20
|
+
isPortal?: boolean
|
|
21
|
+
portalContainer?: HTMLElement
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//
|
|
25
|
+
|
|
26
|
+
export const Modal = ({
|
|
27
|
+
title,
|
|
28
|
+
children,
|
|
29
|
+
isModalOpen,
|
|
30
|
+
isPortal = true,
|
|
31
|
+
portalContainer = globalThis?.document?.body,
|
|
32
|
+
closeModal,
|
|
33
|
+
classes
|
|
34
|
+
}: IModalProps) => {
|
|
35
|
+
const modalBody = (
|
|
36
|
+
<AnimatePresence>
|
|
37
|
+
{isModalOpen && (
|
|
38
|
+
<motion.div
|
|
39
|
+
tabIndex={-1}
|
|
40
|
+
onClick={closeModal}
|
|
41
|
+
className={cn(
|
|
42
|
+
'fixed inset-0 z-1000 flex h-screen w-screen items-center justify-center bg-color-overlay',
|
|
43
|
+
classes?.overlay
|
|
44
|
+
)}
|
|
45
|
+
onKeyDown={(event) => {
|
|
46
|
+
if (event.key === 'Escape') {
|
|
47
|
+
closeModal()
|
|
48
|
+
}
|
|
49
|
+
}}
|
|
50
|
+
{...modalOverlayAnimation}
|
|
51
|
+
>
|
|
52
|
+
<motion.div
|
|
53
|
+
onClick={(event) => event.stopPropagation()}
|
|
54
|
+
className={cn(
|
|
55
|
+
'w-full max-w-[600px] rounded-md bg-color-white px-4 py-6 shadow-sm desktop:px-6 desktop:py-8',
|
|
56
|
+
classes?.modal
|
|
57
|
+
)}
|
|
58
|
+
{...modalContentAnimation}
|
|
59
|
+
>
|
|
60
|
+
<ModalHeader title={title} closeModal={closeModal} classes={classes} />
|
|
61
|
+
<div className={cn('mt-4', classes?.content)}>{children}</div>
|
|
62
|
+
</motion.div>
|
|
63
|
+
</motion.div>
|
|
64
|
+
)}
|
|
65
|
+
</AnimatePresence>
|
|
66
|
+
)
|
|
67
|
+
return <>{isPortal ? createPortal(modalBody, portalContainer) : modalBody}</>
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Modal } from './Modal'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const modalOverlayAnimation = {
|
|
2
|
+
initial: { opacity: 0 },
|
|
3
|
+
animate: { opacity: 1 },
|
|
4
|
+
exit: { opacity: 0 },
|
|
5
|
+
transition: { duration: 0.3, ease: 'easeInOut' }
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const modalContentAnimation = {
|
|
9
|
+
initial: { opacity: 0, scale: 0 },
|
|
10
|
+
animate: { opacity: 1, scale: 1 },
|
|
11
|
+
exit: { opacity: 0, scale: 0 },
|
|
12
|
+
transition: { duration: 0.3, ease: 'easeInOut' }
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { Heading } from '../../Heading'
|
|
3
|
+
import { Icon } from '../../icon'
|
|
4
|
+
import { cn } from '$/shared/utils'
|
|
5
|
+
|
|
6
|
+
export type TModalHeaderClasses = {
|
|
7
|
+
header: string
|
|
8
|
+
title: string
|
|
9
|
+
icon: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IModalHeaderProps {
|
|
13
|
+
title?: string | React.ReactElement
|
|
14
|
+
closeModal: () => void
|
|
15
|
+
classes?: Partial<TModalHeaderClasses>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const ModalHeader = ({ title, closeModal, classes }: IModalHeaderProps) => {
|
|
19
|
+
return (
|
|
20
|
+
<div className={cn('flex items-start justify-between gap-4', classes?.header)}>
|
|
21
|
+
{title && (
|
|
22
|
+
<Heading as='h3' className={cn('flex-1 text-color-dark', classes?.title)}>
|
|
23
|
+
{title}
|
|
24
|
+
</Heading>
|
|
25
|
+
)}
|
|
26
|
+
<Icon
|
|
27
|
+
onClick={closeModal}
|
|
28
|
+
name='general/close'
|
|
29
|
+
className={cn('size-8 cursor-pointer text-icon-dark-hover', classes?.icon)}
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ReactElement } from 'react'
|
|
2
|
+
import toast, { type Toast } from 'react-hot-toast'
|
|
3
|
+
import { CustomToast } from './ui/CustomToast'
|
|
4
|
+
|
|
5
|
+
export interface INotificationProps {
|
|
6
|
+
duration?: number
|
|
7
|
+
intent: 'info' | 'error'
|
|
8
|
+
text: string
|
|
9
|
+
customIcon?: ReactElement
|
|
10
|
+
content?: ReactElement
|
|
11
|
+
closure?: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const renderToast = (props: INotificationProps) => {
|
|
15
|
+
switch (props.intent) {
|
|
16
|
+
case 'info':
|
|
17
|
+
return toast.custom((toastOptions: Toast) => <CustomToast {...toastOptions} {...props} />, {
|
|
18
|
+
duration: props.duration ?? 5000
|
|
19
|
+
})
|
|
20
|
+
case 'error':
|
|
21
|
+
return toast.custom((toastOptions: Toast) => <CustomToast {...toastOptions} {...props} />, {
|
|
22
|
+
duration: props.duration ?? 10000
|
|
23
|
+
})
|
|
24
|
+
default:
|
|
25
|
+
return null
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Notification = (props: INotificationProps) => {
|
|
30
|
+
return renderToast(props)
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Notification, type INotificationProps } from './Notification'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import toast, { type Toast } from 'react-hot-toast'
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
3
|
+
import type { INotificationProps } from '../Notification'
|
|
4
|
+
import { Icon } from '$/shared/ui'
|
|
5
|
+
import { cn } from '$/shared/utils'
|
|
6
|
+
|
|
7
|
+
const toastContainerConfig = cva(
|
|
8
|
+
'flex justify-between items-center gap-4 shadow-sm p-4 rounded-sm max-w-[328px] desktop:max-w-[576px]',
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
intent: {
|
|
12
|
+
info: 'bg-color-footer text-color-white',
|
|
13
|
+
error: 'bg-color-secondary-default text-color-white'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
intent: 'info'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
type TContainerConfig = VariantProps<typeof toastContainerConfig>
|
|
23
|
+
export type ICustomToastProps = INotificationProps & TContainerConfig & Toast
|
|
24
|
+
|
|
25
|
+
export const CustomToast = ({ intent, text, customIcon, closure = true, content, id }: ICustomToastProps) => {
|
|
26
|
+
return (
|
|
27
|
+
<div className={cn(toastContainerConfig({ intent }))}>
|
|
28
|
+
<div className='flex items-center gap-2'>
|
|
29
|
+
<span className='size-6'>{customIcon}</span>
|
|
30
|
+
<div className='desk-body-regular-m text-color-white'>{text}</div>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div className='flex items-center gap-6'>
|
|
34
|
+
{content}
|
|
35
|
+
|
|
36
|
+
{closure && (
|
|
37
|
+
<Icon onClick={() => toast.dismiss(id)} name='general/close' className='size-5 cursor-pointer text-icon-white' />
|
|
38
|
+
)}
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react'
|
|
2
|
+
import type { PopoverContentProps as TPopoverContentPropsBase } from '@radix-ui/react-popover'
|
|
3
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover'
|
|
4
|
+
import { Icon } from '../icon/Icon'
|
|
5
|
+
import { cn } from '$/shared/utils'
|
|
6
|
+
|
|
7
|
+
type TPopoverClasses = {
|
|
8
|
+
content: string
|
|
9
|
+
arrow: string
|
|
10
|
+
trigger: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface IPopoverContentProps extends TPopoverContentPropsBase {
|
|
14
|
+
sideOffset?: number
|
|
15
|
+
alignOffset?: number
|
|
16
|
+
align?: 'end' | 'center' | 'start'
|
|
17
|
+
side?: 'top' | 'right' | 'bottom' | 'left'
|
|
18
|
+
defaultOpen?: boolean
|
|
19
|
+
avoidCollisions?: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface IPopoverProps extends IPopoverContentProps {
|
|
23
|
+
triggerElement: ReactElement
|
|
24
|
+
children: ReactNode
|
|
25
|
+
classes?: Partial<TPopoverClasses>
|
|
26
|
+
headLine?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Popover = ({
|
|
30
|
+
triggerElement,
|
|
31
|
+
classes,
|
|
32
|
+
sideOffset = 4,
|
|
33
|
+
alignOffset,
|
|
34
|
+
align,
|
|
35
|
+
side,
|
|
36
|
+
defaultOpen = false,
|
|
37
|
+
avoidCollisions = true,
|
|
38
|
+
headLine,
|
|
39
|
+
children,
|
|
40
|
+
arrowPadding,
|
|
41
|
+
...contentProps
|
|
42
|
+
}: IPopoverProps) => {
|
|
43
|
+
return (
|
|
44
|
+
<PopoverPrimitive.Root defaultOpen={defaultOpen}>
|
|
45
|
+
<div className='flex w-max items-center gap-2'>
|
|
46
|
+
<h3 className='text-[24px] font-bold'>{headLine}</h3>
|
|
47
|
+
<PopoverPrimitive.Trigger className={cn('cursor-pointer', classes?.trigger)} asChild>
|
|
48
|
+
{triggerElement}
|
|
49
|
+
</PopoverPrimitive.Trigger>
|
|
50
|
+
</div>
|
|
51
|
+
<PopoverPrimitive.Portal>
|
|
52
|
+
<PopoverPrimitive.Content
|
|
53
|
+
className={cn(
|
|
54
|
+
'desk-body-regular-m flex w-64 items-start gap-2 rounded-sm bg-color-white p-4 shadow-sm',
|
|
55
|
+
classes?.content
|
|
56
|
+
)}
|
|
57
|
+
sideOffset={sideOffset}
|
|
58
|
+
alignOffset={alignOffset}
|
|
59
|
+
avoidCollisions={avoidCollisions}
|
|
60
|
+
arrowPadding={arrowPadding}
|
|
61
|
+
align={align}
|
|
62
|
+
side={side}
|
|
63
|
+
{...contentProps}
|
|
64
|
+
>
|
|
65
|
+
{children}
|
|
66
|
+
<PopoverPrimitive.Close aria-label='Close' className='size-4 outline-0 outline-transparent'>
|
|
67
|
+
<Icon name='general/close' className='size-4 cursor-pointer text-icon-blue-grey-600' />
|
|
68
|
+
</PopoverPrimitive.Close>
|
|
69
|
+
<PopoverPrimitive.Arrow width={12} height={6} className={cn('fill-white', classes?.arrow)} />
|
|
70
|
+
</PopoverPrimitive.Content>
|
|
71
|
+
</PopoverPrimitive.Portal>
|
|
72
|
+
</PopoverPrimitive.Root>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Popover } from './Popover'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react'
|
|
4
|
+
import toast, { Toaster, useToasterStore } from 'react-hot-toast'
|
|
5
|
+
|
|
6
|
+
export interface INotificationProviderProps {
|
|
7
|
+
maxToastViewLimit?: number
|
|
8
|
+
toastDuration?: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const NotificationProvider = ({ maxToastViewLimit = 2, toastDuration = 5000 }: INotificationProviderProps) => {
|
|
12
|
+
const { toasts } = useToasterStore()
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
toasts
|
|
16
|
+
.filter((t) => t.visible)
|
|
17
|
+
.filter((_, i) => i >= maxToastViewLimit)
|
|
18
|
+
.forEach((t) => toast.dismiss(t.id))
|
|
19
|
+
}, [maxToastViewLimit, toasts])
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Toaster
|
|
23
|
+
position='top-center'
|
|
24
|
+
toastOptions={{
|
|
25
|
+
duration: toastDuration
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NotificationProvider, type INotificationProviderProps } from './NotificationProvider'
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { ReactElement } from 'react'
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
3
|
+
import { Heading } from '../Heading'
|
|
4
|
+
import { ResponsiveContainer } from '../ResponsiveContainer'
|
|
5
|
+
import type { TableRows, TTableClasses, TTableColumnCount } from './type'
|
|
6
|
+
import { cn } from '$/shared/utils'
|
|
7
|
+
|
|
8
|
+
const tableConfig = cva('grid', {
|
|
9
|
+
variants: {
|
|
10
|
+
columnCount: {
|
|
11
|
+
twoColumns: 'grid-cols-[repeat(2,minmax(172px,_1fr))] desktop:grid-cols-[repeat(2,minmax(172px,_1fr))]',
|
|
12
|
+
threeColumns: 'grid-cols-[repeat(3,minmax(172px,_1fr))] desktop:grid-cols-[repeat(3,minmax(312px,_1fr))]'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const itemTableConfig = cva('grid', {
|
|
18
|
+
variants: {
|
|
19
|
+
columnCount: {
|
|
20
|
+
twoColumns: '',
|
|
21
|
+
threeColumns: ''
|
|
22
|
+
},
|
|
23
|
+
titlesExist: {
|
|
24
|
+
exist: '',
|
|
25
|
+
notExist: ''
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
compoundVariants: [
|
|
29
|
+
{
|
|
30
|
+
titlesExist: 'notExist',
|
|
31
|
+
columnCount: 'twoColumns',
|
|
32
|
+
class: 'grid-rows-[repeat(2,_auto)] border-b border-warm-grey-200 py-4'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
titlesExist: 'notExist',
|
|
36
|
+
columnCount: 'threeColumns',
|
|
37
|
+
class: 'grid-cols-[repeat(3,_auto)]'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
titlesExist: 'exist',
|
|
41
|
+
columnCount: 'twoColumns',
|
|
42
|
+
class: 'grid-cols-[repeat(2,_auto)]'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
titlesExist: 'exist',
|
|
46
|
+
columnCount: 'threeColumns',
|
|
47
|
+
class: 'grid-cols-[repeat(3,_auto)]'
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const tableOverflowConfig = cva('grid', {
|
|
53
|
+
variants: {
|
|
54
|
+
columnCount: {
|
|
55
|
+
twoColumns: '',
|
|
56
|
+
threeColumns: ''
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
compoundVariants: [
|
|
60
|
+
{
|
|
61
|
+
columnCount: 'threeColumns',
|
|
62
|
+
class: 'mobile:overflow-x-scroll mobile:max-w-[368px] mb-1'
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const textTableConfig = cva('border-b border-warm-grey-200 py-4 desktop:desk-body-regular-l mob-body-regular-l', {
|
|
68
|
+
variants: {
|
|
69
|
+
columnCount: {
|
|
70
|
+
twoColumns: '',
|
|
71
|
+
threeColumns: ''
|
|
72
|
+
},
|
|
73
|
+
titlesExist: {
|
|
74
|
+
exist: '',
|
|
75
|
+
notExist: ''
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
compoundVariants: [
|
|
79
|
+
{
|
|
80
|
+
titlesExist: 'notExist',
|
|
81
|
+
columnCount: 'twoColumns',
|
|
82
|
+
class: 'border-transparent border-0 p-0'
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
type TTableProps = VariantProps<typeof tableConfig>
|
|
88
|
+
|
|
89
|
+
export interface ITable<C extends TTableColumnCount> extends TTableProps {
|
|
90
|
+
headTitle: string | ReactElement
|
|
91
|
+
columnCount: TTableColumnCount
|
|
92
|
+
tableHead?: string[]
|
|
93
|
+
tableRows: TableRows<C>
|
|
94
|
+
additionalText?: string
|
|
95
|
+
classes?: Partial<TTableClasses>
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const Table = <C extends TTableColumnCount>({
|
|
99
|
+
headTitle,
|
|
100
|
+
tableRows,
|
|
101
|
+
tableHead,
|
|
102
|
+
additionalText,
|
|
103
|
+
columnCount,
|
|
104
|
+
classes
|
|
105
|
+
}: ITable<C>) => {
|
|
106
|
+
const titlesExist = tableHead && tableHead.length > 0 ? 'exist' : 'notExist'
|
|
107
|
+
return (
|
|
108
|
+
<ResponsiveContainer>
|
|
109
|
+
<div className={cn('flex flex-col', classes?.tableRootWrapper)}>
|
|
110
|
+
<Heading as='h3' className={cn('mob-title-bold-m pb-6 desktop:desk-title-bold-s', classes?.tableHeading)}>
|
|
111
|
+
{headTitle}
|
|
112
|
+
</Heading>
|
|
113
|
+
<div className={cn(tableOverflowConfig({ columnCount }), classes?.tableBody)}>
|
|
114
|
+
<ul className={cn(tableConfig({ columnCount }), classes?.tableTitlesContainer)}>
|
|
115
|
+
{tableHead?.map((title) => (
|
|
116
|
+
<li
|
|
117
|
+
key={title}
|
|
118
|
+
className={cn(
|
|
119
|
+
'mob-body-regular-l border-b border-warm-grey-200 py-4 desktop:desk-body-regular-l',
|
|
120
|
+
classes?.tableTitleRow
|
|
121
|
+
)}
|
|
122
|
+
>
|
|
123
|
+
{title}
|
|
124
|
+
</li>
|
|
125
|
+
))}
|
|
126
|
+
</ul>
|
|
127
|
+
|
|
128
|
+
<ul className={cn('mb-4 flex flex-col', classes?.tableBodyContainer)}>
|
|
129
|
+
{tableRows.map((row, index) => (
|
|
130
|
+
<li key={index} className={cn(itemTableConfig({ columnCount, titlesExist }), classes?.tableBodyRow)}>
|
|
131
|
+
{row.map((ceil, index) => (
|
|
132
|
+
<p key={index} className={cn(textTableConfig({ titlesExist, columnCount }), classes?.tableBodyCeil)}>
|
|
133
|
+
{ceil.text}
|
|
134
|
+
</p>
|
|
135
|
+
))}
|
|
136
|
+
</li>
|
|
137
|
+
))}
|
|
138
|
+
</ul>
|
|
139
|
+
</div>
|
|
140
|
+
<p className={cn('mob-body-regular-m desktop:desk-body-regular-l', classes?.tableAdditionalText)}>{additionalText}</p>
|
|
141
|
+
</div>
|
|
142
|
+
</ResponsiveContainer>
|
|
143
|
+
)
|
|
144
|
+
}
|