@registrucentras/rc-ses-react-components 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/icons/PencilSimpleLineIcon.d.ts +1 -1
- package/dist/components/common/SegmentedControl/components/SegmentButton/index.d.ts +19 -0
- package/dist/components/common/SegmentedControl/index.d.ts +14 -0
- package/dist/components/form/inputs/SearchInput/index.d.ts +10 -0
- package/dist/library/index.d.ts +2 -0
- package/dist/library/types.d.ts +3 -1
- package/dist/registrucentras-rc-ses-react-components.cjs +10 -10
- package/dist/registrucentras-rc-ses-react-components.js +2240 -2042
- package/dist/stories/components/display/SegmentedControl.stories.d.ts +202 -0
- package/package.json +1 -1
- package/src/assets/icons/PencilSimpleLineIcon.tsx +8 -2
- package/src/components/common/SegmentedControl/components/SegmentButton/index.test.tsx +85 -0
- package/src/components/common/SegmentedControl/components/SegmentButton/index.tsx +110 -0
- package/src/components/common/SegmentedControl/index.test.tsx +164 -0
- package/src/components/common/SegmentedControl/index.tsx +188 -0
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.test.tsx +74 -1
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.tsx +16 -1
- package/src/components/form/inputs/SearchInput/index.test.tsx +68 -2
- package/src/components/form/inputs/SearchInput/index.tsx +24 -13
- package/src/i18n/namespaces/common/en.json +4 -0
- package/src/i18n/namespaces/common/lt.json +4 -0
- package/src/library/index.ts +2 -0
- package/src/library/types.ts +8 -0
- package/src/stories/components/display/SegmentedControl.stories.tsx +311 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import type { Meta } from '@storybook/react'
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
|
|
4
|
+
import RcSesSegmentedControl from '../../../components/common/SegmentedControl'
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'components/display/SegmentedControl',
|
|
8
|
+
component: RcSesSegmentedControl,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
},
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
argTypes: {
|
|
14
|
+
options: {
|
|
15
|
+
control: false,
|
|
16
|
+
description: 'Array of options to display',
|
|
17
|
+
},
|
|
18
|
+
value: {
|
|
19
|
+
control: 'text',
|
|
20
|
+
description: 'Currently selected option ID',
|
|
21
|
+
},
|
|
22
|
+
onChange: {
|
|
23
|
+
control: false,
|
|
24
|
+
description: 'Callback when selection changes',
|
|
25
|
+
},
|
|
26
|
+
size: {
|
|
27
|
+
control: 'radio',
|
|
28
|
+
options: ['small', 'regular'],
|
|
29
|
+
description: 'Size of the segmented control',
|
|
30
|
+
},
|
|
31
|
+
role: {
|
|
32
|
+
control: 'radio',
|
|
33
|
+
options: ['radiogroup', 'tablist'],
|
|
34
|
+
description: 'ARIA role for accessibility',
|
|
35
|
+
},
|
|
36
|
+
disableBg: {
|
|
37
|
+
control: 'boolean',
|
|
38
|
+
description: 'Disable container background',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
} satisfies Meta<typeof RcSesSegmentedControl>
|
|
42
|
+
|
|
43
|
+
export default meta
|
|
44
|
+
|
|
45
|
+
const DefaultComponent = ({
|
|
46
|
+
options,
|
|
47
|
+
value: initialValue,
|
|
48
|
+
onChange,
|
|
49
|
+
size,
|
|
50
|
+
role,
|
|
51
|
+
disableBg,
|
|
52
|
+
}: any) => {
|
|
53
|
+
const [value, setValue] = useState(initialValue)
|
|
54
|
+
return (
|
|
55
|
+
<RcSesSegmentedControl
|
|
56
|
+
options={options}
|
|
57
|
+
value={value}
|
|
58
|
+
onChange={(newValue) => {
|
|
59
|
+
setValue(newValue)
|
|
60
|
+
onChange?.(newValue)
|
|
61
|
+
}}
|
|
62
|
+
size={size}
|
|
63
|
+
role={role}
|
|
64
|
+
disableBg={disableBg}
|
|
65
|
+
/>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const Default = {
|
|
70
|
+
args: {
|
|
71
|
+
options: [
|
|
72
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
73
|
+
{ id: '2', label: 'Juridinis asmuo' },
|
|
74
|
+
{ id: '3', label: 'Advokatas' },
|
|
75
|
+
],
|
|
76
|
+
value: '1',
|
|
77
|
+
onChange: () => {},
|
|
78
|
+
size: 'regular' as const,
|
|
79
|
+
role: 'radiogroup' as const,
|
|
80
|
+
disableBg: false,
|
|
81
|
+
},
|
|
82
|
+
render: ({ options, value: initialValue, onChange, size, role, disableBg }: any) => (
|
|
83
|
+
<DefaultComponent
|
|
84
|
+
options={options}
|
|
85
|
+
value={initialValue}
|
|
86
|
+
onChange={onChange}
|
|
87
|
+
size={size}
|
|
88
|
+
role={role}
|
|
89
|
+
disableBg={disableBg}
|
|
90
|
+
/>
|
|
91
|
+
),
|
|
92
|
+
} as const
|
|
93
|
+
|
|
94
|
+
export const RegularTwoOptions = {
|
|
95
|
+
args: {
|
|
96
|
+
options: [
|
|
97
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
98
|
+
{ id: '2', label: 'Juridinis asmuo' },
|
|
99
|
+
],
|
|
100
|
+
value: '1',
|
|
101
|
+
size: 'regular',
|
|
102
|
+
},
|
|
103
|
+
render: (args: any) => <DefaultComponent {...args} />,
|
|
104
|
+
parameters: {
|
|
105
|
+
docs: {
|
|
106
|
+
source: {
|
|
107
|
+
code: `const [value, setValue] = useState('1');
|
|
108
|
+
|
|
109
|
+
<RcSesSegmentedControl
|
|
110
|
+
options={[
|
|
111
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
112
|
+
{ id: '2', label: 'Juridinis asmuo' },
|
|
113
|
+
]}
|
|
114
|
+
value={value}
|
|
115
|
+
onChange={(newValue) => setValue(newValue)}
|
|
116
|
+
size="regular"
|
|
117
|
+
/>`,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
} as const
|
|
122
|
+
|
|
123
|
+
export const RegularFourOptions = {
|
|
124
|
+
args: {
|
|
125
|
+
options: [
|
|
126
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
127
|
+
{ id: '2', label: 'Juridinis asmuo' },
|
|
128
|
+
{ id: '3', label: 'Advokatas' },
|
|
129
|
+
{ id: '4', label: 'Labai ilgas tekstas, netelpantis į vieną eilutę' },
|
|
130
|
+
],
|
|
131
|
+
value: '1',
|
|
132
|
+
size: 'regular',
|
|
133
|
+
},
|
|
134
|
+
render: (args: any) => <DefaultComponent {...args} />,
|
|
135
|
+
parameters: {
|
|
136
|
+
docs: {
|
|
137
|
+
source: {
|
|
138
|
+
code: `const [value, setValue] = useState('1');
|
|
139
|
+
|
|
140
|
+
<RcSesSegmentedControl
|
|
141
|
+
options={[
|
|
142
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
143
|
+
{ id: '2', label: 'Juridinis asmuo' },
|
|
144
|
+
{ id: '3', label: 'Advokatas' },
|
|
145
|
+
{ id: '4', label: 'Labai ilgas tekstas, netelpantis į vieną eilutę' },
|
|
146
|
+
]}
|
|
147
|
+
value={value}
|
|
148
|
+
onChange={(newValue) => setValue(newValue)}
|
|
149
|
+
size="regular"
|
|
150
|
+
/>`,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export const RegularWithDisabled = {
|
|
157
|
+
args: {
|
|
158
|
+
options: [
|
|
159
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
160
|
+
{ id: '2', label: 'Juridinis asmuo (Disabled)', disabled: true },
|
|
161
|
+
{ id: '3', label: 'Advokatas' },
|
|
162
|
+
],
|
|
163
|
+
value: '1',
|
|
164
|
+
size: 'regular',
|
|
165
|
+
},
|
|
166
|
+
render: (args: any) => <DefaultComponent {...args} />,
|
|
167
|
+
parameters: {
|
|
168
|
+
docs: {
|
|
169
|
+
source: {
|
|
170
|
+
code: `const [value, setValue] = useState('1');
|
|
171
|
+
|
|
172
|
+
<RcSesSegmentedControl
|
|
173
|
+
options={[
|
|
174
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
175
|
+
{ id: '2', label: 'Juridinis asmuo', disabled: true },
|
|
176
|
+
{ id: '3', label: 'Advokatas' },
|
|
177
|
+
]}
|
|
178
|
+
value={value}
|
|
179
|
+
onChange={(newValue) => setValue(newValue)}
|
|
180
|
+
size="regular"
|
|
181
|
+
/>`,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export const SmallTwoOptions = {
|
|
188
|
+
args: {
|
|
189
|
+
options: [
|
|
190
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
191
|
+
{ id: '2', label: 'Juridinis asmuo' },
|
|
192
|
+
],
|
|
193
|
+
value: '1',
|
|
194
|
+
size: 'small',
|
|
195
|
+
},
|
|
196
|
+
render: (args: any) => <DefaultComponent {...args} />,
|
|
197
|
+
parameters: {
|
|
198
|
+
docs: {
|
|
199
|
+
source: {
|
|
200
|
+
code: `const [value, setValue] = useState('1');
|
|
201
|
+
|
|
202
|
+
<RcSesSegmentedControl
|
|
203
|
+
options={[
|
|
204
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
205
|
+
{ id: '2', label: 'Juridinis asmuo' },
|
|
206
|
+
]}
|
|
207
|
+
value={value}
|
|
208
|
+
onChange={(newValue) => setValue(newValue)}
|
|
209
|
+
size="small"
|
|
210
|
+
/>`,
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
} as const
|
|
215
|
+
|
|
216
|
+
export const SmallFourOptions = {
|
|
217
|
+
args: {
|
|
218
|
+
options: [
|
|
219
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
220
|
+
{ id: '2', label: 'Juridinis asmuo' },
|
|
221
|
+
{ id: '3', label: 'Advokatas' },
|
|
222
|
+
{ id: '4', label: 'Kita' },
|
|
223
|
+
],
|
|
224
|
+
value: '1',
|
|
225
|
+
size: 'small',
|
|
226
|
+
},
|
|
227
|
+
render: (args: any) => <DefaultComponent {...args} />,
|
|
228
|
+
parameters: {
|
|
229
|
+
docs: {
|
|
230
|
+
source: {
|
|
231
|
+
code: `const [value, setValue] = useState('1');
|
|
232
|
+
|
|
233
|
+
<RcSesSegmentedControl
|
|
234
|
+
options={[
|
|
235
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
236
|
+
{ id: '2', label: 'Juridinis asmuo' },
|
|
237
|
+
{ id: '3', label: 'Advokatas' },
|
|
238
|
+
{ id: '4', label: 'Kita' },
|
|
239
|
+
]}
|
|
240
|
+
value={value}
|
|
241
|
+
onChange={(newValue) => setValue(newValue)}
|
|
242
|
+
size="small"
|
|
243
|
+
/>`,
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export const SmallWithDisabled = {
|
|
250
|
+
args: {
|
|
251
|
+
options: [
|
|
252
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
253
|
+
{ id: '2', label: 'Juridinis asmuo (Disabled)', disabled: true },
|
|
254
|
+
{ id: '3', label: 'Advokatas' },
|
|
255
|
+
],
|
|
256
|
+
value: '1',
|
|
257
|
+
size: 'small',
|
|
258
|
+
},
|
|
259
|
+
render: (args: any) => <DefaultComponent {...args} />,
|
|
260
|
+
parameters: {
|
|
261
|
+
docs: {
|
|
262
|
+
source: {
|
|
263
|
+
code: `const [value, setValue] = useState('1');
|
|
264
|
+
|
|
265
|
+
<RcSesSegmentedControl
|
|
266
|
+
options={[
|
|
267
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
268
|
+
{ id: '2', label: 'Juridinis asmuo', disabled: true },
|
|
269
|
+
{ id: '3', label: 'Advokatas' },
|
|
270
|
+
]}
|
|
271
|
+
value={value}
|
|
272
|
+
onChange={(newValue) => setValue(newValue)}
|
|
273
|
+
size="small"
|
|
274
|
+
/>`,
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export const RegularNoBackground = {
|
|
281
|
+
args: {
|
|
282
|
+
options: [
|
|
283
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
284
|
+
{ id: '2', label: 'Juridinis asmuo' },
|
|
285
|
+
{ id: '3', label: 'Advokatas' },
|
|
286
|
+
],
|
|
287
|
+
value: '1',
|
|
288
|
+
size: 'regular',
|
|
289
|
+
disableBg: true,
|
|
290
|
+
},
|
|
291
|
+
render: (args: any) => <DefaultComponent {...args} />,
|
|
292
|
+
parameters: {
|
|
293
|
+
docs: {
|
|
294
|
+
source: {
|
|
295
|
+
code: `const [value, setValue] = useState('1');
|
|
296
|
+
|
|
297
|
+
<RcSesSegmentedControl
|
|
298
|
+
options={[
|
|
299
|
+
{ id: '1', label: 'Fizinis asmuo' },
|
|
300
|
+
{ id: '2', label: 'Juridinis asmuo' },
|
|
301
|
+
{ id: '3', label: 'Advokatas' },
|
|
302
|
+
]}
|
|
303
|
+
value={value}
|
|
304
|
+
onChange={(newValue) => setValue(newValue)}
|
|
305
|
+
size="regular"
|
|
306
|
+
disableBg
|
|
307
|
+
/>`,
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
}
|