@daoyi/nmtl-ui 2.0.1-beta.47 → 2.0.1-beta.49
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/lib/components/{Autocomplete-5439ff22.js → Autocomplete-aa4a8d6c.js} +4 -2
- package/lib/components/Autocomplete.js +7 -6
- package/lib/components/Avatar.js +2 -4
- package/lib/components/BackTop.js +28 -1
- package/lib/components/BarChart.js +634 -4
- package/lib/components/Breadcrumbs.js +2 -4
- package/lib/components/{Button-63c7e9f3.js → Button-2f8f0493.js} +2 -1
- package/lib/components/Button.js +3 -5
- package/lib/components/Carousel.js +4659 -7
- package/lib/components/CollapseContent.js +3 -5
- package/lib/components/ContactModal-a44e2a42.js +10759 -0
- package/lib/components/ContactModal.js +14 -9
- package/lib/components/{Drawer-af3ed21a.js → Drawer-dd8942f1.js} +2 -2
- package/lib/components/Drawer.js +5 -7
- package/lib/components/Dropdown.js +2 -3
- package/lib/components/{Empty-70f040a9.js → Empty-3637b766.js} +2 -1
- package/lib/components/Empty.js +3 -5
- package/lib/components/ExportButton.js +3 -5
- package/lib/components/ExtraTools-55dad795.js +3479 -0
- package/lib/components/ExtraTools.js +6 -7
- package/lib/components/Filter.js +691 -5
- package/lib/components/Footer.js +14 -9
- package/lib/components/ForwardLink-4759cf99.js +105 -0
- package/lib/components/ForwardLink.js +9 -106
- package/lib/components/Header.js +10 -9
- package/lib/components/Image.js +7 -4
- package/lib/components/Input.js +2 -4
- package/lib/components/InputMethod.js +10861 -4
- package/lib/components/{KeywordSearch-224f84c1.js → KeywordSearch-2d01266e.js} +3 -2
- package/lib/components/KeywordSearch.js +8 -7
- package/lib/components/KeywordTicker.js +24 -16
- package/lib/components/Keywords.js +30 -5
- package/lib/components/Loading.js +2 -4
- package/lib/components/MUITheme.js +2375 -3
- package/lib/components/{Modal-a7591b98.js → Modal-572e17ea.js} +4 -3
- package/lib/components/Modal.js +5 -7
- package/lib/components/{MoreButton-f15ca38e.js → MoreButton-80996b5f.js} +2 -1
- package/lib/components/MoreButton.js +3 -5
- package/lib/components/Radio.js +1 -4
- package/lib/components/SNA.js +1416 -5
- package/lib/components/{Select-98a8e973.js → Select-5533b506.js} +3 -2
- package/lib/components/Select.js +4 -6
- package/lib/components/{Spin-690a3597.js → Spin-ebf79c17.js} +2 -1
- package/lib/components/Spin.js +3 -5
- package/lib/components/{Tooltip-b7eb966d.js → Tooltip-907eaa2e.js} +2 -1
- package/lib/components/Tooltip.js +3 -5
- package/lib/components/_commonjsHelpers-70de2c37.js +28 -0
- package/lib/components/createSvgIcon-48da8b6e.js +576 -0
- package/lib/components/dataExport-d55d6fa3.js +92 -0
- package/lib/components/debounce-127da66c.js +355 -0
- package/lib/components/defaultTheme-19a14721.js +1485 -0
- package/lib/components/hoist-non-react-statics.cjs-3f408ad2.js +105 -0
- package/lib/components/index-7b60a97d.js +481 -0
- package/lib/components/index-f491ebce.js +61 -0
- package/lib/components/isObjectLike-e111475d.js +190 -0
- package/lib/components/style-inject.es-1f59c1d0.js +28 -0
- package/lib/components/transform-3a04288b.js +5475 -0
- package/lib/utils/domToImage.js +771 -1
- package/lib/utils/exportXlsx.js +36 -1
- package/lib/utils/historyAppendSearch.js +480 -1
- package/package.json +1 -1
- package/lib/components/ContactModal-a59bc808.js +0 -924
- package/lib/components/ExtraTools-f10a66a8.js +0 -818
- package/lib/components/dataExport-f418e6fe.js +0 -56
- package/lib/components/vendor-851c6356.js +0 -41940
- package/lib/utils/vendor-3ec75cc9.js +0 -1289
package/lib/utils/exportXlsx.js
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
|
-
import { f as fileDownload } from './vendor-3ec75cc9.js';
|
|
2
1
|
import { a as _slicedToArray } from './_rollupPluginBabelHelpers-a6e0e6e3.js';
|
|
3
2
|
|
|
3
|
+
var fileDownload = function(data, filename, mime, bom) {
|
|
4
|
+
var blobData = (typeof bom !== 'undefined') ? [bom, data] : [data];
|
|
5
|
+
var blob = new Blob(blobData, {type: mime || 'application/octet-stream'});
|
|
6
|
+
if (typeof window.navigator.msSaveBlob !== 'undefined') {
|
|
7
|
+
// IE workaround for "HTML7007: One or more blob URLs were
|
|
8
|
+
// revoked by closing the blob for which they were created.
|
|
9
|
+
// These URLs will no longer resolve as the data backing
|
|
10
|
+
// the URL has been freed."
|
|
11
|
+
window.navigator.msSaveBlob(blob, filename);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
var blobURL = (window.URL && window.URL.createObjectURL) ? window.URL.createObjectURL(blob) : window.webkitURL.createObjectURL(blob);
|
|
15
|
+
var tempLink = document.createElement('a');
|
|
16
|
+
tempLink.style.display = 'none';
|
|
17
|
+
tempLink.href = blobURL;
|
|
18
|
+
tempLink.setAttribute('download', filename);
|
|
19
|
+
|
|
20
|
+
// Safari thinks _blank anchor are pop ups. We only want to set _blank
|
|
21
|
+
// target if the browser does not support the HTML5 download attribute.
|
|
22
|
+
// This allows you to download files in desktop safari if pop up blocking
|
|
23
|
+
// is enabled.
|
|
24
|
+
if (typeof tempLink.download === 'undefined') {
|
|
25
|
+
tempLink.setAttribute('target', '_blank');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
document.body.appendChild(tempLink);
|
|
29
|
+
tempLink.click();
|
|
30
|
+
|
|
31
|
+
// Fixes "webkit blob resource error 1"
|
|
32
|
+
setTimeout(function() {
|
|
33
|
+
document.body.removeChild(tempLink);
|
|
34
|
+
window.URL.revokeObjectURL(blobURL);
|
|
35
|
+
}, 200);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
4
39
|
var jsonExcel = function jsonExcel(json) {
|
|
5
40
|
var output = '';
|
|
6
41
|
if (Array.isArray(json) && json.length > 0) {
|
|
@@ -1,6 +1,485 @@
|
|
|
1
1
|
import { b as _objectWithoutProperties, c as _objectSpread2 } from './_rollupPluginBabelHelpers-a6e0e6e3.js';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
var queryString = {};
|
|
5
|
+
|
|
6
|
+
var strictUriEncode = str => encodeURIComponent(str).replace(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
7
|
+
|
|
8
|
+
var token = '%[a-f0-9]{2}';
|
|
9
|
+
var singleMatcher = new RegExp(token, 'gi');
|
|
10
|
+
var multiMatcher = new RegExp('(' + token + ')+', 'gi');
|
|
11
|
+
|
|
12
|
+
function decodeComponents(components, split) {
|
|
13
|
+
try {
|
|
14
|
+
// Try to decode the entire string first
|
|
15
|
+
return decodeURIComponent(components.join(''));
|
|
16
|
+
} catch (err) {
|
|
17
|
+
// Do nothing
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (components.length === 1) {
|
|
21
|
+
return components;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
split = split || 1;
|
|
25
|
+
|
|
26
|
+
// Split the array in 2 parts
|
|
27
|
+
var left = components.slice(0, split);
|
|
28
|
+
var right = components.slice(split);
|
|
29
|
+
|
|
30
|
+
return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function decode(input) {
|
|
34
|
+
try {
|
|
35
|
+
return decodeURIComponent(input);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
var tokens = input.match(singleMatcher);
|
|
38
|
+
|
|
39
|
+
for (var i = 1; i < tokens.length; i++) {
|
|
40
|
+
input = decodeComponents(tokens, i).join('');
|
|
41
|
+
|
|
42
|
+
tokens = input.match(singleMatcher);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return input;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function customDecodeURIComponent(input) {
|
|
50
|
+
// Keep track of all the replacements and prefill the map with the `BOM`
|
|
51
|
+
var replaceMap = {
|
|
52
|
+
'%FE%FF': '\uFFFD\uFFFD',
|
|
53
|
+
'%FF%FE': '\uFFFD\uFFFD'
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
var match = multiMatcher.exec(input);
|
|
57
|
+
while (match) {
|
|
58
|
+
try {
|
|
59
|
+
// Decode as big chunks as possible
|
|
60
|
+
replaceMap[match[0]] = decodeURIComponent(match[0]);
|
|
61
|
+
} catch (err) {
|
|
62
|
+
var result = decode(match[0]);
|
|
63
|
+
|
|
64
|
+
if (result !== match[0]) {
|
|
65
|
+
replaceMap[match[0]] = result;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
match = multiMatcher.exec(input);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else
|
|
73
|
+
replaceMap['%C2'] = '\uFFFD';
|
|
74
|
+
|
|
75
|
+
var entries = Object.keys(replaceMap);
|
|
76
|
+
|
|
77
|
+
for (var i = 0; i < entries.length; i++) {
|
|
78
|
+
// Replace all decoded components
|
|
79
|
+
var key = entries[i];
|
|
80
|
+
input = input.replace(new RegExp(key, 'g'), replaceMap[key]);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return input;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var decodeUriComponent = function (encodedURI) {
|
|
87
|
+
if (typeof encodedURI !== 'string') {
|
|
88
|
+
throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
encodedURI = encodedURI.replace(/\+/g, ' ');
|
|
93
|
+
|
|
94
|
+
// Try the built in decoder first
|
|
95
|
+
return decodeURIComponent(encodedURI);
|
|
96
|
+
} catch (err) {
|
|
97
|
+
// Fallback to a more advanced decoder
|
|
98
|
+
return customDecodeURIComponent(encodedURI);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
var splitOnFirst = (string, separator) => {
|
|
103
|
+
if (!(typeof string === 'string' && typeof separator === 'string')) {
|
|
104
|
+
throw new TypeError('Expected the arguments to be of type `string`');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (separator === '') {
|
|
108
|
+
return [string];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const separatorIndex = string.indexOf(separator);
|
|
112
|
+
|
|
113
|
+
if (separatorIndex === -1) {
|
|
114
|
+
return [string];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return [
|
|
118
|
+
string.slice(0, separatorIndex),
|
|
119
|
+
string.slice(separatorIndex + separator.length)
|
|
120
|
+
];
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
(function (exports) {
|
|
124
|
+
const strictUriEncode$1 = strictUriEncode;
|
|
125
|
+
const decodeComponent = decodeUriComponent;
|
|
126
|
+
const splitOnFirst$1 = splitOnFirst;
|
|
127
|
+
|
|
128
|
+
const isNullOrUndefined = value => value === null || value === undefined;
|
|
129
|
+
|
|
130
|
+
function encoderForArrayFormat(options) {
|
|
131
|
+
switch (options.arrayFormat) {
|
|
132
|
+
case 'index':
|
|
133
|
+
return key => (result, value) => {
|
|
134
|
+
const index = result.length;
|
|
135
|
+
|
|
136
|
+
if (
|
|
137
|
+
value === undefined ||
|
|
138
|
+
(options.skipNull && value === null) ||
|
|
139
|
+
(options.skipEmptyString && value === '')
|
|
140
|
+
) {
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (value === null) {
|
|
145
|
+
return [...result, [encode(key, options), '[', index, ']'].join('')];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return [
|
|
149
|
+
...result,
|
|
150
|
+
[encode(key, options), '[', encode(index, options), ']=', encode(value, options)].join('')
|
|
151
|
+
];
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
case 'bracket':
|
|
155
|
+
return key => (result, value) => {
|
|
156
|
+
if (
|
|
157
|
+
value === undefined ||
|
|
158
|
+
(options.skipNull && value === null) ||
|
|
159
|
+
(options.skipEmptyString && value === '')
|
|
160
|
+
) {
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (value === null) {
|
|
165
|
+
return [...result, [encode(key, options), '[]'].join('')];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return [...result, [encode(key, options), '[]=', encode(value, options)].join('')];
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
case 'comma':
|
|
172
|
+
case 'separator':
|
|
173
|
+
return key => (result, value) => {
|
|
174
|
+
if (value === null || value === undefined || value.length === 0) {
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (result.length === 0) {
|
|
179
|
+
return [[encode(key, options), '=', encode(value, options)].join('')];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
default:
|
|
186
|
+
return key => (result, value) => {
|
|
187
|
+
if (
|
|
188
|
+
value === undefined ||
|
|
189
|
+
(options.skipNull && value === null) ||
|
|
190
|
+
(options.skipEmptyString && value === '')
|
|
191
|
+
) {
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (value === null) {
|
|
196
|
+
return [...result, encode(key, options)];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return [...result, [encode(key, options), '=', encode(value, options)].join('')];
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function parserForArrayFormat(options) {
|
|
205
|
+
let result;
|
|
206
|
+
|
|
207
|
+
switch (options.arrayFormat) {
|
|
208
|
+
case 'index':
|
|
209
|
+
return (key, value, accumulator) => {
|
|
210
|
+
result = /\[(\d*)\]$/.exec(key);
|
|
211
|
+
|
|
212
|
+
key = key.replace(/\[\d*\]$/, '');
|
|
213
|
+
|
|
214
|
+
if (!result) {
|
|
215
|
+
accumulator[key] = value;
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (accumulator[key] === undefined) {
|
|
220
|
+
accumulator[key] = {};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
accumulator[key][result[1]] = value;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
case 'bracket':
|
|
227
|
+
return (key, value, accumulator) => {
|
|
228
|
+
result = /(\[\])$/.exec(key);
|
|
229
|
+
key = key.replace(/\[\]$/, '');
|
|
230
|
+
|
|
231
|
+
if (!result) {
|
|
232
|
+
accumulator[key] = value;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (accumulator[key] === undefined) {
|
|
237
|
+
accumulator[key] = [value];
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
case 'comma':
|
|
245
|
+
case 'separator':
|
|
246
|
+
return (key, value, accumulator) => {
|
|
247
|
+
const isArray = typeof value === 'string' && value.split('').indexOf(options.arrayFormatSeparator) > -1;
|
|
248
|
+
const newValue = isArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options);
|
|
249
|
+
accumulator[key] = newValue;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
default:
|
|
253
|
+
return (key, value, accumulator) => {
|
|
254
|
+
if (accumulator[key] === undefined) {
|
|
255
|
+
accumulator[key] = value;
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function validateArrayFormatSeparator(value) {
|
|
265
|
+
if (typeof value !== 'string' || value.length !== 1) {
|
|
266
|
+
throw new TypeError('arrayFormatSeparator must be single character string');
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function encode(value, options) {
|
|
271
|
+
if (options.encode) {
|
|
272
|
+
return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return value;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function decode(value, options) {
|
|
279
|
+
if (options.decode) {
|
|
280
|
+
return decodeComponent(value);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return value;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function keysSorter(input) {
|
|
287
|
+
if (Array.isArray(input)) {
|
|
288
|
+
return input.sort();
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (typeof input === 'object') {
|
|
292
|
+
return keysSorter(Object.keys(input))
|
|
293
|
+
.sort((a, b) => Number(a) - Number(b))
|
|
294
|
+
.map(key => input[key]);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return input;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function removeHash(input) {
|
|
301
|
+
const hashStart = input.indexOf('#');
|
|
302
|
+
if (hashStart !== -1) {
|
|
303
|
+
input = input.slice(0, hashStart);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return input;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function getHash(url) {
|
|
310
|
+
let hash = '';
|
|
311
|
+
const hashStart = url.indexOf('#');
|
|
312
|
+
if (hashStart !== -1) {
|
|
313
|
+
hash = url.slice(hashStart);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return hash;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function extract(input) {
|
|
320
|
+
input = removeHash(input);
|
|
321
|
+
const queryStart = input.indexOf('?');
|
|
322
|
+
if (queryStart === -1) {
|
|
323
|
+
return '';
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return input.slice(queryStart + 1);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function parseValue(value, options) {
|
|
330
|
+
if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {
|
|
331
|
+
value = Number(value);
|
|
332
|
+
} else if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
|
|
333
|
+
value = value.toLowerCase() === 'true';
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return value;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function parse(input, options) {
|
|
340
|
+
options = Object.assign({
|
|
341
|
+
decode: true,
|
|
342
|
+
sort: true,
|
|
343
|
+
arrayFormat: 'none',
|
|
344
|
+
arrayFormatSeparator: ',',
|
|
345
|
+
parseNumbers: false,
|
|
346
|
+
parseBooleans: false
|
|
347
|
+
}, options);
|
|
348
|
+
|
|
349
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
350
|
+
|
|
351
|
+
const formatter = parserForArrayFormat(options);
|
|
352
|
+
|
|
353
|
+
// Create an object with no prototype
|
|
354
|
+
const ret = Object.create(null);
|
|
355
|
+
|
|
356
|
+
if (typeof input !== 'string') {
|
|
357
|
+
return ret;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
input = input.trim().replace(/^[?#&]/, '');
|
|
361
|
+
|
|
362
|
+
if (!input) {
|
|
363
|
+
return ret;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
for (const param of input.split('&')) {
|
|
367
|
+
let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, ' ') : param, '=');
|
|
368
|
+
|
|
369
|
+
// Missing `=` should be `null`:
|
|
370
|
+
// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
|
|
371
|
+
value = value === undefined ? null : ['comma', 'separator'].includes(options.arrayFormat) ? value : decode(value, options);
|
|
372
|
+
formatter(decode(key, options), value, ret);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
for (const key of Object.keys(ret)) {
|
|
376
|
+
const value = ret[key];
|
|
377
|
+
if (typeof value === 'object' && value !== null) {
|
|
378
|
+
for (const k of Object.keys(value)) {
|
|
379
|
+
value[k] = parseValue(value[k], options);
|
|
380
|
+
}
|
|
381
|
+
} else {
|
|
382
|
+
ret[key] = parseValue(value, options);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (options.sort === false) {
|
|
387
|
+
return ret;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
|
|
391
|
+
const value = ret[key];
|
|
392
|
+
if (Boolean(value) && typeof value === 'object' && !Array.isArray(value)) {
|
|
393
|
+
// Sort object keys, not values
|
|
394
|
+
result[key] = keysSorter(value);
|
|
395
|
+
} else {
|
|
396
|
+
result[key] = value;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return result;
|
|
400
|
+
}, Object.create(null));
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
exports.extract = extract;
|
|
404
|
+
exports.parse = parse;
|
|
405
|
+
|
|
406
|
+
exports.stringify = (object, options) => {
|
|
407
|
+
if (!object) {
|
|
408
|
+
return '';
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
options = Object.assign({
|
|
412
|
+
encode: true,
|
|
413
|
+
strict: true,
|
|
414
|
+
arrayFormat: 'none',
|
|
415
|
+
arrayFormatSeparator: ','
|
|
416
|
+
}, options);
|
|
417
|
+
|
|
418
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
419
|
+
|
|
420
|
+
const shouldFilter = key => (
|
|
421
|
+
(options.skipNull && isNullOrUndefined(object[key])) ||
|
|
422
|
+
(options.skipEmptyString && object[key] === '')
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
const formatter = encoderForArrayFormat(options);
|
|
426
|
+
|
|
427
|
+
const objectCopy = {};
|
|
428
|
+
|
|
429
|
+
for (const key of Object.keys(object)) {
|
|
430
|
+
if (!shouldFilter(key)) {
|
|
431
|
+
objectCopy[key] = object[key];
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const keys = Object.keys(objectCopy);
|
|
436
|
+
|
|
437
|
+
if (options.sort !== false) {
|
|
438
|
+
keys.sort(options.sort);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
return keys.map(key => {
|
|
442
|
+
const value = object[key];
|
|
443
|
+
|
|
444
|
+
if (value === undefined) {
|
|
445
|
+
return '';
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
if (value === null) {
|
|
449
|
+
return encode(key, options);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
if (Array.isArray(value)) {
|
|
453
|
+
return value
|
|
454
|
+
.reduce(formatter(key), [])
|
|
455
|
+
.join('&');
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
return encode(key, options) + '=' + encode(value, options);
|
|
459
|
+
}).filter(x => x.length > 0).join('&');
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
exports.parseUrl = (input, options) => {
|
|
463
|
+
return {
|
|
464
|
+
url: removeHash(input).split('?')[0] || '',
|
|
465
|
+
query: parse(extract(input), options)
|
|
466
|
+
};
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
exports.stringifyUrl = (input, options) => {
|
|
470
|
+
const url = removeHash(input.url).split('?')[0] || '';
|
|
471
|
+
const queryFromUrl = exports.extract(input.url);
|
|
472
|
+
const parsedQueryFromUrl = exports.parse(queryFromUrl);
|
|
473
|
+
const hash = getHash(input.url);
|
|
474
|
+
const query = Object.assign(parsedQueryFromUrl, input.query);
|
|
475
|
+
let queryString = exports.stringify(query, options);
|
|
476
|
+
if (queryString) {
|
|
477
|
+
queryString = `?${queryString}`;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return `${url}${queryString}${hash}`;
|
|
481
|
+
};
|
|
482
|
+
} (queryString));
|
|
4
483
|
|
|
5
484
|
var _excluded = ["history"];
|
|
6
485
|
var historyAppendSearch = function historyAppendSearch(_ref) {
|
package/package.json
CHANGED