@marigold/system 0.3.0 → 0.4.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 CHANGED
@@ -1,8 +1,402 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a2, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a2, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a2, prop, b[prop]);
20
+ }
21
+ return a2;
22
+ };
23
+ var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
24
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, { get: all[name], enumerable: true });
40
+ };
41
+ var __reExport = (target, module2, copyDefault, desc) => {
42
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
43
+ for (let key of __getOwnPropNames(module2))
44
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
45
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
46
+ }
47
+ return target;
48
+ };
49
+ var __toESM = (module2, isNodeMode) => {
50
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
51
+ };
52
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
53
+ return (module2, temp) => {
54
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
55
+ };
56
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
1
57
 
2
- 'use strict'
58
+ // src/index.ts
59
+ var src_exports = {};
60
+ __export(src_exports, {
61
+ Box: () => Box,
62
+ Global: () => Global,
63
+ SVG: () => SVG,
64
+ ThemeProvider: () => ThemeProvider,
65
+ __defaultTheme: () => __defaultTheme,
66
+ appendVariantState: () => appendVariantState,
67
+ conditional: () => conditional,
68
+ ensureArray: () => ensureArray,
69
+ ensureArrayVariant: () => ensureArrayVariant,
70
+ ensureVariantDefault: () => ensureVariantDefault,
71
+ getNormalizedStyles: () => getNormalizedStyles,
72
+ normalize: () => normalize,
73
+ useTheme: () => useTheme
74
+ });
3
75
 
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./system.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./system.cjs.development.js')
76
+ // src/Box.tsx
77
+ var import_react = require("@emotion/react");
78
+ var import_css = require("@theme-ui/css");
79
+ var import_react2 = require("react");
80
+
81
+ // src/normalize.ts
82
+ var base = {
83
+ boxSizing: "border-box",
84
+ margin: 0,
85
+ minWidth: 0
86
+ };
87
+ var a = __spreadProps(__spreadValues({}, base), {
88
+ textDecoration: "none"
89
+ });
90
+ var text = __spreadProps(__spreadValues({}, base), {
91
+ overflowWrap: "break-word"
92
+ });
93
+ var media = __spreadProps(__spreadValues({}, base), {
94
+ display: "block",
95
+ maxWidth: "100%"
96
+ });
97
+ var button = __spreadProps(__spreadValues({}, base), {
98
+ display: "block",
99
+ appearance: "none",
100
+ font: "inherit",
101
+ background: "transparent",
102
+ textAlign: "center"
103
+ });
104
+ var input = __spreadProps(__spreadValues({}, base), {
105
+ display: "block",
106
+ appearance: "none",
107
+ font: "inherit",
108
+ "&::-ms-clear": {
109
+ display: "none"
110
+ },
111
+ "&::-webkit-search-cancel-button": {
112
+ WebkitAppearance: "none"
113
+ }
114
+ });
115
+ var select = __spreadProps(__spreadValues({}, base), {
116
+ display: "block",
117
+ appearance: "none",
118
+ font: "inherit",
119
+ "&::-ms-expand": {
120
+ display: "none"
121
+ }
122
+ });
123
+ var textarea = __spreadProps(__spreadValues({}, base), {
124
+ display: "block",
125
+ appearance: "none",
126
+ font: "inherit"
127
+ });
128
+ var normalize = {
129
+ base,
130
+ a,
131
+ p: text,
132
+ h1: text,
133
+ h2: text,
134
+ h3: text,
135
+ h4: text,
136
+ h5: text,
137
+ h6: text,
138
+ img: media,
139
+ picture: media,
140
+ video: media,
141
+ canvas: media,
142
+ svg: media,
143
+ select,
144
+ button,
145
+ textarea,
146
+ input
147
+ };
148
+ var getNormalizedStyles = (val) => typeof val === "string" && val in normalize ? normalize[val] : normalize.base;
149
+
150
+ // src/variant.ts
151
+ var isNil = (value) => value === null || value === void 0;
152
+ var ensureArray = (val) => isNil(val) ? [] : Array.isArray(val) ? val : [val];
153
+ var ensureVariantDefault = (val) => val.replace(/\.$/, "");
154
+ var ensureArrayVariant = (variant) => ensureArray(variant).map(ensureVariantDefault);
155
+ var appendVariantState = (variant, state) => {
156
+ return `${ensureVariantDefault(variant)}.:${state}`;
157
+ };
158
+ var conditional = (variant, _a) => {
159
+ var _b = _a, { disabled = false } = _b, states = __objRest(_b, ["disabled"]);
160
+ const entries = [...Object.entries(states), ["disabled", disabled]];
161
+ const stateVariants = entries.filter(([, val]) => Boolean(val)).map(([key]) => appendVariantState(variant, key));
162
+ return [variant, ...stateVariants];
163
+ };
164
+
165
+ // src/Box.tsx
166
+ var isNotEmpty = (val) => !(val && Object.keys(val).length === 0 && val.constructor === Object);
167
+ var createThemedStyle = ({ as, __baseCSS, variant, styles, css: css2 }) => (theme) => {
168
+ return [
169
+ getNormalizedStyles(as),
170
+ (0, import_css.css)(__baseCSS)(theme),
171
+ ...ensureArrayVariant(variant).map((v) => (0, import_css.css)({ variant: v })(theme)),
172
+ (0, import_css.css)(styles)(theme),
173
+ (0, import_css.css)(css2)(theme)
174
+ ].filter(isNotEmpty);
175
+ };
176
+ var Box = (0, import_react2.forwardRef)((_a, ref) => {
177
+ var _b = _a, {
178
+ as = "div",
179
+ children,
180
+ __baseCSS,
181
+ variant,
182
+ css: css2 = {},
183
+ display,
184
+ height,
185
+ width,
186
+ minWidth,
187
+ maxWidth,
188
+ position,
189
+ top,
190
+ bottom,
191
+ right,
192
+ left,
193
+ zIndex,
194
+ p,
195
+ px,
196
+ py,
197
+ pt,
198
+ pb,
199
+ pl,
200
+ pr,
201
+ m,
202
+ mx,
203
+ my,
204
+ mt,
205
+ mb,
206
+ ml,
207
+ mr,
208
+ flexDirection,
209
+ flexWrap,
210
+ flexShrink,
211
+ flexGrow,
212
+ alignItems,
213
+ justifyContent,
214
+ bg,
215
+ border,
216
+ borderRadius,
217
+ boxShadow,
218
+ opacity,
219
+ overflow,
220
+ transition
221
+ } = _b, props = __objRest(_b, [
222
+ "as",
223
+ "children",
224
+ "__baseCSS",
225
+ "variant",
226
+ "css",
227
+ "display",
228
+ "height",
229
+ "width",
230
+ "minWidth",
231
+ "maxWidth",
232
+ "position",
233
+ "top",
234
+ "bottom",
235
+ "right",
236
+ "left",
237
+ "zIndex",
238
+ "p",
239
+ "px",
240
+ "py",
241
+ "pt",
242
+ "pb",
243
+ "pl",
244
+ "pr",
245
+ "m",
246
+ "mx",
247
+ "my",
248
+ "mt",
249
+ "mb",
250
+ "ml",
251
+ "mr",
252
+ "flexDirection",
253
+ "flexWrap",
254
+ "flexShrink",
255
+ "flexGrow",
256
+ "alignItems",
257
+ "justifyContent",
258
+ "bg",
259
+ "border",
260
+ "borderRadius",
261
+ "boxShadow",
262
+ "opacity",
263
+ "overflow",
264
+ "transition"
265
+ ]);
266
+ return (0, import_react.jsx)(as, __spreadProps(__spreadValues({}, props), {
267
+ css: createThemedStyle({
268
+ as,
269
+ __baseCSS,
270
+ variant,
271
+ css: css2,
272
+ styles: {
273
+ display,
274
+ height,
275
+ width,
276
+ minWidth,
277
+ maxWidth,
278
+ position,
279
+ top,
280
+ bottom,
281
+ right,
282
+ left,
283
+ zIndex,
284
+ p,
285
+ px,
286
+ py,
287
+ pt,
288
+ pb,
289
+ pl,
290
+ pr,
291
+ m,
292
+ mx,
293
+ my,
294
+ mt,
295
+ mb,
296
+ ml,
297
+ mr,
298
+ flexDirection,
299
+ flexWrap,
300
+ flexShrink,
301
+ flexGrow,
302
+ alignItems,
303
+ justifyContent,
304
+ bg,
305
+ border,
306
+ borderRadius,
307
+ boxShadow,
308
+ opacity,
309
+ overflow,
310
+ transition
311
+ }
312
+ }),
313
+ ref
314
+ }), children);
315
+ });
316
+
317
+ // src/Global.tsx
318
+ var import_react5 = __toESM(require("react"));
319
+ var import_react6 = require("@emotion/react");
320
+
321
+ // src/useTheme.tsx
322
+ var import_react3 = __toESM(require("react"));
323
+ var import_css2 = require("@theme-ui/css");
324
+ var import_react4 = require("@emotion/react");
325
+ var __defaultTheme = {};
326
+ var InternalContext = (0, import_react3.createContext)(__defaultTheme);
327
+ var useTheme = () => {
328
+ const theme = (0, import_react3.useContext)(InternalContext);
329
+ const css2 = (0, import_react3.useCallback)((style) => (0, import_css2.css)(style)(theme), [theme]);
330
+ return { theme, css: css2 };
331
+ };
332
+ function ThemeProvider({
333
+ theme,
334
+ children
335
+ }) {
336
+ return /* @__PURE__ */ import_react3.default.createElement(import_react4.ThemeProvider, {
337
+ theme
338
+ }, /* @__PURE__ */ import_react3.default.createElement(InternalContext.Provider, {
339
+ value: theme
340
+ }, children));
8
341
  }
342
+
343
+ // src/Global.tsx
344
+ var reduceMotionStyles = {
345
+ "@media screen and (prefers-reduced-motion: reduce), (update: slow)": {
346
+ "*": {
347
+ animationDuration: "0.001ms !important",
348
+ animationIterationCount: "1 !important",
349
+ transitionDuration: "0.001ms !important"
350
+ }
351
+ }
352
+ };
353
+ var Global = () => {
354
+ const { css: css2 } = useTheme();
355
+ const styles = css2({
356
+ html: {
357
+ height: "100%",
358
+ variant: "root.html"
359
+ },
360
+ body: {
361
+ height: "100%",
362
+ lineHeight: 1.5,
363
+ WebkitFontSmoothing: "antialiased",
364
+ variant: "root.body"
365
+ }
366
+ });
367
+ return /* @__PURE__ */ import_react5.default.createElement(import_react6.Global, {
368
+ styles: __spreadValues({ reduceMotionStyles }, styles)
369
+ });
370
+ };
371
+
372
+ // src/SVG.tsx
373
+ var import_react7 = require("@emotion/react");
374
+ var css = getNormalizedStyles("svg");
375
+ var SVG = (_a) => {
376
+ var _b = _a, { size = 24, children } = _b, props = __objRest(_b, ["size", "children"]);
377
+ return (0, import_react7.jsx)("svg", __spreadProps(__spreadValues({
378
+ width: size,
379
+ height: size,
380
+ viewBox: "0 0 24 24",
381
+ fill: "currentcolor"
382
+ }, props), {
383
+ css
384
+ }), children);
385
+ };
386
+ module.exports = __toCommonJS(src_exports);
387
+ // Annotate the CommonJS export names for ESM import in node:
388
+ 0 && (module.exports = {
389
+ Box,
390
+ Global,
391
+ SVG,
392
+ ThemeProvider,
393
+ __defaultTheme,
394
+ appendVariantState,
395
+ conditional,
396
+ ensureArray,
397
+ ensureArrayVariant,
398
+ ensureVariantDefault,
399
+ getNormalizedStyles,
400
+ normalize,
401
+ useTheme
402
+ });