daisyui 0.0.0-insiders.3.0

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.
@@ -0,0 +1,434 @@
1
+ module.exports = {
2
+ "[data-theme=aqua]": {
3
+ "color-scheme": "dark",
4
+ primary: "#09ecf3",
5
+ "primary-content": "#005355",
6
+ secondary: "#966fb3",
7
+ accent: "#ffe999",
8
+ neutral: "#3b8ac4",
9
+ "base-100": "#345da7",
10
+ "info": "#2563eb",
11
+ "success": "#16a34a",
12
+ "warning": "#d97706",
13
+ "error": "#dc2626",
14
+ },
15
+ "[data-theme=black]": {
16
+ "color-scheme": "dark",
17
+ primary: "#343232",
18
+ secondary: "#343232",
19
+ accent: "#343232",
20
+ "base-100": "#000000",
21
+ "base-200": "#0D0D0D",
22
+ "base-300": "#1A1919",
23
+ neutral: "#272626",
24
+ "neutral-focus": "#343232",
25
+ info: "#0000ff",
26
+ success: "#008000",
27
+ warning: "#ffff00",
28
+ error: "#ff0000",
29
+ "--rounded-box": "0",
30
+ "--rounded-btn": "0",
31
+ "--rounded-badge": "0",
32
+ "--animation-btn": "0",
33
+ "--animation-input": "0",
34
+ "--btn-text-case": "lowercase",
35
+ "--btn-focus-scale": "1",
36
+ "--tab-radius": "0",
37
+ },
38
+ "[data-theme=bumblebee]": {
39
+ "color-scheme": "light",
40
+ primary: "#e0a82e",
41
+ "primary-content": "#181830",
42
+ secondary: "#f9d72f",
43
+ "secondary-content": "#181830",
44
+ accent: "#181830",
45
+ neutral: "#181830",
46
+ "base-100": "#ffffff",
47
+ },
48
+ "[data-theme=cmyk]": {
49
+ "color-scheme": "light",
50
+ primary: "#45AEEE",
51
+ secondary: "#E8488A",
52
+ accent: "#FFF232",
53
+ neutral: "#1a1a1a",
54
+ "base-100": "#ffffff",
55
+ info: "#4AA8C0",
56
+ success: "#823290",
57
+ warning: "#EE8133",
58
+ error: "#E93F33",
59
+ },
60
+ "[data-theme=corporate]": {
61
+ "color-scheme": "light",
62
+ primary: "#4b6bfb",
63
+ secondary: "#7b92b2",
64
+ accent: "#67cba0",
65
+ neutral: "#181a2a",
66
+ "neutral-content": "#edf2f7",
67
+ "base-100": "#ffffff",
68
+ "base-content": "#181a2a",
69
+ "--rounded-box": "0.25rem",
70
+ "--rounded-btn": ".125rem",
71
+ "--rounded-badge": ".125rem",
72
+ "--animation-btn": "0",
73
+ "--animation-input": "0",
74
+ "--btn-focus-scale": "1",
75
+ },
76
+ "[data-theme=cupcake]": {
77
+ "color-scheme": "light",
78
+ primary: "#65c3c8",
79
+ secondary: "#ef9fbc",
80
+ accent: "#eeaf3a",
81
+ neutral: "#291334",
82
+ "base-100": "#faf7f5",
83
+ "base-200": "#efeae6",
84
+ "base-300": "#e7e2df",
85
+ "base-content": "#291334",
86
+ "--rounded-btn": "1.9rem",
87
+ "--tab-border": "2px",
88
+ "--tab-radius": ".5rem",
89
+ },
90
+ "[data-theme=cyberpunk]": {
91
+ "color-scheme": "light",
92
+ fontFamily: "ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace",
93
+ primary: "#ff7598",
94
+ secondary: "#75d1f0",
95
+ accent: "#c07eec",
96
+ neutral: "#423f00",
97
+ "neutral-content": "#ffee00",
98
+ "base-100": "#ffee00",
99
+ "--rounded-box": "0",
100
+ "--rounded-btn": "0",
101
+ "--rounded-badge": "0",
102
+ "--tab-radius": "0",
103
+ },
104
+ "[data-theme=dark]": {
105
+ "color-scheme": "dark",
106
+ primary: "#661AE6",
107
+ "primary-content": "#ffffff",
108
+ secondary: "#D926AA",
109
+ "secondary-content": "#ffffff",
110
+ accent: "#1FB2A5",
111
+ "accent-content": "#ffffff",
112
+ neutral: "#191D24",
113
+ "neutral-focus": "#111318",
114
+ "neutral-content": "#A6ADBB",
115
+ "base-100": "#2A303C",
116
+ "base-200": "#242933",
117
+ "base-300": "#20252E",
118
+ "base-content": "#A6ADBB",
119
+ },
120
+ "[data-theme=dracula]": {
121
+ "color-scheme": "dark",
122
+ primary: "#ff79c6",
123
+ secondary: "#bd93f9",
124
+ accent: "#ffb86c",
125
+ neutral: "#414558",
126
+ "base-100": "#282a36",
127
+ "base-content": "#f8f8f2",
128
+ info: "#8be9fd",
129
+ success: "#50fa7b",
130
+ warning: "#f1fa8c",
131
+ error: "#ff5555",
132
+ },
133
+ "[data-theme=emerald]": {
134
+ "color-scheme": "light",
135
+ primary: "#66cc8a",
136
+ "primary-content": "#223D30",
137
+ secondary: "#377cfb",
138
+ "secondary-content": "#f9fafb",
139
+ accent: "#ea5234",
140
+ "accent-content": "#f9fafb",
141
+ neutral: "#333c4d",
142
+ "neutral-content": "#f9fafb",
143
+ "base-100": "#ffffff",
144
+ "base-content": "#333c4d",
145
+ "--animation-btn": "0",
146
+ "--animation-input": "0",
147
+ "--btn-focus-scale": "1",
148
+ },
149
+ "[data-theme=fantasy]": {
150
+ "color-scheme": "light",
151
+ primary: "#6e0b75",
152
+ secondary: "#007ebd",
153
+ accent: "#f8860d",
154
+ neutral: "#1f2937",
155
+ "base-100": "#ffffff",
156
+ "base-content": "#1f2937",
157
+ },
158
+ "[data-theme=forest]": {
159
+ "color-scheme": "dark",
160
+ primary: "#1eb854",
161
+ "primary-content": "#c2ffd7",
162
+ secondary: "#1fd65f",
163
+ accent: "#d99330",
164
+ neutral: "#110e0e",
165
+ "base-100": "#171212",
166
+ "--rounded-btn": "1.9rem",
167
+ },
168
+ "[data-theme=garden]": {
169
+ "color-scheme": "light",
170
+ primary: "#5c7f67",
171
+ secondary: "#ecf4e7",
172
+ "secondary-content": "#24331a",
173
+ accent: "#fae5e5",
174
+ "accent-content": "#322020",
175
+ neutral: "#5d5656",
176
+ "neutral-content": "#e9e7e7",
177
+ "base-100": "#e9e7e7",
178
+ "base-content": "#100f0f",
179
+ },
180
+ "[data-theme=halloween]": {
181
+ "color-scheme": "dark",
182
+ primary: "#f28c18",
183
+ "primary-content": "#131616",
184
+ secondary: "#6d3a9c",
185
+ accent: "#51a800",
186
+ neutral: "#1b1d1d",
187
+ "base-100": "#212121",
188
+ info: "#2563eb",
189
+ success: "#16a34a",
190
+ warning: "#d97706",
191
+ error: "#dc2626",
192
+ },
193
+ "[data-theme=light]": {
194
+ "color-scheme": "light",
195
+ primary: "#570df8",
196
+ "primary-content": "#ffffff",
197
+ secondary: "#f000b8",
198
+ "secondary-content": "#ffffff",
199
+ accent: "#37cdbe",
200
+ "accent-content": "#163835",
201
+ neutral: "#3d4451",
202
+ "neutral-content": "#ffffff",
203
+ "base-100": "#ffffff",
204
+ "base-200": "#F2F2F2",
205
+ "base-300": "#E5E6E6",
206
+ "base-content": "#1f2937",
207
+ },
208
+ "[data-theme=lofi]": {
209
+ "color-scheme": "light",
210
+ "primary": "#0D0D0D",
211
+ "primary-content": "#ffffff",
212
+ "secondary": "#1A1919",
213
+ "secondary-content": "#ffffff",
214
+ "accent": "#262626",
215
+ "accent-content": "#ffffff",
216
+ "neutral": "#000000",
217
+ "neutral-content": "#ffffff",
218
+ "base-100": "#ffffff",
219
+ "base-200": "#F2F2F2",
220
+ "base-300": "#E6E5E5",
221
+ "base-content": "#000000",
222
+ "info": "#0070F3",
223
+ "info-content": "#ffffff",
224
+ "success": "#21CC51",
225
+ "success-content": "#ffffff",
226
+ "warning": "#FF6154",
227
+ "warning-content": "#ffffff",
228
+ "error": "#DE1C8D",
229
+ "error-content": "#ffffff",
230
+ "--rounded-box": "0.25rem",
231
+ "--rounded-btn": "0.125rem",
232
+ "--rounded-badge": "0.125rem",
233
+ "--animation-btn": "0",
234
+ "--animation-input": "0",
235
+ "--btn-focus-scale": "1",
236
+ "--tab-radius": "0",
237
+ },
238
+ "[data-theme=luxury]": {
239
+ "color-scheme": "dark",
240
+ primary: "#ffffff",
241
+ secondary: "#152747",
242
+ accent: "#513448",
243
+ neutral: "#171618",
244
+ "neutral-content": "#dca54c",
245
+ "base-100": "#09090b",
246
+ "base-200": "#171618",
247
+ "base-300": "#2e2d2f",
248
+ "base-content": "#dca54c",
249
+ info: "#66c6ff",
250
+ success: "#87d039",
251
+ warning: "#e2d562",
252
+ error: "#ff6f6f",
253
+ },
254
+ "[data-theme=pastel]": {
255
+ "color-scheme": "light",
256
+ primary: "#d1c1d7",
257
+ secondary: "#f6cbd1",
258
+ accent: "#b4e9d6",
259
+ neutral: "#70acc7",
260
+ "base-100": "#ffffff",
261
+ "base-200": "#f9fafb",
262
+ "base-300": "#d1d5db",
263
+ "--rounded-btn": "1.9rem",
264
+ },
265
+ "[data-theme=retro]": {
266
+ "color-scheme": "light",
267
+ primary: "#ef9995",
268
+ "primary-content": "#282425",
269
+ secondary: "#a4cbb4",
270
+ "secondary-content": "#282425",
271
+ accent: "#ebdc99",
272
+ "accent-content": "#282425",
273
+ neutral: "#7d7259",
274
+ "neutral-content": "#e4d8b4",
275
+ "base-100": "#e4d8b4",
276
+ "base-200": "#d2c59d",
277
+ "base-300": "#c6b386",
278
+ "base-content": "#282425",
279
+ "info": "#2563eb",
280
+ "success": "#16a34a",
281
+ "warning": "#d97706",
282
+ "error": "#dc2626",
283
+ "--rounded-box": "0.4rem",
284
+ "--rounded-btn": "0.4rem",
285
+ "--rounded-badge": "0.4rem",
286
+ },
287
+ "[data-theme=synthwave]": {
288
+ "color-scheme": "dark",
289
+ primary: "#e779c1",
290
+ secondary: "#58c7f3",
291
+ accent: "#f3cc30",
292
+ neutral: "#20134e",
293
+ "neutral-content": "#f9f7fd",
294
+ "base-100": "#2d1b69",
295
+ "base-content": "#f9f7fd",
296
+ info: "#53c0f3",
297
+ "info-content": "#201047",
298
+ success: "#71ead2",
299
+ "success-content": "#201047",
300
+ warning: "#f3cc30",
301
+ "warning-content": "#201047",
302
+ error: "#e24056",
303
+ "error-content": "#f9f7fd",
304
+ },
305
+ "[data-theme=valentine]": {
306
+ "color-scheme": "light",
307
+ primary: "#e96d7b",
308
+ secondary: "#a991f7",
309
+ accent: "#88dbdd",
310
+ neutral: "#af4670",
311
+ "neutral-content": "#f0d6e8",
312
+ "base-100": "#f0d6e8",
313
+ "base-content": "#632c3b",
314
+ "info": "#2563eb",
315
+ "success": "#16a34a",
316
+ "warning": "#d97706",
317
+ "error": "#dc2626",
318
+ "--rounded-btn": "1.9rem",
319
+ },
320
+ "[data-theme=wireframe]": {
321
+ "color-scheme": "light",
322
+ fontFamily: 'Chalkboard,comic sans ms,"sanssecondaryerif"',
323
+ primary: "#b8b8b8",
324
+ secondary: "#b8b8b8",
325
+ accent: "#b8b8b8",
326
+ neutral: "#ebebeb",
327
+ "base-100": "#ffffff",
328
+ "base-200": "#eeeeee",
329
+ "base-300": "#dddddd",
330
+ info: "#0000ff",
331
+ success: "#008000",
332
+ warning: "#a6a659",
333
+ error: "#ff0000",
334
+ "--rounded-box": "0.2rem",
335
+ "--rounded-btn": "0.2rem",
336
+ "--rounded-badge": "0.2rem",
337
+ "--tab-radius": "0.2rem",
338
+ },
339
+ "[data-theme=autumn]": {
340
+ "color-scheme": "light",
341
+ primary: "#8C0327",
342
+ secondary: "#D85251",
343
+ accent: "#D59B6A",
344
+ neutral: "#826A5C",
345
+ "base-100": "#f1f1f1",
346
+ info: "#42ADBB",
347
+ success: "#499380",
348
+ warning: "#E97F14",
349
+ error: "#DF1A2F",
350
+ },
351
+ "[data-theme=business]": {
352
+ "color-scheme": "dark",
353
+ primary: "#1C4E80",
354
+ secondary: "#7C909A",
355
+ accent: "#EA6947",
356
+ neutral: "#23282E",
357
+ "base-100": "#202020",
358
+ info: "#0091D5",
359
+ success: "#6BB187",
360
+ warning: "#DBAE59",
361
+ error: "#AC3E31",
362
+ "--rounded-box": "0.25rem",
363
+ "--rounded-btn": ".125rem",
364
+ "--rounded-badge": ".125rem",
365
+ },
366
+ "[data-theme=acid]": {
367
+ "color-scheme": "light",
368
+ primary: "#FF00F4",
369
+ secondary: "#FF7400",
370
+ accent: "#CBFD03",
371
+ neutral: "#191A3F",
372
+ "base-100": "#fafafa",
373
+ info: "#3194F6",
374
+ success: "#5FC992",
375
+ warning: "#F7DE2D",
376
+ error: "#E60300",
377
+ "--rounded-box": "1.25rem",
378
+ "--rounded-btn": "1rem",
379
+ "--rounded-badge": "1rem",
380
+ },
381
+ "[data-theme=lemonade]": {
382
+ "color-scheme": "light",
383
+ primary: "#519903",
384
+ secondary: "#E9E92E",
385
+ accent: "#F7F9CA",
386
+ neutral: "#191A3F",
387
+ "base-100": "#ffffff",
388
+ info: "#C8E1E7",
389
+ success: "#DEF29F",
390
+ warning: "#F7E589",
391
+ error: "#F2B6B5",
392
+ },
393
+ "[data-theme=night]": {
394
+ "color-scheme": "dark",
395
+ "primary": "#38bdf8",
396
+ "secondary": "#818CF8",
397
+ "accent": "#F471B5",
398
+ "neutral": "#1E293B",
399
+ "neutral-focus": "#273449",
400
+ "base-100": "#0F172A",
401
+ "info": "#0CA5E9",
402
+ "success": "#2DD4BF",
403
+ "warning": "#F4BF50",
404
+ "error": "#FB7085",
405
+ },
406
+ "[data-theme=coffee]": {
407
+ "color-scheme": "dark",
408
+ "primary": "#DB924B",
409
+ "secondary": "#263E3F",
410
+ "accent": "#10576D",
411
+ "neutral": "#120C12",
412
+ "base-100": "#20161F",
413
+ "base-content": "#756E63",
414
+ "info": "#8DCAC1",
415
+ "success": "#9DB787",
416
+ "warning": "#FFD25F",
417
+ "error": "#FC9581",
418
+ },
419
+ "[data-theme=winter]": {
420
+ "color-scheme": "light",
421
+ "primary": "#047AFF",
422
+ "secondary": "#463AA2",
423
+ "accent": "#C148AC",
424
+ "neutral": "#021431",
425
+ "base-100": "#ffffff",
426
+ "base-200": "#F2F7FF",
427
+ "base-300": "#E3E9F4",
428
+ "base-content": "#394E6A",
429
+ "info": "#93E7FB",
430
+ "success": "#81CFD1",
431
+ "warning": "#EFD7BB",
432
+ "error": "#E58B8B",
433
+ },
434
+ };
package/src/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type plugin from "tailwindcss/plugin"
2
+
3
+ // Export types
4
+ declare const daisyui: ReturnType<typeof plugin>
5
+ export = daisyui
package/src/index.js ADDED
@@ -0,0 +1,145 @@
1
+ const tailwindColors = require('tailwindcss/colors')
2
+
3
+ const postcssJs = require("postcss-js")
4
+ const postcssPrefix = require('./lib/postcss-prefixer')
5
+
6
+ const daisyuiInfo = require("../package.json");
7
+ const colors = require("./colors/index");
8
+ const utilities = require("../dist/utilities");
9
+ const base = require("../dist/base");
10
+ const unstyled = require("../dist/unstyled");
11
+ const unstyledRtl = require("../dist/unstyled.rtl");
12
+ const styled = require("../dist/styled");
13
+ const styledRtl = require("../dist/styled.rtl");
14
+ const utilitiesUnstyled = require("../dist/utilities-unstyled");
15
+ const utilitiesStyled = require("../dist/utilities-styled");
16
+ const themes = require("./colors/themes");
17
+ const colorFunctions = require("./colors/functions");
18
+
19
+ const mainFunction = ({ addBase, addComponents, addUtilities, config, postcss }) => {
20
+ let daisyuiIncludedItems = [];
21
+ let logs = false;
22
+ if (config("daisyui.logs") != false) {
23
+ logs = true;
24
+ }
25
+ if (logs) {
26
+ console.log();
27
+ console.log(
28
+ "\x1b[35m%s\x1b[0m",
29
+ "🌼 daisyUI components " + daisyuiInfo.version,
30
+ "\x1b[0m",
31
+ daisyuiInfo.homepage
32
+ );
33
+ console.group();
34
+ }
35
+
36
+ // inject @base style
37
+ if (config("daisyui.base") != false) {
38
+ addBase(base);
39
+ daisyuiIncludedItems.push("base");
40
+ }
41
+
42
+ // inject components
43
+ // because rollupjs doesn't supprt dynamic require
44
+ let file = styled;
45
+ if (config("daisyui.styled") == false && config("daisyui.rtl") != true) {
46
+ daisyuiIncludedItems.push("unstyled components");
47
+ file = unstyled;
48
+ } else if (
49
+ config("daisyui.styled") == false &&
50
+ config("daisyui.rtl") == true
51
+ ) {
52
+ daisyuiIncludedItems.push("unstyled components");
53
+ console.log("\x1b[36m%s\x1b[0m", " Direction:", "\x1b[0m", "RTL");
54
+ file = unstyledRtl;
55
+ } else if (
56
+ config("daisyui.styled") != false &&
57
+ config("daisyui.rtl") != true
58
+ ) {
59
+ daisyuiIncludedItems.push("components");
60
+ file = styled;
61
+ } else if (
62
+ config("daisyui.styled") !== false &&
63
+ config("daisyui.rtl") == true
64
+ ) {
65
+ daisyuiIncludedItems.push("components");
66
+ console.log("\x1b[36m%s\x1b[0m", " Direction:", "\x1b[0m", "RTL");
67
+ file = styledRtl;
68
+ }
69
+
70
+ // add prefix to class names if specified
71
+ const prefix = config("daisyui.prefix")
72
+ let postcssJsProcess
73
+ if (prefix) {
74
+ try {
75
+ postcssJsProcess = postcssJs.sync(postcssPrefix({ prefix, ignore: [] }))
76
+ } catch (error) {
77
+ logs && console.error(`Error occurred and prevent applying the "prefix" option:`, error)
78
+ }
79
+ }
80
+ const shouldApplyPrefix = prefix && postcssJsProcess;
81
+ if (shouldApplyPrefix) {
82
+ file = postcssJsProcess(file)
83
+ }
84
+
85
+ addComponents(file);
86
+
87
+ const themeInjector = colorFunctions.injectThemes(addBase, config, themes)
88
+ themeInjector;
89
+
90
+ daisyuiIncludedItems.push(themeInjector.themeOrder.length + " themes");
91
+
92
+ // inject @utilities style needed by components
93
+ if (config("daisyui.utils") != false) {
94
+ addComponents(utilities, { variants: ["responsive"] });
95
+
96
+ let toAdd = utilitiesUnstyled // shadow clone here to avoid mutate the original
97
+ if (shouldApplyPrefix) {
98
+ toAdd = postcssJsProcess(toAdd);
99
+ }
100
+ addComponents(toAdd, { variants: ["responsive"] });
101
+
102
+ toAdd = utilitiesStyled
103
+ if (shouldApplyPrefix) {
104
+ toAdd = postcssJsProcess(toAdd);
105
+ }
106
+ addComponents(toAdd, { variants: ["responsive"] });
107
+ daisyuiIncludedItems.push("utilities");
108
+ }
109
+ if (logs) {
110
+ console.log(
111
+ "\x1b[32m%s\x1b[0m",
112
+ "✔︎ Including:",
113
+ "\x1b[0m",
114
+ "" + daisyuiIncludedItems.join(", ")
115
+ );
116
+ console.log(
117
+ "\x1b[32m%s\x1b[0m",
118
+ "❤︎ Support daisyUI: ", daisyuiInfo.funding.url,
119
+ "\x1b[0m",
120
+ );
121
+ console.log();
122
+ console.groupEnd();
123
+ }
124
+ };
125
+
126
+ module.exports = require("tailwindcss/plugin")(mainFunction, {
127
+ theme: {
128
+ extend: {
129
+ colors: {
130
+ ...colors,
131
+ // adding all Tailwind `neutral` shades here so they don't get overridden by daisyUI `neutral` color
132
+ "neutral-50": tailwindColors.neutral[50],
133
+ "neutral-100": tailwindColors.neutral[100],
134
+ "neutral-200": tailwindColors.neutral[200],
135
+ "neutral-300": tailwindColors.neutral[300],
136
+ "neutral-400": tailwindColors.neutral[400],
137
+ "neutral-500": tailwindColors.neutral[500],
138
+ "neutral-600": tailwindColors.neutral[600],
139
+ "neutral-700": tailwindColors.neutral[700],
140
+ "neutral-800": tailwindColors.neutral[800],
141
+ "neutral-900": tailwindColors.neutral[900],
142
+ }
143
+ }
144
+ },
145
+ });
@@ -0,0 +1,87 @@
1
+ const Tokenizer = require('css-selector-tokenizer');
2
+ const {
3
+ parseAttrSelector,
4
+ attrStringify,
5
+ itMatchesOne,
6
+ } = require('./utils');
7
+
8
+ function prefixNode(node, prefix) {
9
+ if (['class', 'id'].includes(node.type)) {
10
+ return {
11
+ ...node,
12
+ name: `${prefix}${node.name}`,
13
+ };
14
+ }
15
+
16
+ if (['attribute'].includes(node.type) && node.content) {
17
+ const {
18
+ type, operator, head, classes, foot,
19
+ } = parseAttrSelector(node);
20
+
21
+ if (!['class', 'id'].includes(type)) return node;
22
+
23
+ return {
24
+ ...node,
25
+ content: attrStringify({
26
+ type,
27
+ operator,
28
+ head,
29
+ classes: classes.map((cls) => `${prefix}${cls}`),
30
+ foot,
31
+ }),
32
+ }
33
+ }
34
+
35
+ return node;
36
+ }
37
+
38
+ function iterateSelectorNodes(selector, options) {
39
+ const { prefix, ignore } = options;
40
+ return {
41
+ ...selector,
42
+ nodes: selector.nodes.map((node) => {
43
+ if (['selector', 'nested-pseudo-class'].includes(node.type)) {
44
+ return iterateSelectorNodes(node, options);
45
+ }
46
+
47
+ if (itMatchesOne(ignore, Tokenizer.stringify(node))) return node;
48
+
49
+ return prefixNode(node, prefix);
50
+ }),
51
+ };
52
+ }
53
+
54
+ /**
55
+ * @type {import('postcss').PluginCreator}
56
+ */
57
+ module.exports = (opts = {}) => {
58
+ const { prefix, ignore } = {
59
+ prefix: '',
60
+ ignore: [],
61
+ ...opts,
62
+ };
63
+
64
+ if (typeof prefix !== 'string') {
65
+ throw new Error('@postcss-prefix: prefix option should be of type string.');
66
+ }
67
+
68
+ if (!Array.isArray(ignore)) {
69
+ throw new Error('@postcss-prefix: ignore options should be an Array.');
70
+ }
71
+
72
+ if (!prefix.length) return;
73
+
74
+ return {
75
+ postcssPlugin: 'postcss-prefixer',
76
+ Root(root, postcss) {
77
+ root.walkRules((rule) => {
78
+ const parsed = Tokenizer.parse(rule.selector);
79
+ const selector = iterateSelectorNodes(parsed, { prefix, ignore });
80
+
81
+ rule.selector = Tokenizer.stringify(selector);
82
+ });
83
+ },
84
+ };
85
+ }
86
+
87
+ module.exports.postcss = true
@@ -0,0 +1,29 @@
1
+ module.exports = {
2
+
3
+ itMatchesOne(arr, term) {
4
+ return arr.some((i) => term.search(i) >= 0);
5
+ },
6
+
7
+ parseAttrSelector(node) {
8
+ const { content } = node;
9
+ const regex = /(^class|^id)([*^?~|$=]*)+(?:("\s*)([^"\\]*?(?:\\.[^"\\]*)*?)(\s*")|('\s*)([^'\\]*?(?:\\.[^'\\]*)*?)(\s*'))/i;
10
+
11
+ const [type, operator, head, classes, foot] = content
12
+ .split(regex)
13
+ .filter((part) => part);
14
+
15
+ return {
16
+ type,
17
+ operator,
18
+ head,
19
+ classes: classes ? classes.split(' ').map((c) => c.replace(/"|'/g, '')) : [],
20
+ foot,
21
+ };
22
+ },
23
+
24
+ attrStringify({
25
+ type, operator, head, classes, foot,
26
+ }) {
27
+ return `${type}${operator || ''}${head || ''}${classes.join(' ')}${foot || ''}`;
28
+ },
29
+ };