@marigold/components 0.5.0 → 0.7.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.
- package/LICENSE +21 -0
- package/dist/index.d.ts +73 -37
- package/dist/index.js +371 -262
- package/dist/index.mjs +391 -282
- package/package.json +12 -5
- package/CHANGELOG.md +0 -217
package/dist/index.mjs
CHANGED
|
@@ -34,8 +34,7 @@ var __objRest = (source, exclude) => {
|
|
|
34
34
|
import React3 from "react";
|
|
35
35
|
|
|
36
36
|
// src/Inline/Inline.tsx
|
|
37
|
-
import React
|
|
38
|
-
import flattenChildren from "react-keyed-flatten-children";
|
|
37
|
+
import React from "react";
|
|
39
38
|
|
|
40
39
|
// src/Box.ts
|
|
41
40
|
import { Box } from "@marigold/system";
|
|
@@ -57,15 +56,14 @@ var Inline = (_a) => {
|
|
|
57
56
|
"children"
|
|
58
57
|
]);
|
|
59
58
|
return /* @__PURE__ */ React.createElement(Box, __spreadValues({
|
|
59
|
+
__baseCSS: { gap: space, flexWrap: "wrap" },
|
|
60
60
|
display: "inline-flex",
|
|
61
|
-
css: { "> * + *": { pl: space } },
|
|
62
61
|
alignItems: ALIGNMENT[align]
|
|
63
|
-
}, props),
|
|
62
|
+
}, props), children);
|
|
64
63
|
};
|
|
65
64
|
|
|
66
65
|
// src/Stack/Stack.tsx
|
|
67
|
-
import React2
|
|
68
|
-
import flattenChildren2 from "react-keyed-flatten-children";
|
|
66
|
+
import React2 from "react";
|
|
69
67
|
var ALIGNMENT2 = {
|
|
70
68
|
left: "flex-start",
|
|
71
69
|
center: "center",
|
|
@@ -82,11 +80,11 @@ var Stack = (_a) => {
|
|
|
82
80
|
"children"
|
|
83
81
|
]);
|
|
84
82
|
return /* @__PURE__ */ React2.createElement(Box, __spreadProps(__spreadValues({}, props), {
|
|
83
|
+
__baseCSS: { gap: space },
|
|
85
84
|
display: "flex",
|
|
86
85
|
flexDirection: "column",
|
|
87
|
-
alignItems: ALIGNMENT2[align]
|
|
88
|
-
|
|
89
|
-
}), Children2.map(flattenChildren2(children), (child) => /* @__PURE__ */ React2.createElement(Box, null, React2.cloneElement(child, {}, child.props.children))));
|
|
86
|
+
alignItems: ALIGNMENT2[align]
|
|
87
|
+
}), children);
|
|
90
88
|
};
|
|
91
89
|
|
|
92
90
|
// src/ActionGroup/ActionGroup.tsx
|
|
@@ -107,45 +105,69 @@ var ActionGroup = (_a) => {
|
|
|
107
105
|
}, props), children);
|
|
108
106
|
};
|
|
109
107
|
|
|
110
|
-
// src/
|
|
108
|
+
// src/Aside/Aside.tsx
|
|
111
109
|
import React4 from "react";
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
warning: Notification,
|
|
116
|
-
error: Exclamation
|
|
110
|
+
var SIDE_MAP = {
|
|
111
|
+
left: [":not(style):first-of-type", ":last-child"],
|
|
112
|
+
right: [":last-child", ":not(style):first-of-type"]
|
|
117
113
|
};
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
return /* @__PURE__ */ React4.createElement(Box,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}, children));
|
|
114
|
+
var Aside = ({
|
|
115
|
+
children,
|
|
116
|
+
sideWidth,
|
|
117
|
+
space = "none",
|
|
118
|
+
side = "left",
|
|
119
|
+
stretch = true,
|
|
120
|
+
wrap = "50%"
|
|
121
|
+
}) => {
|
|
122
|
+
const [aside, content] = SIDE_MAP[side];
|
|
123
|
+
return /* @__PURE__ */ React4.createElement(Box, {
|
|
124
|
+
css: {
|
|
125
|
+
display: "flex",
|
|
126
|
+
flexWrap: "wrap",
|
|
127
|
+
gap: space,
|
|
128
|
+
alignItems: stretch ? void 0 : "flex-start",
|
|
129
|
+
[`> ${aside}`]: {
|
|
130
|
+
flexBasis: sideWidth,
|
|
131
|
+
flexGrow: 1
|
|
132
|
+
},
|
|
133
|
+
[`> ${content}`]: {
|
|
134
|
+
flexBasis: 0,
|
|
135
|
+
flexGrow: 999,
|
|
136
|
+
minInlineSize: wrap
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}, children);
|
|
145
140
|
};
|
|
146
141
|
|
|
147
|
-
// src/
|
|
142
|
+
// src/Aspect/Aspect.tsx
|
|
148
143
|
import React5 from "react";
|
|
144
|
+
import { aspect } from "@marigold/tokens";
|
|
145
|
+
var Aspect = React5.forwardRef(function AspectRatio(_a, ref) {
|
|
146
|
+
var _b = _a, { ratio = "square", maxWidth = "100%", children } = _b, props = __objRest(_b, ["ratio", "maxWidth", "children"]);
|
|
147
|
+
return /* @__PURE__ */ React5.createElement(Box, {
|
|
148
|
+
ref,
|
|
149
|
+
__baseCSS: {
|
|
150
|
+
position: "relative",
|
|
151
|
+
overflow: "hidden",
|
|
152
|
+
maxWidth
|
|
153
|
+
}
|
|
154
|
+
}, /* @__PURE__ */ React5.createElement(Box, {
|
|
155
|
+
__baseCSS: {
|
|
156
|
+
aspectRatio: aspect[ratio]
|
|
157
|
+
}
|
|
158
|
+
}), /* @__PURE__ */ React5.createElement(Box, __spreadProps(__spreadValues({}, props), {
|
|
159
|
+
__baseCSS: {
|
|
160
|
+
position: "absolute",
|
|
161
|
+
top: 0,
|
|
162
|
+
right: 0,
|
|
163
|
+
bottom: 0,
|
|
164
|
+
left: 0
|
|
165
|
+
}
|
|
166
|
+
}), children));
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// src/Badge/Badge.tsx
|
|
170
|
+
import React6 from "react";
|
|
149
171
|
var Badge = (_a) => {
|
|
150
172
|
var _b = _a, {
|
|
151
173
|
variant = "",
|
|
@@ -158,14 +180,14 @@ var Badge = (_a) => {
|
|
|
158
180
|
"borderColor",
|
|
159
181
|
"children"
|
|
160
182
|
]);
|
|
161
|
-
return /* @__PURE__ */
|
|
183
|
+
return /* @__PURE__ */ React6.createElement(Box, __spreadValues({
|
|
162
184
|
css: { bg: bgColor, borderColor },
|
|
163
185
|
variant: `badge.${variant}`
|
|
164
186
|
}, props), children);
|
|
165
187
|
};
|
|
166
188
|
|
|
167
189
|
// src/Button/Button.tsx
|
|
168
|
-
import
|
|
190
|
+
import React7, { forwardRef } from "react";
|
|
169
191
|
import { useButton } from "@react-aria/button";
|
|
170
192
|
var Button = forwardRef((_a, ref) => {
|
|
171
193
|
var _b = _a, {
|
|
@@ -189,7 +211,7 @@ var Button = forwardRef((_a, ref) => {
|
|
|
189
211
|
elementType: typeof as === "string" ? as : "span",
|
|
190
212
|
isDisabled: disabled
|
|
191
213
|
}), ref);
|
|
192
|
-
return /* @__PURE__ */
|
|
214
|
+
return /* @__PURE__ */ React7.createElement(Box, __spreadProps(__spreadValues(__spreadValues({}, buttonProps), props), {
|
|
193
215
|
as,
|
|
194
216
|
display: "inline-flex",
|
|
195
217
|
alignItems: "center",
|
|
@@ -201,7 +223,7 @@ var Button = forwardRef((_a, ref) => {
|
|
|
201
223
|
});
|
|
202
224
|
|
|
203
225
|
// src/Card/Card.tsx
|
|
204
|
-
import
|
|
226
|
+
import React8 from "react";
|
|
205
227
|
var Card = (_a) => {
|
|
206
228
|
var _b = _a, {
|
|
207
229
|
variant = "",
|
|
@@ -216,11 +238,11 @@ var Card = (_a) => {
|
|
|
216
238
|
"className",
|
|
217
239
|
"children"
|
|
218
240
|
]);
|
|
219
|
-
return /* @__PURE__ */
|
|
241
|
+
return /* @__PURE__ */ React8.createElement(Box, __spreadProps(__spreadValues({}, props), {
|
|
220
242
|
variant: `card.${variant}`,
|
|
221
243
|
maxWidth: width,
|
|
222
244
|
className
|
|
223
|
-
}), title && /* @__PURE__ */
|
|
245
|
+
}), title && /* @__PURE__ */ React8.createElement(Box, {
|
|
224
246
|
as: "h2",
|
|
225
247
|
variant: "text.h2",
|
|
226
248
|
pb: "small"
|
|
@@ -228,115 +250,21 @@ var Card = (_a) => {
|
|
|
228
250
|
};
|
|
229
251
|
|
|
230
252
|
// src/Checkbox/Checkbox.tsx
|
|
231
|
-
import
|
|
253
|
+
import React12 from "react";
|
|
232
254
|
import { useFocusRing } from "@react-aria/focus";
|
|
233
255
|
import { VisuallyHidden } from "@react-aria/visually-hidden";
|
|
234
256
|
import { useCheckbox } from "@react-aria/checkbox";
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
import { useCallback, useRef, useState } from "react";
|
|
238
|
-
function useControlledState(value, defaultValue, onChange) {
|
|
239
|
-
let [stateValue, setStateValue] = useState(value || defaultValue);
|
|
240
|
-
let ref = useRef(value !== void 0);
|
|
241
|
-
let wasControlled = ref.current;
|
|
242
|
-
let isControlled = value !== void 0;
|
|
243
|
-
let stateRef = useRef(stateValue);
|
|
244
|
-
if (wasControlled !== isControlled) {
|
|
245
|
-
console.warn("WARN: A component changed from " + (wasControlled ? "controlled" : "uncontrolled") + " to " + (isControlled ? "controlled" : "uncontrolled") + ".");
|
|
246
|
-
}
|
|
247
|
-
ref.current = isControlled;
|
|
248
|
-
let setValue = useCallback(function(value2) {
|
|
249
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
250
|
-
args[_key - 1] = arguments[_key];
|
|
251
|
-
}
|
|
252
|
-
let onChangeCaller = function onChangeCaller2(value3) {
|
|
253
|
-
if (onChange) {
|
|
254
|
-
if (!Object.is(stateRef.current, value3)) {
|
|
255
|
-
for (var _len2 = arguments.length, onChangeArgs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
256
|
-
onChangeArgs[_key2 - 1] = arguments[_key2];
|
|
257
|
-
}
|
|
258
|
-
onChange(value3, ...onChangeArgs);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
if (!isControlled) {
|
|
262
|
-
stateRef.current = value3;
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
if (typeof value2 === "function") {
|
|
266
|
-
let updateFunction = function updateFunction2(oldValue) {
|
|
267
|
-
for (var _len3 = arguments.length, functionArgs = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
268
|
-
functionArgs[_key3 - 1] = arguments[_key3];
|
|
269
|
-
}
|
|
270
|
-
let interceptedValue = value2(isControlled ? stateRef.current : oldValue, ...functionArgs);
|
|
271
|
-
onChangeCaller(interceptedValue, ...args);
|
|
272
|
-
if (!isControlled) {
|
|
273
|
-
return interceptedValue;
|
|
274
|
-
}
|
|
275
|
-
return oldValue;
|
|
276
|
-
};
|
|
277
|
-
setStateValue(updateFunction);
|
|
278
|
-
} else {
|
|
279
|
-
if (!isControlled) {
|
|
280
|
-
setStateValue(value2);
|
|
281
|
-
}
|
|
282
|
-
onChangeCaller(value2, ...args);
|
|
283
|
-
}
|
|
284
|
-
}, [isControlled, onChange]);
|
|
285
|
-
if (isControlled) {
|
|
286
|
-
stateRef.current = value;
|
|
287
|
-
} else {
|
|
288
|
-
value = stateValue;
|
|
289
|
-
}
|
|
290
|
-
return [value, setValue];
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// ../../node_modules/@react-stately/toggle/dist/module.js
|
|
294
|
-
function useToggleState(props) {
|
|
295
|
-
if (props === void 0) {
|
|
296
|
-
props = {};
|
|
297
|
-
}
|
|
298
|
-
let {
|
|
299
|
-
isReadOnly,
|
|
300
|
-
onChange
|
|
301
|
-
} = props;
|
|
302
|
-
let [isSelected, setSelected] = useControlledState(props.isSelected, props.defaultSelected || false, () => {
|
|
303
|
-
});
|
|
304
|
-
function updateSelected(value) {
|
|
305
|
-
if (!isReadOnly) {
|
|
306
|
-
setSelected(value);
|
|
307
|
-
if (onChange) {
|
|
308
|
-
onChange(value);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
function toggleState() {
|
|
313
|
-
if (!isReadOnly) {
|
|
314
|
-
setSelected((prev) => {
|
|
315
|
-
let newVal = !prev;
|
|
316
|
-
if (onChange) {
|
|
317
|
-
onChange(newVal);
|
|
318
|
-
}
|
|
319
|
-
return newVal;
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
return {
|
|
324
|
-
isSelected,
|
|
325
|
-
setSelected: updateSelected,
|
|
326
|
-
toggle: toggleState
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// src/Checkbox/Checkbox.tsx
|
|
331
|
-
import { Exclamation as Exclamation2 } from "@marigold/icons";
|
|
257
|
+
import { useToggleState } from "@react-stately/toggle";
|
|
258
|
+
import { Exclamation } from "@marigold/icons";
|
|
332
259
|
|
|
333
260
|
// src/Checkbox/CheckboxIcon.tsx
|
|
334
|
-
import
|
|
261
|
+
import React9 from "react";
|
|
335
262
|
import { conditional, SVG } from "@marigold/system";
|
|
336
263
|
var CheckboxIcon = ({
|
|
337
264
|
variant = "",
|
|
338
265
|
checked = false,
|
|
339
266
|
disabled = false,
|
|
267
|
+
indeterminated,
|
|
340
268
|
error = false
|
|
341
269
|
}) => {
|
|
342
270
|
const conditionalStates = disabled ? {
|
|
@@ -345,13 +273,13 @@ var CheckboxIcon = ({
|
|
|
345
273
|
checked,
|
|
346
274
|
error
|
|
347
275
|
};
|
|
348
|
-
return /* @__PURE__ */
|
|
276
|
+
return /* @__PURE__ */ React9.createElement(SVG, {
|
|
349
277
|
width: "16",
|
|
350
278
|
height: "32",
|
|
351
279
|
viewBox: "0 0 16 32",
|
|
352
280
|
fill: "none",
|
|
353
281
|
"aria-hidden": "true"
|
|
354
|
-
}, /* @__PURE__ */
|
|
282
|
+
}, /* @__PURE__ */ React9.createElement(Box, {
|
|
355
283
|
as: "rect",
|
|
356
284
|
x: "0.5",
|
|
357
285
|
y: "8.5",
|
|
@@ -359,7 +287,13 @@ var CheckboxIcon = ({
|
|
|
359
287
|
height: "15px",
|
|
360
288
|
rx: "1.5",
|
|
361
289
|
variant: conditional(`checkbox.${variant}`, conditionalStates)
|
|
362
|
-
}), checked && /* @__PURE__ */
|
|
290
|
+
}), checked && indeterminated && /* @__PURE__ */ React9.createElement(Box, {
|
|
291
|
+
__baseCSS: { fill: "gray00" },
|
|
292
|
+
as: "path",
|
|
293
|
+
fillRule: "evenodd",
|
|
294
|
+
clipRule: "evenodd",
|
|
295
|
+
d: "M13.5 17.0402H2.5V15.4688H13.5V17.0402V17.0402Z"
|
|
296
|
+
}), checked && !indeterminated && /* @__PURE__ */ React9.createElement(Box, {
|
|
363
297
|
__baseCSS: { fill: "gray00" },
|
|
364
298
|
as: "path",
|
|
365
299
|
fillRule: "evenodd",
|
|
@@ -369,7 +303,7 @@ var CheckboxIcon = ({
|
|
|
369
303
|
};
|
|
370
304
|
|
|
371
305
|
// src/Label/Label.tsx
|
|
372
|
-
import
|
|
306
|
+
import React10 from "react";
|
|
373
307
|
import { Required } from "@marigold/icons";
|
|
374
308
|
var LabelBase = (_a) => {
|
|
375
309
|
var _b = _a, {
|
|
@@ -383,7 +317,7 @@ var LabelBase = (_a) => {
|
|
|
383
317
|
"color",
|
|
384
318
|
"children"
|
|
385
319
|
]);
|
|
386
|
-
return /* @__PURE__ */
|
|
320
|
+
return /* @__PURE__ */ React10.createElement(Box, __spreadProps(__spreadValues({}, props), {
|
|
387
321
|
as: "label",
|
|
388
322
|
__baseCSS: { color },
|
|
389
323
|
variant: `label.${variant}`
|
|
@@ -397,19 +331,18 @@ var Label = (_a) => {
|
|
|
397
331
|
"required",
|
|
398
332
|
"children"
|
|
399
333
|
]);
|
|
400
|
-
return required ? /* @__PURE__ */
|
|
334
|
+
return required ? /* @__PURE__ */ React10.createElement(Box, {
|
|
401
335
|
as: "span",
|
|
402
336
|
display: "inline-flex",
|
|
403
337
|
alignItems: "center"
|
|
404
|
-
}, /* @__PURE__ */
|
|
405
|
-
as: Required,
|
|
338
|
+
}, /* @__PURE__ */ React10.createElement(LabelBase, __spreadValues({}, props), children), required && /* @__PURE__ */ React10.createElement(Required, {
|
|
406
339
|
size: 16,
|
|
407
|
-
|
|
408
|
-
})) : /* @__PURE__ */
|
|
340
|
+
fill: "error"
|
|
341
|
+
})) : /* @__PURE__ */ React10.createElement(LabelBase, __spreadValues({}, props), children);
|
|
409
342
|
};
|
|
410
343
|
|
|
411
344
|
// src/ValidationMessage/ValidationMessage.tsx
|
|
412
|
-
import
|
|
345
|
+
import React11 from "react";
|
|
413
346
|
var ValidationMessage = (_a) => {
|
|
414
347
|
var _b = _a, {
|
|
415
348
|
variant = "error",
|
|
@@ -420,7 +353,7 @@ var ValidationMessage = (_a) => {
|
|
|
420
353
|
"children",
|
|
421
354
|
"className"
|
|
422
355
|
]);
|
|
423
|
-
return /* @__PURE__ */
|
|
356
|
+
return /* @__PURE__ */ React11.createElement(Box, __spreadValues({
|
|
424
357
|
as: "span",
|
|
425
358
|
display: "flex",
|
|
426
359
|
alignItems: "center",
|
|
@@ -431,20 +364,27 @@ var ValidationMessage = (_a) => {
|
|
|
431
364
|
|
|
432
365
|
// src/Checkbox/Checkbox.tsx
|
|
433
366
|
var CheckboxInput = (_a) => {
|
|
434
|
-
var _b = _a, {
|
|
367
|
+
var _b = _a, {
|
|
368
|
+
error,
|
|
369
|
+
indeterminated = false
|
|
370
|
+
} = _b, props = __objRest(_b, [
|
|
371
|
+
"error",
|
|
372
|
+
"indeterminated"
|
|
373
|
+
]);
|
|
435
374
|
const state = useToggleState(props);
|
|
436
|
-
const ref =
|
|
375
|
+
const ref = React12.useRef(null);
|
|
437
376
|
const { inputProps } = useCheckbox(props, state, ref);
|
|
438
377
|
const { focusProps } = useFocusRing();
|
|
439
378
|
const _a2 = props, { children } = _a2, restProps = __objRest(_a2, ["children"]);
|
|
440
|
-
return /* @__PURE__ */
|
|
379
|
+
return /* @__PURE__ */ React12.createElement(Box, {
|
|
441
380
|
pr: "xsmall"
|
|
442
|
-
}, /* @__PURE__ */
|
|
381
|
+
}, /* @__PURE__ */ React12.createElement(VisuallyHidden, null, /* @__PURE__ */ React12.createElement("input", __spreadValues(__spreadProps(__spreadValues(__spreadValues({}, inputProps), focusProps), {
|
|
443
382
|
ref
|
|
444
|
-
}), restProps))), /* @__PURE__ */
|
|
383
|
+
}), restProps))), /* @__PURE__ */ React12.createElement(CheckboxIcon, {
|
|
445
384
|
checked: props.checked,
|
|
446
385
|
variant: props.variant,
|
|
447
386
|
disabled: props.disabled,
|
|
387
|
+
indeterminated,
|
|
448
388
|
error
|
|
449
389
|
}));
|
|
450
390
|
};
|
|
@@ -458,7 +398,7 @@ var Checkbox = (_a) => {
|
|
|
458
398
|
"labelVariant",
|
|
459
399
|
"errorMessage"
|
|
460
400
|
]);
|
|
461
|
-
return /* @__PURE__ */
|
|
401
|
+
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(Box, {
|
|
462
402
|
as: Label,
|
|
463
403
|
__baseCSS: {
|
|
464
404
|
":hover": { cursor: props.disabled ? "not-allowed" : "pointer" }
|
|
@@ -467,16 +407,15 @@ var Checkbox = (_a) => {
|
|
|
467
407
|
required,
|
|
468
408
|
variant: `label.${labelVariant}`,
|
|
469
409
|
color: props.disabled ? "disabled" : "text"
|
|
470
|
-
}, /* @__PURE__ */
|
|
471
|
-
as: CheckboxInput,
|
|
410
|
+
}, /* @__PURE__ */ React12.createElement(CheckboxInput, __spreadValues({
|
|
472
411
|
error: props.error
|
|
473
|
-
}, props)), props.children), props.error && errorMessage && /* @__PURE__ */
|
|
412
|
+
}, props)), props.children), props.error && errorMessage && /* @__PURE__ */ React12.createElement(ValidationMessage, null, /* @__PURE__ */ React12.createElement(Exclamation, {
|
|
474
413
|
size: 16
|
|
475
414
|
}), errorMessage));
|
|
476
415
|
};
|
|
477
416
|
|
|
478
417
|
// src/Column/Column.tsx
|
|
479
|
-
import
|
|
418
|
+
import React13 from "react";
|
|
480
419
|
var transform = (width) => {
|
|
481
420
|
if (Array.isArray(width)) {
|
|
482
421
|
return width.map((v) => `${v / 12 * 100}%`);
|
|
@@ -491,15 +430,38 @@ var Column = (_a) => {
|
|
|
491
430
|
"width",
|
|
492
431
|
"children"
|
|
493
432
|
]);
|
|
494
|
-
return /* @__PURE__ */
|
|
433
|
+
return /* @__PURE__ */ React13.createElement(Box, __spreadProps(__spreadValues({}, props), {
|
|
495
434
|
width: transform(width)
|
|
496
435
|
}), children);
|
|
497
436
|
};
|
|
498
437
|
|
|
499
438
|
// src/Columns/Columns.tsx
|
|
500
|
-
import
|
|
501
|
-
import flattenChildren3 from "react-keyed-flatten-children";
|
|
439
|
+
import React14, { Children as Children2 } from "react";
|
|
502
440
|
import { useTheme } from "@marigold/system";
|
|
441
|
+
|
|
442
|
+
// src/utils/flatten-children.ts
|
|
443
|
+
import {
|
|
444
|
+
Children,
|
|
445
|
+
isValidElement,
|
|
446
|
+
cloneElement
|
|
447
|
+
} from "react";
|
|
448
|
+
import { isFragment } from "react-is";
|
|
449
|
+
var flattenChildren = (children, depth = 0, keys = []) => Children.toArray(children).reduce((acc, node) => {
|
|
450
|
+
if (isFragment(node)) {
|
|
451
|
+
acc.push.apply(acc, flattenChildren(node.props.children, depth + 1, keys.concat(node.key)));
|
|
452
|
+
} else {
|
|
453
|
+
if (isValidElement(node)) {
|
|
454
|
+
acc.push(cloneElement(node, {
|
|
455
|
+
key: keys.concat(String(node.key)).join(".")
|
|
456
|
+
}));
|
|
457
|
+
} else if (typeof node === "string" || typeof node === "number") {
|
|
458
|
+
acc.push(node);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
return acc;
|
|
462
|
+
}, []);
|
|
463
|
+
|
|
464
|
+
// src/Columns/Columns.tsx
|
|
503
465
|
var useAlignment = (direction) => {
|
|
504
466
|
switch (direction) {
|
|
505
467
|
case "right":
|
|
@@ -530,33 +492,33 @@ var Columns = (_a) => {
|
|
|
530
492
|
const { css } = useTheme();
|
|
531
493
|
const spaceObject = css({ space });
|
|
532
494
|
const spaceValue = Object.values(spaceObject)[0];
|
|
533
|
-
return /* @__PURE__ */
|
|
495
|
+
return /* @__PURE__ */ React14.createElement(Box, {
|
|
534
496
|
p: space,
|
|
535
497
|
display: "flex",
|
|
536
498
|
className
|
|
537
|
-
}, /* @__PURE__ */
|
|
499
|
+
}, /* @__PURE__ */ React14.createElement(Box, __spreadValues({
|
|
538
500
|
width: `calc(100% + ${spaceValue}px)`,
|
|
539
501
|
m: `${-spaceValue / 2}px`,
|
|
540
502
|
display: "flex",
|
|
541
503
|
flexWrap: "wrap",
|
|
542
504
|
alignItems,
|
|
543
505
|
justifyContent
|
|
544
|
-
}, props),
|
|
545
|
-
return
|
|
506
|
+
}, props), Children2.map(flattenChildren(children), (child) => {
|
|
507
|
+
return React14.cloneElement(child, {}, /* @__PURE__ */ React14.createElement(Box, {
|
|
546
508
|
css: { p: `${spaceValue / 2}px` }
|
|
547
509
|
}, child.props.children));
|
|
548
510
|
})));
|
|
549
511
|
};
|
|
550
512
|
|
|
551
513
|
// src/Dialog/Dialog.tsx
|
|
552
|
-
import
|
|
514
|
+
import React17 from "react";
|
|
553
515
|
import { useOverlayTriggerState } from "@react-stately/overlays";
|
|
554
516
|
import { OverlayContainer } from "@react-aria/overlays";
|
|
555
517
|
import { useButton as useButton2 } from "@react-aria/button";
|
|
556
518
|
import { Close } from "@marigold/icons";
|
|
557
519
|
|
|
558
520
|
// src/Text/Text.tsx
|
|
559
|
-
import
|
|
521
|
+
import React15, { forwardRef as forwardRef2 } from "react";
|
|
560
522
|
var Text = forwardRef2((_a, ref) => {
|
|
561
523
|
var _b = _a, {
|
|
562
524
|
as = "span",
|
|
@@ -579,7 +541,7 @@ var Text = forwardRef2((_a, ref) => {
|
|
|
579
541
|
"outline",
|
|
580
542
|
"userSelect"
|
|
581
543
|
]);
|
|
582
|
-
return /* @__PURE__ */
|
|
544
|
+
return /* @__PURE__ */ React15.createElement(Box, __spreadProps(__spreadValues({}, props), {
|
|
583
545
|
as,
|
|
584
546
|
variant: `text.${variant}`,
|
|
585
547
|
css: {
|
|
@@ -595,7 +557,7 @@ var Text = forwardRef2((_a, ref) => {
|
|
|
595
557
|
});
|
|
596
558
|
|
|
597
559
|
// src/Dialog/ModalDialog.tsx
|
|
598
|
-
import
|
|
560
|
+
import React16 from "react";
|
|
599
561
|
import {
|
|
600
562
|
useOverlay,
|
|
601
563
|
usePreventScroll,
|
|
@@ -614,12 +576,12 @@ var ModalDialog = (_a) => {
|
|
|
614
576
|
"children"
|
|
615
577
|
]);
|
|
616
578
|
const _a2 = props, { isDismissable, isOpen, onClose } = _a2, restProps = __objRest(_a2, ["isDismissable", "isOpen", "onClose"]);
|
|
617
|
-
const ref =
|
|
579
|
+
const ref = React16.useRef();
|
|
618
580
|
const { overlayProps, underlayProps } = useOverlay({ isDismissable, isOpen, onClose }, ref);
|
|
619
581
|
usePreventScroll();
|
|
620
582
|
const { modalProps } = useModal();
|
|
621
583
|
const { dialogProps } = useDialog(props, ref);
|
|
622
|
-
return /* @__PURE__ */
|
|
584
|
+
return /* @__PURE__ */ React16.createElement(Box, __spreadValues({
|
|
623
585
|
__baseCSS: {
|
|
624
586
|
display: "grid",
|
|
625
587
|
placeItems: "center",
|
|
@@ -631,11 +593,11 @@ var ModalDialog = (_a) => {
|
|
|
631
593
|
right: 0
|
|
632
594
|
},
|
|
633
595
|
variant: `dialog.${backdropVariant}`
|
|
634
|
-
}, underlayProps), /* @__PURE__ */
|
|
596
|
+
}, underlayProps), /* @__PURE__ */ React16.createElement(FocusScope, {
|
|
635
597
|
contain: true,
|
|
636
598
|
restoreFocus: true,
|
|
637
599
|
autoFocus: true
|
|
638
|
-
}, /* @__PURE__ */
|
|
600
|
+
}, /* @__PURE__ */ React16.createElement(Box, __spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, overlayProps), dialogProps), modalProps), {
|
|
639
601
|
ref,
|
|
640
602
|
variant: variant ? `dialog.${variant}` : `dialog`
|
|
641
603
|
}), restProps), children)));
|
|
@@ -660,17 +622,17 @@ var Dialog = (_a) => {
|
|
|
660
622
|
"title",
|
|
661
623
|
"variant"
|
|
662
624
|
]);
|
|
663
|
-
const closeButtonRef =
|
|
625
|
+
const closeButtonRef = React17.useRef();
|
|
664
626
|
const { buttonProps: closeButtonProps } = useButton2({
|
|
665
627
|
onPress: () => close()
|
|
666
628
|
}, closeButtonRef);
|
|
667
|
-
return /* @__PURE__ */
|
|
629
|
+
return /* @__PURE__ */ React17.createElement(OverlayContainer, null, /* @__PURE__ */ React17.createElement(ModalDialog, __spreadValues({
|
|
668
630
|
variant,
|
|
669
631
|
backdropVariant,
|
|
670
632
|
isOpen,
|
|
671
633
|
onClose: close,
|
|
672
634
|
isDismissable: true
|
|
673
|
-
}, props), /* @__PURE__ */
|
|
635
|
+
}, props), /* @__PURE__ */ React17.createElement(Box, {
|
|
674
636
|
__baseCSS: {
|
|
675
637
|
display: "flex",
|
|
676
638
|
justifyContent: "space-between",
|
|
@@ -679,12 +641,12 @@ var Dialog = (_a) => {
|
|
|
679
641
|
pb: "large"
|
|
680
642
|
},
|
|
681
643
|
className
|
|
682
|
-
}, /* @__PURE__ */
|
|
644
|
+
}, /* @__PURE__ */ React17.createElement(Box, {
|
|
683
645
|
pt: "medium"
|
|
684
|
-
}, title && /* @__PURE__ */
|
|
646
|
+
}, title && /* @__PURE__ */ React17.createElement(Text, {
|
|
685
647
|
as: "h4",
|
|
686
648
|
variant: "headline4"
|
|
687
|
-
}, title), children), /* @__PURE__ */
|
|
649
|
+
}, title), children), /* @__PURE__ */ React17.createElement(Box, {
|
|
688
650
|
__baseCSS: {
|
|
689
651
|
display: "flex",
|
|
690
652
|
justifyContent: "flex-end",
|
|
@@ -692,7 +654,7 @@ var Dialog = (_a) => {
|
|
|
692
654
|
paddingTop: "xsmall",
|
|
693
655
|
paddingX: "xsmall"
|
|
694
656
|
}
|
|
695
|
-
}, /* @__PURE__ */
|
|
657
|
+
}, /* @__PURE__ */ React17.createElement(Box, __spreadProps(__spreadValues({
|
|
696
658
|
as: Button,
|
|
697
659
|
__baseCSS: {
|
|
698
660
|
color: "text",
|
|
@@ -710,13 +672,13 @@ var Dialog = (_a) => {
|
|
|
710
672
|
}
|
|
711
673
|
}, closeButtonProps), {
|
|
712
674
|
ref: closeButtonRef
|
|
713
|
-
}), /* @__PURE__ */
|
|
675
|
+
}), /* @__PURE__ */ React17.createElement(Close, {
|
|
714
676
|
size: 16
|
|
715
677
|
}))))));
|
|
716
678
|
};
|
|
717
679
|
var useDialogButtonProps = () => {
|
|
718
680
|
const state = useOverlayTriggerState({});
|
|
719
|
-
const openButtonRef =
|
|
681
|
+
const openButtonRef = React17.useRef();
|
|
720
682
|
const { buttonProps: openButtonProps } = useButton2({
|
|
721
683
|
onPress: () => state.open()
|
|
722
684
|
}, openButtonRef);
|
|
@@ -728,21 +690,21 @@ var useDialogButtonProps = () => {
|
|
|
728
690
|
};
|
|
729
691
|
|
|
730
692
|
// src/Divider/Divider.tsx
|
|
731
|
-
import
|
|
693
|
+
import React18 from "react";
|
|
732
694
|
import { useSeparator } from "@react-aria/separator";
|
|
733
695
|
var Divider = (_a) => {
|
|
734
696
|
var _b = _a, { variant = "" } = _b, props = __objRest(_b, ["variant"]);
|
|
735
697
|
const { separatorProps } = useSeparator(props);
|
|
736
|
-
return /* @__PURE__ */
|
|
698
|
+
return /* @__PURE__ */ React18.createElement(Box, __spreadValues(__spreadValues({
|
|
737
699
|
__baseCSS: { width: "100%", height: "1px", m: "none", bg: "text" },
|
|
738
700
|
variant: `divider.${variant}`
|
|
739
701
|
}, props), separatorProps));
|
|
740
702
|
};
|
|
741
703
|
|
|
742
704
|
// src/Field/Field.tsx
|
|
743
|
-
import
|
|
705
|
+
import React19, { useRef } from "react";
|
|
744
706
|
import { useTextField } from "@react-aria/textfield";
|
|
745
|
-
import { Exclamation as
|
|
707
|
+
import { Exclamation as Exclamation2 } from "@marigold/icons";
|
|
746
708
|
var Field = (_a) => {
|
|
747
709
|
var _b = _a, {
|
|
748
710
|
type = "text",
|
|
@@ -761,20 +723,20 @@ var Field = (_a) => {
|
|
|
761
723
|
"error",
|
|
762
724
|
"errorMessage"
|
|
763
725
|
]);
|
|
764
|
-
const ref =
|
|
726
|
+
const ref = useRef(null);
|
|
765
727
|
const { labelProps, inputProps, errorMessageProps } = useTextField(props, ref);
|
|
766
|
-
return /* @__PURE__ */
|
|
728
|
+
return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement(Label, __spreadValues({
|
|
767
729
|
variant: labelVariant,
|
|
768
730
|
htmlFor,
|
|
769
731
|
required
|
|
770
|
-
}, labelProps), props.label), /* @__PURE__ */
|
|
732
|
+
}, labelProps), props.label), /* @__PURE__ */ React19.createElement(Box, __spreadValues(__spreadProps(__spreadValues({
|
|
771
733
|
as: "input",
|
|
772
734
|
type,
|
|
773
735
|
id: htmlFor,
|
|
774
736
|
variant: `input.${variant}`
|
|
775
737
|
}, inputProps), {
|
|
776
738
|
ref
|
|
777
|
-
}), props)), error && errorMessage && /* @__PURE__ */
|
|
739
|
+
}), props)), error && errorMessage && /* @__PURE__ */ React19.createElement(ValidationMessage, __spreadValues({}, errorMessageProps), /* @__PURE__ */ React19.createElement(Exclamation2, {
|
|
778
740
|
size: 16
|
|
779
741
|
}), errorMessage));
|
|
780
742
|
};
|
|
@@ -783,21 +745,21 @@ var Field = (_a) => {
|
|
|
783
745
|
import { VisuallyHidden as VisuallyHidden2 } from "@react-aria/visually-hidden";
|
|
784
746
|
|
|
785
747
|
// src/Image/Image.tsx
|
|
786
|
-
import
|
|
748
|
+
import React20 from "react";
|
|
787
749
|
var Image = (_a) => {
|
|
788
750
|
var _b = _a, {
|
|
789
751
|
variant = "fullWidth"
|
|
790
752
|
} = _b, props = __objRest(_b, [
|
|
791
753
|
"variant"
|
|
792
754
|
]);
|
|
793
|
-
return /* @__PURE__ */
|
|
755
|
+
return /* @__PURE__ */ React20.createElement(Box, __spreadProps(__spreadValues({}, props), {
|
|
794
756
|
as: "img",
|
|
795
757
|
variant: `image.${variant}`
|
|
796
758
|
}));
|
|
797
759
|
};
|
|
798
760
|
|
|
799
761
|
// src/Link/Link.tsx
|
|
800
|
-
import
|
|
762
|
+
import React21, { useRef as useRef2 } from "react";
|
|
801
763
|
import { useLink } from "@react-aria/link";
|
|
802
764
|
var Link = (_a) => {
|
|
803
765
|
var _b = _a, {
|
|
@@ -811,12 +773,12 @@ var Link = (_a) => {
|
|
|
811
773
|
"children",
|
|
812
774
|
"disabled"
|
|
813
775
|
]);
|
|
814
|
-
const ref =
|
|
776
|
+
const ref = useRef2();
|
|
815
777
|
const { linkProps } = useLink(__spreadProps(__spreadValues({}, props), {
|
|
816
778
|
elementType: typeof as === "string" ? as : "span",
|
|
817
779
|
isDisabled: disabled
|
|
818
780
|
}), ref);
|
|
819
|
-
return /* @__PURE__ */
|
|
781
|
+
return /* @__PURE__ */ React21.createElement(Text, __spreadProps(__spreadValues(__spreadValues({}, props), linkProps), {
|
|
820
782
|
as,
|
|
821
783
|
variant,
|
|
822
784
|
ref
|
|
@@ -824,7 +786,7 @@ var Link = (_a) => {
|
|
|
824
786
|
};
|
|
825
787
|
|
|
826
788
|
// src/Menu/Menu.tsx
|
|
827
|
-
import
|
|
789
|
+
import React22 from "react";
|
|
828
790
|
var Menu = (_a) => {
|
|
829
791
|
var _b = _a, {
|
|
830
792
|
variant = "default",
|
|
@@ -839,12 +801,12 @@ var Menu = (_a) => {
|
|
|
839
801
|
"show",
|
|
840
802
|
"children"
|
|
841
803
|
]);
|
|
842
|
-
return /* @__PURE__ */
|
|
804
|
+
return /* @__PURE__ */ React22.createElement(Box, __spreadValues({
|
|
843
805
|
variant: `menu.${variant}`
|
|
844
|
-
}, props), /* @__PURE__ */
|
|
806
|
+
}, props), /* @__PURE__ */ React22.createElement(Button, {
|
|
845
807
|
onClick,
|
|
846
808
|
variant: "menu"
|
|
847
|
-
}, label), show ? /* @__PURE__ */
|
|
809
|
+
}, label), show ? /* @__PURE__ */ React22.createElement(Box, {
|
|
848
810
|
display: "block",
|
|
849
811
|
position: "absolute",
|
|
850
812
|
minWidth: "120px",
|
|
@@ -853,7 +815,7 @@ var Menu = (_a) => {
|
|
|
853
815
|
};
|
|
854
816
|
|
|
855
817
|
// src/MenuItem/MenuItem.tsx
|
|
856
|
-
import
|
|
818
|
+
import React23 from "react";
|
|
857
819
|
var MenuItem = (_a) => {
|
|
858
820
|
var _b = _a, {
|
|
859
821
|
variant = "default",
|
|
@@ -862,16 +824,16 @@ var MenuItem = (_a) => {
|
|
|
862
824
|
"variant",
|
|
863
825
|
"children"
|
|
864
826
|
]);
|
|
865
|
-
return /* @__PURE__ */
|
|
827
|
+
return /* @__PURE__ */ React23.createElement(Box, {
|
|
866
828
|
variant: `menuItem.${variant}`
|
|
867
|
-
}, /* @__PURE__ */
|
|
829
|
+
}, /* @__PURE__ */ React23.createElement(Link, __spreadValues({
|
|
868
830
|
variant: "menuItemLink"
|
|
869
831
|
}, props), children));
|
|
870
832
|
};
|
|
871
833
|
|
|
872
834
|
// src/Message/Message.tsx
|
|
873
|
-
import
|
|
874
|
-
import { Exclamation as
|
|
835
|
+
import React24 from "react";
|
|
836
|
+
import { Exclamation as Exclamation3, Info, Notification } from "@marigold/icons";
|
|
875
837
|
var Message = (_a) => {
|
|
876
838
|
var _b = _a, {
|
|
877
839
|
messageTitle,
|
|
@@ -884,25 +846,25 @@ var Message = (_a) => {
|
|
|
884
846
|
"className",
|
|
885
847
|
"children"
|
|
886
848
|
]);
|
|
887
|
-
var icon = /* @__PURE__ */
|
|
849
|
+
var icon = /* @__PURE__ */ React24.createElement(Info, null);
|
|
888
850
|
if (variant === "warning") {
|
|
889
|
-
icon = /* @__PURE__ */
|
|
851
|
+
icon = /* @__PURE__ */ React24.createElement(Notification, null);
|
|
890
852
|
}
|
|
891
853
|
if (variant === "error") {
|
|
892
|
-
icon = /* @__PURE__ */
|
|
854
|
+
icon = /* @__PURE__ */ React24.createElement(Exclamation3, null);
|
|
893
855
|
}
|
|
894
|
-
return /* @__PURE__ */
|
|
856
|
+
return /* @__PURE__ */ React24.createElement(Box, __spreadValues({
|
|
895
857
|
display: "inline-block",
|
|
896
858
|
variant: `message.${variant}`,
|
|
897
859
|
className
|
|
898
|
-
}, props), /* @__PURE__ */
|
|
860
|
+
}, props), /* @__PURE__ */ React24.createElement(Box, {
|
|
899
861
|
display: "flex",
|
|
900
862
|
alignItems: "center",
|
|
901
863
|
variant: "message.title"
|
|
902
|
-
}, icon, /* @__PURE__ */
|
|
864
|
+
}, icon, /* @__PURE__ */ React24.createElement(Text, {
|
|
903
865
|
as: "h4",
|
|
904
866
|
variant: "headline4"
|
|
905
|
-
}, messageTitle)), /* @__PURE__ */
|
|
867
|
+
}, messageTitle)), /* @__PURE__ */ React24.createElement(Box, {
|
|
906
868
|
css: { color: "black" }
|
|
907
869
|
}, children));
|
|
908
870
|
};
|
|
@@ -912,7 +874,7 @@ import { useTheme as useTheme3, ThemeProvider as ThemeProvider2 } from "@marigol
|
|
|
912
874
|
import { SSRProvider } from "@react-aria/ssr";
|
|
913
875
|
|
|
914
876
|
// src/Provider/MarigoldProvider.tsx
|
|
915
|
-
import
|
|
877
|
+
import React25 from "react";
|
|
916
878
|
import { OverlayProvider } from "@react-aria/overlays";
|
|
917
879
|
import {
|
|
918
880
|
Global,
|
|
@@ -926,19 +888,19 @@ function MarigoldProvider({
|
|
|
926
888
|
}) {
|
|
927
889
|
const outer = useTheme2();
|
|
928
890
|
const isTopLevel = outer.theme === __defaultTheme;
|
|
929
|
-
return /* @__PURE__ */
|
|
891
|
+
return /* @__PURE__ */ React25.createElement(ThemeProvider, {
|
|
930
892
|
theme
|
|
931
|
-
}, isTopLevel ? /* @__PURE__ */
|
|
893
|
+
}, isTopLevel ? /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(Global, null), /* @__PURE__ */ React25.createElement(OverlayProvider, null, children)) : children);
|
|
932
894
|
}
|
|
933
895
|
|
|
934
896
|
// src/Radio/Radio.tsx
|
|
935
|
-
import
|
|
936
|
-
import { Exclamation as
|
|
897
|
+
import React27 from "react";
|
|
898
|
+
import { Exclamation as Exclamation4 } from "@marigold/icons";
|
|
937
899
|
import { useFocusRing as useFocusRing2 } from "@react-aria/focus";
|
|
938
900
|
import { VisuallyHidden as VisuallyHidden3 } from "@react-aria/visually-hidden";
|
|
939
901
|
|
|
940
902
|
// src/Radio/RadioIcon.tsx
|
|
941
|
-
import
|
|
903
|
+
import React26 from "react";
|
|
942
904
|
import { conditional as conditional2, SVG as SVG2 } from "@marigold/system";
|
|
943
905
|
var RadioIcon = ({
|
|
944
906
|
variant = "",
|
|
@@ -952,19 +914,19 @@ var RadioIcon = ({
|
|
|
952
914
|
checked,
|
|
953
915
|
error
|
|
954
916
|
};
|
|
955
|
-
return /* @__PURE__ */
|
|
917
|
+
return /* @__PURE__ */ React26.createElement(SVG2, {
|
|
956
918
|
width: "16",
|
|
957
919
|
height: "32",
|
|
958
920
|
viewBox: "0 0 16 32",
|
|
959
921
|
fill: "none",
|
|
960
922
|
"aria-hidden": "true"
|
|
961
|
-
}, /* @__PURE__ */
|
|
923
|
+
}, /* @__PURE__ */ React26.createElement(Box, {
|
|
962
924
|
variant: conditional2(`radio.${variant}`, conditionalStates),
|
|
963
925
|
as: "circle",
|
|
964
926
|
cx: "8",
|
|
965
927
|
cy: "16",
|
|
966
928
|
r: "7.5"
|
|
967
|
-
}), checked && /* @__PURE__ */
|
|
929
|
+
}), checked && /* @__PURE__ */ React26.createElement("circle", {
|
|
968
930
|
fill: "white",
|
|
969
931
|
cx: "8",
|
|
970
932
|
cy: "16",
|
|
@@ -977,12 +939,12 @@ var RadioInput = (_a) => {
|
|
|
977
939
|
var _b = _a, { error } = _b, props = __objRest(_b, ["error"]);
|
|
978
940
|
const { focusProps } = useFocusRing2();
|
|
979
941
|
const _a2 = props, { children } = _a2, restProps = __objRest(_a2, ["children"]);
|
|
980
|
-
return /* @__PURE__ */
|
|
942
|
+
return /* @__PURE__ */ React27.createElement(Box, {
|
|
981
943
|
pr: "xsmall"
|
|
982
|
-
}, /* @__PURE__ */
|
|
944
|
+
}, /* @__PURE__ */ React27.createElement(VisuallyHidden3, null, /* @__PURE__ */ React27.createElement("input", __spreadValues(__spreadValues({
|
|
983
945
|
type: "radio",
|
|
984
946
|
disabled: props.disabled
|
|
985
|
-
}, focusProps), restProps))), /* @__PURE__ */
|
|
947
|
+
}, focusProps), restProps))), /* @__PURE__ */ React27.createElement(RadioIcon, {
|
|
986
948
|
variant: props.variant,
|
|
987
949
|
disabled: props.disabled,
|
|
988
950
|
checked: props.checked,
|
|
@@ -999,34 +961,22 @@ var Radio = (_a) => {
|
|
|
999
961
|
"labelVariant",
|
|
1000
962
|
"errorMessage"
|
|
1001
963
|
]);
|
|
1002
|
-
return /* @__PURE__ */
|
|
964
|
+
return /* @__PURE__ */ React27.createElement(React27.Fragment, null, /* @__PURE__ */ React27.createElement(Box, {
|
|
1003
965
|
as: Label,
|
|
1004
966
|
htmlFor: props.id,
|
|
1005
967
|
required,
|
|
1006
968
|
variant: `label.${labelVariant}`,
|
|
1007
969
|
css: props.disabled ? { color: "disabled", ":hover": { cursor: "not-allowed" } } : { color: "text", ":hover": { cursor: "pointer" } }
|
|
1008
|
-
}, /* @__PURE__ */
|
|
970
|
+
}, /* @__PURE__ */ React27.createElement(Box, __spreadValues({
|
|
1009
971
|
as: RadioInput,
|
|
1010
972
|
error: props.error
|
|
1011
|
-
}, props)), props.children), props.error && errorMessage && /* @__PURE__ */
|
|
973
|
+
}, props)), props.children), props.error && errorMessage && /* @__PURE__ */ React27.createElement(ValidationMessage, null, /* @__PURE__ */ React27.createElement(Exclamation4, {
|
|
1012
974
|
size: 16
|
|
1013
975
|
}), errorMessage));
|
|
1014
976
|
};
|
|
1015
977
|
|
|
1016
|
-
// src/Slider/Slider.tsx
|
|
1017
|
-
import React27 from "react";
|
|
1018
|
-
var Slider = (_a) => {
|
|
1019
|
-
var _b = _a, { variant = "" } = _b, props = __objRest(_b, ["variant"]);
|
|
1020
|
-
return /* @__PURE__ */ React27.createElement(Box, __spreadValues({
|
|
1021
|
-
as: "input",
|
|
1022
|
-
type: "range",
|
|
1023
|
-
css: { verticalAlign: "middle" },
|
|
1024
|
-
variant: `slider.${variant}`
|
|
1025
|
-
}, props));
|
|
1026
|
-
};
|
|
1027
|
-
|
|
1028
978
|
// src/Select/Select.tsx
|
|
1029
|
-
import React32, { useRef as
|
|
979
|
+
import React32, { useRef as useRef5 } from "react";
|
|
1030
980
|
import { useSelectState } from "@react-stately/select";
|
|
1031
981
|
import { useButton as useButton3 } from "@react-aria/button";
|
|
1032
982
|
import { mergeProps as mergeProps2 } from "@react-aria/utils";
|
|
@@ -1034,18 +984,18 @@ import { useFocusRing as useFocusRing3 } from "@react-aria/focus";
|
|
|
1034
984
|
import { HiddenSelect, useSelect } from "@react-aria/select";
|
|
1035
985
|
import { useOverlayTriggerState as useOverlayTriggerState2 } from "@react-stately/overlays";
|
|
1036
986
|
import { useOverlayTrigger, useOverlayPosition } from "@react-aria/overlays";
|
|
1037
|
-
import { ArrowDown, ArrowUp, Exclamation as
|
|
987
|
+
import { ArrowDown, ArrowUp, Exclamation as Exclamation5, Required as Required2 } from "@marigold/icons";
|
|
1038
988
|
|
|
1039
989
|
// src/Select/ListBox.tsx
|
|
1040
|
-
import React30, { useRef as
|
|
990
|
+
import React30, { useRef as useRef4 } from "react";
|
|
1041
991
|
import { useListBox } from "@react-aria/listbox";
|
|
1042
992
|
|
|
1043
993
|
// src/Select/Option.tsx
|
|
1044
|
-
import React28, { useEffect, useRef as
|
|
994
|
+
import React28, { useEffect, useRef as useRef3, useState } from "react";
|
|
1045
995
|
import { useOption } from "@react-aria/listbox";
|
|
1046
996
|
var Option = ({ item, state }) => {
|
|
1047
|
-
const ref =
|
|
1048
|
-
const [disabled, setDisabled] =
|
|
997
|
+
const ref = useRef3(null);
|
|
998
|
+
const [disabled, setDisabled] = useState(false);
|
|
1049
999
|
const { optionProps, isSelected } = useOption({
|
|
1050
1000
|
key: item.key
|
|
1051
1001
|
}, state, ref);
|
|
@@ -1093,7 +1043,7 @@ var ListBoxSection = ({ section, state }) => {
|
|
|
1093
1043
|
|
|
1094
1044
|
// src/Select/ListBox.tsx
|
|
1095
1045
|
var ListBox = (props) => {
|
|
1096
|
-
const ref =
|
|
1046
|
+
const ref = useRef4(null);
|
|
1097
1047
|
const { state, error } = props;
|
|
1098
1048
|
const { listBoxProps } = useListBox(props, state, ref);
|
|
1099
1049
|
return /* @__PURE__ */ React30.createElement(Box, __spreadProps(__spreadValues({
|
|
@@ -1168,8 +1118,8 @@ var Select = (_a) => {
|
|
|
1168
1118
|
]);
|
|
1169
1119
|
const state = useSelectState(props);
|
|
1170
1120
|
const overlayTriggerState = useOverlayTriggerState2({});
|
|
1171
|
-
const triggerRef =
|
|
1172
|
-
const overlayRef =
|
|
1121
|
+
const triggerRef = useRef5();
|
|
1122
|
+
const overlayRef = useRef5();
|
|
1173
1123
|
const { overlayProps } = useOverlayTrigger({ type: "listbox" }, overlayTriggerState, triggerRef);
|
|
1174
1124
|
const { overlayProps: positionProps } = useOverlayPosition({
|
|
1175
1125
|
targetRef: triggerRef,
|
|
@@ -1193,10 +1143,9 @@ var Select = (_a) => {
|
|
|
1193
1143
|
as: "span",
|
|
1194
1144
|
display: "inline-flex",
|
|
1195
1145
|
alignItems: "center"
|
|
1196
|
-
}, props.label, /* @__PURE__ */ React32.createElement(
|
|
1197
|
-
as: Required2,
|
|
1146
|
+
}, props.label, /* @__PURE__ */ React32.createElement(Required2, {
|
|
1198
1147
|
size: 16,
|
|
1199
|
-
|
|
1148
|
+
fill: "error"
|
|
1200
1149
|
})) : props.label)), /* @__PURE__ */ React32.createElement(HiddenSelect, {
|
|
1201
1150
|
state,
|
|
1202
1151
|
triggerRef,
|
|
@@ -1214,14 +1163,12 @@ var Select = (_a) => {
|
|
|
1214
1163
|
as: "span"
|
|
1215
1164
|
}, valueProps), {
|
|
1216
1165
|
variant: disabled ? "select.disabled" : "select"
|
|
1217
|
-
}), state.selectedItem ? state.selectedItem.rendered : placeholder), state.isOpen && !disabled ? /* @__PURE__ */ React32.createElement(
|
|
1218
|
-
as: ArrowUp,
|
|
1166
|
+
}), state.selectedItem ? state.selectedItem.rendered : placeholder), state.isOpen && !disabled ? /* @__PURE__ */ React32.createElement(ArrowUp, {
|
|
1219
1167
|
size: 16,
|
|
1220
|
-
|
|
1221
|
-
}) : /* @__PURE__ */ React32.createElement(
|
|
1222
|
-
as: ArrowDown,
|
|
1168
|
+
fill: "text"
|
|
1169
|
+
}) : /* @__PURE__ */ React32.createElement(ArrowDown, {
|
|
1223
1170
|
size: 16,
|
|
1224
|
-
|
|
1171
|
+
fill: disabled ? "disabled" : "text"
|
|
1225
1172
|
})), state.isOpen && !disabled && /* @__PURE__ */ React32.createElement(Box, __spreadProps(__spreadValues(__spreadValues({
|
|
1226
1173
|
as: Popover
|
|
1227
1174
|
}, overlayProps), positionProps), {
|
|
@@ -1240,16 +1187,91 @@ var Select = (_a) => {
|
|
|
1240
1187
|
display: "inline-flex",
|
|
1241
1188
|
alignItems: "center"
|
|
1242
1189
|
}, /* @__PURE__ */ React32.createElement(Box, {
|
|
1243
|
-
as:
|
|
1190
|
+
as: Exclamation5,
|
|
1244
1191
|
size: 16,
|
|
1245
1192
|
css: { color: "error" }
|
|
1246
1193
|
}), /* @__PURE__ */ React32.createElement(ValidationMessage, null, errorMessage)));
|
|
1247
1194
|
};
|
|
1248
1195
|
|
|
1196
|
+
// src/Slider/Slider.tsx
|
|
1197
|
+
import React33 from "react";
|
|
1198
|
+
var Slider = (_a) => {
|
|
1199
|
+
var _b = _a, { variant = "" } = _b, props = __objRest(_b, ["variant"]);
|
|
1200
|
+
return /* @__PURE__ */ React33.createElement(Box, __spreadValues({
|
|
1201
|
+
as: "input",
|
|
1202
|
+
type: "range",
|
|
1203
|
+
css: { verticalAlign: "middle" },
|
|
1204
|
+
variant: `slider.${variant}`
|
|
1205
|
+
}, props));
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
// src/Switch/Switch.tsx
|
|
1209
|
+
import React34, { useRef as useRef6 } from "react";
|
|
1210
|
+
import { useFocusRing as useFocusRing4 } from "@react-aria/focus";
|
|
1211
|
+
import { useSwitch } from "@react-aria/switch";
|
|
1212
|
+
import { VisuallyHidden as VisuallyHidden4 } from "@react-aria/visually-hidden";
|
|
1213
|
+
import { useToggleState as useToggleState2 } from "@react-stately/toggle";
|
|
1214
|
+
import { conditional as conditional3 } from "@marigold/system";
|
|
1215
|
+
var Switch = (_a) => {
|
|
1216
|
+
var _b = _a, {
|
|
1217
|
+
variant = "",
|
|
1218
|
+
labelVariant = "above",
|
|
1219
|
+
disabled
|
|
1220
|
+
} = _b, props = __objRest(_b, [
|
|
1221
|
+
"variant",
|
|
1222
|
+
"labelVariant",
|
|
1223
|
+
"disabled"
|
|
1224
|
+
]);
|
|
1225
|
+
const state = useToggleState2(props);
|
|
1226
|
+
const ref = useRef6();
|
|
1227
|
+
const { inputProps } = useSwitch(props, state, ref);
|
|
1228
|
+
const { focusProps } = useFocusRing4();
|
|
1229
|
+
return /* @__PURE__ */ React34.createElement(Box, {
|
|
1230
|
+
as: Label,
|
|
1231
|
+
__baseCSS: {
|
|
1232
|
+
userSelect: "none"
|
|
1233
|
+
},
|
|
1234
|
+
variant: labelVariant
|
|
1235
|
+
}, props.children, /* @__PURE__ */ React34.createElement(VisuallyHidden4, null, /* @__PURE__ */ React34.createElement("input", __spreadProps(__spreadValues(__spreadValues({}, inputProps), focusProps), {
|
|
1236
|
+
disabled,
|
|
1237
|
+
ref
|
|
1238
|
+
}))), /* @__PURE__ */ React34.createElement(Box, {
|
|
1239
|
+
as: "svg",
|
|
1240
|
+
__baseCSS: {
|
|
1241
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
1242
|
+
width: 56,
|
|
1243
|
+
height: 32
|
|
1244
|
+
},
|
|
1245
|
+
"aria-hidden": "true"
|
|
1246
|
+
}, /* @__PURE__ */ React34.createElement(Box, {
|
|
1247
|
+
as: "rect",
|
|
1248
|
+
__baseCSS: {
|
|
1249
|
+
x: 4,
|
|
1250
|
+
y: 4,
|
|
1251
|
+
rx: 12,
|
|
1252
|
+
width: 48,
|
|
1253
|
+
height: 24
|
|
1254
|
+
},
|
|
1255
|
+
variant: conditional3(`switch.${variant}`, {
|
|
1256
|
+
checked: state.isSelected,
|
|
1257
|
+
disabled
|
|
1258
|
+
})
|
|
1259
|
+
}), /* @__PURE__ */ React34.createElement(Box, {
|
|
1260
|
+
as: "circle",
|
|
1261
|
+
__baseCSS: {
|
|
1262
|
+
boxShadow: "1px 1px 4px rgba(0, 0, 0, 0.25)",
|
|
1263
|
+
cx: state.isSelected ? 40 : 16,
|
|
1264
|
+
cy: 16,
|
|
1265
|
+
r: 11,
|
|
1266
|
+
fill: disabled ? "gray20" : "gray00"
|
|
1267
|
+
}
|
|
1268
|
+
})));
|
|
1269
|
+
};
|
|
1270
|
+
|
|
1249
1271
|
// src/Textarea/Textarea.tsx
|
|
1250
|
-
import
|
|
1272
|
+
import React35, { useRef as useRef7 } from "react";
|
|
1251
1273
|
import { useTextField as useTextField2 } from "@react-aria/textfield";
|
|
1252
|
-
import { Exclamation as
|
|
1274
|
+
import { Exclamation as Exclamation6 } from "@marigold/icons";
|
|
1253
1275
|
var Textarea = (_a) => {
|
|
1254
1276
|
var _b = _a, {
|
|
1255
1277
|
variant = "",
|
|
@@ -1270,10 +1292,10 @@ var Textarea = (_a) => {
|
|
|
1270
1292
|
const { labelProps, inputProps, errorMessageProps } = useTextField2(__spreadProps(__spreadValues({}, props), {
|
|
1271
1293
|
inputElementType: "textarea"
|
|
1272
1294
|
}), ref);
|
|
1273
|
-
return /* @__PURE__ */
|
|
1295
|
+
return /* @__PURE__ */ React35.createElement(Box, null, /* @__PURE__ */ React35.createElement(Label, __spreadValues({
|
|
1274
1296
|
htmlFor,
|
|
1275
1297
|
required
|
|
1276
|
-
}, labelProps), props.label), /* @__PURE__ */
|
|
1298
|
+
}, labelProps), props.label), /* @__PURE__ */ React35.createElement(Box, __spreadValues(__spreadProps(__spreadValues({
|
|
1277
1299
|
as: "textarea",
|
|
1278
1300
|
variant: `textarea.${variant}`,
|
|
1279
1301
|
css: {
|
|
@@ -1281,13 +1303,75 @@ var Textarea = (_a) => {
|
|
|
1281
1303
|
}
|
|
1282
1304
|
}, inputProps), {
|
|
1283
1305
|
ref
|
|
1284
|
-
}), props)), error && errorMessage && /* @__PURE__ */
|
|
1306
|
+
}), props)), error && errorMessage && /* @__PURE__ */ React35.createElement(ValidationMessage, __spreadValues({}, errorMessageProps), /* @__PURE__ */ React35.createElement(Exclamation6, {
|
|
1285
1307
|
size: 16
|
|
1286
1308
|
}), errorMessage));
|
|
1287
1309
|
};
|
|
1288
1310
|
|
|
1311
|
+
// src/Tiles/Tiles.tsx
|
|
1312
|
+
import React36 from "react";
|
|
1313
|
+
var Tiles = React36.forwardRef(function Tiles2(_a, ref) {
|
|
1314
|
+
var _b = _a, { space = "none", itemMinWidth = "250px", children } = _b, props = __objRest(_b, ["space", "itemMinWidth", "children"]);
|
|
1315
|
+
return /* @__PURE__ */ React36.createElement(Box, __spreadValues({
|
|
1316
|
+
ref,
|
|
1317
|
+
display: "grid",
|
|
1318
|
+
__baseCSS: {
|
|
1319
|
+
gap: space,
|
|
1320
|
+
gridTemplateColumns: `repeat(auto-fit, minmax(min(${itemMinWidth}, 100%), 1fr))`
|
|
1321
|
+
}
|
|
1322
|
+
}, props), children);
|
|
1323
|
+
});
|
|
1324
|
+
|
|
1325
|
+
// src/Tooltip/Tooltip.tsx
|
|
1326
|
+
import React38, { useContext } from "react";
|
|
1327
|
+
import { useTooltip } from "@react-aria/tooltip";
|
|
1328
|
+
import { mergeProps as mergeProps3 } from "@react-aria/utils";
|
|
1329
|
+
|
|
1330
|
+
// src/Tooltip/TooltipTrigger.tsx
|
|
1331
|
+
import React37, { useRef as useRef8 } from "react";
|
|
1332
|
+
import { FocusableProvider } from "@react-aria/focus";
|
|
1333
|
+
import { useTooltipTrigger } from "@react-aria/tooltip";
|
|
1334
|
+
import {
|
|
1335
|
+
useTooltipTriggerState
|
|
1336
|
+
} from "@react-stately/tooltip";
|
|
1337
|
+
var TooltipContext = React37.createContext({});
|
|
1338
|
+
var TooltipTrigger = (_a) => {
|
|
1339
|
+
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
1340
|
+
const [trigger, tooltip] = React37.Children.toArray(children);
|
|
1341
|
+
const state = useTooltipTriggerState(props);
|
|
1342
|
+
const tooltipTriggerRef = useRef8();
|
|
1343
|
+
const { triggerProps, tooltipProps } = useTooltipTrigger({}, state, tooltipTriggerRef);
|
|
1344
|
+
return /* @__PURE__ */ React37.createElement(FocusableProvider, __spreadProps(__spreadValues({}, triggerProps), {
|
|
1345
|
+
ref: tooltipTriggerRef
|
|
1346
|
+
}), trigger, state.isOpen && /* @__PURE__ */ React37.createElement(TooltipContext.Provider, {
|
|
1347
|
+
value: __spreadValues({
|
|
1348
|
+
state
|
|
1349
|
+
}, tooltipProps)
|
|
1350
|
+
}, tooltip));
|
|
1351
|
+
};
|
|
1352
|
+
|
|
1353
|
+
// src/Tooltip/Tooltip.tsx
|
|
1354
|
+
var Tooltip = (_a) => {
|
|
1355
|
+
var _b = _a, {
|
|
1356
|
+
variant = "",
|
|
1357
|
+
children
|
|
1358
|
+
} = _b, props = __objRest(_b, [
|
|
1359
|
+
"variant",
|
|
1360
|
+
"children"
|
|
1361
|
+
]);
|
|
1362
|
+
const _a2 = useContext(TooltipContext), { state } = _a2, tooltipProviderProps = __objRest(_a2, ["state"]);
|
|
1363
|
+
const mergedProps = mergeProps3(props, tooltipProviderProps);
|
|
1364
|
+
const { tooltipProps } = useTooltip(mergedProps, state);
|
|
1365
|
+
return /* @__PURE__ */ React38.createElement(Box, __spreadValues({
|
|
1366
|
+
position: "relative"
|
|
1367
|
+
}, tooltipProps), /* @__PURE__ */ React38.createElement(Box, __spreadValues({
|
|
1368
|
+
position: "absolute",
|
|
1369
|
+
variant: `tooltip.${variant}`
|
|
1370
|
+
}, mergedProps), children));
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1289
1373
|
// src/Input/Input.tsx
|
|
1290
|
-
import
|
|
1374
|
+
import React39 from "react";
|
|
1291
1375
|
var Input = (_a) => {
|
|
1292
1376
|
var _b = _a, {
|
|
1293
1377
|
variant = "",
|
|
@@ -1296,7 +1380,7 @@ var Input = (_a) => {
|
|
|
1296
1380
|
"variant",
|
|
1297
1381
|
"type"
|
|
1298
1382
|
]);
|
|
1299
|
-
return /* @__PURE__ */
|
|
1383
|
+
return /* @__PURE__ */ React39.createElement(Box, __spreadProps(__spreadValues({}, props), {
|
|
1300
1384
|
as: "input",
|
|
1301
1385
|
type,
|
|
1302
1386
|
variant: `input.${variant}`
|
|
@@ -1304,19 +1388,39 @@ var Input = (_a) => {
|
|
|
1304
1388
|
};
|
|
1305
1389
|
|
|
1306
1390
|
// src/Container/Container.tsx
|
|
1307
|
-
import
|
|
1391
|
+
import React40 from "react";
|
|
1392
|
+
import { size as tokenSize } from "@marigold/tokens";
|
|
1393
|
+
var ALIGNMENT3 = {
|
|
1394
|
+
left: "flex-start",
|
|
1395
|
+
center: "center",
|
|
1396
|
+
right: "flex-end"
|
|
1397
|
+
};
|
|
1308
1398
|
var Container = (_a) => {
|
|
1309
|
-
var _b = _a, {
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1399
|
+
var _b = _a, {
|
|
1400
|
+
contentType = "content",
|
|
1401
|
+
size = "medium",
|
|
1402
|
+
align = "left",
|
|
1403
|
+
children
|
|
1404
|
+
} = _b, props = __objRest(_b, [
|
|
1405
|
+
"contentType",
|
|
1406
|
+
"size",
|
|
1407
|
+
"align",
|
|
1408
|
+
"children"
|
|
1409
|
+
]);
|
|
1410
|
+
return /* @__PURE__ */ React40.createElement(Box, __spreadValues({
|
|
1411
|
+
display: "flex",
|
|
1412
|
+
flexDirection: "column",
|
|
1413
|
+
maxWidth: tokenSize[contentType][size],
|
|
1414
|
+
alignItems: ALIGNMENT3[align]
|
|
1415
|
+
}, props), children);
|
|
1313
1416
|
};
|
|
1314
1417
|
|
|
1315
1418
|
// src/index.ts
|
|
1316
1419
|
import { Item, Section } from "@react-stately/collections";
|
|
1317
1420
|
export {
|
|
1318
1421
|
ActionGroup,
|
|
1319
|
-
|
|
1422
|
+
Aside,
|
|
1423
|
+
Aspect,
|
|
1320
1424
|
Badge,
|
|
1321
1425
|
Box,
|
|
1322
1426
|
Button,
|
|
@@ -1345,9 +1449,14 @@ export {
|
|
|
1345
1449
|
Select,
|
|
1346
1450
|
Slider,
|
|
1347
1451
|
Stack,
|
|
1452
|
+
Switch,
|
|
1348
1453
|
Text,
|
|
1349
1454
|
Textarea,
|
|
1350
1455
|
ThemeProvider2 as ThemeProvider,
|
|
1456
|
+
Tiles,
|
|
1457
|
+
Tooltip,
|
|
1458
|
+
TooltipContext,
|
|
1459
|
+
TooltipTrigger,
|
|
1351
1460
|
ValidationMessage,
|
|
1352
1461
|
VisuallyHidden2 as VisuallyHidden,
|
|
1353
1462
|
useDialogButtonProps,
|