@cronocode/react-box 0.4.9 → 1.0.1

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.
@@ -1,5 +1,5 @@
1
1
  import Box from '../box';
2
- declare type BoxProps = React.ComponentProps<typeof Box>;
2
+ declare type BoxProps = React.ComponentProps<typeof Box<'button'>>;
3
3
  declare type BoxTagProps = Required<BoxProps>['props'];
4
4
  declare type ButtonTagProps = Omit<BoxTagProps, 'type' | 'onClick' | 'disabled'>;
5
5
  declare type ButtonType = Required<React.ComponentProps<'button'>>['type'];
@@ -1,28 +1,11 @@
1
- import s from "../box.js";
2
- import { jsx as u } from "react/jsx-runtime";
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import u from "../box.js";
3
3
  import "react";
4
4
  import "../box.module.css.js";
5
5
  import "../utils/utils.js";
6
6
  function l(t) {
7
- const {
8
- tag: o,
9
- type: r,
10
- onClick: n,
11
- disabled: p,
12
- props: e
13
- } = t, i = {
14
- ...e,
15
- type: r || "button",
16
- onClick: n,
17
- disabled: p
18
- };
19
- return /* @__PURE__ */ u(s, {
20
- tag: o || "button",
21
- cursor: "pointer",
22
- inline: !0,
23
- ...t,
24
- props: i
25
- });
7
+ const { tag: o, type: r, onClick: n, disabled: p, props: e } = t, i = { ...e, type: r || "button", onClick: n, disabled: p };
8
+ return /* @__PURE__ */ s(u, { tag: o || "button", cursor: "pointer", inline: !0, ...t, props: i });
26
9
  }
27
10
  export {
28
11
  l as default
@@ -1,16 +1,11 @@
1
- import t from "../box.js";
2
- import { jsx as r } from "react/jsx-runtime";
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import r from "../box.js";
3
3
  import "react";
4
4
  import "../box.module.css.js";
5
5
  import "../utils/utils.js";
6
6
  function x(i) {
7
- const {
8
- inline: o
9
- } = i;
10
- return /* @__PURE__ */ r(t, {
11
- display: o ? "inline-flex" : "flex",
12
- ...i
13
- });
7
+ const { inline: o } = i;
8
+ return /* @__PURE__ */ t(r, { display: o ? "inline-flex" : "flex", ...i });
14
9
  }
15
10
  export {
16
11
  x as default
@@ -1,5 +1,9 @@
1
- interface Props<T> {
2
- children: React.ReactNode;
1
+ import Box from '../box';
2
+ declare type BoxProps = React.ComponentProps<typeof Box<'form'>>;
3
+ declare type BoxTagProps = Required<BoxProps>['props'];
4
+ declare type FormAsyncTagProps = Omit<BoxTagProps, 'onSubmit' | 'ref'>;
5
+ interface Props<T> extends Omit<BoxProps, 'props' | 'tag'> {
6
+ props?: FormAsyncTagProps;
3
7
  onSubmit: (obj: T, e: React.FormEvent<HTMLFormElement>) => void;
4
8
  }
5
9
  export default function FormAsync<T>(props: Props<T>): JSX.Element;
@@ -1,43 +1,16 @@
1
- import { useRef as i, useCallback as p } from "react";
2
- import s from "../box.js";
3
- import { jsx as m } from "react/jsx-runtime";
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { useRef as p, useCallback as u } from "react";
3
+ import a from "../box.js";
4
+ import { F as c } from "../utils/utils.js";
4
5
  import "../box.module.css.js";
5
- import "../utils/utils.js";
6
- function d(u) {
7
- const n = Array.from(u.elements).reduce((r, o) => {
8
- const c = o.name;
9
- return c && (r[c] || (r[c] = []), r[c].push(o)), r;
10
- }, {});
11
- return Object.entries(n).reduce((r, [o, c]) => {
12
- if (c.length === 1) {
13
- const e = c[0];
14
- r[o] = e.type === "checkbox" || e.type === "radio" ? e.checked : e.value;
15
- } else
16
- r[o] = [], c.forEach((e) => {
17
- var t;
18
- e.type === "checkbox" ? e.checked && r[o].push(e.value) : e.type === "radio" ? r[o] = (t = c.find((f) => f.checked)) == null ? void 0 : t.value : r[o].push(e.value);
19
- });
20
- return r;
21
- }, {});
22
- }
23
- function v(u) {
24
- const {
25
- children: n,
26
- onSubmit: r
27
- } = u, o = i(null), c = p((e) => {
28
- e.preventDefault();
29
- const t = d(o.current);
30
- r(t, e);
31
- }, []);
32
- return /* @__PURE__ */ m(s, {
33
- tag: "form",
34
- props: {
35
- ref: o,
36
- onSubmit: c
37
- },
38
- children: n
39
- });
6
+ function S(o) {
7
+ const { onSubmit: m, props: n } = o, r = p(null), s = u((t) => {
8
+ t.preventDefault();
9
+ const f = c.getFormEntries(r.current);
10
+ m(f, t);
11
+ }, []), e = { ...n, onSubmit: s, ref: r };
12
+ return /* @__PURE__ */ i(a, { tag: "form", ...o, props: e });
40
13
  }
41
14
  export {
42
- v as default
15
+ S as default
43
16
  };
@@ -1,5 +1,5 @@
1
1
  import Box from '../box';
2
- declare type BoxProps = React.ComponentProps<typeof Box>;
2
+ declare type BoxProps = React.ComponentProps<typeof Box<'input'>>;
3
3
  declare type BoxTagProps = Required<BoxProps>['props'];
4
4
  declare type UncontrolledCheckboxCoreTagProps = Omit<BoxTagProps, 'name' | 'onInput' | 'onChange' | 'type' | 'placeholder' | 'disabled' | 'value' | 'autoFocus' | 'readOnly' | 'required' | 'defaultChecked'>;
5
5
  interface Props extends Omit<BoxProps, 'props'> {
@@ -1,22 +1,10 @@
1
- import m from "../box.js";
2
- import { jsx as f } from "react/jsx-runtime";
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import f from "../box.js";
3
3
  import "react";
4
4
  import "../box.module.css.js";
5
5
  import "../utils/utils.js";
6
6
  function k(o) {
7
- const {
8
- props: e,
9
- name: r,
10
- disabled: t,
11
- placeholder: n,
12
- value: p,
13
- onInput: a,
14
- onChange: i,
15
- autoFocus: u,
16
- readOnly: c,
17
- required: l,
18
- defaultChecked: d
19
- } = o, s = {
7
+ const { props: e, name: r, disabled: t, placeholder: n, value: p, onInput: a, onChange: i, autoFocus: u, readOnly: c, required: l, defaultChecked: d } = o, s = {
20
8
  ...e,
21
9
  type: "checkbox",
22
10
  name: r,
@@ -30,12 +18,7 @@ function k(o) {
30
18
  required: l,
31
19
  defaultChecked: d
32
20
  };
33
- return /* @__PURE__ */ f(m, {
34
- tag: "input",
35
- inline: !0,
36
- ...o,
37
- props: s
38
- });
21
+ return /* @__PURE__ */ m(f, { tag: "input", inline: !0, ...o, props: s });
39
22
  }
40
23
  export {
41
24
  k as default
@@ -1,5 +1,5 @@
1
1
  import Box from '../box';
2
- declare type BoxProps = React.ComponentProps<typeof Box>;
2
+ declare type BoxProps = React.ComponentProps<typeof Box<'input'>>;
3
3
  declare type BoxTagProps = Required<BoxProps>['props'];
4
4
  declare type UncontrolledRadioButtonCoreTagProps = Omit<BoxTagProps, 'name' | 'onInput' | 'onChange' | 'type' | 'placeholder' | 'disabled' | 'value' | 'autoFocus' | 'readOnly' | 'required' | 'defaultChecked'>;
5
5
  interface Props extends Omit<BoxProps, 'props'> {
@@ -1,22 +1,10 @@
1
- import c from "../box.js";
2
- import { jsx as f } from "react/jsx-runtime";
1
+ import { jsx as c } from "react/jsx-runtime";
2
+ import f from "../box.js";
3
3
  import "react";
4
4
  import "../box.module.css.js";
5
5
  import "../utils/utils.js";
6
6
  function B(o) {
7
- const {
8
- props: t,
9
- name: e,
10
- disabled: r,
11
- placeholder: n,
12
- value: a,
13
- onInput: p,
14
- onChange: i,
15
- autoFocus: u,
16
- readOnly: d,
17
- required: l,
18
- defaultChecked: s
19
- } = o, m = {
7
+ const { props: t, name: e, disabled: r, placeholder: n, value: a, onInput: p, onChange: i, autoFocus: u, readOnly: d, required: l, defaultChecked: s } = o, m = {
20
8
  ...t,
21
9
  type: "radio",
22
10
  name: e,
@@ -30,12 +18,7 @@ function B(o) {
30
18
  required: l,
31
19
  defaultChecked: s
32
20
  };
33
- return /* @__PURE__ */ f(c, {
34
- tag: "input",
35
- inline: !0,
36
- ...o,
37
- props: m
38
- });
21
+ return /* @__PURE__ */ c(f, { tag: "input", inline: !0, ...o, props: m });
39
22
  }
40
23
  export {
41
24
  B as default
@@ -1,5 +1,5 @@
1
1
  import Box from '../box';
2
- declare type BoxProps = React.ComponentProps<typeof Box>;
2
+ declare type BoxProps = React.ComponentProps<typeof Box<'textarea'>>;
3
3
  declare type BoxTagProps = Required<BoxProps>['props'];
4
4
  declare type UncontrolledTextareaCoreTagProps = Omit<BoxTagProps, 'name' | 'onInput' | 'onChange' | 'placeholder' | 'disabled' | 'defaultValue' | 'rows' | 'cols' | 'autoFocus' | 'maxLength' | 'minLength' | 'readOnly' | 'required'>;
5
5
  interface Props extends Omit<BoxProps, 'props'> {
@@ -1,5 +1,5 @@
1
- import f from "../box.js";
2
- import { jsx as h } from "react/jsx-runtime";
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import h from "../box.js";
3
3
  import "react";
4
4
  import "../box.module.css.js";
5
5
  import "../utils/utils.js";
@@ -35,12 +35,7 @@ function b(o) {
35
35
  readOnly: c,
36
36
  required: g
37
37
  };
38
- return /* @__PURE__ */ h(f, {
39
- tag: "textarea",
40
- inline: !0,
41
- ...o,
42
- props: x
43
- });
38
+ return /* @__PURE__ */ f(h, { tag: "textarea", inline: !0, ...o, props: x });
44
39
  }
45
40
  export {
46
41
  b as default
@@ -1,5 +1,5 @@
1
1
  import Box from '../box';
2
- declare type BoxProps = React.ComponentProps<typeof Box>;
2
+ declare type BoxProps = React.ComponentProps<typeof Box<'input'>>;
3
3
  declare type BoxTagProps = Required<BoxProps>['props'];
4
4
  declare type UncontrolledTextboxCoreTagProps = Omit<BoxTagProps, 'name' | 'onInput' | 'onChange' | 'type' | 'placeholder' | 'disabled' | 'defaultValue' | 'autoFocus' | 'readOnly' | 'required'>;
5
5
  declare type UncontrolledTextboxCoreType = 'date' | 'datetime-local' | 'email' | 'hidden' | 'month' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url' | 'week';
@@ -1,5 +1,5 @@
1
- import x from "../box.js";
2
- import { jsx as f } from "react/jsx-runtime";
1
+ import { jsx as x } from "react/jsx-runtime";
2
+ import f from "../box.js";
3
3
  import "react";
4
4
  import "../box.module.css.js";
5
5
  import "../utils/utils.js";
@@ -31,12 +31,7 @@ function P(t) {
31
31
  required: d,
32
32
  step: m
33
33
  };
34
- return /* @__PURE__ */ f(x, {
35
- tag: "input",
36
- inline: !0,
37
- ...t,
38
- props: c
39
- });
34
+ return /* @__PURE__ */ x(f, { tag: "input", inline: !0, ...t, props: c });
40
35
  }
41
36
  export {
42
37
  P as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cronocode/react-box",
3
- "version": "0.4.9",
3
+ "version": "1.0.1",
4
4
  "main": "./box.js",
5
5
  "module": "./box.js",
6
6
  "types": "./box.d.ts",
@@ -43,19 +43,19 @@
43
43
  "devDependencies": {
44
44
  "@cronocode/identity-factory": "^0.0.6",
45
45
  "@rollup/pluginutils": "^5.0.2",
46
- "@types/node": "^18.7.14",
46
+ "@types/node": "^18.11.18",
47
47
  "@types/postcss-mixins": "^9.0.0",
48
- "@types/react": "^18.0.18",
49
- "@types/react-dom": "^18.0.6",
50
- "@vitejs/plugin-react": "^2.0.1",
51
- "autoprefixer": "^10.4.8",
52
- "postcss": "^8.4.16",
48
+ "@types/react": "^18.0.27",
49
+ "@types/react-dom": "^18.0.10",
50
+ "@vitejs/plugin-react": "^3.0.1",
51
+ "autoprefixer": "^10.4.13",
52
+ "postcss": "^8.4.21",
53
53
  "postcss-mixins": "^9.0.4",
54
- "prettier": "^2.7.1",
54
+ "prettier": "^2.8.3",
55
55
  "react": "^18.1.0",
56
56
  "react-dom": "^18.2.0",
57
- "typescript": "^4.8.2",
58
- "vite": "^3.0.9",
59
- "vite-plugin-dts": "^1.4.1"
57
+ "typescript": "^4.9.4",
58
+ "vite": "^4.0.4",
59
+ "vite-plugin-dts": "^1.7.1"
60
60
  }
61
61
  }