@oliasoft-open-source/react-ui-library 10.7.0 → 10.8.0-beta-2

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
@@ -6,7 +6,9 @@ import { CSSTransition } from "react-transition-group";
6
6
  import { CheckboxButton, CheckboxField } from "react-aria-components/Checkbox";
7
7
  import { ColorArea, ColorPicker, ColorSlider, ColorSwatch, ColorSwatchPicker, ColorSwatchPickerItem, ColorThumb, DialogTrigger, Focusable, OverlayArrow, Popover as Popover$1, Pressable, RouterProvider, SliderTrack, Tooltip as Tooltip$1, TooltipTrigger, TooltipTriggerStateContext, useLocale } from "react-aria-components";
8
8
  import { clamp, cloneDeep, cloneDeepWith, debounce, every, get, isArray, isBoolean, isEmpty, isEqual, isFinite, isFunction, isNil, isNumber, isObject, isPlainObject, isString, keys, noop, sortBy, toLower, toNumber, upperFirst, values } from "es-toolkit/compat";
9
- import { Header, Menu as Menu$1, MenuItem, MenuTrigger, Separator, SubmenuTrigger } from "react-aria-components/Menu";
9
+ import { Header, Menu as Menu$1, MenuItem, MenuTrigger, Pressable as Pressable$1, Separator, SubmenuTrigger } from "react-aria-components/Menu";
10
+ import { Autocomplete } from "react-aria-components/Autocomplete";
11
+ import { Input as Input$1, SearchField } from "react-aria-components/SearchField";
10
12
  import { Breadcrumb as Breadcrumb$1, Breadcrumbs, Link } from "react-aria-components/Breadcrumbs";
11
13
  import { colord, extend } from "colord";
12
14
  import lchPlugin from "colord/plugins/lch";
@@ -18,7 +20,7 @@ import { ALT_UNITS, KNOWN_UNITS, altUnitsList, cleanNumStr, convertAndGetValue,
18
20
  import { ListBox, ListBoxItem } from "react-aria-components/ListBox";
19
21
  import { ListLayout, Virtualizer } from "react-aria-components/Virtualizer";
20
22
  import { SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
21
- import { CSS } from "@dnd-kit/utilities";
23
+ import { CSS as CSS$1 } from "@dnd-kit/utilities";
22
24
  import * as RadixSlider from "@radix-ui/react-slider";
23
25
  import memoizeOne from "memoize-one";
24
26
  import isEqual$1 from "react-fast-compare";
@@ -1056,32 +1058,35 @@ var isMenuEmpty = (menu) => {
1056
1058
  return !isValidElement(sections) && (!Array.isArray(sections) || sections.every((section) => isEmpty(section)));
1057
1059
  };
1058
1060
  var menu_module_default = {
1059
- layer: "_layer_1f0i9_1",
1060
- nested: "_nested_1f0i9_14",
1061
- fileInput: "_fileInput_1f0i9_17",
1062
- trigger: "_trigger_1f0i9_23",
1063
- heading: "_heading_1f0i9_32",
1064
- headingIcon: "_headingIcon_1f0i9_38",
1065
- clickable: "_clickable_1f0i9_45",
1066
- option: "_option_1f0i9_49",
1067
- active: "_active_1f0i9_68",
1068
- disabled: "_disabled_1f0i9_73",
1069
- selected: "_selected_1f0i9_76",
1070
- optionContent: "_optionContent_1f0i9_89",
1071
- description: "_description_1f0i9_93",
1072
- inline: "_inline_1f0i9_97",
1073
- icon: "_icon_1f0i9_102",
1074
- check: "_check_1f0i9_103",
1075
- label: "_label_1f0i9_130",
1076
- arrow: "_arrow_1f0i9_148",
1077
- divider: "_divider_1f0i9_152",
1078
- buttonLabel: "_buttonLabel_1f0i9_160",
1079
- component: "_component_1f0i9_167",
1080
- right: "_right_1f0i9_173",
1081
- actions: "_actions_1f0i9_178",
1082
- menuPopover: "_menuPopover_1f0i9_185",
1083
- menuPopoverNested: "_menuPopoverNested_1f0i9_207",
1084
- menuItem: "_menuItem_1f0i9_210"
1061
+ layer: "_layer_1dlok_1",
1062
+ nested: "_nested_1dlok_14",
1063
+ fileInput: "_fileInput_1dlok_17",
1064
+ trigger: "_trigger_1dlok_23",
1065
+ heading: "_heading_1dlok_32",
1066
+ headingIcon: "_headingIcon_1dlok_38",
1067
+ clickable: "_clickable_1dlok_45",
1068
+ option: "_option_1dlok_49",
1069
+ active: "_active_1dlok_68",
1070
+ disabled: "_disabled_1dlok_73",
1071
+ selected: "_selected_1dlok_76",
1072
+ optionContent: "_optionContent_1dlok_89",
1073
+ description: "_description_1dlok_93",
1074
+ inline: "_inline_1dlok_97",
1075
+ icon: "_icon_1dlok_102",
1076
+ check: "_check_1dlok_103",
1077
+ label: "_label_1dlok_130",
1078
+ arrow: "_arrow_1dlok_148",
1079
+ divider: "_divider_1dlok_152",
1080
+ buttonLabel: "_buttonLabel_1dlok_160",
1081
+ component: "_component_1dlok_167",
1082
+ right: "_right_1dlok_173",
1083
+ actions: "_actions_1dlok_178",
1084
+ menuPopover: "_menuPopover_1dlok_185",
1085
+ menuPopoverNested: "_menuPopoverNested_1dlok_207",
1086
+ menuItem: "_menuItem_1dlok_210",
1087
+ overlayScope: "_overlayScope_1dlok_229",
1088
+ noResults: "_noResults_1dlok_232",
1089
+ searchInput: "_searchInput_1dlok_236"
1085
1090
  };
1086
1091
  //#endregion
1087
1092
  //#region src/components/menu/layer/heading.tsx
@@ -1205,6 +1210,15 @@ var MenuCarat = /* @__PURE__ */ function(MenuCarat) {
1205
1210
  MenuCarat["DOWN"] = "down";
1206
1211
  return MenuCarat;
1207
1212
  }({});
1213
+ /** Menu trigger variants. Extends shared `TriggerType` with Search. */
1214
+ var MenuTriggerType = /* @__PURE__ */ function(MenuTriggerType) {
1215
+ MenuTriggerType["TEXT"] = "Text";
1216
+ MenuTriggerType["BUTTON"] = "Button";
1217
+ MenuTriggerType["DROP_DOWN_BUTTON"] = "DropDownButton";
1218
+ MenuTriggerType["COMPONENT"] = "Component";
1219
+ MenuTriggerType["SEARCH"] = "Search";
1220
+ return MenuTriggerType;
1221
+ }({});
1208
1222
  //#endregion
1209
1223
  //#region src/components/menu/layer/section.tsx
1210
1224
  /** Leaf section types only. Submenus are owned by Layer. */
@@ -1247,6 +1261,74 @@ var Section$1 = ({ section, closeOnOptionClick, close }) => {
1247
1261
  }
1248
1262
  };
1249
1263
  //#endregion
1264
+ //#region src/helpers/search.ts
1265
+ /**
1266
+ * Shared text-search matching for searchable components (Select, Menu).
1267
+ * Case-insensitive substring match — keep behaviour identical across components.
1268
+ */
1269
+ var normalizeSearch = (value) => String(value !== null && value !== void 0 ? value : "").toLowerCase();
1270
+ var matchesSearch = (query, ...texts) => {
1271
+ const normalizedQuery = normalizeSearch(query);
1272
+ if (!normalizedQuery) return true;
1273
+ return texts.some((text) => text != null && normalizeSearch(text).includes(normalizedQuery));
1274
+ };
1275
+ //#endregion
1276
+ //#region src/components/menu/filter-menu-sections.ts
1277
+ var getSearchText = (label) => typeof label === "string" || typeof label === "number" ? String(label) : "";
1278
+ var isItem = (section) => section.type === MenuType.OPTION || section.type === MenuType.MENU;
1279
+ var isBoundary = (section) => section.type === MenuType.HEADING || section.type === MenuType.DIVIDER;
1280
+ /** Drop headings with no items under them, and leading / trailing / doubled dividers. */
1281
+ var tidy = (sections) => {
1282
+ var _result;
1283
+ const withoutEmptyHeadings = sections.filter((section, i) => {
1284
+ if (section.type !== MenuType.HEADING) return true;
1285
+ const next = sections.slice(i + 1).find((s) => isItem(s) || isBoundary(s));
1286
+ return !!next && isItem(next);
1287
+ });
1288
+ const result = [];
1289
+ withoutEmptyHeadings.forEach((section) => {
1290
+ const previous = result[result.length - 1];
1291
+ if (section.type === MenuType.DIVIDER && (!previous || previous.type === MenuType.DIVIDER)) return;
1292
+ result.push(section);
1293
+ });
1294
+ if (((_result = result[result.length - 1]) === null || _result === void 0 ? void 0 : _result.type) === MenuType.DIVIDER) result.pop();
1295
+ return result;
1296
+ };
1297
+ /**
1298
+ * Filters menu sections by a search query while preserving structure:
1299
+ * - options are kept when their label or description matches
1300
+ * - submenus are kept when their own label matches (with all children), or when any
1301
+ * descendant matches (with children filtered recursively)
1302
+ * - headings / dividers are kept only where they still separate visible items
1303
+ * Labels that are not plain strings/numbers cannot be matched.
1304
+ */
1305
+ var filterMenuSections = (sections, query) => {
1306
+ if (isValidElement(sections) || !Array.isArray(sections)) return [];
1307
+ if (!normalizeSearch(query)) return sections;
1308
+ return tidy(sections.flatMap((section) => {
1309
+ switch (section === null || section === void 0 ? void 0 : section.type) {
1310
+ case MenuType.HEADING:
1311
+ case MenuType.DIVIDER: return [section];
1312
+ case MenuType.OPTION: return matchesSearch(query, getSearchText(section.label), section.description) ? [section] : [];
1313
+ case MenuType.MENU: {
1314
+ var _section$menu$label, _section$menu, _section$menu$section, _section$menu2;
1315
+ if (matchesSearch(query, getSearchText((_section$menu$label = (_section$menu = section.menu) === null || _section$menu === void 0 ? void 0 : _section$menu.label) !== null && _section$menu$label !== void 0 ? _section$menu$label : section.label))) return [section];
1316
+ const children = filterMenuSections((_section$menu$section = (_section$menu2 = section.menu) === null || _section$menu2 === void 0 ? void 0 : _section$menu2.sections) !== null && _section$menu$section !== void 0 ? _section$menu$section : [], query);
1317
+ if (!children.some(isItem)) return [];
1318
+ return [{
1319
+ ...section,
1320
+ menu: {
1321
+ trigger: "Text",
1322
+ ...section.menu,
1323
+ sections: children
1324
+ }
1325
+ }];
1326
+ }
1327
+ default: return [];
1328
+ }
1329
+ }));
1330
+ };
1331
+ //#endregion
1250
1332
  //#region src/components/menu/trigger/text.tsx
1251
1333
  var Text$1 = forwardRef(({ label, title, carat, disabled, isOpen, selected, className, ...domProps }, ref) => {
1252
1334
  let titleText;
@@ -1271,11 +1353,22 @@ var Text$1 = forwardRef(({ label, title, carat, disabled, isOpen, selected, clas
1271
1353
  });
1272
1354
  //#endregion
1273
1355
  //#region src/components/menu/layer/layer.tsx
1356
+ var MENU_SCOPE_ATTRIBUTE = "data-menu-scope";
1357
+ /**
1358
+ * Marks every popover (root + submenus) belonging to one searchable menu, so outside-press
1359
+ * detection can tell clicks inside the menu apart from clicks elsewhere.
1360
+ */
1361
+ var OverlayScope = ({ scopeId, children }) => scopeId ? /* @__PURE__ */ jsx("div", {
1362
+ [MENU_SCOPE_ATTRIBUTE]: scopeId,
1363
+ className: menu_module_default.overlayScope,
1364
+ onMouseDown: (evt) => evt.preventDefault(),
1365
+ children
1366
+ }) : /* @__PURE__ */ jsx(Fragment$1, { children });
1274
1367
  var getTextValue = (label) => {
1275
1368
  if (typeof label === "string" || typeof label === "number") return String(label);
1276
1369
  return "";
1277
1370
  };
1278
- var renderSection = (section, index, { closeOnOptionClick, close, maxHeight, width }) => {
1371
+ var renderSection = (section, index, { closeOnOptionClick, close, maxHeight, width, scopeId }) => {
1279
1372
  if (section.type === MenuType.MENU) {
1280
1373
  var _section$menu, _section$menu2, _section$menu3, _section$menu$label, _section$menu4, _ref, _section$menu$label2, _section$menu5, _section$menu6, _section$menu$section, _section$menu7;
1281
1374
  const submenuSections = (_section$menu = section.menu) === null || _section$menu === void 0 ? void 0 : _section$menu.sections;
@@ -1299,14 +1392,18 @@ var renderSection = (section, index, { closeOnOptionClick, close, maxHeight, wid
1299
1392
  placement: submenuPlacement,
1300
1393
  isNested: true,
1301
1394
  "data-testid": (_section$menu6 = section.menu) === null || _section$menu6 === void 0 ? void 0 : _section$menu6.testId,
1302
- children: /* @__PURE__ */ jsx(Layer$2, {
1303
- sections: (_section$menu$section = (_section$menu7 = section.menu) === null || _section$menu7 === void 0 ? void 0 : _section$menu7.sections) !== null && _section$menu$section !== void 0 ? _section$menu$section : [],
1304
- isNested: true,
1305
- width,
1306
- closeOnOptionClick,
1307
- close,
1308
- maxHeight,
1309
- testId: nestedTestId ? `${nestedTestId}-layer` : void 0
1395
+ children: /* @__PURE__ */ jsx(OverlayScope, {
1396
+ scopeId,
1397
+ children: /* @__PURE__ */ jsx(Layer$2, {
1398
+ sections: (_section$menu$section = (_section$menu7 = section.menu) === null || _section$menu7 === void 0 ? void 0 : _section$menu7.sections) !== null && _section$menu$section !== void 0 ? _section$menu$section : [],
1399
+ isNested: true,
1400
+ width,
1401
+ closeOnOptionClick,
1402
+ close,
1403
+ maxHeight,
1404
+ testId: nestedTestId ? `${nestedTestId}-layer` : void 0,
1405
+ scopeId
1406
+ })
1310
1407
  })
1311
1408
  })] }, `${section.type}-${index}`);
1312
1409
  }
@@ -1316,11 +1413,12 @@ var renderSection = (section, index, { closeOnOptionClick, close, maxHeight, wid
1316
1413
  close
1317
1414
  }, `${section.type}-${index}`);
1318
1415
  };
1319
- var Layer$2 = ({ sections, isNested = false, width, closeOnOptionClick, close, maxHeight, showAllButton, testId }) => {
1320
- var _showAllButton$additi, _showAllButton$additi2;
1416
+ var Layer$2 = ({ sections, isNested = false, width, closeOnOptionClick, close, maxHeight, showAllButton, testId, search, scopeId }) => {
1417
+ var _showAllButton$additi, _showAllButton$additi2, _search$value;
1321
1418
  const [showAll, setShowAll] = useState(!(showAllButton === null || showAllButton === void 0 ? void 0 : showAllButton.visible));
1322
1419
  if (isValidElement(sections)) return /* @__PURE__ */ jsx(Fragment$1, { children: sections });
1323
1420
  const sectionsArray = sections;
1421
+ const isSearching = !!(search === null || search === void 0 ? void 0 : search.value);
1324
1422
  const additionalSections = (_showAllButton$additi = showAllButton === null || showAllButton === void 0 || (_showAllButton$additi2 = showAllButton.additionalSections) === null || _showAllButton$additi2 === void 0 ? void 0 : _showAllButton$additi2.map((s) => ({
1325
1423
  ...s,
1326
1424
  closeOnOptionClick,
@@ -1333,7 +1431,10 @@ var Layer$2 = ({ sections, isNested = false, width, closeOnOptionClick, close, m
1333
1431
  visible: true,
1334
1432
  closeOnOptionClick: false
1335
1433
  }] : [];
1336
- const localSections = (showAllButton === null || showAllButton === void 0 ? void 0 : showAllButton.visible) ? sectionsArray.map((s, i) => {
1434
+ const localSections = isSearching ? filterMenuSections([...sectionsArray, ...(showAllButton === null || showAllButton === void 0 ? void 0 : showAllButton.visible) ? additionalSections : []], (_search$value = search === null || search === void 0 ? void 0 : search.value) !== null && _search$value !== void 0 ? _search$value : "").map((s) => ({
1435
+ ...s,
1436
+ closeOnOptionClick
1437
+ })) : (showAllButton === null || showAllButton === void 0 ? void 0 : showAllButton.visible) ? sectionsArray.map((s, i) => {
1337
1438
  return showAll || i <= 3 ? {
1338
1439
  ...s,
1339
1440
  visible: true,
@@ -1352,14 +1453,128 @@ var Layer$2 = ({ sections, isNested = false, width, closeOnOptionClick, close, m
1352
1453
  shouldCloseOnSelect: closeOnOptionClick,
1353
1454
  autoFocus: isNested ? void 0 : "first",
1354
1455
  "data-testid": testId,
1456
+ renderEmptyState: search ? () => /* @__PURE__ */ jsx("div", {
1457
+ className: menu_module_default.noResults,
1458
+ children: "No results"
1459
+ }) : void 0,
1355
1460
  children: localSections.map((section, i) => renderSection(section, i, {
1356
1461
  closeOnOptionClick: section.closeOnOptionClick,
1357
1462
  close,
1358
1463
  maxHeight,
1359
- width
1464
+ width,
1465
+ scopeId
1360
1466
  }))
1361
1467
  });
1362
1468
  };
1469
+ var trigger_module_default = {
1470
+ inputInTable: "_inputInTable_c2rg4_1",
1471
+ inputHover: "_inputHover_c2rg4_13",
1472
+ inputFocus: "_inputFocus_c2rg4_18",
1473
+ controlFocusVisible: "_controlFocusVisible_c2rg4_25",
1474
+ inputError: "_inputError_c2rg4_29",
1475
+ inputWarning: "_inputWarning_c2rg4_30",
1476
+ inputDisabled: "_inputDisabled_c2rg4_65",
1477
+ hideScrollbars: "_hideScrollbars_c2rg4_71",
1478
+ trigger: "_trigger_c2rg4_81",
1479
+ isInTable: "_isInTable_c2rg4_97",
1480
+ input: "_input_c2rg4_1",
1481
+ isOpen: "_isOpen_c2rg4_118",
1482
+ disabled: "_disabled_c2rg4_161",
1483
+ icons: "_icons_c2rg4_167",
1484
+ clearAll: "_clearAll_c2rg4_174",
1485
+ iconOpen: "_iconOpen_c2rg4_175",
1486
+ small: "_small_c2rg4_186",
1487
+ triggerInputContainer: "_triggerInputContainer_c2rg4_194",
1488
+ right: "_right_c2rg4_203",
1489
+ multiOptions: "_multiOptions_c2rg4_216",
1490
+ multiOption: "_multiOption_c2rg4_216",
1491
+ label: "_label_c2rg4_244",
1492
+ closeMultiOption: "_closeMultiOption_c2rg4_247",
1493
+ focus: "_focus_c2rg4_258",
1494
+ selectedSingleValue: "_selectedSingleValue_c2rg4_262",
1495
+ placeHolder: "_placeHolder_c2rg4_263",
1496
+ groupOrderFirst: "_groupOrderFirst_c2rg4_302",
1497
+ groupOrderMiddle: "_groupOrderMiddle_c2rg4_303",
1498
+ groupOrderLast: "_groupOrderLast_c2rg4_307",
1499
+ detailedLabel: "_detailedLabel_c2rg4_312"
1500
+ };
1501
+ //#endregion
1502
+ //#region src/components/menu/trigger/search-trigger.tsx
1503
+ var hasDisplayValue = (value) => value != null && value !== "";
1504
+ var groupOrderClass = (groupOrder) => {
1505
+ switch (groupOrder) {
1506
+ case GroupOrder.FIRST: return trigger_module_default.groupOrderFirst;
1507
+ case GroupOrder.LAST: return trigger_module_default.groupOrderLast;
1508
+ case void 0: return;
1509
+ default: return trigger_module_default.groupOrderMiddle;
1510
+ }
1511
+ };
1512
+ /**
1513
+ * Select-style search input acting as the Menu trigger. Must render inside an RAC `Autocomplete`
1514
+ * (wires the input to the menu via virtual focus / aria-activedescendant) and a `MenuTrigger`.
1515
+ * Behaviour mirrors the searchable Select: click anywhere toggles, typing / ArrowDown opens,
1516
+ * Escape / Tab close.
1517
+ */
1518
+ var SearchTrigger = forwardRef(({ label, placeholder, searchValue, isOpen, disabled, small, width, groupOrder, error, warning, tabIndex, testId, isInTable, inputRef, onOpen, onClose }, ref) => {
1519
+ const handleMouseDown = (evt) => evt.preventDefault();
1520
+ const handleClick = () => {
1521
+ var _inputRef$current;
1522
+ if (disabled) return;
1523
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
1524
+ if (isOpen) onClose();
1525
+ else onOpen();
1526
+ };
1527
+ const handleKeyDown = (evt) => {
1528
+ if (!isOpen && evt.key === "ArrowDown") onOpen();
1529
+ if (isOpen && (evt.key === "Escape" || evt.key === "Tab")) onClose();
1530
+ };
1531
+ const showLabel = !searchValue && hasDisplayValue(label);
1532
+ const showPlaceholder = !searchValue && !showLabel && hasDisplayValue(placeholder);
1533
+ const ariaLabel = typeof label === "string" && label || typeof placeholder === "string" && placeholder || "Search";
1534
+ return /* @__PURE__ */ jsxs("div", {
1535
+ ref,
1536
+ className: cx(trigger_module_default.trigger, isOpen && trigger_module_default.isOpen, disabled && trigger_module_default.disabled, small && trigger_module_default.small, isInTable && trigger_module_default.isInTable, groupOrderClass(groupOrder)),
1537
+ style: { width },
1538
+ onMouseDown: handleMouseDown,
1539
+ onClick: handleClick,
1540
+ "data-error": error || null,
1541
+ "data-warning": warning || null,
1542
+ "data-testid": testId,
1543
+ children: [/* @__PURE__ */ jsxs(SearchField, {
1544
+ "aria-label": ariaLabel,
1545
+ isDisabled: disabled,
1546
+ onKeyDown: handleKeyDown,
1547
+ className: trigger_module_default.triggerInputContainer,
1548
+ children: [
1549
+ showLabel && /* @__PURE__ */ jsx("span", {
1550
+ className: trigger_module_default.selectedSingleValue,
1551
+ "data-testid": testId && `${testId}-value`,
1552
+ children: label
1553
+ }),
1554
+ showPlaceholder && /* @__PURE__ */ jsx("span", {
1555
+ className: trigger_module_default.placeHolder,
1556
+ children: placeholder
1557
+ }),
1558
+ /* @__PURE__ */ jsx(Input$1, {
1559
+ ref: inputRef,
1560
+ className: cx(trigger_module_default.input, menu_module_default.searchInput),
1561
+ size: searchValue.length + 1,
1562
+ tabIndex,
1563
+ "data-testid": testId ? `${testId}-input` : void 0
1564
+ })
1565
+ ]
1566
+ }), /* @__PURE__ */ jsx("span", {
1567
+ className: trigger_module_default.icons,
1568
+ children: /* @__PURE__ */ jsx(Pressable$1, {
1569
+ isDisabled: true,
1570
+ children: /* @__PURE__ */ jsx("span", {
1571
+ className: trigger_module_default.iconOpen,
1572
+ children: /* @__PURE__ */ jsx(Icon, { icon: IconType.CHEVRON_DOWN })
1573
+ })
1574
+ })
1575
+ })]
1576
+ });
1577
+ });
1363
1578
  //#endregion
1364
1579
  //#region src/components/menu/layer/placementOptions.ts
1365
1580
  var placementOptions = (placement, isNested = false) => ({ placement: placement || (isNested ? "right-start" : "bottom-start") });
@@ -1545,22 +1760,40 @@ var Trigger$1 = React.forwardRef(({ active, disabled, loading, width, trigger, l
1545
1760
  });
1546
1761
  //#endregion
1547
1762
  //#region src/components/menu/menu.tsx
1548
- var Menu = ({ menu, width, disabled = false, badgeTitle, badgeDot = false, loading = false, closeOnOptionClick = true, maxHeight, testId, open: openProp, setOpen: setOpenProp, tooltip, error, warning, tabIndex, active, groupOrder, offset = 0 }) => {
1763
+ var Menu = ({ menu, width, disabled = false, badgeTitle, badgeDot = false, loading = false, closeOnOptionClick = true, maxHeight, testId, open: openProp, setOpen: setOpenProp, tooltip, error, warning, tabIndex, active, groupOrder, offset = 0, isInTable = false }) => {
1549
1764
  const disabledContext = useContext(DisabledContext);
1550
1765
  const triggerRef = useRef(null);
1551
1766
  const [internalOpen, setInternalOpen] = useState(false);
1552
- const { label, title, trigger, colored, basic, small, sections, component, placement, showAllButton } = menu;
1767
+ const [searchValue, setSearchValue] = useState("");
1768
+ const scopeId = useId();
1769
+ const searchTriggerRef = useRef(null);
1770
+ const searchInputRef = useRef(null);
1771
+ const { label, title, trigger, colored, basic, small, sections, component, placement, showAllButton, placeholder } = menu;
1553
1772
  const isControlled = isBoolean(openProp) && isFunction(setOpenProp);
1554
1773
  const isOpen = isControlled ? openProp : internalOpen;
1555
1774
  const isDisabled = disabled || isMenuEmpty(menu) || disabledContext;
1775
+ const isSearchable = trigger === MenuTriggerType.SEARCH && !isValidElement(sections);
1776
+ /** Input trigger, or any popover (root / submenu) belonging to this menu. */
1777
+ const isInSearchScope = (el) => {
1778
+ var _searchTriggerRef$cur;
1779
+ return el instanceof Element && (!!((_searchTriggerRef$cur = searchTriggerRef.current) === null || _searchTriggerRef$cur === void 0 ? void 0 : _searchTriggerRef$cur.contains(el)) || !!el.closest(`[data-menu-scope="${CSS.escape(scopeId)}"]`));
1780
+ };
1556
1781
  const handleOpenChange = useCallback((open) => {
1557
1782
  if (isDisabled && open) return;
1783
+ if (!open) {
1784
+ setSearchValue("");
1785
+ if (isSearchable && isInSearchScope(document.activeElement) && document.activeElement !== searchInputRef.current) {
1786
+ var _searchInputRef$curre;
1787
+ (_searchInputRef$curre = searchInputRef.current) === null || _searchInputRef$curre === void 0 || _searchInputRef$curre.focus();
1788
+ }
1789
+ }
1558
1790
  if (isControlled) setOpenProp(open);
1559
1791
  else setInternalOpen(open);
1560
1792
  }, [
1561
1793
  isControlled,
1562
1794
  isDisabled,
1563
- setOpenProp
1795
+ setOpenProp,
1796
+ isSearchable
1564
1797
  ]);
1565
1798
  const close = useCallback(() => {
1566
1799
  handleOpenChange(false);
@@ -1578,6 +1811,23 @@ var Menu = ({ menu, width, disabled = false, badgeTitle, badgeDot = false, loadi
1578
1811
  evt.stopPropagation();
1579
1812
  evt.preventDefault();
1580
1813
  };
1814
+ const handleSearchChange = (value) => {
1815
+ setSearchValue(value);
1816
+ if (value && !isOpen) handleOpenChange(true);
1817
+ };
1818
+ useEffect(() => {
1819
+ if (!isSearchable || !isOpen) return;
1820
+ const onPointerDown = (evt) => {
1821
+ if (!isInSearchScope(evt.target)) close();
1822
+ };
1823
+ document.addEventListener("pointerdown", onPointerDown, true);
1824
+ return () => document.removeEventListener("pointerdown", onPointerDown, true);
1825
+ }, [
1826
+ isSearchable,
1827
+ isOpen,
1828
+ close
1829
+ ]);
1830
+ const ignorePopoverClose = () => {};
1581
1831
  const triggerControl = /* @__PURE__ */ jsx(OverlayTriggerChild, {
1582
1832
  behavior: OverlayTriggerBehavior.PRESS,
1583
1833
  testId,
@@ -1605,6 +1855,66 @@ var Menu = ({ menu, width, disabled = false, badgeTitle, badgeDot = false, loadi
1605
1855
  onClick: handleTriggerClick
1606
1856
  })
1607
1857
  });
1858
+ const layer = /* @__PURE__ */ jsx(Layer$2, {
1859
+ sections,
1860
+ width,
1861
+ closeOnOptionClick,
1862
+ close,
1863
+ maxHeight,
1864
+ showAllButton,
1865
+ testId: layerTestId,
1866
+ search: isSearchable ? { value: searchValue } : void 0,
1867
+ scopeId: isSearchable ? scopeId : void 0
1868
+ });
1869
+ if (isSearchable) return /* @__PURE__ */ jsx(MenuTrigger, {
1870
+ isOpen,
1871
+ onOpenChange: handleOpenChange,
1872
+ children: /* @__PURE__ */ jsxs(Autocomplete, {
1873
+ inputValue: searchValue,
1874
+ onInputChange: handleSearchChange,
1875
+ children: [/* @__PURE__ */ jsx(TriggerTooltip, {
1876
+ tooltip,
1877
+ error,
1878
+ warning,
1879
+ children: withBadge(/* @__PURE__ */ jsx(SearchTrigger, {
1880
+ ref: searchTriggerRef,
1881
+ inputRef: searchInputRef,
1882
+ label,
1883
+ placeholder,
1884
+ searchValue,
1885
+ isOpen,
1886
+ disabled: isDisabled,
1887
+ small,
1888
+ width,
1889
+ groupOrder,
1890
+ error,
1891
+ warning,
1892
+ tabIndex,
1893
+ testId,
1894
+ isInTable,
1895
+ onOpen: () => handleOpenChange(true),
1896
+ onClose: close
1897
+ }), {
1898
+ badgeTitle,
1899
+ badgeDot
1900
+ })
1901
+ }), /* @__PURE__ */ jsx(AriaOverlayPopover, {
1902
+ className: menu_module_default.menuPopover,
1903
+ placement: resolvedPlacement,
1904
+ triggerRef: searchTriggerRef,
1905
+ portalTriggerRef: searchTriggerRef,
1906
+ offset,
1907
+ isNonModal: true,
1908
+ isOpen,
1909
+ onOpenChange: ignorePopoverClose,
1910
+ "data-testid": menu.testId,
1911
+ children: /* @__PURE__ */ jsx(OverlayScope, {
1912
+ scopeId,
1913
+ children: layer
1914
+ })
1915
+ })]
1916
+ })
1917
+ });
1608
1918
  return /* @__PURE__ */ jsxs(MenuTrigger, {
1609
1919
  isOpen,
1610
1920
  onOpenChange: handleOpenChange,
@@ -1622,15 +1932,7 @@ var Menu = ({ menu, width, disabled = false, badgeTitle, badgeDot = false, loadi
1622
1932
  portalTriggerRef: triggerRef,
1623
1933
  offset,
1624
1934
  "data-testid": menu.testId,
1625
- children: /* @__PURE__ */ jsx(Layer$2, {
1626
- sections,
1627
- width,
1628
- closeOnOptionClick,
1629
- close,
1630
- maxHeight,
1631
- showAllButton,
1632
- testId: layerTestId
1633
- })
1935
+ children: layer
1634
1936
  })]
1635
1937
  });
1636
1938
  };
@@ -3762,38 +4064,6 @@ var Layer$1 = ({ listRef, sections, selectedOptions, onSelectOption, focusedOpti
3762
4064
  children: listBox
3763
4065
  });
3764
4066
  };
3765
- var trigger_module_default = {
3766
- inputInTable: "_inputInTable_c2rg4_1",
3767
- inputHover: "_inputHover_c2rg4_13",
3768
- inputFocus: "_inputFocus_c2rg4_18",
3769
- controlFocusVisible: "_controlFocusVisible_c2rg4_25",
3770
- inputError: "_inputError_c2rg4_29",
3771
- inputWarning: "_inputWarning_c2rg4_30",
3772
- inputDisabled: "_inputDisabled_c2rg4_65",
3773
- hideScrollbars: "_hideScrollbars_c2rg4_71",
3774
- trigger: "_trigger_c2rg4_81",
3775
- isInTable: "_isInTable_c2rg4_97",
3776
- input: "_input_c2rg4_1",
3777
- isOpen: "_isOpen_c2rg4_118",
3778
- disabled: "_disabled_c2rg4_161",
3779
- icons: "_icons_c2rg4_167",
3780
- clearAll: "_clearAll_c2rg4_174",
3781
- iconOpen: "_iconOpen_c2rg4_175",
3782
- small: "_small_c2rg4_186",
3783
- triggerInputContainer: "_triggerInputContainer_c2rg4_194",
3784
- right: "_right_c2rg4_203",
3785
- multiOptions: "_multiOptions_c2rg4_216",
3786
- multiOption: "_multiOption_c2rg4_216",
3787
- label: "_label_c2rg4_244",
3788
- closeMultiOption: "_closeMultiOption_c2rg4_247",
3789
- focus: "_focus_c2rg4_258",
3790
- selectedSingleValue: "_selectedSingleValue_c2rg4_262",
3791
- placeHolder: "_placeHolder_c2rg4_263",
3792
- groupOrderFirst: "_groupOrderFirst_c2rg4_302",
3793
- groupOrderMiddle: "_groupOrderMiddle_c2rg4_303",
3794
- groupOrderLast: "_groupOrderLast_c2rg4_307",
3795
- detailedLabel: "_detailedLabel_c2rg4_312"
3796
- };
3797
4067
  //#endregion
3798
4068
  //#region src/components/select/custom-select/trigger/multi-selected-options.tsx
3799
4069
  var MultiSelectedOptions = ({ selectedOptions, small, width, testId }) => {
@@ -3838,7 +4108,7 @@ var MultiSelectedOptions = ({ selectedOptions, small, width, testId }) => {
3838
4108
  };
3839
4109
  //#endregion
3840
4110
  //#region src/components/select/custom-select/trigger/input.tsx
3841
- var Input$1 = ({ selectedOptions, searchable = false, searchValue, onChange = noop, inputRef, error, placeholder = "Select...", small, testId }) => {
4111
+ var Input$2 = ({ selectedOptions, searchable = false, searchValue, onChange = noop, inputRef, error, placeholder = "Select...", small, testId }) => {
3842
4112
  const containerRef = useRef(null);
3843
4113
  const isMulti = Array.isArray(selectedOptions);
3844
4114
  const hasSelectedValues = isMulti ? selectedOptions.length > 0 : !!selectedOptions;
@@ -3918,7 +4188,7 @@ var Trigger = ({ selectedOptions, searchValue, searchable, clearable, onClickTri
3918
4188
  "data-error": error || null,
3919
4189
  "data-warning": warning || null,
3920
4190
  "data-testid": testId,
3921
- children: [/* @__PURE__ */ jsx(Input$1, {
4191
+ children: [/* @__PURE__ */ jsx(Input$2, {
3922
4192
  selectedOptions: selectedOptionsWithDetails,
3923
4193
  placeholder,
3924
4194
  searchable,
@@ -6233,7 +6503,7 @@ var Row$1 = ({ row, rowIndex, isHeader = false, columnCount, colSpan, columnHead
6233
6503
  ]);
6234
6504
  const rowRef = measureRef ? setMeasuredRowRef : !row.noDrag ? setNodeRef : null;
6235
6505
  const style = {
6236
- transform: !dropDisabled ? CSS.Translate.toString(transform) : void 0,
6506
+ transform: !dropDisabled ? CSS$1.Translate.toString(transform) : void 0,
6237
6507
  height,
6238
6508
  transition,
6239
6509
  opacity: isDragging ? 0 : void 0
@@ -8710,7 +8980,7 @@ var ListRow = forwardRef(({ item, index, expanding, invokeEditOnRowClick, dragga
8710
8980
  animateLayoutChanges: () => false
8711
8981
  });
8712
8982
  const style = {
8713
- transform: CSS.Translate.toString(transform),
8983
+ transform: CSS$1.Translate.toString(transform),
8714
8984
  transition,
8715
8985
  opacity: isDragging ? 0 : 1
8716
8986
  };
@@ -10216,7 +10486,7 @@ var Link$1 = ({ label, url, icon, onClick, active, disabled, testId, component:
10216
10486
  };
10217
10487
  //#endregion
10218
10488
  //#region src/components/top-bar/element/element.tsx
10219
- var Element = ({ element }) => {
10489
+ var Element$1 = ({ element }) => {
10220
10490
  switch (element.type) {
10221
10491
  case ElementType.LINK: return /* @__PURE__ */ jsx("div", {
10222
10492
  className: top_bar_module_default.item,
@@ -10287,14 +10557,14 @@ var TopBar = ({ title, appSwitcher, content = [], contentRight = [], warning = "
10287
10557
  version: title.version,
10288
10558
  onClick: title.onClick
10289
10559
  }), content.map((element, i) => {
10290
- if (element) return /* @__PURE__ */ jsx(Element, { element }, i);
10560
+ if (element) return /* @__PURE__ */ jsx(Element$1, { element }, i);
10291
10561
  return null;
10292
10562
  })]
10293
10563
  }),
10294
10564
  /* @__PURE__ */ jsx("div", {
10295
10565
  className: top_bar_module_default.right,
10296
10566
  children: contentRight.map((element, i) => {
10297
- if (element) return /* @__PURE__ */ jsx(Element, { element }, i);
10567
+ if (element) return /* @__PURE__ */ jsx(Element$1, { element }, i);
10298
10568
  return null;
10299
10569
  })
10300
10570
  })
@@ -14622,4 +14892,4 @@ var initializeGuiLibrary = (config) => {
14622
14892
  });
14623
14893
  };
14624
14894
  //#endregion
14625
- export { Accordion, AccordionWithDefaultToggle, Actions, Align, AuditLog, Badge, Breadcrumb, BreadcrumbLinkType, Button, ButtonGroup, ButtonPosition, ButtonType, Card, CheckBox, Chevron, Collapse, Color, ColorInput, ColorInputPopover, Column, Dialog, DiffCode, DiffTable, DiffViewer, DisabledContext, Divider, Drawer, ElementType, Empty, ErrorBoundary, Field, FileButton, FileInput, Flex, FormRow, Grid, GroupOrder, Heading, HelpIcon, Icon, IconType, Input, InputGroup, InputGroupAddon, InputReaderMethods, InputType, Label, List, ListHeading, ListSubheading, Loader, Mention, Menu, MenuCarat, MenuType, Message, MessageType, Modal, NativeSelect, NumberInput, OptionDropdown, Page, Pagination, PopConfirm, Popover, Portal, PrintHeader, ProgressBar, RadioButton, Resizable, RichTextInput, Row, Select, SettingField, SideBar, Skeleton, Slider, SmartUploadModal, Spacer, Spinner, Table, TableImportExport, Tabs, Text, TextArea, TextLink, TextTransform, Theme, Toaster, Toggle, Tooltip, TopBar, Tree, TreeTable, TriggerType, UnitInput, UnitSlider, UnitTable, UsageTracker, dismissToast, initializeContext, initializeGuiLibrary, readFile, toast, useFocus, useKeyboardEvent, useWindowWidth, withChainableErrorBoundary, withErrorBoundary };
14895
+ export { Accordion, AccordionWithDefaultToggle, Actions, Align, AuditLog, Badge, Breadcrumb, BreadcrumbLinkType, Button, ButtonGroup, ButtonPosition, ButtonType, Card, CheckBox, Chevron, Collapse, Color, ColorInput, ColorInputPopover, Column, Dialog, DiffCode, DiffTable, DiffViewer, DisabledContext, Divider, Drawer, ElementType, Empty, ErrorBoundary, Field, FileButton, FileInput, Flex, FormRow, Grid, GroupOrder, Heading, HelpIcon, Icon, IconType, Input, InputGroup, InputGroupAddon, InputReaderMethods, InputType, Label, List, ListHeading, ListSubheading, Loader, Mention, Menu, MenuCarat, MenuTriggerType, MenuType, Message, MessageType, Modal, NativeSelect, NumberInput, OptionDropdown, Page, Pagination, PopConfirm, Popover, Portal, PrintHeader, ProgressBar, RadioButton, Resizable, RichTextInput, Row, Select, SettingField, SideBar, Skeleton, Slider, SmartUploadModal, Spacer, Spinner, Table, TableImportExport, Tabs, Text, TextArea, TextLink, TextTransform, Theme, Toaster, Toggle, Tooltip, TopBar, Tree, TreeTable, TriggerType, UnitInput, UnitSlider, UnitTable, UsageTracker, dismissToast, initializeContext, initializeGuiLibrary, readFile, toast, useFocus, useKeyboardEvent, useWindowWidth, withChainableErrorBoundary, withErrorBoundary };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/react-ui-library",
3
- "version": "10.7.0",
3
+ "version": "10.8.0-beta-2",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/react-ui-library",
6
6
  "bugs": {