@marigold/system 11.5.0 → 12.0.1
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 +18 -8
- package/dist/index.d.ts +18 -8
- package/dist/index.js +37 -16
- package/dist/index.mjs +28 -7
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React$1, { ReactNode } from 'react';
|
|
1
|
+
import React$1, { Context, ReactNode } from 'react';
|
|
2
2
|
import { HtmlProps, KebabCase } from '@marigold/types';
|
|
3
|
-
import { DateFormatterOptions } from '@react-aria/i18n';
|
|
3
|
+
import { DateFormatterOptions, useNumberFormatter } from '@react-aria/i18n';
|
|
4
4
|
import { ClassValue, StringToBoolean, ClassProp } from 'class-variance-authority/dist/types';
|
|
5
5
|
export { ClassValue } from 'class-variance-authority/dist/types';
|
|
6
6
|
export { VariantProps } from 'class-variance-authority';
|
|
@@ -30,11 +30,13 @@ interface DateFormatProps extends DateFormatterOptions {
|
|
|
30
30
|
}
|
|
31
31
|
declare const DateFormat: ({ value, tabular, ...props }: DateFormatProps) => React$1.JSX.Element;
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
type NumerFormatterOptions = NonNullable<Parameters<typeof useNumberFormatter>[0]>;
|
|
34
|
+
type StringNumericLiteral = `${number}` | 'Infinity' | '-Infinity' | '+Infinity';
|
|
35
|
+
interface NumericFormatProps extends NumerFormatterOptions {
|
|
34
36
|
/**
|
|
35
37
|
* Value to be formatted.
|
|
36
38
|
*/
|
|
37
|
-
value: number | bigint;
|
|
39
|
+
value: number | bigint | StringNumericLiteral | [number, number] | [bigint, bigint] | [StringNumericLiteral, StringNumericLiteral];
|
|
38
40
|
/**
|
|
39
41
|
* The numberingSystem accessor property of Intl.Locale instances returns the numeral system for this locale.
|
|
40
42
|
*/
|
|
@@ -144,7 +146,8 @@ type Theme = {
|
|
|
144
146
|
List?: Record<'ol' | 'ul' | 'item', ComponentStyleFunction<string, string>>;
|
|
145
147
|
Link?: ComponentStyleFunction<string, string>;
|
|
146
148
|
ListBox?: Record<'container' | 'list' | 'item' | 'section' | 'header', ComponentStyleFunction<string, string>>;
|
|
147
|
-
Menu?: Record<'container' | 'section' | 'item', ComponentStyleFunction<string, string>>;
|
|
149
|
+
Menu?: Record<'container' | 'section' | 'item' | 'button', ComponentStyleFunction<string, string>>;
|
|
150
|
+
Modal?: ComponentStyleFunction<string, string>;
|
|
148
151
|
MultiSelect?: Record<'container' | 'closeButton' | 'field' | 'input' | 'icon' | 'listContainer' | 'list' | 'option' | 'tag' | 'valueContainer', ComponentStyleFunction<string, string>>;
|
|
149
152
|
Pagination?: Record<'navigationButton' | 'pageButton' | 'icon', ComponentStyleFunction<string, string>>;
|
|
150
153
|
ProgressCycle?: ComponentStyleFunction<string, string>;
|
|
@@ -170,6 +173,11 @@ type ComponentNames = keyof Theme['components'];
|
|
|
170
173
|
type ThemeComponent<C extends ComponentNames> = NonNullable<Theme['components'][C]>;
|
|
171
174
|
type ThemeComponentParts<C extends ComponentNames> = keyof ThemeComponent<C>;
|
|
172
175
|
|
|
176
|
+
interface ComponentContextProps {
|
|
177
|
+
size?: string;
|
|
178
|
+
variant?: string;
|
|
179
|
+
[key: string]: any;
|
|
180
|
+
}
|
|
173
181
|
interface UseClassNamesProps<C extends ComponentNames> {
|
|
174
182
|
component: C;
|
|
175
183
|
variant?: string;
|
|
@@ -177,11 +185,12 @@ interface UseClassNamesProps<C extends ComponentNames> {
|
|
|
177
185
|
className?: ThemeComponent<C> extends (...args: any) => any ? string : {
|
|
178
186
|
[slot in keyof ThemeComponent<C>]?: string;
|
|
179
187
|
};
|
|
188
|
+
context?: Context<ComponentContextProps>;
|
|
180
189
|
}
|
|
181
190
|
type ComponentClassNames<C extends ComponentNames> = ThemeComponent<C> extends (...args: any) => any ? string : {
|
|
182
191
|
[slot in keyof ThemeComponent<C>]: string;
|
|
183
192
|
};
|
|
184
|
-
declare const useClassNames: <C extends ComponentNames>({ component, className, variant, size, }: UseClassNamesProps<C>) => ComponentClassNames<C>;
|
|
193
|
+
declare const useClassNames: <C extends ComponentNames>({ component, className, variant, size, context: ComponentContext, }: UseClassNamesProps<C>) => ComponentClassNames<C>;
|
|
185
194
|
|
|
186
195
|
/**
|
|
187
196
|
* Hook that can be used to return values based on the current screen size,
|
|
@@ -254,7 +263,8 @@ declare const extendTheme: (newStyles: StylesProps, theme: Theme) => {
|
|
|
254
263
|
List?: Record<"ol" | "ul" | "item", ComponentStyleFunction<string, string>>;
|
|
255
264
|
Link?: ComponentStyleFunction<string, string>;
|
|
256
265
|
ListBox?: Record<"container" | "list" | "item" | "section" | "header", ComponentStyleFunction<string, string>>;
|
|
257
|
-
Menu?: Record<"container" | "section" | "item", ComponentStyleFunction<string, string>>;
|
|
266
|
+
Menu?: Record<"container" | "section" | "item" | "button", ComponentStyleFunction<string, string>>;
|
|
267
|
+
Modal?: ComponentStyleFunction<string, string>;
|
|
258
268
|
MultiSelect?: Record<"container" | "closeButton" | "field" | "input" | "icon" | "listContainer" | "list" | "option" | "tag" | "valueContainer", ComponentStyleFunction<string, string>>;
|
|
259
269
|
Pagination?: Record<"navigationButton" | "pageButton" | "icon", ComponentStyleFunction<string, string>>;
|
|
260
270
|
ProgressCycle?: ComponentStyleFunction<string, string>;
|
|
@@ -1050,4 +1060,4 @@ type HeightProp = {
|
|
|
1050
1060
|
height?: keyof typeof height;
|
|
1051
1061
|
};
|
|
1052
1062
|
|
|
1053
|
-
export { type AlignmentProp, type AspectProp, 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 HeightProp, type MaxWidthProp, 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 StylesProps, type TextAlignProp, type Theme, type ThemeComponent, type ThemeComponentParts, ThemeProvider, type ThemeProviderProps, type UseClassNamesProps, type UseStateProps, type WidthProp, alignment, aspect, cn, createVar, cursorStyle, cva, defaultTheme, ensureCssVar, extendTheme, fontWeight, gapSpace, get, height, isValidCssCustomPropertyName, maxWidth, objectFit, objectPosition, paddingBottom, paddingLeft, paddingRight, paddingSpace, paddingSpaceX, paddingSpaceY, paddingTop, placeItems, textAlign, textSize, textStyle, useClassNames, useResponsiveValue, useSmallScreen, useStateProps, useTheme, width };
|
|
1063
|
+
export { type AlignmentProp, type AspectProp, 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 HeightProp, type MaxWidthProp, type NestedStringObject, type NumerFormatterOptions, 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 StylesProps, type TextAlignProp, type Theme, type ThemeComponent, type ThemeComponentParts, ThemeProvider, type ThemeProviderProps, type UseClassNamesProps, type UseStateProps, type WidthProp, alignment, aspect, cn, createVar, cursorStyle, cva, defaultTheme, ensureCssVar, extendTheme, fontWeight, gapSpace, get, height, isValidCssCustomPropertyName, maxWidth, 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,6 +1,6 @@
|
|
|
1
|
-
import React$1, { ReactNode } from 'react';
|
|
1
|
+
import React$1, { Context, ReactNode } from 'react';
|
|
2
2
|
import { HtmlProps, KebabCase } from '@marigold/types';
|
|
3
|
-
import { DateFormatterOptions } from '@react-aria/i18n';
|
|
3
|
+
import { DateFormatterOptions, useNumberFormatter } from '@react-aria/i18n';
|
|
4
4
|
import { ClassValue, StringToBoolean, ClassProp } from 'class-variance-authority/dist/types';
|
|
5
5
|
export { ClassValue } from 'class-variance-authority/dist/types';
|
|
6
6
|
export { VariantProps } from 'class-variance-authority';
|
|
@@ -30,11 +30,13 @@ interface DateFormatProps extends DateFormatterOptions {
|
|
|
30
30
|
}
|
|
31
31
|
declare const DateFormat: ({ value, tabular, ...props }: DateFormatProps) => React$1.JSX.Element;
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
type NumerFormatterOptions = NonNullable<Parameters<typeof useNumberFormatter>[0]>;
|
|
34
|
+
type StringNumericLiteral = `${number}` | 'Infinity' | '-Infinity' | '+Infinity';
|
|
35
|
+
interface NumericFormatProps extends NumerFormatterOptions {
|
|
34
36
|
/**
|
|
35
37
|
* Value to be formatted.
|
|
36
38
|
*/
|
|
37
|
-
value: number | bigint;
|
|
39
|
+
value: number | bigint | StringNumericLiteral | [number, number] | [bigint, bigint] | [StringNumericLiteral, StringNumericLiteral];
|
|
38
40
|
/**
|
|
39
41
|
* The numberingSystem accessor property of Intl.Locale instances returns the numeral system for this locale.
|
|
40
42
|
*/
|
|
@@ -144,7 +146,8 @@ type Theme = {
|
|
|
144
146
|
List?: Record<'ol' | 'ul' | 'item', ComponentStyleFunction<string, string>>;
|
|
145
147
|
Link?: ComponentStyleFunction<string, string>;
|
|
146
148
|
ListBox?: Record<'container' | 'list' | 'item' | 'section' | 'header', ComponentStyleFunction<string, string>>;
|
|
147
|
-
Menu?: Record<'container' | 'section' | 'item', ComponentStyleFunction<string, string>>;
|
|
149
|
+
Menu?: Record<'container' | 'section' | 'item' | 'button', ComponentStyleFunction<string, string>>;
|
|
150
|
+
Modal?: ComponentStyleFunction<string, string>;
|
|
148
151
|
MultiSelect?: Record<'container' | 'closeButton' | 'field' | 'input' | 'icon' | 'listContainer' | 'list' | 'option' | 'tag' | 'valueContainer', ComponentStyleFunction<string, string>>;
|
|
149
152
|
Pagination?: Record<'navigationButton' | 'pageButton' | 'icon', ComponentStyleFunction<string, string>>;
|
|
150
153
|
ProgressCycle?: ComponentStyleFunction<string, string>;
|
|
@@ -170,6 +173,11 @@ type ComponentNames = keyof Theme['components'];
|
|
|
170
173
|
type ThemeComponent<C extends ComponentNames> = NonNullable<Theme['components'][C]>;
|
|
171
174
|
type ThemeComponentParts<C extends ComponentNames> = keyof ThemeComponent<C>;
|
|
172
175
|
|
|
176
|
+
interface ComponentContextProps {
|
|
177
|
+
size?: string;
|
|
178
|
+
variant?: string;
|
|
179
|
+
[key: string]: any;
|
|
180
|
+
}
|
|
173
181
|
interface UseClassNamesProps<C extends ComponentNames> {
|
|
174
182
|
component: C;
|
|
175
183
|
variant?: string;
|
|
@@ -177,11 +185,12 @@ interface UseClassNamesProps<C extends ComponentNames> {
|
|
|
177
185
|
className?: ThemeComponent<C> extends (...args: any) => any ? string : {
|
|
178
186
|
[slot in keyof ThemeComponent<C>]?: string;
|
|
179
187
|
};
|
|
188
|
+
context?: Context<ComponentContextProps>;
|
|
180
189
|
}
|
|
181
190
|
type ComponentClassNames<C extends ComponentNames> = ThemeComponent<C> extends (...args: any) => any ? string : {
|
|
182
191
|
[slot in keyof ThemeComponent<C>]: string;
|
|
183
192
|
};
|
|
184
|
-
declare const useClassNames: <C extends ComponentNames>({ component, className, variant, size, }: UseClassNamesProps<C>) => ComponentClassNames<C>;
|
|
193
|
+
declare const useClassNames: <C extends ComponentNames>({ component, className, variant, size, context: ComponentContext, }: UseClassNamesProps<C>) => ComponentClassNames<C>;
|
|
185
194
|
|
|
186
195
|
/**
|
|
187
196
|
* Hook that can be used to return values based on the current screen size,
|
|
@@ -254,7 +263,8 @@ declare const extendTheme: (newStyles: StylesProps, theme: Theme) => {
|
|
|
254
263
|
List?: Record<"ol" | "ul" | "item", ComponentStyleFunction<string, string>>;
|
|
255
264
|
Link?: ComponentStyleFunction<string, string>;
|
|
256
265
|
ListBox?: Record<"container" | "list" | "item" | "section" | "header", ComponentStyleFunction<string, string>>;
|
|
257
|
-
Menu?: Record<"container" | "section" | "item", ComponentStyleFunction<string, string>>;
|
|
266
|
+
Menu?: Record<"container" | "section" | "item" | "button", ComponentStyleFunction<string, string>>;
|
|
267
|
+
Modal?: ComponentStyleFunction<string, string>;
|
|
258
268
|
MultiSelect?: Record<"container" | "closeButton" | "field" | "input" | "icon" | "listContainer" | "list" | "option" | "tag" | "valueContainer", ComponentStyleFunction<string, string>>;
|
|
259
269
|
Pagination?: Record<"navigationButton" | "pageButton" | "icon", ComponentStyleFunction<string, string>>;
|
|
260
270
|
ProgressCycle?: ComponentStyleFunction<string, string>;
|
|
@@ -1050,4 +1060,4 @@ type HeightProp = {
|
|
|
1050
1060
|
height?: keyof typeof height;
|
|
1051
1061
|
};
|
|
1052
1062
|
|
|
1053
|
-
export { type AlignmentProp, type AspectProp, 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 HeightProp, type MaxWidthProp, 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 StylesProps, type TextAlignProp, type Theme, type ThemeComponent, type ThemeComponentParts, ThemeProvider, type ThemeProviderProps, type UseClassNamesProps, type UseStateProps, type WidthProp, alignment, aspect, cn, createVar, cursorStyle, cva, defaultTheme, ensureCssVar, extendTheme, fontWeight, gapSpace, get, height, isValidCssCustomPropertyName, maxWidth, objectFit, objectPosition, paddingBottom, paddingLeft, paddingRight, paddingSpace, paddingSpaceX, paddingSpaceY, paddingTop, placeItems, textAlign, textSize, textStyle, useClassNames, useResponsiveValue, useSmallScreen, useStateProps, useTheme, width };
|
|
1063
|
+
export { type AlignmentProp, type AspectProp, 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 HeightProp, type MaxWidthProp, type NestedStringObject, type NumerFormatterOptions, 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 StylesProps, type TextAlignProp, type Theme, type ThemeComponent, type ThemeComponentParts, ThemeProvider, type ThemeProviderProps, type UseClassNamesProps, type UseStateProps, type WidthProp, alignment, aspect, cn, createVar, cursorStyle, cva, defaultTheme, ensureCssVar, extendTheme, fontWeight, gapSpace, get, height, isValidCssCustomPropertyName, maxWidth, objectFit, objectPosition, paddingBottom, paddingLeft, paddingRight, paddingSpace, paddingSpaceX, paddingSpaceY, paddingTop, placeItems, textAlign, textSize, textStyle, useClassNames, useResponsiveValue, useSmallScreen, useStateProps, useTheme, width };
|
package/dist/index.js
CHANGED
|
@@ -136,12 +136,15 @@ var NumericFormat = ({
|
|
|
136
136
|
tabular = true,
|
|
137
137
|
...props
|
|
138
138
|
}) => {
|
|
139
|
-
const
|
|
139
|
+
const formatter = (0, import_i18n2.useNumberFormatter)({
|
|
140
140
|
...props
|
|
141
141
|
});
|
|
142
|
-
return /* @__PURE__ */ import_react3.default.createElement("span", { className: tabular ? "tabular-nums" : void 0 },
|
|
142
|
+
return /* @__PURE__ */ import_react3.default.createElement("span", { className: tabular ? "tabular-nums" : void 0 }, Array.isArray(value) ? formatter.formatRange(value[0], value[1]) : formatter.format(value));
|
|
143
143
|
};
|
|
144
144
|
|
|
145
|
+
// src/hooks/useClassNames.tsx
|
|
146
|
+
var import_react5 = require("react");
|
|
147
|
+
|
|
145
148
|
// src/hooks/useTheme.tsx
|
|
146
149
|
var import_react4 = __toESM(require("react"));
|
|
147
150
|
|
|
@@ -175,13 +178,20 @@ function ThemeProvider({
|
|
|
175
178
|
}
|
|
176
179
|
|
|
177
180
|
// src/hooks/useClassNames.tsx
|
|
181
|
+
var FallbackContext = (0, import_react5.createContext)(
|
|
182
|
+
null
|
|
183
|
+
);
|
|
178
184
|
var useClassNames = ({
|
|
179
185
|
component,
|
|
180
186
|
className,
|
|
181
187
|
variant,
|
|
182
|
-
size
|
|
188
|
+
size,
|
|
189
|
+
context: ComponentContext
|
|
183
190
|
}) => {
|
|
184
191
|
const theme = useTheme();
|
|
192
|
+
const ctx = (0, import_react5.useContext)(ComponentContext != null ? ComponentContext : FallbackContext);
|
|
193
|
+
const currentSize = size != null ? size : ctx == null ? void 0 : ctx.size;
|
|
194
|
+
const currentVariant = variant != null ? variant : ctx == null ? void 0 : ctx.variant;
|
|
185
195
|
const styles = theme.components[component];
|
|
186
196
|
if (!styles) {
|
|
187
197
|
throw new Error(
|
|
@@ -194,7 +204,13 @@ var useClassNames = ({
|
|
|
194
204
|
'"className" must be a string, when using a component without slots'
|
|
195
205
|
);
|
|
196
206
|
}
|
|
197
|
-
return cn(
|
|
207
|
+
return cn(
|
|
208
|
+
styles({
|
|
209
|
+
variant: currentVariant,
|
|
210
|
+
size: currentSize,
|
|
211
|
+
className
|
|
212
|
+
})
|
|
213
|
+
);
|
|
198
214
|
}
|
|
199
215
|
if (className !== void 0 && typeof className !== "object") {
|
|
200
216
|
throw new Error(
|
|
@@ -207,8 +223,8 @@ var useClassNames = ({
|
|
|
207
223
|
slot,
|
|
208
224
|
cn(
|
|
209
225
|
style({
|
|
210
|
-
variant,
|
|
211
|
-
size,
|
|
226
|
+
variant: currentVariant,
|
|
227
|
+
size: currentSize,
|
|
212
228
|
className: className && className[slot]
|
|
213
229
|
})
|
|
214
230
|
)
|
|
@@ -218,7 +234,7 @@ var useClassNames = ({
|
|
|
218
234
|
};
|
|
219
235
|
|
|
220
236
|
// src/hooks/useResponsiveValue.ts
|
|
221
|
-
var
|
|
237
|
+
var import_react6 = require("react");
|
|
222
238
|
var useResponsiveValue = (values, defaultIndex = 0) => {
|
|
223
239
|
const theme = useTheme();
|
|
224
240
|
const screens = theme.screens || defaultTheme.screens;
|
|
@@ -227,8 +243,8 @@ var useResponsiveValue = (values, defaultIndex = 0) => {
|
|
|
227
243
|
`Default breakpoint index is out of bounds. Theme has ${Object.keys(screens).length + 1} breakpoints, default is ${defaultIndex}.`
|
|
228
244
|
);
|
|
229
245
|
}
|
|
230
|
-
const [index, setIndex] = (0,
|
|
231
|
-
(0,
|
|
246
|
+
const [index, setIndex] = (0, import_react6.useState)(defaultIndex);
|
|
247
|
+
(0, import_react6.useEffect)(() => {
|
|
232
248
|
if (typeof window == "undefined") return;
|
|
233
249
|
const getIndex = () => Object.values(screens).filter(
|
|
234
250
|
(breakpoint) => window.matchMedia(`screen and (min-width: ${breakpoint})`).matches
|
|
@@ -247,12 +263,12 @@ var useResponsiveValue = (values, defaultIndex = 0) => {
|
|
|
247
263
|
};
|
|
248
264
|
|
|
249
265
|
// src/hooks/useStateProps.ts
|
|
250
|
-
var
|
|
266
|
+
var import_react7 = require("react");
|
|
251
267
|
var import_react_fast_compare = __toESM(require("react-fast-compare"));
|
|
252
268
|
var KEBAB_REGEX = /[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;
|
|
253
269
|
var toKebap = (val) => val.replace(KEBAB_REGEX, (match) => `-${match.toLocaleLowerCase()}`);
|
|
254
270
|
var useStateProps = (states) => {
|
|
255
|
-
const statePropsRef = (0,
|
|
271
|
+
const statePropsRef = (0, import_react7.useRef)({});
|
|
256
272
|
let stateProps = {};
|
|
257
273
|
for (let state in states) {
|
|
258
274
|
if (states[state]) {
|
|
@@ -267,7 +283,7 @@ var useStateProps = (states) => {
|
|
|
267
283
|
};
|
|
268
284
|
|
|
269
285
|
// src/hooks/useSmallScreen.ts
|
|
270
|
-
var
|
|
286
|
+
var import_react8 = require("react");
|
|
271
287
|
var useSmallScreen = () => {
|
|
272
288
|
const getMatches = () => {
|
|
273
289
|
if (typeof window == "undefined") {
|
|
@@ -275,11 +291,11 @@ var useSmallScreen = () => {
|
|
|
275
291
|
}
|
|
276
292
|
return window.matchMedia("(max-width: 600px)").matches;
|
|
277
293
|
};
|
|
278
|
-
const [matches, setMatches] = (0,
|
|
279
|
-
const handleResize = (0,
|
|
294
|
+
const [matches, setMatches] = (0, import_react8.useState)(getMatches());
|
|
295
|
+
const handleResize = (0, import_react8.useCallback)(() => {
|
|
280
296
|
setMatches(getMatches());
|
|
281
297
|
}, []);
|
|
282
|
-
(0,
|
|
298
|
+
(0, import_react8.useEffect)(() => {
|
|
283
299
|
handleResize();
|
|
284
300
|
if (typeof window == "undefined") return;
|
|
285
301
|
window.addEventListener("resize", handleResize);
|
|
@@ -318,7 +334,10 @@ var extendTheme = (newStyles, theme) => {
|
|
|
318
334
|
const variants = ["size", "variant"].reduce((acc, variantItem) => {
|
|
319
335
|
var _a, _b, _c, _d;
|
|
320
336
|
const newStylesVariants = (_a = newStyles[component].variants) == null ? void 0 : _a[variantItem];
|
|
321
|
-
const mergedStylesVariants = (
|
|
337
|
+
const mergedStylesVariants = (
|
|
338
|
+
// @ts-expect-error any
|
|
339
|
+
(_b = mergedStyles[component].variants) == null ? void 0 : _b[variantItem]
|
|
340
|
+
);
|
|
322
341
|
if (newStylesVariants && mergedStylesVariants) {
|
|
323
342
|
const dupVariants = Object.keys(newStylesVariants).filter(
|
|
324
343
|
(variant) => Object.keys(mergedStylesVariants).includes(variant)
|
|
@@ -328,7 +347,9 @@ var extendTheme = (newStyles, theme) => {
|
|
|
328
347
|
}
|
|
329
348
|
}
|
|
330
349
|
acc[variantItem] = {
|
|
350
|
+
// @ts-expect-error any
|
|
331
351
|
...(_c = newStyles[component].variants) == null ? void 0 : _c[variantItem],
|
|
352
|
+
// @ts-expect-error any
|
|
332
353
|
...(_d = mergedStyles[component].variants) == null ? void 0 : _d[variantItem]
|
|
333
354
|
};
|
|
334
355
|
return acc;
|
package/dist/index.mjs
CHANGED
|
@@ -63,12 +63,15 @@ var NumericFormat = ({
|
|
|
63
63
|
tabular = true,
|
|
64
64
|
...props
|
|
65
65
|
}) => {
|
|
66
|
-
const
|
|
66
|
+
const formatter = useNumberFormatter({
|
|
67
67
|
...props
|
|
68
68
|
});
|
|
69
|
-
return /* @__PURE__ */ React3.createElement("span", { className: tabular ? "tabular-nums" : void 0 },
|
|
69
|
+
return /* @__PURE__ */ React3.createElement("span", { className: tabular ? "tabular-nums" : void 0 }, Array.isArray(value) ? formatter.formatRange(value[0], value[1]) : formatter.format(value));
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
// src/hooks/useClassNames.tsx
|
|
73
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
74
|
+
|
|
72
75
|
// src/hooks/useTheme.tsx
|
|
73
76
|
import React4, { createContext, useContext } from "react";
|
|
74
77
|
|
|
@@ -102,13 +105,20 @@ function ThemeProvider({
|
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
// src/hooks/useClassNames.tsx
|
|
108
|
+
var FallbackContext = createContext2(
|
|
109
|
+
null
|
|
110
|
+
);
|
|
105
111
|
var useClassNames = ({
|
|
106
112
|
component,
|
|
107
113
|
className,
|
|
108
114
|
variant,
|
|
109
|
-
size
|
|
115
|
+
size,
|
|
116
|
+
context: ComponentContext
|
|
110
117
|
}) => {
|
|
111
118
|
const theme = useTheme();
|
|
119
|
+
const ctx = useContext2(ComponentContext != null ? ComponentContext : FallbackContext);
|
|
120
|
+
const currentSize = size != null ? size : ctx == null ? void 0 : ctx.size;
|
|
121
|
+
const currentVariant = variant != null ? variant : ctx == null ? void 0 : ctx.variant;
|
|
112
122
|
const styles = theme.components[component];
|
|
113
123
|
if (!styles) {
|
|
114
124
|
throw new Error(
|
|
@@ -121,7 +131,13 @@ var useClassNames = ({
|
|
|
121
131
|
'"className" must be a string, when using a component without slots'
|
|
122
132
|
);
|
|
123
133
|
}
|
|
124
|
-
return cn(
|
|
134
|
+
return cn(
|
|
135
|
+
styles({
|
|
136
|
+
variant: currentVariant,
|
|
137
|
+
size: currentSize,
|
|
138
|
+
className
|
|
139
|
+
})
|
|
140
|
+
);
|
|
125
141
|
}
|
|
126
142
|
if (className !== void 0 && typeof className !== "object") {
|
|
127
143
|
throw new Error(
|
|
@@ -134,8 +150,8 @@ var useClassNames = ({
|
|
|
134
150
|
slot,
|
|
135
151
|
cn(
|
|
136
152
|
style({
|
|
137
|
-
variant,
|
|
138
|
-
size,
|
|
153
|
+
variant: currentVariant,
|
|
154
|
+
size: currentSize,
|
|
139
155
|
className: className && className[slot]
|
|
140
156
|
})
|
|
141
157
|
)
|
|
@@ -245,7 +261,10 @@ var extendTheme = (newStyles, theme) => {
|
|
|
245
261
|
const variants = ["size", "variant"].reduce((acc, variantItem) => {
|
|
246
262
|
var _a, _b, _c, _d;
|
|
247
263
|
const newStylesVariants = (_a = newStyles[component].variants) == null ? void 0 : _a[variantItem];
|
|
248
|
-
const mergedStylesVariants = (
|
|
264
|
+
const mergedStylesVariants = (
|
|
265
|
+
// @ts-expect-error any
|
|
266
|
+
(_b = mergedStyles[component].variants) == null ? void 0 : _b[variantItem]
|
|
267
|
+
);
|
|
249
268
|
if (newStylesVariants && mergedStylesVariants) {
|
|
250
269
|
const dupVariants = Object.keys(newStylesVariants).filter(
|
|
251
270
|
(variant) => Object.keys(mergedStylesVariants).includes(variant)
|
|
@@ -255,7 +274,9 @@ var extendTheme = (newStyles, theme) => {
|
|
|
255
274
|
}
|
|
256
275
|
}
|
|
257
276
|
acc[variantItem] = {
|
|
277
|
+
// @ts-expect-error any
|
|
258
278
|
...(_c = newStyles[component].variants) == null ? void 0 : _c[variantItem],
|
|
279
|
+
// @ts-expect-error any
|
|
259
280
|
...(_d = mergedStyles[component].variants) == null ? void 0 : _d[variantItem]
|
|
260
281
|
};
|
|
261
282
|
return acc;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marigold/system",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.1",
|
|
4
4
|
"description": "Marigold System Library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"react-dom": ">=17.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@babel/core": "7.
|
|
50
|
-
"@types/react": "19.1.
|
|
49
|
+
"@babel/core": "7.27.1",
|
|
50
|
+
"@types/react": "19.1.3",
|
|
51
51
|
"postcss": "8.5.3",
|
|
52
52
|
"react": "19.1.0",
|
|
53
|
-
"tailwindcss": "4.1.
|
|
53
|
+
"tailwindcss": "4.1.5",
|
|
54
54
|
"tsup": "8.4.0",
|
|
55
55
|
"@marigold/tsconfig": "0.4.0"
|
|
56
56
|
},
|