@sharadox/graphical-user-interface-web-library 0.2.0-development.21 → 0.2.0-development.29
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 +8 -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/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/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/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
package/README.md
CHANGED
|
@@ -105,6 +105,14 @@ everything below it: on the page, in one part of it, or on one piece.
|
|
|
105
105
|
| `…/select` | `Select({ label, options, value?, defaultValue?, onChange?, name?, placeholder? })` | A select drawn by the interface, with a native select's keyboard |
|
|
106
106
|
| `…/combobox` | `Combobox({ label, options, … , empty? })`, `matches(label, typed)` | A text field that filters its options as you type |
|
|
107
107
|
| `…/number-field` | `NumberField({ label, value?, min?, max?, step?, decreaseLabel, increaseLabel })` | A number between a minus and a plus section |
|
|
108
|
+
| `…/dialog` | `Dialog({ open, onClose, title, closeLabel, children })` | A modal in the middle of the screen that leaves the way it came |
|
|
109
|
+
| `…/tip` | `Tip({ text, label })` | A question mark showing a tip on hover, focus or tap |
|
|
110
|
+
| `…/notification` | `NotificationProvider({ label, dismissLabel, duration? })`, `useNotification()` | Notifications at the top right, in their tone's color, hiding themselves |
|
|
111
|
+
| `…/skeleton` | `Skeleton({ label, shape?, lines?, rows?, height? })` | Shimmering shapes like what is loading |
|
|
112
|
+
| `…/skeleton-value` | `SkeletonValue({ label?, width?, circle? })` | A shimmering shape for one value |
|
|
113
|
+
| `…/copy-button` | `CopyButton({ value, label, copiedLabel, onCopied? })` | Copies a value and says so for two seconds |
|
|
114
|
+
| `…/code-boxes` | `CodeBoxes({ label, digitLabel, ofLabel, name?, length?, onComplete? })` | One field box per digit of a one-time code |
|
|
115
|
+
| `…/navigation` | `Navigation({ brand, label, links, actions?, menuLabel, closeLabel, collapse? })` | The sticky bar, and a phone menu below `collapse` (960) |
|
|
108
116
|
|
|
109
117
|
### Box
|
|
110
118
|
|
|
@@ -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" : "enabled", 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,EAAE,MAAM,EAAE,QAAQ,EAA2C,MAAM,OAAO,CAAC;AAClF,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AACzE,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAGzC;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,EACL,UAAU,EACV,OAAO,EACP,IAAI,EACJ,MAAM,GAAG,CAAC,EACV,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,SAAS,GACW;IACpB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAW,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACvF,MAAM,KAAK,GAAG,MAAM,C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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":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CopyButtonProperties } from "@sharadox/graphical-user-interface-web-library/copy-button/type";
|
|
2
|
+
/**
|
|
3
|
+
* Copies a value to the clipboard (a key, a set of recovery codes) and says so for two seconds, with a tick: an
|
|
4
|
+
* outlined middleground button.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <CopyButton value={secret} label="Copy" copiedLabel="Copied." />
|
|
8
|
+
*/
|
|
9
|
+
export declare function CopyButton({ value, label, copiedLabel, onCopied }: CopyButtonProperties): import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/copy-button/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iEAAiE,CAAC;AAE5G;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,oBAAoB,+BAsBvF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { Button } from "@sharadox/graphical-user-interface-web-library/button";
|
|
5
|
+
/**
|
|
6
|
+
* Copies a value to the clipboard (a key, a set of recovery codes) and says so for two seconds, with a tick: an
|
|
7
|
+
* outlined middleground button.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* <CopyButton value={secret} label="Copy" copiedLabel="Copied." />
|
|
11
|
+
*/
|
|
12
|
+
export function CopyButton({ value, label, copiedLabel, onCopied }) {
|
|
13
|
+
const [copied, setCopied] = useState(false);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!copied)
|
|
16
|
+
return;
|
|
17
|
+
const timer = setTimeout(() => setCopied(false), 2000);
|
|
18
|
+
return () => clearTimeout(timer);
|
|
19
|
+
}, [copied]);
|
|
20
|
+
return (_jsx(Button, { variant: "outlined", color: "middleground", size: "small", icon: copied ? "check" : "copy", onClick: async () => {
|
|
21
|
+
await navigator.clipboard.writeText(value);
|
|
22
|
+
setCopied(true);
|
|
23
|
+
onCopied?.();
|
|
24
|
+
}, children: _jsx("span", { "aria-live": "polite", children: copied ? copiedLabel : label }) }));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/copy-button/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,uDAAuD,CAAC;AAG/E;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAwB;IACtF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;QACvD,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACb,OAAO,CACL,KAAC,MAAM,IACL,OAAO,EAAC,UAAU,EAClB,KAAK,EAAC,cAAc,EACpB,IAAI,EAAC,OAAO,EACZ,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAC/B,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAC3C,SAAS,CAAC,IAAI,CAAC,CAAC;YAChB,QAAQ,EAAE,EAAE,CAAC;QACf,CAAC,YAED,4BAAgB,QAAQ,YAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,GAAQ,GACvD,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface CopyButtonProperties {
|
|
2
|
+
/** What is copied. */
|
|
3
|
+
value: string;
|
|
4
|
+
/** The button's words ("Copy", "Copy all"). */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Said for 2 seconds once copied ("Copied."). */
|
|
7
|
+
copiedLabel: string;
|
|
8
|
+
/** After copying (to show a notification). */
|
|
9
|
+
onCopied?: () => void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/copy-button/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/copy-button/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DialogProperties } from "@sharadox/graphical-user-interface-web-library/dialog/type";
|
|
2
|
+
/**
|
|
3
|
+
* A pop-up in the middle of the screen (the browser's own modal dialog: focus stays inside, the page behind is
|
|
4
|
+
* inert), named by its title, closed by Escape, its close button or a click on the backdrop. It leaves the way it
|
|
5
|
+
* came: the opening animation runs backwards before it closes, no longer modal meanwhile, so the page behind works
|
|
6
|
+
* at once.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* <Dialog open={asking} onClose={() => setAsking(false)} title="Check Your Email" closeLabel="Close">…</Dialog>
|
|
10
|
+
*/
|
|
11
|
+
export declare function Dialog({ open, onClose, title, closeLabel, children }: DialogProperties): import("react").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/dialog/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAC;AAMnG;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,gBAAgB,+BA8DtF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useRef, 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
|
+
/** The longest a leaving animation may take before the dialog closes anyway (reduced motion runs none). */
|
|
8
|
+
const LEAVING_MILLISECONDS = 300;
|
|
9
|
+
/**
|
|
10
|
+
* A pop-up in the middle of the screen (the browser's own modal dialog: focus stays inside, the page behind is
|
|
11
|
+
* inert), named by its title, closed by Escape, its close button or a click on the backdrop. It leaves the way it
|
|
12
|
+
* came: the opening animation runs backwards before it closes, no longer modal meanwhile, so the page behind works
|
|
13
|
+
* at once.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* <Dialog open={asking} onClose={() => setAsking(false)} title="Check Your Email" closeLabel="Close">…</Dialog>
|
|
17
|
+
*/
|
|
18
|
+
export function Dialog({ open, onClose, title, closeLabel, children }) {
|
|
19
|
+
const dialog = useRef(null);
|
|
20
|
+
const titleId = useId();
|
|
21
|
+
// Leaving: closed by the parent but still on screen while its animation runs backwards.
|
|
22
|
+
const [leaving, setLeaving] = useState(false);
|
|
23
|
+
const [wasOpen, setWasOpen] = useState(open);
|
|
24
|
+
if (open !== wasOpen) {
|
|
25
|
+
setWasOpen(open);
|
|
26
|
+
setLeaving(!open);
|
|
27
|
+
}
|
|
28
|
+
const finish = () => {
|
|
29
|
+
dialog.current.close();
|
|
30
|
+
setLeaving(false);
|
|
31
|
+
};
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const element = dialog.current;
|
|
34
|
+
if (open && !element.open)
|
|
35
|
+
element.showModal();
|
|
36
|
+
if (!leaving)
|
|
37
|
+
return;
|
|
38
|
+
// Leaving, it stops being modal at once, so the page behind works straight away; it stays on screen only for
|
|
39
|
+
// its animation.
|
|
40
|
+
element.close();
|
|
41
|
+
element.show();
|
|
42
|
+
const timer = setTimeout(finish, LEAVING_MILLISECONDS);
|
|
43
|
+
return () => clearTimeout(timer);
|
|
44
|
+
}, [open, leaving]);
|
|
45
|
+
return (_jsx("dialog", { ref: dialog, className: styles.dialog, "aria-labelledby": titleId, "data-closing": leaving ? "" : undefined, onAnimationEnd: (event) => {
|
|
46
|
+
if (event.target === dialog.current && leaving)
|
|
47
|
+
finish();
|
|
48
|
+
}, onCancel: (event) => {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
onClose();
|
|
51
|
+
}, onClick: (event) => {
|
|
52
|
+
if (event.target === dialog.current)
|
|
53
|
+
onClose();
|
|
54
|
+
}, children: (open || leaving) && (_jsxs(Box, { direction: "top-to-bottom", align: "stretch", textAlign: "start", gap: 16, padding: 24, children: [_jsxs(Box, { justify: "space-between", align: "start", gap: 16, children: [_jsx("h2", { id: titleId, className: styles.title, children: title }), _jsx(Button, { square: true, variant: "transparent", color: "middleground", icon: "close", "aria-label": closeLabel, onClick: onClose })] }), children] })) }));
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/dialog/index.tsx"],"names":[],"mappings":"A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OAAO,EAAE,OAAO,GAChB,IACE,EACL,QAAQ,IACL,CACP,GACM,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.dialog){position:fixed;inset:0;box-sizing:border-box;inline-size:min(440px,100vw - 2*var(--scale-16));block-size:fit-content;max-block-size:calc(100dvh - 2*var(--scale-16));margin:auto;padding:0;overflow:auto;border:var(--line-thickness) var(--line-style) var(--foreground-border-color);border-radius:var(--corner-radius);background:var(--background-color);box-shadow:0 var(--scale-24) var(--scale-64) rgba(0,0,0,.25);color:var(--foreground-color);font-family:var(--font-family);scrollbar-width:thin}:where(.dialog)::backdrop{background:rgba(0,0,0,.5);-webkit-backdrop-filter:blur(var(--scale-4));backdrop-filter:blur(var(--scale-4));animation:fade var(--duration) var(--easing)}:where(.dialog)[open]{animation:rise var(--duration) var(--easing)}:where(.dialog)[data-closing]{animation:rise var(--duration) var(--easing) reverse forwards}:where(.dialog)[data-closing]::backdrop{animation:fade var(--duration) var(--easing) reverse forwards}:where(.title){margin:0;font-size:var(--scale-24);font-weight:600;line-height:1.2}@keyframes rise{from{opacity:0;transform:translateY(var(--scale-16)) scale(0.98)}}@keyframes fade{from{opacity:0}}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Always in the middle of the screen, whatever a site resets margins and positions to.
|
|
2
|
+
:where(.dialog) {
|
|
3
|
+
position: fixed;
|
|
4
|
+
inset: 0;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
inline-size: min(440px, calc(100vw - 2 * var(--scale-16)));
|
|
7
|
+
block-size: fit-content;
|
|
8
|
+
max-block-size: calc(100dvh - 2 * var(--scale-16));
|
|
9
|
+
margin: auto;
|
|
10
|
+
padding: 0;
|
|
11
|
+
overflow: auto;
|
|
12
|
+
border: var(--line-thickness) var(--line-style) var(--foreground-border-color);
|
|
13
|
+
border-radius: var(--corner-radius);
|
|
14
|
+
background: var(--background-color);
|
|
15
|
+
box-shadow: 0 var(--scale-24) var(--scale-64) rgb(0 0 0 / 25%);
|
|
16
|
+
color: var(--foreground-color);
|
|
17
|
+
font-family: var(--font-family);
|
|
18
|
+
scrollbar-width: thin;
|
|
19
|
+
|
|
20
|
+
&::backdrop {
|
|
21
|
+
background: rgb(0 0 0 / 50%);
|
|
22
|
+
-webkit-backdrop-filter: blur(var(--scale-4));
|
|
23
|
+
backdrop-filter: blur(var(--scale-4));
|
|
24
|
+
animation: fade var(--duration) var(--easing);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&[open] {
|
|
28
|
+
animation: rise var(--duration) var(--easing);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Leaving: the same movement, backwards.
|
|
32
|
+
&[data-closing] {
|
|
33
|
+
animation: rise var(--duration) var(--easing) reverse forwards;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&[data-closing]::backdrop {
|
|
37
|
+
animation: fade var(--duration) var(--easing) reverse forwards;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:where(.title) {
|
|
42
|
+
margin: 0;
|
|
43
|
+
font-size: var(--scale-24);
|
|
44
|
+
font-weight: 600;
|
|
45
|
+
line-height: 1.2;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@keyframes rise {
|
|
49
|
+
from {
|
|
50
|
+
opacity: 0;
|
|
51
|
+
transform: translateY(var(--scale-16)) scale(0.98);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@keyframes fade {
|
|
56
|
+
from {
|
|
57
|
+
opacity: 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface DialogProperties {
|
|
3
|
+
open: boolean;
|
|
4
|
+
/** Escape, the close button or a click on the backdrop. */
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
title: string;
|
|
7
|
+
/** The close button's name ("Close"). */
|
|
8
|
+
closeLabel: string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/dialog/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,2DAA2D;IAC3D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/dialog/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NavigationProperties } from "@sharadox/graphical-user-interface-web-library/navigation/type";
|
|
2
|
+
/**
|
|
3
|
+
* The site's bar, sticky at the top: the brand at its start, the links, and the actions at its end. Below `collapse`
|
|
4
|
+
* pixels wide the links and actions move into a phone menu, opened by a button: it covers the page under the bar,
|
|
5
|
+
* scrolls when it doesn't fit (a phone held sideways), keeps the page behind still, and closes on Escape, on anything
|
|
6
|
+
* tapped in it, and when the screen widens (`@sharadox/menu-web-library`). Links are transparent buttons; the current
|
|
7
|
+
* page's is foreground and marked `aria-current`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* <Navigation brand={<Button href="/en" variant="inline">Name</Button>} label="Main" links={links} actions={<StyleSwitch … />} menuLabel="Open the menu" closeLabel="Close the menu" />
|
|
11
|
+
*/
|
|
12
|
+
export declare function Navigation(properties: NavigationProperties): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/navigation/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gEAAgE,CAAC;AAG3G;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,oBAAoB,+BA0E1D"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { classNames } from "@sharadox/web-library/class-name";
|
|
5
|
+
import { useMenu } from "@sharadox/menu-web-library/use-menu";
|
|
6
|
+
import { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
7
|
+
import { Button } from "@sharadox/graphical-user-interface-web-library/button";
|
|
8
|
+
import { Wrapper } from "@sharadox/graphical-user-interface-web-library/wrapper";
|
|
9
|
+
import styles from "./index.module.css";
|
|
10
|
+
/**
|
|
11
|
+
* The site's bar, sticky at the top: the brand at its start, the links, and the actions at its end. Below `collapse`
|
|
12
|
+
* pixels wide the links and actions move into a phone menu, opened by a button: it covers the page under the bar,
|
|
13
|
+
* scrolls when it doesn't fit (a phone held sideways), keeps the page behind still, and closes on Escape, on anything
|
|
14
|
+
* tapped in it, and when the screen widens (`@sharadox/menu-web-library`). Links are transparent buttons; the current
|
|
15
|
+
* page's is foreground and marked `aria-current`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* <Navigation brand={<Button href="/en" variant="inline">Name</Button>} label="Main" links={links} actions={<StyleSwitch … />} menuLabel="Open the menu" closeLabel="Close the menu" />
|
|
19
|
+
*/
|
|
20
|
+
export function Navigation(properties) {
|
|
21
|
+
const { brand, label, links, actions, menuLabel, closeLabel, collapse = 960, className } = properties;
|
|
22
|
+
const id = useId();
|
|
23
|
+
const menu = useMenu({ wide: `(min-width: ${collapse}px)`, id });
|
|
24
|
+
const list = (direction) => links.map((link) => (_jsx(Button, { href: link.href, variant: "transparent", color: link.current ? "foreground" : "middleground", size: direction === "top-to-bottom" ? "large" : undefined, "aria-current": link.current ? "page" : undefined, className: direction === "top-to-bottom" ? styles.menuLink : undefined, children: link.label }, link.href)));
|
|
25
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Wrapper, { as: "header", justify: "space-between", gap: 16, "data-collapse": collapse, className: classNames(styles.bar, className), ...menu.closer, children: [_jsx(Box, { justify: "start", className: styles.brand, children: brand }), _jsx(Box, { as: "nav", "aria-label": label, gap: 4, wrap: "wrap", className: styles.wide, children: list("left-to-right") }), actions !== undefined && (_jsx(Box, { gap: 8, wrap: "wrap", justify: "end", className: styles.wide, children: actions })), _jsx(Button, { ...menu.toggle, square: true, variant: "transparent", color: "foreground", icon: menu.open ? "close" : "menu", "aria-label": menu.open ? closeLabel : menuLabel, className: styles.toggle })] }), menu.open && (_jsxs(Box, { as: "nav", id: id, "aria-label": label, "data-lenis-prevent": "", direction: "top-to-bottom", align: "stretch", justify: "start", gap: 24, className: styles.menu, ...menu.closer, children: [_jsx(Box, { direction: "top-to-bottom", align: "stretch", gap: 4, children: list("top-to-bottom") }), actions !== undefined && (_jsx(Box, { "data-menu-actions": "", direction: "top-to-bottom", align: "start", gap: 12, children: actions }))] }))] }));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/navigation/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,uDAAuD,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,wD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,EAAC,GAAG,EAAE,EAAE,YACtE,OAAO,GACJ,CACP,IACG,CACP,IACA,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.bar{position:sticky;z-index:50;inset-block-start:0;min-block-size:var(--bar-height, 64px);padding-block:var(--scale-8);border-block-end:var(--line-thickness) var(--line-style) var(--foreground-border-color);background:rgb(var(--background-color-rgb)/80%);-webkit-backdrop-filter:blur(var(--glass-blur));backdrop-filter:blur(var(--glass-blur))}:where(.brand){flex:none}.menu{position:fixed;z-index:49;inset:var(--bar-height, 64px) 0 0;overflow-y:auto;padding:var(--scale-16) var(--wrapper-padding) var(--scale-32);background:var(--background-color);overscroll-behavior:contain;animation:open var(--duration) var(--easing)}.menuLink{justify-content:start}.toggle{display:none}@media(max-width: 639.98px){.bar[data-collapse="640"] .wide{display:none}.bar[data-collapse="640"] .toggle{display:inline-flex}}@media(max-width: 959.98px){.bar[data-collapse="960"] .wide{display:none}.bar[data-collapse="960"] .toggle{display:inline-flex}}@media(max-width: 1279.98px){.bar[data-collapse="1280"] .wide{display:none}.bar[data-collapse="1280"] .toggle{display:inline-flex}}@keyframes open{from{opacity:0;transform:translateY(calc(-1 * var(--scale-8)))}}@media(prefers-reduced-motion: reduce){.menu{animation:none}}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// The bar: sticky, see-through over the page (glass), a line under it. Plain classes, to beat the box's own values.
|
|
2
|
+
.bar {
|
|
3
|
+
position: sticky;
|
|
4
|
+
z-index: 50;
|
|
5
|
+
inset-block-start: 0;
|
|
6
|
+
min-block-size: var(--bar-height, 64px);
|
|
7
|
+
padding-block: var(--scale-8);
|
|
8
|
+
border-block-end: var(--line-thickness) var(--line-style) var(--foreground-border-color);
|
|
9
|
+
background: rgb(var(--background-color-rgb) / 80%);
|
|
10
|
+
-webkit-backdrop-filter: blur(var(--glass-blur));
|
|
11
|
+
backdrop-filter: blur(var(--glass-blur));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:where(.brand) {
|
|
15
|
+
flex: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// The phone menu: under the bar, over the whole page, scrolling when it doesn't fit.
|
|
19
|
+
.menu {
|
|
20
|
+
position: fixed;
|
|
21
|
+
z-index: 49;
|
|
22
|
+
inset: var(--bar-height, 64px) 0 0;
|
|
23
|
+
overflow-y: auto;
|
|
24
|
+
padding: var(--scale-16) var(--wrapper-padding) var(--scale-32);
|
|
25
|
+
background: var(--background-color);
|
|
26
|
+
overscroll-behavior: contain;
|
|
27
|
+
animation: open var(--duration) var(--easing);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.menuLink {
|
|
31
|
+
justify-content: start;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Wide: links and actions in the bar, no menu button. Narrow: only the brand and the menu button.
|
|
35
|
+
.toggle {
|
|
36
|
+
display: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@each $width in 640, 960, 1280 {
|
|
40
|
+
@media (max-width: #{$width - 0.02}px) {
|
|
41
|
+
.bar[data-collapse="#{$width}"] {
|
|
42
|
+
.wide {
|
|
43
|
+
display: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.toggle {
|
|
47
|
+
display: inline-flex;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@keyframes open {
|
|
54
|
+
from {
|
|
55
|
+
opacity: 0;
|
|
56
|
+
transform: translateY(calc(-1 * var(--scale-8)));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@media (prefers-reduced-motion: reduce) {
|
|
61
|
+
.menu {
|
|
62
|
+
animation: none;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/** A link of the main navigation. */
|
|
3
|
+
export interface NavigationLink {
|
|
4
|
+
href: string;
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
/** The page being shown: marked for assistive technology and drawn in foreground. */
|
|
7
|
+
current?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface NavigationProperties {
|
|
10
|
+
/** The name or logo, at the bar's start (a link home). */
|
|
11
|
+
brand: ReactNode;
|
|
12
|
+
/** The navigation's name for assistive technology ("Main"). */
|
|
13
|
+
label: string;
|
|
14
|
+
links: readonly NavigationLink[];
|
|
15
|
+
/** What sits at the bar's end (style switches, a profile picture, a call to action); in the menu on phones. */
|
|
16
|
+
actions?: ReactNode;
|
|
17
|
+
/** The menu button's names, closed and open ("Open the menu", "Close the menu"). */
|
|
18
|
+
menuLabel: string;
|
|
19
|
+
closeLabel: string;
|
|
20
|
+
/** The width below which the links and actions move into the menu: 640, 960 (the default) or 1280. */
|
|
21
|
+
collapse?: 640 | 960 | 1280;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/navigation/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,qCAAqC;AACrC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,qFAAqF;IACrF,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,KAAK,EAAE,SAAS,CAAC;IACjB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,+GAA+G;IAC/G,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,sGAAsG;IACtG,QAAQ,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/navigation/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NotificationContextValue, NotificationProviderProperties } from "@sharadox/graphical-user-interface-web-library/notification/type";
|
|
2
|
+
/**
|
|
3
|
+
* The notifications shown after each action, from anywhere under `NotificationProvider`.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const { notify } = useNotification();
|
|
7
|
+
* notify("Saved.");
|
|
8
|
+
*/
|
|
9
|
+
export declare function useNotification(): NotificationContextValue;
|
|
10
|
+
/**
|
|
11
|
+
* Shows a notification after every action, at the top right just below the site's bar: it goes after a few
|
|
12
|
+
* seconds, or when closed. Each is an outlined glass card in its tone's color (success, information, warn, error).
|
|
13
|
+
* At most four at once, newest last.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* <NotificationProvider label="Notifications" dismissLabel="Dismiss">{children}</NotificationProvider>
|
|
17
|
+
*/
|
|
18
|
+
export declare function NotificationProvider({ label, dismissLabel, duration, children, }: NotificationProviderProperties): import("react").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/notification/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,wBAAwB,EACxB,8BAA8B,EAC/B,MAAM,kEAAkE,CAAC;AAM1E;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,wBAAwB,CAE1D;AAgDD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,YAAY,EACZ,QAAe,EACf,QAAQ,GACT,EAAE,8BAA8B,+BA2BhC"}
|