react-proportion-slider 0.9.0 → 0.9.1
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/components/DynamicChildPositioner.d.ts +12 -0
- package/dist/components/Proportion.d.ts +11 -0
- package/dist/components/ProportionSlider.d.ts +20 -0
- package/dist/components/SliderKnob.d.ts +9 -0
- package/dist/index.d.ts +3 -0
- package/dist/react-proportion-slider.es.js +678 -0
- package/dist/react-proportion-slider.es.js.map +1 -0
- package/dist/react-proportion-slider.umd.js +32 -0
- package/dist/react-proportion-slider.umd.js.map +1 -0
- package/package.json +22 -4
- package/dev/App.css +0 -13
- package/dev/App.tsx +0 -49
- package/dev/index.html +0 -17
- package/dev/main.tsx +0 -9
- package/eslint.config.js +0 -28
- package/src/components/DynamicChildPositioner.tsx +0 -143
- package/src/components/Proportion.tsx +0 -55
- package/src/components/ProportionSlider.tsx +0 -112
- package/src/components/SliderKnob.tsx +0 -68
- package/src/index.ts +0 -1
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.app.json +0 -26
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -24
- package/vite.config.ts +0 -26
@@ -0,0 +1,678 @@
|
|
1
|
+
import Pe, { useRef as C, useEffect as je, useState as Me, useMemo as xe, useCallback as ae } from "react";
|
2
|
+
var q = { exports: {} }, H = {};
|
3
|
+
/**
|
4
|
+
* @license React
|
5
|
+
* react-jsx-runtime.production.js
|
6
|
+
*
|
7
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
8
|
+
*
|
9
|
+
* This source code is licensed under the MIT license found in the
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
11
|
+
*/
|
12
|
+
var Re;
|
13
|
+
function Ye() {
|
14
|
+
if (Re) return H;
|
15
|
+
Re = 1;
|
16
|
+
var a = Symbol.for("react.transitional.element"), g = Symbol.for("react.fragment");
|
17
|
+
function c(E, u, f) {
|
18
|
+
var i = null;
|
19
|
+
if (f !== void 0 && (i = "" + f), u.key !== void 0 && (i = "" + u.key), "key" in u) {
|
20
|
+
f = {};
|
21
|
+
for (var l in u)
|
22
|
+
l !== "key" && (f[l] = u[l]);
|
23
|
+
} else f = u;
|
24
|
+
return u = f.ref, {
|
25
|
+
$$typeof: a,
|
26
|
+
type: E,
|
27
|
+
key: i,
|
28
|
+
ref: u !== void 0 ? u : null,
|
29
|
+
props: f
|
30
|
+
};
|
31
|
+
}
|
32
|
+
return H.Fragment = g, H.jsx = c, H.jsxs = c, H;
|
33
|
+
}
|
34
|
+
var U = {};
|
35
|
+
/**
|
36
|
+
* @license React
|
37
|
+
* react-jsx-runtime.development.js
|
38
|
+
*
|
39
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
40
|
+
*
|
41
|
+
* This source code is licensed under the MIT license found in the
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
43
|
+
*/
|
44
|
+
var _e;
|
45
|
+
function We() {
|
46
|
+
return _e || (_e = 1, process.env.NODE_ENV !== "production" && function() {
|
47
|
+
function a(e) {
|
48
|
+
if (e == null) return null;
|
49
|
+
if (typeof e == "function")
|
50
|
+
return e.$$typeof === ke ? null : e.displayName || e.name || null;
|
51
|
+
if (typeof e == "string") return e;
|
52
|
+
switch (e) {
|
53
|
+
case G:
|
54
|
+
return "Fragment";
|
55
|
+
case J:
|
56
|
+
return "Portal";
|
57
|
+
case ue:
|
58
|
+
return "Profiler";
|
59
|
+
case X:
|
60
|
+
return "StrictMode";
|
61
|
+
case K:
|
62
|
+
return "Suspense";
|
63
|
+
case Q:
|
64
|
+
return "SuspenseList";
|
65
|
+
}
|
66
|
+
if (typeof e == "object")
|
67
|
+
switch (typeof e.tag == "number" && console.error(
|
68
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
69
|
+
), e.$$typeof) {
|
70
|
+
case se:
|
71
|
+
return (e.displayName || "Context") + ".Provider";
|
72
|
+
case le:
|
73
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
74
|
+
case Z:
|
75
|
+
var r = e.render;
|
76
|
+
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
77
|
+
case D:
|
78
|
+
return r = e.displayName || null, r !== null ? r : a(e.type) || "Memo";
|
79
|
+
case ee:
|
80
|
+
r = e._payload, e = e._init;
|
81
|
+
try {
|
82
|
+
return a(e(r));
|
83
|
+
} catch {
|
84
|
+
}
|
85
|
+
}
|
86
|
+
return null;
|
87
|
+
}
|
88
|
+
function g(e) {
|
89
|
+
return "" + e;
|
90
|
+
}
|
91
|
+
function c(e) {
|
92
|
+
try {
|
93
|
+
g(e);
|
94
|
+
var r = !1;
|
95
|
+
} catch {
|
96
|
+
r = !0;
|
97
|
+
}
|
98
|
+
if (r) {
|
99
|
+
r = console;
|
100
|
+
var t = r.error, o = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
101
|
+
return t.call(
|
102
|
+
r,
|
103
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
104
|
+
o
|
105
|
+
), g(e);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
function E() {
|
109
|
+
}
|
110
|
+
function u() {
|
111
|
+
if (B === 0) {
|
112
|
+
fe = console.log, de = console.info, Ee = console.warn, ge = console.error, ve = console.group, me = console.groupCollapsed, be = console.groupEnd;
|
113
|
+
var e = {
|
114
|
+
configurable: !0,
|
115
|
+
enumerable: !0,
|
116
|
+
value: E,
|
117
|
+
writable: !0
|
118
|
+
};
|
119
|
+
Object.defineProperties(console, {
|
120
|
+
info: e,
|
121
|
+
log: e,
|
122
|
+
warn: e,
|
123
|
+
error: e,
|
124
|
+
group: e,
|
125
|
+
groupCollapsed: e,
|
126
|
+
groupEnd: e
|
127
|
+
});
|
128
|
+
}
|
129
|
+
B++;
|
130
|
+
}
|
131
|
+
function f() {
|
132
|
+
if (B--, B === 0) {
|
133
|
+
var e = { configurable: !0, enumerable: !0, writable: !0 };
|
134
|
+
Object.defineProperties(console, {
|
135
|
+
log: M({}, e, { value: fe }),
|
136
|
+
info: M({}, e, { value: de }),
|
137
|
+
warn: M({}, e, { value: Ee }),
|
138
|
+
error: M({}, e, { value: ge }),
|
139
|
+
group: M({}, e, { value: ve }),
|
140
|
+
groupCollapsed: M({}, e, { value: me }),
|
141
|
+
groupEnd: M({}, e, { value: be })
|
142
|
+
});
|
143
|
+
}
|
144
|
+
0 > B && console.error(
|
145
|
+
"disabledDepth fell below zero. This is a bug in React. Please file an issue."
|
146
|
+
);
|
147
|
+
}
|
148
|
+
function i(e) {
|
149
|
+
if (te === void 0)
|
150
|
+
try {
|
151
|
+
throw Error();
|
152
|
+
} catch (t) {
|
153
|
+
var r = t.stack.trim().match(/\n( *(at )?)/);
|
154
|
+
te = r && r[1] || "", he = -1 < t.stack.indexOf(`
|
155
|
+
at`) ? " (<anonymous>)" : -1 < t.stack.indexOf("@") ? "@unknown:0:0" : "";
|
156
|
+
}
|
157
|
+
return `
|
158
|
+
` + te + e + he;
|
159
|
+
}
|
160
|
+
function l(e, r) {
|
161
|
+
if (!e || ne) return "";
|
162
|
+
var t = oe.get(e);
|
163
|
+
if (t !== void 0) return t;
|
164
|
+
ne = !0, t = Error.prepareStackTrace, Error.prepareStackTrace = void 0;
|
165
|
+
var o = null;
|
166
|
+
o = P.H, P.H = null, u();
|
167
|
+
try {
|
168
|
+
var v = {
|
169
|
+
DetermineComponentFrameRoot: function() {
|
170
|
+
try {
|
171
|
+
if (r) {
|
172
|
+
var O = function() {
|
173
|
+
throw Error();
|
174
|
+
};
|
175
|
+
if (Object.defineProperty(O.prototype, "props", {
|
176
|
+
set: function() {
|
177
|
+
throw Error();
|
178
|
+
}
|
179
|
+
}), typeof Reflect == "object" && Reflect.construct) {
|
180
|
+
try {
|
181
|
+
Reflect.construct(O, []);
|
182
|
+
} catch (S) {
|
183
|
+
var z = S;
|
184
|
+
}
|
185
|
+
Reflect.construct(e, [], O);
|
186
|
+
} else {
|
187
|
+
try {
|
188
|
+
O.call();
|
189
|
+
} catch (S) {
|
190
|
+
z = S;
|
191
|
+
}
|
192
|
+
e.call(O.prototype);
|
193
|
+
}
|
194
|
+
} else {
|
195
|
+
try {
|
196
|
+
throw Error();
|
197
|
+
} catch (S) {
|
198
|
+
z = S;
|
199
|
+
}
|
200
|
+
(O = e()) && typeof O.catch == "function" && O.catch(function() {
|
201
|
+
});
|
202
|
+
}
|
203
|
+
} catch (S) {
|
204
|
+
if (S && z && typeof S.stack == "string")
|
205
|
+
return [S.stack, z.stack];
|
206
|
+
}
|
207
|
+
return [null, null];
|
208
|
+
}
|
209
|
+
};
|
210
|
+
v.DetermineComponentFrameRoot.displayName = "DetermineComponentFrameRoot";
|
211
|
+
var s = Object.getOwnPropertyDescriptor(
|
212
|
+
v.DetermineComponentFrameRoot,
|
213
|
+
"name"
|
214
|
+
);
|
215
|
+
s && s.configurable && Object.defineProperty(
|
216
|
+
v.DetermineComponentFrameRoot,
|
217
|
+
"name",
|
218
|
+
{ value: "DetermineComponentFrameRoot" }
|
219
|
+
);
|
220
|
+
var n = v.DetermineComponentFrameRoot(), _ = n[0], $ = n[1];
|
221
|
+
if (_ && $) {
|
222
|
+
var m = _.split(`
|
223
|
+
`), Y = $.split(`
|
224
|
+
`);
|
225
|
+
for (n = s = 0; s < m.length && !m[s].includes(
|
226
|
+
"DetermineComponentFrameRoot"
|
227
|
+
); )
|
228
|
+
s++;
|
229
|
+
for (; n < Y.length && !Y[n].includes(
|
230
|
+
"DetermineComponentFrameRoot"
|
231
|
+
); )
|
232
|
+
n++;
|
233
|
+
if (s === m.length || n === Y.length)
|
234
|
+
for (s = m.length - 1, n = Y.length - 1; 1 <= s && 0 <= n && m[s] !== Y[n]; )
|
235
|
+
n--;
|
236
|
+
for (; 1 <= s && 0 <= n; s--, n--)
|
237
|
+
if (m[s] !== Y[n]) {
|
238
|
+
if (s !== 1 || n !== 1)
|
239
|
+
do
|
240
|
+
if (s--, n--, 0 > n || m[s] !== Y[n]) {
|
241
|
+
var F = `
|
242
|
+
` + m[s].replace(
|
243
|
+
" at new ",
|
244
|
+
" at "
|
245
|
+
);
|
246
|
+
return e.displayName && F.includes("<anonymous>") && (F = F.replace("<anonymous>", e.displayName)), typeof e == "function" && oe.set(e, F), F;
|
247
|
+
}
|
248
|
+
while (1 <= s && 0 <= n);
|
249
|
+
break;
|
250
|
+
}
|
251
|
+
}
|
252
|
+
} finally {
|
253
|
+
ne = !1, P.H = o, f(), Error.prepareStackTrace = t;
|
254
|
+
}
|
255
|
+
return m = (m = e ? e.displayName || e.name : "") ? i(m) : "", typeof e == "function" && oe.set(e, m), m;
|
256
|
+
}
|
257
|
+
function d(e) {
|
258
|
+
if (e == null) return "";
|
259
|
+
if (typeof e == "function") {
|
260
|
+
var r = e.prototype;
|
261
|
+
return l(
|
262
|
+
e,
|
263
|
+
!(!r || !r.isReactComponent)
|
264
|
+
);
|
265
|
+
}
|
266
|
+
if (typeof e == "string") return i(e);
|
267
|
+
switch (e) {
|
268
|
+
case K:
|
269
|
+
return i("Suspense");
|
270
|
+
case Q:
|
271
|
+
return i("SuspenseList");
|
272
|
+
}
|
273
|
+
if (typeof e == "object")
|
274
|
+
switch (e.$$typeof) {
|
275
|
+
case Z:
|
276
|
+
return e = l(e.render, !1), e;
|
277
|
+
case D:
|
278
|
+
return d(e.type);
|
279
|
+
case ee:
|
280
|
+
r = e._payload, e = e._init;
|
281
|
+
try {
|
282
|
+
return d(e(r));
|
283
|
+
} catch {
|
284
|
+
}
|
285
|
+
}
|
286
|
+
return "";
|
287
|
+
}
|
288
|
+
function b() {
|
289
|
+
var e = P.A;
|
290
|
+
return e === null ? null : e.getOwner();
|
291
|
+
}
|
292
|
+
function T(e) {
|
293
|
+
if (ce.call(e, "key")) {
|
294
|
+
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
295
|
+
if (r && r.isReactWarning) return !1;
|
296
|
+
}
|
297
|
+
return e.key !== void 0;
|
298
|
+
}
|
299
|
+
function y(e, r) {
|
300
|
+
function t() {
|
301
|
+
Te || (Te = !0, console.error(
|
302
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
303
|
+
r
|
304
|
+
));
|
305
|
+
}
|
306
|
+
t.isReactWarning = !0, Object.defineProperty(e, "key", {
|
307
|
+
get: t,
|
308
|
+
configurable: !0
|
309
|
+
});
|
310
|
+
}
|
311
|
+
function w() {
|
312
|
+
var e = a(this.type);
|
313
|
+
return we[e] || (we[e] = !0, console.error(
|
314
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
315
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
316
|
+
}
|
317
|
+
function W(e, r, t, o, v, s) {
|
318
|
+
return t = s.ref, e = {
|
319
|
+
$$typeof: V,
|
320
|
+
type: e,
|
321
|
+
key: r,
|
322
|
+
props: s,
|
323
|
+
_owner: v
|
324
|
+
}, (t !== void 0 ? t : null) !== null ? Object.defineProperty(e, "ref", {
|
325
|
+
enumerable: !1,
|
326
|
+
get: w
|
327
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
328
|
+
configurable: !1,
|
329
|
+
enumerable: !1,
|
330
|
+
writable: !0,
|
331
|
+
value: 0
|
332
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
333
|
+
configurable: !1,
|
334
|
+
enumerable: !1,
|
335
|
+
writable: !0,
|
336
|
+
value: null
|
337
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
338
|
+
}
|
339
|
+
function h(e, r, t, o, v, s) {
|
340
|
+
if (typeof e == "string" || typeof e == "function" || e === G || e === ue || e === X || e === K || e === Q || e === Oe || typeof e == "object" && e !== null && (e.$$typeof === ee || e.$$typeof === D || e.$$typeof === se || e.$$typeof === le || e.$$typeof === Z || e.$$typeof === Ne || e.getModuleId !== void 0)) {
|
341
|
+
var n = r.children;
|
342
|
+
if (n !== void 0)
|
343
|
+
if (o)
|
344
|
+
if (re(n)) {
|
345
|
+
for (o = 0; o < n.length; o++)
|
346
|
+
A(n[o], e);
|
347
|
+
Object.freeze && Object.freeze(n);
|
348
|
+
} else
|
349
|
+
console.error(
|
350
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
351
|
+
);
|
352
|
+
else A(n, e);
|
353
|
+
} else
|
354
|
+
n = "", (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (n += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."), e === null ? o = "null" : re(e) ? o = "array" : e !== void 0 && e.$$typeof === V ? (o = "<" + (a(e.type) || "Unknown") + " />", n = " Did you accidentally export a JSX literal instead of a component?") : o = typeof e, console.error(
|
355
|
+
"React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",
|
356
|
+
o,
|
357
|
+
n
|
358
|
+
);
|
359
|
+
if (ce.call(r, "key")) {
|
360
|
+
n = a(e);
|
361
|
+
var _ = Object.keys(r).filter(function(m) {
|
362
|
+
return m !== "key";
|
363
|
+
});
|
364
|
+
o = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", pe[n + o] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
|
365
|
+
`A props object containing a "key" prop is being spread into JSX:
|
366
|
+
let props = %s;
|
367
|
+
<%s {...props} />
|
368
|
+
React keys must be passed directly to JSX without using spread:
|
369
|
+
let props = %s;
|
370
|
+
<%s key={someKey} {...props} />`,
|
371
|
+
o,
|
372
|
+
n,
|
373
|
+
_,
|
374
|
+
n
|
375
|
+
), pe[n + o] = !0);
|
376
|
+
}
|
377
|
+
if (n = null, t !== void 0 && (c(t), n = "" + t), T(r) && (c(r.key), n = "" + r.key), "key" in r) {
|
378
|
+
t = {};
|
379
|
+
for (var $ in r)
|
380
|
+
$ !== "key" && (t[$] = r[$]);
|
381
|
+
} else t = r;
|
382
|
+
return n && y(
|
383
|
+
t,
|
384
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
385
|
+
), W(e, n, s, v, b(), t);
|
386
|
+
}
|
387
|
+
function A(e, r) {
|
388
|
+
if (typeof e == "object" && e && e.$$typeof !== Ae) {
|
389
|
+
if (re(e))
|
390
|
+
for (var t = 0; t < e.length; t++) {
|
391
|
+
var o = e[t];
|
392
|
+
j(o) && x(o, r);
|
393
|
+
}
|
394
|
+
else if (j(e))
|
395
|
+
e._store && (e._store.validated = 1);
|
396
|
+
else if (e === null || typeof e != "object" ? t = null : (t = ie && e[ie] || e["@@iterator"], t = typeof t == "function" ? t : null), typeof t == "function" && t !== e.entries && (t = t.call(e), t !== e))
|
397
|
+
for (; !(e = t.next()).done; )
|
398
|
+
j(e.value) && x(e.value, r);
|
399
|
+
}
|
400
|
+
}
|
401
|
+
function j(e) {
|
402
|
+
return typeof e == "object" && e !== null && e.$$typeof === V;
|
403
|
+
}
|
404
|
+
function x(e, r) {
|
405
|
+
if (e._store && !e._store.validated && e.key == null && (e._store.validated = 1, r = R(r), !ye[r])) {
|
406
|
+
ye[r] = !0;
|
407
|
+
var t = "";
|
408
|
+
e && e._owner != null && e._owner !== b() && (t = null, typeof e._owner.tag == "number" ? t = a(e._owner.type) : typeof e._owner.name == "string" && (t = e._owner.name), t = " It was passed a child from " + t + ".");
|
409
|
+
var o = P.getCurrentStack;
|
410
|
+
P.getCurrentStack = function() {
|
411
|
+
var v = d(e.type);
|
412
|
+
return o && (v += o() || ""), v;
|
413
|
+
}, console.error(
|
414
|
+
'Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',
|
415
|
+
r,
|
416
|
+
t
|
417
|
+
), P.getCurrentStack = o;
|
418
|
+
}
|
419
|
+
}
|
420
|
+
function R(e) {
|
421
|
+
var r = "", t = b();
|
422
|
+
return t && (t = a(t.type)) && (r = `
|
423
|
+
|
424
|
+
Check the render method of \`` + t + "`."), r || (e = a(e)) && (r = `
|
425
|
+
|
426
|
+
Check the top-level render call using <` + e + ">."), r;
|
427
|
+
}
|
428
|
+
var I = Pe, V = Symbol.for("react.transitional.element"), J = Symbol.for("react.portal"), G = Symbol.for("react.fragment"), X = Symbol.for("react.strict_mode"), ue = Symbol.for("react.profiler"), le = Symbol.for("react.consumer"), se = Symbol.for("react.context"), Z = Symbol.for("react.forward_ref"), K = Symbol.for("react.suspense"), Q = Symbol.for("react.suspense_list"), D = Symbol.for("react.memo"), ee = Symbol.for("react.lazy"), Oe = Symbol.for("react.offscreen"), ie = Symbol.iterator, ke = Symbol.for("react.client.reference"), P = I.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ce = Object.prototype.hasOwnProperty, M = Object.assign, Ne = Symbol.for("react.client.reference"), re = Array.isArray, B = 0, fe, de, Ee, ge, ve, me, be;
|
429
|
+
E.__reactDisabledLog = !0;
|
430
|
+
var te, he, ne = !1, oe = new (typeof WeakMap == "function" ? WeakMap : Map)(), Ae = Symbol.for("react.client.reference"), Te, we = {}, pe = {}, ye = {};
|
431
|
+
U.Fragment = G, U.jsx = function(e, r, t, o, v) {
|
432
|
+
return h(e, r, t, !1, o, v);
|
433
|
+
}, U.jsxs = function(e, r, t, o, v) {
|
434
|
+
return h(e, r, t, !0, o, v);
|
435
|
+
};
|
436
|
+
}()), U;
|
437
|
+
}
|
438
|
+
var Se;
|
439
|
+
function $e() {
|
440
|
+
return Se || (Se = 1, process.env.NODE_ENV === "production" ? q.exports = Ye() : q.exports = We()), q.exports;
|
441
|
+
}
|
442
|
+
var p = $e();
|
443
|
+
const Le = ({
|
444
|
+
width: a,
|
445
|
+
gap: g,
|
446
|
+
backgroundColor: c = "red",
|
447
|
+
onDrag: E,
|
448
|
+
onDragStart: u,
|
449
|
+
onDragEnd: f
|
450
|
+
}) => {
|
451
|
+
const i = C(null), l = C(!1);
|
452
|
+
return je(() => {
|
453
|
+
const d = (y) => y.target !== i.current ? !1 : (l.current = !0, u(y.clientX), !0), b = (y) => l.current ? (E(y.clientX), !0) : !1, T = () => l.current ? (l.current = !1, f(), !0) : !1;
|
454
|
+
return window.addEventListener("mousedown", d), window.addEventListener("mousemove", b), window.addEventListener("mouseup", T), () => {
|
455
|
+
window.removeEventListener("mousedown", d), window.removeEventListener("mousemove", b), window.removeEventListener("mouseup", T);
|
456
|
+
};
|
457
|
+
}, [u, E, f]), /* @__PURE__ */ p.jsx(
|
458
|
+
"div",
|
459
|
+
{
|
460
|
+
ref: i,
|
461
|
+
style: {
|
462
|
+
width: `${a}px`,
|
463
|
+
margin: `${g}px ${g}px`,
|
464
|
+
alignSelf: "stretch",
|
465
|
+
background: c,
|
466
|
+
borderRadius: "2px",
|
467
|
+
cursor: "ew-resize"
|
468
|
+
}
|
469
|
+
}
|
470
|
+
);
|
471
|
+
}, Ve = ({
|
472
|
+
rightNode: a,
|
473
|
+
leftNode: g,
|
474
|
+
options: { primary: c },
|
475
|
+
width: E,
|
476
|
+
backgroundColor: u = "gray"
|
477
|
+
}) => {
|
478
|
+
const f = C(null), i = C(null), l = C(null), [d, b] = Me(
|
479
|
+
"both"
|
480
|
+
), T = xe(() => {
|
481
|
+
const w = d === "none" || d === "primary" && c === "left";
|
482
|
+
return c === "right" ? w ? k.BOTTOM_RIGHT : k.RIGHT : w ? k.TOP_LEFT : k.RIGHT;
|
483
|
+
}, [d, c]), y = xe(() => {
|
484
|
+
const w = d === "none" || d === "primary" && c === "right";
|
485
|
+
return c === "left" ? w ? k.BOTTOM_LEFT : k.LEFT : w ? k.TOP_RIGHT : k.LEFT;
|
486
|
+
}, [d, c]);
|
487
|
+
return je(() => {
|
488
|
+
const w = setInterval(() => {
|
489
|
+
const W = i.current, h = l.current, A = f.current;
|
490
|
+
if (!A || !W || !h)
|
491
|
+
return;
|
492
|
+
const j = A.getBoundingClientRect().width, x = W.getBoundingClientRect().width, R = h.getBoundingClientRect().width, { primaryWidth: I, secondaryWidth: V } = c === "left" ? { primaryWidth: R, secondaryWidth: x } : { primaryWidth: x, secondaryWidth: R }, J = I + 2 * N <= j, G = V + I + 3 * N <= j;
|
493
|
+
b(J ? G ? "both" : "primary" : "none");
|
494
|
+
}, 33.333333333333336);
|
495
|
+
return () => clearInterval(w);
|
496
|
+
}, [f, i, l, c]), /* @__PURE__ */ p.jsxs(
|
497
|
+
"div",
|
498
|
+
{
|
499
|
+
ref: f,
|
500
|
+
style: {
|
501
|
+
position: "relative",
|
502
|
+
width: E,
|
503
|
+
backgroundColor: u,
|
504
|
+
borderRadius: "5px",
|
505
|
+
color: "white"
|
506
|
+
},
|
507
|
+
children: [
|
508
|
+
/* @__PURE__ */ p.jsx("div", { ref: l, style: y, children: g }),
|
509
|
+
/* @__PURE__ */ p.jsx("div", { ref: i, style: T, children: a })
|
510
|
+
]
|
511
|
+
}
|
512
|
+
);
|
513
|
+
}, N = 5, L = {
|
514
|
+
position: "absolute",
|
515
|
+
transition: "all 200ms cubic-bezier(.47,1.64,.41,.8)",
|
516
|
+
transitionProperty: "transform, top, left, bottom, right"
|
517
|
+
}, k = {
|
518
|
+
TOP_LEFT: {
|
519
|
+
...L,
|
520
|
+
left: N,
|
521
|
+
top: -5,
|
522
|
+
transform: "translateY(-100%)"
|
523
|
+
},
|
524
|
+
LEFT: {
|
525
|
+
...L,
|
526
|
+
left: N,
|
527
|
+
top: "50%",
|
528
|
+
transform: "translateY(-50%)"
|
529
|
+
},
|
530
|
+
BOTTOM_LEFT: {
|
531
|
+
...L,
|
532
|
+
left: N,
|
533
|
+
bottom: -5,
|
534
|
+
transform: "translateY(100%)"
|
535
|
+
},
|
536
|
+
TOP_RIGHT: {
|
537
|
+
...L,
|
538
|
+
right: N,
|
539
|
+
top: -5,
|
540
|
+
transform: "translateY(-100%)"
|
541
|
+
},
|
542
|
+
RIGHT: {
|
543
|
+
...L,
|
544
|
+
right: N,
|
545
|
+
top: "50%",
|
546
|
+
transform: "translateY(-50%)"
|
547
|
+
},
|
548
|
+
BOTTOM_RIGHT: {
|
549
|
+
...L,
|
550
|
+
right: N,
|
551
|
+
bottom: -5,
|
552
|
+
transform: "translateY(100%)"
|
553
|
+
}
|
554
|
+
}, Ce = ({
|
555
|
+
value: a,
|
556
|
+
total: g,
|
557
|
+
detail: c,
|
558
|
+
width: E,
|
559
|
+
anchorName: u,
|
560
|
+
displayValueType: f,
|
561
|
+
backgroundColor: i = "gray"
|
562
|
+
}) => {
|
563
|
+
const l = /* @__PURE__ */ p.jsx(
|
564
|
+
"div",
|
565
|
+
{
|
566
|
+
style: {
|
567
|
+
userSelect: "none",
|
568
|
+
whiteSpace: "nowrap"
|
569
|
+
},
|
570
|
+
children: c.name
|
571
|
+
}
|
572
|
+
), d = f === "percentage" ? /* @__PURE__ */ p.jsx(
|
573
|
+
"div",
|
574
|
+
{
|
575
|
+
style: {
|
576
|
+
userSelect: "none",
|
577
|
+
whiteSpace: "nowrap"
|
578
|
+
},
|
579
|
+
children: `${Math.round(a * 100 / g)}%`
|
580
|
+
}
|
581
|
+
) : null;
|
582
|
+
return /* @__PURE__ */ p.jsx(
|
583
|
+
Ve,
|
584
|
+
{
|
585
|
+
width: E,
|
586
|
+
rightNode: u === "right" ? l : d,
|
587
|
+
leftNode: u === "left" ? l : d,
|
588
|
+
options: {
|
589
|
+
primary: u
|
590
|
+
},
|
591
|
+
backgroundColor: i
|
592
|
+
}
|
593
|
+
);
|
594
|
+
}, Be = ({
|
595
|
+
value: a,
|
596
|
+
proportions: g,
|
597
|
+
onChange: c,
|
598
|
+
sliderOptions: E = {
|
599
|
+
width: 5,
|
600
|
+
gap: 2
|
601
|
+
},
|
602
|
+
options: u = {
|
603
|
+
height: 20,
|
604
|
+
displayValueType: "percentage"
|
605
|
+
}
|
606
|
+
}) => {
|
607
|
+
const f = C(null), i = a[0] + a[1], l = C(null), d = C(null), b = C(null), T = E.width + E.gap * 2, y = ae(
|
608
|
+
(h) => {
|
609
|
+
l.current = h, d.current = a[0], b.current = a[1];
|
610
|
+
},
|
611
|
+
[a]
|
612
|
+
), w = ae(() => {
|
613
|
+
l.current = null, d.current = null, b.current = null;
|
614
|
+
}, []), W = ae(
|
615
|
+
(h) => {
|
616
|
+
if (l.current === null) return;
|
617
|
+
const A = h - l.current, j = f.current - T, x = d.current + b.current;
|
618
|
+
let R = d.current + A / j * x;
|
619
|
+
R = Math.max(0, Math.min(x, R)), c([R, x - R]);
|
620
|
+
},
|
621
|
+
[c, T]
|
622
|
+
);
|
623
|
+
return /* @__PURE__ */ p.jsxs(
|
624
|
+
"div",
|
625
|
+
{
|
626
|
+
ref: (h) => {
|
627
|
+
h && (f.current = h.getBoundingClientRect().width);
|
628
|
+
},
|
629
|
+
style: {
|
630
|
+
display: "flex",
|
631
|
+
flexDirection: "row",
|
632
|
+
height: u.height
|
633
|
+
},
|
634
|
+
children: [
|
635
|
+
/* @__PURE__ */ p.jsx(
|
636
|
+
Ce,
|
637
|
+
{
|
638
|
+
value: a[0],
|
639
|
+
backgroundColor: g[0].backgroundColor,
|
640
|
+
total: i,
|
641
|
+
width: `calc(${a[0] * 100 / i}% - ${T / 2}px)`,
|
642
|
+
detail: g[0],
|
643
|
+
anchorName: "left",
|
644
|
+
displayValueType: u.displayValueType
|
645
|
+
}
|
646
|
+
),
|
647
|
+
/* @__PURE__ */ p.jsx(
|
648
|
+
Le,
|
649
|
+
{
|
650
|
+
backgroundColor: E.backgroundColor,
|
651
|
+
width: E.width,
|
652
|
+
gap: E.gap,
|
653
|
+
onDragStart: y,
|
654
|
+
onDrag: W,
|
655
|
+
onDragEnd: w
|
656
|
+
}
|
657
|
+
),
|
658
|
+
/* @__PURE__ */ p.jsx(
|
659
|
+
Ce,
|
660
|
+
{
|
661
|
+
value: a[1],
|
662
|
+
total: i,
|
663
|
+
backgroundColor: g[1].backgroundColor,
|
664
|
+
width: `calc(${a[1] * 100 / i}% - ${T / 2}px)`,
|
665
|
+
detail: g[1],
|
666
|
+
anchorName: "right",
|
667
|
+
displayValueType: u.displayValueType
|
668
|
+
}
|
669
|
+
)
|
670
|
+
]
|
671
|
+
}
|
672
|
+
);
|
673
|
+
};
|
674
|
+
export {
|
675
|
+
Be as ProportionSlider,
|
676
|
+
Be as default
|
677
|
+
};
|
678
|
+
//# sourceMappingURL=react-proportion-slider.es.js.map
|