@sharadox/graphical-user-interface-web-library 0.2.0-layout.14 → 0.2.0-navigation.27
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 +12 -0
- package/distribution/avatar/index.module.css +1 -1
- package/distribution/avatar/index.module.scss +2 -0
- package/distribution/card/index.module.css +1 -1
- package/distribution/card/index.module.scss +3 -1
- 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/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/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/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/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/package.json +3 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
:where(.input) {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
inline-size: 100%;
|
|
4
|
+
min-inline-size: 0;
|
|
5
|
+
min-block-size: var(--section-minimum-size);
|
|
6
|
+
margin: 0;
|
|
7
|
+
padding: 0;
|
|
8
|
+
border: 0;
|
|
9
|
+
outline: 0;
|
|
10
|
+
background: transparent;
|
|
11
|
+
color: inherit;
|
|
12
|
+
font: inherit;
|
|
13
|
+
font-variant-numeric: tabular-nums;
|
|
14
|
+
text-align: center;
|
|
15
|
+
appearance: textfield;
|
|
16
|
+
|
|
17
|
+
// The browser's own arrows go: the minus and plus sections replace them.
|
|
18
|
+
&::-webkit-inner-spin-button,
|
|
19
|
+
&::-webkit-outer-spin-button {
|
|
20
|
+
margin: 0;
|
|
21
|
+
appearance: none;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// The buttons fill their sections edge to edge, without corners of their own (a plain class, to beat the box's).
|
|
26
|
+
.button {
|
|
27
|
+
align-self: stretch;
|
|
28
|
+
border-radius: 0;
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { BoxLook, BoxState } from "@sharadox/graphical-user-interface-web-library/box/type";
|
|
3
|
+
export interface NumberFieldProperties extends Pick<BoxLook, "variant" | "color" | "colorStyle" | "corner" | "line" | "size"> {
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
hideLabel?: boolean;
|
|
6
|
+
hint?: ReactNode;
|
|
7
|
+
error?: ReactNode;
|
|
8
|
+
/** Controlled: the number (or `undefined` while empty). */
|
|
9
|
+
value?: number;
|
|
10
|
+
/** Uncontrolled: the number at first. */
|
|
11
|
+
defaultValue?: number;
|
|
12
|
+
/** The new number, or `undefined` once emptied. */
|
|
13
|
+
onChange?: (value: number | undefined) => void;
|
|
14
|
+
min?: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
/** How much each button adds or takes away (1 by default). */
|
|
17
|
+
step?: number;
|
|
18
|
+
name?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** The minus button's name for assistive technology ("Fewer"). */
|
|
21
|
+
decreaseLabel: string;
|
|
22
|
+
/** The plus button's name ("More"). */
|
|
23
|
+
increaseLabel: string;
|
|
24
|
+
/** Forces a state (for the design system). */
|
|
25
|
+
state?: BoxState;
|
|
26
|
+
id?: string;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/number-field/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAC;AAEjG,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CACjD,OAAO,EACP,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAChE;IACC,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kEAAkE;IAClE,aAAa,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/number-field/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SelectProperties } from "@sharadox/graphical-user-interface-web-library/select/type";
|
|
2
|
+
/**
|
|
3
|
+
* A select drawn by the interface, never the browser: a field box showing the choice, with a chevron section,
|
|
4
|
+
* opening a `Listbox` under it. It works as a native select does (the select-only combobox of the ARIA practices):
|
|
5
|
+
* the arrows, Home and End move, Enter, Space or Tab choose, Escape closes, a letter jumps to the next option
|
|
6
|
+
* starting with it (and chooses it while closed), and a click outside closes. With a `name`, the value goes in a
|
|
7
|
+
* hidden field for forms.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* <Select label="Month" name="month" placeholder="Choose a month" options={[{ value: "1", label: "January" }]} />
|
|
11
|
+
*/
|
|
12
|
+
export declare function Select(properties: SelectProperties): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/select/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAC;AAGnG;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,UAAU,EAAE,gBAAgB,+BAwIlD"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { Icon } from "@sharadox/icon-web-library/icon";
|
|
5
|
+
import { classNames } from "@sharadox/web-library/class-name";
|
|
6
|
+
import { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
7
|
+
import { Field } from "@sharadox/graphical-user-interface-web-library/field";
|
|
8
|
+
import { Listbox } from "@sharadox/graphical-user-interface-web-library/listbox";
|
|
9
|
+
import styles from "./index.module.css";
|
|
10
|
+
/**
|
|
11
|
+
* A select drawn by the interface, never the browser: a field box showing the choice, with a chevron section,
|
|
12
|
+
* opening a `Listbox` under it. It works as a native select does (the select-only combobox of the ARIA practices):
|
|
13
|
+
* the arrows, Home and End move, Enter, Space or Tab choose, Escape closes, a letter jumps to the next option
|
|
14
|
+
* starting with it (and chooses it while closed), and a click outside closes. With a `name`, the value goes in a
|
|
15
|
+
* hidden field for forms.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* <Select label="Month" name="month" placeholder="Choose a month" options={[{ value: "1", label: "January" }]} />
|
|
19
|
+
*/
|
|
20
|
+
export function Select(properties) {
|
|
21
|
+
const { label, hideLabel, hint, error, options, value, defaultValue, onChange, name, placeholder, disabled, state, id, className, color, ...look } = properties;
|
|
22
|
+
const [own, setOwn] = useState(defaultValue ?? "");
|
|
23
|
+
const chosen = value ?? own;
|
|
24
|
+
const [open, setOpen] = useState(false);
|
|
25
|
+
const [active, setActive] = useState(0);
|
|
26
|
+
const root = useRef(null);
|
|
27
|
+
const chosenIndex = options.findIndex((option) => option.value === chosen);
|
|
28
|
+
const choose = (index) => {
|
|
29
|
+
const option = options[index];
|
|
30
|
+
if (value === undefined)
|
|
31
|
+
setOwn(option.value);
|
|
32
|
+
onChange?.(option.value);
|
|
33
|
+
setOpen(false);
|
|
34
|
+
};
|
|
35
|
+
const show = () => {
|
|
36
|
+
setActive(Math.max(0, chosenIndex));
|
|
37
|
+
setOpen(true);
|
|
38
|
+
};
|
|
39
|
+
/** The next option after `from` whose label starts with `letter`, from the top again at the end. */
|
|
40
|
+
const startingWith = (letter, from) => {
|
|
41
|
+
for (let step = 1; step <= options.length; step++) {
|
|
42
|
+
const index = (from + step) % options.length;
|
|
43
|
+
if (options[index].label.toLowerCase().startsWith(letter))
|
|
44
|
+
return index;
|
|
45
|
+
}
|
|
46
|
+
return -1;
|
|
47
|
+
};
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!open)
|
|
50
|
+
return;
|
|
51
|
+
const outside = (event) => {
|
|
52
|
+
if (!root.current.contains(event.target))
|
|
53
|
+
setOpen(false);
|
|
54
|
+
};
|
|
55
|
+
document.addEventListener("pointerdown", outside);
|
|
56
|
+
return () => document.removeEventListener("pointerdown", outside);
|
|
57
|
+
}, [open]);
|
|
58
|
+
const keyDown = (event) => {
|
|
59
|
+
if (disabled)
|
|
60
|
+
return;
|
|
61
|
+
const { key } = event;
|
|
62
|
+
if (key.length === 1 && key !== " ") {
|
|
63
|
+
const index = startingWith(key.toLowerCase(), open ? active : chosenIndex);
|
|
64
|
+
if (index < 0)
|
|
65
|
+
return;
|
|
66
|
+
if (open)
|
|
67
|
+
setActive(index);
|
|
68
|
+
else
|
|
69
|
+
choose(index);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (!open) {
|
|
73
|
+
if (["ArrowDown", "ArrowUp", "Enter", " "].includes(key)) {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
show();
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const moves = {
|
|
80
|
+
ArrowDown: Math.min(options.length - 1, active + 1),
|
|
81
|
+
ArrowUp: Math.max(0, active - 1),
|
|
82
|
+
Home: 0,
|
|
83
|
+
End: options.length - 1,
|
|
84
|
+
};
|
|
85
|
+
if (key in moves) {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
setActive(moves[key]);
|
|
88
|
+
}
|
|
89
|
+
else if (key === "Enter" || key === " ") {
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
choose(active);
|
|
92
|
+
}
|
|
93
|
+
else if (key === "Tab")
|
|
94
|
+
choose(active);
|
|
95
|
+
else if (key === "Escape") {
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
setOpen(false);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return (_jsx(Field, { label: label, hideLabel: hideLabel, hint: hint, error: error, id: id, className: className, children: (control) => (_jsxs("div", { ref: root, className: styles.anchor, children: [name && _jsx("input", { type: "hidden", name: name, value: chosen }), _jsx(Box, { field: true, variant: "outlined", color: color ?? (error === undefined ? "middleground" : "error"), state: state ?? (disabled ? "disabled" : "enabled"), suffix: _jsx(Icon, { name: "chevron-down", className: classNames(styles.chevron, open && styles.open) }), ...look, className: styles.field, children: _jsx("button", { ...control, type: "button", role: "combobox", "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": `${control.id}-list`, "aria-activedescendant": open ? `${control.id}-list-${active}` : undefined, disabled: disabled, onClick: () => (open ? setOpen(false) : show()), onKeyDown: keyDown, className: styles.button, children: _jsx("span", { className: classNames(styles.value, chosenIndex < 0 && styles.placeholder), children: chosenIndex < 0 ? placeholder : options[chosenIndex].label }) }) }), open && (_jsx(Listbox, { id: `${control.id}-list`, labelledBy: `${control.id}-label`, options: options, chosen: chosen, active: active, onActive: setActive, onChoose: choose }))] })) }));
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/select/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,sDAAsD,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AAEjF,OAAO,MAAM,MAAM,qBAAqB,CAA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AAS,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,YAC7E,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAE,CAAC,KAAK,GACvD,GACA,GACL,EACL,IAAI,IAAI,CACP,KAAC,OAAO,IACN,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,EACxB,UAAU,EAAE,GAAG,OAAO,CAAC,EAAE,QAAQ,EACjC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,MAAM,GAChB,CACH,IACG,CACP,GACK,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.anchor){position:relative;display:flex;flex-direction:column}:where(.anchor)>.field{cursor:pointer}:where(.button){display:flex;align-items:center;inline-size:100%;min-block-size:var(--section-minimum-size);margin:0;padding:0;border:0;outline:0;background:none;color:inherit;font:inherit;text-align:start;cursor:inherit}:where(.field:not([data-variant=filled])) :where(.button){color:var(--current-hover-color)}:where(.placeholder){opacity:.6}:where(.chevron){transition:transform var(--duration) var(--easing)}:where(.open){transform:rotate(180deg)}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
:where(.anchor) {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// A select is pressed, not typed into: a pointer, with weight over the field box's text cursor.
|
|
8
|
+
:where(.anchor) > .field {
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:where(.button) {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
inline-size: 100%;
|
|
16
|
+
min-block-size: var(--section-minimum-size);
|
|
17
|
+
margin: 0;
|
|
18
|
+
padding: 0;
|
|
19
|
+
border: 0;
|
|
20
|
+
outline: 0;
|
|
21
|
+
background: none;
|
|
22
|
+
color: inherit;
|
|
23
|
+
font: inherit;
|
|
24
|
+
text-align: start;
|
|
25
|
+
cursor: inherit;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:where(.field:not([data-variant="filled"])) :where(.button) {
|
|
29
|
+
color: var(--current-hover-color);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:where(.placeholder) {
|
|
33
|
+
opacity: 0.6;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
:where(.chevron) {
|
|
37
|
+
transition: transform var(--duration) var(--easing);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
:where(.open) {
|
|
41
|
+
transform: rotate(180deg);
|
|
42
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { BoxLook, BoxState } from "@sharadox/graphical-user-interface-web-library/box/type";
|
|
3
|
+
import type { ListboxOption } from "@sharadox/graphical-user-interface-web-library/listbox/type";
|
|
4
|
+
export interface SelectProperties extends Pick<BoxLook, "variant" | "color" | "colorStyle" | "corner" | "line" | "size"> {
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
hideLabel?: boolean;
|
|
7
|
+
hint?: ReactNode;
|
|
8
|
+
error?: ReactNode;
|
|
9
|
+
options: readonly ListboxOption[];
|
|
10
|
+
/** Controlled: the chosen value. */
|
|
11
|
+
value?: string;
|
|
12
|
+
/** Uncontrolled: the value chosen at first. */
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
onChange?: (value: string) => void;
|
|
15
|
+
/** With a name, the value goes in a hidden field for forms. */
|
|
16
|
+
name?: string;
|
|
17
|
+
/** Shown while nothing is chosen. */
|
|
18
|
+
placeholder?: ReactNode;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** Forces a state (for the design system). */
|
|
21
|
+
state?: BoxState;
|
|
22
|
+
id?: string;
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/select/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAC;AACjG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6DAA6D,CAAC;AAEjG,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,OAAO,EACP,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAChE;IACC,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,SAAS,aAAa,EAAE,CAAC;IAClC,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/select/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SkeletonProperties } from "@sharadox/graphical-user-interface-web-library/skeleton/type";
|
|
2
|
+
/**
|
|
3
|
+
* Where data is still loading: soft shapes like what will come (lines, a card, a list of rows, a profile, a grid of
|
|
4
|
+
* cards), in the foreground's transparent color, gently shimmering, so a page shows at once and fills in. Screen
|
|
5
|
+
* readers hear `label` once.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <Suspense fallback={<Skeleton label="Loading devices…" shape="list" rows={3} />}><DeviceList /></Suspense>
|
|
9
|
+
*/
|
|
10
|
+
export declare function Skeleton({ label, shape, lines, rows, height }: SkeletonProperties): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/skeleton/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAuBvG;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAe,EAAE,KAAS,EAAE,IAAQ,EAAE,MAAM,EAAE,EAAE,kBAAkB,+BA6CnG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
const Line = ({ short }) => (_jsx("span", { "data-part": "line", className: classNames(styles.shape, styles.line, short && styles.short) }));
|
|
6
|
+
/** A card as the interface draws them: an outlined foreground box. */
|
|
7
|
+
const Card = ({ children, className }) => (_jsx(Box, { as: "span", "data-part": "card", variant: "outlined", color: "foreground", direction: "top-to-bottom", align: "stretch", gap: 12, padding: 24, className: classNames(styles.card, className), children: children }));
|
|
8
|
+
/**
|
|
9
|
+
* Where data is still loading: soft shapes like what will come (lines, a card, a list of rows, a profile, a grid of
|
|
10
|
+
* cards), in the foreground's transparent color, gently shimmering, so a page shows at once and fills in. Screen
|
|
11
|
+
* readers hear `label` once.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <Suspense fallback={<Skeleton label="Loading devices…" shape="list" rows={3} />}><DeviceList /></Suspense>
|
|
15
|
+
*/
|
|
16
|
+
export function Skeleton({ label, shape = "lines", lines = 3, rows = 3, height }) {
|
|
17
|
+
const text = Array.from({ length: lines }, (_, index) => (_jsx(Line, { short: index === lines - 1 && index > 0 }, index)));
|
|
18
|
+
return (_jsx("div", { className: styles.skeleton, role: "status", "aria-label": label, children: height ? (_jsx("span", { className: classNames(styles.shape, styles.block), style: { height } })) : shape === "lines" ? (text) : shape === "card" ? (_jsx(Card, { children: text })) : shape === "profile" ? (_jsxs(Card, { className: styles.profile, children: [_jsx("span", { "data-part": "circle", className: classNames(styles.shape, styles.circle) }), _jsxs("span", { className: styles.stack, children: [_jsx(Line, { short: true }), _jsx(Line, {})] })] })) : shape === "cards" ? (_jsx("span", { className: styles.grid, children: Array.from({ length: rows }, (_, index) => (_jsxs(Card, { children: [_jsx(Line, { short: true }), _jsx(Line, {})] }, index))) })) : (_jsx(Card, { children: Array.from({ length: rows }, (_, index) => (_jsxs("span", { "data-part": "row", className: styles.row, children: [_jsx("span", { className: classNames(styles.shape, styles.dot) }), _jsxs("span", { className: styles.stack, children: [_jsx(Line, {}), _jsx(Line, { short: true })] }), _jsx("span", { className: classNames(styles.shape, styles.button) })] }, index))) })) }));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/skeleton/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;A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,aAC3B,KAAC,IAAI,KAAG,EACR,KAAC,IAAI,IAAC,KAAK,SAAG,IACT,EACP,eAAM,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,GAAI,KANnD,KAAK,CAOT,CACR,CAAC,GACG,CACR,GACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.skeleton){display:flex;flex-direction:column;gap:var(--scale-12);inline-size:100%}:where(.shape){display:block;border-radius:var(--corner-radius);background:linear-gradient(90deg, transparent 0%, rgb(var(--foreground-color-rgb)/6%) 50%, transparent 100%) 0 0/200% 100% no-repeat,var(--foreground-transparent-color);animation:shimmer 1.6s linear infinite}:where(.line){block-size:.9em}:where(.short){inline-size:60%}:where(.block){inline-size:100%}.card{inline-size:100%}:where(.profile){flex-direction:row;align-items:center}:where(.circle){flex:none;inline-size:var(--scale-64);block-size:var(--scale-64);border-radius:10000px}:where(.stack){display:flex;flex:1;flex-direction:column;gap:var(--scale-8)}:where(.grid){display:grid;grid-template-columns:repeat(auto-fill, minmax(min(100%, 240px), 1fr));gap:var(--scale-16)}:where(.row){display:flex;align-items:center;gap:var(--scale-12)}:where(.dot){flex:none;inline-size:var(--scale-32);block-size:var(--scale-32)}:where(.button){flex:none;inline-size:var(--scale-64);block-size:var(--scale-32)}@keyframes shimmer{from{background-position:100% 0,0 0}to{background-position:-100% 0,0 0}}@media(prefers-reduced-motion: reduce){:where(.shape){animation:none}}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
:where(.skeleton) {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--scale-12);
|
|
5
|
+
inline-size: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Every shape: the foreground's transparent color with a light passing over it.
|
|
9
|
+
:where(.shape) {
|
|
10
|
+
display: block;
|
|
11
|
+
border-radius: var(--corner-radius);
|
|
12
|
+
background:
|
|
13
|
+
linear-gradient(90deg, transparent 0%, rgb(var(--foreground-color-rgb) / 6%) 50%, transparent 100%) 0 0 / 200% 100%
|
|
14
|
+
no-repeat,
|
|
15
|
+
var(--foreground-transparent-color);
|
|
16
|
+
animation: shimmer 1.6s linear infinite;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:where(.line) {
|
|
20
|
+
block-size: 0.9em;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:where(.short) {
|
|
24
|
+
inline-size: 60%;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:where(.block) {
|
|
28
|
+
inline-size: 100%;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.card {
|
|
32
|
+
inline-size: 100%;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
:where(.profile) {
|
|
36
|
+
flex-direction: row;
|
|
37
|
+
align-items: center;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
:where(.circle) {
|
|
41
|
+
flex: none;
|
|
42
|
+
inline-size: var(--scale-64);
|
|
43
|
+
block-size: var(--scale-64);
|
|
44
|
+
border-radius: 10000px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:where(.stack) {
|
|
48
|
+
display: flex;
|
|
49
|
+
flex: 1;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
gap: var(--scale-8);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:where(.grid) {
|
|
55
|
+
display: grid;
|
|
56
|
+
grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
|
|
57
|
+
gap: var(--scale-16);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
:where(.row) {
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
gap: var(--scale-12);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:where(.dot) {
|
|
67
|
+
flex: none;
|
|
68
|
+
inline-size: var(--scale-32);
|
|
69
|
+
block-size: var(--scale-32);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
:where(.button) {
|
|
73
|
+
flex: none;
|
|
74
|
+
inline-size: var(--scale-64);
|
|
75
|
+
block-size: var(--scale-32);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@keyframes shimmer {
|
|
79
|
+
from {
|
|
80
|
+
background-position:
|
|
81
|
+
100% 0,
|
|
82
|
+
0 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
to {
|
|
86
|
+
background-position:
|
|
87
|
+
-100% 0,
|
|
88
|
+
0 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@media (prefers-reduced-motion: reduce) {
|
|
93
|
+
:where(.shape) {
|
|
94
|
+
animation: none;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface SkeletonProperties {
|
|
2
|
+
/** What is loading, read aloud once ("Loading devices…"). */
|
|
3
|
+
label: string;
|
|
4
|
+
/**
|
|
5
|
+
* What it stands for: `lines` of text (the default), a `card` of lines, a `list` of rows (an icon, two lines and a
|
|
6
|
+
* button each), a `profile` (a picture and a name), or a grid of `cards`.
|
|
7
|
+
*/
|
|
8
|
+
shape?: "lines" | "card" | "list" | "profile" | "cards";
|
|
9
|
+
/** How many lines of text (3 by default). */
|
|
10
|
+
lines?: number;
|
|
11
|
+
/** How many rows or cards (3 by default). */
|
|
12
|
+
rows?: number;
|
|
13
|
+
/** A block (a picture, a card) instead of lines, this many pixels tall. */
|
|
14
|
+
height?: number;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/skeleton/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IACxD,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/skeleton/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SkeletonValueProperties } from "@sharadox/graphical-user-interface-web-library/skeleton-value/type";
|
|
2
|
+
/**
|
|
3
|
+
* A skeleton for one value, not a whole card: an inline shimmering shape as wide as the awaited text (a name, a
|
|
4
|
+
* count) or a circle (a picture), so everything around it (labels, buttons) shows at once.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <p>Devices: <Suspense fallback={<SkeletonValue width="2ch" label="Loading…" />}><DeviceCount /></Suspense></p>
|
|
8
|
+
*/
|
|
9
|
+
export declare function SkeletonValue({ label, width, circle }: SkeletonValueProperties): import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/skeleton-value/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oEAAoE,CAAC;AAGlH;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,KAAa,EAAE,MAAM,EAAE,EAAE,uBAAuB,+BAStF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { classNames } from "@sharadox/web-library/class-name";
|
|
3
|
+
import styles from "./index.module.css";
|
|
4
|
+
/**
|
|
5
|
+
* A skeleton for one value, not a whole card: an inline shimmering shape as wide as the awaited text (a name, a
|
|
6
|
+
* count) or a circle (a picture), so everything around it (labels, buttons) shows at once.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* <p>Devices: <Suspense fallback={<SkeletonValue width="2ch" label="Loading…" />}><DeviceCount /></Suspense></p>
|
|
10
|
+
*/
|
|
11
|
+
export function SkeletonValue({ label, width = "8ch", circle }) {
|
|
12
|
+
const size = circle ? { width: `${circle}px`, height: `${circle}px` } : { width };
|
|
13
|
+
return (_jsx("span", { className: classNames(styles.value, circle !== undefined && styles.circle), style: size, ...(label ? { role: "status", "aria-label": label } : { "aria-hidden": true }) }));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/skeleton-value/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE,MAAM,EAA2B;IACrF,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;IAClF,OAAO,CACL,eACE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,EAC1E,KAAK,EAAE,IAAI,KACP,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,GAC/E,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.value){display:inline-block;block-size:1em;vertical-align:middle;border-radius:var(--corner-radius);background:linear-gradient(90deg, transparent 0%, rgb(var(--foreground-color-rgb)/6%) 50%, transparent 100%) 0 0/200% 100% no-repeat,var(--foreground-transparent-color);animation:shimmer 1.6s linear infinite}:where(.circle){border-radius:10000px}@keyframes shimmer{from{background-position:100% 0,0 0}to{background-position:-100% 0,0 0}}@media(prefers-reduced-motion: reduce){:where(.value){animation:none}}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
:where(.value) {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
block-size: 1em;
|
|
4
|
+
vertical-align: middle;
|
|
5
|
+
border-radius: var(--corner-radius);
|
|
6
|
+
background:
|
|
7
|
+
linear-gradient(90deg, transparent 0%, rgb(var(--foreground-color-rgb) / 6%) 50%, transparent 100%) 0 0 / 200% 100%
|
|
8
|
+
no-repeat,
|
|
9
|
+
var(--foreground-transparent-color);
|
|
10
|
+
animation: shimmer 1.6s linear infinite;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:where(.circle) {
|
|
14
|
+
border-radius: 10000px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@keyframes shimmer {
|
|
18
|
+
from {
|
|
19
|
+
background-position:
|
|
20
|
+
100% 0,
|
|
21
|
+
0 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
to {
|
|
25
|
+
background-position:
|
|
26
|
+
-100% 0,
|
|
27
|
+
0 0;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@media (prefers-reduced-motion: reduce) {
|
|
32
|
+
:where(.value) {
|
|
33
|
+
animation: none;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface SkeletonValueProperties {
|
|
2
|
+
/** What is loading, read aloud ("Loading your name…"); without it the shape is silent (a parent says it). */
|
|
3
|
+
label?: string;
|
|
4
|
+
/** How wide the awaited text is, in any CSS length ("8ch" by default). */
|
|
5
|
+
width?: string;
|
|
6
|
+
/** A round shape this many pixels wide instead (a picture). */
|
|
7
|
+
circle?: number;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/skeleton-value/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,6GAA6G;IAC7G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/skeleton-value/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TipProperties } from "@sharadox/graphical-user-interface-web-library/tip/type";
|
|
2
|
+
/**
|
|
3
|
+
* A small question mark beside a label that shows a tip on hover, on keyboard focus, or on a tap (phones). Escape
|
|
4
|
+
* hides it. The button is described by the tip, so screen readers hear it too.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <label>Identifier <Tip label="What's this?" text="Like a username…" /></label>
|
|
8
|
+
*/
|
|
9
|
+
export declare function Tip({ text, label }: TipProperties): import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/tip/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yDAAyD,CAAC;AAG7F;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,aAAa,+BAqCjD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
|
+
import { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
5
|
+
import { Button } from "@sharadox/graphical-user-interface-web-library/button";
|
|
6
|
+
import styles from "./index.module.css";
|
|
7
|
+
/**
|
|
8
|
+
* A small question mark beside a label that shows a tip on hover, on keyboard focus, or on a tap (phones). Escape
|
|
9
|
+
* hides it. The button is described by the tip, so screen readers hear it too.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <label>Identifier <Tip label="What's this?" text="Like a username…" /></label>
|
|
13
|
+
*/
|
|
14
|
+
export function Tip({ text, label }) {
|
|
15
|
+
const [open, setOpen] = useState(false);
|
|
16
|
+
const id = useId();
|
|
17
|
+
return (_jsxs("span", { className: styles.tip, onMouseEnter: () => setOpen(true), onMouseLeave: () => setOpen(false), children: [_jsx(Button, { square: true, variant: "transparent", color: "middleground", size: "small", icon: "question", "aria-label": label, "aria-describedby": id, "aria-expanded": open, onClick: () => setOpen(!open), onFocus: () => setOpen(true), onBlur: () => setOpen(false), onKeyDown: (event) => {
|
|
18
|
+
if (event.key === "Escape")
|
|
19
|
+
setOpen(false);
|
|
20
|
+
} }), _jsx(Box, { as: "span", id: id, role: "tooltip", hidden: !open, variant: "filled", color: "foreground", size: "small", padding: 8, textAlign: "start", className: styles.bubble, children: text })] }));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/tip/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,uDAAuD,CAAC;AAE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0,0 +1 @@
|
|
|
1
|
+
:where(.tip){position:relative;display:inline-flex;vertical-align:middle}.bubble{position:absolute;z-index:30;inset-block-end:calc(100% + var(--scale-8));inset-inline-start:50%;inline-size:max-content;max-inline-size:240px;transform:translateX(-50%);font-weight:400;line-height:1.4;pointer-events:none}.bubble[hidden]{display:none}
|