@sharadox/graphical-user-interface-web-library 0.2.0-fields.8 → 0.2.0-interface-refinement.34
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/README.md +45 -7
- package/distribution/accordion/index.d.ts +11 -0
- package/distribution/accordion/index.d.ts.map +1 -0
- package/distribution/accordion/index.js +36 -0
- package/distribution/accordion/index.js.map +1 -0
- package/distribution/accordion/index.module.css +1 -0
- package/distribution/accordion/index.module.scss +56 -0
- package/distribution/accordion/type.d.ts +21 -0
- package/distribution/accordion/type.d.ts.map +1 -0
- package/distribution/accordion/type.js +2 -0
- package/distribution/accordion/type.js.map +1 -0
- package/distribution/avatar/index.d.ts +20 -0
- package/distribution/avatar/index.d.ts.map +1 -0
- package/distribution/avatar/index.js +35 -0
- package/distribution/avatar/index.js.map +1 -0
- package/distribution/avatar/index.module.css +1 -0
- package/distribution/avatar/index.module.scss +16 -0
- package/distribution/avatar/type.d.ts +9 -0
- package/distribution/avatar/type.d.ts.map +1 -0
- package/distribution/avatar/type.js +2 -0
- package/distribution/avatar/type.js.map +1 -0
- package/distribution/badge/index.d.ts +10 -0
- package/distribution/badge/index.d.ts.map +1 -0
- package/distribution/badge/index.js +15 -0
- package/distribution/badge/index.js.map +1 -0
- package/distribution/badge/index.module.css +1 -0
- package/distribution/badge/index.module.scss +7 -0
- package/distribution/badge/type.d.ts +4 -0
- package/distribution/badge/type.d.ts.map +1 -0
- package/distribution/badge/type.js +2 -0
- package/distribution/badge/type.js.map +1 -0
- package/distribution/box/index.d.ts +2 -1
- package/distribution/box/index.d.ts.map +1 -1
- package/distribution/box/index.js +11 -4
- package/distribution/box/index.js.map +1 -1
- package/distribution/box/index.module.css +1 -1
- package/distribution/box/index.module.scss +37 -3
- package/distribution/box/type.d.ts +18 -3
- package/distribution/box/type.d.ts.map +1 -1
- package/distribution/box-axis/index.d.ts +3 -1
- package/distribution/box-axis/index.d.ts.map +1 -1
- package/distribution/box-axis/index.js +70 -16
- package/distribution/box-axis/index.js.map +1 -1
- package/distribution/button/index.d.ts +2 -2
- package/distribution/button/index.d.ts.map +1 -1
- package/distribution/button/index.js +6 -5
- package/distribution/button/index.js.map +1 -1
- package/distribution/button/type.d.ts +4 -1
- package/distribution/button/type.d.ts.map +1 -1
- package/distribution/button-axis/index.d.ts +1 -1
- package/distribution/button-axis/index.js +1 -1
- package/distribution/button-axis/index.js.map +1 -1
- package/distribution/card/index.d.ts +11 -0
- package/distribution/card/index.d.ts.map +1 -0
- package/distribution/card/index.js +18 -0
- package/distribution/card/index.js.map +1 -0
- package/distribution/card/index.module.css +1 -0
- package/distribution/card/index.module.scss +22 -0
- package/distribution/card/type.d.ts +15 -0
- package/distribution/card/type.d.ts.map +1 -0
- package/distribution/card/type.js +2 -0
- package/distribution/card/type.js.map +1 -0
- package/distribution/code-boxes/index.d.ts +11 -0
- package/distribution/code-boxes/index.d.ts.map +1 -0
- package/distribution/code-boxes/index.js +64 -0
- package/distribution/code-boxes/index.js.map +1 -0
- package/distribution/code-boxes/index.module.css +1 -0
- package/distribution/code-boxes/index.module.scss +28 -0
- package/distribution/code-boxes/type.d.ts +17 -0
- package/distribution/code-boxes/type.d.ts.map +1 -0
- package/distribution/code-boxes/type.js +2 -0
- package/distribution/code-boxes/type.js.map +1 -0
- package/distribution/combobox/index.d.ts +18 -0
- package/distribution/combobox/index.d.ts.map +1 -0
- package/distribution/combobox/index.js +105 -0
- package/distribution/combobox/index.js.map +1 -0
- package/distribution/combobox/index.module.css +1 -0
- package/distribution/combobox/index.module.scss +25 -0
- package/distribution/combobox/type.d.ts +8 -0
- package/distribution/combobox/type.d.ts.map +1 -0
- package/distribution/combobox/type.js +2 -0
- package/distribution/combobox/type.js.map +1 -0
- package/distribution/copy-button/index.d.ts +10 -0
- package/distribution/copy-button/index.d.ts.map +1 -0
- package/distribution/copy-button/index.js +26 -0
- package/distribution/copy-button/index.js.map +1 -0
- package/distribution/copy-button/type.d.ts +11 -0
- package/distribution/copy-button/type.d.ts.map +1 -0
- package/distribution/copy-button/type.js +2 -0
- package/distribution/copy-button/type.js.map +1 -0
- package/distribution/date-picker/index.d.ts +35 -0
- package/distribution/date-picker/index.d.ts.map +1 -0
- package/distribution/date-picker/index.js +161 -0
- package/distribution/date-picker/index.js.map +1 -0
- package/distribution/date-picker/index.module.css +1 -0
- package/distribution/date-picker/index.module.scss +70 -0
- package/distribution/date-picker/type.d.ts +41 -0
- package/distribution/date-picker/type.d.ts.map +1 -0
- package/distribution/date-picker/type.js +2 -0
- package/distribution/date-picker/type.js.map +1 -0
- package/distribution/dialog/index.d.ts +12 -0
- package/distribution/dialog/index.d.ts.map +1 -0
- package/distribution/dialog/index.js +56 -0
- package/distribution/dialog/index.js.map +1 -0
- package/distribution/dialog/index.module.css +1 -0
- package/distribution/dialog/index.module.scss +59 -0
- package/distribution/dialog/type.d.ts +11 -0
- package/distribution/dialog/type.d.ts.map +1 -0
- package/distribution/dialog/type.js +2 -0
- package/distribution/dialog/type.js.map +1 -0
- package/distribution/field/index.d.ts +1 -1
- package/distribution/field/index.d.ts.map +1 -1
- package/distribution/field/index.js +2 -2
- package/distribution/field/index.js.map +1 -1
- package/distribution/glow-layer/index.d.ts +13 -0
- package/distribution/glow-layer/index.d.ts.map +1 -0
- package/distribution/glow-layer/index.js +38 -0
- package/distribution/glow-layer/index.js.map +1 -0
- package/distribution/glow-layer/index.module.css +1 -0
- package/distribution/glow-layer/index.module.scss +31 -0
- package/distribution/glow-layer/type.d.ts +5 -0
- package/distribution/glow-layer/type.d.ts.map +1 -0
- package/distribution/glow-layer/type.js +2 -0
- package/distribution/glow-layer/type.js.map +1 -0
- package/distribution/interface-configuration/index.d.ts +1 -1
- package/distribution/interface-configuration/index.d.ts.map +1 -1
- package/distribution/interface-configuration/index.js +16 -4
- package/distribution/interface-configuration/index.js.map +1 -1
- package/distribution/interface-configuration/type.d.ts +10 -2
- package/distribution/interface-configuration/type.d.ts.map +1 -1
- package/distribution/listbox/index.d.ts +11 -0
- package/distribution/listbox/index.d.ts.map +1 -0
- package/distribution/listbox/index.js +21 -0
- package/distribution/listbox/index.js.map +1 -0
- package/distribution/listbox/index.module.css +1 -0
- package/distribution/listbox/index.module.scss +38 -0
- package/distribution/listbox/type.d.ts +22 -0
- package/distribution/listbox/type.d.ts.map +1 -0
- package/distribution/listbox/type.js +2 -0
- package/distribution/listbox/type.js.map +1 -0
- package/distribution/navigation/index.d.ts +13 -0
- package/distribution/navigation/index.d.ts.map +1 -0
- package/distribution/navigation/index.js +27 -0
- package/distribution/navigation/index.js.map +1 -0
- package/distribution/navigation/index.module.css +1 -0
- package/distribution/navigation/index.module.scss +64 -0
- package/distribution/navigation/type.d.ts +24 -0
- package/distribution/navigation/type.d.ts.map +1 -0
- package/distribution/navigation/type.js +2 -0
- package/distribution/navigation/type.js.map +1 -0
- package/distribution/notification/index.d.ts +19 -0
- package/distribution/notification/index.d.ts.map +1 -0
- package/distribution/notification/index.js +48 -0
- package/distribution/notification/index.js.map +1 -0
- package/distribution/notification/index.module.css +1 -0
- package/distribution/notification/index.module.scss +35 -0
- package/distribution/notification/type.d.ts +23 -0
- package/distribution/notification/type.d.ts.map +1 -0
- package/distribution/notification/type.js +2 -0
- package/distribution/notification/type.js.map +1 -0
- package/distribution/number-field/index.d.ts +10 -0
- package/distribution/number-field/index.d.ts.map +1 -0
- package/distribution/number-field/index.js +46 -0
- package/distribution/number-field/index.js.map +1 -0
- package/distribution/number-field/index.module.css +1 -0
- package/distribution/number-field/index.module.scss +29 -0
- package/distribution/number-field/type.d.ts +29 -0
- package/distribution/number-field/type.d.ts.map +1 -0
- package/distribution/number-field/type.js +2 -0
- package/distribution/number-field/type.js.map +1 -0
- package/distribution/select/index.d.ts +13 -0
- package/distribution/select/index.d.ts.map +1 -0
- package/distribution/select/index.js +102 -0
- package/distribution/select/index.js.map +1 -0
- package/distribution/select/index.module.css +1 -0
- package/distribution/select/index.module.scss +42 -0
- package/distribution/select/type.d.ts +25 -0
- package/distribution/select/type.d.ts.map +1 -0
- package/distribution/select/type.js +2 -0
- package/distribution/select/type.js.map +1 -0
- package/distribution/separator/index.d.ts +11 -0
- package/distribution/separator/index.d.ts.map +1 -0
- package/distribution/separator/index.js +16 -0
- package/distribution/separator/index.js.map +1 -0
- package/distribution/separator/index.module.css +1 -0
- package/distribution/separator/index.module.scss +12 -0
- package/distribution/separator/type.d.ts +7 -0
- package/distribution/separator/type.d.ts.map +1 -0
- package/distribution/separator/type.js +2 -0
- package/distribution/separator/type.js.map +1 -0
- package/distribution/skeleton/index.d.ts +11 -0
- package/distribution/skeleton/index.d.ts.map +1 -0
- package/distribution/skeleton/index.js +20 -0
- package/distribution/skeleton/index.js.map +1 -0
- package/distribution/skeleton/index.module.css +1 -0
- package/distribution/skeleton/index.module.scss +96 -0
- package/distribution/skeleton/type.d.ts +16 -0
- package/distribution/skeleton/type.d.ts.map +1 -0
- package/distribution/skeleton/type.js +2 -0
- package/distribution/skeleton/type.js.map +1 -0
- package/distribution/skeleton-value/index.d.ts +10 -0
- package/distribution/skeleton-value/index.d.ts.map +1 -0
- package/distribution/skeleton-value/index.js +15 -0
- package/distribution/skeleton-value/index.js.map +1 -0
- package/distribution/skeleton-value/index.module.css +1 -0
- package/distribution/skeleton-value/index.module.scss +35 -0
- package/distribution/skeleton-value/type.d.ts +9 -0
- package/distribution/skeleton-value/type.d.ts.map +1 -0
- package/distribution/skeleton-value/type.js +2 -0
- package/distribution/skeleton-value/type.js.map +1 -0
- package/distribution/style-sheet/index.d.ts.map +1 -1
- package/distribution/style-sheet/index.js +109 -28
- package/distribution/style-sheet/index.js.map +1 -1
- package/distribution/switch/index.js +1 -1
- package/distribution/switch/index.js.map +1 -1
- package/distribution/switch/index.module.css +1 -1
- package/distribution/switch/index.module.scss +8 -5
- package/distribution/tabs/index.d.ts +11 -0
- package/distribution/tabs/index.d.ts.map +1 -0
- package/distribution/tabs/index.js +45 -0
- package/distribution/tabs/index.js.map +1 -0
- package/distribution/tabs/index.module.css +1 -0
- package/distribution/tabs/index.module.scss +13 -0
- package/distribution/tabs/type.d.ts +19 -0
- package/distribution/tabs/type.d.ts.map +1 -0
- package/distribution/tabs/type.js +2 -0
- package/distribution/tabs/type.js.map +1 -0
- package/distribution/text-field/index.js +1 -1
- package/distribution/text-field/index.js.map +1 -1
- package/distribution/tip/index.d.ts +10 -0
- package/distribution/tip/index.d.ts.map +1 -0
- package/distribution/tip/index.js +22 -0
- package/distribution/tip/index.js.map +1 -0
- package/distribution/tip/index.module.css +1 -0
- package/distribution/tip/index.module.scss +24 -0
- package/distribution/tip/type.d.ts +7 -0
- package/distribution/tip/type.d.ts.map +1 -0
- package/distribution/tip/type.js +2 -0
- package/distribution/tip/type.js.map +1 -0
- package/distribution/toggle-mark/index.js +1 -1
- package/distribution/toggle-mark/index.js.map +1 -1
- package/distribution/wrapper/index.d.ts +11 -0
- package/distribution/wrapper/index.d.ts.map +1 -0
- package/distribution/wrapper/index.js +16 -0
- package/distribution/wrapper/index.js.map +1 -0
- package/distribution/wrapper/index.module.css +1 -0
- package/distribution/wrapper/index.module.scss +9 -0
- package/distribution/wrapper/type.d.ts +4 -0
- package/distribution/wrapper/type.d.ts.map +1 -0
- package/distribution/wrapper/type.js +2 -0
- package/distribution/wrapper/type.js.map +1 -0
- package/package.json +4 -2
|
@@ -8,8 +8,16 @@ export type BoxAlign = "start" | "center" | "end" | "stretch" | "baseline";
|
|
|
8
8
|
export type BoxTextAlign = "start" | "center" | "end" | "left" | "right";
|
|
9
9
|
/** A step of the scale, in pixels. */
|
|
10
10
|
export type ScaleStep = 0 | 4 | 8 | 12 | 14 | 16 | 24 | 32 | 64 | 128;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* An interactive box's state. `none` (the default) leaves it to the pointer: it turns when hovered and pressed. Any
|
|
13
|
+
* other is set and stays: `enabled` at rest, `hover` hovered, `active` and `loading` pressed (with the default
|
|
14
|
+
* cursor), `disabled` faded.
|
|
15
|
+
*/
|
|
16
|
+
export type BoxState = "none" | "enabled" | "hover" | "active" | "loading" | "disabled";
|
|
17
|
+
/** What a box can add to its look: `glass` (the default) blurs what is behind it, `glow` lights it from around. */
|
|
18
|
+
export type BoxModification = "glass" | "glow";
|
|
19
|
+
/** Where a glow rests until the pointer comes near. */
|
|
20
|
+
export type GlowStart = "top" | "end" | "bottom" | "start";
|
|
13
21
|
/** Every look a box can take, each for every width or per breakpoint. */
|
|
14
22
|
export interface BoxLook {
|
|
15
23
|
variant?: Responsive<BoxVariant>;
|
|
@@ -31,6 +39,8 @@ export interface BoxLook {
|
|
|
31
39
|
wrap?: Responsive<"wrap" | "nowrap">;
|
|
32
40
|
gap?: Responsive<ScaleStep>;
|
|
33
41
|
padding?: Responsive<ScaleStep>;
|
|
42
|
+
/** Where a glow rests until the pointer comes near (`bottom` by default). */
|
|
43
|
+
glowStart?: Responsive<GlowStart>;
|
|
34
44
|
}
|
|
35
45
|
export interface BoxProperties extends BoxLook, Omit<HTMLAttributes<HTMLElement>, "color" | "prefix"> {
|
|
36
46
|
/** The element (a tag or a component such as next/link's `Link`); `div` by default. */
|
|
@@ -48,8 +58,13 @@ export interface BoxProperties extends BoxLook, Omit<HTMLAttributes<HTMLElement>
|
|
|
48
58
|
* ring while anything inside has focus, and a line between its sections.
|
|
49
59
|
*/
|
|
50
60
|
field?: boolean;
|
|
51
|
-
/** An interactive box's state (`
|
|
61
|
+
/** An interactive box's state (`none` by default: it follows the pointer). */
|
|
52
62
|
state?: BoxState;
|
|
63
|
+
/**
|
|
64
|
+
* What the box adds to its look, any together: `glass` blurs what is behind a see-through box, `glow` lights it
|
|
65
|
+
* from around, turning toward the pointer. Without a list, glass; an empty list, nothing.
|
|
66
|
+
*/
|
|
67
|
+
modifications?: readonly BoxModification[];
|
|
53
68
|
/** Anything else the element takes (`href`, `type`, `disabled`…). */
|
|
54
69
|
[attribute: string]: unknown;
|
|
55
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.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UAAU,CAAC,UAAU,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IACrC,uFAAuF;IACvF,IAAI,CAAC,EAAE,UAAU,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;IACrC,GAAG,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IAChC,6EAA6E;IAC7E,SAAS,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,aAAc,SAAQ,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACnG,uFAAuF;IACvF,EAAE,CAAC,EAAE,WAAW,CAAC;IACjB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,oDAAoD;IACpD,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iGAAiG;IACjG,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IAC3C,qEAAqE;IACrE,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B"}
|
|
@@ -13,9 +13,11 @@ export declare const ALIGN_AXIS: Axis;
|
|
|
13
13
|
export declare const TEXT_ALIGN_AXIS: Axis;
|
|
14
14
|
/** Whether children wrap onto more lines when they don't fit. */
|
|
15
15
|
export declare const WRAP_AXIS: Axis;
|
|
16
|
+
/** Where a glow rests until the pointer comes near: below by default, or at any side. */
|
|
17
|
+
export declare const GLOW_START_AXIS: Axis;
|
|
16
18
|
/**
|
|
17
19
|
* Every axis of a box, in the order their rules are written: variant, direction, justify, align, text align, and the
|
|
18
|
-
* gap and padding from the scale.
|
|
20
|
+
* gap and padding from the scale, and where a glow starts.
|
|
19
21
|
*
|
|
20
22
|
* @example
|
|
21
23
|
* boxAxes(DEFAULT_INTERFACE.scale).map((axis) => axis.attribute); // ["data-variant", "data-direction", …]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/box-axis/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,8DAA8D,CAAC;AAE3G,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/box-axis/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,8DAA8D,CAAC;AAE3G,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,EAAE,gBAuBhC,CAAC;AAsDF,6GAA6G;AAC7G,eAAO,MAAM,YAAY,EAAE,IAwC1B,CAAC;AAQF,oHAAoH;AACpH,eAAO,MAAM,cAAc,MAKzB,CAAC;AACH,6GAA6G;AAC7G,eAAO,MAAM,YAAY,MAIxB,CAAC;AACF,4BAA4B;AAC5B,eAAO,MAAM,UAAU,MAA2F,CAAC;AACnH,4CAA4C;AAC5C,eAAO,MAAM,eAAe,MAI3B,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,SAAS,MAA0D,CAAC;AAMjF,yFAAyF;AACzF,eAAO,MAAM,eAAe,MAK1B,CAAC;AAEH;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,EAAE,CAYxD"}
|
|
@@ -13,7 +13,14 @@ export const BOX_INITIAL_VALUES = {
|
|
|
13
13
|
"box-border-thickness": "0px",
|
|
14
14
|
"box-border-color": "transparent",
|
|
15
15
|
"box-background": "transparent",
|
|
16
|
+
"box-background-image": "none",
|
|
16
17
|
"box-text-color": "currentcolor",
|
|
18
|
+
"box-text-paint": "none",
|
|
19
|
+
"box-text-fill": "currentcolor",
|
|
20
|
+
"box-text-clip": "border-box",
|
|
21
|
+
"box-border-paint": "none",
|
|
22
|
+
"box-border-gradient-weight": "0%",
|
|
23
|
+
"box-ring-display": "none",
|
|
17
24
|
"box-backdrop": "none",
|
|
18
25
|
};
|
|
19
26
|
/** What every variant sets, so one variant replaces another whole, at any breakpoint. */
|
|
@@ -24,20 +31,48 @@ const SIZED = {
|
|
|
24
31
|
"box-border-thickness": "var(--line-thickness)",
|
|
25
32
|
};
|
|
26
33
|
const GLASS = "blur(var(--glass-blur))";
|
|
27
|
-
/**
|
|
28
|
-
const
|
|
34
|
+
/** Text in the color, painted with its gradient where it has one. */
|
|
35
|
+
const PAINTED_TEXT = {
|
|
36
|
+
"box-text-color": "var(--current-color)",
|
|
37
|
+
"box-text-paint": "var(--current-color-gradient, none)",
|
|
38
|
+
"box-text-fill": "var(--current-text-fill)",
|
|
39
|
+
"box-text-clip": "var(--current-text-clip)",
|
|
40
|
+
};
|
|
41
|
+
/** No border, no gradient border. */
|
|
42
|
+
const UNBORDERED = {
|
|
43
|
+
"box-border-color": "transparent",
|
|
44
|
+
"box-border-paint": "none",
|
|
45
|
+
"box-border-gradient-weight": "0%",
|
|
46
|
+
"box-ring-display": "none",
|
|
47
|
+
};
|
|
48
|
+
/** A background in a transparent color, or its gradient (whose flat color then hides). */
|
|
49
|
+
const tint = (state) => ({
|
|
50
|
+
"box-background": `color-mix(in srgb, transparent var(--current-color-gradient-weight), var(--current-transparent-${state}-color))`,
|
|
51
|
+
"box-background-image": `var(--current-transparent-${state}-color-gradient, none)`,
|
|
52
|
+
"box-text-color": "var(--current-hover-color)",
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Outlined and transparent: the color's transparent background (or gradient) while hovered and pressed;
|
|
56
|
+
* middleground's text turns. Outlined's border is the color's transparent one, a gradient on whole lines.
|
|
57
|
+
*/
|
|
58
|
+
const tinted = (bordered) => ({
|
|
29
59
|
rest: {
|
|
30
60
|
...SIZED,
|
|
31
61
|
"box-background": "transparent",
|
|
32
|
-
"box-
|
|
33
|
-
|
|
62
|
+
"box-background-image": "none",
|
|
63
|
+
...PAINTED_TEXT,
|
|
64
|
+
...(bordered
|
|
65
|
+
? {
|
|
66
|
+
"box-border-color": "var(--current-border-color)",
|
|
67
|
+
"box-border-paint": "var(--current-transparent-color-gradient, none)",
|
|
68
|
+
"box-border-gradient-weight": "var(--current-color-gradient-weight)",
|
|
69
|
+
"box-ring-display": "var(--current-color-gradient-display)",
|
|
70
|
+
}
|
|
71
|
+
: UNBORDERED),
|
|
34
72
|
"box-backdrop": GLASS,
|
|
35
73
|
},
|
|
36
|
-
hover:
|
|
37
|
-
active:
|
|
38
|
-
"box-background": "var(--current-transparent-active-color)",
|
|
39
|
-
"box-text-color": "var(--current-hover-color)",
|
|
40
|
-
},
|
|
74
|
+
hover: tint("hover"),
|
|
75
|
+
active: tint("active"),
|
|
41
76
|
});
|
|
42
77
|
/** The variants: filled, outlined, transparent and inline (a box that sits in running text, like a link). */
|
|
43
78
|
export const VARIANT_AXIS = {
|
|
@@ -46,14 +81,24 @@ export const VARIANT_AXIS = {
|
|
|
46
81
|
filled: {
|
|
47
82
|
rest: {
|
|
48
83
|
...SIZED,
|
|
49
|
-
"box-background": "var(--current-color
|
|
84
|
+
"box-background": "var(--current-color)",
|
|
85
|
+
"box-background-image": "var(--current-color-gradient, none)",
|
|
50
86
|
"box-text-color": "var(--current-on-color)",
|
|
51
|
-
"box-
|
|
87
|
+
"box-text-paint": "none",
|
|
88
|
+
"box-text-fill": "currentcolor",
|
|
89
|
+
"box-text-clip": "border-box",
|
|
90
|
+
...UNBORDERED,
|
|
52
91
|
"box-backdrop": "none",
|
|
53
92
|
},
|
|
93
|
+
// Unchanged, unless the color turns another on hover (middleground turns foreground).
|
|
94
|
+
hover: {
|
|
95
|
+
"box-background": "var(--current-filled-hover-color)",
|
|
96
|
+
"box-background-image": "var(--current-filled-hover-color-gradient, none)",
|
|
97
|
+
"box-text-color": "var(--current-filled-hover-on-color)",
|
|
98
|
+
},
|
|
54
99
|
},
|
|
55
|
-
outlined: tinted(
|
|
56
|
-
transparent: tinted(
|
|
100
|
+
outlined: tinted(true),
|
|
101
|
+
transparent: tinted(false),
|
|
57
102
|
inline: {
|
|
58
103
|
rest: {
|
|
59
104
|
"box-display": "inline-flex",
|
|
@@ -61,8 +106,9 @@ export const VARIANT_AXIS = {
|
|
|
61
106
|
"box-minimum-size": "0px",
|
|
62
107
|
"box-border-thickness": "0px",
|
|
63
108
|
"box-background": "transparent",
|
|
64
|
-
"box-
|
|
65
|
-
|
|
109
|
+
"box-background-image": "none",
|
|
110
|
+
...PAINTED_TEXT,
|
|
111
|
+
...UNBORDERED,
|
|
66
112
|
"box-backdrop": "none",
|
|
67
113
|
},
|
|
68
114
|
hover: { "box-text-color": "var(--current-hover-color)" },
|
|
@@ -92,9 +138,16 @@ export const TEXT_ALIGN_AXIS = simple("data-text-align", "box-text-align", same(
|
|
|
92
138
|
export const WRAP_AXIS = simple("data-wrap", "box-wrap", same("wrap", "nowrap"));
|
|
93
139
|
/** Spaces from the scale: `data-gap="8"` is `var(--scale-8)`. */
|
|
94
140
|
const spaced = (attribute, property, scale) => simple(attribute, property, Object.fromEntries(scale.map((step) => [String(step), `var(--scale-${step})`])));
|
|
141
|
+
/** Where a glow rests until the pointer comes near: below by default, or at any side. */
|
|
142
|
+
export const GLOW_START_AXIS = simple("data-glow-start", "glow-start-angle", {
|
|
143
|
+
top: "-90deg",
|
|
144
|
+
end: "0deg",
|
|
145
|
+
bottom: "90deg",
|
|
146
|
+
start: "180deg",
|
|
147
|
+
});
|
|
95
148
|
/**
|
|
96
149
|
* Every axis of a box, in the order their rules are written: variant, direction, justify, align, text align, and the
|
|
97
|
-
* gap and padding from the scale.
|
|
150
|
+
* gap and padding from the scale, and where a glow starts.
|
|
98
151
|
*
|
|
99
152
|
* @example
|
|
100
153
|
* boxAxes(DEFAULT_INTERFACE.scale).map((axis) => axis.attribute); // ["data-variant", "data-direction", …]
|
|
@@ -109,6 +162,7 @@ export function boxAxes(scale) {
|
|
|
109
162
|
WRAP_AXIS,
|
|
110
163
|
spaced("data-gap", "box-gap", scale),
|
|
111
164
|
spaced("data-padding", "box-padding", scale),
|
|
165
|
+
GLOW_START_AXIS,
|
|
112
166
|
];
|
|
113
167
|
}
|
|
114
168
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/box-axis/index.ts"],"names":[],"mappings":"AAEA,uFAAuF;AACvF,MAAM,CAAC,MAAM,kBAAkB,GAAqB;IAClD,aAAa,EAAE,MAAM;IACrB,eAAe,EAAE,KAAK;IACtB,aAAa,EAAE,QAAQ;IACvB,WAAW,EAAE,QAAQ;IACrB,gBAAgB,EAAE,QAAQ;IAC1B,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,KAAK;IAChB,aAAa,EAAE,KAAK;IACpB,kBAAkB,EAAE,KAAK;IACzB,qBAAqB,EAAE,KAAK;IAC5B,sBAAsB,EAAE,KAAK;IAC7B,kBAAkB,EAAE,aAAa;IACjC,gBAAgB,EAAE,aAAa;IAC/B,gBAAgB,EAAE,cAAc;IAChC,cAAc,EAAE,MAAM;CACvB,CAAC;AAEF,yFAAyF;AACzF,MAAM,KAAK,GAAqB;IAC9B,aAAa,EAAE,MAAM;IACrB,qBAAqB,EAAE,gCAAgC;IACvD,kBAAkB,EAAE,6BAA6B;IACjD,sBAAsB,EAAE,uBAAuB;CAChD,CAAC;AACF,MAAM,KAAK,GAAG,yBAAyB,CAAC;AACxC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/box-axis/index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;QACZ,UAAU;QACV,eAAe;QACf,SAAS;QACT,MAAM,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC;QACpC,MAAM,CAAC,cAAc,EAAE,aAAa,EAAE,KAAK,CAAC;QAC5C,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -3,8 +3,8 @@ import type { ButtonProperties } from "@sharadox/graphical-user-interface-web-li
|
|
|
3
3
|
* The button: a `<button>`, or with `href` a link (next/link's `Link`, or the site's own `link`) that looks the same,
|
|
4
4
|
* so the two can never drift apart. Filled in the brand color by default; any variant, color, color style, corner,
|
|
5
5
|
* line and size (each per breakpoint too), a prefix and a suffix section, or one square icon. While `loading` it
|
|
6
|
-
* shows the spinner, is marked busy and ignores clicks, so an action never runs twice;
|
|
7
|
-
* address. It is a client component (it handles clicks), so a server page can use it with serializable properties.
|
|
6
|
+
* shows the spinner, is marked busy and ignores clicks, so an action never runs twice; a set `active` state (the
|
|
7
|
+
* current page, say) ignores them too; disabled, a link loses its address. It is a client component (it handles clicks), so a server page can use it with serializable properties.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* <Button type="submit" loading={saving}>Save</Button>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/button/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAC;AAEnG;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,UAAU,EAAE,gBAAgB,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/button/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAC;AAEnG;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,UAAU,EAAE,gBAAgB,+BAkDlD"}
|
|
@@ -7,8 +7,8 @@ import { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
|
7
7
|
* The button: a `<button>`, or with `href` a link (next/link's `Link`, or the site's own `link`) that looks the same,
|
|
8
8
|
* so the two can never drift apart. Filled in the brand color by default; any variant, color, color style, corner,
|
|
9
9
|
* line and size (each per breakpoint too), a prefix and a suffix section, or one square icon. While `loading` it
|
|
10
|
-
* shows the spinner, is marked busy and ignores clicks, so an action never runs twice;
|
|
11
|
-
* address. It is a client component (it handles clicks), so a server page can use it with serializable properties.
|
|
10
|
+
* shows the spinner, is marked busy and ignores clicks, so an action never runs twice; a set `active` state (the
|
|
11
|
+
* current page, say) ignores them too; disabled, a link loses its address. It is a client component (it handles clicks), so a server page can use it with serializable properties.
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* <Button type="submit" loading={saving}>Save</Button>
|
|
@@ -17,8 +17,9 @@ import { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
|
17
17
|
*/
|
|
18
18
|
export function Button(properties) {
|
|
19
19
|
const { variant = "filled", color = "brand", state, loading = false, disabled = false, icon, square, children, onClick, ...rest } = properties;
|
|
20
|
-
const currentState = state ?? (disabled ? "disabled" : loading ? "loading" : "
|
|
21
|
-
|
|
20
|
+
const currentState = state ?? (disabled ? "disabled" : loading ? "loading" : "none");
|
|
21
|
+
// Pressed for good (active), busy or disabled: a click does nothing.
|
|
22
|
+
const ignored = currentState === "active" || currentState === "loading" || currentState === "disabled";
|
|
22
23
|
const click = (event) => {
|
|
23
24
|
if (ignored)
|
|
24
25
|
event.preventDefault();
|
|
@@ -37,6 +38,6 @@ export function Button(properties) {
|
|
|
37
38
|
}
|
|
38
39
|
const { type = "button", link: _link, ...button } = box;
|
|
39
40
|
void _link;
|
|
40
|
-
return (_jsx(Box, { ...button, as: "button", type: type, disabled:
|
|
41
|
+
return (_jsx(Box, { ...button, as: "button", type: type, disabled: disabled, children: content }));
|
|
41
42
|
}
|
|
42
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/button/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AAIzE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM,CAAC,UAA4B;IACjD,MAAM,EACJ,OAAO,GAAG,QAAQ,EAClB,KAAK,GAAG,OAAO,EACf,KAAK,EACL,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,EAChB,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,OAAO,EACP,GAAG,IAAI,EACR,GAAG,UAAU,CAAC;IACf,MAAM,YAAY,GAAa,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/button/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AAIzE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM,CAAC,UAA4B;IACjD,MAAM,EACJ,OAAO,GAAG,QAAQ,EAClB,KAAK,GAAG,OAAO,EACf,KAAK,EACL,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,EAChB,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,OAAO,EACP,GAAG,IAAI,EACR,GAAG,UAAU,CAAC;IACf,MAAM,YAAY,GAAa,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,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AK,MAAM,EAAE,EAAE,EAAC,QAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,YACxD,OAAO,GACJ,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -8,7 +8,10 @@ export interface ButtonLinkProperties extends Omit<AnchorHTMLAttributes<HTMLAnch
|
|
|
8
8
|
}
|
|
9
9
|
/** What every button shares, a link or not. */
|
|
10
10
|
interface ButtonLook extends Omit<BoxLook, "direction" | "justify" | "align" | "textAlign" | "gap" | "padding"> {
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Sets a state that stays (`none`, the default, follows the pointer, `disabled` and `loading`); `active`,
|
|
13
|
+
* `loading` and `disabled` ignore clicks.
|
|
14
|
+
*/
|
|
12
15
|
state?: BoxState;
|
|
13
16
|
/** Shows the spinner instead of the words and ignores clicks while an action runs. */
|
|
14
17
|
loading?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/button/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAC;AAEjG,oGAAoG;AACpG,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACjG,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,+CAA+C;AAC/C,UAAU,UAAW,SAAQ,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,KAAK,GAAG,SAAS,CAAC;IAC7G
|
|
1
|
+
{"version":3,"file":"type.d.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,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC,GAAG;IAC3E,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,yGAAyG;IACzG,IAAI,CAAC,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAC5C,CAAC,CAAC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const BUTTON_AXES: {
|
|
9
9
|
readonly variant: readonly ["filled", "outlined", "transparent", "inline"];
|
|
10
|
-
readonly state: readonly ["enabled", "hover", "active", "loading", "disabled"];
|
|
10
|
+
readonly state: readonly ["none", "enabled", "hover", "active", "loading", "disabled"];
|
|
11
11
|
readonly size: readonly ["small", "medium", "large"];
|
|
12
12
|
};
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export const BUTTON_AXES = {
|
|
9
9
|
variant: ["filled", "outlined", "transparent", "inline"],
|
|
10
|
-
state: ["enabled", "hover", "active", "loading", "disabled"],
|
|
10
|
+
state: ["none", "enabled", "hover", "active", "loading", "disabled"],
|
|
11
11
|
size: ["small", "medium", "large"],
|
|
12
12
|
};
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/button-axis/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,OAAO,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,CAAC;IACxD,KAAK,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/button-axis/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,OAAO,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,CAAC;IACxD,KAAK,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC;IACpE,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC;CAC1B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CardProperties } from "@sharadox/graphical-user-interface-web-library/card/type";
|
|
2
|
+
/**
|
|
3
|
+
* A card: one thing on its own (a picture, a name, an identifier). Its title, description and content on one side,
|
|
4
|
+
* its action buttons on the other, centered on the card's height; they wrap under it when there is no room. An
|
|
5
|
+
* outlined foreground article by default (see-through, so glass), with every box look.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <Card title="Email" description="Where sign-in codes go." action={<Button variant="outlined">Edit</Button>}>ana@example.com</Card>
|
|
9
|
+
*/
|
|
10
|
+
export declare function Card(properties: CardProperties): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/card/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0DAA0D,CAAC;AAG/F;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,UAAU,EAAE,cAAc,+BA4B9C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { classNames } from "@sharadox/web-library/class-name";
|
|
3
|
+
import { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
4
|
+
import styles from "./index.module.css";
|
|
5
|
+
/**
|
|
6
|
+
* A card: one thing on its own (a picture, a name, an identifier). Its title, description and content on one side,
|
|
7
|
+
* its action buttons on the other, centered on the card's height; they wrap under it when there is no room. An
|
|
8
|
+
* outlined foreground article by default (see-through, so glass), with every box look.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <Card title="Email" description="Where sign-in codes go." action={<Button variant="outlined">Edit</Button>}>ana@example.com</Card>
|
|
12
|
+
*/
|
|
13
|
+
export function Card(properties) {
|
|
14
|
+
const { title, headingLevel = 2, description, action, children, className, ...box } = properties;
|
|
15
|
+
const Heading = `h${headingLevel}`;
|
|
16
|
+
return (_jsxs(Box, { as: "article", variant: "outlined", color: "foreground", padding: 24, gap: 16, justify: "space-between", wrap: "wrap", textAlign: "start", ...box, className: classNames(styles.card, className), children: [_jsxs(Box, { direction: "top-to-bottom", align: "start", textAlign: "start", gap: 8, className: styles.body, children: [title !== undefined && _jsx(Heading, { className: styles.title, children: title }), description !== undefined && _jsx("p", { className: styles.description, children: description }), children] }), action !== undefined && (_jsx(Box, { gap: 8, wrap: "wrap", className: styles.action, children: action }))] }));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/card/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AAEzE,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAC,UAA0B;IAC7C,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,GAAG,EAAE,GAAG,UAAU,CAAC;IACjG,MAAM,OAAO,GAAG,IAAI,YAAY,EAAW,CAAC;IAC5C,OAAO,CACL,MAAC,GAAG,IACF,EAAE,EAAC,SAAS,EACZ,OAAO,EAAC,UAAU,EAClB,KAAK,EAAC,YAAY,EAClB,OAAO,EAAE,EAAE,EACX,GAAG,EAAE,EAAE,EACP,OAAO,EAAC,eAAe,EACvB,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,OAAO,KACb,GAAG,EACP,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,aAE7C,MAAC,GAAG,IAAC,SAAS,EAAC,eAAe,EAAC,KAAK,EAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAC,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,aAC1F,KAAK,KAAK,SAAS,IAAI,KAAC,OAAO,IAAC,SAAS,EAAE,MAAM,CAAC,KAAK,YAAG,KAAK,GAAW,EAC1E,WAAW,KAAK,SAAS,IAAI,YAAG,SAAS,EAAE,MAAM,CAAC,WAAW,YAAG,WAAW,GAAK,EAChF,QAAQ,IACL,EACL,MAAM,KAAK,SAAS,IAAI,CACvB,KAAC,GAAG,IAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAC,MAAM,EAAC,SAAS,EAAE,MAAM,CAAC,MAAM,YAC9C,MAAM,GACH,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.body){flex:1 1 240px;min-inline-size:0}:where(.title){margin:0;font-size:var(--scale-16);font-weight:600}:where(.description){margin:0;color:inherit;opacity:.7;font-size:var(--scale-14)}:where(.action){flex:none}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
:where(.body) {
|
|
2
|
+
flex: 1 1 240px;
|
|
3
|
+
min-inline-size: 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:where(.title) {
|
|
7
|
+
margin: 0;
|
|
8
|
+
font-size: var(--scale-16);
|
|
9
|
+
font-weight: 600;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:where(.description) {
|
|
13
|
+
margin: 0;
|
|
14
|
+
// The card's own text, softened, so it reads on any fill.
|
|
15
|
+
color: inherit;
|
|
16
|
+
opacity: 0.7;
|
|
17
|
+
font-size: var(--scale-14);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:where(.action) {
|
|
21
|
+
flex: none;
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { BoxProperties } from "@sharadox/graphical-user-interface-web-library/box/type";
|
|
3
|
+
export interface CardProperties extends Omit<BoxProperties, "title"> {
|
|
4
|
+
/** The card's heading. */
|
|
5
|
+
title?: ReactNode;
|
|
6
|
+
/** Its level (`h2` by default), to fit the page's outline. */
|
|
7
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
8
|
+
/** A line under the title. */
|
|
9
|
+
description?: ReactNode;
|
|
10
|
+
/** Buttons beside the content, centered on the card's height. */
|
|
11
|
+
action?: ReactNode;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/card/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yDAAyD,CAAC;AAE7F,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC;IAClE,0BAA0B;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,8BAA8B;IAC9B,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,iEAAiE;IACjE,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/card/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CodeBoxesProperties } from "@sharadox/graphical-user-interface-web-library/code-boxes/type";
|
|
2
|
+
/**
|
|
3
|
+
* A one-time code typed into one box per digit: each digit moves on to the next box, Backspace or Delete clears the
|
|
4
|
+
* box it is on (on an empty box, Backspace clears the one before), the arrows move back and forth, and pasting the code (or the phone filling it in from a message) fills every box at once. The whole
|
|
5
|
+
* code is in one hidden field for forms. Each box is a large outlined field box (the error color when invalid); `onComplete` fires once every box has its digit.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <CodeBoxes label="Code" digitLabel="digit" ofLabel="of" onComplete={submit} autoFocus />
|
|
9
|
+
*/
|
|
10
|
+
export declare function CodeBoxes({ label, digitLabel, ofLabel, name, length, onComplete, invalid, disabled, describedBy, autoFocus, }: CodeBoxesProperties): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/code-boxes/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gEAAgE,CAAC;AAE1G;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,UAAU,EACV,OAAO,EACP,IAAI,EACJ,MAAU,EACV,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,SAAS,GACV,EAAE,mBAAmB,+BAgFrB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
5
|
+
import styles from "./index.module.css";
|
|
6
|
+
/**
|
|
7
|
+
* A one-time code typed into one box per digit: each digit moves on to the next box, Backspace or Delete clears the
|
|
8
|
+
* box it is on (on an empty box, Backspace clears the one before), the arrows move back and forth, and pasting the code (or the phone filling it in from a message) fills every box at once. The whole
|
|
9
|
+
* code is in one hidden field for forms. Each box is a large outlined field box (the error color when invalid); `onComplete` fires once every box has its digit.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <CodeBoxes label="Code" digitLabel="digit" ofLabel="of" onComplete={submit} autoFocus />
|
|
13
|
+
*/
|
|
14
|
+
export function CodeBoxes({ label, digitLabel, ofLabel, name, length = 6, onComplete, invalid, disabled, describedBy, autoFocus, }) {
|
|
15
|
+
const [digits, setDigits] = useState(() => Array.from({ length }, () => ""));
|
|
16
|
+
const boxes = useRef([]);
|
|
17
|
+
const focus = (index) => boxes.current[Math.max(0, Math.min(length - 1, index))]?.focus();
|
|
18
|
+
/** Puts `typed` digits from box `from` on, then moves to the next empty box. */
|
|
19
|
+
const fill = (from, typed) => {
|
|
20
|
+
const next = [...digits];
|
|
21
|
+
let at = from;
|
|
22
|
+
for (const digit of typed.replace(/\D/g, "").slice(0, length - from))
|
|
23
|
+
next[at++] = digit;
|
|
24
|
+
setDigits(next);
|
|
25
|
+
focus(at);
|
|
26
|
+
const code = next.join("");
|
|
27
|
+
if (code.length === length)
|
|
28
|
+
onComplete?.(code);
|
|
29
|
+
};
|
|
30
|
+
const change = (index, value) => {
|
|
31
|
+
const typed = value.replace(/\D/g, "");
|
|
32
|
+
if (!typed)
|
|
33
|
+
return;
|
|
34
|
+
// One new digit typed over an old one: keep the new one (the last typed).
|
|
35
|
+
fill(index, typed.length === 2 && digits[index] ? typed.slice(-1) : typed);
|
|
36
|
+
};
|
|
37
|
+
/** Empties box `index`. */
|
|
38
|
+
const clear = (index) => setDigits(digits.map((digit, at) => (at === index ? "" : digit)));
|
|
39
|
+
const keyDown = (index, event) => {
|
|
40
|
+
if ((event.key === "Backspace" || event.key === "Delete") && digits[index]) {
|
|
41
|
+
// A filled box: clear it, wherever it is, and stay on it.
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
clear(index);
|
|
44
|
+
}
|
|
45
|
+
else if (event.key === "Backspace") {
|
|
46
|
+
// An empty box: clear the one before and go back to it.
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
clear(Math.max(0, index - 1));
|
|
49
|
+
focus(index - 1);
|
|
50
|
+
}
|
|
51
|
+
else if (event.key === "ArrowLeft")
|
|
52
|
+
focus(index - 1);
|
|
53
|
+
else if (event.key === "ArrowRight")
|
|
54
|
+
focus(index + 1);
|
|
55
|
+
};
|
|
56
|
+
const paste = (index, event) => {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
fill(index, event.clipboardData.getData("text"));
|
|
59
|
+
};
|
|
60
|
+
return (_jsxs("div", { role: "group", "aria-label": label, className: styles.boxes, children: [name && _jsx("input", { type: "hidden", name: name, value: digits.join("") }), digits.map((digit, index) => (_jsx(Box, { field: true, variant: "outlined", color: invalid ? "error" : "middleground", size: "large", state: disabled ? "disabled" : "none", className: styles.cell, children: _jsx("input", { ref: (element) => {
|
|
61
|
+
boxes.current[index] = element;
|
|
62
|
+
}, className: styles.box, value: digit, onChange: (event) => change(index, event.target.value), onKeyDown: (event) => keyDown(index, event), onPaste: (event) => paste(index, event), onFocus: (event) => event.target.select(), inputMode: "numeric", autoComplete: index === 0 ? "one-time-code" : "off", "aria-label": `${label}, ${digitLabel} ${index + 1} ${ofLabel} ${length}`, "aria-invalid": invalid || undefined, "aria-describedby": describedBy, disabled: disabled, autoFocus: autoFocus && index === 0 }) }, index)))] }));
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/code-boxes/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EA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C,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EACtD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,EAC3C,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,EACvC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,EACzC,SAAS,EAAC,SAAS,EACnB,YAAY,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,gBACvC,GAAG,KAAK,KAAK,UAAU,IAAI,KAAK,GAAG,CAAC,IAAI,OAAO,IAAI,MAAM,EAAE,kBACzD,OAAO,IAAI,SAAS,sBAChB,WAAW,EAC7B,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,IAAI,KAAK,KAAK,CAAC,GACnC,IAzBG,KAAK,CA0BN,CACP,CAAC,IACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.boxes){display:flex;gap:var(--scale-8);inline-size:100%}.cell{flex:1 1 0;min-inline-size:0}:where(.box){box-sizing:border-box;inline-size:100%;min-inline-size:0;min-block-size:var(--section-minimum-size);margin:0;padding:0;border:0;outline:0;background:rgba(0,0,0,0);color:var(--current-hover-color);font:inherit;font-size:var(--scale-24);font-variant-numeric:tabular-nums;text-align:center}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// The boxes share the width, each at least as tall as a large field, the digits centered and large.
|
|
2
|
+
:where(.boxes) {
|
|
3
|
+
display: flex;
|
|
4
|
+
gap: var(--scale-8);
|
|
5
|
+
inline-size: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.cell {
|
|
9
|
+
flex: 1 1 0;
|
|
10
|
+
min-inline-size: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:where(.box) {
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
inline-size: 100%;
|
|
16
|
+
min-inline-size: 0;
|
|
17
|
+
min-block-size: var(--section-minimum-size);
|
|
18
|
+
margin: 0;
|
|
19
|
+
padding: 0;
|
|
20
|
+
border: 0;
|
|
21
|
+
outline: 0;
|
|
22
|
+
background: transparent;
|
|
23
|
+
color: var(--current-hover-color);
|
|
24
|
+
font: inherit;
|
|
25
|
+
font-size: var(--scale-24);
|
|
26
|
+
font-variant-numeric: tabular-nums;
|
|
27
|
+
text-align: center;
|
|
28
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface CodeBoxesProperties {
|
|
2
|
+
/** The group's name ("Code"); each box reads "Code, digit 3 of 6". */
|
|
3
|
+
label: string;
|
|
4
|
+
/** "digit" and "of", in the reader's language. */
|
|
5
|
+
digitLabel: string;
|
|
6
|
+
ofLabel: string;
|
|
7
|
+
/** The hidden field's name, for forms. */
|
|
8
|
+
name?: string;
|
|
9
|
+
length?: number;
|
|
10
|
+
/** Once every box has its digit. */
|
|
11
|
+
onComplete?: (code: string) => void;
|
|
12
|
+
invalid?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
describedBy?: string;
|
|
15
|
+
autoFocus?: boolean;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/code-boxes/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/code-boxes/type.ts"],"names":[],"mappings":""}
|