@registrucentras/rc-ses-react-components 2.0.0-rc.0 → 2.0.0-rc.2
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/Button/index.d.ts +13 -3
- 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 +1 -1
- package/dist/registrucentras-rc-ses-react-components.js +4137 -3249
- package/dist/stories/components/actions/Button.stories.d.ts +4 -3
- 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/inputs/DatePicker.stories.d.ts +23 -0
- package/dist/stories/components/loaders/LoadingSpinner.stories.d.ts +3 -3
- package/dist/stories/components/overlays/Dialog.stories.d.ts +6 -0
- package/dist/stories/components/overlays/Popover.stories.d.ts +12 -0
- package/dist/stories/theme/ThemedMuiComponents.stories.d.ts +25 -0
- package/dist/theme/light/MuiTooltip.d.ts +3 -0
- package/dist/theme/motion.d.ts +16 -0
- package/package.json +2 -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 +228 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.tsx +270 -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 +340 -0
- package/src/components/common/AdvancedList/index.test.tsx +97 -0
- package/src/components/common/AdvancedList/index.tsx +52 -0
- package/src/components/common/Button/index.tsx +15 -1
- package/src/components/common/Card/index.tsx +2 -2
- 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 +168 -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/PhoneInputFormControl/index.tsx +1 -1
- 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 +107 -52
- package/src/components/layout/Footer/index.test.tsx +13 -0
- package/src/components/layout/Footer/index.tsx +5 -2
- 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 +653 -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/DatePicker.stories.tsx +36 -1
- package/src/stories/components/inputs/Select.stories.tsx +38 -2
- package/src/stories/components/overlays/Dialog.stories.tsx +34 -0
- package/src/stories/components/overlays/Popover.stories.tsx +65 -0
- package/src/stories/theme/ThemedMuiComponents.stories.tsx +177 -0
- 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,653 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Avatar,
|
|
3
|
+
FormControl,
|
|
4
|
+
FormControlLabel,
|
|
5
|
+
FormLabel,
|
|
6
|
+
Radio,
|
|
7
|
+
RadioGroup,
|
|
8
|
+
Stack,
|
|
9
|
+
TextField,
|
|
10
|
+
} from '@mui/material'
|
|
11
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
12
|
+
import { useState } from 'react'
|
|
13
|
+
|
|
14
|
+
import NotePencilIcon from '@/assets/icons/NotePencilIcon'
|
|
15
|
+
import TrashIcon from '@/assets/icons/TrashIcon'
|
|
16
|
+
import UserIcon from '@/assets/icons/UserIcon'
|
|
17
|
+
import AdvancedListItem from '@/components/common/AdvancedList/components/AdvancedListItem'
|
|
18
|
+
|
|
19
|
+
const meta = {
|
|
20
|
+
title: 'components/display/AdvancedListItem',
|
|
21
|
+
component: AdvancedListItem,
|
|
22
|
+
tags: ['autodocs'],
|
|
23
|
+
args: {
|
|
24
|
+
title: 'Įrašo pavadinimas',
|
|
25
|
+
subtitle: 'a.k. 3850.........',
|
|
26
|
+
state: 'rest',
|
|
27
|
+
},
|
|
28
|
+
} satisfies Meta<typeof AdvancedListItem>
|
|
29
|
+
|
|
30
|
+
export default meta
|
|
31
|
+
|
|
32
|
+
type Story = StoryObj<typeof meta>
|
|
33
|
+
|
|
34
|
+
export const Main: Story = {}
|
|
35
|
+
|
|
36
|
+
export const Selected: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
state: 'selected',
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const Disabled: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
state: 'disabled',
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const ErrorState: Story = {
|
|
49
|
+
args: {
|
|
50
|
+
state: 'error',
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const IgaliotojaiPreset: Story = {
|
|
55
|
+
name: 'Preset: Įgaliotojai (reorder + actions)',
|
|
56
|
+
render: () => (
|
|
57
|
+
<AdvancedListItem
|
|
58
|
+
title='Jonas Jonaitis'
|
|
59
|
+
subtitle='a.k. 3850.........'
|
|
60
|
+
leading={{ type: 'reorder', onMoveUp: () => {}, onMoveDown: () => {} }}
|
|
61
|
+
trailing={{
|
|
62
|
+
type: 'actions',
|
|
63
|
+
actions: [
|
|
64
|
+
{ label: 'Keisti', icon: NotePencilIcon, onClick: () => {} },
|
|
65
|
+
{ label: 'Pašalinti', icon: TrashIcon, onClick: () => {} },
|
|
66
|
+
],
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
69
|
+
),
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const JaAtstovaiRedaguojamaStory = () => {
|
|
73
|
+
const [checked, setChecked] = useState(false)
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<AdvancedListItem
|
|
77
|
+
title='Petras Petraitis'
|
|
78
|
+
subtitle='Vadovas'
|
|
79
|
+
leading={{ type: 'reorder', onMoveUp: () => {}, onMoveDown: () => {} }}
|
|
80
|
+
trailing={{ type: 'toggle', checked, onChange: setChecked }}
|
|
81
|
+
/>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const JaAtstovaiRedaguojamaPreset: Story = {
|
|
86
|
+
name: 'Preset: JA atstovai redaguojama (reorder + toggle)',
|
|
87
|
+
render: () => <JaAtstovaiRedaguojamaStory />,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const JaAtstovaiPerziuraPreset: Story = {
|
|
91
|
+
name: 'Preset: JA atstovai peržiūra (status badge)',
|
|
92
|
+
render: () => (
|
|
93
|
+
<AdvancedListItem
|
|
94
|
+
title='Ona Onaitė'
|
|
95
|
+
subtitle='a.k. 3850.........'
|
|
96
|
+
trailing={{ type: 'status', label: 'Laukiama parašo', color: 'warning' }}
|
|
97
|
+
/>
|
|
98
|
+
),
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const PasirenkamasSarasasStory = () => {
|
|
102
|
+
const [checked, setChecked] = useState(true)
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<AdvancedListItem
|
|
106
|
+
title='Nekilnojamasis daiktas'
|
|
107
|
+
subtitle='Unikalus Nr. 4400.....'
|
|
108
|
+
state={checked ? 'selected' : 'rest'}
|
|
109
|
+
leading={{ type: 'checkbox', checked, onChange: setChecked }}
|
|
110
|
+
/>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export const PasirenkamasSarasasPreset: Story = {
|
|
115
|
+
name: 'Preset: Pasirenkamas sąrašas (checkbox, selected)',
|
|
116
|
+
render: () => <PasirenkamasSarasasStory />,
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const PEOPLE_LIST_ITEMS = [
|
|
120
|
+
{ id: 'rep-1', title: 'Petras Petraitis', subtitle: 'Vadovas', initials: 'PP' },
|
|
121
|
+
{ id: 'rep-2', title: 'Ona Onaitė', subtitle: 'Prokuristė', initials: 'OO' },
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
const LeadingMediaStory = () => {
|
|
125
|
+
const [checkedIds, setCheckedIds] = useState<string[]>(['rep-1'])
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<Stack
|
|
129
|
+
sx={{
|
|
130
|
+
gap: 1,
|
|
131
|
+
width: '100%',
|
|
132
|
+
maxWidth: '32rem',
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
{PEOPLE_LIST_ITEMS.map((item) => {
|
|
136
|
+
const checked = checkedIds.includes(item.id)
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<AdvancedListItem
|
|
140
|
+
key={item.id}
|
|
141
|
+
title={item.title}
|
|
142
|
+
subtitle={item.subtitle}
|
|
143
|
+
state={checked ? 'selected' : 'rest'}
|
|
144
|
+
leadingMedia={
|
|
145
|
+
<Avatar sx={{ width: '2rem', height: '2rem' }}>{item.initials}</Avatar>
|
|
146
|
+
}
|
|
147
|
+
leading={{
|
|
148
|
+
type: 'checkbox',
|
|
149
|
+
checked,
|
|
150
|
+
onChange: (next) =>
|
|
151
|
+
setCheckedIds((prev) =>
|
|
152
|
+
next ? [...prev, item.id] : prev.filter((id) => id !== item.id),
|
|
153
|
+
),
|
|
154
|
+
}}
|
|
155
|
+
/>
|
|
156
|
+
)
|
|
157
|
+
})}
|
|
158
|
+
</Stack>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export const CheckboxWithLeadingMedia: Story = {
|
|
163
|
+
name: 'Leading-media: avatar + checkbox people list',
|
|
164
|
+
render: () => <LeadingMediaStory />,
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export const KrepselisPreset: Story = {
|
|
168
|
+
name: 'Preset: Krepšelis (price)',
|
|
169
|
+
render: () => (
|
|
170
|
+
<AdvancedListItem
|
|
171
|
+
title='NTR išrašas (objekto)'
|
|
172
|
+
subtitle='Elektroninis dokumentas (PDF)'
|
|
173
|
+
trailing={{ type: 'price', amount: '12,00 €', caption: 'su PVM' }}
|
|
174
|
+
/>
|
|
175
|
+
),
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const OWNER_OPTIONS = [
|
|
179
|
+
{ id: 'owner-individual', title: 'Savininkas fizinis asmuo' },
|
|
180
|
+
{ id: 'owner-legal', title: 'Savininkas juridinis asmuo' },
|
|
181
|
+
]
|
|
182
|
+
|
|
183
|
+
const RadioExpandStory = () => {
|
|
184
|
+
const [ownerId, setOwnerId] = useState(OWNER_OPTIONS[0].id)
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<Stack
|
|
188
|
+
sx={{
|
|
189
|
+
gap: 1,
|
|
190
|
+
width: '100%',
|
|
191
|
+
maxWidth: '32rem',
|
|
192
|
+
}}
|
|
193
|
+
>
|
|
194
|
+
{OWNER_OPTIONS.map((option) => (
|
|
195
|
+
<AdvancedListItem
|
|
196
|
+
key={option.id}
|
|
197
|
+
title={option.title}
|
|
198
|
+
state={ownerId === option.id ? 'selected' : 'rest'}
|
|
199
|
+
leading={{
|
|
200
|
+
type: 'radio',
|
|
201
|
+
name: 'owner-type',
|
|
202
|
+
checked: ownerId === option.id,
|
|
203
|
+
onChange: () => setOwnerId(option.id),
|
|
204
|
+
}}
|
|
205
|
+
expanded={ownerId === option.id}
|
|
206
|
+
expandedContent={
|
|
207
|
+
option.id === 'owner-legal' ? (
|
|
208
|
+
<Stack
|
|
209
|
+
sx={{
|
|
210
|
+
gap: 1.5,
|
|
211
|
+
}}
|
|
212
|
+
>
|
|
213
|
+
<TextField label='Įmonės pavadinimas' size='small' />
|
|
214
|
+
<TextField label='Įmonės kodas' size='small' />
|
|
215
|
+
<TextField label='Adresas' size='small' />
|
|
216
|
+
</Stack>
|
|
217
|
+
) : undefined
|
|
218
|
+
}
|
|
219
|
+
/>
|
|
220
|
+
))}
|
|
221
|
+
</Stack>
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export const RadioExpand: Story = {
|
|
226
|
+
name: 'GRM-12030: radio-expand (only one open at a time)',
|
|
227
|
+
render: () => <RadioExpandStory />,
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const CHECKBOX_EXPAND_ITEMS = [
|
|
231
|
+
{ id: 'rep-1', title: 'Petras Petraitis', subtitle: 'Vadovas' },
|
|
232
|
+
{ id: 'rep-2', title: 'Ona Onaitė', subtitle: 'Prokuristė' },
|
|
233
|
+
]
|
|
234
|
+
|
|
235
|
+
const CheckboxExpandStory = () => {
|
|
236
|
+
const [checkedIds, setCheckedIds] = useState<string[]>(['rep-1'])
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<Stack
|
|
240
|
+
sx={{
|
|
241
|
+
gap: 1,
|
|
242
|
+
width: '100%',
|
|
243
|
+
maxWidth: '32rem',
|
|
244
|
+
}}
|
|
245
|
+
>
|
|
246
|
+
{CHECKBOX_EXPAND_ITEMS.map((item) => {
|
|
247
|
+
const checked = checkedIds.includes(item.id)
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<AdvancedListItem
|
|
251
|
+
key={item.id}
|
|
252
|
+
title={item.title}
|
|
253
|
+
subtitle={item.subtitle}
|
|
254
|
+
state={checked ? 'selected' : 'rest'}
|
|
255
|
+
leading={{
|
|
256
|
+
type: 'checkbox',
|
|
257
|
+
checked,
|
|
258
|
+
onChange: (next) =>
|
|
259
|
+
setCheckedIds((prev) =>
|
|
260
|
+
next ? [...prev, item.id] : prev.filter((id) => id !== item.id),
|
|
261
|
+
),
|
|
262
|
+
}}
|
|
263
|
+
expanded={checked}
|
|
264
|
+
expandedContent={<TextField label='Kontaktinis el. paštas' size='small' />}
|
|
265
|
+
/>
|
|
266
|
+
)
|
|
267
|
+
})}
|
|
268
|
+
</Stack>
|
|
269
|
+
)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export const CheckboxExpand: Story = {
|
|
273
|
+
name: 'GRM-12030: checkbox-expand (several open independently)',
|
|
274
|
+
render: () => <CheckboxExpandStory />,
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const NestedRadioGroupStory = () => {
|
|
278
|
+
const [checked, setChecked] = useState(true)
|
|
279
|
+
const [declaration, setDeclaration] = useState('yes')
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<AdvancedListItem
|
|
283
|
+
title='Savininkas juridinis asmuo'
|
|
284
|
+
state={checked ? 'selected' : 'rest'}
|
|
285
|
+
leading={{ type: 'radio', checked, onChange: setChecked }}
|
|
286
|
+
expanded={checked}
|
|
287
|
+
expandedContent={
|
|
288
|
+
<Stack
|
|
289
|
+
sx={{
|
|
290
|
+
gap: 1.5,
|
|
291
|
+
}}
|
|
292
|
+
>
|
|
293
|
+
<TextField label='Įmonės pavadinimas' size='small' />
|
|
294
|
+
<TextField label='Adresas' size='small' />
|
|
295
|
+
<FormControl>
|
|
296
|
+
<FormLabel id='declaration-label'>Deklaracija teikiama</FormLabel>
|
|
297
|
+
<RadioGroup
|
|
298
|
+
aria-labelledby='declaration-label'
|
|
299
|
+
value={declaration}
|
|
300
|
+
onChange={(e) => setDeclaration(e.target.value)}
|
|
301
|
+
>
|
|
302
|
+
<FormControlLabel value='yes' control={<Radio />} label='Taip' />
|
|
303
|
+
<FormControlLabel value='no' control={<Radio />} label='Ne' />
|
|
304
|
+
</RadioGroup>
|
|
305
|
+
</FormControl>
|
|
306
|
+
</Stack>
|
|
307
|
+
}
|
|
308
|
+
/>
|
|
309
|
+
)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export const NestedRadioGroup: Story = {
|
|
313
|
+
name: 'GRM-12030: nested radio group inside expanded content',
|
|
314
|
+
render: () => <NestedRadioGroupStory />,
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const LongExpandedContentStory = () => {
|
|
318
|
+
const [checked, setChecked] = useState(true)
|
|
319
|
+
|
|
320
|
+
return (
|
|
321
|
+
<AdvancedListItem
|
|
322
|
+
title='Nekilnojamasis daiktas su ilgu turiniu'
|
|
323
|
+
state={checked ? 'selected' : 'rest'}
|
|
324
|
+
leading={{ type: 'checkbox', checked, onChange: setChecked }}
|
|
325
|
+
expanded={checked}
|
|
326
|
+
expandedContent={
|
|
327
|
+
<Stack
|
|
328
|
+
sx={{
|
|
329
|
+
gap: 1.5,
|
|
330
|
+
}}
|
|
331
|
+
>
|
|
332
|
+
{Array.from({ length: 10 }).map((_, index) => (
|
|
333
|
+
<TextField
|
|
334
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
335
|
+
key={index}
|
|
336
|
+
label={`Laukas ${index + 1}`}
|
|
337
|
+
size='small'
|
|
338
|
+
/>
|
|
339
|
+
))}
|
|
340
|
+
</Stack>
|
|
341
|
+
}
|
|
342
|
+
/>
|
|
343
|
+
)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export const LongExpandedContent: Story = {
|
|
347
|
+
name: 'GRM-12030: long expanded content (no internal scroll)',
|
|
348
|
+
render: () => <LongExpandedContentStory />,
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const TrailingShowcaseStory = () => {
|
|
352
|
+
const [toggleChecked, setToggleChecked] = useState(false)
|
|
353
|
+
const [checkboxChecked, setCheckboxChecked] = useState(false)
|
|
354
|
+
const [radioChecked, setRadioChecked] = useState(false)
|
|
355
|
+
const [stepperValue, setStepperValue] = useState(1)
|
|
356
|
+
|
|
357
|
+
return (
|
|
358
|
+
<Stack
|
|
359
|
+
sx={{
|
|
360
|
+
gap: 1,
|
|
361
|
+
width: '100%',
|
|
362
|
+
maxWidth: '32rem',
|
|
363
|
+
}}
|
|
364
|
+
>
|
|
365
|
+
<AdvancedListItem
|
|
366
|
+
title='Nėra'
|
|
367
|
+
subtitle='Show-trailing: nėra (trailing praleistas)'
|
|
368
|
+
/>
|
|
369
|
+
<AdvancedListItem
|
|
370
|
+
title='Actions'
|
|
371
|
+
subtitle='Show-trailing: actions'
|
|
372
|
+
trailing={{
|
|
373
|
+
type: 'actions',
|
|
374
|
+
actions: [
|
|
375
|
+
{ label: 'Keisti', icon: NotePencilIcon, onClick: () => {} },
|
|
376
|
+
{ label: 'Pašalinti', icon: TrashIcon, onClick: () => {} },
|
|
377
|
+
],
|
|
378
|
+
}}
|
|
379
|
+
/>
|
|
380
|
+
<AdvancedListItem
|
|
381
|
+
title='Toggle'
|
|
382
|
+
subtitle='Show-trailing: toggle'
|
|
383
|
+
trailing={{ type: 'toggle', checked: toggleChecked, onChange: setToggleChecked }}
|
|
384
|
+
/>
|
|
385
|
+
<AdvancedListItem
|
|
386
|
+
title='Status'
|
|
387
|
+
subtitle='Show-trailing: status'
|
|
388
|
+
trailing={{ type: 'status', label: 'Laukiama parašo', color: 'warning' }}
|
|
389
|
+
/>
|
|
390
|
+
<AdvancedListItem
|
|
391
|
+
title='Checkbox'
|
|
392
|
+
subtitle='Show-trailing: checkbox'
|
|
393
|
+
trailing={{
|
|
394
|
+
type: 'checkbox',
|
|
395
|
+
checked: checkboxChecked,
|
|
396
|
+
onChange: setCheckboxChecked,
|
|
397
|
+
}}
|
|
398
|
+
/>
|
|
399
|
+
<AdvancedListItem
|
|
400
|
+
title='Radio'
|
|
401
|
+
subtitle='Show-trailing: radio'
|
|
402
|
+
trailing={{ type: 'radio', checked: radioChecked, onChange: setRadioChecked }}
|
|
403
|
+
/>
|
|
404
|
+
<AdvancedListItem
|
|
405
|
+
title='Chevron'
|
|
406
|
+
subtitle='Show-trailing: chevron'
|
|
407
|
+
trailing={{ type: 'chevron' }}
|
|
408
|
+
onClick={() => console.log('Chevron row clicked — navigate to details')}
|
|
409
|
+
/>
|
|
410
|
+
<AdvancedListItem
|
|
411
|
+
title='Price'
|
|
412
|
+
subtitle='Show-trailing: price'
|
|
413
|
+
trailing={{ type: 'price', amount: '12,00 €', caption: 'su PVM' }}
|
|
414
|
+
/>
|
|
415
|
+
<AdvancedListItem
|
|
416
|
+
title='Stepper'
|
|
417
|
+
subtitle='Show-trailing: stepper'
|
|
418
|
+
trailing={{
|
|
419
|
+
type: 'stepper',
|
|
420
|
+
value: stepperValue,
|
|
421
|
+
onChange: setStepperValue,
|
|
422
|
+
min: 0,
|
|
423
|
+
}}
|
|
424
|
+
/>
|
|
425
|
+
<AdvancedListItem
|
|
426
|
+
title='Price (su Pašalinti)'
|
|
427
|
+
subtitle='Show-trailing: price + onDelete'
|
|
428
|
+
trailing={{
|
|
429
|
+
type: 'price',
|
|
430
|
+
amount: '12,00 €',
|
|
431
|
+
caption: 'su PVM',
|
|
432
|
+
onDelete: () => {},
|
|
433
|
+
}}
|
|
434
|
+
/>
|
|
435
|
+
</Stack>
|
|
436
|
+
)
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export const TrailingShowcase: Story = {
|
|
440
|
+
name: 'Preset: Show-trailing (visos trailing reikšmės)',
|
|
441
|
+
render: () => <TrailingShowcaseStory />,
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const LeadingShowcaseStory = () => {
|
|
445
|
+
const [checked, setChecked] = useState(false)
|
|
446
|
+
const [selected, setSelected] = useState(false)
|
|
447
|
+
|
|
448
|
+
return (
|
|
449
|
+
<Stack
|
|
450
|
+
sx={{
|
|
451
|
+
gap: 1,
|
|
452
|
+
width: '100%',
|
|
453
|
+
maxWidth: '32rem',
|
|
454
|
+
}}
|
|
455
|
+
>
|
|
456
|
+
<AdvancedListItem title='Nėra' subtitle='Show-leading: nėra (leading praleistas)' />
|
|
457
|
+
<AdvancedListItem
|
|
458
|
+
title='Reorder (abu)'
|
|
459
|
+
subtitle='Show-leading: reorder-both'
|
|
460
|
+
leading={{ type: 'reorder', onMoveUp: () => {}, onMoveDown: () => {} }}
|
|
461
|
+
/>
|
|
462
|
+
<AdvancedListItem
|
|
463
|
+
title='Reorder (aukštyn)'
|
|
464
|
+
subtitle='Show-leading: reorder-up'
|
|
465
|
+
leading={{ type: 'reorder', onMoveUp: () => {} }}
|
|
466
|
+
/>
|
|
467
|
+
<AdvancedListItem
|
|
468
|
+
title='Reorder (žemyn)'
|
|
469
|
+
subtitle='Show-leading: reorder-down'
|
|
470
|
+
leading={{ type: 'reorder', onMoveDown: () => {} }}
|
|
471
|
+
/>
|
|
472
|
+
<AdvancedListItem
|
|
473
|
+
title='Checkbox'
|
|
474
|
+
subtitle='Show-leading: checkbox'
|
|
475
|
+
leading={{ type: 'checkbox', checked, onChange: setChecked }}
|
|
476
|
+
/>
|
|
477
|
+
<AdvancedListItem
|
|
478
|
+
title='Radio'
|
|
479
|
+
subtitle='Show-leading: radio'
|
|
480
|
+
leading={{ type: 'radio', checked: selected, onChange: setSelected }}
|
|
481
|
+
/>
|
|
482
|
+
<AdvancedListItem
|
|
483
|
+
title='Drag'
|
|
484
|
+
subtitle='Show-leading: drag'
|
|
485
|
+
leading={{ type: 'drag', 'aria-label': 'Vilkti ir pertvarkyti' }}
|
|
486
|
+
/>
|
|
487
|
+
<AdvancedListItem
|
|
488
|
+
title='Icon'
|
|
489
|
+
subtitle='Show-leading: icon'
|
|
490
|
+
leading={{ type: 'icon', icon: UserIcon, 'aria-label': 'Naudotojas' }}
|
|
491
|
+
/>
|
|
492
|
+
<AdvancedListItem
|
|
493
|
+
title='Avatar'
|
|
494
|
+
subtitle='Show-leading: avatar'
|
|
495
|
+
leading={{ type: 'avatar', initials: 'JP' }}
|
|
496
|
+
/>
|
|
497
|
+
<AdvancedListItem
|
|
498
|
+
title='Index'
|
|
499
|
+
subtitle='Show-leading: index'
|
|
500
|
+
leading={{ type: 'index', index: 1 }}
|
|
501
|
+
/>
|
|
502
|
+
</Stack>
|
|
503
|
+
)
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export const LeadingShowcase: Story = {
|
|
507
|
+
name: 'Preset: Show-leading (visos leading reikšmės)',
|
|
508
|
+
render: () => <LeadingShowcaseStory />,
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
const UNIVERSAL_PRESET_OPTIONS = [
|
|
512
|
+
{ id: 'with-name', title: 'Rodyti su asmens vardu, pavarde ir gimimo data' },
|
|
513
|
+
{
|
|
514
|
+
id: 'anonymised',
|
|
515
|
+
title: 'Nuasmenintas (be asmens vardo, pavardės, gimimo datos ir asmens kodo)',
|
|
516
|
+
},
|
|
517
|
+
]
|
|
518
|
+
|
|
519
|
+
const UniversalPresetStory = () => {
|
|
520
|
+
const [selectedId, setSelectedId] = useState(UNIVERSAL_PRESET_OPTIONS[0].id)
|
|
521
|
+
|
|
522
|
+
return (
|
|
523
|
+
<Stack
|
|
524
|
+
sx={{
|
|
525
|
+
gap: 1,
|
|
526
|
+
width: '100%',
|
|
527
|
+
maxWidth: '32rem',
|
|
528
|
+
}}
|
|
529
|
+
>
|
|
530
|
+
{UNIVERSAL_PRESET_OPTIONS.map((option) => (
|
|
531
|
+
<AdvancedListItem
|
|
532
|
+
key={option.id}
|
|
533
|
+
title={option.title}
|
|
534
|
+
state={selectedId === option.id ? 'selected' : 'rest'}
|
|
535
|
+
leading={{
|
|
536
|
+
type: 'radio',
|
|
537
|
+
name: 'universal-preset',
|
|
538
|
+
checked: selectedId === option.id,
|
|
539
|
+
onChange: () => setSelectedId(option.id),
|
|
540
|
+
}}
|
|
541
|
+
/>
|
|
542
|
+
))}
|
|
543
|
+
</Stack>
|
|
544
|
+
)
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export const UniversalPreset: Story = {
|
|
548
|
+
name: 'Preset: pasirenkamų radijo eilučių sąrašas (universalus)',
|
|
549
|
+
render: () => <UniversalPresetStory />,
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
const PAYMENT_TILE_BANKS = [
|
|
553
|
+
{ id: 'swedbank', title: 'Swedbank', initials: 'SW' },
|
|
554
|
+
{ id: 'seb', title: 'SEB bankas', initials: 'SE' },
|
|
555
|
+
{ id: 'luminor', title: 'Luminor', initials: 'Lu' },
|
|
556
|
+
]
|
|
557
|
+
|
|
558
|
+
const PaymentTileStory = () => {
|
|
559
|
+
const [selectedId, setSelectedId] = useState(PAYMENT_TILE_BANKS[0].id)
|
|
560
|
+
|
|
561
|
+
return (
|
|
562
|
+
<Stack
|
|
563
|
+
sx={{
|
|
564
|
+
gap: 1,
|
|
565
|
+
width: '100%',
|
|
566
|
+
maxWidth: '32rem',
|
|
567
|
+
}}
|
|
568
|
+
>
|
|
569
|
+
{PAYMENT_TILE_BANKS.map((bank) => (
|
|
570
|
+
<AdvancedListItem
|
|
571
|
+
key={bank.id}
|
|
572
|
+
title={bank.title}
|
|
573
|
+
state={selectedId === bank.id ? 'selected' : 'rest'}
|
|
574
|
+
leadingMedia={
|
|
575
|
+
<Avatar
|
|
576
|
+
variant='rounded'
|
|
577
|
+
sx={{
|
|
578
|
+
width: '2rem',
|
|
579
|
+
height: '2rem',
|
|
580
|
+
bgcolor: 'grey.200',
|
|
581
|
+
color: 'grey.700',
|
|
582
|
+
}}
|
|
583
|
+
>
|
|
584
|
+
{bank.initials}
|
|
585
|
+
</Avatar>
|
|
586
|
+
}
|
|
587
|
+
leading={{
|
|
588
|
+
type: 'radio',
|
|
589
|
+
name: 'payment-method',
|
|
590
|
+
checked: selectedId === bank.id,
|
|
591
|
+
onChange: () => setSelectedId(bank.id),
|
|
592
|
+
}}
|
|
593
|
+
/>
|
|
594
|
+
))}
|
|
595
|
+
</Stack>
|
|
596
|
+
)
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
export const PaymentTilePreset: Story = {
|
|
600
|
+
name: 'Preset: Payment tile (Card + Radio + Leading-media logo)',
|
|
601
|
+
render: () => <PaymentTileStory />,
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
const KREPSELIS_ITEMS = [
|
|
605
|
+
{
|
|
606
|
+
id: 'ntr-israsas',
|
|
607
|
+
title: 'NTR išrašas (objekto)',
|
|
608
|
+
subtitle: 'Reg. Nr. 4400-1234-5678',
|
|
609
|
+
amount: '12,00 €',
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
id: 'jar-israsas',
|
|
613
|
+
title: 'JAR išrašas',
|
|
614
|
+
subtitle: 'Įmonės kodas 300000000',
|
|
615
|
+
amount: '8,00 €',
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
id: 'kadastro-israsas',
|
|
619
|
+
title: 'Kadastro žemėlapio ištrauka',
|
|
620
|
+
subtitle: 'Reg. Nr. 4400-9876-5432',
|
|
621
|
+
amount: '5,00 €',
|
|
622
|
+
},
|
|
623
|
+
]
|
|
624
|
+
|
|
625
|
+
const KrepselisWithDeleteStory = () => (
|
|
626
|
+
<Stack
|
|
627
|
+
sx={{
|
|
628
|
+
gap: 1,
|
|
629
|
+
width: '100%',
|
|
630
|
+
maxWidth: '32rem',
|
|
631
|
+
}}
|
|
632
|
+
>
|
|
633
|
+
{KREPSELIS_ITEMS.map((item) => (
|
|
634
|
+
<AdvancedListItem
|
|
635
|
+
key={item.id}
|
|
636
|
+
title={item.title}
|
|
637
|
+
subtitle={item.subtitle}
|
|
638
|
+
trailing={{
|
|
639
|
+
type: 'price',
|
|
640
|
+
amount: item.amount,
|
|
641
|
+
caption: 'su PVM',
|
|
642
|
+
onDelete: () => {},
|
|
643
|
+
deleteAriaLabel: `Pašalinti "${item.title}" iš krepšelio`,
|
|
644
|
+
}}
|
|
645
|
+
/>
|
|
646
|
+
))}
|
|
647
|
+
</Stack>
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
export const KrepselisWithDeletePreset: Story = {
|
|
651
|
+
name: 'Preset: Krepšelis (su trynimu)',
|
|
652
|
+
render: () => <KrepselisWithDeleteStory />,
|
|
653
|
+
}
|
|
@@ -49,12 +49,23 @@ const buildItems = (): SelectableCardListItemData[] =>
|
|
|
49
49
|
title: `Service option ${index + 1}`,
|
|
50
50
|
subtitle: index % 2 === 0 ? 'Recommended for most users' : 'Alternative flow',
|
|
51
51
|
listItems: getListItems(index),
|
|
52
|
+
hasActionButton: index === 0,
|
|
53
|
+
actionButtonLabel: 'Action',
|
|
54
|
+
onActionButtonClick: () => {},
|
|
52
55
|
}))
|
|
53
56
|
|
|
54
57
|
const meta = {
|
|
55
58
|
title: 'components/display/SelectableCardList',
|
|
56
59
|
component: SelectableCardList,
|
|
57
60
|
tags: ['autodocs'],
|
|
61
|
+
parameters: {
|
|
62
|
+
docs: {
|
|
63
|
+
description: {
|
|
64
|
+
component:
|
|
65
|
+
'Paginates items client-side, showing 5 per page on desktop and 3 per page on mobile (below the `md` breakpoint). The page resets to 1 whenever the page size changes, e.g. when resizing across the breakpoint.',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
58
69
|
args: {
|
|
59
70
|
items: buildItems(),
|
|
60
71
|
selectedId: null,
|
|
@@ -101,6 +112,14 @@ export const Main: Story = {
|
|
|
101
112
|
render: (args) => (
|
|
102
113
|
<SelectableCardListStory {...args} onSelect={args.onSelect ?? (() => {})} />
|
|
103
114
|
),
|
|
115
|
+
parameters: {
|
|
116
|
+
docs: {
|
|
117
|
+
description: {
|
|
118
|
+
story:
|
|
119
|
+
'Responsive page size: desktop shows 5 cards per page, mobile (below md) shows 3 cards per page. When page size changes across breakpoints, current page is reset to 1.',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
104
123
|
}
|
|
105
124
|
|
|
106
125
|
export const Loading: Story = {
|