@alphakits/ui 2.5.4 → 2.5.7
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.
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsxs as E, jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import O from "@alphakits/icons/dist/CloseM";
|
|
3
3
|
import C from "classnames";
|
|
4
|
-
import { useState as L, useRef as w, useLayoutEffect as N, useEffect as
|
|
4
|
+
import { useState as L, useRef as w, useLayoutEffect as N, useEffect as S, useCallback as k } from "react";
|
|
5
5
|
import { Button as z } from "../../../button/component.js";
|
|
6
6
|
import { showConfirm as j } from "../../../confirm-popup/component.js";
|
|
7
|
-
import { useMatchMedia as
|
|
7
|
+
import { useMatchMedia as q } from "../../../mq/use-match-media.js";
|
|
8
8
|
import s from "./index.module.css.js";
|
|
9
|
-
const
|
|
9
|
+
const T = {
|
|
10
10
|
s: 488,
|
|
11
11
|
m: 888,
|
|
12
12
|
full: "96%"
|
|
13
|
-
},
|
|
13
|
+
}, A = 102, B = "(max-width: 823px)", D = (t) => t === "full" ? `calc(-96vw - ${A}px)` : -T[t] - A, K = [
|
|
14
14
|
'a[href]:not([tabindex="-1"])',
|
|
15
15
|
'area[href]:not([tabindex="-1"])',
|
|
16
16
|
'button:not([disabled]):not([tabindex="-1"])',
|
|
@@ -25,76 +25,84 @@ const R = {
|
|
|
25
25
|
'audio[controls]:not([tabindex="-1"])',
|
|
26
26
|
'video[controls]:not([tabindex="-1"])',
|
|
27
27
|
'details > summary:first-of-type:not([tabindex="-1"])'
|
|
28
|
-
].join(","), F = (
|
|
28
|
+
].join(","), F = (t) => t ? Array.from(t.querySelectorAll(K)).filter((r) => {
|
|
29
29
|
if (r.hidden || r.getAttribute("aria-hidden") === "true") return !1;
|
|
30
30
|
const a = window.getComputedStyle(r);
|
|
31
31
|
return a.visibility === "hidden" || a.display === "none" ? !1 : r.offsetWidth > 0 || r.offsetHeight > 0 || r.getClientRects().length > 0;
|
|
32
|
-
}) : [],
|
|
33
|
-
|
|
32
|
+
}) : [], P = (t) => {
|
|
33
|
+
if (t.hasAttribute("data-modal-no-autofocus") || t.hasAttribute("aria-haspopup") || t.hasAttribute("aria-autocomplete")) return !0;
|
|
34
|
+
const n = t.getAttribute("role");
|
|
35
|
+
return !!(n === "combobox" || n === "listbox" || t.querySelector('[role="combobox"],[aria-haspopup],[aria-autocomplete]'));
|
|
36
|
+
}, _ = (t) => {
|
|
37
|
+
if (!t) return null;
|
|
38
|
+
const n = t.querySelector("[data-modal-autofocus]");
|
|
39
|
+
return n || F(t).find((d) => !P(d)) || t;
|
|
40
|
+
}, J = ({ modal: t, t: n, index: r, dirtyModals: a, closeModal: d, currentModalId: u }) => {
|
|
41
|
+
const R = D(t.props.size), [m] = q(B), [p, h] = L(!1), c = w(null), x = w(null);
|
|
34
42
|
N(() => {
|
|
35
|
-
const o = requestAnimationFrame(() =>
|
|
43
|
+
const o = requestAnimationFrame(() => h(!0));
|
|
36
44
|
return () => cancelAnimationFrame(o);
|
|
37
|
-
}, [
|
|
38
|
-
if (
|
|
45
|
+
}, [t.id]), S(() => {
|
|
46
|
+
if (t.id !== u) return;
|
|
39
47
|
x.current = document.activeElement || null;
|
|
40
48
|
const o = setTimeout(() => {
|
|
41
|
-
const
|
|
42
|
-
|
|
49
|
+
const e = _(c.current);
|
|
50
|
+
e && typeof e.focus == "function" && e.focus({ preventScroll: !0 });
|
|
43
51
|
}, 50);
|
|
44
52
|
return () => {
|
|
45
53
|
clearTimeout(o);
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
54
|
+
const e = document.activeElement;
|
|
55
|
+
if (!e || !c.current?.contains(e)) return;
|
|
56
|
+
const i = x.current;
|
|
57
|
+
if (i && typeof i.focus == "function" && document.body.contains(i))
|
|
50
58
|
try {
|
|
51
|
-
|
|
59
|
+
i.focus({ preventScroll: !0 });
|
|
52
60
|
} catch {
|
|
53
61
|
document.body.focus();
|
|
54
62
|
}
|
|
55
63
|
};
|
|
56
|
-
}, [
|
|
57
|
-
const
|
|
64
|
+
}, [t.id, u]);
|
|
65
|
+
const y = k(
|
|
58
66
|
(o) => a[o] ? j({
|
|
59
|
-
title:
|
|
60
|
-
confirmText:
|
|
61
|
-
cancelText:
|
|
67
|
+
title: n("common:exitConfirm"),
|
|
68
|
+
confirmText: n("common:Да"),
|
|
69
|
+
cancelText: n("common:Нет"),
|
|
62
70
|
confirmView: "negative"
|
|
63
71
|
}) : Promise.resolve(!0),
|
|
64
72
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
|
-
[a,
|
|
66
|
-
), f =
|
|
73
|
+
[a, n]
|
|
74
|
+
), f = k(
|
|
67
75
|
async (o) => {
|
|
68
|
-
const { id:
|
|
69
|
-
await
|
|
70
|
-
|
|
76
|
+
const { id: e } = t;
|
|
77
|
+
await y(o || e) && (h(!1), setTimeout(() => {
|
|
78
|
+
t.props.closeCallback && t.props.closeCallback(), d(o || e);
|
|
71
79
|
}, 250));
|
|
72
80
|
},
|
|
73
|
-
[
|
|
81
|
+
[d, y, t]
|
|
74
82
|
);
|
|
75
|
-
return
|
|
76
|
-
const o = (
|
|
77
|
-
if (
|
|
83
|
+
return S(() => {
|
|
84
|
+
const o = (e) => {
|
|
85
|
+
if (e.key === "27" || e.key === "Escape") {
|
|
78
86
|
f(u);
|
|
79
87
|
return;
|
|
80
88
|
}
|
|
81
|
-
if (
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
84
|
-
|
|
89
|
+
if (e.key !== "Tab") return;
|
|
90
|
+
const i = F(c.current);
|
|
91
|
+
if (!i.length) {
|
|
92
|
+
e.preventDefault(), c.current && c.current.focus({ preventScroll: !0 });
|
|
85
93
|
return;
|
|
86
94
|
}
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
-
|
|
95
|
+
const g = i[0], v = i[i.length - 1], b = document.activeElement;
|
|
96
|
+
if (e.shiftKey && (b === g || !c.current?.contains(b))) {
|
|
97
|
+
e.preventDefault(), v.focus({ preventScroll: !0 });
|
|
90
98
|
return;
|
|
91
99
|
}
|
|
92
|
-
!
|
|
100
|
+
!e.shiftKey && (b === v || !c.current?.contains(b)) && (e.preventDefault(), g.focus({ preventScroll: !0 }));
|
|
93
101
|
};
|
|
94
|
-
return
|
|
102
|
+
return t.id === u && window?.addEventListener("keydown", o), () => {
|
|
95
103
|
window?.removeEventListener("keydown", o);
|
|
96
104
|
};
|
|
97
|
-
}, [f, u,
|
|
105
|
+
}, [f, u, t.id]), /* @__PURE__ */ E(
|
|
98
106
|
"div",
|
|
99
107
|
{
|
|
100
108
|
className: s.container,
|
|
@@ -105,30 +113,30 @@ const R = {
|
|
|
105
113
|
/* @__PURE__ */ l(
|
|
106
114
|
"div",
|
|
107
115
|
{
|
|
108
|
-
ref:
|
|
116
|
+
ref: c,
|
|
109
117
|
className: C(s.right, s.content, {
|
|
110
118
|
[s.open]: p,
|
|
111
|
-
[s.bottomSheet]:
|
|
119
|
+
[s.bottomSheet]: m
|
|
112
120
|
}),
|
|
113
121
|
style: {
|
|
114
122
|
zIndex: 9999999 + r,
|
|
115
|
-
width:
|
|
123
|
+
width: T[t.props.size],
|
|
116
124
|
// На десктопе right-slide управляется JS-ом (старая
|
|
117
125
|
// схема — анимация ширины и right'а синхронны). На
|
|
118
126
|
// мобиле right=0 всегда, а появление контролируется
|
|
119
127
|
// CSS (.bottomSheet.open → top: 0).
|
|
120
|
-
right:
|
|
128
|
+
right: m || p ? 0 : R
|
|
121
129
|
},
|
|
122
130
|
role: "dialog",
|
|
123
131
|
"aria-modal": "true",
|
|
124
|
-
"aria-labelledby": `modal-title-${
|
|
132
|
+
"aria-labelledby": `modal-title-${t.id}`,
|
|
125
133
|
tabIndex: -1,
|
|
126
134
|
children: /* @__PURE__ */ E("div", { className: s.inner, children: [
|
|
127
135
|
/* @__PURE__ */ l(
|
|
128
|
-
|
|
136
|
+
t.modal,
|
|
129
137
|
{
|
|
130
|
-
...
|
|
131
|
-
modalId:
|
|
138
|
+
...t.props,
|
|
139
|
+
modalId: t.id,
|
|
132
140
|
close: () => f()
|
|
133
141
|
}
|
|
134
142
|
),
|
|
@@ -136,7 +144,7 @@ const R = {
|
|
|
136
144
|
z,
|
|
137
145
|
{
|
|
138
146
|
className: C(s.button, {
|
|
139
|
-
[s.doubleModal]:
|
|
147
|
+
[s.doubleModal]: t.props.isDouble
|
|
140
148
|
}),
|
|
141
149
|
view: "secondary",
|
|
142
150
|
size: "xs",
|
|
@@ -161,5 +169,5 @@ const R = {
|
|
|
161
169
|
);
|
|
162
170
|
};
|
|
163
171
|
export {
|
|
164
|
-
|
|
172
|
+
J as Modal
|
|
165
173
|
};
|
|
@@ -1,326 +1,350 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useMultipleSelection as
|
|
4
|
-
import st, { forwardRef as ot, useRef as
|
|
1
|
+
import { jsx as l, jsxs as rt } from "react/jsx-runtime";
|
|
2
|
+
import re from "classnames";
|
|
3
|
+
import { useMultipleSelection as se, useCombobox as L } from "downshift";
|
|
4
|
+
import st, { forwardRef as ot, useRef as g, useMemo as N, useCallback as W, useEffect as j } from "react";
|
|
5
5
|
import oe from "react-merge-refs";
|
|
6
|
-
import { ResizeObserver as
|
|
7
|
-
import { getDataTestId as
|
|
8
|
-
import { Popover as
|
|
9
|
-
import { processOptions as
|
|
10
|
-
import { NativeSelect as
|
|
11
|
-
import
|
|
12
|
-
const ce = (
|
|
13
|
-
const x =
|
|
14
|
-
return x.current =
|
|
15
|
-
},
|
|
6
|
+
import { ResizeObserver as ct } from "resize-observer";
|
|
7
|
+
import { getDataTestId as A } from "../../../__internal/utils/get-data-test-id.js";
|
|
8
|
+
import { Popover as it } from "../../../popover/component.js";
|
|
9
|
+
import { processOptions as lt } from "../../utils.js";
|
|
10
|
+
import { NativeSelect as at } from "../native-select/component.js";
|
|
11
|
+
import k from "./index.module.css.js";
|
|
12
|
+
const ce = (s) => s ? s.key?.toString() : "", ie = (s) => {
|
|
13
|
+
const x = g(s);
|
|
14
|
+
return x.current = s, x;
|
|
15
|
+
}, kt = ot(
|
|
16
16
|
({
|
|
17
|
-
dataTestId:
|
|
17
|
+
dataTestId: s = "",
|
|
18
18
|
className: x,
|
|
19
19
|
fieldClassName: le,
|
|
20
20
|
filteredOptions: ae,
|
|
21
21
|
popoverOuterClassname: de,
|
|
22
22
|
optionsListClassName: ue,
|
|
23
|
-
optionClassName:
|
|
23
|
+
optionClassName: $,
|
|
24
24
|
options: R,
|
|
25
|
-
actionButton:
|
|
26
|
-
autocomplete:
|
|
27
|
-
multiple:
|
|
28
|
-
allowUnselect:
|
|
29
|
-
disabled:
|
|
30
|
-
closeOnSelect:
|
|
25
|
+
actionButton: H,
|
|
26
|
+
autocomplete: y = !1,
|
|
27
|
+
multiple: p = !1,
|
|
28
|
+
allowUnselect: T = !1,
|
|
29
|
+
disabled: d = !1,
|
|
30
|
+
closeOnSelect: U = !p,
|
|
31
31
|
circularNavigation: fe = !1,
|
|
32
|
-
nativeSelect:
|
|
33
|
-
defaultOpen:
|
|
34
|
-
open:
|
|
32
|
+
nativeSelect: I = !1,
|
|
33
|
+
defaultOpen: V = !1,
|
|
34
|
+
open: O,
|
|
35
35
|
popoverPosition: pe = "bottom-start",
|
|
36
36
|
offset: me,
|
|
37
37
|
withArrow: he,
|
|
38
38
|
preventFlip: ge = !0,
|
|
39
|
-
optionsListWidth:
|
|
40
|
-
name:
|
|
39
|
+
optionsListWidth: _ = "field",
|
|
40
|
+
name: m,
|
|
41
41
|
id: ye,
|
|
42
42
|
required: Ie,
|
|
43
|
-
selected:
|
|
43
|
+
selected: v,
|
|
44
44
|
size: S = "m",
|
|
45
|
-
optionsSize:
|
|
45
|
+
optionsSize: q = S,
|
|
46
46
|
error: we,
|
|
47
47
|
hint: be,
|
|
48
48
|
block: ke = !0,
|
|
49
|
-
label:
|
|
50
|
-
placeholder:
|
|
51
|
-
fieldProps:
|
|
52
|
-
optionsListProps:
|
|
53
|
-
optionProps:
|
|
49
|
+
label: D,
|
|
50
|
+
placeholder: xe,
|
|
51
|
+
fieldProps: Re = {},
|
|
52
|
+
optionsListProps: ve = {},
|
|
53
|
+
optionProps: z = {},
|
|
54
54
|
valueRenderer: Ce,
|
|
55
|
-
onChange:
|
|
56
|
-
onOpen:
|
|
55
|
+
onChange: Me,
|
|
56
|
+
onOpen: Ne,
|
|
57
57
|
onFocus: Te,
|
|
58
|
-
onBlur:
|
|
59
|
-
onScroll:
|
|
60
|
-
Arrow:
|
|
61
|
-
Field:
|
|
62
|
-
OptionsList:
|
|
58
|
+
onBlur: Oe,
|
|
59
|
+
onScroll: Se,
|
|
60
|
+
Arrow: G,
|
|
61
|
+
Field: De = () => null,
|
|
62
|
+
OptionsList: Pe = () => null,
|
|
63
63
|
Optgroup: Ee = () => null,
|
|
64
|
-
Option:
|
|
64
|
+
Option: J = () => null,
|
|
65
65
|
updatePopover: Fe,
|
|
66
66
|
zIndexPopover: Ke,
|
|
67
|
-
showEmptyOptionsList:
|
|
68
|
-
visibleOptions:
|
|
67
|
+
showEmptyOptionsList: Be = !1,
|
|
68
|
+
visibleOptions: Le
|
|
69
69
|
}, We) => {
|
|
70
|
-
const
|
|
71
|
-
() =>
|
|
72
|
-
[R,
|
|
73
|
-
),
|
|
70
|
+
const w = g(null), Q = g(null), b = g(null), X = g(null), h = g(null), Y = ie(Me), Z = ie(Ne), { flatOptions: o, selectedOptions: ee } = N(
|
|
71
|
+
() => lt(R || [], v),
|
|
72
|
+
[R, v]
|
|
73
|
+
), te = N(() => {
|
|
74
74
|
const e = /* @__PURE__ */ new Map();
|
|
75
|
-
return
|
|
76
|
-
e.set(t.key,
|
|
75
|
+
return o.forEach((t, r) => {
|
|
76
|
+
e.set(t.key, r);
|
|
77
77
|
}), e;
|
|
78
|
-
}, [
|
|
78
|
+
}, [o]), je = N(
|
|
79
79
|
() => ({
|
|
80
80
|
itemToString: ce,
|
|
81
81
|
onSelectedItemsChange: (e) => {
|
|
82
82
|
const { selectedItems: t = [] } = e;
|
|
83
|
-
|
|
83
|
+
Y.current?.({
|
|
84
84
|
selectedMultiple: t,
|
|
85
85
|
selected: t.length ? t[0] : null,
|
|
86
|
-
name:
|
|
86
|
+
name: m
|
|
87
87
|
});
|
|
88
88
|
},
|
|
89
89
|
stateReducer: (e, t) => {
|
|
90
|
-
const { type:
|
|
91
|
-
return !
|
|
90
|
+
const { type: r, changes: n } = t;
|
|
91
|
+
return !T && r === se.stateChangeTypes.DropdownKeyDownBackspace ? e : n;
|
|
92
92
|
},
|
|
93
|
-
...
|
|
93
|
+
...v !== void 0 ? { selectedItems: ee } : {}
|
|
94
94
|
}),
|
|
95
|
-
[
|
|
95
|
+
[T, m, v, ee, Y]
|
|
96
96
|
), {
|
|
97
|
-
selectedItems:
|
|
97
|
+
selectedItems: c,
|
|
98
98
|
addSelectedItem: Ae,
|
|
99
|
-
setSelectedItems:
|
|
99
|
+
setSelectedItems: P,
|
|
100
100
|
removeSelectedItem: $e,
|
|
101
101
|
getDropdownProps: He
|
|
102
|
-
} =
|
|
103
|
-
() => new Set(
|
|
104
|
-
[
|
|
102
|
+
} = se(je), E = N(
|
|
103
|
+
() => new Set(c.map((e) => e.key)),
|
|
104
|
+
[c]
|
|
105
105
|
), {
|
|
106
|
-
isOpen:
|
|
106
|
+
isOpen: i,
|
|
107
107
|
getMenuProps: Ue,
|
|
108
108
|
getInputProps: Ve,
|
|
109
|
-
getItemProps:
|
|
109
|
+
getItemProps: ne,
|
|
110
110
|
getComboboxProps: _e,
|
|
111
111
|
getLabelProps: qe,
|
|
112
|
-
highlightedIndex:
|
|
113
|
-
toggleMenu:
|
|
114
|
-
openMenu:
|
|
115
|
-
} =
|
|
112
|
+
highlightedIndex: C,
|
|
113
|
+
toggleMenu: F,
|
|
114
|
+
openMenu: u
|
|
115
|
+
} = L({
|
|
116
116
|
id: ye,
|
|
117
|
-
isOpen:
|
|
117
|
+
isOpen: O,
|
|
118
118
|
circularNavigation: fe,
|
|
119
|
-
items:
|
|
119
|
+
items: o,
|
|
120
120
|
itemToString: ce,
|
|
121
|
-
defaultHighlightedIndex:
|
|
121
|
+
defaultHighlightedIndex: c.length === 0 ? -1 : void 0,
|
|
122
122
|
onIsOpenChange: (e) => {
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
Z.current && setTimeout(() => {
|
|
124
|
+
Z.current?.({ open: e.isOpen, name: m });
|
|
125
125
|
}, 0);
|
|
126
126
|
},
|
|
127
127
|
stateReducer: (e, t) => {
|
|
128
|
-
const { type:
|
|
129
|
-
switch (
|
|
130
|
-
case
|
|
131
|
-
case
|
|
132
|
-
if (
|
|
133
|
-
const
|
|
134
|
-
|
|
128
|
+
const { type: r, changes: n } = t, { selectedItem: a } = n;
|
|
129
|
+
switch (r) {
|
|
130
|
+
case L.stateChangeTypes.InputKeyDownEnter:
|
|
131
|
+
case L.stateChangeTypes.ItemClick:
|
|
132
|
+
if (a && !a.disabled) {
|
|
133
|
+
const M = E.has(a.key), B = T || p && c.length > 1;
|
|
134
|
+
M && B && $e(a), M || (p ? Ae(a) : P([a]));
|
|
135
135
|
}
|
|
136
136
|
return {
|
|
137
137
|
...n,
|
|
138
|
-
isOpen: !
|
|
139
|
-
highlightedIndex: e.isOpen && !
|
|
138
|
+
isOpen: !U,
|
|
139
|
+
highlightedIndex: e.isOpen && !U ? e.highlightedIndex : n.highlightedIndex
|
|
140
140
|
};
|
|
141
141
|
default:
|
|
142
142
|
return n;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
}), ze = Ue(
|
|
146
|
-
{ ref:
|
|
146
|
+
{ ref: b },
|
|
147
147
|
{ suppressRefError: !0 }
|
|
148
|
-
),
|
|
149
|
-
Te?.(e),
|
|
148
|
+
), f = Ve(He({ ref: oe([We, Q]) })), Ge = (e) => {
|
|
149
|
+
Te?.(e), y && !i && u();
|
|
150
150
|
}, Je = (e) => {
|
|
151
151
|
const t = e.relatedTarget || document.activeElement;
|
|
152
|
-
!!(t &&
|
|
152
|
+
!!(t && b.current?.contains(t)) || (Oe?.(e), f.onBlur(e));
|
|
153
153
|
}, Qe = (e) => {
|
|
154
|
-
|
|
154
|
+
f.onKeyDown(e), y && !i && e.key.length === 1 && u(), [" ", "Enter"].includes(e.key) && !y && !I && e.target.tagName !== "INPUT" && (e.preventDefault(), (!i || C === -1) && F());
|
|
155
155
|
}, Xe = (e) => {
|
|
156
|
-
|
|
156
|
+
b.current?.contains(e.target) || (!y || e.target.tagName !== "INPUT" ? F() : u());
|
|
157
157
|
}, Ye = W(
|
|
158
158
|
(e) => {
|
|
159
|
-
|
|
159
|
+
P(
|
|
160
160
|
Array.from(e.target.options).reduce(
|
|
161
|
-
(t,
|
|
161
|
+
(t, r, n) => r.selected ? t.concat(o[n]) : t,
|
|
162
162
|
[]
|
|
163
163
|
)
|
|
164
164
|
);
|
|
165
165
|
},
|
|
166
|
-
[
|
|
166
|
+
[o, P]
|
|
167
167
|
), Ze = W(
|
|
168
|
-
({ option: e, index: t, ...
|
|
168
|
+
({ option: e, index: t, ...r }) => {
|
|
169
169
|
if (!e) return null;
|
|
170
|
-
const n =
|
|
170
|
+
const n = te.get(e.key);
|
|
171
171
|
if (n === void 0) return null;
|
|
172
|
-
const
|
|
173
|
-
item:
|
|
172
|
+
const a = o[n], M = ne({
|
|
173
|
+
item: a,
|
|
174
174
|
index: n,
|
|
175
175
|
disabled: e.disabled,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
176
|
+
/*
|
|
177
|
+
* Стандартный паттерн для menu-items: блокируем
|
|
178
|
+
* только дефолт mouseDown, чтобы input/combobox
|
|
179
|
+
* не терял фокус во время клика по опции.
|
|
180
|
+
*
|
|
181
|
+
* ВАЖНО: НЕ добавлять preventDefault на touchstart
|
|
182
|
+
* или pointerdown! Спецификация W3C Touch Events
|
|
183
|
+
* (§5.6): "If the preventDefault() method is called
|
|
184
|
+
* on the touchstart event, the user agent should
|
|
185
|
+
* not dispatch any compatibility mouse events."
|
|
186
|
+
*
|
|
187
|
+
* Конкретно: touchstart.preventDefault() блокирует
|
|
188
|
+
* последующие mousedown → mouseup → click → focus.
|
|
189
|
+
* Downshift навешивает выбор опции на onClick
|
|
190
|
+
* (см. useCombobox/useMultipleSelection), который
|
|
191
|
+
* после preventDefault() на touchstart НЕ
|
|
192
|
+
* срабатывает. На мобиле опции рендерятся, но
|
|
193
|
+
* клик по ним игнорируется — выбора нет.
|
|
194
|
+
*
|
|
195
|
+
* pointerdown.preventDefault() ведёт себя
|
|
196
|
+
* аналогично в Chromium/Safari: подавляет
|
|
197
|
+
* compatibility mouse events. См. PointerEvent
|
|
198
|
+
* spec §10.1.
|
|
199
|
+
*
|
|
200
|
+
* stopPropagation тоже не нужен: дропдаун рендерится
|
|
201
|
+
* в Portal (вне DOM-дерева модалки), всплытие
|
|
202
|
+
* click'а до модалки не происходит структурно.
|
|
203
|
+
*
|
|
204
|
+
* Регрессия исправлена тут — раньше добавили
|
|
205
|
+
* onTouchStart/onPointerDown с preventDefault как
|
|
206
|
+
* "защиту от потери фокуса", но потеряли работающий
|
|
207
|
+
* select на мобиле.
|
|
208
|
+
*/
|
|
209
|
+
onMouseDown: (B) => B.preventDefault()
|
|
186
210
|
});
|
|
187
|
-
return /* @__PURE__ */
|
|
188
|
-
...
|
|
189
|
-
...
|
|
190
|
-
className:
|
|
191
|
-
innerProps:
|
|
211
|
+
return /* @__PURE__ */ l(st.Fragment, { children: J({
|
|
212
|
+
...z,
|
|
213
|
+
...r,
|
|
214
|
+
className: $,
|
|
215
|
+
innerProps: M,
|
|
192
216
|
index: t,
|
|
193
217
|
option: e,
|
|
194
|
-
size:
|
|
218
|
+
size: q,
|
|
195
219
|
disabled: e.disabled,
|
|
196
|
-
highlighted: n ===
|
|
197
|
-
selected:
|
|
220
|
+
highlighted: n === C,
|
|
221
|
+
selected: E.has(e.key)
|
|
198
222
|
}) }, e.key);
|
|
199
223
|
},
|
|
200
224
|
[
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
ee,
|
|
204
|
-
A,
|
|
225
|
+
z,
|
|
226
|
+
o,
|
|
205
227
|
te,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
228
|
+
$,
|
|
229
|
+
ne,
|
|
230
|
+
q,
|
|
231
|
+
C,
|
|
232
|
+
E,
|
|
233
|
+
J
|
|
210
234
|
]
|
|
211
235
|
);
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}, [
|
|
215
|
-
|
|
216
|
-
}, [
|
|
217
|
-
const
|
|
218
|
-
if (!
|
|
219
|
-
const e =
|
|
220
|
-
|
|
221
|
-
}, [
|
|
222
|
-
|
|
223
|
-
if (!
|
|
236
|
+
j(() => {
|
|
237
|
+
V && u();
|
|
238
|
+
}, [V, u]), j(() => {
|
|
239
|
+
O === !0 && u();
|
|
240
|
+
}, [O, u]);
|
|
241
|
+
const K = W(() => {
|
|
242
|
+
if (!b.current || !w.current) return;
|
|
243
|
+
const e = _ === "field" ? "width" : "minWidth", t = Math.round(w.current.getBoundingClientRect().width);
|
|
244
|
+
X.current !== t && (X.current = t, b.current.style[e] = `${t}px`);
|
|
245
|
+
}, [_]);
|
|
246
|
+
j(() => {
|
|
247
|
+
if (!i || !w.current) return;
|
|
224
248
|
const e = () => {
|
|
225
|
-
|
|
226
|
-
}, t = new
|
|
227
|
-
return t.observe(
|
|
228
|
-
t.disconnect(),
|
|
249
|
+
h.current && window.clearTimeout(h.current), h.current = window.setTimeout(K, 50);
|
|
250
|
+
}, t = new ct(e);
|
|
251
|
+
return t.observe(w.current), K(), () => {
|
|
252
|
+
t.disconnect(), h.current && window.clearTimeout(h.current), h.current = null;
|
|
229
253
|
};
|
|
230
|
-
}, [
|
|
231
|
-
const et =
|
|
254
|
+
}, [i, K]);
|
|
255
|
+
const et = p ? c.map((e) => e.key?.toString()) : c[0]?.key?.toString(), tt = o.length > 0 || Be || !!H, nt = D ? /* @__PURE__ */ l("span", { ...qe(), children: Ie ? `${D} *` : D }) : void 0;
|
|
232
256
|
return /* @__PURE__ */ rt(
|
|
233
257
|
"div",
|
|
234
258
|
{
|
|
235
259
|
..._e({
|
|
236
|
-
ref:
|
|
237
|
-
...
|
|
238
|
-
className:
|
|
260
|
+
ref: w,
|
|
261
|
+
...d && { "aria-disabled": !0 },
|
|
262
|
+
className: re(k.component, { [k.block]: ke }, x)
|
|
239
263
|
}),
|
|
240
|
-
onKeyDown:
|
|
264
|
+
onKeyDown: d ? void 0 : Qe,
|
|
241
265
|
tabIndex: -1,
|
|
242
266
|
id: "slect_wrapper",
|
|
243
|
-
"data-test-id":
|
|
267
|
+
"data-test-id": A("combobox", s),
|
|
244
268
|
children: [
|
|
245
|
-
|
|
246
|
-
|
|
269
|
+
I && /* @__PURE__ */ l(
|
|
270
|
+
at,
|
|
247
271
|
{
|
|
248
|
-
className:
|
|
249
|
-
disabled:
|
|
250
|
-
multiple:
|
|
251
|
-
name:
|
|
272
|
+
className: k.nativeSelect,
|
|
273
|
+
disabled: d,
|
|
274
|
+
multiple: p,
|
|
275
|
+
name: m,
|
|
252
276
|
value: et,
|
|
253
277
|
onChange: Ye,
|
|
254
278
|
options: R
|
|
255
279
|
}
|
|
256
280
|
),
|
|
257
|
-
/* @__PURE__ */
|
|
258
|
-
|
|
281
|
+
/* @__PURE__ */ l(
|
|
282
|
+
De,
|
|
259
283
|
{
|
|
260
|
-
selectedMultiple:
|
|
261
|
-
selected:
|
|
262
|
-
multiple:
|
|
263
|
-
open:
|
|
264
|
-
disabled:
|
|
284
|
+
selectedMultiple: c,
|
|
285
|
+
selected: c[0],
|
|
286
|
+
multiple: p,
|
|
287
|
+
open: i,
|
|
288
|
+
disabled: d,
|
|
265
289
|
size: S,
|
|
266
|
-
placeholder:
|
|
290
|
+
placeholder: xe,
|
|
267
291
|
label: nt,
|
|
268
|
-
Arrow:
|
|
292
|
+
Arrow: G && /* @__PURE__ */ l(G, { open: i }),
|
|
269
293
|
error: we,
|
|
270
294
|
hint: be,
|
|
271
295
|
valueRenderer: Ce,
|
|
272
296
|
className: le,
|
|
273
297
|
innerProps: {
|
|
274
298
|
onBlur: Je,
|
|
275
|
-
onFocus:
|
|
276
|
-
onClick:
|
|
277
|
-
tabIndex:
|
|
278
|
-
ref: oe([
|
|
279
|
-
id:
|
|
280
|
-
"aria-labelledby":
|
|
281
|
-
"aria-controls":
|
|
282
|
-
"aria-autocomplete":
|
|
299
|
+
onFocus: d ? void 0 : Ge,
|
|
300
|
+
onClick: d ? void 0 : Xe,
|
|
301
|
+
tabIndex: I || d ? -1 : 0,
|
|
302
|
+
ref: oe([f.ref]),
|
|
303
|
+
id: f.id,
|
|
304
|
+
"aria-labelledby": f["aria-labelledby"],
|
|
305
|
+
"aria-controls": f["aria-controls"],
|
|
306
|
+
"aria-autocomplete": y ? f["aria-autocomplete"] : void 0
|
|
283
307
|
},
|
|
284
|
-
dataTestId:
|
|
285
|
-
...
|
|
308
|
+
dataTestId: A("field", s),
|
|
309
|
+
...Re
|
|
286
310
|
}
|
|
287
311
|
),
|
|
288
|
-
|
|
289
|
-
!
|
|
290
|
-
|
|
312
|
+
m && !I && c.map((e) => /* @__PURE__ */ l("input", { type: "hidden", name: m, value: e.key }, e.key)),
|
|
313
|
+
!I && /* @__PURE__ */ l(
|
|
314
|
+
it,
|
|
291
315
|
{
|
|
292
|
-
open:
|
|
316
|
+
open: i,
|
|
293
317
|
withTransition: !1,
|
|
294
|
-
anchorElement:
|
|
318
|
+
anchorElement: Q.current,
|
|
295
319
|
position: pe,
|
|
296
320
|
offset: me,
|
|
297
321
|
withArrow: he,
|
|
298
322
|
preventFlip: ge,
|
|
299
323
|
className: de,
|
|
300
|
-
popperClassName:
|
|
324
|
+
popperClassName: k.popoverInner,
|
|
301
325
|
update: Fe,
|
|
302
326
|
zIndex: Ke,
|
|
303
|
-
children: tt && /* @__PURE__ */
|
|
327
|
+
children: tt && /* @__PURE__ */ l(
|
|
304
328
|
"div",
|
|
305
329
|
{
|
|
306
330
|
...ze,
|
|
307
|
-
className:
|
|
308
|
-
children: /* @__PURE__ */
|
|
309
|
-
|
|
331
|
+
className: re(ue, k.optionsList),
|
|
332
|
+
children: /* @__PURE__ */ l(
|
|
333
|
+
Pe,
|
|
310
334
|
{
|
|
311
|
-
...
|
|
312
|
-
flatOptions:
|
|
313
|
-
highlightedIndex:
|
|
314
|
-
open:
|
|
335
|
+
...ve,
|
|
336
|
+
flatOptions: o,
|
|
337
|
+
highlightedIndex: C,
|
|
338
|
+
open: i,
|
|
315
339
|
size: S,
|
|
316
|
-
toggleMenu:
|
|
317
|
-
actionButton:
|
|
340
|
+
toggleMenu: F,
|
|
341
|
+
actionButton: H,
|
|
318
342
|
options: ae ?? R,
|
|
319
343
|
Optgroup: Ee,
|
|
320
344
|
Option: Ze,
|
|
321
|
-
visibleOptions:
|
|
322
|
-
onScroll:
|
|
323
|
-
dataTestId:
|
|
345
|
+
visibleOptions: Le,
|
|
346
|
+
onScroll: Se,
|
|
347
|
+
dataTestId: A("options-list", s)
|
|
324
348
|
}
|
|
325
349
|
)
|
|
326
350
|
}
|
|
@@ -333,5 +357,5 @@ const ce = (o) => o ? o.key?.toString() : "", ie = (o) => {
|
|
|
333
357
|
}
|
|
334
358
|
);
|
|
335
359
|
export {
|
|
336
|
-
|
|
360
|
+
kt as BaseSelect
|
|
337
361
|
};
|
|
@@ -1,68 +1,70 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { createRoot as
|
|
4
|
-
import { ToastPlate as
|
|
5
|
-
import
|
|
6
|
-
import { createTimer as
|
|
7
|
-
let
|
|
8
|
-
typeof window < "u" && (
|
|
9
|
-
const
|
|
10
|
-
className:
|
|
11
|
-
children:
|
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import w from "classnames";
|
|
3
|
+
import { createRoot as E } from "react-dom/client";
|
|
4
|
+
import { ToastPlate as $ } from "../toast-plate/component.js";
|
|
5
|
+
import t from "./index.module.css.js";
|
|
6
|
+
import { createTimer as A } from "./use-timer.js";
|
|
7
|
+
let o;
|
|
8
|
+
typeof window < "u" && (o = document.createElement("div"), o.setAttribute("id", "toast_manager"), document.body.appendChild(o));
|
|
9
|
+
const R = ({
|
|
10
|
+
className: d,
|
|
11
|
+
children: L,
|
|
12
12
|
offset: n = 108,
|
|
13
|
-
hasCloser:
|
|
14
|
-
onClose:
|
|
15
|
-
text:
|
|
16
|
-
onMouseEnter:
|
|
17
|
-
onMouseLeave:
|
|
18
|
-
style:
|
|
19
|
-
position:
|
|
20
|
-
delay:
|
|
21
|
-
...
|
|
13
|
+
hasCloser: u = !0,
|
|
14
|
+
onClose: M,
|
|
15
|
+
text: c,
|
|
16
|
+
onMouseEnter: T,
|
|
17
|
+
onMouseLeave: N,
|
|
18
|
+
style: p,
|
|
19
|
+
position: f = "bottom",
|
|
20
|
+
delay: v = 3e3,
|
|
21
|
+
...x
|
|
22
22
|
}) => {
|
|
23
23
|
if (typeof window > "u") return null;
|
|
24
|
-
const r = window.innerWidth > 600,
|
|
25
|
-
const
|
|
26
|
-
return r ? `${
|
|
24
|
+
const r = window.innerWidth > 600, b = () => {
|
|
25
|
+
const m = "position: fixed; z-index: 999999999;";
|
|
26
|
+
return r ? `${m} ${f}: ${n}px; right: 30px` : `${m} top: ${n}px; right: 30px; left: 30px`;
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}),
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
o.setAttribute("style", b());
|
|
29
|
+
const e = document.createElement("div");
|
|
30
|
+
e.classList.remove(t.isClosing), e.setAttribute("id", `toast_wrap-${Math.random()}`), e.setAttribute("style", "margin-bottom: 18px"), o.appendChild(e);
|
|
31
|
+
const s = E(e);
|
|
32
|
+
let i = !1, a;
|
|
33
|
+
const l = () => {
|
|
34
|
+
i || (i = !0, a?.(), e.classList.add(t.isClosing), setTimeout(() => {
|
|
35
|
+
s.unmount(), e.remove();
|
|
36
|
+
}, 300));
|
|
37
|
+
}, { pause: h, resume: C, cancel: g } = A(l, v);
|
|
38
|
+
return a = g, e.addEventListener("mouseenter", () => {
|
|
39
|
+
h();
|
|
40
|
+
}), e.addEventListener("mouseleave", () => {
|
|
41
|
+
C();
|
|
42
|
+
}), s.render(
|
|
43
|
+
/* @__PURE__ */ y(
|
|
44
|
+
$,
|
|
43
45
|
{
|
|
44
|
-
hasCloser:
|
|
45
|
-
className:
|
|
46
|
+
hasCloser: u,
|
|
47
|
+
className: w(
|
|
46
48
|
{
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
+
[t.isVisible]: !0,
|
|
50
|
+
[t.mobile]: !r
|
|
49
51
|
},
|
|
50
|
-
|
|
52
|
+
d
|
|
51
53
|
),
|
|
52
|
-
contentClassName:
|
|
54
|
+
contentClassName: t.toastContent,
|
|
53
55
|
style: {
|
|
54
56
|
right: 0,
|
|
55
57
|
position: "relative",
|
|
56
|
-
...
|
|
58
|
+
...p
|
|
57
59
|
},
|
|
58
60
|
role: "alert",
|
|
59
|
-
onClose:
|
|
60
|
-
...
|
|
61
|
-
children:
|
|
61
|
+
onClose: l,
|
|
62
|
+
...x,
|
|
63
|
+
children: c
|
|
62
64
|
}
|
|
63
65
|
)
|
|
64
66
|
), null;
|
|
65
67
|
};
|
|
66
68
|
export {
|
|
67
|
-
|
|
69
|
+
R as ToastNotifier
|
|
68
70
|
};
|