@marigold/system 1.1.1 → 1.2.2

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 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, ElementType } from 'react';
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 const Global: () => JSX.Element;
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) => {
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
@@ -1,38 +1,10 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
6
  var __getProtoOf = Object.getPrototypeOf;
9
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
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 = (a2, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a2, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a2, prop, b[prop]);
20
- }
21
- return a2;
22
- };
23
- var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
24
- var __objRest = (source, exclude) => {
25
- var target = {};
26
- for (var prop in source)
27
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
- target[prop] = source[prop];
29
- if (source != null && __getOwnPropSymbols)
30
- for (var prop of __getOwnPropSymbols(source)) {
31
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
- target[prop] = source[prop];
33
- }
34
- return target;
35
- };
36
8
  var __export = (target, all) => {
37
9
  for (var name in all)
38
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -56,8 +28,6 @@ __export(src_exports, {
56
28
  SVG: () => SVG,
57
29
  ThemeProvider: () => ThemeProvider,
58
30
  __defaultTheme: () => __defaultTheme,
59
- getNormalizedStyles: () => getNormalizedStyles,
60
- normalize: () => normalize,
61
31
  useComponentStyles: () => useComponentStyles,
62
32
  useResponsiveValue: () => useResponsiveValue,
63
33
  useStateProps: () => useStateProps,
@@ -71,76 +41,7 @@ var import_react2 = require("@emotion/react");
71
41
  var import_css = require("@theme-ui/css");
72
42
  var import_deepmerge = __toESM(require("deepmerge"));
73
43
 
74
- // src/normalize.ts
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
44
+ // src/components/Box/selector.ts
144
45
  var createteSelector = (selectors, states, suffix = "") => {
145
46
  return selectors.map((selector2) => states.map((state2) => `${selector2}${state2}${suffix ? ` ${suffix}` : ""}`)).flat().join(", ");
146
47
  };
@@ -199,159 +100,109 @@ var transformPseudos = (styles) => {
199
100
  // src/components/Box/Box.tsx
200
101
  var createThemedStyle = ({ as, __baseCSS, styles, css }) => (theme) => {
201
102
  const themedStyles = import_deepmerge.default.all([
202
- getNormalizedStyles(as),
203
103
  (0, import_css.css)(__baseCSS)(theme),
204
104
  (0, import_css.css)(styles)(theme),
205
105
  (0, import_css.css)(css)(theme)
206
106
  ]);
207
107
  return transformPseudos(themedStyles);
208
108
  };
209
- var Box = (0, import_react.forwardRef)((_a, ref) => {
210
- var _b = _a, {
211
- as = "div",
212
- children,
109
+ var Box = (0, import_react.forwardRef)(({
110
+ as = "div",
111
+ children,
112
+ __baseCSS,
113
+ css,
114
+ display,
115
+ height,
116
+ width,
117
+ minWidth,
118
+ maxWidth,
119
+ position,
120
+ top,
121
+ bottom,
122
+ right,
123
+ left,
124
+ zIndex,
125
+ p,
126
+ px,
127
+ py,
128
+ pt,
129
+ pb,
130
+ pl,
131
+ pr,
132
+ m,
133
+ mx,
134
+ my,
135
+ mt,
136
+ mb,
137
+ ml,
138
+ mr,
139
+ flexDirection,
140
+ flexWrap,
141
+ flexShrink,
142
+ flexGrow,
143
+ alignItems,
144
+ justifyContent,
145
+ bg,
146
+ border,
147
+ borderRadius,
148
+ boxShadow,
149
+ opacity,
150
+ overflow,
151
+ transition,
152
+ ...props
153
+ }, ref) => (0, import_react2.jsx)(as, {
154
+ ...props,
155
+ css: createThemedStyle({
156
+ as,
213
157
  __baseCSS,
214
158
  css,
215
- display,
216
- height,
217
- width,
218
- minWidth,
219
- maxWidth,
220
- position,
221
- top,
222
- bottom,
223
- right,
224
- left,
225
- zIndex,
226
- p,
227
- px,
228
- py,
229
- pt,
230
- pb,
231
- pl,
232
- pr,
233
- m,
234
- mx,
235
- my,
236
- mt,
237
- mb,
238
- ml,
239
- mr,
240
- flexDirection,
241
- flexWrap,
242
- flexShrink,
243
- flexGrow,
244
- alignItems,
245
- justifyContent,
246
- bg,
247
- border,
248
- borderRadius,
249
- boxShadow,
250
- opacity,
251
- overflow,
252
- transition
253
- } = _b, props = __objRest(_b, [
254
- "as",
255
- "children",
256
- "__baseCSS",
257
- "css",
258
- "display",
259
- "height",
260
- "width",
261
- "minWidth",
262
- "maxWidth",
263
- "position",
264
- "top",
265
- "bottom",
266
- "right",
267
- "left",
268
- "zIndex",
269
- "p",
270
- "px",
271
- "py",
272
- "pt",
273
- "pb",
274
- "pl",
275
- "pr",
276
- "m",
277
- "mx",
278
- "my",
279
- "mt",
280
- "mb",
281
- "ml",
282
- "mr",
283
- "flexDirection",
284
- "flexWrap",
285
- "flexShrink",
286
- "flexGrow",
287
- "alignItems",
288
- "justifyContent",
289
- "bg",
290
- "border",
291
- "borderRadius",
292
- "boxShadow",
293
- "opacity",
294
- "overflow",
295
- "transition"
296
- ]);
297
- return (0, import_react2.jsx)(as, __spreadProps(__spreadValues({}, props), {
298
- css: createThemedStyle({
299
- as,
300
- __baseCSS,
301
- css,
302
- styles: {
303
- display,
304
- height,
305
- width,
306
- minWidth,
307
- maxWidth,
308
- position,
309
- top,
310
- bottom,
311
- right,
312
- left,
313
- zIndex,
314
- p,
315
- px,
316
- py,
317
- pt,
318
- pb,
319
- pl,
320
- pr,
321
- m,
322
- mx,
323
- my,
324
- mt,
325
- mb,
326
- ml,
327
- mr,
328
- flexDirection,
329
- flexWrap,
330
- flexShrink,
331
- flexGrow,
332
- alignItems,
333
- justifyContent,
334
- bg,
335
- border,
336
- borderRadius,
337
- boxShadow,
338
- opacity,
339
- overflow,
340
- transition
341
- }
342
- }),
343
- ref
344
- }), children);
345
- });
159
+ styles: {
160
+ display,
161
+ height,
162
+ width,
163
+ minWidth,
164
+ maxWidth,
165
+ position,
166
+ top,
167
+ bottom,
168
+ right,
169
+ left,
170
+ zIndex,
171
+ p,
172
+ px,
173
+ py,
174
+ pt,
175
+ pb,
176
+ pl,
177
+ pr,
178
+ m,
179
+ mx,
180
+ my,
181
+ mt,
182
+ mb,
183
+ ml,
184
+ mr,
185
+ flexDirection,
186
+ flexWrap,
187
+ flexShrink,
188
+ flexGrow,
189
+ alignItems,
190
+ justifyContent,
191
+ bg,
192
+ border,
193
+ borderRadius,
194
+ boxShadow,
195
+ opacity,
196
+ overflow,
197
+ transition
198
+ }
199
+ }),
200
+ ref
201
+ }, children));
346
202
 
347
203
  // src/components/Global/Global.tsx
348
- var import_react8 = __toESM(require("react"));
349
- var import_react9 = require("@emotion/react");
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"));
204
+ var import_react5 = __toESM(require("react"));
205
+ var import_react6 = require("@emotion/react");
355
206
 
356
207
  // src/hooks/useTheme.tsx
357
208
  var import_react3 = __toESM(require("react"));
@@ -376,7 +227,98 @@ function ThemeProvider({
376
227
  }, children));
377
228
  }
378
229
 
230
+ // src/components/Global/normalize.ts
231
+ var document = {
232
+ "html, body": {
233
+ height: "100%"
234
+ },
235
+ html: {
236
+ textSizeAdjust: "none"
237
+ },
238
+ body: {
239
+ lineHeight: 1.5,
240
+ WebkitFontSmoothing: "antialiased",
241
+ margin: 0
242
+ },
243
+ "@media screen and (prefers-reduced-motion: reduce), (update: slow)": {
244
+ "*": {
245
+ animationDuration: "0.001ms !important",
246
+ animationIterationCount: "1 !important",
247
+ transitionDuration: "0.001ms !important"
248
+ }
249
+ }
250
+ };
251
+ var element = {
252
+ "*, *::before, *::after": {
253
+ boxSizing: "border-box"
254
+ },
255
+ "*": {
256
+ margin: 0
257
+ },
258
+ a: {
259
+ textDecoration: "none"
260
+ },
261
+ "p, h1, h2, h3, h4, h5, h6": {
262
+ overflowWrap: "break-word"
263
+ },
264
+ "img, picture, video, canvas, svg": {
265
+ display: "block",
266
+ maxWidth: "100%"
267
+ },
268
+ button: {
269
+ display: "block",
270
+ appearance: "none",
271
+ font: "inherit",
272
+ background: "transparent",
273
+ textAlign: "center"
274
+ },
275
+ input: {
276
+ display: "block",
277
+ appearance: "none",
278
+ font: "inherit",
279
+ "&::-ms-clear": {
280
+ display: "none"
281
+ },
282
+ "&::-webkit-search-cancel-button": {
283
+ WebkitAppearance: "none"
284
+ }
285
+ },
286
+ select: {
287
+ display: "block",
288
+ appearance: "none",
289
+ font: "inherit",
290
+ "&::-ms-expand": {
291
+ display: "none"
292
+ }
293
+ },
294
+ textarea: {
295
+ display: "block",
296
+ appearance: "none",
297
+ font: "inherit"
298
+ }
299
+ };
300
+
301
+ // src/components/Global/Global.tsx
302
+ var Global = ({ normalizeDocument = true, selector: selector2 }) => {
303
+ const { css, theme } = useTheme();
304
+ const rootStyles = css((theme == null ? void 0 : theme.root) || {});
305
+ const styles = [
306
+ normalizeDocument ? document : {},
307
+ selector2 ? { [`:where(${selector2})`]: element } : element,
308
+ selector2 ? { [`:where(${selector2})`]: rootStyles } : rootStyles
309
+ ];
310
+ return /* @__PURE__ */ import_react5.default.createElement(import_react6.Global, {
311
+ styles
312
+ });
313
+ };
314
+
315
+ // src/components/SVG/SVG.tsx
316
+ var import_react10 = require("@emotion/react");
317
+
379
318
  // src/hooks/useComponentStyles.ts
319
+ var import_deepmerge2 = __toESM(require("deepmerge"));
320
+ var import_react7 = require("react");
321
+ var import_react_fast_compare = __toESM(require("react-fast-compare"));
380
322
  var get = (obj, path, fallback) => {
381
323
  const key = path.split(".");
382
324
  let result = obj;
@@ -391,12 +333,12 @@ function useComponentStyles(componentName, props = {}, options = {}) {
391
333
  var _a, _b;
392
334
  const { theme } = useTheme();
393
335
  const componentStyles = get(theme, `components.${componentName}`);
394
- const stylesRef = (0, import_react5.useRef)({});
336
+ const stylesRef = (0, import_react7.useRef)({});
395
337
  if (componentStyles) {
396
- const base2 = componentStyles.base || {};
338
+ const base = componentStyles.base || {};
397
339
  const size = ((_a = componentStyles.size) == null ? void 0 : _a[props.size]) || {};
398
340
  const variant = ((_b = componentStyles.variant) == null ? void 0 : _b[props.variant]) || {};
399
- let styles = import_deepmerge2.default.all([base2, size, variant]);
341
+ let styles = import_deepmerge2.default.all([base, size, variant]);
400
342
  if (options.parts) {
401
343
  styles = options.parts.reduce((result, part) => {
402
344
  result[part] = styles[part] || {};
@@ -411,7 +353,7 @@ function useComponentStyles(componentName, props = {}, options = {}) {
411
353
  }
412
354
 
413
355
  // src/hooks/useResponsiveValue.ts
414
- var import_react6 = require("react");
356
+ var import_react8 = require("react");
415
357
  var emptyBreakpoints = ["40em", "52em", "64em"];
416
358
  var useResponsiveValue = (values, defaultIndex = 0) => {
417
359
  const { theme } = useTheme();
@@ -419,8 +361,8 @@ var useResponsiveValue = (values, defaultIndex = 0) => {
419
361
  if (defaultIndex < 0 || defaultIndex >= breakpoints.length) {
420
362
  throw new RangeError(`Default breakpoint index is out of bounds. Theme has ${breakpoints.length} breakpoints, default is ${defaultIndex}.`);
421
363
  }
422
- const [index, setIndex] = (0, import_react6.useState)(defaultIndex);
423
- (0, import_react6.useEffect)(() => {
364
+ const [index, setIndex] = (0, import_react8.useState)(defaultIndex);
365
+ (0, import_react8.useEffect)(() => {
424
366
  const getIndex = () => breakpoints.filter((breakpoint) => window.matchMedia(`screen and (min-width: ${breakpoint})`).matches).length;
425
367
  const handleResize = () => {
426
368
  const newIndex = getIndex();
@@ -436,12 +378,12 @@ var useResponsiveValue = (values, defaultIndex = 0) => {
436
378
  };
437
379
 
438
380
  // src/hooks/useStateProps.ts
439
- var import_react7 = require("react");
381
+ var import_react9 = require("react");
440
382
  var import_react_fast_compare2 = __toESM(require("react-fast-compare"));
441
383
  var KEBAB_REGEX = /[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;
442
384
  var toKebap = (val) => val.replace(KEBAB_REGEX, (match) => `-${match.toLocaleLowerCase()}`);
443
385
  var useStateProps = (states) => {
444
- const statePropsRef = (0, import_react7.useRef)({});
386
+ const statePropsRef = (0, import_react9.useRef)({});
445
387
  let stateProps = {};
446
388
  for (let state2 in states) {
447
389
  if (states[state2]) {
@@ -455,60 +397,25 @@ var useStateProps = (states) => {
455
397
  return statePropsRef.current;
456
398
  };
457
399
 
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
400
  // src/components/SVG/SVG.tsx
489
- var import_react10 = require("@emotion/react");
490
- var normalizedStyles = getNormalizedStyles("svg");
491
401
  var toDimension = (value) => Array.isArray(value) ? value.map(ensureNumberOrToken) : ensureNumberOrToken(value);
492
402
  var ensureNumberOrToken = (value) => typeof value === "string" && /[0-9]+/.test(value) ? Number(value) : value;
493
- var SVG = (_a) => {
494
- var _b = _a, {
495
- size = 24,
496
- fill = "currentcolor",
497
- children
498
- } = _b, props = __objRest(_b, [
499
- "size",
500
- "fill",
501
- "children"
502
- ]);
403
+ var SVG = ({
404
+ size = 24,
405
+ fill = "currentcolor",
406
+ children,
407
+ ...props
408
+ }) => {
503
409
  const { css } = useTheme();
504
- return (0, import_react10.jsx)("svg", __spreadValues({
410
+ return (0, import_react10.jsx)("svg", {
505
411
  viewBox: "0 0 24 24",
506
- css: css(__spreadProps(__spreadValues({}, normalizedStyles), {
412
+ css: css({
507
413
  fill,
508
414
  width: toDimension(props.width || size),
509
415
  height: toDimension(props.height || size)
510
- }))
511
- }, props), children);
416
+ }),
417
+ ...props
418
+ }, children);
512
419
  };
513
420
  // Annotate the CommonJS export names for ESM import in node:
514
421
  0 && (module.exports = {
@@ -517,8 +424,6 @@ var SVG = (_a) => {
517
424
  SVG,
518
425
  ThemeProvider,
519
426
  __defaultTheme,
520
- getNormalizedStyles,
521
- normalize,
522
427
  useComponentStyles,
523
428
  useResponsiveValue,
524
429
  useStateProps,
package/dist/index.mjs CHANGED
@@ -1,111 +1,10 @@
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 = (a2, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a2, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a2, prop, b[prop]);
16
- }
17
- return a2;
18
- };
19
- var __spreadProps = (a2, b) => __defProps(a2, __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
1
  // src/components/Box/Box.tsx
34
2
  import { forwardRef } from "react";
35
3
  import { jsx } from "@emotion/react";
36
4
  import { css as transformStyleObject } from "@theme-ui/css";
37
5
  import merge from "deepmerge";
38
6
 
39
- // src/normalize.ts
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
7
+ // src/components/Box/selector.ts
109
8
  var createteSelector = (selectors, states, suffix = "") => {
110
9
  return selectors.map((selector2) => states.map((state2) => `${selector2}${state2}${suffix ? ` ${suffix}` : ""}`)).flat().join(", ");
111
10
  };
@@ -164,160 +63,110 @@ var transformPseudos = (styles) => {
164
63
  // src/components/Box/Box.tsx
165
64
  var createThemedStyle = ({ as, __baseCSS, styles, css }) => (theme) => {
166
65
  const themedStyles = merge.all([
167
- getNormalizedStyles(as),
168
66
  transformStyleObject(__baseCSS)(theme),
169
67
  transformStyleObject(styles)(theme),
170
68
  transformStyleObject(css)(theme)
171
69
  ]);
172
70
  return transformPseudos(themedStyles);
173
71
  };
174
- var Box = forwardRef((_a, ref) => {
175
- var _b = _a, {
176
- as = "div",
177
- children,
72
+ var Box = forwardRef(({
73
+ as = "div",
74
+ children,
75
+ __baseCSS,
76
+ css,
77
+ display,
78
+ height,
79
+ width,
80
+ minWidth,
81
+ maxWidth,
82
+ position,
83
+ top,
84
+ bottom,
85
+ right,
86
+ left,
87
+ zIndex,
88
+ p,
89
+ px,
90
+ py,
91
+ pt,
92
+ pb,
93
+ pl,
94
+ pr,
95
+ m,
96
+ mx,
97
+ my,
98
+ mt,
99
+ mb,
100
+ ml,
101
+ mr,
102
+ flexDirection,
103
+ flexWrap,
104
+ flexShrink,
105
+ flexGrow,
106
+ alignItems,
107
+ justifyContent,
108
+ bg,
109
+ border,
110
+ borderRadius,
111
+ boxShadow,
112
+ opacity,
113
+ overflow,
114
+ transition,
115
+ ...props
116
+ }, ref) => jsx(as, {
117
+ ...props,
118
+ css: createThemedStyle({
119
+ as,
178
120
  __baseCSS,
179
121
  css,
180
- display,
181
- height,
182
- width,
183
- minWidth,
184
- maxWidth,
185
- position,
186
- top,
187
- bottom,
188
- right,
189
- left,
190
- zIndex,
191
- p,
192
- px,
193
- py,
194
- pt,
195
- pb,
196
- pl,
197
- pr,
198
- m,
199
- mx,
200
- my,
201
- mt,
202
- mb,
203
- ml,
204
- mr,
205
- flexDirection,
206
- flexWrap,
207
- flexShrink,
208
- flexGrow,
209
- alignItems,
210
- justifyContent,
211
- bg,
212
- border,
213
- borderRadius,
214
- boxShadow,
215
- opacity,
216
- overflow,
217
- transition
218
- } = _b, props = __objRest(_b, [
219
- "as",
220
- "children",
221
- "__baseCSS",
222
- "css",
223
- "display",
224
- "height",
225
- "width",
226
- "minWidth",
227
- "maxWidth",
228
- "position",
229
- "top",
230
- "bottom",
231
- "right",
232
- "left",
233
- "zIndex",
234
- "p",
235
- "px",
236
- "py",
237
- "pt",
238
- "pb",
239
- "pl",
240
- "pr",
241
- "m",
242
- "mx",
243
- "my",
244
- "mt",
245
- "mb",
246
- "ml",
247
- "mr",
248
- "flexDirection",
249
- "flexWrap",
250
- "flexShrink",
251
- "flexGrow",
252
- "alignItems",
253
- "justifyContent",
254
- "bg",
255
- "border",
256
- "borderRadius",
257
- "boxShadow",
258
- "opacity",
259
- "overflow",
260
- "transition"
261
- ]);
262
- return jsx(as, __spreadProps(__spreadValues({}, props), {
263
- css: createThemedStyle({
264
- as,
265
- __baseCSS,
266
- css,
267
- styles: {
268
- display,
269
- height,
270
- width,
271
- minWidth,
272
- maxWidth,
273
- position,
274
- top,
275
- bottom,
276
- right,
277
- left,
278
- zIndex,
279
- p,
280
- px,
281
- py,
282
- pt,
283
- pb,
284
- pl,
285
- pr,
286
- m,
287
- mx,
288
- my,
289
- mt,
290
- mb,
291
- ml,
292
- mr,
293
- flexDirection,
294
- flexWrap,
295
- flexShrink,
296
- flexGrow,
297
- alignItems,
298
- justifyContent,
299
- bg,
300
- border,
301
- borderRadius,
302
- boxShadow,
303
- opacity,
304
- overflow,
305
- transition
306
- }
307
- }),
308
- ref
309
- }), children);
310
- });
122
+ styles: {
123
+ display,
124
+ height,
125
+ width,
126
+ minWidth,
127
+ maxWidth,
128
+ position,
129
+ top,
130
+ bottom,
131
+ right,
132
+ left,
133
+ zIndex,
134
+ p,
135
+ px,
136
+ py,
137
+ pt,
138
+ pb,
139
+ pl,
140
+ pr,
141
+ m,
142
+ mx,
143
+ my,
144
+ mt,
145
+ mb,
146
+ ml,
147
+ mr,
148
+ flexDirection,
149
+ flexWrap,
150
+ flexShrink,
151
+ flexGrow,
152
+ alignItems,
153
+ justifyContent,
154
+ bg,
155
+ border,
156
+ borderRadius,
157
+ boxShadow,
158
+ opacity,
159
+ overflow,
160
+ transition
161
+ }
162
+ }),
163
+ ref
164
+ }, children));
311
165
 
312
166
  // src/components/Global/Global.tsx
313
167
  import React2 from "react";
314
168
  import { Global as EmotionGlobal } from "@emotion/react";
315
169
 
316
- // src/hooks/useComponentStyles.ts
317
- import merge2 from "deepmerge";
318
- import { useRef } from "react";
319
- import isEqual from "react-fast-compare";
320
-
321
170
  // src/hooks/useTheme.tsx
322
171
  import React, {
323
172
  createContext,
@@ -348,7 +197,98 @@ function ThemeProvider({
348
197
  }, children));
349
198
  }
350
199
 
200
+ // src/components/Global/normalize.ts
201
+ var document = {
202
+ "html, body": {
203
+ height: "100%"
204
+ },
205
+ html: {
206
+ textSizeAdjust: "none"
207
+ },
208
+ body: {
209
+ lineHeight: 1.5,
210
+ WebkitFontSmoothing: "antialiased",
211
+ margin: 0
212
+ },
213
+ "@media screen and (prefers-reduced-motion: reduce), (update: slow)": {
214
+ "*": {
215
+ animationDuration: "0.001ms !important",
216
+ animationIterationCount: "1 !important",
217
+ transitionDuration: "0.001ms !important"
218
+ }
219
+ }
220
+ };
221
+ var element = {
222
+ "*, *::before, *::after": {
223
+ boxSizing: "border-box"
224
+ },
225
+ "*": {
226
+ margin: 0
227
+ },
228
+ a: {
229
+ textDecoration: "none"
230
+ },
231
+ "p, h1, h2, h3, h4, h5, h6": {
232
+ overflowWrap: "break-word"
233
+ },
234
+ "img, picture, video, canvas, svg": {
235
+ display: "block",
236
+ maxWidth: "100%"
237
+ },
238
+ button: {
239
+ display: "block",
240
+ appearance: "none",
241
+ font: "inherit",
242
+ background: "transparent",
243
+ textAlign: "center"
244
+ },
245
+ input: {
246
+ display: "block",
247
+ appearance: "none",
248
+ font: "inherit",
249
+ "&::-ms-clear": {
250
+ display: "none"
251
+ },
252
+ "&::-webkit-search-cancel-button": {
253
+ WebkitAppearance: "none"
254
+ }
255
+ },
256
+ select: {
257
+ display: "block",
258
+ appearance: "none",
259
+ font: "inherit",
260
+ "&::-ms-expand": {
261
+ display: "none"
262
+ }
263
+ },
264
+ textarea: {
265
+ display: "block",
266
+ appearance: "none",
267
+ font: "inherit"
268
+ }
269
+ };
270
+
271
+ // src/components/Global/Global.tsx
272
+ var Global = ({ normalizeDocument = true, selector: selector2 }) => {
273
+ const { css, theme } = useTheme();
274
+ const rootStyles = css((theme == null ? void 0 : theme.root) || {});
275
+ const styles = [
276
+ normalizeDocument ? document : {},
277
+ selector2 ? { [`:where(${selector2})`]: element } : element,
278
+ selector2 ? { [`:where(${selector2})`]: rootStyles } : rootStyles
279
+ ];
280
+ return /* @__PURE__ */ React2.createElement(EmotionGlobal, {
281
+ styles
282
+ });
283
+ };
284
+
285
+ // src/components/SVG/SVG.tsx
286
+ import { jsx as jsx2 } from "@emotion/react";
287
+
351
288
  // src/hooks/useComponentStyles.ts
289
+ import merge2 from "deepmerge";
290
+ import { useRef } from "react";
291
+ import isEqual from "react-fast-compare";
352
292
  var get = (obj, path, fallback) => {
353
293
  const key = path.split(".");
354
294
  let result = obj;
@@ -365,10 +305,10 @@ function useComponentStyles(componentName, props = {}, options = {}) {
365
305
  const componentStyles = get(theme, `components.${componentName}`);
366
306
  const stylesRef = useRef({});
367
307
  if (componentStyles) {
368
- const base2 = componentStyles.base || {};
308
+ const base = componentStyles.base || {};
369
309
  const size = ((_a = componentStyles.size) == null ? void 0 : _a[props.size]) || {};
370
310
  const variant = ((_b = componentStyles.variant) == null ? void 0 : _b[props.variant]) || {};
371
- let styles = merge2.all([base2, size, variant]);
311
+ let styles = merge2.all([base, size, variant]);
372
312
  if (options.parts) {
373
313
  styles = options.parts.reduce((result, part) => {
374
314
  result[part] = styles[part] || {};
@@ -427,60 +367,25 @@ var useStateProps = (states) => {
427
367
  return statePropsRef.current;
428
368
  };
429
369
 
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
370
  // src/components/SVG/SVG.tsx
461
- import { jsx as jsx2 } from "@emotion/react";
462
- var normalizedStyles = getNormalizedStyles("svg");
463
371
  var toDimension = (value) => Array.isArray(value) ? value.map(ensureNumberOrToken) : ensureNumberOrToken(value);
464
372
  var ensureNumberOrToken = (value) => typeof value === "string" && /[0-9]+/.test(value) ? Number(value) : value;
465
- var SVG = (_a) => {
466
- var _b = _a, {
467
- size = 24,
468
- fill = "currentcolor",
469
- children
470
- } = _b, props = __objRest(_b, [
471
- "size",
472
- "fill",
473
- "children"
474
- ]);
373
+ var SVG = ({
374
+ size = 24,
375
+ fill = "currentcolor",
376
+ children,
377
+ ...props
378
+ }) => {
475
379
  const { css } = useTheme();
476
- return jsx2("svg", __spreadValues({
380
+ return jsx2("svg", {
477
381
  viewBox: "0 0 24 24",
478
- css: css(__spreadProps(__spreadValues({}, normalizedStyles), {
382
+ css: css({
479
383
  fill,
480
384
  width: toDimension(props.width || size),
481
385
  height: toDimension(props.height || size)
482
- }))
483
- }, props), children);
386
+ }),
387
+ ...props
388
+ }, children);
484
389
  };
485
390
  export {
486
391
  Box,
@@ -488,8 +393,6 @@ export {
488
393
  SVG,
489
394
  ThemeProvider,
490
395
  __defaultTheme,
491
- getNormalizedStyles,
492
- normalize,
493
396
  useComponentStyles,
494
397
  useResponsiveValue,
495
398
  useStateProps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marigold/system",
3
- "version": "1.1.1",
3
+ "version": "1.2.2",
4
4
  "description": "Marigold System Library",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -26,22 +26,22 @@
26
26
  "directory": "packages/system"
27
27
  },
28
28
  "dependencies": {
29
- "@emotion/react": "11.9.0",
30
- "@marigold/types": "0.5.1",
31
- "@theme-ui/css": "0.14.5",
29
+ "@emotion/react": "11.9.3",
30
+ "@marigold/types": "0.5.2",
31
+ "@theme-ui/css": "0.14.6",
32
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": "^16.x || ^17.0.0",
38
- "react-dom": "^16.x || ^17.0.0"
37
+ "react": "16.x || 17.x || 18.x",
38
+ "react-dom": "16.x || 17.x || 18.x"
39
39
  },
40
40
  "devDependencies": {
41
- "@babel/core": "7.17.12",
41
+ "@babel/core": "7.18.6",
42
42
  "@marigold/tsconfig": "0.3.0",
43
- "react": "17.0.2",
44
- "tsup": "6.0.1"
43
+ "react": "18.2.0",
44
+ "tsup": "6.1.3"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsup src/index.ts",