@stylix/core 3.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.
Files changed (85) hide show
  1. package/README.md +100 -0
  2. package/dist/Stylix.d.ts +3 -0
  3. package/dist/Stylix.js +66 -0
  4. package/dist/Stylix.js.map +1 -0
  5. package/dist/StylixProvider.d.ts +51 -0
  6. package/dist/StylixProvider.js +139 -0
  7. package/dist/StylixProvider.js.map +1 -0
  8. package/dist/applyRules.d.ts +5 -0
  9. package/dist/applyRules.js +31 -0
  10. package/dist/applyRules.js.map +1 -0
  11. package/dist/classifyProps.d.ts +7 -0
  12. package/dist/classifyProps.js +35 -0
  13. package/dist/classifyProps.js.map +1 -0
  14. package/dist/css-props.json +413 -0
  15. package/dist/html-tags.json +119 -0
  16. package/dist/index.d.ts +8 -0
  17. package/dist/index.js +28 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/plugins/cleanStyles.d.ts +5 -0
  20. package/dist/plugins/cleanStyles.js +28 -0
  21. package/dist/plugins/cleanStyles.js.map +1 -0
  22. package/dist/plugins/customProps.d.ts +2 -0
  23. package/dist/plugins/customProps.js +61 -0
  24. package/dist/plugins/customProps.js.map +1 -0
  25. package/dist/plugins/defaultUnits.d.ts +7 -0
  26. package/dist/plugins/defaultUnits.js +41 -0
  27. package/dist/plugins/defaultUnits.js.map +1 -0
  28. package/dist/plugins/flattenNestedStyles.d.ts +5 -0
  29. package/dist/plugins/flattenNestedStyles.js +47 -0
  30. package/dist/plugins/flattenNestedStyles.js.map +1 -0
  31. package/dist/plugins/index.d.ts +30 -0
  32. package/dist/plugins/index.js +44 -0
  33. package/dist/plugins/index.js.map +1 -0
  34. package/dist/plugins/mediaArrays.d.ts +5 -0
  35. package/dist/plugins/mediaArrays.js +56 -0
  36. package/dist/plugins/mediaArrays.js.map +1 -0
  37. package/dist/plugins/merge$css.d.ts +6 -0
  38. package/dist/plugins/merge$css.js +45 -0
  39. package/dist/plugins/merge$css.js.map +1 -0
  40. package/dist/plugins/propCasing.d.ts +5 -0
  41. package/dist/plugins/propCasing.js +25 -0
  42. package/dist/plugins/propCasing.js.map +1 -0
  43. package/dist/plugins/replace$$class.d.ts +5 -0
  44. package/dist/plugins/replace$$class.js +20 -0
  45. package/dist/plugins/replace$$class.js.map +1 -0
  46. package/dist/plugins/themeFunctions.d.ts +5 -0
  47. package/dist/plugins/themeFunctions.js +20 -0
  48. package/dist/plugins/themeFunctions.js.map +1 -0
  49. package/dist/styleCollector.d.ts +8 -0
  50. package/dist/styleCollector.js +36 -0
  51. package/dist/styleCollector.js.map +1 -0
  52. package/dist/stylesToRuleArray.d.ts +5 -0
  53. package/dist/stylesToRuleArray.js +41 -0
  54. package/dist/stylesToRuleArray.js.map +1 -0
  55. package/dist/types.d.ts +76 -0
  56. package/dist/types.js +3 -0
  57. package/dist/types.js.map +1 -0
  58. package/dist/useStyles.d.ts +16 -0
  59. package/dist/useStyles.js +81 -0
  60. package/dist/useStyles.js.map +1 -0
  61. package/dist/util/cloneDeep.d.ts +4 -0
  62. package/dist/util/cloneDeep.js +28 -0
  63. package/dist/util/cloneDeep.js.map +1 -0
  64. package/dist/util/flatten.d.ts +4 -0
  65. package/dist/util/flatten.js +19 -0
  66. package/dist/util/flatten.js.map +1 -0
  67. package/dist/util/hashString.d.ts +4 -0
  68. package/dist/util/hashString.js +15 -0
  69. package/dist/util/hashString.js.map +1 -0
  70. package/dist/util/isPlainObject.d.ts +4 -0
  71. package/dist/util/isPlainObject.js +11 -0
  72. package/dist/util/isPlainObject.js.map +1 -0
  73. package/dist/util/mapObjectRecursive.d.ts +8 -0
  74. package/dist/util/mapObjectRecursive.js +48 -0
  75. package/dist/util/mapObjectRecursive.js.map +1 -0
  76. package/dist/util/merge.d.ts +5 -0
  77. package/dist/util/merge.js +31 -0
  78. package/dist/util/merge.js.map +1 -0
  79. package/dist/util/useIsoLayoutEffect.d.ts +3 -0
  80. package/dist/util/useIsoLayoutEffect.js +6 -0
  81. package/dist/util/useIsoLayoutEffect.js.map +1 -0
  82. package/dist/util/walkRecursive.d.ts +8 -0
  83. package/dist/util/walkRecursive.js +26 -0
  84. package/dist/util/walkRecursive.js.map +1 -0
  85. package/package.json +65 -0
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useGlobalStyles = exports.useKeyframes = exports.useStyles = void 0;
7
+ const applyRules_1 = __importDefault(require("./applyRules"));
8
+ const plugins_1 = require("./plugins");
9
+ const stylesToRuleArray_1 = __importDefault(require("./stylesToRuleArray"));
10
+ const StylixProvider_1 = require("./StylixProvider");
11
+ const hashString_1 = require("./util/hashString");
12
+ const useIsoLayoutEffect_1 = __importDefault(require("./util/useIsoLayoutEffect"));
13
+ function cleanup(ctx) {
14
+ if (typeof ctx.cleanupRequest !== 'undefined')
15
+ return;
16
+ ctx.cleanupRequest = setTimeout(() => {
17
+ let deleted = false;
18
+ for (const i in ctx.rules) {
19
+ const rule = ctx.rules[i];
20
+ if (!rule.refs) {
21
+ delete ctx.rules[rule.hash];
22
+ deleted = true;
23
+ }
24
+ }
25
+ deleted && applyRules_1.default(ctx);
26
+ delete ctx.cleanupRequest;
27
+ }, 100);
28
+ }
29
+ /**
30
+ * Accepts a Stylix CSS object and returns a unique className based on the styles' hash.
31
+ * The styles are registered with the Stylix context and will be applied to the document.
32
+ * If `global` is false, provided styles will be nested within the generated classname.
33
+ * Returns the className hash if enabled, or an empty string.
34
+ */
35
+ function useStyles(styles, options = { global: false, disabled: false }) {
36
+ const stylixCtx = StylixProvider_1.useStylixContext();
37
+ // Preprocess styles with plugins
38
+ if (!options.disabled && styles)
39
+ styles = plugins_1.applyPlugins('preprocessStyles', styles, null, stylixCtx);
40
+ // Serialize value and generate hash
41
+ const json = !options.disabled && styles && JSON.stringify(styles);
42
+ const hash = json && json !== '{}' && json !== '[]'
43
+ ? hashString_1.hashString(JSON.stringify(stylixCtx.media || []) + json)
44
+ : '';
45
+ // When hash changes, add/remove ref count
46
+ useIsoLayoutEffect_1.default(() => {
47
+ if (!hash)
48
+ return;
49
+ stylixCtx.rules[hash].refs++;
50
+ return () => {
51
+ stylixCtx.rules[hash].refs--;
52
+ cleanup(stylixCtx);
53
+ };
54
+ }, [hash]);
55
+ if (!hash) {
56
+ return '';
57
+ }
58
+ // If css is not cached, process css and apply it.
59
+ if (!stylixCtx.rules[hash]) {
60
+ // If not global styles, wrap original styles with classname
61
+ if (!options.global)
62
+ styles = { ['.' + hash]: styles };
63
+ stylixCtx.rules[hash] = {
64
+ hash,
65
+ rules: stylesToRuleArray_1.default(styles, hash, stylixCtx),
66
+ refs: 0,
67
+ };
68
+ applyRules_1.default(stylixCtx);
69
+ }
70
+ return hash;
71
+ }
72
+ exports.useStyles = useStyles;
73
+ function useKeyframes(keyframes, options = { disabled: false }) {
74
+ return useStyles({ '@keyframes $$class': keyframes }, Object.assign({ global: true }, options));
75
+ }
76
+ exports.useKeyframes = useKeyframes;
77
+ function useGlobalStyles(styles, options = { disabled: false }) {
78
+ return useStyles(styles, Object.assign(Object.assign({}, options), { global: true }));
79
+ }
80
+ exports.useGlobalStyles = useGlobalStyles;
81
+ //# sourceMappingURL=useStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStyles.js","sourceRoot":"","sources":["../src/useStyles.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Deeply clones a value.
3
+ */
4
+ export declare function cloneDeep<T>(value: T): T;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cloneDeep = void 0;
4
+ const isPlainObject_1 = require("./isPlainObject");
5
+ /**
6
+ * Deeply clones a value.
7
+ */
8
+ function cloneDeep(value) {
9
+ if (!value || typeof value !== 'object')
10
+ return value;
11
+ if (Array.isArray(value)) {
12
+ const clone = [];
13
+ for (let index = 0; index < value.length; ++index) {
14
+ clone.push(cloneDeep(value[index]));
15
+ }
16
+ return clone;
17
+ }
18
+ if (isPlainObject_1.isPlainObject(value)) {
19
+ const clone = {};
20
+ for (const key in value) {
21
+ clone[key] = cloneDeep(value[key]);
22
+ }
23
+ return clone;
24
+ }
25
+ return value;
26
+ }
27
+ exports.cloneDeep = cloneDeep;
28
+ //# sourceMappingURL=cloneDeep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloneDeep.js","sourceRoot":"","sources":["../../src/util/cloneDeep.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAEhD;;GAEG;AACH,SAAgB,SAAS,CAAI,KAAQ;IACnC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,MAAM,KAAK,GAAQ,EAAE,CAAC;QACtB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE;YACjD,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACrC;QACD,OAAO,KAAK,CAAC;KACd;IACD,IAAI,6BAAa,CAAC,KAAK,CAAC,EAAE;QACxB,MAAM,KAAK,GAAQ,EAAE,CAAC;QACtB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE;YACvB,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;SACpC;QACD,OAAO,KAAK,CAAC;KACd;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAjBD,8BAiBC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Flatten an array recursively.
3
+ */
4
+ export declare function flatten<TEntryType>(array: unknown[]): TEntryType[];
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flatten = void 0;
4
+ /**
5
+ * Flatten an array recursively.
6
+ */
7
+ function flatten(array) {
8
+ const result = [];
9
+ _flatten(array, result);
10
+ return result;
11
+ }
12
+ exports.flatten = flatten;
13
+ function _flatten(array, result) {
14
+ for (let i = 0; i < array.length; i++) {
15
+ const value = array[i];
16
+ Array.isArray(value) ? _flatten(value, result) : result.push(value);
17
+ }
18
+ }
19
+ //# sourceMappingURL=flatten.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flatten.js","sourceRoot":"","sources":["../../src/util/flatten.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,OAAO,CAAa,KAAgB;IAClD,MAAM,MAAM,GAAc,EAAE,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACxB,OAAO,MAAsB,CAAC;AAChC,CAAC;AAJD,0BAIC;AAED,SAAS,QAAQ,CAAC,KAAgB,EAAE,MAAiB;IACnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAY,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC5E;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Cheap string hashing, suitable for generating css class names
3
+ */
4
+ export declare function hashString(str: any): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hashString = void 0;
4
+ /**
5
+ * Cheap string hashing, suitable for generating css class names
6
+ */
7
+ function hashString(str) {
8
+ let hash = 5381;
9
+ let i = str.length;
10
+ while (i)
11
+ hash = (hash * 33) ^ str.charCodeAt(--i);
12
+ return 'stylix-' + (hash >>> 0).toString(36);
13
+ }
14
+ exports.hashString = hashString;
15
+ //# sourceMappingURL=hashString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashString.js","sourceRoot":"","sources":["../../src/util/hashString.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,UAAU,CAAC,GAAG;IAC5B,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;IACnB,OAAO,CAAC;QAAE,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;IACnD,OAAO,SAAS,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC/C,CAAC;AALD,gCAKC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Indicates that an object is most likely just an object literal.
3
+ */
4
+ export declare function isPlainObject(obj: any): boolean;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPlainObject = void 0;
4
+ /**
5
+ * Indicates that an object is most likely just an object literal.
6
+ */
7
+ function isPlainObject(obj) {
8
+ return typeof obj === 'object' && (obj === null || obj === void 0 ? void 0 : obj.__proto__) === Object.prototype;
9
+ }
10
+ exports.isPlainObject = isPlainObject;
11
+ //# sourceMappingURL=isPlainObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isPlainObject.js","sourceRoot":"","sources":["../../src/util/isPlainObject.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,aAAa,CAAC,GAAQ;IACpC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,SAAS,MAAK,MAAM,CAAC,SAAS,CAAC;AACxE,CAAC;AAFD,sCAEC"}
@@ -0,0 +1,8 @@
1
+ export declare function mapObjectRecursive(object: any, map: (key: string | number, value: any, object: any, context: any) => Record<string | number, any>, context?: any): {};
2
+ /**
3
+ * Invokes `map` on each key/value pair in `object`. The key/value pair is deleted from the object and replaced by
4
+ * merging in the object returned from `map`. Recursively descends into all object and array values.
5
+ * The `map` function will receive the key, the value, the current object being mapped, and a context object.
6
+ * The context object is a plain object that you can modify as needed. The value will persist to subsequent calls to
7
+ * `map` on child properties of `value`.
8
+ */
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapObjectRecursive = void 0;
4
+ const isPlainObject_1 = require("./isPlainObject");
5
+ function mapObjectRecursive(object, map, context = {}) {
6
+ const clone = Array.isArray(object) ? [] : {};
7
+ for (const k of Object.keys(object)) {
8
+ let key = k;
9
+ const value = object[key];
10
+ if (Array.isArray(object))
11
+ key = +key;
12
+ const contextClone = Object.assign({}, context);
13
+ let result = map(key, value, object, contextClone);
14
+ if (typeof result !== 'undefined' && typeof result !== 'object' && !Array.isArray(result))
15
+ throw new Error('mapObjectRecursive: return value of map function must be undefined, object, or array!');
16
+ if (typeof result === 'undefined') {
17
+ result = { [key]: value };
18
+ }
19
+ for (const kk in result) {
20
+ let value = result[kk];
21
+ if (isPlainObject_1.isPlainObject(value) || Array.isArray(value))
22
+ value = mapObjectRecursive(value, map, contextClone);
23
+ if (typeof value !== 'undefined')
24
+ clone[kk] = value;
25
+ }
26
+ }
27
+ return clone;
28
+ }
29
+ exports.mapObjectRecursive = mapObjectRecursive;
30
+ /**
31
+ * Invokes `map` on each key/value pair in `object`. The key/value pair is deleted from the object and replaced by
32
+ * merging in the object returned from `map`. Recursively descends into all object and array values.
33
+ * The `map` function will receive the key, the value, the current object being mapped, and a context object.
34
+ * The context object is a plain object that you can modify as needed. The value will persist to subsequent calls to
35
+ * `map` on child properties of `value`.
36
+ */
37
+ // export function mapObjectRecursive(
38
+ // object: any,
39
+ // map: (
40
+ // key: string | number,
41
+ // value: any,
42
+ // object: any,
43
+ // context: any,
44
+ // ) => Record<string | number, any>,
45
+ // ): any {
46
+ // return _mapObjectRecursive(object, map, {});
47
+ // }
48
+ //# sourceMappingURL=mapObjectRecursive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapObjectRecursive.js","sourceRoot":"","sources":["../../src/util/mapObjectRecursive.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAEhD,SAAgB,kBAAkB,CAChC,MAAW,EACX,GAKiC,EACjC,UAAe,EAAE;IAEjB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAE9C,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACnC,IAAI,GAAG,GAAoB,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAE1B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,GAAG,GAAG,CAAC,GAAG,CAAC;QACtC,MAAM,YAAY,qBAAQ,OAAO,CAAE,CAAC;QACpC,IAAI,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;QACnD,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YACvF,MAAM,IAAI,KAAK,CACb,uFAAuF,CACxF,CAAC;QACJ,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;SAC3B;QACD,KAAK,MAAM,EAAE,IAAI,MAAM,EAAE;YACvB,IAAI,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;YACvB,IAAI,6BAAa,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBAC9C,KAAK,GAAG,kBAAkB,CAAC,KAAK,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;YACvD,IAAI,OAAO,KAAK,KAAK,WAAW;gBAAE,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;SACrD;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAnCD,gDAmCC;AAED;;;;;;GAMG;AACH,sCAAsC;AACtC,iBAAiB;AACjB,WAAW;AACX,4BAA4B;AAC5B,kBAAkB;AAClB,mBAAmB;AACnB,oBAAoB;AACpB,uCAAuC;AACvC,WAAW;AACX,iDAAiD;AACjD,IAAI"}
@@ -0,0 +1,5 @@
1
+ export declare function merge<A>(a?: A): A;
2
+ export declare function merge<A, B>(a: A, b: B): A & B;
3
+ export declare function merge<A, B, C>(a: A, b: B, c: C): A & B & C;
4
+ export declare function merge<A, B, C, D>(a: A, b: B, c: C, d: D): A & B & C & D;
5
+ export declare function merge<A, B, C, D, E>(a: A, b: B, c: C, d: D, e: E): A & B & C & D & E;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.merge = void 0;
4
+ const isPlainObject_1 = require("./isPlainObject");
5
+ function merge(...items) {
6
+ items = items.filter((item) => typeof item !== 'undefined' && item !== null);
7
+ if (!(items === null || items === void 0 ? void 0 : items.length))
8
+ return undefined;
9
+ if (items.length === 1)
10
+ return items[0];
11
+ // If items are not all objects/arrays, return the last object/array if possible, otherwise last non-undefined value
12
+ if (!items.every((item) => Array.isArray(item) || isPlainObject_1.isPlainObject(item))) {
13
+ items.reverse();
14
+ return (items.find((item) => Array.isArray(item) || isPlainObject_1.isPlainObject(item)) ||
15
+ items.find((item) => typeof item !== 'undefined'));
16
+ }
17
+ const merged = Array.isArray(items[0]) ? [] : {};
18
+ for (const item of items) {
19
+ if (!Array.isArray(item) && !isPlainObject_1.isPlainObject(item))
20
+ return merged;
21
+ const keys = [...Object.keys(item), ...Object.getOwnPropertySymbols(item)];
22
+ for (const key of keys) {
23
+ const result = merge(merged[key], item[key]);
24
+ if (typeof result !== 'undefined')
25
+ merged[key] = result;
26
+ }
27
+ }
28
+ return merged;
29
+ }
30
+ exports.merge = merge;
31
+ //# sourceMappingURL=merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/util/merge.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAQhD,SAAgB,KAAK,CAAC,GAAG,KAAwB;IAC/C,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC;IAC7E,IAAI,EAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAA;QAAE,OAAO,SAAS,CAAC;IAErC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAExC,oHAAoH;IACpH,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,6BAAa,CAAC,IAAI,CAAC,CAAC,EAAE;QACtE,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,OAAO,CACL,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,6BAAa,CAAC,IAAI,CAAC,CAAC;YAChE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,WAAW,CAAC,CAClD,CAAC;KACH;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,6BAAa,CAAC,IAAI,CAAC;YAAE,OAAO,MAAM,CAAC;QAEhE,MAAM,IAAI,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3E,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAC7C,IAAI,OAAO,MAAM,KAAK,WAAW;gBAAE,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;SACzD;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AA1BD,sBA0BC"}
@@ -0,0 +1,3 @@
1
+ import { useLayoutEffect } from 'react';
2
+ declare const useIsoLayoutEffect: typeof useLayoutEffect;
3
+ export default useIsoLayoutEffect;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ const useIsoLayoutEffect = typeof window !== 'undefined' ? react_1.useLayoutEffect : react_1.useEffect;
5
+ exports.default = useIsoLayoutEffect;
6
+ //# sourceMappingURL=useIsoLayoutEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsoLayoutEffect.js","sourceRoot":"","sources":["../../src/util/useIsoLayoutEffect.ts"],"names":[],"mappings":";;AAAA,iCAAmD;AAEnD,MAAM,kBAAkB,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,uBAAe,CAAC,CAAC,CAAC,iBAAS,CAAC;AAEvF,kBAAe,kBAAkB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Invokes a callback for each key/value pair in `object`, and continues recursively on each value that is an array or a
3
+ * plain object. Returns `object`.
4
+ * The `cb` function will receive the key, the value, the current object being mapped, and a context object.
5
+ * The context object is a plain object that you can modify as needed. The value will persist to subsequent calls to
6
+ * `map` on child properties of `value`.
7
+ */
8
+ export declare function walkRecursive<T = any>(object: T, cb: (key: string, value: any, currentObject: any, context: any) => void, context?: any): T;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.walkRecursive = void 0;
4
+ const cloneDeep_1 = require("./cloneDeep");
5
+ const isPlainObject_1 = require("./isPlainObject");
6
+ /**
7
+ * Invokes a callback for each key/value pair in `object`, and continues recursively on each value that is an array or a
8
+ * plain object. Returns `object`.
9
+ * The `cb` function will receive the key, the value, the current object being mapped, and a context object.
10
+ * The context object is a plain object that you can modify as needed. The value will persist to subsequent calls to
11
+ * `map` on child properties of `value`.
12
+ */
13
+ function walkRecursive(object, cb, context) {
14
+ const keys = Object.keys(object);
15
+ for (const key of keys) {
16
+ const value = object[key];
17
+ cb(key, value, object, context);
18
+ if (Array.isArray(value) || isPlainObject_1.isPlainObject(value)) {
19
+ const contextClone = cloneDeep_1.cloneDeep(context);
20
+ walkRecursive(value, cb, contextClone);
21
+ }
22
+ }
23
+ return object;
24
+ }
25
+ exports.walkRecursive = walkRecursive;
26
+ //# sourceMappingURL=walkRecursive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walkRecursive.js","sourceRoot":"","sources":["../../src/util/walkRecursive.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,mDAAgD;AAEhD;;;;;;GAMG;AACH,SAAgB,aAAa,CAC3B,MAAS,EACT,EAAuE,EACvE,OAAa;IAEb,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,6BAAa,CAAC,KAAK,CAAC,EAAE;YAChD,MAAM,YAAY,GAAG,qBAAS,CAAC,OAAO,CAAC,CAAC;YACxC,aAAa,CAAC,KAAK,EAAE,EAAE,EAAE,YAAY,CAAC,CAAC;SACxC;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAfD,sCAeC"}
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@stylix/core",
3
+ "version": "3.1.0",
4
+ "description": "React, with style. Add styles to your React apps with props: the easy, natural, and low learning curve approach.",
5
+ "keywords": [
6
+ "react",
7
+ "styles",
8
+ "css",
9
+ "css-in-js",
10
+ "emotion",
11
+ "styled-components"
12
+ ],
13
+ "main": "dist/index.js",
14
+ "types": "dist/index.d.ts",
15
+ "scripts": {
16
+ "build": "npm run clean && tsc",
17
+ "start": "tsc --watch",
18
+ "test": "jest",
19
+ "clean": "rm -rf dist",
20
+ "prettier": "prettier --write .",
21
+ "eslint": "eslint --ext=.ts,.tsx,.js,.jsx ./src",
22
+ "eslint:fix": "eslint --fix --ext=.ts,.tsx,.js,.jsx ./src",
23
+ "prepare": "husky install && rm -rf .git/hooks && ln -s ../.husky .git/hooks"
24
+ },
25
+ "author": "Alex Brombal",
26
+ "license": "MIT",
27
+ "homepage": "https://stylix.dev/",
28
+ "bugs": "https://github.com/brombal/stylix/issues",
29
+ "repository": "https://github.com/brombal/stylix",
30
+ "devDependencies": {
31
+ "@types/jest": "^26.0.22",
32
+ "@types/node": "^14.14.20",
33
+ "@types/react": "^17.0.0",
34
+ "@types/react-dom": "^17.0.0",
35
+ "@typescript-eslint/eslint-plugin": "^4.12.0",
36
+ "@typescript-eslint/parser": "^4.12.0",
37
+ "eslint": "^7.17.0",
38
+ "eslint-config-prettier": "^7.1.0",
39
+ "eslint-plugin-prettier": "^3.3.1",
40
+ "eslint-plugin-react": "^7.22.0",
41
+ "eslint-plugin-simple-import-sort": "^7.0.0",
42
+ "eslint-plugin-unused-imports": "^1.0.1",
43
+ "husky": "^6.0.0",
44
+ "jest": "^26.6.3",
45
+ "lint-staged": "^10.5.3",
46
+ "prettier": "^2.2.1",
47
+ "ts-jest": "^26.5.1",
48
+ "typescript": "^4.1.3"
49
+ },
50
+ "peerDependencies": {
51
+ "react": ">=16.8.0",
52
+ "react-dom": ">=16.8.0"
53
+ },
54
+ "lint-staged": {
55
+ "**/*.{md,json}": [
56
+ "prettier --embedded-language-formatting off --write"
57
+ ],
58
+ "src/**/*.{js,jsx,ts,tsx}": [
59
+ "eslint"
60
+ ]
61
+ },
62
+ "files": [
63
+ "dist/*"
64
+ ]
65
+ }