@sharadox/graphical-user-interface-web-library 0.1.0 → 0.2.0-fields.6

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.
Files changed (67) hide show
  1. package/README.md +23 -0
  2. package/distribution/box/index.d.ts.map +1 -1
  3. package/distribution/box/index.js +5 -2
  4. package/distribution/box/index.js.map +1 -1
  5. package/distribution/box/index.module.css +1 -1
  6. package/distribution/box/index.module.scss +28 -0
  7. package/distribution/box/type.d.ts +5 -0
  8. package/distribution/box/type.d.ts.map +1 -1
  9. package/distribution/checkbox/index.d.ts +10 -0
  10. package/distribution/checkbox/index.d.ts.map +1 -0
  11. package/distribution/checkbox/index.js +21 -0
  12. package/distribution/checkbox/index.js.map +1 -0
  13. package/distribution/checkbox/type.d.ts +9 -0
  14. package/distribution/checkbox/type.d.ts.map +1 -0
  15. package/distribution/checkbox/type.js +2 -0
  16. package/distribution/checkbox/type.js.map +1 -0
  17. package/distribution/field/index.d.ts +11 -0
  18. package/distribution/field/index.d.ts.map +1 -0
  19. package/distribution/field/index.js +26 -0
  20. package/distribution/field/index.js.map +1 -0
  21. package/distribution/field/index.module.css +1 -0
  22. package/distribution/field/index.module.scss +21 -0
  23. package/distribution/field/type.d.ts +23 -0
  24. package/distribution/field/type.d.ts.map +1 -0
  25. package/distribution/field/type.js +2 -0
  26. package/distribution/field/type.js.map +1 -0
  27. package/distribution/radio-group/index.d.ts +11 -0
  28. package/distribution/radio-group/index.d.ts.map +1 -0
  29. package/distribution/radio-group/index.js +27 -0
  30. package/distribution/radio-group/index.js.map +1 -0
  31. package/distribution/radio-group/index.module.css +1 -0
  32. package/distribution/radio-group/index.module.scss +10 -0
  33. package/distribution/radio-group/type.d.ts +25 -0
  34. package/distribution/radio-group/type.d.ts.map +1 -0
  35. package/distribution/radio-group/type.js +2 -0
  36. package/distribution/radio-group/type.js.map +1 -0
  37. package/distribution/switch/index.d.ts +11 -0
  38. package/distribution/switch/index.d.ts.map +1 -0
  39. package/distribution/switch/index.js +44 -0
  40. package/distribution/switch/index.js.map +1 -0
  41. package/distribution/switch/index.module.css +1 -0
  42. package/distribution/switch/index.module.scss +67 -0
  43. package/distribution/switch/type.d.ts +20 -0
  44. package/distribution/switch/type.d.ts.map +1 -0
  45. package/distribution/switch/type.js +2 -0
  46. package/distribution/switch/type.js.map +1 -0
  47. package/distribution/text-field/index.d.ts +13 -0
  48. package/distribution/text-field/index.d.ts.map +1 -0
  49. package/distribution/text-field/index.js +20 -0
  50. package/distribution/text-field/index.js.map +1 -0
  51. package/distribution/text-field/index.module.css +1 -0
  52. package/distribution/text-field/index.module.scss +37 -0
  53. package/distribution/text-field/type.d.ts +27 -0
  54. package/distribution/text-field/type.d.ts.map +1 -0
  55. package/distribution/text-field/type.js +2 -0
  56. package/distribution/text-field/type.js.map +1 -0
  57. package/distribution/toggle-mark/index.d.ts +11 -0
  58. package/distribution/toggle-mark/index.d.ts.map +1 -0
  59. package/distribution/toggle-mark/index.js +18 -0
  60. package/distribution/toggle-mark/index.js.map +1 -0
  61. package/distribution/toggle-mark/index.module.css +1 -0
  62. package/distribution/toggle-mark/index.module.scss +57 -0
  63. package/distribution/toggle-mark/type.d.ts +13 -0
  64. package/distribution/toggle-mark/type.d.ts.map +1 -0
  65. package/distribution/toggle-mark/type.js +2 -0
  66. package/distribution/toggle-mark/type.js.map +1 -0
  67. package/package.json +14 -16
package/README.md CHANGED
@@ -90,6 +90,12 @@ 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 |
93
99
 
94
100
  ### Box
95
101
 
@@ -141,6 +147,23 @@ replaces the words and keeps their size. Hover and pressed looks never apply whi
141
147
  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
148
  filled in brand by default. A disabled link loses its address.
143
149
 
150
+ ### Form controls
151
+
152
+ ```tsx
153
+ <TextField label="Email" type="email" name="email" hint="We never share it." error={error} />
154
+ <TextField label="Price" type="number" prefix="€" suffix=".00" />
155
+ <TextField label="Message" multiline rows={6} />
156
+ <Checkbox label="Remember me" name="remember" />
157
+ <RadioGroup label="Contact me by" name="contact" options={[{ value: "email", label: "Email" }]} />
158
+ <Switch label="Email me" defaultChecked onChange={async (on) => (await save(on)).ok} />
159
+ ```
160
+
161
+ A field box (`Box field`) is interactive with a text cursor and the field's font weight. Its focus ring circles the
162
+ whole field, and a line parts each prefix and suffix from the input. Text fields are outlined middleground by
163
+ default, and switch to the error color when they have an error. The typed text is the color's hovered text, so
164
+ foreground on middleground. Checkboxes and radios are drawn like buttons: outlined, then filled once checked. The
165
+ knob and checks move in 0.25 s.
166
+
144
167
  ## Develop
145
168
 
146
169
  `pnpm verify` runs formatting, lint, type-check, tests with 100% coverage, benchmarks and the build. Branches follow
@@ -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,+BA0C5C"}
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, interactive, state, className, children, ...rest } = properties;
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,g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AC,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":"type.d.ts","sourceRoot":"","sources":["../../source/box/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gEAAgE,CAAC;AAEjG,uFAAuF;AACvF,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,aAAa,GAAG,QAAQ,CAAC;AAC1E,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG,eAAe,GAAG,eAAe,GAAG,eAAe,CAAC;AACjG,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,eAAe,CAAC;AACzF,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,CAAC;AAC3E,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AACzE,sCAAsC;AACtC,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;AACtE,4GAA4G;AAC5G,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE/E,yEAAyE;AACzE,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IACjC,0GAA0G;IAC1G,KAAK,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;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AAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC1B,wDAAwD;IACxD,IAAI,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC1B,SAAS,CAAC,EAAE,UAAU,CAAC,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,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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -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,KAAK,EAAE,CAAC;IACrB,MAAM,SAAS,GAAG,EAAE,IAAI,IAAI,CAAC;IAC7B,MAAM,MAAM,GAAG,GAAG,SAAS,OAAO,CAAC;IACnC,MAAM,OAAO,GAAG,GAAG,SAAS,QAAQ,CAAC;IACrC,MAAM,WAAW,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,EAAE,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7G,MAAM,OAAO,GAAiB;QAC5B,EAAE,EAAE,SAAS;QACb,GAAG,CAAC,WAAW,IAAI,EAAE,kBAAkB,EAAE,WAAW,EAAE,CAAC;QACvD,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;KACrD,CAAC;IACF,OAAO,CACL,MAAC,GAAG,IAAC,SAAS,EAAC,eAAe,EAAC,KAAK,EAAC,SAAS,EAAC,SAAS,EAAC,OAAO,EAAC,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,SAAS,aAC3F,gBAAO,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,KAAM,CAAC,SAAS,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,YACzF,KAAK,GACA,EACP,QAAQ,CAAC,OAAO,CAAC,EACjB,IAAI,KAAK,SAAS,IAAI,CACrB,KAAC,GAAG,IAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAC,cAAc,EAAC,OAAO,EAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAC,SAAS,EAAE,MAAM,CAAC,OAAO,YACrG,IAAI,GACD,CACP,EACA,KAAK,KAAK,SAAS,IAAI,CACtB,KAAC,GAAG,IAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAC,OAAO,EAAC,OAAO,EAAC,OAAO,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
+ }
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -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,EAA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AAI,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,10 @@
1
+ :where(.label) {
2
+ font-size: var(--current-font-size);
3
+ font-weight: var(--current-font-weight);
4
+ }
5
+
6
+ :where(.error) {
7
+ margin: 0;
8
+ color: var(--current-color);
9
+ font-size: var(--scale-12);
10
+ }
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -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 { 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,GA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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(.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(.track)>*{flex:none}: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,67 @@
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.
29
+ :where(.track) {
30
+ justify-content: start;
31
+ inline-size: calc(var(--current-minimum-size) * 2);
32
+ min-inline-size: calc(var(--current-minimum-size) * 2);
33
+ padding: var(--line-thickness);
34
+ }
35
+
36
+ :where(.track) > * {
37
+ // Boxes wrap their children in a section only with sections; the knob sits directly in the track.
38
+ flex: none;
39
+ }
40
+
41
+ :where(.knob) {
42
+ display: flex;
43
+ justify-content: center;
44
+ align-items: center;
45
+ inline-size: calc(var(--current-minimum-size) - 4 * var(--line-thickness));
46
+ block-size: calc(var(--current-minimum-size) - 4 * var(--line-thickness));
47
+ border-radius: var(--corner-radius);
48
+ background: currentcolor;
49
+ font-size: 0.6em;
50
+ transition: transform var(--duration) var(--easing);
51
+
52
+ > * {
53
+ color: var(--current-color);
54
+ }
55
+ }
56
+
57
+ :where(.switch[data-checked]) :where(.knob) {
58
+ transform: translateX(calc(var(--current-minimum-size)));
59
+ }
60
+
61
+ :where(.switch[data-checked]:dir(rtl)) :where(.knob) {
62
+ transform: translateX(calc(var(--current-minimum-size) * -1));
63
+ }
64
+
65
+ :where(.label) {
66
+ font-size: var(--current-font-size);
67
+ }
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -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":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gEAAgE,CAAC;AAG1G;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,mBAAmB,+BAoDxD"}
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box } from "@sharadox/graphical-user-interface-web-library/box";
3
+ import { Field } from "@sharadox/graphical-user-interface-web-library/field";
4
+ import styles from "./index.module.css";
5
+ /**
6
+ * A text field: its label, an outlined field box (middleground by default, the error color with an error) with
7
+ * optional prefix and suffix sections, and its hint and error under it. One line by default; `multiline` makes it a
8
+ * text area. Every look of a box applies, per breakpoint too.
9
+ *
10
+ * @example
11
+ * <TextField label="Email" type="email" name="email" error={error} />
12
+ * <TextField label="Price" type="number" prefix="€" />
13
+ * <TextField label="Message" multiline rows={6} />
14
+ */
15
+ export function TextField(properties) {
16
+ const { label, hideLabel, hint, error, prefix, suffix, state, variant = "outlined", color, colorStyle, corner, line, size, className, multiline, id, ...control } = properties;
17
+ const disabled = Boolean(control.disabled);
18
+ 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: className, ...(multiline && { "data-multiline": "" }), children: multiline ? (_jsx("textarea", { rows: 3, ...control, ...attributes, className: styles.control })) : (_jsx("input", { type: "text", ...control, ...attributes, className: styles.control })) })) }));
19
+ }
20
+ //# 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,GAAG,EAAE,MAAM,oDAAoD,CAAC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M,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:var(--current-hover-color);font:inherit;text-align:start}:where(.control)::placeholder{color:var(--current-color);opacity:.7}: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([data-multiline]){align-items:stretch}
@@ -0,0 +1,37 @@
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 typed text is its color's hovered text: foreground for middleground, the color itself otherwise.
14
+ color: var(--current-hover-color);
15
+ font: inherit;
16
+ text-align: start;
17
+
18
+ &::placeholder {
19
+ color: var(--current-color);
20
+ opacity: 0.7;
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([data-multiline]) {
36
+ align-items: stretch;
37
+ }
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -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,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,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)}
@@ -0,0 +1,57 @@
1
+ :where(.toggle) {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ gap: var(--scale-8);
5
+ cursor: pointer;
6
+ text-align: start;
7
+ }
8
+
9
+ :where(.control) {
10
+ position: relative;
11
+ display: inline-flex;
12
+ flex: none;
13
+ }
14
+
15
+ // The real input, invisible, over the drawn mark: it takes the clicks, the keyboard and the form.
16
+ :where(.native) {
17
+ position: absolute;
18
+ z-index: 1;
19
+ inset: 0;
20
+ margin: 0;
21
+ opacity: 0;
22
+ cursor: inherit;
23
+
24
+ &:disabled {
25
+ cursor: default;
26
+ }
27
+ }
28
+
29
+ :where(.toggle:has(.native:disabled)) {
30
+ cursor: default;
31
+ }
32
+
33
+ :where(.native:focus-visible + .mark) {
34
+ outline: var(--focus-thickness) solid var(--current-color);
35
+ outline-offset: var(--focus-offset);
36
+ }
37
+
38
+ // The check (or dot) grows in when checked and shrinks away when not.
39
+ :where(.mark) > * > :where(svg, .dot) {
40
+ transform: scale(0);
41
+ transition: transform var(--duration) var(--easing);
42
+ }
43
+
44
+ :where(.toggle[data-checked] .mark) > * > :where(svg, .dot) {
45
+ transform: scale(1);
46
+ }
47
+
48
+ :where(.dot) {
49
+ inline-size: 0.5em;
50
+ block-size: 0.5em;
51
+ border-radius: var(--corner-radius);
52
+ background: currentcolor;
53
+ }
54
+
55
+ :where(.label) {
56
+ font-size: var(--current-font-size);
57
+ }
@@ -0,0 +1,13 @@
1
+ import type { InputHTMLAttributes, ReactNode } from "react";
2
+ import type { BoxLook, BoxState } from "@sharadox/graphical-user-interface-web-library/box/type";
3
+ /** A checkbox's or a radio's mark and label. */
4
+ export interface ToggleMarkProperties extends Pick<BoxLook, "color" | "colorStyle" | "corner" | "line" | "size">, Omit<InputHTMLAttributes<HTMLInputElement>, "color" | "size" | "type" | "onChange" | "checked" | "defaultChecked"> {
5
+ type: "checkbox" | "radio";
6
+ label: ReactNode;
7
+ /** Whether it is checked (the owner keeps the state). */
8
+ checked: boolean;
9
+ onChange: (checked: boolean) => void;
10
+ /** Forces a state (for the design system). */
11
+ state?: BoxState;
12
+ }
13
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/toggle-mark/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAC;AAEjG,gDAAgD;AAChD,MAAM,WAAW,oBACf,SACE,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC,EAClE,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,gBAAgB,CAAC;IACpH,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC;IAC3B,KAAK,EAAE,SAAS,CAAC;IACjB,yDAAyD;IACzD,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,8CAA8C;IAC9C,KAAK,CAAC,EAAE,QAAQ,CAAC;CAClB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/toggle-mark/type.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sharadox/graphical-user-interface-web-library",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-fields.6",
4
4
  "description": "One generic, accessible, fully configurable component library: every interface piece in every variant, color, corner, line, size and state, styled from a single source of truth that each brand configures.",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN LICENCA.md",
@@ -32,7 +32,6 @@
32
32
  "engines": {
33
33
  "node": ">=26"
34
34
  },
35
- "packageManager": "pnpm@10.34.9",
36
35
  "publishConfig": {
37
36
  "access": "public"
38
37
  },
@@ -45,18 +44,6 @@
45
44
  "optional": true
46
45
  }
47
46
  },
48
- "scripts": {
49
- "build": "library-build",
50
- "lint": "eslint --max-warnings=0 .",
51
- "format": "prettier --write .",
52
- "format:check": "prettier --check .",
53
- "type-check": "tsc --noEmit",
54
- "test:unit": "vitest run --coverage",
55
- "test:benchmark": "vitest bench --run --passWithNoTests",
56
- "documentation": "typedoc",
57
- "verify": "turbo run format:check lint type-check test:unit test:benchmark build",
58
- "prepare": "turborepo-configuration library && (husky || true)"
59
- },
60
47
  "lint-staged": {
61
48
  "*.{ts,tsx,js,mjs,cjs}": [
62
49
  "prettier --write",
@@ -100,5 +87,16 @@
100
87
  "type": "git",
101
88
  "url": "git+https://github.com/Sharadox/graphical-user-interface-web-library.git"
102
89
  },
103
- "homepage": "https://github.com/Sharadox/graphical-user-interface-web-library#readme"
104
- }
90
+ "homepage": "https://github.com/Sharadox/graphical-user-interface-web-library#readme",
91
+ "scripts": {
92
+ "build": "library-build",
93
+ "lint": "eslint --max-warnings=0 .",
94
+ "format": "prettier --write .",
95
+ "format:check": "prettier --check .",
96
+ "type-check": "tsc --noEmit",
97
+ "test:unit": "vitest run --coverage",
98
+ "test:benchmark": "vitest bench --run --passWithNoTests",
99
+ "documentation": "typedoc",
100
+ "verify": "turbo run format:check lint type-check test:unit test:benchmark build"
101
+ }
102
+ }