funda-ui 4.5.680 → 4.5.682
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/DragDropList/index.css +188 -0
- package/DragDropList/index.d.ts +43 -0
- package/DragDropList/index.js +1589 -0
- package/MultipleSelect/index.css +237 -144
- package/MultipleSelect/index.d.ts +23 -10
- package/MultipleSelect/index.js +2242 -1225
- package/README.md +3 -1
- package/Utils/useBoundedDrag.d.ts +127 -0
- package/Utils/useBoundedDrag.js +382 -0
- package/Utils/useDragDropPosition.d.ts +169 -0
- package/Utils/useDragDropPosition.js +456 -0
- package/all.d.ts +1 -0
- package/all.js +1 -0
- package/lib/cjs/DragDropList/index.d.ts +43 -0
- package/lib/cjs/DragDropList/index.js +1589 -0
- package/lib/cjs/MultipleSelect/index.d.ts +23 -10
- package/lib/cjs/MultipleSelect/index.js +2242 -1225
- package/lib/cjs/Utils/useBoundedDrag.d.ts +127 -0
- package/lib/cjs/Utils/useBoundedDrag.js +382 -0
- package/lib/cjs/Utils/useDragDropPosition.d.ts +169 -0
- package/lib/cjs/Utils/useDragDropPosition.js +456 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/css/DragDropList/index.css +188 -0
- package/lib/css/MultipleSelect/index.css +237 -144
- package/lib/esm/DragDropList/index.scss +245 -0
- package/lib/esm/DragDropList/index.tsx +493 -0
- package/lib/esm/MultipleSelect/index.scss +288 -183
- package/lib/esm/MultipleSelect/index.tsx +304 -166
- package/lib/esm/MultipleSelect/utils/func.ts +21 -1
- package/lib/esm/Utils/hooks/useBoundedDrag.tsx +303 -0
- package/lib/esm/Utils/hooks/useDragDropPosition.tsx +420 -0
- package/lib/esm/index.js +1 -0
- package/package.json +1 -1
- package/lib/esm/MultipleSelect/ItemList.tsx +0 -323
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory(require("react"));
|
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
|
5
|
+
define(["react"], factory);
|
|
6
|
+
else if(typeof exports === 'object')
|
|
7
|
+
exports["RPB"] = factory(require("react"));
|
|
8
|
+
else
|
|
9
|
+
root["RPB"] = factory(root["React"]);
|
|
10
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__787__) => {
|
|
11
|
+
return /******/ (() => { // webpackBootstrap
|
|
12
|
+
/******/ "use strict";
|
|
13
|
+
/******/ var __webpack_modules__ = ({
|
|
14
|
+
|
|
15
|
+
/***/ 787:
|
|
16
|
+
/***/ ((module) => {
|
|
17
|
+
|
|
18
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
|
|
19
|
+
|
|
20
|
+
/***/ })
|
|
21
|
+
|
|
22
|
+
/******/ });
|
|
23
|
+
/************************************************************************/
|
|
24
|
+
/******/ // The module cache
|
|
25
|
+
/******/ var __webpack_module_cache__ = {};
|
|
26
|
+
/******/
|
|
27
|
+
/******/ // The require function
|
|
28
|
+
/******/ function __webpack_require__(moduleId) {
|
|
29
|
+
/******/ // Check if module is in cache
|
|
30
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
31
|
+
/******/ if (cachedModule !== undefined) {
|
|
32
|
+
/******/ return cachedModule.exports;
|
|
33
|
+
/******/ }
|
|
34
|
+
/******/ // Create a new module (and put it into the cache)
|
|
35
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
36
|
+
/******/ // no module.id needed
|
|
37
|
+
/******/ // no module.loaded needed
|
|
38
|
+
/******/ exports: {}
|
|
39
|
+
/******/ };
|
|
40
|
+
/******/
|
|
41
|
+
/******/ // Execute the module function
|
|
42
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
43
|
+
/******/
|
|
44
|
+
/******/ // Return the exports of the module
|
|
45
|
+
/******/ return module.exports;
|
|
46
|
+
/******/ }
|
|
47
|
+
/******/
|
|
48
|
+
/************************************************************************/
|
|
49
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
50
|
+
/******/ (() => {
|
|
51
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
52
|
+
/******/ __webpack_require__.n = (module) => {
|
|
53
|
+
/******/ var getter = module && module.__esModule ?
|
|
54
|
+
/******/ () => (module['default']) :
|
|
55
|
+
/******/ () => (module);
|
|
56
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
57
|
+
/******/ return getter;
|
|
58
|
+
/******/ };
|
|
59
|
+
/******/ })();
|
|
60
|
+
/******/
|
|
61
|
+
/******/ /* webpack/runtime/define property getters */
|
|
62
|
+
/******/ (() => {
|
|
63
|
+
/******/ // define getter functions for harmony exports
|
|
64
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
65
|
+
/******/ for(var key in definition) {
|
|
66
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
67
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
68
|
+
/******/ }
|
|
69
|
+
/******/ }
|
|
70
|
+
/******/ };
|
|
71
|
+
/******/ })();
|
|
72
|
+
/******/
|
|
73
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
74
|
+
/******/ (() => {
|
|
75
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
76
|
+
/******/ })();
|
|
77
|
+
/******/
|
|
78
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
79
|
+
/******/ (() => {
|
|
80
|
+
/******/ // define __esModule on exports
|
|
81
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
82
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
83
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
84
|
+
/******/ }
|
|
85
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
86
|
+
/******/ };
|
|
87
|
+
/******/ })();
|
|
88
|
+
/******/
|
|
89
|
+
/************************************************************************/
|
|
90
|
+
var __webpack_exports__ = {};
|
|
91
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
92
|
+
(() => {
|
|
93
|
+
__webpack_require__.r(__webpack_exports__);
|
|
94
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
95
|
+
/* harmony export */ "useDragDropPosition": () => (/* binding */ useDragDropPosition)
|
|
96
|
+
/* harmony export */ });
|
|
97
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(787);
|
|
98
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
99
|
+
/**
|
|
100
|
+
* Drag Drop Object
|
|
101
|
+
*
|
|
102
|
+
* @usage:
|
|
103
|
+
|
|
104
|
+
import { useState, useCallback } from 'react';
|
|
105
|
+
import { useDragDropPosition } from '@/utils/hooks/useDragDropPosition';
|
|
106
|
+
|
|
107
|
+
const App = () => {
|
|
108
|
+
|
|
109
|
+
const [show, setShow] = useState<boolean>(false);
|
|
110
|
+
|
|
111
|
+
// drag & drop
|
|
112
|
+
//---------------、
|
|
113
|
+
const moveDelay = 150;
|
|
114
|
+
const pin = false;
|
|
115
|
+
const dimension = 32; // onject with dimension
|
|
116
|
+
const [objPosition, setObjPosition] = useState<{
|
|
117
|
+
x: number;
|
|
118
|
+
y: number;
|
|
119
|
+
}>({ x: 0, y: 0 });
|
|
120
|
+
const [isDragged, setIsDragged] = useState<boolean>(false);
|
|
121
|
+
const [isPressed, setIsPressed] = useState<boolean>(false);
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
const { setup, ref } = useDragDropPosition({
|
|
125
|
+
// usePercentage: true, // Enable percentage values
|
|
126
|
+
dimension,
|
|
127
|
+
onDragEnd: ({position, hasContainer}) => {
|
|
128
|
+
const { left, top } = position;
|
|
129
|
+
setObjPosition({
|
|
130
|
+
x: left || 0,
|
|
131
|
+
y: (top || 0),
|
|
132
|
+
});
|
|
133
|
+
setIsPressed(false);
|
|
134
|
+
setIsDragged(false);
|
|
135
|
+
|
|
136
|
+
// click event here (restore)
|
|
137
|
+
setShow(false);
|
|
138
|
+
},
|
|
139
|
+
onDragStart: ({position, hasContainer}) => {
|
|
140
|
+
const { left, top } = position;
|
|
141
|
+
setObjPosition({
|
|
142
|
+
x: left || 0,
|
|
143
|
+
y: (top || 0),
|
|
144
|
+
});
|
|
145
|
+
setIsDragged(true);
|
|
146
|
+
|
|
147
|
+
// click event here (restore)
|
|
148
|
+
setShow(false);
|
|
149
|
+
},
|
|
150
|
+
onInit: ({position, hasContainer}) => {
|
|
151
|
+
const { left, top } = position;
|
|
152
|
+
setObjPosition({
|
|
153
|
+
x: left || 0,
|
|
154
|
+
y: (top || 0),
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
onPointerDown: () => {
|
|
158
|
+
setIsPressed(true);
|
|
159
|
+
},
|
|
160
|
+
onPointerUp: useCallback(() => {
|
|
161
|
+
setIsPressed(false);
|
|
162
|
+
|
|
163
|
+
// click event here
|
|
164
|
+
setShow((prev) => !prev);
|
|
165
|
+
|
|
166
|
+
}, []),
|
|
167
|
+
onMove: ({position, hasContainer}) => {
|
|
168
|
+
const { left, top } = position;
|
|
169
|
+
setObjPosition({
|
|
170
|
+
x: left || 0,
|
|
171
|
+
y: (top || 0),
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
pin,
|
|
175
|
+
moveDelay
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
<>
|
|
184
|
+
|
|
185
|
+
<div
|
|
186
|
+
ref={setup}
|
|
187
|
+
className="float-btn"
|
|
188
|
+
style={{position: 'fixed', left: '50%', top: '50%', zIndex: 1000, background: 'red'}}
|
|
189
|
+
|
|
190
|
+
>Move Here<small>{JSON.stringify(objPosition)}</small><br /><strong>{show ? 'Clicked' : 'None'}</strong></div>
|
|
191
|
+
|
|
192
|
+
</>
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
const App2 = () => {
|
|
200
|
+
|
|
201
|
+
const dragdropContainerRef = useRef<HTMLDivElement>(null);
|
|
202
|
+
....
|
|
203
|
+
|
|
204
|
+
const { setup, ref } = useDragDropPosition({
|
|
205
|
+
container: dragdropContainerRef.current, // If there is a container with a drag range
|
|
206
|
+
...
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
|
|
212
|
+
<>
|
|
213
|
+
|
|
214
|
+
<div
|
|
215
|
+
ref={dragdropContainerRef}
|
|
216
|
+
style={{
|
|
217
|
+
width: '300px',
|
|
218
|
+
height: '300px',
|
|
219
|
+
border: '1px solid #ddd',
|
|
220
|
+
background: '#efefef',
|
|
221
|
+
position: 'relative'
|
|
222
|
+
}}
|
|
223
|
+
>
|
|
224
|
+
<div
|
|
225
|
+
ref={setup}
|
|
226
|
+
className="float-btn"
|
|
227
|
+
style={{ position: 'absolute', left: '50%', top: '50%', zIndex: 1000, background: 'red' }}
|
|
228
|
+
|
|
229
|
+
>Move Here<small>{JSON.stringify(objPosition)}</small><br /><strong>{show ? 'Clicked' : 'None'}</strong></div>
|
|
230
|
+
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
</>
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
*/
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
var useDragDropPosition = function useDragDropPosition(settings) {
|
|
243
|
+
var _settings$container = settings.container,
|
|
244
|
+
container = _settings$container === void 0 ? null : _settings$container,
|
|
245
|
+
onPointerDown = settings.onPointerDown,
|
|
246
|
+
onPointerUp = settings.onPointerUp,
|
|
247
|
+
onDragStart = settings.onDragStart,
|
|
248
|
+
onDragEnd = settings.onDragEnd,
|
|
249
|
+
onMove = settings.onMove,
|
|
250
|
+
_settings$dimension = settings.dimension,
|
|
251
|
+
dimension = _settings$dimension === void 0 ? 0 : _settings$dimension,
|
|
252
|
+
onInit = settings.onInit,
|
|
253
|
+
pin = settings.pin,
|
|
254
|
+
_settings$moveDelay = settings.moveDelay,
|
|
255
|
+
moveDelay = _settings$moveDelay === void 0 ? 150 : _settings$moveDelay,
|
|
256
|
+
_settings$usePercenta = settings.usePercentage,
|
|
257
|
+
usePercentage = _settings$usePercenta === void 0 ? false : _settings$usePercenta;
|
|
258
|
+
var ref = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
259
|
+
var isClicked = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
|
|
260
|
+
var isDragged = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
|
|
261
|
+
var keyPressed = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
|
|
262
|
+
var convertToPercentage = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (position) {
|
|
263
|
+
if (usePercentage) {
|
|
264
|
+
if (!container) return {
|
|
265
|
+
position: position,
|
|
266
|
+
hasContainer: Boolean(container)
|
|
267
|
+
};
|
|
268
|
+
var containerDim = getContainerDimensions();
|
|
269
|
+
return {
|
|
270
|
+
position: {
|
|
271
|
+
left: position.left / containerDim.width * 100,
|
|
272
|
+
top: position.top / containerDim.height * 100
|
|
273
|
+
},
|
|
274
|
+
hasContainer: Boolean(container)
|
|
275
|
+
};
|
|
276
|
+
} else {
|
|
277
|
+
return {
|
|
278
|
+
position: position,
|
|
279
|
+
hasContainer: false
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}, [container, usePercentage]);
|
|
283
|
+
var getContainerDimensions = function getContainerDimensions() {
|
|
284
|
+
if (!container) {
|
|
285
|
+
return {
|
|
286
|
+
width: window.innerWidth,
|
|
287
|
+
height: window.innerHeight,
|
|
288
|
+
left: 0,
|
|
289
|
+
top: 0
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
var rect = container.getBoundingClientRect();
|
|
293
|
+
return {
|
|
294
|
+
width: rect.width,
|
|
295
|
+
height: rect.height,
|
|
296
|
+
left: rect.left,
|
|
297
|
+
top: rect.top
|
|
298
|
+
};
|
|
299
|
+
};
|
|
300
|
+
var getLeft = function getLeft(left, dimension) {
|
|
301
|
+
var containerDim = getContainerDimensions();
|
|
302
|
+
var minLeft = container ? 0 : containerDim.left;
|
|
303
|
+
var maxLeft = containerDim.width - dimension;
|
|
304
|
+
if (left < minLeft) {
|
|
305
|
+
return minLeft;
|
|
306
|
+
} else if (left > maxLeft) {
|
|
307
|
+
return maxLeft;
|
|
308
|
+
}
|
|
309
|
+
return left;
|
|
310
|
+
};
|
|
311
|
+
var getTop = function getTop(top, dimension) {
|
|
312
|
+
var containerDim = getContainerDimensions();
|
|
313
|
+
var minTop = container ? 0 : containerDim.top;
|
|
314
|
+
var maxTop = containerDim.height - dimension;
|
|
315
|
+
if (top < minTop) {
|
|
316
|
+
return minTop;
|
|
317
|
+
} else if (top > maxTop) {
|
|
318
|
+
return maxTop;
|
|
319
|
+
}
|
|
320
|
+
return top;
|
|
321
|
+
};
|
|
322
|
+
var moveTimeout = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
|
|
323
|
+
var moveDisabled = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(true);
|
|
324
|
+
var moveDelayInit = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
|
|
325
|
+
moveTimeout.current = setTimeout(function () {
|
|
326
|
+
moveDisabled.current = false;
|
|
327
|
+
}, moveDelay);
|
|
328
|
+
}, [moveDelay]);
|
|
329
|
+
var moveDelayInitClear = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
|
|
330
|
+
moveDisabled.current = true;
|
|
331
|
+
if (moveTimeout.current) {
|
|
332
|
+
clearTimeout(moveTimeout.current);
|
|
333
|
+
}
|
|
334
|
+
}, []);
|
|
335
|
+
var positionRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)({
|
|
336
|
+
left: 0,
|
|
337
|
+
top: 0
|
|
338
|
+
});
|
|
339
|
+
var calculateRelativePosition = function calculateRelativePosition(clientX, clientY) {
|
|
340
|
+
var containerDim = getContainerDimensions();
|
|
341
|
+
var halfWidth = Math.round(dimension / 2);
|
|
342
|
+
var x = clientX;
|
|
343
|
+
var y = clientY;
|
|
344
|
+
if (container) {
|
|
345
|
+
x = clientX - containerDim.left;
|
|
346
|
+
y = clientY - containerDim.top;
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
x: x - halfWidth,
|
|
350
|
+
y: y - halfWidth
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
var handlePointerDown = function handlePointerDown(ev) {
|
|
354
|
+
moveDelayInit();
|
|
355
|
+
isClicked.current = true;
|
|
356
|
+
var ele = ev.target;
|
|
357
|
+
ev.stopPropagation();
|
|
358
|
+
if (ev instanceof PointerEvent) {
|
|
359
|
+
keyPressed.current = false;
|
|
360
|
+
ele.setPointerCapture(ev.pointerId);
|
|
361
|
+
} else if (ev instanceof KeyboardEvent) {
|
|
362
|
+
keyPressed.current = true;
|
|
363
|
+
}
|
|
364
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown();
|
|
365
|
+
};
|
|
366
|
+
var handlePointerUp = function handlePointerUp(ev) {
|
|
367
|
+
moveDelayInitClear();
|
|
368
|
+
isClicked.current = false;
|
|
369
|
+
if (ev instanceof PointerEvent) {
|
|
370
|
+
var ele = ev.target;
|
|
371
|
+
ele.releasePointerCapture(ev.pointerId);
|
|
372
|
+
}
|
|
373
|
+
if (onDragEnd) {
|
|
374
|
+
var finalPosition = convertToPercentage(positionRef.current);
|
|
375
|
+
onDragEnd(finalPosition);
|
|
376
|
+
}
|
|
377
|
+
if (!isDragged.current) {
|
|
378
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
|
|
379
|
+
} else {
|
|
380
|
+
isDragged.current = false;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
var onPointerMove = function onPointerMove(e) {
|
|
384
|
+
if (moveDisabled.current || !isClicked.current || !ref.current || keyPressed.current) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
var touches = 'touches' in e ? e.touches : null;
|
|
388
|
+
var clientX = touches && touches.length ? touches[0].clientX : e.clientX;
|
|
389
|
+
var clientY = touches && touches.length ? touches[0].clientY : e.clientY;
|
|
390
|
+
var _calculateRelativePos = calculateRelativePosition(clientX, clientY),
|
|
391
|
+
x = _calculateRelativePos.x,
|
|
392
|
+
y = _calculateRelativePos.y;
|
|
393
|
+
var position = {
|
|
394
|
+
left: getLeft(x, dimension),
|
|
395
|
+
top: getTop(y, dimension)
|
|
396
|
+
};
|
|
397
|
+
if (!isDragged.current) {
|
|
398
|
+
isDragged.current = true;
|
|
399
|
+
if (onDragStart) {
|
|
400
|
+
var startPosition = convertToPercentage(position);
|
|
401
|
+
onDragStart(startPosition);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
positionRef.current = position;
|
|
405
|
+
ref.current.style.cssText += "top: ".concat(position.top, "px;left: ").concat(position.left, "px;");
|
|
406
|
+
if (onMove) {
|
|
407
|
+
var movePosition = convertToPercentage(position);
|
|
408
|
+
onMove(movePosition);
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
var setup = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (node) {
|
|
412
|
+
if (node) {
|
|
413
|
+
ref.current = node;
|
|
414
|
+
node.addEventListener("pointerdown", handlePointerDown);
|
|
415
|
+
node.addEventListener("keydown", handlePointerDown);
|
|
416
|
+
node.addEventListener("mouseup", handlePointerUp);
|
|
417
|
+
node.style.touchAction = "none";
|
|
418
|
+
var rect = node.getBoundingClientRect();
|
|
419
|
+
var containerDim = getContainerDimensions();
|
|
420
|
+
var initialPosition = {
|
|
421
|
+
left: container ? rect.left - containerDim.left : rect.left,
|
|
422
|
+
top: container ? rect.top - containerDim.top : rect.top
|
|
423
|
+
};
|
|
424
|
+
if (onInit) {
|
|
425
|
+
var initPosition = convertToPercentage(initialPosition);
|
|
426
|
+
onInit(initPosition);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}, [container, onInit, convertToPercentage]);
|
|
430
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
431
|
+
if (!pin) {
|
|
432
|
+
document.addEventListener("mousemove", onPointerMove);
|
|
433
|
+
document.addEventListener("touchmove", onPointerMove);
|
|
434
|
+
return function () {
|
|
435
|
+
document.removeEventListener("mousemove", onPointerMove);
|
|
436
|
+
document.removeEventListener("touchmove", onPointerMove);
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
}, [container, pin]);
|
|
440
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
441
|
+
return function () {
|
|
442
|
+
moveDelayInitClear();
|
|
443
|
+
};
|
|
444
|
+
}, [moveDelayInitClear]);
|
|
445
|
+
return {
|
|
446
|
+
ref: ref,
|
|
447
|
+
setup: setup
|
|
448
|
+
};
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
})();
|
|
452
|
+
|
|
453
|
+
/******/ return __webpack_exports__;
|
|
454
|
+
/******/ })()
|
|
455
|
+
;
|
|
456
|
+
});
|
package/lib/cjs/index.d.ts
CHANGED
package/lib/cjs/index.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.Checkbox = _interopRequireDefault(require("./Checkbox")).default;
|
|
|
10
10
|
exports.ColorPicker = _interopRequireDefault(require("./ColorPicker")).default;
|
|
11
11
|
exports.Date = _interopRequireDefault(require("./Date")).default;
|
|
12
12
|
exports.DigitalClock = _interopRequireDefault(require("./DigitalClock")).default;
|
|
13
|
+
exports.DragDropList = _interopRequireDefault(require("./DragDropList")).default;
|
|
13
14
|
exports.DropdownMenu = _interopRequireDefault(require("./DropdownMenu")).default;
|
|
14
15
|
exports.DynamicFields = _interopRequireDefault(require("./DynamicFields")).default;
|
|
15
16
|
exports.EventCalendar = _interopRequireDefault(require("./EventCalendar")).default;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/* ======================================================
|
|
2
|
+
<!-- DragDrop List -->
|
|
3
|
+
/* ====================================================== */
|
|
4
|
+
.custom-draggable-list {
|
|
5
|
+
--custom-draggable-content-bg: transparent;
|
|
6
|
+
--custom-draggable-content-color: inherit;
|
|
7
|
+
--custom-draggable-border-color: #ddd;
|
|
8
|
+
--custom-draggable-wrapper-radius: 0.25rem;
|
|
9
|
+
--custom-draggable-control-radius: 0.25rem;
|
|
10
|
+
--custom-draggable-primary-color: #ffa940;
|
|
11
|
+
--custom-draggable-content-diff-bg: #fafafa;
|
|
12
|
+
--custom-draggable-content-diff-border-color: #d9d9d9;
|
|
13
|
+
--custom-draggable-control-fs: 0.75rem;
|
|
14
|
+
--custom-draggable-control-w: 100px;
|
|
15
|
+
--custom-draggable-btn-confirm-bg: #52c41a;
|
|
16
|
+
--custom-draggable-btn-cancel-bg: #ff4d4f;
|
|
17
|
+
--custom-draggable-btn-color: #fff;
|
|
18
|
+
list-style: none;
|
|
19
|
+
padding: 0;
|
|
20
|
+
margin: 0;
|
|
21
|
+
width: 100%;
|
|
22
|
+
position: relative;
|
|
23
|
+
border: 1px solid var(--custom-draggable-border-color);
|
|
24
|
+
border-radius: var(--custom-draggable-wrapper-radius);
|
|
25
|
+
/* Fix the problem that mobile terminals cannot be touched, DO NOT USE "<svg>" */
|
|
26
|
+
/* FORM */
|
|
27
|
+
}
|
|
28
|
+
.custom-draggable-list li {
|
|
29
|
+
margin: 0;
|
|
30
|
+
padding: 0;
|
|
31
|
+
}
|
|
32
|
+
.custom-draggable-list .custom-draggable-list__item {
|
|
33
|
+
padding: 0;
|
|
34
|
+
position: relative;
|
|
35
|
+
transition: transform 0.15s ease;
|
|
36
|
+
position: relative;
|
|
37
|
+
}
|
|
38
|
+
.custom-draggable-list .custom-draggable-list__item .custom-draggable-list__itemcontent {
|
|
39
|
+
padding: 10px 15px;
|
|
40
|
+
background: var(--custom-draggable-content-bg);
|
|
41
|
+
color: var(--custom-draggable-content-color);
|
|
42
|
+
border-bottom: 1px solid var(--custom-draggable-border-color);
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
user-select: none;
|
|
46
|
+
transition: all 0.15s ease;
|
|
47
|
+
}
|
|
48
|
+
.custom-draggable-list .custom-draggable-list__item .custom-draggable-list__itemcontent .custom-draggable-list__itemcontent-inner {
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: space-between;
|
|
52
|
+
width: 100%;
|
|
53
|
+
}
|
|
54
|
+
.custom-draggable-list .custom-draggable-list__item:last-child .custom-draggable-list__itemcontent {
|
|
55
|
+
border-bottom: none;
|
|
56
|
+
}
|
|
57
|
+
.custom-draggable-list .custom-draggable-list__item.disabled {
|
|
58
|
+
pointer-events: none !important;
|
|
59
|
+
opacity: 0.4 !important;
|
|
60
|
+
}
|
|
61
|
+
.custom-draggable-list.alternate-collapse .custom-draggable-list__collapse-arrow {
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
display: inline-block;
|
|
64
|
+
width: 20px;
|
|
65
|
+
text-align: center;
|
|
66
|
+
user-select: none;
|
|
67
|
+
margin-left: 0.2rem;
|
|
68
|
+
}
|
|
69
|
+
.custom-draggable-list.alternate-collapse .custom-draggable-list__collapse-arrow svg {
|
|
70
|
+
transition: all 0.15s ease;
|
|
71
|
+
}
|
|
72
|
+
.custom-draggable-list.alternate-collapse .custom-draggable-list__collapse-arrow:hover {
|
|
73
|
+
opacity: 0.7;
|
|
74
|
+
}
|
|
75
|
+
.custom-draggable-list.alternate-collapse .custom-draggable-list__item.has-children {
|
|
76
|
+
position: relative;
|
|
77
|
+
}
|
|
78
|
+
.custom-draggable-list.alternate-collapse .custom-draggable-list__item.collapsed .custom-draggable-list__collapse-arrow svg {
|
|
79
|
+
transform: rotate(-90deg);
|
|
80
|
+
}
|
|
81
|
+
.custom-draggable-list .custom-draggable-list__item.draggable .custom-draggable-list__itemcontent {
|
|
82
|
+
padding-left: 1.5em;
|
|
83
|
+
}
|
|
84
|
+
.custom-draggable-list.handle-pos-right .custom-draggable-list__item.draggable .custom-draggable-list__itemcontent, .custom-draggable-list.icon-hide .custom-draggable-list__item.draggable .custom-draggable-list__itemcontent {
|
|
85
|
+
padding-left: 0.5rem;
|
|
86
|
+
}
|
|
87
|
+
.custom-draggable-list .custom-draggable-list__item.block.draggable {
|
|
88
|
+
cursor: move;
|
|
89
|
+
}
|
|
90
|
+
.custom-draggable-list .custom-draggable-list__item.dragging .custom-draggable-list__itemcontent {
|
|
91
|
+
background: #fff9e6;
|
|
92
|
+
border: 1px dashed #ffd591;
|
|
93
|
+
opacity: 0.8;
|
|
94
|
+
}
|
|
95
|
+
.custom-draggable-list .custom-draggable-list__item.drag-over .custom-draggable-list__itemcontent {
|
|
96
|
+
background: #fff9e6;
|
|
97
|
+
border: 2px solid #ffd591;
|
|
98
|
+
}
|
|
99
|
+
.custom-draggable-list .custom-draggable-list__item.drag-over-top::before {
|
|
100
|
+
content: "";
|
|
101
|
+
position: absolute;
|
|
102
|
+
top: -3px;
|
|
103
|
+
left: 0;
|
|
104
|
+
right: 0;
|
|
105
|
+
height: 2px;
|
|
106
|
+
background: var(--custom-draggable-primary-color);
|
|
107
|
+
border-radius: 1px;
|
|
108
|
+
}
|
|
109
|
+
.custom-draggable-list .custom-draggable-list__item.drag-over-bottom::after {
|
|
110
|
+
content: "";
|
|
111
|
+
position: absolute;
|
|
112
|
+
bottom: -3px;
|
|
113
|
+
left: 0;
|
|
114
|
+
right: 0;
|
|
115
|
+
height: 2px;
|
|
116
|
+
background: var(--custom-draggable-primary-color);
|
|
117
|
+
border-radius: 1px;
|
|
118
|
+
}
|
|
119
|
+
.custom-draggable-list .custom-draggable-list__handle {
|
|
120
|
+
color: #999;
|
|
121
|
+
padding: 5px;
|
|
122
|
+
cursor: move;
|
|
123
|
+
transition: color 0.15s ease;
|
|
124
|
+
position: absolute;
|
|
125
|
+
width: 1em;
|
|
126
|
+
height: 1em;
|
|
127
|
+
top: 50%;
|
|
128
|
+
transform: translateY(-50%);
|
|
129
|
+
z-index: 1;
|
|
130
|
+
display: flex;
|
|
131
|
+
align-items: center;
|
|
132
|
+
font-size: 0.75rem;
|
|
133
|
+
}
|
|
134
|
+
.custom-draggable-list .custom-draggable-list__handle.left {
|
|
135
|
+
left: 0;
|
|
136
|
+
}
|
|
137
|
+
.custom-draggable-list .custom-draggable-list__handle.right {
|
|
138
|
+
right: 1em;
|
|
139
|
+
}
|
|
140
|
+
.custom-draggable-list .custom-draggable-list__item,
|
|
141
|
+
.custom-draggable-list .custom-draggable-list__itemcontent {
|
|
142
|
+
transition: all 0.15s ease;
|
|
143
|
+
}
|
|
144
|
+
.custom-draggable-list .custom-draggable-list__item.editing .custom-draggable-list__itemcontent, .custom-draggable-list .custom-draggable-list__item:hover .custom-draggable-list__itemcontent {
|
|
145
|
+
background: var(--custom-draggable-content-diff-bg);
|
|
146
|
+
border-color: var(--custom-draggable-content-diff-border-color);
|
|
147
|
+
}
|
|
148
|
+
.custom-draggable-list .custom-draggable-list__item.block:hover .custom-draggable-list__handle {
|
|
149
|
+
color: var(--custom-draggable-primary-color);
|
|
150
|
+
}
|
|
151
|
+
.custom-draggable-list.handle .custom-draggable-list__handle:hover {
|
|
152
|
+
color: var(--custom-draggable-primary-color);
|
|
153
|
+
}
|
|
154
|
+
.custom-draggable-list .custom-draggable-list__edit-form {
|
|
155
|
+
display: flex;
|
|
156
|
+
flex: 1;
|
|
157
|
+
gap: 10px;
|
|
158
|
+
align-items: center;
|
|
159
|
+
}
|
|
160
|
+
.custom-draggable-list .custom-draggable-list__edit-form input {
|
|
161
|
+
padding: 4px 8px;
|
|
162
|
+
border: 1px solid var(--custom-draggable-border-color);
|
|
163
|
+
border-radius: var(--custom-draggable-control-radius);
|
|
164
|
+
font-size: var(--custom-draggable-control-fs);
|
|
165
|
+
width: var(--custom-draggable-control-w);
|
|
166
|
+
}
|
|
167
|
+
.custom-draggable-list .custom-draggable-list__edit-buttons {
|
|
168
|
+
display: flex;
|
|
169
|
+
gap: 5px;
|
|
170
|
+
}
|
|
171
|
+
.custom-draggable-list .custom-draggable-list__edit-buttons button {
|
|
172
|
+
padding: 0.2rem 0.5rem;
|
|
173
|
+
border: none;
|
|
174
|
+
font-size: 0.75rem;
|
|
175
|
+
border-radius: var(--custom-draggable-control-radius);
|
|
176
|
+
cursor: pointer;
|
|
177
|
+
}
|
|
178
|
+
.custom-draggable-list .custom-draggable-list__edit-buttons button:first-child {
|
|
179
|
+
background: var(--custom-draggable-btn-confirm-bg);
|
|
180
|
+
color: var(--custom-draggable-btn-color);
|
|
181
|
+
}
|
|
182
|
+
.custom-draggable-list .custom-draggable-list__edit-buttons button:last-child {
|
|
183
|
+
background: var(--custom-draggable-btn-cancel-bg);
|
|
184
|
+
color: var(--custom-draggable-btn-color);
|
|
185
|
+
}
|
|
186
|
+
.custom-draggable-list .custom-draggable-list__edit-buttons button:hover {
|
|
187
|
+
opacity: 0.8;
|
|
188
|
+
}
|