@takumi-rs/helpers 0.25.0 → 0.26.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.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/jsx/jsx.cjs +1 -1
- package/dist/jsx/jsx.d.cts +2 -2
- package/dist/jsx/jsx.d.ts +2 -2
- package/dist/jsx/jsx.js +1 -1
- package/dist/{types-CrwAkSRU.d.cts → types-kk-nArin.d.cts} +17 -7
- package/dist/{types-CrwAkSRU.d.ts → types-kk-nArin.d.ts} +17 -7
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},d=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of a(t))!c.call(e,r)&&r!==n&&i(e,r,{get:()=>t[r],enumerable:!(o=m(t,r))||o.enumerable});return e};var y=e=>d(i({},"__esModule",{value:!0}),e);var P={};p(P,{container:()=>f,em:()=>C,fr:()=>h,image:()=>x,percentage:()=>b,rem:()=>S,rgba:()=>I,style:()=>N,text:()=>l,vh:()=>s,vw:()=>g});module.exports=y(P);function u(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function f(e){let t={type:"container",children:e.children};return u(t,e.style),t}function l(e,t){let n={type:"text",text:e};return u(n,t),n}function x(e){let t={type:"image",src:e.src};return u(t,e.style),t}function N(e){return e}function b(e){return{percentage:e}}function g(e){return{vw:e}}function s(e){return{vh:e}}function C(e){return{em:e}}function S(e){return{rem:e}}function h(e){return{fr:e}}function I(e,t,n,o=1){return[e,t,n,o]}0&&(module.exports={container,em,fr,image,percentage,rem,rgba,style,text,vh,vw});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { C as ContainerNode, P as PartialStyle, T as TextNode, I as ImageNode, S as Style, a as Color } from './types-
|
|
2
|
-
export { N as Node } from './types-
|
|
1
|
+
import { C as ContainerNode, P as PartialStyle, T as TextNode, I as ImageNode, S as Style, a as Color } from './types-kk-nArin.cjs';
|
|
2
|
+
export { A as AnyNode, J as JsonValue, N as Node } from './types-kk-nArin.cjs';
|
|
3
3
|
|
|
4
4
|
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
5
5
|
declare function text(text: string, style?: PartialStyle): TextNode;
|
|
6
|
-
declare function image(
|
|
6
|
+
declare function image(props: Omit<ImageNode, "type">): ImageNode;
|
|
7
7
|
declare function style(style: PartialStyle): Partial<Style>;
|
|
8
8
|
/**
|
|
9
9
|
* Convert a number to a percentage struct.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { C as ContainerNode, P as PartialStyle, T as TextNode, I as ImageNode, S as Style, a as Color } from './types-
|
|
2
|
-
export { N as Node } from './types-
|
|
1
|
+
import { C as ContainerNode, P as PartialStyle, T as TextNode, I as ImageNode, S as Style, a as Color } from './types-kk-nArin.js';
|
|
2
|
+
export { A as AnyNode, J as JsonValue, N as Node } from './types-kk-nArin.js';
|
|
3
3
|
|
|
4
4
|
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
5
5
|
declare function text(text: string, style?: PartialStyle): TextNode;
|
|
6
|
-
declare function image(
|
|
6
|
+
declare function image(props: Omit<ImageNode, "type">): ImageNode;
|
|
7
7
|
declare function style(style: PartialStyle): Partial<Style>;
|
|
8
8
|
/**
|
|
9
9
|
* Convert a number to a percentage struct.
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function r(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function i(e){let t={type:"container",children:e.children};return r(t,e.style),t}function u(e,t){let n={type:"text",text:e};return r(n,t),n}function m(e){let t={type:"image",src:e.src};return r(t,e.style),t}function a(e){return e}function c(e){return{percentage:e}}function p(e){return{vw:e}}function d(e){return{vh:e}}function y(e){return{em:e}}function f(e){return{rem:e}}function l(e){return{fr:e}}function x(e,t,n,o=1){return[e,t,n,o]}export{i as container,y as em,l as fr,m as image,c as percentage,f as rem,x as rgba,a as style,u as text,d as vh,p as vw};
|
package/dist/jsx/jsx.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var r in e)s(t,r,{get:e[r],enumerable:!0})},k=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of N(e))!w.call(t,i)&&i!==r&&s(t,i,{get:()=>e[i],enumerable:!(o=R(e,i))||o.enumerable});return t};var C=t=>k(s({},"__esModule",{value:!0}),t);var M={};x(M,{fromJsx:()=>v});module.exports=C(M);var S=require("react"),h=require("react-dom/server");function p(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function c(t){let e={type:"container",children:t.children};return p(e,t.style),e}function m(t,e){let r={type:"text",text:t};return p(r,e),r}function f(t){let e={type:"image",src:t.src};return p(e,t.style),e}function u(t){return{percentage:t}}function n(t){return{em:t}}function d(t,e,r,o=1){return[t,e,r,o]}var y={p:{margin:[n(1),0]},blockquote:{margin:[n(1),40]},center:{textAlign:"center"},hr:{margin:[n(.5),"auto"],borderWidth:1},h1:{fontSize:n(2),margin:[n(.67),0],fontWeight:700},h2:{fontSize:n(1.5),margin:[n(.83),0],fontWeight:700},h3:{fontSize:n(1.17),margin:[n(1),0],fontWeight:700},h4:{margin:[n(1.33),0],fontWeight:700},h5:{fontSize:n(.83),margin:[n(1.67),0],fontWeight:700},h6:{fontSize:n(.67),margin:[n(2.33),0],fontWeight:700},strong:{fontWeight:700},b:{fontWeight:700},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{fontFamily:"monospace",margin:[n(1),0]},mark:{backgroundColor:d(255,255,0),color:0},big:{fontSize:n(1.2)},small:{fontSize:n(1/1.2)}};var T=Symbol.for("react.transitional.element"),A=Symbol.for("react.element"),I=Symbol.for("react.forward_ref"),$=Symbol.for("react.memo");function _(t){return typeof t=="object"&&t!==null&&"$$typeof"in t&&(t.$$typeof===T||t.$$typeof===A)}async function v(t){let e=await a(t);return e.length===0?c({}):e.length===1&&e[0]!==void 0?e[0]:c({children:e,style:{width:u(100),height:u(100)}})}async function a(t){if(t==null)return[];if(t instanceof Promise)return a(await t);if(typeof t=="object"&&Symbol.iterator in t)return L(t);if(_(t)){let e=await P(t);return Array.isArray(e)?e:e?[e]:[]}return[m(String(t))]}function b(t){return typeof t=="function"}function F(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof===I&&e.render)return a(e.render(t.props,null))}function W(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof!==$)return;let r=e.type;if(b(r))return a(r(t.props));let o={...t,type:r};return P(o)}async function P(t){if(b(t.type))return a(t.type(t.props));let e=F(t);if(e!==void 0)return e;let r=W(t);if(r!==void 0)return r;if(typeof t.type=="symbol"&&t.type===Symbol.for("react.fragment"))return await E(t)||[];if(g(t,"img"))return[O(t)];if(g(t,"svg"))return[j(t)];let o=await E(t),i=l(t.props);return typeof t.type=="string"&&t.type in y&&Object.assign(i,y[t.type]),[c({children:o,style:i})]}function O(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=l(t.props);return f({src:t.props.src,style:e})}function j(t){let e=l(t.props),r=(0,h.renderToStaticMarkup)((0,S.cloneElement)(t,{xmlns:"http://www.w3.org/2000/svg",...t.props},t.props.children));return f({src:r,style:e})}function l(t){return typeof t!="object"||t===null?{}:"style"in t&&typeof t.style=="object"?t.style:{}}function g(t,e){return t.type===e}function E(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):a(t.props.children)}async function L(t){return(await Promise.all(Array.from(t).map(a))).flat()}0&&(module.exports={fromJsx});
|
package/dist/jsx/jsx.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { N as Node } from '../types-
|
|
2
|
+
import { N as Node } from '../types-kk-nArin.cjs';
|
|
3
3
|
|
|
4
|
-
declare function fromJsx(element: ReactNode): Promise<Node
|
|
4
|
+
declare function fromJsx(element: ReactNode): Promise<Node>;
|
|
5
5
|
|
|
6
6
|
export { fromJsx };
|
package/dist/jsx/jsx.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { N as Node } from '../types-
|
|
2
|
+
import { N as Node } from '../types-kk-nArin.js';
|
|
3
3
|
|
|
4
|
-
declare function fromJsx(element: ReactNode): Promise<Node
|
|
4
|
+
declare function fromJsx(element: ReactNode): Promise<Node>;
|
|
5
5
|
|
|
6
6
|
export { fromJsx };
|
package/dist/jsx/jsx.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cloneElement as
|
|
1
|
+
import{cloneElement as h}from"react";import{renderToStaticMarkup as b}from"react-dom/server";function c(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function a(t){let e={type:"container",children:t.children};return c(e,t.style),e}function l(t,e){let n={type:"text",text:t};return c(n,e),n}function s(t){let e={type:"image",src:t.src};return c(e,t.style),e}function p(t){return{percentage:t}}function r(t){return{em:t}}function m(t,e,n,i=1){return[t,e,n,i]}var f={p:{margin:[r(1),0]},blockquote:{margin:[r(1),40]},center:{textAlign:"center"},hr:{margin:[r(.5),"auto"],borderWidth:1},h1:{fontSize:r(2),margin:[r(.67),0],fontWeight:700},h2:{fontSize:r(1.5),margin:[r(.83),0],fontWeight:700},h3:{fontSize:r(1.17),margin:[r(1),0],fontWeight:700},h4:{margin:[r(1.33),0],fontWeight:700},h5:{fontSize:r(.83),margin:[r(1.67),0],fontWeight:700},h6:{fontSize:r(.67),margin:[r(2.33),0],fontWeight:700},strong:{fontWeight:700},b:{fontWeight:700},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{fontFamily:"monospace",margin:[r(1),0]},mark:{backgroundColor:m(255,255,0),color:0},big:{fontSize:r(1.2)},small:{fontSize:r(1/1.2)}};var P=Symbol.for("react.transitional.element"),R=Symbol.for("react.element"),N=Symbol.for("react.forward_ref"),w=Symbol.for("react.memo");function x(t){return typeof t=="object"&&t!==null&&"$$typeof"in t&&(t.$$typeof===P||t.$$typeof===R)}async function M(t){let e=await o(t);return e.length===0?a({}):e.length===1&&e[0]!==void 0?e[0]:a({children:e,style:{width:p(100),height:p(100)}})}async function o(t){if(t==null)return[];if(t instanceof Promise)return o(await t);if(typeof t=="object"&&Symbol.iterator in t)return I(t);if(x(t)){let e=await S(t);return Array.isArray(e)?e:e?[e]:[]}return[l(String(t))]}function E(t){return typeof t=="function"}function k(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof===N&&e.render)return o(e.render(t.props,null))}function C(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof!==w)return;let n=e.type;if(E(n))return o(n(t.props));let i={...t,type:n};return S(i)}async function S(t){if(E(t.type))return o(t.type(t.props));let e=k(t);if(e!==void 0)return e;let n=C(t);if(n!==void 0)return n;if(typeof t.type=="symbol"&&t.type===Symbol.for("react.fragment"))return await g(t)||[];if(d(t,"img"))return[T(t)];if(d(t,"svg"))return[A(t)];let i=await g(t),y=u(t.props);return typeof t.type=="string"&&t.type in f&&Object.assign(y,f[t.type]),[a({children:i,style:y})]}function T(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=u(t.props);return s({src:t.props.src,style:e})}function A(t){let e=u(t.props),n=b(h(t,{xmlns:"http://www.w3.org/2000/svg",...t.props},t.props.children));return s({src:n,style:e})}function u(t){return typeof t!="object"||t===null?{}:"style"in t&&typeof t.style=="object"?t.style:{}}function d(t,e){return t.type===e}function g(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):o(t.props.children)}async function I(t){return(await Promise.all(Array.from(t).map(o))).flat()}export{M as fromJsx};
|
|
@@ -17,7 +17,7 @@ type Color = [number, number, number] | [number, number, number, number] | numbe
|
|
|
17
17
|
* This corresponds to CSS values that can be specified as pixels, percentages,
|
|
18
18
|
* or the 'auto' keyword for automatic sizing.
|
|
19
19
|
*/
|
|
20
|
-
type LengthUnit = "auto" |
|
|
20
|
+
type LengthUnit = "auto" | {
|
|
21
21
|
"percentage": number;
|
|
22
22
|
} | {
|
|
23
23
|
"rem": number;
|
|
@@ -223,6 +223,11 @@ type ImageScalingAlgorithm = "auto" | "smooth" | "pixelated";
|
|
|
223
223
|
*/
|
|
224
224
|
type JustifyContent = "start" | "end" | "flex-start" | "flex-end" | "center" | "stretch" | "space-between" | "space-evenly" | "space-around";
|
|
225
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Represents a line height value, number value is parsed as em.
|
|
228
|
+
*/
|
|
229
|
+
type LineHeight = number | string | LengthUnit;
|
|
230
|
+
|
|
226
231
|
/**
|
|
227
232
|
* Represents an angle value in degrees.
|
|
228
233
|
*/
|
|
@@ -558,9 +563,9 @@ type Style = {
|
|
|
558
563
|
*/
|
|
559
564
|
fontFamily?: FontFamily;
|
|
560
565
|
/**
|
|
561
|
-
* Line height for text spacing.
|
|
566
|
+
* Line height for text spacing, number is em.
|
|
562
567
|
*/
|
|
563
|
-
lineHeight?:
|
|
568
|
+
lineHeight?: LineHeight;
|
|
564
569
|
/**
|
|
565
570
|
* Font weight for text rendering.
|
|
566
571
|
*/
|
|
@@ -612,17 +617,22 @@ type AnyNode = {
|
|
|
612
617
|
};
|
|
613
618
|
type PartialStyle = Partial<Style>;
|
|
614
619
|
type Node = ContainerNode | TextNode | ImageNode | AnyNode;
|
|
615
|
-
type ContainerNode =
|
|
620
|
+
type ContainerNode = {
|
|
616
621
|
type: "container";
|
|
622
|
+
style?: PartialStyle;
|
|
617
623
|
children?: Node[];
|
|
618
624
|
};
|
|
619
|
-
type TextNode =
|
|
625
|
+
type TextNode = {
|
|
620
626
|
type: "text";
|
|
621
627
|
text: string;
|
|
628
|
+
style?: PartialStyle;
|
|
622
629
|
};
|
|
623
|
-
type ImageNode =
|
|
630
|
+
type ImageNode = {
|
|
624
631
|
type: "image";
|
|
625
632
|
src: string;
|
|
633
|
+
width?: number;
|
|
634
|
+
height?: number;
|
|
635
|
+
style?: PartialStyle;
|
|
626
636
|
};
|
|
627
637
|
|
|
628
|
-
export type { ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, Style as S, TextNode as T, Color as a };
|
|
638
|
+
export type { AnyNode as A, ContainerNode as C, ImageNode as I, JsonValue as J, Node as N, PartialStyle as P, Style as S, TextNode as T, Color as a };
|
|
@@ -17,7 +17,7 @@ type Color = [number, number, number] | [number, number, number, number] | numbe
|
|
|
17
17
|
* This corresponds to CSS values that can be specified as pixels, percentages,
|
|
18
18
|
* or the 'auto' keyword for automatic sizing.
|
|
19
19
|
*/
|
|
20
|
-
type LengthUnit = "auto" |
|
|
20
|
+
type LengthUnit = "auto" | {
|
|
21
21
|
"percentage": number;
|
|
22
22
|
} | {
|
|
23
23
|
"rem": number;
|
|
@@ -223,6 +223,11 @@ type ImageScalingAlgorithm = "auto" | "smooth" | "pixelated";
|
|
|
223
223
|
*/
|
|
224
224
|
type JustifyContent = "start" | "end" | "flex-start" | "flex-end" | "center" | "stretch" | "space-between" | "space-evenly" | "space-around";
|
|
225
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Represents a line height value, number value is parsed as em.
|
|
228
|
+
*/
|
|
229
|
+
type LineHeight = number | string | LengthUnit;
|
|
230
|
+
|
|
226
231
|
/**
|
|
227
232
|
* Represents an angle value in degrees.
|
|
228
233
|
*/
|
|
@@ -558,9 +563,9 @@ type Style = {
|
|
|
558
563
|
*/
|
|
559
564
|
fontFamily?: FontFamily;
|
|
560
565
|
/**
|
|
561
|
-
* Line height for text spacing.
|
|
566
|
+
* Line height for text spacing, number is em.
|
|
562
567
|
*/
|
|
563
|
-
lineHeight?:
|
|
568
|
+
lineHeight?: LineHeight;
|
|
564
569
|
/**
|
|
565
570
|
* Font weight for text rendering.
|
|
566
571
|
*/
|
|
@@ -612,17 +617,22 @@ type AnyNode = {
|
|
|
612
617
|
};
|
|
613
618
|
type PartialStyle = Partial<Style>;
|
|
614
619
|
type Node = ContainerNode | TextNode | ImageNode | AnyNode;
|
|
615
|
-
type ContainerNode =
|
|
620
|
+
type ContainerNode = {
|
|
616
621
|
type: "container";
|
|
622
|
+
style?: PartialStyle;
|
|
617
623
|
children?: Node[];
|
|
618
624
|
};
|
|
619
|
-
type TextNode =
|
|
625
|
+
type TextNode = {
|
|
620
626
|
type: "text";
|
|
621
627
|
text: string;
|
|
628
|
+
style?: PartialStyle;
|
|
622
629
|
};
|
|
623
|
-
type ImageNode =
|
|
630
|
+
type ImageNode = {
|
|
624
631
|
type: "image";
|
|
625
632
|
src: string;
|
|
633
|
+
width?: number;
|
|
634
|
+
height?: number;
|
|
635
|
+
style?: PartialStyle;
|
|
626
636
|
};
|
|
627
637
|
|
|
628
|
-
export type { ContainerNode as C, ImageNode as I, Node as N, PartialStyle as P, Style as S, TextNode as T, Color as a };
|
|
638
|
+
export type { AnyNode as A, ContainerNode as C, ImageNode as I, JsonValue as J, Node as N, PartialStyle as P, Style as S, TextNode as T, Color as a };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takumi-rs/helpers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"email": "me@kane.tw",
|
|
6
6
|
"name": "Kane Wang",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"@types/react": "^19.1.10",
|
|
15
15
|
"@types/react-dom": "^19.1.7",
|
|
16
16
|
"bun-plugin-dts": "^0.3.0",
|
|
17
|
+
"lucide-react": "^0.540.0",
|
|
17
18
|
"react": "^19.1.0",
|
|
18
19
|
"tsup": "^8.5.0",
|
|
19
20
|
"typescript": "catalog:"
|