@codeleap/styles 7.0.0 → 7.0.2

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 (95) hide show
  1. package/dist/classes/Cacher.js +170 -0
  2. package/dist/classes/Cacher.js.map +1 -0
  3. package/dist/classes/StaleControl.js +105 -0
  4. package/dist/classes/StaleControl.js.map +1 -0
  5. package/dist/classes/StyleCache.js +95 -0
  6. package/dist/classes/StyleCache.js.map +1 -0
  7. package/dist/classes/StylePersistor.js +58 -0
  8. package/dist/classes/StylePersistor.js.map +1 -0
  9. package/dist/classes/StyleRegistry.js +474 -0
  10. package/dist/classes/StyleRegistry.js.map +1 -0
  11. package/dist/classes/index.js +19 -0
  12. package/dist/classes/index.js.map +1 -0
  13. package/dist/constants.js +27 -0
  14. package/dist/constants.js.map +1 -0
  15. package/dist/hooks/index.js +21 -0
  16. package/dist/hooks/index.js.map +1 -0
  17. package/dist/hooks/useCompositionStyles.js +30 -0
  18. package/dist/hooks/useCompositionStyles.js.map +1 -0
  19. package/dist/hooks/useNestedStylesByKey.js +20 -0
  20. package/dist/hooks/useNestedStylesByKey.js.map +1 -0
  21. package/dist/hooks/useStyleObserver.js +26 -0
  22. package/dist/hooks/useStyleObserver.js.map +1 -0
  23. package/dist/hooks/useTheme.js +28 -0
  24. package/dist/hooks/useTheme.js.map +1 -0
  25. package/dist/index.js +28 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/lib/calc.js +48 -0
  28. package/dist/lib/calc.js.map +1 -0
  29. package/dist/lib/createStyles.js +63 -0
  30. package/dist/lib/createStyles.js.map +1 -0
  31. package/dist/lib/createTheme.js +147 -0
  32. package/dist/lib/createTheme.js.map +1 -0
  33. package/dist/lib/cssVariables.js +79 -0
  34. package/dist/lib/cssVariables.js.map +1 -0
  35. package/dist/lib/index.js +18 -0
  36. package/dist/lib/index.js.map +1 -0
  37. package/dist/theme/generateColorScheme.js +41 -0
  38. package/dist/theme/generateColorScheme.js.map +1 -0
  39. package/dist/theme/index.js +20 -0
  40. package/dist/theme/index.js.map +1 -0
  41. package/dist/theme/themeStore.d.ts +4 -4
  42. package/dist/theme/themeStore.d.ts.map +1 -1
  43. package/dist/theme/themeStore.js +143 -0
  44. package/dist/theme/themeStore.js.map +1 -0
  45. package/dist/theme/validateTheme.js +36 -0
  46. package/dist/theme/validateTheme.js.map +1 -0
  47. package/dist/tools/colors.js +147 -0
  48. package/dist/tools/colors.js.map +1 -0
  49. package/dist/tools/deepClone.js +14 -0
  50. package/dist/tools/deepClone.js.map +1 -0
  51. package/dist/tools/deepmerge.js +20 -0
  52. package/dist/tools/deepmerge.js.map +1 -0
  53. package/dist/tools/hashKey.js +20 -0
  54. package/dist/tools/hashKey.js.map +1 -0
  55. package/dist/tools/index.js +46 -0
  56. package/dist/tools/index.js.map +1 -0
  57. package/dist/tools/minifier.js +39 -0
  58. package/dist/tools/minifier.js.map +1 -0
  59. package/dist/tools/multiplierProperty.js +12 -0
  60. package/dist/tools/multiplierProperty.js.map +1 -0
  61. package/dist/types/cache.js +3 -0
  62. package/dist/types/cache.js.map +1 -0
  63. package/dist/types/component.js +3 -0
  64. package/dist/types/component.js.map +1 -0
  65. package/dist/types/core.js +4 -0
  66. package/dist/types/core.js.map +1 -0
  67. package/dist/types/icon.js +4 -0
  68. package/dist/types/icon.js.map +1 -0
  69. package/dist/types/index.js +22 -0
  70. package/dist/types/index.js.map +1 -0
  71. package/dist/types/spacing.js +31 -0
  72. package/dist/types/spacing.js.map +1 -0
  73. package/dist/types/store.js +3 -0
  74. package/dist/types/store.js.map +1 -0
  75. package/dist/types/style.js +3 -0
  76. package/dist/types/style.js.map +1 -0
  77. package/dist/types/theme.js +3 -0
  78. package/dist/types/theme.js.map +1 -0
  79. package/dist/utils.js +105 -0
  80. package/dist/utils.js.map +1 -0
  81. package/dist/variants/borderCreator.js +30 -0
  82. package/dist/variants/borderCreator.js.map +1 -0
  83. package/dist/variants/createAppVariants.js +20 -0
  84. package/dist/variants/createAppVariants.js.map +1 -0
  85. package/dist/variants/defaultVariants.js +140 -0
  86. package/dist/variants/defaultVariants.js.map +1 -0
  87. package/dist/variants/dynamicVariants.js +93 -0
  88. package/dist/variants/dynamicVariants.js.map +1 -0
  89. package/dist/variants/index.js +23 -0
  90. package/dist/variants/index.js.map +1 -0
  91. package/dist/variants/mediaQuery.js +59 -0
  92. package/dist/variants/mediaQuery.js.map +1 -0
  93. package/dist/variants/spacing.js +84 -0
  94. package/dist/variants/spacing.js.map +1 -0
  95. package/package.json +3 -3
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/types/theme.ts"],"names":[],"mappings":""}
package/dist/utils.js ADDED
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.concatStyles = exports.ignoredStyleKeys = exports.mergeStyles = exports.spacingKeys = void 0;
4
+ exports.capitalize = capitalize;
5
+ exports.isSpacingKey = isSpacingKey;
6
+ exports.getNestedStylesByKey = getNestedStylesByKey;
7
+ const spacing_1 = require("./types/spacing");
8
+ const tools_1 = require("./tools");
9
+ /**
10
+ * Uppercases (or lowercases when `reverse = true`) the first character of a string.
11
+ * Returns the input unchanged when it is falsy or empty.
12
+ */
13
+ function capitalize(str, reverse = false) {
14
+ if (!(str === null || str === void 0 ? void 0 : str.length))
15
+ return str;
16
+ const firstChar = reverse ? str[0].toLowerCase() : str[0].toUpperCase();
17
+ return firstChar + str.substring(1);
18
+ }
19
+ /**
20
+ * Complete list of CSS/RN spacing-related property names that the style registry treats
21
+ * specially (resolved via the spacing factory rather than passed through as raw ICSS).
22
+ * Built eagerly at module load time by iterating `spacingVariants` and `spacingShortVariants`.
23
+ */
24
+ exports.spacingKeys = [
25
+ 'gap',
26
+ 'top',
27
+ 'left',
28
+ 'right',
29
+ 'bottom',
30
+ ];
31
+ for (const longProperty of ['padding', 'margin']) {
32
+ for (const variant of spacing_1.spacingVariants) {
33
+ exports.spacingKeys.push(`${longProperty}${capitalize(variant)}`);
34
+ }
35
+ }
36
+ for (const shortProperty of ['p', 'm']) {
37
+ for (const shortVariant of spacing_1.spacingShortVariants) {
38
+ exports.spacingKeys.push(shortProperty + shortVariant);
39
+ }
40
+ }
41
+ /** Returns `true` if `key` is one of the pre-built spacing property names. */
42
+ function isSpacingKey(key) {
43
+ if (!key)
44
+ return false;
45
+ return exports.spacingKeys === null || exports.spacingKeys === void 0 ? void 0 : exports.spacingKeys.includes(key);
46
+ }
47
+ /**
48
+ * Extracts all entries whose key starts with `match`, stripping the prefix and
49
+ * lowercasing the first character of the remainder. Used by composition hooks to
50
+ * slice a flat `{ wrapperText: ..., wrapperIcon: ... }` record into a nested
51
+ * `{ text: ..., icon: ... }` map for a single composition element.
52
+ */
53
+ function getNestedStylesByKey(match, styles) {
54
+ const stylesByKey = {};
55
+ for (const [key, value] of Object.entries(styles)) {
56
+ if (key.startsWith(match)) {
57
+ const partName = capitalize(key.replace(match, ''), true);
58
+ stylesByKey[partName] = value;
59
+ }
60
+ }
61
+ return stylesByKey;
62
+ }
63
+ /**
64
+ * Merges an array of style objects into one using `@fastify/deepmerge` with `all: true`.
65
+ * Falsy entries are filtered out before merging. Later entries overwrite earlier ones.
66
+ */
67
+ const mergeStyles = (styles) => {
68
+ const style = styles === null || styles === void 0 ? void 0 : styles.filter(s => !!s);
69
+ return (0, tools_1.deepmerge)({ all: true })(...style);
70
+ };
71
+ exports.mergeStyles = mergeStyles;
72
+ /**
73
+ * Style property names that collide with CSS keywords and must not be treated as
74
+ * composition-element prefixes by the registry. Without this list, a style object
75
+ * like `{ textAlign: 'center' }` would be misidentified as a composition key starting
76
+ * with `text`.
77
+ */
78
+ exports.ignoredStyleKeys = [
79
+ 'textAlign',
80
+ 'textDecoration',
81
+ 'textOverflow',
82
+ 'left',
83
+ 'top',
84
+ 'right',
85
+ 'bottom',
86
+ ];
87
+ /**
88
+ * Flattens nested arrays of `StyledProp` into a single flat array. Useful when
89
+ * assembling the final `style` prop from multiple sources (e.g., variant defaults
90
+ * plus overrides), without losing the order-dependent merge semantics of `StyleProp`.
91
+ */
92
+ const concatStyles = (styles) => {
93
+ const results = [];
94
+ for (const style of styles) {
95
+ if (Array.isArray(style)) {
96
+ results.push(...style);
97
+ }
98
+ else {
99
+ results.push(style);
100
+ }
101
+ }
102
+ return results;
103
+ };
104
+ exports.concatStyles = concatStyles;
105
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAQA,gCAIC;AA4BD,oCAIC;AAQD,oDAWC;AA9DD,6CAAuE;AACvE,mCAAmC;AAEnC;;;GAGG;AACH,SAAgB,UAAU,CAAC,GAAW,EAAE,OAAO,GAAG,KAAK;IACrD,IAAI,CAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,CAAA;QAAE,OAAO,GAAG,CAAA;IAC5B,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IACvE,OAAO,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;AACrC,CAAC;AAED;;;;GAIG;AACU,QAAA,WAAW,GAAG;IACzB,KAAK;IACL,KAAK;IACL,MAAM;IACN,OAAO;IACP,QAAQ;CACT,CAAA;AAED,KAAK,MAAM,YAAY,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC;IACjD,KAAK,MAAM,OAAO,IAAI,yBAAe,EAAE,CAAC;QACtC,mBAAW,CAAC,IAAI,CAAC,GAAG,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,C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,eAIvB;AAED;;;;;GAKG;AACU,QAAA,gBAAgB,GAAG;IAC9B,WAAW;IACX,gBAAgB;IAChB,cAAc;IACd,MAAM;IACN,KAAK;IACL,OAAO;IACP,QAAQ;CACT,CAAA;AAED;;;;GAIG;AACI,MAAM,YAAY,GAAG,CAAmB,MAA4B,EAAiB,EAAE;IAC5F,MAAM,OAAO,GAAG,EAAE,CAAA;IAElB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;QACxB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC;IACH,CAAC;IAED,OAAO,OAAmC,CAAA;AAC5C,CAAC,CAAA;AAZY,QAAA,YAAY,gBAYxB"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.borderCreator = void 0;
4
+ const theme_1 = require("../theme");
5
+ const utils_1 = require("../utils");
6
+ /**
7
+ * Resolves `color` from `theme.colors` (falls back to the raw string if not found),
8
+ * then emits `border{Direction}Color`, `border{Direction}Width`, and — on web only —
9
+ * `border{Direction}Style` for each requested direction.
10
+ * Defaults: all four sides, width 1, style `'solid'`.
11
+ * `borderStyle` is omitted on React Native because RN requires it on individual sides
12
+ * and `isBrowser` guards that path.
13
+ */
14
+ const borderCreator = (args) => {
15
+ var _a, _b;
16
+ const { color: colorKey, width = 1, style = 'solid', directions = ['left', 'top', 'bottom', 'right'], } = args;
17
+ const theme = theme_1.themeStore.themeTyped;
18
+ const color = (_b = (_a = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _a === void 0 ? void 0 : _a[colorKey]) !== null && _b !== void 0 ? _b : colorKey;
19
+ let borderStyles = {};
20
+ for (const direction of directions) {
21
+ const property = `border${(0, utils_1.capitalize)(direction)}`;
22
+ borderStyles[`${property}Color`] = color;
23
+ borderStyles[`${property}Width`] = width;
24
+ if (theme === null || theme === void 0 ? void 0 : theme.isBrowser)
25
+ borderStyles[`${property}Style`] = style;
26
+ }
27
+ return borderStyles;
28
+ };
29
+ exports.borderCreator = borderCreator;
30
+ //# sourceMappingURL=borderCreator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"borderCreator.js","sourceRoot":"","sources":["../../src/variants/borderCreator.ts"],"names":[],"mappings":";;;AAEA,oCAAqC;AACrC,oCAAqC;AAarC;;;;;;;GAOG;AACI,MAAM,aAAa,GAAkB,CAAC,IAAI,EAAE,EAAE;;IACnD,MAAM,EACJ,KAAK,EAAE,QAAQ,EACf,KAAK,GAAG,CAAC,EACT,KAAK,GAAG,OAAO,EACf,UAAU,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,GAChD,GAAG,IAAI,CAAA;IAER,MAAM,KAAK,GAAG,kBAAU,CAAC,UAAU,CAAA;IAEnC,MAAM,KAAK,GAAG,MAAA,MAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAA8B,0CAAG,QAAQ,CAAC,mCAAI,QAAQ,CAAA;IAE5E,IAAI,YAAY,GAAwB,EAAE,CAAA;IAE1C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,SAAS,IAAA,kBAAU,EAAC,SAAS,CAAC,EAAE,CAAA;QAEjD,YAAY,CAAC,GAAG,QAAQ,OAAO,CAAC,GAAG,KAAK,CAAA;QACxC,YAAY,CAAC,GAAG,QAAQ,OAAO,CAAC,GAAG,KAAK,CAAA;QACxC,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS;YAAE,YAAY,CAAC,GAAG,QAAQ,OAAO,CAAC,GAAG,KAAK,CAAA;IAChE,CAAC;IAED,OAAO,YAAoB,CAAA;AAC7B,CAAC,CAAA;AAvBY,QAAA,aAAa,iBAuBzB"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAppVariants = createAppVariants;
4
+ const theme_1 = require("../theme");
5
+ /**
6
+ * Registers app-specific style variants with the global `themeStore`.
7
+ * Call this once during app initialisation (before any component mounts) with the
8
+ * variants object that extends the base variant set. The variants are merged into
9
+ * `commonVariants` when `CodeleapStyleRegistry` initialises.
10
+ *
11
+ * Each entry can be either a static `ICSS` object (applied unconditionally) or a
12
+ * function `(theme: ITheme) => ICSS` (resolved lazily using the current theme).
13
+ *
14
+ * @returns The same `variants` object — useful for typing augmentation of `IAppVariants`.
15
+ */
16
+ function createAppVariants(variants) {
17
+ theme_1.themeStore.setVariants(variants);
18
+ return variants;
19
+ }
20
+ //# sourceMappingURL=createAppVariants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAppVariants.js","sourceRoot":"","sources":["../../src/variants/createAppVariants.ts"],"names":[],"mappings":";;AAkBA,8CAIC;AArBD,oCAAqC;AAMrC;;;;;;;;;;GAUG;AACH,SAAgB,iBAAiB,CAA2B,QAAW;IACrE,kBAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;IAEhC,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultVariants = void 0;
4
+ /**
5
+ * Static built-in style variants available to every component without any registration.
6
+ * These are merged as the lowest-priority layer in `commonVariants`, so app-defined
7
+ * variants and dynamic variants can override them.
8
+ *
9
+ * Notable entries:
10
+ * - `grow` — sets `flex: 1` (not `display: flex`; use `row`/`column` for flex containers).
11
+ * - `inset` — shorthand for `{ top:0, bottom:0, left:0, right:0 }` (useful with `absolute`).
12
+ * - `insetX` / `insetY` — pin to horizontal or vertical edges only.
13
+ * - `centerChildren` — centers children via `alignItems`/`justifyContent`; requires a flex container.
14
+ * - `'visibility:hidden'` / `'display:none'` — use quoted keys in style arrays.
15
+ */
16
+ exports.defaultVariants = {
17
+ block: {
18
+ display: 'block',
19
+ },
20
+ grow: {
21
+ flex: 1,
22
+ },
23
+ absolute: {
24
+ position: 'absolute',
25
+ },
26
+ relative: {
27
+ position: 'relative',
28
+ },
29
+ fixed: {
30
+ position: 'fixed',
31
+ },
32
+ sticky: {
33
+ position: 'sticky',
34
+ },
35
+ insetX: {
36
+ left: 0,
37
+ right: 0,
38
+ },
39
+ insetY: {
40
+ top: 0,
41
+ bottom: 0,
42
+ },
43
+ full: {
44
+ width: '100%',
45
+ height: '100%',
46
+ },
47
+ noWrap: {
48
+ whiteSpace: 'nowrap',
49
+ },
50
+ fullWidth: {
51
+ width: '100%',
52
+ },
53
+ fullHeight: {
54
+ height: '100%',
55
+ },
56
+ inset: {
57
+ top: 0,
58
+ bottom: 0,
59
+ left: 0,
60
+ right: 0,
61
+ },
62
+ centerRow: {
63
+ display: 'flex',
64
+ flexDirection: 'row',
65
+ alignItems: 'center',
66
+ },
67
+ row: {
68
+ display: 'flex',
69
+ flexDirection: 'row',
70
+ },
71
+ column: {
72
+ display: 'flex',
73
+ flexDirection: 'column',
74
+ },
75
+ centerChildren: {
76
+ alignItems: 'center',
77
+ justifyContent: 'center',
78
+ },
79
+ alignStart: {
80
+ alignItems: 'flex-start',
81
+ },
82
+ alignEnd: {
83
+ alignItems: 'flex-end',
84
+ },
85
+ alignCenter: {
86
+ alignItems: 'center',
87
+ },
88
+ alignStretch: {
89
+ alignItems: 'stretch',
90
+ },
91
+ alignSelfCenter: {
92
+ alignSelf: 'center',
93
+ },
94
+ alignSelfStart: {
95
+ alignSelf: 'flex-start',
96
+ },
97
+ alignSelfStretch: {
98
+ alignSelf: 'stretch',
99
+ },
100
+ alignSelfEnd: {
101
+ alignSelf: 'flex-end',
102
+ },
103
+ justifyStart: {
104
+ justifyContent: 'flex-start',
105
+ },
106
+ justifyEnd: {
107
+ justifyContent: 'flex-end',
108
+ },
109
+ justifyCenter: {
110
+ justifyContent: 'center',
111
+ },
112
+ justifySpaceBetween: {
113
+ justifyContent: 'space-between',
114
+ },
115
+ justifySpaceAround: {
116
+ justifyContent: 'space-around',
117
+ },
118
+ textRight: {
119
+ textAlign: 'right',
120
+ },
121
+ textLeft: {
122
+ textAlign: 'left',
123
+ },
124
+ textCenter: {
125
+ textAlign: 'center',
126
+ },
127
+ flexWrap: {
128
+ flexWrap: 'wrap',
129
+ },
130
+ 'visibility:hidden': {
131
+ visibility: 'hidden'
132
+ },
133
+ 'visibility:visible': {
134
+ visibility: 'visible'
135
+ },
136
+ 'display:none': {
137
+ display: 'none'
138
+ }
139
+ };
140
+ //# sourceMappingURL=defaultVariants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultVariants.js","sourceRoot":"","sources":["../../src/variants/defaultVariants.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AACU,QAAA,eAAe,GAAG;IAC7B,KAAK,EAAE;QACL,OAAO,EAAE,OAAO;KACjB;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,CAAC;KACR;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,UAAU;KACrB;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,UAAU;KACrB;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,OAAO;KAClB;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,QAAQ;KACnB;IACD,MAAM,EAAE;QACN,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;KACT;IACD,MAAM,EAAE;QACN,GAAG,EAAE,CAAC;QACN,MAAM,EAAE,CAAC;KACV;IAED,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;KACf;IACD,MAAM,EAAE;QACN,UAAU,EAAE,QAAQ;KACrB;IACD,SAAS,EAAE;QACT,KAAK,EAAE,MAAM;KACd;IACD,UAAU,EAAE;QACV,MAAM,EAAE,MAAM;KACf;IACD,KAAK,EAAE;QACL,GAAG,EAAE,CAAC;QACN,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,oBAAoB,EAAE;QACpB,UAAU,EAAE,SAAS;KACtB;IACD,cAAc,EAAE;QACd,OAAO,EAAC,MAAM;KACf;CACO,CAAA"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dynamicVariants = exports.createDynamicVariants = exports.cursorTypes = exports.borderProperties = exports.borderDirection = exports.borderYDirection = exports.borderXDirection = exports.colorVariants = void 0;
4
+ const utils_1 = require("../utils");
5
+ /** CSS properties that accept a color token: `backgroundColor` and `color`. */
6
+ exports.colorVariants = ['backgroundColor', 'color'];
7
+ /** Horizontal border directions used when generating per-corner radius variants. */
8
+ exports.borderXDirection = ['left', 'right'];
9
+ /** Vertical border directions used when generating per-corner radius variants. */
10
+ exports.borderYDirection = ['bottom', 'top'];
11
+ /** All four border directions plus the un-suffixed (all-sides) form. */
12
+ exports.borderDirection = [...exports.borderYDirection, ...exports.borderXDirection, ''];
13
+ /** Border sub-properties generated for each direction. */
14
+ exports.borderProperties = ['color', 'radius', 'width'];
15
+ /** CSS cursor values surfaced as `cursor:<value>` style variants. */
16
+ exports.cursorTypes = [
17
+ 'not-allowed',
18
+ 'help',
19
+ 'pointer',
20
+ 'wait',
21
+ '',
22
+ ];
23
+ /**
24
+ * Builds the dynamic variant registry object at module initialisation time.
25
+ * Each entry is a function `(theme, value) => ICSS` keyed by the variant name
26
+ * (the part before `:` in the variant string). The registry is consumed by
27
+ * `CodeleapStyleRegistry.computeCommonVariantStyle`.
28
+ */
29
+ const createDynamicVariants = () => {
30
+ const dynamicVariants = {};
31
+ function createVariant(variantName, variantReturn) {
32
+ dynamicVariants[variantName] = variantReturn;
33
+ }
34
+ exports.colorVariants.forEach(variant => {
35
+ createVariant(variant, (theme, color) => ({
36
+ [variant]: theme.colors[color],
37
+ }));
38
+ });
39
+ exports.borderDirection.forEach(direction => {
40
+ if (exports.borderYDirection.includes(direction)) {
41
+ exports.borderXDirection.forEach(y => {
42
+ const variant = `border${(0, utils_1.capitalize)(direction)}${(0, utils_1.capitalize)(y)}Radius`;
43
+ createVariant(variant, (theme, value) => ({
44
+ [variant]: theme.radius[value],
45
+ }));
46
+ });
47
+ }
48
+ exports.borderProperties.forEach(property => {
49
+ const variant = `border${(0, utils_1.capitalize)(direction)}${(0, utils_1.capitalize)(property)}`;
50
+ createVariant(variant, (theme, value) => ({
51
+ [variant]: property == 'color' ? theme.colors[value] : theme.radius[value],
52
+ }));
53
+ });
54
+ });
55
+ exports.borderXDirection.forEach(x => {
56
+ const variant = `border${(0, utils_1.capitalize)(x)}Radius`;
57
+ createVariant(variant, (theme, value) => ({
58
+ [variant]: theme.radius[value],
59
+ }));
60
+ });
61
+ exports.borderYDirection.forEach(y => {
62
+ const variant = `border${(0, utils_1.capitalize)(y)}Radius`;
63
+ createVariant(variant, (theme, value) => ({
64
+ [variant]: theme.radius[value],
65
+ }));
66
+ });
67
+ createVariant('cursor', (theme, cursor) => ({ cursor }));
68
+ createVariant('bg', (theme, color) => ({
69
+ backgroundColor: theme.colors[color],
70
+ }));
71
+ createVariant('effect', (theme, effect) => theme.effects[effect]);
72
+ createVariant('scale', (theme, value) => ({
73
+ transform: theme.isBrowser ? `scale(${value})` : [{ 'scale': Number(value) }],
74
+ }));
75
+ createVariant('br', (theme, value) => ({
76
+ borderRadius: theme.radius[value],
77
+ }));
78
+ createVariant('borderRadius', (theme, value) => ({
79
+ borderRadius: theme.radius[value],
80
+ }));
81
+ createVariant('size', (theme, value) => ({
82
+ height: theme.size[value],
83
+ width: theme.size[value],
84
+ }));
85
+ return dynamicVariants;
86
+ };
87
+ exports.createDynamicVariants = createDynamicVariants;
88
+ /**
89
+ * Pre-built dynamic variant registry used by the `CodeleapStyleRegistry`.
90
+ * Created once at module load; re-creation would lose the closed-over variant map.
91
+ */
92
+ exports.dynamicVariants = (0, exports.createDynamicVariants)();
93
+ //# sourceMappingURL=dynamicVariants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamicVariants.js","sourceRoot":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EAAE,CAAC,CAAC;QACnF,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;QACzB,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;KACzB,CAAC,CAAC,CAAA;IAEH,OAAO,eAAe,CAAA;AACxB,CAAC,CAAA;AA9EY,QAAA,qBAAqB,yBA8EjC;AAED;;;GAGG;AACU,QAAA,eAAe,GAAG,IAAA,6BAAqB,GAAE,CAAA"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./borderCreator"), exports);
18
+ __exportStar(require("./createAppVariants"), exports);
19
+ __exportStar(require("./defaultVariants"), exports);
20
+ __exportStar(require("./dynamicVariants"), exports);
21
+ __exportStar(require("./mediaQuery"), exports);
22
+ __exportStar(require("./spacing"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/variants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,sDAAmC;AACnC,oDAAiC;AACjC,oDAAiC;AACjC,+CAA4B;AAC5B,4CAAyB"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMediaQueries = createMediaQueries;
4
+ function getBreakpointValue(breakpoint, breakpoints) {
5
+ if (breakpoints[breakpoint]) {
6
+ return breakpoints[breakpoint];
7
+ }
8
+ return Infinity;
9
+ }
10
+ /**
11
+ * Produces a `MediaQueries` object bound to the provided `breakpoints` map.
12
+ * Unknown breakpoints (not in the map) fall back to `Infinity`, making `up(unknown)`
13
+ * match all widths and `down(unknown)` match none.
14
+ */
15
+ function createMediaQueries(breakpoints) {
16
+ function getBreakpoint(breakpoint) {
17
+ return getBreakpointValue(breakpoint, breakpoints);
18
+ }
19
+ const queries = {
20
+ up: (breakpoint) => {
21
+ // Upwards of... (excluding)
22
+ const min = getBreakpoint(breakpoint);
23
+ return `@media screen and (min-width:${min}px)`;
24
+ },
25
+ down: (breakpoint) => {
26
+ // Downwards of... (excluding)
27
+ const max = getBreakpoint(breakpoint);
28
+ return `@media screen and (max-width:${max}px)`;
29
+ },
30
+ is: (breakpoint) => {
31
+ // Is media... (exact)
32
+ const value = getBreakpoint(breakpoint);
33
+ return `@media screen and (min-width:${value}px) and (max-width:${value}px)`;
34
+ },
35
+ not: (breakpoint) => {
36
+ // Is NOT media... (exact)
37
+ const value = getBreakpoint(breakpoint);
38
+ return `@media not screen and (min-width:${value}px) and (max-width:${value}px)`;
39
+ },
40
+ };
41
+ const renderToPlatformQuery = (props) => {
42
+ let query = '';
43
+ if (props === null || props === void 0 ? void 0 : props.is) {
44
+ query = queries.not(props.is);
45
+ }
46
+ else if (props === null || props === void 0 ? void 0 : props.not) {
47
+ query = queries.is(props.not);
48
+ }
49
+ else if (props === null || props === void 0 ? void 0 : props.up) {
50
+ query = queries.down(props.up);
51
+ }
52
+ else if (props === null || props === void 0 ? void 0 : props.down) {
53
+ query = queries.up(props.down);
54
+ }
55
+ return query;
56
+ };
57
+ return Object.assign(Object.assign({}, queries), { renderToPlatformQuery });
58
+ }
59
+ //# sourceMappingURL=mediaQuery.js.map
@@ -0,0 +1 @@
1
+ {"version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AK,aAAL,KAAK,uBAAL,KAAK,CAAE,EAAE,EAAE,CAAC;YACd,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAW,CAAC,CAAA;QACxC,CAAC;aAAM,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,GAAG,EAAE,CAAC;YACtB,KAAK,GAAG,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,GAAY,CAAC,CAAA;QACxC,CAAC;aAAM,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,EAAE,EAAE,CAAC;YACrB,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAW,CAAC,CAAA;QACzC,CAAC;aAAM,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,EAAE,CAAC;YACvB,KAAK,GAAG,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,IAAa,CAAC,CAAA;QACzC,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;IAED,uCACK,OAAO,KACV,qBAAqB,IACtB;AACH,CAAC"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.spacingFactory = spacingFactory;
4
+ const spacing_1 = require("../types/spacing");
5
+ const shortMapValues = {
6
+ 'x': 'Horizontal',
7
+ 'y': 'Vertical',
8
+ 'l': 'Left',
9
+ 'r': 'Right',
10
+ 't': 'Top',
11
+ 'b': 'Bottom',
12
+ 'm': 'margin',
13
+ 'p': 'padding'
14
+ };
15
+ const shortPositionMap = {
16
+ 'x': 'Horizontal',
17
+ 'y': 'Vertical',
18
+ 'l': 'Left',
19
+ 'r': 'Right',
20
+ 't': 'Top',
21
+ 'b': 'Bottom'
22
+ };
23
+ /**
24
+ * Builds a spacing variant map for a CSS property (`'padding'`, `'margin'`, `'p'`, `'m'`).
25
+ * Each key in the returned object is a callable that multiplies its argument by `base`.
26
+ * Passing `isShort = true` uses single-letter direction suffixes and maps them to their
27
+ * long-form equivalents before producing the CSS property name.
28
+ * The `'Horizontal'` and `'Vertical'` (or `'x'`/`'y'`) directions expand to two
29
+ * properties each; the empty-string direction produces all four sides at once.
30
+ */
31
+ function spacingFactory(base, spacingProperty, isShort = false) {
32
+ const baseProperty = isShort ? shortMapValues[spacingProperty] : spacingProperty;
33
+ const positions = isShort ? spacing_1.spacingShortVariants : spacing_1.spacingVariants;
34
+ const spacings = {
35
+ [`${spacingProperty}`]: (n) => {
36
+ if (n === 'auto') {
37
+ return { [baseProperty]: 'auto' };
38
+ }
39
+ return { [baseProperty]: base * Number(n) };
40
+ },
41
+ };
42
+ for (const _position of positions) {
43
+ const position = isShort
44
+ ? shortPositionMap[_position] || _position
45
+ : _position;
46
+ const key = `${spacingProperty}${_position}`;
47
+ let getter = null;
48
+ switch (position) {
49
+ case 'Horizontal':
50
+ getter = (value) => ({
51
+ [`${baseProperty}Left`]: value,
52
+ [`${baseProperty}Right`]: value,
53
+ });
54
+ break;
55
+ case 'Vertical':
56
+ getter = (value) => ({
57
+ [`${baseProperty}Top`]: value,
58
+ [`${baseProperty}Bottom`]: value,
59
+ });
60
+ break;
61
+ case '':
62
+ getter = (value) => ({
63
+ [`${baseProperty}Top`]: value,
64
+ [`${baseProperty}Right`]: value,
65
+ [`${baseProperty}Bottom`]: value,
66
+ [`${baseProperty}Left`]: value,
67
+ });
68
+ break;
69
+ default:
70
+ getter = (value) => ({
71
+ [`${baseProperty}${position}`]: value,
72
+ });
73
+ break;
74
+ }
75
+ spacings[key] = (n) => {
76
+ if (n === 'auto')
77
+ return getter('auto');
78
+ const value = base * Number(n);
79
+ return getter(value);
80
+ };
81
+ }
82
+ return spacings;
83
+ }
84
+ //# sourceMappingURL=spacing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spacing.js","sourceRoot":"","sources":["../../src/variants/spacing.ts"],"names":[],"mappings":";;AA+CA,wCA8DC;AA5GD,8CAA+G;AAkB/G,MAAM,cAAc,GAAG;I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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codeleap/styles",
3
- "version": "7.0.0",
4
- "main": "src/index.ts",
3
+ "version": "7.0.2",
4
+ "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
7
7
  ".": {
@@ -22,7 +22,7 @@
22
22
  "directory": "packages/styles"
23
23
  },
24
24
  "devDependencies": {
25
- "@codeleap/config": "7.0.0",
25
+ "@codeleap/config": "7.0.1",
26
26
  "ts-node-dev": "^1.1.8"
27
27
  },
28
28
  "scripts": {