@idlapps/t 0.1.1 → 0.1.2

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
@@ -1,6 +1,6 @@
1
1
  # @idlapps/t
2
2
 
3
- Lightweight, tree-shakable string utility functions.
3
+ Parse HTML strings into DOM elements with shorthand CSS utilities.
4
4
 
5
5
  ## Install
6
6
 
@@ -8,48 +8,249 @@ Lightweight, tree-shakable string utility functions.
8
8
  npm install @idlapps/t
9
9
  # or
10
10
  pnpm add @idlapps/t
11
- # or
12
- yarn add @idlapps/t
13
11
  ```
14
12
 
15
13
  ## Usage
16
14
 
17
15
  ```ts
18
- import { camelCase, truncate } from "@idlapps/t";
16
+ import { t } from "@idlapps/t";
19
17
 
20
- camelCase("hello-world"); // "helloWorld"
21
- truncate("Hello, World!", 5); // "Hello..."
18
+ const { el, refs } = t("<div p10 bgred ref=box>Hello</div>");
19
+ document.body.appendChild(el);
20
+ refs.box.style.color; // apply additional JS to refs
22
21
  ```
23
22
 
24
- ## Functions
23
+ ## How it works
25
24
 
26
- ### `camelCase(str: string): string`
25
+ `t()` parses an HTML string, extracts `ref` attributes as refs, converts shorthand CSS attribute names into inline styles, and returns the DOM fragment.
27
26
 
28
- Converts a string to camelCase.
27
+ ## Shorthand CSS
29
28
 
30
- ```ts
31
- camelCase("hello-world"); // "helloWorld"
32
- camelCase("foo_bar_baz"); // "fooBarBaz"
33
- camelCase("Hello World"); // "helloWorld"
29
+ ### Margin
30
+
31
+ | Shorthand | CSS |
32
+ | --------- | ------------------------------------ |
33
+ | `m10` | `margin:10px` |
34
+ | `m-15` | `margin:-15px` |
35
+ | `ml10` | `margin-left:10px` |
36
+ | `mr10` | `margin-right:10px` |
37
+ | `mt10` | `margin-top:10px` |
38
+ | `mb10` | `margin-bottom:10px` |
39
+ | `mx10` | `margin-left:10px;margin-right:10px` |
40
+ | `my10` | `margin-top:10px;margin-bottom:10px` |
41
+ | `mx20p` | `margin-left:20%;margin-right:20%` |
42
+
43
+ ### Padding
44
+
45
+ | Shorthand | CSS |
46
+ | --------- | -------------------------------------- |
47
+ | `p10` | `padding:10px` |
48
+ | `pl10` | `padding-left:10px` |
49
+ | `pr10` | `padding-right:10px` |
50
+ | `pt10` | `padding-top:10px` |
51
+ | `pb10` | `padding-bottom:10px` |
52
+ | `px10` | `padding-left:10px;padding-right:10px` |
53
+ | `py10` | `padding-top:10px;padding-bottom:10px` |
54
+
55
+ ### Width / Height
56
+
57
+ | Shorthand | CSS |
58
+ | --------- | ------------------ |
59
+ | `w100` | `width:100px` |
60
+ | `h100` | `height:100px` |
61
+ | `w50p` | `width:50%` |
62
+ | `w-50p` | `width:-50%` |
63
+ | `minw100` | `min-width:100px` |
64
+ | `maxw200` | `max-width:200px` |
65
+ | `minh100` | `min-height:100px` |
66
+ | `maxh200` | `max-height:200px` |
67
+
68
+ ### Colors
69
+
70
+ | Shorthand | CSS |
71
+ | --------- | ----------------------- |
72
+ | `bgred` | `background-color:red` |
73
+ | `bgteal` | `background-color:teal` |
74
+ | `clwhite` | `color:white` |
75
+ | `clblack` | `color:black` |
76
+
77
+ ### Typography
78
+
79
+ | Shorthand | CSS |
80
+ | ---------- | -------------------- |
81
+ | `fs14` | `font-size:14px` |
82
+ | `fwbold` | `font-weight:bold` |
83
+ | `lh15` | `line-height:15px` |
84
+ | `ls1` | `letter-spacing:1px` |
85
+ | `tacenter` | `text-align:center` |
86
+
87
+ ### Position
88
+
89
+ | Shorthand | CSS |
90
+ | ---------------- | ------------------- |
91
+ | `a` / `absolute` | `position:absolute` |
92
+ | `r` / `relative` | `position:relative` |
93
+ | `f` / `fixed` | `position:fixed` |
94
+ | `sticky` | `position:sticky` |
95
+ | `l20` | `left:20px` |
96
+ | `l-20` | `left:-20px` |
97
+ | `r20` | `right:20px` |
98
+ | `t20` | `top:20px` |
99
+ | `l5p` | `left:5%` |
100
+
101
+ ### Flex
102
+
103
+ | Shorthand | CSS |
104
+ | --------------- | -------------------------------------------------------- |
105
+ | `flex` | `display:flex` |
106
+ | `c` | `display:flex;justify-content:center;align-items:center` |
107
+ | `h` | `display:flex;flex-direction:row` |
108
+ | `v` | `display:flex;flex-direction:column` |
109
+ | `gap10` | `gap:10px` |
110
+ | `justifycenter` | `justify-content:center` |
111
+ | `itemscenter` | `align-items:center` |
112
+
113
+ ### Text Align
114
+
115
+ | Shorthand | CSS |
116
+ | --------- | ------------------- |
117
+ | `tac` | `text-align:center` |
118
+ | `tar` | `text-align:right` |
119
+ | `tal` | `text-align:left` |
120
+
121
+ ### Border
122
+
123
+ | Shorthand | CSS |
124
+ | ---------- | ------------------- |
125
+ | `b` | `border` |
126
+ | `b1` | `border:1px` |
127
+ | `bt1` | `border-top:1px` |
128
+ | `br1` | `border-right:1px` |
129
+ | `bb1` | `border-bottom:1px` |
130
+ | `bl1` | `border-left:1px` |
131
+ | `rounded8` | `border-radius:8px` |
132
+ | `shadowsm` | `box-shadow:sm` |
133
+
134
+ ### Other
135
+
136
+ | Shorthand | CSS |
137
+ | ---------------- | ------------------ |
138
+ | `z10` | `z-index:10` |
139
+ | `overflowhidden` | `overflow:hidden` |
140
+ | `tn500` | `transition:500ms` |
141
+
142
+ ### Transform
143
+
144
+ | Shorthand | CSS |
145
+ | --------- | ----------------------------- |
146
+ | `tx10` | `transform:translateX(10px)` |
147
+ | `ty20` | `transform:translateY(20px)` |
148
+ | `tx50p` | `transform:translateX(50%)` |
149
+ | `tx-50p` | `transform:translateX(-50%)` |
150
+ | `ty-20` | `transform:translateY(-20px)` |
151
+
152
+ ### Negative values
153
+
154
+ Prefix any numeric value with `-`:
155
+
156
+ ```
157
+ m-15 → margin:-15px
158
+ ml-10 → margin-left:-10px
159
+ tx-50p → transform:translateX(-50%)
34
160
  ```
35
161
 
36
- ### `truncate(str: string, maxLength: number, suffix?: string): string`
162
+ ### Percent values
37
163
 
38
- Truncates a string to a maximum length with an optional suffix (default: `"..."`).
164
+ Suffix with `p`:
39
165
 
40
- ```ts
41
- truncate("Hello, World!", 5); // "Hello..."
42
- truncate("Hi", 10); // "Hi"
43
- truncate("abcdefghij", 7, "…"); // "abcd…"
166
+ ```
167
+ mx20p margin-left:20%;margin-right:20%
168
+ w50p → width:50%
169
+ ```
170
+
171
+ ## Hover (`h:`)
172
+
173
+ Apply styles on hover:
174
+
175
+ ```html
176
+ <div h:bgred h:p15>Hover me</div>
177
+ ```
178
+
179
+ ```css
180
+ ._t0:hover {
181
+ background-color: red !important;
182
+ padding: 15px !important;
183
+ }
184
+ ```
185
+
186
+ ## Ancestor Hover (`h1:`, `h2:`, ...)
187
+
188
+ Hover a parent to style a child. The number indicates how many levels up:
189
+
190
+ ```html
191
+ <div>
192
+ <span h1:p30>Hover parent to pad me</span>
193
+ </div>
194
+ ```
195
+
196
+ ```css
197
+ ._t0:hover ._t1 {
198
+ padding: 30px !important;
199
+ }
200
+ ```
201
+
202
+ - `h1:` — hover immediate parent
203
+ - `h2:` — hover grandparent
204
+ - `h3:` — hover great-grandparent
205
+ - `hN:` — hover Nth ancestor
206
+
207
+ ## Responsive (`sm:`, `md:`, `lg:`, `xl:`, `2xl:`)
208
+
209
+ Media query breakpoints wrapped in `@media(min-width:...)`:
210
+
211
+ | Prefix | Breakpoint |
212
+ | ------ | ---------- |
213
+ | `sm:` | 640px |
214
+ | `md:` | 768px |
215
+ | `lg:` | 1024px |
216
+ | `xl:` | 1280px |
217
+ | `2xl:` | 1536px |
218
+
219
+ ```html
220
+ <div md:p20 lg:bgred>Responsive</div>
221
+ ```
222
+
223
+ ```css
224
+ @media (min-width: 768px) {
225
+ ._t0 {
226
+ padding: 20px !important;
227
+ }
228
+ }
229
+ @media (min-width: 1024px) {
230
+ ._t1 {
231
+ background-color: red !important;
232
+ }
233
+ }
234
+ ```
235
+
236
+ ## Combining hover + responsive + ancestor
237
+
238
+ All prefixes stack:
239
+
240
+ ```
241
+ md:h:bgred → @media(≥768px) hover → background-color:red
242
+ md:h1:p30 → @media(≥768px) parent hover → padding:30px
243
+ lg:h2:clwhite → @media(≥1024px) grandparent hover → color:white
44
244
  ```
45
245
 
46
- ## Tree Shaking
246
+ ## Refs
47
247
 
48
- This library is fully tree-shakable. Only the functions you import are included in your bundle.
248
+ Extract elements by `ref` attribute:
49
249
 
50
250
  ```ts
51
- // Only camelCase is included truncate is eliminated
52
- import { camelCase } from "@idlapps/t";
251
+ const { input, btn } = t("<input ref=input><button ref=btn>OK</button>");
252
+ input.placeholder = "Type...";
253
+ btn.onclick = () => alert(input.value);
53
254
  ```
54
255
 
55
256
  ## License
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return e.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():``).replace(/^[A-Z]/,e=>e.toLowerCase())}function t(e,t,n=`...`){return e.length<=t?e:e.slice(0,t-n.length)+n}function n(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/[_\s]+/g,`-`).toLowerCase()}exports.camelCase=e,exports.kebabCase=n,exports.truncate=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=document.createElement(`template`),t={m:`margin`,p:`padding`,t:`top`,r:`right`,l:`left`,bottom:`bottom`,x:`$l:$r`,y:`$t:$b`,w:`width`,h:`height`,min:`min`,max:`max`,P:`position`,D:`display`,fd:`flexDirection`,C:`center`,bg:`backgroundColor`,cl:`color`,tn:`transition`,tx:`translateX`,ty:`translateY`,fs:`fontSize`,fw:`fontWeight`,lh:`lineHeight`,ls:`letterSpacing`,ta:`textAlign`,bd:`border`,rounded:`borderRadius`,shadow:`boxShadow`,opacity:`opacity`,z:`zIndex`,overflow:`overflow`,gap:`gap`,justify:`justifyContent`,items:`alignItems`,ml:`$m$l`,mr:`$m$r`,mt:`$m$t`,mb:`$m$bottom`,mx:`$m$l:$m$r`,my:`$m$t:$m$bottom`,pl:`$p$l`,pr:`$p$r`,pt:`$p$t`,pb:`$p$bottom`,px:`$p$l:$p$r`,py:`$p$t:$p$bottom`,minw:`$min$w`,minh:`$min$h`,maxw:`$max$w`,maxh:`$max$h`,b:`$bd`,bt:`$bd$t`,br:`$bd$r`,bb:`$bd$bottom`,bl:`$bd$l`},n={absolute:`$P:absolute`,a:`$P:absolute`,relative:`$P:relative`,r:`$P:relative`,fixed:`$P:fixed`,f:`$P:fixed`,sticky:`$P:sticky`,flex:`$D:flex`,c:`$D:flex;$justify:$C;$items:$C`,h:`$D:flex;$fd:row`,v:`$D:flex;$fd:column`,tac:`$ta:center`,tar:`$ta:right`,tal:`$ta:left`,b:`$bd`},r=new Set(`red.blue.green.white.black.yellow.orange.purple.pink.teal.cyan.magenta.lime.maroon.navy.olive.gray.grey.silver.gold.coral.salmon.tomato.crimson.indigo.violet.turquoise.plum.orchid.khaki.lavender.ivory.beige.tan.wheat.peru.sienna.chocolate.firebrick.darkred.lightgreen.darkgreen.lightblue.darkblue.darkcyan.darkmagenta.darkviolet.darkorange.darkgoldenrod.darkslategray.darkolivegreen.mediumseagreen.mediumturquoise.mediumslateblue.mediumorchid.mediumpurple.hotpink.deeppink.palevioletred.lightsalmon.lightcoral.skyblue.lightskyblue.steelblue.dodgerblue.cornflowerblue.royalblue.slateblue.mediumblue.midnightblue.aquamarine.chartreuse.springgreen.forestgreen.limegreen.lawngreen.darkseagreen.palegreen.lightyellow.lemonchiffon.paleturquoise.powderblue.lightsteelblue.aliceblue.ghostwhite.snow.floralwhite.oldlace.linen.antiquewhite.mintcream.mistyrose.peachpuff.navajowhite.burlywood.sandybrown.darksalmon.rosybrown.darkkhaki.palegoldenrod.cadetblue.lightcyan.azure.honeydew.thistle.gainsboro.whitesmoke.darkgray.dimgray.lightslategray.slategray`.split(`.`)),i=new Set(`bold.bolder.lighter.normal.italic.oblique.thin.hairline.semibold.extrabold.ultrabold.medium.regular.small.xxsmall.xsmall.large.xlarge.xxlarge.smaller.larger.normal.collapse.hidden.visible.scroll.auto.block.inline.inlineblock.inlineflex.grid.inlinegrid.none.contents.unset.inherit.initial.solid.dashed.dotted.double.groove.ridge.inset.outset.cover.contain.fill.stroke.running.paused.forwards.backwards.both.ease.linear.easein.easeout.easeinout.stepstart.stepend.nowrap.pre.prewrap.preline.breakspace.uppercase.lowercase.capitalize.center.justify.start.end.stretch.baseline.sub.super.overline.through.pointer.default.notallowed.text.wait.help.progress.snapstart.snapend.snapcenter.snearest.mandatory.smooth.noerase.erase.vertical.horizontal.row.column.rowreverse.columnreverse.wrap.wrapreverse`.split(`.`)),a=new Set([`z`,`opacity`,`zIndex`]),o=new Set([`tn`,`transition`]),s=new Set([`tx`,`ty`,`translateX`,`translateY`]),c={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},l=Object.keys(c).sort((e,t)=>t.length-e.length),u=Object.keys(t).sort((e,t)=>t.length-e.length);function d(e){for(;e.includes(`$`);){let n=``,r=0;for(;r<e.length;){if(e[r]===`$`){let i=e.slice(r+1).match(/^[a-zA-Z]+/);if(i){let e=t[i[0]]??i[0];n+=n&&/[a-zA-Z]$/.test(n)?e[0].toUpperCase()+e.slice(1):e,r+=1+i[0].length;continue}}n+=e[r++]}e=n}return e}const f=e=>e.replace(/([A-Z])/g,`-$1`).toLowerCase(),p=e=>e.split(`;`).map(e=>{let t=e.indexOf(`:`);return t>-1?`${f(e.slice(0,t))}:${e.slice(t+1)}`:f(e)}).join(`;`);function m(e,t){return/^-?\d+$/.test(e)?a.has(t)?e:o.has(t)?`${e}ms`:`${e}px`:/^-?\d+p$/.test(e)?`${e.slice(0,-1)}%`:e}function h(e){if(n[e])return p(d(n[e]));for(let n of u){if(!e.startsWith(n)||n.length>=e.length)continue;let a=e.slice(n.length),o=m(a,n);if(/^\d/.test(a)||r.has(a.toLowerCase())||i.has(a.toLowerCase())||a[0]===`-`&&/^\d/.test(a.slice(1))){let e=d(t[n]);return(e.includes(`:`)?e.split(`:`):[e]).map(e=>s.has(e)?`transform:${e}(${o})`:`${f(e)}:${o}`).join(`;`)}}return``}let g=0;const _=[],v=[];function y(e,t){return e?`@media(min-width:${e}px){${t}}`:t}function b(e){let t=[];for(let n of Array.from(e.attributes)){if(n.name===`ref`)continue;let r=n.name,i;for(let e of l)if(r.startsWith(e+`:`)){i=c[e],r=r.slice(e.length+1);break}if(r.startsWith(`h:`)){let t=h(r.slice(2));if(t){let n=`_t${g++}`;e.classList.add(n),_.push(y(i,`.${n}:hover{${t.split(`;`).map(e=>e+`!important`).join(`;`)}}`))}e.removeAttribute(n.name);continue}let a=r.match(/^h(\d+):(.+)$/);if(a){let t=h(a[2]);t&&v.push({el:e,level:+a[1],css:t,media:i}),e.removeAttribute(n.name);continue}let o=h(r);if(o){if(i){let t=`_t${g++}`;e.classList.add(t),_.push(y(i,`.${t}{${o.split(`;`).map(e=>e+`!important`).join(`;`)}}`))}else t.push(o);e.removeAttribute(n.name)}}t.length&&e.setAttribute(`style`,(e.getAttribute(`style`)||``)+t.join(`;`))}function x(t){e.innerHTML=String(t);let n={},r=document.createTreeWalker(e.content,NodeFilter.SHOW_ELEMENT),i;for(;i=r.nextNode();)b(i),i.hasAttribute(`ref`)&&(n[i.getAttribute(`ref`)]=i,i.removeAttribute(`ref`));for(let{el:e,level:t,css:n,media:r}of v){let i=e;for(let e=0;e<t;e++)i=i?.parentElement??null;if(i&&i!==e){let t=`_t${g++}`,a=`_t${g++}`;i.classList.add(t),e.classList.add(a),_.push(y(r,`.${t}:hover .${a}{${n.split(`;`).map(e=>e+`!important`).join(`;`)}}`))}}if(v.length=0,document.body.appendChild(e.content),_.length){let e=document.querySelector(`style[data-t]`)||(()=>{let e=document.createElement(`style`);return e.setAttribute(`data-t`,``),document.head.appendChild(e)})();e.textContent+=_.join(``),_.length=0}return n}exports.t=x;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Converts a string to camelCase.\n *\n * @example\n * ```ts\n * import { camelCase } from \"@idlapps/t\";\n *\n * camelCase(\"hello-world\"); // \"helloWorld\"\n * camelCase(\"foo_bar_baz\"); // \"fooBarBaz\"\n * camelCase(\"Hello World\"); // \"helloWorld\"\n * camelCase(\"alreadyCamel\"); // \"alreadyCamel\"\n * ```\n */\nexport function camelCase(str: string): string {\n return str\n .replace(/[-_\\s]+(.)?/g, (_, char: string | undefined) =>\n char ? char.toUpperCase() : \"\"\n )\n .replace(/^[A-Z]/, (char) => char.toLowerCase());\n}\n\n/**\n * Truncates a string to a maximum length, appending an ellipsis if truncated.\n *\n * @example\n * ```ts\n * import { truncate } from \"@idlapps/t\";\n *\n * truncate(\"Hello, World!\", 5); // \"Hello...\"\n * truncate(\"Hi\", 10); // \"Hi\"\n * truncate(\"abcdefghij\", 7); // \"abcd...\"\n * ```\n */\nexport function truncate(str: string, maxLength: number, suffix = \"...\"): string {\n if (str.length <= maxLength) return str;\n return str.slice(0, maxLength - suffix.length) + suffix;\n}\n\n/**\n * Converts a string to kebab-case.\n *\n * @example\n * ```ts\n * import { kebabCase } from \"@idlapps/t\";\n *\n * kebabCase(\"helloWorld\"); // \"hello-world\"\n * kebabCase(\"foo_bar_baz\"); // \"foo-bar-baz\"\n * kebabCase(\"Hello World\"); // \"hello-world\"\n * ```\n */\nexport function kebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/[_\\s]+/g, \"-\")\n .toLowerCase();\n}\n"],"mappings":"mEAaA,SAAgB,EAAU,EAAqB,CAC7C,OAAO,EACJ,QAAQ,gBAAiB,EAAG,IAC3B,EAAO,EAAK,YAAY,EAAI,EAC9B,CAAC,CACA,QAAQ,SAAW,GAAS,EAAK,YAAY,CAAC,CACnD,CAcA,SAAgB,EAAS,EAAa,EAAmB,EAAS,MAAe,CAE/E,OADI,EAAI,QAAU,EAAkB,EAC7B,EAAI,MAAM,EAAG,EAAY,EAAO,MAAM,EAAI,CACnD,CAcA,SAAgB,EAAU,EAAqB,CAC7C,OAAO,EACJ,QAAQ,kBAAmB,OAAO,CAAC,CACnC,QAAQ,UAAW,GAAG,CAAC,CACvB,YAAY,CACjB"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["const T = document.createElement('template');\n\nconst A: Record<string, string> = {\n m: 'margin', p: 'padding', t: 'top', r: 'right', l: 'left', bottom: 'bottom',\n x: '$l:$r', y: '$t:$b', w: 'width', h: 'height', min: 'min', max: 'max',\n P: 'position', D: 'display', fd: 'flexDirection', C: 'center',\n bg: 'backgroundColor', cl: 'color', tn: 'transition',\n tx: 'translateX', ty: 'translateY',\n fs: 'fontSize', fw: 'fontWeight', lh: 'lineHeight', ls: 'letterSpacing', ta: 'textAlign',\n bd: 'border', rounded: 'borderRadius', shadow: 'boxShadow',\n opacity: 'opacity', z: 'zIndex', overflow: 'overflow',\n gap: 'gap', justify: 'justifyContent', items: 'alignItems',\n ml: '$m$l', mr: '$m$r', mt: '$m$t', mb: '$m$bottom',\n mx: '$m$l:$m$r', my: '$m$t:$m$bottom',\n pl: '$p$l', pr: '$p$r', pt: '$p$t', pb: '$p$bottom',\n px: '$p$l:$p$r', py: '$p$t:$p$bottom',\n minw: '$min$w', minh: '$min$h', maxw: '$max$w', maxh: '$max$h',\n b: '$bd', bt: '$bd$t', br: '$bd$r', bb: '$bd$bottom', bl: '$bd$l',\n};\n\nconst exact: Record<string, string> = {\n absolute: '$P:absolute', a: '$P:absolute',\n relative: '$P:relative', r: '$P:relative',\n fixed: '$P:fixed', f: '$P:fixed', sticky: '$P:sticky',\n flex: '$D:flex', c: '$D:flex;$justify:$C;$items:$C',\n h: '$D:flex;$fd:row', v: '$D:flex;$fd:column',\n tac: '$ta:center', tar: '$ta:right', tal: '$ta:left',\n b: '$bd',\n};\n\nconst colors = new Set(['red','blue','green','white','black','yellow','orange','purple','pink','teal','cyan','magenta','lime','maroon','navy','olive','gray','grey','silver','gold','coral','salmon','tomato','crimson','indigo','violet','turquoise','plum','orchid','khaki','lavender','ivory','beige','tan','wheat','peru','sienna','chocolate','firebrick','darkred','lightgreen','darkgreen','lightblue','darkblue','darkcyan','darkmagenta','darkviolet','darkorange','darkgoldenrod','darkslategray','darkolivegreen','mediumseagreen','mediumturquoise','mediumslateblue','mediumorchid','mediumpurple','hotpink','deeppink','palevioletred','lightsalmon','lightcoral','skyblue','lightskyblue','steelblue','dodgerblue','cornflowerblue','royalblue','slateblue','mediumblue','midnightblue','aquamarine','chartreuse','springgreen','forestgreen','limegreen','lawngreen','darkseagreen','palegreen','lightyellow','lemonchiffon','paleturquoise','powderblue','lightsteelblue','aliceblue','ghostwhite','snow','floralwhite','oldlace','linen','antiquewhite','mintcream','mistyrose','peachpuff','navajowhite','burlywood','sandybrown','darksalmon','rosybrown','darkkhaki','palegoldenrod','cadetblue','lightcyan','azure','honeydew','thistle','gainsboro','whitesmoke','darkgray','dimgray','lightslategray','slategray']);\nconst keywords = new Set(['bold','bolder','lighter','normal','italic','oblique','thin','hairline','semibold','extrabold','ultrabold','medium','regular','small','xxsmall','xsmall','large','xlarge','xxlarge','smaller','larger','normal','collapse','hidden','visible','scroll','auto','block','inline','inlineblock','inlineflex','grid','inlinegrid','none','contents','unset','inherit','initial','solid','dashed','dotted','double','groove','ridge','inset','outset','cover','contain','fill','stroke','running','paused','forwards','backwards','both','ease','linear','easein','easeout','easeinout','stepstart','stepend','nowrap','pre','prewrap','preline','breakspace','uppercase','lowercase','capitalize','center','justify','start','end','stretch','baseline','sub','super','overline','through','pointer','default','notallowed','text','wait','help','progress','snapstart','snapend','snapcenter','snearest','mandatory','smooth','noerase','erase','vertical','horizontal','row','column','rowreverse','columnreverse','wrap','wrapreverse']);\nconst unitless = new Set(['z', 'opacity', 'zIndex']);\nconst ms = new Set(['tn', 'transition']);\nconst transforms = new Set(['tx', 'ty', 'translateX', 'translateY']);\nconst BP: Record<string, number> = { sm: 640, md: 768, lg: 1024, xl: 1280, '2xl': 1536 };\nconst BPS = Object.keys(BP).sort((a, b) => b.length - a.length);\nconst AP = Object.keys(A).sort((a, b) => b.length - a.length);\n\nfunction resolve(s: string): string {\n while (s.includes('$')) {\n let r = '', i = 0;\n while (i < s.length) {\n if (s[i] === '$') {\n const m = s.slice(i + 1).match(/^[a-zA-Z]+/);\n if (m) {\n const v = A[m[0]] ?? m[0];\n r += r && /[a-zA-Z]$/.test(r) ? v[0].toUpperCase() + v.slice(1) : v;\n i += 1 + m[0].length;\n continue;\n }\n }\n r += s[i++];\n }\n s = r;\n }\n return s;\n}\n\nconst kebab = (s: string) => s.replace(/([A-Z])/g, '-$1').toLowerCase();\n\nconst toCSS = (v: string) => v.split(';').map(p => { const i = p.indexOf(':'); return i > -1 ? `${kebab(p.slice(0, i))}:${p.slice(i + 1)}` : kebab(p); }).join(';');\n\nfunction parseVal(raw: string, prop: string): string {\n if (/^-?\\d+$/.test(raw)) return unitless.has(prop) ? raw : ms.has(prop) ? `${raw}ms` : `${raw}px`;\n if (/^-?\\d+p$/.test(raw)) return `${raw.slice(0, -1)}%`;\n return raw;\n}\n\nfunction parse(attr: string): string {\n if (exact[attr]) return toCSS(resolve(exact[attr]));\n\n for (const p of AP) {\n if (!attr.startsWith(p) || p.length >= attr.length) continue;\n const raw = attr.slice(p.length);\n const val = parseVal(raw, p);\n if (/^\\d/.test(raw) || colors.has(raw.toLowerCase()) || keywords.has(raw.toLowerCase()) || raw[0] === '-' && /^\\d/.test(raw.slice(1))) {\n const resolved = resolve(A[p]);\n const props = resolved.includes(':') ? resolved.split(':') : [resolved];\n return props.map(k => transforms.has(k) ? `transform:${k}(${val})` : `${kebab(k)}:${val}`).join(';');\n }\n }\n return '';\n}\n\nlet C = 0;\nconst R: string[] = [];\nconst pendingHoverTarget: { el: Element; level: number; css: string; media?: number }[] = [];\n\nfunction mediaWrap(m: number | undefined, css: string): string {\n return m ? `@media(min-width:${m}px){${css}}` : css;\n}\n\nfunction apply(el: Element) {\n const s: string[] = [];\n for (const a of Array.from(el.attributes)) {\n if (a.name === 'ref') continue;\n let attr = a.name;\n let media: number | undefined;\n for (const bp of BPS) {\n if (attr.startsWith(bp + ':')) { media = BP[bp]; attr = attr.slice(bp.length + 1); break; }\n }\n if (attr.startsWith('h:')) {\n const css = parse(attr.slice(2));\n if (css) {\n const cls = `_t${C++}`;\n el.classList.add(cls);\n R.push(mediaWrap(media, `.${cls}:hover{${css.split(';').map(p => p + '!important').join(';')}}`));\n }\n el.removeAttribute(a.name);\n continue;\n }\n const hm = attr.match(/^h(\\d+):(.+)$/);\n if (hm) {\n const css = parse(hm[2]);\n if (css) pendingHoverTarget.push({ el, level: +hm[1], css, media });\n el.removeAttribute(a.name);\n continue;\n }\n const css = parse(attr);\n if (css) {\n if (media) {\n const cls = `_t${C++}`;\n el.classList.add(cls);\n R.push(mediaWrap(media, `.${cls}{${css.split(';').map(p => p + '!important').join(';')}}`));\n } else {\n s.push(css);\n }\n el.removeAttribute(a.name);\n }\n }\n if (s.length) el.setAttribute('style', (el.getAttribute('style') || '') + s.join(';'));\n}\n\nexport function t(value: unknown) {\n T.innerHTML = String(value);\n const refs: Record<string, HTMLElement> = {};\n const w = document.createTreeWalker(T.content, NodeFilter.SHOW_ELEMENT);\n let n: HTMLElement | null;\n while ((n = w.nextNode() as HTMLElement | null)) {\n apply(n);\n if (n.hasAttribute('ref')) { refs[n.getAttribute('ref')!] = n; n.removeAttribute('ref'); }\n }\n for (const { el, level, css, media } of pendingHoverTarget) {\n let ancestor: HTMLElement | null = el as HTMLElement;\n for (let i = 0; i < level; i++) ancestor = ancestor?.parentElement ?? null;\n if (ancestor && ancestor !== el) {\n const tCls = `_t${C++}`;\n const hCls = `_t${C++}`;\n ancestor.classList.add(tCls);\n el.classList.add(hCls);\n R.push(mediaWrap(media, `.${tCls}:hover .${hCls}{${css.split(';').map(p => p + '!important').join(';')}}`));\n }\n }\n pendingHoverTarget.length = 0;\n document.body.appendChild(T.content);\n if (R.length) {\n const el = document.querySelector('style[data-t]') as HTMLStyleElement || (() => { const s = document.createElement('style'); s.setAttribute('data-t', ''); return document.head.appendChild(s); })();\n el.textContent += R.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AAK,GAAM,EAAG,EAAE,gBAAgB,KAAK,GAExF,IAAK,GAAM,CAAE,KAAI,QAAO,MAAK,WAAW,EAAoB,CAC1D,IAAI,EAA+B,EACnC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,IAAK,EAAW,GAAU,eAAiB,KACtE,GAAI,GAAY,IAAa,EAAI,CAC/B,IAAM,EAAO,KAAK,MACZ,EAAO,KAAK,MAClB,EAAS,UAAU,IAAI,CAAI,EAC3B,EAAG,UAAU,IAAI,CAAI,EACrB,EAAE,KAAK,EAAU,EAAO,IAAI,EAAK,UAAU,EAAK,GAAG,EAAI,MAAM,GAAG,CAAC,CAAC,IAAI,GAAK,EAAI,YAAY,CAAC,CAAC,KAAK,GAAG,EAAE,EAAE,CAAC,CAC5G,CACF,CAGA,GAFA,EAAmB,OAAS,EAC5B,SAAS,KAAK,YAAY,EAAE,OAAO,EAC/B,EAAE,OAAQ,CACZ,IAAM,EAAK,SAAS,cAAc,eAAe,QAAgC,CAAE,IAAM,EAAI,SAAS,cAAc,OAAO,EAAiC,OAA9B,EAAE,aAAa,SAAU,EAAE,EAAU,SAAS,KAAK,YAAY,CAAC,CAAG,EAAA,CAAG,EACpM,EAAG,aAAe,EAAE,KAAK,EAAE,EAC3B,EAAE,OAAS,CACb,CACA,OAAO,CACT"}
package/dist/index.d.cts CHANGED
@@ -1,44 +1,5 @@
1
1
  //#region src/index.d.ts
2
- /**
3
- * Converts a string to camelCase.
4
- *
5
- * @example
6
- * ```ts
7
- * import { camelCase } from "@idlapps/t";
8
- *
9
- * camelCase("hello-world"); // "helloWorld"
10
- * camelCase("foo_bar_baz"); // "fooBarBaz"
11
- * camelCase("Hello World"); // "helloWorld"
12
- * camelCase("alreadyCamel"); // "alreadyCamel"
13
- * ```
14
- */
15
- declare function camelCase(str: string): string;
16
- /**
17
- * Truncates a string to a maximum length, appending an ellipsis if truncated.
18
- *
19
- * @example
20
- * ```ts
21
- * import { truncate } from "@idlapps/t";
22
- *
23
- * truncate("Hello, World!", 5); // "Hello..."
24
- * truncate("Hi", 10); // "Hi"
25
- * truncate("abcdefghij", 7); // "abcd..."
26
- * ```
27
- */
28
- declare function truncate(str: string, maxLength: number, suffix?: string): string;
29
- /**
30
- * Converts a string to kebab-case.
31
- *
32
- * @example
33
- * ```ts
34
- * import { kebabCase } from "@idlapps/t";
35
- *
36
- * kebabCase("helloWorld"); // "hello-world"
37
- * kebabCase("foo_bar_baz"); // "foo-bar-baz"
38
- * kebabCase("Hello World"); // "hello-world"
39
- * ```
40
- */
41
- declare function kebabCase(str: string): string;
2
+ declare function t(value: unknown): Record<string, HTMLElement>;
42
3
  //#endregion
43
- export { camelCase, kebabCase, truncate };
4
+ export { t };
44
5
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;iBAagB,UAAU;;;;;;;;;;;;;iBAoBV,SAAS,aAAa,mBAAmB;;;;;;;;;;;;;iBAiBzC,UAAU"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";iBAsIgB,EAAE,iBAAc,eAAA"}
package/dist/index.d.mts CHANGED
@@ -1,44 +1,5 @@
1
1
  //#region src/index.d.ts
2
- /**
3
- * Converts a string to camelCase.
4
- *
5
- * @example
6
- * ```ts
7
- * import { camelCase } from "@idlapps/t";
8
- *
9
- * camelCase("hello-world"); // "helloWorld"
10
- * camelCase("foo_bar_baz"); // "fooBarBaz"
11
- * camelCase("Hello World"); // "helloWorld"
12
- * camelCase("alreadyCamel"); // "alreadyCamel"
13
- * ```
14
- */
15
- declare function camelCase(str: string): string;
16
- /**
17
- * Truncates a string to a maximum length, appending an ellipsis if truncated.
18
- *
19
- * @example
20
- * ```ts
21
- * import { truncate } from "@idlapps/t";
22
- *
23
- * truncate("Hello, World!", 5); // "Hello..."
24
- * truncate("Hi", 10); // "Hi"
25
- * truncate("abcdefghij", 7); // "abcd..."
26
- * ```
27
- */
28
- declare function truncate(str: string, maxLength: number, suffix?: string): string;
29
- /**
30
- * Converts a string to kebab-case.
31
- *
32
- * @example
33
- * ```ts
34
- * import { kebabCase } from "@idlapps/t";
35
- *
36
- * kebabCase("helloWorld"); // "hello-world"
37
- * kebabCase("foo_bar_baz"); // "foo-bar-baz"
38
- * kebabCase("Hello World"); // "hello-world"
39
- * ```
40
- */
41
- declare function kebabCase(str: string): string;
2
+ declare function t(value: unknown): Record<string, HTMLElement>;
42
3
  //#endregion
43
- export { camelCase, kebabCase, truncate };
4
+ export { t };
44
5
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;iBAagB,UAAU;;;;;;;;;;;;;iBAoBV,SAAS,aAAa,mBAAmB;;;;;;;;;;;;;iBAiBzC,UAAU"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";iBAsIgB,EAAE,iBAAc,eAAA"}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- function e(e){return e.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():``).replace(/^[A-Z]/,e=>e.toLowerCase())}function t(e,t,n=`...`){return e.length<=t?e:e.slice(0,t-n.length)+n}function n(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/[_\s]+/g,`-`).toLowerCase()}export{e as camelCase,n as kebabCase,t as truncate};
1
+ const e=document.createElement(`template`),t={m:`margin`,p:`padding`,t:`top`,r:`right`,l:`left`,bottom:`bottom`,x:`$l:$r`,y:`$t:$b`,w:`width`,h:`height`,min:`min`,max:`max`,P:`position`,D:`display`,fd:`flexDirection`,C:`center`,bg:`backgroundColor`,cl:`color`,tn:`transition`,tx:`translateX`,ty:`translateY`,fs:`fontSize`,fw:`fontWeight`,lh:`lineHeight`,ls:`letterSpacing`,ta:`textAlign`,bd:`border`,rounded:`borderRadius`,shadow:`boxShadow`,opacity:`opacity`,z:`zIndex`,overflow:`overflow`,gap:`gap`,justify:`justifyContent`,items:`alignItems`,ml:`$m$l`,mr:`$m$r`,mt:`$m$t`,mb:`$m$bottom`,mx:`$m$l:$m$r`,my:`$m$t:$m$bottom`,pl:`$p$l`,pr:`$p$r`,pt:`$p$t`,pb:`$p$bottom`,px:`$p$l:$p$r`,py:`$p$t:$p$bottom`,minw:`$min$w`,minh:`$min$h`,maxw:`$max$w`,maxh:`$max$h`,b:`$bd`,bt:`$bd$t`,br:`$bd$r`,bb:`$bd$bottom`,bl:`$bd$l`},n={absolute:`$P:absolute`,a:`$P:absolute`,relative:`$P:relative`,r:`$P:relative`,fixed:`$P:fixed`,f:`$P:fixed`,sticky:`$P:sticky`,flex:`$D:flex`,c:`$D:flex;$justify:$C;$items:$C`,h:`$D:flex;$fd:row`,v:`$D:flex;$fd:column`,tac:`$ta:center`,tar:`$ta:right`,tal:`$ta:left`,b:`$bd`},r=new Set(`red.blue.green.white.black.yellow.orange.purple.pink.teal.cyan.magenta.lime.maroon.navy.olive.gray.grey.silver.gold.coral.salmon.tomato.crimson.indigo.violet.turquoise.plum.orchid.khaki.lavender.ivory.beige.tan.wheat.peru.sienna.chocolate.firebrick.darkred.lightgreen.darkgreen.lightblue.darkblue.darkcyan.darkmagenta.darkviolet.darkorange.darkgoldenrod.darkslategray.darkolivegreen.mediumseagreen.mediumturquoise.mediumslateblue.mediumorchid.mediumpurple.hotpink.deeppink.palevioletred.lightsalmon.lightcoral.skyblue.lightskyblue.steelblue.dodgerblue.cornflowerblue.royalblue.slateblue.mediumblue.midnightblue.aquamarine.chartreuse.springgreen.forestgreen.limegreen.lawngreen.darkseagreen.palegreen.lightyellow.lemonchiffon.paleturquoise.powderblue.lightsteelblue.aliceblue.ghostwhite.snow.floralwhite.oldlace.linen.antiquewhite.mintcream.mistyrose.peachpuff.navajowhite.burlywood.sandybrown.darksalmon.rosybrown.darkkhaki.palegoldenrod.cadetblue.lightcyan.azure.honeydew.thistle.gainsboro.whitesmoke.darkgray.dimgray.lightslategray.slategray`.split(`.`)),i=new Set(`bold.bolder.lighter.normal.italic.oblique.thin.hairline.semibold.extrabold.ultrabold.medium.regular.small.xxsmall.xsmall.large.xlarge.xxlarge.smaller.larger.normal.collapse.hidden.visible.scroll.auto.block.inline.inlineblock.inlineflex.grid.inlinegrid.none.contents.unset.inherit.initial.solid.dashed.dotted.double.groove.ridge.inset.outset.cover.contain.fill.stroke.running.paused.forwards.backwards.both.ease.linear.easein.easeout.easeinout.stepstart.stepend.nowrap.pre.prewrap.preline.breakspace.uppercase.lowercase.capitalize.center.justify.start.end.stretch.baseline.sub.super.overline.through.pointer.default.notallowed.text.wait.help.progress.snapstart.snapend.snapcenter.snearest.mandatory.smooth.noerase.erase.vertical.horizontal.row.column.rowreverse.columnreverse.wrap.wrapreverse`.split(`.`)),a=new Set([`z`,`opacity`,`zIndex`]),o=new Set([`tn`,`transition`]),s=new Set([`tx`,`ty`,`translateX`,`translateY`]),c={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},l=Object.keys(c).sort((e,t)=>t.length-e.length),u=Object.keys(t).sort((e,t)=>t.length-e.length);function d(e){for(;e.includes(`$`);){let n=``,r=0;for(;r<e.length;){if(e[r]===`$`){let i=e.slice(r+1).match(/^[a-zA-Z]+/);if(i){let e=t[i[0]]??i[0];n+=n&&/[a-zA-Z]$/.test(n)?e[0].toUpperCase()+e.slice(1):e,r+=1+i[0].length;continue}}n+=e[r++]}e=n}return e}const f=e=>e.replace(/([A-Z])/g,`-$1`).toLowerCase(),p=e=>e.split(`;`).map(e=>{let t=e.indexOf(`:`);return t>-1?`${f(e.slice(0,t))}:${e.slice(t+1)}`:f(e)}).join(`;`);function m(e,t){return/^-?\d+$/.test(e)?a.has(t)?e:o.has(t)?`${e}ms`:`${e}px`:/^-?\d+p$/.test(e)?`${e.slice(0,-1)}%`:e}function h(e){if(n[e])return p(d(n[e]));for(let n of u){if(!e.startsWith(n)||n.length>=e.length)continue;let a=e.slice(n.length),o=m(a,n);if(/^\d/.test(a)||r.has(a.toLowerCase())||i.has(a.toLowerCase())||a[0]===`-`&&/^\d/.test(a.slice(1))){let e=d(t[n]);return(e.includes(`:`)?e.split(`:`):[e]).map(e=>s.has(e)?`transform:${e}(${o})`:`${f(e)}:${o}`).join(`;`)}}return``}let g=0;const _=[],v=[];function y(e,t){return e?`@media(min-width:${e}px){${t}}`:t}function b(e){let t=[];for(let n of Array.from(e.attributes)){if(n.name===`ref`)continue;let r=n.name,i;for(let e of l)if(r.startsWith(e+`:`)){i=c[e],r=r.slice(e.length+1);break}if(r.startsWith(`h:`)){let t=h(r.slice(2));if(t){let n=`_t${g++}`;e.classList.add(n),_.push(y(i,`.${n}:hover{${t.split(`;`).map(e=>e+`!important`).join(`;`)}}`))}e.removeAttribute(n.name);continue}let a=r.match(/^h(\d+):(.+)$/);if(a){let t=h(a[2]);t&&v.push({el:e,level:+a[1],css:t,media:i}),e.removeAttribute(n.name);continue}let o=h(r);if(o){if(i){let t=`_t${g++}`;e.classList.add(t),_.push(y(i,`.${t}{${o.split(`;`).map(e=>e+`!important`).join(`;`)}}`))}else t.push(o);e.removeAttribute(n.name)}}t.length&&e.setAttribute(`style`,(e.getAttribute(`style`)||``)+t.join(`;`))}function x(t){e.innerHTML=String(t);let n={},r=document.createTreeWalker(e.content,NodeFilter.SHOW_ELEMENT),i;for(;i=r.nextNode();)b(i),i.hasAttribute(`ref`)&&(n[i.getAttribute(`ref`)]=i,i.removeAttribute(`ref`));for(let{el:e,level:t,css:n,media:r}of v){let i=e;for(let e=0;e<t;e++)i=i?.parentElement??null;if(i&&i!==e){let t=`_t${g++}`,a=`_t${g++}`;i.classList.add(t),e.classList.add(a),_.push(y(r,`.${t}:hover .${a}{${n.split(`;`).map(e=>e+`!important`).join(`;`)}}`))}}if(v.length=0,document.body.appendChild(e.content),_.length){let e=document.querySelector(`style[data-t]`)||(()=>{let e=document.createElement(`style`);return e.setAttribute(`data-t`,``),document.head.appendChild(e)})();e.textContent+=_.join(``),_.length=0}return n}export{x as t};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Converts a string to camelCase.\n *\n * @example\n * ```ts\n * import { camelCase } from \"@idlapps/t\";\n *\n * camelCase(\"hello-world\"); // \"helloWorld\"\n * camelCase(\"foo_bar_baz\"); // \"fooBarBaz\"\n * camelCase(\"Hello World\"); // \"helloWorld\"\n * camelCase(\"alreadyCamel\"); // \"alreadyCamel\"\n * ```\n */\nexport function camelCase(str: string): string {\n return str\n .replace(/[-_\\s]+(.)?/g, (_, char: string | undefined) =>\n char ? char.toUpperCase() : \"\"\n )\n .replace(/^[A-Z]/, (char) => char.toLowerCase());\n}\n\n/**\n * Truncates a string to a maximum length, appending an ellipsis if truncated.\n *\n * @example\n * ```ts\n * import { truncate } from \"@idlapps/t\";\n *\n * truncate(\"Hello, World!\", 5); // \"Hello...\"\n * truncate(\"Hi\", 10); // \"Hi\"\n * truncate(\"abcdefghij\", 7); // \"abcd...\"\n * ```\n */\nexport function truncate(str: string, maxLength: number, suffix = \"...\"): string {\n if (str.length <= maxLength) return str;\n return str.slice(0, maxLength - suffix.length) + suffix;\n}\n\n/**\n * Converts a string to kebab-case.\n *\n * @example\n * ```ts\n * import { kebabCase } from \"@idlapps/t\";\n *\n * kebabCase(\"helloWorld\"); // \"hello-world\"\n * kebabCase(\"foo_bar_baz\"); // \"foo-bar-baz\"\n * kebabCase(\"Hello World\"); // \"hello-world\"\n * ```\n */\nexport function kebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/[_\\s]+/g, \"-\")\n .toLowerCase();\n}\n"],"mappings":"AAaA,SAAgB,EAAU,EAAqB,CAC7C,OAAO,EACJ,QAAQ,gBAAiB,EAAG,IAC3B,EAAO,EAAK,YAAY,EAAI,EAC9B,CAAC,CACA,QAAQ,SAAW,GAAS,EAAK,YAAY,CAAC,CACnD,CAcA,SAAgB,EAAS,EAAa,EAAmB,EAAS,MAAe,CAE/E,OADI,EAAI,QAAU,EAAkB,EAC7B,EAAI,MAAM,EAAG,EAAY,EAAO,MAAM,EAAI,CACnD,CAcA,SAAgB,EAAU,EAAqB,CAC7C,OAAO,EACJ,QAAQ,kBAAmB,OAAO,CAAC,CACnC,QAAQ,UAAW,GAAG,CAAC,CACvB,YAAY,CACjB"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["const T = document.createElement('template');\n\nconst A: Record<string, string> = {\n m: 'margin', p: 'padding', t: 'top', r: 'right', l: 'left', bottom: 'bottom',\n x: '$l:$r', y: '$t:$b', w: 'width', h: 'height', min: 'min', max: 'max',\n P: 'position', D: 'display', fd: 'flexDirection', C: 'center',\n bg: 'backgroundColor', cl: 'color', tn: 'transition',\n tx: 'translateX', ty: 'translateY',\n fs: 'fontSize', fw: 'fontWeight', lh: 'lineHeight', ls: 'letterSpacing', ta: 'textAlign',\n bd: 'border', rounded: 'borderRadius', shadow: 'boxShadow',\n opacity: 'opacity', z: 'zIndex', overflow: 'overflow',\n gap: 'gap', justify: 'justifyContent', items: 'alignItems',\n ml: '$m$l', mr: '$m$r', mt: '$m$t', mb: '$m$bottom',\n mx: '$m$l:$m$r', my: '$m$t:$m$bottom',\n pl: '$p$l', pr: '$p$r', pt: '$p$t', pb: '$p$bottom',\n px: '$p$l:$p$r', py: '$p$t:$p$bottom',\n minw: '$min$w', minh: '$min$h', maxw: '$max$w', maxh: '$max$h',\n b: '$bd', bt: '$bd$t', br: '$bd$r', bb: '$bd$bottom', bl: '$bd$l',\n};\n\nconst exact: Record<string, string> = {\n absolute: '$P:absolute', a: '$P:absolute',\n relative: '$P:relative', r: '$P:relative',\n fixed: '$P:fixed', f: '$P:fixed', sticky: '$P:sticky',\n flex: '$D:flex', c: '$D:flex;$justify:$C;$items:$C',\n h: '$D:flex;$fd:row', v: '$D:flex;$fd:column',\n tac: '$ta:center', tar: '$ta:right', tal: '$ta:left',\n b: '$bd',\n};\n\nconst colors = new Set(['red','blue','green','white','black','yellow','orange','purple','pink','teal','cyan','magenta','lime','maroon','navy','olive','gray','grey','silver','gold','coral','salmon','tomato','crimson','indigo','violet','turquoise','plum','orchid','khaki','lavender','ivory','beige','tan','wheat','peru','sienna','chocolate','firebrick','darkred','lightgreen','darkgreen','lightblue','darkblue','darkcyan','darkmagenta','darkviolet','darkorange','darkgoldenrod','darkslategray','darkolivegreen','mediumseagreen','mediumturquoise','mediumslateblue','mediumorchid','mediumpurple','hotpink','deeppink','palevioletred','lightsalmon','lightcoral','skyblue','lightskyblue','steelblue','dodgerblue','cornflowerblue','royalblue','slateblue','mediumblue','midnightblue','aquamarine','chartreuse','springgreen','forestgreen','limegreen','lawngreen','darkseagreen','palegreen','lightyellow','lemonchiffon','paleturquoise','powderblue','lightsteelblue','aliceblue','ghostwhite','snow','floralwhite','oldlace','linen','antiquewhite','mintcream','mistyrose','peachpuff','navajowhite','burlywood','sandybrown','darksalmon','rosybrown','darkkhaki','palegoldenrod','cadetblue','lightcyan','azure','honeydew','thistle','gainsboro','whitesmoke','darkgray','dimgray','lightslategray','slategray']);\nconst keywords = new Set(['bold','bolder','lighter','normal','italic','oblique','thin','hairline','semibold','extrabold','ultrabold','medium','regular','small','xxsmall','xsmall','large','xlarge','xxlarge','smaller','larger','normal','collapse','hidden','visible','scroll','auto','block','inline','inlineblock','inlineflex','grid','inlinegrid','none','contents','unset','inherit','initial','solid','dashed','dotted','double','groove','ridge','inset','outset','cover','contain','fill','stroke','running','paused','forwards','backwards','both','ease','linear','easein','easeout','easeinout','stepstart','stepend','nowrap','pre','prewrap','preline','breakspace','uppercase','lowercase','capitalize','center','justify','start','end','stretch','baseline','sub','super','overline','through','pointer','default','notallowed','text','wait','help','progress','snapstart','snapend','snapcenter','snearest','mandatory','smooth','noerase','erase','vertical','horizontal','row','column','rowreverse','columnreverse','wrap','wrapreverse']);\nconst unitless = new Set(['z', 'opacity', 'zIndex']);\nconst ms = new Set(['tn', 'transition']);\nconst transforms = new Set(['tx', 'ty', 'translateX', 'translateY']);\nconst BP: Record<string, number> = { sm: 640, md: 768, lg: 1024, xl: 1280, '2xl': 1536 };\nconst BPS = Object.keys(BP).sort((a, b) => b.length - a.length);\nconst AP = Object.keys(A).sort((a, b) => b.length - a.length);\n\nfunction resolve(s: string): string {\n while (s.includes('$')) {\n let r = '', i = 0;\n while (i < s.length) {\n if (s[i] === '$') {\n const m = s.slice(i + 1).match(/^[a-zA-Z]+/);\n if (m) {\n const v = A[m[0]] ?? m[0];\n r += r && /[a-zA-Z]$/.test(r) ? v[0].toUpperCase() + v.slice(1) : v;\n i += 1 + m[0].length;\n continue;\n }\n }\n r += s[i++];\n }\n s = r;\n }\n return s;\n}\n\nconst kebab = (s: string) => s.replace(/([A-Z])/g, '-$1').toLowerCase();\n\nconst toCSS = (v: string) => v.split(';').map(p => { const i = p.indexOf(':'); return i > -1 ? `${kebab(p.slice(0, i))}:${p.slice(i + 1)}` : kebab(p); }).join(';');\n\nfunction parseVal(raw: string, prop: string): string {\n if (/^-?\\d+$/.test(raw)) return unitless.has(prop) ? raw : ms.has(prop) ? `${raw}ms` : `${raw}px`;\n if (/^-?\\d+p$/.test(raw)) return `${raw.slice(0, -1)}%`;\n return raw;\n}\n\nfunction parse(attr: string): string {\n if (exact[attr]) return toCSS(resolve(exact[attr]));\n\n for (const p of AP) {\n if (!attr.startsWith(p) || p.length >= attr.length) continue;\n const raw = attr.slice(p.length);\n const val = parseVal(raw, p);\n if (/^\\d/.test(raw) || colors.has(raw.toLowerCase()) || keywords.has(raw.toLowerCase()) || raw[0] === '-' && /^\\d/.test(raw.slice(1))) {\n const resolved = resolve(A[p]);\n const props = resolved.includes(':') ? resolved.split(':') : [resolved];\n return props.map(k => transforms.has(k) ? `transform:${k}(${val})` : `${kebab(k)}:${val}`).join(';');\n }\n }\n return '';\n}\n\nlet C = 0;\nconst R: string[] = [];\nconst pendingHoverTarget: { el: Element; level: number; css: string; media?: number }[] = [];\n\nfunction mediaWrap(m: number | undefined, css: string): string {\n return m ? `@media(min-width:${m}px){${css}}` : css;\n}\n\nfunction apply(el: Element) {\n const s: string[] = [];\n for (const a of Array.from(el.attributes)) {\n if (a.name === 'ref') continue;\n let attr = a.name;\n let media: number | undefined;\n for (const bp of BPS) {\n if (attr.startsWith(bp + ':')) { media = BP[bp]; attr = attr.slice(bp.length + 1); break; }\n }\n if (attr.startsWith('h:')) {\n const css = parse(attr.slice(2));\n if (css) {\n const cls = `_t${C++}`;\n el.classList.add(cls);\n R.push(mediaWrap(media, `.${cls}:hover{${css.split(';').map(p => p + '!important').join(';')}}`));\n }\n el.removeAttribute(a.name);\n continue;\n }\n const hm = attr.match(/^h(\\d+):(.+)$/);\n if (hm) {\n const css = parse(hm[2]);\n if (css) pendingHoverTarget.push({ el, level: +hm[1], css, media });\n el.removeAttribute(a.name);\n continue;\n }\n const css = parse(attr);\n if (css) {\n if (media) {\n const cls = `_t${C++}`;\n el.classList.add(cls);\n R.push(mediaWrap(media, `.${cls}{${css.split(';').map(p => p + '!important').join(';')}}`));\n } else {\n s.push(css);\n }\n el.removeAttribute(a.name);\n }\n }\n if (s.length) el.setAttribute('style', (el.getAttribute('style') || '') + s.join(';'));\n}\n\nexport function t(value: unknown) {\n T.innerHTML = String(value);\n const refs: Record<string, HTMLElement> = {};\n const w = document.createTreeWalker(T.content, NodeFilter.SHOW_ELEMENT);\n let n: HTMLElement | null;\n while ((n = w.nextNode() as HTMLElement | null)) {\n apply(n);\n if (n.hasAttribute('ref')) { refs[n.getAttribute('ref')!] = n; n.removeAttribute('ref'); }\n }\n for (const { el, level, css, media } of pendingHoverTarget) {\n let ancestor: HTMLElement | null = el as HTMLElement;\n for (let i = 0; i < level; i++) ancestor = ancestor?.parentElement ?? null;\n if (ancestor && ancestor !== el) {\n const tCls = `_t${C++}`;\n const hCls = `_t${C++}`;\n ancestor.classList.add(tCls);\n el.classList.add(hCls);\n R.push(mediaWrap(media, `.${tCls}:hover .${hCls}{${css.split(';').map(p => p + '!important').join(';')}}`));\n }\n }\n pendingHoverTarget.length = 0;\n document.body.appendChild(T.content);\n if (R.length) {\n const el = document.querySelector('style[data-t]') as HTMLStyleElement || (() => { const s = document.createElement('style'); s.setAttribute('data-t', ''); return document.head.appendChild(s); })();\n el.textContent += R.join('');\n R.length = 0;\n }\n return refs;\n}\n"],"mappings":"AAAA,MAAM,EAAI,SAAS,cAAc,UAAU,EAErC,EAA4B,CAChC,EAAG,SAAU,EAAG,UAAW,EAAG,MAAO,EAAG,QAAS,EAAG,OAAQ,OAAQ,SACpE,EAAG,QAAS,EAAG,QAAS,EAAG,QAAS,EAAG,SAAU,IAAK,MAAO,IAAK,MAClE,EAAG,WAAY,EAAG,UAAW,GAAI,gBAAiB,EAAG,SACrD,GAAI,kBAAmB,GAAI,QAAS,GAAI,aACxC,GAAI,aAAc,GAAI,aACtB,GAAI,WAAY,GAAI,aAAc,GAAI,aAAc,GAAI,gBAAiB,GAAI,YAC7E,GAAI,SAAU,QAAS,eAAgB,OAAQ,YAC/C,QAAS,UAAW,EAAG,SAAU,SAAU,WAC3C,IAAK,MAAO,QAAS,iBAAkB,MAAO,aAC9C,GAAI,OAAQ,GAAI,OAAQ,GAAI,OAAQ,GAAI,YACxC,GAAI,YAAa,GAAI,iBACrB,GAAI,OAAQ,GAAI,OAAQ,GAAI,OAAQ,GAAI,YACxC,GAAI,YAAa,GAAI,iBACrB,KAAM,SAAU,KAAM,SAAU,KAAM,SAAU,KAAM,SACtD,EAAG,MAAO,GAAI,QAAS,GAAI,QAAS,GAAI,aAAc,GAAI,OAC5D,EAEM,EAAgC,CACpC,SAAU,cAAe,EAAG,cAC5B,SAAU,cAAe,EAAG,cAC5B,MAAO,WAAY,EAAG,WAAY,OAAQ,YAC1C,KAAM,UAAW,EAAG,gCACpB,EAAG,kBAAmB,EAAG,qBACzB,IAAK,aAAc,IAAK,YAAa,IAAK,WAC1C,EAAG,KACL,EAEM,EA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B,CAChC,EAAE,UAAY,OAAO,CAAK,EAC1B,IAAM,EAAoC,CAAC,EACrC,EAAI,SAAS,iBAAiB,EAAE,QAAS,WAAW,YAAY,EAClE,EACJ,KAAQ,EAAI,EAAE,SAAS,GACrB,EAAM,CAAC,EACH,EAAE,aAAa,KAAK,IAAK,EAAK,EAAE,aAAa,KAAK,GAAM,EAAG,EAAE,gBAAgB,KAAK,GAExF,IAAK,GAAM,CAAE,KAAI,QAAO,MAAK,WAAW,EAAoB,CAC1D,IAAI,EAA+B,EACnC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,IAAK,EAAW,GAAU,eAAiB,KACtE,GAAI,GAAY,IAAa,EAAI,CAC/B,IAAM,EAAO,KAAK,MACZ,EAAO,KAAK,MAClB,EAAS,UAAU,IAAI,CAAI,EAC3B,EAAG,UAAU,IAAI,CAAI,EACrB,EAAE,KAAK,EAAU,EAAO,IAAI,EAAK,UAAU,EAAK,GAAG,EAAI,MAAM,GAAG,CAAC,CAAC,IAAI,GAAK,EAAI,YAAY,CAAC,CAAC,KAAK,GAAG,EAAE,EAAE,CAAC,CAC5G,CACF,CAGA,GAFA,EAAmB,OAAS,EAC5B,SAAS,KAAK,YAAY,EAAE,OAAO,EAC/B,EAAE,OAAQ,CACZ,IAAM,EAAK,SAAS,cAAc,eAAe,QAAgC,CAAE,IAAM,EAAI,SAAS,cAAc,OAAO,EAAiC,OAA9B,EAAE,aAAa,SAAU,EAAE,EAAU,SAAS,KAAK,YAAY,CAAC,CAAG,EAAA,CAAG,EACpM,EAAG,aAAe,EAAE,KAAK,EAAE,EAC3B,EAAE,OAAS,CACb,CACA,OAAO,CACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idlapps/t",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Lightweight, tree-shakable string utility functions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -27,7 +27,8 @@
27
27
  "dev": "tsdown --watch",
28
28
  "lint": "eslint .",
29
29
  "typecheck": "tsc --noEmit",
30
- "prepublishOnly": "npm run build"
30
+ "prepublishOnly": "npm run build",
31
+ "test": "concurrently \"tsdown --watch\" \"browser-sync start --config bs-config.cjs\""
31
32
  },
32
33
  "keywords": [
33
34
  "string",
@@ -39,6 +40,9 @@
39
40
  ],
40
41
  "license": "MIT",
41
42
  "devDependencies": {
43
+ "browser-sync": "^3.0.4",
44
+ "concurrently": "^10.0.5",
45
+ "jsdom": "^30.1.0",
42
46
  "tsdown": "^0.22.14",
43
47
  "typescript": "^5.8.0"
44
48
  },