@marigold/system 0.7.0 → 0.8.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,7 +1,8 @@
1
1
  import { PolymorphicPropsWithRef, PolymorphicComponentWithRef, ComponentProps } 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
- import React, { ElementType, ReactNode } from 'react';
4
+ import * as react from 'react';
5
+ import { ElementType, ReactNode } from 'react';
5
6
  import * as CSS from 'csstype';
6
7
 
7
8
  /**
@@ -180,9 +181,9 @@ declare const getNormalizedStyles: (val?: ElementType<any> | undefined) => {
180
181
  };
181
182
 
182
183
  interface SVGProps extends ComponentProps<'svg'> {
183
- size?: number;
184
+ size?: number | string | number[] | string[];
184
185
  }
185
- declare const SVG: React.FC<SVGProps>;
186
+ declare const SVG: ({ size, fill, children, ...props }: SVGProps) => react.ReactSVGElement;
186
187
 
187
188
  /**
188
189
  * Value used to define a scale.
@@ -344,6 +345,7 @@ declare const __defaultTheme: Theme;
344
345
  declare const useTheme: () => {
345
346
  theme: Theme;
346
347
  css: (style: StyleObject) => _theme_ui_css.CSSObject;
348
+ get: (path: string) => any;
347
349
  };
348
350
  interface ThemeProviderProps<T extends Theme> {
349
351
  theme: T;
package/dist/index.js CHANGED
@@ -21,7 +21,6 @@ var __spreadValues = (a2, b) => {
21
21
  return a2;
22
22
  };
23
23
  var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
24
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
24
  var __objRest = (source, exclude) => {
26
25
  var target = {};
27
26
  for (var prop in source)
@@ -38,22 +37,16 @@ var __export = (target, all) => {
38
37
  for (var name in all)
39
38
  __defProp(target, name, { get: all[name], enumerable: true });
40
39
  };
41
- var __reExport = (target, module2, copyDefault, desc) => {
42
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
43
- for (let key of __getOwnPropNames(module2))
44
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
45
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
40
+ var __copyProps = (to, from, except, desc) => {
41
+ if (from && typeof from === "object" || typeof from === "function") {
42
+ for (let key of __getOwnPropNames(from))
43
+ if (!__hasOwnProp.call(to, key) && key !== except)
44
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
45
  }
47
- return target;
48
- };
49
- var __toESM = (module2, isNodeMode) => {
50
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
46
+ return to;
51
47
  };
52
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
53
- return (module2, temp) => {
54
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
55
- };
56
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
48
+ 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));
49
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
57
50
 
58
51
  // src/index.ts
59
52
  var src_exports = {};
@@ -73,6 +66,7 @@ __export(src_exports, {
73
66
  useResponsiveValue: () => useResponsiveValue,
74
67
  useTheme: () => useTheme
75
68
  });
69
+ module.exports = __toCommonJS(src_exports);
76
70
 
77
71
  // src/Box.tsx
78
72
  var import_react = require("@emotion/react");
@@ -328,7 +322,8 @@ var InternalContext = (0, import_react3.createContext)(__defaultTheme);
328
322
  var useTheme = () => {
329
323
  const theme = (0, import_react3.useContext)(InternalContext);
330
324
  const css = (0, import_react3.useCallback)((style) => (0, import_css2.css)(style)(theme), [theme]);
331
- return { theme, css };
325
+ const get = (0, import_react3.useCallback)((path) => (0, import_css2.get)(theme, path), [theme]);
326
+ return { theme, css, get };
332
327
  };
333
328
  function ThemeProvider({
334
329
  theme,
@@ -374,6 +369,8 @@ var Global = () => {
374
369
  // src/SVG.tsx
375
370
  var import_react7 = require("@emotion/react");
376
371
  var normalizedStyles = getNormalizedStyles("svg");
372
+ var toDimension = (value) => Array.isArray(value) ? value.map(ensureNumberOrToken) : ensureNumberOrToken(value);
373
+ var ensureNumberOrToken = (value) => typeof value === "string" && /[0-9]+/.test(value) ? Number(value) : value;
377
374
  var SVG = (_a) => {
378
375
  var _b = _a, {
379
376
  size = 24,
@@ -386,10 +383,12 @@ var SVG = (_a) => {
386
383
  ]);
387
384
  const { css } = useTheme();
388
385
  return (0, import_react7.jsx)("svg", __spreadValues({
389
- width: size,
390
- height: size,
391
386
  viewBox: "0 0 24 24",
392
- css: css(__spreadValues({ fill }, normalizedStyles))
387
+ css: css(__spreadProps(__spreadValues({}, normalizedStyles), {
388
+ fill,
389
+ width: toDimension(props.width || size),
390
+ height: toDimension(props.height || size)
391
+ }))
393
392
  }, props), children);
394
393
  };
395
394
 
@@ -417,7 +416,6 @@ var useResponsiveValue = (values, defaultIndex = 0) => {
417
416
  }, [breakpoints, index]);
418
417
  return values[index >= values.length ? values.length - 1 : index];
419
418
  };
420
- module.exports = __toCommonJS(src_exports);
421
419
  // Annotate the CommonJS export names for ESM import in node:
422
420
  0 && (module.exports = {
423
421
  Box,
package/dist/index.mjs CHANGED
@@ -281,14 +281,18 @@ import React, {
281
281
  useCallback,
282
282
  useContext
283
283
  } from "react";
284
- import { css as transformStyleObject2 } from "@theme-ui/css";
284
+ import {
285
+ css as transformStyleObject2,
286
+ get as getfromTheme
287
+ } from "@theme-ui/css";
285
288
  import { ThemeProvider as EmotionProvider } from "@emotion/react";
286
289
  var __defaultTheme = {};
287
290
  var InternalContext = createContext(__defaultTheme);
288
291
  var useTheme = () => {
289
292
  const theme = useContext(InternalContext);
290
293
  const css = useCallback((style) => transformStyleObject2(style)(theme), [theme]);
291
- return { theme, css };
294
+ const get = useCallback((path) => getfromTheme(theme, path), [theme]);
295
+ return { theme, css, get };
292
296
  };
293
297
  function ThemeProvider({
294
298
  theme,
@@ -334,6 +338,8 @@ var Global = () => {
334
338
  // src/SVG.tsx
335
339
  import { jsx as jsx2 } from "@emotion/react";
336
340
  var normalizedStyles = getNormalizedStyles("svg");
341
+ var toDimension = (value) => Array.isArray(value) ? value.map(ensureNumberOrToken) : ensureNumberOrToken(value);
342
+ var ensureNumberOrToken = (value) => typeof value === "string" && /[0-9]+/.test(value) ? Number(value) : value;
337
343
  var SVG = (_a) => {
338
344
  var _b = _a, {
339
345
  size = 24,
@@ -346,10 +352,12 @@ var SVG = (_a) => {
346
352
  ]);
347
353
  const { css } = useTheme();
348
354
  return jsx2("svg", __spreadValues({
349
- width: size,
350
- height: size,
351
355
  viewBox: "0 0 24 24",
352
- css: css(__spreadValues({ fill }, normalizedStyles))
356
+ css: css(__spreadProps(__spreadValues({}, normalizedStyles), {
357
+ fill,
358
+ width: toDimension(props.width || size),
359
+ height: toDimension(props.height || size)
360
+ }))
353
361
  }, props), children);
354
362
  };
355
363
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marigold/system",
3
- "version": "0.7.0",
3
+ "version": "0.8.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.7.1",
29
+ "@emotion/react": "11.8.2",
30
30
  "@marigold/types": "0.4.0",
31
- "@theme-ui/css": "0.13.1",
31
+ "@theme-ui/css": "0.14.2",
32
32
  "csstype": "3.0.11"
33
33
  },
34
34
  "peerDependencies": {
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@marigold/tsconfig": "0.3.0",
40
- "tsup": "5.11.13"
40
+ "tsup": "5.12.4"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "tsup src/index.ts",