unocss-merge 0.0.1 → 0.1.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.
- package/dist/chunk-MBFPIAXN.js +6 -0
- package/dist/index.js +1 -8
- package/dist/react.js +1 -12
- package/package.json +1 -1
- package/dist/chunk-XPETEQCQ.js +0 -180
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{uniq as y}from"es-toolkit";var h=[[w(`
|
|
2
|
+
block,inline-block,inline,flex,inline-flex,flow-root,grid,inline-grid,contents,list-item,hidden
|
|
3
|
+
table,inline-table,table-caption,table-cell,table-column,table-row,
|
|
4
|
+
table-column-group,table-footer-group,table-header-group,table-row-group
|
|
5
|
+
`),"display"],[["isolate","isolation-auto"],"isolation"],[["static","fixed","absolute","relative","stick"],"position"],[["visible","invisible","collapse"],"visibility"],[["flex-row","flex-row-reverse","flex-col","flex-col-reverse"],"flex-direction"],[["flex-wrap","flex-wrap-reverse","flex-nowrap"],"flex-wrap"],[l("object-",["contain","cover","fill","none","scale-down"]),"object-fit"],[l("object-",["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"]),"object-position"],[["antialiased","subpixel-antialiased"],"font-smoothing"],[["italic","not-italic"],"font-style"],[l("font-",["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"]),"font-weight"],[["normal-nums","ordinal","slashed-zero","lining-nums","oldstyle-nums","proportional-nums","tabular-nums","diagonal-fractions","stacked-fractions"],"font-variant-numeric"],[["text-xs","text-sm","text-base","text-lg","text-xl",/^text-(size-)?\d+xl/,/^text-(size-)?\d+/,/^font-size-\d+/],"font-size"],[["list-inside","list-outside"],"list-style-position"],[["list-none","list-disc","list-decimal"],"list-style-type"],[l("text-",["left","center","right","justify","start","end"]),"text-align"],[["underline","overline","line-through","no-underline"],"text-decoration-line"],[l("decoration-",["solid","double","dotted","dashed","wavy"]),"text-decoration-style"],[["decoration-auto","decoration-from-font",/^decoration-\d+/],"text-decoration-thickness"],[["truncate","text-ellipsis","text-clip"],"text-overflow"],[["text-wrap","text-nowrap","text-balance","text-pretty"],"text-wrap"],[l("bg-",["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"]),"background-position"],[["bg-repeat","bg-no-repeat",/^bg-repeat-/],"background-repeat"],[["bg-auto","bg-cover","bg-contain"],"background-size"],[["bg-none",/^bg-gradient-to-/],"background-image"],[[/^(?:border-|b-)?(?:rounded|rd)()(?:-(.+))?$/],"rounded"],[/^b(?:order)?-(solid|dashed|dotted|double|hidden|none)$/,"border-style"],[/^b(?:order)?($|-\d+)/,"border-width"],[/^b(?:order)?-(t|b|l|r|x|y|s|e)($|-\d+)/,(t,e)=>`border-${e==null?void 0:e[1]}-width`],[/^outline-\d+/,"outline-width"],[["outline",/^outline-(solid|dashed|dotted|double|none)$/],"outline-style"],[/^divide-(solid|dashed|dotted|double|none)$/,"divide-style"],[/^divide-(x|y)($|-\d+)$/,(t,e)=>`divide-${e==null?void 0:e[1]}-width`],[["ring",/^ring-\d+/],"ring-width"],[[/^ring-offset-\d+/],"ring-offset-width"],[["shadow",...l("shadow",["sm","md","lg","xl","2xl","inner","none"])],"box-shadow"],[["border-collapse","border-separate"],"border-collapse"],[["table-auto","table-fixed"],"table-layout"],[["caption-top","caption-bottom"],"caption-side"],[["scroll-auto","scroll-smooth"],"scroll-behavior"],[["snap-start","snap-end","snap-center","snap-align-none"],"scroll-snap-align"],[["snap-normal","snap-always"],"scroll-snap-stop"],[["snap-none","snap-x","snap-y","snap-both","snap-mandatory","snap-proximity"],"scroll-snap-type"],[/^stroke-\d+/,"stroke-width"],[["sr-only","not-sr-only"],"Screen Readers"],[["grow","flex-grow"],"flex-grow"],[["shrink","flex-shrink"],"flex-shrink"],...["resize","ring-inset","divide-x-reverse","divide-y-reverse","blur","drop-shadow","grayscale","invert","sepia","backdrop-blur","backdrop-grayscale","backdrop-invert","backdrop-sepia"].map(t=>[t,t])],p=new Map,u=new Map;for(let[t,e]of h){let o=[t].flat(),r=o.filter(n=>typeof n=="string"),s=o.filter(n=>typeof n=="object"&&n instanceof RegExp);r.forEach(n=>{let a=typeof e=="string"?e:e(n);p.set(n,a)}),s.forEach(n=>{u.set(n,e)})}function x(t){if(p.has(t))return p.get(t);for(let[e,o]of u.entries())if(e.test(t)){let r=e.exec(t);return typeof o=="string"?o:o(t,r)}}var m=["break-after","break-before","break-inside","grid-flow","align","whitespace","mix-blend","bg-blend","ease","origin","cursor","touch","text","color","bg","b","border","decoration","from","divide","outline","ring","ring-offset","shadow","accent","caret","fill","stroke"],d=new Map(Object.entries({grow:"flex-grow",shrink:"flex-shrink",col:"grid-column","col-span":"grid-column","col-start":"grid-column-start","col-end":"grid-column-end",row:"grid-row","row-span":"grid-row","row-start":"grid-row-start","row-end":"grid-row-end",leading:"line-height"}));function w(t){return t.split(`
|
|
6
|
+
`).map(e=>e.trim()).filter(Boolean).map(e=>e.split(",").map(o=>o.trim()).filter(Boolean)).flat()}function l(t,e){return e.map(o=>t+o)}function k(t){return y((t||"").split(" ").map(e=>e.trim()).filter(Boolean))}function E(...t){let e=t.map(k).flat().filter(Boolean),o=new Map;for(let r of e){let s=x(r);if(s){if(typeof s=="string")o.set(s,r);else{let[i,g]=s;o.set(i,g)}continue}let n=m.find(i=>r.startsWith(i+"-"));if(n){let i=n;d.has(i)&&(i=d.get(i)),o.set(i,r);continue}let a=r,f=/(\[[\w_,-]+\])$/;f.test(r)&&(a=r.replace(f,function(i,g){return"*".repeat(g.length)})),a.includes("--")&&(a=a.replace(/--/g,"-*"));let b=a.lastIndexOf("-");if(b===-1){o.set(r,r);continue}let c=r.slice(0,b);d.has(c)&&(c=d.get(c)),o.set(c,r)}return Array.from(o.values()).join(" ")}export{k as a,E as b};
|
package/dist/index.js
CHANGED
package/dist/react.js
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
unoMerge
|
|
3
|
-
} from "./chunk-XPETEQCQ.js";
|
|
4
|
-
|
|
5
|
-
// src/react.ts
|
|
6
|
-
import { useMemo } from "react";
|
|
7
|
-
function useUnoMerge(...classNames) {
|
|
8
|
-
return useMemo(() => unoMerge(...classNames), [...classNames]);
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
useUnoMerge
|
|
12
|
-
};
|
|
1
|
+
import{b as e}from"./chunk-MBFPIAXN.js";import{useMemo as n}from"react";function i(...r){return n(()=>e(...r),[...r])}export{i as useUnoMerge};
|
package/package.json
CHANGED
package/dist/chunk-XPETEQCQ.js
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import { uniq } from "es-toolkit";
|
|
3
|
-
|
|
4
|
-
// src/config.ts
|
|
5
|
-
var singleValues = {
|
|
6
|
-
"display": toValues(`
|
|
7
|
-
block,inline-block,inline,flex,inline-flex,
|
|
8
|
-
table,inline-table,table-caption,table-cell,table-column,table-row,
|
|
9
|
-
table-column-group,table-footer-group,table-header-group,table-row-group,
|
|
10
|
-
flow-root,grid,inline-grid,contents,list-item,hidden
|
|
11
|
-
`),
|
|
12
|
-
"isolation": ["isolate", "isolation-auto"],
|
|
13
|
-
"position": ["static", "fixed", "absolute", "relative", "stick"],
|
|
14
|
-
"visibility": ["visible", "invisible", "collapse"],
|
|
15
|
-
"flex-direction": ["flex-row", "flex-row-reverse", "flex-col", "flex-col-reverse"],
|
|
16
|
-
"flex-wrap": ["flex-wrap", "flex-wrap-reverse", "flex-nowrap"],
|
|
17
|
-
"object-fit": [
|
|
18
|
-
"object-contain",
|
|
19
|
-
"object-cover",
|
|
20
|
-
"object-fill",
|
|
21
|
-
"object-none",
|
|
22
|
-
"object-scale-down"
|
|
23
|
-
],
|
|
24
|
-
"object-position": [
|
|
25
|
-
"object-bottom",
|
|
26
|
-
"object-center",
|
|
27
|
-
"object-left",
|
|
28
|
-
"object-left-bottom",
|
|
29
|
-
"object-left-top",
|
|
30
|
-
"object-right",
|
|
31
|
-
"object-right-bottom",
|
|
32
|
-
"object-right-top",
|
|
33
|
-
"object-top"
|
|
34
|
-
],
|
|
35
|
-
"font-smoothing": ["antialiased", "subpixel-antialiased"],
|
|
36
|
-
"font-style": ["italic", "not-italic"],
|
|
37
|
-
"font-weight": [
|
|
38
|
-
"font-thin",
|
|
39
|
-
"font-extralight",
|
|
40
|
-
"font-light",
|
|
41
|
-
"font-normal",
|
|
42
|
-
"font-medium",
|
|
43
|
-
"font-semibold",
|
|
44
|
-
"font-bold",
|
|
45
|
-
"font-extrabold",
|
|
46
|
-
"font-black"
|
|
47
|
-
],
|
|
48
|
-
"font-variant-numeric": [
|
|
49
|
-
"normal-nums",
|
|
50
|
-
"ordinal",
|
|
51
|
-
"slashed-zero",
|
|
52
|
-
"lining-nums",
|
|
53
|
-
"oldstyle-nums",
|
|
54
|
-
"proportional-nums",
|
|
55
|
-
"tabular-nums",
|
|
56
|
-
"diagonal-fractions",
|
|
57
|
-
"stacked-fractions"
|
|
58
|
-
],
|
|
59
|
-
// TODO:
|
|
60
|
-
"font-size": [
|
|
61
|
-
"text-xs",
|
|
62
|
-
"text-sm",
|
|
63
|
-
"text-base",
|
|
64
|
-
"text-lg",
|
|
65
|
-
"text-xl",
|
|
66
|
-
"text-2xl",
|
|
67
|
-
"text-3xl",
|
|
68
|
-
"text-4xl",
|
|
69
|
-
"text-5xl",
|
|
70
|
-
"text-6xl",
|
|
71
|
-
"text-7xl",
|
|
72
|
-
"text-8xl",
|
|
73
|
-
"text-9xl"
|
|
74
|
-
],
|
|
75
|
-
"list-style-position": ["list-inside", "list-outside"],
|
|
76
|
-
"list-style-type": ["list-none", "list-disc", "list-decimal"],
|
|
77
|
-
"text-align": [
|
|
78
|
-
"text-left",
|
|
79
|
-
"text-center",
|
|
80
|
-
"text-right",
|
|
81
|
-
"text-justify",
|
|
82
|
-
"text-start",
|
|
83
|
-
"text-end"
|
|
84
|
-
]
|
|
85
|
-
};
|
|
86
|
-
var specialValues = {
|
|
87
|
-
"grow": { key: "flex-grow", value: "1" },
|
|
88
|
-
"shrink": { key: "flex-shrink", value: "1" },
|
|
89
|
-
"flex-grow": { key: "flex-grow", value: "1" },
|
|
90
|
-
"flex-shrink": { key: "flex-shrink", value: "1" }
|
|
91
|
-
};
|
|
92
|
-
var classNameMap = /* @__PURE__ */ new Map();
|
|
93
|
-
for (const [prop, values] of Object.entries(singleValues)) {
|
|
94
|
-
for (const cls of values) {
|
|
95
|
-
classNameMap.set(cls, { key: prop, value: cls });
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
for (const [cls, config] of Object.entries(specialValues)) {
|
|
99
|
-
classNameMap.set(cls, config);
|
|
100
|
-
}
|
|
101
|
-
var knownPrefixHasDashValue = [
|
|
102
|
-
"break-after",
|
|
103
|
-
// break-after-avoid-page
|
|
104
|
-
"break-before",
|
|
105
|
-
"break-inside",
|
|
106
|
-
// grid
|
|
107
|
-
"grid-flow"
|
|
108
|
-
// grid-flow-row-dense
|
|
109
|
-
];
|
|
110
|
-
var ShortcutMap = new Map(
|
|
111
|
-
Object.entries({
|
|
112
|
-
"grow": "flex-grow",
|
|
113
|
-
"shrink": "flex-shrink",
|
|
114
|
-
"col": "grid-column",
|
|
115
|
-
// `col-auto` => `grid-column: auto;`
|
|
116
|
-
"col-span": "grid-column",
|
|
117
|
-
"col-start": "grid-column-start",
|
|
118
|
-
"col-end": "grid-column-end",
|
|
119
|
-
"row": "grid-row",
|
|
120
|
-
// `row-auto` => `grid-row: auto;`
|
|
121
|
-
"row-span": "grid-row",
|
|
122
|
-
"row-start": "grid-row-start",
|
|
123
|
-
"row-end": "grid-row-end",
|
|
124
|
-
"leading": "line-height"
|
|
125
|
-
})
|
|
126
|
-
);
|
|
127
|
-
function toValues(str) {
|
|
128
|
-
return str.split("\n").map((line) => line.trim()).filter(Boolean).map(
|
|
129
|
-
(line) => line.split(",").map((x) => x.trim()).filter(Boolean)
|
|
130
|
-
).flat();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// src/index.ts
|
|
134
|
-
function getClassList(className) {
|
|
135
|
-
return uniq(
|
|
136
|
-
(className || "").split(" ").map((x) => x.trim()).filter(Boolean)
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
function unoMerge(...classNames) {
|
|
140
|
-
const classList = classNames.map(getClassList).flat().filter(Boolean);
|
|
141
|
-
const map = /* @__PURE__ */ new Map();
|
|
142
|
-
for (const cls of classList) {
|
|
143
|
-
if (classNameMap.has(cls)) {
|
|
144
|
-
const { key: key2, value } = classNameMap.get(cls);
|
|
145
|
-
map.set(key2, value);
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
const prefix = knownPrefixHasDashValue.find((prefix2) => cls.startsWith(prefix2 + "-"));
|
|
149
|
-
if (prefix) {
|
|
150
|
-
map.set(prefix, cls);
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
let clsForSearing = cls;
|
|
154
|
-
const reg = /(\[[\w_,-]+\])$/;
|
|
155
|
-
if (reg.test(cls)) {
|
|
156
|
-
clsForSearing = cls.replace(reg, function(match, p1) {
|
|
157
|
-
return "*".repeat(p1.length);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
if (clsForSearing.includes("--")) {
|
|
161
|
-
clsForSearing = clsForSearing.replace(/--/g, "-*");
|
|
162
|
-
}
|
|
163
|
-
const lastHyphenIndex = clsForSearing.lastIndexOf("-");
|
|
164
|
-
if (lastHyphenIndex === -1) {
|
|
165
|
-
map.set(cls, cls);
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
let key = cls.slice(0, lastHyphenIndex);
|
|
169
|
-
if (ShortcutMap.has(key)) {
|
|
170
|
-
key = ShortcutMap.get(key);
|
|
171
|
-
}
|
|
172
|
-
map.set(key, cls);
|
|
173
|
-
}
|
|
174
|
-
return Array.from(map.values()).join(" ");
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export {
|
|
178
|
-
getClassList,
|
|
179
|
-
unoMerge
|
|
180
|
-
};
|