@moving-walls/design-system 1.0.21 → 1.0.22

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
@@ -36323,15 +36323,17 @@ function formatDate(date) {
36323
36323
  var monthShort = monthNames[date.getMonth()];
36324
36324
  var day = String(date.getDate()).padStart(2, '0');
36325
36325
  var year = date.getFullYear();
36326
- // Replace longer tokens first using placeholders to avoid substring conflicts
36327
- // (e.g. 'MMM' contains 'MM', so naive chaining can break)
36326
+ // Use placeholders to avoid substring conflicts (MMM contains MM, yyyy contains yy)
36328
36327
  var result = format;
36329
- if (result.includes('MMM')) {
36330
- result = result.replace('MMM', monthShort);
36331
- } else {
36332
- result = result.replace('MM', month);
36333
- }
36334
- return result.replace('dd', day).replace('yyyy', String(year));
36328
+ result = result.replace('MMM', '\x01');
36329
+ result = result.replace('MM', '\x02');
36330
+ result = result.replace('dd', '\x03');
36331
+ result = result.replace('yyyy', '\x04');
36332
+ result = result.replace('\x01', monthShort);
36333
+ result = result.replace('\x02', month);
36334
+ result = result.replace('\x03', day);
36335
+ result = result.replace('\x04', String(year));
36336
+ return result;
36335
36337
  }
36336
36338
  function isSameDay(date1, date2) {
36337
36339
  if (!date1 || !date2) return false;
@@ -36358,7 +36360,7 @@ function CalendarMonth(_ref) {
36358
36360
  var weekDays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
36359
36361
  var firstDayOfMonth = new Date(currentMonth.getFullYear(), currentMonth.getMonth(), 1);
36360
36362
  var lastDayOfMonth = new Date(currentMonth.getFullYear(), currentMonth.getMonth() + 1, 0);
36361
- var firstDayOfWeek = firstDayOfMonth.getDay();
36363
+ var firstDayOfWeek = (firstDayOfMonth.getDay() + 6) % 7; // Convert to Monday-start (Mon=0, Sun=6)
36362
36364
  var daysInMonth = lastDayOfMonth.getDate();
36363
36365
  var days = [];
36364
36366
  // Previous month's trailing days
@@ -41314,9 +41316,7 @@ Table.Row = TableRow;
41314
41316
  Table.Head = TableHead;
41315
41317
  Table.Cell = TableCell;
41316
41318
 
41317
- var TooltipContext = /*#__PURE__*/React.createContext({
41318
- delayDuration: 0
41319
- });
41319
+ var PADDING = 8;
41320
41320
  function Tooltip(_ref2) {
41321
41321
  var content = _ref2.content,
41322
41322
  children = _ref2.children,
@@ -41327,42 +41327,126 @@ function Tooltip(_ref2) {
41327
41327
  _useState2 = _slicedToArray(_useState, 2),
41328
41328
  isVisible = _useState2[0],
41329
41329
  setIsVisible = _useState2[1];
41330
- var _useContext = React.useContext(TooltipContext);
41331
- _useContext.delayDuration;
41332
- var positionClasses = {
41333
- top: 'bottom-full left-1/2 transform -translate-x-1/2 mb-2',
41334
- bottom: 'top-full left-1/2 transform -translate-x-1/2 mt-2',
41335
- left: 'right-full top-1/2 transform -translate-y-1/2 mr-2',
41336
- right: 'left-full top-1/2 transform -translate-y-1/2 ml-2'
41330
+ var triggerRef = React.useRef(null);
41331
+ var tooltipRef = React.useRef(null);
41332
+ var _useState3 = React.useState(null),
41333
+ _useState4 = _slicedToArray(_useState3, 2),
41334
+ coords = _useState4[0],
41335
+ setCoords = _useState4[1];
41336
+ var _useState5 = React.useState(position),
41337
+ _useState6 = _slicedToArray(_useState5, 2),
41338
+ resolvedPosition = _useState6[0],
41339
+ setResolvedPosition = _useState6[1];
41340
+ React.useLayoutEffect(function () {
41341
+ if (!isVisible || !triggerRef.current || !tooltipRef.current) return;
41342
+ var triggerRect = triggerRef.current.getBoundingClientRect();
41343
+ var tooltipRect = tooltipRef.current.getBoundingClientRect();
41344
+ var vw = window.innerWidth;
41345
+ var vh = window.innerHeight;
41346
+ var top = 0;
41347
+ var left = 0;
41348
+ var resolved = position;
41349
+ // Calculate preferred position
41350
+ var calc = function calc(pos) {
41351
+ switch (pos) {
41352
+ case 'top':
41353
+ top = triggerRect.top - tooltipRect.height - PADDING;
41354
+ left = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;
41355
+ break;
41356
+ case 'bottom':
41357
+ top = triggerRect.bottom + PADDING;
41358
+ left = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;
41359
+ break;
41360
+ case 'left':
41361
+ top = triggerRect.top + triggerRect.height / 2 - tooltipRect.height / 2;
41362
+ left = triggerRect.left - tooltipRect.width - PADDING;
41363
+ break;
41364
+ case 'right':
41365
+ top = triggerRect.top + triggerRect.height / 2 - tooltipRect.height / 2;
41366
+ left = triggerRect.right + PADDING;
41367
+ break;
41368
+ }
41369
+ };
41370
+ calc(position);
41371
+ // Flip if overflowing viewport
41372
+ if (position === 'top' && top < PADDING) {
41373
+ resolved = 'bottom';
41374
+ calc('bottom');
41375
+ } else if (position === 'bottom' && top + tooltipRect.height > vh - PADDING) {
41376
+ resolved = 'top';
41377
+ calc('top');
41378
+ } else if (position === 'left' && left < PADDING) {
41379
+ resolved = 'right';
41380
+ calc('right');
41381
+ } else if (position === 'right' && left + tooltipRect.width > vw - PADDING) {
41382
+ resolved = 'left';
41383
+ calc('left');
41384
+ }
41385
+ // Clamp horizontal to stay within viewport
41386
+ if (left < PADDING) left = PADDING;
41387
+ if (left + tooltipRect.width > vw - PADDING) left = vw - PADDING - tooltipRect.width;
41388
+ // Clamp vertical
41389
+ if (top < PADDING) top = PADDING;
41390
+ if (top + tooltipRect.height > vh - PADDING) top = vh - PADDING - tooltipRect.height;
41391
+ setCoords({
41392
+ top: top,
41393
+ left: left
41394
+ });
41395
+ setResolvedPosition(resolved);
41396
+ }, [isVisible, position]);
41397
+ var show = React.useCallback(function () {
41398
+ return setIsVisible(true);
41399
+ }, []);
41400
+ var hide = React.useCallback(function () {
41401
+ setIsVisible(false);
41402
+ setCoords(null);
41403
+ }, []);
41404
+ // Arrow positioning relative to tooltip
41405
+ var arrowStyle = function arrowStyle() {
41406
+ if (!triggerRef.current || !tooltipRef.current || !coords) return {};
41407
+ var triggerRect = triggerRef.current.getBoundingClientRect();
41408
+ var tooltipRect = tooltipRef.current.getBoundingClientRect();
41409
+ if (resolvedPosition === 'top' || resolvedPosition === 'bottom') {
41410
+ var arrowLeft = triggerRect.left + triggerRect.width / 2 - coords.left - 4;
41411
+ return {
41412
+ left: Math.max(8, Math.min(arrowLeft, tooltipRect.width - 8))
41413
+ };
41414
+ }
41415
+ var arrowTop = triggerRect.top + triggerRect.height / 2 - coords.top - 4;
41416
+ return {
41417
+ top: Math.max(8, Math.min(arrowTop, tooltipRect.height - 8))
41418
+ };
41337
41419
  };
41338
41420
  var arrowClasses = {
41339
- top: 'top-full left-1/2 transform -translate-x-1/2 border-l-transparent border-r-transparent border-b-transparent border-t-white',
41340
- bottom: 'bottom-full left-1/2 transform -translate-x-1/2 border-l-transparent border-r-transparent border-t-transparent border-b-white',
41341
- left: 'left-full top-1/2 transform -translate-y-1/2 border-t-transparent border-b-transparent border-r-transparent border-l-white',
41342
- right: 'right-full top-1/2 transform -translate-y-1/2 border-t-transparent border-b-transparent border-l-transparent border-r-white'
41421
+ top: 'absolute top-full border-l-transparent border-r-transparent border-b-transparent border-t-white',
41422
+ bottom: 'absolute bottom-full border-l-transparent border-r-transparent border-t-transparent border-b-white',
41423
+ left: 'absolute left-full border-t-transparent border-b-transparent border-r-transparent border-l-white',
41424
+ right: 'absolute right-full border-t-transparent border-b-transparent border-l-transparent border-r-white'
41343
41425
  };
41344
41426
  return require$$1.jsxs("div", {
41345
41427
  className: "relative inline-block",
41428
+ ref: triggerRef,
41346
41429
  children: [require$$1.jsx("div", {
41347
- onMouseEnter: function onMouseEnter() {
41348
- return setIsVisible(true);
41349
- },
41350
- onMouseLeave: function onMouseLeave() {
41351
- return setIsVisible(false);
41352
- },
41353
- onFocus: function onFocus() {
41354
- return setIsVisible(true);
41355
- },
41356
- onBlur: function onBlur() {
41357
- return setIsVisible(false);
41358
- },
41430
+ onMouseEnter: show,
41431
+ onMouseLeave: hide,
41432
+ onFocus: show,
41433
+ onBlur: hide,
41359
41434
  children: children
41360
- }), isVisible && require$$1.jsxs("div", {
41361
- className: clsx('absolute z-50 px-2 py-1 text-sm text-mw-neutral-500 bg-white border border-mw-neutral-100 rounded-md whitespace-nowrap shadow-sm', positionClasses[position], className),
41435
+ }), isVisible && /*#__PURE__*/ReactDOM.createPortal(require$$1.jsxs("div", {
41436
+ ref: tooltipRef,
41437
+ style: coords ? {
41438
+ top: coords.top,
41439
+ left: coords.left
41440
+ } : {
41441
+ top: -9999,
41442
+ left: -9999
41443
+ },
41444
+ className: clsx('fixed z-[9999] px-2 py-1 text-sm text-mw-neutral-500 bg-white border border-mw-neutral-100 rounded-md shadow-sm max-w-xs whitespace-normal', className),
41362
41445
  children: [content, require$$1.jsx("div", {
41363
- className: clsx('absolute w-0 h-0 border-4', arrowClasses[position])
41446
+ className: clsx('w-0 h-0 border-4', arrowClasses[resolvedPosition]),
41447
+ style: arrowStyle()
41364
41448
  })]
41365
- })]
41449
+ }), document.body)]
41366
41450
  });
41367
41451
  }
41368
41452