@kvell-group/ui 1.19.5 → 1.19.7
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/package.json +1 -1
- package/src/components/Alert/Alert.module.css +28 -0
- package/src/components/Alert/Alert.stories.tsx +69 -0
- package/src/components/Alert/Alert.tsx +33 -0
- package/src/components/Alert/constants.ts +3 -0
- package/src/components/Alert/index.ts +1 -0
- package/src/components/Alert/types.ts +8 -0
- package/src/components/Inputs/AutocompleteSelect/AutocompleteSelect.module.css +3 -0
- package/src/components/Inputs/AutocompleteSelect/AutocompleteSelect.stories.tsx +89 -0
- package/src/components/Inputs/AutocompleteSelect/AutocompleteSelect.tsx +20 -0
- package/src/components/Inputs/AutocompleteSelect/index.ts +1 -0
- package/src/index.ts +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
padding: rem(16px);
|
|
3
|
+
box-shadow:
|
|
4
|
+
0px 3px 10px -2px rgba(20, 21, 26, 0.02),
|
|
5
|
+
0px 10px 16px -3px rgba(20, 21, 26, 0.05);
|
|
6
|
+
|
|
7
|
+
&[data-variant='warning'] {
|
|
8
|
+
--alert-bg: var(--color-background-surface-warning-subtle);
|
|
9
|
+
--alert-bd: rem(1px) solid var(--color-border-action-normal);
|
|
10
|
+
--alert-color: var(--color-icon-status-warning);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.wrapper {
|
|
15
|
+
align-items: flex-start;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.icon {
|
|
19
|
+
margin-inline-end: rem(12px);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.message {
|
|
23
|
+
font-weight: 500;
|
|
24
|
+
font-size: var(--mantine-font-size-body-s);
|
|
25
|
+
line-height: var(--mantine-line-height-body-s);
|
|
26
|
+
letter-spacing: var(--mantine-spacing-body-s);
|
|
27
|
+
color: var(--color-text-base-primary);
|
|
28
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
|
|
3
|
+
import { KvellUiProvider } from '@/components/KvellUiProvider'
|
|
4
|
+
|
|
5
|
+
import { theme } from '@/theme'
|
|
6
|
+
import { Alert } from '@/components/Alert'
|
|
7
|
+
import { AlertVariants, WARNING_ALERT_VARIANT } from '@/components/Alert/constants'
|
|
8
|
+
|
|
9
|
+
// ----------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
const meta = {
|
|
12
|
+
title: 'Components/Alert',
|
|
13
|
+
argTypes: { variant: AlertVariants },
|
|
14
|
+
component: Alert,
|
|
15
|
+
decorators: (Story) => (
|
|
16
|
+
<KvellUiProvider theme={theme}>
|
|
17
|
+
<Story />
|
|
18
|
+
</KvellUiProvider>
|
|
19
|
+
),
|
|
20
|
+
} satisfies Meta<typeof Alert>
|
|
21
|
+
|
|
22
|
+
type Story = StoryObj<typeof meta>
|
|
23
|
+
|
|
24
|
+
// ----------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
export const ComponentAlert: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
variant: WARNING_ALERT_VARIANT,
|
|
29
|
+
children: 'Проверьте данные карты перед оплатой',
|
|
30
|
+
},
|
|
31
|
+
argTypes: {
|
|
32
|
+
variant: {
|
|
33
|
+
control: 'select',
|
|
34
|
+
options: AlertVariants,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const WarningAlert: Story = {
|
|
40
|
+
args: {
|
|
41
|
+
variant: WARNING_ALERT_VARIANT,
|
|
42
|
+
children: 'Оплата будет доступна после подтверждения банком',
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const CustomIconAlert: Story = {
|
|
47
|
+
args: {
|
|
48
|
+
icon: null,
|
|
49
|
+
children: 'Алерт без иконки',
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const WarningAlertWithoutIcon: Story = {
|
|
54
|
+
args: {
|
|
55
|
+
variant: WARNING_ALERT_VARIANT,
|
|
56
|
+
icon: null,
|
|
57
|
+
children: 'Алерт с вариантом warning, но без иконки (icon явно передан как null)',
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const DefaultAlert: Story = {
|
|
62
|
+
args: {
|
|
63
|
+
children: 'Алерт без variant и без icon — прозрачный фон, без иконки',
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ----------------------------------------------------------------------
|
|
68
|
+
|
|
69
|
+
export default meta
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { forwardRef } from 'react'
|
|
2
|
+
import { Alert as MantineAlert } from '@mantine/core'
|
|
3
|
+
import type { AlertProps as MantineAlertProps } from '@mantine/core'
|
|
4
|
+
import { RiErrorWarningFill } from '@remixicon/react'
|
|
5
|
+
import classNames from './Alert.module.css'
|
|
6
|
+
import { WARNING_ALERT_VARIANT } from './constants'
|
|
7
|
+
import type { ExtendedAlertVariant } from './types'
|
|
8
|
+
|
|
9
|
+
// ----------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
export type AlertProps = Omit<MantineAlertProps, 'variant'> & { variant?: ExtendedAlertVariant }
|
|
12
|
+
|
|
13
|
+
const variantIcons: Partial<Record<ExtendedAlertVariant & string, React.ReactNode>> = {
|
|
14
|
+
[WARNING_ALERT_VARIANT]: <RiErrorWarningFill size={20} />,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// ----------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
|
|
20
|
+
const { variant, icon, ...others } = props
|
|
21
|
+
|
|
22
|
+
const resolvedIcon = icon === undefined ? (variant ? variantIcons[variant] : null) : icon
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<MantineAlert
|
|
26
|
+
ref={ref}
|
|
27
|
+
variant={variant ?? 'transparent'}
|
|
28
|
+
icon={resolvedIcon}
|
|
29
|
+
{...others}
|
|
30
|
+
classNames={classNames}
|
|
31
|
+
/>
|
|
32
|
+
)
|
|
33
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Alert } from './Alert'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AlertVariants } from './constants'
|
|
2
|
+
import type { AlertProps as MantineAlertProps } from '@mantine/core'
|
|
3
|
+
|
|
4
|
+
// ----------------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
type AlertVariantsType = typeof AlertVariants
|
|
7
|
+
|
|
8
|
+
export type ExtendedAlertVariant = MantineAlertProps['variant'] | AlertVariantsType[number]
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
3
|
+
|
|
4
|
+
import { KvellUiProvider } from '@/components/KvellUiProvider'
|
|
5
|
+
import { Text } from '@/components/Text'
|
|
6
|
+
|
|
7
|
+
import { theme } from '@/theme'
|
|
8
|
+
import { AutocompleteSelect as AutocompleteSelectComponent } from '@/components/Inputs/AutocompleteSelect'
|
|
9
|
+
|
|
10
|
+
const data = ['React', 'Angular', 'Vue', 'Svelte', 'Solid', 'Ember']
|
|
11
|
+
|
|
12
|
+
const options: { value: string; label: string }[] = [
|
|
13
|
+
{ value: 'react', label: 'React' },
|
|
14
|
+
{ value: 'angular', label: 'Angular' },
|
|
15
|
+
{ value: 'vue', label: 'Vue' },
|
|
16
|
+
{ value: 'svelte', label: 'Svelte' },
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
const AutocompleteSelectWithLabelValueWrapper = () => {
|
|
20
|
+
const [label, setLabel] = useState('')
|
|
21
|
+
const [value, setValue] = useState<string | null>(null)
|
|
22
|
+
|
|
23
|
+
const handleChange = (nextLabel: string) => {
|
|
24
|
+
setLabel(nextLabel)
|
|
25
|
+
setValue(options.find((option) => option.label === nextLabel)?.value ?? null)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div style={{ maxWidth: '465px' }}>
|
|
30
|
+
<AutocompleteSelectComponent
|
|
31
|
+
label='Фреймворк'
|
|
32
|
+
placeholder='Выберите или введите значение'
|
|
33
|
+
data={options.map((option) => option.label)}
|
|
34
|
+
value={label}
|
|
35
|
+
onChange={handleChange}
|
|
36
|
+
/>
|
|
37
|
+
<Text
|
|
38
|
+
variant='caption-l-regular'
|
|
39
|
+
mt='sm'
|
|
40
|
+
display='block'
|
|
41
|
+
>
|
|
42
|
+
Выбранное value: {value ?? '—'}
|
|
43
|
+
</Text>
|
|
44
|
+
</div>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ----------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
const meta = {
|
|
51
|
+
title: 'Components/Inputs/AutocompleteSelect',
|
|
52
|
+
component: AutocompleteSelectComponent,
|
|
53
|
+
decorators: (Story) => (
|
|
54
|
+
<KvellUiProvider theme={theme}>
|
|
55
|
+
<div style={{ maxWidth: '465px' }}>
|
|
56
|
+
<Story />
|
|
57
|
+
</div>
|
|
58
|
+
</KvellUiProvider>
|
|
59
|
+
),
|
|
60
|
+
} satisfies Meta<typeof AutocompleteSelectComponent>
|
|
61
|
+
|
|
62
|
+
type Story = StoryObj<typeof AutocompleteSelectComponent>
|
|
63
|
+
|
|
64
|
+
// ----------------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
export const AutocompleteSelect: Story = {
|
|
67
|
+
args: {
|
|
68
|
+
placeholder: 'Выберите или введите значение',
|
|
69
|
+
label: 'Фреймворк',
|
|
70
|
+
data,
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const AutocompleteSelectError: Story = {
|
|
75
|
+
args: {
|
|
76
|
+
placeholder: 'Выберите или введите значение',
|
|
77
|
+
label: 'Фреймворк',
|
|
78
|
+
data,
|
|
79
|
+
error: 'Значение не найдено в списке',
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const AutocompleteSelectWithLabelValue: Story = {
|
|
84
|
+
render: () => <AutocompleteSelectWithLabelValueWrapper />,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ----------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
export default meta
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Autocomplete as MantineAutocomplete } from '@mantine/core'
|
|
2
|
+
import clsx from 'clsx'
|
|
3
|
+
import inputClassNames from '../Input/Input.module.css'
|
|
4
|
+
import autocompleteSelectClassNames from './AutocompleteSelect.module.css'
|
|
5
|
+
|
|
6
|
+
// ----------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
const classNames = {
|
|
9
|
+
...inputClassNames,
|
|
10
|
+
root: clsx(autocompleteSelectClassNames.root, inputClassNames.root),
|
|
11
|
+
section: clsx(autocompleteSelectClassNames.section, inputClassNames.section),
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ----------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
export const AutocompleteSelect = MantineAutocomplete.withProps({
|
|
17
|
+
classNames,
|
|
18
|
+
inputWrapperOrder: ['label', 'input', 'error', 'description'],
|
|
19
|
+
comboboxProps: { floatingStrategy: 'fixed' },
|
|
20
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AutocompleteSelect } from './AutocompleteSelect'
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { CardExpireDateInput } from './components/Inputs/CardExpireDateInput'
|
|
|
14
14
|
export { Checkbox } from './components/Inputs/Checkbox'
|
|
15
15
|
export { Switch } from './components/Inputs/Switch'
|
|
16
16
|
export { Select } from './components/Inputs/Select'
|
|
17
|
+
export { AutocompleteSelect } from './components/Inputs/AutocompleteSelect'
|
|
17
18
|
export { Textarea } from './components/Inputs/Textarea'
|
|
18
19
|
export { DatesProvider } from './components/DatesProvider'
|
|
19
20
|
export * from './components/Inputs/DatePickerInput'
|
|
@@ -21,6 +22,7 @@ export { PinInput } from './components/Inputs/PinInput'
|
|
|
21
22
|
export * from './components/Notifications'
|
|
22
23
|
|
|
23
24
|
//components
|
|
25
|
+
export { Alert } from './components/Alert'
|
|
24
26
|
export * from './components/Button'
|
|
25
27
|
export { CardLogoByPan } from './components/CardLogoByPan'
|
|
26
28
|
export { Loader } from './components/Loader'
|