@marigold/system 4.2.2 → 5.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
@@ -1,4 +1,4 @@
1
- import { Simplify, PolymorphicPropsWithRef, PolymorphicComponentWithRef, ComponentProps, KebabCase } from '@marigold/types';
1
+ import { Simplify, PropsOf, PolymorphicComponent, HtmlProps, KebabCase } from '@marigold/types';
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';
@@ -205,9 +205,7 @@ interface Theme {
205
205
  transitions?: Scale<CSS.Property.Transition>;
206
206
  }
207
207
 
208
- interface StyleProps extends Pick<CSSObject, 'display' | 'height' | 'width' | 'minWidth' | 'maxWidth' | 'position' | 'top' | 'bottom' | 'right' | 'left' | 'zIndex' | 'p' | 'px' | 'py' | 'pt' | 'pb' | 'pl' | 'pr' | 'm' | 'mx' | 'my' | 'mt' | 'mb' | 'ml' | 'mr' | 'flexDirection' | 'flexWrap' | 'flexShrink' | 'flexGrow' | 'alignItems' | 'justifyContent' | 'bg' | 'border' | 'borderRadius' | 'boxShadow' | 'opacity' | 'overflow' | 'transition'> {
209
- }
210
- interface BoxOwnProps extends StyleProps {
208
+ interface BoxOwnProps {
211
209
  css?: CSSObject | CSSObject[];
212
210
  /**
213
211
  * Use to set base styles for the component
@@ -215,9 +213,9 @@ interface BoxOwnProps extends StyleProps {
215
213
  */
216
214
  __baseCSS?: CSSObject;
217
215
  }
218
- interface BoxProps extends PolymorphicPropsWithRef<BoxOwnProps, 'div'> {
216
+ interface BoxProps extends PropsOf<typeof Box> {
219
217
  }
220
- declare const Box: PolymorphicComponentWithRef<BoxOwnProps, 'div'>;
218
+ declare const Box: PolymorphicComponent<"div", BoxOwnProps>;
221
219
 
222
220
  type GlobalProps = {
223
221
  /**
@@ -231,7 +229,7 @@ type GlobalProps = {
231
229
  };
232
230
  declare const Global: ({ normalizeDocument, selector }: GlobalProps) => JSX.Element;
233
231
 
234
- interface SVGProps extends ComponentProps<'svg'> {
232
+ interface SVGProps extends HtmlProps<'svg'> {
235
233
  size?: number | string | number[] | string[];
236
234
  css?: CSSObject;
237
235
  }
@@ -290,4 +288,4 @@ interface ThemeProviderProps<T extends Theme> {
290
288
  }
291
289
  declare function ThemeProvider<T extends Theme>({ theme, children, }: ThemeProviderProps<T>): JSX.Element;
292
290
 
293
- 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 };
291
+ export { Box, BoxOwnProps, BoxProps, CSSObject, CSSProperties, ComponentState, ComponentStyleParts, ComponentStylesProps, Global, GlobalProps, ResponsiveStyleValue, SVG, SVGProps, Scale, ScaleValue, SizeScale, StateAttrKeyProps, StateAttrProps, StyleObject, Theme, ThemeComponentProps, ThemeExtension, ThemeExtensionsWithParts, ThemeProvider, ThemeProviderProps, UseStateProps, ZeroScale, ZeroSizeScale, __defaultTheme, useComponentStyles, useResponsiveValue, useStateProps, useTheme };
package/dist/index.js CHANGED
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  return to;
19
19
  };
20
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
@@ -82,6 +86,7 @@ var pseudos = {
82
86
  "&:error": createteSelector([selector.self], state.error),
83
87
  "&:expanded": createteSelector([selector.self], state.expanded),
84
88
  "&:required": createteSelector([selector.self], state.required),
89
+ // Selector for elements that are part of a group
85
90
  "&:in-group": createteSelector(selector.grouped, state.none, selector.self),
86
91
  "&:hover-group": createteSelector(
87
92
  selector.grouped,
@@ -121,106 +126,21 @@ var transformPseudos = (styles) => {
121
126
  };
122
127
 
123
128
  // src/components/Box/Box.tsx
124
- var createThemedStyle = ({ __baseCSS, styles, css }) => (theme) => {
129
+ var createThemedStyle = ({ __baseCSS, css }) => (theme) => {
125
130
  const themedStyles = import_deepmerge.default.all([
126
131
  (0, import_css.css)(__baseCSS)(theme),
127
- (0, import_css.css)(styles)(theme),
128
132
  ...Array.isArray(css) ? css.map((c) => (0, import_css.css)(c)(theme)) : [(0, import_css.css)(css)(theme)]
129
133
  ]);
130
134
  return transformPseudos(themedStyles);
131
135
  };
132
136
  var Box = (0, import_react.forwardRef)(
133
- ({
134
- as = "div",
135
- children,
136
- __baseCSS,
137
- css,
138
- display,
139
- height,
140
- width,
141
- minWidth,
142
- maxWidth,
143
- position,
144
- top,
145
- bottom,
146
- right,
147
- left,
148
- zIndex,
149
- p,
150
- px,
151
- py,
152
- pt,
153
- pb,
154
- pl,
155
- pr,
156
- m,
157
- mx,
158
- my,
159
- mt,
160
- mb,
161
- ml,
162
- mr,
163
- flexDirection,
164
- flexWrap,
165
- flexShrink,
166
- flexGrow,
167
- alignItems,
168
- justifyContent,
169
- bg,
170
- border,
171
- borderRadius,
172
- boxShadow,
173
- opacity,
174
- overflow,
175
- transition,
176
- ...props
177
- }, ref) => (0, import_react2.jsx)(
137
+ ({ as = "div", children, __baseCSS, css, ...props }, ref) => (0, import_react2.jsx)(
178
138
  as,
179
139
  {
180
140
  ...props,
181
141
  css: createThemedStyle({
182
142
  __baseCSS,
183
- css,
184
- styles: {
185
- display,
186
- height,
187
- width,
188
- minWidth,
189
- maxWidth,
190
- position,
191
- top,
192
- bottom,
193
- right,
194
- left,
195
- zIndex,
196
- p,
197
- px,
198
- py,
199
- pt,
200
- pb,
201
- pl,
202
- pr,
203
- m,
204
- mx,
205
- my,
206
- mt,
207
- mb,
208
- ml,
209
- mr,
210
- flexDirection,
211
- flexWrap,
212
- flexShrink,
213
- flexGrow,
214
- alignItems,
215
- justifyContent,
216
- bg,
217
- border,
218
- borderRadius,
219
- boxShadow,
220
- opacity,
221
- overflow,
222
- transition
223
- }
143
+ css
224
144
  }),
225
145
  ref
226
146
  },
@@ -251,11 +171,7 @@ function ThemeProvider({
251
171
  theme,
252
172
  children
253
173
  }) {
254
- return /* @__PURE__ */ import_react3.default.createElement(import_react4.ThemeProvider, {
255
- theme
256
- }, /* @__PURE__ */ import_react3.default.createElement(InternalContext.Provider, {
257
- value: theme
258
- }, children));
174
+ return /* @__PURE__ */ import_react3.default.createElement(import_react4.ThemeProvider, { theme }, /* @__PURE__ */ import_react3.default.createElement(InternalContext.Provider, { value: theme }, children));
259
175
  }
260
176
 
261
177
  // src/components/Global/normalize.ts
@@ -264,13 +180,25 @@ var document = {
264
180
  height: "100%"
265
181
  },
266
182
  html: {
183
+ /**
184
+ * Prevent Mobile Safari from zooming stuff ...
185
+ * Source: https://css-tricks.com/your-css-reset-needs-text-size-adjust-probably/
186
+ */
267
187
  textSizeAdjust: "none"
268
188
  },
269
189
  body: {
270
190
  lineHeight: 1.5,
271
191
  WebkitFontSmoothing: "antialiased",
192
+ /**
193
+ * We have to duplicate this here, since the "*" selector will not be
194
+ * applied to the body element if a custom `selector` is used.
195
+ */
272
196
  margin: 0
273
197
  },
198
+ /**
199
+ * CSS snippet and idea from:
200
+ * https://css-tricks.com/revisiting-prefers-reduced-motion-the-reduced-motion-media-query/
201
+ */
274
202
  "@media screen and (prefers-reduced-motion: reduce), (update: slow)": {
275
203
  "*": {
276
204
  animationDuration: "0.001ms !important",
@@ -296,6 +224,10 @@ var element = {
296
224
  display: "block",
297
225
  maxWidth: "100%"
298
226
  },
227
+ /**
228
+ * No `maxWidth` for SVG since this makes them responsive
229
+ * and will cause icons to shrink.
230
+ */
299
231
  svg: {
300
232
  display: "block",
301
233
  fill: "currentColor"
@@ -334,17 +266,23 @@ var element = {
334
266
  };
335
267
 
336
268
  // src/components/Global/Global.tsx
269
+ var mergeRoot = ({ body, ...rest }) => typeof body === "object" ? {
270
+ ...body,
271
+ ...rest
272
+ } : {
273
+ body,
274
+ ...rest
275
+ };
337
276
  var Global = ({ normalizeDocument = true, selector: selector2 }) => {
338
277
  const { css, theme } = useTheme();
339
278
  const rootStyles = css((theme == null ? void 0 : theme.root) || {});
340
279
  const styles = [
341
280
  normalizeDocument ? document : {},
281
+ // Prefix normalization and root styles with selector if provided.
342
282
  selector2 ? { [`:where(${selector2})`]: element } : element,
343
- selector2 ? { [`:where(${selector2})`]: rootStyles } : rootStyles
283
+ selector2 ? { [`:where(${selector2})`]: mergeRoot(rootStyles) } : rootStyles
344
284
  ];
345
- return /* @__PURE__ */ import_react5.default.createElement(import_react6.Global, {
346
- styles
347
- });
285
+ return /* @__PURE__ */ import_react5.default.createElement(import_react6.Global, { styles });
348
286
  };
349
287
 
350
288
  // src/components/SVG/SVG.tsx
package/dist/index.mjs CHANGED
@@ -42,6 +42,7 @@ var pseudos = {
42
42
  "&:error": createteSelector([selector.self], state.error),
43
43
  "&:expanded": createteSelector([selector.self], state.expanded),
44
44
  "&:required": createteSelector([selector.self], state.required),
45
+ // Selector for elements that are part of a group
45
46
  "&:in-group": createteSelector(selector.grouped, state.none, selector.self),
46
47
  "&:hover-group": createteSelector(
47
48
  selector.grouped,
@@ -81,106 +82,21 @@ var transformPseudos = (styles) => {
81
82
  };
82
83
 
83
84
  // src/components/Box/Box.tsx
84
- var createThemedStyle = ({ __baseCSS, styles, css }) => (theme) => {
85
+ var createThemedStyle = ({ __baseCSS, css }) => (theme) => {
85
86
  const themedStyles = merge.all([
86
87
  transformStyleObject(__baseCSS)(theme),
87
- transformStyleObject(styles)(theme),
88
88
  ...Array.isArray(css) ? css.map((c) => transformStyleObject(c)(theme)) : [transformStyleObject(css)(theme)]
89
89
  ]);
90
90
  return transformPseudos(themedStyles);
91
91
  };
92
92
  var Box = forwardRef(
93
- ({
94
- as = "div",
95
- children,
96
- __baseCSS,
97
- css,
98
- display,
99
- height,
100
- width,
101
- minWidth,
102
- maxWidth,
103
- position,
104
- top,
105
- bottom,
106
- right,
107
- left,
108
- zIndex,
109
- p,
110
- px,
111
- py,
112
- pt,
113
- pb,
114
- pl,
115
- pr,
116
- m,
117
- mx,
118
- my,
119
- mt,
120
- mb,
121
- ml,
122
- mr,
123
- flexDirection,
124
- flexWrap,
125
- flexShrink,
126
- flexGrow,
127
- alignItems,
128
- justifyContent,
129
- bg,
130
- border,
131
- borderRadius,
132
- boxShadow,
133
- opacity,
134
- overflow,
135
- transition,
136
- ...props
137
- }, ref) => jsx(
93
+ ({ as = "div", children, __baseCSS, css, ...props }, ref) => jsx(
138
94
  as,
139
95
  {
140
96
  ...props,
141
97
  css: createThemedStyle({
142
98
  __baseCSS,
143
- css,
144
- styles: {
145
- display,
146
- height,
147
- width,
148
- minWidth,
149
- maxWidth,
150
- position,
151
- top,
152
- bottom,
153
- right,
154
- left,
155
- zIndex,
156
- p,
157
- px,
158
- py,
159
- pt,
160
- pb,
161
- pl,
162
- pr,
163
- m,
164
- mx,
165
- my,
166
- mt,
167
- mb,
168
- ml,
169
- mr,
170
- flexDirection,
171
- flexWrap,
172
- flexShrink,
173
- flexGrow,
174
- alignItems,
175
- justifyContent,
176
- bg,
177
- border,
178
- borderRadius,
179
- boxShadow,
180
- opacity,
181
- overflow,
182
- transition
183
- }
99
+ css
184
100
  }),
185
101
  ref
186
102
  },
@@ -218,11 +134,7 @@ function ThemeProvider({
218
134
  theme,
219
135
  children
220
136
  }) {
221
- return /* @__PURE__ */ React.createElement(EmotionProvider, {
222
- theme
223
- }, /* @__PURE__ */ React.createElement(InternalContext.Provider, {
224
- value: theme
225
- }, children));
137
+ return /* @__PURE__ */ React.createElement(EmotionProvider, { theme }, /* @__PURE__ */ React.createElement(InternalContext.Provider, { value: theme }, children));
226
138
  }
227
139
 
228
140
  // src/components/Global/normalize.ts
@@ -231,13 +143,25 @@ var document = {
231
143
  height: "100%"
232
144
  },
233
145
  html: {
146
+ /**
147
+ * Prevent Mobile Safari from zooming stuff ...
148
+ * Source: https://css-tricks.com/your-css-reset-needs-text-size-adjust-probably/
149
+ */
234
150
  textSizeAdjust: "none"
235
151
  },
236
152
  body: {
237
153
  lineHeight: 1.5,
238
154
  WebkitFontSmoothing: "antialiased",
155
+ /**
156
+ * We have to duplicate this here, since the "*" selector will not be
157
+ * applied to the body element if a custom `selector` is used.
158
+ */
239
159
  margin: 0
240
160
  },
161
+ /**
162
+ * CSS snippet and idea from:
163
+ * https://css-tricks.com/revisiting-prefers-reduced-motion-the-reduced-motion-media-query/
164
+ */
241
165
  "@media screen and (prefers-reduced-motion: reduce), (update: slow)": {
242
166
  "*": {
243
167
  animationDuration: "0.001ms !important",
@@ -263,6 +187,10 @@ var element = {
263
187
  display: "block",
264
188
  maxWidth: "100%"
265
189
  },
190
+ /**
191
+ * No `maxWidth` for SVG since this makes them responsive
192
+ * and will cause icons to shrink.
193
+ */
266
194
  svg: {
267
195
  display: "block",
268
196
  fill: "currentColor"
@@ -301,17 +229,23 @@ var element = {
301
229
  };
302
230
 
303
231
  // src/components/Global/Global.tsx
232
+ var mergeRoot = ({ body, ...rest }) => typeof body === "object" ? {
233
+ ...body,
234
+ ...rest
235
+ } : {
236
+ body,
237
+ ...rest
238
+ };
304
239
  var Global = ({ normalizeDocument = true, selector: selector2 }) => {
305
240
  const { css, theme } = useTheme();
306
241
  const rootStyles = css((theme == null ? void 0 : theme.root) || {});
307
242
  const styles = [
308
243
  normalizeDocument ? document : {},
244
+ // Prefix normalization and root styles with selector if provided.
309
245
  selector2 ? { [`:where(${selector2})`]: element } : element,
310
- selector2 ? { [`:where(${selector2})`]: rootStyles } : rootStyles
246
+ selector2 ? { [`:where(${selector2})`]: mergeRoot(rootStyles) } : rootStyles
311
247
  ];
312
- return /* @__PURE__ */ React2.createElement(EmotionGlobal, {
313
- styles
314
- });
248
+ return /* @__PURE__ */ React2.createElement(EmotionGlobal, { styles });
315
249
  };
316
250
 
317
251
  // src/components/SVG/SVG.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marigold/system",
3
- "version": "4.2.2",
3
+ "version": "5.1.0",
4
4
  "description": "Marigold System Library",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -26,12 +26,12 @@
26
26
  "directory": "packages/system"
27
27
  },
28
28
  "dependencies": {
29
- "@emotion/react": "11.10.5",
29
+ "@emotion/react": "11.10.6",
30
30
  "@theme-ui/css": "0.15.4",
31
31
  "csstype": "3.1.1",
32
32
  "deepmerge": "^4.2.2",
33
33
  "react-fast-compare": "^3.2.0",
34
- "@marigold/types": "0.5.7"
34
+ "@marigold/types": "1.0.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": "16.x || 17.x || 18.x",
@@ -40,7 +40,7 @@
40
40
  "devDependencies": {
41
41
  "@babel/core": "7.20.12",
42
42
  "react": "18.2.0",
43
- "tsup": "6.5.0",
43
+ "tsup": "6.6.3",
44
44
  "@marigold/tsconfig": "0.4.0"
45
45
  },
46
46
  "scripts": {