@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
@@ -1,5 +1,5 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { Intent, MIN_PRESS_TARGET, ensureKeyboardModalityTracking, formatAbsoluteDate, formatDayOfMonth, formatMonthYear, hairline, hairlineWidth, keyboardFocusRingProps, transitionProps, useChartPalette, useResolvedKnobs, wasKeyboardFocus } from "@multiplatform.one/theme";
2
+ import { Intent, MIN_PRESS_TARGET, ensureKeyboardModalityTracking, formatAbsoluteDate, formatDayOfMonth, formatMonthYear, hairline, hairlineWidth, keyboardFocusRingProps, transitionProps, useChartPalette, useLayoutSizeClass, useResolvedKnobs, wasKeyboardFocus } from "@multiplatform.one/theme";
3
3
  import { componentColors, sectionHeading } from "../componentColors.native.js";
4
4
  import { AsyncBoundary } from "../layouts/AsyncBoundary.native.js";
5
5
  import { Skeleton } from "../Skeleton/index.native.js";
@@ -10,15 +10,15 @@ import { Button } from "@multiplatform.one/forms";
10
10
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
11
11
  import { useTranslation } from "../shared/i18n.native.js";
12
12
  import { ScrollView } from "react-native";
13
- import { SizableText, Text, XStack, YStack, getTokenValue, isWeb, useTheme } from "tamagui";
13
+ import { SizableText, Text, XStack, YStack, getFontSize, getTokenValue, isWeb, useTheme } from "tamagui";
14
14
  import { ScrollView as ScrollView$1 } from "../ScrollView.native.js";
15
15
  import { LinearGradient } from "tamagui/linear-gradient";
16
16
  import { normalizeColor } from "@tamagui/core";
17
17
  import { GanttDateGrip } from "./GanttDateGrip.native.js";
18
18
  import { GanttGripDot } from "./GanttGripDot.native.js";
19
- import { EVENT_BAR_PX, EVENT_GRIP_DOT_PX, eventLabelInk, eventPaint, eventSolid, eventStripPaint, useEventDark } from "./eventTint.native.js";
19
+ import { EVENT_BAR_PX, EVENT_GRIP_DOT_PX, EVENT_STRIP_BAND_PX, EVENT_STRIP_BOTTOM_PX, eventLabelInk, eventPaint, eventSolid, eventStripPaint, useEventDark } from "./eventTint.native.js";
20
20
  import { intervalEdgeX, intervalViewport } from "./ganttIntervals.native.js";
21
- import { addDays, barGeometry, clampResizeDayDelta, computeGanttRange, dateLineX, dateToX, dayDiff, dxToDayDelta, formatRangeLabel, formatSpanLabel, ganttTaskAccessibleLabel, generateTicks, isBoundedSpan, openBarGeometry, openSpanExtents, openSpanLabelParts, rangeDays, resizeSpanByDays, scrollAnchorX, shiftSpanByDays, spanInclusiveDays, startOfDay, todayLineX } from "./ganttMath.native.js";
21
+ import { addDays, barGeometry, clampResizeDayDelta, computeGanttRange, dateLineX, dateToX, dayDiff, dxToDayDelta, formatRangeLabel, formatSpanLabel, ganttTaskAccessibleLabel, generateTicks, isBoundedSpan, labelFitsBar, openBarGeometry, openSpanExtents, openSpanLabelParts, rangeDays, resizeSpanByDays, scrollAnchorX, shiftSpanByDays, spanInclusiveDays, startOfDay, todayLineX } from "./ganttMath.native.js";
22
22
  import { Text as Text$1 } from "../Text.native.js";
23
23
 
24
24
  var CanvasScroller = isWeb ? ScrollView$1 : ScrollView;
@@ -174,11 +174,11 @@ function BarIntentWrap(param) {
174
174
  children
175
175
  });
176
176
  }
177
+ var MONTH_LABEL_MIN_PX = 36;
177
178
  var STRIP_INSET_PX = 4;
178
- var STRIP_BOTTOM_PX = 2;
179
179
  var STRIP_TRACK_OPACITY = .3;
180
180
  function GanttBarLabel(param) {
181
- var { title, fill, state, surface, dark } = param;
181
+ var { title, fill, state, surface, dark, stripBand } = param;
182
182
  var _ref;
183
183
  var { knobProps } = useResolvedKnobs();
184
184
  var theme = useTheme();
@@ -192,6 +192,7 @@ function GanttBarLabel(param) {
192
192
  ...knobProps.label,
193
193
  numberOfLines: 1,
194
194
  paddingHorizontal: knobProps.control.paddingHorizontal,
195
+ marginBottom: stripBand,
195
196
  pointerEvents: "none",
196
197
  zIndex: 1,
197
198
  "aria-hidden": true,
@@ -264,20 +265,20 @@ function GanttIntervalFill(param) {
264
265
  [`data-gantt-open-${edge}`]: "true"
265
266
  }, edge);
266
267
  }),
267
- solid && progress != null && /* @__PURE__ */ jsx(YStack, {
268
+ strip && progress != null && /* @__PURE__ */ jsx(YStack, {
268
269
  position: "absolute",
269
- bottom: STRIP_BOTTOM_PX,
270
+ bottom: EVENT_STRIP_BOTTOM_PX,
270
271
  height: EVENT_BAR_PX,
271
272
  ...rtl ? { right: stripStart } : { left: stripStart },
272
273
  width: Math.max(0, width - stripStart - STRIP_INSET_PX),
273
274
  borderRadius: EVENT_BAR_PX / 2,
274
- backgroundColor: solid.ink,
275
+ backgroundColor: strip,
275
276
  opacity: STRIP_TRACK_OPACITY,
276
- "data-gantt-progress-track": solid.ink
277
+ "data-gantt-progress-track": strip
277
278
  }),
278
279
  stripWidth > 0 && /* @__PURE__ */ jsx(YStack, {
279
280
  position: "absolute",
280
- bottom: STRIP_BOTTOM_PX,
281
+ bottom: EVENT_STRIP_BOTTOM_PX,
281
282
  height: EVENT_BAR_PX,
282
283
  ...rtl ? { right: stripStart } : { left: stripStart },
283
284
  width: stripWidth,
@@ -315,6 +316,7 @@ function GanttView(param) {
315
316
  var canvasBackground = (_canvasTheme_background = canvasTheme.background) === null || _canvasTheme_background === void 0 ? void 0 : _canvasTheme_background.val;
316
317
  var canvasGround = typeof canvasBackground === "string" ? canvasBackground : void 0;
317
318
  var dark = useEventDark();
319
+ var sizeClass = useLayoutSizeClass();
318
320
  var { t } = useTranslation();
319
321
  var { knobProps } = useResolvedKnobs();
320
322
  var [zoom, setZoom] = useState(initialZoom);
@@ -338,6 +340,10 @@ function GanttView(param) {
338
340
  var pxPerDay = controlHeight * (zoom === "day" ? 1.6 : zoom === "week" ? .6 : .2);
339
341
  var barInset = controlGap;
340
342
  var barHeight = rowHeight - barInset * 2;
343
+ var hasLabelColumn = sizeClass !== "compact";
344
+ var columnWidth = hasLabelColumn ? labelWidth : 0;
345
+ var labelPadding = Number(knobProps.control.paddingHorizontal);
346
+ var labelFontSize = getFontSize(String(knobProps.label.fontSize), { font: String(knobProps.label.fontFamily) });
341
347
  var railHeight = barHeight / 2;
342
348
  var transition = knobProps.motion.slide.transition;
343
349
  var webLayoutTransition = isWeb ? transition : void 0;
@@ -434,7 +440,7 @@ function GanttView(param) {
434
440
  var viewportWidth = canvasViewportRef.current;
435
441
  if (viewportWidth === null) pendingAnchorRef.current = date;
436
442
  var x = scrollAnchorX(date, range.start, pxPerDay, {
437
- labelWidth,
443
+ labelWidth: columnWidth,
438
444
  chartWidth,
439
445
  viewportWidth,
440
446
  rtl
@@ -456,7 +462,7 @@ function GanttView(param) {
456
462
  }, [
457
463
  range.start,
458
464
  pxPerDay,
459
- labelWidth,
465
+ columnWidth,
460
466
  rtl,
461
467
  chartWidth
462
468
  ]);
@@ -1049,18 +1055,21 @@ function GanttView(param) {
1049
1055
  var barTitle = (_span_title = span.title) !== null && _span_title !== void 0 ? _span_title : task.title;
1050
1056
  var fill = barColor !== null && barColor !== void 0 ? barColor : barIntent && barIntent !== "accent" ? "$color-9" : identity;
1051
1057
  var progress = bounded && !ghost ? clampProgress((_span_progress = span.progress) !== null && _span_progress !== void 0 ? _span_progress : task.progress) : null;
1052
- var showLabel = !geom.eternal && liveWidth >= 44;
1053
- var labelOutside = !showLabel && !geom.eternal && !ghost && resolveSpans(task).length === 1;
1058
+ var fitsLabel = labelFitsBar(barTitle, liveWidth, labelPadding, labelFontSize);
1059
+ var carriesOutside = !geom.eternal && !ghost && resolveSpans(task).length === 1;
1060
+ var labelReadsInside = liveWidth >= 44 && (fitsLabel || !carriesOutside);
1061
+ var showLabel = (!geom.eternal || !hasLabelColumn) && labelReadsInside;
1062
+ var labelOutside = carriesOutside && !labelReadsInside;
1054
1063
  var isBarFocused = focusedBarId === barKey;
1055
1064
  var showHandles = hoveredId === task.id || sessionLive || isBarFocused;
1056
- var barState = ghost ? "ghost" : showHandles || geom.eternal ? "selected" : "rest";
1065
+ var barState = ghost ? "ghost" : showHandles ? "selected" : "rest";
1057
1066
  var handleWidth = bounded ? geom.width >= 24 ? 8 : geom.width >= 12 ? 4 : 0 : 0;
1058
1067
  var physicalLeftEdge = rtl ? "end" : "start";
1059
1068
  var physicalRightEdge = rtl ? "start" : "end";
1060
1069
  var logicalLeft = geom.x + liveTransformX * dirSign;
1061
1070
  var gripShift = function gripShift2(edge) {
1062
- var at = edge === "start" ? logicalLeft : logicalLeft + liveWidth;
1063
- var inside = Math.max(visibleWindow.start + EVENT_GRIP_DOT_PX / 2, Math.min(at, visibleWindow.end - EVENT_GRIP_DOT_PX / 2));
1071
+ var at = edge === "start" ? logicalLeft : logicalLeft + liveWidth - EVENT_GRIP_DOT_PX;
1072
+ var inside = Math.max(visibleWindow.start, Math.min(at, visibleWindow.end - EVENT_GRIP_DOT_PX));
1064
1073
  return (inside - at) * dirSign;
1065
1074
  };
1066
1075
  var squareStart = rtl ? {
@@ -1192,7 +1201,8 @@ function GanttView(param) {
1192
1201
  fill,
1193
1202
  state: barState,
1194
1203
  surface: canvasGround,
1195
- dark
1204
+ dark,
1205
+ stripBand: progress != null ? EVENT_STRIP_BAND_PX : 0
1196
1206
  }),
1197
1207
  labelOutside && /* @__PURE__ */ jsx(YStack, {
1198
1208
  position: "absolute",
@@ -1243,8 +1253,8 @@ function GanttView(param) {
1243
1253
  },
1244
1254
  "data-gantt-resize-handle": physicalLeftEdge,
1245
1255
  children: /* @__PURE__ */ jsx(GanttGripDot, {
1246
- left: gripShift(physicalLeftEdge) - EVENT_GRIP_DOT_PX / 2,
1247
- top: (physicalLeftEdge === "start" ? height2 : 0) - EVENT_GRIP_DOT_PX / 2,
1256
+ left: gripShift(physicalLeftEdge),
1257
+ top: physicalLeftEdge === "start" ? height2 - EVENT_GRIP_DOT_PX : 0,
1248
1258
  color: fill,
1249
1259
  shown: showHandles,
1250
1260
  edge: physicalLeftEdge
@@ -1261,8 +1271,8 @@ function GanttView(param) {
1261
1271
  },
1262
1272
  "data-gantt-resize-handle": physicalRightEdge,
1263
1273
  children: /* @__PURE__ */ jsx(GanttGripDot, {
1264
- left: handleWidth + gripShift(physicalRightEdge) - EVENT_GRIP_DOT_PX / 2,
1265
- top: (physicalRightEdge === "start" ? height2 : 0) - EVENT_GRIP_DOT_PX / 2,
1274
+ left: handleWidth - EVENT_GRIP_DOT_PX + gripShift(physicalRightEdge),
1275
+ top: physicalRightEdge === "start" ? height2 - EVENT_GRIP_DOT_PX : 0,
1266
1276
  color: fill,
1267
1277
  shown: showHandles,
1268
1278
  edge: physicalRightEdge
@@ -1332,7 +1342,7 @@ function GanttView(param) {
1332
1342
  var showSkeleton = !error && isLoading && tasks.length === 0;
1333
1343
  return /* @__PURE__ */ jsx(AsyncBoundary, {
1334
1344
  loading: showSkeleton ? /* @__PURE__ */ jsx(GanttSkeleton, {
1335
- labelWidth,
1345
+ labelWidth: columnWidth,
1336
1346
  rowHeight
1337
1347
  }) : false,
1338
1348
  empty: !error && !isLoading && tasks.length === 0,
@@ -1365,7 +1375,7 @@ function GanttView(param) {
1365
1375
  },
1366
1376
  children: t("Today")
1367
1377
  }),
1368
- /* @__PURE__ */ jsx(SizableText, {
1378
+ sizeClass === "compact" ? null : /* @__PURE__ */ jsx(SizableText, {
1369
1379
  ...sectionHeading,
1370
1380
  ...knobProps.heading,
1371
1381
  numberOfLines: 1,
@@ -1397,8 +1407,8 @@ function GanttView(param) {
1397
1407
  ...hairline.bottom,
1398
1408
  borderColor: "border-color",
1399
1409
  "data-gantt-axis-row": "true",
1400
- children: [/* @__PURE__ */ jsx(XStack, {
1401
- width: labelWidth,
1410
+ children: [hasLabelColumn ? /* @__PURE__ */ jsx(XStack, {
1411
+ width: columnWidth,
1402
1412
  flexShrink: 0,
1403
1413
  height: axisHeight,
1404
1414
  alignItems: "center",
@@ -1412,7 +1422,7 @@ function GanttView(param) {
1412
1422
  numberOfLines: 1,
1413
1423
  children: t("Task")
1414
1424
  })
1415
- }), /* @__PURE__ */ jsx(ScrollView$1, {
1425
+ }) : null, /* @__PURE__ */ jsx(ScrollView$1, {
1416
1426
  ref: axisScrollRef,
1417
1427
  horizontal: true,
1418
1428
  flex: 1,
@@ -1449,14 +1459,19 @@ function GanttView(param) {
1449
1459
  pointerEvents: "none"
1450
1460
  }),
1451
1461
  months.map(function(band) {
1452
- return band.width < 36 ? null : /* @__PURE__ */ jsx(Text, {
1462
+ var bandEnd = band.x + band.width;
1463
+ var shown = Math.min(bandEnd, visibleWindow.end) - Math.max(band.x, visibleWindow.start);
1464
+ if (shown < MONTH_LABEL_MIN_PX) return null;
1465
+ var x = Math.min(Math.max(band.x, visibleWindow.start), bandEnd - MONTH_LABEL_MIN_PX);
1466
+ return /* @__PURE__ */ jsx(Text, {
1453
1467
  position: "absolute",
1454
- ...rtl ? { right: band.x + 4 } : { left: band.x + 4 },
1468
+ ...rtl ? { right: x + 4 } : { left: x + 4 },
1455
1469
  top: 2,
1456
- width: Math.max(0, band.width - 8),
1470
+ width: Math.max(0, bandEnd - x - 8),
1457
1471
  ...knobProps.label,
1458
1472
  color: knobProps.textAccentColor,
1459
1473
  numberOfLines: 1,
1474
+ "data-gantt-month": band.key,
1460
1475
  children: band.label
1461
1476
  }, band.key);
1462
1477
  }),
@@ -1534,8 +1549,8 @@ function GanttView(param) {
1534
1549
  scrollEnabled: !scrollLocked,
1535
1550
  children: /* @__PURE__ */ jsxs(XStack, {
1536
1551
  "data-gantt-scroll-body": "true",
1537
- children: [/* @__PURE__ */ jsx(YStack, {
1538
- width: labelWidth,
1552
+ children: [hasLabelColumn ? /* @__PURE__ */ jsx(YStack, {
1553
+ width: columnWidth,
1539
1554
  flexShrink: 0,
1540
1555
  ...hairlineEnd,
1541
1556
  borderColor: "border-color",
@@ -1587,7 +1602,7 @@ function GanttView(param) {
1587
1602
  })
1588
1603
  }, task.id);
1589
1604
  })
1590
- }), /* @__PURE__ */ jsx(CanvasScroller, {
1605
+ }) : null, /* @__PURE__ */ jsx(CanvasScroller, {
1591
1606
  keyboardShouldPersistTaps: "handled",
1592
1607
  ref: hScrollRef,
1593
1608
  horizontal: true,