@alphakits/ui 2.5.3 → 2.5.5
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 +1 @@
|
|
|
1
|
-
.container_WE0K{position:fixed;inset:0;display:flex;align-items:center;justify-content:center}.content_p1kc{background:var(--color-bg-primary);box-shadow:0 0 10px #0003}@media print{.content_p1kc{width:100%!important}}.button_js2W{position:absolute!important;top:34px;right:32px;z-index:999}.button_js2W.doubleModal_1ZTt{right:384px}.inner_Zsdb{height:100%;box-sizing:border-box;overflow:auto}.right_e065{position:fixed;top:0;right:0;bottom:0;transition:width .2s,opacity .2s,right .2s;transition-delay:width .1s;transition-timing-function:ease-in}.bg_8ZfP{transition:opacity .2s;background:#00000080;position:fixed;display:block;border:0;inset:0}.bottomSheet_CI-8{
|
|
1
|
+
.container_WE0K{position:fixed;inset:0;display:flex;align-items:center;justify-content:center}.content_p1kc{background:var(--color-bg-primary);box-shadow:0 0 10px #0003}@media print{.content_p1kc{width:100%!important}}.button_js2W{position:absolute!important;top:34px;right:32px;z-index:999}.button_js2W.doubleModal_1ZTt{right:384px}.inner_Zsdb{height:100%;box-sizing:border-box;overflow:auto}.right_e065{position:fixed;top:0;right:0;bottom:0;transition:width .2s,opacity .2s,right .2s;transition-delay:width .1s;transition-timing-function:ease-in}.bg_8ZfP{transition:opacity .2s;background:#00000080;position:fixed;display:block;border:0;inset:0}.bottomSheet_CI-8{top:100dvh!important;bottom:auto!important;left:0!important;right:0!important;width:100%!important;max-width:100%!important;height:100dvh;max-height:100dvh;border-radius:0!important;transition:top .25s cubic-bezier(.32,.72,0,1)}@supports not (height: 100dvh){.bottomSheet_CI-8{top:100vh!important;height:100vh;max-height:100vh}}.bottomSheet_CI-8.open_eGDW{top:0!important}@media screen and (max-width:823px){.right_e065,.center_nguy{max-width:100%!important;right:0!important;left:0!important}.content_p1kc{box-shadow:none!important;margin:0!important}.button_js2W{top:16px!important;right:16px!important}}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { useState as
|
|
5
|
-
import { Button as
|
|
6
|
-
import { showConfirm as
|
|
7
|
-
import { useMatchMedia as
|
|
1
|
+
import { jsxs as E, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import O from "@alphakits/icons/dist/CloseM";
|
|
3
|
+
import C from "classnames";
|
|
4
|
+
import { useState as L, useRef as w, useLayoutEffect as N, useEffect as k, useCallback as S } from "react";
|
|
5
|
+
import { Button as z } from "../../../button/component.js";
|
|
6
|
+
import { showConfirm as j } from "../../../confirm-popup/component.js";
|
|
7
|
+
import { useMatchMedia as B } from "../../../mq/use-match-media.js";
|
|
8
8
|
import s from "./index.module.css.js";
|
|
9
|
-
const
|
|
9
|
+
const R = {
|
|
10
10
|
s: 488,
|
|
11
11
|
m: 888,
|
|
12
12
|
full: "96%"
|
|
13
|
-
},
|
|
13
|
+
}, T = 102, D = "(max-width: 823px)", K = (e) => e === "full" ? `calc(-96vw - ${T}px)` : -R[e] - T, _ = [
|
|
14
14
|
'a[href]:not([tabindex="-1"])',
|
|
15
15
|
'area[href]:not([tabindex="-1"])',
|
|
16
16
|
'button:not([disabled]):not([tabindex="-1"])',
|
|
@@ -25,44 +25,37 @@ const N = {
|
|
|
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(","),
|
|
28
|
+
].join(","), F = (e) => e ? Array.from(e.querySelectorAll(_)).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
|
-
const
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
return () => cancelAnimationFrame(
|
|
37
|
-
}, [e.id])
|
|
38
|
-
const D = p(
|
|
39
|
-
(t) => {
|
|
40
|
-
t.propertyName === "transform" && t.target === t.currentTarget && (!m || !f || x(!0));
|
|
41
|
-
},
|
|
42
|
-
[m, f]
|
|
43
|
-
);
|
|
44
|
-
A(() => {
|
|
32
|
+
}) : [], W = ({ modal: e, t: c, index: r, dirtyModals: a, closeModal: m, currentModalId: u }) => {
|
|
33
|
+
const A = K(e.props.size), [b] = B(D), [p, y] = L(!1), i = w(null), x = w(null);
|
|
34
|
+
N(() => {
|
|
35
|
+
const o = requestAnimationFrame(() => y(!0));
|
|
36
|
+
return () => cancelAnimationFrame(o);
|
|
37
|
+
}, [e.id]), k(() => {
|
|
45
38
|
if (e.id !== u) return;
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
39
|
+
x.current = document.activeElement || null;
|
|
40
|
+
const o = setTimeout(() => {
|
|
41
|
+
const n = F(i.current)[0] || i.current;
|
|
42
|
+
n && typeof n.focus == "function" && n.focus({ preventScroll: !0 });
|
|
50
43
|
}, 50);
|
|
51
44
|
return () => {
|
|
52
|
-
clearTimeout(
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
45
|
+
clearTimeout(o);
|
|
46
|
+
const t = document.activeElement;
|
|
47
|
+
if (!t || !i.current?.contains(t)) return;
|
|
48
|
+
const n = x.current;
|
|
49
|
+
if (n && typeof n.focus == "function" && document.body.contains(n))
|
|
57
50
|
try {
|
|
58
|
-
|
|
51
|
+
n.focus({ preventScroll: !0 });
|
|
59
52
|
} catch {
|
|
60
53
|
document.body.focus();
|
|
61
54
|
}
|
|
62
55
|
};
|
|
63
56
|
}, [e.id, u]);
|
|
64
|
-
const
|
|
65
|
-
(
|
|
57
|
+
const h = S(
|
|
58
|
+
(o) => a[o] ? j({
|
|
66
59
|
title: c("common:exitConfirm"),
|
|
67
60
|
confirmText: c("common:Да"),
|
|
68
61
|
cancelText: c("common:Нет"),
|
|
@@ -70,38 +63,38 @@ const N = {
|
|
|
70
63
|
}) : Promise.resolve(!0),
|
|
71
64
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
65
|
[a, c]
|
|
73
|
-
),
|
|
74
|
-
async (
|
|
75
|
-
const { id:
|
|
76
|
-
await
|
|
77
|
-
e.props.closeCallback && e.props.closeCallback(),
|
|
66
|
+
), f = S(
|
|
67
|
+
async (o) => {
|
|
68
|
+
const { id: t } = e;
|
|
69
|
+
await h(o || t) && (y(!1), setTimeout(() => {
|
|
70
|
+
e.props.closeCallback && e.props.closeCallback(), m(o || t);
|
|
78
71
|
}, 250));
|
|
79
72
|
},
|
|
80
|
-
[
|
|
73
|
+
[m, h, e]
|
|
81
74
|
);
|
|
82
|
-
return
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
75
|
+
return k(() => {
|
|
76
|
+
const o = (t) => {
|
|
77
|
+
if (t.key === "27" || t.key === "Escape") {
|
|
78
|
+
f(u);
|
|
86
79
|
return;
|
|
87
80
|
}
|
|
88
|
-
if (
|
|
89
|
-
const
|
|
90
|
-
if (!
|
|
91
|
-
|
|
81
|
+
if (t.key !== "Tab") return;
|
|
82
|
+
const n = F(i.current);
|
|
83
|
+
if (!n.length) {
|
|
84
|
+
t.preventDefault(), i.current && i.current.focus({ preventScroll: !0 });
|
|
92
85
|
return;
|
|
93
86
|
}
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
|
|
87
|
+
const v = n[0], g = n[n.length - 1], d = document.activeElement;
|
|
88
|
+
if (t.shiftKey && (d === v || !i.current?.contains(d))) {
|
|
89
|
+
t.preventDefault(), g.focus({ preventScroll: !0 });
|
|
97
90
|
return;
|
|
98
91
|
}
|
|
99
|
-
!
|
|
92
|
+
!t.shiftKey && (d === g || !i.current?.contains(d)) && (t.preventDefault(), v.focus({ preventScroll: !0 }));
|
|
100
93
|
};
|
|
101
|
-
return e.id === u && window?.addEventListener("keydown",
|
|
102
|
-
window?.removeEventListener("keydown",
|
|
94
|
+
return e.id === u && window?.addEventListener("keydown", o), () => {
|
|
95
|
+
window?.removeEventListener("keydown", o);
|
|
103
96
|
};
|
|
104
|
-
}, [
|
|
97
|
+
}, [f, u, e.id]), /* @__PURE__ */ E(
|
|
105
98
|
"div",
|
|
106
99
|
{
|
|
107
100
|
className: s.container,
|
|
@@ -109,60 +102,58 @@ const N = {
|
|
|
109
102
|
zIndex: 9999998 + r
|
|
110
103
|
},
|
|
111
104
|
children: [
|
|
112
|
-
/* @__PURE__ */
|
|
105
|
+
/* @__PURE__ */ l(
|
|
113
106
|
"div",
|
|
114
107
|
{
|
|
115
108
|
ref: i,
|
|
116
|
-
className:
|
|
117
|
-
[s.open]:
|
|
118
|
-
[s.bottomSheet]:
|
|
109
|
+
className: C(s.right, s.content, {
|
|
110
|
+
[s.open]: p,
|
|
111
|
+
[s.bottomSheet]: b
|
|
119
112
|
}),
|
|
120
113
|
style: {
|
|
121
114
|
zIndex: 9999999 + r,
|
|
122
|
-
width:
|
|
115
|
+
width: R[e.props.size],
|
|
123
116
|
// На десктопе right-slide управляется JS-ом (старая
|
|
124
117
|
// схема — анимация ширины и right'а синхронны). На
|
|
125
118
|
// мобиле right=0 всегда, а появление контролируется
|
|
126
|
-
// CSS
|
|
127
|
-
right:
|
|
119
|
+
// CSS (.bottomSheet.open → top: 0).
|
|
120
|
+
right: b || p ? 0 : A
|
|
128
121
|
},
|
|
129
|
-
onTransitionEnd: D,
|
|
130
|
-
"data-anim-done": f && L ? "true" : void 0,
|
|
131
122
|
role: "dialog",
|
|
132
123
|
"aria-modal": "true",
|
|
133
124
|
"aria-labelledby": `modal-title-${e.id}`,
|
|
134
125
|
tabIndex: -1,
|
|
135
|
-
children: /* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */
|
|
126
|
+
children: /* @__PURE__ */ E("div", { className: s.inner, children: [
|
|
127
|
+
/* @__PURE__ */ l(
|
|
137
128
|
e.modal,
|
|
138
129
|
{
|
|
139
130
|
...e.props,
|
|
140
131
|
modalId: e.id,
|
|
141
|
-
close: () =>
|
|
132
|
+
close: () => f()
|
|
142
133
|
}
|
|
143
134
|
),
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
|
|
135
|
+
/* @__PURE__ */ l(
|
|
136
|
+
z,
|
|
146
137
|
{
|
|
147
|
-
className:
|
|
138
|
+
className: C(s.button, {
|
|
148
139
|
[s.doubleModal]: e.props.isDouble
|
|
149
140
|
}),
|
|
150
141
|
view: "secondary",
|
|
151
142
|
size: "xs",
|
|
152
|
-
leftAddons: /* @__PURE__ */
|
|
153
|
-
onClick: () =>
|
|
143
|
+
leftAddons: /* @__PURE__ */ l(O, {}),
|
|
144
|
+
onClick: () => f()
|
|
154
145
|
}
|
|
155
146
|
)
|
|
156
147
|
] })
|
|
157
148
|
}
|
|
158
149
|
),
|
|
159
|
-
/* @__PURE__ */
|
|
150
|
+
/* @__PURE__ */ l(
|
|
160
151
|
"button",
|
|
161
152
|
{
|
|
162
153
|
className: s.bg,
|
|
163
154
|
"aria-label": "Close dialog",
|
|
164
155
|
type: "button",
|
|
165
|
-
onClick: () =>
|
|
156
|
+
onClick: () => f()
|
|
166
157
|
}
|
|
167
158
|
)
|
|
168
159
|
]
|
|
@@ -170,5 +161,5 @@ const N = {
|
|
|
170
161
|
);
|
|
171
162
|
};
|
|
172
163
|
export {
|
|
173
|
-
|
|
164
|
+
W as Modal
|
|
174
165
|
};
|
|
@@ -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
|
};
|