@marigold/system 1.0.0-beta.0 → 1.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.d.ts +22 -53
- package/dist/index.js +2 -31
- package/dist/index.mjs +2 -26
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -10,28 +10,6 @@ declare type StyleObject = ThemeUIStyleObject;
|
|
|
10
10
|
declare type CSSObject = Simplify<ThemeUICSSObject>;
|
|
11
11
|
declare type CSSProperties = Simplify<ThemeUICSSProperties>;
|
|
12
12
|
|
|
13
|
-
interface StyleProps extends Pick<CSSObject, 'display' | 'height' | 'width' | 'minWidth' | 'maxWidth' | 'position' | 'top' | 'bottom' | 'right' | 'left' | 'zIndex' | 'p' | 'px' | 'py' | 'pt' | 'pb' | 'pl' | 'pr' | 'm' | 'mx' | 'my' | 'mt' | 'mb' | 'ml' | 'mr' | 'flexDirection' | 'flexWrap' | 'flexShrink' | 'flexGrow' | 'alignItems' | 'justifyContent' | 'bg' | 'border' | 'borderRadius' | 'boxShadow' | 'opacity' | 'overflow' | 'transition'> {
|
|
14
|
-
}
|
|
15
|
-
interface BoxOwnProps extends StyleProps {
|
|
16
|
-
css?: CSSObject;
|
|
17
|
-
variant?: string | string[];
|
|
18
|
-
/**
|
|
19
|
-
* Use to set base styles for the component
|
|
20
|
-
* @internal Used to set default styles for Marigold components
|
|
21
|
-
*/
|
|
22
|
-
__baseCSS?: CSSObject;
|
|
23
|
-
}
|
|
24
|
-
interface BoxProps extends PolymorphicPropsWithRef<BoxOwnProps, 'div'> {
|
|
25
|
-
}
|
|
26
|
-
declare const Box: PolymorphicComponentWithRef<BoxOwnProps, 'div'>;
|
|
27
|
-
|
|
28
|
-
declare const Global: () => JSX.Element;
|
|
29
|
-
|
|
30
|
-
interface SVGProps extends ComponentProps<'svg'> {
|
|
31
|
-
size?: number | string | number[] | string[];
|
|
32
|
-
}
|
|
33
|
-
declare const SVG: ({ size, fill, children, ...props }: SVGProps) => react.ReactSVGElement;
|
|
34
|
-
|
|
35
13
|
/**
|
|
36
14
|
* Props that every component should accepts to change the styling
|
|
37
15
|
*/
|
|
@@ -219,6 +197,27 @@ interface Theme {
|
|
|
219
197
|
transitions?: Scale<CSS.Property.Transition>;
|
|
220
198
|
}
|
|
221
199
|
|
|
200
|
+
interface StyleProps extends Pick<CSSObject, 'display' | 'height' | 'width' | 'minWidth' | 'maxWidth' | 'position' | 'top' | 'bottom' | 'right' | 'left' | 'zIndex' | 'p' | 'px' | 'py' | 'pt' | 'pb' | 'pl' | 'pr' | 'm' | 'mx' | 'my' | 'mt' | 'mb' | 'ml' | 'mr' | 'flexDirection' | 'flexWrap' | 'flexShrink' | 'flexGrow' | 'alignItems' | 'justifyContent' | 'bg' | 'border' | 'borderRadius' | 'boxShadow' | 'opacity' | 'overflow' | 'transition'> {
|
|
201
|
+
}
|
|
202
|
+
interface BoxOwnProps extends StyleProps {
|
|
203
|
+
css?: CSSObject;
|
|
204
|
+
/**
|
|
205
|
+
* Use to set base styles for the component
|
|
206
|
+
* @internal
|
|
207
|
+
*/
|
|
208
|
+
__baseCSS?: CSSObject;
|
|
209
|
+
}
|
|
210
|
+
interface BoxProps extends PolymorphicPropsWithRef<BoxOwnProps, 'div'> {
|
|
211
|
+
}
|
|
212
|
+
declare const Box: PolymorphicComponentWithRef<BoxOwnProps, 'div'>;
|
|
213
|
+
|
|
214
|
+
declare const Global: () => JSX.Element;
|
|
215
|
+
|
|
216
|
+
interface SVGProps extends ComponentProps<'svg'> {
|
|
217
|
+
size?: number | string | number[] | string[];
|
|
218
|
+
}
|
|
219
|
+
declare const SVG: ({ size, fill, children, ...props }: SVGProps) => react.ReactSVGElement;
|
|
220
|
+
|
|
222
221
|
interface ComponentStylesProps {
|
|
223
222
|
variant?: string;
|
|
224
223
|
size?: string;
|
|
@@ -421,34 +420,4 @@ declare const getNormalizedStyles: (val?: ElementType<any> | undefined) => {
|
|
|
421
420
|
readonly minWidth: 0;
|
|
422
421
|
};
|
|
423
422
|
|
|
424
|
-
|
|
425
|
-
* Ensures that the `val` is an array. Will return an empty array if `val` is falsy.
|
|
426
|
-
*/
|
|
427
|
-
declare const ensureArray: <T>(val?: T | T[] | undefined) => T[];
|
|
428
|
-
/**
|
|
429
|
-
* Removes trailing dot from variant, if necessary. This is necessary to support
|
|
430
|
-
* `__default` styles. See https://github.com/system-ui/theme-ui/pull/951
|
|
431
|
-
*/
|
|
432
|
-
declare const ensureVariantDefault: (val: string) => string;
|
|
433
|
-
/**
|
|
434
|
-
* Ensures that the `variant` is an array and supports the `__default` key.
|
|
435
|
-
*/
|
|
436
|
-
declare const ensureArrayVariant: <T extends string>(variant?: T | T[] | undefined) => string[];
|
|
437
|
-
interface State {
|
|
438
|
-
checked?: boolean;
|
|
439
|
-
focus?: boolean;
|
|
440
|
-
hover?: boolean;
|
|
441
|
-
disabled?: boolean;
|
|
442
|
-
error?: boolean;
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Appends given `state` to a `variant`.
|
|
446
|
-
*/
|
|
447
|
-
declare const appendVariantState: (variant: string, state: keyof State) => string;
|
|
448
|
-
/**
|
|
449
|
-
* Create a variant array from a `variant` and `state` containing
|
|
450
|
-
* passed states, if they are truthy.
|
|
451
|
-
*/
|
|
452
|
-
declare const conditional: (variant: string, { disabled, ...states }: State) => string[];
|
|
453
|
-
|
|
454
|
-
export { Box, BoxOwnProps, BoxProps, CSSObject, CSSProperties, ComponentState, ComponentStyleParts, ComponentStylesProps, Global, NormalizedElement, ResponsiveStyleValue, SVG, SVGProps, Scale, ScaleValue, SizeScale, State, StateAttrKeyProps, StateAttrProps, StyleObject, StyleProps, Theme, ThemeComponentProps, ThemeExtension, ThemeExtensionsWithParts, ThemeProvider, ThemeProviderProps, UseStateProps, ZeroScale, ZeroSizeScale, __defaultTheme, appendVariantState, conditional, ensureArray, ensureArrayVariant, ensureVariantDefault, getNormalizedStyles, normalize, useComponentStyles, useResponsiveValue, useStateProps, useTheme };
|
|
423
|
+
export { Box, BoxOwnProps, BoxProps, CSSObject, CSSProperties, ComponentState, ComponentStyleParts, ComponentStylesProps, Global, NormalizedElement, ResponsiveStyleValue, SVG, SVGProps, Scale, ScaleValue, SizeScale, StateAttrKeyProps, StateAttrProps, StyleObject, StyleProps, Theme, ThemeComponentProps, ThemeExtension, ThemeExtensionsWithParts, ThemeProvider, ThemeProviderProps, UseStateProps, ZeroScale, ZeroSizeScale, __defaultTheme, getNormalizedStyles, normalize, useComponentStyles, useResponsiveValue, useStateProps, useTheme };
|
package/dist/index.js
CHANGED
|
@@ -56,11 +56,6 @@ __export(src_exports, {
|
|
|
56
56
|
SVG: () => SVG,
|
|
57
57
|
ThemeProvider: () => ThemeProvider,
|
|
58
58
|
__defaultTheme: () => __defaultTheme,
|
|
59
|
-
appendVariantState: () => appendVariantState,
|
|
60
|
-
conditional: () => conditional,
|
|
61
|
-
ensureArray: () => ensureArray,
|
|
62
|
-
ensureArrayVariant: () => ensureArrayVariant,
|
|
63
|
-
ensureVariantDefault: () => ensureVariantDefault,
|
|
64
59
|
getNormalizedStyles: () => getNormalizedStyles,
|
|
65
60
|
normalize: () => normalize,
|
|
66
61
|
useComponentStyles: () => useComponentStyles,
|
|
@@ -145,21 +140,6 @@ var normalize = {
|
|
|
145
140
|
};
|
|
146
141
|
var getNormalizedStyles = (val) => typeof val === "string" && val in normalize ? normalize[val] : normalize.base;
|
|
147
142
|
|
|
148
|
-
// src/variant.ts
|
|
149
|
-
var isNil = (value) => value === null || value === void 0;
|
|
150
|
-
var ensureArray = (val) => isNil(val) ? [] : Array.isArray(val) ? val : [val];
|
|
151
|
-
var ensureVariantDefault = (val) => val.replace(/\.$/, "");
|
|
152
|
-
var ensureArrayVariant = (variant) => ensureArray(variant).map(ensureVariantDefault);
|
|
153
|
-
var appendVariantState = (variant, state2) => {
|
|
154
|
-
return `${ensureVariantDefault(variant)}.:${state2}`;
|
|
155
|
-
};
|
|
156
|
-
var conditional = (variant, _a) => {
|
|
157
|
-
var _b = _a, { disabled = false } = _b, states = __objRest(_b, ["disabled"]);
|
|
158
|
-
const entries = [...Object.entries(states), ["disabled", disabled]];
|
|
159
|
-
const stateVariants = entries.filter(([, val]) => Boolean(val)).map(([key]) => appendVariantState(variant, key));
|
|
160
|
-
return [variant, ...stateVariants];
|
|
161
|
-
};
|
|
162
|
-
|
|
163
143
|
// src/components/Box/utils.ts
|
|
164
144
|
var createteSelector = (selectors, states, suffix = "") => {
|
|
165
145
|
return selectors.map((selector2) => states.map((state2) => `${selector2}${state2}${suffix ? ` ${suffix}` : ""}`)).flat().join(", ");
|
|
@@ -217,11 +197,10 @@ var transformPseudos = (styles) => {
|
|
|
217
197
|
};
|
|
218
198
|
|
|
219
199
|
// src/components/Box/Box.tsx
|
|
220
|
-
var createThemedStyle = ({ as, __baseCSS,
|
|
200
|
+
var createThemedStyle = ({ as, __baseCSS, styles, css }) => (theme) => {
|
|
221
201
|
const themedStyles = import_deepmerge.default.all([
|
|
222
202
|
getNormalizedStyles(as),
|
|
223
203
|
(0, import_css.css)(__baseCSS)(theme),
|
|
224
|
-
...ensureArrayVariant(variant).map((v) => (0, import_css.css)({ variant: v })(theme)),
|
|
225
204
|
(0, import_css.css)(styles)(theme),
|
|
226
205
|
(0, import_css.css)(css)(theme)
|
|
227
206
|
]);
|
|
@@ -232,8 +211,7 @@ var Box = (0, import_react.forwardRef)((_a, ref) => {
|
|
|
232
211
|
as = "div",
|
|
233
212
|
children,
|
|
234
213
|
__baseCSS,
|
|
235
|
-
|
|
236
|
-
css = {},
|
|
214
|
+
css,
|
|
237
215
|
display,
|
|
238
216
|
height,
|
|
239
217
|
width,
|
|
@@ -276,7 +254,6 @@ var Box = (0, import_react.forwardRef)((_a, ref) => {
|
|
|
276
254
|
"as",
|
|
277
255
|
"children",
|
|
278
256
|
"__baseCSS",
|
|
279
|
-
"variant",
|
|
280
257
|
"css",
|
|
281
258
|
"display",
|
|
282
259
|
"height",
|
|
@@ -321,7 +298,6 @@ var Box = (0, import_react.forwardRef)((_a, ref) => {
|
|
|
321
298
|
css: createThemedStyle({
|
|
322
299
|
as,
|
|
323
300
|
__baseCSS,
|
|
324
|
-
variant,
|
|
325
301
|
css,
|
|
326
302
|
styles: {
|
|
327
303
|
display,
|
|
@@ -541,11 +517,6 @@ var SVG = (_a) => {
|
|
|
541
517
|
SVG,
|
|
542
518
|
ThemeProvider,
|
|
543
519
|
__defaultTheme,
|
|
544
|
-
appendVariantState,
|
|
545
|
-
conditional,
|
|
546
|
-
ensureArray,
|
|
547
|
-
ensureArrayVariant,
|
|
548
|
-
ensureVariantDefault,
|
|
549
520
|
getNormalizedStyles,
|
|
550
521
|
normalize,
|
|
551
522
|
useComponentStyles,
|
package/dist/index.mjs
CHANGED
|
@@ -105,21 +105,6 @@ var normalize = {
|
|
|
105
105
|
};
|
|
106
106
|
var getNormalizedStyles = (val) => typeof val === "string" && val in normalize ? normalize[val] : normalize.base;
|
|
107
107
|
|
|
108
|
-
// src/variant.ts
|
|
109
|
-
var isNil = (value) => value === null || value === void 0;
|
|
110
|
-
var ensureArray = (val) => isNil(val) ? [] : Array.isArray(val) ? val : [val];
|
|
111
|
-
var ensureVariantDefault = (val) => val.replace(/\.$/, "");
|
|
112
|
-
var ensureArrayVariant = (variant) => ensureArray(variant).map(ensureVariantDefault);
|
|
113
|
-
var appendVariantState = (variant, state2) => {
|
|
114
|
-
return `${ensureVariantDefault(variant)}.:${state2}`;
|
|
115
|
-
};
|
|
116
|
-
var conditional = (variant, _a) => {
|
|
117
|
-
var _b = _a, { disabled = false } = _b, states = __objRest(_b, ["disabled"]);
|
|
118
|
-
const entries = [...Object.entries(states), ["disabled", disabled]];
|
|
119
|
-
const stateVariants = entries.filter(([, val]) => Boolean(val)).map(([key]) => appendVariantState(variant, key));
|
|
120
|
-
return [variant, ...stateVariants];
|
|
121
|
-
};
|
|
122
|
-
|
|
123
108
|
// src/components/Box/utils.ts
|
|
124
109
|
var createteSelector = (selectors, states, suffix = "") => {
|
|
125
110
|
return selectors.map((selector2) => states.map((state2) => `${selector2}${state2}${suffix ? ` ${suffix}` : ""}`)).flat().join(", ");
|
|
@@ -177,11 +162,10 @@ var transformPseudos = (styles) => {
|
|
|
177
162
|
};
|
|
178
163
|
|
|
179
164
|
// src/components/Box/Box.tsx
|
|
180
|
-
var createThemedStyle = ({ as, __baseCSS,
|
|
165
|
+
var createThemedStyle = ({ as, __baseCSS, styles, css }) => (theme) => {
|
|
181
166
|
const themedStyles = merge.all([
|
|
182
167
|
getNormalizedStyles(as),
|
|
183
168
|
transformStyleObject(__baseCSS)(theme),
|
|
184
|
-
...ensureArrayVariant(variant).map((v) => transformStyleObject({ variant: v })(theme)),
|
|
185
169
|
transformStyleObject(styles)(theme),
|
|
186
170
|
transformStyleObject(css)(theme)
|
|
187
171
|
]);
|
|
@@ -192,8 +176,7 @@ var Box = forwardRef((_a, ref) => {
|
|
|
192
176
|
as = "div",
|
|
193
177
|
children,
|
|
194
178
|
__baseCSS,
|
|
195
|
-
|
|
196
|
-
css = {},
|
|
179
|
+
css,
|
|
197
180
|
display,
|
|
198
181
|
height,
|
|
199
182
|
width,
|
|
@@ -236,7 +219,6 @@ var Box = forwardRef((_a, ref) => {
|
|
|
236
219
|
"as",
|
|
237
220
|
"children",
|
|
238
221
|
"__baseCSS",
|
|
239
|
-
"variant",
|
|
240
222
|
"css",
|
|
241
223
|
"display",
|
|
242
224
|
"height",
|
|
@@ -281,7 +263,6 @@ var Box = forwardRef((_a, ref) => {
|
|
|
281
263
|
css: createThemedStyle({
|
|
282
264
|
as,
|
|
283
265
|
__baseCSS,
|
|
284
|
-
variant,
|
|
285
266
|
css,
|
|
286
267
|
styles: {
|
|
287
268
|
display,
|
|
@@ -507,11 +488,6 @@ export {
|
|
|
507
488
|
SVG,
|
|
508
489
|
ThemeProvider,
|
|
509
490
|
__defaultTheme,
|
|
510
|
-
appendVariantState,
|
|
511
|
-
conditional,
|
|
512
|
-
ensureArray,
|
|
513
|
-
ensureArrayVariant,
|
|
514
|
-
ensureVariantDefault,
|
|
515
491
|
getNormalizedStyles,
|
|
516
492
|
normalize,
|
|
517
493
|
useComponentStyles,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marigold/system",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Marigold System Library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@emotion/react": "11.9.0",
|
|
30
|
-
"@marigold/types": "0.5.0
|
|
30
|
+
"@marigold/types": "0.5.0",
|
|
31
31
|
"@theme-ui/css": "0.14.5",
|
|
32
32
|
"csstype": "3.0.11",
|
|
33
33
|
"deepmerge": "^4.2.2",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"react-dom": "^16.x || ^17.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@babel/core": "7.17.
|
|
41
|
+
"@babel/core": "7.17.12",
|
|
42
42
|
"@marigold/tsconfig": "0.3.0",
|
|
43
|
-
"react": "17.
|
|
44
|
-
"tsup": "5.12.
|
|
43
|
+
"react": "17.0.2",
|
|
44
|
+
"tsup": "5.12.8"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsup src/index.ts",
|