@syscore/ui-library 2.0.0-beta-publish-workflow-beta.2 → 2.0.0-beta-publish-workflow-beta.3
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/client/components/ui/table.tsx +174 -57
- package/client/global.css +28 -106
- package/client/ui/Table/{TableV01.stories.tsx → Table.stories.tsx} +76 -78
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +21 -42
- package/dist/index.es.js +60 -131
- package/package.json +1 -1
- package/client/components/ui/table-v01.tsx +0 -230
|
@@ -2,20 +2,20 @@ import * as React from "react";
|
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
3
|
import { Pencil } from "lucide-react";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type
|
|
13
|
-
type
|
|
14
|
-
} from "../../components/ui/table
|
|
5
|
+
Table,
|
|
6
|
+
TableAction,
|
|
7
|
+
TableBody,
|
|
8
|
+
TableCell,
|
|
9
|
+
TableHeader,
|
|
10
|
+
TableHeaderCell,
|
|
11
|
+
TableRow,
|
|
12
|
+
type TableAlign,
|
|
13
|
+
type TableDensity,
|
|
14
|
+
} from "../../components/ui/table";
|
|
15
15
|
|
|
16
16
|
const meta = {
|
|
17
17
|
title: "Components/Table",
|
|
18
|
-
component:
|
|
18
|
+
component: Table,
|
|
19
19
|
tags: ["autodocs"],
|
|
20
20
|
parameters: {
|
|
21
21
|
layout: "padded",
|
|
@@ -26,36 +26,36 @@ const meta = {
|
|
|
26
26
|
"",
|
|
27
27
|
"```tsx",
|
|
28
28
|
`import {`,
|
|
29
|
-
`
|
|
30
|
-
`
|
|
29
|
+
` Table, TableHeader, TableBody, TableFooter, TableRow,`,
|
|
30
|
+
` TableHeaderCell, TableCell, TableTag, TableAction,`,
|
|
31
31
|
`} from "@syscore/ui-library"`,
|
|
32
32
|
"",
|
|
33
|
-
'<
|
|
34
|
-
" <
|
|
35
|
-
" <
|
|
36
|
-
' <
|
|
37
|
-
' <
|
|
38
|
-
" </
|
|
39
|
-
" </
|
|
40
|
-
" <
|
|
41
|
-
" <
|
|
42
|
-
' <
|
|
43
|
-
' <
|
|
44
|
-
" </
|
|
45
|
-
" </
|
|
46
|
-
"</
|
|
33
|
+
'<Table density="compact">',
|
|
34
|
+
" <TableHeader>",
|
|
35
|
+
" <TableRow>",
|
|
36
|
+
' <TableHeaderCell label="Concept" />',
|
|
37
|
+
' <TableHeaderCell label="Actions" align="right" />',
|
|
38
|
+
" </TableRow>",
|
|
39
|
+
" </TableHeader>",
|
|
40
|
+
" <TableBody>",
|
|
41
|
+
" <TableRow>",
|
|
42
|
+
' <TableCell text="Thermal comfort" tag="T4.1" />',
|
|
43
|
+
' <TableCell align="right" action={<TableAction>…</TableAction>} />',
|
|
44
|
+
" </TableRow>",
|
|
45
|
+
" </TableBody>",
|
|
46
|
+
"</Table>",
|
|
47
47
|
"```",
|
|
48
48
|
"",
|
|
49
49
|
"### Props",
|
|
50
50
|
"",
|
|
51
51
|
"| Component | Prop | Values | Default |",
|
|
52
52
|
"|-----------|------|--------|---------|",
|
|
53
|
-
"| `
|
|
54
|
-
"| `
|
|
53
|
+
"| `Table` | `density` | `compact` \\| `balanced` \\| `spacious` | `compact` |",
|
|
54
|
+
"| `TableHeaderCell` | `label` | column label | — |",
|
|
55
55
|
"| | `align` | `left` \\| `center` \\| `right` | `left` |",
|
|
56
|
-
"| `
|
|
56
|
+
"| `TableCell` | `text` | cell text | — |",
|
|
57
57
|
"| | `tag` | wrapped in the code tag automatically | — |",
|
|
58
|
-
"| | `action` | one or more `
|
|
58
|
+
"| | `action` | one or more `TableAction` | — |",
|
|
59
59
|
"| | `align` | `left` \\| `center` \\| `right` | `left` |",
|
|
60
60
|
"",
|
|
61
61
|
"Mix `text`, `tag` and `action` freely — they render in that order. `children`",
|
|
@@ -77,14 +77,14 @@ const meta = {
|
|
|
77
77
|
},
|
|
78
78
|
},
|
|
79
79
|
},
|
|
80
|
-
} satisfies Meta<typeof
|
|
80
|
+
} satisfies Meta<typeof Table>;
|
|
81
81
|
|
|
82
82
|
export default meta;
|
|
83
83
|
|
|
84
84
|
/** Density and alignment as controls; the three columns show one layout each. */
|
|
85
85
|
type StoryArgs = {
|
|
86
|
-
density:
|
|
87
|
-
align:
|
|
86
|
+
density: TableDensity;
|
|
87
|
+
align: TableAlign;
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
type Story = StoryObj<StoryArgs>;
|
|
@@ -110,9 +110,9 @@ const ROWS = [
|
|
|
110
110
|
|
|
111
111
|
/** A cell holds a single icon action; pass a fragment for more. */
|
|
112
112
|
const action = (label: string) => (
|
|
113
|
-
<
|
|
113
|
+
<TableAction aria-label={`Edit ${label}`}>
|
|
114
114
|
<Pencil strokeWidth={1.5} />
|
|
115
|
-
</
|
|
115
|
+
</TableAction>
|
|
116
116
|
);
|
|
117
117
|
|
|
118
118
|
/**
|
|
@@ -121,7 +121,7 @@ const action = (label: string) => (
|
|
|
121
121
|
*/
|
|
122
122
|
function contentStory(
|
|
123
123
|
headers: [string, string, string],
|
|
124
|
-
cell: (row: (typeof ROWS)[number], align:
|
|
124
|
+
cell: (row: (typeof ROWS)[number], align: TableAlign) => React.ReactNode,
|
|
125
125
|
story: string,
|
|
126
126
|
): Story {
|
|
127
127
|
return {
|
|
@@ -129,24 +129,24 @@ function contentStory(
|
|
|
129
129
|
args: { density: "compact", align: "left" },
|
|
130
130
|
parameters: { docs: { description: { story } } },
|
|
131
131
|
render: ({ density, align }) => (
|
|
132
|
-
<
|
|
133
|
-
<
|
|
134
|
-
<
|
|
132
|
+
<Table density={density} containerClassName="sb-table-triple">
|
|
133
|
+
<TableHeader>
|
|
134
|
+
<TableRow>
|
|
135
135
|
{headers.map((label) => (
|
|
136
|
-
<
|
|
136
|
+
<TableHeaderCell key={label} label={label} align={align} />
|
|
137
137
|
))}
|
|
138
|
-
</
|
|
139
|
-
</
|
|
140
|
-
<
|
|
138
|
+
</TableRow>
|
|
139
|
+
</TableHeader>
|
|
140
|
+
<TableBody>
|
|
141
141
|
{ROWS.map((row) => (
|
|
142
|
-
<
|
|
142
|
+
<TableRow key={row.tag}>
|
|
143
143
|
{headers.map((label) => (
|
|
144
144
|
<React.Fragment key={label}>{cell(row, align)}</React.Fragment>
|
|
145
145
|
))}
|
|
146
|
-
</
|
|
146
|
+
</TableRow>
|
|
147
147
|
))}
|
|
148
|
-
</
|
|
149
|
-
</
|
|
148
|
+
</TableBody>
|
|
149
|
+
</Table>
|
|
150
150
|
),
|
|
151
151
|
};
|
|
152
152
|
}
|
|
@@ -154,7 +154,7 @@ function contentStory(
|
|
|
154
154
|
export const WithText: Story = {
|
|
155
155
|
...contentStory(
|
|
156
156
|
["Concept", "Strategy", "Status"],
|
|
157
|
-
(row, align) => <
|
|
157
|
+
(row, align) => <TableCell text={row.text} align={align} />,
|
|
158
158
|
"Text cells — pass the `text` prop.",
|
|
159
159
|
),
|
|
160
160
|
name: "With text",
|
|
@@ -163,7 +163,7 @@ export const WithText: Story = {
|
|
|
163
163
|
export const WithTag: Story = {
|
|
164
164
|
...contentStory(
|
|
165
165
|
["Code", "Strategy", "Reference"],
|
|
166
|
-
(row, align) => <
|
|
166
|
+
(row, align) => <TableCell tag={row.tag} align={align} />,
|
|
167
167
|
"Tag cells — pass `tag` and it is wrapped in the code tag automatically.",
|
|
168
168
|
),
|
|
169
169
|
name: "With tag",
|
|
@@ -172,8 +172,8 @@ export const WithTag: Story = {
|
|
|
172
172
|
export const WithAction: Story = {
|
|
173
173
|
...contentStory(
|
|
174
174
|
["Actions", "Review", "Archive"],
|
|
175
|
-
(row, align) => <
|
|
176
|
-
"Action cells — pass one or more `
|
|
175
|
+
(row, align) => <TableCell action={action(row.text)} align={align} />,
|
|
176
|
+
"Action cells — pass one or more `TableAction` to `action`.",
|
|
177
177
|
),
|
|
178
178
|
name: "With action",
|
|
179
179
|
};
|
|
@@ -181,9 +181,7 @@ export const WithAction: Story = {
|
|
|
181
181
|
export const TextAndTag: Story = {
|
|
182
182
|
...contentStory(
|
|
183
183
|
["Concept", "Strategy", "Feature"],
|
|
184
|
-
(row, align) =>
|
|
185
|
-
<TableV01Cell text={row.text} tag={row.tag} align={align} />
|
|
186
|
-
),
|
|
184
|
+
(row, align) => <TableCell text={row.text} tag={row.tag} align={align} />,
|
|
187
185
|
"Text and tag on the same cell.",
|
|
188
186
|
),
|
|
189
187
|
name: "Text + tag",
|
|
@@ -193,7 +191,7 @@ export const TextAndAction: Story = {
|
|
|
193
191
|
...contentStory(
|
|
194
192
|
["Concept", "Strategy", "Actions"],
|
|
195
193
|
(row, align) => (
|
|
196
|
-
<
|
|
194
|
+
<TableCell text={row.text} action={action(row.text)} align={align} />
|
|
197
195
|
),
|
|
198
196
|
"Text and an action on the same cell.",
|
|
199
197
|
),
|
|
@@ -218,37 +216,37 @@ export const AllVariants: Story = {
|
|
|
218
216
|
<span className="sb-table-density-label font-mazzardSoft">
|
|
219
217
|
{density}
|
|
220
218
|
</span>
|
|
221
|
-
<
|
|
222
|
-
<
|
|
223
|
-
<
|
|
224
|
-
<
|
|
225
|
-
<
|
|
226
|
-
<
|
|
227
|
-
<
|
|
228
|
-
<
|
|
229
|
-
<
|
|
230
|
-
</
|
|
231
|
-
</
|
|
232
|
-
<
|
|
219
|
+
<Table density={density}>
|
|
220
|
+
<TableHeader>
|
|
221
|
+
<TableRow>
|
|
222
|
+
<TableHeaderCell label="Align" />
|
|
223
|
+
<TableHeaderCell label="Text only" />
|
|
224
|
+
<TableHeaderCell label="Tag only" />
|
|
225
|
+
<TableHeaderCell label="Text + tag" />
|
|
226
|
+
<TableHeaderCell label="Text + action" />
|
|
227
|
+
<TableHeaderCell label="Action only" />
|
|
228
|
+
</TableRow>
|
|
229
|
+
</TableHeader>
|
|
230
|
+
<TableBody>
|
|
233
231
|
{(["left", "center", "right"] as const).map((align, index) => {
|
|
234
232
|
const row = ROWS[index];
|
|
235
233
|
return (
|
|
236
|
-
<
|
|
237
|
-
<
|
|
238
|
-
<
|
|
239
|
-
<
|
|
240
|
-
<
|
|
241
|
-
<
|
|
234
|
+
<TableRow key={align}>
|
|
235
|
+
<TableCell text={align} />
|
|
236
|
+
<TableCell text={row.text} align={align} />
|
|
237
|
+
<TableCell tag={row.tag} align={align} />
|
|
238
|
+
<TableCell text={row.text} tag={row.tag} align={align} />
|
|
239
|
+
<TableCell
|
|
242
240
|
text={row.text}
|
|
243
241
|
action={action(row.text)}
|
|
244
242
|
align={align}
|
|
245
243
|
/>
|
|
246
|
-
<
|
|
247
|
-
</
|
|
244
|
+
<TableCell action={action(row.text)} align={align} />
|
|
245
|
+
</TableRow>
|
|
248
246
|
);
|
|
249
247
|
})}
|
|
250
|
-
</
|
|
251
|
-
</
|
|
248
|
+
</TableBody>
|
|
249
|
+
</Table>
|
|
252
250
|
</div>
|
|
253
251
|
))}
|
|
254
252
|
</div>
|