@multiplatform.one/components 10.2.0 → 10.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/cjs/views/Gantt.cjs +54 -37
  2. package/dist/cjs/views/Gantt.native.cjs +45 -30
  3. package/dist/cjs/views/Gantt.native.js +45 -30
  4. package/dist/cjs/views/Gantt.native.js.map +1 -1
  5. package/dist/cjs/views/GanttDateGrip.cjs +3 -3
  6. package/dist/cjs/views/GanttDateGrip.native.cjs +3 -3
  7. package/dist/cjs/views/GanttDateGrip.native.js +3 -3
  8. package/dist/cjs/views/GanttDateGrip.native.js.map +1 -1
  9. package/dist/cjs/views/eventTint.cjs +16 -4
  10. package/dist/cjs/views/eventTint.native.cjs +17 -4
  11. package/dist/cjs/views/eventTint.native.js +17 -4
  12. package/dist/cjs/views/eventTint.native.js.map +1 -1
  13. package/dist/cjs/views/ganttMath.cjs +10 -0
  14. package/dist/cjs/views/ganttMath.native.cjs +10 -0
  15. package/dist/cjs/views/ganttMath.native.js +10 -0
  16. package/dist/cjs/views/ganttMath.native.js.map +1 -1
  17. package/dist/cjs/views/index.cjs +3 -0
  18. package/dist/cjs/views/index.native.cjs +3 -0
  19. package/dist/cjs/views/index.native.js +3 -0
  20. package/dist/cjs/views/index.native.js.map +1 -1
  21. package/dist/esm/views/Gantt.mjs +58 -41
  22. package/dist/esm/views/Gantt.mjs.map +1 -1
  23. package/dist/esm/views/Gantt.native.js +49 -34
  24. package/dist/esm/views/Gantt.native.js.map +1 -1
  25. package/dist/esm/views/GanttDateGrip.mjs +3 -3
  26. package/dist/esm/views/GanttDateGrip.mjs.map +1 -1
  27. package/dist/esm/views/GanttDateGrip.native.js +3 -3
  28. package/dist/esm/views/GanttDateGrip.native.js.map +1 -1
  29. package/dist/esm/views/eventTint.mjs +15 -5
  30. package/dist/esm/views/eventTint.mjs.map +1 -1
  31. package/dist/esm/views/eventTint.native.js +16 -5
  32. package/dist/esm/views/eventTint.native.js.map +1 -1
  33. package/dist/esm/views/ganttMath.mjs +8 -1
  34. package/dist/esm/views/ganttMath.mjs.map +1 -1
  35. package/dist/esm/views/ganttMath.native.js +8 -1
  36. package/dist/esm/views/ganttMath.native.js.map +1 -1
  37. package/dist/esm/views/index.mjs +2 -2
  38. package/dist/esm/views/index.native.js +2 -2
  39. package/dist/jsx/views/Gantt.mjs +58 -41
  40. package/dist/jsx/views/Gantt.mjs.map +1 -1
  41. package/dist/jsx/views/Gantt.native.cjs +45 -30
  42. package/dist/jsx/views/Gantt.native.js +45 -30
  43. package/dist/jsx/views/Gantt.native.js.map +1 -1
  44. package/dist/jsx/views/GanttDateGrip.mjs +3 -3
  45. package/dist/jsx/views/GanttDateGrip.mjs.map +1 -1
  46. package/dist/jsx/views/GanttDateGrip.native.cjs +3 -3
  47. package/dist/jsx/views/GanttDateGrip.native.js +3 -3
  48. package/dist/jsx/views/GanttDateGrip.native.js.map +1 -1
  49. package/dist/jsx/views/eventTint.mjs +15 -5
  50. package/dist/jsx/views/eventTint.mjs.map +1 -1
  51. package/dist/jsx/views/eventTint.native.cjs +17 -4
  52. package/dist/jsx/views/eventTint.native.js +17 -4
  53. package/dist/jsx/views/eventTint.native.js.map +1 -1
  54. package/dist/jsx/views/ganttMath.mjs +8 -1
  55. package/dist/jsx/views/ganttMath.mjs.map +1 -1
  56. package/dist/jsx/views/ganttMath.native.cjs +10 -0
  57. package/dist/jsx/views/ganttMath.native.js +10 -0
  58. package/dist/jsx/views/ganttMath.native.js.map +1 -1
  59. package/dist/jsx/views/index.mjs +2 -2
  60. package/dist/jsx/views/index.native.cjs +3 -0
  61. package/dist/jsx/views/index.native.js +3 -0
  62. package/dist/jsx/views/index.native.js.map +1 -1
  63. package/package.json +7 -7
  64. package/src/views/Gantt.barInk.spec.tsx +149 -21
  65. package/src/views/Gantt.grips.spec.tsx +21 -4
  66. package/src/views/Gantt.phone.spec.tsx +205 -0
  67. package/src/views/Gantt.spec.tsx +15 -2
  68. package/src/views/Gantt.tint.palette.spec.ts +14 -7
  69. package/src/views/Gantt.tsx +144 -101
  70. package/src/views/GanttDateGrip.tsx +4 -4
  71. package/src/views/eventTint.ts +23 -4
  72. package/src/views/ganttMath.ts +26 -0
  73. package/src/views/index.ts +3 -0
  74. package/types/views/Gantt.d.ts.map +1 -1
  75. package/types/views/eventTint.d.ts +5 -2
  76. package/types/views/eventTint.d.ts.map +1 -1
  77. package/types/views/ganttMath.d.ts +14 -0
  78. package/types/views/ganttMath.d.ts.map +1 -1
  79. package/types/views/index.d.ts +1 -1
  80. package/types/views/index.d.ts.map +1 -1
@@ -205,11 +205,11 @@ function BarIntentWrap(param) {
205
205
  children
206
206
  });
207
207
  }
208
+ var MONTH_LABEL_MIN_PX = 36;
208
209
  var STRIP_INSET_PX = 4;
209
- var STRIP_BOTTOM_PX = 2;
210
210
  var STRIP_TRACK_OPACITY = .3;
211
211
  function GanttBarLabel(param) {
212
- var { title, fill, state, surface, dark } = param;
212
+ var { title, fill, state, surface, dark, stripBand } = param;
213
213
  var _ref;
214
214
  var { knobProps } = (0, import_theme.useResolvedKnobs)();
215
215
  var theme = (0, import_tamagui2.useTheme)();
@@ -223,6 +223,7 @@ function GanttBarLabel(param) {
223
223
  ...knobProps.label,
224
224
  numberOfLines: 1,
225
225
  paddingHorizontal: knobProps.control.paddingHorizontal,
226
+ marginBottom: stripBand,
226
227
  pointerEvents: "none",
227
228
  zIndex: 1,
228
229
  "aria-hidden": true,
@@ -295,20 +296,20 @@ function GanttIntervalFill(param) {
295
296
  [`data-gantt-open-${edge}`]: "true"
296
297
  }, edge);
297
298
  }),
298
- solid && progress != null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
299
+ strip && progress != null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
299
300
  position: "absolute",
300
- bottom: STRIP_BOTTOM_PX,
301
+ bottom: import_eventTint.EVENT_STRIP_BOTTOM_PX,
301
302
  height: import_eventTint.EVENT_BAR_PX,
302
303
  ...rtl ? { right: stripStart } : { left: stripStart },
303
304
  width: Math.max(0, width - stripStart - STRIP_INSET_PX),
304
305
  borderRadius: import_eventTint.EVENT_BAR_PX / 2,
305
- backgroundColor: solid.ink,
306
+ backgroundColor: strip,
306
307
  opacity: STRIP_TRACK_OPACITY,
307
- "data-gantt-progress-track": solid.ink
308
+ "data-gantt-progress-track": strip
308
309
  }),
309
310
  stripWidth > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
310
311
  position: "absolute",
311
- bottom: STRIP_BOTTOM_PX,
312
+ bottom: import_eventTint.EVENT_STRIP_BOTTOM_PX,
312
313
  height: import_eventTint.EVENT_BAR_PX,
313
314
  ...rtl ? { right: stripStart } : { left: stripStart },
314
315
  width: stripWidth,
@@ -346,6 +347,7 @@ function GanttView(param) {
346
347
  var canvasBackground = (_canvasTheme_background = canvasTheme.background) === null || _canvasTheme_background === void 0 ? void 0 : _canvasTheme_background.val;
347
348
  var canvasGround = typeof canvasBackground === "string" ? canvasBackground : void 0;
348
349
  var dark = (0, import_eventTint.useEventDark)();
350
+ var sizeClass = (0, import_theme.useLayoutSizeClass)();
349
351
  var { t } = (0, import_i18n.useTranslation)();
350
352
  var { knobProps } = (0, import_theme.useResolvedKnobs)();
351
353
  var [zoom, setZoom] = (0, import_react.useState)(initialZoom);
@@ -369,6 +371,10 @@ function GanttView(param) {
369
371
  var pxPerDay = controlHeight * (zoom === "day" ? 1.6 : zoom === "week" ? .6 : .2);
370
372
  var barInset = controlGap;
371
373
  var barHeight = rowHeight - barInset * 2;
374
+ var hasLabelColumn = sizeClass !== "compact";
375
+ var columnWidth = hasLabelColumn ? labelWidth : 0;
376
+ var labelPadding = Number(knobProps.control.paddingHorizontal);
377
+ var labelFontSize = (0, import_tamagui2.getFontSize)(String(knobProps.label.fontSize), { font: String(knobProps.label.fontFamily) });
372
378
  var railHeight = barHeight / 2;
373
379
  var transition = knobProps.motion.slide.transition;
374
380
  var webLayoutTransition = import_tamagui.isWeb ? transition : void 0;
@@ -465,7 +471,7 @@ function GanttView(param) {
465
471
  var viewportWidth = canvasViewportRef.current;
466
472
  if (viewportWidth === null) pendingAnchorRef.current = date;
467
473
  var x = (0, import_ganttMath.scrollAnchorX)(date, range.start, pxPerDay, {
468
- labelWidth,
474
+ labelWidth: columnWidth,
469
475
  chartWidth,
470
476
  viewportWidth,
471
477
  rtl
@@ -487,7 +493,7 @@ function GanttView(param) {
487
493
  }, [
488
494
  range.start,
489
495
  pxPerDay,
490
- labelWidth,
496
+ columnWidth,
491
497
  rtl,
492
498
  chartWidth
493
499
  ]);
@@ -1080,18 +1086,21 @@ function GanttView(param) {
1080
1086
  var barTitle = (_span_title = span.title) !== null && _span_title !== void 0 ? _span_title : task.title;
1081
1087
  var fill = barColor !== null && barColor !== void 0 ? barColor : barIntent && barIntent !== "accent" ? "$color-9" : identity;
1082
1088
  var progress = bounded && !ghost ? clampProgress((_span_progress = span.progress) !== null && _span_progress !== void 0 ? _span_progress : task.progress) : null;
1083
- var showLabel = !geom.eternal && liveWidth >= 44;
1084
- var labelOutside = !showLabel && !geom.eternal && !ghost && resolveSpans(task).length === 1;
1089
+ var fitsLabel = (0, import_ganttMath.labelFitsBar)(barTitle, liveWidth, labelPadding, labelFontSize);
1090
+ var carriesOutside = !geom.eternal && !ghost && resolveSpans(task).length === 1;
1091
+ var labelReadsInside = liveWidth >= 44 && (fitsLabel || !carriesOutside);
1092
+ var showLabel = (!geom.eternal || !hasLabelColumn) && labelReadsInside;
1093
+ var labelOutside = carriesOutside && !labelReadsInside;
1085
1094
  var isBarFocused = focusedBarId === barKey;
1086
1095
  var showHandles = hoveredId === task.id || sessionLive || isBarFocused;
1087
- var barState = ghost ? "ghost" : showHandles || geom.eternal ? "selected" : "rest";
1096
+ var barState = ghost ? "ghost" : showHandles ? "selected" : "rest";
1088
1097
  var handleWidth = bounded ? geom.width >= 24 ? 8 : geom.width >= 12 ? 4 : 0 : 0;
1089
1098
  var physicalLeftEdge = rtl ? "end" : "start";
1090
1099
  var physicalRightEdge = rtl ? "start" : "end";
1091
1100
  var logicalLeft = geom.x + liveTransformX * dirSign;
1092
1101
  var gripShift = function gripShift2(edge) {
1093
- var at = edge === "start" ? logicalLeft : logicalLeft + liveWidth;
1094
- var inside = Math.max(visibleWindow.start + import_eventTint.EVENT_GRIP_DOT_PX / 2, Math.min(at, visibleWindow.end - import_eventTint.EVENT_GRIP_DOT_PX / 2));
1102
+ var at = edge === "start" ? logicalLeft : logicalLeft + liveWidth - import_eventTint.EVENT_GRIP_DOT_PX;
1103
+ var inside = Math.max(visibleWindow.start, Math.min(at, visibleWindow.end - import_eventTint.EVENT_GRIP_DOT_PX));
1095
1104
  return (inside - at) * dirSign;
1096
1105
  };
1097
1106
  var squareStart = rtl ? {
@@ -1223,7 +1232,8 @@ function GanttView(param) {
1223
1232
  fill,
1224
1233
  state: barState,
1225
1234
  surface: canvasGround,
1226
- dark
1235
+ dark,
1236
+ stripBand: progress != null ? import_eventTint.EVENT_STRIP_BAND_PX : 0
1227
1237
  }),
1228
1238
  labelOutside && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
1229
1239
  position: "absolute",
@@ -1274,8 +1284,8 @@ function GanttView(param) {
1274
1284
  },
1275
1285
  "data-gantt-resize-handle": physicalLeftEdge,
1276
1286
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_GanttGripDot.GanttGripDot, {
1277
- left: gripShift(physicalLeftEdge) - import_eventTint.EVENT_GRIP_DOT_PX / 2,
1278
- top: (physicalLeftEdge === "start" ? height2 : 0) - import_eventTint.EVENT_GRIP_DOT_PX / 2,
1287
+ left: gripShift(physicalLeftEdge),
1288
+ top: physicalLeftEdge === "start" ? height2 - import_eventTint.EVENT_GRIP_DOT_PX : 0,
1279
1289
  color: fill,
1280
1290
  shown: showHandles,
1281
1291
  edge: physicalLeftEdge
@@ -1292,8 +1302,8 @@ function GanttView(param) {
1292
1302
  },
1293
1303
  "data-gantt-resize-handle": physicalRightEdge,
1294
1304
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_GanttGripDot.GanttGripDot, {
1295
- left: handleWidth + gripShift(physicalRightEdge) - import_eventTint.EVENT_GRIP_DOT_PX / 2,
1296
- top: (physicalRightEdge === "start" ? height2 : 0) - import_eventTint.EVENT_GRIP_DOT_PX / 2,
1305
+ left: handleWidth - import_eventTint.EVENT_GRIP_DOT_PX + gripShift(physicalRightEdge),
1306
+ top: physicalRightEdge === "start" ? height2 - import_eventTint.EVENT_GRIP_DOT_PX : 0,
1297
1307
  color: fill,
1298
1308
  shown: showHandles,
1299
1309
  edge: physicalRightEdge
@@ -1363,7 +1373,7 @@ function GanttView(param) {
1363
1373
  var showSkeleton = !error && isLoading && tasks.length === 0;
1364
1374
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_AsyncBoundary.AsyncBoundary, {
1365
1375
  loading: showSkeleton ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GanttSkeleton, {
1366
- labelWidth,
1376
+ labelWidth: columnWidth,
1367
1377
  rowHeight
1368
1378
  }) : false,
1369
1379
  empty: !error && !isLoading && tasks.length === 0,
@@ -1396,7 +1406,7 @@ function GanttView(param) {
1396
1406
  },
1397
1407
  children: t("Today")
1398
1408
  }),
1399
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.SizableText, {
1409
+ sizeClass === "compact" ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.SizableText, {
1400
1410
  ...import_componentColors.sectionHeading,
1401
1411
  ...knobProps.heading,
1402
1412
  numberOfLines: 1,
@@ -1428,8 +1438,8 @@ function GanttView(param) {
1428
1438
  ...import_theme.hairline.bottom,
1429
1439
  borderColor: "border-color",
1430
1440
  "data-gantt-axis-row": "true",
1431
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.XStack, {
1432
- width: labelWidth,
1441
+ children: [hasLabelColumn ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.XStack, {
1442
+ width: columnWidth,
1433
1443
  flexShrink: 0,
1434
1444
  height: axisHeight,
1435
1445
  alignItems: "center",
@@ -1443,7 +1453,7 @@ function GanttView(param) {
1443
1453
  numberOfLines: 1,
1444
1454
  children: t("Task")
1445
1455
  })
1446
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ScrollView.ScrollView, {
1456
+ }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ScrollView.ScrollView, {
1447
1457
  ref: axisScrollRef,
1448
1458
  horizontal: true,
1449
1459
  flex: 1,
@@ -1480,14 +1490,19 @@ function GanttView(param) {
1480
1490
  pointerEvents: "none"
1481
1491
  }),
1482
1492
  months.map(function(band) {
1483
- return band.width < 36 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Text, {
1493
+ var bandEnd = band.x + band.width;
1494
+ var shown = Math.min(bandEnd, visibleWindow.end) - Math.max(band.x, visibleWindow.start);
1495
+ if (shown < MONTH_LABEL_MIN_PX) return null;
1496
+ var x = Math.min(Math.max(band.x, visibleWindow.start), bandEnd - MONTH_LABEL_MIN_PX);
1497
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.Text, {
1484
1498
  position: "absolute",
1485
- ...rtl ? { right: band.x + 4 } : { left: band.x + 4 },
1499
+ ...rtl ? { right: x + 4 } : { left: x + 4 },
1486
1500
  top: 2,
1487
- width: Math.max(0, band.width - 8),
1501
+ width: Math.max(0, bandEnd - x - 8),
1488
1502
  ...knobProps.label,
1489
1503
  color: knobProps.textAccentColor,
1490
1504
  numberOfLines: 1,
1505
+ "data-gantt-month": band.key,
1491
1506
  children: band.label
1492
1507
  }, band.key);
1493
1508
  }),
@@ -1565,8 +1580,8 @@ function GanttView(param) {
1565
1580
  scrollEnabled: !scrollLocked,
1566
1581
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
1567
1582
  "data-gantt-scroll-body": "true",
1568
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
1569
- width: labelWidth,
1583
+ children: [hasLabelColumn ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
1584
+ width: columnWidth,
1570
1585
  flexShrink: 0,
1571
1586
  ...hairlineEnd,
1572
1587
  borderColor: "border-color",
@@ -1618,7 +1633,7 @@ function GanttView(param) {
1618
1633
  })
1619
1634
  }, task.id);
1620
1635
  })
1621
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CanvasScroller, {
1636
+ }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CanvasScroller, {
1622
1637
  keyboardShouldPersistTaps: "handled",
1623
1638
  ref: hScrollRef,
1624
1639
  horizontal: true,