@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/cjs/index.js
CHANGED
|
@@ -57,6 +57,7 @@ __export(src_exports, {
|
|
|
57
57
|
HeightOnly: () => HeightOnly,
|
|
58
58
|
Highlighter: () => Highlighter,
|
|
59
59
|
Home: () => Home,
|
|
60
|
+
InstrumentPicker: () => InstrumentPicker,
|
|
60
61
|
InstrumentSearch: () => InstrumentSearch,
|
|
61
62
|
LIST_FOCUS_VISIBLE: () => LIST_FOCUS_VISIBLE,
|
|
62
63
|
List: () => List,
|
|
@@ -113,9 +114,11 @@ __export(src_exports, {
|
|
|
113
114
|
isFocusable: () => isFocusable,
|
|
114
115
|
isGroupNode: () => isGroupNode,
|
|
115
116
|
isHeader: () => isHeader,
|
|
117
|
+
isMultiSelection: () => isMultiSelection,
|
|
116
118
|
isNavigationKey: () => isNavigationKey,
|
|
117
119
|
isParentPath: () => isParentPath,
|
|
118
120
|
isSelected: () => isSelected,
|
|
121
|
+
isSingleSelection: () => isSingleSelection,
|
|
119
122
|
itemToString: () => itemToString,
|
|
120
123
|
listItemElement: () => listItemElement,
|
|
121
124
|
listItemId: () => listItemId,
|
|
@@ -150,7 +153,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
150
153
|
// src/combo-box/ComboBox.tsx
|
|
151
154
|
var import_vuu_layout6 = require("@vuu-ui/vuu-layout");
|
|
152
155
|
var import_core14 = require("@salt-ds/core");
|
|
153
|
-
var
|
|
156
|
+
var import_react38 = require("react");
|
|
154
157
|
|
|
155
158
|
// src/common-hooks/collectionProvider.tsx
|
|
156
159
|
var import_react = require("react");
|
|
@@ -312,15 +315,13 @@ function useResizeObserver(ref, dimensions2, onResize, reportInitialSize = false
|
|
|
312
315
|
}
|
|
313
316
|
|
|
314
317
|
// src/common-hooks/selectionTypes.ts
|
|
318
|
+
var isSingleSelection = (s) => s === void 0 || s === "default" || s === "deselectable";
|
|
319
|
+
var isMultiSelection = (s) => s === "multiple" || (s == null ? void 0 : s.startsWith("extended")) === true;
|
|
315
320
|
var selectionIsDisallowed = (selection) => selection === "none";
|
|
316
321
|
var allowMultipleSelection = (selectionStrategy, specialKey = false) => selectionStrategy === "multiple" || selectionStrategy === "multiple-special-key" && specialKey;
|
|
317
322
|
var deselectionIsAllowed = (selection) => selection !== "none" && selection !== "default";
|
|
318
|
-
var hasSelection = (selected) =>
|
|
319
|
-
|
|
320
|
-
};
|
|
321
|
-
var getFirstSelectedItem = (selected) => {
|
|
322
|
-
return Array.isArray(selected) ? selected[0] : selected;
|
|
323
|
-
};
|
|
323
|
+
var hasSelection = (selected) => selected !== void 0 && selected.length > 0;
|
|
324
|
+
var getFirstSelectedItem = (selected) => selected[0];
|
|
324
325
|
|
|
325
326
|
// src/common-hooks/useCollectionItems.ts
|
|
326
327
|
var import_react5 = require("react");
|
|
@@ -425,7 +426,7 @@ var sourceItems = (source, options) => {
|
|
|
425
426
|
} else {
|
|
426
427
|
return source.map(
|
|
427
428
|
(item, index) => {
|
|
428
|
-
var
|
|
429
|
+
var _a2, _b;
|
|
429
430
|
return {
|
|
430
431
|
childNodes: sourceItems(
|
|
431
432
|
item.childNodes,
|
|
@@ -434,7 +435,7 @@ var sourceItems = (source, options) => {
|
|
|
434
435
|
description: item.description,
|
|
435
436
|
expanded: item.expanded,
|
|
436
437
|
value: item,
|
|
437
|
-
label: (_b = (
|
|
438
|
+
label: (_b = (_a2 = options == null ? void 0 : options.itemToString) == null ? void 0 : _a2.call(options, item)) != null ? _b : itemToString(item)
|
|
438
439
|
};
|
|
439
440
|
}
|
|
440
441
|
);
|
|
@@ -529,8 +530,8 @@ var getDefaultFilterRegex = (value) => new RegExp(`(${escapeRegExp(leftTrim(valu
|
|
|
529
530
|
var getDefaultFilter = (inputValue = "", getFilterRegex = getDefaultFilterRegex) => (itemValue = "") => Boolean(itemValue.length) && Boolean(inputValue.length) && itemValue.match(getFilterRegex(inputValue)) !== null;
|
|
530
531
|
|
|
531
532
|
// src/list/common-hooks/utils/isSelected.ts
|
|
532
|
-
function isSelected(
|
|
533
|
-
const isSelected2 = Array.isArray(
|
|
533
|
+
function isSelected(selectedId, item) {
|
|
534
|
+
const isSelected2 = Array.isArray(selectedId) ? selectedId.includes(item.id) : selectedId === item.id;
|
|
534
535
|
return isSelected2;
|
|
535
536
|
}
|
|
536
537
|
|
|
@@ -597,14 +598,14 @@ var useCollectionItems = ({
|
|
|
597
598
|
// revealSelected = false,
|
|
598
599
|
source
|
|
599
600
|
}) => {
|
|
600
|
-
var
|
|
601
|
+
var _a2;
|
|
601
602
|
const { getItemId } = options;
|
|
602
603
|
const [, forceUpdate] = (0, import_react5.useState)(null);
|
|
603
604
|
const inheritedCollectionHook = useCollection();
|
|
604
605
|
const dataRef = (0, import_react5.useRef)([]);
|
|
605
606
|
const flattenedDataRef = (0, import_react5.useRef)([]);
|
|
606
607
|
const EMPTY_COLLECTION = (0, import_react5.useMemo)(() => [], []);
|
|
607
|
-
const filterPattern = (0, import_react5.useRef)((
|
|
608
|
+
const filterPattern = (0, import_react5.useRef)((_a2 = options.filterPattern) != null ? _a2 : "");
|
|
608
609
|
const {
|
|
609
610
|
getFilterRegex = getDefaultFilterRegex,
|
|
610
611
|
noChildrenLabel,
|
|
@@ -616,13 +617,13 @@ var useCollectionItems = ({
|
|
|
616
617
|
const addMetadataToItems = (0, import_react5.useCallback)(
|
|
617
618
|
(items, indexer, level = 1, path = "", results = [], flattenedCollection2 = [], flattenedSource2 = []) => {
|
|
618
619
|
items.forEach((item, i, all) => {
|
|
619
|
-
var
|
|
620
|
+
var _a3, _b;
|
|
620
621
|
const isCollapsibleHeader = item.header && options.collapsibleHeaders;
|
|
621
622
|
const isNonCollapsibleGroupNode = item.childNodes && options.collapsibleHeaders === false;
|
|
622
623
|
const isLeaf3 = !item.childNodes || item.childNodes.length === 0;
|
|
623
624
|
const nonCollapsible = isNonCollapsibleGroupNode || isLeaf3 && !isCollapsibleHeader;
|
|
624
625
|
const childPath = path ? `${path}.${i}` : `item-${i}`;
|
|
625
|
-
const id = (
|
|
626
|
+
const id = (_a3 = item.id) != null ? _a3 : getItemId ? getItemId(i) : `${idRoot}-${childPath}`;
|
|
626
627
|
const expanded = nonCollapsible ? void 0 : (_b = item.expanded) != null ? _b : isExpanded2();
|
|
627
628
|
const normalisedItem = {
|
|
628
629
|
...item,
|
|
@@ -735,8 +736,8 @@ var useCollectionItems = ({
|
|
|
735
736
|
(id, target = collectionItems) => {
|
|
736
737
|
const sourceWithId = target.find(
|
|
737
738
|
(i) => {
|
|
738
|
-
var
|
|
739
|
-
return i.id === id || ((
|
|
739
|
+
var _a3;
|
|
740
|
+
return i.id === id || ((_a3 = i == null ? void 0 : i.childNodes) == null ? void 0 : _a3.length) && isParentPath(i.id, id);
|
|
740
741
|
}
|
|
741
742
|
);
|
|
742
743
|
if ((sourceWithId == null ? void 0 : sourceWithId.id) === id) {
|
|
@@ -748,15 +749,26 @@ var useCollectionItems = ({
|
|
|
748
749
|
},
|
|
749
750
|
[flattenedSource, collectionItems]
|
|
750
751
|
);
|
|
752
|
+
const indexOfItemById = (0, import_react5.useCallback)(
|
|
753
|
+
(id, target = collectionItems) => {
|
|
754
|
+
const sourceWithId = target.find(
|
|
755
|
+
(i) => {
|
|
756
|
+
var _a3;
|
|
757
|
+
return i.id === id || ((_a3 = i == null ? void 0 : i.childNodes) == null ? void 0 : _a3.length) && isParentPath(i.id, id);
|
|
758
|
+
}
|
|
759
|
+
);
|
|
760
|
+
const idx = sourceWithId ? dataRef.current.indexOf(sourceWithId) : -1;
|
|
761
|
+
if (idx !== -1) {
|
|
762
|
+
return idx;
|
|
763
|
+
}
|
|
764
|
+
throw Error(`useCollectionData indexOfItemById, id ${id} not found `);
|
|
765
|
+
},
|
|
766
|
+
[collectionItems]
|
|
767
|
+
);
|
|
751
768
|
const toCollectionItem = (0, import_react5.useCallback)(
|
|
752
769
|
(item) => {
|
|
753
770
|
const collectionItem = flattenedDataRef.current.find(
|
|
754
|
-
(i) => (
|
|
755
|
-
// const collectionItem = collectionItemsRef.current.find((i) =>
|
|
756
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
757
|
-
//@ts-ignore
|
|
758
|
-
(0, import_react5.isValidElement)(i.value) ? i.label === item : i.value === item
|
|
759
|
-
)
|
|
771
|
+
(i) => (0, import_react5.isValidElement)(i.value) ? i.label === item : i.value === item
|
|
760
772
|
);
|
|
761
773
|
if (collectionItem) {
|
|
762
774
|
return collectionItem;
|
|
@@ -792,9 +804,9 @@ var useCollectionItems = ({
|
|
|
792
804
|
if (Array.isArray(selectedCollectionItem)) {
|
|
793
805
|
return selectedCollectionItem.map((i) => i.id);
|
|
794
806
|
} else if (selectedCollectionItem) {
|
|
795
|
-
return selectedCollectionItem.id;
|
|
807
|
+
return [selectedCollectionItem.id];
|
|
796
808
|
} else {
|
|
797
|
-
return
|
|
809
|
+
return [];
|
|
798
810
|
}
|
|
799
811
|
},
|
|
800
812
|
[itemToCollectionItem]
|
|
@@ -874,6 +886,7 @@ var useCollectionItems = ({
|
|
|
874
886
|
expandGroupItem,
|
|
875
887
|
// why not toggle, or just rely on setdata ?
|
|
876
888
|
setFilterPattern,
|
|
889
|
+
indexOfItemById,
|
|
877
890
|
itemById,
|
|
878
891
|
itemToId,
|
|
879
892
|
toCollectionItem,
|
|
@@ -908,16 +921,16 @@ var useClickAway = ({
|
|
|
908
921
|
(0, import_react6.useEffect)(() => {
|
|
909
922
|
const [clickHandler, escapeKeyHandler] = isOpen ? [
|
|
910
923
|
(evt) => {
|
|
911
|
-
var
|
|
924
|
+
var _a2, _b;
|
|
912
925
|
const targetElement = evt.target;
|
|
913
|
-
if (!((
|
|
914
|
-
onClose();
|
|
926
|
+
if (!((_a2 = popperRef.current) == null ? void 0 : _a2.contains(targetElement)) && !((_b = rootRef.current) == null ? void 0 : _b.contains(targetElement))) {
|
|
927
|
+
onClose("click-away");
|
|
915
928
|
}
|
|
916
929
|
},
|
|
917
930
|
(e) => {
|
|
918
931
|
if (e.key === "Escape") {
|
|
919
932
|
if (openRef.current) {
|
|
920
|
-
onClose();
|
|
933
|
+
onClose("Escape");
|
|
921
934
|
e.stopPropagation();
|
|
922
935
|
}
|
|
923
936
|
}
|
|
@@ -954,7 +967,7 @@ var useDropdownBase = ({
|
|
|
954
967
|
rootRef,
|
|
955
968
|
width
|
|
956
969
|
}) => {
|
|
957
|
-
var
|
|
970
|
+
var _a2;
|
|
958
971
|
const justFocused = (0, import_react7.useRef)(null);
|
|
959
972
|
const popperRef = (0, import_react7.useRef)(null);
|
|
960
973
|
const popperCallbackRef = (0, import_react7.useCallback)((element) => {
|
|
@@ -967,16 +980,19 @@ var useDropdownBase = ({
|
|
|
967
980
|
state: "isOpen"
|
|
968
981
|
});
|
|
969
982
|
const [popup, setPopup] = (0, import_react7.useState)({
|
|
970
|
-
width: (
|
|
983
|
+
width: (_a2 = popupWidthProp != null ? popupWidthProp : width) != null ? _a2 : 0
|
|
971
984
|
});
|
|
972
985
|
const showDropdown = (0, import_react7.useCallback)(() => {
|
|
973
986
|
setIsOpen(true);
|
|
974
987
|
onOpenChange == null ? void 0 : onOpenChange(true);
|
|
975
988
|
}, [onOpenChange, setIsOpen]);
|
|
976
|
-
const hideDropdown = (0, import_react7.useCallback)(
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
989
|
+
const hideDropdown = (0, import_react7.useCallback)(
|
|
990
|
+
(reason) => {
|
|
991
|
+
setIsOpen(false);
|
|
992
|
+
onOpenChange == null ? void 0 : onOpenChange(false, reason);
|
|
993
|
+
},
|
|
994
|
+
[onOpenChange, setIsOpen]
|
|
995
|
+
);
|
|
980
996
|
useClickAway({
|
|
981
997
|
popperRef,
|
|
982
998
|
rootRef,
|
|
@@ -1008,12 +1024,15 @@ var useDropdownBase = ({
|
|
|
1008
1024
|
);
|
|
1009
1025
|
const handleKeydown = (0, import_react7.useCallback)(
|
|
1010
1026
|
(evt) => {
|
|
1011
|
-
if (
|
|
1027
|
+
if (
|
|
1028
|
+
/* evt.key === "Tab" || */
|
|
1029
|
+
evt.key === "Escape" && isOpen
|
|
1030
|
+
) {
|
|
1012
1031
|
if (evt.key === "Escape") {
|
|
1013
1032
|
evt.stopPropagation();
|
|
1014
1033
|
evt.preventDefault();
|
|
1015
1034
|
}
|
|
1016
|
-
hideDropdown();
|
|
1035
|
+
hideDropdown(evt.key);
|
|
1017
1036
|
} else if (openKeys.includes(evt.key) && !isOpen) {
|
|
1018
1037
|
evt.preventDefault();
|
|
1019
1038
|
showDropdown();
|
|
@@ -1023,6 +1042,23 @@ var useDropdownBase = ({
|
|
|
1023
1042
|
},
|
|
1024
1043
|
[hideDropdown, isOpen, onKeyDownProp, openKeys, showDropdown]
|
|
1025
1044
|
);
|
|
1045
|
+
const handleBlur = (0, import_react7.useCallback)(
|
|
1046
|
+
(evt) => {
|
|
1047
|
+
var _a3;
|
|
1048
|
+
console.log("useDropdownBase blur", {
|
|
1049
|
+
popperRef: popperRef.current,
|
|
1050
|
+
relatedTarget: evt.relatedTarget
|
|
1051
|
+
});
|
|
1052
|
+
if (isOpen) {
|
|
1053
|
+
if ((_a3 = popperRef.current) == null ? void 0 : _a3.contains(evt.relatedTarget)) {
|
|
1054
|
+
} else {
|
|
1055
|
+
console.log("hide dropdown");
|
|
1056
|
+
hideDropdown("blur");
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
},
|
|
1060
|
+
[hideDropdown, isOpen]
|
|
1061
|
+
);
|
|
1026
1062
|
const fullWidth = fullWidthProp != null ? fullWidthProp : false;
|
|
1027
1063
|
const measurements2 = fullWidth ? WidthOnly : NO_OBSERVER;
|
|
1028
1064
|
useResizeObserver(rootRef, measurements2, setPopup, fullWidth);
|
|
@@ -1034,6 +1070,7 @@ var useDropdownBase = ({
|
|
|
1034
1070
|
onClick: disabled || openOnFocus ? void 0 : handleTriggerToggle,
|
|
1035
1071
|
onFocus: handleTriggerFocus,
|
|
1036
1072
|
role: "listbox",
|
|
1073
|
+
onBlur: handleBlur,
|
|
1037
1074
|
onKeyDown: disabled ? void 0 : handleKeydown,
|
|
1038
1075
|
style: { width: fullWidth ? void 0 : width }
|
|
1039
1076
|
};
|
|
@@ -1041,7 +1078,7 @@ var useDropdownBase = ({
|
|
|
1041
1078
|
id: componentId,
|
|
1042
1079
|
width: popup.width
|
|
1043
1080
|
};
|
|
1044
|
-
const popupComponentRef = (0, import_core.useForkRef)(popperCallbackRef,
|
|
1081
|
+
const popupComponentRef = (0, import_core.useForkRef)(popperCallbackRef, popupComponent.ref);
|
|
1045
1082
|
return {
|
|
1046
1083
|
componentProps: dropdownComponentProps,
|
|
1047
1084
|
popupComponentRef,
|
|
@@ -1058,6 +1095,7 @@ var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
|
1058
1095
|
var classBase = "vuuDropdown";
|
|
1059
1096
|
var DropdownBase = (0, import_react8.forwardRef)(
|
|
1060
1097
|
function Dropdown({
|
|
1098
|
+
PopupProps,
|
|
1061
1099
|
"aria-labelledby": ariaLabelledByProp,
|
|
1062
1100
|
children,
|
|
1063
1101
|
className: classNameProp,
|
|
@@ -1070,7 +1108,7 @@ var DropdownBase = (0, import_react8.forwardRef)(
|
|
|
1070
1108
|
onOpenChange,
|
|
1071
1109
|
openKeys,
|
|
1072
1110
|
openOnFocus,
|
|
1073
|
-
placement = "below",
|
|
1111
|
+
placement = "below-full-width",
|
|
1074
1112
|
popupWidth,
|
|
1075
1113
|
width,
|
|
1076
1114
|
...htmlAttributes
|
|
@@ -1134,13 +1172,21 @@ var DropdownBase = (0, import_react8.forwardRef)(
|
|
|
1134
1172
|
className: (0, import_classnames.default)(className2, `${classBase}-popup-component`),
|
|
1135
1173
|
id: id2,
|
|
1136
1174
|
ref: popupComponentRef,
|
|
1137
|
-
width: ownWidth != null ? ownWidth : width2
|
|
1175
|
+
width: placement.endsWith("full-width") ? "100%" : ownWidth != null ? ownWidth : width2
|
|
1138
1176
|
});
|
|
1139
1177
|
};
|
|
1140
1178
|
const ref = (0, import_core2.useForkRef)(rootRef, forwardedRef);
|
|
1141
1179
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ...htmlAttributes, className, id: idProp, ref, children: [
|
|
1142
1180
|
getTriggerComponent(),
|
|
1143
|
-
isOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_vuu_popups.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1181
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_vuu_popups.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1182
|
+
import_vuu_popups.PopupComponent,
|
|
1183
|
+
{
|
|
1184
|
+
...PopupProps,
|
|
1185
|
+
anchorElement: rootRef,
|
|
1186
|
+
placement,
|
|
1187
|
+
children: getPopupComponent()
|
|
1188
|
+
}
|
|
1189
|
+
) })
|
|
1144
1190
|
] });
|
|
1145
1191
|
}
|
|
1146
1192
|
);
|
|
@@ -1206,7 +1252,7 @@ var DropdownButton = (0, import_react9.forwardRef)(function DropdownButton2({
|
|
|
1206
1252
|
|
|
1207
1253
|
// src/dropdown/Dropdown.tsx
|
|
1208
1254
|
var import_core12 = require("@salt-ds/core");
|
|
1209
|
-
var
|
|
1255
|
+
var import_react36 = require("react");
|
|
1210
1256
|
var import_vuu_layout4 = require("@vuu-ui/vuu-layout");
|
|
1211
1257
|
|
|
1212
1258
|
// src/list/common-hooks/keyUtils.ts
|
|
@@ -1439,9 +1485,9 @@ function nextItemIdx(count, key, idx) {
|
|
|
1439
1485
|
}
|
|
1440
1486
|
}
|
|
1441
1487
|
var getIndexOfSelectedItem = (items, selected) => {
|
|
1442
|
-
const
|
|
1443
|
-
if (
|
|
1444
|
-
return items.
|
|
1488
|
+
const selectedItemId = Array.isArray(selected) ? getFirstSelectedItem(selected) : void 0;
|
|
1489
|
+
if (selectedItemId) {
|
|
1490
|
+
return items.findIndex((item) => item.id === selectedItemId);
|
|
1445
1491
|
} else {
|
|
1446
1492
|
return -1;
|
|
1447
1493
|
}
|
|
@@ -1577,6 +1623,7 @@ var useKeyboardNavigation = ({
|
|
|
1577
1623
|
const ignoreFocus = (0, import_react12.useRef)(false);
|
|
1578
1624
|
const setIgnoreFocus = (value) => ignoreFocus.current = value;
|
|
1579
1625
|
const handleFocus = (0, import_react12.useCallback)(() => {
|
|
1626
|
+
console.trace(`List useKeyboard focus`);
|
|
1580
1627
|
if (ignoreFocus.current) {
|
|
1581
1628
|
ignoreFocus.current = false;
|
|
1582
1629
|
} else {
|
|
@@ -1640,6 +1687,7 @@ var useKeyboardNavigation = ({
|
|
|
1640
1687
|
);
|
|
1641
1688
|
const handleKeyDown = (0, import_react12.useCallback)(
|
|
1642
1689
|
(e) => {
|
|
1690
|
+
console.log("handleKeyDown");
|
|
1643
1691
|
if (itemCount > 0 && isNavigationKey(e)) {
|
|
1644
1692
|
e.preventDefault();
|
|
1645
1693
|
e.stopPropagation();
|
|
@@ -1733,23 +1781,18 @@ var useSelection = ({
|
|
|
1733
1781
|
(evt) => selectionKeys.includes(evt.key),
|
|
1734
1782
|
[selectionKeys]
|
|
1735
1783
|
);
|
|
1736
|
-
const emptyValue = (0, import_react13.useCallback)(() => {
|
|
1737
|
-
return isMultipleSelect || isExtendedSelect ? [] : null;
|
|
1738
|
-
}, [isMultipleSelect, isExtendedSelect]);
|
|
1739
1784
|
const [selected, setSelected] = useControlled({
|
|
1740
1785
|
controlled: selectedProp,
|
|
1741
|
-
default: defaultSelected != null ? defaultSelected :
|
|
1786
|
+
default: defaultSelected != null ? defaultSelected : [],
|
|
1742
1787
|
name: "UseSelection",
|
|
1743
1788
|
state: "selected"
|
|
1744
1789
|
});
|
|
1745
1790
|
const isItemSelected = (0, import_react13.useCallback)(
|
|
1746
|
-
(itemId) =>
|
|
1747
|
-
return Array.isArray(selected) ? selected.includes(itemId) : selected === itemId;
|
|
1748
|
-
},
|
|
1791
|
+
(itemId) => selected.includes(itemId),
|
|
1749
1792
|
[selected]
|
|
1750
1793
|
);
|
|
1751
1794
|
const selectDeselectable = (0, import_react13.useCallback)(
|
|
1752
|
-
(itemId) => isItemSelected(itemId) ?
|
|
1795
|
+
(itemId) => isItemSelected(itemId) ? [] : [itemId],
|
|
1753
1796
|
[isItemSelected]
|
|
1754
1797
|
);
|
|
1755
1798
|
const selectMultiple = (0, import_react13.useCallback)(
|
|
@@ -1789,17 +1832,14 @@ var useSelection = ({
|
|
|
1789
1832
|
if (preserveExistingSelection && !rangeSelect) {
|
|
1790
1833
|
newSelected = selectMultiple(id);
|
|
1791
1834
|
} else if (rangeSelect) {
|
|
1792
|
-
newSelected = selectRange(
|
|
1793
|
-
idx,
|
|
1794
|
-
preserveExistingSelection
|
|
1795
|
-
);
|
|
1835
|
+
newSelected = selectRange(idx, preserveExistingSelection);
|
|
1796
1836
|
} else {
|
|
1797
1837
|
newSelected = [id];
|
|
1798
1838
|
}
|
|
1799
1839
|
} else if (isDeselectable) {
|
|
1800
1840
|
newSelected = selectDeselectable(id);
|
|
1801
1841
|
} else {
|
|
1802
|
-
newSelected = id;
|
|
1842
|
+
newSelected = [id];
|
|
1803
1843
|
}
|
|
1804
1844
|
if (newSelected !== selected) {
|
|
1805
1845
|
setSelected(newSelected);
|
|
@@ -2124,17 +2164,17 @@ var Highlighter = (props) => {
|
|
|
2124
2164
|
};
|
|
2125
2165
|
|
|
2126
2166
|
// src/list/ListItem.tsx
|
|
2127
|
-
var
|
|
2167
|
+
var import_react17 = require("react");
|
|
2128
2168
|
var import_classnames4 = __toESM(require("classnames"));
|
|
2129
2169
|
|
|
2130
2170
|
// src/list/CheckboxIcon.tsx
|
|
2171
|
+
var import_react16 = __toESM(require("react"));
|
|
2131
2172
|
var import_classnames3 = __toESM(require("classnames"));
|
|
2132
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2133
2173
|
var classBase3 = "vuuCheckboxIcon";
|
|
2134
2174
|
var CheckboxIcon = ({
|
|
2135
2175
|
checked = false,
|
|
2136
2176
|
...htmlAttributes
|
|
2137
|
-
}) => /* @__PURE__ */
|
|
2177
|
+
}) => /* @__PURE__ */ import_react16.default.createElement(
|
|
2138
2178
|
"span",
|
|
2139
2179
|
{
|
|
2140
2180
|
...htmlAttributes,
|
|
@@ -2143,13 +2183,13 @@ var CheckboxIcon = ({
|
|
|
2143
2183
|
);
|
|
2144
2184
|
|
|
2145
2185
|
// src/list/ListItem.tsx
|
|
2146
|
-
var
|
|
2186
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2147
2187
|
var classBase4 = "vuuListItem";
|
|
2148
|
-
var ListItemProxy = (0,
|
|
2188
|
+
var ListItemProxy = (0, import_react17.forwardRef)(function ListItemNextProxy({
|
|
2149
2189
|
height,
|
|
2150
2190
|
...htmlAttributes
|
|
2151
2191
|
}, forwardedRef) {
|
|
2152
|
-
return /* @__PURE__ */ (0,
|
|
2192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2153
2193
|
"div",
|
|
2154
2194
|
{
|
|
2155
2195
|
...htmlAttributes,
|
|
@@ -2160,7 +2200,7 @@ var ListItemProxy = (0, import_react16.forwardRef)(function ListItemNextProxy({
|
|
|
2160
2200
|
}
|
|
2161
2201
|
);
|
|
2162
2202
|
});
|
|
2163
|
-
var ListItem = (0,
|
|
2203
|
+
var ListItem = (0, import_react17.forwardRef)(
|
|
2164
2204
|
function ListItem2({
|
|
2165
2205
|
children,
|
|
2166
2206
|
className: classNameProp,
|
|
@@ -2184,7 +2224,7 @@ var ListItem = (0, import_react16.forwardRef)(
|
|
|
2184
2224
|
...styleProp,
|
|
2185
2225
|
height: itemHeight
|
|
2186
2226
|
} : styleProp;
|
|
2187
|
-
return /* @__PURE__ */ (0,
|
|
2227
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2188
2228
|
"div",
|
|
2189
2229
|
{
|
|
2190
2230
|
className,
|
|
@@ -2194,8 +2234,8 @@ var ListItem = (0, import_react16.forwardRef)(
|
|
|
2194
2234
|
ref: forwardedRef,
|
|
2195
2235
|
style,
|
|
2196
2236
|
children: [
|
|
2197
|
-
showCheckbox && /* @__PURE__ */ (0,
|
|
2198
|
-
children && typeof children !== "string" ? children : itemTextHighlightPattern == null ? /* @__PURE__ */ (0,
|
|
2237
|
+
showCheckbox && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckboxIcon, { "aria-hidden": true, checked: selected }),
|
|
2238
|
+
children && typeof children !== "string" ? children : itemTextHighlightPattern == null ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `${classBase4}-textWrapper`, children: label || children }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2199
2239
|
Highlighter,
|
|
2200
2240
|
{
|
|
2201
2241
|
matchPattern: itemTextHighlightPattern,
|
|
@@ -2212,29 +2252,29 @@ var ListItem = (0, import_react16.forwardRef)(
|
|
|
2212
2252
|
var import_vuu_layout3 = require("@vuu-ui/vuu-layout");
|
|
2213
2253
|
var import_core9 = require("@salt-ds/core");
|
|
2214
2254
|
var import_classnames6 = __toESM(require("classnames"));
|
|
2215
|
-
var
|
|
2255
|
+
var import_react31 = require("react");
|
|
2216
2256
|
|
|
2217
2257
|
// src/list/useList.ts
|
|
2218
2258
|
var import_vuu_layout2 = require("@vuu-ui/vuu-layout");
|
|
2219
|
-
var
|
|
2259
|
+
var import_react28 = require("react");
|
|
2220
2260
|
|
|
2221
2261
|
// src/drag-drop/dragDropTypesNext.ts
|
|
2222
2262
|
var FWD = "fwd";
|
|
2223
2263
|
var BWD = "bwd";
|
|
2224
2264
|
|
|
2225
2265
|
// src/drag-drop/DragDropProvider.tsx
|
|
2226
|
-
var
|
|
2266
|
+
var import_react19 = require("react");
|
|
2227
2267
|
|
|
2228
2268
|
// src/drag-drop/useGlobalDragDrop.ts
|
|
2229
2269
|
var import_vuu_utils3 = require("@vuu-ui/vuu-utils");
|
|
2230
|
-
var
|
|
2270
|
+
var import_react18 = require("react");
|
|
2231
2271
|
var useGlobalDragDrop = ({
|
|
2232
2272
|
onDragOverDropTarget
|
|
2233
2273
|
}) => {
|
|
2234
|
-
const measuredDropTargetsRef = (0,
|
|
2235
|
-
const dragDropStateRef = (0,
|
|
2236
|
-
const mousePosRef = (0,
|
|
2237
|
-
const overDropTarget = (0,
|
|
2274
|
+
const measuredDropTargetsRef = (0, import_react18.useRef)();
|
|
2275
|
+
const dragDropStateRef = (0, import_react18.useRef)(null);
|
|
2276
|
+
const mousePosRef = (0, import_react18.useRef)({ x: 0, y: 0 });
|
|
2277
|
+
const overDropTarget = (0, import_react18.useCallback)((x, y) => {
|
|
2238
2278
|
const { current: dropTargets } = measuredDropTargetsRef;
|
|
2239
2279
|
if (dropTargets) {
|
|
2240
2280
|
for (const [id, measuredTarget] of Object.entries(dropTargets)) {
|
|
@@ -2245,7 +2285,7 @@ var useGlobalDragDrop = ({
|
|
|
2245
2285
|
}
|
|
2246
2286
|
return void 0;
|
|
2247
2287
|
}, []);
|
|
2248
|
-
const dragMouseMoveHandler = (0,
|
|
2288
|
+
const dragMouseMoveHandler = (0, import_react18.useCallback)(
|
|
2249
2289
|
(evt) => {
|
|
2250
2290
|
const { clientX, clientY } = evt;
|
|
2251
2291
|
const { current: dragDropState } = dragDropStateRef;
|
|
@@ -2270,11 +2310,11 @@ var useGlobalDragDrop = ({
|
|
|
2270
2310
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2271
2311
|
[]
|
|
2272
2312
|
);
|
|
2273
|
-
const dragMouseUpHandler = (0,
|
|
2313
|
+
const dragMouseUpHandler = (0, import_react18.useCallback)(() => {
|
|
2274
2314
|
document.removeEventListener("mousemove", dragMouseMoveHandler, false);
|
|
2275
2315
|
document.removeEventListener("mouseup", dragMouseUpHandler, false);
|
|
2276
2316
|
}, [dragMouseMoveHandler]);
|
|
2277
|
-
const resumeDrag = (0,
|
|
2317
|
+
const resumeDrag = (0, import_react18.useCallback)(
|
|
2278
2318
|
(dragDropState) => {
|
|
2279
2319
|
console.log(`resume drag of `, {
|
|
2280
2320
|
el: dragDropState.draggableElement
|
|
@@ -2293,14 +2333,14 @@ var useGlobalDragDrop = ({
|
|
|
2293
2333
|
};
|
|
2294
2334
|
|
|
2295
2335
|
// src/drag-drop/DragDropProvider.tsx
|
|
2296
|
-
var
|
|
2336
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2297
2337
|
var NO_DRAG_CONTEXT = {
|
|
2298
2338
|
isDragSource: false,
|
|
2299
2339
|
isDropTarget: false,
|
|
2300
2340
|
register: () => void 0
|
|
2301
2341
|
};
|
|
2302
2342
|
var unconfiguredRegistrationCall = () => console.log(`have you forgotten to provide a DragDrop Provider ?`);
|
|
2303
|
-
var DragDropContext = (0,
|
|
2343
|
+
var DragDropContext = (0, import_react19.createContext)({
|
|
2304
2344
|
registerDragDropParty: unconfiguredRegistrationCall
|
|
2305
2345
|
});
|
|
2306
2346
|
var measureDropTargets = (dropTargetIds = []) => {
|
|
@@ -2317,11 +2357,11 @@ var DragDropProvider = ({
|
|
|
2317
2357
|
children,
|
|
2318
2358
|
dragSources: dragSourcesProp
|
|
2319
2359
|
}) => {
|
|
2320
|
-
const resumeDragHandlers = (0,
|
|
2360
|
+
const resumeDragHandlers = (0, import_react19.useMemo)(
|
|
2321
2361
|
() => /* @__PURE__ */ new Map(),
|
|
2322
2362
|
[]
|
|
2323
2363
|
);
|
|
2324
|
-
const handleDragOverDropTarget = (0,
|
|
2364
|
+
const handleDragOverDropTarget = (0, import_react19.useCallback)(
|
|
2325
2365
|
(dropTargetId, dragDropState) => {
|
|
2326
2366
|
const resumeDrag2 = resumeDragHandlers.get(dropTargetId);
|
|
2327
2367
|
if (resumeDrag2) {
|
|
@@ -2335,7 +2375,7 @@ var DragDropProvider = ({
|
|
|
2335
2375
|
const { measuredDropTargetsRef, resumeDrag } = useGlobalDragDrop({
|
|
2336
2376
|
onDragOverDropTarget: handleDragOverDropTarget
|
|
2337
2377
|
});
|
|
2338
|
-
const [dragSources, dropTargets] = (0,
|
|
2378
|
+
const [dragSources, dropTargets] = (0, import_react19.useMemo)(() => {
|
|
2339
2379
|
const sources = /* @__PURE__ */ new Map();
|
|
2340
2380
|
const targets = /* @__PURE__ */ new Map();
|
|
2341
2381
|
for (const [sourceId, { dropTargets: dropTargets2 }] of Object.entries(dragSourcesProp)) {
|
|
@@ -2361,7 +2401,7 @@ var DragDropProvider = ({
|
|
|
2361
2401
|
dragSources,
|
|
2362
2402
|
dropTargets
|
|
2363
2403
|
});
|
|
2364
|
-
const onDragOut = (0,
|
|
2404
|
+
const onDragOut = (0, import_react19.useCallback)(
|
|
2365
2405
|
(id, dragDropState) => {
|
|
2366
2406
|
measuredDropTargetsRef.current = measureDropTargets(dragSources.get(id));
|
|
2367
2407
|
resumeDrag(dragDropState);
|
|
@@ -2369,10 +2409,10 @@ var DragDropProvider = ({
|
|
|
2369
2409
|
},
|
|
2370
2410
|
[dragSources, measuredDropTargetsRef, resumeDrag]
|
|
2371
2411
|
);
|
|
2372
|
-
const onEndOfDragOperation = (0,
|
|
2412
|
+
const onEndOfDragOperation = (0, import_react19.useCallback)((id) => {
|
|
2373
2413
|
console.log(`end of drag operation, id= ${id}`);
|
|
2374
2414
|
}, []);
|
|
2375
|
-
const registerDragDropParty = (0,
|
|
2415
|
+
const registerDragDropParty = (0, import_react19.useCallback)(
|
|
2376
2416
|
(id, resumeDrag2) => {
|
|
2377
2417
|
if (resumeDrag2) {
|
|
2378
2418
|
resumeDragHandlers.set(id, resumeDrag2);
|
|
@@ -2380,7 +2420,7 @@ var DragDropProvider = ({
|
|
|
2380
2420
|
},
|
|
2381
2421
|
[resumeDragHandlers]
|
|
2382
2422
|
);
|
|
2383
|
-
const contextValue = (0,
|
|
2423
|
+
const contextValue = (0, import_react19.useMemo)(
|
|
2384
2424
|
() => ({
|
|
2385
2425
|
dragSources,
|
|
2386
2426
|
dropTargets,
|
|
@@ -2396,19 +2436,19 @@ var DragDropProvider = ({
|
|
|
2396
2436
|
registerDragDropParty
|
|
2397
2437
|
]
|
|
2398
2438
|
);
|
|
2399
|
-
return /* @__PURE__ */ (0,
|
|
2439
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DragDropContext.Provider, { value: contextValue, children });
|
|
2400
2440
|
};
|
|
2401
2441
|
var useDragDropProvider = (id) => {
|
|
2402
|
-
var
|
|
2442
|
+
var _a2, _b;
|
|
2403
2443
|
const {
|
|
2404
2444
|
dragSources,
|
|
2405
2445
|
dropTargets,
|
|
2406
2446
|
onDragOut,
|
|
2407
2447
|
onEndOfDragOperation,
|
|
2408
2448
|
registerDragDropParty
|
|
2409
|
-
} = (0,
|
|
2449
|
+
} = (0, import_react19.useContext)(DragDropContext);
|
|
2410
2450
|
if (id) {
|
|
2411
|
-
const isDragSource = (
|
|
2451
|
+
const isDragSource = (_a2 = dragSources == null ? void 0 : dragSources.has(id)) != null ? _a2 : false;
|
|
2412
2452
|
const isDropTarget = (_b = dropTargets == null ? void 0 : dropTargets.has(id)) != null ? _b : false;
|
|
2413
2453
|
return {
|
|
2414
2454
|
isDragSource,
|
|
@@ -2449,10 +2489,82 @@ var DragDropState = class {
|
|
|
2449
2489
|
};
|
|
2450
2490
|
|
|
2451
2491
|
// src/drag-drop/useDragDropNaturalMovementNext.tsx
|
|
2452
|
-
var
|
|
2492
|
+
var import_react22 = require("react");
|
|
2453
2493
|
|
|
2454
2494
|
// src/drag-drop/useDragDisplacers.ts
|
|
2495
|
+
var import_react21 = require("react");
|
|
2496
|
+
|
|
2497
|
+
// src/drag-drop/Draggable.tsx
|
|
2498
|
+
var import_core7 = require("@salt-ds/core");
|
|
2499
|
+
var import_classnames5 = __toESM(require("classnames"));
|
|
2455
2500
|
var import_react20 = require("react");
|
|
2501
|
+
var import_vuu_popups2 = require("@vuu-ui/vuu-popups");
|
|
2502
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
2503
|
+
var makeClassNames = (classNames) => classNames.split(" ").map((className) => `vuuDraggable-${className}`);
|
|
2504
|
+
var Draggable = (0, import_react20.forwardRef)(function Draggable2({ wrapperClassName, element, onTransitionEnd, style, scale = 1 }, forwardedRef) {
|
|
2505
|
+
const callbackRef = (0, import_react20.useCallback)(
|
|
2506
|
+
(el) => {
|
|
2507
|
+
if (el) {
|
|
2508
|
+
el.innerHTML = "";
|
|
2509
|
+
el.appendChild(element);
|
|
2510
|
+
if (scale !== 1) {
|
|
2511
|
+
el.style.transform = `scale(${scale},${scale})`;
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
},
|
|
2515
|
+
[element, scale]
|
|
2516
|
+
);
|
|
2517
|
+
const forkedRef = (0, import_core7.useForkRef)(forwardedRef, callbackRef);
|
|
2518
|
+
const position = (0, import_react20.useMemo)(
|
|
2519
|
+
() => ({
|
|
2520
|
+
left: 0,
|
|
2521
|
+
top: 0
|
|
2522
|
+
}),
|
|
2523
|
+
[]
|
|
2524
|
+
);
|
|
2525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_vuu_popups2.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2526
|
+
import_vuu_popups2.PopupComponent,
|
|
2527
|
+
{
|
|
2528
|
+
anchorElement: { current: document.body },
|
|
2529
|
+
placement: "absolute",
|
|
2530
|
+
position,
|
|
2531
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2532
|
+
"div",
|
|
2533
|
+
{
|
|
2534
|
+
className: (0, import_classnames5.default)("vuuDraggable", ...makeClassNames(wrapperClassName)),
|
|
2535
|
+
ref: forkedRef,
|
|
2536
|
+
onTransitionEnd,
|
|
2537
|
+
style
|
|
2538
|
+
}
|
|
2539
|
+
)
|
|
2540
|
+
}
|
|
2541
|
+
) });
|
|
2542
|
+
});
|
|
2543
|
+
var createDragSpacer = (transitioning) => {
|
|
2544
|
+
const spacer = document.createElement("div");
|
|
2545
|
+
spacer.className = "vuuDraggable-spacer";
|
|
2546
|
+
if (transitioning) {
|
|
2547
|
+
spacer.addEventListener("transitionend", () => {
|
|
2548
|
+
transitioning.current = false;
|
|
2549
|
+
});
|
|
2550
|
+
}
|
|
2551
|
+
return spacer;
|
|
2552
|
+
};
|
|
2553
|
+
var createDropIndicatorPosition = () => {
|
|
2554
|
+
const spacer = document.createElement("div");
|
|
2555
|
+
spacer.className = "vuuDraggable-dropIndicatorPosition";
|
|
2556
|
+
return spacer;
|
|
2557
|
+
};
|
|
2558
|
+
var createDropIndicator = (transitioning) => {
|
|
2559
|
+
const spacer = document.createElement("div");
|
|
2560
|
+
spacer.className = "vuuDraggable-dropIndicator";
|
|
2561
|
+
if (transitioning) {
|
|
2562
|
+
spacer.addEventListener("transitionend", () => {
|
|
2563
|
+
transitioning.current = false;
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
return spacer;
|
|
2567
|
+
};
|
|
2456
2568
|
|
|
2457
2569
|
// src/drag-drop/drop-target-utils.ts
|
|
2458
2570
|
var LEFT_RIGHT = ["left", "right"];
|
|
@@ -2658,83 +2770,26 @@ function constrainRect(targetRect, constraintRect) {
|
|
|
2658
2770
|
}
|
|
2659
2771
|
var dropTargetsDebugString = (dropTargets) => dropTargets.map(
|
|
2660
2772
|
(d, i) => {
|
|
2661
|
-
var
|
|
2773
|
+
var _a2;
|
|
2662
2774
|
return `
|
|
2663
2775
|
${d.isDraggedItem ? "*" : " "}[${i}] width : ${Math.floor(
|
|
2664
2776
|
d.size
|
|
2665
2777
|
)} ${Math.floor(d.start)} - ${Math.floor(d.end)} (mid ${Math.floor(
|
|
2666
2778
|
d.mid
|
|
2667
|
-
)}) ${(
|
|
2779
|
+
)}) ${(_a2 = d.element) == null ? void 0 : _a2.textContent} `;
|
|
2668
2780
|
}
|
|
2669
2781
|
).join("");
|
|
2670
2782
|
|
|
2671
|
-
// src/drag-drop/Draggable.tsx
|
|
2672
|
-
var import_core7 = require("@salt-ds/core");
|
|
2673
|
-
var import_classnames5 = __toESM(require("classnames"));
|
|
2674
|
-
var import_react19 = require("react");
|
|
2675
|
-
var import_vuu_popups2 = require("@vuu-ui/vuu-popups");
|
|
2676
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2677
|
-
var makeClassNames = (classNames) => classNames.split(" ").map((className) => `vuuDraggable-${className}`);
|
|
2678
|
-
var Draggable = (0, import_react19.forwardRef)(function Draggable2({ wrapperClassName, element, onTransitionEnd, style, scale = 1 }, forwardedRef) {
|
|
2679
|
-
const callbackRef = (0, import_react19.useCallback)(
|
|
2680
|
-
(el) => {
|
|
2681
|
-
if (el) {
|
|
2682
|
-
el.innerHTML = "";
|
|
2683
|
-
el.appendChild(element);
|
|
2684
|
-
if (scale !== 1) {
|
|
2685
|
-
el.style.transform = `scale(${scale},${scale})`;
|
|
2686
|
-
}
|
|
2687
|
-
}
|
|
2688
|
-
},
|
|
2689
|
-
[element, scale]
|
|
2690
|
-
);
|
|
2691
|
-
const forkedRef = (0, import_core7.useForkRef)(forwardedRef, callbackRef);
|
|
2692
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_vuu_popups2.PortalDeprecated, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2693
|
-
"div",
|
|
2694
|
-
{
|
|
2695
|
-
className: (0, import_classnames5.default)("vuuDraggable", ...makeClassNames(wrapperClassName)),
|
|
2696
|
-
ref: forkedRef,
|
|
2697
|
-
onTransitionEnd,
|
|
2698
|
-
style
|
|
2699
|
-
}
|
|
2700
|
-
) });
|
|
2701
|
-
});
|
|
2702
|
-
var createDragSpacer = (transitioning) => {
|
|
2703
|
-
const spacer = document.createElement("div");
|
|
2704
|
-
spacer.className = "vuuDraggable-spacer";
|
|
2705
|
-
if (transitioning) {
|
|
2706
|
-
spacer.addEventListener("transitionend", () => {
|
|
2707
|
-
transitioning.current = false;
|
|
2708
|
-
});
|
|
2709
|
-
}
|
|
2710
|
-
return spacer;
|
|
2711
|
-
};
|
|
2712
|
-
var createDropIndicatorPosition = () => {
|
|
2713
|
-
const spacer = document.createElement("div");
|
|
2714
|
-
spacer.className = "vuuDraggable-dropIndicatorPosition";
|
|
2715
|
-
return spacer;
|
|
2716
|
-
};
|
|
2717
|
-
var createDropIndicator = (transitioning) => {
|
|
2718
|
-
const spacer = document.createElement("div");
|
|
2719
|
-
spacer.className = "vuuDraggable-dropIndicator";
|
|
2720
|
-
if (transitioning) {
|
|
2721
|
-
spacer.addEventListener("transitionend", () => {
|
|
2722
|
-
transitioning.current = false;
|
|
2723
|
-
});
|
|
2724
|
-
}
|
|
2725
|
-
return spacer;
|
|
2726
|
-
};
|
|
2727
|
-
|
|
2728
2783
|
// src/drag-drop/useDragDisplacers.ts
|
|
2729
2784
|
var useDragDisplacers = (orientation = "horizontal") => {
|
|
2730
|
-
const animationFrame = (0,
|
|
2731
|
-
const transitioning = (0,
|
|
2732
|
-
const spacers = (0,
|
|
2785
|
+
const animationFrame = (0, import_react21.useRef)(0);
|
|
2786
|
+
const transitioning = (0, import_react21.useRef)(false);
|
|
2787
|
+
const spacers = (0, import_react21.useMemo)(
|
|
2733
2788
|
// We only need to listen for transition end on one of the spacers
|
|
2734
2789
|
() => [createDragSpacer(transitioning), createDragSpacer()],
|
|
2735
2790
|
[]
|
|
2736
2791
|
);
|
|
2737
|
-
const animateTransition = (0,
|
|
2792
|
+
const animateTransition = (0, import_react21.useCallback)(
|
|
2738
2793
|
(size, propertyName = "width") => {
|
|
2739
2794
|
const [spacer1, spacer2] = spacers;
|
|
2740
2795
|
animationFrame.current = requestAnimationFrame(() => {
|
|
@@ -2747,7 +2802,7 @@ var useDragDisplacers = (orientation = "horizontal") => {
|
|
|
2747
2802
|
},
|
|
2748
2803
|
[spacers]
|
|
2749
2804
|
);
|
|
2750
|
-
const clearSpacers = (0,
|
|
2805
|
+
const clearSpacers = (0, import_react21.useCallback)(
|
|
2751
2806
|
(useTransition = false) => {
|
|
2752
2807
|
if (useTransition === true) {
|
|
2753
2808
|
const [spacer] = spacers;
|
|
@@ -2764,13 +2819,13 @@ var useDragDisplacers = (orientation = "horizontal") => {
|
|
|
2764
2819
|
},
|
|
2765
2820
|
[animateTransition, orientation, spacers]
|
|
2766
2821
|
);
|
|
2767
|
-
const cancelAnyPendingAnimation = (0,
|
|
2822
|
+
const cancelAnyPendingAnimation = (0, import_react21.useCallback)(() => {
|
|
2768
2823
|
if (animationFrame.current) {
|
|
2769
2824
|
cancelAnimationFrame(animationFrame.current);
|
|
2770
2825
|
animationFrame.current = 0;
|
|
2771
2826
|
}
|
|
2772
2827
|
}, []);
|
|
2773
|
-
const displaceItem = (0,
|
|
2828
|
+
const displaceItem = (0, import_react21.useCallback)(
|
|
2774
2829
|
(dropTargets, dropTarget, size, useTransition = false, direction = "static") => {
|
|
2775
2830
|
if (dropTarget) {
|
|
2776
2831
|
const propertyName = orientation === "horizontal" ? "width" : "height";
|
|
@@ -2817,7 +2872,7 @@ var useDragDisplacers = (orientation = "horizontal") => {
|
|
|
2817
2872
|
spacers
|
|
2818
2873
|
]
|
|
2819
2874
|
);
|
|
2820
|
-
const displaceLastItem = (0,
|
|
2875
|
+
const displaceLastItem = (0, import_react21.useCallback)(
|
|
2821
2876
|
(dropTargets, dropTarget, size, useTransition = false, direction = "static") => {
|
|
2822
2877
|
const propertyName = orientation === "horizontal" ? "width" : "height";
|
|
2823
2878
|
const [spacer1, spacer2] = spacers;
|
|
@@ -2870,22 +2925,22 @@ var useDragDropNaturalMovement = ({
|
|
|
2870
2925
|
selected,
|
|
2871
2926
|
viewportRange
|
|
2872
2927
|
}) => {
|
|
2873
|
-
const dragDirectionRef = (0,
|
|
2874
|
-
const isScrollable = (0,
|
|
2875
|
-
const dragPosRef = (0,
|
|
2876
|
-
const measuredDropTargets = (0,
|
|
2877
|
-
const overflowMenuShowingRef = (0,
|
|
2878
|
-
const [showOverflow, setShowOverflow] = (0,
|
|
2928
|
+
const dragDirectionRef = (0, import_react22.useRef)();
|
|
2929
|
+
const isScrollable = (0, import_react22.useRef)(false);
|
|
2930
|
+
const dragPosRef = (0, import_react22.useRef)(-1);
|
|
2931
|
+
const measuredDropTargets = (0, import_react22.useRef)([]);
|
|
2932
|
+
const overflowMenuShowingRef = (0, import_react22.useRef)(false);
|
|
2933
|
+
const [showOverflow, setShowOverflow] = (0, import_react22.useState)(false);
|
|
2879
2934
|
const { clearSpacers, displaceItem, displaceLastItem } = useDragDisplacers(orientation);
|
|
2880
|
-
const draggedItemRef = (0,
|
|
2935
|
+
const draggedItemRef = (0, import_react22.useRef)();
|
|
2881
2936
|
const fullItemQuery = `:is(${itemQuery}${NOT_OVERFLOWED}${NOT_HIDDEN},.vuuOverflowContainer-OverflowIndicator)`;
|
|
2882
2937
|
const indexOf = (dropTarget) => measuredDropTargets.current.findIndex((d) => d.id === dropTarget.id);
|
|
2883
|
-
const rangeRef = (0,
|
|
2938
|
+
const rangeRef = (0, import_react22.useRef)();
|
|
2884
2939
|
rangeRef.current = viewportRange;
|
|
2885
|
-
const handleScrollStart = (0,
|
|
2940
|
+
const handleScrollStart = (0, import_react22.useCallback)(() => {
|
|
2886
2941
|
clearSpacers();
|
|
2887
2942
|
}, [clearSpacers]);
|
|
2888
|
-
const handleScrollStop = (0,
|
|
2943
|
+
const handleScrollStop = (0, import_react22.useCallback)(
|
|
2889
2944
|
(scrollDirection, _scrollPos, atEnd) => {
|
|
2890
2945
|
const { current: container } = containerRef;
|
|
2891
2946
|
const { current: draggedItem } = draggedItemRef;
|
|
@@ -2926,7 +2981,7 @@ var useDragDropNaturalMovement = ({
|
|
|
2926
2981
|
},
|
|
2927
2982
|
[containerRef, displaceItem, displaceLastItem, fullItemQuery, orientation]
|
|
2928
2983
|
);
|
|
2929
|
-
const beginDrag = (0,
|
|
2984
|
+
const beginDrag = (0, import_react22.useCallback)(
|
|
2930
2985
|
(dragElement) => {
|
|
2931
2986
|
if (
|
|
2932
2987
|
//TODO need a different check for selected
|
|
@@ -3008,7 +3063,7 @@ var useDragDropNaturalMovement = ({
|
|
|
3008
3063
|
viewportRange
|
|
3009
3064
|
]
|
|
3010
3065
|
);
|
|
3011
|
-
const [showPopup, hidePopup] = (0,
|
|
3066
|
+
const [showPopup, hidePopup] = (0, import_react22.useMemo)(() => {
|
|
3012
3067
|
let popupShowing = false;
|
|
3013
3068
|
const show = (dropTarget) => {
|
|
3014
3069
|
if (!popupShowing) {
|
|
@@ -3034,7 +3089,7 @@ var useDragDropNaturalMovement = ({
|
|
|
3034
3089
|
};
|
|
3035
3090
|
return [show, hide];
|
|
3036
3091
|
}, []);
|
|
3037
|
-
const drag = (0,
|
|
3092
|
+
const drag = (0, import_react22.useCallback)(
|
|
3038
3093
|
(dragPos, mouseMoveDirection) => {
|
|
3039
3094
|
const { current: draggedItem } = draggedItemRef;
|
|
3040
3095
|
if (draggedItem) {
|
|
@@ -3075,8 +3130,8 @@ var useDragDropNaturalMovement = ({
|
|
|
3075
3130
|
},
|
|
3076
3131
|
[containerRef, displaceItem, displaceLastItem, hidePopup, showPopup]
|
|
3077
3132
|
);
|
|
3078
|
-
const drop = (0,
|
|
3079
|
-
var
|
|
3133
|
+
const drop = (0, import_react22.useCallback)(() => {
|
|
3134
|
+
var _a2;
|
|
3080
3135
|
clearSpacers();
|
|
3081
3136
|
const { current: dropTargets } = measuredDropTargets;
|
|
3082
3137
|
const indexOfDraggedItem = getIndexOfDraggedItem(dropTargets);
|
|
@@ -3103,13 +3158,13 @@ var useDragDropNaturalMovement = ({
|
|
|
3103
3158
|
}
|
|
3104
3159
|
setShowOverflow(false);
|
|
3105
3160
|
if (containerRef.current) {
|
|
3106
|
-
const scrollTop = (
|
|
3161
|
+
const scrollTop = (_a2 = containerRef.current) == null ? void 0 : _a2.scrollTop;
|
|
3107
3162
|
if (indexOfDraggedItem < dropTargets.length) {
|
|
3108
3163
|
containerRef.current.scrollTop = scrollTop;
|
|
3109
3164
|
}
|
|
3110
3165
|
}
|
|
3111
3166
|
}, [clearSpacers, containerRef, onDrop]);
|
|
3112
|
-
const releaseDrag = (0,
|
|
3167
|
+
const releaseDrag = (0, import_react22.useCallback)(() => {
|
|
3113
3168
|
clearSpacers(true);
|
|
3114
3169
|
}, [clearSpacers]);
|
|
3115
3170
|
return {
|
|
@@ -3124,14 +3179,14 @@ var useDragDropNaturalMovement = ({
|
|
|
3124
3179
|
};
|
|
3125
3180
|
|
|
3126
3181
|
// src/drag-drop/useDragDropIndicator.tsx
|
|
3127
|
-
var
|
|
3182
|
+
var import_react24 = require("react");
|
|
3128
3183
|
|
|
3129
3184
|
// src/drag-drop/useDropIndicator.ts
|
|
3130
|
-
var
|
|
3185
|
+
var import_react23 = require("react");
|
|
3131
3186
|
var useDropIndicator = () => {
|
|
3132
|
-
const spacer = (0,
|
|
3133
|
-
const clearSpacer = (0,
|
|
3134
|
-
const positionDropIndicator = (0,
|
|
3187
|
+
const spacer = (0, import_react23.useMemo)(() => createDropIndicatorPosition(), []);
|
|
3188
|
+
const clearSpacer = (0, import_react23.useCallback)(() => spacer.remove(), [spacer]);
|
|
3189
|
+
const positionDropIndicator = (0, import_react23.useCallback)(
|
|
3135
3190
|
(dropTarget, dropZone2 = "end") => {
|
|
3136
3191
|
if (dropZone2 === "end") {
|
|
3137
3192
|
dropTarget.element.after(spacer);
|
|
@@ -3149,7 +3204,7 @@ var useDropIndicator = () => {
|
|
|
3149
3204
|
};
|
|
3150
3205
|
|
|
3151
3206
|
// src/drag-drop/useDragDropIndicator.tsx
|
|
3152
|
-
var
|
|
3207
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3153
3208
|
var NOT_OVERFLOWED2 = ':not([data-overflowed="true"])';
|
|
3154
3209
|
var NOT_HIDDEN2 = ':not([aria-hidden="true"])';
|
|
3155
3210
|
var useDragDropIndicator = ({
|
|
@@ -3160,18 +3215,18 @@ var useDragDropIndicator = ({
|
|
|
3160
3215
|
selected,
|
|
3161
3216
|
viewportRange
|
|
3162
3217
|
}) => {
|
|
3163
|
-
const dragDirectionRef = (0,
|
|
3164
|
-
const dropIndicatorRef = (0,
|
|
3165
|
-
const dropTargetRef = (0,
|
|
3166
|
-
const dropZoneRef = (0,
|
|
3167
|
-
const isScrollable = (0,
|
|
3168
|
-
const dragPosRef = (0,
|
|
3169
|
-
const measuredDropTargets = (0,
|
|
3170
|
-
const overflowMenuShowingRef = (0,
|
|
3171
|
-
const [showOverflow, setShowOverflow] = (0,
|
|
3172
|
-
const [dropIndicator, setDropIndicator] = (0,
|
|
3218
|
+
const dragDirectionRef = (0, import_react24.useRef)();
|
|
3219
|
+
const dropIndicatorRef = (0, import_react24.useRef)(null);
|
|
3220
|
+
const dropTargetRef = (0, import_react24.useRef)(null);
|
|
3221
|
+
const dropZoneRef = (0, import_react24.useRef)("");
|
|
3222
|
+
const isScrollable = (0, import_react24.useRef)(false);
|
|
3223
|
+
const dragPosRef = (0, import_react24.useRef)(-1);
|
|
3224
|
+
const measuredDropTargets = (0, import_react24.useRef)([]);
|
|
3225
|
+
const overflowMenuShowingRef = (0, import_react24.useRef)(false);
|
|
3226
|
+
const [showOverflow, setShowOverflow] = (0, import_react24.useState)(false);
|
|
3227
|
+
const [dropIndicator, setDropIndicator] = (0, import_react24.useState)();
|
|
3173
3228
|
const { clearSpacer, positionDropIndicator } = useDropIndicator();
|
|
3174
|
-
const draggedItemRef = (0,
|
|
3229
|
+
const draggedItemRef = (0, import_react24.useRef)();
|
|
3175
3230
|
const fullItemQuery = `:is(${itemQuery}${NOT_OVERFLOWED2}${NOT_HIDDEN2},[data-overflow-indicator])`;
|
|
3176
3231
|
const indexOf = (dropTarget) => measuredDropTargets.current.findIndex((d) => d.id === dropTarget.id);
|
|
3177
3232
|
const reposition = (dropTarget, distance, indexShift) => {
|
|
@@ -3182,12 +3237,12 @@ var useDragDropIndicator = ({
|
|
|
3182
3237
|
dropTarget.currentIndex += indexShift;
|
|
3183
3238
|
}
|
|
3184
3239
|
};
|
|
3185
|
-
const rangeRef = (0,
|
|
3240
|
+
const rangeRef = (0, import_react24.useRef)();
|
|
3186
3241
|
rangeRef.current = viewportRange;
|
|
3187
|
-
const handleScrollStart = (0,
|
|
3242
|
+
const handleScrollStart = (0, import_react24.useCallback)(() => {
|
|
3188
3243
|
clearSpacer();
|
|
3189
3244
|
}, [clearSpacer]);
|
|
3190
|
-
const handleScrollStop = (0,
|
|
3245
|
+
const handleScrollStop = (0, import_react24.useCallback)(
|
|
3191
3246
|
(scrollDirection, _scrollPos, atEnd) => {
|
|
3192
3247
|
const { current: container } = containerRef;
|
|
3193
3248
|
const { current: draggedItem } = draggedItemRef;
|
|
@@ -3225,7 +3280,7 @@ var useDragDropIndicator = ({
|
|
|
3225
3280
|
// setVizData,
|
|
3226
3281
|
]
|
|
3227
3282
|
);
|
|
3228
|
-
const beginDrag = (0,
|
|
3283
|
+
const beginDrag = (0, import_react24.useCallback)(
|
|
3229
3284
|
(dragElement) => {
|
|
3230
3285
|
if (dragElement.ariaSelected && Array.isArray(selected) && selected.length > 1) {
|
|
3231
3286
|
console.log("its a selected element, and we have a multi select");
|
|
@@ -3271,7 +3326,7 @@ var useDragDropIndicator = ({
|
|
|
3271
3326
|
height: 2
|
|
3272
3327
|
};
|
|
3273
3328
|
setDropIndicator(
|
|
3274
|
-
/* @__PURE__ */ (0,
|
|
3329
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3275
3330
|
Draggable,
|
|
3276
3331
|
{
|
|
3277
3332
|
wrapperClassName: "dropIndicatorContainer",
|
|
@@ -3293,7 +3348,7 @@ var useDragDropIndicator = ({
|
|
|
3293
3348
|
positionDropIndicator
|
|
3294
3349
|
]
|
|
3295
3350
|
);
|
|
3296
|
-
const drag = (0,
|
|
3351
|
+
const drag = (0, import_react24.useCallback)(
|
|
3297
3352
|
(dragPos, mouseMoveDirection) => {
|
|
3298
3353
|
const { current: currentDropTarget } = dropTargetRef;
|
|
3299
3354
|
const { current: draggedItem } = draggedItemRef;
|
|
@@ -3339,7 +3394,7 @@ var useDragDropIndicator = ({
|
|
|
3339
3394
|
},
|
|
3340
3395
|
[containerRef, orientation, positionDropIndicator]
|
|
3341
3396
|
);
|
|
3342
|
-
const drop = (0,
|
|
3397
|
+
const drop = (0, import_react24.useCallback)(() => {
|
|
3343
3398
|
clearSpacer();
|
|
3344
3399
|
const { current: draggedItem } = draggedItemRef;
|
|
3345
3400
|
const { current: dropTarget } = dropTargetRef;
|
|
@@ -3384,7 +3439,7 @@ var useDragDropIndicator = ({
|
|
|
3384
3439
|
}
|
|
3385
3440
|
setShowOverflow(false);
|
|
3386
3441
|
}, [clearSpacer, onDrop]);
|
|
3387
|
-
const releaseDrag = (0,
|
|
3442
|
+
const releaseDrag = (0, import_react24.useCallback)(() => {
|
|
3388
3443
|
}, []);
|
|
3389
3444
|
return {
|
|
3390
3445
|
beginDrag,
|
|
@@ -3399,20 +3454,20 @@ var useDragDropIndicator = ({
|
|
|
3399
3454
|
};
|
|
3400
3455
|
|
|
3401
3456
|
// src/drag-drop/useDragDropNext.tsx
|
|
3402
|
-
var
|
|
3457
|
+
var import_react26 = require("react");
|
|
3403
3458
|
|
|
3404
3459
|
// src/drag-drop/useAutoScroll.ts
|
|
3405
|
-
var
|
|
3460
|
+
var import_react25 = require("react");
|
|
3406
3461
|
var useAutoScroll = ({
|
|
3407
3462
|
containerRef,
|
|
3408
3463
|
onScrollingStopped,
|
|
3409
3464
|
orientation = "vertical"
|
|
3410
3465
|
}) => {
|
|
3411
|
-
const scrollTimer = (0,
|
|
3412
|
-
const isScrolling = (0,
|
|
3413
|
-
const scrollPosRef = (0,
|
|
3414
|
-
const lastScrollDirectionRef = (0,
|
|
3415
|
-
const stopScrolling = (0,
|
|
3466
|
+
const scrollTimer = (0, import_react25.useRef)(null);
|
|
3467
|
+
const isScrolling = (0, import_react25.useRef)(false);
|
|
3468
|
+
const scrollPosRef = (0, import_react25.useRef)(0);
|
|
3469
|
+
const lastScrollDirectionRef = (0, import_react25.useRef)("fwd");
|
|
3470
|
+
const stopScrolling = (0, import_react25.useCallback)(
|
|
3416
3471
|
(atEnd = false) => {
|
|
3417
3472
|
console.log("[useAutoScroll] stopScrolling");
|
|
3418
3473
|
if (scrollTimer.current !== null) {
|
|
@@ -3428,7 +3483,7 @@ var useAutoScroll = ({
|
|
|
3428
3483
|
},
|
|
3429
3484
|
[onScrollingStopped]
|
|
3430
3485
|
);
|
|
3431
|
-
const startScrolling = (0,
|
|
3486
|
+
const startScrolling = (0, import_react25.useCallback)(
|
|
3432
3487
|
(direction, scrollRate, scrollUnit = 30) => {
|
|
3433
3488
|
const { current: container } = containerRef;
|
|
3434
3489
|
if (container) {
|
|
@@ -3467,7 +3522,7 @@ var useAutoScroll = ({
|
|
|
3467
3522
|
};
|
|
3468
3523
|
|
|
3469
3524
|
// src/drag-drop/useDragDropNext.tsx
|
|
3470
|
-
var
|
|
3525
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3471
3526
|
var NULL_DRAG_DROP_RESULT = {
|
|
3472
3527
|
beginDrag: () => void 0,
|
|
3473
3528
|
drag: () => void 0,
|
|
@@ -3508,26 +3563,26 @@ var useDragDropNext = ({
|
|
|
3508
3563
|
orientation,
|
|
3509
3564
|
...dragDropProps
|
|
3510
3565
|
}) => {
|
|
3511
|
-
const dragBoundaries = (0,
|
|
3566
|
+
const dragBoundaries = (0, import_react26.useRef)({
|
|
3512
3567
|
start: 0,
|
|
3513
3568
|
end: 0,
|
|
3514
3569
|
contraStart: 0,
|
|
3515
3570
|
contraEnd: 0
|
|
3516
3571
|
});
|
|
3517
|
-
const [draggableStatus, setDraggableStatus] = (0,
|
|
3572
|
+
const [draggableStatus, setDraggableStatus] = (0, import_react26.useState)({
|
|
3518
3573
|
draggable: void 0,
|
|
3519
3574
|
draggedItemIndex: -1,
|
|
3520
3575
|
isDragging: false
|
|
3521
3576
|
});
|
|
3522
|
-
const dragDropStateRef = (0,
|
|
3523
|
-
const mouseDownTimer = (0,
|
|
3524
|
-
const isScrollableRef = (0,
|
|
3525
|
-
const mousePosRef = (0,
|
|
3526
|
-
const startPosRef = (0,
|
|
3527
|
-
const settlingItemRef = (0,
|
|
3528
|
-
const dropPosRef = (0,
|
|
3529
|
-
const dropIndexRef = (0,
|
|
3530
|
-
const handleScrollStopRef = (0,
|
|
3577
|
+
const dragDropStateRef = (0, import_react26.useRef)(null);
|
|
3578
|
+
const mouseDownTimer = (0, import_react26.useRef)(null);
|
|
3579
|
+
const isScrollableRef = (0, import_react26.useRef)(false);
|
|
3580
|
+
const mousePosRef = (0, import_react26.useRef)({ x: 0, y: 0 });
|
|
3581
|
+
const startPosRef = (0, import_react26.useRef)({ x: 0, y: 0 });
|
|
3582
|
+
const settlingItemRef = (0, import_react26.useRef)(null);
|
|
3583
|
+
const dropPosRef = (0, import_react26.useRef)(-1);
|
|
3584
|
+
const dropIndexRef = (0, import_react26.useRef)(-1);
|
|
3585
|
+
const handleScrollStopRef = (0, import_react26.useRef)();
|
|
3531
3586
|
const {
|
|
3532
3587
|
isDragSource,
|
|
3533
3588
|
isDropTarget,
|
|
@@ -3535,9 +3590,10 @@ var useDragDropNext = ({
|
|
|
3535
3590
|
onEndOfDragOperation,
|
|
3536
3591
|
register
|
|
3537
3592
|
} = useDragDropProvider(id);
|
|
3538
|
-
const dragMouseMoveHandlerRef = (0,
|
|
3539
|
-
const dragMouseUpHandlerRef = (0,
|
|
3540
|
-
const attachDragHandlers = (0,
|
|
3593
|
+
const dragMouseMoveHandlerRef = (0, import_react26.useRef)();
|
|
3594
|
+
const dragMouseUpHandlerRef = (0, import_react26.useRef)();
|
|
3595
|
+
const attachDragHandlers = (0, import_react26.useCallback)(() => {
|
|
3596
|
+
console.log("attach drag handlers");
|
|
3541
3597
|
const { current: dragMove } = dragMouseMoveHandlerRef;
|
|
3542
3598
|
const { current: dragUp } = dragMouseUpHandlerRef;
|
|
3543
3599
|
if (dragMove && dragUp) {
|
|
@@ -3545,15 +3601,17 @@ var useDragDropNext = ({
|
|
|
3545
3601
|
document.addEventListener("mouseup", dragUp, false);
|
|
3546
3602
|
}
|
|
3547
3603
|
}, []);
|
|
3548
|
-
const removeDragHandlers = (0,
|
|
3604
|
+
const removeDragHandlers = (0, import_react26.useCallback)(() => {
|
|
3605
|
+
console.log("remove drag handlers");
|
|
3549
3606
|
const { current: dragMove } = dragMouseMoveHandlerRef;
|
|
3550
3607
|
const { current: dragUp } = dragMouseUpHandlerRef;
|
|
3551
3608
|
if (dragMove && dragUp) {
|
|
3609
|
+
console.log("... we have both handlers");
|
|
3552
3610
|
document.removeEventListener("mousemove", dragMove, false);
|
|
3553
3611
|
document.removeEventListener("mouseup", dragUp, false);
|
|
3554
3612
|
}
|
|
3555
3613
|
}, []);
|
|
3556
|
-
const setDragBoundaries = (0,
|
|
3614
|
+
const setDragBoundaries = (0, import_react26.useCallback)(
|
|
3557
3615
|
(containerRect, draggableRect) => {
|
|
3558
3616
|
const { current: container } = containerRef;
|
|
3559
3617
|
if (container) {
|
|
@@ -3572,10 +3630,10 @@ var useDragDropNext = ({
|
|
|
3572
3630
|
},
|
|
3573
3631
|
[containerRef, itemQuery, orientation]
|
|
3574
3632
|
);
|
|
3575
|
-
const terminateDrag = (0,
|
|
3576
|
-
var
|
|
3633
|
+
const terminateDrag = (0, import_react26.useCallback)(() => {
|
|
3634
|
+
var _a2;
|
|
3577
3635
|
const { current: toIndex } = dropIndexRef;
|
|
3578
|
-
const droppedItem = (
|
|
3636
|
+
const droppedItem = (_a2 = containerRef.current) == null ? void 0 : _a2.querySelector(
|
|
3579
3637
|
`${itemQuery}[data-index="${toIndex}"]`
|
|
3580
3638
|
);
|
|
3581
3639
|
if (droppedItem) {
|
|
@@ -3588,7 +3646,7 @@ var useDragDropNext = ({
|
|
|
3588
3646
|
draggable: void 0
|
|
3589
3647
|
}));
|
|
3590
3648
|
}, [containerRef, itemQuery, onDropSettle]);
|
|
3591
|
-
const getScrollDirection = (0,
|
|
3649
|
+
const getScrollDirection = (0, import_react26.useCallback)(
|
|
3592
3650
|
(mousePos) => {
|
|
3593
3651
|
if (containerRef.current && dragDropStateRef.current) {
|
|
3594
3652
|
const { mouseOffset } = dragDropStateRef.current;
|
|
@@ -3609,10 +3667,10 @@ var useDragDropNext = ({
|
|
|
3609
3667
|
[containerRef, orientation]
|
|
3610
3668
|
);
|
|
3611
3669
|
const useDragDropHook = allowDragDrop === true || allowDragDrop === "natural-movement" ? useDragDropNaturalMovement : allowDragDrop === "drop-indicator" ? useDragDropIndicator : noDragDrop;
|
|
3612
|
-
const onScrollingStopped = (0,
|
|
3670
|
+
const onScrollingStopped = (0, import_react26.useCallback)(
|
|
3613
3671
|
(scrollDirection, scrollPos, atEnd) => {
|
|
3614
|
-
var
|
|
3615
|
-
(
|
|
3672
|
+
var _a2;
|
|
3673
|
+
(_a2 = handleScrollStopRef.current) == null ? void 0 : _a2.call(handleScrollStopRef, scrollDirection, scrollPos, atEnd);
|
|
3616
3674
|
},
|
|
3617
3675
|
[]
|
|
3618
3676
|
);
|
|
@@ -3621,14 +3679,14 @@ var useDragDropNext = ({
|
|
|
3621
3679
|
onScrollingStopped,
|
|
3622
3680
|
orientation
|
|
3623
3681
|
});
|
|
3624
|
-
const handleDrop = (0,
|
|
3682
|
+
const handleDrop = (0, import_react26.useCallback)(
|
|
3625
3683
|
(fromIndex, toIndex, options) => {
|
|
3626
|
-
var
|
|
3684
|
+
var _a2;
|
|
3627
3685
|
dropPosRef.current = toIndex;
|
|
3628
3686
|
if (options.isExternal) {
|
|
3629
3687
|
onDrop == null ? void 0 : onDrop(fromIndex, toIndex, {
|
|
3630
3688
|
...options,
|
|
3631
|
-
payload: (
|
|
3689
|
+
payload: (_a2 = dragDropStateRef.current) == null ? void 0 : _a2.payload
|
|
3632
3690
|
});
|
|
3633
3691
|
} else {
|
|
3634
3692
|
onDrop == null ? void 0 : onDrop(fromIndex, toIndex, options);
|
|
@@ -3660,7 +3718,7 @@ var useDragDropNext = ({
|
|
|
3660
3718
|
orientation
|
|
3661
3719
|
});
|
|
3662
3720
|
handleScrollStopRef.current = handleScrollStop;
|
|
3663
|
-
const dragHandedOvertoProvider = (0,
|
|
3721
|
+
const dragHandedOvertoProvider = (0, import_react26.useCallback)(
|
|
3664
3722
|
(dragDistance, clientContraPos) => {
|
|
3665
3723
|
const { CONTRA_POS } = dimensions(orientation);
|
|
3666
3724
|
const lastClientContraPos = mousePosRef.current[CONTRA_POS];
|
|
@@ -3677,7 +3735,7 @@ var useDragDropNext = ({
|
|
|
3677
3735
|
},
|
|
3678
3736
|
[id, isDragSource, onDragOut, orientation, releaseDrag, removeDragHandlers]
|
|
3679
3737
|
);
|
|
3680
|
-
const dragMouseMoveHandler = (0,
|
|
3738
|
+
const dragMouseMoveHandler = (0, import_react26.useCallback)(
|
|
3681
3739
|
(evt) => {
|
|
3682
3740
|
const { CLIENT_POS, CONTRA_CLIENT_POS, POS } = dimensions(orientation);
|
|
3683
3741
|
const { clientX, clientY } = evt;
|
|
@@ -3736,7 +3794,7 @@ var useDragDropNext = ({
|
|
|
3736
3794
|
stopScrolling
|
|
3737
3795
|
]
|
|
3738
3796
|
);
|
|
3739
|
-
const dragMouseUpHandler = (0,
|
|
3797
|
+
const dragMouseUpHandler = (0, import_react26.useCallback)(() => {
|
|
3740
3798
|
removeDragHandlers();
|
|
3741
3799
|
if (dragDropStateRef.current) {
|
|
3742
3800
|
settlingItemRef.current = dragDropStateRef.current.draggableElement;
|
|
@@ -3750,12 +3808,11 @@ var useDragDropNext = ({
|
|
|
3750
3808
|
}, [drop, removeDragHandlers]);
|
|
3751
3809
|
dragMouseMoveHandlerRef.current = dragMouseMoveHandler;
|
|
3752
3810
|
dragMouseUpHandlerRef.current = dragMouseUpHandler;
|
|
3753
|
-
const resumeDrag = (0,
|
|
3811
|
+
const resumeDrag = (0, import_react26.useCallback)(
|
|
3754
3812
|
(dragDropState) => {
|
|
3755
3813
|
dragDropStateRef.current = dragDropState;
|
|
3756
3814
|
const { draggableElement, mouseOffset, initialDragElement } = dragDropState;
|
|
3757
3815
|
const { current: container } = containerRef;
|
|
3758
|
-
console.log({ container, draggableElement, initialDragElement });
|
|
3759
3816
|
if (container && draggableElement) {
|
|
3760
3817
|
const containerRect = container.getBoundingClientRect();
|
|
3761
3818
|
const draggableRect = draggableElement.getBoundingClientRect();
|
|
@@ -3771,7 +3828,7 @@ var useDragDropNext = ({
|
|
|
3771
3828
|
},
|
|
3772
3829
|
[attachDragHandlers, beginDrag, containerRef, setDragBoundaries]
|
|
3773
3830
|
);
|
|
3774
|
-
const dragStart = (0,
|
|
3831
|
+
const dragStart = (0, import_react26.useCallback)(
|
|
3775
3832
|
(evt) => {
|
|
3776
3833
|
const { target } = evt;
|
|
3777
3834
|
const dragElement = getDraggableElement(target, itemQuery);
|
|
@@ -3793,7 +3850,7 @@ var useDragDropNext = ({
|
|
|
3793
3850
|
} = dragElement;
|
|
3794
3851
|
setDraggableStatus({
|
|
3795
3852
|
isDragging: true,
|
|
3796
|
-
draggable: /* @__PURE__ */ (0,
|
|
3853
|
+
draggable: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3797
3854
|
Draggable,
|
|
3798
3855
|
{
|
|
3799
3856
|
element: cloneElement3(dragElement),
|
|
@@ -3821,7 +3878,7 @@ var useDragDropNext = ({
|
|
|
3821
3878
|
terminateDrag
|
|
3822
3879
|
]
|
|
3823
3880
|
);
|
|
3824
|
-
const preDragMouseMoveHandler = (0,
|
|
3881
|
+
const preDragMouseMoveHandler = (0, import_react26.useCallback)(
|
|
3825
3882
|
(evt) => {
|
|
3826
3883
|
const { CLIENT_POS, POS } = dimensions(orientation);
|
|
3827
3884
|
const { [CLIENT_POS]: clientPos } = evt;
|
|
@@ -3839,7 +3896,7 @@ var useDragDropNext = ({
|
|
|
3839
3896
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3840
3897
|
[containerRef, beginDrag, orientation]
|
|
3841
3898
|
);
|
|
3842
|
-
const preDragMouseUpHandler = (0,
|
|
3899
|
+
const preDragMouseUpHandler = (0, import_react26.useCallback)(() => {
|
|
3843
3900
|
if (mouseDownTimer.current) {
|
|
3844
3901
|
window.clearTimeout(mouseDownTimer.current);
|
|
3845
3902
|
mouseDownTimer.current = null;
|
|
@@ -3847,7 +3904,7 @@ var useDragDropNext = ({
|
|
|
3847
3904
|
document.removeEventListener("mousemove", preDragMouseMoveHandler, false);
|
|
3848
3905
|
document.removeEventListener("mouseup", preDragMouseUpHandler, false);
|
|
3849
3906
|
}, [preDragMouseMoveHandler]);
|
|
3850
|
-
const mouseDownHandler = (0,
|
|
3907
|
+
const mouseDownHandler = (0, import_react26.useCallback)(
|
|
3851
3908
|
(evt) => {
|
|
3852
3909
|
const { current: container } = containerRef;
|
|
3853
3910
|
evt.stopPropagation();
|
|
@@ -3872,7 +3929,7 @@ var useDragDropNext = ({
|
|
|
3872
3929
|
[containerRef, dragStart, preDragMouseMoveHandler, preDragMouseUpHandler]
|
|
3873
3930
|
);
|
|
3874
3931
|
const { current: settlingItem } = settlingItemRef;
|
|
3875
|
-
(0,
|
|
3932
|
+
(0, import_react26.useLayoutEffect)(() => {
|
|
3876
3933
|
if (settlingItem && containerRef.current) {
|
|
3877
3934
|
const dropPos = dropPosRef.current;
|
|
3878
3935
|
const droppedItem = containerRef.current.querySelector(
|
|
@@ -3897,7 +3954,7 @@ var useDragDropNext = ({
|
|
|
3897
3954
|
settlingItemRef.current = null;
|
|
3898
3955
|
}
|
|
3899
3956
|
}, [containerRef, itemQuery, settlingItem, terminateDrag]);
|
|
3900
|
-
(0,
|
|
3957
|
+
(0, import_react26.useEffect)(() => {
|
|
3901
3958
|
if (id && (isDragSource || isDropTarget)) {
|
|
3902
3959
|
register(id, resumeDrag);
|
|
3903
3960
|
}
|
|
@@ -3910,6 +3967,90 @@ var useDragDropNext = ({
|
|
|
3910
3967
|
};
|
|
3911
3968
|
};
|
|
3912
3969
|
|
|
3970
|
+
// src/list/useListDrop.ts
|
|
3971
|
+
var import_react27 = require("react");
|
|
3972
|
+
var useListDrop = ({
|
|
3973
|
+
dataHook,
|
|
3974
|
+
onDrop,
|
|
3975
|
+
onMoveListItem,
|
|
3976
|
+
selected,
|
|
3977
|
+
setHighlightedIndex,
|
|
3978
|
+
setSelected
|
|
3979
|
+
}) => {
|
|
3980
|
+
const selectedByIndexRef = (0, import_react27.useRef)([]);
|
|
3981
|
+
const dataHookRef = (0, import_react27.useRef)(dataHook);
|
|
3982
|
+
dataHookRef.current = dataHook;
|
|
3983
|
+
const adjustIndex = (0, import_react27.useCallback)(
|
|
3984
|
+
(index, fromIndex, toIndex) => {
|
|
3985
|
+
if (index === fromIndex) {
|
|
3986
|
+
return toIndex;
|
|
3987
|
+
} else if (index < Math.min(fromIndex, toIndex) || index > Math.max(fromIndex, toIndex)) {
|
|
3988
|
+
return index;
|
|
3989
|
+
}
|
|
3990
|
+
if (fromIndex < index) {
|
|
3991
|
+
return index - 1;
|
|
3992
|
+
} else {
|
|
3993
|
+
return index + 1;
|
|
3994
|
+
}
|
|
3995
|
+
},
|
|
3996
|
+
[]
|
|
3997
|
+
);
|
|
3998
|
+
const reorderSelectedIndices = (0, import_react27.useCallback)(
|
|
3999
|
+
(selected2, fromIndex, toIndex) => {
|
|
4000
|
+
const selectedIndices = selected2.map(
|
|
4001
|
+
(id) => dataHookRef.current.indexOfItemById(id)
|
|
4002
|
+
);
|
|
4003
|
+
return selectedIndices.map(
|
|
4004
|
+
(item) => adjustIndex(item, fromIndex, toIndex)
|
|
4005
|
+
);
|
|
4006
|
+
},
|
|
4007
|
+
[adjustIndex]
|
|
4008
|
+
);
|
|
4009
|
+
const handleDrop = (0, import_react27.useCallback)(
|
|
4010
|
+
(fromIndex, toIndex, options) => {
|
|
4011
|
+
if (hasSelection(selected)) {
|
|
4012
|
+
selectedByIndexRef.current = reorderSelectedIndices(
|
|
4013
|
+
selected,
|
|
4014
|
+
fromIndex,
|
|
4015
|
+
toIndex
|
|
4016
|
+
);
|
|
4017
|
+
}
|
|
4018
|
+
if (options.isExternal) {
|
|
4019
|
+
onDrop == null ? void 0 : onDrop(fromIndex, toIndex, options);
|
|
4020
|
+
} else {
|
|
4021
|
+
onMoveListItem == null ? void 0 : onMoveListItem(fromIndex, toIndex);
|
|
4022
|
+
}
|
|
4023
|
+
setHighlightedIndex(-1);
|
|
4024
|
+
},
|
|
4025
|
+
[
|
|
4026
|
+
selected,
|
|
4027
|
+
setHighlightedIndex,
|
|
4028
|
+
reorderSelectedIndices,
|
|
4029
|
+
onDrop,
|
|
4030
|
+
onMoveListItem
|
|
4031
|
+
]
|
|
4032
|
+
);
|
|
4033
|
+
const handleDropSettle = (0, import_react27.useCallback)(
|
|
4034
|
+
(toIndex) => {
|
|
4035
|
+
setHighlightedIndex(toIndex);
|
|
4036
|
+
},
|
|
4037
|
+
[setHighlightedIndex]
|
|
4038
|
+
);
|
|
4039
|
+
(0, import_react27.useEffect)(() => {
|
|
4040
|
+
const { current: selectedByIndex } = selectedByIndexRef;
|
|
4041
|
+
if (hasSelection(selectedByIndex)) {
|
|
4042
|
+
selectedByIndexRef.current = [];
|
|
4043
|
+
const postDropSelected = Array.isArray(selectedByIndex) ? selectedByIndex.map((i) => dataHook.data[i].id) : dataHook.data[selectedByIndex].id;
|
|
4044
|
+
selectedByIndexRef.current = [];
|
|
4045
|
+
setSelected(postDropSelected);
|
|
4046
|
+
}
|
|
4047
|
+
}, [dataHook.data, setSelected]);
|
|
4048
|
+
return {
|
|
4049
|
+
handleDrop,
|
|
4050
|
+
onDropSettle: handleDropSettle
|
|
4051
|
+
};
|
|
4052
|
+
};
|
|
4053
|
+
|
|
3913
4054
|
// src/list/useList.ts
|
|
3914
4055
|
var useList = ({
|
|
3915
4056
|
allowDragDrop = false,
|
|
@@ -3944,14 +4085,15 @@ var useList = ({
|
|
|
3944
4085
|
tabToSelect,
|
|
3945
4086
|
viewportRange
|
|
3946
4087
|
}) => {
|
|
3947
|
-
const
|
|
3948
|
-
|
|
4088
|
+
const lastSelection = (0, import_react28.useRef)(
|
|
4089
|
+
selected || defaultSelected
|
|
4090
|
+
);
|
|
3949
4091
|
const handleKeyboardNavigation = (evt, nextIndex) => {
|
|
3950
|
-
var
|
|
3951
|
-
(_b = (
|
|
4092
|
+
var _a2, _b;
|
|
4093
|
+
(_b = (_a2 = selectionHook.listHandlers).onKeyboardNavigation) == null ? void 0 : _b.call(_a2, evt, nextIndex);
|
|
3952
4094
|
onKeyboardNavigation == null ? void 0 : onKeyboardNavigation(evt, nextIndex);
|
|
3953
4095
|
};
|
|
3954
|
-
const handleSelect = (0,
|
|
4096
|
+
const handleSelect = (0, import_react28.useCallback)(
|
|
3955
4097
|
(evt, selectedId) => {
|
|
3956
4098
|
if (onSelect) {
|
|
3957
4099
|
if (selectedId !== null) {
|
|
@@ -3961,29 +4103,35 @@ var useList = ({
|
|
|
3961
4103
|
},
|
|
3962
4104
|
[dataHook, onSelect]
|
|
3963
4105
|
);
|
|
3964
|
-
const scrollContainer = (0,
|
|
3965
|
-
var
|
|
4106
|
+
const scrollContainer = (0, import_react28.useMemo)(() => {
|
|
4107
|
+
var _a2, _b;
|
|
3966
4108
|
if (scrollContainerRef) {
|
|
3967
4109
|
return scrollContainerRef;
|
|
3968
4110
|
} else {
|
|
3969
4111
|
return {
|
|
3970
|
-
current: (_b = (
|
|
4112
|
+
current: (_b = (_a2 = containerRef.current) == null ? void 0 : _a2.querySelector(".vuuList-scrollContainer")) != null ? _b : null
|
|
3971
4113
|
};
|
|
3972
4114
|
}
|
|
3973
|
-
}, []);
|
|
3974
|
-
const handleSelectionChange = (0,
|
|
4115
|
+
}, [containerRef, scrollContainerRef]);
|
|
4116
|
+
const handleSelectionChange = (0, import_react28.useCallback)(
|
|
3975
4117
|
(evt, selected2) => {
|
|
3976
4118
|
if (onSelectionChange) {
|
|
3977
|
-
if (
|
|
4119
|
+
if (isSingleSelection(selectionStrategy)) {
|
|
4120
|
+
const [selectedItem] = selected2;
|
|
4121
|
+
onSelectionChange(
|
|
4122
|
+
evt,
|
|
4123
|
+
dataHook.itemById(selectedItem)
|
|
4124
|
+
);
|
|
4125
|
+
} else if (isMultiSelection(selectionStrategy)) {
|
|
3978
4126
|
const selectedItems = selected2.map((id2) => dataHook.itemById(id2));
|
|
3979
|
-
onSelectionChange(
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
4127
|
+
onSelectionChange(
|
|
4128
|
+
evt,
|
|
4129
|
+
selectedItems
|
|
4130
|
+
);
|
|
3983
4131
|
}
|
|
3984
4132
|
}
|
|
3985
4133
|
},
|
|
3986
|
-
[dataHook, onSelectionChange]
|
|
4134
|
+
[dataHook, onSelectionChange, selectionStrategy]
|
|
3987
4135
|
);
|
|
3988
4136
|
const {
|
|
3989
4137
|
highlightedIndex,
|
|
@@ -4013,7 +4161,7 @@ var useList = ({
|
|
|
4013
4161
|
highlightedIdx: highlightedIndex,
|
|
4014
4162
|
collectionHook: dataHook
|
|
4015
4163
|
});
|
|
4016
|
-
const handleDragStart = (0,
|
|
4164
|
+
const handleDragStart = (0, import_react28.useCallback)(
|
|
4017
4165
|
(dragDropState) => {
|
|
4018
4166
|
setHighlightedIndex(-1);
|
|
4019
4167
|
onDragStart == null ? void 0 : onDragStart(dragDropState);
|
|
@@ -4033,76 +4181,20 @@ var useList = ({
|
|
|
4033
4181
|
selectionKeys,
|
|
4034
4182
|
tabToSelect
|
|
4035
4183
|
});
|
|
4036
|
-
const
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
if (fromIndex < index) {
|
|
4045
|
-
return index - 1;
|
|
4046
|
-
} else {
|
|
4047
|
-
return index + 1;
|
|
4048
|
-
}
|
|
4049
|
-
},
|
|
4050
|
-
[dataHook.data]
|
|
4051
|
-
);
|
|
4052
|
-
const reorderSelectedIndices = (0, import_react26.useCallback)(
|
|
4053
|
-
(selected2, fromIndex, toIndex) => {
|
|
4054
|
-
if (Array.isArray(selected2)) {
|
|
4055
|
-
return selected2.map((item) => adjustIndex(item, fromIndex, toIndex));
|
|
4056
|
-
} else {
|
|
4057
|
-
return adjustIndex(selected2, fromIndex, toIndex);
|
|
4058
|
-
}
|
|
4059
|
-
},
|
|
4060
|
-
[adjustIndex]
|
|
4061
|
-
);
|
|
4062
|
-
const handleDrop = (0, import_react26.useCallback)(
|
|
4063
|
-
(fromIndex, toIndex, options) => {
|
|
4064
|
-
if (hasSelection(selectionHook.selected)) {
|
|
4065
|
-
selectedByIndexRef.current = reorderSelectedIndices(
|
|
4066
|
-
selectionHook.selected,
|
|
4067
|
-
fromIndex,
|
|
4068
|
-
toIndex
|
|
4069
|
-
);
|
|
4070
|
-
}
|
|
4071
|
-
if (options.isExternal) {
|
|
4072
|
-
onDrop == null ? void 0 : onDrop(fromIndex, toIndex, options);
|
|
4073
|
-
} else {
|
|
4074
|
-
onMoveListItem == null ? void 0 : onMoveListItem(fromIndex, toIndex);
|
|
4075
|
-
}
|
|
4076
|
-
setHighlightedIndex(-1);
|
|
4077
|
-
},
|
|
4078
|
-
[
|
|
4079
|
-
selectionHook.selected,
|
|
4080
|
-
setHighlightedIndex,
|
|
4081
|
-
reorderSelectedIndices,
|
|
4082
|
-
onDrop,
|
|
4083
|
-
onMoveListItem
|
|
4084
|
-
]
|
|
4085
|
-
);
|
|
4086
|
-
const handleDropSettle = (0, import_react26.useCallback)(
|
|
4087
|
-
(toIndex) => {
|
|
4088
|
-
setHighlightedIndex(toIndex);
|
|
4089
|
-
},
|
|
4090
|
-
[setHighlightedIndex]
|
|
4091
|
-
);
|
|
4184
|
+
const { handleDrop, onDropSettle } = useListDrop({
|
|
4185
|
+
dataHook,
|
|
4186
|
+
onDrop,
|
|
4187
|
+
onMoveListItem,
|
|
4188
|
+
selected: selectionHook.selected,
|
|
4189
|
+
setHighlightedIndex,
|
|
4190
|
+
setSelected: selectionHook.setSelected
|
|
4191
|
+
});
|
|
4092
4192
|
const { setSelected } = selectionHook;
|
|
4093
|
-
(0, import_react26.useEffect)(() => {
|
|
4094
|
-
const { current: selectedByIndex } = selectedByIndexRef;
|
|
4095
|
-
if (hasSelection(selectedByIndex)) {
|
|
4096
|
-
const postDropSelected = Array.isArray(selectedByIndex) ? selectedByIndex.map((i) => dataHook.data[i]) : dataHook.data[selectedByIndex];
|
|
4097
|
-
selectedByIndexRef.current = null;
|
|
4098
|
-
setSelected(postDropSelected);
|
|
4099
|
-
}
|
|
4100
|
-
}, [dataHook.data, setSelected]);
|
|
4101
4193
|
(0, import_vuu_layout2.useLayoutEffectSkipFirst)(() => {
|
|
4102
4194
|
if (hasSelection(lastSelection.current)) {
|
|
4103
|
-
setSelected(
|
|
4195
|
+
setSelected([]);
|
|
4104
4196
|
}
|
|
4105
|
-
}, [
|
|
4197
|
+
}, [selected, dataHook.data, setSelected]);
|
|
4106
4198
|
const {
|
|
4107
4199
|
onMouseDown,
|
|
4108
4200
|
isDragging,
|
|
@@ -4117,8 +4209,7 @@ var useList = ({
|
|
|
4117
4209
|
itemQuery: ".vuuListItem",
|
|
4118
4210
|
onDragStart: handleDragStart,
|
|
4119
4211
|
onDrop: handleDrop,
|
|
4120
|
-
onDropSettle
|
|
4121
|
-
// selected: selectionHook.selected,
|
|
4212
|
+
onDropSettle,
|
|
4122
4213
|
viewportRange
|
|
4123
4214
|
});
|
|
4124
4215
|
const { onKeyDown: typeaheadOnKeyDown } = useTypeahead({
|
|
@@ -4128,15 +4219,15 @@ var useList = ({
|
|
|
4128
4219
|
typeToNavigate: true,
|
|
4129
4220
|
items: dataHook.data
|
|
4130
4221
|
});
|
|
4131
|
-
const handleKeyDown = (0,
|
|
4222
|
+
const handleKeyDown = (0, import_react28.useCallback)(
|
|
4132
4223
|
(evt) => {
|
|
4133
|
-
var
|
|
4224
|
+
var _a2, _b, _c;
|
|
4134
4225
|
if (!evt.defaultPrevented) {
|
|
4135
4226
|
typeaheadOnKeyDown == null ? void 0 : typeaheadOnKeyDown(evt);
|
|
4136
4227
|
}
|
|
4137
4228
|
navigationKeyDown(evt);
|
|
4138
4229
|
if (!evt.defaultPrevented) {
|
|
4139
|
-
(_b = (
|
|
4230
|
+
(_b = (_a2 = selectionHook.listHandlers).onKeyDown) == null ? void 0 : _b.call(_a2, evt);
|
|
4140
4231
|
}
|
|
4141
4232
|
if (!evt.defaultPrevented) {
|
|
4142
4233
|
(_c = collapsibleHook == null ? void 0 : collapsibleHook.onKeyDown) == null ? void 0 : _c.call(collapsibleHook, evt);
|
|
@@ -4161,7 +4252,7 @@ var useList = ({
|
|
|
4161
4252
|
stickyHeaders
|
|
4162
4253
|
});
|
|
4163
4254
|
const isScrolling = isViewportScrolling.current || isDragDropScrolling.current;
|
|
4164
|
-
const handleMouseMove = (0,
|
|
4255
|
+
const handleMouseMove = (0, import_react28.useCallback)(
|
|
4165
4256
|
(evt) => {
|
|
4166
4257
|
if (!isScrolling && !disabled && !isDragging) {
|
|
4167
4258
|
navigationMouseMove();
|
|
@@ -4187,8 +4278,8 @@ var useList = ({
|
|
|
4187
4278
|
]
|
|
4188
4279
|
);
|
|
4189
4280
|
const getActiveDescendant = () => {
|
|
4190
|
-
var
|
|
4191
|
-
return highlightedIndex === void 0 || highlightedIndex === -1 || disableAriaActiveDescendant ? void 0 : (
|
|
4281
|
+
var _a2;
|
|
4282
|
+
return highlightedIndex === void 0 || highlightedIndex === -1 || disableAriaActiveDescendant ? void 0 : (_a2 = dataHook.data[highlightedIndex]) == null ? void 0 : _a2.id;
|
|
4192
4283
|
};
|
|
4193
4284
|
lastSelection.current = selectionHook.selected;
|
|
4194
4285
|
const listControlProps = {
|
|
@@ -4216,6 +4307,7 @@ var useList = ({
|
|
|
4216
4307
|
listItemHeaderHandlers: collapsibleHook,
|
|
4217
4308
|
listControlProps,
|
|
4218
4309
|
scrollIntoView,
|
|
4310
|
+
//TODO given that we firs onSelect and onSelectionCHange with Item(s), should we return Item(s) here ?
|
|
4219
4311
|
selected: selectionHook.selected,
|
|
4220
4312
|
setHighlightedIndex,
|
|
4221
4313
|
setIgnoreFocus: keyboardHook.setIgnoreFocus,
|
|
@@ -4225,7 +4317,7 @@ var useList = ({
|
|
|
4225
4317
|
};
|
|
4226
4318
|
|
|
4227
4319
|
// src/list/useListHeight.ts
|
|
4228
|
-
var
|
|
4320
|
+
var import_react29 = require("react");
|
|
4229
4321
|
var getContentHeight = (itemCount, itemHeight, itemGapSize = 0) => {
|
|
4230
4322
|
if (itemCount === 0) {
|
|
4231
4323
|
return 0;
|
|
@@ -4245,14 +4337,13 @@ var useListHeight = ({
|
|
|
4245
4337
|
itemHeight: itemHeightProp = 36,
|
|
4246
4338
|
size
|
|
4247
4339
|
}) => {
|
|
4248
|
-
const [measuredItemHeight, setMeasuredItemHeight] = (0,
|
|
4249
|
-
const [, forceUpdate] = (0,
|
|
4250
|
-
const proxyItemRef = (0,
|
|
4251
|
-
const [contentHeight, computedListHeight] = (0,
|
|
4340
|
+
const [measuredItemHeight, setMeasuredItemHeight] = (0, import_react29.useState)(itemHeightProp);
|
|
4341
|
+
const [, forceUpdate] = (0, import_react29.useState)({});
|
|
4342
|
+
const proxyItemRef = (0, import_react29.useRef)(null);
|
|
4343
|
+
const [contentHeight, computedListHeight] = (0, import_react29.useMemo)(() => {
|
|
4252
4344
|
let result = 0;
|
|
4253
4345
|
const itemHeight = measuredItemHeight != null ? measuredItemHeight : itemHeightProp;
|
|
4254
4346
|
const contentHeight2 = getContentHeight(itemCount, itemHeight, itemGapSize);
|
|
4255
|
-
console.log(`contentHeight ${contentHeight2}`);
|
|
4256
4347
|
if (height !== void 0) {
|
|
4257
4348
|
return [contentHeight2, void 0];
|
|
4258
4349
|
}
|
|
@@ -4277,12 +4368,12 @@ var useListHeight = ({
|
|
|
4277
4368
|
itemHeightProp,
|
|
4278
4369
|
measuredItemHeight
|
|
4279
4370
|
]);
|
|
4280
|
-
const handleRowHeight = (0,
|
|
4371
|
+
const handleRowHeight = (0, import_react29.useCallback)(({ height: height2 }) => {
|
|
4281
4372
|
if (typeof height2 === "number") {
|
|
4282
4373
|
setMeasuredItemHeight(height2);
|
|
4283
4374
|
}
|
|
4284
4375
|
}, []);
|
|
4285
|
-
const rowHeightProxyRef = (0,
|
|
4376
|
+
const rowHeightProxyRef = (0, import_react29.useCallback)((el) => {
|
|
4286
4377
|
proxyItemRef.current = el;
|
|
4287
4378
|
forceUpdate({});
|
|
4288
4379
|
}, []);
|
|
@@ -4298,7 +4389,7 @@ var useListHeight = ({
|
|
|
4298
4389
|
|
|
4299
4390
|
// src/list/useScrollPosition.ts
|
|
4300
4391
|
var import_core8 = require("@salt-ds/core");
|
|
4301
|
-
var
|
|
4392
|
+
var import_react30 = require("react");
|
|
4302
4393
|
var getRange = (scrollPos, height, itemCount, itemHeight) => {
|
|
4303
4394
|
const viewportRowCount = Math.ceil(height / itemHeight);
|
|
4304
4395
|
const from = Math.floor(scrollPos / itemHeight);
|
|
@@ -4317,10 +4408,10 @@ var useScrollPosition = ({
|
|
|
4317
4408
|
itemSize: listItemHeight,
|
|
4318
4409
|
onViewportScroll
|
|
4319
4410
|
}) => {
|
|
4320
|
-
const firstVisibleRowRef = (0,
|
|
4321
|
-
const lastVisibleRowRef = (0,
|
|
4322
|
-
const scrollPosRef = (0,
|
|
4323
|
-
const range = (0,
|
|
4411
|
+
const firstVisibleRowRef = (0, import_react30.useRef)(0);
|
|
4412
|
+
const lastVisibleRowRef = (0, import_react30.useRef)(0);
|
|
4413
|
+
const scrollPosRef = (0, import_react30.useRef)(0);
|
|
4414
|
+
const range = (0, import_react30.useMemo)(() => {
|
|
4324
4415
|
return getRange(
|
|
4325
4416
|
scrollPosRef.current,
|
|
4326
4417
|
listHeight,
|
|
@@ -4328,11 +4419,11 @@ var useScrollPosition = ({
|
|
|
4328
4419
|
listItemHeight + listItemGapSize
|
|
4329
4420
|
);
|
|
4330
4421
|
}, [listHeight, listItemCount, listItemHeight, listItemGapSize]);
|
|
4331
|
-
const [viewportRange, setViewportRange] = (0,
|
|
4422
|
+
const [viewportRange, setViewportRange] = (0, import_react30.useState)(range);
|
|
4332
4423
|
(0, import_core8.useIsomorphicLayoutEffect)(() => {
|
|
4333
4424
|
setViewportRange(range);
|
|
4334
4425
|
}, [range]);
|
|
4335
|
-
const handleVerticalScroll = (0,
|
|
4426
|
+
const handleVerticalScroll = (0, import_react30.useCallback)(
|
|
4336
4427
|
(e) => {
|
|
4337
4428
|
const scrollTop = e.target.scrollTop;
|
|
4338
4429
|
if (scrollTop !== scrollPosRef.current) {
|
|
@@ -4367,11 +4458,11 @@ var useScrollPosition = ({
|
|
|
4367
4458
|
};
|
|
4368
4459
|
|
|
4369
4460
|
// src/list/List.tsx
|
|
4370
|
-
var
|
|
4371
|
-
var
|
|
4461
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
4462
|
+
var import_react32 = require("react");
|
|
4372
4463
|
var defaultEmptyMessage = "No data to display";
|
|
4373
4464
|
var classBase5 = "vuuList";
|
|
4374
|
-
var List = (0,
|
|
4465
|
+
var List = (0, import_react31.forwardRef)(function List2({
|
|
4375
4466
|
ListItem: ListItem4 = ListItem,
|
|
4376
4467
|
ListPlaceholder,
|
|
4377
4468
|
allowDragDrop,
|
|
@@ -4417,16 +4508,17 @@ var List = (0, import_react29.forwardRef)(function List2({
|
|
|
4417
4508
|
source,
|
|
4418
4509
|
style: styleProp,
|
|
4419
4510
|
stickyHeaders,
|
|
4511
|
+
tabIndex = 0,
|
|
4420
4512
|
tabToSelect,
|
|
4421
4513
|
...htmlAttributes
|
|
4422
4514
|
}, forwardedRef) {
|
|
4423
|
-
var
|
|
4515
|
+
var _a2, _b;
|
|
4424
4516
|
const id = (0, import_vuu_layout3.useId)(idProp);
|
|
4425
|
-
const containerRef = (0,
|
|
4426
|
-
const scrollContainerRef = (0,
|
|
4427
|
-
const contentContainerRef = (0,
|
|
4428
|
-
const [size, setSize] = (0,
|
|
4429
|
-
const handleResize = (0,
|
|
4517
|
+
const containerRef = (0, import_react31.useRef)(null);
|
|
4518
|
+
const scrollContainerRef = (0, import_react31.useRef)(null);
|
|
4519
|
+
const contentContainerRef = (0, import_react31.useRef)(null);
|
|
4520
|
+
const [size, setSize] = (0, import_react31.useState)();
|
|
4521
|
+
const handleResize = (0, import_react31.useCallback)((size2) => {
|
|
4430
4522
|
setSize(size2);
|
|
4431
4523
|
}, []);
|
|
4432
4524
|
const collectionHook = useCollectionItems({
|
|
@@ -4459,7 +4551,7 @@ var List = (0, import_react29.forwardRef)(function List2({
|
|
|
4459
4551
|
const { onVerticalScroll, viewportRange } = useScrollPosition({
|
|
4460
4552
|
containerSize: (
|
|
4461
4553
|
// TODO whats the right way to handle string values - ie percentages
|
|
4462
|
-
(_b = (
|
|
4554
|
+
(_b = (_a2 = listClientHeight != null ? listClientHeight : computedListHeight) != null ? _a2 : size == null ? void 0 : size.height) != null ? _b : 0
|
|
4463
4555
|
),
|
|
4464
4556
|
itemCount: collectionHook.data.length,
|
|
4465
4557
|
itemGapSize,
|
|
@@ -4514,7 +4606,7 @@ var List = (0, import_react29.forwardRef)(function List2({
|
|
|
4514
4606
|
});
|
|
4515
4607
|
const appliedFocusVisible = focusVisibleProp != null ? focusVisibleProp : focusVisible;
|
|
4516
4608
|
const createHeader = function createHeader2(idx, headerId, title, expanded) {
|
|
4517
|
-
const header = /* @__PURE__ */ (0,
|
|
4609
|
+
const header = /* @__PURE__ */ (0, import_react32.createElement)(
|
|
4518
4610
|
ListItem4,
|
|
4519
4611
|
{
|
|
4520
4612
|
...listItemHeaderHandlers,
|
|
@@ -4537,13 +4629,13 @@ var List = (0, import_react29.forwardRef)(function List2({
|
|
|
4537
4629
|
};
|
|
4538
4630
|
const getItemHeight = getItemHeightProp === void 0 ? () => itemHeightProp : getItemHeightProp;
|
|
4539
4631
|
function renderCollectionItem(list, item, idx) {
|
|
4540
|
-
var
|
|
4632
|
+
var _a3, _b2;
|
|
4541
4633
|
const { disabled, value, id: itemId, label } = item;
|
|
4542
|
-
const isChildItem = (0,
|
|
4634
|
+
const isChildItem = (0, import_react31.isValidElement)(value);
|
|
4543
4635
|
const listItemProps = {
|
|
4544
4636
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4545
4637
|
// @ts-ignore until we refactor this whole section
|
|
4546
|
-
className: (0, import_classnames6.default)((
|
|
4638
|
+
className: (0, import_classnames6.default)((_a3 = value == null ? void 0 : value.props) == null ? void 0 : _a3.className, {
|
|
4547
4639
|
vuuHighlighted: idx.value === highlightedIndex,
|
|
4548
4640
|
vuuFocusVisible: appliedFocusVisible === idx.value,
|
|
4549
4641
|
[`vuuDraggable-dragAway`]: draggedItemIndex === idx.value
|
|
@@ -4561,7 +4653,7 @@ var List = (0, import_react29.forwardRef)(function List2({
|
|
|
4561
4653
|
showCheckbox: checkable
|
|
4562
4654
|
};
|
|
4563
4655
|
list.push(
|
|
4564
|
-
isChildItem ? (0,
|
|
4656
|
+
isChildItem ? (0, import_react31.cloneElement)(value, listItemProps) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ListItem4, { ...listItemProps })
|
|
4565
4657
|
);
|
|
4566
4658
|
idx.value += 1;
|
|
4567
4659
|
}
|
|
@@ -4572,7 +4664,7 @@ var List = (0, import_react29.forwardRef)(function List2({
|
|
|
4572
4664
|
renderCollectionItems(items, idx, idx.value + count) || []
|
|
4573
4665
|
) : header;
|
|
4574
4666
|
list.push(
|
|
4575
|
-
/* @__PURE__ */ (0,
|
|
4667
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { role: "group", children: childItems2 }, id2)
|
|
4576
4668
|
);
|
|
4577
4669
|
};
|
|
4578
4670
|
const renderCollectionItems = (items, idx = { value: 0 }, end = items.length) => {
|
|
@@ -4593,13 +4685,14 @@ var List = (0, import_react29.forwardRef)(function List2({
|
|
|
4593
4685
|
};
|
|
4594
4686
|
function renderEmpty() {
|
|
4595
4687
|
if (emptyMessage || showEmptyMessage) {
|
|
4596
|
-
return /* @__PURE__ */ (0,
|
|
4688
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: `${classBase5}-empty-message`, children: emptyMessage != null ? emptyMessage : defaultEmptyMessage });
|
|
4597
4689
|
} else {
|
|
4598
4690
|
return null;
|
|
4599
4691
|
}
|
|
4600
4692
|
}
|
|
4693
|
+
const isEmpty = collectionHook.data.length === 0;
|
|
4601
4694
|
const renderContent = () => {
|
|
4602
|
-
if (
|
|
4695
|
+
if (!isEmpty) {
|
|
4603
4696
|
const itemsToRender = collectionHook.data;
|
|
4604
4697
|
return renderCollectionItems(itemsToRender);
|
|
4605
4698
|
} else {
|
|
@@ -4616,7 +4709,7 @@ var List = (0, import_react29.forwardRef)(function List2({
|
|
|
4616
4709
|
maxWidth,
|
|
4617
4710
|
maxHeight
|
|
4618
4711
|
};
|
|
4619
|
-
return /* @__PURE__ */ (0,
|
|
4712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
4620
4713
|
import_vuu_layout3.MeasuredContainer,
|
|
4621
4714
|
{
|
|
4622
4715
|
"aria-multiselectable": selectionStrategy === "multiple" || selectionStrategy === "extended" || selectionStrategy === "extended-multi-range" || void 0,
|
|
@@ -4626,6 +4719,7 @@ var List = (0, import_react29.forwardRef)(function List2({
|
|
|
4626
4719
|
className: (0, import_classnames6.default)(classBase5, className, {
|
|
4627
4720
|
[`${classBase5}-collapsible`]: collapsibleHeaders,
|
|
4628
4721
|
[`${classBase5}-contentSized`]: computedListHeight !== void 0,
|
|
4722
|
+
[`${classBase5}-empty`]: isEmpty,
|
|
4629
4723
|
vuuFocusVisible: highlightedIndex === LIST_FOCUS_VISIBLE
|
|
4630
4724
|
}),
|
|
4631
4725
|
height: computedListHeight != null ? computedListHeight : height,
|
|
@@ -4635,10 +4729,10 @@ var List = (0, import_react29.forwardRef)(function List2({
|
|
|
4635
4729
|
role: "listbox",
|
|
4636
4730
|
onScroll: onVerticalScroll,
|
|
4637
4731
|
style: { ...styleProp, ...sizeStyles },
|
|
4638
|
-
tabIndex: listDisabled || disableFocus ? void 0 :
|
|
4732
|
+
tabIndex: listDisabled || disableFocus ? void 0 : tabIndex,
|
|
4639
4733
|
children: [
|
|
4640
|
-
/* @__PURE__ */ (0,
|
|
4641
|
-
collectionHook.data.length === 0 && ListPlaceholder !== void 0 ? /* @__PURE__ */ (0,
|
|
4734
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ListItemProxy, { ref: rowHeightProxyRef, height: itemHeightProp }),
|
|
4735
|
+
collectionHook.data.length === 0 && ListPlaceholder !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ListPlaceholder, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `${classBase5}-viewport`, ref: scrollContainerRef, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
4642
4736
|
"div",
|
|
4643
4737
|
{
|
|
4644
4738
|
className: `${classBase5}-scrollingContentContainer`,
|
|
@@ -4680,10 +4774,10 @@ function clsx() {
|
|
|
4680
4774
|
}
|
|
4681
4775
|
|
|
4682
4776
|
// src/list/VirtualizedList.tsx
|
|
4683
|
-
var
|
|
4777
|
+
var import_react34 = require("react");
|
|
4684
4778
|
|
|
4685
4779
|
// src/list/useVirtualization.ts
|
|
4686
|
-
var
|
|
4780
|
+
var import_react33 = require("react");
|
|
4687
4781
|
|
|
4688
4782
|
// src/list/keyset.ts
|
|
4689
4783
|
var KeySet = class {
|
|
@@ -4732,7 +4826,7 @@ var useVirtualization = ({
|
|
|
4732
4826
|
listItemHeight,
|
|
4733
4827
|
viewportRange
|
|
4734
4828
|
}) => {
|
|
4735
|
-
const keys = (0,
|
|
4829
|
+
const keys = (0, import_react33.useMemo)(() => new KeySet(0, 1), []);
|
|
4736
4830
|
const rowHeightWithGap = listItemHeight + listItemGapSize;
|
|
4737
4831
|
const lo = Math.max(0, viewportRange.from - renderBuffer);
|
|
4738
4832
|
const hi = Math.min(data.length, viewportRange.to + renderBuffer);
|
|
@@ -4749,11 +4843,11 @@ var useVirtualization = ({
|
|
|
4749
4843
|
};
|
|
4750
4844
|
|
|
4751
4845
|
// src/list/VirtualizedList.tsx
|
|
4752
|
-
var
|
|
4846
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
4753
4847
|
var defaultEmptyMessage2 = "No data to display";
|
|
4754
4848
|
var withBaseName2 = (0, import_core10.makePrefixer)("saltList");
|
|
4755
|
-
var ListItem3 = (0,
|
|
4756
|
-
var VirtualizedList = (0,
|
|
4849
|
+
var ListItem3 = (0, import_react34.memo)(ListItem);
|
|
4850
|
+
var VirtualizedList = (0, import_react34.forwardRef)(function List3({
|
|
4757
4851
|
borderless,
|
|
4758
4852
|
children,
|
|
4759
4853
|
className,
|
|
@@ -4799,8 +4893,8 @@ var VirtualizedList = (0, import_react32.forwardRef)(function List3({
|
|
|
4799
4893
|
...htmlAttributes
|
|
4800
4894
|
}, forwardedRef) {
|
|
4801
4895
|
const id = (0, import_core10.useIdMemo)(idProp);
|
|
4802
|
-
const rootRef = (0,
|
|
4803
|
-
const rowHeightProxyRef = (0,
|
|
4896
|
+
const rootRef = (0, import_react34.useRef)(null);
|
|
4897
|
+
const rowHeightProxyRef = (0, import_react34.useRef)(null);
|
|
4804
4898
|
const collectionHook = useCollectionItems({
|
|
4805
4899
|
id,
|
|
4806
4900
|
label: "List",
|
|
@@ -4836,9 +4930,7 @@ var VirtualizedList = (0, import_react32.forwardRef)(function List3({
|
|
|
4836
4930
|
collectionHook,
|
|
4837
4931
|
containerRef: rootRef,
|
|
4838
4932
|
defaultHighlightedIndex: defaultHighlightedIdx,
|
|
4839
|
-
|
|
4840
|
-
// @ts-ignore
|
|
4841
|
-
defaultSelected: collectionHook.itemToCollectionItem(defaultSelected),
|
|
4933
|
+
defaultSelected: collectionHook.itemToCollectionItemId(defaultSelected),
|
|
4842
4934
|
disabled: listDisabled,
|
|
4843
4935
|
disableTypeToSelect,
|
|
4844
4936
|
highlightedIndex: highlightedIdxProp,
|
|
@@ -4847,9 +4939,7 @@ var VirtualizedList = (0, import_react32.forwardRef)(function List3({
|
|
|
4847
4939
|
onSelectionChange,
|
|
4848
4940
|
onHighlight,
|
|
4849
4941
|
restoreLastFocus,
|
|
4850
|
-
|
|
4851
|
-
// @ts-ignore
|
|
4852
|
-
selected: collectionHook.itemToCollectionItem(selectedProp),
|
|
4942
|
+
selected: collectionHook.itemToCollectionItemId(selectedProp),
|
|
4853
4943
|
selectionStrategy,
|
|
4854
4944
|
selectionKeys,
|
|
4855
4945
|
stickyHeaders,
|
|
@@ -4878,7 +4968,7 @@ var VirtualizedList = (0, import_react32.forwardRef)(function List3({
|
|
|
4878
4968
|
const [key, offset, pos, item] = row;
|
|
4879
4969
|
const index = pos - 1;
|
|
4880
4970
|
list.push(
|
|
4881
|
-
/* @__PURE__ */ (0,
|
|
4971
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
4882
4972
|
ListItem3,
|
|
4883
4973
|
{
|
|
4884
4974
|
"aria-setsize": collectionHook.data.length,
|
|
@@ -4911,7 +5001,7 @@ var VirtualizedList = (0, import_react32.forwardRef)(function List3({
|
|
|
4911
5001
|
}
|
|
4912
5002
|
function renderEmpty() {
|
|
4913
5003
|
if (emptyMessage || showEmptyMessage) {
|
|
4914
|
-
return /* @__PURE__ */ (0,
|
|
5004
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: withBaseName2("empty-message"), children: emptyMessage != null ? emptyMessage : defaultEmptyMessage2 });
|
|
4915
5005
|
} else {
|
|
4916
5006
|
return null;
|
|
4917
5007
|
}
|
|
@@ -4932,7 +5022,7 @@ var VirtualizedList = (0, import_react32.forwardRef)(function List3({
|
|
|
4932
5022
|
maxWidth: maxWidth != null ? maxWidth : width,
|
|
4933
5023
|
maxHeight: maxHeight != null ? maxHeight : listHeight
|
|
4934
5024
|
};
|
|
4935
|
-
return /* @__PURE__ */ (0,
|
|
5025
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
4936
5026
|
"div",
|
|
4937
5027
|
{
|
|
4938
5028
|
...htmlAttributes,
|
|
@@ -4945,13 +5035,13 @@ var VirtualizedList = (0, import_react32.forwardRef)(function List3({
|
|
|
4945
5035
|
onScroll: onVerticalScroll,
|
|
4946
5036
|
style: { ...styleProp, ...sizeStyles },
|
|
4947
5037
|
tabIndex: listDisabled || disableFocus ? void 0 : 0,
|
|
4948
|
-
children: /* @__PURE__ */ (0,
|
|
5038
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
4949
5039
|
"div",
|
|
4950
5040
|
{
|
|
4951
5041
|
className: withBaseName2("scrollingContentContainer"),
|
|
4952
5042
|
style: { height: contentHeight },
|
|
4953
5043
|
children: [
|
|
4954
|
-
/* @__PURE__ */ (0,
|
|
5044
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ListItemProxy, { ref: rowHeightProxyRef }),
|
|
4955
5045
|
renderContent()
|
|
4956
5046
|
]
|
|
4957
5047
|
}
|
|
@@ -4962,12 +5052,12 @@ var VirtualizedList = (0, import_react32.forwardRef)(function List3({
|
|
|
4962
5052
|
|
|
4963
5053
|
// src/list/RadioIcon.tsx
|
|
4964
5054
|
var import_classnames7 = __toESM(require("classnames"));
|
|
4965
|
-
var
|
|
5055
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
4966
5056
|
var classBase6 = "vuuRadioIcon";
|
|
4967
5057
|
var RadioIcon = ({
|
|
4968
5058
|
checked = false,
|
|
4969
5059
|
...htmlAttributes
|
|
4970
|
-
}) => /* @__PURE__ */ (0,
|
|
5060
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4971
5061
|
"span",
|
|
4972
5062
|
{
|
|
4973
5063
|
...htmlAttributes,
|
|
@@ -4977,7 +5067,7 @@ var RadioIcon = ({
|
|
|
4977
5067
|
|
|
4978
5068
|
// src/dropdown/useDropdown.ts
|
|
4979
5069
|
var import_core11 = require("@salt-ds/core");
|
|
4980
|
-
var
|
|
5070
|
+
var import_react35 = require("react");
|
|
4981
5071
|
var useDropdown = ({
|
|
4982
5072
|
collectionHook,
|
|
4983
5073
|
defaultHighlightedIndex: defaultHighlightedIndexProp,
|
|
@@ -4994,23 +5084,36 @@ var useDropdown = ({
|
|
|
4994
5084
|
selected,
|
|
4995
5085
|
selectionStrategy
|
|
4996
5086
|
}) => {
|
|
4997
|
-
const isMultiSelect = selectionStrategy
|
|
5087
|
+
const isMultiSelect = isMultiSelection(selectionStrategy);
|
|
4998
5088
|
const [isOpen, setIsOpen] = (0, import_core11.useControlled)({
|
|
4999
5089
|
controlled: isOpenProp,
|
|
5000
5090
|
default: defaultIsOpen != null ? defaultIsOpen : false,
|
|
5001
5091
|
name: "useDropdownList"
|
|
5002
5092
|
});
|
|
5003
|
-
const handleSelectionChange = (0,
|
|
5093
|
+
const handleSelectionChange = (0, import_react35.useCallback)(
|
|
5004
5094
|
(evt, selected2) => {
|
|
5095
|
+
console.log(`useDropdown onSelectionChange`, {
|
|
5096
|
+
selected: selected2
|
|
5097
|
+
});
|
|
5005
5098
|
if (!isMultiSelect) {
|
|
5006
5099
|
setIsOpen(false);
|
|
5007
5100
|
onOpenChange == null ? void 0 : onOpenChange(false);
|
|
5008
5101
|
}
|
|
5009
|
-
|
|
5102
|
+
if (Array.isArray(selected2)) {
|
|
5103
|
+
onSelectionChange == null ? void 0 : onSelectionChange(
|
|
5104
|
+
null,
|
|
5105
|
+
selected2
|
|
5106
|
+
);
|
|
5107
|
+
} else if (selected2) {
|
|
5108
|
+
onSelectionChange == null ? void 0 : onSelectionChange(
|
|
5109
|
+
null,
|
|
5110
|
+
selected2
|
|
5111
|
+
);
|
|
5112
|
+
}
|
|
5010
5113
|
},
|
|
5011
5114
|
[isMultiSelect, onOpenChange, onSelectionChange, setIsOpen]
|
|
5012
5115
|
);
|
|
5013
|
-
const handleSelect = (0,
|
|
5116
|
+
const handleSelect = (0, import_react35.useCallback)(
|
|
5014
5117
|
(evt, selected2) => {
|
|
5015
5118
|
if (!isMultiSelect) {
|
|
5016
5119
|
setIsOpen(false);
|
|
@@ -5034,15 +5137,15 @@ var useDropdown = ({
|
|
|
5034
5137
|
selectionStrategy,
|
|
5035
5138
|
tabToSelect: !isMultiSelect
|
|
5036
5139
|
});
|
|
5037
|
-
const handleOpenChange = (0,
|
|
5140
|
+
const handleOpenChange = (0, import_react35.useCallback)(
|
|
5038
5141
|
(open) => {
|
|
5039
5142
|
setIsOpen(open);
|
|
5040
5143
|
onOpenChange == null ? void 0 : onOpenChange(open);
|
|
5041
5144
|
},
|
|
5042
5145
|
[onOpenChange, setIsOpen]
|
|
5043
5146
|
);
|
|
5044
|
-
const triggerLabel = (0,
|
|
5045
|
-
if (
|
|
5147
|
+
const triggerLabel = (0, import_react35.useMemo)(() => {
|
|
5148
|
+
if (Array.isArray(listHook.selected)) {
|
|
5046
5149
|
const selectedItems = listHook.selected.map(
|
|
5047
5150
|
(id) => collectionHook.itemById(id)
|
|
5048
5151
|
);
|
|
@@ -5054,11 +5157,8 @@ var useDropdown = ({
|
|
|
5054
5157
|
} else {
|
|
5055
5158
|
return `${selectedItems.length} items selected`;
|
|
5056
5159
|
}
|
|
5057
|
-
} else {
|
|
5058
|
-
const selectedItem = listHook.selected;
|
|
5059
|
-
return selectedItem == null ? void 0 : itemToString2(collectionHook.itemById(selectedItem));
|
|
5060
5160
|
}
|
|
5061
|
-
}, [collectionHook,
|
|
5161
|
+
}, [collectionHook, itemToString2, listHook.selected]);
|
|
5062
5162
|
return {
|
|
5063
5163
|
isOpen,
|
|
5064
5164
|
onOpenChange: handleOpenChange,
|
|
@@ -5068,8 +5168,8 @@ var useDropdown = ({
|
|
|
5068
5168
|
};
|
|
5069
5169
|
|
|
5070
5170
|
// src/dropdown/Dropdown.tsx
|
|
5071
|
-
var
|
|
5072
|
-
var Dropdown2 = (0,
|
|
5171
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
5172
|
+
var Dropdown2 = (0, import_react36.forwardRef)(function Dropdown3({
|
|
5073
5173
|
"aria-label": ariaLabel,
|
|
5074
5174
|
children,
|
|
5075
5175
|
defaultIsOpen,
|
|
@@ -5090,8 +5190,8 @@ var Dropdown2 = (0, import_react34.forwardRef)(function Dropdown3({
|
|
|
5090
5190
|
...props
|
|
5091
5191
|
}, forwardedRef) {
|
|
5092
5192
|
const id = (0, import_vuu_layout4.useId)(idProp);
|
|
5093
|
-
const rootRef = (0,
|
|
5094
|
-
const listRef = (0,
|
|
5193
|
+
const rootRef = (0, import_react36.useRef)(null);
|
|
5194
|
+
const listRef = (0, import_react36.useRef)(null);
|
|
5095
5195
|
const forkedRef = (0, import_core12.useForkRef)(rootRef, forwardedRef);
|
|
5096
5196
|
const collectionHook = useCollectionItems({
|
|
5097
5197
|
id,
|
|
@@ -5116,7 +5216,6 @@ var Dropdown2 = (0, import_react34.forwardRef)(function Dropdown3({
|
|
|
5116
5216
|
highlightedIndex: ListProps3 == null ? void 0 : ListProps3.highlightedIndex,
|
|
5117
5217
|
isOpen: isOpenProp,
|
|
5118
5218
|
itemToString: itemToString2,
|
|
5119
|
-
label: "Dropdown",
|
|
5120
5219
|
listRef,
|
|
5121
5220
|
onHighlight: ListProps3 == null ? void 0 : ListProps3.onHighlight,
|
|
5122
5221
|
onOpenChange,
|
|
@@ -5125,14 +5224,13 @@ var Dropdown2 = (0, import_react34.forwardRef)(function Dropdown3({
|
|
|
5125
5224
|
selected: collectionHook.itemToCollectionItemId(selectedProp),
|
|
5126
5225
|
selectionStrategy
|
|
5127
5226
|
});
|
|
5128
|
-
const
|
|
5129
|
-
(
|
|
5130
|
-
if (Array.isArray(
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
return collectionHook.itemById(itemIdOrItemIds);
|
|
5227
|
+
const itemIdToItem = (0, import_react36.useCallback)(
|
|
5228
|
+
(itemId) => {
|
|
5229
|
+
if (Array.isArray(itemId)) {
|
|
5230
|
+
const items = itemId.map((id2) => collectionHook.itemById(id2));
|
|
5231
|
+
return items;
|
|
5232
|
+
} else {
|
|
5233
|
+
return collectionHook.itemById(itemId);
|
|
5136
5234
|
}
|
|
5137
5235
|
},
|
|
5138
5236
|
[collectionHook]
|
|
@@ -5144,7 +5242,7 @@ var Dropdown2 = (0, import_react34.forwardRef)(function Dropdown3({
|
|
|
5144
5242
|
};
|
|
5145
5243
|
if (triggerComponent) {
|
|
5146
5244
|
const ownProps = triggerComponent.props;
|
|
5147
|
-
return (0,
|
|
5245
|
+
return (0, import_react36.cloneElement)(
|
|
5148
5246
|
triggerComponent,
|
|
5149
5247
|
forwardCallbackProps(ownProps, {
|
|
5150
5248
|
...dropdownListHook.isOpen ? listControlProps : {},
|
|
@@ -5152,7 +5250,7 @@ var Dropdown2 = (0, import_react34.forwardRef)(function Dropdown3({
|
|
|
5152
5250
|
})
|
|
5153
5251
|
);
|
|
5154
5252
|
} else {
|
|
5155
|
-
return /* @__PURE__ */ (0,
|
|
5253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
5156
5254
|
DropdownButton,
|
|
5157
5255
|
{
|
|
5158
5256
|
label: triggerLabel,
|
|
@@ -5162,7 +5260,7 @@ var Dropdown2 = (0, import_react34.forwardRef)(function Dropdown3({
|
|
|
5162
5260
|
);
|
|
5163
5261
|
}
|
|
5164
5262
|
};
|
|
5165
|
-
return /* @__PURE__ */ (0,
|
|
5263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CollectionProvider, { collectionHook, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
5166
5264
|
DropdownBase,
|
|
5167
5265
|
{
|
|
5168
5266
|
...props,
|
|
@@ -5174,7 +5272,7 @@ var Dropdown2 = (0, import_react34.forwardRef)(function Dropdown3({
|
|
|
5174
5272
|
width,
|
|
5175
5273
|
children: [
|
|
5176
5274
|
getTriggerComponent(),
|
|
5177
|
-
/* @__PURE__ */ (0,
|
|
5275
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
5178
5276
|
List,
|
|
5179
5277
|
{
|
|
5180
5278
|
ListItem: ListItem4,
|
|
@@ -5185,7 +5283,7 @@ var Dropdown2 = (0, import_react34.forwardRef)(function Dropdown3({
|
|
|
5185
5283
|
onSelectionChange,
|
|
5186
5284
|
onSelect,
|
|
5187
5285
|
ref: listRef,
|
|
5188
|
-
selected:
|
|
5286
|
+
selected: selected === void 0 ? void 0 : itemIdToItem(selected),
|
|
5189
5287
|
selectionStrategy
|
|
5190
5288
|
}
|
|
5191
5289
|
)
|
|
@@ -5197,13 +5295,14 @@ var Dropdown2 = (0, import_react34.forwardRef)(function Dropdown3({
|
|
|
5197
5295
|
// src/combo-box/useCombobox.ts
|
|
5198
5296
|
var import_core13 = require("@salt-ds/core");
|
|
5199
5297
|
var import_vuu_layout5 = require("@vuu-ui/vuu-layout");
|
|
5200
|
-
var
|
|
5298
|
+
var import_react37 = require("react");
|
|
5201
5299
|
var EnterOnly = ["Enter"];
|
|
5202
5300
|
var useCombobox = ({
|
|
5203
5301
|
allowFreeText,
|
|
5204
5302
|
ariaLabel,
|
|
5205
5303
|
collectionHook,
|
|
5206
5304
|
defaultIsOpen,
|
|
5305
|
+
defaultSelected,
|
|
5207
5306
|
defaultValue,
|
|
5208
5307
|
onBlur,
|
|
5209
5308
|
onFocus,
|
|
@@ -5212,12 +5311,15 @@ var useCombobox = ({
|
|
|
5212
5311
|
id,
|
|
5213
5312
|
initialHighlightedIndex = -1,
|
|
5214
5313
|
isOpen: isOpenProp,
|
|
5314
|
+
itemCount,
|
|
5315
|
+
itemsToString,
|
|
5215
5316
|
itemToString: itemToString2 = itemToString,
|
|
5216
5317
|
listRef,
|
|
5217
5318
|
onOpenChange,
|
|
5218
5319
|
onSelectionChange,
|
|
5320
|
+
onSetSelectedText,
|
|
5321
|
+
selected: selectedProp,
|
|
5219
5322
|
selectionStrategy,
|
|
5220
|
-
stringToItem,
|
|
5221
5323
|
value: valueProp,
|
|
5222
5324
|
InputProps: inputProps = {
|
|
5223
5325
|
onBlur,
|
|
@@ -5226,21 +5328,11 @@ var useCombobox = ({
|
|
|
5226
5328
|
onSelect
|
|
5227
5329
|
}
|
|
5228
5330
|
}) => {
|
|
5229
|
-
|
|
5230
|
-
const
|
|
5231
|
-
const
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
const {
|
|
5235
|
-
data: indexPositions,
|
|
5236
|
-
itemToCollectionItem,
|
|
5237
|
-
setFilterPattern,
|
|
5238
|
-
stringToCollectionItem
|
|
5239
|
-
} = collectionHook;
|
|
5240
|
-
const setHighlightedIndexRef = (0, import_react35.useRef)(null);
|
|
5241
|
-
const setSelectedRef = (0, import_react35.useRef)(null);
|
|
5242
|
-
const ignoreSelectOnFocus = (0, import_react35.useRef)(true);
|
|
5243
|
-
const selectedRef = (0, import_react35.useRef)(selectedValue);
|
|
5331
|
+
const isMultiSelect = isMultiSelection(selectionStrategy);
|
|
5332
|
+
const { setFilterPattern } = collectionHook;
|
|
5333
|
+
const setHighlightedIndexRef = (0, import_react37.useRef)(null);
|
|
5334
|
+
const selectedRef = (0, import_react37.useRef)(isMultiSelect ? [] : null);
|
|
5335
|
+
const ignoreSelectOnFocus = (0, import_react37.useRef)(true);
|
|
5244
5336
|
const [isOpen, setIsOpen] = (0, import_core13.useControlled)({
|
|
5245
5337
|
controlled: isOpenProp,
|
|
5246
5338
|
default: defaultIsOpen != null ? defaultIsOpen : false,
|
|
@@ -5248,116 +5340,138 @@ var useCombobox = ({
|
|
|
5248
5340
|
});
|
|
5249
5341
|
const [value, setValue] = (0, import_core13.useControlled)({
|
|
5250
5342
|
controlled: void 0,
|
|
5251
|
-
default: defaultValue != null ? defaultValue :
|
|
5343
|
+
default: defaultValue != null ? defaultValue : valueProp,
|
|
5252
5344
|
name: "ComboBox",
|
|
5253
5345
|
state: "value"
|
|
5254
5346
|
});
|
|
5255
|
-
const
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
);
|
|
5267
|
-
const [disableAriaActiveDescendant, setDisableAriaActiveDescendant] = (0, import_react35.useState)(true);
|
|
5268
|
-
const [quickSelection, setQuickSelection] = (0, import_react35.useState)(false);
|
|
5269
|
-
const highlightSelectedItem = (0, import_react35.useCallback)(
|
|
5270
|
-
(selected2 = selectedRef.current) => {
|
|
5271
|
-
var _a2, _b;
|
|
5272
|
-
if (Array.isArray(selected2)) {
|
|
5273
|
-
console.log("TODO multi selection");
|
|
5274
|
-
} else if (selected2 == null) {
|
|
5275
|
-
(_a2 = setHighlightedIndexRef.current) == null ? void 0 : _a2.call(setHighlightedIndexRef, -1);
|
|
5276
|
-
} else {
|
|
5277
|
-
const indexOfSelectedItem = indexPositions.indexOf(selected2);
|
|
5278
|
-
(_b = setHighlightedIndexRef.current) == null ? void 0 : _b.call(setHighlightedIndexRef, indexOfSelectedItem);
|
|
5279
|
-
}
|
|
5280
|
-
},
|
|
5281
|
-
[indexPositions]
|
|
5282
|
-
);
|
|
5283
|
-
const setTextValue = (0, import_react35.useCallback)(
|
|
5284
|
-
(value2) => {
|
|
5347
|
+
const [disableAriaActiveDescendant, setDisableAriaActiveDescendant] = (0, import_react37.useState)(true);
|
|
5348
|
+
const highlightSelectedItem = (0, import_react37.useCallback)((selected2) => {
|
|
5349
|
+
var _a2;
|
|
5350
|
+
if (Array.isArray(selected2)) {
|
|
5351
|
+
console.log("TODO multi selection");
|
|
5352
|
+
} else if (selected2 == null) {
|
|
5353
|
+
(_a2 = setHighlightedIndexRef.current) == null ? void 0 : _a2.call(setHighlightedIndexRef, -1);
|
|
5354
|
+
}
|
|
5355
|
+
}, []);
|
|
5356
|
+
const setTextValue = (0, import_react37.useCallback)(
|
|
5357
|
+
(value2, applyFilter = true) => {
|
|
5285
5358
|
setValue(value2);
|
|
5286
|
-
|
|
5359
|
+
if (applyFilter) {
|
|
5360
|
+
setFilterPattern(value2 === "" ? void 0 : value2);
|
|
5361
|
+
}
|
|
5287
5362
|
},
|
|
5288
5363
|
[setFilterPattern, setValue]
|
|
5289
5364
|
);
|
|
5290
|
-
const reconcileInput = (0,
|
|
5291
|
-
(selected2
|
|
5292
|
-
|
|
5293
|
-
let value2 = "";
|
|
5365
|
+
const reconcileInput = (0, import_react37.useCallback)(
|
|
5366
|
+
(selected2) => {
|
|
5367
|
+
let newValue = allowFreeText ? value != null ? value : "" : "";
|
|
5294
5368
|
if (Array.isArray(selected2)) {
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5369
|
+
if (selected2.length === 1) {
|
|
5370
|
+
newValue = itemToString2(selected2[0]);
|
|
5371
|
+
} else if (selected2.length > 1) {
|
|
5372
|
+
newValue = (itemsToString == null ? void 0 : itemsToString(selected2)) || "";
|
|
5373
|
+
}
|
|
5374
|
+
} else if (selected2) {
|
|
5375
|
+
newValue = itemToString2(selected2);
|
|
5298
5376
|
}
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5377
|
+
if (newValue !== value) {
|
|
5378
|
+
setTextValue(newValue, !isMultiSelect);
|
|
5379
|
+
onSetSelectedText == null ? void 0 : onSetSelectedText(newValue);
|
|
5380
|
+
return true;
|
|
5302
5381
|
} else {
|
|
5303
|
-
|
|
5382
|
+
return false;
|
|
5304
5383
|
}
|
|
5305
5384
|
},
|
|
5306
|
-
[
|
|
5385
|
+
[
|
|
5386
|
+
allowFreeText,
|
|
5387
|
+
isMultiSelect,
|
|
5388
|
+
itemToString2,
|
|
5389
|
+
itemsToString,
|
|
5390
|
+
onSetSelectedText,
|
|
5391
|
+
setTextValue,
|
|
5392
|
+
value
|
|
5393
|
+
]
|
|
5307
5394
|
);
|
|
5308
|
-
const applySelection = (0,
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5395
|
+
const applySelection = (0, import_react37.useCallback)(() => {
|
|
5396
|
+
const { current: selected2 } = selectedRef;
|
|
5397
|
+
if (reconcileInput(selected2)) {
|
|
5398
|
+
if (selected2) {
|
|
5399
|
+
if (Array.isArray(selected2)) {
|
|
5400
|
+
onSelectionChange == null ? void 0 : onSelectionChange(
|
|
5401
|
+
null,
|
|
5402
|
+
selected2
|
|
5403
|
+
);
|
|
5404
|
+
} else if (selected2) {
|
|
5405
|
+
onSelectionChange == null ? void 0 : onSelectionChange(
|
|
5406
|
+
null,
|
|
5407
|
+
selected2
|
|
5408
|
+
);
|
|
5409
|
+
}
|
|
5410
|
+
}
|
|
5411
|
+
}
|
|
5412
|
+
}, [onSelectionChange, reconcileInput]);
|
|
5413
|
+
const selectFreeTextInputValue = (0, import_react37.useCallback)(() => {
|
|
5414
|
+
if (allowFreeText) {
|
|
5415
|
+
const text = value == null ? void 0 : value.trim();
|
|
5416
|
+
const { current: selected2 } = selectedRef;
|
|
5417
|
+
if (text) {
|
|
5418
|
+
if (itemCount === 0 && text) {
|
|
5419
|
+
if (isMultiSelect) {
|
|
5420
|
+
onSelectionChange == null ? void 0 : onSelectionChange(null, [
|
|
5421
|
+
text
|
|
5422
|
+
]);
|
|
5423
|
+
} else {
|
|
5424
|
+
onSelectionChange == null ? void 0 : onSelectionChange(null, text);
|
|
5425
|
+
}
|
|
5426
|
+
selectedRef.current = null;
|
|
5427
|
+
return true;
|
|
5428
|
+
} else if (selected2 && !isMultiSelect) {
|
|
5429
|
+
if (selected2 && !Array.isArray(selected2) && itemToString2(selected2) === text) {
|
|
5430
|
+
}
|
|
5431
|
+
}
|
|
5432
|
+
}
|
|
5433
|
+
}
|
|
5434
|
+
return false;
|
|
5435
|
+
}, [
|
|
5436
|
+
allowFreeText,
|
|
5437
|
+
value,
|
|
5438
|
+
itemCount,
|
|
5439
|
+
isMultiSelect,
|
|
5440
|
+
onSelectionChange,
|
|
5441
|
+
itemToString2
|
|
5442
|
+
]);
|
|
5443
|
+
const handleOpenChange = (0, import_react37.useCallback)(
|
|
5444
|
+
(open, closeReason) => {
|
|
5445
|
+
if (open && isMultiSelect) {
|
|
5446
|
+
setTextValue("", false);
|
|
5447
|
+
}
|
|
5448
|
+
setIsOpen(open);
|
|
5449
|
+
onOpenChange == null ? void 0 : onOpenChange(open);
|
|
5450
|
+
if (!open && closeReason !== "Escape") {
|
|
5451
|
+
if (!selectFreeTextInputValue()) {
|
|
5452
|
+
applySelection();
|
|
5453
|
+
}
|
|
5312
5454
|
}
|
|
5313
|
-
selectedRef.current = selected2;
|
|
5314
|
-
reconcileInput(selected2);
|
|
5315
|
-
onSelectionChange == null ? void 0 : onSelectionChange(evt, collectionItemsToItem(selected2 != null ? selected2 : null));
|
|
5316
5455
|
},
|
|
5317
5456
|
[
|
|
5318
|
-
|
|
5457
|
+
applySelection,
|
|
5319
5458
|
isMultiSelect,
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
setIsOpen
|
|
5459
|
+
onOpenChange,
|
|
5460
|
+
selectFreeTextInputValue,
|
|
5461
|
+
setIsOpen,
|
|
5462
|
+
setTextValue
|
|
5323
5463
|
]
|
|
5324
5464
|
);
|
|
5325
|
-
const handleSelectionChange = (0,
|
|
5465
|
+
const handleSelectionChange = (0, import_react37.useCallback)(
|
|
5326
5466
|
(evt, selected2) => {
|
|
5467
|
+
selectedRef.current = selected2;
|
|
5327
5468
|
if (!isMultiSelect) {
|
|
5328
|
-
|
|
5329
|
-
applySelection(evt, selectedCollectionItem);
|
|
5330
|
-
}
|
|
5331
|
-
},
|
|
5332
|
-
[applySelection, isMultiSelect, itemToCollectionItem]
|
|
5333
|
-
);
|
|
5334
|
-
const handleFirstItemSelection = (0, import_react35.useCallback)(
|
|
5335
|
-
(evt) => {
|
|
5336
|
-
if (!allowFreeText && evt.key === "Enter" && quickSelection) {
|
|
5337
|
-
const [firstItem] = indexPositions;
|
|
5338
|
-
applySelection(evt, firstItem);
|
|
5469
|
+
handleOpenChange(false, "select");
|
|
5339
5470
|
}
|
|
5340
5471
|
},
|
|
5341
|
-
[
|
|
5472
|
+
[handleOpenChange, isMultiSelect]
|
|
5342
5473
|
);
|
|
5343
|
-
const
|
|
5344
|
-
(evt) => {
|
|
5345
|
-
if ("Escape" === evt.key) {
|
|
5346
|
-
if (allowFreeText) {
|
|
5347
|
-
setTextValue("");
|
|
5348
|
-
} else {
|
|
5349
|
-
reconcileInput();
|
|
5350
|
-
}
|
|
5351
|
-
} else if ("Tab" === evt.key) {
|
|
5352
|
-
if (!allowFreeText) {
|
|
5353
|
-
reconcileInput();
|
|
5354
|
-
}
|
|
5355
|
-
}
|
|
5356
|
-
handleFirstItemSelection(evt);
|
|
5357
|
-
},
|
|
5358
|
-
[allowFreeText, handleFirstItemSelection, reconcileInput, setTextValue]
|
|
5359
|
-
);
|
|
5360
|
-
const handleKeyboardNavigation = (0, import_react35.useCallback)(() => {
|
|
5474
|
+
const handleKeyboardNavigation = (0, import_react37.useCallback)(() => {
|
|
5361
5475
|
setDisableAriaActiveDescendant(false);
|
|
5362
5476
|
}, []);
|
|
5363
5477
|
const {
|
|
@@ -5366,41 +5480,26 @@ var useCombobox = ({
|
|
|
5366
5480
|
highlightedIndex,
|
|
5367
5481
|
listControlProps,
|
|
5368
5482
|
listHandlers: listHookListHandlers,
|
|
5369
|
-
selected
|
|
5370
|
-
setSelected
|
|
5483
|
+
selected
|
|
5371
5484
|
} = useList({
|
|
5372
5485
|
collectionHook,
|
|
5373
5486
|
containerRef: listRef,
|
|
5374
5487
|
defaultHighlightedIndex: initialHighlightedIndex,
|
|
5488
|
+
defaultSelected: collectionHook.itemToCollectionItemId(defaultSelected),
|
|
5375
5489
|
disableAriaActiveDescendant,
|
|
5376
5490
|
disableHighlightOnFocus: true,
|
|
5377
5491
|
disableTypeToSelect: true,
|
|
5378
|
-
label: "useComboBox",
|
|
5379
5492
|
onKeyboardNavigation: handleKeyboardNavigation,
|
|
5380
|
-
onKeyDown: handleInputKeyDown,
|
|
5493
|
+
// onKeyDown: handleInputKeyDown,
|
|
5381
5494
|
onSelectionChange: handleSelectionChange,
|
|
5382
|
-
|
|
5383
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5384
|
-
// @ts-ignore
|
|
5385
|
-
selected: selectedRef.current,
|
|
5495
|
+
selected: collectionHook.itemToCollectionItemId(selectedProp),
|
|
5386
5496
|
selectionKeys: EnterOnly,
|
|
5387
5497
|
selectionStrategy,
|
|
5388
5498
|
tabToSelect: !isMultiSelect
|
|
5389
5499
|
});
|
|
5390
5500
|
setHighlightedIndexRef.current = setHighlightedIndex;
|
|
5391
|
-
setSelectedRef.current = setSelected;
|
|
5392
|
-
const handleOpenChange = (0, import_react35.useCallback)(
|
|
5393
|
-
(open) => {
|
|
5394
|
-
setIsOpen(open);
|
|
5395
|
-
if (!open) {
|
|
5396
|
-
setQuickSelection(false);
|
|
5397
|
-
}
|
|
5398
|
-
onOpenChange == null ? void 0 : onOpenChange(open);
|
|
5399
|
-
},
|
|
5400
|
-
[onOpenChange, setIsOpen]
|
|
5401
|
-
);
|
|
5402
5501
|
const { onClick: listHandlersOnClick } = listHookListHandlers;
|
|
5403
|
-
const handleListClick = (0,
|
|
5502
|
+
const handleListClick = (0, import_react37.useCallback)(
|
|
5404
5503
|
(evt) => {
|
|
5405
5504
|
var _a2;
|
|
5406
5505
|
(_a2 = document.getElementById(`${id}-input`)) == null ? void 0 : _a2.focus();
|
|
@@ -5408,7 +5507,7 @@ var useCombobox = ({
|
|
|
5408
5507
|
},
|
|
5409
5508
|
[id, listHandlersOnClick]
|
|
5410
5509
|
);
|
|
5411
|
-
const handleInputChange = (0,
|
|
5510
|
+
const handleInputChange = (0, import_react37.useCallback)(
|
|
5412
5511
|
(evt) => {
|
|
5413
5512
|
const newValue = evt.target.value;
|
|
5414
5513
|
setValue(newValue);
|
|
@@ -5416,20 +5515,14 @@ var useCombobox = ({
|
|
|
5416
5515
|
setFilterPattern(newValue);
|
|
5417
5516
|
} else {
|
|
5418
5517
|
setFilterPattern(void 0);
|
|
5419
|
-
selectedRef.current = null;
|
|
5420
|
-
onSelectionChange == null ? void 0 : onSelectionChange(
|
|
5421
|
-
evt,
|
|
5422
|
-
null
|
|
5423
|
-
);
|
|
5424
5518
|
}
|
|
5425
5519
|
setIsOpen(true);
|
|
5426
|
-
setQuickSelection(newValue.length > 0 && !allowFreeText);
|
|
5427
5520
|
},
|
|
5428
|
-
[
|
|
5521
|
+
[setFilterPattern, setIsOpen, setValue]
|
|
5429
5522
|
);
|
|
5430
5523
|
const { onFocus: inputOnFocus = onFocus } = inputProps;
|
|
5431
5524
|
const { onFocus: listOnFocus } = listControlProps;
|
|
5432
|
-
const handleInputFocus = (0,
|
|
5525
|
+
const handleInputFocus = (0, import_react37.useCallback)(
|
|
5433
5526
|
(evt) => {
|
|
5434
5527
|
setDisableAriaActiveDescendant(false);
|
|
5435
5528
|
listOnFocus == null ? void 0 : listOnFocus(evt);
|
|
@@ -5437,70 +5530,29 @@ var useCombobox = ({
|
|
|
5437
5530
|
},
|
|
5438
5531
|
[inputOnFocus, listOnFocus]
|
|
5439
5532
|
);
|
|
5440
|
-
const listFocused = (0,
|
|
5533
|
+
const listFocused = (0, import_react37.useCallback)(
|
|
5441
5534
|
(evt) => {
|
|
5442
5535
|
const element = evt.relatedTarget;
|
|
5443
5536
|
return (element == null ? void 0 : element.id) === `${id}-list`;
|
|
5444
5537
|
},
|
|
5445
5538
|
[id]
|
|
5446
5539
|
);
|
|
5447
|
-
const selectInputValue = (0, import_react35.useCallback)(
|
|
5448
|
-
(evt) => {
|
|
5449
|
-
var _a2;
|
|
5450
|
-
const text = value.trim();
|
|
5451
|
-
if (text) {
|
|
5452
|
-
const selectedCollectionItem = stringToCollectionItem(
|
|
5453
|
-
text
|
|
5454
|
-
);
|
|
5455
|
-
if (selectedCollectionItem) {
|
|
5456
|
-
if (Array.isArray(selectedCollectionItem)) {
|
|
5457
|
-
} else if (selectedCollectionItem !== selected) {
|
|
5458
|
-
(_a2 = setSelectedRef.current) == null ? void 0 : _a2.call(setSelectedRef, selectedCollectionItem);
|
|
5459
|
-
onSelectionChange == null ? void 0 : onSelectionChange(
|
|
5460
|
-
evt,
|
|
5461
|
-
selectedCollectionItem.value
|
|
5462
|
-
);
|
|
5463
|
-
}
|
|
5464
|
-
} else if (stringToItem) {
|
|
5465
|
-
const item = stringToItem(text);
|
|
5466
|
-
if (item) {
|
|
5467
|
-
console.log("we have a new item");
|
|
5468
|
-
}
|
|
5469
|
-
}
|
|
5470
|
-
}
|
|
5471
|
-
},
|
|
5472
|
-
[onSelectionChange, selected, stringToItem, stringToCollectionItem, value]
|
|
5473
|
-
);
|
|
5474
5540
|
const { onBlur: inputOnBlur = onBlur } = inputProps;
|
|
5475
5541
|
const { onBlur: listOnBlur } = listControlProps;
|
|
5476
|
-
const handleInputBlur = (0,
|
|
5542
|
+
const handleInputBlur = (0, import_react37.useCallback)(
|
|
5477
5543
|
(evt) => {
|
|
5478
5544
|
if (listFocused(evt)) {
|
|
5479
5545
|
} else {
|
|
5480
5546
|
listOnBlur == null ? void 0 : listOnBlur(evt);
|
|
5481
5547
|
inputOnBlur == null ? void 0 : inputOnBlur(evt);
|
|
5482
|
-
if (allowFreeText) {
|
|
5483
|
-
selectInputValue(evt);
|
|
5484
|
-
} else {
|
|
5485
|
-
reconcileInput();
|
|
5486
|
-
}
|
|
5487
5548
|
setDisableAriaActiveDescendant(true);
|
|
5488
5549
|
ignoreSelectOnFocus.current = true;
|
|
5489
|
-
setIsOpen(false);
|
|
5490
5550
|
}
|
|
5491
5551
|
},
|
|
5492
|
-
[
|
|
5493
|
-
listFocused,
|
|
5494
|
-
listOnBlur,
|
|
5495
|
-
inputOnBlur,
|
|
5496
|
-
allowFreeText,
|
|
5497
|
-
setIsOpen,
|
|
5498
|
-
selectInputValue,
|
|
5499
|
-
reconcileInput
|
|
5500
|
-
]
|
|
5552
|
+
[listFocused, listOnBlur, inputOnBlur]
|
|
5501
5553
|
);
|
|
5502
5554
|
const { onSelect: inputOnSelect } = inputProps;
|
|
5503
|
-
const handleInputSelect = (0,
|
|
5555
|
+
const handleInputSelect = (0, import_react37.useCallback)(
|
|
5504
5556
|
(event) => {
|
|
5505
5557
|
if (ignoreSelectOnFocus.current) {
|
|
5506
5558
|
ignoreSelectOnFocus.current = false;
|
|
@@ -5513,16 +5565,13 @@ var useCombobox = ({
|
|
|
5513
5565
|
);
|
|
5514
5566
|
(0, import_vuu_layout5.useLayoutEffectSkipFirst)(() => {
|
|
5515
5567
|
if (hasSelection(selected)) {
|
|
5516
|
-
highlightSelectedItem();
|
|
5568
|
+
highlightSelectedItem(selected);
|
|
5517
5569
|
} else {
|
|
5518
5570
|
setHighlightedIndex(initialHighlightedIndex);
|
|
5519
5571
|
}
|
|
5520
|
-
if (indexPositions.length === 0) {
|
|
5521
|
-
setIsOpen(false);
|
|
5522
|
-
}
|
|
5523
5572
|
}, [
|
|
5524
5573
|
highlightSelectedItem,
|
|
5525
|
-
|
|
5574
|
+
itemCount,
|
|
5526
5575
|
initialHighlightedIndex,
|
|
5527
5576
|
selected,
|
|
5528
5577
|
setHighlightedIndex,
|
|
@@ -5531,7 +5580,8 @@ var useCombobox = ({
|
|
|
5531
5580
|
const mergedInputProps = {
|
|
5532
5581
|
...inputProps.inputProps,
|
|
5533
5582
|
// "aria-owns": listId,
|
|
5534
|
-
"aria-label": ariaLabel
|
|
5583
|
+
"aria-label": ariaLabel,
|
|
5584
|
+
autoComplete: "off"
|
|
5535
5585
|
};
|
|
5536
5586
|
return {
|
|
5537
5587
|
focusVisible,
|
|
@@ -5548,7 +5598,6 @@ var useCombobox = ({
|
|
|
5548
5598
|
role: "combobox",
|
|
5549
5599
|
value
|
|
5550
5600
|
},
|
|
5551
|
-
// listControlProps,
|
|
5552
5601
|
listControlProps: {
|
|
5553
5602
|
...listControlProps,
|
|
5554
5603
|
onBlur: handleInputBlur,
|
|
@@ -5558,57 +5607,69 @@ var useCombobox = ({
|
|
|
5558
5607
|
...listHookListHandlers,
|
|
5559
5608
|
onClick: handleListClick
|
|
5560
5609
|
},
|
|
5561
|
-
selected
|
|
5610
|
+
selected: selectedRef.current
|
|
5562
5611
|
};
|
|
5563
5612
|
};
|
|
5564
5613
|
|
|
5565
5614
|
// src/list/ChevronIcon.tsx
|
|
5566
5615
|
var import_classnames8 = __toESM(require("classnames"));
|
|
5567
|
-
var
|
|
5616
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
5568
5617
|
var classBase7 = "vuuChevronIcon";
|
|
5569
5618
|
var ChevronIcon = (props) => {
|
|
5570
5619
|
const { direction, ...htmlAttributes } = props;
|
|
5571
|
-
return /* @__PURE__ */ (0,
|
|
5620
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { ...htmlAttributes, className: (0, import_classnames8.default)(classBase7, direction) });
|
|
5572
5621
|
};
|
|
5573
5622
|
|
|
5574
5623
|
// src/combo-box/ComboBox.tsx
|
|
5575
|
-
var
|
|
5576
|
-
var ComboBox = (0,
|
|
5624
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
5625
|
+
var ComboBox = (0, import_react38.forwardRef)(function Combobox({
|
|
5577
5626
|
InputProps: InputProps5,
|
|
5578
5627
|
ListProps: ListProps3,
|
|
5628
|
+
PopupProps,
|
|
5579
5629
|
ListItem: ListItem4,
|
|
5580
5630
|
"aria-label": ariaLabel,
|
|
5581
5631
|
allowFreeText,
|
|
5582
5632
|
children,
|
|
5583
5633
|
defaultIsOpen,
|
|
5634
|
+
defaultSelected,
|
|
5584
5635
|
defaultValue,
|
|
5585
5636
|
disabled,
|
|
5586
5637
|
onBlur,
|
|
5587
5638
|
onFocus,
|
|
5588
5639
|
onChange,
|
|
5589
5640
|
onSelect,
|
|
5641
|
+
onSetSelectedText,
|
|
5590
5642
|
getFilterRegex,
|
|
5591
5643
|
id: idProp,
|
|
5592
5644
|
initialHighlightedIndex = -1,
|
|
5593
5645
|
isOpen: isOpenProp,
|
|
5594
|
-
itemToString: itemToString2,
|
|
5646
|
+
itemToString: itemToString2 = itemToString,
|
|
5647
|
+
itemsToString,
|
|
5595
5648
|
onOpenChange: onOpenChangeProp,
|
|
5596
5649
|
onSelectionChange,
|
|
5650
|
+
selected: selectedProp,
|
|
5597
5651
|
selectionStrategy,
|
|
5598
5652
|
source,
|
|
5599
|
-
stringToItem,
|
|
5600
5653
|
value: valueProp,
|
|
5601
5654
|
width = 180,
|
|
5602
5655
|
...props
|
|
5603
5656
|
}, forwardedRef) {
|
|
5604
5657
|
const id = (0, import_vuu_layout6.useId)(idProp);
|
|
5605
|
-
const listRef = (0,
|
|
5658
|
+
const listRef = (0, import_react38.useRef)(null);
|
|
5659
|
+
const valueFromSelected = (item) => {
|
|
5660
|
+
return Array.isArray(item) && item.length > 0 ? item[0] : void 0;
|
|
5661
|
+
};
|
|
5662
|
+
const getInitialValue = (items1, items2) => {
|
|
5663
|
+
const item = items1 ? valueFromSelected(items1) : items2 ? valueFromSelected(items2) : void 0;
|
|
5664
|
+
return item ? itemToString2(item) : "";
|
|
5665
|
+
};
|
|
5666
|
+
const initialValue = getInitialValue(selectedProp, defaultSelected);
|
|
5606
5667
|
const collectionHook = useCollectionItems({
|
|
5607
5668
|
id,
|
|
5608
5669
|
source,
|
|
5609
5670
|
children,
|
|
5610
5671
|
options: {
|
|
5611
|
-
filterPattern:
|
|
5672
|
+
filterPattern: initialValue,
|
|
5612
5673
|
getFilterRegex,
|
|
5613
5674
|
itemToString: itemToString2
|
|
5614
5675
|
}
|
|
@@ -5628,9 +5689,12 @@ var ComboBox = (0, import_react36.forwardRef)(function Combobox({
|
|
|
5628
5689
|
ariaLabel,
|
|
5629
5690
|
collectionHook,
|
|
5630
5691
|
defaultIsOpen,
|
|
5692
|
+
defaultSelected,
|
|
5631
5693
|
defaultValue,
|
|
5632
5694
|
disabled,
|
|
5633
5695
|
initialHighlightedIndex,
|
|
5696
|
+
itemCount: collectionHook.data.length,
|
|
5697
|
+
label: props.title,
|
|
5634
5698
|
listRef,
|
|
5635
5699
|
onBlur,
|
|
5636
5700
|
onFocus,
|
|
@@ -5639,39 +5703,33 @@ var ComboBox = (0, import_react36.forwardRef)(function Combobox({
|
|
|
5639
5703
|
id,
|
|
5640
5704
|
isOpen: isOpenProp,
|
|
5641
5705
|
itemToString: itemToString2,
|
|
5642
|
-
|
|
5706
|
+
itemsToString,
|
|
5643
5707
|
onOpenChange: onOpenChangeProp,
|
|
5644
5708
|
onSelectionChange,
|
|
5709
|
+
onSetSelectedText,
|
|
5710
|
+
selected: selectedProp,
|
|
5645
5711
|
selectionStrategy,
|
|
5646
|
-
|
|
5647
|
-
value: valueProp
|
|
5712
|
+
value: initialValue
|
|
5648
5713
|
});
|
|
5649
|
-
const
|
|
5650
|
-
(
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
}
|
|
5658
|
-
},
|
|
5659
|
-
[]
|
|
5660
|
-
);
|
|
5661
|
-
const endAdornment = endAdornmentProp === null ? null : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
5714
|
+
const handleDropdownIconClick = (0, import_react38.useCallback)(() => {
|
|
5715
|
+
if (isOpen) {
|
|
5716
|
+
onOpenChange(false, "toggle");
|
|
5717
|
+
} else {
|
|
5718
|
+
onOpenChange(true);
|
|
5719
|
+
}
|
|
5720
|
+
}, [isOpen, onOpenChange]);
|
|
5721
|
+
const endAdornment = endAdornmentProp === null ? null : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
5662
5722
|
ChevronIcon,
|
|
5663
5723
|
{
|
|
5664
5724
|
direction: isOpen ? "up" : "down",
|
|
5665
|
-
onClick:
|
|
5666
|
-
onOpenChange(!isOpen);
|
|
5667
|
-
}
|
|
5725
|
+
onClick: handleDropdownIconClick
|
|
5668
5726
|
}
|
|
5669
5727
|
);
|
|
5670
|
-
return /* @__PURE__ */ (0,
|
|
5728
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CollectionProvider, { collectionHook, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
5671
5729
|
DropdownBase,
|
|
5672
5730
|
{
|
|
5673
5731
|
...props,
|
|
5674
|
-
|
|
5732
|
+
PopupProps,
|
|
5675
5733
|
id,
|
|
5676
5734
|
isOpen,
|
|
5677
5735
|
onOpenChange,
|
|
@@ -5679,7 +5737,7 @@ var ComboBox = (0, import_react36.forwardRef)(function Combobox({
|
|
|
5679
5737
|
ref: forwardedRef,
|
|
5680
5738
|
width,
|
|
5681
5739
|
children: [
|
|
5682
|
-
/* @__PURE__ */ (0,
|
|
5740
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
5683
5741
|
import_core14.Input,
|
|
5684
5742
|
{
|
|
5685
5743
|
...inputProps,
|
|
@@ -5688,11 +5746,12 @@ var ComboBox = (0, import_react36.forwardRef)(function Combobox({
|
|
|
5688
5746
|
endAdornment
|
|
5689
5747
|
}
|
|
5690
5748
|
),
|
|
5691
|
-
/* @__PURE__ */ (0,
|
|
5749
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
5692
5750
|
List,
|
|
5693
5751
|
{
|
|
5694
5752
|
...ListProps3,
|
|
5695
5753
|
ListItem: ListItem4,
|
|
5754
|
+
defaultSelected: void 0,
|
|
5696
5755
|
focusVisible,
|
|
5697
5756
|
highlightedIndex,
|
|
5698
5757
|
itemTextHighlightPattern: String(inputProps.value) || void 0,
|
|
@@ -5700,8 +5759,9 @@ var ComboBox = (0, import_react36.forwardRef)(function Combobox({
|
|
|
5700
5759
|
listHandlers,
|
|
5701
5760
|
onSelectionChange,
|
|
5702
5761
|
ref: listRef,
|
|
5703
|
-
selected
|
|
5704
|
-
selectionStrategy
|
|
5762
|
+
selected,
|
|
5763
|
+
selectionStrategy,
|
|
5764
|
+
tabIndex: -1
|
|
5705
5765
|
}
|
|
5706
5766
|
)
|
|
5707
5767
|
]
|
|
@@ -5745,7 +5805,7 @@ function applyRules(rules, value) {
|
|
|
5745
5805
|
}
|
|
5746
5806
|
|
|
5747
5807
|
// src/editable/useEditableText.ts
|
|
5748
|
-
var
|
|
5808
|
+
var import_react39 = require("react");
|
|
5749
5809
|
var dispatchCommitEvent = (el) => {
|
|
5750
5810
|
const commitEvent = new Event("vuu-commit");
|
|
5751
5811
|
el.dispatchEvent(commitEvent);
|
|
@@ -5755,15 +5815,15 @@ var useEditableText = ({
|
|
|
5755
5815
|
initialValue,
|
|
5756
5816
|
onCommit
|
|
5757
5817
|
}) => {
|
|
5758
|
-
const [message, setMessage] = (0,
|
|
5759
|
-
const [value, setValue] = (0,
|
|
5760
|
-
const initialValueRef = (0,
|
|
5761
|
-
const isDirtyRef = (0,
|
|
5762
|
-
const hasCommittedRef = (0,
|
|
5763
|
-
const handleBlur = (0,
|
|
5818
|
+
const [message, setMessage] = (0, import_react39.useState)();
|
|
5819
|
+
const [value, setValue] = (0, import_react39.useState)(initialValue);
|
|
5820
|
+
const initialValueRef = (0, import_react39.useRef)(initialValue);
|
|
5821
|
+
const isDirtyRef = (0, import_react39.useRef)(false);
|
|
5822
|
+
const hasCommittedRef = (0, import_react39.useRef)(false);
|
|
5823
|
+
const handleBlur = (0, import_react39.useCallback)(() => {
|
|
5764
5824
|
console.log("blur");
|
|
5765
5825
|
}, []);
|
|
5766
|
-
const handleKeyDown = (0,
|
|
5826
|
+
const handleKeyDown = (0, import_react39.useCallback)(
|
|
5767
5827
|
(evt) => {
|
|
5768
5828
|
if (evt.key === "Enter") {
|
|
5769
5829
|
evt.stopPropagation();
|
|
@@ -5795,7 +5855,7 @@ var useEditableText = ({
|
|
|
5795
5855
|
},
|
|
5796
5856
|
[clientSideEditValidationCheck, onCommit, value]
|
|
5797
5857
|
);
|
|
5798
|
-
const handleChange = (0,
|
|
5858
|
+
const handleChange = (0, import_react39.useCallback)(
|
|
5799
5859
|
(evt) => {
|
|
5800
5860
|
const { value: value2 } = evt.target;
|
|
5801
5861
|
isDirtyRef.current = value2 !== initialValueRef.current;
|
|
@@ -5822,11 +5882,11 @@ var useEditableText = ({
|
|
|
5822
5882
|
|
|
5823
5883
|
// src/editable-label/EditableLabel.tsx
|
|
5824
5884
|
var import_classnames9 = __toESM(require("classnames"));
|
|
5825
|
-
var
|
|
5885
|
+
var import_react40 = require("react");
|
|
5826
5886
|
var import_core15 = require("@salt-ds/core");
|
|
5827
|
-
var
|
|
5887
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
5828
5888
|
var classBase8 = "vuuEditableLabel";
|
|
5829
|
-
var EditableLabel = (0,
|
|
5889
|
+
var EditableLabel = (0, import_react40.forwardRef)(function EditableLabel2({
|
|
5830
5890
|
className: classNameProp,
|
|
5831
5891
|
defaultEditing,
|
|
5832
5892
|
defaultValue,
|
|
@@ -5837,8 +5897,8 @@ var EditableLabel = (0, import_react38.forwardRef)(function EditableLabel2({
|
|
|
5837
5897
|
value: valueProp,
|
|
5838
5898
|
...restProps
|
|
5839
5899
|
}, forwardedRef) {
|
|
5840
|
-
const inputRef = (0,
|
|
5841
|
-
const editingRef = (0,
|
|
5900
|
+
const inputRef = (0, import_react40.useRef)(null);
|
|
5901
|
+
const editingRef = (0, import_react40.useRef)(false);
|
|
5842
5902
|
const [value, setValue] = (0, import_core15.useControlled)({
|
|
5843
5903
|
controlled: valueProp,
|
|
5844
5904
|
default: defaultValue != null ? defaultValue : "",
|
|
@@ -5851,14 +5911,14 @@ var EditableLabel = (0, import_react38.forwardRef)(function EditableLabel2({
|
|
|
5851
5911
|
name: "EditableLabel",
|
|
5852
5912
|
state: "editing"
|
|
5853
5913
|
});
|
|
5854
|
-
const setEditing = (0,
|
|
5914
|
+
const setEditing = (0, import_react40.useCallback)(
|
|
5855
5915
|
(value2) => {
|
|
5856
5916
|
_setEditing(editingRef.current = value2);
|
|
5857
5917
|
},
|
|
5858
5918
|
[_setEditing]
|
|
5859
5919
|
);
|
|
5860
|
-
const initialValue = (0,
|
|
5861
|
-
(0,
|
|
5920
|
+
const initialValue = (0, import_react40.useRef)(value);
|
|
5921
|
+
(0, import_react40.useLayoutEffect)(() => {
|
|
5862
5922
|
if (editing) {
|
|
5863
5923
|
if (inputRef.current !== null) {
|
|
5864
5924
|
inputRef.current.select();
|
|
@@ -5866,7 +5926,7 @@ var EditableLabel = (0, import_react38.forwardRef)(function EditableLabel2({
|
|
|
5866
5926
|
}
|
|
5867
5927
|
}
|
|
5868
5928
|
}, [editing, inputRef]);
|
|
5869
|
-
const enterEditMode = (0,
|
|
5929
|
+
const enterEditMode = (0, import_react40.useCallback)(() => {
|
|
5870
5930
|
setEditing(true);
|
|
5871
5931
|
onEnterEditMode && onEnterEditMode();
|
|
5872
5932
|
}, [onEnterEditMode, setEditing]);
|
|
@@ -5911,7 +5971,7 @@ var EditableLabel = (0, import_react38.forwardRef)(function EditableLabel2({
|
|
|
5911
5971
|
const className = (0, import_classnames9.default)(classBase8, classNameProp, {
|
|
5912
5972
|
[`${classBase8}-editing`]: editing
|
|
5913
5973
|
});
|
|
5914
|
-
return /* @__PURE__ */ (0,
|
|
5974
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
5915
5975
|
"div",
|
|
5916
5976
|
{
|
|
5917
5977
|
...restProps,
|
|
@@ -5919,7 +5979,7 @@ var EditableLabel = (0, import_react38.forwardRef)(function EditableLabel2({
|
|
|
5919
5979
|
onDoubleClick: handleDoubleClick,
|
|
5920
5980
|
"data-text": value,
|
|
5921
5981
|
ref: forwardedRef,
|
|
5922
|
-
children: editing ? /* @__PURE__ */ (0,
|
|
5982
|
+
children: editing ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
5923
5983
|
import_core15.Input,
|
|
5924
5984
|
{
|
|
5925
5985
|
inputProps: { className: `${classBase8}-input`, spellCheck: false },
|
|
@@ -5932,7 +5992,7 @@ var EditableLabel = (0, import_react38.forwardRef)(function EditableLabel2({
|
|
|
5932
5992
|
textAlign: "left",
|
|
5933
5993
|
variant: "secondary"
|
|
5934
5994
|
}
|
|
5935
|
-
) : /* @__PURE__ */ (0,
|
|
5995
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: `${classBase8}-label`, children: value })
|
|
5936
5996
|
}
|
|
5937
5997
|
);
|
|
5938
5998
|
});
|
|
@@ -5940,11 +6000,11 @@ var EditableLabel = (0, import_react38.forwardRef)(function EditableLabel2({
|
|
|
5940
6000
|
// src/expando-input/ExpandoInput.tsx
|
|
5941
6001
|
var import_core16 = require("@salt-ds/core");
|
|
5942
6002
|
var import_classnames10 = __toESM(require("classnames"));
|
|
5943
|
-
var
|
|
5944
|
-
var
|
|
6003
|
+
var import_react41 = require("react");
|
|
6004
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
5945
6005
|
var classBase9 = "vuuExpandoInput";
|
|
5946
|
-
var ExpandoInput = (0,
|
|
5947
|
-
return /* @__PURE__ */ (0,
|
|
6006
|
+
var ExpandoInput = (0, import_react41.forwardRef)(function ExpandoInput2({ className: classNameProp, value, inputProps, ...InputProps5 }, forwardedRef) {
|
|
6007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: (0, import_classnames10.default)(classBase9, classNameProp), "data-text": value, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
5948
6008
|
import_core16.Input,
|
|
5949
6009
|
{
|
|
5950
6010
|
...InputProps5,
|
|
@@ -5959,17 +6019,17 @@ var ExpandoInput = (0, import_react39.forwardRef)(function ExpandoInput2({ class
|
|
|
5959
6019
|
});
|
|
5960
6020
|
|
|
5961
6021
|
// src/inputs/Checkbox.tsx
|
|
5962
|
-
var
|
|
6022
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
5963
6023
|
var Checkbox = (props) => {
|
|
5964
6024
|
const { onToggle, checked, label } = props;
|
|
5965
|
-
return /* @__PURE__ */ (0,
|
|
6025
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
5966
6026
|
"div",
|
|
5967
6027
|
{
|
|
5968
6028
|
className: "vuuCheckbox",
|
|
5969
6029
|
onClick: onToggle,
|
|
5970
6030
|
onKeyUp: (e) => e.key === " " && onToggle(),
|
|
5971
6031
|
children: [
|
|
5972
|
-
/* @__PURE__ */ (0,
|
|
6032
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CheckboxIcon, { tabIndex: 0, checked }),
|
|
5973
6033
|
label
|
|
5974
6034
|
]
|
|
5975
6035
|
}
|
|
@@ -5977,28 +6037,27 @@ var Checkbox = (props) => {
|
|
|
5977
6037
|
};
|
|
5978
6038
|
|
|
5979
6039
|
// src/inputs/RadioButton.tsx
|
|
5980
|
-
var
|
|
6040
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
5981
6041
|
var RadioButton = (props) => {
|
|
5982
6042
|
const { onClick, checked, label, groupName } = props;
|
|
5983
|
-
return /* @__PURE__ */ (0,
|
|
5984
|
-
/* @__PURE__ */ (0,
|
|
5985
|
-
/* @__PURE__ */ (0,
|
|
5986
|
-
/* @__PURE__ */ (0,
|
|
6043
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "vuuRadioButton", onClick, children: [
|
|
6044
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "radio", children: [
|
|
6045
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("input", { type: "radio", name: groupName }),
|
|
6046
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RadioIcon, { checked })
|
|
5987
6047
|
] }),
|
|
5988
6048
|
label
|
|
5989
6049
|
] });
|
|
5990
6050
|
};
|
|
5991
6051
|
|
|
5992
|
-
// src/instrument-
|
|
6052
|
+
// src/instrument-picker/InstrumentPicker.tsx
|
|
5993
6053
|
var import_vuu_layout7 = require("@vuu-ui/vuu-layout");
|
|
5994
6054
|
var import_vuu_table = require("@vuu-ui/vuu-table");
|
|
5995
6055
|
var import_core17 = require("@salt-ds/core");
|
|
5996
|
-
var
|
|
5997
|
-
var import_react40 = require("react");
|
|
6056
|
+
var import_react43 = require("react");
|
|
5998
6057
|
|
|
5999
|
-
// src/instrument-
|
|
6058
|
+
// src/instrument-picker/SearchCell.tsx
|
|
6000
6059
|
var import_vuu_utils6 = require("@vuu-ui/vuu-utils");
|
|
6001
|
-
var
|
|
6060
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
6002
6061
|
var classBase10 = "vuuSearchCell";
|
|
6003
6062
|
var SearchCell = ({
|
|
6004
6063
|
column,
|
|
@@ -6007,8 +6066,8 @@ var SearchCell = ({
|
|
|
6007
6066
|
}) => {
|
|
6008
6067
|
const key = columnMap[column.name];
|
|
6009
6068
|
const value = row[key];
|
|
6010
|
-
return /* @__PURE__ */ (0,
|
|
6011
|
-
/* @__PURE__ */ (0,
|
|
6069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: classBase10, tabIndex: -1, children: [
|
|
6070
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { "data-icon": "draggable" }),
|
|
6012
6071
|
value
|
|
6013
6072
|
] });
|
|
6014
6073
|
};
|
|
@@ -6017,9 +6076,176 @@ console.log("register SearchCell");
|
|
|
6017
6076
|
serverDataType: "private"
|
|
6018
6077
|
});
|
|
6019
6078
|
|
|
6079
|
+
// src/instrument-picker/useInstrumentPicker.ts
|
|
6080
|
+
var import_react42 = require("react");
|
|
6081
|
+
var useInstrumentPicker = ({
|
|
6082
|
+
columnMap,
|
|
6083
|
+
dataSource,
|
|
6084
|
+
defaultIsOpen,
|
|
6085
|
+
isOpen: isOpenProp,
|
|
6086
|
+
onSelect,
|
|
6087
|
+
searchColumns
|
|
6088
|
+
}) => {
|
|
6089
|
+
const [value, setValue] = (0, import_react42.useState)("");
|
|
6090
|
+
const [isOpen, setIsOpen] = useControlled({
|
|
6091
|
+
controlled: isOpenProp,
|
|
6092
|
+
default: defaultIsOpen != null ? defaultIsOpen : false,
|
|
6093
|
+
name: "useDropdownList"
|
|
6094
|
+
});
|
|
6095
|
+
console.log({ dataSource });
|
|
6096
|
+
const baseFilterPattern = (0, import_react42.useMemo)(
|
|
6097
|
+
// TODO make this contains once server supports it
|
|
6098
|
+
() => searchColumns.map((col) => `${col} starts "__VALUE__"`).join(" or "),
|
|
6099
|
+
[searchColumns]
|
|
6100
|
+
);
|
|
6101
|
+
const handleOpenChange = (0, import_react42.useCallback)(
|
|
6102
|
+
(open) => {
|
|
6103
|
+
setIsOpen(open);
|
|
6104
|
+
},
|
|
6105
|
+
[setIsOpen]
|
|
6106
|
+
);
|
|
6107
|
+
const handleInputChange = (0, import_react42.useCallback)(
|
|
6108
|
+
(evt) => {
|
|
6109
|
+
const { value: value2 } = evt.target;
|
|
6110
|
+
setValue(value2);
|
|
6111
|
+
if (value2 && value2.trim().length) {
|
|
6112
|
+
const filter = baseFilterPattern.replaceAll("__VALUE__", value2);
|
|
6113
|
+
dataSource.filter = {
|
|
6114
|
+
filter
|
|
6115
|
+
};
|
|
6116
|
+
} else {
|
|
6117
|
+
dataSource.filter = {
|
|
6118
|
+
filter: ""
|
|
6119
|
+
};
|
|
6120
|
+
}
|
|
6121
|
+
setIsOpen(true);
|
|
6122
|
+
},
|
|
6123
|
+
[baseFilterPattern, dataSource, setIsOpen]
|
|
6124
|
+
);
|
|
6125
|
+
const handleSelectRow = (0, import_react42.useCallback)(
|
|
6126
|
+
(row) => {
|
|
6127
|
+
const { name } = columnMap;
|
|
6128
|
+
const { [name]: value2 } = row;
|
|
6129
|
+
setValue(value2);
|
|
6130
|
+
setIsOpen(false);
|
|
6131
|
+
onSelect(row);
|
|
6132
|
+
},
|
|
6133
|
+
[columnMap, onSelect, setIsOpen]
|
|
6134
|
+
);
|
|
6135
|
+
const inputProps = {
|
|
6136
|
+
onChange: handleInputChange
|
|
6137
|
+
};
|
|
6138
|
+
const controlProps = {};
|
|
6139
|
+
const tableHandlers = {
|
|
6140
|
+
onSelect: handleSelectRow
|
|
6141
|
+
};
|
|
6142
|
+
return {
|
|
6143
|
+
controlProps,
|
|
6144
|
+
inputProps,
|
|
6145
|
+
isOpen,
|
|
6146
|
+
onOpenChange: handleOpenChange,
|
|
6147
|
+
tableHandlers,
|
|
6148
|
+
value
|
|
6149
|
+
};
|
|
6150
|
+
};
|
|
6151
|
+
|
|
6152
|
+
// src/instrument-picker/InstrumentPicker.tsx
|
|
6153
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
6154
|
+
var classBase11 = "vuuInstrumentPicker";
|
|
6155
|
+
var InstrumentPicker = (0, import_react43.forwardRef)(function InstrumentPicker2({
|
|
6156
|
+
TableProps: { dataSource, ...TableProps3 },
|
|
6157
|
+
className,
|
|
6158
|
+
columnMap,
|
|
6159
|
+
disabled,
|
|
6160
|
+
id: idProp,
|
|
6161
|
+
onSelect,
|
|
6162
|
+
schema,
|
|
6163
|
+
searchColumns,
|
|
6164
|
+
width,
|
|
6165
|
+
...htmlAttributes
|
|
6166
|
+
}, forwardedRef) {
|
|
6167
|
+
const id = (0, import_vuu_layout7.useId)(idProp);
|
|
6168
|
+
const {
|
|
6169
|
+
controlProps,
|
|
6170
|
+
inputProps,
|
|
6171
|
+
isOpen,
|
|
6172
|
+
onOpenChange,
|
|
6173
|
+
tableHandlers,
|
|
6174
|
+
value
|
|
6175
|
+
} = useInstrumentPicker({ columnMap, dataSource, onSelect, searchColumns });
|
|
6176
|
+
const endAdornment = (0, import_react43.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { "data-icon": "chevron-down" }), []);
|
|
6177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
6178
|
+
DropdownBase,
|
|
6179
|
+
{
|
|
6180
|
+
...htmlAttributes,
|
|
6181
|
+
fullWidth: true,
|
|
6182
|
+
id,
|
|
6183
|
+
isOpen,
|
|
6184
|
+
onOpenChange,
|
|
6185
|
+
openOnFocus: true,
|
|
6186
|
+
placement: "below-full-width",
|
|
6187
|
+
ref: forwardedRef,
|
|
6188
|
+
width,
|
|
6189
|
+
children: [
|
|
6190
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
6191
|
+
import_core17.Input,
|
|
6192
|
+
{
|
|
6193
|
+
...inputProps,
|
|
6194
|
+
disabled,
|
|
6195
|
+
...controlProps,
|
|
6196
|
+
endAdornment,
|
|
6197
|
+
value
|
|
6198
|
+
}
|
|
6199
|
+
),
|
|
6200
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
6201
|
+
import_vuu_table.TableNext,
|
|
6202
|
+
{
|
|
6203
|
+
rowHeight: 25,
|
|
6204
|
+
renderBufferSize: 100,
|
|
6205
|
+
...TableProps3,
|
|
6206
|
+
...tableHandlers,
|
|
6207
|
+
className: `${classBase11}-list`,
|
|
6208
|
+
height: 200,
|
|
6209
|
+
dataSource,
|
|
6210
|
+
showColumnHeaders: false
|
|
6211
|
+
}
|
|
6212
|
+
)
|
|
6213
|
+
]
|
|
6214
|
+
}
|
|
6215
|
+
);
|
|
6216
|
+
});
|
|
6217
|
+
|
|
6020
6218
|
// src/instrument-search/InstrumentSearch.tsx
|
|
6219
|
+
var import_vuu_layout8 = require("@vuu-ui/vuu-layout");
|
|
6220
|
+
var import_vuu_table2 = require("@vuu-ui/vuu-table");
|
|
6221
|
+
var import_core18 = require("@salt-ds/core");
|
|
6222
|
+
var import_classnames11 = __toESM(require("classnames"));
|
|
6223
|
+
var import_react44 = require("react");
|
|
6224
|
+
|
|
6225
|
+
// src/instrument-search/SearchCell.tsx
|
|
6226
|
+
var import_vuu_utils7 = require("@vuu-ui/vuu-utils");
|
|
6021
6227
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
6022
|
-
var
|
|
6228
|
+
var classBase12 = "vuuSearchCell";
|
|
6229
|
+
var SearchCell2 = ({
|
|
6230
|
+
column,
|
|
6231
|
+
columnMap,
|
|
6232
|
+
row
|
|
6233
|
+
}) => {
|
|
6234
|
+
const key = columnMap[column.name];
|
|
6235
|
+
const value = row[key];
|
|
6236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: classBase12, tabIndex: -1, children: [
|
|
6237
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { "data-icon": "draggable" }),
|
|
6238
|
+
value
|
|
6239
|
+
] });
|
|
6240
|
+
};
|
|
6241
|
+
console.log("register SearchCell");
|
|
6242
|
+
(0, import_vuu_utils7.registerComponent)("search-cell", SearchCell2, "cell-renderer", {
|
|
6243
|
+
serverDataType: "private"
|
|
6244
|
+
});
|
|
6245
|
+
|
|
6246
|
+
// src/instrument-search/InstrumentSearch.tsx
|
|
6247
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
6248
|
+
var classBase13 = "vuuInstrumentSearch";
|
|
6023
6249
|
var defaultTableConfig = {
|
|
6024
6250
|
columns: [
|
|
6025
6251
|
{ name: "bbg", hidden: true },
|
|
@@ -6036,16 +6262,16 @@ var defaultTableConfig = {
|
|
|
6036
6262
|
],
|
|
6037
6263
|
rowSeparators: true
|
|
6038
6264
|
};
|
|
6039
|
-
var searchIcon = /* @__PURE__ */ (0,
|
|
6265
|
+
var searchIcon = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { "data-icon": "search" });
|
|
6040
6266
|
var InstrumentSearch = ({
|
|
6041
|
-
TableProps:
|
|
6267
|
+
TableProps: TableProps3,
|
|
6042
6268
|
className,
|
|
6043
6269
|
dataSource,
|
|
6044
6270
|
searchColumn = "description",
|
|
6045
6271
|
...htmlAttributes
|
|
6046
6272
|
}) => {
|
|
6047
|
-
const [searchState, setSearchState] = (0,
|
|
6048
|
-
const handleChange = (0,
|
|
6273
|
+
const [searchState, setSearchState] = (0, import_react44.useState)({ searchText: "", filter: "" });
|
|
6274
|
+
const handleChange = (0, import_react44.useCallback)(
|
|
6049
6275
|
(evt) => {
|
|
6050
6276
|
const { value } = evt.target;
|
|
6051
6277
|
const filter = `name starts "${value}"`;
|
|
@@ -6064,11 +6290,11 @@ var InstrumentSearch = ({
|
|
|
6064
6290
|
},
|
|
6065
6291
|
[dataSource, searchColumn]
|
|
6066
6292
|
);
|
|
6067
|
-
return /* @__PURE__ */ (0,
|
|
6068
|
-
/* @__PURE__ */ (0,
|
|
6069
|
-
/* @__PURE__ */ (0,
|
|
6070
|
-
/* @__PURE__ */ (0,
|
|
6071
|
-
|
|
6293
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { ...htmlAttributes, className: (0, import_classnames11.default)(classBase13, className), children: [
|
|
6294
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_core18.FormField, { className: `${classBase13}-inputField`, children: [
|
|
6295
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_core18.FormFieldLabel, {}),
|
|
6296
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
6297
|
+
import_core18.Input,
|
|
6072
6298
|
{
|
|
6073
6299
|
endAdornment: searchIcon,
|
|
6074
6300
|
value: searchState.searchText,
|
|
@@ -6076,29 +6302,30 @@ var InstrumentSearch = ({
|
|
|
6076
6302
|
}
|
|
6077
6303
|
)
|
|
6078
6304
|
] }),
|
|
6079
|
-
/* @__PURE__ */ (0,
|
|
6080
|
-
|
|
6305
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
6306
|
+
import_vuu_table2.TableNext,
|
|
6081
6307
|
{
|
|
6082
6308
|
rowHeight: 25,
|
|
6083
6309
|
config: defaultTableConfig,
|
|
6084
6310
|
renderBufferSize: 100,
|
|
6085
|
-
...
|
|
6086
|
-
className: `${
|
|
6311
|
+
...TableProps3,
|
|
6312
|
+
className: `${classBase13}-list`,
|
|
6087
6313
|
dataSource,
|
|
6088
6314
|
showColumnHeaders: false
|
|
6089
6315
|
}
|
|
6090
6316
|
)
|
|
6091
6317
|
] });
|
|
6092
6318
|
};
|
|
6093
|
-
|
|
6319
|
+
var _a;
|
|
6320
|
+
(_a = import_vuu_layout8.registerComponent) == null ? void 0 : _a("InstrumentSearch", InstrumentSearch, "view");
|
|
6094
6321
|
|
|
6095
6322
|
// src/price-ticker/PriceTicker.tsx
|
|
6096
|
-
var
|
|
6097
|
-
var
|
|
6323
|
+
var import_vuu_utils8 = require("@vuu-ui/vuu-utils");
|
|
6324
|
+
var import_react45 = require("react");
|
|
6098
6325
|
var import_classnames12 = __toESM(require("classnames"));
|
|
6099
|
-
var
|
|
6100
|
-
var
|
|
6101
|
-
var getValueFormatter = (decimals) => (0,
|
|
6326
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
6327
|
+
var classBase14 = "vuuPriceTicker";
|
|
6328
|
+
var getValueFormatter = (decimals) => (0, import_vuu_utils8.numericFormatter)({
|
|
6102
6329
|
type: {
|
|
6103
6330
|
name: "number",
|
|
6104
6331
|
formatting: {
|
|
@@ -6108,7 +6335,7 @@ var getValueFormatter = (decimals) => (0, import_vuu_utils7.numericFormatter)({
|
|
|
6108
6335
|
}
|
|
6109
6336
|
});
|
|
6110
6337
|
var INITIAL_VALUE = [void 0, void 0];
|
|
6111
|
-
var PriceTicker = (0,
|
|
6338
|
+
var PriceTicker = (0, import_react45.memo)(
|
|
6112
6339
|
({
|
|
6113
6340
|
className,
|
|
6114
6341
|
decimals = 2,
|
|
@@ -6116,28 +6343,28 @@ var PriceTicker = (0, import_react41.memo)(
|
|
|
6116
6343
|
showArrow,
|
|
6117
6344
|
...htmlAttributes
|
|
6118
6345
|
}) => {
|
|
6119
|
-
const ref = (0,
|
|
6346
|
+
const ref = (0, import_react45.useRef)(INITIAL_VALUE);
|
|
6120
6347
|
const [prevValue, prevDirection] = ref.current;
|
|
6121
|
-
const formatNumber = (0,
|
|
6122
|
-
const direction = (0,
|
|
6348
|
+
const formatNumber = (0, import_react45.useMemo)(() => getValueFormatter(decimals), [decimals]);
|
|
6349
|
+
const direction = (0, import_vuu_utils8.isValidNumber)(prevValue) ? (0, import_vuu_utils8.getMovingValueDirection)(price, prevDirection, prevValue, decimals) : "";
|
|
6123
6350
|
ref.current = [price, direction];
|
|
6124
|
-
return /* @__PURE__ */ (0,
|
|
6351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { ...htmlAttributes, className: (0, import_classnames12.default)(classBase14, className, direction), children: [
|
|
6125
6352
|
formatNumber(price),
|
|
6126
|
-
showArrow ? /* @__PURE__ */ (0,
|
|
6353
|
+
showArrow ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "data-icon": "price-arrow" }) : null
|
|
6127
6354
|
] });
|
|
6128
6355
|
}
|
|
6129
6356
|
);
|
|
6130
6357
|
PriceTicker.displayName = "PriceTicker";
|
|
6131
6358
|
|
|
6132
6359
|
// src/tabstrip/Tabstrip.tsx
|
|
6133
|
-
var
|
|
6134
|
-
var
|
|
6360
|
+
var import_vuu_layout9 = require("@vuu-ui/vuu-layout");
|
|
6361
|
+
var import_core21 = require("@salt-ds/core");
|
|
6135
6362
|
var import_classnames13 = __toESM(require("classnames"));
|
|
6136
|
-
var
|
|
6363
|
+
var import_react50 = __toESM(require("react"));
|
|
6137
6364
|
|
|
6138
6365
|
// src/tabstrip/useTabstrip.ts
|
|
6139
|
-
var
|
|
6140
|
-
var
|
|
6366
|
+
var import_vuu_utils13 = require("@vuu-ui/vuu-utils");
|
|
6367
|
+
var import_react49 = require("react");
|
|
6141
6368
|
|
|
6142
6369
|
// src/tabstrip/TabMenuOptions.ts
|
|
6143
6370
|
var isTabMenuOptions = (options) => typeof options === "object" && options !== null && "tabIndex" in options && typeof options.tabIndex === "number";
|
|
@@ -6155,13 +6382,13 @@ var renameCommand = (options) => ({
|
|
|
6155
6382
|
});
|
|
6156
6383
|
|
|
6157
6384
|
// src/tabstrip/tabstrip-dom-utils.ts
|
|
6158
|
-
var
|
|
6385
|
+
var import_vuu_utils9 = require("@vuu-ui/vuu-utils");
|
|
6159
6386
|
var getIndexOfItem = (container, query) => {
|
|
6160
6387
|
if (container) {
|
|
6161
6388
|
const targetTab = container.querySelector(
|
|
6162
6389
|
`[data-index]:has(${query})`
|
|
6163
6390
|
);
|
|
6164
|
-
return (0,
|
|
6391
|
+
return (0, import_vuu_utils9.getElementDataIndex)(targetTab);
|
|
6165
6392
|
}
|
|
6166
6393
|
return -1;
|
|
6167
6394
|
};
|
|
@@ -6169,44 +6396,44 @@ var getIndexOfSelectedTab = (container) => getIndexOfItem(container, '[aria-sele
|
|
|
6169
6396
|
var getIndexOfEditedItem = (container) => getIndexOfItem(container, ".vuuEditableLabel-editing");
|
|
6170
6397
|
|
|
6171
6398
|
// src/tabstrip/useAnimatedSelectionThumb.ts
|
|
6172
|
-
var
|
|
6173
|
-
var
|
|
6399
|
+
var import_vuu_utils10 = require("@vuu-ui/vuu-utils");
|
|
6400
|
+
var import_react46 = require("react");
|
|
6174
6401
|
var useAnimatedSelectionThumb = (containerRef, activeTabIndex, orientation = "horizontal") => {
|
|
6175
|
-
const animationSuspendedRef = (0,
|
|
6176
|
-
const suspendAnimation = (0,
|
|
6402
|
+
const animationSuspendedRef = (0, import_react46.useRef)(false);
|
|
6403
|
+
const suspendAnimation = (0, import_react46.useCallback)(() => {
|
|
6177
6404
|
animationSuspendedRef.current = true;
|
|
6178
6405
|
}, []);
|
|
6179
|
-
const resumeAnimation = (0,
|
|
6406
|
+
const resumeAnimation = (0, import_react46.useCallback)(() => {
|
|
6180
6407
|
animationSuspendedRef.current = false;
|
|
6181
6408
|
}, []);
|
|
6182
|
-
const onTransitionEnd = (0,
|
|
6183
|
-
var
|
|
6184
|
-
(
|
|
6409
|
+
const onTransitionEnd = (0, import_react46.useCallback)(() => {
|
|
6410
|
+
var _a2, _b;
|
|
6411
|
+
(_a2 = containerRef.current) == null ? void 0 : _a2.style.setProperty("--tab-thumb-transition", "none");
|
|
6185
6412
|
(_b = containerRef.current) == null ? void 0 : _b.removeEventListener("transitionend", onTransitionEnd);
|
|
6186
6413
|
}, [containerRef]);
|
|
6187
|
-
const lastSelectedRef = (0,
|
|
6188
|
-
return (0,
|
|
6189
|
-
var
|
|
6414
|
+
const lastSelectedRef = (0, import_react46.useRef)(-1);
|
|
6415
|
+
return (0, import_react46.useMemo)(() => {
|
|
6416
|
+
var _a2, _b;
|
|
6190
6417
|
let offset = 0;
|
|
6191
6418
|
let size = 0;
|
|
6192
6419
|
if (lastSelectedRef.current !== -1) {
|
|
6193
|
-
const oldSelected = (
|
|
6420
|
+
const oldSelected = (_a2 = containerRef.current) == null ? void 0 : _a2.querySelector(".vuuTab-selected");
|
|
6194
6421
|
const newSelected = (_b = containerRef.current) == null ? void 0 : _b.querySelector(
|
|
6195
6422
|
`[data-index="${activeTabIndex}"] .vuuTab`
|
|
6196
6423
|
);
|
|
6197
|
-
const { positionProp, sizeProp } =
|
|
6424
|
+
const { positionProp, sizeProp } = import_vuu_utils10.MEASURES[orientation];
|
|
6198
6425
|
if (oldSelected && newSelected && !animationSuspendedRef.current) {
|
|
6199
6426
|
const { [positionProp]: oldPosition, [sizeProp]: oldSize } = oldSelected.getBoundingClientRect();
|
|
6200
6427
|
const { [positionProp]: newPosition } = newSelected.getBoundingClientRect();
|
|
6201
|
-
if ((0,
|
|
6428
|
+
if ((0, import_vuu_utils10.isValidNumber)(oldPosition) && (0, import_vuu_utils10.isValidNumber)(newPosition) && (0, import_vuu_utils10.isValidNumber)(oldSize)) {
|
|
6202
6429
|
console.log({ orientation, positionProp, oldPosition, newPosition });
|
|
6203
6430
|
offset = oldPosition - newPosition;
|
|
6204
6431
|
size = oldSize;
|
|
6205
6432
|
const speed = orientation === "horizontal" ? 1100 : 700;
|
|
6206
6433
|
const duration = Math.abs(offset / speed);
|
|
6207
6434
|
requestAnimationFrame(() => {
|
|
6208
|
-
var
|
|
6209
|
-
(
|
|
6435
|
+
var _a3, _b2, _c, _d;
|
|
6436
|
+
(_a3 = containerRef.current) == null ? void 0 : _a3.style.setProperty(
|
|
6210
6437
|
"--tab-thumb-offset",
|
|
6211
6438
|
"0px"
|
|
6212
6439
|
);
|
|
@@ -6254,26 +6481,26 @@ var useAnimatedSelectionThumb = (containerRef, activeTabIndex, orientation = "ho
|
|
|
6254
6481
|
};
|
|
6255
6482
|
|
|
6256
6483
|
// src/tabstrip/useKeyboardNavigation.ts
|
|
6257
|
-
var
|
|
6258
|
-
var import_vuu_utils10 = require("@vuu-ui/vuu-utils");
|
|
6259
|
-
var import_react43 = require("react");
|
|
6484
|
+
var import_core19 = require("@salt-ds/core");
|
|
6260
6485
|
var import_vuu_utils11 = require("@vuu-ui/vuu-utils");
|
|
6486
|
+
var import_react47 = require("react");
|
|
6487
|
+
var import_vuu_utils12 = require("@vuu-ui/vuu-utils");
|
|
6261
6488
|
var navigation = {
|
|
6262
6489
|
horizontal: {
|
|
6263
|
-
[
|
|
6264
|
-
[
|
|
6265
|
-
[
|
|
6266
|
-
[
|
|
6490
|
+
[import_vuu_utils12.Home]: "start",
|
|
6491
|
+
[import_vuu_utils12.End]: "end",
|
|
6492
|
+
[import_vuu_utils12.ArrowLeft]: "bwd",
|
|
6493
|
+
[import_vuu_utils12.ArrowRight]: "fwd"
|
|
6267
6494
|
},
|
|
6268
6495
|
vertical: {
|
|
6269
|
-
[
|
|
6270
|
-
[
|
|
6271
|
-
[
|
|
6272
|
-
[
|
|
6496
|
+
[import_vuu_utils12.Home]: "start",
|
|
6497
|
+
[import_vuu_utils12.End]: "end",
|
|
6498
|
+
[import_vuu_utils12.ArrowUp]: "bwd",
|
|
6499
|
+
[import_vuu_utils12.ArrowDown]: "fwd"
|
|
6273
6500
|
}
|
|
6274
6501
|
};
|
|
6275
6502
|
var isNavigationKey2 = (key, orientation = "horizontal") => navigation[orientation][key] !== void 0;
|
|
6276
|
-
var isMenuActivationKey = (key) => key ===
|
|
6503
|
+
var isMenuActivationKey = (key) => key === import_vuu_utils12.ArrowDown;
|
|
6277
6504
|
function nextItemIdx2(count, direction, idx) {
|
|
6278
6505
|
if (direction === "start") {
|
|
6279
6506
|
return 0;
|
|
@@ -6306,23 +6533,23 @@ var useKeyboardNavigation2 = ({
|
|
|
6306
6533
|
selectedIndex: selectedTabIndex = 0
|
|
6307
6534
|
}) => {
|
|
6308
6535
|
const manualActivation = keyBoardActivation === "manual";
|
|
6309
|
-
const mouseClickPending = (0,
|
|
6310
|
-
const focusedRef = (0,
|
|
6311
|
-
const [hasFocus, setHasFocus] = (0,
|
|
6312
|
-
const [, forceRefresh] = (0,
|
|
6313
|
-
const [highlightedIdx, _setHighlightedIdx] = (0,
|
|
6536
|
+
const mouseClickPending = (0, import_react47.useRef)(false);
|
|
6537
|
+
const focusedRef = (0, import_react47.useRef)(-1);
|
|
6538
|
+
const [hasFocus, setHasFocus] = (0, import_react47.useState)(false);
|
|
6539
|
+
const [, forceRefresh] = (0, import_react47.useState)({});
|
|
6540
|
+
const [highlightedIdx, _setHighlightedIdx] = (0, import_core19.useControlled)({
|
|
6314
6541
|
controlled: highlightedIdxProp,
|
|
6315
6542
|
default: defaultHighlightedIdx,
|
|
6316
6543
|
name: "UseKeyboardNavigation"
|
|
6317
6544
|
});
|
|
6318
|
-
const setHighlightedIdx = (0,
|
|
6545
|
+
const setHighlightedIdx = (0, import_react47.useCallback)(
|
|
6319
6546
|
(value) => {
|
|
6320
6547
|
_setHighlightedIdx(focusedRef.current = value);
|
|
6321
6548
|
},
|
|
6322
6549
|
[_setHighlightedIdx]
|
|
6323
6550
|
);
|
|
6324
|
-
const keyboardNavigation = (0,
|
|
6325
|
-
const focusTab = (0,
|
|
6551
|
+
const keyboardNavigation = (0, import_react47.useRef)(false);
|
|
6552
|
+
const focusTab = (0, import_react47.useCallback)(
|
|
6326
6553
|
(tabIndex, immediateFocus = false, withKeyboard, delay = 70) => {
|
|
6327
6554
|
setHighlightedIdx(tabIndex);
|
|
6328
6555
|
if (withKeyboard === true && !keyboardNavigation.current) {
|
|
@@ -6331,7 +6558,7 @@ var useKeyboardNavigation2 = ({
|
|
|
6331
6558
|
const setFocus = () => {
|
|
6332
6559
|
const element = getElementByPosition(containerRef.current, tabIndex);
|
|
6333
6560
|
if (element) {
|
|
6334
|
-
const focussableElement = (0,
|
|
6561
|
+
const focussableElement = (0, import_vuu_utils11.getFocusableElement)(element);
|
|
6335
6562
|
focussableElement == null ? void 0 : focussableElement.focus();
|
|
6336
6563
|
}
|
|
6337
6564
|
};
|
|
@@ -6362,14 +6589,14 @@ var useKeyboardNavigation2 = ({
|
|
|
6362
6589
|
}
|
|
6363
6590
|
}
|
|
6364
6591
|
};
|
|
6365
|
-
const getIndexCount = (0,
|
|
6592
|
+
const getIndexCount = (0, import_react47.useCallback)(
|
|
6366
6593
|
() => {
|
|
6367
|
-
var
|
|
6368
|
-
return (_b = (
|
|
6594
|
+
var _a2, _b;
|
|
6595
|
+
return (_b = (_a2 = containerRef.current) == null ? void 0 : _a2.querySelectorAll(`[data-index]`).length) != null ? _b : 0;
|
|
6369
6596
|
},
|
|
6370
6597
|
[containerRef]
|
|
6371
6598
|
);
|
|
6372
|
-
const nextFocusableItemIdx = (0,
|
|
6599
|
+
const nextFocusableItemIdx = (0, import_react47.useCallback)(
|
|
6373
6600
|
(direction = "fwd", idx) => {
|
|
6374
6601
|
const indexCount = getIndexCount();
|
|
6375
6602
|
const index = typeof idx === "number" ? idx : indexCount;
|
|
@@ -6389,7 +6616,7 @@ var useKeyboardNavigation2 = ({
|
|
|
6389
6616
|
},
|
|
6390
6617
|
[containerRef, getIndexCount]
|
|
6391
6618
|
);
|
|
6392
|
-
const navigateChildItems = (0,
|
|
6619
|
+
const navigateChildItems = (0, import_react47.useCallback)(
|
|
6393
6620
|
(e, forceFocusVisible = false) => {
|
|
6394
6621
|
const direction = navigation[orientation][e.key];
|
|
6395
6622
|
const nextIdx = nextFocusableItemIdx(direction, highlightedIdx);
|
|
@@ -6411,22 +6638,22 @@ var useKeyboardNavigation2 = ({
|
|
|
6411
6638
|
orientation
|
|
6412
6639
|
]
|
|
6413
6640
|
);
|
|
6414
|
-
const highlightedTabHasMenu = (0,
|
|
6641
|
+
const highlightedTabHasMenu = (0, import_react47.useCallback)(() => {
|
|
6415
6642
|
const el = getElementByPosition(containerRef.current, highlightedIdx);
|
|
6416
6643
|
if (el) {
|
|
6417
6644
|
return el.querySelector(".vuuPopupMenu") != null;
|
|
6418
6645
|
}
|
|
6419
6646
|
return false;
|
|
6420
6647
|
}, [containerRef, highlightedIdx]);
|
|
6421
|
-
const activateTabMenu = (0,
|
|
6648
|
+
const activateTabMenu = (0, import_react47.useCallback)(() => {
|
|
6422
6649
|
const el = getElementByPosition(containerRef.current, highlightedIdx);
|
|
6423
6650
|
const menuEl = el == null ? void 0 : el.querySelector(".vuuPopupMenu");
|
|
6424
6651
|
if (menuEl) {
|
|
6425
|
-
(0,
|
|
6652
|
+
(0, import_vuu_utils11.dispatchMouseEvent)(menuEl, "click");
|
|
6426
6653
|
}
|
|
6427
6654
|
return false;
|
|
6428
6655
|
}, [containerRef, highlightedIdx]);
|
|
6429
|
-
const handleKeyDown = (0,
|
|
6656
|
+
const handleKeyDown = (0, import_react47.useCallback)(
|
|
6430
6657
|
(e) => {
|
|
6431
6658
|
if (getIndexCount() > 0 && isNavigationKey2(e.key, orientation)) {
|
|
6432
6659
|
e.preventDefault();
|
|
@@ -6451,7 +6678,7 @@ var useKeyboardNavigation2 = ({
|
|
|
6451
6678
|
const handleItemClick = (_, tabIndex) => {
|
|
6452
6679
|
setHighlightedIdx(tabIndex);
|
|
6453
6680
|
};
|
|
6454
|
-
const handleFocus = (0,
|
|
6681
|
+
const handleFocus = (0, import_react47.useCallback)(() => {
|
|
6455
6682
|
if (!hasFocus) {
|
|
6456
6683
|
setHasFocus(true);
|
|
6457
6684
|
if (!mouseClickPending.current) {
|
|
@@ -6461,7 +6688,7 @@ var useKeyboardNavigation2 = ({
|
|
|
6461
6688
|
}
|
|
6462
6689
|
}
|
|
6463
6690
|
}, [hasFocus]);
|
|
6464
|
-
const handleContainerMouseDown = (0,
|
|
6691
|
+
const handleContainerMouseDown = (0, import_react47.useCallback)(() => {
|
|
6465
6692
|
if (!hasFocus) {
|
|
6466
6693
|
mouseClickPending.current = true;
|
|
6467
6694
|
}
|
|
@@ -6498,8 +6725,8 @@ var useKeyboardNavigation2 = ({
|
|
|
6498
6725
|
};
|
|
6499
6726
|
|
|
6500
6727
|
// src/tabstrip/useSelection.ts
|
|
6501
|
-
var
|
|
6502
|
-
var
|
|
6728
|
+
var import_core20 = require("@salt-ds/core");
|
|
6729
|
+
var import_react48 = require("react");
|
|
6503
6730
|
var defaultSelectionKeys2 = ["Enter", " "];
|
|
6504
6731
|
var isTabElement = (el) => el && el.matches('[class*="vuuTab "]');
|
|
6505
6732
|
var useSelection2 = ({
|
|
@@ -6508,24 +6735,24 @@ var useSelection2 = ({
|
|
|
6508
6735
|
onSelectionChange,
|
|
6509
6736
|
selected: selectedProp
|
|
6510
6737
|
}) => {
|
|
6511
|
-
const [selected, setSelected, isControlled] = (0,
|
|
6738
|
+
const [selected, setSelected, isControlled] = (0, import_core20.useControlled)({
|
|
6512
6739
|
controlled: selectedProp,
|
|
6513
6740
|
default: defaultSelected != null ? defaultSelected : 0,
|
|
6514
6741
|
name: "Tabstrip",
|
|
6515
6742
|
state: "value"
|
|
6516
6743
|
});
|
|
6517
|
-
const isSelectionEvent = (0,
|
|
6744
|
+
const isSelectionEvent = (0, import_react48.useCallback)(
|
|
6518
6745
|
(evt) => defaultSelectionKeys2.includes(evt.key),
|
|
6519
6746
|
[]
|
|
6520
6747
|
);
|
|
6521
|
-
const selectItem = (0,
|
|
6748
|
+
const selectItem = (0, import_react48.useCallback)(
|
|
6522
6749
|
(tabIndex) => {
|
|
6523
6750
|
setSelected(tabIndex);
|
|
6524
6751
|
onSelectionChange == null ? void 0 : onSelectionChange(tabIndex);
|
|
6525
6752
|
},
|
|
6526
6753
|
[onSelectionChange, setSelected]
|
|
6527
6754
|
);
|
|
6528
|
-
const handleKeyDown = (0,
|
|
6755
|
+
const handleKeyDown = (0, import_react48.useCallback)(
|
|
6529
6756
|
(e) => {
|
|
6530
6757
|
const targetElement = e.target;
|
|
6531
6758
|
if (isSelectionEvent(e) && highlightedIdx !== selected && isTabElement(targetElement)) {
|
|
@@ -6536,7 +6763,7 @@ var useSelection2 = ({
|
|
|
6536
6763
|
},
|
|
6537
6764
|
[isSelectionEvent, highlightedIdx, selected, selectItem]
|
|
6538
6765
|
);
|
|
6539
|
-
const onClick = (0,
|
|
6766
|
+
const onClick = (0, import_react48.useCallback)(
|
|
6540
6767
|
(e, tabIndex) => {
|
|
6541
6768
|
if (tabIndex !== selected) {
|
|
6542
6769
|
selectItem(tabIndex);
|
|
@@ -6576,7 +6803,7 @@ var useTabstrip = ({
|
|
|
6576
6803
|
orientation,
|
|
6577
6804
|
keyBoardActivation
|
|
6578
6805
|
}) => {
|
|
6579
|
-
const lastSelection = (0,
|
|
6806
|
+
const lastSelection = (0, import_react49.useRef)(activeTabIndexProp);
|
|
6580
6807
|
const {
|
|
6581
6808
|
focusTab: keyboardHookFocusTab,
|
|
6582
6809
|
highlightedIdx,
|
|
@@ -6606,7 +6833,7 @@ var useTabstrip = ({
|
|
|
6606
6833
|
animateSelectionThumb ? selectionHookSelected : -1,
|
|
6607
6834
|
orientation
|
|
6608
6835
|
);
|
|
6609
|
-
const handleDrop = (0,
|
|
6836
|
+
const handleDrop = (0, import_react49.useCallback)(
|
|
6610
6837
|
(fromIndex, toIndex) => {
|
|
6611
6838
|
const { current: selected } = lastSelection;
|
|
6612
6839
|
console.log(
|
|
@@ -6648,7 +6875,7 @@ var useTabstrip = ({
|
|
|
6648
6875
|
orientation: "horizontal",
|
|
6649
6876
|
itemQuery: ".vuuOverflowContainer-item"
|
|
6650
6877
|
});
|
|
6651
|
-
const handleExitEditMode = (0,
|
|
6878
|
+
const handleExitEditMode = (0, import_react49.useCallback)(
|
|
6652
6879
|
(originalValue, editedValue, allowDeactivation, tabIndex) => {
|
|
6653
6880
|
console.log(
|
|
6654
6881
|
`handleExitEditMode ${originalValue} ${editedValue} ${allowDeactivation} ${tabIndex}`
|
|
@@ -6660,7 +6887,7 @@ var useTabstrip = ({
|
|
|
6660
6887
|
},
|
|
6661
6888
|
[keyboardHookFocusTab, onExitEditMode]
|
|
6662
6889
|
);
|
|
6663
|
-
const handleClick = (0,
|
|
6890
|
+
const handleClick = (0, import_react49.useCallback)(
|
|
6664
6891
|
(evt, tabIndex) => {
|
|
6665
6892
|
keyboardHookHandleClick(evt, tabIndex);
|
|
6666
6893
|
selectionHookHandleClick(evt, tabIndex);
|
|
@@ -6668,7 +6895,7 @@ var useTabstrip = ({
|
|
|
6668
6895
|
// [dragDropHook.isDragging, keyboardHook, selectionHook]
|
|
6669
6896
|
[keyboardHookHandleClick, selectionHookHandleClick]
|
|
6670
6897
|
);
|
|
6671
|
-
const getEditableLabel = (0,
|
|
6898
|
+
const getEditableLabel = (0, import_react49.useCallback)(
|
|
6672
6899
|
(tabIndex = highlightedIdx) => {
|
|
6673
6900
|
const targetEl = getElementWithIndex(containerRef.current, tabIndex);
|
|
6674
6901
|
if (targetEl) {
|
|
@@ -6677,7 +6904,7 @@ var useTabstrip = ({
|
|
|
6677
6904
|
},
|
|
6678
6905
|
[containerRef, highlightedIdx]
|
|
6679
6906
|
);
|
|
6680
|
-
const tabInEditMode = (0,
|
|
6907
|
+
const tabInEditMode = (0, import_react49.useCallback)(
|
|
6681
6908
|
(tabIndex = highlightedIdx) => {
|
|
6682
6909
|
const editableLabel = getEditableLabel(tabIndex);
|
|
6683
6910
|
if (editableLabel) {
|
|
@@ -6687,16 +6914,16 @@ var useTabstrip = ({
|
|
|
6687
6914
|
},
|
|
6688
6915
|
[getEditableLabel, highlightedIdx]
|
|
6689
6916
|
);
|
|
6690
|
-
const editTab = (0,
|
|
6917
|
+
const editTab = (0, import_react49.useCallback)(
|
|
6691
6918
|
(tabIndex = highlightedIdx) => {
|
|
6692
6919
|
const editableLabelEl = getEditableLabel(tabIndex);
|
|
6693
6920
|
if (editableLabelEl) {
|
|
6694
|
-
(0,
|
|
6921
|
+
(0, import_vuu_utils13.dispatchMouseEvent)(editableLabelEl, "dblclick");
|
|
6695
6922
|
}
|
|
6696
6923
|
},
|
|
6697
6924
|
[getEditableLabel, highlightedIdx]
|
|
6698
6925
|
);
|
|
6699
|
-
const handleKeyDown = (0,
|
|
6926
|
+
const handleKeyDown = (0, import_react49.useCallback)(
|
|
6700
6927
|
(evt) => {
|
|
6701
6928
|
keyboardHookHandleKeyDown(evt);
|
|
6702
6929
|
if (!evt.defaultPrevented) {
|
|
@@ -6708,7 +6935,7 @@ var useTabstrip = ({
|
|
|
6708
6935
|
},
|
|
6709
6936
|
[editTab, keyboardHookHandleKeyDown, selectionHookHandleKeyDown]
|
|
6710
6937
|
);
|
|
6711
|
-
const handleCloseTabFromMenu = (0,
|
|
6938
|
+
const handleCloseTabFromMenu = (0, import_react49.useCallback)(
|
|
6712
6939
|
(tabIndex) => {
|
|
6713
6940
|
const selectedTabIndex = getIndexOfSelectedTab(containerRef.current);
|
|
6714
6941
|
const newActiveTabIndex = selectedTabIndex > tabIndex ? selectedTabIndex - 1 : selectedTabIndex === tabIndex ? 0 : selectedTabIndex;
|
|
@@ -6721,14 +6948,14 @@ var useTabstrip = ({
|
|
|
6721
6948
|
},
|
|
6722
6949
|
[containerRef, onCloseTab, resumeAnimation, suspendAnimation]
|
|
6723
6950
|
);
|
|
6724
|
-
const handleRenameTabFromMenu = (0,
|
|
6951
|
+
const handleRenameTabFromMenu = (0, import_react49.useCallback)(
|
|
6725
6952
|
(tabIndex) => {
|
|
6726
6953
|
editTab(tabIndex);
|
|
6727
6954
|
return true;
|
|
6728
6955
|
},
|
|
6729
6956
|
[editTab]
|
|
6730
6957
|
);
|
|
6731
|
-
const handleTabMenuAction = (0,
|
|
6958
|
+
const handleTabMenuAction = (0, import_react49.useCallback)(
|
|
6732
6959
|
(action) => {
|
|
6733
6960
|
if (isTabMenuOptions(action.options)) {
|
|
6734
6961
|
switch (action.menuId) {
|
|
@@ -6744,7 +6971,7 @@ var useTabstrip = ({
|
|
|
6744
6971
|
},
|
|
6745
6972
|
[handleCloseTabFromMenu, handleRenameTabFromMenu]
|
|
6746
6973
|
);
|
|
6747
|
-
const handleTabMenuClose = (0,
|
|
6974
|
+
const handleTabMenuClose = (0, import_react49.useCallback)(() => {
|
|
6748
6975
|
if (!tabInEditMode()) {
|
|
6749
6976
|
keyboardHookFocusTab(highlightedIdx);
|
|
6750
6977
|
} else {
|
|
@@ -6756,7 +6983,7 @@ var useTabstrip = ({
|
|
|
6756
6983
|
keyboardHookSetHighlightedIndex,
|
|
6757
6984
|
tabInEditMode
|
|
6758
6985
|
]);
|
|
6759
|
-
const onSwitchWrappedItemIntoView = (0,
|
|
6986
|
+
const onSwitchWrappedItemIntoView = (0, import_react49.useCallback)(
|
|
6760
6987
|
(item) => {
|
|
6761
6988
|
const index = parseInt(item.index);
|
|
6762
6989
|
if (!isNaN(index)) {
|
|
@@ -6769,7 +6996,7 @@ var useTabstrip = ({
|
|
|
6769
6996
|
onFocus: keyboardHook.onFocus,
|
|
6770
6997
|
onKeyDown: handleKeyDown
|
|
6771
6998
|
};
|
|
6772
|
-
const handleAddTabClick = (0,
|
|
6999
|
+
const handleAddTabClick = (0, import_react49.useCallback)(() => {
|
|
6773
7000
|
onAddTab == null ? void 0 : onAddTab();
|
|
6774
7001
|
requestAnimationFrame(() => {
|
|
6775
7002
|
const selectedTabIndex = getIndexOfSelectedTab(containerRef.current);
|
|
@@ -6802,9 +7029,9 @@ var useTabstrip = ({
|
|
|
6802
7029
|
};
|
|
6803
7030
|
|
|
6804
7031
|
// src/tabstrip/Tabstrip.tsx
|
|
6805
|
-
var
|
|
6806
|
-
var
|
|
6807
|
-
var
|
|
7032
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
7033
|
+
var import_react51 = require("react");
|
|
7034
|
+
var classBase15 = "vuuTabstrip";
|
|
6808
7035
|
var Tabstrip = ({
|
|
6809
7036
|
activeTabIndex: activeTabIndexProp,
|
|
6810
7037
|
allowAddTab,
|
|
@@ -6827,7 +7054,7 @@ var Tabstrip = ({
|
|
|
6827
7054
|
style: styleProp,
|
|
6828
7055
|
...htmlAttributes
|
|
6829
7056
|
}) => {
|
|
6830
|
-
const rootRef = (0,
|
|
7057
|
+
const rootRef = (0, import_react50.useRef)(null);
|
|
6831
7058
|
const {
|
|
6832
7059
|
activeTabIndex,
|
|
6833
7060
|
focusVisible,
|
|
@@ -6849,14 +7076,14 @@ var Tabstrip = ({
|
|
|
6849
7076
|
onMoveTab,
|
|
6850
7077
|
orientation
|
|
6851
7078
|
});
|
|
6852
|
-
const id = (0,
|
|
6853
|
-
const className = (0, import_classnames13.default)(
|
|
7079
|
+
const id = (0, import_vuu_layout9.useId)(idProp);
|
|
7080
|
+
const className = (0, import_classnames13.default)(classBase15, `${classBase15}-${orientation}`, classNameProp);
|
|
6854
7081
|
const style = styleProp || containerStyle ? {
|
|
6855
7082
|
...styleProp,
|
|
6856
7083
|
...containerStyle
|
|
6857
7084
|
} : void 0;
|
|
6858
|
-
const tabs = (0,
|
|
6859
|
-
() => (0,
|
|
7085
|
+
const tabs = (0, import_react50.useMemo)(
|
|
7086
|
+
() => (0, import_vuu_layout9.asReactElements)(children).map((child, index) => {
|
|
6860
7087
|
const {
|
|
6861
7088
|
id: tabId = `${id}-tab-${index}`,
|
|
6862
7089
|
closeable = allowCloseTab,
|
|
@@ -6865,7 +7092,7 @@ var Tabstrip = ({
|
|
|
6865
7092
|
showMenuButton = showTabMenuButton
|
|
6866
7093
|
} = child.props;
|
|
6867
7094
|
const selected = index === activeTabIndex;
|
|
6868
|
-
return
|
|
7095
|
+
return import_react50.default.cloneElement(child, {
|
|
6869
7096
|
...tabProps,
|
|
6870
7097
|
...tabstripHook.navigationProps,
|
|
6871
7098
|
closeable,
|
|
@@ -6882,12 +7109,12 @@ var Tabstrip = ({
|
|
|
6882
7109
|
tabIndex: selected ? 0 : -1
|
|
6883
7110
|
});
|
|
6884
7111
|
}).concat(
|
|
6885
|
-
allowAddTab ? /* @__PURE__ */ (0,
|
|
6886
|
-
|
|
7112
|
+
allowAddTab ? /* @__PURE__ */ (0, import_react51.createElement)(
|
|
7113
|
+
import_core21.Button,
|
|
6887
7114
|
{
|
|
6888
7115
|
...tabstripHook.navigationProps,
|
|
6889
7116
|
"aria-label": "Create Tab",
|
|
6890
|
-
className: `${
|
|
7117
|
+
className: `${classBase15}-addTabButton`,
|
|
6891
7118
|
"data-icon": "add",
|
|
6892
7119
|
"data-overflow-priority": "1",
|
|
6893
7120
|
key: "addButton",
|
|
@@ -6913,9 +7140,9 @@ var Tabstrip = ({
|
|
|
6913
7140
|
tabstripHook.navigationProps
|
|
6914
7141
|
]
|
|
6915
7142
|
);
|
|
6916
|
-
return /* @__PURE__ */ (0,
|
|
6917
|
-
/* @__PURE__ */ (0,
|
|
6918
|
-
|
|
7143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
7144
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
7145
|
+
import_vuu_layout9.OverflowContainer,
|
|
6919
7146
|
{
|
|
6920
7147
|
...htmlAttributes,
|
|
6921
7148
|
...tabstripHook.containerProps,
|
|
@@ -6934,16 +7161,16 @@ var Tabstrip = ({
|
|
|
6934
7161
|
};
|
|
6935
7162
|
|
|
6936
7163
|
// src/tabstrip/Tab.tsx
|
|
6937
|
-
var
|
|
7164
|
+
var import_core22 = require("@salt-ds/core");
|
|
6938
7165
|
var import_classnames15 = __toESM(require("classnames"));
|
|
6939
|
-
var
|
|
7166
|
+
var import_react53 = require("react");
|
|
6940
7167
|
|
|
6941
7168
|
// src/tabstrip/TabMenu.tsx
|
|
6942
7169
|
var import_vuu_popups3 = require("@vuu-ui/vuu-popups");
|
|
6943
|
-
var
|
|
7170
|
+
var import_react52 = require("react");
|
|
6944
7171
|
var import_classnames14 = __toESM(require("classnames"));
|
|
6945
|
-
var
|
|
6946
|
-
var
|
|
7172
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
7173
|
+
var classBase16 = "vuuTabMenu";
|
|
6947
7174
|
var TabMenu = ({
|
|
6948
7175
|
allowClose,
|
|
6949
7176
|
allowRename,
|
|
@@ -6953,7 +7180,7 @@ var TabMenu = ({
|
|
|
6953
7180
|
onMenuClose,
|
|
6954
7181
|
index
|
|
6955
7182
|
}) => {
|
|
6956
|
-
const [menuBuilder, menuOptions] = (0,
|
|
7183
|
+
const [menuBuilder, menuOptions] = (0, import_react52.useMemo)(
|
|
6957
7184
|
() => [
|
|
6958
7185
|
(_location, options) => {
|
|
6959
7186
|
const menuItems = [];
|
|
@@ -6972,10 +7199,10 @@ var TabMenu = ({
|
|
|
6972
7199
|
],
|
|
6973
7200
|
[allowClose, allowRename, controlledComponentId, index]
|
|
6974
7201
|
);
|
|
6975
|
-
return /* @__PURE__ */ (0,
|
|
7202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
6976
7203
|
import_vuu_popups3.PopupMenu,
|
|
6977
7204
|
{
|
|
6978
|
-
className:
|
|
7205
|
+
className: classBase16,
|
|
6979
7206
|
menuBuilder,
|
|
6980
7207
|
menuActionHandler: onMenuAction,
|
|
6981
7208
|
menuLocation: (0, import_classnames14.default)("tab", location),
|
|
@@ -6987,10 +7214,10 @@ var TabMenu = ({
|
|
|
6987
7214
|
};
|
|
6988
7215
|
|
|
6989
7216
|
// src/tabstrip/Tab.tsx
|
|
6990
|
-
var
|
|
6991
|
-
var
|
|
7217
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
7218
|
+
var classBase17 = "vuuTab";
|
|
6992
7219
|
var noop = () => void 0;
|
|
6993
|
-
var Tab = (0,
|
|
7220
|
+
var Tab = (0, import_react53.forwardRef)(function Tab2({
|
|
6994
7221
|
ariaControls,
|
|
6995
7222
|
children,
|
|
6996
7223
|
className,
|
|
@@ -7019,10 +7246,10 @@ var Tab = (0, import_react49.forwardRef)(function Tab2({
|
|
|
7019
7246
|
if (showMenuButton && typeof onMenuAction !== "function") {
|
|
7020
7247
|
throw Error("Tab onMenuAction must be provided if showMenuButton is set");
|
|
7021
7248
|
}
|
|
7022
|
-
const rootRef = (0,
|
|
7023
|
-
const editableRef = (0,
|
|
7024
|
-
const setForkRef = (0,
|
|
7025
|
-
const handleClick = (0,
|
|
7249
|
+
const rootRef = (0, import_react53.useRef)(null);
|
|
7250
|
+
const editableRef = (0, import_react53.useRef)(null);
|
|
7251
|
+
const setForkRef = (0, import_core22.useForkRef)(ref, rootRef);
|
|
7252
|
+
const handleClick = (0, import_react53.useCallback)(
|
|
7026
7253
|
(e) => {
|
|
7027
7254
|
if (!editing) {
|
|
7028
7255
|
e.preventDefault();
|
|
@@ -7047,7 +7274,7 @@ var Tab = (0, import_react49.forwardRef)(function Tab2({
|
|
|
7047
7274
|
};
|
|
7048
7275
|
const getLabel = () => {
|
|
7049
7276
|
if (editable) {
|
|
7050
|
-
return /* @__PURE__ */ (0,
|
|
7277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
7051
7278
|
EditableLabel,
|
|
7052
7279
|
{
|
|
7053
7280
|
editing,
|
|
@@ -7072,18 +7299,18 @@ var Tab = (0, import_react49.forwardRef)(function Tab2({
|
|
|
7072
7299
|
}
|
|
7073
7300
|
onFocusProp == null ? void 0 : onFocusProp(evt);
|
|
7074
7301
|
};
|
|
7075
|
-
return /* @__PURE__ */ (0,
|
|
7302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
7076
7303
|
"div",
|
|
7077
7304
|
{
|
|
7078
7305
|
...props,
|
|
7079
7306
|
"aria-controls": ariaControls,
|
|
7080
7307
|
"aria-selected": selected,
|
|
7081
|
-
className: (0, import_classnames15.default)(
|
|
7082
|
-
[`${
|
|
7308
|
+
className: (0, import_classnames15.default)(classBase17, {
|
|
7309
|
+
[`${classBase17}-closeable`]: closeable,
|
|
7083
7310
|
"vuuDraggable-dragAway": dragging,
|
|
7084
|
-
[`${
|
|
7085
|
-
[`${
|
|
7086
|
-
[`${
|
|
7311
|
+
[`${classBase17}-editing`]: editing,
|
|
7312
|
+
[`${classBase17}-selected`]: selected || void 0,
|
|
7313
|
+
[`${classBase17}-vertical`]: orientation === "vertical",
|
|
7087
7314
|
[`vuuFocusVisible`]: focusVisible
|
|
7088
7315
|
}),
|
|
7089
7316
|
onClick: handleClick,
|
|
@@ -7093,15 +7320,15 @@ var Tab = (0, import_react49.forwardRef)(function Tab2({
|
|
|
7093
7320
|
role: "tab",
|
|
7094
7321
|
tabIndex,
|
|
7095
7322
|
children: [
|
|
7096
|
-
/* @__PURE__ */ (0,
|
|
7323
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: `${classBase17}-main`, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
7097
7324
|
"span",
|
|
7098
7325
|
{
|
|
7099
|
-
className: `${
|
|
7326
|
+
className: `${classBase17}-text`,
|
|
7100
7327
|
"data-text": editable ? void 0 : label,
|
|
7101
7328
|
children: children != null ? children : getLabel()
|
|
7102
7329
|
}
|
|
7103
7330
|
) }),
|
|
7104
|
-
showMenuButton ? /* @__PURE__ */ (0,
|
|
7331
|
+
showMenuButton ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
7105
7332
|
TabMenu,
|
|
7106
7333
|
{
|
|
7107
7334
|
allowClose: closeable,
|
|
@@ -7119,18 +7346,18 @@ var Tab = (0, import_react49.forwardRef)(function Tab2({
|
|
|
7119
7346
|
});
|
|
7120
7347
|
|
|
7121
7348
|
// src/tree/Tree.tsx
|
|
7122
|
-
var
|
|
7349
|
+
var import_core25 = require("@salt-ds/core");
|
|
7123
7350
|
var import_classnames16 = __toESM(require("classnames"));
|
|
7124
|
-
var
|
|
7351
|
+
var import_react62 = require("react");
|
|
7125
7352
|
|
|
7126
7353
|
// src/tree/list-dom-utils.ts
|
|
7127
7354
|
function listItemIndex2(listItemEl) {
|
|
7128
|
-
var
|
|
7355
|
+
var _a2;
|
|
7129
7356
|
if (listItemEl) {
|
|
7130
7357
|
let idx = listItemEl.dataset.idx;
|
|
7131
7358
|
if (idx) {
|
|
7132
7359
|
return parseInt(idx, 10);
|
|
7133
|
-
} else if (idx = (
|
|
7360
|
+
} else if (idx = (_a2 = listItemEl.ariaPosInSet) != null ? _a2 : "-1") {
|
|
7134
7361
|
return parseInt(idx, 10) - 1;
|
|
7135
7362
|
}
|
|
7136
7363
|
}
|
|
@@ -7139,7 +7366,7 @@ var closestListItem2 = (el) => el.closest("[data-idx],[aria-posinset]");
|
|
|
7139
7366
|
var closestListItemIndex2 = (el) => listItemIndex2(closestListItem2(el));
|
|
7140
7367
|
|
|
7141
7368
|
// src/tree/use-items-with-ids.ts
|
|
7142
|
-
var
|
|
7369
|
+
var import_react54 = require("react");
|
|
7143
7370
|
var PathSeparators2 = /* @__PURE__ */ new Set(["/", "-", "."]);
|
|
7144
7371
|
var isPathSeparator2 = (char) => PathSeparators2.has(char);
|
|
7145
7372
|
var isParentPath2 = (parentPath, childPath) => childPath.startsWith(parentPath) && isPathSeparator2(childPath[parentPath.length]);
|
|
@@ -7163,7 +7390,7 @@ var useItemsWithIds = (sourceProp, idRoot = "root", {
|
|
|
7163
7390
|
return 0;
|
|
7164
7391
|
}
|
|
7165
7392
|
};
|
|
7166
|
-
const isExpanded2 = (0,
|
|
7393
|
+
const isExpanded2 = (0, import_react54.useCallback)(
|
|
7167
7394
|
(path) => {
|
|
7168
7395
|
if (Array.isArray(revealSelected)) {
|
|
7169
7396
|
return revealSelected.some((id) => isParentPath2(path, id));
|
|
@@ -7172,17 +7399,17 @@ var useItemsWithIds = (sourceProp, idRoot = "root", {
|
|
|
7172
7399
|
},
|
|
7173
7400
|
[defaultExpanded, revealSelected]
|
|
7174
7401
|
);
|
|
7175
|
-
const normalizeItems = (0,
|
|
7402
|
+
const normalizeItems = (0, import_react54.useCallback)(
|
|
7176
7403
|
(items, indexer, level = 1, path = "", results = [], flattenedSource2 = []) => {
|
|
7177
7404
|
let count2 = 0;
|
|
7178
7405
|
items.forEach((item, i, all) => {
|
|
7179
|
-
var
|
|
7406
|
+
var _a2;
|
|
7180
7407
|
const isCollapsibleHeader = item.header && collapsibleHeaders;
|
|
7181
7408
|
const isNonCollapsibleGroupNode = item.childNodes && collapsibleHeaders === false;
|
|
7182
7409
|
const isLeaf3 = !item.childNodes || item.childNodes.length === 0;
|
|
7183
7410
|
const nonCollapsible = isNonCollapsibleGroupNode || isLeaf3 && !isCollapsibleHeader;
|
|
7184
7411
|
const childPath = path ? `${path}.${i}` : `${i}`;
|
|
7185
|
-
const id = (
|
|
7412
|
+
const id = (_a2 = item.id) != null ? _a2 : `${idRoot}-${childPath}`;
|
|
7186
7413
|
const expanded = nonCollapsible ? void 0 : isExpanded2(id);
|
|
7187
7414
|
const normalisedItem = {
|
|
7188
7415
|
...item,
|
|
@@ -7216,15 +7443,15 @@ var useItemsWithIds = (sourceProp, idRoot = "root", {
|
|
|
7216
7443
|
},
|
|
7217
7444
|
[collapsibleHeaders, idRoot, isExpanded2]
|
|
7218
7445
|
);
|
|
7219
|
-
const [count, sourceWithIds, flattenedSource] = (0,
|
|
7446
|
+
const [count, sourceWithIds, flattenedSource] = (0, import_react54.useMemo)(() => {
|
|
7220
7447
|
return normalizeItems(sourceProp, { index: 0 });
|
|
7221
7448
|
}, [normalizeItems, sourceProp]);
|
|
7222
|
-
const sourceItemById = (0,
|
|
7449
|
+
const sourceItemById = (0, import_react54.useCallback)(
|
|
7223
7450
|
(id, target = sourceWithIds) => {
|
|
7224
7451
|
const sourceWithId = target.find(
|
|
7225
7452
|
(i) => {
|
|
7226
|
-
var
|
|
7227
|
-
return i.id === id || ((
|
|
7453
|
+
var _a2;
|
|
7454
|
+
return i.id === id || ((_a2 = i == null ? void 0 : i.childNodes) == null ? void 0 : _a2.length) && isParentPath2(i.id, id);
|
|
7228
7455
|
}
|
|
7229
7456
|
);
|
|
7230
7457
|
if ((sourceWithId == null ? void 0 : sourceWithId.id) === id) {
|
|
@@ -7239,8 +7466,8 @@ var useItemsWithIds = (sourceProp, idRoot = "root", {
|
|
|
7239
7466
|
};
|
|
7240
7467
|
|
|
7241
7468
|
// src/tree/use-selection.ts
|
|
7242
|
-
var
|
|
7243
|
-
var
|
|
7469
|
+
var import_react55 = require("react");
|
|
7470
|
+
var import_core23 = require("@salt-ds/core");
|
|
7244
7471
|
var SINGLE = "single";
|
|
7245
7472
|
var CHECKBOX2 = "checkbox";
|
|
7246
7473
|
var MULTI = "multi";
|
|
@@ -7261,17 +7488,17 @@ var useSelection3 = ({
|
|
|
7261
7488
|
const singleSelect = selection === SINGLE;
|
|
7262
7489
|
const multiSelect = selection === MULTI || selection.startsWith(CHECKBOX2);
|
|
7263
7490
|
const extendedSelect = selection === EXTENDED;
|
|
7264
|
-
const lastActive = (0,
|
|
7265
|
-
const isSelectionEvent = (0,
|
|
7491
|
+
const lastActive = (0, import_react55.useRef)(-1);
|
|
7492
|
+
const isSelectionEvent = (0, import_react55.useCallback)(
|
|
7266
7493
|
(evt) => selectionKeys.includes(evt.key),
|
|
7267
7494
|
[selectionKeys]
|
|
7268
7495
|
);
|
|
7269
|
-
const [selected, setSelected] = (0,
|
|
7496
|
+
const [selected, setSelected] = (0, import_core23.useControlled)({
|
|
7270
7497
|
controlled: selectedProp,
|
|
7271
7498
|
default: defaultSelected != null ? defaultSelected : [],
|
|
7272
7499
|
name: "selected"
|
|
7273
7500
|
});
|
|
7274
|
-
const selectItemAtIndex = (0,
|
|
7501
|
+
const selectItemAtIndex = (0, import_react55.useCallback)(
|
|
7275
7502
|
(evt, idx, id, rangeSelect, preserveExistingSelection = false) => {
|
|
7276
7503
|
const { current: active } = lastActive;
|
|
7277
7504
|
const isSelected2 = selected == null ? void 0 : selected.includes(id);
|
|
@@ -7312,7 +7539,7 @@ var useSelection3 = ({
|
|
|
7312
7539
|
singleSelect
|
|
7313
7540
|
]
|
|
7314
7541
|
);
|
|
7315
|
-
const handleKeyDown = (0,
|
|
7542
|
+
const handleKeyDown = (0, import_react55.useCallback)(
|
|
7316
7543
|
(evt) => {
|
|
7317
7544
|
if (~highlightedIdx && isSelectionEvent(evt)) {
|
|
7318
7545
|
evt.preventDefault();
|
|
@@ -7337,7 +7564,7 @@ var useSelection3 = ({
|
|
|
7337
7564
|
selectItemAtIndex
|
|
7338
7565
|
]
|
|
7339
7566
|
);
|
|
7340
|
-
const handleKeyboardNavigation = (0,
|
|
7567
|
+
const handleKeyboardNavigation = (0, import_react55.useCallback)(
|
|
7341
7568
|
(evt, currentIndex) => {
|
|
7342
7569
|
if (extendedSelect && evt.shiftKey) {
|
|
7343
7570
|
const item = treeNodes[currentIndex];
|
|
@@ -7350,7 +7577,7 @@ var useSelection3 = ({
|
|
|
7350
7577
|
onKeyDown: handleKeyDown,
|
|
7351
7578
|
onKeyboardNavigation: handleKeyboardNavigation
|
|
7352
7579
|
};
|
|
7353
|
-
const handleClick = (0,
|
|
7580
|
+
const handleClick = (0, import_react55.useCallback)(
|
|
7354
7581
|
(evt) => {
|
|
7355
7582
|
if (highlightedIdx !== -1) {
|
|
7356
7583
|
const item = treeNodes[highlightedIdx];
|
|
@@ -7384,14 +7611,14 @@ var useSelection3 = ({
|
|
|
7384
7611
|
};
|
|
7385
7612
|
|
|
7386
7613
|
// src/tree/use-viewport-tracking.ts
|
|
7387
|
-
var
|
|
7614
|
+
var import_react56 = require("react");
|
|
7388
7615
|
var HeightOnly3 = ["height", "scrollHeight"];
|
|
7389
7616
|
var useViewportTracking2 = (root, highlightedIdx, stickyHeaders = false) => {
|
|
7390
|
-
const scrollTop = (0,
|
|
7391
|
-
const scrolling = (0,
|
|
7392
|
-
const rootHeight = (0,
|
|
7393
|
-
const rootScrollHeight = (0,
|
|
7394
|
-
const scrollIntoView = (0,
|
|
7617
|
+
const scrollTop = (0, import_react56.useRef)(0);
|
|
7618
|
+
const scrolling = (0, import_react56.useRef)(false);
|
|
7619
|
+
const rootHeight = (0, import_react56.useRef)(0);
|
|
7620
|
+
const rootScrollHeight = (0, import_react56.useRef)(0);
|
|
7621
|
+
const scrollIntoView = (0, import_react56.useCallback)(
|
|
7395
7622
|
(el) => {
|
|
7396
7623
|
const targetEl = el.ariaExpanded ? el.firstChild : el;
|
|
7397
7624
|
const headerHeight = stickyHeaders ? 30 : 0;
|
|
@@ -7412,10 +7639,10 @@ var useViewportTracking2 = (root, highlightedIdx, stickyHeaders = false) => {
|
|
|
7412
7639
|
},
|
|
7413
7640
|
[root, stickyHeaders]
|
|
7414
7641
|
);
|
|
7415
|
-
const scrollHandler = (0,
|
|
7642
|
+
const scrollHandler = (0, import_react56.useCallback)((e) => {
|
|
7416
7643
|
scrollTop.current = e.target.scrollTop;
|
|
7417
7644
|
}, []);
|
|
7418
|
-
(0,
|
|
7645
|
+
(0, import_react56.useEffect)(() => {
|
|
7419
7646
|
const { current: rootEl } = root;
|
|
7420
7647
|
if (rootEl) {
|
|
7421
7648
|
rootEl.addEventListener("scroll", scrollHandler);
|
|
@@ -7426,7 +7653,7 @@ var useViewportTracking2 = (root, highlightedIdx, stickyHeaders = false) => {
|
|
|
7426
7653
|
}
|
|
7427
7654
|
};
|
|
7428
7655
|
}, [root, scrollHandler]);
|
|
7429
|
-
(0,
|
|
7656
|
+
(0, import_react56.useLayoutEffect)(() => {
|
|
7430
7657
|
if (highlightedIdx !== -1 && rootScrollHeight.current > rootHeight.current) {
|
|
7431
7658
|
if (root.current) {
|
|
7432
7659
|
const item = root.current.querySelector(`
|
|
@@ -7443,9 +7670,9 @@ var useViewportTracking2 = (root, highlightedIdx, stickyHeaders = false) => {
|
|
|
7443
7670
|
}
|
|
7444
7671
|
}
|
|
7445
7672
|
}, [highlightedIdx, root, scrollIntoView]);
|
|
7446
|
-
(0,
|
|
7673
|
+
(0, import_react56.useEffect)(() => {
|
|
7447
7674
|
}, [stickyHeaders]);
|
|
7448
|
-
const onResize = (0,
|
|
7675
|
+
const onResize = (0, import_react56.useCallback)(({ height, scrollHeight }) => {
|
|
7449
7676
|
rootHeight.current = height;
|
|
7450
7677
|
rootScrollHeight.current = scrollHeight;
|
|
7451
7678
|
}, []);
|
|
@@ -7454,10 +7681,10 @@ var useViewportTracking2 = (root, highlightedIdx, stickyHeaders = false) => {
|
|
|
7454
7681
|
};
|
|
7455
7682
|
|
|
7456
7683
|
// src/tree/useTree.ts
|
|
7457
|
-
var
|
|
7684
|
+
var import_react61 = require("react");
|
|
7458
7685
|
|
|
7459
7686
|
// src/tree/use-keyboard-navigation.ts
|
|
7460
|
-
var
|
|
7687
|
+
var import_react57 = require("react");
|
|
7461
7688
|
|
|
7462
7689
|
// src/tree/hierarchical-data-utils.ts
|
|
7463
7690
|
var getNodeParentPath = ({ id }) => {
|
|
@@ -7524,7 +7751,7 @@ var replaceNode = (nodes, id, props) => {
|
|
|
7524
7751
|
};
|
|
7525
7752
|
|
|
7526
7753
|
// src/tree/use-keyboard-navigation.ts
|
|
7527
|
-
var
|
|
7754
|
+
var import_core24 = require("@salt-ds/core");
|
|
7528
7755
|
|
|
7529
7756
|
// src/tree/key-code.ts
|
|
7530
7757
|
function union2(set1, ...sets) {
|
|
@@ -7607,26 +7834,26 @@ var useKeyboardNavigation3 = ({
|
|
|
7607
7834
|
onKeyboardNavigation,
|
|
7608
7835
|
selected = []
|
|
7609
7836
|
}) => {
|
|
7610
|
-
const { bwd: ArrowBwd, fwd: ArrowFwd } = (0,
|
|
7837
|
+
const { bwd: ArrowBwd, fwd: ArrowFwd } = (0, import_react57.useMemo)(
|
|
7611
7838
|
() => ({
|
|
7612
7839
|
bwd: ArrowUp3,
|
|
7613
7840
|
fwd: ArrowDown3
|
|
7614
7841
|
}),
|
|
7615
7842
|
[]
|
|
7616
7843
|
);
|
|
7617
|
-
const [highlightedIdx, setHighlightedIdx, isControlledHighlighting] = (0,
|
|
7844
|
+
const [highlightedIdx, setHighlightedIdx, isControlledHighlighting] = (0, import_core24.useControlled)({
|
|
7618
7845
|
controlled: highlightedIdxProp,
|
|
7619
7846
|
default: defaultHighlightedIdx,
|
|
7620
7847
|
name: "highlightedIdx"
|
|
7621
7848
|
});
|
|
7622
|
-
const setHighlightedIndex = (0,
|
|
7849
|
+
const setHighlightedIndex = (0, import_react57.useCallback)(
|
|
7623
7850
|
(idx) => {
|
|
7624
7851
|
onHighlight == null ? void 0 : onHighlight(idx);
|
|
7625
7852
|
setHighlightedIdx(idx);
|
|
7626
7853
|
},
|
|
7627
7854
|
[onHighlight, setHighlightedIdx]
|
|
7628
7855
|
);
|
|
7629
|
-
const nextFocusableItemIdx = (0,
|
|
7856
|
+
const nextFocusableItemIdx = (0, import_react57.useCallback)(
|
|
7630
7857
|
(key = ArrowFwd, idx = key === ArrowFwd ? -1 : treeNodes.length) => {
|
|
7631
7858
|
let nextIdx = nextItemIdx3(treeNodes.length, key, idx);
|
|
7632
7859
|
while (nextIdx !== -1 && (key === ArrowFwd && nextIdx < treeNodes.length || key === ArrowBwd && nextIdx > 0) && !isFocusable3(treeNodes[nextIdx])) {
|
|
@@ -7636,10 +7863,10 @@ var useKeyboardNavigation3 = ({
|
|
|
7636
7863
|
},
|
|
7637
7864
|
[ArrowBwd, ArrowFwd, treeNodes]
|
|
7638
7865
|
);
|
|
7639
|
-
const keyBoardNavigation = (0,
|
|
7640
|
-
const ignoreFocus = (0,
|
|
7866
|
+
const keyBoardNavigation = (0, import_react57.useRef)(true);
|
|
7867
|
+
const ignoreFocus = (0, import_react57.useRef)(false);
|
|
7641
7868
|
const setIgnoreFocus = (value) => ignoreFocus.current = value;
|
|
7642
|
-
const handleFocus = (0,
|
|
7869
|
+
const handleFocus = (0, import_react57.useCallback)(() => {
|
|
7643
7870
|
if (ignoreFocus.current) {
|
|
7644
7871
|
ignoreFocus.current = false;
|
|
7645
7872
|
} else if (selected.length > 0) {
|
|
@@ -7652,7 +7879,7 @@ var useKeyboardNavigation3 = ({
|
|
|
7652
7879
|
setHighlightedIndex(nextFocusableItemIdx());
|
|
7653
7880
|
}
|
|
7654
7881
|
}, [treeNodes, nextFocusableItemIdx, selected, setHighlightedIndex]);
|
|
7655
|
-
const navigateChildItems = (0,
|
|
7882
|
+
const navigateChildItems = (0, import_react57.useCallback)(
|
|
7656
7883
|
(e) => {
|
|
7657
7884
|
const nextIdx = nextFocusableItemIdx(e.key, highlightedIdx);
|
|
7658
7885
|
if (nextIdx !== highlightedIdx) {
|
|
@@ -7667,7 +7894,7 @@ var useKeyboardNavigation3 = ({
|
|
|
7667
7894
|
setHighlightedIndex
|
|
7668
7895
|
]
|
|
7669
7896
|
);
|
|
7670
|
-
const handleKeyDown = (0,
|
|
7897
|
+
const handleKeyDown = (0, import_react57.useCallback)(
|
|
7671
7898
|
(e) => {
|
|
7672
7899
|
if (treeNodes.length > 0 && isNavigationKey3(e, "vertical")) {
|
|
7673
7900
|
e.preventDefault();
|
|
@@ -7678,7 +7905,7 @@ var useKeyboardNavigation3 = ({
|
|
|
7678
7905
|
},
|
|
7679
7906
|
[treeNodes, navigateChildItems]
|
|
7680
7907
|
);
|
|
7681
|
-
const listProps = (0,
|
|
7908
|
+
const listProps = (0, import_react57.useMemo)(
|
|
7682
7909
|
() => ({
|
|
7683
7910
|
onBlur: () => {
|
|
7684
7911
|
setHighlightedIndex(-1);
|
|
@@ -7716,7 +7943,7 @@ var useKeyboardNavigation3 = ({
|
|
|
7716
7943
|
};
|
|
7717
7944
|
|
|
7718
7945
|
// src/tree/use-hierarchical-data.ts
|
|
7719
|
-
var
|
|
7946
|
+
var import_react58 = require("react");
|
|
7720
7947
|
var populateIndices = (nodes, results = [], idx = { value: 0 }) => {
|
|
7721
7948
|
let skipToNextHeader = false;
|
|
7722
7949
|
for (const node of nodes) {
|
|
@@ -7738,10 +7965,10 @@ var populateIndices = (nodes, results = [], idx = { value: 0 }) => {
|
|
|
7738
7965
|
return results;
|
|
7739
7966
|
};
|
|
7740
7967
|
var useHierarchicalData = (source) => {
|
|
7741
|
-
const externalSource = (0,
|
|
7742
|
-
const statefulSource = (0,
|
|
7743
|
-
const indexPositions = (0,
|
|
7744
|
-
const [, forceUpdate] = (0,
|
|
7968
|
+
const externalSource = (0, import_react58.useRef)(source);
|
|
7969
|
+
const statefulSource = (0, import_react58.useRef)(source);
|
|
7970
|
+
const indexPositions = (0, import_react58.useRef)(populateIndices(source));
|
|
7971
|
+
const [, forceUpdate] = (0, import_react58.useState)({});
|
|
7745
7972
|
if (source !== externalSource.current) {
|
|
7746
7973
|
externalSource.current = source;
|
|
7747
7974
|
statefulSource.current = source;
|
|
@@ -7761,7 +7988,7 @@ var useHierarchicalData = (source) => {
|
|
|
7761
7988
|
};
|
|
7762
7989
|
|
|
7763
7990
|
// src/tree/use-collapsible-groups.ts
|
|
7764
|
-
var
|
|
7991
|
+
var import_react59 = require("react");
|
|
7765
7992
|
var NO_HANDLERS4 = {};
|
|
7766
7993
|
var isToggleElement = (element) => element && element.hasAttribute("aria-expanded");
|
|
7767
7994
|
var useCollapsibleGroups2 = ({
|
|
@@ -7771,23 +7998,23 @@ var useCollapsibleGroups2 = ({
|
|
|
7771
7998
|
setVisibleData,
|
|
7772
7999
|
source
|
|
7773
8000
|
}) => {
|
|
7774
|
-
const fullSource = (0,
|
|
7775
|
-
const stateSource = (0,
|
|
7776
|
-
const setSource = (0,
|
|
8001
|
+
const fullSource = (0, import_react59.useRef)(source);
|
|
8002
|
+
const stateSource = (0, import_react59.useRef)(fullSource.current);
|
|
8003
|
+
const setSource = (0, import_react59.useCallback)(
|
|
7777
8004
|
(value) => {
|
|
7778
8005
|
setVisibleData(stateSource.current = value);
|
|
7779
8006
|
},
|
|
7780
8007
|
[setVisibleData]
|
|
7781
8008
|
);
|
|
7782
|
-
const expandNode = (0,
|
|
8009
|
+
const expandNode = (0, import_react59.useCallback)(
|
|
7783
8010
|
(nodeList, { id }) => replaceNode(nodeList, id, { expanded: true }),
|
|
7784
8011
|
[]
|
|
7785
8012
|
);
|
|
7786
|
-
const collapseNode = (0,
|
|
8013
|
+
const collapseNode = (0, import_react59.useCallback)(
|
|
7787
8014
|
(nodeList, { id }) => replaceNode(nodeList, id, { expanded: false }),
|
|
7788
8015
|
[]
|
|
7789
8016
|
);
|
|
7790
|
-
const handleKeyDown = (0,
|
|
8017
|
+
const handleKeyDown = (0, import_react59.useCallback)(
|
|
7791
8018
|
(e) => {
|
|
7792
8019
|
if (e.key === ArrowRight3 || e.key === Enter2) {
|
|
7793
8020
|
const node = treeNodes[highlightedIdx];
|
|
@@ -7813,7 +8040,7 @@ var useCollapsibleGroups2 = ({
|
|
|
7813
8040
|
const listHandlers = collapsibleHeaders ? {
|
|
7814
8041
|
onKeyDown: handleKeyDown
|
|
7815
8042
|
} : NO_HANDLERS4;
|
|
7816
|
-
const handleClick = (0,
|
|
8043
|
+
const handleClick = (0, import_react59.useCallback)(
|
|
7817
8044
|
(evt) => {
|
|
7818
8045
|
const el = closestListItem2(evt.target);
|
|
7819
8046
|
if (isToggleElement(el)) {
|
|
@@ -7839,14 +8066,14 @@ var useCollapsibleGroups2 = ({
|
|
|
7839
8066
|
};
|
|
7840
8067
|
|
|
7841
8068
|
// src/tree/use-tree-keyboard-navigation.ts
|
|
7842
|
-
var
|
|
8069
|
+
var import_react60 = require("react");
|
|
7843
8070
|
var useTreeKeyboardNavigation = ({
|
|
7844
8071
|
highlightedIdx,
|
|
7845
8072
|
hiliteItemAtIndex,
|
|
7846
8073
|
indexPositions,
|
|
7847
8074
|
source
|
|
7848
8075
|
}) => {
|
|
7849
|
-
const handleKeyDown = (0,
|
|
8076
|
+
const handleKeyDown = (0, import_react60.useCallback)(
|
|
7850
8077
|
(e) => {
|
|
7851
8078
|
if (e.key === ArrowLeft3) {
|
|
7852
8079
|
const node = indexPositions[highlightedIdx];
|
|
@@ -7883,11 +8110,11 @@ var useTree = ({
|
|
|
7883
8110
|
selected: selectedProp,
|
|
7884
8111
|
selection
|
|
7885
8112
|
}) => {
|
|
7886
|
-
const lastSelection = (0,
|
|
8113
|
+
const lastSelection = (0, import_react61.useRef)(EMPTY_ARRAY2);
|
|
7887
8114
|
const dataHook = useHierarchicalData(sourceWithIds);
|
|
7888
8115
|
const handleKeyboardNavigation = (evt, nextIdx) => {
|
|
7889
|
-
var
|
|
7890
|
-
(_b = (
|
|
8116
|
+
var _a2, _b;
|
|
8117
|
+
(_b = (_a2 = selectionHook.listHandlers).onKeyboardNavigation) == null ? void 0 : _b.call(_a2, evt, nextIdx);
|
|
7891
8118
|
};
|
|
7892
8119
|
const { highlightedIdx, ...keyboardHook } = useKeyboardNavigation3({
|
|
7893
8120
|
treeNodes: dataHook.indexPositions,
|
|
@@ -7916,20 +8143,20 @@ var useTree = ({
|
|
|
7916
8143
|
hiliteItemAtIndex: keyboardHook.hiliteItemAtIndex,
|
|
7917
8144
|
indexPositions: dataHook.indexPositions
|
|
7918
8145
|
});
|
|
7919
|
-
const handleClick = (0,
|
|
8146
|
+
const handleClick = (0, import_react61.useCallback)(
|
|
7920
8147
|
(evt) => {
|
|
7921
|
-
var
|
|
7922
|
-
(
|
|
8148
|
+
var _a2, _b, _c;
|
|
8149
|
+
(_a2 = collapsibleHook.listItemHandlers) == null ? void 0 : _a2.onClick(evt);
|
|
7923
8150
|
if (!evt.defaultPrevented) {
|
|
7924
8151
|
(_c = (_b = selectionHook.listItemHandlers) == null ? void 0 : _b.onClick) == null ? void 0 : _c.call(_b, evt);
|
|
7925
8152
|
}
|
|
7926
8153
|
},
|
|
7927
8154
|
[collapsibleHook, selectionHook]
|
|
7928
8155
|
);
|
|
7929
|
-
const handleKeyDown = (0,
|
|
8156
|
+
const handleKeyDown = (0, import_react61.useCallback)(
|
|
7930
8157
|
(evt) => {
|
|
7931
|
-
var
|
|
7932
|
-
(_b = (
|
|
8158
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
8159
|
+
(_b = (_a2 = keyboardHook.listProps).onKeyDown) == null ? void 0 : _b.call(_a2, evt);
|
|
7933
8160
|
if (!evt.defaultPrevented) {
|
|
7934
8161
|
(_d = (_c = selectionHook.listHandlers).onKeyDown) == null ? void 0 : _d.call(_c, evt);
|
|
7935
8162
|
}
|
|
@@ -7948,8 +8175,8 @@ var useTree = ({
|
|
|
7948
8175
|
]
|
|
7949
8176
|
);
|
|
7950
8177
|
const getActiveDescendant = () => {
|
|
7951
|
-
var
|
|
7952
|
-
return highlightedIdx === void 0 || highlightedIdx === -1 ? void 0 : (
|
|
8178
|
+
var _a2;
|
|
8179
|
+
return highlightedIdx === void 0 || highlightedIdx === -1 ? void 0 : (_a2 = dataHook.indexPositions[highlightedIdx]) == null ? void 0 : _a2.id;
|
|
7953
8180
|
};
|
|
7954
8181
|
lastSelection.current = selectionHook.selected;
|
|
7955
8182
|
const listProps = {
|
|
@@ -7976,14 +8203,14 @@ var useTree = ({
|
|
|
7976
8203
|
};
|
|
7977
8204
|
|
|
7978
8205
|
// src/tree/Tree.tsx
|
|
7979
|
-
var
|
|
7980
|
-
var
|
|
7981
|
-
var
|
|
8206
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
8207
|
+
var import_react63 = require("react");
|
|
8208
|
+
var classBase18 = "vuuTree";
|
|
7982
8209
|
var isExpanded = (node) => node.expanded === true;
|
|
7983
8210
|
var TreeNode = ({ children, idx, ...props }) => {
|
|
7984
|
-
return /* @__PURE__ */ (0,
|
|
8211
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("li", { ...props, children });
|
|
7985
8212
|
};
|
|
7986
|
-
var Tree = (0,
|
|
8213
|
+
var Tree = (0, import_react62.forwardRef)(function Tree2({
|
|
7987
8214
|
allowDragDrop,
|
|
7988
8215
|
className,
|
|
7989
8216
|
defaultSelected,
|
|
@@ -7997,11 +8224,11 @@ var Tree = (0, import_react58.forwardRef)(function Tree2({
|
|
|
7997
8224
|
source,
|
|
7998
8225
|
...htmlAttributes
|
|
7999
8226
|
}, forwardedRef) {
|
|
8000
|
-
var
|
|
8001
|
-
const id = (0,
|
|
8002
|
-
const rootRef = (0,
|
|
8227
|
+
var _a2;
|
|
8228
|
+
const id = (0, import_core25.useIdMemo)(idProp);
|
|
8229
|
+
const rootRef = (0, import_react62.useRef)(null);
|
|
8003
8230
|
const [, sourceWithIds, sourceItemById] = useItemsWithIds(source, id, {
|
|
8004
|
-
revealSelected: revealSelected ? (
|
|
8231
|
+
revealSelected: revealSelected ? (_a2 = selectedProp != null ? selectedProp : defaultSelected) != null ? _a2 : false : void 0
|
|
8005
8232
|
});
|
|
8006
8233
|
const handleSelectionChange = (evt, selected2) => {
|
|
8007
8234
|
if (onSelectionChange) {
|
|
@@ -8042,14 +8269,14 @@ var Tree = (0, import_react58.forwardRef)(function Tree2({
|
|
|
8042
8269
|
const allowGroupSelect = groupSelectionEnabled2(groupSelection);
|
|
8043
8270
|
function addLeafNode(list, item, idx) {
|
|
8044
8271
|
list.push(
|
|
8045
|
-
/* @__PURE__ */ (0,
|
|
8272
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
8046
8273
|
TreeNode,
|
|
8047
8274
|
{
|
|
8048
8275
|
...propsCommonToAllListItems,
|
|
8049
8276
|
...getListItemProps(item, idx, highlightedIdx, selected, focusVisible),
|
|
8050
8277
|
children: [
|
|
8051
|
-
item.icon ? /* @__PURE__ */ (0,
|
|
8052
|
-
/* @__PURE__ */ (0,
|
|
8278
|
+
item.icon ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: `${classBase18}Node-icon`, "data-icon": item.icon }) : null,
|
|
8279
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children: item.label })
|
|
8053
8280
|
]
|
|
8054
8281
|
}
|
|
8055
8282
|
)
|
|
@@ -8060,16 +8287,16 @@ var Tree = (0, import_react58.forwardRef)(function Tree2({
|
|
|
8060
8287
|
const { value: i } = idx;
|
|
8061
8288
|
idx.value += 1;
|
|
8062
8289
|
list.push(
|
|
8063
|
-
/* @__PURE__ */ (0,
|
|
8290
|
+
/* @__PURE__ */ (0, import_react63.createElement)(
|
|
8064
8291
|
TreeNode,
|
|
8065
8292
|
{
|
|
8066
8293
|
...listItemHandlers,
|
|
8067
8294
|
"aria-expanded": child.expanded,
|
|
8068
8295
|
"aria-level": child.level,
|
|
8069
8296
|
"aria-selected": selected.includes(id2) || void 0,
|
|
8070
|
-
className: (0, import_classnames16.default)(`${
|
|
8297
|
+
className: (0, import_classnames16.default)(`${classBase18}Node`, {
|
|
8071
8298
|
focusVisible: focusVisible === i,
|
|
8072
|
-
[`${
|
|
8299
|
+
[`${classBase18}Node-toggle`]: !allowGroupSelect
|
|
8073
8300
|
}),
|
|
8074
8301
|
"data-idx": i,
|
|
8075
8302
|
"data-highlighted": i === highlightedIdx || void 0,
|
|
@@ -8077,20 +8304,20 @@ var Tree = (0, import_react58.forwardRef)(function Tree2({
|
|
|
8077
8304
|
id: id2,
|
|
8078
8305
|
key: `header-${i}`
|
|
8079
8306
|
},
|
|
8080
|
-
allowGroupSelect ? /* @__PURE__ */ (0,
|
|
8081
|
-
/* @__PURE__ */ (0,
|
|
8307
|
+
allowGroupSelect ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: `${classBase18}Node-label`, children: [
|
|
8308
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: `${classBase18}Node-toggle` }),
|
|
8082
8309
|
title
|
|
8083
|
-
] }) : /* @__PURE__ */ (0,
|
|
8084
|
-
child.icon ? /* @__PURE__ */ (0,
|
|
8310
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: `${classBase18}Node-label`, children: [
|
|
8311
|
+
child.icon ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
8085
8312
|
"span",
|
|
8086
8313
|
{
|
|
8087
|
-
className: `${
|
|
8314
|
+
className: `${classBase18}Node-icon`,
|
|
8088
8315
|
"data-icon": child.icon
|
|
8089
8316
|
}
|
|
8090
8317
|
) : null,
|
|
8091
|
-
/* @__PURE__ */ (0,
|
|
8318
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children: title })
|
|
8092
8319
|
] }),
|
|
8093
|
-
/* @__PURE__ */ (0,
|
|
8320
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("ul", { role: "group", children: isExpanded(child) ? renderSourceContent(child.childNodes, idx) : "" })
|
|
8094
8321
|
)
|
|
8095
8322
|
);
|
|
8096
8323
|
}
|
|
@@ -8107,14 +8334,14 @@ var Tree = (0, import_react58.forwardRef)(function Tree2({
|
|
|
8107
8334
|
return listItems;
|
|
8108
8335
|
}
|
|
8109
8336
|
}
|
|
8110
|
-
return /* @__PURE__ */ (0,
|
|
8337
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
8111
8338
|
"ul",
|
|
8112
8339
|
{
|
|
8113
8340
|
...htmlAttributes,
|
|
8114
8341
|
...listProps,
|
|
8115
|
-
className: (0, import_classnames16.default)(
|
|
8342
|
+
className: (0, import_classnames16.default)(classBase18, className),
|
|
8116
8343
|
id: `Tree-${id}`,
|
|
8117
|
-
ref: (0,
|
|
8344
|
+
ref: (0, import_core25.useForkRef)(rootRef, forwardedRef),
|
|
8118
8345
|
role: "tree",
|
|
8119
8346
|
tabIndex: 0,
|
|
8120
8347
|
children: renderSourceContent(visibleData)
|
|
@@ -8136,39 +8363,61 @@ Tree.displayName = "Tree";
|
|
|
8136
8363
|
var Tree_default = Tree;
|
|
8137
8364
|
|
|
8138
8365
|
// src/vuu-input/VuuInput.tsx
|
|
8139
|
-
var
|
|
8366
|
+
var import_vuu_utils14 = require("@vuu-ui/vuu-utils");
|
|
8367
|
+
var import_core26 = require("@salt-ds/core");
|
|
8140
8368
|
var import_classnames17 = __toESM(require("classnames"));
|
|
8141
|
-
var
|
|
8142
|
-
var
|
|
8143
|
-
var
|
|
8369
|
+
var import_react64 = require("react");
|
|
8370
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
8371
|
+
var classBase19 = "vuuInput";
|
|
8144
8372
|
var VuuInput = ({
|
|
8145
8373
|
className,
|
|
8146
8374
|
onCommit,
|
|
8147
8375
|
onKeyDown,
|
|
8376
|
+
type,
|
|
8148
8377
|
...props
|
|
8149
8378
|
}) => {
|
|
8150
|
-
const
|
|
8379
|
+
const commitValue = (0, import_react64.useCallback)(
|
|
8380
|
+
(evt, value) => {
|
|
8381
|
+
console.log(`commit value ${value}`);
|
|
8382
|
+
if (type === "number") {
|
|
8383
|
+
const numericValue = parseFloat(value);
|
|
8384
|
+
if ((0, import_vuu_utils14.isValidNumber)(numericValue)) {
|
|
8385
|
+
onCommit(evt, numericValue);
|
|
8386
|
+
} else {
|
|
8387
|
+
throw Error("Invalid value");
|
|
8388
|
+
}
|
|
8389
|
+
} else if (type === "boolean") {
|
|
8390
|
+
onCommit(evt, Boolean(value));
|
|
8391
|
+
} else {
|
|
8392
|
+
onCommit(evt, value);
|
|
8393
|
+
}
|
|
8394
|
+
},
|
|
8395
|
+
[onCommit, type]
|
|
8396
|
+
);
|
|
8397
|
+
const handleKeyDown = (0, import_react64.useCallback)(
|
|
8151
8398
|
(evt) => {
|
|
8152
8399
|
if (evt.key === "Enter") {
|
|
8153
8400
|
evt.preventDefault();
|
|
8154
8401
|
evt.stopPropagation();
|
|
8155
|
-
|
|
8402
|
+
const { value } = evt.target;
|
|
8403
|
+
commitValue(evt, value);
|
|
8156
8404
|
}
|
|
8157
8405
|
onKeyDown == null ? void 0 : onKeyDown(evt);
|
|
8158
8406
|
},
|
|
8159
|
-
[
|
|
8407
|
+
[commitValue, onKeyDown]
|
|
8160
8408
|
);
|
|
8161
|
-
const handleBlur = (0,
|
|
8409
|
+
const handleBlur = (0, import_react64.useCallback)(
|
|
8162
8410
|
(evt) => {
|
|
8163
|
-
|
|
8411
|
+
const { value } = evt.target;
|
|
8412
|
+
commitValue(evt, value);
|
|
8164
8413
|
},
|
|
8165
|
-
[
|
|
8414
|
+
[commitValue]
|
|
8166
8415
|
);
|
|
8167
|
-
return /* @__PURE__ */ (0,
|
|
8168
|
-
|
|
8416
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
8417
|
+
import_core26.Input,
|
|
8169
8418
|
{
|
|
8170
8419
|
...props,
|
|
8171
|
-
className: (0, import_classnames17.default)(
|
|
8420
|
+
className: (0, import_classnames17.default)(classBase19, className),
|
|
8172
8421
|
onBlur: handleBlur,
|
|
8173
8422
|
onKeyDown: handleKeyDown
|
|
8174
8423
|
}
|