@weapp-tailwindcss/reset 0.1.0 → 0.1.1-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/index.cjs +234 -277
- package/dist/index.d.ts +55 -47
- package/dist/index.mjs +214 -250
- package/package.json +4 -4
- package/dist/index.d.mts +0 -51
package/dist/index.cjs
CHANGED
|
@@ -1,311 +1,268 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
2
6
|
var __create = Object.create;
|
|
3
7
|
var __defProp = Object.defineProperty;
|
|
4
8
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
9
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
10
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
11
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
12
|
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: ((k) => from[k]).bind(null, key),
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
19
21
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
default: () => index_default,
|
|
34
|
-
reset: () => reset
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(index_exports);
|
|
37
|
-
var import_plugin = __toESM(require("tailwindcss/plugin"));
|
|
38
|
-
|
|
39
|
-
// src/normalize.ts
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
//#endregion
|
|
27
|
+
let tailwindcss_plugin = require("tailwindcss/plugin");
|
|
28
|
+
tailwindcss_plugin = __toESM(tailwindcss_plugin);
|
|
29
|
+
//#region src/normalize.ts
|
|
40
30
|
function normalizeResetSelectors(option, defaults) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
return normalized.length ? normalized : void 0;
|
|
31
|
+
const resolved = option?.selectors?.length ? option.selectors : defaults;
|
|
32
|
+
const normalized = [];
|
|
33
|
+
for (const selector of resolved) {
|
|
34
|
+
const trimmed = selector.trim();
|
|
35
|
+
if (!trimmed || normalized.includes(trimmed)) continue;
|
|
36
|
+
normalized.push(trimmed);
|
|
37
|
+
}
|
|
38
|
+
return normalized.length ? normalized : void 0;
|
|
51
39
|
}
|
|
52
40
|
function convertSelectorForBase(selector) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return `[id="${id}"]`;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return selector;
|
|
41
|
+
if (selector.startsWith(".")) {
|
|
42
|
+
const className = selector.slice(1);
|
|
43
|
+
if (className.length > 0) return `[class~="${className}"]`;
|
|
44
|
+
}
|
|
45
|
+
if (selector.startsWith("#")) {
|
|
46
|
+
const id = selector.slice(1);
|
|
47
|
+
if (id.length > 0) return `[id="${id}"]`;
|
|
48
|
+
}
|
|
49
|
+
return selector;
|
|
66
50
|
}
|
|
67
51
|
function normalizeDeclarationValue(value) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
return typeof value === "number" ? value.toString() : value;
|
|
52
|
+
if (value === false || value === null || value === void 0) return;
|
|
53
|
+
return typeof value === "number" ? value.toString() : value;
|
|
72
54
|
}
|
|
73
55
|
function normalizeDeclarations(option, defaults) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
} else {
|
|
85
|
-
normalized[prop] = resolved;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return normalized;
|
|
56
|
+
const normalized = { ...defaults };
|
|
57
|
+
const overrides = option?.declarations;
|
|
58
|
+
if (!overrides) return normalized;
|
|
59
|
+
const entries = Object.entries(overrides);
|
|
60
|
+
for (const [prop, value] of entries) {
|
|
61
|
+
const resolved = normalizeDeclarationValue(value);
|
|
62
|
+
if (resolved === void 0) delete normalized[prop];
|
|
63
|
+
else normalized[prop] = resolved;
|
|
64
|
+
}
|
|
65
|
+
return normalized;
|
|
89
66
|
}
|
|
90
67
|
function normalizePseudo(option, defaults) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
} else {
|
|
102
|
-
normalized[prop] = resolved;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return Object.keys(normalized).length ? normalized : void 0;
|
|
68
|
+
const normalized = defaults ? { ...defaults } : {};
|
|
69
|
+
const overrides = option?.pseudo;
|
|
70
|
+
if (!overrides) return Object.keys(normalized).length ? normalized : void 0;
|
|
71
|
+
const entries = Object.entries(overrides);
|
|
72
|
+
for (const [prop, value] of entries) {
|
|
73
|
+
const resolved = normalizeDeclarationValue(value);
|
|
74
|
+
if (resolved === void 0) delete normalized[prop];
|
|
75
|
+
else normalized[prop] = resolved;
|
|
76
|
+
}
|
|
77
|
+
return Object.keys(normalized).length ? normalized : void 0;
|
|
106
78
|
}
|
|
107
79
|
function createResetRule(option, defaults) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const pseudo = normalizePseudo(option ?? {}, defaults.pseudo);
|
|
120
|
-
return {
|
|
121
|
-
selectors: selectors.map(convertSelectorForBase),
|
|
122
|
-
declarations,
|
|
123
|
-
pseudo
|
|
124
|
-
};
|
|
80
|
+
if (option === false) return;
|
|
81
|
+
const selectors = normalizeResetSelectors(option, defaults.selectors);
|
|
82
|
+
if (!selectors) return;
|
|
83
|
+
const declarations = normalizeDeclarations(option ?? {}, defaults.declarations);
|
|
84
|
+
if (Object.keys(declarations).length === 0) return;
|
|
85
|
+
const pseudo = normalizePseudo(option ?? {}, defaults.pseudo);
|
|
86
|
+
return {
|
|
87
|
+
selectors: selectors.map(convertSelectorForBase),
|
|
88
|
+
declarations,
|
|
89
|
+
pseudo
|
|
90
|
+
};
|
|
125
91
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
};
|
|
137
|
-
var BUTTON_RESET_PSEUDO_DECLARATIONS = {
|
|
138
|
-
border: "none"
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/index.ts
|
|
94
|
+
const DEFAULT_BUTTON_RESET_SELECTORS = ["button"];
|
|
95
|
+
const DEFAULT_BUTTON_DECLARATIONS = {
|
|
96
|
+
padding: "0",
|
|
97
|
+
backgroundColor: "transparent",
|
|
98
|
+
fontSize: "inherit",
|
|
99
|
+
lineHeight: "inherit",
|
|
100
|
+
color: "inherit",
|
|
101
|
+
borderWidth: "0"
|
|
139
102
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
103
|
+
const BUTTON_RESET_PSEUDO_DECLARATIONS = { border: "none" };
|
|
104
|
+
const DEFAULT_IMAGE_RESET_SELECTORS = ["image", "img"];
|
|
105
|
+
const DEFAULT_IMAGE_DECLARATIONS = {
|
|
106
|
+
display: "block",
|
|
107
|
+
borderWidth: "0",
|
|
108
|
+
backgroundColor: "transparent",
|
|
109
|
+
maxWidth: "100%",
|
|
110
|
+
height: "auto"
|
|
147
111
|
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
112
|
+
const DEFAULT_INPUT_RESET_SELECTORS = ["input"];
|
|
113
|
+
const DEFAULT_INPUT_DECLARATIONS = {
|
|
114
|
+
padding: "0",
|
|
115
|
+
fontSize: "100%",
|
|
116
|
+
fontFamily: "inherit",
|
|
117
|
+
lineHeight: "inherit",
|
|
118
|
+
color: "inherit",
|
|
119
|
+
backgroundColor: "transparent",
|
|
120
|
+
borderWidth: "0"
|
|
157
121
|
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
122
|
+
const DEFAULT_TEXTAREA_RESET_SELECTORS = ["textarea"];
|
|
123
|
+
const DEFAULT_TEXTAREA_DECLARATIONS = {
|
|
124
|
+
padding: "0",
|
|
125
|
+
fontSize: "100%",
|
|
126
|
+
fontFamily: "inherit",
|
|
127
|
+
lineHeight: "inherit",
|
|
128
|
+
color: "inherit",
|
|
129
|
+
backgroundColor: "transparent",
|
|
130
|
+
borderWidth: "0",
|
|
131
|
+
resize: "vertical"
|
|
168
132
|
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
133
|
+
const DEFAULT_LIST_RESET_SELECTORS = ["ul", "ol"];
|
|
134
|
+
const DEFAULT_LIST_DECLARATIONS = {
|
|
135
|
+
listStyle: "none",
|
|
136
|
+
margin: "0",
|
|
137
|
+
padding: "0"
|
|
174
138
|
};
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
139
|
+
const DEFAULT_NAVIGATOR_RESET_SELECTORS = ["navigator", "a"];
|
|
140
|
+
const DEFAULT_NAVIGATOR_DECLARATIONS = {
|
|
141
|
+
color: "inherit",
|
|
142
|
+
textDecoration: "inherit"
|
|
179
143
|
};
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
144
|
+
const DEFAULT_VIDEO_RESET_SELECTORS = ["video"];
|
|
145
|
+
const DEFAULT_VIDEO_DECLARATIONS = {
|
|
146
|
+
display: "block",
|
|
147
|
+
maxWidth: "100%",
|
|
148
|
+
height: "auto"
|
|
185
149
|
};
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
150
|
+
const presetMap = {
|
|
151
|
+
minimal: ["buttonReset", "imageReset"],
|
|
152
|
+
form: [
|
|
153
|
+
"buttonReset",
|
|
154
|
+
"imageReset",
|
|
155
|
+
"inputReset",
|
|
156
|
+
"textareaReset"
|
|
157
|
+
],
|
|
158
|
+
content: [
|
|
159
|
+
"buttonReset",
|
|
160
|
+
"imageReset",
|
|
161
|
+
"listReset",
|
|
162
|
+
"navigatorReset"
|
|
163
|
+
],
|
|
164
|
+
media: [
|
|
165
|
+
"buttonReset",
|
|
166
|
+
"imageReset",
|
|
167
|
+
"videoReset"
|
|
168
|
+
],
|
|
169
|
+
all: [
|
|
170
|
+
"buttonReset",
|
|
171
|
+
"imageReset",
|
|
172
|
+
"inputReset",
|
|
173
|
+
"textareaReset",
|
|
174
|
+
"listReset",
|
|
175
|
+
"navigatorReset",
|
|
176
|
+
"videoReset"
|
|
177
|
+
]
|
|
200
178
|
};
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
179
|
+
const builtInResetKeys = [
|
|
180
|
+
"buttonReset",
|
|
181
|
+
"imageReset",
|
|
182
|
+
"inputReset",
|
|
183
|
+
"textareaReset",
|
|
184
|
+
"listReset",
|
|
185
|
+
"navigatorReset",
|
|
186
|
+
"videoReset"
|
|
209
187
|
];
|
|
210
188
|
function hasCustomResetConfig(value) {
|
|
211
|
-
|
|
189
|
+
return value !== void 0 && value !== false;
|
|
212
190
|
}
|
|
213
191
|
function resolvePresetFlags(options) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
for (const key of builtInResetKeys) {
|
|
233
|
-
if (hasCustomResetConfig(options?.[key])) {
|
|
234
|
-
resolved[key] = true;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return resolved;
|
|
192
|
+
const resolved = {
|
|
193
|
+
buttonReset: true,
|
|
194
|
+
imageReset: true,
|
|
195
|
+
inputReset: false,
|
|
196
|
+
textareaReset: false,
|
|
197
|
+
listReset: false,
|
|
198
|
+
navigatorReset: false,
|
|
199
|
+
videoReset: false
|
|
200
|
+
};
|
|
201
|
+
const presets = options?.preset;
|
|
202
|
+
if (presets) {
|
|
203
|
+
const normalizedPresets = Array.isArray(presets) ? presets : [presets];
|
|
204
|
+
for (const preset of normalizedPresets) for (const key of presetMap[preset]) resolved[key] = true;
|
|
205
|
+
}
|
|
206
|
+
for (const key of builtInResetKeys) if (hasCustomResetConfig(options?.[key])) resolved[key] = true;
|
|
207
|
+
return resolved;
|
|
238
208
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (rule.pseudo) {
|
|
296
|
-
const pseudoSelectors = rule.selectors.map((selector) => `${selector}::after`).join(",");
|
|
297
|
-
baseRules[pseudoSelectors] = rule.pseudo;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
addBase(baseRules);
|
|
301
|
-
};
|
|
302
|
-
},
|
|
303
|
-
() => {
|
|
304
|
-
return {};
|
|
305
|
-
}
|
|
306
|
-
);
|
|
307
|
-
var index_default = reset;
|
|
308
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
309
|
-
0 && (module.exports = {
|
|
310
|
-
reset
|
|
209
|
+
const reset = tailwindcss_plugin.default.withOptions((options) => {
|
|
210
|
+
const rules = [];
|
|
211
|
+
const enabledFlags = resolvePresetFlags(options);
|
|
212
|
+
const builtInRules = [
|
|
213
|
+
enabledFlags.buttonReset ? createResetRule(options?.buttonReset, {
|
|
214
|
+
selectors: DEFAULT_BUTTON_RESET_SELECTORS,
|
|
215
|
+
declarations: DEFAULT_BUTTON_DECLARATIONS,
|
|
216
|
+
pseudo: BUTTON_RESET_PSEUDO_DECLARATIONS
|
|
217
|
+
}) : void 0,
|
|
218
|
+
enabledFlags.imageReset ? createResetRule(options?.imageReset, {
|
|
219
|
+
selectors: DEFAULT_IMAGE_RESET_SELECTORS,
|
|
220
|
+
declarations: DEFAULT_IMAGE_DECLARATIONS
|
|
221
|
+
}) : void 0,
|
|
222
|
+
enabledFlags.inputReset ? createResetRule(options?.inputReset, {
|
|
223
|
+
selectors: DEFAULT_INPUT_RESET_SELECTORS,
|
|
224
|
+
declarations: DEFAULT_INPUT_DECLARATIONS
|
|
225
|
+
}) : void 0,
|
|
226
|
+
enabledFlags.textareaReset ? createResetRule(options?.textareaReset, {
|
|
227
|
+
selectors: DEFAULT_TEXTAREA_RESET_SELECTORS,
|
|
228
|
+
declarations: DEFAULT_TEXTAREA_DECLARATIONS
|
|
229
|
+
}) : void 0,
|
|
230
|
+
enabledFlags.listReset ? createResetRule(options?.listReset, {
|
|
231
|
+
selectors: DEFAULT_LIST_RESET_SELECTORS,
|
|
232
|
+
declarations: DEFAULT_LIST_DECLARATIONS
|
|
233
|
+
}) : void 0,
|
|
234
|
+
enabledFlags.navigatorReset ? createResetRule(options?.navigatorReset, {
|
|
235
|
+
selectors: DEFAULT_NAVIGATOR_RESET_SELECTORS,
|
|
236
|
+
declarations: DEFAULT_NAVIGATOR_DECLARATIONS
|
|
237
|
+
}) : void 0,
|
|
238
|
+
enabledFlags.videoReset ? createResetRule(options?.videoReset, {
|
|
239
|
+
selectors: DEFAULT_VIDEO_RESET_SELECTORS,
|
|
240
|
+
declarations: DEFAULT_VIDEO_DECLARATIONS
|
|
241
|
+
}) : void 0
|
|
242
|
+
];
|
|
243
|
+
for (const rule of builtInRules) if (rule) rules.push(rule);
|
|
244
|
+
for (const extra of options?.extraResets ?? []) {
|
|
245
|
+
const normalized = createResetRule(extra, {
|
|
246
|
+
selectors: extra.selectors ?? [],
|
|
247
|
+
declarations: {}
|
|
248
|
+
});
|
|
249
|
+
if (normalized) rules.push(normalized);
|
|
250
|
+
}
|
|
251
|
+
return ({ addBase }) => {
|
|
252
|
+
if (!rules.length) return;
|
|
253
|
+
const baseRules = {};
|
|
254
|
+
for (const rule of rules) {
|
|
255
|
+
baseRules[rule.selectors.join(",")] = rule.declarations;
|
|
256
|
+
if (rule.pseudo) {
|
|
257
|
+
const pseudoSelectors = rule.selectors.map((selector) => `${selector}::after`).join(",");
|
|
258
|
+
baseRules[pseudoSelectors] = rule.pseudo;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
addBase(baseRules);
|
|
262
|
+
};
|
|
263
|
+
}, () => {
|
|
264
|
+
return {};
|
|
311
265
|
});
|
|
266
|
+
//#endregion
|
|
267
|
+
exports.default = reset;
|
|
268
|
+
exports.reset = reset;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,53 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/types.d.ts
|
|
3
2
|
type ResetPreset = 'minimal' | 'form' | 'content' | 'media' | 'all';
|
|
4
3
|
type BuiltInResetName = 'buttonReset' | 'imageReset' | 'inputReset' | 'textareaReset' | 'listReset' | 'navigatorReset' | 'videoReset';
|
|
5
4
|
interface ResetOptions {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
5
|
+
/**
|
|
6
|
+
* 启用一组内置 reset 预设;默认不传时保持最小行为,仅注入 button/image。
|
|
7
|
+
*/
|
|
8
|
+
preset?: ResetPreset | ResetPreset[];
|
|
9
|
+
/**
|
|
10
|
+
* 控制 `button` reset 的注入与选择器,传入 `false` 可跳过该规则。
|
|
11
|
+
*/
|
|
12
|
+
buttonReset?: false | ResetConfig;
|
|
13
|
+
/**
|
|
14
|
+
* 控制 `image` reset(同时覆盖 `<image>` 与 `<img>`)。
|
|
15
|
+
*/
|
|
16
|
+
imageReset?: false | ResetConfig;
|
|
17
|
+
/**
|
|
18
|
+
* 控制常见输入框 reset(`input`)。
|
|
19
|
+
*/
|
|
20
|
+
inputReset?: false | ResetConfig;
|
|
21
|
+
/**
|
|
22
|
+
* 控制多行输入框 reset(`textarea`)。
|
|
23
|
+
*/
|
|
24
|
+
textareaReset?: false | ResetConfig;
|
|
25
|
+
/**
|
|
26
|
+
* 控制列表 reset(`ul` / `ol`)。
|
|
27
|
+
*/
|
|
28
|
+
listReset?: false | ResetConfig;
|
|
29
|
+
/**
|
|
30
|
+
* 控制链接 reset(`navigator` / `a`)。
|
|
31
|
+
*/
|
|
32
|
+
navigatorReset?: false | ResetConfig;
|
|
33
|
+
/**
|
|
34
|
+
* 控制 `video` reset。
|
|
35
|
+
*/
|
|
36
|
+
videoReset?: false | ResetConfig;
|
|
37
|
+
/**
|
|
38
|
+
* 额外的 reset 规则,可根据业务自定义。
|
|
39
|
+
*/
|
|
40
|
+
extraResets?: ResetConfig[];
|
|
42
41
|
}
|
|
43
42
|
interface ResetConfig {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
selectors?: string[];
|
|
44
|
+
declarations?: Record<string, string | number | false | null | undefined>;
|
|
45
|
+
pseudo?: Record<string, string | number | false | null | undefined>;
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/index.d.ts
|
|
49
|
+
interface ResetPluginResult {
|
|
50
|
+
handler: (api: {
|
|
51
|
+
addBase: (base: Record<string, Record<string, string>>) => void;
|
|
52
|
+
}) => void;
|
|
53
|
+
config?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
interface ResetPlugin {
|
|
56
|
+
(options?: ResetOptions): ResetPluginResult;
|
|
57
|
+
__isOptionsFunction: true;
|
|
58
|
+
}
|
|
59
|
+
declare const reset: ResetPlugin;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { type BuiltInResetName, type ResetConfig, type ResetOptions, ResetPlugin, ResetPluginResult, type ResetPreset, reset as default, reset };
|
package/dist/index.mjs
CHANGED
|
@@ -1,276 +1,240 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
1
|
import plugin from "tailwindcss/plugin";
|
|
3
|
-
|
|
4
|
-
// src/normalize.ts
|
|
2
|
+
//#region src/normalize.ts
|
|
5
3
|
function normalizeResetSelectors(option, defaults) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return normalized.length ? normalized : void 0;
|
|
4
|
+
const resolved = option?.selectors?.length ? option.selectors : defaults;
|
|
5
|
+
const normalized = [];
|
|
6
|
+
for (const selector of resolved) {
|
|
7
|
+
const trimmed = selector.trim();
|
|
8
|
+
if (!trimmed || normalized.includes(trimmed)) continue;
|
|
9
|
+
normalized.push(trimmed);
|
|
10
|
+
}
|
|
11
|
+
return normalized.length ? normalized : void 0;
|
|
16
12
|
}
|
|
17
13
|
function convertSelectorForBase(selector) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return `[id="${id}"]`;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return selector;
|
|
14
|
+
if (selector.startsWith(".")) {
|
|
15
|
+
const className = selector.slice(1);
|
|
16
|
+
if (className.length > 0) return `[class~="${className}"]`;
|
|
17
|
+
}
|
|
18
|
+
if (selector.startsWith("#")) {
|
|
19
|
+
const id = selector.slice(1);
|
|
20
|
+
if (id.length > 0) return `[id="${id}"]`;
|
|
21
|
+
}
|
|
22
|
+
return selector;
|
|
31
23
|
}
|
|
32
24
|
function normalizeDeclarationValue(value) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
return typeof value === "number" ? value.toString() : value;
|
|
25
|
+
if (value === false || value === null || value === void 0) return;
|
|
26
|
+
return typeof value === "number" ? value.toString() : value;
|
|
37
27
|
}
|
|
38
28
|
function normalizeDeclarations(option, defaults) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
} else {
|
|
50
|
-
normalized[prop] = resolved;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return normalized;
|
|
29
|
+
const normalized = { ...defaults };
|
|
30
|
+
const overrides = option?.declarations;
|
|
31
|
+
if (!overrides) return normalized;
|
|
32
|
+
const entries = Object.entries(overrides);
|
|
33
|
+
for (const [prop, value] of entries) {
|
|
34
|
+
const resolved = normalizeDeclarationValue(value);
|
|
35
|
+
if (resolved === void 0) delete normalized[prop];
|
|
36
|
+
else normalized[prop] = resolved;
|
|
37
|
+
}
|
|
38
|
+
return normalized;
|
|
54
39
|
}
|
|
55
40
|
function normalizePseudo(option, defaults) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
} else {
|
|
67
|
-
normalized[prop] = resolved;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return Object.keys(normalized).length ? normalized : void 0;
|
|
41
|
+
const normalized = defaults ? { ...defaults } : {};
|
|
42
|
+
const overrides = option?.pseudo;
|
|
43
|
+
if (!overrides) return Object.keys(normalized).length ? normalized : void 0;
|
|
44
|
+
const entries = Object.entries(overrides);
|
|
45
|
+
for (const [prop, value] of entries) {
|
|
46
|
+
const resolved = normalizeDeclarationValue(value);
|
|
47
|
+
if (resolved === void 0) delete normalized[prop];
|
|
48
|
+
else normalized[prop] = resolved;
|
|
49
|
+
}
|
|
50
|
+
return Object.keys(normalized).length ? normalized : void 0;
|
|
71
51
|
}
|
|
72
52
|
function createResetRule(option, defaults) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const pseudo = normalizePseudo(option ?? {}, defaults.pseudo);
|
|
85
|
-
return {
|
|
86
|
-
selectors: selectors.map(convertSelectorForBase),
|
|
87
|
-
declarations,
|
|
88
|
-
pseudo
|
|
89
|
-
};
|
|
53
|
+
if (option === false) return;
|
|
54
|
+
const selectors = normalizeResetSelectors(option, defaults.selectors);
|
|
55
|
+
if (!selectors) return;
|
|
56
|
+
const declarations = normalizeDeclarations(option ?? {}, defaults.declarations);
|
|
57
|
+
if (Object.keys(declarations).length === 0) return;
|
|
58
|
+
const pseudo = normalizePseudo(option ?? {}, defaults.pseudo);
|
|
59
|
+
return {
|
|
60
|
+
selectors: selectors.map(convertSelectorForBase),
|
|
61
|
+
declarations,
|
|
62
|
+
pseudo
|
|
63
|
+
};
|
|
90
64
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/index.ts
|
|
67
|
+
const DEFAULT_BUTTON_RESET_SELECTORS = ["button"];
|
|
68
|
+
const DEFAULT_BUTTON_DECLARATIONS = {
|
|
69
|
+
padding: "0",
|
|
70
|
+
backgroundColor: "transparent",
|
|
71
|
+
fontSize: "inherit",
|
|
72
|
+
lineHeight: "inherit",
|
|
73
|
+
color: "inherit",
|
|
74
|
+
borderWidth: "0"
|
|
101
75
|
};
|
|
102
|
-
|
|
103
|
-
|
|
76
|
+
const BUTTON_RESET_PSEUDO_DECLARATIONS = { border: "none" };
|
|
77
|
+
const DEFAULT_IMAGE_RESET_SELECTORS = ["image", "img"];
|
|
78
|
+
const DEFAULT_IMAGE_DECLARATIONS = {
|
|
79
|
+
display: "block",
|
|
80
|
+
borderWidth: "0",
|
|
81
|
+
backgroundColor: "transparent",
|
|
82
|
+
maxWidth: "100%",
|
|
83
|
+
height: "auto"
|
|
104
84
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
85
|
+
const DEFAULT_INPUT_RESET_SELECTORS = ["input"];
|
|
86
|
+
const DEFAULT_INPUT_DECLARATIONS = {
|
|
87
|
+
padding: "0",
|
|
88
|
+
fontSize: "100%",
|
|
89
|
+
fontFamily: "inherit",
|
|
90
|
+
lineHeight: "inherit",
|
|
91
|
+
color: "inherit",
|
|
92
|
+
backgroundColor: "transparent",
|
|
93
|
+
borderWidth: "0"
|
|
112
94
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
95
|
+
const DEFAULT_TEXTAREA_RESET_SELECTORS = ["textarea"];
|
|
96
|
+
const DEFAULT_TEXTAREA_DECLARATIONS = {
|
|
97
|
+
padding: "0",
|
|
98
|
+
fontSize: "100%",
|
|
99
|
+
fontFamily: "inherit",
|
|
100
|
+
lineHeight: "inherit",
|
|
101
|
+
color: "inherit",
|
|
102
|
+
backgroundColor: "transparent",
|
|
103
|
+
borderWidth: "0",
|
|
104
|
+
resize: "vertical"
|
|
122
105
|
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
lineHeight: "inherit",
|
|
129
|
-
color: "inherit",
|
|
130
|
-
backgroundColor: "transparent",
|
|
131
|
-
borderWidth: "0",
|
|
132
|
-
resize: "vertical"
|
|
106
|
+
const DEFAULT_LIST_RESET_SELECTORS = ["ul", "ol"];
|
|
107
|
+
const DEFAULT_LIST_DECLARATIONS = {
|
|
108
|
+
listStyle: "none",
|
|
109
|
+
margin: "0",
|
|
110
|
+
padding: "0"
|
|
133
111
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
padding: "0"
|
|
112
|
+
const DEFAULT_NAVIGATOR_RESET_SELECTORS = ["navigator", "a"];
|
|
113
|
+
const DEFAULT_NAVIGATOR_DECLARATIONS = {
|
|
114
|
+
color: "inherit",
|
|
115
|
+
textDecoration: "inherit"
|
|
139
116
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
117
|
+
const DEFAULT_VIDEO_RESET_SELECTORS = ["video"];
|
|
118
|
+
const DEFAULT_VIDEO_DECLARATIONS = {
|
|
119
|
+
display: "block",
|
|
120
|
+
maxWidth: "100%",
|
|
121
|
+
height: "auto"
|
|
144
122
|
};
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
123
|
+
const presetMap = {
|
|
124
|
+
minimal: ["buttonReset", "imageReset"],
|
|
125
|
+
form: [
|
|
126
|
+
"buttonReset",
|
|
127
|
+
"imageReset",
|
|
128
|
+
"inputReset",
|
|
129
|
+
"textareaReset"
|
|
130
|
+
],
|
|
131
|
+
content: [
|
|
132
|
+
"buttonReset",
|
|
133
|
+
"imageReset",
|
|
134
|
+
"listReset",
|
|
135
|
+
"navigatorReset"
|
|
136
|
+
],
|
|
137
|
+
media: [
|
|
138
|
+
"buttonReset",
|
|
139
|
+
"imageReset",
|
|
140
|
+
"videoReset"
|
|
141
|
+
],
|
|
142
|
+
all: [
|
|
143
|
+
"buttonReset",
|
|
144
|
+
"imageReset",
|
|
145
|
+
"inputReset",
|
|
146
|
+
"textareaReset",
|
|
147
|
+
"listReset",
|
|
148
|
+
"navigatorReset",
|
|
149
|
+
"videoReset"
|
|
150
|
+
]
|
|
150
151
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
"inputReset",
|
|
160
|
-
"textareaReset",
|
|
161
|
-
"listReset",
|
|
162
|
-
"navigatorReset",
|
|
163
|
-
"videoReset"
|
|
164
|
-
]
|
|
165
|
-
};
|
|
166
|
-
var builtInResetKeys = [
|
|
167
|
-
"buttonReset",
|
|
168
|
-
"imageReset",
|
|
169
|
-
"inputReset",
|
|
170
|
-
"textareaReset",
|
|
171
|
-
"listReset",
|
|
172
|
-
"navigatorReset",
|
|
173
|
-
"videoReset"
|
|
152
|
+
const builtInResetKeys = [
|
|
153
|
+
"buttonReset",
|
|
154
|
+
"imageReset",
|
|
155
|
+
"inputReset",
|
|
156
|
+
"textareaReset",
|
|
157
|
+
"listReset",
|
|
158
|
+
"navigatorReset",
|
|
159
|
+
"videoReset"
|
|
174
160
|
];
|
|
175
161
|
function hasCustomResetConfig(value) {
|
|
176
|
-
|
|
162
|
+
return value !== void 0 && value !== false;
|
|
177
163
|
}
|
|
178
164
|
function resolvePresetFlags(options) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
for (const key of builtInResetKeys) {
|
|
198
|
-
if (hasCustomResetConfig(options?.[key])) {
|
|
199
|
-
resolved[key] = true;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return resolved;
|
|
165
|
+
const resolved = {
|
|
166
|
+
buttonReset: true,
|
|
167
|
+
imageReset: true,
|
|
168
|
+
inputReset: false,
|
|
169
|
+
textareaReset: false,
|
|
170
|
+
listReset: false,
|
|
171
|
+
navigatorReset: false,
|
|
172
|
+
videoReset: false
|
|
173
|
+
};
|
|
174
|
+
const presets = options?.preset;
|
|
175
|
+
if (presets) {
|
|
176
|
+
const normalizedPresets = Array.isArray(presets) ? presets : [presets];
|
|
177
|
+
for (const preset of normalizedPresets) for (const key of presetMap[preset]) resolved[key] = true;
|
|
178
|
+
}
|
|
179
|
+
for (const key of builtInResetKeys) if (hasCustomResetConfig(options?.[key])) resolved[key] = true;
|
|
180
|
+
return resolved;
|
|
203
181
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
addBase(baseRules);
|
|
266
|
-
};
|
|
267
|
-
},
|
|
268
|
-
() => {
|
|
269
|
-
return {};
|
|
270
|
-
}
|
|
271
|
-
);
|
|
272
|
-
var index_default = reset;
|
|
273
|
-
export {
|
|
274
|
-
index_default as default,
|
|
275
|
-
reset
|
|
276
|
-
};
|
|
182
|
+
const reset = plugin.withOptions((options) => {
|
|
183
|
+
const rules = [];
|
|
184
|
+
const enabledFlags = resolvePresetFlags(options);
|
|
185
|
+
const builtInRules = [
|
|
186
|
+
enabledFlags.buttonReset ? createResetRule(options?.buttonReset, {
|
|
187
|
+
selectors: DEFAULT_BUTTON_RESET_SELECTORS,
|
|
188
|
+
declarations: DEFAULT_BUTTON_DECLARATIONS,
|
|
189
|
+
pseudo: BUTTON_RESET_PSEUDO_DECLARATIONS
|
|
190
|
+
}) : void 0,
|
|
191
|
+
enabledFlags.imageReset ? createResetRule(options?.imageReset, {
|
|
192
|
+
selectors: DEFAULT_IMAGE_RESET_SELECTORS,
|
|
193
|
+
declarations: DEFAULT_IMAGE_DECLARATIONS
|
|
194
|
+
}) : void 0,
|
|
195
|
+
enabledFlags.inputReset ? createResetRule(options?.inputReset, {
|
|
196
|
+
selectors: DEFAULT_INPUT_RESET_SELECTORS,
|
|
197
|
+
declarations: DEFAULT_INPUT_DECLARATIONS
|
|
198
|
+
}) : void 0,
|
|
199
|
+
enabledFlags.textareaReset ? createResetRule(options?.textareaReset, {
|
|
200
|
+
selectors: DEFAULT_TEXTAREA_RESET_SELECTORS,
|
|
201
|
+
declarations: DEFAULT_TEXTAREA_DECLARATIONS
|
|
202
|
+
}) : void 0,
|
|
203
|
+
enabledFlags.listReset ? createResetRule(options?.listReset, {
|
|
204
|
+
selectors: DEFAULT_LIST_RESET_SELECTORS,
|
|
205
|
+
declarations: DEFAULT_LIST_DECLARATIONS
|
|
206
|
+
}) : void 0,
|
|
207
|
+
enabledFlags.navigatorReset ? createResetRule(options?.navigatorReset, {
|
|
208
|
+
selectors: DEFAULT_NAVIGATOR_RESET_SELECTORS,
|
|
209
|
+
declarations: DEFAULT_NAVIGATOR_DECLARATIONS
|
|
210
|
+
}) : void 0,
|
|
211
|
+
enabledFlags.videoReset ? createResetRule(options?.videoReset, {
|
|
212
|
+
selectors: DEFAULT_VIDEO_RESET_SELECTORS,
|
|
213
|
+
declarations: DEFAULT_VIDEO_DECLARATIONS
|
|
214
|
+
}) : void 0
|
|
215
|
+
];
|
|
216
|
+
for (const rule of builtInRules) if (rule) rules.push(rule);
|
|
217
|
+
for (const extra of options?.extraResets ?? []) {
|
|
218
|
+
const normalized = createResetRule(extra, {
|
|
219
|
+
selectors: extra.selectors ?? [],
|
|
220
|
+
declarations: {}
|
|
221
|
+
});
|
|
222
|
+
if (normalized) rules.push(normalized);
|
|
223
|
+
}
|
|
224
|
+
return ({ addBase }) => {
|
|
225
|
+
if (!rules.length) return;
|
|
226
|
+
const baseRules = {};
|
|
227
|
+
for (const rule of rules) {
|
|
228
|
+
baseRules[rule.selectors.join(",")] = rule.declarations;
|
|
229
|
+
if (rule.pseudo) {
|
|
230
|
+
const pseudoSelectors = rule.selectors.map((selector) => `${selector}::after`).join(",");
|
|
231
|
+
baseRules[pseudoSelectors] = rule.pseudo;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
addBase(baseRules);
|
|
235
|
+
};
|
|
236
|
+
}, () => {
|
|
237
|
+
return {};
|
|
238
|
+
});
|
|
239
|
+
//#endregion
|
|
240
|
+
export { reset as default, reset };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/reset",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1-next.1",
|
|
4
4
|
"description": "weapp-tailwindcss 的静态 reset 样式资源集合",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,20 +42,20 @@
|
|
|
42
42
|
"uni-app"
|
|
43
43
|
],
|
|
44
44
|
"engines": {
|
|
45
|
-
"node": "
|
|
45
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"tailwindcss": "^3.0.0 || ^4.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@weapp-tailwindcss/test-helper": "0.0.1"
|
|
51
|
+
"@weapp-tailwindcss/test-helper": "0.0.2-next.1"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public",
|
|
55
55
|
"registry": "https://registry.npmjs.org"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
|
-
"build": "
|
|
58
|
+
"build": "tsdown",
|
|
59
59
|
"test": "vitest run",
|
|
60
60
|
"test:dev": "vitest"
|
|
61
61
|
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import * as node_modules_tailwindcss_dist_types_CJYAW1ql_mjs from 'node_modules/tailwindcss/dist/types-CJYAW1ql.mjs';
|
|
2
|
-
|
|
3
|
-
type ResetPreset = 'minimal' | 'form' | 'content' | 'media' | 'all';
|
|
4
|
-
type BuiltInResetName = 'buttonReset' | 'imageReset' | 'inputReset' | 'textareaReset' | 'listReset' | 'navigatorReset' | 'videoReset';
|
|
5
|
-
interface ResetOptions {
|
|
6
|
-
/**
|
|
7
|
-
* 启用一组内置 reset 预设;默认不传时保持最小行为,仅注入 button/image。
|
|
8
|
-
*/
|
|
9
|
-
preset?: ResetPreset | ResetPreset[];
|
|
10
|
-
/**
|
|
11
|
-
* 控制 `button` reset 的注入与选择器,传入 `false` 可跳过该规则。
|
|
12
|
-
*/
|
|
13
|
-
buttonReset?: false | ResetConfig;
|
|
14
|
-
/**
|
|
15
|
-
* 控制 `image` reset(同时覆盖 `<image>` 与 `<img>`)。
|
|
16
|
-
*/
|
|
17
|
-
imageReset?: false | ResetConfig;
|
|
18
|
-
/**
|
|
19
|
-
* 控制常见输入框 reset(`input`)。
|
|
20
|
-
*/
|
|
21
|
-
inputReset?: false | ResetConfig;
|
|
22
|
-
/**
|
|
23
|
-
* 控制多行输入框 reset(`textarea`)。
|
|
24
|
-
*/
|
|
25
|
-
textareaReset?: false | ResetConfig;
|
|
26
|
-
/**
|
|
27
|
-
* 控制列表 reset(`ul` / `ol`)。
|
|
28
|
-
*/
|
|
29
|
-
listReset?: false | ResetConfig;
|
|
30
|
-
/**
|
|
31
|
-
* 控制链接 reset(`navigator` / `a`)。
|
|
32
|
-
*/
|
|
33
|
-
navigatorReset?: false | ResetConfig;
|
|
34
|
-
/**
|
|
35
|
-
* 控制 `video` reset。
|
|
36
|
-
*/
|
|
37
|
-
videoReset?: false | ResetConfig;
|
|
38
|
-
/**
|
|
39
|
-
* 额外的 reset 规则,可根据业务自定义。
|
|
40
|
-
*/
|
|
41
|
-
extraResets?: ResetConfig[];
|
|
42
|
-
}
|
|
43
|
-
interface ResetConfig {
|
|
44
|
-
selectors?: string[];
|
|
45
|
-
declarations?: Record<string, string | number | false | null | undefined>;
|
|
46
|
-
pseudo?: Record<string, string | number | false | null | undefined>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
declare const reset: node_modules_tailwindcss_dist_types_CJYAW1ql_mjs.c<ResetOptions>;
|
|
50
|
-
|
|
51
|
-
export { type BuiltInResetName, type ResetConfig, type ResetOptions, type ResetPreset, reset as default, reset };
|