@wonderflow/react-components 10.17.1 → 10.18.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.
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /*
3
- * Copyright 2022 Wonderflow <authored by Mattia Astorino>
3
+ * Copyright 2022-2023 Wonderflow <authored by Mattia Astorino>
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import { Stack, Text } from '../..';
21
21
  import * as styles from './input-group.module.css';
22
22
  export const InputGroup = forwardRef(({ className, input, suffix, prefix, label, dimension = 'regular', ...otherProps }, forwardedRef) => {
23
23
  const seedID = useUIDSeed();
24
- return (_jsxs(Stack, { rowGap: 4, hAlign: "stretch", vAlign: "start", fill: false, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor: seedID('field'), children: label }), _jsxs(Stack, { as: "fieldset", direction: "row", vAlign: "start", hAlign: "start", fill: false, inline: true, ref: forwardedRef, className: clsx(styles.InputGroup, className), "data-input-group-has-end": Boolean(suffix), "data-input-group-has-start": !!prefix, ...otherProps, children: [_jsx("div", { className: styles.Start, children: Children.map(prefix, child => isValidElement(child) && cloneElement(child, {
24
+ return (_jsxs(Stack, { rowGap: 4, hAlign: "stretch", vAlign: "start", fill: false, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, lineHeight: "small", htmlFor: seedID('field'), children: label }), _jsxs(Stack, { as: "fieldset", direction: "row", vAlign: "start", hAlign: "start", fill: false, inline: true, ref: forwardedRef, className: clsx(styles.InputGroup, className), "data-input-group-has-end": Boolean(suffix), "data-input-group-has-start": !!prefix, ...otherProps, children: [_jsx("div", { className: styles.Start, children: Children.map(prefix, child => isValidElement(child) && cloneElement(child, {
25
25
  dimension,
26
26
  })) }), _jsx("div", { className: styles.InputField, children: Children.map(input, child => isValidElement(child) && cloneElement(child, {
27
27
  id: seedID('field'),
@@ -1 +1 @@
1
- @layer components{.InputGroup{position:relative}.Start :is(button,input,a,select,fieldset[tabindex="0"]){outline-offset:-2px}.InputGroup[data-input-group-has-end=true] .Start *{border-bottom-right-radius:0;border-top-right-radius:0}.InputField :is(button,input,a,select,fieldset[tabindex="0"]){outline-offset:-2px}.InputGroup[data-input-group-has-end=true] .InputField input{border-bottom-right-radius:0;border-right:0;border-top-right-radius:0}.InputGroup[data-input-group-has-start=true] .InputField input{border-bottom-left-radius:0;border-left:0;border-top-left-radius:0}.End :is(button,input,a,select,fieldset[tabindex="0"]){outline-offset:-2px}.InputGroup[data-input-group-has-end=true] .End *{border-bottom-left-radius:0;border-top-left-radius:0}}
1
+ @layer components{.InputGroup{position:relative}.Start :is(button,input,a,select,fieldset[tabindex="0"]){outline-offset:-2px}.InputGroup[data-input-group-has-end=true] .Start *{border-bottom-right-radius:0;border-top-right-radius:0}.InputField :is(button,input,a,select,fieldset[tabindex="0"]){outline-offset:-2px}.InputGroup[data-input-group-has-end=true] .InputField input{border-bottom-right-radius:0;border-right:0;border-top-right-radius:0}.InputGroup[data-input-group-has-start=true] .InputField input{border-bottom-left-radius:0;border-left:0;border-top-left-radius:0}.End{line-height:1rem}.End :is(button,input,a,select,fieldset[tabindex="0"]){outline-offset:-2px}.InputGroup[data-input-group-has-end=true] .End *{border-bottom-left-radius:0;border-top-left-radius:0}}
@@ -1 +1 @@
1
- {"version":3,"file":"input-group.stories.d.ts","sourceRoot":"","sources":["../../../src/components/input-group/input-group.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,UAAU,CAM3C,CAAC;AAEF,eAAe,KAAK,CAAC;AA8BrB,eAAO,MAAM,MAAM;;;wFAAmB,CAAC"}
1
+ {"version":3,"file":"input-group.stories.d.ts","sourceRoot":"","sources":["../../../src/components/input-group/input-group.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,UAAU,CAc3C,CAAC;AAEF,eAAe,KAAK,CAAC;AA8BrB,eAAO,MAAM,MAAM;;;wFAAmB,CAAC"}
@@ -5,8 +5,16 @@ const story = {
5
5
  title: 'Inputs/Input group',
6
6
  component: InputGroup,
7
7
  args: {
8
+ label: 'Label',
9
+ dimension: 'regular',
8
10
  input: _jsx(Textfield, { type: "text", defaultValue: "sample" }),
9
11
  },
12
+ argTypes: {
13
+ dimension: {
14
+ options: ['small', 'regular', 'big'],
15
+ control: { type: 'radio' },
16
+ },
17
+ },
10
18
  };
11
19
  export default story;
12
20
  const Default = args => (_jsxs(Stack, { inline: true, fill: false, hAlign: "start", rowGap: 32, children: [_jsx(InputGroup, { suffix: _jsx(Button, { children: "Confirm" }), ...args }), _jsx(InputGroup, { suffix: _jsx(Textfield, { disabled: true, size: 9, placeholder: "@mail.com" }), ...args }), _jsx(InputGroup, { dimension: "big", label: "Sample label", prefix: _jsx(Textfield, { readOnly: true, size: 6, defaultValue: "https://" }), suffix: (_jsxs(Select, { defaultValue: 1, children: [_jsx("option", { value: "1", children: ".com" }), _jsx("option", { value: "2", children: ".it" }), _jsx("option", { value: "3", children: ".org" }), _jsx("option", { value: "4", children: ".dev" }), _jsx("option", { value: "5", children: ".io" })] })), ...args })] }));
@@ -16,6 +16,11 @@ export declare type TextfieldProps<T = Record<string, unknown>> = BaseFieldProps
16
16
  * you can bind a custom label to the input by using an id.
17
17
  */
18
18
  label?: string;
19
+ /**
20
+ * Optional hint text field, it provides additional help or context
21
+ * to the user, it is often used to explain the correct format of the textfield data.
22
+ */
23
+ message?: string;
19
24
  /**
20
25
  * Set the input type. The value can be anything that
21
26
  * is supported by the HTML input element.
@@ -1 +1 @@
1
- {"version":3,"file":"textfield.d.ts","sourceRoot":"","sources":["../../../src/components/textfield/textfield.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACZ,MAAM,OAAO,CAAC;AAGf,OAAO,EACuC,WAAW,EACxD,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAa,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAG7E,oBAAY,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,cAAc,CAAC;IACvE;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,KAAK,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;IAC5D;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC,GAAG,CAAC,CAAA;AAEN,eAAO,MAAM,SAAS,sJA8GpB,CAAC"}
1
+ {"version":3,"file":"textfield.d.ts","sourceRoot":"","sources":["../../../src/components/textfield/textfield.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACZ,MAAM,OAAO,CAAC;AAGf,OAAO,EACuC,WAAW,EACxD,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAa,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAG7E,oBAAY,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,cAAc,CAAC;IACvE;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,KAAK,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;IAC5D;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC,GAAG,CAAC,CAAA;AAEN,eAAO,MAAM,SAAS,sJAmHpB,CAAC"}
@@ -5,7 +5,7 @@ import { useUIDSeed } from 'react-uid';
5
5
  import { IconButton, Stack, Symbol, Text, } from '../..';
6
6
  import { BaseField } from './base-field';
7
7
  import * as styles from './textfield.module.css';
8
- export const Textfield = forwardRef(({ children, className, disabled = false, icon, label, textarea, readOnly, invalid, id, iconPosition = 'right', dimension = 'regular', type, style, onChange, fullWidth, ...otherProps }, forwardedRef) => {
8
+ export const Textfield = forwardRef(({ children, className, disabled = false, icon, label, textarea, readOnly, invalid, id, iconPosition = 'right', dimension = 'regular', message, type, style, onChange, fullWidth, ...otherProps }, forwardedRef) => {
9
9
  const [isPasswordVisible, setPasswordVisible] = useState(false);
10
10
  const seedID = useUIDSeed();
11
11
  const isPassword = type === 'password';
@@ -29,8 +29,8 @@ export const Textfield = forwardRef(({ children, className, disabled = false, ic
29
29
  disabled,
30
30
  onChange,
31
31
  };
32
- return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(styles.Textfield, className), "data-textfield-has-icon": isPassword || Boolean(icon), "data-textfield-icon-position": iconPosition, "data-textfield-dimension": dimension, "data-textfield-invalid": invalid, "data-textfield-fullwidth": fullWidth, "aria-disabled": disabled, hAlign: "stretch", vAlign: "start", tabIndex: disabled ? 0 : undefined, style: style, children: [label && _jsx(Text, { as: "label", "aria-disabled": disabled, className: styles.Label, size: dimension === 'small' ? 14 : 16, htmlFor: fieldID, children: label }), _jsxs("div", { className: styles.FieldContainer, children: [textarea
32
+ return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(styles.Textfield, className), "data-textfield-has-icon": isPassword || Boolean(icon), "data-textfield-icon-position": iconPosition, "data-textfield-dimension": dimension, "data-textfield-invalid": invalid, "data-textfield-fullwidth": fullWidth, "aria-disabled": disabled, hAlign: "stretch", vAlign: "start", tabIndex: disabled ? 0 : undefined, style: style, children: [label && _jsx(Text, { as: "label", lineHeight: "small", "aria-disabled": disabled, className: styles.Label, size: dimension === 'small' ? 14 : 16, htmlFor: fieldID, children: label }), _jsxs("div", { className: styles.FieldContainer, children: [textarea
33
33
  ? (_jsx(BaseField, { ref: forwardedRef, as: "textarea", id: fieldID, ...commonProps, ...otherProps }))
34
- : (_jsx(BaseField, { className: styles.InputField, id: fieldID, ref: forwardedRef, type: isPasswordVisible ? 'text' : type, spellCheck: isPassword ? false : undefined, ...commonProps, ...otherProps })), isPassword && (_jsx(IconButton, { className: styles.IconButton, dimension: actionSizes[dimension], onClick: handlePasswordVisibility, kind: "flat", "aria-label": "Reveal password", icon: isPasswordVisible ? 'eye-slash' : 'eye' })), !textarea && icon && !isPassword && (_jsx(Symbol, { className: styles.Icon, source: icon, dimension: iconSizes[dimension] }))] })] }));
34
+ : (_jsx(BaseField, { className: styles.InputField, id: fieldID, ref: forwardedRef, type: isPasswordVisible ? 'text' : type, spellCheck: isPassword ? false : undefined, ...commonProps, ...otherProps })), isPassword && (_jsx(IconButton, { className: styles.IconButton, dimension: actionSizes[dimension], onClick: handlePasswordVisibility, kind: "flat", "aria-label": "Reveal password", icon: isPasswordVisible ? 'eye-slash' : 'eye' })), !textarea && icon && !isPassword && (_jsx(Symbol, { className: styles.Icon, source: icon, dimension: iconSizes[dimension] }))] }), message && _jsx(Text, { as: "label", lineHeight: "small", sentiment: invalid ? 'danger' : undefined, "aria-disabled": disabled, className: styles.Label, size: 14, children: message })] }));
35
35
  });
36
36
  Textfield.displayName = 'Textfield';
@@ -1 +1 @@
1
- {"version":3,"file":"textfield.stories.d.ts","sourceRoot":"","sources":["../../../src/components/textfield/textfield.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,SAAS,CAoC1C,CAAC;AAEF,eAAe,KAAK,CAAC;AA4BrB,eAAO,MAAM,MAAM,+LAA0B,CAAC;AAa9C,eAAO,MAAM,KAAK,+LAA4B,CAAC;AAgB/C,eAAO,MAAM,QAAQ,+LAA4B,CAAC;AAalD,eAAO,MAAM,QAAQ,+LAA0B,CAAC"}
1
+ {"version":3,"file":"textfield.stories.d.ts","sourceRoot":"","sources":["../../../src/components/textfield/textfield.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,SAAS,CAoC1C,CAAC;AAEF,eAAe,KAAK,CAAC;AA2BrB,eAAO,MAAM,MAAM,+LAA0B,CAAC;AAc9C,eAAO,MAAM,KAAK,+LAA4B,CAAC;AAgB/C,eAAO,MAAM,QAAQ,+LAA4B,CAAC;AAalD,eAAO,MAAM,QAAQ,+LAA0B,CAAC"}
@@ -39,12 +39,13 @@ const story = {
39
39
  },
40
40
  };
41
41
  export default story;
42
- const SingleTemplate = args => (_jsxs(Stack, { rowGap: 24, children: [_jsx(Textfield, { ...args, size: 4, placeholder: "Placeholder" }), _jsx(Textfield, { ...args, size: 4, placeholder: "Placeholder" }), _jsx(Textfield, { ...args, size: 4, placeholder: "Placeholder" }), _jsx(Textfield, { ...args, type: "password", label: "Password", defaultValue: "123123kl\u00F2asj", placeholder: "Placeholder" })] }));
42
+ const SingleTemplate = args => (_jsxs(Stack, { rowGap: 24, children: [_jsx(Textfield, { ...args, size: 4, placeholder: "Placeholder", message: "" }), _jsx(Textfield, { ...args, size: 4, placeholder: "Placeholder" }), _jsx(Textfield, { ...args, type: "password", label: "Password", defaultValue: "123123kl\u00F2asj", placeholder: "Placeholder" })] }));
43
43
  const MultipleTemplate = args => (_jsxs(Stack, { rowGap: 24, children: [_jsx(Textfield, { ...args, label: "Filled", defaultValue: "Sample value" }), _jsx(Textfield, { ...args, label: "Filled read only", defaultValue: "Sample value", readOnly: true }), _jsx(Textfield, { ...args, label: "Empty disbled", placeholder: "Placeholder", disabled: true }), _jsx(Textfield, { ...args, label: "Filled disabled", defaultValue: "Sample value", disabled: true }), _jsx(Textfield, { ...args, type: "password", label: "Type password", defaultValue: "912435jh345" }), _jsx(Textfield, { ...args, type: "number", label: "Type number", defaultValue: 100 }), _jsx(Textfield, { ...args, type: "search", label: "Type search" }), _jsx(Textfield, { ...args, type: "date", label: "Type date" }), _jsx(Textfield, { ...args, type: "time", label: "Type time" }), _jsx(Textfield, { ...args, type: "month", label: "Type month" }), _jsx(Textfield, { ...args, type: "week", label: "Type week" }), _jsx(Textfield, { ...args, type: "datetime-local", label: "Type datetime-local" })] }));
44
44
  export const Single = SingleTemplate.bind({});
45
45
  Single.args = {
46
46
  disabled: false,
47
- label: 'Empty',
47
+ label: 'Label',
48
+ message: 'Sample hint text',
48
49
  };
49
50
  Single.argTypes = {
50
51
  textarea: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
- "version": "10.17.1",
3
+ "version": "10.18.0",
4
4
  "description": "UI components from Wonderflow's Wanda design system",
5
5
  "author": "Wonderflow",
6
6
  "license": "Apache-2.0",
@@ -74,8 +74,8 @@
74
74
  "@types/react": "17.0.43",
75
75
  "@types/react-dom": "17.0.14",
76
76
  "@types/react-table": "7.7.12",
77
- "@wonderflow/config": "10.17.1",
78
- "@wonderflow/tokens": "10.17.1",
77
+ "@wonderflow/config": "10.18.0",
78
+ "@wonderflow/tokens": "10.18.0",
79
79
  "babel-loader": "8.2.5",
80
80
  "cpy-cli": "3.1.1",
81
81
  "postcss": "8.4.17",