@scbt-ecom/ui 0.0.30 → 0.0.32
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/client.d.ts +2 -0
- package/dist/client.js +921 -0
- package/dist/cn-uh4jkx7b.js +2892 -0
- package/dist/configs/index.d.ts +1 -0
- package/dist/configs/tailwindConfigBase.d.ts +2 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +15 -0
- package/dist/shared/constants/api.d.ts +2 -0
- package/dist/shared/constants/designSystem/colors.d.ts +120 -0
- package/dist/shared/constants/designSystem/index.d.ts +3 -0
- package/dist/shared/constants/designSystem/others.d.ts +16 -0
- package/dist/shared/constants/designSystem/typography.d.ts +75 -0
- package/dist/shared/constants/index.d.ts +2 -0
- package/dist/shared/hooks/index.d.ts +4 -0
- package/dist/shared/hooks/useBoolean.d.ts +3 -0
- package/dist/shared/hooks/useClickOutside.d.ts +2 -0
- package/dist/shared/hooks/useControlledForm.d.ts +7 -0
- package/dist/shared/hooks/useDebounce.d.ts +3 -0
- package/dist/shared/ui/Badge.d.ts +6 -0
- package/dist/shared/ui/Breadcrumbs.d.ts +15 -0
- package/dist/shared/ui/ButtonIcon.d.ts +17 -0
- package/dist/shared/ui/CustomLink.d.ts +15 -0
- package/dist/shared/ui/Document.d.ts +13 -0
- package/dist/shared/ui/Heading.d.ts +12 -0
- package/dist/shared/ui/Hint.d.ts +21 -0
- package/dist/shared/ui/Loader.d.ts +21 -0
- package/dist/shared/ui/PhoneView.d.ts +12 -0
- package/dist/shared/ui/Portal.d.ts +7 -0
- package/dist/shared/ui/ProgressBar.d.ts +18 -0
- package/dist/shared/ui/ResponsiveContainer.d.ts +6 -0
- package/dist/shared/ui/Section.d.ts +6 -0
- package/dist/shared/ui/Skeleton.d.ts +4 -0
- package/dist/shared/ui/TabsSwitcher.d.ts +33 -0
- package/dist/shared/ui/accordion/Accordion.d.ts +13 -0
- package/dist/shared/ui/accordion/index.d.ts +1 -0
- package/dist/shared/ui/accordion/model/types.d.ts +17 -0
- package/dist/shared/ui/accordion/ui/AccordionHeader.d.ts +8 -0
- package/dist/shared/ui/brandLogos.d.ts +5 -0
- package/dist/shared/ui/button/Button.d.ts +17 -0
- package/dist/shared/ui/button/index.d.ts +1 -0
- package/dist/shared/ui/button/model/helpers.d.ts +2 -0
- package/dist/shared/ui/calendar/Calendar.d.ts +20 -0
- package/dist/shared/ui/calendar/index.d.ts +1 -0
- package/dist/shared/ui/calendar/model/animation.d.ts +18 -0
- package/dist/shared/ui/calendar/model/classes.d.ts +24 -0
- package/dist/shared/ui/calendar/model/helpers.d.ts +9 -0
- package/dist/shared/ui/calendar/model/hooks/index.d.ts +2 -0
- package/dist/shared/ui/calendar/model/hooks/useCalendarDropdowns.d.ts +9 -0
- package/dist/shared/ui/calendar/model/hooks/useDatePicker.d.ts +19 -0
- package/dist/shared/ui/calendar/ui/CalendarHeader.d.ts +15 -0
- package/dist/shared/ui/calendar/ui/Dropdown.d.ts +10 -0
- package/dist/shared/ui/calendar/ui/NavigationArrows.d.ts +5 -0
- package/dist/shared/ui/calendar/ui/Weekdays.d.ts +1 -0
- package/dist/shared/ui/calendar/ui/index.d.ts +2 -0
- package/dist/shared/ui/formControlElements/CheckboxControl.d.ts +13 -0
- package/dist/shared/ui/formControlElements/FormControl.d.ts +3 -0
- package/dist/shared/ui/formControlElements/InputControl.d.ts +6 -0
- package/dist/shared/ui/formControlElements/InputControlMask.d.ts +10 -0
- package/dist/shared/ui/formControlElements/RadioControl.d.ts +26 -0
- package/dist/shared/ui/formControlElements/SelectControl.d.ts +27 -0
- package/dist/shared/ui/formControlElements/SwitchControl.d.ts +16 -0
- package/dist/shared/ui/formControlElements/TextareaControl.d.ts +11 -0
- package/dist/shared/ui/formControlElements/calendarControl/CalendarControl.d.ts +13 -0
- package/dist/shared/ui/formControlElements/calendarControl/hooks/index.d.ts +2 -0
- package/dist/shared/ui/formControlElements/calendarControl/hooks/useCalendar.d.ts +16 -0
- package/dist/shared/ui/formControlElements/calendarControl/hooks/useCalendarDropdowns.d.ts +9 -0
- package/{lib/shared/ui/formControlElements/calendarControl/index.ts → dist/shared/ui/formControlElements/calendarControl/index.d.ts} +1 -1
- package/dist/shared/ui/formControlElements/calendarControl/model/helpers.d.ts +24 -0
- package/dist/shared/ui/formControlElements/calendarControl/model/types.d.ts +33 -0
- package/dist/shared/ui/formControlElements/calendarControl/ui/DaysOfMonth.d.ts +10 -0
- package/dist/shared/ui/formControlElements/calendarControl/ui/DaysOfWeek.d.ts +6 -0
- package/dist/shared/ui/formControlElements/calendarControl/ui/Dropdown.d.ts +11 -0
- package/dist/shared/ui/formControlElements/calendarControl/ui/Header.d.ts +14 -0
- package/dist/shared/ui/formControlElements/calendarControl/ui/Navigation.d.ts +9 -0
- package/dist/shared/ui/formControlElements/calendarControl/ui/OptionsList.d.ts +5 -0
- package/dist/shared/ui/formControlElements/calendarControl/ui/index.d.ts +4 -0
- package/dist/shared/ui/formControlElements/dadata/DadataInputControl.d.ts +14 -0
- package/{lib/shared/ui/formControlElements/dadata/index.ts → dist/shared/ui/formControlElements/dadata/index.d.ts} +1 -1
- package/dist/shared/ui/formControlElements/dadata/model/api.d.ts +2 -0
- package/dist/shared/ui/formControlElements/dadata/model/helpers.d.ts +7 -0
- package/dist/shared/ui/formControlElements/dadata/model/types.d.ts +42 -0
- package/dist/shared/ui/formControlElements/dadata/model/useDadata.d.ts +7 -0
- package/{lib/shared/ui/formControlElements/index.ts → dist/shared/ui/formControlElements/index.d.ts} +10 -10
- package/dist/shared/ui/formControlElements/model/classes-types.d.ts +18 -0
- package/dist/shared/ui/formControlElements/model/index.d.ts +2 -0
- package/dist/shared/ui/formControlElements/model/props-types.d.ts +20 -0
- package/dist/shared/ui/formControlElements/ui/FieldAttachment.d.ts +13 -0
- package/dist/shared/ui/formControlElements/ui/FieldContainer.d.ts +14 -0
- package/dist/shared/ui/formControlElements/ui/FieldWrapper.d.ts +14 -0
- package/dist/shared/ui/formControlElements/ui/MessageView.d.ts +13 -0
- package/dist/shared/ui/formControlElements/ui/index.d.ts +4 -0
- package/dist/shared/ui/icon/Icon.d.ts +10 -0
- package/{lib/shared/ui/icon/index.ts → dist/shared/ui/icon/index.d.ts} +2 -2
- package/dist/shared/ui/icon/sprite.gen.d.ts +17 -0
- package/dist/shared/ui/index.d.ts +21 -0
- package/dist/shared/ui/popover/Popover.d.ts +23 -0
- package/dist/shared/ui/popover/index.d.ts +1 -0
- package/dist/shared/ui/table/Table.d.ts +17 -0
- package/dist/shared/ui/table/index.d.ts +1 -0
- package/dist/shared/ui/table/type.d.ts +21 -0
- package/dist/shared/utils/capitalize.d.ts +1 -0
- package/dist/shared/utils/cn.d.ts +2 -0
- package/dist/shared/utils/deepCompare.d.ts +1 -0
- package/dist/shared/utils/formatToDate.d.ts +1 -0
- package/dist/shared/utils/index.d.ts +5 -0
- package/dist/shared/utils/isClient.d.ts +1 -0
- package/dist/shared/validation/index.d.ts +3 -0
- package/dist/shared/validation/messages.d.ts +12 -0
- package/dist/shared/validation/regExp.d.ts +3 -0
- package/dist/shared/validation/zodValidation/calendar.d.ts +2 -0
- package/dist/shared/validation/zodValidation/dadataFio.d.ts +6 -0
- package/dist/shared/validation/zodValidation/index.d.ts +2 -0
- package/dist/widgets/Advantages.d.ts +17 -0
- package/dist/widgets/banner/Banner.d.ts +28 -0
- package/dist/widgets/banner/index.d.ts +1 -0
- package/dist/widgets/banner/model/helpers.d.ts +4 -0
- package/dist/widgets/banner/ui/BannerButtonsGroup.d.ts +12 -0
- package/{lib/widgets/index.ts → dist/widgets/index.d.ts} +3 -3
- package/dist/widgets/pageHeader/PageHeader.d.ts +16 -0
- package/{lib/widgets/pageHeader/index.ts → dist/widgets/pageHeader/index.d.ts} +1 -1
- package/package.json +8 -5
- package/.env +0 -2
- package/.eslintrc.cjs +0 -134
- package/.github/workflows/npm-publish.yml +0 -22
- package/.github/workflows/publish.yml +0 -49
- package/.github/workflows/setup-node/action.yml +0 -22
- package/.husky/pre-commit +0 -1
- package/.prettierrc +0 -19
- package/.storybook/main.ts +0 -44
- package/.storybook/preview.tsx +0 -37
- package/chromatic.config.json +0 -5
- package/index.html +0 -13
- package/lib/client.ts +0 -80
- package/lib/configs/index.ts +0 -1
- package/lib/configs/tailwindConfigBase.ts +0 -110
- package/lib/server.ts +0 -2
- package/lib/shared/constants/api.ts +0 -2
- package/lib/shared/constants/designSystem/colors.ts +0 -117
- package/lib/shared/constants/designSystem/index.ts +0 -3
- package/lib/shared/constants/designSystem/others.ts +0 -18
- package/lib/shared/constants/designSystem/typography.ts +0 -88
- package/lib/shared/constants/index.ts +0 -2
- package/lib/shared/hooks/index.ts +0 -4
- package/lib/shared/hooks/useBoolean.ts +0 -12
- package/lib/shared/hooks/useClickOutside.ts +0 -19
- package/lib/shared/hooks/useControlledForm.ts +0 -16
- package/lib/shared/hooks/useDebounce.ts +0 -38
- package/lib/shared/style.css +0 -74
- package/lib/shared/ui/Badge.tsx +0 -20
- package/lib/shared/ui/Breadcrumbs.tsx +0 -57
- package/lib/shared/ui/ButtonIcon.tsx +0 -52
- package/lib/shared/ui/CustomLink.tsx +0 -70
- package/lib/shared/ui/Document.tsx +0 -51
- package/lib/shared/ui/Heading.tsx +0 -33
- package/lib/shared/ui/Hint.tsx +0 -62
- package/lib/shared/ui/Loader.tsx +0 -58
- package/lib/shared/ui/PhoneView.tsx +0 -23
- package/lib/shared/ui/Portal.tsx +0 -9
- package/lib/shared/ui/ProgressBar.tsx +0 -43
- package/lib/shared/ui/ResponsiveContainer.tsx +0 -11
- package/lib/shared/ui/Section.tsx +0 -15
- package/lib/shared/ui/Skeleton.tsx +0 -9
- package/lib/shared/ui/TabsSwitcher.tsx +0 -80
- package/lib/shared/ui/accordion/Accordion.tsx +0 -36
- package/lib/shared/ui/accordion/index.ts +0 -1
- package/lib/shared/ui/accordion/model/types.ts +0 -20
- package/lib/shared/ui/accordion/ui/AccordionHeader.tsx +0 -35
- package/lib/shared/ui/brandLogos.tsx +0 -14
- package/lib/shared/ui/button/Button.tsx +0 -111
- package/lib/shared/ui/button/index.ts +0 -1
- package/lib/shared/ui/button/model/helpers.ts +0 -16
- package/lib/shared/ui/calendar/Calendar.tsx +0 -228
- package/lib/shared/ui/calendar/index.ts +0 -231
- package/lib/shared/ui/calendar/model/animation.ts +0 -112
- package/lib/shared/ui/calendar/model/classes.ts +0 -34
- package/lib/shared/ui/calendar/model/helpers.ts +0 -51
- package/lib/shared/ui/calendar/model/hooks/index.ts +0 -2
- package/lib/shared/ui/calendar/model/hooks/useCalendarDropdowns.ts +0 -38
- package/lib/shared/ui/calendar/model/hooks/useDatePicker.ts +0 -103
- package/lib/shared/ui/calendar/ui/CalendarHeader.tsx +0 -54
- package/lib/shared/ui/calendar/ui/Dropdown.tsx +0 -75
- package/lib/shared/ui/calendar/ui/NavigationArrows.tsx +0 -23
- package/lib/shared/ui/calendar/ui/Weekdays.tsx +0 -16
- package/lib/shared/ui/calendar/ui/index.ts +0 -2
- package/lib/shared/ui/formControlElements/CheckboxControl.tsx +0 -92
- package/lib/shared/ui/formControlElements/FormControl.tsx +0 -5
- package/lib/shared/ui/formControlElements/InputControl.tsx +0 -68
- package/lib/shared/ui/formControlElements/InputControlMask.tsx +0 -80
- package/lib/shared/ui/formControlElements/RadioControl.tsx +0 -130
- package/lib/shared/ui/formControlElements/SelectControl.tsx +0 -185
- package/lib/shared/ui/formControlElements/SwitchControl.tsx +0 -79
- package/lib/shared/ui/formControlElements/TextareaControl.tsx +0 -92
- package/lib/shared/ui/formControlElements/calendarControl/CalendarControl.tsx +0 -175
- package/lib/shared/ui/formControlElements/calendarControl/hooks/index.ts +0 -2
- package/lib/shared/ui/formControlElements/calendarControl/hooks/useCalendar.tsx +0 -86
- package/lib/shared/ui/formControlElements/calendarControl/hooks/useCalendarDropdowns.ts +0 -38
- package/lib/shared/ui/formControlElements/calendarControl/model/helpers.ts +0 -60
- package/lib/shared/ui/formControlElements/calendarControl/model/types.ts +0 -44
- package/lib/shared/ui/formControlElements/calendarControl/ui/DaysOfMonth.tsx +0 -53
- package/lib/shared/ui/formControlElements/calendarControl/ui/DaysOfWeek.tsx +0 -28
- package/lib/shared/ui/formControlElements/calendarControl/ui/Dropdown.tsx +0 -62
- package/lib/shared/ui/formControlElements/calendarControl/ui/Header.tsx +0 -51
- package/lib/shared/ui/formControlElements/calendarControl/ui/Navigation.tsx +0 -32
- package/lib/shared/ui/formControlElements/calendarControl/ui/OptionsList.tsx +0 -44
- package/lib/shared/ui/formControlElements/calendarControl/ui/index.ts +0 -4
- package/lib/shared/ui/formControlElements/dadata/DadataInputControl.tsx +0 -132
- package/lib/shared/ui/formControlElements/dadata/model/api.ts +0 -25
- package/lib/shared/ui/formControlElements/dadata/model/helpers.ts +0 -76
- package/lib/shared/ui/formControlElements/dadata/model/types.ts +0 -52
- package/lib/shared/ui/formControlElements/dadata/model/useDadata.ts +0 -25
- package/lib/shared/ui/formControlElements/model/classes-types.ts +0 -22
- package/lib/shared/ui/formControlElements/model/index.ts +0 -2
- package/lib/shared/ui/formControlElements/model/props-types.ts +0 -26
- package/lib/shared/ui/formControlElements/ui/FieldAttachment.tsx +0 -66
- package/lib/shared/ui/formControlElements/ui/FieldContainer.tsx +0 -36
- package/lib/shared/ui/formControlElements/ui/FieldWrapper.tsx +0 -55
- package/lib/shared/ui/formControlElements/ui/MessageView.tsx +0 -37
- package/lib/shared/ui/formControlElements/ui/index.ts +0 -4
- package/lib/shared/ui/icon/Icon.tsx +0 -43
- package/lib/shared/ui/icon/sprite.gen.ts +0 -121
- package/lib/shared/ui/index.ts +0 -56
- package/lib/shared/ui/popover/Popover.tsx +0 -77
- package/lib/shared/ui/popover/index.ts +0 -1
- package/lib/shared/ui/table/Table.tsx +0 -143
- package/lib/shared/ui/table/index.ts +0 -1
- package/lib/shared/ui/table/type.ts +0 -30
- package/lib/shared/utils/capitalize.ts +0 -6
- package/lib/shared/utils/cn.ts +0 -6
- package/lib/shared/utils/deepCompare.ts +0 -1
- package/lib/shared/utils/formatToDate.ts +0 -5
- package/lib/shared/utils/index.ts +0 -5
- package/lib/shared/utils/isClient.ts +0 -1
- package/lib/shared/validation/index.ts +0 -3
- package/lib/shared/validation/messages.ts +0 -12
- package/lib/shared/validation/regExp.ts +0 -5
- package/lib/shared/validation/zodValidation/calendar.ts +0 -32
- package/lib/shared/validation/zodValidation/dadataFio.ts +0 -67
- package/lib/shared/validation/zodValidation/index.ts +0 -2
- package/lib/vite-env.d.ts +0 -2
- package/lib/widgets/Advantages.tsx +0 -45
- package/lib/widgets/banner/Banner.tsx +0 -62
- package/lib/widgets/banner/index.ts +0 -1
- package/lib/widgets/banner/model/helpers.ts +0 -44
- package/lib/widgets/banner/money.png +0 -0
- package/lib/widgets/banner/ui/BannerButtonsGroup.tsx +0 -30
- package/lib/widgets/pageHeader/PageHeader.tsx +0 -54
- package/postcss.config.mjs +0 -8
- package/src/App.tsx +0 -9
- package/src/app/providers/RootProvider.tsx +0 -11
- package/src/app/providers/index.ts +0 -1
- package/src/app/providers/model/types.ts +0 -5
- package/src/app/providers/ui/ToasterProvider.tsx +0 -23
- package/src/app/providers/ui/index.ts +0 -1
- package/src/configs/setup.ts +0 -9
- package/src/configs/storybook.config.ts +0 -23
- package/src/main.tsx +0 -10
- package/src/stories/primitives/Accordion.stories.tsx +0 -66
- package/src/stories/primitives/Badge.stories.tsx +0 -28
- package/src/stories/primitives/Breadcrumbs.stories.tsx +0 -29
- package/src/stories/primitives/Button/Button.stories.tsx +0 -149
- package/src/stories/primitives/Button/Button.test.tsx +0 -150
- package/src/stories/primitives/ButtonIcon.stories.tsx +0 -75
- package/src/stories/primitives/CustomLink.stories.tsx +0 -64
- package/src/stories/primitives/Document.stories.tsx +0 -36
- package/src/stories/primitives/Heading.stories.tsx +0 -29
- package/src/stories/primitives/Hint.stories.tsx +0 -82
- package/src/stories/primitives/Icon.stories.tsx +0 -36
- package/src/stories/primitives/Loader.stories.tsx +0 -39
- package/src/stories/primitives/PhoneView.stories.tsx +0 -22
- package/src/stories/primitives/Popover.stories.tsx +0 -41
- package/src/stories/primitives/ProgressBar.stories.tsx +0 -68
- package/src/stories/primitives/Skeleton.stories.tsx +0 -21
- package/src/stories/primitives/Table.stories.tsx +0 -44
- package/src/stories/primitives/TabsSwitcher.stories.tsx +0 -34
- package/src/stories/primitives/formControl/Calendar.stories.tsx +0 -61
- package/src/stories/primitives/formControl/CalendarControl.stories.tsx +0 -39
- package/src/stories/primitives/formControl/CheckboxControl.stories.tsx +0 -64
- package/src/stories/primitives/formControl/DadataInputControl.stories.tsx +0 -83
- package/src/stories/primitives/formControl/FormControlAllFields.stories.tsx +0 -25
- package/src/stories/primitives/formControl/InputControl.stories.tsx +0 -77
- package/src/stories/primitives/formControl/RadioContol.stories.tsx +0 -63
- package/src/stories/primitives/formControl/SelectControl.stories.tsx +0 -117
- package/src/stories/primitives/formControl/SwitchControl.stories.tsx +0 -51
- package/src/stories/primitives/formControl/TextareaControl.stories.tsx +0 -55
- package/src/stories/primitives/formControl/inputControlMask.stories.tsx +0 -69
- package/src/stories/widgets/Advantages.stories.tsx +0 -42
- package/src/stories/widgets/Banner.stories.tsx +0 -40
- package/src/stories/widgets/PageHeader.stories.tsx +0 -33
- package/src/storybookHelpers/actions.tsx +0 -5
- package/src/storybookHelpers/index.ts +0 -2
- package/src/storybookHelpers/reactHookForm/index.ts +0 -3
- package/src/storybookHelpers/reactHookForm/model/mockData.ts +0 -21
- package/src/storybookHelpers/reactHookForm/model/mocks.tsx +0 -71
- package/src/storybookHelpers/reactHookForm/model/types.ts +0 -62
- package/src/storybookHelpers/reactHookForm/ui/StorybookFieldsMapper.tsx +0 -76
- package/src/storybookHelpers/reactHookForm/ui/StorybookFormProvider.tsx +0 -43
- package/src/storybookHelpers/reactHookForm/ui/index.ts +0 -2
- package/src/storybookHelpers/table/utils/defaultValue.ts +0 -51
- package/static/arrows/arrowCircle.svg +0 -18
- package/static/arrows/arrowLink.svg +0 -3
- package/static/arrows/arrowRight.svg +0 -3
- package/static/brandLogos/logoBlack.svg +0 -14
- package/static/brandLogos/logoBusiness.svg +0 -80
- package/static/brandLogos/logoGray.svg +0 -56
- package/static/brandLogos/logoInsurance.svg +0 -124
- package/static/brandLogos/logoMain.svg +0 -14
- package/static/brandLogos/logoWhite.svg +0 -56
- package/static/files/documentFilled.svg +0 -4
- package/static/files/documentOutline.svg +0 -4
- package/static/general/calendar.svg +0 -3
- package/static/general/check.svg +0 -6
- package/static/general/close.svg +0 -12
- package/static/info/warningCircle.svg +0 -5
- package/tailwind.config.ts +0 -9
- package/tsconfig.json +0 -33
- package/tsconfig.node.json +0 -11
- package/vite.config.ts +0 -63
- package/vitest.config.mjs +0 -12
- /package/{public → dist}/sprites/arrows.svg +0 -0
- /package/{public → dist}/sprites/brandLogos.svg +0 -0
- /package/{public → dist}/sprites/common.svg +0 -0
- /package/{public → dist}/sprites/files.svg +0 -0
- /package/{public → dist}/sprites/general.svg +0 -0
- /package/{public → dist}/sprites/info.svg +0 -0
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import * as React from 'react'
|
|
4
|
-
import { Controller, type FieldValues } from 'react-hook-form'
|
|
5
|
-
import { Combobox, ComboboxInput, ComboboxOption, ComboboxOptions } from '@headlessui/react'
|
|
6
|
-
import type { TAdditionalInputClassesWithAttachment, TControlledInputProps, TInputCommonProps } from '../model'
|
|
7
|
-
import { FieldAttachment, FieldContainer, FieldWrapper, MessageView } from '../ui'
|
|
8
|
-
import type { TDadataBaseUrl, TDadataType } from './model/types'
|
|
9
|
-
import { useDadata } from './model/useDadata'
|
|
10
|
-
import { cn } from '$/shared/utils'
|
|
11
|
-
|
|
12
|
-
type TDadataClasses = Partial<TAdditionalInputClassesWithAttachment> & {
|
|
13
|
-
options?: string
|
|
14
|
-
indentMargin?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface IDadataInputControlProps<T extends FieldValues> extends TControlledInputProps<T>, TInputCommonProps {
|
|
18
|
-
classes?: TDadataClasses
|
|
19
|
-
dadataType?: TDadataType
|
|
20
|
-
dadataBaseUrl?: TDadataBaseUrl
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const DadataInputControl = <T extends FieldValues>({
|
|
24
|
-
control,
|
|
25
|
-
helperText,
|
|
26
|
-
classes,
|
|
27
|
-
size = 'full',
|
|
28
|
-
label,
|
|
29
|
-
disabled,
|
|
30
|
-
dadataType = 'fio',
|
|
31
|
-
dadataBaseUrl = 'cache',
|
|
32
|
-
badge,
|
|
33
|
-
icon,
|
|
34
|
-
swapPosition,
|
|
35
|
-
...props
|
|
36
|
-
}: IDadataInputControlProps<T>) => {
|
|
37
|
-
const { setQuery, suggestionsOptions } = useDadata(dadataType, dadataBaseUrl)
|
|
38
|
-
const inputId = React.useId()
|
|
39
|
-
// TODO: Пофиксить при нажатие на enter очищается инпут, если нет опшенов
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<Controller
|
|
43
|
-
control={control}
|
|
44
|
-
name={props.name}
|
|
45
|
-
render={({ field: { onChange, ref, name, value }, fieldState: { error } }) => {
|
|
46
|
-
return (
|
|
47
|
-
<FieldContainer size={size} classes={classes}>
|
|
48
|
-
<Combobox value={value} onChange={onChange}>
|
|
49
|
-
<FieldWrapper
|
|
50
|
-
fieldId={inputId}
|
|
51
|
-
label={label}
|
|
52
|
-
classes={classes}
|
|
53
|
-
disabled={disabled}
|
|
54
|
-
value={value}
|
|
55
|
-
error={!!error?.message}
|
|
56
|
-
>
|
|
57
|
-
<>
|
|
58
|
-
<ComboboxInput
|
|
59
|
-
className={cn(
|
|
60
|
-
'w-full h-[56px] desk-body-regular-l text-color-dark transition-all bg-color-transparent outline-none pt-5 px-4 rounded-md z-10',
|
|
61
|
-
classes?.input
|
|
62
|
-
)}
|
|
63
|
-
ref={ref}
|
|
64
|
-
name={name}
|
|
65
|
-
value={value} // TODO: capitalize
|
|
66
|
-
displayValue={(currentValue: string) => {
|
|
67
|
-
return currentValue
|
|
68
|
-
}}
|
|
69
|
-
onChange={(event) => {
|
|
70
|
-
onChange(event.target.value)
|
|
71
|
-
setQuery(event.target.value)
|
|
72
|
-
}}
|
|
73
|
-
/>
|
|
74
|
-
{/* //TODO: Пока проблемы с реализацией на других полях */}
|
|
75
|
-
{/* {suggestionsOptions && debounceQuery && (
|
|
76
|
-
<span className='absolute desk-body-regular-l text-color-blue-grey-600 left-[16px] top-[28px] capitalize group-focus-within:visible'>
|
|
77
|
-
{suggestionsOptions[0]?.value}
|
|
78
|
-
</span>
|
|
79
|
-
)} */}
|
|
80
|
-
<FieldAttachment
|
|
81
|
-
badge={badge}
|
|
82
|
-
icon={icon}
|
|
83
|
-
error={!!error?.message}
|
|
84
|
-
classes={classes}
|
|
85
|
-
swapPosition={swapPosition}
|
|
86
|
-
/>
|
|
87
|
-
</>
|
|
88
|
-
</FieldWrapper>
|
|
89
|
-
<MessageView
|
|
90
|
-
className={cn(classes?.message)}
|
|
91
|
-
intent={error?.message ? 'error' : 'simple'}
|
|
92
|
-
text={error?.message || helperText}
|
|
93
|
-
disabled={disabled}
|
|
94
|
-
/>
|
|
95
|
-
<ComboboxOptions
|
|
96
|
-
transition
|
|
97
|
-
className={cn(
|
|
98
|
-
'absolute top-14 w-full data-[closed]:scale-95 data-[closed]:opacity-0 transition-all scrollHidden p-2 rounded-md bg-color-white border-solid border border-blue-grey-700 mt-2 flex flex-col z-10 empty:invisible'
|
|
99
|
-
)}
|
|
100
|
-
>
|
|
101
|
-
<div className='p-2 customScrollbar-y overflow-x-hidden !max-h-[246px]'>
|
|
102
|
-
{suggestionsOptions && suggestionsOptions?.length > 0 ? (
|
|
103
|
-
<>
|
|
104
|
-
{suggestionsOptions?.map(({ value: suggestionValue, additionalText, isDisabled }) => (
|
|
105
|
-
<ComboboxOption
|
|
106
|
-
disabled={isDisabled}
|
|
107
|
-
key={suggestionValue}
|
|
108
|
-
value={suggestionValue ?? ''}
|
|
109
|
-
className='cursor-pointer px-3 py-3 flex items-center justify-between gap-2 hover:bg-color-blue-grey-200 rounded-sm data-[focus]:bg-color-blue-grey-200 data-[disabled]:bg-color-blue-grey-100 data-[disabled]:text-color-disabled data-[disabled]:pointer-events-none'
|
|
110
|
-
>
|
|
111
|
-
<div className='flex flex-col gap-1'>
|
|
112
|
-
<p className='desk-body-regular-l'>{suggestionValue}</p>
|
|
113
|
-
|
|
114
|
-
{additionalText && <span className='desk-body-regular-s text-color-tetriary'>{additionalText}</span>}
|
|
115
|
-
</div>
|
|
116
|
-
</ComboboxOption>
|
|
117
|
-
))}
|
|
118
|
-
</>
|
|
119
|
-
) : (
|
|
120
|
-
<ComboboxOption value='' className='text-color-tetriary desk-body-regular-m'>
|
|
121
|
-
Ничего не найдено
|
|
122
|
-
</ComboboxOption>
|
|
123
|
-
)}
|
|
124
|
-
</div>
|
|
125
|
-
</ComboboxOptions>
|
|
126
|
-
</Combobox>
|
|
127
|
-
</FieldContainer>
|
|
128
|
-
)
|
|
129
|
-
}}
|
|
130
|
-
/>
|
|
131
|
-
)
|
|
132
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { getDadataBaseUrl, getDataByDadataType } from './helpers'
|
|
2
|
-
import type { TDadataBaseUrl, TDadataType } from './types'
|
|
3
|
-
|
|
4
|
-
export const fetchSuggestions = async (searchText: string, dadataType: TDadataType, dadataBaseUrl: TDadataBaseUrl) => {
|
|
5
|
-
try {
|
|
6
|
-
const response = await fetch(`${getDadataBaseUrl(dadataBaseUrl)}/${dadataType}`, {
|
|
7
|
-
method: 'POST',
|
|
8
|
-
headers: {
|
|
9
|
-
'Content-Type': 'application/json',
|
|
10
|
-
Accept: 'application/json'
|
|
11
|
-
},
|
|
12
|
-
body: JSON.stringify({ query: searchText })
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
if (!response.ok) throw new Error('error')
|
|
16
|
-
const data = await response.json()
|
|
17
|
-
|
|
18
|
-
const formattedData = getDataByDadataType(dadataType, data)
|
|
19
|
-
|
|
20
|
-
return formattedData
|
|
21
|
-
} catch (error) {
|
|
22
|
-
console.error(error)
|
|
23
|
-
return []
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
IDadataAutoOption,
|
|
3
|
-
IDadataCacheOption,
|
|
4
|
-
IDadataCacheSuggestion,
|
|
5
|
-
IDadataConstantsAutoSuggestion,
|
|
6
|
-
IDadataConstantsCountrySuggestion,
|
|
7
|
-
IDadataCountryOption,
|
|
8
|
-
IDadataOrganizationOption,
|
|
9
|
-
TDadataBaseUrl,
|
|
10
|
-
TDadataReturn,
|
|
11
|
-
TDadataSuggestionType,
|
|
12
|
-
TDadataType
|
|
13
|
-
} from './types'
|
|
14
|
-
import { DADATA_BASE_CACHE_URL, DADATA_BASE_CONSTANTS_URL } from '$/shared/constants'
|
|
15
|
-
|
|
16
|
-
export const getDadataBaseUrl = (baseUrl: TDadataBaseUrl) => {
|
|
17
|
-
switch (baseUrl) {
|
|
18
|
-
case 'cache':
|
|
19
|
-
return DADATA_BASE_CACHE_URL
|
|
20
|
-
case 'constants':
|
|
21
|
-
return DADATA_BASE_CONSTANTS_URL
|
|
22
|
-
default:
|
|
23
|
-
return DADATA_BASE_CACHE_URL
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const getDataByDadataType = <T>(dadataType: TDadataType, data: TDadataReturn<T>) => {
|
|
28
|
-
switch (dadataType) {
|
|
29
|
-
case 'country':
|
|
30
|
-
return (data as IDadataConstantsCountrySuggestion).matches
|
|
31
|
-
case 'auto':
|
|
32
|
-
return (data as IDadataConstantsAutoSuggestion).matches
|
|
33
|
-
default:
|
|
34
|
-
return (data as IDadataCacheSuggestion<T>).suggestions
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const getOptionsByDadataType = <T>(dadataType: TDadataType, suggestions: TDadataSuggestionType<T>) => {
|
|
39
|
-
switch (dadataType) {
|
|
40
|
-
case 'country':
|
|
41
|
-
return (suggestions as IDadataCountryOption[])?.map((suggestion) => {
|
|
42
|
-
return {
|
|
43
|
-
value: suggestion?.country_name,
|
|
44
|
-
label: suggestion?.country_name
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
case 'auto':
|
|
49
|
-
return (suggestions as IDadataAutoOption[])?.map((suggestion) => {
|
|
50
|
-
return {
|
|
51
|
-
value: suggestion?.model_mark,
|
|
52
|
-
label: suggestion?.model_mark
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
case 'party':
|
|
57
|
-
return (suggestions as IDadataOrganizationOption[])?.map((suggestion) => {
|
|
58
|
-
return {
|
|
59
|
-
value: suggestion?.value,
|
|
60
|
-
label: suggestion?.value,
|
|
61
|
-
additionalText: `ИНН: ${suggestion?.data?.inn}`
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
case 'fio':
|
|
65
|
-
case 'address':
|
|
66
|
-
return (suggestions as IDadataCacheOption<T>[])?.map((suggestion) => {
|
|
67
|
-
return {
|
|
68
|
-
value: suggestion?.value,
|
|
69
|
-
label: suggestion?.value
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
default:
|
|
74
|
-
return []
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export type TDadataType = 'address' | 'fio' | 'country' | 'auto' | 'party'
|
|
2
|
-
export type TDadataBaseUrl = 'cache' | 'constants'
|
|
3
|
-
|
|
4
|
-
export type TDadataOption = {
|
|
5
|
-
value: string
|
|
6
|
-
additionalText?: string
|
|
7
|
-
isDisabled?: boolean
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// # constants suggestions COUNTRY
|
|
11
|
-
export interface IDadataCountryOption {
|
|
12
|
-
id: number
|
|
13
|
-
country_name: string
|
|
14
|
-
}
|
|
15
|
-
export interface IDadataConstantsCountrySuggestion {
|
|
16
|
-
matches: IDadataCountryOption[]
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// # constants suggestions AUTO
|
|
20
|
-
export interface IDadataAutoOption {
|
|
21
|
-
id: number
|
|
22
|
-
mark: string
|
|
23
|
-
model: string
|
|
24
|
-
model_mark: string
|
|
25
|
-
year_max: string
|
|
26
|
-
year_min: string
|
|
27
|
-
}
|
|
28
|
-
export interface IDadataConstantsAutoSuggestion {
|
|
29
|
-
matches: IDadataAutoOption[]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// # Default dadata suggestions [FIO, ADDRESS]
|
|
33
|
-
export interface IDadataCacheOption<T> {
|
|
34
|
-
value: string
|
|
35
|
-
unrestricted_value: string
|
|
36
|
-
data: T
|
|
37
|
-
}
|
|
38
|
-
export interface IDadataCacheSuggestion<T> {
|
|
39
|
-
suggestions: IDadataCacheOption<T>[]
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// # dadata suggestions organization (party)
|
|
43
|
-
export interface IDadataOrganizationOption {
|
|
44
|
-
value: string
|
|
45
|
-
unrestricted_value: string
|
|
46
|
-
data: {
|
|
47
|
-
inn: 'string'
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export type TDadataReturn<T> = IDadataConstantsCountrySuggestion | IDadataCacheSuggestion<T> | IDadataConstantsAutoSuggestion
|
|
52
|
-
export type TDadataSuggestionType<T> = IDadataCountryOption[] | IDadataCacheOption<T>[] | IDadataAutoOption[]
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import * as React from 'react'
|
|
4
|
-
import { fetchSuggestions } from './api'
|
|
5
|
-
import { getOptionsByDadataType } from './helpers'
|
|
6
|
-
import type { TDadataBaseUrl, TDadataOption, TDadataType } from './types'
|
|
7
|
-
import { useDebounceValue } from '$/shared/hooks'
|
|
8
|
-
|
|
9
|
-
export const useDadata = (dadataType: TDadataType, dadataBaseUrl: TDadataBaseUrl) => {
|
|
10
|
-
const [query, setQuery] = React.useState('')
|
|
11
|
-
const [suggestionsOptions, setSuggestionsOptions] = React.useState<TDadataOption[] | null>(null)
|
|
12
|
-
const debounceQuery = useDebounceValue(query, 300)
|
|
13
|
-
|
|
14
|
-
React.useEffect(() => {
|
|
15
|
-
if (debounceQuery) {
|
|
16
|
-
const handleSearch = async () => {
|
|
17
|
-
const suggestions = await fetchSuggestions(debounceQuery, dadataType, dadataBaseUrl)
|
|
18
|
-
setSuggestionsOptions(getOptionsByDadataType(dadataType, suggestions))
|
|
19
|
-
}
|
|
20
|
-
handleSearch()
|
|
21
|
-
}
|
|
22
|
-
}, [debounceQuery, dadataType, dadataBaseUrl])
|
|
23
|
-
|
|
24
|
-
return { setQuery, suggestionsOptions, debounceQuery }
|
|
25
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type TFieldWrapperClasses = {
|
|
2
|
-
field: string
|
|
3
|
-
label: string
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export type TFieldAttachmentClasses = {
|
|
7
|
-
badge: string
|
|
8
|
-
icon: string
|
|
9
|
-
attachmentWrapper: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type TFieldContainerClasses = {
|
|
13
|
-
container: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type TInputCommonClasses = {
|
|
17
|
-
input: string
|
|
18
|
-
message: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type TAdditionalInputPrimitiveClasses = TFieldWrapperClasses & TFieldContainerClasses & TInputCommonClasses
|
|
22
|
-
export type TAdditionalInputClassesWithAttachment = TAdditionalInputPrimitiveClasses & TFieldAttachmentClasses
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type * as React from 'react'
|
|
2
|
-
import type { Control, FieldValues, Path } from 'react-hook-form'
|
|
3
|
-
import type { TFieldContainerConfig } from '../ui/FieldContainer'
|
|
4
|
-
|
|
5
|
-
export type TInputCommonProps = Omit<React.ComponentProps<'input'>, 'name' | 'placeholder' | 'size' | 'type' | 'defaultValue'>
|
|
6
|
-
export type TTextareaCommonProps = Omit<React.ComponentProps<'textarea'>, 'name' | 'size' | 'type' | 'defaultValue'>
|
|
7
|
-
|
|
8
|
-
type TFieldControlledProps<T extends FieldValues> = {
|
|
9
|
-
name: Path<T>
|
|
10
|
-
control: Control<T>
|
|
11
|
-
label: string
|
|
12
|
-
helperText?: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type TFieldContainerSize = 'sm' | 'md' | 'lg' | 'full'
|
|
16
|
-
export type TFieldAttachment = {
|
|
17
|
-
badge?: string
|
|
18
|
-
icon?: React.ReactElement
|
|
19
|
-
swapPosition?: boolean
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// # Required props on controlled INPUTS - [maskInput, baseInput, dadata]
|
|
23
|
-
export type TControlledInputProps<T extends FieldValues> = TFieldContainerConfig & TFieldAttachment & TFieldControlledProps<T>
|
|
24
|
-
|
|
25
|
-
// # Required props on controlled INPUTS - [checkbox, radio]
|
|
26
|
-
export type TControlledInputPrimitiveProps<T extends FieldValues> = TInputCommonProps & TFieldControlledProps<T>
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import * as React from 'react'
|
|
4
|
-
import { Badge } from '../../Badge'
|
|
5
|
-
import { Icon } from '../../icon/Icon'
|
|
6
|
-
import type { TFieldAttachmentClasses } from '../model/classes-types'
|
|
7
|
-
import type { TFieldAttachment } from '../model/props-types'
|
|
8
|
-
import { cn } from '$/shared/utils'
|
|
9
|
-
|
|
10
|
-
interface IFieldAttachmentProps extends TFieldAttachment {
|
|
11
|
-
classes?: Partial<TFieldAttachmentClasses>
|
|
12
|
-
error?: boolean
|
|
13
|
-
isTextarea?: boolean
|
|
14
|
-
swapPosition?: boolean
|
|
15
|
-
onClickIcon?: (...args: unknown[]) => unknown
|
|
16
|
-
onKeyDownIcon?: (event: React.KeyboardEvent) => unknown
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const FieldAttachment = ({
|
|
20
|
-
badge,
|
|
21
|
-
icon,
|
|
22
|
-
error,
|
|
23
|
-
isTextarea = false,
|
|
24
|
-
classes,
|
|
25
|
-
swapPosition,
|
|
26
|
-
onClickIcon,
|
|
27
|
-
onKeyDownIcon
|
|
28
|
-
}: IFieldAttachmentProps) => {
|
|
29
|
-
const interactiveIconAttr = (onClickIcon || onKeyDownIcon) && {
|
|
30
|
-
role: 'button',
|
|
31
|
-
tabIndex: 0,
|
|
32
|
-
onClick: onClickIcon,
|
|
33
|
-
onKeyDown: onKeyDownIcon
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<>
|
|
38
|
-
{error ? (
|
|
39
|
-
<Icon name='info/warningCircle' className={cn('text-icon-secondary-default size-6 mr-4', { 'm-0 size-5': isTextarea })} />
|
|
40
|
-
) : (
|
|
41
|
-
<>
|
|
42
|
-
{(badge || icon) && (
|
|
43
|
-
<div
|
|
44
|
-
className={cn(
|
|
45
|
-
'flex items-center gap-4 mr-4',
|
|
46
|
-
{ 'm-0': isTextarea },
|
|
47
|
-
{ 'flex-row-reverse': swapPosition },
|
|
48
|
-
classes?.attachmentWrapper
|
|
49
|
-
)}
|
|
50
|
-
>
|
|
51
|
-
{icon && (
|
|
52
|
-
<span
|
|
53
|
-
{...interactiveIconAttr}
|
|
54
|
-
className={cn('size-6 flex justify-center items-center', { 'size-5': isTextarea }, classes?.icon)}
|
|
55
|
-
>
|
|
56
|
-
{icon}
|
|
57
|
-
</span>
|
|
58
|
-
)}
|
|
59
|
-
{badge && <Badge className={cn('bg-color-positive', classes?.badge)}>{badge}</Badge>}
|
|
60
|
-
</div>
|
|
61
|
-
)}
|
|
62
|
-
</>
|
|
63
|
-
)}
|
|
64
|
-
</>
|
|
65
|
-
)
|
|
66
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import * as React from 'react'
|
|
4
|
-
import { cva, type VariantProps } from 'class-variance-authority'
|
|
5
|
-
import type { TFieldContainerClasses } from '../model/classes-types'
|
|
6
|
-
import { cn } from '$/shared/utils'
|
|
7
|
-
|
|
8
|
-
const fieldContainerConfig = cva('relative flex flex-col group', {
|
|
9
|
-
variants: {
|
|
10
|
-
intent: {
|
|
11
|
-
clear: '!w-full min-w-[140px]',
|
|
12
|
-
filled: ''
|
|
13
|
-
},
|
|
14
|
-
size: {
|
|
15
|
-
sm: 'w-[360px]',
|
|
16
|
-
md: 'w-[520px]',
|
|
17
|
-
lg: 'w-[720px]',
|
|
18
|
-
full: 'w-full'
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
defaultVariants: {
|
|
22
|
-
size: 'full',
|
|
23
|
-
intent: 'filled'
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
export type TFieldContainerConfig = VariantProps<typeof fieldContainerConfig>
|
|
28
|
-
|
|
29
|
-
interface IFieldContainerProps extends TFieldContainerConfig {
|
|
30
|
-
classes?: Partial<TFieldContainerClasses>
|
|
31
|
-
children: React.ReactNode
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const FieldContainer = ({ size, intent, classes, children }: IFieldContainerProps) => {
|
|
35
|
-
return <div className={cn(fieldContainerConfig({ size, intent }), classes?.container)}>{children}</div>
|
|
36
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import * as React from 'react'
|
|
4
|
-
import type { TFieldWrapperClasses } from '../model'
|
|
5
|
-
import { cn } from '$/shared/utils'
|
|
6
|
-
|
|
7
|
-
interface IFieldWrapperProps<V> {
|
|
8
|
-
children: React.ReactElement
|
|
9
|
-
label: string
|
|
10
|
-
fieldId: string
|
|
11
|
-
value: V
|
|
12
|
-
error?: boolean
|
|
13
|
-
classes?: Partial<TFieldWrapperClasses>
|
|
14
|
-
disabled?: boolean
|
|
15
|
-
isTextarea?: boolean
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const FieldWrapper = <V,>({
|
|
19
|
-
children,
|
|
20
|
-
error,
|
|
21
|
-
disabled,
|
|
22
|
-
classes,
|
|
23
|
-
fieldId,
|
|
24
|
-
label,
|
|
25
|
-
value,
|
|
26
|
-
isTextarea = false
|
|
27
|
-
}: IFieldWrapperProps<V>) => {
|
|
28
|
-
return (
|
|
29
|
-
<div
|
|
30
|
-
className={cn(
|
|
31
|
-
'relative border-solid transition-colors rounded-sm border border-transparent bg-color-blue-grey-100 group-focus-within:border-blue-grey-800 focus:outline-blue-grey-800 hover:bg-color-blue-grey-200 active:bg-color-blue-grey-100 flex items-center justify-between',
|
|
32
|
-
{ '!border-negative': error },
|
|
33
|
-
{ '!bg-color-blue-grey-100': disabled },
|
|
34
|
-
classes?.field
|
|
35
|
-
)}
|
|
36
|
-
>
|
|
37
|
-
<label
|
|
38
|
-
htmlFor={fieldId}
|
|
39
|
-
className={cn(
|
|
40
|
-
'absolute top-2/4 -translate-y-1/2 left-4 desk-body-regular-l text-color-tetriary pointer-events-none transition-all duration-15 ',
|
|
41
|
-
{ 'top-2 bg-color-transparent translate-y-0 desk-body-regular-s': value && !isTextarea },
|
|
42
|
-
{
|
|
43
|
-
'group-focus-within:top-2 group-focus-within:bg-color-transparent group-focus-within:translate-y-0 group-focus-within:desk-body-regular-s':
|
|
44
|
-
!isTextarea
|
|
45
|
-
},
|
|
46
|
-
{ 'top-2 desk-body-regular-s translate-y-0': isTextarea },
|
|
47
|
-
classes?.label
|
|
48
|
-
)}
|
|
49
|
-
>
|
|
50
|
-
{label}
|
|
51
|
-
</label>
|
|
52
|
-
{children}
|
|
53
|
-
</div>
|
|
54
|
-
)
|
|
55
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import type { FieldError } from 'react-hook-form'
|
|
4
|
-
import { cva, type VariantProps } from 'class-variance-authority'
|
|
5
|
-
import { cn } from '$/shared/utils'
|
|
6
|
-
|
|
7
|
-
const messageViewConfig = cva('desk-body-regular-m mt-2', {
|
|
8
|
-
variants: {
|
|
9
|
-
intent: {
|
|
10
|
-
simple: 'text-color-tetriary',
|
|
11
|
-
error: 'text-color-negative'
|
|
12
|
-
},
|
|
13
|
-
disabled: {
|
|
14
|
-
true: 'text-color-disabled',
|
|
15
|
-
false: ''
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
defaultVariants: {
|
|
19
|
-
intent: 'simple'
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
export interface IMessageViewProps extends VariantProps<typeof messageViewConfig> {
|
|
24
|
-
as?: 'div' | 'span' | 'p'
|
|
25
|
-
text?: string | FieldError['message']
|
|
26
|
-
className?: string
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const MessageView = ({ intent, as: Element = 'p', disabled, text, className, ...props }: IMessageViewProps) => {
|
|
30
|
-
if (!text) return null
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<Element className={cn(messageViewConfig({ intent, disabled }), className)} {...props}>
|
|
34
|
-
{text}
|
|
35
|
-
</Element>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import * as React from 'react'
|
|
4
|
-
import { SPRITES_META, type SpritesMap } from './sprite.gen'
|
|
5
|
-
import { cn } from '$/shared/utils'
|
|
6
|
-
|
|
7
|
-
export type IconName<Key extends keyof SpritesMap> = `${Key}/${SpritesMap[Key]}`
|
|
8
|
-
export type TAllowedIcons = { [Key in keyof SpritesMap]: IconName<Key> }[keyof SpritesMap]
|
|
9
|
-
|
|
10
|
-
export interface IconProps extends React.SVGProps<SVGSVGElement> {
|
|
11
|
-
name: TAllowedIcons
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const getIconMeta = <Key extends keyof SpritesMap>(name: IconName<Key>) => {
|
|
15
|
-
const [spriteName, iconName] = name.split('/') as [Key, SpritesMap[Key]]
|
|
16
|
-
const {
|
|
17
|
-
filePath,
|
|
18
|
-
items: {
|
|
19
|
-
[iconName]: { viewBox, width, height }
|
|
20
|
-
}
|
|
21
|
-
} = SPRITES_META[spriteName]
|
|
22
|
-
// eslint-disable-next-line no-nested-ternary
|
|
23
|
-
const axis = width === height ? 'xy' : width > height ? 'x' : 'y'
|
|
24
|
-
|
|
25
|
-
return { filePath, iconName, viewBox, axis }
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const Icon = ({ name, className, ...props }: IconProps) => {
|
|
29
|
-
const { viewBox, filePath, iconName, axis } = getIconMeta(name)
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<svg
|
|
33
|
-
className={cn('select-none fill-current inline-block text-inherit size-6', className)}
|
|
34
|
-
focusable='false'
|
|
35
|
-
viewBox={viewBox}
|
|
36
|
-
aria-hidden
|
|
37
|
-
data-axis={axis}
|
|
38
|
-
{...props}
|
|
39
|
-
>
|
|
40
|
-
<use href={`sprites/${filePath}#${iconName}`} />
|
|
41
|
-
</svg>
|
|
42
|
-
)
|
|
43
|
-
}
|