@vuu-ui/vuu-ui-controls 0.8.10-debug → 0.8.11-debug
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/cjs/index.js +1188 -939
- package/cjs/index.js.map +4 -4
- package/esm/index.js +1052 -797
- package/esm/index.js.map +4 -4
- package/index.css +35 -3
- package/index.css.map +3 -3
- package/package.json +8 -8
- package/types/combo-box/ComboBox.d.ts +19 -0
- package/types/combo-box/useCombobox.d.ts +25 -0
- package/types/{vuu-ui-controls/src/common-hooks → common-hooks}/collectionTypes.d.ts +4 -4
- package/types/{vuu-ui-controls/src/common-hooks → common-hooks}/navigationTypes.d.ts +2 -3
- package/types/{vuu-ui-controls/src/common-hooks → common-hooks}/selectionTypes.d.ts +30 -14
- package/types/common-hooks/useSelection.d.ts +8 -0
- package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/drop-target-utils.d.ts +6 -6
- package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/useDragDisplacers.d.ts +2 -2
- package/types/dropdown/Dropdown.d.ts +10 -0
- package/types/{vuu-ui-controls/src/dropdown → dropdown}/dropdownTypes.d.ts +9 -4
- package/types/{vuu-ui-controls/src/dropdown → dropdown}/useClickAway.d.ts +2 -1
- package/types/dropdown/useDropdown.d.ts +13 -0
- package/types/{vuu-ui-controls/src/index.d.ts → index.d.ts} +1 -0
- package/types/instrument-picker/InstrumentPicker.d.ts +16 -0
- package/types/instrument-picker/index.d.ts +1 -0
- package/types/{vuu-ui-controls/src/instrument-search → instrument-picker}/useDataSource.d.ts +1 -1
- package/types/instrument-picker/useInstrumentPicker.d.ts +24 -0
- package/types/instrument-search/SearchCell.d.ts +4 -0
- package/types/instrument-search/moving-window.d.ts +14 -0
- package/types/instrument-search/useDataSource.d.ts +7 -0
- package/types/list/List.d.ts +7 -0
- package/types/list/common-hooks/useKeyboardNavigation.d.ts +3 -0
- package/types/list/common-hooks/utils/isSelected.d.ts +2 -0
- package/types/{vuu-ui-controls/src/list → list}/listTypes.d.ts +6 -12
- package/types/list/useList.d.ts +3 -0
- package/types/list/useListDrop.d.ts +15 -0
- package/types/{vuu-ui-controls/src/tabstrip → tabstrip}/Tab.d.ts +1 -1
- package/types/{vuu-ui-controls/src/tabstrip → tabstrip}/TabMenuOptions.d.ts +1 -1
- package/types/{vuu-ui-controls/src/tabstrip → tabstrip}/TabsTypes.d.ts +1 -1
- package/types/vuu-input/VuuInput.d.ts +13 -0
- package/types/vuu-popups/src/dialog/Dialog.d.ts +0 -8
- package/types/vuu-popups/src/dialog/index.d.ts +0 -1
- package/types/vuu-popups/src/index.d.ts +0 -8
- package/types/vuu-popups/src/menu/ContextMenu.d.ts +0 -16
- package/types/vuu-popups/src/menu/MenuList.d.ts +0 -43
- package/types/vuu-popups/src/menu/context-menu-provider.d.ts +0 -10
- package/types/vuu-popups/src/menu/index.d.ts +0 -4
- package/types/vuu-popups/src/menu/key-code.d.ts +0 -12
- package/types/vuu-popups/src/menu/list-dom-utils.d.ts +0 -4
- package/types/vuu-popups/src/menu/use-cascade.d.ts +0 -25
- package/types/vuu-popups/src/menu/use-items-with-ids-next.d.ts +0 -13
- package/types/vuu-popups/src/menu/use-keyboard-navigation.d.ts +0 -27
- package/types/vuu-popups/src/menu/useContextMenu.d.ts +0 -20
- package/types/vuu-popups/src/menu/utils.d.ts +0 -2
- package/types/vuu-popups/src/popup/Popup.d.ts +0 -10
- package/types/vuu-popups/src/popup/index.d.ts +0 -3
- package/types/vuu-popups/src/popup/popup-service.d.ts +0 -59
- package/types/vuu-popups/src/popup/useAnchoredPosition.d.ts +0 -12
- package/types/vuu-popups/src/popup-menu/PopupMenu.d.ts +0 -16
- package/types/vuu-popups/src/popup-menu/index.d.ts +0 -1
- package/types/vuu-popups/src/portal/Portal.d.ts +0 -30
- package/types/vuu-popups/src/portal/index.d.ts +0 -1
- package/types/vuu-popups/src/portal-deprecated/PortalDeprecated.d.ts +0 -8
- package/types/vuu-popups/src/portal-deprecated/index.d.ts +0 -3
- package/types/vuu-popups/src/portal-deprecated/portal-utils.d.ts +0 -1
- package/types/vuu-popups/src/portal-deprecated/render-portal.d.ts +0 -10
- package/types/vuu-popups/src/prompt/Prompt.d.ts +0 -14
- package/types/vuu-popups/src/prompt/index.d.ts +0 -1
- package/types/vuu-popups/src/tooltip/Tooltip.d.ts +0 -12
- package/types/vuu-popups/src/tooltip/index.d.ts +0 -2
- package/types/vuu-popups/src/tooltip/useAnchoredPosition.d.ts +0 -12
- package/types/vuu-popups/src/tooltip/useTooltip.d.ts +0 -16
- package/types/vuu-ui-controls/src/combo-box/ComboBox.d.ts +0 -18
- package/types/vuu-ui-controls/src/combo-box/useCombobox.d.ts +0 -22
- package/types/vuu-ui-controls/src/common-hooks/useSelection.d.ts +0 -8
- package/types/vuu-ui-controls/src/dropdown/Dropdown.d.ts +0 -10
- package/types/vuu-ui-controls/src/dropdown/useDropdown.d.ts +0 -13
- package/types/vuu-ui-controls/src/list/List.d.ts +0 -7
- package/types/vuu-ui-controls/src/list/common-hooks/useKeyboardNavigation.d.ts +0 -3
- package/types/vuu-ui-controls/src/list/common-hooks/utils/isSelected.d.ts +0 -2
- package/types/vuu-ui-controls/src/list/useList.d.ts +0 -3
- package/types/vuu-ui-controls/src/vuu-input/VuuInput.d.ts +0 -10
- package/types/vuu-utils/src/DataWindow.d.ts +0 -39
- package/types/vuu-utils/src/array-utils.d.ts +0 -6
- package/types/vuu-utils/src/box-utils.d.ts +0 -9
- package/types/vuu-utils/src/column-utils.d.ts +0 -130
- package/types/vuu-utils/src/common-types.d.ts +0 -6
- package/types/vuu-utils/src/component-registry.d.ts +0 -23
- package/types/vuu-utils/src/cookie-utils.d.ts +0 -1
- package/types/vuu-utils/src/data-utils.d.ts +0 -14
- package/types/vuu-utils/src/date-utils.d.ts +0 -7
- package/types/vuu-utils/src/debug-utils.d.ts +0 -9
- package/types/vuu-utils/src/event-emitter.d.ts +0 -13
- package/types/vuu-utils/src/filter-utils.d.ts +0 -14
- package/types/vuu-utils/src/formatting-utils.d.ts +0 -9
- package/types/vuu-utils/src/getUniqueId.d.ts +0 -1
- package/types/vuu-utils/src/group-utils.d.ts +0 -3
- package/types/vuu-utils/src/html-utils.d.ts +0 -12
- package/types/vuu-utils/src/index.d.ts +0 -34
- package/types/vuu-utils/src/input-utils.d.ts +0 -2
- package/types/vuu-utils/src/invariant.d.ts +0 -1
- package/types/vuu-utils/src/itemToString.d.ts +0 -2
- package/types/vuu-utils/src/json-utils.d.ts +0 -6
- package/types/vuu-utils/src/keyboard-utils.d.ts +0 -12
- package/types/vuu-utils/src/keyset.d.ts +0 -11
- package/types/vuu-utils/src/logging-utils.d.ts +0 -44
- package/types/vuu-utils/src/menu-utils.d.ts +0 -2
- package/types/vuu-utils/src/nanoid/index.d.ts +0 -1
- package/types/vuu-utils/src/perf-utils.d.ts +0 -5
- package/types/vuu-utils/src/range-utils.d.ts +0 -24
- package/types/vuu-utils/src/round-decimal.d.ts +0 -1
- package/types/vuu-utils/src/row-utils.d.ts +0 -7
- package/types/vuu-utils/src/screenshot-utils.d.ts +0 -6
- package/types/vuu-utils/src/selection-utils.d.ts +0 -27
- package/types/vuu-utils/src/sort-utils.d.ts +0 -5
- package/types/vuu-utils/src/text-utils.d.ts +0 -2
- package/types/vuu-utils/src/url-utils.d.ts +0 -2
- /package/types/{vuu-ui-controls/src/combo-box → combo-box}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/common-hooks → common-hooks}/collectionProvider.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/common-hooks → common-hooks}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/common-hooks → common-hooks}/itemToString.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/common-hooks → common-hooks}/use-resize-observer.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/common-hooks → common-hooks}/useCollectionItems.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/common-hooks → common-hooks}/useControlled.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/DragDropProvider.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/DragDropState.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/Draggable.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/DropIndicator.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/dragDropTypesNext.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/useAutoScroll.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/useDragDropIndicator.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/useDragDropNaturalMovementNext.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/useDragDropNext.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/useDropIndicator.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/useGlobalDragDrop.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/drag-drop → drag-drop}/useTransition.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/dropdown → dropdown}/DropdownBase.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/dropdown → dropdown}/DropdownButton.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/dropdown → dropdown}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/dropdown → dropdown}/useDropdownBase.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/editable → editable}/editable-utils.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/editable → editable}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/editable → editable}/useEditableText.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/editable-label → editable-label}/EditableLabel.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/editable-label → editable-label}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/expando-input → expando-input}/ExpandoInput.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/expando-input → expando-input}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/inputs → inputs}/Checkbox.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/inputs → inputs}/RadioButton.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/inputs → inputs}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/instrument-search → instrument-picker}/SearchCell.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/instrument-search → instrument-picker}/moving-window.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/instrument-search → instrument-search}/InstrumentSearch.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/instrument-search → instrument-search}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/CheckboxIcon.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/ChevronIcon.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/Highlighter.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/ListItem.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/ListItemGroup.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/ListItemHeader.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/RadioIcon.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/VirtualizedList.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/common-hooks/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/common-hooks/keyUtils.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/common-hooks/list-dom-utils.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/common-hooks/useCollapsibleGroups.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/common-hooks/useImperativeScrollingAPI.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/common-hooks/useTypeahead.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/common-hooks/useViewportTracking.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/common-hooks/utils/collection-item-utils.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/common-hooks/utils/filter-utils.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/common-hooks/utils/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/keyset.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/useListHeight.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/useScrollPosition.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/list → list}/useVirtualization.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/price-ticker → price-ticker}/PriceTicker.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/price-ticker → price-ticker}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tabstrip → tabstrip}/TabMenu.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tabstrip → tabstrip}/Tabstrip.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tabstrip → tabstrip}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tabstrip → tabstrip}/tabstrip-dom-utils.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tabstrip → tabstrip}/useAnimatedSelectionThumb.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tabstrip → tabstrip}/useKeyboardNavigation.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tabstrip → tabstrip}/useSelection.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tabstrip → tabstrip}/useTabstrip.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tree → tree}/Tree.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tree → tree}/hierarchical-data-utils.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tree → tree}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tree → tree}/key-code.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tree → tree}/list-dom-utils.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tree → tree}/use-collapsible-groups.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tree → tree}/use-hierarchical-data.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tree → tree}/use-items-with-ids.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tree → tree}/use-keyboard-navigation.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tree → tree}/use-selection.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tree → tree}/use-tree-keyboard-navigation.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tree → tree}/use-viewport-tracking.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/tree → tree}/useTree.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/utils → utils}/escapeRegExp.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/utils → utils}/forwardCallbackProps.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/utils → utils}/index.d.ts +0 -0
- /package/types/{vuu-ui-controls/src/vuu-input → vuu-input}/index.d.ts +0 -0
package/esm/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import { useId as useId4 } from "@vuu-ui/vuu-layout";
|
|
|
3
3
|
import { Input } from "@salt-ds/core";
|
|
4
4
|
import {
|
|
5
5
|
forwardRef as forwardRef8,
|
|
6
|
-
useCallback as
|
|
7
|
-
useRef as
|
|
6
|
+
useCallback as useCallback27,
|
|
7
|
+
useRef as useRef25
|
|
8
8
|
} from "react";
|
|
9
9
|
|
|
10
10
|
// src/common-hooks/collectionProvider.tsx
|
|
@@ -172,15 +172,13 @@ function useResizeObserver(ref, dimensions2, onResize, reportInitialSize = false
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
// src/common-hooks/selectionTypes.ts
|
|
175
|
+
var isSingleSelection = (s) => s === void 0 || s === "default" || s === "deselectable";
|
|
176
|
+
var isMultiSelection = (s) => s === "multiple" || (s == null ? void 0 : s.startsWith("extended")) === true;
|
|
175
177
|
var selectionIsDisallowed = (selection) => selection === "none";
|
|
176
178
|
var allowMultipleSelection = (selectionStrategy, specialKey = false) => selectionStrategy === "multiple" || selectionStrategy === "multiple-special-key" && specialKey;
|
|
177
179
|
var deselectionIsAllowed = (selection) => selection !== "none" && selection !== "default";
|
|
178
|
-
var hasSelection = (selected) =>
|
|
179
|
-
|
|
180
|
-
};
|
|
181
|
-
var getFirstSelectedItem = (selected) => {
|
|
182
|
-
return Array.isArray(selected) ? selected[0] : selected;
|
|
183
|
-
};
|
|
180
|
+
var hasSelection = (selected) => selected !== void 0 && selected.length > 0;
|
|
181
|
+
var getFirstSelectedItem = (selected) => selected[0];
|
|
184
182
|
|
|
185
183
|
// src/common-hooks/useCollectionItems.ts
|
|
186
184
|
import { useCallback as useCallback3, useMemo, useRef as useRef3, useState as useState2, isValidElement as isValidElement3 } from "react";
|
|
@@ -285,7 +283,7 @@ var sourceItems = (source, options) => {
|
|
|
285
283
|
} else {
|
|
286
284
|
return source.map(
|
|
287
285
|
(item, index) => {
|
|
288
|
-
var
|
|
286
|
+
var _a2, _b;
|
|
289
287
|
return {
|
|
290
288
|
childNodes: sourceItems(
|
|
291
289
|
item.childNodes,
|
|
@@ -294,7 +292,7 @@ var sourceItems = (source, options) => {
|
|
|
294
292
|
description: item.description,
|
|
295
293
|
expanded: item.expanded,
|
|
296
294
|
value: item,
|
|
297
|
-
label: (_b = (
|
|
295
|
+
label: (_b = (_a2 = options == null ? void 0 : options.itemToString) == null ? void 0 : _a2.call(options, item)) != null ? _b : itemToString(item)
|
|
298
296
|
};
|
|
299
297
|
}
|
|
300
298
|
);
|
|
@@ -389,8 +387,8 @@ var getDefaultFilterRegex = (value) => new RegExp(`(${escapeRegExp(leftTrim(valu
|
|
|
389
387
|
var getDefaultFilter = (inputValue = "", getFilterRegex = getDefaultFilterRegex) => (itemValue = "") => Boolean(itemValue.length) && Boolean(inputValue.length) && itemValue.match(getFilterRegex(inputValue)) !== null;
|
|
390
388
|
|
|
391
389
|
// src/list/common-hooks/utils/isSelected.ts
|
|
392
|
-
function isSelected(
|
|
393
|
-
const isSelected2 = Array.isArray(
|
|
390
|
+
function isSelected(selectedId, item) {
|
|
391
|
+
const isSelected2 = Array.isArray(selectedId) ? selectedId.includes(item.id) : selectedId === item.id;
|
|
394
392
|
return isSelected2;
|
|
395
393
|
}
|
|
396
394
|
|
|
@@ -463,14 +461,14 @@ var useCollectionItems = ({
|
|
|
463
461
|
// revealSelected = false,
|
|
464
462
|
source
|
|
465
463
|
}) => {
|
|
466
|
-
var
|
|
464
|
+
var _a2;
|
|
467
465
|
const { getItemId } = options;
|
|
468
466
|
const [, forceUpdate] = useState2(null);
|
|
469
467
|
const inheritedCollectionHook = useCollection();
|
|
470
468
|
const dataRef = useRef3([]);
|
|
471
469
|
const flattenedDataRef = useRef3([]);
|
|
472
470
|
const EMPTY_COLLECTION = useMemo(() => [], []);
|
|
473
|
-
const filterPattern = useRef3((
|
|
471
|
+
const filterPattern = useRef3((_a2 = options.filterPattern) != null ? _a2 : "");
|
|
474
472
|
const {
|
|
475
473
|
getFilterRegex = getDefaultFilterRegex,
|
|
476
474
|
noChildrenLabel,
|
|
@@ -482,13 +480,13 @@ var useCollectionItems = ({
|
|
|
482
480
|
const addMetadataToItems = useCallback3(
|
|
483
481
|
(items, indexer, level = 1, path = "", results = [], flattenedCollection2 = [], flattenedSource2 = []) => {
|
|
484
482
|
items.forEach((item, i, all) => {
|
|
485
|
-
var
|
|
483
|
+
var _a3, _b;
|
|
486
484
|
const isCollapsibleHeader = item.header && options.collapsibleHeaders;
|
|
487
485
|
const isNonCollapsibleGroupNode = item.childNodes && options.collapsibleHeaders === false;
|
|
488
486
|
const isLeaf3 = !item.childNodes || item.childNodes.length === 0;
|
|
489
487
|
const nonCollapsible = isNonCollapsibleGroupNode || isLeaf3 && !isCollapsibleHeader;
|
|
490
488
|
const childPath = path ? `${path}.${i}` : `item-${i}`;
|
|
491
|
-
const id = (
|
|
489
|
+
const id = (_a3 = item.id) != null ? _a3 : getItemId ? getItemId(i) : `${idRoot}-${childPath}`;
|
|
492
490
|
const expanded = nonCollapsible ? void 0 : (_b = item.expanded) != null ? _b : isExpanded2();
|
|
493
491
|
const normalisedItem = {
|
|
494
492
|
...item,
|
|
@@ -601,8 +599,8 @@ var useCollectionItems = ({
|
|
|
601
599
|
(id, target = collectionItems) => {
|
|
602
600
|
const sourceWithId = target.find(
|
|
603
601
|
(i) => {
|
|
604
|
-
var
|
|
605
|
-
return i.id === id || ((
|
|
602
|
+
var _a3;
|
|
603
|
+
return i.id === id || ((_a3 = i == null ? void 0 : i.childNodes) == null ? void 0 : _a3.length) && isParentPath(i.id, id);
|
|
606
604
|
}
|
|
607
605
|
);
|
|
608
606
|
if ((sourceWithId == null ? void 0 : sourceWithId.id) === id) {
|
|
@@ -614,15 +612,26 @@ var useCollectionItems = ({
|
|
|
614
612
|
},
|
|
615
613
|
[flattenedSource, collectionItems]
|
|
616
614
|
);
|
|
615
|
+
const indexOfItemById = useCallback3(
|
|
616
|
+
(id, target = collectionItems) => {
|
|
617
|
+
const sourceWithId = target.find(
|
|
618
|
+
(i) => {
|
|
619
|
+
var _a3;
|
|
620
|
+
return i.id === id || ((_a3 = i == null ? void 0 : i.childNodes) == null ? void 0 : _a3.length) && isParentPath(i.id, id);
|
|
621
|
+
}
|
|
622
|
+
);
|
|
623
|
+
const idx = sourceWithId ? dataRef.current.indexOf(sourceWithId) : -1;
|
|
624
|
+
if (idx !== -1) {
|
|
625
|
+
return idx;
|
|
626
|
+
}
|
|
627
|
+
throw Error(`useCollectionData indexOfItemById, id ${id} not found `);
|
|
628
|
+
},
|
|
629
|
+
[collectionItems]
|
|
630
|
+
);
|
|
617
631
|
const toCollectionItem = useCallback3(
|
|
618
632
|
(item) => {
|
|
619
633
|
const collectionItem = flattenedDataRef.current.find(
|
|
620
|
-
(i) => (
|
|
621
|
-
// const collectionItem = collectionItemsRef.current.find((i) =>
|
|
622
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
623
|
-
//@ts-ignore
|
|
624
|
-
isValidElement3(i.value) ? i.label === item : i.value === item
|
|
625
|
-
)
|
|
634
|
+
(i) => isValidElement3(i.value) ? i.label === item : i.value === item
|
|
626
635
|
);
|
|
627
636
|
if (collectionItem) {
|
|
628
637
|
return collectionItem;
|
|
@@ -658,9 +667,9 @@ var useCollectionItems = ({
|
|
|
658
667
|
if (Array.isArray(selectedCollectionItem)) {
|
|
659
668
|
return selectedCollectionItem.map((i) => i.id);
|
|
660
669
|
} else if (selectedCollectionItem) {
|
|
661
|
-
return selectedCollectionItem.id;
|
|
670
|
+
return [selectedCollectionItem.id];
|
|
662
671
|
} else {
|
|
663
|
-
return
|
|
672
|
+
return [];
|
|
664
673
|
}
|
|
665
674
|
},
|
|
666
675
|
[itemToCollectionItem]
|
|
@@ -740,6 +749,7 @@ var useCollectionItems = ({
|
|
|
740
749
|
expandGroupItem,
|
|
741
750
|
// why not toggle, or just rely on setdata ?
|
|
742
751
|
setFilterPattern,
|
|
752
|
+
indexOfItemById,
|
|
743
753
|
itemById,
|
|
744
754
|
itemToId,
|
|
745
755
|
toCollectionItem,
|
|
@@ -756,7 +766,11 @@ import { Children as Children2, cloneElement as cloneElement2, forwardRef, useRe
|
|
|
756
766
|
|
|
757
767
|
// src/dropdown/useDropdownBase.ts
|
|
758
768
|
import { useControlled as useControlled2, useForkRef } from "@salt-ds/core";
|
|
759
|
-
import {
|
|
769
|
+
import {
|
|
770
|
+
useCallback as useCallback4,
|
|
771
|
+
useRef as useRef5,
|
|
772
|
+
useState as useState3
|
|
773
|
+
} from "react";
|
|
760
774
|
|
|
761
775
|
// src/dropdown/useClickAway.ts
|
|
762
776
|
import { useEffect as useEffect3, useRef as useRef4 } from "react";
|
|
@@ -774,16 +788,16 @@ var useClickAway = ({
|
|
|
774
788
|
useEffect3(() => {
|
|
775
789
|
const [clickHandler, escapeKeyHandler] = isOpen ? [
|
|
776
790
|
(evt) => {
|
|
777
|
-
var
|
|
791
|
+
var _a2, _b;
|
|
778
792
|
const targetElement = evt.target;
|
|
779
|
-
if (!((
|
|
780
|
-
onClose();
|
|
793
|
+
if (!((_a2 = popperRef.current) == null ? void 0 : _a2.contains(targetElement)) && !((_b = rootRef.current) == null ? void 0 : _b.contains(targetElement))) {
|
|
794
|
+
onClose("click-away");
|
|
781
795
|
}
|
|
782
796
|
},
|
|
783
797
|
(e) => {
|
|
784
798
|
if (e.key === "Escape") {
|
|
785
799
|
if (openRef.current) {
|
|
786
|
-
onClose();
|
|
800
|
+
onClose("Escape");
|
|
787
801
|
e.stopPropagation();
|
|
788
802
|
}
|
|
789
803
|
}
|
|
@@ -820,7 +834,7 @@ var useDropdownBase = ({
|
|
|
820
834
|
rootRef,
|
|
821
835
|
width
|
|
822
836
|
}) => {
|
|
823
|
-
var
|
|
837
|
+
var _a2;
|
|
824
838
|
const justFocused = useRef5(null);
|
|
825
839
|
const popperRef = useRef5(null);
|
|
826
840
|
const popperCallbackRef = useCallback4((element) => {
|
|
@@ -833,16 +847,19 @@ var useDropdownBase = ({
|
|
|
833
847
|
state: "isOpen"
|
|
834
848
|
});
|
|
835
849
|
const [popup, setPopup] = useState3({
|
|
836
|
-
width: (
|
|
850
|
+
width: (_a2 = popupWidthProp != null ? popupWidthProp : width) != null ? _a2 : 0
|
|
837
851
|
});
|
|
838
852
|
const showDropdown = useCallback4(() => {
|
|
839
853
|
setIsOpen(true);
|
|
840
854
|
onOpenChange == null ? void 0 : onOpenChange(true);
|
|
841
855
|
}, [onOpenChange, setIsOpen]);
|
|
842
|
-
const hideDropdown = useCallback4(
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
856
|
+
const hideDropdown = useCallback4(
|
|
857
|
+
(reason) => {
|
|
858
|
+
setIsOpen(false);
|
|
859
|
+
onOpenChange == null ? void 0 : onOpenChange(false, reason);
|
|
860
|
+
},
|
|
861
|
+
[onOpenChange, setIsOpen]
|
|
862
|
+
);
|
|
846
863
|
useClickAway({
|
|
847
864
|
popperRef,
|
|
848
865
|
rootRef,
|
|
@@ -874,12 +891,15 @@ var useDropdownBase = ({
|
|
|
874
891
|
);
|
|
875
892
|
const handleKeydown = useCallback4(
|
|
876
893
|
(evt) => {
|
|
877
|
-
if (
|
|
894
|
+
if (
|
|
895
|
+
/* evt.key === "Tab" || */
|
|
896
|
+
evt.key === "Escape" && isOpen
|
|
897
|
+
) {
|
|
878
898
|
if (evt.key === "Escape") {
|
|
879
899
|
evt.stopPropagation();
|
|
880
900
|
evt.preventDefault();
|
|
881
901
|
}
|
|
882
|
-
hideDropdown();
|
|
902
|
+
hideDropdown(evt.key);
|
|
883
903
|
} else if (openKeys.includes(evt.key) && !isOpen) {
|
|
884
904
|
evt.preventDefault();
|
|
885
905
|
showDropdown();
|
|
@@ -889,6 +909,23 @@ var useDropdownBase = ({
|
|
|
889
909
|
},
|
|
890
910
|
[hideDropdown, isOpen, onKeyDownProp, openKeys, showDropdown]
|
|
891
911
|
);
|
|
912
|
+
const handleBlur = useCallback4(
|
|
913
|
+
(evt) => {
|
|
914
|
+
var _a3;
|
|
915
|
+
console.log("useDropdownBase blur", {
|
|
916
|
+
popperRef: popperRef.current,
|
|
917
|
+
relatedTarget: evt.relatedTarget
|
|
918
|
+
});
|
|
919
|
+
if (isOpen) {
|
|
920
|
+
if ((_a3 = popperRef.current) == null ? void 0 : _a3.contains(evt.relatedTarget)) {
|
|
921
|
+
} else {
|
|
922
|
+
console.log("hide dropdown");
|
|
923
|
+
hideDropdown("blur");
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
},
|
|
927
|
+
[hideDropdown, isOpen]
|
|
928
|
+
);
|
|
892
929
|
const fullWidth = fullWidthProp != null ? fullWidthProp : false;
|
|
893
930
|
const measurements2 = fullWidth ? WidthOnly : NO_OBSERVER;
|
|
894
931
|
useResizeObserver(rootRef, measurements2, setPopup, fullWidth);
|
|
@@ -900,6 +937,7 @@ var useDropdownBase = ({
|
|
|
900
937
|
onClick: disabled || openOnFocus ? void 0 : handleTriggerToggle,
|
|
901
938
|
onFocus: handleTriggerFocus,
|
|
902
939
|
role: "listbox",
|
|
940
|
+
onBlur: handleBlur,
|
|
903
941
|
onKeyDown: disabled ? void 0 : handleKeydown,
|
|
904
942
|
style: { width: fullWidth ? void 0 : width }
|
|
905
943
|
};
|
|
@@ -907,7 +945,7 @@ var useDropdownBase = ({
|
|
|
907
945
|
id: componentId,
|
|
908
946
|
width: popup.width
|
|
909
947
|
};
|
|
910
|
-
const popupComponentRef = useForkRef(popperCallbackRef,
|
|
948
|
+
const popupComponentRef = useForkRef(popperCallbackRef, popupComponent.ref);
|
|
911
949
|
return {
|
|
912
950
|
componentProps: dropdownComponentProps,
|
|
913
951
|
popupComponentRef,
|
|
@@ -924,6 +962,7 @@ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
|
924
962
|
var classBase = "vuuDropdown";
|
|
925
963
|
var DropdownBase = forwardRef(
|
|
926
964
|
function Dropdown({
|
|
965
|
+
PopupProps,
|
|
927
966
|
"aria-labelledby": ariaLabelledByProp,
|
|
928
967
|
children,
|
|
929
968
|
className: classNameProp,
|
|
@@ -936,7 +975,7 @@ var DropdownBase = forwardRef(
|
|
|
936
975
|
onOpenChange,
|
|
937
976
|
openKeys,
|
|
938
977
|
openOnFocus,
|
|
939
|
-
placement = "below",
|
|
978
|
+
placement = "below-full-width",
|
|
940
979
|
popupWidth,
|
|
941
980
|
width,
|
|
942
981
|
...htmlAttributes
|
|
@@ -1000,13 +1039,21 @@ var DropdownBase = forwardRef(
|
|
|
1000
1039
|
className: cx(className2, `${classBase}-popup-component`),
|
|
1001
1040
|
id: id2,
|
|
1002
1041
|
ref: popupComponentRef,
|
|
1003
|
-
width: ownWidth != null ? ownWidth : width2
|
|
1042
|
+
width: placement.endsWith("full-width") ? "100%" : ownWidth != null ? ownWidth : width2
|
|
1004
1043
|
});
|
|
1005
1044
|
};
|
|
1006
1045
|
const ref = useForkRef2(rootRef, forwardedRef);
|
|
1007
1046
|
return /* @__PURE__ */ jsxs("div", { ...htmlAttributes, className, id: idProp, ref, children: [
|
|
1008
1047
|
getTriggerComponent(),
|
|
1009
|
-
isOpen && /* @__PURE__ */ jsx2(Portal, { children: /* @__PURE__ */ jsx2(
|
|
1048
|
+
isOpen && /* @__PURE__ */ jsx2(Portal, { children: /* @__PURE__ */ jsx2(
|
|
1049
|
+
Popup,
|
|
1050
|
+
{
|
|
1051
|
+
...PopupProps,
|
|
1052
|
+
anchorElement: rootRef,
|
|
1053
|
+
placement,
|
|
1054
|
+
children: getPopupComponent()
|
|
1055
|
+
}
|
|
1056
|
+
) })
|
|
1010
1057
|
] });
|
|
1011
1058
|
}
|
|
1012
1059
|
);
|
|
@@ -1075,8 +1122,8 @@ import { useForkRef as useForkRef6 } from "@salt-ds/core";
|
|
|
1075
1122
|
import {
|
|
1076
1123
|
cloneElement as cloneElement5,
|
|
1077
1124
|
forwardRef as forwardRef7,
|
|
1078
|
-
useCallback as
|
|
1079
|
-
useRef as
|
|
1125
|
+
useCallback as useCallback25,
|
|
1126
|
+
useRef as useRef23
|
|
1080
1127
|
} from "react";
|
|
1081
1128
|
import { useId as useId3 } from "@vuu-ui/vuu-layout";
|
|
1082
1129
|
|
|
@@ -1318,9 +1365,9 @@ function nextItemIdx(count, key, idx) {
|
|
|
1318
1365
|
}
|
|
1319
1366
|
}
|
|
1320
1367
|
var getIndexOfSelectedItem = (items, selected) => {
|
|
1321
|
-
const
|
|
1322
|
-
if (
|
|
1323
|
-
return items.
|
|
1368
|
+
const selectedItemId = Array.isArray(selected) ? getFirstSelectedItem(selected) : void 0;
|
|
1369
|
+
if (selectedItemId) {
|
|
1370
|
+
return items.findIndex((item) => item.id === selectedItemId);
|
|
1324
1371
|
} else {
|
|
1325
1372
|
return -1;
|
|
1326
1373
|
}
|
|
@@ -1456,6 +1503,7 @@ var useKeyboardNavigation = ({
|
|
|
1456
1503
|
const ignoreFocus = useRef7(false);
|
|
1457
1504
|
const setIgnoreFocus = (value) => ignoreFocus.current = value;
|
|
1458
1505
|
const handleFocus = useCallback6(() => {
|
|
1506
|
+
console.trace(`List useKeyboard focus`);
|
|
1459
1507
|
if (ignoreFocus.current) {
|
|
1460
1508
|
ignoreFocus.current = false;
|
|
1461
1509
|
} else {
|
|
@@ -1519,6 +1567,7 @@ var useKeyboardNavigation = ({
|
|
|
1519
1567
|
);
|
|
1520
1568
|
const handleKeyDown = useCallback6(
|
|
1521
1569
|
(e) => {
|
|
1570
|
+
console.log("handleKeyDown");
|
|
1522
1571
|
if (itemCount > 0 && isNavigationKey(e)) {
|
|
1523
1572
|
e.preventDefault();
|
|
1524
1573
|
e.stopPropagation();
|
|
@@ -1619,23 +1668,18 @@ var useSelection = ({
|
|
|
1619
1668
|
(evt) => selectionKeys.includes(evt.key),
|
|
1620
1669
|
[selectionKeys]
|
|
1621
1670
|
);
|
|
1622
|
-
const emptyValue = useCallback7(() => {
|
|
1623
|
-
return isMultipleSelect || isExtendedSelect ? [] : null;
|
|
1624
|
-
}, [isMultipleSelect, isExtendedSelect]);
|
|
1625
1671
|
const [selected, setSelected] = useControlled({
|
|
1626
1672
|
controlled: selectedProp,
|
|
1627
|
-
default: defaultSelected != null ? defaultSelected :
|
|
1673
|
+
default: defaultSelected != null ? defaultSelected : [],
|
|
1628
1674
|
name: "UseSelection",
|
|
1629
1675
|
state: "selected"
|
|
1630
1676
|
});
|
|
1631
1677
|
const isItemSelected = useCallback7(
|
|
1632
|
-
(itemId) =>
|
|
1633
|
-
return Array.isArray(selected) ? selected.includes(itemId) : selected === itemId;
|
|
1634
|
-
},
|
|
1678
|
+
(itemId) => selected.includes(itemId),
|
|
1635
1679
|
[selected]
|
|
1636
1680
|
);
|
|
1637
1681
|
const selectDeselectable = useCallback7(
|
|
1638
|
-
(itemId) => isItemSelected(itemId) ?
|
|
1682
|
+
(itemId) => isItemSelected(itemId) ? [] : [itemId],
|
|
1639
1683
|
[isItemSelected]
|
|
1640
1684
|
);
|
|
1641
1685
|
const selectMultiple = useCallback7(
|
|
@@ -1675,17 +1719,14 @@ var useSelection = ({
|
|
|
1675
1719
|
if (preserveExistingSelection && !rangeSelect) {
|
|
1676
1720
|
newSelected = selectMultiple(id);
|
|
1677
1721
|
} else if (rangeSelect) {
|
|
1678
|
-
newSelected = selectRange(
|
|
1679
|
-
idx,
|
|
1680
|
-
preserveExistingSelection
|
|
1681
|
-
);
|
|
1722
|
+
newSelected = selectRange(idx, preserveExistingSelection);
|
|
1682
1723
|
} else {
|
|
1683
1724
|
newSelected = [id];
|
|
1684
1725
|
}
|
|
1685
1726
|
} else if (isDeselectable) {
|
|
1686
1727
|
newSelected = selectDeselectable(id);
|
|
1687
1728
|
} else {
|
|
1688
|
-
newSelected = id;
|
|
1729
|
+
newSelected = [id];
|
|
1689
1730
|
}
|
|
1690
1731
|
if (newSelected !== selected) {
|
|
1691
1732
|
setSelected(newSelected);
|
|
@@ -2014,13 +2055,13 @@ import { forwardRef as forwardRef3 } from "react";
|
|
|
2014
2055
|
import cx4 from "classnames";
|
|
2015
2056
|
|
|
2016
2057
|
// src/list/CheckboxIcon.tsx
|
|
2017
|
-
import React from "react";
|
|
2018
2058
|
import cx3 from "classnames";
|
|
2059
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
2019
2060
|
var classBase3 = "vuuCheckboxIcon";
|
|
2020
2061
|
var CheckboxIcon = ({
|
|
2021
2062
|
checked = false,
|
|
2022
2063
|
...htmlAttributes
|
|
2023
|
-
}) => /* @__PURE__ */
|
|
2064
|
+
}) => /* @__PURE__ */ jsx5(
|
|
2024
2065
|
"span",
|
|
2025
2066
|
{
|
|
2026
2067
|
...htmlAttributes,
|
|
@@ -2029,13 +2070,13 @@ var CheckboxIcon = ({
|
|
|
2029
2070
|
);
|
|
2030
2071
|
|
|
2031
2072
|
// src/list/ListItem.tsx
|
|
2032
|
-
import { jsx as
|
|
2073
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2033
2074
|
var classBase4 = "vuuListItem";
|
|
2034
2075
|
var ListItemProxy = forwardRef3(function ListItemNextProxy({
|
|
2035
2076
|
height,
|
|
2036
2077
|
...htmlAttributes
|
|
2037
2078
|
}, forwardedRef) {
|
|
2038
|
-
return /* @__PURE__ */
|
|
2079
|
+
return /* @__PURE__ */ jsx6(
|
|
2039
2080
|
"div",
|
|
2040
2081
|
{
|
|
2041
2082
|
...htmlAttributes,
|
|
@@ -2080,8 +2121,8 @@ var ListItem = forwardRef3(
|
|
|
2080
2121
|
ref: forwardedRef,
|
|
2081
2122
|
style,
|
|
2082
2123
|
children: [
|
|
2083
|
-
showCheckbox && /* @__PURE__ */
|
|
2084
|
-
children && typeof children !== "string" ? children : itemTextHighlightPattern == null ? /* @__PURE__ */
|
|
2124
|
+
showCheckbox && /* @__PURE__ */ jsx6(CheckboxIcon, { "aria-hidden": true, checked: selected }),
|
|
2125
|
+
children && typeof children !== "string" ? children : itemTextHighlightPattern == null ? /* @__PURE__ */ jsx6("span", { className: `${classBase4}-textWrapper`, children: label || children }) : /* @__PURE__ */ jsx6(
|
|
2085
2126
|
Highlighter,
|
|
2086
2127
|
{
|
|
2087
2128
|
matchPattern: itemTextHighlightPattern,
|
|
@@ -2102,18 +2143,17 @@ import {
|
|
|
2102
2143
|
cloneElement as cloneElement4,
|
|
2103
2144
|
forwardRef as forwardRef5,
|
|
2104
2145
|
isValidElement as isValidElement4,
|
|
2105
|
-
useCallback as
|
|
2106
|
-
useRef as
|
|
2146
|
+
useCallback as useCallback23,
|
|
2147
|
+
useRef as useRef21,
|
|
2107
2148
|
useState as useState10
|
|
2108
2149
|
} from "react";
|
|
2109
2150
|
|
|
2110
2151
|
// src/list/useList.ts
|
|
2111
2152
|
import { useLayoutEffectSkipFirst } from "@vuu-ui/vuu-layout";
|
|
2112
2153
|
import {
|
|
2113
|
-
useCallback as
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
useRef as useRef17
|
|
2154
|
+
useCallback as useCallback20,
|
|
2155
|
+
useMemo as useMemo9,
|
|
2156
|
+
useRef as useRef18
|
|
2117
2157
|
} from "react";
|
|
2118
2158
|
|
|
2119
2159
|
// src/drag-drop/dragDropTypesNext.ts
|
|
@@ -2196,7 +2236,7 @@ var useGlobalDragDrop = ({
|
|
|
2196
2236
|
};
|
|
2197
2237
|
|
|
2198
2238
|
// src/drag-drop/DragDropProvider.tsx
|
|
2199
|
-
import { jsx as
|
|
2239
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
2200
2240
|
var NO_DRAG_CONTEXT = {
|
|
2201
2241
|
isDragSource: false,
|
|
2202
2242
|
isDropTarget: false,
|
|
@@ -2299,10 +2339,10 @@ var DragDropProvider = ({
|
|
|
2299
2339
|
registerDragDropParty
|
|
2300
2340
|
]
|
|
2301
2341
|
);
|
|
2302
|
-
return /* @__PURE__ */
|
|
2342
|
+
return /* @__PURE__ */ jsx7(DragDropContext.Provider, { value: contextValue, children });
|
|
2303
2343
|
};
|
|
2304
2344
|
var useDragDropProvider = (id) => {
|
|
2305
|
-
var
|
|
2345
|
+
var _a2, _b;
|
|
2306
2346
|
const {
|
|
2307
2347
|
dragSources,
|
|
2308
2348
|
dropTargets,
|
|
@@ -2311,7 +2351,7 @@ var useDragDropProvider = (id) => {
|
|
|
2311
2351
|
registerDragDropParty
|
|
2312
2352
|
} = useContext2(DragDropContext);
|
|
2313
2353
|
if (id) {
|
|
2314
|
-
const isDragSource = (
|
|
2354
|
+
const isDragSource = (_a2 = dragSources == null ? void 0 : dragSources.has(id)) != null ? _a2 : false;
|
|
2315
2355
|
const isDropTarget = (_b = dropTargets == null ? void 0 : dropTargets.has(id)) != null ? _b : false;
|
|
2316
2356
|
return {
|
|
2317
2357
|
isDragSource,
|
|
@@ -2352,10 +2392,86 @@ var DragDropState = class {
|
|
|
2352
2392
|
};
|
|
2353
2393
|
|
|
2354
2394
|
// src/drag-drop/useDragDropNaturalMovementNext.tsx
|
|
2355
|
-
import { useCallback as useCallback14, useMemo as
|
|
2395
|
+
import { useCallback as useCallback14, useMemo as useMemo7, useRef as useRef13, useState as useState5 } from "react";
|
|
2356
2396
|
|
|
2357
2397
|
// src/drag-drop/useDragDisplacers.ts
|
|
2358
|
-
import { useCallback as useCallback13, useMemo as
|
|
2398
|
+
import { useCallback as useCallback13, useMemo as useMemo6, useRef as useRef12 } from "react";
|
|
2399
|
+
|
|
2400
|
+
// src/drag-drop/Draggable.tsx
|
|
2401
|
+
import { useForkRef as useForkRef3 } from "@salt-ds/core";
|
|
2402
|
+
import cx5 from "classnames";
|
|
2403
|
+
import {
|
|
2404
|
+
forwardRef as forwardRef4,
|
|
2405
|
+
useCallback as useCallback12,
|
|
2406
|
+
useMemo as useMemo5
|
|
2407
|
+
} from "react";
|
|
2408
|
+
import { PopupComponent as Popup2, Portal as Portal2 } from "@vuu-ui/vuu-popups";
|
|
2409
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
2410
|
+
var makeClassNames = (classNames) => classNames.split(" ").map((className) => `vuuDraggable-${className}`);
|
|
2411
|
+
var Draggable = forwardRef4(function Draggable2({ wrapperClassName, element, onTransitionEnd, style, scale = 1 }, forwardedRef) {
|
|
2412
|
+
const callbackRef = useCallback12(
|
|
2413
|
+
(el) => {
|
|
2414
|
+
if (el) {
|
|
2415
|
+
el.innerHTML = "";
|
|
2416
|
+
el.appendChild(element);
|
|
2417
|
+
if (scale !== 1) {
|
|
2418
|
+
el.style.transform = `scale(${scale},${scale})`;
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
},
|
|
2422
|
+
[element, scale]
|
|
2423
|
+
);
|
|
2424
|
+
const forkedRef = useForkRef3(forwardedRef, callbackRef);
|
|
2425
|
+
const position = useMemo5(
|
|
2426
|
+
() => ({
|
|
2427
|
+
left: 0,
|
|
2428
|
+
top: 0
|
|
2429
|
+
}),
|
|
2430
|
+
[]
|
|
2431
|
+
);
|
|
2432
|
+
return /* @__PURE__ */ jsx8(Portal2, { children: /* @__PURE__ */ jsx8(
|
|
2433
|
+
Popup2,
|
|
2434
|
+
{
|
|
2435
|
+
anchorElement: { current: document.body },
|
|
2436
|
+
placement: "absolute",
|
|
2437
|
+
position,
|
|
2438
|
+
children: /* @__PURE__ */ jsx8(
|
|
2439
|
+
"div",
|
|
2440
|
+
{
|
|
2441
|
+
className: cx5("vuuDraggable", ...makeClassNames(wrapperClassName)),
|
|
2442
|
+
ref: forkedRef,
|
|
2443
|
+
onTransitionEnd,
|
|
2444
|
+
style
|
|
2445
|
+
}
|
|
2446
|
+
)
|
|
2447
|
+
}
|
|
2448
|
+
) });
|
|
2449
|
+
});
|
|
2450
|
+
var createDragSpacer = (transitioning) => {
|
|
2451
|
+
const spacer = document.createElement("div");
|
|
2452
|
+
spacer.className = "vuuDraggable-spacer";
|
|
2453
|
+
if (transitioning) {
|
|
2454
|
+
spacer.addEventListener("transitionend", () => {
|
|
2455
|
+
transitioning.current = false;
|
|
2456
|
+
});
|
|
2457
|
+
}
|
|
2458
|
+
return spacer;
|
|
2459
|
+
};
|
|
2460
|
+
var createDropIndicatorPosition = () => {
|
|
2461
|
+
const spacer = document.createElement("div");
|
|
2462
|
+
spacer.className = "vuuDraggable-dropIndicatorPosition";
|
|
2463
|
+
return spacer;
|
|
2464
|
+
};
|
|
2465
|
+
var createDropIndicator = (transitioning) => {
|
|
2466
|
+
const spacer = document.createElement("div");
|
|
2467
|
+
spacer.className = "vuuDraggable-dropIndicator";
|
|
2468
|
+
if (transitioning) {
|
|
2469
|
+
spacer.addEventListener("transitionend", () => {
|
|
2470
|
+
transitioning.current = false;
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2473
|
+
return spacer;
|
|
2474
|
+
};
|
|
2359
2475
|
|
|
2360
2476
|
// src/drag-drop/drop-target-utils.ts
|
|
2361
2477
|
var LEFT_RIGHT = ["left", "right"];
|
|
@@ -2561,81 +2677,21 @@ function constrainRect(targetRect, constraintRect) {
|
|
|
2561
2677
|
}
|
|
2562
2678
|
var dropTargetsDebugString = (dropTargets) => dropTargets.map(
|
|
2563
2679
|
(d, i) => {
|
|
2564
|
-
var
|
|
2680
|
+
var _a2;
|
|
2565
2681
|
return `
|
|
2566
2682
|
${d.isDraggedItem ? "*" : " "}[${i}] width : ${Math.floor(
|
|
2567
2683
|
d.size
|
|
2568
2684
|
)} ${Math.floor(d.start)} - ${Math.floor(d.end)} (mid ${Math.floor(
|
|
2569
2685
|
d.mid
|
|
2570
|
-
)}) ${(
|
|
2686
|
+
)}) ${(_a2 = d.element) == null ? void 0 : _a2.textContent} `;
|
|
2571
2687
|
}
|
|
2572
2688
|
).join("");
|
|
2573
2689
|
|
|
2574
|
-
// src/drag-drop/Draggable.tsx
|
|
2575
|
-
import { useForkRef as useForkRef3 } from "@salt-ds/core";
|
|
2576
|
-
import cx5 from "classnames";
|
|
2577
|
-
import {
|
|
2578
|
-
forwardRef as forwardRef4,
|
|
2579
|
-
useCallback as useCallback12
|
|
2580
|
-
} from "react";
|
|
2581
|
-
import { PortalDeprecated } from "@vuu-ui/vuu-popups";
|
|
2582
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
2583
|
-
var makeClassNames = (classNames) => classNames.split(" ").map((className) => `vuuDraggable-${className}`);
|
|
2584
|
-
var Draggable = forwardRef4(function Draggable2({ wrapperClassName, element, onTransitionEnd, style, scale = 1 }, forwardedRef) {
|
|
2585
|
-
const callbackRef = useCallback12(
|
|
2586
|
-
(el) => {
|
|
2587
|
-
if (el) {
|
|
2588
|
-
el.innerHTML = "";
|
|
2589
|
-
el.appendChild(element);
|
|
2590
|
-
if (scale !== 1) {
|
|
2591
|
-
el.style.transform = `scale(${scale},${scale})`;
|
|
2592
|
-
}
|
|
2593
|
-
}
|
|
2594
|
-
},
|
|
2595
|
-
[element, scale]
|
|
2596
|
-
);
|
|
2597
|
-
const forkedRef = useForkRef3(forwardedRef, callbackRef);
|
|
2598
|
-
return /* @__PURE__ */ jsx7(PortalDeprecated, { children: /* @__PURE__ */ jsx7(
|
|
2599
|
-
"div",
|
|
2600
|
-
{
|
|
2601
|
-
className: cx5("vuuDraggable", ...makeClassNames(wrapperClassName)),
|
|
2602
|
-
ref: forkedRef,
|
|
2603
|
-
onTransitionEnd,
|
|
2604
|
-
style
|
|
2605
|
-
}
|
|
2606
|
-
) });
|
|
2607
|
-
});
|
|
2608
|
-
var createDragSpacer = (transitioning) => {
|
|
2609
|
-
const spacer = document.createElement("div");
|
|
2610
|
-
spacer.className = "vuuDraggable-spacer";
|
|
2611
|
-
if (transitioning) {
|
|
2612
|
-
spacer.addEventListener("transitionend", () => {
|
|
2613
|
-
transitioning.current = false;
|
|
2614
|
-
});
|
|
2615
|
-
}
|
|
2616
|
-
return spacer;
|
|
2617
|
-
};
|
|
2618
|
-
var createDropIndicatorPosition = () => {
|
|
2619
|
-
const spacer = document.createElement("div");
|
|
2620
|
-
spacer.className = "vuuDraggable-dropIndicatorPosition";
|
|
2621
|
-
return spacer;
|
|
2622
|
-
};
|
|
2623
|
-
var createDropIndicator = (transitioning) => {
|
|
2624
|
-
const spacer = document.createElement("div");
|
|
2625
|
-
spacer.className = "vuuDraggable-dropIndicator";
|
|
2626
|
-
if (transitioning) {
|
|
2627
|
-
spacer.addEventListener("transitionend", () => {
|
|
2628
|
-
transitioning.current = false;
|
|
2629
|
-
});
|
|
2630
|
-
}
|
|
2631
|
-
return spacer;
|
|
2632
|
-
};
|
|
2633
|
-
|
|
2634
2690
|
// src/drag-drop/useDragDisplacers.ts
|
|
2635
2691
|
var useDragDisplacers = (orientation = "horizontal") => {
|
|
2636
2692
|
const animationFrame = useRef12(0);
|
|
2637
2693
|
const transitioning = useRef12(false);
|
|
2638
|
-
const spacers =
|
|
2694
|
+
const spacers = useMemo6(
|
|
2639
2695
|
// We only need to listen for transition end on one of the spacers
|
|
2640
2696
|
() => [createDragSpacer(transitioning), createDragSpacer()],
|
|
2641
2697
|
[]
|
|
@@ -2914,7 +2970,7 @@ var useDragDropNaturalMovement = ({
|
|
|
2914
2970
|
viewportRange
|
|
2915
2971
|
]
|
|
2916
2972
|
);
|
|
2917
|
-
const [showPopup, hidePopup] =
|
|
2973
|
+
const [showPopup, hidePopup] = useMemo7(() => {
|
|
2918
2974
|
let popupShowing = false;
|
|
2919
2975
|
const show = (dropTarget) => {
|
|
2920
2976
|
if (!popupShowing) {
|
|
@@ -2982,7 +3038,7 @@ var useDragDropNaturalMovement = ({
|
|
|
2982
3038
|
[containerRef, displaceItem, displaceLastItem, hidePopup, showPopup]
|
|
2983
3039
|
);
|
|
2984
3040
|
const drop = useCallback14(() => {
|
|
2985
|
-
var
|
|
3041
|
+
var _a2;
|
|
2986
3042
|
clearSpacers();
|
|
2987
3043
|
const { current: dropTargets } = measuredDropTargets;
|
|
2988
3044
|
const indexOfDraggedItem = getIndexOfDraggedItem(dropTargets);
|
|
@@ -3009,7 +3065,7 @@ var useDragDropNaturalMovement = ({
|
|
|
3009
3065
|
}
|
|
3010
3066
|
setShowOverflow(false);
|
|
3011
3067
|
if (containerRef.current) {
|
|
3012
|
-
const scrollTop = (
|
|
3068
|
+
const scrollTop = (_a2 = containerRef.current) == null ? void 0 : _a2.scrollTop;
|
|
3013
3069
|
if (indexOfDraggedItem < dropTargets.length) {
|
|
3014
3070
|
containerRef.current.scrollTop = scrollTop;
|
|
3015
3071
|
}
|
|
@@ -3033,9 +3089,9 @@ var useDragDropNaturalMovement = ({
|
|
|
3033
3089
|
import { useCallback as useCallback16, useRef as useRef14, useState as useState6 } from "react";
|
|
3034
3090
|
|
|
3035
3091
|
// src/drag-drop/useDropIndicator.ts
|
|
3036
|
-
import { useCallback as useCallback15, useMemo as
|
|
3092
|
+
import { useCallback as useCallback15, useMemo as useMemo8 } from "react";
|
|
3037
3093
|
var useDropIndicator = () => {
|
|
3038
|
-
const spacer =
|
|
3094
|
+
const spacer = useMemo8(() => createDropIndicatorPosition(), []);
|
|
3039
3095
|
const clearSpacer = useCallback15(() => spacer.remove(), [spacer]);
|
|
3040
3096
|
const positionDropIndicator = useCallback15(
|
|
3041
3097
|
(dropTarget, dropZone2 = "end") => {
|
|
@@ -3055,7 +3111,7 @@ var useDropIndicator = () => {
|
|
|
3055
3111
|
};
|
|
3056
3112
|
|
|
3057
3113
|
// src/drag-drop/useDragDropIndicator.tsx
|
|
3058
|
-
import { jsx as
|
|
3114
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
3059
3115
|
var NOT_OVERFLOWED2 = ':not([data-overflowed="true"])';
|
|
3060
3116
|
var NOT_HIDDEN2 = ':not([aria-hidden="true"])';
|
|
3061
3117
|
var useDragDropIndicator = ({
|
|
@@ -3177,7 +3233,7 @@ var useDragDropIndicator = ({
|
|
|
3177
3233
|
height: 2
|
|
3178
3234
|
};
|
|
3179
3235
|
setDropIndicator(
|
|
3180
|
-
/* @__PURE__ */
|
|
3236
|
+
/* @__PURE__ */ jsx9(
|
|
3181
3237
|
Draggable,
|
|
3182
3238
|
{
|
|
3183
3239
|
wrapperClassName: "dropIndicatorContainer",
|
|
@@ -3307,7 +3363,7 @@ var useDragDropIndicator = ({
|
|
|
3307
3363
|
// src/drag-drop/useDragDropNext.tsx
|
|
3308
3364
|
import {
|
|
3309
3365
|
useCallback as useCallback18,
|
|
3310
|
-
useEffect as
|
|
3366
|
+
useEffect as useEffect5,
|
|
3311
3367
|
useLayoutEffect as useLayoutEffect2,
|
|
3312
3368
|
useRef as useRef16,
|
|
3313
3369
|
useState as useState7
|
|
@@ -3379,7 +3435,7 @@ var useAutoScroll = ({
|
|
|
3379
3435
|
};
|
|
3380
3436
|
|
|
3381
3437
|
// src/drag-drop/useDragDropNext.tsx
|
|
3382
|
-
import { jsx as
|
|
3438
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
3383
3439
|
var NULL_DRAG_DROP_RESULT = {
|
|
3384
3440
|
beginDrag: () => void 0,
|
|
3385
3441
|
drag: () => void 0,
|
|
@@ -3450,6 +3506,7 @@ var useDragDropNext = ({
|
|
|
3450
3506
|
const dragMouseMoveHandlerRef = useRef16();
|
|
3451
3507
|
const dragMouseUpHandlerRef = useRef16();
|
|
3452
3508
|
const attachDragHandlers = useCallback18(() => {
|
|
3509
|
+
console.log("attach drag handlers");
|
|
3453
3510
|
const { current: dragMove } = dragMouseMoveHandlerRef;
|
|
3454
3511
|
const { current: dragUp } = dragMouseUpHandlerRef;
|
|
3455
3512
|
if (dragMove && dragUp) {
|
|
@@ -3458,9 +3515,11 @@ var useDragDropNext = ({
|
|
|
3458
3515
|
}
|
|
3459
3516
|
}, []);
|
|
3460
3517
|
const removeDragHandlers = useCallback18(() => {
|
|
3518
|
+
console.log("remove drag handlers");
|
|
3461
3519
|
const { current: dragMove } = dragMouseMoveHandlerRef;
|
|
3462
3520
|
const { current: dragUp } = dragMouseUpHandlerRef;
|
|
3463
3521
|
if (dragMove && dragUp) {
|
|
3522
|
+
console.log("... we have both handlers");
|
|
3464
3523
|
document.removeEventListener("mousemove", dragMove, false);
|
|
3465
3524
|
document.removeEventListener("mouseup", dragUp, false);
|
|
3466
3525
|
}
|
|
@@ -3485,9 +3544,9 @@ var useDragDropNext = ({
|
|
|
3485
3544
|
[containerRef, itemQuery, orientation]
|
|
3486
3545
|
);
|
|
3487
3546
|
const terminateDrag = useCallback18(() => {
|
|
3488
|
-
var
|
|
3547
|
+
var _a2;
|
|
3489
3548
|
const { current: toIndex } = dropIndexRef;
|
|
3490
|
-
const droppedItem = (
|
|
3549
|
+
const droppedItem = (_a2 = containerRef.current) == null ? void 0 : _a2.querySelector(
|
|
3491
3550
|
`${itemQuery}[data-index="${toIndex}"]`
|
|
3492
3551
|
);
|
|
3493
3552
|
if (droppedItem) {
|
|
@@ -3523,8 +3582,8 @@ var useDragDropNext = ({
|
|
|
3523
3582
|
const useDragDropHook = allowDragDrop === true || allowDragDrop === "natural-movement" ? useDragDropNaturalMovement : allowDragDrop === "drop-indicator" ? useDragDropIndicator : noDragDrop;
|
|
3524
3583
|
const onScrollingStopped = useCallback18(
|
|
3525
3584
|
(scrollDirection, scrollPos, atEnd) => {
|
|
3526
|
-
var
|
|
3527
|
-
(
|
|
3585
|
+
var _a2;
|
|
3586
|
+
(_a2 = handleScrollStopRef.current) == null ? void 0 : _a2.call(handleScrollStopRef, scrollDirection, scrollPos, atEnd);
|
|
3528
3587
|
},
|
|
3529
3588
|
[]
|
|
3530
3589
|
);
|
|
@@ -3535,12 +3594,12 @@ var useDragDropNext = ({
|
|
|
3535
3594
|
});
|
|
3536
3595
|
const handleDrop = useCallback18(
|
|
3537
3596
|
(fromIndex, toIndex, options) => {
|
|
3538
|
-
var
|
|
3597
|
+
var _a2;
|
|
3539
3598
|
dropPosRef.current = toIndex;
|
|
3540
3599
|
if (options.isExternal) {
|
|
3541
3600
|
onDrop == null ? void 0 : onDrop(fromIndex, toIndex, {
|
|
3542
3601
|
...options,
|
|
3543
|
-
payload: (
|
|
3602
|
+
payload: (_a2 = dragDropStateRef.current) == null ? void 0 : _a2.payload
|
|
3544
3603
|
});
|
|
3545
3604
|
} else {
|
|
3546
3605
|
onDrop == null ? void 0 : onDrop(fromIndex, toIndex, options);
|
|
@@ -3667,7 +3726,6 @@ var useDragDropNext = ({
|
|
|
3667
3726
|
dragDropStateRef.current = dragDropState;
|
|
3668
3727
|
const { draggableElement, mouseOffset, initialDragElement } = dragDropState;
|
|
3669
3728
|
const { current: container } = containerRef;
|
|
3670
|
-
console.log({ container, draggableElement, initialDragElement });
|
|
3671
3729
|
if (container && draggableElement) {
|
|
3672
3730
|
const containerRect = container.getBoundingClientRect();
|
|
3673
3731
|
const draggableRect = draggableElement.getBoundingClientRect();
|
|
@@ -3705,7 +3763,7 @@ var useDragDropNext = ({
|
|
|
3705
3763
|
} = dragElement;
|
|
3706
3764
|
setDraggableStatus({
|
|
3707
3765
|
isDragging: true,
|
|
3708
|
-
draggable: /* @__PURE__ */
|
|
3766
|
+
draggable: /* @__PURE__ */ jsx10(
|
|
3709
3767
|
Draggable,
|
|
3710
3768
|
{
|
|
3711
3769
|
element: cloneElement3(dragElement),
|
|
@@ -3809,7 +3867,7 @@ var useDragDropNext = ({
|
|
|
3809
3867
|
settlingItemRef.current = null;
|
|
3810
3868
|
}
|
|
3811
3869
|
}, [containerRef, itemQuery, settlingItem, terminateDrag]);
|
|
3812
|
-
|
|
3870
|
+
useEffect5(() => {
|
|
3813
3871
|
if (id && (isDragSource || isDropTarget)) {
|
|
3814
3872
|
register(id, resumeDrag);
|
|
3815
3873
|
}
|
|
@@ -3822,6 +3880,90 @@ var useDragDropNext = ({
|
|
|
3822
3880
|
};
|
|
3823
3881
|
};
|
|
3824
3882
|
|
|
3883
|
+
// src/list/useListDrop.ts
|
|
3884
|
+
import { useCallback as useCallback19, useEffect as useEffect6, useRef as useRef17 } from "react";
|
|
3885
|
+
var useListDrop = ({
|
|
3886
|
+
dataHook,
|
|
3887
|
+
onDrop,
|
|
3888
|
+
onMoveListItem,
|
|
3889
|
+
selected,
|
|
3890
|
+
setHighlightedIndex,
|
|
3891
|
+
setSelected
|
|
3892
|
+
}) => {
|
|
3893
|
+
const selectedByIndexRef = useRef17([]);
|
|
3894
|
+
const dataHookRef = useRef17(dataHook);
|
|
3895
|
+
dataHookRef.current = dataHook;
|
|
3896
|
+
const adjustIndex = useCallback19(
|
|
3897
|
+
(index, fromIndex, toIndex) => {
|
|
3898
|
+
if (index === fromIndex) {
|
|
3899
|
+
return toIndex;
|
|
3900
|
+
} else if (index < Math.min(fromIndex, toIndex) || index > Math.max(fromIndex, toIndex)) {
|
|
3901
|
+
return index;
|
|
3902
|
+
}
|
|
3903
|
+
if (fromIndex < index) {
|
|
3904
|
+
return index - 1;
|
|
3905
|
+
} else {
|
|
3906
|
+
return index + 1;
|
|
3907
|
+
}
|
|
3908
|
+
},
|
|
3909
|
+
[]
|
|
3910
|
+
);
|
|
3911
|
+
const reorderSelectedIndices = useCallback19(
|
|
3912
|
+
(selected2, fromIndex, toIndex) => {
|
|
3913
|
+
const selectedIndices = selected2.map(
|
|
3914
|
+
(id) => dataHookRef.current.indexOfItemById(id)
|
|
3915
|
+
);
|
|
3916
|
+
return selectedIndices.map(
|
|
3917
|
+
(item) => adjustIndex(item, fromIndex, toIndex)
|
|
3918
|
+
);
|
|
3919
|
+
},
|
|
3920
|
+
[adjustIndex]
|
|
3921
|
+
);
|
|
3922
|
+
const handleDrop = useCallback19(
|
|
3923
|
+
(fromIndex, toIndex, options) => {
|
|
3924
|
+
if (hasSelection(selected)) {
|
|
3925
|
+
selectedByIndexRef.current = reorderSelectedIndices(
|
|
3926
|
+
selected,
|
|
3927
|
+
fromIndex,
|
|
3928
|
+
toIndex
|
|
3929
|
+
);
|
|
3930
|
+
}
|
|
3931
|
+
if (options.isExternal) {
|
|
3932
|
+
onDrop == null ? void 0 : onDrop(fromIndex, toIndex, options);
|
|
3933
|
+
} else {
|
|
3934
|
+
onMoveListItem == null ? void 0 : onMoveListItem(fromIndex, toIndex);
|
|
3935
|
+
}
|
|
3936
|
+
setHighlightedIndex(-1);
|
|
3937
|
+
},
|
|
3938
|
+
[
|
|
3939
|
+
selected,
|
|
3940
|
+
setHighlightedIndex,
|
|
3941
|
+
reorderSelectedIndices,
|
|
3942
|
+
onDrop,
|
|
3943
|
+
onMoveListItem
|
|
3944
|
+
]
|
|
3945
|
+
);
|
|
3946
|
+
const handleDropSettle = useCallback19(
|
|
3947
|
+
(toIndex) => {
|
|
3948
|
+
setHighlightedIndex(toIndex);
|
|
3949
|
+
},
|
|
3950
|
+
[setHighlightedIndex]
|
|
3951
|
+
);
|
|
3952
|
+
useEffect6(() => {
|
|
3953
|
+
const { current: selectedByIndex } = selectedByIndexRef;
|
|
3954
|
+
if (hasSelection(selectedByIndex)) {
|
|
3955
|
+
selectedByIndexRef.current = [];
|
|
3956
|
+
const postDropSelected = Array.isArray(selectedByIndex) ? selectedByIndex.map((i) => dataHook.data[i].id) : dataHook.data[selectedByIndex].id;
|
|
3957
|
+
selectedByIndexRef.current = [];
|
|
3958
|
+
setSelected(postDropSelected);
|
|
3959
|
+
}
|
|
3960
|
+
}, [dataHook.data, setSelected]);
|
|
3961
|
+
return {
|
|
3962
|
+
handleDrop,
|
|
3963
|
+
onDropSettle: handleDropSettle
|
|
3964
|
+
};
|
|
3965
|
+
};
|
|
3966
|
+
|
|
3825
3967
|
// src/list/useList.ts
|
|
3826
3968
|
var useList = ({
|
|
3827
3969
|
allowDragDrop = false,
|
|
@@ -3856,14 +3998,15 @@ var useList = ({
|
|
|
3856
3998
|
tabToSelect,
|
|
3857
3999
|
viewportRange
|
|
3858
4000
|
}) => {
|
|
3859
|
-
const
|
|
3860
|
-
|
|
4001
|
+
const lastSelection = useRef18(
|
|
4002
|
+
selected || defaultSelected
|
|
4003
|
+
);
|
|
3861
4004
|
const handleKeyboardNavigation = (evt, nextIndex) => {
|
|
3862
|
-
var
|
|
3863
|
-
(_b = (
|
|
4005
|
+
var _a2, _b;
|
|
4006
|
+
(_b = (_a2 = selectionHook.listHandlers).onKeyboardNavigation) == null ? void 0 : _b.call(_a2, evt, nextIndex);
|
|
3864
4007
|
onKeyboardNavigation == null ? void 0 : onKeyboardNavigation(evt, nextIndex);
|
|
3865
4008
|
};
|
|
3866
|
-
const handleSelect =
|
|
4009
|
+
const handleSelect = useCallback20(
|
|
3867
4010
|
(evt, selectedId) => {
|
|
3868
4011
|
if (onSelect) {
|
|
3869
4012
|
if (selectedId !== null) {
|
|
@@ -3873,29 +4016,35 @@ var useList = ({
|
|
|
3873
4016
|
},
|
|
3874
4017
|
[dataHook, onSelect]
|
|
3875
4018
|
);
|
|
3876
|
-
const scrollContainer =
|
|
3877
|
-
var
|
|
4019
|
+
const scrollContainer = useMemo9(() => {
|
|
4020
|
+
var _a2, _b;
|
|
3878
4021
|
if (scrollContainerRef) {
|
|
3879
4022
|
return scrollContainerRef;
|
|
3880
4023
|
} else {
|
|
3881
4024
|
return {
|
|
3882
|
-
current: (_b = (
|
|
4025
|
+
current: (_b = (_a2 = containerRef.current) == null ? void 0 : _a2.querySelector(".vuuList-scrollContainer")) != null ? _b : null
|
|
3883
4026
|
};
|
|
3884
4027
|
}
|
|
3885
|
-
}, []);
|
|
3886
|
-
const handleSelectionChange =
|
|
4028
|
+
}, [containerRef, scrollContainerRef]);
|
|
4029
|
+
const handleSelectionChange = useCallback20(
|
|
3887
4030
|
(evt, selected2) => {
|
|
3888
4031
|
if (onSelectionChange) {
|
|
3889
|
-
if (
|
|
4032
|
+
if (isSingleSelection(selectionStrategy)) {
|
|
4033
|
+
const [selectedItem] = selected2;
|
|
4034
|
+
onSelectionChange(
|
|
4035
|
+
evt,
|
|
4036
|
+
dataHook.itemById(selectedItem)
|
|
4037
|
+
);
|
|
4038
|
+
} else if (isMultiSelection(selectionStrategy)) {
|
|
3890
4039
|
const selectedItems = selected2.map((id2) => dataHook.itemById(id2));
|
|
3891
|
-
onSelectionChange(
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
4040
|
+
onSelectionChange(
|
|
4041
|
+
evt,
|
|
4042
|
+
selectedItems
|
|
4043
|
+
);
|
|
3895
4044
|
}
|
|
3896
4045
|
}
|
|
3897
4046
|
},
|
|
3898
|
-
[dataHook, onSelectionChange]
|
|
4047
|
+
[dataHook, onSelectionChange, selectionStrategy]
|
|
3899
4048
|
);
|
|
3900
4049
|
const {
|
|
3901
4050
|
highlightedIndex,
|
|
@@ -3925,7 +4074,7 @@ var useList = ({
|
|
|
3925
4074
|
highlightedIdx: highlightedIndex,
|
|
3926
4075
|
collectionHook: dataHook
|
|
3927
4076
|
});
|
|
3928
|
-
const handleDragStart =
|
|
4077
|
+
const handleDragStart = useCallback20(
|
|
3929
4078
|
(dragDropState) => {
|
|
3930
4079
|
setHighlightedIndex(-1);
|
|
3931
4080
|
onDragStart == null ? void 0 : onDragStart(dragDropState);
|
|
@@ -3945,76 +4094,20 @@ var useList = ({
|
|
|
3945
4094
|
selectionKeys,
|
|
3946
4095
|
tabToSelect
|
|
3947
4096
|
});
|
|
3948
|
-
const
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
if (fromIndex < index) {
|
|
3957
|
-
return index - 1;
|
|
3958
|
-
} else {
|
|
3959
|
-
return index + 1;
|
|
3960
|
-
}
|
|
3961
|
-
},
|
|
3962
|
-
[dataHook.data]
|
|
3963
|
-
);
|
|
3964
|
-
const reorderSelectedIndices = useCallback19(
|
|
3965
|
-
(selected2, fromIndex, toIndex) => {
|
|
3966
|
-
if (Array.isArray(selected2)) {
|
|
3967
|
-
return selected2.map((item) => adjustIndex(item, fromIndex, toIndex));
|
|
3968
|
-
} else {
|
|
3969
|
-
return adjustIndex(selected2, fromIndex, toIndex);
|
|
3970
|
-
}
|
|
3971
|
-
},
|
|
3972
|
-
[adjustIndex]
|
|
3973
|
-
);
|
|
3974
|
-
const handleDrop = useCallback19(
|
|
3975
|
-
(fromIndex, toIndex, options) => {
|
|
3976
|
-
if (hasSelection(selectionHook.selected)) {
|
|
3977
|
-
selectedByIndexRef.current = reorderSelectedIndices(
|
|
3978
|
-
selectionHook.selected,
|
|
3979
|
-
fromIndex,
|
|
3980
|
-
toIndex
|
|
3981
|
-
);
|
|
3982
|
-
}
|
|
3983
|
-
if (options.isExternal) {
|
|
3984
|
-
onDrop == null ? void 0 : onDrop(fromIndex, toIndex, options);
|
|
3985
|
-
} else {
|
|
3986
|
-
onMoveListItem == null ? void 0 : onMoveListItem(fromIndex, toIndex);
|
|
3987
|
-
}
|
|
3988
|
-
setHighlightedIndex(-1);
|
|
3989
|
-
},
|
|
3990
|
-
[
|
|
3991
|
-
selectionHook.selected,
|
|
3992
|
-
setHighlightedIndex,
|
|
3993
|
-
reorderSelectedIndices,
|
|
3994
|
-
onDrop,
|
|
3995
|
-
onMoveListItem
|
|
3996
|
-
]
|
|
3997
|
-
);
|
|
3998
|
-
const handleDropSettle = useCallback19(
|
|
3999
|
-
(toIndex) => {
|
|
4000
|
-
setHighlightedIndex(toIndex);
|
|
4001
|
-
},
|
|
4002
|
-
[setHighlightedIndex]
|
|
4003
|
-
);
|
|
4097
|
+
const { handleDrop, onDropSettle } = useListDrop({
|
|
4098
|
+
dataHook,
|
|
4099
|
+
onDrop,
|
|
4100
|
+
onMoveListItem,
|
|
4101
|
+
selected: selectionHook.selected,
|
|
4102
|
+
setHighlightedIndex,
|
|
4103
|
+
setSelected: selectionHook.setSelected
|
|
4104
|
+
});
|
|
4004
4105
|
const { setSelected } = selectionHook;
|
|
4005
|
-
useEffect5(() => {
|
|
4006
|
-
const { current: selectedByIndex } = selectedByIndexRef;
|
|
4007
|
-
if (hasSelection(selectedByIndex)) {
|
|
4008
|
-
const postDropSelected = Array.isArray(selectedByIndex) ? selectedByIndex.map((i) => dataHook.data[i]) : dataHook.data[selectedByIndex];
|
|
4009
|
-
selectedByIndexRef.current = null;
|
|
4010
|
-
setSelected(postDropSelected);
|
|
4011
|
-
}
|
|
4012
|
-
}, [dataHook.data, setSelected]);
|
|
4013
4106
|
useLayoutEffectSkipFirst(() => {
|
|
4014
4107
|
if (hasSelection(lastSelection.current)) {
|
|
4015
|
-
setSelected(
|
|
4108
|
+
setSelected([]);
|
|
4016
4109
|
}
|
|
4017
|
-
}, [
|
|
4110
|
+
}, [selected, dataHook.data, setSelected]);
|
|
4018
4111
|
const {
|
|
4019
4112
|
onMouseDown,
|
|
4020
4113
|
isDragging,
|
|
@@ -4029,8 +4122,7 @@ var useList = ({
|
|
|
4029
4122
|
itemQuery: ".vuuListItem",
|
|
4030
4123
|
onDragStart: handleDragStart,
|
|
4031
4124
|
onDrop: handleDrop,
|
|
4032
|
-
onDropSettle
|
|
4033
|
-
// selected: selectionHook.selected,
|
|
4125
|
+
onDropSettle,
|
|
4034
4126
|
viewportRange
|
|
4035
4127
|
});
|
|
4036
4128
|
const { onKeyDown: typeaheadOnKeyDown } = useTypeahead({
|
|
@@ -4040,15 +4132,15 @@ var useList = ({
|
|
|
4040
4132
|
typeToNavigate: true,
|
|
4041
4133
|
items: dataHook.data
|
|
4042
4134
|
});
|
|
4043
|
-
const handleKeyDown =
|
|
4135
|
+
const handleKeyDown = useCallback20(
|
|
4044
4136
|
(evt) => {
|
|
4045
|
-
var
|
|
4137
|
+
var _a2, _b, _c;
|
|
4046
4138
|
if (!evt.defaultPrevented) {
|
|
4047
4139
|
typeaheadOnKeyDown == null ? void 0 : typeaheadOnKeyDown(evt);
|
|
4048
4140
|
}
|
|
4049
4141
|
navigationKeyDown(evt);
|
|
4050
4142
|
if (!evt.defaultPrevented) {
|
|
4051
|
-
(_b = (
|
|
4143
|
+
(_b = (_a2 = selectionHook.listHandlers).onKeyDown) == null ? void 0 : _b.call(_a2, evt);
|
|
4052
4144
|
}
|
|
4053
4145
|
if (!evt.defaultPrevented) {
|
|
4054
4146
|
(_c = collapsibleHook == null ? void 0 : collapsibleHook.onKeyDown) == null ? void 0 : _c.call(collapsibleHook, evt);
|
|
@@ -4073,7 +4165,7 @@ var useList = ({
|
|
|
4073
4165
|
stickyHeaders
|
|
4074
4166
|
});
|
|
4075
4167
|
const isScrolling = isViewportScrolling.current || isDragDropScrolling.current;
|
|
4076
|
-
const handleMouseMove =
|
|
4168
|
+
const handleMouseMove = useCallback20(
|
|
4077
4169
|
(evt) => {
|
|
4078
4170
|
if (!isScrolling && !disabled && !isDragging) {
|
|
4079
4171
|
navigationMouseMove();
|
|
@@ -4099,8 +4191,8 @@ var useList = ({
|
|
|
4099
4191
|
]
|
|
4100
4192
|
);
|
|
4101
4193
|
const getActiveDescendant = () => {
|
|
4102
|
-
var
|
|
4103
|
-
return highlightedIndex === void 0 || highlightedIndex === -1 || disableAriaActiveDescendant ? void 0 : (
|
|
4194
|
+
var _a2;
|
|
4195
|
+
return highlightedIndex === void 0 || highlightedIndex === -1 || disableAriaActiveDescendant ? void 0 : (_a2 = dataHook.data[highlightedIndex]) == null ? void 0 : _a2.id;
|
|
4104
4196
|
};
|
|
4105
4197
|
lastSelection.current = selectionHook.selected;
|
|
4106
4198
|
const listControlProps = {
|
|
@@ -4128,6 +4220,7 @@ var useList = ({
|
|
|
4128
4220
|
listItemHeaderHandlers: collapsibleHook,
|
|
4129
4221
|
listControlProps,
|
|
4130
4222
|
scrollIntoView,
|
|
4223
|
+
//TODO given that we firs onSelect and onSelectionCHange with Item(s), should we return Item(s) here ?
|
|
4131
4224
|
selected: selectionHook.selected,
|
|
4132
4225
|
setHighlightedIndex,
|
|
4133
4226
|
setIgnoreFocus: keyboardHook.setIgnoreFocus,
|
|
@@ -4137,7 +4230,7 @@ var useList = ({
|
|
|
4137
4230
|
};
|
|
4138
4231
|
|
|
4139
4232
|
// src/list/useListHeight.ts
|
|
4140
|
-
import { useCallback as
|
|
4233
|
+
import { useCallback as useCallback21, useMemo as useMemo10, useRef as useRef19, useState as useState8 } from "react";
|
|
4141
4234
|
var getContentHeight = (itemCount, itemHeight, itemGapSize = 0) => {
|
|
4142
4235
|
if (itemCount === 0) {
|
|
4143
4236
|
return 0;
|
|
@@ -4159,12 +4252,11 @@ var useListHeight = ({
|
|
|
4159
4252
|
}) => {
|
|
4160
4253
|
const [measuredItemHeight, setMeasuredItemHeight] = useState8(itemHeightProp);
|
|
4161
4254
|
const [, forceUpdate] = useState8({});
|
|
4162
|
-
const proxyItemRef =
|
|
4163
|
-
const [contentHeight, computedListHeight] =
|
|
4255
|
+
const proxyItemRef = useRef19(null);
|
|
4256
|
+
const [contentHeight, computedListHeight] = useMemo10(() => {
|
|
4164
4257
|
let result = 0;
|
|
4165
4258
|
const itemHeight = measuredItemHeight != null ? measuredItemHeight : itemHeightProp;
|
|
4166
4259
|
const contentHeight2 = getContentHeight(itemCount, itemHeight, itemGapSize);
|
|
4167
|
-
console.log(`contentHeight ${contentHeight2}`);
|
|
4168
4260
|
if (height !== void 0) {
|
|
4169
4261
|
return [contentHeight2, void 0];
|
|
4170
4262
|
}
|
|
@@ -4189,12 +4281,12 @@ var useListHeight = ({
|
|
|
4189
4281
|
itemHeightProp,
|
|
4190
4282
|
measuredItemHeight
|
|
4191
4283
|
]);
|
|
4192
|
-
const handleRowHeight =
|
|
4284
|
+
const handleRowHeight = useCallback21(({ height: height2 }) => {
|
|
4193
4285
|
if (typeof height2 === "number") {
|
|
4194
4286
|
setMeasuredItemHeight(height2);
|
|
4195
4287
|
}
|
|
4196
4288
|
}, []);
|
|
4197
|
-
const rowHeightProxyRef =
|
|
4289
|
+
const rowHeightProxyRef = useCallback21((el) => {
|
|
4198
4290
|
proxyItemRef.current = el;
|
|
4199
4291
|
forceUpdate({});
|
|
4200
4292
|
}, []);
|
|
@@ -4210,7 +4302,7 @@ var useListHeight = ({
|
|
|
4210
4302
|
|
|
4211
4303
|
// src/list/useScrollPosition.ts
|
|
4212
4304
|
import { useIsomorphicLayoutEffect as useIsomorphicLayoutEffect2 } from "@salt-ds/core";
|
|
4213
|
-
import { useCallback as
|
|
4305
|
+
import { useCallback as useCallback22, useMemo as useMemo11, useRef as useRef20, useState as useState9 } from "react";
|
|
4214
4306
|
var getRange = (scrollPos, height, itemCount, itemHeight) => {
|
|
4215
4307
|
const viewportRowCount = Math.ceil(height / itemHeight);
|
|
4216
4308
|
const from = Math.floor(scrollPos / itemHeight);
|
|
@@ -4229,10 +4321,10 @@ var useScrollPosition = ({
|
|
|
4229
4321
|
itemSize: listItemHeight,
|
|
4230
4322
|
onViewportScroll
|
|
4231
4323
|
}) => {
|
|
4232
|
-
const firstVisibleRowRef =
|
|
4233
|
-
const lastVisibleRowRef =
|
|
4234
|
-
const scrollPosRef =
|
|
4235
|
-
const range =
|
|
4324
|
+
const firstVisibleRowRef = useRef20(0);
|
|
4325
|
+
const lastVisibleRowRef = useRef20(0);
|
|
4326
|
+
const scrollPosRef = useRef20(0);
|
|
4327
|
+
const range = useMemo11(() => {
|
|
4236
4328
|
return getRange(
|
|
4237
4329
|
scrollPosRef.current,
|
|
4238
4330
|
listHeight,
|
|
@@ -4244,7 +4336,7 @@ var useScrollPosition = ({
|
|
|
4244
4336
|
useIsomorphicLayoutEffect2(() => {
|
|
4245
4337
|
setViewportRange(range);
|
|
4246
4338
|
}, [range]);
|
|
4247
|
-
const handleVerticalScroll =
|
|
4339
|
+
const handleVerticalScroll = useCallback22(
|
|
4248
4340
|
(e) => {
|
|
4249
4341
|
const scrollTop = e.target.scrollTop;
|
|
4250
4342
|
if (scrollTop !== scrollPosRef.current) {
|
|
@@ -4279,7 +4371,7 @@ var useScrollPosition = ({
|
|
|
4279
4371
|
};
|
|
4280
4372
|
|
|
4281
4373
|
// src/list/List.tsx
|
|
4282
|
-
import { Fragment as Fragment2, jsx as
|
|
4374
|
+
import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
4283
4375
|
import { createElement } from "react";
|
|
4284
4376
|
var defaultEmptyMessage = "No data to display";
|
|
4285
4377
|
var classBase5 = "vuuList";
|
|
@@ -4329,16 +4421,17 @@ var List = forwardRef5(function List2({
|
|
|
4329
4421
|
source,
|
|
4330
4422
|
style: styleProp,
|
|
4331
4423
|
stickyHeaders,
|
|
4424
|
+
tabIndex = 0,
|
|
4332
4425
|
tabToSelect,
|
|
4333
4426
|
...htmlAttributes
|
|
4334
4427
|
}, forwardedRef) {
|
|
4335
|
-
var
|
|
4428
|
+
var _a2, _b;
|
|
4336
4429
|
const id = useId2(idProp);
|
|
4337
|
-
const containerRef =
|
|
4338
|
-
const scrollContainerRef =
|
|
4339
|
-
const contentContainerRef =
|
|
4430
|
+
const containerRef = useRef21(null);
|
|
4431
|
+
const scrollContainerRef = useRef21(null);
|
|
4432
|
+
const contentContainerRef = useRef21(null);
|
|
4340
4433
|
const [size, setSize] = useState10();
|
|
4341
|
-
const handleResize =
|
|
4434
|
+
const handleResize = useCallback23((size2) => {
|
|
4342
4435
|
setSize(size2);
|
|
4343
4436
|
}, []);
|
|
4344
4437
|
const collectionHook = useCollectionItems({
|
|
@@ -4371,7 +4464,7 @@ var List = forwardRef5(function List2({
|
|
|
4371
4464
|
const { onVerticalScroll, viewportRange } = useScrollPosition({
|
|
4372
4465
|
containerSize: (
|
|
4373
4466
|
// TODO whats the right way to handle string values - ie percentages
|
|
4374
|
-
(_b = (
|
|
4467
|
+
(_b = (_a2 = listClientHeight != null ? listClientHeight : computedListHeight) != null ? _a2 : size == null ? void 0 : size.height) != null ? _b : 0
|
|
4375
4468
|
),
|
|
4376
4469
|
itemCount: collectionHook.data.length,
|
|
4377
4470
|
itemGapSize,
|
|
@@ -4449,13 +4542,13 @@ var List = forwardRef5(function List2({
|
|
|
4449
4542
|
};
|
|
4450
4543
|
const getItemHeight = getItemHeightProp === void 0 ? () => itemHeightProp : getItemHeightProp;
|
|
4451
4544
|
function renderCollectionItem(list, item, idx) {
|
|
4452
|
-
var
|
|
4545
|
+
var _a3, _b2;
|
|
4453
4546
|
const { disabled, value, id: itemId, label } = item;
|
|
4454
4547
|
const isChildItem = isValidElement4(value);
|
|
4455
4548
|
const listItemProps = {
|
|
4456
4549
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4457
4550
|
// @ts-ignore until we refactor this whole section
|
|
4458
|
-
className: cx6((
|
|
4551
|
+
className: cx6((_a3 = value == null ? void 0 : value.props) == null ? void 0 : _a3.className, {
|
|
4459
4552
|
vuuHighlighted: idx.value === highlightedIndex,
|
|
4460
4553
|
vuuFocusVisible: appliedFocusVisible === idx.value,
|
|
4461
4554
|
[`vuuDraggable-dragAway`]: draggedItemIndex === idx.value
|
|
@@ -4473,7 +4566,7 @@ var List = forwardRef5(function List2({
|
|
|
4473
4566
|
showCheckbox: checkable
|
|
4474
4567
|
};
|
|
4475
4568
|
list.push(
|
|
4476
|
-
isChildItem ? cloneElement4(value, listItemProps) : /* @__PURE__ */
|
|
4569
|
+
isChildItem ? cloneElement4(value, listItemProps) : /* @__PURE__ */ jsx11(ListItem4, { ...listItemProps })
|
|
4477
4570
|
);
|
|
4478
4571
|
idx.value += 1;
|
|
4479
4572
|
}
|
|
@@ -4484,7 +4577,7 @@ var List = forwardRef5(function List2({
|
|
|
4484
4577
|
renderCollectionItems(items, idx, idx.value + count) || []
|
|
4485
4578
|
) : header;
|
|
4486
4579
|
list.push(
|
|
4487
|
-
/* @__PURE__ */
|
|
4580
|
+
/* @__PURE__ */ jsx11("div", { role: "group", children: childItems2 }, id2)
|
|
4488
4581
|
);
|
|
4489
4582
|
};
|
|
4490
4583
|
const renderCollectionItems = (items, idx = { value: 0 }, end = items.length) => {
|
|
@@ -4505,13 +4598,14 @@ var List = forwardRef5(function List2({
|
|
|
4505
4598
|
};
|
|
4506
4599
|
function renderEmpty() {
|
|
4507
4600
|
if (emptyMessage || showEmptyMessage) {
|
|
4508
|
-
return /* @__PURE__ */
|
|
4601
|
+
return /* @__PURE__ */ jsx11("span", { className: `${classBase5}-empty-message`, children: emptyMessage != null ? emptyMessage : defaultEmptyMessage });
|
|
4509
4602
|
} else {
|
|
4510
4603
|
return null;
|
|
4511
4604
|
}
|
|
4512
4605
|
}
|
|
4606
|
+
const isEmpty = collectionHook.data.length === 0;
|
|
4513
4607
|
const renderContent = () => {
|
|
4514
|
-
if (
|
|
4608
|
+
if (!isEmpty) {
|
|
4515
4609
|
const itemsToRender = collectionHook.data;
|
|
4516
4610
|
return renderCollectionItems(itemsToRender);
|
|
4517
4611
|
} else {
|
|
@@ -4538,6 +4632,7 @@ var List = forwardRef5(function List2({
|
|
|
4538
4632
|
className: cx6(classBase5, className, {
|
|
4539
4633
|
[`${classBase5}-collapsible`]: collapsibleHeaders,
|
|
4540
4634
|
[`${classBase5}-contentSized`]: computedListHeight !== void 0,
|
|
4635
|
+
[`${classBase5}-empty`]: isEmpty,
|
|
4541
4636
|
vuuFocusVisible: highlightedIndex === LIST_FOCUS_VISIBLE
|
|
4542
4637
|
}),
|
|
4543
4638
|
height: computedListHeight != null ? computedListHeight : height,
|
|
@@ -4547,10 +4642,10 @@ var List = forwardRef5(function List2({
|
|
|
4547
4642
|
role: "listbox",
|
|
4548
4643
|
onScroll: onVerticalScroll,
|
|
4549
4644
|
style: { ...styleProp, ...sizeStyles },
|
|
4550
|
-
tabIndex: listDisabled || disableFocus ? void 0 :
|
|
4645
|
+
tabIndex: listDisabled || disableFocus ? void 0 : tabIndex,
|
|
4551
4646
|
children: [
|
|
4552
|
-
/* @__PURE__ */
|
|
4553
|
-
collectionHook.data.length === 0 && ListPlaceholder !== void 0 ? /* @__PURE__ */
|
|
4647
|
+
/* @__PURE__ */ jsx11(ListItemProxy, { ref: rowHeightProxyRef, height: itemHeightProp }),
|
|
4648
|
+
collectionHook.data.length === 0 && ListPlaceholder !== void 0 ? /* @__PURE__ */ jsx11(Fragment2, { children: /* @__PURE__ */ jsx11(ListPlaceholder, {}) }) : /* @__PURE__ */ jsx11("div", { className: `${classBase5}-viewport`, ref: scrollContainerRef, children: /* @__PURE__ */ jsxs4(
|
|
4554
4649
|
"div",
|
|
4555
4650
|
{
|
|
4556
4651
|
className: `${classBase5}-scrollingContentContainer`,
|
|
@@ -4592,10 +4687,10 @@ function clsx() {
|
|
|
4592
4687
|
}
|
|
4593
4688
|
|
|
4594
4689
|
// src/list/VirtualizedList.tsx
|
|
4595
|
-
import { forwardRef as forwardRef6, memo, useRef as
|
|
4690
|
+
import { forwardRef as forwardRef6, memo, useRef as useRef22 } from "react";
|
|
4596
4691
|
|
|
4597
4692
|
// src/list/useVirtualization.ts
|
|
4598
|
-
import { useMemo as
|
|
4693
|
+
import { useMemo as useMemo12 } from "react";
|
|
4599
4694
|
|
|
4600
4695
|
// src/list/keyset.ts
|
|
4601
4696
|
var KeySet = class {
|
|
@@ -4644,7 +4739,7 @@ var useVirtualization = ({
|
|
|
4644
4739
|
listItemHeight,
|
|
4645
4740
|
viewportRange
|
|
4646
4741
|
}) => {
|
|
4647
|
-
const keys =
|
|
4742
|
+
const keys = useMemo12(() => new KeySet(0, 1), []);
|
|
4648
4743
|
const rowHeightWithGap = listItemHeight + listItemGapSize;
|
|
4649
4744
|
const lo = Math.max(0, viewportRange.from - renderBuffer);
|
|
4650
4745
|
const hi = Math.min(data.length, viewportRange.to + renderBuffer);
|
|
@@ -4661,7 +4756,7 @@ var useVirtualization = ({
|
|
|
4661
4756
|
};
|
|
4662
4757
|
|
|
4663
4758
|
// src/list/VirtualizedList.tsx
|
|
4664
|
-
import { jsx as
|
|
4759
|
+
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
4665
4760
|
var defaultEmptyMessage2 = "No data to display";
|
|
4666
4761
|
var withBaseName2 = makePrefixer2("saltList");
|
|
4667
4762
|
var ListItem3 = memo(ListItem);
|
|
@@ -4711,8 +4806,8 @@ var VirtualizedList = forwardRef6(function List3({
|
|
|
4711
4806
|
...htmlAttributes
|
|
4712
4807
|
}, forwardedRef) {
|
|
4713
4808
|
const id = useIdMemo(idProp);
|
|
4714
|
-
const rootRef =
|
|
4715
|
-
const rowHeightProxyRef =
|
|
4809
|
+
const rootRef = useRef22(null);
|
|
4810
|
+
const rowHeightProxyRef = useRef22(null);
|
|
4716
4811
|
const collectionHook = useCollectionItems({
|
|
4717
4812
|
id,
|
|
4718
4813
|
label: "List",
|
|
@@ -4748,9 +4843,7 @@ var VirtualizedList = forwardRef6(function List3({
|
|
|
4748
4843
|
collectionHook,
|
|
4749
4844
|
containerRef: rootRef,
|
|
4750
4845
|
defaultHighlightedIndex: defaultHighlightedIdx,
|
|
4751
|
-
|
|
4752
|
-
// @ts-ignore
|
|
4753
|
-
defaultSelected: collectionHook.itemToCollectionItem(defaultSelected),
|
|
4846
|
+
defaultSelected: collectionHook.itemToCollectionItemId(defaultSelected),
|
|
4754
4847
|
disabled: listDisabled,
|
|
4755
4848
|
disableTypeToSelect,
|
|
4756
4849
|
highlightedIndex: highlightedIdxProp,
|
|
@@ -4759,9 +4852,7 @@ var VirtualizedList = forwardRef6(function List3({
|
|
|
4759
4852
|
onSelectionChange,
|
|
4760
4853
|
onHighlight,
|
|
4761
4854
|
restoreLastFocus,
|
|
4762
|
-
|
|
4763
|
-
// @ts-ignore
|
|
4764
|
-
selected: collectionHook.itemToCollectionItem(selectedProp),
|
|
4855
|
+
selected: collectionHook.itemToCollectionItemId(selectedProp),
|
|
4765
4856
|
selectionStrategy,
|
|
4766
4857
|
selectionKeys,
|
|
4767
4858
|
stickyHeaders,
|
|
@@ -4790,7 +4881,7 @@ var VirtualizedList = forwardRef6(function List3({
|
|
|
4790
4881
|
const [key, offset, pos, item] = row;
|
|
4791
4882
|
const index = pos - 1;
|
|
4792
4883
|
list.push(
|
|
4793
|
-
/* @__PURE__ */
|
|
4884
|
+
/* @__PURE__ */ jsx12(
|
|
4794
4885
|
ListItem3,
|
|
4795
4886
|
{
|
|
4796
4887
|
"aria-setsize": collectionHook.data.length,
|
|
@@ -4823,7 +4914,7 @@ var VirtualizedList = forwardRef6(function List3({
|
|
|
4823
4914
|
}
|
|
4824
4915
|
function renderEmpty() {
|
|
4825
4916
|
if (emptyMessage || showEmptyMessage) {
|
|
4826
|
-
return /* @__PURE__ */
|
|
4917
|
+
return /* @__PURE__ */ jsx12("span", { className: withBaseName2("empty-message"), children: emptyMessage != null ? emptyMessage : defaultEmptyMessage2 });
|
|
4827
4918
|
} else {
|
|
4828
4919
|
return null;
|
|
4829
4920
|
}
|
|
@@ -4844,7 +4935,7 @@ var VirtualizedList = forwardRef6(function List3({
|
|
|
4844
4935
|
maxWidth: maxWidth != null ? maxWidth : width,
|
|
4845
4936
|
maxHeight: maxHeight != null ? maxHeight : listHeight
|
|
4846
4937
|
};
|
|
4847
|
-
return /* @__PURE__ */
|
|
4938
|
+
return /* @__PURE__ */ jsx12(
|
|
4848
4939
|
"div",
|
|
4849
4940
|
{
|
|
4850
4941
|
...htmlAttributes,
|
|
@@ -4863,7 +4954,7 @@ var VirtualizedList = forwardRef6(function List3({
|
|
|
4863
4954
|
className: withBaseName2("scrollingContentContainer"),
|
|
4864
4955
|
style: { height: contentHeight },
|
|
4865
4956
|
children: [
|
|
4866
|
-
/* @__PURE__ */
|
|
4957
|
+
/* @__PURE__ */ jsx12(ListItemProxy, { ref: rowHeightProxyRef }),
|
|
4867
4958
|
renderContent()
|
|
4868
4959
|
]
|
|
4869
4960
|
}
|
|
@@ -4874,12 +4965,12 @@ var VirtualizedList = forwardRef6(function List3({
|
|
|
4874
4965
|
|
|
4875
4966
|
// src/list/RadioIcon.tsx
|
|
4876
4967
|
import cx7 from "classnames";
|
|
4877
|
-
import { jsx as
|
|
4968
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
4878
4969
|
var classBase6 = "vuuRadioIcon";
|
|
4879
4970
|
var RadioIcon = ({
|
|
4880
4971
|
checked = false,
|
|
4881
4972
|
...htmlAttributes
|
|
4882
|
-
}) => /* @__PURE__ */
|
|
4973
|
+
}) => /* @__PURE__ */ jsx13(
|
|
4883
4974
|
"span",
|
|
4884
4975
|
{
|
|
4885
4976
|
...htmlAttributes,
|
|
@@ -4889,7 +4980,7 @@ var RadioIcon = ({
|
|
|
4889
4980
|
|
|
4890
4981
|
// src/dropdown/useDropdown.ts
|
|
4891
4982
|
import { useControlled as useControlled4 } from "@salt-ds/core";
|
|
4892
|
-
import { useCallback as
|
|
4983
|
+
import { useCallback as useCallback24, useMemo as useMemo13 } from "react";
|
|
4893
4984
|
var useDropdown = ({
|
|
4894
4985
|
collectionHook,
|
|
4895
4986
|
defaultHighlightedIndex: defaultHighlightedIndexProp,
|
|
@@ -4906,23 +4997,36 @@ var useDropdown = ({
|
|
|
4906
4997
|
selected,
|
|
4907
4998
|
selectionStrategy
|
|
4908
4999
|
}) => {
|
|
4909
|
-
const isMultiSelect = selectionStrategy
|
|
5000
|
+
const isMultiSelect = isMultiSelection(selectionStrategy);
|
|
4910
5001
|
const [isOpen, setIsOpen] = useControlled4({
|
|
4911
5002
|
controlled: isOpenProp,
|
|
4912
5003
|
default: defaultIsOpen != null ? defaultIsOpen : false,
|
|
4913
5004
|
name: "useDropdownList"
|
|
4914
5005
|
});
|
|
4915
|
-
const handleSelectionChange =
|
|
5006
|
+
const handleSelectionChange = useCallback24(
|
|
4916
5007
|
(evt, selected2) => {
|
|
5008
|
+
console.log(`useDropdown onSelectionChange`, {
|
|
5009
|
+
selected: selected2
|
|
5010
|
+
});
|
|
4917
5011
|
if (!isMultiSelect) {
|
|
4918
5012
|
setIsOpen(false);
|
|
4919
5013
|
onOpenChange == null ? void 0 : onOpenChange(false);
|
|
4920
5014
|
}
|
|
4921
|
-
|
|
5015
|
+
if (Array.isArray(selected2)) {
|
|
5016
|
+
onSelectionChange == null ? void 0 : onSelectionChange(
|
|
5017
|
+
null,
|
|
5018
|
+
selected2
|
|
5019
|
+
);
|
|
5020
|
+
} else if (selected2) {
|
|
5021
|
+
onSelectionChange == null ? void 0 : onSelectionChange(
|
|
5022
|
+
null,
|
|
5023
|
+
selected2
|
|
5024
|
+
);
|
|
5025
|
+
}
|
|
4922
5026
|
},
|
|
4923
5027
|
[isMultiSelect, onOpenChange, onSelectionChange, setIsOpen]
|
|
4924
5028
|
);
|
|
4925
|
-
const handleSelect =
|
|
5029
|
+
const handleSelect = useCallback24(
|
|
4926
5030
|
(evt, selected2) => {
|
|
4927
5031
|
if (!isMultiSelect) {
|
|
4928
5032
|
setIsOpen(false);
|
|
@@ -4946,15 +5050,15 @@ var useDropdown = ({
|
|
|
4946
5050
|
selectionStrategy,
|
|
4947
5051
|
tabToSelect: !isMultiSelect
|
|
4948
5052
|
});
|
|
4949
|
-
const handleOpenChange =
|
|
5053
|
+
const handleOpenChange = useCallback24(
|
|
4950
5054
|
(open) => {
|
|
4951
5055
|
setIsOpen(open);
|
|
4952
5056
|
onOpenChange == null ? void 0 : onOpenChange(open);
|
|
4953
5057
|
},
|
|
4954
5058
|
[onOpenChange, setIsOpen]
|
|
4955
5059
|
);
|
|
4956
|
-
const triggerLabel =
|
|
4957
|
-
if (
|
|
5060
|
+
const triggerLabel = useMemo13(() => {
|
|
5061
|
+
if (Array.isArray(listHook.selected)) {
|
|
4958
5062
|
const selectedItems = listHook.selected.map(
|
|
4959
5063
|
(id) => collectionHook.itemById(id)
|
|
4960
5064
|
);
|
|
@@ -4966,11 +5070,8 @@ var useDropdown = ({
|
|
|
4966
5070
|
} else {
|
|
4967
5071
|
return `${selectedItems.length} items selected`;
|
|
4968
5072
|
}
|
|
4969
|
-
} else {
|
|
4970
|
-
const selectedItem = listHook.selected;
|
|
4971
|
-
return selectedItem == null ? void 0 : itemToString2(collectionHook.itemById(selectedItem));
|
|
4972
5073
|
}
|
|
4973
|
-
}, [collectionHook,
|
|
5074
|
+
}, [collectionHook, itemToString2, listHook.selected]);
|
|
4974
5075
|
return {
|
|
4975
5076
|
isOpen,
|
|
4976
5077
|
onOpenChange: handleOpenChange,
|
|
@@ -4980,7 +5081,7 @@ var useDropdown = ({
|
|
|
4980
5081
|
};
|
|
4981
5082
|
|
|
4982
5083
|
// src/dropdown/Dropdown.tsx
|
|
4983
|
-
import { jsx as
|
|
5084
|
+
import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
4984
5085
|
var Dropdown2 = forwardRef7(function Dropdown3({
|
|
4985
5086
|
"aria-label": ariaLabel,
|
|
4986
5087
|
children,
|
|
@@ -5002,8 +5103,8 @@ var Dropdown2 = forwardRef7(function Dropdown3({
|
|
|
5002
5103
|
...props
|
|
5003
5104
|
}, forwardedRef) {
|
|
5004
5105
|
const id = useId3(idProp);
|
|
5005
|
-
const rootRef =
|
|
5006
|
-
const listRef =
|
|
5106
|
+
const rootRef = useRef23(null);
|
|
5107
|
+
const listRef = useRef23(null);
|
|
5007
5108
|
const forkedRef = useForkRef6(rootRef, forwardedRef);
|
|
5008
5109
|
const collectionHook = useCollectionItems({
|
|
5009
5110
|
id,
|
|
@@ -5028,7 +5129,6 @@ var Dropdown2 = forwardRef7(function Dropdown3({
|
|
|
5028
5129
|
highlightedIndex: ListProps3 == null ? void 0 : ListProps3.highlightedIndex,
|
|
5029
5130
|
isOpen: isOpenProp,
|
|
5030
5131
|
itemToString: itemToString2,
|
|
5031
|
-
label: "Dropdown",
|
|
5032
5132
|
listRef,
|
|
5033
5133
|
onHighlight: ListProps3 == null ? void 0 : ListProps3.onHighlight,
|
|
5034
5134
|
onOpenChange,
|
|
@@ -5037,14 +5137,13 @@ var Dropdown2 = forwardRef7(function Dropdown3({
|
|
|
5037
5137
|
selected: collectionHook.itemToCollectionItemId(selectedProp),
|
|
5038
5138
|
selectionStrategy
|
|
5039
5139
|
});
|
|
5040
|
-
const
|
|
5041
|
-
(
|
|
5042
|
-
if (Array.isArray(
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
return collectionHook.itemById(itemIdOrItemIds);
|
|
5140
|
+
const itemIdToItem = useCallback25(
|
|
5141
|
+
(itemId) => {
|
|
5142
|
+
if (Array.isArray(itemId)) {
|
|
5143
|
+
const items = itemId.map((id2) => collectionHook.itemById(id2));
|
|
5144
|
+
return items;
|
|
5145
|
+
} else {
|
|
5146
|
+
return collectionHook.itemById(itemId);
|
|
5048
5147
|
}
|
|
5049
5148
|
},
|
|
5050
5149
|
[collectionHook]
|
|
@@ -5064,7 +5163,7 @@ var Dropdown2 = forwardRef7(function Dropdown3({
|
|
|
5064
5163
|
})
|
|
5065
5164
|
);
|
|
5066
5165
|
} else {
|
|
5067
|
-
return /* @__PURE__ */
|
|
5166
|
+
return /* @__PURE__ */ jsx14(
|
|
5068
5167
|
DropdownButton,
|
|
5069
5168
|
{
|
|
5070
5169
|
label: triggerLabel,
|
|
@@ -5074,7 +5173,7 @@ var Dropdown2 = forwardRef7(function Dropdown3({
|
|
|
5074
5173
|
);
|
|
5075
5174
|
}
|
|
5076
5175
|
};
|
|
5077
|
-
return /* @__PURE__ */
|
|
5176
|
+
return /* @__PURE__ */ jsx14(CollectionProvider, { collectionHook, children: /* @__PURE__ */ jsxs6(
|
|
5078
5177
|
DropdownBase,
|
|
5079
5178
|
{
|
|
5080
5179
|
...props,
|
|
@@ -5086,7 +5185,7 @@ var Dropdown2 = forwardRef7(function Dropdown3({
|
|
|
5086
5185
|
width,
|
|
5087
5186
|
children: [
|
|
5088
5187
|
getTriggerComponent(),
|
|
5089
|
-
/* @__PURE__ */
|
|
5188
|
+
/* @__PURE__ */ jsx14(
|
|
5090
5189
|
List,
|
|
5091
5190
|
{
|
|
5092
5191
|
ListItem: ListItem4,
|
|
@@ -5097,7 +5196,7 @@ var Dropdown2 = forwardRef7(function Dropdown3({
|
|
|
5097
5196
|
onSelectionChange,
|
|
5098
5197
|
onSelect,
|
|
5099
5198
|
ref: listRef,
|
|
5100
|
-
selected:
|
|
5199
|
+
selected: selected === void 0 ? void 0 : itemIdToItem(selected),
|
|
5101
5200
|
selectionStrategy
|
|
5102
5201
|
}
|
|
5103
5202
|
)
|
|
@@ -5110,8 +5209,8 @@ var Dropdown2 = forwardRef7(function Dropdown3({
|
|
|
5110
5209
|
import { useControlled as useControlled5 } from "@salt-ds/core";
|
|
5111
5210
|
import { useLayoutEffectSkipFirst as useLayoutEffectSkipFirst2 } from "@vuu-ui/vuu-layout";
|
|
5112
5211
|
import {
|
|
5113
|
-
useCallback as
|
|
5114
|
-
useRef as
|
|
5212
|
+
useCallback as useCallback26,
|
|
5213
|
+
useRef as useRef24,
|
|
5115
5214
|
useState as useState11
|
|
5116
5215
|
} from "react";
|
|
5117
5216
|
var EnterOnly = ["Enter"];
|
|
@@ -5120,6 +5219,7 @@ var useCombobox = ({
|
|
|
5120
5219
|
ariaLabel,
|
|
5121
5220
|
collectionHook,
|
|
5122
5221
|
defaultIsOpen,
|
|
5222
|
+
defaultSelected,
|
|
5123
5223
|
defaultValue,
|
|
5124
5224
|
onBlur,
|
|
5125
5225
|
onFocus,
|
|
@@ -5128,12 +5228,15 @@ var useCombobox = ({
|
|
|
5128
5228
|
id,
|
|
5129
5229
|
initialHighlightedIndex = -1,
|
|
5130
5230
|
isOpen: isOpenProp,
|
|
5231
|
+
itemCount,
|
|
5232
|
+
itemsToString,
|
|
5131
5233
|
itemToString: itemToString2 = itemToString,
|
|
5132
5234
|
listRef,
|
|
5133
5235
|
onOpenChange,
|
|
5134
5236
|
onSelectionChange,
|
|
5237
|
+
onSetSelectedText,
|
|
5238
|
+
selected: selectedProp,
|
|
5135
5239
|
selectionStrategy,
|
|
5136
|
-
stringToItem,
|
|
5137
5240
|
value: valueProp,
|
|
5138
5241
|
InputProps: inputProps = {
|
|
5139
5242
|
onBlur,
|
|
@@ -5142,21 +5245,11 @@ var useCombobox = ({
|
|
|
5142
5245
|
onSelect
|
|
5143
5246
|
}
|
|
5144
5247
|
}) => {
|
|
5145
|
-
|
|
5146
|
-
const
|
|
5147
|
-
const
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
const {
|
|
5151
|
-
data: indexPositions,
|
|
5152
|
-
itemToCollectionItem,
|
|
5153
|
-
setFilterPattern,
|
|
5154
|
-
stringToCollectionItem
|
|
5155
|
-
} = collectionHook;
|
|
5156
|
-
const setHighlightedIndexRef = useRef23(null);
|
|
5157
|
-
const setSelectedRef = useRef23(null);
|
|
5158
|
-
const ignoreSelectOnFocus = useRef23(true);
|
|
5159
|
-
const selectedRef = useRef23(selectedValue);
|
|
5248
|
+
const isMultiSelect = isMultiSelection(selectionStrategy);
|
|
5249
|
+
const { setFilterPattern } = collectionHook;
|
|
5250
|
+
const setHighlightedIndexRef = useRef24(null);
|
|
5251
|
+
const selectedRef = useRef24(isMultiSelect ? [] : null);
|
|
5252
|
+
const ignoreSelectOnFocus = useRef24(true);
|
|
5160
5253
|
const [isOpen, setIsOpen] = useControlled5({
|
|
5161
5254
|
controlled: isOpenProp,
|
|
5162
5255
|
default: defaultIsOpen != null ? defaultIsOpen : false,
|
|
@@ -5164,116 +5257,138 @@ var useCombobox = ({
|
|
|
5164
5257
|
});
|
|
5165
5258
|
const [value, setValue] = useControlled5({
|
|
5166
5259
|
controlled: void 0,
|
|
5167
|
-
default: defaultValue != null ? defaultValue :
|
|
5260
|
+
default: defaultValue != null ? defaultValue : valueProp,
|
|
5168
5261
|
name: "ComboBox",
|
|
5169
5262
|
state: "value"
|
|
5170
5263
|
});
|
|
5171
|
-
const collectionItemsToItem = useCallback25(
|
|
5172
|
-
(sel) => {
|
|
5173
|
-
if (Array.isArray(sel)) {
|
|
5174
|
-
return sel.map((i) => i.value);
|
|
5175
|
-
} else if (sel) {
|
|
5176
|
-
return sel.value;
|
|
5177
|
-
} else {
|
|
5178
|
-
return sel;
|
|
5179
|
-
}
|
|
5180
|
-
},
|
|
5181
|
-
[]
|
|
5182
|
-
);
|
|
5183
5264
|
const [disableAriaActiveDescendant, setDisableAriaActiveDescendant] = useState11(true);
|
|
5184
|
-
const
|
|
5185
|
-
|
|
5186
|
-
(selected2
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
(_b = setHighlightedIndexRef.current) == null ? void 0 : _b.call(setHighlightedIndexRef, indexOfSelectedItem);
|
|
5195
|
-
}
|
|
5196
|
-
},
|
|
5197
|
-
[indexPositions]
|
|
5198
|
-
);
|
|
5199
|
-
const setTextValue = useCallback25(
|
|
5200
|
-
(value2) => {
|
|
5265
|
+
const highlightSelectedItem = useCallback26((selected2) => {
|
|
5266
|
+
var _a2;
|
|
5267
|
+
if (Array.isArray(selected2)) {
|
|
5268
|
+
console.log("TODO multi selection");
|
|
5269
|
+
} else if (selected2 == null) {
|
|
5270
|
+
(_a2 = setHighlightedIndexRef.current) == null ? void 0 : _a2.call(setHighlightedIndexRef, -1);
|
|
5271
|
+
}
|
|
5272
|
+
}, []);
|
|
5273
|
+
const setTextValue = useCallback26(
|
|
5274
|
+
(value2, applyFilter = true) => {
|
|
5201
5275
|
setValue(value2);
|
|
5202
|
-
|
|
5276
|
+
if (applyFilter) {
|
|
5277
|
+
setFilterPattern(value2 === "" ? void 0 : value2);
|
|
5278
|
+
}
|
|
5203
5279
|
},
|
|
5204
5280
|
[setFilterPattern, setValue]
|
|
5205
5281
|
);
|
|
5206
|
-
const reconcileInput =
|
|
5207
|
-
(selected2
|
|
5208
|
-
|
|
5209
|
-
let value2 = "";
|
|
5282
|
+
const reconcileInput = useCallback26(
|
|
5283
|
+
(selected2) => {
|
|
5284
|
+
let newValue = allowFreeText ? value != null ? value : "" : "";
|
|
5210
5285
|
if (Array.isArray(selected2)) {
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5286
|
+
if (selected2.length === 1) {
|
|
5287
|
+
newValue = itemToString2(selected2[0]);
|
|
5288
|
+
} else if (selected2.length > 1) {
|
|
5289
|
+
newValue = (itemsToString == null ? void 0 : itemsToString(selected2)) || "";
|
|
5290
|
+
}
|
|
5291
|
+
} else if (selected2) {
|
|
5292
|
+
newValue = itemToString2(selected2);
|
|
5214
5293
|
}
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5294
|
+
if (newValue !== value) {
|
|
5295
|
+
setTextValue(newValue, !isMultiSelect);
|
|
5296
|
+
onSetSelectedText == null ? void 0 : onSetSelectedText(newValue);
|
|
5297
|
+
return true;
|
|
5218
5298
|
} else {
|
|
5219
|
-
|
|
5299
|
+
return false;
|
|
5220
5300
|
}
|
|
5221
5301
|
},
|
|
5222
|
-
[
|
|
5302
|
+
[
|
|
5303
|
+
allowFreeText,
|
|
5304
|
+
isMultiSelect,
|
|
5305
|
+
itemToString2,
|
|
5306
|
+
itemsToString,
|
|
5307
|
+
onSetSelectedText,
|
|
5308
|
+
setTextValue,
|
|
5309
|
+
value
|
|
5310
|
+
]
|
|
5223
5311
|
);
|
|
5224
|
-
const applySelection =
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5312
|
+
const applySelection = useCallback26(() => {
|
|
5313
|
+
const { current: selected2 } = selectedRef;
|
|
5314
|
+
if (reconcileInput(selected2)) {
|
|
5315
|
+
if (selected2) {
|
|
5316
|
+
if (Array.isArray(selected2)) {
|
|
5317
|
+
onSelectionChange == null ? void 0 : onSelectionChange(
|
|
5318
|
+
null,
|
|
5319
|
+
selected2
|
|
5320
|
+
);
|
|
5321
|
+
} else if (selected2) {
|
|
5322
|
+
onSelectionChange == null ? void 0 : onSelectionChange(
|
|
5323
|
+
null,
|
|
5324
|
+
selected2
|
|
5325
|
+
);
|
|
5326
|
+
}
|
|
5327
|
+
}
|
|
5328
|
+
}
|
|
5329
|
+
}, [onSelectionChange, reconcileInput]);
|
|
5330
|
+
const selectFreeTextInputValue = useCallback26(() => {
|
|
5331
|
+
if (allowFreeText) {
|
|
5332
|
+
const text = value == null ? void 0 : value.trim();
|
|
5333
|
+
const { current: selected2 } = selectedRef;
|
|
5334
|
+
if (text) {
|
|
5335
|
+
if (itemCount === 0 && text) {
|
|
5336
|
+
if (isMultiSelect) {
|
|
5337
|
+
onSelectionChange == null ? void 0 : onSelectionChange(null, [
|
|
5338
|
+
text
|
|
5339
|
+
]);
|
|
5340
|
+
} else {
|
|
5341
|
+
onSelectionChange == null ? void 0 : onSelectionChange(null, text);
|
|
5342
|
+
}
|
|
5343
|
+
selectedRef.current = null;
|
|
5344
|
+
return true;
|
|
5345
|
+
} else if (selected2 && !isMultiSelect) {
|
|
5346
|
+
if (selected2 && !Array.isArray(selected2) && itemToString2(selected2) === text) {
|
|
5347
|
+
}
|
|
5348
|
+
}
|
|
5349
|
+
}
|
|
5350
|
+
}
|
|
5351
|
+
return false;
|
|
5352
|
+
}, [
|
|
5353
|
+
allowFreeText,
|
|
5354
|
+
value,
|
|
5355
|
+
itemCount,
|
|
5356
|
+
isMultiSelect,
|
|
5357
|
+
onSelectionChange,
|
|
5358
|
+
itemToString2
|
|
5359
|
+
]);
|
|
5360
|
+
const handleOpenChange = useCallback26(
|
|
5361
|
+
(open, closeReason) => {
|
|
5362
|
+
if (open && isMultiSelect) {
|
|
5363
|
+
setTextValue("", false);
|
|
5364
|
+
}
|
|
5365
|
+
setIsOpen(open);
|
|
5366
|
+
onOpenChange == null ? void 0 : onOpenChange(open);
|
|
5367
|
+
if (!open && closeReason !== "Escape") {
|
|
5368
|
+
if (!selectFreeTextInputValue()) {
|
|
5369
|
+
applySelection();
|
|
5370
|
+
}
|
|
5228
5371
|
}
|
|
5229
|
-
selectedRef.current = selected2;
|
|
5230
|
-
reconcileInput(selected2);
|
|
5231
|
-
onSelectionChange == null ? void 0 : onSelectionChange(evt, collectionItemsToItem(selected2 != null ? selected2 : null));
|
|
5232
5372
|
},
|
|
5233
5373
|
[
|
|
5234
|
-
|
|
5374
|
+
applySelection,
|
|
5235
5375
|
isMultiSelect,
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
setIsOpen
|
|
5376
|
+
onOpenChange,
|
|
5377
|
+
selectFreeTextInputValue,
|
|
5378
|
+
setIsOpen,
|
|
5379
|
+
setTextValue
|
|
5239
5380
|
]
|
|
5240
5381
|
);
|
|
5241
|
-
const handleSelectionChange =
|
|
5382
|
+
const handleSelectionChange = useCallback26(
|
|
5242
5383
|
(evt, selected2) => {
|
|
5384
|
+
selectedRef.current = selected2;
|
|
5243
5385
|
if (!isMultiSelect) {
|
|
5244
|
-
|
|
5245
|
-
applySelection(evt, selectedCollectionItem);
|
|
5246
|
-
}
|
|
5247
|
-
},
|
|
5248
|
-
[applySelection, isMultiSelect, itemToCollectionItem]
|
|
5249
|
-
);
|
|
5250
|
-
const handleFirstItemSelection = useCallback25(
|
|
5251
|
-
(evt) => {
|
|
5252
|
-
if (!allowFreeText && evt.key === "Enter" && quickSelection) {
|
|
5253
|
-
const [firstItem] = indexPositions;
|
|
5254
|
-
applySelection(evt, firstItem);
|
|
5386
|
+
handleOpenChange(false, "select");
|
|
5255
5387
|
}
|
|
5256
5388
|
},
|
|
5257
|
-
[
|
|
5389
|
+
[handleOpenChange, isMultiSelect]
|
|
5258
5390
|
);
|
|
5259
|
-
const
|
|
5260
|
-
(evt) => {
|
|
5261
|
-
if ("Escape" === evt.key) {
|
|
5262
|
-
if (allowFreeText) {
|
|
5263
|
-
setTextValue("");
|
|
5264
|
-
} else {
|
|
5265
|
-
reconcileInput();
|
|
5266
|
-
}
|
|
5267
|
-
} else if ("Tab" === evt.key) {
|
|
5268
|
-
if (!allowFreeText) {
|
|
5269
|
-
reconcileInput();
|
|
5270
|
-
}
|
|
5271
|
-
}
|
|
5272
|
-
handleFirstItemSelection(evt);
|
|
5273
|
-
},
|
|
5274
|
-
[allowFreeText, handleFirstItemSelection, reconcileInput, setTextValue]
|
|
5275
|
-
);
|
|
5276
|
-
const handleKeyboardNavigation = useCallback25(() => {
|
|
5391
|
+
const handleKeyboardNavigation = useCallback26(() => {
|
|
5277
5392
|
setDisableAriaActiveDescendant(false);
|
|
5278
5393
|
}, []);
|
|
5279
5394
|
const {
|
|
@@ -5282,41 +5397,26 @@ var useCombobox = ({
|
|
|
5282
5397
|
highlightedIndex,
|
|
5283
5398
|
listControlProps,
|
|
5284
5399
|
listHandlers: listHookListHandlers,
|
|
5285
|
-
selected
|
|
5286
|
-
setSelected
|
|
5400
|
+
selected
|
|
5287
5401
|
} = useList({
|
|
5288
5402
|
collectionHook,
|
|
5289
5403
|
containerRef: listRef,
|
|
5290
5404
|
defaultHighlightedIndex: initialHighlightedIndex,
|
|
5405
|
+
defaultSelected: collectionHook.itemToCollectionItemId(defaultSelected),
|
|
5291
5406
|
disableAriaActiveDescendant,
|
|
5292
5407
|
disableHighlightOnFocus: true,
|
|
5293
5408
|
disableTypeToSelect: true,
|
|
5294
|
-
label: "useComboBox",
|
|
5295
5409
|
onKeyboardNavigation: handleKeyboardNavigation,
|
|
5296
|
-
onKeyDown: handleInputKeyDown,
|
|
5410
|
+
// onKeyDown: handleInputKeyDown,
|
|
5297
5411
|
onSelectionChange: handleSelectionChange,
|
|
5298
|
-
|
|
5299
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5300
|
-
// @ts-ignore
|
|
5301
|
-
selected: selectedRef.current,
|
|
5412
|
+
selected: collectionHook.itemToCollectionItemId(selectedProp),
|
|
5302
5413
|
selectionKeys: EnterOnly,
|
|
5303
5414
|
selectionStrategy,
|
|
5304
5415
|
tabToSelect: !isMultiSelect
|
|
5305
5416
|
});
|
|
5306
5417
|
setHighlightedIndexRef.current = setHighlightedIndex;
|
|
5307
|
-
setSelectedRef.current = setSelected;
|
|
5308
|
-
const handleOpenChange = useCallback25(
|
|
5309
|
-
(open) => {
|
|
5310
|
-
setIsOpen(open);
|
|
5311
|
-
if (!open) {
|
|
5312
|
-
setQuickSelection(false);
|
|
5313
|
-
}
|
|
5314
|
-
onOpenChange == null ? void 0 : onOpenChange(open);
|
|
5315
|
-
},
|
|
5316
|
-
[onOpenChange, setIsOpen]
|
|
5317
|
-
);
|
|
5318
5418
|
const { onClick: listHandlersOnClick } = listHookListHandlers;
|
|
5319
|
-
const handleListClick =
|
|
5419
|
+
const handleListClick = useCallback26(
|
|
5320
5420
|
(evt) => {
|
|
5321
5421
|
var _a2;
|
|
5322
5422
|
(_a2 = document.getElementById(`${id}-input`)) == null ? void 0 : _a2.focus();
|
|
@@ -5324,7 +5424,7 @@ var useCombobox = ({
|
|
|
5324
5424
|
},
|
|
5325
5425
|
[id, listHandlersOnClick]
|
|
5326
5426
|
);
|
|
5327
|
-
const handleInputChange =
|
|
5427
|
+
const handleInputChange = useCallback26(
|
|
5328
5428
|
(evt) => {
|
|
5329
5429
|
const newValue = evt.target.value;
|
|
5330
5430
|
setValue(newValue);
|
|
@@ -5332,20 +5432,14 @@ var useCombobox = ({
|
|
|
5332
5432
|
setFilterPattern(newValue);
|
|
5333
5433
|
} else {
|
|
5334
5434
|
setFilterPattern(void 0);
|
|
5335
|
-
selectedRef.current = null;
|
|
5336
|
-
onSelectionChange == null ? void 0 : onSelectionChange(
|
|
5337
|
-
evt,
|
|
5338
|
-
null
|
|
5339
|
-
);
|
|
5340
5435
|
}
|
|
5341
5436
|
setIsOpen(true);
|
|
5342
|
-
setQuickSelection(newValue.length > 0 && !allowFreeText);
|
|
5343
5437
|
},
|
|
5344
|
-
[
|
|
5438
|
+
[setFilterPattern, setIsOpen, setValue]
|
|
5345
5439
|
);
|
|
5346
5440
|
const { onFocus: inputOnFocus = onFocus } = inputProps;
|
|
5347
5441
|
const { onFocus: listOnFocus } = listControlProps;
|
|
5348
|
-
const handleInputFocus =
|
|
5442
|
+
const handleInputFocus = useCallback26(
|
|
5349
5443
|
(evt) => {
|
|
5350
5444
|
setDisableAriaActiveDescendant(false);
|
|
5351
5445
|
listOnFocus == null ? void 0 : listOnFocus(evt);
|
|
@@ -5353,70 +5447,29 @@ var useCombobox = ({
|
|
|
5353
5447
|
},
|
|
5354
5448
|
[inputOnFocus, listOnFocus]
|
|
5355
5449
|
);
|
|
5356
|
-
const listFocused =
|
|
5450
|
+
const listFocused = useCallback26(
|
|
5357
5451
|
(evt) => {
|
|
5358
5452
|
const element = evt.relatedTarget;
|
|
5359
5453
|
return (element == null ? void 0 : element.id) === `${id}-list`;
|
|
5360
5454
|
},
|
|
5361
5455
|
[id]
|
|
5362
5456
|
);
|
|
5363
|
-
const selectInputValue = useCallback25(
|
|
5364
|
-
(evt) => {
|
|
5365
|
-
var _a2;
|
|
5366
|
-
const text = value.trim();
|
|
5367
|
-
if (text) {
|
|
5368
|
-
const selectedCollectionItem = stringToCollectionItem(
|
|
5369
|
-
text
|
|
5370
|
-
);
|
|
5371
|
-
if (selectedCollectionItem) {
|
|
5372
|
-
if (Array.isArray(selectedCollectionItem)) {
|
|
5373
|
-
} else if (selectedCollectionItem !== selected) {
|
|
5374
|
-
(_a2 = setSelectedRef.current) == null ? void 0 : _a2.call(setSelectedRef, selectedCollectionItem);
|
|
5375
|
-
onSelectionChange == null ? void 0 : onSelectionChange(
|
|
5376
|
-
evt,
|
|
5377
|
-
selectedCollectionItem.value
|
|
5378
|
-
);
|
|
5379
|
-
}
|
|
5380
|
-
} else if (stringToItem) {
|
|
5381
|
-
const item = stringToItem(text);
|
|
5382
|
-
if (item) {
|
|
5383
|
-
console.log("we have a new item");
|
|
5384
|
-
}
|
|
5385
|
-
}
|
|
5386
|
-
}
|
|
5387
|
-
},
|
|
5388
|
-
[onSelectionChange, selected, stringToItem, stringToCollectionItem, value]
|
|
5389
|
-
);
|
|
5390
5457
|
const { onBlur: inputOnBlur = onBlur } = inputProps;
|
|
5391
5458
|
const { onBlur: listOnBlur } = listControlProps;
|
|
5392
|
-
const handleInputBlur =
|
|
5459
|
+
const handleInputBlur = useCallback26(
|
|
5393
5460
|
(evt) => {
|
|
5394
5461
|
if (listFocused(evt)) {
|
|
5395
5462
|
} else {
|
|
5396
5463
|
listOnBlur == null ? void 0 : listOnBlur(evt);
|
|
5397
5464
|
inputOnBlur == null ? void 0 : inputOnBlur(evt);
|
|
5398
|
-
if (allowFreeText) {
|
|
5399
|
-
selectInputValue(evt);
|
|
5400
|
-
} else {
|
|
5401
|
-
reconcileInput();
|
|
5402
|
-
}
|
|
5403
5465
|
setDisableAriaActiveDescendant(true);
|
|
5404
5466
|
ignoreSelectOnFocus.current = true;
|
|
5405
|
-
setIsOpen(false);
|
|
5406
5467
|
}
|
|
5407
5468
|
},
|
|
5408
|
-
[
|
|
5409
|
-
listFocused,
|
|
5410
|
-
listOnBlur,
|
|
5411
|
-
inputOnBlur,
|
|
5412
|
-
allowFreeText,
|
|
5413
|
-
setIsOpen,
|
|
5414
|
-
selectInputValue,
|
|
5415
|
-
reconcileInput
|
|
5416
|
-
]
|
|
5469
|
+
[listFocused, listOnBlur, inputOnBlur]
|
|
5417
5470
|
);
|
|
5418
5471
|
const { onSelect: inputOnSelect } = inputProps;
|
|
5419
|
-
const handleInputSelect =
|
|
5472
|
+
const handleInputSelect = useCallback26(
|
|
5420
5473
|
(event) => {
|
|
5421
5474
|
if (ignoreSelectOnFocus.current) {
|
|
5422
5475
|
ignoreSelectOnFocus.current = false;
|
|
@@ -5429,16 +5482,13 @@ var useCombobox = ({
|
|
|
5429
5482
|
);
|
|
5430
5483
|
useLayoutEffectSkipFirst2(() => {
|
|
5431
5484
|
if (hasSelection(selected)) {
|
|
5432
|
-
highlightSelectedItem();
|
|
5485
|
+
highlightSelectedItem(selected);
|
|
5433
5486
|
} else {
|
|
5434
5487
|
setHighlightedIndex(initialHighlightedIndex);
|
|
5435
5488
|
}
|
|
5436
|
-
if (indexPositions.length === 0) {
|
|
5437
|
-
setIsOpen(false);
|
|
5438
|
-
}
|
|
5439
5489
|
}, [
|
|
5440
5490
|
highlightSelectedItem,
|
|
5441
|
-
|
|
5491
|
+
itemCount,
|
|
5442
5492
|
initialHighlightedIndex,
|
|
5443
5493
|
selected,
|
|
5444
5494
|
setHighlightedIndex,
|
|
@@ -5447,7 +5497,8 @@ var useCombobox = ({
|
|
|
5447
5497
|
const mergedInputProps = {
|
|
5448
5498
|
...inputProps.inputProps,
|
|
5449
5499
|
// "aria-owns": listId,
|
|
5450
|
-
"aria-label": ariaLabel
|
|
5500
|
+
"aria-label": ariaLabel,
|
|
5501
|
+
autoComplete: "off"
|
|
5451
5502
|
};
|
|
5452
5503
|
return {
|
|
5453
5504
|
focusVisible,
|
|
@@ -5464,7 +5515,6 @@ var useCombobox = ({
|
|
|
5464
5515
|
role: "combobox",
|
|
5465
5516
|
value
|
|
5466
5517
|
},
|
|
5467
|
-
// listControlProps,
|
|
5468
5518
|
listControlProps: {
|
|
5469
5519
|
...listControlProps,
|
|
5470
5520
|
onBlur: handleInputBlur,
|
|
@@ -5474,57 +5524,69 @@ var useCombobox = ({
|
|
|
5474
5524
|
...listHookListHandlers,
|
|
5475
5525
|
onClick: handleListClick
|
|
5476
5526
|
},
|
|
5477
|
-
selected
|
|
5527
|
+
selected: selectedRef.current
|
|
5478
5528
|
};
|
|
5479
5529
|
};
|
|
5480
5530
|
|
|
5481
5531
|
// src/list/ChevronIcon.tsx
|
|
5482
5532
|
import cx8 from "classnames";
|
|
5483
|
-
import { jsx as
|
|
5533
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
5484
5534
|
var classBase7 = "vuuChevronIcon";
|
|
5485
5535
|
var ChevronIcon = (props) => {
|
|
5486
5536
|
const { direction, ...htmlAttributes } = props;
|
|
5487
|
-
return /* @__PURE__ */
|
|
5537
|
+
return /* @__PURE__ */ jsx15("span", { ...htmlAttributes, className: cx8(classBase7, direction) });
|
|
5488
5538
|
};
|
|
5489
5539
|
|
|
5490
5540
|
// src/combo-box/ComboBox.tsx
|
|
5491
|
-
import { jsx as
|
|
5541
|
+
import { jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
5492
5542
|
var ComboBox = forwardRef8(function Combobox({
|
|
5493
5543
|
InputProps: InputProps5,
|
|
5494
5544
|
ListProps: ListProps3,
|
|
5545
|
+
PopupProps,
|
|
5495
5546
|
ListItem: ListItem4,
|
|
5496
5547
|
"aria-label": ariaLabel,
|
|
5497
5548
|
allowFreeText,
|
|
5498
5549
|
children,
|
|
5499
5550
|
defaultIsOpen,
|
|
5551
|
+
defaultSelected,
|
|
5500
5552
|
defaultValue,
|
|
5501
5553
|
disabled,
|
|
5502
5554
|
onBlur,
|
|
5503
5555
|
onFocus,
|
|
5504
5556
|
onChange,
|
|
5505
5557
|
onSelect,
|
|
5558
|
+
onSetSelectedText,
|
|
5506
5559
|
getFilterRegex,
|
|
5507
5560
|
id: idProp,
|
|
5508
5561
|
initialHighlightedIndex = -1,
|
|
5509
5562
|
isOpen: isOpenProp,
|
|
5510
|
-
itemToString: itemToString2,
|
|
5563
|
+
itemToString: itemToString2 = itemToString,
|
|
5564
|
+
itemsToString,
|
|
5511
5565
|
onOpenChange: onOpenChangeProp,
|
|
5512
5566
|
onSelectionChange,
|
|
5567
|
+
selected: selectedProp,
|
|
5513
5568
|
selectionStrategy,
|
|
5514
5569
|
source,
|
|
5515
|
-
stringToItem,
|
|
5516
5570
|
value: valueProp,
|
|
5517
5571
|
width = 180,
|
|
5518
5572
|
...props
|
|
5519
5573
|
}, forwardedRef) {
|
|
5520
5574
|
const id = useId4(idProp);
|
|
5521
|
-
const listRef =
|
|
5575
|
+
const listRef = useRef25(null);
|
|
5576
|
+
const valueFromSelected = (item) => {
|
|
5577
|
+
return Array.isArray(item) && item.length > 0 ? item[0] : void 0;
|
|
5578
|
+
};
|
|
5579
|
+
const getInitialValue = (items1, items2) => {
|
|
5580
|
+
const item = items1 ? valueFromSelected(items1) : items2 ? valueFromSelected(items2) : void 0;
|
|
5581
|
+
return item ? itemToString2(item) : "";
|
|
5582
|
+
};
|
|
5583
|
+
const initialValue = getInitialValue(selectedProp, defaultSelected);
|
|
5522
5584
|
const collectionHook = useCollectionItems({
|
|
5523
5585
|
id,
|
|
5524
5586
|
source,
|
|
5525
5587
|
children,
|
|
5526
5588
|
options: {
|
|
5527
|
-
filterPattern:
|
|
5589
|
+
filterPattern: initialValue,
|
|
5528
5590
|
getFilterRegex,
|
|
5529
5591
|
itemToString: itemToString2
|
|
5530
5592
|
}
|
|
@@ -5544,9 +5606,12 @@ var ComboBox = forwardRef8(function Combobox({
|
|
|
5544
5606
|
ariaLabel,
|
|
5545
5607
|
collectionHook,
|
|
5546
5608
|
defaultIsOpen,
|
|
5609
|
+
defaultSelected,
|
|
5547
5610
|
defaultValue,
|
|
5548
5611
|
disabled,
|
|
5549
5612
|
initialHighlightedIndex,
|
|
5613
|
+
itemCount: collectionHook.data.length,
|
|
5614
|
+
label: props.title,
|
|
5550
5615
|
listRef,
|
|
5551
5616
|
onBlur,
|
|
5552
5617
|
onFocus,
|
|
@@ -5555,39 +5620,33 @@ var ComboBox = forwardRef8(function Combobox({
|
|
|
5555
5620
|
id,
|
|
5556
5621
|
isOpen: isOpenProp,
|
|
5557
5622
|
itemToString: itemToString2,
|
|
5558
|
-
|
|
5623
|
+
itemsToString,
|
|
5559
5624
|
onOpenChange: onOpenChangeProp,
|
|
5560
5625
|
onSelectionChange,
|
|
5626
|
+
onSetSelectedText,
|
|
5627
|
+
selected: selectedProp,
|
|
5561
5628
|
selectionStrategy,
|
|
5562
|
-
|
|
5563
|
-
value: valueProp
|
|
5629
|
+
value: initialValue
|
|
5564
5630
|
});
|
|
5565
|
-
const
|
|
5566
|
-
(
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
}
|
|
5574
|
-
},
|
|
5575
|
-
[]
|
|
5576
|
-
);
|
|
5577
|
-
const endAdornment = endAdornmentProp === null ? null : /* @__PURE__ */ jsx15(
|
|
5631
|
+
const handleDropdownIconClick = useCallback27(() => {
|
|
5632
|
+
if (isOpen) {
|
|
5633
|
+
onOpenChange(false, "toggle");
|
|
5634
|
+
} else {
|
|
5635
|
+
onOpenChange(true);
|
|
5636
|
+
}
|
|
5637
|
+
}, [isOpen, onOpenChange]);
|
|
5638
|
+
const endAdornment = endAdornmentProp === null ? null : /* @__PURE__ */ jsx16(
|
|
5578
5639
|
ChevronIcon,
|
|
5579
5640
|
{
|
|
5580
5641
|
direction: isOpen ? "up" : "down",
|
|
5581
|
-
onClick:
|
|
5582
|
-
onOpenChange(!isOpen);
|
|
5583
|
-
}
|
|
5642
|
+
onClick: handleDropdownIconClick
|
|
5584
5643
|
}
|
|
5585
5644
|
);
|
|
5586
|
-
return /* @__PURE__ */
|
|
5645
|
+
return /* @__PURE__ */ jsx16(CollectionProvider, { collectionHook, children: /* @__PURE__ */ jsxs7(
|
|
5587
5646
|
DropdownBase,
|
|
5588
5647
|
{
|
|
5589
5648
|
...props,
|
|
5590
|
-
|
|
5649
|
+
PopupProps,
|
|
5591
5650
|
id,
|
|
5592
5651
|
isOpen,
|
|
5593
5652
|
onOpenChange,
|
|
@@ -5595,7 +5654,7 @@ var ComboBox = forwardRef8(function Combobox({
|
|
|
5595
5654
|
ref: forwardedRef,
|
|
5596
5655
|
width,
|
|
5597
5656
|
children: [
|
|
5598
|
-
/* @__PURE__ */
|
|
5657
|
+
/* @__PURE__ */ jsx16(
|
|
5599
5658
|
Input,
|
|
5600
5659
|
{
|
|
5601
5660
|
...inputProps,
|
|
@@ -5604,11 +5663,12 @@ var ComboBox = forwardRef8(function Combobox({
|
|
|
5604
5663
|
endAdornment
|
|
5605
5664
|
}
|
|
5606
5665
|
),
|
|
5607
|
-
/* @__PURE__ */
|
|
5666
|
+
/* @__PURE__ */ jsx16(
|
|
5608
5667
|
List,
|
|
5609
5668
|
{
|
|
5610
5669
|
...ListProps3,
|
|
5611
5670
|
ListItem: ListItem4,
|
|
5671
|
+
defaultSelected: void 0,
|
|
5612
5672
|
focusVisible,
|
|
5613
5673
|
highlightedIndex,
|
|
5614
5674
|
itemTextHighlightPattern: String(inputProps.value) || void 0,
|
|
@@ -5616,8 +5676,9 @@ var ComboBox = forwardRef8(function Combobox({
|
|
|
5616
5676
|
listHandlers,
|
|
5617
5677
|
onSelectionChange,
|
|
5618
5678
|
ref: listRef,
|
|
5619
|
-
selected
|
|
5620
|
-
selectionStrategy
|
|
5679
|
+
selected,
|
|
5680
|
+
selectionStrategy,
|
|
5681
|
+
tabIndex: -1
|
|
5621
5682
|
}
|
|
5622
5683
|
)
|
|
5623
5684
|
]
|
|
@@ -5662,8 +5723,8 @@ function applyRules(rules, value) {
|
|
|
5662
5723
|
|
|
5663
5724
|
// src/editable/useEditableText.ts
|
|
5664
5725
|
import {
|
|
5665
|
-
useCallback as
|
|
5666
|
-
useRef as
|
|
5726
|
+
useCallback as useCallback28,
|
|
5727
|
+
useRef as useRef26,
|
|
5667
5728
|
useState as useState12
|
|
5668
5729
|
} from "react";
|
|
5669
5730
|
var dispatchCommitEvent = (el) => {
|
|
@@ -5677,13 +5738,13 @@ var useEditableText = ({
|
|
|
5677
5738
|
}) => {
|
|
5678
5739
|
const [message, setMessage] = useState12();
|
|
5679
5740
|
const [value, setValue] = useState12(initialValue);
|
|
5680
|
-
const initialValueRef =
|
|
5681
|
-
const isDirtyRef =
|
|
5682
|
-
const hasCommittedRef =
|
|
5683
|
-
const handleBlur =
|
|
5741
|
+
const initialValueRef = useRef26(initialValue);
|
|
5742
|
+
const isDirtyRef = useRef26(false);
|
|
5743
|
+
const hasCommittedRef = useRef26(false);
|
|
5744
|
+
const handleBlur = useCallback28(() => {
|
|
5684
5745
|
console.log("blur");
|
|
5685
5746
|
}, []);
|
|
5686
|
-
const handleKeyDown =
|
|
5747
|
+
const handleKeyDown = useCallback28(
|
|
5687
5748
|
(evt) => {
|
|
5688
5749
|
if (evt.key === "Enter") {
|
|
5689
5750
|
evt.stopPropagation();
|
|
@@ -5715,7 +5776,7 @@ var useEditableText = ({
|
|
|
5715
5776
|
},
|
|
5716
5777
|
[clientSideEditValidationCheck, onCommit, value]
|
|
5717
5778
|
);
|
|
5718
|
-
const handleChange =
|
|
5779
|
+
const handleChange = useCallback28(
|
|
5719
5780
|
(evt) => {
|
|
5720
5781
|
const { value: value2 } = evt.target;
|
|
5721
5782
|
isDirtyRef.current = value2 !== initialValueRef.current;
|
|
@@ -5743,13 +5804,13 @@ var useEditableText = ({
|
|
|
5743
5804
|
// src/editable-label/EditableLabel.tsx
|
|
5744
5805
|
import cx9 from "classnames";
|
|
5745
5806
|
import {
|
|
5746
|
-
useCallback as
|
|
5807
|
+
useCallback as useCallback29,
|
|
5747
5808
|
useLayoutEffect as useLayoutEffect3,
|
|
5748
5809
|
forwardRef as forwardRef9,
|
|
5749
|
-
useRef as
|
|
5810
|
+
useRef as useRef27
|
|
5750
5811
|
} from "react";
|
|
5751
5812
|
import { Input as Input2, useControlled as useControlled6 } from "@salt-ds/core";
|
|
5752
|
-
import { jsx as
|
|
5813
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
5753
5814
|
var classBase8 = "vuuEditableLabel";
|
|
5754
5815
|
var EditableLabel = forwardRef9(function EditableLabel2({
|
|
5755
5816
|
className: classNameProp,
|
|
@@ -5762,8 +5823,8 @@ var EditableLabel = forwardRef9(function EditableLabel2({
|
|
|
5762
5823
|
value: valueProp,
|
|
5763
5824
|
...restProps
|
|
5764
5825
|
}, forwardedRef) {
|
|
5765
|
-
const inputRef =
|
|
5766
|
-
const editingRef =
|
|
5826
|
+
const inputRef = useRef27(null);
|
|
5827
|
+
const editingRef = useRef27(false);
|
|
5767
5828
|
const [value, setValue] = useControlled6({
|
|
5768
5829
|
controlled: valueProp,
|
|
5769
5830
|
default: defaultValue != null ? defaultValue : "",
|
|
@@ -5776,13 +5837,13 @@ var EditableLabel = forwardRef9(function EditableLabel2({
|
|
|
5776
5837
|
name: "EditableLabel",
|
|
5777
5838
|
state: "editing"
|
|
5778
5839
|
});
|
|
5779
|
-
const setEditing =
|
|
5840
|
+
const setEditing = useCallback29(
|
|
5780
5841
|
(value2) => {
|
|
5781
5842
|
_setEditing(editingRef.current = value2);
|
|
5782
5843
|
},
|
|
5783
5844
|
[_setEditing]
|
|
5784
5845
|
);
|
|
5785
|
-
const initialValue =
|
|
5846
|
+
const initialValue = useRef27(value);
|
|
5786
5847
|
useLayoutEffect3(() => {
|
|
5787
5848
|
if (editing) {
|
|
5788
5849
|
if (inputRef.current !== null) {
|
|
@@ -5791,7 +5852,7 @@ var EditableLabel = forwardRef9(function EditableLabel2({
|
|
|
5791
5852
|
}
|
|
5792
5853
|
}
|
|
5793
5854
|
}, [editing, inputRef]);
|
|
5794
|
-
const enterEditMode =
|
|
5855
|
+
const enterEditMode = useCallback29(() => {
|
|
5795
5856
|
setEditing(true);
|
|
5796
5857
|
onEnterEditMode && onEnterEditMode();
|
|
5797
5858
|
}, [onEnterEditMode, setEditing]);
|
|
@@ -5836,7 +5897,7 @@ var EditableLabel = forwardRef9(function EditableLabel2({
|
|
|
5836
5897
|
const className = cx9(classBase8, classNameProp, {
|
|
5837
5898
|
[`${classBase8}-editing`]: editing
|
|
5838
5899
|
});
|
|
5839
|
-
return /* @__PURE__ */
|
|
5900
|
+
return /* @__PURE__ */ jsx17(
|
|
5840
5901
|
"div",
|
|
5841
5902
|
{
|
|
5842
5903
|
...restProps,
|
|
@@ -5844,7 +5905,7 @@ var EditableLabel = forwardRef9(function EditableLabel2({
|
|
|
5844
5905
|
onDoubleClick: handleDoubleClick,
|
|
5845
5906
|
"data-text": value,
|
|
5846
5907
|
ref: forwardedRef,
|
|
5847
|
-
children: editing ? /* @__PURE__ */
|
|
5908
|
+
children: editing ? /* @__PURE__ */ jsx17(
|
|
5848
5909
|
Input2,
|
|
5849
5910
|
{
|
|
5850
5911
|
inputProps: { className: `${classBase8}-input`, spellCheck: false },
|
|
@@ -5857,7 +5918,7 @@ var EditableLabel = forwardRef9(function EditableLabel2({
|
|
|
5857
5918
|
textAlign: "left",
|
|
5858
5919
|
variant: "secondary"
|
|
5859
5920
|
}
|
|
5860
|
-
) : /* @__PURE__ */
|
|
5921
|
+
) : /* @__PURE__ */ jsx17("span", { className: `${classBase8}-label`, children: value })
|
|
5861
5922
|
}
|
|
5862
5923
|
);
|
|
5863
5924
|
});
|
|
@@ -5866,10 +5927,10 @@ var EditableLabel = forwardRef9(function EditableLabel2({
|
|
|
5866
5927
|
import { Input as Input3 } from "@salt-ds/core";
|
|
5867
5928
|
import cx10 from "classnames";
|
|
5868
5929
|
import { forwardRef as forwardRef10 } from "react";
|
|
5869
|
-
import { jsx as
|
|
5930
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
5870
5931
|
var classBase9 = "vuuExpandoInput";
|
|
5871
5932
|
var ExpandoInput = forwardRef10(function ExpandoInput2({ className: classNameProp, value, inputProps, ...InputProps5 }, forwardedRef) {
|
|
5872
|
-
return /* @__PURE__ */
|
|
5933
|
+
return /* @__PURE__ */ jsx18("div", { className: cx10(classBase9, classNameProp), "data-text": value, children: /* @__PURE__ */ jsx18(
|
|
5873
5934
|
Input3,
|
|
5874
5935
|
{
|
|
5875
5936
|
...InputProps5,
|
|
@@ -5884,7 +5945,7 @@ var ExpandoInput = forwardRef10(function ExpandoInput2({ className: classNamePro
|
|
|
5884
5945
|
});
|
|
5885
5946
|
|
|
5886
5947
|
// src/inputs/Checkbox.tsx
|
|
5887
|
-
import { jsx as
|
|
5948
|
+
import { jsx as jsx19, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
5888
5949
|
var Checkbox = (props) => {
|
|
5889
5950
|
const { onToggle, checked, label } = props;
|
|
5890
5951
|
return /* @__PURE__ */ jsxs8(
|
|
@@ -5894,7 +5955,7 @@ var Checkbox = (props) => {
|
|
|
5894
5955
|
onClick: onToggle,
|
|
5895
5956
|
onKeyUp: (e) => e.key === " " && onToggle(),
|
|
5896
5957
|
children: [
|
|
5897
|
-
/* @__PURE__ */
|
|
5958
|
+
/* @__PURE__ */ jsx19(CheckboxIcon, { tabIndex: 0, checked }),
|
|
5898
5959
|
label
|
|
5899
5960
|
]
|
|
5900
5961
|
}
|
|
@@ -5902,28 +5963,29 @@ var Checkbox = (props) => {
|
|
|
5902
5963
|
};
|
|
5903
5964
|
|
|
5904
5965
|
// src/inputs/RadioButton.tsx
|
|
5905
|
-
import { jsx as
|
|
5966
|
+
import { jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
5906
5967
|
var RadioButton = (props) => {
|
|
5907
5968
|
const { onClick, checked, label, groupName } = props;
|
|
5908
5969
|
return /* @__PURE__ */ jsxs9("div", { className: "vuuRadioButton", onClick, children: [
|
|
5909
5970
|
/* @__PURE__ */ jsxs9("div", { className: "radio", children: [
|
|
5910
|
-
/* @__PURE__ */
|
|
5911
|
-
/* @__PURE__ */
|
|
5971
|
+
/* @__PURE__ */ jsx20("input", { type: "radio", name: groupName }),
|
|
5972
|
+
/* @__PURE__ */ jsx20(RadioIcon, { checked })
|
|
5912
5973
|
] }),
|
|
5913
5974
|
label
|
|
5914
5975
|
] });
|
|
5915
5976
|
};
|
|
5916
5977
|
|
|
5917
|
-
// src/instrument-
|
|
5918
|
-
import {
|
|
5919
|
-
import {
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
import {
|
|
5978
|
+
// src/instrument-picker/InstrumentPicker.tsx
|
|
5979
|
+
import { useId as useId5 } from "@vuu-ui/vuu-layout";
|
|
5980
|
+
import {
|
|
5981
|
+
TableNext
|
|
5982
|
+
} from "@vuu-ui/vuu-table";
|
|
5983
|
+
import { Input as Input4 } from "@salt-ds/core";
|
|
5984
|
+
import { forwardRef as forwardRef11, useMemo as useMemo15 } from "react";
|
|
5923
5985
|
|
|
5924
|
-
// src/instrument-
|
|
5986
|
+
// src/instrument-picker/SearchCell.tsx
|
|
5925
5987
|
import { registerComponent } from "@vuu-ui/vuu-utils";
|
|
5926
|
-
import { jsx as
|
|
5988
|
+
import { jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
5927
5989
|
var classBase10 = "vuuSearchCell";
|
|
5928
5990
|
var SearchCell = ({
|
|
5929
5991
|
column,
|
|
@@ -5933,7 +5995,7 @@ var SearchCell = ({
|
|
|
5933
5995
|
const key = columnMap[column.name];
|
|
5934
5996
|
const value = row[key];
|
|
5935
5997
|
return /* @__PURE__ */ jsxs10("div", { className: classBase10, tabIndex: -1, children: [
|
|
5936
|
-
/* @__PURE__ */
|
|
5998
|
+
/* @__PURE__ */ jsx21("span", { "data-icon": "draggable" }),
|
|
5937
5999
|
value
|
|
5938
6000
|
] });
|
|
5939
6001
|
};
|
|
@@ -5942,9 +6004,176 @@ registerComponent("search-cell", SearchCell, "cell-renderer", {
|
|
|
5942
6004
|
serverDataType: "private"
|
|
5943
6005
|
});
|
|
5944
6006
|
|
|
6007
|
+
// src/instrument-picker/useInstrumentPicker.ts
|
|
6008
|
+
import { useCallback as useCallback30, useMemo as useMemo14, useState as useState13 } from "react";
|
|
6009
|
+
var useInstrumentPicker = ({
|
|
6010
|
+
columnMap,
|
|
6011
|
+
dataSource,
|
|
6012
|
+
defaultIsOpen,
|
|
6013
|
+
isOpen: isOpenProp,
|
|
6014
|
+
onSelect,
|
|
6015
|
+
searchColumns
|
|
6016
|
+
}) => {
|
|
6017
|
+
const [value, setValue] = useState13("");
|
|
6018
|
+
const [isOpen, setIsOpen] = useControlled({
|
|
6019
|
+
controlled: isOpenProp,
|
|
6020
|
+
default: defaultIsOpen != null ? defaultIsOpen : false,
|
|
6021
|
+
name: "useDropdownList"
|
|
6022
|
+
});
|
|
6023
|
+
console.log({ dataSource });
|
|
6024
|
+
const baseFilterPattern = useMemo14(
|
|
6025
|
+
// TODO make this contains once server supports it
|
|
6026
|
+
() => searchColumns.map((col) => `${col} starts "__VALUE__"`).join(" or "),
|
|
6027
|
+
[searchColumns]
|
|
6028
|
+
);
|
|
6029
|
+
const handleOpenChange = useCallback30(
|
|
6030
|
+
(open) => {
|
|
6031
|
+
setIsOpen(open);
|
|
6032
|
+
},
|
|
6033
|
+
[setIsOpen]
|
|
6034
|
+
);
|
|
6035
|
+
const handleInputChange = useCallback30(
|
|
6036
|
+
(evt) => {
|
|
6037
|
+
const { value: value2 } = evt.target;
|
|
6038
|
+
setValue(value2);
|
|
6039
|
+
if (value2 && value2.trim().length) {
|
|
6040
|
+
const filter = baseFilterPattern.replaceAll("__VALUE__", value2);
|
|
6041
|
+
dataSource.filter = {
|
|
6042
|
+
filter
|
|
6043
|
+
};
|
|
6044
|
+
} else {
|
|
6045
|
+
dataSource.filter = {
|
|
6046
|
+
filter: ""
|
|
6047
|
+
};
|
|
6048
|
+
}
|
|
6049
|
+
setIsOpen(true);
|
|
6050
|
+
},
|
|
6051
|
+
[baseFilterPattern, dataSource, setIsOpen]
|
|
6052
|
+
);
|
|
6053
|
+
const handleSelectRow = useCallback30(
|
|
6054
|
+
(row) => {
|
|
6055
|
+
const { name } = columnMap;
|
|
6056
|
+
const { [name]: value2 } = row;
|
|
6057
|
+
setValue(value2);
|
|
6058
|
+
setIsOpen(false);
|
|
6059
|
+
onSelect(row);
|
|
6060
|
+
},
|
|
6061
|
+
[columnMap, onSelect, setIsOpen]
|
|
6062
|
+
);
|
|
6063
|
+
const inputProps = {
|
|
6064
|
+
onChange: handleInputChange
|
|
6065
|
+
};
|
|
6066
|
+
const controlProps = {};
|
|
6067
|
+
const tableHandlers = {
|
|
6068
|
+
onSelect: handleSelectRow
|
|
6069
|
+
};
|
|
6070
|
+
return {
|
|
6071
|
+
controlProps,
|
|
6072
|
+
inputProps,
|
|
6073
|
+
isOpen,
|
|
6074
|
+
onOpenChange: handleOpenChange,
|
|
6075
|
+
tableHandlers,
|
|
6076
|
+
value
|
|
6077
|
+
};
|
|
6078
|
+
};
|
|
6079
|
+
|
|
6080
|
+
// src/instrument-picker/InstrumentPicker.tsx
|
|
6081
|
+
import { jsx as jsx22, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
6082
|
+
var classBase11 = "vuuInstrumentPicker";
|
|
6083
|
+
var InstrumentPicker = forwardRef11(function InstrumentPicker2({
|
|
6084
|
+
TableProps: { dataSource, ...TableProps3 },
|
|
6085
|
+
className,
|
|
6086
|
+
columnMap,
|
|
6087
|
+
disabled,
|
|
6088
|
+
id: idProp,
|
|
6089
|
+
onSelect,
|
|
6090
|
+
schema,
|
|
6091
|
+
searchColumns,
|
|
6092
|
+
width,
|
|
6093
|
+
...htmlAttributes
|
|
6094
|
+
}, forwardedRef) {
|
|
6095
|
+
const id = useId5(idProp);
|
|
6096
|
+
const {
|
|
6097
|
+
controlProps,
|
|
6098
|
+
inputProps,
|
|
6099
|
+
isOpen,
|
|
6100
|
+
onOpenChange,
|
|
6101
|
+
tableHandlers,
|
|
6102
|
+
value
|
|
6103
|
+
} = useInstrumentPicker({ columnMap, dataSource, onSelect, searchColumns });
|
|
6104
|
+
const endAdornment = useMemo15(() => /* @__PURE__ */ jsx22("span", { "data-icon": "chevron-down" }), []);
|
|
6105
|
+
return /* @__PURE__ */ jsxs11(
|
|
6106
|
+
DropdownBase,
|
|
6107
|
+
{
|
|
6108
|
+
...htmlAttributes,
|
|
6109
|
+
fullWidth: true,
|
|
6110
|
+
id,
|
|
6111
|
+
isOpen,
|
|
6112
|
+
onOpenChange,
|
|
6113
|
+
openOnFocus: true,
|
|
6114
|
+
placement: "below-full-width",
|
|
6115
|
+
ref: forwardedRef,
|
|
6116
|
+
width,
|
|
6117
|
+
children: [
|
|
6118
|
+
/* @__PURE__ */ jsx22(
|
|
6119
|
+
Input4,
|
|
6120
|
+
{
|
|
6121
|
+
...inputProps,
|
|
6122
|
+
disabled,
|
|
6123
|
+
...controlProps,
|
|
6124
|
+
endAdornment,
|
|
6125
|
+
value
|
|
6126
|
+
}
|
|
6127
|
+
),
|
|
6128
|
+
/* @__PURE__ */ jsx22(
|
|
6129
|
+
TableNext,
|
|
6130
|
+
{
|
|
6131
|
+
rowHeight: 25,
|
|
6132
|
+
renderBufferSize: 100,
|
|
6133
|
+
...TableProps3,
|
|
6134
|
+
...tableHandlers,
|
|
6135
|
+
className: `${classBase11}-list`,
|
|
6136
|
+
height: 200,
|
|
6137
|
+
dataSource,
|
|
6138
|
+
showColumnHeaders: false
|
|
6139
|
+
}
|
|
6140
|
+
)
|
|
6141
|
+
]
|
|
6142
|
+
}
|
|
6143
|
+
);
|
|
6144
|
+
});
|
|
6145
|
+
|
|
5945
6146
|
// src/instrument-search/InstrumentSearch.tsx
|
|
5946
|
-
import {
|
|
5947
|
-
|
|
6147
|
+
import { registerComponent as registerComponent3 } from "@vuu-ui/vuu-layout";
|
|
6148
|
+
import { TableNext as TableNext2 } from "@vuu-ui/vuu-table";
|
|
6149
|
+
import { FormField, FormFieldLabel, Input as Input5 } from "@salt-ds/core";
|
|
6150
|
+
import cx11 from "classnames";
|
|
6151
|
+
import { useCallback as useCallback31, useState as useState14 } from "react";
|
|
6152
|
+
|
|
6153
|
+
// src/instrument-search/SearchCell.tsx
|
|
6154
|
+
import { registerComponent as registerComponent2 } from "@vuu-ui/vuu-utils";
|
|
6155
|
+
import { jsx as jsx23, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
6156
|
+
var classBase12 = "vuuSearchCell";
|
|
6157
|
+
var SearchCell2 = ({
|
|
6158
|
+
column,
|
|
6159
|
+
columnMap,
|
|
6160
|
+
row
|
|
6161
|
+
}) => {
|
|
6162
|
+
const key = columnMap[column.name];
|
|
6163
|
+
const value = row[key];
|
|
6164
|
+
return /* @__PURE__ */ jsxs12("div", { className: classBase12, tabIndex: -1, children: [
|
|
6165
|
+
/* @__PURE__ */ jsx23("span", { "data-icon": "draggable" }),
|
|
6166
|
+
value
|
|
6167
|
+
] });
|
|
6168
|
+
};
|
|
6169
|
+
console.log("register SearchCell");
|
|
6170
|
+
registerComponent2("search-cell", SearchCell2, "cell-renderer", {
|
|
6171
|
+
serverDataType: "private"
|
|
6172
|
+
});
|
|
6173
|
+
|
|
6174
|
+
// src/instrument-search/InstrumentSearch.tsx
|
|
6175
|
+
import { jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
6176
|
+
var classBase13 = "vuuInstrumentSearch";
|
|
5948
6177
|
var defaultTableConfig = {
|
|
5949
6178
|
columns: [
|
|
5950
6179
|
{ name: "bbg", hidden: true },
|
|
@@ -5961,16 +6190,16 @@ var defaultTableConfig = {
|
|
|
5961
6190
|
],
|
|
5962
6191
|
rowSeparators: true
|
|
5963
6192
|
};
|
|
5964
|
-
var searchIcon = /* @__PURE__ */
|
|
6193
|
+
var searchIcon = /* @__PURE__ */ jsx24("span", { "data-icon": "search" });
|
|
5965
6194
|
var InstrumentSearch = ({
|
|
5966
|
-
TableProps:
|
|
6195
|
+
TableProps: TableProps3,
|
|
5967
6196
|
className,
|
|
5968
6197
|
dataSource,
|
|
5969
6198
|
searchColumn = "description",
|
|
5970
6199
|
...htmlAttributes
|
|
5971
6200
|
}) => {
|
|
5972
|
-
const [searchState, setSearchState] =
|
|
5973
|
-
const handleChange =
|
|
6201
|
+
const [searchState, setSearchState] = useState14({ searchText: "", filter: "" });
|
|
6202
|
+
const handleChange = useCallback31(
|
|
5974
6203
|
(evt) => {
|
|
5975
6204
|
const { value } = evt.target;
|
|
5976
6205
|
const filter = `name starts "${value}"`;
|
|
@@ -5989,11 +6218,11 @@ var InstrumentSearch = ({
|
|
|
5989
6218
|
},
|
|
5990
6219
|
[dataSource, searchColumn]
|
|
5991
6220
|
);
|
|
5992
|
-
return /* @__PURE__ */
|
|
5993
|
-
/* @__PURE__ */
|
|
5994
|
-
/* @__PURE__ */
|
|
5995
|
-
/* @__PURE__ */
|
|
5996
|
-
|
|
6221
|
+
return /* @__PURE__ */ jsxs13("div", { ...htmlAttributes, className: cx11(classBase13, className), children: [
|
|
6222
|
+
/* @__PURE__ */ jsxs13(FormField, { className: `${classBase13}-inputField`, children: [
|
|
6223
|
+
/* @__PURE__ */ jsx24(FormFieldLabel, {}),
|
|
6224
|
+
/* @__PURE__ */ jsx24(
|
|
6225
|
+
Input5,
|
|
5997
6226
|
{
|
|
5998
6227
|
endAdornment: searchIcon,
|
|
5999
6228
|
value: searchState.searchText,
|
|
@@ -6001,21 +6230,22 @@ var InstrumentSearch = ({
|
|
|
6001
6230
|
}
|
|
6002
6231
|
)
|
|
6003
6232
|
] }),
|
|
6004
|
-
/* @__PURE__ */
|
|
6005
|
-
|
|
6233
|
+
/* @__PURE__ */ jsx24(
|
|
6234
|
+
TableNext2,
|
|
6006
6235
|
{
|
|
6007
6236
|
rowHeight: 25,
|
|
6008
6237
|
config: defaultTableConfig,
|
|
6009
6238
|
renderBufferSize: 100,
|
|
6010
|
-
...
|
|
6011
|
-
className: `${
|
|
6239
|
+
...TableProps3,
|
|
6240
|
+
className: `${classBase13}-list`,
|
|
6012
6241
|
dataSource,
|
|
6013
6242
|
showColumnHeaders: false
|
|
6014
6243
|
}
|
|
6015
6244
|
)
|
|
6016
6245
|
] });
|
|
6017
6246
|
};
|
|
6018
|
-
|
|
6247
|
+
var _a;
|
|
6248
|
+
(_a = registerComponent3) == null ? void 0 : _a("InstrumentSearch", InstrumentSearch, "view");
|
|
6019
6249
|
|
|
6020
6250
|
// src/price-ticker/PriceTicker.tsx
|
|
6021
6251
|
import {
|
|
@@ -6023,10 +6253,10 @@ import {
|
|
|
6023
6253
|
isValidNumber,
|
|
6024
6254
|
numericFormatter
|
|
6025
6255
|
} from "@vuu-ui/vuu-utils";
|
|
6026
|
-
import { memo as memo2, useMemo as
|
|
6256
|
+
import { memo as memo2, useMemo as useMemo16, useRef as useRef28 } from "react";
|
|
6027
6257
|
import cx12 from "classnames";
|
|
6028
|
-
import { jsx as
|
|
6029
|
-
var
|
|
6258
|
+
import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
6259
|
+
var classBase14 = "vuuPriceTicker";
|
|
6030
6260
|
var getValueFormatter = (decimals) => numericFormatter({
|
|
6031
6261
|
type: {
|
|
6032
6262
|
name: "number",
|
|
@@ -6045,30 +6275,30 @@ var PriceTicker = memo2(
|
|
|
6045
6275
|
showArrow,
|
|
6046
6276
|
...htmlAttributes
|
|
6047
6277
|
}) => {
|
|
6048
|
-
const ref =
|
|
6278
|
+
const ref = useRef28(INITIAL_VALUE);
|
|
6049
6279
|
const [prevValue, prevDirection] = ref.current;
|
|
6050
|
-
const formatNumber =
|
|
6280
|
+
const formatNumber = useMemo16(() => getValueFormatter(decimals), [decimals]);
|
|
6051
6281
|
const direction = isValidNumber(prevValue) ? getMovingValueDirection(price, prevDirection, prevValue, decimals) : "";
|
|
6052
6282
|
ref.current = [price, direction];
|
|
6053
|
-
return /* @__PURE__ */
|
|
6283
|
+
return /* @__PURE__ */ jsxs14("div", { ...htmlAttributes, className: cx12(classBase14, className, direction), children: [
|
|
6054
6284
|
formatNumber(price),
|
|
6055
|
-
showArrow ? /* @__PURE__ */
|
|
6285
|
+
showArrow ? /* @__PURE__ */ jsx25("span", { "data-icon": "price-arrow" }) : null
|
|
6056
6286
|
] });
|
|
6057
6287
|
}
|
|
6058
6288
|
);
|
|
6059
6289
|
PriceTicker.displayName = "PriceTicker";
|
|
6060
6290
|
|
|
6061
6291
|
// src/tabstrip/Tabstrip.tsx
|
|
6062
|
-
import { asReactElements, OverflowContainer, useId as
|
|
6292
|
+
import { asReactElements, OverflowContainer, useId as useId6 } from "@vuu-ui/vuu-layout";
|
|
6063
6293
|
import { Button as Button2 } from "@salt-ds/core";
|
|
6064
6294
|
import cx13 from "classnames";
|
|
6065
|
-
import
|
|
6295
|
+
import React2, { useMemo as useMemo18, useRef as useRef32 } from "react";
|
|
6066
6296
|
|
|
6067
6297
|
// src/tabstrip/useTabstrip.ts
|
|
6068
6298
|
import { dispatchMouseEvent as dispatchMouseEvent3 } from "@vuu-ui/vuu-utils";
|
|
6069
6299
|
import {
|
|
6070
|
-
useCallback as
|
|
6071
|
-
useRef as
|
|
6300
|
+
useCallback as useCallback35,
|
|
6301
|
+
useRef as useRef31
|
|
6072
6302
|
} from "react";
|
|
6073
6303
|
|
|
6074
6304
|
// src/tabstrip/TabMenuOptions.ts
|
|
@@ -6102,27 +6332,27 @@ var getIndexOfEditedItem = (container) => getIndexOfItem(container, ".vuuEditabl
|
|
|
6102
6332
|
|
|
6103
6333
|
// src/tabstrip/useAnimatedSelectionThumb.ts
|
|
6104
6334
|
import { isValidNumber as isValidNumber2, MEASURES } from "@vuu-ui/vuu-utils";
|
|
6105
|
-
import { useCallback as
|
|
6335
|
+
import { useCallback as useCallback32, useMemo as useMemo17, useRef as useRef29 } from "react";
|
|
6106
6336
|
var useAnimatedSelectionThumb = (containerRef, activeTabIndex, orientation = "horizontal") => {
|
|
6107
|
-
const animationSuspendedRef =
|
|
6108
|
-
const suspendAnimation =
|
|
6337
|
+
const animationSuspendedRef = useRef29(false);
|
|
6338
|
+
const suspendAnimation = useCallback32(() => {
|
|
6109
6339
|
animationSuspendedRef.current = true;
|
|
6110
6340
|
}, []);
|
|
6111
|
-
const resumeAnimation =
|
|
6341
|
+
const resumeAnimation = useCallback32(() => {
|
|
6112
6342
|
animationSuspendedRef.current = false;
|
|
6113
6343
|
}, []);
|
|
6114
|
-
const onTransitionEnd =
|
|
6115
|
-
var
|
|
6116
|
-
(
|
|
6344
|
+
const onTransitionEnd = useCallback32(() => {
|
|
6345
|
+
var _a2, _b;
|
|
6346
|
+
(_a2 = containerRef.current) == null ? void 0 : _a2.style.setProperty("--tab-thumb-transition", "none");
|
|
6117
6347
|
(_b = containerRef.current) == null ? void 0 : _b.removeEventListener("transitionend", onTransitionEnd);
|
|
6118
6348
|
}, [containerRef]);
|
|
6119
|
-
const lastSelectedRef =
|
|
6120
|
-
return
|
|
6121
|
-
var
|
|
6349
|
+
const lastSelectedRef = useRef29(-1);
|
|
6350
|
+
return useMemo17(() => {
|
|
6351
|
+
var _a2, _b;
|
|
6122
6352
|
let offset = 0;
|
|
6123
6353
|
let size = 0;
|
|
6124
6354
|
if (lastSelectedRef.current !== -1) {
|
|
6125
|
-
const oldSelected = (
|
|
6355
|
+
const oldSelected = (_a2 = containerRef.current) == null ? void 0 : _a2.querySelector(".vuuTab-selected");
|
|
6126
6356
|
const newSelected = (_b = containerRef.current) == null ? void 0 : _b.querySelector(
|
|
6127
6357
|
`[data-index="${activeTabIndex}"] .vuuTab`
|
|
6128
6358
|
);
|
|
@@ -6137,8 +6367,8 @@ var useAnimatedSelectionThumb = (containerRef, activeTabIndex, orientation = "ho
|
|
|
6137
6367
|
const speed = orientation === "horizontal" ? 1100 : 700;
|
|
6138
6368
|
const duration = Math.abs(offset / speed);
|
|
6139
6369
|
requestAnimationFrame(() => {
|
|
6140
|
-
var
|
|
6141
|
-
(
|
|
6370
|
+
var _a3, _b2, _c, _d;
|
|
6371
|
+
(_a3 = containerRef.current) == null ? void 0 : _a3.style.setProperty(
|
|
6142
6372
|
"--tab-thumb-offset",
|
|
6143
6373
|
"0px"
|
|
6144
6374
|
);
|
|
@@ -6192,9 +6422,9 @@ import {
|
|
|
6192
6422
|
getFocusableElement
|
|
6193
6423
|
} from "@vuu-ui/vuu-utils";
|
|
6194
6424
|
import {
|
|
6195
|
-
useCallback as
|
|
6196
|
-
useRef as
|
|
6197
|
-
useState as
|
|
6425
|
+
useCallback as useCallback33,
|
|
6426
|
+
useRef as useRef30,
|
|
6427
|
+
useState as useState15
|
|
6198
6428
|
} from "react";
|
|
6199
6429
|
import {
|
|
6200
6430
|
ArrowDown as ArrowDown2,
|
|
@@ -6252,23 +6482,23 @@ var useKeyboardNavigation2 = ({
|
|
|
6252
6482
|
selectedIndex: selectedTabIndex = 0
|
|
6253
6483
|
}) => {
|
|
6254
6484
|
const manualActivation = keyBoardActivation === "manual";
|
|
6255
|
-
const mouseClickPending =
|
|
6256
|
-
const focusedRef =
|
|
6257
|
-
const [hasFocus, setHasFocus] =
|
|
6258
|
-
const [, forceRefresh] =
|
|
6485
|
+
const mouseClickPending = useRef30(false);
|
|
6486
|
+
const focusedRef = useRef30(-1);
|
|
6487
|
+
const [hasFocus, setHasFocus] = useState15(false);
|
|
6488
|
+
const [, forceRefresh] = useState15({});
|
|
6259
6489
|
const [highlightedIdx, _setHighlightedIdx] = useControlled7({
|
|
6260
6490
|
controlled: highlightedIdxProp,
|
|
6261
6491
|
default: defaultHighlightedIdx,
|
|
6262
6492
|
name: "UseKeyboardNavigation"
|
|
6263
6493
|
});
|
|
6264
|
-
const setHighlightedIdx =
|
|
6494
|
+
const setHighlightedIdx = useCallback33(
|
|
6265
6495
|
(value) => {
|
|
6266
6496
|
_setHighlightedIdx(focusedRef.current = value);
|
|
6267
6497
|
},
|
|
6268
6498
|
[_setHighlightedIdx]
|
|
6269
6499
|
);
|
|
6270
|
-
const keyboardNavigation =
|
|
6271
|
-
const focusTab =
|
|
6500
|
+
const keyboardNavigation = useRef30(false);
|
|
6501
|
+
const focusTab = useCallback33(
|
|
6272
6502
|
(tabIndex, immediateFocus = false, withKeyboard, delay = 70) => {
|
|
6273
6503
|
setHighlightedIdx(tabIndex);
|
|
6274
6504
|
if (withKeyboard === true && !keyboardNavigation.current) {
|
|
@@ -6308,14 +6538,14 @@ var useKeyboardNavigation2 = ({
|
|
|
6308
6538
|
}
|
|
6309
6539
|
}
|
|
6310
6540
|
};
|
|
6311
|
-
const getIndexCount =
|
|
6541
|
+
const getIndexCount = useCallback33(
|
|
6312
6542
|
() => {
|
|
6313
|
-
var
|
|
6314
|
-
return (_b = (
|
|
6543
|
+
var _a2, _b;
|
|
6544
|
+
return (_b = (_a2 = containerRef.current) == null ? void 0 : _a2.querySelectorAll(`[data-index]`).length) != null ? _b : 0;
|
|
6315
6545
|
},
|
|
6316
6546
|
[containerRef]
|
|
6317
6547
|
);
|
|
6318
|
-
const nextFocusableItemIdx =
|
|
6548
|
+
const nextFocusableItemIdx = useCallback33(
|
|
6319
6549
|
(direction = "fwd", idx) => {
|
|
6320
6550
|
const indexCount = getIndexCount();
|
|
6321
6551
|
const index = typeof idx === "number" ? idx : indexCount;
|
|
@@ -6335,7 +6565,7 @@ var useKeyboardNavigation2 = ({
|
|
|
6335
6565
|
},
|
|
6336
6566
|
[containerRef, getIndexCount]
|
|
6337
6567
|
);
|
|
6338
|
-
const navigateChildItems =
|
|
6568
|
+
const navigateChildItems = useCallback33(
|
|
6339
6569
|
(e, forceFocusVisible = false) => {
|
|
6340
6570
|
const direction = navigation[orientation][e.key];
|
|
6341
6571
|
const nextIdx = nextFocusableItemIdx(direction, highlightedIdx);
|
|
@@ -6357,14 +6587,14 @@ var useKeyboardNavigation2 = ({
|
|
|
6357
6587
|
orientation
|
|
6358
6588
|
]
|
|
6359
6589
|
);
|
|
6360
|
-
const highlightedTabHasMenu =
|
|
6590
|
+
const highlightedTabHasMenu = useCallback33(() => {
|
|
6361
6591
|
const el = getElementByPosition(containerRef.current, highlightedIdx);
|
|
6362
6592
|
if (el) {
|
|
6363
6593
|
return el.querySelector(".vuuPopupMenu") != null;
|
|
6364
6594
|
}
|
|
6365
6595
|
return false;
|
|
6366
6596
|
}, [containerRef, highlightedIdx]);
|
|
6367
|
-
const activateTabMenu =
|
|
6597
|
+
const activateTabMenu = useCallback33(() => {
|
|
6368
6598
|
const el = getElementByPosition(containerRef.current, highlightedIdx);
|
|
6369
6599
|
const menuEl = el == null ? void 0 : el.querySelector(".vuuPopupMenu");
|
|
6370
6600
|
if (menuEl) {
|
|
@@ -6372,7 +6602,7 @@ var useKeyboardNavigation2 = ({
|
|
|
6372
6602
|
}
|
|
6373
6603
|
return false;
|
|
6374
6604
|
}, [containerRef, highlightedIdx]);
|
|
6375
|
-
const handleKeyDown =
|
|
6605
|
+
const handleKeyDown = useCallback33(
|
|
6376
6606
|
(e) => {
|
|
6377
6607
|
if (getIndexCount() > 0 && isNavigationKey2(e.key, orientation)) {
|
|
6378
6608
|
e.preventDefault();
|
|
@@ -6397,7 +6627,7 @@ var useKeyboardNavigation2 = ({
|
|
|
6397
6627
|
const handleItemClick = (_, tabIndex) => {
|
|
6398
6628
|
setHighlightedIdx(tabIndex);
|
|
6399
6629
|
};
|
|
6400
|
-
const handleFocus =
|
|
6630
|
+
const handleFocus = useCallback33(() => {
|
|
6401
6631
|
if (!hasFocus) {
|
|
6402
6632
|
setHasFocus(true);
|
|
6403
6633
|
if (!mouseClickPending.current) {
|
|
@@ -6407,7 +6637,7 @@ var useKeyboardNavigation2 = ({
|
|
|
6407
6637
|
}
|
|
6408
6638
|
}
|
|
6409
6639
|
}, [hasFocus]);
|
|
6410
|
-
const handleContainerMouseDown =
|
|
6640
|
+
const handleContainerMouseDown = useCallback33(() => {
|
|
6411
6641
|
if (!hasFocus) {
|
|
6412
6642
|
mouseClickPending.current = true;
|
|
6413
6643
|
}
|
|
@@ -6445,7 +6675,7 @@ var useKeyboardNavigation2 = ({
|
|
|
6445
6675
|
|
|
6446
6676
|
// src/tabstrip/useSelection.ts
|
|
6447
6677
|
import { useControlled as useControlled8 } from "@salt-ds/core";
|
|
6448
|
-
import { useCallback as
|
|
6678
|
+
import { useCallback as useCallback34 } from "react";
|
|
6449
6679
|
var defaultSelectionKeys2 = ["Enter", " "];
|
|
6450
6680
|
var isTabElement = (el) => el && el.matches('[class*="vuuTab "]');
|
|
6451
6681
|
var useSelection2 = ({
|
|
@@ -6460,18 +6690,18 @@ var useSelection2 = ({
|
|
|
6460
6690
|
name: "Tabstrip",
|
|
6461
6691
|
state: "value"
|
|
6462
6692
|
});
|
|
6463
|
-
const isSelectionEvent =
|
|
6693
|
+
const isSelectionEvent = useCallback34(
|
|
6464
6694
|
(evt) => defaultSelectionKeys2.includes(evt.key),
|
|
6465
6695
|
[]
|
|
6466
6696
|
);
|
|
6467
|
-
const selectItem =
|
|
6697
|
+
const selectItem = useCallback34(
|
|
6468
6698
|
(tabIndex) => {
|
|
6469
6699
|
setSelected(tabIndex);
|
|
6470
6700
|
onSelectionChange == null ? void 0 : onSelectionChange(tabIndex);
|
|
6471
6701
|
},
|
|
6472
6702
|
[onSelectionChange, setSelected]
|
|
6473
6703
|
);
|
|
6474
|
-
const handleKeyDown =
|
|
6704
|
+
const handleKeyDown = useCallback34(
|
|
6475
6705
|
(e) => {
|
|
6476
6706
|
const targetElement = e.target;
|
|
6477
6707
|
if (isSelectionEvent(e) && highlightedIdx !== selected && isTabElement(targetElement)) {
|
|
@@ -6482,7 +6712,7 @@ var useSelection2 = ({
|
|
|
6482
6712
|
},
|
|
6483
6713
|
[isSelectionEvent, highlightedIdx, selected, selectItem]
|
|
6484
6714
|
);
|
|
6485
|
-
const onClick =
|
|
6715
|
+
const onClick = useCallback34(
|
|
6486
6716
|
(e, tabIndex) => {
|
|
6487
6717
|
if (tabIndex !== selected) {
|
|
6488
6718
|
selectItem(tabIndex);
|
|
@@ -6522,7 +6752,7 @@ var useTabstrip = ({
|
|
|
6522
6752
|
orientation,
|
|
6523
6753
|
keyBoardActivation
|
|
6524
6754
|
}) => {
|
|
6525
|
-
const lastSelection =
|
|
6755
|
+
const lastSelection = useRef31(activeTabIndexProp);
|
|
6526
6756
|
const {
|
|
6527
6757
|
focusTab: keyboardHookFocusTab,
|
|
6528
6758
|
highlightedIdx,
|
|
@@ -6552,7 +6782,7 @@ var useTabstrip = ({
|
|
|
6552
6782
|
animateSelectionThumb ? selectionHookSelected : -1,
|
|
6553
6783
|
orientation
|
|
6554
6784
|
);
|
|
6555
|
-
const handleDrop =
|
|
6785
|
+
const handleDrop = useCallback35(
|
|
6556
6786
|
(fromIndex, toIndex) => {
|
|
6557
6787
|
const { current: selected } = lastSelection;
|
|
6558
6788
|
console.log(
|
|
@@ -6594,7 +6824,7 @@ var useTabstrip = ({
|
|
|
6594
6824
|
orientation: "horizontal",
|
|
6595
6825
|
itemQuery: ".vuuOverflowContainer-item"
|
|
6596
6826
|
});
|
|
6597
|
-
const handleExitEditMode =
|
|
6827
|
+
const handleExitEditMode = useCallback35(
|
|
6598
6828
|
(originalValue, editedValue, allowDeactivation, tabIndex) => {
|
|
6599
6829
|
console.log(
|
|
6600
6830
|
`handleExitEditMode ${originalValue} ${editedValue} ${allowDeactivation} ${tabIndex}`
|
|
@@ -6606,7 +6836,7 @@ var useTabstrip = ({
|
|
|
6606
6836
|
},
|
|
6607
6837
|
[keyboardHookFocusTab, onExitEditMode]
|
|
6608
6838
|
);
|
|
6609
|
-
const handleClick =
|
|
6839
|
+
const handleClick = useCallback35(
|
|
6610
6840
|
(evt, tabIndex) => {
|
|
6611
6841
|
keyboardHookHandleClick(evt, tabIndex);
|
|
6612
6842
|
selectionHookHandleClick(evt, tabIndex);
|
|
@@ -6614,7 +6844,7 @@ var useTabstrip = ({
|
|
|
6614
6844
|
// [dragDropHook.isDragging, keyboardHook, selectionHook]
|
|
6615
6845
|
[keyboardHookHandleClick, selectionHookHandleClick]
|
|
6616
6846
|
);
|
|
6617
|
-
const getEditableLabel =
|
|
6847
|
+
const getEditableLabel = useCallback35(
|
|
6618
6848
|
(tabIndex = highlightedIdx) => {
|
|
6619
6849
|
const targetEl = getElementWithIndex(containerRef.current, tabIndex);
|
|
6620
6850
|
if (targetEl) {
|
|
@@ -6623,7 +6853,7 @@ var useTabstrip = ({
|
|
|
6623
6853
|
},
|
|
6624
6854
|
[containerRef, highlightedIdx]
|
|
6625
6855
|
);
|
|
6626
|
-
const tabInEditMode =
|
|
6856
|
+
const tabInEditMode = useCallback35(
|
|
6627
6857
|
(tabIndex = highlightedIdx) => {
|
|
6628
6858
|
const editableLabel = getEditableLabel(tabIndex);
|
|
6629
6859
|
if (editableLabel) {
|
|
@@ -6633,7 +6863,7 @@ var useTabstrip = ({
|
|
|
6633
6863
|
},
|
|
6634
6864
|
[getEditableLabel, highlightedIdx]
|
|
6635
6865
|
);
|
|
6636
|
-
const editTab =
|
|
6866
|
+
const editTab = useCallback35(
|
|
6637
6867
|
(tabIndex = highlightedIdx) => {
|
|
6638
6868
|
const editableLabelEl = getEditableLabel(tabIndex);
|
|
6639
6869
|
if (editableLabelEl) {
|
|
@@ -6642,7 +6872,7 @@ var useTabstrip = ({
|
|
|
6642
6872
|
},
|
|
6643
6873
|
[getEditableLabel, highlightedIdx]
|
|
6644
6874
|
);
|
|
6645
|
-
const handleKeyDown =
|
|
6875
|
+
const handleKeyDown = useCallback35(
|
|
6646
6876
|
(evt) => {
|
|
6647
6877
|
keyboardHookHandleKeyDown(evt);
|
|
6648
6878
|
if (!evt.defaultPrevented) {
|
|
@@ -6654,7 +6884,7 @@ var useTabstrip = ({
|
|
|
6654
6884
|
},
|
|
6655
6885
|
[editTab, keyboardHookHandleKeyDown, selectionHookHandleKeyDown]
|
|
6656
6886
|
);
|
|
6657
|
-
const handleCloseTabFromMenu =
|
|
6887
|
+
const handleCloseTabFromMenu = useCallback35(
|
|
6658
6888
|
(tabIndex) => {
|
|
6659
6889
|
const selectedTabIndex = getIndexOfSelectedTab(containerRef.current);
|
|
6660
6890
|
const newActiveTabIndex = selectedTabIndex > tabIndex ? selectedTabIndex - 1 : selectedTabIndex === tabIndex ? 0 : selectedTabIndex;
|
|
@@ -6667,14 +6897,14 @@ var useTabstrip = ({
|
|
|
6667
6897
|
},
|
|
6668
6898
|
[containerRef, onCloseTab, resumeAnimation, suspendAnimation]
|
|
6669
6899
|
);
|
|
6670
|
-
const handleRenameTabFromMenu =
|
|
6900
|
+
const handleRenameTabFromMenu = useCallback35(
|
|
6671
6901
|
(tabIndex) => {
|
|
6672
6902
|
editTab(tabIndex);
|
|
6673
6903
|
return true;
|
|
6674
6904
|
},
|
|
6675
6905
|
[editTab]
|
|
6676
6906
|
);
|
|
6677
|
-
const handleTabMenuAction =
|
|
6907
|
+
const handleTabMenuAction = useCallback35(
|
|
6678
6908
|
(action) => {
|
|
6679
6909
|
if (isTabMenuOptions(action.options)) {
|
|
6680
6910
|
switch (action.menuId) {
|
|
@@ -6690,7 +6920,7 @@ var useTabstrip = ({
|
|
|
6690
6920
|
},
|
|
6691
6921
|
[handleCloseTabFromMenu, handleRenameTabFromMenu]
|
|
6692
6922
|
);
|
|
6693
|
-
const handleTabMenuClose =
|
|
6923
|
+
const handleTabMenuClose = useCallback35(() => {
|
|
6694
6924
|
if (!tabInEditMode()) {
|
|
6695
6925
|
keyboardHookFocusTab(highlightedIdx);
|
|
6696
6926
|
} else {
|
|
@@ -6702,7 +6932,7 @@ var useTabstrip = ({
|
|
|
6702
6932
|
keyboardHookSetHighlightedIndex,
|
|
6703
6933
|
tabInEditMode
|
|
6704
6934
|
]);
|
|
6705
|
-
const onSwitchWrappedItemIntoView =
|
|
6935
|
+
const onSwitchWrappedItemIntoView = useCallback35(
|
|
6706
6936
|
(item) => {
|
|
6707
6937
|
const index = parseInt(item.index);
|
|
6708
6938
|
if (!isNaN(index)) {
|
|
@@ -6715,7 +6945,7 @@ var useTabstrip = ({
|
|
|
6715
6945
|
onFocus: keyboardHook.onFocus,
|
|
6716
6946
|
onKeyDown: handleKeyDown
|
|
6717
6947
|
};
|
|
6718
|
-
const handleAddTabClick =
|
|
6948
|
+
const handleAddTabClick = useCallback35(() => {
|
|
6719
6949
|
onAddTab == null ? void 0 : onAddTab();
|
|
6720
6950
|
requestAnimationFrame(() => {
|
|
6721
6951
|
const selectedTabIndex = getIndexOfSelectedTab(containerRef.current);
|
|
@@ -6748,9 +6978,9 @@ var useTabstrip = ({
|
|
|
6748
6978
|
};
|
|
6749
6979
|
|
|
6750
6980
|
// src/tabstrip/Tabstrip.tsx
|
|
6751
|
-
import { Fragment as Fragment3, jsx as
|
|
6981
|
+
import { Fragment as Fragment3, jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
6752
6982
|
import { createElement as createElement2 } from "react";
|
|
6753
|
-
var
|
|
6983
|
+
var classBase15 = "vuuTabstrip";
|
|
6754
6984
|
var Tabstrip = ({
|
|
6755
6985
|
activeTabIndex: activeTabIndexProp,
|
|
6756
6986
|
allowAddTab,
|
|
@@ -6773,7 +7003,7 @@ var Tabstrip = ({
|
|
|
6773
7003
|
style: styleProp,
|
|
6774
7004
|
...htmlAttributes
|
|
6775
7005
|
}) => {
|
|
6776
|
-
const rootRef =
|
|
7006
|
+
const rootRef = useRef32(null);
|
|
6777
7007
|
const {
|
|
6778
7008
|
activeTabIndex,
|
|
6779
7009
|
focusVisible,
|
|
@@ -6795,13 +7025,13 @@ var Tabstrip = ({
|
|
|
6795
7025
|
onMoveTab,
|
|
6796
7026
|
orientation
|
|
6797
7027
|
});
|
|
6798
|
-
const id =
|
|
6799
|
-
const className = cx13(
|
|
7028
|
+
const id = useId6(idProp);
|
|
7029
|
+
const className = cx13(classBase15, `${classBase15}-${orientation}`, classNameProp);
|
|
6800
7030
|
const style = styleProp || containerStyle ? {
|
|
6801
7031
|
...styleProp,
|
|
6802
7032
|
...containerStyle
|
|
6803
7033
|
} : void 0;
|
|
6804
|
-
const tabs =
|
|
7034
|
+
const tabs = useMemo18(
|
|
6805
7035
|
() => asReactElements(children).map((child, index) => {
|
|
6806
7036
|
const {
|
|
6807
7037
|
id: tabId = `${id}-tab-${index}`,
|
|
@@ -6811,7 +7041,7 @@ var Tabstrip = ({
|
|
|
6811
7041
|
showMenuButton = showTabMenuButton
|
|
6812
7042
|
} = child.props;
|
|
6813
7043
|
const selected = index === activeTabIndex;
|
|
6814
|
-
return
|
|
7044
|
+
return React2.cloneElement(child, {
|
|
6815
7045
|
...tabProps,
|
|
6816
7046
|
...tabstripHook.navigationProps,
|
|
6817
7047
|
closeable,
|
|
@@ -6833,7 +7063,7 @@ var Tabstrip = ({
|
|
|
6833
7063
|
{
|
|
6834
7064
|
...tabstripHook.navigationProps,
|
|
6835
7065
|
"aria-label": "Create Tab",
|
|
6836
|
-
className: `${
|
|
7066
|
+
className: `${classBase15}-addTabButton`,
|
|
6837
7067
|
"data-icon": "add",
|
|
6838
7068
|
"data-overflow-priority": "1",
|
|
6839
7069
|
key: "addButton",
|
|
@@ -6859,8 +7089,8 @@ var Tabstrip = ({
|
|
|
6859
7089
|
tabstripHook.navigationProps
|
|
6860
7090
|
]
|
|
6861
7091
|
);
|
|
6862
|
-
return /* @__PURE__ */
|
|
6863
|
-
/* @__PURE__ */
|
|
7092
|
+
return /* @__PURE__ */ jsxs15(Fragment3, { children: [
|
|
7093
|
+
/* @__PURE__ */ jsx26(
|
|
6864
7094
|
OverflowContainer,
|
|
6865
7095
|
{
|
|
6866
7096
|
...htmlAttributes,
|
|
@@ -6883,17 +7113,17 @@ var Tabstrip = ({
|
|
|
6883
7113
|
import { useForkRef as useForkRef7 } from "@salt-ds/core";
|
|
6884
7114
|
import cx15 from "classnames";
|
|
6885
7115
|
import {
|
|
6886
|
-
forwardRef as
|
|
6887
|
-
useCallback as
|
|
6888
|
-
useRef as
|
|
7116
|
+
forwardRef as forwardRef12,
|
|
7117
|
+
useCallback as useCallback36,
|
|
7118
|
+
useRef as useRef33
|
|
6889
7119
|
} from "react";
|
|
6890
7120
|
|
|
6891
7121
|
// src/tabstrip/TabMenu.tsx
|
|
6892
7122
|
import { PopupMenu } from "@vuu-ui/vuu-popups";
|
|
6893
|
-
import { useMemo as
|
|
7123
|
+
import { useMemo as useMemo19 } from "react";
|
|
6894
7124
|
import cx14 from "classnames";
|
|
6895
|
-
import { jsx as
|
|
6896
|
-
var
|
|
7125
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
7126
|
+
var classBase16 = "vuuTabMenu";
|
|
6897
7127
|
var TabMenu = ({
|
|
6898
7128
|
allowClose,
|
|
6899
7129
|
allowRename,
|
|
@@ -6903,7 +7133,7 @@ var TabMenu = ({
|
|
|
6903
7133
|
onMenuClose,
|
|
6904
7134
|
index
|
|
6905
7135
|
}) => {
|
|
6906
|
-
const [menuBuilder, menuOptions] =
|
|
7136
|
+
const [menuBuilder, menuOptions] = useMemo19(
|
|
6907
7137
|
() => [
|
|
6908
7138
|
(_location, options) => {
|
|
6909
7139
|
const menuItems = [];
|
|
@@ -6922,10 +7152,10 @@ var TabMenu = ({
|
|
|
6922
7152
|
],
|
|
6923
7153
|
[allowClose, allowRename, controlledComponentId, index]
|
|
6924
7154
|
);
|
|
6925
|
-
return /* @__PURE__ */
|
|
7155
|
+
return /* @__PURE__ */ jsx27(
|
|
6926
7156
|
PopupMenu,
|
|
6927
7157
|
{
|
|
6928
|
-
className:
|
|
7158
|
+
className: classBase16,
|
|
6929
7159
|
menuBuilder,
|
|
6930
7160
|
menuActionHandler: onMenuAction,
|
|
6931
7161
|
menuLocation: cx14("tab", location),
|
|
@@ -6937,10 +7167,10 @@ var TabMenu = ({
|
|
|
6937
7167
|
};
|
|
6938
7168
|
|
|
6939
7169
|
// src/tabstrip/Tab.tsx
|
|
6940
|
-
import { jsx as
|
|
6941
|
-
var
|
|
7170
|
+
import { jsx as jsx28, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
7171
|
+
var classBase17 = "vuuTab";
|
|
6942
7172
|
var noop = () => void 0;
|
|
6943
|
-
var Tab =
|
|
7173
|
+
var Tab = forwardRef12(function Tab2({
|
|
6944
7174
|
ariaControls,
|
|
6945
7175
|
children,
|
|
6946
7176
|
className,
|
|
@@ -6969,10 +7199,10 @@ var Tab = forwardRef11(function Tab2({
|
|
|
6969
7199
|
if (showMenuButton && typeof onMenuAction !== "function") {
|
|
6970
7200
|
throw Error("Tab onMenuAction must be provided if showMenuButton is set");
|
|
6971
7201
|
}
|
|
6972
|
-
const rootRef =
|
|
6973
|
-
const editableRef =
|
|
7202
|
+
const rootRef = useRef33(null);
|
|
7203
|
+
const editableRef = useRef33(null);
|
|
6974
7204
|
const setForkRef = useForkRef7(ref, rootRef);
|
|
6975
|
-
const handleClick =
|
|
7205
|
+
const handleClick = useCallback36(
|
|
6976
7206
|
(e) => {
|
|
6977
7207
|
if (!editing) {
|
|
6978
7208
|
e.preventDefault();
|
|
@@ -6997,7 +7227,7 @@ var Tab = forwardRef11(function Tab2({
|
|
|
6997
7227
|
};
|
|
6998
7228
|
const getLabel = () => {
|
|
6999
7229
|
if (editable) {
|
|
7000
|
-
return /* @__PURE__ */
|
|
7230
|
+
return /* @__PURE__ */ jsx28(
|
|
7001
7231
|
EditableLabel,
|
|
7002
7232
|
{
|
|
7003
7233
|
editing,
|
|
@@ -7022,18 +7252,18 @@ var Tab = forwardRef11(function Tab2({
|
|
|
7022
7252
|
}
|
|
7023
7253
|
onFocusProp == null ? void 0 : onFocusProp(evt);
|
|
7024
7254
|
};
|
|
7025
|
-
return /* @__PURE__ */
|
|
7255
|
+
return /* @__PURE__ */ jsxs16(
|
|
7026
7256
|
"div",
|
|
7027
7257
|
{
|
|
7028
7258
|
...props,
|
|
7029
7259
|
"aria-controls": ariaControls,
|
|
7030
7260
|
"aria-selected": selected,
|
|
7031
|
-
className: cx15(
|
|
7032
|
-
[`${
|
|
7261
|
+
className: cx15(classBase17, {
|
|
7262
|
+
[`${classBase17}-closeable`]: closeable,
|
|
7033
7263
|
"vuuDraggable-dragAway": dragging,
|
|
7034
|
-
[`${
|
|
7035
|
-
[`${
|
|
7036
|
-
[`${
|
|
7264
|
+
[`${classBase17}-editing`]: editing,
|
|
7265
|
+
[`${classBase17}-selected`]: selected || void 0,
|
|
7266
|
+
[`${classBase17}-vertical`]: orientation === "vertical",
|
|
7037
7267
|
[`vuuFocusVisible`]: focusVisible
|
|
7038
7268
|
}),
|
|
7039
7269
|
onClick: handleClick,
|
|
@@ -7043,15 +7273,15 @@ var Tab = forwardRef11(function Tab2({
|
|
|
7043
7273
|
role: "tab",
|
|
7044
7274
|
tabIndex,
|
|
7045
7275
|
children: [
|
|
7046
|
-
/* @__PURE__ */
|
|
7276
|
+
/* @__PURE__ */ jsx28("div", { className: `${classBase17}-main`, children: /* @__PURE__ */ jsx28(
|
|
7047
7277
|
"span",
|
|
7048
7278
|
{
|
|
7049
|
-
className: `${
|
|
7279
|
+
className: `${classBase17}-text`,
|
|
7050
7280
|
"data-text": editable ? void 0 : label,
|
|
7051
7281
|
children: children != null ? children : getLabel()
|
|
7052
7282
|
}
|
|
7053
7283
|
) }),
|
|
7054
|
-
showMenuButton ? /* @__PURE__ */
|
|
7284
|
+
showMenuButton ? /* @__PURE__ */ jsx28(
|
|
7055
7285
|
TabMenu,
|
|
7056
7286
|
{
|
|
7057
7287
|
allowClose: closeable,
|
|
@@ -7069,21 +7299,21 @@ var Tab = forwardRef11(function Tab2({
|
|
|
7069
7299
|
});
|
|
7070
7300
|
|
|
7071
7301
|
// src/tree/Tree.tsx
|
|
7072
|
-
import { useForkRef as useForkRef8, useIdMemo as
|
|
7302
|
+
import { useForkRef as useForkRef8, useIdMemo as useId7 } from "@salt-ds/core";
|
|
7073
7303
|
import cx16 from "classnames";
|
|
7074
7304
|
import {
|
|
7075
|
-
forwardRef as
|
|
7076
|
-
useRef as
|
|
7305
|
+
forwardRef as forwardRef13,
|
|
7306
|
+
useRef as useRef40
|
|
7077
7307
|
} from "react";
|
|
7078
7308
|
|
|
7079
7309
|
// src/tree/list-dom-utils.ts
|
|
7080
7310
|
function listItemIndex2(listItemEl) {
|
|
7081
|
-
var
|
|
7311
|
+
var _a2;
|
|
7082
7312
|
if (listItemEl) {
|
|
7083
7313
|
let idx = listItemEl.dataset.idx;
|
|
7084
7314
|
if (idx) {
|
|
7085
7315
|
return parseInt(idx, 10);
|
|
7086
|
-
} else if (idx = (
|
|
7316
|
+
} else if (idx = (_a2 = listItemEl.ariaPosInSet) != null ? _a2 : "-1") {
|
|
7087
7317
|
return parseInt(idx, 10) - 1;
|
|
7088
7318
|
}
|
|
7089
7319
|
}
|
|
@@ -7092,7 +7322,7 @@ var closestListItem2 = (el) => el.closest("[data-idx],[aria-posinset]");
|
|
|
7092
7322
|
var closestListItemIndex2 = (el) => listItemIndex2(closestListItem2(el));
|
|
7093
7323
|
|
|
7094
7324
|
// src/tree/use-items-with-ids.ts
|
|
7095
|
-
import { useCallback as
|
|
7325
|
+
import { useCallback as useCallback37, useMemo as useMemo20 } from "react";
|
|
7096
7326
|
var PathSeparators2 = /* @__PURE__ */ new Set(["/", "-", "."]);
|
|
7097
7327
|
var isPathSeparator2 = (char) => PathSeparators2.has(char);
|
|
7098
7328
|
var isParentPath2 = (parentPath, childPath) => childPath.startsWith(parentPath) && isPathSeparator2(childPath[parentPath.length]);
|
|
@@ -7116,7 +7346,7 @@ var useItemsWithIds = (sourceProp, idRoot = "root", {
|
|
|
7116
7346
|
return 0;
|
|
7117
7347
|
}
|
|
7118
7348
|
};
|
|
7119
|
-
const isExpanded2 =
|
|
7349
|
+
const isExpanded2 = useCallback37(
|
|
7120
7350
|
(path) => {
|
|
7121
7351
|
if (Array.isArray(revealSelected)) {
|
|
7122
7352
|
return revealSelected.some((id) => isParentPath2(path, id));
|
|
@@ -7125,17 +7355,17 @@ var useItemsWithIds = (sourceProp, idRoot = "root", {
|
|
|
7125
7355
|
},
|
|
7126
7356
|
[defaultExpanded, revealSelected]
|
|
7127
7357
|
);
|
|
7128
|
-
const normalizeItems =
|
|
7358
|
+
const normalizeItems = useCallback37(
|
|
7129
7359
|
(items, indexer, level = 1, path = "", results = [], flattenedSource2 = []) => {
|
|
7130
7360
|
let count2 = 0;
|
|
7131
7361
|
items.forEach((item, i, all) => {
|
|
7132
|
-
var
|
|
7362
|
+
var _a2;
|
|
7133
7363
|
const isCollapsibleHeader = item.header && collapsibleHeaders;
|
|
7134
7364
|
const isNonCollapsibleGroupNode = item.childNodes && collapsibleHeaders === false;
|
|
7135
7365
|
const isLeaf3 = !item.childNodes || item.childNodes.length === 0;
|
|
7136
7366
|
const nonCollapsible = isNonCollapsibleGroupNode || isLeaf3 && !isCollapsibleHeader;
|
|
7137
7367
|
const childPath = path ? `${path}.${i}` : `${i}`;
|
|
7138
|
-
const id = (
|
|
7368
|
+
const id = (_a2 = item.id) != null ? _a2 : `${idRoot}-${childPath}`;
|
|
7139
7369
|
const expanded = nonCollapsible ? void 0 : isExpanded2(id);
|
|
7140
7370
|
const normalisedItem = {
|
|
7141
7371
|
...item,
|
|
@@ -7169,15 +7399,15 @@ var useItemsWithIds = (sourceProp, idRoot = "root", {
|
|
|
7169
7399
|
},
|
|
7170
7400
|
[collapsibleHeaders, idRoot, isExpanded2]
|
|
7171
7401
|
);
|
|
7172
|
-
const [count, sourceWithIds, flattenedSource] =
|
|
7402
|
+
const [count, sourceWithIds, flattenedSource] = useMemo20(() => {
|
|
7173
7403
|
return normalizeItems(sourceProp, { index: 0 });
|
|
7174
7404
|
}, [normalizeItems, sourceProp]);
|
|
7175
|
-
const sourceItemById =
|
|
7405
|
+
const sourceItemById = useCallback37(
|
|
7176
7406
|
(id, target = sourceWithIds) => {
|
|
7177
7407
|
const sourceWithId = target.find(
|
|
7178
7408
|
(i) => {
|
|
7179
|
-
var
|
|
7180
|
-
return i.id === id || ((
|
|
7409
|
+
var _a2;
|
|
7410
|
+
return i.id === id || ((_a2 = i == null ? void 0 : i.childNodes) == null ? void 0 : _a2.length) && isParentPath2(i.id, id);
|
|
7181
7411
|
}
|
|
7182
7412
|
);
|
|
7183
7413
|
if ((sourceWithId == null ? void 0 : sourceWithId.id) === id) {
|
|
@@ -7193,8 +7423,8 @@ var useItemsWithIds = (sourceProp, idRoot = "root", {
|
|
|
7193
7423
|
|
|
7194
7424
|
// src/tree/use-selection.ts
|
|
7195
7425
|
import {
|
|
7196
|
-
useCallback as
|
|
7197
|
-
useRef as
|
|
7426
|
+
useCallback as useCallback38,
|
|
7427
|
+
useRef as useRef34
|
|
7198
7428
|
} from "react";
|
|
7199
7429
|
import { useControlled as useControlled9 } from "@salt-ds/core";
|
|
7200
7430
|
var SINGLE = "single";
|
|
@@ -7217,8 +7447,8 @@ var useSelection3 = ({
|
|
|
7217
7447
|
const singleSelect = selection === SINGLE;
|
|
7218
7448
|
const multiSelect = selection === MULTI || selection.startsWith(CHECKBOX2);
|
|
7219
7449
|
const extendedSelect = selection === EXTENDED;
|
|
7220
|
-
const lastActive =
|
|
7221
|
-
const isSelectionEvent =
|
|
7450
|
+
const lastActive = useRef34(-1);
|
|
7451
|
+
const isSelectionEvent = useCallback38(
|
|
7222
7452
|
(evt) => selectionKeys.includes(evt.key),
|
|
7223
7453
|
[selectionKeys]
|
|
7224
7454
|
);
|
|
@@ -7227,7 +7457,7 @@ var useSelection3 = ({
|
|
|
7227
7457
|
default: defaultSelected != null ? defaultSelected : [],
|
|
7228
7458
|
name: "selected"
|
|
7229
7459
|
});
|
|
7230
|
-
const selectItemAtIndex =
|
|
7460
|
+
const selectItemAtIndex = useCallback38(
|
|
7231
7461
|
(evt, idx, id, rangeSelect, preserveExistingSelection = false) => {
|
|
7232
7462
|
const { current: active } = lastActive;
|
|
7233
7463
|
const isSelected2 = selected == null ? void 0 : selected.includes(id);
|
|
@@ -7268,7 +7498,7 @@ var useSelection3 = ({
|
|
|
7268
7498
|
singleSelect
|
|
7269
7499
|
]
|
|
7270
7500
|
);
|
|
7271
|
-
const handleKeyDown =
|
|
7501
|
+
const handleKeyDown = useCallback38(
|
|
7272
7502
|
(evt) => {
|
|
7273
7503
|
if (~highlightedIdx && isSelectionEvent(evt)) {
|
|
7274
7504
|
evt.preventDefault();
|
|
@@ -7293,7 +7523,7 @@ var useSelection3 = ({
|
|
|
7293
7523
|
selectItemAtIndex
|
|
7294
7524
|
]
|
|
7295
7525
|
);
|
|
7296
|
-
const handleKeyboardNavigation =
|
|
7526
|
+
const handleKeyboardNavigation = useCallback38(
|
|
7297
7527
|
(evt, currentIndex) => {
|
|
7298
7528
|
if (extendedSelect && evt.shiftKey) {
|
|
7299
7529
|
const item = treeNodes[currentIndex];
|
|
@@ -7306,7 +7536,7 @@ var useSelection3 = ({
|
|
|
7306
7536
|
onKeyDown: handleKeyDown,
|
|
7307
7537
|
onKeyboardNavigation: handleKeyboardNavigation
|
|
7308
7538
|
};
|
|
7309
|
-
const handleClick =
|
|
7539
|
+
const handleClick = useCallback38(
|
|
7310
7540
|
(evt) => {
|
|
7311
7541
|
if (highlightedIdx !== -1) {
|
|
7312
7542
|
const item = treeNodes[highlightedIdx];
|
|
@@ -7341,18 +7571,18 @@ var useSelection3 = ({
|
|
|
7341
7571
|
|
|
7342
7572
|
// src/tree/use-viewport-tracking.ts
|
|
7343
7573
|
import {
|
|
7344
|
-
useCallback as
|
|
7345
|
-
useEffect as
|
|
7574
|
+
useCallback as useCallback39,
|
|
7575
|
+
useEffect as useEffect7,
|
|
7346
7576
|
useLayoutEffect as useLayoutEffect4,
|
|
7347
|
-
useRef as
|
|
7577
|
+
useRef as useRef35
|
|
7348
7578
|
} from "react";
|
|
7349
7579
|
var HeightOnly3 = ["height", "scrollHeight"];
|
|
7350
7580
|
var useViewportTracking2 = (root, highlightedIdx, stickyHeaders = false) => {
|
|
7351
|
-
const scrollTop =
|
|
7352
|
-
const scrolling =
|
|
7353
|
-
const rootHeight =
|
|
7354
|
-
const rootScrollHeight =
|
|
7355
|
-
const scrollIntoView =
|
|
7581
|
+
const scrollTop = useRef35(0);
|
|
7582
|
+
const scrolling = useRef35(false);
|
|
7583
|
+
const rootHeight = useRef35(0);
|
|
7584
|
+
const rootScrollHeight = useRef35(0);
|
|
7585
|
+
const scrollIntoView = useCallback39(
|
|
7356
7586
|
(el) => {
|
|
7357
7587
|
const targetEl = el.ariaExpanded ? el.firstChild : el;
|
|
7358
7588
|
const headerHeight = stickyHeaders ? 30 : 0;
|
|
@@ -7373,10 +7603,10 @@ var useViewportTracking2 = (root, highlightedIdx, stickyHeaders = false) => {
|
|
|
7373
7603
|
},
|
|
7374
7604
|
[root, stickyHeaders]
|
|
7375
7605
|
);
|
|
7376
|
-
const scrollHandler =
|
|
7606
|
+
const scrollHandler = useCallback39((e) => {
|
|
7377
7607
|
scrollTop.current = e.target.scrollTop;
|
|
7378
7608
|
}, []);
|
|
7379
|
-
|
|
7609
|
+
useEffect7(() => {
|
|
7380
7610
|
const { current: rootEl } = root;
|
|
7381
7611
|
if (rootEl) {
|
|
7382
7612
|
rootEl.addEventListener("scroll", scrollHandler);
|
|
@@ -7404,9 +7634,9 @@ var useViewportTracking2 = (root, highlightedIdx, stickyHeaders = false) => {
|
|
|
7404
7634
|
}
|
|
7405
7635
|
}
|
|
7406
7636
|
}, [highlightedIdx, root, scrollIntoView]);
|
|
7407
|
-
|
|
7637
|
+
useEffect7(() => {
|
|
7408
7638
|
}, [stickyHeaders]);
|
|
7409
|
-
const onResize =
|
|
7639
|
+
const onResize = useCallback39(({ height, scrollHeight }) => {
|
|
7410
7640
|
rootHeight.current = height;
|
|
7411
7641
|
rootScrollHeight.current = scrollHeight;
|
|
7412
7642
|
}, []);
|
|
@@ -7415,10 +7645,10 @@ var useViewportTracking2 = (root, highlightedIdx, stickyHeaders = false) => {
|
|
|
7415
7645
|
};
|
|
7416
7646
|
|
|
7417
7647
|
// src/tree/useTree.ts
|
|
7418
|
-
import { useCallback as
|
|
7648
|
+
import { useCallback as useCallback43, useRef as useRef39 } from "react";
|
|
7419
7649
|
|
|
7420
7650
|
// src/tree/use-keyboard-navigation.ts
|
|
7421
|
-
import { useCallback as
|
|
7651
|
+
import { useCallback as useCallback40, useMemo as useMemo21, useRef as useRef36 } from "react";
|
|
7422
7652
|
|
|
7423
7653
|
// src/tree/hierarchical-data-utils.ts
|
|
7424
7654
|
var getNodeParentPath = ({ id }) => {
|
|
@@ -7568,7 +7798,7 @@ var useKeyboardNavigation3 = ({
|
|
|
7568
7798
|
onKeyboardNavigation,
|
|
7569
7799
|
selected = []
|
|
7570
7800
|
}) => {
|
|
7571
|
-
const { bwd: ArrowBwd, fwd: ArrowFwd } =
|
|
7801
|
+
const { bwd: ArrowBwd, fwd: ArrowFwd } = useMemo21(
|
|
7572
7802
|
() => ({
|
|
7573
7803
|
bwd: ArrowUp3,
|
|
7574
7804
|
fwd: ArrowDown3
|
|
@@ -7580,14 +7810,14 @@ var useKeyboardNavigation3 = ({
|
|
|
7580
7810
|
default: defaultHighlightedIdx,
|
|
7581
7811
|
name: "highlightedIdx"
|
|
7582
7812
|
});
|
|
7583
|
-
const setHighlightedIndex =
|
|
7813
|
+
const setHighlightedIndex = useCallback40(
|
|
7584
7814
|
(idx) => {
|
|
7585
7815
|
onHighlight == null ? void 0 : onHighlight(idx);
|
|
7586
7816
|
setHighlightedIdx(idx);
|
|
7587
7817
|
},
|
|
7588
7818
|
[onHighlight, setHighlightedIdx]
|
|
7589
7819
|
);
|
|
7590
|
-
const nextFocusableItemIdx =
|
|
7820
|
+
const nextFocusableItemIdx = useCallback40(
|
|
7591
7821
|
(key = ArrowFwd, idx = key === ArrowFwd ? -1 : treeNodes.length) => {
|
|
7592
7822
|
let nextIdx = nextItemIdx3(treeNodes.length, key, idx);
|
|
7593
7823
|
while (nextIdx !== -1 && (key === ArrowFwd && nextIdx < treeNodes.length || key === ArrowBwd && nextIdx > 0) && !isFocusable3(treeNodes[nextIdx])) {
|
|
@@ -7597,10 +7827,10 @@ var useKeyboardNavigation3 = ({
|
|
|
7597
7827
|
},
|
|
7598
7828
|
[ArrowBwd, ArrowFwd, treeNodes]
|
|
7599
7829
|
);
|
|
7600
|
-
const keyBoardNavigation =
|
|
7601
|
-
const ignoreFocus =
|
|
7830
|
+
const keyBoardNavigation = useRef36(true);
|
|
7831
|
+
const ignoreFocus = useRef36(false);
|
|
7602
7832
|
const setIgnoreFocus = (value) => ignoreFocus.current = value;
|
|
7603
|
-
const handleFocus =
|
|
7833
|
+
const handleFocus = useCallback40(() => {
|
|
7604
7834
|
if (ignoreFocus.current) {
|
|
7605
7835
|
ignoreFocus.current = false;
|
|
7606
7836
|
} else if (selected.length > 0) {
|
|
@@ -7613,7 +7843,7 @@ var useKeyboardNavigation3 = ({
|
|
|
7613
7843
|
setHighlightedIndex(nextFocusableItemIdx());
|
|
7614
7844
|
}
|
|
7615
7845
|
}, [treeNodes, nextFocusableItemIdx, selected, setHighlightedIndex]);
|
|
7616
|
-
const navigateChildItems =
|
|
7846
|
+
const navigateChildItems = useCallback40(
|
|
7617
7847
|
(e) => {
|
|
7618
7848
|
const nextIdx = nextFocusableItemIdx(e.key, highlightedIdx);
|
|
7619
7849
|
if (nextIdx !== highlightedIdx) {
|
|
@@ -7628,7 +7858,7 @@ var useKeyboardNavigation3 = ({
|
|
|
7628
7858
|
setHighlightedIndex
|
|
7629
7859
|
]
|
|
7630
7860
|
);
|
|
7631
|
-
const handleKeyDown =
|
|
7861
|
+
const handleKeyDown = useCallback40(
|
|
7632
7862
|
(e) => {
|
|
7633
7863
|
if (treeNodes.length > 0 && isNavigationKey3(e, "vertical")) {
|
|
7634
7864
|
e.preventDefault();
|
|
@@ -7639,7 +7869,7 @@ var useKeyboardNavigation3 = ({
|
|
|
7639
7869
|
},
|
|
7640
7870
|
[treeNodes, navigateChildItems]
|
|
7641
7871
|
);
|
|
7642
|
-
const listProps =
|
|
7872
|
+
const listProps = useMemo21(
|
|
7643
7873
|
() => ({
|
|
7644
7874
|
onBlur: () => {
|
|
7645
7875
|
setHighlightedIndex(-1);
|
|
@@ -7677,7 +7907,7 @@ var useKeyboardNavigation3 = ({
|
|
|
7677
7907
|
};
|
|
7678
7908
|
|
|
7679
7909
|
// src/tree/use-hierarchical-data.ts
|
|
7680
|
-
import { useRef as
|
|
7910
|
+
import { useRef as useRef37, useState as useState16 } from "react";
|
|
7681
7911
|
var populateIndices = (nodes, results = [], idx = { value: 0 }) => {
|
|
7682
7912
|
let skipToNextHeader = false;
|
|
7683
7913
|
for (const node of nodes) {
|
|
@@ -7699,10 +7929,10 @@ var populateIndices = (nodes, results = [], idx = { value: 0 }) => {
|
|
|
7699
7929
|
return results;
|
|
7700
7930
|
};
|
|
7701
7931
|
var useHierarchicalData = (source) => {
|
|
7702
|
-
const externalSource =
|
|
7703
|
-
const statefulSource =
|
|
7704
|
-
const indexPositions =
|
|
7705
|
-
const [, forceUpdate] =
|
|
7932
|
+
const externalSource = useRef37(source);
|
|
7933
|
+
const statefulSource = useRef37(source);
|
|
7934
|
+
const indexPositions = useRef37(populateIndices(source));
|
|
7935
|
+
const [, forceUpdate] = useState16({});
|
|
7706
7936
|
if (source !== externalSource.current) {
|
|
7707
7937
|
externalSource.current = source;
|
|
7708
7938
|
statefulSource.current = source;
|
|
@@ -7722,7 +7952,7 @@ var useHierarchicalData = (source) => {
|
|
|
7722
7952
|
};
|
|
7723
7953
|
|
|
7724
7954
|
// src/tree/use-collapsible-groups.ts
|
|
7725
|
-
import { useCallback as
|
|
7955
|
+
import { useCallback as useCallback41, useRef as useRef38 } from "react";
|
|
7726
7956
|
var NO_HANDLERS4 = {};
|
|
7727
7957
|
var isToggleElement = (element) => element && element.hasAttribute("aria-expanded");
|
|
7728
7958
|
var useCollapsibleGroups2 = ({
|
|
@@ -7732,23 +7962,23 @@ var useCollapsibleGroups2 = ({
|
|
|
7732
7962
|
setVisibleData,
|
|
7733
7963
|
source
|
|
7734
7964
|
}) => {
|
|
7735
|
-
const fullSource =
|
|
7736
|
-
const stateSource =
|
|
7737
|
-
const setSource =
|
|
7965
|
+
const fullSource = useRef38(source);
|
|
7966
|
+
const stateSource = useRef38(fullSource.current);
|
|
7967
|
+
const setSource = useCallback41(
|
|
7738
7968
|
(value) => {
|
|
7739
7969
|
setVisibleData(stateSource.current = value);
|
|
7740
7970
|
},
|
|
7741
7971
|
[setVisibleData]
|
|
7742
7972
|
);
|
|
7743
|
-
const expandNode =
|
|
7973
|
+
const expandNode = useCallback41(
|
|
7744
7974
|
(nodeList, { id }) => replaceNode(nodeList, id, { expanded: true }),
|
|
7745
7975
|
[]
|
|
7746
7976
|
);
|
|
7747
|
-
const collapseNode =
|
|
7977
|
+
const collapseNode = useCallback41(
|
|
7748
7978
|
(nodeList, { id }) => replaceNode(nodeList, id, { expanded: false }),
|
|
7749
7979
|
[]
|
|
7750
7980
|
);
|
|
7751
|
-
const handleKeyDown =
|
|
7981
|
+
const handleKeyDown = useCallback41(
|
|
7752
7982
|
(e) => {
|
|
7753
7983
|
if (e.key === ArrowRight3 || e.key === Enter2) {
|
|
7754
7984
|
const node = treeNodes[highlightedIdx];
|
|
@@ -7774,7 +8004,7 @@ var useCollapsibleGroups2 = ({
|
|
|
7774
8004
|
const listHandlers = collapsibleHeaders ? {
|
|
7775
8005
|
onKeyDown: handleKeyDown
|
|
7776
8006
|
} : NO_HANDLERS4;
|
|
7777
|
-
const handleClick =
|
|
8007
|
+
const handleClick = useCallback41(
|
|
7778
8008
|
(evt) => {
|
|
7779
8009
|
const el = closestListItem2(evt.target);
|
|
7780
8010
|
if (isToggleElement(el)) {
|
|
@@ -7800,14 +8030,14 @@ var useCollapsibleGroups2 = ({
|
|
|
7800
8030
|
};
|
|
7801
8031
|
|
|
7802
8032
|
// src/tree/use-tree-keyboard-navigation.ts
|
|
7803
|
-
import { useCallback as
|
|
8033
|
+
import { useCallback as useCallback42 } from "react";
|
|
7804
8034
|
var useTreeKeyboardNavigation = ({
|
|
7805
8035
|
highlightedIdx,
|
|
7806
8036
|
hiliteItemAtIndex,
|
|
7807
8037
|
indexPositions,
|
|
7808
8038
|
source
|
|
7809
8039
|
}) => {
|
|
7810
|
-
const handleKeyDown =
|
|
8040
|
+
const handleKeyDown = useCallback42(
|
|
7811
8041
|
(e) => {
|
|
7812
8042
|
if (e.key === ArrowLeft3) {
|
|
7813
8043
|
const node = indexPositions[highlightedIdx];
|
|
@@ -7844,11 +8074,11 @@ var useTree = ({
|
|
|
7844
8074
|
selected: selectedProp,
|
|
7845
8075
|
selection
|
|
7846
8076
|
}) => {
|
|
7847
|
-
const lastSelection =
|
|
8077
|
+
const lastSelection = useRef39(EMPTY_ARRAY2);
|
|
7848
8078
|
const dataHook = useHierarchicalData(sourceWithIds);
|
|
7849
8079
|
const handleKeyboardNavigation = (evt, nextIdx) => {
|
|
7850
|
-
var
|
|
7851
|
-
(_b = (
|
|
8080
|
+
var _a2, _b;
|
|
8081
|
+
(_b = (_a2 = selectionHook.listHandlers).onKeyboardNavigation) == null ? void 0 : _b.call(_a2, evt, nextIdx);
|
|
7852
8082
|
};
|
|
7853
8083
|
const { highlightedIdx, ...keyboardHook } = useKeyboardNavigation3({
|
|
7854
8084
|
treeNodes: dataHook.indexPositions,
|
|
@@ -7877,20 +8107,20 @@ var useTree = ({
|
|
|
7877
8107
|
hiliteItemAtIndex: keyboardHook.hiliteItemAtIndex,
|
|
7878
8108
|
indexPositions: dataHook.indexPositions
|
|
7879
8109
|
});
|
|
7880
|
-
const handleClick =
|
|
8110
|
+
const handleClick = useCallback43(
|
|
7881
8111
|
(evt) => {
|
|
7882
|
-
var
|
|
7883
|
-
(
|
|
8112
|
+
var _a2, _b, _c;
|
|
8113
|
+
(_a2 = collapsibleHook.listItemHandlers) == null ? void 0 : _a2.onClick(evt);
|
|
7884
8114
|
if (!evt.defaultPrevented) {
|
|
7885
8115
|
(_c = (_b = selectionHook.listItemHandlers) == null ? void 0 : _b.onClick) == null ? void 0 : _c.call(_b, evt);
|
|
7886
8116
|
}
|
|
7887
8117
|
},
|
|
7888
8118
|
[collapsibleHook, selectionHook]
|
|
7889
8119
|
);
|
|
7890
|
-
const handleKeyDown =
|
|
8120
|
+
const handleKeyDown = useCallback43(
|
|
7891
8121
|
(evt) => {
|
|
7892
|
-
var
|
|
7893
|
-
(_b = (
|
|
8122
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
8123
|
+
(_b = (_a2 = keyboardHook.listProps).onKeyDown) == null ? void 0 : _b.call(_a2, evt);
|
|
7894
8124
|
if (!evt.defaultPrevented) {
|
|
7895
8125
|
(_d = (_c = selectionHook.listHandlers).onKeyDown) == null ? void 0 : _d.call(_c, evt);
|
|
7896
8126
|
}
|
|
@@ -7909,8 +8139,8 @@ var useTree = ({
|
|
|
7909
8139
|
]
|
|
7910
8140
|
);
|
|
7911
8141
|
const getActiveDescendant = () => {
|
|
7912
|
-
var
|
|
7913
|
-
return highlightedIdx === void 0 || highlightedIdx === -1 ? void 0 : (
|
|
8142
|
+
var _a2;
|
|
8143
|
+
return highlightedIdx === void 0 || highlightedIdx === -1 ? void 0 : (_a2 = dataHook.indexPositions[highlightedIdx]) == null ? void 0 : _a2.id;
|
|
7914
8144
|
};
|
|
7915
8145
|
lastSelection.current = selectionHook.selected;
|
|
7916
8146
|
const listProps = {
|
|
@@ -7937,14 +8167,14 @@ var useTree = ({
|
|
|
7937
8167
|
};
|
|
7938
8168
|
|
|
7939
8169
|
// src/tree/Tree.tsx
|
|
7940
|
-
import { jsx as
|
|
8170
|
+
import { jsx as jsx29, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
7941
8171
|
import { createElement as createElement3 } from "react";
|
|
7942
|
-
var
|
|
8172
|
+
var classBase18 = "vuuTree";
|
|
7943
8173
|
var isExpanded = (node) => node.expanded === true;
|
|
7944
8174
|
var TreeNode = ({ children, idx, ...props }) => {
|
|
7945
|
-
return /* @__PURE__ */
|
|
8175
|
+
return /* @__PURE__ */ jsx29("li", { ...props, children });
|
|
7946
8176
|
};
|
|
7947
|
-
var Tree =
|
|
8177
|
+
var Tree = forwardRef13(function Tree2({
|
|
7948
8178
|
allowDragDrop,
|
|
7949
8179
|
className,
|
|
7950
8180
|
defaultSelected,
|
|
@@ -7958,11 +8188,11 @@ var Tree = forwardRef12(function Tree2({
|
|
|
7958
8188
|
source,
|
|
7959
8189
|
...htmlAttributes
|
|
7960
8190
|
}, forwardedRef) {
|
|
7961
|
-
var
|
|
7962
|
-
const id =
|
|
7963
|
-
const rootRef =
|
|
8191
|
+
var _a2;
|
|
8192
|
+
const id = useId7(idProp);
|
|
8193
|
+
const rootRef = useRef40(null);
|
|
7964
8194
|
const [, sourceWithIds, sourceItemById] = useItemsWithIds(source, id, {
|
|
7965
|
-
revealSelected: revealSelected ? (
|
|
8195
|
+
revealSelected: revealSelected ? (_a2 = selectedProp != null ? selectedProp : defaultSelected) != null ? _a2 : false : void 0
|
|
7966
8196
|
});
|
|
7967
8197
|
const handleSelectionChange = (evt, selected2) => {
|
|
7968
8198
|
if (onSelectionChange) {
|
|
@@ -8003,14 +8233,14 @@ var Tree = forwardRef12(function Tree2({
|
|
|
8003
8233
|
const allowGroupSelect = groupSelectionEnabled2(groupSelection);
|
|
8004
8234
|
function addLeafNode(list, item, idx) {
|
|
8005
8235
|
list.push(
|
|
8006
|
-
/* @__PURE__ */
|
|
8236
|
+
/* @__PURE__ */ jsxs17(
|
|
8007
8237
|
TreeNode,
|
|
8008
8238
|
{
|
|
8009
8239
|
...propsCommonToAllListItems,
|
|
8010
8240
|
...getListItemProps(item, idx, highlightedIdx, selected, focusVisible),
|
|
8011
8241
|
children: [
|
|
8012
|
-
item.icon ? /* @__PURE__ */
|
|
8013
|
-
/* @__PURE__ */
|
|
8242
|
+
item.icon ? /* @__PURE__ */ jsx29("span", { className: `${classBase18}Node-icon`, "data-icon": item.icon }) : null,
|
|
8243
|
+
/* @__PURE__ */ jsx29("span", { children: item.label })
|
|
8014
8244
|
]
|
|
8015
8245
|
}
|
|
8016
8246
|
)
|
|
@@ -8028,9 +8258,9 @@ var Tree = forwardRef12(function Tree2({
|
|
|
8028
8258
|
"aria-expanded": child.expanded,
|
|
8029
8259
|
"aria-level": child.level,
|
|
8030
8260
|
"aria-selected": selected.includes(id2) || void 0,
|
|
8031
|
-
className: cx16(`${
|
|
8261
|
+
className: cx16(`${classBase18}Node`, {
|
|
8032
8262
|
focusVisible: focusVisible === i,
|
|
8033
|
-
[`${
|
|
8263
|
+
[`${classBase18}Node-toggle`]: !allowGroupSelect
|
|
8034
8264
|
}),
|
|
8035
8265
|
"data-idx": i,
|
|
8036
8266
|
"data-highlighted": i === highlightedIdx || void 0,
|
|
@@ -8038,20 +8268,20 @@ var Tree = forwardRef12(function Tree2({
|
|
|
8038
8268
|
id: id2,
|
|
8039
8269
|
key: `header-${i}`
|
|
8040
8270
|
},
|
|
8041
|
-
allowGroupSelect ? /* @__PURE__ */
|
|
8042
|
-
/* @__PURE__ */
|
|
8271
|
+
allowGroupSelect ? /* @__PURE__ */ jsxs17("div", { className: `${classBase18}Node-label`, children: [
|
|
8272
|
+
/* @__PURE__ */ jsx29("span", { className: `${classBase18}Node-toggle` }),
|
|
8043
8273
|
title
|
|
8044
|
-
] }) : /* @__PURE__ */
|
|
8045
|
-
child.icon ? /* @__PURE__ */
|
|
8274
|
+
] }) : /* @__PURE__ */ jsxs17("div", { className: `${classBase18}Node-label`, children: [
|
|
8275
|
+
child.icon ? /* @__PURE__ */ jsx29(
|
|
8046
8276
|
"span",
|
|
8047
8277
|
{
|
|
8048
|
-
className: `${
|
|
8278
|
+
className: `${classBase18}Node-icon`,
|
|
8049
8279
|
"data-icon": child.icon
|
|
8050
8280
|
}
|
|
8051
8281
|
) : null,
|
|
8052
|
-
/* @__PURE__ */
|
|
8282
|
+
/* @__PURE__ */ jsx29("span", { children: title })
|
|
8053
8283
|
] }),
|
|
8054
|
-
/* @__PURE__ */
|
|
8284
|
+
/* @__PURE__ */ jsx29("ul", { role: "group", children: isExpanded(child) ? renderSourceContent(child.childNodes, idx) : "" })
|
|
8055
8285
|
)
|
|
8056
8286
|
);
|
|
8057
8287
|
}
|
|
@@ -8068,12 +8298,12 @@ var Tree = forwardRef12(function Tree2({
|
|
|
8068
8298
|
return listItems;
|
|
8069
8299
|
}
|
|
8070
8300
|
}
|
|
8071
|
-
return /* @__PURE__ */
|
|
8301
|
+
return /* @__PURE__ */ jsx29(
|
|
8072
8302
|
"ul",
|
|
8073
8303
|
{
|
|
8074
8304
|
...htmlAttributes,
|
|
8075
8305
|
...listProps,
|
|
8076
|
-
className: cx16(
|
|
8306
|
+
className: cx16(classBase18, className),
|
|
8077
8307
|
id: `Tree-${id}`,
|
|
8078
8308
|
ref: useForkRef8(rootRef, forwardedRef),
|
|
8079
8309
|
role: "tree",
|
|
@@ -8097,41 +8327,63 @@ Tree.displayName = "Tree";
|
|
|
8097
8327
|
var Tree_default = Tree;
|
|
8098
8328
|
|
|
8099
8329
|
// src/vuu-input/VuuInput.tsx
|
|
8100
|
-
import {
|
|
8330
|
+
import { isValidNumber as isValidNumber3 } from "@vuu-ui/vuu-utils";
|
|
8331
|
+
import { Input as Input6 } from "@salt-ds/core";
|
|
8101
8332
|
import cx17 from "classnames";
|
|
8102
8333
|
import {
|
|
8103
|
-
useCallback as
|
|
8334
|
+
useCallback as useCallback44
|
|
8104
8335
|
} from "react";
|
|
8105
|
-
import { jsx as
|
|
8106
|
-
var
|
|
8336
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
8337
|
+
var classBase19 = "vuuInput";
|
|
8107
8338
|
var VuuInput = ({
|
|
8108
8339
|
className,
|
|
8109
8340
|
onCommit,
|
|
8110
8341
|
onKeyDown,
|
|
8342
|
+
type,
|
|
8111
8343
|
...props
|
|
8112
8344
|
}) => {
|
|
8113
|
-
const
|
|
8345
|
+
const commitValue = useCallback44(
|
|
8346
|
+
(evt, value) => {
|
|
8347
|
+
console.log(`commit value ${value}`);
|
|
8348
|
+
if (type === "number") {
|
|
8349
|
+
const numericValue = parseFloat(value);
|
|
8350
|
+
if (isValidNumber3(numericValue)) {
|
|
8351
|
+
onCommit(evt, numericValue);
|
|
8352
|
+
} else {
|
|
8353
|
+
throw Error("Invalid value");
|
|
8354
|
+
}
|
|
8355
|
+
} else if (type === "boolean") {
|
|
8356
|
+
onCommit(evt, Boolean(value));
|
|
8357
|
+
} else {
|
|
8358
|
+
onCommit(evt, value);
|
|
8359
|
+
}
|
|
8360
|
+
},
|
|
8361
|
+
[onCommit, type]
|
|
8362
|
+
);
|
|
8363
|
+
const handleKeyDown = useCallback44(
|
|
8114
8364
|
(evt) => {
|
|
8115
8365
|
if (evt.key === "Enter") {
|
|
8116
8366
|
evt.preventDefault();
|
|
8117
8367
|
evt.stopPropagation();
|
|
8118
|
-
|
|
8368
|
+
const { value } = evt.target;
|
|
8369
|
+
commitValue(evt, value);
|
|
8119
8370
|
}
|
|
8120
8371
|
onKeyDown == null ? void 0 : onKeyDown(evt);
|
|
8121
8372
|
},
|
|
8122
|
-
[
|
|
8373
|
+
[commitValue, onKeyDown]
|
|
8123
8374
|
);
|
|
8124
|
-
const handleBlur =
|
|
8375
|
+
const handleBlur = useCallback44(
|
|
8125
8376
|
(evt) => {
|
|
8126
|
-
|
|
8377
|
+
const { value } = evt.target;
|
|
8378
|
+
commitValue(evt, value);
|
|
8127
8379
|
},
|
|
8128
|
-
[
|
|
8380
|
+
[commitValue]
|
|
8129
8381
|
);
|
|
8130
|
-
return /* @__PURE__ */
|
|
8131
|
-
|
|
8382
|
+
return /* @__PURE__ */ jsx30(
|
|
8383
|
+
Input6,
|
|
8132
8384
|
{
|
|
8133
8385
|
...props,
|
|
8134
|
-
className: cx17(
|
|
8386
|
+
className: cx17(classBase19, className),
|
|
8135
8387
|
onBlur: handleBlur,
|
|
8136
8388
|
onKeyDown: handleKeyDown
|
|
8137
8389
|
}
|
|
@@ -8165,6 +8417,7 @@ export {
|
|
|
8165
8417
|
HeightOnly,
|
|
8166
8418
|
Highlighter,
|
|
8167
8419
|
Home,
|
|
8420
|
+
InstrumentPicker,
|
|
8168
8421
|
InstrumentSearch,
|
|
8169
8422
|
LIST_FOCUS_VISIBLE,
|
|
8170
8423
|
List,
|
|
@@ -8221,9 +8474,11 @@ export {
|
|
|
8221
8474
|
isFocusable,
|
|
8222
8475
|
isGroupNode,
|
|
8223
8476
|
isHeader,
|
|
8477
|
+
isMultiSelection,
|
|
8224
8478
|
isNavigationKey,
|
|
8225
8479
|
isParentPath,
|
|
8226
8480
|
isSelected,
|
|
8481
|
+
isSingleSelection,
|
|
8227
8482
|
itemToString,
|
|
8228
8483
|
listItemElement,
|
|
8229
8484
|
listItemId,
|