@trackunit/react-core-hooks 1.4.44 → 1.4.46

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/index.cjs.js CHANGED
@@ -1120,6 +1120,7 @@ const WidgetConfigProvider = (props) => jsxRuntime.jsx(WidgetConfigContext.Provi
1120
1120
  */
1121
1121
  const useWidgetConfig = () => {
1122
1122
  const [data, setData] = react.useState(null);
1123
+ const [loadingData, setLoadingData] = react.useState(true);
1123
1124
  const [dataVersion, setDataVersion] = react.useState(null);
1124
1125
  const [title, setTitle] = react.useState(null);
1125
1126
  const filters = useFilterBarContext();
@@ -1127,7 +1128,10 @@ const useWidgetConfig = () => {
1127
1128
  const { hash } = reactRouter.useLocation();
1128
1129
  const edit = react.useMemo(() => hash.includes("edit=true"), [hash]);
1129
1130
  react.useEffect(() => {
1130
- irisAppRuntimeCore.WidgetConfigRuntime.getData().then(d => setData(d));
1131
+ irisAppRuntimeCore.WidgetConfigRuntime.getData().then(d => {
1132
+ setData(d);
1133
+ setLoadingData(false);
1134
+ });
1131
1135
  irisAppRuntimeCore.WidgetConfigRuntime.getDataVersion().then(dv => setDataVersion(dv));
1132
1136
  irisAppRuntimeCore.WidgetConfigRuntime.getTitle().then(t => setTitle(t));
1133
1137
  }, []);
@@ -1139,6 +1143,7 @@ const useWidgetConfig = () => {
1139
1143
  setDataVersion(newDataVersion);
1140
1144
  },
1141
1145
  dataVersion,
1146
+ loadingData,
1142
1147
  title,
1143
1148
  setTitle: async (newTitle) => {
1144
1149
  await irisAppRuntimeCore.WidgetConfigRuntime.setTitle(newTitle);
@@ -1151,9 +1156,11 @@ const useWidgetConfig = () => {
1151
1156
  await irisAppRuntimeCore.WidgetConfigRuntime.openEditMode();
1152
1157
  },
1153
1158
  closeEditMode: async () => {
1154
- await irisAppRuntimeCore.WidgetConfigRuntime.closeEditMode();
1159
+ setTimeout(async () => {
1160
+ await irisAppRuntimeCore.WidgetConfigRuntime.closeEditMode();
1161
+ }, 300);
1155
1162
  },
1156
- }), [data, dataVersion, title, filters, timeRange, edit]);
1163
+ }), [data, dataVersion, title, filters, timeRange, edit, loadingData]);
1157
1164
  return result;
1158
1165
  };
1159
1166
 
package/index.esm.js CHANGED
@@ -1118,6 +1118,7 @@ const WidgetConfigProvider = (props) => jsx(WidgetConfigContext.Provider, { ...p
1118
1118
  */
1119
1119
  const useWidgetConfig = () => {
1120
1120
  const [data, setData] = useState(null);
1121
+ const [loadingData, setLoadingData] = useState(true);
1121
1122
  const [dataVersion, setDataVersion] = useState(null);
1122
1123
  const [title, setTitle] = useState(null);
1123
1124
  const filters = useFilterBarContext();
@@ -1125,7 +1126,10 @@ const useWidgetConfig = () => {
1125
1126
  const { hash } = useLocation();
1126
1127
  const edit = useMemo(() => hash.includes("edit=true"), [hash]);
1127
1128
  useEffect(() => {
1128
- WidgetConfigRuntime.getData().then(d => setData(d));
1129
+ WidgetConfigRuntime.getData().then(d => {
1130
+ setData(d);
1131
+ setLoadingData(false);
1132
+ });
1129
1133
  WidgetConfigRuntime.getDataVersion().then(dv => setDataVersion(dv));
1130
1134
  WidgetConfigRuntime.getTitle().then(t => setTitle(t));
1131
1135
  }, []);
@@ -1137,6 +1141,7 @@ const useWidgetConfig = () => {
1137
1141
  setDataVersion(newDataVersion);
1138
1142
  },
1139
1143
  dataVersion,
1144
+ loadingData,
1140
1145
  title,
1141
1146
  setTitle: async (newTitle) => {
1142
1147
  await WidgetConfigRuntime.setTitle(newTitle);
@@ -1149,9 +1154,11 @@ const useWidgetConfig = () => {
1149
1154
  await WidgetConfigRuntime.openEditMode();
1150
1155
  },
1151
1156
  closeEditMode: async () => {
1152
- await WidgetConfigRuntime.closeEditMode();
1157
+ setTimeout(async () => {
1158
+ await WidgetConfigRuntime.closeEditMode();
1159
+ }, 300);
1153
1160
  },
1154
- }), [data, dataVersion, title, filters, timeRange, edit]);
1161
+ }), [data, dataVersion, title, filters, timeRange, edit, loadingData]);
1155
1162
  return result;
1156
1163
  };
1157
1164
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-hooks",
3
- "version": "1.4.44",
3
+ "version": "1.4.46",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -10,11 +10,11 @@
10
10
  "react": "19.0.0",
11
11
  "jest-fetch-mock": "^3.0.3",
12
12
  "zod": "3.23.4",
13
- "@trackunit/react-core-contexts-api": "1.5.44",
14
- "@trackunit/iris-app-runtime-core": "1.5.44",
15
- "@trackunit/shared-utils": "1.6.39",
13
+ "@trackunit/react-core-contexts-api": "1.5.45",
14
+ "@trackunit/iris-app-runtime-core": "1.5.45",
15
+ "@trackunit/shared-utils": "1.6.40",
16
16
  "@tanstack/react-router": "1.114.29",
17
- "@trackunit/react-test-setup": "1.1.39"
17
+ "@trackunit/react-test-setup": "1.1.40"
18
18
  },
19
19
  "module": "./index.esm.js",
20
20
  "main": "./index.cjs.js",
@@ -41,6 +41,7 @@ export declare const useWidgetConfig: () => {
41
41
  data: Record<string, unknown> | null;
42
42
  setData: (newData: Record<string, unknown>, newDataVersion: number) => Promise<void>;
43
43
  dataVersion: number | null;
44
+ loadingData: boolean;
44
45
  title: string | null;
45
46
  setTitle: (newTitle: string) => Promise<void>;
46
47
  filters: import("@trackunit/react-core-contexts-api").FilterBarContext;