@homebound/beam 4.42.0 → 4.43.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/index.cjs +1109 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.js +1106 -106
- package/dist/index.js.map +1 -1
- package/dist/truss.css +18 -0
- package/dist/utils/rtlUtils.cjs +2 -2
- package/dist/utils/rtlUtils.cjs.map +1 -1
- package/dist/utils/rtlUtils.js +2 -2
- package/dist/utils/rtlUtils.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -152,6 +152,7 @@ __export(index_exports, {
|
|
|
152
152
|
Loader: () => Loader,
|
|
153
153
|
LoadingSkeleton: () => LoadingSkeleton,
|
|
154
154
|
MaxLines: () => MaxLines,
|
|
155
|
+
MenuSelectField: () => MenuSelectField,
|
|
155
156
|
ModalBanner: () => ModalBanner,
|
|
156
157
|
ModalBody: () => ModalBody,
|
|
157
158
|
ModalFilterItem: () => ModalFilterItem,
|
|
@@ -464,95 +465,95 @@ module.exports = __toCommonJS(index_exports);
|
|
|
464
465
|
|
|
465
466
|
// src/Css.ts
|
|
466
467
|
var import_runtime = require("@homebound/truss/runtime");
|
|
467
|
-
var Tokens = /* @__PURE__ */ ((
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
return
|
|
468
|
+
var Tokens = /* @__PURE__ */ ((Tokens69) => {
|
|
469
|
+
Tokens69["AiFieldBg"] = "--b-ai-field-bg";
|
|
470
|
+
Tokens69["AiFieldFg"] = "--b-ai-field-fg";
|
|
471
|
+
Tokens69["ButtonCautionDisabledBg"] = "--b-button-caution-disabled-bg";
|
|
472
|
+
Tokens69["ButtonCautionDisabledFg"] = "--b-button-caution-disabled-fg";
|
|
473
|
+
Tokens69["ButtonDangerDisabledBg"] = "--b-button-danger-disabled-bg";
|
|
474
|
+
Tokens69["ButtonDangerDisabledFg"] = "--b-button-danger-disabled-fg";
|
|
475
|
+
Tokens69["ButtonGhostDisabledFg"] = "--b-button-ghost-disabled-fg";
|
|
476
|
+
Tokens69["ButtonGhostFg"] = "--b-button-ghost-fg";
|
|
477
|
+
Tokens69["ButtonPrimaryDisabledBg"] = "--b-button-primary-disabled-bg";
|
|
478
|
+
Tokens69["ButtonPrimaryDisabledFg"] = "--b-button-primary-disabled-fg";
|
|
479
|
+
Tokens69["ButtonSecondaryFg"] = "--b-button-secondary-fg";
|
|
480
|
+
Tokens69["ButtonTertiaryFg"] = "--b-button-tertiary-fg";
|
|
481
|
+
Tokens69["ButtonTertiaryFgPressed"] = "--b-button-tertiary-fg-pressed";
|
|
482
|
+
Tokens69["ChoiceDisabled"] = "--b-choice-disabled";
|
|
483
|
+
Tokens69["ChoiceSelected"] = "--b-choice-selected";
|
|
484
|
+
Tokens69["Danger"] = "--b-danger";
|
|
485
|
+
Tokens69["DangerPressed"] = "--b-danger-pressed";
|
|
486
|
+
Tokens69["EnvBrandDev"] = "--b-env-brand-dev";
|
|
487
|
+
Tokens69["EnvBrandLocalProd"] = "--b-env-brand-local-prod";
|
|
488
|
+
Tokens69["EnvBrandProd"] = "--b-env-brand-prod";
|
|
489
|
+
Tokens69["EnvBrandQa"] = "--b-env-brand-qa";
|
|
490
|
+
Tokens69["FieldBgDefault"] = "--b-field-bg-default";
|
|
491
|
+
Tokens69["FieldBgDisabled"] = "--b-field-bg-disabled";
|
|
492
|
+
Tokens69["FieldBgHover"] = "--b-field-bg-hover";
|
|
493
|
+
Tokens69["FieldBorderDefault"] = "--b-field-border-default";
|
|
494
|
+
Tokens69["FieldBorderError"] = "--b-field-border-error";
|
|
495
|
+
Tokens69["FieldBorderFocus"] = "--b-field-border-focus";
|
|
496
|
+
Tokens69["FieldBorderHover"] = "--b-field-border-hover";
|
|
497
|
+
Tokens69["FieldTextDisabled"] = "--b-field-text-disabled";
|
|
498
|
+
Tokens69["FocusRingInset"] = "--b-focus-ring-inset";
|
|
499
|
+
Tokens69["FocusRingMuted"] = "--b-focus-ring-muted";
|
|
500
|
+
Tokens69["LoaderFill"] = "--b-loader-fill";
|
|
501
|
+
Tokens69["LoaderSpinner"] = "--b-loader-spinner";
|
|
502
|
+
Tokens69["LoaderTrack"] = "--b-loader-track";
|
|
503
|
+
Tokens69["NavGlobalItemBgActive"] = "--b-nav-global-item-bg-active";
|
|
504
|
+
Tokens69["NavGlobalItemBgHover"] = "--b-nav-global-item-bg-hover";
|
|
505
|
+
Tokens69["NavGlobalItemBgPressed"] = "--b-nav-global-item-bg-pressed";
|
|
506
|
+
Tokens69["NavGlobalText"] = "--b-nav-global-text";
|
|
507
|
+
Tokens69["NavGlobalTextActive"] = "--b-nav-global-text-active";
|
|
508
|
+
Tokens69["NavGlobalTextDisabled"] = "--b-nav-global-text-disabled";
|
|
509
|
+
Tokens69["NavItemBgActive"] = "--b-nav-item-bg-active";
|
|
510
|
+
Tokens69["NavItemBgHover"] = "--b-nav-item-bg-hover";
|
|
511
|
+
Tokens69["NavItemBgPressed"] = "--b-nav-item-bg-pressed";
|
|
512
|
+
Tokens69["NavText"] = "--b-nav-text";
|
|
513
|
+
Tokens69["NavTextActive"] = "--b-nav-text-active";
|
|
514
|
+
Tokens69["NavTextDisabled"] = "--b-nav-text-disabled";
|
|
515
|
+
Tokens69["NavTextFocusVisible"] = "--b-nav-text-focus-visible";
|
|
516
|
+
Tokens69["NavTextPressed"] = "--b-nav-text-pressed";
|
|
517
|
+
Tokens69["NeutralFillHover"] = "--b-neutral-fill-hover";
|
|
518
|
+
Tokens69["NeutralFillHoverStrong"] = "--b-neutral-fill-hover-strong";
|
|
519
|
+
Tokens69["NeutralFillHoverSubtle"] = "--b-neutral-fill-hover-subtle";
|
|
520
|
+
Tokens69["NeutralFillPressed"] = "--b-neutral-fill-pressed";
|
|
521
|
+
Tokens69["NeutralSurfacePressed"] = "--b-neutral-surface-pressed";
|
|
522
|
+
Tokens69["OnPrimary"] = "--b-on-primary";
|
|
523
|
+
Tokens69["OnSurface"] = "--b-on-surface";
|
|
524
|
+
Tokens69["OnSurfaceActive"] = "--b-on-surface-active";
|
|
525
|
+
Tokens69["OnSurfaceActiveDisabled"] = "--b-on-surface-active-disabled";
|
|
526
|
+
Tokens69["OnSurfaceDisabled"] = "--b-on-surface-disabled";
|
|
527
|
+
Tokens69["OnSurfaceMuted"] = "--b-on-surface-muted";
|
|
528
|
+
Tokens69["OnSurfaceRaisedHover"] = "--b-on-surface-raised-hover";
|
|
529
|
+
Tokens69["OnSurfaceRaisedPressed"] = "--b-on-surface-raised-pressed";
|
|
530
|
+
Tokens69["Primary"] = "--b-primary";
|
|
531
|
+
Tokens69["PrimaryHover"] = "--b-primary-hover";
|
|
532
|
+
Tokens69["PrimaryPressed"] = "--b-primary-pressed";
|
|
533
|
+
Tokens69["Scrim"] = "--b-scrim";
|
|
534
|
+
Tokens69["SelectionFill"] = "--b-selection-fill";
|
|
535
|
+
Tokens69["SelectionIndicator"] = "--b-selection-indicator";
|
|
536
|
+
Tokens69["Surface"] = "--b-surface";
|
|
537
|
+
Tokens69["SurfaceActive"] = "--b-surface-active";
|
|
538
|
+
Tokens69["SurfaceActiveBorder"] = "--b-surface-active-border";
|
|
539
|
+
Tokens69["SurfaceActiveHover"] = "--b-surface-active-hover";
|
|
540
|
+
Tokens69["SurfaceDisabled"] = "--b-surface-disabled";
|
|
541
|
+
Tokens69["SurfaceHover"] = "--b-surface-hover";
|
|
542
|
+
Tokens69["SurfaceRaised"] = "--b-surface-raised";
|
|
543
|
+
Tokens69["SurfaceRaisedHover"] = "--b-surface-raised-hover";
|
|
544
|
+
Tokens69["SurfaceRaisedPressed"] = "--b-surface-raised-pressed";
|
|
545
|
+
Tokens69["SurfaceSeparator"] = "--b-surface-separator";
|
|
546
|
+
Tokens69["SurfaceSubtle"] = "--b-surface-subtle";
|
|
547
|
+
Tokens69["TextDisabled"] = "--b-text-disabled";
|
|
548
|
+
Tokens69["TextHelper"] = "--b-text-helper";
|
|
549
|
+
Tokens69["TextLabel"] = "--b-text-label";
|
|
550
|
+
Tokens69["TextLinkDefault"] = "--b-text-link-default";
|
|
551
|
+
Tokens69["TextLinkDisabled"] = "--b-text-link-disabled";
|
|
552
|
+
Tokens69["TextLinkHover"] = "--b-text-link-hover";
|
|
553
|
+
Tokens69["TextLinkPressed"] = "--b-text-link-pressed";
|
|
554
|
+
Tokens69["TextPlaceholder"] = "--b-text-placeholder";
|
|
555
|
+
Tokens69["TextSelection"] = "--b-text-selection";
|
|
556
|
+
return Tokens69;
|
|
556
557
|
})(Tokens || {});
|
|
557
558
|
var Keyframes = /* @__PURE__ */ ((Keyframes2) => {
|
|
558
559
|
Keyframes2["LoadingDots"] = "loadingDots";
|
|
@@ -8335,7 +8336,7 @@ function CompanionRowImpl(props) {
|
|
|
8335
8336
|
companion,
|
|
8336
8337
|
position = "trailing",
|
|
8337
8338
|
levelIndent,
|
|
8338
|
-
rowCss,
|
|
8339
|
+
rowCss: rowCss2,
|
|
8339
8340
|
cellCss
|
|
8340
8341
|
} = props;
|
|
8341
8342
|
const RowTag = as === "table" ? "tr" : "div";
|
|
@@ -8368,7 +8369,7 @@ function CompanionRowImpl(props) {
|
|
|
8368
8369
|
}]
|
|
8369
8370
|
},
|
|
8370
8371
|
...isLastBodyRow && style.lastRowCss,
|
|
8371
|
-
...
|
|
8372
|
+
...rowCss2
|
|
8372
8373
|
}), "data-gridrow": true, ...tid[rowId], children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CellTag, { ...(0, import_runtime17.trussProps)({
|
|
8373
8374
|
...style.cellCss,
|
|
8374
8375
|
...style.betweenRowsCss,
|
|
@@ -11016,7 +11017,7 @@ function RowImpl(props) {
|
|
|
11016
11017
|
}
|
|
11017
11018
|
};
|
|
11018
11019
|
const rowHoverBg = maybeCssVar(aiMode && !reservedRowKinds.includes(row.kind) ? "rgba(237, 233, 254, 1)" /* Purple100 */ : style.rowHoverColor !== void 0 && style.rowHoverColor !== "none" ? style.rowHoverColor : "--b-surface-hover" /* SurfaceHover */);
|
|
11019
|
-
const
|
|
11020
|
+
const rowCss2 = {
|
|
11020
11021
|
...!reservedRowKinds.includes(row.kind) && style.nonHeaderRowCss,
|
|
11021
11022
|
...isFirstBodyRow && style.firstBodyRowCss,
|
|
11022
11023
|
...isFirstHeadRow && style.firstRowCss,
|
|
@@ -11056,7 +11057,7 @@ function RowImpl(props) {
|
|
|
11056
11057
|
const ref = (0, import_react33.useRef)(null);
|
|
11057
11058
|
const dragOverCallback = (0, import_react33.useCallback)((row2, evt) => onDragOver?.(row2, evt), [onDragOver]);
|
|
11058
11059
|
const onDragOverDebounced = (0, import_use_debounce3.useDebouncedCallback)(dragOverCallback, 100);
|
|
11059
|
-
const RowContent = () => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(RowTag, { ...(0, import_runtime24.mergeProps)(`${BorderHoverParent}${showRowHoverColor ? ` ${RowHoverClass}` : ""}`, void 0,
|
|
11060
|
+
const RowContent = () => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(RowTag, { ...(0, import_runtime24.mergeProps)(`${BorderHoverParent}${showRowHoverColor ? ` ${RowHoverClass}` : ""}`, void 0, rowCss2), ...others, "data-gridrow": true, ...getCount(row.id), ref, children: isKeptGroupRow ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(KeptGroupRow, { as, style, columnSizes, row, colSpan: columns.length, isLastBodyRow }) : columns.map((column2, columnIndex) => {
|
|
11060
11061
|
const maybeExpandedColumn = expandColumnHidden ? columns[columnIndex - 1] : column2;
|
|
11061
11062
|
const isExpanded = tableState.isExpandedColumn(maybeExpandedColumn.id);
|
|
11062
11063
|
if (column2.hideOnExpand && isExpanded) {
|
|
@@ -32823,12 +32824,1011 @@ function Autocomplete(props) {
|
|
|
32823
32824
|
] });
|
|
32824
32825
|
}
|
|
32825
32826
|
|
|
32826
|
-
// src/inputs/
|
|
32827
|
+
// src/inputs/MenuSelectField/internal/AnchoredOverlay.tsx
|
|
32828
|
+
var import_react183 = require("react");
|
|
32829
|
+
var import_react_aria73 = require("react-aria");
|
|
32830
|
+
|
|
32831
|
+
// src/inputs/MenuSelectField/internal/useAnchoredPosition.ts
|
|
32827
32832
|
var import_react182 = require("react");
|
|
32828
32833
|
var import_react_aria72 = require("react-aria");
|
|
32829
|
-
|
|
32830
|
-
|
|
32834
|
+
function useAnchoredPosition(triggerRef, popoverRef, isOpen2) {
|
|
32835
|
+
const { overlayProps, updatePosition } = (0, import_react_aria72.useOverlayPosition)({
|
|
32836
|
+
targetRef: triggerRef,
|
|
32837
|
+
overlayRef: popoverRef,
|
|
32838
|
+
isOpen: isOpen2,
|
|
32839
|
+
shouldFlip: true,
|
|
32840
|
+
placement: "bottom start",
|
|
32841
|
+
offset: overlayOffset,
|
|
32842
|
+
containerPadding: viewportPadding,
|
|
32843
|
+
maxHeight: menuMaxHeight
|
|
32844
|
+
});
|
|
32845
|
+
(0, import_react182.useLayoutEffect)(() => {
|
|
32846
|
+
if (!isOpen2) return;
|
|
32847
|
+
const onScroll = (event) => {
|
|
32848
|
+
const target = event.target;
|
|
32849
|
+
if (!(target instanceof Node) || !triggerRef.current || !target.contains(triggerRef.current)) return;
|
|
32850
|
+
updatePosition();
|
|
32851
|
+
};
|
|
32852
|
+
window.addEventListener("scroll", onScroll, true);
|
|
32853
|
+
return () => window.removeEventListener("scroll", onScroll, true);
|
|
32854
|
+
}, [isOpen2, updatePosition, triggerRef]);
|
|
32855
|
+
(0, import_react182.useLayoutEffect)(() => {
|
|
32856
|
+
if (!isOpen2) return;
|
|
32857
|
+
applyMenuFrame(popoverRef.current, triggerRef.current);
|
|
32858
|
+
});
|
|
32859
|
+
return {
|
|
32860
|
+
...overlayProps,
|
|
32861
|
+
style: {
|
|
32862
|
+
...overlayProps.style,
|
|
32863
|
+
zIndex: zIndices.popover
|
|
32864
|
+
}
|
|
32865
|
+
};
|
|
32866
|
+
}
|
|
32867
|
+
var overlayOffset = 4;
|
|
32868
|
+
var viewportPadding = 8;
|
|
32869
|
+
var menuMaxHeight = 512;
|
|
32870
|
+
function applyMenuFrame(overlay, trigger) {
|
|
32871
|
+
if (!overlay) return;
|
|
32872
|
+
const height = overlay.style.maxHeight;
|
|
32873
|
+
if (height && overlay.style.getPropertyValue("--menu-max-height") !== height) {
|
|
32874
|
+
overlay.style.setProperty("--menu-max-height", height);
|
|
32875
|
+
}
|
|
32876
|
+
if (!trigger) return;
|
|
32877
|
+
const width2 = `${trigger.offsetWidth}px`;
|
|
32878
|
+
if (overlay.style.minWidth !== width2) overlay.style.minWidth = width2;
|
|
32879
|
+
}
|
|
32880
|
+
|
|
32881
|
+
// src/inputs/MenuSelectField/internal/AnchoredOverlay.tsx
|
|
32831
32882
|
var import_jsx_runtime265 = require("react/jsx-runtime");
|
|
32883
|
+
function AnchoredOverlay(props) {
|
|
32884
|
+
const { triggerRef, isOpen: isOpen2, onClose, children } = props;
|
|
32885
|
+
const popoverRef = (0, import_react183.useRef)(null);
|
|
32886
|
+
const tid = useTestIds(props, "anchoredOverlay");
|
|
32887
|
+
const positionProps = useAnchoredPosition(triggerRef, popoverRef, isOpen2);
|
|
32888
|
+
if (!isOpen2) return null;
|
|
32889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(
|
|
32890
|
+
Popover,
|
|
32891
|
+
{
|
|
32892
|
+
triggerRef,
|
|
32893
|
+
popoverRef,
|
|
32894
|
+
positionProps: { ...positionProps, ...tid.overlay },
|
|
32895
|
+
onClose,
|
|
32896
|
+
isOpen: isOpen2,
|
|
32897
|
+
shouldCloseOnInteractOutside: (el) => {
|
|
32898
|
+
if (!triggerRef.current?.contains(el) && shouldDismissOverlay(el, triggerRef.current)) onClose();
|
|
32899
|
+
return false;
|
|
32900
|
+
},
|
|
32901
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(import_react_aria73.FocusScope, { children })
|
|
32902
|
+
}
|
|
32903
|
+
);
|
|
32904
|
+
}
|
|
32905
|
+
|
|
32906
|
+
// src/inputs/MenuSelectField/internal/BottomSheet.tsx
|
|
32907
|
+
var import_react184 = require("react");
|
|
32908
|
+
var import_react_aria74 = require("react-aria");
|
|
32909
|
+
var import_react_dom11 = require("react-dom");
|
|
32910
|
+
var import_runtime173 = require("@homebound/truss/runtime");
|
|
32911
|
+
var import_jsx_runtime266 = require("react/jsx-runtime");
|
|
32912
|
+
function BottomSheet(props) {
|
|
32913
|
+
const {
|
|
32914
|
+
isOpen: isOpen2,
|
|
32915
|
+
onClose,
|
|
32916
|
+
label,
|
|
32917
|
+
children
|
|
32918
|
+
} = props;
|
|
32919
|
+
const frameRef = (0, import_react184.useRef)(null);
|
|
32920
|
+
const sheetRef = (0, import_react184.useRef)(null);
|
|
32921
|
+
const contrast = useContrastScope();
|
|
32922
|
+
const tid = useTestIds(props, "bottomSheet");
|
|
32923
|
+
useVisualViewportFrame(frameRef, isOpen2);
|
|
32924
|
+
(0, import_react_aria74.usePreventScroll)({
|
|
32925
|
+
isDisabled: !isOpen2
|
|
32926
|
+
});
|
|
32927
|
+
const {
|
|
32928
|
+
overlayProps,
|
|
32929
|
+
underlayProps
|
|
32930
|
+
} = (0, import_react_aria74.useOverlay)({
|
|
32931
|
+
isOpen: isOpen2,
|
|
32932
|
+
onClose,
|
|
32933
|
+
isDismissable: true
|
|
32934
|
+
}, sheetRef);
|
|
32935
|
+
const {
|
|
32936
|
+
dialogProps
|
|
32937
|
+
} = (0, import_react_aria74.useDialog)({
|
|
32938
|
+
"aria-label": label
|
|
32939
|
+
}, sheetRef);
|
|
32940
|
+
if (!isOpen2) return null;
|
|
32941
|
+
return (0, import_react_dom11.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime266.jsxs)("div", { ref: frameRef, ...(0, import_runtime173.trussProps)(frameCss), "data-theme": contrast ? contrastDataTheme : void 0, children: [
|
|
32942
|
+
/* @__PURE__ */ (0, import_jsx_runtime266.jsx)("div", { ...underlayProps, ...(0, import_runtime173.trussProps)(scrimCss), ...tid.sheetScrim }),
|
|
32943
|
+
/* @__PURE__ */ (0, import_jsx_runtime266.jsx)(import_react_aria74.FocusScope, { contain: true, restoreFocus: true, children: /* @__PURE__ */ (0, import_jsx_runtime266.jsxs)("div", { ...(0, import_react_aria74.mergeProps)(overlayProps, dialogProps), ref: sheetRef, ...(0, import_runtime173.trussProps)(sheetCss), ...tid.sheet, children: [
|
|
32944
|
+
/* @__PURE__ */ (0, import_jsx_runtime266.jsxs)("div", { ...(0, import_runtime173.trussProps)({
|
|
32945
|
+
display: "df",
|
|
32946
|
+
alignItems: "aic",
|
|
32947
|
+
justifyContent: "jcsb",
|
|
32948
|
+
gap: "g_1",
|
|
32949
|
+
paddingLeft: "pl2",
|
|
32950
|
+
paddingRight: "pr2",
|
|
32951
|
+
height: ["h_var", {
|
|
32952
|
+
"--height": `${sheetHeaderHeight}px`
|
|
32953
|
+
}],
|
|
32954
|
+
borderBottomStyle: "bbs_solid",
|
|
32955
|
+
borderBottomWidth: "bbw_1px",
|
|
32956
|
+
borderColor: ["bc_var", {
|
|
32957
|
+
"--borderColor": "var(--b-surface-separator)"
|
|
32958
|
+
}]
|
|
32959
|
+
}), children: [
|
|
32960
|
+
/* @__PURE__ */ (0, import_jsx_runtime266.jsx)("span", { className: "fw6 fz_14px lh_20px wsnw oh to_ellipsis", children: label }),
|
|
32961
|
+
/* @__PURE__ */ (0, import_jsx_runtime266.jsx)(Button, { label: "Done", variant: "tertiary", onClick: onClose, ...tid.sheetDone })
|
|
32962
|
+
] }),
|
|
32963
|
+
children
|
|
32964
|
+
] }) })
|
|
32965
|
+
] }), document.body);
|
|
32966
|
+
}
|
|
32967
|
+
function useVisualViewportFrame(frameRef, isOpen2) {
|
|
32968
|
+
(0, import_react184.useLayoutEffect)(() => {
|
|
32969
|
+
const frame = frameRef.current;
|
|
32970
|
+
if (!isOpen2 || !frame) return;
|
|
32971
|
+
let raf = 0;
|
|
32972
|
+
const apply = () => {
|
|
32973
|
+
raf = 0;
|
|
32974
|
+
const vv = window.visualViewport;
|
|
32975
|
+
const top = vv?.offsetTop ?? 0;
|
|
32976
|
+
const height = vv?.height ?? window.innerHeight;
|
|
32977
|
+
frame.style.top = `${top}px`;
|
|
32978
|
+
frame.style.height = `${height}px`;
|
|
32979
|
+
frame.style.setProperty("--menu-max-height", `${Math.max(0, Math.round(height * sheetMaxRatio) - sheetHeaderHeight)}px`);
|
|
32980
|
+
};
|
|
32981
|
+
const schedule = () => {
|
|
32982
|
+
if (!raf) raf = requestAnimationFrame(apply);
|
|
32983
|
+
};
|
|
32984
|
+
apply();
|
|
32985
|
+
window.visualViewport?.addEventListener("resize", schedule);
|
|
32986
|
+
window.visualViewport?.addEventListener("scroll", schedule);
|
|
32987
|
+
window.addEventListener("resize", schedule);
|
|
32988
|
+
return () => {
|
|
32989
|
+
if (raf) cancelAnimationFrame(raf);
|
|
32990
|
+
window.visualViewport?.removeEventListener("resize", schedule);
|
|
32991
|
+
window.visualViewport?.removeEventListener("scroll", schedule);
|
|
32992
|
+
window.removeEventListener("resize", schedule);
|
|
32993
|
+
};
|
|
32994
|
+
}, [frameRef, isOpen2]);
|
|
32995
|
+
}
|
|
32996
|
+
var sheetHeaderHeight = 48;
|
|
32997
|
+
var sheetMaxRatio = 0.85;
|
|
32998
|
+
var frameCss = {
|
|
32999
|
+
position: "fixed",
|
|
33000
|
+
left: "l_0",
|
|
33001
|
+
width: "w100",
|
|
33002
|
+
top: "top0",
|
|
33003
|
+
display: "df",
|
|
33004
|
+
flexDirection: "fdc",
|
|
33005
|
+
justifyContent: "jcfe",
|
|
33006
|
+
zIndex: ["z_var", {
|
|
33007
|
+
"--zIndex": (0, import_runtime173.maybeCssVar)(zIndices.popover)
|
|
33008
|
+
}]
|
|
33009
|
+
};
|
|
33010
|
+
var scrimCss = {
|
|
33011
|
+
position: "absolute",
|
|
33012
|
+
inset: "ins_0",
|
|
33013
|
+
backgroundColor: ["bgColor_var", {
|
|
33014
|
+
"--backgroundColor": "var(--b-scrim)"
|
|
33015
|
+
}]
|
|
33016
|
+
};
|
|
33017
|
+
var sheetCss = {
|
|
33018
|
+
...{
|
|
33019
|
+
position: "relative",
|
|
33020
|
+
display: "df",
|
|
33021
|
+
flexDirection: "fdc",
|
|
33022
|
+
width: "w100",
|
|
33023
|
+
backgroundColor: ["bgColor_var", {
|
|
33024
|
+
"--backgroundColor": "var(--b-surface-raised)"
|
|
33025
|
+
}],
|
|
33026
|
+
color: ["color_var", {
|
|
33027
|
+
"--color": "var(--b-on-surface)"
|
|
33028
|
+
}],
|
|
33029
|
+
boxShadow: "bshModal",
|
|
33030
|
+
outline: "ol_0",
|
|
33031
|
+
bottom: "bot_0px"
|
|
33032
|
+
},
|
|
33033
|
+
...{
|
|
33034
|
+
borderTopLeftRadius: "btlr_12px",
|
|
33035
|
+
borderTopRightRadius: "btrr_12px",
|
|
33036
|
+
paddingBottom: "pb_env_safe_area_inset_bottom"
|
|
33037
|
+
}
|
|
33038
|
+
};
|
|
33039
|
+
|
|
33040
|
+
// src/inputs/MenuSelectField/internal/MenuPanel.tsx
|
|
33041
|
+
var import_runtime174 = require("@homebound/truss/runtime");
|
|
33042
|
+
var import_jsx_runtime267 = require("react/jsx-runtime");
|
|
33043
|
+
function MenuPanel(props) {
|
|
33044
|
+
const {
|
|
33045
|
+
header,
|
|
33046
|
+
children,
|
|
33047
|
+
variant = "anchored"
|
|
33048
|
+
} = props;
|
|
33049
|
+
const tid = useTestIds(props, "menuPanel");
|
|
33050
|
+
return /* @__PURE__ */ (0, import_jsx_runtime267.jsxs)("div", { ...(0, import_runtime174.trussProps)({
|
|
33051
|
+
...panelCss,
|
|
33052
|
+
...variant === "anchored" ? anchoredCss : {}
|
|
33053
|
+
}), ...tid.menuPanel, children: [
|
|
33054
|
+
header && /* @__PURE__ */ (0, import_jsx_runtime267.jsx)("div", { ...(0, import_runtime174.trussProps)({
|
|
33055
|
+
flexShrink: "fs0",
|
|
33056
|
+
borderBottomStyle: "bbs_solid",
|
|
33057
|
+
borderBottomWidth: "bbw_1px",
|
|
33058
|
+
borderColor: ["bc_var", {
|
|
33059
|
+
"--borderColor": "var(--b-surface-separator)"
|
|
33060
|
+
}]
|
|
33061
|
+
}), children: header }),
|
|
33062
|
+
/* @__PURE__ */ (0, import_jsx_runtime267.jsx)("div", { className: "df fdc fg1 mh0", children })
|
|
33063
|
+
] });
|
|
33064
|
+
}
|
|
33065
|
+
var panelCss = {
|
|
33066
|
+
display: "df",
|
|
33067
|
+
flexDirection: "fdc",
|
|
33068
|
+
width: "w100",
|
|
33069
|
+
overflow: "oh",
|
|
33070
|
+
color: ["color_var", {
|
|
33071
|
+
"--color": "var(--b-on-surface)"
|
|
33072
|
+
}],
|
|
33073
|
+
maxHeight: "maxh_var_menu_max_height_512px"
|
|
33074
|
+
};
|
|
33075
|
+
var anchoredCss = {
|
|
33076
|
+
backgroundColor: ["bgColor_var", {
|
|
33077
|
+
"--backgroundColor": "var(--b-surface-raised)"
|
|
33078
|
+
}],
|
|
33079
|
+
borderRadius: "br4",
|
|
33080
|
+
boxShadow: "bshBasic"
|
|
33081
|
+
};
|
|
33082
|
+
|
|
33083
|
+
// src/inputs/MenuSelectField/internal/MenuSearchInput.tsx
|
|
33084
|
+
var import_runtime175 = require("@homebound/truss/runtime");
|
|
33085
|
+
var import_jsx_runtime268 = require("react/jsx-runtime");
|
|
33086
|
+
function MenuSearchInput(props) {
|
|
33087
|
+
const {
|
|
33088
|
+
search,
|
|
33089
|
+
inputRef,
|
|
33090
|
+
label,
|
|
33091
|
+
placeholder = "Search"
|
|
33092
|
+
} = props;
|
|
33093
|
+
const tid = useTestIds(props, "menuSearch");
|
|
33094
|
+
return /* @__PURE__ */ (0, import_jsx_runtime268.jsxs)("label", { className: "df aic g_1 pl2 pr2 h_48px cur_text", children: [
|
|
33095
|
+
/* @__PURE__ */ (0, import_jsx_runtime268.jsx)("span", { ...(0, import_runtime175.trussProps)({
|
|
33096
|
+
display: "df",
|
|
33097
|
+
alignItems: "aic",
|
|
33098
|
+
flexShrink: "fs0",
|
|
33099
|
+
color: ["color_var", {
|
|
33100
|
+
"--color": "var(--b-on-surface-muted)"
|
|
33101
|
+
}]
|
|
33102
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(Icon, { icon: "search" }) }),
|
|
33103
|
+
/* @__PURE__ */ (0, import_jsx_runtime268.jsx)("input", { ref: inputRef, type: "text", role: "combobox", "aria-label": label, "aria-autocomplete": "list", "aria-expanded": true, "aria-controls": search.listId, "aria-activedescendant": search.activeDescendant, autoComplete: "off", autoCorrect: "off", spellCheck: false, enterKeyHint: "done", placeholder, value: search.value, onChange: (e) => search.onChange(e.target.value), onKeyDown: search.onKeyDown, ...(0, import_runtime175.trussProps)(inputCss), ...tid.search })
|
|
33104
|
+
] });
|
|
33105
|
+
}
|
|
33106
|
+
var inputCss = {
|
|
33107
|
+
...{
|
|
33108
|
+
flexGrow: "fg1",
|
|
33109
|
+
minWidth: "mw0",
|
|
33110
|
+
outline: "ol_0",
|
|
33111
|
+
backgroundColor: "bgTransparent",
|
|
33112
|
+
fontWeight: "fw4",
|
|
33113
|
+
fontSize: "fz_14px",
|
|
33114
|
+
lineHeight: "lh_20px",
|
|
33115
|
+
color: ["color_var", {
|
|
33116
|
+
"--color": "var(--b-on-surface)"
|
|
33117
|
+
}]
|
|
33118
|
+
},
|
|
33119
|
+
// iOS zooms the page when a focused input is under 16px.
|
|
33120
|
+
...{
|
|
33121
|
+
fontSize: "sm_fs_16px"
|
|
33122
|
+
}
|
|
33123
|
+
};
|
|
33124
|
+
|
|
33125
|
+
// src/inputs/MenuSelectField/internal/MenuSelectTrigger.tsx
|
|
33126
|
+
var import_react_aria75 = require("react-aria");
|
|
33127
|
+
var import_runtime176 = require("@homebound/truss/runtime");
|
|
33128
|
+
var import_jsx_runtime269 = require("react/jsx-runtime");
|
|
33129
|
+
function MenuSelectTrigger(props) {
|
|
33130
|
+
const {
|
|
33131
|
+
label,
|
|
33132
|
+
required,
|
|
33133
|
+
errorMsg,
|
|
33134
|
+
helperText,
|
|
33135
|
+
disabled,
|
|
33136
|
+
readOnly,
|
|
33137
|
+
labelStyle: labelStyleProp,
|
|
33138
|
+
inputStylePalette,
|
|
33139
|
+
trigger,
|
|
33140
|
+
triggerRef
|
|
33141
|
+
} = props;
|
|
33142
|
+
const internalProps = props.internalProps ?? {};
|
|
33143
|
+
const {
|
|
33144
|
+
compound = false,
|
|
33145
|
+
forceFocus = false,
|
|
33146
|
+
forceHover = false
|
|
33147
|
+
} = internalProps;
|
|
33148
|
+
const tid = useTestIds(props, defaultTestId(label));
|
|
33149
|
+
const {
|
|
33150
|
+
fieldProps
|
|
33151
|
+
} = usePresentationContext();
|
|
33152
|
+
const labelStyle = labelStyleProp ?? fieldProps?.labelStyle ?? "above";
|
|
33153
|
+
const compact = props.compact ?? fieldProps?.compact ?? false;
|
|
33154
|
+
const borderless = props.borderless ?? fieldProps?.borderless ?? false;
|
|
33155
|
+
const borderOnHover = props.borderOnHover ?? fieldProps?.borderOnHover ?? false;
|
|
33156
|
+
const fullWidth = props.fullWidth ?? fieldProps?.fullWidth ?? false;
|
|
33157
|
+
const visuallyDisabled = props.visuallyDisabled ?? fieldProps?.visuallyDisabled ?? true;
|
|
33158
|
+
const errorInTooltip = props.errorInTooltip ?? fieldProps?.errorInTooltip ?? false;
|
|
33159
|
+
const typeScale = fieldProps?.typeScale ?? "sm";
|
|
33160
|
+
const labelSuffix = useLabelSuffix(required, trigger.isReadOnly);
|
|
33161
|
+
const showFocus = (trigger.isFocusVisible || trigger.isOpen) && !trigger.isDisabled && !trigger.isReadOnly || forceFocus;
|
|
33162
|
+
const showHover = trigger.isHovered && !trigger.isDisabled && !trigger.isReadOnly && !showFocus || forceHover;
|
|
33163
|
+
const showErrorAndHelper = !compound && !trigger.isDisabled && !trigger.isReadOnly;
|
|
33164
|
+
const {
|
|
33165
|
+
proposedValue: proposedText,
|
|
33166
|
+
originalValue: originalText
|
|
33167
|
+
} = trigger.proposalProps;
|
|
33168
|
+
const showProposal = proposedText !== void 0;
|
|
33169
|
+
const originalBelow = originalText && !trigger.isReadOnly ? originalText : void 0;
|
|
33170
|
+
const fieldChrome = getFieldChrome({
|
|
33171
|
+
typeScale,
|
|
33172
|
+
labelStyle,
|
|
33173
|
+
labelLeftFieldWidth: fieldProps?.labelLeftFieldWidth,
|
|
33174
|
+
compact,
|
|
33175
|
+
borderless,
|
|
33176
|
+
borderOnHover,
|
|
33177
|
+
fullWidth,
|
|
33178
|
+
compound,
|
|
33179
|
+
visuallyDisabled,
|
|
33180
|
+
isHovered: trigger.isHovered || forceHover,
|
|
33181
|
+
showProposal,
|
|
33182
|
+
inputStylePalette
|
|
33183
|
+
});
|
|
33184
|
+
const fieldStateCss = {
|
|
33185
|
+
...fieldChrome.control,
|
|
33186
|
+
...trigger.isDisabled ? fieldChrome.disabled : {},
|
|
33187
|
+
...showFocus ? fieldChrome.focus : {},
|
|
33188
|
+
...showHover ? fieldChrome.hover : {},
|
|
33189
|
+
...errorMsg && !trigger.isDisabled ? fieldChrome.error : {},
|
|
33190
|
+
...{
|
|
33191
|
+
textAlign: "tal",
|
|
33192
|
+
outline: "ol_0",
|
|
33193
|
+
appearance: "app_none",
|
|
33194
|
+
font: "fnt_inherit",
|
|
33195
|
+
...!trigger.isDisabled ? {
|
|
33196
|
+
cursor: "cur_pointer"
|
|
33197
|
+
} : {}
|
|
33198
|
+
}
|
|
33199
|
+
};
|
|
33200
|
+
const supporting = /* @__PURE__ */ (0, import_jsx_runtime269.jsxs)(import_jsx_runtime269.Fragment, { children: [
|
|
33201
|
+
originalBelow && /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(OriginalValue, { originalValue: originalBelow, ...tid.originalValue }),
|
|
33202
|
+
showErrorAndHelper && errorMsg && !errorInTooltip && /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(ErrorMessage, { id: trigger.errorId, errorMsg, ...tid.errorMsg }),
|
|
33203
|
+
showErrorAndHelper && helperText && /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(HelperText, { helperText, ...tid.helperText })
|
|
33204
|
+
] });
|
|
33205
|
+
const hasSupporting = !!(originalBelow || showErrorAndHelper && (errorMsg || helperText));
|
|
33206
|
+
const valueNode = /* @__PURE__ */ (0, import_jsx_runtime269.jsxs)(import_jsx_runtime269.Fragment, { children: [
|
|
33207
|
+
labelStyle === "inline" && /* @__PURE__ */ (0, import_jsx_runtime269.jsxs)("span", { id: trigger.labelId, ...(0, import_runtime176.trussProps)({
|
|
33208
|
+
fontWeight: "fw4",
|
|
33209
|
+
fontSize: "fz_14px",
|
|
33210
|
+
lineHeight: "lh_20px",
|
|
33211
|
+
whiteSpace: "wsnw",
|
|
33212
|
+
paddingRight: "pr_4px",
|
|
33213
|
+
color: ["color_var", {
|
|
33214
|
+
"--color": (0, import_runtime176.maybeCssVar)(trigger.isDisabled && visuallyDisabled ? "currentColor" : "--b-text-label" /* TextLabel */)
|
|
33215
|
+
}]
|
|
33216
|
+
}), children: [
|
|
33217
|
+
label,
|
|
33218
|
+
":"
|
|
33219
|
+
] }),
|
|
33220
|
+
/* @__PURE__ */ (0, import_jsx_runtime269.jsx)("span", { id: trigger.valueId, className: "df aic fg1 mw0 oh", children: trigger.isReadOnly && showProposal ? /* @__PURE__ */ (0, import_jsx_runtime269.jsx)("span", { className: "fg1 wsnw oh to_ellipsis", children: /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(ProposedValue, { original: originalText, proposed: proposedText, ...tid.proposedValue }) }) : /* @__PURE__ */ (0, import_jsx_runtime269.jsx)("span", { ...(0, import_runtime176.trussProps)({
|
|
33221
|
+
...{
|
|
33222
|
+
flexGrow: "fg1",
|
|
33223
|
+
whiteSpace: "wsnw",
|
|
33224
|
+
overflow: "oh",
|
|
33225
|
+
textOverflow: "to_ellipsis",
|
|
33226
|
+
color: ["color_var", {
|
|
33227
|
+
"--color": (0, import_runtime176.maybeCssVar)(trigger.isPlaceholder ? inputPlaceholderColor : void 0)
|
|
33228
|
+
}]
|
|
33229
|
+
},
|
|
33230
|
+
// A placeholder reads as hint text, so it stays at the field's regular weight.
|
|
33231
|
+
...!trigger.isPlaceholder ? selectedValueCss(labelStyle, trigger.isReadOnly) : {},
|
|
33232
|
+
...showProposal ? {
|
|
33233
|
+
fontWeight: "fw6",
|
|
33234
|
+
color: ["color_var", {
|
|
33235
|
+
"--color": "var(--b-ai-field-fg)"
|
|
33236
|
+
}]
|
|
33237
|
+
} : {}
|
|
33238
|
+
}), children: trigger.displayText }) }),
|
|
33239
|
+
errorInTooltip && errorMsg && showErrorAndHelper && /* @__PURE__ */ (0, import_jsx_runtime269.jsx)("span", { className: "df aic fs0 pl1", children: /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(Icon, { icon: "error", color: "--b-danger" /* Danger */, tooltip: errorMsg }) }),
|
|
33240
|
+
!trigger.isReadOnly && /* @__PURE__ */ (0, import_jsx_runtime269.jsx)("span", { ...(0, import_runtime176.trussProps)({
|
|
33241
|
+
display: "df",
|
|
33242
|
+
alignItems: "aic",
|
|
33243
|
+
flexShrink: "fs0",
|
|
33244
|
+
paddingLeft: "pl1",
|
|
33245
|
+
color: ["color_var", {
|
|
33246
|
+
"--color": (0, import_runtime176.maybeCssVar)(trigger.isDisabled ? "--b-field-text-disabled" /* FieldTextDisabled */ : "--b-text-placeholder" /* TextPlaceholder */)
|
|
33247
|
+
}]
|
|
33248
|
+
}), ...tid.toggle, children: /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(Icon, { icon: trigger.isOpen ? "chevronUp" : "chevronDown" }) })
|
|
33249
|
+
] });
|
|
33250
|
+
return /* @__PURE__ */ (0, import_jsx_runtime269.jsxs)(import_jsx_runtime269.Fragment, { children: [
|
|
33251
|
+
/* @__PURE__ */ (0, import_jsx_runtime269.jsxs)("div", { ...(0, import_runtime176.trussProps)(fieldChrome.container), children: [
|
|
33252
|
+
label && labelStyle !== "inline" && /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(Label, { labelProps: {
|
|
33253
|
+
id: trigger.labelId,
|
|
33254
|
+
htmlFor: trigger.isReadOnly ? void 0 : trigger.triggerId,
|
|
33255
|
+
onClick: (event) => {
|
|
33256
|
+
event.preventDefault();
|
|
33257
|
+
if (trigger.isDisabled || trigger.isReadOnly || trigger.isOpen) return;
|
|
33258
|
+
triggerRef.current?.focus();
|
|
33259
|
+
trigger.open();
|
|
33260
|
+
}
|
|
33261
|
+
}, hidden: labelStyle === "hidden", label, inline: labelStyle === "left", suffix: labelSuffix, ...tid.label }),
|
|
33262
|
+
maybeTooltip({
|
|
33263
|
+
title: resolveTooltip(disabled, void 0, readOnly),
|
|
33264
|
+
placement: "top",
|
|
33265
|
+
children: trigger.isReadOnly ? /* @__PURE__ */ (0, import_jsx_runtime269.jsx)("div", { ...(0, import_runtime176.trussProps)(fieldChrome.readOnly), "data-readonly": "true", "data-ai-mode": showProposal ? "true" : void 0, ...tid, children: valueNode }) : /* @__PURE__ */ (0, import_jsx_runtime269.jsx)("button", { ...(0, import_react_aria75.mergeProps)(trigger.hoverProps, trigger.focusProps, {
|
|
33266
|
+
id: trigger.triggerId,
|
|
33267
|
+
type: "button",
|
|
33268
|
+
disabled: trigger.isDisabled,
|
|
33269
|
+
"aria-haspopup": "listbox",
|
|
33270
|
+
"aria-expanded": trigger.isOpen,
|
|
33271
|
+
"aria-controls": trigger.listId,
|
|
33272
|
+
"aria-labelledby": `${trigger.labelId} ${trigger.valueId}`,
|
|
33273
|
+
"aria-invalid": errorMsg ? true : void 0,
|
|
33274
|
+
"aria-errormessage": errorMsg ? trigger.errorId : void 0,
|
|
33275
|
+
"data-ai-mode": showProposal ? "true" : void 0,
|
|
33276
|
+
onKeyDown: trigger.onKeyDown,
|
|
33277
|
+
onClick: () => trigger.isOpen ? trigger.close({
|
|
33278
|
+
restoreFocus: true
|
|
33279
|
+
}) : trigger.open(),
|
|
33280
|
+
onFocus: trigger.onFocus,
|
|
33281
|
+
onBlur: trigger.onBlur
|
|
33282
|
+
}), ref: triggerRef, ...(0, import_runtime176.mergeProps)(BorderHoverChild, void 0, fieldStateCss), ...tid, children: valueNode })
|
|
33283
|
+
}),
|
|
33284
|
+
labelStyle !== "left" && supporting
|
|
33285
|
+
] }),
|
|
33286
|
+
labelStyle === "left" && hasSupporting && /* @__PURE__ */ (0, import_jsx_runtime269.jsx)("div", { className: "mt_neg1 ml_50", children: supporting })
|
|
33287
|
+
] });
|
|
33288
|
+
}
|
|
33289
|
+
var inputPlaceholderColor = "#9ca3af";
|
|
33290
|
+
|
|
33291
|
+
// src/inputs/MenuSelectField/internal/OptionList.tsx
|
|
33292
|
+
var import_interactions2 = require("@react-aria/interactions");
|
|
33293
|
+
var import_react186 = require("react");
|
|
33294
|
+
var import_react_aria77 = require("react-aria");
|
|
33295
|
+
var import_react_virtuoso3 = require("react-virtuoso");
|
|
33296
|
+
|
|
33297
|
+
// src/inputs/MenuSelectField/internal/OptionRow.tsx
|
|
33298
|
+
var import_react185 = require("react");
|
|
33299
|
+
var import_react_aria76 = require("react-aria");
|
|
33300
|
+
var import_runtime177 = require("@homebound/truss/runtime");
|
|
33301
|
+
var import_jsx_runtime270 = require("react/jsx-runtime");
|
|
33302
|
+
function OptionRow(props) {
|
|
33303
|
+
const {
|
|
33304
|
+
item,
|
|
33305
|
+
state,
|
|
33306
|
+
id,
|
|
33307
|
+
disabledReason
|
|
33308
|
+
} = props;
|
|
33309
|
+
const ref = (0, import_react185.useRef)(null);
|
|
33310
|
+
const tid = useTestIds(props, "option");
|
|
33311
|
+
const {
|
|
33312
|
+
hoverProps,
|
|
33313
|
+
isHovered
|
|
33314
|
+
} = (0, import_react_aria76.useHover)({});
|
|
33315
|
+
const {
|
|
33316
|
+
optionProps,
|
|
33317
|
+
isDisabled,
|
|
33318
|
+
isFocused,
|
|
33319
|
+
isSelected
|
|
33320
|
+
} = (0, import_react_aria76.useOption)({
|
|
33321
|
+
key: item.key,
|
|
33322
|
+
shouldSelectOnPressUp: true,
|
|
33323
|
+
shouldFocusOnHover: false
|
|
33324
|
+
}, state, ref);
|
|
33325
|
+
const highlighted = !isDisabled && (isHovered || isFocused);
|
|
33326
|
+
return maybeTooltip({
|
|
33327
|
+
title: disabledReason,
|
|
33328
|
+
placement: "top",
|
|
33329
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime270.jsxs)(
|
|
33330
|
+
"div",
|
|
33331
|
+
{
|
|
33332
|
+
...(0, import_react_aria76.mergeProps)(optionProps, hoverProps),
|
|
33333
|
+
id,
|
|
33334
|
+
"data-key": item.key,
|
|
33335
|
+
"data-label": item.textValue,
|
|
33336
|
+
ref,
|
|
33337
|
+
...(0, import_runtime177.trussProps)({
|
|
33338
|
+
...rowCss,
|
|
33339
|
+
...highlighted ? {
|
|
33340
|
+
backgroundColor: ["bgColor_var", {
|
|
33341
|
+
"--backgroundColor": "var(--b-surface-raised-hover)"
|
|
33342
|
+
}]
|
|
33343
|
+
} : {},
|
|
33344
|
+
...isDisabled ? {
|
|
33345
|
+
cursor: "cur_not_allowed",
|
|
33346
|
+
color: ["color_var", {
|
|
33347
|
+
"--color": "var(--b-text-disabled)"
|
|
33348
|
+
}]
|
|
33349
|
+
} : {}
|
|
33350
|
+
}),
|
|
33351
|
+
...tid.option,
|
|
33352
|
+
children: [
|
|
33353
|
+
/* @__PURE__ */ (0, import_jsx_runtime270.jsx)("span", { className: "wsnw oh to_ellipsis fg1 mw0", children: item.rendered }),
|
|
33354
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime270.jsx)("span", { className: "df aic fs0", children: /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(Icon, { icon: "check", color: isDisabled ? "--b-text-disabled" /* TextDisabled */ : "--b-selection-indicator" /* SelectionIndicator */ }) })
|
|
33355
|
+
]
|
|
33356
|
+
}
|
|
33357
|
+
)
|
|
33358
|
+
});
|
|
33359
|
+
}
|
|
33360
|
+
var menuRowHeight = 40;
|
|
33361
|
+
var rowCss = {
|
|
33362
|
+
display: "df",
|
|
33363
|
+
alignItems: "aic",
|
|
33364
|
+
gap: "g_1",
|
|
33365
|
+
paddingLeft: "pl2",
|
|
33366
|
+
paddingRight: "pr2",
|
|
33367
|
+
height: ["h_var", {
|
|
33368
|
+
"--height": `${menuRowHeight}px`
|
|
33369
|
+
}],
|
|
33370
|
+
outline: "ol_0",
|
|
33371
|
+
cursor: "cur_pointer",
|
|
33372
|
+
fontWeight: "fw4",
|
|
33373
|
+
fontSize: "fz_14px",
|
|
33374
|
+
lineHeight: "lh_20px",
|
|
33375
|
+
color: ["color_var", {
|
|
33376
|
+
"--color": "var(--b-on-surface)"
|
|
33377
|
+
}]
|
|
33378
|
+
};
|
|
33379
|
+
|
|
33380
|
+
// src/inputs/MenuSelectField/internal/OptionList.tsx
|
|
33381
|
+
var import_runtime178 = require("@homebound/truss/runtime");
|
|
33382
|
+
var import_jsx_runtime271 = require("react/jsx-runtime");
|
|
33383
|
+
function OptionList(props) {
|
|
33384
|
+
const {
|
|
33385
|
+
menu,
|
|
33386
|
+
listRef,
|
|
33387
|
+
label,
|
|
33388
|
+
onKeyDown,
|
|
33389
|
+
activeDescendant
|
|
33390
|
+
} = props;
|
|
33391
|
+
const {
|
|
33392
|
+
state,
|
|
33393
|
+
listId: id,
|
|
33394
|
+
disabledReasons,
|
|
33395
|
+
initialIndex,
|
|
33396
|
+
loading
|
|
33397
|
+
} = menu;
|
|
33398
|
+
const tid = useTestIds(props, "optionList");
|
|
33399
|
+
const virtuosoRef = (0, import_react186.useRef)(null);
|
|
33400
|
+
const {
|
|
33401
|
+
listBoxProps
|
|
33402
|
+
} = (0, import_react_aria77.useListBox)({
|
|
33403
|
+
id,
|
|
33404
|
+
"aria-label": label,
|
|
33405
|
+
autoFocus: false,
|
|
33406
|
+
shouldUseVirtualFocus: true,
|
|
33407
|
+
shouldFocusOnHover: false,
|
|
33408
|
+
shouldSelectOnPressUp: true,
|
|
33409
|
+
isVirtualized: true
|
|
33410
|
+
}, state, listRef);
|
|
33411
|
+
const items = [...state.collection];
|
|
33412
|
+
const focusedKey = state.selectionManager.focusedKey;
|
|
33413
|
+
(0, import_react186.useEffect)(() => {
|
|
33414
|
+
if (focusedKey == null || (0, import_interactions2.getInteractionModality)() !== "keyboard") return;
|
|
33415
|
+
const index = state.collection.getItem(focusedKey)?.index;
|
|
33416
|
+
if (index !== void 0) virtuosoRef.current?.scrollIntoView({
|
|
33417
|
+
index,
|
|
33418
|
+
behavior: "auto"
|
|
33419
|
+
});
|
|
33420
|
+
}, [focusedKey, state.collection]);
|
|
33421
|
+
const [{
|
|
33422
|
+
initialTop,
|
|
33423
|
+
initialCount
|
|
33424
|
+
}] = (0, import_react186.useState)(() => ({
|
|
33425
|
+
initialTop: Math.max(0, Math.min(initialIndex, items.length - 1)),
|
|
33426
|
+
initialCount: items.length
|
|
33427
|
+
}));
|
|
33428
|
+
const syncScroll = initialTop + initialRenderCount <= maxSyncRenderCount;
|
|
33429
|
+
(0, import_react186.useLayoutEffect)(() => {
|
|
33430
|
+
const scroller = listRef.current?.firstElementChild;
|
|
33431
|
+
if (!syncScroll || !scroller) return;
|
|
33432
|
+
const maxTop = Math.max(0, initialCount * menuRowHeight - scroller.clientHeight);
|
|
33433
|
+
setScrollTop(scroller, Math.min(initialTop * menuRowHeight, maxTop));
|
|
33434
|
+
}, [listRef, syncScroll, initialTop, initialCount]);
|
|
33435
|
+
const isTest = process.env.NODE_ENV === "test";
|
|
33436
|
+
return /* @__PURE__ */ (0, import_jsx_runtime271.jsx)("div", { ...listBoxProps, ...onKeyDown ? {
|
|
33437
|
+
onKeyDown,
|
|
33438
|
+
tabIndex: -1,
|
|
33439
|
+
"aria-activedescendant": activeDescendant
|
|
33440
|
+
} : {}, ref: listRef, className: "df fdc fg1 mh0 ol_0", ...tid.listbox, children: items.length === 0 && !loading ? /* @__PURE__ */ (0, import_jsx_runtime271.jsx)("div", { role: "presentation", ...(0, import_runtime178.trussProps)(emptyCss), ...tid.empty, children: "No results" }) : /* @__PURE__ */ (0, import_jsx_runtime271.jsxs)(import_jsx_runtime271.Fragment, { children: [
|
|
33441
|
+
items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(import_react_virtuoso3.Virtuoso, { ref: virtuosoRef, style: {
|
|
33442
|
+
height: items.length * menuRowHeight,
|
|
33443
|
+
flexShrink: 1,
|
|
33444
|
+
minHeight: 0,
|
|
33445
|
+
overscrollBehavior: "contain"
|
|
33446
|
+
}, totalCount: items.length, fixedItemHeight: menuRowHeight, computeItemKey: (index) => String(items[index]?.key ?? index), ...isTest ? {
|
|
33447
|
+
initialItemCount: items.length
|
|
33448
|
+
} : syncScroll ? {
|
|
33449
|
+
initialItemCount: Math.min(items.length, initialTop + initialRenderCount)
|
|
33450
|
+
} : {
|
|
33451
|
+
initialTopMostItemIndex: initialTop
|
|
33452
|
+
}, itemContent: (index) => {
|
|
33453
|
+
const item = items[index];
|
|
33454
|
+
if (!item) return null;
|
|
33455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(OptionRow, { item, state, id: optionDomId(id, index), disabledReason: disabledReasons[String(item.key)], ...tid });
|
|
33456
|
+
} }, isTest ? items.length : "virtuoso"),
|
|
33457
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(LoadingDots, {})
|
|
33458
|
+
] }) });
|
|
33459
|
+
}
|
|
33460
|
+
function optionDomId(listId, index) {
|
|
33461
|
+
return `${listId}-option-${index}`;
|
|
33462
|
+
}
|
|
33463
|
+
function setScrollTop(el, top) {
|
|
33464
|
+
el.scrollTop = top;
|
|
33465
|
+
}
|
|
33466
|
+
var initialRenderCount = 13;
|
|
33467
|
+
var maxSyncRenderCount = 60;
|
|
33468
|
+
var emptyCss = {
|
|
33469
|
+
display: "df",
|
|
33470
|
+
alignItems: "aic",
|
|
33471
|
+
paddingLeft: "pl2",
|
|
33472
|
+
paddingRight: "pr2",
|
|
33473
|
+
height: ["h_var", {
|
|
33474
|
+
"--height": `${menuRowHeight}px`
|
|
33475
|
+
}],
|
|
33476
|
+
fontWeight: "fw4",
|
|
33477
|
+
fontSize: "fz_14px",
|
|
33478
|
+
lineHeight: "lh_20px",
|
|
33479
|
+
color: ["color_var", {
|
|
33480
|
+
"--color": "var(--b-on-surface-muted)"
|
|
33481
|
+
}]
|
|
33482
|
+
};
|
|
33483
|
+
|
|
33484
|
+
// src/inputs/MenuSelectField/internal/useMenuSelectField.tsx
|
|
33485
|
+
var import_react187 = require("react");
|
|
33486
|
+
var import_react_aria78 = require("react-aria");
|
|
33487
|
+
var import_react_stately20 = require("react-stately");
|
|
33488
|
+
var import_jsx_runtime272 = require("react/jsx-runtime");
|
|
33489
|
+
function useMenuSelectField(props) {
|
|
33490
|
+
const {
|
|
33491
|
+
options: optionsProp,
|
|
33492
|
+
getOptionValue = defaultOptionValue,
|
|
33493
|
+
getOptionLabel = defaultOptionLabel,
|
|
33494
|
+
getOptionMenuLabel,
|
|
33495
|
+
getOptionSearchText,
|
|
33496
|
+
disabledOptions,
|
|
33497
|
+
nothingSelectedText = "",
|
|
33498
|
+
placeholder,
|
|
33499
|
+
disabled,
|
|
33500
|
+
readOnly,
|
|
33501
|
+
onFocus,
|
|
33502
|
+
onBlur,
|
|
33503
|
+
value: propValue,
|
|
33504
|
+
proposedValue,
|
|
33505
|
+
onSelect
|
|
33506
|
+
} = props;
|
|
33507
|
+
const isDisabled = !!disabled;
|
|
33508
|
+
const isReadOnly = !!readOnly;
|
|
33509
|
+
const fieldId = (0, import_react187.useId)();
|
|
33510
|
+
const listId = `${fieldId}-listbox`;
|
|
33511
|
+
const triggerId = `${fieldId}-trigger`;
|
|
33512
|
+
const labelId = `${fieldId}-label`;
|
|
33513
|
+
const valueId = `${fieldId}-value`;
|
|
33514
|
+
const errorId = `${fieldId}-error`;
|
|
33515
|
+
const triggerRef = (0, import_react187.useRef)(null);
|
|
33516
|
+
const searchRef = (0, import_react187.useRef)(null);
|
|
33517
|
+
const listRef = (0, import_react187.useRef)(null);
|
|
33518
|
+
const hasFocusRef = (0, import_react187.useRef)(false);
|
|
33519
|
+
const [isOpen2, setIsOpen] = (0, import_react187.useState)(false);
|
|
33520
|
+
const [search, setSearch] = (0, import_react187.useState)("");
|
|
33521
|
+
const [optionsLoading, setOptionsLoading] = (0, import_react187.useState)(false);
|
|
33522
|
+
const didRequestOptionsRef = (0, import_react187.useRef)(false);
|
|
33523
|
+
const options = (0, import_react187.useMemo)(
|
|
33524
|
+
() => initializeOptions(optionsProp, getOptionValue, getOptionLabel, void 0, false),
|
|
33525
|
+
// getOptionValue and getOptionLabel are typically inline lambdas
|
|
33526
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
|
33527
|
+
[optionsProp]
|
|
33528
|
+
);
|
|
33529
|
+
const { hoverProps, isHovered } = (0, import_react_aria78.useHover)({});
|
|
33530
|
+
const { focusProps, isFocusVisible } = (0, import_react_aria78.useFocusRing)();
|
|
33531
|
+
const { contains } = (0, import_react_aria78.useFilter)({ sensitivity: "base" });
|
|
33532
|
+
const optionsByKey = (0, import_react187.useMemo)(
|
|
33533
|
+
() => new Map(options.map((o) => [valueToKey(getOptionValue(o)), o])),
|
|
33534
|
+
// getOptionValue is typically an inline lambda
|
|
33535
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
|
33536
|
+
[options]
|
|
33537
|
+
);
|
|
33538
|
+
const { effectiveValue: value, proposalProps } = useAiProposal(propValue, proposedValue, (v) => {
|
|
33539
|
+
const option = optionsByKey.get(valueToKey(v));
|
|
33540
|
+
return option === void 0 ? void 0 : getOptionLabel(option);
|
|
33541
|
+
});
|
|
33542
|
+
const selectedKeys = (0, import_react187.useMemo)(() => new Set(value === void 0 ? [] : [valueToKey(value)]), [value]);
|
|
33543
|
+
const filteredOptions = (0, import_react187.useMemo)(
|
|
33544
|
+
() => search ? options.filter((o) => matchesSearch(o, search, getOptionLabel, getOptionSearchText, contains)) : options,
|
|
33545
|
+
// getOptionLabel and getOptionSearchText are typically inline lambdas
|
|
33546
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
|
33547
|
+
[options, search, contains]
|
|
33548
|
+
);
|
|
33549
|
+
const [disabledKeys, disabledReasons] = (0, import_react187.useMemo)(() => {
|
|
33550
|
+
const tuples = (disabledOptions ?? []).map(disabledOptionToKeyedTuple);
|
|
33551
|
+
return [tuples.map(([k]) => String(k)), Object.fromEntries(tuples.map(([k, r]) => [String(k), r]))];
|
|
33552
|
+
}, [disabledOptions]);
|
|
33553
|
+
function onSelectionChange(keys) {
|
|
33554
|
+
if (keys === "all") return;
|
|
33555
|
+
const [key] = [...keys];
|
|
33556
|
+
if (key === void 0) {
|
|
33557
|
+
close({ restoreFocus: true });
|
|
33558
|
+
return;
|
|
33559
|
+
}
|
|
33560
|
+
const opt = optionsByKey.get(String(key));
|
|
33561
|
+
proposalProps.onUserEdit?.();
|
|
33562
|
+
onSelect(opt === void 0 ? void 0 : getOptionValue(opt), opt);
|
|
33563
|
+
close({ restoreFocus: true });
|
|
33564
|
+
}
|
|
33565
|
+
const state = (0, import_react_stately20.useListState)({
|
|
33566
|
+
items: filteredOptions,
|
|
33567
|
+
children: (o) => /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(import_react_stately20.Item, { textValue: getOptionLabel(o), children: getOptionMenuLabel ? getOptionMenuLabel(o) : getOptionLabel(o) }, valueToKey(getOptionValue(o))),
|
|
33568
|
+
selectionMode: "single",
|
|
33569
|
+
selectedKeys,
|
|
33570
|
+
disabledKeys,
|
|
33571
|
+
onSelectionChange
|
|
33572
|
+
});
|
|
33573
|
+
const { selectionManager } = state;
|
|
33574
|
+
const keyboardDelegate = (0, import_react187.useMemo)(
|
|
33575
|
+
() => new MenuSelectKeyboardDelegate({
|
|
33576
|
+
collection: state.collection,
|
|
33577
|
+
disabledKeys: state.disabledKeys,
|
|
33578
|
+
ref: listRef
|
|
33579
|
+
}),
|
|
33580
|
+
[state.collection, state.disabledKeys]
|
|
33581
|
+
);
|
|
33582
|
+
function open() {
|
|
33583
|
+
if (isDisabled || isReadOnly) return;
|
|
33584
|
+
setSearch("");
|
|
33585
|
+
setIsOpen(true);
|
|
33586
|
+
if (didRequestOptionsRef.current || Array.isArray(optionsProp)) return;
|
|
33587
|
+
didRequestOptionsRef.current = true;
|
|
33588
|
+
setOptionsLoading(true);
|
|
33589
|
+
void optionsProp.load().finally(() => setOptionsLoading(false));
|
|
33590
|
+
}
|
|
33591
|
+
function close(opts) {
|
|
33592
|
+
setIsOpen(false);
|
|
33593
|
+
setSearch("");
|
|
33594
|
+
if (opts.restoreFocus) {
|
|
33595
|
+
triggerRef.current?.focus({ preventScroll: true });
|
|
33596
|
+
} else if (hasFocusRef.current) {
|
|
33597
|
+
settleBlur();
|
|
33598
|
+
}
|
|
33599
|
+
}
|
|
33600
|
+
function settleBlur() {
|
|
33601
|
+
hasFocusRef.current = false;
|
|
33602
|
+
maybeCall(proposalProps.onUserBlur);
|
|
33603
|
+
maybeCall(onBlur);
|
|
33604
|
+
}
|
|
33605
|
+
const showSearch = options.length > searchOptionLimit;
|
|
33606
|
+
(0, import_react187.useLayoutEffect)(() => {
|
|
33607
|
+
if (!isOpen2) return;
|
|
33608
|
+
const keyTarget = showSearch ? searchRef.current : listRef.current;
|
|
33609
|
+
keyTarget?.focus({ preventScroll: true });
|
|
33610
|
+
selectionManager.setFocusedKey(null);
|
|
33611
|
+
selectionManager.setFocused(false);
|
|
33612
|
+
}, [isOpen2, showSearch]);
|
|
33613
|
+
function onSearchChange(value2) {
|
|
33614
|
+
setSearch(value2);
|
|
33615
|
+
selectionManager.setFocusedKey(null);
|
|
33616
|
+
selectionManager.setFocused(false);
|
|
33617
|
+
}
|
|
33618
|
+
function focusKey(key) {
|
|
33619
|
+
if (key == null) return;
|
|
33620
|
+
selectionManager.setFocused(true);
|
|
33621
|
+
selectionManager.setFocusedKey(key);
|
|
33622
|
+
}
|
|
33623
|
+
function onMenuKeyDown(e) {
|
|
33624
|
+
const current2 = selectionManager.focusedKey;
|
|
33625
|
+
switch (e.key) {
|
|
33626
|
+
case "ArrowDown":
|
|
33627
|
+
e.preventDefault();
|
|
33628
|
+
focusKey(
|
|
33629
|
+
current2 == null ? keyboardDelegate.getFirstKey() : keyboardDelegate.getKeyBelow(current2) ?? keyboardDelegate.getFirstKey()
|
|
33630
|
+
);
|
|
33631
|
+
break;
|
|
33632
|
+
case "ArrowUp":
|
|
33633
|
+
e.preventDefault();
|
|
33634
|
+
focusKey(
|
|
33635
|
+
current2 == null ? keyboardDelegate.getLastKey() : keyboardDelegate.getKeyAbove(current2) ?? keyboardDelegate.getLastKey()
|
|
33636
|
+
);
|
|
33637
|
+
break;
|
|
33638
|
+
case "PageDown":
|
|
33639
|
+
e.preventDefault();
|
|
33640
|
+
focusKey(current2 == null ? keyboardDelegate.getFirstKey() : keyboardDelegate.getKeyPageBelow(current2));
|
|
33641
|
+
break;
|
|
33642
|
+
case "PageUp":
|
|
33643
|
+
e.preventDefault();
|
|
33644
|
+
focusKey(current2 == null ? keyboardDelegate.getLastKey() : keyboardDelegate.getKeyPageAbove(current2));
|
|
33645
|
+
break;
|
|
33646
|
+
case "Home":
|
|
33647
|
+
e.preventDefault();
|
|
33648
|
+
focusKey(keyboardDelegate.getFirstKey());
|
|
33649
|
+
break;
|
|
33650
|
+
case "End":
|
|
33651
|
+
e.preventDefault();
|
|
33652
|
+
focusKey(keyboardDelegate.getLastKey());
|
|
33653
|
+
break;
|
|
33654
|
+
case "Enter": {
|
|
33655
|
+
e.preventDefault();
|
|
33656
|
+
const key = selectionManager.focusedKey;
|
|
33657
|
+
if (key != null && !state.disabledKeys.has(key)) selectionManager.select(key);
|
|
33658
|
+
break;
|
|
33659
|
+
}
|
|
33660
|
+
case "Escape":
|
|
33661
|
+
e.preventDefault();
|
|
33662
|
+
e.stopPropagation();
|
|
33663
|
+
close({ restoreFocus: true });
|
|
33664
|
+
break;
|
|
33665
|
+
case "Tab":
|
|
33666
|
+
e.preventDefault();
|
|
33667
|
+
close({ restoreFocus: true });
|
|
33668
|
+
break;
|
|
33669
|
+
default:
|
|
33670
|
+
break;
|
|
33671
|
+
}
|
|
33672
|
+
}
|
|
33673
|
+
function onTriggerKeyDown(e) {
|
|
33674
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
33675
|
+
e.preventDefault();
|
|
33676
|
+
open();
|
|
33677
|
+
}
|
|
33678
|
+
}
|
|
33679
|
+
function onTriggerFocus() {
|
|
33680
|
+
if (hasFocusRef.current) return;
|
|
33681
|
+
hasFocusRef.current = true;
|
|
33682
|
+
maybeCall(onFocus);
|
|
33683
|
+
}
|
|
33684
|
+
function onTriggerBlur() {
|
|
33685
|
+
if (isOpen2) return;
|
|
33686
|
+
settleBlur();
|
|
33687
|
+
}
|
|
33688
|
+
const focusedKey = selectionManager.focusedKey;
|
|
33689
|
+
const focusedIndex = focusedKey != null ? state.collection.getItem(focusedKey)?.index : void 0;
|
|
33690
|
+
const activeDescendant = isOpen2 && focusedIndex !== void 0 ? optionDomId(listId, focusedIndex) : void 0;
|
|
33691
|
+
const initialIndex = Math.max(
|
|
33692
|
+
0,
|
|
33693
|
+
filteredOptions.findIndex((o) => selectedKeys.has(valueToKey(getOptionValue(o))))
|
|
33694
|
+
);
|
|
33695
|
+
const selectedOption = value === void 0 ? void 0 : optionsByKey.get(valueToKey(value));
|
|
33696
|
+
const selectedText = selectedOption === void 0 ? "" : getOptionLabel(selectedOption);
|
|
33697
|
+
const displayText = selectedText || nothingSelectedText || placeholder || "";
|
|
33698
|
+
const isPlaceholder = !selectedText && !nothingSelectedText && !!placeholder;
|
|
33699
|
+
const triggerProps = {
|
|
33700
|
+
isDisabled,
|
|
33701
|
+
isReadOnly,
|
|
33702
|
+
isOpen: isOpen2,
|
|
33703
|
+
listId,
|
|
33704
|
+
triggerId,
|
|
33705
|
+
labelId,
|
|
33706
|
+
valueId,
|
|
33707
|
+
errorId,
|
|
33708
|
+
hoverProps,
|
|
33709
|
+
focusProps,
|
|
33710
|
+
isFocusVisible,
|
|
33711
|
+
isHovered,
|
|
33712
|
+
open,
|
|
33713
|
+
close,
|
|
33714
|
+
onKeyDown: onTriggerKeyDown,
|
|
33715
|
+
onFocus: onTriggerFocus,
|
|
33716
|
+
onBlur: onTriggerBlur,
|
|
33717
|
+
displayText,
|
|
33718
|
+
isPlaceholder,
|
|
33719
|
+
proposalProps
|
|
33720
|
+
};
|
|
33721
|
+
const searchProps = {
|
|
33722
|
+
show: showSearch,
|
|
33723
|
+
value: search,
|
|
33724
|
+
onChange: onSearchChange,
|
|
33725
|
+
listId,
|
|
33726
|
+
activeDescendant,
|
|
33727
|
+
onKeyDown: onMenuKeyDown
|
|
33728
|
+
};
|
|
33729
|
+
const menuProps = {
|
|
33730
|
+
isOpen: isOpen2,
|
|
33731
|
+
close,
|
|
33732
|
+
listId,
|
|
33733
|
+
state,
|
|
33734
|
+
loading: optionsLoading,
|
|
33735
|
+
disabledReasons,
|
|
33736
|
+
initialIndex,
|
|
33737
|
+
onKeyDown: onMenuKeyDown,
|
|
33738
|
+
activeDescendant
|
|
33739
|
+
};
|
|
33740
|
+
return { triggerRef, trigger: triggerProps, searchRef, search: searchProps, listRef, menu: menuProps };
|
|
33741
|
+
}
|
|
33742
|
+
function matchesSearch(option, query, getOptionLabel, getOptionSearchText, contains) {
|
|
33743
|
+
if (contains(getOptionLabel(option), query)) return true;
|
|
33744
|
+
const extra = getOptionSearchText?.(option);
|
|
33745
|
+
const terms = typeof extra === "string" ? [extra] : extra;
|
|
33746
|
+
return terms?.some((term) => contains(term, query)) ?? false;
|
|
33747
|
+
}
|
|
33748
|
+
var searchOptionLimit = 8;
|
|
33749
|
+
var MenuSelectKeyboardDelegate = class _MenuSelectKeyboardDelegate extends import_react_aria78.ListKeyboardDelegate {
|
|
33750
|
+
/** Rows skipped by Page Up / Page Down. */
|
|
33751
|
+
static pageSize = 10;
|
|
33752
|
+
getKeyPageBelow(key) {
|
|
33753
|
+
return this.stepKeys(key, "below");
|
|
33754
|
+
}
|
|
33755
|
+
getKeyPageAbove(key) {
|
|
33756
|
+
return this.stepKeys(key, "above");
|
|
33757
|
+
}
|
|
33758
|
+
stepKeys(key, direction) {
|
|
33759
|
+
let next = key;
|
|
33760
|
+
for (let index = 0; index < _MenuSelectKeyboardDelegate.pageSize; index += 1) {
|
|
33761
|
+
if (next == null) return next;
|
|
33762
|
+
const candidate = direction === "below" ? this.getKeyBelow(next) : this.getKeyAbove(next);
|
|
33763
|
+
if (candidate == null) return next;
|
|
33764
|
+
next = candidate;
|
|
33765
|
+
}
|
|
33766
|
+
return next;
|
|
33767
|
+
}
|
|
33768
|
+
};
|
|
33769
|
+
|
|
33770
|
+
// src/inputs/MenuSelectField/internal/BaseMenuSelectField.tsx
|
|
33771
|
+
var import_jsx_runtime273 = require("react/jsx-runtime");
|
|
33772
|
+
function BaseMenuSelectField(props) {
|
|
33773
|
+
const { label, searchPlaceholder } = props;
|
|
33774
|
+
const { triggerRef, trigger, searchRef, search, listRef, menu } = useMenuSelectField(props);
|
|
33775
|
+
const tid = useTestIds(props, defaultTestId(label));
|
|
33776
|
+
const { sm: isMobile } = useBreakpoint();
|
|
33777
|
+
const panel = /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(
|
|
33778
|
+
MenuPanel,
|
|
33779
|
+
{
|
|
33780
|
+
variant: isMobile ? "sheet" : "anchored",
|
|
33781
|
+
header: search.show ? /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(
|
|
33782
|
+
MenuSearchInput,
|
|
33783
|
+
{
|
|
33784
|
+
search,
|
|
33785
|
+
inputRef: searchRef,
|
|
33786
|
+
label: `Search ${label}`,
|
|
33787
|
+
placeholder: searchPlaceholder,
|
|
33788
|
+
...tid
|
|
33789
|
+
}
|
|
33790
|
+
) : void 0,
|
|
33791
|
+
...tid,
|
|
33792
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(
|
|
33793
|
+
OptionList,
|
|
33794
|
+
{
|
|
33795
|
+
menu,
|
|
33796
|
+
listRef,
|
|
33797
|
+
label,
|
|
33798
|
+
onKeyDown: search.show ? void 0 : menu.onKeyDown,
|
|
33799
|
+
activeDescendant: search.show ? void 0 : menu.activeDescendant,
|
|
33800
|
+
...tid
|
|
33801
|
+
}
|
|
33802
|
+
)
|
|
33803
|
+
}
|
|
33804
|
+
);
|
|
33805
|
+
return /* @__PURE__ */ (0, import_jsx_runtime273.jsxs)(import_jsx_runtime273.Fragment, { children: [
|
|
33806
|
+
/* @__PURE__ */ (0, import_jsx_runtime273.jsx)(MenuSelectTrigger, { ...props, trigger, triggerRef }),
|
|
33807
|
+
isMobile ? /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(BottomSheet, { isOpen: menu.isOpen, onClose: () => menu.close({ restoreFocus: true }), label, ...tid, children: panel }) : /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(
|
|
33808
|
+
AnchoredOverlay,
|
|
33809
|
+
{
|
|
33810
|
+
triggerRef,
|
|
33811
|
+
isOpen: menu.isOpen,
|
|
33812
|
+
onClose: () => menu.close({ restoreFocus: false }),
|
|
33813
|
+
...tid,
|
|
33814
|
+
children: panel
|
|
33815
|
+
}
|
|
33816
|
+
)
|
|
33817
|
+
] });
|
|
33818
|
+
}
|
|
33819
|
+
|
|
33820
|
+
// src/inputs/MenuSelectField/MenuSelectField.tsx
|
|
33821
|
+
var import_jsx_runtime274 = require("react/jsx-runtime");
|
|
33822
|
+
function MenuSelectField(props) {
|
|
33823
|
+
return /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(BaseMenuSelectField, { ...props });
|
|
33824
|
+
}
|
|
33825
|
+
|
|
33826
|
+
// src/inputs/ToggleButton.tsx
|
|
33827
|
+
var import_react188 = require("react");
|
|
33828
|
+
var import_react_aria79 = require("react-aria");
|
|
33829
|
+
var import_react_stately21 = require("react-stately");
|
|
33830
|
+
var import_runtime179 = require("@homebound/truss/runtime");
|
|
33831
|
+
var import_jsx_runtime275 = require("react/jsx-runtime");
|
|
32832
33832
|
function ToggleButton(props) {
|
|
32833
33833
|
const {
|
|
32834
33834
|
selected: isSelected = false,
|
|
@@ -32839,7 +33839,7 @@ function ToggleButton(props) {
|
|
|
32839
33839
|
__storyState,
|
|
32840
33840
|
...otherProps
|
|
32841
33841
|
} = props;
|
|
32842
|
-
const [asyncInProgress, setAsyncInProgress] = (0,
|
|
33842
|
+
const [asyncInProgress, setAsyncInProgress] = (0, import_react188.useState)(false);
|
|
32843
33843
|
const isDisabled = !!disabled || asyncInProgress;
|
|
32844
33844
|
const ariaProps = {
|
|
32845
33845
|
"aria-label": label,
|
|
@@ -32847,7 +33847,7 @@ function ToggleButton(props) {
|
|
|
32847
33847
|
isDisabled,
|
|
32848
33848
|
...otherProps
|
|
32849
33849
|
};
|
|
32850
|
-
const state = (0,
|
|
33850
|
+
const state = (0, import_react_stately21.useToggleState)({
|
|
32851
33851
|
...ariaProps,
|
|
32852
33852
|
onChange: (e) => {
|
|
32853
33853
|
const result = onChange(e);
|
|
@@ -32858,30 +33858,30 @@ function ToggleButton(props) {
|
|
|
32858
33858
|
return result;
|
|
32859
33859
|
}
|
|
32860
33860
|
});
|
|
32861
|
-
const labelRef = (0,
|
|
32862
|
-
const ref = (0,
|
|
33861
|
+
const labelRef = (0, import_react188.useRef)(null);
|
|
33862
|
+
const ref = (0, import_react188.useRef)(null);
|
|
32863
33863
|
const tid = useTestIds(otherProps, label);
|
|
32864
33864
|
const {
|
|
32865
33865
|
isPressed: isPressedFromEvents,
|
|
32866
33866
|
pressProps
|
|
32867
|
-
} = (0,
|
|
33867
|
+
} = (0, import_react_aria79.usePress)({
|
|
32868
33868
|
ref: labelRef,
|
|
32869
33869
|
isDisabled
|
|
32870
33870
|
});
|
|
32871
33871
|
const {
|
|
32872
33872
|
inputProps
|
|
32873
|
-
} = (0,
|
|
33873
|
+
} = (0, import_react_aria79.useSwitch)(ariaProps, state, ref);
|
|
32874
33874
|
const {
|
|
32875
33875
|
isFocusVisible: isFocusVisibleFromEvents,
|
|
32876
33876
|
focusProps
|
|
32877
|
-
} = (0,
|
|
33877
|
+
} = (0, import_react_aria79.useFocusRing)({
|
|
32878
33878
|
...otherProps,
|
|
32879
33879
|
within: true
|
|
32880
33880
|
});
|
|
32881
33881
|
const {
|
|
32882
33882
|
hoverProps,
|
|
32883
33883
|
isHovered: isHoveredFromEvents
|
|
32884
|
-
} = (0,
|
|
33884
|
+
} = (0, import_react_aria79.useHover)({
|
|
32885
33885
|
isDisabled
|
|
32886
33886
|
});
|
|
32887
33887
|
const isHovered = __storyState?.hovered ?? isHoveredFromEvents;
|
|
@@ -32892,7 +33892,7 @@ function ToggleButton(props) {
|
|
|
32892
33892
|
...focusProps,
|
|
32893
33893
|
...hoverProps,
|
|
32894
33894
|
...pressProps,
|
|
32895
|
-
...(0,
|
|
33895
|
+
...(0, import_runtime179.trussProps)({
|
|
32896
33896
|
// Gray500 off-state has no semantic match — keep palette (OnSurfaceMuted is Gray700).
|
|
32897
33897
|
...{
|
|
32898
33898
|
borderRadius: "br4",
|
|
@@ -32932,10 +33932,10 @@ function ToggleButton(props) {
|
|
|
32932
33932
|
return maybeTooltip({
|
|
32933
33933
|
title: tooltip,
|
|
32934
33934
|
placement: "top",
|
|
32935
|
-
children: /* @__PURE__ */ (0,
|
|
32936
|
-
icon && /* @__PURE__ */ (0,
|
|
33935
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime275.jsxs)("label", { ...labelAttrs, children: [
|
|
33936
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(Icon, { icon }),
|
|
32937
33937
|
label,
|
|
32938
|
-
/* @__PURE__ */ (0,
|
|
33938
|
+
/* @__PURE__ */ (0, import_jsx_runtime275.jsx)(import_react_aria79.VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime275.jsx)("input", { ref, ...inputProps, ...tid.value }) })
|
|
32939
33939
|
] })
|
|
32940
33940
|
});
|
|
32941
33941
|
}
|
|
@@ -33076,6 +34076,7 @@ var togglePressStyles = {
|
|
|
33076
34076
|
Loader,
|
|
33077
34077
|
LoadingSkeleton,
|
|
33078
34078
|
MaxLines,
|
|
34079
|
+
MenuSelectField,
|
|
33079
34080
|
ModalBanner,
|
|
33080
34081
|
ModalBody,
|
|
33081
34082
|
ModalFilterItem,
|