@animus-ui/theming 0.1.1-beta.24 → 0.1.1-beta.26

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/CHANGELOG.md CHANGED
@@ -3,206 +3,114 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [0.1.1-beta.24](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.23...@animus-ui/theming@0.1.1-beta.24) (2023-03-15)
6
+ ## [0.1.1-beta.26](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.25...@animus-ui/theming@0.1.1-beta.26) (2025-05-29)
7
7
 
8
8
  **Note:** Version bump only for package @animus-ui/theming
9
9
 
10
+ ## [0.1.1-beta.25](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.24...@animus-ui/theming@0.1.1-beta.25) (2023-03-15)
10
11
 
12
+ **Note:** Version bump only for package @animus-ui/theming
11
13
 
14
+ ## [0.1.1-beta.24](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.23...@animus-ui/theming@0.1.1-beta.24) (2023-03-15)
12
15
 
16
+ **Note:** Version bump only for package @animus-ui/theming
13
17
 
14
18
  ## [0.1.1-beta.23](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.21...@animus-ui/theming@0.1.1-beta.23) (2023-03-13)
15
19
 
16
20
  **Note:** Version bump only for package @animus-ui/theming
17
21
 
18
-
19
-
20
-
21
-
22
22
  ## [0.1.1-beta.22](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.21...@animus-ui/theming@0.1.1-beta.22) (2022-03-25)
23
23
 
24
24
  **Note:** Version bump only for package @animus-ui/theming
25
25
 
26
-
27
-
28
-
29
-
30
26
  ## [0.1.1-beta.21](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.20...@animus-ui/theming@0.1.1-beta.21) (2022-02-14)
31
27
 
32
28
  **Note:** Version bump only for package @animus-ui/theming
33
29
 
34
-
35
-
36
-
37
-
38
30
  ## [0.1.1-beta.20](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.19...@animus-ui/theming@0.1.1-beta.20) (2022-02-14)
39
31
 
40
32
  **Note:** Version bump only for package @animus-ui/theming
41
33
 
42
-
43
-
44
-
45
-
46
34
  ## [0.1.1-beta.19](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.18...@animus-ui/theming@0.1.1-beta.19) (2022-02-12)
47
35
 
48
36
  **Note:** Version bump only for package @animus-ui/theming
49
37
 
50
-
51
-
52
-
53
-
54
38
  ## [0.1.1-beta.18](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.17...@animus-ui/theming@0.1.1-beta.18) (2022-02-11)
55
39
 
56
40
  **Note:** Version bump only for package @animus-ui/theming
57
41
 
58
-
59
-
60
-
61
-
62
42
  ## [0.1.1-beta.17](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.16...@animus-ui/theming@0.1.1-beta.17) (2022-02-02)
63
43
 
64
44
  **Note:** Version bump only for package @animus-ui/theming
65
45
 
66
-
67
-
68
-
69
-
70
46
  ## [0.1.1-beta.16](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.15...@animus-ui/theming@0.1.1-beta.16) (2022-02-02)
71
47
 
72
48
  **Note:** Version bump only for package @animus-ui/theming
73
49
 
74
-
75
-
76
-
77
-
78
50
  ## [0.1.1-beta.15](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.14...@animus-ui/theming@0.1.1-beta.15) (2022-01-26)
79
51
 
80
52
  **Note:** Version bump only for package @animus-ui/theming
81
53
 
82
-
83
-
84
-
85
-
86
54
  ## [0.1.1-beta.14](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.13...@animus-ui/theming@0.1.1-beta.14) (2022-01-24)
87
55
 
88
56
  **Note:** Version bump only for package @animus-ui/theming
89
57
 
90
-
91
-
92
-
93
-
94
58
  ## [0.1.1-beta.13](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.12...@animus-ui/theming@0.1.1-beta.13) (2022-01-24)
95
59
 
96
60
  **Note:** Version bump only for package @animus-ui/theming
97
61
 
98
-
99
-
100
-
101
-
102
62
  ## [0.1.1-beta.12](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.11...@animus-ui/theming@0.1.1-beta.12) (2022-01-24)
103
63
 
104
64
  **Note:** Version bump only for package @animus-ui/theming
105
65
 
106
-
107
-
108
-
109
-
110
66
  ## [0.1.1-beta.11](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.10...@animus-ui/theming@0.1.1-beta.11) (2022-01-24)
111
67
 
112
68
  **Note:** Version bump only for package @animus-ui/theming
113
69
 
114
-
115
-
116
-
117
-
118
70
  ## [0.1.1-beta.10](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.9...@animus-ui/theming@0.1.1-beta.10) (2022-01-23)
119
71
 
120
72
  **Note:** Version bump only for package @animus-ui/theming
121
73
 
122
-
123
-
124
-
125
-
126
74
  ## [0.1.1-beta.9](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.8...@animus-ui/theming@0.1.1-beta.9) (2022-01-18)
127
75
 
128
76
  **Note:** Version bump only for package @animus-ui/theming
129
77
 
130
-
131
-
132
-
133
-
134
78
  ## [0.1.1-beta.8](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.7...@animus-ui/theming@0.1.1-beta.8) (2022-01-16)
135
79
 
136
80
  **Note:** Version bump only for package @animus-ui/theming
137
81
 
138
-
139
-
140
-
141
-
142
82
  ## [0.1.1-beta.7](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.6...@animus-ui/theming@0.1.1-beta.7) (2022-01-16)
143
83
 
144
84
  **Note:** Version bump only for package @animus-ui/theming
145
85
 
146
-
147
-
148
-
149
-
150
86
  ## [0.1.1-beta.6](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.5...@animus-ui/theming@0.1.1-beta.6) (2022-01-11)
151
87
 
152
88
  **Note:** Version bump only for package @animus-ui/theming
153
89
 
154
-
155
-
156
-
157
-
158
90
  ## [0.1.1-beta.5](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.4...@animus-ui/theming@0.1.1-beta.5) (2022-01-09)
159
91
 
160
92
  **Note:** Version bump only for package @animus-ui/theming
161
93
 
162
-
163
-
164
-
165
-
166
94
  ## [0.1.1-beta.4](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.3...@animus-ui/theming@0.1.1-beta.4) (2022-01-09)
167
95
 
168
96
  **Note:** Version bump only for package @animus-ui/theming
169
97
 
170
-
171
-
172
-
173
-
174
98
  ## [0.1.1-beta.3](https://github.com/codecaaron/animus/compare/@animus-ui/theming@0.1.1-beta.2...@animus-ui/theming@0.1.1-beta.3) (2022-01-09)
175
99
 
176
100
  **Note:** Version bump only for package @animus-ui/theming
177
101
 
178
-
179
-
180
-
181
-
182
102
  ## 0.1.1-beta.2 (2022-01-09)
183
103
 
184
-
185
-
186
104
  ## 0.1.1-beta.1 (2022-01-09)
187
105
 
188
-
189
-
190
106
  ## 0.1.1-beta.0 (2022-01-09)
191
107
 
192
108
  **Note:** Version bump only for package @animus-ui/theming
193
109
 
194
-
195
-
196
-
197
-
198
110
  ## [0.1.1-beta.1](https://github.com/codecaaron/animus/compare/v0.1.1-beta.0...v0.1.1-beta.1) (2022-01-09)
199
111
 
200
112
  **Note:** Version bump only for package @animus-ui/theming
201
113
 
202
-
203
-
204
-
205
-
206
114
  ## 0.1.1-beta.0 (2022-01-09)
207
115
 
208
116
  **Note:** Version bump only for package @animus-ui/theming
@@ -1,34 +1,34 @@
1
- import { Breakpoints } from '@animus-ui/core';
2
- /**
3
- * 1. Breakpoints
4
- * 2. Scales
5
- * 3. Tokens
6
- * 4. Variables
7
- * 5. Colors
8
- * 6. Color Modes
9
- */
10
- export declare class ThemeWithAll<Bps, Scales, Tokens, Vars> {
11
- breakpoints: Bps;
12
- scales: Scales;
13
- tokens: Tokens;
14
- variables: Vars;
15
- constructor(breakpoints: Bps, scales: Scales, tokens: Tokens, vars: Vars);
16
- addScale(): ThemeWithAll<Bps, Scales, Tokens, Vars>;
17
- build(): {
18
- breakpoints: Bps;
19
- } & Scales & {
20
- _tokens: Tokens;
21
- _variables: Vars;
22
- };
23
- }
24
- export declare class ThemeWithRawColors<Bps extends Breakpoints, Scales, Tokens, Vars> extends ThemeWithAll<Bps, Scales, Tokens, Vars> {
25
- constructor(breakpoints: Bps, scales: Scales, tokens: Tokens, vars: Vars);
26
- addColorModes(): ThemeWithAll<Bps, Scales, Tokens, Vars>;
27
- }
28
- export declare class ThemeWithBreakpoints<Bps extends Breakpoints> extends ThemeWithAll<Bps, {}, {}, {}> {
29
- constructor(breakpoints: Bps);
30
- addColors(): ThemeWithRawColors<Bps, {}, {}, {}>;
31
- }
32
- export declare class ThemeUnitialized {
33
- addBreakpoints<Bps extends Breakpoints>(breakpoints: Bps): ThemeWithBreakpoints<Bps>;
34
- }
1
+ import { Breakpoints } from '@animus-ui/core';
2
+ /**
3
+ * 1. Breakpoints
4
+ * 2. Scales
5
+ * 3. Tokens
6
+ * 4. Variables
7
+ * 5. Colors
8
+ * 6. Color Modes
9
+ */
10
+ export declare class ThemeWithAll<Bps, Scales, Tokens, Vars> {
11
+ breakpoints: Bps;
12
+ scales: Scales;
13
+ tokens: Tokens;
14
+ variables: Vars;
15
+ constructor(breakpoints: Bps, scales: Scales, tokens: Tokens, vars: Vars);
16
+ addScale(): ThemeWithAll<Bps, Scales, Tokens, Vars>;
17
+ build(): {
18
+ breakpoints: Bps;
19
+ } & Scales & {
20
+ _tokens: Tokens;
21
+ _variables: Vars;
22
+ };
23
+ }
24
+ export declare class ThemeWithRawColors<Bps extends Breakpoints, Scales, Tokens, Vars> extends ThemeWithAll<Bps, Scales, Tokens, Vars> {
25
+ constructor(breakpoints: Bps, scales: Scales, tokens: Tokens, vars: Vars);
26
+ addColorModes(): ThemeWithAll<Bps, Scales, Tokens, Vars>;
27
+ }
28
+ export declare class ThemeWithBreakpoints<Bps extends Breakpoints> extends ThemeWithAll<Bps, {}, {}, {}> {
29
+ constructor(breakpoints: Bps);
30
+ addColors(): ThemeWithRawColors<Bps, {}, {}, {}>;
31
+ }
32
+ export declare class ThemeUnitialized {
33
+ addBreakpoints<Bps extends Breakpoints>(breakpoints: Bps): ThemeWithBreakpoints<Bps>;
34
+ }
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './utils';
1
+ export * from './utils';
package/dist/index.js CHANGED
@@ -1,142 +1,111 @@
1
1
  import { isObject, merge, mapValues } from 'lodash';
2
2
 
3
- function ownKeys(object, enumerableOnly) {
4
- var keys = Object.keys(object);
5
- if (Object.getOwnPropertySymbols) {
6
- var symbols = Object.getOwnPropertySymbols(object);
7
- enumerableOnly && (symbols = symbols.filter(function (sym) {
8
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
9
- })), keys.push.apply(keys, symbols);
10
- }
11
- return keys;
3
+ function _assertClassBrand(e, t, n) {
4
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
5
+ throw new TypeError("Private element is not present on this object");
12
6
  }
13
- function _objectSpread2(target) {
14
- for (var i = 1; i < arguments.length; i++) {
15
- var source = null != arguments[i] ? arguments[i] : {};
16
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
17
- _defineProperty(target, key, source[key]);
18
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
19
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
20
- });
21
- }
22
- return target;
7
+ function _checkPrivateRedeclaration(e, t) {
8
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
23
9
  }
24
- function _classCallCheck(instance, Constructor) {
25
- if (!(instance instanceof Constructor)) {
26
- throw new TypeError("Cannot call a class as a function");
27
- }
10
+ function _classCallCheck(a, n) {
11
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
28
12
  }
29
- function _defineProperties(target, props) {
30
- for (var i = 0; i < props.length; i++) {
31
- var descriptor = props[i];
32
- descriptor.enumerable = descriptor.enumerable || false;
33
- descriptor.configurable = true;
34
- if ("value" in descriptor) descriptor.writable = true;
35
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
36
- }
13
+ function _classPrivateFieldGet2(s, a) {
14
+ return s.get(_assertClassBrand(s, a));
37
15
  }
38
- function _createClass(Constructor, protoProps, staticProps) {
39
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
40
- if (staticProps) _defineProperties(Constructor, staticProps);
41
- Object.defineProperty(Constructor, "prototype", {
42
- writable: false
43
- });
44
- return Constructor;
16
+ function _classPrivateFieldInitSpec(e, t, a) {
17
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
45
18
  }
46
- function _defineProperty(obj, key, value) {
47
- key = _toPropertyKey(key);
48
- if (key in obj) {
49
- Object.defineProperty(obj, key, {
50
- value: value,
51
- enumerable: true,
52
- configurable: true,
53
- writable: true
54
- });
55
- } else {
56
- obj[key] = value;
19
+ function _defineProperties(e, r) {
20
+ for (var t = 0; t < r.length; t++) {
21
+ var o = r[t];
22
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
57
23
  }
58
- return obj;
59
24
  }
60
- function _objectWithoutPropertiesLoose(source, excluded) {
61
- if (source == null) return {};
62
- var target = {};
63
- var sourceKeys = Object.keys(source);
64
- var key, i;
65
- for (i = 0; i < sourceKeys.length; i++) {
66
- key = sourceKeys[i];
67
- if (excluded.indexOf(key) >= 0) continue;
68
- target[key] = source[key];
69
- }
70
- return target;
25
+ function _createClass(e, r, t) {
26
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
27
+ writable: !1
28
+ }), e;
71
29
  }
72
- function _objectWithoutProperties(source, excluded) {
73
- if (source == null) return {};
74
- var target = _objectWithoutPropertiesLoose(source, excluded);
75
- var key, i;
30
+ function _defineProperty(e, r, t) {
31
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
32
+ value: t,
33
+ enumerable: !0,
34
+ configurable: !0,
35
+ writable: !0
36
+ }) : e[r] = t, e;
37
+ }
38
+ function ownKeys(e, r) {
39
+ var t = Object.keys(e);
76
40
  if (Object.getOwnPropertySymbols) {
77
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
78
- for (i = 0; i < sourceSymbolKeys.length; i++) {
79
- key = sourceSymbolKeys[i];
80
- if (excluded.indexOf(key) >= 0) continue;
81
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
82
- target[key] = source[key];
83
- }
41
+ var o = Object.getOwnPropertySymbols(e);
42
+ r && (o = o.filter(function (r) {
43
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
44
+ })), t.push.apply(t, o);
84
45
  }
85
- return target;
46
+ return t;
86
47
  }
87
- function _toPrimitive(input, hint) {
88
- if (typeof input !== "object" || input === null) return input;
89
- var prim = input[Symbol.toPrimitive];
90
- if (prim !== undefined) {
91
- var res = prim.call(input, hint || "default");
92
- if (typeof res !== "object") return res;
93
- throw new TypeError("@@toPrimitive must return a primitive value.");
48
+ function _objectSpread2(e) {
49
+ for (var r = 1; r < arguments.length; r++) {
50
+ var t = null != arguments[r] ? arguments[r] : {};
51
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
52
+ _defineProperty(e, r, t[r]);
53
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
54
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
55
+ });
94
56
  }
95
- return (hint === "string" ? String : Number)(input);
96
- }
97
- function _toPropertyKey(arg) {
98
- var key = _toPrimitive(arg, "string");
99
- return typeof key === "symbol" ? key : String(key);
57
+ return e;
100
58
  }
101
- function _classPrivateFieldGet(receiver, privateMap) {
102
- var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
103
- return _classApplyDescriptorGet(receiver, descriptor);
104
- }
105
- function _classPrivateFieldSet(receiver, privateMap, value) {
106
- var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
107
- _classApplyDescriptorSet(receiver, descriptor, value);
108
- return value;
109
- }
110
- function _classExtractFieldDescriptor(receiver, privateMap, action) {
111
- if (!privateMap.has(receiver)) {
112
- throw new TypeError("attempted to " + action + " private field on non-instance");
59
+ function _objectWithoutProperties(e, t) {
60
+ if (null == e) return {};
61
+ var o,
62
+ r,
63
+ i = _objectWithoutPropertiesLoose(e, t);
64
+ if (Object.getOwnPropertySymbols) {
65
+ var n = Object.getOwnPropertySymbols(e);
66
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
113
67
  }
114
- return privateMap.get(receiver);
68
+ return i;
115
69
  }
116
- function _classApplyDescriptorGet(receiver, descriptor) {
117
- if (descriptor.get) {
118
- return descriptor.get.call(receiver);
70
+ function _objectWithoutPropertiesLoose(r, e) {
71
+ if (null == r) return {};
72
+ var t = {};
73
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
74
+ if (-1 !== e.indexOf(n)) continue;
75
+ t[n] = r[n];
119
76
  }
120
- return descriptor.value;
77
+ return t;
121
78
  }
122
- function _classApplyDescriptorSet(receiver, descriptor, value) {
123
- if (descriptor.set) {
124
- descriptor.set.call(receiver, value);
125
- } else {
126
- if (!descriptor.writable) {
127
- throw new TypeError("attempted to set read only private field");
128
- }
129
- descriptor.value = value;
79
+ function _toPrimitive(t, r) {
80
+ if ("object" != typeof t || !t) return t;
81
+ var e = t[Symbol.toPrimitive];
82
+ if (void 0 !== e) {
83
+ var i = e.call(t, r || "default");
84
+ if ("object" != typeof i) return i;
85
+ throw new TypeError("@@toPrimitive must return a primitive value.");
130
86
  }
87
+ return ("string" === r ? String : Number)(t);
88
+ }
89
+ function _toPropertyKey(t) {
90
+ var i = _toPrimitive(t, "string");
91
+ return "symbol" == typeof i ? i : i + "";
131
92
  }
132
- function _checkPrivateRedeclaration(obj, privateCollection) {
133
- if (privateCollection.has(obj)) {
134
- throw new TypeError("Cannot initialize the same private elements twice on an object");
93
+ function _classApplyDescriptorGet(e, t) {
94
+ return t.get ? t.get.call(e) : t.value;
95
+ }
96
+ function _classApplyDescriptorSet(e, t, l) {
97
+ if (t.set) t.set.call(e, l);else {
98
+ if (!t.writable) throw new TypeError("attempted to set read only private field");
99
+ t.value = l;
135
100
  }
136
101
  }
137
- function _classPrivateFieldInitSpec(obj, privateMap, value) {
138
- _checkPrivateRedeclaration(obj, privateMap);
139
- privateMap.set(obj, value);
102
+ function _classPrivateFieldGet(e, t) {
103
+ var r = _classPrivateFieldGet2(t, e);
104
+ return _classApplyDescriptorGet(e, r);
105
+ }
106
+ function _classPrivateFieldSet(e, t, r) {
107
+ var s = _classPrivateFieldGet2(t, e);
108
+ return _classApplyDescriptorSet(e, s, r), r;
140
109
  }
141
110
 
142
111
  function flattenScale(object, path) {
@@ -192,10 +161,10 @@ var ThemeBuilder = /*#__PURE__*/function () {
192
161
  });
193
162
  _classPrivateFieldSet(this, _theme, baseTheme);
194
163
  }
195
- /**
196
- *
197
- * @param key A key of the current theme to transform into CSS Variables and Variable References
198
- * @example .createScaleVariables('fontSize')
164
+ /**
165
+ *
166
+ * @param key A key of the current theme to transform into CSS Variables and Variable References
167
+ * @example .createScaleVariables('fontSize')
199
168
  */
200
169
  _createClass(ThemeBuilder, [{
201
170
  key: "createScaleVariables",
@@ -207,10 +176,10 @@ var ThemeBuilder = /*#__PURE__*/function () {
207
176
  _classPrivateFieldSet(this, _theme, merge({}, _classPrivateFieldGet(this, _theme), (_merge = {}, _defineProperty(_merge, key, tokens), _defineProperty(_merge, "_variables", _defineProperty({}, key, variables)), _defineProperty(_merge, "_tokens", _defineProperty({}, key, _classPrivateFieldGet(this, _theme)[key])), _merge)));
208
177
  return this;
209
178
  }
210
- /**
211
- *
212
- * @param colors A map of color tokens to add to the theme. These tokens are immediately converted to CSS Variables `--color-${key}`.
213
- * @example .addColors({ navy: 'navy', hyper: 'purple' })
179
+ /**
180
+ *
181
+ * @param colors A map of color tokens to add to the theme. These tokens are immediately converted to CSS Variables `--color-${key}`.
182
+ * @example .addColors({ navy: 'navy', hyper: 'purple' })
214
183
  */
215
184
  }, {
216
185
  key: "addColors",
@@ -230,11 +199,11 @@ var ThemeBuilder = /*#__PURE__*/function () {
230
199
  }));
231
200
  return this;
232
201
  }
233
- /**
234
- *
235
- * @param initialMode A key of the object passed for modes. This sets the default state for the theme and transforms the correct variables.
236
- * @param modes A map of color modes with keys of each possible mode with a value of alias to color keys. This must be called after `addColors`
237
- * @example .addColorModes('light', { light: { primary: 'hyper' }, { dark: { primary: 'navy' } } })
202
+ /**
203
+ *
204
+ * @param initialMode A key of the object passed for modes. This sets the default state for the theme and transforms the correct variables.
205
+ * @param modes A map of color modes with keys of each possible mode with a value of alias to color keys. This must be called after `addColors`
206
+ * @example .addColorModes('light', { light: { primary: 'hyper' }, { dark: { primary: 'navy' } } })
238
207
  */
239
208
  }, {
240
209
  key: "addColorModes",
@@ -269,11 +238,11 @@ var ThemeBuilder = /*#__PURE__*/function () {
269
238
  }));
270
239
  return this;
271
240
  }
272
- /**
273
- *
274
- * @param key A new key of theme
275
- * @param createScale A function that accepts the current theme and returns a new object of scale values.
276
- * @example .addScale('fonts', () => ({ basic: 'Gotham', cool: 'Wingdings' }))
241
+ /**
242
+ *
243
+ * @param key A new key of theme
244
+ * @param createScale A function that accepts the current theme and returns a new object of scale values.
245
+ * @example .addScale('fonts', () => ({ basic: 'Gotham', cool: 'Wingdings' }))
277
246
  */
278
247
  }, {
279
248
  key: "addScale",
@@ -281,11 +250,11 @@ var ThemeBuilder = /*#__PURE__*/function () {
281
250
  _classPrivateFieldSet(this, _theme, merge({}, _classPrivateFieldGet(this, _theme), _defineProperty({}, key, flattenScale(createScale(_classPrivateFieldGet(this, _theme))))));
282
251
  return this;
283
252
  }
284
- /**
285
- *
286
- * @param key A current key of theme to be updated with new or computed values
287
- * @param updateFn A function that accepts an argument of the current values at the specified keys an returns a map of new values to merge.
288
- * @example .updateScale('fonts', ({ basic }) => ({ basicFallback: `{basic}, Montserrat` }))
253
+ /**
254
+ *
255
+ * @param key A current key of theme to be updated with new or computed values
256
+ * @param updateFn A function that accepts an argument of the current values at the specified keys an returns a map of new values to merge.
257
+ * @example .updateScale('fonts', ({ basic }) => ({ basicFallback: `{basic}, Montserrat` }))
289
258
  */
290
259
  }, {
291
260
  key: "updateScale",
@@ -293,8 +262,8 @@ var ThemeBuilder = /*#__PURE__*/function () {
293
262
  _classPrivateFieldSet(this, _theme, merge({}, _classPrivateFieldGet(this, _theme), _defineProperty({}, key, updateFn(_classPrivateFieldGet(this, _theme)[key]))));
294
263
  return this;
295
264
  }
296
- /**
297
- * This finalizes the theme build and returns the final theme and variables to be provided.
265
+ /**
266
+ * This finalizes the theme build and returns the final theme and variables to be provided.
298
267
  */
299
268
  }, {
300
269
  key: "build",
@@ -1,53 +1,53 @@
1
- import { AbstractTheme, CSSObject } from '@animus-ui/core';
2
- import { LiteralPaths } from './flattenScale';
3
- import { KeyAsVariable } from './serializeTokens';
4
- import { ColorModeConfig, Merge, MergeTheme, PrivateThemeKeys } from './types';
5
- export declare class ThemeBuilder<T extends AbstractTheme> {
6
- #private;
7
- constructor(baseTheme: T);
8
- /**
9
- *
10
- * @param key A key of the current theme to transform into CSS Variables and Variable References
11
- * @example .createScaleVariables('fontSize')
12
- */
13
- createScaleVariables<Key extends keyof Omit<T, 'breakpoints'> & string>(key: Key): ThemeBuilder<MergeTheme<T, PrivateThemeKeys, Record<Key, Record<Key, KeyAsVariable<T[Key], Key>>>>>;
14
- /**
15
- *
16
- * @param colors A map of color tokens to add to the theme. These tokens are immediately converted to CSS Variables `--color-${key}`.
17
- * @example .addColors({ navy: 'navy', hyper: 'purple' })
18
- */
19
- addColors<Colors extends Record<string, string | number | CSSObject>, NextColors extends LiteralPaths<Colors, '-'>>(colors: Colors): ThemeBuilder<MergeTheme<T & PrivateThemeKeys, Record<'colors', KeyAsVariable<NextColors, 'color'>>>>;
20
- /**
21
- *
22
- * @param initialMode A key of the object passed for modes. This sets the default state for the theme and transforms the correct variables.
23
- * @param modes A map of color modes with keys of each possible mode with a value of alias to color keys. This must be called after `addColors`
24
- * @example .addColorModes('light', { light: { primary: 'hyper' }, { dark: { primary: 'navy' } } })
25
- */
26
- addColorModes<Modes extends string, InitialMode extends keyof Config, Colors extends keyof T['colors'], ModeColors extends ColorModeConfig<Colors>, Config extends Record<Modes, ModeColors>, ColorAliases extends {
27
- [K in keyof Config]: LiteralPaths<Config[K], '-', '_'>;
28
- }>(initialMode: InitialMode, modeConfig: Config): ThemeBuilder<MergeTheme<T & PrivateThemeKeys, {
29
- colors: KeyAsVariable<LiteralPaths<Config[keyof Config], '-', '_'>, 'colors'> & T['colors'];
30
- modes: Merge<T['modes'], ColorAliases>;
31
- mode: keyof Config;
32
- _getColorValue: (color: keyof T['colors']) => string;
33
- }>>;
34
- /**
35
- *
36
- * @param key A new key of theme
37
- * @param createScale A function that accepts the current theme and returns a new object of scale values.
38
- * @example .addScale('fonts', () => ({ basic: 'Gotham', cool: 'Wingdings' }))
39
- */
40
- addScale<Key extends string, Fn extends (theme: T) => Record<string | number, string | number | Record<string, string | number>>, NewScale extends LiteralPaths<ReturnType<Fn>, '-'>>(key: Key, createScale: Fn): ThemeBuilder<MergeTheme<T, Record<Key, NewScale>>>;
41
- /**
42
- *
43
- * @param key A current key of theme to be updated with new or computed values
44
- * @param updateFn A function that accepts an argument of the current values at the specified keys an returns a map of new values to merge.
45
- * @example .updateScale('fonts', ({ basic }) => ({ basicFallback: `{basic}, Montserrat` }))
46
- */
47
- updateScale<Key extends keyof T, Fn extends (tokens: T[Key]) => Record<string | number, unknown>>(key: Key, updateFn: Fn): ThemeBuilder<T & Record<Key, T[Key] & ReturnType<Fn>>>;
48
- /**
49
- * This finalizes the theme build and returns the final theme and variables to be provided.
50
- */
51
- build(): T & PrivateThemeKeys;
52
- }
53
- export declare function createTheme<T extends AbstractTheme>(base: T): ThemeBuilder<T>;
1
+ import { AbstractTheme, CSSObject } from '@animus-ui/core';
2
+ import { LiteralPaths } from './flattenScale';
3
+ import { KeyAsVariable } from './serializeTokens';
4
+ import { ColorModeConfig, Merge, MergeTheme, PrivateThemeKeys } from './types';
5
+ export declare class ThemeBuilder<T extends AbstractTheme> {
6
+ #private;
7
+ constructor(baseTheme: T);
8
+ /**
9
+ *
10
+ * @param key A key of the current theme to transform into CSS Variables and Variable References
11
+ * @example .createScaleVariables('fontSize')
12
+ */
13
+ createScaleVariables<Key extends keyof Omit<T, 'breakpoints'> & string>(key: Key): ThemeBuilder<MergeTheme<T, PrivateThemeKeys, Record<Key, Record<Key, KeyAsVariable<T[Key], Key>>>>>;
14
+ /**
15
+ *
16
+ * @param colors A map of color tokens to add to the theme. These tokens are immediately converted to CSS Variables `--color-${key}`.
17
+ * @example .addColors({ navy: 'navy', hyper: 'purple' })
18
+ */
19
+ addColors<Colors extends Record<string, string | number | CSSObject>, NextColors extends LiteralPaths<Colors, '-'>>(colors: Colors): ThemeBuilder<MergeTheme<T & PrivateThemeKeys, Record<'colors', KeyAsVariable<NextColors, 'color'>>>>;
20
+ /**
21
+ *
22
+ * @param initialMode A key of the object passed for modes. This sets the default state for the theme and transforms the correct variables.
23
+ * @param modes A map of color modes with keys of each possible mode with a value of alias to color keys. This must be called after `addColors`
24
+ * @example .addColorModes('light', { light: { primary: 'hyper' }, { dark: { primary: 'navy' } } })
25
+ */
26
+ addColorModes<Modes extends string, InitialMode extends keyof Config, Colors extends keyof T['colors'], ModeColors extends ColorModeConfig<Colors>, Config extends Record<Modes, ModeColors>, ColorAliases extends {
27
+ [K in keyof Config]: LiteralPaths<Config[K], '-', '_'>;
28
+ }>(initialMode: InitialMode, modeConfig: Config): ThemeBuilder<MergeTheme<T & PrivateThemeKeys, {
29
+ colors: KeyAsVariable<LiteralPaths<Config[keyof Config], '-', '_'>, 'colors'> & T['colors'];
30
+ modes: Merge<T['modes'], ColorAliases>;
31
+ mode: keyof Config;
32
+ _getColorValue: (color: keyof T['colors']) => string;
33
+ }>>;
34
+ /**
35
+ *
36
+ * @param key A new key of theme
37
+ * @param createScale A function that accepts the current theme and returns a new object of scale values.
38
+ * @example .addScale('fonts', () => ({ basic: 'Gotham', cool: 'Wingdings' }))
39
+ */
40
+ addScale<Key extends string, Fn extends (theme: T) => Record<string | number, string | number | Record<string, string | number>>, NewScale extends LiteralPaths<ReturnType<Fn>, '-'>>(key: Key, createScale: Fn): ThemeBuilder<MergeTheme<T, Record<Key, NewScale>>>;
41
+ /**
42
+ *
43
+ * @param key A current key of theme to be updated with new or computed values
44
+ * @param updateFn A function that accepts an argument of the current values at the specified keys an returns a map of new values to merge.
45
+ * @example .updateScale('fonts', ({ basic }) => ({ basicFallback: `{basic}, Montserrat` }))
46
+ */
47
+ updateScale<Key extends keyof T, Fn extends (tokens: T[Key]) => Record<string | number, unknown>>(key: Key, updateFn: Fn): ThemeBuilder<T & Record<Key, T[Key] & ReturnType<Fn>>>;
48
+ /**
49
+ * This finalizes the theme build and returns the final theme and variables to be provided.
50
+ */
51
+ build(): T & PrivateThemeKeys;
52
+ }
53
+ export declare function createTheme<T extends AbstractTheme>(base: T): ThemeBuilder<T>;
@@ -1,20 +1,20 @@
1
- /**
2
- * Returns an exhaustive list of all possible paths of an object T for keys K.
3
- * Possibilities are returned as `k1.k2.k3`.
4
- */
5
- export type FindPath<T, K extends keyof T, D extends string = '.'> = K extends string | number ? T[K] extends Record<string | number, any> ? T[K] extends ArrayLike<any> ? K | `${K}${D}${FindPath<T[K], Exclude<keyof T[K], keyof any[]>, D>}` : K | `${K}${D}${FindPath<T[K], keyof T[K], D>}` : K : never;
6
- /** Returns valid paths of object T */
7
- export type Path<T, D extends string = '.'> = FindPath<T, keyof T, D> | keyof T;
8
- /** Returns the value of a valid path P `k1.k2.k3` in object T */
9
- export type PathValue<T, P extends Path<T, D>, D extends string = '.'> = P extends `${infer K}${D}${infer Rest}` ? K extends keyof T ? Rest extends Path<T[K], D> ? PathValue<T[K], Rest, D> : never : never : P extends keyof T ? T[P] : never;
10
- /** Check if path has a primitive end value and return only the union of end paths */
11
- export type PathToLiteral<T, K extends Path<T, D>, D extends string = '.', Base extends string = ''> = PathValue<T, K, D> extends string | number ? K extends string | number ? K extends `${infer BasePath}${D}${Base}` ? BasePath : K : never : never;
12
- /**
13
- * Reduce all paths to a single map of paths with primitive values removing all extra non stateful paths
14
- * { path: { sub: 1 } } => { 'path-sub': 1 }
15
- *
16
- */
17
- export type LiteralPaths<T extends Record<string | number, any>, D extends string = '.', Base extends string = ''> = {
18
- [K in Path<T, D> as PathToLiteral<T, K, D, Base>]: PathValue<T, PathToLiteral<T, K, D>, D>;
19
- };
20
- export declare function flattenScale<T extends Record<string | number, unknown>, P extends string>(object: T, path?: P): LiteralPaths<T, '-', '_'>;
1
+ /**
2
+ * Returns an exhaustive list of all possible paths of an object T for keys K.
3
+ * Possibilities are returned as `k1.k2.k3`.
4
+ */
5
+ export type FindPath<T, K extends keyof T, D extends string = '.'> = K extends string | number ? T[K] extends Record<string | number, any> ? T[K] extends ArrayLike<any> ? K | `${K}${D}${FindPath<T[K], Exclude<keyof T[K], keyof any[]>, D>}` : K | `${K}${D}${FindPath<T[K], keyof T[K], D>}` : K : never;
6
+ /** Returns valid paths of object T */
7
+ export type Path<T, D extends string = '.'> = FindPath<T, keyof T, D> | keyof T;
8
+ /** Returns the value of a valid path P `k1.k2.k3` in object T */
9
+ export type PathValue<T, P extends Path<T, D>, D extends string = '.'> = P extends `${infer K}${D}${infer Rest}` ? K extends keyof T ? Rest extends Path<T[K], D> ? PathValue<T[K], Rest, D> : never : never : P extends keyof T ? T[P] : never;
10
+ /** Check if path has a primitive end value and return only the union of end paths */
11
+ export type PathToLiteral<T, K extends Path<T, D>, D extends string = '.', Base extends string = ''> = PathValue<T, K, D> extends string | number ? K extends string | number ? K extends `${infer BasePath}${D}${Base}` ? BasePath : K : never : never;
12
+ /**
13
+ * Reduce all paths to a single map of paths with primitive values removing all extra non stateful paths
14
+ * { path: { sub: 1 } } => { 'path-sub': 1 }
15
+ *
16
+ */
17
+ export type LiteralPaths<T extends Record<string | number, any>, D extends string = '.', Base extends string = ''> = {
18
+ [K in Path<T, D> as PathToLiteral<T, K, D, Base>]: PathValue<T, PathToLiteral<T, K, D>, D>;
19
+ };
20
+ export declare function flattenScale<T extends Record<string | number, unknown>, P extends string>(object: T, path?: P): LiteralPaths<T, '-', '_'>;
@@ -1,3 +1,3 @@
1
- export * from './createTheme';
2
- export * from './serializeTokens';
3
- export * from './flattenScale';
1
+ export * from './createTheme';
2
+ export * from './serializeTokens';
3
+ export * from './flattenScale';
@@ -1,19 +1,19 @@
1
- import { CSSObject } from '@animus-ui/core';
2
- import { Theme } from '@emotion/react';
3
- /**
4
- * Returns an type of any object with { key: 'var(--key) }
5
- */
6
- export type KeyAsVariable<T extends Record<string, any>, Prefix extends string> = {
7
- [V in keyof T]: `var(--${Prefix}-${SanitizeKey<Extract<V, string>>})`;
8
- };
9
- export type SanitizeKey<T extends string> = T extends `${'$'}${infer Y}` ? Y : T;
10
- type SerializedTokensInput = Record<string, string | number | CSSObject | SerializedTokensInputRecursive>;
11
- interface SerializedTokensInputRecursive {
12
- [i: number]: SerializedTokensInput;
13
- [i: string]: SerializedTokensInput;
14
- }
15
- export declare const serializeTokens: <T extends SerializedTokensInput, Prefix extends string>(tokens: T, prefix: Prefix, theme: Theme | undefined) => {
16
- tokens: KeyAsVariable<T, Prefix>;
17
- variables: CSSObject;
18
- };
19
- export {};
1
+ import { CSSObject } from '@animus-ui/core';
2
+ import { Theme } from '@emotion/react';
3
+ /**
4
+ * Returns an type of any object with { key: 'var(--key) }
5
+ */
6
+ export type KeyAsVariable<T extends Record<string, any>, Prefix extends string> = {
7
+ [V in keyof T]: `var(--${Prefix}-${SanitizeKey<Extract<V, string>>})`;
8
+ };
9
+ export type SanitizeKey<T extends string> = T extends `${'$'}${infer Y}` ? Y : T;
10
+ type SerializedTokensInput = Record<string, string | number | CSSObject | SerializedTokensInputRecursive>;
11
+ interface SerializedTokensInputRecursive {
12
+ [i: number]: SerializedTokensInput;
13
+ [i: string]: SerializedTokensInput;
14
+ }
15
+ export declare const serializeTokens: <T extends SerializedTokensInput, Prefix extends string>(tokens: T, prefix: Prefix, theme: Theme | undefined) => {
16
+ tokens: KeyAsVariable<T, Prefix>;
17
+ variables: CSSObject;
18
+ };
19
+ export {};
@@ -1,41 +1,41 @@
1
- import { AbstractTheme, CSSObject } from '@animus-ui/core';
2
- /**
3
- * This is a custom generic that ensures the safety of adding additional values to a theme object without accidentally wiping out
4
- * required keys like `breakpoints`. It works by creating a new mapped type and merging the values of the union of Base & Next:
5
- * 1. If the key exists on both Base and Next return the intersection of both values
6
- * 2. If the key exists on next use the value on next.
7
- * 3. If the key exists on base but nothing else use the value on base.
8
- *
9
- * The resulting type is then rejoined with keys that cannot be mutated (breakpoints) as the next version of Theme
10
- */
11
- export type MergeTheme<Base extends AbstractTheme, Next, Unmergable = Record<'breakpoints', Base['breakpoints']>> = Unmergable & Merge<Base, Next>;
12
- /** This merges at 2 levels of depth */
13
- export type Merge<A, B> = {
14
- [K in keyof (A & B)]: K extends keyof B ? K extends keyof A ? AssignValueIfUnmergable<A[K], B[K]> : B[K] : K extends keyof A ? A[K] : never;
15
- };
16
- /** Extract mergable objects */
17
- export type Mergable<T> = Exclude<T, ((...args: any) => any) | string | boolean | symbol | number | any[]>;
18
- /** Return B if either A or B is unmergable */
19
- export type AssignValueIfUnmergable<A, B> = Mergable<A> extends never ? B : Mergable<B> extends never ? B : Assign<A, B>;
20
- /** Prefer all values from B */
21
- export type Assign<A, B> = {
22
- [K in keyof A | keyof B]: K extends keyof B ? B[K] : K extends keyof A ? A[K] : never;
23
- };
24
- /** These are keys that are consistent for all theme builds - they are loosely typed as they are not meant to be accessed directly */
25
- export type PrivateThemeKeys = {
26
- _variables: Record<string, CSSObject>;
27
- _tokens: Record<string | number, any>;
28
- };
29
- /** This allows 3 layers of color aliases to be constructed when adding colorModes
30
- * @example
31
- * {
32
- * button: {
33
- * bg: {
34
- * hover: 'someAlias'
35
- * }
36
- * }
37
- * }
38
- *
39
- * `button-bg-hover`
40
- * */
41
- export type ColorModeConfig<Colors> = Record<string, Colors | Record<string, Colors> | Record<string, Colors | Record<string, Colors>>>;
1
+ import { AbstractTheme, CSSObject } from '@animus-ui/core';
2
+ /**
3
+ * This is a custom generic that ensures the safety of adding additional values to a theme object without accidentally wiping out
4
+ * required keys like `breakpoints`. It works by creating a new mapped type and merging the values of the union of Base & Next:
5
+ * 1. If the key exists on both Base and Next return the intersection of both values
6
+ * 2. If the key exists on next use the value on next.
7
+ * 3. If the key exists on base but nothing else use the value on base.
8
+ *
9
+ * The resulting type is then rejoined with keys that cannot be mutated (breakpoints) as the next version of Theme
10
+ */
11
+ export type MergeTheme<Base extends AbstractTheme, Next, Unmergable = Record<'breakpoints', Base['breakpoints']>> = Unmergable & Merge<Base, Next>;
12
+ /** This merges at 2 levels of depth */
13
+ export type Merge<A, B> = {
14
+ [K in keyof (A & B)]: K extends keyof B ? K extends keyof A ? AssignValueIfUnmergable<A[K], B[K]> : B[K] : K extends keyof A ? A[K] : never;
15
+ };
16
+ /** Extract mergable objects */
17
+ export type Mergable<T> = Exclude<T, ((...args: any) => any) | string | boolean | symbol | number | any[]>;
18
+ /** Return B if either A or B is unmergable */
19
+ export type AssignValueIfUnmergable<A, B> = Mergable<A> extends never ? B : Mergable<B> extends never ? B : Assign<A, B>;
20
+ /** Prefer all values from B */
21
+ export type Assign<A, B> = {
22
+ [K in keyof A | keyof B]: K extends keyof B ? B[K] : K extends keyof A ? A[K] : never;
23
+ };
24
+ /** These are keys that are consistent for all theme builds - they are loosely typed as they are not meant to be accessed directly */
25
+ export type PrivateThemeKeys = {
26
+ _variables: Record<string, CSSObject>;
27
+ _tokens: Record<string | number, any>;
28
+ };
29
+ /** This allows 3 layers of color aliases to be constructed when adding colorModes
30
+ * @example
31
+ * {
32
+ * button: {
33
+ * bg: {
34
+ * hover: 'someAlias'
35
+ * }
36
+ * }
37
+ * }
38
+ *
39
+ * `button-bg-hover`
40
+ * */
41
+ export type ColorModeConfig<Colors> = Record<string, Colors | Record<string, Colors> | Record<string, Colors | Record<string, Colors>>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animus-ui/theming",
3
- "version": "0.1.1-beta.24",
3
+ "version": "0.1.1-beta.26",
4
4
  "description": "Theming Utilities",
5
5
  "author": "Aaron Robb <airrobb@gmail.com>",
6
6
  "homepage": "https://github.com/codecaaron/animus#readme",
@@ -25,13 +25,13 @@
25
25
  "url": "https://github.com/codecaaron/animus/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@animus-ui/core": "^0.1.1-beta.23",
29
- "@emotion/react": "^11.0.0",
30
- "@emotion/styled": "^11.0.0"
28
+ "@animus-ui/core": "^0.1.1-beta.25",
29
+ "@emotion/react": "^11.14.0",
30
+ "@emotion/styled": "^11.14.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "lodash": "*",
34
34
  "typescript": ">=4.3.5"
35
35
  },
36
- "gitHead": "815998212fbe5f4603aa2ddf38d086c484ab88d2"
36
+ "gitHead": "60452a65a6679aaadb95075b8d7f12771164d8fb"
37
37
  }