@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.
@@ -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?: (ev: Event) => void;
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, { useCallback, useState } from "react";
2
- import keycode from "keycode";
3
- import minimatch from "minimatch";
4
- import { Input } from "../Input";
5
- import { Chips, Chip } from "../Chips";
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
- const [inputValue, setInputValue] = useState("");
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","useCallback","useState","keycode","minimatch","Input","Chips","Chip","Tags","props","inputValue","setInputValue","value","disabled","onChange","protectedTags","otherInputProps","isProtected","tag","some","pattern","inputProps","onKeyDown","ev","newValue","Array","isArray","push","length","splice","createElement","map","item","index","label","key","onRemove","undefined"],"sources":["Tags.tsx"],"sourcesContent":["import type { SyntheticEvent } from \"react\";\nimport React, { useCallback, useState } from \"react\";\nimport keycode from \"keycode\";\nimport minimatch from \"minimatch\";\nimport type { InputProps } from \"~/Input\";\nimport { Input } from \"~/Input\";\nimport { Chips, Chip } from \"~/Chips\";\nimport type { FormComponentProps } from \"~/types\";\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?: (ev: Event) => void;\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\nexport const Tags = (props: TagsProps) => {\n const [inputValue, setInputValue] = useState(\"\");\n\n const { value, disabled, onChange, protectedTags = [], ...otherInputProps } = props;\n\n const isProtected = useCallback(\n (tag: string) => protectedTags.some(pattern => minimatch(tag, pattern)),\n [protectedTags]\n );\n\n const inputProps: InputProps<string> = {\n ...otherInputProps,\n value: inputValue,\n onChange: inputValue => {\n setInputValue(inputValue);\n },\n onKeyDown: (ev: SyntheticEvent) => {\n if (!onChange) {\n return;\n }\n\n const newValue = Array.isArray(value) ? [...value] : [];\n\n /**\n * We must cast as keycode only works with Event | string type.\n */\n switch (keycode(ev as unknown as Event)) {\n case \"enter\":\n if (inputValue) {\n newValue.push(inputValue);\n onChange(newValue);\n setInputValue(\"\");\n }\n break;\n case \"backspace\":\n if (newValue.length && !inputValue) {\n newValue.splice(-1, 1);\n onChange(newValue);\n break;\n }\n }\n }\n };\n\n return (\n <div>\n <Input {...inputProps} />\n {Array.isArray(value) && value.length ? (\n <Chips disabled={disabled}>\n {value.map((item, index) => {\n return (\n <Chip\n label={item}\n key={`${item}-${index}`}\n onRemove={\n !isProtected(item)\n ? () => {\n // On removal, let's update the value and call \"onChange\" callback.\n if (onChange) {\n const newValue = [...value];\n newValue.splice(index, 1);\n onChange(newValue);\n }\n }\n : undefined\n }\n />\n );\n })}\n </Chips>\n ) : null}\n </div>\n );\n};\n\nexport default Tags;\n"],"mappings":"AACA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AACpD,OAAOC,OAAO,MAAM,SAAS;AAC7B,OAAOC,SAAS,MAAM,WAAW;AAEjC,SAASC,KAAK;AACd,SAASC,KAAK,EAAEC,IAAI;AAuDpB,OAAO,MAAMC,IAAI,GAAIC,KAAgB,IAAK;EACtC,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGT,QAAQ,CAAC,EAAE,CAAC;EAEhD,MAAM;IAAEU,KAAK;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,aAAa,GAAG,EAAE;IAAE,GAAGC;EAAgB,CAAC,GAAGP,KAAK;EAEnF,MAAMQ,WAAW,GAAGhB,WAAW,CAC1BiB,GAAW,IAAKH,aAAa,CAACI,IAAI,CAACC,OAAO,IAAIhB,SAAS,CAACc,GAAG,EAAEE,OAAO,CAAC,CAAC,EACvE,CAACL,aAAa,CAClB,CAAC;EAED,MAAMM,UAA8B,GAAG;IACnC,GAAGL,eAAe;IAClBJ,KAAK,EAAEF,UAAU;IACjBI,QAAQ,EAAEJ,UAAU,IAAI;MACpBC,aAAa,CAACD,UAAU,CAAC;IAC7B,CAAC;IACDY,SAAS,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nB,QAAQ,CAACU,QAAQ,CAAC;QACtB;MACJ,CAAC,GACDa;IACT,CACJ,CAAC;EAEV,CAAC,CACE,CAAC,GACR,IACH,CAAC;AAEd,CAAC;AAED,eAAe7B,IAAI","ignoreList":[]}
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.e53eceafb5",
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.e53eceafb5",
19
- "@webiny/utils": "0.0.0-unstable.e53eceafb5",
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.e53eceafb5",
28
- "@webiny/project-utils": "0.0.0-unstable.e53eceafb5",
29
- "@webiny/validation": "0.0.0-unstable.e53eceafb5",
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": "e53eceafb5ce1a3872c9b4548939bb2eae5b1aef"
62
+ "gitHead": "eb196ccd2f32296e10f7add6dd7220d4e3abece4"
64
63
  }