@css-hooks/core 1.8.2 → 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/README.md +69 -37
- package/cjs/index.js +292 -257
- package/esm/index.js +291 -253
- package/package.json +17 -6
- package/types/index.d.ts +347 -65
package/esm/index.js
CHANGED
|
@@ -1,268 +1,306 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
/** @internal */
|
|
23
|
-
export function genericStringify(_, value) {
|
|
24
|
-
if (typeof value === "string") {
|
|
25
|
-
return value;
|
|
26
|
-
}
|
|
27
|
-
if (typeof value === "number") {
|
|
28
|
-
return `${value}`;
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
const helpers = {
|
|
4
|
+
and: (...and) => ({ and }),
|
|
5
|
+
or: (...or) => ({ or }),
|
|
6
|
+
not: not => ({ not }),
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function genericStringify(_, value) {
|
|
10
|
+
if (typeof value === "string") {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (typeof value === "number") {
|
|
15
|
+
return `${value}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return null;
|
|
31
19
|
}
|
|
20
|
+
|
|
32
21
|
function hash(obj) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
22
|
+
const jsonString = JSON.stringify(obj);
|
|
23
|
+
|
|
24
|
+
let hashValue = 0;
|
|
25
|
+
|
|
26
|
+
for (let i = 0; i < jsonString.length; i++) {
|
|
27
|
+
const charCode = jsonString.charCodeAt(i);
|
|
28
|
+
hashValue = (hashValue << 5) - hashValue + charCode;
|
|
29
|
+
hashValue &= 0x7fffffff;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return hashValue.toString(36);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function normalizeCondition(cond) {
|
|
36
|
+
if (!cond) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
if (typeof cond === "string") {
|
|
40
|
+
return cond;
|
|
41
|
+
}
|
|
42
|
+
if (typeof cond !== "object") {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
if ("not" in cond) {
|
|
46
|
+
if (!cond.not) {
|
|
47
|
+
return undefined;
|
|
39
48
|
}
|
|
40
|
-
|
|
49
|
+
if (cond.not.not) {
|
|
50
|
+
return normalizeCondition(cond.not.not);
|
|
51
|
+
}
|
|
52
|
+
const inner = normalizeCondition(cond.not);
|
|
53
|
+
return inner ? { not: inner } : undefined;
|
|
54
|
+
}
|
|
55
|
+
const [operator] = Object.keys(cond);
|
|
56
|
+
const [head, ...tail] = cond[operator].map(normalizeCondition).filter(x => x);
|
|
57
|
+
if (!head) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
if (tail.length === 0) {
|
|
61
|
+
return head;
|
|
62
|
+
}
|
|
63
|
+
if (tail.length === 1) {
|
|
64
|
+
return { [operator]: [head, tail[0]] };
|
|
65
|
+
}
|
|
66
|
+
return { [operator]: [head, normalizeCondition({ [operator]: tail })] };
|
|
41
67
|
}
|
|
68
|
+
|
|
42
69
|
export function buildHooksSystem(stringify = genericStringify) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
return function createHooks({
|
|
71
|
+
hooks: hooksConfigUnresolved,
|
|
72
|
+
fallback = "revert-layer",
|
|
73
|
+
debug,
|
|
74
|
+
sort: {
|
|
75
|
+
properties: sortProperties = true,
|
|
76
|
+
conditionalStyles: sortConditionalStyles = true,
|
|
77
|
+
} = {},
|
|
78
|
+
hookNameToId: customHookNameToId,
|
|
79
|
+
}) {
|
|
80
|
+
const hooksConfig =
|
|
81
|
+
typeof hooksConfigUnresolved === "function"
|
|
82
|
+
? hooksConfigUnresolved(helpers)
|
|
83
|
+
: hooksConfigUnresolved;
|
|
84
|
+
|
|
85
|
+
const [space, newline] = debug ? [" ", "\n"] : ["", ""];
|
|
86
|
+
const indent = `${space}${space}`;
|
|
87
|
+
|
|
88
|
+
const hookNameToId =
|
|
89
|
+
customHookNameToId ||
|
|
90
|
+
(hookName => {
|
|
91
|
+
const specHash = hash(hooksConfig[hookName]);
|
|
92
|
+
return debug
|
|
93
|
+
? `${hookName.replace(/[^A-Za-z0-9-]/g, "_")}-${specHash}`
|
|
94
|
+
: specHash;
|
|
95
|
+
});
|
|
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
|
+
|
|
117
|
+
function styleSheet() {
|
|
118
|
+
function variablePair({ id, initial, indents }) {
|
|
119
|
+
return [0, 1]
|
|
120
|
+
.map(
|
|
121
|
+
i =>
|
|
122
|
+
`${Array(indents).fill(indent).join("")}--${id}-${i}:${space}${
|
|
123
|
+
initial === i ? "initial" : space ? "" : " "
|
|
124
|
+
};${newline}`,
|
|
125
|
+
)
|
|
126
|
+
.join("");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let sheet = `*${space}{${newline}`;
|
|
130
|
+
|
|
131
|
+
const hooks = Object.entries(hooksConfig)
|
|
132
|
+
.map(([hookName, hookCondition]) => [
|
|
133
|
+
hookName,
|
|
134
|
+
normalizeCondition(hookCondition),
|
|
135
|
+
])
|
|
136
|
+
.filter(([, hookCondition]) => hookCondition);
|
|
137
|
+
|
|
138
|
+
for (const [hookName, hookCondition] of hooks) {
|
|
139
|
+
(function it(id, hookCondition) {
|
|
140
|
+
if (hookCondition && typeof hookCondition === "object") {
|
|
141
|
+
if (hookCondition.not) {
|
|
142
|
+
it(`${id}X`, hookCondition.not);
|
|
143
|
+
sheet += `${indent}--${id}-0:${space}var(--${id}X-1);${newline}`;
|
|
144
|
+
sheet += `${indent}--${id}-1:${space}var(--${id}X-0);${newline}`;
|
|
145
|
+
return;
|
|
81
146
|
}
|
|
82
|
-
|
|
83
|
-
|
|
147
|
+
|
|
148
|
+
if ("and" in hookCondition || "or" in hookCondition) {
|
|
149
|
+
const operator = hookCondition.and ? "and" : "or";
|
|
150
|
+
it(`${id}A`, hookCondition[operator][0]);
|
|
151
|
+
it(`${id}B`, hookCondition[operator][1]);
|
|
152
|
+
if (operator === "and") {
|
|
153
|
+
sheet += `${indent}--${id}-0:${space}var(--${id}A-0)${space}var(--${id}B-0);${newline}`;
|
|
154
|
+
sheet += `${indent}--${id}-1:${space}var(--${id}A-1,${space}var(--${id}B-1));${newline}`;
|
|
155
|
+
} else {
|
|
156
|
+
sheet += `${indent}--${id}-0:${space}var(--${id}A-0,${space}var(--${id}B-0));${newline}`;
|
|
157
|
+
sheet += `${indent}--${id}-1:${space}var(--${id}A-1)${space}var(--${id}B-1);${newline}`;
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
84
160
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
161
|
+
}
|
|
162
|
+
sheet += variablePair({ id, initial: 0, indents: 1 });
|
|
163
|
+
})(hookNameToId(hookName), hookCondition);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
sheet += `}${newline}`;
|
|
167
|
+
|
|
168
|
+
for (const [hookName, hookCondition] of hooks) {
|
|
169
|
+
(function it(id, hookCondition) {
|
|
170
|
+
if (hookCondition && typeof hookCondition === "object") {
|
|
171
|
+
if (hookCondition.not) {
|
|
172
|
+
return it(`${id}X`, hookCondition.not);
|
|
90
173
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return [];
|
|
98
|
-
}
|
|
99
|
-
if (!b) {
|
|
100
|
-
return hooksCSS(name, a);
|
|
101
|
-
}
|
|
102
|
-
extraHooksCSS = [
|
|
103
|
-
{
|
|
104
|
-
init: (function aorb(x) {
|
|
105
|
-
const a = `${x}A`;
|
|
106
|
-
const b = `${x}B`;
|
|
107
|
-
return [
|
|
108
|
-
`--${x}-0:var(--${a}-0,var(--${b}-0));`,
|
|
109
|
-
`--${x}-1:var(--${a}-1) var(--${b}-1);`,
|
|
110
|
-
].join("");
|
|
111
|
-
})(name),
|
|
112
|
-
},
|
|
113
|
-
];
|
|
114
|
-
}
|
|
115
|
-
else if ("and" in definition) {
|
|
116
|
-
operator = "and";
|
|
117
|
-
[a, b] = definition.and;
|
|
118
|
-
if (!a) {
|
|
119
|
-
return [];
|
|
120
|
-
}
|
|
121
|
-
if (!b) {
|
|
122
|
-
return hooksCSS(name, a);
|
|
123
|
-
}
|
|
124
|
-
extraHooksCSS = [
|
|
125
|
-
{
|
|
126
|
-
init: (function aandb(x) {
|
|
127
|
-
const a = `${x}A`;
|
|
128
|
-
const b = `${x}B`;
|
|
129
|
-
return [
|
|
130
|
-
`--${x}-0:var(--${a}-0) var(--${b}-0);`,
|
|
131
|
-
`--${x}-1:var(--${a}-1,var(--${b}-1));`,
|
|
132
|
-
].join("");
|
|
133
|
-
})(name),
|
|
134
|
-
},
|
|
135
|
-
];
|
|
136
|
-
}
|
|
137
|
-
if (operator) {
|
|
138
|
-
return [
|
|
139
|
-
...hooksCSS(`${name}A`, a),
|
|
140
|
-
...hooksCSS(`${name}B`, b),
|
|
141
|
-
...extraHooksCSS,
|
|
142
|
-
];
|
|
143
|
-
}
|
|
174
|
+
|
|
175
|
+
if ("and" in hookCondition || "or" in hookCondition) {
|
|
176
|
+
const operator = hookCondition.and ? "and" : "or";
|
|
177
|
+
it(`${id}A`, hookCondition[operator][0]);
|
|
178
|
+
it(`${id}B`, hookCondition[operator][1]);
|
|
179
|
+
return;
|
|
144
180
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (typeof hookCondition === "string") {
|
|
184
|
+
if (hookCondition[0] === "@") {
|
|
185
|
+
sheet += [
|
|
186
|
+
`${hookCondition}${space}{${newline}`,
|
|
187
|
+
`${indent}*${space}{${newline}`,
|
|
188
|
+
variablePair({
|
|
189
|
+
id,
|
|
190
|
+
initial: 1,
|
|
191
|
+
indents: 2,
|
|
192
|
+
}),
|
|
193
|
+
`${indent}}${newline}`,
|
|
194
|
+
`}${newline}`,
|
|
195
|
+
].join("");
|
|
196
|
+
} else {
|
|
197
|
+
sheet += [
|
|
198
|
+
`${hookCondition.replace(/&/g, "*")}${space}{${newline}`,
|
|
199
|
+
variablePair({
|
|
200
|
+
id,
|
|
201
|
+
initial: 1,
|
|
202
|
+
indents: 1,
|
|
203
|
+
}),
|
|
204
|
+
`}${newline}`,
|
|
205
|
+
].join("");
|
|
157
206
|
}
|
|
158
|
-
|
|
159
|
-
})(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
if (v === null) {
|
|
182
|
-
v = fallbackKeyword;
|
|
183
|
-
}
|
|
184
|
-
return v;
|
|
185
|
-
});
|
|
186
|
-
for (const propertyNameStr in innerProperties) {
|
|
187
|
-
if (keys.indexOf(propertyNameStr) > keys.indexOf(hookName)) {
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
const propertyName = propertyNameStr;
|
|
191
|
-
const v1 = stringifyImpl(propertyName, innerProperties[propertyName]);
|
|
192
|
-
if (v1 !== null) {
|
|
193
|
-
let v0 = fallback(propertyName);
|
|
194
|
-
if (v0 === null) {
|
|
195
|
-
v0 = fallbackKeyword;
|
|
196
|
-
}
|
|
197
|
-
if (sort) {
|
|
198
|
-
delete properties[propertyName];
|
|
199
|
-
}
|
|
200
|
-
properties[propertyName] = `var(--${hookId(hookName)}-1, ${v1}) var(--${hookId(hookName)}-0, ${v0})`;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
delete properties[hookName];
|
|
204
|
-
}
|
|
205
|
-
else if (sort) {
|
|
206
|
-
delete properties[key];
|
|
207
|
-
Object.assign(properties, { [key]: value });
|
|
208
|
-
}
|
|
207
|
+
}
|
|
208
|
+
})(hookNameToId(hookName), hookCondition);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return sheet;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function css(...args) {
|
|
215
|
+
const style = {};
|
|
216
|
+
const rules = args
|
|
217
|
+
.filter(rule => rule)
|
|
218
|
+
.reduce(
|
|
219
|
+
([baseStyles, conditionalStyles], rule) => {
|
|
220
|
+
if (rule.on) {
|
|
221
|
+
baseStyles.push(rule);
|
|
222
|
+
(sortConditionalStyles ? conditionalStyles : baseStyles).push(
|
|
223
|
+
...(typeof rule.on === "function"
|
|
224
|
+
? rule.on((condition, styles) => [condition, styles], helpers)
|
|
225
|
+
: rule.on),
|
|
226
|
+
);
|
|
227
|
+
} else {
|
|
228
|
+
baseStyles.push(rule);
|
|
209
229
|
}
|
|
210
|
-
|
|
230
|
+
delete rule.on;
|
|
231
|
+
return [baseStyles, conditionalStyles];
|
|
232
|
+
},
|
|
233
|
+
[[], []],
|
|
234
|
+
)
|
|
235
|
+
.reduce((a, b) => {
|
|
236
|
+
return a.concat(b);
|
|
237
|
+
}, []);
|
|
238
|
+
for (const rule of rules) {
|
|
239
|
+
if (!rule || typeof rule !== "object") {
|
|
240
|
+
continue;
|
|
211
241
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
242
|
+
if (rule instanceof Array && rule.length === 2) {
|
|
243
|
+
let conditionId = normalizeCondition(rule[0]);
|
|
244
|
+
if (!conditionId) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
if (typeof conditionId === "string") {
|
|
248
|
+
conditionId = hookNameToId(conditionId);
|
|
249
|
+
} else if (typeof conditionId === "object") {
|
|
250
|
+
conditionId = (function it(name, cond) {
|
|
251
|
+
if (typeof cond === "string") {
|
|
252
|
+
return hookNameToId(cond);
|
|
253
|
+
}
|
|
254
|
+
if (cond.not) {
|
|
255
|
+
const inner = it(`${name}X`, cond.not);
|
|
256
|
+
style[`--${name}-0`] = `var(--${inner}-1)`;
|
|
257
|
+
style[`--${name}-1`] = `var(--${inner}-0)`;
|
|
258
|
+
}
|
|
259
|
+
if (cond.and || cond.or) {
|
|
260
|
+
const operator = cond.and ? "and" : "or";
|
|
261
|
+
const a = it(`${name}A`, cond[operator][0]);
|
|
262
|
+
const b = it(`${name}B`, cond[operator][1]);
|
|
263
|
+
if (operator === "and") {
|
|
264
|
+
style[`--${name}-0`] = `var(--${a}-0)${space}var(--${b}-0)`;
|
|
265
|
+
style[`--${name}-1`] = `var(--${a}-1,${space}var(--${b}-1))`;
|
|
266
|
+
} else {
|
|
267
|
+
style[`--${name}-0`] = `var(--${a}-0,${space}var(--${b}-0))`;
|
|
268
|
+
style[`--${name}-1`] = `var(--${a}-1)${space}var(--${b}-1)`;
|
|
223
269
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
270
|
+
}
|
|
271
|
+
return name;
|
|
272
|
+
})(`cond-${hash(conditionToId(conditionId))}`, conditionId);
|
|
273
|
+
}
|
|
274
|
+
for (const [property, value] of Object.entries(rule[1])) {
|
|
275
|
+
const stringifiedValue = stringify(property, value);
|
|
276
|
+
if (stringifiedValue === null) {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
const fallbackValue = (() => {
|
|
280
|
+
if (!(property in style)) {
|
|
281
|
+
return fallback;
|
|
282
|
+
}
|
|
283
|
+
const stringifiedValue = stringify(property, style[property]);
|
|
284
|
+
return stringifiedValue === null ? fallback : stringifiedValue;
|
|
285
|
+
})();
|
|
286
|
+
if (sortProperties) {
|
|
287
|
+
delete style[property];
|
|
288
|
+
}
|
|
289
|
+
style[property] =
|
|
290
|
+
`var(--${conditionId}-1,${space}${stringifiedValue})${space}var(--${conditionId}-0,${space}${fallbackValue})`;
|
|
291
|
+
}
|
|
292
|
+
continue;
|
|
228
293
|
}
|
|
229
|
-
|
|
230
|
-
|
|
294
|
+
for (const [property, value] of Object.entries(rule)) {
|
|
295
|
+
if (sortProperties) {
|
|
296
|
+
delete style[property];
|
|
297
|
+
}
|
|
298
|
+
style[property] = value;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return style;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return { styleSheet, css };
|
|
305
|
+
};
|
|
231
306
|
}
|
|
232
|
-
/**
|
|
233
|
-
* A list of hooks offered as a "sensible default" to solve the most common use cases.
|
|
234
|
-
*
|
|
235
|
-
* @deprecated Use the `@css-hooks/recommended` package instead.
|
|
236
|
-
*/
|
|
237
|
-
export const recommended = {
|
|
238
|
-
active: ":active",
|
|
239
|
-
autofill: { or: [":autofill", ":-webkit-autofill"] },
|
|
240
|
-
checked: ":checked",
|
|
241
|
-
default: ":default",
|
|
242
|
-
disabled: ":disabled",
|
|
243
|
-
empty: ":empty",
|
|
244
|
-
enabled: ":enabled",
|
|
245
|
-
evenChild: ":nth-child(even)",
|
|
246
|
-
firstChild: ":first-child",
|
|
247
|
-
firstOfType: ":first-of-type",
|
|
248
|
-
focus: ":focus",
|
|
249
|
-
focusVisible: ":focus-visible",
|
|
250
|
-
focusWithin: ":focus-within",
|
|
251
|
-
hover: ":hover",
|
|
252
|
-
inRange: ":in-range",
|
|
253
|
-
indeterminate: ":indeterminate",
|
|
254
|
-
invalid: ":invalid",
|
|
255
|
-
lastChild: ":last-child",
|
|
256
|
-
lastOfType: ":last-of-type",
|
|
257
|
-
oddChild: ":nth-child(odd)",
|
|
258
|
-
onlyChild: ":only-child",
|
|
259
|
-
onlyOfType: ":only-of-type",
|
|
260
|
-
outOfRange: ":out-of-range",
|
|
261
|
-
placeholderShown: { or: [":placeholder-shown", ":-moz-placeholder-shown"] },
|
|
262
|
-
readOnly: { or: [":read-only", ":-moz-read-only"] },
|
|
263
|
-
readWrite: { or: [":read-write", ":-moz-read-write"] },
|
|
264
|
-
required: ":required",
|
|
265
|
-
target: ":target",
|
|
266
|
-
valid: ":valid",
|
|
267
|
-
visited: ":visited",
|
|
268
|
-
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@css-hooks/core",
|
|
3
3
|
"description": "CSS Hooks core library",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"author": "Nick Saunders",
|
|
6
6
|
"devDependencies": {
|
|
7
|
+
"@microsoft/api-extractor": "^7.39.4",
|
|
7
8
|
"@tsconfig/strictest": "^2.0.1",
|
|
8
|
-
"@types/
|
|
9
|
+
"@types/color": "^3.0.6",
|
|
9
10
|
"@typescript-eslint/eslint-plugin": "^6.3.0",
|
|
10
11
|
"@typescript-eslint/parser": "^6.3.0",
|
|
11
|
-
"
|
|
12
|
+
"ascjs": "^6.0.3",
|
|
13
|
+
"color": "^4.2.3",
|
|
14
|
+
"csstype": "^3.1.3",
|
|
12
15
|
"eslint": "^8.47.0",
|
|
16
|
+
"eslint-plugin-compat": "^4.2.0",
|
|
17
|
+
"lightningcss": "^1.23.0",
|
|
18
|
+
"puppeteer": "^21.7.0",
|
|
13
19
|
"rimraf": "^5.0.1",
|
|
14
20
|
"tsc-watch": "^6.0.4",
|
|
15
21
|
"typescript": "^5.1.6"
|
|
@@ -17,7 +23,8 @@
|
|
|
17
23
|
"files": [
|
|
18
24
|
"cjs",
|
|
19
25
|
"esm",
|
|
20
|
-
"types"
|
|
26
|
+
"types",
|
|
27
|
+
"tsdoc-metadata.json"
|
|
21
28
|
],
|
|
22
29
|
"license": "MIT",
|
|
23
30
|
"main": "cjs",
|
|
@@ -30,9 +37,10 @@
|
|
|
30
37
|
"directory": "packages/core"
|
|
31
38
|
},
|
|
32
39
|
"scripts": {
|
|
40
|
+
"api": "node -e \"var path=require('path').resolve,fs=require('fs'),cp=fs.cpSync;cp(path('src', 'index.d.ts'),path('types','index.d.ts'))\" && api-extractor run",
|
|
33
41
|
"clean": "rimraf cjs esm out types",
|
|
34
42
|
"lint": "eslint src .*.*js *.*js",
|
|
35
|
-
"prepublishOnly": "
|
|
43
|
+
"prepublishOnly": "node -e \"var path=require('path').resolve,fs=require('fs'),cp=fs.cpSync,mkdir=fs.mkdirSync;cp(path('src', 'index.d.ts'),path('types','index.d.ts'));cp(path('src','index.js'),path('esm','index.js'));mkdir(path('cjs'),{recursive:true})\" && ascjs src/index.js cjs/index.js",
|
|
36
44
|
"test": "tsc && node --test",
|
|
37
45
|
"test.watch": "tsc-watch --onSuccess 'node --test'"
|
|
38
46
|
},
|
|
@@ -43,5 +51,8 @@
|
|
|
43
51
|
"require": "./cjs/index.js",
|
|
44
52
|
"types": "./types/index.d.ts"
|
|
45
53
|
}
|
|
46
|
-
}
|
|
54
|
+
},
|
|
55
|
+
"browserslist": [
|
|
56
|
+
"supports css-variables and supports object-entries"
|
|
57
|
+
]
|
|
47
58
|
}
|