@marigold/components 0.3.3 → 0.5.1

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 (232) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/index.d.ts +362 -32
  3. package/dist/index.js +1422 -5
  4. package/dist/index.mjs +1374 -0
  5. package/package.json +30 -11
  6. package/dist/ActionGroup/ActionGroup.d.ts +0 -8
  7. package/dist/ActionGroup/ActionGroup.stories.d.ts +0 -5
  8. package/dist/ActionGroup/index.d.ts +0 -1
  9. package/dist/Alert/Alert.d.ts +0 -27
  10. package/dist/Alert/Alert.stories.d.ts +0 -5
  11. package/dist/Alert/index.d.ts +0 -1
  12. package/dist/Badge/Badge.d.ts +0 -13
  13. package/dist/Badge/Badge.stories.d.ts +0 -5
  14. package/dist/Badge/index.d.ts +0 -1
  15. package/dist/Box.d.ts +0 -2
  16. package/dist/Button/Button.d.ts +0 -9
  17. package/dist/Button/Button.stories.d.ts +0 -5
  18. package/dist/Button/index.d.ts +0 -1
  19. package/dist/Card/Card.d.ts +0 -14
  20. package/dist/Card/Card.stories.d.ts +0 -5
  21. package/dist/Card/index.d.ts +0 -1
  22. package/dist/Checkbox/Checkbox.d.ts +0 -20
  23. package/dist/Checkbox/Checkbox.stories.d.ts +0 -5
  24. package/dist/Checkbox/CheckboxIcons.d.ts +0 -9
  25. package/dist/Checkbox/index.d.ts +0 -1
  26. package/dist/Column/Column.d.ts +0 -8
  27. package/dist/Column/Column.stories.d.ts +0 -5
  28. package/dist/Column/index.d.ts +0 -1
  29. package/dist/Columns/Columns.d.ts +0 -10
  30. package/dist/Columns/Columns.stories.d.ts +0 -5
  31. package/dist/Columns/index.d.ts +0 -1
  32. package/dist/Container/Container.d.ts +0 -6
  33. package/dist/Container/Container.stories.d.ts +0 -5
  34. package/dist/Container/index.d.ts +0 -1
  35. package/dist/Dialog/Dialog.d.ts +0 -17
  36. package/dist/Dialog/Dialog.stories.d.ts +0 -5
  37. package/dist/Dialog/ModalDialog.d.ts +0 -8
  38. package/dist/Dialog/index.d.ts +0 -1
  39. package/dist/Divider/Divider.d.ts +0 -11
  40. package/dist/Divider/Divider.stories.d.ts +0 -5
  41. package/dist/Divider/index.d.ts +0 -1
  42. package/dist/Field/Field.d.ts +0 -13
  43. package/dist/Field/Field.stories.d.ts +0 -5
  44. package/dist/Field/index.d.ts +0 -1
  45. package/dist/Image/Image.d.ts +0 -12
  46. package/dist/Image/Image.stories.d.ts +0 -5
  47. package/dist/Image/index.d.ts +0 -1
  48. package/dist/Inline/Inline.d.ts +0 -7
  49. package/dist/Inline/Inline.stories.d.ts +0 -5
  50. package/dist/Inline/index.d.ts +0 -1
  51. package/dist/Input/Input.d.ts +0 -11
  52. package/dist/Input/Input.stories.d.ts +0 -5
  53. package/dist/Input/index.d.ts +0 -1
  54. package/dist/Label/Label.d.ts +0 -19
  55. package/dist/Label/Label.stories.d.ts +0 -5
  56. package/dist/Label/index.d.ts +0 -1
  57. package/dist/Link/Link.d.ts +0 -10
  58. package/dist/Link/Link.stories.d.ts +0 -5
  59. package/dist/Link/index.d.ts +0 -1
  60. package/dist/Menu/Menu.d.ts +0 -15
  61. package/dist/Menu/Menu.stories.d.ts +0 -5
  62. package/dist/Menu/index.d.ts +0 -1
  63. package/dist/MenuItem/MenuItem.d.ts +0 -12
  64. package/dist/MenuItem/MenuItem.stories.d.ts +0 -5
  65. package/dist/MenuItem/index.d.ts +0 -1
  66. package/dist/Message/Message.d.ts +0 -12
  67. package/dist/Message/Message.stories.d.ts +0 -5
  68. package/dist/Message/index.d.ts +0 -1
  69. package/dist/Provider/MarigoldProvider.d.ts +0 -11
  70. package/dist/Provider/index.d.ts +0 -3
  71. package/dist/Radio/Radio.d.ts +0 -19
  72. package/dist/Radio/Radio.stories.d.ts +0 -5
  73. package/dist/Radio/RadioIcon.d.ts +0 -9
  74. package/dist/Radio/index.d.ts +0 -1
  75. package/dist/Select/ListBox.d.ts +0 -9
  76. package/dist/Select/ListBoxSection.d.ts +0 -9
  77. package/dist/Select/Option.d.ts +0 -9
  78. package/dist/Select/Popover.d.ts +0 -9
  79. package/dist/Select/Select.d.ts +0 -27
  80. package/dist/Select/Select.stories.d.ts +0 -5
  81. package/dist/Select/index.d.ts +0 -1
  82. package/dist/Slider/Slider.d.ts +0 -11
  83. package/dist/Slider/Slider.stories.d.ts +0 -5
  84. package/dist/Slider/index.d.ts +0 -1
  85. package/dist/Stack/Stack.d.ts +0 -7
  86. package/dist/Stack/Stack.stories.d.ts +0 -5
  87. package/dist/Stack/index.d.ts +0 -1
  88. package/dist/Text/Text.d.ts +0 -17
  89. package/dist/Text/Text.stories.d.ts +0 -5
  90. package/dist/Text/index.d.ts +0 -1
  91. package/dist/Textarea/Textarea.d.ts +0 -16
  92. package/dist/Textarea/Textarea.stories.d.ts +0 -5
  93. package/dist/Textarea/index.d.ts +0 -1
  94. package/dist/ValidationMessage/ValidationMessage.d.ts +0 -11
  95. package/dist/ValidationMessage/ValidationMessage.stories.d.ts +0 -5
  96. package/dist/ValidationMessage/index.d.ts +0 -1
  97. package/dist/VisuallyHidden/VisuallyHidden.d.ts +0 -1
  98. package/dist/VisuallyHidden/VisuallyHidden.stories.d.ts +0 -5
  99. package/dist/VisuallyHidden/index.d.ts +0 -1
  100. package/dist/components.cjs.development.js +0 -1394
  101. package/dist/components.cjs.development.js.map +0 -1
  102. package/dist/components.cjs.production.min.js +0 -2
  103. package/dist/components.cjs.production.min.js.map +0 -1
  104. package/dist/components.esm.js +0 -1320
  105. package/dist/components.esm.js.map +0 -1
  106. package/dist/theme.d.ts +0 -23
  107. package/src/ActionGroup/ActionGroup.stories.tsx +0 -47
  108. package/src/ActionGroup/ActionGroup.test.tsx +0 -83
  109. package/src/ActionGroup/ActionGroup.tsx +0 -32
  110. package/src/ActionGroup/index.ts +0 -1
  111. package/src/Alert/Alert.stories.tsx +0 -32
  112. package/src/Alert/Alert.test.tsx +0 -82
  113. package/src/Alert/Alert.tsx +0 -52
  114. package/src/Alert/index.ts +0 -1
  115. package/src/Badge/Badge.stories.tsx +0 -38
  116. package/src/Badge/Badge.test.tsx +0 -65
  117. package/src/Badge/Badge.tsx +0 -37
  118. package/src/Badge/index.ts +0 -1
  119. package/src/Box.ts +0 -2
  120. package/src/Button/Button.stories.tsx +0 -57
  121. package/src/Button/Button.test.tsx +0 -149
  122. package/src/Button/Button.tsx +0 -64
  123. package/src/Button/index.ts +0 -1
  124. package/src/Card/Card.stories.tsx +0 -41
  125. package/src/Card/Card.test.tsx +0 -71
  126. package/src/Card/Card.tsx +0 -48
  127. package/src/Card/index.ts +0 -1
  128. package/src/Checkbox/Checkbox.stories.tsx +0 -78
  129. package/src/Checkbox/Checkbox.test.tsx +0 -166
  130. package/src/Checkbox/Checkbox.tsx +0 -101
  131. package/src/Checkbox/CheckboxIcons.tsx +0 -59
  132. package/src/Checkbox/index.ts +0 -1
  133. package/src/Column/Column.stories.tsx +0 -33
  134. package/src/Column/Column.test.tsx +0 -32
  135. package/src/Column/Column.tsx +0 -27
  136. package/src/Column/index.ts +0 -1
  137. package/src/Columns/Columns.stories.tsx +0 -75
  138. package/src/Columns/Columns.test.tsx +0 -113
  139. package/src/Columns/Columns.tsx +0 -69
  140. package/src/Columns/index.ts +0 -1
  141. package/src/Container/Container.stories.tsx +0 -14
  142. package/src/Container/Container.test.tsx +0 -26
  143. package/src/Container/Container.tsx +0 -13
  144. package/src/Container/index.ts +0 -1
  145. package/src/Dialog/Dialog.stories.tsx +0 -88
  146. package/src/Dialog/Dialog.test.tsx +0 -158
  147. package/src/Dialog/Dialog.tsx +0 -130
  148. package/src/Dialog/ModalDialog.tsx +0 -76
  149. package/src/Dialog/index.ts +0 -1
  150. package/src/Divider/Divider.stories.tsx +0 -30
  151. package/src/Divider/Divider.test.tsx +0 -72
  152. package/src/Divider/Divider.tsx +0 -33
  153. package/src/Divider/index.ts +0 -1
  154. package/src/Field/Field.stories.tsx +0 -110
  155. package/src/Field/Field.test.tsx +0 -130
  156. package/src/Field/Field.tsx +0 -56
  157. package/src/Field/index.ts +0 -1
  158. package/src/Image/Image.stories.tsx +0 -34
  159. package/src/Image/Image.test.tsx +0 -73
  160. package/src/Image/Image.tsx +0 -25
  161. package/src/Image/index.ts +0 -1
  162. package/src/Inline/Inline.stories.tsx +0 -39
  163. package/src/Inline/Inline.test.tsx +0 -99
  164. package/src/Inline/Inline.tsx +0 -38
  165. package/src/Inline/index.ts +0 -1
  166. package/src/Input/Input.stories.tsx +0 -54
  167. package/src/Input/Input.test.tsx +0 -74
  168. package/src/Input/Input.tsx +0 -25
  169. package/src/Input/index.ts +0 -1
  170. package/src/Label/Label.stories.tsx +0 -41
  171. package/src/Label/Label.test.tsx +0 -109
  172. package/src/Label/Label.tsx +0 -64
  173. package/src/Label/index.ts +0 -1
  174. package/src/Link/Link.stories.tsx +0 -35
  175. package/src/Link/Link.test.tsx +0 -97
  176. package/src/Link/Link.tsx +0 -43
  177. package/src/Link/index.ts +0 -1
  178. package/src/Menu/Menu.stories.tsx +0 -62
  179. package/src/Menu/Menu.test.tsx +0 -84
  180. package/src/Menu/Menu.tsx +0 -51
  181. package/src/Menu/index.ts +0 -1
  182. package/src/MenuItem/MenuItem.stories.tsx +0 -30
  183. package/src/MenuItem/MenuItem.test.tsx +0 -68
  184. package/src/MenuItem/MenuItem.tsx +0 -35
  185. package/src/MenuItem/index.ts +0 -1
  186. package/src/Message/Message.stories.tsx +0 -30
  187. package/src/Message/Message.test.tsx +0 -90
  188. package/src/Message/Message.tsx +0 -55
  189. package/src/Message/index.ts +0 -1
  190. package/src/Provider/MarigoldProvider.test.tsx +0 -136
  191. package/src/Provider/MarigoldProvider.tsx +0 -47
  192. package/src/Provider/index.ts +0 -4
  193. package/src/Radio/Radio.stories.tsx +0 -78
  194. package/src/Radio/Radio.test.tsx +0 -154
  195. package/src/Radio/Radio.tsx +0 -88
  196. package/src/Radio/RadioIcon.tsx +0 -49
  197. package/src/Radio/index.ts +0 -1
  198. package/src/Select/ListBox.tsx +0 -40
  199. package/src/Select/ListBoxSection.tsx +0 -40
  200. package/src/Select/Option.tsx +0 -48
  201. package/src/Select/Popover.tsx +0 -50
  202. package/src/Select/Select.stories.tsx +0 -81
  203. package/src/Select/Select.test.tsx +0 -349
  204. package/src/Select/Select.tsx +0 -174
  205. package/src/Select/index.ts +0 -1
  206. package/src/Slider/Slider.stories.tsx +0 -24
  207. package/src/Slider/Slider.test.tsx +0 -63
  208. package/src/Slider/Slider.tsx +0 -35
  209. package/src/Slider/index.ts +0 -1
  210. package/src/Stack/Stack.stories.tsx +0 -57
  211. package/src/Stack/Stack.test.tsx +0 -138
  212. package/src/Stack/Stack.tsx +0 -39
  213. package/src/Stack/index.ts +0 -1
  214. package/src/Text/Text.stories.tsx +0 -61
  215. package/src/Text/Text.test.tsx +0 -99
  216. package/src/Text/Text.tsx +0 -60
  217. package/src/Text/index.ts +0 -1
  218. package/src/Textarea/Textarea.stories.tsx +0 -64
  219. package/src/Textarea/Textarea.test.tsx +0 -95
  220. package/src/Textarea/Textarea.tsx +0 -62
  221. package/src/Textarea/index.ts +0 -1
  222. package/src/ValidationMessage/ValidationMessage.stories.tsx +0 -27
  223. package/src/ValidationMessage/ValidationMessage.test.tsx +0 -68
  224. package/src/ValidationMessage/ValidationMessage.tsx +0 -40
  225. package/src/ValidationMessage/index.ts +0 -1
  226. package/src/VisuallyHidden/VisuallyHidden.stories.tsx +0 -19
  227. package/src/VisuallyHidden/VisuallyHidden.test.tsx +0 -10
  228. package/src/VisuallyHidden/VisuallyHidden.tsx +0 -1
  229. package/src/VisuallyHidden/index.ts +0 -1
  230. package/src/index.ts +0 -34
  231. package/src/theme.ts +0 -50
  232. package/tsconfig.build.json +0 -3
package/dist/index.mjs ADDED
@@ -0,0 +1,1374 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+
33
+ // src/ActionGroup/ActionGroup.tsx
34
+ import React3 from "react";
35
+
36
+ // src/Inline/Inline.tsx
37
+ import React, { Children as Children2 } from "react";
38
+
39
+ // src/utils/flatten-children.ts
40
+ import {
41
+ Children,
42
+ isValidElement,
43
+ cloneElement
44
+ } from "react";
45
+ import { isFragment } from "react-is";
46
+ var flattenChildren = (children, depth = 0, keys = []) => Children.toArray(children).reduce((acc, node) => {
47
+ if (isFragment(node)) {
48
+ acc.push.apply(acc, flattenChildren(node.props.children, depth + 1, keys.concat(node.key)));
49
+ } else {
50
+ if (isValidElement(node)) {
51
+ acc.push(cloneElement(node, {
52
+ key: keys.concat(String(node.key)).join(".")
53
+ }));
54
+ } else if (typeof node === "string" || typeof node === "number") {
55
+ acc.push(node);
56
+ }
57
+ }
58
+ return acc;
59
+ }, []);
60
+
61
+ // src/Box.ts
62
+ import { Box } from "@marigold/system";
63
+
64
+ // src/Inline/Inline.tsx
65
+ var ALIGNMENT = {
66
+ top: "flex-start",
67
+ center: "center",
68
+ bottom: "flex-end"
69
+ };
70
+ var Inline = (_a) => {
71
+ var _b = _a, {
72
+ space = "none",
73
+ align = "center",
74
+ children
75
+ } = _b, props = __objRest(_b, [
76
+ "space",
77
+ "align",
78
+ "children"
79
+ ]);
80
+ return /* @__PURE__ */ React.createElement(Box, __spreadValues({
81
+ display: "inline-flex",
82
+ css: { "> * + *": { pl: space } },
83
+ alignItems: ALIGNMENT[align]
84
+ }, props), Children2.map(flattenChildren(children), (child) => /* @__PURE__ */ React.createElement(Box, null, React.cloneElement(child, {}, child.props.children))));
85
+ };
86
+
87
+ // src/Stack/Stack.tsx
88
+ import React2, { Children as Children3 } from "react";
89
+ var ALIGNMENT2 = {
90
+ left: "flex-start",
91
+ center: "center",
92
+ right: "flex-end"
93
+ };
94
+ var Stack = (_a) => {
95
+ var _b = _a, {
96
+ space = "none",
97
+ align = "left",
98
+ children
99
+ } = _b, props = __objRest(_b, [
100
+ "space",
101
+ "align",
102
+ "children"
103
+ ]);
104
+ return /* @__PURE__ */ React2.createElement(Box, __spreadProps(__spreadValues({}, props), {
105
+ display: "flex",
106
+ flexDirection: "column",
107
+ alignItems: ALIGNMENT2[align],
108
+ css: { "> * + *": { pt: space } }
109
+ }), Children3.map(flattenChildren(children), (child) => /* @__PURE__ */ React2.createElement(Box, null, React2.cloneElement(child, {}, child.props.children))));
110
+ };
111
+
112
+ // src/ActionGroup/ActionGroup.tsx
113
+ var ActionGroup = (_a) => {
114
+ var _b = _a, {
115
+ space = "none",
116
+ verticalAlignment = false,
117
+ children
118
+ } = _b, props = __objRest(_b, [
119
+ "space",
120
+ "verticalAlignment",
121
+ "children"
122
+ ]);
123
+ return verticalAlignment ? /* @__PURE__ */ React3.createElement(Stack, __spreadValues({
124
+ space
125
+ }, props), children) : /* @__PURE__ */ React3.createElement(Inline, __spreadValues({
126
+ space
127
+ }, props), children);
128
+ };
129
+
130
+ // src/Alert/Alert.tsx
131
+ import React4 from "react";
132
+ import { Exclamation, Check, Notification } from "@marigold/icons";
133
+ var ICON_MAP = {
134
+ success: Check,
135
+ warning: Notification,
136
+ error: Exclamation
137
+ };
138
+ var Alert = (_a) => {
139
+ var _b = _a, {
140
+ variant = "success",
141
+ children
142
+ } = _b, props = __objRest(_b, [
143
+ "variant",
144
+ "children"
145
+ ]);
146
+ const Icon = ICON_MAP[variant];
147
+ return /* @__PURE__ */ React4.createElement(Box, __spreadProps(__spreadValues({}, props), {
148
+ display: "flex",
149
+ variant: `alert.${variant}`
150
+ }), /* @__PURE__ */ React4.createElement(Box, {
151
+ display: "inline-block",
152
+ alignItems: "center",
153
+ width: "32px",
154
+ height: "32px",
155
+ bg: variant
156
+ }, /* @__PURE__ */ React4.createElement(Box, {
157
+ as: Icon,
158
+ size: 12,
159
+ color: "#fff",
160
+ bg: variant,
161
+ m: 10
162
+ })), /* @__PURE__ */ React4.createElement(Box, {
163
+ mx: "16px"
164
+ }, children));
165
+ };
166
+
167
+ // src/Badge/Badge.tsx
168
+ import React5 from "react";
169
+ var Badge = (_a) => {
170
+ var _b = _a, {
171
+ variant = "",
172
+ bgColor = "transparent",
173
+ borderColor = "transparent",
174
+ children
175
+ } = _b, props = __objRest(_b, [
176
+ "variant",
177
+ "bgColor",
178
+ "borderColor",
179
+ "children"
180
+ ]);
181
+ return /* @__PURE__ */ React5.createElement(Box, __spreadValues({
182
+ css: { bg: bgColor, borderColor },
183
+ variant: `badge.${variant}`
184
+ }, props), children);
185
+ };
186
+
187
+ // src/Button/Button.tsx
188
+ import React6, { forwardRef } from "react";
189
+ import { useButton } from "@react-aria/button";
190
+ var Button = forwardRef((_a, ref) => {
191
+ var _b = _a, {
192
+ as = "button",
193
+ variant = "primary",
194
+ size = "large",
195
+ space = "none",
196
+ disabled,
197
+ children,
198
+ className
199
+ } = _b, props = __objRest(_b, [
200
+ "as",
201
+ "variant",
202
+ "size",
203
+ "space",
204
+ "disabled",
205
+ "children",
206
+ "className"
207
+ ]);
208
+ const { buttonProps } = useButton(__spreadProps(__spreadValues({}, props), {
209
+ elementType: typeof as === "string" ? as : "span",
210
+ isDisabled: disabled
211
+ }), ref);
212
+ return /* @__PURE__ */ React6.createElement(Box, __spreadProps(__spreadValues(__spreadValues({}, buttonProps), props), {
213
+ as,
214
+ display: "inline-flex",
215
+ alignItems: "center",
216
+ variant: [`button.${variant}`, `button.${size}`],
217
+ className,
218
+ ref,
219
+ css: { columnGap: space }
220
+ }), children);
221
+ });
222
+
223
+ // src/Card/Card.tsx
224
+ import React7 from "react";
225
+ var Card = (_a) => {
226
+ var _b = _a, {
227
+ variant = "",
228
+ title,
229
+ width,
230
+ className,
231
+ children
232
+ } = _b, props = __objRest(_b, [
233
+ "variant",
234
+ "title",
235
+ "width",
236
+ "className",
237
+ "children"
238
+ ]);
239
+ return /* @__PURE__ */ React7.createElement(Box, __spreadProps(__spreadValues({}, props), {
240
+ variant: `card.${variant}`,
241
+ maxWidth: width,
242
+ className
243
+ }), title && /* @__PURE__ */ React7.createElement(Box, {
244
+ as: "h2",
245
+ variant: "text.h2",
246
+ pb: "small"
247
+ }, title), children);
248
+ };
249
+
250
+ // src/Checkbox/Checkbox.tsx
251
+ import React11 from "react";
252
+ import { useFocusRing } from "@react-aria/focus";
253
+ import { VisuallyHidden } from "@react-aria/visually-hidden";
254
+ import { useCheckbox } from "@react-aria/checkbox";
255
+
256
+ // ../../node_modules/@react-stately/utils/dist/module.js
257
+ import { useCallback, useRef, useState } from "react";
258
+ function useControlledState(value, defaultValue, onChange) {
259
+ let [stateValue, setStateValue] = useState(value || defaultValue);
260
+ let ref = useRef(value !== void 0);
261
+ let wasControlled = ref.current;
262
+ let isControlled = value !== void 0;
263
+ let stateRef = useRef(stateValue);
264
+ if (wasControlled !== isControlled) {
265
+ console.warn("WARN: A component changed from " + (wasControlled ? "controlled" : "uncontrolled") + " to " + (isControlled ? "controlled" : "uncontrolled") + ".");
266
+ }
267
+ ref.current = isControlled;
268
+ let setValue = useCallback(function(value2) {
269
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
270
+ args[_key - 1] = arguments[_key];
271
+ }
272
+ let onChangeCaller = function onChangeCaller2(value3) {
273
+ if (onChange) {
274
+ if (!Object.is(stateRef.current, value3)) {
275
+ for (var _len2 = arguments.length, onChangeArgs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
276
+ onChangeArgs[_key2 - 1] = arguments[_key2];
277
+ }
278
+ onChange(value3, ...onChangeArgs);
279
+ }
280
+ }
281
+ if (!isControlled) {
282
+ stateRef.current = value3;
283
+ }
284
+ };
285
+ if (typeof value2 === "function") {
286
+ let updateFunction = function updateFunction2(oldValue) {
287
+ for (var _len3 = arguments.length, functionArgs = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
288
+ functionArgs[_key3 - 1] = arguments[_key3];
289
+ }
290
+ let interceptedValue = value2(isControlled ? stateRef.current : oldValue, ...functionArgs);
291
+ onChangeCaller(interceptedValue, ...args);
292
+ if (!isControlled) {
293
+ return interceptedValue;
294
+ }
295
+ return oldValue;
296
+ };
297
+ setStateValue(updateFunction);
298
+ } else {
299
+ if (!isControlled) {
300
+ setStateValue(value2);
301
+ }
302
+ onChangeCaller(value2, ...args);
303
+ }
304
+ }, [isControlled, onChange]);
305
+ if (isControlled) {
306
+ stateRef.current = value;
307
+ } else {
308
+ value = stateValue;
309
+ }
310
+ return [value, setValue];
311
+ }
312
+
313
+ // ../../node_modules/@react-stately/toggle/dist/module.js
314
+ function useToggleState(props) {
315
+ if (props === void 0) {
316
+ props = {};
317
+ }
318
+ let {
319
+ isReadOnly,
320
+ onChange
321
+ } = props;
322
+ let [isSelected, setSelected] = useControlledState(props.isSelected, props.defaultSelected || false, () => {
323
+ });
324
+ function updateSelected(value) {
325
+ if (!isReadOnly) {
326
+ setSelected(value);
327
+ if (onChange) {
328
+ onChange(value);
329
+ }
330
+ }
331
+ }
332
+ function toggleState() {
333
+ if (!isReadOnly) {
334
+ setSelected((prev) => {
335
+ let newVal = !prev;
336
+ if (onChange) {
337
+ onChange(newVal);
338
+ }
339
+ return newVal;
340
+ });
341
+ }
342
+ }
343
+ return {
344
+ isSelected,
345
+ setSelected: updateSelected,
346
+ toggle: toggleState
347
+ };
348
+ }
349
+
350
+ // src/Checkbox/Checkbox.tsx
351
+ import { Exclamation as Exclamation2 } from "@marigold/icons";
352
+
353
+ // src/Checkbox/CheckboxIcon.tsx
354
+ import React8 from "react";
355
+ import { conditional, SVG } from "@marigold/system";
356
+ var CheckboxIcon = ({
357
+ variant = "",
358
+ checked = false,
359
+ disabled = false,
360
+ error = false
361
+ }) => {
362
+ const conditionalStates = disabled ? {
363
+ disabled
364
+ } : {
365
+ checked,
366
+ error
367
+ };
368
+ return /* @__PURE__ */ React8.createElement(SVG, {
369
+ width: "16",
370
+ height: "32",
371
+ viewBox: "0 0 16 32",
372
+ fill: "none",
373
+ "aria-hidden": "true"
374
+ }, /* @__PURE__ */ React8.createElement(Box, {
375
+ as: "rect",
376
+ x: "0.5",
377
+ y: "8.5",
378
+ width: "15px",
379
+ height: "15px",
380
+ rx: "1.5",
381
+ variant: conditional(`checkbox.${variant}`, conditionalStates)
382
+ }), checked && /* @__PURE__ */ React8.createElement(Box, {
383
+ __baseCSS: { fill: "gray00" },
384
+ as: "path",
385
+ fillRule: "evenodd",
386
+ clipRule: "evenodd",
387
+ d: "M13.9571 12.8338L12.4085 11.2852L6.08699 17.6007L3.59887 15.1126L2.04163 16.6588L6.08682 20.704L13.9571 12.8338Z"
388
+ }));
389
+ };
390
+
391
+ // src/Label/Label.tsx
392
+ import React9 from "react";
393
+ import { Required } from "@marigold/icons";
394
+ var LabelBase = (_a) => {
395
+ var _b = _a, {
396
+ variant = "above",
397
+ required,
398
+ color = "text",
399
+ children
400
+ } = _b, props = __objRest(_b, [
401
+ "variant",
402
+ "required",
403
+ "color",
404
+ "children"
405
+ ]);
406
+ return /* @__PURE__ */ React9.createElement(Box, __spreadProps(__spreadValues({}, props), {
407
+ as: "label",
408
+ __baseCSS: { color },
409
+ variant: `label.${variant}`
410
+ }), children);
411
+ };
412
+ var Label = (_a) => {
413
+ var _b = _a, {
414
+ required,
415
+ children
416
+ } = _b, props = __objRest(_b, [
417
+ "required",
418
+ "children"
419
+ ]);
420
+ return required ? /* @__PURE__ */ React9.createElement(Box, {
421
+ as: "span",
422
+ display: "inline-flex",
423
+ alignItems: "center"
424
+ }, /* @__PURE__ */ React9.createElement(LabelBase, __spreadValues({}, props), children), required && /* @__PURE__ */ React9.createElement(Box, {
425
+ as: Required,
426
+ size: 16,
427
+ css: { color: "error" }
428
+ })) : /* @__PURE__ */ React9.createElement(LabelBase, __spreadValues({}, props), children);
429
+ };
430
+
431
+ // src/ValidationMessage/ValidationMessage.tsx
432
+ import React10 from "react";
433
+ var ValidationMessage = (_a) => {
434
+ var _b = _a, {
435
+ variant = "error",
436
+ children,
437
+ className
438
+ } = _b, props = __objRest(_b, [
439
+ "variant",
440
+ "children",
441
+ "className"
442
+ ]);
443
+ return /* @__PURE__ */ React10.createElement(Box, __spreadValues({
444
+ as: "span",
445
+ display: "flex",
446
+ alignItems: "center",
447
+ variant: `validation.${variant}`,
448
+ className
449
+ }, props), children);
450
+ };
451
+
452
+ // src/Checkbox/Checkbox.tsx
453
+ var CheckboxInput = (_a) => {
454
+ var _b = _a, { error } = _b, props = __objRest(_b, ["error"]);
455
+ const state = useToggleState(props);
456
+ const ref = React11.useRef(null);
457
+ const { inputProps } = useCheckbox(props, state, ref);
458
+ const { focusProps } = useFocusRing();
459
+ const _a2 = props, { children } = _a2, restProps = __objRest(_a2, ["children"]);
460
+ return /* @__PURE__ */ React11.createElement(Box, {
461
+ pr: "xsmall"
462
+ }, /* @__PURE__ */ React11.createElement(VisuallyHidden, null, /* @__PURE__ */ React11.createElement("input", __spreadValues(__spreadProps(__spreadValues(__spreadValues({}, inputProps), focusProps), {
463
+ ref
464
+ }), restProps))), /* @__PURE__ */ React11.createElement(CheckboxIcon, {
465
+ checked: props.checked,
466
+ variant: props.variant,
467
+ disabled: props.disabled,
468
+ error
469
+ }));
470
+ };
471
+ var Checkbox = (_a) => {
472
+ var _b = _a, {
473
+ required,
474
+ labelVariant = "inline",
475
+ errorMessage
476
+ } = _b, props = __objRest(_b, [
477
+ "required",
478
+ "labelVariant",
479
+ "errorMessage"
480
+ ]);
481
+ return /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Box, {
482
+ as: Label,
483
+ __baseCSS: {
484
+ ":hover": { cursor: props.disabled ? "not-allowed" : "pointer" }
485
+ },
486
+ htmlFor: props.id,
487
+ required,
488
+ variant: `label.${labelVariant}`,
489
+ color: props.disabled ? "disabled" : "text"
490
+ }, /* @__PURE__ */ React11.createElement(Box, __spreadValues({
491
+ as: CheckboxInput,
492
+ error: props.error
493
+ }, props)), props.children), props.error && errorMessage && /* @__PURE__ */ React11.createElement(ValidationMessage, null, /* @__PURE__ */ React11.createElement(Exclamation2, {
494
+ size: 16
495
+ }), errorMessage));
496
+ };
497
+
498
+ // src/Column/Column.tsx
499
+ import React12 from "react";
500
+ var transform = (width) => {
501
+ if (Array.isArray(width)) {
502
+ return width.map((v) => `${v / 12 * 100}%`);
503
+ }
504
+ return `${width / 12 * 100}%`;
505
+ };
506
+ var Column = (_a) => {
507
+ var _b = _a, {
508
+ width = 12,
509
+ children
510
+ } = _b, props = __objRest(_b, [
511
+ "width",
512
+ "children"
513
+ ]);
514
+ return /* @__PURE__ */ React12.createElement(Box, __spreadProps(__spreadValues({}, props), {
515
+ width: transform(width)
516
+ }), children);
517
+ };
518
+
519
+ // src/Columns/Columns.tsx
520
+ import React13, { Children as Children4 } from "react";
521
+ import { useTheme } from "@marigold/system";
522
+ var useAlignment = (direction) => {
523
+ switch (direction) {
524
+ case "right":
525
+ return "flex-end";
526
+ case "bottom":
527
+ return "flex-end";
528
+ case "center":
529
+ return "center";
530
+ }
531
+ return "flex-start";
532
+ };
533
+ var Columns = (_a) => {
534
+ var _b = _a, {
535
+ space = "none",
536
+ horizontalAlign = "left",
537
+ verticalAlign = "top",
538
+ className,
539
+ children
540
+ } = _b, props = __objRest(_b, [
541
+ "space",
542
+ "horizontalAlign",
543
+ "verticalAlign",
544
+ "className",
545
+ "children"
546
+ ]);
547
+ const justifyContent = useAlignment(horizontalAlign);
548
+ const alignItems = useAlignment(verticalAlign);
549
+ const { css } = useTheme();
550
+ const spaceObject = css({ space });
551
+ const spaceValue = Object.values(spaceObject)[0];
552
+ return /* @__PURE__ */ React13.createElement(Box, {
553
+ p: space,
554
+ display: "flex",
555
+ className
556
+ }, /* @__PURE__ */ React13.createElement(Box, __spreadValues({
557
+ width: `calc(100% + ${spaceValue}px)`,
558
+ m: `${-spaceValue / 2}px`,
559
+ display: "flex",
560
+ flexWrap: "wrap",
561
+ alignItems,
562
+ justifyContent
563
+ }, props), Children4.map(flattenChildren(children), (child) => {
564
+ return React13.cloneElement(child, {}, /* @__PURE__ */ React13.createElement(Box, {
565
+ css: { p: `${spaceValue / 2}px` }
566
+ }, child.props.children));
567
+ })));
568
+ };
569
+
570
+ // src/Dialog/Dialog.tsx
571
+ import React16 from "react";
572
+ import { useOverlayTriggerState } from "@react-stately/overlays";
573
+ import { OverlayContainer } from "@react-aria/overlays";
574
+ import { useButton as useButton2 } from "@react-aria/button";
575
+ import { Close } from "@marigold/icons";
576
+
577
+ // src/Text/Text.tsx
578
+ import React14, { forwardRef as forwardRef2 } from "react";
579
+ var Text = forwardRef2((_a, ref) => {
580
+ var _b = _a, {
581
+ as = "span",
582
+ variant = "body",
583
+ children,
584
+ align,
585
+ color,
586
+ cursor,
587
+ size,
588
+ outline,
589
+ userSelect
590
+ } = _b, props = __objRest(_b, [
591
+ "as",
592
+ "variant",
593
+ "children",
594
+ "align",
595
+ "color",
596
+ "cursor",
597
+ "size",
598
+ "outline",
599
+ "userSelect"
600
+ ]);
601
+ return /* @__PURE__ */ React14.createElement(Box, __spreadProps(__spreadValues({}, props), {
602
+ as,
603
+ variant: `text.${variant}`,
604
+ css: {
605
+ textAlign: align,
606
+ fontSize: size,
607
+ color,
608
+ cursor,
609
+ outline,
610
+ userSelect
611
+ },
612
+ ref
613
+ }), children);
614
+ });
615
+
616
+ // src/Dialog/ModalDialog.tsx
617
+ import React15 from "react";
618
+ import {
619
+ useOverlay,
620
+ usePreventScroll,
621
+ useModal
622
+ } from "@react-aria/overlays";
623
+ import { useDialog } from "@react-aria/dialog";
624
+ import { FocusScope } from "@react-aria/focus";
625
+ var ModalDialog = (_a) => {
626
+ var _b = _a, {
627
+ variant,
628
+ backdropVariant = "backdrop",
629
+ children
630
+ } = _b, props = __objRest(_b, [
631
+ "variant",
632
+ "backdropVariant",
633
+ "children"
634
+ ]);
635
+ const _a2 = props, { isDismissable, isOpen, onClose } = _a2, restProps = __objRest(_a2, ["isDismissable", "isOpen", "onClose"]);
636
+ const ref = React15.useRef();
637
+ const { overlayProps, underlayProps } = useOverlay({ isDismissable, isOpen, onClose }, ref);
638
+ usePreventScroll();
639
+ const { modalProps } = useModal();
640
+ const { dialogProps } = useDialog(props, ref);
641
+ return /* @__PURE__ */ React15.createElement(Box, __spreadValues({
642
+ __baseCSS: {
643
+ display: "grid",
644
+ placeItems: "center",
645
+ position: "fixed",
646
+ zIndex: 100,
647
+ top: 0,
648
+ left: 0,
649
+ bottom: 0,
650
+ right: 0
651
+ },
652
+ variant: `dialog.${backdropVariant}`
653
+ }, underlayProps), /* @__PURE__ */ React15.createElement(FocusScope, {
654
+ contain: true,
655
+ restoreFocus: true,
656
+ autoFocus: true
657
+ }, /* @__PURE__ */ React15.createElement(Box, __spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, overlayProps), dialogProps), modalProps), {
658
+ ref,
659
+ variant: variant ? `dialog.${variant}` : `dialog`
660
+ }), restProps), children)));
661
+ };
662
+
663
+ // src/Dialog/Dialog.tsx
664
+ var Dialog = (_a) => {
665
+ var _b = _a, {
666
+ backdropVariant,
667
+ children,
668
+ className,
669
+ close,
670
+ isOpen,
671
+ title,
672
+ variant
673
+ } = _b, props = __objRest(_b, [
674
+ "backdropVariant",
675
+ "children",
676
+ "className",
677
+ "close",
678
+ "isOpen",
679
+ "title",
680
+ "variant"
681
+ ]);
682
+ const closeButtonRef = React16.useRef();
683
+ const { buttonProps: closeButtonProps } = useButton2({
684
+ onPress: () => close()
685
+ }, closeButtonRef);
686
+ return /* @__PURE__ */ React16.createElement(OverlayContainer, null, /* @__PURE__ */ React16.createElement(ModalDialog, __spreadValues({
687
+ variant,
688
+ backdropVariant,
689
+ isOpen,
690
+ onClose: close,
691
+ isDismissable: true
692
+ }, props), /* @__PURE__ */ React16.createElement(Box, {
693
+ __baseCSS: {
694
+ display: "flex",
695
+ justifyContent: "space-between",
696
+ borderRadius: "small",
697
+ pl: "large",
698
+ pb: "large"
699
+ },
700
+ className
701
+ }, /* @__PURE__ */ React16.createElement(Box, {
702
+ pt: "medium"
703
+ }, title && /* @__PURE__ */ React16.createElement(Text, {
704
+ as: "h4",
705
+ variant: "headline4"
706
+ }, title), children), /* @__PURE__ */ React16.createElement(Box, {
707
+ __baseCSS: {
708
+ display: "flex",
709
+ justifyContent: "flex-end",
710
+ alignItems: "start",
711
+ paddingTop: "xsmall",
712
+ paddingX: "xsmall"
713
+ }
714
+ }, /* @__PURE__ */ React16.createElement(Box, __spreadProps(__spreadValues({
715
+ as: Button,
716
+ __baseCSS: {
717
+ color: "text",
718
+ bg: "transparent",
719
+ lineHeight: "xsmall",
720
+ px: "xxsmall",
721
+ ":hover": {
722
+ color: "text",
723
+ bg: "transparent",
724
+ cursor: "pointer"
725
+ },
726
+ ":focus": {
727
+ outline: 0
728
+ }
729
+ }
730
+ }, closeButtonProps), {
731
+ ref: closeButtonRef
732
+ }), /* @__PURE__ */ React16.createElement(Close, {
733
+ size: 16
734
+ }))))));
735
+ };
736
+ var useDialogButtonProps = () => {
737
+ const state = useOverlayTriggerState({});
738
+ const openButtonRef = React16.useRef();
739
+ const { buttonProps: openButtonProps } = useButton2({
740
+ onPress: () => state.open()
741
+ }, openButtonRef);
742
+ return {
743
+ state,
744
+ openButtonProps,
745
+ openButtonRef
746
+ };
747
+ };
748
+
749
+ // src/Divider/Divider.tsx
750
+ import React17 from "react";
751
+ import { useSeparator } from "@react-aria/separator";
752
+ var Divider = (_a) => {
753
+ var _b = _a, { variant = "" } = _b, props = __objRest(_b, ["variant"]);
754
+ const { separatorProps } = useSeparator(props);
755
+ return /* @__PURE__ */ React17.createElement(Box, __spreadValues(__spreadValues({
756
+ __baseCSS: { width: "100%", height: "1px", m: "none", bg: "text" },
757
+ variant: `divider.${variant}`
758
+ }, props), separatorProps));
759
+ };
760
+
761
+ // src/Field/Field.tsx
762
+ import React18, { useRef as useRef2 } from "react";
763
+ import { useTextField } from "@react-aria/textfield";
764
+ import { Exclamation as Exclamation3 } from "@marigold/icons";
765
+ var Field = (_a) => {
766
+ var _b = _a, {
767
+ type = "text",
768
+ variant = "",
769
+ labelVariant = "above",
770
+ htmlFor,
771
+ required,
772
+ error,
773
+ errorMessage
774
+ } = _b, props = __objRest(_b, [
775
+ "type",
776
+ "variant",
777
+ "labelVariant",
778
+ "htmlFor",
779
+ "required",
780
+ "error",
781
+ "errorMessage"
782
+ ]);
783
+ const ref = useRef2(null);
784
+ const { labelProps, inputProps, errorMessageProps } = useTextField(props, ref);
785
+ return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(Label, __spreadValues({
786
+ variant: labelVariant,
787
+ htmlFor,
788
+ required
789
+ }, labelProps), props.label), /* @__PURE__ */ React18.createElement(Box, __spreadValues(__spreadProps(__spreadValues({
790
+ as: "input",
791
+ type,
792
+ id: htmlFor,
793
+ variant: `input.${variant}`
794
+ }, inputProps), {
795
+ ref
796
+ }), props)), error && errorMessage && /* @__PURE__ */ React18.createElement(ValidationMessage, __spreadValues({}, errorMessageProps), /* @__PURE__ */ React18.createElement(Exclamation3, {
797
+ size: 16
798
+ }), errorMessage));
799
+ };
800
+
801
+ // src/VisuallyHidden/VisuallyHidden.tsx
802
+ import { VisuallyHidden as VisuallyHidden2 } from "@react-aria/visually-hidden";
803
+
804
+ // src/Image/Image.tsx
805
+ import React19 from "react";
806
+ var Image = (_a) => {
807
+ var _b = _a, {
808
+ variant = "fullWidth"
809
+ } = _b, props = __objRest(_b, [
810
+ "variant"
811
+ ]);
812
+ return /* @__PURE__ */ React19.createElement(Box, __spreadProps(__spreadValues({}, props), {
813
+ as: "img",
814
+ variant: `image.${variant}`
815
+ }));
816
+ };
817
+
818
+ // src/Link/Link.tsx
819
+ import React20, { useRef as useRef3 } from "react";
820
+ import { useLink } from "@react-aria/link";
821
+ var Link = (_a) => {
822
+ var _b = _a, {
823
+ as = "a",
824
+ variant = "link",
825
+ children,
826
+ disabled
827
+ } = _b, props = __objRest(_b, [
828
+ "as",
829
+ "variant",
830
+ "children",
831
+ "disabled"
832
+ ]);
833
+ const ref = useRef3();
834
+ const { linkProps } = useLink(__spreadProps(__spreadValues({}, props), {
835
+ elementType: typeof as === "string" ? as : "span",
836
+ isDisabled: disabled
837
+ }), ref);
838
+ return /* @__PURE__ */ React20.createElement(Text, __spreadProps(__spreadValues(__spreadValues({}, props), linkProps), {
839
+ as,
840
+ variant,
841
+ ref
842
+ }), children);
843
+ };
844
+
845
+ // src/Menu/Menu.tsx
846
+ import React21 from "react";
847
+ var Menu = (_a) => {
848
+ var _b = _a, {
849
+ variant = "default",
850
+ label = "Menu",
851
+ onClick,
852
+ show = false,
853
+ children
854
+ } = _b, props = __objRest(_b, [
855
+ "variant",
856
+ "label",
857
+ "onClick",
858
+ "show",
859
+ "children"
860
+ ]);
861
+ return /* @__PURE__ */ React21.createElement(Box, __spreadValues({
862
+ variant: `menu.${variant}`
863
+ }, props), /* @__PURE__ */ React21.createElement(Button, {
864
+ onClick,
865
+ variant: "menu"
866
+ }, label), show ? /* @__PURE__ */ React21.createElement(Box, {
867
+ display: "block",
868
+ position: "absolute",
869
+ minWidth: "120px",
870
+ borderRadius: "2px"
871
+ }, children) : null);
872
+ };
873
+
874
+ // src/MenuItem/MenuItem.tsx
875
+ import React22 from "react";
876
+ var MenuItem = (_a) => {
877
+ var _b = _a, {
878
+ variant = "default",
879
+ children
880
+ } = _b, props = __objRest(_b, [
881
+ "variant",
882
+ "children"
883
+ ]);
884
+ return /* @__PURE__ */ React22.createElement(Box, {
885
+ variant: `menuItem.${variant}`
886
+ }, /* @__PURE__ */ React22.createElement(Link, __spreadValues({
887
+ variant: "menuItemLink"
888
+ }, props), children));
889
+ };
890
+
891
+ // src/Message/Message.tsx
892
+ import React23 from "react";
893
+ import { Exclamation as Exclamation4, Info, Notification as Notification2 } from "@marigold/icons";
894
+ var Message = (_a) => {
895
+ var _b = _a, {
896
+ messageTitle,
897
+ variant = "info",
898
+ className,
899
+ children
900
+ } = _b, props = __objRest(_b, [
901
+ "messageTitle",
902
+ "variant",
903
+ "className",
904
+ "children"
905
+ ]);
906
+ var icon = /* @__PURE__ */ React23.createElement(Info, null);
907
+ if (variant === "warning") {
908
+ icon = /* @__PURE__ */ React23.createElement(Notification2, null);
909
+ }
910
+ if (variant === "error") {
911
+ icon = /* @__PURE__ */ React23.createElement(Exclamation4, null);
912
+ }
913
+ return /* @__PURE__ */ React23.createElement(Box, __spreadValues({
914
+ display: "inline-block",
915
+ variant: `message.${variant}`,
916
+ className
917
+ }, props), /* @__PURE__ */ React23.createElement(Box, {
918
+ display: "flex",
919
+ alignItems: "center",
920
+ variant: "message.title"
921
+ }, icon, /* @__PURE__ */ React23.createElement(Text, {
922
+ as: "h4",
923
+ variant: "headline4"
924
+ }, messageTitle)), /* @__PURE__ */ React23.createElement(Box, {
925
+ css: { color: "black" }
926
+ }, children));
927
+ };
928
+
929
+ // src/Provider/index.ts
930
+ import { useTheme as useTheme3, ThemeProvider as ThemeProvider2 } from "@marigold/system";
931
+ import { SSRProvider } from "@react-aria/ssr";
932
+
933
+ // src/Provider/MarigoldProvider.tsx
934
+ import React24 from "react";
935
+ import { OverlayProvider } from "@react-aria/overlays";
936
+ import {
937
+ Global,
938
+ ThemeProvider,
939
+ useTheme as useTheme2,
940
+ __defaultTheme
941
+ } from "@marigold/system";
942
+ function MarigoldProvider({
943
+ theme,
944
+ children
945
+ }) {
946
+ const outer = useTheme2();
947
+ const isTopLevel = outer.theme === __defaultTheme;
948
+ return /* @__PURE__ */ React24.createElement(ThemeProvider, {
949
+ theme
950
+ }, isTopLevel ? /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(Global, null), /* @__PURE__ */ React24.createElement(OverlayProvider, null, children)) : children);
951
+ }
952
+
953
+ // src/Radio/Radio.tsx
954
+ import React26 from "react";
955
+ import { Exclamation as Exclamation5 } from "@marigold/icons";
956
+ import { useFocusRing as useFocusRing2 } from "@react-aria/focus";
957
+ import { VisuallyHidden as VisuallyHidden3 } from "@react-aria/visually-hidden";
958
+
959
+ // src/Radio/RadioIcon.tsx
960
+ import React25 from "react";
961
+ import { conditional as conditional2, SVG as SVG2 } from "@marigold/system";
962
+ var RadioIcon = ({
963
+ variant = "",
964
+ checked = false,
965
+ disabled = false,
966
+ error = false
967
+ }) => {
968
+ const conditionalStates = disabled ? {
969
+ disabled
970
+ } : {
971
+ checked,
972
+ error
973
+ };
974
+ return /* @__PURE__ */ React25.createElement(SVG2, {
975
+ width: "16",
976
+ height: "32",
977
+ viewBox: "0 0 16 32",
978
+ fill: "none",
979
+ "aria-hidden": "true"
980
+ }, /* @__PURE__ */ React25.createElement(Box, {
981
+ variant: conditional2(`radio.${variant}`, conditionalStates),
982
+ as: "circle",
983
+ cx: "8",
984
+ cy: "16",
985
+ r: "7.5"
986
+ }), checked && /* @__PURE__ */ React25.createElement("circle", {
987
+ fill: "white",
988
+ cx: "8",
989
+ cy: "16",
990
+ r: "3"
991
+ }));
992
+ };
993
+
994
+ // src/Radio/Radio.tsx
995
+ var RadioInput = (_a) => {
996
+ var _b = _a, { error } = _b, props = __objRest(_b, ["error"]);
997
+ const { focusProps } = useFocusRing2();
998
+ const _a2 = props, { children } = _a2, restProps = __objRest(_a2, ["children"]);
999
+ return /* @__PURE__ */ React26.createElement(Box, {
1000
+ pr: "xsmall"
1001
+ }, /* @__PURE__ */ React26.createElement(VisuallyHidden3, null, /* @__PURE__ */ React26.createElement("input", __spreadValues(__spreadValues({
1002
+ type: "radio",
1003
+ disabled: props.disabled
1004
+ }, focusProps), restProps))), /* @__PURE__ */ React26.createElement(RadioIcon, {
1005
+ variant: props.variant,
1006
+ disabled: props.disabled,
1007
+ checked: props.checked,
1008
+ error
1009
+ }));
1010
+ };
1011
+ var Radio = (_a) => {
1012
+ var _b = _a, {
1013
+ required,
1014
+ labelVariant = "inline",
1015
+ errorMessage
1016
+ } = _b, props = __objRest(_b, [
1017
+ "required",
1018
+ "labelVariant",
1019
+ "errorMessage"
1020
+ ]);
1021
+ return /* @__PURE__ */ React26.createElement(React26.Fragment, null, /* @__PURE__ */ React26.createElement(Box, {
1022
+ as: Label,
1023
+ htmlFor: props.id,
1024
+ required,
1025
+ variant: `label.${labelVariant}`,
1026
+ css: props.disabled ? { color: "disabled", ":hover": { cursor: "not-allowed" } } : { color: "text", ":hover": { cursor: "pointer" } }
1027
+ }, /* @__PURE__ */ React26.createElement(Box, __spreadValues({
1028
+ as: RadioInput,
1029
+ error: props.error
1030
+ }, props)), props.children), props.error && errorMessage && /* @__PURE__ */ React26.createElement(ValidationMessage, null, /* @__PURE__ */ React26.createElement(Exclamation5, {
1031
+ size: 16
1032
+ }), errorMessage));
1033
+ };
1034
+
1035
+ // src/Slider/Slider.tsx
1036
+ import React27 from "react";
1037
+ var Slider = (_a) => {
1038
+ var _b = _a, { variant = "" } = _b, props = __objRest(_b, ["variant"]);
1039
+ return /* @__PURE__ */ React27.createElement(Box, __spreadValues({
1040
+ as: "input",
1041
+ type: "range",
1042
+ css: { verticalAlign: "middle" },
1043
+ variant: `slider.${variant}`
1044
+ }, props));
1045
+ };
1046
+
1047
+ // src/Select/Select.tsx
1048
+ import React32, { useRef as useRef6 } from "react";
1049
+ import { useSelectState } from "@react-stately/select";
1050
+ import { useButton as useButton3 } from "@react-aria/button";
1051
+ import { mergeProps as mergeProps2 } from "@react-aria/utils";
1052
+ import { useFocusRing as useFocusRing3 } from "@react-aria/focus";
1053
+ import { HiddenSelect, useSelect } from "@react-aria/select";
1054
+ import { useOverlayTriggerState as useOverlayTriggerState2 } from "@react-stately/overlays";
1055
+ import { useOverlayTrigger, useOverlayPosition } from "@react-aria/overlays";
1056
+ import { ArrowDown, ArrowUp, Exclamation as Exclamation6, Required as Required2 } from "@marigold/icons";
1057
+
1058
+ // src/Select/ListBox.tsx
1059
+ import React30, { useRef as useRef5 } from "react";
1060
+ import { useListBox } from "@react-aria/listbox";
1061
+
1062
+ // src/Select/Option.tsx
1063
+ import React28, { useEffect, useRef as useRef4, useState as useState2 } from "react";
1064
+ import { useOption } from "@react-aria/listbox";
1065
+ var Option = ({ item, state }) => {
1066
+ const ref = useRef4(null);
1067
+ const [disabled, setDisabled] = useState2(false);
1068
+ const { optionProps, isSelected } = useOption({
1069
+ key: item.key
1070
+ }, state, ref);
1071
+ useEffect(() => {
1072
+ for (const key of state.disabledKeys.values()) {
1073
+ if (key === item.key) {
1074
+ setDisabled(true);
1075
+ }
1076
+ }
1077
+ }, [state.disabledKeys, item.key]);
1078
+ return /* @__PURE__ */ React28.createElement(Box, __spreadProps(__spreadValues({
1079
+ as: "li"
1080
+ }, optionProps), {
1081
+ ref,
1082
+ variant: isSelected ? "select.option.selected" : disabled ? "select.option.disabled" : "select.option"
1083
+ }), item.rendered);
1084
+ };
1085
+
1086
+ // src/Select/ListBoxSection.tsx
1087
+ import React29 from "react";
1088
+ import { useListBoxSection } from "@react-aria/listbox";
1089
+ var ListBoxSection = ({ section, state }) => {
1090
+ const { itemProps, headingProps, groupProps } = useListBoxSection({
1091
+ heading: section.rendered,
1092
+ "aria-label": section["aria-label"]
1093
+ });
1094
+ return /* @__PURE__ */ React29.createElement(Box, __spreadProps(__spreadValues({
1095
+ as: "li"
1096
+ }, itemProps), {
1097
+ css: {
1098
+ cursor: "not-allowed"
1099
+ }
1100
+ }), section.rendered && /* @__PURE__ */ React29.createElement(Box, __spreadProps(__spreadValues({
1101
+ as: "span"
1102
+ }, headingProps), {
1103
+ variant: "select.section"
1104
+ }), section.rendered), /* @__PURE__ */ React29.createElement(Box, __spreadValues({
1105
+ as: "ul"
1106
+ }, groupProps), [...section.childNodes].map((node) => /* @__PURE__ */ React29.createElement(Option, {
1107
+ key: node.key,
1108
+ item: node,
1109
+ state
1110
+ }))));
1111
+ };
1112
+
1113
+ // src/Select/ListBox.tsx
1114
+ var ListBox = (props) => {
1115
+ const ref = useRef5(null);
1116
+ const { state, error } = props;
1117
+ const { listBoxProps } = useListBox(props, state, ref);
1118
+ return /* @__PURE__ */ React30.createElement(Box, __spreadProps(__spreadValues({
1119
+ as: "ul",
1120
+ p: "none",
1121
+ css: {
1122
+ listStyle: "none"
1123
+ }
1124
+ }, listBoxProps), {
1125
+ variant: error ? "select.listbox.error" : "select.listbox",
1126
+ ref
1127
+ }), [...state.collection].map((item) => item.type === "section" ? /* @__PURE__ */ React30.createElement(ListBoxSection, {
1128
+ key: item.key,
1129
+ section: item,
1130
+ state
1131
+ }) : /* @__PURE__ */ React30.createElement(Option, {
1132
+ key: item.key,
1133
+ item,
1134
+ state
1135
+ })));
1136
+ };
1137
+
1138
+ // src/Select/Popover.tsx
1139
+ import React31, { forwardRef as forwardRef3 } from "react";
1140
+ import { FocusScope as FocusScope2 } from "@react-aria/focus";
1141
+ import {
1142
+ DismissButton,
1143
+ OverlayContainer as OverlayContainer2,
1144
+ useModal as useModal2,
1145
+ useOverlay as useOverlay2
1146
+ } from "@react-aria/overlays";
1147
+ import { mergeProps } from "@react-aria/utils";
1148
+ var Popover = forwardRef3((_a, ref) => {
1149
+ var _b = _a, { children, className, isOpen, onClose } = _b, otherProps = __objRest(_b, ["children", "className", "isOpen", "onClose"]);
1150
+ const { overlayProps } = useOverlay2({
1151
+ isOpen,
1152
+ onClose,
1153
+ shouldCloseOnBlur: true,
1154
+ isDismissable: true
1155
+ }, ref);
1156
+ const { modalProps } = useModal2();
1157
+ return /* @__PURE__ */ React31.createElement(OverlayContainer2, null, /* @__PURE__ */ React31.createElement(FocusScope2, {
1158
+ restoreFocus: true
1159
+ }, /* @__PURE__ */ React31.createElement(Box, __spreadProps(__spreadValues({}, mergeProps(overlayProps, otherProps, modalProps)), {
1160
+ className,
1161
+ ref
1162
+ }), children, /* @__PURE__ */ React31.createElement(DismissButton, {
1163
+ onDismiss: onClose
1164
+ }))));
1165
+ });
1166
+
1167
+ // src/Select/Select.tsx
1168
+ var Select = (_a) => {
1169
+ var _b = _a, {
1170
+ labelVariant = "above",
1171
+ placeholder = "Select an option",
1172
+ disabled,
1173
+ required,
1174
+ error,
1175
+ errorMessage,
1176
+ width,
1177
+ className
1178
+ } = _b, props = __objRest(_b, [
1179
+ "labelVariant",
1180
+ "placeholder",
1181
+ "disabled",
1182
+ "required",
1183
+ "error",
1184
+ "errorMessage",
1185
+ "width",
1186
+ "className"
1187
+ ]);
1188
+ const state = useSelectState(props);
1189
+ const overlayTriggerState = useOverlayTriggerState2({});
1190
+ const triggerRef = useRef6();
1191
+ const overlayRef = useRef6();
1192
+ const { overlayProps } = useOverlayTrigger({ type: "listbox" }, overlayTriggerState, triggerRef);
1193
+ const { overlayProps: positionProps } = useOverlayPosition({
1194
+ targetRef: triggerRef,
1195
+ overlayRef,
1196
+ placement: "bottom",
1197
+ shouldFlip: false,
1198
+ isOpen: state.isOpen,
1199
+ onClose: state.close
1200
+ });
1201
+ const { labelProps, triggerProps, valueProps, menuProps } = useSelect(props, state, triggerRef);
1202
+ const { buttonProps } = useButton3(triggerProps, triggerRef);
1203
+ const { focusProps } = useFocusRing3();
1204
+ return /* @__PURE__ */ React32.createElement(Box, {
1205
+ position: "relative",
1206
+ display: "inline-block",
1207
+ width: width && width
1208
+ }, props.label && /* @__PURE__ */ React32.createElement(Box, null, /* @__PURE__ */ React32.createElement(Label, __spreadProps(__spreadValues({}, labelProps), {
1209
+ htmlFor: labelProps.id,
1210
+ variant: labelVariant
1211
+ }), required ? /* @__PURE__ */ React32.createElement(Box, {
1212
+ as: "span",
1213
+ display: "inline-flex",
1214
+ alignItems: "center"
1215
+ }, props.label, /* @__PURE__ */ React32.createElement(Box, {
1216
+ as: Required2,
1217
+ size: 16,
1218
+ css: { color: "error" }
1219
+ })) : props.label)), /* @__PURE__ */ React32.createElement(HiddenSelect, {
1220
+ state,
1221
+ triggerRef,
1222
+ label: props.label,
1223
+ name: props.name,
1224
+ isDisabled: disabled
1225
+ }), /* @__PURE__ */ React32.createElement(Box, __spreadProps(__spreadValues({
1226
+ as: "button"
1227
+ }, mergeProps2(buttonProps, focusProps)), {
1228
+ ref: triggerRef,
1229
+ variant: error && state.isOpen && !disabled ? "button.select.errorOpened" : error ? "button.select.error" : state.isOpen && !disabled ? "button.select.open" : "button.select",
1230
+ disabled,
1231
+ className
1232
+ }), /* @__PURE__ */ React32.createElement(Box, __spreadProps(__spreadValues({
1233
+ as: "span"
1234
+ }, valueProps), {
1235
+ variant: disabled ? "select.disabled" : "select"
1236
+ }), state.selectedItem ? state.selectedItem.rendered : placeholder), state.isOpen && !disabled ? /* @__PURE__ */ React32.createElement(Box, {
1237
+ as: ArrowUp,
1238
+ size: 16,
1239
+ css: { fill: "text" }
1240
+ }) : /* @__PURE__ */ React32.createElement(Box, {
1241
+ as: ArrowDown,
1242
+ size: 16,
1243
+ css: { fill: disabled ? "disabled" : "text" }
1244
+ })), state.isOpen && !disabled && /* @__PURE__ */ React32.createElement(Box, __spreadProps(__spreadValues(__spreadValues({
1245
+ as: Popover
1246
+ }, overlayProps), positionProps), {
1247
+ css: {
1248
+ width: triggerRef.current && triggerRef.current.offsetWidth + "px"
1249
+ },
1250
+ ref: overlayRef,
1251
+ isOpen: state.isOpen,
1252
+ onClose: state.close
1253
+ }), /* @__PURE__ */ React32.createElement(ListBox, __spreadProps(__spreadValues({
1254
+ error
1255
+ }, menuProps), {
1256
+ state
1257
+ }))), error && errorMessage && /* @__PURE__ */ React32.createElement(Box, {
1258
+ as: "span",
1259
+ display: "inline-flex",
1260
+ alignItems: "center"
1261
+ }, /* @__PURE__ */ React32.createElement(Box, {
1262
+ as: Exclamation6,
1263
+ size: 16,
1264
+ css: { color: "error" }
1265
+ }), /* @__PURE__ */ React32.createElement(ValidationMessage, null, errorMessage)));
1266
+ };
1267
+
1268
+ // src/Textarea/Textarea.tsx
1269
+ import React33, { useRef as useRef7 } from "react";
1270
+ import { useTextField as useTextField2 } from "@react-aria/textfield";
1271
+ import { Exclamation as Exclamation7 } from "@marigold/icons";
1272
+ var Textarea = (_a) => {
1273
+ var _b = _a, {
1274
+ variant = "",
1275
+ htmlFor,
1276
+ error,
1277
+ errorMessage,
1278
+ required,
1279
+ children
1280
+ } = _b, props = __objRest(_b, [
1281
+ "variant",
1282
+ "htmlFor",
1283
+ "error",
1284
+ "errorMessage",
1285
+ "required",
1286
+ "children"
1287
+ ]);
1288
+ const ref = useRef7(null);
1289
+ const { labelProps, inputProps, errorMessageProps } = useTextField2(__spreadProps(__spreadValues({}, props), {
1290
+ inputElementType: "textarea"
1291
+ }), ref);
1292
+ return /* @__PURE__ */ React33.createElement(Box, null, /* @__PURE__ */ React33.createElement(Label, __spreadValues({
1293
+ htmlFor,
1294
+ required
1295
+ }, labelProps), props.label), /* @__PURE__ */ React33.createElement(Box, __spreadValues(__spreadProps(__spreadValues({
1296
+ as: "textarea",
1297
+ variant: `textarea.${variant}`,
1298
+ css: {
1299
+ outlineColor: error && "error"
1300
+ }
1301
+ }, inputProps), {
1302
+ ref
1303
+ }), props)), error && errorMessage && /* @__PURE__ */ React33.createElement(ValidationMessage, __spreadValues({}, errorMessageProps), /* @__PURE__ */ React33.createElement(Exclamation7, {
1304
+ size: 16
1305
+ }), errorMessage));
1306
+ };
1307
+
1308
+ // src/Input/Input.tsx
1309
+ import React34 from "react";
1310
+ var Input = (_a) => {
1311
+ var _b = _a, {
1312
+ variant = "",
1313
+ type = "text"
1314
+ } = _b, props = __objRest(_b, [
1315
+ "variant",
1316
+ "type"
1317
+ ]);
1318
+ return /* @__PURE__ */ React34.createElement(Box, __spreadProps(__spreadValues({}, props), {
1319
+ as: "input",
1320
+ type,
1321
+ variant: `input.${variant}`
1322
+ }));
1323
+ };
1324
+
1325
+ // src/Container/Container.tsx
1326
+ import React35 from "react";
1327
+ var Container = (_a) => {
1328
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
1329
+ return /* @__PURE__ */ React35.createElement(Box, __spreadProps(__spreadValues({}, props), {
1330
+ width: "100%"
1331
+ }), children);
1332
+ };
1333
+
1334
+ // src/index.ts
1335
+ import { Item, Section } from "@react-stately/collections";
1336
+ export {
1337
+ ActionGroup,
1338
+ Alert,
1339
+ Badge,
1340
+ Box,
1341
+ Button,
1342
+ Card,
1343
+ Checkbox,
1344
+ Column,
1345
+ Columns,
1346
+ Container,
1347
+ Dialog,
1348
+ Divider,
1349
+ Field,
1350
+ Image,
1351
+ Inline,
1352
+ Input,
1353
+ Item,
1354
+ Label,
1355
+ LabelBase,
1356
+ Link,
1357
+ MarigoldProvider,
1358
+ Menu,
1359
+ MenuItem,
1360
+ Message,
1361
+ Radio,
1362
+ SSRProvider,
1363
+ Section,
1364
+ Select,
1365
+ Slider,
1366
+ Stack,
1367
+ Text,
1368
+ Textarea,
1369
+ ThemeProvider2 as ThemeProvider,
1370
+ ValidationMessage,
1371
+ VisuallyHidden2 as VisuallyHidden,
1372
+ useDialogButtonProps,
1373
+ useTheme3 as useTheme
1374
+ };