@bspk/ui 1.1.13 → 1.1.14
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/dist/Checkbox.d.ts +1 -1
- package/dist/Checkbox.js +2 -2
- package/dist/Checkbox.js.map +1 -1
- package/dist/CheckboxOption.d.ts +2 -1
- package/dist/Dropdown.d.ts +3 -3
- package/dist/Dropdown.js +2 -1
- package/dist/Dropdown.js.map +1 -1
- package/dist/FormField.d.ts +5 -4
- package/dist/FormField.js +3 -3
- package/dist/FormField.js.map +1 -1
- package/dist/InlineAlert.js +1 -1
- package/dist/ListItem.d.ts +1 -1
- package/dist/ListItem.js +2 -2
- package/dist/ListItem.js.map +1 -1
- package/dist/NumberField.d.ts +2 -1
- package/dist/NumberInput.d.ts +22 -8
- package/dist/NumberInput.js +5 -2
- package/dist/NumberInput.js.map +1 -1
- package/dist/Radio.d.ts +2 -2
- package/dist/Radio.js.map +1 -1
- package/dist/RadioOption.d.ts +2 -1
- package/dist/RadioOption.js.map +1 -1
- package/dist/TextField.d.ts +2 -1
- package/dist/TextField.js.map +1 -1
- package/dist/TextInput.d.ts +3 -3
- package/dist/TextInput.js +2 -2
- package/dist/TextInput.js.map +1 -1
- package/dist/Textarea.d.ts +7 -7
- package/dist/Textarea.js +2 -2
- package/dist/Textarea.js.map +1 -1
- package/dist/form-field.css +1 -1
- package/dist/hooks/useFloatingMenu.d.ts +3 -2
- package/dist/hooks/useFloatingMenu.js +1 -0
- package/dist/hooks/useFloatingMenu.js.map +1 -1
- package/dist/index.d.ts +22 -13
- package/dist/index.js.map +1 -1
- package/dist/inline-alert.css +1 -1
- package/dist/number-input.css +1 -1
- package/package.json +2 -2
- package/src/Checkbox.tsx +3 -0
- package/src/CheckboxOption.tsx +4 -4
- package/src/Dropdown.tsx +5 -2
- package/src/FormField.tsx +35 -24
- package/src/ListItem.tsx +2 -0
- package/src/NumberField.tsx +5 -5
- package/src/NumberInput.tsx +38 -24
- package/src/Radio.tsx +3 -5
- package/src/RadioOption.tsx +4 -1
- package/src/TextField.tsx +19 -17
- package/src/TextInput.tsx +33 -30
- package/src/Textarea.tsx +51 -48
- package/src/form-field.scss +2 -1
- package/src/hooks/useFloatingMenu.ts +4 -2
- package/src/index.ts +24 -13
- package/src/inline-alert.scss +1 -1
- package/src/number-input.scss +6 -3
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export type CallToActionButton = {
|
|
|
24
24
|
/** The size of the call to action button. */
|
|
25
25
|
size?: ButtonSize;
|
|
26
26
|
};
|
|
27
|
-
export type ToggleControlProps<T extends HTMLElement> = CommonProps<'aria-label' | 'disabled' | '
|
|
27
|
+
export type ToggleControlProps<T extends HTMLElement> = CommonProps<'aria-label' | 'disabled' | 'name', T> & InvalidPropsLibrary & Required<CommonProps<'value'>> & {
|
|
28
28
|
/**
|
|
29
29
|
* Marks the control as checked.
|
|
30
30
|
*
|
|
@@ -40,6 +40,27 @@ export type ToggleControlProps<T extends HTMLElement> = CommonProps<'aria-label'
|
|
|
40
40
|
onChange: (checked: boolean, event: ChangeEvent<T>) => void;
|
|
41
41
|
};
|
|
42
42
|
export type CommonProps<K extends keyof CommonPropsLibrary, T extends HTMLElement = HTMLElement> = Pick<CommonPropsLibrary<T>, K>;
|
|
43
|
+
/**
|
|
44
|
+
* The props that are common to input elements.
|
|
45
|
+
*
|
|
46
|
+
* If an element is invalid it must have an errorMessage.
|
|
47
|
+
*/
|
|
48
|
+
export type InvalidPropsLibrary = {
|
|
49
|
+
/**
|
|
50
|
+
* Marks the element as invalid and displays error state theme.
|
|
51
|
+
*
|
|
52
|
+
* If the errorMessage is empty the error state theme will not appear.
|
|
53
|
+
*
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
invalid?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Marks the element as invalid and displays error message.
|
|
59
|
+
*
|
|
60
|
+
* When an element is invalid it must display an error message explaining why it is invalid.
|
|
61
|
+
*/
|
|
62
|
+
errorMessage?: string;
|
|
63
|
+
};
|
|
43
64
|
export type CommonPropsLibrary<T extends HTMLElement = HTMLElement> = {
|
|
44
65
|
/** The id of the element. If not provided one will be generated. */
|
|
45
66
|
id?: string;
|
|
@@ -73,12 +94,6 @@ export type CommonPropsLibrary<T extends HTMLElement = HTMLElement> = {
|
|
|
73
94
|
* @default false
|
|
74
95
|
*/
|
|
75
96
|
disabled?: boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Marks the element as invalid and displays error state theme.
|
|
78
|
-
*
|
|
79
|
-
* @default false
|
|
80
|
-
*/
|
|
81
|
-
invalid?: boolean;
|
|
82
97
|
/**
|
|
83
98
|
* Determines if the element is [readonly](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly).
|
|
84
99
|
*
|
|
@@ -91,12 +106,6 @@ export type CommonPropsLibrary<T extends HTMLElement = HTMLElement> = {
|
|
|
91
106
|
* @required
|
|
92
107
|
*/
|
|
93
108
|
name: string;
|
|
94
|
-
/**
|
|
95
|
-
* Marks the element as invalid and displays error message.
|
|
96
|
-
*
|
|
97
|
-
* When an element is invalid it must display an error message explaining why it is invalid.
|
|
98
|
-
*/
|
|
99
|
-
errorMessage?: string;
|
|
100
109
|
/**
|
|
101
110
|
* The value of the control.
|
|
102
111
|
*
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA0JH,MAAM,CAAC,MAAM,MAAM,GAAqC;IACpD,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;IACvC,EAAE,KAAK,EAAE,wBAAwB,EAAE,IAAI,EAAE,sBAAsB,EAAE;IACjE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IACnC,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE;IAC3C,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,EAAE;IACrD,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;IACvC,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE;IAC7C,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IAC7B,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE;CAClC,CAAC;AAEX,sDAAsD"}
|
package/dist/inline-alert.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[data-bspk=inline-alert]{display:flex;align-items:start;justify-content:
|
|
1
|
+
[data-bspk=inline-alert]{display:flex;align-items:start;justify-content:start;flex-direction:row;gap:var(--spacing-sizing-02)}[data-bspk=inline-alert] [data-txt]{flex:1}[data-bspk=inline-alert][data-variant=error]{color:var(--status-error);--first-tone: var(--status-error);--second-tone: var(--status-on-information)}[data-bspk=inline-alert][data-variant=success]{color:var(--status-success);--first-tone: var(--status-success);--second-tone: var(--status-on-success)}[data-bspk=inline-alert][data-variant=warning]{color:var(--foreground-neutral-on-surface);--first-tone: var(--status-warning);--second-tone: var(--status-on-warning)}[data-bspk=inline-alert][data-variant=informational]{color:var(--status-information);--first-tone: var(--status-information);--second-tone: var(--status-on-information)}[data-bspk=inline-alert] svg{color:var(--first-tone);width:var(--spacing-sizing-05);height:var(--spacing-sizing-05)}[data-bspk=inline-alert] svg [data-second-tone]{fill:var(--second-tone)}
|
package/dist/number-input.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[data-bspk=number-input]{--font: var(--body-base);--height: var(--spacing-sizing-10);--svg-width: var(--spacing-sizing-05);--color: var(--foreground-neutral-on-surface);width:100%;display:flex;flex-flow:row nowrap;font:var(--font);height:var(--height);border:1px solid var(--stroke-neutral-base);border-radius:var(--radius-small);background:var(--surface-neutral-t1-base)}[data-bspk=number-input]:focus-within{border-color:var(--stroke-brand-primary)
|
|
1
|
+
[data-bspk=number-input]{--font: var(--body-base);--height: var(--spacing-sizing-10);--svg-width: var(--spacing-sizing-05);--color: var(--foreground-neutral-on-surface);width:100%;display:flex;flex-flow:row nowrap;font:var(--font);height:var(--height);border:1px solid var(--stroke-neutral-base);border-radius:var(--radius-small);background:var(--surface-neutral-t1-base);max-width:280px}[data-bspk=number-input]:focus-within{border-color:var(--stroke-brand-primary)}[data-bspk=number-input] [data-divider]{width:4px;border-right:1px solid var(--stroke-neutral-base);height:calc(var(--height) - 8px);margin:3px 0}[data-bspk=number-input] button{width:var(--height);height:var(--height);background:none;border:none;cursor:pointer;font:var(--font);flex-shrink:0;display:flex;justify-content:center;align-items:center;color:var(--color)}[data-bspk=number-input] button svg{width:var(--svg-width)}[data-bspk=number-input] button:disabled{cursor:not-allowed;color:var(--foreground-neutral-disabled-on-surface)}[data-bspk=number-input] input{color:var(--color);min-width:0;display:block;font:var(--font);text-align:center;padding:0 var(--spacing-sizing-03);background:rgba(0,0,0,0);border:none;flex-grow:1}[data-bspk=number-input] input:focus{outline:none}[data-bspk=number-input] input::-webkit-outer-spin-button,[data-bspk=number-input] input::-webkit-inner-spin-button{appearance:none;margin:0}[data-bspk=number-input] input[type=number]{appearance:textfield}[data-bspk=number-input]:not([data-disabled],[data-readonly]) input:hover,[data-bspk=number-input]:not([data-disabled],[data-readonly]) button:not(:disabled):hover{background-color:var(--interactions-hover-opacity)}[data-bspk=number-input]:not([data-disabled],[data-readonly]) input:active,[data-bspk=number-input]:not([data-disabled],[data-readonly]) button:not(:disabled):active{background-color:var(--interactions-press-opacity)}[data-bspk=number-input]:not([data-disabled],[data-readonly])[data-invalid]{border-color:var(--status-error);outline-color:var(--status-error)}[data-bspk=number-input][data-disabled],[data-bspk=number-input][data-readonly]{--color: var(--foreground-neutral-disabled-on-surface);border-color:var(--stroke-neutral-disabled-light);background:linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=number-input][data-disabled] [data-divider],[data-bspk=number-input][data-readonly] [data-divider]{border-color:var(--stroke-neutral-disabled-light)}[data-bspk=number-input][data-readonly] input{color:var(--foreground-neutral-on-surface) !important}[data-bspk=number-input][data-size=small]{--font: var(--body-small);--height: var(--spacing-sizing-08)}[data-bspk=number-input][data-size=large]{--font: var(--body-large);--height: var(--spacing-sizing-12);--svg-width: var(--spacing-sizing-06)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bspk/ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
4
4
|
"license": "CC-BY-4.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"sass": "sass --style=compressed --no-source-map src:dist",
|
|
20
20
|
"build": "tsx build.ts",
|
|
21
21
|
"lint:css": "npx stylelint '**/*.scss'",
|
|
22
|
-
"lint": "eslint",
|
|
22
|
+
"lint": "eslint && tsc --noEmit && stylelint '**/*.scss'",
|
|
23
23
|
"lint:fix": "eslint --fix",
|
|
24
24
|
"semantic-release": "semantic-release",
|
|
25
25
|
"test": "jest",
|
package/src/Checkbox.tsx
CHANGED
|
@@ -27,6 +27,8 @@ function Checkbox({
|
|
|
27
27
|
indeterminate: indeterminateProp,
|
|
28
28
|
invalid,
|
|
29
29
|
disabled,
|
|
30
|
+
errorMessage,
|
|
31
|
+
|
|
30
32
|
...props
|
|
31
33
|
}: ElementProps<CheckboxProps, 'input'>) {
|
|
32
34
|
const indeterminate = !!indeterminateProp;
|
|
@@ -46,6 +48,7 @@ function Checkbox({
|
|
|
46
48
|
>
|
|
47
49
|
<input
|
|
48
50
|
{...props}
|
|
51
|
+
aria-errormessage={errorMessage || undefined}
|
|
49
52
|
aria-invalid={invalid || undefined}
|
|
50
53
|
checked={checked}
|
|
51
54
|
disabled={disabled || undefined}
|
package/src/CheckboxOption.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CheckboxProps, Checkbox } from './Checkbox';
|
|
2
2
|
import { ToggleOptionProps, ToggleOption } from './ToggleOption';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
> &
|
|
4
|
+
import { InvalidPropsLibrary } from '.';
|
|
5
|
+
|
|
6
|
+
export type CheckboxOptionProps = InvalidPropsLibrary &
|
|
7
|
+
Pick<CheckboxProps, 'checked' | 'disabled' | 'indeterminate' | 'name' | 'onChange' | 'value'> &
|
|
8
8
|
Pick<ToggleOptionProps, 'description' | 'label'>;
|
|
9
9
|
|
|
10
10
|
/**
|
package/src/Dropdown.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import { Placement } from './hooks/useFloating';
|
|
|
8
8
|
import { useFloatingMenu } from './hooks/useFloatingMenu';
|
|
9
9
|
import { useId } from './hooks/useId';
|
|
10
10
|
|
|
11
|
-
import { CommonProps } from './';
|
|
11
|
+
import { CommonProps, InvalidPropsLibrary } from './';
|
|
12
12
|
|
|
13
13
|
export type DropdownOption = {
|
|
14
14
|
/** The value of the option. */
|
|
@@ -18,8 +18,9 @@ export type DropdownOption = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export type DropdownProps<O extends DropdownOption = DropdownOption> = CommonProps<
|
|
21
|
-
'aria-label' | 'disabled' | 'id' | '
|
|
21
|
+
'aria-label' | 'disabled' | 'id' | 'name' | 'readOnly' | 'size'
|
|
22
22
|
> &
|
|
23
|
+
InvalidPropsLibrary &
|
|
23
24
|
Pick<MenuProps<O>, 'isMulti' | 'itemCount' | 'onChange' | 'renderListItem'> & {
|
|
24
25
|
/**
|
|
25
26
|
* Array of options to display in the dropdown
|
|
@@ -66,6 +67,7 @@ function Dropdown<O extends DropdownOption = DropdownOption>({
|
|
|
66
67
|
disabled,
|
|
67
68
|
id: propId,
|
|
68
69
|
invalid,
|
|
70
|
+
errorMessage,
|
|
69
71
|
readOnly,
|
|
70
72
|
placement = 'bottom',
|
|
71
73
|
name,
|
|
@@ -81,6 +83,7 @@ function Dropdown<O extends DropdownOption = DropdownOption>({
|
|
|
81
83
|
disabled,
|
|
82
84
|
invalid,
|
|
83
85
|
readOnly,
|
|
86
|
+
errorMessage,
|
|
84
87
|
},
|
|
85
88
|
});
|
|
86
89
|
|
package/src/FormField.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { InlineAlert } from './InlineAlert';
|
|
|
3
3
|
import { Layout } from './Layout';
|
|
4
4
|
import { Txt } from './Txt';
|
|
5
5
|
|
|
6
|
-
import { CommonProps } from './';
|
|
6
|
+
import { CommonProps, InvalidPropsLibrary } from './';
|
|
7
7
|
|
|
8
8
|
export type FieldControlProps = {
|
|
9
9
|
/**
|
|
@@ -18,27 +18,29 @@ export type FieldControlProps = {
|
|
|
18
18
|
'aria-errormessage'?: string;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export type FormFieldProps = CommonProps<'
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
21
|
+
export type FormFieldProps = CommonProps<'required'> &
|
|
22
|
+
InvalidPropsLibrary & {
|
|
23
|
+
/**
|
|
24
|
+
* The label of the field.
|
|
25
|
+
*
|
|
26
|
+
* @required
|
|
27
|
+
*/
|
|
28
|
+
label: string;
|
|
29
|
+
/** The id of the control. */
|
|
30
|
+
controlId: string;
|
|
31
|
+
/**
|
|
32
|
+
* The children of the form field. This should be a control such as TextInput, Dropdown, DatePicker, or
|
|
33
|
+
* TimePicker.
|
|
34
|
+
*
|
|
35
|
+
* @type (childProps: FieldControlProps) => JSX.Element
|
|
36
|
+
* @required
|
|
37
|
+
*/
|
|
38
|
+
children: (childProps: FieldControlProps) => JSX.Element;
|
|
39
|
+
/** The helperText of the field. */
|
|
40
|
+
helperText?: string;
|
|
41
|
+
/** The trailing element of the label. */
|
|
42
|
+
labelTrailing?: React.ReactNode;
|
|
43
|
+
};
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
46
|
* Wrapper component for form controls.
|
|
@@ -47,14 +49,23 @@ export type FormFieldProps = CommonProps<'errorMessage' | 'required'> & {
|
|
|
47
49
|
*
|
|
48
50
|
* @name FormField
|
|
49
51
|
*/
|
|
50
|
-
function FormField({
|
|
52
|
+
function FormField({
|
|
53
|
+
label,
|
|
54
|
+
invalid,
|
|
55
|
+
errorMessage,
|
|
56
|
+
helperText,
|
|
57
|
+
children,
|
|
58
|
+
labelTrailing,
|
|
59
|
+
controlId,
|
|
60
|
+
required,
|
|
61
|
+
}: FormFieldProps) {
|
|
51
62
|
const errorMessageId = errorMessage && `${controlId}-error-message`;
|
|
52
63
|
const helperTextId = helperText && `${controlId}-helper-text`;
|
|
53
64
|
|
|
54
65
|
if (typeof children !== 'function') return null;
|
|
55
66
|
|
|
56
67
|
return (
|
|
57
|
-
<div data-bspk="form-field">
|
|
68
|
+
<div data-bspk="form-field" data-invalid={invalid || undefined}>
|
|
58
69
|
<Layout as="header">
|
|
59
70
|
<label htmlFor={controlId}>
|
|
60
71
|
<Txt as="span" variant="labels-small">
|
package/src/ListItem.tsx
CHANGED
|
@@ -81,6 +81,7 @@ function ListItem<As extends ElementType = 'div'>({
|
|
|
81
81
|
subText,
|
|
82
82
|
active,
|
|
83
83
|
readOnly,
|
|
84
|
+
errorMessage,
|
|
84
85
|
...props
|
|
85
86
|
}: ElementProps<ListItemProps<As>, As>) {
|
|
86
87
|
let As: ElementType = as || 'div';
|
|
@@ -120,6 +121,7 @@ function ListItem<As extends ElementType = 'div'>({
|
|
|
120
121
|
<As
|
|
121
122
|
{...props}
|
|
122
123
|
aria-disabled={disabled || undefined}
|
|
124
|
+
aria-errormessage={errorMessage || undefined}
|
|
123
125
|
aria-invalid={invalid || undefined}
|
|
124
126
|
data-action={actionable || undefined}
|
|
125
127
|
data-active={active || undefined}
|
package/src/NumberField.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FormFieldProps, FormField } from './FormField';
|
|
2
2
|
import { NumberInputProps, NumberInput } from './NumberInput';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
> &
|
|
8
|
-
Pick<
|
|
4
|
+
import { InvalidPropsLibrary } from '.';
|
|
5
|
+
|
|
6
|
+
export type NumberFieldProps = InvalidPropsLibrary &
|
|
7
|
+
Pick<FormFieldProps, 'controlId' | 'errorMessage' | 'helperText' | 'label' | 'labelTrailing' | 'required'> &
|
|
8
|
+
Pick<NumberInputProps, 'align' | 'disabled' | 'id' | 'name' | 'onChange' | 'readOnly' | 'size' | 'value'>;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* A input element that allows users to either input a numerical value or singularly increase or decrease the values by
|
package/src/NumberInput.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import './number-input.scss';
|
|
|
5
5
|
import { useId } from './hooks/useId';
|
|
6
6
|
import { useLongPress } from './hooks/useLongPress';
|
|
7
7
|
|
|
8
|
-
import { CommonProps } from '.';
|
|
8
|
+
import { CommonProps, InvalidPropsLibrary } from '.';
|
|
9
9
|
|
|
10
10
|
function isNumber(value: unknown): number | undefined {
|
|
11
11
|
if (typeof value === 'number') return value;
|
|
@@ -14,40 +14,53 @@ function isNumber(value: unknown): number | undefined {
|
|
|
14
14
|
return isNaN(num) ? undefined : num;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export type NumberInputProps = CommonProps<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
export type NumberInputProps = CommonProps<'aria-label' | 'disabled' | 'id' | 'name' | 'readOnly' | 'size'> &
|
|
18
|
+
InvalidPropsLibrary & {
|
|
19
|
+
/**
|
|
20
|
+
* The value of the control.
|
|
21
|
+
*
|
|
22
|
+
* @required
|
|
23
|
+
*/
|
|
24
|
+
value?: number;
|
|
25
|
+
/** Callback when the value changes. */
|
|
26
|
+
onChange: (value: number) => void;
|
|
27
|
+
/**
|
|
28
|
+
* The alignment of the input box. Centered between the plus and minus buttons or to the left of the buttons.
|
|
29
|
+
*
|
|
30
|
+
* @default center
|
|
31
|
+
*/
|
|
32
|
+
align?: 'center' | 'left';
|
|
33
|
+
/**
|
|
34
|
+
* Defines the [maximum](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/max) value that is
|
|
35
|
+
* accepted.
|
|
36
|
+
*
|
|
37
|
+
* @default 99
|
|
38
|
+
* @maximum 99
|
|
39
|
+
* @minimum 1
|
|
40
|
+
*/
|
|
41
|
+
max?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Defines the [minimum](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/min) value that is
|
|
44
|
+
* accepted.
|
|
45
|
+
*
|
|
46
|
+
* @minimum 0
|
|
47
|
+
*/
|
|
48
|
+
min?: number;
|
|
49
|
+
};
|
|
39
50
|
|
|
40
51
|
/**
|
|
41
52
|
* A input element that allows users to either input a numerical value or singularly increase or decrease the values by
|
|
42
53
|
* pressing the (+) or (-).
|
|
43
54
|
*
|
|
55
|
+
* The value of the input is a number. The value is clamped to the min and max values if they are provided.
|
|
56
|
+
*
|
|
44
57
|
* @name NumberInput
|
|
45
58
|
*/
|
|
46
59
|
function NumberInput({
|
|
47
60
|
//
|
|
48
61
|
value = 1,
|
|
49
62
|
onChange,
|
|
50
|
-
|
|
63
|
+
align = 'center',
|
|
51
64
|
size = 'medium',
|
|
52
65
|
disabled = false,
|
|
53
66
|
readOnly = false,
|
|
@@ -58,6 +71,7 @@ function NumberInput({
|
|
|
58
71
|
max: maxProp,
|
|
59
72
|
min: minProp,
|
|
60
73
|
}: NumberInputProps) {
|
|
74
|
+
const centered = align !== 'left';
|
|
61
75
|
const inputId = useId(inputIdProp);
|
|
62
76
|
const max = isNumber(maxProp);
|
|
63
77
|
const min = isNumber(minProp);
|
package/src/Radio.tsx
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import './radio.scss';
|
|
2
|
-
import { ToggleControlProps, ElementProps } from './';
|
|
2
|
+
import { ToggleControlProps, ElementProps, InvalidPropsLibrary } from './';
|
|
3
3
|
|
|
4
|
-
export type RadioProps =
|
|
5
|
-
ToggleControlProps<HTMLInputElement>,
|
|
6
|
-
'aria-label' | 'checked' | 'disabled' | 'invalid' | 'name' | 'onChange' | 'value'
|
|
7
|
-
>;
|
|
4
|
+
export type RadioProps = InvalidPropsLibrary &
|
|
5
|
+
Pick<ToggleControlProps<HTMLInputElement>, 'aria-label' | 'checked' | 'disabled' | 'name' | 'onChange' | 'value'>;
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* A round control that allows user to choose one option from a set. This is the base element and if used directly you
|
package/src/RadioOption.tsx
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { RadioProps, Radio } from './Radio';
|
|
2
2
|
import { ToggleOptionProps, ToggleOption } from './ToggleOption';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import { InvalidPropsLibrary } from '.';
|
|
5
|
+
|
|
6
|
+
export type RadioOptionProps = InvalidPropsLibrary &
|
|
7
|
+
Pick<RadioProps, 'checked' | 'disabled' | 'name' | 'onChange' | 'value'> &
|
|
5
8
|
Pick<ToggleOptionProps, 'description' | 'label'>;
|
|
6
9
|
|
|
7
10
|
/**
|
package/src/TextField.tsx
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { FormFieldProps, FormField } from './FormField';
|
|
2
2
|
import { TextInputProps, TextInput } from './TextInput';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
import { InvalidPropsLibrary } from '.';
|
|
5
|
+
|
|
6
|
+
export type TextFieldProps = InvalidPropsLibrary &
|
|
7
|
+
Pick<
|
|
8
|
+
TextInputProps,
|
|
9
|
+
| 'autoComplete'
|
|
10
|
+
| 'disabled'
|
|
11
|
+
| 'inputRef'
|
|
12
|
+
| 'leading'
|
|
13
|
+
| 'name'
|
|
14
|
+
| 'onChange'
|
|
15
|
+
| 'placeholder'
|
|
16
|
+
| 'readOnly'
|
|
17
|
+
| 'required'
|
|
18
|
+
| 'size'
|
|
19
|
+
| 'trailing'
|
|
20
|
+
| 'type'
|
|
21
|
+
| 'value'
|
|
22
|
+
> &
|
|
21
23
|
Pick<FormFieldProps, 'controlId' | 'errorMessage' | 'helperText' | 'label' | 'labelTrailing'>;
|
|
22
24
|
|
|
23
25
|
/**
|
package/src/TextInput.tsx
CHANGED
|
@@ -4,38 +4,39 @@ import { ChangeEvent, HTMLInputAutoCompleteAttribute, HTMLInputTypeAttribute, Re
|
|
|
4
4
|
|
|
5
5
|
import { useId } from './hooks/useId';
|
|
6
6
|
|
|
7
|
-
import { ElementProps, CommonProps } from '.';
|
|
7
|
+
import { ElementProps, CommonProps, InvalidPropsLibrary } from '.';
|
|
8
8
|
|
|
9
9
|
export type TextInputProps = CommonProps<
|
|
10
|
-
'aria-label' | 'disabled' | 'id' | '
|
|
11
|
-
> &
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
10
|
+
'aria-label' | 'disabled' | 'id' | 'name' | 'readOnly' | 'required' | 'size' | 'value'
|
|
11
|
+
> &
|
|
12
|
+
InvalidPropsLibrary & {
|
|
13
|
+
/**
|
|
14
|
+
* Callback when the value of the field changes.
|
|
15
|
+
*
|
|
16
|
+
* @type (next: String, Event) => void
|
|
17
|
+
* @required
|
|
18
|
+
*/
|
|
19
|
+
onChange: (next: string, event?: ChangeEvent<HTMLInputElement>) => void;
|
|
20
|
+
/** The ref of the container. */
|
|
21
|
+
containerRef?: (node: HTMLElement | null) => void;
|
|
22
|
+
/** The ref of the input. */
|
|
23
|
+
inputRef?: (node: HTMLElement | null) => void;
|
|
24
|
+
/** The trailing element to display in the field. */
|
|
25
|
+
trailing?: ReactNode;
|
|
26
|
+
/** The leading element to display in the field. */
|
|
27
|
+
leading?: ReactNode;
|
|
28
|
+
/** The placeholder of the field. */
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
/** The type of the input. */
|
|
31
|
+
type?: Extract<HTMLInputTypeAttribute, 'number' | 'text'>;
|
|
32
|
+
/**
|
|
33
|
+
* Specifies if user agent has any permission to provide automated assistance in filling out form field values.
|
|
34
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
|
|
35
|
+
*
|
|
36
|
+
* @default off
|
|
37
|
+
*/
|
|
38
|
+
autoComplete?: HTMLInputAutoCompleteAttribute;
|
|
39
|
+
};
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
* A text input that allows users to enter text, numbers or symbols in a singular line. This is the base element and is
|
|
@@ -63,6 +64,7 @@ function TextInput({
|
|
|
63
64
|
disabled,
|
|
64
65
|
autoComplete = 'off',
|
|
65
66
|
containerRef,
|
|
67
|
+
errorMessage,
|
|
66
68
|
...otherProps
|
|
67
69
|
}: ElementProps<TextInputProps, 'div'>) {
|
|
68
70
|
const id = useId(idProp);
|
|
@@ -82,6 +84,7 @@ function TextInput({
|
|
|
82
84
|
>
|
|
83
85
|
{leading && <span data-leading>{leading}</span>}
|
|
84
86
|
<input
|
|
87
|
+
aria-errormessage={errorMessage || undefined}
|
|
85
88
|
aria-invalid={invalid || undefined}
|
|
86
89
|
aria-label={ariaLabel}
|
|
87
90
|
autoComplete={autoComplete}
|