@webiny/admin-ui 6.2.0-beta.0 → 6.3.0-beta.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/Accordion/Accordion.d.ts +1 -1
- package/Accordion/Accordion.mdx +437 -463
- package/Accordion/components/AccordionContent.js.map +1 -1
- package/Alert/Alert.d.ts +1 -1
- package/Alert/Alert.js.map +1 -1
- package/Alert/Alert.mdx +80 -83
- package/AutoComplete/AutoComplete.mdx +63 -55
- package/Avatar/Avatar.d.ts +1 -1
- package/Avatar/Avatar.js.map +1 -1
- package/Avatar/Avatar.mdx +52 -43
- package/Button/Button.d.ts +1 -1
- package/Button/Button.js.map +1 -1
- package/Button/Button.mdx +50 -42
- package/Button/IconButton.d.ts +1 -1
- package/Button/IconButton.js.map +1 -1
- package/Card/components/CardContent.d.ts +1 -1
- package/Card/components/CardTitle.d.ts +1 -1
- package/Checkbox/Checkbox.mdx +51 -49
- package/Checkbox/primitives/CheckboxPrimitive.d.ts +1 -1
- package/CheckboxGroup/CheckboxGroup.mdx +51 -53
- package/CodeEditor/CodeEditor.mdx +44 -43
- package/ColorPicker/ColorPicker.mdx +41 -40
- package/Command/components/Item.d.ts +1 -1
- package/Command/components/Item.js.map +1 -1
- package/DataTable/DataTable.mdx +537 -542
- package/DataTable/components/ColumnSorter.d.ts +1 -1
- package/DataTable/components/ColumnSorter.js.map +1 -1
- package/Dialog/Dialog.js.map +1 -1
- package/Dialog/components/DialogContent.d.ts +1 -1
- package/Dialog/components/DialogContent.js +1 -1
- package/Dialog/components/DialogContent.js.map +1 -1
- package/Dialog/components/DialogFooter.d.ts +1 -1
- package/Dialog/components/DialogFooter.js.map +1 -1
- package/Dialog/components/DialogTitle.d.ts +1 -1
- package/Drawer/Drawer.js.map +1 -1
- package/Drawer/Drawer.mdx +73 -64
- package/Drawer/components/DrawerContent.d.ts +1 -1
- package/Drawer/components/DrawerContent.js.map +1 -1
- package/DropdownMenu/DropdownMenu.js.map +1 -1
- package/DropdownMenu/DropdownMenu.mdx +155 -256
- package/DropdownMenu/components/DropdownMenuCheckboxItem.js.map +1 -1
- package/DropdownMenu/components/DropdownMenuLabel.js.map +1 -1
- package/FilePicker/FilePicker.mdx +69 -69
- package/FilePicker/primitives/FilePickerPrimitive.d.ts +19 -19
- package/FilePicker/primitives/FilePickerPrimitive.js.map +1 -1
- package/FilePicker/primitives/components/Trigger.d.ts +1 -1
- package/FilePicker/primitives/components/previews/TextOnlyPreview/TextOnlyPreview.d.ts +1 -1
- package/FilePicker/primitives/components/previews/variants.d.ts +1 -1
- package/FilePicker/primitives/components/types.js.map +1 -1
- package/FormComponent/Description.d.ts +1 -1
- package/FormComponent/ErrorMessage.d.ts +1 -1
- package/FormComponent/Note.d.ts +1 -1
- package/Grid/Grid.d.ts +2 -2
- package/Grid/Grid.js.map +1 -1
- package/Grid/Grid.mdx +111 -121
- package/HeaderBar/HeaderBar.mdx +98 -99
- package/Heading/Heading.d.ts +1 -1
- package/Heading/Heading.js.map +1 -1
- package/Heading/Heading.mdx +63 -58
- package/Icon/Icon.d.ts +1 -1
- package/Icon/Icon.js.map +1 -1
- package/Icon/Icon.mdx +79 -147
- package/IconPicker/IconPicker.mdx +66 -64
- package/IconPicker/primitives/IconPickerPrimitive.d.ts +1 -1
- package/IconPicker/primitives/components/IconPickerTrigger.d.ts +1 -1
- package/Image/Image.js.map +1 -1
- package/Input/Input.mdx +67 -56
- package/Input/InputPrimitive.d.ts +1 -1
- package/Label/Label.d.ts +1 -1
- package/Label/Label.js.map +1 -1
- package/Label/Label.mdx +42 -42
- package/Label/components/LabelDescription.d.ts +1 -1
- package/Label/components/LabelRequired.d.ts +1 -1
- package/Label/components/LabelValue.d.ts +1 -1
- package/Link/Link.d.ts +1 -1
- package/Link/Link.mdx +129 -116
- package/List/List.d.ts +1 -1
- package/List/List.js.map +1 -1
- package/List/List.mdx +317 -329
- package/List/components/ListItem.d.ts +1 -1
- package/List/components/ListItem.js.map +1 -1
- package/Loader/Loader.d.ts +2 -2
- package/Loader/Loader.js.map +1 -1
- package/Loader/Loader.mdx +96 -91
- package/MultiAutoComplete/MultiAutoComplete.mdx +52 -51
- package/MultiAutoComplete/primitives/components/MultiAutoCompleteInput.d.ts +1 -1
- package/MultiAutoComplete/primitives/presenters/MultiAutoCompleteListOptionsPresenter.js.map +1 -1
- package/MultiAutoComplete/primitives/presenters/MultiAutoCompleteListOptionsPresenterWithUniqueValues.js.map +1 -1
- package/MultiAutoComplete/primitives/presenters/MultiAutoCompleteSelectedOptionsPresenter.js.map +1 -1
- package/MultiAutoComplete/primitives/presenters/MultiAutoCompleteTemporaryOptionPresenter.js.map +1 -1
- package/MultiFilePicker/MultiFilePicker.mdx +84 -80
- package/MultiFilePicker/primitives/MultiFilePickerPrimitive.js.map +1 -1
- package/Popover/Popover.mdx +112 -118
- package/Popover/primitives/components/PopoverArrow.d.ts +1 -1
- package/Popover/primitives/components/PopoverContent.d.ts +1 -1
- package/RadioGroup/RadioGroup.mdx +62 -59
- package/RadioGroup/primitives/RadioGroupPrimitive.js.map +1 -1
- package/RangeSlider/RangeSlider.mdx +48 -47
- package/RangeSlider/primitives/RangeSliderPrimitive.js.map +1 -1
- package/RangeSlider/primitives/components/RangeSliderValue.d.ts +1 -1
- package/RangeSlider/primitives/components/RangeSliderValue.js.map +1 -1
- package/ScrollArea/ScrollArea.js.map +1 -1
- package/SegmentedControl/SegmentedControl.mdx +59 -59
- package/SegmentedControl/primitives/SegmentedControlPrimitive.d.ts +1 -1
- package/SegmentedControl/primitives/SegmentedControlPrimitive.js.map +1 -1
- package/Select/Select.mdx +52 -43
- package/Select/primitives/components/SelectTrigger.d.ts +1 -1
- package/Select/primitives/components/SelectTrigger.js.map +1 -1
- package/Select/primitives/presenters/SelectPresenter.d.ts +1 -1
- package/Separator/Separator.d.ts +1 -1
- package/Separator/Separator.mdx +139 -150
- package/Sidebar/Sidebar.js.map +1 -1
- package/Sidebar/Sidebar.mdx +66 -88
- package/Sidebar/components/items/SidebarMenuSubItemIndentation.d.ts +1 -1
- package/Sidebar/components/items/SidebarMenuSubItemIndentation.js.map +1 -1
- package/Skeleton/Skeleton.d.ts +1 -1
- package/Skeleton/Skeleton.js.map +1 -1
- package/Skeleton/Skeleton.mdx +37 -37
- package/Slider/Slider.mdx +48 -47
- package/Slider/primitives/SliderPrimitive.js.map +1 -1
- package/Slider/primitives/components/SliderSideValue.d.ts +1 -1
- package/Slider/primitives/components/SliderSideValue.js.map +1 -1
- package/Slider/primitives/components/SliderTooltip.d.ts +1 -1
- package/SteppedProgress/components/SteppedProgressIcon.d.ts +1 -1
- package/SteppedProgress/components/SteppedProgressIcon.js.map +1 -1
- package/SteppedProgress/components/SteppedProgressIndicator.d.ts +1 -1
- package/SteppedProgress/components/SteppedProgressIndicator.js.map +1 -1
- package/Switch/Switch.mdx +44 -42
- package/Switch/primitives/SwitchPrimitive.d.ts +1 -1
- package/Table/Table.d.ts +1 -1
- package/Table/Table.js.map +1 -1
- package/Table/components/Direction.d.ts +1 -1
- package/Table/components/Direction.js.map +1 -1
- package/Table/components/Header.d.ts +1 -1
- package/Table/components/Header.js.map +1 -1
- package/Table/components/Resizer.d.ts +1 -1
- package/Table/components/Resizer.js.map +1 -1
- package/Table/components/Row.d.ts +1 -1
- package/Table/components/Row.js.map +1 -1
- package/Tabs/Tabs.mdx +297 -292
- package/Tabs/components/Content.d.ts +1 -1
- package/Tabs/components/List.d.ts +1 -1
- package/Tabs/components/Trigger.d.ts +1 -1
- package/Tag/Tag.d.ts +1 -1
- package/Tag/Tag.js.map +1 -1
- package/Tag/Tag.mdx +68 -64
- package/Tags/primitives/TagsPrimitive.js.map +1 -1
- package/Text/Text.d.ts +1 -1
- package/Text/Text.mdx +54 -48
- package/Textarea/Textarea.mdx +49 -39
- package/Textarea/TextareaPrimitive.d.ts +1 -1
- package/Textarea/TextareaPrimitive.js.map +1 -1
- package/Toast/Toast.mdx +63 -53
- package/Toast/components/ToastRoot.d.ts +1 -1
- package/Tooltip/Tooltip.mdx +197 -198
- package/Tooltip/components/TooltipArrow.d.ts +1 -1
- package/Tooltip/components/TooltipContent.d.ts +1 -1
- package/Tree/components/Item.d.ts +1 -1
- package/Tree/useTree.d.ts +1 -1
- package/Widget/components/WidgetContent.d.ts +1 -1
- package/package.json +15 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Canvas, Meta, Controls } from
|
|
1
|
+
import { Canvas, Meta, Controls } from "@storybook/addon-docs/blocks";
|
|
2
2
|
|
|
3
|
-
import * as IconPickerStories from
|
|
3
|
+
import * as IconPickerStories from "./IconPicker.stories";
|
|
4
4
|
|
|
5
5
|
<Meta of={IconPickerStories} />
|
|
6
6
|
|
|
@@ -20,8 +20,8 @@ import { fas } from "@fortawesome/free-solid-svg-icons";
|
|
|
20
20
|
library.add(fas as any);
|
|
21
21
|
|
|
22
22
|
const IconPickerExample = () => {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const [selectedIcon, setSelectedIcon] = useState("");
|
|
24
|
+
const [validation, setValidation] = useState({ isValid: true, message: "" });
|
|
25
25
|
|
|
26
26
|
const handleChange = (newIcon: string) => {
|
|
27
27
|
setSelectedIcon(newIcon);
|
|
@@ -52,22 +52,23 @@ const IconPickerExample = () => {
|
|
|
52
52
|
validation={validation}
|
|
53
53
|
/>
|
|
54
54
|
);
|
|
55
|
+
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
export default IconPickerExample;
|
|
58
59
|
|
|
59
60
|
` } }
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
additionalActions={[
|
|
62
|
+
{
|
|
63
|
+
title: 'Open in GitHub',
|
|
64
|
+
onClick: () => {
|
|
65
|
+
window.open(
|
|
66
|
+
'https://github.com/webiny/webiny-js/blob/feat/new-admin-ui/packages/admin-ui/src/IconPicker/IconPicker.tsx',
|
|
67
|
+
'_blank'
|
|
68
|
+
);
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
]}
|
|
71
72
|
/>
|
|
72
73
|
|
|
73
74
|
<Controls of={IconPickerStories.Documentation} exclude={"onChange"} />
|
|
@@ -82,38 +83,39 @@ import { fas } from "@fortawesome/free-solid-svg-icons";
|
|
|
82
83
|
library.add(fas as any);
|
|
83
84
|
|
|
84
85
|
const IconPickerExample = () => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
86
|
+
const [selectedIcon, setSelectedIcon] = useState("");
|
|
87
|
+
const [validation, setValidation] = useState({ isValid: true, message: "" });
|
|
88
|
+
|
|
89
|
+
const handleChange = (newIcon: string) => {
|
|
90
|
+
setSelectedIcon(newIcon);
|
|
91
|
+
|
|
92
|
+
if (!newIcon && true) {
|
|
93
|
+
// true represents required field
|
|
94
|
+
setValidation({ isValid: false, message: "Please select an icon" });
|
|
95
|
+
} else {
|
|
96
|
+
setValidation({ isValid: true, message: "" });
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<IconPicker
|
|
102
|
+
label="Select an Icon"
|
|
103
|
+
description="Choose an icon for your button"
|
|
104
|
+
note="Note: The selected icon will be displayed on your button"
|
|
105
|
+
required={true}
|
|
106
|
+
icons={[
|
|
107
|
+
{ prefix: "fas", name: "trash-restore-alt" },
|
|
108
|
+
{ prefix: "fas", name: "file-pen" },
|
|
109
|
+
{ prefix: "fas", name: "receipt" },
|
|
110
|
+
{ prefix: "fas", name: "user-circle" },
|
|
111
|
+
{ prefix: "fas", name: "circle-user" }
|
|
112
|
+
// Add more icons as needed
|
|
113
|
+
]}
|
|
114
|
+
value={selectedIcon}
|
|
115
|
+
onChange={handleChange}
|
|
116
|
+
validation={validation}
|
|
117
|
+
/>
|
|
118
|
+
);
|
|
117
119
|
};
|
|
118
120
|
|
|
119
121
|
export default IconPickerExample;
|
|
@@ -146,29 +148,29 @@ const definitions = (library as any).definitions;
|
|
|
146
148
|
const allIcons: IconPickerIconDto[] = [];
|
|
147
149
|
|
|
148
150
|
Object.keys(definitions)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
151
|
+
.filter((pack): pack is IconPrefix => validPrefixes.includes(pack as IconPrefix))
|
|
152
|
+
.forEach(prefix => {
|
|
153
|
+
const icons = definitions[prefix];
|
|
154
|
+
Object.keys(icons).forEach(icon => {
|
|
155
|
+
allIcons.push({
|
|
156
|
+
prefix,
|
|
157
|
+
name: icon as IconName
|
|
158
|
+
});
|
|
158
159
|
});
|
|
160
|
+
});
|
|
159
161
|
```
|
|
160
162
|
|
|
161
163
|
You can then pass the `allIcons` array to the `IconPicker` component:
|
|
162
164
|
|
|
163
165
|
```tsx
|
|
164
166
|
<IconPicker
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
167
|
+
label="Select an Icon"
|
|
168
|
+
description="Choose an icon for your button"
|
|
169
|
+
note="Note: The selected icon will be displayed on your button"
|
|
170
|
+
required={true}
|
|
171
|
+
icons={allIcons}
|
|
172
|
+
value={selectedIcon}
|
|
173
|
+
onChange={handleChange}
|
|
174
|
+
validation={validation}
|
|
173
175
|
/>
|
|
174
176
|
```
|
|
@@ -5,7 +5,7 @@ import type { IconPickerIconDto } from "../domains/index.js";
|
|
|
5
5
|
declare const iconPickerVariants: (props?: ({
|
|
6
6
|
size?: "md" | "lg" | "xl" | null | undefined;
|
|
7
7
|
disabled?: boolean | null | undefined;
|
|
8
|
-
} & import("class-variance-authority/
|
|
8
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
9
|
interface IconPickerPrimitiveProps extends VariantProps<typeof iconPickerVariants> {
|
|
10
10
|
/**
|
|
11
11
|
* Indicates if the field is disabled.
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { type VariantProps } from "../../../utils.js";
|
|
3
3
|
declare const iconPickerTriggerVariants: (props?: ({
|
|
4
4
|
size?: "md" | "lg" | "xl" | null | undefined;
|
|
5
|
-
} & import("class-variance-authority/
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
6
|
interface IconPickerTriggerProps extends VariantProps<typeof iconPickerTriggerVariants> {
|
|
7
7
|
value?: string;
|
|
8
8
|
}
|
package/Image/Image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Image","rest","finalProps","srcSet","Object","keys","map","key","join","createElement"],"sources":["Image.tsx"],"sourcesContent":["import React from \"react\";\n\n// Accepts all props that a normal <img> element would accept.\ninterface ImageProps
|
|
1
|
+
{"version":3,"names":["React","Image","rest","finalProps","srcSet","Object","keys","map","key","join","createElement"],"sources":["Image.tsx"],"sourcesContent":["import React from \"react\";\n\n// Accepts all props that a normal <img> element would accept.\ninterface ImageProps extends React.DetailedHTMLProps<\n React.ImgHTMLAttributes<HTMLImageElement>,\n HTMLImageElement\n> {\n [key: string]: any;\n}\n\nconst Image = ({ ...rest }: ImageProps) => {\n const finalProps = { ...rest };\n const srcSet = finalProps.srcSet;\n if (srcSet && typeof srcSet === \"object\") {\n finalProps.srcSet = Object.keys(srcSet)\n .map(key => `${srcSet[key]} ${key}`)\n .join(\", \");\n }\n\n return <img {...finalProps} />;\n};\n\nexport { Image, type ImageProps };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;;AAEzB;;AAQA,MAAMC,KAAK,GAAGA,CAAC;EAAE,GAAGC;AAAiB,CAAC,KAAK;EACvC,MAAMC,UAAU,GAAG;IAAE,GAAGD;EAAK,CAAC;EAC9B,MAAME,MAAM,GAAGD,UAAU,CAACC,MAAM;EAChC,IAAIA,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IACtCD,UAAU,CAACC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACF,MAAM,CAAC,CAClCG,GAAG,CAACC,GAAG,IAAI,GAAGJ,MAAM,CAACI,GAAG,CAAC,IAAIA,GAAG,EAAE,CAAC,CACnCC,IAAI,CAAC,IAAI,CAAC;EACnB;EAEA,oBAAOT,KAAA,CAAAU,aAAA,QAASP,UAAa,CAAC;AAClC,CAAC;AAED,SAASF,KAAK","ignoreList":[]}
|
package/Input/Input.mdx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Canvas, Meta, Controls } from
|
|
1
|
+
import { Canvas, Meta, Controls } from "@storybook/addon-docs/blocks";
|
|
2
2
|
|
|
3
|
-
import * as InputStories from
|
|
3
|
+
import * as InputStories from "./Input.stories";
|
|
4
4
|
|
|
5
5
|
<Meta of={InputStories} />
|
|
6
6
|
|
|
@@ -16,8 +16,8 @@ import React, { useState } from "react";
|
|
|
16
16
|
import { Input } from "@webiny/admin-ui";
|
|
17
17
|
|
|
18
18
|
const InputExample = () => {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const [value, setValue] = useState("");
|
|
20
|
+
const [validation, setValidation] = useState({ isValid: true, message: "" });
|
|
21
21
|
|
|
22
22
|
const handleValidation = () => {
|
|
23
23
|
if (!value.trim()) {
|
|
@@ -46,25 +46,26 @@ const InputExample = () => {
|
|
|
46
46
|
/>
|
|
47
47
|
</div>
|
|
48
48
|
);
|
|
49
|
+
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
export default InputExample;
|
|
52
53
|
|
|
53
54
|
` } }
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
additionalActions={[
|
|
56
|
+
{
|
|
57
|
+
title: 'Open in GitHub',
|
|
58
|
+
onClick: () => {
|
|
59
|
+
window.open(
|
|
60
|
+
'https://github.com/webiny/webiny-js/blob/feat/new-admin-ui/packages/admin-ui/src/Input/Input.tsx',
|
|
61
|
+
'_blank'
|
|
62
|
+
);
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
]}
|
|
65
66
|
/>
|
|
66
67
|
|
|
67
|
-
<Controls of={InputStories.Documentation}/>
|
|
68
|
+
<Controls of={InputStories.Documentation} />
|
|
68
69
|
|
|
69
70
|
```jsx
|
|
70
71
|
import React, { useState } from "react";
|
|
@@ -72,36 +73,36 @@ import React, { useState } from "react";
|
|
|
72
73
|
import { Input } from "@webiny/admin-ui";
|
|
73
74
|
|
|
74
75
|
const InputExample = () => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
76
|
+
const [value, setValue] = useState("");
|
|
77
|
+
const [validation, setValidation] = useState({ isValid: true, message: "" });
|
|
78
|
+
|
|
79
|
+
const handleValidation = () => {
|
|
80
|
+
if (!value.trim()) {
|
|
81
|
+
setValidation({ isValid: false, message: "This field is required" });
|
|
82
|
+
} else if (value.trim().length < 3) {
|
|
83
|
+
setValidation({ isValid: false, message: "Must be at least 3 characters long" });
|
|
84
|
+
} else {
|
|
85
|
+
setValidation({ isValid: true, message: "" });
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<div>
|
|
91
|
+
<Input
|
|
92
|
+
type="text"
|
|
93
|
+
label="Full Name"
|
|
94
|
+
description="Enter your full name as it appears on your ID"
|
|
95
|
+
note="This will be used for official documentation"
|
|
96
|
+
placeholder="Enter your full name"
|
|
97
|
+
required={true}
|
|
98
|
+
value={value}
|
|
99
|
+
validation={validation}
|
|
100
|
+
onChange={newValue => setValue(newValue)}
|
|
101
|
+
onBlur={handleValidation}
|
|
102
|
+
onEnter={handleValidation}
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
105
106
|
};
|
|
106
107
|
|
|
107
108
|
export default InputExample;
|
|
@@ -110,6 +111,7 @@ export default InputExample;
|
|
|
110
111
|
## Examples
|
|
111
112
|
|
|
112
113
|
### With Validate Function
|
|
114
|
+
|
|
113
115
|
The Input component supports validation using the validation prop, as shown in the example above.
|
|
114
116
|
For more complex or reusable validation scenarios, you can use the validate prop, which accepts a custom validation function.
|
|
115
117
|
Try entering **exists@** in the input box to see it in action, and click on **Show code** to view the validation function.
|
|
@@ -120,8 +122,8 @@ import React, { useState } from "react";
|
|
|
120
122
|
import { Input } from "@webiny/admin-ui";
|
|
121
123
|
|
|
122
124
|
const EmailInput = () => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
const [value, setValue] = useState("");
|
|
126
|
+
const [validation, setValidation] = useState({ isValid: true, message: undefined });
|
|
125
127
|
|
|
126
128
|
const validate = async () => {
|
|
127
129
|
// Simulate API call delay
|
|
@@ -146,33 +148,42 @@ const EmailInput = () => {
|
|
|
146
148
|
validation={validation}
|
|
147
149
|
/>
|
|
148
150
|
);
|
|
151
|
+
|
|
149
152
|
};` } }
|
|
150
153
|
/>
|
|
151
154
|
|
|
152
155
|
## Anatomy
|
|
153
156
|
|
|
154
157
|
### Input Anatomy
|
|
155
|
-
|
|
158
|
+
|
|
159
|
+
<img src="/images/storybook/input/anatomy.png" alt="Input Anatomy" />
|
|
156
160
|
|
|
157
161
|
### Styles
|
|
158
|
-
|
|
162
|
+
|
|
163
|
+
<img src="/images/storybook/input/styles.png" alt="Styles" />
|
|
159
164
|
|
|
160
165
|
### Field Size
|
|
161
|
-
|
|
166
|
+
|
|
167
|
+
<img src="/images/storybook/input/field-size.png" alt="Field Size" />
|
|
162
168
|
|
|
163
169
|
### States and Styles
|
|
164
|
-
|
|
170
|
+
|
|
171
|
+
<img src="/images/storybook/input/states-and-styles.png" alt="States and Styles" />
|
|
165
172
|
|
|
166
173
|
### Label Anatomy
|
|
167
|
-
|
|
174
|
+
|
|
175
|
+
<img src="/images/storybook/input/label-anatomy.png" alt="Label Anatomy" />
|
|
168
176
|
|
|
169
177
|
### Label Properties
|
|
170
|
-
|
|
178
|
+
|
|
179
|
+
<img src="/images/storybook/input/label-properties.png" alt="Label Properties" />
|
|
171
180
|
|
|
172
181
|
### Label Options
|
|
173
|
-
|
|
182
|
+
|
|
183
|
+
<img src="/images/storybook/input/label-options.png" alt="Label Options" />
|
|
174
184
|
|
|
175
185
|
## Usage
|
|
176
186
|
|
|
177
187
|
### Used in forms
|
|
178
|
-
|
|
188
|
+
|
|
189
|
+
<img src="/images/storybook/input/used-in-forms.png" alt="Used in forms" />
|
|
@@ -17,7 +17,7 @@ declare const inputVariants: (props?: ({
|
|
|
17
17
|
size?: "md" | "lg" | "xl" | null | undefined;
|
|
18
18
|
variant?: "primary" | "secondary" | "ghost" | "ghost-negative" | null | undefined;
|
|
19
19
|
invalid?: boolean | null | undefined;
|
|
20
|
-
} & import("class-variance-authority/
|
|
20
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
21
21
|
type InputPrimitiveProps<TValue = any> = Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "onChange"> & VariantProps<typeof inputVariants> & {
|
|
22
22
|
/**
|
|
23
23
|
* Icon to be displayed at the start of the input field.
|
package/Label/Label.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare const labelVariants: (props?: ({
|
|
|
5
5
|
weight?: "strong" | "light" | null | undefined;
|
|
6
6
|
disabled?: boolean | null | undefined;
|
|
7
7
|
invalid?: boolean | null | undefined;
|
|
8
|
-
} & import("class-variance-authority/
|
|
8
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
9
|
interface LabelProps extends Omit<React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>, "children">, VariantProps<typeof labelVariants> {
|
|
10
10
|
text: React.ReactNode;
|
|
11
11
|
value?: React.ReactNode;
|
package/Label/Label.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Label","LabelPrimitive","cn","makeDecoratable","cva","LabelDescription","LabelHint","LabelRequired","LabelValue","useAdminUi","labelVariants","variants","weight","strong","light","disabled","true","invalid","defaultVariants","LabelBase","className","description","hint","required","value","text","props","compileMarkdown","createElement","Root","Object","assign","content"],"sources":["Label.tsx"],"sourcesContent":["import React from \"react\";\nimport { Label as LabelPrimitive } from \"radix-ui\";\nimport { cn, makeDecoratable, cva, type VariantProps } from \"~/utils.js\";\nimport { LabelDescription, LabelHint, LabelRequired, LabelValue } from \"./components/index.js\";\nimport { useAdminUi } from \"~/AdminUiProvider/index.js\";\n\nconst labelVariants = cva(\n [\n \"inline-flex items-center justify-between w-full text-sm\",\n \"text-neutral-primary whitespace-nowrap\",\n \"peer-disabled:text-neutral-disabled peer-disabled:cursor-not-allowed\"\n ],\n {\n variants: {\n weight: {\n strong: \"font-semibold\",\n light: \"font-regular\"\n },\n disabled: {\n true: \"text-neutral-disabled cursor-not-allowed\"\n },\n invalid: {\n true: \"webiny_label-invalid\"\n }\n },\n defaultVariants: {\n weight: \"strong\"\n }\n }\n);\n\ninterface LabelProps\n extends
|
|
1
|
+
{"version":3,"names":["React","Label","LabelPrimitive","cn","makeDecoratable","cva","LabelDescription","LabelHint","LabelRequired","LabelValue","useAdminUi","labelVariants","variants","weight","strong","light","disabled","true","invalid","defaultVariants","LabelBase","className","description","hint","required","value","text","props","compileMarkdown","createElement","Root","Object","assign","content"],"sources":["Label.tsx"],"sourcesContent":["import React from \"react\";\nimport { Label as LabelPrimitive } from \"radix-ui\";\nimport { cn, makeDecoratable, cva, type VariantProps } from \"~/utils.js\";\nimport { LabelDescription, LabelHint, LabelRequired, LabelValue } from \"./components/index.js\";\nimport { useAdminUi } from \"~/AdminUiProvider/index.js\";\n\nconst labelVariants = cva(\n [\n \"inline-flex items-center justify-between w-full text-sm\",\n \"text-neutral-primary whitespace-nowrap\",\n \"peer-disabled:text-neutral-disabled peer-disabled:cursor-not-allowed\"\n ],\n {\n variants: {\n weight: {\n strong: \"font-semibold\",\n light: \"font-regular\"\n },\n disabled: {\n true: \"text-neutral-disabled cursor-not-allowed\"\n },\n invalid: {\n true: \"webiny_label-invalid\"\n }\n },\n defaultVariants: {\n weight: \"strong\"\n }\n }\n);\n\ninterface LabelProps\n extends\n Omit<React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>, \"children\">,\n VariantProps<typeof labelVariants> {\n text: React.ReactNode;\n value?: React.ReactNode;\n description?: React.ReactNode;\n hint?: React.ReactNode;\n required?: boolean;\n disabled?: boolean;\n}\n\nconst LabelBase = ({\n className,\n disabled,\n description,\n hint,\n required,\n value,\n text,\n weight,\n invalid,\n ...props\n}: LabelProps) => {\n const { compileMarkdown } = useAdminUi();\n\n if (!text) {\n return null;\n }\n\n return (\n <LabelPrimitive.Root\n className={cn(labelVariants({ weight, disabled, invalid }), className)}\n {...props}\n >\n <span>\n <span className={\"flex items-center gap-xxs\"}>\n <span className={\"webiny_label-text\"}>{text}</span>\n {description && (\n <LabelDescription\n content={compileMarkdown(description)}\n disabled={disabled}\n />\n )}\n {hint && <LabelHint content={compileMarkdown(hint)} />}\n {required && <LabelRequired disabled={disabled} />}\n </span>\n </span>\n {value && <LabelValue value={value} weight={weight} disabled={disabled} />}\n </LabelPrimitive.Root>\n );\n};\n\nconst Label = makeDecoratable(\"Label\", LabelBase);\n\nexport { Label, type LabelProps };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,KAAK,IAAIC,cAAc,QAAQ,UAAU;AAClD,SAASC,EAAE,EAAEC,eAAe,EAAEC,GAAG;AACjC,SAASC,gBAAgB,EAAEC,SAAS,EAAEC,aAAa,EAAEC,UAAU;AAC/D,SAASC,UAAU;AAEnB,MAAMC,aAAa,GAAGN,GAAG,CACrB,CACI,yDAAyD,EACzD,wCAAwC,EACxC,sEAAsE,CACzE,EACD;EACIO,QAAQ,EAAE;IACNC,MAAM,EAAE;MACJC,MAAM,EAAE,eAAe;MACvBC,KAAK,EAAE;IACX,CAAC;IACDC,QAAQ,EAAE;MACNC,IAAI,EAAE;IACV,CAAC;IACDC,OAAO,EAAE;MACLD,IAAI,EAAE;IACV;EACJ,CAAC;EACDE,eAAe,EAAE;IACbN,MAAM,EAAE;EACZ;AACJ,CACJ,CAAC;AAcD,MAAMO,SAAS,GAAGA,CAAC;EACfC,SAAS;EACTL,QAAQ;EACRM,WAAW;EACXC,IAAI;EACJC,QAAQ;EACRC,KAAK;EACLC,IAAI;EACJb,MAAM;EACNK,OAAO;EACP,GAAGS;AACK,CAAC,KAAK;EACd,MAAM;IAAEC;EAAgB,CAAC,GAAGlB,UAAU,CAAC,CAAC;EAExC,IAAI,CAACgB,IAAI,EAAE;IACP,OAAO,IAAI;EACf;EAEA,oBACI1B,KAAA,CAAA6B,aAAA,CAAC3B,cAAc,CAAC4B,IAAI,EAAAC,MAAA,CAAAC,MAAA;IAChBX,SAAS,EAAElB,EAAE,CAACQ,aAAa,CAAC;MAAEE,MAAM;MAAEG,QAAQ;MAAEE;IAAQ,CAAC,CAAC,EAAEG,SAAS;EAAE,GACnEM,KAAK,gBAET3B,KAAA,CAAA6B,aAAA,4BACI7B,KAAA,CAAA6B,aAAA;IAAMR,SAAS,EAAE;EAA4B,gBACzCrB,KAAA,CAAA6B,aAAA;IAAMR,SAAS,EAAE;EAAoB,GAAEK,IAAW,CAAC,EAClDJ,WAAW,iBACRtB,KAAA,CAAA6B,aAAA,CAACvB,gBAAgB;IACb2B,OAAO,EAAEL,eAAe,CAACN,WAAW,CAAE;IACtCN,QAAQ,EAAEA;EAAS,CACtB,CACJ,EACAO,IAAI,iBAAIvB,KAAA,CAAA6B,aAAA,CAACtB,SAAS;IAAC0B,OAAO,EAAEL,eAAe,CAACL,IAAI;EAAE,CAAE,CAAC,EACrDC,QAAQ,iBAAIxB,KAAA,CAAA6B,aAAA,CAACrB,aAAa;IAACQ,QAAQ,EAAEA;EAAS,CAAE,CAC/C,CACJ,CAAC,EACNS,KAAK,iBAAIzB,KAAA,CAAA6B,aAAA,CAACpB,UAAU;IAACgB,KAAK,EAAEA,KAAM;IAACZ,MAAM,EAAEA,MAAO;IAACG,QAAQ,EAAEA;EAAS,CAAE,CACxD,CAAC;AAE9B,CAAC;AAED,MAAMf,KAAK,GAAGG,eAAe,CAAC,OAAO,EAAEgB,SAAS,CAAC;AAEjD,SAASnB,KAAK","ignoreList":[]}
|
package/Label/Label.mdx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Canvas, Meta, Controls } from
|
|
1
|
+
import { Canvas, Meta, Controls } from "@storybook/addon-docs/blocks";
|
|
2
2
|
|
|
3
|
-
import * as LabelStories from
|
|
3
|
+
import * as LabelStories from "./Label.stories";
|
|
4
4
|
|
|
5
5
|
<Meta of={LabelStories} />
|
|
6
6
|
|
|
@@ -12,7 +12,6 @@ The Label component is a fundamental UI element used to provide clear text descr
|
|
|
12
12
|
It enhances usability by clearly identifying input fields and improves accessibility by properly associating labels with their corresponding form elements using htmlFor.
|
|
13
13
|
The component supports a range of customization options, including descriptions, hints, required indicators, disabled and invalid states, and visual weight variants.
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
## Usage
|
|
17
16
|
|
|
18
17
|
<Canvas of={LabelStories.Documentation} source={ { code: `
|
|
@@ -20,7 +19,7 @@ import React, { useState } from "react";
|
|
|
20
19
|
import { Label, Input } from "@webiny/admin-ui";
|
|
21
20
|
|
|
22
21
|
const LabelExample = () => {
|
|
23
|
-
|
|
22
|
+
const [value, setValue] = useState("");
|
|
24
23
|
|
|
25
24
|
return (
|
|
26
25
|
<div className="mb-4 space-y-2">
|
|
@@ -47,22 +46,23 @@ const LabelExample = () => {
|
|
|
47
46
|
/>
|
|
48
47
|
</div>
|
|
49
48
|
);
|
|
49
|
+
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
export default LabelExample;
|
|
53
53
|
|
|
54
54
|
` } }
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
additionalActions={[
|
|
56
|
+
{
|
|
57
|
+
title: 'Open in GitHub',
|
|
58
|
+
onClick: () => {
|
|
59
|
+
window.open(
|
|
60
|
+
'https://github.com/webiny/webiny-js/blob/feat/new-admin-ui/packages/admin-ui/src/Label/Label.tsx',
|
|
61
|
+
'_blank'
|
|
62
|
+
);
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
]}
|
|
66
66
|
/>
|
|
67
67
|
|
|
68
68
|
<Controls of={LabelStories.Documentation} />
|
|
@@ -72,33 +72,33 @@ import React, { useState } from "react";
|
|
|
72
72
|
import { Label, Input } from "@webiny/admin-ui";
|
|
73
73
|
|
|
74
74
|
const LabelExample = () => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
75
|
+
const [value, setValue] = useState("");
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div className="mb-4 space-y-2">
|
|
79
|
+
<Label
|
|
80
|
+
id="full-name-label"
|
|
81
|
+
htmlFor="full-name"
|
|
82
|
+
text="Full Name"
|
|
83
|
+
description="As shown on your government-issued ID"
|
|
84
|
+
hint="Include middle name if applicable"
|
|
85
|
+
required={true}
|
|
86
|
+
value="Label value will be shown here"
|
|
87
|
+
weight="strong"
|
|
88
|
+
invalid={false}
|
|
89
|
+
disabled={false}
|
|
90
|
+
/>
|
|
91
|
+
|
|
92
|
+
<Input
|
|
93
|
+
id="full-name"
|
|
94
|
+
type="text"
|
|
95
|
+
placeholder="e.g. John Michael Doe"
|
|
96
|
+
required={true}
|
|
97
|
+
value={value}
|
|
98
|
+
onChange={e => setValue(e.target.value)}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
102
|
};
|
|
103
103
|
|
|
104
104
|
export default LabelExample;
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { type VariantProps } from "../../utils.js";
|
|
3
3
|
declare const labelDescriptionVariants: (props?: ({
|
|
4
4
|
disabled?: boolean | null | undefined;
|
|
5
|
-
} & import("class-variance-authority/
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
6
|
interface LabelDescriptionProps extends VariantProps<typeof labelDescriptionVariants> {
|
|
7
7
|
content: React.ReactNode;
|
|
8
8
|
}
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { type VariantProps } from "../../utils.js";
|
|
3
3
|
declare const labelRequiredVariants: (props?: ({
|
|
4
4
|
disabled?: boolean | null | undefined;
|
|
5
|
-
} & import("class-variance-authority/
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
6
|
type LabelRequiredProps = VariantProps<typeof labelRequiredVariants>;
|
|
7
7
|
declare const LabelRequired: ({ disabled }: LabelRequiredProps) => React.JSX.Element;
|
|
8
8
|
export { LabelRequired, type LabelRequiredProps };
|
|
@@ -3,7 +3,7 @@ import { type VariantProps } from "../../utils.js";
|
|
|
3
3
|
declare const labelValueVariants: (props?: ({
|
|
4
4
|
weight?: "strong" | "light" | null | undefined;
|
|
5
5
|
disabled?: boolean | null | undefined;
|
|
6
|
-
} & import("class-variance-authority/
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
interface LabelValueProps extends VariantProps<typeof labelValueVariants> {
|
|
8
8
|
value: React.ReactNode;
|
|
9
9
|
}
|
package/Link/Link.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare const linkVariants: (props?: ({
|
|
|
5
5
|
size?: "sm" | "md" | "lg" | "xl" | "inherit" | null | undefined;
|
|
6
6
|
variant?: "primary" | "secondary" | "primary-negative" | "secondary-negative" | null | undefined;
|
|
7
7
|
underline?: boolean | null | undefined;
|
|
8
|
-
} & import("class-variance-authority/
|
|
8
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
9
|
export type LinkProps = LinkComponentProps & VariantProps<typeof linkVariants> & {
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
};
|