funda-ui 4.4.15 → 4.4.35
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/EventCalendar/index.css +114 -114
- package/EventCalendar/index.d.ts +1 -0
- package/EventCalendar/index.js +116 -84
- package/EventCalendarTimeline/index.css +274 -270
- package/EventCalendarTimeline/index.d.ts +3 -0
- package/EventCalendarTimeline/index.js +641 -224
- package/MultipleCheckboxes/index.js +11 -11
- package/MultipleSelect/index.js +11 -11
- package/NativeSelect/index.js +11 -11
- package/Radio/index.js +11 -11
- package/Select/index.js +11 -11
- package/Table/index.css +1 -0
- package/Table/index.js +36 -7
- package/TagInput/index.d.ts +1 -0
- package/TagInput/index.js +20 -2
- package/Tree/index.js +11 -11
- package/Utils/object.js +11 -11
- package/Utils/os.d.ts +2 -0
- package/Utils/os.js +104 -0
- package/lib/cjs/EventCalendar/index.d.ts +1 -0
- package/lib/cjs/EventCalendar/index.js +116 -84
- package/lib/cjs/EventCalendarTimeline/index.d.ts +3 -0
- package/lib/cjs/EventCalendarTimeline/index.js +641 -224
- package/lib/cjs/MultipleCheckboxes/index.js +11 -11
- package/lib/cjs/MultipleSelect/index.js +11 -11
- package/lib/cjs/NativeSelect/index.js +11 -11
- package/lib/cjs/Radio/index.js +11 -11
- package/lib/cjs/Select/index.js +11 -11
- package/lib/cjs/Table/index.js +36 -7
- package/lib/cjs/TagInput/index.d.ts +1 -0
- package/lib/cjs/TagInput/index.js +20 -2
- package/lib/cjs/Tree/index.js +11 -11
- package/lib/cjs/Utils/object.js +11 -11
- package/lib/cjs/Utils/os.d.ts +2 -0
- package/lib/cjs/Utils/os.js +104 -0
- package/lib/css/EventCalendar/index.css +114 -114
- package/lib/css/EventCalendarTimeline/index.css +274 -270
- package/lib/css/Table/index.css +1 -0
- package/lib/esm/EventCalendar/index.scss +81 -81
- package/lib/esm/EventCalendar/index.tsx +136 -98
- package/lib/esm/EventCalendarTimeline/index.scss +226 -221
- package/lib/esm/EventCalendarTimeline/index.tsx +445 -207
- package/lib/esm/ModalDialog/index.tsx +0 -1
- package/lib/esm/Table/Table.tsx +0 -1
- package/lib/esm/Table/index.scss +2 -0
- package/lib/esm/Table/utils/hooks/useTableDraggable.tsx +47 -6
- package/lib/esm/TagInput/index.tsx +23 -1
- package/lib/esm/Utils/libs/object.ts +67 -67
- package/lib/esm/Utils/libs/os.ts +63 -0
- package/package.json +1 -1
package/lib/esm/Table/Table.tsx
CHANGED
|
@@ -5,7 +5,6 @@ import useComId from 'funda-utils/dist/cjs/useComId';
|
|
|
5
5
|
import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
import { TableProvider } from './TableContext';
|
|
10
9
|
import useTableResponsive from './utils/hooks/useTableResponsive';
|
|
11
10
|
import useTableDraggable from './utils/hooks/useTableDraggable';
|
package/lib/esm/Table/index.scss
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
&.table-responsive {
|
|
17
17
|
overflow-x: auto;
|
|
18
|
+
overflow-y: hidden;
|
|
18
19
|
|
|
19
20
|
&::-webkit-scrollbar {
|
|
20
21
|
height: var(--syntable-scrollbar-h);
|
|
@@ -164,6 +165,7 @@
|
|
|
164
165
|
|
|
165
166
|
.row-obj-clonelast {
|
|
166
167
|
height: 0 !important;
|
|
168
|
+
|
|
167
169
|
|
|
168
170
|
td {
|
|
169
171
|
border: none;
|
|
@@ -64,7 +64,7 @@ function useTableDraggable({
|
|
|
64
64
|
|
|
65
65
|
const placeholderGenerator = (trHeight: number) => {
|
|
66
66
|
const tbodyRef: any = getTbody(spyElement);
|
|
67
|
-
if (tbodyRef === null) return;
|
|
67
|
+
if (tbodyRef === null || tbodyRef.querySelector('tr') === null) return;
|
|
68
68
|
|
|
69
69
|
// Insert a row at the "index" of the table
|
|
70
70
|
const newRow = document.createElement('tr');
|
|
@@ -85,7 +85,11 @@ function useTableDraggable({
|
|
|
85
85
|
|
|
86
86
|
const lastRowGenerator = (trHeight: number) => {
|
|
87
87
|
const tbodyRef: any = getTbody(spyElement);
|
|
88
|
-
if (tbodyRef === null) return;
|
|
88
|
+
if (tbodyRef === null || tbodyRef.querySelector('tr') === null) return;
|
|
89
|
+
|
|
90
|
+
const cloneEl = tbodyRef.querySelector('.row-obj-clonelast');
|
|
91
|
+
if (cloneEl !== null) return;
|
|
92
|
+
|
|
89
93
|
|
|
90
94
|
// Insert a row at the "index" of the table
|
|
91
95
|
const newRow = document.createElement('tr');
|
|
@@ -93,6 +97,7 @@ function useTableDraggable({
|
|
|
93
97
|
newRow.dataset.order = allRows(spyElement).length.toString();
|
|
94
98
|
newRow.style.height = trHeight + 'px';
|
|
95
99
|
newRow.style.display = 'none';
|
|
100
|
+
|
|
96
101
|
|
|
97
102
|
// Insert a cell in the row at index
|
|
98
103
|
const newCell = newRow.insertCell(0);
|
|
@@ -134,7 +139,14 @@ function useTableDraggable({
|
|
|
134
139
|
setSortData(listIndexes);
|
|
135
140
|
|
|
136
141
|
//last placeholder
|
|
137
|
-
|
|
142
|
+
if (_allRows.length > 0) {
|
|
143
|
+
const lastEl: any = lastRowGenerator((_allRows.at(-1) as any).clientHeight);
|
|
144
|
+
if (typeof _allRows.at(-1) !== 'undefined') {
|
|
145
|
+
insertAfter(lastEl, _allRows.at(-1));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
138
150
|
};
|
|
139
151
|
|
|
140
152
|
const handleTbodyEnter = (e: any) => {
|
|
@@ -182,6 +194,9 @@ function useTableDraggable({
|
|
|
182
194
|
|
|
183
195
|
|
|
184
196
|
const handleDragStart = useCallback((e: any) => {
|
|
197
|
+
const tbodyRef: any = getTbody(spyElement);
|
|
198
|
+
if (tbodyRef === null) return;
|
|
199
|
+
|
|
185
200
|
draggedObj = e.currentTarget;
|
|
186
201
|
e.dataTransfer.effectAllowed = 'move';
|
|
187
202
|
e.dataTransfer.setData('text/html', draggedObj);
|
|
@@ -196,6 +211,15 @@ function useTableDraggable({
|
|
|
196
211
|
};
|
|
197
212
|
onRowDrag?.(dragStart, null);
|
|
198
213
|
|
|
214
|
+
|
|
215
|
+
// init clone <tr>
|
|
216
|
+
// !!! It needs to be put at the end of the code to fix the location of the clone element
|
|
217
|
+
const cloneEl = tbodyRef.querySelector('.row-obj-clonelast');
|
|
218
|
+
if (cloneEl !== null) {
|
|
219
|
+
cloneEl.style.display = 'none';
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
199
223
|
}, [handledragOver]);
|
|
200
224
|
|
|
201
225
|
const handleDragEnd = useCallback((e: any) => {
|
|
@@ -250,9 +274,12 @@ function useTableDraggable({
|
|
|
250
274
|
// sort elements
|
|
251
275
|
const categoryItemsArray = allRows(spyElement);
|
|
252
276
|
const sorter = (a: any, b: any) => {
|
|
253
|
-
|
|
277
|
+
let txt1 = Number(a.dataset.order),
|
|
278
|
+
txt2 = Number(b.dataset.order);
|
|
279
|
+
|
|
280
|
+
return txt2 < txt1 ? -1 : txt2 > txt1 ? 1 : 0;
|
|
254
281
|
}
|
|
255
|
-
const sorted = categoryItemsArray.sort(sorter);
|
|
282
|
+
const sorted = categoryItemsArray.sort(sorter).reverse();
|
|
256
283
|
sorted.forEach(e => spyElement.querySelector('table').querySelector('tbody').appendChild(e));
|
|
257
284
|
|
|
258
285
|
|
|
@@ -264,13 +291,27 @@ function useTableDraggable({
|
|
|
264
291
|
|
|
265
292
|
|
|
266
293
|
|
|
294
|
+
// init clone <tr>
|
|
295
|
+
// !!! It needs to be put at the end of the code to fix the location of the clone element
|
|
296
|
+
const _allRows = allRows(spyElement);
|
|
297
|
+
const cloneEl = tbodyRef.querySelector('.row-obj-clonelast');
|
|
298
|
+
if (cloneEl !== null) {
|
|
299
|
+
if (typeof _allRows.at(-1) !== 'undefined') {
|
|
300
|
+
insertAfter(cloneEl, _allRows.at(-1));
|
|
301
|
+
cloneEl.style.display = 'none';
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
267
307
|
}, [sortData]);
|
|
268
308
|
|
|
269
309
|
|
|
270
310
|
|
|
271
311
|
useEffect(() => {
|
|
272
312
|
if (enabled) {
|
|
273
|
-
if (Array.isArray(data)) {
|
|
313
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
314
|
+
// !!! REQUIRED "data.length > 0" to avoid data-order cannot be assigned when asynchronous data is empty
|
|
274
315
|
data.forEach((item: any, i: number) => {
|
|
275
316
|
item.order = i;
|
|
276
317
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef, forwardRef, ChangeEvent, MouseEvent, KeyboardEvent, FocusEvent, CompositionEvent } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useRef, forwardRef, useImperativeHandle, ChangeEvent, MouseEvent, KeyboardEvent, FocusEvent, CompositionEvent } from 'react';
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -14,6 +14,7 @@ import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
export type TagInputProps = {
|
|
17
|
+
contentRef?: React.ForwardedRef<any>;
|
|
17
18
|
wrapperClassName?: string;
|
|
18
19
|
value?: string;
|
|
19
20
|
maxTags?: number;
|
|
@@ -45,6 +46,7 @@ export type TagInputProps = {
|
|
|
45
46
|
|
|
46
47
|
const TagInput = forwardRef((props: TagInputProps, externalRef: any) => {
|
|
47
48
|
const {
|
|
49
|
+
contentRef,
|
|
48
50
|
wrapperClassName,
|
|
49
51
|
maxTags,
|
|
50
52
|
disabled,
|
|
@@ -85,6 +87,26 @@ const TagInput = forwardRef((props: TagInputProps, externalRef: any) => {
|
|
|
85
87
|
const [onComposition, setOnComposition] = useState<boolean>(false);
|
|
86
88
|
|
|
87
89
|
|
|
90
|
+
// exposes the following methods
|
|
91
|
+
useImperativeHandle(
|
|
92
|
+
contentRef,
|
|
93
|
+
() => ({
|
|
94
|
+
control: () => {
|
|
95
|
+
return valRef.current;
|
|
96
|
+
},
|
|
97
|
+
clear: (cb?: any) => {
|
|
98
|
+
initDefaultValue('');
|
|
99
|
+
cb?.();
|
|
100
|
+
},
|
|
101
|
+
set: (value: string, cb?: any) => {
|
|
102
|
+
initDefaultValue(`${value}`);
|
|
103
|
+
cb?.();
|
|
104
|
+
}
|
|
105
|
+
}),
|
|
106
|
+
[contentRef],
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
|
|
88
110
|
function initDefaultValue(defaultValue: any) {
|
|
89
111
|
|
|
90
112
|
// change the value to trigger component rendering
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Remove Duplicate objects from JSON Array
|
|
4
|
-
* @param {Array} obj
|
|
5
|
-
* @param {String} fieldName
|
|
6
|
-
*/
|
|
7
|
-
function removeArrDuplicateItems(obj: any[], fieldName: string): any[] {
|
|
8
|
-
if (!Array.isArray(obj)) return [];
|
|
9
|
-
|
|
10
|
-
const clean = obj.filter((item, index, self) => index === self.findIndex((t) => (t[fieldName] === item[fieldName])));
|
|
11
|
-
return clean;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Deep clone
|
|
17
|
-
* @param {*} obj
|
|
18
|
-
*/
|
|
19
|
-
function deepClone(obj: any): any {
|
|
20
|
-
if (Array.isArray(obj)) {
|
|
21
|
-
return (obj).map((item) => deepClone(item));
|
|
22
|
-
} else if (typeof obj === 'object' && obj !== null) {
|
|
23
|
-
const clone: any = {};
|
|
24
|
-
for (let key in obj) {
|
|
25
|
-
if (obj.hasOwnProperty(key)) {
|
|
26
|
-
clone[key] = deepClone(obj[key]);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return clone;
|
|
30
|
-
} else {
|
|
31
|
-
return obj;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Flat Data
|
|
38
|
-
* @param {*} data
|
|
39
|
-
* @returns
|
|
40
|
-
*/
|
|
41
|
-
function flatData(data: any): any[] {
|
|
42
|
-
const result: any[] = [];
|
|
43
|
-
const iterate = (obj: any) => {
|
|
44
|
-
if (!obj) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
obj.forEach((item: any) => {
|
|
48
|
-
result.push(item);
|
|
49
|
-
if (item.children) {
|
|
50
|
-
iterate(item.children);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// delete current item children
|
|
54
|
-
delete item.children;
|
|
55
|
-
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
iterate(data);
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
export {
|
|
65
|
-
removeArrDuplicateItems,
|
|
66
|
-
deepClone,
|
|
67
|
-
flatData
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Remove Duplicate objects from JSON Array
|
|
4
|
+
* @param {Array} obj
|
|
5
|
+
* @param {String} fieldName
|
|
6
|
+
*/
|
|
7
|
+
function removeArrDuplicateItems(obj: any[], fieldName: string): any[] {
|
|
8
|
+
if (!Array.isArray(obj)) return [];
|
|
9
|
+
|
|
10
|
+
const clean = obj.filter((item, index, self) => index === self.findIndex((t) => (t[fieldName] === item[fieldName])));
|
|
11
|
+
return clean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Deep clone
|
|
17
|
+
* @param {*} obj
|
|
18
|
+
*/
|
|
19
|
+
function deepClone(obj: any): any {
|
|
20
|
+
if (Array.isArray(obj)) {
|
|
21
|
+
return (obj).map((item) => deepClone(item));
|
|
22
|
+
} else if (typeof obj === 'object' && obj !== null) {
|
|
23
|
+
const clone: any = {};
|
|
24
|
+
for (let key in obj) {
|
|
25
|
+
if (obj.hasOwnProperty(key)) {
|
|
26
|
+
clone[key] = deepClone(obj[key]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return clone;
|
|
30
|
+
} else {
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Flat Data
|
|
38
|
+
* @param {*} data
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
function flatData(data: any): any[] {
|
|
42
|
+
const result: any[] = [];
|
|
43
|
+
const iterate = (obj: any) => {
|
|
44
|
+
if (!obj) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
obj.forEach((item: any) => {
|
|
48
|
+
result.push(item);
|
|
49
|
+
if (item.children) {
|
|
50
|
+
iterate(item.children);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// delete current item children
|
|
54
|
+
delete item.children;
|
|
55
|
+
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
iterate(data);
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
removeArrDuplicateItems,
|
|
66
|
+
deepClone,
|
|
67
|
+
flatData
|
|
68
68
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Determine whether it is a special platform
|
|
5
|
+
*
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
function getOs() {
|
|
9
|
+
if (typeof window === 'undefined') return {};
|
|
10
|
+
|
|
11
|
+
let os;
|
|
12
|
+
|
|
13
|
+
if ( typeof window !== "undefined" ) {
|
|
14
|
+
|
|
15
|
+
const getOs = () => {
|
|
16
|
+
const _navigator: any = window.navigator;
|
|
17
|
+
const platform = () => {
|
|
18
|
+
// 2022 way of detecting. Note : this userAgentData feature is available only in secure contexts (HTTPS)
|
|
19
|
+
if (typeof _navigator.userAgentData !== 'undefined' && _navigator.userAgentData != null) {
|
|
20
|
+
return _navigator.userAgentData.platform;
|
|
21
|
+
}
|
|
22
|
+
// Deprecated but still works for most of the browser
|
|
23
|
+
if (typeof _navigator.platform !== 'undefined') {
|
|
24
|
+
if (typeof _navigator.userAgent !== 'undefined' && /android/.test(_navigator.userAgent.toLowerCase())) {
|
|
25
|
+
// android device’s _navigator.platform is often set as 'linux', so const’s use userAgent for them
|
|
26
|
+
return 'android';
|
|
27
|
+
}
|
|
28
|
+
return _navigator.platform;
|
|
29
|
+
}
|
|
30
|
+
return 'unknown';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const _platform = platform().toLowerCase();
|
|
34
|
+
|
|
35
|
+
const isOSX = /mac/.test(_platform); // Mac desktop
|
|
36
|
+
const isIOS = ['iphone', 'ipad', 'ipod'].indexOf(_platform) === -1 ? false : true; // Mac iOs
|
|
37
|
+
const isApple = isOSX || isIOS; // Apple device (desktop or iOS)
|
|
38
|
+
const isWindows = /win/.test(_platform); // Windows
|
|
39
|
+
const isAndroid = /android/.test(_platform); // Android
|
|
40
|
+
const isLinux = /linux/.test(_platform); // Linux
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
isOSX,
|
|
44
|
+
isIOS,
|
|
45
|
+
isApple,
|
|
46
|
+
isWindows,
|
|
47
|
+
isAndroid,
|
|
48
|
+
isLinux
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
os = getOs();
|
|
54
|
+
|
|
55
|
+
} else {
|
|
56
|
+
os = {};
|
|
57
|
+
}
|
|
58
|
+
return os;
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
export default getOs;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "UIUX Lab",
|
|
3
3
|
"email": "uiuxlab@gmail.com",
|
|
4
4
|
"name": "funda-ui",
|
|
5
|
-
"version": "4.4.
|
|
5
|
+
"version": "4.4.35",
|
|
6
6
|
"description": "React components using pure Bootstrap 5+ which does not contain any external style and script libraries.",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|