@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.
Files changed (81) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +147 -3
  3. package/dist/components/ActionBar.d.ts +14 -0
  4. package/dist/components/ActionBar.js +5 -2
  5. package/dist/components/DenominationGrid.d.ts +5 -2
  6. package/dist/components/DenominationGrid.js +11 -3
  7. package/dist/components/Dialog.d.ts +28 -4
  8. package/dist/components/Dialog.js +20 -2
  9. package/dist/components/Notice.d.ts +69 -0
  10. package/dist/components/Notice.js +48 -0
  11. package/dist/components/Progress.d.ts +3 -1
  12. package/dist/components/Progress.js +4 -0
  13. package/dist/components/Stepper.d.ts +44 -0
  14. package/dist/components/Stepper.js +77 -0
  15. package/dist/components/Steps.d.ts +18 -0
  16. package/dist/components/Steps.js +34 -0
  17. package/dist/components/Toast.d.ts +20 -4
  18. package/dist/components/Toast.js +44 -21
  19. package/dist/components/action-bar/ActionBarSummary.d.ts +22 -0
  20. package/dist/components/action-bar/ActionBarSummary.js +23 -0
  21. package/dist/components/denomination-grid/ColumnHeadText.d.ts +7 -0
  22. package/dist/components/denomination-grid/ColumnHeadText.js +13 -0
  23. package/dist/components/denomination-grid/DenominationStrip.d.ts +5 -2
  24. package/dist/components/denomination-grid/DenominationStrip.js +4 -8
  25. package/dist/components/denomination-grid/DenominationTiles.d.ts +5 -2
  26. package/dist/components/denomination-grid/DenominationTiles.js +4 -3
  27. package/dist/components/denomination-grid/EntryCell.d.ts +15 -0
  28. package/dist/components/denomination-grid/EntryCell.js +16 -0
  29. package/dist/components/denomination-grid/RowLabelLine.d.ts +3 -2
  30. package/dist/components/denomination-grid/RowLabelLine.js +5 -3
  31. package/dist/components/denomination-grid/StripRow.d.ts +13 -0
  32. package/dist/components/denomination-grid/StripRow.js +19 -0
  33. package/dist/components/denomination-grid/types.d.ts +53 -1
  34. package/dist/components/denomination-grid/validate-entry.d.ts +15 -0
  35. package/dist/components/denomination-grid/validate-entry.js +78 -0
  36. package/dist/components/dialog/DialogFooter.d.ts +14 -0
  37. package/dist/components/dialog/DialogFooter.js +11 -0
  38. package/dist/components/dialog/DialogTitle.d.ts +11 -4
  39. package/dist/components/dialog/DialogTitle.js +8 -6
  40. package/dist/components/steps/Step.d.ts +24 -0
  41. package/dist/components/steps/Step.js +62 -0
  42. package/dist/components/steps/step-status.d.ts +26 -0
  43. package/dist/components/steps/step-status.js +37 -0
  44. package/dist/components/steps/steps-context.d.ts +16 -0
  45. package/dist/components/steps/steps-context.js +3 -0
  46. package/dist/components/toast/ToastContent.d.ts +22 -0
  47. package/dist/components/toast/ToastContent.js +21 -0
  48. package/dist/components/toast/use-toast-hold.d.ts +28 -0
  49. package/dist/components/toast/use-toast-hold.js +53 -0
  50. package/dist/components/toast/use-toast-timer.d.ts +15 -0
  51. package/dist/components/toast/use-toast-timer.js +34 -0
  52. package/dist/css/css-action-bar-summary.d.ts +2 -0
  53. package/dist/css/css-action-bar-summary.js +48 -0
  54. package/dist/css/css-action-bar.js +4 -0
  55. package/dist/css/css-components.js +16 -0
  56. package/dist/css/css-denomination-entry.d.ts +2 -0
  57. package/dist/css/css-denomination-entry.js +78 -0
  58. package/dist/css/css-denomination-grid.js +8 -0
  59. package/dist/css/css-denomination-label.d.ts +10 -0
  60. package/dist/css/css-denomination-label.js +36 -0
  61. package/dist/css/css-dialog-frame.d.ts +2 -0
  62. package/dist/css/css-dialog-frame.js +83 -0
  63. package/dist/css/css-dialog.js +20 -4
  64. package/dist/css/css-notice.d.ts +22 -0
  65. package/dist/css/css-notice.js +168 -0
  66. package/dist/css/css-progress.d.ts +3 -0
  67. package/dist/css/css-progress.js +13 -6
  68. package/dist/css/css-stepper.d.ts +10 -0
  69. package/dist/css/css-stepper.js +126 -0
  70. package/dist/css/css-steps.d.ts +9 -0
  71. package/dist/css/css-steps.js +203 -0
  72. package/dist/css/css-toast-card.d.ts +5 -0
  73. package/dist/css/css-toast-card.js +122 -0
  74. package/dist/css/css-variables.js +1 -0
  75. package/dist/css/stylesheet.js +10 -0
  76. package/dist/index.d.ts +9 -6
  77. package/dist/index.js +8 -5
  78. package/dist/stepper-count.d.ts +37 -0
  79. package/dist/stepper-count.js +50 -0
  80. package/dist/styles.css +623 -1
  81. 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
+ }