unocss-merge 0.7.3 → 0.8.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/README.md CHANGED
@@ -97,6 +97,8 @@ expect(unoMergeMemoized('cursor-pointer', 'cursor-not-allowed')).toBe('cursor-no
97
97
  - ✅ negative value `mr--4px`
98
98
  - ✅ simple colon separated variants `hover:mr-4px` `dark:ml-4px` `hover:dark:ml-4px`
99
99
  - ✅ simple shorthand: supports `margin` & `padding`, like `m-1` `mx-1` `ml-1` `mr-1`
100
+ - ✅ `mx-2` overwrite `ml-1` & `mr-1`
101
+ - ✅ `m-2` overwrite `mx-1` & `mr-1`
100
102
  - ✅ merge multiple important utilities
101
103
  ```ts
102
104
  expect(unoMerge('mr-4px mr-2px!')).toBe('mr-4px mr-2px!')
@@ -112,6 +114,12 @@ expect(unoMergeMemoized('cursor-pointer', 'cursor-not-allowed')).toBe('cursor-no
112
114
  - ❌ [Shortcuts](https://unocss.dev/config/shortcuts) are not recongized
113
115
  - ❌ complex shorthand: I don't recall any example in my mind
114
116
 
117
+ ## unocss `Too Flexible`
118
+
119
+ - All valid for unocss presetWind3: `m-r-1` / `m-r1` / `mr-1` / `mr1`
120
+ - [Tailwindcss v3 documentation](https://v3.tailwindcss.com/docs/installation) using `mr-1`, unocss has no document pages.
121
+ - So only `mr-1` is supported
122
+
115
123
  ## Changelog
116
124
 
117
125
  See https://github.com/magicdawn/unocss-merge/releases
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{n as e,t}from"./src-DIbbySoB.js";export{t as getClassList,e as unoMerge};
1
+ import{n as e,t}from"./src-HowVAvb4.js";export{t as getClassList,e as unoMerge};
package/dist/memoize.js CHANGED
@@ -1 +1 @@
1
- import{n as e}from"./src-DIbbySoB.js";import t,{memoizeClear as n}from"memoize";function r(r){let i=t(e,{cacheKey:e=>e.flat(5).map(e=>e?.toString()).filter(Boolean).join(`,`),...r});return Object.defineProperty(i,`clear`,{value:()=>{n(i)}}),i}const i=r();export{r as createUnoMergeMemoized,i as unoMergeMemoized};
1
+ import{n as e}from"./src-HowVAvb4.js";import t,{memoizeClear as n}from"memoize";function r(r){let i=t(e,{cacheKey:e=>e.flat(5).map(e=>e?.toString()).filter(Boolean).join(`,`),...r});return Object.defineProperty(i,`clear`,{value:()=>{n(i)}}),i}const i=r();export{r as createUnoMergeMemoized,i as unoMergeMemoized};
package/dist/react.js CHANGED
@@ -1 +1 @@
1
- import{n as e}from"./src-DIbbySoB.js";import{clsx as t}from"clsx";import{useMemo as n}from"react";function r(...r){let i=n(()=>t(...r),[...r]);return n(()=>e(i),[i])}export{r as useUnoMerge};
1
+ import{n as e}from"./src-HowVAvb4.js";import{clsx as t}from"clsx";import{useMemo as n}from"react";function r(...r){let i=n(()=>t(...r),[...r]);return n(()=>e(i),[i])}export{r as useUnoMerge};
@@ -0,0 +1 @@
1
+ import{clsx as e}from"clsx";function t(e){return[...new Set(e)]}function n(e,t){if(!e)throw typeof t==`string`?Error(t):t}const r=String.raw,i=(e,...t)=>new RegExp(r(e,...t)),a=r`(\d+(\.\d+)?)?(xs|sm|md|lg|xl)`,o=`(solid|dashed|dotted|double|none|hidden)`;function s(e,t){return n(e.endsWith(`-`),"prefix must end with `-`"),t.map(t=>e+t)}const c=[[[...[`block`,`flex`,`grid`,`table`].flatMap(e=>[e,`inline-${e}`]),`inline`,`flow-root`,`contents`,`list-item`,`hidden`,...s(`table-`,[`row`,`column`,`cell`,`caption`,`row-group`,`column-group`,`header-group`,`footer-group`])],`display`],[[`isolate`,`isolation-auto`],`isolation`],[[`static`,`fixed`,`absolute`,`relative`,`sticky`],`position`],[[`visible`,`invisible`,`collapse`],`visibility`],[s(`flex-`,[`row`,`row-reverse`,`col`,`col-reverse`]),`flex-direction`],[s(`flex-`,[`wrap`,`wrap-reverse`,`nowrap`]),`flex-wrap`],[s(`object-`,[`contain`,`cover`,`fill`,`none`,`scale-down`]),`object-fit`],[s(`object-`,[`bottom`,`center`,`left`,`left-bottom`,`left-top`,`right`,`right-bottom`,`right-top`,`top`]),`object-position`],[[`antialiased`,`subpixel-antialiased`],`font-smoothing`],[[`italic`,`not-italic`,`oblique`,`not-oblique`],`font-style`],[s(`font-`,[`mono`,`sans`,`serif`]),`font-family`],[/^(?:font|fw)-?(thin|extralight|light|normal|medium|semibold|bold|extrabold|black|\d+)$/,`font-weight`],[[`normal-nums`,`ordinal`,`slashed-zero`,`lining-nums`,`oldstyle-nums`,`proportional-nums`,`tabular-nums`,`diagonal-fractions`,`stacked-fractions`],`font-variant-numeric`],[i`^(text|text-size|font-size)-(\d+|${a}$)`,`font-size`],[/^(leading|line-height)-/,`line-height`],[s(`list-`,[`inside`,`outside`]),`list-style-position`],[s(`list-`,[`none`,`disc`,`decimal`]),`list-style-type`],[s(`text-`,[`left`,`center`,`right`,`justify`,`start`,`end`]),`text-align`],[[`underline`,`overline`,`line-through`,`no-underline`],`text-decoration-line`],[s(`decoration-`,[`solid`,`double`,`dotted`,`dashed`,`wavy`]),`text-decoration-style`],[/^decoration-(\d+|(auto|from-font)$)/,`text-decoration-thickness`],[[`truncate`,`text-ellipsis`,`text-clip`],`text-overflow`],[s(`text-`,[`wrap`,`nowrap`,`balance`,`pretty`]),`text-wrap`],[s(`bg-`,[`bottom`,`center`,`left`,`left-bottom`,`left-top`,`right`,`right-bottom`,`right-top`,`top`]),`background-position`],[/^bg(-no)?-repeat($|-)/,`background-repeat`],[s(`bg-`,[`auto`,`cover`,`contain`]),`background-size`],[[`bg-none`,/^bg-gradient-to-/],`background-image`],[/^(?:border-|b-)?(?:rounded|rd)(?:-(.+))?$/,`rounded`],[i`^b(?:order)?-${o}$`,`border-style`],[i`^b(?:order)?-([tblrxyse])-${o}$`,(e,t)=>`border-${t?.[1]}-style`],[/^b(?:order)?($|-\d+)/,`border-width`],[/^b(?:order)?-([tblrxyse])($|-\d+)/,(e,t)=>`border-${t?.[1]}-width`],[/^(?:border|b)-(?:color-)?(.+)$/,`border-color`],[/^(?:border|b)-([rltbse])-(?:color-)?(.+)$/,(e,t)=>`border-${t?.[1]}-color`],[/^outline-\d+/,`outline-width`],[[`outline`,i`^outline-${o}$`],`outline-style`],[i`^divide-${o}$`,`divide-style`],[/^divide-(x|y)($|-\d+)/,(e,t)=>`divide-${t?.[1]}-width`],[[`ring`,/^ring-\d+/],`ring-width`],[[/^ring-offset-\d+/],`ring-offset-width`],[[`shadow`,...s(`shadow-`,[`inner`,`none`]),i`^shadow-${a}$`],`box-shadow`],[s(`border-`,[`collapse`,`separate`]),`border-collapse`],[s(`table-`,[`auto`,`fixed`]),`table-layout`],[s(`caption-`,[`top`,`bottom`]),`caption-side`],[s(`scroll-`,[`auto`,`smooth`]),`scroll-behavior`],[s(`snap-`,[`start`,`end`,`center`,`align-none`]),`scroll-snap-align`],[s(`snap-`,[`normal`,`always`]),`scroll-snap-stop`],[s(`snap-`,[`none`,`x`,`y`,`both`,`mandatory`,`proximity`]),`scroll-snap-type`],[/^stroke-\d+/,`stroke-width`],[[`sr-only`,`not-sr-only`],`Screen-Readers`],[/^(flex-)?grow($|-\d+$)/,`flex-grow`],[/^(flex-)?shrink($|-\d+$)/,`flex-shrink`],[/^(flex-)?basis-(.+)$/,`flex-basis`],[/^flex-(initial|auto|none|\d+)$/,`flex`],[/^col-start-/,`grid-column-start`],[/^col-end-/,`grid-column-end`],[[/^col-/,/^col-span-/],`grid-column`],[/^row-start-/,`grid-row-start`],[/^row-end-/,`grid-row-end`],[[/^row-/,/^row-span-/],`grid-row`],[`transition-none`,`transition-none`],[/^transition-delay-(.+)$/,`transition-delay`],[/^transition-ease(?:-(.+))?$/,`transition-timing-function`],[/^transition(-duration)?-\d+(m?s)?$/,`transition-duration`],[/^transition-(all$|\w+)/,`transition-property`],...[`ring-inset`,`divide-x-reverse`,`divide-y-reverse`].map(e=>[e,e]),...[`resize`,`blur`,`drop-shadow`,`grayscale`,`invert`,`sepia`,`backdrop-blur`,`backdrop-grayscale`,`backdrop-invert`,`backdrop-sepia`].map(e=>[i`^${e}($|-)`,e])],l=new Map,u=new Map;for(let[e,t]of c){let n=[e].flat(),r=n.filter(e=>typeof e==`string`),i=n.filter(e=>typeof e==`object`&&e instanceof RegExp);r.forEach(e=>{let n=typeof t==`string`?t:t(e);l.set(e,n)}),i.forEach(e=>{u.set(e,t)})}function d(e){if(l.has(e))return l.get(e);for(let[t,n]of u.entries())if(t.test(e)){let r=t.exec(e);return typeof n==`string`?n:n(e,r)}}function f(e){return p.map(e=>typeof e==`string`?[e,e]:e).find(([t,n])=>e.startsWith(`${t}-`))}const p=[`break-after`,`break-before`,`break-inside`,`grid-flow`,`align`,`whitespace`,`mix-blend`,`bg-blend`,`ease`,`origin`,`cursor`,`touch`,`color`,[`text`,`color`],[`c`,`color`],[`bg`,`background-color`],[`decoration`,`text-decoration-color`],[`from`,`gradient-color-stops`],[`divide`,`divide-color`],[`outline`,`outline-color`],[`ring`,`ring-color`],[`ring-offset`,`ring-offset-color`],[`shadow`,`box-shadow-color`],[`accent`,`accent-color`],[`caret`,`caret-color`],`fill`,`stroke`],m=new Map(Object.entries({flex:[`flex-grow`,`flex-shrink`,`flex-basis`],"transiton-none":[`transition-duration`,`transition-delay`,`transition-timing-function`,`transition-property`],m:[`mt`,`mb`,`ml`,`mr`,`mx`,`my`],mx:[`ml`,`mr`],my:[`mt`,`mb`],p:[`pt`,`pb`,`pl`,`pr`,`px`,`py`],px:[`pl`,`pr`],py:[`pt`,`pb`]}));function h(e){return(e||``).split(` `).map(e=>e.trim()).filter(Boolean)}function g(...n){let r=new Map;return h(e(...n)).filter(Boolean).forEach(e=>_(e,r)),t(Array.from(r.values())).join(` `)}function _(e,t){let n=e,r;function i(e){[e].flat().forEach(e=>{m.has(e)&&[m.get(e)].flat().filter(e=>e!==void 0).forEach(e=>{t.delete(r?r+e:e)}),t.set(r?r+e:e,n)})}function a(){let t=d(e);if(t)return i(t),!0}function o(){let t=f(e);if(!t)return;let[n,r]=t;return i(r),!0}function s(){let t=e,n=/(\[[\w,()/-]+\])$/;n.test(e)&&(t=e.replace(n,function(e,t){return`*`.repeat(t.length)})),t=t.replaceAll(/--(?=\d)/g,`-*`);let r=t.lastIndexOf(`-`);if(r!==-1)return i(e.slice(0,r)),!0}function c(){return i(e)}function l(){let t=/^(?:(?:[\w-]+|\[[^\s[\]]+\]):)+/.exec(e);t&&(r=t[0].split(/(?<=:)(?:\b|$)/).filter(Boolean).sort().join(``),e=e.slice(r.length))}function u(){if(e.startsWith(`!`)){e=`important:`+e.slice(1);return}if(e.endsWith(`!`)){e=`important:`+e.slice(0,-1);return}}a()||o()||(u(),l(),a()||o()||s()||c())}export{g as n,h as t};
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "unocss-merge",
3
3
  "type": "module",
4
- "version": "0.7.3",
5
- "packageManager": "pnpm@10.26.1+sha512.664074abc367d2c9324fdc18037097ce0a8f126034160f709928e9e9f95d98714347044e5c3164d65bd5da6c59c6be362b107546292a8eecb7999196e5ce58fa",
4
+ "version": "0.8.0",
5
+ "packageManager": "pnpm@10.27.0+sha512.72d699da16b1179c14ba9e64dc71c9a40988cbdc65c264cb0e489db7de917f20dcf4d64d8723625f2969ba52d4b7e2a1170682d9ac2a5dcaeaab732b7e16f04a",
6
6
  "description": "simple utility to merge unocss class names",
7
7
  "author": "magicdawn",
8
8
  "license": "MIT",
@@ -68,7 +68,7 @@
68
68
  "clsx": "^2.1.1"
69
69
  },
70
70
  "devDependencies": {
71
- "@magicdawn/eslint-config": "^1.5.14",
71
+ "@magicdawn/eslint-config": "^1.6.1",
72
72
  "@magicdawn/prettier-config": "^0.1.0",
73
73
  "@types/react": "^19.2.7",
74
74
  "@vitest/coverage-v8": "^4.0.16",
@@ -77,7 +77,7 @@
77
77
  "husky": "^9.1.7",
78
78
  "lint-staged": "^16.2.7",
79
79
  "prettier": "^3.7.4",
80
- "tsdown": "^0.18.2",
80
+ "tsdown": "^0.18.4",
81
81
  "typescript": "^5.9.3",
82
82
  "vitest": "^4.0.16"
83
83
  },
@@ -1 +0,0 @@
1
- import{clsx as e}from"clsx";function t(e){return[...new Set(e)]}function n(e,t){if(!e)throw typeof t==`string`?Error(t):t}const r=String.raw,i=(e,...t)=>new RegExp(r(e,...t)),a=r`(\d+(\.\d+)?)?(xs|sm|md|lg|xl)`,o=`(solid|dashed|dotted|double|none|hidden)`,s=[[[...[`block`,`flex`,`grid`,`table`].flatMap(e=>[e,`inline-${e}`]),`inline`,`flow-root`,`contents`,`list-item`,`hidden`,...h(`table-`,[`row`,`column`,`cell`,`caption`,`row-group`,`column-group`,`header-group`,`footer-group`])],`display`],[[`isolate`,`isolation-auto`],`isolation`],[[`static`,`fixed`,`absolute`,`relative`,`sticky`],`position`],[[`visible`,`invisible`,`collapse`],`visibility`],[h(`flex-`,[`row`,`row-reverse`,`col`,`col-reverse`]),`flex-direction`],[h(`flex-`,[`wrap`,`wrap-reverse`,`nowrap`]),`flex-wrap`],[h(`object-`,[`contain`,`cover`,`fill`,`none`,`scale-down`]),`object-fit`],[h(`object-`,[`bottom`,`center`,`left`,`left-bottom`,`left-top`,`right`,`right-bottom`,`right-top`,`top`]),`object-position`],[[`antialiased`,`subpixel-antialiased`],`font-smoothing`],[[`italic`,`not-italic`,`oblique`,`not-oblique`],`font-style`],[h(`font-`,[`mono`,`sans`,`serif`]),`font-family`],[/^(?:font|fw)-?(thin|extralight|light|normal|medium|semibold|bold|extrabold|black|\d+)$/,`font-weight`],[[`normal-nums`,`ordinal`,`slashed-zero`,`lining-nums`,`oldstyle-nums`,`proportional-nums`,`tabular-nums`,`diagonal-fractions`,`stacked-fractions`],`font-variant-numeric`],[i`^(text|text-size|font-size)-(\d+|${a}$)`,`font-size`],[h(`list-`,[`inside`,`outside`]),`list-style-position`],[h(`list-`,[`none`,`disc`,`decimal`]),`list-style-type`],[h(`text-`,[`left`,`center`,`right`,`justify`,`start`,`end`]),`text-align`],[[`underline`,`overline`,`line-through`,`no-underline`],`text-decoration-line`],[h(`decoration-`,[`solid`,`double`,`dotted`,`dashed`,`wavy`]),`text-decoration-style`],[/^decoration-(\d+|(auto|from-font)$)/,`text-decoration-thickness`],[[`truncate`,`text-ellipsis`,`text-clip`],`text-overflow`],[h(`text-`,[`wrap`,`nowrap`,`balance`,`pretty`]),`text-wrap`],[h(`bg-`,[`bottom`,`center`,`left`,`left-bottom`,`left-top`,`right`,`right-bottom`,`right-top`,`top`]),`background-position`],[/^bg(-no)?-repeat($|-)/,`background-repeat`],[h(`bg-`,[`auto`,`cover`,`contain`]),`background-size`],[[`bg-none`,/^bg-gradient-to-/],`background-image`],[/^(?:border-|b-)?(?:rounded|rd)(?:-(.+))?$/,`rounded`],[i`^b(?:order)?-${o}$`,`border-style`],[i`^b(?:order)?-([tblrxyse])-${o}$`,(e,t)=>`border-${t?.[1]}-style`],[/^b(?:order)?($|-\d+)/,`border-width`],[/^b(?:order)?-([tblrxyse])($|-\d+)/,(e,t)=>`border-${t?.[1]}-width`],[/^(?:border|b)-(?:color-)?(.+)$/,`border-color`],[/^(?:border|b)-([rltbse])-(?:color-)?(.+)$/,(e,t)=>`border-${t?.[1]}-color`],[/^outline-\d+/,`outline-width`],[[`outline`,i`^outline-${o}$`],`outline-style`],[i`^divide-${o}$`,`divide-style`],[/^divide-(x|y)($|-\d+)/,(e,t)=>`divide-${t?.[1]}-width`],[[`ring`,/^ring-\d+/],`ring-width`],[[/^ring-offset-\d+/],`ring-offset-width`],[[`shadow`,...h(`shadow-`,[`inner`,`none`]),i`^shadow-${a}$`],`box-shadow`],[h(`border-`,[`collapse`,`separate`]),`border-collapse`],[h(`table-`,[`auto`,`fixed`]),`table-layout`],[h(`caption-`,[`top`,`bottom`]),`caption-side`],[h(`scroll-`,[`auto`,`smooth`]),`scroll-behavior`],[h(`snap-`,[`start`,`end`,`center`,`align-none`]),`scroll-snap-align`],[h(`snap-`,[`normal`,`always`]),`scroll-snap-stop`],[h(`snap-`,[`none`,`x`,`y`,`both`,`mandatory`,`proximity`]),`scroll-snap-type`],[/^stroke-\d+/,`stroke-width`],[[`sr-only`,`not-sr-only`],`Screen-Readers`],[/^(flex-)?grow($|-\d+$)/,`flex-grow`],[/^(flex-)?shrink($|-\d+$)/,`flex-shrink`],...[`ring-inset`,`divide-x-reverse`,`divide-y-reverse`].map(e=>[e,e]),...[`resize`,`blur`,`drop-shadow`,`grayscale`,`invert`,`sepia`,`backdrop-blur`,`backdrop-grayscale`,`backdrop-invert`,`backdrop-sepia`].map(e=>[i`^${e}($|-)`,e])],c=new Map,l=new Map;for(let[e,t]of s){let n=[e].flat(),r=n.filter(e=>typeof e==`string`),i=n.filter(e=>typeof e==`object`&&e instanceof RegExp);r.forEach(e=>{let n=typeof t==`string`?t:t(e);c.set(e,n)}),i.forEach(e=>{l.set(e,t)})}function u(e){if(c.has(e))return c.get(e);for(let[t,n]of l.entries())if(t.test(e)){let r=t.exec(e);return typeof n==`string`?n:n(e,r)}}function d(e){return f.map(e=>typeof e==`string`?[e,e]:e).find(([t,n])=>e.startsWith(`${t}-`))}const f=[`break-after`,`break-before`,`break-inside`,`grid-flow`,`align`,`whitespace`,`mix-blend`,`bg-blend`,`ease`,`origin`,`cursor`,`touch`,`color`,[`text`,`color`],[`c`,`color`],[`bg`,`background-color`],[`decoration`,`text-decoration-color`],[`from`,`gradient-color-stops`],[`divide`,`divide-color`],[`outline`,`outline-color`],[`ring`,`ring-color`],[`ring-offset`,`ring-offset-color`],[`shadow`,`box-shadow-color`],[`accent`,`accent-color`],[`caret`,`caret-color`],`fill`,`stroke`];function p(e){return m.has(e)?m.get(e):e}const m=new Map(Object.entries({leading:`line-height`,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`,m:[`mt`,`mb`,`ml`,`mr`],mx:[`ml`,`mr`],my:[`mt`,`mb`],p:[`pt`,`pb`,`pl`,`pr`],px:[`pl`,`pr`],py:[`pt`,`pb`]}));function h(e,t){return n(e.endsWith(`-`),"prefix must end with `-`"),t.map(t=>e+t)}function g(e){return(e||``).split(` `).map(e=>e.trim()).filter(Boolean)}function _(...n){let r=new Map;return g(e(...n)).filter(Boolean).forEach(e=>v(e,r)),t(Array.from(r.values())).join(` `)}function v(e,t){let n=e,r;function i(e){[e].flat().forEach(e=>{t.set(r?r+e:e,n)})}function a(){let t=u(e);if(t)return i(t),!0}function o(){let t=d(e);if(!t)return;let[n,r]=t;return i(p(r)),!0}function s(){let t=e,n=/(\[[\w,()/-]+\])$/;n.test(e)&&(t=e.replace(n,function(e,t){return`*`.repeat(t.length)})),t=t.replaceAll(/--(?=\d)/g,`-*`);let r=t.lastIndexOf(`-`);if(r!==-1)return i(p(e.slice(0,r))),!0}function c(){return i(p(e))}function l(){let t=/^(?:(?:[\w-]+|\[[^\s[\]]+\]):)+/.exec(e);t&&(r=t[0].split(/(?<=:)(?:\b|$)/).filter(Boolean).sort().join(``),e=e.slice(r.length))}function f(){if(e.startsWith(`!`)){e=`important:`+e.slice(1);return}if(e.endsWith(`!`)){e=`important:`+e.slice(0,-1);return}}a()||o()||(f(),l(),a()||o()||s()||c())}export{_ as n,g as t};