@apia/dashboard-controller 2.0.11 → 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.
Files changed (162) hide show
  1. package/dist/index.d.ts +414 -23
  2. package/dist/index.js +2238 -22
  3. package/dist/index.js.map +1 -1
  4. package/package.json +8 -8
  5. package/dist/actions/basicAction.d.ts +0 -15
  6. package/dist/actions/basicAction.d.ts.map +0 -1
  7. package/dist/actions/basicAction.js +0 -40
  8. package/dist/actions/basicAction.js.map +0 -1
  9. package/dist/actions/externalFirePanelAction.d.ts +0 -6
  10. package/dist/actions/externalFirePanelAction.d.ts.map +0 -1
  11. package/dist/actions/externalFirePanelAction.js +0 -12
  12. package/dist/actions/externalFirePanelAction.js.map +0 -1
  13. package/dist/actions/firePanelAction.d.ts +0 -6
  14. package/dist/actions/firePanelAction.d.ts.map +0 -1
  15. package/dist/actions/firePanelAction.js +0 -75
  16. package/dist/actions/firePanelAction.js.map +0 -1
  17. package/dist/actions/usePanelActions.d.ts +0 -63
  18. package/dist/actions/usePanelActions.d.ts.map +0 -1
  19. package/dist/actions/usePanelActions.js +0 -55
  20. package/dist/actions/usePanelActions.js.map +0 -1
  21. package/dist/actions/usePanelIsLoading.d.ts +0 -4
  22. package/dist/actions/usePanelIsLoading.d.ts.map +0 -1
  23. package/dist/actions/usePanelIsLoading.js +0 -14
  24. package/dist/actions/usePanelIsLoading.js.map +0 -1
  25. package/dist/actions/usePanelNetworkState.d.ts +0 -8
  26. package/dist/actions/usePanelNetworkState.d.ts.map +0 -1
  27. package/dist/actions/usePanelNetworkState.js +0 -21
  28. package/dist/actions/usePanelNetworkState.js.map +0 -1
  29. package/dist/common/usePanelIdentity.d.ts +0 -10
  30. package/dist/common/usePanelIdentity.d.ts.map +0 -1
  31. package/dist/common/usePanelIdentity.js +0 -12
  32. package/dist/common/usePanelIdentity.js.map +0 -1
  33. package/dist/config/parametersStore.d.ts +0 -15
  34. package/dist/config/parametersStore.d.ts.map +0 -1
  35. package/dist/config/parametersStore.js +0 -25
  36. package/dist/config/parametersStore.js.map +0 -1
  37. package/dist/config/saveParameters.d.ts +0 -11
  38. package/dist/config/saveParameters.d.ts.map +0 -1
  39. package/dist/config/saveParameters.js +0 -16
  40. package/dist/config/saveParameters.js.map +0 -1
  41. package/dist/config/usePanelConfig.js +0 -22
  42. package/dist/config/usePanelConfig.js.map +0 -1
  43. package/dist/config/usePanelParametersSelector.d.ts +0 -25
  44. package/dist/config/usePanelParametersSelector.d.ts.map +0 -1
  45. package/dist/config/usePanelParametersSelector.js +0 -17
  46. package/dist/config/usePanelParametersSelector.js.map +0 -1
  47. package/dist/dashboard/DashboardContext.d.ts +0 -6
  48. package/dist/dashboard/DashboardContext.d.ts.map +0 -1
  49. package/dist/dashboard/DashboardContext.js +0 -12
  50. package/dist/dashboard/DashboardContext.js.map +0 -1
  51. package/dist/dashboard/DashboardPanel.d.ts +0 -45
  52. package/dist/dashboard/DashboardPanel.d.ts.map +0 -1
  53. package/dist/dashboard/DashboardPanel.js +0 -236
  54. package/dist/dashboard/DashboardPanel.js.map +0 -1
  55. package/dist/dashboard/DashboardPanelContext.d.ts +0 -6
  56. package/dist/dashboard/DashboardPanelContext.d.ts.map +0 -1
  57. package/dist/dashboard/DashboardPanelContext.js +0 -12
  58. package/dist/dashboard/DashboardPanelContext.js.map +0 -1
  59. package/dist/dashboard/DashboardPanelsBootstraper.d.ts +0 -33
  60. package/dist/dashboard/DashboardPanelsBootstraper.d.ts.map +0 -1
  61. package/dist/dashboard/DashboardPanelsBootstraper.js +0 -135
  62. package/dist/dashboard/DashboardPanelsBootstraper.js.map +0 -1
  63. package/dist/dashboard/DashboardRouter.d.ts +0 -30
  64. package/dist/dashboard/DashboardRouter.d.ts.map +0 -1
  65. package/dist/dashboard/DashboardRouter.js +0 -74
  66. package/dist/dashboard/DashboardRouter.js.map +0 -1
  67. package/dist/dashboard/PanelNotFound.js +0 -14
  68. package/dist/dashboard/PanelNotFound.js.map +0 -1
  69. package/dist/dashboard/dashboard.d.ts +0 -26
  70. package/dist/dashboard/dashboard.d.ts.map +0 -1
  71. package/dist/dashboard/dashboard.js +0 -167
  72. package/dist/dashboard/dashboard.js.map +0 -1
  73. package/dist/eventsController/eventsController.d.ts +0 -11
  74. package/dist/eventsController/eventsController.d.ts.map +0 -1
  75. package/dist/eventsController/eventsController.js +0 -57
  76. package/dist/eventsController/eventsController.js.map +0 -1
  77. package/dist/eventsController/types.d.ts +0 -21
  78. package/dist/eventsController/types.d.ts.map +0 -1
  79. package/dist/eventsController/usePanelFireEvent.d.ts +0 -13
  80. package/dist/eventsController/usePanelFireEvent.d.ts.map +0 -1
  81. package/dist/eventsController/usePanelFireEvent.js +0 -21
  82. package/dist/eventsController/usePanelFireEvent.js.map +0 -1
  83. package/dist/eventsController/usePanelOnEvent.d.ts +0 -12
  84. package/dist/eventsController/usePanelOnEvent.d.ts.map +0 -1
  85. package/dist/eventsController/usePanelOnEvent.js +0 -14
  86. package/dist/eventsController/usePanelOnEvent.js.map +0 -1
  87. package/dist/panelsStore/createPanelStore.d.ts +0 -16
  88. package/dist/panelsStore/createPanelStore.d.ts.map +0 -1
  89. package/dist/panelsStore/createPanelStore.js +0 -58
  90. package/dist/panelsStore/createPanelStore.js.map +0 -1
  91. package/dist/panelsStore/panelsStore.js +0 -59
  92. package/dist/panelsStore/panelsStore.js.map +0 -1
  93. package/dist/panelsStore/usePanelSelector.js +0 -32
  94. package/dist/panelsStore/usePanelSelector.js.map +0 -1
  95. package/dist/panelsUtil/usePanelChangeTitle.d.ts +0 -5
  96. package/dist/panelsUtil/usePanelChangeTitle.d.ts.map +0 -1
  97. package/dist/panelsUtil/usePanelChangeTitle.js +0 -23
  98. package/dist/panelsUtil/usePanelChangeTitle.js.map +0 -1
  99. package/dist/panelsUtil/usePanelTitleAction.js +0 -34
  100. package/dist/panelsUtil/usePanelTitleAction.js.map +0 -1
  101. package/dist/position/usePanelPosition.d.ts +0 -13
  102. package/dist/position/usePanelPosition.d.ts.map +0 -1
  103. package/dist/position/usePanelPosition.js +0 -40
  104. package/dist/position/usePanelPosition.js.map +0 -1
  105. package/dist/splash/events/Dragleave.js +0 -15
  106. package/dist/splash/events/Dragleave.js.map +0 -1
  107. package/dist/splash/events/Dragover.js +0 -120
  108. package/dist/splash/events/Dragover.js.map +0 -1
  109. package/dist/splash/events/Dragstart.js +0 -65
  110. package/dist/splash/events/Dragstart.js.map +0 -1
  111. package/dist/splash/events/Drop.js +0 -60
  112. package/dist/splash/events/Drop.js.map +0 -1
  113. package/dist/splash/panels/DefaultPanelWrapper/NetworkState.js +0 -28
  114. package/dist/splash/panels/DefaultPanelWrapper/NetworkState.js.map +0 -1
  115. package/dist/splash/panels/DefaultPanelWrapper/PanelButtons.js +0 -16
  116. package/dist/splash/panels/DefaultPanelWrapper/PanelButtons.js.map +0 -1
  117. package/dist/splash/panels/DefaultPanelWrapper/RefreshButton.js +0 -35
  118. package/dist/splash/panels/DefaultPanelWrapper/RefreshButton.js.map +0 -1
  119. package/dist/splash/panels/DefaultPanelWrapper/SettingsButton.js +0 -45
  120. package/dist/splash/panels/DefaultPanelWrapper/SettingsButton.js.map +0 -1
  121. package/dist/splash/panels/DefaultPanelWrapper/defaultPanelWrapperStyles.js +0 -103
  122. package/dist/splash/panels/DefaultPanelWrapper/defaultPanelWrapperStyles.js.map +0 -1
  123. package/dist/splash/panels/DefaultPanelWrapper/index.js +0 -57
  124. package/dist/splash/panels/DefaultPanelWrapper/index.js.map +0 -1
  125. package/dist/splash/panels/LandingPagePanelWrapper.d.ts +0 -6
  126. package/dist/splash/panels/LandingPagePanelWrapper.d.ts.map +0 -1
  127. package/dist/splash/panels/LandingPagePanelWrapper.js +0 -52
  128. package/dist/splash/panels/LandingPagePanelWrapper.js.map +0 -1
  129. package/dist/splash/panels/PanelContext/PanelFooter.js +0 -71
  130. package/dist/splash/panels/PanelContext/PanelFooter.js.map +0 -1
  131. package/dist/splash/panels/PanelContext/index.d.ts +0 -31
  132. package/dist/splash/panels/PanelContext/index.d.ts.map +0 -1
  133. package/dist/splash/panels/PanelContext/index.js +0 -69
  134. package/dist/splash/panels/PanelContext/index.js.map +0 -1
  135. package/dist/splash/panels/PanelContext/usePanelContextLayout.d.ts +0 -6
  136. package/dist/splash/panels/PanelContext/usePanelContextLayout.d.ts.map +0 -1
  137. package/dist/splash/panels/PanelContext/usePanelContextLayout.js +0 -38
  138. package/dist/splash/panels/PanelContext/usePanelContextLayout.js.map +0 -1
  139. package/dist/splash/panels/PanelContext/usePanelFooter.js +0 -38
  140. package/dist/splash/panels/PanelContext/usePanelFooter.js.map +0 -1
  141. package/dist/splash/panels/PanelContext/useYieldPanelIsReady.d.ts +0 -45
  142. package/dist/splash/panels/PanelContext/useYieldPanelIsReady.d.ts.map +0 -1
  143. package/dist/splash/panels/PanelContext/useYieldPanelIsReady.js +0 -12
  144. package/dist/splash/panels/PanelContext/useYieldPanelIsReady.js.map +0 -1
  145. package/dist/splash/panels/PanelErrorBoundary.js +0 -53
  146. package/dist/splash/panels/PanelErrorBoundary.js.map +0 -1
  147. package/dist/splash/panels/PanelIdentifier.d.ts +0 -16
  148. package/dist/splash/panels/PanelIdentifier.d.ts.map +0 -1
  149. package/dist/splash/panels/PanelIdentifier.js +0 -19
  150. package/dist/splash/panels/PanelIdentifier.js.map +0 -1
  151. package/dist/splash/util/DragAndDrop.js +0 -243
  152. package/dist/splash/util/DragAndDrop.js.map +0 -1
  153. package/dist/splash/util/getColumnAreas.js +0 -19
  154. package/dist/splash/util/getColumnAreas.js.map +0 -1
  155. package/dist/splash/util/isCursorInArea.js +0 -13
  156. package/dist/splash/util/isCursorInArea.js.map +0 -1
  157. package/dist/types.d.ts +0 -27
  158. package/dist/types.d.ts.map +0 -1
  159. package/dist/util.d.ts +0 -8
  160. package/dist/util.d.ts.map +0 -1
  161. package/dist/util.js +0 -29
  162. package/dist/util.js.map +0 -1
@@ -1,75 +0,0 @@
1
- import { ApiaApi, makeApiaUrl } from '@apia/api';
2
- import { panelActionsEmitter } from './usePanelActions.js';
3
- import { panelNetworkStateEmitter } from './usePanelNetworkState.js';
4
- import { ucfirst } from '@apia/util';
5
- import { changePanelFooter } from '../splash/panels/PanelContext/usePanelFooter.js';
6
- import { setPanelTitleAction, setPanelTitleDescritpion } from '../panelsUtil/usePanelTitleAction.js';
7
- import { startTransition } from 'react';
8
- import { changePanelTitle } from '../panelsUtil/usePanelChangeTitle.js';
9
-
10
- function firePanelAction(panelId, action, parameters, options) {
11
- const postData = { p_action: action, ...parameters };
12
- panelActionsEmitter.emit(panelId, `pre${ucfirst(action)}`, null);
13
- void ApiaApi.post(
14
- makeApiaUrl({
15
- action: "panelAction",
16
- pnlId: panelId
17
- }),
18
- { postData, postDataTreatement: "stringify", ...options?.requestConfig }
19
- ).then((result) => {
20
- if (result?.status !== 200) {
21
- console.log("ERROR", panelId);
22
- panelNetworkStateEmitter.emit("stateChange", {
23
- panelId,
24
- isConnected: false
25
- });
26
- } else {
27
- panelNetworkStateEmitter.emit("stateChange", {
28
- panelId,
29
- isConnected: true
30
- });
31
- }
32
- try {
33
- if (result) {
34
- startTransition(() => {
35
- if (result?.data?.title) {
36
- changePanelTitle(
37
- panelId,
38
- result?.data?.title
39
- );
40
- }
41
- if (result?.data?.footer) {
42
- changePanelFooter(
43
- panelId,
44
- result?.data?.footer
45
- );
46
- }
47
- if (result?.data?.titleAction) {
48
- setPanelTitleAction(panelId, result?.data?.titleAction);
49
- }
50
- if (result?.data?.titleDescription) {
51
- setPanelTitleDescritpion(
52
- panelId,
53
- result?.data?.titleDescription
54
- );
55
- }
56
- options?.onComplete?.(true, result);
57
- panelActionsEmitter.emit(panelId, action, result);
58
- });
59
- } else
60
- options?.onComplete?.(false, null);
61
- } catch (e) {
62
- console.error(e);
63
- }
64
- }).catch((e) => {
65
- console.error(e);
66
- panelNetworkStateEmitter.emit("stateChange", {
67
- panelId,
68
- isConnected: false
69
- });
70
- options?.onComplete?.(false, null);
71
- });
72
- }
73
-
74
- export { firePanelAction };
75
- //# sourceMappingURL=firePanelAction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"firePanelAction.js","sources":["../../src/actions/firePanelAction.ts"],"sourcesContent":["import { ApiaApi, makeApiaUrl } from '@apia/api';\r\nimport {\r\n TActionDispatcherOptions,\r\n TActionResult,\r\n TFooter,\r\n panelActionsEmitter,\r\n} from './usePanelActions';\r\nimport { panelNetworkStateEmitter } from './usePanelNetworkState';\r\nimport { changePanelTitle } from '../panelsUtil';\r\nimport { ucfirst } from '@apia/util';\r\nimport { changePanelFooter } from '../splash/panels/PanelContext/usePanelFooter';\r\nimport {\r\n setPanelTitleAction,\r\n setPanelTitleDescritpion,\r\n} from '../panelsUtil/usePanelTitleAction';\r\nimport { startTransition } from 'react';\r\n\r\nexport type TOnSucceed = (hasSucceed: boolean, data: TActionResult) => unknown;\r\n\r\n/**\r\n * **MÉTODO DE USO INTERNO**\r\n *\r\n * LLama al server para ejecutar una acción iniciada en el cliente.\r\n *\r\n * La forma de llamar acciones desde un panel es con el hook usePanelActions.\r\n */\r\nexport function firePanelAction(\r\n panelId: string,\r\n action: string,\r\n parameters?: Record<string, unknown>,\r\n options?: TActionDispatcherOptions,\r\n) {\r\n const postData = { p_action: action, ...parameters };\r\n panelActionsEmitter.emit(panelId, `pre${ucfirst(action)}`, null);\r\n void ApiaApi.post(\r\n makeApiaUrl({\r\n action: 'panelAction',\r\n pnlId: panelId,\r\n }),\r\n { postData, postDataTreatement: 'stringify', ...options?.requestConfig },\r\n )\r\n .then((result) => {\r\n if (result?.status !== 200) {\r\n console.log('ERROR', panelId);\r\n panelNetworkStateEmitter.emit('stateChange', {\r\n panelId,\r\n isConnected: false,\r\n });\r\n } else {\r\n panelNetworkStateEmitter.emit('stateChange', {\r\n panelId,\r\n isConnected: true,\r\n });\r\n }\r\n try {\r\n if (result) {\r\n startTransition(() => {\r\n if (result?.data?.title) {\r\n changePanelTitle(\r\n panelId,\r\n (result as TActionResult<{ title: string }>)?.data\r\n ?.title as string,\r\n );\r\n }\r\n if (result?.data?.footer) {\r\n changePanelFooter(\r\n panelId,\r\n (result as TActionResult<{ footer: TFooter }>)?.data\r\n ?.footer as TFooter,\r\n );\r\n }\r\n if (result?.data?.titleAction) {\r\n setPanelTitleAction(panelId, result?.data?.titleAction as string);\r\n }\r\n if (result?.data?.titleDescription) {\r\n setPanelTitleDescritpion(\r\n panelId,\r\n result?.data?.titleDescription as string,\r\n );\r\n }\r\n options?.onComplete?.(true, result);\r\n panelActionsEmitter.emit(panelId, action, result);\r\n });\r\n } else options?.onComplete?.(false, null);\r\n } catch (e) {\r\n console.error(e);\r\n }\r\n })\r\n .catch((e) => {\r\n console.error(e);\r\n panelNetworkStateEmitter.emit('stateChange', {\r\n panelId,\r\n isConnected: false,\r\n });\r\n options?.onComplete?.(false, null);\r\n });\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;AA0BO,SAAS,eACd,CAAA,OAAA,EACA,MACA,EAAA,UAAA,EACA,OACA,EAAA;AACA,EAAA,MAAM,QAAW,GAAA,EAAE,QAAU,EAAA,MAAA,EAAQ,GAAG,UAAW,EAAA,CAAA;AACnD,EAAA,mBAAA,CAAoB,KAAK,OAAS,EAAA,CAAA,GAAA,EAAM,QAAQ,MAAM,CAAC,IAAI,IAAI,CAAA,CAAA;AAC/D,EAAA,KAAK,OAAQ,CAAA,IAAA;AAAA,IACX,WAAY,CAAA;AAAA,MACV,MAAQ,EAAA,aAAA;AAAA,MACR,KAAO,EAAA,OAAA;AAAA,KACR,CAAA;AAAA,IACD,EAAE,QAAU,EAAA,kBAAA,EAAoB,WAAa,EAAA,GAAG,SAAS,aAAc,EAAA;AAAA,GACzE,CACG,IAAK,CAAA,CAAC,MAAW,KAAA;AAChB,IAAI,IAAA,MAAA,EAAQ,WAAW,GAAK,EAAA;AAC1B,MAAQ,OAAA,CAAA,GAAA,CAAI,SAAS,OAAO,CAAA,CAAA;AAC5B,MAAA,wBAAA,CAAyB,KAAK,aAAe,EAAA;AAAA,QAC3C,OAAA;AAAA,QACA,WAAa,EAAA,KAAA;AAAA,OACd,CAAA,CAAA;AAAA,KACI,MAAA;AACL,MAAA,wBAAA,CAAyB,KAAK,aAAe,EAAA;AAAA,QAC3C,OAAA;AAAA,QACA,WAAa,EAAA,IAAA;AAAA,OACd,CAAA,CAAA;AAAA,KACH;AACA,IAAI,IAAA;AACF,MAAA,IAAI,MAAQ,EAAA;AACV,QAAA,eAAA,CAAgB,MAAM;AACpB,UAAI,IAAA,MAAA,EAAQ,MAAM,KAAO,EAAA;AACvB,YAAA,gBAAA;AAAA,cACE,OAAA;AAAA,cACC,QAA6C,IAC1C,EAAA,KAAA;AAAA,aACN,CAAA;AAAA,WACF;AACA,UAAI,IAAA,MAAA,EAAQ,MAAM,MAAQ,EAAA;AACxB,YAAA,iBAAA;AAAA,cACE,OAAA;AAAA,cACC,QAA+C,IAC5C,EAAA,MAAA;AAAA,aACN,CAAA;AAAA,WACF;AACA,UAAI,IAAA,MAAA,EAAQ,MAAM,WAAa,EAAA;AAC7B,YAAoB,mBAAA,CAAA,OAAA,EAAS,MAAQ,EAAA,IAAA,EAAM,WAAqB,CAAA,CAAA;AAAA,WAClE;AACA,UAAI,IAAA,MAAA,EAAQ,MAAM,gBAAkB,EAAA;AAClC,YAAA,wBAAA;AAAA,cACE,OAAA;AAAA,cACA,QAAQ,IAAM,EAAA,gBAAA;AAAA,aAChB,CAAA;AAAA,WACF;AACA,UAAS,OAAA,EAAA,UAAA,GAAa,MAAM,MAAM,CAAA,CAAA;AAClC,UAAoB,mBAAA,CAAA,IAAA,CAAK,OAAS,EAAA,MAAA,EAAQ,MAAM,CAAA,CAAA;AAAA,SACjD,CAAA,CAAA;AAAA,OACH;AAAO,QAAS,OAAA,EAAA,UAAA,GAAa,OAAO,IAAI,CAAA,CAAA;AAAA,aACjC,CAAG,EAAA;AACV,MAAA,OAAA,CAAQ,MAAM,CAAC,CAAA,CAAA;AAAA,KACjB;AAAA,GACD,CAAA,CACA,KAAM,CAAA,CAAC,CAAM,KAAA;AACZ,IAAA,OAAA,CAAQ,MAAM,CAAC,CAAA,CAAA;AACf,IAAA,wBAAA,CAAyB,KAAK,aAAe,EAAA;AAAA,MAC3C,OAAA;AAAA,MACA,WAAa,EAAA,KAAA;AAAA,KACd,CAAA,CAAA;AACD,IAAS,OAAA,EAAA,UAAA,GAAa,OAAO,IAAI,CAAA,CAAA;AAAA,GAClC,CAAA,CAAA;AACL;;;;"}
@@ -1,63 +0,0 @@
1
- import { TApiaApiResult, IApiaApiRequestConfig } from '@apia/api';
2
- import { TOnSucceed } from './firePanelAction.js';
3
- import { TBasicAction } from './basicAction.js';
4
-
5
- type TFooter = TBasicAction;
6
- type TCommonActionResult = {
7
- title: string;
8
- footer: TFooter;
9
- };
10
- type TActionResult<T = any> = null | NonNullable<Awaited<TApiaApiResult<T extends Record<string, unknown> ? T & TCommonActionResult : T>>>;
11
- type TActionDispatcherOptions = {
12
- onComplete?: TOnSucceed;
13
- requestConfig?: IApiaApiRequestConfig<object>;
14
- };
15
- type TExternalActionDispatcher = (panelId: string, { action, ...parameters }: {
16
- action: string;
17
- } & Record<string, unknown>, options?: TActionDispatcherOptions) => void;
18
- type TActionDispatcher = ({ action, ...parameters }: {
19
- action: string;
20
- } & Record<string, unknown>, options?: TActionDispatcherOptions) => Promise<TActionResult>;
21
- type TActionHandler = (result: TActionResult) => unknown;
22
- /**
23
- * El hook usePanelActions es el método principal de comunicación entre el
24
- * módulo cliente y el módulo server de un panel.
25
- *
26
- * Acepta un actionsHandler y devuelve un actionDispatcher.
27
- *
28
- * **Existe la acción refresh** que será llamada automáticamente cada vez que
29
- * se guarde la configuración del panel o se haga click en el botón refrescar
30
- * del mismo.
31
- *
32
- * @param actionsHandler Es un objeto de tipo clave-valor en donde cada clave debe corresponderse con una acción que puede ser ejecutada en el panel. El valor debe ser una función que recibe la respuesta del servidor a la ejecución de la acción.
33
- *
34
- * @returns Un método actionDispatcher que permite ejecutar acciones para ser procesadas por la contraparte del panel en el servidor. Al ser llamado acepta un objeto que debe tener como mínimo la propiedad action: string, que indica qué acción será ejecutada. Acepta opcionalmente cualquier cantidad adicional de propiedades en el objeto.
35
- *
36
- * @example
37
- *
38
- const dispatch = usePanelActions({
39
- refresh() {
40
- console.log('Refresh');
41
- },
42
- revert(response: TActionResult<TApiaLoadText>) {
43
- if (response?.data?.text.label !== undefined)
44
- setLabel(response?.data?.text.label);
45
- },
46
- });
47
-
48
- return <Button
49
- onClick={() => {
50
- dispatch({
51
- action: 'revert',
52
- text: (document.getElementById('Text') as
53
- HTMLInputElement).value,
54
- });
55
- }}
56
- >
57
- Revert
58
- </Button>
59
- */
60
- declare function usePanelActions(actionsHandler?: Record<string, TActionHandler>): TActionDispatcher;
61
-
62
- export { type TActionDispatcher, type TActionDispatcherOptions, type TActionHandler, type TActionResult, type TCommonActionResult, type TExternalActionDispatcher, type TFooter, usePanelActions };
63
- //# sourceMappingURL=usePanelActions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePanelActions.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,55 +0,0 @@
1
- import { useMount } from '@apia/util';
2
- import { usePanelIdentity } from '../common/usePanelIdentity.js';
3
- import { useDashboardPanel } from '../dashboard/DashboardPanelContext.js';
4
-
5
- var __defProp = Object.defineProperty;
6
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
- var __publicField = (obj, key, value) => {
8
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
9
- return value;
10
- };
11
- const panelActionsEmitter = new class PanelActionsEmitter {
12
- constructor() {
13
- __publicField(this, "listeners", {});
14
- __publicField(this, "on", (panelId, action, cb) => {
15
- if (!this.listeners[panelId])
16
- this.listeners[panelId] = {};
17
- if (!this.listeners[panelId][action])
18
- this.listeners[panelId][action] = [];
19
- this.listeners[panelId][action].push(cb);
20
- return () => {
21
- this.listeners[panelId][action] = this.listeners[panelId][action].filter(
22
- (current) => current !== cb
23
- );
24
- };
25
- });
26
- __publicField(this, "emit", (panelId, action, data) => {
27
- this.listeners[panelId]?.[action]?.forEach((current) => {
28
- window.requestAnimationFrame(() => {
29
- current({ action, panelId, data });
30
- });
31
- });
32
- });
33
- }
34
- }();
35
- function usePanelActions(actionsHandler) {
36
- const { panelId } = usePanelIdentity();
37
- useMount(() => {
38
- const subscriptions = [];
39
- Object.entries(actionsHandler ?? {}).forEach(([action, handler]) => {
40
- subscriptions.push(
41
- panelActionsEmitter.on(panelId, action, (res) => {
42
- handler(res.data);
43
- })
44
- );
45
- });
46
- return () => {
47
- subscriptions.forEach((unsubscribe) => unsubscribe());
48
- };
49
- });
50
- const panel = useDashboardPanel();
51
- return panel.fireAction;
52
- }
53
-
54
- export { panelActionsEmitter, usePanelActions };
55
- //# sourceMappingURL=usePanelActions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePanelActions.js","sources":["../../src/actions/usePanelActions.ts"],"sourcesContent":["import { TApiaApiResult, IApiaApiRequestConfig } from '@apia/api';\r\nimport { useMount } from '@apia/util';\r\nimport { usePanelIdentity } from '../common';\r\nimport { TPanelId } from '../types';\r\nimport { TOnSucceed } from './firePanelAction';\r\nimport { TBasicAction } from './basicAction';\r\nimport { useDashboardPanel } from '../dashboard/DashboardPanelContext';\r\n\r\ntype TActionListener = (result: {\r\n action: string;\r\n data: TActionResult;\r\n panelId: TPanelId;\r\n}) => unknown;\r\n\r\nexport const panelActionsEmitter = new (class PanelActionsEmitter {\r\n listeners: Record<TPanelId, Record<string, TActionListener[]>> = {};\r\n\r\n on = (panelId: TPanelId, action: string, cb: TActionListener) => {\r\n if (!this.listeners[panelId]) this.listeners[panelId] = {};\r\n if (!this.listeners[panelId][action]) this.listeners[panelId][action] = [];\r\n\r\n this.listeners[panelId][action].push(cb);\r\n\r\n return () => {\r\n this.listeners[panelId][action] = this.listeners[panelId][action].filter(\r\n (current) => current !== cb,\r\n );\r\n };\r\n };\r\n\r\n emit = (panelId: TPanelId, action: string, data: TActionResult) => {\r\n this.listeners[panelId]?.[action]?.forEach((current) => {\r\n window.requestAnimationFrame(() => {\r\n current({ action, panelId, data });\r\n });\r\n });\r\n };\r\n})();\r\n\r\nexport type TFooter = TBasicAction;\r\n\r\nexport type TCommonActionResult = { title: string; footer: TFooter };\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport type TActionResult<T = any> = null | NonNullable<\r\n Awaited<\r\n TApiaApiResult<\r\n T extends Record<string, unknown> ? T & TCommonActionResult : T\r\n >\r\n >\r\n>;\r\n\r\nexport type TActionDispatcherOptions = {\r\n onComplete?: TOnSucceed;\r\n requestConfig?: IApiaApiRequestConfig<object>;\r\n};\r\n\r\nexport type TExternalActionDispatcher = (\r\n panelId: string,\r\n { action, ...parameters }: { action: string } & Record<string, unknown>,\r\n options?: TActionDispatcherOptions,\r\n) => void;\r\n\r\nexport type TActionDispatcher = (\r\n { action, ...parameters }: { action: string } & Record<string, unknown>,\r\n options?: TActionDispatcherOptions,\r\n) => Promise<TActionResult>;\r\n\r\nexport type TActionHandler = (result: TActionResult) => unknown;\r\n\r\n/**\r\n * El hook usePanelActions es el método principal de comunicación entre el\r\n * módulo cliente y el módulo server de un panel.\r\n *\r\n * Acepta un actionsHandler y devuelve un actionDispatcher.\r\n *\r\n * **Existe la acción refresh** que será llamada automáticamente cada vez que\r\n * se guarde la configuración del panel o se haga click en el botón refrescar\r\n * del mismo.\r\n *\r\n * @param actionsHandler Es un objeto de tipo clave-valor en donde cada clave debe corresponderse con una acción que puede ser ejecutada en el panel. El valor debe ser una función que recibe la respuesta del servidor a la ejecución de la acción.\r\n *\r\n * @returns Un método actionDispatcher que permite ejecutar acciones para ser procesadas por la contraparte del panel en el servidor. Al ser llamado acepta un objeto que debe tener como mínimo la propiedad action: string, que indica qué acción será ejecutada. Acepta opcionalmente cualquier cantidad adicional de propiedades en el objeto.\r\n *\r\n * @example\r\n *\r\n const dispatch = usePanelActions({\r\n refresh() {\r\n console.log('Refresh');\r\n },\r\n revert(response: TActionResult<TApiaLoadText>) {\r\n if (response?.data?.text.label !== undefined)\r\n setLabel(response?.data?.text.label);\r\n },\r\n });\r\n\r\n return <Button\r\n onClick={() => {\r\n dispatch({\r\n action: 'revert',\r\n text: (document.getElementById('Text') as\r\n HTMLInputElement).value,\r\n });\r\n }}\r\n >\r\n Revert\r\n </Button>\r\n */\r\nexport function usePanelActions(\r\n actionsHandler?: Record<string, TActionHandler>,\r\n) {\r\n const { panelId } = usePanelIdentity();\r\n\r\n useMount(() => {\r\n const subscriptions: (() => unknown)[] = [];\r\n\r\n Object.entries(actionsHandler ?? {}).forEach(([action, handler]) => {\r\n subscriptions.push(\r\n panelActionsEmitter.on(panelId, action, (res) => {\r\n handler(res.data);\r\n }),\r\n );\r\n });\r\n\r\n return () => {\r\n subscriptions.forEach((unsubscribe) => unsubscribe());\r\n };\r\n });\r\n\r\n const panel = useDashboardPanel();\r\n\r\n return panel.fireAction as TActionDispatcher;\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;;AAca,MAAA,mBAAA,GAAsB,IAAK,MAAM,mBAAoB,CAAA;AAAA,EAA1B,WAAA,GAAA;AACtC,IAAA,aAAA,CAAA,IAAA,EAAA,WAAA,EAAiE,EAAC,CAAA,CAAA;AAElE,IAAK,aAAA,CAAA,IAAA,EAAA,IAAA,EAAA,CAAC,OAAmB,EAAA,MAAA,EAAgB,EAAwB,KAAA;AAC/D,MAAI,IAAA,CAAC,IAAK,CAAA,SAAA,CAAU,OAAO,CAAA;AAAG,QAAK,IAAA,CAAA,SAAA,CAAU,OAAO,CAAA,GAAI,EAAC,CAAA;AACzD,MAAA,IAAI,CAAC,IAAA,CAAK,SAAU,CAAA,OAAO,EAAE,MAAM,CAAA;AAAG,QAAA,IAAA,CAAK,SAAU,CAAA,OAAO,CAAE,CAAA,MAAM,IAAI,EAAC,CAAA;AAEzE,MAAA,IAAA,CAAK,UAAU,OAAO,CAAA,CAAE,MAAM,CAAA,CAAE,KAAK,EAAE,CAAA,CAAA;AAEvC,MAAA,OAAO,MAAM;AACX,QAAK,IAAA,CAAA,SAAA,CAAU,OAAO,CAAA,CAAE,MAAM,CAAA,GAAI,KAAK,SAAU,CAAA,OAAO,CAAE,CAAA,MAAM,CAAE,CAAA,MAAA;AAAA,UAChE,CAAC,YAAY,OAAY,KAAA,EAAA;AAAA,SAC3B,CAAA;AAAA,OACF,CAAA;AAAA,KACF,CAAA,CAAA;AAEA,IAAO,aAAA,CAAA,IAAA,EAAA,MAAA,EAAA,CAAC,OAAmB,EAAA,MAAA,EAAgB,IAAwB,KAAA;AACjE,MAAA,IAAA,CAAK,UAAU,OAAO,CAAA,GAAI,MAAM,CAAG,EAAA,OAAA,CAAQ,CAAC,OAAY,KAAA;AACtD,QAAA,MAAA,CAAO,sBAAsB,MAAM;AACjC,UAAA,OAAA,CAAQ,EAAE,MAAA,EAAQ,OAAS,EAAA,IAAA,EAAM,CAAA,CAAA;AAAA,SAClC,CAAA,CAAA;AAAA,OACF,CAAA,CAAA;AAAA,KACH,CAAA,CAAA;AAAA,GAAA;AACF,CAAG,GAAA;AAuEI,SAAS,gBACd,cACA,EAAA;AACA,EAAM,MAAA,EAAE,OAAQ,EAAA,GAAI,gBAAiB,EAAA,CAAA;AAErC,EAAA,QAAA,CAAS,MAAM;AACb,IAAA,MAAM,gBAAmC,EAAC,CAAA;AAE1C,IAAO,MAAA,CAAA,OAAA,CAAQ,cAAkB,IAAA,EAAE,CAAA,CAAE,QAAQ,CAAC,CAAC,MAAQ,EAAA,OAAO,CAAM,KAAA;AAClE,MAAc,aAAA,CAAA,IAAA;AAAA,QACZ,mBAAoB,CAAA,EAAA,CAAG,OAAS,EAAA,MAAA,EAAQ,CAAC,GAAQ,KAAA;AAC/C,UAAA,OAAA,CAAQ,IAAI,IAAI,CAAA,CAAA;AAAA,SACjB,CAAA;AAAA,OACH,CAAA;AAAA,KACD,CAAA,CAAA;AAED,IAAA,OAAO,MAAM;AACX,MAAA,aAAA,CAAc,OAAQ,CAAA,CAAC,WAAgB,KAAA,WAAA,EAAa,CAAA,CAAA;AAAA,KACtD,CAAA;AAAA,GACD,CAAA,CAAA;AAED,EAAA,MAAM,QAAQ,iBAAkB,EAAA,CAAA;AAEhC,EAAA,OAAO,KAAM,CAAA,UAAA,CAAA;AACf;;;;"}
@@ -1,4 +0,0 @@
1
- declare function usePanelIsLoading(): boolean;
2
-
3
- export { usePanelIsLoading };
4
- //# sourceMappingURL=usePanelIsLoading.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePanelIsLoading.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,14 +0,0 @@
1
- import { useState } from 'react';
2
- import { usePanelActions } from './usePanelActions.js';
3
-
4
- function usePanelIsLoading() {
5
- const [isLoading, setIsLoading] = useState(false);
6
- usePanelActions({
7
- preRefresh: () => setIsLoading(true),
8
- refresh: () => setIsLoading(false)
9
- });
10
- return isLoading;
11
- }
12
-
13
- export { usePanelIsLoading };
14
- //# sourceMappingURL=usePanelIsLoading.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePanelIsLoading.js","sources":["../../src/actions/usePanelIsLoading.ts"],"sourcesContent":["import { useState } from 'react';\r\nimport { usePanelActions } from './usePanelActions';\r\n\r\nexport function usePanelIsLoading() {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n usePanelActions({\r\n preRefresh: () => setIsLoading(true),\r\n refresh: () => setIsLoading(false),\r\n });\r\n\r\n return isLoading;\r\n}\r\n"],"names":[],"mappings":";;;AAGO,SAAS,iBAAoB,GAAA;AAClC,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AAEhD,EAAgB,eAAA,CAAA;AAAA,IACd,UAAA,EAAY,MAAM,YAAA,CAAa,IAAI,CAAA;AAAA,IACnC,OAAA,EAAS,MAAM,YAAA,CAAa,KAAK,CAAA;AAAA,GAClC,CAAA,CAAA;AAED,EAAO,OAAA,SAAA,CAAA;AACT;;;;"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Permite saber en todo momento si el panel actual tuvo un error en su
3
- * conexión de red
4
- */
5
- declare const usePanelNetworkState: () => boolean;
6
-
7
- export { usePanelNetworkState };
8
- //# sourceMappingURL=usePanelNetworkState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePanelNetworkState.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,21 +0,0 @@
1
- import { useState, useEffect } from 'react';
2
- import { EventEmitter } from '@apia/util';
3
- import { usePanelIdentity } from '../common/usePanelIdentity.js';
4
-
5
- class PanelNetworkStateEmitter extends EventEmitter {
6
- }
7
- const panelNetworkStateEmitter = new PanelNetworkStateEmitter();
8
- const usePanelNetworkState = () => {
9
- const [isConnected, setIsConnected] = useState(true);
10
- const { panelId } = usePanelIdentity();
11
- useEffect(() => {
12
- return panelNetworkStateEmitter.on("stateChange", (ev) => {
13
- if (ev.panelId === panelId && ev.isConnected !== isConnected)
14
- setIsConnected(ev.isConnected);
15
- });
16
- }, [isConnected, panelId]);
17
- return isConnected;
18
- };
19
-
20
- export { panelNetworkStateEmitter, usePanelNetworkState };
21
- //# sourceMappingURL=usePanelNetworkState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePanelNetworkState.js","sources":["../../src/actions/usePanelNetworkState.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\r\nimport { EventEmitter, TId } from '@apia/util';\r\nimport { usePanelIdentity } from '../common';\r\n\r\nclass PanelNetworkStateEmitter extends EventEmitter<{\r\n stateChange: {\r\n panelId: TId;\r\n isConnected: boolean;\r\n };\r\n}> {}\r\n\r\nexport const panelNetworkStateEmitter = new PanelNetworkStateEmitter();\r\n\r\n/**\r\n * Permite saber en todo momento si el panel actual tuvo un error en su\r\n * conexión de red\r\n */\r\nexport const usePanelNetworkState = () => {\r\n const [isConnected, setIsConnected] = useState(true);\r\n\r\n const { panelId } = usePanelIdentity();\r\n\r\n useEffect(() => {\r\n return panelNetworkStateEmitter.on('stateChange', (ev) => {\r\n if (ev.panelId === panelId && ev.isConnected !== isConnected)\r\n setIsConnected(ev.isConnected);\r\n });\r\n }, [isConnected, panelId]);\r\n\r\n return isConnected;\r\n};\r\n"],"names":[],"mappings":";;;;AAIA,MAAM,iCAAiC,YAKpC,CAAA;AAAC,CAAA;AAES,MAAA,wBAAA,GAA2B,IAAI,wBAAyB,GAAA;AAM9D,MAAM,uBAAuB,MAAM;AACxC,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,IAAI,CAAA,CAAA;AAEnD,EAAM,MAAA,EAAE,OAAQ,EAAA,GAAI,gBAAiB,EAAA,CAAA;AAErC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,OAAO,wBAAyB,CAAA,EAAA,CAAG,aAAe,EAAA,CAAC,EAAO,KAAA;AACxD,MAAA,IAAI,EAAG,CAAA,OAAA,KAAY,OAAW,IAAA,EAAA,CAAG,WAAgB,KAAA,WAAA;AAC/C,QAAA,cAAA,CAAe,GAAG,WAAW,CAAA,CAAA;AAAA,KAChC,CAAA,CAAA;AAAA,GACA,EAAA,CAAC,WAAa,EAAA,OAAO,CAAC,CAAA,CAAA;AAEzB,EAAO,OAAA,WAAA,CAAA;AACT;;;;"}
@@ -1,10 +0,0 @@
1
- import { TPanelIdentifier } from '../eventsController/types.js';
2
- import '../dashboard/DashboardPanelsBootstraper.js';
3
-
4
- /**
5
- * Permite acceder a la identidad del panel actual.
6
- */
7
- declare function usePanelIdentity(): TPanelIdentifier;
8
-
9
- export { usePanelIdentity };
10
- //# sourceMappingURL=usePanelIdentity.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePanelIdentity.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
1
- import { useContext } from 'react';
2
- import { PanelIdentifierContext } from '../splash/panels/PanelIdentifier.js';
3
-
4
- function usePanelIdentity() {
5
- const context = useContext(PanelIdentifierContext);
6
- if (!context)
7
- throw new Error("Trying to access an unexistent PanelIdentifierContext");
8
- return context;
9
- }
10
-
11
- export { usePanelIdentity };
12
- //# sourceMappingURL=usePanelIdentity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePanelIdentity.js","sources":["../../src/common/usePanelIdentity.ts"],"sourcesContent":["import { useContext } from 'react';\r\nimport { PanelIdentifierContext } from '../splash/panels/PanelIdentifier';\r\n\r\n/**\r\n * Permite acceder a la identidad del panel actual.\r\n */\r\nexport function usePanelIdentity() {\r\n const context = useContext(PanelIdentifierContext);\r\n\r\n if (!context)\r\n throw new Error('Trying to access an unexistent PanelIdentifierContext');\r\n\r\n return context;\r\n}\r\n"],"names":[],"mappings":";;;AAMO,SAAS,gBAAmB,GAAA;AACjC,EAAM,MAAA,OAAA,GAAU,WAAW,sBAAsB,CAAA,CAAA;AAEjD,EAAA,IAAI,CAAC,OAAA;AACH,IAAM,MAAA,IAAI,MAAM,uDAAuD,CAAA,CAAA;AAEzE,EAAO,OAAA,OAAA,CAAA;AACT;;;;"}
@@ -1,15 +0,0 @@
1
- import * as _reduxjs_toolkit_dist_configureStore from '@reduxjs/toolkit/dist/configureStore';
2
- import * as redux_thunk from 'redux-thunk';
3
- import * as redux from 'redux';
4
-
5
- type TPanelParameter = string | number | boolean;
6
- type TParamsStore = Record<string, TPanelParameter>;
7
- type TParamsSlice = Record<string, TParamsStore>;
8
- declare const store: _reduxjs_toolkit_dist_configureStore.ToolkitStore<{
9
- panelParameters: TParamsSlice;
10
- }, redux.AnyAction, [redux_thunk.ThunkMiddleware<{
11
- panelParameters: TParamsSlice;
12
- }>]>;
13
-
14
- export { type TPanelParameter, type TParamsSlice, type TParamsStore, store as parametersStore };
15
- //# sourceMappingURL=parametersStore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parametersStore.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,25 +0,0 @@
1
- import { createSlice, injectReducers } from '@apia/store';
2
-
3
- const paramsSlice = createSlice({
4
- initialState: {},
5
- name: "panelParameters",
6
- reducers: {
7
- udpate(state, {
8
- payload
9
- }) {
10
- if (!state[payload.panelId])
11
- state[payload.panelId] = {};
12
- state[payload.panelId] = {
13
- ...state[payload.panelId],
14
- ...payload.parameters
15
- };
16
- }
17
- }
18
- });
19
- const { store, useSelector } = injectReducers({
20
- panelParameters: paramsSlice.reducer
21
- });
22
- const parametersActions = paramsSlice.actions;
23
-
24
- export { parametersActions, store as parametersStore, useSelector as useParametersSelector };
25
- //# sourceMappingURL=parametersStore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parametersStore.js","sources":["../../src/config/parametersStore.ts"],"sourcesContent":["import { createSlice, injectReducers, PayloadAction } from '@apia/store';\r\nimport { TPanelId } from '../types';\r\n\r\nexport type TPanelParameter = string | number | boolean;\r\nexport type TParamsStore = Record<string, TPanelParameter>;\r\nexport type TParamsSlice = Record<string, TParamsStore>;\r\n\r\nconst paramsSlice = createSlice({\r\n initialState: {} as TParamsSlice,\r\n name: 'panelParameters',\r\n reducers: {\r\n udpate(\r\n state,\r\n {\r\n payload,\r\n }: PayloadAction<{\r\n panelId: TPanelId;\r\n parameters: TParamsStore;\r\n }>,\r\n ) {\r\n if (!state[payload.panelId]) state[payload.panelId] = {};\r\n\r\n state[payload.panelId] = {\r\n ...state[payload.panelId],\r\n ...payload.parameters,\r\n };\r\n },\r\n },\r\n});\r\n\r\nconst { store, useSelector } = injectReducers({\r\n panelParameters: paramsSlice.reducer,\r\n});\r\n\r\nexport { store as parametersStore, useSelector as useParametersSelector };\r\nexport const parametersActions = paramsSlice.actions;\r\n"],"names":[],"mappings":";;AAOA,MAAM,cAAc,WAAY,CAAA;AAAA,EAC9B,cAAc,EAAC;AAAA,EACf,IAAM,EAAA,iBAAA;AAAA,EACN,QAAU,EAAA;AAAA,IACR,OACE,KACA,EAAA;AAAA,MACE,OAAA;AAAA,KAKF,EAAA;AACA,MAAI,IAAA,CAAC,KAAM,CAAA,OAAA,CAAQ,OAAO,CAAA;AAAG,QAAM,KAAA,CAAA,OAAA,CAAQ,OAAO,CAAA,GAAI,EAAC,CAAA;AAEvD,MAAM,KAAA,CAAA,OAAA,CAAQ,OAAO,CAAI,GAAA;AAAA,QACvB,GAAG,KAAM,CAAA,OAAA,CAAQ,OAAO,CAAA;AAAA,QACxB,GAAG,OAAQ,CAAA,UAAA;AAAA,OACb,CAAA;AAAA,KACF;AAAA,GACF;AACF,CAAC,CAAA,CAAA;AAED,MAAM,EAAE,KAAA,EAAO,WAAY,EAAA,GAAI,cAAe,CAAA;AAAA,EAC5C,iBAAiB,WAAY,CAAA,OAAA;AAC/B,CAAC,EAAA;AAGM,MAAM,oBAAoB,WAAY,CAAA;;;;"}
@@ -1,11 +0,0 @@
1
- import { TPanelId } from '../types.js';
2
- import { TParamsStore } from './parametersStore.js';
3
-
4
- /**
5
- * Actualiza los parámetros de un panel a nivel de cliente. Este método se
6
- * expone con el único fin de ser llamado por la acción saveParams del api.
7
- */
8
- declare function saveParameters(panelId: TPanelId, parameters: TParamsStore, refresh?: boolean): void;
9
-
10
- export { saveParameters };
11
- //# sourceMappingURL=saveParameters.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"saveParameters.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,16 +0,0 @@
1
- import { firePanelAction } from '../actions/firePanelAction.js';
2
- import { panelActionsEmitter } from '../actions/usePanelActions.js';
3
- import { parametersStore as store, parametersActions } from './parametersStore.js';
4
-
5
- function saveParameters(panelId, parameters, refresh = true) {
6
- store.dispatch(parametersActions.udpate({ panelId, parameters }));
7
- if (refresh) {
8
- panelActionsEmitter.emit(panelId, "configurationApply", {
9
- data: parameters
10
- });
11
- firePanelAction(panelId, "refresh");
12
- }
13
- }
14
-
15
- export { saveParameters };
16
- //# sourceMappingURL=saveParameters.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"saveParameters.js","sources":["../../src/config/saveParameters.ts"],"sourcesContent":["import { firePanelAction } from '../actions/firePanelAction';\r\nimport { TActionResult, panelActionsEmitter } from '../actions/usePanelActions';\r\nimport { TPanelId } from '../types';\r\nimport {\r\n TParamsStore,\r\n parametersActions,\r\n parametersStore,\r\n} from './parametersStore';\r\n\r\n/**\r\n * Actualiza los parámetros de un panel a nivel de cliente. Este método se\r\n * expone con el único fin de ser llamado por la acción saveParams del api.\r\n */\r\nexport function saveParameters(\r\n panelId: TPanelId,\r\n parameters: TParamsStore,\r\n refresh = true,\r\n) {\r\n parametersStore.dispatch(parametersActions.udpate({ panelId, parameters }));\r\n if (refresh) {\r\n panelActionsEmitter.emit(panelId, 'configurationApply', {\r\n data: parameters,\r\n } as TActionResult);\r\n firePanelAction(panelId, 'refresh');\r\n }\r\n}\r\n"],"names":["parametersStore"],"mappings":";;;;AAaO,SAAS,cACd,CAAA,OAAA,EACA,UACA,EAAA,OAAA,GAAU,IACV,EAAA;AACA,EAAAA,KAAA,CAAgB,SAAS,iBAAkB,CAAA,MAAA,CAAO,EAAE,OAAS,EAAA,UAAA,EAAY,CAAC,CAAA,CAAA;AAC1E,EAAA,IAAI,OAAS,EAAA;AACX,IAAoB,mBAAA,CAAA,IAAA,CAAK,SAAS,oBAAsB,EAAA;AAAA,MACtD,IAAM,EAAA,UAAA;AAAA,KACU,CAAA,CAAA;AAClB,IAAA,eAAA,CAAgB,SAAS,SAAS,CAAA,CAAA;AAAA,GACpC;AACF;;;;"}
@@ -1,22 +0,0 @@
1
- import { ApiaApi, makeApiaUrl } from '@apia/api';
2
- import { EventEmitter } from '@apia/util';
3
- import { usePanelIdentity } from '../common/usePanelIdentity.js';
4
-
5
- class ConfigEmitter extends EventEmitter {
6
- }
7
- new ConfigEmitter();
8
- function usePanelConfig() {
9
- const { panelId } = usePanelIdentity();
10
- return function config() {
11
- void ApiaApi.post(
12
- makeApiaUrl({
13
- action: "panelEdit",
14
- pnlId: panelId
15
- }),
16
- { handleLoad: true }
17
- );
18
- };
19
- }
20
-
21
- export { usePanelConfig };
22
- //# sourceMappingURL=usePanelConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePanelConfig.js","sources":["../../src/config/usePanelConfig.ts"],"sourcesContent":["import { ApiaApi, makeApiaUrl } from '@apia/api';\r\nimport { EventEmitter } from '@apia/util';\r\nimport { usePanelIdentity } from '../common';\r\nimport { TPanelId } from '../types';\r\n\r\nclass ConfigEmitter extends EventEmitter<{\r\n refresh: { panelId: TPanelId };\r\n}> {}\r\n\r\nexport const configEmitter = new ConfigEmitter();\r\n\r\n/**\r\n * Esta función devuelve una función que al ser llamada abre el modal de\r\n * configuración del panel actual. Este modal permite al usuario modificar\r\n * parámetros y una vez confirmado, el resultado de la operación deberá ser\r\n * tomado por una función aún inexistente.\r\n *\r\n * Esta función se deberá encargar de almacenar los parámetros recibidos desde\r\n * el server para el panel actual, así como hacerle llegar al panel\r\n * correspondiente los datos emitidos por su contraparte en el servidor, a fin\r\n * de que actualice su vista.\r\n *\r\n * Admite un callback que será llamado cada vez que se confirme el modal de\r\n * configuración. Este callback se expone a fin de permitir la ejecución de\r\n * acciones previas al refresh que es lanzado en forma automática cuando\r\n */\r\nexport function usePanelConfig() {\r\n const { panelId } = usePanelIdentity();\r\n\r\n return function config() {\r\n void ApiaApi.post(\r\n makeApiaUrl({\r\n action: 'panelEdit',\r\n pnlId: panelId,\r\n }),\r\n { handleLoad: true },\r\n );\r\n };\r\n}\r\n"],"names":[],"mappings":";;;;AAKA,MAAM,sBAAsB,YAEzB,CAAA;AAAC,CAAA;AAEyB,IAAI,aAAc,GAAA;AAiBxC,SAAS,cAAiB,GAAA;AAC/B,EAAM,MAAA,EAAE,OAAQ,EAAA,GAAI,gBAAiB,EAAA,CAAA;AAErC,EAAA,OAAO,SAAS,MAAS,GAAA;AACvB,IAAA,KAAK,OAAQ,CAAA,IAAA;AAAA,MACX,WAAY,CAAA;AAAA,QACV,MAAQ,EAAA,WAAA;AAAA,QACR,KAAO,EAAA,OAAA;AAAA,OACR,CAAA;AAAA,MACD,EAAE,YAAY,IAAK,EAAA;AAAA,KACrB,CAAA;AAAA,GACF,CAAA;AACF;;;;"}
@@ -1,25 +0,0 @@
1
- import { TPanelName } from '../types.js';
2
- import { TPanelParameter } from './parametersStore.js';
3
-
4
- type TParametersSelector<Selected> = (parameters: Record<string, TPanelParameter>) => Selected;
5
- /**
6
- // eslint-disable-next-line comment-length/limit-multi-line-comments
7
- * Este hook permite seleccionar parámetros de un panel. Cada vez que los
8
- * parámetros del panel sean actualizados, se llamará a la función selector y en
9
- * caso de que la selección actual de parámetros difiera de la anterior, se
10
- * provocará un renderizado en el componente que lo utiliza.
11
- *
12
- * Si se quiere obtener los parámetros del panel en el que se está trabajando,
13
- * el segundo parámetro es innecesario. En caso de querer obtener los
14
- * parámetros de otro panel, se puede pasar su nombre como segundo parámetro y
15
- * la selección se hará de acuerdo a los parámetros de éste.
16
- *
17
- * Es importante ver que es imposible prever qué parámetros tendrá cada panel,
18
- * por ello el tipo entregado al selector es Record, que puede entenderse como
19
- * un mapa de entradas con clave string y valor TPanelParameter = string |
20
- * boolean | number.
21
- */
22
- declare function usePanelParametersSelector<Selected>(selector: TParametersSelector<Selected>, panelName?: TPanelName): Selected;
23
-
24
- export { type TParametersSelector, usePanelParametersSelector };
25
- //# sourceMappingURL=usePanelParametersSelector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePanelParametersSelector.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,17 +0,0 @@
1
- import { shallowEqual } from 'react-redux';
2
- import { usePanelIdentity } from '../common/usePanelIdentity.js';
3
- import { useParametersSelector as useSelector } from './parametersStore.js';
4
- import { useDashboardContext } from '../dashboard/DashboardContext.js';
5
-
6
- function usePanelParametersSelector(selector, panelName) {
7
- const { panelId } = usePanelIdentity();
8
- const dashboard = useDashboardContext();
9
- const id = panelName !== void 0 ? dashboard.getPanelByName(panelName)?.id ?? "" : panelId;
10
- return useSelector((global) => {
11
- const currentParams = global.panelParameters[id];
12
- return selector(currentParams ?? {});
13
- }, shallowEqual);
14
- }
15
-
16
- export { usePanelParametersSelector };
17
- //# sourceMappingURL=usePanelParametersSelector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePanelParametersSelector.js","sources":["../../src/config/usePanelParametersSelector.ts"],"sourcesContent":["import { shallowEqual } from 'react-redux';\r\nimport { usePanelIdentity } from '../common';\r\nimport { TPanelName } from '../types';\r\nimport { TPanelParameter, useParametersSelector } from './parametersStore';\r\nimport { useDashboardContext } from '../dashboard';\r\n\r\nexport type TParametersSelector<Selected> = (\r\n parameters: Record<string, TPanelParameter>,\r\n) => Selected;\r\n\r\n/**\r\n // eslint-disable-next-line comment-length/limit-multi-line-comments\r\n * Este hook permite seleccionar parámetros de un panel. Cada vez que los\r\n * parámetros del panel sean actualizados, se llamará a la función selector y en\r\n * caso de que la selección actual de parámetros difiera de la anterior, se\r\n * provocará un renderizado en el componente que lo utiliza.\r\n *\r\n * Si se quiere obtener los parámetros del panel en el que se está trabajando,\r\n * el segundo parámetro es innecesario. En caso de querer obtener los\r\n * parámetros de otro panel, se puede pasar su nombre como segundo parámetro y\r\n * la selección se hará de acuerdo a los parámetros de éste.\r\n *\r\n * Es importante ver que es imposible prever qué parámetros tendrá cada panel,\r\n * por ello el tipo entregado al selector es Record, que puede entenderse como\r\n * un mapa de entradas con clave string y valor TPanelParameter = string |\r\n * boolean | number.\r\n */\r\nexport function usePanelParametersSelector<Selected>(\r\n selector: TParametersSelector<Selected>,\r\n panelName?: TPanelName,\r\n) {\r\n const { panelId } = usePanelIdentity();\r\n const dashboard = useDashboardContext();\r\n const id =\r\n panelName !== undefined\r\n ? dashboard.getPanelByName(panelName)?.id ?? ''\r\n : panelId;\r\n\r\n return useParametersSelector((global) => {\r\n const currentParams = global.panelParameters[id];\r\n return selector(currentParams ?? {});\r\n }, shallowEqual);\r\n}\r\n"],"names":["useParametersSelector"],"mappings":";;;;;AA2BgB,SAAA,0BAAA,CACd,UACA,SACA,EAAA;AACA,EAAM,MAAA,EAAE,OAAQ,EAAA,GAAI,gBAAiB,EAAA,CAAA;AACrC,EAAA,MAAM,YAAY,mBAAoB,EAAA,CAAA;AACtC,EAAM,MAAA,EAAA,GACJ,cAAc,KACV,CAAA,GAAA,SAAA,CAAU,eAAe,SAAS,CAAA,EAAG,MAAM,EAC3C,GAAA,OAAA,CAAA;AAEN,EAAO,OAAAA,WAAA,CAAsB,CAAC,MAAW,KAAA;AACvC,IAAM,MAAA,aAAA,GAAgB,MAAO,CAAA,eAAA,CAAgB,EAAE,CAAA,CAAA;AAC/C,IAAO,OAAA,QAAA,CAAS,aAAiB,IAAA,EAAE,CAAA,CAAA;AAAA,KAClC,YAAY,CAAA,CAAA;AACjB;;;;"}
@@ -1,6 +0,0 @@
1
- import { Dashboard } from './dashboard.js';
2
-
3
- declare function useDashboardContext(): Dashboard;
4
-
5
- export { useDashboardContext };
6
- //# sourceMappingURL=DashboardContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DashboardContext.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
1
- import { createContext, useContext } from 'react';
2
-
3
- const DashboardContext = createContext(null);
4
- function useDashboardContext() {
5
- const context = useContext(DashboardContext);
6
- if (!context)
7
- throw new Error("There is no Dashboard context");
8
- return context;
9
- }
10
-
11
- export { DashboardContext, useDashboardContext };
12
- //# sourceMappingURL=DashboardContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DashboardContext.js","sources":["../../src/dashboard/DashboardContext.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\r\nimport { Dashboard } from './dashboard';\r\n\r\nexport const DashboardContext = createContext<Dashboard | null>(null);\r\n\r\nexport function useDashboardContext() {\r\n const context = useContext(DashboardContext);\r\n\r\n if (!context) throw new Error('There is no Dashboard context');\r\n\r\n return context;\r\n}\r\n"],"names":[],"mappings":";;AAGa,MAAA,gBAAA,GAAmB,cAAgC,IAAI,EAAA;AAE7D,SAAS,mBAAsB,GAAA;AACpC,EAAM,MAAA,OAAA,GAAU,WAAW,gBAAgB,CAAA,CAAA;AAE3C,EAAA,IAAI,CAAC,OAAA;AAAS,IAAM,MAAA,IAAI,MAAM,+BAA+B,CAAA,CAAA;AAE7D,EAAO,OAAA,OAAA,CAAA;AACT;;;;"}
@@ -1,45 +0,0 @@
1
- import * as react from 'react';
2
- import { ReactPortal } from 'react';
3
- import { PanelContainer, TLoadedPanelProps } from '../types.js';
4
- import { TParamsStore } from '../config/parametersStore.js';
5
- import { Dashboard } from './dashboard.js';
6
- import { importPanel } from '../util.js';
7
- import { EventEmitter } from '@apia/util';
8
- import { TActionDispatcherOptions, TActionResult } from '../actions/usePanelActions.js';
9
-
10
- type TPanelProps = Omit<TLoadedPanelProps, 'initialData'>;
11
- declare class DashboardPanel extends EventEmitter<{
12
- hasLoaded: boolean;
13
- isVisible: boolean;
14
- }> {
15
- #private;
16
- dashboard: Dashboard;
17
- hasInited: boolean;
18
- hasLoaded: boolean;
19
- id: string;
20
- initialData: Promise<unknown> | null;
21
- isVisible: boolean;
22
- portal: ReactPortal;
23
- props: TPanelProps;
24
- constructor({ id, dashboard, PanelContainer, }: {
25
- id: string;
26
- dashboard: Dashboard;
27
- PanelContainer: PanelContainer;
28
- });
29
- fireAction: ({ action, ...parameters }: {
30
- action: string;
31
- } & Record<string, unknown>, options?: TActionDispatcherOptions) => Promise<TActionResult>;
32
- getContainer(): HTMLElement;
33
- getParameters(): TParamsStore;
34
- hide(): void;
35
- refresh(): Promise<TActionResult>;
36
- setHasLoaded(): void;
37
- show(): void;
38
- PanelElement: ({ ActualPanelContainer, Element, }: {
39
- ActualPanelContainer: PanelContainer;
40
- Element: ReturnType<typeof importPanel>;
41
- }) => react.JSX.Element | null;
42
- }
43
-
44
- export { DashboardPanel };
45
- //# sourceMappingURL=DashboardPanel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DashboardPanel.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}