@agregio-solutions/design-system 1.90.1 → 1.92.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/design-system.cjs +9 -5
- package/dist/design-system.js +14 -6
- package/dist/packages/components/Accordion/doc.md +342 -0
- package/dist/packages/components/Badge/doc.md +192 -0
- package/dist/packages/components/Breadcrumbs/doc.md +332 -0
- package/dist/packages/components/Button/doc.md +425 -0
- package/dist/packages/components/Calendar/doc.md +465 -0
- package/dist/packages/components/ChartLegend/doc.md +151 -0
- package/dist/packages/components/ChartTooltip/doc.md +124 -0
- package/dist/packages/components/Checkbox/doc.md +329 -0
- package/dist/packages/components/CheckboxGroup/doc.md +242 -0
- package/dist/packages/components/Chip/doc.md +99 -0
- package/dist/packages/components/Combobox/Combobox.d.ts +8 -0
- package/dist/packages/components/Combobox/doc.md +680 -0
- package/dist/packages/components/DataTable/doc.md +1124 -0
- package/dist/packages/components/DatePicker/doc.md +579 -0
- package/dist/packages/components/DateRangePicker/doc.md +638 -0
- package/dist/packages/components/Drawer/doc.md +338 -0
- package/dist/packages/components/Dropdown/Dropdown.d.ts +4 -0
- package/dist/packages/components/Dropdown/doc.md +205 -0
- package/dist/packages/components/EmptyState/doc.md +101 -0
- package/dist/packages/components/FileUpload/doc.md +449 -0
- package/dist/packages/components/Filter/doc.md +196 -0
- package/dist/packages/components/Header/doc.md +373 -0
- package/dist/packages/components/I18nProvider/doc.md +187 -0
- package/dist/packages/components/Icon/doc.md +63 -0
- package/dist/packages/components/Label/doc.md +60 -0
- package/dist/packages/components/LinearProgressBar/doc.md +148 -0
- package/dist/packages/components/Link/doc.md +206 -0
- package/dist/packages/components/List/doc.md +481 -0
- package/dist/packages/components/Loader/doc.md +53 -0
- package/dist/packages/components/Menu/Menu.d.ts +5 -1
- package/dist/packages/components/Menu/doc.md +231 -0
- package/dist/packages/components/Message/doc.md +166 -0
- package/dist/packages/components/Modal/doc.md +289 -0
- package/dist/packages/components/Navigation/doc.md +992 -0
- package/dist/packages/components/NavigationItem/doc.md +167 -0
- package/dist/packages/components/NotificationCard/doc.md +206 -0
- package/dist/packages/components/Notifications/doc.md +240 -0
- package/dist/packages/components/NumberField/doc.md +582 -0
- package/dist/packages/components/PageLayout/doc.md +651 -0
- package/dist/packages/components/Pagination/doc.md +227 -0
- package/dist/packages/components/Popover/doc.md +245 -0
- package/dist/packages/components/Radio/doc.md +370 -0
- package/dist/packages/components/RouterProvider/doc.md +64 -0
- package/dist/packages/components/SearchBar/doc.md +504 -0
- package/dist/packages/components/SegmentedControl/doc.md +398 -0
- package/dist/packages/components/Select/Select.d.ts +4 -0
- package/dist/packages/components/Select/doc.md +1133 -0
- package/dist/packages/components/Skeleton/doc.md +129 -0
- package/dist/packages/components/Slider/doc.md +362 -0
- package/dist/packages/components/Stepper/doc.md +104 -0
- package/dist/packages/components/Switch/doc.md +296 -0
- package/dist/packages/components/Tabs/doc.md +295 -0
- package/dist/packages/components/Tag/doc.md +81 -0
- package/dist/packages/components/TextInput/doc.md +490 -0
- package/dist/packages/components/TimeField/doc.md +353 -0
- package/dist/packages/components/Timeline/doc.md +1046 -0
- package/dist/packages/components/Toaster/doc.md +263 -0
- package/dist/packages/components/ToggleButton/doc.md +108 -0
- package/dist/packages/components/ToggleButtonGroup/doc.md +307 -0
- package/dist/packages/components/Tooltip/doc.md +206 -0
- package/dist/packages/components/YearMonthPicker/YearMonthPicker.d.ts +8 -0
- package/dist/packages/components/YearMonthPicker/doc.md +638 -0
- package/dist/public_docs/components.md +68 -0
- package/dist/public_docs/index.md +30 -0
- package/dist/public_docs/tokens.md +121 -0
- package/package.json +3 -2
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
# Header
|
|
2
|
+
|
|
3
|
+
## Props
|
|
4
|
+
|
|
5
|
+
The complete Props documentation with JS doc for this component is available at this path:
|
|
6
|
+
|
|
7
|
+
node_modules/@agregio-solutions/design-system/dist/packages/components/Header/Header.d.ts
|
|
8
|
+
|
|
9
|
+
## Example usage
|
|
10
|
+
|
|
11
|
+
Here are the Storybook Stories.
|
|
12
|
+
|
|
13
|
+
Base stories:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
17
|
+
import { fn, within } from "storybook/test";
|
|
18
|
+
import { STORYBOOK_VIEWPORTS } from "@internal/test-utils-storybook/test-utils-storybook";
|
|
19
|
+
import Header from "./Header";
|
|
20
|
+
import Tag from "../Tag/Tag";
|
|
21
|
+
import { I18nProvider } from "react-aria-components";
|
|
22
|
+
import Breadcrumbs from "../Breadcrumbs/Breadcrumbs";
|
|
23
|
+
import Button from "../Button/Button";
|
|
24
|
+
import Select from "../Select/Select";
|
|
25
|
+
import SelectItem from "../SelectItem/SelectItem";
|
|
26
|
+
import Tabs from "../Tabs/Tabs/Tabs";
|
|
27
|
+
import Tab from "../Tabs/Tab/Tab";
|
|
28
|
+
import TabList from "../Tabs/TabList/TabList";
|
|
29
|
+
import TabPanel from "../Tabs/TabPanel/TabPanel";
|
|
30
|
+
import styled from "styled-components";
|
|
31
|
+
|
|
32
|
+
const meta = {
|
|
33
|
+
component: Header,
|
|
34
|
+
argTypes: {
|
|
35
|
+
subtitle: { control: "text" },
|
|
36
|
+
tagComponent: { control: false },
|
|
37
|
+
onGoBack: { control: false },
|
|
38
|
+
breadcrumbsComponent: { control: false },
|
|
39
|
+
helperIconComponent: { control: false },
|
|
40
|
+
notificationIconComponent: { control: false },
|
|
41
|
+
additionalActions: { control: false },
|
|
42
|
+
tabsComponent: { control: false },
|
|
43
|
+
},
|
|
44
|
+
parameters: {
|
|
45
|
+
layout: "none",
|
|
46
|
+
},
|
|
47
|
+
args: {
|
|
48
|
+
onGoBack: fn(),
|
|
49
|
+
},
|
|
50
|
+
decorators: [
|
|
51
|
+
(story) => (
|
|
52
|
+
<div
|
|
53
|
+
style={{ display: "flex", flexDirection: "column", height: "100vh" }}
|
|
54
|
+
>
|
|
55
|
+
<I18nProvider locale="en-EN">{story()}</I18nProvider>
|
|
56
|
+
</div>
|
|
57
|
+
),
|
|
58
|
+
],
|
|
59
|
+
} satisfies Meta<typeof Header>;
|
|
60
|
+
export default meta;
|
|
61
|
+
|
|
62
|
+
type Story = StoryObj<typeof meta>;
|
|
63
|
+
|
|
64
|
+
const StyledTabPanel = styled(TabPanel)`
|
|
65
|
+
flex: 1;
|
|
66
|
+
padding: var(--spacing-lg);
|
|
67
|
+
background-color: var(--color-background-neutral-underground-1);
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
export const Playground: Story = {
|
|
71
|
+
args: {
|
|
72
|
+
title: "Insert title",
|
|
73
|
+
subtitle: "Insert subtitle",
|
|
74
|
+
tagComponent: <Tag iconLeft="help_outline">[Insert tag]</Tag>,
|
|
75
|
+
logo: "agregio",
|
|
76
|
+
onGoBack: fn(),
|
|
77
|
+
breadcrumbsComponent: (
|
|
78
|
+
<Breadcrumbs
|
|
79
|
+
links={[
|
|
80
|
+
{ href: "#link-1", text: "Link 1" },
|
|
81
|
+
{ href: "#link-2", text: "Link 2" },
|
|
82
|
+
{ href: "#link-3", text: "Link 3" },
|
|
83
|
+
]}
|
|
84
|
+
/>
|
|
85
|
+
),
|
|
86
|
+
helperIconComponent: (
|
|
87
|
+
<Button
|
|
88
|
+
iconLeft="help_outline"
|
|
89
|
+
onClick={() => alert("Help")}
|
|
90
|
+
mode="tertiary"
|
|
91
|
+
/>
|
|
92
|
+
),
|
|
93
|
+
notificationIconComponent: (
|
|
94
|
+
<Button
|
|
95
|
+
iconLeft="notifications_none"
|
|
96
|
+
onClick={() => alert("Notifications")}
|
|
97
|
+
mode="tertiary"
|
|
98
|
+
/>
|
|
99
|
+
),
|
|
100
|
+
additionalActions: (
|
|
101
|
+
<Select
|
|
102
|
+
mode="single"
|
|
103
|
+
id="select"
|
|
104
|
+
aria-label="Select"
|
|
105
|
+
value={null}
|
|
106
|
+
onChange={fn()}
|
|
107
|
+
placeholder="Select"
|
|
108
|
+
>
|
|
109
|
+
<SelectItem id="select-item-1" text="Item 1" />
|
|
110
|
+
<SelectItem id="select-item-2" text="Item 2" />
|
|
111
|
+
<SelectItem id="select-item-3" text="Item 3" />
|
|
112
|
+
</Select>
|
|
113
|
+
),
|
|
114
|
+
tabsComponent: (
|
|
115
|
+
<Tabs>
|
|
116
|
+
<TabList>
|
|
117
|
+
<Tab id="tab-1">Tab 1</Tab>
|
|
118
|
+
<Tab id="tab-2" badgeProps={{ nature: "negative", variant: "dot" }}>
|
|
119
|
+
Tab 2
|
|
120
|
+
</Tab>
|
|
121
|
+
<Tab id="tab-3" badgeProps={{ variant: "dot", nature: "positive" }}>
|
|
122
|
+
Tab 3
|
|
123
|
+
</Tab>
|
|
124
|
+
</TabList>
|
|
125
|
+
|
|
126
|
+
{/* StyledPanel is a TabPanel with styled: `flex: 1; padding: var(--spacing-lg); background-color: var(--color-background-neutral-underground-1);` */}
|
|
127
|
+
{/* You need to create it on your side if you want those styles, or just use a TabPanel component directly */}
|
|
128
|
+
<StyledTabPanel id="tab-1">Content for the panel 1</StyledTabPanel>
|
|
129
|
+
<StyledTabPanel id="tab-2">Content for the panel 2</StyledTabPanel>
|
|
130
|
+
<StyledTabPanel id="tab-3">Content for the panel 3</StyledTabPanel>
|
|
131
|
+
</Tabs>
|
|
132
|
+
),
|
|
133
|
+
},
|
|
134
|
+
play: async ({ canvasElement, args }) => {
|
|
135
|
+
const canvas = within(canvasElement);
|
|
136
|
+
await canvas.findByText(args.title);
|
|
137
|
+
await canvas.findByText(args.subtitle as string);
|
|
138
|
+
await canvas.findByText("[Insert tag]");
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const WithoutSubtitle: Story = {
|
|
143
|
+
args: {
|
|
144
|
+
...Playground.args,
|
|
145
|
+
subtitle: undefined,
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const WithoutTag: Story = {
|
|
150
|
+
args: {
|
|
151
|
+
...Playground.args,
|
|
152
|
+
tagComponent: undefined,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export const WithoutGoBack: Story = {
|
|
157
|
+
args: {
|
|
158
|
+
...Playground.args,
|
|
159
|
+
onGoBack: undefined,
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export const WithoutBreadcrumbs: Story = {
|
|
164
|
+
args: {
|
|
165
|
+
...Playground.args,
|
|
166
|
+
breadcrumbsComponent: undefined,
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const WithoutHelperIcon: Story = {
|
|
171
|
+
args: {
|
|
172
|
+
...Playground.args,
|
|
173
|
+
helperIconComponent: undefined,
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const WithoutNotificationIcon: Story = {
|
|
178
|
+
args: {
|
|
179
|
+
...Playground.args,
|
|
180
|
+
notificationIconComponent: undefined,
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export const WithoutadditionalActions: Story = {
|
|
185
|
+
args: {
|
|
186
|
+
...Playground.args,
|
|
187
|
+
additionalActions: undefined,
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export const WithoutTabs: Story = {
|
|
192
|
+
args: {
|
|
193
|
+
...Playground.args,
|
|
194
|
+
tabsComponent: undefined,
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export const WithoutSubtitleAndTag: Story = {
|
|
199
|
+
args: {
|
|
200
|
+
...Playground.args,
|
|
201
|
+
subtitle: undefined,
|
|
202
|
+
tagComponent: undefined,
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export const Mobile: Story = {
|
|
207
|
+
parameters: {
|
|
208
|
+
...STORYBOOK_VIEWPORTS,
|
|
209
|
+
layout: "none",
|
|
210
|
+
},
|
|
211
|
+
globals: {
|
|
212
|
+
viewport: { value: "iphone6", isRotated: false },
|
|
213
|
+
},
|
|
214
|
+
args: {
|
|
215
|
+
...Playground.args,
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## How to test this component
|
|
221
|
+
|
|
222
|
+
Here are some more advanced stories with more testing coverage and examples that you can read to understand how to test this component.
|
|
223
|
+
|
|
224
|
+
```tsx
|
|
225
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
226
|
+
import { expect, fn, userEvent, within } from "storybook/test";
|
|
227
|
+
import Header from "../Header";
|
|
228
|
+
import Tag from "../../Tag/Tag";
|
|
229
|
+
import Breadcrumbs from "../../Breadcrumbs/Breadcrumbs";
|
|
230
|
+
import Button from "../../Button/Button";
|
|
231
|
+
import Select from "../../Select/Select";
|
|
232
|
+
import SelectItem from "../../SelectItem/SelectItem";
|
|
233
|
+
import Tabs from "../../Tabs/Tabs/Tabs";
|
|
234
|
+
import Tab from "../../Tabs/Tab/Tab";
|
|
235
|
+
import TabList from "../../Tabs/TabList/TabList";
|
|
236
|
+
import TabPanel from "../../Tabs/TabPanel/TabPanel";
|
|
237
|
+
import styled from "styled-components";
|
|
238
|
+
import * as HeaderMainStory from "../Header.stories";
|
|
239
|
+
|
|
240
|
+
const meta: Meta<typeof Header> = {
|
|
241
|
+
...HeaderMainStory.default,
|
|
242
|
+
component: Header,
|
|
243
|
+
parameters: {
|
|
244
|
+
...HeaderMainStory.default.parameters,
|
|
245
|
+
chromatic: { disableSnapshot: true },
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
export default meta;
|
|
249
|
+
|
|
250
|
+
type Story = StoryObj<typeof meta>;
|
|
251
|
+
|
|
252
|
+
const StyledTabPanel = styled(TabPanel)`
|
|
253
|
+
flex: 1;
|
|
254
|
+
padding: var(--spacing-lg);
|
|
255
|
+
background-color: var(--color-background-neutral-underground-1);
|
|
256
|
+
`;
|
|
257
|
+
|
|
258
|
+
export const FullFeatured: Story = {
|
|
259
|
+
render: () => (
|
|
260
|
+
<Header
|
|
261
|
+
title="Insert title"
|
|
262
|
+
subtitle="Insert subtitle"
|
|
263
|
+
tagComponent={<Tag iconLeft="help_outline">[Insert tag]</Tag>}
|
|
264
|
+
onGoBack={fn()}
|
|
265
|
+
breadcrumbsComponent={
|
|
266
|
+
<Breadcrumbs
|
|
267
|
+
links={[
|
|
268
|
+
{ href: "#link-1", text: "Link 1" },
|
|
269
|
+
{ href: "#link-2", text: "Link 2" },
|
|
270
|
+
{ href: "#link-3", text: "Link 3" },
|
|
271
|
+
]}
|
|
272
|
+
/>
|
|
273
|
+
}
|
|
274
|
+
helperIconComponent={
|
|
275
|
+
<Button
|
|
276
|
+
iconLeft="help_outline"
|
|
277
|
+
onClick={() => alert("Help")}
|
|
278
|
+
mode="tertiary"
|
|
279
|
+
/>
|
|
280
|
+
}
|
|
281
|
+
notificationIconComponent={
|
|
282
|
+
<Button
|
|
283
|
+
iconLeft="notifications_none"
|
|
284
|
+
onClick={() => alert("Notifications")}
|
|
285
|
+
mode="tertiary"
|
|
286
|
+
/>
|
|
287
|
+
}
|
|
288
|
+
additionalActions={
|
|
289
|
+
<Select
|
|
290
|
+
mode="single"
|
|
291
|
+
id="select"
|
|
292
|
+
aria-label="Select"
|
|
293
|
+
value={null}
|
|
294
|
+
onChange={fn()}
|
|
295
|
+
placeholder="Select"
|
|
296
|
+
>
|
|
297
|
+
<SelectItem id="select-item-1" text="Item 1" />
|
|
298
|
+
<SelectItem id="select-item-2" text="Item 2" />
|
|
299
|
+
<SelectItem id="select-item-3" text="Item 3" />
|
|
300
|
+
</Select>
|
|
301
|
+
}
|
|
302
|
+
tabsComponent={
|
|
303
|
+
<Tabs>
|
|
304
|
+
<TabList>
|
|
305
|
+
<Tab id="tab-1">Tab 1</Tab>
|
|
306
|
+
<Tab id="tab-2" badgeProps={{ nature: "negative", variant: "dot" }}>
|
|
307
|
+
Tab 2
|
|
308
|
+
</Tab>
|
|
309
|
+
<Tab id="tab-3" badgeProps={{ nature: "negative", variant: "dot" }}>
|
|
310
|
+
Tab 3
|
|
311
|
+
</Tab>
|
|
312
|
+
</TabList>
|
|
313
|
+
|
|
314
|
+
{/* StyledPanel is a TabPanel with styled: `flex: 1; padding: var(--spacing-lg); background-color: var(--color-background-neutral-underground-1);` */}
|
|
315
|
+
{/* You need to create it on your side if you want those styles, or just use a TabPanel component directly */}
|
|
316
|
+
<StyledTabPanel id="tab-1">Content for the panel 1</StyledTabPanel>
|
|
317
|
+
<StyledTabPanel id="tab-2">Content for the panel 2</StyledTabPanel>
|
|
318
|
+
<StyledTabPanel id="tab-3">Content for the panel 3</StyledTabPanel>
|
|
319
|
+
</Tabs>
|
|
320
|
+
}
|
|
321
|
+
/>
|
|
322
|
+
),
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
export const ShouldCallOnGoBack: Story = {
|
|
326
|
+
args: {
|
|
327
|
+
...HeaderMainStory.Playground.args,
|
|
328
|
+
},
|
|
329
|
+
play: async ({ canvasElement, args }) => {
|
|
330
|
+
const canvas = within(canvasElement);
|
|
331
|
+
const user = userEvent.setup();
|
|
332
|
+
await user.click(canvas.getByLabelText("Go back"));
|
|
333
|
+
await expect(args.onGoBack).toHaveBeenCalledTimes(1);
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
## Developer notes
|
|
339
|
+
|
|
340
|
+
Here are the notes available for the developer on the built Storybook, you can read them to understand the component and how to use it.
|
|
341
|
+
|
|
342
|
+
```mdx
|
|
343
|
+
import {
|
|
344
|
+
Canvas,
|
|
345
|
+
Meta,
|
|
346
|
+
Stories,
|
|
347
|
+
Controls,
|
|
348
|
+
Source,
|
|
349
|
+
} from "@storybook/addon-docs/blocks";
|
|
350
|
+
|
|
351
|
+
import * as Header from "./Header.stories";
|
|
352
|
+
import * as HeaderTests from "./tests/Header.stories";
|
|
353
|
+
|
|
354
|
+
<Meta of={Header} />
|
|
355
|
+
|
|
356
|
+
# Header
|
|
357
|
+
|
|
358
|
+
<Canvas of={Header.Playground} />
|
|
359
|
+
|
|
360
|
+
## Usage
|
|
361
|
+
|
|
362
|
+
This component does not provide any feature, it's just a wrapper that lets you put the required elements and handle their positioning.
|
|
363
|
+
|
|
364
|
+
Here is a good starting point that handles the most common use cases:
|
|
365
|
+
|
|
366
|
+
<Source of={HeaderTests.FullFeatured} type="code" dark />
|
|
367
|
+
|
|
368
|
+
## Props
|
|
369
|
+
|
|
370
|
+
<Controls of={Header.Playground} />
|
|
371
|
+
|
|
372
|
+
<Stories />
|
|
373
|
+
```
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# I18nProvider
|
|
2
|
+
|
|
3
|
+
## Props
|
|
4
|
+
|
|
5
|
+
The complete Props documentation with JS doc for this component is available at this path:
|
|
6
|
+
|
|
7
|
+
node_modules/@agregio-solutions/design-system/dist/packages/components/I18nProvider/I18nProvider.d.ts
|
|
8
|
+
|
|
9
|
+
## Example usage
|
|
10
|
+
|
|
11
|
+
Here are the Storybook Stories.
|
|
12
|
+
|
|
13
|
+
Base stories:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
17
|
+
import { I18nProvider as AriaI18nProvider } from "react-aria";
|
|
18
|
+
import { fn, within } from "storybook/test";
|
|
19
|
+
import Chip from "@components/Chip/Chip";
|
|
20
|
+
import React from "react";
|
|
21
|
+
import Select from "@components/Select/Select";
|
|
22
|
+
import SelectItem from "@components/SelectItem/SelectItem";
|
|
23
|
+
import { useController, useForm } from "react-hook-form";
|
|
24
|
+
|
|
25
|
+
// Wrapper necessary for Storybook source code parsing
|
|
26
|
+
function I18nProvider({
|
|
27
|
+
locale,
|
|
28
|
+
children,
|
|
29
|
+
}: {
|
|
30
|
+
locale: string;
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
}) {
|
|
33
|
+
return <AriaI18nProvider locale={locale}>{children}</AriaI18nProvider>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const meta: Meta<typeof I18nProvider> = {
|
|
37
|
+
component: I18nProvider,
|
|
38
|
+
argTypes: {
|
|
39
|
+
locale: {
|
|
40
|
+
options: ["en-US", "fr-FR"],
|
|
41
|
+
control: { type: "radio" },
|
|
42
|
+
},
|
|
43
|
+
children: { control: false },
|
|
44
|
+
},
|
|
45
|
+
parameters: {
|
|
46
|
+
layout: "centered",
|
|
47
|
+
chromatic: { disableSnapshot: true },
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
export default meta;
|
|
51
|
+
|
|
52
|
+
export const ChipFR: StoryObj<typeof I18nProvider> = {
|
|
53
|
+
args: {
|
|
54
|
+
locale: "fr-FR",
|
|
55
|
+
children: <Chip value="Item" onClose={fn()} />,
|
|
56
|
+
},
|
|
57
|
+
play: async ({ canvasElement }) => {
|
|
58
|
+
const canvas = within(canvasElement);
|
|
59
|
+
await canvas.findByLabelText("Fermer Item");
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const ChipEN: StoryObj<typeof I18nProvider> = {
|
|
64
|
+
args: {
|
|
65
|
+
locale: "en-US",
|
|
66
|
+
children: <Chip value="Item" onClose={fn()} />,
|
|
67
|
+
},
|
|
68
|
+
play: async ({ canvasElement }) => {
|
|
69
|
+
const canvas = within(canvasElement);
|
|
70
|
+
await canvas.findByLabelText("Close Item");
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const SelectExample = () => {
|
|
75
|
+
const { control } = useForm<any>({
|
|
76
|
+
defaultValues: {
|
|
77
|
+
select: ["1", "2"],
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
const selectField = useController({ control, name: "select" });
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<>
|
|
84
|
+
<div style={{ marginBottom: 16 }}>
|
|
85
|
+
Selected values : {selectField.field.value.join(", ")}
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<Select
|
|
89
|
+
id="my-select"
|
|
90
|
+
label="[Insert label]"
|
|
91
|
+
selectedKeys={selectField.field.value}
|
|
92
|
+
onSelectionChange={selectField.field.onChange}
|
|
93
|
+
mode="multiple"
|
|
94
|
+
placeholder="Please select an option"
|
|
95
|
+
>
|
|
96
|
+
<SelectItem text="Option 1" id="1" />
|
|
97
|
+
<SelectItem text="Option 2" id="2" />
|
|
98
|
+
<SelectItem text="Option 3" id="3" />
|
|
99
|
+
</Select>
|
|
100
|
+
</>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const SelectMultipletEN: StoryObj<typeof I18nProvider> = {
|
|
105
|
+
args: {
|
|
106
|
+
locale: "en-US",
|
|
107
|
+
children: <SelectExample />,
|
|
108
|
+
},
|
|
109
|
+
play: async ({ canvasElement }) => {
|
|
110
|
+
const canvas = within(canvasElement);
|
|
111
|
+
await canvas.findByText("items selected");
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const SelectMultipletFR: StoryObj<typeof I18nProvider> = {
|
|
116
|
+
args: {
|
|
117
|
+
locale: "fr-FR",
|
|
118
|
+
children: <SelectExample />,
|
|
119
|
+
},
|
|
120
|
+
play: async ({ canvasElement }) => {
|
|
121
|
+
const canvas = within(canvasElement);
|
|
122
|
+
await canvas.findByText("éléments sélectionnés");
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Developer notes
|
|
128
|
+
|
|
129
|
+
Here are the notes available for the developer on the built Storybook, you can read them to understand the component and how to use it.
|
|
130
|
+
|
|
131
|
+
````mdx
|
|
132
|
+
import { Meta, Canvas, Controls, Stories } from "@storybook/addon-docs/blocks";
|
|
133
|
+
|
|
134
|
+
import * as I18nProvider from "./I18nProvider.stories";
|
|
135
|
+
|
|
136
|
+
<Meta of={I18nProvider} />
|
|
137
|
+
|
|
138
|
+
# I18nProvider
|
|
139
|
+
|
|
140
|
+
<Canvas of={I18nProvider.ChipFR} />
|
|
141
|
+
|
|
142
|
+
## I18nProvider props
|
|
143
|
+
|
|
144
|
+
<Controls of={I18nProvider.ChipEN} />
|
|
145
|
+
|
|
146
|
+
## Purpose
|
|
147
|
+
|
|
148
|
+
**TL;DR: `I18nProvider` allows you to tell the Design System components in which language they should display their hard-coded text. It does not replace an i18n solution on your side.**
|
|
149
|
+
|
|
150
|
+
Most of the text that can be displayed inside the Design System components is handled by the dev that adds it in a front-end project (i.e. you).
|
|
151
|
+
|
|
152
|
+
The Design System component will then display them exactly as you provided them. So it is your responsibility to handle translation in the languages needed for you users.
|
|
153
|
+
|
|
154
|
+
**But, the Design System also has some text that is not controlled by you**. At 2 levels:
|
|
155
|
+
|
|
156
|
+
- short hard coded texts that are part a component's logic (like the character counter in the text input)
|
|
157
|
+
- invisible texts that are added for screen readers by React Aria
|
|
158
|
+
|
|
159
|
+
By default, those texts will be translated depending on the language set in the browser.
|
|
160
|
+
But you can force the displayed language using the `I18nProvider` component as a global Provider.
|
|
161
|
+
|
|
162
|
+
Use it like any other global provider you may have (you only need it once for the whole project):
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
import { I18nProvider } from "@agregio-solutions/design-system";
|
|
166
|
+
|
|
167
|
+
<I18nProvider lang="fr-FR">
|
|
168
|
+
<App />
|
|
169
|
+
</I18nProvider>;
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Available languages
|
|
173
|
+
|
|
174
|
+
For now, the Design System only supports **English** and **French**.
|
|
175
|
+
|
|
176
|
+
If you need another language, please contact the Design System team, we will add it for you!
|
|
177
|
+
|
|
178
|
+
## SSR hydration mismatch errors
|
|
179
|
+
|
|
180
|
+
If you are using Server Side Rendering (SSR), then you should use the `I18nProvider` to avoid hydration mismatches.
|
|
181
|
+
|
|
182
|
+
The reason is simple, the server locale and the client locale may not match. Forcing the locale with the `I18nProvider` will ensure that the locale is the same on the server and the client.
|
|
183
|
+
|
|
184
|
+
## Stories (list all components that display translated text to users)
|
|
185
|
+
|
|
186
|
+
<Stories of={I18nProvider} />
|
|
187
|
+
````
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Icon
|
|
2
|
+
|
|
3
|
+
## Props
|
|
4
|
+
|
|
5
|
+
The complete Props documentation with JS doc for this component is available at this path:
|
|
6
|
+
|
|
7
|
+
node_modules/@agregio-solutions/design-system/dist/packages/components/Icon/Icon.d.ts
|
|
8
|
+
|
|
9
|
+
## Example usage
|
|
10
|
+
|
|
11
|
+
Here are the Storybook Stories.
|
|
12
|
+
|
|
13
|
+
Base stories:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
17
|
+
import Icon from "./Icon";
|
|
18
|
+
|
|
19
|
+
const meta: Meta<typeof Icon> = {
|
|
20
|
+
component: Icon,
|
|
21
|
+
parameters: {
|
|
22
|
+
layout: "centered",
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export default meta;
|
|
26
|
+
|
|
27
|
+
export const Playground: StoryObj<typeof Icon> = {
|
|
28
|
+
args: {
|
|
29
|
+
name: "star",
|
|
30
|
+
style: {
|
|
31
|
+
color: "var(--color-content-action-action)",
|
|
32
|
+
fontSize: 30,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Developer notes
|
|
39
|
+
|
|
40
|
+
Here are the notes available for the developer on the built Storybook, you can read them to understand the component and how to use it.
|
|
41
|
+
|
|
42
|
+
```mdx
|
|
43
|
+
import { Meta, IconGallery, IconItem } from "@storybook/addon-docs/blocks";
|
|
44
|
+
import * as IconStories from "./Icon.stories";
|
|
45
|
+
import Icon, { ICON_NAMES_ARRAY } from "./Icon";
|
|
46
|
+
|
|
47
|
+
<Meta of={IconStories} />
|
|
48
|
+
|
|
49
|
+
# List of available icons
|
|
50
|
+
|
|
51
|
+
Here is a list of all available icons:
|
|
52
|
+
|
|
53
|
+
<IconGallery>
|
|
54
|
+
{ICON_NAMES_ARRAY.map((name) => (
|
|
55
|
+
<IconItem key={name} name={name}>
|
|
56
|
+
<Icon
|
|
57
|
+
name={name}
|
|
58
|
+
style={{ color: "var(--color-content-action-action)" }}
|
|
59
|
+
/>
|
|
60
|
+
</IconItem>
|
|
61
|
+
))}
|
|
62
|
+
</IconGallery>
|
|
63
|
+
```
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Label
|
|
2
|
+
|
|
3
|
+
## Props
|
|
4
|
+
|
|
5
|
+
The complete Props documentation with JS doc for this component is available at this path:
|
|
6
|
+
|
|
7
|
+
node_modules/@agregio-solutions/design-system/dist/packages/components/Label/Label.d.ts
|
|
8
|
+
|
|
9
|
+
## Example usage
|
|
10
|
+
|
|
11
|
+
Here are the Storybook Stories.
|
|
12
|
+
|
|
13
|
+
Base stories:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
17
|
+
import { within } from "storybook/test";
|
|
18
|
+
|
|
19
|
+
import Label from "./Label";
|
|
20
|
+
|
|
21
|
+
const meta: Meta<typeof Label> = {
|
|
22
|
+
component: Label,
|
|
23
|
+
tags: ["autodocs"],
|
|
24
|
+
parameters: {
|
|
25
|
+
layout: "centered",
|
|
26
|
+
chromatic: { disableSnapshot: true },
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export default meta;
|
|
30
|
+
|
|
31
|
+
export const WithIconTooltip: StoryObj<typeof Label> = {
|
|
32
|
+
args: {
|
|
33
|
+
htmlForId: "input",
|
|
34
|
+
label: "[Insert label]",
|
|
35
|
+
labelIconRight: "help_outline",
|
|
36
|
+
labelIconRightTooltip: "This field requires a specific format",
|
|
37
|
+
},
|
|
38
|
+
play: async ({ canvasElement }) => {
|
|
39
|
+
const canvas = within(canvasElement);
|
|
40
|
+
await canvas.findByText("[Insert label]");
|
|
41
|
+
await canvas.findByRole("button", {
|
|
42
|
+
name: "This field requires a specific format",
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Playground: StoryObj<typeof Label> = {
|
|
48
|
+
args: {
|
|
49
|
+
htmlForId: "input",
|
|
50
|
+
label: "[Insert label]",
|
|
51
|
+
labelIconRight: "help_outline",
|
|
52
|
+
required: true,
|
|
53
|
+
},
|
|
54
|
+
play: async ({ canvasElement }) => {
|
|
55
|
+
const canvas = within(canvasElement);
|
|
56
|
+
await canvas.findByTitle("Required");
|
|
57
|
+
await canvas.findByText("[Insert label]");
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
```
|