funda-ui 4.7.345 → 4.7.512
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/CascadingSelect/index.css +2 -1
- package/CascadingSelectE2E/index.css +2 -1
- package/Table/index.js +59 -14
- package/lib/cjs/Table/index.js +59 -14
- package/lib/css/CascadingSelect/index.css +2 -1
- package/lib/css/CascadingSelectE2E/index.css +2 -1
- package/lib/esm/CascadingSelect/index.scss +2 -1
- package/lib/esm/CascadingSelectE2E/index.scss +2 -1
- package/lib/esm/Table/Table.tsx +1 -0
- package/lib/esm/Table/TableCell.tsx +0 -2
- package/lib/esm/Table/utils/SortSprite.tsx +8 -2
- package/lib/esm/Table/utils/hooks/useTableSort.tsx +60 -16
- package/package.json +1 -1
|
@@ -174,7 +174,8 @@
|
|
|
174
174
|
}
|
|
175
175
|
.casc-select__items-wrapper .casc-select__items-col-searchbox input {
|
|
176
176
|
border: 1px solid var(--casc-select-searchbox-border-color);
|
|
177
|
-
border-radius: 0.
|
|
177
|
+
border-radius: 0.15rem;
|
|
178
|
+
width: 100%;
|
|
178
179
|
background: transparent;
|
|
179
180
|
font-size: 0.75rem;
|
|
180
181
|
}
|
|
@@ -174,7 +174,8 @@
|
|
|
174
174
|
}
|
|
175
175
|
.casc-select-e2e__items-wrapper .casc-select-e2e__items-col-searchbox input {
|
|
176
176
|
border: 1px solid var(--casc-select-e2e-searchbox-border-color);
|
|
177
|
-
border-radius: 0.
|
|
177
|
+
border-radius: 0.15rem;
|
|
178
|
+
width: 100%;
|
|
178
179
|
background: transparent;
|
|
179
180
|
font-size: 0.75rem;
|
|
180
181
|
}
|
package/Table/index.js
CHANGED
|
@@ -2069,7 +2069,28 @@ const App = () => {
|
|
|
2069
2069
|
|
|
2070
2070
|
useTableSort({
|
|
2071
2071
|
enabled: sortableTable && rootRef.current,
|
|
2072
|
-
spyElement: rootRef.current
|
|
2072
|
+
spyElement: rootRef.current,
|
|
2073
|
+
sortBy: (handleProcess: Function, filterType: string, inverse: boolean) => (a: Element, b: Element) => {
|
|
2074
|
+
|
|
2075
|
+
// Custom comparison logic
|
|
2076
|
+
let v1 = a.textContent, v2 = b.textContent;
|
|
2077
|
+
if (filterType === 'number') {
|
|
2078
|
+
v1 = parseFloat(v1);
|
|
2079
|
+
v2 = parseFloat(v2);
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
let result = 0;
|
|
2083
|
+
if (filterType === 'text') {
|
|
2084
|
+
result = v1.localeCompare(v2);
|
|
2085
|
+
} else {
|
|
2086
|
+
result = v1 - v2;
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
// Apply display animation and status updates
|
|
2090
|
+
handleProcess();
|
|
2091
|
+
|
|
2092
|
+
return inverse ? -result : result;
|
|
2093
|
+
}
|
|
2073
2094
|
}, [rootRef]);
|
|
2074
2095
|
|
|
2075
2096
|
return (
|
|
@@ -2087,8 +2108,11 @@ function useTableSort(_ref, deps) {
|
|
|
2087
2108
|
data = _ref.data,
|
|
2088
2109
|
spyElement = _ref.spyElement,
|
|
2089
2110
|
fieldType = _ref.fieldType,
|
|
2111
|
+
_ref$isReverse = _ref.isReverse,
|
|
2112
|
+
isReverse = _ref$isReverse === void 0 ? false : _ref$isReverse,
|
|
2090
2113
|
onColSort = _ref.onColSort,
|
|
2091
|
-
onClick = _ref.onClick
|
|
2114
|
+
onClick = _ref.onClick,
|
|
2115
|
+
sortBy = _ref.sortBy;
|
|
2092
2116
|
var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
|
|
2093
2117
|
_useState2 = useTableSort_slicedToArray(_useState, 2),
|
|
2094
2118
|
inverse = _useState2[0],
|
|
@@ -2102,16 +2126,22 @@ function useTableSort(_ref, deps) {
|
|
|
2102
2126
|
var filterType = fieldType || 'text';
|
|
2103
2127
|
var curIndex = el.dataset.tableCol;
|
|
2104
2128
|
var targetComparator = [].slice.call(tbodyRef.querySelectorAll("[data-table-col=\"".concat(curIndex, "\"]")));
|
|
2129
|
+
var handleProcess = function handleProcess() {
|
|
2130
|
+
allRows(spyElement).forEach(function (node) {
|
|
2131
|
+
node.classList.add('newsort');
|
|
2132
|
+
});
|
|
2133
|
+
setInverse(!inverse);
|
|
2134
|
+
};
|
|
2105
2135
|
|
|
2106
|
-
//
|
|
2107
|
-
var
|
|
2136
|
+
//
|
|
2137
|
+
var defaultSortBy = function defaultSortBy(a, b) {
|
|
2108
2138
|
var txt1 = a.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase(),
|
|
2109
2139
|
txt2 = b.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase();
|
|
2110
2140
|
|
|
2111
2141
|
//type of number
|
|
2112
2142
|
if (filterType == 'number') {
|
|
2113
|
-
txt1 =
|
|
2114
|
-
txt2 =
|
|
2143
|
+
txt1 = parseFloat(txt1.replace(/[^0-9.+-]+/g, ''));
|
|
2144
|
+
txt2 = parseFloat(txt2.replace(/[^0-9.+-]+/g, ''));
|
|
2115
2145
|
}
|
|
2116
2146
|
|
|
2117
2147
|
//type of date
|
|
@@ -2121,13 +2151,23 @@ function useTableSort(_ref, deps) {
|
|
|
2121
2151
|
}
|
|
2122
2152
|
|
|
2123
2153
|
//add filter class
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2154
|
+
handleProcess();
|
|
2155
|
+
|
|
2156
|
+
// result
|
|
2157
|
+
if (filterType == 'text') {
|
|
2158
|
+
return isReverse ? txt1.localeCompare(txt2, 'zh-CN', {
|
|
2159
|
+
sensitivity: 'base'
|
|
2160
|
+
}) : txt2.localeCompare(txt1, 'zh-CN', {
|
|
2161
|
+
sensitivity: 'base'
|
|
2162
|
+
});
|
|
2163
|
+
} else {
|
|
2164
|
+
return isReverse ? txt1 < txt2 ? -1 : txt1 > txt2 ? 1 : 0 : txt2 < txt1 ? -1 : txt2 > txt1 ? 1 : 0;
|
|
2165
|
+
}
|
|
2129
2166
|
};
|
|
2130
|
-
|
|
2167
|
+
|
|
2168
|
+
// Use a custom sort method if available, otherwise default is used
|
|
2169
|
+
var sortFn = typeof sortBy === 'function' ? sortBy(handleProcess, filterType, inverse) : defaultSortBy;
|
|
2170
|
+
targetComparator.sort(sortFn);
|
|
2131
2171
|
|
|
2132
2172
|
//console.log( 'targetComparator:', targetComparator );
|
|
2133
2173
|
//console.log( 'inverse:', inverse );
|
|
@@ -2177,7 +2217,10 @@ var SortSprite = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_re
|
|
|
2177
2217
|
var fieldType = props.fieldType,
|
|
2178
2218
|
className = props.className,
|
|
2179
2219
|
icon = props.icon,
|
|
2180
|
-
|
|
2220
|
+
_props$isReverse = props.isReverse,
|
|
2221
|
+
isReverse = _props$isReverse === void 0 ? false : _props$isReverse,
|
|
2222
|
+
onClick = props.onClick,
|
|
2223
|
+
sortBy = props.sortBy;
|
|
2181
2224
|
var _useContext = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useContext)(TableContext),
|
|
2182
2225
|
originData = _useContext.originData,
|
|
2183
2226
|
rootRef = _useContext.rootRef,
|
|
@@ -2191,7 +2234,9 @@ var SortSprite = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_re
|
|
|
2191
2234
|
spyElement: rootRef.current,
|
|
2192
2235
|
fieldType: fieldType,
|
|
2193
2236
|
onColSort: onColSort,
|
|
2194
|
-
|
|
2237
|
+
isReverse: isReverse,
|
|
2238
|
+
onClick: onClick,
|
|
2239
|
+
sortBy: sortBy
|
|
2195
2240
|
}, [rootRef]),
|
|
2196
2241
|
handleSortList = _useTableSort.handleSortList;
|
|
2197
2242
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, colSortable ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
package/lib/cjs/Table/index.js
CHANGED
|
@@ -2069,7 +2069,28 @@ const App = () => {
|
|
|
2069
2069
|
|
|
2070
2070
|
useTableSort({
|
|
2071
2071
|
enabled: sortableTable && rootRef.current,
|
|
2072
|
-
spyElement: rootRef.current
|
|
2072
|
+
spyElement: rootRef.current,
|
|
2073
|
+
sortBy: (handleProcess: Function, filterType: string, inverse: boolean) => (a: Element, b: Element) => {
|
|
2074
|
+
|
|
2075
|
+
// Custom comparison logic
|
|
2076
|
+
let v1 = a.textContent, v2 = b.textContent;
|
|
2077
|
+
if (filterType === 'number') {
|
|
2078
|
+
v1 = parseFloat(v1);
|
|
2079
|
+
v2 = parseFloat(v2);
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
let result = 0;
|
|
2083
|
+
if (filterType === 'text') {
|
|
2084
|
+
result = v1.localeCompare(v2);
|
|
2085
|
+
} else {
|
|
2086
|
+
result = v1 - v2;
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
// Apply display animation and status updates
|
|
2090
|
+
handleProcess();
|
|
2091
|
+
|
|
2092
|
+
return inverse ? -result : result;
|
|
2093
|
+
}
|
|
2073
2094
|
}, [rootRef]);
|
|
2074
2095
|
|
|
2075
2096
|
return (
|
|
@@ -2087,8 +2108,11 @@ function useTableSort(_ref, deps) {
|
|
|
2087
2108
|
data = _ref.data,
|
|
2088
2109
|
spyElement = _ref.spyElement,
|
|
2089
2110
|
fieldType = _ref.fieldType,
|
|
2111
|
+
_ref$isReverse = _ref.isReverse,
|
|
2112
|
+
isReverse = _ref$isReverse === void 0 ? false : _ref$isReverse,
|
|
2090
2113
|
onColSort = _ref.onColSort,
|
|
2091
|
-
onClick = _ref.onClick
|
|
2114
|
+
onClick = _ref.onClick,
|
|
2115
|
+
sortBy = _ref.sortBy;
|
|
2092
2116
|
var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
|
|
2093
2117
|
_useState2 = useTableSort_slicedToArray(_useState, 2),
|
|
2094
2118
|
inverse = _useState2[0],
|
|
@@ -2102,16 +2126,22 @@ function useTableSort(_ref, deps) {
|
|
|
2102
2126
|
var filterType = fieldType || 'text';
|
|
2103
2127
|
var curIndex = el.dataset.tableCol;
|
|
2104
2128
|
var targetComparator = [].slice.call(tbodyRef.querySelectorAll("[data-table-col=\"".concat(curIndex, "\"]")));
|
|
2129
|
+
var handleProcess = function handleProcess() {
|
|
2130
|
+
allRows(spyElement).forEach(function (node) {
|
|
2131
|
+
node.classList.add('newsort');
|
|
2132
|
+
});
|
|
2133
|
+
setInverse(!inverse);
|
|
2134
|
+
};
|
|
2105
2135
|
|
|
2106
|
-
//
|
|
2107
|
-
var
|
|
2136
|
+
//
|
|
2137
|
+
var defaultSortBy = function defaultSortBy(a, b) {
|
|
2108
2138
|
var txt1 = a.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase(),
|
|
2109
2139
|
txt2 = b.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase();
|
|
2110
2140
|
|
|
2111
2141
|
//type of number
|
|
2112
2142
|
if (filterType == 'number') {
|
|
2113
|
-
txt1 =
|
|
2114
|
-
txt2 =
|
|
2143
|
+
txt1 = parseFloat(txt1.replace(/[^0-9.+-]+/g, ''));
|
|
2144
|
+
txt2 = parseFloat(txt2.replace(/[^0-9.+-]+/g, ''));
|
|
2115
2145
|
}
|
|
2116
2146
|
|
|
2117
2147
|
//type of date
|
|
@@ -2121,13 +2151,23 @@ function useTableSort(_ref, deps) {
|
|
|
2121
2151
|
}
|
|
2122
2152
|
|
|
2123
2153
|
//add filter class
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2154
|
+
handleProcess();
|
|
2155
|
+
|
|
2156
|
+
// result
|
|
2157
|
+
if (filterType == 'text') {
|
|
2158
|
+
return isReverse ? txt1.localeCompare(txt2, 'zh-CN', {
|
|
2159
|
+
sensitivity: 'base'
|
|
2160
|
+
}) : txt2.localeCompare(txt1, 'zh-CN', {
|
|
2161
|
+
sensitivity: 'base'
|
|
2162
|
+
});
|
|
2163
|
+
} else {
|
|
2164
|
+
return isReverse ? txt1 < txt2 ? -1 : txt1 > txt2 ? 1 : 0 : txt2 < txt1 ? -1 : txt2 > txt1 ? 1 : 0;
|
|
2165
|
+
}
|
|
2129
2166
|
};
|
|
2130
|
-
|
|
2167
|
+
|
|
2168
|
+
// Use a custom sort method if available, otherwise default is used
|
|
2169
|
+
var sortFn = typeof sortBy === 'function' ? sortBy(handleProcess, filterType, inverse) : defaultSortBy;
|
|
2170
|
+
targetComparator.sort(sortFn);
|
|
2131
2171
|
|
|
2132
2172
|
//console.log( 'targetComparator:', targetComparator );
|
|
2133
2173
|
//console.log( 'inverse:', inverse );
|
|
@@ -2177,7 +2217,10 @@ var SortSprite = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_re
|
|
|
2177
2217
|
var fieldType = props.fieldType,
|
|
2178
2218
|
className = props.className,
|
|
2179
2219
|
icon = props.icon,
|
|
2180
|
-
|
|
2220
|
+
_props$isReverse = props.isReverse,
|
|
2221
|
+
isReverse = _props$isReverse === void 0 ? false : _props$isReverse,
|
|
2222
|
+
onClick = props.onClick,
|
|
2223
|
+
sortBy = props.sortBy;
|
|
2181
2224
|
var _useContext = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useContext)(TableContext),
|
|
2182
2225
|
originData = _useContext.originData,
|
|
2183
2226
|
rootRef = _useContext.rootRef,
|
|
@@ -2191,7 +2234,9 @@ var SortSprite = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_re
|
|
|
2191
2234
|
spyElement: rootRef.current,
|
|
2192
2235
|
fieldType: fieldType,
|
|
2193
2236
|
onColSort: onColSort,
|
|
2194
|
-
|
|
2237
|
+
isReverse: isReverse,
|
|
2238
|
+
onClick: onClick,
|
|
2239
|
+
sortBy: sortBy
|
|
2195
2240
|
}, [rootRef]),
|
|
2196
2241
|
handleSortList = _useTableSort.handleSortList;
|
|
2197
2242
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, colSortable ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
@@ -174,7 +174,8 @@
|
|
|
174
174
|
}
|
|
175
175
|
.casc-select__items-wrapper .casc-select__items-col-searchbox input {
|
|
176
176
|
border: 1px solid var(--casc-select-searchbox-border-color);
|
|
177
|
-
border-radius: 0.
|
|
177
|
+
border-radius: 0.15rem;
|
|
178
|
+
width: 100%;
|
|
178
179
|
background: transparent;
|
|
179
180
|
font-size: 0.75rem;
|
|
180
181
|
}
|
|
@@ -174,7 +174,8 @@
|
|
|
174
174
|
}
|
|
175
175
|
.casc-select-e2e__items-wrapper .casc-select-e2e__items-col-searchbox input {
|
|
176
176
|
border: 1px solid var(--casc-select-e2e-searchbox-border-color);
|
|
177
|
-
border-radius: 0.
|
|
177
|
+
border-radius: 0.15rem;
|
|
178
|
+
width: 100%;
|
|
178
179
|
background: transparent;
|
|
179
180
|
font-size: 0.75rem;
|
|
180
181
|
}
|
|
@@ -239,7 +239,8 @@
|
|
|
239
239
|
.casc-select-e2e__items-col-searchbox {
|
|
240
240
|
input {
|
|
241
241
|
border: 1px solid var(--casc-select-e2e-searchbox-border-color);
|
|
242
|
-
border-radius: 0.
|
|
242
|
+
border-radius: 0.15rem;
|
|
243
|
+
width: 100%;
|
|
243
244
|
background: transparent;
|
|
244
245
|
font-size: 0.75rem;
|
|
245
246
|
}
|
package/lib/esm/Table/Table.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import useComId from 'funda-utils/dist/cjs/useComId';
|
|
|
5
5
|
import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
|
|
8
9
|
import { TableProvider } from './TableContext';
|
|
9
10
|
import useTableResponsive from './utils/hooks/useTableResponsive';
|
|
10
11
|
import useTableDraggable from './utils/hooks/useTableDraggable';
|
|
@@ -7,7 +7,9 @@ export type SortSpriteProps = {
|
|
|
7
7
|
fieldType: 'text' | 'number' | 'date';
|
|
8
8
|
className?: string;
|
|
9
9
|
icon?: React.ReactNode;
|
|
10
|
+
isReverse?: boolean;
|
|
10
11
|
onClick?: (e: any) => void;
|
|
12
|
+
sortBy?: (handleProcess: Function, filterType: string, inverse: boolean) => ((a: Element, b: Element) => number); // A function that determines the order of the elements.
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
|
|
@@ -16,7 +18,9 @@ const SortSprite = forwardRef((props: SortSpriteProps, externalRef: any) => {
|
|
|
16
18
|
fieldType,
|
|
17
19
|
className,
|
|
18
20
|
icon,
|
|
19
|
-
|
|
21
|
+
isReverse = false,
|
|
22
|
+
onClick,
|
|
23
|
+
sortBy
|
|
20
24
|
} = props;
|
|
21
25
|
|
|
22
26
|
const {
|
|
@@ -34,7 +38,9 @@ const SortSprite = forwardRef((props: SortSpriteProps, externalRef: any) => {
|
|
|
34
38
|
spyElement: rootRef.current,
|
|
35
39
|
fieldType: fieldType,
|
|
36
40
|
onColSort: onColSort,
|
|
37
|
-
|
|
41
|
+
isReverse: isReverse,
|
|
42
|
+
onClick: onClick,
|
|
43
|
+
sortBy: sortBy
|
|
38
44
|
}, [rootRef]);
|
|
39
45
|
|
|
40
46
|
|
|
@@ -10,7 +10,28 @@ const App = () => {
|
|
|
10
10
|
|
|
11
11
|
useTableSort({
|
|
12
12
|
enabled: sortableTable && rootRef.current,
|
|
13
|
-
spyElement: rootRef.current
|
|
13
|
+
spyElement: rootRef.current,
|
|
14
|
+
sortBy: (handleProcess: Function, filterType: string, inverse: boolean) => (a: Element, b: Element) => {
|
|
15
|
+
|
|
16
|
+
// Custom comparison logic
|
|
17
|
+
let v1 = a.textContent, v2 = b.textContent;
|
|
18
|
+
if (filterType === 'number') {
|
|
19
|
+
v1 = parseFloat(v1);
|
|
20
|
+
v2 = parseFloat(v2);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let result = 0;
|
|
24
|
+
if (filterType === 'text') {
|
|
25
|
+
result = v1.localeCompare(v2);
|
|
26
|
+
} else {
|
|
27
|
+
result = v1 - v2;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Apply display animation and status updates
|
|
31
|
+
handleProcess();
|
|
32
|
+
|
|
33
|
+
return inverse ? -result : result;
|
|
34
|
+
}
|
|
14
35
|
}, [rootRef]);
|
|
15
36
|
|
|
16
37
|
return (
|
|
@@ -25,13 +46,16 @@ import { useEffect, useState } from 'react';
|
|
|
25
46
|
|
|
26
47
|
import { getTbody, allRows, sortDataByIndex, initOrderProps, initRowColProps } from '../func';
|
|
27
48
|
|
|
49
|
+
|
|
28
50
|
export interface UseTableSortProps {
|
|
29
51
|
enabled: boolean;
|
|
30
52
|
data?: any[];
|
|
31
53
|
spyElement?: any;
|
|
32
54
|
fieldType: 'text' | 'number' | 'date';
|
|
55
|
+
isReverse?: boolean;
|
|
33
56
|
onColSort?: (fetchData: any) => void;
|
|
34
57
|
onClick?: (e: any) => void;
|
|
58
|
+
sortBy?: (handleProcess: Function, filterType: string, inverse: boolean) => ((a: Element, b: Element) => number); // A function that determines the order of the elements.
|
|
35
59
|
}
|
|
36
60
|
|
|
37
61
|
function useTableSort({
|
|
@@ -39,8 +63,10 @@ function useTableSort({
|
|
|
39
63
|
data,
|
|
40
64
|
spyElement,
|
|
41
65
|
fieldType,
|
|
66
|
+
isReverse = false,
|
|
42
67
|
onColSort,
|
|
43
|
-
onClick
|
|
68
|
+
onClick,
|
|
69
|
+
sortBy
|
|
44
70
|
}: UseTableSortProps, deps: any[]) {
|
|
45
71
|
|
|
46
72
|
|
|
@@ -60,17 +86,24 @@ function useTableSort({
|
|
|
60
86
|
const curIndex = el.dataset.tableCol;
|
|
61
87
|
const targetComparator = [].slice.call(tbodyRef.querySelectorAll(`[data-table-col="${curIndex}"]`));
|
|
62
88
|
|
|
89
|
+
const handleProcess = function () {
|
|
90
|
+
allRows(spyElement).forEach((node: any) => {
|
|
91
|
+
node.classList.add('newsort');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
setInverse(!inverse);
|
|
95
|
+
};
|
|
63
96
|
|
|
64
|
-
//
|
|
65
|
-
const
|
|
97
|
+
//
|
|
98
|
+
const defaultSortBy = function (a: Element, b: Element) {
|
|
66
99
|
|
|
67
|
-
let txt1 = a.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase(),
|
|
68
|
-
txt2 = b.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase();
|
|
100
|
+
let txt1: any = a.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase(),
|
|
101
|
+
txt2: any = b.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase();
|
|
69
102
|
|
|
70
103
|
//type of number
|
|
71
104
|
if (filterType == 'number') {
|
|
72
|
-
txt1 =
|
|
73
|
-
txt2 =
|
|
105
|
+
txt1 = parseFloat(txt1.replace(/[^0-9.+-]+/g, ''));
|
|
106
|
+
txt2 = parseFloat(txt2.replace(/[^0-9.+-]+/g, ''));
|
|
74
107
|
}
|
|
75
108
|
|
|
76
109
|
//type of date
|
|
@@ -79,17 +112,28 @@ function useTableSort({
|
|
|
79
112
|
txt2 = new Date(txt2);
|
|
80
113
|
}
|
|
81
114
|
|
|
82
|
-
//add filter class
|
|
83
|
-
allRows(spyElement).forEach((node: any) => {
|
|
84
|
-
node.classList.add('newsort');
|
|
85
|
-
});
|
|
86
115
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
116
|
+
//add filter class
|
|
117
|
+
handleProcess();
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
// result
|
|
121
|
+
if (filterType == 'text') {
|
|
122
|
+
return isReverse
|
|
123
|
+
? txt1.localeCompare(txt2, 'zh-CN', { sensitivity: 'base' })
|
|
124
|
+
: txt2.localeCompare(txt1, 'zh-CN', { sensitivity: 'base' });
|
|
125
|
+
} else {
|
|
126
|
+
return isReverse
|
|
127
|
+
? (txt1 < txt2 ? -1 : txt1 > txt2 ? 1 : 0)
|
|
128
|
+
: (txt2 < txt1 ? -1 : txt2 > txt1 ? 1 : 0);
|
|
129
|
+
}
|
|
130
|
+
|
|
90
131
|
}
|
|
91
132
|
|
|
92
|
-
|
|
133
|
+
// Use a custom sort method if available, otherwise default is used
|
|
134
|
+
const sortFn = typeof sortBy === 'function' ? sortBy(handleProcess, filterType, inverse) : defaultSortBy;
|
|
135
|
+
|
|
136
|
+
targetComparator.sort(sortFn);
|
|
93
137
|
|
|
94
138
|
//console.log( 'targetComparator:', targetComparator );
|
|
95
139
|
//console.log( 'inverse:', inverse );
|
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.7.
|
|
5
|
+
"version": "4.7.512",
|
|
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",
|