@animus-ui/system 0.1.0-next.1
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/dist/Animus.d.ts +75 -0
- package/dist/Animus.d.ts.map +1 -0
- package/dist/AnimusExtended.d.ts +69 -0
- package/dist/AnimusExtended.d.ts.map +1 -0
- package/dist/PropertyBuilder.d.ts +11 -0
- package/dist/PropertyBuilder.d.ts.map +1 -0
- package/dist/SystemBuilder.d.ts +46 -0
- package/dist/SystemBuilder.d.ts.map +1 -0
- package/dist/groups/index.d.ts +630 -0
- package/dist/groups/index.d.ts.map +1 -0
- package/dist/groups/index.js +474 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +295 -0
- package/dist/scales/createScale.d.ts +7 -0
- package/dist/scales/createScale.d.ts.map +1 -0
- package/dist/size-Dge_rsuz.js +70 -0
- package/dist/transforms/border.d.ts +2 -0
- package/dist/transforms/border.d.ts.map +1 -0
- package/dist/transforms/createTransform.d.ts +6 -0
- package/dist/transforms/createTransform.d.ts.map +1 -0
- package/dist/transforms/grid.d.ts +5 -0
- package/dist/transforms/grid.d.ts.map +1 -0
- package/dist/transforms/index.d.ts +6 -0
- package/dist/transforms/index.d.ts.map +1 -0
- package/dist/transforms/size.d.ts +3 -0
- package/dist/transforms/size.d.ts.map +1 -0
- package/dist/transforms/utils.d.ts +3 -0
- package/dist/transforms/utils.d.ts.map +1 -0
- package/dist/types/component.d.ts +55 -0
- package/dist/types/component.d.ts.map +1 -0
- package/dist/types/config.d.ts +78 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/properties.d.ts +19 -0
- package/dist/types/properties.d.ts.map +1 -0
- package/dist/types/props.d.ts +35 -0
- package/dist/types/props.d.ts.map +1 -0
- package/dist/types/scales.d.ts +3 -0
- package/dist/types/scales.d.ts.map +1 -0
- package/dist/types/shared.d.ts +5 -0
- package/dist/types/shared.d.ts.map +1 -0
- package/dist/types/theme.d.ts +32 -0
- package/dist/types/theme.d.ts.map +1 -0
- package/dist/types/utils.d.ts +5 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +46 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { a as borderShorthand, c as numericOrStringScale, i as gridItemRatio, l as numericScale, n as size, o as createTransform, r as gridItem, s as createScale, t as percentageOrAbsolute, u as stringScale } from "./size-Dge_rsuz.js";
|
|
2
|
+
import { createComponent } from "@animus-ui/runtime";
|
|
3
|
+
import { createTheme } from "@animus-ui/theming";
|
|
4
|
+
//#region src/AnimusExtended.ts
|
|
5
|
+
function deepMerge$1(target, source) {
|
|
6
|
+
const result = { ...target };
|
|
7
|
+
for (const key of Object.keys(source)) if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key]) && target[key] && typeof target[key] === "object" && !Array.isArray(target[key])) result[key] = deepMerge$1(target[key], source[key]);
|
|
8
|
+
else result[key] = source[key];
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
var AnimusExtendedWithAll = class {
|
|
12
|
+
propRegistry = {};
|
|
13
|
+
groupRegistry = {};
|
|
14
|
+
baseStyles = {};
|
|
15
|
+
statesConfig = {};
|
|
16
|
+
variants = {};
|
|
17
|
+
activeGroups = {};
|
|
18
|
+
custom = {};
|
|
19
|
+
constructor(props, groups, base, variants, states, activeGroups, custom) {
|
|
20
|
+
this.propRegistry = props;
|
|
21
|
+
this.groupRegistry = groups;
|
|
22
|
+
this.baseStyles = base;
|
|
23
|
+
this.variants = variants;
|
|
24
|
+
this.statesConfig = states;
|
|
25
|
+
this.activeGroups = activeGroups;
|
|
26
|
+
this.custom = custom;
|
|
27
|
+
}
|
|
28
|
+
extend() {
|
|
29
|
+
return new AnimusExtended(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, this.custom);
|
|
30
|
+
}
|
|
31
|
+
asElement(component) {
|
|
32
|
+
const Component = createComponent(component, "", this._buildComponentConfig());
|
|
33
|
+
const extendFn = this.extend.bind(this);
|
|
34
|
+
return Object.assign(Component, { extend: extendFn });
|
|
35
|
+
}
|
|
36
|
+
asComponent(AsComponent) {
|
|
37
|
+
const Component = createComponent(AsComponent, "", this._buildComponentConfig());
|
|
38
|
+
const extendFn = this.extend.bind(this);
|
|
39
|
+
return Object.assign(Component, { extend: extendFn });
|
|
40
|
+
}
|
|
41
|
+
build() {
|
|
42
|
+
return Object.assign((() => ({})), { extend: this.extend.bind(this) });
|
|
43
|
+
}
|
|
44
|
+
_buildComponentConfig() {
|
|
45
|
+
const variantConfig = {};
|
|
46
|
+
for (const [key, vc] of Object.entries(this.variants)) {
|
|
47
|
+
const prop = vc.prop || key;
|
|
48
|
+
variantConfig[prop] = {
|
|
49
|
+
options: Object.keys(vc.variants || {}),
|
|
50
|
+
default: vc.defaultVariant
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const states = Object.keys(this.statesConfig);
|
|
54
|
+
const allPropNames = [...Object.keys(this.propRegistry), ...Object.keys(this.custom)];
|
|
55
|
+
return {
|
|
56
|
+
variants: Object.keys(variantConfig).length > 0 ? variantConfig : void 0,
|
|
57
|
+
states: states.length > 0 ? states : void 0,
|
|
58
|
+
systemPropNames: allPropNames
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var AnimusExtendedWithSystem = class extends AnimusExtendedWithAll {
|
|
63
|
+
props(config) {
|
|
64
|
+
return new AnimusExtendedWithAll(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, deepMerge$1({}, config));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var AnimusExtendedWithStates = class extends AnimusExtendedWithSystem {
|
|
68
|
+
groups(config) {
|
|
69
|
+
return new AnimusExtendedWithSystem(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, deepMerge$1(this.activeGroups, config), this.custom);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var AnimusExtendedWithVariants = class AnimusExtendedWithVariants extends AnimusExtendedWithStates {
|
|
73
|
+
variant(options) {
|
|
74
|
+
const prop = options.prop || "variant";
|
|
75
|
+
return new AnimusExtendedWithVariants(this.propRegistry, this.groupRegistry, this.baseStyles, deepMerge$1(this.variants, { [prop]: options }), this.statesConfig, this.activeGroups, this.custom);
|
|
76
|
+
}
|
|
77
|
+
states(config) {
|
|
78
|
+
return new AnimusExtendedWithStates(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, deepMerge$1(this.statesConfig, config), this.activeGroups, this.custom);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var AnimusExtendedWithBase = class extends AnimusExtendedWithVariants {
|
|
82
|
+
variant(options) {
|
|
83
|
+
const prop = options.prop || "variant";
|
|
84
|
+
return new AnimusExtendedWithVariants(this.propRegistry, this.groupRegistry, this.baseStyles, deepMerge$1(this.variants, { [prop]: options }), this.statesConfig, this.activeGroups, this.custom);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var AnimusExtended = class extends AnimusExtendedWithBase {
|
|
88
|
+
styles(config) {
|
|
89
|
+
return new AnimusExtendedWithBase(this.propRegistry, this.groupRegistry, deepMerge$1(this.baseStyles, config), this.variants, this.statesConfig, this.activeGroups, this.custom);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/Animus.ts
|
|
94
|
+
/**
|
|
95
|
+
* Deep merge utility — replaces lodash.merge for variant accumulation.
|
|
96
|
+
*/
|
|
97
|
+
function deepMerge(target, source) {
|
|
98
|
+
const result = { ...target };
|
|
99
|
+
for (const key of Object.keys(source)) if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key]) && target[key] && typeof target[key] === "object" && !Array.isArray(target[key])) result[key] = deepMerge(target[key], source[key]);
|
|
100
|
+
else result[key] = source[key];
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
var AnimusWithAll = class {
|
|
104
|
+
propRegistry = {};
|
|
105
|
+
groupRegistry = {};
|
|
106
|
+
baseStyles = {};
|
|
107
|
+
statesConfig = {};
|
|
108
|
+
variants = {};
|
|
109
|
+
activeGroups = {};
|
|
110
|
+
custom = {};
|
|
111
|
+
constructor(props, groups, base, variants, states, activeGroups, custom) {
|
|
112
|
+
this.propRegistry = props;
|
|
113
|
+
this.groupRegistry = groups;
|
|
114
|
+
this.baseStyles = base;
|
|
115
|
+
this.variants = variants;
|
|
116
|
+
this.statesConfig = states;
|
|
117
|
+
this.activeGroups = activeGroups;
|
|
118
|
+
this.custom = custom;
|
|
119
|
+
}
|
|
120
|
+
extend() {
|
|
121
|
+
return new AnimusExtended(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, this.custom);
|
|
122
|
+
}
|
|
123
|
+
asElement(component) {
|
|
124
|
+
const Component = createComponent(component, "", this._buildComponentConfig());
|
|
125
|
+
const extendFn = this.extend.bind(this);
|
|
126
|
+
return Object.assign(Component, { extend: extendFn });
|
|
127
|
+
}
|
|
128
|
+
asComponent(AsComponent) {
|
|
129
|
+
const Component = createComponent(AsComponent, "", this._buildComponentConfig());
|
|
130
|
+
const extendFn = this.extend.bind(this);
|
|
131
|
+
return Object.assign(Component, { extend: extendFn });
|
|
132
|
+
}
|
|
133
|
+
build() {
|
|
134
|
+
return Object.assign((() => ({})), { extend: this.extend.bind(this) });
|
|
135
|
+
}
|
|
136
|
+
_buildComponentConfig() {
|
|
137
|
+
const variantConfig = {};
|
|
138
|
+
for (const [key, vc] of Object.entries(this.variants)) {
|
|
139
|
+
const prop = vc.prop || key;
|
|
140
|
+
variantConfig[prop] = {
|
|
141
|
+
options: Object.keys(vc.variants || {}),
|
|
142
|
+
default: vc.defaultVariant
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const states = Object.keys(this.statesConfig);
|
|
146
|
+
const allPropNames = [...Object.keys(this.propRegistry), ...Object.keys(this.custom)];
|
|
147
|
+
return {
|
|
148
|
+
variants: Object.keys(variantConfig).length > 0 ? variantConfig : void 0,
|
|
149
|
+
states: states.length > 0 ? states : void 0,
|
|
150
|
+
systemPropNames: allPropNames
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var AnimusWithSystem = class extends AnimusWithAll {
|
|
155
|
+
constructor(props, groups, base, variants, states, activeGroups) {
|
|
156
|
+
super(props, groups, base, variants, states, activeGroups, {});
|
|
157
|
+
}
|
|
158
|
+
props(config) {
|
|
159
|
+
return new AnimusWithAll(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, config);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
var AnimusWithStates = class extends AnimusWithSystem {
|
|
163
|
+
constructor(props, groups, base, variants, states) {
|
|
164
|
+
super(props, groups, base, variants, states, {});
|
|
165
|
+
}
|
|
166
|
+
groups(config) {
|
|
167
|
+
return new AnimusWithSystem(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, config);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
var AnimusWithVariants = class AnimusWithVariants extends AnimusWithStates {
|
|
171
|
+
constructor(props, groups, base, variants) {
|
|
172
|
+
super(props, groups, base, variants, {});
|
|
173
|
+
}
|
|
174
|
+
states(config) {
|
|
175
|
+
return new AnimusWithStates(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, config);
|
|
176
|
+
}
|
|
177
|
+
variant(options) {
|
|
178
|
+
const prop = options.prop || "variant";
|
|
179
|
+
return new AnimusWithVariants(this.propRegistry, this.groupRegistry, this.baseStyles, deepMerge(this.variants, { [prop]: options }));
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
var AnimusWithBase = class extends AnimusWithVariants {
|
|
183
|
+
constructor(props, groups, base) {
|
|
184
|
+
super(props, groups, base, {});
|
|
185
|
+
}
|
|
186
|
+
variant(options) {
|
|
187
|
+
const prop = options.prop || "variant";
|
|
188
|
+
return new AnimusWithVariants(this.propRegistry, this.groupRegistry, this.baseStyles, deepMerge(this.variants, { [prop]: options }));
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
var Animus = class extends AnimusWithBase {
|
|
192
|
+
constructor(props, groups) {
|
|
193
|
+
super(props, groups, {});
|
|
194
|
+
}
|
|
195
|
+
styles(config) {
|
|
196
|
+
return new AnimusWithBase(this.propRegistry, this.groupRegistry, config);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/PropertyBuilder.ts
|
|
201
|
+
var PropertyBuilder = class PropertyBuilder {
|
|
202
|
+
#props;
|
|
203
|
+
#groups;
|
|
204
|
+
constructor(props, groups) {
|
|
205
|
+
this.#props = props || {};
|
|
206
|
+
this.#groups = groups || {};
|
|
207
|
+
}
|
|
208
|
+
addGroup(name, config) {
|
|
209
|
+
const newGroup = { [name]: Object.keys(config) };
|
|
210
|
+
return new PropertyBuilder({
|
|
211
|
+
...this.#props,
|
|
212
|
+
...config
|
|
213
|
+
}, {
|
|
214
|
+
...this.#groups,
|
|
215
|
+
...newGroup
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
build() {
|
|
219
|
+
return {
|
|
220
|
+
propRegistry: this.#props,
|
|
221
|
+
groupRegistry: this.#groups
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region src/SystemBuilder.ts
|
|
227
|
+
var SystemBuilder = class SystemBuilder {
|
|
228
|
+
#tokens;
|
|
229
|
+
#propRegistry;
|
|
230
|
+
#groupRegistry;
|
|
231
|
+
#globalStyles;
|
|
232
|
+
constructor(tokens, propRegistry, groupRegistry, globalStyles) {
|
|
233
|
+
this.#tokens = tokens || {};
|
|
234
|
+
this.#propRegistry = propRegistry || {};
|
|
235
|
+
this.#groupRegistry = groupRegistry || {};
|
|
236
|
+
this.#globalStyles = globalStyles;
|
|
237
|
+
}
|
|
238
|
+
withTokens(cb) {
|
|
239
|
+
return new SystemBuilder(cb(createTheme({ breakpoints: {
|
|
240
|
+
xs: 0,
|
|
241
|
+
sm: 0,
|
|
242
|
+
md: 0,
|
|
243
|
+
lg: 0,
|
|
244
|
+
xl: 0
|
|
245
|
+
} })), this.#propRegistry, this.#groupRegistry, this.#globalStyles);
|
|
246
|
+
}
|
|
247
|
+
withProperties(cb) {
|
|
248
|
+
const result = cb(new PropertyBuilder());
|
|
249
|
+
return new SystemBuilder(this.#tokens, result.propRegistry, result.groupRegistry, this.#globalStyles);
|
|
250
|
+
}
|
|
251
|
+
withGlobalStyles(styles) {
|
|
252
|
+
return new SystemBuilder(this.#tokens, this.#propRegistry, this.#groupRegistry, styles);
|
|
253
|
+
}
|
|
254
|
+
build() {
|
|
255
|
+
const animus = new Animus(this.#propRegistry, this.#groupRegistry);
|
|
256
|
+
const globalStyles = this.#globalStyles;
|
|
257
|
+
return Object.assign(animus, {
|
|
258
|
+
tokens: this.#tokens,
|
|
259
|
+
serialize: () => {
|
|
260
|
+
return serializeInstance(this.#tokens, this.#propRegistry, this.#groupRegistry, globalStyles);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
function serializeInstance(tokens, propRegistry, groupRegistry, globalStyles) {
|
|
266
|
+
const serialized = {};
|
|
267
|
+
const transforms = {};
|
|
268
|
+
for (const [propName, entry] of Object.entries(propRegistry)) {
|
|
269
|
+
const s = { property: entry.property };
|
|
270
|
+
if (entry.properties && entry.properties.length > 0) s.properties = [...entry.properties];
|
|
271
|
+
if (typeof entry.scale === "string") s.scale = entry.scale;
|
|
272
|
+
if (entry.transform) {
|
|
273
|
+
const fn = entry.transform;
|
|
274
|
+
const name = fn.transformName ?? fn.name;
|
|
275
|
+
if (name) {
|
|
276
|
+
s.transform = name;
|
|
277
|
+
transforms[name] = fn;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
serialized[propName] = s;
|
|
281
|
+
}
|
|
282
|
+
const result = {
|
|
283
|
+
tokens,
|
|
284
|
+
propConfig: JSON.stringify(serialized),
|
|
285
|
+
groupRegistry: JSON.stringify(groupRegistry),
|
|
286
|
+
transforms
|
|
287
|
+
};
|
|
288
|
+
if (globalStyles) result.globalStyles = globalStyles;
|
|
289
|
+
return result;
|
|
290
|
+
}
|
|
291
|
+
function createSystem() {
|
|
292
|
+
return new SystemBuilder();
|
|
293
|
+
}
|
|
294
|
+
//#endregion
|
|
295
|
+
export { Animus, AnimusExtended, AnimusExtendedWithAll, AnimusWithAll, PropertyBuilder, SystemBuilder, borderShorthand, createScale, createSystem, createTransform, gridItem, gridItemRatio, numericOrStringScale, numericScale, percentageOrAbsolute, size, stringScale };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const createScale: <T extends string | number>() => readonly T[] & {
|
|
2
|
+
length: 0;
|
|
3
|
+
};
|
|
4
|
+
export declare const numericScale: (number & {})[];
|
|
5
|
+
export declare const stringScale: (string & {})[];
|
|
6
|
+
export declare const numericOrStringScale: ((string & {}) | (number & {}))[];
|
|
7
|
+
//# sourceMappingURL=createScale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createScale.d.ts","sourceRoot":"","sources":["../../src/scales/createScale.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,GAAG,MAAM,OAC7C,SAAS,CAAC,EAAE,GAAG;IAAE,MAAM,EAAE,CAAC,CAAA;CAAE,CAAC;AAErC,eAAO,MAAM,YAAY,EAAS,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC;AAElD,eAAO,MAAM,WAAW,EAAS,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC;AAEjD,eAAO,MAAM,oBAAoB,EAAS,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//#region src/scales/createScale.ts
|
|
2
|
+
const createScale = () => [];
|
|
3
|
+
const numericScale = [];
|
|
4
|
+
const stringScale = [];
|
|
5
|
+
const numericOrStringScale = [];
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/transforms/createTransform.ts
|
|
8
|
+
function createTransform(name, fn) {
|
|
9
|
+
const wrapper = (value, property, props) => fn(value, property, props);
|
|
10
|
+
Object.defineProperty(wrapper, "name", { value: name });
|
|
11
|
+
return Object.assign(wrapper, { transformName: name });
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/transforms/utils.ts
|
|
15
|
+
const numberToTemplate = (val, template) => typeof val === "number" ? template(val) : val;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/transforms/border.ts
|
|
18
|
+
const borderShorthand = createTransform("borderShorthand", (val) => numberToTemplate(val, (width) => `${width}px solid currentColor`));
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/transforms/grid.ts
|
|
21
|
+
const gridItemMap = {
|
|
22
|
+
max: "max-content",
|
|
23
|
+
min: "min-content"
|
|
24
|
+
};
|
|
25
|
+
const unitlessNumber = /* @__PURE__ */ new RegExp(/^[0-9]*$/);
|
|
26
|
+
const isUnitlessNumber = (val) => unitlessNumber.test(val);
|
|
27
|
+
const gridItem = createTransform("gridItem", (item) => {
|
|
28
|
+
const strItem = String(item);
|
|
29
|
+
return `minmax(0, ${isUnitlessNumber(strItem) ? `${strItem}fr` : gridItemMap[strItem] ?? strItem})`;
|
|
30
|
+
});
|
|
31
|
+
const repeatGridItem = (item, count) => {
|
|
32
|
+
const template = gridItem(item);
|
|
33
|
+
return count > 1 ? `repeat(${count}, ${template})` : template;
|
|
34
|
+
};
|
|
35
|
+
const parseGridRatio = (val) => {
|
|
36
|
+
const items = val.split(":");
|
|
37
|
+
let repeated = ["", 0];
|
|
38
|
+
let gridStyle = "";
|
|
39
|
+
for (let i = 0; i < items.length + 1; i += 1) {
|
|
40
|
+
const delimiter = gridStyle.length > 0 ? " " : "";
|
|
41
|
+
const curr = items[i];
|
|
42
|
+
if (repeated?.[0] !== curr) {
|
|
43
|
+
if (repeated[0].length) gridStyle += delimiter + repeatGridItem(...repeated);
|
|
44
|
+
if (curr) repeated = [curr, 1];
|
|
45
|
+
} else repeated[1] += 1;
|
|
46
|
+
}
|
|
47
|
+
return gridStyle;
|
|
48
|
+
};
|
|
49
|
+
const gridItemRatio = createTransform("gridItemRatio", (val) => {
|
|
50
|
+
return typeof val === "number" ? repeatGridItem("1", val) : parseGridRatio(val);
|
|
51
|
+
});
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/transforms/size.ts
|
|
54
|
+
const percentageOrAbsolute = (coordinate) => {
|
|
55
|
+
if (coordinate === 0) return coordinate;
|
|
56
|
+
if (coordinate <= 1 && coordinate >= -1) return `${coordinate * 100}%`;
|
|
57
|
+
return `${coordinate}px`;
|
|
58
|
+
};
|
|
59
|
+
const valueWithUnit = /(-?\d*\.?\d+)(%|\w*)/;
|
|
60
|
+
const size = createTransform("size", (value) => {
|
|
61
|
+
if (typeof value === "number") return percentageOrAbsolute(value);
|
|
62
|
+
const strValue = value;
|
|
63
|
+
if (strValue.includes("calc")) return strValue;
|
|
64
|
+
const [match, number, unit] = valueWithUnit.exec(strValue) || [];
|
|
65
|
+
if (match === void 0) return strValue;
|
|
66
|
+
const numericValue = parseFloat(number);
|
|
67
|
+
return !unit ? percentageOrAbsolute(numericValue) : `${numericValue}${unit}`;
|
|
68
|
+
});
|
|
69
|
+
//#endregion
|
|
70
|
+
export { borderShorthand as a, numericOrStringScale as c, gridItemRatio as i, numericScale as l, size as n, createTransform as o, gridItem as r, createScale as s, percentageOrAbsolute as t, stringScale as u };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"border.d.ts","sourceRoot":"","sources":["../../src/transforms/border.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,4CAE3B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type TransformFn = (value: string | number, property?: string, props?: any) => string | number | Record<string, any>;
|
|
2
|
+
export type NamedTransform = TransformFn & {
|
|
3
|
+
transformName: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function createTransform(name: string, fn: TransformFn): NamedTransform;
|
|
6
|
+
//# sourceMappingURL=createTransform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTransform.d.ts","sourceRoot":"","sources":["../../src/transforms/createTransform.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CACxB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,GAAG,KACR,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE3C,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,cAAc,CAK7E"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const gridItem: import("./createTransform").NamedTransform;
|
|
2
|
+
export declare const repeatGridItem: (item: string, count: number) => string;
|
|
3
|
+
export declare const parseGridRatio: (val: string) => string;
|
|
4
|
+
export declare const gridItemRatio: import("./createTransform").NamedTransform;
|
|
5
|
+
//# sourceMappingURL=grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/transforms/grid.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,QAAQ,4CAMnB,CAAC;AAEH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,WAGzD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,WAkBzC,CAAC;AAEF,eAAO,MAAM,aAAa,4CAIxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../src/transforms/size.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,GAAI,YAAY,MAAM,eAQtD,CAAC;AAIF,eAAO,MAAM,IAAI,4CAoBf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/transforms/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,GAC3B,KAAK,MAAM,GAAG,MAAM,EACpB,UAAU,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,WACiB,CAAC;AAErD,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,GAAG,MAAM,WAE9C,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, ForwardRefExoticComponent, ReactNode } from 'react';
|
|
2
|
+
import type { AnimusExtended } from '../AnimusExtended';
|
|
3
|
+
import type { AbstractParser, CSSPropMap, CSSProps, Prop, Scale, SystemProps, VariantConfig } from './config';
|
|
4
|
+
import type { AbstractProps } from './props';
|
|
5
|
+
import type { BaseTheme } from './theme';
|
|
6
|
+
type ExtendFn<T extends BaseTheme, PR extends Record<string, Prop>, GR extends Record<string, (keyof PR)[]>, BS, V, S, AG, CP> = {
|
|
7
|
+
extend: () => AnimusExtended<T, PR, GR, BS & CSSProps<AbstractProps, SystemProps<AbstractParser>>, V & Record<string, VariantConfig>, S & CSSPropMap<AbstractProps, SystemProps<AbstractParser>>, AG & Record<string, true>, CP & Record<string, Prop>>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Compute the group prop names from active groups.
|
|
11
|
+
* GR maps group names to prop name arrays, AG records which groups are active.
|
|
12
|
+
* The result is the union of prop names from all active groups.
|
|
13
|
+
*/
|
|
14
|
+
type ActiveGroupPropNames<PR extends Record<string, Prop>, GR extends Record<string, (keyof PR)[]>, AG> = GR[Extract<keyof AG, keyof GR>][number];
|
|
15
|
+
/**
|
|
16
|
+
* Compute the group system props — each active group prop accepts its scale-resolved type.
|
|
17
|
+
* For pragmatic type inference, we use Scale<PR[K], T> for each prop.
|
|
18
|
+
*/
|
|
19
|
+
type GroupProps<T extends BaseTheme, PR extends Record<string, Prop>, GR extends Record<string, (keyof PR)[]>, AG> = {
|
|
20
|
+
[K in ActiveGroupPropNames<PR, GR, AG> as K extends string ? K : never]?: Scale<PR[K & keyof PR], T>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Compute custom prop types from .props() config.
|
|
24
|
+
* Each key K in CP maps to Scale<CP[K], T>.
|
|
25
|
+
*/
|
|
26
|
+
type CustomPropValues<CP extends Record<string, Prop>, T extends BaseTheme> = {
|
|
27
|
+
[K in keyof CP]?: Scale<CP[K], T>;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Compute variant props — each variant key accepts one of its variant values.
|
|
31
|
+
* Guard: if V widened to string index signature (Record<string, VariantConfig>),
|
|
32
|
+
* produce {} instead of { [x: string]?: string } which would reject children.
|
|
33
|
+
*/
|
|
34
|
+
type VariantProps<V> = string extends keyof V ? {} : {
|
|
35
|
+
[K in keyof V]?: V[K] extends VariantConfig ? keyof V[K]['variants'] : string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Compute state props — each state key is a boolean toggle.
|
|
39
|
+
* Same guard against widened index signatures.
|
|
40
|
+
*/
|
|
41
|
+
type StateProps<S> = string extends keyof S ? {} : {
|
|
42
|
+
[K in keyof S]?: boolean;
|
|
43
|
+
};
|
|
44
|
+
/** Component type for .asElement() — HTML element tag with full Animus props. */
|
|
45
|
+
export type AnimusComponent<El extends keyof JSX.IntrinsicElements, T extends BaseTheme, PR extends Record<string, Prop>, GR extends Record<string, (keyof PR)[]>, BS, V, S, AG, CP extends Record<string, Prop>> = ForwardRefExoticComponent<ComponentPropsWithRef<El> & GroupProps<T, PR, GR, AG> & VariantProps<V> & StateProps<S> & CustomPropValues<CP, T> & {
|
|
46
|
+
className?: string;
|
|
47
|
+
children?: ReactNode;
|
|
48
|
+
}> & ExtendFn<T, PR, GR, BS, V, S, AG, CP>;
|
|
49
|
+
/** Component type for .asComponent() — wraps an existing React component. */
|
|
50
|
+
export type AnimusWrappedComponent<T extends BaseTheme, PR extends Record<string, Prop>, GR extends Record<string, (keyof PR)[]>, BS, V, S, AG, CP> = ForwardRefExoticComponent<Record<string, any> & GroupProps<T, PR, GR, {}> & VariantProps<V> & StateProps<S> & {
|
|
51
|
+
className?: string;
|
|
52
|
+
children?: ReactNode;
|
|
53
|
+
}> & ExtendFn<T, PR, GR, BS, V, S, AG, CP>;
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/types/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,yBAAyB,EACzB,SAAS,EACV,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,WAAW,EACX,aAAa,EACd,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,KAAK,QAAQ,CACX,CAAC,SAAS,SAAS,EACnB,EA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E,CAAC,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,CACzE,GACC,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAExC,6EAA6E;AAC7E,MAAM,MAAM,sBAAsB,CAChC,CAAC,SAAS,SAAS,EACnB,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAC/B,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EACvC,EAAE,EACF,CAAC,EACD,CAAC,EACD,EAAE,EACF,EAAE,IACA,yBAAyB,CAC3B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACjB,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GACzB,YAAY,CAAC,CAAC,CAAC,GACf,UAAU,CAAC,CAAC,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,CAC/D,GACC,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { DefaultCSSPropertyValue, PropertyTypes } from './properties';
|
|
2
|
+
import { AbstractProps, ResponsiveProp, ThemeProps } from './props';
|
|
3
|
+
import { ArrayScale, MapScale } from './scales';
|
|
4
|
+
import { CSSObject } from './shared';
|
|
5
|
+
import { BaseTheme, Theme, TokenScales } from './theme';
|
|
6
|
+
import { Arg } from './utils';
|
|
7
|
+
export interface BaseProperty {
|
|
8
|
+
property: keyof PropertyTypes;
|
|
9
|
+
properties?: readonly (keyof PropertyTypes)[];
|
|
10
|
+
}
|
|
11
|
+
export interface Prop extends BaseProperty {
|
|
12
|
+
scale?: string | MapScale | ArrayScale;
|
|
13
|
+
variable?: string;
|
|
14
|
+
transform?: (val: string | number, prop?: string, props?: AbstractProps) => string | number | CSSObject;
|
|
15
|
+
}
|
|
16
|
+
export interface AbstractParser {
|
|
17
|
+
(props: AbstractProps, orderProps?: boolean): CSSObject;
|
|
18
|
+
propNames: string[];
|
|
19
|
+
config: Record<string, Prop>;
|
|
20
|
+
}
|
|
21
|
+
type IsEmpty<T> = [] extends T ? true : false | {} extends T ? true : false;
|
|
22
|
+
export type PropertyValues<Property extends Prop, IncludeGlobals = false> = Exclude<PropertyTypes<IncludeGlobals extends true ? DefaultCSSPropertyValue : never>[Property['property']], IncludeGlobals extends true ? never : object | any[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Resolve scale values from T directly. No CompatTheme fallback.
|
|
25
|
+
*
|
|
26
|
+
* Resolution order:
|
|
27
|
+
* 1. If scale is a key of T's token scales → keyof T[scale]
|
|
28
|
+
* 2. If scale is an inline MapScale → keyof scale
|
|
29
|
+
* 3. If scale is an inline ArrayScale → scale[number]
|
|
30
|
+
* 4. Otherwise → raw CSS property values
|
|
31
|
+
*/
|
|
32
|
+
export type ScaleValue<Config extends Prop, T extends BaseTheme> = Config['scale'] extends keyof TokenScales<T> ? keyof TokenScales<T>[Config['scale']] | PropertyValues<Config, IsEmpty<TokenScales<T>[Config['scale']]>> : Config['scale'] extends MapScale ? keyof Config['scale'] | PropertyValues<Config, IsEmpty<Config['scale']>> : Config['scale'] extends ArrayScale ? Config['scale'][number] | PropertyValues<Config, IsEmpty<Config['scale']>> : PropertyValues<Config, true>;
|
|
33
|
+
export type Scale<Config extends Prop, T extends BaseTheme> = ResponsiveProp<ScaleValue<Config, T>>;
|
|
34
|
+
export type ParserProps<Config extends Record<string, Prop>, T extends BaseTheme> = ThemeProps<{
|
|
35
|
+
[P in keyof Config]?: Scale<Config[P], T>;
|
|
36
|
+
}, T>;
|
|
37
|
+
export interface Parser<Config extends Record<string, Prop>, T extends BaseTheme> {
|
|
38
|
+
(props: ParserProps<Config, T>, orderProps?: boolean): CSSObject;
|
|
39
|
+
propNames: Extract<keyof Config, string>[];
|
|
40
|
+
config: Config;
|
|
41
|
+
}
|
|
42
|
+
export type SystemProps<P extends AbstractParser, SafeProps = Omit<Arg<P>, 'theme'>> = {
|
|
43
|
+
[K in keyof SafeProps]: SafeProps[K];
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Theme-fixed scale value — uses the augmentable Theme interface
|
|
47
|
+
* instead of a generic T. This enables type-safe CSS object constraints
|
|
48
|
+
* without threading T through the entire class hierarchy.
|
|
49
|
+
*/
|
|
50
|
+
export type ThemedScaleValue<Config extends Prop> = Config['scale'] extends keyof TokenScales<Theme> ? keyof TokenScales<Theme>[Config['scale']] | PropertyValues<Config, IsEmpty<TokenScales<Theme>[Config['scale']]>> : Config['scale'] extends MapScale ? keyof Config['scale'] | PropertyValues<Config, IsEmpty<Config['scale']>> : Config['scale'] extends ArrayScale ? Config['scale'][number] | PropertyValues<Config, IsEmpty<Config['scale']>> : PropertyValues<Config, true>;
|
|
51
|
+
export type ThemedScale<Config extends Prop> = ResponsiveProp<ThemedScaleValue<Config>>;
|
|
52
|
+
/**
|
|
53
|
+
* Theme-aware CSS props — uses the augmentable Theme interface
|
|
54
|
+
* to constrain values per-key. No generic T needed.
|
|
55
|
+
*
|
|
56
|
+
* When Theme is augmented, props with scales get constrained to scale keys.
|
|
57
|
+
* When Theme is NOT augmented (empty), falls back to standard CSS values.
|
|
58
|
+
*/
|
|
59
|
+
export type ThemedCSSProps<Props, Config extends Record<string, Prop>> = {
|
|
60
|
+
[K in keyof Props]?: K extends keyof Config ? ThemedScale<Config[K]> : K extends keyof PropertyTypes ? PropertyTypes[K] : unknown;
|
|
61
|
+
};
|
|
62
|
+
export type ThemedCSSPropMap<Props, Config extends Record<string, Prop>> = {
|
|
63
|
+
[K in keyof Props]?: ThemedCSSProps<Props[K], Config>;
|
|
64
|
+
};
|
|
65
|
+
export interface VariantConfig {
|
|
66
|
+
prop?: any;
|
|
67
|
+
defaultVariant?: any;
|
|
68
|
+
base?: CSSProps<AbstractProps, SystemProps<AbstractParser>>;
|
|
69
|
+
variants: CSSPropMap<AbstractProps, SystemProps<AbstractParser>>;
|
|
70
|
+
}
|
|
71
|
+
export type CSSPropMap<Props, System> = {
|
|
72
|
+
[K in keyof Props]?: CSSProps<Props[K], System>;
|
|
73
|
+
};
|
|
74
|
+
export type CSSProps<Props, System> = {
|
|
75
|
+
[K in keyof Props]?: K extends keyof System ? System[K] : K extends keyof PropertyTypes ? PropertyTypes[K] : Omit<PropertyTypes, keyof System> & Omit<System, 'theme'>;
|
|
76
|
+
};
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,aAAa,CAAC,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,IAAK,SAAQ,YAAY;IACxC,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;IACvC,QA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,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;CACtD,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,IAAI,CAAC,EAAE,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;IAC5D,QAAQ,EAAE,UAAU,CAAC,aAAa,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;CAClE;AAED,MAAM,MAAM,UAAU,CAAC,KAAK,EAAE,MAAM,IAAI;KACrC,CAAC,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI;KACnC,CAAC,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,MAAM,GACvC,MAAM,CAAC,CAAC,CAAC,GACT,CAAC,SAAS,MAAM,aAAa,GAC3B,aAAa,CAAC,CAAC,CAAC,GAChB,IAAI,CAAC,aAAa,EAAE,MAAM,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;CAChE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Globals, StandardProperties, SvgProperties, VendorProperties } from 'csstype';
|
|
2
|
+
import { CSSObject, NarrowPrimitive } from './shared';
|
|
3
|
+
type AnimusCSSProperties<Overrides = DefaultCSSPropertyValue> = StandardProperties<Overrides> & VendorProperties<Overrides> & Omit<SvgProperties<Overrides>, keyof StandardProperties>;
|
|
4
|
+
type ColorProperties = 'color' | `${string}Color` | 'fill' | 'stroke';
|
|
5
|
+
type ColorGlobals = {
|
|
6
|
+
[K in Extract<keyof AnimusCSSProperties, ColorProperties>]?: Globals | 'currentColor' | 'transparent' | NarrowPrimitive<string>;
|
|
7
|
+
};
|
|
8
|
+
type SizeProperties = 'left' | 'right' | 'top' | 'bottom' | 'inset' | 'width' | 'height' | `${string}${'Width' | 'Height'}`;
|
|
9
|
+
type SizeValues = `${number}${'px' | 'rem' | 'vh' | 'vw' | 'vmax' | 'vmin' | '%'}` | `calc(${any})`;
|
|
10
|
+
type SizeGlobals = {
|
|
11
|
+
[K in Extract<keyof AnimusCSSProperties, SizeProperties>]?: AnimusCSSProperties[K] | SizeValues | NarrowPrimitive<number>;
|
|
12
|
+
};
|
|
13
|
+
export type DefaultCSSPropertyValue = (string & {}) | 0;
|
|
14
|
+
export interface PropertyTypes<Overrides = DefaultCSSPropertyValue> extends Omit<AnimusCSSProperties<Overrides>, keyof ColorGlobals | keyof SizeGlobals>, ColorGlobals, SizeGlobals {
|
|
15
|
+
none?: never;
|
|
16
|
+
variables?: CSSObject;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=properties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../src/types/properties.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEtD,KAAK,mBAAmB,CAAC,SAAS,GAAG,uBAAuB,IAC1D,kBAAkB,CAAC,SAAS,CAAC,GAC3B,gBAAgB,CAAC,SAAS,CAAC,GAC3B,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,kBAAkB,CAAC,CAAC;AAE7D,KAAK,eAAe,GAAG,OAAO,GAAG,GAAG,MAAM,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtE,KAAK,YAAY,GAAG;KACjB,CAAC,IAAI,OAAO,CAAC,MAAM,mBAAmB,EAAE,eAAe,CAAC,CAAC,CAAC,EACvD,OAAO,GACP,cAAc,GACd,aAAa,GACb,eAAe,CAAC,MAAM,CAAC;CAC5B,CAAC;AAEF,KAAK,cAAc,GACf,MAAM,GACN,OAAO,GACP,KAAK,GACL,QAAQ,GACR,OAAO,GACP,OAAO,GACP,QAAQ,GACR,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,EAAE,CAAC;AAErC,KAAK,UAAU,GACX,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,EAAE,GAChE,QAAQ,GAAG,GAAG,CAAC;AAEnB,KAAK,WAAW,GAAG;KAChB,CAAC,IAAI,OAAO,CAAC,MAAM,mBAAmB,EAAE,cAAc,CAAC,CAAC,CAAC,EACtD,mBAAmB,CAAC,CAAC,CAAC,GACtB,UAAU,GACV,eAAe,CAAC,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;AAExD,MAAM,WAAW,aAAa,CAAC,SAAS,GAAG,uBAAuB,CAChE,SAAQ,IAAI,CACR,mBAAmB,CAAC,SAAS,CAAC,EAC9B,MAAM,YAAY,GAAG,MAAM,WAAW,CACvC,EACD,YAAY,EACZ,WAAW;IACb,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseTheme } from './theme';
|
|
2
|
+
export type AbstractProps = ThemeProps<Record<string, unknown>, BaseTheme>;
|
|
3
|
+
interface MediaQueryByKey<T = string> {
|
|
4
|
+
xs: T;
|
|
5
|
+
sm: T;
|
|
6
|
+
md: T;
|
|
7
|
+
lg: T;
|
|
8
|
+
xl: T;
|
|
9
|
+
}
|
|
10
|
+
export interface MediaQueryCache {
|
|
11
|
+
map: MediaQueryByKey;
|
|
12
|
+
array: string[];
|
|
13
|
+
}
|
|
14
|
+
export type ThemeProps<Props = {}, T extends BaseTheme = BaseTheme> = Props & {
|
|
15
|
+
theme?: T;
|
|
16
|
+
};
|
|
17
|
+
export interface MediaQueryArray<T> {
|
|
18
|
+
0?: T;
|
|
19
|
+
1?: T;
|
|
20
|
+
2?: T;
|
|
21
|
+
3?: T;
|
|
22
|
+
4?: T;
|
|
23
|
+
5?: T;
|
|
24
|
+
}
|
|
25
|
+
export interface MediaQueryMap<T> {
|
|
26
|
+
_?: T;
|
|
27
|
+
xs?: T;
|
|
28
|
+
sm?: T;
|
|
29
|
+
md?: T;
|
|
30
|
+
lg?: T;
|
|
31
|
+
xl?: T;
|
|
32
|
+
}
|
|
33
|
+
export type ResponsiveProp<T> = T | MediaQueryMap<T> | MediaQueryArray<T>;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=props.d.ts.map
|