@eightshift/ui-components 6.0.8 → 6.0.10
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/{Button-BXjXzdW_.js → Button-JRIu2BnS.js} +8 -8
- package/dist/{Dialog-D8bjn-nh.js → Dialog-Dd1yqNus.js} +31 -27
- package/dist/{FieldError-DwBG6m1U.js → FieldError-DmVwL6Dj.js} +2 -2
- package/dist/{FocusScope-BMk5oZCk.js → FocusScope-Dri1oBcH.js} +2 -2
- package/dist/{Heading-BmRX4BRL.js → Heading-eA6LXIKB.js} +1 -1
- package/dist/{Input-CNNksOWg.js → Input-Cuw9UbNb.js} +14 -24
- package/dist/{Label-D8a3eYb-.js → Label-DPWyf-gp.js} +1 -1
- package/dist/{List-BGHOoFf0.js → List-CWheI3JH.js} +1 -1
- package/dist/{ListBox-Dd37zMvs.js → ListBox-DT1sFY3e.js} +17 -16
- package/dist/{OverlayArrow-DokC40S3.js → OverlayArrow-DVJTTfZM.js} +67 -123
- package/dist/{RadioGroup-BVFvITWO.js → RadioGroup-Cp5cdBI_.js} +14 -14
- package/dist/{SearchField-CHYnN-jt.js → SearchField-CLhr5PGZ.js} +44 -37
- package/dist/{SelectionManager-N8X7T_4D.js → SelectionManager-DbBiF5M8.js} +41 -68
- package/dist/{SharedElementTransition-BDT84GtD.js → SharedElementTransition-B_vnQ1uR.js} +1 -1
- package/dist/{Slider-CL5CM9S8.js → Slider-CZV3HhHY.js} +119 -83
- package/dist/{Text-ztX6G1zR.js → Text-Dae33gHp.js} +1 -1
- package/dist/{VisuallyHidden-DTUuKFiI.js → VisuallyHidden-eaCBtXhE.js} +2 -2
- package/dist/animation-DY7CNkr6.js +67 -0
- package/dist/assets/style-admin.css +44 -57
- package/dist/assets/style-editor.css +44 -57
- package/dist/assets/style.css +44 -57
- package/dist/assets/wp-overrides/allow-full-width-blocks.css +1 -1
- package/dist/assets/wp-overrides/fix-label-text-case.css +1 -1
- package/dist/assets/wp-overrides/increase-sidebar-width.css +1 -1
- package/dist/assets/wp-overrides/make-block-messages-nicer.css +1 -1
- package/dist/assets/wp-overrides/replace-fonts.css +1 -1
- package/dist/assets/wp-overrides/restyle-tooltips.css +1 -1
- package/dist/assets/wp-overrides/round-corners.css +1 -1
- package/dist/assets/wp-overrides/unify-button-sizes.css +1 -1
- package/dist/{color-swatch-BEBLRxTy.js → color-swatch-CZj0jHZd.js} +4 -4
- package/dist/components/animated-visibility/animated-visibility.js +2 -2
- package/dist/components/base-control/base-control.js +1 -1
- package/dist/components/button/button.js +5 -5
- package/dist/components/checkbox/checkbox.js +10 -10
- package/dist/components/color-pickers/color-picker.js +1 -1
- package/dist/components/color-pickers/color-swatch.js +1 -1
- package/dist/components/color-pickers/gradient-editor.js +2 -2
- package/dist/components/color-pickers/solid-color-picker.js +17 -17
- package/dist/components/draggable/draggable.js +329 -156
- package/dist/components/draggable-list/draggable-list.js +1 -1
- package/dist/components/expandable/expandable.js +16 -13
- package/dist/components/index.js +1 -1
- package/dist/components/input-field/input-field.js +8 -8
- package/dist/components/link-input/link-input.js +25 -25
- package/dist/components/matrix-align/matrix-align.js +1 -1
- package/dist/components/menu/menu.js +1 -1
- package/dist/components/modal/modal.js +19 -12
- package/dist/components/number-picker/number-picker.js +9 -9
- package/dist/components/options-panel/options-panel.js +1 -1
- package/dist/components/popover/popover.js +5 -5
- package/dist/components/radio/radio.js +2 -2
- package/dist/components/repeater/repeater.js +1 -1
- package/dist/components/responsive/mini-responsive.js +1 -1
- package/dist/components/select/async-multi-select.js +10 -10
- package/dist/components/select/async-select.js +10 -10
- package/dist/components/select/multi-select.js +10 -10
- package/dist/components/select/shared.js +3 -3
- package/dist/components/select/single-select.js +10 -10
- package/dist/components/slider/column-config-slider.js +3 -3
- package/dist/components/slider/slider.js +3 -3
- package/dist/components/smart-image/smart-image.js +1 -1
- package/dist/components/smart-image/worker-inline.js +1 -1
- package/dist/components/tabs/tabs.js +36 -17
- package/dist/components/toggle/switch.js +7 -7
- package/dist/components/toggle/toggle.js +1 -1
- package/dist/components/toggle-button/toggle-button.js +6 -6
- package/dist/components/tooltip/tooltip.js +10 -8
- package/dist/{context-BQvmiUqb.js → context-DYYO3Ns3.js} +9 -6
- package/dist/{filterDOMProps-D2C6R0DK.js → filterDOMProps-eGTqWSTd.js} +1 -1
- package/dist/{general-ChNQK6O9.js → general-C8Q0dvEx.js} +15 -14
- package/dist/{index-oFgxU4zs.js → index-sSixe2j_.js} +20 -20
- package/dist/index.js +1 -1
- package/dist/{proxy-DkQpcQgI.js → proxy-CcjltLEW.js} +272 -121
- package/dist/{shared-DOxXagm0.js → shared-Bg9lx3pE.js} +20 -20
- package/dist/{textSelection-CwHUtNVX.js → textSelection-Cq_Br7RW.js} +1 -1
- package/dist/{useAsyncList-D52mQcrH.js → useAsyncList-DsZvQXls.js} +5 -2
- package/dist/{useButton-DdZrS1Kz.js → useButton-CeuyDay5.js} +4 -4
- package/dist/{useEvent-BD7Olibq.js → useEvent-DoWvho2u.js} +2 -3
- package/dist/{useFilter-bhxeEDg8.js → useFilter-DYtfYPua.js} +1 -1
- package/dist/{useFocusRing-D3b7Kh4P.js → useFocusRing-WEswknAY.js} +1 -1
- package/dist/{useFormReset-WUv2PdFO.js → useFormReset-BDF1K4E4.js} +2 -3
- package/dist/{useFormValidation-DQeXkyLm.js → useFormValidation-Dqzjv4jX.js} +2 -5
- package/dist/{useHover-Bycb7BsD.js → useHover-CG39Ci3A.js} +164 -66
- package/dist/{useLabel-Bnv4-T24.js → useLabel--3fT2XKM.js} +2 -2
- package/dist/{useLabels-B49ptFDX.js → useLabels-vzdDMGCX.js} +1 -1
- package/dist/{useListState-ZKhRO8ML.js → useListState-Bya9g7W8.js} +1 -1
- package/dist/{useLocalizedStringFormatter-NETP-8H8.js → useLocalizedStringFormatter-M3L6Ge2c.js} +3 -3
- package/dist/{useNumberField-D2fUHql3.js → useNumberField-D6lsi3Vu.js} +91 -24
- package/dist/{useNumberFormatter-DGvuRCn7.js → useNumberFormatter-BWOyCamK.js} +1 -1
- package/dist/{usePress-B8OteQMu.js → usePress-B9w0X4Ur.js} +168 -180
- package/dist/{useSingleSelectListState-BBTu4shO.js → useSingleSelectListState-D9SqGLJ0.js} +2 -2
- package/dist/{useToggle-BZhaYwZl.js → useToggle-Deq2xxQV.js} +5 -5
- package/dist/{useToggleState-VkXJjsru.js → useToggleState-j3o1PvdS.js} +1 -1
- package/dist/utilities/general.js +1 -1
- package/dist/utilities/index.js +1 -1
- package/dist/{utils-DGpXyJOJ.js → utils-HC9_3Crc.js} +20 -31
- package/dist/workers/image-analysis.worker.js +1 -1
- package/package.json +24 -28
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useLayoutEffect, useMemo, useState, useCallback,
|
|
2
|
+
import { useEffect, useRef, useLayoutEffect, useMemo, useState, useCallback, createContext, memo, useInsertionEffect, forwardRef, startTransition, useImperativeHandle, useContext } from "react";
|
|
3
3
|
import { _ as __ } from "../../default-i18n-CnQeC5Pl.js";
|
|
4
4
|
import { DraggableContext } from "./draggable-context.js";
|
|
5
|
-
import { r as reactDomExports } from "../../index-
|
|
5
|
+
import { r as reactDomExports } from "../../index-sSixe2j_.js";
|
|
6
6
|
import { randomId } from "../../utilities/hash.js";
|
|
7
|
-
var i = Symbol.for("preact-signals");
|
|
7
|
+
var i = /* @__PURE__ */ Symbol.for("preact-signals");
|
|
8
8
|
function t() {
|
|
9
9
|
if (!(s > 1)) {
|
|
10
10
|
var i2, t2 = false;
|
|
@@ -378,7 +378,7 @@ var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
|
|
378
378
|
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
379
379
|
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
380
380
|
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
381
|
-
var __knownSymbol$5 = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
381
|
+
var __knownSymbol$5 = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
382
382
|
var __typeError$6 = (msg) => {
|
|
383
383
|
throw TypeError(msg);
|
|
384
384
|
};
|
|
@@ -532,7 +532,7 @@ function enumerable(enumerable2 = true) {
|
|
|
532
532
|
};
|
|
533
533
|
}
|
|
534
534
|
function effects(...entries) {
|
|
535
|
-
const effects2 = entries.map(E);
|
|
535
|
+
const effects2 = entries.map((fn) => E(fn));
|
|
536
536
|
return () => effects2.forEach((cleanup) => cleanup());
|
|
537
537
|
}
|
|
538
538
|
var _previous_dec, _initial_dec, _current_dec$1, _current_dec2, _previous_dec2, _initial_dec2, _init$5, _initial, _a$3, initial_get, initial_set, _ValueHistory_instances, _previous, _b$1, previous_get, previous_set, _current, _c$2, current_get, current_set;
|
|
@@ -629,7 +629,7 @@ var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
|
|
|
629
629
|
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
630
630
|
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
631
631
|
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
632
|
-
var __knownSymbol$4 = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
632
|
+
var __knownSymbol$4 = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
633
633
|
var __typeError$5 = (msg) => {
|
|
634
634
|
throw TypeError(msg);
|
|
635
635
|
};
|
|
@@ -920,7 +920,7 @@ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
|
920
920
|
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
921
921
|
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
922
922
|
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
923
|
-
var __knownSymbol$3 = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
923
|
+
var __knownSymbol$3 = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
924
924
|
var __typeError$4 = (msg) => {
|
|
925
925
|
throw TypeError(msg);
|
|
926
926
|
};
|
|
@@ -2018,6 +2018,56 @@ var Sensor = class extends Plugin {
|
|
|
2018
2018
|
this.options = options2;
|
|
2019
2019
|
}
|
|
2020
2020
|
};
|
|
2021
|
+
var ActivationController = class extends AbortController {
|
|
2022
|
+
constructor(constraints, onActivate) {
|
|
2023
|
+
super();
|
|
2024
|
+
this.constraints = constraints;
|
|
2025
|
+
this.onActivate = onActivate;
|
|
2026
|
+
this.activated = false;
|
|
2027
|
+
for (const constraint of constraints != null ? constraints : []) {
|
|
2028
|
+
constraint.controller = this;
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
onEvent(event) {
|
|
2032
|
+
var _a4;
|
|
2033
|
+
if (this.activated) return;
|
|
2034
|
+
if ((_a4 = this.constraints) == null ? void 0 : _a4.length) {
|
|
2035
|
+
for (const constraint of this.constraints) {
|
|
2036
|
+
constraint.onEvent(event);
|
|
2037
|
+
}
|
|
2038
|
+
} else {
|
|
2039
|
+
this.activate(event);
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
activate(event) {
|
|
2043
|
+
if (this.activated) return;
|
|
2044
|
+
this.activated = true;
|
|
2045
|
+
this.onActivate(event);
|
|
2046
|
+
}
|
|
2047
|
+
abort(event) {
|
|
2048
|
+
this.activated = false;
|
|
2049
|
+
super.abort(event);
|
|
2050
|
+
}
|
|
2051
|
+
};
|
|
2052
|
+
var _controller;
|
|
2053
|
+
var ActivationConstraint = class {
|
|
2054
|
+
constructor(options2) {
|
|
2055
|
+
this.options = options2;
|
|
2056
|
+
__privateAdd$4(this, _controller);
|
|
2057
|
+
}
|
|
2058
|
+
set controller(controller) {
|
|
2059
|
+
__privateSet$4(this, _controller, controller);
|
|
2060
|
+
controller.signal.addEventListener("abort", () => this.abort());
|
|
2061
|
+
}
|
|
2062
|
+
/**
|
|
2063
|
+
* Called when the activation is triggered.
|
|
2064
|
+
*/
|
|
2065
|
+
activate(event) {
|
|
2066
|
+
var _a4;
|
|
2067
|
+
(_a4 = __privateGet$4(this, _controller)) == null ? void 0 : _a4.activate(event);
|
|
2068
|
+
}
|
|
2069
|
+
};
|
|
2070
|
+
_controller = /* @__PURE__ */ new WeakMap();
|
|
2021
2071
|
var Modifier = class extends Plugin {
|
|
2022
2072
|
/**
|
|
2023
2073
|
* Creates a new modifier instance.
|
|
@@ -2461,7 +2511,6 @@ function getBoundingRectangle(element) {
|
|
|
2461
2511
|
const { width, height, top, left, bottom, right } = element.getBoundingClientRect();
|
|
2462
2512
|
return { width, height, top, left, bottom, right };
|
|
2463
2513
|
}
|
|
2464
|
-
var canUseDOM$1 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
2465
2514
|
function isWindow(element) {
|
|
2466
2515
|
const elementString = Object.prototype.toString.call(element);
|
|
2467
2516
|
return elementString === "[object Window]" || // In Electron context the Window object serializes to [object global]
|
|
@@ -2590,6 +2639,40 @@ function getVisibleBoundingRectangle(element, boundingClientRect = element.getBo
|
|
|
2590
2639
|
}
|
|
2591
2640
|
return rect;
|
|
2592
2641
|
}
|
|
2642
|
+
function getEventCoordinates(event) {
|
|
2643
|
+
return {
|
|
2644
|
+
x: event.clientX,
|
|
2645
|
+
y: event.clientY
|
|
2646
|
+
};
|
|
2647
|
+
}
|
|
2648
|
+
var canUseDOM$1 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
2649
|
+
function getDocuments(rootDoc = document, seen = /* @__PURE__ */ new Set()) {
|
|
2650
|
+
if (seen.has(rootDoc)) return [];
|
|
2651
|
+
seen.add(rootDoc);
|
|
2652
|
+
const docs = [rootDoc];
|
|
2653
|
+
for (const frame of Array.from(
|
|
2654
|
+
rootDoc.querySelectorAll("iframe, frame")
|
|
2655
|
+
)) {
|
|
2656
|
+
try {
|
|
2657
|
+
const childDoc = frame.contentDocument;
|
|
2658
|
+
if (childDoc && !seen.has(childDoc)) {
|
|
2659
|
+
docs.push(...getDocuments(childDoc, seen));
|
|
2660
|
+
}
|
|
2661
|
+
} catch (e2) {
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
try {
|
|
2665
|
+
const win = rootDoc.defaultView;
|
|
2666
|
+
if (win && win !== window.top) {
|
|
2667
|
+
const parentWin = win.parent;
|
|
2668
|
+
if (parentWin && parentWin.document && parentWin.document !== rootDoc) {
|
|
2669
|
+
docs.push(...getDocuments(parentWin.document, seen));
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
} catch (e2) {
|
|
2673
|
+
}
|
|
2674
|
+
return docs;
|
|
2675
|
+
}
|
|
2593
2676
|
function isSafari() {
|
|
2594
2677
|
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
2595
2678
|
}
|
|
@@ -2639,6 +2722,18 @@ function isIFrameElement(element) {
|
|
|
2639
2722
|
return (element == null ? void 0 : element.tagName) === "IFRAME";
|
|
2640
2723
|
}
|
|
2641
2724
|
var ProxiedElements = /* @__PURE__ */ new WeakMap();
|
|
2725
|
+
function isInteractiveElement(element) {
|
|
2726
|
+
return Boolean(
|
|
2727
|
+
element.closest(`
|
|
2728
|
+
input:not([disabled]),
|
|
2729
|
+
select:not([disabled]),
|
|
2730
|
+
textarea:not([disabled]),
|
|
2731
|
+
button:not([disabled]),
|
|
2732
|
+
a[href],
|
|
2733
|
+
[contenteditable]:not([contenteditable="false"])
|
|
2734
|
+
`)
|
|
2735
|
+
);
|
|
2736
|
+
}
|
|
2642
2737
|
var Listeners = class {
|
|
2643
2738
|
constructor() {
|
|
2644
2739
|
this.entries = /* @__PURE__ */ new Set();
|
|
@@ -2651,14 +2746,17 @@ var Listeners = class {
|
|
|
2651
2746
|
};
|
|
2652
2747
|
}
|
|
2653
2748
|
bind(target, input) {
|
|
2749
|
+
const eventTargets = Array.isArray(target) ? target : [target];
|
|
2654
2750
|
const listeners = Array.isArray(input) ? input : [input];
|
|
2655
2751
|
const entries = [];
|
|
2656
|
-
for (const
|
|
2657
|
-
const
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2752
|
+
for (const target2 of eventTargets) {
|
|
2753
|
+
for (const descriptor2 of listeners) {
|
|
2754
|
+
const { type, listener, options: options2 } = descriptor2;
|
|
2755
|
+
const entry = [target2, descriptor2];
|
|
2756
|
+
target2.addEventListener(type, listener, options2);
|
|
2757
|
+
this.entries.add(entry);
|
|
2758
|
+
entries.push(entry);
|
|
2759
|
+
}
|
|
2662
2760
|
}
|
|
2663
2761
|
return function cleanup() {
|
|
2664
2762
|
for (const [target2, { type, listener, options: options2 }] of entries) {
|
|
@@ -3664,7 +3762,7 @@ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
|
3664
3762
|
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
3665
3763
|
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
3666
3764
|
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
3667
|
-
var __knownSymbol$2 = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
3765
|
+
var __knownSymbol$2 = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
3668
3766
|
var __typeError$2 = (msg) => {
|
|
3669
3767
|
throw TypeError(msg);
|
|
3670
3768
|
};
|
|
@@ -4979,9 +5077,8 @@ var defaults = Object.freeze({
|
|
|
4979
5077
|
left: ["ArrowLeft"],
|
|
4980
5078
|
right: ["ArrowRight"]
|
|
4981
5079
|
},
|
|
4982
|
-
|
|
5080
|
+
preventActivation(event, source) {
|
|
4983
5081
|
var _a4;
|
|
4984
|
-
const { event, source } = args;
|
|
4985
5082
|
const target = (_a4 = source.handle) != null ? _a4 : source.element;
|
|
4986
5083
|
return event.target === target;
|
|
4987
5084
|
}
|
|
@@ -5006,7 +5103,7 @@ var _KeyboardSensor = class _KeyboardSensor2 extends Sensor {
|
|
|
5006
5103
|
}
|
|
5007
5104
|
const {
|
|
5008
5105
|
keyboardCodes = defaults.keyboardCodes,
|
|
5009
|
-
|
|
5106
|
+
preventActivation = defaults.preventActivation
|
|
5010
5107
|
} = options3 != null ? options3 : {};
|
|
5011
5108
|
if (!keyboardCodes.start.includes(event.code)) {
|
|
5012
5109
|
return;
|
|
@@ -5014,9 +5111,8 @@ var _KeyboardSensor = class _KeyboardSensor2 extends Sensor {
|
|
|
5014
5111
|
if (!this.manager.dragOperation.status.idle) {
|
|
5015
5112
|
return;
|
|
5016
5113
|
}
|
|
5017
|
-
if (
|
|
5018
|
-
|
|
5019
|
-
}
|
|
5114
|
+
if (preventActivation == null ? void 0 : preventActivation(event, source)) return;
|
|
5115
|
+
this.handleStart(event, source, options3);
|
|
5020
5116
|
};
|
|
5021
5117
|
}
|
|
5022
5118
|
bind(source, options2 = this.options) {
|
|
@@ -5156,6 +5252,89 @@ var KeyboardSensor = _KeyboardSensor;
|
|
|
5156
5252
|
function isKeycode(event, codes) {
|
|
5157
5253
|
return codes.includes(event.code);
|
|
5158
5254
|
}
|
|
5255
|
+
var _coordinates;
|
|
5256
|
+
var DistanceConstraint = class extends ActivationConstraint {
|
|
5257
|
+
constructor() {
|
|
5258
|
+
super(...arguments);
|
|
5259
|
+
__privateAdd$2(this, _coordinates);
|
|
5260
|
+
}
|
|
5261
|
+
onEvent(event) {
|
|
5262
|
+
switch (event.type) {
|
|
5263
|
+
case "pointerdown":
|
|
5264
|
+
__privateSet$2(this, _coordinates, getEventCoordinates(event));
|
|
5265
|
+
break;
|
|
5266
|
+
case "pointermove":
|
|
5267
|
+
if (!__privateGet$2(this, _coordinates)) return;
|
|
5268
|
+
const { x, y: y2 } = getEventCoordinates(event);
|
|
5269
|
+
const delta = {
|
|
5270
|
+
x: x - __privateGet$2(this, _coordinates).x,
|
|
5271
|
+
y: y2 - __privateGet$2(this, _coordinates).y
|
|
5272
|
+
};
|
|
5273
|
+
const { tolerance } = this.options;
|
|
5274
|
+
if (tolerance && exceedsDistance(delta, tolerance)) {
|
|
5275
|
+
this.abort();
|
|
5276
|
+
return;
|
|
5277
|
+
}
|
|
5278
|
+
if (exceedsDistance(delta, this.options.value)) {
|
|
5279
|
+
this.activate(event);
|
|
5280
|
+
}
|
|
5281
|
+
break;
|
|
5282
|
+
case "pointerup":
|
|
5283
|
+
this.abort();
|
|
5284
|
+
break;
|
|
5285
|
+
}
|
|
5286
|
+
}
|
|
5287
|
+
abort() {
|
|
5288
|
+
__privateSet$2(this, _coordinates, void 0);
|
|
5289
|
+
}
|
|
5290
|
+
};
|
|
5291
|
+
_coordinates = /* @__PURE__ */ new WeakMap();
|
|
5292
|
+
var _timeout2, _coordinates2;
|
|
5293
|
+
var DelayConstraint = class extends ActivationConstraint {
|
|
5294
|
+
constructor() {
|
|
5295
|
+
super(...arguments);
|
|
5296
|
+
__privateAdd$2(this, _timeout2);
|
|
5297
|
+
__privateAdd$2(this, _coordinates2);
|
|
5298
|
+
}
|
|
5299
|
+
onEvent(event) {
|
|
5300
|
+
switch (event.type) {
|
|
5301
|
+
case "pointerdown":
|
|
5302
|
+
__privateSet$2(this, _coordinates2, getEventCoordinates(event));
|
|
5303
|
+
__privateSet$2(this, _timeout2, setTimeout(
|
|
5304
|
+
() => this.activate(event),
|
|
5305
|
+
this.options.value
|
|
5306
|
+
));
|
|
5307
|
+
break;
|
|
5308
|
+
case "pointermove":
|
|
5309
|
+
if (!__privateGet$2(this, _coordinates2)) return;
|
|
5310
|
+
const { x, y: y2 } = getEventCoordinates(event);
|
|
5311
|
+
const delta = {
|
|
5312
|
+
x: x - __privateGet$2(this, _coordinates2).x,
|
|
5313
|
+
y: y2 - __privateGet$2(this, _coordinates2).y
|
|
5314
|
+
};
|
|
5315
|
+
if (exceedsDistance(delta, this.options.tolerance)) {
|
|
5316
|
+
this.abort();
|
|
5317
|
+
}
|
|
5318
|
+
break;
|
|
5319
|
+
case "pointerup":
|
|
5320
|
+
this.abort();
|
|
5321
|
+
break;
|
|
5322
|
+
}
|
|
5323
|
+
}
|
|
5324
|
+
abort() {
|
|
5325
|
+
if (__privateGet$2(this, _timeout2)) {
|
|
5326
|
+
clearTimeout(__privateGet$2(this, _timeout2));
|
|
5327
|
+
__privateSet$2(this, _coordinates2, void 0);
|
|
5328
|
+
__privateSet$2(this, _timeout2, void 0);
|
|
5329
|
+
}
|
|
5330
|
+
}
|
|
5331
|
+
};
|
|
5332
|
+
_timeout2 = /* @__PURE__ */ new WeakMap();
|
|
5333
|
+
_coordinates2 = /* @__PURE__ */ new WeakMap();
|
|
5334
|
+
var PointerActivationConstraints = class {
|
|
5335
|
+
};
|
|
5336
|
+
PointerActivationConstraints.Delay = DelayConstraint;
|
|
5337
|
+
PointerActivationConstraints.Distance = DistanceConstraint;
|
|
5159
5338
|
var defaults2 = Object.freeze({
|
|
5160
5339
|
activationConstraints(event, source) {
|
|
5161
5340
|
var _a4;
|
|
@@ -5164,29 +5343,37 @@ var defaults2 = Object.freeze({
|
|
|
5164
5343
|
return void 0;
|
|
5165
5344
|
}
|
|
5166
5345
|
if (pointerType === "touch") {
|
|
5167
|
-
return
|
|
5168
|
-
|
|
5169
|
-
|
|
5346
|
+
return [
|
|
5347
|
+
new PointerActivationConstraints.Delay({ value: 250, tolerance: 5 })
|
|
5348
|
+
];
|
|
5170
5349
|
}
|
|
5171
5350
|
if (isTextInput(target) && !event.defaultPrevented) {
|
|
5172
|
-
return
|
|
5173
|
-
|
|
5174
|
-
|
|
5351
|
+
return [
|
|
5352
|
+
new PointerActivationConstraints.Delay({ value: 200, tolerance: 0 })
|
|
5353
|
+
];
|
|
5175
5354
|
}
|
|
5176
|
-
return
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5355
|
+
return [
|
|
5356
|
+
new PointerActivationConstraints.Delay({ value: 200, tolerance: 10 }),
|
|
5357
|
+
new PointerActivationConstraints.Distance({ value: 5 })
|
|
5358
|
+
];
|
|
5359
|
+
},
|
|
5360
|
+
preventActivation(event, source) {
|
|
5361
|
+
var _a4;
|
|
5362
|
+
const { target } = event;
|
|
5363
|
+
if (target === source.element) return false;
|
|
5364
|
+
if (target === source.handle) return false;
|
|
5365
|
+
if (!isElement(target)) return false;
|
|
5366
|
+
if ((_a4 = source.handle) == null ? void 0 : _a4.contains(target)) return false;
|
|
5367
|
+
return isInteractiveElement(target);
|
|
5180
5368
|
}
|
|
5181
5369
|
});
|
|
5182
|
-
var _cleanup
|
|
5370
|
+
var _cleanup;
|
|
5183
5371
|
var _PointerSensor = class _PointerSensor2 extends Sensor {
|
|
5184
5372
|
constructor(manager, options2) {
|
|
5185
5373
|
super(manager);
|
|
5186
5374
|
this.manager = manager;
|
|
5187
5375
|
this.options = options2;
|
|
5188
5376
|
__privateAdd$2(this, _cleanup, /* @__PURE__ */ new Set());
|
|
5189
|
-
__privateAdd$2(this, _clearTimeout);
|
|
5190
5377
|
this.listeners = new Listeners();
|
|
5191
5378
|
this.latest = {
|
|
5192
5379
|
event: void 0,
|
|
@@ -5236,36 +5423,33 @@ var _PointerSensor = class _PointerSensor2 extends Sensor {
|
|
|
5236
5423
|
});
|
|
5237
5424
|
return unbind;
|
|
5238
5425
|
}
|
|
5239
|
-
handlePointerDown(event, source, options2
|
|
5426
|
+
handlePointerDown(event, source, options2) {
|
|
5240
5427
|
if (this.disabled || !event.isPrimary || event.button !== 0 || !isElement(event.target) || source.disabled || isCapturedBySensor(event) || !this.manager.dragOperation.status.idle) {
|
|
5241
5428
|
return;
|
|
5242
5429
|
}
|
|
5430
|
+
const { preventActivation = defaults2.preventActivation } = options2 != null ? options2 : {};
|
|
5431
|
+
if (preventActivation == null ? void 0 : preventActivation(event, source)) {
|
|
5432
|
+
return;
|
|
5433
|
+
}
|
|
5243
5434
|
const { target } = event;
|
|
5244
5435
|
const isNativeDraggable = isHTMLElement(target) && target.draggable && target.getAttribute("draggable") === "true";
|
|
5245
5436
|
const offset = getFrameTransform(source.element);
|
|
5437
|
+
const { x, y: y2 } = getEventCoordinates(event);
|
|
5246
5438
|
this.initialCoordinates = {
|
|
5247
|
-
x:
|
|
5248
|
-
y:
|
|
5439
|
+
x: x * offset.scaleX + offset.x,
|
|
5440
|
+
y: y2 * offset.scaleY + offset.y
|
|
5249
5441
|
};
|
|
5250
5442
|
const constraints = this.activationConstraints(event, source);
|
|
5251
5443
|
event.sensor = this;
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
__privateSet$2(this, _clearTimeout, () => {
|
|
5262
|
-
clearTimeout(timeout2);
|
|
5263
|
-
__privateSet$2(this, _clearTimeout, void 0);
|
|
5264
|
-
});
|
|
5265
|
-
}
|
|
5266
|
-
}
|
|
5267
|
-
const ownerDocument = getDocument(event.target);
|
|
5268
|
-
const unbindListeners = this.listeners.bind(ownerDocument, [
|
|
5444
|
+
const controller = new ActivationController(
|
|
5445
|
+
constraints,
|
|
5446
|
+
(event2) => this.handleStart(source, event2)
|
|
5447
|
+
);
|
|
5448
|
+
controller.signal.onabort = () => this.handleCancel(event);
|
|
5449
|
+
controller.onEvent(event);
|
|
5450
|
+
this.controller = controller;
|
|
5451
|
+
const documents = getDocuments();
|
|
5452
|
+
const unbindListeners = this.listeners.bind(documents, [
|
|
5269
5453
|
{
|
|
5270
5454
|
type: "pointermove",
|
|
5271
5455
|
listener: (event2) => this.handlePointerMove(event2, source)
|
|
@@ -5287,50 +5471,27 @@ var _PointerSensor = class _PointerSensor2 extends Sensor {
|
|
|
5287
5471
|
}
|
|
5288
5472
|
]);
|
|
5289
5473
|
const cleanup = () => {
|
|
5290
|
-
var _a4;
|
|
5291
5474
|
unbindListeners();
|
|
5292
|
-
(_a4 = __privateGet$2(this, _clearTimeout)) == null ? void 0 : _a4.call(this);
|
|
5293
5475
|
this.initialCoordinates = void 0;
|
|
5294
5476
|
};
|
|
5295
5477
|
__privateGet$2(this, _cleanup).add(cleanup);
|
|
5296
5478
|
}
|
|
5297
5479
|
handlePointerMove(event, source) {
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
coordinates.x = coordinates.x * offset.scaleX + offset.x;
|
|
5304
|
-
coordinates.y = coordinates.y * offset.scaleY + offset.y;
|
|
5480
|
+
var _a4, _b2;
|
|
5481
|
+
if (((_a4 = this.controller) == null ? void 0 : _a4.activated) === false) {
|
|
5482
|
+
(_b2 = this.controller) == null ? void 0 : _b2.onEvent(event);
|
|
5483
|
+
return;
|
|
5484
|
+
}
|
|
5305
5485
|
if (this.manager.dragOperation.status.dragging) {
|
|
5486
|
+
const coordinates = getEventCoordinates(event);
|
|
5487
|
+
const offset = getFrameTransform(source.element);
|
|
5488
|
+
coordinates.x = coordinates.x * offset.scaleX + offset.x;
|
|
5489
|
+
coordinates.y = coordinates.y * offset.scaleY + offset.y;
|
|
5306
5490
|
event.preventDefault();
|
|
5307
5491
|
event.stopPropagation();
|
|
5308
5492
|
this.latest.event = event;
|
|
5309
5493
|
this.latest.coordinates = coordinates;
|
|
5310
5494
|
scheduler.schedule(this.handleMove);
|
|
5311
|
-
return;
|
|
5312
|
-
}
|
|
5313
|
-
if (!this.initialCoordinates) {
|
|
5314
|
-
return;
|
|
5315
|
-
}
|
|
5316
|
-
const delta = {
|
|
5317
|
-
x: coordinates.x - this.initialCoordinates.x,
|
|
5318
|
-
y: coordinates.y - this.initialCoordinates.y
|
|
5319
|
-
};
|
|
5320
|
-
const constraints = this.activationConstraints(event, source);
|
|
5321
|
-
const { distance, delay } = constraints != null ? constraints : {};
|
|
5322
|
-
if (distance) {
|
|
5323
|
-
if (distance.tolerance != null && exceedsDistance(delta, distance.tolerance)) {
|
|
5324
|
-
return this.handleCancel(event);
|
|
5325
|
-
}
|
|
5326
|
-
if (exceedsDistance(delta, distance.value)) {
|
|
5327
|
-
return this.handleStart(source, event);
|
|
5328
|
-
}
|
|
5329
|
-
}
|
|
5330
|
-
if (delay) {
|
|
5331
|
-
if (exceedsDistance(delta, delay.tolerance)) {
|
|
5332
|
-
return this.handleCancel(event);
|
|
5333
|
-
}
|
|
5334
5495
|
}
|
|
5335
5496
|
}
|
|
5336
5497
|
handlePointerUp(event) {
|
|
@@ -5350,9 +5511,7 @@ var _PointerSensor = class _PointerSensor2 extends Sensor {
|
|
|
5350
5511
|
}
|
|
5351
5512
|
}
|
|
5352
5513
|
handleStart(source, event) {
|
|
5353
|
-
var _a4;
|
|
5354
5514
|
const { manager, initialCoordinates } = this;
|
|
5355
|
-
(_a4 = __privateGet$2(this, _clearTimeout)) == null ? void 0 : _a4.call(this);
|
|
5356
5515
|
if (!initialCoordinates || !manager.dragOperation.status.idle) {
|
|
5357
5516
|
return;
|
|
5358
5517
|
}
|
|
@@ -5369,7 +5528,8 @@ var _PointerSensor = class _PointerSensor2 extends Sensor {
|
|
|
5369
5528
|
const ownerDocument = getDocument(event.target);
|
|
5370
5529
|
const pointerCaptureTarget = ownerDocument.body;
|
|
5371
5530
|
pointerCaptureTarget.setPointerCapture(event.pointerId);
|
|
5372
|
-
const
|
|
5531
|
+
const listenerTargets = isElement(event.target) ? [event.target, ownerDocument.body] : ownerDocument.body;
|
|
5532
|
+
const unbind = this.listeners.bind(listenerTargets, [
|
|
5373
5533
|
{
|
|
5374
5534
|
// Prevent scrolling on touch devices
|
|
5375
5535
|
type: "touchmove",
|
|
@@ -5390,13 +5550,6 @@ var _PointerSensor = class _PointerSensor2 extends Sensor {
|
|
|
5390
5550
|
{
|
|
5391
5551
|
type: "keydown",
|
|
5392
5552
|
listener: this.handleKeyDown
|
|
5393
|
-
},
|
|
5394
|
-
{
|
|
5395
|
-
type: "lostpointercapture",
|
|
5396
|
-
listener: (event2) => {
|
|
5397
|
-
if (event2.target !== pointerCaptureTarget) return;
|
|
5398
|
-
this.handlePointerUp(event2);
|
|
5399
|
-
}
|
|
5400
5553
|
}
|
|
5401
5554
|
]);
|
|
5402
5555
|
__privateGet$2(this, _cleanup).add(unbind);
|
|
@@ -5422,7 +5575,6 @@ var _PointerSensor = class _PointerSensor2 extends Sensor {
|
|
|
5422
5575
|
}
|
|
5423
5576
|
};
|
|
5424
5577
|
_cleanup = /* @__PURE__ */ new WeakMap();
|
|
5425
|
-
_clearTimeout = /* @__PURE__ */ new WeakMap();
|
|
5426
5578
|
_PointerSensor.configure = configurator(_PointerSensor);
|
|
5427
5579
|
_PointerSensor.defaults = defaults2;
|
|
5428
5580
|
var PointerSensor = _PointerSensor;
|
|
@@ -5608,7 +5760,7 @@ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
|
5608
5760
|
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
5609
5761
|
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
5610
5762
|
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
5611
|
-
var __knownSymbol$1 = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
5763
|
+
var __knownSymbol$1 = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
5612
5764
|
var __typeError$1 = (msg) => {
|
|
5613
5765
|
throw TypeError(msg);
|
|
5614
5766
|
};
|
|
@@ -6566,9 +6718,7 @@ function DragDropProvider(_a22) {
|
|
|
6566
6718
|
"onDragOver",
|
|
6567
6719
|
"onDragEnd"
|
|
6568
6720
|
]);
|
|
6569
|
-
var _a32;
|
|
6570
6721
|
const rendererRef = useRef(null);
|
|
6571
|
-
const [manager, setManager] = useState((_a32 = input.manager) != null ? _a32 : null);
|
|
6572
6722
|
const { plugins, modifiers, sensors } = input;
|
|
6573
6723
|
const handleBeforeDragStart = useLatest(onBeforeDragStart);
|
|
6574
6724
|
const handleDragStart = useLatest(onDragStart);
|
|
@@ -6576,53 +6726,57 @@ function DragDropProvider(_a22) {
|
|
|
6576
6726
|
const handleDragMove = useLatest(onDragMove);
|
|
6577
6727
|
const handleDragEnd = useLatest(onDragEnd);
|
|
6578
6728
|
const handleCollision = useLatest(onCollision);
|
|
6729
|
+
const manager = useStableInstance(() => {
|
|
6730
|
+
var _a32;
|
|
6731
|
+
return (_a32 = input.manager) != null ? _a32 : new DragDropManager2(input);
|
|
6732
|
+
});
|
|
6579
6733
|
useEffect(() => {
|
|
6580
|
-
var _a4;
|
|
6581
6734
|
if (!rendererRef.current) throw new Error("Renderer not found");
|
|
6582
6735
|
const { renderer, trackRendering } = rendererRef.current;
|
|
6583
|
-
const
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6736
|
+
const { monitor } = manager;
|
|
6737
|
+
manager.renderer = renderer;
|
|
6738
|
+
const listeners = [
|
|
6739
|
+
monitor.addEventListener("beforedragstart", (event) => {
|
|
6740
|
+
const callback = handleBeforeDragStart.current;
|
|
6741
|
+
if (callback) {
|
|
6742
|
+
trackRendering(() => callback(event, manager));
|
|
6743
|
+
}
|
|
6744
|
+
}),
|
|
6745
|
+
monitor.addEventListener(
|
|
6746
|
+
"dragstart",
|
|
6747
|
+
(event) => {
|
|
6748
|
+
var _a32;
|
|
6749
|
+
return (_a32 = handleDragStart.current) == null ? void 0 : _a32.call(handleDragStart, event, manager);
|
|
6750
|
+
}
|
|
6751
|
+
),
|
|
6752
|
+
monitor.addEventListener("dragover", (event) => {
|
|
6753
|
+
const callback = handleDragOver.current;
|
|
6754
|
+
if (callback) {
|
|
6755
|
+
trackRendering(() => callback(event, manager));
|
|
6756
|
+
}
|
|
6757
|
+
}),
|
|
6758
|
+
monitor.addEventListener("dragmove", (event) => {
|
|
6759
|
+
const callback = handleDragMove.current;
|
|
6760
|
+
if (callback) {
|
|
6761
|
+
trackRendering(() => callback(event, manager));
|
|
6762
|
+
}
|
|
6763
|
+
}),
|
|
6764
|
+
monitor.addEventListener("dragend", (event) => {
|
|
6765
|
+
const callback = handleDragEnd.current;
|
|
6766
|
+
if (callback) {
|
|
6767
|
+
trackRendering(() => callback(event, manager));
|
|
6768
|
+
}
|
|
6769
|
+
}),
|
|
6770
|
+
monitor.addEventListener(
|
|
6771
|
+
"collision",
|
|
6772
|
+
(event) => {
|
|
6773
|
+
var _a32;
|
|
6774
|
+
return (_a32 = handleCollision.current) == null ? void 0 : _a32.call(handleCollision, event, manager);
|
|
6775
|
+
}
|
|
6776
|
+
)
|
|
6777
|
+
];
|
|
6778
|
+
return () => listeners.forEach((dispose) => dispose());
|
|
6779
|
+
}, [manager]);
|
|
6626
6780
|
useOnValueChange(
|
|
6627
6781
|
plugins,
|
|
6628
6782
|
() => manager && (manager.plugins = plugins != null ? plugins : defaultPreset.plugins),
|
|
@@ -6643,6 +6797,19 @@ function DragDropProvider(_a22) {
|
|
|
6643
6797
|
children
|
|
6644
6798
|
] });
|
|
6645
6799
|
}
|
|
6800
|
+
function useStableInstance(create) {
|
|
6801
|
+
const ref = useRef(null);
|
|
6802
|
+
if (!ref.current) {
|
|
6803
|
+
ref.current = create();
|
|
6804
|
+
}
|
|
6805
|
+
useInsertionEffect(() => {
|
|
6806
|
+
return () => {
|
|
6807
|
+
var _a22;
|
|
6808
|
+
return (_a22 = ref.current) == null ? void 0 : _a22.destroy();
|
|
6809
|
+
};
|
|
6810
|
+
}, []);
|
|
6811
|
+
return ref.current;
|
|
6812
|
+
}
|
|
6646
6813
|
function useDragDropManager() {
|
|
6647
6814
|
return useContext(DragDropContext);
|
|
6648
6815
|
}
|
|
@@ -6659,7 +6826,7 @@ function useInstance(initializer) {
|
|
|
6659
6826
|
var __create = Object.create;
|
|
6660
6827
|
var __defProp2 = Object.defineProperty;
|
|
6661
6828
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6662
|
-
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
6829
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
6663
6830
|
var __typeError = (msg) => {
|
|
6664
6831
|
throw TypeError(msg);
|
|
6665
6832
|
};
|
|
@@ -7223,6 +7390,7 @@ function mutate(items, event, mutation) {
|
|
|
7223
7390
|
function move(items, event) {
|
|
7224
7391
|
return mutate(items, event, arrayMove);
|
|
7225
7392
|
}
|
|
7393
|
+
const removeIds = (arr) => arr.map(({ id, ...item }) => item);
|
|
7226
7394
|
const SortableItem = ({ id, index, disabled, children, axis }) => {
|
|
7227
7395
|
const [element, setElement] = useState(null);
|
|
7228
7396
|
const handleRef = useRef(null);
|
|
@@ -7282,7 +7450,6 @@ const SortableItem = ({ id, index, disabled, children, axis }) => {
|
|
|
7282
7450
|
* @preserve
|
|
7283
7451
|
*/
|
|
7284
7452
|
const Draggable3 = (props) => {
|
|
7285
|
-
useId("draggable-list-item-");
|
|
7286
7453
|
const {
|
|
7287
7454
|
children,
|
|
7288
7455
|
items: rawItems,
|
|
@@ -7297,9 +7464,12 @@ const Draggable3 = (props) => {
|
|
|
7297
7464
|
if (typeof rawItems === "undefined" || rawItems === null || !Array.isArray(rawItems)) {
|
|
7298
7465
|
console.warn(__("Draggable: 'items' are not an array or are undefined!", "eightshift-ui-components"));
|
|
7299
7466
|
}
|
|
7300
|
-
const [items, setItems] = useState(rawItems);
|
|
7467
|
+
const [items, setItems] = useState(rawItems.map((item) => ({ ...item, id: item?.id || randomId(6) })));
|
|
7301
7468
|
useEffect(() => {
|
|
7302
|
-
|
|
7469
|
+
if (JSON.stringify(rawItems) === JSON.stringify(removeIds(items))) {
|
|
7470
|
+
return;
|
|
7471
|
+
}
|
|
7472
|
+
setItems(rawItems.map((item) => ({ ...item, id: randomId(6) })));
|
|
7303
7473
|
}, [rawItems]);
|
|
7304
7474
|
if (hidden) {
|
|
7305
7475
|
return null;
|
|
@@ -7312,18 +7482,20 @@ const Draggable3 = (props) => {
|
|
|
7312
7482
|
children: /* @__PURE__ */ jsx(
|
|
7313
7483
|
DragDropProvider,
|
|
7314
7484
|
{
|
|
7315
|
-
onDragOver: (event) => setItems((items2) => move(items2, event)),
|
|
7316
7485
|
onDragEnd: (event) => {
|
|
7317
7486
|
if (event?.canceled) {
|
|
7318
7487
|
return;
|
|
7319
7488
|
}
|
|
7320
|
-
setItems((items2) =>
|
|
7321
|
-
|
|
7489
|
+
setItems((items2) => {
|
|
7490
|
+
const newItems = move(items2, event);
|
|
7491
|
+
onChange(removeIds(newItems));
|
|
7492
|
+
return newItems;
|
|
7493
|
+
});
|
|
7322
7494
|
},
|
|
7323
|
-
children: items.map((item, index) => /* @__PURE__ */ jsx(
|
|
7495
|
+
children: items.map(({ id, ...item }, index) => /* @__PURE__ */ jsx(
|
|
7324
7496
|
SortableItem,
|
|
7325
7497
|
{
|
|
7326
|
-
id
|
|
7498
|
+
id,
|
|
7327
7499
|
index,
|
|
7328
7500
|
item,
|
|
7329
7501
|
disabled: noReorder,
|
|
@@ -7336,20 +7508,21 @@ const Draggable3 = (props) => {
|
|
|
7336
7508
|
...updated[index],
|
|
7337
7509
|
...newValue
|
|
7338
7510
|
};
|
|
7339
|
-
onChange(updated);
|
|
7340
7511
|
setItems(updated);
|
|
7512
|
+
onChange(removeIds(updated));
|
|
7341
7513
|
},
|
|
7342
7514
|
itemIndex: index,
|
|
7343
7515
|
deleteItem: () => {
|
|
7344
7516
|
setItems([...items].filter((_2, i2) => i2 !== index));
|
|
7345
|
-
onChange([...items].filter((_2, i2) => i2 !== index));
|
|
7517
|
+
onChange(removeIds([...items].filter((_2, i2) => i2 !== index)));
|
|
7346
7518
|
if (onAfterItemRemove) {
|
|
7347
|
-
|
|
7519
|
+
const { id: id2, ...restItem } = item;
|
|
7520
|
+
onAfterItemRemove(restItem);
|
|
7348
7521
|
}
|
|
7349
7522
|
}
|
|
7350
7523
|
}) })
|
|
7351
7524
|
},
|
|
7352
|
-
|
|
7525
|
+
id
|
|
7353
7526
|
))
|
|
7354
7527
|
}
|
|
7355
7528
|
)
|