@youthfulhps/prettier-plugin-tailwindcss-normalizer 0.3.4

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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/ast-transformer.d.ts +4 -0
  4. package/dist/ast-transformer.js +180 -0
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.js +75 -0
  7. package/dist/mappings/effects/index.d.ts +2 -0
  8. package/dist/mappings/effects/index.js +7 -0
  9. package/dist/mappings/effects/shadows-opacity.d.ts +2 -0
  10. package/dist/mappings/effects/shadows-opacity.js +33 -0
  11. package/dist/mappings/filters/blur-effects.d.ts +2 -0
  12. package/dist/mappings/filters/blur-effects.js +141 -0
  13. package/dist/mappings/filters/index.d.ts +2 -0
  14. package/dist/mappings/filters/index.js +7 -0
  15. package/dist/mappings/index.d.ts +2 -0
  16. package/dist/mappings/index.js +23 -0
  17. package/dist/mappings/interactivity/index.d.ts +2 -0
  18. package/dist/mappings/interactivity/index.js +7 -0
  19. package/dist/mappings/interactivity/outline-ring-scroll.d.ts +2 -0
  20. package/dist/mappings/interactivity/outline-ring-scroll.js +68 -0
  21. package/dist/mappings/layout/borders-rounded.d.ts +2 -0
  22. package/dist/mappings/layout/borders-rounded.js +153 -0
  23. package/dist/mappings/layout/index.d.ts +2 -0
  24. package/dist/mappings/layout/index.js +9 -0
  25. package/dist/mappings/layout/positioning.d.ts +2 -0
  26. package/dist/mappings/layout/positioning.js +99 -0
  27. package/dist/mappings/sizing/height.d.ts +2 -0
  28. package/dist/mappings/sizing/height.js +173 -0
  29. package/dist/mappings/sizing/index.d.ts +2 -0
  30. package/dist/mappings/sizing/index.js +11 -0
  31. package/dist/mappings/sizing/size.d.ts +2 -0
  32. package/dist/mappings/sizing/size.js +62 -0
  33. package/dist/mappings/sizing/width.d.ts +2 -0
  34. package/dist/mappings/sizing/width.js +166 -0
  35. package/dist/mappings/spacing/gap-space.d.ts +2 -0
  36. package/dist/mappings/spacing/gap-space.js +70 -0
  37. package/dist/mappings/spacing/index.d.ts +2 -0
  38. package/dist/mappings/spacing/index.js +11 -0
  39. package/dist/mappings/spacing/margin.d.ts +2 -0
  40. package/dist/mappings/spacing/margin.js +587 -0
  41. package/dist/mappings/spacing/padding.d.ts +2 -0
  42. package/dist/mappings/spacing/padding.js +305 -0
  43. package/dist/mappings/transforms/index.d.ts +2 -0
  44. package/dist/mappings/transforms/index.js +7 -0
  45. package/dist/mappings/transforms/rotate-scale-translate.d.ts +2 -0
  46. package/dist/mappings/transforms/rotate-scale-translate.js +64 -0
  47. package/dist/mappings/transitions/duration-delay.d.ts +2 -0
  48. package/dist/mappings/transitions/duration-delay.js +36 -0
  49. package/dist/mappings/transitions/index.d.ts +2 -0
  50. package/dist/mappings/transitions/index.js +7 -0
  51. package/dist/mappings/typography/font-size.d.ts +2 -0
  52. package/dist/mappings/typography/font-size.js +40 -0
  53. package/dist/mappings/typography/index.d.ts +2 -0
  54. package/dist/mappings/typography/index.js +7 -0
  55. package/dist/normalizer.d.ts +3 -0
  56. package/dist/normalizer.js +123 -0
  57. package/dist/types/prettier-compat.d.ts +20 -0
  58. package/dist/types/prettier-compat.js +10 -0
  59. package/dist/types.d.ts +93 -0
  60. package/dist/types.js +2 -0
  61. package/dist/utils/version-utils.d.ts +6 -0
  62. package/dist/utils/version-utils.js +89 -0
  63. package/package.json +69 -0
@@ -0,0 +1,305 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.paddingMappings = void 0;
4
+ exports.paddingMappings = {
5
+ p: {
6
+ "0px": "p-0",
7
+ "1px": "p-px",
8
+ "4px": "p-1",
9
+ "8px": "p-2",
10
+ "12px": "p-3",
11
+ "16px": "p-4",
12
+ "20px": "p-5",
13
+ "24px": "p-6",
14
+ "28px": "p-7",
15
+ "32px": "p-8",
16
+ "36px": "p-9",
17
+ "40px": "p-10",
18
+ "44px": "p-11",
19
+ "48px": "p-12",
20
+ "56px": "p-14",
21
+ "64px": "p-16",
22
+ "80px": "p-20",
23
+ "96px": "p-24",
24
+ "112px": "p-28",
25
+ "128px": "p-32",
26
+ "144px": "p-36",
27
+ "160px": "p-40",
28
+ "176px": "p-44",
29
+ "192px": "p-48",
30
+ "208px": "p-52",
31
+ "224px": "p-56",
32
+ "240px": "p-60",
33
+ "256px": "p-64",
34
+ "288px": "p-72",
35
+ "320px": "p-80",
36
+ "384px": "p-96",
37
+ },
38
+ px: {
39
+ "0px": "px-0",
40
+ "1px": "px-px",
41
+ "4px": "px-1",
42
+ "8px": "px-2",
43
+ "12px": "px-3",
44
+ "16px": "px-4",
45
+ "20px": "px-5",
46
+ "24px": "px-6",
47
+ "28px": "px-7",
48
+ "32px": "px-8",
49
+ "36px": "px-9",
50
+ "40px": "px-10",
51
+ "44px": "px-11",
52
+ "48px": "px-12",
53
+ "56px": "px-14",
54
+ "64px": "px-16",
55
+ "80px": "px-20",
56
+ "96px": "px-24",
57
+ "112px": "px-28",
58
+ "128px": "px-32",
59
+ "144px": "px-36",
60
+ "160px": "px-40",
61
+ "176px": "px-44",
62
+ "192px": "px-48",
63
+ "208px": "px-52",
64
+ "224px": "px-56",
65
+ "240px": "px-60",
66
+ "256px": "px-64",
67
+ "288px": "px-72",
68
+ "320px": "px-80",
69
+ "384px": "px-96",
70
+ },
71
+ py: {
72
+ "0px": "py-0",
73
+ "1px": "py-px",
74
+ "2px": "py-0.5",
75
+ "4px": "py-1",
76
+ "6px": "py-1.5",
77
+ "8px": "py-2",
78
+ "10px": "py-2.5",
79
+ "12px": "py-3",
80
+ "16px": "py-4",
81
+ "20px": "py-5",
82
+ "24px": "py-6",
83
+ "28px": "py-7",
84
+ "32px": "py-8",
85
+ "36px": "py-9",
86
+ "40px": "py-10",
87
+ "44px": "py-11",
88
+ "48px": "py-12",
89
+ "56px": "py-14",
90
+ "64px": "py-16",
91
+ "80px": "py-20",
92
+ "96px": "py-24",
93
+ "112px": "py-28",
94
+ "128px": "py-32",
95
+ "144px": "py-36",
96
+ "160px": "py-40",
97
+ "176px": "py-44",
98
+ "192px": "py-48",
99
+ "208px": "py-52",
100
+ "224px": "py-56",
101
+ "240px": "py-60",
102
+ "256px": "py-64",
103
+ "288px": "py-72",
104
+ "320px": "py-80",
105
+ "384px": "py-96",
106
+ },
107
+ pt: {
108
+ "0px": "pt-0",
109
+ "1px": "pt-px",
110
+ "4px": "pt-1",
111
+ "8px": "pt-2",
112
+ "12px": "pt-3",
113
+ "16px": "pt-4",
114
+ "20px": "pt-5",
115
+ "24px": "pt-6",
116
+ "28px": "pt-7",
117
+ "32px": "pt-8",
118
+ "36px": "pt-9",
119
+ "40px": "pt-10",
120
+ "44px": "pt-11",
121
+ "48px": "pt-12",
122
+ "56px": "pt-14",
123
+ "64px": "pt-16",
124
+ "80px": "pt-20",
125
+ "96px": "pt-24",
126
+ "112px": "pt-28",
127
+ "128px": "pt-32",
128
+ "144px": "pt-36",
129
+ "160px": "pt-40",
130
+ "176px": "pt-44",
131
+ "192px": "pt-48",
132
+ "208px": "pt-52",
133
+ "224px": "pt-56",
134
+ "240px": "pt-60",
135
+ "256px": "pt-64",
136
+ "288px": "pt-72",
137
+ "320px": "pt-80",
138
+ "384px": "pt-96",
139
+ },
140
+ pr: {
141
+ "0px": "pr-0",
142
+ "1px": "pr-px",
143
+ "4px": "pr-1",
144
+ "8px": "pr-2",
145
+ "12px": "pr-3",
146
+ "16px": "pr-4",
147
+ "20px": "pr-5",
148
+ "24px": "pr-6",
149
+ "28px": "pr-7",
150
+ "32px": "pr-8",
151
+ "36px": "pr-9",
152
+ "40px": "pr-10",
153
+ "44px": "pr-11",
154
+ "48px": "pr-12",
155
+ "56px": "pr-14",
156
+ "64px": "pr-16",
157
+ "80px": "pr-20",
158
+ "96px": "pr-24",
159
+ "112px": "pr-28",
160
+ "128px": "pr-32",
161
+ "144px": "pr-36",
162
+ "160px": "pr-40",
163
+ "176px": "pr-44",
164
+ "192px": "pr-48",
165
+ "208px": "pr-52",
166
+ "224px": "pr-56",
167
+ "240px": "pr-60",
168
+ "256px": "pr-64",
169
+ "288px": "pr-72",
170
+ "320px": "pr-80",
171
+ "384px": "pr-96",
172
+ },
173
+ pb: {
174
+ "0px": "pb-0",
175
+ "1px": "pb-px",
176
+ "4px": "pb-1",
177
+ "8px": "pb-2",
178
+ "12px": "pb-3",
179
+ "16px": "pb-4",
180
+ "20px": "pb-5",
181
+ "24px": "pb-6",
182
+ "28px": "pb-7",
183
+ "32px": "pb-8",
184
+ "36px": "pb-9",
185
+ "40px": "pb-10",
186
+ "44px": "pb-11",
187
+ "48px": "pb-12",
188
+ "56px": "pb-14",
189
+ "64px": "pb-16",
190
+ "80px": "pb-20",
191
+ "96px": "pb-24",
192
+ "112px": "pb-28",
193
+ "128px": "pb-32",
194
+ "144px": "pb-36",
195
+ "160px": "pb-40",
196
+ "176px": "pb-44",
197
+ "192px": "pb-48",
198
+ "208px": "pb-52",
199
+ "224px": "pb-56",
200
+ "240px": "pb-60",
201
+ "256px": "pb-64",
202
+ "288px": "pb-72",
203
+ "320px": "pb-80",
204
+ "384px": "pb-96",
205
+ },
206
+ pl: {
207
+ "0px": "pl-0",
208
+ "1px": "pl-px",
209
+ "4px": "pl-1",
210
+ "8px": "pl-2",
211
+ "12px": "pl-3",
212
+ "16px": "pl-4",
213
+ "20px": "pl-5",
214
+ "24px": "pl-6",
215
+ "28px": "pl-7",
216
+ "32px": "pl-8",
217
+ "36px": "pl-9",
218
+ "40px": "pl-10",
219
+ "44px": "pl-11",
220
+ "48px": "pl-12",
221
+ "56px": "pl-14",
222
+ "64px": "pl-16",
223
+ "80px": "pl-20",
224
+ "96px": "pl-24",
225
+ "112px": "pl-28",
226
+ "128px": "pl-32",
227
+ "144px": "pl-36",
228
+ "160px": "pl-40",
229
+ "176px": "pl-44",
230
+ "192px": "pl-48",
231
+ "208px": "pl-52",
232
+ "224px": "pl-56",
233
+ "240px": "pl-60",
234
+ "256px": "pl-64",
235
+ "288px": "pl-72",
236
+ "320px": "pl-80",
237
+ "384px": "pl-96",
238
+ },
239
+ ps: {
240
+ "0px": "ps-0",
241
+ "1px": "ps-px",
242
+ "4px": "ps-1",
243
+ "8px": "ps-2",
244
+ "12px": "ps-3",
245
+ "16px": "ps-4",
246
+ "20px": "ps-5",
247
+ "24px": "ps-6",
248
+ "28px": "ps-7",
249
+ "32px": "ps-8",
250
+ "36px": "ps-9",
251
+ "40px": "ps-10",
252
+ "44px": "ps-11",
253
+ "48px": "ps-12",
254
+ "56px": "ps-14",
255
+ "64px": "ps-16",
256
+ "80px": "ps-20",
257
+ "96px": "ps-24",
258
+ "112px": "ps-28",
259
+ "128px": "ps-32",
260
+ "144px": "ps-36",
261
+ "160px": "ps-40",
262
+ "176px": "ps-44",
263
+ "192px": "ps-48",
264
+ "208px": "ps-52",
265
+ "224px": "ps-56",
266
+ "240px": "ps-60",
267
+ "256px": "ps-64",
268
+ "288px": "ps-72",
269
+ "320px": "ps-80",
270
+ "384px": "ps-96",
271
+ },
272
+ pe: {
273
+ "0px": "pe-0",
274
+ "1px": "pe-px",
275
+ "4px": "pe-1",
276
+ "8px": "pe-2",
277
+ "12px": "pe-3",
278
+ "16px": "pe-4",
279
+ "20px": "pe-5",
280
+ "24px": "pe-6",
281
+ "28px": "pe-7",
282
+ "32px": "pe-8",
283
+ "36px": "pe-9",
284
+ "40px": "pe-10",
285
+ "44px": "pe-11",
286
+ "48px": "pe-12",
287
+ "56px": "pe-14",
288
+ "64px": "pe-16",
289
+ "80px": "pe-20",
290
+ "96px": "pe-24",
291
+ "112px": "pe-28",
292
+ "128px": "pe-32",
293
+ "144px": "pe-36",
294
+ "160px": "pe-40",
295
+ "176px": "pe-44",
296
+ "192px": "pe-48",
297
+ "208px": "pe-52",
298
+ "224px": "pe-56",
299
+ "240px": "pe-60",
300
+ "256px": "pe-64",
301
+ "288px": "pe-72",
302
+ "320px": "pe-80",
303
+ "384px": "pe-96",
304
+ },
305
+ };
@@ -0,0 +1,2 @@
1
+ import { TailwindMapping } from "../../types";
2
+ export declare const allTransformsMappings: TailwindMapping;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.allTransformsMappings = void 0;
4
+ const rotate_scale_translate_1 = require("./rotate-scale-translate");
5
+ exports.allTransformsMappings = {
6
+ ...rotate_scale_translate_1.transformsMappings,
7
+ };
@@ -0,0 +1,2 @@
1
+ import { ValueMapping } from "../../types";
2
+ export declare const transformsMappings: Record<string, ValueMapping>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformsMappings = void 0;
4
+ exports.transformsMappings = {
5
+ rotate: {
6
+ "0deg": "rotate-0",
7
+ "1deg": "rotate-1",
8
+ "2deg": "rotate-2",
9
+ "3deg": "rotate-3",
10
+ "6deg": "rotate-6",
11
+ "12deg": "rotate-12",
12
+ "45deg": "rotate-45",
13
+ "90deg": "rotate-90",
14
+ "180deg": "rotate-180",
15
+ "-180deg": "-rotate-180",
16
+ "-90deg": "-rotate-90",
17
+ "-45deg": "-rotate-45",
18
+ "-12deg": "-rotate-12",
19
+ "-6deg": "-rotate-6",
20
+ "-3deg": "-rotate-3",
21
+ "-2deg": "-rotate-2",
22
+ "-1deg": "-rotate-1",
23
+ },
24
+ scale: {
25
+ "0": "scale-0",
26
+ "0.5": "scale-50",
27
+ "0.75": "scale-75",
28
+ "0.9": "scale-90",
29
+ "0.95": "scale-95",
30
+ "1": "scale-100",
31
+ "1.05": "scale-105",
32
+ "1.1": "scale-110",
33
+ "1.25": "scale-125",
34
+ "1.5": "scale-150",
35
+ },
36
+ "translate-x": {
37
+ "0px": "translate-x-0",
38
+ "1px": "translate-x-px",
39
+ "4px": "translate-x-1",
40
+ "8px": "translate-x-2",
41
+ "12px": "translate-x-3",
42
+ "16px": "translate-x-4",
43
+ "20px": "translate-x-5",
44
+ "24px": "translate-x-6",
45
+ "50%": "translate-x-1/2",
46
+ "100%": "translate-x-full",
47
+ "-100%": "-translate-x-full",
48
+ "-50%": "-translate-x-1/2",
49
+ },
50
+ "translate-y": {
51
+ "0px": "translate-y-0",
52
+ "1px": "translate-y-px",
53
+ "4px": "translate-y-1",
54
+ "8px": "translate-y-2",
55
+ "12px": "translate-y-3",
56
+ "16px": "translate-y-4",
57
+ "20px": "translate-y-5",
58
+ "24px": "translate-y-6",
59
+ "50%": "translate-y-1/2",
60
+ "100%": "translate-y-full",
61
+ "-100%": "-translate-y-full",
62
+ "-50%": "-translate-y-1/2",
63
+ },
64
+ };
@@ -0,0 +1,2 @@
1
+ import { ValueMapping } from "../../types";
2
+ export declare const transitionsMappings: Record<string, ValueMapping>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transitionsMappings = void 0;
4
+ exports.transitionsMappings = {
5
+ duration: {
6
+ "75ms": "duration-75",
7
+ "100ms": "duration-100",
8
+ "150ms": "duration-150",
9
+ "200ms": "duration-200",
10
+ "300ms": "duration-300",
11
+ "500ms": "duration-500",
12
+ "700ms": "duration-700",
13
+ "1000ms": "duration-1000",
14
+ },
15
+ "transition-duration": {
16
+ "75ms": "duration-75",
17
+ "100ms": "duration-100",
18
+ "150ms": "duration-150",
19
+ "200ms": "duration-200",
20
+ "300ms": "duration-300",
21
+ "500ms": "duration-500",
22
+ "700ms": "duration-700",
23
+ "1000ms": "duration-1000",
24
+ },
25
+ delay: {
26
+ "0ms": "delay-0",
27
+ "75ms": "delay-75",
28
+ "100ms": "delay-100",
29
+ "150ms": "delay-150",
30
+ "200ms": "delay-200",
31
+ "300ms": "delay-300",
32
+ "500ms": "delay-500",
33
+ "700ms": "delay-700",
34
+ "1000ms": "delay-1000",
35
+ },
36
+ };
@@ -0,0 +1,2 @@
1
+ import { TailwindMapping } from "../../types";
2
+ export declare const allTransitionsMappings: TailwindMapping;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.allTransitionsMappings = void 0;
4
+ const duration_delay_1 = require("./duration-delay");
5
+ exports.allTransitionsMappings = {
6
+ ...duration_delay_1.transitionsMappings,
7
+ };
@@ -0,0 +1,2 @@
1
+ import { ValueMapping } from "../../types";
2
+ export declare const fontSizeMappings: Record<string, ValueMapping>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fontSizeMappings = void 0;
4
+ exports.fontSizeMappings = {
5
+ text: {
6
+ "12px": "text-xs",
7
+ "14px": "text-sm",
8
+ "16px": "text-base",
9
+ "18px": "text-lg",
10
+ "20px": "text-xl",
11
+ "24px": "text-2xl",
12
+ "30px": "text-3xl",
13
+ "36px": "text-4xl",
14
+ "48px": "text-5xl",
15
+ "60px": "text-6xl",
16
+ "72px": "text-7xl",
17
+ "96px": "text-8xl",
18
+ "128px": "text-9xl",
19
+ },
20
+ leading: {
21
+ "1": "leading-none",
22
+ "1.25": "leading-tight",
23
+ "1.375": "leading-snug",
24
+ "1.5": "leading-normal",
25
+ "1.6": "leading-relaxed",
26
+ "1.625": "leading-6",
27
+ "1.75": "leading-7",
28
+ "2": "leading-loose",
29
+ "2.25": "leading-9",
30
+ "2.5": "leading-10",
31
+ },
32
+ tracking: {
33
+ "-0.05em": "tracking-tighter",
34
+ "-0.025em": "tracking-tight",
35
+ "0em": "tracking-normal",
36
+ "0.025em": "tracking-wide",
37
+ "0.05em": "tracking-wider",
38
+ "0.1em": "tracking-widest",
39
+ },
40
+ };
@@ -0,0 +1,2 @@
1
+ import { TailwindMapping } from "../../types";
2
+ export declare const typographyMappings: TailwindMapping;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typographyMappings = void 0;
4
+ const font_size_1 = require("./font-size");
5
+ exports.typographyMappings = {
6
+ ...font_size_1.fontSizeMappings,
7
+ };
@@ -0,0 +1,3 @@
1
+ export declare function normalizeClassAttribute(content: string): string;
2
+ export declare function normalizeClassNames(classNames: string): string;
3
+ export declare function normalizeClassName(className: string): string;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeClassAttribute = normalizeClassAttribute;
4
+ exports.normalizeClassNames = normalizeClassNames;
5
+ exports.normalizeClassName = normalizeClassName;
6
+ const mappings_1 = require("./mappings");
7
+ function normalizeClassAttribute(content) {
8
+ let result = content;
9
+ const classAttributeRegex = /class\s*=\s*["']([^"']*?)["']/g;
10
+ result = result.replace(classAttributeRegex, (match, classNames) => {
11
+ const normalizedClasses = normalizeClassNames(classNames);
12
+ return match.replace(classNames, normalizedClasses);
13
+ });
14
+ const classNameAttributeRegex = /className\s*=\s*["']([^"']*?)["']/g;
15
+ result = result.replace(classNameAttributeRegex, (match, classNames) => {
16
+ const normalizedClasses = normalizeClassNames(classNames);
17
+ return match.replace(classNames, normalizedClasses);
18
+ });
19
+ const vueClassRegex = /(?::class|v-bind:class)\s*=\s*["']([^"']*?)["']/g;
20
+ result = result.replace(vueClassRegex, (match, classNames) => {
21
+ const normalizedClasses = normalizeClassNames(classNames);
22
+ return match.replace(classNames, normalizedClasses);
23
+ });
24
+ const angularClassRegex = /\[class\]\s*=\s*["']([^"']*?)["']/g;
25
+ result = result.replace(angularClassRegex, (match, classNames) => {
26
+ const normalizedClasses = normalizeClassNames(classNames);
27
+ return match.replace(classNames, normalizedClasses);
28
+ });
29
+ const templateLiteralRegex = /`([^`]*?)`/g;
30
+ result = result.replace(templateLiteralRegex, (match, content) => {
31
+ const processedContent = content.replace(/([a-z-]+\[[^\]]+\])/g, (classMatch) => {
32
+ return normalizeClassName(classMatch);
33
+ });
34
+ return "`" + processedContent + "`";
35
+ });
36
+ const jsxBraceStringRegex = /(className\s*=\s*\{)\s*["']([^"']*?)["']\s*(\})/g;
37
+ result = result.replace(jsxBraceStringRegex, (match, prefix, classNames, suffix) => {
38
+ const normalizedClasses = normalizeClassNames(classNames);
39
+ return prefix + '"' + normalizedClasses + '"' + suffix;
40
+ });
41
+ const classUtilRegex = /((?:clsx|classnames|cn)\s*\([^)]*?)["']([^"']*?)["']/g;
42
+ result = result.replace(classUtilRegex, (match, prefix, classNames) => {
43
+ const normalizedClasses = normalizeClassNames(classNames);
44
+ return prefix + '"' + normalizedClasses + '"';
45
+ });
46
+ const generalStringRegex = /(["'])([^"']*?)(\1)/g;
47
+ result = result.replace(generalStringRegex, (match, quote, content, endQuote) => {
48
+ if (content.includes("=") || content.length < 3) {
49
+ return match;
50
+ }
51
+ const hasArbitraryValues = /[a-z-]+\[[^\]]+\]/.test(content);
52
+ if (hasArbitraryValues) {
53
+ const normalizedContent = normalizeClassNames(content);
54
+ return quote + normalizedContent + endQuote;
55
+ }
56
+ return match;
57
+ });
58
+ return result;
59
+ }
60
+ function normalizeClassNames(classNames) {
61
+ const classes = classNames.split(/\s+/).filter(Boolean);
62
+ return classes.map((className) => normalizeClassName(className)).join(" ");
63
+ }
64
+ function normalizeClassName(className) {
65
+ const negativeArbitraryValueRegex = /^-([a-z:-]+)\[([^\]]+)\]$/;
66
+ const negativeArbitraryMatch = className.match(negativeArbitraryValueRegex);
67
+ if (negativeArbitraryMatch) {
68
+ const [, prefixWithDash, value] = negativeArbitraryMatch;
69
+ const prefix = prefixWithDash.replace(/-$/, "");
70
+ if (value === "0px" || value === "0") {
71
+ const mapping = findStandardMapping(prefix, value);
72
+ return mapping || className;
73
+ }
74
+ const negativeValue = `-${value}`;
75
+ const mapping = findStandardMapping(prefix, negativeValue);
76
+ return mapping || className;
77
+ }
78
+ const arbitraryValueRegex = /^([a-z:-]+)\[([^\]]+)\]$/;
79
+ const arbitraryMatch = className.match(arbitraryValueRegex);
80
+ if (arbitraryMatch) {
81
+ const [, prefixWithDash, value] = arbitraryMatch;
82
+ const prefix = prefixWithDash.replace(/-$/, "");
83
+ if (value.startsWith("-")) {
84
+ if (value === "-0px" || value === "-0") {
85
+ const positiveValue = value.substring(1);
86
+ const mapping = findStandardMapping(prefix, positiveValue);
87
+ return mapping || className;
88
+ }
89
+ const mapping = findStandardMapping(prefix, value);
90
+ return mapping || className;
91
+ }
92
+ const mapping = findStandardMapping(prefix, value);
93
+ return mapping || className;
94
+ }
95
+ const negativePxSuffixRegex = /^-([a-z:-]+)-(\d+)px$/;
96
+ const negativePxMatch = className.match(negativePxSuffixRegex);
97
+ if (negativePxMatch) {
98
+ const [, prefix, numValue] = negativePxMatch;
99
+ if (numValue === "0") {
100
+ const mapping = findStandardMapping(prefix, "0px");
101
+ return mapping || className;
102
+ }
103
+ const negativePixelValue = `-${numValue}px`;
104
+ const mapping = findStandardMapping(prefix, negativePixelValue);
105
+ return mapping || className;
106
+ }
107
+ const pxSuffixRegex = /^([a-z:-]+)-(\d+)px$/;
108
+ const pxMatch = className.match(pxSuffixRegex);
109
+ if (pxMatch) {
110
+ const [, prefix, numValue] = pxMatch;
111
+ const pixelValue = numValue + "px";
112
+ const mapping = findStandardMapping(prefix, pixelValue);
113
+ return mapping || className;
114
+ }
115
+ return className;
116
+ }
117
+ function findStandardMapping(prefix, value) {
118
+ const mappings = mappings_1.TAILWIND_MAPPINGS[prefix];
119
+ if (!mappings) {
120
+ return null;
121
+ }
122
+ return mappings[value] || null;
123
+ }
@@ -0,0 +1,20 @@
1
+ export interface CompatParser {
2
+ parse?: (text: string, options: any) => any;
3
+ preprocess?: (text: string, options: any) => string;
4
+ astFormat?: string;
5
+ locStart?: (node: any) => number;
6
+ locEnd?: (node: any) => number;
7
+ [key: string]: any;
8
+ }
9
+ export interface CompatPlugin {
10
+ languages?: Array<{
11
+ name: string;
12
+ parsers: string[];
13
+ extensions: string[];
14
+ }>;
15
+ parsers: Record<string, CompatParser>;
16
+ printers?: Record<string, any>;
17
+ options?: Record<string, any>;
18
+ }
19
+ export declare function isValidParser(parser: any): parser is CompatParser;
20
+ export declare function isValidPlugin(plugin: any): plugin is CompatPlugin;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidParser = isValidParser;
4
+ exports.isValidPlugin = isValidPlugin;
5
+ function isValidParser(parser) {
6
+ return parser && typeof parser === "object";
7
+ }
8
+ function isValidPlugin(plugin) {
9
+ return plugin && typeof plugin === "object" && plugin.parsers;
10
+ }