bianic-ui 2.15.0 → 2.15.1-alpha.0

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/cjs/index.js CHANGED
@@ -2372,30 +2372,67 @@ function MenuContainerNoAnchorInner(propsComp, ref) {
2372
2372
  }
2373
2373
  var MenuContainerNoAnchor = React.forwardRef(MenuContainerNoAnchorInner);
2374
2374
 
2375
+ // Internal. Not exported from any index file.
2376
+ // Shared by DropdownItem and MenuItem to pick the side of a sub-menu.
2377
+ // true when the parent sub-menu opened on the left (deeper levels try left first)
2378
+ var SubMenuSideContext = React.createContext(false);
2379
+ function pickIsLeft(itemRect, subMenuWidth, viewportWidth, preferLeft) {
2380
+ var roomRight = viewportWidth - itemRect.right;
2381
+ var roomLeft = itemRect.left;
2382
+ var fitsRight = subMenuWidth <= roomRight;
2383
+ var fitsLeft = subMenuWidth <= roomLeft;
2384
+ if (preferLeft) {
2385
+ if (fitsLeft)
2386
+ return true;
2387
+ if (fitsRight)
2388
+ return false;
2389
+ return roomLeft >= roomRight;
2390
+ }
2391
+ if (fitsRight)
2392
+ return false;
2393
+ if (fitsLeft)
2394
+ return true;
2395
+ return roomLeft > roomRight;
2396
+ }
2397
+ function useSubMenuSide(isOpen, itemRef, subMenuRef) {
2398
+ var preferLeft = React.useContext(SubMenuSideContext);
2399
+ var _a = React.useState(false), isLeft = _a[0], setIsLeft = _a[1];
2400
+ var measure = React.useCallback(function () {
2401
+ var item = itemRef.current;
2402
+ var subMenu = subMenuRef.current;
2403
+ if (!item || !subMenu)
2404
+ return;
2405
+ setIsLeft(pickIsLeft(item.getBoundingClientRect(), subMenu.offsetWidth, document.documentElement.clientWidth, preferLeft));
2406
+ }, [preferLeft, itemRef, subMenuRef]);
2407
+ // No dependency array: runs before paint on every open and on every
2408
+ // re-render while open. Setting the same side again does nothing.
2409
+ React.useLayoutEffect(function () {
2410
+ if (!isOpen)
2411
+ return;
2412
+ measure();
2413
+ });
2414
+ React.useLayoutEffect(function () {
2415
+ if (!isOpen)
2416
+ return undefined;
2417
+ window.addEventListener('resize', measure);
2418
+ return function () { return window.removeEventListener('resize', measure); };
2419
+ }, [isOpen, measure]);
2420
+ return isLeft;
2421
+ }
2422
+
2375
2423
  function MenuItem(_a) {
2376
2424
  var _b = _a.className, className = _b === void 0 ? '' : _b, label = _a.label, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.caption, caption = _d === void 0 ? undefined : _d, _e = _a.isChecked, isChecked = _e === void 0 ? undefined : _e, _f = _a.onClose, onClose = _f === void 0 ? function () { } : _f, _g = _a.children, children = _g === void 0 ? undefined : _g, _h = _a.zIndex, zIndex = _h === void 0 ? 100 : _h, _j = _a.inheritedOnClick, inheritedOnClick = _j === void 0 ? function () { } : _j, _k = _a.disabled, disabled = _k === void 0 ? false : _k, _l = _a.onKeyDown, consumerOnKeyDown = _l === void 0 ? undefined : _l, _m = _a.onFocus, consumerOnFocus = _m === void 0 ? undefined : _m, _o = _a.onBlur, consumerOnBlur = _o === void 0 ? undefined : _o, props = __rest(_a, ["className", "label", "onClick", "caption", "isChecked", "onClose", "children", "zIndex", "inheritedOnClick", "disabled", "onKeyDown", "onFocus", "onBlur"]);
2377
2425
  var _p = React.useState(false), isHovered = _p[0], setIsHovered = _p[1];
2378
2426
  var _q = React.useState(false), isKeyboardOpen = _q[0], setIsKeyboardOpen = _q[1];
2379
2427
  var _r = React.useState(false), isKeyFocused = _r[0], setIsKeyFocused = _r[1];
2380
2428
  var outerRef = React.useRef(null);
2381
- var _s = React.useState(false), isLeft = _s[0], setIsLeft = _s[1];
2382
2429
  var isWithChecked = isChecked !== undefined;
2383
2430
  var leftPadding = isWithChecked ? 'pl-[5px]' : 'pl-[10px]';
2384
2431
  var rightPadding = caption || children ? 'pr-[5px]' : 'pr-[10px]';
2385
2432
  var itemClass = "".concat(leftPadding, " ").concat(rightPadding, " ").concat(className);
2386
2433
  var MenuContRef = React.useRef(null);
2387
- React.useEffect(function () {
2388
- if (MenuContRef.current) {
2389
- // Adjust dropdown position to prevent overflow on the right.
2390
- var MenuContRect = MenuContRef.current.getBoundingClientRect();
2391
- var RectRight = MenuContRect.right;
2392
- var innerWindow = window.innerWidth;
2393
- if (RectRight > innerWindow)
2394
- setIsLeft(true);
2395
- else
2396
- setIsLeft(false);
2397
- }
2398
- }, [isHovered, isKeyboardOpen]);
2434
+ var isOpen = isHovered || isKeyboardOpen;
2435
+ var isLeft = useSubMenuSide(isOpen, outerRef, MenuContRef);
2399
2436
  var translateClass = isLeft
2400
2437
  ? 'left-0 -translate-x-full'
2401
2438
  : 'right-0 translate-x-full';
@@ -2472,10 +2509,11 @@ function MenuItem(_a) {
2472
2509
  React.createElement("div", { className: "ml-auto flex items-center" },
2473
2510
  children && (React.createElement(TbChevronRight, { className: "ml-[10px] text-bia-coolgrey" })),
2474
2511
  children === undefined && caption && (React.createElement("span", { className: "ml-[30px] whitespace-nowrap text-[11px] ".concat(disabled ? 'text-bia-coolgrey-light-50' : 'text-bia-coolgrey') }, caption)))),
2475
- children && !disabled && (React.createElement(MenuContainerNoAnchor, { open: isHovered || isKeyboardOpen, onKeyDown: handleSubMenuKeyDown, onClose: function () {
2476
- setIsKeyboardOpen(false);
2477
- onClose();
2478
- }, className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), ref: MenuContRef, zIndex: currentZIndex + 10, onClickItem: function () { return inheritedOnClick(); } }, children))));
2512
+ children && !disabled && (React.createElement(SubMenuSideContext.Provider, { value: isLeft },
2513
+ React.createElement(MenuContainerNoAnchor, { open: isOpen, onKeyDown: handleSubMenuKeyDown, onClose: function () {
2514
+ setIsKeyboardOpen(false);
2515
+ onClose();
2516
+ }, className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), ref: MenuContRef, zIndex: currentZIndex + 10, onClickItem: function () { return inheritedOnClick(); } }, children)))));
2479
2517
  }
2480
2518
 
2481
2519
  var TooltipItem = function (_a) {
@@ -3198,26 +3236,14 @@ function DropdownItem(_a) {
3198
3236
  var _o = React.useState(false), isHovered = _o[0], setIsHovered = _o[1];
3199
3237
  var _p = React.useState(false), isKeyboardOpen = _p[0], setIsKeyboardOpen = _p[1];
3200
3238
  var _q = React.useState(false), isKeyFocused = _q[0], setIsKeyFocused = _q[1];
3201
- var _r = React.useState(false), isLeft = _r[0], setIsLeft = _r[1];
3202
3239
  var outerRef = React.useRef(null);
3203
3240
  var fontClass = fontConfig[size] || fontConfig.md;
3204
3241
  var itemSizeClass = itemSizeConfig[size] || itemSizeConfig.md;
3205
3242
  var itemClass = "".concat(itemSizeClass, " ").concat(fontClass, " ").concat(className);
3206
3243
  var chevronSize = size === 'sm' ? 14 : 18;
3207
3244
  var DropdownContRef = React.useRef(null);
3208
- React.useEffect(function () {
3209
- var _a;
3210
- if (DropdownContRef.current) {
3211
- // Adjust dropdown position to prevent overflow on the right.
3212
- var MenuContRect = (_a = DropdownContRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
3213
- var RectRight = MenuContRect === null || MenuContRect === void 0 ? void 0 : MenuContRect.right;
3214
- var innerWindow = window.innerWidth;
3215
- if (RectRight > innerWindow)
3216
- setIsLeft(true);
3217
- else
3218
- setIsLeft(false);
3219
- }
3220
- }, [isHovered, isKeyboardOpen]);
3245
+ var isOpen = isHovered || isKeyboardOpen;
3246
+ var isLeft = useSubMenuSide(isOpen, outerRef, DropdownContRef);
3221
3247
  var translateClass = isLeft
3222
3248
  ? 'left-0 -translate-x-full'
3223
3249
  : 'right-0 translate-x-full';
@@ -3278,10 +3304,11 @@ function DropdownItem(_a) {
3278
3304
  React.createElement("button", __assign({ className: "relative flex w-full !min-w-fit items-center justify-start whitespace-nowrap bg-bia-white px-[15px] py-[5px] text-left text-bia-black disabled:cursor-not-allowed disabled:text-bia-coolgrey-light-50 hover:[&:not(:disabled)]:bg-bia-blue-pastel ".concat(itemClass).concat(keyFocusClass), style: { zIndex: currentZIndex + 15 }, onClick: function (e) { return onClickItem(e, value); }, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur, disabled: disabled, type: "button" }, props),
3279
3305
  content,
3280
3306
  React.createElement("div", { className: "ml-auto flex items-center" }, children && (React.createElement(TbChevronRight, { className: "ml-[10px] text-bia-coolgrey", size: chevronSize })))),
3281
- children && (React.createElement(DropdownContNoAnchor, { className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), onClose: function () {
3282
- setIsKeyboardOpen(false);
3283
- onClose();
3284
- }, onKeyDown: handleSubMenuKeyDown, open: isHovered || isKeyboardOpen, onClickItem: function (e, itemValue) { return onClickItem(e, itemValue); }, size: size, ref: DropdownContRef, zIndex: currentZIndex + 10 }, children))));
3307
+ children && (React.createElement(SubMenuSideContext.Provider, { value: isLeft },
3308
+ React.createElement(DropdownContNoAnchor, { className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), onClose: function () {
3309
+ setIsKeyboardOpen(false);
3310
+ onClose();
3311
+ }, onKeyDown: handleSubMenuKeyDown, open: isOpen, onClickItem: function (e, itemValue) { return onClickItem(e, itemValue); }, size: size, ref: DropdownContRef, zIndex: currentZIndex + 10 }, children)))));
3285
3312
  }
3286
3313
 
3287
3314
  var matchSearchTerm = function (content, term, variant) {
@@ -7543,7 +7570,15 @@ var MARKER_PX = 12;
7543
7570
  * possible keeps the button focusable (aria-disabled) and looks disabled.
7544
7571
  * On touch screens the tap area grows to 44px tall without changing the look.
7545
7572
  */
7546
- var hintButtonClass = "aria-disabled:cursor-not-allowed aria-disabled:border-bia-coolgrey-disabled aria-disabled:text-bia-coolgrey-disabled aria-disabled:hover:border-bia-coolgrey-disabled aria-disabled:active:bg-primary-white [@media(pointer:coarse)]:relative [@media(pointer:coarse)]:after:absolute [@media(pointer:coarse)]:after:-inset-x-[2px] [@media(pointer:coarse)]:after:-inset-y-[7px] [@media(pointer:coarse)]:after:content-['']";
7573
+ var hintButtonClass = "disabled:cursor-not-allowed aria-disabled:cursor-not-allowed aria-disabled:border-bia-coolgrey-disabled aria-disabled:text-bia-coolgrey-disabled aria-disabled:hover:border-bia-coolgrey-disabled aria-disabled:active:bg-primary-white [@media(pointer:coarse)]:relative [@media(pointer:coarse)]:after:absolute [@media(pointer:coarse)]:after:-inset-x-[2px] [@media(pointer:coarse)]:after:-inset-y-[7px] [@media(pointer:coarse)]:after:content-['']";
7574
+ /**
7575
+ * Default-variant step buttons (bianic Button, default-outlined, sm).
7576
+ * REVISI: a disabled button shows the not-allowed cursor; the bianic Button
7577
+ * does not set one. Its disabled border class has a typo in buttonConfigs.ts
7578
+ * (a missing space), so the light disabled border is set here too, matching
7579
+ * the lite buttons.
7580
+ */
7581
+ var stepButtonClass = 'disabled:cursor-not-allowed disabled:border-bia-coolgrey-disabled';
7547
7582
  /** Icon color of a button that cannot move. The bianic Button colors icons black. */
7548
7583
  var inactiveIconClass = '!text-bia-coolgrey-disabled';
7549
7584
  /**
@@ -7573,7 +7608,11 @@ var LITE_BUTTON_LABELS = {
7573
7608
  /** Hover delay before a tooltip shows. Keyboard focus shows it at once. */
7574
7609
  var HINT_DELAY_MS = 400;
7575
7610
  var hintBubbleClass = 'pointer-events-none z-[150] w-max max-w-[240px] rounded-[4px] bg-bia-black px-[7px] py-[4px] font-segoe text-size-sm text-bia-white';
7576
- var mutedTextClass = 'text-bia-coolgrey-dark-20';
7611
+ /**
7612
+ * Grey text, as in Figma ("Primary/Cool Grey" #8C8CA6). Its contrast on white
7613
+ * is about 3.3:1; the team chose the Figma color (decision log BIAN-268).
7614
+ */
7615
+ var mutedTextClass = 'text-bia-coolgrey';
7577
7616
  /** Text for an empty period, in both variants. */
7578
7617
  var NO_EVENTS_TEXT = 'No events in this period';
7579
7618
  /** Default `noEventLabel`: a day without an event in a period that has events. */
@@ -8111,11 +8150,11 @@ function DefaultLayout(_a) {
8111
8150
  React.createElement(Text, { variant: "tiny-text", className: "".concat(mutedTextClass, " ").concat(axisLabelClass) }, tick.label))); })),
8112
8151
  React.createElement("div", { className: "mt-[14px] flex items-center justify-between gap-[5px]" },
8113
8152
  React.createElement("div", { className: "flex gap-[5px]" },
8114
- React.createElement(Button, { variant: "default-outlined", size: "sm", label: "Previous Event", iconLeft: React.createElement(TbChevronLeftPipe, { "aria-hidden": "true", className: iconClass(noPreviousEvent) }), disabled: noPreviousEvent, onClick: function () { return previousEvent && goToDay(previousEvent.day); } }),
8115
- React.createElement(Button, { variant: "default-outlined", size: "sm", label: "Day", "aria-label": "Previous day", iconLeft: React.createElement(TbChevronLeft, { "aria-hidden": "true", className: iconClass(noPreviousDay) }), disabled: noPreviousDay, onClick: function () { return goToDay(valueDay - 1); } })),
8153
+ React.createElement(Button, { variant: "default-outlined", size: "sm", className: stepButtonClass, label: "Previous Event", iconLeft: React.createElement(TbChevronLeftPipe, { "aria-hidden": "true", className: iconClass(noPreviousEvent) }), disabled: noPreviousEvent, onClick: function () { return previousEvent && goToDay(previousEvent.day); } }),
8154
+ React.createElement(Button, { variant: "default-outlined", size: "sm", className: stepButtonClass, label: "Day", "aria-label": "Previous day", iconLeft: React.createElement(TbChevronLeft, { "aria-hidden": "true", className: iconClass(noPreviousDay) }), disabled: noPreviousDay, onClick: function () { return goToDay(valueDay - 1); } })),
8116
8155
  React.createElement("div", { className: "flex gap-[5px]" },
8117
- React.createElement(Button, { variant: "default-outlined", size: "sm", label: "Day", "aria-label": "Next day", iconRight: React.createElement(TbChevronRight, { "aria-hidden": "true", className: iconClass(noNextDay) }), disabled: noNextDay, onClick: function () { return goToDay(valueDay + 1); } }),
8118
- React.createElement(Button, { variant: "default-outlined", size: "sm", label: "Next Event", iconRight: React.createElement(TbChevronRightPipe, { "aria-hidden": "true", className: iconClass(noNextEvent) }), disabled: noNextEvent, onClick: function () { return nextEvent && goToDay(nextEvent.day); } })))));
8156
+ React.createElement(Button, { variant: "default-outlined", size: "sm", className: stepButtonClass, label: "Day", "aria-label": "Next day", iconRight: React.createElement(TbChevronRight, { "aria-hidden": "true", className: iconClass(noNextDay) }), disabled: noNextDay, onClick: function () { return goToDay(valueDay + 1); } }),
8157
+ React.createElement(Button, { variant: "default-outlined", size: "sm", className: stepButtonClass, label: "Next Event", iconRight: React.createElement(TbChevronRightPipe, { "aria-hidden": "true", className: iconClass(noNextEvent) }), disabled: noNextEvent, onClick: function () { return nextEvent && goToDay(nextEvent.day); } })))));
8119
8158
  }
8120
8159
 
8121
8160
  var NO_EVENTS = [];
@@ -8158,18 +8197,18 @@ function LiteLayout(_a) {
8158
8197
  !currentEvent && statusText && (React.createElement(TruncatedText, { text: statusText, textSize: "tiny", textClassName: mutedTextClass })))),
8159
8198
  React.createElement(Track, { className: "mx-5 min-w-[80px] flex-1", timeline: timeline, sliderLabel: sliderLabel, disabled: disabled }),
8160
8199
  React.createElement("div", { className: "mr-5 flex shrink-0 flex-col items-end gap-[2px]" },
8161
- React.createElement(Text, { variant: "tiny-text", className: mutedTextClass }, "Day"),
8162
- React.createElement("span", { className: "grid grid-rows-[14px] whitespace-nowrap font-arial text-size-tiny tabular-nums" },
8200
+ React.createElement(Text, { variant: "tiny-text", className: "".concat(mutedTextClass, " leading-4") }, "Day"),
8201
+ React.createElement("span", { className: "grid grid-rows-[14px] whitespace-nowrap font-segoe text-size-sm tabular-nums" },
8163
8202
  React.createElement("span", { "aria-hidden": "true", className: "invisible col-start-1 row-start-1" },
8164
- React.createElement(Text, { variant: "tiny-text-bold" }, totalDays),
8203
+ React.createElement(Text, { variant: "small-text-semibold" }, totalDays),
8165
8204
  ' ',
8166
- React.createElement(Text, { variant: "tiny-text" },
8205
+ React.createElement(Text, { variant: "small-text-semibold" },
8167
8206
  "/ ",
8168
8207
  totalDays)),
8169
8208
  React.createElement("span", { className: "col-start-1 row-start-1 text-right" },
8170
- React.createElement(Text, { variant: "tiny-text-bold" }, dayOfPeriod),
8209
+ React.createElement(Text, { variant: "small-text-semibold" }, dayOfPeriod),
8171
8210
  ' ',
8172
- React.createElement(Text, { variant: "tiny-text", className: mutedTextClass },
8211
+ React.createElement(Text, { variant: "small-text-semibold", className: mutedTextClass },
8173
8212
  "/ ",
8174
8213
  totalDays)))),
8175
8214
  React.createElement("div", { className: "flex shrink-0 gap-[5px]" },