aidos-ui 4.0.5 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -3
- package/dist/index.js +267 -201
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -564,7 +564,9 @@ var sizes2 = {
|
|
|
564
564
|
small: 6,
|
|
565
565
|
medium: 12,
|
|
566
566
|
large: 18,
|
|
567
|
-
xlarge: 24
|
|
567
|
+
xlarge: 24,
|
|
568
|
+
xxlarge: 32,
|
|
569
|
+
xxxlarge: 40
|
|
568
570
|
};
|
|
569
571
|
function Badge({
|
|
570
572
|
size = "medium",
|
|
@@ -771,12 +773,13 @@ var BaseButton = React34.forwardRef(
|
|
|
771
773
|
disabled,
|
|
772
774
|
animateInteraction = true,
|
|
773
775
|
padding,
|
|
776
|
+
type = "button",
|
|
774
777
|
...otherProps
|
|
775
778
|
}, ref) => {
|
|
776
779
|
return /* @__PURE__ */ jsx(
|
|
777
780
|
"button",
|
|
778
781
|
{
|
|
779
|
-
type
|
|
782
|
+
type,
|
|
780
783
|
...otherProps,
|
|
781
784
|
"aria-disabled": disabled ? true : void 0,
|
|
782
785
|
ref,
|
|
@@ -931,12 +934,12 @@ var BaseLink = React34.forwardRef(
|
|
|
931
934
|
href,
|
|
932
935
|
role,
|
|
933
936
|
ref,
|
|
934
|
-
onClick:
|
|
937
|
+
onClick: (event) => {
|
|
935
938
|
if (disabled) {
|
|
936
939
|
return;
|
|
937
940
|
}
|
|
938
|
-
onClick(event);
|
|
939
|
-
}
|
|
941
|
+
onClick && onClick(event);
|
|
942
|
+
},
|
|
940
943
|
className: toClassnames([
|
|
941
944
|
...getInteractableJSS({
|
|
942
945
|
color,
|
|
@@ -1133,15 +1136,20 @@ var focusElement = (focusables, index) => {
|
|
|
1133
1136
|
};
|
|
1134
1137
|
function useRefEffect(callback) {
|
|
1135
1138
|
const unsubscribeRef = useRef(null);
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1139
|
+
return useCallback(
|
|
1140
|
+
(root) => {
|
|
1141
|
+
if (root === null) {
|
|
1142
|
+
const unsubscribe = unsubscribeRef.current;
|
|
1143
|
+
if (unsubscribe) {
|
|
1144
|
+
unsubscribe();
|
|
1145
|
+
}
|
|
1146
|
+
unsubscribeRef.current = null;
|
|
1147
|
+
} else {
|
|
1148
|
+
unsubscribeRef.current = callback(root);
|
|
1149
|
+
}
|
|
1150
|
+
},
|
|
1151
|
+
[callback]
|
|
1152
|
+
);
|
|
1145
1153
|
}
|
|
1146
1154
|
|
|
1147
1155
|
// src/useNavigation.tsx
|
|
@@ -1150,72 +1158,78 @@ function useNavigation({
|
|
|
1150
1158
|
rowLength = 1,
|
|
1151
1159
|
enabled = true
|
|
1152
1160
|
} = {}) {
|
|
1153
|
-
return useRefEffect(
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
const elements = queryFocusables(root);
|
|
1159
|
-
if (elements.length === 0) {
|
|
1160
|
-
return;
|
|
1161
|
-
}
|
|
1162
|
-
if (elements.length !== 0 && autofocus) {
|
|
1163
|
-
focusElement(elements, index);
|
|
1164
|
-
} else {
|
|
1165
|
-
normalizeElements(elements, index);
|
|
1166
|
-
}
|
|
1167
|
-
const onKeyDown = (e) => {
|
|
1168
|
-
const elements2 = queryFocusables(root);
|
|
1169
|
-
if (elements2.length === 0) {
|
|
1170
|
-
return;
|
|
1171
|
-
}
|
|
1172
|
-
let newIndex = -1;
|
|
1173
|
-
if (e.code === "ArrowUp") {
|
|
1174
|
-
if (index - rowLength < 0) {
|
|
1175
|
-
newIndex = elements2.length - elements2.length % rowLength + index;
|
|
1176
|
-
} else {
|
|
1177
|
-
newIndex = index - rowLength;
|
|
1178
|
-
}
|
|
1179
|
-
} else if (e.code === "ArrowLeft") {
|
|
1180
|
-
if (index <= 0) {
|
|
1181
|
-
newIndex = elements2.length - 1;
|
|
1182
|
-
} else {
|
|
1183
|
-
newIndex = index - 1;
|
|
1161
|
+
return useRefEffect(
|
|
1162
|
+
useCallback(
|
|
1163
|
+
(root) => {
|
|
1164
|
+
if (!enabled) {
|
|
1165
|
+
return;
|
|
1184
1166
|
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
newIndex = index + 1;
|
|
1167
|
+
let index = 0;
|
|
1168
|
+
const elements = queryFocusables(root);
|
|
1169
|
+
if (elements.length === 0) {
|
|
1170
|
+
return;
|
|
1190
1171
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
newIndex = (index + rowLength) % rowLength;
|
|
1172
|
+
if (elements.length !== 0 && autofocus) {
|
|
1173
|
+
focusElement(elements, index);
|
|
1194
1174
|
} else {
|
|
1195
|
-
|
|
1175
|
+
normalizeElements(elements, index);
|
|
1196
1176
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1177
|
+
const onKeyDown = (e) => {
|
|
1178
|
+
const elements2 = queryFocusables(root);
|
|
1179
|
+
if (elements2.length === 0) {
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
let newIndex = -1;
|
|
1183
|
+
if (e.code === "ArrowUp") {
|
|
1184
|
+
if (index - rowLength < 0) {
|
|
1185
|
+
newIndex = elements2.length - elements2.length % rowLength + index;
|
|
1186
|
+
} else {
|
|
1187
|
+
newIndex = index - rowLength;
|
|
1188
|
+
}
|
|
1189
|
+
} else if (e.code === "ArrowLeft") {
|
|
1190
|
+
if (index <= 0) {
|
|
1191
|
+
newIndex = elements2.length - 1;
|
|
1192
|
+
} else {
|
|
1193
|
+
newIndex = index - 1;
|
|
1194
|
+
}
|
|
1195
|
+
} else if (e.code === "ArrowRight") {
|
|
1196
|
+
if (index >= elements2.length - 1) {
|
|
1197
|
+
newIndex = 0;
|
|
1198
|
+
} else {
|
|
1199
|
+
newIndex = index + 1;
|
|
1200
|
+
}
|
|
1201
|
+
} else if (e.code === "ArrowDown") {
|
|
1202
|
+
if (index + rowLength > elements2.length - 1) {
|
|
1203
|
+
newIndex = (index + rowLength) % rowLength;
|
|
1204
|
+
} else {
|
|
1205
|
+
newIndex = index + rowLength;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
if (newIndex !== -1 && index !== newIndex) {
|
|
1209
|
+
index = newIndex;
|
|
1210
|
+
focusElement(elements2, index);
|
|
1211
|
+
e.preventDefault();
|
|
1212
|
+
e.stopPropagation();
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
root.addEventListener("keydown", onKeyDown);
|
|
1216
|
+
const observer = new MutationObserver((mutationList) => {
|
|
1217
|
+
if (mutationList.filter((m) => m.type === "childList").length > 0) {
|
|
1218
|
+
const elements2 = queryFocusables(root);
|
|
1219
|
+
if (elements2.length > 0) {
|
|
1220
|
+
normalizeElements(elements2, index);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
observer.observe(root, { childList: true });
|
|
1225
|
+
return () => {
|
|
1226
|
+
root.removeEventListener("keydown", onKeyDown);
|
|
1227
|
+
observer.disconnect();
|
|
1228
|
+
};
|
|
1229
|
+
},
|
|
1230
|
+
[autofocus, enabled, rowLength]
|
|
1231
|
+
)
|
|
1232
|
+
);
|
|
1219
1233
|
}
|
|
1220
1234
|
var ListContext = React34.createContext({ bare: false, carded: true });
|
|
1221
1235
|
function List({
|
|
@@ -1488,7 +1502,7 @@ var Button = React34.forwardRef(
|
|
|
1488
1502
|
);
|
|
1489
1503
|
}
|
|
1490
1504
|
);
|
|
1491
|
-
var dateFormatter = Intl.DateTimeFormat("en-
|
|
1505
|
+
var dateFormatter = Intl.DateTimeFormat("en-GB", {
|
|
1492
1506
|
weekday: "short"
|
|
1493
1507
|
});
|
|
1494
1508
|
var MON = dateFormatter.format(new Date(2e3, 1, 7));
|
|
@@ -1635,7 +1649,9 @@ var sizes3 = {
|
|
|
1635
1649
|
small: 24,
|
|
1636
1650
|
medium: 32,
|
|
1637
1651
|
large: 40,
|
|
1638
|
-
xlarge: 48
|
|
1652
|
+
xlarge: 48,
|
|
1653
|
+
xxlarge: 56,
|
|
1654
|
+
xxxlarge: 64
|
|
1639
1655
|
};
|
|
1640
1656
|
function StaticCheckbox({
|
|
1641
1657
|
checked,
|
|
@@ -1859,6 +1875,32 @@ function DarkModeToggle() {
|
|
|
1859
1875
|
}
|
|
1860
1876
|
);
|
|
1861
1877
|
}
|
|
1878
|
+
|
|
1879
|
+
// src/dateInputValue.ts
|
|
1880
|
+
var pad = (value) => value.toString().padStart(2, "0");
|
|
1881
|
+
function formatDateInputValue(date) {
|
|
1882
|
+
return `${date.getFullYear().toString().padStart(4, "0")}-${pad(
|
|
1883
|
+
date.getMonth() + 1
|
|
1884
|
+
)}-${pad(date.getDate())}`;
|
|
1885
|
+
}
|
|
1886
|
+
function parseDateInputValue(value) {
|
|
1887
|
+
const [year, month, day] = value.split("-").map(Number);
|
|
1888
|
+
return new Date(year, month - 1, day);
|
|
1889
|
+
}
|
|
1890
|
+
function formatDatetimeInputValue(date) {
|
|
1891
|
+
return `${formatDateInputValue(date)}T${pad(date.getHours())}:${pad(
|
|
1892
|
+
date.getMinutes()
|
|
1893
|
+
)}`;
|
|
1894
|
+
}
|
|
1895
|
+
function parseDatetimeInputValue(value) {
|
|
1896
|
+
const [date, time] = value.split("T");
|
|
1897
|
+
const [year, month, day] = date.split("-").map(Number);
|
|
1898
|
+
const [hour, minute] = time.split(":").map(Number);
|
|
1899
|
+
return new Date(year, month - 1, day, hour, minute);
|
|
1900
|
+
}
|
|
1901
|
+
function formatTimeInputValue(date) {
|
|
1902
|
+
return `${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
1903
|
+
}
|
|
1862
1904
|
var DateInput = React34.forwardRef(
|
|
1863
1905
|
({ date, onDateChange, jss, icon, addOn, ...inputProps }, ref) => {
|
|
1864
1906
|
return /* @__PURE__ */ jsxs(
|
|
@@ -1875,8 +1917,12 @@ var DateInput = React34.forwardRef(
|
|
|
1875
1917
|
...inputProps,
|
|
1876
1918
|
type: "date",
|
|
1877
1919
|
ref,
|
|
1878
|
-
value: date
|
|
1879
|
-
onChange: (e) =>
|
|
1920
|
+
value: formatDateInputValue(date),
|
|
1921
|
+
onChange: (e) => {
|
|
1922
|
+
if (e.target.value) {
|
|
1923
|
+
onDateChange(parseDateInputValue(e.target.value));
|
|
1924
|
+
}
|
|
1925
|
+
},
|
|
1880
1926
|
jss: [
|
|
1881
1927
|
{
|
|
1882
1928
|
flexGrow: 1,
|
|
@@ -1920,12 +1966,15 @@ function DatePicker({
|
|
|
1920
1966
|
date,
|
|
1921
1967
|
onDateChange
|
|
1922
1968
|
}) {
|
|
1923
|
-
const
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1969
|
+
const [{ min, max }] = useState(() => {
|
|
1970
|
+
const year = date.getFullYear();
|
|
1971
|
+
const month = date.getMonth();
|
|
1972
|
+
const day = date.getDate();
|
|
1973
|
+
return {
|
|
1974
|
+
min: formatDateInputValue(new Date(year - 1, month, day)),
|
|
1975
|
+
max: formatDateInputValue(new Date(year + 1, month, day))
|
|
1976
|
+
};
|
|
1977
|
+
});
|
|
1929
1978
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1930
1979
|
/* @__PURE__ */ jsx("label", { htmlFor: id, children: /* @__PURE__ */ jsx(Text, { size: "small", color, children: label }) }),
|
|
1931
1980
|
/* @__PURE__ */ jsx(
|
|
@@ -1936,15 +1985,10 @@ function DatePicker({
|
|
|
1936
1985
|
className: toClassnames(styles6.dateInput),
|
|
1937
1986
|
type: "date",
|
|
1938
1987
|
id,
|
|
1939
|
-
value: date
|
|
1988
|
+
value: formatDateInputValue(date),
|
|
1940
1989
|
onChange: (event) => {
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
parsedDate = new Date(event.target.value);
|
|
1944
|
-
} finally {
|
|
1945
|
-
if (parsedDate != null) {
|
|
1946
|
-
onDateChange(parsedDate);
|
|
1947
|
-
}
|
|
1990
|
+
if (event.target.value) {
|
|
1991
|
+
onDateChange(parseDateInputValue(event.target.value));
|
|
1948
1992
|
}
|
|
1949
1993
|
}
|
|
1950
1994
|
}
|
|
@@ -1982,8 +2026,12 @@ var DatetimeInput = React34.forwardRef(
|
|
|
1982
2026
|
...inputProps,
|
|
1983
2027
|
type: "datetime-local",
|
|
1984
2028
|
ref,
|
|
1985
|
-
value: date
|
|
1986
|
-
onChange: (e) =>
|
|
2029
|
+
value: formatDatetimeInputValue(date),
|
|
2030
|
+
onChange: (e) => {
|
|
2031
|
+
if (e.target.value) {
|
|
2032
|
+
onDateChange(parseDatetimeInputValue(e.target.value));
|
|
2033
|
+
}
|
|
2034
|
+
},
|
|
1987
2035
|
jss: [styles7.input, jss]
|
|
1988
2036
|
}
|
|
1989
2037
|
),
|
|
@@ -2147,15 +2195,17 @@ function Dropdown({
|
|
|
2147
2195
|
const triggerRef = useRef(null);
|
|
2148
2196
|
const [expanded, setExpanded] = useState(false);
|
|
2149
2197
|
const dropdownRef = useNavigation({ autofocus: true });
|
|
2150
|
-
const rootRef = useRefEffect(
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2198
|
+
const rootRef = useRefEffect(
|
|
2199
|
+
useCallback((root) => {
|
|
2200
|
+
const onKeyDown = (e) => {
|
|
2201
|
+
if (e.code === "Escape") {
|
|
2202
|
+
setExpanded(false);
|
|
2203
|
+
}
|
|
2204
|
+
};
|
|
2205
|
+
root.addEventListener("keydown", onKeyDown);
|
|
2206
|
+
return () => root.removeEventListener("keydown", onKeyDown);
|
|
2207
|
+
}, [])
|
|
2208
|
+
);
|
|
2159
2209
|
useEffect(() => {
|
|
2160
2210
|
if (!expanded) {
|
|
2161
2211
|
triggerRef.current && triggerRef.current.focus();
|
|
@@ -2263,7 +2313,9 @@ var sizes5 = {
|
|
|
2263
2313
|
small: 24,
|
|
2264
2314
|
medium: 32,
|
|
2265
2315
|
large: 40,
|
|
2266
|
-
xlarge: 48
|
|
2316
|
+
xlarge: 48,
|
|
2317
|
+
xxlarge: 56,
|
|
2318
|
+
xxxlarge: 64
|
|
2267
2319
|
};
|
|
2268
2320
|
var IconLink = React34.forwardRef(
|
|
2269
2321
|
({ icon, size, color, bare, disabled, jss, ...otherProps }, ref) => {
|
|
@@ -2667,47 +2719,53 @@ var styles11 = {
|
|
|
2667
2719
|
};
|
|
2668
2720
|
function Popover({ children, close }) {
|
|
2669
2721
|
const activeElementRef = useRef(null);
|
|
2670
|
-
const focusTrapRoot = useRefEffect(
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2722
|
+
const focusTrapRoot = useRefEffect(
|
|
2723
|
+
useCallback(
|
|
2724
|
+
(root) => {
|
|
2725
|
+
activeElementRef.current = document.activeElement;
|
|
2726
|
+
const [element] = queryFocusables(root);
|
|
2727
|
+
element ? element.focus() : root.focus();
|
|
2728
|
+
const keydown = (e) => {
|
|
2729
|
+
if (e.key === "Escape") {
|
|
2730
|
+
close();
|
|
2731
|
+
} else if (e.key === "Tab") {
|
|
2732
|
+
const focusables = queryFocusables(root).filter(
|
|
2733
|
+
(element2) => element2.tabIndex !== -1
|
|
2734
|
+
);
|
|
2735
|
+
if (focusables.length === 0) {
|
|
2736
|
+
e.stopPropagation();
|
|
2737
|
+
e.preventDefault();
|
|
2738
|
+
}
|
|
2739
|
+
const focusedIndex = focusables.findIndex(
|
|
2740
|
+
(x) => x === document.activeElement
|
|
2741
|
+
);
|
|
2742
|
+
if (focusables.length === 0) {
|
|
2743
|
+
e.stopPropagation();
|
|
2744
|
+
e.preventDefault();
|
|
2745
|
+
} else if (focusedIndex === focusables.length - 1) {
|
|
2746
|
+
focusables[0].focus();
|
|
2747
|
+
e.stopPropagation();
|
|
2748
|
+
e.preventDefault();
|
|
2749
|
+
} else ;
|
|
2750
|
+
}
|
|
2751
|
+
};
|
|
2752
|
+
const click = () => {
|
|
2753
|
+
close();
|
|
2754
|
+
};
|
|
2755
|
+
const timeout = window.setTimeout(() => {
|
|
2756
|
+
window.addEventListener("keydown", keydown);
|
|
2757
|
+
window.addEventListener("click", click);
|
|
2758
|
+
}, 0);
|
|
2759
|
+
return () => {
|
|
2760
|
+
window.clearTimeout(timeout);
|
|
2761
|
+
activeElementRef.current && activeElementRef.current.focus();
|
|
2762
|
+
window.removeEventListener("keydown", keydown);
|
|
2763
|
+
window.removeEventListener("click", click);
|
|
2764
|
+
};
|
|
2765
|
+
},
|
|
2766
|
+
[close]
|
|
2767
|
+
)
|
|
2768
|
+
);
|
|
2711
2769
|
return /* @__PURE__ */ jsx(BaseView, { ref: focusTrapRoot, children });
|
|
2712
2770
|
}
|
|
2713
2771
|
function PopoverTrigger({
|
|
@@ -2795,7 +2853,9 @@ var sizes6 = {
|
|
|
2795
2853
|
small: 8,
|
|
2796
2854
|
medium: 12,
|
|
2797
2855
|
large: 16,
|
|
2798
|
-
xlarge: 20
|
|
2856
|
+
xlarge: 20,
|
|
2857
|
+
xxlarge: 28,
|
|
2858
|
+
xxxlarge: 36
|
|
2799
2859
|
};
|
|
2800
2860
|
function ProgressBar({
|
|
2801
2861
|
color,
|
|
@@ -3493,7 +3553,6 @@ var TextArea = React34.forwardRef(
|
|
|
3493
3553
|
jss,
|
|
3494
3554
|
onValueChange,
|
|
3495
3555
|
value,
|
|
3496
|
-
onChange,
|
|
3497
3556
|
padding = "medium",
|
|
3498
3557
|
...otherProps
|
|
3499
3558
|
}, ref) => {
|
|
@@ -3647,9 +3706,10 @@ function TextInputWithState({
|
|
|
3647
3706
|
);
|
|
3648
3707
|
return /* @__PURE__ */ jsx(TextInput, { ...otherProps, value, onValueChange });
|
|
3649
3708
|
}
|
|
3650
|
-
var timeFormatter = Intl.DateTimeFormat("en-
|
|
3709
|
+
var timeFormatter = Intl.DateTimeFormat("en-GB", {
|
|
3651
3710
|
hour: "2-digit",
|
|
3652
|
-
minute: "2-digit"
|
|
3711
|
+
minute: "2-digit",
|
|
3712
|
+
hourCycle: "h23"
|
|
3653
3713
|
});
|
|
3654
3714
|
function TimeInputInternal({
|
|
3655
3715
|
time: date,
|
|
@@ -3695,7 +3755,7 @@ function TimeInputInternal({
|
|
|
3695
3755
|
...inputProps,
|
|
3696
3756
|
type: "time",
|
|
3697
3757
|
ref,
|
|
3698
|
-
value:
|
|
3758
|
+
value: formatTimeInputValue(date),
|
|
3699
3759
|
onChange: (e) => {
|
|
3700
3760
|
const value = e.target.value;
|
|
3701
3761
|
const [hour, minute] = value.split(":");
|
|
@@ -3754,34 +3814,37 @@ var styles13 = {
|
|
|
3754
3814
|
function Tooltip({ content, jss, tag, children }) {
|
|
3755
3815
|
const [tooltip, setTooltip] = useState(null);
|
|
3756
3816
|
const dialogRef = useRef(null);
|
|
3757
|
-
const focusTrapRoot = useRefEffect(
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3817
|
+
const focusTrapRoot = useRefEffect(
|
|
3818
|
+
useCallback((root) => {
|
|
3819
|
+
dialogRef.current = root;
|
|
3820
|
+
const keydown = (e) => {
|
|
3821
|
+
if (e.key === "Escape") {
|
|
3822
|
+
dialogRef.current?.close();
|
|
3823
|
+
} else if (e.key === "Tab") {
|
|
3824
|
+
dialogRef.current?.close();
|
|
3825
|
+
}
|
|
3826
|
+
};
|
|
3827
|
+
const click = () => {
|
|
3763
3828
|
dialogRef.current?.close();
|
|
3764
|
-
}
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
window.removeEventListener("click", click);
|
|
3777
|
-
};
|
|
3778
|
-
});
|
|
3829
|
+
};
|
|
3830
|
+
window.addEventListener("keydown", keydown);
|
|
3831
|
+
window.addEventListener("click", click);
|
|
3832
|
+
const activeElement = document.activeElement;
|
|
3833
|
+
root.show();
|
|
3834
|
+
activeElement.focus();
|
|
3835
|
+
return () => {
|
|
3836
|
+
window.removeEventListener("keydown", keydown);
|
|
3837
|
+
window.removeEventListener("click", click);
|
|
3838
|
+
};
|
|
3839
|
+
}, [])
|
|
3840
|
+
);
|
|
3779
3841
|
const toggle = () => {
|
|
3780
3842
|
if (tooltip == null) {
|
|
3781
3843
|
setTooltip(
|
|
3782
3844
|
/* @__PURE__ */ jsx(
|
|
3783
3845
|
"dialog",
|
|
3784
3846
|
{
|
|
3847
|
+
role: "tooltip",
|
|
3785
3848
|
ref: (ref) => {
|
|
3786
3849
|
dialogRef.current = ref;
|
|
3787
3850
|
focusTrapRoot(ref);
|
|
@@ -3825,35 +3888,38 @@ function Tooltip({ content, jss, tag, children }) {
|
|
|
3825
3888
|
}
|
|
3826
3889
|
);
|
|
3827
3890
|
}
|
|
3828
|
-
|
|
3829
|
-
// src/useKeyboard.tsx
|
|
3830
3891
|
function useKeyboard(shortcuts) {
|
|
3831
|
-
return useRefEffect(
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3892
|
+
return useRefEffect(
|
|
3893
|
+
useCallback(
|
|
3894
|
+
(root) => {
|
|
3895
|
+
const onKeyDown = (e) => {
|
|
3896
|
+
for (const {
|
|
3897
|
+
metaKey,
|
|
3898
|
+
key,
|
|
3899
|
+
action,
|
|
3900
|
+
ctrlKey,
|
|
3901
|
+
onlyWhenFocused
|
|
3902
|
+
} of shortcuts) {
|
|
3903
|
+
if (metaKey && e.metaKey !== true) {
|
|
3904
|
+
continue;
|
|
3905
|
+
} else if (ctrlKey && e.ctrlKey !== true) {
|
|
3906
|
+
continue;
|
|
3907
|
+
} else if (onlyWhenFocused && document.activeElement !== root) {
|
|
3908
|
+
continue;
|
|
3909
|
+
}
|
|
3910
|
+
if (e.key.toLowerCase() === key.toLowerCase()) {
|
|
3911
|
+
action(root);
|
|
3912
|
+
}
|
|
3913
|
+
}
|
|
3914
|
+
};
|
|
3915
|
+
window.addEventListener("keydown", onKeyDown);
|
|
3916
|
+
return () => {
|
|
3917
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
3918
|
+
};
|
|
3919
|
+
},
|
|
3920
|
+
[shortcuts]
|
|
3921
|
+
)
|
|
3922
|
+
);
|
|
3857
3923
|
}
|
|
3858
3924
|
function usePromise(promiseFactory, inputs, initialValue) {
|
|
3859
3925
|
const [value, setValue] = useState(initialValue);
|