@marigold/system 16.0.1 → 17.0.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} +129 -62
- package/dist/{index.d.ts → index.d.cts} +198 -64
- package/dist/index.d.mts +198 -64
- package/dist/index.mjs +125 -35
- package/package.json +7 -7
|
@@ -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,26 @@ 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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
28
|
+
const isScale = (value) => /^[0-9]+(\.[0-9]+)?$/.test(value);
|
|
29
|
+
/**
|
|
30
|
+
* Checks if a value represents a fraction (e.g., "1/2", "2/3").
|
|
31
|
+
*
|
|
32
|
+
* @param value - The string to test for fraction format.
|
|
33
|
+
* @returns `true` if the string is a valid fraction, otherwise `false`.
|
|
34
|
+
*/
|
|
35
|
+
const isFraction = (value) => /^[0-9]+\/[0-9]+$/.test(value);
|
|
63
36
|
/**
|
|
64
37
|
* Checks if a given string is a valid CSS custom property name (without the leading `--`).
|
|
65
38
|
*
|
|
@@ -79,10 +52,58 @@ const isValidCssCustomPropertyName = (val) => /^[A-Za-z0-9_-]+$/.test(val);
|
|
|
79
52
|
* If the value is not a valid custom property name, the function returns the original value.
|
|
80
53
|
*/
|
|
81
54
|
const ensureCssVar = (val, prefix) => isValidCssCustomPropertyName(val) ? `var(--${prefix ? `${prefix}-` : ""}${val}, ${val})` : val;
|
|
55
|
+
/**
|
|
56
|
+
* Creates a CSS custom properties object from the given key-value pairs.
|
|
57
|
+
*
|
|
58
|
+
* @param o - An object with string keys and string/number/undefined values
|
|
59
|
+
* @returns A CSSProperties object with `--` prefixed keys
|
|
60
|
+
*/
|
|
61
|
+
const createVar = (o) => Object.fromEntries(Object.entries(o).map(([name, val]) => [`--${name}`, val]));
|
|
62
|
+
/**
|
|
63
|
+
* Generates a CSS custom property for spacing that uses either a calc expression or a
|
|
64
|
+
* spacing variable reference.
|
|
65
|
+
*
|
|
66
|
+
* If `value` is a number (integer or decimal), uses the `--spacing` scale from Tailwind with calc().
|
|
67
|
+
* Otherwise, references a specific spacing variable (e.g., `--spacing-group`).
|
|
68
|
+
*
|
|
69
|
+
* @param name - The custom property name for spacing.
|
|
70
|
+
* @param value - Spacing value as a string (number or scale key).
|
|
71
|
+
* @returns Object with the CSS custom property for spacing.
|
|
72
|
+
*/
|
|
73
|
+
const createSpacingVar = (name, value) => {
|
|
74
|
+
return { [`--${name}`]: isScale(value) ? `calc(var(--spacing) * ${value})` : `var(--spacing-${value})` };
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Generates a CSS custom property for width that uses either a calc expression or a
|
|
78
|
+
* fraction percentage.
|
|
79
|
+
*
|
|
80
|
+
* Supports:
|
|
81
|
+
* - Numeric scale (e.g., "4", "2.5"): Uses `--spacing` scale with calc() → `w-4`, `w-2.5`
|
|
82
|
+
* - Fractions (e.g., "1/2", "2/3"): Converts to percentage → `w-1/2`, `w-2/3`
|
|
83
|
+
* - CSS keywords (e.g., "fit", "min", "max"): Uses corresponding CSS values → `w-fit`, `w-min`, `w-max`
|
|
84
|
+
*
|
|
85
|
+
* @param name - The custom property name for width.
|
|
86
|
+
* @param value - Width value as a string (number, fraction, or keyword).
|
|
87
|
+
* @returns Object with the CSS custom property for width.
|
|
88
|
+
*
|
|
89
|
+
*/
|
|
90
|
+
const createWidthVar = (name, value) => {
|
|
91
|
+
const widthKeywords = {
|
|
92
|
+
fit: "fit-content",
|
|
93
|
+
min: "min-content",
|
|
94
|
+
max: "max-content",
|
|
95
|
+
full: "100%",
|
|
96
|
+
screen: "100vw",
|
|
97
|
+
auto: "auto"
|
|
98
|
+
};
|
|
99
|
+
const resolvedValue = widthKeywords[value] || isScale(value) && `calc(var(--spacing) * ${value})` || isFraction(value) && `calc((${value.split("/").join(" / ")}) * 100%)`;
|
|
100
|
+
if (!resolvedValue) throw new Error(`Unsupported width value: "${value}". Expected a keyword (${Object.keys(widthKeywords).join(", ")}), a scale number, or a fraction (e.g., "1/2").`);
|
|
101
|
+
return { [`--${name}`]: resolvedValue };
|
|
102
|
+
};
|
|
82
103
|
|
|
83
104
|
//#endregion
|
|
84
105
|
//#region src/components/SVG/SVG.tsx
|
|
85
|
-
const SVG = (0, react.forwardRef)(({ size = 24, children, className, color
|
|
106
|
+
const SVG = (0, react.forwardRef)(({ size = 24, children, className, color, ...props }, ref) => {
|
|
86
107
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
87
108
|
...props,
|
|
88
109
|
ref,
|
|
@@ -96,7 +117,7 @@ const SVG = (0, react.forwardRef)(({ size = 24, children, className, color,...pr
|
|
|
96
117
|
|
|
97
118
|
//#endregion
|
|
98
119
|
//#region src/components/Formatters/DateFormat.tsx
|
|
99
|
-
const DateFormat = ({ value, tabular
|
|
120
|
+
const DateFormat = ({ value, tabular, ...props }) => {
|
|
100
121
|
const formatter = (0, __react_aria_i18n.useDateFormatter)({ ...props });
|
|
101
122
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
102
123
|
className: tabular ? "tabular-nums" : "",
|
|
@@ -106,7 +127,7 @@ const DateFormat = ({ value, tabular,...props }) => {
|
|
|
106
127
|
|
|
107
128
|
//#endregion
|
|
108
129
|
//#region src/components/Formatters/NumericFormat.tsx
|
|
109
|
-
const NumericFormat = ({ value, tabular = true
|
|
130
|
+
const NumericFormat = ({ value, tabular = true, ...props }) => {
|
|
110
131
|
const formatter = (0, __react_aria_i18n.useNumberFormatter)({ ...props });
|
|
111
132
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
112
133
|
className: tabular ? "tabular-nums" : void 0,
|
|
@@ -175,6 +196,14 @@ const useClassNames = ({ component, className, variant, size, context: Component
|
|
|
175
196
|
//#endregion
|
|
176
197
|
//#region src/hooks/useResponsiveValue.ts
|
|
177
198
|
/**
|
|
199
|
+
* Based on https://theme-ui.com/packages/match-media/
|
|
200
|
+
*/
|
|
201
|
+
/**
|
|
202
|
+
* Hardcode fallback breakpoints, not make sure `useEffect`
|
|
203
|
+
* doesn't trigger on every render. Since it is part of the
|
|
204
|
+
* dependency array.
|
|
205
|
+
*/
|
|
206
|
+
/**
|
|
178
207
|
* Hook that can be used to return values based on the current screen size,
|
|
179
208
|
* using breakpoints from the theme (`theme.breakpoints`). Note that this
|
|
180
209
|
* hook is client.side only.
|
|
@@ -210,14 +239,14 @@ const toKebap = (val) => val.replace(KEBAB_REGEX, (match) => `-${match.toLocaleL
|
|
|
210
239
|
* (e.g. `[data-hover]` and `[data-focus]`).
|
|
211
240
|
*/
|
|
212
241
|
const useStateProps = (states) => {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
242
|
+
return (0, react.useMemo)(() => {
|
|
243
|
+
const stateProps = {};
|
|
244
|
+
for (const state in states) if (states[state]) {
|
|
245
|
+
const key = `data-${toKebap(state)}`;
|
|
246
|
+
stateProps[key] = "";
|
|
247
|
+
}
|
|
248
|
+
return stateProps;
|
|
249
|
+
}, [states]);
|
|
221
250
|
};
|
|
222
251
|
|
|
223
252
|
//#endregion
|
|
@@ -227,12 +256,11 @@ const useSmallScreen = () => {
|
|
|
227
256
|
if (typeof window == "undefined") return false;
|
|
228
257
|
return window.matchMedia("(max-width: 600px)").matches;
|
|
229
258
|
};
|
|
230
|
-
const [matches, setMatches] = (0, react.useState)(getMatches
|
|
259
|
+
const [matches, setMatches] = (0, react.useState)(getMatches);
|
|
231
260
|
const handleResize = (0, react.useCallback)(() => {
|
|
232
261
|
setMatches(getMatches());
|
|
233
262
|
}, []);
|
|
234
263
|
(0, react.useEffect)(() => {
|
|
235
|
-
handleResize();
|
|
236
264
|
if (typeof window == "undefined") return;
|
|
237
265
|
window.addEventListener("resize", handleResize);
|
|
238
266
|
return () => window.removeEventListener("resize", handleResize);
|
|
@@ -545,6 +573,14 @@ const whiteSpace = {
|
|
|
545
573
|
preWrap: "whitespace-pre-wrap",
|
|
546
574
|
breakSpaces: "whitespace-break-spaces"
|
|
547
575
|
};
|
|
576
|
+
const lineHeight = {
|
|
577
|
+
none: "leading-none",
|
|
578
|
+
tight: "leading-tight",
|
|
579
|
+
snug: "leading-snug",
|
|
580
|
+
normal: "leading-normal",
|
|
581
|
+
relaxed: "leading-relaxed",
|
|
582
|
+
loose: "leading-loose"
|
|
583
|
+
};
|
|
548
584
|
const gapSpace = {
|
|
549
585
|
0: "gap-0",
|
|
550
586
|
"0.5": "gap-0.5",
|
|
@@ -581,8 +617,8 @@ const gapSpace = {
|
|
|
581
617
|
80: "gap-80",
|
|
582
618
|
96: "gap-96",
|
|
583
619
|
section: "gap-[var(--spacing-section)]",
|
|
584
|
-
fieldY: "gap-[var(--spacing-
|
|
585
|
-
fieldX: "gap-[var(--spacing-
|
|
620
|
+
fieldY: "gap-[var(--spacing-fieldY)]",
|
|
621
|
+
fieldX: "gap-[var(--spacing-fieldX)]",
|
|
586
622
|
container: "gap-[var(--spacing-container)]",
|
|
587
623
|
group: "gap-[var(--spacing-group)]"
|
|
588
624
|
};
|
|
@@ -848,7 +884,8 @@ const alignment = {
|
|
|
848
884
|
alignmentX: {
|
|
849
885
|
left: "items-start",
|
|
850
886
|
center: "items-center",
|
|
851
|
-
right: "items-end"
|
|
887
|
+
right: "items-end",
|
|
888
|
+
stretch: "items-stretch"
|
|
852
889
|
},
|
|
853
890
|
alignmentY: {
|
|
854
891
|
top: "justify-start",
|
|
@@ -882,11 +919,16 @@ const placeItems = {
|
|
|
882
919
|
right: "place-items-end"
|
|
883
920
|
};
|
|
884
921
|
const textAlign = {
|
|
885
|
-
none: void 0,
|
|
886
922
|
left: "text-left",
|
|
887
923
|
center: "text-center",
|
|
888
924
|
right: "text-right"
|
|
889
925
|
};
|
|
926
|
+
const verticalAlign = {
|
|
927
|
+
top: "align-top",
|
|
928
|
+
middle: "align-middle",
|
|
929
|
+
bottom: "align-bottom",
|
|
930
|
+
baseline: "align-baseline"
|
|
931
|
+
};
|
|
890
932
|
const aspect = {
|
|
891
933
|
square: "aspect-[1]",
|
|
892
934
|
landscape: "aspect-4/3",
|
|
@@ -923,6 +965,25 @@ const cursorStyle = {
|
|
|
923
965
|
zoomOut: "cursor-zoom-out"
|
|
924
966
|
};
|
|
925
967
|
|
|
968
|
+
//#endregion
|
|
969
|
+
//#region src/utils/object.utils.ts
|
|
970
|
+
/**
|
|
971
|
+
* Safely get a dot-notated path within a nested object, with ability
|
|
972
|
+
* to return a default if the full key path does not exist or
|
|
973
|
+
* the value is undefined
|
|
974
|
+
*
|
|
975
|
+
* Based on: https://github.com/developit/dlv
|
|
976
|
+
*/
|
|
977
|
+
const get = (obj, path, fallback) => {
|
|
978
|
+
const key = path.split(".");
|
|
979
|
+
let result = obj;
|
|
980
|
+
for (let i = 0, length = key.length; i < length; i++) {
|
|
981
|
+
if (!result) break;
|
|
982
|
+
result = result[key[i]];
|
|
983
|
+
}
|
|
984
|
+
return result === void 0 ? fallback : result;
|
|
985
|
+
};
|
|
986
|
+
|
|
926
987
|
//#endregion
|
|
927
988
|
exports.DateFormat = DateFormat;
|
|
928
989
|
exports.NumericFormat = NumericFormat;
|
|
@@ -931,7 +992,9 @@ exports.ThemeProvider = ThemeProvider;
|
|
|
931
992
|
exports.alignment = alignment;
|
|
932
993
|
exports.aspect = aspect;
|
|
933
994
|
exports.cn = cn;
|
|
995
|
+
exports.createSpacingVar = createSpacingVar;
|
|
934
996
|
exports.createVar = createVar;
|
|
997
|
+
exports.createWidthVar = createWidthVar;
|
|
935
998
|
exports.cursorStyle = cursorStyle;
|
|
936
999
|
exports.cva = cva;
|
|
937
1000
|
exports.defaultTheme = defaultTheme;
|
|
@@ -941,7 +1004,10 @@ exports.fontWeight = fontWeight;
|
|
|
941
1004
|
exports.gapSpace = gapSpace;
|
|
942
1005
|
exports.get = get;
|
|
943
1006
|
exports.height = height;
|
|
1007
|
+
exports.isFraction = isFraction;
|
|
1008
|
+
exports.isScale = isScale;
|
|
944
1009
|
exports.isValidCssCustomPropertyName = isValidCssCustomPropertyName;
|
|
1010
|
+
exports.lineHeight = lineHeight;
|
|
945
1011
|
exports.maxWidth = maxWidth;
|
|
946
1012
|
exports.paddingBottom = paddingBottom;
|
|
947
1013
|
exports.paddingLeft = paddingLeft;
|
|
@@ -960,5 +1026,6 @@ exports.useResponsiveValue = useResponsiveValue;
|
|
|
960
1026
|
exports.useSmallScreen = useSmallScreen;
|
|
961
1027
|
exports.useStateProps = useStateProps;
|
|
962
1028
|
exports.useTheme = useTheme;
|
|
1029
|
+
exports.verticalAlign = verticalAlign;
|
|
963
1030
|
exports.whiteSpace = whiteSpace;
|
|
964
1031
|
exports.width = width;
|