@takumi-rs/helpers 0.14.3 → 0.15.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/index.d.ts CHANGED
@@ -85,11 +85,11 @@ export type BoxShadow = {
85
85
  */
86
86
  blur_radius: LengthUnit;
87
87
  /**
88
- * Spread radius of the box shadow
88
+ * Spread radius of the box shadow (can be negative)
89
89
  */
90
90
  spread_radius: LengthUnit;
91
91
  /**
92
- * Whether the shadow is inset (inside the element)
92
+ * Whether the shadow is inset (inside the element) or outset (outside the element)
93
93
  */
94
94
  inset: boolean;
95
95
  };
@@ -119,8 +119,10 @@ export type FlexWrap = "nowrap" | "wrap" | "wrap-reverse";
119
119
  /**
120
120
  * Represents font weight as a numeric value.
121
121
  *
122
- * This wraps a u16 value that corresponds to CSS font-weight values
123
- * (e.g., 100 for thin, 400 for normal, 700 for bold, 900 for black).
122
+ * This wraps a u16 value that corresponds to CSS font-weight values.
123
+ * Common values include 100 (thin), 200 (extra light), 300 (light),
124
+ * 400 (normal), 500 (medium), 600 (semi bold), 700 (bold),
125
+ * 800 (extra bold), 900 (black).
124
126
  */
125
127
  export type FontWeight = number;
126
128
  /**
@@ -261,19 +263,19 @@ export type Style = {
261
263
  */
262
264
  min_height: LengthUnit;
263
265
  /**
264
- * Aspect ratio of the element
266
+ * Aspect ratio of the element (width/height)
265
267
  */
266
268
  aspect_ratio?: number;
267
269
  /**
268
- * Internal spacing around the element's content
270
+ * Internal spacing around the element's content (top, right, bottom, left)
269
271
  */
270
272
  padding: SidesValue<LengthUnit>;
271
273
  /**
272
- * External spacing around the element
274
+ * External spacing around the element (top, right, bottom, left)
273
275
  */
274
276
  margin: SidesValue<LengthUnit>;
275
277
  /**
276
- * Positioning offset from the element's normal position
278
+ * Positioning offsets (top, right, bottom, left) from the element's normal position
277
279
  */
278
280
  inset: SidesValue<LengthUnit>;
279
281
  /**
@@ -281,27 +283,35 @@ export type Style = {
281
283
  */
282
284
  flex_direction: FlexDirection;
283
285
  /**
284
- * How flex items are aligned along the main axis
286
+ * How a single grid item is aligned along the inline (row) axis, overriding the container's justify-items value
287
+ */
288
+ justify_self?: AlignItems;
289
+ /**
290
+ * How items are aligned along the main axis
285
291
  */
286
292
  justify_content?: JustifyContent;
287
293
  /**
288
- * How flex items are aligned along the cross axis when there's extra space
294
+ * How lines are aligned within the flex container when there's extra space in the cross axis
289
295
  */
290
296
  align_content?: JustifyContent;
291
297
  /**
292
- * How grid items are aligned along the inline (row) axis
298
+ * How grid items are aligned along the inline (row) axis within their grid areas
293
299
  */
294
300
  justify_items?: AlignItems;
295
301
  /**
296
- * How flex items are aligned along the cross axis
302
+ * How items are aligned along the cross axis
297
303
  */
298
304
  align_items?: AlignItems;
305
+ /**
306
+ * How a single item is aligned along the cross axis, overriding the container's align-items value
307
+ */
308
+ align_self?: AlignItems;
299
309
  /**
300
310
  * How flex items should wrap
301
311
  */
302
312
  flex_wrap: FlexWrap;
303
313
  /**
304
- * The initial size of the flex item before growing or shrinking
314
+ * The initial main size of the flex item before growing or shrinking
305
315
  */
306
316
  flex_basis: LengthUnit;
307
317
  /**
@@ -309,19 +319,19 @@ export type Style = {
309
319
  */
310
320
  position: Position$1;
311
321
  /**
312
- * Spacing between flex items or grid tracks
322
+ * Spacing between rows and columns in flex or grid layouts
313
323
  */
314
324
  gap: Gap;
315
325
  /**
316
- * How much the element should grow relative to other flex items (0.0 = no growth)
326
+ * How much the flex item should grow relative to other flex items when positive free space is distributed
317
327
  */
318
328
  flex_grow: number;
319
329
  /**
320
- * How much the element should shrink relative to other flex items (0.0 = no shrinking)
330
+ * How much the flex item should shrink relative to other flex items when negative free space is distributed
321
331
  */
322
332
  flex_shrink: number;
323
333
  /**
324
- * Width of the element's border on each side
334
+ * Width of the element's border on each side (top, right, bottom, left)
325
335
  */
326
336
  border_width: SidesValue<LengthUnit>;
327
337
  /**
@@ -329,11 +339,11 @@ export type Style = {
329
339
  */
330
340
  object_fit: ObjectFit;
331
341
  /**
332
- * Element's background color
342
+ * Background color of the element
333
343
  */
334
344
  background_color?: ColorInput;
335
345
  /**
336
- * Box shadow for the element
346
+ * Box shadow effect for the element
337
347
  */
338
348
  box_shadow?: BoxShadowInput;
339
349
  /**
@@ -397,7 +407,7 @@ export type Style = {
397
407
  */
398
408
  line_clamp?: number;
399
409
  /**
400
- * Corner radius for rounded borders in pixels
410
+ * Corner radius for rounded borders
401
411
  */
402
412
  border_radius?: SidesValue<LengthUnit>;
403
413
  /**
@@ -405,8 +415,8 @@ export type Style = {
405
415
  */
406
416
  text_align?: TextAlign;
407
417
  /**
408
- * Letter spacing for text rendering
409
- * Value is measured in EM units
418
+ * Additional spacing between characters in text
419
+ * Positive values increase spacing, negative values decrease spacing
410
420
  */
411
421
  letter_spacing?: LengthUnit;
412
422
  };
@@ -450,7 +460,7 @@ export type InheritableStyle = {
450
460
  */
451
461
  line_clamp?: number;
452
462
  /**
453
- * Corner radius for rounded borders in pixels
463
+ * Corner radius for rounded borders
454
464
  */
455
465
  border_radius?: SidesValue<LengthUnit>;
456
466
  /**
@@ -458,8 +468,8 @@ export type InheritableStyle = {
458
468
  */
459
469
  text_align?: TextAlign;
460
470
  /**
461
- * Letter spacing for text rendering
462
- * Value is measured in EM units
471
+ * Additional spacing between characters in text
472
+ * Positive values increase spacing, negative values decrease spacing
463
473
  */
464
474
  letter_spacing?: LengthUnit;
465
475
  };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- function $(t){return{type:"container",...t}}function C(t,e){return{...e,type:"text",text:t}}function N(t,e){return{...e,type:"image",src:t}}function yt(t){return t}function E(t){return{percentage:t}}function J(t){return{vw:t}}function S(t){return{vh:t}}function j(t){return{em:t}}function G(t){return{rem:t}}function k(t){return{fr:t}}function xt(t,e,o=0){return{from:t,to:e,angle:o}}function B(t){return t.replace(/[A-Z]/g,(e)=>`_${e.toLowerCase()}`)}var F=["-moz-","-webkit-","-o-","-ms-"];function X(t){if(typeof t!=="string")return t;if(M(t))return;if(t[0]==="-"){for(let e of F)if(t.startsWith(e))return t.slice(e.length);throw new Error(`Unsupported prefix in value: ${t}`)}return t}function M(t){return t==="inherit"||t==="initial"||t==="revert"||t==="unset"}function W(t){if(t.length===7)return Number.parseInt(t.slice(1),16);if(t.length===9){let e=Number.parseInt(t.slice(1),16);return[e>>24&255,e>>16&255,e>>8&255,(e&255)/255]}throw new Error(`Invalid hex color: ${t}`)}function c(t){let e=t.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);if(e){let[,o,f,n]=e;return[Number(o),Number(f),Number(n)]}return null}function U(t){let e=t.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/);if(e){let[,o,f,n,r]=e,m=Number(o),y=Number(f),h=Number(n),d=Number(r);if(m<0||m>255||y<0||y>255||h<0||h>255)return null;if(d<0||d>1)return null;return[m,y,h,d]}return null}function s(t){if(t.startsWith("#"))return W(t);if(t.startsWith("rgb(")){let e=c(t);if(e!==null)return e}if(t.startsWith("rgba(")){let e=U(t);if(e!==null)return e}throw new Error(`Invalid RGB color: ${t}`)}function i(t){if(typeof t==="number")return t;if(t==="auto"||t==="min-content"||t==="max-content")return t;let e=t.match(/^(-?[\d.]+)(.*)$/);if(!e)return 0;let[,o,f]=e;if(!o)return 0;let n=Number.parseFloat(o);switch(f){case"%":return E(n);case"rem":return G(n);case"em":return j(n);case"vh":return S(n);case"vw":return J(n);case"px":case"":return n;default:return n}}function x(t){if(typeof t==="number")return i(t);let o=t.trim().split(/\s+/).map(i);if(o.length===1)return o[0];if(o.length===2||o.length===4)return o;if(o.length===3&&o[0]!==void 0&&o[1]!==void 0&&o[2]!==void 0)return[o[0],o[1],o[2],o[1]];throw new Error(`Invalid sides value: ${t}. Expected 1 to at most 4 values.`)}function Z(t){if(t.inset!==void 0)return x(t.inset);let e=t.top!==void 0?i(t.top):void 0,o=t.right!==void 0?i(t.right):void 0,f=t.bottom!==void 0?i(t.bottom):void 0,n=t.left!==void 0?i(t.left):void 0;if(e===void 0&&o===void 0&&f===void 0&&n===void 0)return;return[e??0,o??0,f??0,n??0]}function q(t){if(typeof t==="number")return t;if(typeof t==="string"&&t.includes("/")){let[e,o]=t.split("/").map(Number.parseFloat);if(e===void 0||o===void 0)throw new Error(`Invalid aspect ratio: ${t}. Expected format 'width/height'.`);if(o===0)throw new Error(`Invalid aspect ratio: ${t}. Denominator cannot be zero.`);return e/o}if(typeof t==="string")return Number.parseFloat(t);throw new Error(`Invalid aspect ratio: ${t}`)}function Q(t){switch(t){case"block":case"flex":case"grid":case"none":return t;default:return console.warn(`Invalid display value: ${t}, fallback to 'block'.`),"block"}}function H(t){switch(t){case"relative":case"absolute":return t;case"static":return"relative";default:return console.warn(`Invalid position value: ${t}, fallback to 'relative'.`),"relative"}}function P(t){let e=t.trim().split(/\s+/);if(e.length<2)throw new Error(`Invalid box-shadow: ${t}`);let o=!1,f="black",n=0;if(e[0]==="inset")o=!0,n=1;let r=/^(#|rgb|rgba|hsl|hsla|[a-zA-Z]+)/,m=[];for(let p=n;p<e.length;p++){let w=e[p]??"";if(p===e.length-1&&r.test(w))f=w;else m.push(w)}if(m.length<2||m.length>4)throw new Error(`Invalid box-shadow format: ${t}`);let[y="0px",h="0px",d="0px",O="0px"]=m;try{return{color:s(f),offset_x:i(y)??0,offset_y:i(h)??0,blur_radius:i(d)??0,spread_radius:i(O)??0,inset:o}}catch{throw new Error(`Invalid box-shadow color: ${f}`)}}function a(t){return t.trim().split(/\s+/).map((o)=>{if(o.endsWith("fr")){let f=Number.parseFloat(o.slice(0,-2));if(Number.isNaN(f))return{fr:0};return{fr:f}}return i(o)??0})}function Y(t){switch(t){case"row":case"column":case"row dense":case"column dense":return t.replace(" ","-");default:return console.warn(`Invalid grid-auto-flow value: ${t}, fallback to 'row'.`),"row"}}function V(t){if(t.startsWith("span ")){let o=Number.parseInt(t.slice(5));if(Number.isNaN(o))throw new Error(`Invalid span value: ${t}`);return{start:o,end:null}}if(t.includes("/")){let o=t.split("/");if(o.length!==2)throw new Error(`Invalid grid line format: ${t}`);let[f="",n=""]=o.map((y)=>y.trim()),r=f==="auto"?null:Number.parseInt(f)||f,m=n==="auto"?null:Number.parseInt(n)||n;return{start:r,end:m}}if(t==="auto")return{start:null,end:null};let e=Number.parseInt(t);if(Number.isNaN(e))return{start:t,end:null};return{start:e,end:null}}function g(t){let e=t.match(/repeat\(([^,]+),\s*(.+)\)/);if(e){let o=L(e);if(!o)throw new Error(`Invalid repeat function: ${t}`);return o}return u(t)}function L(t){let[,e,o]=t;if(!e||!o)return;let f;if(e==="auto-fill")f="auto-fill";else if(e==="auto-fit")f="auto-fit";else{let r=Number.parseInt(e);if(Number.isNaN(r))return;f=r}let n=o.trim().split(/\s+/).map((r)=>{if(r.endsWith("fr")){let m=Number.parseFloat(r.slice(0,-2));return Number.isNaN(m)?0:{fr:m}}return i(r)??0});return[{repeat:[f,n]}]}function u(t){return t.trim().split(/\s+/).map((o)=>{if(o.endsWith("fr")){let f=Number.parseFloat(o.slice(0,-2));return{single:Number.isNaN(f)?0:{fr:f}}}return{single:i(o)??0}})}function _(t){if(typeof t==="number")return Math.max(1,Math.min(1000,t));if(typeof t==="string")switch(t){case"normal":return 400;case"bold":return 700;case"lighter":return 300;case"bolder":return 600;default:{let e=Number.parseInt(t);if(!Number.isNaN(e))return Math.max(1,Math.min(1000,e))}}return console.warn(`Invalid font-weight value: ${t}, fallback to 400.`),400}function l(t){if(typeof t==="string")return a(t);if(Array.isArray(t))return t;return typeof t==="number"?[t]:[k(1)]}function A(t){if(typeof t==="string")return V(t);if(typeof t==="number")return{start:t,end:null};return t}function I(t){if(typeof t==="string")return g(t);if(Array.isArray(t))return t;return typeof t==="number"?[{single:t}]:[{single:0}]}function K(t){if(typeof t==="string")return g(t);if(Array.isArray(t))return t;return typeof t==="number"?[{single:t}]:[{single:0}]}function z(t){if(t==="none")return 0;return Number(t)}var b=Symbol("skip-parsing"),v={display:Q,position:H,width:i,height:i,maxWidth:i,maxHeight:i,minWidth:i,minHeight:i,aspectRatio:q,padding:x,margin:x,flexDirection:b,flexWrap:b,justifyContent:(t)=>t,alignContent:(t)=>t,alignItems:(t)=>t,justifyItems:(t)=>t,flexBasis:i,gap:i,flexGrow:(t)=>Number(t),flexShrink:(t)=>Number(t),borderWidth:x,backgroundColor:s,boxShadow:P,objectFit:b,gridAutoColumns:l,gridAutoRows:l,gridAutoFlow:Y,gridColumn:A,gridRow:A,gridTemplateColumns:I,gridTemplateRows:K,textOverflow:(t)=>t,borderColor:s,color:s,fontSize:i,fontFamily:b,lineHeight:i,fontWeight:_,lineClamp:z,borderRadius:(t)=>x(t),textAlign(t){if(t==="match-parent")return void console.warn("Unsupported value for text-align found:",t);return t},letterSpacing:i,inset:(t)=>x(t)},tt=new Set(["top","right","bottom","left"]);function et(t,e,o){if(tt.has(e))return;let f=X(o);if(f===void 0||f===null)return;let n=v[e];if(!n){console.warn(`No parser found for CSS property: ${e}`);return}let r=B(e);if(n===b){t[r]=f;return}try{let m=n(f);if(m!=null&&m!==void 0)t[r]=m}catch(m){console.warn(`Failed to parse ${e}:`,m)}}function D(t){if(!t)return;let e={};for(let[f,n]of Object.entries(t))et(e,f,n);let o=Z(t);if(o!==void 0)e.inset=o;return Object.keys(e).length>0?e:void 0}var ot=Symbol.for("react.transitional.element");function ft(t){return typeof t==="object"&&t!==null&&"$$typeof"in t&&t.$$typeof===ot}async function T(t){if(t===void 0||t===null)return[];if(t instanceof Promise)return T(await t);if(typeof t==="object"&&Symbol.iterator in t)return rt(t);if(ft(t)){let e=await nt(t);return Array.isArray(e)?e:e?[e]:[]}return[C(String(t))]}async function nt(t){if(typeof t.type==="function"){let f=t.type;return T(f(t.props))}if(typeof t.type==="symbol"&&t.type===Symbol.for("react.fragment"))return await R(t)||[];if(mt(t,"img")&&t.props.src)return[N(t.props.src,D(t.props.style))];let e=await R(t),o=it(t.props);return[$({children:e,...D(o)})]}function it(t){return typeof t==="object"&&t&&"style"in t?t.style:void 0}function mt(t,e){return t.type===e}async function R(t){if(typeof t.props!=="object"||t.props===null||!("children"in t.props))return[];return await T(t.props.children)}async function rt(t){return(await Promise.all(Array.from(t).map(T))).flat()}export{J as vw,S as vh,C as text,yt as style,G as rem,E as percentage,N as image,xt as gradient,T as fromJsx,k as fr,j as em,$ as container};
1
+ function C(t){return{type:"container",...t}}function $(t,e){return{...e,type:"text",text:t}}function N(t,e){return{...e,type:"image",src:t}}function rt(t){return t}function E(t){return{percentage:t}}function J(t){return{vw:t}}function S(t){return{vh:t}}function j(t){return{em:t}}function G(t){return{rem:t}}function k(t){return{fr:t}}function xt(t,e,o=0){return{from:t,to:e,angle:o}}function B(t){return t.replace(/[A-Z]/g,(e)=>`_${e.toLowerCase()}`)}var O=["-moz-","-webkit-","-o-","-ms-"];function X(t){if(typeof t!=="string")return t;if(F(t))return;if(t[0]==="-"){for(let e of O)if(t.startsWith(e))return t.slice(e.length);throw new Error(`Unsupported prefix in value: ${t}`)}return t}function F(t){return t==="inherit"||t==="initial"||t==="revert"||t==="unset"}function W(t){if(t.length===7)return Number.parseInt(t.slice(1),16);if(t.length===9){let e=Number.parseInt(t.slice(1),16);return[e>>24&255,e>>16&255,e>>8&255,(e&255)/255]}throw new Error(`Invalid hex color: ${t}`)}function U(t){let e=t.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);if(e){let[,o,f,m]=e;return[Number(o),Number(f),Number(m)]}return null}function V(t){let e=t.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([0-9]*\.?[0-9]+)\s*\)$/);if(e){let[,o,f,m,y]=e,i=Number(o),r=Number(f),s=Number(m),d=Number(y);if(i<0||i>255||r<0||r>255||s<0||s>255)return null;if(d<0||d>1)return null;return[i,r,s,d]}return null}function h(t){if(t.startsWith("#"))return W(t);if(t.startsWith("rgb(")){let e=U(t);if(e!==null)return e}if(t.startsWith("rgba(")){let e=V(t);if(e!==null)return e}throw new Error(`Invalid RGB color: ${t}`)}function n(t){if(typeof t==="number")return t;if(t==="auto"||t==="min-content"||t==="max-content")return t;let e=t.match(/^(-?[\d.]+)(.*)$/);if(!e)return 0;let[,o,f]=e;if(!o)return 0;let m=Number.parseFloat(o);switch(f){case"%":return E(m);case"rem":return G(m);case"em":return j(m);case"vh":return S(m);case"vw":return J(m);case"px":case"":return m;default:return m}}function x(t){if(typeof t==="number")return n(t);let o=t.trim().split(/\s+/).map(n);if(o.length===1)return o[0];if(o.length===2||o.length===4)return o;if(o.length===3&&o[0]!==void 0&&o[1]!==void 0&&o[2]!==void 0)return[o[0],o[1],o[2],o[1]];throw new Error(`Invalid sides value: ${t}. Expected 1 to at most 4 values.`)}function Z(t){if(t.inset!==void 0)return x(t.inset);let e=t.top!==void 0?n(t.top):void 0,o=t.right!==void 0?n(t.right):void 0,f=t.bottom!==void 0?n(t.bottom):void 0,m=t.left!==void 0?n(t.left):void 0;if(e===void 0&&o===void 0&&f===void 0&&m===void 0)return;return[e??0,o??0,f??0,m??0]}function q(t){if(typeof t==="number")return t;if(typeof t==="string"&&t.includes("/")){let[e,o]=t.split("/").map(Number.parseFloat);if(e===void 0||o===void 0)throw new Error(`Invalid aspect ratio: ${t}. Expected format 'width/height'.`);if(o===0)throw new Error(`Invalid aspect ratio: ${t}. Denominator cannot be zero.`);return e/o}if(typeof t==="string")return Number.parseFloat(t);throw new Error(`Invalid aspect ratio: ${t}`)}function Q(t){switch(t){case"block":case"flex":case"grid":case"none":return t;default:return console.warn(`Invalid display value: ${t}, fallback to 'block'.`),"block"}}function H(t){switch(t){case"relative":case"absolute":return t;case"static":return"relative";default:return console.warn(`Invalid position value: ${t}, fallback to 'relative'.`),"relative"}}function P(t){let e=t.trim().split(/\s+/);if(e.length<2)throw new Error(`Invalid box-shadow: ${t}`);let o=!1,f="black",m=0;if(e[0]==="inset")o=!0,m=1;let y=/^(#|rgb|rgba|hsl|hsla|[a-zA-Z]+)/,i=[];for(let b=m;b<e.length;b++){let l=e[b]??"";if(b===e.length-1&&y.test(l))f=l;else i.push(l)}if(i.length<2||i.length>4)throw new Error(`Invalid box-shadow format: ${t}`);let[r="0px",s="0px",d="0px",R="0px"]=i;try{return{color:h(f),offset_x:n(r)??0,offset_y:n(s)??0,blur_radius:n(d)??0,spread_radius:n(R)??0,inset:o}}catch{throw new Error(`Invalid box-shadow color: ${f}`)}}function c(t){return t.trim().split(/\s+/).map((o)=>{if(o.endsWith("fr")){let f=Number.parseFloat(o.slice(0,-2));if(Number.isNaN(f))return{fr:0};return{fr:f}}return n(o)??0})}function Y(t){switch(t){case"row":case"column":case"row dense":case"column dense":return t.replace(" ","-");default:return console.warn(`Invalid grid-auto-flow value: ${t}, fallback to 'row'.`),"row"}}function a(t){if(t.startsWith("span ")){let o=Number.parseInt(t.slice(5));if(Number.isNaN(o))throw new Error(`Invalid span value: ${t}`);return{start:o,end:null}}if(t.includes("/")){let o=t.split("/");if(o.length!==2)throw new Error(`Invalid grid line format: ${t}`);let[f="",m=""]=o.map((r)=>r.trim()),y=f==="auto"?null:Number.parseInt(f)||f,i=m==="auto"?null:Number.parseInt(m)||m;return{start:y,end:i}}if(t==="auto")return{start:null,end:null};let e=Number.parseInt(t);if(Number.isNaN(e))return{start:t,end:null};return{start:e,end:null}}function _(t){let e=t.match(/repeat\(([^,]+),\s*(.+)\)/);if(e){let o=L(e);if(!o)throw new Error(`Invalid repeat function: ${t}`);return o}return u(t)}function L(t){let[,e,o]=t;if(!e||!o)return;let f;if(e==="auto-fill")f="auto-fill";else if(e==="auto-fit")f="auto-fit";else{let y=Number.parseInt(e);if(Number.isNaN(y))return;f=y}let m=o.trim().split(/\s+/).map((y)=>{if(y.endsWith("fr")){let i=Number.parseFloat(y.slice(0,-2));return Number.isNaN(i)?0:{fr:i}}return n(y)??0});return[{repeat:[f,m]}]}function u(t){return t.trim().split(/\s+/).map((o)=>{if(o.endsWith("fr")){let f=Number.parseFloat(o.slice(0,-2));return{single:Number.isNaN(f)?0:{fr:f}}}return{single:n(o)??0}})}function I(t){if(typeof t==="number")return Math.max(1,Math.min(1000,t));if(typeof t==="string")switch(t){case"normal":return 400;case"bold":return 700;case"lighter":return 300;case"bolder":return 600;default:{let e=Number.parseInt(t);if(!Number.isNaN(e))return Math.max(1,Math.min(1000,e))}}return console.warn(`Invalid font-weight value: ${t}, fallback to 400.`),400}function w(t){if(typeof t==="string")return c(t);if(Array.isArray(t))return t;return typeof t==="number"?[t]:[k(1)]}function A(t){if(typeof t==="string")return a(t);if(typeof t==="number")return{start:t,end:null};return t}function K(t){if(typeof t==="string")return _(t);if(Array.isArray(t))return t;return typeof t==="number"?[{single:t}]:[{single:0}]}function g(t){if(typeof t==="string")return _(t);if(Array.isArray(t))return t;return typeof t==="number"?[{single:t}]:[{single:0}]}function z(t){if(t==="none")return 0;return Number(t)}var p=Symbol("skip-parsing"),v={display:Q,position:H,width:n,height:n,maxWidth:n,maxHeight:n,minWidth:n,minHeight:n,aspectRatio:q,padding:x,margin:x,flexDirection:p,flexWrap:p,justifyContent:(t)=>t,alignContent:(t)=>t,justifySelf:(t)=>t,alignItems:(t)=>t,alignSelf:(t)=>t,justifyItems:(t)=>t,flexBasis:n,gap:n,flexGrow:(t)=>Number(t),flexShrink:(t)=>Number(t),borderWidth:x,backgroundColor:h,boxShadow:P,objectFit:p,gridAutoColumns:w,gridAutoRows:w,gridAutoFlow:Y,gridColumn:A,gridRow:A,gridTemplateColumns:K,gridTemplateRows:g,textOverflow:(t)=>t,borderColor:h,color:h,fontSize:n,fontFamily:p,lineHeight:n,fontWeight:I,lineClamp:z,borderRadius:(t)=>x(t),textAlign(t){if(t==="match-parent")return void console.warn("Unsupported value for text-align found:",t);return t},letterSpacing:n,inset:(t)=>x(t)},tt=new Set(["top","right","bottom","left"]);function et(t,e,o){if(tt.has(e))return;let f=X(o);if(f===void 0||f===null)return;let m=v[e];if(!m){console.warn(`No parser found for CSS property: ${e}`);return}let y=B(e);if(m===p){t[y]=f;return}try{let i=m(f);if(i!=null&&i!==void 0)t[y]=i}catch(i){console.warn(`Failed to parse ${e}:`,i)}}function D(t){if(!t)return;let e={};for(let[f,m]of Object.entries(t))et(e,f,m);let o=Z(t);if(o!==void 0)e.inset=o;return Object.keys(e).length>0?e:void 0}var ot=Symbol.for("react.transitional.element");function ft(t){return typeof t==="object"&&t!==null&&"$$typeof"in t&&t.$$typeof===ot}async function T(t){if(t===void 0||t===null)return[];if(t instanceof Promise)return T(await t);if(typeof t==="object"&&Symbol.iterator in t)return yt(t);if(ft(t)){let e=await mt(t);return Array.isArray(e)?e:e?[e]:[]}return[$(String(t))]}async function mt(t){if(typeof t.type==="function"){let f=t.type;return T(f(t.props))}if(typeof t.type==="symbol"&&t.type===Symbol.for("react.fragment"))return await M(t)||[];if(it(t,"img")&&t.props.src)return[N(t.props.src,D(t.props.style))];let e=await M(t),o=nt(t.props);return[C({children:e,...D(o)})]}function nt(t){return typeof t==="object"&&t&&"style"in t?t.style:void 0}function it(t,e){return t.type===e}async function M(t){if(typeof t.props!=="object"||t.props===null||!("children"in t.props))return[];return await T(t.props.children)}async function yt(t){return(await Promise.all(Array.from(t).map(T))).flat()}export{J as vw,S as vh,$ as text,rt as style,G as rem,E as percentage,N as image,xt as gradient,T as fromJsx,k as fr,j as em,C as container};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takumi-rs/helpers",
3
- "version": "0.14.3",
3
+ "version": "0.15.0",
4
4
  "author": {
5
5
  "email": "me@kane.tw",
6
6
  "name": "Kane Wang",