@registrucentras/rc-ses-react-components 1.11.0 → 1.13.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/README.md +5 -1
- package/dist/assets/icons/CaretUpBoldIcon.d.ts +3 -0
- package/dist/assets/icons/CaretUpIcon.d.ts +3 -0
- package/dist/assets/icons/ListIcon.d.ts +3 -0
- package/dist/assets/icons/MinusIcon.d.ts +3 -0
- package/dist/assets/icons/NotePencilIcon.d.ts +3 -0
- package/dist/assets/icons/PlusIcon.d.ts +3 -0
- package/dist/assets/icons/TrashIcon.d.ts +3 -0
- package/dist/assets/icons/UserIcon.d.ts +3 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/AdvancedListItem.types.d.ts +106 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.d.ts +12 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.d.ts +7 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/hooks/usePrefersReducedMotion.d.ts +2 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/index.d.ts +4 -0
- package/dist/components/common/AdvancedList/index.d.ts +11 -0
- package/dist/components/common/SelectableCardList/components/SelectableCardListItem.d.ts +4 -1
- package/dist/components/common/SelectableCardList/index.d.ts +4 -1
- package/dist/components/common/Tooltip/index.d.ts +20 -0
- package/dist/components/form/inputs/Select/index.d.ts +1 -0
- package/dist/library/icons.d.ts +9 -1
- package/dist/library/index.d.ts +5 -0
- package/dist/library/types.d.ts +2 -1
- package/dist/registrucentras-rc-ses-react-components.cjs +10 -10
- package/dist/registrucentras-rc-ses-react-components.js +4218 -3377
- package/dist/stories/components/display/AdvancedList.stories.d.ts +33 -0
- package/dist/stories/components/display/AdvancedListItem.stories.d.ts +33 -0
- package/dist/stories/components/display/SelectableCardList.stories.d.ts +8 -1
- package/dist/stories/components/display/Tooltip.stories.d.ts +48 -0
- package/dist/stories/components/loaders/LoadingSpinner.stories.d.ts +3 -3
- package/dist/theme/light/MuiTooltip.d.ts +3 -0
- package/dist/theme/motion.d.ts +16 -0
- package/package.json +1 -1
- package/src/assets/icons/CaretUpBoldIcon.tsx +17 -0
- package/src/assets/icons/CaretUpIcon.tsx +9 -0
- package/src/assets/icons/ListIcon.tsx +17 -0
- package/src/assets/icons/MinusIcon.tsx +9 -0
- package/src/assets/icons/NotePencilIcon.tsx +9 -0
- package/src/assets/icons/PlusIcon.tsx +9 -0
- package/src/assets/icons/TrashIcon.tsx +23 -0
- package/src/assets/icons/UserIcon.tsx +17 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/AdvancedListItem.types.ts +100 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.tsx +214 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.tsx +241 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/hooks/usePrefersReducedMotion.test.ts +80 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/hooks/usePrefersReducedMotion.ts +28 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/index.test.tsx +631 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/index.tsx +329 -0
- package/src/components/common/AdvancedList/index.test.tsx +97 -0
- package/src/components/common/AdvancedList/index.tsx +52 -0
- package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +7 -5
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.test.tsx +50 -0
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.tsx +34 -0
- package/src/components/common/SelectableCardList/index.test.tsx +56 -2
- package/src/components/common/SelectableCardList/index.tsx +29 -10
- package/src/components/common/Tooltip/index.test.tsx +85 -0
- package/src/components/common/Tooltip/index.tsx +167 -0
- package/src/components/form/inputs/FileDropzone.tsx +1 -0
- package/src/components/form/inputs/FileUpload.tsx +1 -0
- package/src/components/form/inputs/NumberStepper.tsx +1 -0
- package/src/components/form/inputs/RadioButtonGroup.test.tsx +71 -0
- package/src/components/form/inputs/RadioButtonGroup.tsx +1 -0
- package/src/components/form/inputs/Select/index.test.tsx +159 -0
- package/src/components/form/inputs/Select/index.tsx +109 -53
- package/src/i18n/namespaces/common/en.json +14 -0
- package/src/i18n/namespaces/common/lt.json +14 -0
- package/src/library/icons.ts +16 -0
- package/src/library/index.ts +5 -0
- package/src/library/types.ts +2 -0
- package/src/setupTests.ts +7 -1
- package/src/stories/components/display/AdvancedList.stories.tsx +660 -0
- package/src/stories/components/display/AdvancedListItem.stories.tsx +593 -0
- package/src/stories/components/display/SelectableCardList.stories.tsx +19 -0
- package/src/stories/components/display/Tooltip.stories.tsx +67 -0
- package/src/stories/components/inputs/Select.stories.tsx +38 -2
- package/src/theme/light/MuiAutocomplete.ts +3 -1
- package/src/theme/light/MuiInputBase.ts +4 -0
- package/src/theme/light/MuiTooltip.ts +40 -0
- package/src/theme/light/index.tsx +2 -0
- package/src/theme/motion.tsx +10 -0
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Avatar,
|
|
3
|
+
Box,
|
|
4
|
+
Checkbox,
|
|
5
|
+
FormControl,
|
|
6
|
+
FormControlLabel,
|
|
7
|
+
FormLabel,
|
|
8
|
+
Radio,
|
|
9
|
+
RadioGroup,
|
|
10
|
+
Stack,
|
|
11
|
+
TextField,
|
|
12
|
+
Typography,
|
|
13
|
+
} from '@mui/material'
|
|
14
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
15
|
+
import { useState } from 'react'
|
|
16
|
+
import { useForm } from 'react-hook-form'
|
|
17
|
+
|
|
18
|
+
import InfoFillIcon from '@/assets/icons/InfoFillIcon'
|
|
19
|
+
import NotePencilIcon from '@/assets/icons/NotePencilIcon'
|
|
20
|
+
import TrashIcon from '@/assets/icons/TrashIcon'
|
|
21
|
+
import UserIcon from '@/assets/icons/UserIcon'
|
|
22
|
+
import AdvancedList, { type AdvancedListItemData } from '@/components/common/AdvancedList'
|
|
23
|
+
import RcSesSelect from '@/components/form/inputs/Select'
|
|
24
|
+
|
|
25
|
+
const buildItems = (): AdvancedListItemData[] =>
|
|
26
|
+
Array.from({ length: 8 }, (_, index) => ({
|
|
27
|
+
id: `item-${index + 1}`,
|
|
28
|
+
title: `Service option ${index + 1}`,
|
|
29
|
+
subtitle: index % 2 === 0 ? 'Recommended for most users' : 'Alternative flow',
|
|
30
|
+
}))
|
|
31
|
+
|
|
32
|
+
const meta = {
|
|
33
|
+
title: 'components/display/AdvancedList',
|
|
34
|
+
component: AdvancedList,
|
|
35
|
+
tags: ['autodocs'],
|
|
36
|
+
args: {
|
|
37
|
+
items: buildItems(),
|
|
38
|
+
error: undefined,
|
|
39
|
+
},
|
|
40
|
+
argTypes: {
|
|
41
|
+
items: {
|
|
42
|
+
control: false,
|
|
43
|
+
},
|
|
44
|
+
error: {
|
|
45
|
+
control: false,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
} satisfies Meta<typeof AdvancedList>
|
|
49
|
+
|
|
50
|
+
export default meta
|
|
51
|
+
|
|
52
|
+
type Story = StoryObj<typeof meta>
|
|
53
|
+
|
|
54
|
+
const MainStory = () => {
|
|
55
|
+
const [selectedId, setSelectedId] = useState('item-1')
|
|
56
|
+
|
|
57
|
+
const items: AdvancedListItemData[] = buildItems().map((item) => ({
|
|
58
|
+
...item,
|
|
59
|
+
state: selectedId === item.id ? 'selected' : 'rest',
|
|
60
|
+
leading: {
|
|
61
|
+
type: 'radio',
|
|
62
|
+
name: 'service-option',
|
|
63
|
+
checked: selectedId === item.id,
|
|
64
|
+
onChange: () => setSelectedId(item.id),
|
|
65
|
+
},
|
|
66
|
+
}))
|
|
67
|
+
|
|
68
|
+
return <AdvancedList items={items} />
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const Main: Story = {
|
|
72
|
+
render: () => <MainStory />,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const Error: Story = {
|
|
76
|
+
args: {
|
|
77
|
+
error: 'Unable to load list items. Please try again.',
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const OWNER_TYPE_OPTIONS = [
|
|
82
|
+
{ id: 'owner-individual', title: 'Savininkas fizinis asmuo' },
|
|
83
|
+
{ id: 'owner-legal', title: 'Savininkas juridinis asmuo' },
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
const KitchenSinkStory = () => {
|
|
87
|
+
const [igaliotojaiChecked, setIgaliotojaiChecked] = useState(false)
|
|
88
|
+
const [signatoryToggle, setSignatoryToggle] = useState(false)
|
|
89
|
+
const [propertyChecked, setPropertyChecked] = useState(true)
|
|
90
|
+
|
|
91
|
+
const items: AdvancedListItemData[] = [
|
|
92
|
+
{
|
|
93
|
+
id: 'igaliotojai',
|
|
94
|
+
title: 'Jonas Jonaitis',
|
|
95
|
+
subtitle: 'a.k. 3850.........',
|
|
96
|
+
state: igaliotojaiChecked ? 'selected' : 'rest',
|
|
97
|
+
leadingMedia: <Avatar sx={{ width: '2rem', height: '2rem' }}>JJ</Avatar>,
|
|
98
|
+
leading: {
|
|
99
|
+
type: 'checkbox',
|
|
100
|
+
checked: igaliotojaiChecked,
|
|
101
|
+
onChange: setIgaliotojaiChecked,
|
|
102
|
+
},
|
|
103
|
+
trailing: {
|
|
104
|
+
type: 'actions',
|
|
105
|
+
actions: [
|
|
106
|
+
{ label: 'Keisti', icon: NotePencilIcon, onClick: () => {} },
|
|
107
|
+
{ label: 'Pašalinti', icon: TrashIcon, onClick: () => {} },
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 'ja-atstovai-redaguojama',
|
|
113
|
+
title: 'Petras Petraitis',
|
|
114
|
+
subtitle: 'Vadovas',
|
|
115
|
+
leading: { type: 'reorder', onMoveUp: () => {}, onMoveDown: () => {} },
|
|
116
|
+
trailing: {
|
|
117
|
+
type: 'toggle',
|
|
118
|
+
checked: signatoryToggle,
|
|
119
|
+
onChange: setSignatoryToggle,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: 'ja-atstovai-perziura',
|
|
124
|
+
title: 'Ona Onaitė',
|
|
125
|
+
subtitle: 'a.k. 3850.........',
|
|
126
|
+
trailing: { type: 'status', label: 'Laukiama parašo', color: 'warning' },
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 'pasirenkamas-sarasas',
|
|
130
|
+
title: 'Nekilnojamasis daiktas',
|
|
131
|
+
subtitle: 'Unikalus Nr. 4400.....',
|
|
132
|
+
state: propertyChecked ? 'selected' : 'rest',
|
|
133
|
+
leading: {
|
|
134
|
+
type: 'checkbox',
|
|
135
|
+
checked: propertyChecked,
|
|
136
|
+
onChange: setPropertyChecked,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: 'krepselis',
|
|
141
|
+
title: 'NTR išrašas (objekto)',
|
|
142
|
+
subtitle: 'Elektroninis dokumentas (PDF)',
|
|
143
|
+
trailing: { type: 'price', amount: '12,00 €', caption: 'su PVM' },
|
|
144
|
+
},
|
|
145
|
+
]
|
|
146
|
+
|
|
147
|
+
return <AdvancedList items={items} />
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export const KitchenSink: Story = {
|
|
151
|
+
name: 'Presetai: 5 realūs naudojimo atvejai',
|
|
152
|
+
render: () => <KitchenSinkStory />,
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const OwnerTypeExpandStory = () => {
|
|
156
|
+
const [ownerTypeId, setOwnerTypeId] = useState(OWNER_TYPE_OPTIONS[0].id)
|
|
157
|
+
const [declaration, setDeclaration] = useState('yes')
|
|
158
|
+
|
|
159
|
+
const items: AdvancedListItemData[] = OWNER_TYPE_OPTIONS.map((option) => ({
|
|
160
|
+
id: option.id,
|
|
161
|
+
title: option.title,
|
|
162
|
+
state: ownerTypeId === option.id ? 'selected' : 'rest',
|
|
163
|
+
leading: {
|
|
164
|
+
type: 'radio',
|
|
165
|
+
name: 'owner-type',
|
|
166
|
+
checked: ownerTypeId === option.id,
|
|
167
|
+
onChange: () => setOwnerTypeId(option.id),
|
|
168
|
+
},
|
|
169
|
+
expanded: ownerTypeId === option.id,
|
|
170
|
+
expandedContent:
|
|
171
|
+
option.id === 'owner-legal' ? (
|
|
172
|
+
<Stack gap={1.5}>
|
|
173
|
+
<TextField label='Įmonės pavadinimas' size='small' />
|
|
174
|
+
<TextField label='Įmonės kodas' size='small' />
|
|
175
|
+
<TextField label='Adresas' size='small' />
|
|
176
|
+
<FormControl>
|
|
177
|
+
<FormLabel id='declaration-label'>Deklaracija teikiama</FormLabel>
|
|
178
|
+
<RadioGroup
|
|
179
|
+
aria-labelledby='declaration-label'
|
|
180
|
+
value={declaration}
|
|
181
|
+
onChange={(e) => setDeclaration(e.target.value)}
|
|
182
|
+
>
|
|
183
|
+
<FormControlLabel value='yes' control={<Radio />} label='Taip' />
|
|
184
|
+
<FormControlLabel value='no' control={<Radio />} label='Ne' />
|
|
185
|
+
</RadioGroup>
|
|
186
|
+
</FormControl>
|
|
187
|
+
</Stack>
|
|
188
|
+
) : undefined,
|
|
189
|
+
}))
|
|
190
|
+
|
|
191
|
+
return <AdvancedList items={items} />
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export const OwnerTypeExpand: Story = {
|
|
195
|
+
name: 'Preset: savininko tipas (radio + expand)',
|
|
196
|
+
render: () => <OwnerTypeExpandStory />,
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
type OwnerBranchFormModel = {
|
|
200
|
+
individual: { municipality: string | null }
|
|
201
|
+
legalEntity: { legalForm: string | null }
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const MUNICIPALITY_OPTIONS = [
|
|
205
|
+
{ value: 'vilnius', label: 'Vilniaus m. sav.' },
|
|
206
|
+
{ value: 'kaunas', label: 'Kauno m. sav.' },
|
|
207
|
+
]
|
|
208
|
+
|
|
209
|
+
const LEGAL_FORM_OPTIONS = [
|
|
210
|
+
{ value: 'uab', label: 'UAB' },
|
|
211
|
+
{ value: 'mb', label: 'Mažoji bendrija' },
|
|
212
|
+
]
|
|
213
|
+
|
|
214
|
+
const PANEL_SX = {
|
|
215
|
+
backgroundColor: 'grey.100',
|
|
216
|
+
borderRadius: '.5rem',
|
|
217
|
+
fontSize: '.75rem',
|
|
218
|
+
m: 0,
|
|
219
|
+
overflowX: 'auto',
|
|
220
|
+
p: 1.5,
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const RadioBranchFormStory = () => {
|
|
224
|
+
const [ownerTypeId, setOwnerTypeId] = useState(OWNER_TYPE_OPTIONS[0].id)
|
|
225
|
+
const [shouldUnregister, setShouldUnregister] = useState(true)
|
|
226
|
+
|
|
227
|
+
const { control, watch } = useForm<OwnerBranchFormModel>({
|
|
228
|
+
defaultValues: {
|
|
229
|
+
individual: { municipality: null },
|
|
230
|
+
legalEntity: { legalForm: null },
|
|
231
|
+
},
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
const formState = watch()
|
|
235
|
+
|
|
236
|
+
// The non-selected branch stays in form state when shouldUnregister is off, so the
|
|
237
|
+
// submitted payload is built from the selected branch instead of the whole form.
|
|
238
|
+
const payload =
|
|
239
|
+
ownerTypeId === 'owner-legal'
|
|
240
|
+
? { legalEntity: formState.legalEntity }
|
|
241
|
+
: { individual: formState.individual }
|
|
242
|
+
|
|
243
|
+
// Only the selected branch renders its fields, so switching unmounts the other one -
|
|
244
|
+
// that unmount is what makes shouldUnregister observable.
|
|
245
|
+
const renderBranchFields = (optionId: string) => {
|
|
246
|
+
if (optionId !== ownerTypeId) return undefined
|
|
247
|
+
|
|
248
|
+
if (optionId === 'owner-legal') {
|
|
249
|
+
return (
|
|
250
|
+
<RcSesSelect
|
|
251
|
+
id='owner-branch-legal-form'
|
|
252
|
+
control={control}
|
|
253
|
+
name='legalEntity.legalForm'
|
|
254
|
+
label='Juridinio asmens forma'
|
|
255
|
+
options={LEGAL_FORM_OPTIONS}
|
|
256
|
+
slotProps={{ controller: { shouldUnregister } }}
|
|
257
|
+
/>
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return (
|
|
262
|
+
<RcSesSelect
|
|
263
|
+
id='owner-branch-municipality'
|
|
264
|
+
control={control}
|
|
265
|
+
name='individual.municipality'
|
|
266
|
+
label='Savivaldybė'
|
|
267
|
+
options={MUNICIPALITY_OPTIONS}
|
|
268
|
+
slotProps={{ controller: { shouldUnregister } }}
|
|
269
|
+
/>
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const items: AdvancedListItemData[] = OWNER_TYPE_OPTIONS.map((option) => ({
|
|
274
|
+
id: option.id,
|
|
275
|
+
title: option.title,
|
|
276
|
+
state: ownerTypeId === option.id ? 'selected' : 'rest',
|
|
277
|
+
leading: {
|
|
278
|
+
type: 'radio',
|
|
279
|
+
name: 'owner-branch-form',
|
|
280
|
+
checked: ownerTypeId === option.id,
|
|
281
|
+
onChange: () => setOwnerTypeId(option.id),
|
|
282
|
+
},
|
|
283
|
+
expanded: ownerTypeId === option.id,
|
|
284
|
+
expandedContent: renderBranchFields(option.id),
|
|
285
|
+
}))
|
|
286
|
+
|
|
287
|
+
return (
|
|
288
|
+
<Stack gap={2}>
|
|
289
|
+
<FormControlLabel
|
|
290
|
+
control={
|
|
291
|
+
<Checkbox
|
|
292
|
+
checked={shouldUnregister}
|
|
293
|
+
onChange={(event) => setShouldUnregister(event.target.checked)}
|
|
294
|
+
/>
|
|
295
|
+
}
|
|
296
|
+
label='slotProps.controller.shouldUnregister (bibliotekos numatytoji reikšmė - true)'
|
|
297
|
+
/>
|
|
298
|
+
|
|
299
|
+
<AdvancedList items={items} />
|
|
300
|
+
|
|
301
|
+
<Stack direction={{ xs: 'column', md: 'row' }} gap={2}>
|
|
302
|
+
<Box sx={{ flex: 1, minWidth: 0 }}>
|
|
303
|
+
<Typography variant='body2'>Formos būsena</Typography>
|
|
304
|
+
<Box component='pre' sx={PANEL_SX}>
|
|
305
|
+
{JSON.stringify(formState, null, 2)}
|
|
306
|
+
</Box>
|
|
307
|
+
</Box>
|
|
308
|
+
|
|
309
|
+
<Box sx={{ flex: 1, minWidth: 0 }}>
|
|
310
|
+
<Typography variant='body2'>Submit payload (tik pasirinkta šaka)</Typography>
|
|
311
|
+
<Box component='pre' sx={PANEL_SX}>
|
|
312
|
+
{JSON.stringify(payload, null, 2)}
|
|
313
|
+
</Box>
|
|
314
|
+
</Box>
|
|
315
|
+
</Stack>
|
|
316
|
+
</Stack>
|
|
317
|
+
)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export const RadioBranchForm: Story = {
|
|
321
|
+
name: 'Preset: radio šakos su react-hook-form',
|
|
322
|
+
render: () => <RadioBranchFormStory />,
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const FigmaAnatomyStory = () => {
|
|
326
|
+
const [selectedId, setSelectedId] = useState<string | null>(null)
|
|
327
|
+
|
|
328
|
+
const items: AdvancedListItemData[] = ['anatomy-1', 'anatomy-2', 'anatomy-3'].map(
|
|
329
|
+
(id) => ({
|
|
330
|
+
id,
|
|
331
|
+
title: 'Įrašo pavadinimas',
|
|
332
|
+
label: 'Label',
|
|
333
|
+
subtitle: 'a.k. 3850.........',
|
|
334
|
+
metaItems: [
|
|
335
|
+
{ icon: InfoFillIcon, text: 'Meta info 1' },
|
|
336
|
+
{ icon: InfoFillIcon, text: 'Meta info 2' },
|
|
337
|
+
{ icon: InfoFillIcon, text: 'Meta info 3' },
|
|
338
|
+
],
|
|
339
|
+
state: selectedId === id ? 'selected' : 'rest',
|
|
340
|
+
leading: {
|
|
341
|
+
type: 'radio',
|
|
342
|
+
name: 'anatomy-demo',
|
|
343
|
+
checked: selectedId === id,
|
|
344
|
+
onChange: () => setSelectedId(id),
|
|
345
|
+
},
|
|
346
|
+
trailing: {
|
|
347
|
+
type: 'actions',
|
|
348
|
+
actions: [
|
|
349
|
+
{ label: 'Keisti', icon: NotePencilIcon, onClick: () => {} },
|
|
350
|
+
{ label: 'Pašalinti', icon: TrashIcon, onClick: () => {} },
|
|
351
|
+
],
|
|
352
|
+
},
|
|
353
|
+
expanded: selectedId === id,
|
|
354
|
+
expandedContent: 'Išplėstas turinys — pakeiskite čia (pvz. JA atstovų sąrašas)',
|
|
355
|
+
}),
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
return <AdvancedList items={items} />
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export const FigmaAnatomy: Story = {
|
|
362
|
+
name: 'Anatomija: Leading × Trailing × Label × Meta × Expand',
|
|
363
|
+
render: () => <FigmaAnatomyStory />,
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const LeadingOptionsStory = () => {
|
|
367
|
+
const [checked, setChecked] = useState(false)
|
|
368
|
+
const [selected, setSelected] = useState(false)
|
|
369
|
+
|
|
370
|
+
const items: AdvancedListItemData[] = [
|
|
371
|
+
{
|
|
372
|
+
id: 'leading-none',
|
|
373
|
+
title: 'Nėra',
|
|
374
|
+
subtitle: 'Show-leading: nėra (leading praleistas)',
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
id: 'leading-reorder-both',
|
|
378
|
+
title: 'Reorder (abu)',
|
|
379
|
+
subtitle: 'Show-leading: reorder-both',
|
|
380
|
+
leading: { type: 'reorder', onMoveUp: () => {}, onMoveDown: () => {} },
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
id: 'leading-reorder-up',
|
|
384
|
+
title: 'Reorder (aukštyn)',
|
|
385
|
+
subtitle: 'Show-leading: reorder-up',
|
|
386
|
+
leading: { type: 'reorder', onMoveUp: () => {} },
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
id: 'leading-reorder-down',
|
|
390
|
+
title: 'Reorder (žemyn)',
|
|
391
|
+
subtitle: 'Show-leading: reorder-down',
|
|
392
|
+
leading: { type: 'reorder', onMoveDown: () => {} },
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
id: 'leading-checkbox',
|
|
396
|
+
title: 'Checkbox',
|
|
397
|
+
subtitle: 'Show-leading: checkbox',
|
|
398
|
+
leading: { type: 'checkbox', checked, onChange: setChecked },
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
id: 'leading-radio',
|
|
402
|
+
title: 'Radio',
|
|
403
|
+
subtitle: 'Show-leading: radio',
|
|
404
|
+
leading: { type: 'radio', checked: selected, onChange: setSelected },
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
id: 'leading-drag',
|
|
408
|
+
title: 'Drag',
|
|
409
|
+
subtitle: 'Show-leading: drag',
|
|
410
|
+
leading: { type: 'drag', 'aria-label': 'Vilkti ir pertvarkyti' },
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
id: 'leading-icon',
|
|
414
|
+
title: 'Icon',
|
|
415
|
+
subtitle: 'Show-leading: icon',
|
|
416
|
+
leading: { type: 'icon', icon: UserIcon, 'aria-label': 'Naudotojas' },
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
id: 'leading-avatar',
|
|
420
|
+
title: 'Avatar',
|
|
421
|
+
subtitle: 'Show-leading: avatar',
|
|
422
|
+
leading: { type: 'avatar', initials: 'JP' },
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
id: 'leading-index',
|
|
426
|
+
title: 'Index',
|
|
427
|
+
subtitle: 'Show-leading: index',
|
|
428
|
+
leading: { type: 'index', index: 1 },
|
|
429
|
+
},
|
|
430
|
+
]
|
|
431
|
+
|
|
432
|
+
return <AdvancedList items={items} />
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export const LeadingOptions: Story = {
|
|
436
|
+
name: 'Kitchen sink: visos Leading parinktys (paginuota)',
|
|
437
|
+
render: () => <LeadingOptionsStory />,
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const TrailingOptionsStory = () => {
|
|
441
|
+
const [toggleChecked, setToggleChecked] = useState(false)
|
|
442
|
+
const [checkboxChecked, setCheckboxChecked] = useState(false)
|
|
443
|
+
const [radioChecked, setRadioChecked] = useState(false)
|
|
444
|
+
const [stepperValue, setStepperValue] = useState(1)
|
|
445
|
+
|
|
446
|
+
const items: AdvancedListItemData[] = [
|
|
447
|
+
{
|
|
448
|
+
id: 'trailing-none',
|
|
449
|
+
title: 'Nėra',
|
|
450
|
+
subtitle: 'Show-trailing: nėra (trailing praleistas)',
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
id: 'trailing-actions',
|
|
454
|
+
title: 'Actions',
|
|
455
|
+
subtitle: 'Show-trailing: actions',
|
|
456
|
+
trailing: {
|
|
457
|
+
type: 'actions',
|
|
458
|
+
actions: [
|
|
459
|
+
{ label: 'Keisti', icon: NotePencilIcon, onClick: () => {} },
|
|
460
|
+
{ label: 'Pašalinti', icon: TrashIcon, onClick: () => {} },
|
|
461
|
+
],
|
|
462
|
+
},
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
id: 'trailing-toggle',
|
|
466
|
+
title: 'Toggle',
|
|
467
|
+
subtitle: 'Show-trailing: toggle',
|
|
468
|
+
trailing: { type: 'toggle', checked: toggleChecked, onChange: setToggleChecked },
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
id: 'trailing-status',
|
|
472
|
+
title: 'Status',
|
|
473
|
+
subtitle: 'Show-trailing: status',
|
|
474
|
+
trailing: { type: 'status', label: 'Laukiama parašo', color: 'warning' },
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
id: 'trailing-checkbox',
|
|
478
|
+
title: 'Checkbox',
|
|
479
|
+
subtitle: 'Show-trailing: checkbox',
|
|
480
|
+
trailing: {
|
|
481
|
+
type: 'checkbox',
|
|
482
|
+
checked: checkboxChecked,
|
|
483
|
+
onChange: setCheckboxChecked,
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
id: 'trailing-radio',
|
|
488
|
+
title: 'Radio',
|
|
489
|
+
subtitle: 'Show-trailing: radio',
|
|
490
|
+
trailing: { type: 'radio', checked: radioChecked, onChange: setRadioChecked },
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
id: 'trailing-chevron',
|
|
494
|
+
title: 'Chevron',
|
|
495
|
+
subtitle: 'Show-trailing: chevron',
|
|
496
|
+
trailing: { type: 'chevron' },
|
|
497
|
+
onClick: () => console.log('Chevron row clicked — navigate to details'),
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
id: 'trailing-price',
|
|
501
|
+
title: 'Price',
|
|
502
|
+
subtitle: 'Show-trailing: price',
|
|
503
|
+
trailing: { type: 'price', amount: '12,00 €', caption: 'su PVM' },
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
id: 'trailing-stepper',
|
|
507
|
+
title: 'Stepper',
|
|
508
|
+
subtitle: 'Show-trailing: stepper',
|
|
509
|
+
trailing: {
|
|
510
|
+
type: 'stepper',
|
|
511
|
+
value: stepperValue,
|
|
512
|
+
onChange: setStepperValue,
|
|
513
|
+
min: 0,
|
|
514
|
+
'aria-label': 'Kiekis',
|
|
515
|
+
},
|
|
516
|
+
},
|
|
517
|
+
]
|
|
518
|
+
|
|
519
|
+
return <AdvancedList items={items} />
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
export const TrailingOptions: Story = {
|
|
523
|
+
name: 'Kitchen sink: visos Trailing parinktys (paginuota)',
|
|
524
|
+
render: () => <TrailingOptionsStory />,
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
const STATE_VARIANTS = ['rest', 'selected', 'disabled', 'error'] as const
|
|
528
|
+
|
|
529
|
+
const StateShowcaseStory = () => {
|
|
530
|
+
const items: AdvancedListItemData[] = STATE_VARIANTS.map((state) => ({
|
|
531
|
+
id: `state-${state}`,
|
|
532
|
+
title: 'Pavyzdys',
|
|
533
|
+
state,
|
|
534
|
+
leading: { type: 'radio', checked: state === 'selected', onChange: () => {} },
|
|
535
|
+
trailing: {
|
|
536
|
+
type: 'actions',
|
|
537
|
+
actions: [
|
|
538
|
+
{ label: 'Keisti', icon: NotePencilIcon, onClick: () => {} },
|
|
539
|
+
{ label: 'Pašalinti', icon: TrashIcon, onClick: () => {} },
|
|
540
|
+
],
|
|
541
|
+
},
|
|
542
|
+
}))
|
|
543
|
+
|
|
544
|
+
return <AdvancedList items={items} />
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export const StateShowcase: Story = {
|
|
548
|
+
name: 'Kitchen sink: visi state (rest/selected/disabled/error)',
|
|
549
|
+
render: () => <StateShowcaseStory />,
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
const UNIVERSAL_PRESET_OPTIONS = [
|
|
553
|
+
{ id: 'with-name', title: 'Rodyti su asmens vardu, pavarde ir gimimo data' },
|
|
554
|
+
{
|
|
555
|
+
id: 'anonymised',
|
|
556
|
+
title: 'Nuasmenintas (be asmens vardo, pavardės, gimimo datos ir asmens kodo)',
|
|
557
|
+
},
|
|
558
|
+
]
|
|
559
|
+
|
|
560
|
+
const UniversalPresetListStory = () => {
|
|
561
|
+
const [selectedId, setSelectedId] = useState(UNIVERSAL_PRESET_OPTIONS[0].id)
|
|
562
|
+
|
|
563
|
+
const items: AdvancedListItemData[] = UNIVERSAL_PRESET_OPTIONS.map((option) => ({
|
|
564
|
+
...option,
|
|
565
|
+
state: selectedId === option.id ? 'selected' : 'rest',
|
|
566
|
+
leading: {
|
|
567
|
+
type: 'radio',
|
|
568
|
+
name: 'universal-preset',
|
|
569
|
+
checked: selectedId === option.id,
|
|
570
|
+
onChange: () => setSelectedId(option.id),
|
|
571
|
+
},
|
|
572
|
+
}))
|
|
573
|
+
|
|
574
|
+
return <AdvancedList items={items} />
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export const UniversalPresetList: Story = {
|
|
578
|
+
name: 'Preset: pasirenkamų radijo eilučių sąrašas (universalus)',
|
|
579
|
+
render: () => <UniversalPresetListStory />,
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
const PAYMENT_TILE_BANKS = [
|
|
583
|
+
{ id: 'swedbank', title: 'Swedbank', initials: 'SW' },
|
|
584
|
+
{ id: 'seb', title: 'SEB bankas', initials: 'SE' },
|
|
585
|
+
{ id: 'luminor', title: 'Luminor', initials: 'Lu' },
|
|
586
|
+
]
|
|
587
|
+
|
|
588
|
+
const PaymentTileListStory = () => {
|
|
589
|
+
const [paymentMethodId, setPaymentMethodId] = useState(PAYMENT_TILE_BANKS[0].id)
|
|
590
|
+
|
|
591
|
+
const items: AdvancedListItemData[] = PAYMENT_TILE_BANKS.map((bank) => ({
|
|
592
|
+
id: bank.id,
|
|
593
|
+
title: bank.title,
|
|
594
|
+
state: paymentMethodId === bank.id ? 'selected' : 'rest',
|
|
595
|
+
leadingMedia: (
|
|
596
|
+
<Avatar
|
|
597
|
+
variant='rounded'
|
|
598
|
+
sx={{ width: '2rem', height: '2rem', bgcolor: 'grey.200', color: 'grey.700' }}
|
|
599
|
+
>
|
|
600
|
+
{bank.initials}
|
|
601
|
+
</Avatar>
|
|
602
|
+
),
|
|
603
|
+
leading: {
|
|
604
|
+
type: 'radio',
|
|
605
|
+
name: 'payment-method',
|
|
606
|
+
checked: paymentMethodId === bank.id,
|
|
607
|
+
onChange: () => setPaymentMethodId(bank.id),
|
|
608
|
+
},
|
|
609
|
+
}))
|
|
610
|
+
|
|
611
|
+
return <AdvancedList items={items} />
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
export const PaymentTileList: Story = {
|
|
615
|
+
name: 'Preset: Payment tile (Card + Radio + Leading-media logo)',
|
|
616
|
+
render: () => <PaymentTileListStory />,
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
const CART_ITEMS_SOURCE = [
|
|
620
|
+
{
|
|
621
|
+
id: 'ntr-israsas',
|
|
622
|
+
title: 'NTR išrašas (objekto)',
|
|
623
|
+
subtitle: 'Reg. Nr. 4400-1234-5678',
|
|
624
|
+
amount: '12,00 €',
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
id: 'jar-israsas',
|
|
628
|
+
title: 'JAR išrašas',
|
|
629
|
+
subtitle: 'Įmonės kodas 300000000',
|
|
630
|
+
amount: '8,00 €',
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
id: 'kadastro-israsas',
|
|
634
|
+
title: 'Kadastro žemėlapio ištrauka',
|
|
635
|
+
subtitle: 'Reg. Nr. 4400-9876-5432',
|
|
636
|
+
amount: '5,00 €',
|
|
637
|
+
},
|
|
638
|
+
]
|
|
639
|
+
|
|
640
|
+
const CartWithDeleteListStory = () => {
|
|
641
|
+
const items: AdvancedListItemData[] = CART_ITEMS_SOURCE.map((item) => ({
|
|
642
|
+
id: item.id,
|
|
643
|
+
title: item.title,
|
|
644
|
+
subtitle: item.subtitle,
|
|
645
|
+
trailing: {
|
|
646
|
+
type: 'price',
|
|
647
|
+
amount: item.amount,
|
|
648
|
+
caption: 'su PVM',
|
|
649
|
+
onDelete: () => {},
|
|
650
|
+
deleteAriaLabel: `Pašalinti "${item.title}" iš krepšelio`,
|
|
651
|
+
},
|
|
652
|
+
}))
|
|
653
|
+
|
|
654
|
+
return <AdvancedList items={items} />
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
export const CartWithDeleteList: Story = {
|
|
658
|
+
name: 'Preset: Krepšelis (su trynimu)',
|
|
659
|
+
render: () => <CartWithDeleteListStory />,
|
|
660
|
+
}
|