@allxsmith/bestax-bulma 5.42.1 → 5.43.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.
- package/dist/bestax.css +1 -1
- package/dist/bestax.css.map +1 -1
- package/dist/esm/components/Carousel.js.map +1 -1
- package/dist/esm/form/Field.js.map +1 -1
- package/dist/esm/form/PinInput.js +201 -0
- package/dist/esm/form/PinInput.js.map +1 -0
- package/dist/extras.css +1 -1
- package/dist/extras.css.map +1 -1
- package/dist/index.cjs +187 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +1 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/types/components/Carousel.d.ts +7 -0
- package/dist/types/form/Field.d.ts +1 -1
- package/dist/types/form/PinInput.d.ts +103 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types-cjs/components/Carousel.d.ts +7 -0
- package/dist/types-cjs/form/Field.d.ts +1 -1
- package/dist/types-cjs/form/PinInput.d.ts +103 -0
- package/dist/types-cjs/index.d.ts +1 -0
- package/dist/versions/bestax-no-dark-mode.css +1 -1
- package/dist/versions/bestax-no-dark-mode.css.map +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
- package/dist/versions/bestax-no-helpers.css +1 -1
- package/dist/versions/bestax-no-helpers.css.map +1 -1
- package/dist/versions/bestax-prefixed.css +1 -1
- package/dist/versions/bestax-prefixed.css.map +1 -1
- package/package.json +13 -13
- package/src/scss/components/_carousel.scss +7 -2
- package/src/scss/form/_index.scss +1 -0
- package/src/scss/form/_pininput.scss +175 -0
package/dist/index.esm.js
CHANGED
|
@@ -80,6 +80,7 @@ export { Radios } from './esm/form/Radios.js';
|
|
|
80
80
|
export { Switch, switchColors, switchSizes } from './esm/form/Switch.js';
|
|
81
81
|
export { Slider } from './esm/form/Slider.js';
|
|
82
82
|
export { NumberInput, Numberinput } from './esm/form/Numberinput.js';
|
|
83
|
+
export { PinInput } from './esm/form/PinInput.js';
|
|
83
84
|
export { Rate } from './esm/form/Rate.js';
|
|
84
85
|
export { Autocomplete } from './esm/form/Autocomplete.js';
|
|
85
86
|
export { Combobox, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxList, ComboboxMenu } from './esm/form/Combobox.js';
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -9,6 +9,13 @@ export interface CarouselItemProps extends React.HTMLAttributes<HTMLDivElement>
|
|
|
9
9
|
* so with several in view several are active.
|
|
10
10
|
*/
|
|
11
11
|
active?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The slide's content. An image in it is held to the slide's width at its
|
|
14
|
+
* own height, unless something sizes the image itself: a ratio `Image`
|
|
15
|
+
* fills its frame, and an `Avatar`'s photo its circle, as they do outside a
|
|
16
|
+
* carousel.
|
|
17
|
+
*/
|
|
18
|
+
children?: React.ReactNode;
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
21
|
* Individual carousel item/slide.
|
|
@@ -12,7 +12,7 @@ export interface FieldProps extends React.HTMLAttributes<HTMLDivElement>, Omit<B
|
|
|
12
12
|
hasAddons?: boolean | 'centered' | 'right';
|
|
13
13
|
/** Constrains the field to its content's width (used inside horizontal field bodies). */
|
|
14
14
|
narrow?: boolean;
|
|
15
|
-
/** Field label, rendered above the widget. Automatically names the one control the Field holds: a composed `InputBase`, `SelectBase`, `TextAreaBase`, `DateInputBase`, `TimeInputBase` or `DateTimeInputBase` (an `inline` picker has no input, so it takes nothing), or a bestax input that renders a single input of its own (`Input`, `Select`, `TextArea`, `Numberinput`, `Slider`, `DateInput`, `TimeInput`, `DateTimeInput`, `Autocomplete`, `Combobox`, `Taginput`, `File`), adopts a generated id that the label's `htmlFor` points at, and a group (`Radios`, `Checkboxes`, `Rate`, `DateRangeInput`, or a composed `DateRangeInputBase`, `inline` or not) points `aria-labelledby` at the label's own id unless you gave the group an `aria-label` or `aria-labelledby`. A range `Slider` takes the id on its low thumb and also starts each thumb's name with the label through `aria-labelledby`, unless its `ariaLabel` names that thumb or its own `aria-label` or `aria-labelledby` takes the label's place. An `Autocomplete`, a `Combobox` or a `Taginput` also names its open list after the label through `aria-labelledby`. `Checkbox`, `Radio` and `Switch` are named by their own children, and the label names one only when you wire it as you would any control with an `id` of its own, `labelProps={{ htmlFor }}` plus that control's `id`. Only the single inputs take the `htmlFor`, so once the Field's content has mounted the label keeps it only while one of them holds the id, and drops it over anything else: a group, a `Checkbox`, `Radio` or `Switch`, an `inline` picker, an inner `Field`, an input with an `id` of its own, markup of your own, or nothing at all. A server render, and the first render while hydrating, still write the `htmlFor`, which keeps hydration matching, and an input that mounts later puts it back. The label names an input with an `id` of your own only through `labelProps={{ htmlFor }}` set to that `id`, a `for` it always keeps; `labelProps={{ htmlFor: undefined }}` opts out. Skipped for `grouped`/`hasAddons` fields (multiple controls), and a nested `Field` starts its own scope, so a horizontal Field whose body holds an inner `Field` names the control there only when you wire it. Two controls in one plain labeled Field would both adopt the id, so give each an `id` of its own. */
|
|
15
|
+
/** Field label, rendered above the widget. Automatically names the one control the Field holds: a composed `InputBase`, `SelectBase`, `TextAreaBase`, `DateInputBase`, `TimeInputBase` or `DateTimeInputBase` (an `inline` picker has no input, so it takes nothing), or a bestax input that renders a single input of its own (`Input`, `Select`, `TextArea`, `Numberinput`, `PinInput`, `Slider`, `DateInput`, `TimeInput`, `DateTimeInput`, `Autocomplete`, `Combobox`, `Taginput`, `File`), adopts a generated id that the label's `htmlFor` points at, and a group (`Radios`, `Checkboxes`, `Rate`, `DateRangeInput`, or a composed `DateRangeInputBase`, `inline` or not) points `aria-labelledby` at the label's own id unless you gave the group an `aria-label` or `aria-labelledby`. A range `Slider` takes the id on its low thumb and also starts each thumb's name with the label through `aria-labelledby`, unless its `ariaLabel` names that thumb or its own `aria-label` or `aria-labelledby` takes the label's place. An `Autocomplete`, a `Combobox` or a `Taginput` also names its open list after the label through `aria-labelledby`. `Checkbox`, `Radio` and `Switch` are named by their own children, and the label names one only when you wire it as you would any control with an `id` of its own, `labelProps={{ htmlFor }}` plus that control's `id`. Only the single inputs take the `htmlFor`, so once the Field's content has mounted the label keeps it only while one of them holds the id, and drops it over anything else: a group, a `Checkbox`, `Radio` or `Switch`, an `inline` picker, an inner `Field`, an input with an `id` of its own, markup of your own, or nothing at all. A server render, and the first render while hydrating, still write the `htmlFor`, which keeps hydration matching, and an input that mounts later puts it back. The label names an input with an `id` of your own only through `labelProps={{ htmlFor }}` set to that `id`, a `for` it always keeps; `labelProps={{ htmlFor: undefined }}` opts out. Skipped for `grouped`/`hasAddons` fields (multiple controls), and a nested `Field` starts its own scope, so a horizontal Field whose body holds an inner `Field` names the control there only when you wire it. Two controls in one plain labeled Field would both adopt the id, so give each an `id` of its own. */
|
|
16
16
|
label?: React.ReactNode;
|
|
17
17
|
/** Size for the label. */
|
|
18
18
|
labelSize?: 'small' | 'normal' | 'medium' | 'large';
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
|
|
3
|
+
import { FormFieldProps } from './fieldProps.js';
|
|
4
|
+
/**
|
|
5
|
+
* What a PinInput takes: `'number'` keeps digits only, and `'alphanumeric'`
|
|
6
|
+
* keeps the letters A to Z, in either case, and digits. A digit from any
|
|
7
|
+
* script, such as an Arabic-Indic `٣` or a Persian `۳`, is kept as its ASCII
|
|
8
|
+
* digit, `3`.
|
|
9
|
+
*/
|
|
10
|
+
export type PinInputType = 'number' | 'alphanumeric';
|
|
11
|
+
/**
|
|
12
|
+
* Props for the PinInput component.
|
|
13
|
+
* Inside an existing `Control` it renders no `Control` of its own. Inside an
|
|
14
|
+
* outer `Field`, or a `Control` with no `Field` around it, it renders no
|
|
15
|
+
* `Field` of its own either. The exception is `label`, `message`, `horizontal`
|
|
16
|
+
* or `fieldClassName` in that bare `Control`: it keeps a `Field` for them,
|
|
17
|
+
* nested in the `.control`, and warns in development. Wrap the `Control` in a
|
|
18
|
+
* `Field` instead, and set the `label`, `horizontal` and class name on that
|
|
19
|
+
* `Field`.
|
|
20
|
+
* Every other prop goes to the `<input>` that holds the code, except
|
|
21
|
+
* `className` and the helper props, which go to the row of boxes.
|
|
22
|
+
* @extraProp {string} [name] - Form field name, on the input, so a form submits the code under it.
|
|
23
|
+
* @extraProp {string} [autoComplete="one-time-code"] - Lets the browser offer a code it received by text message, and tells a password manager this is a one-time code.
|
|
24
|
+
* @extraProp {string} [inputMode] - The keyboard a phone shows: `"numeric"` with `type="number"`, `"text"` with `type="alphanumeric"`.
|
|
25
|
+
* @extraProp {string} [pattern] - Exactly `length` of what `type` takes, `[0-9]{6}` by default, so a form with `required` won't submit a partial code. Any non-empty partial code fails it, `required` or not.
|
|
26
|
+
* @extraProp {string} [className] - Additional CSS classes for the row of boxes.
|
|
27
|
+
* @extraProp {React.Ref<HTMLInputElement>} [ref] - Ref forwarded to the input that holds the code.
|
|
28
|
+
*/
|
|
29
|
+
export interface PinInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'color' | 'size' | 'type' | 'value' | 'defaultValue' | 'onChange' | 'maxLength'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor' | 'size'>, FormFieldProps {
|
|
30
|
+
/** Field label. Automatically associated with the input that holds the code via `htmlFor`, so a screen reader announces one field under this name. Uses your `id` when provided, otherwise a generated one. Dropped inside an outer `Field`, whose own label associates instead when that `Field` generates a target id (not `grouped`/`hasAddons`, no explicit `labelProps.htmlFor`) and you set no `id` here. */
|
|
31
|
+
label?: React.ReactNode;
|
|
32
|
+
/** Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id is generated then). */
|
|
33
|
+
labelProps?: React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
/** Applied to the input that holds the code (the labellable control), not the row of boxes. */
|
|
37
|
+
id?: string;
|
|
38
|
+
/** How many characters the code has. Each gets a box, and it is the input's `maxLength`. */
|
|
39
|
+
length?: number;
|
|
40
|
+
/** The code (controlled). Only its first `length` characters are shown and submitted. */
|
|
41
|
+
value?: string;
|
|
42
|
+
/** The code to start with (uncontrolled). Only its first `length` characters are kept. */
|
|
43
|
+
defaultValue?: string;
|
|
44
|
+
/**
|
|
45
|
+
* What the code takes. A digit from any script, such as an Arabic-Indic or
|
|
46
|
+
* a Persian one, goes in as its ASCII digit, so the code reaches
|
|
47
|
+
* `onChange`, `onComplete` and the form as `0` to `9`. Anything else typed
|
|
48
|
+
* or pasted is dropped, and the caret stays where it was. The input stays a
|
|
49
|
+
* text field either way, so a code keeps its leading zeros.
|
|
50
|
+
*/
|
|
51
|
+
type?: PinInputType;
|
|
52
|
+
/**
|
|
53
|
+
* Shows a dot in each filled box in place of its character, and makes the
|
|
54
|
+
* input a password field, so a screen reader doesn't read the code out
|
|
55
|
+
* either.
|
|
56
|
+
*/
|
|
57
|
+
isMasked?: boolean;
|
|
58
|
+
/** Bulma color for the boxes, the colors an `Input` takes. */
|
|
59
|
+
color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger' | 'black' | 'dark' | 'light' | 'white';
|
|
60
|
+
/** Size of the boxes. */
|
|
61
|
+
size?: 'small' | 'medium' | 'large';
|
|
62
|
+
/** Round boxes. */
|
|
63
|
+
isRounded?: boolean;
|
|
64
|
+
/** Whether the input is disabled. */
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Called with the code each time it changes. A paste replaces the whole
|
|
68
|
+
* code with what was pasted, kept to what `type` takes and cut to `length`,
|
|
69
|
+
* and a paste with nothing the code takes changes nothing.
|
|
70
|
+
*/
|
|
71
|
+
onChange?: (value: string) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Called with the code when a change makes it `length` characters long,
|
|
74
|
+
* such as typing the last character, a paste or autofill. It fires once for
|
|
75
|
+
* each change that fills the last box with a new code, and never on a
|
|
76
|
+
* render. A `value` you set yourself doesn't call it.
|
|
77
|
+
*/
|
|
78
|
+
onComplete?: (value: string) => void;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The `PinInput` component is a field for a short code, such as a one-time
|
|
82
|
+
* code or a PIN, drawn as a row of boxes with one character in each.
|
|
83
|
+
*
|
|
84
|
+
* The code lives in one real `<input>` that lies over the boxes, so it is
|
|
85
|
+
* one field to a screen reader, and paste, autofill from a text message and
|
|
86
|
+
* password managers work on it as they do on any input. The boxes draw what
|
|
87
|
+
* it holds, and the box at the caret, or every box in a selection, shows
|
|
88
|
+
* Bulma's focus look.
|
|
89
|
+
*
|
|
90
|
+
* @function
|
|
91
|
+
* @param {PinInputProps} props - Props for the PinInput component.
|
|
92
|
+
* @returns {JSX.Element} The rendered code field.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* <PinInput
|
|
96
|
+
* label="Verification code"
|
|
97
|
+
* value={code}
|
|
98
|
+
* onChange={setCode}
|
|
99
|
+
* onComplete={verify}
|
|
100
|
+
* />
|
|
101
|
+
*/
|
|
102
|
+
export declare const PinInput: React.ForwardRefExoticComponent<PinInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
103
|
+
export default PinInput;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -79,6 +79,7 @@ export * from './form/Radios.js';
|
|
|
79
79
|
export * from './form/Switch.js';
|
|
80
80
|
export * from './form/Slider.js';
|
|
81
81
|
export * from './form/Numberinput.js';
|
|
82
|
+
export * from './form/PinInput.js';
|
|
82
83
|
export * from './form/Rate.js';
|
|
83
84
|
export * from './form/Autocomplete.js';
|
|
84
85
|
export * from './form/Combobox.js';
|
|
@@ -9,6 +9,13 @@ export interface CarouselItemProps extends React.HTMLAttributes<HTMLDivElement>
|
|
|
9
9
|
* so with several in view several are active.
|
|
10
10
|
*/
|
|
11
11
|
active?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The slide's content. An image in it is held to the slide's width at its
|
|
14
|
+
* own height, unless something sizes the image itself: a ratio `Image`
|
|
15
|
+
* fills its frame, and an `Avatar`'s photo its circle, as they do outside a
|
|
16
|
+
* carousel.
|
|
17
|
+
*/
|
|
18
|
+
children?: React.ReactNode;
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
21
|
* Individual carousel item/slide.
|
|
@@ -12,7 +12,7 @@ export interface FieldProps extends React.HTMLAttributes<HTMLDivElement>, Omit<B
|
|
|
12
12
|
hasAddons?: boolean | 'centered' | 'right';
|
|
13
13
|
/** Constrains the field to its content's width (used inside horizontal field bodies). */
|
|
14
14
|
narrow?: boolean;
|
|
15
|
-
/** Field label, rendered above the widget. Automatically names the one control the Field holds: a composed `InputBase`, `SelectBase`, `TextAreaBase`, `DateInputBase`, `TimeInputBase` or `DateTimeInputBase` (an `inline` picker has no input, so it takes nothing), or a bestax input that renders a single input of its own (`Input`, `Select`, `TextArea`, `Numberinput`, `Slider`, `DateInput`, `TimeInput`, `DateTimeInput`, `Autocomplete`, `Combobox`, `Taginput`, `File`), adopts a generated id that the label's `htmlFor` points at, and a group (`Radios`, `Checkboxes`, `Rate`, `DateRangeInput`, or a composed `DateRangeInputBase`, `inline` or not) points `aria-labelledby` at the label's own id unless you gave the group an `aria-label` or `aria-labelledby`. A range `Slider` takes the id on its low thumb and also starts each thumb's name with the label through `aria-labelledby`, unless its `ariaLabel` names that thumb or its own `aria-label` or `aria-labelledby` takes the label's place. An `Autocomplete`, a `Combobox` or a `Taginput` also names its open list after the label through `aria-labelledby`. `Checkbox`, `Radio` and `Switch` are named by their own children, and the label names one only when you wire it as you would any control with an `id` of its own, `labelProps={{ htmlFor }}` plus that control's `id`. Only the single inputs take the `htmlFor`, so once the Field's content has mounted the label keeps it only while one of them holds the id, and drops it over anything else: a group, a `Checkbox`, `Radio` or `Switch`, an `inline` picker, an inner `Field`, an input with an `id` of its own, markup of your own, or nothing at all. A server render, and the first render while hydrating, still write the `htmlFor`, which keeps hydration matching, and an input that mounts later puts it back. The label names an input with an `id` of your own only through `labelProps={{ htmlFor }}` set to that `id`, a `for` it always keeps; `labelProps={{ htmlFor: undefined }}` opts out. Skipped for `grouped`/`hasAddons` fields (multiple controls), and a nested `Field` starts its own scope, so a horizontal Field whose body holds an inner `Field` names the control there only when you wire it. Two controls in one plain labeled Field would both adopt the id, so give each an `id` of its own. */
|
|
15
|
+
/** Field label, rendered above the widget. Automatically names the one control the Field holds: a composed `InputBase`, `SelectBase`, `TextAreaBase`, `DateInputBase`, `TimeInputBase` or `DateTimeInputBase` (an `inline` picker has no input, so it takes nothing), or a bestax input that renders a single input of its own (`Input`, `Select`, `TextArea`, `Numberinput`, `PinInput`, `Slider`, `DateInput`, `TimeInput`, `DateTimeInput`, `Autocomplete`, `Combobox`, `Taginput`, `File`), adopts a generated id that the label's `htmlFor` points at, and a group (`Radios`, `Checkboxes`, `Rate`, `DateRangeInput`, or a composed `DateRangeInputBase`, `inline` or not) points `aria-labelledby` at the label's own id unless you gave the group an `aria-label` or `aria-labelledby`. A range `Slider` takes the id on its low thumb and also starts each thumb's name with the label through `aria-labelledby`, unless its `ariaLabel` names that thumb or its own `aria-label` or `aria-labelledby` takes the label's place. An `Autocomplete`, a `Combobox` or a `Taginput` also names its open list after the label through `aria-labelledby`. `Checkbox`, `Radio` and `Switch` are named by their own children, and the label names one only when you wire it as you would any control with an `id` of its own, `labelProps={{ htmlFor }}` plus that control's `id`. Only the single inputs take the `htmlFor`, so once the Field's content has mounted the label keeps it only while one of them holds the id, and drops it over anything else: a group, a `Checkbox`, `Radio` or `Switch`, an `inline` picker, an inner `Field`, an input with an `id` of its own, markup of your own, or nothing at all. A server render, and the first render while hydrating, still write the `htmlFor`, which keeps hydration matching, and an input that mounts later puts it back. The label names an input with an `id` of your own only through `labelProps={{ htmlFor }}` set to that `id`, a `for` it always keeps; `labelProps={{ htmlFor: undefined }}` opts out. Skipped for `grouped`/`hasAddons` fields (multiple controls), and a nested `Field` starts its own scope, so a horizontal Field whose body holds an inner `Field` names the control there only when you wire it. Two controls in one plain labeled Field would both adopt the id, so give each an `id` of its own. */
|
|
16
16
|
label?: React.ReactNode;
|
|
17
17
|
/** Size for the label. */
|
|
18
18
|
labelSize?: 'small' | 'normal' | 'medium' | 'large';
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
|
|
3
|
+
import { FormFieldProps } from './fieldProps.js';
|
|
4
|
+
/**
|
|
5
|
+
* What a PinInput takes: `'number'` keeps digits only, and `'alphanumeric'`
|
|
6
|
+
* keeps the letters A to Z, in either case, and digits. A digit from any
|
|
7
|
+
* script, such as an Arabic-Indic `٣` or a Persian `۳`, is kept as its ASCII
|
|
8
|
+
* digit, `3`.
|
|
9
|
+
*/
|
|
10
|
+
export type PinInputType = 'number' | 'alphanumeric';
|
|
11
|
+
/**
|
|
12
|
+
* Props for the PinInput component.
|
|
13
|
+
* Inside an existing `Control` it renders no `Control` of its own. Inside an
|
|
14
|
+
* outer `Field`, or a `Control` with no `Field` around it, it renders no
|
|
15
|
+
* `Field` of its own either. The exception is `label`, `message`, `horizontal`
|
|
16
|
+
* or `fieldClassName` in that bare `Control`: it keeps a `Field` for them,
|
|
17
|
+
* nested in the `.control`, and warns in development. Wrap the `Control` in a
|
|
18
|
+
* `Field` instead, and set the `label`, `horizontal` and class name on that
|
|
19
|
+
* `Field`.
|
|
20
|
+
* Every other prop goes to the `<input>` that holds the code, except
|
|
21
|
+
* `className` and the helper props, which go to the row of boxes.
|
|
22
|
+
* @extraProp {string} [name] - Form field name, on the input, so a form submits the code under it.
|
|
23
|
+
* @extraProp {string} [autoComplete="one-time-code"] - Lets the browser offer a code it received by text message, and tells a password manager this is a one-time code.
|
|
24
|
+
* @extraProp {string} [inputMode] - The keyboard a phone shows: `"numeric"` with `type="number"`, `"text"` with `type="alphanumeric"`.
|
|
25
|
+
* @extraProp {string} [pattern] - Exactly `length` of what `type` takes, `[0-9]{6}` by default, so a form with `required` won't submit a partial code. Any non-empty partial code fails it, `required` or not.
|
|
26
|
+
* @extraProp {string} [className] - Additional CSS classes for the row of boxes.
|
|
27
|
+
* @extraProp {React.Ref<HTMLInputElement>} [ref] - Ref forwarded to the input that holds the code.
|
|
28
|
+
*/
|
|
29
|
+
export interface PinInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'color' | 'size' | 'type' | 'value' | 'defaultValue' | 'onChange' | 'maxLength'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor' | 'size'>, FormFieldProps {
|
|
30
|
+
/** Field label. Automatically associated with the input that holds the code via `htmlFor`, so a screen reader announces one field under this name. Uses your `id` when provided, otherwise a generated one. Dropped inside an outer `Field`, whose own label associates instead when that `Field` generates a target id (not `grouped`/`hasAddons`, no explicit `labelProps.htmlFor`) and you set no `id` here. */
|
|
31
|
+
label?: React.ReactNode;
|
|
32
|
+
/** Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id is generated then). */
|
|
33
|
+
labelProps?: React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
/** Applied to the input that holds the code (the labellable control), not the row of boxes. */
|
|
37
|
+
id?: string;
|
|
38
|
+
/** How many characters the code has. Each gets a box, and it is the input's `maxLength`. */
|
|
39
|
+
length?: number;
|
|
40
|
+
/** The code (controlled). Only its first `length` characters are shown and submitted. */
|
|
41
|
+
value?: string;
|
|
42
|
+
/** The code to start with (uncontrolled). Only its first `length` characters are kept. */
|
|
43
|
+
defaultValue?: string;
|
|
44
|
+
/**
|
|
45
|
+
* What the code takes. A digit from any script, such as an Arabic-Indic or
|
|
46
|
+
* a Persian one, goes in as its ASCII digit, so the code reaches
|
|
47
|
+
* `onChange`, `onComplete` and the form as `0` to `9`. Anything else typed
|
|
48
|
+
* or pasted is dropped, and the caret stays where it was. The input stays a
|
|
49
|
+
* text field either way, so a code keeps its leading zeros.
|
|
50
|
+
*/
|
|
51
|
+
type?: PinInputType;
|
|
52
|
+
/**
|
|
53
|
+
* Shows a dot in each filled box in place of its character, and makes the
|
|
54
|
+
* input a password field, so a screen reader doesn't read the code out
|
|
55
|
+
* either.
|
|
56
|
+
*/
|
|
57
|
+
isMasked?: boolean;
|
|
58
|
+
/** Bulma color for the boxes, the colors an `Input` takes. */
|
|
59
|
+
color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger' | 'black' | 'dark' | 'light' | 'white';
|
|
60
|
+
/** Size of the boxes. */
|
|
61
|
+
size?: 'small' | 'medium' | 'large';
|
|
62
|
+
/** Round boxes. */
|
|
63
|
+
isRounded?: boolean;
|
|
64
|
+
/** Whether the input is disabled. */
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Called with the code each time it changes. A paste replaces the whole
|
|
68
|
+
* code with what was pasted, kept to what `type` takes and cut to `length`,
|
|
69
|
+
* and a paste with nothing the code takes changes nothing.
|
|
70
|
+
*/
|
|
71
|
+
onChange?: (value: string) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Called with the code when a change makes it `length` characters long,
|
|
74
|
+
* such as typing the last character, a paste or autofill. It fires once for
|
|
75
|
+
* each change that fills the last box with a new code, and never on a
|
|
76
|
+
* render. A `value` you set yourself doesn't call it.
|
|
77
|
+
*/
|
|
78
|
+
onComplete?: (value: string) => void;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The `PinInput` component is a field for a short code, such as a one-time
|
|
82
|
+
* code or a PIN, drawn as a row of boxes with one character in each.
|
|
83
|
+
*
|
|
84
|
+
* The code lives in one real `<input>` that lies over the boxes, so it is
|
|
85
|
+
* one field to a screen reader, and paste, autofill from a text message and
|
|
86
|
+
* password managers work on it as they do on any input. The boxes draw what
|
|
87
|
+
* it holds, and the box at the caret, or every box in a selection, shows
|
|
88
|
+
* Bulma's focus look.
|
|
89
|
+
*
|
|
90
|
+
* @function
|
|
91
|
+
* @param {PinInputProps} props - Props for the PinInput component.
|
|
92
|
+
* @returns {JSX.Element} The rendered code field.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* <PinInput
|
|
96
|
+
* label="Verification code"
|
|
97
|
+
* value={code}
|
|
98
|
+
* onChange={setCode}
|
|
99
|
+
* onComplete={verify}
|
|
100
|
+
* />
|
|
101
|
+
*/
|
|
102
|
+
export declare const PinInput: React.ForwardRefExoticComponent<PinInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
103
|
+
export default PinInput;
|
|
@@ -79,6 +79,7 @@ export * from './form/Radios.js';
|
|
|
79
79
|
export * from './form/Switch.js';
|
|
80
80
|
export * from './form/Slider.js';
|
|
81
81
|
export * from './form/Numberinput.js';
|
|
82
|
+
export * from './form/PinInput.js';
|
|
82
83
|
export * from './form/Rate.js';
|
|
83
84
|
export * from './form/Autocomplete.js';
|
|
84
85
|
export * from './form/Combobox.js';
|