@moving-walls/design-system 1.0.20 → 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
@@ -36318,10 +36318,22 @@ var defaultPresets$1 = [{
36318
36318
  function formatDate(date) {
36319
36319
  var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'MM/dd/yyyy';
36320
36320
  if (!date) return '';
36321
+ var monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
36321
36322
  var month = String(date.getMonth() + 1).padStart(2, '0');
36323
+ var monthShort = monthNames[date.getMonth()];
36322
36324
  var day = String(date.getDate()).padStart(2, '0');
36323
36325
  var year = date.getFullYear();
36324
- return format.replace('MM', month).replace('dd', day).replace('yyyy', String(year));
36326
+ // Use placeholders to avoid substring conflicts (MMM contains MM, yyyy contains yy)
36327
+ var result = format;
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;
36325
36337
  }
36326
36338
  function isSameDay(date1, date2) {
36327
36339
  if (!date1 || !date2) return false;
@@ -36348,7 +36360,7 @@ function CalendarMonth(_ref) {
36348
36360
  var weekDays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
36349
36361
  var firstDayOfMonth = new Date(currentMonth.getFullYear(), currentMonth.getMonth(), 1);
36350
36362
  var lastDayOfMonth = new Date(currentMonth.getFullYear(), currentMonth.getMonth() + 1, 0);
36351
- var firstDayOfWeek = firstDayOfMonth.getDay();
36363
+ var firstDayOfWeek = (firstDayOfMonth.getDay() + 6) % 7; // Convert to Monday-start (Mon=0, Sun=6)
36352
36364
  var daysInMonth = lastDayOfMonth.getDate();
36353
36365
  var days = [];
36354
36366
  // Previous month's trailing days
@@ -41304,9 +41316,7 @@ Table.Row = TableRow;
41304
41316
  Table.Head = TableHead;
41305
41317
  Table.Cell = TableCell;
41306
41318
 
41307
- var TooltipContext = /*#__PURE__*/React.createContext({
41308
- delayDuration: 0
41309
- });
41319
+ var PADDING = 8;
41310
41320
  function Tooltip(_ref2) {
41311
41321
  var content = _ref2.content,
41312
41322
  children = _ref2.children,
@@ -41317,42 +41327,126 @@ function Tooltip(_ref2) {
41317
41327
  _useState2 = _slicedToArray(_useState, 2),
41318
41328
  isVisible = _useState2[0],
41319
41329
  setIsVisible = _useState2[1];
41320
- var _useContext = React.useContext(TooltipContext);
41321
- _useContext.delayDuration;
41322
- var positionClasses = {
41323
- top: 'bottom-full left-1/2 transform -translate-x-1/2 mb-2',
41324
- bottom: 'top-full left-1/2 transform -translate-x-1/2 mt-2',
41325
- left: 'right-full top-1/2 transform -translate-y-1/2 mr-2',
41326
- 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
+ };
41327
41419
  };
41328
41420
  var arrowClasses = {
41329
- top: 'top-full left-1/2 transform -translate-x-1/2 border-l-transparent border-r-transparent border-b-transparent border-t-white',
41330
- bottom: 'bottom-full left-1/2 transform -translate-x-1/2 border-l-transparent border-r-transparent border-t-transparent border-b-white',
41331
- left: 'left-full top-1/2 transform -translate-y-1/2 border-t-transparent border-b-transparent border-r-transparent border-l-white',
41332
- 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'
41333
41425
  };
41334
41426
  return require$$1.jsxs("div", {
41335
41427
  className: "relative inline-block",
41428
+ ref: triggerRef,
41336
41429
  children: [require$$1.jsx("div", {
41337
- onMouseEnter: function onMouseEnter() {
41338
- return setIsVisible(true);
41339
- },
41340
- onMouseLeave: function onMouseLeave() {
41341
- return setIsVisible(false);
41342
- },
41343
- onFocus: function onFocus() {
41344
- return setIsVisible(true);
41345
- },
41346
- onBlur: function onBlur() {
41347
- return setIsVisible(false);
41348
- },
41430
+ onMouseEnter: show,
41431
+ onMouseLeave: hide,
41432
+ onFocus: show,
41433
+ onBlur: hide,
41349
41434
  children: children
41350
- }), isVisible && require$$1.jsxs("div", {
41351
- 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),
41352
41445
  children: [content, require$$1.jsx("div", {
41353
- 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()
41354
41448
  })]
41355
- })]
41449
+ }), document.body)]
41356
41450
  });
41357
41451
  }
41358
41452