funda-ui 4.5.666 → 4.5.671
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/ColorPicker/index.js +3 -1
- package/Date/index.js +14 -1
- package/DragDropList/index.css +188 -0
- package/DragDropList/index.d.ts +44 -0
- package/DragDropList/index.js +1587 -0
- package/Input/index.d.ts +2 -0
- package/Input/index.js +14 -1
- package/LICENSE +21 -0
- package/MultipleSelect/index.css +237 -144
- package/MultipleSelect/index.d.ts +24 -10
- package/MultipleSelect/index.js +2240 -1225
- package/README.md +3 -1
- package/RangeSlider/index.js +14 -1
- package/Textarea/index.d.ts +2 -0
- package/Textarea/index.js +14 -1
- package/Tree/index.d.ts +1 -0
- package/Tree/index.js +29 -0
- package/Utils/useBoundedDrag.d.ts +125 -0
- package/Utils/useBoundedDrag.js +380 -0
- package/Utils/useDragDropPosition.d.ts +169 -0
- package/Utils/useDragDropPosition.js +456 -0
- package/Utils/useIsMobile.d.ts +2 -0
- package/Utils/useIsMobile.js +168 -0
- package/all.d.ts +1 -0
- package/all.js +1 -1
- package/lib/cjs/ColorPicker/index.js +3 -1
- package/lib/cjs/Date/index.js +14 -1
- package/lib/cjs/DragDropList/index.d.ts +44 -0
- package/lib/cjs/DragDropList/index.js +1587 -0
- package/lib/cjs/Input/index.d.ts +2 -0
- package/lib/cjs/Input/index.js +14 -1
- package/lib/cjs/MultipleSelect/index.d.ts +24 -10
- package/lib/cjs/MultipleSelect/index.js +2240 -1225
- package/lib/cjs/RangeSlider/index.js +14 -1
- package/lib/cjs/Textarea/index.d.ts +2 -0
- package/lib/cjs/Textarea/index.js +14 -1
- package/lib/cjs/Tree/index.d.ts +1 -0
- package/lib/cjs/Tree/index.js +29 -0
- package/lib/cjs/Utils/useBoundedDrag.d.ts +125 -0
- package/lib/cjs/Utils/useBoundedDrag.js +380 -0
- package/lib/cjs/Utils/useDragDropPosition.d.ts +169 -0
- package/lib/cjs/Utils/useDragDropPosition.js +456 -0
- package/lib/cjs/Utils/useIsMobile.d.ts +2 -0
- package/lib/cjs/Utils/useIsMobile.js +168 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -1
- package/lib/css/DragDropList/index.css +188 -0
- package/lib/css/MultipleSelect/index.css +237 -144
- package/lib/esm/ColorPicker/index.tsx +53 -49
- package/lib/esm/DragDropList/index.scss +245 -0
- package/lib/esm/DragDropList/index.tsx +494 -0
- package/lib/esm/Input/index.tsx +17 -3
- package/lib/esm/MultipleSelect/index.scss +288 -183
- package/lib/esm/MultipleSelect/index.tsx +305 -166
- package/lib/esm/MultipleSelect/utils/func.ts +21 -1
- package/lib/esm/Tabs/Tabs.tsx +1 -1
- package/lib/esm/Textarea/index.tsx +18 -1
- package/lib/esm/Tree/TreeList.tsx +32 -0
- package/lib/esm/Tree/index.tsx +3 -0
- package/lib/esm/Utils/hooks/useBoundedDrag.tsx +301 -0
- package/lib/esm/Utils/hooks/useDragDropPosition.tsx +420 -0
- package/lib/esm/Utils/hooks/useIsMobile.tsx +56 -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
|
+
});
|
|
@@ -0,0 +1,168 @@
|
|
|
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 */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
100
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
101
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
102
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
103
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
104
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
105
|
+
/**
|
|
106
|
+
* Determine whether it is the mobile terminal of the specified breakpoint
|
|
107
|
+
* *
|
|
108
|
+
* @usage:
|
|
109
|
+
*
|
|
110
|
+
|
|
111
|
+
const App = () => {
|
|
112
|
+
|
|
113
|
+
const isMobile = useIsMobile();
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<div>
|
|
117
|
+
{isMobile ? (
|
|
118
|
+
<p>This content is hidden on mobile devices.</p>
|
|
119
|
+
) : (
|
|
120
|
+
<p>This content is visible on larger screens.</p>
|
|
121
|
+
)}
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
var useIsMobile = function useIsMobile() {
|
|
130
|
+
var breakpoint = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 768;
|
|
131
|
+
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
|
|
132
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
133
|
+
isMobile = _useState2[0],
|
|
134
|
+
setIsMobile = _useState2[1];
|
|
135
|
+
var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
|
|
136
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
137
|
+
isMounted = _useState4[0],
|
|
138
|
+
setIsMounted = _useState4[1];
|
|
139
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
140
|
+
// Set the mounted state to true after the component has mounted
|
|
141
|
+
setIsMounted(true);
|
|
142
|
+
var handleResize = function handleResize() {
|
|
143
|
+
if (window) {
|
|
144
|
+
setIsMobile(window.innerWidth <= breakpoint);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// Add event listener for resize
|
|
149
|
+
window.addEventListener('resize', handleResize);
|
|
150
|
+
// Call the handler once to set the initial state
|
|
151
|
+
handleResize();
|
|
152
|
+
|
|
153
|
+
// Cleanup the event listener on component unmount
|
|
154
|
+
return function () {
|
|
155
|
+
window.removeEventListener('resize', handleResize);
|
|
156
|
+
};
|
|
157
|
+
}, [breakpoint]);
|
|
158
|
+
|
|
159
|
+
// Only return the isMobile state if the component is mounted
|
|
160
|
+
return isMounted ? isMobile : false;
|
|
161
|
+
};
|
|
162
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (useIsMobile);
|
|
163
|
+
})();
|
|
164
|
+
|
|
165
|
+
/******/ return __webpack_exports__;
|
|
166
|
+
/******/ })()
|
|
167
|
+
;
|
|
168
|
+
});
|
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;
|
|
@@ -43,4 +44,3 @@ exports.Textarea = _interopRequireDefault(require("./Textarea")).default;
|
|
|
43
44
|
exports.Toast = _interopRequireDefault(require("./Toast")).default;
|
|
44
45
|
exports.Tooltip = _interopRequireDefault(require("./Tooltip")).default;
|
|
45
46
|
exports.Tree = _interopRequireDefault(require("./Tree")).default;
|
|
46
|
-
exports.Utils = _interopRequireDefault(require("./Utils")).default;
|