@adam-milo/ui 1.0.22 → 1.0.24
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.cjs +1 -1
- package/dist/index.js +18 -9
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +53 -59
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +50 -104
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +108 -76
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +77 -26
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +22 -462
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +466 -109
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +111 -30
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +42 -12
- package/dist/index18.cjs +1 -0
- package/dist/index18.js +14 -0
- package/dist/index2.cjs +1 -1
- package/dist/index2.js +1 -1
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +20 -299
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +298 -13
- package/dist/index22.cjs +1 -0
- package/dist/index22.js +16 -0
- package/dist/index25.cjs +1 -0
- package/dist/index25.js +1193 -0
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +2 -2
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +7 -19
- package/dist/index36.cjs +1 -0
- package/dist/index36.js +21 -0
- package/dist/index38.cjs +1 -0
- package/dist/index38.js +6 -0
- package/dist/index39.cjs +1 -0
- package/dist/index39.js +11 -0
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +1 -1
- package/dist/index40.cjs +1 -0
- package/dist/index40.js +70 -0
- package/dist/index41.cjs +1 -0
- package/dist/index41.js +39 -0
- package/dist/index42.cjs +1 -0
- package/dist/index42.js +64 -0
- package/dist/index43.cjs +1 -0
- package/dist/index43.js +10 -0
- package/dist/index44.cjs +1 -0
- package/dist/index44.js +212 -0
- package/dist/index45.cjs +1 -0
- package/dist/index45.js +29 -0
- package/dist/index46.cjs +1 -0
- package/dist/index46.js +208 -0
- package/dist/index47.cjs +1 -0
- package/dist/index47.js +14 -0
- package/dist/index48.cjs +1 -0
- package/dist/index48.js +293 -0
- package/dist/index49.cjs +1 -0
- package/dist/index49.js +18 -0
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +1 -1
- package/dist/index50.cjs +1 -0
- package/dist/index50.js +43 -0
- package/dist/index51.cjs +1 -0
- package/dist/index51.js +89 -0
- package/dist/index52.cjs +1 -0
- package/dist/index52.js +14 -0
- package/dist/index53.cjs +1 -0
- package/dist/index53.js +71 -0
- package/dist/index54.cjs +1 -0
- package/dist/index54.js +6 -0
- package/dist/index55.cjs +1 -0
- package/dist/index55.js +14 -0
- package/dist/index56.cjs +1 -0
- package/dist/index56.js +34 -0
- package/dist/index57.cjs +1 -0
- package/dist/index57.js +122 -0
- package/dist/index58.cjs +1 -0
- package/dist/index58.js +11 -0
- package/dist/index59.cjs +1 -0
- package/dist/index59.js +17 -0
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +2 -2
- package/dist/index60.cjs +1 -0
- package/dist/index60.js +297 -0
- package/dist/index61.cjs +1 -0
- package/dist/index61.js +25 -0
- package/dist/index62.cjs +1 -0
- package/dist/index62.js +39 -0
- package/dist/index63.cjs +1 -0
- package/dist/index63.js +625 -0
- package/dist/index64.cjs +1 -0
- package/dist/index64.js +39 -0
- package/dist/index65.cjs +1 -0
- package/dist/index65.js +38 -0
- package/dist/index66.cjs +1 -0
- package/dist/index66.js +7 -0
- package/dist/index67.cjs +1 -0
- package/dist/index67.js +10 -0
- package/dist/index68.cjs +1 -0
- package/dist/index68.js +5 -0
- package/dist/index69.cjs +1 -0
- package/dist/index69.js +35 -0
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +1 -1
- package/dist/index70.cjs +1 -0
- package/dist/index70.js +180 -0
- package/dist/index71.cjs +1 -0
- package/dist/index71.js +21 -0
- package/dist/index72.cjs +1 -0
- package/dist/index72.js +721 -0
- package/dist/index73.cjs +1 -0
- package/dist/index73.js +154 -0
- package/dist/index74.cjs +1 -0
- package/dist/index74.js +173 -0
- package/dist/index75.cjs +1 -0
- package/dist/index75.js +88 -0
- package/dist/index76.cjs +1 -0
- package/dist/index76.js +47 -0
- package/dist/index77.cjs +1 -0
- package/dist/index77.js +13 -0
- package/dist/index78.cjs +1 -0
- package/dist/index78.js +19 -0
- package/dist/index79.cjs +1 -0
- package/dist/index79.js +102 -0
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +1 -1
- package/dist/index80.cjs +1 -0
- package/dist/index80.js +11 -0
- package/dist/index81.cjs +1 -0
- package/dist/index81.js +29 -0
- package/dist/index82.cjs +1 -0
- package/dist/index82.js +16 -0
- package/dist/index83.cjs +1 -0
- package/dist/index83.js +48 -0
- package/dist/index84.cjs +1 -0
- package/dist/index84.js +9 -0
- package/dist/index85.cjs +1 -0
- package/dist/index85.js +37 -0
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +224 -35
- package/dist/src/components/forms/select/Select.component.d.ts +100 -0
- package/dist/src/components/forms/select/Select.component.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -1
- package/dist/index19.cjs +0 -1
- package/dist/index19.js +0 -22
- package/dist/index30.cjs +0 -1
- package/dist/index30.js +0 -9
package/dist/index60.js
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { computePosition, offset as offset$1, shift as shift$1, flip as flip$1, size as size$1, hide as hide$1, limitShift as limitShift$1, arrow as arrow$2 } from "./index63.js";
|
|
2
|
+
import { autoUpdate, platform } from "./index63.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useLayoutEffect } from "react";
|
|
5
|
+
import * as ReactDOM from "react-dom";
|
|
6
|
+
var isClient = typeof document !== "undefined";
|
|
7
|
+
var noop = function noop2() {
|
|
8
|
+
};
|
|
9
|
+
var index = isClient ? useLayoutEffect : noop;
|
|
10
|
+
function deepEqual(a, b) {
|
|
11
|
+
if (a === b) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
if (typeof a !== typeof b) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (typeof a === "function" && a.toString() === b.toString()) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
let length;
|
|
21
|
+
let i;
|
|
22
|
+
let keys;
|
|
23
|
+
if (a && b && typeof a === "object") {
|
|
24
|
+
if (Array.isArray(a)) {
|
|
25
|
+
length = a.length;
|
|
26
|
+
if (length !== b.length) return false;
|
|
27
|
+
for (i = length; i-- !== 0; ) {
|
|
28
|
+
if (!deepEqual(a[i], b[i])) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
keys = Object.keys(a);
|
|
35
|
+
length = keys.length;
|
|
36
|
+
if (length !== Object.keys(b).length) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
for (i = length; i-- !== 0; ) {
|
|
40
|
+
if (!{}.hasOwnProperty.call(b, keys[i])) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
for (i = length; i-- !== 0; ) {
|
|
45
|
+
const key = keys[i];
|
|
46
|
+
if (key === "_owner" && a.$$typeof) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (!deepEqual(a[key], b[key])) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return a !== a && b !== b;
|
|
56
|
+
}
|
|
57
|
+
function getDPR(element) {
|
|
58
|
+
if (typeof window === "undefined") {
|
|
59
|
+
return 1;
|
|
60
|
+
}
|
|
61
|
+
const win = element.ownerDocument.defaultView || window;
|
|
62
|
+
return win.devicePixelRatio || 1;
|
|
63
|
+
}
|
|
64
|
+
function roundByDPR(element, value) {
|
|
65
|
+
const dpr = getDPR(element);
|
|
66
|
+
return Math.round(value * dpr) / dpr;
|
|
67
|
+
}
|
|
68
|
+
function useLatestRef(value) {
|
|
69
|
+
const ref = React.useRef(value);
|
|
70
|
+
index(() => {
|
|
71
|
+
ref.current = value;
|
|
72
|
+
});
|
|
73
|
+
return ref;
|
|
74
|
+
}
|
|
75
|
+
function useFloating(options) {
|
|
76
|
+
if (options === void 0) {
|
|
77
|
+
options = {};
|
|
78
|
+
}
|
|
79
|
+
const {
|
|
80
|
+
placement = "bottom",
|
|
81
|
+
strategy = "absolute",
|
|
82
|
+
middleware = [],
|
|
83
|
+
platform: platform2,
|
|
84
|
+
elements: {
|
|
85
|
+
reference: externalReference,
|
|
86
|
+
floating: externalFloating
|
|
87
|
+
} = {},
|
|
88
|
+
transform = true,
|
|
89
|
+
whileElementsMounted,
|
|
90
|
+
open
|
|
91
|
+
} = options;
|
|
92
|
+
const [data, setData] = React.useState({
|
|
93
|
+
x: 0,
|
|
94
|
+
y: 0,
|
|
95
|
+
strategy,
|
|
96
|
+
placement,
|
|
97
|
+
middlewareData: {},
|
|
98
|
+
isPositioned: false
|
|
99
|
+
});
|
|
100
|
+
const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
|
|
101
|
+
if (!deepEqual(latestMiddleware, middleware)) {
|
|
102
|
+
setLatestMiddleware(middleware);
|
|
103
|
+
}
|
|
104
|
+
const [_reference, _setReference] = React.useState(null);
|
|
105
|
+
const [_floating, _setFloating] = React.useState(null);
|
|
106
|
+
const setReference = React.useCallback((node) => {
|
|
107
|
+
if (node !== referenceRef.current) {
|
|
108
|
+
referenceRef.current = node;
|
|
109
|
+
_setReference(node);
|
|
110
|
+
}
|
|
111
|
+
}, []);
|
|
112
|
+
const setFloating = React.useCallback((node) => {
|
|
113
|
+
if (node !== floatingRef.current) {
|
|
114
|
+
floatingRef.current = node;
|
|
115
|
+
_setFloating(node);
|
|
116
|
+
}
|
|
117
|
+
}, []);
|
|
118
|
+
const referenceEl = externalReference || _reference;
|
|
119
|
+
const floatingEl = externalFloating || _floating;
|
|
120
|
+
const referenceRef = React.useRef(null);
|
|
121
|
+
const floatingRef = React.useRef(null);
|
|
122
|
+
const dataRef = React.useRef(data);
|
|
123
|
+
const hasWhileElementsMounted = whileElementsMounted != null;
|
|
124
|
+
const whileElementsMountedRef = useLatestRef(whileElementsMounted);
|
|
125
|
+
const platformRef = useLatestRef(platform2);
|
|
126
|
+
const openRef = useLatestRef(open);
|
|
127
|
+
const update = React.useCallback(() => {
|
|
128
|
+
if (!referenceRef.current || !floatingRef.current) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const config = {
|
|
132
|
+
placement,
|
|
133
|
+
strategy,
|
|
134
|
+
middleware: latestMiddleware
|
|
135
|
+
};
|
|
136
|
+
if (platformRef.current) {
|
|
137
|
+
config.platform = platformRef.current;
|
|
138
|
+
}
|
|
139
|
+
computePosition(referenceRef.current, floatingRef.current, config).then((data2) => {
|
|
140
|
+
const fullData = {
|
|
141
|
+
...data2,
|
|
142
|
+
// The floating element's position may be recomputed while it's closed
|
|
143
|
+
// but still mounted (such as when transitioning out). To ensure
|
|
144
|
+
// `isPositioned` will be `false` initially on the next open, avoid
|
|
145
|
+
// setting it to `true` when `open === false` (must be specified).
|
|
146
|
+
isPositioned: openRef.current !== false
|
|
147
|
+
};
|
|
148
|
+
if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
|
|
149
|
+
dataRef.current = fullData;
|
|
150
|
+
ReactDOM.flushSync(() => {
|
|
151
|
+
setData(fullData);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}, [latestMiddleware, placement, strategy, platformRef, openRef]);
|
|
156
|
+
index(() => {
|
|
157
|
+
if (open === false && dataRef.current.isPositioned) {
|
|
158
|
+
dataRef.current.isPositioned = false;
|
|
159
|
+
setData((data2) => ({
|
|
160
|
+
...data2,
|
|
161
|
+
isPositioned: false
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
}, [open]);
|
|
165
|
+
const isMountedRef = React.useRef(false);
|
|
166
|
+
index(() => {
|
|
167
|
+
isMountedRef.current = true;
|
|
168
|
+
return () => {
|
|
169
|
+
isMountedRef.current = false;
|
|
170
|
+
};
|
|
171
|
+
}, []);
|
|
172
|
+
index(() => {
|
|
173
|
+
if (referenceEl) referenceRef.current = referenceEl;
|
|
174
|
+
if (floatingEl) floatingRef.current = floatingEl;
|
|
175
|
+
if (referenceEl && floatingEl) {
|
|
176
|
+
if (whileElementsMountedRef.current) {
|
|
177
|
+
return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
|
178
|
+
}
|
|
179
|
+
update();
|
|
180
|
+
}
|
|
181
|
+
}, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
|
|
182
|
+
const refs = React.useMemo(() => ({
|
|
183
|
+
reference: referenceRef,
|
|
184
|
+
floating: floatingRef,
|
|
185
|
+
setReference,
|
|
186
|
+
setFloating
|
|
187
|
+
}), [setReference, setFloating]);
|
|
188
|
+
const elements = React.useMemo(() => ({
|
|
189
|
+
reference: referenceEl,
|
|
190
|
+
floating: floatingEl
|
|
191
|
+
}), [referenceEl, floatingEl]);
|
|
192
|
+
const floatingStyles = React.useMemo(() => {
|
|
193
|
+
const initialStyles = {
|
|
194
|
+
position: strategy,
|
|
195
|
+
left: 0,
|
|
196
|
+
top: 0
|
|
197
|
+
};
|
|
198
|
+
if (!elements.floating) {
|
|
199
|
+
return initialStyles;
|
|
200
|
+
}
|
|
201
|
+
const x = roundByDPR(elements.floating, data.x);
|
|
202
|
+
const y = roundByDPR(elements.floating, data.y);
|
|
203
|
+
if (transform) {
|
|
204
|
+
return {
|
|
205
|
+
...initialStyles,
|
|
206
|
+
transform: "translate(" + x + "px, " + y + "px)",
|
|
207
|
+
...getDPR(elements.floating) >= 1.5 && {
|
|
208
|
+
willChange: "transform"
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
position: strategy,
|
|
214
|
+
left: x,
|
|
215
|
+
top: y
|
|
216
|
+
};
|
|
217
|
+
}, [strategy, transform, elements.floating, data.x, data.y]);
|
|
218
|
+
return React.useMemo(() => ({
|
|
219
|
+
...data,
|
|
220
|
+
update,
|
|
221
|
+
refs,
|
|
222
|
+
elements,
|
|
223
|
+
floatingStyles
|
|
224
|
+
}), [data, update, refs, elements, floatingStyles]);
|
|
225
|
+
}
|
|
226
|
+
const arrow$1 = (options) => {
|
|
227
|
+
function isRef(value) {
|
|
228
|
+
return {}.hasOwnProperty.call(value, "current");
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
name: "arrow",
|
|
232
|
+
options,
|
|
233
|
+
fn(state) {
|
|
234
|
+
const {
|
|
235
|
+
element,
|
|
236
|
+
padding
|
|
237
|
+
} = typeof options === "function" ? options(state) : options;
|
|
238
|
+
if (element && isRef(element)) {
|
|
239
|
+
if (element.current != null) {
|
|
240
|
+
return arrow$2({
|
|
241
|
+
element: element.current,
|
|
242
|
+
padding
|
|
243
|
+
}).fn(state);
|
|
244
|
+
}
|
|
245
|
+
return {};
|
|
246
|
+
}
|
|
247
|
+
if (element) {
|
|
248
|
+
return arrow$2({
|
|
249
|
+
element,
|
|
250
|
+
padding
|
|
251
|
+
}).fn(state);
|
|
252
|
+
}
|
|
253
|
+
return {};
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
const offset = (options, deps) => ({
|
|
258
|
+
...offset$1(options),
|
|
259
|
+
options: [options, deps]
|
|
260
|
+
});
|
|
261
|
+
const shift = (options, deps) => ({
|
|
262
|
+
...shift$1(options),
|
|
263
|
+
options: [options, deps]
|
|
264
|
+
});
|
|
265
|
+
const limitShift = (options, deps) => ({
|
|
266
|
+
...limitShift$1(options),
|
|
267
|
+
options: [options, deps]
|
|
268
|
+
});
|
|
269
|
+
const flip = (options, deps) => ({
|
|
270
|
+
...flip$1(options),
|
|
271
|
+
options: [options, deps]
|
|
272
|
+
});
|
|
273
|
+
const size = (options, deps) => ({
|
|
274
|
+
...size$1(options),
|
|
275
|
+
options: [options, deps]
|
|
276
|
+
});
|
|
277
|
+
const hide = (options, deps) => ({
|
|
278
|
+
...hide$1(options),
|
|
279
|
+
options: [options, deps]
|
|
280
|
+
});
|
|
281
|
+
const arrow = (options, deps) => ({
|
|
282
|
+
...arrow$1(options),
|
|
283
|
+
options: [options, deps]
|
|
284
|
+
});
|
|
285
|
+
export {
|
|
286
|
+
arrow,
|
|
287
|
+
autoUpdate,
|
|
288
|
+
computePosition,
|
|
289
|
+
flip,
|
|
290
|
+
hide,
|
|
291
|
+
limitShift,
|
|
292
|
+
offset,
|
|
293
|
+
platform,
|
|
294
|
+
shift,
|
|
295
|
+
size,
|
|
296
|
+
useFloating
|
|
297
|
+
};
|
package/dist/index61.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("./index50.cjs"),t=require("react/jsx-runtime");function o(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const t in e)if("default"!==t){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:()=>e[t]})}return r.default=e,Object.freeze(r)}var i=o(e).forwardRef((e,o)=>{const{children:i,width:n=10,height:s=5,...c}=e;return t.jsx(r.Primitive.svg,{...c,ref:o,width:n,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?i:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});i.displayName="Arrow";var n=i;exports.Arrow=i,exports.Root=n;
|
package/dist/index61.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Primitive } from "./index50.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var NAME = "Arrow";
|
|
5
|
+
var Arrow = React.forwardRef((props, forwardedRef) => {
|
|
6
|
+
const { children, width = 10, height = 5, ...arrowProps } = props;
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
Primitive.svg,
|
|
9
|
+
{
|
|
10
|
+
...arrowProps,
|
|
11
|
+
ref: forwardedRef,
|
|
12
|
+
width,
|
|
13
|
+
height,
|
|
14
|
+
viewBox: "0 0 30 10",
|
|
15
|
+
preserveAspectRatio: "none",
|
|
16
|
+
children: props.asChild ? children : /* @__PURE__ */ jsx("polygon", { points: "0,0 30,0 15,10" })
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
Arrow.displayName = NAME;
|
|
21
|
+
var Root = Arrow;
|
|
22
|
+
export {
|
|
23
|
+
Arrow,
|
|
24
|
+
Root
|
|
25
|
+
};
|
package/dist/index62.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("./index54.cjs");function r(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}const o=r(e);exports.useSize=function(e){const[r,i]=o.useState(void 0);return t.useLayoutEffect(()=>{if(e){i({width:e.offsetWidth,height:e.offsetHeight});const t=new ResizeObserver(t=>{if(!Array.isArray(t))return;if(!t.length)return;const r=t[0];let o,n;if("borderBoxSize"in r){const e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;o=t.inlineSize,n=t.blockSize}else o=e.offsetWidth,n=e.offsetHeight;i({width:o,height:n})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}i(void 0)},[e]),r};
|
package/dist/index62.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useLayoutEffect as useLayoutEffect2 } from "./index54.js";
|
|
3
|
+
function useSize(element) {
|
|
4
|
+
const [size, setSize] = React.useState(void 0);
|
|
5
|
+
useLayoutEffect2(() => {
|
|
6
|
+
if (element) {
|
|
7
|
+
setSize({ width: element.offsetWidth, height: element.offsetHeight });
|
|
8
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
9
|
+
if (!Array.isArray(entries)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!entries.length) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const entry = entries[0];
|
|
16
|
+
let width;
|
|
17
|
+
let height;
|
|
18
|
+
if ("borderBoxSize" in entry) {
|
|
19
|
+
const borderSizeEntry = entry["borderBoxSize"];
|
|
20
|
+
const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
|
|
21
|
+
width = borderSize["inlineSize"];
|
|
22
|
+
height = borderSize["blockSize"];
|
|
23
|
+
} else {
|
|
24
|
+
width = element.offsetWidth;
|
|
25
|
+
height = element.offsetHeight;
|
|
26
|
+
}
|
|
27
|
+
setSize({ width, height });
|
|
28
|
+
});
|
|
29
|
+
resizeObserver.observe(element, { box: "border-box" });
|
|
30
|
+
return () => resizeObserver.unobserve(element);
|
|
31
|
+
} else {
|
|
32
|
+
setSize(void 0);
|
|
33
|
+
}
|
|
34
|
+
}, [element]);
|
|
35
|
+
return size;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
useSize
|
|
39
|
+
};
|
package/dist/index63.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index72.cjs"),e=require("./index73.cjs"),n=require("./index74.cjs");function o(t){const o=n.getComputedStyle(t);let i=parseFloat(o.width)||0,r=parseFloat(o.height)||0;const l=n.isHTMLElement(t),s=l?t.offsetWidth:i,c=l?t.offsetHeight:r,f=e.round(i)!==s||e.round(r)!==c;return f&&(i=s,r=c),{width:i,height:r,$:f}}function i(t){return n.isElement(t)?t:t.contextElement}function r(t){const r=i(t);if(!n.isHTMLElement(r))return e.createCoords(1);const l=r.getBoundingClientRect(),{width:s,height:c,$:f}=o(r);let u=(f?e.round(l.width):l.width)/s,a=(f?e.round(l.height):l.height)/c;return u&&Number.isFinite(u)||(u=1),a&&Number.isFinite(a)||(a=1),{x:u,y:a}}const l=e.createCoords(0);function s(t){const e=n.getWindow(t);return n.isWebKit()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:l}function c(t,o,l,c){void 0===o&&(o=!1),void 0===l&&(l=!1);const f=t.getBoundingClientRect(),u=i(t);let a=e.createCoords(1);o&&(c?n.isElement(c)&&(a=r(c)):a=r(t));const d=function(t,e,o){return void 0===e&&(e=!1),!(!o||e&&o!==n.getWindow(t))&&e}(u,l,c)?s(u):e.createCoords(0);let g=(f.left+d.x)/a.x,h=(f.top+d.y)/a.y,m=f.width/a.x,p=f.height/a.y;if(u){const t=n.getWindow(u),e=c&&n.isElement(c)?n.getWindow(c):c;let o=t,i=n.getFrameElement(o);for(;i&&c&&e!==o;){const t=r(i),e=i.getBoundingClientRect(),l=n.getComputedStyle(i),s=e.left+(i.clientLeft+parseFloat(l.paddingLeft))*t.x,c=e.top+(i.clientTop+parseFloat(l.paddingTop))*t.y;g*=t.x,h*=t.y,m*=t.x,p*=t.y,g+=s,h+=c,o=n.getWindow(i),i=n.getFrameElement(o)}}return e.rectToClientRect({width:m,height:p,x:g,y:h})}function f(t,e){const o=n.getNodeScroll(t).scrollLeft;return e?e.left+o:c(n.getDocumentElement(t)).left+o}function u(t,e){const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-f(t,n),y:n.top+e.scrollTop}}const a=new Set(["absolute","fixed"]);function d(t,o,i){let l;if("viewport"===o)l=function(t,e){const o=n.getWindow(t),i=n.getDocumentElement(t),r=o.visualViewport;let l=i.clientWidth,s=i.clientHeight,c=0,u=0;if(r){l=r.width,s=r.height;const t=n.isWebKit();(!t||t&&"fixed"===e)&&(c=r.offsetLeft,u=r.offsetTop)}const a=f(i);if(a<=0){const t=i.ownerDocument,e=t.body,n=getComputedStyle(e),o="CSS1Compat"===t.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,r=Math.abs(i.clientWidth-e.clientWidth-o);r<=25&&(l-=r)}else a<=25&&(l+=a);return{width:l,height:s,x:c,y:u}}(t,i);else if("document"===o)l=function(t){const o=n.getDocumentElement(t),i=n.getNodeScroll(t),r=t.ownerDocument.body,l=e.max(o.scrollWidth,o.clientWidth,r.scrollWidth,r.clientWidth),s=e.max(o.scrollHeight,o.clientHeight,r.scrollHeight,r.clientHeight);let c=-i.scrollLeft+f(t);const u=-i.scrollTop;return"rtl"===n.getComputedStyle(r).direction&&(c+=e.max(o.clientWidth,r.clientWidth)-l),{width:l,height:s,x:c,y:u}}(n.getDocumentElement(t));else if(n.isElement(o))l=function(t,o){const i=c(t,!0,"fixed"===o),l=i.top+t.clientTop,s=i.left+t.clientLeft,f=n.isHTMLElement(t)?r(t):e.createCoords(1);return{width:t.clientWidth*f.x,height:t.clientHeight*f.y,x:s*f.x,y:l*f.y}}(o,i);else{const e=s(t);l={x:o.x-e.x,y:o.y-e.y,width:o.width,height:o.height}}return e.rectToClientRect(l)}function g(t,e){const o=n.getParentNode(t);return!(o===e||!n.isElement(o)||n.isLastTraversableNode(o))&&("fixed"===n.getComputedStyle(o).position||g(o,e))}function h(t,o,i){const r=n.isHTMLElement(o),l=n.getDocumentElement(o),s="fixed"===i,a=c(t,!0,s,o);let d={scrollLeft:0,scrollTop:0};const g=e.createCoords(0);function h(){g.x=f(l)}if(r||!r&&!s)if(("body"!==n.getNodeName(o)||n.isOverflowElement(l))&&(d=n.getNodeScroll(o)),r){const t=c(o,!0,s,o);g.x=t.x+o.clientLeft,g.y=t.y+o.clientTop}else l&&h();s&&!r&&l&&h();const m=!l||r||s?e.createCoords(0):u(l,d);return{x:a.left+d.scrollLeft-g.x-m.x,y:a.top+d.scrollTop-g.y-m.y,width:a.width,height:a.height}}function m(t){return"static"===n.getComputedStyle(t).position}function p(t,e){if(!n.isHTMLElement(t)||"fixed"===n.getComputedStyle(t).position)return null;if(e)return e(t);let o=t.offsetParent;return n.getDocumentElement(t)===o&&(o=o.ownerDocument.body),o}function x(t,e){const o=n.getWindow(t);if(n.isTopLayer(t))return o;if(!n.isHTMLElement(t)){let e=n.getParentNode(t);for(;e&&!n.isLastTraversableNode(e);){if(n.isElement(e)&&!m(e))return e;e=n.getParentNode(e)}return o}let i=p(t,e);for(;i&&n.isTableElement(i)&&m(i);)i=p(i,e);return i&&n.isLastTraversableNode(i)&&m(i)&&!n.isContainingBlock(i)?o:i||n.getContainingBlock(t)||o}const y={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:o,rect:i,offsetParent:l,strategy:s}=t;const f="fixed"===s,a=n.getDocumentElement(l),d=!!o&&n.isTopLayer(o.floating);if(l===a||d&&f)return i;let g={scrollLeft:0,scrollTop:0},h=e.createCoords(1);const m=e.createCoords(0),p=n.isHTMLElement(l);if((p||!p&&!f)&&(("body"!==n.getNodeName(l)||n.isOverflowElement(a))&&(g=n.getNodeScroll(l)),n.isHTMLElement(l))){const t=c(l);h=r(l),m.x=t.x+l.clientLeft,m.y=t.y+l.clientTop}const x=!a||p||f?e.createCoords(0):u(a,g);return{width:i.width*h.x,height:i.height*h.y,x:i.x*h.x-g.scrollLeft*h.x+m.x+x.x,y:i.y*h.y-g.scrollTop*h.y+m.y+x.y}},getDocumentElement:n.getDocumentElement,getClippingRect:function(t){let{element:o,boundary:i,rootBoundary:r,strategy:l}=t;const s=[..."clippingAncestors"===i?n.isTopLayer(o)?[]:function(t,e){const o=e.get(t);if(o)return o;let i=n.getOverflowAncestors(t,[],!1).filter(t=>n.isElement(t)&&"body"!==n.getNodeName(t)),r=null;const l="fixed"===n.getComputedStyle(t).position;let s=l?n.getParentNode(t):t;for(;n.isElement(s)&&!n.isLastTraversableNode(s);){const e=n.getComputedStyle(s),o=n.isContainingBlock(s);o||"fixed"!==e.position||(r=null),(l?!o&&!r:!o&&"static"===e.position&&r&&a.has(r.position)||n.isOverflowElement(s)&&!o&&g(t,s))?i=i.filter(t=>t!==s):r=e,s=n.getParentNode(s)}return e.set(t,i),i}(o,this._c):[].concat(i),r],c=s[0],f=s.reduce((t,n)=>{const i=d(o,n,l);return t.top=e.max(i.top,t.top),t.right=e.min(i.right,t.right),t.bottom=e.min(i.bottom,t.bottom),t.left=e.max(i.left,t.left),t},d(o,c,l));return{width:f.right-f.left,height:f.bottom-f.top,x:f.left,y:f.top}},getOffsetParent:x,getElementRects:async function(t){const e=this.getOffsetParent||x,n=this.getDimensions,o=await n(t.floating);return{reference:h(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=o(t);return{width:e,height:n}},getScale:r,isElement:n.isElement,isRTL:function(t){return"rtl"===n.getComputedStyle(t).direction}};function w(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}const v=t.offset,E=t.shift,C=t.flip,T=t.size,L=t.hide,b=t.arrow,S=t.limitShift;exports.getOverflowAncestors=n.getOverflowAncestors,exports.arrow=b,exports.autoUpdate=function(t,o,r,l){void 0===l&&(l={});const{ancestorScroll:s=!0,ancestorResize:f=!0,elementResize:u="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:d=!1}=l,g=i(t),h=s||f?[...g?n.getOverflowAncestors(g):[],...n.getOverflowAncestors(o)]:[];h.forEach(t=>{s&&t.addEventListener("scroll",r,{passive:!0}),f&&t.addEventListener("resize",r)});const m=g&&a?function(t,o){let i,r=null;const l=n.getDocumentElement(t);function s(){var t;clearTimeout(i),null==(t=r)||t.disconnect(),r=null}return function n(c,f){void 0===c&&(c=!1),void 0===f&&(f=1),s();const u=t.getBoundingClientRect(),{left:a,top:d,width:g,height:h}=u;if(c||o(),!g||!h)return;const m={rootMargin:-e.floor(d)+"px "+-e.floor(l.clientWidth-(a+g))+"px "+-e.floor(l.clientHeight-(d+h))+"px "+-e.floor(a)+"px",threshold:e.max(0,e.min(1,f))||1};let p=!0;function x(e){const o=e[0].intersectionRatio;if(o!==f){if(!p)return n();o?n(!1,o):i=setTimeout(()=>{n(!1,1e-7)},1e3)}1!==o||w(u,t.getBoundingClientRect())||n(),p=!1}try{r=new IntersectionObserver(x,{...m,root:l.ownerDocument})}catch(y){r=new IntersectionObserver(x,m)}r.observe(t)}(!0),s}(g,r):null;let p,x=-1,y=null;u&&(y=new ResizeObserver(t=>{let[e]=t;e&&e.target===g&&y&&(y.unobserve(o),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var t;null==(t=y)||t.observe(o)})),r()}),g&&!d&&y.observe(g),y.observe(o));let v=d?c(t):null;return d&&function e(){const n=c(t);v&&!w(v,n)&&r();v=n,p=requestAnimationFrame(e)}(),r(),()=>{var t;h.forEach(t=>{s&&t.removeEventListener("scroll",r),f&&t.removeEventListener("resize",r)}),null==m||m(),null==(t=y)||t.disconnect(),y=null,d&&cancelAnimationFrame(p)}},exports.computePosition=(e,n,o)=>{const i=new Map,r={platform:y,...o},l={...r.platform,_c:i};return t.computePosition(e,n,{...r,platform:l})},exports.flip=C,exports.hide=L,exports.limitShift=S,exports.offset=v,exports.platform=y,exports.shift=E,exports.size=T;
|