@duro-app/ui 0.18.0 → 0.20.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/components/Checkbox/Checkbox.meta.d.ts.map +1 -1
- package/dist/components/Cluster/Cluster.meta.d.ts.map +1 -1
- package/dist/components/DetailPanel/DetailPanel.d.ts +53 -0
- package/dist/components/DetailPanel/DetailPanel.d.ts.map +1 -0
- package/dist/components/DetailPanel/DetailPanel.meta.d.ts +3 -0
- package/dist/components/DetailPanel/DetailPanel.meta.d.ts.map +1 -0
- package/dist/components/DetailPanel/DetailPanel.stories.d.ts +9 -0
- package/dist/components/DetailPanel/DetailPanel.stories.d.ts.map +1 -0
- package/dist/components/DetailPanel/styles.css.d.ts +126 -0
- package/dist/components/DetailPanel/styles.css.d.ts.map +1 -0
- package/dist/components/Dialog/Dialog.d.ts +58 -0
- package/dist/components/Dialog/Dialog.d.ts.map +1 -0
- package/dist/components/Dialog/Dialog.meta.d.ts +3 -0
- package/dist/components/Dialog/Dialog.meta.d.ts.map +1 -0
- package/dist/components/Dialog/Dialog.stories.d.ts +13 -0
- package/dist/components/Dialog/Dialog.stories.d.ts.map +1 -0
- package/dist/components/Dialog/styles.css.d.ts +140 -0
- package/dist/components/Dialog/styles.css.d.ts.map +1 -0
- package/dist/components/Drawer/Drawer.d.ts +62 -0
- package/dist/components/Drawer/Drawer.d.ts.map +1 -0
- package/dist/components/Drawer/Drawer.meta.d.ts +3 -0
- package/dist/components/Drawer/Drawer.meta.d.ts.map +1 -0
- package/dist/components/Drawer/Drawer.stories.d.ts +15 -0
- package/dist/components/Drawer/Drawer.stories.d.ts.map +1 -0
- package/dist/components/Drawer/styles.css.d.ts +184 -0
- package/dist/components/Drawer/styles.css.d.ts.map +1 -0
- package/dist/components/Drawer/useSwipeDismiss.d.ts +17 -0
- package/dist/components/Drawer/useSwipeDismiss.d.ts.map +1 -0
- package/dist/components/Field/Field.meta.d.ts.map +1 -1
- package/dist/components/Fieldset/Fieldset.meta.d.ts.map +1 -1
- package/dist/components/Form/Form.meta.d.ts.map +1 -1
- package/dist/components/Grid/Grid.meta.d.ts.map +1 -1
- package/dist/components/Inline/Inline.meta.d.ts.map +1 -1
- package/dist/components/Input/Input.meta.d.ts.map +1 -1
- package/dist/components/LinkButton/LinkButton.meta.d.ts.map +1 -1
- package/dist/components/Menu/Menu.meta.d.ts.map +1 -1
- package/dist/components/Panel/Panel.d.ts +27 -0
- package/dist/components/Panel/Panel.d.ts.map +1 -0
- package/dist/components/Panel/Panel.meta.d.ts +3 -0
- package/dist/components/Panel/Panel.meta.d.ts.map +1 -0
- package/dist/components/Panel/Panel.stories.d.ts +10 -0
- package/dist/components/Panel/Panel.stories.d.ts.map +1 -0
- package/dist/components/Panel/styles.css.d.ts +50 -0
- package/dist/components/Panel/styles.css.d.ts.map +1 -0
- package/dist/components/SideNav/SideNav.meta.d.ts.map +1 -1
- package/dist/components/Stack/Stack.meta.d.ts.map +1 -1
- package/dist/components/Switch/Switch.meta.d.ts.map +1 -1
- package/dist/components/Table/Table.d.ts.map +1 -1
- package/dist/components/Table/Table.stories.d.ts +1 -0
- package/dist/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/components/Textarea/Textarea.meta.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3286 -2007
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Checkbox/Checkbox.meta.ts +4 -1
- package/src/components/Cluster/Cluster.meta.ts +2 -6
- package/src/components/DetailPanel/DetailPanel.meta.ts +41 -0
- package/src/components/DetailPanel/DetailPanel.stories.tsx +270 -0
- package/src/components/DetailPanel/DetailPanel.tsx +312 -0
- package/src/components/DetailPanel/styles.css.ts +187 -0
- package/src/components/Dialog/Dialog.meta.ts +44 -0
- package/src/components/Dialog/Dialog.stories.tsx +325 -0
- package/src/components/Dialog/Dialog.tsx +310 -0
- package/src/components/Dialog/styles.css.ts +197 -0
- package/src/components/Drawer/Drawer.meta.ts +45 -0
- package/src/components/Drawer/Drawer.stories.tsx +364 -0
- package/src/components/Drawer/Drawer.tsx +370 -0
- package/src/components/Drawer/styles.css.ts +242 -0
- package/src/components/Drawer/useSwipeDismiss.ts +295 -0
- package/src/components/Field/Field.meta.ts +1 -3
- package/src/components/Fieldset/Fieldset.meta.ts +1 -3
- package/src/components/Form/Form.meta.ts +1 -4
- package/src/components/Grid/Grid.meta.ts +1 -3
- package/src/components/Inline/Inline.meta.ts +1 -2
- package/src/components/Input/Input.meta.ts +2 -7
- package/src/components/LinkButton/LinkButton.meta.ts +1 -3
- package/src/components/Menu/Menu.meta.ts +1 -4
- package/src/components/Panel/Panel.meta.ts +37 -0
- package/src/components/Panel/Panel.stories.tsx +124 -0
- package/src/components/Panel/Panel.tsx +56 -0
- package/src/components/Panel/styles.css.ts +55 -0
- package/src/components/SideNav/SideNav.meta.ts +1 -4
- package/src/components/Stack/Stack.meta.ts +1 -2
- package/src/components/Switch/Switch.meta.ts +4 -1
- package/src/components/Table/Table.stories.tsx +107 -0
- package/src/components/Table/Table.tsx +0 -1
- package/src/components/Textarea/Textarea.meta.ts +2 -6
- package/src/index.ts +4 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type {ComponentMeta} from '../component-meta'
|
|
2
2
|
|
|
3
3
|
export const meta: ComponentMeta = {
|
|
4
|
-
description:
|
|
5
|
-
'Vertical flex layout. Stacks children top-to-bottom with consistent gap.',
|
|
4
|
+
description: 'Vertical flex layout. Stacks children top-to-bottom with consistent gap.',
|
|
6
5
|
whenToUse: [
|
|
7
6
|
'Vertically stacking form fields, cards, or sections',
|
|
8
7
|
'Any column-direction layout with uniform spacing',
|
|
@@ -12,7 +12,10 @@ export const meta: ComponentMeta = {
|
|
|
12
12
|
'Selecting between multiple options — use Select or ToggleGroup',
|
|
13
13
|
],
|
|
14
14
|
relatedTo: [
|
|
15
|
-
{
|
|
15
|
+
{
|
|
16
|
+
component: 'Checkbox',
|
|
17
|
+
relationship: 'Checkbox for selection/opt-in; Switch for on/off settings',
|
|
18
|
+
},
|
|
16
19
|
{component: 'Toggle', relationship: 'Toggle for toolbar pressed state; Switch for settings'},
|
|
17
20
|
],
|
|
18
21
|
example: `<Switch
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type {Meta, StoryObj} from '@storybook/react'
|
|
2
2
|
import {expect} from 'storybook/test'
|
|
3
3
|
import {css, html} from 'react-strict-dom'
|
|
4
|
+
import {useState} from 'react'
|
|
4
5
|
import {Table} from './Table'
|
|
5
6
|
import {Badge} from '../Badge/Badge'
|
|
7
|
+
import {Checkbox} from '../Checkbox/Checkbox'
|
|
8
|
+
import {Button} from '../Button/Button'
|
|
9
|
+
import {ActionBar} from '../ActionBar/ActionBar'
|
|
6
10
|
import {colors} from '@duro-app/tokens/tokens/colors.css'
|
|
7
11
|
|
|
8
12
|
const meta: Meta = {
|
|
@@ -186,6 +190,109 @@ export const Compact: Story = {
|
|
|
186
190
|
},
|
|
187
191
|
}
|
|
188
192
|
|
|
193
|
+
// --- WithCheckboxes: demonstrates parent/child cascading selection ---
|
|
194
|
+
|
|
195
|
+
interface ServiceData {
|
|
196
|
+
id: string
|
|
197
|
+
name: string
|
|
198
|
+
status: string
|
|
199
|
+
port: string
|
|
200
|
+
uptime: string
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function CheckboxTableDemo() {
|
|
204
|
+
const items: ServiceData[] = [
|
|
205
|
+
{id: 's1', name: 'Traefik', status: 'Running', port: '443', uptime: '14d 3h'},
|
|
206
|
+
{id: 's2', name: 'Pi-hole', status: 'Running', port: '80', uptime: '14d 3h'},
|
|
207
|
+
{id: 's3', name: 'Portainer', status: 'Stopped', port: '9000', uptime: '\u2014'},
|
|
208
|
+
{id: 's4', name: 'Grafana', status: 'Running', port: '3000', uptime: '7d 12h'},
|
|
209
|
+
]
|
|
210
|
+
|
|
211
|
+
const [selected, setSelected] = useState<Set<string>>(new Set())
|
|
212
|
+
|
|
213
|
+
const allSelected = items.length > 0 && items.every((i) => selected.has(i.id))
|
|
214
|
+
const someSelected = items.some((i) => selected.has(i.id))
|
|
215
|
+
|
|
216
|
+
const toggleAll = () => {
|
|
217
|
+
if (allSelected) {
|
|
218
|
+
setSelected(new Set())
|
|
219
|
+
} else {
|
|
220
|
+
setSelected(new Set(items.map((i) => i.id)))
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const toggleOne = (id: string) => {
|
|
225
|
+
setSelected((prev) => {
|
|
226
|
+
const next = new Set(prev)
|
|
227
|
+
if (next.has(id)) next.delete(id)
|
|
228
|
+
else next.add(id)
|
|
229
|
+
return next
|
|
230
|
+
})
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return (
|
|
234
|
+
<>
|
|
235
|
+
<Table.Root columns={5}>
|
|
236
|
+
<Table.Header>
|
|
237
|
+
<Table.Row>
|
|
238
|
+
<Table.HeaderCell aria-label="Select all">
|
|
239
|
+
<Checkbox
|
|
240
|
+
checked={allSelected}
|
|
241
|
+
onChange={toggleAll}
|
|
242
|
+
aria-label="Select all services"
|
|
243
|
+
/>
|
|
244
|
+
</Table.HeaderCell>
|
|
245
|
+
<Table.HeaderCell>Service</Table.HeaderCell>
|
|
246
|
+
<Table.HeaderCell>Status</Table.HeaderCell>
|
|
247
|
+
<Table.HeaderCell>Port</Table.HeaderCell>
|
|
248
|
+
<Table.HeaderCell>Uptime</Table.HeaderCell>
|
|
249
|
+
</Table.Row>
|
|
250
|
+
</Table.Header>
|
|
251
|
+
<Table.Body>
|
|
252
|
+
{items.map((s) => (
|
|
253
|
+
<Table.Row key={s.id}>
|
|
254
|
+
<Table.Cell>
|
|
255
|
+
<Checkbox
|
|
256
|
+
checked={selected.has(s.id)}
|
|
257
|
+
onChange={() => toggleOne(s.id)}
|
|
258
|
+
aria-label={s.name}
|
|
259
|
+
/>
|
|
260
|
+
</Table.Cell>
|
|
261
|
+
<Table.Cell>{s.name}</Table.Cell>
|
|
262
|
+
<Table.Cell>
|
|
263
|
+
<Badge variant={statusVariant(s.status)} size="sm">
|
|
264
|
+
{s.status}
|
|
265
|
+
</Badge>
|
|
266
|
+
</Table.Cell>
|
|
267
|
+
<Table.Cell>{s.port}</Table.Cell>
|
|
268
|
+
<Table.Cell>{s.uptime}</Table.Cell>
|
|
269
|
+
</Table.Row>
|
|
270
|
+
))}
|
|
271
|
+
</Table.Body>
|
|
272
|
+
</Table.Root>
|
|
273
|
+
|
|
274
|
+
<ActionBar
|
|
275
|
+
selectedItemCount={selected.size}
|
|
276
|
+
onClearSelection={() => setSelected(new Set())}
|
|
277
|
+
>
|
|
278
|
+
<Button variant="danger" size="small">
|
|
279
|
+
Delete
|
|
280
|
+
</Button>
|
|
281
|
+
</ActionBar>
|
|
282
|
+
</>
|
|
283
|
+
)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export const WithCheckboxes: Story = {
|
|
287
|
+
render: () => <CheckboxTableDemo />,
|
|
288
|
+
play: async ({canvas}) => {
|
|
289
|
+
await expect(canvas.getByRole('table')).toBeInTheDocument()
|
|
290
|
+
const checkboxes = canvas.getAllByRole('checkbox')
|
|
291
|
+
await expect(checkboxes.length).toBe(5) // 1 select-all + 4 rows
|
|
292
|
+
await expect(canvas.getByLabelText('Select all services')).toBeInTheDocument()
|
|
293
|
+
},
|
|
294
|
+
}
|
|
295
|
+
|
|
189
296
|
const storyStyles = css.create({
|
|
190
297
|
stack: {display: 'flex', flexDirection: 'column', gap: 24},
|
|
191
298
|
label: {color: colors.textMuted, fontSize: '0.875rem', fontWeight: 600},
|
|
@@ -94,7 +94,6 @@ function Row({children}: {children: ReactNode}) {
|
|
|
94
94
|
const rowIndex = useContext(RowIndexContext)
|
|
95
95
|
const isEvenRow = rowIndex >= 0 && rowIndex % 2 === 1
|
|
96
96
|
const childArray = Children.toArray(children)
|
|
97
|
-
const isLastRow = false // handled by CSS or parent
|
|
98
97
|
|
|
99
98
|
return (
|
|
100
99
|
<html.div
|
|
@@ -3,12 +3,8 @@ import type {ComponentMeta} from '../component-meta'
|
|
|
3
3
|
export const meta: ComponentMeta = {
|
|
4
4
|
description:
|
|
5
5
|
'Multi-line text input with automatic Field/Form integration. Same Field binding behavior as Input.',
|
|
6
|
-
whenToUse: [
|
|
7
|
-
|
|
8
|
-
],
|
|
9
|
-
whenNotToUse: [
|
|
10
|
-
'Single-line input — use Input',
|
|
11
|
-
],
|
|
6
|
+
whenToUse: ['Multi-line text entry (comments, messages, descriptions)'],
|
|
7
|
+
whenNotToUse: ['Single-line input — use Input'],
|
|
12
8
|
relatedTo: [
|
|
13
9
|
{component: 'Input', relationship: 'Single-line variant'},
|
|
14
10
|
{component: 'Field', relationship: 'Wrap in Field.Root for label + error'},
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,9 @@ export {Button, type ButtonVariant, type ButtonSize} from './components/Button/B
|
|
|
11
11
|
export {Callout, type CalloutVariant} from './components/Callout/Callout'
|
|
12
12
|
export {Card, type CardVariant, type CardSize} from './components/Card/Card'
|
|
13
13
|
export {Checkbox} from './components/Checkbox/Checkbox'
|
|
14
|
+
export {Dialog, type DialogSize} from './components/Dialog/Dialog'
|
|
15
|
+
export {DetailPanel, type DetailPanelSize} from './components/DetailPanel/DetailPanel'
|
|
16
|
+
export {Drawer, type DrawerAnchor, type DrawerSize} from './components/Drawer/Drawer'
|
|
14
17
|
export {EmptyState} from './components/EmptyState/EmptyState'
|
|
15
18
|
export {Heading, type HeadingVariant} from './components/Heading/Heading'
|
|
16
19
|
export {Field} from './components/Field/Field'
|
|
@@ -24,6 +27,7 @@ export {
|
|
|
24
27
|
type LinkButtonSize,
|
|
25
28
|
} from './components/LinkButton/LinkButton'
|
|
26
29
|
export {Menu} from './components/Menu/Menu'
|
|
30
|
+
export {Panel} from './components/Panel/Panel'
|
|
27
31
|
export {ScrollArea} from './components/ScrollArea/ScrollArea'
|
|
28
32
|
export {Select} from './components/Select/Select'
|
|
29
33
|
export {SideNav} from './components/SideNav/SideNav'
|