@kwiz/fluentui 1.0.176 → 1.0.178

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.
@@ -4,10 +4,11 @@ export * from './drag-drop';
4
4
  export * from './hooks';
5
5
  export * from './hooks-events';
6
6
  export * from './use-alerts';
7
- export * from './use-track-changes';
7
+ export * from './use-controlled-state-tracker';
8
8
  export * from './use-highlight';
9
+ export * from './use-is-concurrenct';
9
10
  export * from './use-reload-tracker';
10
11
  export * from './use-show-on-hover';
11
12
  export * from './use-theme';
12
13
  export * from './use-toast';
13
- export * from './use-controlled-state-tracker';
14
+ export * from './use-track-changes';
@@ -4,11 +4,12 @@ export * from './drag-drop';
4
4
  export * from './hooks';
5
5
  export * from './hooks-events';
6
6
  export * from './use-alerts';
7
- export * from './use-track-changes';
7
+ export * from './use-controlled-state-tracker';
8
8
  export * from './use-highlight';
9
+ export * from './use-is-concurrenct';
9
10
  export * from './use-reload-tracker';
10
11
  export * from './use-show-on-hover';
11
12
  export * from './use-theme';
12
13
  export * from './use-toast';
13
- export * from './use-controlled-state-tracker';
14
+ export * from './use-track-changes';
14
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Call at the beginning of a useEffect, check after all your promises finished before applying results to state.
3
+ * You must keep the same name for each useEffect
4
+ * const {getConcurrency} = useIsConcurrent();
5
+ * useEffect(()=>{
6
+ * const c = getConcurrency('loading data');
7
+ * const result = await someSlowPromise();
8
+ * if( c.isCurrent() ) setData(result);
9
+ * },[]);
10
+ */
11
+ export declare function useIsConcurrent(): {
12
+ isCurrent: (effectName: string, value: number) => boolean;
13
+ /** effectName must be unique for each useEffect */
14
+ getConcurrency: (effectName: string) => {
15
+ value: number;
16
+ isCurrent: () => boolean;
17
+ };
18
+ };
@@ -0,0 +1,37 @@
1
+ import { CommonLogger } from "@kwiz/common";
2
+ import { useCallback, useRef } from "react";
3
+ const logger = new CommonLogger("useIsConcurrent");
4
+ /**
5
+ * Call at the beginning of a useEffect, check after all your promises finished before applying results to state.
6
+ * You must keep the same name for each useEffect
7
+ * const {getConcurrency} = useIsConcurrent();
8
+ * useEffect(()=>{
9
+ * const c = getConcurrency('loading data');
10
+ * const result = await someSlowPromise();
11
+ * if( c.isCurrent() ) setData(result);
12
+ * },[]);
13
+ */
14
+ export function useIsConcurrent() {
15
+ const keys = useRef({});
16
+ const isCurrent = useCallback((effectName, value) => {
17
+ const isConcurrent = keys.current[effectName] === value;
18
+ if (!isConcurrent)
19
+ logger.log(`${effectName}:${value} is not concurrent`);
20
+ return isConcurrent;
21
+ }, []);
22
+ return {
23
+ isCurrent,
24
+ /** effectName must be unique for each useEffect */
25
+ getConcurrency: (effectName) => {
26
+ const myValue = (keys.current[effectName] > 0 ? keys.current[effectName] : 0) + 1;
27
+ //update ref
28
+ keys.current[effectName] = myValue;
29
+ logger.log(`${effectName}:${myValue} started`);
30
+ return {
31
+ value: myValue,
32
+ isCurrent: () => isCurrent(effectName, myValue)
33
+ };
34
+ }
35
+ };
36
+ }
37
+ //# sourceMappingURL=use-is-concurrenct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-is-concurrenct.js","sourceRoot":"","sources":["../../src/helpers/use-is-concurrenct.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAEnD;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe;IAC3B,MAAM,IAAI,GAAG,MAAM,CAAsB,EAAE,CAAC,CAAC;IAE7C,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,UAAkB,EAAE,KAAa,EAAE,EAAE;QAChE,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,KAAK,CAAC;QACxD,IAAI,CAAC,YAAY;YAAE,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,IAAI,KAAK,oBAAoB,CAAC,CAAC;QAC1E,OAAO,YAAY,CAAC;IACxB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACH,SAAS;QACT,mDAAmD;QACnD,cAAc,EAAE,CAAC,UAAkB,EAAE,EAAE;YACnC,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YAClF,YAAY;YACZ,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC;YAEnC,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,IAAI,OAAO,UAAU,CAAC,CAAC;YAC/C,OAAO;gBACH,KAAK,EAAE,OAAO;gBACd,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC;aAClD,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kwiz/fluentui",
3
- "version": "1.0.176",
3
+ "version": "1.0.178",
4
4
  "description": "KWIZ common controls for FluentUI",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",