@thisisagile/easy-react 15.26.2 → 15.27.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.js CHANGED
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -11,15 +15,121 @@ var __copyProps = (to, from, except, desc) => {
11
15
  }
12
16
  return to;
13
17
  };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
16
21
  var src_exports = {};
22
+ __export(src_exports, {
23
+ If: () => If,
24
+ useA: () => useA,
25
+ useAn: () => useAn,
26
+ useEntity: () => useEntity,
27
+ useGet: () => useGet,
28
+ useGetList: () => useGetList,
29
+ useList: () => useList,
30
+ useOnce: () => useOnce,
31
+ useOptional: () => useOptional,
32
+ usePageList: () => usePageList,
33
+ usePaging: () => usePaging,
34
+ useToggle: () => useToggle
35
+ });
17
36
  module.exports = __toCommonJS(src_exports);
18
- __reExport(src_exports, require("./layout"), module.exports);
19
- __reExport(src_exports, require("./utils"), module.exports);
37
+
38
+ // src/layout/If.tsx
39
+ var import_jsx_runtime = require("react/jsx-runtime");
40
+ var If = ({ condition, children }) => condition ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children }) : null;
41
+
42
+ // src/utils/Hooks.ts
43
+ var import_easy = require("@thisisagile/easy");
44
+ var import_react = require("react");
45
+ var useToggle = (initialState = false) => {
46
+ const [state, setState] = (0, import_react.useState)(initialState);
47
+ return [state, () => setState((s) => !s)];
48
+ };
49
+ var useA = (item = {}) => {
50
+ const [state, setState] = (0, import_react.useState)({ isValid: false, ...item });
51
+ return [
52
+ state,
53
+ (e) => {
54
+ setState(e);
55
+ return e;
56
+ }
57
+ ];
58
+ };
59
+ var useAn = useA;
60
+ var useOptional = (item) => {
61
+ const [state, setState] = (0, import_react.useState)(item);
62
+ const set = (e) => {
63
+ setState(e);
64
+ return e;
65
+ };
66
+ return [state, set, () => set()];
67
+ };
68
+ var useEntity = useA;
69
+ var useList = (...items) => {
70
+ const [state, setState] = (0, import_react.useState)((0, import_easy.toList)(...items));
71
+ return [
72
+ state,
73
+ (e) => {
74
+ setState(e);
75
+ return e;
76
+ }
77
+ ];
78
+ };
79
+ var usePageList = (...items) => {
80
+ const [pages, setPages] = (0, import_react.useState)((0, import_easy.toPageList)(items));
81
+ return [
82
+ pages,
83
+ (e) => {
84
+ setPages(e);
85
+ return e;
86
+ }
87
+ ];
88
+ };
89
+ var usePaging = (f, options) => {
90
+ const [list, setList] = usePageList();
91
+ const [skip, setSkip] = (0, import_react.useState)(options?.skip ?? 0);
92
+ const [take] = (0, import_react.useState)(options?.take ?? 5);
93
+ const next = (options2 = { skip, take }) => f(options2).then((items) => {
94
+ setSkip(skip + take);
95
+ return setList((0, import_easy.toPageList)(list.add(items), items));
96
+ });
97
+ return [list, next, list.length < (list?.total ?? 0), skip, take];
98
+ };
99
+ var useGet = (f, initial) => {
100
+ const [item, setItem] = (0, import_react.useState)(initial ?? {});
101
+ const getter = () => f().then((i) => {
102
+ setItem(i);
103
+ return i;
104
+ });
105
+ return [item, getter];
106
+ };
107
+ var useGetList = (f) => {
108
+ const [list, setList] = usePageList();
109
+ const getter = () => f().then((l) => setList((0, import_easy.isPageList)(l) ? l : (0, import_easy.toPageList)(l, { total: l.length })));
110
+ return [list, getter];
111
+ };
112
+
113
+ // src/utils/useOnce.ts
114
+ var import_react2 = require("react");
115
+ function useOnce(f, options) {
116
+ const [item, setItem] = (0, import_react2.useState)(options?.initial);
117
+ (0, import_react2.useEffect)(() => void f().then((i) => setItem(i)), options?.deps ?? []);
118
+ return [item];
119
+ }
20
120
  // Annotate the CommonJS export names for ESM import in node:
21
121
  0 && (module.exports = {
22
- ...require("./layout"),
23
- ...require("./utils")
122
+ If,
123
+ useA,
124
+ useAn,
125
+ useEntity,
126
+ useGet,
127
+ useGetList,
128
+ useList,
129
+ useOnce,
130
+ useOptional,
131
+ usePageList,
132
+ usePaging,
133
+ useToggle
24
134
  });
25
135
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './layout';\nexport * from './utils';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,qBAAd;AACA,wBAAc,oBADd;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/layout/If.tsx","../src/utils/Hooks.ts","../src/utils/useOnce.ts"],"sourcesContent":["export * from './layout';\nexport * from './utils';\n","import * as React from 'react';\nimport { FunctionComponent, ReactElement, ReactNode } from 'react';\n\nexport interface IfProps {\n condition: any | undefined;\n children?: ReactNode;\n}\n\nexport const If: FunctionComponent<IfProps> = ({ condition, children }): ReactElement | null => (condition ? <>{children}</> : null);\n","import { isPageList, List, Optional, PageList, PageOptions, toList, toPageList, Validatable } from '@thisisagile/easy';\nimport { useState } from 'react';\n\nexport const useToggle = (initialState = false): [boolean, () => void] => {\n const [state, setState] = useState<boolean>(initialState);\n return [state, () => setState(s => !s)];\n};\n\nexport const useA = <E extends Validatable>(item: Partial<E> = {} as Partial<E>): [E, (e: E) => E] => {\n const [state, setState] = useState<E>({ isValid: false, ...item } as E);\n return [\n state,\n (e: E): E => {\n setState(e);\n return e;\n },\n ];\n};\n\nexport const useAn = useA;\n\nexport const useOptional = <E>(item?: Partial<E>): [E, (e: Optional<E>) => Optional<E>, () => Optional<E>] => {\n const [state, setState] = useState<E>(item as E);\n const set = (e?: Optional<E>): Optional<E> => {\n setState(e as E);\n return e;\n };\n return [state, set, (): Optional<E> => set()];\n};\n\nexport const useEntity = useA;\n\nexport const useList = <E>(...items: E[]): [List<E>, (e: List<E>) => List<E>] => {\n const [state, setState] = useState<List<E>>(toList<E>(...items));\n return [\n state,\n (e: List<E>): List<E> => {\n setState(e);\n return e;\n },\n ];\n};\n\nexport const usePageList = <E>(...items: E[]): [PageList<E>, (e: PageList<E>) => PageList<E>] => {\n const [pages, setPages] = useState<PageList<E>>(toPageList<E>(items));\n return [\n pages,\n (e: PageList<E>): PageList<E> => {\n setPages(e);\n return e;\n },\n ];\n};\n\nexport const usePaging = <E>(\n f: (options?: PageOptions) => Promise<PageList<E>>,\n options?: PageOptions\n): [PageList<E>, (options?: PageOptions) => Promise<PageList<E>>, boolean, number, number] => {\n const [list, setList] = usePageList<E>();\n const [skip, setSkip] = useState(options?.skip ?? 0);\n const [take] = useState(options?.take ?? 5);\n const next = (options: PageOptions = { skip, take }) =>\n f(options).then(items => {\n setSkip(skip + take);\n return setList(toPageList(list.add(items), items));\n });\n return [list, next, list.length < (list?.total ?? 0), skip, take];\n};\n\nexport const useGet = <E>(f: () => Promise<E>, initial?: Partial<E>): [E, () => Promise<E>] => {\n const [item, setItem] = useState((initial ?? {}) as E);\n const getter = () =>\n f().then(i => {\n setItem(i);\n return i;\n });\n return [item, getter];\n};\n\nexport const useGetList = <E>(f: () => Promise<List<E>>): [List<E>, () => Promise<PageList<E>>] => {\n const [list, setList] = usePageList<E>();\n const getter = () => f().then(l => setList(isPageList<E>(l) ? l : toPageList(l, { total: l.length })));\n return [list, getter];\n};\n","import { DependencyList, useEffect, useState } from 'react';\n\nexport type UseOnceOptions<E> = {\n deps?: DependencyList;\n initial?: Partial<E>;\n};\n\nexport function useOnce<E>(f: () => Promise<E>, options?: UseOnceOptions<E>): [E] {\n const [item, setItem] = useState(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,CAAC,CAAC,GAAG,SAAS,QAAQ,CAAC,CAAC;AACnE,SAAO,CAAC,IAAI;AACd;","names":["options","import_react"]}
@@ -1,5 +1,6 @@
1
+ // src/layout/If.tsx
1
2
  import { Fragment, jsx } from "react/jsx-runtime";
2
- const If = ({ condition, children }) => condition ? /* @__PURE__ */ jsx(Fragment, { children }) : null;
3
+ var If = ({ condition, children }) => condition ? /* @__PURE__ */ jsx(Fragment, { children }) : null;
3
4
  export {
4
5
  If
5
6
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/layout/If.tsx"],"sourcesContent":["import * as React from 'react';\nimport { FunctionComponent, ReactElement, ReactNode } from 'react';\n\nexport interface IfProps {\n condition: any | undefined;\n children?: ReactNode;\n}\n\nexport const If: FunctionComponent<IfProps> = ({ condition, children }): ReactElement | null => (condition ? <>{children}</> : null);\n"],"mappings":"AAQ6G;AAAtG,MAAM,KAAiC,CAAC,EAAE,WAAW,SAAS,MAA4B,YAAY,gCAAG,UAAS,IAAM;","names":[]}
1
+ {"version":3,"sources":["../../src/layout/If.tsx"],"sourcesContent":["import * as React from 'react';\nimport { FunctionComponent, ReactElement, ReactNode } from 'react';\n\nexport interface IfProps {\n condition: any | undefined;\n children?: ReactNode;\n}\n\nexport const If: FunctionComponent<IfProps> = ({ condition, children }): ReactElement | null => (condition ? <>{children}</> : null);\n"],"mappings":";AAQ6G;AAAtG,IAAM,KAAiC,CAAC,EAAE,WAAW,SAAS,MAA4B,YAAY,gCAAG,UAAS,IAAM;","names":[]}
@@ -1,10 +1,11 @@
1
+ // src/utils/Hooks.ts
1
2
  import { isPageList, toList, toPageList } from "@thisisagile/easy";
2
3
  import { useState } from "react";
3
- const useToggle = (initialState = false) => {
4
+ var useToggle = (initialState = false) => {
4
5
  const [state, setState] = useState(initialState);
5
6
  return [state, () => setState((s) => !s)];
6
7
  };
7
- const useA = (item = {}) => {
8
+ var useA = (item = {}) => {
8
9
  const [state, setState] = useState({ isValid: false, ...item });
9
10
  return [
10
11
  state,
@@ -14,8 +15,8 @@ const useA = (item = {}) => {
14
15
  }
15
16
  ];
16
17
  };
17
- const useAn = useA;
18
- const useOptional = (item) => {
18
+ var useAn = useA;
19
+ var useOptional = (item) => {
19
20
  const [state, setState] = useState(item);
20
21
  const set = (e) => {
21
22
  setState(e);
@@ -23,8 +24,8 @@ const useOptional = (item) => {
23
24
  };
24
25
  return [state, set, () => set()];
25
26
  };
26
- const useEntity = useA;
27
- const useList = (...items) => {
27
+ var useEntity = useA;
28
+ var useList = (...items) => {
28
29
  const [state, setState] = useState(toList(...items));
29
30
  return [
30
31
  state,
@@ -34,7 +35,7 @@ const useList = (...items) => {
34
35
  }
35
36
  ];
36
37
  };
37
- const usePageList = (...items) => {
38
+ var usePageList = (...items) => {
38
39
  const [pages, setPages] = useState(toPageList(items));
39
40
  return [
40
41
  pages,
@@ -44,7 +45,7 @@ const usePageList = (...items) => {
44
45
  }
45
46
  ];
46
47
  };
47
- const usePaging = (f, options) => {
48
+ var usePaging = (f, options) => {
48
49
  const [list, setList] = usePageList();
49
50
  const [skip, setSkip] = useState(options?.skip ?? 0);
50
51
  const [take] = useState(options?.take ?? 5);
@@ -54,7 +55,7 @@ const usePaging = (f, options) => {
54
55
  });
55
56
  return [list, next, list.length < (list?.total ?? 0), skip, take];
56
57
  };
57
- const useGet = (f, initial) => {
58
+ var useGet = (f, initial) => {
58
59
  const [item, setItem] = useState(initial ?? {});
59
60
  const getter = () => f().then((i) => {
60
61
  setItem(i);
@@ -62,7 +63,7 @@ const useGet = (f, initial) => {
62
63
  });
63
64
  return [item, getter];
64
65
  };
65
- const useGetList = (f) => {
66
+ var useGetList = (f) => {
66
67
  const [list, setList] = usePageList();
67
68
  const getter = () => f().then((l) => setList(isPageList(l) ? l : toPageList(l, { total: l.length })));
68
69
  return [list, getter];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/Hooks.ts"],"sourcesContent":["import { isPageList, List, Optional, PageList, PageOptions, toList, toPageList, Validatable } from '@thisisagile/easy';\nimport { useState } from 'react';\n\nexport const useToggle = (initialState = false): [boolean, () => void] => {\n const [state, setState] = useState<boolean>(initialState);\n return [state, () => setState(s => !s)];\n};\n\nexport const useA = <E extends Validatable>(item: Partial<E> = {} as Partial<E>): [E, (e: E) => E] => {\n const [state, setState] = useState<E>({ isValid: false, ...item } as E);\n return [\n state,\n (e: E): E => {\n setState(e);\n return e;\n },\n ];\n};\n\nexport const useAn = useA;\n\nexport const useOptional = <E>(item?: Partial<E>): [E, (e: Optional<E>) => Optional<E>, () => Optional<E>] => {\n const [state, setState] = useState<E>(item as E);\n const set = (e?: Optional<E>): Optional<E> => {\n setState(e as E);\n return e;\n };\n return [state, set, (): Optional<E> => set()];\n};\n\nexport const useEntity = useA;\n\nexport const useList = <E>(...items: E[]): [List<E>, (e: List<E>) => List<E>] => {\n const [state, setState] = useState<List<E>>(toList<E>(...items));\n return [\n state,\n (e: List<E>): List<E> => {\n setState(e);\n return e;\n },\n ];\n};\n\nexport const usePageList = <E>(...items: E[]): [PageList<E>, (e: PageList<E>) => PageList<E>] => {\n const [pages, setPages] = useState<PageList<E>>(toPageList<E>(items));\n return [\n pages,\n (e: PageList<E>): PageList<E> => {\n setPages(e);\n return e;\n },\n ];\n};\n\nexport const usePaging = <E>(\n f: (options?: PageOptions) => Promise<PageList<E>>,\n options?: PageOptions\n): [PageList<E>, (options?: PageOptions) => Promise<PageList<E>>, boolean, number, number] => {\n const [list, setList] = usePageList<E>();\n const [skip, setSkip] = useState(options?.skip ?? 0);\n const [take] = useState(options?.take ?? 5);\n const next = (options: PageOptions = { skip, take }) =>\n f(options).then(items => {\n setSkip(skip + take);\n return setList(toPageList(list.add(items), items));\n });\n return [list, next, list.length < (list?.total ?? 0), skip, take];\n};\n\nexport const useGet = <E>(f: () => Promise<E>, initial?: Partial<E>): [E, () => Promise<E>] => {\n const [item, setItem] = useState((initial ?? {}) as E);\n const getter = () =>\n f().then(i => {\n setItem(i);\n return i;\n });\n return [item, getter];\n};\n\nexport const useGetList = <E>(f: () => Promise<List<E>>): [List<E>, () => Promise<PageList<E>>] => {\n const [list, setList] = usePageList<E>();\n const getter = () => f().then(l => setList(isPageList<E>(l) ? l : toPageList(l, { total: l.length })));\n return [list, getter];\n};\n"],"mappings":"AAAA,SAAS,YAAmD,QAAQ,kBAA+B;AACnG,SAAS,gBAAgB;AAElB,MAAM,YAAY,CAAC,eAAe,UAAiC;AACxE,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkB,YAAY;AACxD,SAAO,CAAC,OAAO,MAAM,SAAS,OAAK,CAAC,CAAC,CAAC;AACxC;AAEO,MAAM,OAAO,CAAwB,OAAmB,CAAC,MAAsC;AACpG,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAY,EAAE,SAAS,OAAO,GAAG,KAAK,CAAM;AACtE,SAAO;AAAA,IACL;AAAA,IACA,CAAC,MAAY;AACX,eAAS,CAAC;AACV,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,QAAQ;AAEd,MAAM,cAAc,CAAI,SAA+E;AAC5G,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAY,IAAS;AAC/C,QAAM,MAAM,CAAC,MAAiC;AAC5C,aAAS,CAAM;AACf,WAAO;AAAA,EACT;AACA,SAAO,CAAC,OAAO,KAAK,MAAmB,IAAI,CAAC;AAC9C;AAEO,MAAM,YAAY;AAElB,MAAM,UAAU,IAAO,UAAmD;AAC/E,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkB,OAAU,GAAG,KAAK,CAAC;AAC/D,SAAO;AAAA,IACL;AAAA,IACA,CAAC,MAAwB;AACvB,eAAS,CAAC;AACV,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,cAAc,IAAO,UAA+D;AAC/F,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAsB,WAAc,KAAK,CAAC;AACpE,SAAO;AAAA,IACL;AAAA,IACA,CAAC,MAAgC;AAC/B,eAAS,CAAC;AACV,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,YAAY,CACvB,GACA,YAC4F;AAC5F,QAAM,CAAC,MAAM,OAAO,IAAI,YAAe;AACvC,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,SAAS,QAAQ,CAAC;AACnD,QAAM,CAAC,IAAI,IAAI,SAAS,SAAS,QAAQ,CAAC;AAC1C,QAAM,OAAO,CAACA,WAAuB,EAAE,MAAM,KAAK,MAChD,EAAEA,QAAO,EAAE,KAAK,WAAS;AACvB,YAAQ,OAAO,IAAI;AACnB,WAAO,QAAQ,WAAW,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC;AAAA,EACnD,CAAC;AACH,SAAO,CAAC,MAAM,MAAM,KAAK,UAAU,MAAM,SAAS,IAAI,MAAM,IAAI;AAClE;AAEO,MAAM,SAAS,CAAI,GAAqB,YAAgD;AAC7F,QAAM,CAAC,MAAM,OAAO,IAAI,SAAU,WAAW,CAAC,CAAO;AACrD,QAAM,SAAS,MACb,EAAE,EAAE,KAAK,OAAK;AACZ,YAAQ,CAAC;AACT,WAAO;AAAA,EACT,CAAC;AACH,SAAO,CAAC,MAAM,MAAM;AACtB;AAEO,MAAM,aAAa,CAAI,MAAqE;AACjG,QAAM,CAAC,MAAM,OAAO,IAAI,YAAe;AACvC,QAAM,SAAS,MAAM,EAAE,EAAE,KAAK,OAAK,QAAQ,WAAc,CAAC,IAAI,IAAI,WAAW,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACrG,SAAO,CAAC,MAAM,MAAM;AACtB;","names":["options"]}
1
+ {"version":3,"sources":["../../src/utils/Hooks.ts"],"sourcesContent":["import { isPageList, List, Optional, PageList, PageOptions, toList, toPageList, Validatable } from '@thisisagile/easy';\nimport { useState } from 'react';\n\nexport const useToggle = (initialState = false): [boolean, () => void] => {\n const [state, setState] = useState<boolean>(initialState);\n return [state, () => setState(s => !s)];\n};\n\nexport const useA = <E extends Validatable>(item: Partial<E> = {} as Partial<E>): [E, (e: E) => E] => {\n const [state, setState] = useState<E>({ isValid: false, ...item } as E);\n return [\n state,\n (e: E): E => {\n setState(e);\n return e;\n },\n ];\n};\n\nexport const useAn = useA;\n\nexport const useOptional = <E>(item?: Partial<E>): [E, (e: Optional<E>) => Optional<E>, () => Optional<E>] => {\n const [state, setState] = useState<E>(item as E);\n const set = (e?: Optional<E>): Optional<E> => {\n setState(e as E);\n return e;\n };\n return [state, set, (): Optional<E> => set()];\n};\n\nexport const useEntity = useA;\n\nexport const useList = <E>(...items: E[]): [List<E>, (e: List<E>) => List<E>] => {\n const [state, setState] = useState<List<E>>(toList<E>(...items));\n return [\n state,\n (e: List<E>): List<E> => {\n setState(e);\n return e;\n },\n ];\n};\n\nexport const usePageList = <E>(...items: E[]): [PageList<E>, (e: PageList<E>) => PageList<E>] => {\n const [pages, setPages] = useState<PageList<E>>(toPageList<E>(items));\n return [\n pages,\n (e: PageList<E>): PageList<E> => {\n setPages(e);\n return e;\n },\n ];\n};\n\nexport const usePaging = <E>(\n f: (options?: PageOptions) => Promise<PageList<E>>,\n options?: PageOptions\n): [PageList<E>, (options?: PageOptions) => Promise<PageList<E>>, boolean, number, number] => {\n const [list, setList] = usePageList<E>();\n const [skip, setSkip] = useState(options?.skip ?? 0);\n const [take] = useState(options?.take ?? 5);\n const next = (options: PageOptions = { skip, take }) =>\n f(options).then(items => {\n setSkip(skip + take);\n return setList(toPageList(list.add(items), items));\n });\n return [list, next, list.length < (list?.total ?? 0), skip, take];\n};\n\nexport const useGet = <E>(f: () => Promise<E>, initial?: Partial<E>): [E, () => Promise<E>] => {\n const [item, setItem] = useState((initial ?? {}) as E);\n const getter = () =>\n f().then(i => {\n setItem(i);\n return i;\n });\n return [item, getter];\n};\n\nexport const useGetList = <E>(f: () => Promise<List<E>>): [List<E>, () => Promise<PageList<E>>] => {\n const [list, setList] = usePageList<E>();\n const getter = () => f().then(l => setList(isPageList<E>(l) ? l : toPageList(l, { total: l.length })));\n return [list, getter];\n};\n"],"mappings":";AAAA,SAA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C,IAAI,IAAI,SAAS,SAAS,QAAQ,CAAC;AAC1C,QAAM,OAAO,CAACA,WAAuB,EAAE,MAAM,KAAK,MAChD,EAAEA,QAAO,EAAE,KAAK,WAAS;AACvB,YAAQ,OAAO,IAAI;AACnB,WAAO,QAAQ,WAAW,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC;AAAA,EACnD,CAAC;AACH,SAAO,CAAC,MAAM,MAAM,KAAK,UAAU,MAAM,SAAS,IAAI,MAAM,IAAI;AAClE;AAEO,IAAM,SAAS,CAAI,GAAqB,YAAgD;AAC7F,QAAM,CAAC,MAAM,OAAO,IAAI,SAAU,WAAW,CAAC,CAAO;AACrD,QAAM,SAAS,MACb,EAAE,EAAE,KAAK,OAAK;AACZ,YAAQ,CAAC;AACT,WAAO;AAAA,EACT,CAAC;AACH,SAAO,CAAC,MAAM,MAAM;AACtB;AAEO,IAAM,aAAa,CAAI,MAAqE;AACjG,QAAM,CAAC,MAAM,OAAO,IAAI,YAAe;AACvC,QAAM,SAAS,MAAM,EAAE,EAAE,KAAK,OAAK,QAAQ,WAAc,CAAC,IAAI,IAAI,WAAW,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACrG,SAAO,CAAC,MAAM,MAAM;AACtB;","names":["options"]}
@@ -1,3 +1,4 @@
1
+ // src/utils/useOnce.ts
1
2
  import { useEffect, useState } from "react";
2
3
  function useOnce(f, options) {
3
4
  const [item, setItem] = useState(options?.initial);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/useOnce.ts"],"sourcesContent":["import { DependencyList, useEffect, useState } from 'react';\n\nexport type UseOnceOptions<E> = {\n deps?: DependencyList;\n initial?: Partial<E>;\n};\n\nexport function useOnce<E>(f: () => Promise<E>, options?: UseOnceOptions<E>): [E] {\n const [item, setItem] = useState(options?.initial as E);\n useEffect(() => void f().then(i => setItem(i)), options?.deps ?? []);\n return [item];\n}\n"],"mappings":"AAAA,SAAyB,WAAW,gBAAgB;AAO7C,SAAS,QAAW,GAAqB,SAAkC;AAChF,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,SAAS,OAAY;AACtD,YAAU,MAAM,KAAK,EAAE,EAAE,KAAK,OAAK,QAAQ,CAAC,CAAC,GAAG,SAAS,QAAQ,CAAC,CAAC;AACnE,SAAO,CAAC,IAAI;AACd;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/useOnce.ts"],"sourcesContent":["import { DependencyList, useEffect, useState } from 'react';\n\nexport type UseOnceOptions<E> = {\n deps?: DependencyList;\n initial?: Partial<E>;\n};\n\nexport function useOnce<E>(f: () => Promise<E>, options?: UseOnceOptions<E>): [E] {\n const [item, setItem] = useState(options?.initial as E);\n useEffect(() => void f().then(i => setItem(i)), options?.deps ?? []);\n return [item];\n}\n"],"mappings":";AAAA,SAAyB,WAAW,gBAAgB;AAO7C,SAAS,QAAW,GAAqB,SAAkC;AAChF,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,SAAS,OAAY;AACtD,YAAU,MAAM,KAAK,EAAE,EAAE,KAAK,OAAK,QAAQ,CAAC,CAAC,GAAG,SAAS,QAAQ,CAAC,CAAC;AACnE,SAAO,CAAC,IAAI;AACd;","names":[]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@thisisagile/easy-react",
3
- "version": "15.26.2",
3
+ "version": "15.27.0",
4
4
  "description": "Straightforward library building micro applications in react",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.mjs",
9
- "types": "dist/index",
9
+ "types": "dist/index.d.ts",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git@github.com:thisisagile/easy.git"
@@ -28,6 +28,7 @@
28
28
  "prepack": "yarn g:copy-readme",
29
29
  "demo": "cd demo && next dev -p 3001"
30
30
  },
31
+ "sideEffects": false,
31
32
  "files": [
32
33
  "dist",
33
34
  "src"
@@ -36,8 +37,8 @@
36
37
  "access": "public"
37
38
  },
38
39
  "devDependencies": {
39
- "@thisisagile/easy-test": "15.26.2",
40
- "@thisisagile/easy-test-react": "15.26.2",
40
+ "@thisisagile/easy-test": "15.27.0",
41
+ "@thisisagile/easy-test-react": "15.27.0",
41
42
  "@types/copyfiles": "^2.4.4",
42
43
  "copyfiles": "^2.4.1",
43
44
  "jest-environment-jsdom": "^29.7.0",
@@ -46,7 +47,7 @@
46
47
  "next-transpile-modules": "^10.0.0"
47
48
  },
48
49
  "dependencies": {
49
- "@thisisagile/easy": "^15.26.2",
50
+ "@thisisagile/easy": "^15.27.0",
50
51
  "react": "^18.2.0",
51
52
  "react-dom": "^18.2.0",
52
53
  "sass": "^1.62.1"
package/dist/layout/If.js DELETED
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var If_exports = {};
20
- __export(If_exports, {
21
- If: () => If
22
- });
23
- module.exports = __toCommonJS(If_exports);
24
- var import_jsx_runtime = require("react/jsx-runtime");
25
- const If = ({ condition, children }) => condition ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children }) : null;
26
- // Annotate the CommonJS export names for ESM import in node:
27
- 0 && (module.exports = {
28
- If
29
- });
30
- //# sourceMappingURL=If.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/layout/If.tsx"],"sourcesContent":["import * as React from 'react';\nimport { FunctionComponent, ReactElement, ReactNode } from 'react';\n\nexport interface IfProps {\n condition: any | undefined;\n children?: ReactNode;\n}\n\nexport const If: FunctionComponent<IfProps> = ({ condition, children }): ReactElement | null => (condition ? <>{children}</> : null);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ6G;AAAtG,MAAM,KAAiC,CAAC,EAAE,WAAW,SAAS,MAA4B,YAAY,2EAAG,UAAS,IAAM;","names":[]}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var layout_exports = {};
17
- module.exports = __toCommonJS(layout_exports);
18
- __reExport(layout_exports, require("./If"), module.exports);
19
- // Annotate the CommonJS export names for ESM import in node:
20
- 0 && (module.exports = {
21
- ...require("./If")
22
- });
23
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/layout/index.ts"],"sourcesContent":["export * from './If';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,2BAAc,iBAAd;","names":[]}
@@ -1,115 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var Hooks_exports = {};
20
- __export(Hooks_exports, {
21
- useA: () => useA,
22
- useAn: () => useAn,
23
- useEntity: () => useEntity,
24
- useGet: () => useGet,
25
- useGetList: () => useGetList,
26
- useList: () => useList,
27
- useOptional: () => useOptional,
28
- usePageList: () => usePageList,
29
- usePaging: () => usePaging,
30
- useToggle: () => useToggle
31
- });
32
- module.exports = __toCommonJS(Hooks_exports);
33
- var import_easy = require("@thisisagile/easy");
34
- var import_react = require("react");
35
- const useToggle = (initialState = false) => {
36
- const [state, setState] = (0, import_react.useState)(initialState);
37
- return [state, () => setState((s) => !s)];
38
- };
39
- const useA = (item = {}) => {
40
- const [state, setState] = (0, import_react.useState)({ isValid: false, ...item });
41
- return [
42
- state,
43
- (e) => {
44
- setState(e);
45
- return e;
46
- }
47
- ];
48
- };
49
- const useAn = useA;
50
- const useOptional = (item) => {
51
- const [state, setState] = (0, import_react.useState)(item);
52
- const set = (e) => {
53
- setState(e);
54
- return e;
55
- };
56
- return [state, set, () => set()];
57
- };
58
- const useEntity = useA;
59
- const useList = (...items) => {
60
- const [state, setState] = (0, import_react.useState)((0, import_easy.toList)(...items));
61
- return [
62
- state,
63
- (e) => {
64
- setState(e);
65
- return e;
66
- }
67
- ];
68
- };
69
- const usePageList = (...items) => {
70
- const [pages, setPages] = (0, import_react.useState)((0, import_easy.toPageList)(items));
71
- return [
72
- pages,
73
- (e) => {
74
- setPages(e);
75
- return e;
76
- }
77
- ];
78
- };
79
- const usePaging = (f, options) => {
80
- const [list, setList] = usePageList();
81
- const [skip, setSkip] = (0, import_react.useState)(options?.skip ?? 0);
82
- const [take] = (0, import_react.useState)(options?.take ?? 5);
83
- const next = (options2 = { skip, take }) => f(options2).then((items) => {
84
- setSkip(skip + take);
85
- return setList((0, import_easy.toPageList)(list.add(items), items));
86
- });
87
- return [list, next, list.length < (list?.total ?? 0), skip, take];
88
- };
89
- const useGet = (f, initial) => {
90
- const [item, setItem] = (0, import_react.useState)(initial ?? {});
91
- const getter = () => f().then((i) => {
92
- setItem(i);
93
- return i;
94
- });
95
- return [item, getter];
96
- };
97
- const useGetList = (f) => {
98
- const [list, setList] = usePageList();
99
- const getter = () => f().then((l) => setList((0, import_easy.isPageList)(l) ? l : (0, import_easy.toPageList)(l, { total: l.length })));
100
- return [list, getter];
101
- };
102
- // Annotate the CommonJS export names for ESM import in node:
103
- 0 && (module.exports = {
104
- useA,
105
- useAn,
106
- useEntity,
107
- useGet,
108
- useGetList,
109
- useList,
110
- useOptional,
111
- usePageList,
112
- usePaging,
113
- useToggle
114
- });
115
- //# sourceMappingURL=Hooks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/Hooks.ts"],"sourcesContent":["import { isPageList, List, Optional, PageList, PageOptions, toList, toPageList, Validatable } from '@thisisagile/easy';\nimport { useState } from 'react';\n\nexport const useToggle = (initialState = false): [boolean, () => void] => {\n const [state, setState] = useState<boolean>(initialState);\n return [state, () => setState(s => !s)];\n};\n\nexport const useA = <E extends Validatable>(item: Partial<E> = {} as Partial<E>): [E, (e: E) => E] => {\n const [state, setState] = useState<E>({ isValid: false, ...item } as E);\n return [\n state,\n (e: E): E => {\n setState(e);\n return e;\n },\n ];\n};\n\nexport const useAn = useA;\n\nexport const useOptional = <E>(item?: Partial<E>): [E, (e: Optional<E>) => Optional<E>, () => Optional<E>] => {\n const [state, setState] = useState<E>(item as E);\n const set = (e?: Optional<E>): Optional<E> => {\n setState(e as E);\n return e;\n };\n return [state, set, (): Optional<E> => set()];\n};\n\nexport const useEntity = useA;\n\nexport const useList = <E>(...items: E[]): [List<E>, (e: List<E>) => List<E>] => {\n const [state, setState] = useState<List<E>>(toList<E>(...items));\n return [\n state,\n (e: List<E>): List<E> => {\n setState(e);\n return e;\n },\n ];\n};\n\nexport const usePageList = <E>(...items: E[]): [PageList<E>, (e: PageList<E>) => PageList<E>] => {\n const [pages, setPages] = useState<PageList<E>>(toPageList<E>(items));\n return [\n pages,\n (e: PageList<E>): PageList<E> => {\n setPages(e);\n return e;\n },\n ];\n};\n\nexport const usePaging = <E>(\n f: (options?: PageOptions) => Promise<PageList<E>>,\n options?: PageOptions\n): [PageList<E>, (options?: PageOptions) => Promise<PageList<E>>, boolean, number, number] => {\n const [list, setList] = usePageList<E>();\n const [skip, setSkip] = useState(options?.skip ?? 0);\n const [take] = useState(options?.take ?? 5);\n const next = (options: PageOptions = { skip, take }) =>\n f(options).then(items => {\n setSkip(skip + take);\n return setList(toPageList(list.add(items), items));\n });\n return [list, next, list.length < (list?.total ?? 0), skip, take];\n};\n\nexport const useGet = <E>(f: () => Promise<E>, initial?: Partial<E>): [E, () => Promise<E>] => {\n const [item, setItem] = useState((initial ?? {}) as E);\n const getter = () =>\n f().then(i => {\n setItem(i);\n return i;\n });\n return [item, getter];\n};\n\nexport const useGetList = <E>(f: () => Promise<List<E>>): [List<E>, () => Promise<PageList<E>>] => {\n const [list, setList] = usePageList<E>();\n const getter = () => f().then(l => setList(isPageList<E>(l) ? l : toPageList(l, { total: l.length })));\n return [list, getter];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmG;AACnG,mBAAyB;AAElB,MAAM,YAAY,CAAC,e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AACA,WAAuB,EAAE,MAAM,KAAK,MAChD,EAAEA,QAAO,EAAE,KAAK,WAAS;AACvB,YAAQ,OAAO,IAAI;AACnB,WAAO,YAAQ,wBAAW,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC;AAAA,EACnD,CAAC;AACH,SAAO,CAAC,MAAM,MAAM,KAAK,UAAU,MAAM,SAAS,IAAI,MAAM,IAAI;AAClE;AAEO,MAAM,SAAS,CAAI,GAAqB,YAAgD;AAC7F,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAU,WAAW,CAAC,CAAO;AACrD,QAAM,SAAS,MACb,EAAE,EAAE,KAAK,OAAK;AACZ,YAAQ,CAAC;AACT,WAAO;AAAA,EACT,CAAC;AACH,SAAO,CAAC,MAAM,MAAM;AACtB;AAEO,MAAM,aAAa,CAAI,MAAqE;AACjG,QAAM,CAAC,MAAM,OAAO,IAAI,YAAe;AACvC,QAAM,SAAS,MAAM,EAAE,EAAE,KAAK,OAAK,YAAQ,wBAAc,CAAC,IAAI,QAAI,wBAAW,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACrG,SAAO,CAAC,MAAM,MAAM;AACtB;","names":["options"]}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var utils_exports = {};
17
- module.exports = __toCommonJS(utils_exports);
18
- __reExport(utils_exports, require("./Hooks"), module.exports);
19
- __reExport(utils_exports, require("./useOnce"), module.exports);
20
- // Annotate the CommonJS export names for ESM import in node:
21
- 0 && (module.exports = {
22
- ...require("./Hooks"),
23
- ...require("./useOnce")
24
- });
25
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './Hooks';\nexport * from './useOnce';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,oBAAd;AACA,0BAAc,sBADd;","names":[]}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useOnce_exports = {};
20
- __export(useOnce_exports, {
21
- useOnce: () => useOnce
22
- });
23
- module.exports = __toCommonJS(useOnce_exports);
24
- var import_react = require("react");
25
- function useOnce(f, options) {
26
- const [item, setItem] = (0, import_react.useState)(options?.initial);
27
- (0, import_react.useEffect)(() => void f().then((i) => setItem(i)), options?.deps ?? []);
28
- return [item];
29
- }
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- useOnce
33
- });
34
- //# sourceMappingURL=useOnce.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/useOnce.ts"],"sourcesContent":["import { DependencyList, useEffect, useState } from 'react';\n\nexport type UseOnceOptions<E> = {\n deps?: DependencyList;\n initial?: Partial<E>;\n};\n\nexport function useOnce<E>(f: () => Promise<E>, options?: UseOnceOptions<E>): [E] {\n const [item, setItem] = useState(options?.initial as E);\n useEffect(() => void f().then(i => setItem(i)), options?.deps ?? []);\n return [item];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoD;AAO7C,SAAS,QAAW,GAAqB,SAAkC;AAChF,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,SAAS,OAAY;AACtD,8BAAU,MAAM,KAAK,EAAE,EAAE,KAAK,OAAK,QAAQ,CAAC,CAAC,GAAG,SAAS,QAAQ,CAAC,CAAC;AACnE,SAAO,CAAC,IAAI;AACd;","names":[]}