@univerjs/find-replace 0.16.1 → 0.17.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/lib/index.js CHANGED
@@ -1,30 +1,30 @@
1
- var st = Object.defineProperty;
2
- var rt = (t, e, n) => e in t ? st(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var o = (t, e, n) => rt(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { createIdentifier as at, Inject as $, Injector as ue, IContextService as J, Disposable as Q, DisposableCollection as ot, toDisposable as O, IUniverInstanceService as fe, ICommandService as U, CommandType as b, IConfirmService as ct, LocaleService as B, FOCUSING_SHEET as pe, EDITOR_ACTIVATED as _e, UniverInstanceType as lt, RxDisposable as dt, IConfigService as ht, Plugin as ut, merge as ft } from "@univerjs/core";
5
- import { MessageType as N, Input as ge, Pager as pt, FormLayout as R, Select as k, FormDualColumnLayout as re, Checkbox as ae, Button as j } from "@univerjs/design";
6
- import { IMessageService as me, useDependency as m, useObservable as P, useDebounceFn as _t, ILayoutService as Se, KeyCode as C, MetaKeys as D, getMenuHiddenObservable as gt, MenuItemType as mt, RibbonDataGroup as St, IMenuManagerService as vt, IShortcutService as Ct, IDialogService as Mt, ComponentManager as Rt } from "@univerjs/ui";
7
- import { RENDER_RAW_FORMULA_KEY as bt } from "@univerjs/engine-render";
8
- import { throttleTime as It, BehaviorSubject as T, combineLatest as ve, debounceTime as Ft, Subject as Ce, fromEvent as Dt, map as yt, takeUntil as oe } from "rxjs";
9
- import { useRef as G, createElement as Me, forwardRef as X, useState as Pt, useCallback as u, useEffect as A, useMemo as ee, useImperativeHandle as Tt } from "react";
1
+ var rt = Object.defineProperty;
2
+ var at = (t, e, n) => e in t ? rt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var o = (t, e, n) => at(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { createIdentifier as ot, Inject as O, Injector as fe, IContextService as J, Disposable as Q, DisposableCollection as ct, toDisposable as A, IUniverInstanceService as pe, ICommandService as B, CommandType as b, IConfirmService as lt, LocaleService as W, EDITOR_ACTIVATED as _e, FOCUSING_SHEET as ge, UniverInstanceType as dt, RxDisposable as ht, IConfigService as ut, Plugin as ft, merge as pt } from "@univerjs/core";
5
+ import { MessageType as N, Input as me, Pager as _t, FormLayout as R, Select as j, FormDualColumnLayout as re, Checkbox as ae, Button as V } from "@univerjs/design";
6
+ import { IMessageService as Se, getMenuHiddenObservable as gt, MenuItemType as mt, RibbonDataGroup as St, useDependency as m, useObservable as T, useDebounceFn as vt, ILayoutService as ve, KeyCode as C, MetaKeys as D, IMenuManagerService as Ct, IShortcutService as Mt, IDialogService as Rt, ComponentManager as bt } from "@univerjs/ui";
7
+ import { RENDER_RAW_FORMULA_KEY as It } from "@univerjs/engine-render";
8
+ import { throttleTime as Ft, BehaviorSubject as x, combineLatest as Ce, debounceTime as Dt, Subject as Me, map as yt, fromEvent as Pt, takeUntil as oe } from "rxjs";
9
+ import { useRef as G, createElement as Re, forwardRef as X, useState as Tt, useCallback as u, useEffect as L, useMemo as ee, useImperativeHandle as xt } from "react";
10
10
  import { jsx as c, jsxs as F, Fragment as H } from "react/jsx-runtime";
11
- const Re = "FIND_REPLACE_INPUT_FOCUS", be = "FIND_REPLACE_DIALOG_FOCUS", Ie = "FIND_REPLACE_REPLACE_REVEALED";
12
- var xt = Object.getOwnPropertyDescriptor, Fe = (t, e, n, i) => {
13
- for (var s = i > 1 ? void 0 : i ? xt(e, n) : e, r = t.length - 1, a; r >= 0; r--)
11
+ const be = "FIND_REPLACE_INPUT_FOCUS", Ie = "FIND_REPLACE_DIALOG_FOCUS", Fe = "FIND_REPLACE_REPLACE_REVEALED";
12
+ var Et = Object.getOwnPropertyDescriptor, De = (t, e, n, i) => {
13
+ for (var s = i > 1 ? void 0 : i ? Et(e, n) : e, r = t.length - 1, a; r >= 0; r--)
14
14
  (a = t[r]) && (s = a(s) || s);
15
15
  return s;
16
- }, L = (t, e) => (n, i) => e(n, i, t);
17
- class gi extends Q {
16
+ }, w = (t, e) => (n, i) => e(n, i, t);
17
+ class Si extends Q {
18
18
  }
19
- const f = at("find-replace.service");
20
- function Et(t) {
19
+ const f = ot("find-replace.service");
20
+ function $t(t) {
21
21
  return typeof t.findString < "u" || typeof t.inputtingFindString < "u" || typeof t.findDirection < "u" || typeof t.matchesTheWholeCell < "u" || typeof t.caseSensitive < "u" || typeof t.findScope < "u" || typeof t.findBy < "u";
22
22
  }
23
23
  let K = class extends Q {
24
24
  constructor(e, n, i, s) {
25
25
  super();
26
- o(this, "currentMatch$", new T(null));
27
- o(this, "replaceables$", new T([]));
26
+ o(this, "currentMatch$", new x(null));
27
+ o(this, "replaceables$", new x([]));
28
28
  /** All find models returned by providers. */
29
29
  o(this, "_findModels", []);
30
30
  /** The find model that the current match is from. */
@@ -32,9 +32,9 @@ let K = class extends Q {
32
32
  o(this, "_matches", []);
33
33
  o(this, "_currentSearchingDisposables", null);
34
34
  this._state = e, this._providers = n, this._univerInstanceService = i, this._commandService = s, this.disposeWithMe(
35
- this._state.stateUpdates$.pipe(It(200, void 0, { leading: !0, trailing: !0 })).subscribe(async (r) => {
35
+ this._state.stateUpdates$.pipe(Ft(200, void 0, { leading: !0, trailing: !0 })).subscribe(async (r) => {
36
36
  const a = this._state.state;
37
- Et(r) && (a.findString !== "" && !a.replaceRevealed ? (await this._startSearching(), this._state.changeState({ findCompleted: !0 })) : r.replaceRevealed !== !0 && this._stopSearching());
37
+ $t(r) && (a.findString !== "" && !a.replaceRevealed ? (await this._startSearching(), this._state.changeState({ findCompleted: !0 })) : r.replaceRevealed !== !0 && this._stopSearching());
38
38
  })
39
39
  );
40
40
  }
@@ -82,14 +82,14 @@ let K = class extends Q {
82
82
  }
83
83
  // When a document's content changes, we should reset all matches and try to move to the next match.
84
84
  _subscribeToModelsChanges(e) {
85
- const n = this._currentSearchingDisposables = new ot(), i = ve(e.map((s) => s.matchesUpdate$)).pipe(Ft(220)).subscribe(([...s]) => {
85
+ const n = this._currentSearchingDisposables = new ct(), i = Ce(e.map((s) => s.matchesUpdate$)).pipe(Dt(220)).subscribe(([...s]) => {
86
86
  const r = this._matches = s.flat();
87
87
  r.length ? (this._moveToInitialMatch(this._findModels, !0), this._state.changeState({ matchesCount: r.length }), this.replaceables$.next(r.filter((a) => a.replaceable))) : (this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), this.replaceables$.next([]));
88
88
  });
89
- e.forEach((s) => n.add(O(s.activelyChangingMatch$.subscribe((r) => {
89
+ e.forEach((s) => n.add(A(s.activelyChangingMatch$.subscribe((r) => {
90
90
  const a = this._matches.findIndex((l) => l === r);
91
91
  this._state.changeState({ matchesPosition: a + 1 });
92
- })))), n.add(O(i));
92
+ })))), n.add(A(i));
93
93
  }
94
94
  async replace() {
95
95
  return this._matchingModel ? this._matchingModel.replace(this._state.replaceString) : !1;
@@ -163,9 +163,9 @@ let K = class extends Q {
163
163
  return this._moveToNextUnitMatch(s), 0;
164
164
  }
165
165
  };
166
- K = Fe([
167
- L(2, fe),
168
- L(3, U)
166
+ K = De([
167
+ w(2, pe),
168
+ w(3, B)
169
169
  ], K);
170
170
  var q = /* @__PURE__ */ ((t) => (t.ROW = "row", t.COLUMN = "column", t))(q || {}), Z = /* @__PURE__ */ ((t) => (t.VALUE = "value", t.FORMULA = "formula", t))(Z || {}), z = /* @__PURE__ */ ((t) => (t.SUBUNIT = "subunit", t.UNIT = "unit", t))(z || {});
171
171
  function te() {
@@ -187,9 +187,9 @@ function te() {
187
187
  }
188
188
  class Nt {
189
189
  constructor() {
190
- o(this, "_stateUpdates$", new Ce());
190
+ o(this, "_stateUpdates$", new Me());
191
191
  o(this, "stateUpdates$", this._stateUpdates$.asObservable());
192
- o(this, "_state$", new T(te()));
192
+ o(this, "_state$", new x(te()));
193
193
  o(this, "state$", this._state$.asObservable());
194
194
  o(this, "_findString", "");
195
195
  o(this, "_inputtingFindString", "");
@@ -273,11 +273,11 @@ let Y = class extends Q {
273
273
  o(this, "_providers", /* @__PURE__ */ new Set());
274
274
  o(this, "_state", new Nt());
275
275
  o(this, "_model");
276
- o(this, "_currentMatch$", new T(null));
276
+ o(this, "_currentMatch$", new x(null));
277
277
  o(this, "currentMatch$", this._currentMatch$.asObservable());
278
- o(this, "_replaceables$", new T([]));
278
+ o(this, "_replaceables$", new x([]));
279
279
  o(this, "replaceables$", this._replaceables$.asObservable());
280
- o(this, "_focusSignal$", new Ce());
280
+ o(this, "_focusSignal$", new Me());
281
281
  o(this, "focusSignal$", this._focusSignal$.asObservable());
282
282
  this._injector = e, this._contextService = n;
283
283
  }
@@ -373,30 +373,30 @@ let Y = class extends Q {
373
373
  (e = this._model) == null || e.dispose(), this._model = null, this._toggleDisplayRawFormula(!1), this._toggleRevealReplace(!1);
374
374
  }
375
375
  registerFindReplaceProvider(e) {
376
- return this._providers.add(e), O(() => this._providers.delete(e));
376
+ return this._providers.add(e), A(() => this._providers.delete(e));
377
377
  }
378
378
  _toggleRevealReplace(e) {
379
- this._contextService.setContextValue(Ie, e);
379
+ this._contextService.setContextValue(Fe, e);
380
380
  }
381
381
  _toggleDisplayRawFormula(e) {
382
- this._contextService.setContextValue(bt, e);
382
+ this._contextService.setContextValue(It, e);
383
383
  }
384
384
  };
385
- Y = Fe([
386
- L(0, $(ue)),
387
- L(1, J)
385
+ Y = De([
386
+ w(0, O(fe)),
387
+ w(1, J)
388
388
  ], Y);
389
- const De = {
389
+ const ye = {
390
390
  id: "ui.command.replace-current-match",
391
391
  type: b.COMMAND,
392
392
  handler: (t) => t.get(f).replace()
393
- }, $t = "CONFIRM_REPLACE_ALL", ye = {
393
+ }, Ot = "CONFIRM_REPLACE_ALL", Pe = {
394
394
  id: "ui.command.replace-all-matches",
395
395
  type: b.COMMAND,
396
396
  handler: async (t) => {
397
- const e = t.get(ct), n = t.get(B), i = t.get(me);
397
+ const e = t.get(lt), n = t.get(W), i = t.get(Se);
398
398
  if (!await e.confirm({
399
- id: $t,
399
+ id: Ot,
400
400
  title: { title: n.t("find-replace.replace.confirm.title") },
401
401
  cancelText: n.t("button.cancel"),
402
402
  confirmText: n.t("button.confirm")
@@ -414,7 +414,7 @@ const De = {
414
414
  content: n.t("find-replace.replace.all-success", `${a}`)
415
415
  }), !0);
416
416
  }
417
- }, x = {
417
+ }, E = {
418
418
  id: "ui.operation.open-find-dialog",
419
419
  type: b.OPERATION,
420
420
  handler: (t) => {
@@ -428,21 +428,21 @@ const De = {
428
428
  const e = t.get(f);
429
429
  return e.revealed ? e.replaceRevealed ? e.focusFindInput() : e.revealReplace() : e.start(!0), !0;
430
430
  }
431
- }, Pe = {
431
+ }, Te = {
432
432
  type: b.OPERATION,
433
433
  id: "ui.operation.go-to-next-match",
434
434
  handler: (t) => (t.get(f).moveToNextMatch(), !0)
435
- }, Te = {
435
+ }, xe = {
436
436
  type: b.OPERATION,
437
437
  id: "ui.operation.go-to-previous-match",
438
438
  handler: (t) => (t.get(f).moveToPreviousMatch(), !0)
439
- }, xe = {
439
+ }, Ee = {
440
440
  type: b.OPERATION,
441
441
  id: "ui.operation.focus-selection",
442
442
  handler: (t) => (t.get(f).focusSelection(), !0)
443
443
  };
444
- function Ee({ ref: t, ...e }) {
445
- const { icon: n, id: i, className: s, extend: r, ...a } = e, l = `univerjs-icon univerjs-icon-${i} ${s || ""}`.trim(), d = G(`_${Lt()}`);
444
+ function $e({ ref: t, ...e }) {
445
+ const { icon: n, id: i, className: s, extend: r, ...a } = e, l = `univerjs-icon univerjs-icon-${i} ${s || ""}`.trim(), d = G(`_${wt()}`);
446
446
  return Ne(n, `${i}`, {
447
447
  defIds: n.defIds,
448
448
  idSuffix: d.current
@@ -453,13 +453,13 @@ function Ee({ ref: t, ...e }) {
453
453
  }, r);
454
454
  }
455
455
  function Ne(t, e, n, i, s) {
456
- return Me(t.tag, {
456
+ return Re(t.tag, {
457
457
  key: e,
458
- ...Ot(t, n, s),
458
+ ...At(t, n, s),
459
459
  ...i
460
- }, (At(t, n).children || []).map((r, a) => Ne(r, `${e}-${t.tag}-${a}`, n, void 0, s)));
460
+ }, (Lt(t, n).children || []).map((r, a) => Ne(r, `${e}-${t.tag}-${a}`, n, void 0, s)));
461
461
  }
462
- function Ot(t, e, n) {
462
+ function At(t, e, n) {
463
463
  const i = { ...t.attrs };
464
464
  n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1), t.tag === "mask" && i.id && (i.id = i.id + e.idSuffix), Object.entries(i).forEach(([r, a]) => {
465
465
  r === "mask" && typeof a == "string" && (i[r] = a.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
@@ -469,7 +469,7 @@ function Ot(t, e, n) {
469
469
  typeof a == "string" && (i[r] = a.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
470
470
  })), i;
471
471
  }
472
- function At(t, e) {
472
+ function Lt(t, e) {
473
473
  var i;
474
474
  const { defIds: n } = e;
475
475
  return !n || n.length === 0 ? t : t.tag === "defs" && ((i = t.children) != null && i.length) ? {
@@ -483,11 +483,11 @@ function At(t, e) {
483
483
  } : s)
484
484
  } : t;
485
485
  }
486
- function Lt() {
486
+ function wt() {
487
487
  return Math.random().toString(36).substring(2, 8);
488
488
  }
489
- Ee.displayName = "UniverIcon";
490
- const wt = {
489
+ $e.displayName = "UniverIcon";
490
+ const Ut = {
491
491
  tag: "svg",
492
492
  attrs: {
493
493
  xmlns: "http://www.w3.org/2000/svg",
@@ -505,15 +505,37 @@ const wt = {
505
505
  clipRule: "evenodd"
506
506
  }
507
507
  }]
508
- }, $e = X(function(e, n) {
509
- return Me(Ee, Object.assign({}, e, {
508
+ }, Oe = X(function(e, n) {
509
+ return Re($e, Object.assign({}, e, {
510
510
  id: "search-icon",
511
511
  ref: n,
512
- icon: wt
512
+ icon: Ut
513
513
  }));
514
514
  });
515
- $e.displayName = "SearchIcon";
516
- function Oe(t) {
515
+ Oe.displayName = "SearchIcon";
516
+ function Bt(t) {
517
+ const e = t.get(J);
518
+ return {
519
+ id: E.id,
520
+ icon: "SearchIcon",
521
+ tooltip: "find-replace.toolbar",
522
+ type: mt.BUTTON,
523
+ hidden$: gt(t, dt.UNIVER_SHEET),
524
+ disabled$: Ce([
525
+ e.subscribeContextValue$(_e),
526
+ e.subscribeContextValue$(ge)
527
+ ]).pipe(yt(([n, i]) => n || !i))
528
+ };
529
+ }
530
+ const Wt = {
531
+ [St.ORGANIZATION]: {
532
+ [E.id]: {
533
+ order: 2,
534
+ menuItemFactory: Bt
535
+ }
536
+ }
537
+ };
538
+ function Ae(t) {
517
539
  const {
518
540
  findCompleted: e,
519
541
  localeService: n,
@@ -523,12 +545,12 @@ function Oe(t) {
523
545
  findReplaceService: a,
524
546
  onChange: l,
525
547
  ...d
526
- } = t, [_, p] = Pt(r), I = e && i === 0 ? n.t("find-replace.dialog.no-result") : i === 0 ? " " : void 0;
548
+ } = t, [_, p] = Tt(r), I = e && i === 0 ? n.t("find-replace.dialog.no-result") : i === 0 ? " " : void 0;
527
549
  function S(g) {
528
550
  s === i && g === 1 ? a.moveToNextMatch() : s === 1 && g === i || g < s ? a.moveToPreviousMatch() : a.moveToNextMatch();
529
551
  }
530
552
  return /* @__PURE__ */ c("div", { className: "univer-relative univer-flex univer-items-center univer-gap-2", onDrag: (g) => g.stopPropagation(), children: /* @__PURE__ */ c(
531
- ge,
553
+ me,
532
554
  {
533
555
  "data-u-comp": "search-input",
534
556
  autoFocus: !0,
@@ -538,7 +560,7 @@ function Oe(t) {
538
560
  p(g), l == null || l(g);
539
561
  },
540
562
  slot: /* @__PURE__ */ c(
541
- pt,
563
+ _t,
542
564
  {
543
565
  loop: !0,
544
566
  text: I,
@@ -551,7 +573,7 @@ function Oe(t) {
551
573
  }
552
574
  ) });
553
575
  }
554
- function Ae(t, e) {
576
+ function Le(t, e) {
555
577
  const n = u(() => {
556
578
  var s;
557
579
  (s = document.querySelector(".univer-find-input input")) == null || s.focus();
@@ -559,18 +581,18 @@ function Ae(t, e) {
559
581
  const s = document.querySelectorAll("[data-u-comp=find-replace-dialog] [data-u-comp=search-input]");
560
582
  return Array.from(s).some((r) => r === document.activeElement);
561
583
  }, []);
562
- return Tt(e, () => ({ focus: n, selectHasFocus: i })), A(() => {
584
+ return xt(e, () => ({ focus: n, selectHasFocus: i })), L(() => {
563
585
  const s = t.focusSignal$.subscribe(() => n());
564
586
  return () => s.unsubscribe();
565
587
  }, [t, n]), { focus: n, selectHasFocus: i };
566
588
  }
567
- const Ut = X(function(e, n) {
568
- const i = m(B), s = m(f), r = m(U), a = P(s.state$, void 0, !0), { findCompleted: l, findString: d, matchesCount: _, matchesPosition: p } = a, M = u(() => {
589
+ const kt = X(function(e, n) {
590
+ const i = m(W), s = m(f), r = m(B), a = T(s.state$, void 0, !0), { findCompleted: l, findString: d, matchesCount: _, matchesPosition: p } = a, M = u(() => {
569
591
  r.executeCommand(ie.id);
570
- }, [r]), I = _t((S) => s.changeFindString(S), 500);
571
- return Ae(s, n), /* @__PURE__ */ F(H, { children: [
592
+ }, [r]), I = vt((S) => s.changeFindString(S), 500);
593
+ return Le(s, n), /* @__PURE__ */ F(H, { children: [
572
594
  /* @__PURE__ */ c(
573
- Oe,
595
+ Ae,
574
596
  {
575
597
  findCompleted: l,
576
598
  matchesCount: _,
@@ -590,74 +612,74 @@ const Ut = X(function(e, n) {
590
612
  }
591
613
  ) })
592
614
  ] });
593
- }), Bt = X(function(e, n) {
594
- const i = m(f), s = m(B), r = m(U), a = m(me), l = P(i.currentMatch$, void 0, !0), d = P(i.replaceables$, void 0, !0), _ = P(i.state$, void 0, !0), {
615
+ }), jt = X(function(e, n) {
616
+ const i = m(f), s = m(W), r = m(B), a = m(Se), l = T(i.currentMatch$, void 0, !0), d = T(i.replaceables$, void 0, !0), _ = T(i.state$, void 0, !0), {
595
617
  matchesCount: p,
596
618
  matchesPosition: M,
597
619
  findString: I,
598
620
  inputtingFindString: S,
599
621
  replaceString: g,
600
- caseSensitive: Ue,
601
- matchesTheWholeCell: Be,
602
- findDirection: We,
603
- findScope: ke,
604
- findBy: je,
605
- findCompleted: W
606
- } = _, Ve = S.length === 0, Ge = p === 0 || !(l != null && l.replaceable), He = d.length === 0, Ke = u(
622
+ caseSensitive: Be,
623
+ matchesTheWholeCell: We,
624
+ findDirection: ke,
625
+ findScope: je,
626
+ findBy: Ve,
627
+ findCompleted: k
628
+ } = _, Ge = S.length === 0, He = p === 0 || !(l != null && l.replaceable), Ke = d.length === 0, qe = u(
607
629
  (h) => i.changeInputtingFindString(h),
608
630
  [i]
609
- ), qe = u(
631
+ ), Ze = u(
610
632
  (h) => i.changeReplaceString(h),
611
633
  [i]
612
- ), { focus: Ze } = Ae(i, n), ze = u(() => {
634
+ ), { focus: ze } = Le(i, n), Ye = u(() => {
613
635
  I === S ? i.moveToNextMatch() : (i.changeFindString(S), i.find());
614
- }, [I, S, i]), Ye = u(() => r.executeCommand(De.id), [r]), Je = u(async () => {
615
- await r.executeCommand(ye.id), Ze();
616
- }, [r]), Qe = u((h) => {
636
+ }, [I, S, i]), Je = u(() => r.executeCommand(ye.id), [r]), Qe = u(async () => {
637
+ await r.executeCommand(Pe.id), ze();
638
+ }, [r]), Xe = u((h) => {
617
639
  i.changeFindDirection(h);
618
- }, [i]), Xe = u((h) => {
619
- i.changeFindScope(h);
620
640
  }, [i]), et = u((h) => {
641
+ i.changeFindScope(h);
642
+ }, [i]), tt = u((h) => {
621
643
  i.changeFindBy(h);
622
- }, [i]), tt = kt(s), it = jt(s), nt = Vt(s);
623
- return A(() => {
624
- W && p === 0 && a.show({
644
+ }, [i]), it = Gt(s), nt = Ht(s), st = Kt(s);
645
+ return L(() => {
646
+ k && p === 0 && a.show({
625
647
  content: s.t("find-replace.dialog.no-match"),
626
648
  type: N.Warning,
627
649
  duration: 5e3
628
650
  });
629
- }, [W, p, a, s]), /* @__PURE__ */ F("div", { children: [
651
+ }, [k, p, a, s]), /* @__PURE__ */ F("div", { children: [
630
652
  /* @__PURE__ */ c(R, { label: s.t("find-replace.dialog.find"), children: /* @__PURE__ */ c(
631
- Oe,
653
+ Ae,
632
654
  {
633
- findCompleted: W,
655
+ findCompleted: k,
634
656
  className: "univer-find-input",
635
657
  matchesCount: p,
636
658
  matchesPosition: M,
637
659
  findReplaceService: i,
638
660
  localeService: s,
639
661
  initialFindString: S,
640
- onChange: Ke
662
+ onChange: qe
641
663
  }
642
664
  ) }),
643
665
  /* @__PURE__ */ c(R, { label: s.t("find-replace.dialog.replace"), children: /* @__PURE__ */ c(
644
- ge,
666
+ me,
645
667
  {
646
668
  placeholder: s.t("find-replace.dialog.replace-placeholder"),
647
669
  value: g,
648
- onChange: (h) => qe(h)
670
+ onChange: (h) => Ze(h)
649
671
  }
650
672
  ) }),
651
- /* @__PURE__ */ c(R, { label: s.t("find-replace.dialog.find-direction.title"), children: /* @__PURE__ */ c(k, { value: We, options: it, onChange: Qe }) }),
673
+ /* @__PURE__ */ c(R, { label: s.t("find-replace.dialog.find-direction.title"), children: /* @__PURE__ */ c(j, { value: ke, options: nt, onChange: Xe }) }),
652
674
  /* @__PURE__ */ c(re, { children: /* @__PURE__ */ F(H, { children: [
653
- /* @__PURE__ */ c(R, { label: s.t("find-replace.dialog.find-scope.title"), children: /* @__PURE__ */ c(k, { value: ke, options: tt, onChange: Xe }) }),
654
- /* @__PURE__ */ c(R, { label: s.t("find-replace.dialog.find-by.title"), children: /* @__PURE__ */ c(k, { value: je, options: nt, onChange: et }) })
675
+ /* @__PURE__ */ c(R, { label: s.t("find-replace.dialog.find-scope.title"), children: /* @__PURE__ */ c(j, { value: je, options: it, onChange: et }) }),
676
+ /* @__PURE__ */ c(R, { label: s.t("find-replace.dialog.find-by.title"), children: /* @__PURE__ */ c(j, { value: Ve, options: st, onChange: tt }) })
655
677
  ] }) }),
656
678
  /* @__PURE__ */ c(re, { children: /* @__PURE__ */ F(H, { children: [
657
679
  /* @__PURE__ */ c(R, { children: /* @__PURE__ */ c(
658
680
  ae,
659
681
  {
660
- checked: Ue,
682
+ checked: Be,
661
683
  onChange: (h) => {
662
684
  i.changeCaseSensitive(h);
663
685
  },
@@ -667,7 +689,7 @@ const Ut = X(function(e, n) {
667
689
  /* @__PURE__ */ c(R, { children: /* @__PURE__ */ c(
668
690
  ae,
669
691
  {
670
- checked: Be,
692
+ checked: We,
671
693
  onChange: (h) => {
672
694
  i.changeMatchesTheWholeCell(h);
673
695
  },
@@ -676,53 +698,53 @@ const Ut = X(function(e, n) {
676
698
  ) })
677
699
  ] }) }),
678
700
  /* @__PURE__ */ F("div", { className: "univer-mt-6 univer-flex univer-justify-between", children: [
679
- /* @__PURE__ */ c(j, { variant: "primary", onClick: ze, disabled: Ve, children: s.t("find-replace.dialog.find") }),
701
+ /* @__PURE__ */ c(V, { variant: "primary", onClick: Ye, disabled: Ge, children: s.t("find-replace.dialog.find") }),
680
702
  /* @__PURE__ */ F("span", { className: "univer-inline-flex univer-gap-2", children: [
681
- /* @__PURE__ */ c(j, { disabled: Ge, onClick: Ye, children: s.t("find-replace.dialog.replace") }),
682
- /* @__PURE__ */ c(j, { disabled: He, onClick: Je, children: s.t("find-replace.dialog.replace-all") })
703
+ /* @__PURE__ */ c(V, { disabled: He, onClick: Je, children: s.t("find-replace.dialog.replace") }),
704
+ /* @__PURE__ */ c(V, { disabled: Ke, onClick: Qe, children: s.t("find-replace.dialog.replace-all") })
683
705
  ] })
684
706
  ] })
685
707
  ] });
686
708
  });
687
- function Wt() {
688
- const t = m(f), e = m(Se), n = m(J), i = P(t.state$, void 0, !0), s = G(null);
689
- A(() => {
709
+ function Vt() {
710
+ const t = m(f), e = m(ve), n = m(J), i = T(t.state$, void 0, !0), s = G(null);
711
+ L(() => {
690
712
  let d;
691
713
  return s.current && (d = e.registerContainerElement(s.current)), () => d == null ? void 0 : d.dispose();
692
714
  }, [e]);
693
715
  const r = G(null), a = u(
694
- (d) => n.setContextValue(be, d),
716
+ (d) => n.setContextValue(Ie, d),
695
717
  [n]
696
718
  ), l = u(
697
- (d) => n.setContextValue(Re, d),
719
+ (d) => n.setContextValue(be, d),
698
720
  [n]
699
721
  );
700
- return A(() => {
722
+ return L(() => {
701
723
  var _;
702
- const d = Dt(document, "focusin").subscribe((p) => {
724
+ const d = Pt(document, "focusin").subscribe((p) => {
703
725
  var M;
704
726
  p.target && ((M = s.current) != null && M.contains(p.target)) ? a(!0) : a(!1), !r.current || !r.current.selectHasFocus() ? l(!1) : l(!0);
705
727
  });
706
728
  return (_ = r.current) == null || _.focus(), a(!0), l(!0), () => {
707
729
  d.unsubscribe(), a(!1);
708
730
  };
709
- }, [a, l]), /* @__PURE__ */ c("div", { ref: s, "data-u-comp": "find-replace-dialog", children: i.replaceRevealed ? /* @__PURE__ */ c(Bt, { ref: r }) : /* @__PURE__ */ c(Ut, { ref: r }) });
731
+ }, [a, l]), /* @__PURE__ */ c("div", { ref: s, "data-u-comp": "find-replace-dialog", children: i.replaceRevealed ? /* @__PURE__ */ c(jt, { ref: r }) : /* @__PURE__ */ c(kt, { ref: r }) });
710
732
  }
711
- function kt(t) {
733
+ function Gt(t) {
712
734
  const e = t.getCurrentLocale();
713
735
  return ee(() => [
714
736
  { label: t.t("find-replace.dialog.find-scope.current-sheet"), value: z.SUBUNIT },
715
737
  { label: t.t("find-replace.dialog.find-scope.workbook"), value: z.UNIT }
716
738
  ], [e]);
717
739
  }
718
- function jt(t) {
740
+ function Ht(t) {
719
741
  const e = t.getCurrentLocale();
720
742
  return ee(() => [
721
743
  { label: t.t("find-replace.dialog.find-direction.row"), value: q.ROW },
722
744
  { label: t.t("find-replace.dialog.find-direction.column"), value: q.COLUMN }
723
745
  ], [e]);
724
746
  }
725
- function Vt(t) {
747
+ function Kt(t) {
726
748
  const e = t.getCurrentLocale();
727
749
  return ee(() => [
728
750
  { label: t.t("find-replace.dialog.find-by.value"), value: Z.VALUE },
@@ -730,103 +752,81 @@ function Vt(t) {
730
752
  ], [e]);
731
753
  }
732
754
  function y(t) {
733
- return t.getContextValue(be);
734
- }
735
- function Gt(t) {
736
755
  return t.getContextValue(Ie);
737
756
  }
738
- function Le(t) {
739
- return t.getContextValue(Re);
757
+ function qt(t) {
758
+ return t.getContextValue(Fe);
740
759
  }
741
- const E = "7_find-replace-shortcuts";
760
+ function we(t) {
761
+ return t.getContextValue(be);
762
+ }
763
+ const $ = "7_find-replace-shortcuts";
742
764
  function ne(t) {
743
- return t.getContextValue(pe);
765
+ return t.getContextValue(ge);
744
766
  }
745
767
  function se(t) {
746
768
  return !t.getContextValue(_e);
747
769
  }
748
- const Ht = {
749
- id: x.id,
770
+ const Zt = {
771
+ id: E.id,
750
772
  description: "find-replace.shortcut.open-find-dialog",
751
773
  binding: C.F | D.CTRL_COMMAND,
752
- group: E,
774
+ group: $,
753
775
  preconditions(t) {
754
776
  return !y(t) && ne(t) && se(t);
755
777
  }
756
- }, Kt = {
757
- id: x.id,
778
+ }, zt = {
779
+ id: E.id,
758
780
  description: "find-replace.shortcut.open-find-dialog",
759
781
  binding: C.F | D.CTRL_COMMAND,
760
782
  mac: C.F | D.MAC_CTRL,
761
783
  preconditions(t) {
762
784
  return !y(t) && ne(t) && se(t);
763
785
  }
764
- }, qt = {
786
+ }, Yt = {
765
787
  id: ie.id,
766
788
  description: "find-replace.shortcut.open-replace-dialog",
767
789
  binding: C.H | D.CTRL_COMMAND,
768
790
  mac: C.H | D.MAC_CTRL,
769
- group: E,
791
+ group: $,
770
792
  preconditions(t) {
771
- return ne(t) && se(t) && (!y(t) || !Gt(t));
793
+ return ne(t) && se(t) && (!y(t) || !qt(t));
772
794
  }
773
- }, Zt = {
774
- id: Pe.id,
795
+ }, Jt = {
796
+ id: Te.id,
775
797
  description: "find-replace.shortcut.go-to-next-match",
776
798
  binding: C.ENTER,
777
- group: E,
799
+ group: $,
778
800
  priority: 1e3,
779
801
  preconditions(t) {
780
- return Le(t) && y(t);
802
+ return we(t) && y(t);
781
803
  }
782
- }, zt = {
783
- id: Te.id,
804
+ }, Qt = {
805
+ id: xe.id,
784
806
  description: "find-replace.shortcut.go-to-previous-match",
785
807
  binding: C.ENTER | D.SHIFT,
786
- group: E,
808
+ group: $,
787
809
  priority: 1e3,
788
810
  preconditions(t) {
789
- return Le(t) && y(t);
811
+ return we(t) && y(t);
790
812
  }
791
- }, Yt = {
792
- id: xe.id,
813
+ }, Xt = {
814
+ id: Ee.id,
793
815
  description: "find-replace.shortcut.focus-selection",
794
816
  binding: C.ESC,
795
- group: E,
817
+ group: $,
796
818
  priority: 1e3,
797
819
  preconditions(t) {
798
820
  return y(t);
799
821
  }
800
822
  };
801
- function Jt(t) {
802
- const e = t.get(J);
803
- return {
804
- id: x.id,
805
- icon: "SearchIcon",
806
- tooltip: "find-replace.toolbar",
807
- type: mt.BUTTON,
808
- hidden$: gt(t, lt.UNIVER_SHEET),
809
- disabled$: ve([
810
- e.subscribeContextValue$(_e),
811
- e.subscribeContextValue$(pe)
812
- ]).pipe(yt(([n, i]) => n || !i))
813
- };
814
- }
815
- const Qt = {
816
- [St.ORGANIZATION]: {
817
- [x.id]: {
818
- order: 2,
819
- menuItemFactory: Jt
820
- }
821
- }
822
- };
823
- var Xt = Object.getOwnPropertyDescriptor, ei = (t, e, n, i) => {
824
- for (var s = i > 1 ? void 0 : i ? Xt(e, n) : e, r = t.length - 1, a; r >= 0; r--)
823
+ var ei = Object.getOwnPropertyDescriptor, ti = (t, e, n, i) => {
824
+ for (var s = i > 1 ? void 0 : i ? ei(e, n) : e, r = t.length - 1, a; r >= 0; r--)
825
825
  (a = t[r]) && (s = a(s) || s);
826
826
  return s;
827
827
  }, v = (t, e) => (n, i) => e(n, i, t);
828
- const ce = "DESKTOP_FIND_REPLACE_DIALOG", we = 350, ti = 20, ii = 64;
829
- let w = class extends dt {
828
+ const ce = "DESKTOP_FIND_REPLACE_DIALOG", Ue = 350, ii = 20, ni = 64;
829
+ let U = class extends ht {
830
830
  constructor(e, n, i, s, r, a, l, d, _) {
831
831
  super();
832
832
  o(this, "_closingListenerDisposable");
@@ -838,36 +838,36 @@ let w = class extends dt {
838
838
  }
839
839
  _initCommands() {
840
840
  [
841
- x,
841
+ E,
842
842
  ie,
843
- Pe,
844
843
  Te,
844
+ xe,
845
+ Pe,
845
846
  ye,
846
- De,
847
- xe
847
+ Ee
848
848
  ].forEach((e) => {
849
849
  this.disposeWithMe(this._commandService.registerCommand(e));
850
850
  });
851
851
  }
852
852
  _initShortcuts() {
853
853
  [
854
- qt,
855
- Ht,
856
- Kt,
857
- zt,
854
+ Yt,
858
855
  Zt,
859
- Yt
856
+ zt,
857
+ Qt,
858
+ Jt,
859
+ Xt
860
860
  ].forEach((e) => this.disposeWithMe(this._shortcutService.registerShortcut(e)));
861
861
  }
862
862
  _initUI() {
863
863
  [
864
- ["FindReplaceDialog", Wt],
865
- ["SearchIcon", $e]
864
+ ["FindReplaceDialog", Vt],
865
+ ["SearchIcon", Oe]
866
866
  ].forEach(([e, n]) => {
867
867
  this.disposeWithMe(
868
868
  this._componentManager.register(e, n)
869
869
  );
870
- }), this._menuManagerService.mergeMenu(Qt), this._findReplaceService.stateUpdates$.pipe(oe(this.dispose$)).subscribe((e) => {
870
+ }), this._menuManagerService.mergeMenu(Wt), this._findReplaceService.stateUpdates$.pipe(oe(this.dispose$)).subscribe((e) => {
871
871
  e.revealed === !0 && this._openPanel();
872
872
  });
873
873
  }
@@ -875,16 +875,16 @@ let w = class extends dt {
875
875
  this._dialogService.open({
876
876
  id: ce,
877
877
  draggable: !0,
878
- width: we,
878
+ width: Ue,
879
879
  title: { title: this._localeService.t("find-replace.dialog.title") },
880
880
  children: { label: "FindReplaceDialog" },
881
881
  destroyOnClose: !0,
882
882
  mask: !1,
883
883
  maskClosable: !1,
884
- defaultPosition: ni(),
884
+ defaultPosition: si(),
885
885
  preservePositionOnDestroy: !0,
886
886
  onClose: () => this.closePanel()
887
- }), this._closingListenerDisposable = O(this._univerInstanceService.focused$.pipe(oe(this.dispose$)).subscribe((e) => {
887
+ }), this._closingListenerDisposable = A(this._univerInstanceService.focused$.pipe(oe(this.dispose$)).subscribe((e) => {
888
888
  (!e || !this._univerInstanceService.getUniverSheetInstance(e)) && this.closePanel();
889
889
  }));
890
890
  }
@@ -892,68 +892,69 @@ let w = class extends dt {
892
892
  this._closingListenerDisposable && (this._closingListenerDisposable.dispose(), this._closingListenerDisposable = null, this._dialogService.close(ce), this._findReplaceService.terminate(), queueMicrotask(() => this._layoutService.focus()));
893
893
  }
894
894
  };
895
- w = ei([
896
- v(0, fe),
897
- v(1, vt),
898
- v(2, Ct),
899
- v(3, U),
895
+ U = ti([
896
+ v(0, pe),
897
+ v(1, Ct),
898
+ v(2, Mt),
899
+ v(3, B),
900
900
  v(4, f),
901
- v(5, Mt),
902
- v(6, Se),
903
- v(7, $(B)),
904
- v(8, $(Rt))
905
- ], w);
906
- function ni() {
901
+ v(5, Rt),
902
+ v(6, ve),
903
+ v(7, O(W)),
904
+ v(8, O(bt))
905
+ ], U);
906
+ function si() {
907
907
  const { innerWidth: t } = window;
908
- return { x: t - we - ti, y: ii };
908
+ return { x: t - Ue - ii, y: ni };
909
909
  }
910
- const si = "find-replace.config", le = {};
911
- var ri = Object.getOwnPropertyDescriptor, ai = (t, e, n, i) => {
912
- for (var s = i > 1 ? void 0 : i ? ri(e, n) : e, r = t.length - 1, a; r >= 0; r--)
910
+ const ri = "@univerjs/find-replace", ai = "0.17.0", le = {
911
+ name: ri,
912
+ version: ai
913
+ }, oi = "find-replace.config", de = {};
914
+ var ci = Object.getOwnPropertyDescriptor, li = (t, e, n, i) => {
915
+ for (var s = i > 1 ? void 0 : i ? ci(e, n) : e, r = t.length - 1, a; r >= 0; r--)
913
916
  (a = t[r]) && (s = a(s) || s);
914
917
  return s;
915
- }, de = (t, e) => (n, i) => e(n, i, t);
916
- const oi = "UNIVER_FIND_REPLACE_PLUGIN";
917
- var V;
918
- let he = (V = class extends ut {
919
- constructor(t = le, e, n) {
918
+ }, he = (t, e) => (n, i) => e(n, i, t), P;
919
+ let ue = (P = class extends ft {
920
+ constructor(t = de, e, n) {
920
921
  super(), this._config = t, this._injector = e, this._configService = n;
921
- const { ...i } = ft(
922
+ const { ...i } = pt(
922
923
  {},
923
- le,
924
+ de,
924
925
  this._config
925
926
  );
926
- this._configService.setConfig(si, i);
927
+ this._configService.setConfig(oi, i);
927
928
  }
928
929
  onStarting() {
929
930
  [
930
- [w],
931
+ [U],
931
932
  [f, { useClass: Y }]
932
933
  ].forEach((t) => this._injector.add(t));
933
934
  }
934
935
  onRendered() {
935
- this._injector.get(w);
936
+ this._injector.get(U);
936
937
  }
937
- }, o(V, "pluginName", oi), V);
938
- he = ai([
939
- de(1, $(ue)),
940
- de(2, ht)
941
- ], he);
938
+ }, o(P, "pluginName", "UNIVER_FIND_REPLACE_PLUGIN"), o(P, "packageName", le.name), o(P, "version", le.version), P);
939
+ ue = li([
940
+ he(1, O(fe)),
941
+ he(2, ut)
942
+ ], ue);
942
943
  export {
943
944
  Z as FindBy,
944
945
  q as FindDirection,
945
- gi as FindModel,
946
- w as FindReplaceController,
946
+ Si as FindModel,
947
+ U as FindReplaceController,
947
948
  K as FindReplaceModel,
948
949
  Nt as FindReplaceState,
949
950
  z as FindScope,
950
- Pe as GoToNextMatchOperation,
951
- Te as GoToPreviousMatchOperation,
951
+ Te as GoToNextMatchOperation,
952
+ xe as GoToPreviousMatchOperation,
952
953
  f as IFindReplaceService,
953
- x as OpenFindDialogOperation,
954
+ E as OpenFindDialogOperation,
954
955
  ie as OpenReplaceDialogOperation,
955
- ye as ReplaceAllMatchesCommand,
956
- De as ReplaceCurrentMatchCommand,
957
- he as UniverFindReplacePlugin,
956
+ Pe as ReplaceAllMatchesCommand,
957
+ ye as ReplaceCurrentMatchCommand,
958
+ ue as UniverFindReplacePlugin,
958
959
  te as createInitFindReplaceState
959
960
  };