@box/combobox-with-api 1.15.7 → 1.16.0
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/chunks/dynamic-loading-tree.js +133 -142
- package/dist/chunks/treeReducer.js +2 -2
- package/dist/esm/lib/components/combobox-with-api/combobox-with-api-container.js +33 -33
- package/dist/esm/lib/components/combobox-with-api-pagination/combobox-with-api-pagination.js +110 -113
- package/dist/esm/lib/components/combobox-with-api-pagination/request.js +2 -2
- package/dist/esm/lib/components/combobox-with-api-pagination/use-async-list.js +3 -4
- package/dist/esm/lib/components/combobox-with-api-pagination/utils/use-controllable-state.js +21 -24
- package/dist/esm/lib/components/combobox-with-api-pagination/utils/use-intersection-observer.js +59 -61
- package/dist/esm/lib/components/combobox-with-api-tree-view/combobox-with-api-tree-view.js +97 -100
- package/dist/esm/lib/components/combobox-with-api-tree-view/index.js +22 -22
- package/dist/i18n/en-x-pseudo.js +8 -8
- package/dist/i18n/en-x-pseudo.properties +8 -8
- package/package.json +7 -7
package/dist/esm/lib/components/combobox-with-api-pagination/combobox-with-api-pagination.js
CHANGED
|
@@ -1,48 +1,47 @@
|
|
|
1
1
|
import { ComboboxItemValue as ce } from "@ariakit/react";
|
|
2
|
-
import { Combobox as
|
|
3
|
-
import { Search as
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { forwardRef as
|
|
7
|
-
import { useIntl as
|
|
2
|
+
import { Combobox as d, useForkRef as ue, LoadingIndicator as de, InlineNotice as pe, Text as me } from "@box/blueprint-web";
|
|
3
|
+
import { Search as he, Loader as fe } from "@box/blueprint-web-assets/icons/Fill";
|
|
4
|
+
import { Size6 as V, Size1 as ge, IconIconOnLightSecondary as be } from "@box/blueprint-web-assets/tokens/tokens";
|
|
5
|
+
import S from "clsx";
|
|
6
|
+
import { forwardRef as D, useRef as A, useState as xe, useCallback as N, useMemo as L, useEffect as Oe } from "react";
|
|
7
|
+
import { useIntl as B, FormattedMessage as k } from "react-intl";
|
|
8
8
|
import a from "./messages.js";
|
|
9
9
|
import { useAsyncList as _e } from "./use-async-list.js";
|
|
10
|
-
import { useControllableState as
|
|
11
|
-
import { useTrackVisibility as
|
|
12
|
-
import { jsx as r, jsxs as
|
|
13
|
-
import '../../../../styles/combobox-with-api-pagination.css';const Le = "
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
selected: ve,
|
|
10
|
+
import { useControllableState as Ce } from "./utils/use-controllable-state.js";
|
|
11
|
+
import { useTrackVisibility as Re } from "./utils/use-intersection-observer.js";
|
|
12
|
+
import { jsx as r, jsxs as F, Fragment as Ae } from "react/jsx-runtime";
|
|
13
|
+
import '../../../../styles/combobox-with-api-pagination.css';const Le = "_disabled_19k3s_8", ye = "_highlightOptionText_19k3s_12", Ee = "_selected_19k3s_24", Ie = "_option_19k3s_35", ve = "_errorComboboxOption_19k3s_39", Me = "_errorComboboxOptionText_19k3s_44", i = {
|
|
14
|
+
disabled: Le,
|
|
15
|
+
highlightOptionText: ye,
|
|
16
|
+
selected: Ee,
|
|
18
17
|
option: Ie,
|
|
19
|
-
errorComboboxOption:
|
|
20
|
-
errorComboboxOptionText:
|
|
21
|
-
},
|
|
18
|
+
errorComboboxOption: ve,
|
|
19
|
+
errorComboboxOptionText: Me
|
|
20
|
+
}, P = /* @__PURE__ */ D(({
|
|
22
21
|
onTryAgain: I
|
|
23
|
-
},
|
|
22
|
+
}, p) => {
|
|
24
23
|
const {
|
|
25
|
-
formatMessage:
|
|
26
|
-
} =
|
|
27
|
-
return /* @__PURE__ */
|
|
24
|
+
formatMessage: m
|
|
25
|
+
} = B();
|
|
26
|
+
return /* @__PURE__ */ F(Ae, {
|
|
28
27
|
children: [/* @__PURE__ */ r(pe, {
|
|
29
28
|
variant: "error",
|
|
30
|
-
variantIconAriaLabel:
|
|
31
|
-
children: /* @__PURE__ */ r(
|
|
29
|
+
variantIconAriaLabel: m(a.loadingResultsErrorIconLabel),
|
|
30
|
+
children: /* @__PURE__ */ r(k, {
|
|
32
31
|
...a.loadingResultsErrorMessage
|
|
33
32
|
})
|
|
34
|
-
}), /* @__PURE__ */ r(
|
|
35
|
-
ref:
|
|
36
|
-
className:
|
|
33
|
+
}), /* @__PURE__ */ r(d.Option, {
|
|
34
|
+
ref: p,
|
|
35
|
+
className: i.errorComboboxOption,
|
|
37
36
|
onClick: I,
|
|
38
|
-
children: /* @__PURE__ */
|
|
37
|
+
children: /* @__PURE__ */ F(me, {
|
|
39
38
|
as: "span",
|
|
40
|
-
className:
|
|
39
|
+
className: i.errorComboboxOptionText,
|
|
41
40
|
color: "textOnLightLink",
|
|
42
41
|
variant: "bodyDefaultBold",
|
|
43
|
-
children: [/* @__PURE__ */ r(
|
|
42
|
+
children: [/* @__PURE__ */ r(k, {
|
|
44
43
|
...a.loadingResultsErrorAction
|
|
45
|
-
}), /* @__PURE__ */ r(
|
|
44
|
+
}), /* @__PURE__ */ r(fe, {
|
|
46
45
|
color: "currentColor",
|
|
47
46
|
height: "12px",
|
|
48
47
|
width: "12px"
|
|
@@ -50,158 +49,156 @@ import '../../../../styles/combobox-with-api-pagination.css';const Le = "_contai
|
|
|
50
49
|
})
|
|
51
50
|
})]
|
|
52
51
|
});
|
|
53
|
-
}),
|
|
54
|
-
color:
|
|
52
|
+
}), y = "__LOADING__", E = "__LOADING_ERROR__", Te = "0px 0px 20px 0px", Ve = /* @__PURE__ */ r(he, {
|
|
53
|
+
color: be,
|
|
55
54
|
height: V,
|
|
56
55
|
role: "presentation",
|
|
57
56
|
style: {
|
|
58
|
-
padding:
|
|
57
|
+
padding: ge,
|
|
59
58
|
boxSizing: "border-box"
|
|
60
59
|
},
|
|
61
60
|
width: V
|
|
62
|
-
}),
|
|
61
|
+
}), Ue = /* @__PURE__ */ D(function(p, m) {
|
|
63
62
|
const {
|
|
64
|
-
dataTargetId:
|
|
65
|
-
defaultFetcher:
|
|
66
|
-
initialOpen:
|
|
67
|
-
onInputValueChange:
|
|
63
|
+
dataTargetId: W,
|
|
64
|
+
defaultFetcher: w,
|
|
65
|
+
initialOpen: z = !1,
|
|
66
|
+
onInputValueChange: G,
|
|
68
67
|
value: j,
|
|
69
68
|
onValueChange: U,
|
|
70
|
-
onOpenChange:
|
|
69
|
+
onOpenChange: h,
|
|
71
70
|
noResultMessage: q,
|
|
72
71
|
defaultValue: H = [],
|
|
73
72
|
loadingAriaLabel: J,
|
|
74
|
-
multiselect:
|
|
73
|
+
multiselect: s = !1,
|
|
75
74
|
disabled: K,
|
|
76
75
|
className: Q,
|
|
77
|
-
displaySingleSelectionAsChip:
|
|
76
|
+
displaySingleSelectionAsChip: f = !0,
|
|
78
77
|
...X
|
|
79
|
-
} =
|
|
80
|
-
formatMessage:
|
|
81
|
-
} =
|
|
78
|
+
} = p, {
|
|
79
|
+
formatMessage: c
|
|
80
|
+
} = B(), g = A(null), b = A(!0), [Y, v] = xe(z), e = _e({
|
|
82
81
|
async load({
|
|
83
|
-
marker:
|
|
82
|
+
marker: o,
|
|
84
83
|
searchInput: t,
|
|
85
84
|
signal: C
|
|
86
85
|
}) {
|
|
87
|
-
const
|
|
86
|
+
const l = await w({
|
|
88
87
|
signal: C,
|
|
89
|
-
marker:
|
|
88
|
+
marker: o,
|
|
90
89
|
searchInput: t
|
|
91
90
|
});
|
|
92
91
|
return {
|
|
93
|
-
items:
|
|
94
|
-
marker:
|
|
92
|
+
items: l.options,
|
|
93
|
+
marker: l.marker
|
|
95
94
|
};
|
|
96
95
|
}
|
|
97
|
-
}),
|
|
98
|
-
|
|
99
|
-
}, []), [n,
|
|
96
|
+
}), M = A(!1), Z = N(() => {
|
|
97
|
+
M.current || (e.reload(), M.current = !0);
|
|
98
|
+
}, []), [n, x] = Ce({
|
|
100
99
|
prop: j,
|
|
101
100
|
defaultProp: H,
|
|
102
101
|
onChange: U
|
|
103
|
-
}),
|
|
104
|
-
|
|
105
|
-
}, [
|
|
106
|
-
|
|
107
|
-
}, oe =
|
|
102
|
+
}), O = !s && n.length === 1, $ = N((o) => {
|
|
103
|
+
v(o), h?.(o);
|
|
104
|
+
}, [h]), ee = (o) => {
|
|
105
|
+
o === void 0 ? (x([]), (!b.current || !f) && (e.search(""), b.current = !0)) : Array.isArray(o) ? x(o) : (x([o]), s || (v(!1), h?.(!1)));
|
|
106
|
+
}, oe = L(() => n.length === 0 ? s ? [] : void 0 : s ? n : n[0], [s, n]), _ = L(() => n.filter((o) => !e.items.some((t) => t.value === o.value)), [n, e.items]), te = (o) => {
|
|
108
107
|
const {
|
|
109
108
|
value: t,
|
|
110
109
|
displayValue: C,
|
|
111
|
-
...
|
|
112
|
-
} =
|
|
113
|
-
if (t ===
|
|
114
|
-
return
|
|
115
|
-
...
|
|
116
|
-
ref:
|
|
110
|
+
...l
|
|
111
|
+
} = o;
|
|
112
|
+
if (t === y)
|
|
113
|
+
return e.hasNextPage ? /* @__PURE__ */ r(d.Option, {
|
|
114
|
+
...l,
|
|
115
|
+
ref: ae,
|
|
117
116
|
disabled: !0,
|
|
118
117
|
value: t,
|
|
119
118
|
children: /* @__PURE__ */ r(de, {
|
|
120
|
-
"aria-label":
|
|
119
|
+
"aria-label": c(a.loadingMoreAriaLabel),
|
|
121
120
|
style: {
|
|
122
121
|
position: "unset"
|
|
123
122
|
}
|
|
124
123
|
})
|
|
125
124
|
}) : null;
|
|
126
|
-
if (t ===
|
|
127
|
-
return /* @__PURE__ */ r(
|
|
125
|
+
if (t === E && e.hasError && !e.isEmpty)
|
|
126
|
+
return /* @__PURE__ */ r(P, {
|
|
128
127
|
onTryAgain: () => {
|
|
129
|
-
|
|
130
|
-
o.loadMore(), (l = x.current) == null || l.focus();
|
|
128
|
+
e.loadMore(), g.current?.focus();
|
|
131
129
|
}
|
|
132
130
|
});
|
|
133
|
-
if (
|
|
131
|
+
if (_.some((R) => R.value === t))
|
|
134
132
|
return null;
|
|
135
|
-
const le = n.some((
|
|
136
|
-
return /* @__PURE__ */ r(
|
|
137
|
-
...
|
|
138
|
-
className:
|
|
133
|
+
const le = n.some((R) => R.value === t);
|
|
134
|
+
return /* @__PURE__ */ r(d.Option, {
|
|
135
|
+
...l,
|
|
136
|
+
className: i.option,
|
|
139
137
|
value: t,
|
|
140
138
|
children: /* @__PURE__ */ r(ce, {
|
|
141
|
-
className:
|
|
139
|
+
className: S(i.highlightOptionText, le && i.selected),
|
|
142
140
|
value: C || t
|
|
143
141
|
})
|
|
144
142
|
});
|
|
145
|
-
}, re = (
|
|
146
|
-
if (
|
|
147
|
-
|
|
143
|
+
}, re = (o) => {
|
|
144
|
+
if (G?.(o), O && o === "") {
|
|
145
|
+
b.current = !1;
|
|
148
146
|
return;
|
|
149
147
|
}
|
|
150
|
-
|
|
148
|
+
e.search(o);
|
|
151
149
|
}, ne = () => {
|
|
152
|
-
|
|
153
|
-
o.reload(), (e = x.current) == null || e.focus();
|
|
150
|
+
e.reload(), g.current?.focus();
|
|
154
151
|
};
|
|
155
|
-
let
|
|
156
|
-
|
|
152
|
+
let u;
|
|
153
|
+
e.hasError && !e.isLoading ? u = /* @__PURE__ */ r(P, {
|
|
157
154
|
onTryAgain: ne
|
|
158
|
-
}) :
|
|
159
|
-
const [
|
|
160
|
-
rootRef:
|
|
161
|
-
isVisible:
|
|
162
|
-
}] =
|
|
163
|
-
rootMargin:
|
|
155
|
+
}) : e.isEmpty && !e.isLoading ? u = q || c(a.noResults) : u = void 0;
|
|
156
|
+
const [ae, {
|
|
157
|
+
rootRef: se,
|
|
158
|
+
isVisible: T
|
|
159
|
+
}] = Re({
|
|
160
|
+
rootMargin: Te
|
|
164
161
|
});
|
|
165
162
|
Oe(() => {
|
|
166
|
-
if (!(
|
|
163
|
+
if (!(T && e.hasNextPage))
|
|
167
164
|
return;
|
|
168
165
|
const t = setTimeout(() => {
|
|
169
|
-
|
|
166
|
+
e.loadMore();
|
|
170
167
|
}, 100);
|
|
171
168
|
return () => {
|
|
172
169
|
clearTimeout(t);
|
|
173
170
|
};
|
|
174
|
-
}, [
|
|
175
|
-
const ie =
|
|
176
|
-
const
|
|
171
|
+
}, [T]);
|
|
172
|
+
const ie = L(() => {
|
|
173
|
+
const o = e.hasNextPage ? {
|
|
174
|
+
displayValue: y,
|
|
175
|
+
value: y
|
|
176
|
+
} : null, t = !o && e.hasError && !e.isEmpty ? {
|
|
177
177
|
displayValue: E,
|
|
178
178
|
value: E
|
|
179
|
-
} : null, t = !e && o.hasError && !o.isEmpty ? {
|
|
180
|
-
displayValue: v,
|
|
181
|
-
value: v
|
|
182
179
|
} : null;
|
|
183
|
-
return [...
|
|
184
|
-
}, [
|
|
185
|
-
return /* @__PURE__ */ r(
|
|
180
|
+
return [...e.items, ..._, o, t].filter(Boolean);
|
|
181
|
+
}, [e.hasNextPage, e.hasError, e.isEmpty, e.items, _]);
|
|
182
|
+
return /* @__PURE__ */ r(d, {
|
|
186
183
|
...X,
|
|
187
|
-
ref: ue(
|
|
184
|
+
ref: ue(g, m),
|
|
188
185
|
as: "input",
|
|
189
|
-
className:
|
|
190
|
-
[
|
|
186
|
+
className: S({
|
|
187
|
+
[i.disabled]: O
|
|
191
188
|
}, Q),
|
|
192
|
-
clearButtonAriaLabel:
|
|
189
|
+
clearButtonAriaLabel: c(a.clearButtonAriaLabel),
|
|
193
190
|
clearOnBlur: !1,
|
|
194
|
-
"data-target-id":
|
|
195
|
-
disabled: K ||
|
|
196
|
-
displaySingleSelectionAsChip:
|
|
197
|
-
displayValue: (
|
|
191
|
+
"data-target-id": W,
|
|
192
|
+
disabled: K || O && f,
|
|
193
|
+
displaySingleSelectionAsChip: f,
|
|
194
|
+
displayValue: (o) => o.displayValue || o.value,
|
|
198
195
|
endComboboxIcon: Ve,
|
|
199
196
|
focusLoop: !1,
|
|
200
|
-
getPopoverRef:
|
|
201
|
-
loading:
|
|
202
|
-
loadingAriaLabel: J ||
|
|
203
|
-
multiselect:
|
|
204
|
-
noResultMessage:
|
|
197
|
+
getPopoverRef: se,
|
|
198
|
+
loading: e.isReloading,
|
|
199
|
+
loadingAriaLabel: J || c(a.loadingAriaLabel),
|
|
200
|
+
multiselect: s,
|
|
201
|
+
noResultMessage: u,
|
|
205
202
|
onFocus: Z,
|
|
206
203
|
onInputValueChange: re,
|
|
207
204
|
onOpenChange: $,
|
|
@@ -213,5 +210,5 @@ import '../../../../styles/combobox-with-api-pagination.css';const Le = "_contai
|
|
|
213
210
|
});
|
|
214
211
|
});
|
|
215
212
|
export {
|
|
216
|
-
|
|
213
|
+
Ue as ComboboxWithApiPagination
|
|
217
214
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
let C = /* @__PURE__ */ function(E) {
|
|
1
|
+
let C = /* @__PURE__ */ (function(E) {
|
|
2
2
|
return E.NOT_STARTED = "NOT_STARTED", E.IN_PROGRESS = "IN_PROGRESS", E.ERROR = "ERROR", E.SUCCESS = "SUCCESS", E.CANCELLED = "CANCELLED", E;
|
|
3
|
-
}({});
|
|
3
|
+
})({});
|
|
4
4
|
export {
|
|
5
5
|
C as RequestStates
|
|
6
6
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useReducer as O } from "react";
|
|
2
2
|
import { RequestStates as u } from "./request.js";
|
|
3
3
|
import { isAbortError as I } from "./utils/is-abort-error.js";
|
|
4
|
-
var s = /* @__PURE__ */ function(r) {
|
|
4
|
+
var s = /* @__PURE__ */ (function(r) {
|
|
5
5
|
return r.LOAD_MORE = "LOAD_MORE", r.RELOAD = "RELOAD", r.SEARCH = "SEARCH", r.SET_ERROR = "SET_ERROR", r.SET_LOADING = "SET_LOADING", r;
|
|
6
|
-
}(s || {});
|
|
6
|
+
})(s || {});
|
|
7
7
|
function a(r, e) {
|
|
8
8
|
switch (e.type) {
|
|
9
9
|
case s.LOAD_MORE:
|
|
@@ -63,8 +63,7 @@ function m(r, e) {
|
|
|
63
63
|
return E(r, e) || S(r, e);
|
|
64
64
|
}
|
|
65
65
|
function p(r, e) {
|
|
66
|
-
|
|
67
|
-
E(r, e) && e.abortController.abort(), S(r, e) && ((t = r.abortController) == null || t.abort());
|
|
66
|
+
E(r, e) && e.abortController.abort(), S(r, e) && r.abortController?.abort();
|
|
68
67
|
}
|
|
69
68
|
function h(r, e) {
|
|
70
69
|
return S(r, e);
|
package/dist/esm/lib/components/combobox-with-api-pagination/utils/use-controllable-state.js
CHANGED
|
@@ -1,40 +1,37 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as o from "react";
|
|
2
2
|
function a(e) {
|
|
3
|
-
const
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
}),
|
|
7
|
-
var t;
|
|
8
|
-
return (t = n.current) == null ? void 0 : t.call(n, ...o);
|
|
9
|
-
}, []);
|
|
3
|
+
const c = o.useRef(e);
|
|
4
|
+
return o.useEffect(() => {
|
|
5
|
+
c.current = e;
|
|
6
|
+
}), o.useMemo(() => (...t) => c.current?.(...t), []);
|
|
10
7
|
}
|
|
11
|
-
function
|
|
8
|
+
function v({
|
|
12
9
|
prop: e,
|
|
13
|
-
defaultProp:
|
|
14
|
-
onChange:
|
|
10
|
+
defaultProp: c,
|
|
11
|
+
onChange: t = () => {
|
|
15
12
|
}
|
|
16
13
|
}) {
|
|
17
|
-
const [
|
|
18
|
-
defaultProp:
|
|
19
|
-
onChange:
|
|
20
|
-
}), r = e !== void 0, i = r ? e :
|
|
14
|
+
const [n, s] = R({
|
|
15
|
+
defaultProp: c,
|
|
16
|
+
onChange: t
|
|
17
|
+
}), r = e !== void 0, i = r ? e : n, l = a(t), d = o.useCallback((u) => {
|
|
21
18
|
if (r) {
|
|
22
19
|
const f = typeof u == "function" ? u(e) : u;
|
|
23
20
|
f !== e && l(f);
|
|
24
21
|
} else
|
|
25
|
-
|
|
26
|
-
}, [r, e,
|
|
22
|
+
s(u);
|
|
23
|
+
}, [r, e, s, l]);
|
|
27
24
|
return [i, d];
|
|
28
25
|
}
|
|
29
|
-
function
|
|
26
|
+
function R({
|
|
30
27
|
defaultProp: e,
|
|
31
|
-
onChange:
|
|
28
|
+
onChange: c
|
|
32
29
|
}) {
|
|
33
|
-
const
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
}, [
|
|
30
|
+
const t = o.useState(e), [n] = t, s = o.useRef(n), r = a(c);
|
|
31
|
+
return o.useEffect(() => {
|
|
32
|
+
s.current !== n && (r(n), s.current = n);
|
|
33
|
+
}, [n, s, r]), t;
|
|
37
34
|
}
|
|
38
35
|
export {
|
|
39
|
-
|
|
36
|
+
v as useControllableState
|
|
40
37
|
};
|
package/dist/esm/lib/components/combobox-with-api-pagination/utils/use-intersection-observer.js
CHANGED
|
@@ -1,87 +1,85 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
const k = "0px",
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
root:
|
|
7
|
-
rootMargin:
|
|
8
|
-
threshold:
|
|
1
|
+
import { useState as y, useRef as R, useCallback as f } from "react";
|
|
2
|
+
const k = "0px", g = [0];
|
|
3
|
+
function C() {
|
|
4
|
+
const b = /* @__PURE__ */ new Map();
|
|
5
|
+
function a({
|
|
6
|
+
root: s,
|
|
7
|
+
rootMargin: t,
|
|
8
|
+
threshold: c
|
|
9
9
|
}) {
|
|
10
|
-
let r =
|
|
11
|
-
r || (r = /* @__PURE__ */ new Map(),
|
|
10
|
+
let r = b.get(s);
|
|
11
|
+
r || (r = /* @__PURE__ */ new Map(), b.set(s, r));
|
|
12
12
|
const i = JSON.stringify({
|
|
13
|
-
rootMargin:
|
|
14
|
-
threshold:
|
|
13
|
+
rootMargin: t,
|
|
14
|
+
threshold: c
|
|
15
15
|
});
|
|
16
|
-
let
|
|
17
|
-
if (!
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
observer: new IntersectionObserver((
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
t == null || t(v);
|
|
16
|
+
let n = r.get(i);
|
|
17
|
+
if (!n) {
|
|
18
|
+
const e = /* @__PURE__ */ new Map();
|
|
19
|
+
n = {
|
|
20
|
+
observer: new IntersectionObserver((O) => {
|
|
21
|
+
O.forEach((v) => {
|
|
22
|
+
e.get(v.target)?.(v);
|
|
24
23
|
});
|
|
25
24
|
}, {
|
|
26
|
-
root:
|
|
27
|
-
rootMargin:
|
|
28
|
-
threshold:
|
|
25
|
+
root: s,
|
|
26
|
+
rootMargin: t,
|
|
27
|
+
threshold: c
|
|
29
28
|
}),
|
|
30
|
-
entryCallbacks:
|
|
31
|
-
}, r.set(i,
|
|
29
|
+
entryCallbacks: e
|
|
30
|
+
}, r.set(i, n);
|
|
32
31
|
}
|
|
33
32
|
return {
|
|
34
|
-
observe: (
|
|
35
|
-
|
|
33
|
+
observe: (e, l) => {
|
|
34
|
+
n?.entryCallbacks.set(e, l), n?.observer.observe(e);
|
|
36
35
|
},
|
|
37
|
-
unobserve: (
|
|
38
|
-
|
|
36
|
+
unobserve: (e) => {
|
|
37
|
+
n?.entryCallbacks.delete(e), n?.observer.unobserve(e);
|
|
39
38
|
}
|
|
40
39
|
};
|
|
41
40
|
}
|
|
42
41
|
return {
|
|
43
|
-
getObserver:
|
|
42
|
+
getObserver: a
|
|
44
43
|
};
|
|
45
44
|
}
|
|
46
|
-
const
|
|
47
|
-
function
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
if (!
|
|
51
|
-
|
|
45
|
+
const E = C();
|
|
46
|
+
function p(b) {
|
|
47
|
+
const a = b?.rootMargin ?? k, s = b?.threshold ?? g, t = R(null), c = R(null), r = R(null), [i, n] = y(), e = f(() => {
|
|
48
|
+
const o = t.current;
|
|
49
|
+
if (!o) {
|
|
50
|
+
n(void 0);
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
54
|
-
const
|
|
55
|
-
root:
|
|
56
|
-
rootMargin:
|
|
57
|
-
threshold:
|
|
53
|
+
const u = E.getObserver({
|
|
54
|
+
root: c.current,
|
|
55
|
+
rootMargin: a,
|
|
56
|
+
threshold: s
|
|
58
57
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}), r.current =
|
|
62
|
-
}, [
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
}, []),
|
|
66
|
-
l(),
|
|
67
|
-
}, [
|
|
68
|
-
l(),
|
|
69
|
-
}, [
|
|
70
|
-
return [
|
|
58
|
+
u.observe(o, (h) => {
|
|
59
|
+
n(h);
|
|
60
|
+
}), r.current = u;
|
|
61
|
+
}, [a, s]), l = f(() => {
|
|
62
|
+
const o = r.current, u = t.current;
|
|
63
|
+
u && o?.unobserve(u), r.current = null;
|
|
64
|
+
}, []), O = f((o) => {
|
|
65
|
+
l(), t.current = o, e();
|
|
66
|
+
}, [e, l]), v = f((o) => {
|
|
67
|
+
l(), c.current = o, e();
|
|
68
|
+
}, [e, l]);
|
|
69
|
+
return [O, {
|
|
71
70
|
entry: i,
|
|
72
71
|
rootRef: v
|
|
73
72
|
}];
|
|
74
73
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
wasEverVisible: u
|
|
74
|
+
function w(b) {
|
|
75
|
+
const [a, s] = p(b), t = !!s.entry?.isIntersecting, [c, r] = y(t);
|
|
76
|
+
return t && !c && r(!0), [a, {
|
|
77
|
+
...s,
|
|
78
|
+
isVisible: t,
|
|
79
|
+
wasEverVisible: c
|
|
82
80
|
}];
|
|
83
81
|
}
|
|
84
82
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
C as createObserverCache,
|
|
84
|
+
w as useTrackVisibility
|
|
87
85
|
};
|