@webiny/admin-ui 6.2.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
package/Textarea/Textarea.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 TextareaStories from
|
|
3
|
+
import * as TextareaStories from "./Textarea.stories";
|
|
4
4
|
|
|
5
5
|
<Meta of={TextareaStories} />
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ import React, { useState } from "react";
|
|
|
16
16
|
import { Textarea } from "@webiny/admin-ui";
|
|
17
17
|
|
|
18
18
|
const TextareaExample = () => {
|
|
19
|
-
|
|
19
|
+
const [value, setValue] = useState("");
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
22
|
<Textarea
|
|
@@ -29,25 +29,26 @@ const TextareaExample = () => {
|
|
|
29
29
|
onChange={newValue => setValue(newValue)}
|
|
30
30
|
/>
|
|
31
31
|
);
|
|
32
|
+
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
export default TextareaExample;
|
|
35
36
|
|
|
36
37
|
`} }
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
additionalActions={[
|
|
39
|
+
{
|
|
40
|
+
title: 'Open in GitHub',
|
|
41
|
+
onClick: () => {
|
|
42
|
+
window.open(
|
|
43
|
+
'https://github.com/webiny/webiny-js/blob/feat/new-admin-ui/packages/admin-ui/src/Textarea/Textarea.tsx',
|
|
44
|
+
'_blank'
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
]}
|
|
48
49
|
/>
|
|
49
50
|
|
|
50
|
-
<Controls of={TextareaStories.Documentation}/>
|
|
51
|
+
<Controls of={TextareaStories.Documentation} />
|
|
51
52
|
|
|
52
53
|
```jsx
|
|
53
54
|
import React, { useState } from "react";
|
|
@@ -55,19 +56,19 @@ import React, { useState } from "react";
|
|
|
55
56
|
import { Textarea } from "@webiny/admin-ui";
|
|
56
57
|
|
|
57
58
|
const TextareaExample = () => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
const [value, setValue] = useState("");
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Textarea
|
|
63
|
+
label="Message"
|
|
64
|
+
description="Enter your feedback or message"
|
|
65
|
+
note="Please be specific and provide relevant details"
|
|
66
|
+
placeholder="Type your message here..."
|
|
67
|
+
required={true}
|
|
68
|
+
value={value}
|
|
69
|
+
onChange={newValue => setValue(newValue)}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
71
72
|
};
|
|
72
73
|
|
|
73
74
|
export default TextareaExample;
|
|
@@ -76,6 +77,7 @@ export default TextareaExample;
|
|
|
76
77
|
## Examples
|
|
77
78
|
|
|
78
79
|
### With Validate Function
|
|
80
|
+
|
|
79
81
|
The Textarea component supports validation using the validation prop, as shown in the example above.
|
|
80
82
|
For more complex or reusable validation scenarios, you can use the validate prop, which accepts a custom validation function.
|
|
81
83
|
Try entering less than 10 characters to see it in action, and click on **Show code** to view the validation function.
|
|
@@ -86,8 +88,8 @@ import React, { useState } from "react";
|
|
|
86
88
|
import { Textarea } from "@webiny/admin-ui";
|
|
87
89
|
|
|
88
90
|
const MessageTextarea = () => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
const [value, setValue] = useState("");
|
|
92
|
+
const [validation, setValidation] = useState({ isValid: true, message: "" });
|
|
91
93
|
|
|
92
94
|
const validate = async () => {
|
|
93
95
|
if (!value.trim()) {
|
|
@@ -110,34 +112,42 @@ const MessageTextarea = () => {
|
|
|
110
112
|
validation={validation}
|
|
111
113
|
/>
|
|
112
114
|
);
|
|
115
|
+
|
|
113
116
|
};` } }
|
|
114
117
|
/>
|
|
115
118
|
|
|
116
|
-
|
|
117
119
|
## Anatomy
|
|
118
120
|
|
|
119
121
|
### Textarea
|
|
120
|
-
|
|
122
|
+
|
|
123
|
+
<img src="/images/storybook/textarea/anatomy.png" alt="Textarea Anatomy" />
|
|
121
124
|
|
|
122
125
|
### Styles
|
|
123
|
-
|
|
126
|
+
|
|
127
|
+
<img src="/images/storybook/textarea/styles.png" alt="Styles" />
|
|
124
128
|
|
|
125
129
|
### Field Size
|
|
126
|
-
|
|
130
|
+
|
|
131
|
+
<img src="/images/storybook/textarea/field-size.png" alt="Field Size" />
|
|
127
132
|
|
|
128
133
|
### States and Styles
|
|
129
|
-
|
|
134
|
+
|
|
135
|
+
<img src="/images/storybook/textarea/states-and-styles.png" alt="States and Styles" />
|
|
130
136
|
|
|
131
137
|
### Label Anatomy
|
|
132
|
-
|
|
138
|
+
|
|
139
|
+
<img src="/images/storybook/textarea/label-anatomy.png" alt="Label Anatomy" />
|
|
133
140
|
|
|
134
141
|
### Label Properties
|
|
135
|
-
|
|
142
|
+
|
|
143
|
+
<img src="/images/storybook/textarea/label-properties.png" alt="Label Properties" />
|
|
136
144
|
|
|
137
145
|
### Label Options
|
|
138
|
-
|
|
146
|
+
|
|
147
|
+
<img src="/images/storybook/textarea/label-options.png" alt="Label Options" />
|
|
139
148
|
|
|
140
149
|
## Usage
|
|
141
150
|
|
|
142
151
|
### Used in forms
|
|
143
|
-
|
|
152
|
+
|
|
153
|
+
<img src="/images/storybook/textarea/used-in-forms.png" alt="Used in forms" />
|
|
@@ -4,7 +4,7 @@ declare const textareaVariants: (props?: ({
|
|
|
4
4
|
variant?: "primary" | "secondary" | "ghost" | "ghost-negative" | null | undefined;
|
|
5
5
|
size?: "md" | "lg" | "xl" | null | undefined;
|
|
6
6
|
invalid?: boolean | null | undefined;
|
|
7
|
-
} & import("class-variance-authority/
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
8
|
interface TextareaPrimitiveProps extends React.ComponentProps<"textarea">, VariantProps<typeof textareaVariants> {
|
|
9
9
|
/**
|
|
10
10
|
* Reference to the textarea element.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","cn","cva","makeDecoratable","textareaVariants","variants","variant","primary","secondary","ghost","size","md","lg","xl","invalid","true","compoundVariants","class","defaultVariants","DecoratableTextareaPrimitive","className","textareaRef","forwardEventOnChange","onChange","originalOnChange","onEnter","onKeyDown","originalOnKeyDown","value","props","useCallback","event","target","e","key","createElement","Object","assign","ref","TextareaPrimitive"],"sources":["TextareaPrimitive.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn, cva, makeDecoratable, type VariantProps } from \"~/utils.js\";\n\nconst textareaVariants = cva(\n [\n \"flex min-h-[80px] w-full border-sm text-md focus-visible:outline-none disabled:cursor-not-allowed\"\n ],\n {\n variants: {\n variant: {\n primary: [\n \"bg-neutral-base border-neutral-muted text-neutral-strong placeholder:text-neutral-dimmed\",\n \"hover:border-neutral-strong\",\n \"focus:border-neutral-black\",\n \"disabled:bg-neutral-disabled disabled:border-neutral-dimmed disabled:text-neutral-disabled disabled:placeholder:text-neutral-disabled\"\n ],\n secondary: [\n \"bg-neutral-light border-neutral-subtle text-neutral-strong placeholder:text-neutral-dimmed\",\n \"hover:bg-neutral-dimmed\",\n \"focus:bg-neutral-base focus:border-neutral-black\",\n \"disabled:bg-neutral-disabled disabled:text-neutral-disabled disabled:placeholder:text-neutral-disabled\"\n ],\n ghost: [\n \"bg-transparent border-transparent text-neutral-strong placeholder:text-neutral-dimmed\",\n \"hover:bg-neutral-dark/5\",\n \"focus:bg-neutral-dark/5\",\n \"disabled:bg-transparent disabled:text-neutral-disabled disabled:placeholder:text-neutral-disabled\"\n ],\n \"ghost-negative\": [\n \"bg-transparent border-transparent text-neutral-light/50 placeholder:text-neutral-light/50\",\n \"hover:bg-neutral-base/20\",\n \"focus:bg-neutral-base focus:text-neutral-primary focus:placeholder:text-neutral-dimmed\",\n \"data-[focused=true]:bg-neutral-base data-[focused=true]:bg-neutral-primary data-[focused=true]:placeholder:text-neutral-dimmed\",\n \"disabled:bg-transparent disabled:text-neutral-disabled/50 disabled:placeholder:text-neutral-disabled/50\",\n \"data-[disabled=true]:bg-transparent data-[disabled=true]:text-neutral-disabled/50 data-[disabled=true]:placeholder:text-neutral-disabled/50\"\n ]\n },\n size: {\n md: [\"px-sm-extra py-xs-plus rounded-md\"],\n lg: [\"px-sm-extra py-sm-plus rounded-md\"],\n xl: [\"px-md-extra p-md rounded-lg\"]\n },\n invalid: {\n true: \"\"\n }\n },\n compoundVariants: [\n {\n variant: \"primary\",\n invalid: true,\n class: \"border-destructive-default!\"\n },\n {\n variant: \"secondary\",\n invalid: true,\n class: \"border-destructive-default!\"\n },\n {\n variant: \"ghost\",\n invalid: true,\n class: \"border-destructive-subtle! bg-destructive-subtle!\"\n },\n {\n variant: \"ghost-negative\",\n invalid: true,\n class: \"border-destructive-default! bg-destructive-subtle! text-neutral-primary placeholder:text-neutral-dimmed\"\n }\n ],\n defaultVariants: {\n variant: \"primary\",\n size: \"lg\"\n }\n }\n);\n\ninterface TextareaPrimitiveProps\n extends React.ComponentProps<\"textarea\"
|
|
1
|
+
{"version":3,"names":["React","cn","cva","makeDecoratable","textareaVariants","variants","variant","primary","secondary","ghost","size","md","lg","xl","invalid","true","compoundVariants","class","defaultVariants","DecoratableTextareaPrimitive","className","textareaRef","forwardEventOnChange","onChange","originalOnChange","onEnter","onKeyDown","originalOnKeyDown","value","props","useCallback","event","target","e","key","createElement","Object","assign","ref","TextareaPrimitive"],"sources":["TextareaPrimitive.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn, cva, makeDecoratable, type VariantProps } from \"~/utils.js\";\n\nconst textareaVariants = cva(\n [\n \"flex min-h-[80px] w-full border-sm text-md focus-visible:outline-none disabled:cursor-not-allowed\"\n ],\n {\n variants: {\n variant: {\n primary: [\n \"bg-neutral-base border-neutral-muted text-neutral-strong placeholder:text-neutral-dimmed\",\n \"hover:border-neutral-strong\",\n \"focus:border-neutral-black\",\n \"disabled:bg-neutral-disabled disabled:border-neutral-dimmed disabled:text-neutral-disabled disabled:placeholder:text-neutral-disabled\"\n ],\n secondary: [\n \"bg-neutral-light border-neutral-subtle text-neutral-strong placeholder:text-neutral-dimmed\",\n \"hover:bg-neutral-dimmed\",\n \"focus:bg-neutral-base focus:border-neutral-black\",\n \"disabled:bg-neutral-disabled disabled:text-neutral-disabled disabled:placeholder:text-neutral-disabled\"\n ],\n ghost: [\n \"bg-transparent border-transparent text-neutral-strong placeholder:text-neutral-dimmed\",\n \"hover:bg-neutral-dark/5\",\n \"focus:bg-neutral-dark/5\",\n \"disabled:bg-transparent disabled:text-neutral-disabled disabled:placeholder:text-neutral-disabled\"\n ],\n \"ghost-negative\": [\n \"bg-transparent border-transparent text-neutral-light/50 placeholder:text-neutral-light/50\",\n \"hover:bg-neutral-base/20\",\n \"focus:bg-neutral-base focus:text-neutral-primary focus:placeholder:text-neutral-dimmed\",\n \"data-[focused=true]:bg-neutral-base data-[focused=true]:bg-neutral-primary data-[focused=true]:placeholder:text-neutral-dimmed\",\n \"disabled:bg-transparent disabled:text-neutral-disabled/50 disabled:placeholder:text-neutral-disabled/50\",\n \"data-[disabled=true]:bg-transparent data-[disabled=true]:text-neutral-disabled/50 data-[disabled=true]:placeholder:text-neutral-disabled/50\"\n ]\n },\n size: {\n md: [\"px-sm-extra py-xs-plus rounded-md\"],\n lg: [\"px-sm-extra py-sm-plus rounded-md\"],\n xl: [\"px-md-extra p-md rounded-lg\"]\n },\n invalid: {\n true: \"\"\n }\n },\n compoundVariants: [\n {\n variant: \"primary\",\n invalid: true,\n class: \"border-destructive-default!\"\n },\n {\n variant: \"secondary\",\n invalid: true,\n class: \"border-destructive-default!\"\n },\n {\n variant: \"ghost\",\n invalid: true,\n class: \"border-destructive-subtle! bg-destructive-subtle!\"\n },\n {\n variant: \"ghost-negative\",\n invalid: true,\n class: \"border-destructive-default! bg-destructive-subtle! text-neutral-primary placeholder:text-neutral-dimmed\"\n }\n ],\n defaultVariants: {\n variant: \"primary\",\n size: \"lg\"\n }\n }\n);\n\ninterface TextareaPrimitiveProps\n extends React.ComponentProps<\"textarea\">, VariantProps<typeof textareaVariants> {\n /**\n * Reference to the textarea element.\n */\n textareaRef?: React.Ref<HTMLTextAreaElement>;\n\n /**\n * If true, it will pass the native `event` to the `onChange` callback\n */\n forwardEventOnChange?: boolean;\n\n /**\n * Callback function to be called when the Enter key is pressed.\n */\n onEnter?: () => void;\n}\n\nconst DecoratableTextareaPrimitive = ({\n className,\n variant,\n invalid,\n size,\n textareaRef,\n forwardEventOnChange,\n onChange: originalOnChange,\n onEnter,\n onKeyDown: originalOnKeyDown,\n value,\n ...props\n}: TextareaPrimitiveProps) => {\n const onChange = React.useCallback(\n (event: React.SyntheticEvent<HTMLTextAreaElement>) => {\n if (!originalOnChange) {\n return;\n }\n\n // @ts-expect-error\n originalOnChange(forwardEventOnChange ? event : event.target.value);\n },\n [forwardEventOnChange, originalOnChange]\n );\n\n const onKeyDown = React.useCallback(\n (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (typeof onEnter === \"function\" && e.key === \"Enter\") {\n onEnter();\n }\n\n if (typeof originalOnKeyDown === \"function\") {\n return originalOnKeyDown(e);\n }\n },\n [originalOnKeyDown, onEnter]\n );\n\n return (\n <textarea\n {...props}\n ref={textareaRef}\n className={cn(textareaVariants({ variant, invalid, size }), className)}\n onChange={onChange}\n onKeyDown={onKeyDown}\n value={value ?? \"\"}\n />\n );\n};\n\nconst TextareaPrimitive = makeDecoratable(\"TextareaPrimitive\", DecoratableTextareaPrimitive);\n\nexport { TextareaPrimitive, type T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CAAC;AAE5F,SAASoB,iBAAiB","ignoreList":[]}
|
package/Toast/Toast.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 ToastStories from
|
|
3
|
+
import * as ToastStories from "./useToast.stories";
|
|
4
4
|
|
|
5
5
|
<Meta of={ToastStories} />
|
|
6
6
|
|
|
@@ -15,8 +15,8 @@ import React, { useState } from "react";
|
|
|
15
15
|
import { useToast, Toast, Button } from "@webiny/admin-ui";
|
|
16
16
|
|
|
17
17
|
const ToastExample = () => {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const [lastToast, setLastToast] = useState<string | number>("");
|
|
19
|
+
const { showToast, hideToast, hideAllToasts } = useToast();
|
|
20
20
|
|
|
21
21
|
const handleShowToast = () => {
|
|
22
22
|
const toast = showToast({
|
|
@@ -38,17 +38,17 @@ const ToastExample = () => {
|
|
|
38
38
|
export default ToastExample;
|
|
39
39
|
|
|
40
40
|
` } }
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
additionalActions={[
|
|
42
|
+
{
|
|
43
|
+
title: 'Open in GitHub',
|
|
44
|
+
onClick: () => {
|
|
45
|
+
window.open(
|
|
46
|
+
'https://github.com/webiny/webiny-js/blob/feat/new-admin-ui/packages/admin-ui/src/Toast/Toast.tsx',
|
|
47
|
+
'_blank'
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
]}
|
|
52
52
|
/>
|
|
53
53
|
|
|
54
54
|
<Controls of={ToastStories.Documentation} />
|
|
@@ -58,24 +58,24 @@ import React, { useState } from "react";
|
|
|
58
58
|
import { useToast, Toast, Button } from "@webiny/admin-ui";
|
|
59
59
|
|
|
60
60
|
const ToastExample = () => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
61
|
+
const [lastToast, setLastToast] = useState<string | number>("");
|
|
62
|
+
const { showToast, hideToast, hideAllToasts } = useToast();
|
|
63
|
+
|
|
64
|
+
const handleShowToast = () => {
|
|
65
|
+
const toast = showToast({
|
|
66
|
+
title: "New entry created"
|
|
67
|
+
});
|
|
68
|
+
setLastToast(toast);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<>
|
|
73
|
+
<Button text="Show Toast" onClick={handleShowToast} />
|
|
74
|
+
<Button text="Hide latest toast" onClick={() => hideToast(lastToast)} />
|
|
75
|
+
<Button text="Hide all toasts" onClick={() => hideAllToasts()} />
|
|
76
|
+
<Toast.Provider />
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
export default ToastExample;
|
|
@@ -92,8 +92,8 @@ import React, { useState } from "react";
|
|
|
92
92
|
import { useToast, Toast, Button } from "@webiny/admin-ui";
|
|
93
93
|
|
|
94
94
|
const BasicToastExample = () => {
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
const [lastToast, setLastToast] = useState<string | number>("");
|
|
96
|
+
const { showToast, hideToast, hideAllToasts } = useToast();
|
|
97
97
|
|
|
98
98
|
return (
|
|
99
99
|
<>
|
|
@@ -111,6 +111,7 @@ const BasicToastExample = () => {
|
|
|
111
111
|
<Toast.Provider />
|
|
112
112
|
</>
|
|
113
113
|
);
|
|
114
|
+
|
|
114
115
|
};
|
|
115
116
|
|
|
116
117
|
export default BasicToastExample;
|
|
@@ -125,8 +126,8 @@ import React, { useState } from "react";
|
|
|
125
126
|
import { useToast, Toast, Button } from "@webiny/admin-ui";
|
|
126
127
|
|
|
127
128
|
const SubtleToastExample = () => {
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
const [lastToast, setLastToast] = useState<string | number>("");
|
|
130
|
+
const { showToast, hideToast, hideAllToasts } = useToast();
|
|
130
131
|
|
|
131
132
|
return (
|
|
132
133
|
<>
|
|
@@ -145,6 +146,7 @@ const SubtleToastExample = () => {
|
|
|
145
146
|
<Toast.Provider />
|
|
146
147
|
</>
|
|
147
148
|
);
|
|
149
|
+
|
|
148
150
|
};
|
|
149
151
|
|
|
150
152
|
export default SubtleToastExample;
|
|
@@ -159,8 +161,8 @@ import React, { useState } from "react";
|
|
|
159
161
|
import { useToast, Toast, Button } from "@webiny/admin-ui";
|
|
160
162
|
|
|
161
163
|
const ToastWithDescriptionExample = () => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
+
const [lastToast, setLastToast] = useState<string | number>("");
|
|
165
|
+
const { showToast, hideToast, hideAllToasts } = useToast();
|
|
164
166
|
|
|
165
167
|
return (
|
|
166
168
|
<>
|
|
@@ -179,6 +181,7 @@ const ToastWithDescriptionExample = () => {
|
|
|
179
181
|
<Toast.Provider />
|
|
180
182
|
</>
|
|
181
183
|
);
|
|
184
|
+
|
|
182
185
|
};
|
|
183
186
|
|
|
184
187
|
export default ToastWithDescriptionExample;
|
|
@@ -193,8 +196,8 @@ import React, { useState } from "react";
|
|
|
193
196
|
import { useToast, Toast, Button } from "@webiny/admin-ui";
|
|
194
197
|
|
|
195
198
|
const ToastWithComponentsExample = () => {
|
|
196
|
-
|
|
197
|
-
|
|
199
|
+
const [lastToast, setLastToast] = useState<string | number>("");
|
|
200
|
+
const { showToast, hideToast, hideAllToasts } = useToast();
|
|
198
201
|
|
|
199
202
|
return (
|
|
200
203
|
<>
|
|
@@ -215,6 +218,7 @@ const ToastWithComponentsExample = () => {
|
|
|
215
218
|
<Toast.Provider />
|
|
216
219
|
</>
|
|
217
220
|
);
|
|
221
|
+
|
|
218
222
|
};
|
|
219
223
|
|
|
220
224
|
export default ToastWithComponentsExample;
|
|
@@ -229,8 +233,8 @@ import React, { useState } from "react";
|
|
|
229
233
|
import { useToast, Toast, Button } from "@webiny/admin-ui";
|
|
230
234
|
|
|
231
235
|
const ToastWithActionsExample = () => {
|
|
232
|
-
|
|
233
|
-
|
|
236
|
+
const [lastToast, setLastToast] = useState<string | number>("");
|
|
237
|
+
const { showToast, hideToast, hideAllToasts } = useToast();
|
|
234
238
|
|
|
235
239
|
return (
|
|
236
240
|
<>
|
|
@@ -263,6 +267,7 @@ const ToastWithActionsExample = () => {
|
|
|
263
267
|
<Toast.Provider />
|
|
264
268
|
</>
|
|
265
269
|
);
|
|
270
|
+
|
|
266
271
|
};
|
|
267
272
|
|
|
268
273
|
export default ToastWithActionsExample;
|
|
@@ -277,8 +282,8 @@ import React, { useState } from "react";
|
|
|
277
282
|
import { useToast, Toast, Button } from "@webiny/admin-ui";
|
|
278
283
|
|
|
279
284
|
const ToastWithDescriptionAndActionsExample = () => {
|
|
280
|
-
|
|
281
|
-
|
|
285
|
+
const [lastToast, setLastToast] = useState<string | number>("");
|
|
286
|
+
const { showToast, hideToast, hideAllToasts } = useToast();
|
|
282
287
|
|
|
283
288
|
return (
|
|
284
289
|
<>
|
|
@@ -314,6 +319,7 @@ const ToastWithDescriptionAndActionsExample = () => {
|
|
|
314
319
|
<Toast.Provider />
|
|
315
320
|
</>
|
|
316
321
|
);
|
|
322
|
+
|
|
317
323
|
};
|
|
318
324
|
|
|
319
325
|
export default ToastWithDescriptionAndActionsExample;
|
|
@@ -329,8 +335,8 @@ import { useToast, Toast, Button, Icon } from "@webiny/admin-ui";
|
|
|
329
335
|
import { ReactComponent as SettingsIcon } from "@webiny/icons/settings.svg";
|
|
330
336
|
|
|
331
337
|
const ToastWithCustomIconExample = () => {
|
|
332
|
-
|
|
333
|
-
|
|
338
|
+
const [lastToast, setLastToast] = useState<string | number>("");
|
|
339
|
+
const { showToast, hideToast, hideAllToasts } = useToast();
|
|
334
340
|
|
|
335
341
|
return (
|
|
336
342
|
<>
|
|
@@ -349,6 +355,7 @@ const ToastWithCustomIconExample = () => {
|
|
|
349
355
|
<Toast.Provider />
|
|
350
356
|
</>
|
|
351
357
|
);
|
|
358
|
+
|
|
352
359
|
};
|
|
353
360
|
|
|
354
361
|
export default ToastWithCustomIconExample;
|
|
@@ -363,8 +370,8 @@ import React, { useState } from "react";
|
|
|
363
370
|
import { useToast, Toast, Button } from "@webiny/admin-ui";
|
|
364
371
|
|
|
365
372
|
const ToastWithInfiniteDurationExample = () => {
|
|
366
|
-
|
|
367
|
-
|
|
373
|
+
const [lastToast, setLastToast] = useState<string | number>("");
|
|
374
|
+
const { showToast, hideToast, hideAllToasts } = useToast();
|
|
368
375
|
|
|
369
376
|
return (
|
|
370
377
|
<>
|
|
@@ -383,6 +390,7 @@ const ToastWithInfiniteDurationExample = () => {
|
|
|
383
390
|
<Toast.Provider />
|
|
384
391
|
</>
|
|
385
392
|
);
|
|
393
|
+
|
|
386
394
|
};
|
|
387
395
|
|
|
388
396
|
export default ToastWithInfiniteDurationExample;
|
|
@@ -397,8 +405,8 @@ import React, { useState } from "react";
|
|
|
397
405
|
import { useToast, Toast, Button } from "@webiny/admin-ui";
|
|
398
406
|
|
|
399
407
|
const ToastNotDismissibleExample = () => {
|
|
400
|
-
|
|
401
|
-
|
|
408
|
+
const [lastToast, setLastToast] = useState<string | number>("");
|
|
409
|
+
const { showToast, hideToast, hideAllToasts } = useToast();
|
|
402
410
|
|
|
403
411
|
return (
|
|
404
412
|
<>
|
|
@@ -417,6 +425,7 @@ const ToastNotDismissibleExample = () => {
|
|
|
417
425
|
<Toast.Provider />
|
|
418
426
|
</>
|
|
419
427
|
);
|
|
428
|
+
|
|
420
429
|
};
|
|
421
430
|
|
|
422
431
|
export default ToastNotDismissibleExample;
|
|
@@ -431,8 +440,8 @@ import React, { useState } from "react";
|
|
|
431
440
|
import { useToast, Toast, Button } from "@webiny/admin-ui";
|
|
432
441
|
|
|
433
442
|
const ToastWithCustomPositionExample = () => {
|
|
434
|
-
|
|
435
|
-
|
|
443
|
+
const [lastToast, setLastToast] = useState<string | number>("");
|
|
444
|
+
const { showToast, hideToast, hideAllToasts } = useToast();
|
|
436
445
|
|
|
437
446
|
return (
|
|
438
447
|
<>
|
|
@@ -451,6 +460,7 @@ const ToastWithCustomPositionExample = () => {
|
|
|
451
460
|
<Toast.Provider />
|
|
452
461
|
</>
|
|
453
462
|
);
|
|
463
|
+
|
|
454
464
|
};
|
|
455
465
|
|
|
456
466
|
export default ToastWithCustomPositionExample;
|
|
@@ -3,7 +3,7 @@ import { type VariantProps } from "../../utils.js";
|
|
|
3
3
|
declare const toastRootVariants: (props?: ({
|
|
4
4
|
variant?: "default" | "subtle" | null | undefined;
|
|
5
5
|
hasDescription?: boolean | null | undefined;
|
|
6
|
-
} & import("class-variance-authority/
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
type ToastRootProps = React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof toastRootVariants>;
|
|
8
8
|
declare const ToastRoot: ({ className, hasDescription, variant, children, ...props }: ToastRootProps) => React.JSX.Element;
|
|
9
9
|
export { ToastRoot, type ToastRootProps, toastRootVariants };
|