@arc-ui/components 3.0.0 → 5.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.
@@ -4,7 +4,7 @@ declare type Ref = React.Ref<HTMLInputElement>;
4
4
  /**
5
5
  * Use `Checkbox` to allow users to select individual options.
6
6
  */
7
- declare const Checkbox: React.ForwardRefExoticComponent<Pick<CheckboxProps, "label" | "id" | "onChange" | "value" | "isDisabled" | "errorMessage" | "helper" | "isRequired" | "name" | "isChecked"> & React.RefAttributes<HTMLInputElement>>;
7
+ declare const Checkbox: React.ForwardRefExoticComponent<Pick<CheckboxProps, "label" | "id" | "onBlur" | "onChange" | "value" | "size" | "isDisabled" | "errorMessage" | "helper" | "name" | "isRequired" | "checked"> & React.RefAttributes<HTMLInputElement>>;
8
8
  export interface CheckboxProps {
9
9
  /**
10
10
  * Error message for the Checkbox.
@@ -19,9 +19,9 @@ export interface CheckboxProps {
19
19
  */
20
20
  id: string;
21
21
  /**
22
- * Is the input checked (controlled).
22
+ * Is the input checked?
23
23
  */
24
- isChecked?: boolean;
24
+ checked?: boolean;
25
25
  /**
26
26
  * Should the Checkbox be disabled?
27
27
  */
@@ -37,18 +37,27 @@ export interface CheckboxProps {
37
37
  /**
38
38
  * Name for the Checkbox.
39
39
  */
40
- name: string;
40
+ name?: string;
41
41
  /**
42
- * onChange callback.
42
+ * Function to call when the Checkbox loses focus.
43
+ */
44
+ onBlur?: (e: EventType) => void;
45
+ /**
46
+ * Callback function to update the Checkbox's controlled `checked` prop, for
47
+ * example `e => setChecked(e.target.checked)`.
43
48
  */
44
49
  onChange?: (event: EventType) => void;
45
50
  /**
46
51
  * Optional property to provide component Ref
47
52
  */
48
53
  ref?: Ref;
54
+ /**
55
+ * Size of the Checkbox.
56
+ */
57
+ size?: "s" | "l";
49
58
  /**
50
59
  * Value for the Checkbox.
51
60
  */
52
- value: string;
61
+ value?: string;
53
62
  }
54
63
  export default Checkbox;
@@ -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";
@@ -4,7 +4,6 @@ import { FC } from "react";
4
4
  * Use `Icon` to display brand iconography.
5
5
  */
6
6
  declare const Icon: FC<IconProps>;
7
- export { icons };
8
7
  export declare const colors: readonly ["auto", "brand", "statusRed", "statusAmber", "statusGreen"];
9
8
  export interface IconProps {
10
9
  /**
@@ -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
+ * Default value.
14
14
  */
15
- defaultValue?: string;
15
+ defaultValue: 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 `defaultValue` prop,
46
+ * for example `e => setDefaultValue(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;
6
+ groupDisabled: boolean;
7
7
  isChecked: string;
8
- isDisabled: boolean;
9
- isInvalid: boolean;
10
- isRequired: boolean;
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,4 +1,5 @@
1
1
  import React, { FC, ReactNode } from "react";
2
+ import { subBrands } from "../BrandLogo/BrandLogo";
2
3
  import Column from "./components/Column";
3
4
  import Item from "./components/Item";
4
5
  import ItemGroup from "./components/ItemGroup";
@@ -60,6 +61,10 @@ export interface SiteHeaderProps {
60
61
  * Search component for the SiteHeader.
61
62
  */
62
63
  search?: ReactNode;
64
+ /**
65
+ * Optional sub-brand variant. Only applies to BT.
66
+ */
67
+ subBrand?: typeof subBrands[number];
63
68
  }
64
69
  export { Context as SiteHeaderContext };
65
70
  export default SiteHeader;
@@ -5,9 +5,19 @@ export interface ItemGroupProps {
5
5
  * Contents of the ItemGroup. Must be Item components.
6
6
  */
7
7
  children: ReactNode;
8
+ /**
9
+ * A top-level URL for the ItemGroup to link to.
10
+ */
11
+ href?: string;
8
12
  /**
9
13
  * Title text to be displayed in the ItemGroup summary.
10
14
  */
11
15
  title: string;
16
+ /**
17
+ * Text to display in top-level link inside the ItemGroup in narrow viewports.
18
+ * Only applies if `href` is present. If not provided, top-level link text
19
+ * will be automatically generated from `title`.
20
+ */
21
+ viewAllTitle?: string;
12
22
  }
13
23
  export default ItemGroup;
@@ -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": "3.0.0",
3
+ "version": "5.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",
@@ -11,7 +11,7 @@
11
11
  "storybook": "start-storybook --ci -p 6006 --no-manager-cache",
12
12
  "storybook:build": "build-storybook --docs --quiet",
13
13
  "storybook:quiet": "yarn storybook --quiet",
14
- "test": "jest",
14
+ "test": "TZ=UTC jest",
15
15
  "test:coverage": "yarn test --coverage",
16
16
  "test:watch": "yarn test --changedSince=origin/master --coverage --watch"
17
17
  },
@@ -25,9 +25,10 @@
25
25
  "react": "^17.0.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@arc-ui/fonts": "^3.0.0",
29
- "@arc-ui/tokens": "^3.0.0",
28
+ "@arc-ui/fonts": "^5.0.0",
29
+ "@arc-ui/tokens": "^5.0.0",
30
30
  "@babel/core": "^7.14.3",
31
+ "@babel/helper-define-map": "^7.14.3",
31
32
  "@storybook/addon-essentials": "^6.3.6",
32
33
  "@storybook/addon-ie11": "BTEnterpriseDigital/addon-ie11#measuredco-fork",
33
34
  "@storybook/addon-links": "^6.3.6",
@@ -42,6 +43,7 @@
42
43
  "camelcase": "^6.2.1",
43
44
  "cheerio": "^1.0.0-rc.3",
44
45
  "classnames": "^2.2.6",
46
+ "formik": "^2.2.9",
45
47
  "ie-array-find-polyfill": "^1.1.0",
46
48
  "prop-types": "^15.7.2",
47
49
  "react": "^17.0.0",
@@ -49,6 +51,7 @@
49
51
  "react-dom": "^17.0.0",
50
52
  "react-is": "^17.0.0",
51
53
  "tslib": "^2.0.1",
52
- "typescript": "^4.0.2"
54
+ "typescript": "^4.0.2",
55
+ "yup": "^0.32.11"
53
56
  }
54
57
  }