@sharadox/graphical-user-interface-web-library 0.1.0 → 0.2.0-development.16
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 +28 -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.map +1 -1
- package/distribution/box/index.js +5 -2
- package/distribution/box/index.js.map +1 -1
- package/distribution/box/index.module.css +1 -1
- package/distribution/box/index.module.scss +28 -0
- package/distribution/box/type.d.ts +5 -0
- package/distribution/box/type.d.ts.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/checkbox/index.d.ts +10 -0
- package/distribution/checkbox/index.d.ts.map +1 -0
- package/distribution/checkbox/index.js +21 -0
- package/distribution/checkbox/index.js.map +1 -0
- package/distribution/checkbox/type.d.ts +9 -0
- package/distribution/checkbox/type.d.ts.map +1 -0
- package/distribution/checkbox/type.js +2 -0
- package/distribution/checkbox/type.js.map +1 -0
- package/distribution/field/index.d.ts +11 -0
- package/distribution/field/index.d.ts.map +1 -0
- package/distribution/field/index.js +26 -0
- package/distribution/field/index.js.map +1 -0
- package/distribution/field/index.module.css +1 -0
- package/distribution/field/index.module.scss +21 -0
- package/distribution/field/type.d.ts +23 -0
- package/distribution/field/type.d.ts.map +1 -0
- package/distribution/field/type.js +2 -0
- package/distribution/field/type.js.map +1 -0
- package/distribution/radio-group/index.d.ts +11 -0
- package/distribution/radio-group/index.d.ts.map +1 -0
- package/distribution/radio-group/index.js +27 -0
- package/distribution/radio-group/index.js.map +1 -0
- package/distribution/radio-group/index.module.css +1 -0
- package/distribution/radio-group/index.module.scss +10 -0
- package/distribution/radio-group/type.d.ts +25 -0
- package/distribution/radio-group/type.d.ts.map +1 -0
- package/distribution/radio-group/type.js +2 -0
- package/distribution/radio-group/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/switch/index.d.ts +11 -0
- package/distribution/switch/index.d.ts.map +1 -0
- package/distribution/switch/index.js +44 -0
- package/distribution/switch/index.js.map +1 -0
- package/distribution/switch/index.module.css +1 -0
- package/distribution/switch/index.module.scss +70 -0
- package/distribution/switch/type.d.ts +20 -0
- package/distribution/switch/type.d.ts.map +1 -0
- package/distribution/switch/type.js +2 -0
- package/distribution/switch/type.js.map +1 -0
- package/distribution/text-field/index.d.ts +13 -0
- package/distribution/text-field/index.d.ts.map +1 -0
- package/distribution/text-field/index.js +21 -0
- package/distribution/text-field/index.js.map +1 -0
- package/distribution/text-field/index.module.css +1 -0
- package/distribution/text-field/index.module.scss +42 -0
- package/distribution/text-field/type.d.ts +27 -0
- package/distribution/text-field/type.d.ts.map +1 -0
- package/distribution/text-field/type.js +2 -0
- package/distribution/text-field/type.js.map +1 -0
- package/distribution/toggle-mark/index.d.ts +11 -0
- package/distribution/toggle-mark/index.d.ts.map +1 -0
- package/distribution/toggle-mark/index.js +18 -0
- package/distribution/toggle-mark/index.js.map +1 -0
- package/distribution/toggle-mark/index.module.css +1 -0
- package/distribution/toggle-mark/index.module.scss +57 -0
- package/distribution/toggle-mark/type.d.ts +13 -0
- package/distribution/toggle-mark/type.d.ts.map +1 -0
- package/distribution/toggle-mark/type.js +2 -0
- package/distribution/toggle-mark/type.js.map +1 -0
- package/distribution/wrapper/index.d.ts +10 -0
- package/distribution/wrapper/index.d.ts.map +1 -0
- package/distribution/wrapper/index.js +15 -0
- package/distribution/wrapper/index.js.map +1 -0
- package/distribution/wrapper/index.module.css +1 -0
- package/distribution/wrapper/index.module.scss +8 -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 +15 -16
package/README.md
CHANGED
|
@@ -90,6 +90,17 @@ everything below it: on the page, in one part of it, or on one piece.
|
|
|
90
90
|
| `…/choice` | `Choice({ label, options, value, onChange, size?, color? })` | A segmented choice: a radio group, one tab stop, arrow keys |
|
|
91
91
|
| `…/interface-styles` | `interfaceStyles(configuration)` | The color, corner and line styles as remembered `style-web-library` groups |
|
|
92
92
|
| `…/style-switch` | `StyleSwitch({ configuration, group, label, labels? })` | A `Choice` that switches a style group for the whole page |
|
|
93
|
+
| `…/field` | `Field({ label, hideLabel?, hint?, error?, id?, children: (control) => … })` | A control's label, hint and error, linked for assistive technology |
|
|
94
|
+
| `…/text-field` | `TextField({ label, hint?, error?, prefix?, suffix?, multiline?, …input })` | A text field (or with `multiline` a text area) in an outlined field box |
|
|
95
|
+
| `…/toggle-mark` | `ToggleMark({ type, label, checked, onChange })` | A native checkbox or radio over a drawn mark (used by the two below) |
|
|
96
|
+
| `…/checkbox` | `Checkbox({ label, checked?, defaultChecked?, onChange? })` | Outlined, filled once checked, the check growing in |
|
|
97
|
+
| `…/radio-group` | `RadioGroup({ label, options, value?, defaultValue?, onChange?, error? })` | Native radios sharing a name, round, filled once chosen |
|
|
98
|
+
| `…/switch` | `Switch({ label, checked?, defaultChecked?, onChange? })` | On/off; flips at once, busy while an async change runs, back if refused |
|
|
99
|
+
| `…/wrapper` | `Wrapper(box)` | The page's width: up to 1280, centered, 16 a side |
|
|
100
|
+
| `…/card` | `Card({ title?, headingLevel?, description?, action?, children })` | One thing: content on one side, its actions centered on the other |
|
|
101
|
+
| `…/separator` | `Separator({ orientation?, color?, line? })` | A horizontal (or vertical) line in the line style |
|
|
102
|
+
| `…/badge` | `Badge(box)` | A short label in running text: small, filled, brand |
|
|
103
|
+
| `…/avatar` | `Avatar({ name, src?, size?, color?, corner? })`, `initials(name)` | A picture, or the initials when there is none; round |
|
|
93
104
|
|
|
94
105
|
### Box
|
|
95
106
|
|
|
@@ -141,6 +152,23 @@ replaces the words and keeps their size. Hover and pressed looks never apply whi
|
|
|
141
152
|
Without `href` it is a `<button type="button">`. With one, it is next/link's `Link`, or the site's own `link`. It is
|
|
142
153
|
filled in brand by default. A disabled link loses its address.
|
|
143
154
|
|
|
155
|
+
### Form controls
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
<TextField label="Email" type="email" name="email" hint="We never share it." error={error} />
|
|
159
|
+
<TextField label="Price" type="number" prefix="€" suffix=".00" />
|
|
160
|
+
<TextField label="Message" multiline rows={6} />
|
|
161
|
+
<Checkbox label="Remember me" name="remember" />
|
|
162
|
+
<RadioGroup label="Contact me by" name="contact" options={[{ value: "email", label: "Email" }]} />
|
|
163
|
+
<Switch label="Email me" defaultChecked onChange={async (on) => (await save(on)).ok} />
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
A field box (`Box field`) is interactive with a text cursor and the field's font weight. Its focus ring circles the
|
|
167
|
+
whole field, and a line parts each prefix and suffix from the input. Text fields are outlined middleground by
|
|
168
|
+
default, and switch to the error color when they have an error. The typed text is the color's hovered text, so
|
|
169
|
+
foreground on middleground. Checkboxes and radios are drawn like buttons: outlined, then filled once checked. The
|
|
170
|
+
knob and checks move in 0.25 s.
|
|
171
|
+
|
|
144
172
|
## Develop
|
|
145
173
|
|
|
146
174
|
`pnpm verify` runs formatting, lint, type-check, tests with 100% coverage, benchmarks and the build. Branches follow
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AvatarProperties } from "@sharadox/graphical-user-interface-web-library/avatar/type";
|
|
2
|
+
/**
|
|
3
|
+
* A name's initials: the first letter of its first and last words, upper case.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* initials("Ana Maria Silva"); // "AS"
|
|
7
|
+
*/
|
|
8
|
+
export declare function initials(name: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* A person's (or a company's) picture: a square box of the size's height, round by default. Without a picture, or
|
|
11
|
+
* when it can't load, their initials on a filled box (brand by default). Either way it is an image named by `name`.
|
|
12
|
+
*
|
|
13
|
+
* The picture is a plain `img`: avatars come from anywhere (uploads, other services), which next/image would need
|
|
14
|
+
* each site to allow by address.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* <Avatar name="Ana Silva" src={account.picture} size="large" />
|
|
18
|
+
*/
|
|
19
|
+
export declare function Avatar({ name, src, color, corner, size, className, ...look }: AvatarProperties): import("react").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/avatar/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAC;AAGnG;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK7C;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,EACrB,IAAI,EACJ,GAAG,EACH,KAAe,EACf,MAAiB,EACjB,IAAe,EACf,SAAS,EACT,GAAG,IAAI,EACR,EAAE,gBAAgB,+BAsBlB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { classNames } from "@sharadox/web-library/class-name";
|
|
5
|
+
import { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
6
|
+
import styles from "./index.module.css";
|
|
7
|
+
/**
|
|
8
|
+
* A name's initials: the first letter of its first and last words, upper case.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* initials("Ana Maria Silva"); // "AS"
|
|
12
|
+
*/
|
|
13
|
+
export function initials(name) {
|
|
14
|
+
const words = name.trim().split(/\s+/).filter(Boolean);
|
|
15
|
+
if (words.length === 0)
|
|
16
|
+
return "";
|
|
17
|
+
const letters = words.length === 1 ? [words[0]] : [words[0], words.at(-1)];
|
|
18
|
+
return letters.map((word) => [...word][0].toLocaleUpperCase()).join("");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A person's (or a company's) picture: a square box of the size's height, round by default. Without a picture, or
|
|
22
|
+
* when it can't load, their initials on a filled box (brand by default). Either way it is an image named by `name`.
|
|
23
|
+
*
|
|
24
|
+
* The picture is a plain `img`: avatars come from anywhere (uploads, other services), which next/image would need
|
|
25
|
+
* each site to allow by address.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* <Avatar name="Ana Silva" src={account.picture} size="large" />
|
|
29
|
+
*/
|
|
30
|
+
export function Avatar({ name, src, color = "brand", corner = "circle", size = "medium", className, ...look }) {
|
|
31
|
+
const [failed, setFailed] = useState(false);
|
|
32
|
+
const picture = src !== undefined && !failed;
|
|
33
|
+
return (_jsx(Box, { as: "span", square: true, corner: corner, size: size, color: color, ...look, ...(picture ? {} : { variant: "filled", role: "img", "aria-label": name }), className: classNames(styles.avatar, className), children: picture ? (_jsx("img", { src: src, alt: name, className: styles.picture, onError: () => setFailed(true) })) : (initials(name)) }));
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/avatar/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AAEzE,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAClC,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;IAC9E,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAE,CAAC,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,MAAM,CAAC,EACrB,IAAI,EACJ,GAAG,EACH,KAAK,GAAG,OAAO,EACf,MAAM,GAAG,QAAQ,EACjB,IAAI,GAAG,QAAQ,EACf,SAAS,EACT,GAAG,IAAI,EACU;IACjB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,GAAG,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC;IAC7C,OAAO,CACL,KAAC,GAAG,IACF,EAAE,EAAC,MAAM,EACT,MAAM,QACN,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,KACR,IAAI,KACJ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,EAC3E,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,YAE9C,OAAO,CAAC,CAAC,CAAC,CAET,cAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAI,CACxF,CAAC,CAAC,CAAC,CACF,QAAQ,CAAC,IAAI,CAAC,CACf,GACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.avatar){overflow:hidden;inline-size:var(--current-minimum-size);block-size:var(--current-minimum-size);font-size:calc(var(--current-minimum-size)*.4);font-weight:600;line-height:1}:where(.picture){display:block;inline-size:100%;block-size:100%;object-fit:cover}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
:where(.avatar) {
|
|
2
|
+
overflow: hidden;
|
|
3
|
+
inline-size: var(--current-minimum-size);
|
|
4
|
+
block-size: var(--current-minimum-size);
|
|
5
|
+
// Two letters always fit: the initials grow with the avatar.
|
|
6
|
+
font-size: calc(var(--current-minimum-size) * 0.4);
|
|
7
|
+
font-weight: 600;
|
|
8
|
+
line-height: 1;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
:where(.picture) {
|
|
12
|
+
display: block;
|
|
13
|
+
inline-size: 100%;
|
|
14
|
+
block-size: 100%;
|
|
15
|
+
object-fit: cover;
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BoxLook } from "@sharadox/graphical-user-interface-web-library/box/type";
|
|
2
|
+
export interface AvatarProperties extends Pick<BoxLook, "color" | "colorStyle" | "corner" | "line" | "size"> {
|
|
3
|
+
/** Whose picture: its accessible name, and the initials without a picture. */
|
|
4
|
+
name: string;
|
|
5
|
+
/** The picture's address; without one (or when it fails) the initials show. */
|
|
6
|
+
src?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/avatar/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yDAAyD,CAAC;AAEvF,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IAC1G,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/avatar/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BadgeProperties } from "@sharadox/graphical-user-interface-web-library/badge/type";
|
|
2
|
+
/**
|
|
3
|
+
* A badge: a short label (a status, a count, "New") sitting in running text. A small filled brand box by default,
|
|
4
|
+
* with every box look, a prefix and a suffix.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <Badge color="success" variant="outlined">Online</Badge>
|
|
8
|
+
*/
|
|
9
|
+
export declare function Badge({ className, ...box }: BadgeProperties): import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/badge/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2DAA2D,CAAC;AAGjG;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,GAAG,EAAE,EAAE,eAAe,+BAY3D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { classNames } from "@sharadox/web-library/class-name";
|
|
3
|
+
import { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
4
|
+
import styles from "./index.module.css";
|
|
5
|
+
/**
|
|
6
|
+
* A badge: a short label (a status, a count, "New") sitting in running text. A small filled brand box by default,
|
|
7
|
+
* with every box look, a prefix and a suffix.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* <Badge color="success" variant="outlined">Online</Badge>
|
|
11
|
+
*/
|
|
12
|
+
export function Badge({ className, ...box }) {
|
|
13
|
+
return (_jsx(Box, { as: "span", variant: "filled", color: "brand", size: "small", ...box, "data-badge": "", className: classNames(styles.badge, className) }));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/badge/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AAEzE,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,GAAG,EAAmB;IAC1D,OAAO,CACL,KAAC,GAAG,IACF,EAAE,EAAC,MAAM,EACT,OAAO,EAAC,QAAQ,EAChB,KAAK,EAAC,OAAO,EACb,IAAI,EAAC,OAAO,KACR,GAAG,gBACI,EAAE,EACb,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,GAC9C,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.badge{display:inline-flex;vertical-align:middle;padding-inline:var(--scale-8);white-space:nowrap}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/badge/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yDAAyD,CAAC;AAE7F,2CAA2C;AAC3C,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/badge/type.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/box/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yDAAyD,CAAC;AAoBtG,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOpE;AAED;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,UAAU,EAAE,aAAa,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/box/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yDAAyD,CAAC;AAoBtG,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOpE;AAED;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,UAAU,EAAE,aAAa,+BA6C5C"}
|
|
@@ -33,10 +33,13 @@ export function lookAttributes(look) {
|
|
|
33
33
|
* <Box variant="outlined" color="brand" padding={16} direction={{ base: "top-to-bottom", 960: "left-to-right" }}>…</Box>
|
|
34
34
|
*/
|
|
35
35
|
export function Box(properties) {
|
|
36
|
-
const { as: Element = "div", prefix, suffix, square,
|
|
36
|
+
const { as: Element = "div", prefix, suffix, square, field, state, className, children, ...rest } = properties;
|
|
37
|
+
const interactive = properties.interactive || field;
|
|
37
38
|
const look = {};
|
|
38
39
|
const element = {};
|
|
39
40
|
for (const [key, value] of Object.entries(rest)) {
|
|
41
|
+
if (key === "interactive")
|
|
42
|
+
continue;
|
|
40
43
|
if (LOOK_ATTRIBUTES.some(([name]) => name === key))
|
|
41
44
|
look[key] = value;
|
|
42
45
|
else
|
|
@@ -44,6 +47,6 @@ export function Box(properties) {
|
|
|
44
47
|
}
|
|
45
48
|
const sectioned = prefix !== undefined || suffix !== undefined || square || interactive;
|
|
46
49
|
const currentState = interactive ? (state ?? "enabled") : undefined;
|
|
47
|
-
return (_jsx(Element, { ...element, className: classNames(styles.box, className), ...lookAttributes(look), ...(square && { "data-square": "" }), ...(interactive && { "data-interactive": "", "data-state": currentState }), ...(currentState === "disabled" && { "aria-disabled": "true" }), ...(currentState === "loading" && { "aria-busy": "true" }), children: sectioned ? (_jsxs(_Fragment, { children: [prefix !== undefined && (_jsx("span", { className: styles.section, "data-section": "prefix", children: prefix })), _jsx("span", { className: styles.content, "data-section": "content", children: children }), suffix !== undefined && (_jsx("span", { className: styles.section, "data-section": "suffix", children: suffix })), currentState === "loading" && _jsx(Spinner, { className: styles.spinner })] })) : (children) }));
|
|
50
|
+
return (_jsx(Element, { ...element, className: classNames(styles.box, className), ...lookAttributes(look), ...(square && { "data-square": "" }), ...(field && { "data-field": "" }), ...(interactive && { "data-interactive": "", "data-state": currentState }), ...(currentState === "disabled" && { "aria-disabled": "true" }), ...(currentState === "loading" && { "aria-busy": "true" }), children: sectioned ? (_jsxs(_Fragment, { children: [prefix !== undefined && (_jsx("span", { className: styles.section, "data-section": "prefix", children: prefix })), _jsx("span", { className: styles.content, "data-section": "content", children: children }), suffix !== undefined && (_jsx("span", { className: styles.section, "data-section": "suffix", children: suffix })), currentState === "loading" && _jsx(Spinner, { className: styles.spinner })] })) : (children) }));
|
|
48
51
|
}
|
|
49
52
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/box/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2DAA2D,CAAC;AAEjG,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AAEjF,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC,kFAAkF;AAClF,MAAM,eAAe,GAA2C;IAC9D,CAAC,SAAS,EAAE,cAAc,CAAC;IAC3B,CAAC,OAAO,EAAE,YAAY,CAAC;IACvB,CAAC,YAAY,EAAE,kBAAkB,CAAC;IAClC,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IAC/B,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAC3B,CAAC,MAAM,EAAE,WAAW,CAAC;IACrB,CAAC,WAAW,EAAE,gBAAgB,CAAC;IAC/B,CAAC,SAAS,EAAE,cAAc,CAAC;IAC3B,CAAC,OAAO,EAAE,YAAY,CAAC;IACvB,CAAC,WAAW,EAAE,iBAAiB,CAAC;IAChC,CAAC,MAAM,EAAE,WAAW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CAAC,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACpE,OAAO,CACL,KAAC,OAAO,OACF,OAAO,EACX,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,KACxC,cAAc,CAAC,IAAI,CAAC,KACpB,CAAC,MAAM,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,KACjC,CAAC,KAAK,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,KAC/B,CAAC,WAAW,IAAI,EAAE,kBAAkB,EAAE,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,KACvE,CAAC,YAAY,KAAK,UAAU,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,KAC5D,CAAC,YAAY,KAAK,SAAS,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,YAE1D,SAAS,CAAC,CAAC,CAAC,CACX,8BACG,MAAM,KAAK,SAAS,IAAI,CACvB,eAAM,SAAS,EAAE,MAAM,CAAC,OAAO,kBAAe,QAAQ,YACnD,MAAM,GACF,CACR,EACD,eAAM,SAAS,EAAE,MAAM,CAAC,OAAO,kBAAe,SAAS,YACpD,QAAQ,GACJ,EACN,MAAM,KAAK,SAAS,IAAI,CACvB,eAAM,SAAS,EAAE,MAAM,CAAC,OAAO,kBAAe,QAAQ,YACnD,MAAM,GACF,CACR,EACA,YAAY,KAAK,SAAS,IAAI,KAAC,OAAO,IAAC,SAAS,EAAE,MAAM,CAAC,OAAO,GAAI,IACpE,CACJ,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,GACO,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:where(.box){position:relative;box-sizing:border-box;display:var(--box-display);flex-direction:var(--box-direction);flex-wrap:var(--box-wrap);justify-content:var(--box-justify);align-items:var(--box-align);gap:var(--box-gap);min-block-size:var(--box-minimum-size);min-inline-size:var(--box-minimum-size);padding:var(--box-padding);border:var(--box-border-thickness) var(--line-style) var(--box-border-color);border-radius:var(--corner-radius);background:var(--box-background);color:var(--box-text-color);font-family:var(--font-family);line-height:var(--line-height);text-align:var(--box-text-align);text-decoration:none;--section-padding: var(--box-section-padding);--section-minimum-size: calc(var(--box-minimum-size) - 2 * var(--box-border-thickness));-webkit-backdrop-filter:var(--box-backdrop);backdrop-filter:var(--box-backdrop);transition:background-color var(--quick-duration) var(--easing),color var(--quick-duration) var(--easing),border-color var(--quick-duration) var(--easing),opacity var(--quick-duration) var(--easing)}:where(.box[data-variant],.box[data-size],.box[data-interactive]){font-size:var(--current-font-size)}:where(.box[data-interactive]){cursor:pointer;font-weight:var(--current-font-weight);user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}:where(.box[data-interactive]):active{cursor:default}:where(.box[data-interactive]):focus-visible{outline:var(--focus-thickness) solid var(--current-color);outline-offset:var(--focus-offset)}:where(.box[data-state=loading],.box[data-state=disabled]){cursor:default}:where(.box[data-state=disabled]){opacity:var(--disabled-opacity)}:where(.content){display:flex;flex:1 1 auto;flex-direction:inherit;justify-content:inherit;align-items:inherit;gap:inherit;min-inline-size:0;padding-inline:var(--section-padding)}:where(.section){display:flex;flex:none;justify-content:center;align-items:center;min-block-size:var(--section-minimum-size);min-inline-size:var(--section-minimum-size)}:where(.box[data-square]){aspect-ratio:1}:where(.box[data-square])>:where(.content){justify-content:center;padding-inline:0}:where(.box[data-state=loading])>:where(.content,.section){opacity:0}:where(.spinner){position:absolute;inset:0;margin:auto}
|
|
1
|
+
:where(.box){position:relative;box-sizing:border-box;display:var(--box-display);flex-direction:var(--box-direction);flex-wrap:var(--box-wrap);justify-content:var(--box-justify);align-items:var(--box-align);gap:var(--box-gap);min-block-size:var(--box-minimum-size);min-inline-size:var(--box-minimum-size);padding:var(--box-padding);border:var(--box-border-thickness) var(--line-style) var(--box-border-color);border-radius:var(--corner-radius);background:var(--box-background);color:var(--box-text-color);font-family:var(--font-family);line-height:var(--line-height);text-align:var(--box-text-align);text-decoration:none;--section-padding: var(--box-section-padding);--section-minimum-size: calc(var(--box-minimum-size) - 2 * var(--box-border-thickness));-webkit-backdrop-filter:var(--box-backdrop);backdrop-filter:var(--box-backdrop);transition:background-color var(--quick-duration) var(--easing),color var(--quick-duration) var(--easing),border-color var(--quick-duration) var(--easing),opacity var(--quick-duration) var(--easing)}:where(.box[data-variant],.box[data-size],.box[data-interactive]){font-size:var(--current-font-size)}:where(.box[data-interactive]){cursor:pointer;font-weight:var(--current-font-weight);user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}:where(.box[data-interactive]):active{cursor:default}:where(.box[data-interactive]):focus-visible{outline:var(--focus-thickness) solid var(--current-color);outline-offset:var(--focus-offset)}:where(.box[data-state=loading],.box[data-state=disabled]){cursor:default}:where(.box[data-state=disabled]){opacity:var(--disabled-opacity)}:where(.box[data-field]){cursor:text;font-weight:var(--current-field-font-weight)}:where(.box[data-field]):active{cursor:text}:where(.box[data-field]):focus-within{outline:var(--focus-thickness) solid var(--current-color);outline-offset:var(--focus-offset)}:where(.box[data-field])>:where([data-section=prefix]){border-inline-end:var(--box-border-thickness) var(--line-style) var(--box-border-color)}:where(.box[data-field])>:where([data-section=suffix]){border-inline-start:var(--box-border-thickness) var(--line-style) var(--box-border-color)}:where(.box[data-field][data-state=disabled]){cursor:default}:where(.content){display:flex;flex:1 1 auto;flex-direction:inherit;justify-content:inherit;align-items:inherit;gap:inherit;min-inline-size:0;padding-inline:var(--section-padding)}:where(.section){display:flex;flex:none;justify-content:center;align-items:center;min-block-size:var(--section-minimum-size);min-inline-size:var(--section-minimum-size)}:where(.box[data-square]){aspect-ratio:1}:where(.box[data-square])>:where(.content){justify-content:center;padding-inline:0}:where(.box[data-state=loading])>:where(.content,.section){opacity:0}:where(.spinner){position:absolute;inset:0;margin:auto}
|
|
@@ -60,6 +60,34 @@
|
|
|
60
60
|
opacity: var(--disabled-opacity);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
// A field: typed into, so a text cursor and the field's weight; its focus ring circles the whole box, and a line
|
|
64
|
+
// parts each prefix and suffix from the content.
|
|
65
|
+
:where(.box[data-field]) {
|
|
66
|
+
cursor: text;
|
|
67
|
+
font-weight: var(--current-field-font-weight);
|
|
68
|
+
|
|
69
|
+
&:active {
|
|
70
|
+
cursor: text;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&:focus-within {
|
|
74
|
+
outline: var(--focus-thickness) solid var(--current-color);
|
|
75
|
+
outline-offset: var(--focus-offset);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
> :where([data-section="prefix"]) {
|
|
79
|
+
border-inline-end: var(--box-border-thickness) var(--line-style) var(--box-border-color);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
> :where([data-section="suffix"]) {
|
|
83
|
+
border-inline-start: var(--box-border-thickness) var(--line-style) var(--box-border-color);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
:where(.box[data-field][data-state="disabled"]) {
|
|
88
|
+
cursor: default;
|
|
89
|
+
}
|
|
90
|
+
|
|
63
91
|
// Sections: the content padded by the size's section padding, prefix and suffix at least square.
|
|
64
92
|
:where(.content) {
|
|
65
93
|
display: flex;
|
|
@@ -43,6 +43,11 @@ export interface BoxProperties extends BoxLook, Omit<HTMLAttributes<HTMLElement>
|
|
|
43
43
|
square?: boolean;
|
|
44
44
|
/** Reacts to the pointer and the keyboard: hover and pressed looks, a pointer cursor, states. */
|
|
45
45
|
interactive?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Holds a form control (a text field, a select): interactive, with a text cursor, the field's font weight, a focus
|
|
48
|
+
* ring while anything inside has focus, and a line between its sections.
|
|
49
|
+
*/
|
|
50
|
+
field?: boolean;
|
|
46
51
|
/** An interactive box's state (`enabled` by default). */
|
|
47
52
|
state?: BoxState;
|
|
48
53
|
/** Anything else the element takes (`href`, `type`, `disabled`…). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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AAC,YAAY,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IACrC,uFAAuF;IACvF,IAAI,CAAC,EAAE,UAAU,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;IACrC,GAAG,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,aAAc,SAAQ,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACnG,uFAAuF;IACvF,EAAE,CAAC,EAAE,WAAW,CAAC;IACjB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,oDAAoD;IACpD,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iGAAiG;IACjG,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yDAAyD;IACzD,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,qEAAqE;IACrE,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CardProperties } from "@sharadox/graphical-user-interface-web-library/card/type";
|
|
2
|
+
/**
|
|
3
|
+
* A card: one thing on its own (a picture, a name, an identifier). Its title, description and content on one side,
|
|
4
|
+
* its action buttons on the other, centered on the card's height; they wrap under it when there is no room. An
|
|
5
|
+
* outlined foreground article by default (see-through, so glass), with every box look.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <Card title="Email" description="Where sign-in codes go." action={<Button variant="outlined">Edit</Button>}>ana@example.com</Card>
|
|
9
|
+
*/
|
|
10
|
+
export declare function Card(properties: CardProperties): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/card/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0DAA0D,CAAC;AAG/F;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,UAAU,EAAE,cAAc,+BA4B9C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { classNames } from "@sharadox/web-library/class-name";
|
|
3
|
+
import { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
4
|
+
import styles from "./index.module.css";
|
|
5
|
+
/**
|
|
6
|
+
* A card: one thing on its own (a picture, a name, an identifier). Its title, description and content on one side,
|
|
7
|
+
* its action buttons on the other, centered on the card's height; they wrap under it when there is no room. An
|
|
8
|
+
* outlined foreground article by default (see-through, so glass), with every box look.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <Card title="Email" description="Where sign-in codes go." action={<Button variant="outlined">Edit</Button>}>ana@example.com</Card>
|
|
12
|
+
*/
|
|
13
|
+
export function Card(properties) {
|
|
14
|
+
const { title, headingLevel = 2, description, action, children, className, ...box } = properties;
|
|
15
|
+
const Heading = `h${headingLevel}`;
|
|
16
|
+
return (_jsxs(Box, { as: "article", variant: "outlined", color: "foreground", padding: 24, gap: 16, justify: "space-between", wrap: "wrap", textAlign: "start", ...box, className: classNames(styles.card, className), children: [_jsxs(Box, { direction: "top-to-bottom", align: "start", textAlign: "start", gap: 8, className: styles.body, children: [title !== undefined && _jsx(Heading, { className: styles.title, children: title }), description !== undefined && _jsx("p", { className: styles.description, children: description }), children] }), action !== undefined && (_jsx(Box, { gap: 8, wrap: "wrap", className: styles.action, children: action }))] }));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/card/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AAEzE,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAC,UAA0B;IAC7C,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,GAAG,EAAE,GAAG,UAAU,CAAC;IACjG,MAAM,OAAO,GAAG,IAAI,YAAY,EAAW,CAAC;IAC5C,OAAO,CACL,MAAC,GAAG,IACF,EAAE,EAAC,SAAS,EACZ,OAAO,EAAC,UAAU,EAClB,KAAK,EAAC,YAAY,EAClB,OAAO,EAAE,EAAE,EACX,GAAG,EAAE,EAAE,EACP,OAAO,EAAC,eAAe,EACvB,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,OAAO,KACb,GAAG,EACP,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,aAE7C,MAAC,GAAG,IAAC,SAAS,EAAC,eAAe,EAAC,KAAK,EAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAC,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,aAC1F,KAAK,KAAK,SAAS,IAAI,KAAC,OAAO,IAAC,SAAS,EAAE,MAAM,CAAC,KAAK,YAAG,KAAK,GAAW,EAC1E,WAAW,KAAK,SAAS,IAAI,YAAG,SAAS,EAAE,MAAM,CAAC,WAAW,YAAG,WAAW,GAAK,EAChF,QAAQ,IACL,EACL,MAAM,KAAK,SAAS,IAAI,CACvB,KAAC,GAAG,IAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAC,MAAM,EAAC,SAAS,EAAE,MAAM,CAAC,MAAM,YAC9C,MAAM,GACH,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.body){flex:1 1 240px;min-inline-size:0}:where(.title){margin:0;font-size:var(--scale-16);font-weight:600}:where(.description){margin:0;color:inherit;opacity:.7;font-size:var(--scale-14)}:where(.action){flex:none}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
:where(.body) {
|
|
2
|
+
flex: 1 1 240px;
|
|
3
|
+
min-inline-size: 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:where(.title) {
|
|
7
|
+
margin: 0;
|
|
8
|
+
font-size: var(--scale-16);
|
|
9
|
+
font-weight: 600;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:where(.description) {
|
|
13
|
+
margin: 0;
|
|
14
|
+
// The card's own text, softened, so it reads on any fill.
|
|
15
|
+
color: inherit;
|
|
16
|
+
opacity: 0.7;
|
|
17
|
+
font-size: var(--scale-14);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:where(.action) {
|
|
21
|
+
flex: none;
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { BoxProperties } from "@sharadox/graphical-user-interface-web-library/box/type";
|
|
3
|
+
export interface CardProperties extends Omit<BoxProperties, "title"> {
|
|
4
|
+
/** The card's heading. */
|
|
5
|
+
title?: ReactNode;
|
|
6
|
+
/** Its level (`h2` by default), to fit the page's outline. */
|
|
7
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
8
|
+
/** A line under the title. */
|
|
9
|
+
description?: ReactNode;
|
|
10
|
+
/** Buttons beside the content, centered on the card's height. */
|
|
11
|
+
action?: ReactNode;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/card/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yDAAyD,CAAC;AAE7F,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC;IAClE,0BAA0B;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,8BAA8B;IAC9B,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,iEAAiE;IACjE,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/card/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CheckboxProperties } from "@sharadox/graphical-user-interface-web-library/checkbox/type";
|
|
2
|
+
/**
|
|
3
|
+
* A checkbox drawn like the buttons: outlined, filled once checked, with a check growing in. A native checkbox
|
|
4
|
+
* underneath, so it works with forms, keyboards and screen readers. Controlled (`checked`) or not (`defaultChecked`).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <Checkbox label="Remember me" name="remember" />
|
|
8
|
+
*/
|
|
9
|
+
export declare function Checkbox({ checked, defaultChecked, onChange, ...mark }: CheckboxProperties): import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/checkbox/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAEvG;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,cAAsB,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,kBAAkB,+BAclG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { ToggleMark } from "@sharadox/graphical-user-interface-web-library/toggle-mark";
|
|
5
|
+
/**
|
|
6
|
+
* A checkbox drawn like the buttons: outlined, filled once checked, with a check growing in. A native checkbox
|
|
7
|
+
* underneath, so it works with forms, keyboards and screen readers. Controlled (`checked`) or not (`defaultChecked`).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* <Checkbox label="Remember me" name="remember" />
|
|
11
|
+
*/
|
|
12
|
+
export function Checkbox({ checked, defaultChecked = false, onChange, ...mark }) {
|
|
13
|
+
const [own, setOwn] = useState(defaultChecked);
|
|
14
|
+
const current = checked ?? own;
|
|
15
|
+
return (_jsx(ToggleMark, { ...mark, type: "checkbox", checked: current, onChange: (next) => {
|
|
16
|
+
if (checked === undefined)
|
|
17
|
+
setOwn(next);
|
|
18
|
+
onChange?.(next);
|
|
19
|
+
} }));
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/checkbox/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,4DAA4D,CAAC;AAGxF;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAsB;IACjG,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,OAAO,IAAI,GAAG,CAAC;IAC/B,OAAO,CACL,KAAC,UAAU,OACL,IAAI,EACR,IAAI,EAAC,UAAU,EACf,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;YACjB,IAAI,OAAO,KAAK,SAAS;gBAAE,MAAM,CAAC,IAAI,CAAC,CAAC;YACxC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC,GACD,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ToggleMarkProperties } from "@sharadox/graphical-user-interface-web-library/toggle-mark/type";
|
|
2
|
+
export interface CheckboxProperties extends Omit<ToggleMarkProperties, "type" | "checked" | "onChange"> {
|
|
3
|
+
/** Controlled: whether it is checked. */
|
|
4
|
+
checked?: boolean;
|
|
5
|
+
/** Uncontrolled: whether it starts checked. */
|
|
6
|
+
defaultChecked?: boolean;
|
|
7
|
+
onChange?: (checked: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/checkbox/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iEAAiE,CAAC;AAE5G,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;IACrG,yCAAyC;IACzC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/checkbox/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FieldProperties } from "@sharadox/graphical-user-interface-web-library/field/type";
|
|
2
|
+
/**
|
|
3
|
+
* A form control with its label above it and its hint and error under it, all linked for assistive technology: the
|
|
4
|
+
* label names the control, the hint and error describe it, and an error marks it invalid. The control is drawn by
|
|
5
|
+
* `children`, which receives the attributes to spread on it.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <Field label="Email" hint="We never share it." error={error}>{(control) => <input {...control} type="email" />}</Field>
|
|
9
|
+
*/
|
|
10
|
+
export declare function Field({ label, hideLabel, hint, error, id, className, children }: FieldProperties): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/field/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,eAAe,EAAE,MAAM,2DAA2D,CAAC;AAG/G;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,eAAe,+BA6BhG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
4
|
+
import styles from "./index.module.css";
|
|
5
|
+
/**
|
|
6
|
+
* A form control with its label above it and its hint and error under it, all linked for assistive technology: the
|
|
7
|
+
* label names the control, the hint and error describe it, and an error marks it invalid. The control is drawn by
|
|
8
|
+
* `children`, which receives the attributes to spread on it.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <Field label="Email" hint="We never share it." error={error}>{(control) => <input {...control} type="email" />}</Field>
|
|
12
|
+
*/
|
|
13
|
+
export function Field({ label, hideLabel, hint, error, id, className, children }) {
|
|
14
|
+
const made = useId();
|
|
15
|
+
const controlId = id ?? made;
|
|
16
|
+
const hintId = `${controlId}-hint`;
|
|
17
|
+
const errorId = `${controlId}-error`;
|
|
18
|
+
const describedBy = [hint !== undefined && hintId, error !== undefined && errorId].filter(Boolean).join(" ");
|
|
19
|
+
const control = {
|
|
20
|
+
id: controlId,
|
|
21
|
+
...(describedBy && { "aria-describedby": describedBy }),
|
|
22
|
+
...(error !== undefined && { "aria-invalid": true }),
|
|
23
|
+
};
|
|
24
|
+
return (_jsxs(Box, { direction: "top-to-bottom", align: "stretch", textAlign: "start", gap: 8, className: className, children: [_jsx("label", { htmlFor: controlId, className: styles.label, ...(hideLabel && { "data-hidden": "" }), children: label }), children(control), hint !== undefined && (_jsx(Box, { as: "p", id: hintId, color: "middleground", justify: "start", textAlign: "start", className: styles.message, children: hint })), error !== undefined && (_jsx(Box, { as: "p", id: errorId, color: "error", justify: "start", textAlign: "start", className: styles.message, children: error }))] }));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/field/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AAEzE,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAmB;IAC/F,MAAM,IAAI,GAAG,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AO,EAAC,SAAS,EAAC,OAAO,EAAC,SAAS,EAAE,MAAM,CAAC,OAAO,YAC/F,KAAK,GACF,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.label){font-size:var(--current-font-size);font-weight:var(--current-font-weight);text-align:start}:where(.label[data-hidden]){position:absolute;inline-size:1px;block-size:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}:where(.message){margin:0;color:var(--current-color);font-size:var(--scale-12)}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
:where(.label) {
|
|
2
|
+
font-size: var(--current-font-size);
|
|
3
|
+
font-weight: var(--current-font-weight);
|
|
4
|
+
text-align: start;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// Hidden from sight, still read by screen readers.
|
|
8
|
+
:where(.label[data-hidden]) {
|
|
9
|
+
position: absolute;
|
|
10
|
+
inline-size: 1px;
|
|
11
|
+
block-size: 1px;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
clip-path: inset(50%);
|
|
14
|
+
white-space: nowrap;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:where(.message) {
|
|
18
|
+
margin: 0;
|
|
19
|
+
color: var(--current-color);
|
|
20
|
+
font-size: var(--scale-12);
|
|
21
|
+
}
|