@xfe-repo/web-components 1.2.6 → 1.5.0

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/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import React, { PureComponent, RefObject, ReactNode } from 'react';
2
+ import * as React from 'react';
3
+ import React__default, { PureComponent, RefObject, ReactNode } from 'react';
3
4
  import { ThemeConfig } from 'antd/lib';
4
5
  import { KeepAliveRef, useKeepAliveRef } from 'keepalive-for-react';
5
6
 
@@ -17,7 +18,7 @@ type MultiWindowContentsProps = {
17
18
  children: ReactNode;
18
19
  contentRef?: MultiWindowContentsRefType;
19
20
  };
20
- declare const MultiWindowContents: React.MemoExoticComponent<(props: MultiWindowContentsProps) => react_jsx_runtime.JSX.Element>;
21
+ declare const MultiWindowContents: React__default.MemoExoticComponent<(props: MultiWindowContentsProps) => react_jsx_runtime.JSX.Element>;
21
22
 
22
23
  type PagePathType = {
23
24
  label: string;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import React, { PureComponent, RefObject, ReactNode } from 'react';
2
+ import * as React from 'react';
3
+ import React__default, { PureComponent, RefObject, ReactNode } from 'react';
3
4
  import { ThemeConfig } from 'antd/lib';
4
5
  import { KeepAliveRef, useKeepAliveRef } from 'keepalive-for-react';
5
6
 
@@ -17,7 +18,7 @@ type MultiWindowContentsProps = {
17
18
  children: ReactNode;
18
19
  contentRef?: MultiWindowContentsRefType;
19
20
  };
20
- declare const MultiWindowContents: React.MemoExoticComponent<(props: MultiWindowContentsProps) => react_jsx_runtime.JSX.Element>;
21
+ declare const MultiWindowContents: React__default.MemoExoticComponent<(props: MultiWindowContentsProps) => react_jsx_runtime.JSX.Element>;
21
22
 
22
23
  type PagePathType = {
23
24
  label: string;
package/dist/index.js CHANGED
@@ -16,6 +16,10 @@ function _assert_this_initialized(self) {
16
16
  }
17
17
  return self;
18
18
  }
19
+ function _call_super(_this, derived, args) {
20
+ derived = _get_prototype_of(derived);
21
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
22
+ }
19
23
  function _class_call_check(instance, Constructor) {
20
24
  if (!(instance instanceof Constructor)) {
21
25
  throw new TypeError("Cannot call a class as a function");
@@ -141,12 +145,22 @@ function _object_spread_props(target, source) {
141
145
  }
142
146
  function _object_without_properties(source, excluded) {
143
147
  if (source == null) return {};
144
- var target = _object_without_properties_loose(source, excluded);
145
- var key, i;
148
+ var target = {}, sourceKeys, key, i;
149
+ if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
150
+ sourceKeys = Reflect.ownKeys(Object(source));
151
+ for(i = 0; i < sourceKeys.length; i++){
152
+ key = sourceKeys[i];
153
+ if (excluded.indexOf(key) >= 0) continue;
154
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
155
+ target[key] = source[key];
156
+ }
157
+ return target;
158
+ }
159
+ target = _object_without_properties_loose(source, excluded);
146
160
  if (Object.getOwnPropertySymbols) {
147
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
148
- for(i = 0; i < sourceSymbolKeys.length; i++){
149
- key = sourceSymbolKeys[i];
161
+ sourceKeys = Object.getOwnPropertySymbols(source);
162
+ for(i = 0; i < sourceKeys.length; i++){
163
+ key = sourceKeys[i];
150
164
  if (excluded.indexOf(key) >= 0) continue;
151
165
  if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
152
166
  target[key] = source[key];
@@ -156,12 +170,11 @@ function _object_without_properties(source, excluded) {
156
170
  }
157
171
  function _object_without_properties_loose(source, excluded) {
158
172
  if (source == null) return {};
159
- var target = {};
160
- var sourceKeys = Object.keys(source);
161
- var key, i;
173
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
162
174
  for(i = 0; i < sourceKeys.length; i++){
163
175
  key = sourceKeys[i];
164
176
  if (excluded.indexOf(key) >= 0) continue;
177
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
165
178
  target[key] = source[key];
166
179
  }
167
180
  return target;
@@ -198,28 +211,12 @@ function _unsupported_iterable_to_array(o, minLen) {
198
211
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
199
212
  }
200
213
  function _is_native_reflect_construct() {
201
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
202
- if (Reflect.construct.sham) return false;
203
- if (typeof Proxy === "function") return true;
204
214
  try {
205
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
206
- return true;
207
- } catch (e) {
208
- return false;
209
- }
210
- }
211
- function _create_super(Derived) {
212
- var hasNativeReflectConstruct = _is_native_reflect_construct();
213
- return function _createSuperInternal() {
214
- var Super = _get_prototype_of(Derived), result;
215
- if (hasNativeReflectConstruct) {
216
- var NewTarget = _get_prototype_of(this).constructor;
217
- result = Reflect.construct(Super, arguments, NewTarget);
218
- } else {
219
- result = Super.apply(this, arguments);
220
- }
221
- return _possible_constructor_return(this, result);
222
- };
215
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
216
+ } catch (_) {}
217
+ return (_is_native_reflect_construct = function() {
218
+ return !!result;
219
+ })();
223
220
  }
224
221
  var __create = Object.create;
225
222
  var __defProp = Object.defineProperty;
@@ -227,20 +224,20 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
227
224
  var __getOwnPropNames = Object.getOwnPropertyNames;
228
225
  var __getProtoOf = Object.getPrototypeOf;
229
226
  var __hasOwnProp = Object.prototype.hasOwnProperty;
230
- var __export = function(target, all) {
227
+ var __export = function __export(target, all) {
231
228
  for(var name in all)__defProp(target, name, {
232
229
  get: all[name],
233
230
  enumerable: true
234
231
  });
235
232
  };
236
- var __copyProps = function(to, from, except, desc) {
237
- if (from && typeof from === "object" || typeof from === "function") {
233
+ var __copyProps = function __copyProps(to, from, except, desc) {
234
+ if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
238
235
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
239
236
  try {
240
237
  var _loop = function() {
241
238
  var key = _step.value;
242
239
  if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
243
- get: function() {
240
+ get: function get() {
244
241
  return from[key];
245
242
  },
246
243
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
@@ -264,7 +261,7 @@ var __copyProps = function(to, from, except, desc) {
264
261
  }
265
262
  return to;
266
263
  };
267
- var __toESM = function(mod, isNodeMode, target) {
264
+ var __toESM = function __toESM(mod, isNodeMode, target) {
268
265
  return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
269
266
  // file that has been converted to a CommonJS file using a Babel-
270
267
  // compatible transform (i.e. "__esModule" has not been set), then set
@@ -274,28 +271,28 @@ var __toESM = function(mod, isNodeMode, target) {
274
271
  enumerable: true
275
272
  }) : target, mod);
276
273
  };
277
- var __toCommonJS = function(mod) {
274
+ var __toCommonJS = function __toCommonJS(mod) {
278
275
  return __copyProps(__defProp({}, "__esModule", {
279
276
  value: true
280
277
  }), mod);
281
278
  };
282
279
  // src/index.ts
283
- var src_exports = {};
284
- __export(src_exports, {
285
- Loading: function() {
280
+ var index_exports = {};
281
+ __export(index_exports, {
282
+ Loading: function Loading1() {
286
283
  return Loading;
287
284
  },
288
- MultiWindow: function() {
285
+ MultiWindow: function MultiWindow1() {
289
286
  return MultiWindow;
290
287
  },
291
- MultiWindowContents: function() {
288
+ MultiWindowContents: function MultiWindowContents1() {
292
289
  return MultiWindowContents;
293
290
  },
294
- useMultiWindowContentsRef: function() {
291
+ useMultiWindowContentsRef: function useMultiWindowContentsRef1() {
295
292
  return useMultiWindowContentsRef;
296
293
  }
297
294
  });
298
- module.exports = __toCommonJS(src_exports);
295
+ module.exports = __toCommonJS(index_exports);
299
296
  // src/Loading/index.tsx
300
297
  var import_react = require("react");
301
298
  // src/Loading/index.module.less
@@ -307,10 +304,9 @@ var import_antd = require("antd");
307
304
  var import_jsx_runtime = require("react/jsx-runtime");
308
305
  var Loading = /*#__PURE__*/ function(_import_react_PureComponent) {
309
306
  _inherits(Loading, _import_react_PureComponent);
310
- var _super = _create_super(Loading);
311
307
  function Loading() {
312
308
  _class_call_check(this, Loading);
313
- return _super.apply(this, arguments);
309
+ return _call_super(this, Loading, arguments);
314
310
  }
315
311
  _create_class(Loading, [
316
312
  {
@@ -333,9 +329,14 @@ var Loading = /*#__PURE__*/ function(_import_react_PureComponent) {
333
329
  }(import_react.PureComponent);
334
330
  // src/MultiWindow/MultiWindow.tsx
335
331
  var import_react5 = require("react");
332
+ var import_classnames = __toESM(require("classnames"));
333
+ var import_icons2 = require("@ant-design/icons");
334
+ var import_antd4 = require("antd");
336
335
  var import_web_micro = require("@xfe-repo/web-micro");
336
+ var import_web_router = require("@xfe-repo/web-router");
337
337
  var import_tools = require("@xfe-repo/web-utils/tools");
338
- var import_classnames = __toESM(require("classnames"));
338
+ // src/MultiWindow/MultiWindowSearch.tsx
339
+ var import_react2 = require("react");
339
340
  // src/MultiWindow/MultiWindow.module.less
340
341
  var MultiWindow_module_default = {
341
342
  multi_window: "MultiWindow_module_multi_window",
@@ -346,26 +347,74 @@ var MultiWindow_module_default = {
346
347
  input: "MultiWindow_module_input",
347
348
  collection: "MultiWindow_module_collection"
348
349
  };
349
- // src/MultiWindow/MultiWindow.tsx
350
- var import_antd4 = require("antd");
351
- var import_icons2 = require("@ant-design/icons");
352
- // src/MultiWindow/MultiWindowTabs.tsx
353
- var import_react2 = __toESM(require("react"));
350
+ // src/MultiWindow/MultiWindowSearch.tsx
354
351
  var import_antd2 = require("antd");
352
+ var import_icons = require("@ant-design/icons");
353
+ var import_jsx_runtime2 = require("react/jsx-runtime");
354
+ var Search = import_antd2.Input.Search;
355
+ var MultiWindowSearch = (0, import_react2.memo)(function(props) {
356
+ var onSearch = props.onSearch;
357
+ var _ref = _sliced_to_array((0, import_react2.useState)(false), 2), showSearch = _ref[0], setShowSearch = _ref[1];
358
+ var _ref1 = _sliced_to_array((0, import_react2.useState)(""), 2), searchValue = _ref1[0], setSearchValue = _ref1[1];
359
+ var shouldShowSearch = (0, import_react2.useMemo)(function() {
360
+ return showSearch || searchValue;
361
+ }, [
362
+ showSearch,
363
+ searchValue
364
+ ]);
365
+ var handleShowSearch = (0, import_react2.useCallback)(function() {
366
+ setShowSearch(true);
367
+ }, []);
368
+ var handleHideSearch = (0, import_react2.useCallback)(function() {
369
+ setShowSearch(false);
370
+ }, []);
371
+ var handleSearch = (0, import_react2.useCallback)(function(value) {
372
+ setSearchValue(value);
373
+ onSearch === null || onSearch === void 0 ? void 0 : onSearch(value);
374
+ }, [
375
+ onSearch
376
+ ]);
377
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", {
378
+ className: MultiWindow_module_default.search,
379
+ onMouseLeave: handleHideSearch,
380
+ onMouseEnter: handleShowSearch,
381
+ children: [
382
+ shouldShowSearch && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Search, {
383
+ className: MultiWindow_module_default.input,
384
+ placeholder: "\u6807\u7B7E/\u5355\u53F7",
385
+ onSearch: handleSearch,
386
+ allowClear: true,
387
+ autoFocus: true
388
+ }),
389
+ !shouldShowSearch && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd2.Tooltip, {
390
+ title: "\u641C\u7D22\u6807\u7B7E/\u5355\u53F7",
391
+ color: "var(--ant-color-primary)",
392
+ mouseEnterDelay: 0.5,
393
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd2.Button, {
394
+ icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons.SearchOutlined, {}),
395
+ type: "text"
396
+ })
397
+ })
398
+ ]
399
+ });
400
+ });
401
+ // src/MultiWindow/MultiWindowTabs.tsx
402
+ var import_react3 = __toESM(require("react"));
403
+ var import_antd3 = require("antd");
355
404
  var import_core = require("@dnd-kit/core");
356
405
  var import_sortable = require("@dnd-kit/sortable");
357
406
  var import_modifiers = require("@dnd-kit/modifiers");
358
407
  var import_utilities = require("@dnd-kit/utilities");
359
- var import_jsx_runtime2 = require("react/jsx-runtime");
360
- var import_react3 = require("react");
361
- var MultiWindowTabs = (0, import_react2.memo)(function(props) {
408
+ var import_jsx_runtime3 = require("react/jsx-runtime");
409
+ var import_react4 = require("react");
410
+ var MultiWindowTabs = (0, import_react3.memo)(function(props) {
362
411
  var pathKey = props.pathKey, pagePaths = props.pagePaths, className = props.className, onChange = props.onChange, onClose = props.onClose, onSort = props.onSort, onCollectionChange = props.onCollectionChange, sortAutoActive = props.sortAutoActive;
363
412
  var sensor = (0, import_core.useSensor)(import_core.PointerSensor, {
364
413
  activationConstraint: {
365
414
  distance: 10
366
415
  }
367
416
  });
368
- var pagePathsHelperData = (0, import_react2.useMemo)(function() {
417
+ var pagePathsHelperData = (0, import_react3.useMemo)(function() {
369
418
  var keys = [];
370
419
  var map = /* @__PURE__ */ new Map();
371
420
  pagePaths.forEach(function(item) {
@@ -379,26 +428,26 @@ var MultiWindowTabs = (0, import_react2.memo)(function(props) {
379
428
  }, [
380
429
  pagePaths
381
430
  ]);
382
- var handleEdit = (0, import_react2.useCallback)(function(targetKey, action) {
431
+ var handleEdit = (0, import_react3.useCallback)(function(targetKey, action) {
383
432
  if (action === "add") {} else if (action === "remove") {
384
433
  onClose === null || onClose === void 0 ? void 0 : onClose(String(targetKey));
385
434
  }
386
435
  }, [
387
436
  onClose
388
437
  ]);
389
- var handleTabChange = (0, import_react2.useCallback)(function(activeKey) {
438
+ var handleTabChange = (0, import_react3.useCallback)(function(activeKey) {
390
439
  onChange === null || onChange === void 0 ? void 0 : onChange(activeKey);
391
440
  }, [
392
441
  onChange
393
442
  ]);
394
- var onDragStart = (0, import_react2.useCallback)(function(event) {
443
+ var onDragStart = (0, import_react3.useCallback)(function(event) {
395
444
  var active = event.active;
396
445
  sortAutoActive && (onChange === null || onChange === void 0 ? void 0 : onChange(String(active.id)));
397
446
  }, [
398
447
  onChange,
399
448
  sortAutoActive
400
449
  ]);
401
- var onDragEnd = (0, import_react2.useCallback)(function(event) {
450
+ var onDragEnd = (0, import_react3.useCallback)(function(event) {
402
451
  var active = event.active, over = event.over;
403
452
  if (active.id === (over === null || over === void 0 ? void 0 : over.id)) return;
404
453
  var oldIndex = pagePaths.findIndex(function(i) {
@@ -413,8 +462,8 @@ var MultiWindowTabs = (0, import_react2.memo)(function(props) {
413
462
  pagePaths,
414
463
  onSort
415
464
  ]);
416
- var renderTabBar = (0, import_react2.useCallback)(function(tabBarProps, DefaultTabBar) {
417
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core.DndContext, {
465
+ var renderTabBar = (0, import_react3.useCallback)(function(tabBarProps, DefaultTabBar) {
466
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core.DndContext, {
418
467
  sensors: [
419
468
  sensor
420
469
  ],
@@ -424,12 +473,12 @@ var MultiWindowTabs = (0, import_react2.memo)(function(props) {
424
473
  modifiers: [
425
474
  import_modifiers.restrictToHorizontalAxis
426
475
  ],
427
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_sortable.SortableContext, {
476
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_sortable.SortableContext, {
428
477
  items: pagePathsHelperData.keys,
429
478
  strategy: import_sortable.horizontalListSortingStrategy,
430
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DefaultTabBar, _object_spread_props(_object_spread({}, tabBarProps), {
431
- children: function(node) {
432
- return /* @__PURE__ */ (0, import_react3.createElement)(TabItem, _object_spread_props(_object_spread({}, node.props), {
479
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DefaultTabBar, _object_spread_props(_object_spread({}, tabBarProps), {
480
+ children: function children(node) {
481
+ return /* @__PURE__ */ (0, import_react4.createElement)(TabItem, _object_spread_props(_object_spread({}, node.props), {
433
482
  key: node.key,
434
483
  data: pagePathsHelperData.map.get(String(node.key)),
435
484
  onCollectionChange: onCollectionChange,
@@ -446,7 +495,7 @@ var MultiWindowTabs = (0, import_react2.memo)(function(props) {
446
495
  onCollectionChange,
447
496
  sensor
448
497
  ]);
449
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd2.Tabs, {
498
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Tabs, {
450
499
  className: className,
451
500
  activeKey: pathKey,
452
501
  onChange: handleTabChange,
@@ -458,18 +507,18 @@ var MultiWindowTabs = (0, import_react2.memo)(function(props) {
458
507
  hideAdd: true
459
508
  });
460
509
  });
461
- var TabItem = (0, import_react2.memo)(function(props) {
510
+ var TabItem = (0, import_react3.memo)(function(props) {
462
511
  var data = props.data, children = props.children, style = props.style, isActivated = props.isActivated, onCollectionChange = props.onCollectionChange;
463
512
  var _ref = (0, import_sortable.useSortable)({
464
513
  id: props["data-node-key"]
465
514
  }), attributes = _ref.attributes, listeners = _ref.listeners, setNodeRef = _ref.setNodeRef, transform = _ref.transform, transition = _ref.transition, isDragging = _ref.isDragging;
466
- var handleCollectionChange = (0, import_react2.useCallback)(function(collectionKey) {
515
+ var handleCollectionChange = (0, import_react3.useCallback)(function(collectionKey) {
467
516
  if (!data) return;
468
517
  onCollectionChange === null || onCollectionChange === void 0 ? void 0 : onCollectionChange(data.key, collectionKey);
469
518
  }, [
470
519
  data
471
520
  ]);
472
- var collectionSelect = (0, import_react2.useMemo)(function() {
521
+ var collectionSelect = (0, import_react3.useMemo)(function() {
473
522
  var _data_searchCollection;
474
523
  if (!(data === null || data === void 0 ? void 0 : (_data_searchCollection = data.searchCollection) === null || _data_searchCollection === void 0 ? void 0 : _data_searchCollection.length)) return null;
475
524
  if (!isActivated) return null;
@@ -480,7 +529,7 @@ var TabItem = (0, import_react2.memo)(function(props) {
480
529
  };
481
530
  });
482
531
  var currentKey = data.searchCollection[0];
483
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd2.Select, {
532
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Select, {
484
533
  className: MultiWindow_module_default.collection,
485
534
  options: options,
486
535
  value: currentKey,
@@ -488,13 +537,13 @@ var TabItem = (0, import_react2.memo)(function(props) {
488
537
  popupMatchSelectWidth: false,
489
538
  size: "small",
490
539
  showSearch: true,
491
- placeholder: "请选择"
540
+ placeholder: "\u8BF7\u9009\u62E9"
492
541
  }, data.key);
493
542
  }, [
494
543
  data,
495
544
  isActivated
496
545
  ]);
497
- var childrenWithCollectionSelect = (0, import_react2.useMemo)(function() {
546
+ var childrenWithCollectionSelect = (0, import_react3.useMemo)(function() {
498
547
  var innerChildren = children.props.children;
499
548
  if (!Array.isArray(innerChildren)) return innerChildren;
500
549
  var newChildren = _to_consumable_array(innerChildren);
@@ -504,7 +553,7 @@ var TabItem = (0, import_react2.memo)(function(props) {
504
553
  children,
505
554
  collectionSelect
506
555
  ]);
507
- return import_react2.default.cloneElement(children, _object_spread({
556
+ return import_react3.default.cloneElement(children, _object_spread({
508
557
  ref: setNodeRef,
509
558
  style: _object_spread_props(_object_spread({}, style), {
510
559
  transform: import_utilities.CSS.Translate.toString(transform && _object_spread_props(_object_spread({}, transform), {
@@ -517,58 +566,6 @@ var TabItem = (0, import_react2.memo)(function(props) {
517
566
  children: childrenWithCollectionSelect
518
567
  }, attributes, listeners));
519
568
  });
520
- // src/MultiWindow/MultiWindowSearch.tsx
521
- var import_react4 = require("react");
522
- var import_antd3 = require("antd");
523
- var import_icons = require("@ant-design/icons");
524
- var import_jsx_runtime3 = require("react/jsx-runtime");
525
- var Search = import_antd3.Input.Search;
526
- var MultiWindowSearch = (0, import_react4.memo)(function(props) {
527
- var onSearch = props.onSearch;
528
- var _ref = _sliced_to_array((0, import_react4.useState)(false), 2), showSearch = _ref[0], setShowSearch = _ref[1];
529
- var _ref1 = _sliced_to_array((0, import_react4.useState)(""), 2), searchValue = _ref1[0], setSearchValue = _ref1[1];
530
- var shouldShowSearch = (0, import_react4.useMemo)(function() {
531
- return showSearch || searchValue;
532
- }, [
533
- showSearch,
534
- searchValue
535
- ]);
536
- var handleShowSearch = (0, import_react4.useCallback)(function() {
537
- setShowSearch(true);
538
- }, []);
539
- var handleHideSearch = (0, import_react4.useCallback)(function() {
540
- setShowSearch(false);
541
- }, []);
542
- var handleSearch = (0, import_react4.useCallback)(function(value) {
543
- setSearchValue(value);
544
- onSearch === null || onSearch === void 0 ? void 0 : onSearch(value);
545
- }, [
546
- onSearch
547
- ]);
548
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", {
549
- className: MultiWindow_module_default.search,
550
- onMouseLeave: handleHideSearch,
551
- onMouseEnter: handleShowSearch,
552
- children: [
553
- shouldShowSearch && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Search, {
554
- className: MultiWindow_module_default.input,
555
- placeholder: "标签/单号",
556
- onSearch: handleSearch,
557
- allowClear: true,
558
- autoFocus: true
559
- }),
560
- !shouldShowSearch && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Tooltip, {
561
- title: "搜索标签/单号",
562
- color: "var(--ant-color-primary)",
563
- mouseEnterDelay: 0.5,
564
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Button, {
565
- icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons.SearchOutlined, {}),
566
- type: "text"
567
- })
568
- })
569
- ]
570
- });
571
- });
572
569
  // src/MultiWindow/MultiWindow.tsx
573
570
  var import_jsx_runtime4 = require("react/jsx-runtime");
574
571
  var MultiWindow = (0, import_react5.memo)(function(props) {
@@ -613,7 +610,7 @@ var MultiWindow = (0, import_react5.memo)(function(props) {
613
610
  });
614
611
  if (!searchResult.length) {
615
612
  var notFoundPagePath = {
616
- label: "未找到匹配的标签",
613
+ label: "\u672A\u627E\u5230\u5339\u914D\u7684\u6807\u7B7E",
617
614
  key: "notFound",
618
615
  fullPath: "/",
619
616
  disabled: true,
@@ -641,7 +638,7 @@ var MultiWindow = (0, import_react5.memo)(function(props) {
641
638
  var _currentStateRef_current = currentStateRef.current, pathKey2 = _currentStateRef_current.pathKey, prev = _currentStateRef_current.pagePaths;
642
639
  var newPagePaths = _to_consumable_array(prev);
643
640
  var newPagePath = {
644
- label: "加载中",
641
+ label: "\u52A0\u8F7D\u4E2D",
645
642
  key: newPathKey,
646
643
  fullPath: fullPath
647
644
  };
@@ -699,6 +696,16 @@ var MultiWindow = (0, import_react5.memo)(function(props) {
699
696
  cancelCallback();
700
697
  };
701
698
  }, []);
699
+ (0, import_react5.useEffect)(function() {
700
+ var unsubscribe = (0, import_web_router.onHistoryChange)(function(detail) {
701
+ handleRouterUpdate("".concat(detail.pathname).concat(detail.search));
702
+ });
703
+ return function() {
704
+ unsubscribe();
705
+ };
706
+ }, [
707
+ handleRouterUpdate
708
+ ]);
702
709
  (0, import_react5.useEffect)(function() {
703
710
  var titleEl = document.querySelector("title");
704
711
  if (!titleEl) return;
@@ -819,7 +826,7 @@ var MultiWindow = (0, import_react5.memo)(function(props) {
819
826
  onSearch: handleUpdateSearchPagePaths
820
827
  }),
821
828
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd4.Tooltip, {
822
- title: "刷新当前页面",
829
+ title: "\u5237\u65B0\u5F53\u524D\u9875\u9762",
823
830
  color: "var(--ant-color-primary)",
824
831
  mouseEnterDelay: 0.5,
825
832
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd4.Button, {
@@ -829,18 +836,18 @@ var MultiWindow = (0, import_react5.memo)(function(props) {
829
836
  })
830
837
  }),
831
838
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd4.Tooltip, {
832
- title: "关闭其他页面",
839
+ title: "\u5173\u95ED\u5176\u4ED6\u9875\u9762",
833
840
  color: "var(--ant-color-primary)",
834
841
  mouseEnterDelay: 0.5,
835
842
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd4.Popconfirm, {
836
- title: "关闭其他页面",
843
+ title: "\u5173\u95ED\u5176\u4ED6\u9875\u9762",
837
844
  icon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons2.QuestionCircleOutlined, {
838
845
  style: {
839
846
  color: "red"
840
847
  }
841
848
  }),
842
- okText: "确定",
843
- cancelText: "取消",
849
+ okText: "\u786E\u5B9A",
850
+ cancelText: "\u53D6\u6D88",
844
851
  onConfirm: handleRemoveOther,
845
852
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd4.Button, {
846
853
  icon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons2.CloseOutlined, {}),
@@ -854,16 +861,16 @@ var MultiWindow = (0, import_react5.memo)(function(props) {
854
861
  })
855
862
  });
856
863
  });
857
- var createSearchCollectionKey = function(search) {
864
+ var createSearchCollectionKey = function createSearchCollectionKey(search) {
858
865
  var queryJson = import_tools.queryString.parse(search);
859
866
  if (queryJson.ts) delete queryJson.ts;
860
867
  return import_tools.queryString.stringify(queryJson, {
861
- sort: function(itemLeft, itemRight) {
868
+ sort: function sort(itemLeft, itemRight) {
862
869
  return itemLeft.localeCompare(itemRight);
863
870
  }
864
871
  });
865
872
  };
866
- var checkCanEnableCollection = function(path) {
873
+ var checkCanEnableCollection = function checkCanEnableCollection(path) {
867
874
  var blackList = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
868
875
  var _path_split_pop;
869
876
  var isDetailPage = !!((_path_split_pop = path.split("/").pop()) === null || _path_split_pop === void 0 ? void 0 : _path_split_pop.toLowerCase().includes("detail"));
package/dist/index.mjs CHANGED
@@ -1,4 +1,3 @@
1
- // src/Loading/index.tsx
2
1
  function _array_like_to_array(arr, len) {
3
2
  if (len == null || len > arr.length) len = arr.length;
4
3
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -16,6 +15,10 @@ function _assert_this_initialized(self) {
16
15
  }
17
16
  return self;
18
17
  }
18
+ function _call_super(_this, derived, args) {
19
+ derived = _get_prototype_of(derived);
20
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
21
+ }
19
22
  function _class_call_check(instance, Constructor) {
20
23
  if (!(instance instanceof Constructor)) {
21
24
  throw new TypeError("Cannot call a class as a function");
@@ -141,12 +144,22 @@ function _object_spread_props(target, source) {
141
144
  }
142
145
  function _object_without_properties(source, excluded) {
143
146
  if (source == null) return {};
144
- var target = _object_without_properties_loose(source, excluded);
145
- var key, i;
147
+ var target = {}, sourceKeys, key, i;
148
+ if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
149
+ sourceKeys = Reflect.ownKeys(Object(source));
150
+ for(i = 0; i < sourceKeys.length; i++){
151
+ key = sourceKeys[i];
152
+ if (excluded.indexOf(key) >= 0) continue;
153
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
154
+ target[key] = source[key];
155
+ }
156
+ return target;
157
+ }
158
+ target = _object_without_properties_loose(source, excluded);
146
159
  if (Object.getOwnPropertySymbols) {
147
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
148
- for(i = 0; i < sourceSymbolKeys.length; i++){
149
- key = sourceSymbolKeys[i];
160
+ sourceKeys = Object.getOwnPropertySymbols(source);
161
+ for(i = 0; i < sourceKeys.length; i++){
162
+ key = sourceKeys[i];
150
163
  if (excluded.indexOf(key) >= 0) continue;
151
164
  if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
152
165
  target[key] = source[key];
@@ -156,12 +169,11 @@ function _object_without_properties(source, excluded) {
156
169
  }
157
170
  function _object_without_properties_loose(source, excluded) {
158
171
  if (source == null) return {};
159
- var target = {};
160
- var sourceKeys = Object.keys(source);
161
- var key, i;
172
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
162
173
  for(i = 0; i < sourceKeys.length; i++){
163
174
  key = sourceKeys[i];
164
175
  if (excluded.indexOf(key) >= 0) continue;
176
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
165
177
  target[key] = source[key];
166
178
  }
167
179
  return target;
@@ -198,29 +210,14 @@ function _unsupported_iterable_to_array(o, minLen) {
198
210
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
199
211
  }
200
212
  function _is_native_reflect_construct() {
201
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
202
- if (Reflect.construct.sham) return false;
203
- if (typeof Proxy === "function") return true;
204
213
  try {
205
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
206
- return true;
207
- } catch (e) {
208
- return false;
209
- }
210
- }
211
- function _create_super(Derived) {
212
- var hasNativeReflectConstruct = _is_native_reflect_construct();
213
- return function _createSuperInternal() {
214
- var Super = _get_prototype_of(Derived), result;
215
- if (hasNativeReflectConstruct) {
216
- var NewTarget = _get_prototype_of(this).constructor;
217
- result = Reflect.construct(Super, arguments, NewTarget);
218
- } else {
219
- result = Super.apply(this, arguments);
220
- }
221
- return _possible_constructor_return(this, result);
222
- };
214
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
215
+ } catch (_) {}
216
+ return (_is_native_reflect_construct = function() {
217
+ return !!result;
218
+ })();
223
219
  }
220
+ // src/Loading/index.tsx
224
221
  import { PureComponent } from "react";
225
222
  // src/Loading/index.module.less
226
223
  var index_module_default = {
@@ -232,10 +229,9 @@ import { jsx } from "react/jsx-runtime";
232
229
  var Loading = /*#__PURE__*/ function(PureComponent) {
233
230
  "use strict";
234
231
  _inherits(Loading, PureComponent);
235
- var _super = _create_super(Loading);
236
232
  function Loading() {
237
233
  _class_call_check(this, Loading);
238
- return _super.apply(this, arguments);
234
+ return _call_super(this, Loading, arguments);
239
235
  }
240
236
  _create_class(Loading, [
241
237
  {
@@ -258,9 +254,14 @@ var Loading = /*#__PURE__*/ function(PureComponent) {
258
254
  }(PureComponent);
259
255
  // src/MultiWindow/MultiWindow.tsx
260
256
  import { memo as memo3, useCallback as useCallback3, useEffect, useMemo as useMemo3, useRef, useState as useState2 } from "react";
257
+ import classnames from "classnames";
258
+ import { CloseOutlined, QuestionCircleOutlined, RedoOutlined } from "@ant-design/icons";
259
+ import { Button as Button2, ConfigProvider, Popconfirm, Tooltip as Tooltip2 } from "antd";
261
260
  import { microApp, navigateToWithMicroApp } from "@xfe-repo/web-micro";
261
+ import { onHistoryChange } from "@xfe-repo/web-router";
262
262
  import { queryString } from "@xfe-repo/web-utils/tools";
263
- import classnames from "classnames";
263
+ // src/MultiWindow/MultiWindowSearch.tsx
264
+ import { memo, useCallback, useMemo, useState } from "react";
264
265
  // src/MultiWindow/MultiWindow.module.less
265
266
  var MultiWindow_module_default = {
266
267
  multi_window: "MultiWindow_module_multi_window",
@@ -271,26 +272,74 @@ var MultiWindow_module_default = {
271
272
  input: "MultiWindow_module_input",
272
273
  collection: "MultiWindow_module_collection"
273
274
  };
274
- // src/MultiWindow/MultiWindow.tsx
275
- import { Button as Button2, ConfigProvider, Popconfirm, Tooltip as Tooltip2 } from "antd";
276
- import { CloseOutlined, QuestionCircleOutlined, RedoOutlined } from "@ant-design/icons";
275
+ // src/MultiWindow/MultiWindowSearch.tsx
276
+ import { Button, Input, Tooltip } from "antd";
277
+ import { SearchOutlined } from "@ant-design/icons";
278
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
279
+ var Search = Input.Search;
280
+ var MultiWindowSearch = memo(function(props) {
281
+ var onSearch = props.onSearch;
282
+ var _useState = _sliced_to_array(useState(false), 2), showSearch = _useState[0], setShowSearch = _useState[1];
283
+ var _useState1 = _sliced_to_array(useState(""), 2), searchValue = _useState1[0], setSearchValue = _useState1[1];
284
+ var shouldShowSearch = useMemo(function() {
285
+ return showSearch || searchValue;
286
+ }, [
287
+ showSearch,
288
+ searchValue
289
+ ]);
290
+ var handleShowSearch = useCallback(function() {
291
+ setShowSearch(true);
292
+ }, []);
293
+ var handleHideSearch = useCallback(function() {
294
+ setShowSearch(false);
295
+ }, []);
296
+ var handleSearch = useCallback(function(value) {
297
+ setSearchValue(value);
298
+ onSearch === null || onSearch === void 0 ? void 0 : onSearch(value);
299
+ }, [
300
+ onSearch
301
+ ]);
302
+ return /* @__PURE__ */ jsxs("div", {
303
+ className: MultiWindow_module_default.search,
304
+ onMouseLeave: handleHideSearch,
305
+ onMouseEnter: handleShowSearch,
306
+ children: [
307
+ shouldShowSearch && /* @__PURE__ */ jsx2(Search, {
308
+ className: MultiWindow_module_default.input,
309
+ placeholder: "\u6807\u7B7E/\u5355\u53F7",
310
+ onSearch: handleSearch,
311
+ allowClear: true,
312
+ autoFocus: true
313
+ }),
314
+ !shouldShowSearch && /* @__PURE__ */ jsx2(Tooltip, {
315
+ title: "\u641C\u7D22\u6807\u7B7E/\u5355\u53F7",
316
+ color: "var(--ant-color-primary)",
317
+ mouseEnterDelay: 0.5,
318
+ children: /* @__PURE__ */ jsx2(Button, {
319
+ icon: /* @__PURE__ */ jsx2(SearchOutlined, {}),
320
+ type: "text"
321
+ })
322
+ })
323
+ ]
324
+ });
325
+ });
277
326
  // src/MultiWindow/MultiWindowTabs.tsx
278
- import React2, { memo, useCallback, useMemo } from "react";
327
+ import React3, { memo as memo2, useCallback as useCallback2, useMemo as useMemo2 } from "react";
279
328
  import { Tabs, Select } from "antd";
280
329
  import { closestCenter, DndContext, PointerSensor, useSensor } from "@dnd-kit/core";
281
330
  import { arrayMove, horizontalListSortingStrategy, SortableContext, useSortable } from "@dnd-kit/sortable";
282
331
  import { restrictToHorizontalAxis } from "@dnd-kit/modifiers";
283
332
  import { CSS } from "@dnd-kit/utilities";
284
- import { jsx as jsx2 } from "react/jsx-runtime";
333
+ import { jsx as jsx3 } from "react/jsx-runtime";
285
334
  import { createElement } from "react";
286
- var MultiWindowTabs = memo(function(props) {
335
+ var MultiWindowTabs = memo2(function(props) {
287
336
  var pathKey = props.pathKey, pagePaths = props.pagePaths, className = props.className, onChange = props.onChange, onClose = props.onClose, onSort = props.onSort, onCollectionChange = props.onCollectionChange, sortAutoActive = props.sortAutoActive;
288
337
  var sensor = useSensor(PointerSensor, {
289
338
  activationConstraint: {
290
339
  distance: 10
291
340
  }
292
341
  });
293
- var pagePathsHelperData = useMemo(function() {
342
+ var pagePathsHelperData = useMemo2(function() {
294
343
  var keys = [];
295
344
  var map = /* @__PURE__ */ new Map();
296
345
  pagePaths.forEach(function(item) {
@@ -304,26 +353,26 @@ var MultiWindowTabs = memo(function(props) {
304
353
  }, [
305
354
  pagePaths
306
355
  ]);
307
- var handleEdit = useCallback(function(targetKey, action) {
356
+ var handleEdit = useCallback2(function(targetKey, action) {
308
357
  if (action === "add") {} else if (action === "remove") {
309
358
  onClose === null || onClose === void 0 ? void 0 : onClose(String(targetKey));
310
359
  }
311
360
  }, [
312
361
  onClose
313
362
  ]);
314
- var handleTabChange = useCallback(function(activeKey) {
363
+ var handleTabChange = useCallback2(function(activeKey) {
315
364
  onChange === null || onChange === void 0 ? void 0 : onChange(activeKey);
316
365
  }, [
317
366
  onChange
318
367
  ]);
319
- var onDragStart = useCallback(function(event) {
368
+ var onDragStart = useCallback2(function(event) {
320
369
  var active = event.active;
321
370
  sortAutoActive && (onChange === null || onChange === void 0 ? void 0 : onChange(String(active.id)));
322
371
  }, [
323
372
  onChange,
324
373
  sortAutoActive
325
374
  ]);
326
- var onDragEnd = useCallback(function(event) {
375
+ var onDragEnd = useCallback2(function(event) {
327
376
  var active = event.active, over = event.over;
328
377
  if (active.id === (over === null || over === void 0 ? void 0 : over.id)) return;
329
378
  var oldIndex = pagePaths.findIndex(function(i) {
@@ -338,8 +387,8 @@ var MultiWindowTabs = memo(function(props) {
338
387
  pagePaths,
339
388
  onSort
340
389
  ]);
341
- var renderTabBar = useCallback(function(tabBarProps, DefaultTabBar) {
342
- return /* @__PURE__ */ jsx2(DndContext, {
390
+ var renderTabBar = useCallback2(function(tabBarProps, DefaultTabBar) {
391
+ return /* @__PURE__ */ jsx3(DndContext, {
343
392
  sensors: [
344
393
  sensor
345
394
  ],
@@ -349,11 +398,11 @@ var MultiWindowTabs = memo(function(props) {
349
398
  modifiers: [
350
399
  restrictToHorizontalAxis
351
400
  ],
352
- children: /* @__PURE__ */ jsx2(SortableContext, {
401
+ children: /* @__PURE__ */ jsx3(SortableContext, {
353
402
  items: pagePathsHelperData.keys,
354
403
  strategy: horizontalListSortingStrategy,
355
- children: /* @__PURE__ */ jsx2(DefaultTabBar, _object_spread_props(_object_spread({}, tabBarProps), {
356
- children: function(node) {
404
+ children: /* @__PURE__ */ jsx3(DefaultTabBar, _object_spread_props(_object_spread({}, tabBarProps), {
405
+ children: function children(node) {
357
406
  return /* @__PURE__ */ createElement(TabItem, _object_spread_props(_object_spread({}, node.props), {
358
407
  key: node.key,
359
408
  data: pagePathsHelperData.map.get(String(node.key)),
@@ -371,7 +420,7 @@ var MultiWindowTabs = memo(function(props) {
371
420
  onCollectionChange,
372
421
  sensor
373
422
  ]);
374
- return /* @__PURE__ */ jsx2(Tabs, {
423
+ return /* @__PURE__ */ jsx3(Tabs, {
375
424
  className: className,
376
425
  activeKey: pathKey,
377
426
  onChange: handleTabChange,
@@ -383,18 +432,18 @@ var MultiWindowTabs = memo(function(props) {
383
432
  hideAdd: true
384
433
  });
385
434
  });
386
- var TabItem = memo(function(props) {
435
+ var TabItem = memo2(function(props) {
387
436
  var data = props.data, children = props.children, style = props.style, isActivated = props.isActivated, onCollectionChange = props.onCollectionChange;
388
437
  var _useSortable = useSortable({
389
438
  id: props["data-node-key"]
390
439
  }), attributes = _useSortable.attributes, listeners = _useSortable.listeners, setNodeRef = _useSortable.setNodeRef, transform = _useSortable.transform, transition = _useSortable.transition, isDragging = _useSortable.isDragging;
391
- var handleCollectionChange = useCallback(function(collectionKey) {
440
+ var handleCollectionChange = useCallback2(function(collectionKey) {
392
441
  if (!data) return;
393
442
  onCollectionChange === null || onCollectionChange === void 0 ? void 0 : onCollectionChange(data.key, collectionKey);
394
443
  }, [
395
444
  data
396
445
  ]);
397
- var collectionSelect = useMemo(function() {
446
+ var collectionSelect = useMemo2(function() {
398
447
  var _data_searchCollection;
399
448
  if (!(data === null || data === void 0 ? void 0 : (_data_searchCollection = data.searchCollection) === null || _data_searchCollection === void 0 ? void 0 : _data_searchCollection.length)) return null;
400
449
  if (!isActivated) return null;
@@ -405,7 +454,7 @@ var TabItem = memo(function(props) {
405
454
  };
406
455
  });
407
456
  var currentKey = data.searchCollection[0];
408
- return /* @__PURE__ */ jsx2(Select, {
457
+ return /* @__PURE__ */ jsx3(Select, {
409
458
  className: MultiWindow_module_default.collection,
410
459
  options: options,
411
460
  value: currentKey,
@@ -413,13 +462,13 @@ var TabItem = memo(function(props) {
413
462
  popupMatchSelectWidth: false,
414
463
  size: "small",
415
464
  showSearch: true,
416
- placeholder: "请选择"
465
+ placeholder: "\u8BF7\u9009\u62E9"
417
466
  }, data.key);
418
467
  }, [
419
468
  data,
420
469
  isActivated
421
470
  ]);
422
- var childrenWithCollectionSelect = useMemo(function() {
471
+ var childrenWithCollectionSelect = useMemo2(function() {
423
472
  var innerChildren = children.props.children;
424
473
  if (!Array.isArray(innerChildren)) return innerChildren;
425
474
  var newChildren = _to_consumable_array(innerChildren);
@@ -429,7 +478,7 @@ var TabItem = memo(function(props) {
429
478
  children,
430
479
  collectionSelect
431
480
  ]);
432
- return React2.cloneElement(children, _object_spread({
481
+ return React3.cloneElement(children, _object_spread({
433
482
  ref: setNodeRef,
434
483
  style: _object_spread_props(_object_spread({}, style), {
435
484
  transform: CSS.Translate.toString(transform && _object_spread_props(_object_spread({}, transform), {
@@ -442,58 +491,6 @@ var TabItem = memo(function(props) {
442
491
  children: childrenWithCollectionSelect
443
492
  }, attributes, listeners));
444
493
  });
445
- // src/MultiWindow/MultiWindowSearch.tsx
446
- import { memo as memo2, useCallback as useCallback2, useMemo as useMemo2, useState } from "react";
447
- import { Button, Input, Tooltip } from "antd";
448
- import { SearchOutlined } from "@ant-design/icons";
449
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
450
- var Search = Input.Search;
451
- var MultiWindowSearch = memo2(function(props) {
452
- var onSearch = props.onSearch;
453
- var _useState = _sliced_to_array(useState(false), 2), showSearch = _useState[0], setShowSearch = _useState[1];
454
- var _useState1 = _sliced_to_array(useState(""), 2), searchValue = _useState1[0], setSearchValue = _useState1[1];
455
- var shouldShowSearch = useMemo2(function() {
456
- return showSearch || searchValue;
457
- }, [
458
- showSearch,
459
- searchValue
460
- ]);
461
- var handleShowSearch = useCallback2(function() {
462
- setShowSearch(true);
463
- }, []);
464
- var handleHideSearch = useCallback2(function() {
465
- setShowSearch(false);
466
- }, []);
467
- var handleSearch = useCallback2(function(value) {
468
- setSearchValue(value);
469
- onSearch === null || onSearch === void 0 ? void 0 : onSearch(value);
470
- }, [
471
- onSearch
472
- ]);
473
- return /* @__PURE__ */ jsxs("div", {
474
- className: MultiWindow_module_default.search,
475
- onMouseLeave: handleHideSearch,
476
- onMouseEnter: handleShowSearch,
477
- children: [
478
- shouldShowSearch && /* @__PURE__ */ jsx3(Search, {
479
- className: MultiWindow_module_default.input,
480
- placeholder: "标签/单号",
481
- onSearch: handleSearch,
482
- allowClear: true,
483
- autoFocus: true
484
- }),
485
- !shouldShowSearch && /* @__PURE__ */ jsx3(Tooltip, {
486
- title: "搜索标签/单号",
487
- color: "var(--ant-color-primary)",
488
- mouseEnterDelay: 0.5,
489
- children: /* @__PURE__ */ jsx3(Button, {
490
- icon: /* @__PURE__ */ jsx3(SearchOutlined, {}),
491
- type: "text"
492
- })
493
- })
494
- ]
495
- });
496
- });
497
494
  // src/MultiWindow/MultiWindow.tsx
498
495
  import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
499
496
  var MultiWindow = memo3(function(props) {
@@ -538,7 +535,7 @@ var MultiWindow = memo3(function(props) {
538
535
  });
539
536
  if (!searchResult.length) {
540
537
  var notFoundPagePath = {
541
- label: "未找到匹配的标签",
538
+ label: "\u672A\u627E\u5230\u5339\u914D\u7684\u6807\u7B7E",
542
539
  key: "notFound",
543
540
  fullPath: "/",
544
541
  disabled: true,
@@ -566,7 +563,7 @@ var MultiWindow = memo3(function(props) {
566
563
  var _currentStateRef_current = currentStateRef.current, pathKey2 = _currentStateRef_current.pathKey, prev = _currentStateRef_current.pagePaths;
567
564
  var newPagePaths = _to_consumable_array(prev);
568
565
  var newPagePath = {
569
- label: "加载中",
566
+ label: "\u52A0\u8F7D\u4E2D",
570
567
  key: newPathKey,
571
568
  fullPath: fullPath
572
569
  };
@@ -624,6 +621,16 @@ var MultiWindow = memo3(function(props) {
624
621
  cancelCallback();
625
622
  };
626
623
  }, []);
624
+ useEffect(function() {
625
+ var unsubscribe = onHistoryChange(function(detail) {
626
+ handleRouterUpdate("".concat(detail.pathname).concat(detail.search));
627
+ });
628
+ return function() {
629
+ unsubscribe();
630
+ };
631
+ }, [
632
+ handleRouterUpdate
633
+ ]);
627
634
  useEffect(function() {
628
635
  var titleEl = document.querySelector("title");
629
636
  if (!titleEl) return;
@@ -744,7 +751,7 @@ var MultiWindow = memo3(function(props) {
744
751
  onSearch: handleUpdateSearchPagePaths
745
752
  }),
746
753
  /* @__PURE__ */ jsx4(Tooltip2, {
747
- title: "刷新当前页面",
754
+ title: "\u5237\u65B0\u5F53\u524D\u9875\u9762",
748
755
  color: "var(--ant-color-primary)",
749
756
  mouseEnterDelay: 0.5,
750
757
  children: /* @__PURE__ */ jsx4(Button2, {
@@ -754,18 +761,18 @@ var MultiWindow = memo3(function(props) {
754
761
  })
755
762
  }),
756
763
  /* @__PURE__ */ jsx4(Tooltip2, {
757
- title: "关闭其他页面",
764
+ title: "\u5173\u95ED\u5176\u4ED6\u9875\u9762",
758
765
  color: "var(--ant-color-primary)",
759
766
  mouseEnterDelay: 0.5,
760
767
  children: /* @__PURE__ */ jsx4(Popconfirm, {
761
- title: "关闭其他页面",
768
+ title: "\u5173\u95ED\u5176\u4ED6\u9875\u9762",
762
769
  icon: /* @__PURE__ */ jsx4(QuestionCircleOutlined, {
763
770
  style: {
764
771
  color: "red"
765
772
  }
766
773
  }),
767
- okText: "确定",
768
- cancelText: "取消",
774
+ okText: "\u786E\u5B9A",
775
+ cancelText: "\u53D6\u6D88",
769
776
  onConfirm: handleRemoveOther,
770
777
  children: /* @__PURE__ */ jsx4(Button2, {
771
778
  icon: /* @__PURE__ */ jsx4(CloseOutlined, {}),
@@ -779,16 +786,16 @@ var MultiWindow = memo3(function(props) {
779
786
  })
780
787
  });
781
788
  });
782
- var createSearchCollectionKey = function(search) {
789
+ var createSearchCollectionKey = function createSearchCollectionKey(search) {
783
790
  var queryJson = queryString.parse(search);
784
791
  if (queryJson.ts) delete queryJson.ts;
785
792
  return queryString.stringify(queryJson, {
786
- sort: function(itemLeft, itemRight) {
793
+ sort: function sort(itemLeft, itemRight) {
787
794
  return itemLeft.localeCompare(itemRight);
788
795
  }
789
796
  });
790
797
  };
791
- var checkCanEnableCollection = function(path) {
798
+ var checkCanEnableCollection = function checkCanEnableCollection(path) {
792
799
  var blackList = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
793
800
  var _path_split_pop;
794
801
  var isDetailPage = !!((_path_split_pop = path.split("/").pop()) === null || _path_split_pop === void 0 ? void 0 : _path_split_pop.toLowerCase().includes("detail"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-components",
3
- "version": "1.2.6",
3
+ "version": "1.5.0",
4
4
  "module": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": [
@@ -32,19 +32,21 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@swc/core": "^1.3.100",
35
- "@types/node": "^20.16.5",
35
+ "@types/node": "^20.17.0",
36
36
  "@types/react": "^18",
37
37
  "esbuild-plugin-less": "^1.3.9",
38
- "@xfe-repo/eslint-config": "0.0.5",
39
- "@xfe-repo/typescript-config": "0.0.6"
38
+ "eslint": "8.57.1",
39
+ "@xfe-repo/eslint-config": "1.5.0",
40
+ "@xfe-repo/typescript-config": "1.5.0"
40
41
  },
41
42
  "peerDependencies": {
42
43
  "@ant-design/icons": "^5.0.0",
43
44
  "antd": "^5.24.5",
44
45
  "react": "18.2.0",
45
46
  "react-dom": "18.2.0",
46
- "@xfe-repo/web-utils": "1.3.7",
47
- "@xfe-repo/web-micro": "1.2.5"
47
+ "@xfe-repo/web-micro": "1.5.0",
48
+ "@xfe-repo/web-router": "1.5.0",
49
+ "@xfe-repo/web-utils": "1.5.0"
48
50
  },
49
51
  "publishConfig": {
50
52
  "registry": "https://registry.npmjs.org/"
@@ -52,7 +54,7 @@
52
54
  "scripts": {
53
55
  "build": "tsup",
54
56
  "dev": "tsup --watch",
55
- "lint": "eslint \"src/**/*.ts*\"",
57
+ "lint": "eslint \"src/**/*.ts*\" --fix",
56
58
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
57
59
  }
58
60
  }