@cronocode/react-box 2.0.6 → 3.0.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.
Files changed (53) hide show
  1. package/box.cjs +1 -1
  2. package/box.d.ts +13 -7
  3. package/box.mjs +15 -9
  4. package/components/baseSvg.d.ts +3 -4
  5. package/components/button.cjs +1 -1
  6. package/components/button.d.ts +0 -1
  7. package/components/button.mjs +1 -1
  8. package/components/checkbox.cjs +1 -1
  9. package/components/checkbox.d.ts +2 -5
  10. package/components/checkbox.mjs +10 -10
  11. package/components/dataGrid/dataGridContract.d.ts +19 -11
  12. package/components/dataGrid/useGridData.d.ts +7 -0
  13. package/components/dataGrid.cjs +1 -1
  14. package/components/dataGrid.d.ts +5 -3
  15. package/components/dataGrid.mjs +17 -28
  16. package/components/flex.d.ts +3 -5
  17. package/components/form.cjs +1 -1
  18. package/components/form.d.ts +0 -1
  19. package/components/form.mjs +1 -1
  20. package/components/grid.d.ts +3 -5
  21. package/components/label.d.ts +0 -1
  22. package/components/radioButton.cjs +1 -1
  23. package/components/radioButton.d.ts +1 -3
  24. package/components/radioButton.mjs +9 -9
  25. package/components/textarea.cjs +1 -1
  26. package/components/textarea.d.ts +1 -2
  27. package/components/textarea.mjs +8 -9
  28. package/components/textbox.cjs +1 -1
  29. package/components/textbox.d.ts +0 -2
  30. package/components/textbox.mjs +1 -1
  31. package/components/tooltip.cjs +1 -1
  32. package/components/tooltip.d.ts +1 -2
  33. package/components/tooltip.mjs +34 -40
  34. package/core/boxExtends.d.ts +6 -0
  35. package/core/boxStyles.d.ts +701 -1217
  36. package/core/boxStylesFormatters.d.ts +2 -2
  37. package/core/coreTypes.d.ts +31 -0
  38. package/core/theme.d.ts +13 -32
  39. package/core/useStyles.d.ts +12 -3
  40. package/core/useTheme.d.ts +7 -10
  41. package/core.cjs +4 -34
  42. package/core.mjs +1397 -1158
  43. package/package.json +20 -25
  44. package/ssg.d.ts +0 -1
  45. package/types.d.ts +26 -0
  46. package/utils/object/objectUtils.d.ts +2 -0
  47. package/components/dataGrid/useGrid.d.ts +0 -3
  48. package/core/stylesContext.d.ts +0 -13
  49. package/core/theme.cjs +0 -1
  50. package/core/theme.mjs +0 -4
  51. package/core/types.d.ts +0 -60
  52. package/utils.cjs +0 -1
  53. package/utils.mjs +0 -63
package/box.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const s=require("react"),u=require("./core.cjs");function g(t,r){const{tag:n="div",children:o,props:f,className:d,style:c,disabled:a}=t,y=u.useStyles(t,n==="svg"),m=s.useMemo(()=>u.classNames(y,d).join(" "),[t]),e={...f,className:m,disabled:Array.isArray(a)?a[0]:a};c&&(e.style=c),r&&(e.ref=r);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;
1
+ "use strict";const s=require("react"),a=require("./core.cjs");function g(n,l){const{tag:d="div",children:c,props:p,className:x,style:m,disabled:t,required:r,checked:o}=n,v=a.useStyles(n,d==="svg"),i=s.useMemo(()=>{const h=a.classNames(v,x).join(" "),e={...p,className:h};return t&&(e.disabled=Array.isArray(t)?t[0]:t),r&&(e.required=Array.isArray(r)?r[0]:r),o&&(e.checked=Array.isArray(o)?o[0]:o),m&&(e.style=m),l&&(e.ref=l),e},[n]),[A,y]=s.useState(!1),f=typeof c=="function";return f&&(i.onMouseEnter=()=>y(!0),i.onMouseLeave=()=>y(!1)),s.createElement(d,i,f?c({isHover:A}):c)}const u=s.memo(s.forwardRef(g));u.extend=a.BoxExtends.extend;u.themeSetup=a.Theme.setup;module.exports=u;
package/box.d.ts CHANGED
@@ -1,9 +1,11 @@
1
+ import { default as React, RefAttributes } from 'react';
1
2
  import { ClassNameType } from './core/classNames';
2
- import { BoxStyleProps, ExtractElementFromTag } from './core/types';
3
- import { default as React, Ref, RefAttributes } from 'react';
4
-
3
+ import { ExtractElementFromTag } from './core/coreTypes';
4
+ import { BoxStyleProps } from './types';
5
+ import { default as BoxExtends } from './core/boxExtends';
6
+ import { default as Theme } from './core/theme';
5
7
  type AllProps<TTag extends keyof React.JSX.IntrinsicElements> = React.ComponentProps<TTag>;
6
- type TagPropsType<TTag extends keyof React.JSX.IntrinsicElements> = Omit<AllProps<TTag>, 'className' | 'style' | 'ref' | 'disabled'>;
8
+ type TagPropsType<TTag extends keyof React.JSX.IntrinsicElements> = Omit<AllProps<TTag>, 'className' | 'style' | 'ref' | 'disabled' | 'required' | 'checked'>;
7
9
  interface Props<TTag extends keyof React.JSX.IntrinsicElements> extends BoxStyleProps {
8
10
  children?: React.ReactNode | ((props: {
9
11
  isHover: boolean;
@@ -13,8 +15,12 @@ interface Props<TTag extends keyof React.JSX.IntrinsicElements> extends BoxStyle
13
15
  className?: ClassNameType;
14
16
  style?: React.ComponentProps<TTag>['style'];
15
17
  }
16
- 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>>;
17
- declare const _default: <TTag extends keyof React.JSX.IntrinsicElements = "div">(props: Props<TTag> & RefAttributes<ExtractElementFromTag<TTag>>) => React.ReactNode;
18
- export default _default;
18
+ interface BoxType {
19
+ <TTag extends keyof React.JSX.IntrinsicElements = 'div'>(props: Props<TTag> & RefAttributes<ExtractElementFromTag<TTag>>): React.ReactNode;
20
+ extend: typeof BoxExtends.extend;
21
+ themeSetup: typeof Theme.setup;
22
+ }
23
+ declare const Box: BoxType;
24
+ export default Box;
19
25
  export type BoxProps<TTag extends keyof React.JSX.IntrinsicElements = 'div'> = React.ComponentProps<typeof Box<TTag>>;
20
26
  export type BoxTagProps<TTag extends keyof React.JSX.IntrinsicElements = 'div'> = Required<BoxProps<TTag>>['props'];
package/box.mjs CHANGED
@@ -1,12 +1,18 @@
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: f, style: n, disabled: a } = s, u = N(s, r === "svg"), m = g(() => x(u, f).join(" "), [s]), e = { ...i, className: m, disabled: Array.isArray(a) ? a[0] : a };
5
- n && (e.style = n), o && (e.ref = o);
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);
1
+ import A, { memo as h, forwardRef as g, useMemo as B, useState as N } from "react";
2
+ import { B as S, T as C, u as E, c as H } from "./core.mjs";
3
+ function M(a, c) {
4
+ const { tag: i = "div", children: o, props: f, className: y, style: l, disabled: s, required: t, checked: r } = a, p = E(a, i === "svg"), n = B(() => {
5
+ const v = H(p, y).join(" "), e = {
6
+ ...f,
7
+ className: v
8
+ };
9
+ return s && (e.disabled = Array.isArray(s) ? s[0] : s), t && (e.required = Array.isArray(t) ? t[0] : t), r && (e.checked = Array.isArray(r) ? r[0] : r), l && (e.style = l), c && (e.ref = c), e;
10
+ }, [a]), [x, u] = N(!1), d = typeof o == "function";
11
+ return d && (n.onMouseEnter = () => u(!0), n.onMouseLeave = () => u(!1)), A.createElement(i, n, d ? o({ isHover: x }) : o);
8
12
  }
9
- const b = v(H);
13
+ const m = h(g(M));
14
+ m.extend = S.extend;
15
+ m.themeSetup = C.setup;
10
16
  export {
11
- b as default
17
+ m as default
12
18
  };
@@ -1,9 +1,8 @@
1
- import { ClassNameType } from '../core/classNames';
2
- import { BoxSvgStyles } from '../core/types';
3
1
  import { BoxTagProps } from '../box';
4
-
2
+ import { BoxStyleProps } from '../types';
3
+ import { ClassNameType } from '../core/classNames';
5
4
  type BoxSvgTagProps = Omit<BoxTagProps<'svg'>, 'viewBox' | 'width' | 'height'>;
6
- interface Props extends Omit<BoxSvgStyles, 'width' | 'height'> {
5
+ interface Props extends Omit<BoxStyleProps, 'width' | 'height'> {
7
6
  children?: React.ReactNode | ((props: {
8
7
  isHover: boolean;
9
8
  }) => React.ReactNode);
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),r=require("react"),s=require("../box.cjs"),u=require("../utils.cjs"),c=["type","onClick"];function i(t,o){const n=u.ObjectUtils.buildProps(t,c);return e.jsx(s,{ref:o,tag:"button",component:"button",...n})}const b=r.forwardRef(i);module.exports=b;
1
+ "use strict";const n=require("react/jsx-runtime"),r=require("react"),s=require("../box.cjs"),c=require("../core.cjs"),u=["type","onClick"];function i(t,o){const e=c.ObjectUtils.buildProps(t,u);return n.jsx(s,{ref:o,tag:"button",component:"button",...e})}const b=r.forwardRef(i);module.exports=b;
@@ -1,5 +1,4 @@
1
1
  import { default as Box } from '../box';
2
-
3
2
  type BoxProps = Omit<React.ComponentProps<typeof Box<'button'>>, 'ref' | 'tag'>;
4
3
  type BoxTagProps = Required<BoxProps>['props'];
5
4
  declare const tagProps: readonly ["type", "onClick"];
@@ -1,7 +1,7 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
2
  import { forwardRef as p } from "react";
3
3
  import s from "../box.mjs";
4
- import { O as m } from "../utils.mjs";
4
+ import { O as m } from "../core.mjs";
5
5
  const e = ["type", "onClick"];
6
6
  function f(o, t) {
7
7
  const r = m.buildProps(o, e);
@@ -1 +1 @@
1
- "use strict";const u=require("react/jsx-runtime"),t=require("react"),s=require("../box.cjs"),i=require("../utils.cjs"),a=["name","onInput","onChange","autoFocus","readOnly","required","value","checked","defaultChecked"];function d(n,r){const{indeterminate:c}=n,o=i.ObjectUtils.buildProps(n,a,{type:"checkbox"}),e=t.useRef(null);return t.useImperativeHandle(r,()=>e.current),t.useEffect(()=>{e.current&&(e.current.indeterminate=!!c)},[e,c]),u.jsx(s,{tag:"input",ref:e,component:"checkbox",...o})}const f=t.forwardRef(d);module.exports=f;
1
+ "use strict";const i=require("react/jsx-runtime"),n=require("react"),u=require("../box.cjs"),a=require("../core.cjs"),s=["name","onInput","onChange","autoFocus","readOnly","value","defaultChecked"];function d(t,c){const o=a.ObjectUtils.buildProps(t,s,{type:"checkbox"}),r=Array.isArray(t.indeterminate)?t.indeterminate[0]:t.indeterminate,e=n.useRef(null);return n.useImperativeHandle(c,()=>e.current),n.useEffect(()=>{e.current&&(e.current.indeterminate=!!r)},[e,r]),i.jsx(u,{tag:"input",ref:e,component:"checkbox",...o})}const f=n.forwardRef(d);module.exports=f;
@@ -1,6 +1,5 @@
1
1
  import { BoxTagProps, BoxProps } from '../box';
2
-
3
- declare const tagProps: readonly ["name", "onInput", "onChange", "autoFocus", "readOnly", "required", "value", "checked", "defaultChecked"];
2
+ declare const tagProps: readonly ["name", "onInput", "onChange", "autoFocus", "readOnly", "value", "defaultChecked"];
4
3
  type TagPropsType = (typeof tagProps)[number];
5
4
  type CheckboxProps = Omit<BoxProps<'input'>, 'tag' | 'props'>;
6
5
  type CheckboxTagProps = Omit<BoxTagProps<'input'>, TagPropsType | 'type'>;
@@ -12,9 +11,7 @@ interface Props extends CheckboxProps {
12
11
  value?: string | number;
13
12
  autoFocus?: boolean;
14
13
  readOnly?: boolean;
15
- required?: boolean;
16
14
  defaultChecked?: boolean;
17
- indeterminate?: boolean;
18
15
  }
19
- declare const _default: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<HTMLInputElement>>;
16
+ declare const _default: import('react').ForwardRefExoticComponent<Omit<Props, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
20
17
  export default _default;
@@ -1,15 +1,15 @@
1
1
  import { jsx as c } from "react/jsx-runtime";
2
- import { forwardRef as u, useRef as a, useImperativeHandle as f, useEffect as i } from "react";
3
- import s from "../box.mjs";
4
- import { O as m } from "../utils.mjs";
5
- const d = ["name", "onInput", "onChange", "autoFocus", "readOnly", "required", "value", "checked", "defaultChecked"];
6
- function p(o, n) {
7
- const { indeterminate: t } = o, r = m.buildProps(o, d, { type: "checkbox" }), e = a(null);
8
- return f(n, () => e.current), i(() => {
9
- e.current && (e.current.indeterminate = !!t);
10
- }, [e, t]), /* @__PURE__ */ c(s, { tag: "input", ref: e, component: "checkbox", ...r });
2
+ import { forwardRef as a, useRef as i, useImperativeHandle as u, useEffect as m } from "react";
3
+ import f from "../box.mjs";
4
+ import { O as s } from "../core.mjs";
5
+ const d = ["name", "onInput", "onChange", "autoFocus", "readOnly", "value", "defaultChecked"];
6
+ function l(t, r) {
7
+ const o = s.buildProps(t, d, { type: "checkbox" }), n = Array.isArray(t.indeterminate) ? t.indeterminate[0] : t.indeterminate, e = i(null);
8
+ return u(r, () => e.current), m(() => {
9
+ e.current && (e.current.indeterminate = !!n);
10
+ }, [e, n]), /* @__PURE__ */ c(f, { tag: "input", ref: e, component: "checkbox", ...o });
11
11
  }
12
- const k = u(p);
12
+ const k = a(l);
13
13
  export {
14
14
  k as default
15
15
  };
@@ -1,16 +1,24 @@
1
- /// <reference types="react" />
2
- export interface GridCell<T> {
3
- key: keyof T;
1
+ import { Key } from 'react';
2
+ type KeysMatching<T, V> = {
3
+ [K in keyof T]-?: T[K] extends V ? K : never;
4
+ }[keyof T];
5
+ export interface GridDef<TRow> {
6
+ rowKey?: KeysMatching<TRow, Key> | ((rowData: TRow) => Key);
7
+ columns: GridColumn<TRow>[];
8
+ }
9
+ export interface GridCell<TRow> {
10
+ key: keyof TRow;
4
11
  value: React.ReactNode;
5
12
  }
6
- export interface GridColumn<T extends {}> {
7
- key: keyof T;
13
+ export interface GridColumn<TRow> {
14
+ key: keyof TRow;
8
15
  }
9
- export interface GridRow<T extends {}> {
10
- dataRow: T;
11
- cells: GridCell<T>[];
16
+ export interface GridRow<TRow> {
17
+ dataRow: TRow;
18
+ cells: GridCell<TRow>[];
12
19
  }
13
- export interface Grid<T extends {}> {
14
- columns: GridColumn<T>[];
15
- rows: GridRow<T>[];
20
+ export interface GridData<TRow> {
21
+ columns: GridColumn<TRow>[];
22
+ rows: GridRow<TRow>[];
16
23
  }
24
+ export {};
@@ -0,0 +1,7 @@
1
+ import { GridColumn, GridData } from './dataGridContract';
2
+ interface Props<TRow> {
3
+ data?: TRow[];
4
+ columns: GridColumn<TRow>[];
5
+ }
6
+ export default function useGridData<TRow>(props: Props<TRow>): GridData<TRow>;
7
+ export {};
@@ -1 +1 @@
1
- "use strict";const s=require("react/jsx-runtime"),o=require("../box.cjs");function c(e){if(!(e!=null&&e.length))return{rows:[],columns:[]};const t=Object.keys(e[0]);return{rows:e.map(r=>({dataRow:r,cells:t.map(n=>({key:n,value:r[n]}))})),columns:t.map(r=>({key:r}))}}function l(e){const{data:t}=e,r=c(t);return s.jsx(o,{display:"grid",b:1,borderRadius:1,children:r.columns.length===0?s.jsx(s.Fragment,{children:"empty grid"}):s.jsxs(s.Fragment,{children:[r.columns.map((n,i)=>s.jsx(o,{style:{gridColumn:i+1},children:n.key.toString()},n.key.toString())),r.rows.map((n,i)=>n.cells.map(u=>s.jsx(o,{children:u.value},u.key.toString()+i)))]})})}module.exports=l;
1
+ "use strict";const n=require("react/jsx-runtime");require("react");const i=require("../box.cjs"),c=require("./grid.cjs");function g(u){const{data:e,def:d}=u,{rowKey:t,columns:s}=d;return s.length===0?(console.error("Cannot render grid without column definitions"),null):n.jsx(i,{component:"dataGrid",children:n.jsxs(c,{b:1,borderRadius:1,children:[s.map((r,o)=>n.jsx(i,{style:{gridColumn:o+1},children:r.key.toString()},r.key.toString())),((e==null?void 0:e.length)??0)===0&&n.jsx(i,{children:"Empty table"}),((e==null?void 0:e.length)??0)>0&&n.jsx(n.Fragment,{children:e==null?void 0:e.map((r,o)=>{const m=t?typeof t=="function"?t(r):r[t]:o;return n.jsx(c,{style:{gridTemplateRows:"subgrid"},children:s.map((h,l)=>n.jsxs(i,{style:{gridColumn:l+1},children:["tes ",l]}))},m)})})]})})}module.exports=g;
@@ -1,5 +1,7 @@
1
- interface Props<T extends {}> {
2
- data?: T[];
1
+ import { GridDef } from './dataGrid/dataGridContract';
2
+ interface Props<TRow> {
3
+ data?: TRow[];
4
+ def: GridDef<TRow>;
3
5
  }
4
- export default function DataGrid<T extends {}>(props: Props<T>): import("react/jsx-runtime").JSX.Element;
6
+ export default function DataGrid<TRow extends {}>(props: Props<TRow>): import("react/jsx-runtime").JSX.Element | null;
5
7
  export {};
@@ -1,32 +1,21 @@
1
- import { jsx as i, Fragment as m, jsxs as u } from "react/jsx-runtime";
2
- import t from "../box.mjs";
3
- function c(e) {
4
- if (!(e != null && e.length))
5
- return {
6
- rows: [],
7
- columns: []
8
- };
9
- const s = Object.keys(e[0]);
10
- return {
11
- rows: e.map((r) => ({
12
- dataRow: r,
13
- cells: s.map((n) => ({
14
- key: n,
15
- value: r[n]
16
- }))
17
- })),
18
- columns: s.map((r) => ({
19
- key: r
20
- }))
21
- };
22
- }
23
- function d(e) {
24
- const { data: s } = e, r = c(s);
25
- return /* @__PURE__ */ i(t, { display: "grid", b: 1, borderRadius: 1, children: r.columns.length === 0 ? /* @__PURE__ */ i(m, { children: "empty grid" }) : /* @__PURE__ */ u(m, { children: [
26
- r.columns.map((n, o) => /* @__PURE__ */ i(t, { style: { gridColumn: o + 1 }, children: n.key.toString() }, n.key.toString())),
27
- r.rows.map((n, o) => n.cells.map((l) => /* @__PURE__ */ i(t, { children: l.value }, l.key.toString() + o)))
1
+ import { jsx as n, jsxs as d, Fragment as g } from "react/jsx-runtime";
2
+ import "react";
3
+ import o from "../box.mjs";
4
+ import s from "./grid.mjs";
5
+ function x(c) {
6
+ const { data: r, def: u } = c, { rowKey: t, columns: i } = u;
7
+ return i.length === 0 ? (console.error("Cannot render grid without column definitions"), null) : /* @__PURE__ */ n(o, { component: "dataGrid", children: /* @__PURE__ */ d(s, { b: 1, borderRadius: 1, children: [
8
+ i.map((e, l) => /* @__PURE__ */ n(o, { style: { gridColumn: l + 1 }, children: e.key.toString() }, e.key.toString())),
9
+ ((r == null ? void 0 : r.length) ?? 0) === 0 && /* @__PURE__ */ n(o, { children: "Empty table" }),
10
+ ((r == null ? void 0 : r.length) ?? 0) > 0 && /* @__PURE__ */ n(g, { children: r == null ? void 0 : r.map((e, l) => {
11
+ const p = t ? typeof t == "function" ? t(e) : e[t] : l;
12
+ return /* @__PURE__ */ n(s, { style: { gridTemplateRows: "subgrid" }, children: i.map((h, m) => /* @__PURE__ */ d(o, { style: { gridColumn: m + 1 }, children: [
13
+ "tes ",
14
+ m
15
+ ] })) }, p);
16
+ }) })
28
17
  ] }) });
29
18
  }
30
19
  export {
31
- d as default
20
+ x as default
32
21
  };
@@ -1,8 +1,6 @@
1
- import { default as Box } from '../box';
2
1
  import { RefAttributes } from 'react';
3
-
4
- type ExtractElementType<T> = T extends React.DetailedHTMLProps<React.HTMLAttributes<infer E>, infer E> ? E : T extends React.SVGProps<infer E> ? E : never;
5
- type ExtractElementFromTag<T extends keyof React.JSX.IntrinsicElements> = ExtractElementType<React.JSX.IntrinsicElements[T]>;
2
+ import { default as Box } from '../box';
3
+ import { ExtractElementFromTag } from '../core/coreTypes';
6
4
  type BoxProps<TTag extends keyof React.JSX.IntrinsicElements = 'div'> = Omit<React.ComponentProps<typeof Box<TTag>>, 'ref'>;
7
- declare const _default: <TTag extends keyof import("react").JSX.IntrinsicElements = "div">(props: BoxProps<TTag> & RefAttributes<ExtractElementFromTag<TTag>>) => React.ReactNode;
5
+ declare const _default: <TTag extends keyof React.JSX.IntrinsicElements = "div">(props: BoxProps<TTag> & RefAttributes<ExtractElementFromTag<TTag>>) => React.ReactNode;
8
6
  export default _default;
@@ -1 +1 @@
1
- "use strict";const m=require("react/jsx-runtime"),o=require("react"),a=require("../box.cjs"),f=require("../utils.cjs");function l(t){const{onSubmit:s,props:n}=t,r=o.useRef(null),u=o.useCallback(e=>{e.preventDefault();const i=f.FormUtils.getFormEntries(r.current);s(i,e)},[]),c={...n,onSubmit:u,ref:r};return m.jsx(a,{tag:"form",...t,props:c})}module.exports=l;
1
+ "use strict";const m=require("react/jsx-runtime"),o=require("react"),a=require("../box.cjs"),f=require("../core.cjs");function l(r){const{onSubmit:n,props:s}=r,t=o.useRef(null),u=o.useCallback(e=>{e.preventDefault();const i=f.FormUtils.getFormEntries(t.current);n(i,e)},[]),c={...s,onSubmit:u,ref:t};return m.jsx(a,{tag:"form",...r,props:c})}module.exports=l;
@@ -1,5 +1,4 @@
1
1
  import { default as Box } from '../box';
2
-
3
2
  type BoxProps = React.ComponentProps<typeof Box<'form'>>;
4
3
  type BoxTagProps = Required<BoxProps>['props'];
5
4
  type FormTagProps = Omit<BoxTagProps, 'onSubmit' | 'ref'>;
@@ -1,7 +1,7 @@
1
1
  import { jsx as u } from "react/jsx-runtime";
2
2
  import { useRef as a, useCallback as i } from "react";
3
3
  import p from "../box.mjs";
4
- import { F as c } from "../utils.mjs";
4
+ import { F as c } from "../core.mjs";
5
5
  function x(o) {
6
6
  const { onSubmit: m, props: n } = o, r = a(null), e = i((t) => {
7
7
  t.preventDefault();
@@ -1,8 +1,6 @@
1
- import { default as Box } from '../box';
2
1
  import { RefAttributes } from 'react';
3
-
4
- type ExtractElementType<T> = T extends React.DetailedHTMLProps<React.HTMLAttributes<infer E>, infer E> ? E : T extends React.SVGProps<infer E> ? E : never;
5
- type ExtractElementFromTag<T extends keyof React.JSX.IntrinsicElements> = ExtractElementType<React.JSX.IntrinsicElements[T]>;
2
+ import { default as Box } from '../box';
3
+ import { ExtractElementFromTag } from '../core/coreTypes';
6
4
  type BoxProps<TTag extends keyof React.JSX.IntrinsicElements = 'div'> = Omit<React.ComponentProps<typeof Box<TTag>>, 'ref'>;
7
- declare const _default: <TTag extends keyof import("react").JSX.IntrinsicElements = "div">(props: BoxProps<TTag> & RefAttributes<ExtractElementFromTag<TTag>>) => React.ReactNode;
5
+ declare const _default: <TTag extends keyof React.JSX.IntrinsicElements = "div">(props: BoxProps<TTag> & RefAttributes<ExtractElementFromTag<TTag>>) => React.ReactNode;
8
6
  export default _default;
@@ -1,5 +1,4 @@
1
1
  import { BoxProps } from '../box';
2
-
3
2
  interface Props extends Omit<BoxProps<'label'>, 'ref' | 'tag'> {
4
3
  }
5
4
  declare const _default: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<HTMLLabelElement>>;
@@ -1 +1 @@
1
- "use strict";const n=require("react/jsx-runtime"),r=require("react"),u=require("../box.cjs"),s=require("../utils.cjs"),c=["name","onInput","onChange","value","autoFocus","readOnly","required","checked","defaultChecked"];function i(t,e){const o=s.ObjectUtils.buildProps(t,c,{type:"radio"});return n.jsx(u,{ref:e,tag:"input",component:"radioButton",...o})}const a=r.forwardRef(i);module.exports=a;
1
+ "use strict";const n=require("react/jsx-runtime"),r=require("react"),u=require("../box.cjs"),s=require("../core.cjs"),c=["name","onInput","onChange","value","autoFocus","readOnly","defaultChecked"];function a(t,o){const e=s.ObjectUtils.buildProps(t,c,{type:"radio"});return n.jsx(u,{ref:o,tag:"input",component:"radioButton",...e})}const i=r.forwardRef(a);module.exports=i;
@@ -1,8 +1,7 @@
1
1
  import { default as Box } from '../box';
2
-
3
2
  type BoxProps = Omit<React.ComponentProps<typeof Box<'input'>>, 'ref' | 'tag'>;
4
3
  type BoxTagProps = Required<BoxProps>['props'];
5
- declare const tagProps: readonly ["name", "onInput", "onChange", "value", "autoFocus", "readOnly", "required", "checked", "defaultChecked"];
4
+ declare const tagProps: readonly ["name", "onInput", "onChange", "value", "autoFocus", "readOnly", "defaultChecked"];
6
5
  type TagPropsType = (typeof tagProps)[number];
7
6
  type RadioButtonTagProps = Omit<BoxTagProps, TagPropsType | 'type'>;
8
7
  interface Props extends Omit<BoxProps, 'props'> {
@@ -13,7 +12,6 @@ interface Props extends Omit<BoxProps, 'props'> {
13
12
  value?: string | number;
14
13
  autoFocus?: boolean;
15
14
  readOnly?: boolean;
16
- required?: boolean;
17
15
  defaultChecked?: boolean;
18
16
  }
19
17
  declare const _default: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<HTMLInputElement>>;
@@ -1,13 +1,13 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { forwardRef as n } from "react";
3
- import a from "../box.mjs";
4
- import { O as u } from "../utils.mjs";
5
- const i = ["name", "onInput", "onChange", "value", "autoFocus", "readOnly", "required", "checked", "defaultChecked"];
6
- function d(o, t) {
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { forwardRef as a } from "react";
3
+ import e from "../box.mjs";
4
+ import { O as u } from "../core.mjs";
5
+ const i = ["name", "onInput", "onChange", "value", "autoFocus", "readOnly", "defaultChecked"];
6
+ function p(o, t) {
7
7
  const r = u.buildProps(o, i, { type: "radio" });
8
- return /* @__PURE__ */ e(a, { ref: t, tag: "input", component: "radioButton", ...r });
8
+ return /* @__PURE__ */ n(e, { ref: t, tag: "input", component: "radioButton", ...r });
9
9
  }
10
- const f = n(d);
10
+ const c = a(p);
11
11
  export {
12
- f as default
12
+ c as default
13
13
  };
@@ -1 +1 @@
1
- "use strict";const n=require("react/jsx-runtime"),o=require("react"),a=require("../box.cjs"),s=require("../utils.cjs"),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;
1
+ "use strict";const o=require("react/jsx-runtime"),n=require("react"),a=require("../box.cjs"),s=require("../core.cjs"),c=["name","onInput","onChange","placeholder","value","defaultValue","rows","cols","autoFocus","maxLength","minLength","readOnly"];function u(e,t){const r=s.ObjectUtils.buildProps(e,c);return o.jsx(a,{ref:t,tag:"textarea",component:"textarea",...r})}const i=n.forwardRef(u);module.exports=i;
@@ -1,8 +1,7 @@
1
1
  import { default as Box } from '../box';
2
-
3
2
  type BoxProps = Omit<React.ComponentProps<typeof Box<'textarea'>>, 'ref' | 'tag'>;
4
3
  type BoxTagProps = Required<BoxProps>['props'];
5
- declare const tagProps: readonly ["name", "onInput", "onChange", "placeholder", "value", "defaultValue", "rows", "cols", "autoFocus", "maxLength", "minLength", "readOnly", "required"];
4
+ declare const tagProps: readonly ["name", "onInput", "onChange", "placeholder", "value", "defaultValue", "rows", "cols", "autoFocus", "maxLength", "minLength", "readOnly"];
6
5
  type TagPropsType = (typeof tagProps)[number];
7
6
  type TextareaTagProps = Omit<BoxTagProps, TagPropsType>;
8
7
  interface Props extends Omit<BoxProps, 'props'> {
@@ -1,7 +1,7 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { forwardRef as a } from "react";
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { forwardRef as r } from "react";
3
3
  import n from "../box.mjs";
4
- import { O as s } from "../utils.mjs";
4
+ import { O as s } from "../core.mjs";
5
5
  const m = [
6
6
  "name",
7
7
  "onInput",
@@ -14,14 +14,13 @@ const m = [
14
14
  "autoFocus",
15
15
  "maxLength",
16
16
  "minLength",
17
- "readOnly",
18
- "required"
17
+ "readOnly"
19
18
  ];
20
- function p(t, e) {
21
- const o = s.buildProps(t, m);
22
- return /* @__PURE__ */ r(n, { ref: e, tag: "textarea", component: "textarea", ...o });
19
+ function p(t, o) {
20
+ const e = s.buildProps(t, m);
21
+ return /* @__PURE__ */ a(n, { ref: o, tag: "textarea", component: "textarea", ...e });
23
22
  }
24
- const i = a(p);
23
+ const i = r(p);
25
24
  export {
26
25
  i as default
27
26
  };
@@ -1 +1 @@
1
- "use strict";const n=require("react/jsx-runtime"),r=require("react"),s=require("../box.cjs"),u=require("../utils.cjs"),c=["name","onInput","onChange","type","placeholder","defaultValue","autoFocus","readOnly","required","value","pattern"];function a(e,t){const o=u.ObjectUtils.buildProps(e,c);return n.jsx(s,{ref:t,tag:"input",component:"textbox",...o})}const i=r.forwardRef(a);module.exports=i;
1
+ "use strict";const r=require("react/jsx-runtime"),n=require("react"),s=require("../box.cjs"),u=require("../core.cjs"),c=["name","onInput","onChange","type","placeholder","defaultValue","autoFocus","readOnly","required","value","pattern"];function a(e,t){const o=u.ObjectUtils.buildProps(e,c);return r.jsx(s,{ref:t,tag:"input",component:"textbox",...o})}const i=n.forwardRef(a);module.exports=i;
@@ -1,5 +1,4 @@
1
1
  import { default as Box } from '../box';
2
-
3
2
  type BoxProps = Omit<React.ComponentProps<typeof Box<'input'>>, 'ref' | 'tag'>;
4
3
  type BoxTagProps = Required<BoxProps>['props'];
5
4
  declare const tagProps: readonly ["name", "onInput", "onChange", "type", "placeholder", "defaultValue", "autoFocus", "readOnly", "required", "value", "pattern"];
@@ -18,7 +17,6 @@ interface Props extends Omit<BoxProps, 'props'> {
18
17
  pattern?: string;
19
18
  autoFocus?: boolean;
20
19
  readOnly?: boolean;
21
- required?: boolean;
22
20
  step?: number | string;
23
21
  }
24
22
  declare const _default: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<HTMLInputElement>>;
@@ -1,7 +1,7 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
2
  import { forwardRef as n } from "react";
3
3
  import a from "../box.mjs";
4
- import { O as p } from "../utils.mjs";
4
+ import { O as p } from "../core.mjs";
5
5
  const u = [
6
6
  "name",
7
7
  "onInput",
@@ -1 +1 @@
1
- "use strict";const u=require("react/jsx-runtime"),h=require("react-dom"),f=require("../box.cjs"),s=require("react");function v(){return s.useMemo(()=>{const i="crono-box";let r=document.getElementById(i);return r||(r=document.createElement("div"),r.id=i,document.body.appendChild(r)),r},[])}const a=2;function x(i){const{onPositionChange:r}=i,l=s.useRef(null),[e,p]=s.useState(),m=v(),w=s.useCallback((o,t)=>{const n=c=>{c.target.contains(o)&&t(o)};return document.addEventListener("scroll",n,{capture:!0}),()=>{document.removeEventListener("scroll",n,{capture:!0})}},[e]),b=s.useCallback((o,t)=>{const n=c=>{t(o)};return window.addEventListener("resize",n,{capture:!0}),()=>{window.removeEventListener("resize",n,{capture:!0})}},[e]),d=s.useCallback(o=>{const t=o.getBoundingClientRect(),n=Math.round((t.top+window.scrollY)*a)/a,c=Math.round((t.left+window.scrollX)*a)/a;((e==null?void 0:e.top)!==n||(e==null?void 0:e.left)!==c)&&(r==null||r({top:n,left:c}),p({top:n,left:c,width:t.width>0?t.width:void 0}))},[e]);return s.useLayoutEffect(()=>{if(l.current){d(l.current);const o=w(l.current,d),t=b(l.current,d);return()=>{o(),t()}}},[e]),u.jsxs(u.Fragment,{children:[u.jsx(f,{ref:l}),e&&h.createPortal(u.jsx(f,{position:"absolute",top:0,left:0,transition:"none",style:{transform:`translate(${e.left}px,${e.top}px)`,width:e.width},children:u.jsx(f,{position:"absolute",width:"fit",...i})}),m)]})}module.exports=x;
1
+ "use strict";const i=require("react/jsx-runtime"),v=require("react-dom"),d=require("../box.cjs"),s=require("react"),x=require("../core.cjs"),l=2;function b(f){const{onPositionChange:u}=f,c=s.useRef(null),[t,p]=s.useState(),w=x.usePortalContainer(),h=s.useCallback((n,e)=>{const r=o=>{o.target.contains(n)&&e(n)};return document.addEventListener("scroll",r,{capture:!0}),()=>{document.removeEventListener("scroll",r,{capture:!0})}},[t]),m=s.useCallback((n,e)=>{const r=o=>{e(n)};return window.addEventListener("resize",r,{capture:!0}),()=>{window.removeEventListener("resize",r,{capture:!0})}},[t]),a=s.useCallback(n=>{const e=n.getBoundingClientRect(),r=Math.round((e.top+window.scrollY)*l)/l,o=Math.round((e.left+window.scrollX)*l)/l;((t==null?void 0:t.top)!==r||(t==null?void 0:t.left)!==o)&&(u==null||u({top:r,left:o}),p({top:r,left:o,width:e.width>0?e.width:void 0}))},[t]);return s.useLayoutEffect(()=>{if(c.current){a(c.current);const n=h(c.current,a),e=m(c.current,a);return()=>{n(),e()}}},[t]),i.jsxs(i.Fragment,{children:[i.jsx(d,{ref:c}),t&&v.createPortal(i.jsx(d,{position:"absolute",top:0,left:0,transition:"none",style:{transform:`translate(${t.left}px,${t.top}px)`,width:t.width},children:i.jsx(d,{position:"absolute",width:"fit",...f})}),w)]})}module.exports=b;
@@ -1,6 +1,5 @@
1
- import { default as React } from 'react';
2
1
  import { default as Box } from '../box';
3
-
2
+ import { default as React } from 'react';
4
3
  interface Props extends React.ComponentProps<typeof Box> {
5
4
  onPositionChange?(position: {
6
5
  top: number;
@@ -1,63 +1,57 @@
1
- import { jsxs as v, Fragment as b, jsx as a } from "react/jsx-runtime";
2
- import { createPortal as x } from "react-dom";
3
- import d from "../box.mjs";
4
- import { useMemo as E, useRef as C, useState as g, useCallback as f, useLayoutEffect as L } from "react";
5
- function y() {
6
- return E(() => {
7
- const i = "crono-box";
8
- let r = document.getElementById(i);
9
- return r || (r = document.createElement("div"), r.id = i, document.body.appendChild(r)), r;
10
- }, []);
11
- }
12
- const l = 2;
13
- function M(i) {
14
- const { onPositionChange: r } = i, c = C(null), [t, p] = g(), m = y(), w = f(
15
- (n, e) => {
16
- const o = (s) => {
17
- s.target.contains(n) && e(n);
1
+ import { jsxs as v, Fragment as x, jsx as a } from "react/jsx-runtime";
2
+ import { createPortal as b } from "react-dom";
3
+ import u from "../box.mjs";
4
+ import { useRef as E, useState as L, useCallback as d, useLayoutEffect as g } from "react";
5
+ import { a as z } from "../core.mjs";
6
+ const i = 2;
7
+ function y(f) {
8
+ const { onPositionChange: c } = f, s = E(null), [t, p] = L(), m = z(), w = d(
9
+ (o, e) => {
10
+ const r = (n) => {
11
+ n.target.contains(o) && e(o);
18
12
  };
19
- return document.addEventListener("scroll", o, { capture: !0 }), () => {
20
- document.removeEventListener("scroll", o, { capture: !0 });
13
+ return document.addEventListener("scroll", r, { capture: !0 }), () => {
14
+ document.removeEventListener("scroll", r, { capture: !0 });
21
15
  };
22
16
  },
23
17
  [t]
24
- ), h = f(
25
- (n, e) => {
26
- const o = (s) => {
27
- e(n);
18
+ ), h = d(
19
+ (o, e) => {
20
+ const r = (n) => {
21
+ e(o);
28
22
  };
29
- return window.addEventListener("resize", o, { capture: !0 }), () => {
30
- window.removeEventListener("resize", o, { capture: !0 });
23
+ return window.addEventListener("resize", r, { capture: !0 }), () => {
24
+ window.removeEventListener("resize", r, { capture: !0 });
31
25
  };
32
26
  },
33
27
  [t]
34
- ), u = f(
35
- (n) => {
36
- const e = n.getBoundingClientRect(), o = Math.round((e.top + window.scrollY) * l) / l, s = Math.round((e.left + window.scrollX) * l) / l;
37
- ((t == null ? void 0 : t.top) !== o || (t == null ? void 0 : t.left) !== s) && (r == null || r({ top: o, left: s }), p({ top: o, left: s, width: e.width > 0 ? e.width : void 0 }));
28
+ ), l = d(
29
+ (o) => {
30
+ const e = o.getBoundingClientRect(), r = Math.round((e.top + window.scrollY) * i) / i, n = Math.round((e.left + window.scrollX) * i) / i;
31
+ ((t == null ? void 0 : t.top) !== r || (t == null ? void 0 : t.left) !== n) && (c == null || c({ top: r, left: n }), p({ top: r, left: n, width: e.width > 0 ? e.width : void 0 }));
38
32
  },
39
33
  [t]
40
34
  );
41
- return L(() => {
42
- if (c.current) {
43
- u(c.current);
44
- const n = w(c.current, u), e = h(c.current, u);
35
+ return g(() => {
36
+ if (s.current) {
37
+ l(s.current);
38
+ const o = w(s.current, l), e = h(s.current, l);
45
39
  return () => {
46
- n(), e();
40
+ o(), e();
47
41
  };
48
42
  }
49
- }, [t]), /* @__PURE__ */ v(b, { children: [
50
- /* @__PURE__ */ a(d, { ref: c }),
51
- t && x(
43
+ }, [t]), /* @__PURE__ */ v(x, { children: [
44
+ /* @__PURE__ */ a(u, { ref: s }),
45
+ t && b(
52
46
  /* @__PURE__ */ a(
53
- d,
47
+ u,
54
48
  {
55
49
  position: "absolute",
56
50
  top: 0,
57
51
  left: 0,
58
52
  transition: "none",
59
53
  style: { transform: `translate(${t.left}px,${t.top}px)`, width: t.width },
60
- children: /* @__PURE__ */ a(d, { position: "absolute", width: "fit", ...i })
54
+ children: /* @__PURE__ */ a(u, { position: "absolute", width: "fit", ...f })
61
55
  }
62
56
  ),
63
57
  m
@@ -65,5 +59,5 @@ function M(i) {
65
59
  ] });
66
60
  }
67
61
  export {
68
- M as default
62
+ y as default
69
63
  };
@@ -0,0 +1,6 @@
1
+ import { BoxStyle } from './coreTypes';
2
+ declare namespace BoxExtends {
3
+ function extend<TProps extends Record<string, BoxStyle[]>>(variables: Record<string, string>, props: TProps): TProps;
4
+ function getVariables(): string;
5
+ }
6
+ export default BoxExtends;