@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComboboxProperties } from "@sharadox/graphical-user-interface-web-library/combobox/type";
|
|
2
|
+
/**
|
|
3
|
+
* Whether an option's words contain what was typed, ignoring case and accents.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* matches("Loulé", "loule"); // true
|
|
7
|
+
*/
|
|
8
|
+
export declare function matches(label: string, typed: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* A combobox: a text field that filters its options as you type (ignoring case and accents) and opens a `Listbox`
|
|
11
|
+
* of the ones that match. The arrows, Home and End move, Enter chooses, Escape closes and puts back the chosen
|
|
12
|
+
* option's words, and a click outside closes. With a `name`, the chosen value goes in a hidden field for forms.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* <Combobox label="City" name="city" options={cities} empty="No city found." />
|
|
16
|
+
*/
|
|
17
|
+
export declare function Combobox(properties: ComboboxProperties): import("react").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/combobox/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAUvG;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,kBAAkB,+BAqItD"}
|
|
@@ -0,0 +1,105 @@
|
|
|
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 { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
6
|
+
import { Field } from "@sharadox/graphical-user-interface-web-library/field";
|
|
7
|
+
import { Listbox } from "@sharadox/graphical-user-interface-web-library/listbox";
|
|
8
|
+
import styles from "./index.module.css";
|
|
9
|
+
/** Lower case without accents, so "Loulé" is found by "loule". */
|
|
10
|
+
const plain = (text) => text
|
|
11
|
+
.normalize("NFD")
|
|
12
|
+
.replace(/\p{Diacritic}/gu, "")
|
|
13
|
+
.toLowerCase();
|
|
14
|
+
/**
|
|
15
|
+
* Whether an option's words contain what was typed, ignoring case and accents.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* matches("Loulé", "loule"); // true
|
|
19
|
+
*/
|
|
20
|
+
export function matches(label, typed) {
|
|
21
|
+
return plain(label).includes(plain(typed));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A combobox: a text field that filters its options as you type (ignoring case and accents) and opens a `Listbox`
|
|
25
|
+
* of the ones that match. The arrows, Home and End move, Enter chooses, Escape closes and puts back the chosen
|
|
26
|
+
* option's words, and a click outside closes. With a `name`, the chosen value goes in a hidden field for forms.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* <Combobox label="City" name="city" options={cities} empty="No city found." />
|
|
30
|
+
*/
|
|
31
|
+
export function Combobox(properties) {
|
|
32
|
+
const { label, hideLabel, hint, error, options, value, defaultValue, onChange, name, placeholder, empty, disabled, state, id, className, color, ...look } = properties;
|
|
33
|
+
const [own, setOwn] = useState(defaultValue ?? "");
|
|
34
|
+
const chosen = value ?? own;
|
|
35
|
+
const words = (chosenValue) => options.find((option) => option.value === chosenValue)?.label ?? "";
|
|
36
|
+
const [typed, setTyped] = useState(() => words(chosen));
|
|
37
|
+
const [open, setOpen] = useState(false);
|
|
38
|
+
const [active, setActive] = useState(0);
|
|
39
|
+
const root = useRef(null);
|
|
40
|
+
// Until something new is typed, every option shows; then only those that match.
|
|
41
|
+
const shown = typed === words(chosen) ? options : options.filter((option) => matches(option.label, typed));
|
|
42
|
+
const show = () => {
|
|
43
|
+
if (disabled)
|
|
44
|
+
return;
|
|
45
|
+
setActive(0);
|
|
46
|
+
setOpen(true);
|
|
47
|
+
};
|
|
48
|
+
const close = () => {
|
|
49
|
+
setOpen(false);
|
|
50
|
+
setTyped(words(chosen));
|
|
51
|
+
};
|
|
52
|
+
const choose = (index) => {
|
|
53
|
+
const option = shown[index];
|
|
54
|
+
if (value === undefined)
|
|
55
|
+
setOwn(option.value);
|
|
56
|
+
onChange?.(option.value);
|
|
57
|
+
setTyped(option.label);
|
|
58
|
+
setOpen(false);
|
|
59
|
+
};
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!open)
|
|
62
|
+
return;
|
|
63
|
+
const outside = (event) => {
|
|
64
|
+
if (!root.current.contains(event.target))
|
|
65
|
+
close();
|
|
66
|
+
};
|
|
67
|
+
document.addEventListener("pointerdown", outside);
|
|
68
|
+
return () => document.removeEventListener("pointerdown", outside);
|
|
69
|
+
});
|
|
70
|
+
const keyDown = (event) => {
|
|
71
|
+
const { key } = event;
|
|
72
|
+
if (!open) {
|
|
73
|
+
if (key === "ArrowDown" || key === "ArrowUp") {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
show();
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const moves = {
|
|
80
|
+
ArrowDown: Math.min(shown.length - 1, active + 1),
|
|
81
|
+
ArrowUp: Math.max(0, active - 1),
|
|
82
|
+
Home: 0,
|
|
83
|
+
End: shown.length - 1,
|
|
84
|
+
};
|
|
85
|
+
if (key in moves) {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
setActive(moves[key]);
|
|
88
|
+
}
|
|
89
|
+
else if (key === "Enter") {
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
if (shown.length > 0)
|
|
92
|
+
choose(active);
|
|
93
|
+
}
|
|
94
|
+
else if (key === "Escape") {
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
close();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
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" : "none"), suffix: _jsx(Icon, { name: "chevron-down" }), ...look, children: _jsx("input", { ...control, type: "text", role: "combobox", autoComplete: "off", "aria-autocomplete": "list", "aria-expanded": open, "aria-controls": `${control.id}-list`, "aria-activedescendant": open && shown.length > 0 ? `${control.id}-list-${active}` : undefined, placeholder: placeholder, value: typed, disabled: disabled, onFocus: show, onChange: (event) => {
|
|
100
|
+
setTyped(event.target.value);
|
|
101
|
+
setActive(0);
|
|
102
|
+
setOpen(true);
|
|
103
|
+
}, onKeyDown: keyDown, className: styles.input }) }), open && (_jsx(Listbox, { id: `${control.id}-list`, labelledBy: `${control.id}-label`, options: shown, chosen: chosen, active: active, onActive: setActive, onChoose: choose, empty: empty }))] })) }));
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/combobox/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,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,CAAC;AAEzC,kEAAkE;AAClE,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAC7B,IAAI;KACD,SAAS,CAAC,KAAK,CAAC;KAChB,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;KAC9B,WAAW,EAAE,CAAC;AAEnB;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,KAAa;IAClD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,UAA8B;IACrD,MAAM,EACJ,KAAK,EACL,SAAS,EACT,IAAI,EACJ,KAAK,EACL,OAAO,EACP,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,KAAK,EACL,QAAQ,EACR,KA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C,IAAI,IAAC,IAAI,EAAC,cAAc,GAAG,KAChC,IAAI,YAER,mBACM,OAAO,EACX,IAAI,EAAC,MAAM,EACX,IAAI,EAAC,UAAU,EACf,YAAY,EAAC,KAAK,uBACA,MAAM,mBACT,IAAI,mBACJ,GAAG,OAAO,CAAC,EAAE,OAAO,2BACZ,IAAI,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,EAC5F,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,IAAI,EACb,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;4BAClB,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;4BAC7B,SAAS,CAAC,CAAC,CAAC,CAAC;4BACb,OAAO,CAAC,IAAI,CAAC,CAAC;wBAChB,CAAC,EACD,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,MAAM,CAAC,KAAK,GACvB,GACE,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,KAAK,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,KAAK,GACZ,CACH,IACG,CACP,GACK,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.anchor){position:relative;display:flex;flex-direction:column}:where(.input){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:inherit;font:inherit;text-align:start}:where(.input)::placeholder{color:inherit;opacity:.6}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
:where(.anchor) {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
:where(.input) {
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
inline-size: 100%;
|
|
10
|
+
min-inline-size: 0;
|
|
11
|
+
min-block-size: var(--section-minimum-size);
|
|
12
|
+
margin: 0;
|
|
13
|
+
padding: 0;
|
|
14
|
+
border: 0;
|
|
15
|
+
outline: 0;
|
|
16
|
+
background: transparent;
|
|
17
|
+
color: inherit;
|
|
18
|
+
font: inherit;
|
|
19
|
+
text-align: start;
|
|
20
|
+
|
|
21
|
+
&::placeholder {
|
|
22
|
+
color: inherit;
|
|
23
|
+
opacity: 0.6;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SelectProperties } from "@sharadox/graphical-user-interface-web-library/select/type";
|
|
2
|
+
export interface ComboboxProperties extends Omit<SelectProperties, "placeholder"> {
|
|
3
|
+
/** Shown in the empty input. */
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
/** Shown in the list when nothing matches what was typed. */
|
|
6
|
+
empty?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/combobox/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAC;AAEnG,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,aAAa,CAAC;IAC/E,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/combobox/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,35 @@
|
|
|
1
|
+
import type { DatePickerProperties, Day } from "@sharadox/graphical-user-interface-web-library/date-picker/type";
|
|
2
|
+
/**
|
|
3
|
+
* A day written as `yyyy-mm-dd`.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* formatDay({ year: 2026, month: 1, day: 28 }); // "2026-02-28"
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatDay({ year, month, day }: Day): string;
|
|
9
|
+
/**
|
|
10
|
+
* A `yyyy-mm-dd` day, or `undefined` when it isn't one (a 13th month, a 30th of February).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* parseDay("2026-02-28"); // { year: 2026, month: 1, day: 28 }
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseDay(text: string | undefined): Day | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* A month's calendar: whole weeks (starting on `weekStart`, 1 for Monday or 0 for Sunday) as `yyyy-mm-dd` days,
|
|
18
|
+
* with the days of the months before and after that fill them.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* monthDays(2026, 1, 1)[0]; // ["2026-01-26", …, "2026-02-01"]
|
|
22
|
+
*/
|
|
23
|
+
export declare function monthDays(year: number, month: number, weekStart: 0 | 1): string[][];
|
|
24
|
+
/**
|
|
25
|
+
* A date picker: a field box showing the chosen day in the page's language, with a calendar section, opening a
|
|
26
|
+
* calendar under it. The calendar's grid follows the ARIA date picker pattern: the arrows move by day and week,
|
|
27
|
+
* Home and End to the week's start and end, Page Up and Page Down by month, Enter chooses, Escape closes; the month
|
|
28
|
+
* buttons change month; days outside `min` and `max` can't be chosen; a press outside closes. Days are `yyyy-mm-dd`,
|
|
29
|
+
* free of time zones, and with a `name` the day goes in a hidden field for forms.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* <DatePicker label="Visit" name="visit" locale="pt-PT" min={today} previousLabel="Mês anterior" nextLabel="Mês seguinte" />
|
|
33
|
+
*/
|
|
34
|
+
export declare function DatePicker(properties: DatePickerProperties): import("react").JSX.Element;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/date-picker/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,MAAM,iEAAiE,CAAC;AAKjH;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,GAAG,GAAG,MAAM,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,GAAG,SAAS,CAMlE;AAiBD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,EAAE,EAAE,CAQnF;AAQD;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,oBAAoB,+BA0N1D"}
|
|
@@ -0,0 +1,161 @@
|
|
|
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 { Button } from "@sharadox/graphical-user-interface-web-library/button";
|
|
8
|
+
import { Field } from "@sharadox/graphical-user-interface-web-library/field";
|
|
9
|
+
import styles from "./index.module.css";
|
|
10
|
+
const pad = (number, length = 2) => String(number).padStart(length, "0");
|
|
11
|
+
/**
|
|
12
|
+
* A day written as `yyyy-mm-dd`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* formatDay({ year: 2026, month: 1, day: 28 }); // "2026-02-28"
|
|
16
|
+
*/
|
|
17
|
+
export function formatDay({ year, month, day }) {
|
|
18
|
+
return `${pad(year, 4)}-${pad(month + 1)}-${pad(day)}`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A `yyyy-mm-dd` day, or `undefined` when it isn't one (a 13th month, a 30th of February).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* parseDay("2026-02-28"); // { year: 2026, month: 1, day: 28 }
|
|
25
|
+
*/
|
|
26
|
+
export function parseDay(text) {
|
|
27
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text ?? "");
|
|
28
|
+
if (!match)
|
|
29
|
+
return undefined;
|
|
30
|
+
const [year, month, day] = [Number(match[1]), Number(match[2]) - 1, Number(match[3])];
|
|
31
|
+
const date = new Date(Date.UTC(year, month, day));
|
|
32
|
+
return date.getUTCMonth() === month && date.getUTCDate() === day ? { year, month, day } : undefined;
|
|
33
|
+
}
|
|
34
|
+
/** The day `days` after a day (before, when negative). */
|
|
35
|
+
const addDays = (text, days) => {
|
|
36
|
+
const { year, month, day } = parseDay(text);
|
|
37
|
+
const date = new Date(Date.UTC(year, month, day + days));
|
|
38
|
+
return formatDay({ year: date.getUTCFullYear(), month: date.getUTCMonth(), day: date.getUTCDate() });
|
|
39
|
+
};
|
|
40
|
+
/** The same day `months` later (the month's last day when it has fewer). */
|
|
41
|
+
const addMonths = (text, months) => {
|
|
42
|
+
const { year, month, day } = parseDay(text);
|
|
43
|
+
const last = new Date(Date.UTC(year, month + months + 1, 0)).getUTCDate();
|
|
44
|
+
const date = new Date(Date.UTC(year, month + months, Math.min(day, last)));
|
|
45
|
+
return formatDay({ year: date.getUTCFullYear(), month: date.getUTCMonth(), day: date.getUTCDate() });
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A month's calendar: whole weeks (starting on `weekStart`, 1 for Monday or 0 for Sunday) as `yyyy-mm-dd` days,
|
|
49
|
+
* with the days of the months before and after that fill them.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* monthDays(2026, 1, 1)[0]; // ["2026-01-26", …, "2026-02-01"]
|
|
53
|
+
*/
|
|
54
|
+
export function monthDays(year, month, weekStart) {
|
|
55
|
+
const first = formatDay({ year, month, day: 1 });
|
|
56
|
+
const lead = (new Date(Date.UTC(year, month, 1)).getUTCDay() - weekStart + 7) % 7;
|
|
57
|
+
const length = new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
|
58
|
+
const weeks = Math.ceil((lead + length) / 7);
|
|
59
|
+
return Array.from({ length: weeks }, (_, week) => Array.from({ length: 7 }, (_, weekday) => addDays(first, week * 7 + weekday - lead)));
|
|
60
|
+
}
|
|
61
|
+
/** Today on this device, as `yyyy-mm-dd`. */
|
|
62
|
+
const deviceToday = () => {
|
|
63
|
+
const now = new Date();
|
|
64
|
+
return formatDay({ year: now.getFullYear(), month: now.getMonth(), day: now.getDate() });
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* A date picker: a field box showing the chosen day in the page's language, with a calendar section, opening a
|
|
68
|
+
* calendar under it. The calendar's grid follows the ARIA date picker pattern: the arrows move by day and week,
|
|
69
|
+
* Home and End to the week's start and end, Page Up and Page Down by month, Enter chooses, Escape closes; the month
|
|
70
|
+
* buttons change month; days outside `min` and `max` can't be chosen; a press outside closes. Days are `yyyy-mm-dd`,
|
|
71
|
+
* free of time zones, and with a `name` the day goes in a hidden field for forms.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* <DatePicker label="Visit" name="visit" locale="pt-PT" min={today} previousLabel="Mês anterior" nextLabel="Mês seguinte" />
|
|
75
|
+
*/
|
|
76
|
+
export function DatePicker(properties) {
|
|
77
|
+
const { label, hideLabel, hint, error, value, defaultValue, onChange, name, min, max, locale = "en", weekStart = 1, today = deviceToday(), placeholder, previousLabel, nextLabel, disabled, state, id, className, color, variant = "outlined", ...look } = properties;
|
|
78
|
+
const [own, setOwn] = useState(defaultValue ?? "");
|
|
79
|
+
const chosen = value ?? own;
|
|
80
|
+
const [open, setOpen] = useState(false);
|
|
81
|
+
const [focused, setFocused] = useState(chosen || today);
|
|
82
|
+
const root = useRef(null);
|
|
83
|
+
const field = useRef(null);
|
|
84
|
+
const write = (text, options) => {
|
|
85
|
+
const { year, month, day } = parseDay(text);
|
|
86
|
+
return new Intl.DateTimeFormat(locale, { ...options, timeZone: "UTC" }).format(new Date(Date.UTC(year, month, day)));
|
|
87
|
+
};
|
|
88
|
+
const allowed = (day) => (min === undefined || day >= min) && (max === undefined || day <= max);
|
|
89
|
+
const view = parseDay(focused);
|
|
90
|
+
const monthStart = formatDay({ ...view, day: 1 });
|
|
91
|
+
const weeks = monthDays(view.year, view.month, weekStart);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (!open)
|
|
94
|
+
return;
|
|
95
|
+
root.current?.querySelector(`[data-day="${focused}"]`)?.focus();
|
|
96
|
+
}, [open, focused]);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (!open)
|
|
99
|
+
return;
|
|
100
|
+
const outside = (event) => {
|
|
101
|
+
if (!root.current.contains(event.target))
|
|
102
|
+
setOpen(false);
|
|
103
|
+
};
|
|
104
|
+
document.addEventListener("pointerdown", outside);
|
|
105
|
+
return () => document.removeEventListener("pointerdown", outside);
|
|
106
|
+
}, [open]);
|
|
107
|
+
const show = () => {
|
|
108
|
+
setFocused(chosen || today);
|
|
109
|
+
setOpen(true);
|
|
110
|
+
};
|
|
111
|
+
const choose = (day) => {
|
|
112
|
+
if (!allowed(day))
|
|
113
|
+
return;
|
|
114
|
+
if (value === undefined)
|
|
115
|
+
setOwn(day);
|
|
116
|
+
onChange?.(day);
|
|
117
|
+
setOpen(false);
|
|
118
|
+
field.current?.focus();
|
|
119
|
+
};
|
|
120
|
+
const keyDown = (event) => {
|
|
121
|
+
const weekday = (new Date(Date.UTC(view.year, view.month, view.day)).getUTCDay() - weekStart + 7) % 7;
|
|
122
|
+
const moves = {
|
|
123
|
+
ArrowRight: () => addDays(focused, 1),
|
|
124
|
+
ArrowLeft: () => addDays(focused, -1),
|
|
125
|
+
ArrowDown: () => addDays(focused, 7),
|
|
126
|
+
ArrowUp: () => addDays(focused, -7),
|
|
127
|
+
Home: () => addDays(focused, -weekday),
|
|
128
|
+
End: () => addDays(focused, 6 - weekday),
|
|
129
|
+
PageDown: () => addMonths(focused, 1),
|
|
130
|
+
PageUp: () => addMonths(focused, -1),
|
|
131
|
+
};
|
|
132
|
+
if (event.key in moves) {
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
setFocused(moves[event.key]());
|
|
135
|
+
}
|
|
136
|
+
else if (event.key === "Enter") {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
choose(focused);
|
|
139
|
+
}
|
|
140
|
+
else if (event.key === "Escape") {
|
|
141
|
+
event.preventDefault();
|
|
142
|
+
setOpen(false);
|
|
143
|
+
field.current?.focus();
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const previousMonth = addMonths(monthStart, -1);
|
|
147
|
+
const nextMonth = addMonths(monthStart, 1);
|
|
148
|
+
const lastOfMonth = (start) => addDays(addMonths(start, 1), -1);
|
|
149
|
+
const weekdays = weeks[0].map((day) => ({
|
|
150
|
+
short: write(day, { weekday: "short" }).replace(/\.$/, "").slice(0, 2),
|
|
151
|
+
long: write(day, { weekday: "long" }),
|
|
152
|
+
}));
|
|
153
|
+
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: variant, color: color ?? (error === undefined ? "middleground" : "error"), state: state ?? (disabled ? "disabled" : "none"), suffix: _jsx(Icon, { name: "calendar" }), ...look, className: styles.field, children: _jsx("button", { ...control, ref: field, type: "button", "aria-haspopup": "dialog", "aria-expanded": open, disabled: disabled, onClick: () => (open ? setOpen(false) : show()), className: styles.button, children: _jsx("span", { className: classNames(!chosen && styles.placeholder), children: chosen ? write(chosen, { dateStyle: "long" }) : placeholder }) }) }), open && (_jsxs(Box, { role: "dialog", "aria-labelledby": `${control.id}-label`, variant: "outlined", color: "foreground", direction: "top-to-bottom", align: "stretch", gap: 8, padding: 12, className: styles.calendar, children: [_jsxs(Box, { justify: "space-between", gap: 8, children: [_jsx(Button, { square: true, variant: "transparent", color: "middleground", icon: "chevron-left", "aria-label": previousLabel, disabled: min !== undefined && lastOfMonth(previousMonth) < min, onClick: () => setFocused(addMonths(focused, -1)) }), _jsx("span", { "aria-live": "polite", className: styles.month, children: write(monthStart, { month: "long", year: "numeric" }) }), _jsx(Button, { square: true, variant: "transparent", color: "middleground", icon: "chevron-right", "aria-label": nextLabel, disabled: max !== undefined && nextMonth > max, onClick: () => setFocused(addMonths(focused, 1)) })] }), _jsxs("table", { role: "grid", className: styles.grid, children: [_jsx("thead", { children: _jsx("tr", { children: weekdays.map((weekday) => (_jsx("th", { role: "columnheader", abbr: weekday.long, className: styles.weekday, children: weekday.short }, weekday.long))) }) }), _jsx("tbody", { children: weeks.map((week) => (_jsx("tr", { children: week.map((day) => (_jsx("td", { role: "gridcell", "aria-selected": day === chosen, ...(parseDay(day).month !== view.month && { "data-outside": "" }), className: styles.cell, children: _jsx(Button, { "data-day": day, square: true, variant: day === chosen ? "filled" : "transparent", color: day === chosen
|
|
154
|
+
? "brand"
|
|
155
|
+
: parseDay(day).month === view.month
|
|
156
|
+
? "foreground"
|
|
157
|
+
: "middleground", tabIndex: day === focused ? 0 : -1, "aria-label": write(day, { dateStyle: "full" }), "aria-current": day === today ? "date" : undefined,
|
|
158
|
+
// Disabled but still focusable, so the arrow keys can pass over it.
|
|
159
|
+
state: allowed(day) ? undefined : "disabled", onClick: () => choose(day), onKeyDown: keyDown, className: styles.day, children: parseDay(day).day }) }, day))) }, week[0]))) })] })] }))] })) }));
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/date-picker/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,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,GAAG,CAAC,EAC1B,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,MAAM,CAAC,GAAG,YAEpB,QAAQ,CAAC,GAAG,CAAE,CAAC,GAAG,GACZ,IA3BJ,GAAG,CA4BL,CACN,CAAC,IAhCK,IAAI,CAAC,CAAC,CAAC,CAiCX,CACN,CAAC,GACI,IACF,IACJ,CACP,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}.calendar{position:absolute;z-index:20;inset-block-start:calc(100% + var(--scale-4));inset-inline-start:0;inline-size:max-content;background:rgb(var(--background-color-rgb)/90%)}:where(.month){font-weight:600;text-transform:capitalize}:where(.grid){border-collapse:collapse}:where(.weekday){padding-block:var(--scale-4);color:var(--middleground-color);font-size:var(--scale-12);font-weight:500}:where(.cell){padding:1px;text-align:center}:where(.day[aria-current=date]){text-decoration:underline;text-underline-offset:.25em}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
:where(.anchor) {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
:where(.anchor) > .field {
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
:where(.button) {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
inline-size: 100%;
|
|
15
|
+
min-block-size: var(--section-minimum-size);
|
|
16
|
+
margin: 0;
|
|
17
|
+
padding: 0;
|
|
18
|
+
border: 0;
|
|
19
|
+
outline: 0;
|
|
20
|
+
background: none;
|
|
21
|
+
color: inherit;
|
|
22
|
+
font: inherit;
|
|
23
|
+
text-align: start;
|
|
24
|
+
cursor: inherit;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:where(.field:not([data-variant="filled"])) :where(.button) {
|
|
28
|
+
color: var(--current-hover-color);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:where(.placeholder) {
|
|
32
|
+
opacity: 0.6;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Under the field, above what follows; nearly opaque behind the glass.
|
|
36
|
+
.calendar {
|
|
37
|
+
position: absolute;
|
|
38
|
+
z-index: 20;
|
|
39
|
+
inset-block-start: calc(100% + var(--scale-4));
|
|
40
|
+
inset-inline-start: 0;
|
|
41
|
+
inline-size: max-content;
|
|
42
|
+
background: rgb(var(--background-color-rgb) / 90%);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:where(.month) {
|
|
46
|
+
font-weight: 600;
|
|
47
|
+
text-transform: capitalize;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
:where(.grid) {
|
|
51
|
+
border-collapse: collapse;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:where(.weekday) {
|
|
55
|
+
padding-block: var(--scale-4);
|
|
56
|
+
color: var(--middleground-color);
|
|
57
|
+
font-size: var(--scale-12);
|
|
58
|
+
font-weight: 500;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
:where(.cell) {
|
|
62
|
+
padding: 1px;
|
|
63
|
+
text-align: center;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Today is underlined, so it is found at a glance.
|
|
67
|
+
:where(.day[aria-current="date"]) {
|
|
68
|
+
text-decoration: underline;
|
|
69
|
+
text-underline-offset: 0.25em;
|
|
70
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { BoxLook, BoxState } from "@sharadox/graphical-user-interface-web-library/box/type";
|
|
3
|
+
/** A calendar day, without time or time zone; `month` counts from 0. */
|
|
4
|
+
export interface Day {
|
|
5
|
+
year: number;
|
|
6
|
+
month: number;
|
|
7
|
+
day: number;
|
|
8
|
+
}
|
|
9
|
+
export interface DatePickerProperties extends Pick<BoxLook, "variant" | "color" | "colorStyle" | "corner" | "line" | "size"> {
|
|
10
|
+
label: ReactNode;
|
|
11
|
+
hideLabel?: boolean;
|
|
12
|
+
hint?: ReactNode;
|
|
13
|
+
error?: ReactNode;
|
|
14
|
+
/** Controlled: the day as `yyyy-mm-dd` (empty for none). */
|
|
15
|
+
value?: string;
|
|
16
|
+
/** Uncontrolled: the day at first. */
|
|
17
|
+
defaultValue?: string;
|
|
18
|
+
onChange?: (value: string) => void;
|
|
19
|
+
/** With a name, the day goes in a hidden field for forms (`yyyy-mm-dd`). */
|
|
20
|
+
name?: string;
|
|
21
|
+
/** The first and last days that can be chosen (`yyyy-mm-dd`). */
|
|
22
|
+
min?: string;
|
|
23
|
+
max?: string;
|
|
24
|
+
/** The language days, months and weekdays are written in (`en`, `pt-PT`…); `en` by default. */
|
|
25
|
+
locale?: string;
|
|
26
|
+
/** The weekday weeks start on: 1 (Monday, the default) or 0 (Sunday). */
|
|
27
|
+
weekStart?: 0 | 1;
|
|
28
|
+
/** Today (`yyyy-mm-dd`), where the calendar opens when no day is chosen; the device's today by default. */
|
|
29
|
+
today?: string;
|
|
30
|
+
/** Shown while no day is chosen. */
|
|
31
|
+
placeholder?: ReactNode;
|
|
32
|
+
/** The month buttons' names ("Previous month", "Next month"). */
|
|
33
|
+
previousLabel: string;
|
|
34
|
+
nextLabel: string;
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
/** Forces a state (for the design system). */
|
|
37
|
+
state?: BoxState;
|
|
38
|
+
id?: string;
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/date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ACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/date-picker/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
|