@marigold/system 16.0.1 → 16.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.js → index.cjs} +77 -61
- package/dist/{index.d.ts → index.d.cts} +113 -51
- package/dist/index.d.mts +113 -51
- package/dist/index.mjs +77 -34
- package/package.json +2 -2
|
@@ -1,40 +1,10 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
1
|
let react = require("react");
|
|
25
|
-
react = __toESM(react);
|
|
26
2
|
let class_variance_authority = require("class-variance-authority");
|
|
27
|
-
class_variance_authority = __toESM(class_variance_authority);
|
|
28
3
|
let tailwind_merge = require("tailwind-merge");
|
|
29
|
-
tailwind_merge = __toESM(tailwind_merge);
|
|
30
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
-
react_jsx_runtime = __toESM(react_jsx_runtime);
|
|
32
5
|
let __react_aria_i18n = require("@react-aria/i18n");
|
|
33
|
-
__react_aria_i18n = __toESM(__react_aria_i18n);
|
|
34
|
-
let react_fast_compare = require("react-fast-compare");
|
|
35
|
-
react_fast_compare = __toESM(react_fast_compare);
|
|
36
6
|
|
|
37
|
-
//#region src/utils.ts
|
|
7
|
+
//#region src/utils/className.utils.ts
|
|
38
8
|
const cva = (base, config) => {
|
|
39
9
|
function styles(props) {
|
|
40
10
|
return (0, tailwind_merge.twMerge)((0, class_variance_authority.cva)(base, config)(props));
|
|
@@ -43,23 +13,19 @@ const cva = (base, config) => {
|
|
|
43
13
|
return styles;
|
|
44
14
|
};
|
|
45
15
|
const cn = (...inputs) => (0, tailwind_merge.twMerge)((0, class_variance_authority.cx)(inputs));
|
|
46
|
-
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/utils/css-variables.utils.ts
|
|
47
19
|
/**
|
|
48
|
-
*
|
|
49
|
-
* to return a default if the full key path does not exist or
|
|
50
|
-
* the value is undefined
|
|
20
|
+
* Checks if the provided string represents a numeric scale value.
|
|
51
21
|
*
|
|
52
|
-
*
|
|
22
|
+
* A scale value is defined as a string containing only digits,
|
|
23
|
+
* optionally followed by a decimal point and more digits (e.g., "1", "2.5").
|
|
24
|
+
*
|
|
25
|
+
* @param value - The string to test for scale format.
|
|
26
|
+
* @returns `true` if the string is a valid scale value, otherwise `false`.
|
|
53
27
|
*/
|
|
54
|
-
const
|
|
55
|
-
const key = path.split(".");
|
|
56
|
-
let result = obj;
|
|
57
|
-
for (let i = 0, length = key.length; i < length; i++) {
|
|
58
|
-
if (!result) break;
|
|
59
|
-
result = result[key[i]];
|
|
60
|
-
}
|
|
61
|
-
return result === void 0 ? fallback : result;
|
|
62
|
-
};
|
|
28
|
+
const isScale = (value) => /^[0-9]+(\.[0-9]+)?$/.test(value);
|
|
63
29
|
/**
|
|
64
30
|
* Checks if a given string is a valid CSS custom property name (without the leading `--`).
|
|
65
31
|
*
|
|
@@ -79,10 +45,31 @@ const isValidCssCustomPropertyName = (val) => /^[A-Za-z0-9_-]+$/.test(val);
|
|
|
79
45
|
* If the value is not a valid custom property name, the function returns the original value.
|
|
80
46
|
*/
|
|
81
47
|
const ensureCssVar = (val, prefix) => isValidCssCustomPropertyName(val) ? `var(--${prefix ? `${prefix}-` : ""}${val}, ${val})` : val;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a CSS custom properties object from the given key-value pairs.
|
|
50
|
+
*
|
|
51
|
+
* @param o - An object with string keys and string/number/undefined values
|
|
52
|
+
* @returns A CSSProperties object with `--` prefixed keys
|
|
53
|
+
*/
|
|
54
|
+
const createVar = (o) => Object.fromEntries(Object.entries(o).map(([name, val]) => [`--${name}`, val]));
|
|
55
|
+
/**
|
|
56
|
+
* Generates a CSS custom property for spacing that uses either a calc expression or a
|
|
57
|
+
* spacing variable reference.
|
|
58
|
+
*
|
|
59
|
+
* If `value` is a number (integer or decimal), uses the `--spacing` scale from Tailwind with calc().
|
|
60
|
+
* Otherwise, references a specific spacing variable (e.g., `--spacing-group`).
|
|
61
|
+
*
|
|
62
|
+
* @param name - The custom property name for spacing.
|
|
63
|
+
* @param value - Spacing value as a string (number or scale key).
|
|
64
|
+
* @returns Object with the CSS custom property for spacing.
|
|
65
|
+
*/
|
|
66
|
+
const createSpacingVar = (name, value) => {
|
|
67
|
+
return { [`--${name}`]: isScale(value) ? `calc(var(--spacing) * ${value})` : `var(--spacing-${value})` };
|
|
68
|
+
};
|
|
82
69
|
|
|
83
70
|
//#endregion
|
|
84
71
|
//#region src/components/SVG/SVG.tsx
|
|
85
|
-
const SVG = (0, react.forwardRef)(({ size = 24, children, className, color
|
|
72
|
+
const SVG = (0, react.forwardRef)(({ size = 24, children, className, color, ...props }, ref) => {
|
|
86
73
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
87
74
|
...props,
|
|
88
75
|
ref,
|
|
@@ -96,7 +83,7 @@ const SVG = (0, react.forwardRef)(({ size = 24, children, className, color,...pr
|
|
|
96
83
|
|
|
97
84
|
//#endregion
|
|
98
85
|
//#region src/components/Formatters/DateFormat.tsx
|
|
99
|
-
const DateFormat = ({ value, tabular
|
|
86
|
+
const DateFormat = ({ value, tabular, ...props }) => {
|
|
100
87
|
const formatter = (0, __react_aria_i18n.useDateFormatter)({ ...props });
|
|
101
88
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
102
89
|
className: tabular ? "tabular-nums" : "",
|
|
@@ -106,7 +93,7 @@ const DateFormat = ({ value, tabular,...props }) => {
|
|
|
106
93
|
|
|
107
94
|
//#endregion
|
|
108
95
|
//#region src/components/Formatters/NumericFormat.tsx
|
|
109
|
-
const NumericFormat = ({ value, tabular = true
|
|
96
|
+
const NumericFormat = ({ value, tabular = true, ...props }) => {
|
|
110
97
|
const formatter = (0, __react_aria_i18n.useNumberFormatter)({ ...props });
|
|
111
98
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
112
99
|
className: tabular ? "tabular-nums" : void 0,
|
|
@@ -175,6 +162,14 @@ const useClassNames = ({ component, className, variant, size, context: Component
|
|
|
175
162
|
//#endregion
|
|
176
163
|
//#region src/hooks/useResponsiveValue.ts
|
|
177
164
|
/**
|
|
165
|
+
* Based on https://theme-ui.com/packages/match-media/
|
|
166
|
+
*/
|
|
167
|
+
/**
|
|
168
|
+
* Hardcode fallback breakpoints, not make sure `useEffect`
|
|
169
|
+
* doesn't trigger on every render. Since it is part of the
|
|
170
|
+
* dependency array.
|
|
171
|
+
*/
|
|
172
|
+
/**
|
|
178
173
|
* Hook that can be used to return values based on the current screen size,
|
|
179
174
|
* using breakpoints from the theme (`theme.breakpoints`). Note that this
|
|
180
175
|
* hook is client.side only.
|
|
@@ -210,14 +205,14 @@ const toKebap = (val) => val.replace(KEBAB_REGEX, (match) => `-${match.toLocaleL
|
|
|
210
205
|
* (e.g. `[data-hover]` and `[data-focus]`).
|
|
211
206
|
*/
|
|
212
207
|
const useStateProps = (states) => {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
208
|
+
return (0, react.useMemo)(() => {
|
|
209
|
+
const stateProps = {};
|
|
210
|
+
for (const state in states) if (states[state]) {
|
|
211
|
+
const key = `data-${toKebap(state)}`;
|
|
212
|
+
stateProps[key] = "";
|
|
213
|
+
}
|
|
214
|
+
return stateProps;
|
|
215
|
+
}, [states]);
|
|
221
216
|
};
|
|
222
217
|
|
|
223
218
|
//#endregion
|
|
@@ -227,12 +222,11 @@ const useSmallScreen = () => {
|
|
|
227
222
|
if (typeof window == "undefined") return false;
|
|
228
223
|
return window.matchMedia("(max-width: 600px)").matches;
|
|
229
224
|
};
|
|
230
|
-
const [matches, setMatches] = (0, react.useState)(getMatches
|
|
225
|
+
const [matches, setMatches] = (0, react.useState)(getMatches);
|
|
231
226
|
const handleResize = (0, react.useCallback)(() => {
|
|
232
227
|
setMatches(getMatches());
|
|
233
228
|
}, []);
|
|
234
229
|
(0, react.useEffect)(() => {
|
|
235
|
-
handleResize();
|
|
236
230
|
if (typeof window == "undefined") return;
|
|
237
231
|
window.addEventListener("resize", handleResize);
|
|
238
232
|
return () => window.removeEventListener("resize", handleResize);
|
|
@@ -581,8 +575,8 @@ const gapSpace = {
|
|
|
581
575
|
80: "gap-80",
|
|
582
576
|
96: "gap-96",
|
|
583
577
|
section: "gap-[var(--spacing-section)]",
|
|
584
|
-
fieldY: "gap-[var(--spacing-
|
|
585
|
-
fieldX: "gap-[var(--spacing-
|
|
578
|
+
fieldY: "gap-[var(--spacing-fieldY)]",
|
|
579
|
+
fieldX: "gap-[var(--spacing-fieldX)]",
|
|
586
580
|
container: "gap-[var(--spacing-container)]",
|
|
587
581
|
group: "gap-[var(--spacing-group)]"
|
|
588
582
|
};
|
|
@@ -848,7 +842,8 @@ const alignment = {
|
|
|
848
842
|
alignmentX: {
|
|
849
843
|
left: "items-start",
|
|
850
844
|
center: "items-center",
|
|
851
|
-
right: "items-end"
|
|
845
|
+
right: "items-end",
|
|
846
|
+
stretch: "items-stretch"
|
|
852
847
|
},
|
|
853
848
|
alignmentY: {
|
|
854
849
|
top: "justify-start",
|
|
@@ -923,6 +918,25 @@ const cursorStyle = {
|
|
|
923
918
|
zoomOut: "cursor-zoom-out"
|
|
924
919
|
};
|
|
925
920
|
|
|
921
|
+
//#endregion
|
|
922
|
+
//#region src/utils/object.utils.ts
|
|
923
|
+
/**
|
|
924
|
+
* Safely get a dot-notated path within a nested object, with ability
|
|
925
|
+
* to return a default if the full key path does not exist or
|
|
926
|
+
* the value is undefined
|
|
927
|
+
*
|
|
928
|
+
* Based on: https://github.com/developit/dlv
|
|
929
|
+
*/
|
|
930
|
+
const get = (obj, path, fallback) => {
|
|
931
|
+
const key = path.split(".");
|
|
932
|
+
let result = obj;
|
|
933
|
+
for (let i = 0, length = key.length; i < length; i++) {
|
|
934
|
+
if (!result) break;
|
|
935
|
+
result = result[key[i]];
|
|
936
|
+
}
|
|
937
|
+
return result === void 0 ? fallback : result;
|
|
938
|
+
};
|
|
939
|
+
|
|
926
940
|
//#endregion
|
|
927
941
|
exports.DateFormat = DateFormat;
|
|
928
942
|
exports.NumericFormat = NumericFormat;
|
|
@@ -931,6 +945,7 @@ exports.ThemeProvider = ThemeProvider;
|
|
|
931
945
|
exports.alignment = alignment;
|
|
932
946
|
exports.aspect = aspect;
|
|
933
947
|
exports.cn = cn;
|
|
948
|
+
exports.createSpacingVar = createSpacingVar;
|
|
934
949
|
exports.createVar = createVar;
|
|
935
950
|
exports.cursorStyle = cursorStyle;
|
|
936
951
|
exports.cva = cva;
|
|
@@ -941,6 +956,7 @@ exports.fontWeight = fontWeight;
|
|
|
941
956
|
exports.gapSpace = gapSpace;
|
|
942
957
|
exports.get = get;
|
|
943
958
|
exports.height = height;
|
|
959
|
+
exports.isScale = isScale;
|
|
944
960
|
exports.isValidCssCustomPropertyName = isValidCssCustomPropertyName;
|
|
945
961
|
exports.maxWidth = maxWidth;
|
|
946
962
|
exports.paddingBottom = paddingBottom;
|
|
@@ -61,51 +61,21 @@ declare const NumericFormat: ({
|
|
|
61
61
|
...props
|
|
62
62
|
}: NumericFormatProps) => react_jsx_runtime0.JSX.Element;
|
|
63
63
|
//#endregion
|
|
64
|
-
//#region src/utils.d.ts
|
|
64
|
+
//#region src/utils/className.utils.d.ts
|
|
65
65
|
type ConfigSchema = Record<string, Record<string, ClassValue>>;
|
|
66
|
-
type ConfigVariants<T
|
|
67
|
-
type ConfigVariantsMulti<T
|
|
68
|
-
type Config<T
|
|
69
|
-
variants?: T
|
|
70
|
-
defaultVariants?: ConfigVariants<T
|
|
71
|
-
compoundVariants?: (T
|
|
66
|
+
type ConfigVariants<T extends ConfigSchema> = { [Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null | undefined };
|
|
67
|
+
type ConfigVariantsMulti<T extends ConfigSchema> = { [Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | StringToBoolean<keyof T[Variant]>[] | undefined };
|
|
68
|
+
type Config<T> = T extends ConfigSchema ? {
|
|
69
|
+
variants?: T;
|
|
70
|
+
defaultVariants?: ConfigVariants<T>;
|
|
71
|
+
compoundVariants?: (T extends ConfigSchema ? (ConfigVariants<T> | ConfigVariantsMulti<T>) & ClassProp : ClassProp)[];
|
|
72
72
|
} : never;
|
|
73
|
-
type Props<T
|
|
73
|
+
type Props<T> = T extends ConfigSchema ? ConfigVariants<T> & ClassProp : ClassProp;
|
|
74
74
|
declare const cva: <T>(base?: ClassValue, config?: Config<T>) => {
|
|
75
75
|
(props?: Props<T>): string;
|
|
76
76
|
variants: T | undefined;
|
|
77
77
|
};
|
|
78
78
|
declare const cn: (...inputs: ClassValue[]) => string;
|
|
79
|
-
declare const createVar: (o: {
|
|
80
|
-
[key: string]: string | number | undefined;
|
|
81
|
-
}) => CSSProperties;
|
|
82
|
-
/**
|
|
83
|
-
* Safely get a dot-notated path within a nested object, with ability
|
|
84
|
-
* to return a default if the full key path does not exist or
|
|
85
|
-
* the value is undefined
|
|
86
|
-
*
|
|
87
|
-
* Based on: https://github.com/developit/dlv
|
|
88
|
-
*/
|
|
89
|
-
declare const get: (obj: object, path: string, fallback?: any) => any;
|
|
90
|
-
/**
|
|
91
|
-
* Checks if a given string is a valid CSS custom property name (without the leading `--`).
|
|
92
|
-
*
|
|
93
|
-
* This simplified check ensures:
|
|
94
|
-
* - The name does not start with a digit.
|
|
95
|
-
* - It contains only word characters (letters, digits, underscore) or hyphens.
|
|
96
|
-
* - It must include at least one hyphen to be considered a custom property name.
|
|
97
|
-
*/
|
|
98
|
-
declare const isValidCssCustomPropertyName: (val: string) => boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Ensures that the given value is formatted as a CSS variable reference.
|
|
101
|
-
*
|
|
102
|
-
* If the provided value (`val`) is a valid CSS custom property name (without the leading `--`),
|
|
103
|
-
* the function returns a string in the form of `var(--<prefix-if-provided><val>, <val>)`. When a
|
|
104
|
-
* `prefix` is provided, it is prepended to the custom property name with a hyphen.
|
|
105
|
-
*
|
|
106
|
-
* If the value is not a valid custom property name, the function returns the original value.
|
|
107
|
-
*/
|
|
108
|
-
declare const ensureCssVar: (val: string, prefix?: string) => string;
|
|
109
79
|
//#endregion
|
|
110
80
|
//#region src/types/theme.d.ts
|
|
111
81
|
interface NestedStringObject {
|
|
@@ -181,8 +151,8 @@ type Theme = {
|
|
|
181
151
|
};
|
|
182
152
|
};
|
|
183
153
|
type ComponentNames = keyof Theme['components'];
|
|
184
|
-
type ThemeComponent<C
|
|
185
|
-
type ThemeComponentParts<C
|
|
154
|
+
type ThemeComponent<C extends ComponentNames> = NonNullable<Theme['components'][C]>;
|
|
155
|
+
type ThemeComponentParts<C extends ComponentNames> = keyof ThemeComponent<C>;
|
|
186
156
|
//#endregion
|
|
187
157
|
//#region src/hooks/useClassNames.d.ts
|
|
188
158
|
interface ComponentContextProps {
|
|
@@ -190,14 +160,14 @@ interface ComponentContextProps {
|
|
|
190
160
|
variant?: string;
|
|
191
161
|
[key: string]: any;
|
|
192
162
|
}
|
|
193
|
-
interface UseClassNamesProps<C
|
|
194
|
-
component: C
|
|
163
|
+
interface UseClassNamesProps<C extends ComponentNames> {
|
|
164
|
+
component: C;
|
|
195
165
|
variant?: string;
|
|
196
166
|
size?: string;
|
|
197
|
-
className?: ThemeComponent<C
|
|
167
|
+
className?: ThemeComponent<C> extends ((...args: any) => any) ? string : { [slot in keyof ThemeComponent<C>]?: string };
|
|
198
168
|
context?: Context<ComponentContextProps>;
|
|
199
169
|
}
|
|
200
|
-
type ComponentClassNames<C
|
|
170
|
+
type ComponentClassNames<C extends ComponentNames> = ThemeComponent<C> extends ((...args: any) => any) ? string : { [slot in keyof ThemeComponent<C>]: string };
|
|
201
171
|
declare const useClassNames: <C extends ComponentNames>({
|
|
202
172
|
component,
|
|
203
173
|
className,
|
|
@@ -228,11 +198,11 @@ declare const useStateProps: (states: UseStateProps) => StateAttrProps;
|
|
|
228
198
|
//#endregion
|
|
229
199
|
//#region src/hooks/useTheme.d.ts
|
|
230
200
|
declare const useTheme: () => Theme;
|
|
231
|
-
interface ThemeProviderProps<T
|
|
201
|
+
interface ThemeProviderProps<T extends Theme> {
|
|
232
202
|
/**
|
|
233
203
|
* The theme that should be used within the provider context.
|
|
234
204
|
*/
|
|
235
|
-
theme: T
|
|
205
|
+
theme: T;
|
|
236
206
|
/**
|
|
237
207
|
* The children of the component.
|
|
238
208
|
*/
|
|
@@ -242,11 +212,11 @@ interface ThemeProviderProps<T$1 extends Theme> {
|
|
|
242
212
|
*/
|
|
243
213
|
className?: string;
|
|
244
214
|
}
|
|
245
|
-
declare function ThemeProvider<T
|
|
215
|
+
declare function ThemeProvider<T extends Theme>({
|
|
246
216
|
theme,
|
|
247
217
|
children,
|
|
248
218
|
className
|
|
249
|
-
}: ThemeProviderProps<T
|
|
219
|
+
}: ThemeProviderProps<T>): react_jsx_runtime0.JSX.Element;
|
|
250
220
|
//#endregion
|
|
251
221
|
//#region src/hooks/useSmallScreen.d.ts
|
|
252
222
|
declare const useSmallScreen: () => boolean;
|
|
@@ -326,6 +296,76 @@ declare const defaultTheme: {
|
|
|
326
296
|
components: {};
|
|
327
297
|
};
|
|
328
298
|
//#endregion
|
|
299
|
+
//#region src/utils/css-variables.utils.d.ts
|
|
300
|
+
/**
|
|
301
|
+
* Checks if the provided string represents a numeric scale value.
|
|
302
|
+
*
|
|
303
|
+
* A scale value is defined as a string containing only digits,
|
|
304
|
+
* optionally followed by a decimal point and more digits (e.g., "1", "2.5").
|
|
305
|
+
*
|
|
306
|
+
* @param value - The string to test for scale format.
|
|
307
|
+
* @returns `true` if the string is a valid scale value, otherwise `false`.
|
|
308
|
+
*/
|
|
309
|
+
declare const isScale: (value: string) => boolean;
|
|
310
|
+
/**
|
|
311
|
+
* Represents the numeric values found in the default Tailwind CSS spacing scale.
|
|
312
|
+
*
|
|
313
|
+
* Includes:
|
|
314
|
+
* - Fractional steps: 0.5, 1.5, 2.5, 3.5
|
|
315
|
+
* - Integer steps: 0–12
|
|
316
|
+
* - Extended spacing steps: 14, 16, 20... up to 96
|
|
317
|
+
*/
|
|
318
|
+
type ScaleValue = 0 | 0.5 | 1 | 1.5 | 2 | 2.5 | 3 | 3.5 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 72 | 80 | 96;
|
|
319
|
+
/**
|
|
320
|
+
* A strictly typed union of valid Tailwind CSS spacing keys.
|
|
321
|
+
* Accepts both the raw numbers (e.g., `4`, `2.5`) and their string equivalents (e.g., `"4"`, `"2.5"`).
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* const spacing: Scale = 4; // Valid (matches w-4)
|
|
325
|
+
* const padding: Scale = "2.5"; // Valid (matches p-2.5)
|
|
326
|
+
*/
|
|
327
|
+
type Scale = ScaleValue | `${ScaleValue}`;
|
|
328
|
+
/**
|
|
329
|
+
* Checks if a given string is a valid CSS custom property name (without the leading `--`).
|
|
330
|
+
*
|
|
331
|
+
* This simplified check ensures:
|
|
332
|
+
* - The name does not start with a digit.
|
|
333
|
+
* - It contains only word characters (letters, digits, underscore) or hyphens.
|
|
334
|
+
* - It must include at least one hyphen to be considered a custom property name.
|
|
335
|
+
*/
|
|
336
|
+
declare const isValidCssCustomPropertyName: (val: string) => boolean;
|
|
337
|
+
/**
|
|
338
|
+
* Ensures that the given value is formatted as a CSS variable reference.
|
|
339
|
+
*
|
|
340
|
+
* If the provided value (`val`) is a valid CSS custom property name (without the leading `--`),
|
|
341
|
+
* the function returns a string in the form of `var(--<prefix-if-provided><val>, <val>)`. When a
|
|
342
|
+
* `prefix` is provided, it is prepended to the custom property name with a hyphen.
|
|
343
|
+
*
|
|
344
|
+
* If the value is not a valid custom property name, the function returns the original value.
|
|
345
|
+
*/
|
|
346
|
+
declare const ensureCssVar: (val: string, prefix?: string) => string;
|
|
347
|
+
/**
|
|
348
|
+
* Creates a CSS custom properties object from the given key-value pairs.
|
|
349
|
+
*
|
|
350
|
+
* @param o - An object with string keys and string/number/undefined values
|
|
351
|
+
* @returns A CSSProperties object with `--` prefixed keys
|
|
352
|
+
*/
|
|
353
|
+
declare const createVar: (o: {
|
|
354
|
+
[key: string]: string | number | undefined;
|
|
355
|
+
}) => CSSProperties;
|
|
356
|
+
/**
|
|
357
|
+
* Generates a CSS custom property for spacing that uses either a calc expression or a
|
|
358
|
+
* spacing variable reference.
|
|
359
|
+
*
|
|
360
|
+
* If `value` is a number (integer or decimal), uses the `--spacing` scale from Tailwind with calc().
|
|
361
|
+
* Otherwise, references a specific spacing variable (e.g., `--spacing-group`).
|
|
362
|
+
*
|
|
363
|
+
* @param name - The custom property name for spacing.
|
|
364
|
+
* @param value - Spacing value as a string (number or scale key).
|
|
365
|
+
* @returns Object with the CSS custom property for spacing.
|
|
366
|
+
*/
|
|
367
|
+
declare const createSpacingVar: (name: string, value: string) => CSSProperties;
|
|
368
|
+
//#endregion
|
|
329
369
|
//#region src/style-props.d.ts
|
|
330
370
|
declare const width: {
|
|
331
371
|
readonly auto: "w-auto";
|
|
@@ -622,8 +662,8 @@ declare const gapSpace: {
|
|
|
622
662
|
readonly 80: "gap-80";
|
|
623
663
|
readonly 96: "gap-96";
|
|
624
664
|
readonly section: "gap-[var(--spacing-section)]";
|
|
625
|
-
readonly fieldY: "gap-[var(--spacing-
|
|
626
|
-
readonly fieldX: "gap-[var(--spacing-
|
|
665
|
+
readonly fieldY: "gap-[var(--spacing-fieldY)]";
|
|
666
|
+
readonly fieldX: "gap-[var(--spacing-fieldX)]";
|
|
627
667
|
readonly container: "gap-[var(--spacing-container)]";
|
|
628
668
|
readonly group: "gap-[var(--spacing-group)]";
|
|
629
669
|
};
|
|
@@ -890,6 +930,7 @@ declare const alignment: {
|
|
|
890
930
|
readonly left: "items-start";
|
|
891
931
|
readonly center: "items-center";
|
|
892
932
|
readonly right: "items-end";
|
|
933
|
+
readonly stretch: "items-stretch";
|
|
893
934
|
};
|
|
894
935
|
readonly alignmentY: {
|
|
895
936
|
readonly top: "justify-start";
|
|
@@ -1092,5 +1133,26 @@ type HeightProp = {
|
|
|
1092
1133
|
*/
|
|
1093
1134
|
height?: keyof typeof height;
|
|
1094
1135
|
};
|
|
1136
|
+
/**
|
|
1137
|
+
* Defines spacing properties for managing space between child elements.
|
|
1138
|
+
* @template T - A string type parameter that allows extending the base spacing
|
|
1139
|
+
* scale with custom values. Defaults to an empty string.
|
|
1140
|
+
*/
|
|
1141
|
+
type SpaceProp<T extends string = ''> = {
|
|
1142
|
+
/**
|
|
1143
|
+
* Set the spacing between child elements.
|
|
1144
|
+
*/
|
|
1145
|
+
space?: Scale | T;
|
|
1146
|
+
};
|
|
1147
|
+
//#endregion
|
|
1148
|
+
//#region src/utils/object.utils.d.ts
|
|
1149
|
+
/**
|
|
1150
|
+
* Safely get a dot-notated path within a nested object, with ability
|
|
1151
|
+
* to return a default if the full key path does not exist or
|
|
1152
|
+
* the value is undefined
|
|
1153
|
+
*
|
|
1154
|
+
* Based on: https://github.com/developit/dlv
|
|
1155
|
+
*/
|
|
1156
|
+
declare const get: (obj: object, path: string, fallback?: any) => any;
|
|
1095
1157
|
//#endregion
|
|
1096
|
-
export { type AlignmentProp, type AspectProp, 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 HeightProp, type MaxWidthProp, type NestedStringObject, type NumerFormatterOptions, NumericFormat, 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 TextWrapProp, type Theme, type ThemeComponent, type ThemeComponentParts, ThemeProvider, type ThemeProviderProps, type UseClassNamesProps, type UseStateProps, type VariantProps, type WhiteSpaceProps, type WidthProp, alignment, aspect, cn, createVar, cursorStyle, cva, defaultTheme, ensureCssVar, extendTheme, fontWeight, gapSpace, get, height, isValidCssCustomPropertyName, maxWidth, paddingBottom, paddingLeft, paddingRight, paddingSpace, paddingSpaceX, paddingSpaceY, paddingTop, placeItems, textAlign, textSize, textStyle, textWrap, useClassNames, useResponsiveValue, useSmallScreen, useStateProps, useTheme, whiteSpace, width };
|
|
1158
|
+
export { type AlignmentProp, type AspectProp, 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 HeightProp, type MaxWidthProp, type NestedStringObject, type NumerFormatterOptions, NumericFormat, type PaddingBottomProp, type PaddingLeftProp, type PaddingRightProp, type PaddingSpaceProp, type PaddingSpacePropX, type PaddingSpacePropY, type PaddingTopProp, type PlaceItemsProp, type Props, SVG, type SVGProps, type Scale, type ScaleValue, type SpaceProp, type StateAttrKeyProps, type StateAttrProps, type StylesProps, type TextAlignProp, type TextWrapProp, type Theme, type ThemeComponent, type ThemeComponentParts, ThemeProvider, type ThemeProviderProps, type UseClassNamesProps, type UseStateProps, type VariantProps, type WhiteSpaceProps, type WidthProp, alignment, aspect, cn, createSpacingVar, createVar, cursorStyle, cva, defaultTheme, ensureCssVar, extendTheme, fontWeight, gapSpace, get, height, isScale, isValidCssCustomPropertyName, maxWidth, paddingBottom, paddingLeft, paddingRight, paddingSpace, paddingSpaceX, paddingSpaceY, paddingTop, placeItems, textAlign, textSize, textStyle, textWrap, useClassNames, useResponsiveValue, useSmallScreen, useStateProps, useTheme, whiteSpace, width };
|
package/dist/index.d.mts
CHANGED
|
@@ -61,51 +61,21 @@ declare const NumericFormat: ({
|
|
|
61
61
|
...props
|
|
62
62
|
}: NumericFormatProps) => react_jsx_runtime0.JSX.Element;
|
|
63
63
|
//#endregion
|
|
64
|
-
//#region src/utils.d.ts
|
|
64
|
+
//#region src/utils/className.utils.d.ts
|
|
65
65
|
type ConfigSchema = Record<string, Record<string, ClassValue>>;
|
|
66
|
-
type ConfigVariants<T
|
|
67
|
-
type ConfigVariantsMulti<T
|
|
68
|
-
type Config<T
|
|
69
|
-
variants?: T
|
|
70
|
-
defaultVariants?: ConfigVariants<T
|
|
71
|
-
compoundVariants?: (T
|
|
66
|
+
type ConfigVariants<T extends ConfigSchema> = { [Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null | undefined };
|
|
67
|
+
type ConfigVariantsMulti<T extends ConfigSchema> = { [Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | StringToBoolean<keyof T[Variant]>[] | undefined };
|
|
68
|
+
type Config<T> = T extends ConfigSchema ? {
|
|
69
|
+
variants?: T;
|
|
70
|
+
defaultVariants?: ConfigVariants<T>;
|
|
71
|
+
compoundVariants?: (T extends ConfigSchema ? (ConfigVariants<T> | ConfigVariantsMulti<T>) & ClassProp : ClassProp)[];
|
|
72
72
|
} : never;
|
|
73
|
-
type Props<T
|
|
73
|
+
type Props<T> = T extends ConfigSchema ? ConfigVariants<T> & ClassProp : ClassProp;
|
|
74
74
|
declare const cva: <T>(base?: ClassValue, config?: Config<T>) => {
|
|
75
75
|
(props?: Props<T>): string;
|
|
76
76
|
variants: T | undefined;
|
|
77
77
|
};
|
|
78
78
|
declare const cn: (...inputs: ClassValue[]) => string;
|
|
79
|
-
declare const createVar: (o: {
|
|
80
|
-
[key: string]: string | number | undefined;
|
|
81
|
-
}) => CSSProperties;
|
|
82
|
-
/**
|
|
83
|
-
* Safely get a dot-notated path within a nested object, with ability
|
|
84
|
-
* to return a default if the full key path does not exist or
|
|
85
|
-
* the value is undefined
|
|
86
|
-
*
|
|
87
|
-
* Based on: https://github.com/developit/dlv
|
|
88
|
-
*/
|
|
89
|
-
declare const get: (obj: object, path: string, fallback?: any) => any;
|
|
90
|
-
/**
|
|
91
|
-
* Checks if a given string is a valid CSS custom property name (without the leading `--`).
|
|
92
|
-
*
|
|
93
|
-
* This simplified check ensures:
|
|
94
|
-
* - The name does not start with a digit.
|
|
95
|
-
* - It contains only word characters (letters, digits, underscore) or hyphens.
|
|
96
|
-
* - It must include at least one hyphen to be considered a custom property name.
|
|
97
|
-
*/
|
|
98
|
-
declare const isValidCssCustomPropertyName: (val: string) => boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Ensures that the given value is formatted as a CSS variable reference.
|
|
101
|
-
*
|
|
102
|
-
* If the provided value (`val`) is a valid CSS custom property name (without the leading `--`),
|
|
103
|
-
* the function returns a string in the form of `var(--<prefix-if-provided><val>, <val>)`. When a
|
|
104
|
-
* `prefix` is provided, it is prepended to the custom property name with a hyphen.
|
|
105
|
-
*
|
|
106
|
-
* If the value is not a valid custom property name, the function returns the original value.
|
|
107
|
-
*/
|
|
108
|
-
declare const ensureCssVar: (val: string, prefix?: string) => string;
|
|
109
79
|
//#endregion
|
|
110
80
|
//#region src/types/theme.d.ts
|
|
111
81
|
interface NestedStringObject {
|
|
@@ -181,8 +151,8 @@ type Theme = {
|
|
|
181
151
|
};
|
|
182
152
|
};
|
|
183
153
|
type ComponentNames = keyof Theme['components'];
|
|
184
|
-
type ThemeComponent<C
|
|
185
|
-
type ThemeComponentParts<C
|
|
154
|
+
type ThemeComponent<C extends ComponentNames> = NonNullable<Theme['components'][C]>;
|
|
155
|
+
type ThemeComponentParts<C extends ComponentNames> = keyof ThemeComponent<C>;
|
|
186
156
|
//#endregion
|
|
187
157
|
//#region src/hooks/useClassNames.d.ts
|
|
188
158
|
interface ComponentContextProps {
|
|
@@ -190,14 +160,14 @@ interface ComponentContextProps {
|
|
|
190
160
|
variant?: string;
|
|
191
161
|
[key: string]: any;
|
|
192
162
|
}
|
|
193
|
-
interface UseClassNamesProps<C
|
|
194
|
-
component: C
|
|
163
|
+
interface UseClassNamesProps<C extends ComponentNames> {
|
|
164
|
+
component: C;
|
|
195
165
|
variant?: string;
|
|
196
166
|
size?: string;
|
|
197
|
-
className?: ThemeComponent<C
|
|
167
|
+
className?: ThemeComponent<C> extends ((...args: any) => any) ? string : { [slot in keyof ThemeComponent<C>]?: string };
|
|
198
168
|
context?: Context<ComponentContextProps>;
|
|
199
169
|
}
|
|
200
|
-
type ComponentClassNames<C
|
|
170
|
+
type ComponentClassNames<C extends ComponentNames> = ThemeComponent<C> extends ((...args: any) => any) ? string : { [slot in keyof ThemeComponent<C>]: string };
|
|
201
171
|
declare const useClassNames: <C extends ComponentNames>({
|
|
202
172
|
component,
|
|
203
173
|
className,
|
|
@@ -228,11 +198,11 @@ declare const useStateProps: (states: UseStateProps) => StateAttrProps;
|
|
|
228
198
|
//#endregion
|
|
229
199
|
//#region src/hooks/useTheme.d.ts
|
|
230
200
|
declare const useTheme: () => Theme;
|
|
231
|
-
interface ThemeProviderProps<T
|
|
201
|
+
interface ThemeProviderProps<T extends Theme> {
|
|
232
202
|
/**
|
|
233
203
|
* The theme that should be used within the provider context.
|
|
234
204
|
*/
|
|
235
|
-
theme: T
|
|
205
|
+
theme: T;
|
|
236
206
|
/**
|
|
237
207
|
* The children of the component.
|
|
238
208
|
*/
|
|
@@ -242,11 +212,11 @@ interface ThemeProviderProps<T$1 extends Theme> {
|
|
|
242
212
|
*/
|
|
243
213
|
className?: string;
|
|
244
214
|
}
|
|
245
|
-
declare function ThemeProvider<T
|
|
215
|
+
declare function ThemeProvider<T extends Theme>({
|
|
246
216
|
theme,
|
|
247
217
|
children,
|
|
248
218
|
className
|
|
249
|
-
}: ThemeProviderProps<T
|
|
219
|
+
}: ThemeProviderProps<T>): react_jsx_runtime0.JSX.Element;
|
|
250
220
|
//#endregion
|
|
251
221
|
//#region src/hooks/useSmallScreen.d.ts
|
|
252
222
|
declare const useSmallScreen: () => boolean;
|
|
@@ -326,6 +296,76 @@ declare const defaultTheme: {
|
|
|
326
296
|
components: {};
|
|
327
297
|
};
|
|
328
298
|
//#endregion
|
|
299
|
+
//#region src/utils/css-variables.utils.d.ts
|
|
300
|
+
/**
|
|
301
|
+
* Checks if the provided string represents a numeric scale value.
|
|
302
|
+
*
|
|
303
|
+
* A scale value is defined as a string containing only digits,
|
|
304
|
+
* optionally followed by a decimal point and more digits (e.g., "1", "2.5").
|
|
305
|
+
*
|
|
306
|
+
* @param value - The string to test for scale format.
|
|
307
|
+
* @returns `true` if the string is a valid scale value, otherwise `false`.
|
|
308
|
+
*/
|
|
309
|
+
declare const isScale: (value: string) => boolean;
|
|
310
|
+
/**
|
|
311
|
+
* Represents the numeric values found in the default Tailwind CSS spacing scale.
|
|
312
|
+
*
|
|
313
|
+
* Includes:
|
|
314
|
+
* - Fractional steps: 0.5, 1.5, 2.5, 3.5
|
|
315
|
+
* - Integer steps: 0–12
|
|
316
|
+
* - Extended spacing steps: 14, 16, 20... up to 96
|
|
317
|
+
*/
|
|
318
|
+
type ScaleValue = 0 | 0.5 | 1 | 1.5 | 2 | 2.5 | 3 | 3.5 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 72 | 80 | 96;
|
|
319
|
+
/**
|
|
320
|
+
* A strictly typed union of valid Tailwind CSS spacing keys.
|
|
321
|
+
* Accepts both the raw numbers (e.g., `4`, `2.5`) and their string equivalents (e.g., `"4"`, `"2.5"`).
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* const spacing: Scale = 4; // Valid (matches w-4)
|
|
325
|
+
* const padding: Scale = "2.5"; // Valid (matches p-2.5)
|
|
326
|
+
*/
|
|
327
|
+
type Scale = ScaleValue | `${ScaleValue}`;
|
|
328
|
+
/**
|
|
329
|
+
* Checks if a given string is a valid CSS custom property name (without the leading `--`).
|
|
330
|
+
*
|
|
331
|
+
* This simplified check ensures:
|
|
332
|
+
* - The name does not start with a digit.
|
|
333
|
+
* - It contains only word characters (letters, digits, underscore) or hyphens.
|
|
334
|
+
* - It must include at least one hyphen to be considered a custom property name.
|
|
335
|
+
*/
|
|
336
|
+
declare const isValidCssCustomPropertyName: (val: string) => boolean;
|
|
337
|
+
/**
|
|
338
|
+
* Ensures that the given value is formatted as a CSS variable reference.
|
|
339
|
+
*
|
|
340
|
+
* If the provided value (`val`) is a valid CSS custom property name (without the leading `--`),
|
|
341
|
+
* the function returns a string in the form of `var(--<prefix-if-provided><val>, <val>)`. When a
|
|
342
|
+
* `prefix` is provided, it is prepended to the custom property name with a hyphen.
|
|
343
|
+
*
|
|
344
|
+
* If the value is not a valid custom property name, the function returns the original value.
|
|
345
|
+
*/
|
|
346
|
+
declare const ensureCssVar: (val: string, prefix?: string) => string;
|
|
347
|
+
/**
|
|
348
|
+
* Creates a CSS custom properties object from the given key-value pairs.
|
|
349
|
+
*
|
|
350
|
+
* @param o - An object with string keys and string/number/undefined values
|
|
351
|
+
* @returns A CSSProperties object with `--` prefixed keys
|
|
352
|
+
*/
|
|
353
|
+
declare const createVar: (o: {
|
|
354
|
+
[key: string]: string | number | undefined;
|
|
355
|
+
}) => CSSProperties;
|
|
356
|
+
/**
|
|
357
|
+
* Generates a CSS custom property for spacing that uses either a calc expression or a
|
|
358
|
+
* spacing variable reference.
|
|
359
|
+
*
|
|
360
|
+
* If `value` is a number (integer or decimal), uses the `--spacing` scale from Tailwind with calc().
|
|
361
|
+
* Otherwise, references a specific spacing variable (e.g., `--spacing-group`).
|
|
362
|
+
*
|
|
363
|
+
* @param name - The custom property name for spacing.
|
|
364
|
+
* @param value - Spacing value as a string (number or scale key).
|
|
365
|
+
* @returns Object with the CSS custom property for spacing.
|
|
366
|
+
*/
|
|
367
|
+
declare const createSpacingVar: (name: string, value: string) => CSSProperties;
|
|
368
|
+
//#endregion
|
|
329
369
|
//#region src/style-props.d.ts
|
|
330
370
|
declare const width: {
|
|
331
371
|
readonly auto: "w-auto";
|
|
@@ -622,8 +662,8 @@ declare const gapSpace: {
|
|
|
622
662
|
readonly 80: "gap-80";
|
|
623
663
|
readonly 96: "gap-96";
|
|
624
664
|
readonly section: "gap-[var(--spacing-section)]";
|
|
625
|
-
readonly fieldY: "gap-[var(--spacing-
|
|
626
|
-
readonly fieldX: "gap-[var(--spacing-
|
|
665
|
+
readonly fieldY: "gap-[var(--spacing-fieldY)]";
|
|
666
|
+
readonly fieldX: "gap-[var(--spacing-fieldX)]";
|
|
627
667
|
readonly container: "gap-[var(--spacing-container)]";
|
|
628
668
|
readonly group: "gap-[var(--spacing-group)]";
|
|
629
669
|
};
|
|
@@ -890,6 +930,7 @@ declare const alignment: {
|
|
|
890
930
|
readonly left: "items-start";
|
|
891
931
|
readonly center: "items-center";
|
|
892
932
|
readonly right: "items-end";
|
|
933
|
+
readonly stretch: "items-stretch";
|
|
893
934
|
};
|
|
894
935
|
readonly alignmentY: {
|
|
895
936
|
readonly top: "justify-start";
|
|
@@ -1092,5 +1133,26 @@ type HeightProp = {
|
|
|
1092
1133
|
*/
|
|
1093
1134
|
height?: keyof typeof height;
|
|
1094
1135
|
};
|
|
1136
|
+
/**
|
|
1137
|
+
* Defines spacing properties for managing space between child elements.
|
|
1138
|
+
* @template T - A string type parameter that allows extending the base spacing
|
|
1139
|
+
* scale with custom values. Defaults to an empty string.
|
|
1140
|
+
*/
|
|
1141
|
+
type SpaceProp<T extends string = ''> = {
|
|
1142
|
+
/**
|
|
1143
|
+
* Set the spacing between child elements.
|
|
1144
|
+
*/
|
|
1145
|
+
space?: Scale | T;
|
|
1146
|
+
};
|
|
1147
|
+
//#endregion
|
|
1148
|
+
//#region src/utils/object.utils.d.ts
|
|
1149
|
+
/**
|
|
1150
|
+
* Safely get a dot-notated path within a nested object, with ability
|
|
1151
|
+
* to return a default if the full key path does not exist or
|
|
1152
|
+
* the value is undefined
|
|
1153
|
+
*
|
|
1154
|
+
* Based on: https://github.com/developit/dlv
|
|
1155
|
+
*/
|
|
1156
|
+
declare const get: (obj: object, path: string, fallback?: any) => any;
|
|
1095
1157
|
//#endregion
|
|
1096
|
-
export { type AlignmentProp, type AspectProp, 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 HeightProp, type MaxWidthProp, type NestedStringObject, type NumerFormatterOptions, NumericFormat, 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 TextWrapProp, type Theme, type ThemeComponent, type ThemeComponentParts, ThemeProvider, type ThemeProviderProps, type UseClassNamesProps, type UseStateProps, type VariantProps, type WhiteSpaceProps, type WidthProp, alignment, aspect, cn, createVar, cursorStyle, cva, defaultTheme, ensureCssVar, extendTheme, fontWeight, gapSpace, get, height, isValidCssCustomPropertyName, maxWidth, paddingBottom, paddingLeft, paddingRight, paddingSpace, paddingSpaceX, paddingSpaceY, paddingTop, placeItems, textAlign, textSize, textStyle, textWrap, useClassNames, useResponsiveValue, useSmallScreen, useStateProps, useTheme, whiteSpace, width };
|
|
1158
|
+
export { type AlignmentProp, type AspectProp, 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 HeightProp, type MaxWidthProp, type NestedStringObject, type NumerFormatterOptions, NumericFormat, type PaddingBottomProp, type PaddingLeftProp, type PaddingRightProp, type PaddingSpaceProp, type PaddingSpacePropX, type PaddingSpacePropY, type PaddingTopProp, type PlaceItemsProp, type Props, SVG, type SVGProps, type Scale, type ScaleValue, type SpaceProp, type StateAttrKeyProps, type StateAttrProps, type StylesProps, type TextAlignProp, type TextWrapProp, type Theme, type ThemeComponent, type ThemeComponentParts, ThemeProvider, type ThemeProviderProps, type UseClassNamesProps, type UseStateProps, type VariantProps, type WhiteSpaceProps, type WidthProp, alignment, aspect, cn, createSpacingVar, createVar, cursorStyle, cva, defaultTheme, ensureCssVar, extendTheme, fontWeight, gapSpace, get, height, isScale, isValidCssCustomPropertyName, maxWidth, paddingBottom, paddingLeft, paddingRight, paddingSpace, paddingSpaceX, paddingSpaceY, paddingTop, placeItems, textAlign, textSize, textStyle, textWrap, useClassNames, useResponsiveValue, useSmallScreen, useStateProps, useTheme, whiteSpace, width };
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { createContext, forwardRef, useCallback, useContext, useEffect,
|
|
1
|
+
import { createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { cva as cva$1, cx } from "class-variance-authority";
|
|
3
3
|
import { twMerge } from "tailwind-merge";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { useDateFormatter, useNumberFormatter } from "@react-aria/i18n";
|
|
6
|
-
import isEqual from "react-fast-compare";
|
|
7
6
|
|
|
8
|
-
//#region src/utils.ts
|
|
7
|
+
//#region src/utils/className.utils.ts
|
|
9
8
|
const cva = (base, config) => {
|
|
10
9
|
function styles(props) {
|
|
11
10
|
return twMerge(cva$1(base, config)(props));
|
|
@@ -14,23 +13,19 @@ const cva = (base, config) => {
|
|
|
14
13
|
return styles;
|
|
15
14
|
};
|
|
16
15
|
const cn = (...inputs) => twMerge(cx(inputs));
|
|
17
|
-
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/utils/css-variables.utils.ts
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
-
* to return a default if the full key path does not exist or
|
|
21
|
-
* the value is undefined
|
|
20
|
+
* Checks if the provided string represents a numeric scale value.
|
|
22
21
|
*
|
|
23
|
-
*
|
|
22
|
+
* A scale value is defined as a string containing only digits,
|
|
23
|
+
* optionally followed by a decimal point and more digits (e.g., "1", "2.5").
|
|
24
|
+
*
|
|
25
|
+
* @param value - The string to test for scale format.
|
|
26
|
+
* @returns `true` if the string is a valid scale value, otherwise `false`.
|
|
24
27
|
*/
|
|
25
|
-
const
|
|
26
|
-
const key = path.split(".");
|
|
27
|
-
let result = obj;
|
|
28
|
-
for (let i = 0, length = key.length; i < length; i++) {
|
|
29
|
-
if (!result) break;
|
|
30
|
-
result = result[key[i]];
|
|
31
|
-
}
|
|
32
|
-
return result === void 0 ? fallback : result;
|
|
33
|
-
};
|
|
28
|
+
const isScale = (value) => /^[0-9]+(\.[0-9]+)?$/.test(value);
|
|
34
29
|
/**
|
|
35
30
|
* Checks if a given string is a valid CSS custom property name (without the leading `--`).
|
|
36
31
|
*
|
|
@@ -50,10 +45,31 @@ const isValidCssCustomPropertyName = (val) => /^[A-Za-z0-9_-]+$/.test(val);
|
|
|
50
45
|
* If the value is not a valid custom property name, the function returns the original value.
|
|
51
46
|
*/
|
|
52
47
|
const ensureCssVar = (val, prefix) => isValidCssCustomPropertyName(val) ? `var(--${prefix ? `${prefix}-` : ""}${val}, ${val})` : val;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a CSS custom properties object from the given key-value pairs.
|
|
50
|
+
*
|
|
51
|
+
* @param o - An object with string keys and string/number/undefined values
|
|
52
|
+
* @returns A CSSProperties object with `--` prefixed keys
|
|
53
|
+
*/
|
|
54
|
+
const createVar = (o) => Object.fromEntries(Object.entries(o).map(([name, val]) => [`--${name}`, val]));
|
|
55
|
+
/**
|
|
56
|
+
* Generates a CSS custom property for spacing that uses either a calc expression or a
|
|
57
|
+
* spacing variable reference.
|
|
58
|
+
*
|
|
59
|
+
* If `value` is a number (integer or decimal), uses the `--spacing` scale from Tailwind with calc().
|
|
60
|
+
* Otherwise, references a specific spacing variable (e.g., `--spacing-group`).
|
|
61
|
+
*
|
|
62
|
+
* @param name - The custom property name for spacing.
|
|
63
|
+
* @param value - Spacing value as a string (number or scale key).
|
|
64
|
+
* @returns Object with the CSS custom property for spacing.
|
|
65
|
+
*/
|
|
66
|
+
const createSpacingVar = (name, value) => {
|
|
67
|
+
return { [`--${name}`]: isScale(value) ? `calc(var(--spacing) * ${value})` : `var(--spacing-${value})` };
|
|
68
|
+
};
|
|
53
69
|
|
|
54
70
|
//#endregion
|
|
55
71
|
//#region src/components/SVG/SVG.tsx
|
|
56
|
-
const SVG = forwardRef(({ size = 24, children, className, color
|
|
72
|
+
const SVG = forwardRef(({ size = 24, children, className, color, ...props }, ref) => {
|
|
57
73
|
return /* @__PURE__ */ jsx("svg", {
|
|
58
74
|
...props,
|
|
59
75
|
ref,
|
|
@@ -67,7 +83,7 @@ const SVG = forwardRef(({ size = 24, children, className, color,...props }, ref)
|
|
|
67
83
|
|
|
68
84
|
//#endregion
|
|
69
85
|
//#region src/components/Formatters/DateFormat.tsx
|
|
70
|
-
const DateFormat = ({ value, tabular
|
|
86
|
+
const DateFormat = ({ value, tabular, ...props }) => {
|
|
71
87
|
const formatter = useDateFormatter({ ...props });
|
|
72
88
|
return /* @__PURE__ */ jsx("span", {
|
|
73
89
|
className: tabular ? "tabular-nums" : "",
|
|
@@ -77,7 +93,7 @@ const DateFormat = ({ value, tabular,...props }) => {
|
|
|
77
93
|
|
|
78
94
|
//#endregion
|
|
79
95
|
//#region src/components/Formatters/NumericFormat.tsx
|
|
80
|
-
const NumericFormat = ({ value, tabular = true
|
|
96
|
+
const NumericFormat = ({ value, tabular = true, ...props }) => {
|
|
81
97
|
const formatter = useNumberFormatter({ ...props });
|
|
82
98
|
return /* @__PURE__ */ jsx("span", {
|
|
83
99
|
className: tabular ? "tabular-nums" : void 0,
|
|
@@ -146,6 +162,14 @@ const useClassNames = ({ component, className, variant, size, context: Component
|
|
|
146
162
|
//#endregion
|
|
147
163
|
//#region src/hooks/useResponsiveValue.ts
|
|
148
164
|
/**
|
|
165
|
+
* Based on https://theme-ui.com/packages/match-media/
|
|
166
|
+
*/
|
|
167
|
+
/**
|
|
168
|
+
* Hardcode fallback breakpoints, not make sure `useEffect`
|
|
169
|
+
* doesn't trigger on every render. Since it is part of the
|
|
170
|
+
* dependency array.
|
|
171
|
+
*/
|
|
172
|
+
/**
|
|
149
173
|
* Hook that can be used to return values based on the current screen size,
|
|
150
174
|
* using breakpoints from the theme (`theme.breakpoints`). Note that this
|
|
151
175
|
* hook is client.side only.
|
|
@@ -181,14 +205,14 @@ const toKebap = (val) => val.replace(KEBAB_REGEX, (match) => `-${match.toLocaleL
|
|
|
181
205
|
* (e.g. `[data-hover]` and `[data-focus]`).
|
|
182
206
|
*/
|
|
183
207
|
const useStateProps = (states) => {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
208
|
+
return useMemo(() => {
|
|
209
|
+
const stateProps = {};
|
|
210
|
+
for (const state in states) if (states[state]) {
|
|
211
|
+
const key = `data-${toKebap(state)}`;
|
|
212
|
+
stateProps[key] = "";
|
|
213
|
+
}
|
|
214
|
+
return stateProps;
|
|
215
|
+
}, [states]);
|
|
192
216
|
};
|
|
193
217
|
|
|
194
218
|
//#endregion
|
|
@@ -198,12 +222,11 @@ const useSmallScreen = () => {
|
|
|
198
222
|
if (typeof window == "undefined") return false;
|
|
199
223
|
return window.matchMedia("(max-width: 600px)").matches;
|
|
200
224
|
};
|
|
201
|
-
const [matches, setMatches] = useState(getMatches
|
|
225
|
+
const [matches, setMatches] = useState(getMatches);
|
|
202
226
|
const handleResize = useCallback(() => {
|
|
203
227
|
setMatches(getMatches());
|
|
204
228
|
}, []);
|
|
205
229
|
useEffect(() => {
|
|
206
|
-
handleResize();
|
|
207
230
|
if (typeof window == "undefined") return;
|
|
208
231
|
window.addEventListener("resize", handleResize);
|
|
209
232
|
return () => window.removeEventListener("resize", handleResize);
|
|
@@ -552,8 +575,8 @@ const gapSpace = {
|
|
|
552
575
|
80: "gap-80",
|
|
553
576
|
96: "gap-96",
|
|
554
577
|
section: "gap-[var(--spacing-section)]",
|
|
555
|
-
fieldY: "gap-[var(--spacing-
|
|
556
|
-
fieldX: "gap-[var(--spacing-
|
|
578
|
+
fieldY: "gap-[var(--spacing-fieldY)]",
|
|
579
|
+
fieldX: "gap-[var(--spacing-fieldX)]",
|
|
557
580
|
container: "gap-[var(--spacing-container)]",
|
|
558
581
|
group: "gap-[var(--spacing-group)]"
|
|
559
582
|
};
|
|
@@ -819,7 +842,8 @@ const alignment = {
|
|
|
819
842
|
alignmentX: {
|
|
820
843
|
left: "items-start",
|
|
821
844
|
center: "items-center",
|
|
822
|
-
right: "items-end"
|
|
845
|
+
right: "items-end",
|
|
846
|
+
stretch: "items-stretch"
|
|
823
847
|
},
|
|
824
848
|
alignmentY: {
|
|
825
849
|
top: "justify-start",
|
|
@@ -895,4 +919,23 @@ const cursorStyle = {
|
|
|
895
919
|
};
|
|
896
920
|
|
|
897
921
|
//#endregion
|
|
898
|
-
|
|
922
|
+
//#region src/utils/object.utils.ts
|
|
923
|
+
/**
|
|
924
|
+
* Safely get a dot-notated path within a nested object, with ability
|
|
925
|
+
* to return a default if the full key path does not exist or
|
|
926
|
+
* the value is undefined
|
|
927
|
+
*
|
|
928
|
+
* Based on: https://github.com/developit/dlv
|
|
929
|
+
*/
|
|
930
|
+
const get = (obj, path, fallback) => {
|
|
931
|
+
const key = path.split(".");
|
|
932
|
+
let result = obj;
|
|
933
|
+
for (let i = 0, length = key.length; i < length; i++) {
|
|
934
|
+
if (!result) break;
|
|
935
|
+
result = result[key[i]];
|
|
936
|
+
}
|
|
937
|
+
return result === void 0 ? fallback : result;
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
//#endregion
|
|
941
|
+
export { DateFormat, NumericFormat, SVG, ThemeProvider, alignment, aspect, cn, createSpacingVar, createVar, cursorStyle, cva, defaultTheme, ensureCssVar, extendTheme, fontWeight, gapSpace, get, height, isScale, isValidCssCustomPropertyName, maxWidth, paddingBottom, paddingLeft, paddingRight, paddingSpace, paddingSpaceX, paddingSpaceY, paddingTop, placeItems, textAlign, textSize, textStyle, textWrap, useClassNames, useResponsiveValue, useSmallScreen, useStateProps, useTheme, whiteSpace, width };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marigold/system",
|
|
3
|
-
"version": "16.0
|
|
3
|
+
"version": "16.1.0",
|
|
4
4
|
"description": "Marigold System Library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"postcss": "8.5.6",
|
|
52
52
|
"react": "19.2.0",
|
|
53
53
|
"tailwindcss": "4.1.17",
|
|
54
|
-
"tsdown": "0.
|
|
54
|
+
"tsdown": "0.16.8",
|
|
55
55
|
"@marigold/tsconfig": "0.4.2"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|