@adcops/autocore-react 3.0.1 → 3.0.3

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 (284) hide show
  1. package/dist/assets/BlocklyLogo.d.ts +3 -0
  2. package/dist/assets/BlocklyLogo.js +1 -0
  3. package/dist/assets/Distance.d.ts +3 -0
  4. package/dist/assets/Distance.js +1 -0
  5. package/dist/assets/JogLong.d.ts +3 -0
  6. package/dist/assets/JogLong.js +1 -0
  7. package/dist/assets/JogMedium.d.ts +3 -0
  8. package/dist/assets/JogMedium.js +1 -0
  9. package/dist/assets/JogShort.d.ts +3 -0
  10. package/dist/assets/JogShort.js +1 -0
  11. package/dist/assets/PythonLogo.d.ts +3 -0
  12. package/dist/assets/PythonLogo.js +1 -0
  13. package/dist/assets/Rotation3D.d.ts +3 -0
  14. package/dist/assets/Rotation3D.js +1 -0
  15. package/dist/assets/RotationCcw.d.ts +3 -0
  16. package/dist/assets/RotationCcw.js +1 -0
  17. package/dist/assets/RotationCcwA.d.ts +3 -0
  18. package/dist/assets/RotationCcwA.js +1 -0
  19. package/dist/assets/RotationCcwB.d.ts +3 -0
  20. package/dist/assets/RotationCcwB.js +1 -0
  21. package/dist/assets/RotationCcwC.d.ts +3 -0
  22. package/dist/assets/RotationCcwC.js +1 -0
  23. package/dist/assets/RotationCw.d.ts +3 -0
  24. package/dist/assets/RotationCw.js +1 -0
  25. package/dist/assets/RotationCwA.d.ts +3 -0
  26. package/dist/assets/RotationCwA.js +1 -0
  27. package/dist/assets/RotationCwB.d.ts +3 -0
  28. package/dist/assets/RotationCwB.js +1 -0
  29. package/dist/assets/RotationCwC.d.ts +3 -0
  30. package/dist/assets/RotationCwC.js +1 -0
  31. package/dist/assets/Run.d.ts +3 -0
  32. package/dist/assets/Run.js +1 -0
  33. package/dist/assets/Speed.d.ts +3 -0
  34. package/dist/assets/Speed.js +1 -0
  35. package/dist/assets/SpeedFast.d.ts +3 -0
  36. package/dist/assets/SpeedFast.js +1 -0
  37. package/dist/assets/SpeedMedium.d.ts +3 -0
  38. package/dist/assets/SpeedMedium.js +1 -0
  39. package/dist/assets/SpeedNone.d.ts +3 -0
  40. package/dist/assets/SpeedNone.js +1 -0
  41. package/dist/assets/SpeedSlow.d.ts +3 -0
  42. package/dist/assets/SpeedSlow.js +1 -0
  43. package/dist/assets/Walk.d.ts +3 -0
  44. package/dist/assets/Walk.js +1 -0
  45. package/dist/assets/index.d.ts +22 -0
  46. package/dist/assets/index.js +1 -0
  47. package/dist/assets/svg/blockly_logo.svg +82 -0
  48. package/dist/assets/svg/distance.svg +40 -0
  49. package/dist/assets/svg/jog_long.svg +1 -0
  50. package/dist/assets/svg/jog_medium.svg +1 -0
  51. package/dist/assets/svg/jog_short.svg +1 -0
  52. package/dist/assets/svg/python_logo.svg +246 -0
  53. package/dist/assets/svg/rotation_3d.svg +1 -0
  54. package/dist/assets/svg/rotation_ccw.svg +50 -0
  55. package/dist/assets/svg/rotation_ccw_a.svg +57 -0
  56. package/dist/assets/svg/rotation_ccw_b.svg +57 -0
  57. package/dist/assets/svg/rotation_ccw_c.svg +57 -0
  58. package/dist/assets/svg/rotation_cw.svg +49 -0
  59. package/dist/assets/svg/rotation_cw_a.svg +30 -0
  60. package/dist/assets/svg/rotation_cw_b.svg +30 -0
  61. package/dist/assets/svg/rotation_cw_c.svg +30 -0
  62. package/dist/assets/svg/run.svg +1 -0
  63. package/dist/assets/svg/speed.svg +39 -0
  64. package/dist/assets/svg/speed_fast.svg +1 -0
  65. package/dist/assets/svg/speed_medium.svg +1 -0
  66. package/dist/assets/svg/speed_none.svg +1 -0
  67. package/dist/assets/svg/speed_slow.svg +1 -0
  68. package/dist/assets/svg/walk.svg +1 -0
  69. package/dist/components/BlocklyEditor.css +25 -0
  70. package/dist/components/BlocklyEditor.d.ts +120 -0
  71. package/dist/components/BlocklyEditor.js +1 -0
  72. package/dist/components/CodeEditor.d.ts +76 -0
  73. package/dist/components/CodeEditor.js +1 -0
  74. package/dist/components/Indicator.d.ts +12 -27
  75. package/dist/components/Indicator.js +1 -1
  76. package/dist/components/IndicatorButton.d.ts +56 -37
  77. package/dist/components/IndicatorButton.js +1 -1
  78. package/dist/components/JogPanel.css +41 -0
  79. package/dist/components/JogPanel.d.ts +115 -0
  80. package/dist/components/JogPanel.js +1 -0
  81. package/dist/components/Lamp.d.ts +81 -0
  82. package/dist/components/Lamp.js +1 -0
  83. package/dist/components/ToggleGroup.d.ts +103 -0
  84. package/dist/components/ToggleGroup.js +1 -0
  85. package/dist/core/ActionMode.d.ts +9 -0
  86. package/dist/core/ActionMode.js +1 -0
  87. package/dist/core/IndicatorButtonState.d.ts +21 -0
  88. package/dist/core/IndicatorButtonState.js +1 -0
  89. package/docs/assets/highlight.css +25 -18
  90. package/docs/assets/navigation.js +1 -1
  91. package/docs/assets/search.js +1 -1
  92. package/docs/classes/components_BlocklyEditor.BlocklyEditor.html +124 -0
  93. package/docs/classes/components_CodeEditor.CodeEditor.html +128 -0
  94. package/docs/classes/components_Indicator.Indicator.html +8 -8
  95. package/docs/classes/components_IndicatorButton.IndicatorButton.html +17 -17
  96. package/docs/classes/components_JogPanel.JogPanel.html +138 -0
  97. package/docs/classes/components_Lamp.Lamp.html +105 -0
  98. package/docs/classes/components_OskDialog.OskDialog.html +5 -5
  99. package/docs/classes/components_ToggleGroup.ToggleGroup.html +118 -0
  100. package/docs/classes/components_ValueDisplay.ValueDisplay.html +4 -4
  101. package/docs/classes/core_ValueSimulator.ValueSimulator.html +2 -2
  102. package/docs/classes/hub_HubBase.HubBase.html +4 -4
  103. package/docs/classes/hub_HubSimulate.HubSimulate.html +2 -2
  104. package/docs/classes/hub_HubSocketIo.HubSocketIo.html +5 -5
  105. package/docs/classes/hub_HubTauri.HubTauri.html +5 -5
  106. package/docs/enums/components_JogPanel.JogDistanceAction.html +5 -0
  107. package/docs/enums/components_JogPanel.JogPanelAction.html +18 -0
  108. package/docs/enums/components_JogPanel.JogSpeedAction.html +5 -0
  109. package/docs/enums/core_ActionMode.ActionMode.html +6 -0
  110. package/docs/enums/core_IndicatorColor.IndicatorColor.html +23 -0
  111. package/docs/functions/assets_BlocklyLogo.default.html +1 -0
  112. package/docs/functions/assets_Distance.default.html +1 -0
  113. package/docs/functions/assets_JogLong.default.html +1 -0
  114. package/docs/functions/assets_JogMedium.default.html +1 -0
  115. package/docs/functions/assets_JogShort.default.html +1 -0
  116. package/docs/functions/assets_PythonLogo.default.html +1 -0
  117. package/docs/functions/assets_Rotation3D.default.html +1 -0
  118. package/docs/functions/assets_RotationCcw.default.html +1 -0
  119. package/docs/functions/assets_RotationCcwA.default.html +1 -0
  120. package/docs/functions/assets_RotationCcwB.default.html +1 -0
  121. package/docs/functions/assets_RotationCcwC.default.html +1 -0
  122. package/docs/functions/assets_RotationCw.default.html +1 -0
  123. package/docs/functions/assets_RotationCwA.default.html +1 -0
  124. package/docs/functions/assets_RotationCwB.default.html +1 -0
  125. package/docs/functions/assets_RotationCwC.default.html +1 -0
  126. package/docs/functions/assets_Run.default.html +1 -0
  127. package/docs/functions/assets_Speed.default.html +1 -0
  128. package/docs/functions/assets_SpeedFast.default.html +1 -0
  129. package/docs/functions/assets_SpeedMedium.default.html +1 -0
  130. package/docs/functions/assets_SpeedNone.default.html +1 -0
  131. package/docs/functions/assets_SpeedSlow.default.html +1 -0
  132. package/docs/functions/assets_Walk.default.html +1 -0
  133. package/docs/functions/components_BlocklyEditor.createCustomToolbox.html +6 -0
  134. package/docs/functions/components_Osk.Osk.html +2 -2
  135. package/docs/functions/core_EventEmitterContext.EventEmitterProvider.html +2 -2
  136. package/docs/functions/core_UniqueId.UniqueId.html +2 -2
  137. package/docs/functions/core_hoc.hocAddSubscription.html +2 -2
  138. package/docs/functions/hub.createHub.html +2 -2
  139. package/docs/hierarchy.html +1 -1
  140. package/docs/index.html +18 -2
  141. package/docs/interfaces/components_IndicatorButton.IndicatorButtonProps.html +160 -132
  142. package/docs/interfaces/components_JogPanel.JogPanelButtonDefinition.html +5 -0
  143. package/docs/interfaces/components_ToggleGroup.ToggleGroupProps.html +636 -0
  144. package/docs/interfaces/core_EventEmitterContext.Action.html +2 -2
  145. package/docs/interfaces/core_EventEmitterContext.EventEmitterContextType.html +2 -2
  146. package/docs/interfaces/core_EventEmitterContext.State.html +2 -2
  147. package/docs/interfaces/core_EventEmitterContext.Subscription.html +2 -2
  148. package/docs/interfaces/core_IndicatorButtonState.IndicatorButtonState.html +10 -0
  149. package/docs/interfaces/core_PositionContext.IPositionContext.html +2 -2
  150. package/docs/modules/assets.html +23 -0
  151. package/docs/modules/assets_BlocklyLogo.html +2 -0
  152. package/docs/modules/assets_Distance.html +2 -0
  153. package/docs/modules/assets_JogLong.html +2 -0
  154. package/docs/modules/assets_JogMedium.html +2 -0
  155. package/docs/modules/assets_JogShort.html +2 -0
  156. package/docs/modules/assets_PythonLogo.html +2 -0
  157. package/docs/modules/assets_Rotation3D.html +2 -0
  158. package/docs/modules/assets_RotationCcw.html +2 -0
  159. package/docs/modules/assets_RotationCcwA.html +2 -0
  160. package/docs/modules/assets_RotationCcwB.html +2 -0
  161. package/docs/modules/assets_RotationCcwC.html +2 -0
  162. package/docs/modules/assets_RotationCw.html +2 -0
  163. package/docs/modules/assets_RotationCwA.html +2 -0
  164. package/docs/modules/assets_RotationCwB.html +2 -0
  165. package/docs/modules/assets_RotationCwC.html +2 -0
  166. package/docs/modules/assets_Run.html +2 -0
  167. package/docs/modules/assets_Speed.html +2 -0
  168. package/docs/modules/assets_SpeedFast.html +2 -0
  169. package/docs/modules/assets_SpeedMedium.html +2 -0
  170. package/docs/modules/assets_SpeedNone.html +2 -0
  171. package/docs/modules/assets_SpeedSlow.html +2 -0
  172. package/docs/modules/assets_Walk.html +2 -0
  173. package/docs/modules/components_BlocklyEditor.html +5 -0
  174. package/docs/modules/components_CodeEditor.html +3 -0
  175. package/docs/modules/components_Indicator.html +2 -2
  176. package/docs/modules/components_IndicatorButton.html +4 -4
  177. package/docs/modules/components_JogPanel.html +9 -0
  178. package/docs/modules/components_Lamp.html +4 -0
  179. package/docs/modules/components_Osk.html +2 -2
  180. package/docs/modules/components_OskDialog.html +2 -2
  181. package/docs/modules/components_ToggleGroup.html +5 -0
  182. package/docs/modules/components_ValueDisplay.html +2 -2
  183. package/docs/modules/core_ActionMode.html +2 -0
  184. package/docs/modules/core_EventEmitterContext.html +2 -2
  185. package/docs/modules/{components_IndicatorColor.html → core_IndicatorButtonState.html} +2 -2
  186. package/docs/modules/core_IndicatorColor.html +2 -0
  187. package/docs/modules/core_MaskPatterns.html +2 -2
  188. package/docs/modules/core_NumerableTypes.html +2 -2
  189. package/docs/modules/core_PositionContext.html +2 -2
  190. package/docs/modules/core_UniqueId.html +2 -2
  191. package/docs/modules/core_ValueSimulator.html +2 -2
  192. package/docs/modules/core_hoc.html +2 -2
  193. package/docs/modules/hub.html +2 -2
  194. package/docs/modules/hub_HubBase.html +2 -2
  195. package/docs/modules/hub_HubSimulate.html +2 -2
  196. package/docs/modules/hub_HubSocketIo.html +2 -2
  197. package/docs/modules/hub_HubTauri.html +2 -2
  198. package/docs/types/components_IndicatorButton.IndicatorButtonOptionsType.html +1 -0
  199. package/docs/types/core_EventEmitterContext.EmitterDispatchFunction.html +2 -2
  200. package/docs/types/core_EventEmitterContext.EmitterSubscribeFunction.html +2 -2
  201. package/docs/types/core_EventEmitterContext.EmitterUnsubscribeFunction.html +2 -2
  202. package/docs/types/core_NumerableTypes.NumerableFormatOptions.html +2 -2
  203. package/docs/types/core_hoc.HocAddSubscriptionProps.html +2 -2
  204. package/docs/variables/components_BlocklyEditor.StandardToolbox.html +1 -0
  205. package/docs/variables/components_JogPanel.kDefaultButtonDefinitions.html +2 -0
  206. package/docs/variables/components_JogPanel.kRotationButtonDefinitions.html +1 -0
  207. package/docs/variables/core_EventEmitterContext.EventEmitterContext.html +6 -6
  208. package/docs/variables/core_MaskPatterns.PrimeReactMaskPatterns.html +2 -2
  209. package/docs/variables/core_MaskPatterns.RegExMaskPatterns.html +2 -2
  210. package/docs/variables/core_PositionContext.DimensionsContext.html +2 -2
  211. package/package.json +7 -3
  212. package/readme.md +33 -0
  213. package/src/assets/BlocklyLogo.tsx +27 -0
  214. package/src/assets/Distance.tsx +18 -0
  215. package/src/assets/JogLong.tsx +13 -0
  216. package/src/assets/JogMedium.tsx +13 -0
  217. package/src/assets/JogShort.tsx +13 -0
  218. package/src/assets/PythonLogo.tsx +83 -0
  219. package/src/assets/Rotation3D.tsx +13 -0
  220. package/src/assets/RotationCcw.tsx +33 -0
  221. package/src/assets/RotationCcwA.tsx +45 -0
  222. package/src/assets/RotationCcwB.tsx +45 -0
  223. package/src/assets/RotationCcwC.tsx +45 -0
  224. package/src/assets/RotationCw.tsx +31 -0
  225. package/src/assets/RotationCwA.tsx +42 -0
  226. package/src/assets/RotationCwB.tsx +42 -0
  227. package/src/assets/RotationCwC.tsx +42 -0
  228. package/src/assets/Run.tsx +13 -0
  229. package/src/assets/Speed.tsx +18 -0
  230. package/src/assets/SpeedFast.tsx +13 -0
  231. package/src/assets/SpeedMedium.tsx +13 -0
  232. package/src/assets/SpeedNone.tsx +13 -0
  233. package/src/assets/SpeedSlow.tsx +13 -0
  234. package/src/assets/Walk.tsx +13 -0
  235. package/src/assets/index.ts +22 -0
  236. package/src/assets/svg/blockly_logo.svg +82 -0
  237. package/src/assets/svg/distance.svg +40 -0
  238. package/src/assets/svg/jog_long.svg +1 -0
  239. package/src/assets/svg/jog_medium.svg +1 -0
  240. package/src/assets/svg/jog_short.svg +1 -0
  241. package/src/assets/svg/python_logo.svg +246 -0
  242. package/src/assets/svg/rotation_3d.svg +1 -0
  243. package/src/assets/svg/rotation_ccw.svg +50 -0
  244. package/src/assets/svg/rotation_ccw_a.svg +57 -0
  245. package/src/assets/svg/rotation_ccw_b.svg +57 -0
  246. package/src/assets/svg/rotation_ccw_c.svg +57 -0
  247. package/src/assets/svg/rotation_cw.svg +49 -0
  248. package/src/assets/svg/rotation_cw_a.svg +30 -0
  249. package/src/assets/svg/rotation_cw_b.svg +30 -0
  250. package/src/assets/svg/rotation_cw_c.svg +30 -0
  251. package/src/assets/svg/run.svg +1 -0
  252. package/src/assets/svg/speed.svg +39 -0
  253. package/src/assets/svg/speed_fast.svg +1 -0
  254. package/src/assets/svg/speed_medium.svg +1 -0
  255. package/src/assets/svg/speed_none.svg +1 -0
  256. package/src/assets/svg/speed_slow.svg +1 -0
  257. package/src/assets/svg/walk.svg +1 -0
  258. package/src/components/BlocklyEditor.css +25 -0
  259. package/src/components/BlocklyEditor.tsx +598 -0
  260. package/src/components/CodeEditor.tsx +156 -0
  261. package/src/components/Indicator.tsx +63 -118
  262. package/src/components/IndicatorButton.tsx +104 -50
  263. package/src/components/JogPanel.css +41 -0
  264. package/src/components/JogPanel.tsx +458 -0
  265. package/src/components/Lamp.tsx +243 -0
  266. package/src/components/ToggleGroup.tsx +429 -0
  267. package/src/core/ActionMode.ts +20 -0
  268. package/src/core/IndicatorButtonState.ts +34 -0
  269. package/tools/copy-distribution-files.cjs +3 -2
  270. package/dist/components/DPad.css +0 -522
  271. package/dist/components/DPad.d.ts +0 -34
  272. package/dist/components/DPad.js +0 -1
  273. package/docs/enums/components_DPad.VcJoyPadAction.html +0 -10
  274. package/docs/enums/components_DPad.VcJoyPadButtonId.html +0 -7
  275. package/docs/enums/components_IndicatorButton.ActionMode.html +0 -6
  276. package/docs/enums/components_IndicatorColor.IndicatorColor.html +0 -23
  277. package/docs/functions/components_DPad.VcDPad.html +0 -5
  278. package/docs/interfaces/components_IndicatorButton.IndicatorButtonState.html +0 -10
  279. package/docs/modules/components_DPad.html +0 -5
  280. package/src/components/DPad.css +0 -522
  281. package/src/components/DPad.tsx +0 -94
  282. /package/dist/{components → core}/IndicatorColor.d.ts +0 -0
  283. /package/dist/{components → core}/IndicatorColor.js +0 -0
  284. /package/src/{components → core}/IndicatorColor.ts +0 -0
@@ -0,0 +1,429 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
+ * Created Date: 2024-03-12 10:14:48
4
+ * -----
5
+ * Last Modified: 2024-03-12 20:40:14
6
+ * -----
7
+ *
8
+ */
9
+
10
+ import { Component } from 'react';
11
+ import { SelectButton, SelectButtonProps } from 'primereact/selectbutton';
12
+ import {SelectItemOptionsType} from "primereact/selectitem";
13
+
14
+ import { EventEmitterContext, EventEmitterContextType } from '../core/EventEmitterContext';
15
+ import {IndicatorColor} from "../core/IndicatorColor";
16
+ export {IndicatorColor}
17
+ import { ActionMode } from '../core/ActionMode';
18
+ export {ActionMode};
19
+
20
+ import { IndicatorButtonState } from '../core/IndicatorButtonState';
21
+
22
+
23
+
24
+ export interface ToggleGroupProps extends SelectButtonProps {
25
+
26
+ /**
27
+ * Label of the group/row. Can be any element.
28
+ *
29
+ * ## Examples
30
+ * ```
31
+ * <ToggleGroup label="Simple Text" />
32
+ * <ToggleGroup label={<span><i className="pi pi-check"></i> Icon and Text</span>} />
33
+ * <ToggleGroup label={<YourCustomIconComponent />} />
34
+ * ```
35
+ */
36
+ label? : React.ReactNode;
37
+
38
+
39
+ /**
40
+ * Topic name to monitor for state indication.
41
+ * If `value` field is not undefined, then that value is used instead.
42
+ */
43
+ topic?: string;
44
+
45
+ /**
46
+ * Color for the button when the state is TRUE.
47
+ */
48
+ onColor?: IndicatorColor | IndicatorColor[];
49
+
50
+ /**
51
+ * Color for the button when the state is FALSE.
52
+ */
53
+ offColor?: IndicatorColor;
54
+
55
+
56
+ /**
57
+ * Name of the command to invoke on button events.
58
+ * If command is "*", then the commandTopic will be dispatched
59
+ * internally.
60
+ */
61
+ command?: string;
62
+
63
+ /**
64
+ * Optional topic parameter to send along with the command.
65
+ * If set, will automatically be included with commandArgs as
66
+ * the value of field 'topic.'
67
+ */
68
+ commandTopic? : string;
69
+
70
+ /**
71
+ * Optional arguments sent with the command.
72
+ */
73
+ commandArgs?: any;
74
+
75
+ /**
76
+ * Topic to disable button interaction.
77
+ */
78
+ disableTopic?: string;
79
+
80
+ /**
81
+ * Topic to control the visibility of the button.
82
+ */
83
+ invisibleTopic?: string;
84
+
85
+ /**
86
+ * Mode of input for the button (e.g., TAP, TOGGLE).
87
+ */
88
+ actionMode?: ActionMode;
89
+
90
+ /**
91
+ * Inverts the signal values for TAP, PRESSED, and RELEASED modes.
92
+ */
93
+ invert?: boolean;
94
+ }
95
+
96
+
97
+ /**
98
+ *
99
+ * @param s string | undefined[]
100
+ * @returns
101
+ */
102
+ // function generateSelectButtonOptions(s? : SelectItemOptionsType | undefined) : SelectItemOptionsType | undefined {
103
+ // if (s !== undefined && s !== null) {
104
+ // let ret : SelectItemOptionsType = [];
105
+ // for (let i=0;i<s.length;++i) {
106
+ // ret.push({label:s[i]});
107
+ // }
108
+
109
+ // return ret;
110
+ // }
111
+ // else {
112
+ // return undefined;
113
+ // }
114
+ // }
115
+
116
+
117
+ /**
118
+ *
119
+ * @param currentValue
120
+ * @param options
121
+ * @returns
122
+ */
123
+ function matchCurrentValue(currentValue : any, options : SelectItemOptionsType | undefined) : any {
124
+
125
+ if (options === undefined || options === null || options.length === 0)
126
+ return undefined;
127
+
128
+ let t = typeof(currentValue);
129
+ if (t == "boolean" ) {
130
+ let b = currentValue as boolean;
131
+ if (b) {
132
+ if (options.length > 1 )
133
+ return options[1];
134
+ else
135
+ return options[0];
136
+ }
137
+ else {
138
+ return options[0];
139
+ }
140
+ }
141
+ else if (t == "number") {
142
+ let n = currentValue as number;
143
+ if (n !== undefined && n < options.length ) {
144
+ return options[n];
145
+ }
146
+ }
147
+ else if (t == "string") {
148
+ // The SelectButton should match to this value automatically, if it's in the
149
+ // options array. No reason to search twice.
150
+ return currentValue;
151
+ }
152
+
153
+
154
+ return undefined;
155
+ }
156
+
157
+
158
+
159
+ /**
160
+ *
161
+ * @param currentValue
162
+ * @param options
163
+ * @returns
164
+ */
165
+
166
+ function selectOnColor(
167
+ currentValue: any,
168
+ options: SelectItemOptionsType | undefined,
169
+ onColorProp: IndicatorColor | IndicatorColor[] | undefined
170
+ ): IndicatorColor {
171
+
172
+ if (!options || options.length === 0)
173
+ return IndicatorColor.IndicatorInvalid;
174
+
175
+ let colorArray =
176
+ Array.isArray(onColorProp) ? onColorProp :
177
+ onColorProp !== undefined ? [onColorProp] : [IndicatorColor.IndicatorInvalid];
178
+
179
+ let t = typeof(currentValue);
180
+ if (t === "boolean") {
181
+ return currentValue ? colorArray[0] : colorArray.length > 1 ? colorArray[1] : colorArray[0];
182
+ }
183
+ else if (t === "number" && options.length > currentValue) {
184
+ if (colorArray.length > currentValue) {
185
+ let index = currentValue as number;
186
+ return colorArray[index];
187
+ }
188
+ else {
189
+ return colorArray[0];
190
+ }
191
+ }
192
+ else if (t === "string") {
193
+ let index = options.indexOf(currentValue);
194
+ if (index !== -1 && index < colorArray.length)
195
+ return colorArray[index];
196
+ else
197
+ return colorArray[0];
198
+ }
199
+
200
+ if (onColorProp !== undefined && onColorProp !== null) {
201
+ return Array.isArray(onColorProp) ? onColorProp[0] : onColorProp as IndicatorColor;
202
+ }
203
+ else {
204
+ return IndicatorColor.IndicatorInvalid;
205
+ }
206
+
207
+ }
208
+
209
+
210
+ export class ToggleGroup extends Component<ToggleGroupProps, IndicatorButtonState> {
211
+
212
+ static contextType = EventEmitterContext;
213
+
214
+ constructor(props: ToggleGroupProps) {
215
+ super(props);
216
+ this.state = {
217
+ currentValue: undefined,
218
+ isDisabled: false,
219
+ isInvisible: false,
220
+ isPressed: false
221
+ };
222
+ }
223
+
224
+ componentDidMount() {
225
+ this.setupSubscriptions();
226
+ }
227
+
228
+ componentDidUpdate(prevProps: ToggleGroupProps) {
229
+ prevProps;
230
+ // Logic to handle updates in props, if necessary
231
+ }
232
+
233
+ componentWillUnmount() {
234
+ // Unsubscribe logic if needed
235
+ }
236
+
237
+ /**
238
+ * Sets up subscriptions based on provided topics.
239
+ */
240
+ private setupSubscriptions() {
241
+ const { topic, disableTopic, invisibleTopic } = this.props;
242
+ const { subscribe } = this.context as EventEmitterContextType;
243
+
244
+ if (topic) {
245
+ // Subscribe to the main topic
246
+ subscribe(topic, this.handleTopicUpdate);
247
+ }
248
+
249
+ if (disableTopic) {
250
+ // Subscribe to the disable topic
251
+ subscribe(disableTopic, this.handleDisableTopicUpdate);
252
+ }
253
+
254
+ if (invisibleTopic) {
255
+ // Subscribe to the invisible topic
256
+ subscribe(invisibleTopic, this.handleInvisibleTopicUpdate);
257
+ }
258
+ }
259
+
260
+ /**
261
+ * Handles updates for the main topic.
262
+ */
263
+ private handleTopicUpdate = (value: boolean) => {
264
+ this.setState({ currentValue: value });
265
+ };
266
+
267
+ /**
268
+ * Handles updates for the disable topic.
269
+ */
270
+ private handleDisableTopicUpdate = (value: boolean) => {
271
+ this.setState({ isDisabled: value });
272
+ };
273
+
274
+ /**
275
+ * Handles updates for the invisible topic.
276
+ */
277
+ private handleInvisibleTopicUpdate = (value: boolean) => {
278
+ this.setState({ isInvisible: value });
279
+ };
280
+
281
+
282
+ /**
283
+ * Handle the button being pressed down. Used for TAP and PRESSED action modes.
284
+ */
285
+ protected handleOnPressed() {
286
+ const { isPressed } = this.state;
287
+ const {actionMode} = this.props;
288
+
289
+ if (!isPressed) {
290
+ this.setState({isPressed: true});
291
+
292
+ if (actionMode === ActionMode.Tap || actionMode === ActionMode.Pressed) {
293
+ this.dispatchCommand(true);
294
+ }
295
+ }
296
+ }
297
+
298
+ /**
299
+ * Handle the button being released. Used for TAP and RELEASED action modes.
300
+ */
301
+ protected handleOnReleased() {
302
+ const { isPressed } = this.state;
303
+ const {actionMode} = this.props;
304
+
305
+ if (isPressed) {
306
+ this.setState({isPressed: false});
307
+
308
+ if (actionMode === ActionMode.Tap ) {
309
+ this.dispatchCommand(false);
310
+ }
311
+ else if (actionMode === ActionMode.Released) {
312
+ this.dispatchCommand(true);
313
+ }
314
+ }
315
+ }
316
+
317
+
318
+ /**
319
+ * Dispatch a value to any listeners.
320
+ * @param value The value to dispatch as part of the payload.
321
+ */
322
+ protected dispatchCommand(value : any) {
323
+
324
+ const {command, commandTopic, commandArgs} = this.props;
325
+ const { dispatch } = this.context as EventEmitterContextType;
326
+
327
+ if (command !== undefined && command !== null && command.length > 0 )
328
+ {
329
+ const payload = {
330
+ topic: commandTopic,
331
+ value: value,
332
+ ...commandArgs
333
+ };
334
+
335
+ dispatch({
336
+ topic: command,
337
+ payload: payload
338
+ });
339
+
340
+ }
341
+
342
+ }
343
+
344
+
345
+
346
+
347
+ render() {
348
+ // const { currentValue, isDisabled, isInvisible } = this.state;
349
+ // const { className, severity, label, raised,
350
+ // onColor, offColor, options, topic, command,
351
+ // commandArgs, disableTopic, invisibleTopic, inputMode, invert,
352
+ // onIcon, offIcon, icon,
353
+ // ...restProps
354
+ // } = this.props;
355
+
356
+
357
+ const { currentValue, isDisabled, isInvisible} = this.state;
358
+ const { label, value, disabled, className,
359
+ onColor, offColor, options,
360
+ ...restProps
361
+ } = this.props;
362
+
363
+
364
+ // let btnIcon = currentValue ? onIcon : offIcon;
365
+ // if (btnIcon === undefined || btnIcon === null || btnIcon.length === 0)
366
+ // btnIcon = icon;
367
+
368
+
369
+ //
370
+ // Load the value from the proper source.
371
+ // If the `value` property is undefined, that takes precedence.
372
+ //
373
+ let displayValue = currentValue;
374
+ if (value !== undefined) {
375
+ displayValue = value;
376
+ }
377
+
378
+ let color = selectOnColor(displayValue, options, onColor); // displayValue ? onColor : offColor;
379
+
380
+ // Handle special cases like undefined state or specific input modes
381
+ if (displayValue === undefined) {
382
+ color = IndicatorColor.IndicatorInvalid;
383
+ }
384
+
385
+ const isMultiple = options !== undefined && options !== null && options.length > 2;
386
+
387
+
388
+ return (
389
+ <div className="flex">
390
+
391
+ <style>{`
392
+ ${offColor !== undefined ? `
393
+ .togglegroup-selectbutton-container .p-selectbutton .p-button {
394
+ background-color: ${offColor};
395
+ }
396
+ ` : ''}
397
+ .togglegroup-selectbutton-container .p-selectbutton .p-button.p-highlight {
398
+ background-color: ${color} !important;
399
+ border-color: ${color} !important;
400
+ }
401
+ .togglegroup-selectbutton-container .p-selectbutton .p-highlight {
402
+ background-color: ${color} !important;
403
+ border-color: ${color} !important;
404
+ }
405
+ `}
406
+ </style>
407
+ <div className='p-inputgroup togglegroup-selectbutton-container'>
408
+ <span className="p-inputgroup-addon" style={{flexGrow: 1}}>
409
+ {label}
410
+ </span>
411
+ <SelectButton {...restProps}
412
+ options={options}
413
+ disabled={isDisabled || disabled}
414
+ multiple={isMultiple}
415
+ className={`${className || ''} ${displayValue === undefined ? 'p-invalid' : ''}`.trim()}
416
+ {...(isInvisible && { style: { display: 'none' }})}
417
+ value={matchCurrentValue(displayValue, options)}
418
+ allowEmpty={false}
419
+ onMouseDown={() => this.handleOnPressed() }
420
+ onTouchStart={() => this.handleOnPressed() }
421
+ onMouseUp={() => this.handleOnReleased() }
422
+ onTouchEnd={() => this.handleOnReleased() }
423
+ />
424
+ </div>
425
+ </div>
426
+ );
427
+ }
428
+
429
+ }
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
+ * Created Date: 2024-03-12 10:28:38
4
+ * -----
5
+ * Last Modified: 2024-03-12 10:28:47
6
+ * -----
7
+ *
8
+ */
9
+
10
+
11
+
12
+ /**
13
+ * Enum for different input modes of the IndicatorButton.
14
+ */
15
+ export enum ActionMode {
16
+ Tap = 'Tap',
17
+ Toggle = 'Toggle',
18
+ Pressed = 'Pressed',
19
+ Released = 'Released'
20
+ }
@@ -0,0 +1,34 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
+ * Created Date: 2024-03-12 11:08:29
4
+ * -----
5
+ * Last Modified: 2024-03-12 11:08:41
6
+ * -----
7
+ *
8
+ */
9
+
10
+
11
+ /**
12
+ * Common state for the indicator buttons, toggles or similar components.
13
+ */
14
+ export interface IndicatorButtonState {
15
+ /**
16
+ * Current value/state of the button based on the subscribed topic.
17
+ */
18
+ currentValue?: boolean | number | string;
19
+
20
+ /**
21
+ * Indicates whether the button is disabled.
22
+ */
23
+ isDisabled?: boolean;
24
+
25
+ /**
26
+ * Indicates whether the button is invisible.
27
+ */
28
+ isInvisible?: boolean;
29
+
30
+ /**
31
+ * The button is in the "down" state.
32
+ */
33
+ isPressed : boolean;
34
+ }
@@ -3,8 +3,8 @@
3
3
  * Created Date: 2024-01-08 13:01:16
4
4
  * Author: Thomas C. Bitsky Jr.
5
5
  * -----
6
- * Last Modified: 2024-01-15 07:32:57
7
- * Modified By: Thomas C. Bitsky Jr.
6
+ * Last Modified: 2024-03-17 12:37:37
7
+ * Modified By: ADC
8
8
  * -----
9
9
  *
10
10
  */
@@ -69,5 +69,6 @@ function copyFilesByType(srcDir, destDir, extension) {
69
69
  copyFilesByType("./src", "./dist", "css");
70
70
  copyFilesByType("./src", "./dist", "ttf");
71
71
  copyFilesByType("./src", "./dist", "woff2");
72
+ copyFilesByType("./src", "./dist", "svg");
72
73
  // JavaScript files won't be processed by tsc
73
74
  //copyFilesByType("./src", "./dist", "js");