@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,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultPixelUnits = exports.defaultUnits = exports.defaultIgnoreUnits = void 0;
4
+ const mapObjectRecursive_1 = require("../util/mapObjectRecursive");
5
+ exports.defaultIgnoreUnits = [
6
+ 'columns',
7
+ 'column-count',
8
+ 'fill-opacity',
9
+ 'flex',
10
+ 'flex-grow',
11
+ 'flex-shrink',
12
+ 'font-weight',
13
+ 'line-height',
14
+ 'opacity',
15
+ 'orphans',
16
+ 'stroke-opacity',
17
+ 'widows',
18
+ 'z-index',
19
+ 'zoom',
20
+ 'order',
21
+ ];
22
+ /**
23
+ * Adds unit (px, em, etc) to numeric values for any style properties not included in `ignoreProps`..
24
+ */
25
+ const defaultUnits = (unit = 'px', ignoreProps = exports.defaultIgnoreUnits) => {
26
+ return {
27
+ name: 'defaultUnits',
28
+ type: 'processStyles',
29
+ plugin(ctx, styles) {
30
+ return mapObjectRecursive_1.mapObjectRecursive(styles, defaultUnitsMap, { unit, ignoreProps });
31
+ },
32
+ };
33
+ };
34
+ exports.defaultUnits = defaultUnits;
35
+ const defaultUnitsMap = (key, value, object, ctx) => {
36
+ if (typeof value === 'number' && !ctx.ignoreProps.includes(key)) {
37
+ return { [key]: String(value) + ctx.unit };
38
+ }
39
+ };
40
+ exports.defaultPixelUnits = exports.defaultUnits();
41
+ //# sourceMappingURL=defaultUnits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultUnits.js","sourceRoot":"","sources":["../../src/plugins/defaultUnits.ts"],"names":[],"mappings":";;;AAAA,mEAAgE;AAGnD,QAAA,kBAAkB,GAAG;IAChC,SAAS;IACT,cAAc;IACd,cAAc;IACd,MAAM;IACN,WAAW;IACX,aAAa;IACb,aAAa;IACb,aAAa;IACb,SAAS;IACT,SAAS;IACT,gBAAgB;IAChB,QAAQ;IACR,SAAS;IACT,MAAM;IACN,OAAO;CACR,CAAC;AAEF;;GAEG;AACI,MAAM,YAAY,GAAG,CAAC,IAAI,GAAG,IAAI,EAAE,WAAW,GAAG,0BAAkB,EAAgB,EAAE;IAC1F,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,eAAe;QACrB,MAAM,CAAC,GAAG,EAAE,MAAW;YACrB,OAAO,uCAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;QAC5E,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,YAAY,gBAQvB;AAEF,MAAM,eAAe,GAAG,CAAC,GAAoB,EAAE,KAAU,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;IACxE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAa,CAAC,EAAE;QACzE,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;KAC5C;AACH,CAAC,CAAC;AAEW,QAAA,iBAAiB,GAAG,oBAAY,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { StylixPlugin } from './index';
2
+ /**
3
+ * Flattens nested style objects that use `&` to reference parent class.
4
+ */
5
+ export declare const flattenNestedStyles: StylixPlugin;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flattenNestedStyles = void 0;
4
+ const isPlainObject_1 = require("../util/isPlainObject");
5
+ const flatten = function flatten(styles, parent, selector, root, mediaRoot) {
6
+ for (let key in styles) {
7
+ const value = styles[key];
8
+ if (key.startsWith('@media')) {
9
+ // Flatten media queries, but nest them under the root object
10
+ root[key] = root[key] || {};
11
+ flatten(value, root[key], selector, root, root[key]);
12
+ }
13
+ else if (key.startsWith('@keyframes')) {
14
+ // Add keyframe rules as-is directly to mediaRoot object
15
+ mediaRoot[key] = value;
16
+ }
17
+ else if (isPlainObject_1.isPlainObject(styles[key])) {
18
+ // Concatenate or replace & in selectors and then continue flattening styles
19
+ if (key.includes('&')) {
20
+ key = key.replace(/&/g, selector);
21
+ }
22
+ else {
23
+ key = (selector + ' ' + key).trim();
24
+ }
25
+ parent[key] = parent[key] || {};
26
+ flatten(value, parent, key, root, mediaRoot);
27
+ }
28
+ else {
29
+ // Selector is just a css property
30
+ parent[selector] = parent[selector] || {};
31
+ parent[selector][key] = styles[key];
32
+ }
33
+ }
34
+ };
35
+ /**
36
+ * Flattens nested style objects that use `&` to reference parent class.
37
+ */
38
+ exports.flattenNestedStyles = {
39
+ name: 'flattenNestedStyles',
40
+ type: 'processStyles',
41
+ plugin(ctx, styles) {
42
+ const flattened = {};
43
+ flatten(styles, flattened, '', flattened, flattened);
44
+ return flattened;
45
+ },
46
+ };
47
+ //# sourceMappingURL=flattenNestedStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flattenNestedStyles.js","sourceRoot":"","sources":["../../src/plugins/flattenNestedStyles.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAGtD,MAAM,OAAO,GAAG,SAAS,OAAO,CAC9B,MAAW,EACX,MAAW,EACX,QAAgB,EAChB,IAAS,EACT,SAAc;IAEd,KAAK,IAAI,GAAG,IAAI,MAAM,EAAE;QACtB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;YAC5B,6DAA6D;YAC7D,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CA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context object
4
+ */
5
+ export declare type StylixPluginFunctionContext = StylixPublicContext & {
6
+ hash: string;
7
+ };
8
+ /**
9
+ * Stylix plugin interface
10
+ */
11
+ export interface StylixPlugin {
12
+ name: string;
13
+ type: 'initialize' | 'processStyles' | 'preprocessStyles';
14
+ plugin(ctx: StylixPluginFunctionContext, styles: any): any;
15
+ before?: StylixPlugin;
16
+ after?: StylixPlugin;
17
+ atIndex?: number;
18
+ }
19
+ export declare function applyPlugins(type: StylixPlugin['type'], styles: any, hash: string, context: StylixContext): any;
20
+ export { customProps } from './customProps';
21
+ export declare const defaultPlugins: {
22
+ themeFunctions: StylixPlugin;
23
+ merge$css: StylixPlugin;
24
+ mediaArrays: StylixPlugin;
25
+ propCasing: StylixPlugin;
26
+ flattenNestedStyles: StylixPlugin;
27
+ replace$$class: StylixPlugin;
28
+ defaultPixelUnits: StylixPlugin;
29
+ cleanStyles: StylixPlugin;
30
+ };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultPlugins = exports.customProps = exports.applyPlugins = void 0;
4
+ const cleanStyles_1 = require("./cleanStyles");
5
+ const defaultUnits_1 = require("./defaultUnits");
6
+ const flattenNestedStyles_1 = require("./flattenNestedStyles");
7
+ const mediaArrays_1 = require("./mediaArrays");
8
+ const merge_css_1 = require("./merge$css");
9
+ const propCasing_1 = require("./propCasing");
10
+ const replace__class_1 = require("./replace$$class");
11
+ const themeFunctions_1 = require("./themeFunctions");
12
+ function applyPlugins(type, styles, hash, context) {
13
+ const pluginContext = {
14
+ id: context.id,
15
+ devMode: context.devMode,
16
+ theme: context.theme,
17
+ media: context.media,
18
+ stylesheet: context.stylesheet,
19
+ styleElement: context.styleElement,
20
+ styleProps: context.styleProps,
21
+ hash,
22
+ };
23
+ let processedStyles = styles;
24
+ for (const i in context.plugins) {
25
+ const plugin = context.plugins[i];
26
+ if (plugin.type === type)
27
+ processedStyles = plugin.plugin(pluginContext, processedStyles);
28
+ }
29
+ return processedStyles;
30
+ }
31
+ exports.applyPlugins = applyPlugins;
32
+ var customProps_1 = require("./customProps");
33
+ Object.defineProperty(exports, "customProps", { enumerable: true, get: function () { return customProps_1.customProps; } });
34
+ exports.defaultPlugins = {
35
+ themeFunctions: themeFunctions_1.themeFunctions,
36
+ merge$css: merge_css_1.merge$css,
37
+ mediaArrays: mediaArrays_1.mediaArrays,
38
+ propCasing: propCasing_1.propCasing,
39
+ flattenNestedStyles: flattenNestedStyles_1.flattenNestedStyles,
40
+ replace$$class: replace__class_1.replace$$class,
41
+ defaultPixelUnits: defaultUnits_1.defaultPixelUnits,
42
+ cleanStyles: cleanStyles_1.cleanStyles,
43
+ };
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAC5C,iDAAmD;AACnD,+DAA4D;AAC5D,+CAA4C;AAC5C,2CAAwC;AACxC,6CAA0C;AAC1C,qDAAkD;AAClD,qDAAkD;AAmBlD,SAAgB,YAAY,CAC1B,IAA0B,EAC1B,MAAW,EACX,IAAY,EACZ,OAAsB;IAEtB,MAAM,aAAa,GAAG;QACpB,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,IAAI;KACL,CAAC;IAEF,IAAI,eAAe,GAAG,MAAM,CAAC;IAC7B,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE;QAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClC,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;YAAE,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;KAC3F;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAvBD,oCAuBC;AAED,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AAEP,QAAA,cAAc,GAAG;IAC5B,cAAc,EAAd,+BAAc;IACd,SAAS,EAAT,qBAAS;IACT,WAAW,EAAX,yBAAW;IACX,UAAU,EAAV,uBAAU;IACV,mBAAmB,EAAnB,yCAAmB;IACnB,cAAc,EAAd,+BAAc;IACd,iBAAiB,EAAjB,gCAAiB;IACjB,WAAW,EAAX,yBAAW;CACZ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { StylixPlugin } from './index';
2
+ /**
3
+ * Expands arrays as media queries.
4
+ */
5
+ export declare const mediaArrays: StylixPlugin;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mediaArrays = void 0;
4
+ const isPlainObject_1 = require("../util/isPlainObject");
5
+ const mapObjectRecursive_1 = require("../util/mapObjectRecursive");
6
+ const mapDittoValues = (key, value) => {
7
+ if (Array.isArray(value)) {
8
+ for (const i in value) {
9
+ const v = value[i];
10
+ if (v === '@')
11
+ value[i] = value[+i - 1];
12
+ }
13
+ return { [key]: value };
14
+ }
15
+ };
16
+ const mapNonMedia = (key, value, object, context) => {
17
+ if (Array.isArray(value)) {
18
+ return { [key]: value[context.i] };
19
+ }
20
+ };
21
+ const mapMediaStyles = (key, value, object, context) => {
22
+ if (key.startsWith('@keyframes'))
23
+ context.keyframes = true;
24
+ if (Array.isArray(value)) {
25
+ return { [key]: value[context.i] };
26
+ }
27
+ if (isPlainObject_1.isPlainObject(value) || context.keyframes) {
28
+ return;
29
+ }
30
+ // delete key/value pair if primitive
31
+ return { [key]: undefined };
32
+ };
33
+ /**
34
+ * Expands arrays as media queries.
35
+ */
36
+ exports.mediaArrays = {
37
+ name: 'mediaArrays',
38
+ type: 'processStyles',
39
+ plugin(ctx, styles) {
40
+ // Fill out ditto values
41
+ styles = mapObjectRecursive_1.mapObjectRecursive(styles, mapDittoValues);
42
+ const mediaStyles = {};
43
+ let nonMediaStyles = styles;
44
+ for (const i in ctx.media) {
45
+ const mediaQuery = ctx.media[i];
46
+ if (!mediaQuery) {
47
+ nonMediaStyles = mapObjectRecursive_1.mapObjectRecursive(styles, mapNonMedia, { i });
48
+ }
49
+ else {
50
+ mediaStyles[`@media ${mediaQuery}`] = mapObjectRecursive_1.mapObjectRecursive(styles, mapMediaStyles, { i });
51
+ }
52
+ }
53
+ return Object.assign(Object.assign({}, nonMediaStyles), mediaStyles);
54
+ },
55
+ };
56
+ //# sourceMappingURL=mediaArrays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mediaArrays.js","sourceRoot":"","sources":["../../src/plugins/mediaArrays.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AACtD,mEAAgE;AAGhE,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;IACpC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;YACrB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACnB,IAAI,CAAC,KAAK,GAAG;gBAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;SACzC;QACD,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;KACzB;AACH,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;IAClD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;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CAAC"}
@@ -0,0 +1,6 @@
1
+ import { StylixPlugin } from './index';
2
+ export declare function _merge$css(obj: any, ctx: any): void;
3
+ /**
4
+ * Merges $css property into parent styles
5
+ */
6
+ export declare const merge$css: StylixPlugin;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.merge$css = exports._merge$css = void 0;
4
+ const flatten_1 = require("../util/flatten");
5
+ const isPlainObject_1 = require("../util/isPlainObject");
6
+ function _merge$css(obj, ctx) {
7
+ if (!isPlainObject_1.isPlainObject(obj))
8
+ return;
9
+ for (const key in obj) {
10
+ if (key === '$css') {
11
+ const $css = obj[key];
12
+ if (Array.isArray($css)) {
13
+ const flat$css = flatten_1.flatten($css);
14
+ for (const val of flat$css) {
15
+ _merge$css(val, ctx);
16
+ }
17
+ }
18
+ else {
19
+ _merge$css($css, ctx);
20
+ }
21
+ }
22
+ else {
23
+ let value = obj[key];
24
+ if (isPlainObject_1.isPlainObject(value)) {
25
+ value = ctx[key] || {};
26
+ _merge$css(obj[key], value);
27
+ }
28
+ ctx[key] = value;
29
+ }
30
+ }
31
+ }
32
+ exports._merge$css = _merge$css;
33
+ /**
34
+ * Merges $css property into parent styles
35
+ */
36
+ exports.merge$css = {
37
+ name: 'merge$css',
38
+ type: 'processStyles',
39
+ plugin(ctx, styles) {
40
+ const result = {};
41
+ _merge$css(styles, result);
42
+ return result;
43
+ },
44
+ };
45
+ //# sourceMappingURL=merge$css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge$css.js","sourceRoot":"","sources":["../../src/plugins/merge$css.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAC1C,yDAAsD;AAGtD,SAAgB,UAAU,CAAC,GAAQ,EAAE,GAAQ;IAC3C,IAAI,CAAC,6BAAa,CAAC,GAAG,CAAC;QAAE,OAAO;IAChC,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;QACrB,IAAI,GAAG,KAAK,MAAM,EAAE;YAClB,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACtB,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACvB,MAAM,QAAQ,GAAG,iBAAO,CAAC,IAAI,CAAC,CAAC;gBAC/B,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;oBAC1B,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;iBACtB;aACF;iBAAM;gBACL,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;aACvB;SACF;aAAM;YACL,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACrB,IAAI,6BAAa,CAAC,KAAK,CAAC,EAAE;gBACxB,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;gBACvB,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;aAC7B;YACD,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SAClB;KACF;AACH,CAAC;AAtBD,gCAsBC;AAED;;GAEG;AACU,QAAA,SAAS,GAAiB;IACrC,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,eAAe;IACrB,MAAM,CAAC,GAAgC,EAAE,MAAW;QAClD,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { StylixPlugin } from './index';
2
+ /**
3
+ * Fixes casing and hyphenation on known style props
4
+ */
5
+ export declare const propCasing: StylixPlugin;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.propCasing = void 0;
4
+ const classifyProps_1 = require("../classifyProps");
5
+ const mapObjectRecursive_1 = require("../util/mapObjectRecursive");
6
+ /**
7
+ * Fixes casing and hyphenation on known style props
8
+ */
9
+ exports.propCasing = {
10
+ name: 'normalizeStyleProps',
11
+ type: 'processStyles',
12
+ plugin(ctx, styles) {
13
+ return mapObjectRecursive_1.mapObjectRecursive(styles, (key, value) => {
14
+ if (typeof key === 'string' && ctx.styleProps[classifyProps_1.simplifyStylePropName(key)]) {
15
+ return { [ctx.styleProps[classifyProps_1.simplifyStylePropName(key)]]: value };
16
+ }
17
+ });
18
+ },
19
+ };
20
+ const propCasingMap = (key, value, object, context) => {
21
+ if (typeof key === 'string' && context.ctx.styleProps[classifyProps_1.simplifyStylePropName(key)]) {
22
+ return { [context.ctx.styleProps[classifyProps_1.simplifyStylePropName(key)]]: value };
23
+ }
24
+ };
25
+ //# sourceMappingURL=propCasing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propCasing.js","sourceRoot":"","sources":["../../src/plugins/propCasing.ts"],"names":[],"mappings":";;;AAAA,oDAAyD;AACzD,mEAAgE;AAGhE;;GAEG;AACU,QAAA,UAAU,GAAiB;IACtC,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,eAAe;IACrB,MAAM,CAAC,GAAgC,EAAE,MAAW;QAClD,OAAO,uCAAkB,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YAC/C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,UAAU,CAAC,qCAAqB,CAAC,GAAG,CAAC,CAAC,EAAE;gBACzE,OAAO,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,qCAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;aAChE;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;IACpD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,qCAAqB,CAAC,GAAG,CAAC,CAAC,EAAE;QACjF,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,qCAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;KACxE;AACH,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { StylixPlugin } from './index';
2
+ /**
3
+ * Replaces $$class with hash in string values
4
+ */
5
+ export declare const replace$$class: StylixPlugin;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.replace$$class = void 0;
4
+ const mapObjectRecursive_1 = require("../util/mapObjectRecursive");
5
+ /**
6
+ * Replaces $$class with hash in string values
7
+ */
8
+ exports.replace$$class = {
9
+ name: 'replace$$class',
10
+ type: 'processStyles',
11
+ plugin(ctx, styles) {
12
+ return mapObjectRecursive_1.mapObjectRecursive(styles, replace$$classMap, { ctx });
13
+ },
14
+ };
15
+ const replace$$classMap = (key, value, object, context) => {
16
+ value = typeof value === 'string' ? value.replace('$$class', context.ctx.hash) : value;
17
+ key = typeof key === 'string' ? key.replace('$$class', context.ctx.hash) : key;
18
+ return { [key]: value };
19
+ };
20
+ //# sourceMappingURL=replace$$class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace$$class.js","sourceRoot":"","sources":["../../src/plugins/replace$$class.ts"],"names":[],"mappings":";;;AAAA,mEAAgE;AAGhE;;GAEG;AACU,QAAA,cAAc,GAAiB;IAC1C,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE,eAAe;IACrB,MAAM,CAAC,GAAgC,EAAE,MAAW;QAClD,OAAO,uCAAkB,CAAC,MAAM,EAAE,iBAAiB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAChE,CAAC;CACF,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;IACxD,KAAK,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACvF,GAAG,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC/E,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;AAC1B,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { StylixPlugin } from './index';
2
+ /**
3
+ * Evaluates functions in style objects, providing the theme and media from the current Stylix context.
4
+ */
5
+ export declare const themeFunctions: StylixPlugin;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.themeFunctions = void 0;
4
+ const mapObjectRecursive_1 = require("../util/mapObjectRecursive");
5
+ /**
6
+ * Evaluates functions in style objects, providing the theme and media from the current Stylix context.
7
+ */
8
+ exports.themeFunctions = {
9
+ name: 'themeFunctions',
10
+ type: 'preprocessStyles',
11
+ plugin(ctx, styles) {
12
+ return mapObjectRecursive_1.mapObjectRecursive(styles, themeFunctionsMap, { ctx });
13
+ },
14
+ };
15
+ const themeFunctionsMap = (key, value, object, context) => {
16
+ if (typeof value === 'function') {
17
+ return { [key]: value(context.ctx.theme, context.ctx) };
18
+ }
19
+ };
20
+ //# sourceMappingURL=themeFunctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"themeFunctions.js","sourceRoot":"","sources":["../../src/plugins/themeFunctions.ts"],"names":[],"mappings":";;;AAAA,mEAAgE;AAGhE;;GAEG;AACU,QAAA,cAAc,GAAiB;IAC1C,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE,kBAAkB;IACxB,MAAM,CAAC,GAAgC,EAAE,MAAW;QAClD,OAAO,uCAAkB,CAAC,MAAM,EAAE,iBAAiB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAChE,CAAC;CACF,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;IACxD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;QAC/B,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;KACzD;AACH,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export interface StyleCollector {
3
+ collect: (element: React.ReactElement) => React.ReactElement;
4
+ render: React.FC<React.ComponentProps<'style'>>;
5
+ styles: string[];
6
+ }
7
+ export declare const styleCollectorContext: React.Context<string[]>;
8
+ export declare function createStyleCollector(): StyleCollector;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.createStyleCollector = exports.styleCollectorContext = void 0;
23
+ const react_1 = __importStar(require("react"));
24
+ exports.styleCollectorContext = react_1.createContext(null);
25
+ function createStyleCollector() {
26
+ const styles = [];
27
+ const collector = {
28
+ collect: (element) => (react_1.default.createElement(exports.styleCollectorContext.Provider, { value: styles }, element)),
29
+ render: (props) => (react_1.default.createElement("style", Object.assign({ type: "text/css", key: props.id || 'stylix' }, props, { dangerouslySetInnerHTML: { __html: collector.styles.join(' ') } }))),
30
+ styles,
31
+ };
32
+ collector.render.displayName = 'StylixStyleCollectorRenderer';
33
+ return collector;
34
+ }
35
+ exports.createStyleCollector = createStyleCollector;
36
+ //# sourceMappingURL=styleCollector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styleCollector.js","sourceRoot":"","sources":["../src/styleCollector.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA6C;AAQhC,QAAA,qBAAqB,GAAG,qBAAa,CAAW,IAAI,CAAC,CAAC;AAEnE,SAAgB,oBAAoB;IAClC,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,SAAS,GAAmB;QAChC,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CACpB,8BAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,IAAG,OAAO,CAAkC,CAC1F;QACD,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CACjB,uDACE,IAAI,EAAC,UAAU,EACf,GAAG,EAAE,KAAK,CAAC,EAAE,IAAI,QAAQ,IACrB,KAAK,IACT,uBAAuB,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAC/D,CACH;QACD,MAAM;KACP,CAAC;IACF,SAAS,CAAC,MAAM,CAAC,WAAW,GAAG,8BAA8B,CAAC;IAC9D,OAAO,SAAS,CAAC;AACnB,CAAC;AAlBD,oDAkBC"}
@@ -0,0 +1,5 @@
1
+ import { StylixContext } from './StylixProvider';
2
+ /**
3
+ * Converts a Stylix CSS object to an array of rules, suitable for passing to StyleSheet#insertRule.
4
+ */
5
+ export default function stylesToRuleArray(styles: any, hash: string, context: StylixContext): string[];
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const plugins_1 = require("./plugins");
4
+ const isPlainObject_1 = require("./util/isPlainObject");
5
+ /**
6
+ * Converts a Stylix CSS object to an array of rules, suitable for passing to StyleSheet#insertRule.
7
+ */
8
+ function stylesToRuleArray(styles, hash, context) {
9
+ try {
10
+ const processedStyles = plugins_1.applyPlugins('processStyles', styles, hash, context);
11
+ // serialize to css rules array
12
+ const serialize = function serialize(selector, styles) {
13
+ const lines = [];
14
+ for (const key in styles) {
15
+ const value = styles[key];
16
+ if (isPlainObject_1.isPlainObject(value))
17
+ lines.push(serialize(key, value));
18
+ else
19
+ lines.push(` ${key}: ${value};`);
20
+ }
21
+ return `${selector} {\n${lines.join('\n')} }`;
22
+ };
23
+ const result = [];
24
+ for (const key in processedStyles) {
25
+ const value = processedStyles[key];
26
+ result.push(serialize(key, value));
27
+ }
28
+ return result;
29
+ }
30
+ catch (e) {
31
+ if (e.name && e.reason) {
32
+ console.error(`${e.name}: ${e.reason}\n`, e.source.replace('\n', ' ').substr(Math.max(0, e.column - 20), 100) + '\n', ' '.repeat(20) + '^');
33
+ }
34
+ else {
35
+ console.error(e);
36
+ }
37
+ return [];
38
+ }
39
+ }
40
+ exports.default = stylesToRuleArray;
41
+ //# sourceMappingURL=stylesToRuleArray.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stylesToRuleArray.js","sourceRoot":"","sources":["../src/stylesToRuleArray.ts"],"names":[],"mappings":";;AAAA,uCAAyC;AAEzC,wDAAqD;AAErD;;GAEG;AACH,SAAwB,iBAAiB,CACvC,MAAW,EACX,IAAY,EACZ,OAAsB;IAEtB,IAAI;QACF,MAAM,eAAe,GAAG,sBAAY,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAE7E,+BAA+B;QAC/B,MAAM,SAAS,GA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H,CAAC;AArCD,oCAqCC"}
@@ -0,0 +1,76 @@
1
+ import React, { CSSProperties } from 'react';
2
+ export declare type StylixValue<T> = T | Array<T | '@'> | ((theme: any, media: string[]) => T | Array<T | '@'>);
3
+ /**
4
+ * All standard CSS properties, custom style props, and the $css prop.
5
+ */
6
+ declare type StylixStyleProps = {
7
+ /**
8
+ * Additional styles.
9
+ */
10
+ $css?: any;
11
+ /**
12
+ * Disables Stylix for the current element.
13
+ */
14
+ $disabled?: boolean;
15
+ } & {
16
+ [key in keyof CSSProperties]?: StylixValue<CSSProperties[key]>;
17
+ } & {
18
+ [key in keyof StylixPropsExtensions]?: StylixValue<key extends keyof StylixPropsExtensions ? StylixPropsExtensions[key] : never>;
19
+ };
20
+ /**
21
+ * Allows users to add custom props to Stylix components:
22
+ *
23
+ * declare module 'stylix' {
24
+ * interface StylixStyleProperties {
25
+ * ...
26
+ * }
27
+ * }
28
+ */
29
+ export interface StylixPropsExtensions {
30
+ }
31
+ /**
32
+ * A component's props, without properties that conflict with style properties.
33
+ */
34
+ declare type ComponentPropsWithoutStyles<TComponent extends React.ElementType> = Omit<React.ComponentPropsWithRef<TComponent>, keyof StylixStyleProps>;
35
+ /**
36
+ * Allows users to define components that accept Stylix style props.
37
+ */
38
+ export declare type StylixProps<ElType extends React.ElementType = any> = ComponentPropsWithoutStyles<ElType> & StylixStyleProps;
39
+ /**
40
+ * Additional properties on Stylix component functions.
41
+ */
42
+ declare type StylixComponentMeta = {
43
+ displayName?: string;
44
+ __isStylix: true;
45
+ };
46
+ export declare type StylixWrappedComponentProps<TComponent extends React.ElementType> = ComponentPropsWithoutStyles<TComponent> & StylixStyleProps;
47
+ export declare type StylixWrappedComponent<TComponent extends React.ElementType, TAdditionalProps = unknown> = React.FunctionComponent<TAdditionalProps & StylixWrappedComponentProps<TComponent>> & StylixComponentMeta;
48
+ /**
49
+ * Props for main Stylix component (<$>)
50
+ * `TComponent` is determined automatically by the type of $el.
51
+ * <$ $el={...}>...</$>
52
+ */
53
+ export declare type Stylix$Props<TComponent extends React.ElementType | React.ReactElement> = {
54
+ /**
55
+ * Specifies the element to render.
56
+ */
57
+ $el: TComponent;
58
+ } & ComponentPropsWithoutStyles<TComponent extends React.ElementType ? TComponent : TComponent extends React.ReactElement<infer P> ? P : never> & StylixStyleProps;
59
+ /**
60
+ * Type of main Stylix component ($)
61
+ */
62
+ export declare type Stylix$Component = {
63
+ /**
64
+ * This is equivalent to React.FunctionComponent, but must be specified explicitly this way to allow
65
+ * TComponent to be generic here and not directly on Stylix$Component, so that it can be inferred at the time
66
+ * the component is used.
67
+ */
68
+ <TComponent extends React.ElementType | React.ReactElement>(props: Stylix$Props<TComponent>, context?: any): React.ReactElement<any, any> | null;
69
+ /**
70
+ * Type for the $.styled() helper function.
71
+ */
72
+ styled: <TComponent extends React.ElementType, TPropMap extends Record<string, string> = Record<string, never>>($el: TComponent, conflictingPropMapping?: TPropMap) => StylixWrappedComponent<TComponent, Record<keyof TPropMap, any>>;
73
+ } & StylixComponentMeta & {
74
+ [key in keyof JSX.IntrinsicElements]: StylixWrappedComponent<key>;
75
+ };
76
+ export {};
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Accepts a Stylix CSS object and returns a unique className based on the styles' hash.
3
+ * The styles are registered with the Stylix context and will be applied to the document.
4
+ * If `global` is false, provided styles will be nested within the generated classname.
5
+ * Returns the className hash if enabled, or an empty string.
6
+ */
7
+ export declare function useStyles(styles: any, options?: {
8
+ global?: boolean;
9
+ disabled?: boolean;
10
+ }): string;
11
+ export declare function useKeyframes(keyframes: any, options?: {
12
+ disabled?: boolean;
13
+ }): string;
14
+ export declare function useGlobalStyles(styles: any, options?: {
15
+ disabled?: boolean;
16
+ }): string;