@marigold/system 7.1.0 → 7.3.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.mts CHANGED
@@ -1,15 +1,30 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { ReactNode } from 'react';
3
3
  import { HtmlProps, KebabCase } from '@marigold/types';
4
+ import { DateFormatterOptions } from '@react-aria/i18n';
4
5
  import { StringToBoolean, ClassProp } from 'class-variance-authority/dist/types';
5
6
  export { VariantProps } from 'class-variance-authority';
6
7
 
7
- interface SVGProps extends Omit<HtmlProps<'svg'>, 'fill'> {
8
+ interface SVGProps extends Omit<HtmlProps<'svg'>, 'fill' | 'style'> {
8
9
  size?: number | string | number[] | string[];
9
10
  className?: string;
10
11
  }
11
12
  declare const SVG: React__default.ForwardRefExoticComponent<SVGProps & React__default.RefAttributes<SVGSVGElement>>;
12
13
 
14
+ interface DateFormatProps extends DateFormatterOptions {
15
+ value: Date;
16
+ tabular?: boolean;
17
+ }
18
+ declare const DateFormat: ({ value, tabular, ...props }: DateFormatProps) => React__default.JSX.Element;
19
+
20
+ interface NumericFormatProps extends Omit<Intl.NumberFormatOptions, 'style'> {
21
+ value: number | bigint;
22
+ numberingSystem?: string;
23
+ tabular?: boolean;
24
+ styleFormat?: string;
25
+ }
26
+ declare const NumericFormat: ({ value, styleFormat, tabular, ...props }: NumericFormatProps) => React__default.JSX.Element;
27
+
13
28
  type ConfigSchema = Record<string, Record<string, ClassValue>>;
14
29
  type ConfigVariants<T extends ConfigSchema> = {
15
30
  [Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null | undefined;
@@ -34,6 +49,9 @@ declare const cn: (...inputs: ClassValue[]) => string;
34
49
  declare const createVar: (o: {
35
50
  [key: string]: string | number | undefined;
36
51
  }) => React.CSSProperties;
52
+ declare const isObject: (val: any) => val is {
53
+ [key: string]: any;
54
+ };
37
55
  /**
38
56
  * Safely get a dot-notated path within a nested object, with ability
39
57
  * to return a default if the full key path does not exist or
@@ -42,6 +60,15 @@ declare const createVar: (o: {
42
60
  * Based on: https://github.com/developit/dlv
43
61
  */
44
62
  declare const get: (obj: object, path: string, fallback?: any) => any;
63
+ /**
64
+ * Safely get a color value from a Tailwind theme object. This also supports
65
+ * Tailwind's "DEFAULT" fallback.
66
+ *
67
+ * Note: Use the CSS "var name" (e.g. primary-500) not the dot notation.
68
+ */
69
+ declare const getColor: (theme: {
70
+ colors?: object;
71
+ }, path: string, fallback?: any) => any;
45
72
 
46
73
  interface NestedStringObject {
47
74
  [key: string]: NestedStringObject | string;
@@ -147,8 +174,9 @@ declare const useTheme: () => Theme;
147
174
  interface ThemeProviderProps<T extends Theme> {
148
175
  theme: T;
149
176
  children: ReactNode;
177
+ className?: string;
150
178
  }
151
- declare function ThemeProvider<T extends Theme>({ theme, children, }: ThemeProviderProps<T>): React__default.JSX.Element;
179
+ declare function ThemeProvider<T extends Theme>({ theme, children, className, }: ThemeProviderProps<T>): React__default.JSX.Element;
152
180
 
153
181
  declare const useSmallScreen: () => boolean;
154
182
 
@@ -693,4 +721,4 @@ type WidthProp = {
693
721
  width?: keyof typeof width;
694
722
  };
695
723
 
696
- export { type AlignmentProp, type AspectProp, type ClassArray, type ClassDictionary, type ClassValue, type ComponentClassNames, type ComponentNames, type ComponentState, type ComponentStyleFunction, type Config, type ConfigSchema, type ConfigVariants, type ConfigVariantsMulti, type CursorProp, type FontSizeProp, type FontStyleProp, type FontWeightProp, type GapSpaceProp, type GridColsAlignProp, type GridColumn, type NestedStringObject, type ObjectFitProp, type ObjectPositionProp, type PaddingBottomProp, type PaddingLeftProp, type PaddingRightProp, type PaddingSpaceProp, type PaddingSpacePropX, type PaddingSpacePropY, type PaddingTopProp, type PlaceItemsProp, type Props, SVG, type SVGProps, type StateAttrKeyProps, type StateAttrProps, type TextAlignProp, type Theme, type ThemeComponent, ThemeProvider, type ThemeProviderProps, type UseClassNamesProps, type UseStateProps, type WidthProp, alignment, aspect, cn, createVar, cursorStyle, cva, defaultTheme, fontWeight, gapSpace, get, gridColsAlign, gridColumn, objectFit, objectPosition, paddingBottom, paddingLeft, paddingRight, paddingSpace, paddingSpaceX, paddingSpaceY, paddingTop, placeItems, textAlign, textSize, textStyle, useClassNames, useResponsiveValue, useSmallScreen, useStateProps, useTheme, width };
724
+ export { type AlignmentProp, type AspectProp, type ClassArray, type ClassDictionary, type ClassValue, type ComponentClassNames, type ComponentNames, type ComponentState, type ComponentStyleFunction, type Config, type ConfigSchema, type ConfigVariants, type ConfigVariantsMulti, type CursorProp, DateFormat, type FontSizeProp, type FontStyleProp, type FontWeightProp, type GapSpaceProp, type GridColsAlignProp, type GridColumn, type NestedStringObject, NumericFormat, type ObjectFitProp, type ObjectPositionProp, type PaddingBottomProp, type PaddingLeftProp, type PaddingRightProp, type PaddingSpaceProp, type PaddingSpacePropX, type PaddingSpacePropY, type PaddingTopProp, type PlaceItemsProp, type Props, SVG, type SVGProps, type StateAttrKeyProps, type StateAttrProps, type TextAlignProp, type Theme, type ThemeComponent, ThemeProvider, type ThemeProviderProps, type UseClassNamesProps, type UseStateProps, type WidthProp, alignment, aspect, cn, createVar, cursorStyle, cva, defaultTheme, fontWeight, gapSpace, get, getColor, gridColsAlign, gridColumn, isObject, objectFit, objectPosition, paddingBottom, paddingLeft, paddingRight, paddingSpace, paddingSpaceX, paddingSpaceY, paddingTop, placeItems, textAlign, textSize, textStyle, useClassNames, useResponsiveValue, useSmallScreen, useStateProps, useTheme, width };
package/dist/index.d.ts CHANGED
@@ -1,15 +1,30 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { ReactNode } from 'react';
3
3
  import { HtmlProps, KebabCase } from '@marigold/types';
4
+ import { DateFormatterOptions } from '@react-aria/i18n';
4
5
  import { StringToBoolean, ClassProp } from 'class-variance-authority/dist/types';
5
6
  export { VariantProps } from 'class-variance-authority';
6
7
 
7
- interface SVGProps extends Omit<HtmlProps<'svg'>, 'fill'> {
8
+ interface SVGProps extends Omit<HtmlProps<'svg'>, 'fill' | 'style'> {
8
9
  size?: number | string | number[] | string[];
9
10
  className?: string;
10
11
  }
11
12
  declare const SVG: React__default.ForwardRefExoticComponent<SVGProps & React__default.RefAttributes<SVGSVGElement>>;
12
13
 
14
+ interface DateFormatProps extends DateFormatterOptions {
15
+ value: Date;
16
+ tabular?: boolean;
17
+ }
18
+ declare const DateFormat: ({ value, tabular, ...props }: DateFormatProps) => React__default.JSX.Element;
19
+
20
+ interface NumericFormatProps extends Omit<Intl.NumberFormatOptions, 'style'> {
21
+ value: number | bigint;
22
+ numberingSystem?: string;
23
+ tabular?: boolean;
24
+ styleFormat?: string;
25
+ }
26
+ declare const NumericFormat: ({ value, styleFormat, tabular, ...props }: NumericFormatProps) => React__default.JSX.Element;
27
+
13
28
  type ConfigSchema = Record<string, Record<string, ClassValue>>;
14
29
  type ConfigVariants<T extends ConfigSchema> = {
15
30
  [Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null | undefined;
@@ -34,6 +49,9 @@ declare const cn: (...inputs: ClassValue[]) => string;
34
49
  declare const createVar: (o: {
35
50
  [key: string]: string | number | undefined;
36
51
  }) => React.CSSProperties;
52
+ declare const isObject: (val: any) => val is {
53
+ [key: string]: any;
54
+ };
37
55
  /**
38
56
  * Safely get a dot-notated path within a nested object, with ability
39
57
  * to return a default if the full key path does not exist or
@@ -42,6 +60,15 @@ declare const createVar: (o: {
42
60
  * Based on: https://github.com/developit/dlv
43
61
  */
44
62
  declare const get: (obj: object, path: string, fallback?: any) => any;
63
+ /**
64
+ * Safely get a color value from a Tailwind theme object. This also supports
65
+ * Tailwind's "DEFAULT" fallback.
66
+ *
67
+ * Note: Use the CSS "var name" (e.g. primary-500) not the dot notation.
68
+ */
69
+ declare const getColor: (theme: {
70
+ colors?: object;
71
+ }, path: string, fallback?: any) => any;
45
72
 
46
73
  interface NestedStringObject {
47
74
  [key: string]: NestedStringObject | string;
@@ -147,8 +174,9 @@ declare const useTheme: () => Theme;
147
174
  interface ThemeProviderProps<T extends Theme> {
148
175
  theme: T;
149
176
  children: ReactNode;
177
+ className?: string;
150
178
  }
151
- declare function ThemeProvider<T extends Theme>({ theme, children, }: ThemeProviderProps<T>): React__default.JSX.Element;
179
+ declare function ThemeProvider<T extends Theme>({ theme, children, className, }: ThemeProviderProps<T>): React__default.JSX.Element;
152
180
 
153
181
  declare const useSmallScreen: () => boolean;
154
182
 
@@ -693,4 +721,4 @@ type WidthProp = {
693
721
  width?: keyof typeof width;
694
722
  };
695
723
 
696
- export { type AlignmentProp, type AspectProp, type ClassArray, type ClassDictionary, type ClassValue, type ComponentClassNames, type ComponentNames, type ComponentState, type ComponentStyleFunction, type Config, type ConfigSchema, type ConfigVariants, type ConfigVariantsMulti, type CursorProp, type FontSizeProp, type FontStyleProp, type FontWeightProp, type GapSpaceProp, type GridColsAlignProp, type GridColumn, type NestedStringObject, type ObjectFitProp, type ObjectPositionProp, type PaddingBottomProp, type PaddingLeftProp, type PaddingRightProp, type PaddingSpaceProp, type PaddingSpacePropX, type PaddingSpacePropY, type PaddingTopProp, type PlaceItemsProp, type Props, SVG, type SVGProps, type StateAttrKeyProps, type StateAttrProps, type TextAlignProp, type Theme, type ThemeComponent, ThemeProvider, type ThemeProviderProps, type UseClassNamesProps, type UseStateProps, type WidthProp, alignment, aspect, cn, createVar, cursorStyle, cva, defaultTheme, fontWeight, gapSpace, get, gridColsAlign, gridColumn, objectFit, objectPosition, paddingBottom, paddingLeft, paddingRight, paddingSpace, paddingSpaceX, paddingSpaceY, paddingTop, placeItems, textAlign, textSize, textStyle, useClassNames, useResponsiveValue, useSmallScreen, useStateProps, useTheme, width };
724
+ export { type AlignmentProp, type AspectProp, type ClassArray, type ClassDictionary, type ClassValue, type ComponentClassNames, type ComponentNames, type ComponentState, type ComponentStyleFunction, type Config, type ConfigSchema, type ConfigVariants, type ConfigVariantsMulti, type CursorProp, DateFormat, type FontSizeProp, type FontStyleProp, type FontWeightProp, type GapSpaceProp, type GridColsAlignProp, type GridColumn, type NestedStringObject, NumericFormat, type ObjectFitProp, type ObjectPositionProp, type PaddingBottomProp, type PaddingLeftProp, type PaddingRightProp, type PaddingSpaceProp, type PaddingSpacePropX, type PaddingSpacePropY, type PaddingTopProp, type PlaceItemsProp, type Props, SVG, type SVGProps, type StateAttrKeyProps, type StateAttrProps, type TextAlignProp, type Theme, type ThemeComponent, ThemeProvider, type ThemeProviderProps, type UseClassNamesProps, type UseStateProps, type WidthProp, alignment, aspect, cn, createVar, cursorStyle, cva, defaultTheme, fontWeight, gapSpace, get, getColor, gridColsAlign, gridColumn, isObject, objectFit, objectPosition, paddingBottom, paddingLeft, paddingRight, paddingSpace, paddingSpaceX, paddingSpaceY, paddingTop, placeItems, textAlign, textSize, textStyle, useClassNames, useResponsiveValue, useSmallScreen, useStateProps, useTheme, width };
package/dist/index.js CHANGED
@@ -30,6 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
+ DateFormat: () => DateFormat,
34
+ NumericFormat: () => NumericFormat,
33
35
  SVG: () => SVG,
34
36
  ThemeProvider: () => ThemeProvider,
35
37
  alignment: () => alignment,
@@ -42,8 +44,10 @@ __export(src_exports, {
42
44
  fontWeight: () => fontWeight,
43
45
  gapSpace: () => gapSpace,
44
46
  get: () => get,
47
+ getColor: () => getColor,
45
48
  gridColsAlign: () => gridColsAlign,
46
49
  gridColumn: () => gridColumn,
50
+ isObject: () => isObject,
47
51
  objectFit: () => objectFit,
48
52
  objectPosition: () => objectPosition,
49
53
  paddingBottom: () => paddingBottom,
@@ -67,7 +71,7 @@ __export(src_exports, {
67
71
  module.exports = __toCommonJS(src_exports);
68
72
 
69
73
  // src/components/SVG/SVG.tsx
70
- var import_react = __toESM(require("react"));
74
+ var import_react5 = __toESM(require("react"));
71
75
 
72
76
  // src/utils.ts
73
77
  var import_class_variance_authority = require("class-variance-authority");
@@ -84,6 +88,7 @@ var cn = (...inputs) => (0, import_tailwind_merge.twMerge)((0, import_class_vari
84
88
  var createVar = (o) => Object.fromEntries(
85
89
  Object.entries(o).map(([name, val]) => [`--${name}`, val])
86
90
  );
91
+ var isObject = (val) => val && val.constructor === Object;
87
92
  var get = (obj, path, fallback) => {
88
93
  const key = path.split(".");
89
94
  let result = obj;
@@ -94,24 +99,13 @@ var get = (obj, path, fallback) => {
94
99
  }
95
100
  return result === void 0 ? fallback : result;
96
101
  };
97
-
98
- // src/components/SVG/SVG.tsx
99
- var SVG = (0, import_react.forwardRef)(
100
- ({ size = 24, children, className, ...props }, ref) => /* @__PURE__ */ import_react.default.createElement(
101
- "svg",
102
- {
103
- ...props,
104
- ref,
105
- width: `${props.width || size}px`,
106
- height: `${props.height || size}px`,
107
- className: cn("flex-none fill-current", className)
108
- },
109
- children
110
- )
111
- );
102
+ var getColor = (theme, path, fallback) => {
103
+ const result = get(theme.colors || {}, path.replace("-", "."), fallback);
104
+ return isObject(result) ? result["DEFAULT"] : result;
105
+ };
112
106
 
113
107
  // src/hooks/useTheme.tsx
114
- var import_react2 = __toESM(require("react"));
108
+ var import_react = __toESM(require("react"));
115
109
 
116
110
  // src/defaultTheme.ts
117
111
  var defaultTheme = {
@@ -127,17 +121,19 @@ var defaultTheme = {
127
121
  };
128
122
 
129
123
  // src/hooks/useTheme.tsx
130
- var InternalContext = (0, import_react2.createContext)(defaultTheme);
124
+ var InternalContext = (0, import_react.createContext)(defaultTheme);
131
125
  var useTheme = () => {
132
- const theme = (0, import_react2.useContext)(InternalContext);
126
+ const theme = (0, import_react.useContext)(InternalContext);
133
127
  return theme;
134
128
  };
135
129
  function ThemeProvider({
136
130
  theme,
137
- children
131
+ children,
132
+ className
138
133
  }) {
139
- var _a, _b;
140
- return /* @__PURE__ */ import_react2.default.createElement("div", { "data-theme": theme.name, className: (_b = (_a = theme.root) == null ? void 0 : _a.call(theme)) != null ? _b : "" }, /* @__PURE__ */ import_react2.default.createElement(InternalContext.Provider, { value: theme }, children));
134
+ var _a;
135
+ const root = (_a = theme.root) == null ? void 0 : _a.call(theme);
136
+ return /* @__PURE__ */ import_react.default.createElement(InternalContext.Provider, { value: theme }, /* @__PURE__ */ import_react.default.createElement("div", { className: cn(root ? root : "", className) }, children));
141
137
  }
142
138
 
143
139
  // src/hooks/useClassNames.tsx
@@ -184,7 +180,7 @@ var useClassNames = ({
184
180
  };
185
181
 
186
182
  // src/hooks/useResponsiveValue.ts
187
- var import_react3 = require("react");
183
+ var import_react2 = require("react");
188
184
  var useResponsiveValue = (values, defaultIndex = 0) => {
189
185
  const theme = useTheme();
190
186
  const screens = theme.screens || defaultTheme.screens;
@@ -193,8 +189,8 @@ var useResponsiveValue = (values, defaultIndex = 0) => {
193
189
  `Default breakpoint index is out of bounds. Theme has ${Object.keys(screens).length + 1} breakpoints, default is ${defaultIndex}.`
194
190
  );
195
191
  }
196
- const [index, setIndex] = (0, import_react3.useState)(defaultIndex);
197
- (0, import_react3.useEffect)(() => {
192
+ const [index, setIndex] = (0, import_react2.useState)(defaultIndex);
193
+ (0, import_react2.useEffect)(() => {
198
194
  if (typeof window == "undefined")
199
195
  return;
200
196
  const getIndex = () => Object.values(screens).filter(
@@ -214,12 +210,12 @@ var useResponsiveValue = (values, defaultIndex = 0) => {
214
210
  };
215
211
 
216
212
  // src/hooks/useStateProps.ts
217
- var import_react4 = require("react");
213
+ var import_react3 = require("react");
218
214
  var import_react_fast_compare = __toESM(require("react-fast-compare"));
219
215
  var KEBAB_REGEX = /[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;
220
216
  var toKebap = (val) => val.replace(KEBAB_REGEX, (match) => `-${match.toLocaleLowerCase()}`);
221
217
  var useStateProps = (states) => {
222
- const statePropsRef = (0, import_react4.useRef)({});
218
+ const statePropsRef = (0, import_react3.useRef)({});
223
219
  let stateProps = {};
224
220
  for (let state in states) {
225
221
  if (states[state]) {
@@ -234,7 +230,7 @@ var useStateProps = (states) => {
234
230
  };
235
231
 
236
232
  // src/hooks/useSmallScreen.ts
237
- var import_react5 = require("react");
233
+ var import_react4 = require("react");
238
234
  var useSmallScreen = () => {
239
235
  const getMatches = () => {
240
236
  if (typeof window == "undefined") {
@@ -242,11 +238,11 @@ var useSmallScreen = () => {
242
238
  }
243
239
  return window.matchMedia("(max-width: 600px)").matches;
244
240
  };
245
- const [matches, setMatches] = (0, import_react5.useState)(getMatches());
246
- const handleResize = (0, import_react5.useCallback)(() => {
241
+ const [matches, setMatches] = (0, import_react4.useState)(getMatches());
242
+ const handleResize = (0, import_react4.useCallback)(() => {
247
243
  setMatches(getMatches());
248
244
  }, []);
249
- (0, import_react5.useEffect)(() => {
245
+ (0, import_react4.useEffect)(() => {
250
246
  handleResize();
251
247
  if (typeof window == "undefined")
252
248
  return;
@@ -256,6 +252,58 @@ var useSmallScreen = () => {
256
252
  return matches;
257
253
  };
258
254
 
255
+ // src/components/SVG/SVG.tsx
256
+ var SVG = (0, import_react5.forwardRef)(
257
+ ({ size = 24, children, className, color, ...props }, ref) => {
258
+ const theme = useTheme();
259
+ return /* @__PURE__ */ import_react5.default.createElement(
260
+ "svg",
261
+ {
262
+ ...props,
263
+ ref,
264
+ width: `${props.width || size}px`,
265
+ height: `${props.height || size}px`,
266
+ className: cn("flex-none fill-current text-[--color]", className),
267
+ style: createVar({
268
+ color: color && getColor(
269
+ theme,
270
+ color,
271
+ color
272
+ /* fallback */
273
+ )
274
+ })
275
+ },
276
+ children
277
+ );
278
+ }
279
+ );
280
+
281
+ // src/components/Formatters/DateFormat.tsx
282
+ var import_react6 = __toESM(require("react"));
283
+ var import_i18n = require("@react-aria/i18n");
284
+ var DateFormat = ({ value, tabular, ...props }) => {
285
+ const dateFormatter = (0, import_i18n.useDateFormatter)({
286
+ ...props
287
+ });
288
+ return /* @__PURE__ */ import_react6.default.createElement("span", { className: tabular ? "tabular-nums" : "" }, dateFormatter.format(value));
289
+ };
290
+
291
+ // src/components/Formatters/NumericFormat.tsx
292
+ var import_react7 = __toESM(require("react"));
293
+ var import_i18n2 = require("@react-aria/i18n");
294
+ var NumericFormat = ({
295
+ value,
296
+ styleFormat,
297
+ tabular = true,
298
+ ...props
299
+ }) => {
300
+ const numberFormatter = (0, import_i18n2.useNumberFormatter)({
301
+ style: styleFormat,
302
+ ...props
303
+ });
304
+ return /* @__PURE__ */ import_react7.default.createElement("span", { className: tabular ? "tabular-nums" : "" }, numberFormatter.format(value));
305
+ };
306
+
259
307
  // src/style-props.tsx
260
308
  var width = {
261
309
  full: "w-full",
@@ -715,6 +763,8 @@ var cursorStyle = {
715
763
  };
716
764
  // Annotate the CommonJS export names for ESM import in node:
717
765
  0 && (module.exports = {
766
+ DateFormat,
767
+ NumericFormat,
718
768
  SVG,
719
769
  ThemeProvider,
720
770
  alignment,
@@ -727,8 +777,10 @@ var cursorStyle = {
727
777
  fontWeight,
728
778
  gapSpace,
729
779
  get,
780
+ getColor,
730
781
  gridColsAlign,
731
782
  gridColumn,
783
+ isObject,
732
784
  objectFit,
733
785
  objectPosition,
734
786
  paddingBottom,
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/components/SVG/SVG.tsx
2
- import React, { forwardRef } from "react";
2
+ import React2, { forwardRef } from "react";
3
3
 
4
4
  // src/utils.ts
5
5
  import { cx } from "class-variance-authority";
@@ -16,6 +16,7 @@ var cn = (...inputs) => twMerge(cx(inputs));
16
16
  var createVar = (o) => Object.fromEntries(
17
17
  Object.entries(o).map(([name, val]) => [`--${name}`, val])
18
18
  );
19
+ var isObject = (val) => val && val.constructor === Object;
19
20
  var get = (obj, path, fallback) => {
20
21
  const key = path.split(".");
21
22
  let result = obj;
@@ -26,24 +27,13 @@ var get = (obj, path, fallback) => {
26
27
  }
27
28
  return result === void 0 ? fallback : result;
28
29
  };
29
-
30
- // src/components/SVG/SVG.tsx
31
- var SVG = forwardRef(
32
- ({ size = 24, children, className, ...props }, ref) => /* @__PURE__ */ React.createElement(
33
- "svg",
34
- {
35
- ...props,
36
- ref,
37
- width: `${props.width || size}px`,
38
- height: `${props.height || size}px`,
39
- className: cn("flex-none fill-current", className)
40
- },
41
- children
42
- )
43
- );
30
+ var getColor = (theme, path, fallback) => {
31
+ const result = get(theme.colors || {}, path.replace("-", "."), fallback);
32
+ return isObject(result) ? result["DEFAULT"] : result;
33
+ };
44
34
 
45
35
  // src/hooks/useTheme.tsx
46
- import React2, { createContext, useContext } from "react";
36
+ import React, { createContext, useContext } from "react";
47
37
 
48
38
  // src/defaultTheme.ts
49
39
  var defaultTheme = {
@@ -66,10 +56,12 @@ var useTheme = () => {
66
56
  };
67
57
  function ThemeProvider({
68
58
  theme,
69
- children
59
+ children,
60
+ className
70
61
  }) {
71
- var _a, _b;
72
- return /* @__PURE__ */ React2.createElement("div", { "data-theme": theme.name, className: (_b = (_a = theme.root) == null ? void 0 : _a.call(theme)) != null ? _b : "" }, /* @__PURE__ */ React2.createElement(InternalContext.Provider, { value: theme }, children));
62
+ var _a;
63
+ const root = (_a = theme.root) == null ? void 0 : _a.call(theme);
64
+ return /* @__PURE__ */ React.createElement(InternalContext.Provider, { value: theme }, /* @__PURE__ */ React.createElement("div", { className: cn(root ? root : "", className) }, children));
73
65
  }
74
66
 
75
67
  // src/hooks/useClassNames.tsx
@@ -188,6 +180,58 @@ var useSmallScreen = () => {
188
180
  return matches;
189
181
  };
190
182
 
183
+ // src/components/SVG/SVG.tsx
184
+ var SVG = forwardRef(
185
+ ({ size = 24, children, className, color, ...props }, ref) => {
186
+ const theme = useTheme();
187
+ return /* @__PURE__ */ React2.createElement(
188
+ "svg",
189
+ {
190
+ ...props,
191
+ ref,
192
+ width: `${props.width || size}px`,
193
+ height: `${props.height || size}px`,
194
+ className: cn("flex-none fill-current text-[--color]", className),
195
+ style: createVar({
196
+ color: color && getColor(
197
+ theme,
198
+ color,
199
+ color
200
+ /* fallback */
201
+ )
202
+ })
203
+ },
204
+ children
205
+ );
206
+ }
207
+ );
208
+
209
+ // src/components/Formatters/DateFormat.tsx
210
+ import React3 from "react";
211
+ import { useDateFormatter } from "@react-aria/i18n";
212
+ var DateFormat = ({ value, tabular, ...props }) => {
213
+ const dateFormatter = useDateFormatter({
214
+ ...props
215
+ });
216
+ return /* @__PURE__ */ React3.createElement("span", { className: tabular ? "tabular-nums" : "" }, dateFormatter.format(value));
217
+ };
218
+
219
+ // src/components/Formatters/NumericFormat.tsx
220
+ import React4 from "react";
221
+ import { useNumberFormatter } from "@react-aria/i18n";
222
+ var NumericFormat = ({
223
+ value,
224
+ styleFormat,
225
+ tabular = true,
226
+ ...props
227
+ }) => {
228
+ const numberFormatter = useNumberFormatter({
229
+ style: styleFormat,
230
+ ...props
231
+ });
232
+ return /* @__PURE__ */ React4.createElement("span", { className: tabular ? "tabular-nums" : "" }, numberFormatter.format(value));
233
+ };
234
+
191
235
  // src/style-props.tsx
192
236
  var width = {
193
237
  full: "w-full",
@@ -646,6 +690,8 @@ var cursorStyle = {
646
690
  zoomOut: "cursor-zoom-out"
647
691
  };
648
692
  export {
693
+ DateFormat,
694
+ NumericFormat,
649
695
  SVG,
650
696
  ThemeProvider,
651
697
  alignment,
@@ -658,8 +704,10 @@ export {
658
704
  fontWeight,
659
705
  gapSpace,
660
706
  get,
707
+ getColor,
661
708
  gridColsAlign,
662
709
  gridColumn,
710
+ isObject,
663
711
  objectFit,
664
712
  objectPosition,
665
713
  paddingBottom,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marigold/system",
3
- "version": "7.1.0",
3
+ "version": "7.3.0",
4
4
  "description": "Marigold System Library",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -24,10 +24,11 @@
24
24
  "directory": "packages/system"
25
25
  },
26
26
  "dependencies": {
27
+ "@react-aria/i18n": "3.10.0",
27
28
  "class-variance-authority": "0.7.0",
28
29
  "deepmerge": "^4.2.2",
29
30
  "react-fast-compare": "^3.2.0",
30
- "tailwind-merge": "2.1.0",
31
+ "tailwind-merge": "2.2.0",
31
32
  "@marigold/types": "1.1.0"
32
33
  },
33
34
  "peerDependencies": {
@@ -35,10 +36,10 @@
35
36
  "react-dom": "16.x || 17.x || 18.x"
36
37
  },
37
38
  "devDependencies": {
38
- "@babel/core": "7.23.3",
39
- "postcss": "8.4.32",
39
+ "@babel/core": "7.23.7",
40
+ "postcss": "8.4.33",
40
41
  "react": "18.2.0",
41
- "tailwindcss": "3.3.6",
42
+ "tailwindcss": "3.4.1",
42
43
  "tsup": "8.0.1",
43
44
  "@marigold/tsconfig": "0.4.0"
44
45
  },