@arc-ui/components 4.0.0 → 6.0.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,4 +1,8 @@
1
1
  import React, { FC } from "react";
2
+ declare type RequirementStatus = "required" | "optional" | "not-applicable";
3
+ declare const Context: React.Context<{
4
+ requirementStatus: RequirementStatus | null;
5
+ }>;
2
6
  /**
3
7
  * Use `FormControl` to provide inputs with labels, helper text and error messages
4
8
  */
@@ -30,9 +34,10 @@ export interface FormControlProps {
30
34
  */
31
35
  id?: string;
32
36
  /**
33
- * Is the input(s) required?
37
+ * Are all of the inputs in the FormControl required, optional, or is a
38
+ * uniform requirement status for all inputs not applicable?
34
39
  */
35
- isRequired?: boolean;
40
+ requirementStatus?: RequirementStatus;
36
41
  /**
37
42
  * Label for the FormControl.
38
43
  */
@@ -42,4 +47,5 @@ export interface FormControlProps {
42
47
  */
43
48
  labelSize?: "s" | "l";
44
49
  }
50
+ export { Context as FormControlContext };
45
51
  export default FormControl;
@@ -1 +1 @@
1
- export { default } from "./FormControl";
1
+ export { default, FormControlContext } from "./FormControl";
@@ -8,6 +8,10 @@ export interface RadioButtonProps {
8
8
  * ID for the Radio Button.
9
9
  */
10
10
  id: string;
11
+ /**
12
+ * Should the RadioButton be disabled?
13
+ */
14
+ isDisabled?: boolean;
11
15
  /**
12
16
  * Helper text for the RadioButton, shown below the label.
13
17
  */
@@ -8,23 +8,15 @@ declare type EventType = React.ChangeEvent<HTMLInputElement>;
8
8
  declare const RadioGroup: FC<RadioGroupProps> & {
9
9
  RadioButton: typeof RadioButton;
10
10
  };
11
- export interface RadioGroupProps extends Omit<FormControlProps, "children" | "elementType" | "htmlFor" | "labelSize"> {
11
+ export interface RadioGroupProps extends Omit<FormControlProps, "children" | "elementType" | "errorMessage" | "htmlFor" | "labelSize" | "requirementStatus"> {
12
12
  /**
13
- * Default value (uncontrolled).
13
+ * Value of the RadioButton that should be checked by default.
14
14
  */
15
- defaultValue?: string;
15
+ checkedValue: string;
16
16
  /**
17
17
  * Should all controls be disabled?
18
18
  */
19
19
  isDisabled?: boolean;
20
- /**
21
- * Should all control be required?
22
- */
23
- isRequired?: boolean;
24
- /**
25
- * Error message for the RadioGroup.
26
- */
27
- errorMessage?: string;
28
20
  /**
29
21
  * Helper message for the RadioGroup.
30
22
  */
@@ -37,13 +29,26 @@ export interface RadioGroupProps extends Omit<FormControlProps, "children" | "el
37
29
  * Label for the RadioGroup.
38
30
  */
39
31
  label: string;
32
+ /**
33
+ * Label size for the RadioGroup
34
+ */
35
+ labelSize?: "s" | "l";
40
36
  /**
41
37
  * Name for the RadioGroup.
42
38
  */
43
39
  name: string;
44
40
  /**
45
- * onChange callback.
41
+ * Function to call when the RadioGroup loses focus.
42
+ */
43
+ onBlur?: (e: EventType) => void;
44
+ /**
45
+ * Callback function to update the RadioGroup's controlled `checkedValue` prop,
46
+ * for example `e => setCheckedValue(e.target.value)`.
46
47
  */
47
48
  onChange?: (event: EventType) => void;
49
+ /**
50
+ * Size of the RadioGroup.
51
+ */
52
+ size?: "s" | "l";
48
53
  }
49
54
  export default RadioGroup;
@@ -1,14 +1,13 @@
1
1
  import React from "react";
2
2
  declare type EventType = React.ChangeEvent<HTMLInputElement>;
3
3
  declare type ContextProps = {
4
+ blurEvent: (event: EventType) => void;
4
5
  changeEvent: (event: EventType) => void;
5
- errorId: string;
6
- errorMessage: string;
7
- isChecked: string;
8
- isDisabled: boolean;
9
- isInvalid: boolean;
10
- isRequired: boolean;
6
+ groupDisabled: boolean;
7
+ checkedValue: string;
8
+ labelSize: "s" | "l";
11
9
  name: string;
10
+ size: "s" | "l";
12
11
  };
13
12
  export declare const Provider: React.Provider<ContextProps>;
14
13
  export declare const useRadioContext: () => ContextProps;
@@ -1,14 +1,14 @@
1
1
  import React, { FC } from "react";
2
2
  import { FormControlProps } from "../FormControl/FormControl";
3
3
  declare type EventType = React.ChangeEvent<HTMLInputElement>;
4
- declare type Ref = React.Ref<HTMLInputElement>;
5
4
  /**
6
5
  * Use `TextInput` to allow custom user text entry with a keyboard.
7
6
  */
8
7
  declare const TextInput: FC<TextInputProps>;
9
- export interface TextInputProps extends Omit<FormControlProps, "children" | "elementType"> {
8
+ export interface TextInputProps extends Omit<FormControlProps, "children" | "elementType" | "htmlFor" | "requirementStatus"> {
10
9
  /**
11
- * Default value (uncontrolled).
10
+ * Uncontrolled default value of the TextInput. If the TextInput is controlled
11
+ * via `value`/`onChange`, `defaultValue` will be ignored.
12
12
  */
13
13
  defaultValue?: string;
14
14
  /**
@@ -27,6 +27,10 @@ export interface TextInputProps extends Omit<FormControlProps, "children" | "ele
27
27
  * Should the control be read-only?
28
28
  */
29
29
  isReadOnly?: boolean;
30
+ /**
31
+ * Should the control be required?
32
+ */
33
+ isRequired?: boolean;
30
34
  /**
31
35
  * Maximum number of characters.
32
36
  */
@@ -40,23 +44,25 @@ export interface TextInputProps extends Omit<FormControlProps, "children" | "ele
40
44
  */
41
45
  name?: string;
42
46
  /**
43
- * onChange callback. Must be provided if providing `value` prop.
47
+ * Function to call when the TextInput loses focus.
48
+ */
49
+ onBlur?: (e: EventType) => void;
50
+ /**
51
+ * Callback function commonly used to update the TextInput's controlled
52
+ * `value`, for example `e => setValue(e.target.value)`.
44
53
  */
45
54
  onChange?: (e: EventType) => void;
46
55
  /**
47
56
  * Validation regex pattern.
48
57
  */
49
58
  pattern?: string;
50
- /**
51
- * Optional property to provide component Ref
52
- */
53
- ref?: Ref;
54
59
  /**
55
60
  * Type for the input. `number` will be changed to `text` and set the `numeric` inputMode.
56
61
  */
57
62
  type?: "email" | "number" | "password" | "tel" | "text" | "url";
58
63
  /**
59
- * Current value (controlled). Must use with `onChange` if editable. Otherwise, use `defaultValue` or `isReadOnly`.
64
+ * Current value of the TextInput. Must be controlled via an
65
+ * `onChange` callback function. Otherwise, use `defaultValue` (or `isReadOnly`).
60
66
  */
61
67
  value?: string;
62
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arc-ui/components",
3
- "version": "4.0.0",
3
+ "version": "6.0.0",
4
4
  "homepage": "https://ui.digital-ent-int.bt.com",
5
5
  "author": "BT Enterprise Digital UI Team <ui-digital-ent-int@bt.com>",
6
6
  "main": "dist/index.js",
@@ -25,8 +25,8 @@
25
25
  "react": "^17.0.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@arc-ui/fonts": "^4.0.0",
29
- "@arc-ui/tokens": "^4.0.0",
28
+ "@arc-ui/fonts": "^6.0.0",
29
+ "@arc-ui/tokens": "^6.0.0",
30
30
  "@babel/core": "^7.14.3",
31
31
  "@babel/helper-define-map": "^7.14.3",
32
32
  "@storybook/addon-essentials": "^6.3.6",
@@ -43,6 +43,7 @@
43
43
  "camelcase": "^6.2.1",
44
44
  "cheerio": "^1.0.0-rc.3",
45
45
  "classnames": "^2.2.6",
46
+ "formik": "^2.2.9",
46
47
  "ie-array-find-polyfill": "^1.1.0",
47
48
  "prop-types": "^15.7.2",
48
49
  "react": "^17.0.0",
@@ -50,6 +51,7 @@
50
51
  "react-dom": "^17.0.0",
51
52
  "react-is": "^17.0.0",
52
53
  "tslib": "^2.0.1",
53
- "typescript": "^4.0.2"
54
+ "typescript": "^4.0.2",
55
+ "yup": "^0.32.11"
54
56
  }
55
57
  }