@marigold/system 1.2.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -119,7 +119,9 @@ interface Theme {
119
119
  * for full page apps or an element if you're only using Marigold on a portion of the page.
120
120
  * This is useful for additional normalizationor and to style non-Marigold elements.
121
121
  */
122
- root?: CSSObject;
122
+ root?: {
123
+ [key: string]: CSSObject;
124
+ };
123
125
  /**
124
126
  * To configure the default breakpoints used in responsive array values,
125
127
  * add a breakpoints array to your theme.
@@ -231,8 +233,9 @@ declare const Global: ({ normalizeDocument, selector }: GlobalProps) => JSX.Elem
231
233
 
232
234
  interface SVGProps extends ComponentProps<'svg'> {
233
235
  size?: number | string | number[] | string[];
236
+ css?: CSSObject;
234
237
  }
235
- declare const SVG: ({ size, fill, children, ...props }: SVGProps) => react.ReactSVGElement;
238
+ declare const SVG: react.ForwardRefExoticComponent<SVGProps & react.RefAttributes<SVGElement>>;
236
239
 
237
240
  interface ComponentStylesProps {
238
241
  variant?: string;
package/dist/index.js CHANGED
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  }
18
18
  return to;
19
19
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
21
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
25
 
23
26
  // src/index.ts
@@ -43,7 +46,9 @@ var import_deepmerge = __toESM(require("deepmerge"));
43
46
 
44
47
  // src/components/Box/selector.ts
45
48
  var createteSelector = (selectors, states, suffix = "") => {
46
- return selectors.map((selector2) => states.map((state2) => `${selector2}${state2}${suffix ? ` ${suffix}` : ""}`)).flat().join(", ");
49
+ return selectors.map(
50
+ (selector2) => states.map((state2) => `${selector2}${state2}${suffix ? ` ${suffix}` : ""}`)
51
+ ).flat().join(", ");
47
52
  };
48
53
  var selector = {
49
54
  self: "&",
@@ -76,10 +81,26 @@ var pseudos = {
76
81
  "&:error": createteSelector([selector.self], state.error),
77
82
  "&:expanded": createteSelector([selector.self], state.expanded),
78
83
  "&:in-group": createteSelector(selector.grouped, state.none, selector.self),
79
- "&:hover-group": createteSelector(selector.grouped, state.hover, selector.self),
80
- "&:focus-group": createteSelector(selector.grouped, state.focus, selector.self),
81
- "&:active-group": createteSelector(selector.grouped, state.active, selector.self),
82
- "&:error-group": createteSelector(selector.grouped, state.error, selector.self)
84
+ "&:hover-group": createteSelector(
85
+ selector.grouped,
86
+ state.hover,
87
+ selector.self
88
+ ),
89
+ "&:focus-group": createteSelector(
90
+ selector.grouped,
91
+ state.focus,
92
+ selector.self
93
+ ),
94
+ "&:active-group": createteSelector(
95
+ selector.grouped,
96
+ state.active,
97
+ selector.self
98
+ ),
99
+ "&:error-group": createteSelector(
100
+ selector.grouped,
101
+ state.error,
102
+ selector.self
103
+ )
83
104
  };
84
105
  var transformPseudos = (styles) => {
85
106
  let result = {};
@@ -106,99 +127,105 @@ var createThemedStyle = ({ as, __baseCSS, styles, css }) => (theme) => {
106
127
  ]);
107
128
  return transformPseudos(themedStyles);
108
129
  };
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,
130
+ var Box = (0, import_react.forwardRef)(
131
+ ({
132
+ as = "div",
133
+ children,
157
134
  __baseCSS,
158
135
  css,
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));
136
+ display,
137
+ height,
138
+ width,
139
+ minWidth,
140
+ maxWidth,
141
+ position,
142
+ top,
143
+ bottom,
144
+ right,
145
+ left,
146
+ zIndex,
147
+ p,
148
+ px,
149
+ py,
150
+ pt,
151
+ pb,
152
+ pl,
153
+ pr,
154
+ m,
155
+ mx,
156
+ my,
157
+ mt,
158
+ mb,
159
+ ml,
160
+ mr,
161
+ flexDirection,
162
+ flexWrap,
163
+ flexShrink,
164
+ flexGrow,
165
+ alignItems,
166
+ justifyContent,
167
+ bg,
168
+ border,
169
+ borderRadius,
170
+ boxShadow,
171
+ opacity,
172
+ overflow,
173
+ transition,
174
+ ...props
175
+ }, ref) => (0, import_react2.jsx)(
176
+ as,
177
+ {
178
+ ...props,
179
+ css: createThemedStyle({
180
+ as,
181
+ __baseCSS,
182
+ css,
183
+ styles: {
184
+ display,
185
+ height,
186
+ width,
187
+ minWidth,
188
+ maxWidth,
189
+ position,
190
+ top,
191
+ bottom,
192
+ right,
193
+ left,
194
+ zIndex,
195
+ p,
196
+ px,
197
+ py,
198
+ pt,
199
+ pb,
200
+ pl,
201
+ pr,
202
+ m,
203
+ mx,
204
+ my,
205
+ mt,
206
+ mb,
207
+ ml,
208
+ mr,
209
+ flexDirection,
210
+ flexWrap,
211
+ flexShrink,
212
+ flexGrow,
213
+ alignItems,
214
+ justifyContent,
215
+ bg,
216
+ border,
217
+ borderRadius,
218
+ boxShadow,
219
+ opacity,
220
+ overflow,
221
+ transition
222
+ }
223
+ }),
224
+ ref
225
+ },
226
+ children
227
+ )
228
+ );
202
229
 
203
230
  // src/components/Global/Global.tsx
204
231
  var import_react5 = __toESM(require("react"));
@@ -212,7 +239,10 @@ var __defaultTheme = {};
212
239
  var InternalContext = (0, import_react3.createContext)(__defaultTheme);
213
240
  var useTheme = () => {
214
241
  const theme = (0, import_react3.useContext)(InternalContext);
215
- const css = (0, import_react3.useCallback)((style) => (0, import_css2.css)(style)(theme), [theme]);
242
+ const css = (0, import_react3.useCallback)(
243
+ (style) => (0, import_css2.css)(style)(theme),
244
+ [theme]
245
+ );
216
246
  const get2 = (0, import_react3.useCallback)((path) => (0, import_css2.get)(theme, path), [theme]);
217
247
  return { theme, css, get: get2 };
218
248
  };
@@ -313,7 +343,8 @@ var Global = ({ normalizeDocument = true, selector: selector2 }) => {
313
343
  };
314
344
 
315
345
  // src/components/SVG/SVG.tsx
316
- var import_react10 = require("@emotion/react");
346
+ var import_react10 = require("react");
347
+ var import_react11 = require("@emotion/react");
317
348
 
318
349
  // src/hooks/useComponentStyles.ts
319
350
  var import_deepmerge2 = __toESM(require("deepmerge"));
@@ -359,11 +390,15 @@ var useResponsiveValue = (values, defaultIndex = 0) => {
359
390
  const { theme } = useTheme();
360
391
  const breakpoints = theme.breakpoints || emptyBreakpoints;
361
392
  if (defaultIndex < 0 || defaultIndex >= breakpoints.length) {
362
- throw new RangeError(`Default breakpoint index is out of bounds. Theme has ${breakpoints.length} breakpoints, default is ${defaultIndex}.`);
393
+ throw new RangeError(
394
+ `Default breakpoint index is out of bounds. Theme has ${breakpoints.length} breakpoints, default is ${defaultIndex}.`
395
+ );
363
396
  }
364
397
  const [index, setIndex] = (0, import_react8.useState)(defaultIndex);
365
398
  (0, import_react8.useEffect)(() => {
366
- const getIndex = () => breakpoints.filter((breakpoint) => window.matchMedia(`screen and (min-width: ${breakpoint})`).matches).length;
399
+ const getIndex = () => breakpoints.filter(
400
+ (breakpoint) => window.matchMedia(`screen and (min-width: ${breakpoint})`).matches
401
+ ).length;
367
402
  const handleResize = () => {
368
403
  const newIndex = getIndex();
369
404
  if (index !== newIndex) {
@@ -400,23 +435,25 @@ var useStateProps = (states) => {
400
435
  // src/components/SVG/SVG.tsx
401
436
  var toDimension = (value) => Array.isArray(value) ? value.map(ensureNumberOrToken) : ensureNumberOrToken(value);
402
437
  var ensureNumberOrToken = (value) => typeof value === "string" && /[0-9]+/.test(value) ? Number(value) : value;
403
- var SVG = ({
404
- size = 24,
405
- fill = "currentcolor",
406
- children,
407
- ...props
408
- }) => {
409
- const { css } = useTheme();
410
- return (0, import_react10.jsx)("svg", {
411
- viewBox: "0 0 24 24",
412
- css: css({
413
- fill,
414
- width: toDimension(props.width || size),
415
- height: toDimension(props.height || size)
416
- }),
417
- ...props
418
- }, children);
419
- };
438
+ var SVG = (0, import_react10.forwardRef)(
439
+ ({ size = 24, fill = "currentcolor", children, css: styles, ...props }, ref) => {
440
+ const { css } = useTheme();
441
+ return (0, import_react11.jsx)(
442
+ "svg",
443
+ {
444
+ ...props,
445
+ css: css({
446
+ ...styles,
447
+ fill,
448
+ width: toDimension(props.width || size),
449
+ height: toDimension(props.height || size)
450
+ }),
451
+ ref
452
+ },
453
+ children
454
+ );
455
+ }
456
+ );
420
457
  // Annotate the CommonJS export names for ESM import in node:
421
458
  0 && (module.exports = {
422
459
  Box,
package/dist/index.mjs CHANGED
@@ -6,7 +6,9 @@ import merge from "deepmerge";
6
6
 
7
7
  // src/components/Box/selector.ts
8
8
  var createteSelector = (selectors, states, suffix = "") => {
9
- return selectors.map((selector2) => states.map((state2) => `${selector2}${state2}${suffix ? ` ${suffix}` : ""}`)).flat().join(", ");
9
+ return selectors.map(
10
+ (selector2) => states.map((state2) => `${selector2}${state2}${suffix ? ` ${suffix}` : ""}`)
11
+ ).flat().join(", ");
10
12
  };
11
13
  var selector = {
12
14
  self: "&",
@@ -39,10 +41,26 @@ var pseudos = {
39
41
  "&:error": createteSelector([selector.self], state.error),
40
42
  "&:expanded": createteSelector([selector.self], state.expanded),
41
43
  "&:in-group": createteSelector(selector.grouped, state.none, selector.self),
42
- "&:hover-group": createteSelector(selector.grouped, state.hover, selector.self),
43
- "&:focus-group": createteSelector(selector.grouped, state.focus, selector.self),
44
- "&:active-group": createteSelector(selector.grouped, state.active, selector.self),
45
- "&:error-group": createteSelector(selector.grouped, state.error, selector.self)
44
+ "&:hover-group": createteSelector(
45
+ selector.grouped,
46
+ state.hover,
47
+ selector.self
48
+ ),
49
+ "&:focus-group": createteSelector(
50
+ selector.grouped,
51
+ state.focus,
52
+ selector.self
53
+ ),
54
+ "&:active-group": createteSelector(
55
+ selector.grouped,
56
+ state.active,
57
+ selector.self
58
+ ),
59
+ "&:error-group": createteSelector(
60
+ selector.grouped,
61
+ state.error,
62
+ selector.self
63
+ )
46
64
  };
47
65
  var transformPseudos = (styles) => {
48
66
  let result = {};
@@ -69,99 +87,105 @@ var createThemedStyle = ({ as, __baseCSS, styles, css }) => (theme) => {
69
87
  ]);
70
88
  return transformPseudos(themedStyles);
71
89
  };
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,
90
+ var Box = forwardRef(
91
+ ({
92
+ as = "div",
93
+ children,
120
94
  __baseCSS,
121
95
  css,
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));
96
+ display,
97
+ height,
98
+ width,
99
+ minWidth,
100
+ maxWidth,
101
+ position,
102
+ top,
103
+ bottom,
104
+ right,
105
+ left,
106
+ zIndex,
107
+ p,
108
+ px,
109
+ py,
110
+ pt,
111
+ pb,
112
+ pl,
113
+ pr,
114
+ m,
115
+ mx,
116
+ my,
117
+ mt,
118
+ mb,
119
+ ml,
120
+ mr,
121
+ flexDirection,
122
+ flexWrap,
123
+ flexShrink,
124
+ flexGrow,
125
+ alignItems,
126
+ justifyContent,
127
+ bg,
128
+ border,
129
+ borderRadius,
130
+ boxShadow,
131
+ opacity,
132
+ overflow,
133
+ transition,
134
+ ...props
135
+ }, ref) => jsx(
136
+ as,
137
+ {
138
+ ...props,
139
+ css: createThemedStyle({
140
+ as,
141
+ __baseCSS,
142
+ css,
143
+ styles: {
144
+ display,
145
+ height,
146
+ width,
147
+ minWidth,
148
+ maxWidth,
149
+ position,
150
+ top,
151
+ bottom,
152
+ right,
153
+ left,
154
+ zIndex,
155
+ p,
156
+ px,
157
+ py,
158
+ pt,
159
+ pb,
160
+ pl,
161
+ pr,
162
+ m,
163
+ mx,
164
+ my,
165
+ mt,
166
+ mb,
167
+ ml,
168
+ mr,
169
+ flexDirection,
170
+ flexWrap,
171
+ flexShrink,
172
+ flexGrow,
173
+ alignItems,
174
+ justifyContent,
175
+ bg,
176
+ border,
177
+ borderRadius,
178
+ boxShadow,
179
+ opacity,
180
+ overflow,
181
+ transition
182
+ }
183
+ }),
184
+ ref
185
+ },
186
+ children
187
+ )
188
+ );
165
189
 
166
190
  // src/components/Global/Global.tsx
167
191
  import React2 from "react";
@@ -182,7 +206,10 @@ var __defaultTheme = {};
182
206
  var InternalContext = createContext(__defaultTheme);
183
207
  var useTheme = () => {
184
208
  const theme = useContext(InternalContext);
185
- const css = useCallback((style) => transformStyleObject2(style)(theme), [theme]);
209
+ const css = useCallback(
210
+ (style) => transformStyleObject2(style)(theme),
211
+ [theme]
212
+ );
186
213
  const get2 = useCallback((path) => getfromTheme(theme, path), [theme]);
187
214
  return { theme, css, get: get2 };
188
215
  };
@@ -283,6 +310,7 @@ var Global = ({ normalizeDocument = true, selector: selector2 }) => {
283
310
  };
284
311
 
285
312
  // src/components/SVG/SVG.tsx
313
+ import { forwardRef as forwardRef2 } from "react";
286
314
  import { jsx as jsx2 } from "@emotion/react";
287
315
 
288
316
  // src/hooks/useComponentStyles.ts
@@ -329,11 +357,15 @@ var useResponsiveValue = (values, defaultIndex = 0) => {
329
357
  const { theme } = useTheme();
330
358
  const breakpoints = theme.breakpoints || emptyBreakpoints;
331
359
  if (defaultIndex < 0 || defaultIndex >= breakpoints.length) {
332
- throw new RangeError(`Default breakpoint index is out of bounds. Theme has ${breakpoints.length} breakpoints, default is ${defaultIndex}.`);
360
+ throw new RangeError(
361
+ `Default breakpoint index is out of bounds. Theme has ${breakpoints.length} breakpoints, default is ${defaultIndex}.`
362
+ );
333
363
  }
334
364
  const [index, setIndex] = useState(defaultIndex);
335
365
  useEffect(() => {
336
- const getIndex = () => breakpoints.filter((breakpoint) => window.matchMedia(`screen and (min-width: ${breakpoint})`).matches).length;
366
+ const getIndex = () => breakpoints.filter(
367
+ (breakpoint) => window.matchMedia(`screen and (min-width: ${breakpoint})`).matches
368
+ ).length;
337
369
  const handleResize = () => {
338
370
  const newIndex = getIndex();
339
371
  if (index !== newIndex) {
@@ -370,23 +402,25 @@ var useStateProps = (states) => {
370
402
  // src/components/SVG/SVG.tsx
371
403
  var toDimension = (value) => Array.isArray(value) ? value.map(ensureNumberOrToken) : ensureNumberOrToken(value);
372
404
  var ensureNumberOrToken = (value) => typeof value === "string" && /[0-9]+/.test(value) ? Number(value) : value;
373
- var SVG = ({
374
- size = 24,
375
- fill = "currentcolor",
376
- children,
377
- ...props
378
- }) => {
379
- const { css } = useTheme();
380
- return jsx2("svg", {
381
- viewBox: "0 0 24 24",
382
- css: css({
383
- fill,
384
- width: toDimension(props.width || size),
385
- height: toDimension(props.height || size)
386
- }),
387
- ...props
388
- }, children);
389
- };
405
+ var SVG = forwardRef2(
406
+ ({ size = 24, fill = "currentcolor", children, css: styles, ...props }, ref) => {
407
+ const { css } = useTheme();
408
+ return jsx2(
409
+ "svg",
410
+ {
411
+ ...props,
412
+ css: css({
413
+ ...styles,
414
+ fill,
415
+ width: toDimension(props.width || size),
416
+ height: toDimension(props.height || size)
417
+ }),
418
+ ref
419
+ },
420
+ children
421
+ );
422
+ }
423
+ );
390
424
  export {
391
425
  Box,
392
426
  Global,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marigold/system",
3
- "version": "1.2.2",
3
+ "version": "2.1.0",
4
4
  "description": "Marigold System Library",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -26,9 +26,9 @@
26
26
  "directory": "packages/system"
27
27
  },
28
28
  "dependencies": {
29
- "@emotion/react": "11.9.3",
29
+ "@emotion/react": "11.10.0",
30
30
  "@marigold/types": "0.5.2",
31
- "@theme-ui/css": "0.14.6",
31
+ "@theme-ui/css": "0.14.7",
32
32
  "csstype": "3.1.0",
33
33
  "deepmerge": "^4.2.2",
34
34
  "react-fast-compare": "^3.2.0"
@@ -38,15 +38,14 @@
38
38
  "react-dom": "16.x || 17.x || 18.x"
39
39
  },
40
40
  "devDependencies": {
41
- "@babel/core": "7.18.6",
41
+ "@babel/core": "7.18.10",
42
42
  "@marigold/tsconfig": "0.3.0",
43
43
  "react": "18.2.0",
44
- "tsup": "6.1.3"
44
+ "tsup": "6.2.2"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsup src/index.ts",
48
48
  "watch": "tsup src/index.ts --watch",
49
49
  "clean": "rm -rf node_modules && rm -rf dist"
50
- },
51
- "readme": "# `@marigold/system`\n\n> Marigold system\n"
50
+ }
52
51
  }