@itwin/components-react 4.0.0-dev.14 → 4.0.0-dev.15

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.
@@ -7,6 +7,7 @@
7
7
  * The first promise will always be executed.
8
8
  * Any promises following the first while it is executing will be scheduled (and unscheduled), leaving only the last promise to be resolved.
9
9
  * Once the first promise finishes resolving, the last passed promise starts resolving.
10
+ * @throws if/when `valueToBeResolved` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.
10
11
  * @beta
11
12
  */
12
13
  export declare function useDebouncedAsyncValue<TReturn>(valueToBeResolved: undefined | (() => Promise<TReturn>)): {
@@ -1 +1 @@
1
- {"version":3,"file":"UseDebouncedAsyncValue.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":"AAIA;;GAEG;AAQH;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,EAAE,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;;;EAgCtG"}
1
+ {"version":3,"file":"UseDebouncedAsyncValue.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":"AAIA;;GAEG;AAQH;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,EAAE,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;;;EA8CtG"}
@@ -9,9 +9,9 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.useDebouncedAsyncValue = void 0;
11
11
  const react_1 = require("react");
12
+ const defer_1 = require("rxjs/internal/observable/defer");
12
13
  const publish_1 = require("rxjs/internal/operators/publish");
13
14
  const refCount_1 = require("rxjs/internal/operators/refCount");
14
- const defer_1 = require("rxjs/internal/observable/defer");
15
15
  const SubscriptionScheduler_1 = require("./SubscriptionScheduler");
16
16
  /**
17
17
  * Custom hook for working with promise values.
@@ -19,12 +19,17 @@ const SubscriptionScheduler_1 = require("./SubscriptionScheduler");
19
19
  * The first promise will always be executed.
20
20
  * Any promises following the first while it is executing will be scheduled (and unscheduled), leaving only the last promise to be resolved.
21
21
  * Once the first promise finishes resolving, the last passed promise starts resolving.
22
+ * @throws if/when `valueToBeResolved` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.
22
23
  * @beta
23
24
  */
24
25
  function useDebouncedAsyncValue(valueToBeResolved) {
25
26
  const scheduler = (0, react_1.useMemo)(() => new SubscriptionScheduler_1.SubscriptionScheduler(), []); // eslint-disable-line react-hooks/exhaustive-deps
26
27
  const [value, setValue] = (0, react_1.useState)();
27
28
  const [inProgress, setInProgress] = (0, react_1.useState)(false);
29
+ const [errorState, setErrorState] = (0, react_1.useState)({
30
+ error: undefined,
31
+ hasError: false,
32
+ });
28
33
  (0, react_1.useEffect)(() => {
29
34
  if (!valueToBeResolved) {
30
35
  setValue(undefined);
@@ -40,9 +45,15 @@ function useDebouncedAsyncValue(valueToBeResolved) {
40
45
  setValue(data);
41
46
  setInProgress(false);
42
47
  },
48
+ error: (err) => {
49
+ setErrorState({ error: err, hasError: true });
50
+ setInProgress(false);
51
+ },
43
52
  });
44
53
  return () => { subscription.unsubscribe(); };
45
54
  }, [valueToBeResolved, scheduler]);
55
+ if (errorState.hasError)
56
+ throw errorState.error ?? new Error("Exception in `useDebouncedAsyncValue`");
46
57
  return { value, inProgress };
47
58
  }
48
59
  exports.useDebouncedAsyncValue = useDebouncedAsyncValue;
@@ -1 +1 @@
1
- {"version":3,"file":"UseDebouncedAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iCAAqD;AACrD,6DAA0D;AAC1D,+DAA4D;AAC5D,0DAAuD;AACvD,mEAAsF;AAEtF;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CAAU,iBAAuD;IACrG,MAAM,SAAS,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAI,6CAAqB,EAAW,EAAE,EAAE,CAAC,CAAC,CAAC,kDAAkD;IAE7H,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,GAAW,CAAC;IAC9C,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEpD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,iBAAiB,EAAE;YACtB,QAAQ,CAAC,SAAS,CAAC,CAAC;YACpB,aAAa,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO;SACR;QAED,aAAa,CAAC,IAAI,CAAC,CAAC;QACpB,yFAAyF;QACzF,MAAM,YAAY,GAAG,IAAA,aAAK,EAAC,iBAAiB,CAAC;aAC1C,IAAI,CACH,IAAA,iBAAO,GAAE,EACT,IAAA,mBAAQ,GAAE,EACV,IAAA,4CAAoB,EAAC,SAAS,CAAC,CAChC;aACA,SAAS,CAAC;YACT,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;gBACb,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACf,aAAa,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;SACF,CAAC,CAAC;QAEL,OAAO,GAAG,EAAE,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,CAAC;IAEnC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,CAAC;AAhCD,wDAgCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport { useEffect, useMemo, useState } from \"react\";\r\nimport { publish } from \"rxjs/internal/operators/publish\";\r\nimport { refCount } from \"rxjs/internal/operators/refCount\";\r\nimport { defer } from \"rxjs/internal/observable/defer\";\r\nimport { scheduleSubscription, SubscriptionScheduler } from \"./SubscriptionScheduler\";\r\n\r\n/**\r\n * Custom hook for working with promise values.\r\n * Promises are debounced using trailing and leading edge.\r\n * The first promise will always be executed.\r\n * Any promises following the first while it is executing will be scheduled (and unscheduled), leaving only the last promise to be resolved.\r\n * Once the first promise finishes resolving, the last passed promise starts resolving.\r\n * @beta\r\n */\r\nexport function useDebouncedAsyncValue<TReturn>(valueToBeResolved: undefined | (() => Promise<TReturn>)) {\r\n const scheduler = useMemo(() => new SubscriptionScheduler<TReturn>(), []); // eslint-disable-line react-hooks/exhaustive-deps\r\n\r\n const [value, setValue] = useState<TReturn>();\r\n const [inProgress, setInProgress] = useState(false);\r\n\r\n useEffect(() => {\r\n if (!valueToBeResolved) {\r\n setValue(undefined);\r\n setInProgress(false);\r\n return;\r\n }\r\n\r\n setInProgress(true);\r\n // schedule and subscribe to the observable emitting value from valueToBeResolved promise\r\n const subscription = defer(valueToBeResolved)\r\n .pipe(\r\n publish(),\r\n refCount(),\r\n scheduleSubscription(scheduler),\r\n )\r\n .subscribe({\r\n next: (data) => {\r\n setValue(data);\r\n setInProgress(false);\r\n },\r\n });\r\n\r\n return () => { subscription.unsubscribe(); };\r\n }, [valueToBeResolved, scheduler]);\r\n\r\n return { value, inProgress };\r\n}\r\n"]}
1
+ {"version":3,"file":"UseDebouncedAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iCAAqD;AACrD,0DAAuD;AACvD,6DAA0D;AAC1D,+DAA4D;AAC5D,mEAAsF;AAEtF;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CAAU,iBAAuD;IACrG,MAAM,SAAS,GAA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AC,CAAC,CAAC;IAEnC,IAAI,UAAU,CAAC,QAAQ;QACrB,MAAM,UAAU,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAE/E,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,CAAC;AA9CD,wDA8CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport { useEffect, useMemo, useState } from \"react\";\r\nimport { defer } from \"rxjs/internal/observable/defer\";\r\nimport { publish } from \"rxjs/internal/operators/publish\";\r\nimport { refCount } from \"rxjs/internal/operators/refCount\";\r\nimport { scheduleSubscription, SubscriptionScheduler } from \"./SubscriptionScheduler\";\r\n\r\n/**\r\n * Custom hook for working with promise values.\r\n * Promises are debounced using trailing and leading edge.\r\n * The first promise will always be executed.\r\n * Any promises following the first while it is executing will be scheduled (and unscheduled), leaving only the last promise to be resolved.\r\n * Once the first promise finishes resolving, the last passed promise starts resolving.\r\n * @throws if/when `valueToBeResolved` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.\r\n * @beta\r\n */\r\nexport function useDebouncedAsyncValue<TReturn>(valueToBeResolved: undefined | (() => Promise<TReturn>)) {\r\n const scheduler = useMemo(() => new SubscriptionScheduler<TReturn>(), []); // eslint-disable-line react-hooks/exhaustive-deps\r\n\r\n const [value, setValue] = useState<TReturn>();\r\n const [inProgress, setInProgress] = useState(false);\r\n const [errorState, setErrorState] = useState<{\r\n error: Error | undefined;\r\n hasError: boolean;\r\n }>({\r\n error: undefined,\r\n hasError: false,\r\n });\r\n\r\n useEffect(() => {\r\n if (!valueToBeResolved) {\r\n setValue(undefined);\r\n setInProgress(false);\r\n return;\r\n }\r\n\r\n setInProgress(true);\r\n // schedule and subscribe to the observable emitting value from valueToBeResolved promise\r\n const subscription = defer(valueToBeResolved)\r\n .pipe(\r\n publish(),\r\n refCount(),\r\n scheduleSubscription(scheduler),\r\n )\r\n .subscribe({\r\n next: (data) => {\r\n setValue(data);\r\n setInProgress(false);\r\n },\r\n error: (err) => {\r\n setErrorState({ error: err, hasError: true });\r\n setInProgress(false);\r\n },\r\n });\r\n\r\n return () => { subscription.unsubscribe(); };\r\n }, [valueToBeResolved, scheduler]);\r\n\r\n if (errorState.hasError)\r\n throw errorState.error ?? new Error(\"Exception in `useDebouncedAsyncValue`\");\r\n\r\n return { value, inProgress };\r\n}\r\n"]}
@@ -7,6 +7,7 @@ import { IPropertyGridModel } from "./PropertyGridModel";
7
7
  import { IPropertyGridModelSource, PropertyGridModelSource } from "./PropertyGridModelSource";
8
8
  /**
9
9
  * Custom hook that gets [[PropertyData]] from given [[IPropertyDataProvider]] and subscribes to further data changes.
10
+ * @throws if/when `IPropertyDataProvider.getData()` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.
10
11
  * @public
11
12
  */
12
13
  export declare function usePropertyData(props: {
@@ -17,6 +18,7 @@ export declare function usePropertyData(props: {
17
18
  };
18
19
  /**
19
20
  * Custom hook that creates a [[PropertyGridModelSource]] and subscribes it to data updates from the data provider.
21
+ * @throws if/when `IPropertyDataProvider.getData()` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.
20
22
  * @public
21
23
  */
22
24
  export declare function usePropertyGridModelSource(props: {
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyGridHooks.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/propertygrid/internal/PropertyGridHooks.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAE9F;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IAAE,YAAY,EAAE,qBAAqB,CAAA;CAAE;;;EAa7E;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAAE,YAAY,EAAE,qBAAqB,CAAA;CAAE,2BAcxF;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IAAE,WAAW,EAAE,wBAAwB,CAAA;CAAE,4BAE3F;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAAE,WAAW,EAAE,wBAAwB,CAAA;CAAE,kCAapF"}
1
+ {"version":3,"file":"PropertyGridHooks.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/propertygrid/internal/PropertyGridHooks.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAE9F;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IAAE,YAAY,EAAE,qBAAqB,CAAA;CAAE;;;EAa7E;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAAE,YAAY,EAAE,qBAAqB,CAAA;CAAE,2BAcxF;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IAAE,WAAW,EAAE,wBAAwB,CAAA;CAAE,4BAE3F;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAAE,WAAW,EAAE,wBAAwB,CAAA;CAAE,kCAapF"}
@@ -15,6 +15,7 @@ const PropertyGridEventHandler_1 = require("./PropertyGridEventHandler");
15
15
  const PropertyGridModelSource_1 = require("./PropertyGridModelSource");
16
16
  /**
17
17
  * Custom hook that gets [[PropertyData]] from given [[IPropertyDataProvider]] and subscribes to further data changes.
18
+ * @throws if/when `IPropertyDataProvider.getData()` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.
18
19
  * @public
19
20
  */
20
21
  function usePropertyData(props) {
@@ -32,6 +33,7 @@ function usePropertyData(props) {
32
33
  exports.usePropertyData = usePropertyData;
33
34
  /**
34
35
  * Custom hook that creates a [[PropertyGridModelSource]] and subscribes it to data updates from the data provider.
36
+ * @throws if/when `IPropertyDataProvider.getData()` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.
35
37
  * @public
36
38
  */
37
39
  function usePropertyGridModelSource(props) {
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyGridHooks.js","sourceRoot":"","sources":["../../../../../src/components-react/propertygrid/internal/PropertyGridHooks.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iCAA8E;AAC9E,gFAA6E;AAE7E,gFAA6E;AAC7E,yEAAsE;AAEtE,uEAA8F;AAE9F;;;GAGG;AACH,SAAgB,eAAe,CAAC,KAA8C;IAC5E,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAE/B,MAAM,CAAC,YAAY,EAAE,mBAAmB,CAAC,GAAG,IAAA,kBAAU,EAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACvE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,OAAO,YAAY,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,EAAE;YACjD,mBAAmB,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,yGAAyG;IACzG,uDAAuD;IACvD,OAAO,IAAA,+CAAsB,EAAC,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE,CAAC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,CAAC;QACF,YAAY,EAAE,CAAC;QACf,OAAO,WAAW,CAAC,cAAc,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC9D,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,OAAO,KAAK,CAAC;AACf,CAAC;AAbD,oDAaC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyGrid\r\n */\r\n\r\nimport { useCallback, useEffect, useMemo, useReducer, useState } from \"react\";\r\nimport { useDebouncedAsyncValue } from \"../../common/UseDebouncedAsyncValue\";\r\nimport { IPropertyDataProvider } from \"../PropertyDataProvider\";\r\nimport { MutableGridItemFactory } from \"./flat-items/MutableGridItemFactory\";\r\nimport { PropertyGridEventHandler } from \"./PropertyGridEventHandler\";\r\nimport { IPropertyGridModel } from \"./PropertyGridModel\";\r\nimport { IPropertyGridModelSource, PropertyGridModelSource } from \"./PropertyGridModelSource\";\r\n\r\n/**\r\n * Custom hook that gets [[PropertyData]] from given [[IPropertyDataProvider]] and subscribes to further data changes.\r\n * @public\r\n */\r\nexport function usePropertyData(props: { dataProvider: IPropertyDataProvider }) {\r\n const { dataProvider } = props;\r\n\r\n const [forcedUpdate, triggerForcedUpdate] = useReducer(() => ({}), {});\r\n useEffect(() => {\r\n return dataProvider.onDataChanged.addListener(() => {\r\n triggerForcedUpdate();\r\n });\r\n }, [dataProvider]);\r\n\r\n // forcedUpdate is added to dependency list to re-memo getData promise when onDataChanged emits an event.\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n return useDebouncedAsyncValue(useCallback(async () => dataProvider.getData(), [dataProvider, forcedUpdate]));\r\n}\r\n\r\n/**\r\n * Custom hook that creates a [[PropertyGridModelSource]] and subscribes it to data updates from the data provider.\r\n * @public\r\n */\r\nexport function usePropertyGridModelSource(props: { dataProvider: IPropertyDataProvider }) {\r\n const { value: propertyData } = usePropertyData(props);\r\n const { dataProvider } = { ...props };\r\n\r\n // Model source needs to be recreated if data provider changes\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n const modelSource = useMemo(() => new PropertyGridModelSource(new MutableGridItemFactory()), [dataProvider]);\r\n\r\n useEffect(() => {\r\n if (propertyData)\r\n modelSource.setPropertyData(propertyData);\r\n }, [modelSource, propertyData]);\r\n\r\n return modelSource;\r\n}\r\n\r\n/**\r\n * Custom hook that creates memoized version of [[PropertyGridEventHandler]] that modifies given modelSource\r\n * @public\r\n */\r\nexport function usePropertyGridEventHandler(props: { modelSource: IPropertyGridModelSource }) {\r\n return useMemo(() => new PropertyGridEventHandler(props.modelSource), [props.modelSource]);\r\n}\r\n\r\n/**\r\n * Custom hook that automatically listens and retrieves latest model from model source\r\n * @public\r\n */\r\nexport function usePropertyGridModel(props: { modelSource: IPropertyGridModelSource }) {\r\n const { modelSource } = { ...props };\r\n const [model, setModel] = useState<IPropertyGridModel>();\r\n\r\n useEffect(() => {\r\n const modelChanged = () => {\r\n setModel(modelSource.getModel());\r\n };\r\n modelChanged();\r\n return modelSource.onModelChanged.addListener(modelChanged);\r\n }, [modelSource]);\r\n\r\n return model;\r\n}\r\n"]}
1
+ {"version":3,"file":"PropertyGridHooks.js","sourceRoot":"","sources":["../../../../../src/components-react/propertygrid/internal/PropertyGridHooks.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iCAA8E;AAC9E,gFAA6E;AAE7E,gFAA6E;AAC7E,yEAAsE;AAEtE,uEAA8F;AAE9F;;;;GAIG;AACH,SAAgB,eAAe,CAAC,KAA8C;IAC5E,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAE/B,MAAM,CAAC,YAAY,EAAE,mBAAmB,CAAC,GAAG,IAAA,kBAAU,EAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAA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AoB,CAAC,KAAgD;IACnF,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;IACrC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,GAAsB,CAAC;IAEzD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnC,CAAC,CAAC;QACF,YAAY,EAAE,CAAC;QACf,OAAO,WAAW,CAAC,cAAc,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC9D,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,OAAO,KAAK,CAAC;AACf,CAAC;AAbD,oDAaC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyGrid\r\n */\r\n\r\nimport { useCallback, useEffect, useMemo, useReducer, useState } from \"react\";\r\nimport { useDebouncedAsyncValue } from \"../../common/UseDebouncedAsyncValue\";\r\nimport { IPropertyDataProvider } from \"../PropertyDataProvider\";\r\nimport { MutableGridItemFactory } from \"./flat-items/MutableGridItemFactory\";\r\nimport { PropertyGridEventHandler } from \"./PropertyGridEventHandler\";\r\nimport { IPropertyGridModel } from \"./PropertyGridModel\";\r\nimport { IPropertyGridModelSource, PropertyGridModelSource } from \"./PropertyGridModelSource\";\r\n\r\n/**\r\n * Custom hook that gets [[PropertyData]] from given [[IPropertyDataProvider]] and subscribes to further data changes.\r\n * @throws if/when `IPropertyDataProvider.getData()` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.\r\n * @public\r\n */\r\nexport function usePropertyData(props: { dataProvider: IPropertyDataProvider }) {\r\n const { dataProvider } = props;\r\n\r\n const [forcedUpdate, triggerForcedUpdate] = useReducer(() => ({}), {});\r\n useEffect(() => {\r\n return dataProvider.onDataChanged.addListener(() => {\r\n triggerForcedUpdate();\r\n });\r\n }, [dataProvider]);\r\n\r\n // forcedUpdate is added to dependency list to re-memo getData promise when onDataChanged emits an event.\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n return useDebouncedAsyncValue(useCallback(async () => dataProvider.getData(), [dataProvider, forcedUpdate]));\r\n}\r\n\r\n/**\r\n * Custom hook that creates a [[PropertyGridModelSource]] and subscribes it to data updates from the data provider.\r\n * @throws if/when `IPropertyDataProvider.getData()` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.\r\n * @public\r\n */\r\nexport function usePropertyGridModelSource(props: { dataProvider: IPropertyDataProvider }) {\r\n const { value: propertyData } = usePropertyData(props);\r\n const { dataProvider } = { ...props };\r\n\r\n // Model source needs to be recreated if data provider changes\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n const modelSource = useMemo(() => new PropertyGridModelSource(new MutableGridItemFactory()), [dataProvider]);\r\n\r\n useEffect(() => {\r\n if (propertyData)\r\n modelSource.setPropertyData(propertyData);\r\n }, [modelSource, propertyData]);\r\n\r\n return modelSource;\r\n}\r\n\r\n/**\r\n * Custom hook that creates memoized version of [[PropertyGridEventHandler]] that modifies given modelSource\r\n * @public\r\n */\r\nexport function usePropertyGridEventHandler(props: { modelSource: IPropertyGridModelSource }) {\r\n return useMemo(() => new PropertyGridEventHandler(props.modelSource), [props.modelSource]);\r\n}\r\n\r\n/**\r\n * Custom hook that automatically listens and retrieves latest model from model source\r\n * @public\r\n */\r\nexport function usePropertyGridModel(props: { modelSource: IPropertyGridModelSource }) {\r\n const { modelSource } = { ...props };\r\n const [model, setModel] = useState<IPropertyGridModel>();\r\n\r\n useEffect(() => {\r\n const modelChanged = () => {\r\n setModel(modelSource.getModel());\r\n };\r\n modelChanged();\r\n return modelSource.onModelChanged.addListener(modelChanged);\r\n }, [modelSource]);\r\n\r\n return model;\r\n}\r\n"]}
@@ -7,6 +7,7 @@
7
7
  * The first promise will always be executed.
8
8
  * Any promises following the first while it is executing will be scheduled (and unscheduled), leaving only the last promise to be resolved.
9
9
  * Once the first promise finishes resolving, the last passed promise starts resolving.
10
+ * @throws if/when `valueToBeResolved` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.
10
11
  * @beta
11
12
  */
12
13
  export declare function useDebouncedAsyncValue<TReturn>(valueToBeResolved: undefined | (() => Promise<TReturn>)): {
@@ -1 +1 @@
1
- {"version":3,"file":"UseDebouncedAsyncValue.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":"AAIA;;GAEG;AAQH;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,EAAE,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;;;EAgCtG"}
1
+ {"version":3,"file":"UseDebouncedAsyncValue.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":"AAIA;;GAEG;AAQH;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,EAAE,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;;;EA8CtG"}
@@ -6,9 +6,9 @@
6
6
  * @module Common
7
7
  */
8
8
  import { useEffect, useMemo, useState } from "react";
9
+ import { defer } from "rxjs/internal/observable/defer";
9
10
  import { publish } from "rxjs/internal/operators/publish";
10
11
  import { refCount } from "rxjs/internal/operators/refCount";
11
- import { defer } from "rxjs/internal/observable/defer";
12
12
  import { scheduleSubscription, SubscriptionScheduler } from "./SubscriptionScheduler";
13
13
  /**
14
14
  * Custom hook for working with promise values.
@@ -16,12 +16,17 @@ import { scheduleSubscription, SubscriptionScheduler } from "./SubscriptionSched
16
16
  * The first promise will always be executed.
17
17
  * Any promises following the first while it is executing will be scheduled (and unscheduled), leaving only the last promise to be resolved.
18
18
  * Once the first promise finishes resolving, the last passed promise starts resolving.
19
+ * @throws if/when `valueToBeResolved` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.
19
20
  * @beta
20
21
  */
21
22
  export function useDebouncedAsyncValue(valueToBeResolved) {
22
23
  const scheduler = useMemo(() => new SubscriptionScheduler(), []); // eslint-disable-line react-hooks/exhaustive-deps
23
24
  const [value, setValue] = useState();
24
25
  const [inProgress, setInProgress] = useState(false);
26
+ const [errorState, setErrorState] = useState({
27
+ error: undefined,
28
+ hasError: false,
29
+ });
25
30
  useEffect(() => {
26
31
  if (!valueToBeResolved) {
27
32
  setValue(undefined);
@@ -37,9 +42,15 @@ export function useDebouncedAsyncValue(valueToBeResolved) {
37
42
  setValue(data);
38
43
  setInProgress(false);
39
44
  },
45
+ error: (err) => {
46
+ setErrorState({ error: err, hasError: true });
47
+ setInProgress(false);
48
+ },
40
49
  });
41
50
  return () => { subscription.unsubscribe(); };
42
51
  }, [valueToBeResolved, scheduler]);
52
+ if (errorState.hasError)
53
+ throw errorState.error ?? new Error("Exception in `useDebouncedAsyncValue`");
43
54
  return { value, inProgress };
44
55
  }
45
56
  //# sourceMappingURL=UseDebouncedAsyncValue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UseDebouncedAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEtF;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAU,iBAAuD;IACrG,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,qBAAqB,EAAW,EAAE,EAAE,CAAC,CAAC,CAAC,kDAAkD;IAE7H,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAW,CAAC;IAC9C,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEpD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,iBAAiB,EAAE;YACtB,QAAQ,CAAC,SAAS,CAAC,CAAC;YACpB,aAAa,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO;SACR;QAED,aAAa,CAAC,IAAI,CAAC,CAAC;QACpB,yFAAyF;QACzF,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC;aAC1C,IAAI,CACH,OAAO,EAAE,EACT,QAAQ,EAAE,EACV,oBAAoB,CAAC,SAAS,CAAC,CAChC;aACA,SAAS,CAAC;YACT,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;gBACb,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACf,aAAa,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;SACF,CAAC,CAAC;QAEL,OAAO,GAAG,EAAE,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,CAAC;IAEnC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport { useEffect, useMemo, useState } from \"react\";\r\nimport { publish } from \"rxjs/internal/operators/publish\";\r\nimport { refCount } from \"rxjs/internal/operators/refCount\";\r\nimport { defer } from \"rxjs/internal/observable/defer\";\r\nimport { scheduleSubscription, SubscriptionScheduler } from \"./SubscriptionScheduler\";\r\n\r\n/**\r\n * Custom hook for working with promise values.\r\n * Promises are debounced using trailing and leading edge.\r\n * The first promise will always be executed.\r\n * Any promises following the first while it is executing will be scheduled (and unscheduled), leaving only the last promise to be resolved.\r\n * Once the first promise finishes resolving, the last passed promise starts resolving.\r\n * @beta\r\n */\r\nexport function useDebouncedAsyncValue<TReturn>(valueToBeResolved: undefined | (() => Promise<TReturn>)) {\r\n const scheduler = useMemo(() => new SubscriptionScheduler<TReturn>(), []); // eslint-disable-line react-hooks/exhaustive-deps\r\n\r\n const [value, setValue] = useState<TReturn>();\r\n const [inProgress, setInProgress] = useState(false);\r\n\r\n useEffect(() => {\r\n if (!valueToBeResolved) {\r\n setValue(undefined);\r\n setInProgress(false);\r\n return;\r\n }\r\n\r\n setInProgress(true);\r\n // schedule and subscribe to the observable emitting value from valueToBeResolved promise\r\n const subscription = defer(valueToBeResolved)\r\n .pipe(\r\n publish(),\r\n refCount(),\r\n scheduleSubscription(scheduler),\r\n )\r\n .subscribe({\r\n next: (data) => {\r\n setValue(data);\r\n setInProgress(false);\r\n },\r\n });\r\n\r\n return () => { subscription.unsubscribe(); };\r\n }, [valueToBeResolved, scheduler]);\r\n\r\n return { value, inProgress };\r\n}\r\n"]}
1
+ {"version":3,"file":"UseDebouncedAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE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AG,EAAE,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,CAAC;IAEnC,IAAI,UAAU,CAAC,QAAQ;QACrB,MAAM,UAAU,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAE/E,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport { useEffect, useMemo, useState } from \"react\";\r\nimport { defer } from \"rxjs/internal/observable/defer\";\r\nimport { publish } from \"rxjs/internal/operators/publish\";\r\nimport { refCount } from \"rxjs/internal/operators/refCount\";\r\nimport { scheduleSubscription, SubscriptionScheduler } from \"./SubscriptionScheduler\";\r\n\r\n/**\r\n * Custom hook for working with promise values.\r\n * Promises are debounced using trailing and leading edge.\r\n * The first promise will always be executed.\r\n * Any promises following the first while it is executing will be scheduled (and unscheduled), leaving only the last promise to be resolved.\r\n * Once the first promise finishes resolving, the last passed promise starts resolving.\r\n * @throws if/when `valueToBeResolved` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.\r\n * @beta\r\n */\r\nexport function useDebouncedAsyncValue<TReturn>(valueToBeResolved: undefined | (() => Promise<TReturn>)) {\r\n const scheduler = useMemo(() => new SubscriptionScheduler<TReturn>(), []); // eslint-disable-line react-hooks/exhaustive-deps\r\n\r\n const [value, setValue] = useState<TReturn>();\r\n const [inProgress, setInProgress] = useState(false);\r\n const [errorState, setErrorState] = useState<{\r\n error: Error | undefined;\r\n hasError: boolean;\r\n }>({\r\n error: undefined,\r\n hasError: false,\r\n });\r\n\r\n useEffect(() => {\r\n if (!valueToBeResolved) {\r\n setValue(undefined);\r\n setInProgress(false);\r\n return;\r\n }\r\n\r\n setInProgress(true);\r\n // schedule and subscribe to the observable emitting value from valueToBeResolved promise\r\n const subscription = defer(valueToBeResolved)\r\n .pipe(\r\n publish(),\r\n refCount(),\r\n scheduleSubscription(scheduler),\r\n )\r\n .subscribe({\r\n next: (data) => {\r\n setValue(data);\r\n setInProgress(false);\r\n },\r\n error: (err) => {\r\n setErrorState({ error: err, hasError: true });\r\n setInProgress(false);\r\n },\r\n });\r\n\r\n return () => { subscription.unsubscribe(); };\r\n }, [valueToBeResolved, scheduler]);\r\n\r\n if (errorState.hasError)\r\n throw errorState.error ?? new Error(\"Exception in `useDebouncedAsyncValue`\");\r\n\r\n return { value, inProgress };\r\n}\r\n"]}
@@ -7,6 +7,7 @@ import { IPropertyGridModel } from "./PropertyGridModel";
7
7
  import { IPropertyGridModelSource, PropertyGridModelSource } from "./PropertyGridModelSource";
8
8
  /**
9
9
  * Custom hook that gets [[PropertyData]] from given [[IPropertyDataProvider]] and subscribes to further data changes.
10
+ * @throws if/when `IPropertyDataProvider.getData()` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.
10
11
  * @public
11
12
  */
12
13
  export declare function usePropertyData(props: {
@@ -17,6 +18,7 @@ export declare function usePropertyData(props: {
17
18
  };
18
19
  /**
19
20
  * Custom hook that creates a [[PropertyGridModelSource]] and subscribes it to data updates from the data provider.
21
+ * @throws if/when `IPropertyDataProvider.getData()` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.
20
22
  * @public
21
23
  */
22
24
  export declare function usePropertyGridModelSource(props: {
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyGridHooks.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/propertygrid/internal/PropertyGridHooks.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAE9F;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IAAE,YAAY,EAAE,qBAAqB,CAAA;CAAE;;;EAa7E;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAAE,YAAY,EAAE,qBAAqB,CAAA;CAAE,2BAcxF;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IAAE,WAAW,EAAE,wBAAwB,CAAA;CAAE,4BAE3F;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAAE,WAAW,EAAE,wBAAwB,CAAA;CAAE,kCAapF"}
1
+ {"version":3,"file":"PropertyGridHooks.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/propertygrid/internal/PropertyGridHooks.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAE9F;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IAAE,YAAY,EAAE,qBAAqB,CAAA;CAAE;;;EAa7E;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAAE,YAAY,EAAE,qBAAqB,CAAA;CAAE,2BAcxF;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IAAE,WAAW,EAAE,wBAAwB,CAAA;CAAE,4BAE3F;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAAE,WAAW,EAAE,wBAAwB,CAAA;CAAE,kCAapF"}
@@ -12,6 +12,7 @@ import { PropertyGridEventHandler } from "./PropertyGridEventHandler";
12
12
  import { PropertyGridModelSource } from "./PropertyGridModelSource";
13
13
  /**
14
14
  * Custom hook that gets [[PropertyData]] from given [[IPropertyDataProvider]] and subscribes to further data changes.
15
+ * @throws if/when `IPropertyDataProvider.getData()` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.
15
16
  * @public
16
17
  */
17
18
  export function usePropertyData(props) {
@@ -28,6 +29,7 @@ export function usePropertyData(props) {
28
29
  }
29
30
  /**
30
31
  * Custom hook that creates a [[PropertyGridModelSource]] and subscribes it to data updates from the data provider.
32
+ * @throws if/when `IPropertyDataProvider.getData()` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.
31
33
  * @public
32
34
  */
33
35
  export function usePropertyGridModelSource(props) {
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyGridHooks.js","sourceRoot":"","sources":["../../../../../src/components-react/propertygrid/internal/PropertyGridHooks.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,EAA4B,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAE9F;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAA8C;IAC5E,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAE/B,MAAM,CAAC,YAAY,EAAE,mBAAmB,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,C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E,GAAG,KAAK,EAAE,CAAC;IACrC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAsB,CAAC;IAEzD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnC,CAAC,CAAC;QACF,YAAY,EAAE,CAAC;QACf,OAAO,WAAW,CAAC,cAAc,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC9D,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyGrid\r\n */\r\n\r\nimport { useCallback, useEffect, useMemo, useReducer, useState } from \"react\";\r\nimport { useDebouncedAsyncValue } from \"../../common/UseDebouncedAsyncValue\";\r\nimport { IPropertyDataProvider } from \"../PropertyDataProvider\";\r\nimport { MutableGridItemFactory } from \"./flat-items/MutableGridItemFactory\";\r\nimport { PropertyGridEventHandler } from \"./PropertyGridEventHandler\";\r\nimport { IPropertyGridModel } from \"./PropertyGridModel\";\r\nimport { IPropertyGridModelSource, PropertyGridModelSource } from \"./PropertyGridModelSource\";\r\n\r\n/**\r\n * Custom hook that gets [[PropertyData]] from given [[IPropertyDataProvider]] and subscribes to further data changes.\r\n * @public\r\n */\r\nexport function usePropertyData(props: { dataProvider: IPropertyDataProvider }) {\r\n const { dataProvider } = props;\r\n\r\n const [forcedUpdate, triggerForcedUpdate] = useReducer(() => ({}), {});\r\n useEffect(() => {\r\n return dataProvider.onDataChanged.addListener(() => {\r\n triggerForcedUpdate();\r\n });\r\n }, [dataProvider]);\r\n\r\n // forcedUpdate is added to dependency list to re-memo getData promise when onDataChanged emits an event.\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n return useDebouncedAsyncValue(useCallback(async () => dataProvider.getData(), [dataProvider, forcedUpdate]));\r\n}\r\n\r\n/**\r\n * Custom hook that creates a [[PropertyGridModelSource]] and subscribes it to data updates from the data provider.\r\n * @public\r\n */\r\nexport function usePropertyGridModelSource(props: { dataProvider: IPropertyDataProvider }) {\r\n const { value: propertyData } = usePropertyData(props);\r\n const { dataProvider } = { ...props };\r\n\r\n // Model source needs to be recreated if data provider changes\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n const modelSource = useMemo(() => new PropertyGridModelSource(new MutableGridItemFactory()), [dataProvider]);\r\n\r\n useEffect(() => {\r\n if (propertyData)\r\n modelSource.setPropertyData(propertyData);\r\n }, [modelSource, propertyData]);\r\n\r\n return modelSource;\r\n}\r\n\r\n/**\r\n * Custom hook that creates memoized version of [[PropertyGridEventHandler]] that modifies given modelSource\r\n * @public\r\n */\r\nexport function usePropertyGridEventHandler(props: { modelSource: IPropertyGridModelSource }) {\r\n return useMemo(() => new PropertyGridEventHandler(props.modelSource), [props.modelSource]);\r\n}\r\n\r\n/**\r\n * Custom hook that automatically listens and retrieves latest model from model source\r\n * @public\r\n */\r\nexport function usePropertyGridModel(props: { modelSource: IPropertyGridModelSource }) {\r\n const { modelSource } = { ...props };\r\n const [model, setModel] = useState<IPropertyGridModel>();\r\n\r\n useEffect(() => {\r\n const modelChanged = () => {\r\n setModel(modelSource.getModel());\r\n };\r\n modelChanged();\r\n return modelSource.onModelChanged.addListener(modelChanged);\r\n }, [modelSource]);\r\n\r\n return model;\r\n}\r\n"]}
1
+ {"version":3,"file":"PropertyGridHooks.js","sourceRoot":"","sources":["../../../../../src/components-react/propertygrid/internal/PropertyGridHooks.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAA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AAY;YACd,WAAW,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;IAEhC,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAAgD;IAC1F,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,wBAAwB,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAgD;IACnF,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;IACrC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAsB,CAAC;IAEzD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnC,CAAC,CAAC;QACF,YAAY,EAAE,CAAC;QACf,OAAO,WAAW,CAAC,cAAc,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC9D,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyGrid\r\n */\r\n\r\nimport { useCallback, useEffect, useMemo, useReducer, useState } from \"react\";\r\nimport { useDebouncedAsyncValue } from \"../../common/UseDebouncedAsyncValue\";\r\nimport { IPropertyDataProvider } from \"../PropertyDataProvider\";\r\nimport { MutableGridItemFactory } from \"./flat-items/MutableGridItemFactory\";\r\nimport { PropertyGridEventHandler } from \"./PropertyGridEventHandler\";\r\nimport { IPropertyGridModel } from \"./PropertyGridModel\";\r\nimport { IPropertyGridModelSource, PropertyGridModelSource } from \"./PropertyGridModelSource\";\r\n\r\n/**\r\n * Custom hook that gets [[PropertyData]] from given [[IPropertyDataProvider]] and subscribes to further data changes.\r\n * @throws if/when `IPropertyDataProvider.getData()` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.\r\n * @public\r\n */\r\nexport function usePropertyData(props: { dataProvider: IPropertyDataProvider }) {\r\n const { dataProvider } = props;\r\n\r\n const [forcedUpdate, triggerForcedUpdate] = useReducer(() => ({}), {});\r\n useEffect(() => {\r\n return dataProvider.onDataChanged.addListener(() => {\r\n triggerForcedUpdate();\r\n });\r\n }, [dataProvider]);\r\n\r\n // forcedUpdate is added to dependency list to re-memo getData promise when onDataChanged emits an event.\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n return useDebouncedAsyncValue(useCallback(async () => dataProvider.getData(), [dataProvider, forcedUpdate]));\r\n}\r\n\r\n/**\r\n * Custom hook that creates a [[PropertyGridModelSource]] and subscribes it to data updates from the data provider.\r\n * @throws if/when `IPropertyDataProvider.getData()` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.\r\n * @public\r\n */\r\nexport function usePropertyGridModelSource(props: { dataProvider: IPropertyDataProvider }) {\r\n const { value: propertyData } = usePropertyData(props);\r\n const { dataProvider } = { ...props };\r\n\r\n // Model source needs to be recreated if data provider changes\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n const modelSource = useMemo(() => new PropertyGridModelSource(new MutableGridItemFactory()), [dataProvider]);\r\n\r\n useEffect(() => {\r\n if (propertyData)\r\n modelSource.setPropertyData(propertyData);\r\n }, [modelSource, propertyData]);\r\n\r\n return modelSource;\r\n}\r\n\r\n/**\r\n * Custom hook that creates memoized version of [[PropertyGridEventHandler]] that modifies given modelSource\r\n * @public\r\n */\r\nexport function usePropertyGridEventHandler(props: { modelSource: IPropertyGridModelSource }) {\r\n return useMemo(() => new PropertyGridEventHandler(props.modelSource), [props.modelSource]);\r\n}\r\n\r\n/**\r\n * Custom hook that automatically listens and retrieves latest model from model source\r\n * @public\r\n */\r\nexport function usePropertyGridModel(props: { modelSource: IPropertyGridModelSource }) {\r\n const { modelSource } = { ...props };\r\n const [model, setModel] = useState<IPropertyGridModel>();\r\n\r\n useEffect(() => {\r\n const modelChanged = () => {\r\n setModel(modelSource.getModel());\r\n };\r\n modelChanged();\r\n return modelSource.onModelChanged.addListener(modelChanged);\r\n }, [modelSource]);\r\n\r\n return model;\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/components-react",
3
- "version": "4.0.0-dev.14",
3
+ "version": "4.0.0-dev.15",
4
4
  "description": "iTwin.js UI complex components",
5
5
  "main": "lib/cjs/components-react.js",
6
6
  "module": "lib/esm/components-react.js",
@@ -24,7 +24,7 @@
24
24
  "peerDependencies": {
25
25
  "@itwin/appui-abstract": ">=3.7.0",
26
26
  "@itwin/core-bentley": ">=3.7.0",
27
- "@itwin/core-react": "^4.0.0-dev.14",
27
+ "@itwin/core-react": "^4.0.0-dev.15",
28
28
  "react": "^17.0.0 || ^18.0.0",
29
29
  "react-dom": "^17.0.0 || ^18.0.0"
30
30
  },
@@ -39,7 +39,7 @@
39
39
  "@itwin/core-common": "^3.7.0",
40
40
  "@itwin/core-geometry": "^3.7.0",
41
41
  "@itwin/core-i18n": "^3.7.0",
42
- "@itwin/core-react": "4.0.0-dev.14",
42
+ "@itwin/core-react": "4.0.0-dev.15",
43
43
  "@itwin/eslint-plugin": "^3.7.0",
44
44
  "@testing-library/dom": "^8.11.2",
45
45
  "@testing-library/react": "^12.0.0",