@noah-libjs/utils 0.0.3 → 0.0.5

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.
@@ -0,0 +1,17 @@
1
+ export declare const EMPTY_PLACEHOLDER = "-";
2
+ export declare const TOKEN_KEY = "\u03A3(\u3063 \u00B0\u0414 \u00B0;)\u3063";
3
+ export declare const ARG_URS1_KEY = "usr1";
4
+ export declare const ARG_URS2_KEY = "usr2";
5
+ export declare const noop: () => void;
6
+ export declare const ROMAN_NUMERALS: {
7
+ 1: string;
8
+ 2: string;
9
+ 3: string;
10
+ 4: string;
11
+ 5: string;
12
+ 6: string;
13
+ 7: string;
14
+ 8: string;
15
+ 9: string;
16
+ 10: string;
17
+ };
@@ -0,0 +1,37 @@
1
+ import { AnyObject } from "./type-utils";
2
+ interface IDictionary {
3
+ id: number;
4
+ module: string;
5
+ type: number;
6
+ key: string;
7
+ name: string;
8
+ note: string;
9
+ enumerations: Partial<IEnumeration>[];
10
+ }
11
+ interface IEnumeration {
12
+ id: number;
13
+ label: string;
14
+ note: string;
15
+ value: number;
16
+ }
17
+ export declare function getDictionaries(): AnyObject<IDictionary>;
18
+ /**
19
+ *
20
+ * @param value 枚举值value
21
+ * @param type string 字典类型
22
+ */
23
+ export declare function getDictionariesEnumerations(type: string): Partial<IEnumeration>[];
24
+ /**
25
+ *
26
+ * @param value 枚举值value
27
+ * @param type string 字典类型
28
+ */
29
+ export declare function getDictionaryLabel(type: string, value: string | number): string | null | undefined;
30
+ /**
31
+ *
32
+ * @param label 枚举值value
33
+ * @param type string 字典类型
34
+ */
35
+ export declare function getDictionaryValue(type: string, label: string): number | null | undefined;
36
+ export declare function merge_dict(ops: AnyObject<IDictionary>): void;
37
+ export {};
@@ -670,15 +670,15 @@ function all(_x11) {
670
670
  return _all.apply(this, arguments);
671
671
  }
672
672
  function _all() {
673
- _all = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(promises) {
673
+ _all = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(promises) {
674
674
  var entries, results, exceptions;
675
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
676
- while (1) switch (_context10.prev = _context10.next) {
675
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
676
+ while (1) switch (_context11.prev = _context11.next) {
677
677
  case 0:
678
678
  entries = isArray(promises) ? promises.map(function (p) {
679
679
  return [null, p];
680
680
  }) : Object.entries(promises);
681
- _context10.next = 3;
681
+ _context11.next = 3;
682
682
  return Promise.all(entries.map(function (_ref19) {
683
683
  var _ref20 = _slicedToArray(_ref19, 2),
684
684
  key = _ref20[0],
@@ -698,12 +698,12 @@ function _all() {
698
698
  });
699
699
  }));
700
700
  case 3:
701
- results = _context10.sent;
701
+ results = _context11.sent;
702
702
  exceptions = results.filter(function (r) {
703
703
  return r.exc;
704
704
  });
705
705
  if (!(exceptions.length > 0)) {
706
- _context10.next = 7;
706
+ _context11.next = 7;
707
707
  break;
708
708
  }
709
709
  throw new AggregateError(exceptions.map(function (e) {
@@ -711,21 +711,21 @@ function _all() {
711
711
  }));
712
712
  case 7:
713
713
  if (!isArray(promises)) {
714
- _context10.next = 9;
714
+ _context11.next = 9;
715
715
  break;
716
716
  }
717
- return _context10.abrupt("return", results.map(function (r) {
717
+ return _context11.abrupt("return", results.map(function (r) {
718
718
  return r.result;
719
719
  }));
720
720
  case 9:
721
- return _context10.abrupt("return", results.reduce(function (acc, item) {
721
+ return _context11.abrupt("return", results.reduce(function (acc, item) {
722
722
  return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, item.key, item.result));
723
723
  }, {}));
724
724
  case 10:
725
725
  case "end":
726
- return _context10.stop();
726
+ return _context11.stop();
727
727
  }
728
- }, _callee10);
728
+ }, _callee11);
729
729
  }));
730
730
  return _all.apply(this, arguments);
731
731
  }
@@ -1109,7 +1109,7 @@ var omit = function omit(obj, keys2) {
1109
1109
  return acc;
1110
1110
  }, _objectSpread({}, obj));
1111
1111
  };
1112
- var get = function get(value, path, defaultValue) {
1112
+ var get$1 = function get$1(value, path, defaultValue) {
1113
1113
  var segments = path.split(/[\.\[\]]/g);
1114
1114
  var current = value;
1115
1115
  var _iterator4 = _createForOfIteratorHelper(segments),
@@ -1189,7 +1189,7 @@ var crush = function crush(value) {
1189
1189
  return objectify(keys(value), function (k) {
1190
1190
  return k;
1191
1191
  }, function (k) {
1192
- return get(value, k);
1192
+ return get$1(value, k);
1193
1193
  });
1194
1194
  };
1195
1195
  var construct = function construct(obj) {
@@ -1355,6 +1355,15 @@ var trim = function trim(str) {
1355
1355
  var regex = new RegExp("^[".concat(toTrim, "]+|[").concat(toTrim, "]+$"), "g");
1356
1356
  return str.replace(regex, "");
1357
1357
  };
1358
+ function get(value, path, defaultValue) {
1359
+ //@ts-ignore
1360
+ var direct_value = value === null || value === void 0 ? void 0 : value[path];
1361
+ if (direct_value) return direct_value;
1362
+ return get$1(value, path, defaultValue);
1363
+ }
1364
+ function identity(value) {
1365
+ return value;
1366
+ }
1358
1367
  var symbolProto = Symbol ? Symbol.prototype : undefined;
1359
1368
  var symbolToString = symbolProto ? symbolProto.toString : undefined;
1360
1369
  var INFINITY = 1 / 0;
@@ -1367,6 +1376,11 @@ function isObjectLike(value) {
1367
1376
  function isNull(value) {
1368
1377
  return value === null;
1369
1378
  }
1379
+ function size(value) {
1380
+ if (isString(value) || isArray(value)) return value.length;
1381
+ if (isObject(value)) return Object.keys(value).length;
1382
+ return 0;
1383
+ }
1370
1384
  function isNil(value) {
1371
1385
  return value == null;
1372
1386
  }
@@ -1417,6 +1431,9 @@ function safe_json_parse(str) {
1417
1431
  }
1418
1432
  }
1419
1433
  function safe_json_stringify(obj) {
1434
+ if (isString(obj) && safe_json_parse(obj)) {
1435
+ return obj;
1436
+ }
1420
1437
  return JSON.stringify(obj);
1421
1438
  }
1422
1439
  function safe_json_parse_arr(str) {
@@ -1493,6 +1510,20 @@ function getSearchParamsAll(url) {
1493
1510
  }, {}) : {};
1494
1511
  return searchParams;
1495
1512
  }
1513
+ function setSearchParamsValue(key, value) {
1514
+ var _a;
1515
+ var url = new URL(location.toString());
1516
+ (_a = url === null || url === void 0 ? void 0 : url.searchParams) === null || _a === void 0 ? void 0 : _a.set(key, "".concat(value));
1517
+ return url;
1518
+ }
1519
+ function setSearchParamsAll(data) {
1520
+ var _url = new URL(location.href);
1521
+ Object.keys(data).forEach(function (k) {
1522
+ var _a;
1523
+ (_a = _url === null || _url === void 0 ? void 0 : _url.searchParams) === null || _a === void 0 ? void 0 : _a.set(k, "".concat(data[k]));
1524
+ });
1525
+ return _url;
1526
+ }
1496
1527
  function scrollIntoView(symbol) {
1497
1528
  var finder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document.querySelector.bind(document);
1498
1529
  var dom = finder(symbol);
@@ -1588,7 +1619,6 @@ function copyText(text) {
1588
1619
  textareaC.select();
1589
1620
  var res = document.execCommand('copy');
1590
1621
  document.body.removeChild(textareaC);
1591
- console.log("复制成功");
1592
1622
  return res;
1593
1623
  }
1594
1624
  function safeExec(fn) {
@@ -1632,7 +1662,11 @@ function safe_number_parse(value) {
1632
1662
  return isNaN(rawParse) ? defaultValue : rawParse;
1633
1663
  }
1634
1664
  function expect_array(value) {
1635
- if (!Array.isArray(value)) return [];
1665
+ var default_v = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1666
+ if (!Array.isArray(value)) {
1667
+ if (Array.isArray(default_v)) return default_v;
1668
+ return [];
1669
+ }
1636
1670
  return value;
1637
1671
  }
1638
1672
  // 生成包含字符的 svg 转义字符串
@@ -1794,15 +1828,29 @@ function simple_decrypt(code) {
1794
1828
  }).join('');
1795
1829
  return safe_json_parse(str);
1796
1830
  }
1831
+ function simple_encrypt_str(data) {
1832
+ if (!data || !isString(data)) return null;
1833
+ return data.split('').map(function (_, idx) {
1834
+ return ~_.charCodeAt(0) + idx * 119;
1835
+ }).join('@@');
1836
+ }
1837
+ function simple_decrypt_str(code) {
1838
+ if (!code || !isString(code)) return null;
1839
+ var str = code.split('@@').map(function (_, idx) {
1840
+ return String.fromCharCode(~(+_ - idx * 119));
1841
+ }).join('');
1842
+ return str;
1843
+ }
1797
1844
  function getFn(format) {
1798
- return Object.assign(function (s) {
1845
+ function f(s) {
1799
1846
  if (isFunction(s === null || s === void 0 ? void 0 : s.format)) {
1800
1847
  var res = s.format(format);
1801
1848
  if (isString(res)) return res;
1802
1849
  }
1803
1850
  var a = dayjs(s);
1804
1851
  return a.isValid() ? a.format(format) : null;
1805
- }, {
1852
+ }
1853
+ return Object.assign(f, {
1806
1854
  format: format
1807
1855
  });
1808
1856
  }
@@ -1813,21 +1861,67 @@ var formatDate = getFn('YYYY-MM-DD');
1813
1861
  var formatDateTime = getFn('YYYY-MM-DD HH:mm:ss');
1814
1862
  var formatDateTimeNoSecond = getFn('YYYY-MM-DD HH:mm');
1815
1863
  var formatTime = getFn('HH:mm:ss');
1864
+ function start() {
1865
+ var m = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : dayjs;
1866
+ return m().set('hour', 0).set('minute', 0).set('second', 0);
1867
+ }
1868
+ function end() {
1869
+ var m = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : dayjs;
1870
+ return m().set('hour', 23).set('minute', 59).set('second', 59);
1871
+ }
1816
1872
  function getMomentRange() {
1817
1873
  var m = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : dayjs;
1818
1874
  return {
1819
- 昨天: [m().add(-1, 'day'), m().add(-1, 'day')],
1820
- 今天: [m(), m()],
1821
- 明天: [m().add(1, 'day'), m().add(1, 'day')],
1822
- 上周: [m().add(-1, 'week').startOf('week'), m().add(-1, 'week').endOf('week')],
1823
- 这周: [m().startOf('week'), m().endOf('week')],
1824
- 下周: [m().add(1, 'week').startOf('week'), m().add(1, 'week').endOf('week')],
1825
- 上月: [m().add(-1, 'month').startOf('month'), m().add(-1, 'month').endOf('month')],
1826
- 这月: [m().startOf('month'), m().endOf('month')],
1827
- 下月: [m().add(1, 'month').startOf('month'), m().add(1, 'month').endOf('month')],
1828
- 今年: [m().startOf('year'), m().endOf('year')]
1875
+ 昨天: [start(m).add(-1, 'day'), end(m).add(-1, 'day')],
1876
+ 今天: [start(m), end(m)],
1877
+ 明天: [start(m).add(1, 'day'), end(m).add(1, 'day')],
1878
+ 上周: [start(m).add(-1, 'week').startOf('week'), end(m).add(-1, 'week').endOf('week')],
1879
+ // 这周: [start(m).startOf('week'), end(m).endOf('week')] as DT,
1880
+ 近一周: [start(m).add(-1, 'week').add(1, 'day'), end(m)],
1881
+ 下周: [start(m).add(1, 'week').startOf('week'), end(m).add(1, 'week').endOf('week')],
1882
+ 上月: [start(m).add(-1, 'month').startOf('month'), end(m).add(-1, 'month').endOf('month')],
1883
+ // 这月: [start(m).startOf('month'), end(m).endOf('month')] as DT,
1884
+ 近一月: [start(m).add(-1, 'month').add(1, 'day'), end(m)],
1885
+ 下月: [start(m).add(1, 'month').startOf('month'), end(m).add(1, 'month').endOf('month')],
1886
+ 近一年: [start(m).add(-1, 'year').add(1, 'day'), end(m)]
1829
1887
  };
1830
1888
  }
1889
+ function presets_date() {
1890
+ return [{
1891
+ label: '一月前',
1892
+ value: start().add(-1, 'month')
1893
+ }, {
1894
+ label: '一周前',
1895
+ value: start().add(-1, 'week')
1896
+ }, {
1897
+ label: '一天前',
1898
+ value: start().add(-1, 'day')
1899
+ }, {
1900
+ label: '一天后',
1901
+ value: start().add(1, 'day')
1902
+ }, {
1903
+ label: '两天后',
1904
+ value: start().add(2, 'day')
1905
+ }, {
1906
+ label: '三天后',
1907
+ value: start().add(3, 'day')
1908
+ }, {
1909
+ label: '一周后',
1910
+ value: start().add(1, 'week')
1911
+ }, {
1912
+ label: '两周后',
1913
+ value: start().add(2, 'week')
1914
+ }, {
1915
+ label: '一月后',
1916
+ value: start().add(1, 'month')
1917
+ }, {
1918
+ label: '两月后',
1919
+ value: start().add(2, 'month')
1920
+ }, {
1921
+ label: '半年后',
1922
+ value: start().add(6, 'month')
1923
+ }];
1924
+ }
1831
1925
  function isMoment(m) {
1832
1926
  return isFunction(m.format);
1833
1927
  }
@@ -1850,6 +1944,10 @@ function dayjs_quarter(input, which_quarter) {
1850
1944
  return [input, currentQuarter];
1851
1945
  }
1852
1946
  }
1947
+ function diff_between(a, b, unit) {
1948
+ var _float = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
1949
+ return dayjs(a).diff(dayjs(b), unit, _float);
1950
+ }
1853
1951
  var colorMap = {
1854
1952
  'log': '#1475b2',
1855
1953
  'warn': '#f89c1e',
@@ -2071,4 +2169,307 @@ Object.defineProperty(EventEmitter, "logger", {
2071
2169
  writable: true,
2072
2170
  value: new MyLog('EventEmitter')
2073
2171
  });
2074
- export { EventEmitter, MyLog, all, alphabetical, _assign as assign, base64ToBinary, base64_to_image, boil, cache_fetch, callable, camel, capitalize, chain, charToUTF8, charToUnicode, clone, cloneDeep, cluster, compose, confirm_operation, construct, copyText, counting, crush, dash, dayjs_quarter, debounce, defer, diff, downloadFile, draw, expect_array, filter_obj_to_url_search, first, flat, fork, formatDate, formatDateTime, formatDateTimeNoSecond, formatTime, gen_encoded_char_svg, get, getFilledArray, getFuckTimeInterval, getFutureDate, getMomentObj, getMomentRange, getSearchParamsAll, getSearchParamsValue, group, guard, image_to_base64, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, _isEqual as isEqual, isFloat, isFunction, isInt, isMoment, isNil, isNull, isNumber, isObject, isObjectLike, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, min, numberLikeCompare, objectify, omit, parallel, partial, partob, pascal, pick, proxied, random, randomHex, random_word, range, reduce, replace, replaceOrAppend, retry, safeExec, safeGetFromFuncOrData, safe_async_call, safe_json_parse, safe_json_parse_arr, safe_json_stringify, safe_number_parse, scrollIntoView, select, series, set, shake, shift, shuffle, sift, simple_decrypt, simple_encrypt, sleep, snake, sort, speculate_on_display, sum, template, throttle, title, toFloat, toInt, toString, toggle, trim, tryit as try, tryit, uid, unicodeToChar, unicode_to_UTF8, unique, upperize, uuid, warpBase64Type, zip, zipToObject };
2172
+ var EMPTY_PLACEHOLDER = '-';
2173
+ var TOKEN_KEY = 'Σ(っ °Д °;)っ';
2174
+ var ARG_URS1_KEY = 'usr1';
2175
+ var ARG_URS2_KEY = 'usr2';
2176
+ var noop = function noop() {};
2177
+ var ROMAN_NUMERALS = {
2178
+ 1: 'Ⅰ',
2179
+ 2: 'Ⅱ',
2180
+ 3: 'Ⅲ',
2181
+ 4: 'Ⅳ',
2182
+ 5: 'Ⅴ',
2183
+ 6: 'Ⅵ',
2184
+ 7: 'Ⅶ',
2185
+ 8: 'Ⅷ',
2186
+ 9: 'Ⅷ',
2187
+ 10: 'Ⅹ'
2188
+ };
2189
+ var selectOptionMap = {};
2190
+ var REGE_AutoComplete = /\<(.*)\>a$/;
2191
+ var REGE_MyCheckbox = /\<(.*)\>c$/;
2192
+ var REGE_MySelect = /\<(.*)\>s$/;
2193
+ var REGE_EXCLUSIVE = /^(.*)\<(.*)\>(.*)#$/;
2194
+ var optionKey其他 = 99;
2195
+ var optionKey不详 = 100;
2196
+ var optionKey否 = 0;
2197
+ var defalutSp = [{
2198
+ label: '不详',
2199
+ value: optionKey不详
2200
+ }, {
2201
+ label: '其他',
2202
+ value: optionKey其他,
2203
+ inputType: 'MyInput'
2204
+ }, {
2205
+ label: '其它',
2206
+ value: optionKey其他,
2207
+ inputType: 'MyInput'
2208
+ }, {
2209
+ label: '无',
2210
+ value: optionKey否,
2211
+ exclusive: true
2212
+ }, {
2213
+ label: '否',
2214
+ value: optionKey否,
2215
+ exclusive: true
2216
+ }];
2217
+ function _getSimpleOptions(_arr) {
2218
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2219
+ var arr = parseList(_arr);
2220
+ var _options$sp = options.sp,
2221
+ sp = _options$sp === void 0 ? [] : _options$sp,
2222
+ _options$start = options.start,
2223
+ start = _options$start === void 0 ? 1 : _options$start,
2224
+ _options$useDefault = options.useDefault,
2225
+ useDefault = _options$useDefault === void 0 ? true : _options$useDefault,
2226
+ useString = options.useString;
2227
+ var index = start;
2228
+ var opt = arr.map(function (_label, idx) {
2229
+ var _a, _b;
2230
+ var preset = presetInput(_label);
2231
+ var label = (_a = preset.label) !== null && _a !== void 0 ? _a : _label;
2232
+ var _defaultSpItem = useDefault ? defalutSp.find(function (s) {
2233
+ return label === s.label;
2234
+ }) : null;
2235
+ var _spItem = sp.find(function (s) {
2236
+ return label === s.label;
2237
+ });
2238
+ var spItem = (_b = _spItem !== null && _spItem !== void 0 ? _spItem : _defaultSpItem) !== null && _b !== void 0 ? _b : {};
2239
+ if (spItem.value && useString) {
2240
+ spItem.value = spItem.value.toString();
2241
+ }
2242
+ var _value = _defaultSpItem ? index : index++;
2243
+ return Object.assign({
2244
+ label: label,
2245
+ value: useString ? _value.toString() : _value,
2246
+ inputType: preset.inputType,
2247
+ props: preset.props,
2248
+ exclusive: preset.exclusive,
2249
+ parentheses: preset.parentheses,
2250
+ prefix: preset.prefix,
2251
+ suffix: preset.suffix
2252
+ }, spItem);
2253
+ });
2254
+ return opt;
2255
+ }
2256
+ function getSimpleOptions(_arr) {
2257
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2258
+ var ret = typeof _arr === 'function' ? function () {
2259
+ return _getSimpleOptions(_arr(), options);
2260
+ } : _getSimpleOptions(_arr, options);
2261
+ return ret;
2262
+ }
2263
+ function _getSameOptions(_arr) {
2264
+ var arr = parseList(_arr);
2265
+ return arr.map(function (label) {
2266
+ return {
2267
+ label: label,
2268
+ value: label
2269
+ };
2270
+ });
2271
+ }
2272
+ function getSameOptions(_arr) {
2273
+ var ret = typeof _arr === 'function' ? function () {
2274
+ return _getSameOptions(_arr());
2275
+ } : _getSameOptions(_arr);
2276
+ return ret;
2277
+ }
2278
+ function getDualModeOptions(arr, options) {
2279
+ return [getSimpleOptions(arr, options), getSameOptions(arr)];
2280
+ }
2281
+ function parseList(arr) {
2282
+ if (!arr) return [];
2283
+ var _arr = [];
2284
+ var split1 = [];
2285
+ if (Array.isArray(arr)) {
2286
+ _arr = arr;
2287
+ } else if ((split1 = arr.split(',')) && split1.length > 1) {
2288
+ _arr = split1;
2289
+ } else if ((split1 = arr.split('、')) && split1.length > 1) {
2290
+ _arr = split1;
2291
+ }
2292
+ return _arr;
2293
+ }
2294
+ function presetInput(_label) {
2295
+ if (!_label) return {
2296
+ label: _label
2297
+ };
2298
+ var withInput = (_label === null || _label === void 0 ? void 0 : _label.endsWith('|i')) || (_label === null || _label === void 0 ? void 0 : _label.endsWith('i'));
2299
+ if (withInput) {
2300
+ return {
2301
+ inputType: 'Input',
2302
+ label: _label.slice(0, -1)
2303
+ };
2304
+ }
2305
+ var useAuto = REGE_AutoComplete.exec(_label);
2306
+ if (useAuto) {
2307
+ return {
2308
+ inputType: 'MA',
2309
+ label: _label.slice(0, useAuto.index),
2310
+ props: {
2311
+ options: useAuto[1]
2312
+ }
2313
+ };
2314
+ }
2315
+ var useCheckbox = REGE_MyCheckbox.exec(_label);
2316
+ if (useCheckbox) {
2317
+ var config = useCheckbox[1];
2318
+ var arr = config.split('|');
2319
+ var options = arr[0];
2320
+ var marshal = arr[1] ? Number(arr[1]) : undefined;
2321
+ var type = arr[2] || undefined;
2322
+ return {
2323
+ inputType: 'MC',
2324
+ label: _label.slice(0, useCheckbox.index),
2325
+ props: {
2326
+ options: options,
2327
+ marshal: marshal,
2328
+ type: type
2329
+ }
2330
+ };
2331
+ }
2332
+ var useSelect = REGE_MySelect.exec(_label);
2333
+ if (useSelect) {
2334
+ var _config = useSelect[1];
2335
+ var _arr2 = _config.split('|');
2336
+ var _options = _arr2[0];
2337
+ var _marshal = _arr2[1] ? Number(_arr2[1]) : undefined;
2338
+ var mode = _arr2[2] || undefined;
2339
+ return {
2340
+ inputType: 'MS',
2341
+ label: _label.slice(0, useSelect.index),
2342
+ props: {
2343
+ options: _options,
2344
+ marshal: _marshal,
2345
+ mode: mode
2346
+ }
2347
+ };
2348
+ }
2349
+ // 文字<exclusive|parentheses|prefix|suffix>MyInput#
2350
+ var useExclusive = REGE_EXCLUSIVE.exec(_label);
2351
+ if (useExclusive) {
2352
+ var label = useExclusive[1];
2353
+ var _config2 = useExclusive[2];
2354
+ var _arr3 = _config2.split('|');
2355
+ var inputType = useExclusive[3];
2356
+ var exclusive = _arr3[0] ? Boolean(_arr3[0]) : undefined;
2357
+ var parentheses = _arr3[1] ? Boolean(_arr3[1]) : undefined;
2358
+ var prefix = _arr3[2];
2359
+ var suffix = _arr3[3];
2360
+ // mchcLogger.log('useExclusive', { useExclusive, exclusive, parentheses, prefix, suffix, inputType, label, _label })
2361
+ return {
2362
+ exclusive: exclusive,
2363
+ parentheses: parentheses,
2364
+ prefix: prefix,
2365
+ suffix: suffix,
2366
+ inputType: inputType,
2367
+ label: label
2368
+ };
2369
+ }
2370
+ return {
2371
+ label: _label
2372
+ };
2373
+ }
2374
+ function safe_fetch_options(cb) {
2375
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
2376
+ var arr;
2377
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
2378
+ while (1) switch (_context10.prev = _context10.next) {
2379
+ case 0:
2380
+ _context10.next = 2;
2381
+ return safe_async_call(cb);
2382
+ case 2:
2383
+ arr = _context10.sent;
2384
+ return _context10.abrupt("return", expect_array(arr));
2385
+ case 4:
2386
+ case "end":
2387
+ return _context10.stop();
2388
+ }
2389
+ }, _callee10);
2390
+ }));
2391
+ }
2392
+ function getPresetOptions(key) {
2393
+ var pure = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2394
+ var _a, _b;
2395
+ var options = (_b = (_a = selectOptionMap[key]) === null || _a === void 0 ? void 0 : _a.call(selectOptionMap)) !== null && _b !== void 0 ? _b : [];
2396
+ return pure ? options.map(function (_) {
2397
+ return Object.assign(Object.assign({}, _), {
2398
+ inputType: undefined
2399
+ });
2400
+ }) : options;
2401
+ }
2402
+ function getOptionLabel(k, value) {
2403
+ var defaultLabel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
2404
+ var _a, _b, _c, _d;
2405
+ var options = (_b = (_a = selectOptionMap[k]) === null || _a === void 0 ? void 0 : _a.call(selectOptionMap)) !== null && _b !== void 0 ? _b : [];
2406
+ return (_d = (_c = options.find(function (_) {
2407
+ return _.value === value;
2408
+ })) === null || _c === void 0 ? void 0 : _c.label) !== null && _d !== void 0 ? _d : defaultLabel;
2409
+ }
2410
+ function getOptionValue(k, label) {
2411
+ var _a, _b, _c;
2412
+ var options = (_b = (_a = selectOptionMap[k]) === null || _a === void 0 ? void 0 : _a.call(selectOptionMap)) !== null && _b !== void 0 ? _b : [];
2413
+ return (_c = options.find(function (_) {
2414
+ return _.label === label;
2415
+ })) === null || _c === void 0 ? void 0 : _c.value;
2416
+ }
2417
+ // merge options
2418
+ function merge_preset_options(ops) {
2419
+ Object.assign(selectOptionMap, ops);
2420
+ }
2421
+ var dic_map = {};
2422
+ function getDictionaries() {
2423
+ return dic_map;
2424
+ }
2425
+ /**
2426
+ *
2427
+ * @param value 枚举值value
2428
+ * @param type string 字典类型
2429
+ */
2430
+ function getDictionariesEnumerations(type) {
2431
+ var _a;
2432
+ var dictionaries = getDictionaries();
2433
+ var object = dictionaries === null || dictionaries === void 0 ? void 0 : dictionaries[type];
2434
+ if (!object) {
2435
+ console.warn("\u5B57\u5178 ".concat(type, " \u4E0D\u5B58\u5728!"));
2436
+ return [];
2437
+ }
2438
+ var enumerations = (_a = object === null || object === void 0 ? void 0 : object.enumerations) !== null && _a !== void 0 ? _a : [];
2439
+ return enumerations;
2440
+ }
2441
+ /**
2442
+ *
2443
+ * @param value 枚举值value
2444
+ * @param type string 字典类型
2445
+ */
2446
+ function getDictionaryLabel(type, value) {
2447
+ var enumerations = getDictionariesEnumerations(type);
2448
+ var item = enumerations.find(function (_) {
2449
+ return _.value === +value;
2450
+ });
2451
+ if (!item) {
2452
+ return null;
2453
+ }
2454
+ return item.label;
2455
+ }
2456
+ /**
2457
+ *
2458
+ * @param label 枚举值value
2459
+ * @param type string 字典类型
2460
+ */
2461
+ function getDictionaryValue(type, label) {
2462
+ var enumerations = getDictionariesEnumerations(type);
2463
+ var item = enumerations.find(function (_) {
2464
+ return _.label === label;
2465
+ });
2466
+ if (!item) {
2467
+ return null;
2468
+ }
2469
+ return item.value;
2470
+ }
2471
+ // merge dic
2472
+ function merge_dict(ops) {
2473
+ Object.assign(dic_map, ops);
2474
+ }
2475
+ export { ARG_URS1_KEY, ARG_URS2_KEY, EMPTY_PLACEHOLDER, EventEmitter, MyLog, ROMAN_NUMERALS, TOKEN_KEY, all, alphabetical, _assign as assign, base64ToBinary, base64_to_image, boil, cache_fetch, callable, camel, capitalize, chain, charToUTF8, charToUnicode, clone, cloneDeep, cluster, compose, confirm_operation, construct, copyText, counting, crush, dash, dayjs_quarter, debounce, defer, diff, diff_between, downloadFile, draw, expect_array, filter_obj_to_url_search, first, flat, fork, formatDate, formatDateTime, formatDateTimeNoSecond, formatTime, gen_encoded_char_svg, get, getDictionaries, getDictionariesEnumerations, getDictionaryLabel, getDictionaryValue, getDualModeOptions, getFilledArray, getFuckTimeInterval, getFutureDate, getMomentObj, getMomentRange, getOptionLabel, getOptionValue, getPresetOptions, getSameOptions, getSearchParamsAll, getSearchParamsValue, getSimpleOptions, group, guard, identity, image_to_base64, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, _isEqual as isEqual, isFloat, isFunction, isInt, isMoment, isNil, isNull, isNumber, isObject, isObjectLike, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, merge_dict, merge_preset_options, min, noop, numberLikeCompare, objectify, omit, optionKey不详, optionKey其他, optionKey否, parallel, partial, partob, pascal, pick, presets_date, proxied, random, randomHex, random_word, range, reduce, replace, replaceOrAppend, retry, safeExec, safeGetFromFuncOrData, safe_async_call, safe_fetch_options, safe_json_parse, safe_json_parse_arr, safe_json_stringify, safe_number_parse, scrollIntoView, select, series, set, setSearchParamsAll, setSearchParamsValue, shake, shift, shuffle, sift, simple_decrypt, simple_decrypt_str, simple_encrypt, simple_encrypt_str, size, sleep, snake, sort, speculate_on_display, sum, template, throttle, title, toFloat, toInt, toString, toggle, trim, tryit as try, tryit, uid, unicodeToChar, unicode_to_UTF8, unique, upperize, uuid, warpBase64Type, zip, zipToObject };
package/dist/helper.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  export * from "radash";
2
+ export declare function get<T = any>(value: T, path: string, defaultValue?: T | undefined): T;
3
+ export declare function identity<T>(value: T): T;
2
4
  export declare function isBoolean(value: any): value is boolean;
3
5
  export declare function isObjectLike(value: any): boolean;
4
6
  export declare function isNull(value: any): value is null;
7
+ export declare function size(value: any): number;
5
8
  export declare function isNil(value: any): value is null | undefined;
6
9
  export declare function toString(value: any): string;
7
10
  export declare function cloneDeep<T>(value: T): T | null;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,11 @@
1
+ export * from './types';
1
2
  export * from './helper';
2
- export * from './type-utils';
3
3
  export * from './json-helper';
4
4
  export * from './small-fn';
5
5
  export * from './Event';
6
+ export * from './type-utils';
6
7
  export * from './log';
8
+ export * from './constant';
7
9
  export * from './moment-help';
10
+ export * from './option-help';
11
+ export * from './dic-helper';