@kvell-group/ui 1.19.6 → 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 CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@kvell-group/ui",
3
3
  "author": "Kvell Group",
4
4
  "private": false,
5
- "version": "1.19.6",
5
+ "version": "1.19.7",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/kvell-group/ui.git"
@@ -0,0 +1,3 @@
1
+ .root .section {
2
+ --right-section-end: rem(3px);
3
+ }
@@ -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'