@almadar/ui 2.47.0 → 2.47.1

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.
@@ -36914,31 +36914,7 @@ function useUISlotManager() {
36914
36914
  var SelectionContext = React90.createContext(null);
36915
36915
 
36916
36916
  // hooks/useUIEvents.ts
36917
- var UI_EVENT_MAP = {
36918
- // Form/CRUD events
36919
- "UI:SAVE": "SAVE",
36920
- "UI:CANCEL": "CANCEL",
36921
- "UI:CLOSE": "CLOSE",
36922
- "UI:VIEW": "VIEW",
36923
- "UI:EDIT": "EDIT",
36924
- "UI:DELETE": "DELETE",
36925
- "UI:CREATE": "CREATE",
36926
- "UI:SELECT": "SELECT",
36927
- "UI:DESELECT": "DESELECT",
36928
- "UI:SUBMIT": "SAVE",
36929
- "UI:UPDATE_STATUS": "UPDATE_STATUS",
36930
- "UI:SEARCH": "SEARCH",
36931
- "UI:CLEAR_SEARCH": "CLEAR_SEARCH",
36932
- "UI:ADD": "CREATE",
36933
- // Game events (for closed circuit with GameMenu, GamePauseOverlay, GameOverScreen)
36934
- "UI:PAUSE": "PAUSE",
36935
- "UI:RESUME": "RESUME",
36936
- "UI:RESTART": "RESTART",
36937
- "UI:GAME_OVER": "GAME_OVER",
36938
- "UI:START": "START",
36939
- "UI:QUIT": "QUIT",
36940
- "UI:INIT": "INIT"
36941
- };
36917
+ var UI_PREFIX = "UI:";
36942
36918
  function useUIEvents(dispatch, validEvents, eventBusInstance) {
36943
36919
  const defaultEventBus = useEventBus();
36944
36920
  const eventBus = eventBusInstance ?? defaultEventBus;
@@ -36950,15 +36926,18 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
36950
36926
  );
36951
36927
  React90.useEffect(() => {
36952
36928
  const unsubscribes = [];
36953
- Object.entries(UI_EVENT_MAP).forEach(([uiEvent, smEvent]) => {
36954
- const handler = (event) => {
36955
- if (!stableValidEvents || stableValidEvents.includes(smEvent)) {
36929
+ if (stableValidEvents) {
36930
+ for (const smEvent of stableValidEvents) {
36931
+ const prefixedHandler = (event) => {
36956
36932
  dispatch(smEvent, event.payload);
36957
- }
36958
- };
36959
- const unsubscribe = eventBus.on(uiEvent, handler);
36960
- unsubscribes.push(unsubscribe);
36961
- });
36933
+ };
36934
+ unsubscribes.push(eventBus.on(`${UI_PREFIX}${smEvent}`, prefixedHandler));
36935
+ const directHandler = (event) => {
36936
+ dispatch(smEvent, event.payload);
36937
+ };
36938
+ unsubscribes.push(eventBus.on(smEvent, directHandler));
36939
+ }
36940
+ }
36962
36941
  const genericHandler = (event) => {
36963
36942
  const eventName = event.payload?.event;
36964
36943
  if (eventName) {
@@ -36968,30 +36947,11 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
36968
36947
  }
36969
36948
  }
36970
36949
  };
36971
- const genericUnsubscribe = eventBus.on("UI:DISPATCH", genericHandler);
36972
- unsubscribes.push(genericUnsubscribe);
36973
- if (stableValidEvents) {
36974
- stableValidEvents.forEach((smEvent) => {
36975
- const uiPrefixedEvent = `UI:${smEvent}`;
36976
- const alreadyMapped = Object.keys(UI_EVENT_MAP).includes(uiPrefixedEvent);
36977
- if (!alreadyMapped) {
36978
- const directHandler = (event) => {
36979
- dispatch(smEvent, event.payload);
36980
- };
36981
- const unsubscribePrefixed = eventBus.on(
36982
- uiPrefixedEvent,
36983
- directHandler
36984
- );
36985
- unsubscribes.push(unsubscribePrefixed);
36986
- const unsubscribeDirect = eventBus.on(smEvent, directHandler);
36987
- unsubscribes.push(unsubscribeDirect);
36988
- }
36989
- });
36990
- }
36950
+ unsubscribes.push(eventBus.on(`${UI_PREFIX}DISPATCH`, genericHandler));
36991
36951
  return () => {
36992
- unsubscribes.forEach((unsub) => {
36952
+ for (const unsub of unsubscribes) {
36993
36953
  if (typeof unsub === "function") unsub();
36994
- });
36954
+ }
36995
36955
  };
36996
36956
  }, [eventBus, dispatch, stableValidEvents]);
36997
36957
  }
@@ -36867,31 +36867,7 @@ function useUISlotManager() {
36867
36867
  var SelectionContext = createContext(null);
36868
36868
 
36869
36869
  // hooks/useUIEvents.ts
36870
- var UI_EVENT_MAP = {
36871
- // Form/CRUD events
36872
- "UI:SAVE": "SAVE",
36873
- "UI:CANCEL": "CANCEL",
36874
- "UI:CLOSE": "CLOSE",
36875
- "UI:VIEW": "VIEW",
36876
- "UI:EDIT": "EDIT",
36877
- "UI:DELETE": "DELETE",
36878
- "UI:CREATE": "CREATE",
36879
- "UI:SELECT": "SELECT",
36880
- "UI:DESELECT": "DESELECT",
36881
- "UI:SUBMIT": "SAVE",
36882
- "UI:UPDATE_STATUS": "UPDATE_STATUS",
36883
- "UI:SEARCH": "SEARCH",
36884
- "UI:CLEAR_SEARCH": "CLEAR_SEARCH",
36885
- "UI:ADD": "CREATE",
36886
- // Game events (for closed circuit with GameMenu, GamePauseOverlay, GameOverScreen)
36887
- "UI:PAUSE": "PAUSE",
36888
- "UI:RESUME": "RESUME",
36889
- "UI:RESTART": "RESTART",
36890
- "UI:GAME_OVER": "GAME_OVER",
36891
- "UI:START": "START",
36892
- "UI:QUIT": "QUIT",
36893
- "UI:INIT": "INIT"
36894
- };
36870
+ var UI_PREFIX = "UI:";
36895
36871
  function useUIEvents(dispatch, validEvents, eventBusInstance) {
36896
36872
  const defaultEventBus = useEventBus();
36897
36873
  const eventBus = eventBusInstance ?? defaultEventBus;
@@ -36903,15 +36879,18 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
36903
36879
  );
36904
36880
  useEffect(() => {
36905
36881
  const unsubscribes = [];
36906
- Object.entries(UI_EVENT_MAP).forEach(([uiEvent, smEvent]) => {
36907
- const handler = (event) => {
36908
- if (!stableValidEvents || stableValidEvents.includes(smEvent)) {
36882
+ if (stableValidEvents) {
36883
+ for (const smEvent of stableValidEvents) {
36884
+ const prefixedHandler = (event) => {
36909
36885
  dispatch(smEvent, event.payload);
36910
- }
36911
- };
36912
- const unsubscribe = eventBus.on(uiEvent, handler);
36913
- unsubscribes.push(unsubscribe);
36914
- });
36886
+ };
36887
+ unsubscribes.push(eventBus.on(`${UI_PREFIX}${smEvent}`, prefixedHandler));
36888
+ const directHandler = (event) => {
36889
+ dispatch(smEvent, event.payload);
36890
+ };
36891
+ unsubscribes.push(eventBus.on(smEvent, directHandler));
36892
+ }
36893
+ }
36915
36894
  const genericHandler = (event) => {
36916
36895
  const eventName = event.payload?.event;
36917
36896
  if (eventName) {
@@ -36921,30 +36900,11 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
36921
36900
  }
36922
36901
  }
36923
36902
  };
36924
- const genericUnsubscribe = eventBus.on("UI:DISPATCH", genericHandler);
36925
- unsubscribes.push(genericUnsubscribe);
36926
- if (stableValidEvents) {
36927
- stableValidEvents.forEach((smEvent) => {
36928
- const uiPrefixedEvent = `UI:${smEvent}`;
36929
- const alreadyMapped = Object.keys(UI_EVENT_MAP).includes(uiPrefixedEvent);
36930
- if (!alreadyMapped) {
36931
- const directHandler = (event) => {
36932
- dispatch(smEvent, event.payload);
36933
- };
36934
- const unsubscribePrefixed = eventBus.on(
36935
- uiPrefixedEvent,
36936
- directHandler
36937
- );
36938
- unsubscribes.push(unsubscribePrefixed);
36939
- const unsubscribeDirect = eventBus.on(smEvent, directHandler);
36940
- unsubscribes.push(unsubscribeDirect);
36941
- }
36942
- });
36943
- }
36903
+ unsubscribes.push(eventBus.on(`${UI_PREFIX}DISPATCH`, genericHandler));
36944
36904
  return () => {
36945
- unsubscribes.forEach((unsub) => {
36905
+ for (const unsub of unsubscribes) {
36946
36906
  if (typeof unsub === "function") unsub();
36947
- });
36907
+ }
36948
36908
  };
36949
36909
  }, [eventBus, dispatch, stableValidEvents]);
36950
36910
  }
@@ -1177,31 +1177,7 @@ function useUISlotManager() {
1177
1177
  var SelectionContext = React2.createContext(null);
1178
1178
 
1179
1179
  // hooks/useUIEvents.ts
1180
- var UI_EVENT_MAP = {
1181
- // Form/CRUD events
1182
- "UI:SAVE": "SAVE",
1183
- "UI:CANCEL": "CANCEL",
1184
- "UI:CLOSE": "CLOSE",
1185
- "UI:VIEW": "VIEW",
1186
- "UI:EDIT": "EDIT",
1187
- "UI:DELETE": "DELETE",
1188
- "UI:CREATE": "CREATE",
1189
- "UI:SELECT": "SELECT",
1190
- "UI:DESELECT": "DESELECT",
1191
- "UI:SUBMIT": "SAVE",
1192
- "UI:UPDATE_STATUS": "UPDATE_STATUS",
1193
- "UI:SEARCH": "SEARCH",
1194
- "UI:CLEAR_SEARCH": "CLEAR_SEARCH",
1195
- "UI:ADD": "CREATE",
1196
- // Game events (for closed circuit with GameMenu, GamePauseOverlay, GameOverScreen)
1197
- "UI:PAUSE": "PAUSE",
1198
- "UI:RESUME": "RESUME",
1199
- "UI:RESTART": "RESTART",
1200
- "UI:GAME_OVER": "GAME_OVER",
1201
- "UI:START": "START",
1202
- "UI:QUIT": "QUIT",
1203
- "UI:INIT": "INIT"
1204
- };
1180
+ var UI_PREFIX = "UI:";
1205
1181
  function useUIEvents(dispatch, validEvents, eventBusInstance) {
1206
1182
  const defaultEventBus = useEventBus();
1207
1183
  const eventBus = eventBusInstance ?? defaultEventBus;
@@ -1213,15 +1189,18 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
1213
1189
  );
1214
1190
  React2.useEffect(() => {
1215
1191
  const unsubscribes = [];
1216
- Object.entries(UI_EVENT_MAP).forEach(([uiEvent, smEvent]) => {
1217
- const handler = (event) => {
1218
- if (!stableValidEvents || stableValidEvents.includes(smEvent)) {
1192
+ if (stableValidEvents) {
1193
+ for (const smEvent of stableValidEvents) {
1194
+ const prefixedHandler = (event) => {
1219
1195
  dispatch(smEvent, event.payload);
1220
- }
1221
- };
1222
- const unsubscribe = eventBus.on(uiEvent, handler);
1223
- unsubscribes.push(unsubscribe);
1224
- });
1196
+ };
1197
+ unsubscribes.push(eventBus.on(`${UI_PREFIX}${smEvent}`, prefixedHandler));
1198
+ const directHandler = (event) => {
1199
+ dispatch(smEvent, event.payload);
1200
+ };
1201
+ unsubscribes.push(eventBus.on(smEvent, directHandler));
1202
+ }
1203
+ }
1225
1204
  const genericHandler = (event) => {
1226
1205
  const eventName = event.payload?.event;
1227
1206
  if (eventName) {
@@ -1231,30 +1210,11 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
1231
1210
  }
1232
1211
  }
1233
1212
  };
1234
- const genericUnsubscribe = eventBus.on("UI:DISPATCH", genericHandler);
1235
- unsubscribes.push(genericUnsubscribe);
1236
- if (stableValidEvents) {
1237
- stableValidEvents.forEach((smEvent) => {
1238
- const uiPrefixedEvent = `UI:${smEvent}`;
1239
- const alreadyMapped = Object.keys(UI_EVENT_MAP).includes(uiPrefixedEvent);
1240
- if (!alreadyMapped) {
1241
- const directHandler = (event) => {
1242
- dispatch(smEvent, event.payload);
1243
- };
1244
- const unsubscribePrefixed = eventBus.on(
1245
- uiPrefixedEvent,
1246
- directHandler
1247
- );
1248
- unsubscribes.push(unsubscribePrefixed);
1249
- const unsubscribeDirect = eventBus.on(smEvent, directHandler);
1250
- unsubscribes.push(unsubscribeDirect);
1251
- }
1252
- });
1253
- }
1213
+ unsubscribes.push(eventBus.on(`${UI_PREFIX}DISPATCH`, genericHandler));
1254
1214
  return () => {
1255
- unsubscribes.forEach((unsub) => {
1215
+ for (const unsub of unsubscribes) {
1256
1216
  if (typeof unsub === "function") unsub();
1257
- });
1217
+ }
1258
1218
  };
1259
1219
  }, [eventBus, dispatch, stableValidEvents]);
1260
1220
  }
@@ -1170,31 +1170,7 @@ function useUISlotManager() {
1170
1170
  var SelectionContext = createContext(null);
1171
1171
 
1172
1172
  // hooks/useUIEvents.ts
1173
- var UI_EVENT_MAP = {
1174
- // Form/CRUD events
1175
- "UI:SAVE": "SAVE",
1176
- "UI:CANCEL": "CANCEL",
1177
- "UI:CLOSE": "CLOSE",
1178
- "UI:VIEW": "VIEW",
1179
- "UI:EDIT": "EDIT",
1180
- "UI:DELETE": "DELETE",
1181
- "UI:CREATE": "CREATE",
1182
- "UI:SELECT": "SELECT",
1183
- "UI:DESELECT": "DESELECT",
1184
- "UI:SUBMIT": "SAVE",
1185
- "UI:UPDATE_STATUS": "UPDATE_STATUS",
1186
- "UI:SEARCH": "SEARCH",
1187
- "UI:CLEAR_SEARCH": "CLEAR_SEARCH",
1188
- "UI:ADD": "CREATE",
1189
- // Game events (for closed circuit with GameMenu, GamePauseOverlay, GameOverScreen)
1190
- "UI:PAUSE": "PAUSE",
1191
- "UI:RESUME": "RESUME",
1192
- "UI:RESTART": "RESTART",
1193
- "UI:GAME_OVER": "GAME_OVER",
1194
- "UI:START": "START",
1195
- "UI:QUIT": "QUIT",
1196
- "UI:INIT": "INIT"
1197
- };
1173
+ var UI_PREFIX = "UI:";
1198
1174
  function useUIEvents(dispatch, validEvents, eventBusInstance) {
1199
1175
  const defaultEventBus = useEventBus();
1200
1176
  const eventBus = eventBusInstance ?? defaultEventBus;
@@ -1206,15 +1182,18 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
1206
1182
  );
1207
1183
  useEffect(() => {
1208
1184
  const unsubscribes = [];
1209
- Object.entries(UI_EVENT_MAP).forEach(([uiEvent, smEvent]) => {
1210
- const handler = (event) => {
1211
- if (!stableValidEvents || stableValidEvents.includes(smEvent)) {
1185
+ if (stableValidEvents) {
1186
+ for (const smEvent of stableValidEvents) {
1187
+ const prefixedHandler = (event) => {
1212
1188
  dispatch(smEvent, event.payload);
1213
- }
1214
- };
1215
- const unsubscribe = eventBus.on(uiEvent, handler);
1216
- unsubscribes.push(unsubscribe);
1217
- });
1189
+ };
1190
+ unsubscribes.push(eventBus.on(`${UI_PREFIX}${smEvent}`, prefixedHandler));
1191
+ const directHandler = (event) => {
1192
+ dispatch(smEvent, event.payload);
1193
+ };
1194
+ unsubscribes.push(eventBus.on(smEvent, directHandler));
1195
+ }
1196
+ }
1218
1197
  const genericHandler = (event) => {
1219
1198
  const eventName = event.payload?.event;
1220
1199
  if (eventName) {
@@ -1224,30 +1203,11 @@ function useUIEvents(dispatch, validEvents, eventBusInstance) {
1224
1203
  }
1225
1204
  }
1226
1205
  };
1227
- const genericUnsubscribe = eventBus.on("UI:DISPATCH", genericHandler);
1228
- unsubscribes.push(genericUnsubscribe);
1229
- if (stableValidEvents) {
1230
- stableValidEvents.forEach((smEvent) => {
1231
- const uiPrefixedEvent = `UI:${smEvent}`;
1232
- const alreadyMapped = Object.keys(UI_EVENT_MAP).includes(uiPrefixedEvent);
1233
- if (!alreadyMapped) {
1234
- const directHandler = (event) => {
1235
- dispatch(smEvent, event.payload);
1236
- };
1237
- const unsubscribePrefixed = eventBus.on(
1238
- uiPrefixedEvent,
1239
- directHandler
1240
- );
1241
- unsubscribes.push(unsubscribePrefixed);
1242
- const unsubscribeDirect = eventBus.on(smEvent, directHandler);
1243
- unsubscribes.push(unsubscribeDirect);
1244
- }
1245
- });
1246
- }
1206
+ unsubscribes.push(eventBus.on(`${UI_PREFIX}DISPATCH`, genericHandler));
1247
1207
  return () => {
1248
- unsubscribes.forEach((unsub) => {
1208
+ for (const unsub of unsubscribes) {
1249
1209
  if (typeof unsub === "function") unsub();
1250
- });
1210
+ }
1251
1211
  };
1252
1212
  }, [eventBus, dispatch, stableValidEvents]);
1253
1213
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "2.47.0",
3
+ "version": "2.47.1",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",