@marigold/system 1.1.0 → 1.2.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.
- package/dist/index.d.ts +19 -152
- package/dist/index.js +109 -129
- package/dist/index.mjs +101 -119
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Simplify, PolymorphicPropsWithRef, PolymorphicComponentWithRef, Compone
|
|
|
2
2
|
import * as _theme_ui_css from '@theme-ui/css';
|
|
3
3
|
import { ResponsiveStyleValue as ResponsiveStyleValue$1, ThemeUIStyleObject, ThemeUICSSObject, ThemeUICSSProperties, NestedScaleDict } from '@theme-ui/css';
|
|
4
4
|
import * as react from 'react';
|
|
5
|
-
import { ReactNode
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
6
|
import * as CSS from 'csstype';
|
|
7
7
|
|
|
8
8
|
declare type ResponsiveStyleValue<T> = ResponsiveStyleValue$1<T>;
|
|
@@ -114,6 +114,12 @@ interface ZeroSizeScale<T> extends SizeScale<T> {
|
|
|
114
114
|
* Base theme with typings for available scales properties.
|
|
115
115
|
*/
|
|
116
116
|
interface Theme {
|
|
117
|
+
/**
|
|
118
|
+
* Styles that applied to the root of the app, where the root can be either the document
|
|
119
|
+
* for full page apps or an element if you're only using Marigold on a portion of the page.
|
|
120
|
+
* This is useful for additional normalizationor and to style non-Marigold elements.
|
|
121
|
+
*/
|
|
122
|
+
root?: CSSObject;
|
|
117
123
|
/**
|
|
118
124
|
* To configure the default breakpoints used in responsive array values,
|
|
119
125
|
* add a breakpoints array to your theme.
|
|
@@ -211,7 +217,17 @@ interface BoxProps extends PolymorphicPropsWithRef<BoxOwnProps, 'div'> {
|
|
|
211
217
|
}
|
|
212
218
|
declare const Box: PolymorphicComponentWithRef<BoxOwnProps, 'div'>;
|
|
213
219
|
|
|
214
|
-
declare
|
|
220
|
+
declare type GlobalProps = {
|
|
221
|
+
/**
|
|
222
|
+
* CSS Selector to change the element that the styles will be applied to.
|
|
223
|
+
*/
|
|
224
|
+
selector?: string;
|
|
225
|
+
/**
|
|
226
|
+
* Normalize `html` and `body`? Defaults to `true`.
|
|
227
|
+
*/
|
|
228
|
+
normalizeDocument?: boolean;
|
|
229
|
+
};
|
|
230
|
+
declare const Global: ({ normalizeDocument, selector }: GlobalProps) => JSX.Element;
|
|
215
231
|
|
|
216
232
|
interface SVGProps extends ComponentProps<'svg'> {
|
|
217
233
|
size?: number | string | number[] | string[];
|
|
@@ -271,153 +287,4 @@ interface ThemeProviderProps<T extends Theme> {
|
|
|
271
287
|
}
|
|
272
288
|
declare function ThemeProvider<T extends Theme>({ theme, children, }: ThemeProviderProps<T>): JSX.Element;
|
|
273
289
|
|
|
274
|
-
|
|
275
|
-
* Normalize styling of certain elements between browsers.
|
|
276
|
-
* Based on https://www.joshwcomeau.com/css/custom-css-reset/
|
|
277
|
-
*/
|
|
278
|
-
|
|
279
|
-
declare const normalize: {
|
|
280
|
-
readonly base: {
|
|
281
|
-
readonly boxSizing: "border-box";
|
|
282
|
-
readonly margin: 0;
|
|
283
|
-
readonly minWidth: 0;
|
|
284
|
-
};
|
|
285
|
-
readonly a: {
|
|
286
|
-
readonly textDecoration: "none";
|
|
287
|
-
readonly boxSizing: "border-box";
|
|
288
|
-
readonly margin: 0;
|
|
289
|
-
readonly minWidth: 0;
|
|
290
|
-
};
|
|
291
|
-
readonly p: {
|
|
292
|
-
readonly overflowWrap: "break-word";
|
|
293
|
-
readonly boxSizing: "border-box";
|
|
294
|
-
readonly margin: 0;
|
|
295
|
-
readonly minWidth: 0;
|
|
296
|
-
};
|
|
297
|
-
readonly h1: {
|
|
298
|
-
readonly overflowWrap: "break-word";
|
|
299
|
-
readonly boxSizing: "border-box";
|
|
300
|
-
readonly margin: 0;
|
|
301
|
-
readonly minWidth: 0;
|
|
302
|
-
};
|
|
303
|
-
readonly h2: {
|
|
304
|
-
readonly overflowWrap: "break-word";
|
|
305
|
-
readonly boxSizing: "border-box";
|
|
306
|
-
readonly margin: 0;
|
|
307
|
-
readonly minWidth: 0;
|
|
308
|
-
};
|
|
309
|
-
readonly h3: {
|
|
310
|
-
readonly overflowWrap: "break-word";
|
|
311
|
-
readonly boxSizing: "border-box";
|
|
312
|
-
readonly margin: 0;
|
|
313
|
-
readonly minWidth: 0;
|
|
314
|
-
};
|
|
315
|
-
readonly h4: {
|
|
316
|
-
readonly overflowWrap: "break-word";
|
|
317
|
-
readonly boxSizing: "border-box";
|
|
318
|
-
readonly margin: 0;
|
|
319
|
-
readonly minWidth: 0;
|
|
320
|
-
};
|
|
321
|
-
readonly h5: {
|
|
322
|
-
readonly overflowWrap: "break-word";
|
|
323
|
-
readonly boxSizing: "border-box";
|
|
324
|
-
readonly margin: 0;
|
|
325
|
-
readonly minWidth: 0;
|
|
326
|
-
};
|
|
327
|
-
readonly h6: {
|
|
328
|
-
readonly overflowWrap: "break-word";
|
|
329
|
-
readonly boxSizing: "border-box";
|
|
330
|
-
readonly margin: 0;
|
|
331
|
-
readonly minWidth: 0;
|
|
332
|
-
};
|
|
333
|
-
readonly img: {
|
|
334
|
-
readonly display: "block";
|
|
335
|
-
readonly maxWidth: "100%";
|
|
336
|
-
readonly boxSizing: "border-box";
|
|
337
|
-
readonly margin: 0;
|
|
338
|
-
readonly minWidth: 0;
|
|
339
|
-
};
|
|
340
|
-
readonly picture: {
|
|
341
|
-
readonly display: "block";
|
|
342
|
-
readonly maxWidth: "100%";
|
|
343
|
-
readonly boxSizing: "border-box";
|
|
344
|
-
readonly margin: 0;
|
|
345
|
-
readonly minWidth: 0;
|
|
346
|
-
};
|
|
347
|
-
readonly video: {
|
|
348
|
-
readonly display: "block";
|
|
349
|
-
readonly maxWidth: "100%";
|
|
350
|
-
readonly boxSizing: "border-box";
|
|
351
|
-
readonly margin: 0;
|
|
352
|
-
readonly minWidth: 0;
|
|
353
|
-
};
|
|
354
|
-
readonly canvas: {
|
|
355
|
-
readonly display: "block";
|
|
356
|
-
readonly maxWidth: "100%";
|
|
357
|
-
readonly boxSizing: "border-box";
|
|
358
|
-
readonly margin: 0;
|
|
359
|
-
readonly minWidth: 0;
|
|
360
|
-
};
|
|
361
|
-
readonly svg: {
|
|
362
|
-
readonly display: "block";
|
|
363
|
-
readonly maxWidth: "100%";
|
|
364
|
-
readonly boxSizing: "border-box";
|
|
365
|
-
readonly margin: 0;
|
|
366
|
-
readonly minWidth: 0;
|
|
367
|
-
};
|
|
368
|
-
readonly select: {
|
|
369
|
-
readonly display: "block";
|
|
370
|
-
readonly appearance: "none";
|
|
371
|
-
readonly font: "inherit";
|
|
372
|
-
readonly '&::-ms-expand': {
|
|
373
|
-
readonly display: "none";
|
|
374
|
-
};
|
|
375
|
-
readonly boxSizing: "border-box";
|
|
376
|
-
readonly margin: 0;
|
|
377
|
-
readonly minWidth: 0;
|
|
378
|
-
};
|
|
379
|
-
readonly button: {
|
|
380
|
-
readonly display: "block";
|
|
381
|
-
readonly appearance: "none";
|
|
382
|
-
readonly font: "inherit";
|
|
383
|
-
readonly background: "transparent";
|
|
384
|
-
readonly textAlign: "center";
|
|
385
|
-
readonly boxSizing: "border-box";
|
|
386
|
-
readonly margin: 0;
|
|
387
|
-
readonly minWidth: 0;
|
|
388
|
-
};
|
|
389
|
-
readonly textarea: {
|
|
390
|
-
readonly display: "block";
|
|
391
|
-
readonly appearance: "none";
|
|
392
|
-
readonly font: "inherit";
|
|
393
|
-
readonly boxSizing: "border-box";
|
|
394
|
-
readonly margin: 0;
|
|
395
|
-
readonly minWidth: 0;
|
|
396
|
-
};
|
|
397
|
-
readonly input: {
|
|
398
|
-
readonly display: "block";
|
|
399
|
-
readonly appearance: "none";
|
|
400
|
-
readonly font: "inherit";
|
|
401
|
-
readonly '&::-ms-clear': {
|
|
402
|
-
readonly display: "none";
|
|
403
|
-
};
|
|
404
|
-
readonly '&::-webkit-search-cancel-button': {
|
|
405
|
-
readonly WebkitAppearance: "none";
|
|
406
|
-
};
|
|
407
|
-
readonly boxSizing: "border-box";
|
|
408
|
-
readonly margin: 0;
|
|
409
|
-
readonly minWidth: 0;
|
|
410
|
-
};
|
|
411
|
-
};
|
|
412
|
-
declare type NormalizedElement = keyof typeof normalize;
|
|
413
|
-
/**
|
|
414
|
-
* Type-safe helper to get normalization. If no normalization is found,
|
|
415
|
-
* returns the *base* normalization.
|
|
416
|
-
*/
|
|
417
|
-
declare const getNormalizedStyles: (val?: ElementType<any> | undefined) => {
|
|
418
|
-
readonly boxSizing: "border-box";
|
|
419
|
-
readonly margin: 0;
|
|
420
|
-
readonly minWidth: 0;
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
export { Box, BoxOwnProps, BoxProps, CSSObject, CSSProperties, ComponentState, ComponentStyleParts, ComponentStylesProps, Global, NormalizedElement, ResponsiveStyleValue, SVG, SVGProps, Scale, ScaleValue, SizeScale, StateAttrKeyProps, StateAttrProps, StyleObject, StyleProps, Theme, ThemeComponentProps, ThemeExtension, ThemeExtensionsWithParts, ThemeProvider, ThemeProviderProps, UseStateProps, ZeroScale, ZeroSizeScale, __defaultTheme, getNormalizedStyles, normalize, useComponentStyles, useResponsiveValue, useStateProps, useTheme };
|
|
290
|
+
export { Box, BoxOwnProps, BoxProps, CSSObject, CSSProperties, ComponentState, ComponentStyleParts, ComponentStylesProps, Global, GlobalProps, ResponsiveStyleValue, SVG, SVGProps, Scale, ScaleValue, SizeScale, StateAttrKeyProps, StateAttrProps, StyleObject, StyleProps, Theme, ThemeComponentProps, ThemeExtension, ThemeExtensionsWithParts, ThemeProvider, ThemeProviderProps, UseStateProps, ZeroScale, ZeroSizeScale, __defaultTheme, useComponentStyles, useResponsiveValue, useStateProps, useTheme };
|
package/dist/index.js
CHANGED
|
@@ -9,18 +9,18 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
10
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
11
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
13
|
for (var prop in b || (b = {}))
|
|
14
14
|
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
16
|
if (__getOwnPropSymbols)
|
|
17
17
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
18
|
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
20
|
}
|
|
21
|
-
return
|
|
21
|
+
return a;
|
|
22
22
|
};
|
|
23
|
-
var __spreadProps = (
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
24
|
var __objRest = (source, exclude) => {
|
|
25
25
|
var target = {};
|
|
26
26
|
for (var prop in source)
|
|
@@ -56,8 +56,6 @@ __export(src_exports, {
|
|
|
56
56
|
SVG: () => SVG,
|
|
57
57
|
ThemeProvider: () => ThemeProvider,
|
|
58
58
|
__defaultTheme: () => __defaultTheme,
|
|
59
|
-
getNormalizedStyles: () => getNormalizedStyles,
|
|
60
|
-
normalize: () => normalize,
|
|
61
59
|
useComponentStyles: () => useComponentStyles,
|
|
62
60
|
useResponsiveValue: () => useResponsiveValue,
|
|
63
61
|
useStateProps: () => useStateProps,
|
|
@@ -71,76 +69,7 @@ var import_react2 = require("@emotion/react");
|
|
|
71
69
|
var import_css = require("@theme-ui/css");
|
|
72
70
|
var import_deepmerge = __toESM(require("deepmerge"));
|
|
73
71
|
|
|
74
|
-
// src/
|
|
75
|
-
var base = {
|
|
76
|
-
boxSizing: "border-box",
|
|
77
|
-
margin: 0,
|
|
78
|
-
minWidth: 0
|
|
79
|
-
};
|
|
80
|
-
var a = __spreadProps(__spreadValues({}, base), {
|
|
81
|
-
textDecoration: "none"
|
|
82
|
-
});
|
|
83
|
-
var text = __spreadProps(__spreadValues({}, base), {
|
|
84
|
-
overflowWrap: "break-word"
|
|
85
|
-
});
|
|
86
|
-
var media = __spreadProps(__spreadValues({}, base), {
|
|
87
|
-
display: "block",
|
|
88
|
-
maxWidth: "100%"
|
|
89
|
-
});
|
|
90
|
-
var button = __spreadProps(__spreadValues({}, base), {
|
|
91
|
-
display: "block",
|
|
92
|
-
appearance: "none",
|
|
93
|
-
font: "inherit",
|
|
94
|
-
background: "transparent",
|
|
95
|
-
textAlign: "center"
|
|
96
|
-
});
|
|
97
|
-
var input = __spreadProps(__spreadValues({}, base), {
|
|
98
|
-
display: "block",
|
|
99
|
-
appearance: "none",
|
|
100
|
-
font: "inherit",
|
|
101
|
-
"&::-ms-clear": {
|
|
102
|
-
display: "none"
|
|
103
|
-
},
|
|
104
|
-
"&::-webkit-search-cancel-button": {
|
|
105
|
-
WebkitAppearance: "none"
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
var select = __spreadProps(__spreadValues({}, base), {
|
|
109
|
-
display: "block",
|
|
110
|
-
appearance: "none",
|
|
111
|
-
font: "inherit",
|
|
112
|
-
"&::-ms-expand": {
|
|
113
|
-
display: "none"
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
var textarea = __spreadProps(__spreadValues({}, base), {
|
|
117
|
-
display: "block",
|
|
118
|
-
appearance: "none",
|
|
119
|
-
font: "inherit"
|
|
120
|
-
});
|
|
121
|
-
var normalize = {
|
|
122
|
-
base,
|
|
123
|
-
a,
|
|
124
|
-
p: text,
|
|
125
|
-
h1: text,
|
|
126
|
-
h2: text,
|
|
127
|
-
h3: text,
|
|
128
|
-
h4: text,
|
|
129
|
-
h5: text,
|
|
130
|
-
h6: text,
|
|
131
|
-
img: media,
|
|
132
|
-
picture: media,
|
|
133
|
-
video: media,
|
|
134
|
-
canvas: media,
|
|
135
|
-
svg: media,
|
|
136
|
-
select,
|
|
137
|
-
button,
|
|
138
|
-
textarea,
|
|
139
|
-
input
|
|
140
|
-
};
|
|
141
|
-
var getNormalizedStyles = (val) => typeof val === "string" && val in normalize ? normalize[val] : normalize.base;
|
|
142
|
-
|
|
143
|
-
// src/components/Box/utils.ts
|
|
72
|
+
// src/components/Box/selector.ts
|
|
144
73
|
var createteSelector = (selectors, states, suffix = "") => {
|
|
145
74
|
return selectors.map((selector2) => states.map((state2) => `${selector2}${state2}${suffix ? ` ${suffix}` : ""}`)).flat().join(", ");
|
|
146
75
|
};
|
|
@@ -199,7 +128,6 @@ var transformPseudos = (styles) => {
|
|
|
199
128
|
// src/components/Box/Box.tsx
|
|
200
129
|
var createThemedStyle = ({ as, __baseCSS, styles, css }) => (theme) => {
|
|
201
130
|
const themedStyles = import_deepmerge.default.all([
|
|
202
|
-
getNormalizedStyles(as),
|
|
203
131
|
(0, import_css.css)(__baseCSS)(theme),
|
|
204
132
|
(0, import_css.css)(styles)(theme),
|
|
205
133
|
(0, import_css.css)(css)(theme)
|
|
@@ -345,13 +273,8 @@ var Box = (0, import_react.forwardRef)((_a, ref) => {
|
|
|
345
273
|
});
|
|
346
274
|
|
|
347
275
|
// src/components/Global/Global.tsx
|
|
348
|
-
var
|
|
349
|
-
var
|
|
350
|
-
|
|
351
|
-
// src/hooks/useComponentStyles.ts
|
|
352
|
-
var import_deepmerge2 = __toESM(require("deepmerge"));
|
|
353
|
-
var import_react5 = require("react");
|
|
354
|
-
var import_react_fast_compare = __toESM(require("react-fast-compare"));
|
|
276
|
+
var import_react5 = __toESM(require("react"));
|
|
277
|
+
var import_react6 = require("@emotion/react");
|
|
355
278
|
|
|
356
279
|
// src/hooks/useTheme.tsx
|
|
357
280
|
var import_react3 = __toESM(require("react"));
|
|
@@ -376,7 +299,98 @@ function ThemeProvider({
|
|
|
376
299
|
}, children));
|
|
377
300
|
}
|
|
378
301
|
|
|
302
|
+
// src/components/Global/normalize.ts
|
|
303
|
+
var document = {
|
|
304
|
+
"html, body": {
|
|
305
|
+
height: "100%"
|
|
306
|
+
},
|
|
307
|
+
html: {
|
|
308
|
+
textSizeAdjust: "none"
|
|
309
|
+
},
|
|
310
|
+
body: {
|
|
311
|
+
lineHeight: 1.5,
|
|
312
|
+
WebkitFontSmoothing: "antialiased",
|
|
313
|
+
margin: 0
|
|
314
|
+
},
|
|
315
|
+
"@media screen and (prefers-reduced-motion: reduce), (update: slow)": {
|
|
316
|
+
"*": {
|
|
317
|
+
animationDuration: "0.001ms !important",
|
|
318
|
+
animationIterationCount: "1 !important",
|
|
319
|
+
transitionDuration: "0.001ms !important"
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
var element = {
|
|
324
|
+
"*, *::before, *::after": {
|
|
325
|
+
boxSizing: "border-box"
|
|
326
|
+
},
|
|
327
|
+
"*": {
|
|
328
|
+
margin: 0
|
|
329
|
+
},
|
|
330
|
+
a: {
|
|
331
|
+
textDecoration: "none"
|
|
332
|
+
},
|
|
333
|
+
"p, h1, h2, h3, h4, h5, h6": {
|
|
334
|
+
overflowWrap: "break-word"
|
|
335
|
+
},
|
|
336
|
+
"img, picture, video, canvas, svg": {
|
|
337
|
+
display: "block",
|
|
338
|
+
maxWidth: "100%"
|
|
339
|
+
},
|
|
340
|
+
button: {
|
|
341
|
+
display: "block",
|
|
342
|
+
appearance: "none",
|
|
343
|
+
font: "inherit",
|
|
344
|
+
background: "transparent",
|
|
345
|
+
textAlign: "center"
|
|
346
|
+
},
|
|
347
|
+
input: {
|
|
348
|
+
display: "block",
|
|
349
|
+
appearance: "none",
|
|
350
|
+
font: "inherit",
|
|
351
|
+
"&::-ms-clear": {
|
|
352
|
+
display: "none"
|
|
353
|
+
},
|
|
354
|
+
"&::-webkit-search-cancel-button": {
|
|
355
|
+
WebkitAppearance: "none"
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
select: {
|
|
359
|
+
display: "block",
|
|
360
|
+
appearance: "none",
|
|
361
|
+
font: "inherit",
|
|
362
|
+
"&::-ms-expand": {
|
|
363
|
+
display: "none"
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
textarea: {
|
|
367
|
+
display: "block",
|
|
368
|
+
appearance: "none",
|
|
369
|
+
font: "inherit"
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
// src/components/Global/Global.tsx
|
|
374
|
+
var Global = ({ normalizeDocument = true, selector: selector2 }) => {
|
|
375
|
+
const { css, theme } = useTheme();
|
|
376
|
+
const rootStyles = css((theme == null ? void 0 : theme.root) || {});
|
|
377
|
+
const styles = [
|
|
378
|
+
normalizeDocument ? document : {},
|
|
379
|
+
selector2 ? { [`:where(${selector2})`]: element } : element,
|
|
380
|
+
selector2 ? { [`:where(${selector2})`]: rootStyles } : rootStyles
|
|
381
|
+
];
|
|
382
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react6.Global, {
|
|
383
|
+
styles
|
|
384
|
+
});
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
// src/components/SVG/SVG.tsx
|
|
388
|
+
var import_react10 = require("@emotion/react");
|
|
389
|
+
|
|
379
390
|
// src/hooks/useComponentStyles.ts
|
|
391
|
+
var import_deepmerge2 = __toESM(require("deepmerge"));
|
|
392
|
+
var import_react7 = require("react");
|
|
393
|
+
var import_react_fast_compare = __toESM(require("react-fast-compare"));
|
|
380
394
|
var get = (obj, path, fallback) => {
|
|
381
395
|
const key = path.split(".");
|
|
382
396
|
let result = obj;
|
|
@@ -391,12 +405,12 @@ function useComponentStyles(componentName, props = {}, options = {}) {
|
|
|
391
405
|
var _a, _b;
|
|
392
406
|
const { theme } = useTheme();
|
|
393
407
|
const componentStyles = get(theme, `components.${componentName}`);
|
|
394
|
-
const stylesRef = (0,
|
|
408
|
+
const stylesRef = (0, import_react7.useRef)({});
|
|
395
409
|
if (componentStyles) {
|
|
396
|
-
const
|
|
410
|
+
const base = componentStyles.base || {};
|
|
397
411
|
const size = ((_a = componentStyles.size) == null ? void 0 : _a[props.size]) || {};
|
|
398
412
|
const variant = ((_b = componentStyles.variant) == null ? void 0 : _b[props.variant]) || {};
|
|
399
|
-
let styles = import_deepmerge2.default.all([
|
|
413
|
+
let styles = import_deepmerge2.default.all([base, size, variant]);
|
|
400
414
|
if (options.parts) {
|
|
401
415
|
styles = options.parts.reduce((result, part) => {
|
|
402
416
|
result[part] = styles[part] || {};
|
|
@@ -411,7 +425,7 @@ function useComponentStyles(componentName, props = {}, options = {}) {
|
|
|
411
425
|
}
|
|
412
426
|
|
|
413
427
|
// src/hooks/useResponsiveValue.ts
|
|
414
|
-
var
|
|
428
|
+
var import_react8 = require("react");
|
|
415
429
|
var emptyBreakpoints = ["40em", "52em", "64em"];
|
|
416
430
|
var useResponsiveValue = (values, defaultIndex = 0) => {
|
|
417
431
|
const { theme } = useTheme();
|
|
@@ -419,8 +433,8 @@ var useResponsiveValue = (values, defaultIndex = 0) => {
|
|
|
419
433
|
if (defaultIndex < 0 || defaultIndex >= breakpoints.length) {
|
|
420
434
|
throw new RangeError(`Default breakpoint index is out of bounds. Theme has ${breakpoints.length} breakpoints, default is ${defaultIndex}.`);
|
|
421
435
|
}
|
|
422
|
-
const [index, setIndex] = (0,
|
|
423
|
-
(0,
|
|
436
|
+
const [index, setIndex] = (0, import_react8.useState)(defaultIndex);
|
|
437
|
+
(0, import_react8.useEffect)(() => {
|
|
424
438
|
const getIndex = () => breakpoints.filter((breakpoint) => window.matchMedia(`screen and (min-width: ${breakpoint})`).matches).length;
|
|
425
439
|
const handleResize = () => {
|
|
426
440
|
const newIndex = getIndex();
|
|
@@ -436,12 +450,12 @@ var useResponsiveValue = (values, defaultIndex = 0) => {
|
|
|
436
450
|
};
|
|
437
451
|
|
|
438
452
|
// src/hooks/useStateProps.ts
|
|
439
|
-
var
|
|
453
|
+
var import_react9 = require("react");
|
|
440
454
|
var import_react_fast_compare2 = __toESM(require("react-fast-compare"));
|
|
441
455
|
var KEBAB_REGEX = /[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;
|
|
442
456
|
var toKebap = (val) => val.replace(KEBAB_REGEX, (match) => `-${match.toLocaleLowerCase()}`);
|
|
443
457
|
var useStateProps = (states) => {
|
|
444
|
-
const statePropsRef = (0,
|
|
458
|
+
const statePropsRef = (0, import_react9.useRef)({});
|
|
445
459
|
let stateProps = {};
|
|
446
460
|
for (let state2 in states) {
|
|
447
461
|
if (states[state2]) {
|
|
@@ -455,39 +469,7 @@ var useStateProps = (states) => {
|
|
|
455
469
|
return statePropsRef.current;
|
|
456
470
|
};
|
|
457
471
|
|
|
458
|
-
// src/components/Global/Global.tsx
|
|
459
|
-
var reduceMotionStyles = {
|
|
460
|
-
"@media screen and (prefers-reduced-motion: reduce), (update: slow)": {
|
|
461
|
-
"*": {
|
|
462
|
-
animationDuration: "0.001ms !important",
|
|
463
|
-
animationIterationCount: "1 !important",
|
|
464
|
-
transitionDuration: "0.001ms !important"
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
var Global = () => {
|
|
469
|
-
const { css } = useTheme();
|
|
470
|
-
const styles = css({
|
|
471
|
-
html: {
|
|
472
|
-
height: "100%",
|
|
473
|
-
textSizeAdjust: "none",
|
|
474
|
-
variant: "root.html"
|
|
475
|
-
},
|
|
476
|
-
body: {
|
|
477
|
-
height: "100%",
|
|
478
|
-
lineHeight: 1.5,
|
|
479
|
-
WebkitFontSmoothing: "antialiased",
|
|
480
|
-
variant: "root.body"
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
return /* @__PURE__ */ import_react8.default.createElement(import_react9.Global, {
|
|
484
|
-
styles: __spreadValues({ reduceMotionStyles }, styles)
|
|
485
|
-
});
|
|
486
|
-
};
|
|
487
|
-
|
|
488
472
|
// src/components/SVG/SVG.tsx
|
|
489
|
-
var import_react10 = require("@emotion/react");
|
|
490
|
-
var normalizedStyles = getNormalizedStyles("svg");
|
|
491
473
|
var toDimension = (value) => Array.isArray(value) ? value.map(ensureNumberOrToken) : ensureNumberOrToken(value);
|
|
492
474
|
var ensureNumberOrToken = (value) => typeof value === "string" && /[0-9]+/.test(value) ? Number(value) : value;
|
|
493
475
|
var SVG = (_a) => {
|
|
@@ -503,11 +485,11 @@ var SVG = (_a) => {
|
|
|
503
485
|
const { css } = useTheme();
|
|
504
486
|
return (0, import_react10.jsx)("svg", __spreadValues({
|
|
505
487
|
viewBox: "0 0 24 24",
|
|
506
|
-
css: css(
|
|
488
|
+
css: css({
|
|
507
489
|
fill,
|
|
508
490
|
width: toDimension(props.width || size),
|
|
509
491
|
height: toDimension(props.height || size)
|
|
510
|
-
})
|
|
492
|
+
})
|
|
511
493
|
}, props), children);
|
|
512
494
|
};
|
|
513
495
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -517,8 +499,6 @@ var SVG = (_a) => {
|
|
|
517
499
|
SVG,
|
|
518
500
|
ThemeProvider,
|
|
519
501
|
__defaultTheme,
|
|
520
|
-
getNormalizedStyles,
|
|
521
|
-
normalize,
|
|
522
502
|
useComponentStyles,
|
|
523
503
|
useResponsiveValue,
|
|
524
504
|
useStateProps,
|
package/dist/index.mjs
CHANGED
|
@@ -5,18 +5,18 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
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 = (
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
9
|
for (var prop in b || (b = {}))
|
|
10
10
|
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
12
|
if (__getOwnPropSymbols)
|
|
13
13
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
14
|
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
16
|
}
|
|
17
|
-
return
|
|
17
|
+
return a;
|
|
18
18
|
};
|
|
19
|
-
var __spreadProps = (
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
var __objRest = (source, exclude) => {
|
|
21
21
|
var target = {};
|
|
22
22
|
for (var prop in source)
|
|
@@ -36,76 +36,7 @@ import { jsx } from "@emotion/react";
|
|
|
36
36
|
import { css as transformStyleObject } from "@theme-ui/css";
|
|
37
37
|
import merge from "deepmerge";
|
|
38
38
|
|
|
39
|
-
// src/
|
|
40
|
-
var base = {
|
|
41
|
-
boxSizing: "border-box",
|
|
42
|
-
margin: 0,
|
|
43
|
-
minWidth: 0
|
|
44
|
-
};
|
|
45
|
-
var a = __spreadProps(__spreadValues({}, base), {
|
|
46
|
-
textDecoration: "none"
|
|
47
|
-
});
|
|
48
|
-
var text = __spreadProps(__spreadValues({}, base), {
|
|
49
|
-
overflowWrap: "break-word"
|
|
50
|
-
});
|
|
51
|
-
var media = __spreadProps(__spreadValues({}, base), {
|
|
52
|
-
display: "block",
|
|
53
|
-
maxWidth: "100%"
|
|
54
|
-
});
|
|
55
|
-
var button = __spreadProps(__spreadValues({}, base), {
|
|
56
|
-
display: "block",
|
|
57
|
-
appearance: "none",
|
|
58
|
-
font: "inherit",
|
|
59
|
-
background: "transparent",
|
|
60
|
-
textAlign: "center"
|
|
61
|
-
});
|
|
62
|
-
var input = __spreadProps(__spreadValues({}, base), {
|
|
63
|
-
display: "block",
|
|
64
|
-
appearance: "none",
|
|
65
|
-
font: "inherit",
|
|
66
|
-
"&::-ms-clear": {
|
|
67
|
-
display: "none"
|
|
68
|
-
},
|
|
69
|
-
"&::-webkit-search-cancel-button": {
|
|
70
|
-
WebkitAppearance: "none"
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
var select = __spreadProps(__spreadValues({}, base), {
|
|
74
|
-
display: "block",
|
|
75
|
-
appearance: "none",
|
|
76
|
-
font: "inherit",
|
|
77
|
-
"&::-ms-expand": {
|
|
78
|
-
display: "none"
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
var textarea = __spreadProps(__spreadValues({}, base), {
|
|
82
|
-
display: "block",
|
|
83
|
-
appearance: "none",
|
|
84
|
-
font: "inherit"
|
|
85
|
-
});
|
|
86
|
-
var normalize = {
|
|
87
|
-
base,
|
|
88
|
-
a,
|
|
89
|
-
p: text,
|
|
90
|
-
h1: text,
|
|
91
|
-
h2: text,
|
|
92
|
-
h3: text,
|
|
93
|
-
h4: text,
|
|
94
|
-
h5: text,
|
|
95
|
-
h6: text,
|
|
96
|
-
img: media,
|
|
97
|
-
picture: media,
|
|
98
|
-
video: media,
|
|
99
|
-
canvas: media,
|
|
100
|
-
svg: media,
|
|
101
|
-
select,
|
|
102
|
-
button,
|
|
103
|
-
textarea,
|
|
104
|
-
input
|
|
105
|
-
};
|
|
106
|
-
var getNormalizedStyles = (val) => typeof val === "string" && val in normalize ? normalize[val] : normalize.base;
|
|
107
|
-
|
|
108
|
-
// src/components/Box/utils.ts
|
|
39
|
+
// src/components/Box/selector.ts
|
|
109
40
|
var createteSelector = (selectors, states, suffix = "") => {
|
|
110
41
|
return selectors.map((selector2) => states.map((state2) => `${selector2}${state2}${suffix ? ` ${suffix}` : ""}`)).flat().join(", ");
|
|
111
42
|
};
|
|
@@ -164,7 +95,6 @@ var transformPseudos = (styles) => {
|
|
|
164
95
|
// src/components/Box/Box.tsx
|
|
165
96
|
var createThemedStyle = ({ as, __baseCSS, styles, css }) => (theme) => {
|
|
166
97
|
const themedStyles = merge.all([
|
|
167
|
-
getNormalizedStyles(as),
|
|
168
98
|
transformStyleObject(__baseCSS)(theme),
|
|
169
99
|
transformStyleObject(styles)(theme),
|
|
170
100
|
transformStyleObject(css)(theme)
|
|
@@ -313,11 +243,6 @@ var Box = forwardRef((_a, ref) => {
|
|
|
313
243
|
import React2 from "react";
|
|
314
244
|
import { Global as EmotionGlobal } from "@emotion/react";
|
|
315
245
|
|
|
316
|
-
// src/hooks/useComponentStyles.ts
|
|
317
|
-
import merge2 from "deepmerge";
|
|
318
|
-
import { useRef } from "react";
|
|
319
|
-
import isEqual from "react-fast-compare";
|
|
320
|
-
|
|
321
246
|
// src/hooks/useTheme.tsx
|
|
322
247
|
import React, {
|
|
323
248
|
createContext,
|
|
@@ -348,7 +273,98 @@ function ThemeProvider({
|
|
|
348
273
|
}, children));
|
|
349
274
|
}
|
|
350
275
|
|
|
276
|
+
// src/components/Global/normalize.ts
|
|
277
|
+
var document = {
|
|
278
|
+
"html, body": {
|
|
279
|
+
height: "100%"
|
|
280
|
+
},
|
|
281
|
+
html: {
|
|
282
|
+
textSizeAdjust: "none"
|
|
283
|
+
},
|
|
284
|
+
body: {
|
|
285
|
+
lineHeight: 1.5,
|
|
286
|
+
WebkitFontSmoothing: "antialiased",
|
|
287
|
+
margin: 0
|
|
288
|
+
},
|
|
289
|
+
"@media screen and (prefers-reduced-motion: reduce), (update: slow)": {
|
|
290
|
+
"*": {
|
|
291
|
+
animationDuration: "0.001ms !important",
|
|
292
|
+
animationIterationCount: "1 !important",
|
|
293
|
+
transitionDuration: "0.001ms !important"
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
var element = {
|
|
298
|
+
"*, *::before, *::after": {
|
|
299
|
+
boxSizing: "border-box"
|
|
300
|
+
},
|
|
301
|
+
"*": {
|
|
302
|
+
margin: 0
|
|
303
|
+
},
|
|
304
|
+
a: {
|
|
305
|
+
textDecoration: "none"
|
|
306
|
+
},
|
|
307
|
+
"p, h1, h2, h3, h4, h5, h6": {
|
|
308
|
+
overflowWrap: "break-word"
|
|
309
|
+
},
|
|
310
|
+
"img, picture, video, canvas, svg": {
|
|
311
|
+
display: "block",
|
|
312
|
+
maxWidth: "100%"
|
|
313
|
+
},
|
|
314
|
+
button: {
|
|
315
|
+
display: "block",
|
|
316
|
+
appearance: "none",
|
|
317
|
+
font: "inherit",
|
|
318
|
+
background: "transparent",
|
|
319
|
+
textAlign: "center"
|
|
320
|
+
},
|
|
321
|
+
input: {
|
|
322
|
+
display: "block",
|
|
323
|
+
appearance: "none",
|
|
324
|
+
font: "inherit",
|
|
325
|
+
"&::-ms-clear": {
|
|
326
|
+
display: "none"
|
|
327
|
+
},
|
|
328
|
+
"&::-webkit-search-cancel-button": {
|
|
329
|
+
WebkitAppearance: "none"
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
select: {
|
|
333
|
+
display: "block",
|
|
334
|
+
appearance: "none",
|
|
335
|
+
font: "inherit",
|
|
336
|
+
"&::-ms-expand": {
|
|
337
|
+
display: "none"
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
textarea: {
|
|
341
|
+
display: "block",
|
|
342
|
+
appearance: "none",
|
|
343
|
+
font: "inherit"
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
// src/components/Global/Global.tsx
|
|
348
|
+
var Global = ({ normalizeDocument = true, selector: selector2 }) => {
|
|
349
|
+
const { css, theme } = useTheme();
|
|
350
|
+
const rootStyles = css((theme == null ? void 0 : theme.root) || {});
|
|
351
|
+
const styles = [
|
|
352
|
+
normalizeDocument ? document : {},
|
|
353
|
+
selector2 ? { [`:where(${selector2})`]: element } : element,
|
|
354
|
+
selector2 ? { [`:where(${selector2})`]: rootStyles } : rootStyles
|
|
355
|
+
];
|
|
356
|
+
return /* @__PURE__ */ React2.createElement(EmotionGlobal, {
|
|
357
|
+
styles
|
|
358
|
+
});
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
// src/components/SVG/SVG.tsx
|
|
362
|
+
import { jsx as jsx2 } from "@emotion/react";
|
|
363
|
+
|
|
351
364
|
// src/hooks/useComponentStyles.ts
|
|
365
|
+
import merge2 from "deepmerge";
|
|
366
|
+
import { useRef } from "react";
|
|
367
|
+
import isEqual from "react-fast-compare";
|
|
352
368
|
var get = (obj, path, fallback) => {
|
|
353
369
|
const key = path.split(".");
|
|
354
370
|
let result = obj;
|
|
@@ -365,10 +381,10 @@ function useComponentStyles(componentName, props = {}, options = {}) {
|
|
|
365
381
|
const componentStyles = get(theme, `components.${componentName}`);
|
|
366
382
|
const stylesRef = useRef({});
|
|
367
383
|
if (componentStyles) {
|
|
368
|
-
const
|
|
384
|
+
const base = componentStyles.base || {};
|
|
369
385
|
const size = ((_a = componentStyles.size) == null ? void 0 : _a[props.size]) || {};
|
|
370
386
|
const variant = ((_b = componentStyles.variant) == null ? void 0 : _b[props.variant]) || {};
|
|
371
|
-
let styles = merge2.all([
|
|
387
|
+
let styles = merge2.all([base, size, variant]);
|
|
372
388
|
if (options.parts) {
|
|
373
389
|
styles = options.parts.reduce((result, part) => {
|
|
374
390
|
result[part] = styles[part] || {};
|
|
@@ -427,39 +443,7 @@ var useStateProps = (states) => {
|
|
|
427
443
|
return statePropsRef.current;
|
|
428
444
|
};
|
|
429
445
|
|
|
430
|
-
// src/components/Global/Global.tsx
|
|
431
|
-
var reduceMotionStyles = {
|
|
432
|
-
"@media screen and (prefers-reduced-motion: reduce), (update: slow)": {
|
|
433
|
-
"*": {
|
|
434
|
-
animationDuration: "0.001ms !important",
|
|
435
|
-
animationIterationCount: "1 !important",
|
|
436
|
-
transitionDuration: "0.001ms !important"
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
var Global = () => {
|
|
441
|
-
const { css } = useTheme();
|
|
442
|
-
const styles = css({
|
|
443
|
-
html: {
|
|
444
|
-
height: "100%",
|
|
445
|
-
textSizeAdjust: "none",
|
|
446
|
-
variant: "root.html"
|
|
447
|
-
},
|
|
448
|
-
body: {
|
|
449
|
-
height: "100%",
|
|
450
|
-
lineHeight: 1.5,
|
|
451
|
-
WebkitFontSmoothing: "antialiased",
|
|
452
|
-
variant: "root.body"
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
return /* @__PURE__ */ React2.createElement(EmotionGlobal, {
|
|
456
|
-
styles: __spreadValues({ reduceMotionStyles }, styles)
|
|
457
|
-
});
|
|
458
|
-
};
|
|
459
|
-
|
|
460
446
|
// src/components/SVG/SVG.tsx
|
|
461
|
-
import { jsx as jsx2 } from "@emotion/react";
|
|
462
|
-
var normalizedStyles = getNormalizedStyles("svg");
|
|
463
447
|
var toDimension = (value) => Array.isArray(value) ? value.map(ensureNumberOrToken) : ensureNumberOrToken(value);
|
|
464
448
|
var ensureNumberOrToken = (value) => typeof value === "string" && /[0-9]+/.test(value) ? Number(value) : value;
|
|
465
449
|
var SVG = (_a) => {
|
|
@@ -475,11 +459,11 @@ var SVG = (_a) => {
|
|
|
475
459
|
const { css } = useTheme();
|
|
476
460
|
return jsx2("svg", __spreadValues({
|
|
477
461
|
viewBox: "0 0 24 24",
|
|
478
|
-
css: css(
|
|
462
|
+
css: css({
|
|
479
463
|
fill,
|
|
480
464
|
width: toDimension(props.width || size),
|
|
481
465
|
height: toDimension(props.height || size)
|
|
482
|
-
})
|
|
466
|
+
})
|
|
483
467
|
}, props), children);
|
|
484
468
|
};
|
|
485
469
|
export {
|
|
@@ -488,8 +472,6 @@ export {
|
|
|
488
472
|
SVG,
|
|
489
473
|
ThemeProvider,
|
|
490
474
|
__defaultTheme,
|
|
491
|
-
getNormalizedStyles,
|
|
492
|
-
normalize,
|
|
493
475
|
useComponentStyles,
|
|
494
476
|
useResponsiveValue,
|
|
495
477
|
useStateProps,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marigold/system",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Marigold System Library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -27,21 +27,21 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@emotion/react": "11.9.0",
|
|
30
|
-
"@marigold/types": "0.5.
|
|
30
|
+
"@marigold/types": "0.5.2",
|
|
31
31
|
"@theme-ui/css": "0.14.5",
|
|
32
|
-
"csstype": "3.0
|
|
32
|
+
"csstype": "3.1.0",
|
|
33
33
|
"deepmerge": "^4.2.2",
|
|
34
34
|
"react-fast-compare": "^3.2.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"react": "
|
|
38
|
-
"react-dom": "
|
|
37
|
+
"react": "16.x || 17.x || 18.x",
|
|
38
|
+
"react-dom": "16.x || 17.x || 18.x"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@babel/core": "7.17.12",
|
|
42
42
|
"@marigold/tsconfig": "0.3.0",
|
|
43
|
-
"react": "
|
|
44
|
-
"tsup": "
|
|
43
|
+
"react": "18.1.0",
|
|
44
|
+
"tsup": "6.0.1"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsup src/index.ts",
|