@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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/** What the control inside a field takes, so the label names it and the hint and error describe it. */
|
|
3
|
+
export interface FieldControl {
|
|
4
|
+
id: string;
|
|
5
|
+
"aria-describedby"?: string;
|
|
6
|
+
"aria-invalid"?: true;
|
|
7
|
+
}
|
|
8
|
+
export interface FieldProperties {
|
|
9
|
+
/** The control's name, shown above it. */
|
|
10
|
+
label: ReactNode;
|
|
11
|
+
/** Hides the label from sight; screen readers still read it. */
|
|
12
|
+
hideLabel?: boolean;
|
|
13
|
+
/** A line of help under the control. */
|
|
14
|
+
hint?: ReactNode;
|
|
15
|
+
/** What is wrong, in the error color; marks the control invalid. */
|
|
16
|
+
error?: ReactNode;
|
|
17
|
+
/** The control's id; one is made otherwise. */
|
|
18
|
+
id?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
/** Draws the control with what it must take. */
|
|
21
|
+
children: (control: FieldControl) => ReactNode;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/field/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,uGAAuG;AACvG,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,KAAK,EAAE,SAAS,CAAC;IACjB,gEAAgE;IAChE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wCAAwC;IACxC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,oEAAoE;IACpE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,+CAA+C;IAC/C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,QAAQ,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,SAAS,CAAC;CAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/field/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RadioGroupProperties } from "@sharadox/graphical-user-interface-web-library/radio-group/type";
|
|
2
|
+
/**
|
|
3
|
+
* A group of radios under its label, one choice among them: native radios sharing a name (arrow keys move between
|
|
4
|
+
* them), each drawn like the buttons (outlined, filled once chosen), round by default. Controlled (`value`) or not
|
|
5
|
+
* (`defaultValue`).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <RadioGroup label="Contact me by" name="contact" options={[{ value: "email", label: "Email" }, …]} defaultValue="email" />
|
|
9
|
+
*/
|
|
10
|
+
export declare function RadioGroup(properties: RadioGroupProperties): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/radio-group/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iEAAiE,CAAC;AAG5G;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,oBAAoB,+BA6C1D"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
|
+
import { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
5
|
+
import { ToggleMark } from "@sharadox/graphical-user-interface-web-library/toggle-mark";
|
|
6
|
+
import styles from "./index.module.css";
|
|
7
|
+
/**
|
|
8
|
+
* A group of radios under its label, one choice among them: native radios sharing a name (arrow keys move between
|
|
9
|
+
* them), each drawn like the buttons (outlined, filled once chosen), round by default. Controlled (`value`) or not
|
|
10
|
+
* (`defaultValue`).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <RadioGroup label="Contact me by" name="contact" options={[{ value: "email", label: "Email" }, …]} defaultValue="email" />
|
|
14
|
+
*/
|
|
15
|
+
export function RadioGroup(properties) {
|
|
16
|
+
const { label, options, name, value, defaultValue, onChange, disabled, error, state, className, ...look } = properties;
|
|
17
|
+
const id = useId();
|
|
18
|
+
const [own, setOwn] = useState(defaultValue);
|
|
19
|
+
const current = value ?? own;
|
|
20
|
+
const errorId = `${id}-error`;
|
|
21
|
+
return (_jsxs(Box, { role: "radiogroup", "aria-labelledby": `${id}-label`, ...(error !== undefined && { "aria-invalid": true, "aria-describedby": errorId }), direction: "top-to-bottom", align: "start", textAlign: "start", gap: 8, className: className, children: [_jsx("span", { id: `${id}-label`, className: styles.label, children: label }), options.map((option) => (_jsx(ToggleMark, { ...look, type: "radio", name: name ?? id, value: option.value, label: option.label, checked: current === option.value, disabled: disabled, state: state, onChange: () => {
|
|
22
|
+
if (value === undefined)
|
|
23
|
+
setOwn(option.value);
|
|
24
|
+
onChange?.(option.value);
|
|
25
|
+
} }, option.value))), error !== undefined && (_jsx(Box, { as: "p", id: errorId, color: "error", textAlign: "start", className: styles.error, children: error }))] }));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/radio-group/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,4DAA4D,CAAC;AAExF,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,UAAgC;IACzD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GACvG,UAAU,CAAC;IACb,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,KAAK,IAAI,GAAG,CAAC;IAC7B,MAAM,OAAO,GAAG,GAAG,EAAE,QAAQ,CAAC;IAC9B,OAAO,CACL,MAAC,GAAG,IACF,IAAI,EAAC,YAAY,qBACA,GAAG,EAAE,QAAQ,KAC1B,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,EAClF,SAAS,EAAC,eAAe,EACzB,KAAK,EAAC,OAAO,EACb,SAAS,EAAC,OAAO,EACjB,GAAG,EAAE,CAAC,EACN,SAAS,EAAE,SAAS,aAEpB,eAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,YAC7C,KAAK,GACD,EACN,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,KAAC,UAAU,OAEL,IAAI,EACR,IAAI,EAAC,OAAO,EACZ,IAAI,EAAE,IAAI,IAAI,EAAE,EAChB,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC,KAAK,EACjC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,GAAG,EAAE;oBACb,IAAI,KAAK,KAAK,SAAS;wBAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBAC9C,QAAQ,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC3B,CAAC,IAZI,MAAM,CAAC,KAAK,CAajB,CACH,CAAC,EACD,KAAK,KAAK,SAAS,IAAI,CACtB,KAAC,GAAG,IAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAC,SAAS,EAAE,MAAM,CAAC,KAAK,YAC7E,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)}:where(.error){margin:0;color:var(--current-color);font-size:var(--scale-12)}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { BoxLook, BoxState } from "@sharadox/graphical-user-interface-web-library/box/type";
|
|
3
|
+
export interface RadioOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface RadioGroupProperties extends Pick<BoxLook, "color" | "colorStyle" | "corner" | "line" | "size"> {
|
|
8
|
+
/** The group's name, shown above it. */
|
|
9
|
+
label: ReactNode;
|
|
10
|
+
options: readonly RadioOption[];
|
|
11
|
+
/** The form field's name; one is made otherwise. */
|
|
12
|
+
name?: string;
|
|
13
|
+
/** Controlled: the chosen value. */
|
|
14
|
+
value?: string;
|
|
15
|
+
/** Uncontrolled: the value chosen at first. */
|
|
16
|
+
defaultValue?: string;
|
|
17
|
+
onChange?: (value: string) => void;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** What is wrong, under the options; marks the group invalid. */
|
|
20
|
+
error?: ReactNode;
|
|
21
|
+
/** Forces a state on every mark (for the design system). */
|
|
22
|
+
state?: BoxState;
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/radio-group/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAC;AAEjG,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IAC9G,wCAAwC;IACxC,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IAChC,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iEAAiE;IACjE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/radio-group/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SeparatorProperties } from "@sharadox/graphical-user-interface-web-library/separator/type";
|
|
2
|
+
/**
|
|
3
|
+
* A line between things: a horizontal rule by default, or vertical between items in a row. It is the color's border
|
|
4
|
+
* color (foreground's by default), in the line style and thickness.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <Separator />
|
|
8
|
+
* <Separator orientation="vertical" line="dashed" />
|
|
9
|
+
*/
|
|
10
|
+
export declare function Separator({ orientation, color, line, className }: SeparatorProperties): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/separator/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+DAA+D,CAAC;AAGzG;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,EAAE,WAA0B,EAAE,KAAoB,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,mBAAmB,+BASnH"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { classNames } from "@sharadox/web-library/class-name";
|
|
3
|
+
import { lookAttributes } from "@sharadox/graphical-user-interface-web-library/box";
|
|
4
|
+
import styles from "./index.module.css";
|
|
5
|
+
/**
|
|
6
|
+
* A line between things: a horizontal rule by default, or vertical between items in a row. It is the color's border
|
|
7
|
+
* color (foreground's by default), in the line style and thickness.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* <Separator />
|
|
11
|
+
* <Separator orientation="vertical" line="dashed" />
|
|
12
|
+
*/
|
|
13
|
+
export function Separator({ orientation = "horizontal", color = "foreground", line, className }) {
|
|
14
|
+
return (_jsx("hr", { ...lookAttributes({ color, line }), ...(orientation === "vertical" && { "aria-orientation": "vertical" }), "data-orientation": orientation, className: classNames(styles.separator, className) }));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/separator/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AAEpF,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,EAAE,WAAW,GAAG,YAAY,EAAE,KAAK,GAAG,YAAY,EAAE,IAAI,EAAE,SAAS,EAAuB;IAClH,OAAO,CACL,gBACM,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,KAC/B,CAAC,WAAW,KAAK,UAAU,IAAI,EAAE,kBAAkB,EAAE,UAAU,EAAE,CAAC,sBACpD,WAAW,EAC7B,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,GAClD,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.separator){flex:none;align-self:stretch;margin:0;border:0;border-block-start:var(--line-thickness) var(--line-style) var(--current-border-color)}:where(.separator[data-orientation=vertical]){border-block-start:0;border-inline-start:var(--line-thickness) var(--line-style) var(--current-border-color)}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
:where(.separator) {
|
|
2
|
+
flex: none;
|
|
3
|
+
align-self: stretch;
|
|
4
|
+
margin: 0;
|
|
5
|
+
border: 0;
|
|
6
|
+
border-block-start: var(--line-thickness) var(--line-style) var(--current-border-color);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
:where(.separator[data-orientation="vertical"]) {
|
|
10
|
+
border-block-start: 0;
|
|
11
|
+
border-inline-start: var(--line-thickness) var(--line-style) var(--current-border-color);
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BoxLook } from "@sharadox/graphical-user-interface-web-library/box/type";
|
|
2
|
+
export interface SeparatorProperties extends Pick<BoxLook, "color" | "line"> {
|
|
3
|
+
/** Across a column (`horizontal`, by default) or between items in a row (`vertical`). */
|
|
4
|
+
orientation?: "horizontal" | "vertical";
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/separator/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yDAAyD,CAAC;AAEvF,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1E,yFAAyF;IACzF,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/separator/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SwitchProperties } from "@sharadox/graphical-user-interface-web-library/switch/type";
|
|
2
|
+
/**
|
|
3
|
+
* An on/off switch beside its label: a round track, outlined when off and filled when on, whose knob glides across.
|
|
4
|
+
* A change shows at once: while an asynchronous `onChange` runs the knob holds a spinner and clicks are ignored, and
|
|
5
|
+
* if it answers `false` the switch flips back.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <Switch label="Email me" checked={on} onChange={async (next) => (await save(next)).ok} />
|
|
9
|
+
*/
|
|
10
|
+
export declare function Switch(properties: SwitchProperties): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/switch/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAC;AAGnG;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,UAAU,EAAE,gBAAgB,+BA6DlD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } 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 { Spinner } from "@sharadox/graphical-user-interface-web-library/spinner";
|
|
7
|
+
import styles from "./index.module.css";
|
|
8
|
+
/**
|
|
9
|
+
* An on/off switch beside its label: a round track, outlined when off and filled when on, whose knob glides across.
|
|
10
|
+
* A change shows at once: while an asynchronous `onChange` runs the knob holds a spinner and clicks are ignored, and
|
|
11
|
+
* if it answers `false` the switch flips back.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <Switch label="Email me" checked={on} onChange={async (next) => (await save(next)).ok} />
|
|
15
|
+
*/
|
|
16
|
+
export function Switch(properties) {
|
|
17
|
+
const { label, checked, defaultChecked = false, onChange, disabled, state, className, corner = "circle", size = "small", color = "brand", ...look } = properties;
|
|
18
|
+
const [own, setOwn] = useState(defaultChecked);
|
|
19
|
+
const [shown, setShown] = useState(undefined);
|
|
20
|
+
const [pending, setPending] = useState(false);
|
|
21
|
+
const current = shown ?? checked ?? own;
|
|
22
|
+
const toggle = async () => {
|
|
23
|
+
if (pending)
|
|
24
|
+
return;
|
|
25
|
+
const next = !current;
|
|
26
|
+
setShown(next);
|
|
27
|
+
const answer = onChange?.(next);
|
|
28
|
+
if (answer instanceof Promise) {
|
|
29
|
+
setPending(true);
|
|
30
|
+
const accepted = (await answer) !== false;
|
|
31
|
+
setPending(false);
|
|
32
|
+
if (accepted && checked === undefined)
|
|
33
|
+
setOwn(next);
|
|
34
|
+
setShown(undefined);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
if (checked === undefined)
|
|
38
|
+
setOwn(next);
|
|
39
|
+
setShown(undefined);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return (_jsxs("button", { type: "button", role: "switch", "aria-checked": current, ...(pending && { "aria-busy": true }), disabled: disabled, onClick: toggle, className: classNames(styles.switch, className), "data-checked": current || undefined, children: [_jsx(Box, { as: "span", interactive: true, variant: current ? "filled" : "outlined", color: color, corner: corner, size: size, state: state ?? (disabled ? "disabled" : "enabled"), ...look, className: styles.track, children: _jsx("span", { className: styles.knob, children: pending && _jsx(Spinner, {}) }) }), _jsx("span", { className: styles.label, children: label })] }));
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/switch/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;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AAEjF,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,UAA4B;IACjD,MAAM,EACJ,KAAK,EACL,OAAO,EACP,cAAc,GAAG,KAAK,EACtB,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,SAAS,EACT,MAAM,GAAG,QAAQ,EACjB,IAAI,GAAG,OAAO,EACd,KAAK,GAAG,OAAO,EACf,GAAG,IAAI,EACR,GAAG,UAAU,CAAC;IACf,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC/C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAsB,SAAS,CAAC,CAAC;IACnE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,KAAK,IAAI,OAAO,IAAI,GAAG,CAAC;IACxC,MAAM,MAAM,GAAG,KAAK,IAAI,EAAE;QACxB,IAAI,OAAO;YAAE,OAAO;QACpB,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC;QACtB,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;YAC9B,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,KAAK,KAAK,CAAC;YAC1C,UAAU,CAAC,KAAK,CAAC,CAAC;YAClB,IAAI,QAAQ,IAAI,OAAO,KAAK,SAAS;gBAAE,MAAM,CAAC,IAAI,CAAC,CAAC;YACpD,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,IAAI,OAAO,KAAK,SAAS;gBAAE,MAAM,CAAC,IAAI,CAAC,CAAC;YACxC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;IACF,OAAO,CACL,kBACE,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,QAAQ,kBACC,OAAO,KACjB,CAAC,OAAO,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,EACtC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,kBACjC,OAAO,IAAI,SAAS,aAElC,KAAC,GAAG,IACF,EAAE,EAAC,MAAM,EACT,WAAW,QACX,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,EACxC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,KAC/C,IAAI,EACR,SAAS,EAAE,MAAM,CAAC,KAAK,YAEvB,eAAM,SAAS,EAAE,MAAM,CAAC,IAAI,YAAG,OAAO,IAAI,KAAC,OAAO,KAAG,GAAQ,GACzD,EACN,eAAM,SAAS,EAAE,MAAM,CAAC,KAAK,YAAG,KAAK,GAAQ,IACtC,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.switch){display:inline-flex;align-items:center;gap:var(--scale-8);margin:0;padding:0;border:0;background:none;color:inherit;font:inherit;text-align:start;cursor:pointer}:where(.switch):disabled{cursor:default}:where(.switch):focus-visible{outline:none}:where(.switch):focus-visible>:where(.track){outline:var(--focus-thickness) solid var(--current-color);outline-offset:var(--focus-offset)}:where(.switch) .track{justify-content:start;inline-size:calc(var(--current-minimum-size)*2);min-inline-size:calc(var(--current-minimum-size)*2);padding:var(--line-thickness)}:where(.switch) .track>*{flex:1 1 auto;justify-content:start;padding:0}:where(.knob){display:flex;justify-content:center;align-items:center;inline-size:calc(var(--current-minimum-size) - 4*var(--line-thickness));block-size:calc(var(--current-minimum-size) - 4*var(--line-thickness));border-radius:var(--corner-radius);background:currentcolor;font-size:.6em;transition:transform var(--duration) var(--easing)}:where(.knob)>*{color:var(--current-color)}:where(.switch[data-checked]) :where(.knob){transform:translateX(calc(var(--current-minimum-size)))}:where(.switch[data-checked]:dir(rtl)) :where(.knob){transform:translateX(calc(var(--current-minimum-size) * -1))}:where(.label){font-size:var(--current-font-size)}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
:where(.switch) {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: var(--scale-8);
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
border: 0;
|
|
8
|
+
background: none;
|
|
9
|
+
color: inherit;
|
|
10
|
+
font: inherit;
|
|
11
|
+
text-align: start;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
|
|
14
|
+
&:disabled {
|
|
15
|
+
cursor: default;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:focus-visible {
|
|
19
|
+
outline: none;
|
|
20
|
+
|
|
21
|
+
> :where(.track) {
|
|
22
|
+
outline: var(--focus-thickness) solid var(--current-color);
|
|
23
|
+
outline-offset: var(--focus-offset);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Twice as wide as high; the knob is a square of the track's inner height, gliding to the far end when on. Inside the
|
|
29
|
+
// switch, so these beat the box's own (zero-weight) size and padding whichever style sheet loads last.
|
|
30
|
+
:where(.switch) .track {
|
|
31
|
+
justify-content: start;
|
|
32
|
+
inline-size: calc(var(--current-minimum-size) * 2);
|
|
33
|
+
min-inline-size: calc(var(--current-minimum-size) * 2);
|
|
34
|
+
padding: var(--line-thickness);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
:where(.switch) .track > * {
|
|
38
|
+
// An interactive box puts its content in a padded section: here it holds only the knob, from the track's start.
|
|
39
|
+
flex: 1 1 auto;
|
|
40
|
+
justify-content: start;
|
|
41
|
+
padding: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
:where(.knob) {
|
|
45
|
+
display: flex;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
align-items: center;
|
|
48
|
+
inline-size: calc(var(--current-minimum-size) - 4 * var(--line-thickness));
|
|
49
|
+
block-size: calc(var(--current-minimum-size) - 4 * var(--line-thickness));
|
|
50
|
+
border-radius: var(--corner-radius);
|
|
51
|
+
background: currentcolor;
|
|
52
|
+
font-size: 0.6em;
|
|
53
|
+
transition: transform var(--duration) var(--easing);
|
|
54
|
+
|
|
55
|
+
> * {
|
|
56
|
+
color: var(--current-color);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
:where(.switch[data-checked]) :where(.knob) {
|
|
61
|
+
transform: translateX(calc(var(--current-minimum-size)));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
:where(.switch[data-checked]:dir(rtl)) :where(.knob) {
|
|
65
|
+
transform: translateX(calc(var(--current-minimum-size) * -1));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
:where(.label) {
|
|
69
|
+
font-size: var(--current-font-size);
|
|
70
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { BoxLook, BoxState } from "@sharadox/graphical-user-interface-web-library/box/type";
|
|
3
|
+
export interface SwitchProperties extends Pick<BoxLook, "color" | "colorStyle" | "corner" | "line" | "size"> {
|
|
4
|
+
/** What it turns on, beside it. */
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
/** Controlled: whether it is on. */
|
|
7
|
+
checked?: boolean;
|
|
8
|
+
/** Uncontrolled: whether it starts on. */
|
|
9
|
+
defaultChecked?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Called with the new value. It may answer later (a promise): the switch flips at once, is busy until then, and
|
|
12
|
+
* flips back when the answer is `false`.
|
|
13
|
+
*/
|
|
14
|
+
onChange?: (checked: boolean) => void | Promise<boolean | void>;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** Forces a state (for the design system). */
|
|
17
|
+
state?: BoxState;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/switch/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAC;AAEjG,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IAC1G,mCAAmC;IACnC,KAAK,EAAE,SAAS,CAAC;IACjB,oCAAoC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0CAA0C;IAC1C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/switch/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TextFieldProperties } from "@sharadox/graphical-user-interface-web-library/text-field/type";
|
|
2
|
+
/**
|
|
3
|
+
* A text field: its label, an outlined field box (middleground by default, the error color with an error) with
|
|
4
|
+
* optional prefix and suffix sections, and its hint and error under it. One line by default; `multiline` makes it a
|
|
5
|
+
* text area. Every look of a box applies, per breakpoint too.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <TextField label="Email" type="email" name="email" error={error} />
|
|
9
|
+
* <TextField label="Price" type="number" prefix="€" />
|
|
10
|
+
* <TextField label="Message" multiline rows={6} />
|
|
11
|
+
*/
|
|
12
|
+
export declare function TextField(properties: TextFieldProperties): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/text-field/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gEAAgE,CAAC;AAG1G;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,mBAAmB,+BAoDxD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { Field } from "@sharadox/graphical-user-interface-web-library/field";
|
|
5
|
+
import styles from "./index.module.css";
|
|
6
|
+
/**
|
|
7
|
+
* A text field: its label, an outlined field box (middleground by default, the error color with an error) with
|
|
8
|
+
* optional prefix and suffix sections, and its hint and error under it. One line by default; `multiline` makes it a
|
|
9
|
+
* text area. Every look of a box applies, per breakpoint too.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <TextField label="Email" type="email" name="email" error={error} />
|
|
13
|
+
* <TextField label="Price" type="number" prefix="€" />
|
|
14
|
+
* <TextField label="Message" multiline rows={6} />
|
|
15
|
+
*/
|
|
16
|
+
export function TextField(properties) {
|
|
17
|
+
const { label, hideLabel, hint, error, prefix, suffix, state, variant = "outlined", color, colorStyle, corner, line, size, className, multiline, id, ...control } = properties;
|
|
18
|
+
const disabled = Boolean(control.disabled);
|
|
19
|
+
return (_jsx(Field, { label: label, hideLabel: hideLabel, hint: hint, error: error, id: id, children: (attributes) => (_jsx(Box, { field: true, variant: variant, color: color ?? (error === undefined ? "middleground" : "error"), colorStyle: colorStyle, corner: corner, line: line, size: size, state: state ?? (disabled ? "disabled" : "enabled"), prefix: prefix, suffix: suffix, className: classNames(styles.field, multiline && styles.multiline, className), ...(multiline && { "data-multiline": "" }), children: multiline ? (_jsx("textarea", { rows: 3, ...control, ...attributes, className: styles.control })) : (_jsx("input", { type: "text", ...control, ...attributes, className: styles.control })) })) }));
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/text-field/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,oDAAoD,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,sDAAsD,CAAC;AAE7E,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CAAC,UAA+B;IACvD,MAAM,EACJ,KAAK,EACL,SAAS,EACT,IAAI,EACJ,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACL,OAAO,GAAG,UAAU,EACpB,KAAK,EACL,UAAU,EACV,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,SAAS,EACT,EAAE,EACF,GAAG,OAAO,EACX,GAAG,UAAU,CAAC;IACf,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3C,OAAO,CACL,KAAC,KAAK,IAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,YACxE,CAAC,UAAU,EAAE,EAAE,CAAC,CACf,KAAC,GAAG,IACF,KAAK,QACL,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,EAChE,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,EACnD,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,IAAI,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,KACzE,CAAC,SAAS,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC,YAE1C,SAAS,CAAC,CAAC,CAAC,CACX,mBACE,IAAI,EAAE,CAAC,KACF,OAAuD,KACxD,UAAU,EACd,SAAS,EAAE,MAAM,CAAC,OAAO,GACzB,CACH,CAAC,CAAC,CAAC,CACF,gBAAO,IAAI,EAAC,MAAM,KAAM,OAAkB,KAAM,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,OAAO,GAAI,CAC1F,GACG,CACP,GACK,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.control){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(.control)::placeholder{color:inherit;opacity:.6}:where(.control):disabled{cursor:default}:where(textarea.control){min-block-size:calc(var(--section-minimum-size)*2);padding-block:var(--scale-8);resize:vertical}:where(.multiline){align-items:stretch}:where(.field:not([data-variant=filled])) :where(.control){color:var(--current-hover-color)}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// The control fills the field box's content section and takes its looks: no border, background or outline of its
|
|
2
|
+
// own (the box draws them, and its focus ring circles the whole field).
|
|
3
|
+
:where(.control) {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
inline-size: 100%;
|
|
6
|
+
min-inline-size: 0;
|
|
7
|
+
min-block-size: var(--section-minimum-size);
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: 0;
|
|
10
|
+
border: 0;
|
|
11
|
+
outline: 0;
|
|
12
|
+
background: transparent;
|
|
13
|
+
// The box's text color: the color's own on a fill (its "on" color), so it always reads.
|
|
14
|
+
color: inherit;
|
|
15
|
+
font: inherit;
|
|
16
|
+
text-align: start;
|
|
17
|
+
|
|
18
|
+
&::placeholder {
|
|
19
|
+
color: inherit;
|
|
20
|
+
opacity: 0.6;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&:disabled {
|
|
24
|
+
cursor: default;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:where(textarea.control) {
|
|
29
|
+
min-block-size: calc(var(--section-minimum-size) * 2);
|
|
30
|
+
padding-block: var(--scale-8);
|
|
31
|
+
resize: vertical;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// A text area's sections sit at its top, beside the first line.
|
|
35
|
+
:where(.multiline) {
|
|
36
|
+
align-items: stretch;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Not filled, the typed text is the color's hovered text: foreground in a middleground field, the color otherwise.
|
|
40
|
+
:where(.field:not([data-variant="filled"])) :where(.control) {
|
|
41
|
+
color: var(--current-hover-color);
|
|
42
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode, TextareaHTMLAttributes } from "react";
|
|
2
|
+
import type { BoxLook, BoxState } from "@sharadox/graphical-user-interface-web-library/box/type";
|
|
3
|
+
/** What a text field shares, one line or many. */
|
|
4
|
+
interface TextFieldLook extends Pick<BoxLook, "variant" | "color" | "colorStyle" | "corner" | "line" | "size"> {
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
hideLabel?: boolean;
|
|
7
|
+
hint?: ReactNode;
|
|
8
|
+
/** What is wrong: the field turns to the error color and the input is marked invalid. */
|
|
9
|
+
error?: ReactNode;
|
|
10
|
+
/** A section before the input (a currency, an icon), at least square. */
|
|
11
|
+
prefix?: ReactNode;
|
|
12
|
+
/** A section after the input (a unit, a button), at least square. */
|
|
13
|
+
suffix?: ReactNode;
|
|
14
|
+
/** Forces a state (for the design system); otherwise it follows the pointer and `disabled`. */
|
|
15
|
+
state?: BoxState;
|
|
16
|
+
/** The field box's class (the label, hint and error sit around it). */
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
/** A text field: one line, or with `multiline` a text area. */
|
|
20
|
+
export type TextFieldProperties = (TextFieldLook & Omit<InputHTMLAttributes<HTMLInputElement>, "color" | "prefix" | "size"> & {
|
|
21
|
+
multiline?: false;
|
|
22
|
+
}) | (TextFieldLook & Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "color" | "prefix"> & {
|
|
23
|
+
/** Many lines: a text area, `rows` high (3 by default), growing taller by hand. */
|
|
24
|
+
multiline: true;
|
|
25
|
+
});
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/text-field/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAC;AAEjG,kDAAkD;AAClD,UAAU,aAAc,SAAQ,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IAC5G,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,yFAAyF;IACzF,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,yEAAyE;IACzE,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,qEAAqE;IACrE,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,+FAA+F;IAC/F,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,+DAA+D;AAC/D,MAAM,MAAM,mBAAmB,GAC3B,CAAC,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,GAClH,CAAC,aAAa,GACZ,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC,GAAG;IACtE,mFAAmF;IACnF,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/text-field/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ToggleMarkProperties } from "@sharadox/graphical-user-interface-web-library/toggle-mark/type";
|
|
2
|
+
/**
|
|
3
|
+
* A checkbox's or a radio's mark beside its label: the native input, invisible, lies over a square box drawn like a
|
|
4
|
+
* button (outlined, then filled once checked) holding a check (or a dot), so keyboards, forms and screen readers get
|
|
5
|
+
* the real control. Used by `Checkbox` and `RadioGroup`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <ToggleMark type="checkbox" label="Remember me" checked={on} onChange={setOn} />
|
|
9
|
+
*/
|
|
10
|
+
export declare function ToggleMark(properties: ToggleMarkProperties): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/toggle-mark/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iEAAiE,CAAC;AAG5G;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,oBAAoB,+BA6C1D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from "@sharadox/icon-web-library/icon";
|
|
3
|
+
import { classNames } from "@sharadox/web-library/class-name";
|
|
4
|
+
import { Box } from "@sharadox/graphical-user-interface-web-library/box";
|
|
5
|
+
import styles from "./index.module.css";
|
|
6
|
+
/**
|
|
7
|
+
* A checkbox's or a radio's mark beside its label: the native input, invisible, lies over a square box drawn like a
|
|
8
|
+
* button (outlined, then filled once checked) holding a check (or a dot), so keyboards, forms and screen readers get
|
|
9
|
+
* the real control. Used by `Checkbox` and `RadioGroup`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <ToggleMark type="checkbox" label="Remember me" checked={on} onChange={setOn} />
|
|
13
|
+
*/
|
|
14
|
+
export function ToggleMark(properties) {
|
|
15
|
+
const { type, label, checked, onChange, state, color = "brand", colorStyle, corner, line, size = "small", className, ...input } = properties;
|
|
16
|
+
return (_jsxs("label", { className: classNames(styles.toggle, className), "data-checked": checked || undefined, children: [_jsxs("span", { className: styles.control, children: [_jsx("input", { ...input, type: type, checked: checked, onChange: (event) => onChange(event.target.checked), className: styles.native }), _jsx(Box, { as: "span", square: true, interactive: true, variant: checked ? "filled" : "outlined", color: color, colorStyle: colorStyle, corner: corner ?? (type === "radio" ? "circle" : undefined), line: line, size: size, state: state ?? (input.disabled ? "disabled" : "enabled"), "aria-hidden": "true", className: styles.mark, children: type === "checkbox" ? _jsx(Icon, { name: "check", strokeWidth: 2.5 }) : _jsx("span", { className: styles.dot }) })] }), _jsx("span", { className: styles.label, children: label })] }));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/toggle-mark/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AACvD,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,UAAU,CAAC,UAAgC;IACzD,MAAM,EACJ,IAAI,EACJ,KAAK,EACL,OAAO,EACP,QAAQ,EACR,KAAK,EACL,KAAK,GAAG,OAAO,EACf,UAAU,EACV,MAAM,EACN,IAAI,EACJ,IAAI,GAAG,OAAO,EACd,SAAS,EACT,GAAG,KAAK,EACT,GAAG,UAAU,CAAC;IACf,OAAO,CACL,iBAAO,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,kBAAgB,OAAO,IAAI,SAAS,aACxF,gBAAM,SAAS,EAAE,MAAM,CAAC,OAAO,aAC7B,mBACM,KAAK,EACT,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,EACnD,SAAS,EAAE,MAAM,CAAC,MAAM,GACxB,EACF,KAAC,GAAG,IACF,EAAE,EAAC,MAAM,EACT,MAAM,QACN,WAAW,QACX,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,EACxC,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,EAC3D,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,iBAC7C,MAAM,EAClB,SAAS,EAAE,MAAM,CAAC,IAAI,YAErB,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAE,GAAG,GAAI,CAAC,CAAC,CAAC,eAAM,SAAS,EAAE,MAAM,CAAC,GAAG,GAAI,GAC5F,IACD,EACP,eAAM,SAAS,EAAE,MAAM,CAAC,KAAK,YAAG,KAAK,GAAQ,IACvC,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.toggle){display:inline-flex;align-items:center;gap:var(--scale-8);cursor:pointer;text-align:start}:where(.control){position:relative;display:inline-flex;flex:none}:where(.native){position:absolute;z-index:1;inset:0;margin:0;opacity:0;cursor:inherit}:where(.native):disabled{cursor:default}:where(.toggle:has(.native:disabled)){cursor:default}:where(.native:focus-visible+.mark){outline:var(--focus-thickness) solid var(--current-color);outline-offset:var(--focus-offset)}:where(.mark)>*>:where(svg,.dot){transform:scale(0);transition:transform var(--duration) var(--easing)}:where(.toggle[data-checked] .mark)>*>:where(svg,.dot){transform:scale(1)}:where(.dot){inline-size:.5em;block-size:.5em;border-radius:var(--corner-radius);background:currentcolor}:where(.label){font-size:var(--current-font-size)}
|