@animus-ui/theming 0.1.1-beta.23 → 0.1.1-beta.25
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 +5 -93
- package/dist/index.js +29 -80
- package/dist/utils/flattenScale.d.ts +5 -5
- package/dist/utils/serializeTokens.d.ts +3 -3
- package/dist/utils/types.d.ts +7 -7
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,198 +3,110 @@
|
|
|
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.
|
|
6
|
+
## [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)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @animus-ui/theming
|
|
9
9
|
|
|
10
|
+
## [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)
|
|
10
11
|
|
|
12
|
+
**Note:** Version bump only for package @animus-ui/theming
|
|
11
13
|
|
|
14
|
+
## [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)
|
|
12
15
|
|
|
16
|
+
**Note:** Version bump only for package @animus-ui/theming
|
|
13
17
|
|
|
14
18
|
## [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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.2 (2022-01-09)
|
|
175
99
|
|
|
176
|
-
|
|
177
|
-
|
|
178
100
|
## 0.1.1-beta.1 (2022-01-09)
|
|
179
101
|
|
|
180
|
-
|
|
181
|
-
|
|
182
102
|
## 0.1.1-beta.0 (2022-01-09)
|
|
183
103
|
|
|
184
104
|
**Note:** Version bump only for package @animus-ui/theming
|
|
185
105
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
106
|
## [0.1.1-beta.1](https://github.com/codecaaron/animus/compare/v0.1.1-beta.0...v0.1.1-beta.1) (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.0 (2022-01-09)
|
|
199
111
|
|
|
200
112
|
**Note:** Version bump only for package @animus-ui/theming
|
package/dist/index.js
CHANGED
|
@@ -2,17 +2,14 @@ import { isObject, merge, mapValues } from 'lodash';
|
|
|
2
2
|
|
|
3
3
|
function ownKeys(object, enumerableOnly) {
|
|
4
4
|
var keys = Object.keys(object);
|
|
5
|
-
|
|
6
5
|
if (Object.getOwnPropertySymbols) {
|
|
7
6
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
8
7
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
9
8
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
10
9
|
})), keys.push.apply(keys, symbols);
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
return keys;
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
function _objectSpread2(target) {
|
|
17
14
|
for (var i = 1; i < arguments.length; i++) {
|
|
18
15
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -22,26 +19,22 @@ function _objectSpread2(target) {
|
|
|
22
19
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
23
20
|
});
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
return target;
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
function _classCallCheck(instance, Constructor) {
|
|
30
25
|
if (!(instance instanceof Constructor)) {
|
|
31
26
|
throw new TypeError("Cannot call a class as a function");
|
|
32
27
|
}
|
|
33
28
|
}
|
|
34
|
-
|
|
35
29
|
function _defineProperties(target, props) {
|
|
36
30
|
for (var i = 0; i < props.length; i++) {
|
|
37
31
|
var descriptor = props[i];
|
|
38
32
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
39
33
|
descriptor.configurable = true;
|
|
40
34
|
if ("value" in descriptor) descriptor.writable = true;
|
|
41
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
35
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
42
36
|
}
|
|
43
37
|
}
|
|
44
|
-
|
|
45
38
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
46
39
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
47
40
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
@@ -50,8 +43,8 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
50
43
|
});
|
|
51
44
|
return Constructor;
|
|
52
45
|
}
|
|
53
|
-
|
|
54
46
|
function _defineProperty(obj, key, value) {
|
|
47
|
+
key = _toPropertyKey(key);
|
|
55
48
|
if (key in obj) {
|
|
56
49
|
Object.defineProperty(obj, key, {
|
|
57
50
|
value: value,
|
|
@@ -62,35 +55,26 @@ function _defineProperty(obj, key, value) {
|
|
|
62
55
|
} else {
|
|
63
56
|
obj[key] = value;
|
|
64
57
|
}
|
|
65
|
-
|
|
66
58
|
return obj;
|
|
67
59
|
}
|
|
68
|
-
|
|
69
60
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
70
61
|
if (source == null) return {};
|
|
71
62
|
var target = {};
|
|
72
63
|
var sourceKeys = Object.keys(source);
|
|
73
64
|
var key, i;
|
|
74
|
-
|
|
75
65
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
76
66
|
key = sourceKeys[i];
|
|
77
67
|
if (excluded.indexOf(key) >= 0) continue;
|
|
78
68
|
target[key] = source[key];
|
|
79
69
|
}
|
|
80
|
-
|
|
81
70
|
return target;
|
|
82
71
|
}
|
|
83
|
-
|
|
84
72
|
function _objectWithoutProperties(source, excluded) {
|
|
85
73
|
if (source == null) return {};
|
|
86
|
-
|
|
87
74
|
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
88
|
-
|
|
89
75
|
var key, i;
|
|
90
|
-
|
|
91
76
|
if (Object.getOwnPropertySymbols) {
|
|
92
77
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
93
|
-
|
|
94
78
|
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
95
79
|
key = sourceSymbolKeys[i];
|
|
96
80
|
if (excluded.indexOf(key) >= 0) continue;
|
|
@@ -98,40 +82,43 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
98
82
|
target[key] = source[key];
|
|
99
83
|
}
|
|
100
84
|
}
|
|
101
|
-
|
|
102
85
|
return target;
|
|
103
86
|
}
|
|
104
|
-
|
|
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.");
|
|
94
|
+
}
|
|
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);
|
|
100
|
+
}
|
|
105
101
|
function _classPrivateFieldGet(receiver, privateMap) {
|
|
106
102
|
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
|
|
107
|
-
|
|
108
103
|
return _classApplyDescriptorGet(receiver, descriptor);
|
|
109
104
|
}
|
|
110
|
-
|
|
111
105
|
function _classPrivateFieldSet(receiver, privateMap, value) {
|
|
112
106
|
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
|
|
113
|
-
|
|
114
107
|
_classApplyDescriptorSet(receiver, descriptor, value);
|
|
115
|
-
|
|
116
108
|
return value;
|
|
117
109
|
}
|
|
118
|
-
|
|
119
110
|
function _classExtractFieldDescriptor(receiver, privateMap, action) {
|
|
120
111
|
if (!privateMap.has(receiver)) {
|
|
121
112
|
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
122
113
|
}
|
|
123
|
-
|
|
124
114
|
return privateMap.get(receiver);
|
|
125
115
|
}
|
|
126
|
-
|
|
127
116
|
function _classApplyDescriptorGet(receiver, descriptor) {
|
|
128
117
|
if (descriptor.get) {
|
|
129
118
|
return descriptor.get.call(receiver);
|
|
130
119
|
}
|
|
131
|
-
|
|
132
120
|
return descriptor.value;
|
|
133
121
|
}
|
|
134
|
-
|
|
135
122
|
function _classApplyDescriptorSet(receiver, descriptor, value) {
|
|
136
123
|
if (descriptor.set) {
|
|
137
124
|
descriptor.set.call(receiver, value);
|
|
@@ -139,20 +126,16 @@ function _classApplyDescriptorSet(receiver, descriptor, value) {
|
|
|
139
126
|
if (!descriptor.writable) {
|
|
140
127
|
throw new TypeError("attempted to set read only private field");
|
|
141
128
|
}
|
|
142
|
-
|
|
143
129
|
descriptor.value = value;
|
|
144
130
|
}
|
|
145
131
|
}
|
|
146
|
-
|
|
147
132
|
function _checkPrivateRedeclaration(obj, privateCollection) {
|
|
148
133
|
if (privateCollection.has(obj)) {
|
|
149
134
|
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
150
135
|
}
|
|
151
136
|
}
|
|
152
|
-
|
|
153
137
|
function _classPrivateFieldInitSpec(obj, privateMap, value) {
|
|
154
138
|
_checkPrivateRedeclaration(obj, privateMap);
|
|
155
|
-
|
|
156
139
|
privateMap.set(obj, value);
|
|
157
140
|
}
|
|
158
141
|
|
|
@@ -160,24 +143,19 @@ function flattenScale(object, path) {
|
|
|
160
143
|
return Object.keys(object).reduce(function (carry, key) {
|
|
161
144
|
var nextKey = path ? "".concat(path).concat(key === '_' ? '' : "-".concat(key)) : key;
|
|
162
145
|
var current = object[key];
|
|
163
|
-
|
|
164
146
|
if (isObject(current)) {
|
|
165
147
|
return _objectSpread2(_objectSpread2({}, carry), flattenScale(current, nextKey));
|
|
166
148
|
}
|
|
167
|
-
|
|
168
149
|
return _objectSpread2(_objectSpread2({}, carry), {}, _defineProperty({}, nextKey, object[key]));
|
|
169
150
|
}, {});
|
|
170
151
|
}
|
|
171
152
|
|
|
172
153
|
var _excluded = ["_"];
|
|
173
|
-
|
|
174
154
|
var templateBreakpoints = function templateBreakpoints(value, alias, theme) {
|
|
175
155
|
if (isObject(value)) {
|
|
176
156
|
var _ = value._,
|
|
177
|
-
|
|
178
|
-
|
|
157
|
+
rest = _objectWithoutProperties(value, _excluded);
|
|
179
158
|
var css = _defineProperty({}, alias, _);
|
|
180
|
-
|
|
181
159
|
if (theme) {
|
|
182
160
|
var breakpoints = theme.breakpoints;
|
|
183
161
|
Object.keys(breakpoints).forEach(function (key) {
|
|
@@ -186,13 +164,10 @@ var templateBreakpoints = function templateBreakpoints(value, alias, theme) {
|
|
|
186
164
|
}
|
|
187
165
|
});
|
|
188
166
|
}
|
|
189
|
-
|
|
190
167
|
return css;
|
|
191
168
|
}
|
|
192
|
-
|
|
193
169
|
return _defineProperty({}, alias, value);
|
|
194
170
|
};
|
|
195
|
-
|
|
196
171
|
var serializeTokens = function serializeTokens(tokens, prefix, theme) {
|
|
197
172
|
var tokenReferences = {};
|
|
198
173
|
var tokenVariables = {};
|
|
@@ -208,16 +183,13 @@ var serializeTokens = function serializeTokens(tokens, prefix, theme) {
|
|
|
208
183
|
};
|
|
209
184
|
|
|
210
185
|
var _theme = /*#__PURE__*/new WeakMap();
|
|
211
|
-
|
|
212
186
|
var ThemeBuilder = /*#__PURE__*/function () {
|
|
213
187
|
function ThemeBuilder(baseTheme) {
|
|
214
188
|
_classCallCheck(this, ThemeBuilder);
|
|
215
|
-
|
|
216
189
|
_classPrivateFieldInitSpec(this, _theme, {
|
|
217
190
|
writable: true,
|
|
218
191
|
value: {}
|
|
219
192
|
});
|
|
220
|
-
|
|
221
193
|
_classPrivateFieldSet(this, _theme, baseTheme);
|
|
222
194
|
}
|
|
223
195
|
/**
|
|
@@ -225,19 +197,14 @@ var ThemeBuilder = /*#__PURE__*/function () {
|
|
|
225
197
|
* @param key A key of the current theme to transform into CSS Variables and Variable References
|
|
226
198
|
* @example .createScaleVariables('fontSize')
|
|
227
199
|
*/
|
|
228
|
-
|
|
229
|
-
|
|
230
200
|
_createClass(ThemeBuilder, [{
|
|
231
201
|
key: "createScaleVariables",
|
|
232
202
|
value: function createScaleVariables(key) {
|
|
233
203
|
var _merge;
|
|
234
|
-
|
|
235
204
|
var _serializeTokens = serializeTokens(_classPrivateFieldGet(this, _theme)[key], key, _classPrivateFieldGet(this, _theme)),
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
205
|
+
variables = _serializeTokens.variables,
|
|
206
|
+
tokens = _serializeTokens.tokens;
|
|
239
207
|
_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)));
|
|
240
|
-
|
|
241
208
|
return this;
|
|
242
209
|
}
|
|
243
210
|
/**
|
|
@@ -245,16 +212,13 @@ var ThemeBuilder = /*#__PURE__*/function () {
|
|
|
245
212
|
* @param colors A map of color tokens to add to the theme. These tokens are immediately converted to CSS Variables `--color-${key}`.
|
|
246
213
|
* @example .addColors({ navy: 'navy', hyper: 'purple' })
|
|
247
214
|
*/
|
|
248
|
-
|
|
249
215
|
}, {
|
|
250
216
|
key: "addColors",
|
|
251
217
|
value: function addColors(colors) {
|
|
252
218
|
var flatColors = flattenScale(colors);
|
|
253
|
-
|
|
254
219
|
var _serializeTokens2 = serializeTokens(flatColors, 'color', _classPrivateFieldGet(this, _theme)),
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
220
|
+
variables = _serializeTokens2.variables,
|
|
221
|
+
tokens = _serializeTokens2.tokens;
|
|
258
222
|
_classPrivateFieldSet(this, _theme, merge({}, _classPrivateFieldGet(this, _theme), {
|
|
259
223
|
colors: tokens,
|
|
260
224
|
_variables: {
|
|
@@ -264,7 +228,6 @@ var ThemeBuilder = /*#__PURE__*/function () {
|
|
|
264
228
|
colors: flatColors
|
|
265
229
|
}
|
|
266
230
|
}));
|
|
267
|
-
|
|
268
231
|
return this;
|
|
269
232
|
}
|
|
270
233
|
/**
|
|
@@ -273,29 +236,23 @@ var ThemeBuilder = /*#__PURE__*/function () {
|
|
|
273
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`
|
|
274
237
|
* @example .addColorModes('light', { light: { primary: 'hyper' }, { dark: { primary: 'navy' } } })
|
|
275
238
|
*/
|
|
276
|
-
|
|
277
239
|
}, {
|
|
278
240
|
key: "addColorModes",
|
|
279
241
|
value: function addColorModes(initialMode, modeConfig) {
|
|
280
242
|
var _classPrivateFieldGet2,
|
|
281
|
-
|
|
282
|
-
|
|
243
|
+
_this = this;
|
|
283
244
|
var modes = mapValues(modeConfig, function (mode) {
|
|
284
245
|
return flattenScale(mode);
|
|
285
246
|
});
|
|
286
|
-
|
|
287
247
|
var _serializeTokens3 = serializeTokens(mapValues(merge({}, (_classPrivateFieldGet2 = _classPrivateFieldGet(this, _theme).modes) === null || _classPrivateFieldGet2 === void 0 ? void 0 : _classPrivateFieldGet2[initialMode], modes[initialMode]), function (color) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
248
|
+
return _classPrivateFieldGet(_this, _theme).colors[color];
|
|
249
|
+
}), 'color', _classPrivateFieldGet(this, _theme)),
|
|
250
|
+
colors = _serializeTokens3.tokens,
|
|
251
|
+
variables = _serializeTokens3.variables;
|
|
293
252
|
var getColorValue = function getColorValue(color) {
|
|
294
253
|
var _classPrivateFieldGet3, _classPrivateFieldGet4;
|
|
295
|
-
|
|
296
254
|
return (_classPrivateFieldGet3 = _classPrivateFieldGet(_this, _theme)._tokens) === null || _classPrivateFieldGet3 === void 0 ? void 0 : (_classPrivateFieldGet4 = _classPrivateFieldGet3.colors) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4[color];
|
|
297
255
|
};
|
|
298
|
-
|
|
299
256
|
_classPrivateFieldSet(this, _theme, merge({}, _classPrivateFieldGet(this, _theme), {
|
|
300
257
|
colors: colors,
|
|
301
258
|
modes: modes,
|
|
@@ -310,7 +267,6 @@ var ThemeBuilder = /*#__PURE__*/function () {
|
|
|
310
267
|
})
|
|
311
268
|
}
|
|
312
269
|
}));
|
|
313
|
-
|
|
314
270
|
return this;
|
|
315
271
|
}
|
|
316
272
|
/**
|
|
@@ -319,12 +275,10 @@ var ThemeBuilder = /*#__PURE__*/function () {
|
|
|
319
275
|
* @param createScale A function that accepts the current theme and returns a new object of scale values.
|
|
320
276
|
* @example .addScale('fonts', () => ({ basic: 'Gotham', cool: 'Wingdings' }))
|
|
321
277
|
*/
|
|
322
|
-
|
|
323
278
|
}, {
|
|
324
279
|
key: "addScale",
|
|
325
280
|
value: function addScale(key, createScale) {
|
|
326
281
|
_classPrivateFieldSet(this, _theme, merge({}, _classPrivateFieldGet(this, _theme), _defineProperty({}, key, flattenScale(createScale(_classPrivateFieldGet(this, _theme))))));
|
|
327
|
-
|
|
328
282
|
return this;
|
|
329
283
|
}
|
|
330
284
|
/**
|
|
@@ -333,26 +287,22 @@ var ThemeBuilder = /*#__PURE__*/function () {
|
|
|
333
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.
|
|
334
288
|
* @example .updateScale('fonts', ({ basic }) => ({ basicFallback: `{basic}, Montserrat` }))
|
|
335
289
|
*/
|
|
336
|
-
|
|
337
290
|
}, {
|
|
338
291
|
key: "updateScale",
|
|
339
292
|
value: function updateScale(key, updateFn) {
|
|
340
293
|
_classPrivateFieldSet(this, _theme, merge({}, _classPrivateFieldGet(this, _theme), _defineProperty({}, key, updateFn(_classPrivateFieldGet(this, _theme)[key]))));
|
|
341
|
-
|
|
342
294
|
return this;
|
|
343
295
|
}
|
|
344
296
|
/**
|
|
345
297
|
* This finalizes the theme build and returns the final theme and variables to be provided.
|
|
346
298
|
*/
|
|
347
|
-
|
|
348
299
|
}, {
|
|
349
300
|
key: "build",
|
|
350
301
|
value: function build() {
|
|
351
302
|
var _serializeTokens4 = serializeTokens(mapValues(_classPrivateFieldGet(this, _theme).breakpoints, function (val) {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
303
|
+
return "".concat(val, "px");
|
|
304
|
+
}), 'breakpoint', _classPrivateFieldGet(this, _theme)),
|
|
305
|
+
variables = _serializeTokens4.variables;
|
|
356
306
|
return merge({}, _classPrivateFieldGet(this, _theme), {
|
|
357
307
|
_variables: {
|
|
358
308
|
breakpoints: variables
|
|
@@ -361,7 +311,6 @@ var ThemeBuilder = /*#__PURE__*/function () {
|
|
|
361
311
|
});
|
|
362
312
|
}
|
|
363
313
|
}]);
|
|
364
|
-
|
|
365
314
|
return ThemeBuilder;
|
|
366
315
|
}();
|
|
367
316
|
function createTheme(base) {
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* Returns an exhaustive list of all possible paths of an object T for keys K.
|
|
3
3
|
* Possibilities are returned as `k1.k2.k3`.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
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
6
|
/** Returns valid paths of object T */
|
|
7
|
-
export
|
|
7
|
+
export type Path<T, D extends string = '.'> = FindPath<T, keyof T, D> | keyof T;
|
|
8
8
|
/** Returns the value of a valid path P `k1.k2.k3` in object T */
|
|
9
|
-
export
|
|
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
10
|
/** Check if path has a primitive end value and return only the union of end paths */
|
|
11
|
-
export
|
|
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
12
|
/**
|
|
13
13
|
* Reduce all paths to a single map of paths with primitive values removing all extra non stateful paths
|
|
14
14
|
* { path: { sub: 1 } } => { 'path-sub': 1 }
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export type LiteralPaths<T extends Record<string | number, any>, D extends string = '.', Base extends string = ''> = {
|
|
18
18
|
[K in Path<T, D> as PathToLiteral<T, K, D, Base>]: PathValue<T, PathToLiteral<T, K, D>, D>;
|
|
19
19
|
};
|
|
20
20
|
export declare function flattenScale<T extends Record<string | number, unknown>, P extends string>(object: T, path?: P): LiteralPaths<T, '-', '_'>;
|
|
@@ -3,11 +3,11 @@ import { Theme } from '@emotion/react';
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns an type of any object with { key: 'var(--key) }
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type KeyAsVariable<T extends Record<string, any>, Prefix extends string> = {
|
|
7
7
|
[V in keyof T]: `var(--${Prefix}-${SanitizeKey<Extract<V, string>>})`;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
10
|
-
|
|
9
|
+
export type SanitizeKey<T extends string> = T extends `${'$'}${infer Y}` ? Y : T;
|
|
10
|
+
type SerializedTokensInput = Record<string, string | number | CSSObject | SerializedTokensInputRecursive>;
|
|
11
11
|
interface SerializedTokensInputRecursive {
|
|
12
12
|
[i: number]: SerializedTokensInput;
|
|
13
13
|
[i: string]: SerializedTokensInput;
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -8,21 +8,21 @@ import { AbstractTheme, CSSObject } from '@animus-ui/core';
|
|
|
8
8
|
*
|
|
9
9
|
* The resulting type is then rejoined with keys that cannot be mutated (breakpoints) as the next version of Theme
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type MergeTheme<Base extends AbstractTheme, Next, Unmergable = Record<'breakpoints', Base['breakpoints']>> = Unmergable & Merge<Base, Next>;
|
|
12
12
|
/** This merges at 2 levels of depth */
|
|
13
|
-
export
|
|
13
|
+
export type Merge<A, B> = {
|
|
14
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
15
|
};
|
|
16
16
|
/** Extract mergable objects */
|
|
17
|
-
export
|
|
17
|
+
export type Mergable<T> = Exclude<T, ((...args: any) => any) | string | boolean | symbol | number | any[]>;
|
|
18
18
|
/** Return B if either A or B is unmergable */
|
|
19
|
-
export
|
|
19
|
+
export type AssignValueIfUnmergable<A, B> = Mergable<A> extends never ? B : Mergable<B> extends never ? B : Assign<A, B>;
|
|
20
20
|
/** Prefer all values from B */
|
|
21
|
-
export
|
|
21
|
+
export type Assign<A, B> = {
|
|
22
22
|
[K in keyof A | keyof B]: K extends keyof B ? B[K] : K extends keyof A ? A[K] : never;
|
|
23
23
|
};
|
|
24
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
|
|
25
|
+
export type PrivateThemeKeys = {
|
|
26
26
|
_variables: Record<string, CSSObject>;
|
|
27
27
|
_tokens: Record<string | number, any>;
|
|
28
28
|
};
|
|
@@ -38,4 +38,4 @@ export declare type PrivateThemeKeys = {
|
|
|
38
38
|
*
|
|
39
39
|
* `button-bg-hover`
|
|
40
40
|
* */
|
|
41
|
-
export
|
|
41
|
+
export type ColorModeConfig<Colors> = Record<string, Colors | Record<string, Colors> | Record<string, Colors | Record<string, Colors>>>;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@animus-ui/theming",
|
|
3
|
-
"version": "0.1.1-beta.
|
|
3
|
+
"version": "0.1.1-beta.25",
|
|
4
4
|
"description": "Theming Utilities",
|
|
5
5
|
"author": "Aaron Robb <airrobb@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/codecaaron/animus#readme",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"module": "dist/index.js",
|
|
9
|
-
"main": "dist/index.js",
|
|
10
|
-
"types": "dist/index.d.ts",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"url": "https://github.com/codecaaron/animus/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@animus-ui/core": "^0.1.1-beta.
|
|
28
|
+
"@animus-ui/core": "^0.1.1-beta.24",
|
|
29
29
|
"@emotion/react": "^11.0.0",
|
|
30
30
|
"@emotion/styled": "^11.0.0"
|
|
31
31
|
},
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"lodash": "*",
|
|
34
34
|
"typescript": ">=4.3.5"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "42aeb80b573618b883e9740ba803ed54ed29d5e5"
|
|
37
37
|
}
|