@webiny/ui 0.0.0-unstable.e53eceafb5 → 0.0.0-unstable.eb196ccd2f
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/Button/useMappedButtonProps.d.ts +3 -3
- package/Tags/Tags.d.ts +7 -2
- package/Tags/Tags.js +7 -62
- package/Tags/Tags.js.map +1 -1
- package/package.json +7 -8
|
@@ -3,12 +3,12 @@ import type { ButtonProps } from "./Button";
|
|
|
3
3
|
export declare const useMappedButtonProps: (props: ButtonProps) => {
|
|
4
4
|
text?: import("react").ReactNode;
|
|
5
5
|
size?: "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
6
|
+
children?: import("react").ReactNode;
|
|
7
|
+
className?: string | undefined;
|
|
6
8
|
style?: {
|
|
7
9
|
[key: string]: any;
|
|
8
10
|
} | undefined;
|
|
9
|
-
className?: string | undefined;
|
|
10
|
-
children?: import("react").ReactNode;
|
|
11
|
-
disabled?: boolean | undefined;
|
|
12
11
|
onClick?: ((event: import("react").MouseEvent<any, MouseEvent>) => any) | undefined;
|
|
12
|
+
disabled?: boolean | undefined;
|
|
13
13
|
"data-testid"?: string | undefined;
|
|
14
14
|
};
|
package/Tags/Tags.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { FocusEventHandler } from "react";
|
|
1
2
|
import React from "react";
|
|
2
|
-
import type { FormComponentProps } from "../types";
|
|
3
|
+
import type { FormComponentProps } from "../types.js";
|
|
3
4
|
interface TagsProps extends FormComponentProps {
|
|
4
5
|
/**
|
|
5
6
|
* Component label.
|
|
@@ -32,7 +33,7 @@ interface TagsProps extends FormComponentProps {
|
|
|
32
33
|
/**
|
|
33
34
|
* Callback that gets executed when the input is focused.
|
|
34
35
|
*/
|
|
35
|
-
onFocus?:
|
|
36
|
+
onFocus?: FocusEventHandler<HTMLInputElement> | undefined;
|
|
36
37
|
/**
|
|
37
38
|
* Automatically focus on the tags input.
|
|
38
39
|
*/
|
|
@@ -42,5 +43,9 @@ interface TagsProps extends FormComponentProps {
|
|
|
42
43
|
*/
|
|
43
44
|
protectedTags?: string[];
|
|
44
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated This component is deprecated and will be removed in future releases.
|
|
48
|
+
* Please use the `Tags` component from the `@webiny/admin-ui` package instead.
|
|
49
|
+
*/
|
|
45
50
|
export declare const Tags: (props: TagsProps) => React.JSX.Element;
|
|
46
51
|
export default Tags;
|
package/Tags/Tags.js
CHANGED
|
@@ -1,66 +1,11 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Tags as AdminTags } from "@webiny/admin-ui";
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated This component is deprecated and will be removed in future releases.
|
|
5
|
+
* Please use the `Tags` component from the `@webiny/admin-ui` package instead.
|
|
6
|
+
*/
|
|
6
7
|
export const Tags = props => {
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
value,
|
|
10
|
-
disabled,
|
|
11
|
-
onChange,
|
|
12
|
-
protectedTags = [],
|
|
13
|
-
...otherInputProps
|
|
14
|
-
} = props;
|
|
15
|
-
const isProtected = useCallback(tag => protectedTags.some(pattern => minimatch(tag, pattern)), [protectedTags]);
|
|
16
|
-
const inputProps = {
|
|
17
|
-
...otherInputProps,
|
|
18
|
-
value: inputValue,
|
|
19
|
-
onChange: inputValue => {
|
|
20
|
-
setInputValue(inputValue);
|
|
21
|
-
},
|
|
22
|
-
onKeyDown: ev => {
|
|
23
|
-
if (!onChange) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const newValue = Array.isArray(value) ? [...value] : [];
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* We must cast as keycode only works with Event | string type.
|
|
30
|
-
*/
|
|
31
|
-
switch (keycode(ev)) {
|
|
32
|
-
case "enter":
|
|
33
|
-
if (inputValue) {
|
|
34
|
-
newValue.push(inputValue);
|
|
35
|
-
onChange(newValue);
|
|
36
|
-
setInputValue("");
|
|
37
|
-
}
|
|
38
|
-
break;
|
|
39
|
-
case "backspace":
|
|
40
|
-
if (newValue.length && !inputValue) {
|
|
41
|
-
newValue.splice(-1, 1);
|
|
42
|
-
onChange(newValue);
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Input, inputProps), Array.isArray(value) && value.length ? /*#__PURE__*/React.createElement(Chips, {
|
|
49
|
-
disabled: disabled
|
|
50
|
-
}, value.map((item, index) => {
|
|
51
|
-
return /*#__PURE__*/React.createElement(Chip, {
|
|
52
|
-
label: item,
|
|
53
|
-
key: `${item}-${index}`,
|
|
54
|
-
onRemove: !isProtected(item) ? () => {
|
|
55
|
-
// On removal, let's update the value and call "onChange" callback.
|
|
56
|
-
if (onChange) {
|
|
57
|
-
const newValue = [...value];
|
|
58
|
-
newValue.splice(index, 1);
|
|
59
|
-
onChange(newValue);
|
|
60
|
-
}
|
|
61
|
-
} : undefined
|
|
62
|
-
});
|
|
63
|
-
})) : null);
|
|
8
|
+
return /*#__PURE__*/React.createElement(AdminTags, props);
|
|
64
9
|
};
|
|
65
10
|
export default Tags;
|
|
66
11
|
|
package/Tags/Tags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","Tags","AdminTags","props","createElement"],"sources":["Tags.tsx"],"sourcesContent":["import type { FocusEventHandler } from \"react\";\nimport React from \"react\";\nimport { Tags as AdminTags } from \"@webiny/admin-ui\";\nimport type { FormComponentProps } from \"~/types.js\";\n\ninterface TagsProps extends FormComponentProps {\n /**\n * Component label.\n */\n label?: React.ReactNode;\n\n /**\n * Are input and chosen tags disabled?\n */\n disabled?: boolean;\n\n /**\n * Placeholder text for the form control. Set to a blank string to create a non-floating placeholder label.\n */\n placeholder?: string;\n\n /**\n * Description beneath the input.\n */\n description?: string;\n\n /**\n * A className for the root element.\n */\n className?: string;\n\n /**\n * A list of tags.\n */\n value?: string[];\n\n /**\n * Callback that gets executed on change of input value.\n */\n onInput?: <T = unknown>(value: T) => void;\n\n /**\n * Callback that gets executed when the input is focused.\n */\n onFocus?: FocusEventHandler<HTMLInputElement> | undefined;\n\n /**\n * Automatically focus on the tags input.\n */\n autoFocus?: boolean;\n\n /**\n * Protected tags cannot be removed by the user.\n */\n protectedTags?: string[];\n}\n\n/**\n * @deprecated This component is deprecated and will be removed in future releases.\n * Please use the `Tags` component from the `@webiny/admin-ui` package instead.\n */\nexport const Tags = (props: TagsProps) => {\n return <AdminTags {...props} />;\n};\n\nexport default Tags;\n"],"mappings":"AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,IAAIC,SAAS,QAAQ,kBAAkB;AAuDpD;AACA;AACA;AACA;AACA,OAAO,MAAMD,IAAI,GAAIE,KAAgB,IAAK;EACtC,oBAAOH,KAAA,CAAAI,aAAA,CAACF,SAAS,EAAKC,KAAQ,CAAC;AACnC,CAAC;AAED,eAAeF,IAAI","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/ui",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.eb196ccd2f",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,18 +15,17 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@svgr/webpack": "6.5.1",
|
|
18
|
-
"@webiny/admin-ui": "0.0.0-unstable.
|
|
19
|
-
"@webiny/utils": "0.0.0-unstable.
|
|
18
|
+
"@webiny/admin-ui": "0.0.0-unstable.eb196ccd2f",
|
|
19
|
+
"@webiny/utils": "0.0.0-unstable.eb196ccd2f",
|
|
20
20
|
"classnames": "2.5.1",
|
|
21
|
-
"keycode": "2.2.1",
|
|
22
21
|
"lodash": "4.17.21"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {
|
|
25
24
|
"@emotion/babel-plugin": "11.11.0",
|
|
26
25
|
"@testing-library/react": "15.0.7",
|
|
27
|
-
"@webiny/cli": "0.0.0-unstable.
|
|
28
|
-
"@webiny/project-utils": "0.0.0-unstable.
|
|
29
|
-
"@webiny/validation": "0.0.0-unstable.
|
|
26
|
+
"@webiny/cli": "0.0.0-unstable.eb196ccd2f",
|
|
27
|
+
"@webiny/project-utils": "0.0.0-unstable.eb196ccd2f",
|
|
28
|
+
"@webiny/validation": "0.0.0-unstable.eb196ccd2f",
|
|
30
29
|
"babel-loader": "9.2.1",
|
|
31
30
|
"execa": "5.1.1",
|
|
32
31
|
"ncp": "2.0.0",
|
|
@@ -60,5 +59,5 @@
|
|
|
60
59
|
]
|
|
61
60
|
}
|
|
62
61
|
},
|
|
63
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "eb196ccd2f32296e10f7add6dd7220d4e3abece4"
|
|
64
63
|
}
|