@css-hooks/core 2.0.0 → 2.0.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/cjs/index.js +21 -2
- package/esm/index.js +21 -2
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -95,6 +95,26 @@ function buildHooksSystem(stringify = genericStringify) {
|
|
|
95
95
|
: specHash;
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
+
function conditionToId(condition) {
|
|
99
|
+
if (condition) {
|
|
100
|
+
if (typeof condition === "string") {
|
|
101
|
+
return hookNameToId(condition);
|
|
102
|
+
}
|
|
103
|
+
if (typeof condition === "object") {
|
|
104
|
+
if (condition.and) {
|
|
105
|
+
return `_${condition.and.map(conditionToId).join("-and-")}_`;
|
|
106
|
+
}
|
|
107
|
+
if (condition.or) {
|
|
108
|
+
return `_${condition.or.map(conditionToId).join("-or-")}_`;
|
|
109
|
+
}
|
|
110
|
+
if (condition.not) {
|
|
111
|
+
return `_-not-${conditionToId(condition.not)}_`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return `${condition}`;
|
|
116
|
+
}
|
|
117
|
+
|
|
98
118
|
function styleSheet() {
|
|
99
119
|
function variablePair({ id, initial, indents }) {
|
|
100
120
|
return [0, 1]
|
|
@@ -194,7 +214,6 @@ function buildHooksSystem(stringify = genericStringify) {
|
|
|
194
214
|
|
|
195
215
|
function css(...args) {
|
|
196
216
|
const style = {};
|
|
197
|
-
let conditionCount = 0;
|
|
198
217
|
const rules = args
|
|
199
218
|
.filter(rule => rule)
|
|
200
219
|
.reduce(
|
|
@@ -251,7 +270,7 @@ function buildHooksSystem(stringify = genericStringify) {
|
|
|
251
270
|
}
|
|
252
271
|
}
|
|
253
272
|
return name;
|
|
254
|
-
})(`cond
|
|
273
|
+
})(`cond-${hash(conditionToId(conditionId))}`, conditionId);
|
|
255
274
|
}
|
|
256
275
|
for (const [property, value] of Object.entries(rule[1])) {
|
|
257
276
|
const stringifiedValue = stringify(property, value);
|
package/esm/index.js
CHANGED
|
@@ -94,6 +94,26 @@ export function buildHooksSystem(stringify = genericStringify) {
|
|
|
94
94
|
: specHash;
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
+
function conditionToId(condition) {
|
|
98
|
+
if (condition) {
|
|
99
|
+
if (typeof condition === "string") {
|
|
100
|
+
return hookNameToId(condition);
|
|
101
|
+
}
|
|
102
|
+
if (typeof condition === "object") {
|
|
103
|
+
if (condition.and) {
|
|
104
|
+
return `_${condition.and.map(conditionToId).join("-and-")}_`;
|
|
105
|
+
}
|
|
106
|
+
if (condition.or) {
|
|
107
|
+
return `_${condition.or.map(conditionToId).join("-or-")}_`;
|
|
108
|
+
}
|
|
109
|
+
if (condition.not) {
|
|
110
|
+
return `_-not-${conditionToId(condition.not)}_`;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return `${condition}`;
|
|
115
|
+
}
|
|
116
|
+
|
|
97
117
|
function styleSheet() {
|
|
98
118
|
function variablePair({ id, initial, indents }) {
|
|
99
119
|
return [0, 1]
|
|
@@ -193,7 +213,6 @@ export function buildHooksSystem(stringify = genericStringify) {
|
|
|
193
213
|
|
|
194
214
|
function css(...args) {
|
|
195
215
|
const style = {};
|
|
196
|
-
let conditionCount = 0;
|
|
197
216
|
const rules = args
|
|
198
217
|
.filter(rule => rule)
|
|
199
218
|
.reduce(
|
|
@@ -250,7 +269,7 @@ export function buildHooksSystem(stringify = genericStringify) {
|
|
|
250
269
|
}
|
|
251
270
|
}
|
|
252
271
|
return name;
|
|
253
|
-
})(`cond
|
|
272
|
+
})(`cond-${hash(conditionToId(conditionId))}`, conditionId);
|
|
254
273
|
}
|
|
255
274
|
for (const [property, value] of Object.entries(rule[1])) {
|
|
256
275
|
const stringifiedValue = stringify(property, value);
|