@cronocode/react-box 1.8.0 → 1.8.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/box.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const s=require("react"),u=require("./core.cjs");function d(t,n){const{tag:r="div",children:o,props:i,className:f,style:a}=t,m=u.useStyles(t,r==="svg"),v=s.useMemo(()=>u.classNames(m,f).join(" "),[t]),e={...i,className:v};a&&(e.style=a),n&&(e.ref=n);const[y,c]=s.useState(!1),l=typeof o=="function";return l&&(e.onMouseEnter=()=>c(!0),e.onMouseLeave=()=>c(!1)),s.createElement(r,e,l?o({isHover:y}):o)}const g=s.forwardRef(d);module.exports=g;
1
+ "use strict";const s=require("react"),u=require("./core.cjs");function g(t,a){const{tag:n="div",children:o,props:f,className:d,style:c,disabled:r}=t,y=u.useStyles(t,n==="svg"),m=s.useMemo(()=>u.classNames(y,d).join(" "),[t]),e={...f,className:m,disabled:Array.isArray(r)?r[0]:r};c&&(e.style=c),a&&(e.ref=a);const[v,l]=s.useState(!1),i=typeof o=="function";return i&&(e.onMouseEnter=()=>l(!0),e.onMouseLeave=()=>l(!1)),s.createElement(n,e,i?o({isHover:v}):o)}const N=s.forwardRef(g);module.exports=N;
package/box.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import React, { RefAttributes } from 'react';
1
+ import React, { Ref, RefAttributes } from 'react';
2
2
  import { BoxStyleProps, ExtractElementFromTag } from './core/types';
3
3
  import { ClassNameType } from './core/classNames';
4
4
  type AllProps<TTag extends keyof React.JSX.IntrinsicElements> = React.ComponentProps<TTag>;
5
- type TagPropsType<TTag extends keyof React.JSX.IntrinsicElements> = Omit<AllProps<TTag>, 'className' | 'style' | 'ref'>;
5
+ type TagPropsType<TTag extends keyof React.JSX.IntrinsicElements> = Omit<AllProps<TTag>, 'className' | 'style' | 'ref' | 'disabled'>;
6
6
  interface Props<TTag extends keyof React.JSX.IntrinsicElements> extends BoxStyleProps {
7
7
  children?: React.ReactNode | ((props: {
8
8
  isHover: boolean;
@@ -12,5 +12,8 @@ interface Props<TTag extends keyof React.JSX.IntrinsicElements> extends BoxStyle
12
12
  className?: ClassNameType;
13
13
  style?: React.ComponentProps<TTag>['style'];
14
14
  }
15
+ declare function Box<TTag extends keyof React.JSX.IntrinsicElements = 'div'>(props: Props<TTag>, ref: Ref<ExtractElementFromTag<TTag>>): React.ReactElement<React.ComponentProps<TTag>, string | React.JSXElementConstructor<any>>;
15
16
  declare const _default: <TTag extends keyof React.JSX.IntrinsicElements = "div">(props: Props<TTag> & React.RefAttributes<ExtractElementFromTag<TTag>>) => React.ReactNode;
16
17
  export default _default;
18
+ export type BoxProps<TTag extends keyof React.JSX.IntrinsicElements = 'div'> = React.ComponentProps<typeof Box<TTag>>;
19
+ export type BoxTagProps<TTag extends keyof React.JSX.IntrinsicElements = 'div'> = Required<BoxProps<TTag>>['props'];
package/box.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import v, { forwardRef as d, useMemo as y, useState as g } from "react";
2
- import { u as p, c as N } from "./core.mjs";
3
- function x(s, o) {
4
- const { tag: a = "div", children: t, props: l, className: u, style: n } = s, f = p(s, a === "svg"), i = y(() => N(f, u).join(" "), [s]), e = { ...l, className: i };
1
+ import y, { forwardRef as v, useMemo as g, useState as p } from "react";
2
+ import { u as N, c as x } from "./core.mjs";
3
+ function H(s, o) {
4
+ const { tag: r = "div", children: t, props: i, className: u, style: n, disabled: a } = s, f = N(s, r === "svg"), m = g(() => x(f, u).join(" "), [s]), e = { ...i, className: m, disabled: Array.isArray(a) ? a[0] : a };
5
5
  n && (e.style = n), o && (e.ref = o);
6
- const [m, r] = g(!1), c = typeof t == "function";
7
- return c && (e.onMouseEnter = () => r(!0), e.onMouseLeave = () => r(!1)), v.createElement(a, e, c ? t({ isHover: m }) : t);
6
+ const [d, l] = p(!1), c = typeof t == "function";
7
+ return c && (e.onMouseEnter = () => l(!0), e.onMouseLeave = () => l(!1)), y.createElement(r, e, c ? t({ isHover: d }) : t);
8
8
  }
9
- const S = d(x);
9
+ const $ = v(H);
10
10
  export {
11
- S as default
11
+ $ as default
12
12
  };
@@ -1,9 +1,8 @@
1
1
  /// <reference types="react" />
2
- import Box from '../box';
2
+ import { BoxTagProps } from '../box';
3
3
  import { BoxSvgStyles } from '../core/types';
4
4
  import { ClassNameType } from '../core/classNames';
5
- type SvgTagProps = Required<React.ComponentProps<typeof Box<'svg'>>>['props'];
6
- type BoxSvgTagProps = Omit<SvgTagProps, 'viewBox' | 'width' | 'height'>;
5
+ type BoxSvgTagProps = Omit<BoxTagProps<'svg'>, 'viewBox' | 'width' | 'height'>;
7
6
  interface Props extends BoxSvgStyles {
8
7
  children?: React.ReactNode | ((props: {
9
8
  isHover: boolean;
@@ -1 +1 @@
1
- "use strict";const r=require("react/jsx-runtime"),n=require("react"),s=require("../box.cjs"),u=require("../utils.cjs");require("../core.cjs");const i=["type","onClick","disabled"];function c(t,e){const o=u.ObjectUtils.buildProps(t,i);return r.jsx(s,{ref:e,tag:"button",component:"button",...o})}const b=n.forwardRef(c);module.exports=b;
1
+ "use strict";const r=require("react/jsx-runtime"),n=require("react"),s=require("../box.cjs"),u=require("../utils.cjs");require("../core.cjs");const i=["type","onClick"];function c(t,e){const o=u.ObjectUtils.buildProps(t,i);return r.jsx(s,{ref:e,tag:"button",component:"button",...o})}const b=n.forwardRef(c);module.exports=b;
@@ -2,7 +2,7 @@
2
2
  import Box from '../box';
3
3
  type BoxProps = Omit<React.ComponentProps<typeof Box<'button'>>, 'ref' | 'tag'>;
4
4
  type BoxTagProps = Required<BoxProps>['props'];
5
- declare const tagProps: readonly ["type", "onClick", "disabled"];
5
+ declare const tagProps: readonly ["type", "onClick"];
6
6
  type TagPropsType = (typeof tagProps)[number];
7
7
  type ButtonTagProps = Omit<BoxTagProps, TagPropsType>;
8
8
  type ButtonType = Required<React.ComponentProps<'button'>>['type'];
@@ -1,14 +1,14 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
2
  import { forwardRef as p } from "react";
3
- import s from "../box.mjs";
4
- import { O as i } from "../utils.mjs";
3
+ import m from "../box.mjs";
4
+ import { O as s } from "../utils.mjs";
5
5
  import "../core.mjs";
6
- const m = ["type", "onClick", "disabled"];
6
+ const i = ["type", "onClick"];
7
7
  function e(o, t) {
8
- const r = i.buildProps(o, m);
9
- return /* @__PURE__ */ n(s, { ref: t, tag: "button", component: "button", ...r });
8
+ const r = s.buildProps(o, i);
9
+ return /* @__PURE__ */ n(m, { ref: t, tag: "button", component: "button", ...r });
10
10
  }
11
- const d = p(e);
11
+ const l = p(e);
12
12
  export {
13
- d as default
13
+ l as default
14
14
  };
@@ -1 +1 @@
1
- "use strict";const t=require("react/jsx-runtime"),c=require("react"),n=require("../box.cjs"),s=require("../utils.cjs");require("../core.cjs");const u=["name","onInput","onChange","disabled","autoFocus","readOnly","required","value","checked","defaultChecked"];function i(e,o){const r=s.ObjectUtils.buildProps(e,u,{type:"checkbox"});return t.jsx(n,{ref:o,tag:"input",component:"checkbox",...r})}const a=c.forwardRef(i);module.exports=a;
1
+ "use strict";const u=require("react/jsx-runtime"),c=require("react"),i=require("../box.cjs"),s=require("../utils.cjs");require("../core.cjs");const a=["name","onInput","onChange","autoFocus","readOnly","required","value","checked","defaultChecked"];function l(o,e){const{indeterminate:n}=o,r=s.ObjectUtils.buildProps(o,a,{type:"checkbox"}),t=c.useRef(null);return c.useEffect(()=>{e&&typeof e!="function"&&e.current?e.current.indeterminate=!!n:t.current&&(t.current.indeterminate=!!n)},[e,t,n]),u.jsx(i,{tag:"input",ref:e||t,component:"checkbox",...r})}const d=c.forwardRef(l);module.exports=d;
@@ -1,11 +1,10 @@
1
1
  import React from 'react';
2
- import Box from '../box';
3
- type BoxProps = Omit<React.ComponentProps<typeof Box<'input'>>, 'ref' | 'tag'>;
4
- type BoxTagProps = Required<BoxProps>['props'];
5
- declare const tagProps: readonly ["name", "onInput", "onChange", "disabled", "autoFocus", "readOnly", "required", "value", "checked", "defaultChecked"];
2
+ import { BoxTagProps, BoxProps } from '../box';
3
+ declare const tagProps: readonly ["name", "onInput", "onChange", "autoFocus", "readOnly", "required", "value", "checked", "defaultChecked"];
6
4
  type TagPropsType = (typeof tagProps)[number];
7
- type CheckboxTagProps = Omit<BoxTagProps, TagPropsType | 'type'>;
8
- interface Props extends Omit<BoxProps, 'props'> {
5
+ type CheckboxProps = Omit<BoxProps<'input'>, 'tag' | 'props'>;
6
+ type CheckboxTagProps = Omit<BoxTagProps<'input'>, TagPropsType | 'type'>;
7
+ interface Props extends CheckboxProps {
9
8
  name?: string;
10
9
  props?: CheckboxTagProps;
11
10
  onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
@@ -16,6 +15,7 @@ interface Props extends Omit<BoxProps, 'props'> {
16
15
  required?: boolean;
17
16
  checked?: boolean;
18
17
  defaultChecked?: boolean;
18
+ indeterminate?: boolean;
19
19
  }
20
20
  declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
21
21
  export default _default;
@@ -1,25 +1,16 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
- import { forwardRef as c } from "react";
3
- import n from "../box.mjs";
4
- import { O as a } from "../utils.mjs";
2
+ import { forwardRef as i, useRef as u, useEffect as a } from "react";
3
+ import s from "../box.mjs";
4
+ import { O as m } from "../utils.mjs";
5
5
  import "../core.mjs";
6
- const p = [
7
- "name",
8
- "onInput",
9
- "onChange",
10
- "disabled",
11
- "autoFocus",
12
- "readOnly",
13
- "required",
14
- "value",
15
- "checked",
16
- "defaultChecked"
17
- ];
18
- function s(o, e) {
19
- const t = a.buildProps(o, p, { type: "checkbox" });
20
- return /* @__PURE__ */ r(n, { ref: e, tag: "input", component: "checkbox", ...t });
6
+ const f = ["name", "onInput", "onChange", "autoFocus", "readOnly", "required", "value", "checked", "defaultChecked"];
7
+ function p(n, e) {
8
+ const { indeterminate: t } = n, c = m.buildProps(n, f, { type: "checkbox" }), o = u(null);
9
+ return a(() => {
10
+ e && typeof e != "function" && e.current ? e.current.indeterminate = !!t : o.current && (o.current.indeterminate = !!t);
11
+ }, [e, o, t]), /* @__PURE__ */ r(s, { tag: "input", ref: e || o, component: "checkbox", ...c });
21
12
  }
22
- const b = c(s);
13
+ const k = i(p);
23
14
  export {
24
- b as default
15
+ k as default
25
16
  };
@@ -1 +1 @@
1
- "use strict";const r=require("react/jsx-runtime"),n=require("react"),u=require("../box.cjs"),i=require("../utils.cjs");require("../core.cjs");const s=["name","onInput","onChange","disabled","value","autoFocus","readOnly","required","checked","defaultChecked"];function c(e,t){const o=i.ObjectUtils.buildProps(e,s,{type:"radio"});return r.jsx(u,{ref:t,tag:"input",component:"radioButton",...o})}const a=n.forwardRef(c);module.exports=a;
1
+ "use strict";const r=require("react/jsx-runtime"),n=require("react"),u=require("../box.cjs"),i=require("../utils.cjs");require("../core.cjs");const s=["name","onInput","onChange","value","autoFocus","readOnly","required","checked","defaultChecked"];function c(e,t){const o=i.ObjectUtils.buildProps(e,s,{type:"radio"});return r.jsx(u,{ref:t,tag:"input",component:"radioButton",...o})}const a=n.forwardRef(c);module.exports=a;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import Box from '../box';
3
3
  type BoxProps = Omit<React.ComponentProps<typeof Box<'input'>>, 'ref' | 'tag'>;
4
4
  type BoxTagProps = Required<BoxProps>['props'];
5
- declare const tagProps: readonly ["name", "onInput", "onChange", "disabled", "value", "autoFocus", "readOnly", "required", "checked", "defaultChecked"];
5
+ declare const tagProps: readonly ["name", "onInput", "onChange", "value", "autoFocus", "readOnly", "required", "checked", "defaultChecked"];
6
6
  type TagPropsType = (typeof tagProps)[number];
7
7
  type RadioButtonTagProps = Omit<BoxTagProps, TagPropsType | 'type'>;
8
8
  interface Props extends Omit<BoxProps, 'props'> {
@@ -3,23 +3,12 @@ import { forwardRef as n } from "react";
3
3
  import a from "../box.mjs";
4
4
  import { O as i } from "../utils.mjs";
5
5
  import "../core.mjs";
6
- const d = [
7
- "name",
8
- "onInput",
9
- "onChange",
10
- "disabled",
11
- "value",
12
- "autoFocus",
13
- "readOnly",
14
- "required",
15
- "checked",
16
- "defaultChecked"
17
- ];
18
- function u(o, t) {
19
- const r = i.buildProps(o, d, { type: "radio" });
6
+ const u = ["name", "onInput", "onChange", "value", "autoFocus", "readOnly", "required", "checked", "defaultChecked"];
7
+ function p(o, t) {
8
+ const r = i.buildProps(o, u, { type: "radio" });
20
9
  return /* @__PURE__ */ e(a, { ref: t, tag: "input", component: "radioButton", ...r });
21
10
  }
22
- const l = n(u);
11
+ const l = n(p);
23
12
  export {
24
13
  l as default
25
14
  };
@@ -1 +1 @@
1
- "use strict";const n=require("react/jsx-runtime"),o=require("react"),a=require("../box.cjs"),s=require("../utils.cjs");require("../core.cjs");const u=["name","onInput","onChange","placeholder","disabled","value","defaultValue","rows","cols","autoFocus","maxLength","minLength","readOnly","required"];function i(e,t){const r=s.ObjectUtils.buildProps(e,u);return n.jsx(a,{ref:t,tag:"textarea",component:"textarea",...r})}const c=o.forwardRef(i);module.exports=c;
1
+ "use strict";const n=require("react/jsx-runtime"),o=require("react"),a=require("../box.cjs"),s=require("../utils.cjs");require("../core.cjs");const u=["name","onInput","onChange","placeholder","value","defaultValue","rows","cols","autoFocus","maxLength","minLength","readOnly","required"];function c(e,t){const r=s.ObjectUtils.buildProps(e,u);return n.jsx(a,{ref:t,tag:"textarea",component:"textarea",...r})}const i=o.forwardRef(c);module.exports=i;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import Box from '../box';
3
3
  type BoxProps = Omit<React.ComponentProps<typeof Box<'textarea'>>, 'ref' | 'tag'>;
4
4
  type BoxTagProps = Required<BoxProps>['props'];
5
- declare const tagProps: readonly ["name", "onInput", "onChange", "placeholder", "disabled", "value", "defaultValue", "rows", "cols", "autoFocus", "maxLength", "minLength", "readOnly", "required"];
5
+ declare const tagProps: readonly ["name", "onInput", "onChange", "placeholder", "value", "defaultValue", "rows", "cols", "autoFocus", "maxLength", "minLength", "readOnly", "required"];
6
6
  type TagPropsType = (typeof tagProps)[number];
7
7
  type TextareaTagProps = Omit<BoxTagProps, TagPropsType>;
8
8
  interface Props extends Omit<BoxProps, 'props'> {
@@ -1,14 +1,13 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
2
  import { forwardRef as a } from "react";
3
3
  import n from "../box.mjs";
4
- import { O as s } from "../utils.mjs";
4
+ import { O as m } from "../utils.mjs";
5
5
  import "../core.mjs";
6
- const m = [
6
+ const s = [
7
7
  "name",
8
8
  "onInput",
9
9
  "onChange",
10
10
  "placeholder",
11
- "disabled",
12
11
  "value",
13
12
  "defaultValue",
14
13
  "rows",
@@ -19,11 +18,11 @@ const m = [
19
18
  "readOnly",
20
19
  "required"
21
20
  ];
22
- function p(t, e) {
23
- const o = s.buildProps(t, m);
24
- return /* @__PURE__ */ r(n, { ref: e, tag: "textarea", component: "textarea", ...o });
21
+ function p(t, o) {
22
+ const e = m.buildProps(t, s);
23
+ return /* @__PURE__ */ r(n, { ref: o, tag: "textarea", component: "textarea", ...e });
25
24
  }
26
- const f = a(p);
25
+ const x = a(p);
27
26
  export {
28
- f as default
27
+ x as default
29
28
  };
@@ -1 +1 @@
1
- "use strict";const o=require("react/jsx-runtime"),n=require("react"),u=require("../box.cjs"),s=require("../utils.cjs");require("../core.cjs");const i=["name","onInput","onChange","type","placeholder","disabled","defaultValue","autoFocus","readOnly","required","value","pattern"];function a(e,t){const r=s.ObjectUtils.buildProps(e,i);return o.jsx(u,{ref:t,tag:"input",component:"textbox",...r})}const c=n.forwardRef(a);module.exports=c;
1
+ "use strict";const o=require("react/jsx-runtime"),n=require("react"),u=require("../box.cjs"),s=require("../utils.cjs");require("../core.cjs");const i=["name","onInput","onChange","type","placeholder","defaultValue","autoFocus","readOnly","required","value","pattern"];function c(e,t){const r=s.ObjectUtils.buildProps(e,i);return o.jsx(u,{ref:t,tag:"input",component:"textbox",...r})}const a=n.forwardRef(c);module.exports=a;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import Box from '../box';
3
3
  type BoxProps = Omit<React.ComponentProps<typeof Box<'input'>>, 'ref' | 'tag'>;
4
4
  type BoxTagProps = Required<BoxProps>['props'];
5
- declare const tagProps: readonly ["name", "onInput", "onChange", "type", "placeholder", "disabled", "defaultValue", "autoFocus", "readOnly", "required", "value", "pattern"];
5
+ declare const tagProps: readonly ["name", "onInput", "onChange", "type", "placeholder", "defaultValue", "autoFocus", "readOnly", "required", "value", "pattern"];
6
6
  type TagPropsType = (typeof tagProps)[number];
7
7
  type TextboxTagProps = Omit<BoxTagProps, TagPropsType>;
8
8
  type TextboxType = 'date' | 'datetime-local' | 'email' | 'hidden' | 'month' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url' | 'week';
@@ -3,13 +3,12 @@ import { forwardRef as n } from "react";
3
3
  import a from "../box.mjs";
4
4
  import { O as p } from "../utils.mjs";
5
5
  import "../core.mjs";
6
- const s = [
6
+ const u = [
7
7
  "name",
8
8
  "onInput",
9
9
  "onChange",
10
10
  "type",
11
11
  "placeholder",
12
- "disabled",
13
12
  "defaultValue",
14
13
  "autoFocus",
15
14
  "readOnly",
@@ -17,11 +16,11 @@ const s = [
17
16
  "value",
18
17
  "pattern"
19
18
  ];
20
- function u(o, t) {
21
- const e = p.buildProps(o, s);
19
+ function m(o, t) {
20
+ const e = p.buildProps(o, u);
22
21
  return /* @__PURE__ */ r(a, { ref: t, tag: "input", component: "textbox", ...e });
23
22
  }
24
- const x = n(u);
23
+ const c = n(m);
25
24
  export {
26
- x as default
25
+ c as default
27
26
  };