@imperosoft/cris-webui-components 1.1.2-beta.1 → 1.1.2-beta.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.
package/dist/index.mjs CHANGED
@@ -73,9 +73,12 @@ function CrisButton({
73
73
  iconNameActive,
74
74
  iconClassActive,
75
75
  iconStyleActive,
76
+ selected,
76
77
  showControlFeedback = true,
77
78
  showLocalFeedback = true,
78
79
  suppressKeyClicks = false,
80
+ visible,
81
+ enabled,
79
82
  smartId,
80
83
  className = "",
81
84
  classActive = "",
@@ -99,11 +102,11 @@ function CrisButton({
99
102
  const touchStartedHereRef = useRef(false);
100
103
  const feedbackJoin = joinFeedback ?? join;
101
104
  const feedback = useDigital(feedbackJoin ?? 0);
102
- const enabled = useDigital(joinEnable ?? 0);
103
- const visible = useDigital(joinVisible ?? 0);
105
+ const enabledJoin = useDigital(joinEnable ?? 0);
106
+ const visibleJoin = useDigital(joinVisible ?? 0);
104
107
  const dSet = useJoinsStore((state) => state.dSet);
105
- const isEnabled = joinEnable == null ? true : enabled;
106
- const isVisible = joinVisible == null ? true : visible;
108
+ const isEnabled = enabled ?? (joinEnable == null ? true : enabledJoin);
109
+ const isVisible = visible ?? (joinVisible == null ? true : visibleJoin);
107
110
  useEffect(() => {
108
111
  log("visibility effect", { isVisible, pressedRef: pressedRef.current });
109
112
  if (!isVisible && pressedRef.current) {
@@ -126,7 +129,7 @@ function CrisButton({
126
129
  }
127
130
  };
128
131
  }, [join, smartId, dSet, log]);
129
- const hasControlFeedback = showControlFeedback && feedbackJoin != null && feedback;
132
+ const hasControlFeedback = showControlFeedback && (feedbackJoin != null && feedback || selected === true);
130
133
  const hasPressedFeedback = showLocalFeedback && pressed && isEnabled;
131
134
  const isActive = hasControlFeedback || hasPressedFeedback;
132
135
  let currentText = text ?? "";
@@ -1103,8 +1106,194 @@ function CrisOfflinePage({
1103
1106
  ] })
1104
1107
  ] }) });
1105
1108
  }
1109
+
1110
+ // src/components/CrisCoDebug.tsx
1111
+ import { useCustomObject, useCustomObjectSend } from "@imperosoft/cris-webui-ch5-core";
1112
+ import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
1113
+ var defaultStyles = {
1114
+ container: {
1115
+ display: "flex",
1116
+ flexDirection: "column",
1117
+ overflow: "auto",
1118
+ gap: 2
1119
+ },
1120
+ title: {
1121
+ fontSize: 14,
1122
+ fontWeight: 600,
1123
+ padding: "8px 12px",
1124
+ opacity: 0.7
1125
+ },
1126
+ item: {
1127
+ display: "flex",
1128
+ alignItems: "center",
1129
+ padding: "8px 12px",
1130
+ gap: 8,
1131
+ minHeight: 48
1132
+ },
1133
+ info: {
1134
+ flex: 1,
1135
+ minWidth: 0,
1136
+ overflow: "hidden"
1137
+ },
1138
+ moduleName: {
1139
+ fontSize: 14,
1140
+ fontWeight: 600,
1141
+ whiteSpace: "nowrap",
1142
+ overflow: "hidden",
1143
+ textOverflow: "ellipsis"
1144
+ },
1145
+ moduleType: {
1146
+ fontSize: 11,
1147
+ opacity: 0.5
1148
+ },
1149
+ icons: {
1150
+ display: "flex",
1151
+ gap: 4,
1152
+ alignItems: "center",
1153
+ minWidth: 56,
1154
+ justifyContent: "center"
1155
+ },
1156
+ buttons: {
1157
+ display: "flex",
1158
+ gap: 4,
1159
+ alignItems: "center"
1160
+ },
1161
+ iconBox: {
1162
+ width: 24,
1163
+ height: 24,
1164
+ display: "flex",
1165
+ alignItems: "center",
1166
+ justifyContent: "center",
1167
+ position: "relative"
1168
+ }
1169
+ };
1170
+ function ConnectionIcon({ on, type }) {
1171
+ const label = type === "eth" ? "ETH" : "RS";
1172
+ return /* @__PURE__ */ jsx7(
1173
+ "div",
1174
+ {
1175
+ style: {
1176
+ ...defaultStyles.iconBox,
1177
+ opacity: on ? 1 : 0.4
1178
+ },
1179
+ title: `${type === "eth" ? "Ethernet" : "RS232"}: ${on ? "Connected" : "Disconnected"}`,
1180
+ children: /* @__PURE__ */ jsxs6("svg", { width: "20", height: "20", viewBox: "0 0 20 20", children: [
1181
+ /* @__PURE__ */ jsx7("rect", { x: "1", y: "4", width: "18", height: "12", rx: "2", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }),
1182
+ /* @__PURE__ */ jsx7("text", { x: "10", y: "12.5", textAnchor: "middle", fontSize: "7", fontWeight: "bold", fill: "currentColor", children: label }),
1183
+ on ? /* @__PURE__ */ jsx7("circle", { cx: "16", cy: "5", r: "3.5", fill: "#4caf50", stroke: "none" }) : /* @__PURE__ */ jsxs6(Fragment2, { children: [
1184
+ /* @__PURE__ */ jsx7("circle", { cx: "16", cy: "5", r: "3.5", fill: "#f44336", stroke: "none" }),
1185
+ /* @__PURE__ */ jsx7("line", { x1: "14", y1: "3", x2: "18", y2: "7", stroke: "white", strokeWidth: "1.5" })
1186
+ ] })
1187
+ ] })
1188
+ }
1189
+ );
1190
+ }
1191
+ function DebugModuleItem({
1192
+ module,
1193
+ onAction,
1194
+ itemClassName,
1195
+ itemStyle,
1196
+ buttonClassName,
1197
+ buttonActiveClassName,
1198
+ iconEthOn,
1199
+ iconEthOff,
1200
+ iconRs232On,
1201
+ iconRs232Off
1202
+ }) {
1203
+ const name = module.lb ? `${module.id} (${module.lb})` : module.id;
1204
+ return /* @__PURE__ */ jsxs6(
1205
+ "div",
1206
+ {
1207
+ className: itemClassName,
1208
+ style: itemClassName ? itemStyle : { ...defaultStyles.item, ...itemStyle },
1209
+ children: [
1210
+ /* @__PURE__ */ jsxs6("div", { style: defaultStyles.info, children: [
1211
+ /* @__PURE__ */ jsx7("div", { style: defaultStyles.moduleName, children: name }),
1212
+ /* @__PURE__ */ jsx7("div", { style: defaultStyles.moduleType, children: module.tp })
1213
+ ] }),
1214
+ /* @__PURE__ */ jsxs6("div", { style: defaultStyles.icons, children: [
1215
+ module.et.vs && (iconEthOn && iconEthOff ? module.et.on ? iconEthOn : iconEthOff : /* @__PURE__ */ jsx7(ConnectionIcon, { on: module.et.on, type: "eth" })),
1216
+ module.rs.vs && (iconRs232On && iconRs232Off ? module.rs.on ? iconRs232On : iconRs232Off : /* @__PURE__ */ jsx7(ConnectionIcon, { on: module.rs.on, type: "rs232" }))
1217
+ ] }),
1218
+ /* @__PURE__ */ jsxs6("div", { style: defaultStyles.buttons, children: [
1219
+ module.md.vs && /* @__PURE__ */ jsx7(
1220
+ CrisButton,
1221
+ {
1222
+ selected: module.md.on,
1223
+ text: "Mod",
1224
+ className: buttonClassName,
1225
+ classActive: buttonActiveClassName,
1226
+ onPress: () => onAction("toggleMod", module.id)
1227
+ }
1228
+ ),
1229
+ module.cm.vs && /* @__PURE__ */ jsx7(
1230
+ CrisButton,
1231
+ {
1232
+ selected: module.cm.on,
1233
+ text: "Com",
1234
+ className: buttonClassName,
1235
+ classActive: buttonActiveClassName,
1236
+ onPress: () => onAction("toggleCom", module.id)
1237
+ }
1238
+ )
1239
+ ] })
1240
+ ]
1241
+ }
1242
+ );
1243
+ }
1244
+ function CrisCoDebug({
1245
+ oid = "__DBG__",
1246
+ title,
1247
+ className,
1248
+ style,
1249
+ itemClassName,
1250
+ itemStyle,
1251
+ buttonClassName,
1252
+ buttonActiveClassName,
1253
+ iconEthOn,
1254
+ iconEthOff,
1255
+ iconRs232On,
1256
+ iconRs232Off
1257
+ }) {
1258
+ const modules = useCustomObject(oid);
1259
+ const send = useCustomObjectSend();
1260
+ const handleAction = (action, id) => {
1261
+ send(oid, { action, id });
1262
+ };
1263
+ if (!modules || modules.length === 0) {
1264
+ return null;
1265
+ }
1266
+ const visibleModules = modules.filter((m) => m.vs);
1267
+ return /* @__PURE__ */ jsxs6(
1268
+ "div",
1269
+ {
1270
+ className,
1271
+ style: className ? style : { ...defaultStyles.container, ...style },
1272
+ children: [
1273
+ title && /* @__PURE__ */ jsx7("div", { style: defaultStyles.title, children: title }),
1274
+ visibleModules.map((module) => /* @__PURE__ */ jsx7(
1275
+ DebugModuleItem,
1276
+ {
1277
+ module,
1278
+ onAction: handleAction,
1279
+ itemClassName,
1280
+ itemStyle,
1281
+ buttonClassName,
1282
+ buttonActiveClassName,
1283
+ iconEthOn,
1284
+ iconEthOff,
1285
+ iconRs232On,
1286
+ iconRs232Off
1287
+ },
1288
+ module.id
1289
+ ))
1290
+ ]
1291
+ }
1292
+ );
1293
+ }
1106
1294
  export {
1107
1295
  CrisButton,
1296
+ CrisCoDebug,
1108
1297
  CrisGauge,
1109
1298
  CrisOfflinePage,
1110
1299
  CrisSlider,