@imperosoft/cris-webui-components 1.1.2-beta.12 → 1.1.2-beta.14

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.js CHANGED
@@ -137,6 +137,8 @@ function CrisButton({
137
137
  const pressedRef = (0, import_react.useRef)(false);
138
138
  const touchingRef = (0, import_react.useRef)(false);
139
139
  const touchStartedHereRef = (0, import_react.useRef)(false);
140
+ const touchStartYRef = (0, import_react.useRef)(0);
141
+ const touchMovedRef = (0, import_react.useRef)(false);
140
142
  const feedbackJoin = joinFeedback ?? join;
141
143
  const feedback = (0, import_cris_webui_ch5_core.useDigital)(feedbackJoin ?? 0);
142
144
  const enabledJoin = (0, import_cris_webui_ch5_core.useDigital)(joinEnable ?? 0);
@@ -219,22 +221,34 @@ function CrisButton({
219
221
  dSet(join, false);
220
222
  }
221
223
  };
222
- const handleTouchStart = () => {
224
+ const SCROLL_THRESHOLD = 8;
225
+ const handleTouchStart = (e) => {
223
226
  log("handleTouchStart");
224
227
  touchStart();
225
228
  touchingRef.current = true;
226
229
  touchStartedHereRef.current = true;
230
+ touchMovedRef.current = false;
231
+ touchStartYRef.current = e.touches[0]?.clientY ?? 0;
232
+ };
233
+ const handleTouchMove = (e) => {
234
+ if (touchMovedRef.current) return;
235
+ const dy = Math.abs((e.touches[0]?.clientY ?? 0) - touchStartYRef.current);
236
+ if (dy > SCROLL_THRESHOLD) {
237
+ touchMovedRef.current = true;
238
+ log("touchMove: scroll detected, dy:", dy);
239
+ }
227
240
  };
228
241
  const handleTouchEnd = () => {
229
- log("handleTouchEnd", { touchStartedHereRef: touchStartedHereRef.current });
242
+ log("handleTouchEnd", { touchStartedHere: touchStartedHereRef.current, moved: touchMovedRef.current });
230
243
  touchEnd();
231
244
  touchingRef.current = true;
232
- if (touchStartedHereRef.current) {
245
+ if (touchStartedHereRef.current && !touchMovedRef.current) {
233
246
  touchStartedHereRef.current = false;
234
247
  handlePress();
235
248
  handleRelease();
236
249
  } else {
237
- log("SKIPPED: touch did not start here");
250
+ touchStartedHereRef.current = false;
251
+ log("SKIPPED: touch moved or did not start here");
238
252
  }
239
253
  };
240
254
  const handleTouchCancel = () => {
@@ -242,6 +256,7 @@ function CrisButton({
242
256
  touchEnd();
243
257
  touchingRef.current = true;
244
258
  touchStartedHereRef.current = false;
259
+ touchMovedRef.current = false;
245
260
  };
246
261
  const handleMouseDown = () => {
247
262
  if (isTouchActive() || touchingRef.current) return;
@@ -342,7 +357,7 @@ function CrisButton({
342
357
  cursor: suppressKeyClicks ? "default" : "pointer",
343
358
  position: isFreePositioned ? void 0 : "relative",
344
359
  overflow: isFreePositioned ? void 0 : "hidden",
345
- touchAction: "pan-y",
360
+ touchAction: "pan-x pan-y",
346
361
  userSelect: "none",
347
362
  WebkitUserSelect: "none"
348
363
  },
@@ -350,6 +365,7 @@ function CrisButton({
350
365
  onMouseUp: handleMouseUp,
351
366
  onMouseLeave: handleMouseLeave,
352
367
  onTouchStart: handleTouchStart,
368
+ onTouchMove: handleTouchMove,
353
369
  onTouchEnd: handleTouchEnd,
354
370
  onTouchCancel: handleTouchCancel,
355
371
  children: [
@@ -1331,12 +1347,25 @@ function CrisCoDebug({
1331
1347
  // src/components/CrisCoMatrixListsTie.tsx
1332
1348
  var import_cris_webui_ch5_core8 = require("@imperosoft/cris-webui-ch5-core");
1333
1349
  var import_jsx_runtime8 = require("react/jsx-runtime");
1350
+ var colors = {
1351
+ itemBg: "#4f5152",
1352
+ itemActiveBg: "#007ca0",
1353
+ vmActiveBg: "#dc2626",
1354
+ text: "#ffffff",
1355
+ headerText: "#6b7280",
1356
+ ioOn: "#4caf50",
1357
+ ioOff: "#f44336",
1358
+ sgOn: "#2196f3",
1359
+ sgOff: "#666666"
1360
+ };
1334
1361
  var defaults = {
1335
1362
  container: {
1336
1363
  display: "flex",
1337
1364
  flexDirection: "row",
1338
- gap: 8,
1339
- height: "100%"
1365
+ gap: "1.5rem",
1366
+ padding: "1rem 2rem",
1367
+ height: "100%",
1368
+ width: "100%"
1340
1369
  },
1341
1370
  list: {
1342
1371
  flex: 1,
@@ -1346,57 +1375,125 @@ var defaults = {
1346
1375
  minHeight: 0
1347
1376
  },
1348
1377
  header: {
1349
- fontSize: 13,
1350
- fontWeight: 600,
1351
- padding: "6px 10px",
1378
+ fontSize: "1.5em",
1379
+ fontWeight: 700,
1380
+ padding: "0.5rem 0.75rem",
1352
1381
  textTransform: "uppercase",
1353
- opacity: 0.6,
1354
- flexShrink: 0
1382
+ letterSpacing: "0.05em",
1383
+ color: colors.headerText,
1384
+ flexShrink: 0,
1385
+ textAlign: "center"
1355
1386
  },
1356
1387
  scroll: {
1357
1388
  flex: 1,
1358
1389
  minHeight: 0,
1359
1390
  overflow: "auto",
1391
+ scrollbarWidth: "none",
1360
1392
  WebkitOverflowScrolling: "touch",
1361
1393
  display: "flex",
1362
1394
  flexDirection: "column",
1363
- gap: 2
1395
+ gap: "0.15rem"
1364
1396
  },
1365
1397
  item: {
1366
1398
  display: "flex",
1367
- alignItems: "center",
1368
- gap: 6,
1369
- padding: "6px 10px",
1370
- minHeight: 40,
1399
+ alignItems: "stretch",
1400
+ gap: "0.5rem",
1401
+ padding: "0 0.4rem 0 0",
1402
+ minHeight: "3.7rem",
1371
1403
  cursor: "pointer",
1372
- userSelect: "none"
1404
+ userSelect: "none",
1405
+ background: colors.itemBg,
1406
+ borderRadius: "0.5rem",
1407
+ transition: "background 0.15s"
1408
+ },
1409
+ itemActive: {
1410
+ background: colors.itemActiveBg
1411
+ },
1412
+ itemBtn: {
1413
+ flex: 1,
1414
+ minWidth: 0,
1415
+ background: "transparent",
1416
+ border: "none",
1417
+ padding: "0.5rem 0.9rem",
1418
+ textAlign: "left",
1419
+ color: colors.text,
1420
+ height: "100%",
1421
+ borderRadius: "0.5rem",
1422
+ cursor: "pointer"
1423
+ },
1424
+ itemBtnInner: {
1425
+ display: "flex",
1426
+ alignItems: "center",
1427
+ gap: "0.4rem",
1428
+ width: "100%"
1429
+ },
1430
+ channelNum: {
1431
+ flexShrink: 0,
1432
+ opacity: 0.6,
1433
+ minWidth: "1.7em",
1434
+ textAlign: "right",
1435
+ fontWeight: 400,
1436
+ marginRight: "0.4em"
1373
1437
  },
1374
1438
  itemLabel: {
1375
1439
  flex: 1,
1376
- fontSize: 13,
1440
+ fontSize: "1.4em",
1441
+ fontWeight: 700,
1377
1442
  whiteSpace: "nowrap",
1378
1443
  overflow: "hidden",
1379
- textOverflow: "ellipsis"
1444
+ textOverflow: "ellipsis",
1445
+ color: colors.text
1380
1446
  },
1381
1447
  indicators: {
1382
1448
  display: "flex",
1383
- gap: 4,
1449
+ gap: "0.25rem",
1384
1450
  alignItems: "center"
1385
1451
  },
1386
1452
  indicator: {
1387
- width: 8,
1388
- height: 8,
1453
+ width: "1rem",
1454
+ height: "1rem",
1389
1455
  borderRadius: "50%",
1390
1456
  flexShrink: 0
1457
+ },
1458
+ vmBtn: {
1459
+ flexShrink: 0,
1460
+ alignSelf: "stretch",
1461
+ display: "flex",
1462
+ alignItems: "center",
1463
+ background: colors.itemBg,
1464
+ color: colors.text,
1465
+ border: "none",
1466
+ borderRadius: "0.4rem",
1467
+ padding: "0 0.6rem",
1468
+ margin: "0.3rem 0.3rem 0.3rem 0",
1469
+ fontSize: "0.85em",
1470
+ fontWeight: 700,
1471
+ cursor: "pointer",
1472
+ transition: "background 0.15s"
1473
+ },
1474
+ vmBtnActive: {
1475
+ background: colors.vmActiveBg,
1476
+ color: colors.text
1391
1477
  }
1392
1478
  };
1479
+ var SCROLLBAR_CSS = `
1480
+ .cris-co-matrix-scroll::-webkit-scrollbar { display: none; }
1481
+ `;
1482
+ var scrollbarStyleInjected = false;
1483
+ function injectScrollbarStyle() {
1484
+ if (scrollbarStyleInjected) return;
1485
+ scrollbarStyleInjected = true;
1486
+ const style = document.createElement("style");
1487
+ style.textContent = SCROLLBAR_CSS;
1488
+ document.head.appendChild(style);
1489
+ }
1393
1490
  function DefaultIoIndicator({ on }) {
1394
1491
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1395
1492
  "div",
1396
1493
  {
1397
1494
  style: {
1398
1495
  ...defaults.indicator,
1399
- backgroundColor: on ? "#4caf50" : "#f44336"
1496
+ backgroundColor: on ? colors.ioOn : colors.ioOff
1400
1497
  },
1401
1498
  title: on ? "Online" : "Offline"
1402
1499
  }
@@ -1408,7 +1505,7 @@ function DefaultSignalIndicator({ on }) {
1408
1505
  {
1409
1506
  style: {
1410
1507
  ...defaults.indicator,
1411
- backgroundColor: on ? "#2196f3" : "#666"
1508
+ backgroundColor: on ? colors.sgOn : colors.sgOff
1412
1509
  },
1413
1510
  title: on ? "Signal detected" : "No signal"
1414
1511
  }
@@ -1434,18 +1531,19 @@ function MatrixItemRow({
1434
1531
  }) {
1435
1532
  const isActive = active;
1436
1533
  const isEnabled = item.sl.en;
1534
+ const useDefaults = !itemClassName;
1437
1535
  const classes = [
1438
1536
  "cris-co-matrix-item",
1439
1537
  itemClassName,
1440
1538
  isActive && (itemActiveClassName || "active"),
1441
1539
  !isEnabled && (itemDisabledClassName || "disabled")
1442
1540
  ].filter(Boolean).join(" ");
1443
- const computedStyle = itemClassName ? { ...itemStyleProp } : {
1541
+ const computedStyle = useDefaults ? {
1444
1542
  ...defaults.item,
1445
1543
  ...itemStyleProp,
1446
- ...isActive ? itemActiveStyle : void 0,
1544
+ ...isActive ? { ...defaults.itemActive, ...itemActiveStyle } : void 0,
1447
1545
  opacity: isEnabled ? 1 : 0.4
1448
- };
1546
+ } : { ...itemStyleProp };
1449
1547
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: classes, style: computedStyle, children: [
1450
1548
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1451
1549
  CrisButton,
@@ -1453,19 +1551,40 @@ function MatrixItemRow({
1453
1551
  selected: isActive,
1454
1552
  enabled: isEnabled,
1455
1553
  onPress: onSelect,
1456
- className: `cris-co-matrix-item-btn ${itemActiveClassName ?? ""}`,
1457
- classActive: itemActiveClassName,
1458
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 6, width: "100%" }, children: [
1459
- showChannels && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "cris-co-matrix-ch", style: { flexShrink: 0, opacity: 0.6 }, children: item.id }),
1554
+ className: itemClassName ? `cris-co-matrix-item-btn ${itemActiveClassName ?? ""}` : void 0,
1555
+ classActive: itemClassName ? itemActiveClassName : void 0,
1556
+ children: useDefaults ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: defaults.itemBtnInner, children: [
1557
+ showChannels && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "cris-co-matrix-ch", style: defaults.channelNum, children: item.id }),
1460
1558
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: defaults.itemLabel, children: item.lb || `${type === "input" ? "Input" : "Output"} ${item.id}` }),
1461
1559
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: defaults.indicators, children: [
1462
1560
  item.io.vs && (renderIoIndicator ? renderIoIndicator(item.io.on) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DefaultIoIndicator, { on: item.io.on })),
1463
1561
  item.sg.vs && (renderSignalIndicator ? renderSignalIndicator(item.sg.on) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DefaultSignalIndicator, { on: item.sg.on }))
1464
1562
  ] })
1563
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "0.4rem", width: "100%" }, children: [
1564
+ showChannels && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "cris-co-matrix-ch", style: { flexShrink: 0, opacity: 0.6 }, children: item.id }),
1565
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: { flex: 1, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: item.lb || `${type === "input" ? "Input" : "Output"} ${item.id}` }),
1566
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: defaults.indicators, children: [
1567
+ item.io.vs && (renderIoIndicator ? renderIoIndicator(item.io.on) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DefaultIoIndicator, { on: item.io.on })),
1568
+ item.sg.vs && (renderSignalIndicator ? renderSignalIndicator(item.sg.on) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DefaultSignalIndicator, { on: item.sg.on }))
1569
+ ] })
1465
1570
  ] })
1466
1571
  }
1467
1572
  ),
1468
- item.vm.vs && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1573
+ item.vm.vs && (useDefaults && !vmButtonClassName ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
1574
+ ...defaults.vmBtn,
1575
+ ...item.vm.on ? defaults.vmBtnActive : void 0,
1576
+ opacity: item.vm.en ? 1 : 0.4,
1577
+ pointerEvents: item.vm.en ? "auto" : "none"
1578
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1579
+ CrisButton,
1580
+ {
1581
+ selected: item.vm.on,
1582
+ enabled: item.vm.en,
1583
+ text: vmText,
1584
+ onPress: onToggleVideoMute,
1585
+ showLocalFeedback: false
1586
+ }
1587
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1469
1588
  CrisButton,
1470
1589
  {
1471
1590
  selected: item.vm.on,
@@ -1475,7 +1594,7 @@ function MatrixItemRow({
1475
1594
  className: vmButtonClassName,
1476
1595
  classActive: vmButtonActiveClassName
1477
1596
  }
1478
- )
1597
+ ))
1479
1598
  ] });
1480
1599
  }
1481
1600
  function CrisCoMatrixListsTie({
@@ -1502,6 +1621,7 @@ function CrisCoMatrixListsTie({
1502
1621
  }) {
1503
1622
  const matrix = (0, import_cris_webui_ch5_core8.useCustomObject)(oid);
1504
1623
  const send = (0, import_cris_webui_ch5_core8.useCustomObjectSend)();
1624
+ injectScrollbarStyle();
1505
1625
  if (!matrix) return null;
1506
1626
  const { si, ip: inputs, op: outputs } = matrix;
1507
1627
  const handleSelectInput = (id) => {
@@ -1533,7 +1653,7 @@ function CrisCoMatrixListsTie({
1533
1653
  children: inputTitle
1534
1654
  }
1535
1655
  ),
1536
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: defaults.scroll, children: inputs?.map((item) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1656
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "cris-co-matrix-scroll", style: defaults.scroll, children: inputs?.map((item) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1537
1657
  MatrixItemRow,
1538
1658
  {
1539
1659
  item,
@@ -1572,7 +1692,7 @@ function CrisCoMatrixListsTie({
1572
1692
  children: outputTitle
1573
1693
  }
1574
1694
  ),
1575
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: defaults.scroll, children: outputs?.map((item) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1695
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "cris-co-matrix-scroll", style: defaults.scroll, children: outputs?.map((item) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1576
1696
  MatrixItemRow,
1577
1697
  {
1578
1698
  item,