@vuu-ui/vuu-table-extras 4.2.6 → 4.2.8
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.2.
|
|
2
|
+
"version": "4.2.8",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"lezer-generate:column": "lezer-generator --output ./src/column-expression-input/column-language-parser/generated/column-parser.js ./src/column-expression-input/column-language-parser/grammar/column.grammar"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@vuu-ui/vuu-filter-types": "4.2.
|
|
14
|
-
"@vuu-ui/vuu-protocol-types": "4.2.
|
|
13
|
+
"@vuu-ui/vuu-filter-types": "4.2.8",
|
|
14
|
+
"@vuu-ui/vuu-protocol-types": "4.2.8"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@vuu-ui/vuu-codemirror": "4.2.
|
|
18
|
-
"@vuu-ui/vuu-data-editing": "4.2.
|
|
19
|
-
"@vuu-ui/vuu-data-react": "4.2.
|
|
20
|
-
"@vuu-ui/vuu-data-types": "4.2.
|
|
21
|
-
"@vuu-ui/vuu-table-types": "4.2.
|
|
22
|
-
"@vuu-ui/vuu-popups": "4.2.
|
|
23
|
-
"@vuu-ui/vuu-table": "4.2.
|
|
24
|
-
"@vuu-ui/vuu-utils": "4.2.
|
|
25
|
-
"@vuu-ui/vuu-ui-controls": "4.2.
|
|
17
|
+
"@vuu-ui/vuu-codemirror": "4.2.8",
|
|
18
|
+
"@vuu-ui/vuu-data-editing": "4.2.8",
|
|
19
|
+
"@vuu-ui/vuu-data-react": "4.2.8",
|
|
20
|
+
"@vuu-ui/vuu-data-types": "4.2.8",
|
|
21
|
+
"@vuu-ui/vuu-table-types": "4.2.8",
|
|
22
|
+
"@vuu-ui/vuu-popups": "4.2.8",
|
|
23
|
+
"@vuu-ui/vuu-table": "4.2.8",
|
|
24
|
+
"@vuu-ui/vuu-utils": "4.2.8",
|
|
25
|
+
"@vuu-ui/vuu-ui-controls": "4.2.8",
|
|
26
26
|
"@lezer/lr": "1.4.2",
|
|
27
27
|
"@salt-ds/core": "1.74.0",
|
|
28
28
|
"@salt-ds/styles": "0.4.2",
|
|
@@ -20,14 +20,18 @@ const css = `
|
|
|
20
20
|
--saltButton-borderWidth: 2px;
|
|
21
21
|
padding-left: 7px;
|
|
22
22
|
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
.vuuTableCell-editable:focus-within, .vuuTableCell:focus {
|
|
27
|
+
& .vuuTableDropdownCell.saltDropdown {
|
|
28
|
+
outline: solid var(--salt-editable-borderColor-active) 2px;
|
|
29
|
+
outline-offset: -1px;
|
|
30
|
+
border-color: #0000;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
& .vuuTableDropdownCell
|
|
30
|
-
|
|
33
|
+
& .vuuTableDropdownCell[aria-expanded="true"] {
|
|
34
|
+
outline-style: dashed;
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useLookupValues } from "@vuu-ui/vuu-data-react";
|
|
3
|
-
import { dataColumnAndKeyUnchanged, dispatchCustomEvent, getSelectedOption, isRpcSuccess, registerComponent } from "@vuu-ui/vuu-utils";
|
|
3
|
+
import { dataColumnAndKeyUnchanged, dispatchCustomEvent, getSelectedOption, isCharacterKey, isRpcSuccess, registerComponent } from "@vuu-ui/vuu-utils";
|
|
4
4
|
import { isEditRowReadOnly } from "@vuu-ui/vuu-data-editing";
|
|
5
5
|
import clsx from "clsx";
|
|
6
6
|
import { Dropdown, Option } from "@salt-ds/core";
|
|
7
7
|
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
8
8
|
import { useWindow } from "@salt-ds/window";
|
|
9
|
-
import { memo, useCallback, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
10
10
|
import DropdownCell_0 from "./DropdownCell.css";
|
|
11
11
|
const classBase = "vuuTableDropdownCell";
|
|
12
|
+
const optionToString = ({ label })=>label;
|
|
12
13
|
const DropdownCell_DropdownCell = /*#__PURE__*/ memo(function({ column, dataRow, editedDuringCurrentSession, onEdit }) {
|
|
13
14
|
const targetWindow = useWindow();
|
|
14
15
|
useComponentCssInjection({
|
|
@@ -22,6 +23,8 @@ const DropdownCell_DropdownCell = /*#__PURE__*/ memo(function({ column, dataRow,
|
|
|
22
23
|
const readOnly = isEditRowReadOnly(dataRow);
|
|
23
24
|
const { values } = useLookupValues(column, dataValue);
|
|
24
25
|
const valueRef = useRef(void 0);
|
|
26
|
+
const buttonRef = useRef(null);
|
|
27
|
+
const pendingKeysRef = useRef("");
|
|
25
28
|
useMemo(()=>{
|
|
26
29
|
valueRef.current = getSelectedOption(values, dataValue);
|
|
27
30
|
}, [
|
|
@@ -51,14 +54,42 @@ const DropdownCell_DropdownCell = /*#__PURE__*/ memo(function({ column, dataRow,
|
|
|
51
54
|
open
|
|
52
55
|
]);
|
|
53
56
|
const handleKeyDown = useCallback((e)=>{
|
|
54
|
-
if ("Enter"
|
|
57
|
+
if ("Enter" !== e.key || open) {
|
|
58
|
+
if (!open && !readOnly && isCharacterKey(e.key) && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
e.stopPropagation();
|
|
61
|
+
pendingKeysRef.current += e.key;
|
|
62
|
+
setOpen(true);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
55
65
|
e.preventDefault();
|
|
56
66
|
e.stopPropagation();
|
|
57
67
|
setOpen(true);
|
|
58
68
|
}
|
|
69
|
+
}, [
|
|
70
|
+
open,
|
|
71
|
+
readOnly
|
|
72
|
+
]);
|
|
73
|
+
useEffect(()=>{
|
|
74
|
+
const { current: button } = buttonRef;
|
|
75
|
+
const keys = pendingKeysRef.current;
|
|
76
|
+
if (open && button && keys) {
|
|
77
|
+
pendingKeysRef.current = "";
|
|
78
|
+
requestAnimationFrame(()=>{
|
|
79
|
+
for (const key of keys)button.dispatchEvent(new KeyboardEvent("keydown", {
|
|
80
|
+
bubbles: true,
|
|
81
|
+
cancelable: true,
|
|
82
|
+
key
|
|
83
|
+
}));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
59
86
|
}, [
|
|
60
87
|
open
|
|
61
88
|
]);
|
|
89
|
+
const handleFocus = useCallback((e)=>{
|
|
90
|
+
const source = e.relatedTarget;
|
|
91
|
+
if (source?.classList.contains("vuuTableCell") && source.contains(e.target)) setOpen(true);
|
|
92
|
+
}, []);
|
|
62
93
|
const { current: selectedOption } = valueRef;
|
|
63
94
|
return /*#__PURE__*/ jsx(Dropdown, {
|
|
64
95
|
className: clsx(classBase, {
|
|
@@ -66,15 +97,18 @@ const DropdownCell_DropdownCell = /*#__PURE__*/ memo(function({ column, dataRow,
|
|
|
66
97
|
}),
|
|
67
98
|
"data-icon": "triangle-down",
|
|
68
99
|
onClick: handleClick,
|
|
100
|
+
onFocus: handleFocus,
|
|
69
101
|
onKeyDownCapture: handleKeyDown,
|
|
70
102
|
onOpenChange: handleOpenChange,
|
|
71
103
|
onSelectionChange: handleSelectionChange,
|
|
72
104
|
open: open,
|
|
73
105
|
readOnly: readOnly,
|
|
106
|
+
ref: buttonRef,
|
|
74
107
|
selected: selectedOption ? [
|
|
75
108
|
selectedOption
|
|
76
109
|
] : [],
|
|
77
110
|
value: selectedOption?.label,
|
|
111
|
+
valueToString: optionToString,
|
|
78
112
|
children: values.map((listOption, i)=>/*#__PURE__*/ jsx(Option, {
|
|
79
113
|
value: listOption,
|
|
80
114
|
children: listOption.label
|