@thisisagile/easy-react 15.19.0 → 15.20.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.
@@ -1 +1,2 @@
1
1
  export * from './Hooks';
2
+ export * from './useOnce';
@@ -16,8 +16,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  var utils_exports = {};
17
17
  module.exports = __toCommonJS(utils_exports);
18
18
  __reExport(utils_exports, require("./Hooks"), module.exports);
19
+ __reExport(utils_exports, require("./useOnce"), module.exports);
19
20
  // Annotate the CommonJS export names for ESM import in node:
20
21
  0 && (module.exports = {
21
- ...require("./Hooks")
22
+ ...require("./Hooks"),
23
+ ...require("./useOnce")
22
24
  });
23
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './Hooks';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,oBAAd;","names":[]}
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,2 +1,3 @@
1
1
  export * from "./Hooks";
2
+ export * from "./useOnce";
2
3
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './Hooks';\n"],"mappings":"AAAA,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './Hooks';\nexport * from './useOnce';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,6 @@
1
+ import { DependencyList } from 'react';
2
+ export type UseOnceOptions<E> = {
3
+ deps?: DependencyList;
4
+ initial?: Partial<E>;
5
+ };
6
+ export declare function useOnce<E>(f: () => Promise<E>, options?: UseOnceOptions<E>): [E];
@@ -0,0 +1,34 @@
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
@@ -0,0 +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;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":[]}
@@ -0,0 +1,10 @@
1
+ import { useEffect, useState } from "react";
2
+ function useOnce(f, options) {
3
+ const [item, setItem] = useState(options?.initial);
4
+ useEffect(() => void f().then((i) => setItem(i)), options?.deps ?? []);
5
+ return [item];
6
+ }
7
+ export {
8
+ useOnce
9
+ };
10
+ //# sourceMappingURL=useOnce.mjs.map
@@ -0,0 +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":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy-react",
3
- "version": "15.19.0",
3
+ "version": "15.20.0",
4
4
  "description": "Straightforward library building micro applications in react",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
@@ -36,8 +36,8 @@
36
36
  "access": "public"
37
37
  },
38
38
  "devDependencies": {
39
- "@thisisagile/easy-test": "15.19.0",
40
- "@thisisagile/easy-test-react": "15.19.0",
39
+ "@thisisagile/easy-test": "15.20.0",
40
+ "@thisisagile/easy-test-react": "15.20.0",
41
41
  "@types/copyfiles": "^2.4.4",
42
42
  "copyfiles": "^2.4.1",
43
43
  "jest-environment-jsdom": "^29.7.0",
@@ -46,7 +46,7 @@
46
46
  "next-transpile-modules": "^10.0.0"
47
47
  },
48
48
  "dependencies": {
49
- "@thisisagile/easy": "^15.19.0",
49
+ "@thisisagile/easy": "^15.20.0",
50
50
  "react": "^18.2.0",
51
51
  "react-dom": "^18.2.0",
52
52
  "sass": "^1.62.1"
@@ -1 +1,2 @@
1
1
  export * from './Hooks';
2
+ export * from './useOnce';
@@ -0,0 +1,12 @@
1
+ import { DependencyList, useEffect, useState } from 'react';
2
+
3
+ export type UseOnceOptions<E> = {
4
+ deps?: DependencyList;
5
+ initial?: Partial<E>;
6
+ };
7
+
8
+ export function useOnce<E>(f: () => Promise<E>, options?: UseOnceOptions<E>): [E] {
9
+ const [item, setItem] = useState(options?.initial as E);
10
+ useEffect(() => void f().then(i => setItem(i)), options?.deps ?? []);
11
+ return [item];
12
+ }