@scalewing/react 1.26.0 → 1.28.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 +74 -0
- package/README.md +147 -3
- package/dist/components/ActionBar.d.ts +14 -0
- package/dist/components/ActionBar.js +5 -2
- package/dist/components/DenominationGrid.d.ts +5 -2
- package/dist/components/DenominationGrid.js +11 -3
- package/dist/components/Dialog.d.ts +28 -4
- package/dist/components/Dialog.js +20 -2
- package/dist/components/Notice.d.ts +69 -0
- package/dist/components/Notice.js +48 -0
- package/dist/components/Progress.d.ts +3 -1
- package/dist/components/Progress.js +4 -0
- package/dist/components/Stepper.d.ts +44 -0
- package/dist/components/Stepper.js +77 -0
- package/dist/components/Steps.d.ts +18 -0
- package/dist/components/Steps.js +34 -0
- package/dist/components/Toast.d.ts +20 -4
- package/dist/components/Toast.js +44 -21
- package/dist/components/action-bar/ActionBarSummary.d.ts +22 -0
- package/dist/components/action-bar/ActionBarSummary.js +23 -0
- package/dist/components/denomination-grid/ColumnHeadText.d.ts +7 -0
- package/dist/components/denomination-grid/ColumnHeadText.js +13 -0
- package/dist/components/denomination-grid/DenominationStrip.d.ts +5 -2
- package/dist/components/denomination-grid/DenominationStrip.js +4 -8
- package/dist/components/denomination-grid/DenominationTiles.d.ts +5 -2
- package/dist/components/denomination-grid/DenominationTiles.js +4 -3
- package/dist/components/denomination-grid/EntryCell.d.ts +15 -0
- package/dist/components/denomination-grid/EntryCell.js +16 -0
- package/dist/components/denomination-grid/RowLabelLine.d.ts +3 -2
- package/dist/components/denomination-grid/RowLabelLine.js +5 -3
- package/dist/components/denomination-grid/StripRow.d.ts +13 -0
- package/dist/components/denomination-grid/StripRow.js +19 -0
- package/dist/components/denomination-grid/types.d.ts +53 -1
- package/dist/components/denomination-grid/validate-entry.d.ts +15 -0
- package/dist/components/denomination-grid/validate-entry.js +78 -0
- package/dist/components/dialog/DialogFooter.d.ts +14 -0
- package/dist/components/dialog/DialogFooter.js +11 -0
- package/dist/components/dialog/DialogTitle.d.ts +11 -4
- package/dist/components/dialog/DialogTitle.js +8 -6
- package/dist/components/steps/Step.d.ts +24 -0
- package/dist/components/steps/Step.js +62 -0
- package/dist/components/steps/step-status.d.ts +26 -0
- package/dist/components/steps/step-status.js +37 -0
- package/dist/components/steps/steps-context.d.ts +16 -0
- package/dist/components/steps/steps-context.js +3 -0
- package/dist/components/toast/ToastContent.d.ts +22 -0
- package/dist/components/toast/ToastContent.js +21 -0
- package/dist/components/toast/use-toast-hold.d.ts +28 -0
- package/dist/components/toast/use-toast-hold.js +53 -0
- package/dist/components/toast/use-toast-timer.d.ts +15 -0
- package/dist/components/toast/use-toast-timer.js +34 -0
- package/dist/css/css-action-bar-summary.d.ts +2 -0
- package/dist/css/css-action-bar-summary.js +48 -0
- package/dist/css/css-action-bar.js +4 -0
- package/dist/css/css-components.js +16 -0
- package/dist/css/css-denomination-entry.d.ts +2 -0
- package/dist/css/css-denomination-entry.js +78 -0
- package/dist/css/css-denomination-grid.js +8 -0
- package/dist/css/css-denomination-label.d.ts +10 -0
- package/dist/css/css-denomination-label.js +36 -0
- package/dist/css/css-dialog-frame.d.ts +2 -0
- package/dist/css/css-dialog-frame.js +83 -0
- package/dist/css/css-dialog.js +20 -4
- package/dist/css/css-notice.d.ts +22 -0
- package/dist/css/css-notice.js +168 -0
- package/dist/css/css-progress.d.ts +3 -0
- package/dist/css/css-progress.js +13 -6
- package/dist/css/css-stepper.d.ts +10 -0
- package/dist/css/css-stepper.js +126 -0
- package/dist/css/css-steps.d.ts +9 -0
- package/dist/css/css-steps.js +203 -0
- package/dist/css/css-toast-card.d.ts +5 -0
- package/dist/css/css-toast-card.js +122 -0
- package/dist/css/css-variables.js +1 -0
- package/dist/css/stylesheet.js +10 -0
- package/dist/index.d.ts +9 -6
- package/dist/index.js +8 -5
- package/dist/stepper-count.d.ts +37 -0
- package/dist/stepper-count.js +50 -0
- package/dist/styles.css +623 -1
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** A web `Stepper`'s bounds: whole numbers, `min <= max`, `step > 0`. */
|
|
2
|
+
export type StepperBounds = {
|
|
3
|
+
min: number;
|
|
4
|
+
max: number;
|
|
5
|
+
step: number;
|
|
6
|
+
};
|
|
7
|
+
/** Where one press of − and of + lands, or null where that button is stopped. */
|
|
8
|
+
export type StepperMoves = {
|
|
9
|
+
down: number | null;
|
|
10
|
+
up: number | null;
|
|
11
|
+
};
|
|
12
|
+
/** A typed text: no count (empty), a whole count, or text the box refuses. */
|
|
13
|
+
export type StepperEntry = {
|
|
14
|
+
kind: 'empty';
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'count';
|
|
17
|
+
value: number;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'refused';
|
|
20
|
+
};
|
|
21
|
+
/** A consumer bug, not a runtime state: the bounds must describe a range. */
|
|
22
|
+
export declare function assertStepperBounds(bounds: StepperBounds): void;
|
|
23
|
+
/**
|
|
24
|
+
* The counts − and + would move to. An empty box counts as `min`. A count
|
|
25
|
+
* outside the bounds (typed) moves back inside them; a bound stops its own
|
|
26
|
+
* direction, and a locked (disabled or read-only) stepper stops both.
|
|
27
|
+
*/
|
|
28
|
+
export declare function stepperMoves(value: number | null, bounds: StepperBounds, locked: boolean): StepperMoves;
|
|
29
|
+
/**
|
|
30
|
+
* Reads what the person typed. Digits make a count, with a leading minus
|
|
31
|
+
* only when the range goes below zero; an empty box, or a lone minus on its
|
|
32
|
+
* way to a negative count, is no count. Anything else, or a count too large
|
|
33
|
+
* to be exact, is refused and the box keeps its last text.
|
|
34
|
+
*/
|
|
35
|
+
export declare function readStepperEntry(text: string, allowsNegative: boolean): StepperEntry;
|
|
36
|
+
/** The box's text for a count: the plain number, or empty for none. */
|
|
37
|
+
export declare function stepperText(value: number | null): string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** A consumer bug, not a runtime state: the bounds must describe a range. */
|
|
2
|
+
export function assertStepperBounds(bounds) {
|
|
3
|
+
const { min, max, step } = bounds;
|
|
4
|
+
if (!Number.isSafeInteger(min) || !Number.isSafeInteger(step))
|
|
5
|
+
throw new RangeError('Stepper min and step must be whole numbers');
|
|
6
|
+
if (max !== Number.POSITIVE_INFINITY && !Number.isSafeInteger(max))
|
|
7
|
+
throw new RangeError('Stepper max must be a whole number');
|
|
8
|
+
if (min > max)
|
|
9
|
+
throw new RangeError(`Stepper min ${min} is greater than max ${max}`);
|
|
10
|
+
if (step <= 0)
|
|
11
|
+
throw new RangeError(`Stepper step ${step} must be greater than zero`);
|
|
12
|
+
}
|
|
13
|
+
function clamp(value, bounds) {
|
|
14
|
+
return Math.min(Math.max(value, bounds.min), bounds.max);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The counts − and + would move to. An empty box counts as `min`. A count
|
|
18
|
+
* outside the bounds (typed) moves back inside them; a bound stops its own
|
|
19
|
+
* direction, and a locked (disabled or read-only) stepper stops both.
|
|
20
|
+
*/
|
|
21
|
+
export function stepperMoves(value, bounds, locked) {
|
|
22
|
+
if (locked)
|
|
23
|
+
return { down: null, up: null };
|
|
24
|
+
const base = value ?? bounds.min;
|
|
25
|
+
return {
|
|
26
|
+
down: base > bounds.min ? clamp(base - bounds.step, bounds) : null,
|
|
27
|
+
up: base < bounds.max ? clamp(base + bounds.step, bounds) : null,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Reads what the person typed. Digits make a count, with a leading minus
|
|
32
|
+
* only when the range goes below zero; an empty box, or a lone minus on its
|
|
33
|
+
* way to a negative count, is no count. Anything else, or a count too large
|
|
34
|
+
* to be exact, is refused and the box keeps its last text.
|
|
35
|
+
*/
|
|
36
|
+
export function readStepperEntry(text, allowsNegative) {
|
|
37
|
+
if (text === '' || (allowsNegative && text === '-'))
|
|
38
|
+
return { kind: 'empty' };
|
|
39
|
+
const pattern = allowsNegative ? /^-?\d+$/ : /^\d+$/;
|
|
40
|
+
if (!pattern.test(text))
|
|
41
|
+
return { kind: 'refused' };
|
|
42
|
+
const value = Number(text);
|
|
43
|
+
if (!Number.isSafeInteger(value))
|
|
44
|
+
return { kind: 'refused' };
|
|
45
|
+
return { kind: 'count', value: Object.is(value, -0) ? 0 : value };
|
|
46
|
+
}
|
|
47
|
+
/** The box's text for a count: the plain number, or empty for none. */
|
|
48
|
+
export function stepperText(value) {
|
|
49
|
+
return value === null ? '' : String(value);
|
|
50
|
+
}
|