@carbonorm/carbonreact 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ export type KeysMatching<T, V> = {
2
+ [K in keyof T]-?: T[K] extends V ? K : never;
3
+ }[keyof T];
@@ -1,2 +1,3 @@
1
- import { tRestfulObjectArrayValues, tStatefulApiData } from "variables/C6";
2
- export default function deleteRestfulObjectArrays<ObjectType = tRestfulObjectArrayValues, S = {}, P = {}>(dataOrCallback: ObjectType[] | (<K extends keyof S>(state: ((prevState: Readonly<S>, props: Readonly<P>) => (Pick<S, K> | S | null)) | (Pick<S, K> | S | null), callback?: () => void) => ObjectType[]), stateKey: S[keyof S] extends tStatefulApiData<ObjectType> ? keyof S : never, uniqueObjectId: keyof ObjectType, callback?: () => void): void;
1
+ import { tRestfulObjectArrayValues } from "variables/C6";
2
+ import { KeysMatching } from "./KeysMatching";
3
+ export default function deleteRestfulObjectArrays<ObjectType = tRestfulObjectArrayValues, S = {}, P = {}>(dataOrCallback: ObjectType[] | (<K extends keyof S>(state: ((prevState: Readonly<S>, props: Readonly<P>) => (Pick<S, K> | S | null)) | (Pick<S, K> | S | null), callback?: () => void) => ObjectType[]), stateKey: KeysMatching<S, ObjectType>, uniqueObjectId: keyof ObjectType, callback?: () => void): void;
@@ -1,4 +1,5 @@
1
- import { tRestfulObjectArrayValues, tStatefulApiData } from "variables/C6";
1
+ import { tRestfulObjectArrayValues } from "variables/C6";
2
+ import { KeysMatching } from "./KeysMatching";
2
3
  export declare enum eUpdateInsertMethod {
3
4
  REPLACE = 0,
4
5
  FIRST = 1,
@@ -14,4 +15,4 @@ export declare enum eUpdateInsertMethod {
14
15
  * @param callback - if you want to do something with the updated state, you can pass a callback here. Run as the second
15
16
  * parameter of setState.
16
17
  */
17
- export default function updateRestfulObjectArrays<ObjectType = tRestfulObjectArrayValues, S = {}, P = {}>(dataOrCallback: ObjectType[] | (<K extends keyof S>(state: ((prevState: Readonly<S>, props: Readonly<P>) => (Pick<S, K> | S | null)) | (Pick<S, K> | S | null), callback?: () => void) => ObjectType[]), stateKey: S[keyof S] extends tStatefulApiData<ObjectType> ? keyof S : never, uniqueObjectId: keyof ObjectType, insertUpdateOrder?: eUpdateInsertMethod, callback?: () => void): void;
18
+ export default function updateRestfulObjectArrays<ObjectType = tRestfulObjectArrayValues, S = {}, P = {}>(dataOrCallback: ObjectType[] | (<K extends keyof S>(state: ((prevState: Readonly<S>, props: Readonly<P>) => (Pick<S, K> | S | null)) | (Pick<S, K> | S | null), callback?: () => void) => ObjectType[]), stateKey: KeysMatching<S, ObjectType>, uniqueObjectId: keyof ObjectType, insertUpdateOrder?: eUpdateInsertMethod, callback?: () => void): void;
package/dist/index.d.ts CHANGED
@@ -20,6 +20,7 @@ export * from "./components/Nest/Nest";
20
20
  export { default as Popup } from "./components/Popup/Popup";
21
21
  export * from "./components/Popup/Popup";
22
22
  export * from "./hoc/GlobalHistory";
23
+ export * from "./hoc/KeysMatching";
23
24
  export { default as addValidSQL } from "./hoc/addValidSQL";
24
25
  export * from "./hoc/addValidSQL";
25
26
  export { default as changed } from "./hoc/changed";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carbonorm/carbonreact",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,3 @@
1
+
2
+
3
+ export type KeysMatching<T, V> = {[K in keyof T]-?: T[K] extends V ? K : never}[keyof T];
@@ -1,5 +1,6 @@
1
1
  import CarbonReact from "CarbonReact";
2
- import {tRestfulObjectArrayValues, tStatefulApiData} from "variables/C6";
2
+ import {tRestfulObjectArrayValues} from "variables/C6";
3
+ import {KeysMatching} from "./KeysMatching";
3
4
 
4
5
 
5
6
  //ObjectType, UniqueIdType extends keyof ObjectType
@@ -9,7 +10,7 @@ export default function deleteRestfulObjectArrays<ObjectType = tRestfulObjectArr
9
10
  state: ((prevState: Readonly<S>, props: Readonly<P>) => (Pick<S, K> | S | null)) | (Pick<S, K> | S | null),
10
11
  callback?: () => void
11
12
  ) => ObjectType[]),
12
- stateKey: S[keyof S] extends tStatefulApiData<ObjectType> ? keyof S : never,
13
+ stateKey: KeysMatching<S, ObjectType>,
13
14
  uniqueObjectId: keyof ObjectType,
14
15
  callback?: () => void): void {
15
16
 
@@ -1,5 +1,6 @@
1
- import {tRestfulObjectArrayValues, tStatefulApiData} from "variables/C6";
1
+ import {tRestfulObjectArrayValues} from "variables/C6";
2
2
  import CarbonReact from "CarbonReact";
3
+ import {KeysMatching} from "./KeysMatching";
3
4
 
4
5
 
5
6
  export enum eUpdateInsertMethod {
@@ -23,7 +24,7 @@ export default function updateRestfulObjectArrays<ObjectType = tRestfulObjectArr
23
24
  state: ((prevState: Readonly<S>, props: Readonly<P>) => (Pick<S, K> | S | null)) | (Pick<S, K> | S | null),
24
25
  callback?: () => void
25
26
  ) => ObjectType[]),
26
- stateKey: S[keyof S] extends tStatefulApiData<ObjectType> ? keyof S : never,
27
+ stateKey: KeysMatching<S, ObjectType>,
27
28
  uniqueObjectId: keyof ObjectType,
28
29
  insertUpdateOrder: eUpdateInsertMethod = eUpdateInsertMethod.LAST,
29
30
  callback?: () => void): void {
package/src/index.ts CHANGED
@@ -21,6 +21,7 @@ export * from "./components/Nest/Nest";
21
21
  export { default as Popup } from "./components/Popup/Popup";
22
22
  export * from "./components/Popup/Popup";
23
23
  export * from "./hoc/GlobalHistory";
24
+ export * from "./hoc/KeysMatching";
24
25
  export { default as addValidSQL } from "./hoc/addValidSQL";
25
26
  export * from "./hoc/addValidSQL";
26
27
  export { default as changed } from "./hoc/changed";