@nizivo/react 0.0.0-stage → 0.1.0

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 (258) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +120 -2
  3. package/THIRD_PARTY_NOTICES +61 -0
  4. package/dist/_engines/react-aria/dialog.client.js +134 -0
  5. package/dist/_engines/react-aria/dom-allowlist.js +19 -0
  6. package/dist/_engines/react-aria/dom.js +31 -0
  7. package/dist/_engines/react-aria/locale.client.js +13 -0
  8. package/dist/_engines/react-aria/menu.client.js +225 -0
  9. package/dist/_engines/react-aria/overlay.client.js +41 -0
  10. package/dist/_engines/react-aria/popup.client.js +127 -0
  11. package/dist/_engines/react-aria/select.client.js +170 -0
  12. package/dist/_engines/react-aria/tabs.client.js +95 -0
  13. package/dist/_engines/react-aria/tooltip.client.js +72 -0
  14. package/dist/_internal/cx.js +11 -0
  15. package/dist/_internal/engine-part.d.ts +1 -0
  16. package/dist/_internal/field.js +20 -0
  17. package/dist/_internal/glyphs.js +34 -0
  18. package/dist/_internal/keys.js +62 -0
  19. package/dist/_internal/overlay.d.ts +9 -0
  20. package/dist/_virtual/_rolldown/runtime.js +13 -0
  21. package/dist/alert/alert-dismiss.client.d.ts +32 -0
  22. package/dist/alert/alert-dismiss.client.js +36 -0
  23. package/dist/alert/alert.d.ts +28 -0
  24. package/dist/alert/alert.js +44 -0
  25. package/dist/alert/index.d.ts +3 -0
  26. package/dist/alert/index.js +3 -0
  27. package/dist/augment.d.ts +13 -0
  28. package/dist/augment.js +0 -0
  29. package/dist/badge/badge.d.ts +19 -0
  30. package/dist/badge/badge.js +22 -0
  31. package/dist/badge/index.d.ts +2 -0
  32. package/dist/badge/index.js +1 -0
  33. package/dist/button/button.d.ts +54 -0
  34. package/dist/button/button.js +62 -0
  35. package/dist/button/index.d.ts +2 -0
  36. package/dist/button/index.js +1 -0
  37. package/dist/card/card.d.ts +57 -0
  38. package/dist/card/card.js +62 -0
  39. package/dist/card/card.parts.d.ts +6 -0
  40. package/dist/card/card.parts.js +14 -0
  41. package/dist/card/index.d.ts +3 -0
  42. package/dist/card/index.js +3 -0
  43. package/dist/checkbox/checkbox.client.d.ts +37 -0
  44. package/dist/checkbox/checkbox.client.js +81 -0
  45. package/dist/checkbox/index.d.ts +2 -0
  46. package/dist/checkbox/index.js +1 -0
  47. package/dist/config/config.client.d.ts +9 -0
  48. package/dist/config/config.client.js +18 -0
  49. package/dist/config/index.d.ts +2 -0
  50. package/dist/config/index.js +1 -0
  51. package/dist/container/container.d.ts +13 -0
  52. package/dist/container/container.js +16 -0
  53. package/dist/container/index.d.ts +2 -0
  54. package/dist/container/index.js +1 -0
  55. package/dist/contracts/details.d.ts +13 -0
  56. package/dist/contracts/details.js +9 -0
  57. package/dist/contracts/index.d.ts +5 -0
  58. package/dist/contracts/index.js +5 -0
  59. package/dist/contracts/merge-props.d.ts +16 -0
  60. package/dist/contracts/merge-props.js +76 -0
  61. package/dist/contracts/render.d.ts +17 -0
  62. package/dist/contracts/render.js +43 -0
  63. package/dist/contracts/state.d.ts +42 -0
  64. package/dist/contracts/state.js +42 -0
  65. package/dist/css/alert.css +2 -0
  66. package/dist/css/badge.css +2 -0
  67. package/dist/css/base.css +2 -0
  68. package/dist/css/button.css +2 -0
  69. package/dist/css/card.css +2 -0
  70. package/dist/css/checkbox.css +2 -0
  71. package/dist/css/container.css +2 -0
  72. package/dist/css/delta.css +2 -0
  73. package/dist/css/dialog.css +2 -0
  74. package/dist/css/empty-state.css +2 -0
  75. package/dist/css/field.css +2 -0
  76. package/dist/css/fieldset.css +2 -0
  77. package/dist/css/grid.css +2 -0
  78. package/dist/css/heading.css +2 -0
  79. package/dist/css/icon-button.css +2 -0
  80. package/dist/css/image.css +2 -0
  81. package/dist/css/inline-error.css +2 -0
  82. package/dist/css/inline.css +2 -0
  83. package/dist/css/input.css +2 -0
  84. package/dist/css/kbd.css +2 -0
  85. package/dist/css/menu.css +2 -0
  86. package/dist/css/meter.css +2 -0
  87. package/dist/css/native-select.css +2 -0
  88. package/dist/css/progress-bar.css +2 -0
  89. package/dist/css/progress-ring.css +2 -0
  90. package/dist/css/radio-group.css +2 -0
  91. package/dist/css/segmented-control.css +2 -0
  92. package/dist/css/select.css +2 -0
  93. package/dist/css/separator.css +2 -0
  94. package/dist/css/skeleton.css +2 -0
  95. package/dist/css/stack.css +2 -0
  96. package/dist/css/switch.css +2 -0
  97. package/dist/css/tab-nav.css +2 -0
  98. package/dist/css/tabs.css +2 -0
  99. package/dist/css/text.css +2 -0
  100. package/dist/css/textarea.css +2 -0
  101. package/dist/css/tooltip.css +2 -0
  102. package/dist/delta/delta.d.ts +32 -0
  103. package/dist/delta/delta.js +50 -0
  104. package/dist/delta/index.d.ts +2 -0
  105. package/dist/delta/index.js +1 -0
  106. package/dist/dialog/dialog.client.d.ts +25 -0
  107. package/dist/dialog/dialog.client.js +167 -0
  108. package/dist/dialog/dialog.contract.d.ts +97 -0
  109. package/dist/dialog/dialog.parts.d.ts +6 -0
  110. package/dist/dialog/dialog.parts.js +15 -0
  111. package/dist/dialog/index.d.ts +5 -0
  112. package/dist/dialog/index.js +3 -0
  113. package/dist/empty-state/empty-state.d.ts +18 -0
  114. package/dist/empty-state/empty-state.js +32 -0
  115. package/dist/empty-state/index.d.ts +2 -0
  116. package/dist/empty-state/index.js +1 -0
  117. package/dist/field/field-scope.client.d.ts +50 -0
  118. package/dist/field/field-scope.client.js +205 -0
  119. package/dist/field/field-static.d.ts +122 -0
  120. package/dist/field/field-static.js +159 -0
  121. package/dist/field/field.d.ts +5 -0
  122. package/dist/field/field.js +53 -0
  123. package/dist/field/index.d.ts +4 -0
  124. package/dist/field/index.js +4 -0
  125. package/dist/fieldset/fieldset.d.ts +36 -0
  126. package/dist/fieldset/fieldset.js +63 -0
  127. package/dist/fieldset/index.d.ts +2 -0
  128. package/dist/fieldset/index.js +1 -0
  129. package/dist/grid/grid.d.ts +38 -0
  130. package/dist/grid/grid.js +28 -0
  131. package/dist/grid/index.d.ts +2 -0
  132. package/dist/grid/index.js +1 -0
  133. package/dist/heading/heading.d.ts +27 -0
  134. package/dist/heading/heading.js +26 -0
  135. package/dist/heading/index.d.ts +2 -0
  136. package/dist/heading/index.js +1 -0
  137. package/dist/icon-button/icon-button-static.d.ts +23 -0
  138. package/dist/icon-button/icon-button-static.js +83 -0
  139. package/dist/icon-button/icon-button.client.js +29 -0
  140. package/dist/icon-button/icon-button.contract.d.ts +89 -0
  141. package/dist/icon-button/icon-button.d.ts +5 -0
  142. package/dist/icon-button/icon-button.js +21 -0
  143. package/dist/icon-button/index.d.ts +4 -0
  144. package/dist/icon-button/index.js +3 -0
  145. package/dist/image/image.d.ts +28 -0
  146. package/dist/image/image.js +24 -0
  147. package/dist/image/index.d.ts +2 -0
  148. package/dist/image/index.js +1 -0
  149. package/dist/index.d.ts +95 -0
  150. package/dist/index.js +51 -0
  151. package/dist/inline/index.d.ts +2 -0
  152. package/dist/inline/index.js +1 -0
  153. package/dist/inline/inline.d.ts +16 -0
  154. package/dist/inline/inline.js +14 -0
  155. package/dist/inline-error/index.d.ts +2 -0
  156. package/dist/inline-error/index.js +1 -0
  157. package/dist/inline-error/inline-error.d.ts +17 -0
  158. package/dist/inline-error/inline-error.js +33 -0
  159. package/dist/input/index.d.ts +2 -0
  160. package/dist/input/index.js +1 -0
  161. package/dist/input/input.client.d.ts +39 -0
  162. package/dist/input/input.client.js +82 -0
  163. package/dist/kbd/index.d.ts +2 -0
  164. package/dist/kbd/index.js +1 -0
  165. package/dist/kbd/kbd.d.ts +19 -0
  166. package/dist/kbd/kbd.js +68 -0
  167. package/dist/menu/index.d.ts +5 -0
  168. package/dist/menu/index.js +3 -0
  169. package/dist/menu/menu.client.d.ts +14 -0
  170. package/dist/menu/menu.client.js +152 -0
  171. package/dist/menu/menu.contract.d.ts +152 -0
  172. package/dist/menu/menu.parts.d.ts +6 -0
  173. package/dist/menu/menu.parts.js +17 -0
  174. package/dist/meter/index.d.ts +2 -0
  175. package/dist/meter/index.js +1 -0
  176. package/dist/meter/meter.d.ts +43 -0
  177. package/dist/meter/meter.js +59 -0
  178. package/dist/native-select/index.d.ts +2 -0
  179. package/dist/native-select/index.js +1 -0
  180. package/dist/native-select/native-select.d.ts +43 -0
  181. package/dist/native-select/native-select.js +56 -0
  182. package/dist/progress-bar/index.d.ts +2 -0
  183. package/dist/progress-bar/index.js +1 -0
  184. package/dist/progress-bar/progress-bar.d.ts +34 -0
  185. package/dist/progress-bar/progress-bar.js +55 -0
  186. package/dist/progress-ring/index.d.ts +2 -0
  187. package/dist/progress-ring/index.js +1 -0
  188. package/dist/progress-ring/progress-ring.d.ts +38 -0
  189. package/dist/progress-ring/progress-ring.js +67 -0
  190. package/dist/radio-group/index.d.ts +3 -0
  191. package/dist/radio-group/index.js +3 -0
  192. package/dist/radio-group/radio-group.client.d.ts +22 -0
  193. package/dist/radio-group/radio-group.client.js +70 -0
  194. package/dist/radio-group/radio-group.d.ts +28 -0
  195. package/dist/radio-group/radio-group.js +35 -0
  196. package/dist/segmented-control/index.d.ts +3 -0
  197. package/dist/segmented-control/index.js +3 -0
  198. package/dist/segmented-control/segmented-control.client.d.ts +61 -0
  199. package/dist/segmented-control/segmented-control.client.js +156 -0
  200. package/dist/segmented-control/segmented-control.parts.d.ts +6 -0
  201. package/dist/segmented-control/segmented-control.parts.js +9 -0
  202. package/dist/select/index.d.ts +5 -0
  203. package/dist/select/index.js +3 -0
  204. package/dist/select/select.client.d.ts +12 -0
  205. package/dist/select/select.client.js +152 -0
  206. package/dist/select/select.contract.d.ts +119 -0
  207. package/dist/select/select.parts.d.ts +6 -0
  208. package/dist/select/select.parts.js +15 -0
  209. package/dist/separator/index.d.ts +2 -0
  210. package/dist/separator/index.js +1 -0
  211. package/dist/separator/separator.d.ts +26 -0
  212. package/dist/separator/separator.js +23 -0
  213. package/dist/skeleton/index.d.ts +2 -0
  214. package/dist/skeleton/index.js +1 -0
  215. package/dist/skeleton/skeleton.d.ts +20 -0
  216. package/dist/skeleton/skeleton.js +19 -0
  217. package/dist/stack/index.d.ts +2 -0
  218. package/dist/stack/index.js +1 -0
  219. package/dist/stack/stack.d.ts +17 -0
  220. package/dist/stack/stack.js +14 -0
  221. package/dist/styles.css +536 -0
  222. package/dist/switch/index.d.ts +2 -0
  223. package/dist/switch/index.js +1 -0
  224. package/dist/switch/switch.client.d.ts +33 -0
  225. package/dist/switch/switch.client.js +63 -0
  226. package/dist/tab-nav/index.d.ts +3 -0
  227. package/dist/tab-nav/index.js +3 -0
  228. package/dist/tab-nav/tab-nav.d.ts +36 -0
  229. package/dist/tab-nav/tab-nav.js +47 -0
  230. package/dist/tab-nav/tab-nav.parts.d.ts +6 -0
  231. package/dist/tab-nav/tab-nav.parts.js +9 -0
  232. package/dist/tabs/index.d.ts +4 -0
  233. package/dist/tabs/index.js +3 -0
  234. package/dist/tabs/tabs.client.d.ts +8 -0
  235. package/dist/tabs/tabs.client.js +68 -0
  236. package/dist/tabs/tabs.contract.d.ts +89 -0
  237. package/dist/tabs/tabs.parts.d.ts +6 -0
  238. package/dist/tabs/tabs.parts.js +11 -0
  239. package/dist/text/index.d.ts +2 -0
  240. package/dist/text/index.js +1 -0
  241. package/dist/text/text.d.ts +21 -0
  242. package/dist/text/text.js +17 -0
  243. package/dist/textarea/index.d.ts +2 -0
  244. package/dist/textarea/index.js +1 -0
  245. package/dist/textarea/textarea.client.d.ts +18 -0
  246. package/dist/textarea/textarea.client.js +31 -0
  247. package/dist/theme-script/index.d.ts +2 -0
  248. package/dist/theme-script/index.js +1 -0
  249. package/dist/theme-script/theme-script.d.ts +43 -0
  250. package/dist/theme-script/theme-script.js +46 -0
  251. package/dist/tooltip/index.d.ts +5 -0
  252. package/dist/tooltip/index.js +3 -0
  253. package/dist/tooltip/tooltip.client.d.ts +12 -0
  254. package/dist/tooltip/tooltip.client.js +51 -0
  255. package/dist/tooltip/tooltip.contract.d.ts +60 -0
  256. package/dist/tooltip/tooltip.parts.d.ts +6 -0
  257. package/dist/tooltip/tooltip.parts.js +10 -0
  258. package/package.json +284 -3
@@ -0,0 +1,159 @@
1
+ import { cx } from "../_internal/cx.js";
2
+ import { renderElement } from "../contracts/render.js";
3
+ import { CircleXGlyph } from "../_internal/glyphs.js";
4
+ import { stateAttrs } from "../contracts/state.js";
5
+ import { joinIds, presented } from "../_internal/field.js";
6
+ import { InlineError } from "../inline-error/inline-error.js";
7
+ import { useId } from "react";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ //#region src/field/field-static.tsx
10
+ /**
11
+ * The Field anatomy with no client code: label, control, description and error, the same HTML and
12
+ * ids as `Field` with a function child (M31). Server-safe, and its module imports no client leaf,
13
+ * so a page that renders only FieldStatic ships no Field JavaScript in any bundler. It provides no
14
+ * context and no announcer, and native validation shows the browser's own bubble; the function
15
+ * child wires the control (FIELD-CONTRACT.md "FieldStatic").
16
+ */
17
+ function FieldStatic({ label, description, error, errorIcon, group = false, name, required = false, disabled = false, readOnly = false, ids, render, children, messages: _messages, validateOn: _validateOn, ...root }) {
18
+ const anatomy = {
19
+ ids: resolveIds(useId(), ids, void 0),
20
+ label,
21
+ group,
22
+ description,
23
+ error,
24
+ errorIcon,
25
+ required,
26
+ disabled,
27
+ readOnly,
28
+ render,
29
+ root
30
+ };
31
+ if (typeof children !== "function") throw new TypeError("FieldStatic: children must be a function; put an element in a Field");
32
+ return staticField(anatomy, name, children);
33
+ }
34
+ /** The ids of one Field: a directly placed control's own id, else `ids`, else generated. */
35
+ function resolveIds(base, ids, ownId) {
36
+ return {
37
+ control: ownId ?? ids?.control ?? `${base}-control`,
38
+ label: ids?.label ?? `${base}-label`,
39
+ description: ids?.description ?? `${base}-description`,
40
+ error: ids?.error ?? `${base}-error`
41
+ };
42
+ }
43
+ /**
44
+ * The zero-JS render, shared by FieldStatic and Field's function child: the control attributes and
45
+ * the wiring go to `control`, and the anatomy renders around what it returns, with no
46
+ * `data-validate-on` and no announcer.
47
+ */
48
+ function staticField(anatomy, name, control) {
49
+ const { ids, label, description, required, disabled, readOnly } = anatomy;
50
+ const invalid = presented(anatomy.error);
51
+ const described = describedBy(ids, description, invalid);
52
+ const attributes = fieldControlProps({
53
+ id: ids.control,
54
+ name,
55
+ required,
56
+ disabled,
57
+ readOnly,
58
+ invalid,
59
+ describedBy: described
60
+ });
61
+ const wiring = {
62
+ ids,
63
+ labelledBy: presented(label) ? ids.label : void 0,
64
+ describedBy: described,
65
+ invalid,
66
+ required,
67
+ disabled,
68
+ readOnly
69
+ };
70
+ const field = {
71
+ ...anatomy,
72
+ validateOn: void 0,
73
+ children: control(attributes, wiring)
74
+ };
75
+ return renderElement("div", anatomy.render, fieldState(field), {
76
+ ...fieldRootProps(field),
77
+ "data-slot": "field",
78
+ className: cx("nz-field", anatomy.root.className)
79
+ });
80
+ }
81
+ /** The state a Field's `render` function receives. */
82
+ function fieldState(anatomy) {
83
+ const { required, disabled, readOnly } = anatomy;
84
+ return {
85
+ invalid: presented(anatomy.error),
86
+ disabled,
87
+ required,
88
+ readOnly
89
+ };
90
+ }
91
+ /**
92
+ * The root props of the one DOM shape of a Field: label, control, description, error (§10.6).
93
+ * Every path renders it: FieldStatic and Field's function child (zero JS) and FieldScope (with its
94
+ * native message and announcer).
95
+ */
96
+ function fieldRootProps(anatomy) {
97
+ const { ids, label, description, error, required, disabled, readOnly, validateOn } = anatomy;
98
+ const invalid = presented(error);
99
+ return {
100
+ "data-slot": "field",
101
+ ...stateAttrs({
102
+ invalid,
103
+ disabled,
104
+ required,
105
+ readOnly
106
+ }),
107
+ "data-validate-on": validateOn,
108
+ ...anatomy.root,
109
+ className: cx("nz-field", anatomy.root.className),
110
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [
111
+ presented(label) && /* @__PURE__ */ jsxs("label", {
112
+ className: "nz-field-label",
113
+ "data-slot": "field-label",
114
+ id: ids.label,
115
+ htmlFor: anatomy.group ? void 0 : ids.control,
116
+ onClick: anatomy.onLabelClick,
117
+ children: [label, required && /* @__PURE__ */ jsx("span", {
118
+ className: "nz-field-required",
119
+ "data-slot": "field-required",
120
+ "aria-hidden": "true",
121
+ children: "*"
122
+ })]
123
+ }),
124
+ anatomy.children,
125
+ presented(description) && /* @__PURE__ */ jsx("div", {
126
+ className: "nz-field-description",
127
+ "data-slot": "field-description",
128
+ id: ids.description,
129
+ children: description
130
+ }),
131
+ invalid && /* @__PURE__ */ jsx(InlineError, {
132
+ className: "nz-field-error",
133
+ "data-slot": "field-error",
134
+ id: ids.error,
135
+ icon: anatomy.errorIcon ?? /* @__PURE__ */ jsx(CircleXGlyph, {}),
136
+ children: error
137
+ }),
138
+ anatomy.announcer
139
+ ] })
140
+ };
141
+ }
142
+ /** `aria-describedby` of the control: description, then error (§16.1). */
143
+ function describedBy(ids, description, invalid) {
144
+ return joinIds(presented(description) && ids.description, invalid && ids.error);
145
+ }
146
+ /** Control attributes; `false` flags and unknown values are left out, never set to `undefined`. */
147
+ function fieldControlProps(state) {
148
+ return {
149
+ ...state.id !== void 0 && { id: state.id },
150
+ ...state.name !== void 0 && { name: state.name },
151
+ ...state.required && { required: true },
152
+ ...state.disabled && { disabled: true },
153
+ ...state.readOnly && { readOnly: true },
154
+ ...state.describedBy !== void 0 && { "aria-describedby": state.describedBy },
155
+ ...state.invalid && { "aria-invalid": true }
156
+ };
157
+ }
158
+ //#endregion
159
+ export { FieldStatic, describedBy, fieldControlProps, fieldRootProps, fieldState, resolveIds, staticField };
@@ -0,0 +1,5 @@
1
+ import { FieldControlProps, FieldIds, FieldProps, FieldState, FieldValidateOn, FieldValidityKey } from "./field-static.js";
2
+ import { ReactElement } from "react";
3
+ //#region src/field/field.d.ts
4
+ export declare function Field({ label, description, error, errorIcon, group, name, required, disabled, readOnly, ids, messages, validateOn, render, children, ...root }: FieldProps): ReactElement;
5
+ //#endregion
@@ -0,0 +1,53 @@
1
+ import { FIELD_CONTROL, joinIds } from "../_internal/field.js";
2
+ import { resolveIds, staticField } from "./field-static.js";
3
+ import { FieldScope } from "./field-scope.client.js";
4
+ import { cloneElement, isValidElement, useId } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/field/field.tsx
7
+ function Field({ label, description, error, errorIcon, group = false, name, required = false, disabled = false, readOnly = false, ids, messages, validateOn = "submit", render, children, ...root }) {
8
+ const base = useId();
9
+ const wired = staticControl(children) ? children : void 0;
10
+ const ownId = wired?.props["id"];
11
+ const anatomy = {
12
+ ids: resolveIds(base, ids, typeof ownId === "string" ? ownId : void 0),
13
+ label,
14
+ group,
15
+ description,
16
+ error,
17
+ errorIcon,
18
+ required,
19
+ disabled,
20
+ readOnly,
21
+ render,
22
+ root
23
+ };
24
+ if (typeof children === "function") return staticField(anatomy, name, children);
25
+ if (wired !== void 0) return staticField(anatomy, name, (control) => cloneElement(wired, fill(control, wired.props)));
26
+ return /* @__PURE__ */ jsx(FieldScope, {
27
+ anatomy: {
28
+ ...anatomy,
29
+ validateOn
30
+ },
31
+ name,
32
+ messages,
33
+ children
34
+ });
35
+ }
36
+ /** A server-safe control (NativeSelect) that takes the zero-JS wiring as plain props. */
37
+ function staticControl(children) {
38
+ return isValidElement(children) && typeof children.type === "function" && Object.hasOwn(children.type, FIELD_CONTROL);
39
+ }
40
+ /**
41
+ * The Field's attributes a directly placed control did not set itself: the control's own props win
42
+ * (an explicit `false` included), and `aria-describedby` is joined after the Field's ids.
43
+ */
44
+ function fill(control, own) {
45
+ const out = {};
46
+ for (const [key, value] of Object.entries(control)) if (own[key] === void 0) out[key] = value;
47
+ const ownDescribedBy = own["aria-describedby"];
48
+ const described = joinIds(control["aria-describedby"], typeof ownDescribedBy === "string" ? ownDescribedBy : void 0);
49
+ if (described !== void 0) out["aria-describedby"] = described;
50
+ return out;
51
+ }
52
+ //#endregion
53
+ export { Field };
@@ -0,0 +1,4 @@
1
+ import { FieldControlProps, FieldIds, FieldProps, FieldState, FieldStatic, FieldStaticProps, FieldStaticWiring, FieldValidateOn, FieldValidityKey } from "./field-static.js";
2
+ import { Field } from "./field.js";
3
+ import { FieldControl, FieldControlElementProps, FieldControlOptions, FieldValidatable, useFieldControl } from "./field-scope.client.js";
4
+ export { Field, type FieldControl, type FieldControlElementProps, type FieldControlOptions, type FieldControlProps, type FieldIds, type FieldProps, type FieldState, FieldStatic, type FieldStaticProps, type FieldStaticWiring, type FieldValidatable, type FieldValidateOn, type FieldValidityKey, useFieldControl };
@@ -0,0 +1,4 @@
1
+ import { FieldStatic } from "./field-static.js";
2
+ import { useFieldControl } from "./field-scope.client.js";
3
+ import { Field } from "./field.js";
4
+ export { Field, FieldStatic, useFieldControl };
@@ -0,0 +1,36 @@
1
+ import { RenderProp } from "../contracts/render.js";
2
+ import { ComponentPropsWithRef, ReactElement, ReactNode } from "react";
3
+ //#region src/fieldset/fieldset.d.ts
4
+ export interface FieldsetState {
5
+ /** An error message is presented. */
6
+ invalid: boolean;
7
+ disabled: boolean;
8
+ required: boolean;
9
+ }
10
+ export interface FieldsetProps extends Omit<ComponentPropsWithRef<"fieldset">, "children"> {
11
+ /** The group's name, a native `<legend>`. */
12
+ legend?: ReactNode;
13
+ /** Help text after the group, announced on entering it through `aria-describedby`. */
14
+ description?: ReactNode;
15
+ /**
16
+ * The group's error, rendered through InlineError and joined to `aria-describedby`; sets
17
+ * `data-invalid`. Not a live region (§16.5). `null`, `false` and `''` present no error.
18
+ */
19
+ error?: ReactNode;
20
+ /** Replaces the internal error mark (`circle-x`). Decorative. */
21
+ errorIcon?: ReactNode;
22
+ /** Draws an `aria-hidden` mark after the legend; the controls inside carry `required`. @default false */
23
+ required?: boolean;
24
+ /** Native: disables every control inside, with no client code. @default false */
25
+ disabled?: boolean;
26
+ /** Ids replacing the generated ones. */
27
+ ids?: {
28
+ description?: string | undefined;
29
+ error?: string | undefined;
30
+ };
31
+ /** Composition of the root; anything but a `<fieldset>` loses native `disabled`. */
32
+ render?: RenderProp<FieldsetState>;
33
+ children?: ReactNode;
34
+ }
35
+ export declare function Fieldset({ legend, description, error, errorIcon, required, disabled, ids, render, "aria-describedby": ariaDescribedBy, className, children, ...rest }: FieldsetProps): ReactElement;
36
+ //#endregion
@@ -0,0 +1,63 @@
1
+ import { cx } from "../_internal/cx.js";
2
+ import { renderElement } from "../contracts/render.js";
3
+ import { CircleXGlyph } from "../_internal/glyphs.js";
4
+ import { stateAttrs } from "../contracts/state.js";
5
+ import { joinIds, presented } from "../_internal/field.js";
6
+ import { InlineError } from "../inline-error/inline-error.js";
7
+ import { useId } from "react";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ //#region src/fieldset/fieldset.tsx
10
+ function Fieldset({ legend, description, error, errorIcon, required = false, disabled = false, ids, render, "aria-describedby": ariaDescribedBy, className, children, ...rest }) {
11
+ const base = useId();
12
+ const descriptionId = ids?.description ?? `${base}-description`;
13
+ const errorId = ids?.error ?? `${base}-error`;
14
+ const hasDescription = presented(description);
15
+ const invalid = presented(error);
16
+ return renderElement("fieldset", render, {
17
+ invalid,
18
+ disabled,
19
+ required
20
+ }, {
21
+ "data-slot": "fieldset",
22
+ ...stateAttrs({
23
+ invalid,
24
+ disabled,
25
+ required
26
+ }),
27
+ ...rest,
28
+ className: cx("nz-fieldset", className),
29
+ disabled: render === void 0 && disabled ? true : void 0,
30
+ "aria-describedby": joinIds(hasDescription && descriptionId, invalid && errorId, ariaDescribedBy),
31
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [presented(legend) && /* @__PURE__ */ jsxs("legend", {
32
+ className: "nz-fieldset-legend",
33
+ "data-slot": "fieldset-legend",
34
+ children: [legend, required && /* @__PURE__ */ jsx("span", {
35
+ className: "nz-fieldset-required",
36
+ "data-slot": "fieldset-required",
37
+ "aria-hidden": "true",
38
+ children: "*"
39
+ })]
40
+ }), /* @__PURE__ */ jsxs("div", {
41
+ className: "nz-fieldset-content",
42
+ "data-slot": "fieldset-content",
43
+ children: [
44
+ children,
45
+ hasDescription && /* @__PURE__ */ jsx("div", {
46
+ className: "nz-fieldset-description",
47
+ "data-slot": "fieldset-description",
48
+ id: descriptionId,
49
+ children: description
50
+ }),
51
+ invalid && /* @__PURE__ */ jsx(InlineError, {
52
+ className: "nz-fieldset-error",
53
+ "data-slot": "fieldset-error",
54
+ id: errorId,
55
+ icon: errorIcon ?? /* @__PURE__ */ jsx(CircleXGlyph, {}),
56
+ children: error
57
+ })
58
+ ]
59
+ })] })
60
+ });
61
+ }
62
+ //#endregion
63
+ export { Fieldset };
@@ -0,0 +1,2 @@
1
+ import { Fieldset, FieldsetProps, FieldsetState } from "./fieldset.js";
2
+ export { Fieldset, type FieldsetProps, type FieldsetState };
@@ -0,0 +1 @@
1
+ export { Fieldset } from "./fieldset.js";
@@ -0,0 +1,38 @@
1
+ import { RenderProp } from "../contracts/render.js";
2
+ import { LayoutGap } from "../stack/stack.js";
3
+ import { ComponentPropsWithRef, ReactElement } from "react";
4
+ //#region src/grid/grid.d.ts
5
+ /** Columns an item spans, or `'full'` for the whole row. Clamped to the columns available. */
6
+ export type GridSpan = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | "full";
7
+ /**
8
+ * A span per breakpoint: `base` is mobile first, `sm` applies from 40rem (`--nz-sm`) and `lg` from
9
+ * 80rem (`--nz-lg`, provisional). An absent breakpoint keeps the one below it.
10
+ */
11
+ export interface GridResponsiveSpan {
12
+ base?: GridSpan;
13
+ sm?: GridSpan;
14
+ lg?: GridSpan;
15
+ }
16
+ export interface GridState {
17
+ gap: LayoutGap | undefined;
18
+ }
19
+ export interface GridProps extends ComponentPropsWithRef<"div"> {
20
+ /**
21
+ * Space between tracks, as a `--nz-space-*` key. Absent, the responsive gutter
22
+ * (`--nz-grid-gutter`: 16, 20, 24 px).
23
+ */
24
+ gap?: LayoutGap;
25
+ render?: RenderProp<GridState>;
26
+ }
27
+ export interface GridItemState {
28
+ span: GridSpan | GridResponsiveSpan | undefined;
29
+ }
30
+ export interface GridItemProps extends ComponentPropsWithRef<"div"> {
31
+ /** @default 1 */
32
+ span?: GridSpan | GridResponsiveSpan;
33
+ render?: RenderProp<GridItemState>;
34
+ }
35
+ /** The page grid: `--nz-grid-columns` columns (4, 8, 12 by viewport). Items snap to spans. */
36
+ export declare function Grid({ gap, render, className, ...rest }: GridProps): ReactElement;
37
+ export declare function GridItem({ span, render, className, ...rest }: GridItemProps): ReactElement;
38
+ //#endregion
@@ -0,0 +1,28 @@
1
+ import { cx } from "../_internal/cx.js";
2
+ import { renderElement } from "../contracts/render.js";
3
+ //#region src/grid/grid.tsx
4
+ /** The page grid: `--nz-grid-columns` columns (4, 8, 12 by viewport). Items snap to spans. */
5
+ function Grid({ gap, render, className, ...rest }) {
6
+ return renderElement("div", render, { gap }, {
7
+ "data-slot": "grid",
8
+ "data-gap": gap,
9
+ ...rest,
10
+ className: cx("nz-grid", className)
11
+ });
12
+ }
13
+ function GridItem({ span, render, className, ...rest }) {
14
+ const spans = typeof span === "object" ? span : span === void 0 ? {} : { base: span };
15
+ return renderElement("div", render, { span }, {
16
+ "data-slot": "grid-item",
17
+ "data-span": attr(spans.base),
18
+ "data-span-sm": attr(spans.sm),
19
+ "data-span-lg": attr(spans.lg),
20
+ ...rest,
21
+ className: cx("nz-grid-item", className)
22
+ });
23
+ }
24
+ function attr(span) {
25
+ return span === void 0 ? void 0 : String(span);
26
+ }
27
+ //#endregion
28
+ export { Grid, GridItem };
@@ -0,0 +1,2 @@
1
+ import { Grid, GridItem, GridItemProps, GridItemState, GridProps, GridResponsiveSpan, GridSpan, GridState } from "./grid.js";
2
+ export { Grid, GridItem, type GridItemProps, type GridItemState, type GridProps, type GridResponsiveSpan, type GridSpan, type GridState };
@@ -0,0 +1 @@
1
+ export { Grid, GridItem } from "./grid.js";
@@ -0,0 +1,27 @@
1
+ import { RenderProp } from "../contracts/render.js";
2
+ import { TextTone } from "../text/text.js";
3
+ import { ComponentPropsWithRef, ReactElement } from "react";
4
+ //#region src/heading/heading.d.ts
5
+ /** The document outline level: `<h1>` to `<h6>`. */
6
+ export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
7
+ /** The Figma display and heading text styles. */
8
+ export type HeadingVariant = "display-l" | "display-m" | "heading-h1" | "heading-h2" | "heading-h3" | "heading-h4";
9
+ export interface HeadingState {
10
+ level: HeadingLevel;
11
+ variant: HeadingVariant;
12
+ tone: TextTone | undefined;
13
+ }
14
+ export interface HeadingProps extends ComponentPropsWithRef<"h2"> {
15
+ /** Required: the outline level decides the element, never the look. */
16
+ level: HeadingLevel;
17
+ /**
18
+ * The text style, independent of `level` (a page title can be an `<h1>` drawn as Heading/H3).
19
+ * @default the style named after the level, and `heading-h4` for levels 5 and 6 (Figma has no H5 or H6)
20
+ */
21
+ variant?: HeadingVariant;
22
+ /** A `text/*` colour. Absent, the colour is inherited from the surface. */
23
+ tone?: TextTone;
24
+ render?: RenderProp<HeadingState>;
25
+ }
26
+ export declare function Heading({ level, variant, tone, render, className, ...rest }: HeadingProps): ReactElement;
27
+ //#endregion
@@ -0,0 +1,26 @@
1
+ import { cx } from "../_internal/cx.js";
2
+ import { renderElement } from "../contracts/render.js";
3
+ //#region src/heading/heading.tsx
4
+ const VARIANT_OF_LEVEL = {
5
+ 1: "heading-h1",
6
+ 2: "heading-h2",
7
+ 3: "heading-h3",
8
+ 4: "heading-h4",
9
+ 5: "heading-h4",
10
+ 6: "heading-h4"
11
+ };
12
+ function Heading({ level, variant = VARIANT_OF_LEVEL[level], tone, render, className, ...rest }) {
13
+ return renderElement(`h${level}`, render, {
14
+ level,
15
+ variant,
16
+ tone
17
+ }, {
18
+ "data-slot": "heading",
19
+ "data-variant": variant,
20
+ "data-tone": tone,
21
+ ...rest,
22
+ className: cx("nz-heading", className)
23
+ });
24
+ }
25
+ //#endregion
26
+ export { Heading };
@@ -0,0 +1,2 @@
1
+ import { Heading, HeadingLevel, HeadingProps, HeadingState, HeadingVariant } from "./heading.js";
2
+ export { Heading, type HeadingLevel, type HeadingProps, type HeadingState, type HeadingVariant };
@@ -0,0 +1 @@
1
+ export { Heading } from "./heading.js";
@@ -0,0 +1,23 @@
1
+ import { IconButtonStaticProps } from "./icon-button.contract.js";
2
+ import { ReactElement } from "react";
3
+ //#region src/icon-button/icon-button-static.d.ts
4
+ /**
5
+ * A server-safe IconButton with no tooltip: the same `<button>`, classes and CSS as
6
+ * `<IconButton tooltip={false}>`, from a module that imports no client code.
7
+ *
8
+ * Use it only where visible text already names the action for sighted users (a column header, a
9
+ * labelled row) and the page should ship no JavaScript for the button: a table row action that is a
10
+ * link (`render={<a href="/orders/42/edit" />}`) under a header that says what it does, a submit
11
+ * button in a Server Action form (`type="submit"` inside `<form action={deleteProduct}>`) beside its
12
+ * label. Under Turbopack and `next dev`, importing `IconButton` ships its tooltip code even with
13
+ * `tooltip={false}` (about 20 KB gzip in production); `IconButtonStatic` ships none.
14
+ *
15
+ * An icon-only toolbar needs `IconButton`'s tooltip, so a sighted user can read what each glyph does
16
+ * (Figma: "Icon-only buttons have an aria-label and a Tooltip").
17
+ *
18
+ * `aria-label` is always required. You may also pass `aria-labelledby` pointing at visible text; it
19
+ * then names the button, with `aria-label` as the fallback. There is no `tooltip`, no `shortcut`
20
+ * (pass `aria-keyshortcuts` yourself, for example `"Meta+B Control+B"`) and no `label`.
21
+ */
22
+ export declare function IconButtonStatic({ "aria-label": ariaLabel, label: _label, tooltip: _tooltip, shortcut: _shortcut, ...props }: IconButtonStaticProps): ReactElement;
23
+ //#endregion
@@ -0,0 +1,83 @@
1
+ import { cx } from "../_internal/cx.js";
2
+ import { mergeProps } from "../contracts/merge-props.js";
3
+ import { renderElement } from "../contracts/render.js";
4
+ import { SpinnerGlyph } from "../_internal/glyphs.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/icon-button/icon-button-static.tsx
7
+ /**
8
+ * A server-safe IconButton with no tooltip: the same `<button>`, classes and CSS as
9
+ * `<IconButton tooltip={false}>`, from a module that imports no client code.
10
+ *
11
+ * Use it only where visible text already names the action for sighted users (a column header, a
12
+ * labelled row) and the page should ship no JavaScript for the button: a table row action that is a
13
+ * link (`render={<a href="/orders/42/edit" />}`) under a header that says what it does, a submit
14
+ * button in a Server Action form (`type="submit"` inside `<form action={deleteProduct}>`) beside its
15
+ * label. Under Turbopack and `next dev`, importing `IconButton` ships its tooltip code even with
16
+ * `tooltip={false}` (about 20 KB gzip in production); `IconButtonStatic` ships none.
17
+ *
18
+ * An icon-only toolbar needs `IconButton`'s tooltip, so a sighted user can read what each glyph does
19
+ * (Figma: "Icon-only buttons have an aria-label and a Tooltip").
20
+ *
21
+ * `aria-label` is always required. You may also pass `aria-labelledby` pointing at visible text; it
22
+ * then names the button, with `aria-label` as the fallback. There is no `tooltip`, no `shortcut`
23
+ * (pass `aria-keyshortcuts` yourself, for example `"Meta+B Control+B"`) and no `label`.
24
+ */
25
+ function IconButtonStatic({ "aria-label": ariaLabel, label: _label, tooltip: _tooltip, shortcut: _shortcut, ...props }) {
26
+ warnUnnamed(ariaLabel, props["aria-labelledby"], "IconButtonStatic", "aria-label");
27
+ return iconButtonElement({
28
+ ...props,
29
+ label: ariaLabel
30
+ });
31
+ }
32
+ /**
33
+ * Renders the button. `trigger` holds the Tooltip trigger's props (handlers and ref) on IconButton's
34
+ * client path; the consumer's handlers run before them, as everywhere (§8.2).
35
+ */
36
+ function iconButtonElement({ label, icon, variant = "secondary", size = "md", pressed, pending = false, pendingIndicator, disabled = false, type, render, className, ...rest }, trigger) {
37
+ const native = render === void 0;
38
+ const props = trigger === void 0 ? rest : mergeProps(trigger, rest);
39
+ return renderElement("button", render, {
40
+ variant,
41
+ size,
42
+ pending,
43
+ disabled,
44
+ pressed
45
+ }, {
46
+ "data-slot": "icon-button",
47
+ "data-variant": variant,
48
+ "data-size": size,
49
+ "data-pending": pending ? "" : void 0,
50
+ "data-disabled": disabled ? "" : void 0,
51
+ ...props,
52
+ className: cx("nz-icon-button nz-hit-target", className),
53
+ type: native ? pending ? "button" : type ?? "button" : void 0,
54
+ disabled: native && disabled && !pending ? true : void 0,
55
+ "aria-label": label,
56
+ "aria-pressed": pressed,
57
+ "aria-disabled": pending || !native && disabled ? true : void 0,
58
+ onClick: pending && props["onClick"] !== void 0 ? swallow : props["onClick"],
59
+ children: /* @__PURE__ */ jsx("span", {
60
+ className: "nz-icon-button-icon",
61
+ "data-slot": "icon-button-icon",
62
+ "aria-hidden": "true",
63
+ children: pending ? pendingIndicator ?? /* @__PURE__ */ jsx(SpinnerGlyph, {}) : icon
64
+ })
65
+ });
66
+ }
67
+ function swallow(event) {
68
+ event.preventDefault();
69
+ }
70
+ /**
71
+ * Development builds warn about a button nothing names; bundlers strip it from production. `prop` is
72
+ * the prop that names it (`label` on IconButton, `aria-label` on IconButtonStatic).
73
+ */
74
+ function warnUnnamed(name, labelledBy, component = "IconButton", prop = "label") {
75
+ if ((name ?? "").trim() !== "" || (labelledBy ?? "").trim() !== "") return;
76
+ let development = false;
77
+ try {
78
+ development = process.env.NODE_ENV !== "production";
79
+ } catch {}
80
+ if (development) console.warn(`Nizivo ${component}: \`${prop}\` is empty, so the button has no accessible name. Pass the action in words, for example ${prop}="Delete product".`);
81
+ }
82
+ //#endregion
83
+ export { IconButtonStatic, iconButtonElement, warnUnnamed };
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import { TooltipPopup, TooltipRoot, TooltipTrigger } from "../tooltip/tooltip.client.js";
3
+ import { iconButtonElement } from "./icon-button-static.js";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ //#region src/icon-button/icon-button.client.tsx
6
+ function IconButtonTooltip({ tooltip: { side, align, delay }, shortcut, ...button }) {
7
+ return /* @__PURE__ */ jsxs(TooltipRoot, {
8
+ disabled: button.disabled === true,
9
+ ...delay === void 0 ? {} : { delay },
10
+ children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: (props) => iconButtonElement(button, triggerProps(props)) }), /* @__PURE__ */ jsx(TooltipPopup, {
11
+ ...side === void 0 ? {} : { side },
12
+ ...align === void 0 ? {} : { align },
13
+ ...shortcut === void 0 ? {} : { shortcut },
14
+ children: button.label
15
+ })]
16
+ });
17
+ }
18
+ /**
19
+ * Keeps the trigger's handlers and ref. Drops what would make the DOM differ from the server path:
20
+ * `nz-tooltip-trigger`, its slot, `data-open` and the `tabIndex` that makes any element focusable (a
21
+ * button or link already is; a consumer's own `tabIndex` still applies). Drops `aria-describedby` too:
22
+ * the tooltip repeats the accessible name, so describing the button by it would say the label twice.
23
+ */
24
+ function triggerProps(props) {
25
+ const { className: _class, "data-slot": _slot, "data-open": _open, "aria-describedby": _described, type: _type, tabIndex: _tabIndex, ...kept } = props;
26
+ return kept;
27
+ }
28
+ //#endregion
29
+ export { IconButtonTooltip };