@scalewing/react 1.70.0 → 1.71.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/CHANGELOG.md +6 -0
- package/README.md +28 -0
- package/dist/components/PinField.d.ts +48 -0
- package/dist/components/PinField.js +63 -0
- package/dist/components/pin-field/PinPad.d.ts +15 -0
- package/dist/components/pin-field/PinPad.js +20 -0
- package/dist/css/css-components.js +3 -0
- package/dist/css/css-pin-field.d.ts +6 -0
- package/dist/css/css-pin-field.js +240 -0
- package/dist/css/stylesheet.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/pin-entry.d.ts +26 -0
- package/dist/pin-entry.js +46 -0
- package/dist/pin-field-labels.d.ts +17 -0
- package/dist/pin-field-labels.js +13 -0
- package/dist/styles.css +189 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @scalewing/react
|
|
2
2
|
|
|
3
|
+
## 1.71.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 399d27e: `PinField`: a code of a fixed number of digits (`length`, 6 by default) that is never shown. One dot per digit over one real input (`type="text"`, `inputmode="numeric"`, never a password field, kept out of autofill), named by `label`, with `Field`'s `description` and `error`. The consumer holds the digits (`value`, `onChange`); the input's own value is a mask, so no digit is in the page's text, attributes or accessible names. Typing and pasting keep digits only, Backspace removes the last, and `onComplete` is called once at the last digit. The count ("3 of 6 digits entered", `labels.count`) describes the input and is announced politely after each entry. `pad` adds twelve on-screen keys (1 to 9, 0 and Delete), each a button of at least 64 px that keeps the focus when pressed. Also `disabled`, `autoFocus`, `labelVisuallyHidden`, `id`, `aria-describedby` and a ref to the input. New exports `PinField`, `PinFieldProps`, `PinFieldLabels`, `defaultPinFieldLabels`; new `sw-pin-field*` classes. No new tokens, no new dependency. Request: `docs/requests/teisoro-pin-field.md`.
|
|
8
|
+
|
|
3
9
|
## 1.70.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -63,6 +63,7 @@ import {
|
|
|
63
63
|
DateField,
|
|
64
64
|
Field,
|
|
65
65
|
FileField,
|
|
66
|
+
PinField,
|
|
66
67
|
Article,
|
|
67
68
|
Stepper,
|
|
68
69
|
Steps,
|
|
@@ -288,6 +289,33 @@ A chosen photo can show itself: `value.preview` is the address of a small image
|
|
|
288
289
|
/>
|
|
289
290
|
```
|
|
290
291
|
|
|
292
|
+
`PinField` is a code of a fixed number of digits (`length`, 6 by default, 1 to 12) that is never shown: a short PIN or a door code. It draws one dot per digit, filled for the digits entered, over one real input: a native `<input type="text" inputmode="numeric">` named by `label` (above it, or hidden with `labelVisuallyHidden` where a heading says it). It is never a password field, so the browser does not offer to save the code over the account's password, and it is kept out of autofill (`autocomplete="off"`, no `name`, the password managers' ignore hints). You hold the digits: `value` is a string of 0 to 9, `onChange` receives the new one after a key, a paste or a pad press. Typed and pasted text keeps its ASCII digits and drops the rest; digits are added after those already entered and cut to `length`; Backspace removes the last. `onComplete(value)` is called once, after `onChange`, by the entry that fills the last dot (not for a `value` you set, and not again while the field stays full).
|
|
293
|
+
|
|
294
|
+
The digits are never in the page. The input's own value is a mask, one `•` per digit, and nothing the field renders depends on which digits were entered, only on how many: not its text, not an attribute (the input's `value` included), not an accessible name. So read the code from the `value` you hold, never from the input or a form submission, and do not render, log or store it yourself. The input is described by the count ("3 of 6 digits entered") and the same words are announced politely after each entry; `labels.count` is your template, with `{count}` and `{length}`. A screen reader that reads a text field's value also reads the mask ("bullet bullet bullet") beside the count, never a digit. A desktop screen reader set to echo typed keys still says the keys it hears from the keyboard, as in any text field that is not a password field.
|
|
295
|
+
|
|
296
|
+
`pad` adds on-screen keys under the dots: 1 to 9, an empty place, 0 and Delete, in a group named `labels.pad` ("Number pad"). Each key is a real button and Tab stop of at least 64 px with a visible edge; a press enters or deletes as typing does and leaves the focus on the key. Delete is named `labels.delete` ("Delete the last digit") and is `aria-disabled` while there is nothing to delete. With the pad the field is a centred column at most 320 px wide (centred in a wider parent too), the dots stand without a frame, and the hint and error sit under the keys, so the keys never move. The input keeps `inputmode="numeric"`, so on a touch screen focusing it also opens the system's number keyboard; leave `autoFocus` off there if only the pad should show.
|
|
297
|
+
|
|
298
|
+
`description` and `error` are `Field`'s (the error a polite live region in place of the hint, `aria-invalid`, the frame's edge in the danger color); `disabled` turns the input and every key off; `autoFocus` focuses the input on mount; the ref and `id` are the input's, and `aria-describedby` adds your own descriptions before the field's. A blank `label`, a `length` outside 1 to 12, a `value` that is not digits or is longer than `length`, or a blank word in `labels` throws a `RangeError`.
|
|
299
|
+
|
|
300
|
+
```tsx
|
|
301
|
+
<PinField
|
|
302
|
+
label="New code"
|
|
303
|
+
description="Six digits."
|
|
304
|
+
value={code}
|
|
305
|
+
onChange={setCode}
|
|
306
|
+
/>
|
|
307
|
+
|
|
308
|
+
<PinField
|
|
309
|
+
label="Enter your code"
|
|
310
|
+
labelVisuallyHidden
|
|
311
|
+
pad
|
|
312
|
+
value={code}
|
|
313
|
+
onChange={setCode}
|
|
314
|
+
onComplete={check}
|
|
315
|
+
error={refused ? 'That code is not right. Try again.' : undefined}
|
|
316
|
+
/>
|
|
317
|
+
```
|
|
318
|
+
|
|
291
319
|
`Stepper` is a whole-number count changed with − and + or typed. The count is a native text input with `role="spinbutton"` and `inputmode="numeric"`, named by `label` (visible above it, or `labelVisuallyHidden` where table headers say it) and the one tab stop: ArrowUp and ArrowDown step it by `step` (default 1), Home goes to `min` and End to a finite `max` (a range below zero takes `inputmode="text"`, since a phone's numeric pad has no minus key). The − and + buttons are pointer targets outside the tab order, named by `decrementLabel` and `incrementLabel` (your copy), and a press on one leaves focus where it was; the count and both buttons sit in a `group` named by the label. − is disabled at `min` (default 0) and + at `max` (no upper bound when left out). `value` is a count or `null` for an empty box, which the buttons treat as `min` and `placeholder` can fill. Typed text is refused unless it is digits (with a leading minus when `min` is below zero), so `onChange` only receives a whole number or `null`; a typed count is reported as typed even outside the bounds, so say why in `error` (a polite message, `aria-invalid` and the danger border, as `Field`'s), and the buttons then move it back inside them. `aria-describedby` takes ids of elements that describe the count, such as the value it adds up to, read before an `error`'s message. `changed` takes `Field`'s changed look; `readOnly` keeps the count focusable and hides the buttons in their own room; `disabled` stops all three. `limitAppearance="plain"` (default `"faded"`) keeps − at `min` and + at `max` in their usual look instead of faded, for a count sheet where a faded − reads as broken; they are still disabled, a disabled or read-only Stepper is unchanged, forced colors still grey them, and an unknown value throws a `RangeError`. The count is a few digits wide and keeps that width (`width="fixed"`), or fills its container (`width="full"`, for a table cell). `unit` (opt-in) is a short muted word after the count inside its frame, such as "min" or "players": the frame (`sw-stepper-count`) draws the control surface, focus ring and the invalid, changed and disabled states, a press on the word focuses the count, and the count keeps its few-digit width with its digits against the word, so the frame never follows it. The word (`sw-stepper-unit`) is hidden from assistive technology; the count is read with it (`aria-valuetext` "90 min", none while the box is empty), and a `valueText` you pass wins. The default joins the count and the word as given, so a word that changes with the count ("players") reads "1 players": pass `valueText` in your language's right form ("1 player", "11 players"). A blank `unit` throws a `RangeError`. Bounds that are not whole numbers, `min` above `max`, or a `step` that is not above zero throw a `RangeError`.
|
|
292
320
|
|
|
293
321
|
`Stepper` `onCommit` (opt-in) is the finished count once per entry, for a page that saves as you go: it fires on blur, on Enter (a form round the count still submits), and `commitDelay` ms (default 600) after the last − / + press or step key (ArrowUp, ArrowDown, Home, End), each press restarting the wait; blur or Enter while it waits commits at once. Typed digits never commit by themselves. It gives the count you hold at that moment, `null` or outside the bounds included as `onChange` reports them, so check it before saving. It does not fire when that count is the one last committed, or, before the first commit, the one held before the first edit; a count you set while nothing waits (a server's answer) becomes the new baseline. A commit still waiting when the Stepper unmounts is made then. `onChange` is unchanged. A `commitDelay` that is negative or not finite throws a `RangeError`.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type PinFieldLabels } from '../pin-field-labels.js';
|
|
2
|
+
export { defaultPinFieldLabels, type PinFieldLabels, } from '../pin-field-labels.js';
|
|
3
|
+
export type PinFieldProps = {
|
|
4
|
+
/** The field's label, drawn above it as Field's, and the input's name. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Keeps the label as the name only, where a heading already says it. */
|
|
7
|
+
labelVisuallyHidden?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The digits entered so far, held by the consumer: only 0 to 9, at most
|
|
10
|
+
* `length` of them. They are never written to the page.
|
|
11
|
+
*/
|
|
12
|
+
value: string;
|
|
13
|
+
/** Called with the digits after a key, a paste or a pad press changed them. */
|
|
14
|
+
onChange: (value: string) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Called once, after `onChange`, by the entry that brings the count to
|
|
17
|
+
* `length`. Not called for a `value` the consumer sets.
|
|
18
|
+
*/
|
|
19
|
+
onComplete?: (value: string) => void;
|
|
20
|
+
/** How many digits the code has, 1 to 12. Default 6. */
|
|
21
|
+
length?: number;
|
|
22
|
+
/** A muted hint under the field. */
|
|
23
|
+
description?: string;
|
|
24
|
+
/** Replaces the hint with an error, in a polite live region. */
|
|
25
|
+
error?: string;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/** Focuses the input when the field mounts. */
|
|
28
|
+
autoFocus?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Draws on-screen keys under the dots: 1 to 9, 0 and Delete, each a
|
|
31
|
+
* button of at least 64 px. Default false: typed only.
|
|
32
|
+
*/
|
|
33
|
+
pad?: boolean;
|
|
34
|
+
/** The field's own words, over English defaults. */
|
|
35
|
+
labels?: Partial<PinFieldLabels>;
|
|
36
|
+
/** The input's id; the ids of the field's parts start with it. */
|
|
37
|
+
id?: string;
|
|
38
|
+
/** Ids of elements that describe the field, read before its own words. */
|
|
39
|
+
'aria-describedby'?: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A code of a fixed number of digits that is never shown: dots for the
|
|
43
|
+
* digits entered, typed in one real input or pressed on an optional pad.
|
|
44
|
+
* The input holds a mask character per digit, never the digits, which live
|
|
45
|
+
* only in the consumer's `value`; the count is read with the field and
|
|
46
|
+
* announced politely after each entry.
|
|
47
|
+
*/
|
|
48
|
+
export declare const PinField: import("react").ForwardRefExoticComponent<PinFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useId, useState } from 'react';
|
|
4
|
+
import { cx } from '../class-names.js';
|
|
5
|
+
import { assertPinLength, assertPinValue, defaultPinLength, pinCountText, pinMask, readPinEntry, } from '../pin-entry.js';
|
|
6
|
+
import { resolvePinFieldLabels, } from '../pin-field-labels.js';
|
|
7
|
+
import { FieldErrorRegion } from './FieldErrorRegion.js';
|
|
8
|
+
import { FieldLabelText } from './FieldLabelText.js';
|
|
9
|
+
import { LiveRegion } from './LiveRegion.js';
|
|
10
|
+
import { PinPad } from './pin-field/PinPad.js';
|
|
11
|
+
import { Stack } from './Stack.js';
|
|
12
|
+
export { defaultPinFieldLabels, } from '../pin-field-labels.js';
|
|
13
|
+
/**
|
|
14
|
+
* A code of a fixed number of digits that is never shown: dots for the
|
|
15
|
+
* digits entered, typed in one real input or pressed on an optional pad.
|
|
16
|
+
* The input holds a mask character per digit, never the digits, which live
|
|
17
|
+
* only in the consumer's `value`; the count is read with the field and
|
|
18
|
+
* announced politely after each entry.
|
|
19
|
+
*/
|
|
20
|
+
export const PinField = forwardRef(function PinField({ label, labelVisuallyHidden = false, value, onChange, onComplete, length = defaultPinLength, description, error, disabled = false, autoFocus = false, pad = false, labels, id, 'aria-describedby': describedBy, }, ref) {
|
|
21
|
+
if (label.trim() === '')
|
|
22
|
+
throw new RangeError('PinField needs a label');
|
|
23
|
+
assertPinLength(length);
|
|
24
|
+
assertPinValue(value, length);
|
|
25
|
+
const words = resolvePinFieldLabels(labels);
|
|
26
|
+
const ownId = useId();
|
|
27
|
+
const inputId = id ?? ownId;
|
|
28
|
+
const ids = {
|
|
29
|
+
count: `${inputId}-count`,
|
|
30
|
+
hint: `${inputId}-hint`,
|
|
31
|
+
error: `${inputId}-error`,
|
|
32
|
+
};
|
|
33
|
+
// Nothing is announced until the person has entered something.
|
|
34
|
+
const [entered, setEntered] = useState(false);
|
|
35
|
+
const count = value.length;
|
|
36
|
+
const countText = pinCountText(words.count, count, length);
|
|
37
|
+
function enter(next) {
|
|
38
|
+
if (next === value)
|
|
39
|
+
return;
|
|
40
|
+
setEntered(true);
|
|
41
|
+
onChange(next);
|
|
42
|
+
if (next.length === length && count < length)
|
|
43
|
+
onComplete?.(next);
|
|
44
|
+
}
|
|
45
|
+
// No digit stays in the input: after an edit that changes nothing here
|
|
46
|
+
// (a refused key, a full field, a consumer that keeps its value), React
|
|
47
|
+
// restores the controlled value, the mask, over what the browser typed.
|
|
48
|
+
function onEdit(event) {
|
|
49
|
+
enter(readPinEntry(event.currentTarget.value, value, length));
|
|
50
|
+
}
|
|
51
|
+
const invalid = Boolean(error);
|
|
52
|
+
const messages = (_jsxs(_Fragment, { children: [description && !invalid ? (_jsx("span", { className: "sw-field-description", id: ids.hint, children: description })) : null, _jsx(FieldErrorRegion, { className: "sw-field-error", id: ids.error, message: error })] }));
|
|
53
|
+
return (_jsxs(Stack, { className: cx('sw-field', 'sw-pin-field', pad && 'sw-pin-field-with-pad', invalid && 'sw-field-invalid'), gap: labelVisuallyHidden ? 0 : 1, children: [_jsx("label", { className: labelVisuallyHidden ? 'sw-sr-only' : undefined, htmlFor: inputId, children: _jsx(FieldLabelText, { label: label }) }), _jsxs("div", { className: "sw-pin-field-entry", children: [_jsx("input", { ref: ref, "aria-describedby": [
|
|
54
|
+
describedBy?.trim() || null,
|
|
55
|
+
ids.count,
|
|
56
|
+
description && !invalid ? ids.hint : null,
|
|
57
|
+
invalid ? ids.error : null,
|
|
58
|
+
]
|
|
59
|
+
.filter((part) => part !== null)
|
|
60
|
+
.join(' '), "aria-invalid": invalid || undefined, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", autoFocus: autoFocus, className: "sw-pin-field-input", "data-1p-ignore": "", "data-bwignore": "", "data-form-type": "other", "data-lpignore": "true", disabled: disabled, id: inputId, inputMode: "numeric", onChange: onEdit, spellCheck: false, type: "text",
|
|
61
|
+
// Never the digits: one mask character for each one entered.
|
|
62
|
+
value: pinMask(count) }), _jsx("span", { "aria-hidden": "true", className: "sw-pin-field-dots", children: Array.from({ length }, (_, index) => (_jsx("span", { className: cx('sw-pin-field-dot', index < count && 'sw-pin-field-dot-filled') }, index))) })] }), _jsx("span", { hidden: true, id: ids.count, children: countText }), _jsx(LiveRegion, { visuallyHidden: true, children: entered ? countText : '' }), pad ? (_jsx(PinPad, { canDelete: count > 0, deleteLabel: words.delete, disabled: disabled, label: words.pad, onDelete: () => enter(value.slice(0, -1)), onDigit: (digit) => enter((value + digit).slice(0, length)) })) : null, messages] }));
|
|
63
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A PinField's on-screen keys: twelve positions in three columns, 1 to 9,
|
|
3
|
+
* an empty one, 0 and Delete. Each key is a native button and its own Tab
|
|
4
|
+
* stop; a press reports the key and moves no focus. Delete with nothing to
|
|
5
|
+
* delete is `aria-disabled`, never `disabled`, so the focus it holds after
|
|
6
|
+
* the last digit goes is not dropped.
|
|
7
|
+
*/
|
|
8
|
+
export declare function PinPad({ canDelete, deleteLabel, disabled, label, onDelete, onDigit, }: {
|
|
9
|
+
canDelete: boolean;
|
|
10
|
+
deleteLabel: string;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
label: string;
|
|
13
|
+
onDelete: () => void;
|
|
14
|
+
onDigit: (digit: string) => void;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { tabStop } from '../../tab-stop.js';
|
|
3
|
+
const digitKeys = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
4
|
+
/** Private control chrome: the Delete key's backspace mark. */
|
|
5
|
+
function DeleteGlyph() {
|
|
6
|
+
return (_jsx("svg", { "aria-hidden": "true", className: "sw-pin-field-glyph", focusable: "false", viewBox: "0 0 24 24", children: _jsx("path", { d: "M21 5H9l-6 7 6 7h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1zM17 9l-5 6M12 9l5 6" }) }));
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A PinField's on-screen keys: twelve positions in three columns, 1 to 9,
|
|
10
|
+
* an empty one, 0 and Delete. Each key is a native button and its own Tab
|
|
11
|
+
* stop; a press reports the key and moves no focus. Delete with nothing to
|
|
12
|
+
* delete is `aria-disabled`, never `disabled`, so the focus it holds after
|
|
13
|
+
* the last digit goes is not dropped.
|
|
14
|
+
*/
|
|
15
|
+
export function PinPad({ canDelete, deleteLabel, disabled, label, onDelete, onDigit, }) {
|
|
16
|
+
function digitKey(digit) {
|
|
17
|
+
return (_jsx("button", { className: "sw-pin-field-key", disabled: disabled, onClick: () => onDigit(digit), tabIndex: tabStop, type: "button", children: digit }, digit));
|
|
18
|
+
}
|
|
19
|
+
return (_jsxs("div", { "aria-label": label, className: "sw-pin-field-pad", role: "group", children: [digitKeys.map(digitKey), _jsx("span", { "aria-hidden": "true" }), digitKey('0'), _jsx("button", { "aria-disabled": !disabled && !canDelete ? true : undefined, "aria-label": deleteLabel, className: "sw-pin-field-key sw-pin-field-key-delete", disabled: disabled, onClick: onDelete, tabIndex: tabStop, type: "button", children: _jsx(DeleteGlyph, {}) })] }));
|
|
20
|
+
}
|
|
@@ -9,6 +9,7 @@ import { cssButtonLinkClasses } from './css-button-link.js';
|
|
|
9
9
|
import { cssCalendarButtonClasses } from './css-calendar-button.js';
|
|
10
10
|
import { cssDateRangeClasses } from './css-date-range.js';
|
|
11
11
|
import { cssFileFieldClasses } from './css-file-field.js';
|
|
12
|
+
import { cssPinFieldClasses } from './css-pin-field.js';
|
|
12
13
|
import { cssArticleClasses } from './css-article.js';
|
|
13
14
|
import { cssDocumentViewerClasses } from './css-document-viewer.js';
|
|
14
15
|
import { cssFixtureClasses } from './css-fixture.js';
|
|
@@ -291,6 +292,8 @@ ${cssFieldClasses()}
|
|
|
291
292
|
|
|
292
293
|
${cssStepperClasses()}
|
|
293
294
|
|
|
295
|
+
${cssPinFieldClasses()}
|
|
296
|
+
|
|
294
297
|
${cssStepsClasses()}
|
|
295
298
|
|
|
296
299
|
${cssTaskListClasses()}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The web PinField: a label over a frame of dots with an unseen input, and
|
|
3
|
+
* with `sw-pin-field-with-pad` a centred column of dots over twelve keys.
|
|
4
|
+
*/
|
|
5
|
+
export declare function cssPinFieldClasses(): string;
|
|
6
|
+
export declare function pinFieldClassCatalog(): string[];
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { typographyVariants } from '@scalewing/tokens';
|
|
2
|
+
import { controlSurface, disabledControlForcedColors, disabledControlSurface, } from './css-document.js';
|
|
3
|
+
const heading = typographyVariants.heading;
|
|
4
|
+
/** A pad key's least size both ways: two space-6, 64 px. */
|
|
5
|
+
const keySize = 'calc(2 * var(--sw-space-6))';
|
|
6
|
+
/*
|
|
7
|
+
* The entry is the field's frame: it draws the canvas control surface, the
|
|
8
|
+
* dots and, while its input has the focus, the accent ring. The input fills
|
|
9
|
+
* it at opacity 0, so the mask characters it holds and its caret are never
|
|
10
|
+
* painted (in forced colours either, where a transparent text colour would
|
|
11
|
+
* be drawn), yet it takes every press and the focus. Its type stays the
|
|
12
|
+
* canvas's body size, so iOS does not zoom when it is focused.
|
|
13
|
+
* `input.sw-pin-field-input` matches the canvas's typed-input rule's
|
|
14
|
+
* specificity and comes later in the sheet.
|
|
15
|
+
*/
|
|
16
|
+
function entryRules() {
|
|
17
|
+
return `.sw-pin-field {
|
|
18
|
+
min-width: 0;
|
|
19
|
+
/* Holds its hidden label, count and empty error region, which leave the flow. */
|
|
20
|
+
position: relative;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.sw-pin-field-entry {
|
|
24
|
+
${controlSurface}
|
|
25
|
+
align-items: center;
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
cursor: text;
|
|
28
|
+
display: flex;
|
|
29
|
+
min-height: var(--sw-control-md-min-height);
|
|
30
|
+
position: relative;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[data-theme] input.sw-pin-field-input {
|
|
34
|
+
border: 0;
|
|
35
|
+
cursor: inherit;
|
|
36
|
+
height: 100%;
|
|
37
|
+
inset: 0;
|
|
38
|
+
margin: 0;
|
|
39
|
+
min-height: 0;
|
|
40
|
+
opacity: 0;
|
|
41
|
+
padding: 0;
|
|
42
|
+
position: absolute;
|
|
43
|
+
width: 100%;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* The canvas sets a disabled text control's opacity back to 1: not this one's. */
|
|
47
|
+
[data-theme] input.sw-pin-field-input:disabled { opacity: 0; }
|
|
48
|
+
|
|
49
|
+
.sw-pin-field-entry:focus-within {
|
|
50
|
+
outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
|
|
51
|
+
outline-offset: var(--sw-focus-ring-offset);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.sw-field-invalid .sw-pin-field-entry { border-color: var(--sw-color-danger); }
|
|
55
|
+
|
|
56
|
+
/* The frame draws the surface, so it carries the disabled look for its input. */
|
|
57
|
+
.sw-pin-field-entry:has(> input:disabled) {
|
|
58
|
+
${disabledControlSurface}
|
|
59
|
+
}`;
|
|
60
|
+
}
|
|
61
|
+
/*
|
|
62
|
+
* One dot per digit of the code: a ring in the muted colour (3:1 or more on
|
|
63
|
+
* the surface and on the subtle fill in every palette), filled in the text
|
|
64
|
+
* colour for a digit entered. A border draws the ring, so forced colours
|
|
65
|
+
* keep it.
|
|
66
|
+
*/
|
|
67
|
+
function dotRules() {
|
|
68
|
+
return `.sw-pin-field-dots {
|
|
69
|
+
display: flex;
|
|
70
|
+
gap: var(--sw-space-3);
|
|
71
|
+
pointer-events: none;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.sw-pin-field-dot {
|
|
75
|
+
border: 2px solid var(--sw-color-muted);
|
|
76
|
+
border-radius: var(--sw-radius-pill);
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
flex: none;
|
|
79
|
+
height: var(--sw-space-4);
|
|
80
|
+
width: var(--sw-space-4);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.sw-pin-field-dot-filled {
|
|
84
|
+
background: var(--sw-color-text);
|
|
85
|
+
border-color: var(--sw-color-text);
|
|
86
|
+
}`;
|
|
87
|
+
}
|
|
88
|
+
/*
|
|
89
|
+
* With its pad the field is one centred column, ten space-6 wide at most:
|
|
90
|
+
* the dots stand without a frame (the ring still shows where the focus is),
|
|
91
|
+
* and the keys are three equal columns. A key is at least 64 px both ways,
|
|
92
|
+
* on the subtle fill inside an edge in the muted colour (3:1 or more
|
|
93
|
+
* against the fill and the surface), its digit at the heading size. Delete
|
|
94
|
+
* has the same edge on no fill. The hover fill is for a pointer that
|
|
95
|
+
* hovers, so it never sticks after a touch.
|
|
96
|
+
*/
|
|
97
|
+
function padRules() {
|
|
98
|
+
return `.sw-pin-field-with-pad {
|
|
99
|
+
/* Centred in a column wider than it, whatever the column's alignment. */
|
|
100
|
+
margin-inline: auto;
|
|
101
|
+
max-inline-size: calc(10 * var(--sw-space-6));
|
|
102
|
+
text-align: center;
|
|
103
|
+
width: 100%;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.sw-pin-field-with-pad .sw-pin-field-entry,
|
|
107
|
+
.sw-pin-field-with-pad .sw-pin-field-entry:has(> input:disabled) {
|
|
108
|
+
background-color: transparent;
|
|
109
|
+
border-width: 0;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.sw-pin-field-with-pad .sw-pin-field-entry:has(> input:disabled) .sw-pin-field-dots {
|
|
114
|
+
opacity: var(--sw-disabled-opacity);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.sw-pin-field-pad {
|
|
118
|
+
display: grid;
|
|
119
|
+
gap: var(--sw-space-2);
|
|
120
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
121
|
+
margin-block-start: var(--sw-space-3);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* The hint or the error under the keys stands a little apart from them. */
|
|
125
|
+
.sw-pin-field-pad ~ :is(.sw-field-description, .sw-field-error:not(:empty)) {
|
|
126
|
+
margin-block-start: var(--sw-space-2);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.sw-pin-field-key {
|
|
130
|
+
align-items: center;
|
|
131
|
+
appearance: none;
|
|
132
|
+
background: var(--sw-color-subtle);
|
|
133
|
+
border: 1px solid var(--sw-color-muted);
|
|
134
|
+
border-radius: var(--sw-radius-md);
|
|
135
|
+
box-sizing: border-box;
|
|
136
|
+
color: var(--sw-color-text);
|
|
137
|
+
cursor: pointer;
|
|
138
|
+
display: inline-flex;
|
|
139
|
+
font-family: var(--sw-font-sans);
|
|
140
|
+
font-size: ${heading.fontSize}px;
|
|
141
|
+
font-variant-numeric: tabular-nums;
|
|
142
|
+
font-weight: 400;
|
|
143
|
+
justify-content: center;
|
|
144
|
+
line-height: ${heading.lineHeight}px;
|
|
145
|
+
margin: 0;
|
|
146
|
+
min-block-size: ${keySize};
|
|
147
|
+
min-inline-size: ${keySize};
|
|
148
|
+
padding: 0;
|
|
149
|
+
touch-action: manipulation;
|
|
150
|
+
user-select: none;
|
|
151
|
+
-webkit-tap-highlight-color: transparent;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.sw-pin-field-key-delete { background: transparent; }
|
|
155
|
+
|
|
156
|
+
@media (hover: hover) {
|
|
157
|
+
.sw-pin-field-key:hover:not(:disabled, [aria-disabled='true']) {
|
|
158
|
+
background: var(--sw-color-border);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.sw-pin-field-key:active:not(:disabled, [aria-disabled='true']) {
|
|
163
|
+
background: var(--sw-color-border);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.sw-pin-field-key:focus { outline: none; }
|
|
167
|
+
|
|
168
|
+
.sw-pin-field-key:focus-visible {
|
|
169
|
+
outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
|
|
170
|
+
outline-offset: var(--sw-focus-ring-offset);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.sw-pin-field-key:is(:disabled, [aria-disabled='true']) {
|
|
174
|
+
cursor: not-allowed;
|
|
175
|
+
opacity: var(--sw-disabled-opacity);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.sw-pin-field-glyph {
|
|
179
|
+
fill: none;
|
|
180
|
+
flex: none;
|
|
181
|
+
height: var(--sw-space-5);
|
|
182
|
+
stroke: currentColor;
|
|
183
|
+
stroke-linecap: round;
|
|
184
|
+
stroke-linejoin: round;
|
|
185
|
+
/* The stroke of the system's other private glyphs and of consumer icons (ADR 0008). */
|
|
186
|
+
stroke-width: 1.75;
|
|
187
|
+
width: var(--sw-space-5);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* The mark points the way a deletion goes. */
|
|
191
|
+
[dir='rtl'] .sw-pin-field-glyph { transform: scaleX(-1); }`;
|
|
192
|
+
}
|
|
193
|
+
/* Forced colours: system edges and fills; a disabled part in GrayText, unfaded. */
|
|
194
|
+
function forcedColorRules() {
|
|
195
|
+
return `@media (forced-colors: active) {
|
|
196
|
+
.sw-field-invalid .sw-pin-field-entry { border-color: Mark; }
|
|
197
|
+
.sw-pin-field-entry:has(> input:disabled) {
|
|
198
|
+
${disabledControlForcedColors}
|
|
199
|
+
}
|
|
200
|
+
.sw-pin-field-dot { border-color: CanvasText; }
|
|
201
|
+
.sw-pin-field-dot-filled { background: CanvasText; }
|
|
202
|
+
.sw-pin-field-entry:has(> input:disabled) .sw-pin-field-dot { border-color: GrayText; }
|
|
203
|
+
.sw-pin-field-entry:has(> input:disabled) .sw-pin-field-dot-filled { background: GrayText; }
|
|
204
|
+
.sw-pin-field-with-pad .sw-pin-field-entry:has(> input:disabled) .sw-pin-field-dots { opacity: 1; }
|
|
205
|
+
.sw-pin-field-key { border-color: ButtonText; }
|
|
206
|
+
.sw-pin-field-key:is(:disabled, [aria-disabled='true']) {
|
|
207
|
+
border-color: GrayText;
|
|
208
|
+
color: GrayText;
|
|
209
|
+
opacity: 1;
|
|
210
|
+
}
|
|
211
|
+
}`;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* The web PinField: a label over a frame of dots with an unseen input, and
|
|
215
|
+
* with `sw-pin-field-with-pad` a centred column of dots over twelve keys.
|
|
216
|
+
*/
|
|
217
|
+
export function cssPinFieldClasses() {
|
|
218
|
+
return `${entryRules()}
|
|
219
|
+
|
|
220
|
+
${dotRules()}
|
|
221
|
+
|
|
222
|
+
${padRules()}
|
|
223
|
+
|
|
224
|
+
${forcedColorRules()}`;
|
|
225
|
+
}
|
|
226
|
+
export function pinFieldClassCatalog() {
|
|
227
|
+
return [
|
|
228
|
+
'sw-pin-field',
|
|
229
|
+
'sw-pin-field-with-pad',
|
|
230
|
+
'sw-pin-field-entry',
|
|
231
|
+
'sw-pin-field-input',
|
|
232
|
+
'sw-pin-field-dots',
|
|
233
|
+
'sw-pin-field-dot',
|
|
234
|
+
'sw-pin-field-dot-filled',
|
|
235
|
+
'sw-pin-field-pad',
|
|
236
|
+
'sw-pin-field-key',
|
|
237
|
+
'sw-pin-field-key-delete',
|
|
238
|
+
'sw-pin-field-glyph',
|
|
239
|
+
];
|
|
240
|
+
}
|
package/dist/css/stylesheet.js
CHANGED
|
@@ -10,6 +10,7 @@ import { dateFieldClassCatalog } from './css-date-field.js';
|
|
|
10
10
|
import { calendarButtonClassCatalog } from './css-calendar-button.js';
|
|
11
11
|
import { dateRangeClassCatalog } from './css-date-range.js';
|
|
12
12
|
import { fileFieldClassCatalog } from './css-file-field.js';
|
|
13
|
+
import { pinFieldClassCatalog } from './css-pin-field.js';
|
|
13
14
|
import { articleClassCatalog } from './css-article.js';
|
|
14
15
|
import { documentViewerClassCatalog } from './css-document-viewer.js';
|
|
15
16
|
import { fixtureClassCatalog } from './css-fixture.js';
|
|
@@ -170,6 +171,7 @@ export function utilityClassCatalog() {
|
|
|
170
171
|
...denominationGridClassCatalog(),
|
|
171
172
|
...fieldClassCatalog(),
|
|
172
173
|
...stepperClassCatalog(),
|
|
174
|
+
...pinFieldClassCatalog(),
|
|
173
175
|
...stepsClassCatalog(),
|
|
174
176
|
...taskListClassCatalog(),
|
|
175
177
|
...splitClassCatalog(),
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { CalendarButton, type CalendarButtonLabels, type CalendarButtonProps, ty
|
|
|
8
8
|
export { DateRangeButton, type DateRangeButtonLabels, type DateRangeButtonProps, type DateRangeButtonValue, type DateRangePreset, } from './components/DateRangeButton.js';
|
|
9
9
|
export { Article, articleTitleElements, type ArticleCover, type ArticleProps, type ArticleTitleElement, } from './components/Article.js';
|
|
10
10
|
export { FileField, type FileFieldProps, type FileFieldValue, } from './components/FileField.js';
|
|
11
|
+
export { defaultPinFieldLabels, PinField, type PinFieldLabels, type PinFieldProps, } from './components/PinField.js';
|
|
11
12
|
export { DocumentViewer, type DocumentViewerLabels, type DocumentViewerProps, } from './components/DocumentViewer.js';
|
|
12
13
|
export { ListGroup, type ListGroupProps } from './components/ListGroup.js';
|
|
13
14
|
export { inspectMarkdown, markdownOmissionKinds, MarkdownView, type MarkdownHeading, type MarkdownInspection, type MarkdownImage, type MarkdownImageResolver, type MarkdownOmission, type MarkdownOmissionCounts, type MarkdownOmissionKind, type MarkdownOptions, type MarkdownViewProps, } from './components/MarkdownView.js';
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { CalendarButton, } from './components/CalendarButton.js';
|
|
|
7
7
|
export { DateRangeButton, } from './components/DateRangeButton.js';
|
|
8
8
|
export { Article, articleTitleElements, } from './components/Article.js';
|
|
9
9
|
export { FileField, } from './components/FileField.js';
|
|
10
|
+
export { defaultPinFieldLabels, PinField, } from './components/PinField.js';
|
|
10
11
|
export { DocumentViewer, } from './components/DocumentViewer.js';
|
|
11
12
|
export { ListGroup } from './components/ListGroup.js';
|
|
12
13
|
export { inspectMarkdown, markdownOmissionKinds, MarkdownView, } from './components/MarkdownView.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The character a PinField's input holds in place of each digit entered.
|
|
3
|
+
* The input's DOM value is only ever a run of these, so the digits are
|
|
4
|
+
* never in the page: not in the input's `value`, nor in any attribute.
|
|
5
|
+
*/
|
|
6
|
+
export declare const pinMaskCharacter = "\u2022";
|
|
7
|
+
export declare const defaultPinLength = 6;
|
|
8
|
+
/** The most digits a PinField takes: its dots still fit a 390 px column. */
|
|
9
|
+
export declare const maxPinLength = 12;
|
|
10
|
+
/** Fails closed on a length that is not a whole number from 1 to the cap. */
|
|
11
|
+
export declare function assertPinLength(length: number): void;
|
|
12
|
+
/** Fails closed on a value that is not ASCII digits or is past `length`. */
|
|
13
|
+
export declare function assertPinValue(value: string, length: number): void;
|
|
14
|
+
/** What the input holds for `count` digits entered: one mask character each. */
|
|
15
|
+
export declare function pinMask(count: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* The digits after an edit of the input. `edited` is the input's text once
|
|
18
|
+
* the browser applied a key, a paste or a deletion to the mask: the mask
|
|
19
|
+
* characters left say how many of the earlier digits survive (always the
|
|
20
|
+
* first ones: the entry adds and removes at its end), and the ASCII digits
|
|
21
|
+
* in it are the new ones, in order. Anything else is dropped, and the result
|
|
22
|
+
* is cut to `length`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function readPinEntry(edited: string, value: string, length: number): string;
|
|
25
|
+
/** The count's words: `{count}` and `{length}` replaced in the template. */
|
|
26
|
+
export declare function pinCountText(template: string, count: number, length: number): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The character a PinField's input holds in place of each digit entered.
|
|
3
|
+
* The input's DOM value is only ever a run of these, so the digits are
|
|
4
|
+
* never in the page: not in the input's `value`, nor in any attribute.
|
|
5
|
+
*/
|
|
6
|
+
export const pinMaskCharacter = '•';
|
|
7
|
+
export const defaultPinLength = 6;
|
|
8
|
+
/** The most digits a PinField takes: its dots still fit a 390 px column. */
|
|
9
|
+
export const maxPinLength = 12;
|
|
10
|
+
/** Fails closed on a length that is not a whole number from 1 to the cap. */
|
|
11
|
+
export function assertPinLength(length) {
|
|
12
|
+
if (!Number.isInteger(length) || length < 1 || length > maxPinLength)
|
|
13
|
+
throw new RangeError(`PinField length must be a whole number from 1 to ${maxPinLength}`);
|
|
14
|
+
}
|
|
15
|
+
/** Fails closed on a value that is not ASCII digits or is past `length`. */
|
|
16
|
+
export function assertPinValue(value, length) {
|
|
17
|
+
if (typeof value !== 'string' || /[^0-9]/.test(value))
|
|
18
|
+
throw new RangeError('PinField value must hold only the digits 0 to 9');
|
|
19
|
+
if (value.length > length)
|
|
20
|
+
throw new RangeError('PinField value is longer than its length');
|
|
21
|
+
}
|
|
22
|
+
/** What the input holds for `count` digits entered: one mask character each. */
|
|
23
|
+
export function pinMask(count) {
|
|
24
|
+
return pinMaskCharacter.repeat(count);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The digits after an edit of the input. `edited` is the input's text once
|
|
28
|
+
* the browser applied a key, a paste or a deletion to the mask: the mask
|
|
29
|
+
* characters left say how many of the earlier digits survive (always the
|
|
30
|
+
* first ones: the entry adds and removes at its end), and the ASCII digits
|
|
31
|
+
* in it are the new ones, in order. Anything else is dropped, and the result
|
|
32
|
+
* is cut to `length`.
|
|
33
|
+
*/
|
|
34
|
+
export function readPinEntry(edited, value, length) {
|
|
35
|
+
// A typed or pasted mask character only counts toward the earlier digits
|
|
36
|
+
// that survive (capped at how many there were); it is never a new digit.
|
|
37
|
+
const kept = Math.min(edited.split(pinMaskCharacter).length - 1, value.length);
|
|
38
|
+
const typed = edited.replace(/[^0-9]/g, '');
|
|
39
|
+
return (value.slice(0, kept) + typed).slice(0, length);
|
|
40
|
+
}
|
|
41
|
+
/** The count's words: `{count}` and `{length}` replaced in the template. */
|
|
42
|
+
export function pinCountText(template, count, length) {
|
|
43
|
+
return template
|
|
44
|
+
.replaceAll('{count}', String(count))
|
|
45
|
+
.replaceAll('{length}', String(length));
|
|
46
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Words the PinField speaks on its own. Products pass their translations.
|
|
3
|
+
*/
|
|
4
|
+
export type PinFieldLabels = {
|
|
5
|
+
/**
|
|
6
|
+
* How many digits are entered, read with the field and announced after
|
|
7
|
+
* each entry: `{count}` and `{length}` are replaced by the numbers.
|
|
8
|
+
*/
|
|
9
|
+
count: string;
|
|
10
|
+
/** The pad's Delete key's name. */
|
|
11
|
+
delete: string;
|
|
12
|
+
/** The pad's name: its keys are a group. */
|
|
13
|
+
pad: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const defaultPinFieldLabels: PinFieldLabels;
|
|
16
|
+
/** Consumer labels over the English defaults; empty strings fail closed. */
|
|
17
|
+
export declare function resolvePinFieldLabels(labels?: Partial<PinFieldLabels>): PinFieldLabels;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const defaultPinFieldLabels = {
|
|
2
|
+
count: '{count} of {length} digits entered',
|
|
3
|
+
delete: 'Delete the last digit',
|
|
4
|
+
pad: 'Number pad',
|
|
5
|
+
};
|
|
6
|
+
/** Consumer labels over the English defaults; empty strings fail closed. */
|
|
7
|
+
export function resolvePinFieldLabels(labels = {}) {
|
|
8
|
+
const resolved = { ...defaultPinFieldLabels, ...labels };
|
|
9
|
+
for (const [key, text] of Object.entries(resolved))
|
|
10
|
+
if (typeof text !== 'string' || text.trim() === '')
|
|
11
|
+
throw new RangeError(`labels.${key} must be non-empty text`);
|
|
12
|
+
return resolved;
|
|
13
|
+
}
|
package/dist/styles.css
CHANGED
|
@@ -11056,6 +11056,195 @@ html:has(.sw-site-header-sticky) .sw-docs-layout {
|
|
|
11056
11056
|
}
|
|
11057
11057
|
}
|
|
11058
11058
|
|
|
11059
|
+
.sw-pin-field {
|
|
11060
|
+
min-width: 0;
|
|
11061
|
+
/* Holds its hidden label, count and empty error region, which leave the flow. */
|
|
11062
|
+
position: relative;
|
|
11063
|
+
}
|
|
11064
|
+
|
|
11065
|
+
.sw-pin-field-entry {
|
|
11066
|
+
background-color: var(--sw-glass-fill);
|
|
11067
|
+
border: 1px solid var(--sw-color-border);
|
|
11068
|
+
border-radius: var(--sw-radius-sm);
|
|
11069
|
+
color: inherit;
|
|
11070
|
+
font-family: inherit;
|
|
11071
|
+
font-size: inherit;
|
|
11072
|
+
padding-inline: var(--sw-control-md-padding-inline);
|
|
11073
|
+
align-items: center;
|
|
11074
|
+
box-sizing: border-box;
|
|
11075
|
+
cursor: text;
|
|
11076
|
+
display: flex;
|
|
11077
|
+
min-height: var(--sw-control-md-min-height);
|
|
11078
|
+
position: relative;
|
|
11079
|
+
}
|
|
11080
|
+
|
|
11081
|
+
[data-theme] input.sw-pin-field-input {
|
|
11082
|
+
border: 0;
|
|
11083
|
+
cursor: inherit;
|
|
11084
|
+
height: 100%;
|
|
11085
|
+
inset: 0;
|
|
11086
|
+
margin: 0;
|
|
11087
|
+
min-height: 0;
|
|
11088
|
+
opacity: 0;
|
|
11089
|
+
padding: 0;
|
|
11090
|
+
position: absolute;
|
|
11091
|
+
width: 100%;
|
|
11092
|
+
}
|
|
11093
|
+
|
|
11094
|
+
/* The canvas sets a disabled text control's opacity back to 1: not this one's. */
|
|
11095
|
+
[data-theme] input.sw-pin-field-input:disabled { opacity: 0; }
|
|
11096
|
+
|
|
11097
|
+
.sw-pin-field-entry:focus-within {
|
|
11098
|
+
outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
|
|
11099
|
+
outline-offset: var(--sw-focus-ring-offset);
|
|
11100
|
+
}
|
|
11101
|
+
|
|
11102
|
+
.sw-field-invalid .sw-pin-field-entry { border-color: var(--sw-color-danger); }
|
|
11103
|
+
|
|
11104
|
+
/* The frame draws the surface, so it carries the disabled look for its input. */
|
|
11105
|
+
.sw-pin-field-entry:has(> input:disabled) {
|
|
11106
|
+
background-color: var(--sw-color-subtle);
|
|
11107
|
+
border-style: dashed;
|
|
11108
|
+
cursor: not-allowed;
|
|
11109
|
+
opacity: 1;
|
|
11110
|
+
-webkit-text-fill-color: currentColor;
|
|
11111
|
+
}
|
|
11112
|
+
|
|
11113
|
+
.sw-pin-field-dots {
|
|
11114
|
+
display: flex;
|
|
11115
|
+
gap: var(--sw-space-3);
|
|
11116
|
+
pointer-events: none;
|
|
11117
|
+
}
|
|
11118
|
+
|
|
11119
|
+
.sw-pin-field-dot {
|
|
11120
|
+
border: 2px solid var(--sw-color-muted);
|
|
11121
|
+
border-radius: var(--sw-radius-pill);
|
|
11122
|
+
box-sizing: border-box;
|
|
11123
|
+
flex: none;
|
|
11124
|
+
height: var(--sw-space-4);
|
|
11125
|
+
width: var(--sw-space-4);
|
|
11126
|
+
}
|
|
11127
|
+
|
|
11128
|
+
.sw-pin-field-dot-filled {
|
|
11129
|
+
background: var(--sw-color-text);
|
|
11130
|
+
border-color: var(--sw-color-text);
|
|
11131
|
+
}
|
|
11132
|
+
|
|
11133
|
+
.sw-pin-field-with-pad {
|
|
11134
|
+
/* Centred in a column wider than it, whatever the column's alignment. */
|
|
11135
|
+
margin-inline: auto;
|
|
11136
|
+
max-inline-size: calc(10 * var(--sw-space-6));
|
|
11137
|
+
text-align: center;
|
|
11138
|
+
width: 100%;
|
|
11139
|
+
}
|
|
11140
|
+
|
|
11141
|
+
.sw-pin-field-with-pad .sw-pin-field-entry,
|
|
11142
|
+
.sw-pin-field-with-pad .sw-pin-field-entry:has(> input:disabled) {
|
|
11143
|
+
background-color: transparent;
|
|
11144
|
+
border-width: 0;
|
|
11145
|
+
justify-content: center;
|
|
11146
|
+
}
|
|
11147
|
+
|
|
11148
|
+
.sw-pin-field-with-pad .sw-pin-field-entry:has(> input:disabled) .sw-pin-field-dots {
|
|
11149
|
+
opacity: var(--sw-disabled-opacity);
|
|
11150
|
+
}
|
|
11151
|
+
|
|
11152
|
+
.sw-pin-field-pad {
|
|
11153
|
+
display: grid;
|
|
11154
|
+
gap: var(--sw-space-2);
|
|
11155
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
11156
|
+
margin-block-start: var(--sw-space-3);
|
|
11157
|
+
}
|
|
11158
|
+
|
|
11159
|
+
/* The hint or the error under the keys stands a little apart from them. */
|
|
11160
|
+
.sw-pin-field-pad ~ :is(.sw-field-description, .sw-field-error:not(:empty)) {
|
|
11161
|
+
margin-block-start: var(--sw-space-2);
|
|
11162
|
+
}
|
|
11163
|
+
|
|
11164
|
+
.sw-pin-field-key {
|
|
11165
|
+
align-items: center;
|
|
11166
|
+
appearance: none;
|
|
11167
|
+
background: var(--sw-color-subtle);
|
|
11168
|
+
border: 1px solid var(--sw-color-muted);
|
|
11169
|
+
border-radius: var(--sw-radius-md);
|
|
11170
|
+
box-sizing: border-box;
|
|
11171
|
+
color: var(--sw-color-text);
|
|
11172
|
+
cursor: pointer;
|
|
11173
|
+
display: inline-flex;
|
|
11174
|
+
font-family: var(--sw-font-sans);
|
|
11175
|
+
font-size: 28px;
|
|
11176
|
+
font-variant-numeric: tabular-nums;
|
|
11177
|
+
font-weight: 400;
|
|
11178
|
+
justify-content: center;
|
|
11179
|
+
line-height: 34px;
|
|
11180
|
+
margin: 0;
|
|
11181
|
+
min-block-size: calc(2 * var(--sw-space-6));
|
|
11182
|
+
min-inline-size: calc(2 * var(--sw-space-6));
|
|
11183
|
+
padding: 0;
|
|
11184
|
+
touch-action: manipulation;
|
|
11185
|
+
user-select: none;
|
|
11186
|
+
-webkit-tap-highlight-color: transparent;
|
|
11187
|
+
}
|
|
11188
|
+
|
|
11189
|
+
.sw-pin-field-key-delete { background: transparent; }
|
|
11190
|
+
|
|
11191
|
+
@media (hover: hover) {
|
|
11192
|
+
.sw-pin-field-key:hover:not(:disabled, [aria-disabled='true']) {
|
|
11193
|
+
background: var(--sw-color-border);
|
|
11194
|
+
}
|
|
11195
|
+
}
|
|
11196
|
+
|
|
11197
|
+
.sw-pin-field-key:active:not(:disabled, [aria-disabled='true']) {
|
|
11198
|
+
background: var(--sw-color-border);
|
|
11199
|
+
}
|
|
11200
|
+
|
|
11201
|
+
.sw-pin-field-key:focus { outline: none; }
|
|
11202
|
+
|
|
11203
|
+
.sw-pin-field-key:focus-visible {
|
|
11204
|
+
outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
|
|
11205
|
+
outline-offset: var(--sw-focus-ring-offset);
|
|
11206
|
+
}
|
|
11207
|
+
|
|
11208
|
+
.sw-pin-field-key:is(:disabled, [aria-disabled='true']) {
|
|
11209
|
+
cursor: not-allowed;
|
|
11210
|
+
opacity: var(--sw-disabled-opacity);
|
|
11211
|
+
}
|
|
11212
|
+
|
|
11213
|
+
.sw-pin-field-glyph {
|
|
11214
|
+
fill: none;
|
|
11215
|
+
flex: none;
|
|
11216
|
+
height: var(--sw-space-5);
|
|
11217
|
+
stroke: currentColor;
|
|
11218
|
+
stroke-linecap: round;
|
|
11219
|
+
stroke-linejoin: round;
|
|
11220
|
+
/* The stroke of the system's other private glyphs and of consumer icons (ADR 0008). */
|
|
11221
|
+
stroke-width: 1.75;
|
|
11222
|
+
width: var(--sw-space-5);
|
|
11223
|
+
}
|
|
11224
|
+
|
|
11225
|
+
/* The mark points the way a deletion goes. */
|
|
11226
|
+
[dir='rtl'] .sw-pin-field-glyph { transform: scaleX(-1); }
|
|
11227
|
+
|
|
11228
|
+
@media (forced-colors: active) {
|
|
11229
|
+
.sw-field-invalid .sw-pin-field-entry { border-color: Mark; }
|
|
11230
|
+
.sw-pin-field-entry:has(> input:disabled) {
|
|
11231
|
+
border-color: GrayText;
|
|
11232
|
+
color: GrayText;
|
|
11233
|
+
-webkit-text-fill-color: GrayText;
|
|
11234
|
+
}
|
|
11235
|
+
.sw-pin-field-dot { border-color: CanvasText; }
|
|
11236
|
+
.sw-pin-field-dot-filled { background: CanvasText; }
|
|
11237
|
+
.sw-pin-field-entry:has(> input:disabled) .sw-pin-field-dot { border-color: GrayText; }
|
|
11238
|
+
.sw-pin-field-entry:has(> input:disabled) .sw-pin-field-dot-filled { background: GrayText; }
|
|
11239
|
+
.sw-pin-field-with-pad .sw-pin-field-entry:has(> input:disabled) .sw-pin-field-dots { opacity: 1; }
|
|
11240
|
+
.sw-pin-field-key { border-color: ButtonText; }
|
|
11241
|
+
.sw-pin-field-key:is(:disabled, [aria-disabled='true']) {
|
|
11242
|
+
border-color: GrayText;
|
|
11243
|
+
color: GrayText;
|
|
11244
|
+
opacity: 1;
|
|
11245
|
+
}
|
|
11246
|
+
}
|
|
11247
|
+
|
|
11059
11248
|
.sw-steps {
|
|
11060
11249
|
display: flex;
|
|
11061
11250
|
flex-direction: column;
|