@univerjs_sheets-numfmt-ui.js 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286
  1. import {
  2. Ae,
  3. De,
  4. Ie,
  5. J,
  6. Je,
  7. O,
  8. Oe,
  9. P,
  10. Q,
  11. Qe,
  12. T as T2,
  13. Te as Te2,
  14. U,
  15. Ue,
  16. Ve,
  17. Ze as Ze2,
  18. k,
  19. ke,
  20. nt as nt2,
  21. rt as rt2,
  22. tt as tt2,
  23. we,
  24. x,
  25. xe
  26. } from "./chunk-KVSOW4CT.js";
  27. import {
  28. Er,
  29. Ks,
  30. bi,
  31. fl,
  32. me,
  33. tt,
  34. ue,
  35. xt
  36. } from "./chunk-T4NNB5UY.js";
  37. import {
  38. F,
  39. Go,
  40. Me,
  41. Pe,
  42. T,
  43. Te,
  44. V,
  45. Vo,
  46. ar as ar2,
  47. et,
  48. lh,
  49. lo,
  50. on,
  51. qn,
  52. uh,
  53. wt,
  54. zr
  55. } from "./chunk-BW43Z7N3.js";
  56. import {
  57. Pr
  58. } from "./chunk-QRYBFJ3R.js";
  59. import "./chunk-MIOQ566M.js";
  60. import {
  61. $e,
  62. Fa,
  63. _1,
  64. j0,
  65. l1,
  66. m1,
  67. n1,
  68. rt,
  69. u3
  70. } from "./chunk-POAJ2YNP.js";
  71. import {
  72. BO,
  73. Po,
  74. QC,
  75. a_,
  76. r_
  77. } from "./chunk-GBYP4PB2.js";
  78. import "./chunk-PZD7N4BC.js";
  79. import {
  80. Yx
  81. } from "./chunk-2MK3Q52E.js";
  82. import "./chunk-BSDDCPAW.js";
  83. import "./chunk-QG2HZMYH.js";
  84. import {
  85. DC,
  86. Fe,
  87. K0,
  88. Mf,
  89. Mi,
  90. OR,
  91. Observable,
  92. Op,
  93. Ot,
  94. Pt,
  95. Ra,
  96. SE,
  97. Vn,
  98. Vr,
  99. W0,
  100. Ze,
  101. _n,
  102. ar,
  103. combineLatest,
  104. debounceTime,
  105. dn,
  106. map,
  107. merge,
  108. ml,
  109. nf,
  110. nt,
  111. nu,
  112. ot,
  113. switchMap,
  114. tap,
  115. tr,
  116. xR
  117. } from "./chunk-23V3HWTR.js";
  118. import {
  119. require_react
  120. } from "./chunk-GNR2UJZM.js";
  121. import {
  122. __toESM
  123. } from "./chunk-2LSFTFF7.js";
  124. // node_modules/.pnpm/@univerjs+sheets-numfmt-ui@0.5.5_@grpc+grpc-js@1.13.4_react-dom@18.3.1_react@18.3.1_rxjs@7.8.1_typescript@5.4.5/node_modules/@univerjs/sheets-numfmt-ui/lib/es/index.js
  125. var import_react = __toESM(require_react());
  126. var pt = Object.defineProperty;
  127. var vt = (t, e, n) => e in t ? pt(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
  128. var X = (t, e, n) => vt(t, typeof e != "symbol" ? e + "" : e, n);
  129. var De2 = {};
  130. var dn2 = Object.defineProperty;
  131. var hn = Object.getOwnPropertyDescriptor;
  132. var fn = (t, e, n, r) => {
  133. for (var s = r > 1 ? void 0 : r ? hn(e, n) : e, i = t.length - 1, o; i >= 0; i--)
  134. (o = t[i]) && (s = (r ? o(e, n, s) : o(s)) || s);
  135. return r && s && dn2(e, n, s), s;
  136. };
  137. var U2 = (t, e) => (n, r) => e(n, r, t);
  138. var de = "SHEET_NUMFMT_ALERT";
  139. var Se = class extends nt {
  140. constructor(t, e, n, r, s, i, o) {
  141. super(), this._context = t, this._hoverManagerService = e, this._cellAlertManagerService = n, this._localeService = r, this._formulaDataModel = s, this._zenZoneService = i, this._numfmtService = o, this._init();
  142. }
  143. _init() {
  144. this._initCellAlertPopup(), this._initZenService();
  145. }
  146. _initCellAlertPopup() {
  147. this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(debounceTime(100)).subscribe((t) => {
  148. var e;
  149. if (t) {
  150. const n = t.location, r = this._context.unit, s = r.getActiveSheet();
  151. if (!s)
  152. return;
  153. const i = n.unitId, o = n.subUnitId;
  154. let a;
  155. const c = s.getCell(n.row, n.col);
  156. if (c != null && c.s) {
  157. const m = r.getStyles().get(c.s);
  158. m != null && m.n && (a = m.n);
  159. }
  160. if (a || (a = this._numfmtService.getValue(i, o, n.row, n.col)), !a) {
  161. this._hideAlert();
  162. return;
  163. }
  164. if (a.pattern === T && (c != null && c.v) && DC(c.v)) {
  165. const m = this._cellAlertManagerService.currentAlert.get(de), d = (e = m == null ? void 0 : m.alert) == null ? void 0 : e.location;
  166. if (d && d.row === n.row && d.col === n.col && d.subUnitId === n.subUnitId && d.unitId === n.unitId)
  167. return;
  168. this._cellAlertManagerService.showAlert({
  169. type: Ks.ERROR,
  170. title: this._localeService.t("info.error"),
  171. message: this._localeService.t("info.forceStringInfo"),
  172. location: n,
  173. width: 200,
  174. height: 74,
  175. key: de
  176. });
  177. return;
  178. }
  179. }
  180. this._hideAlert();
  181. }));
  182. }
  183. _initZenService() {
  184. this.disposeWithMe(this._zenZoneService.visible$.subscribe((t) => {
  185. t && this._hideAlert();
  186. }));
  187. }
  188. _hideAlert() {
  189. this._cellAlertManagerService.removeAlert(de);
  190. }
  191. };
  192. Se = fn([
  193. U2(1, ot(Er)),
  194. U2(2, ot(bi)),
  195. U2(3, ot(Vr)),
  196. U2(4, ot(Pr)),
  197. U2(5, u3),
  198. U2(6, ot(wt))
  199. ], Se);
  200. var he = {
  201. id: "sheet.operation.close.numfmt.panel",
  202. type: ar.OPERATION,
  203. handler: () => (
  204. // do nothing, just notify panel is closed
  205. true
  206. )
  207. };
  208. var A = {
  209. id: "sheet.operation.open.numfmt.panel",
  210. type: ar.OPERATION,
  211. handler: (t) => (t.get(B).openPanel(), true)
  212. };
  213. var fe = { exports: {} };
  214. var L = {};
  215. var Fe2;
  216. function pn() {
  217. if (Fe2)
  218. return L;
  219. Fe2 = 1;
  220. var t = import_react.default, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: true, ref: true, __self: true, __source: true };
  221. function o(a, c, m) {
  222. var d, u = {}, h = null, p = null;
  223. m !== void 0 && (h = "" + m), c.key !== void 0 && (h = "" + c.key), c.ref !== void 0 && (p = c.ref);
  224. for (d in c)
  225. r.call(c, d) && !i.hasOwnProperty(d) && (u[d] = c[d]);
  226. if (a && a.defaultProps)
  227. for (d in c = a.defaultProps, c)
  228. u[d] === void 0 && (u[d] = c[d]);
  229. return { $$typeof: e, type: a, key: h, ref: p, props: u, _owner: s.current };
  230. }
  231. return L.Fragment = n, L.jsx = o, L.jsxs = o, L;
  232. }
  233. var Le;
  234. function vn() {
  235. return Le || (Le = 1, fe.exports = pn()), fe.exports;
  236. }
  237. var l = vn();
  238. var _n2 = Object.defineProperty;
  239. var gn = Object.getOwnPropertyDescriptor;
  240. var Sn = (t, e, n, r) => {
  241. for (var s = r > 1 ? void 0 : r ? gn(e, n) : e, i = t.length - 1, o; i >= 0; i--)
  242. (o = t[i]) && (s = (r ? o(e, n, s) : o(s)) || s);
  243. return r && s && _n2(e, n, s), s;
  244. };
  245. var yn = (t, e) => (n, r) => e(n, r, t);
  246. var we2 = (0, import_react.createContext)([]);
  247. var k2 = class {
  248. constructor(t) {
  249. this._localStorageService = t;
  250. }
  251. _getKey(t) {
  252. return `userHabitController_${t}`;
  253. }
  254. async addHabit(t, e) {
  255. const n = this._getKey(t);
  256. return this._localStorageService.getItem(n).then((r) => {
  257. r || this._localStorageService.setItem(n, e);
  258. });
  259. }
  260. markHabit(t, e) {
  261. const n = this._getKey(t);
  262. this._localStorageService.getItem(n).then((r) => {
  263. if (r) {
  264. const s = r.findIndex((i) => i === e);
  265. s > -1 && r.splice(s, 1), r.unshift(e), this._localStorageService.setItem(n, r);
  266. }
  267. });
  268. }
  269. async getHabit(t, e) {
  270. const n = this._getKey(t), r = await this._localStorageService.getItem(n);
  271. if (e && r) {
  272. const s = r.map((i, o, a) => {
  273. const c = a.length;
  274. return {
  275. value: i,
  276. priority: c - o
  277. };
  278. });
  279. return e.sort((i, o) => {
  280. var m, d;
  281. const a = ((m = s.find((u) => u.value === i)) == null ? void 0 : m.priority) || -1;
  282. return (((d = s.find((u) => u.value === o)) == null ? void 0 : d.priority) || -1) - a;
  283. });
  284. }
  285. return r || [];
  286. }
  287. deleteHabit(t) {
  288. this._localStorageService.removeItem(t);
  289. }
  290. };
  291. k2 = Sn([
  292. yn(0, ot(xR))
  293. ], k2);
  294. var He = "numfmtCurrency";
  295. var bn = (t) => {
  296. const e = W0(k2), [n, r] = (0, import_react.useState)(J);
  297. return (0, import_react.useEffect)(() => {
  298. e.addHabit("numfmtCurrency", []).then(() => {
  299. e.getHabit(He, [...J]).then((i) => {
  300. r(i), t(i);
  301. });
  302. });
  303. }, []), { userHabitCurrency: n, mark: (i) => {
  304. e.markHabit(He, i);
  305. } };
  306. };
  307. var Cn = () => {
  308. const t = (0, import_react.useRef)([]), [e, n] = (0, import_react.useState)({});
  309. return (0, import_react.useEffect)(() => {
  310. t.current.forEach((s) => {
  311. s();
  312. }), t.current = [];
  313. }, [e]), (s) => {
  314. t.current.push(s), n({});
  315. };
  316. };
  317. var In = (t) => !!ke(t) && t.startsWith("_(");
  318. var Nn = (t) => {
  319. const { defaultPattern: e, action: n, onChange: r } = t, [s, i] = (0, import_react.useState)(() => x(e || "", 2)), o = (0, import_react.useContext)(we2), [a, c] = (0, import_react.useState)(() => ke(e) || o[0]), m = (0, import_react.useMemo)(() => o.map((v) => ({ label: v, value: v })), []), u = W0(Vr).t;
  320. n.current = () => P(`_("${a}"* #,##0${s > 0 ? ".0" : ""}_)`, s);
  321. const h = (v) => {
  322. c(v), r(P(`_("${v}"* #,##0${s > 0 ? ".0" : ""}_)`, s));
  323. }, p = (v) => {
  324. const f = v || 0;
  325. i(f), r(P(`_("${a}"* #,##0${f > 0 ? ".0" : ""}_)`, f));
  326. };
  327. return l.jsxs("div", { children: [
  328. l.jsxs("div", { className: "m-t-16 options", children: [
  329. l.jsxs("div", { className: "option", children: [
  330. l.jsx("div", { className: "label", children: u("sheet.numfmt.decimalLength") }),
  331. l.jsx("div", { className: "m-t-8 w-120", children: l.jsx(BO, { value: s, max: 20, min: 0, onChange: p }) })
  332. ] }),
  333. l.jsxs("div", { className: "option", children: [
  334. l.jsx("div", { className: "label", children: u("sheet.numfmt.currencyType") }),
  335. l.jsx("div", { className: "m-t-8 w-140", children: l.jsx(r_, { onChange: h, options: m, value: a }) })
  336. ] })
  337. ] }),
  338. l.jsx("div", { className: "describe m-t-14", children: u("sheet.numfmt.accountingDes") })
  339. ] });
  340. };
  341. var En = (t) => !!ke(t) && !t.startsWith("_(");
  342. var Tn = (t) => {
  343. const n = W0(Vr).t, r = (0, import_react.useContext)(we2), [s, i] = (0, import_react.useState)(() => ke(t.defaultPattern) || r[0]), [o, a] = (0, import_react.useState)(() => x(t.defaultPattern || "", 2)), [c, m] = (0, import_react.useState)(() => {
  344. var _;
  345. const f = tt2(s);
  346. return ((_ = f.find((I) => Ze2(I.value, t.defaultPattern))) == null ? void 0 : _.value) || f[0].value;
  347. }), d = (0, import_react.useMemo)(() => tt2(s), [s]), u = (0, import_react.useMemo)(() => r.map((f) => ({ label: f, value: f })), [r]);
  348. t.action.current = () => P(c, o);
  349. const h = (f) => {
  350. if (f === void 0)
  351. return;
  352. i(f);
  353. const y = tt2(f)[0].value;
  354. m(y), t.onChange(P(y, o));
  355. }, p = (f) => {
  356. f !== void 0 && (m(f), t.onChange(P(f, o)));
  357. }, v = (f) => {
  358. a(f || 0), t.onChange(P(c, f || 0));
  359. };
  360. return l.jsxs("div", { children: [
  361. l.jsxs("div", { className: "m-t-16 options", children: [
  362. l.jsxs("div", { className: "option", children: [
  363. l.jsx("div", { className: "label", children: n("sheet.numfmt.decimalLength") }),
  364. l.jsx("div", { className: "m-t-8 w-120", children: l.jsx(BO, { value: o, max: 20, min: 0, onChange: v }) })
  365. ] }),
  366. l.jsxs("div", { className: "option", children: [
  367. l.jsx("div", { className: "label", children: n("sheet.numfmt.currencyType") }),
  368. l.jsx("div", { className: "m-t-8 w-140", children: l.jsx(r_, { onChange: h, options: u, value: s }) })
  369. ] })
  370. ] }),
  371. l.jsx("div", { className: "m-t-16 label", children: n("sheet.numfmt.negType") }),
  372. l.jsx("div", { className: "m-t-8", children: l.jsx(a_, { onChange: p, options: d, value: c }) }),
  373. l.jsx("div", { className: "describe m-t-14", children: n("sheet.numfmt.currencyDes") })
  374. ] });
  375. };
  376. var N = function() {
  377. return N = Object.assign || function(t) {
  378. for (var e, n = 1, r = arguments.length; n < r; n++) {
  379. e = arguments[n];
  380. for (var s in e)
  381. Object.prototype.hasOwnProperty.call(e, s) && (t[s] = e[s]);
  382. }
  383. return t;
  384. }, N.apply(this, arguments);
  385. };
  386. var xn = function(t, e) {
  387. var n = {};
  388. for (var r in t)
  389. Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
  390. if (t != null && typeof Object.getOwnPropertySymbols == "function")
  391. for (var s = 0, r = Object.getOwnPropertySymbols(t); s < r.length; s++)
  392. e.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[s]) && (n[r[s]] = t[r[s]]);
  393. return n;
  394. };
  395. var ot2 = (0, import_react.forwardRef)(function(t, e) {
  396. var n = t.icon, r = t.id, s = t.className, i = t.extend, o = xn(t, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(s || "").trim(), c = (0, import_react.useRef)("_".concat(Rn()));
  397. return ct(n, "".concat(r), { defIds: n.defIds, idSuffix: c.current }, N({ ref: e, className: a }, o), i);
  398. });
  399. function ct(t, e, n, r, s) {
  400. return (0, import_react.createElement)(t.tag, N(N({ key: e }, Pn(t, n, s)), r), (Mn(t, n).children || []).map(function(i, o) {
  401. return ct(i, "".concat(e, "-").concat(t.tag, "-").concat(o), n, void 0, s);
  402. }));
  403. }
  404. function Pn(t, e, n) {
  405. var r = N({}, t.attrs);
  406. n != null && n.colorChannel1 && r.fill === "colorChannel1" && (r.fill = n.colorChannel1);
  407. var s = e.defIds;
  408. return !s || s.length === 0 || (t.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(i) {
  409. var o = i[0], a = i[1];
  410. typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
  411. })), r;
  412. }
  413. function Mn(t, e) {
  414. var n, r = e.defIds;
  415. return !r || r.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? N(N({}, t), { children: t.children.map(function(s) {
  416. return typeof s.attrs.id == "string" && r && r.indexOf(s.attrs.id) > -1 ? N(N({}, s), { attrs: N(N({}, s.attrs), { id: s.attrs.id + e.idSuffix }) }) : s;
  417. }) }) : t;
  418. }
  419. function Rn() {
  420. return Math.random().toString(36).substring(2, 8);
  421. }
  422. ot2.displayName = "UniverIcon";
  423. var jn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] };
  424. var at = (0, import_react.forwardRef)(function(t, e) {
  425. return (0, import_react.createElement)(ot2, Object.assign({}, t, {
  426. id: "check-mark-single",
  427. ref: e,
  428. icon: jn
  429. }));
  430. });
  431. at.displayName = "CheckMarkSingle";
  432. var wn = "univer-custom-format-title";
  433. var On = "univer-custom-format-input";
  434. var Un = "univer-custom-format-history-list";
  435. var $n = "univer-custom-format-history-list-item";
  436. var Dn = "univer-custom-format-history-list-item-icon-wrap";
  437. var Fn = "univer-custom-format-des";
  438. var j = {
  439. customFormatTitle: wn,
  440. customFormatInput: On,
  441. customFormatHistoryList: Un,
  442. customFormatHistoryListItem: $n,
  443. customFormatHistoryListItemIconWrap: Dn,
  444. customFormatDes: Fn
  445. };
  446. var pe = "customFormat";
  447. var ve = "numfmt_custom_pattern";
  448. function Ln(t) {
  449. const { defaultPattern: e, action: n, onChange: r } = t, s = W0(k2), i = W0(xR), o = W0(Vr), [a, c] = (0, import_react.useState)(e);
  450. n.current = () => (s.markHabit(pe, a), i.getItem(ve).then((p = []) => {
  451. const v = [.../* @__PURE__ */ new Set([a, ...p || []])].splice(0, 10).filter((f) => !!f);
  452. i.setItem(ve, v);
  453. }), a);
  454. const [m, d] = (0, import_react.useState)([]);
  455. (0, import_react.useEffect)(() => {
  456. i.getItem(ve).then((p) => {
  457. const v = [
  458. ...Q.map((f) => f.suffix("$")),
  459. ...Te2.map((f) => f.suffix),
  460. ...xe.map((f) => f.suffix)
  461. ];
  462. v.push(...p || []), s.addHabit(pe, []).finally(() => {
  463. s.getHabit(pe, v).then((f) => {
  464. d([...new Set(f)]);
  465. });
  466. });
  467. });
  468. }, []);
  469. const u = (p) => {
  470. c(p), r(p);
  471. }, h = () => {
  472. r(a);
  473. };
  474. return l.jsxs("div", { className: j.customFormat, children: [
  475. l.jsx("div", { className: j.customFormatTitle, children: o.t("sheet.numfmt.customFormat") }),
  476. l.jsx(QC, { placeholder: o.t("sheet.numfmt.customFormat"), onBlur: h, value: a, onChange: c, className: j.customFormatInput }),
  477. l.jsx("div", { className: j.customFormatHistoryList, children: m.map((p) => l.jsxs("div", { onClick: () => u(p), className: j.customFormatHistoryListItem, children: [
  478. l.jsx("div", { className: j.customFormatHistoryListItemIconWrap, children: a === p && l.jsx(at, {}) }),
  479. l.jsx("div", { children: p })
  480. ] }, p)) }),
  481. l.jsx("div", { className: j.customFormatDes, children: o.t("sheet.numfmt.customFormatDes") })
  482. ] });
  483. }
  484. var Hn = (t) => {
  485. const e = Op.getInfo(t);
  486. return nt2().map((n) => n.value).includes(t) || ["date", "datetime", "time"].includes(e.type);
  487. };
  488. var An = (t) => {
  489. const e = (0, import_react.useMemo)(nt2, []), r = W0(Vr).t, [s, i] = (0, import_react.useState)(() => {
  490. if (t.defaultPattern) {
  491. const a = e.find((c) => c.value === t.defaultPattern);
  492. if (a)
  493. return a.value;
  494. }
  495. return e[0].value;
  496. });
  497. t.action.current = () => s;
  498. const o = (a) => {
  499. a !== void 0 && (i(a), t.onChange(a));
  500. };
  501. return l.jsxs("div", { children: [
  502. l.jsx("div", { className: "m-t-16 label", children: r("sheet.numfmt.dateType") }),
  503. l.jsx("div", { className: "m-t-8", children: l.jsx(a_, { value: s, options: e, onChange: o }) }),
  504. l.jsx("div", { className: "describe m-t-14", children: r("sheet.numfmt.dateDes") })
  505. ] });
  506. };
  507. var kn = (t) => !t;
  508. var Bn = (t) => {
  509. const n = W0(Vr).t;
  510. return t.action.current = () => "", l.jsx("div", { children: l.jsx("div", { className: "describe m-t-14", children: n("sheet.numfmt.generalDes") }) });
  511. };
  512. var Wn = (t) => rt2().some((e) => Ze2(e.value, t));
  513. var Vn2 = (t) => {
  514. const e = W0(Vr), n = (0, import_react.useMemo)(rt2, []), [r, s] = (0, import_react.useState)(() => x(t.defaultPattern || "", 0)), [i, o] = (0, import_react.useState)(() => {
  515. const u = n.find((h) => Ze2(h.value, t.defaultPattern || ""));
  516. return (u == null ? void 0 : u.value) || n[0].value;
  517. }), a = (0, import_react.useMemo)(() => P(i, Number(r || 0)), [i, r]), c = (0, import_react.useMemo)(() => !Je(i), [i]), m = (u) => {
  518. s(u || 0), t.onChange(P(i, Number(u || 0)));
  519. }, d = (u) => {
  520. u !== void 0 && (s(x(u, 0)), o(u), t.onChange(u));
  521. };
  522. return t.action.current = () => a, l.jsxs("div", { children: [
  523. l.jsx("div", { className: "m-t-16 label", children: e.t("sheet.numfmt.decimalLength") }),
  524. l.jsx("div", { className: "m-t-8", children: l.jsx(
  525. BO,
  526. {
  527. disabled: c,
  528. value: r,
  529. max: 20,
  530. min: 0,
  531. onChange: m
  532. }
  533. ) }),
  534. l.jsxs("div", { className: "m-t-16 label", children: [
  535. " ",
  536. e.t("sheet.numfmt.negType")
  537. ] }),
  538. l.jsx("div", { className: "m-t-8", children: l.jsx(a_, { onChange: d, options: n, value: i }) }),
  539. l.jsx("div", { className: "describe m-t-14", children: e.t("sheet.numfmt.thousandthPercentileDes") })
  540. ] });
  541. };
  542. var Gn = (t) => {
  543. const { defaultValue: e, defaultPattern: n, row: r, col: s } = t.value, i = W0(Vr), o = (0, import_react.useRef)(() => ""), a = i.t, c = Cn(), m = (0, import_react.useMemo)(
  544. () => [
  545. { label: "sheet.numfmt.general", component: Bn },
  546. { label: "sheet.numfmt.accounting", component: Nn },
  547. { label: "sheet.numfmt.currency", component: Tn },
  548. { label: "sheet.numfmt.date", component: An },
  549. { label: "sheet.numfmt.thousandthPercentile", component: Vn2 },
  550. { label: "sheet.numfmt.customFormat", component: Ln }
  551. ].map((g) => ({ ...g, label: a(g.label) })),
  552. []
  553. ), [d, u] = (0, import_react.useState)(_), [h, p] = (0, import_react.useState)(() => `${r}_${s}`), { mark: v, userHabitCurrency: f } = bn(() => p(`${r}_${s}_userCurrency'`)), y = (0, import_react.useMemo)(() => {
  554. var g;
  555. return (g = m.find((w) => w.label === d)) == null ? void 0 : g.component;
  556. }, [d]);
  557. function _() {
  558. return [kn, In, En, Hn, Wn].reduce((w, ht, ft) => w || (ht(n) ? m[ft].label : ""), "") || m[0].label;
  559. }
  560. const I = m.map((g) => ({
  561. label: g.label,
  562. value: g.label
  563. })), P2 = (g) => {
  564. u(g), c(() => t.onChange({ type: "change", value: o.current() || "" }));
  565. }, J2 = (g) => {
  566. t.onChange({ type: "change", value: g });
  567. }, le = () => {
  568. const g = o.current() || "", w = ke(g);
  569. w && v(w), t.onChange({ type: "confirm", value: g });
  570. }, F2 = () => {
  571. t.onChange({ type: "cancel", value: "" });
  572. }, me2 = {
  573. onChange: J2,
  574. defaultValue: e,
  575. defaultPattern: n,
  576. action: o
  577. };
  578. return (0, import_react.useEffect)(() => {
  579. u(_()), p(`${r}_${s}`);
  580. }, [r, s]), l.jsxs("div", { className: "numfmt-panel p-b-20", children: [
  581. l.jsxs("div", { children: [
  582. l.jsx("div", { className: "label m-t-14", children: a("sheet.numfmt.numfmtType") }),
  583. l.jsx("div", { className: "m-t-8", children: l.jsx(r_, { onChange: P2, options: I, value: d, style: { width: "100%" } }) }),
  584. l.jsx("div", { children: y && l.jsx(we2.Provider, { value: f, children: (0, import_react.createElement)(y, { ...me2, key: h }) }) })
  585. ] }),
  586. l.jsxs("div", { className: "btn-list m-t-14 m-b-20", children: [
  587. l.jsx(Po, { size: "small", onClick: F2, className: "m-r-12", children: a("sheet.numfmt.cancel") }),
  588. l.jsx(Po, { type: "primary", size: "small", onClick: le, children: a("sheet.numfmt.confirm") })
  589. ] })
  590. ] });
  591. };
  592. var Kn = Object.defineProperty;
  593. var qn2 = Object.getOwnPropertyDescriptor;
  594. var Yn = (t, e, n, r) => {
  595. for (var s = r > 1 ? void 0 : r ? qn2(e, n) : e, i = t.length - 1, o; i >= 0; i--)
  596. (o = t[i]) && (s = (r ? o(e, n, s) : o(s)) || s);
  597. return r && s && Kn(e, n, s), s;
  598. };
  599. var x2 = (t, e) => (n, r) => e(n, r, t);
  600. var Ae2 = "SHEET_NUMFMT_PANEL";
  601. var B = class extends nt {
  602. constructor(e, n, r, s, i, o, a, c, m, d, u) {
  603. super();
  604. X(this, "_previewPattern", "");
  605. X(this, "_sidebarDisposable", null);
  606. this._sheetInterceptorService = e, this._themeService = n, this._univerInstanceService = r, this._commandService = s, this._selectionManagerService = i, this._renderManagerService = o, this._numfmtService = a, this._componentManager = c, this._sidebarService = m, this._localeService = d, this._sheetsNumfmtCellContentController = u, this._initRealTimeRenderingInterceptor(), this._initPanel(), this._initCommands(), this._initCloseListener(), this._commandExecutedListener(), this._initNumfmtLocalChange();
  607. }
  608. _initNumfmtLocalChange() {
  609. this.disposeWithMe(merge(this._sheetsNumfmtCellContentController.local$, this._localeService.currentLocale$).subscribe(() => {
  610. this._forceUpdate();
  611. }));
  612. }
  613. openPanel() {
  614. var y;
  615. const e = this._sidebarService, n = this._selectionManagerService, r = this._commandService, s = this._univerInstanceService, i = this._numfmtService, o = this._localeService, c = (((y = n.getCurrentSelections()) == null ? void 0 : y.map((_) => _.range)) || [])[0];
  616. if (!c)
  617. return false;
  618. const m = s.getCurrentUnitForType(Fe.UNIVER_SHEET), d = m.getActiveSheet();
  619. if (!d)
  620. return false;
  621. const u = d.getCellRaw(c.startRow, c.startColumn), h = i.getValue(
  622. m.getUnitId(),
  623. d.getSheetId(),
  624. c.startRow,
  625. c.startColumn
  626. );
  627. let p = "";
  628. h && (p = h.pattern);
  629. const v = (u == null ? void 0 : u.t) === dn.NUMBER ? u.v : 12345678, f = {
  630. onChange: (_) => {
  631. var I;
  632. if (_.type === "change")
  633. this._previewPattern = _.value, this._forceUpdate();
  634. else if (_.type === "confirm") {
  635. const P2 = ((I = n.getCurrentSelections()) == null ? void 0 : I.map((F2) => F2.range)) || [], J2 = { values: [] }, le = Qe(_.value);
  636. P2.forEach((F2) => {
  637. tr.foreach(F2, (me2, g) => {
  638. J2.values.push({
  639. row: me2,
  640. col: g,
  641. pattern: _.value,
  642. type: le
  643. });
  644. });
  645. }), r.executeCommand(T2.id, J2), e.close();
  646. } else
  647. _.type === "cancel" && e.close();
  648. },
  649. value: { defaultPattern: p, defaultValue: v, row: c.startRow, col: c.startColumn }
  650. };
  651. return this._sidebarDisposable = e.open({
  652. header: { title: o.t("sheet.numfmt.title") },
  653. children: {
  654. label: Ae2,
  655. ...f
  656. // need passthrough to react props.
  657. },
  658. onClose: () => {
  659. this._forceUpdate(), r.executeCommand(he.id);
  660. }
  661. }), true;
  662. }
  663. _forceUpdate(e) {
  664. var r;
  665. const n = this._renderManagerService.getRenderById(
  666. e != null ? e : this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET).getUnitId()
  667. );
  668. n == null || n.with(me).reCalculate(), (r = n == null ? void 0 : n.mainComponent) == null || r.makeDirty();
  669. }
  670. _initCommands() {
  671. [
  672. A,
  673. he
  674. ].forEach((e) => {
  675. this.disposeWithMe(this._commandService.registerCommand(e));
  676. });
  677. }
  678. _initPanel() {
  679. this._componentManager.register(Ae2, Gn);
  680. }
  681. // eslint-disable-next-line max-lines-per-function
  682. _initRealTimeRenderingInterceptor() {
  683. const e = new Observable((r) => {
  684. this._commandService.onCommandExecuted((s) => {
  685. s.id === A.id && r.next(true), s.id === he.id && r.next(false);
  686. });
  687. }), n = combineLatest([
  688. e,
  689. this._selectionManagerService.selectionMoveEnd$.pipe(
  690. map((r) => r ? r.map((s) => s.range) : [])
  691. )
  692. ]);
  693. this.disposeWithMe(
  694. Ze(
  695. n.pipe(
  696. switchMap(
  697. ([r, s]) => new Observable((i) => {
  698. const o = new Mi();
  699. return r && s.length && i.next({ selectionRanges: s, disposableCollection: o }), () => {
  700. o.dispose();
  701. };
  702. })
  703. ),
  704. tap(() => {
  705. this._previewPattern = null;
  706. })
  707. ).subscribe(({ disposableCollection: r, selectionRanges: s }) => {
  708. var o, a;
  709. const i = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET);
  710. this.openPanel(), r.add(
  711. this._sheetInterceptorService.intercept(et.CELL_CONTENT, {
  712. priority: 99,
  713. effect: Vn.Value | Vn.Style,
  714. handler: (c, m, d) => {
  715. const { row: u, col: h } = m, p = d(c) || {};
  716. if (s.find(
  717. (v) => v.startColumn <= h && v.endColumn >= h && v.startRow <= u && v.endRow >= u
  718. )) {
  719. const v = m.worksheet.getCellRaw(u, h), f = v == null ? void 0 : v.v, y = v == null ? void 0 : v.t;
  720. if (f == null || y !== dn.NUMBER || this._previewPattern === null)
  721. return p;
  722. const _ = we(this._previewPattern, f, this._sheetsNumfmtCellContentController.local);
  723. if (_.color) {
  724. const P2 = this._themeService.getCurrentTheme()[`${_.color}500`];
  725. return {
  726. ...p,
  727. v: _.result,
  728. t: dn.STRING,
  729. s: { cl: { rgb: P2 } }
  730. };
  731. }
  732. return {
  733. ...p,
  734. v: _.result,
  735. t: dn.STRING
  736. };
  737. }
  738. return p;
  739. }
  740. })
  741. ), (a = (o = this._renderManagerService.getRenderById(i.getUnitId())) == null ? void 0 : o.mainComponent) == null || a.makeDirty();
  742. })
  743. )
  744. );
  745. }
  746. _commandExecutedListener() {
  747. const e = [zr.id, Vo.id];
  748. this.disposeWithMe(
  749. new Observable((n) => {
  750. const r = this._commandService.onCommandExecuted((s) => {
  751. if (e.includes(s.id)) {
  752. const i = s.params;
  753. n.next(i.unitId);
  754. }
  755. });
  756. return () => r.dispose();
  757. }).pipe(debounceTime(16)).subscribe((n) => this._forceUpdate(n))
  758. );
  759. }
  760. _initCloseListener() {
  761. this._univerInstanceService.getCurrentTypeOfUnit$(Fe.UNIVER_SHEET).subscribe((e) => {
  762. var n;
  763. e || ((n = this._sidebarDisposable) == null || n.dispose(), this._sidebarDisposable = null);
  764. });
  765. }
  766. };
  767. B = Yn([
  768. x2(0, ot(V)),
  769. x2(1, ot(ml)),
  770. x2(2, _n),
  771. x2(3, Pt),
  772. x2(4, ot(F)),
  773. x2(5, Yx),
  774. x2(6, wt),
  775. x2(7, ot(n1)),
  776. x2(8, rt),
  777. x2(9, ot(Vr)),
  778. x2(10, ot(U))
  779. ], B);
  780. var Zn = Object.defineProperty;
  781. var zn = Object.getOwnPropertyDescriptor;
  782. var Jn = (t, e, n, r) => {
  783. for (var s = r > 1 ? void 0 : r ? zn(e, n) : e, i = t.length - 1, o; i >= 0; i--)
  784. (o = t[i]) && (s = (r ? o(e, n, s) : o(s)) || s);
  785. return r && s && Zn(e, n, s), s;
  786. };
  787. var H = (t, e) => (n, r) => e(n, r, t);
  788. var Xn = () => {
  789. let t = [];
  790. return {
  791. add: (s, i, o, a, c) => t.push({ unitId: s, subUnitId: i, row: o, col: a, value: c }),
  792. getEffects: () => t,
  793. clean: () => {
  794. t = [];
  795. }
  796. };
  797. };
  798. var re = class extends nt {
  799. constructor(e, n, r, s, i) {
  800. super();
  801. X(this, "_collectEffectMutation", Xn());
  802. this._sheetInterceptorService = e, this._numfmtService = n, this._univerInstanceService = r, this._injector = s, this._editorBridgeService = i, this._initInterceptorEditorStart(), this._initInterceptorEditorEnd(), this._initInterceptorCommands();
  803. }
  804. _initInterceptorEditorStart() {
  805. this._editorBridgeService && this.disposeWithMe(
  806. Ze(
  807. this._sheetInterceptorService.writeCellInterceptor.intercept(
  808. Go,
  809. {
  810. handler: (e, n, r) => {
  811. const s = n.row, i = n.col, o = this._numfmtService.getValue(
  812. n.unitId,
  813. n.subUnitId,
  814. s,
  815. i
  816. );
  817. if (o)
  818. switch (Qe(o.pattern)) {
  819. case "scientific":
  820. case "currency":
  821. case "grouped":
  822. case "number": {
  823. const c = n.worksheet.getCellRaw(s, i);
  824. return r && r(c);
  825. }
  826. case "percent":
  827. case "date":
  828. case "time":
  829. case "datetime":
  830. default:
  831. return r && r(e);
  832. }
  833. return r(e);
  834. }
  835. }
  836. )
  837. )
  838. );
  839. }
  840. /**
  841. * Process the values after edit
  842. * @private
  843. * @memberof NumfmtService
  844. */
  845. _initInterceptorEditorEnd() {
  846. this.disposeWithMe(
  847. Ze(
  848. this._sheetInterceptorService.writeCellInterceptor.intercept(
  849. qn,
  850. {
  851. // eslint-disable-next-line complexity
  852. handler: (e, n, r) => {
  853. var d, u, h, p;
  854. this._collectEffectMutation.clean();
  855. const s = this._numfmtService.getValue(
  856. n.unitId,
  857. n.subUnitId,
  858. n.row,
  859. n.col
  860. ), i = (d = s && Qe(s.pattern)) != null ? d : "", o = () => {
  861. s && this._collectEffectMutation.add(
  862. n.unitId,
  863. n.subUnitId,
  864. n.row,
  865. n.col,
  866. null
  867. );
  868. };
  869. if (!(e != null && e.v) && !(e != null && e.p) || (s == null ? void 0 : s.pattern) === T || e.t === dn.FORCE_STRING)
  870. return r(e);
  871. const a = (u = e.p) == null ? void 0 : u.body, c = (p = (h = e == null ? void 0 : e.p) == null ? void 0 : h.body) != null && p.dataStream ? e.p.body.dataStream.replace(/\r\n$/, "") : String(e.v), m = Op.parseDate(c) || Op.parseTime(c) || Op.parseNumber(c);
  872. if (a)
  873. if (er(a)) {
  874. const { dataStream: v } = a, f = v.replace(/\r\n$/, ""), y = Number(f);
  875. if (Number.isNaN(y) && !m)
  876. return r(e);
  877. } else
  878. return r(e);
  879. if (m) {
  880. m.z && this._collectEffectMutation.add(
  881. n.unitId,
  882. n.subUnitId,
  883. n.row,
  884. n.col,
  885. {
  886. pattern: m.z
  887. }
  888. );
  889. const v = Number(m.v);
  890. return r({ ...e, p: void 0, v, t: dn.NUMBER });
  891. } else
  892. (["date", "time", "datetime", "percent"].includes(i) || !Qn(c)) && o();
  893. return r(e);
  894. }
  895. }
  896. )
  897. )
  898. );
  899. }
  900. _initInterceptorCommands() {
  901. const e = this;
  902. this.disposeWithMe(
  903. this._sheetInterceptorService.interceptCommand({
  904. getMutations(n) {
  905. var r;
  906. switch (n.id) {
  907. case on.id: {
  908. const s = e._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET), i = s.getUnitId(), o = (r = s.getActiveSheet()) == null ? void 0 : r.getSheetId();
  909. if (!o)
  910. return {
  911. redos: [],
  912. undos: []
  913. };
  914. const a = e._collectEffectMutation.getEffects();
  915. if (e._collectEffectMutation.clean(), !a.length)
  916. return {
  917. redos: [],
  918. undos: []
  919. };
  920. const c = a.filter((h) => {
  921. var p;
  922. return !!((p = h.value) != null && p.pattern);
  923. }).map((h) => ({
  924. row: h.row,
  925. col: h.col,
  926. pattern: h.value.pattern
  927. })), m = a.filter((h) => {
  928. var p;
  929. return !((p = h.value) != null && p.pattern);
  930. }).map((h) => ({
  931. startRow: h.row,
  932. endColumn: h.col,
  933. startColumn: h.col,
  934. endRow: h.row
  935. })), d = [], u = [];
  936. if (c.length) {
  937. const h = {
  938. id: Vo.id,
  939. params: lo(i, o, c)
  940. };
  941. d.push(h), u.push(...uh(e._injector, h.params));
  942. }
  943. if (m.length) {
  944. const h = {
  945. id: zr.id,
  946. params: {
  947. unitId: i,
  948. subUnitId: o,
  949. ranges: m
  950. }
  951. };
  952. d.push(h), u.push(...lh(e._injector, h.params));
  953. }
  954. return {
  955. redos: d,
  956. undos: u.reverse()
  957. };
  958. }
  959. }
  960. return {
  961. redos: [],
  962. undos: []
  963. };
  964. }
  965. })
  966. );
  967. }
  968. };
  969. re = Jn([
  970. H(0, ot(V)),
  971. H(1, ot(wt)),
  972. H(2, ot(_n)),
  973. H(3, ot(Ot)),
  974. H(4, nf(tt))
  975. ], re);
  976. function Qn(t) {
  977. return /^-?\d+(\.\d+)?$/.test(t);
  978. }
  979. function er(t) {
  980. const { textRuns: e = [], paragraphs: n = [], customRanges: r, customBlocks: s = [] } = t, i = ["va"];
  981. return !(e.some((o) => !!(o.ts && Object.keys(o.ts).some((c) => i.includes(c)))) || n.some((o) => o.bullet) || n.length >= 2 || r != null && r.length || s.length > 0);
  982. }
  983. var ee = [
  984. {
  985. label: "sheet.numfmt.general",
  986. pattern: null
  987. },
  988. {
  989. label: "sheet.numfmt.text",
  990. pattern: T
  991. },
  992. "|",
  993. {
  994. label: "sheet.numfmt.number",
  995. pattern: "0"
  996. },
  997. "|",
  998. {
  999. label: "sheet.numfmt.accounting",
  1000. pattern: '"¥" #,##0.00_);[Red]("¥"#,##0.00)'
  1001. },
  1002. {
  1003. label: "sheet.numfmt.financialValue",
  1004. pattern: "#,##0.00;[Red]#,##0.00"
  1005. },
  1006. {
  1007. label: "sheet.numfmt.currency",
  1008. pattern: '"¥"#,##0.00_);[Red]("¥"#,##0.00)'
  1009. },
  1010. {
  1011. label: "sheet.numfmt.roundingCurrency",
  1012. pattern: '"¥"#,##0;[Red]"¥"#,##0'
  1013. },
  1014. "|",
  1015. {
  1016. label: "sheet.numfmt.date",
  1017. pattern: "yyyy-mm-dd;@"
  1018. },
  1019. {
  1020. label: "sheet.numfmt.time",
  1021. pattern: 'am/pm h":"mm":"ss'
  1022. },
  1023. {
  1024. label: "sheet.numfmt.dateTime",
  1025. pattern: "yyyy-m-d am/pm h:mm"
  1026. },
  1027. {
  1028. label: "sheet.numfmt.timeDuration",
  1029. pattern: "h:mm:ss"
  1030. },
  1031. "|",
  1032. {
  1033. label: "sheet.numfmt.moreFmt",
  1034. pattern: ""
  1035. }
  1036. ];
  1037. var tr2 = (t) => ({
  1038. icon: new Observable((e) => {
  1039. const n = t.get(k);
  1040. function r(i) {
  1041. return {
  1042. [Ie.US]: "DollarSingle",
  1043. [Ie.RU]: "RoubleSingle",
  1044. [Ie.CN]: "RmbSingle",
  1045. [Ie.AT]: "EuroSingle"
  1046. }[i] || "DollarSingle";
  1047. }
  1048. const s = Ie[n.getCurrencySymbol()] || "$";
  1049. return e.next(r(s)), n.currencySymbol$.subscribe((i) => {
  1050. const o = Ie[i] || "$";
  1051. e.next(r(o));
  1052. });
  1053. }),
  1054. id: Oe.id,
  1055. title: "sheet.numfmt.currency",
  1056. tooltip: "sheet.numfmt.currency",
  1057. type: $e.BUTTON,
  1058. hidden$: Fa(t, Fe.UNIVER_SHEET),
  1059. disabled$: ue(t, { workbookTypes: [Me], worksheetTypes: [Te, ar2], rangeTypes: [Pe] })
  1060. });
  1061. var nr = (t) => ({
  1062. icon: "AddDigitsSingle",
  1063. id: Ue.id,
  1064. title: "sheet.numfmt.addDecimal",
  1065. tooltip: "sheet.numfmt.addDecimal",
  1066. type: $e.BUTTON,
  1067. hidden$: Fa(t, Fe.UNIVER_SHEET),
  1068. disabled$: ue(t, { workbookTypes: [Me], worksheetTypes: [Te, ar2], rangeTypes: [Pe] })
  1069. });
  1070. var rr = (t) => ({
  1071. icon: "ReduceDigitsSingle",
  1072. id: Ve.id,
  1073. title: "sheet.numfmt.subtractDecimal",
  1074. tooltip: "sheet.numfmt.subtractDecimal",
  1075. type: $e.BUTTON,
  1076. hidden$: Fa(t, Fe.UNIVER_SHEET),
  1077. disabled$: ue(t, { workbookTypes: [Me], worksheetTypes: [Te, ar2], rangeTypes: [Pe] })
  1078. });
  1079. var sr = (t) => ({
  1080. icon: "PercentSingle",
  1081. id: De.id,
  1082. title: "sheet.numfmt.percent",
  1083. tooltip: "sheet.numfmt.percent",
  1084. type: $e.BUTTON,
  1085. hidden$: Fa(t, Fe.UNIVER_SHEET),
  1086. disabled$: ue(t, { workbookTypes: [Me], worksheetTypes: [Te, ar2], rangeTypes: [Pe] })
  1087. });
  1088. var ir = (t) => {
  1089. const e = t.get(_n), n = t.get(Pt), r = t.get(Vr), s = t.get(F), i = xt(e, "", ({ workbook: o, worksheet: a }) => new Observable(
  1090. (c) => merge(
  1091. s.selectionMoveEnd$,
  1092. new Observable((m) => {
  1093. const d = [zr.id, Vo.id], u = n.onCommandExecuted((h) => {
  1094. d.includes(h.id) && m.next(null);
  1095. });
  1096. return () => u.dispose();
  1097. })
  1098. ).subscribe(() => {
  1099. var d, u;
  1100. const m = s.getCurrentSelections();
  1101. if (m && m[0]) {
  1102. const h = m[0].range, p = h.startRow, v = h.startColumn, f = (u = o.getStyles().get((d = a.getCell(p, v)) == null ? void 0 : d.s)) == null ? void 0 : u.n, y = f == null ? void 0 : f.pattern;
  1103. let _ = r.t("sheet.numfmt.general");
  1104. if (y) {
  1105. const I = ee.filter((P2) => typeof P2 == "object" && P2.pattern).find(
  1106. (P2) => Ze2(y, P2.pattern)
  1107. );
  1108. I && typeof I == "object" && I.pattern ? _ = r.t(I.label) : _ = r.t("sheet.numfmt.moreFmt");
  1109. }
  1110. c.next(_);
  1111. }
  1112. })
  1113. ));
  1114. return {
  1115. label: lt,
  1116. id: A.id,
  1117. tooltip: "sheet.numfmt.title",
  1118. type: $e.SELECTOR,
  1119. selections: [
  1120. {
  1121. label: {
  1122. name: mt,
  1123. hoverable: false
  1124. }
  1125. }
  1126. ],
  1127. value$: i,
  1128. hidden$: Fa(t, Fe.UNIVER_SHEET),
  1129. disabled$: ue(t, { workbookTypes: [Me], worksheetTypes: [ar2, Te], rangeTypes: [Pe] })
  1130. };
  1131. };
  1132. var lt = "sheet.numfmt.moreNumfmtType";
  1133. var mt = "sheet.numfmt.moreNumfmtType.options";
  1134. var or = (t) => {
  1135. var r;
  1136. const e = W0(Vr), n = (r = t.value) != null ? r : e.t("sheet.numfmt.general");
  1137. return l.jsx("span", { className: "more-numfmt-type", children: n });
  1138. };
  1139. var cr = () => {
  1140. const t = W0(Pt), e = W0(Vr), n = W0(_1), r = W0(U), s = W0(F), i = (c) => {
  1141. const m = s.getCurrentLastSelection();
  1142. if (!m)
  1143. return;
  1144. const d = m.range, u = [];
  1145. tr.foreach(d, (h, p) => {
  1146. c ? u.push({ row: h, col: p, pattern: c, type: Qe(c) }) : u.push({ row: h, col: p });
  1147. }), t.executeCommand(T2.id, { values: u }), n.focus();
  1148. }, o = (c) => {
  1149. if (c === 0)
  1150. i(null);
  1151. else if (c === ee.length - 1)
  1152. t.executeCommand(A.id);
  1153. else {
  1154. const m = ee[c];
  1155. m.pattern && i(m.pattern);
  1156. }
  1157. }, a = 1220;
  1158. return l.jsx("div", { className: "more-numfmt-type-options", children: ee.map((c, m) => c === "|" ? l.jsx("div", { className: "line m-t-4", onClick: (d) => d.stopPropagation() }, m) : l.jsxs(
  1159. "div",
  1160. {
  1161. className: "option-item m-t-4",
  1162. onClick: () => {
  1163. o(m);
  1164. },
  1165. children: [
  1166. l.jsx("div", { children: e.t(c.label) }),
  1167. l.jsx("div", { className: "m-l-26", children: c.pattern ? Ae(c.pattern || "", a, r.local).result : "" })
  1168. ]
  1169. },
  1170. m
  1171. )) });
  1172. };
  1173. var ar3 = {
  1174. [l1.FORMULAS_INSERT]: {
  1175. [Oe.id]: {
  1176. order: 4,
  1177. menuItemFactory: tr2
  1178. },
  1179. [Ue.id]: {
  1180. order: 5,
  1181. menuItemFactory: nr
  1182. },
  1183. [Ve.id]: {
  1184. order: 6,
  1185. menuItemFactory: rr
  1186. },
  1187. [De.id]: {
  1188. order: 7,
  1189. menuItemFactory: sr
  1190. },
  1191. [A.id]: {
  1192. order: 8,
  1193. menuItemFactory: ir
  1194. }
  1195. }
  1196. };
  1197. var lr = Object.defineProperty;
  1198. var mr = Object.getOwnPropertyDescriptor;
  1199. var ur = (t, e, n, r) => {
  1200. for (var s = r > 1 ? void 0 : r ? mr(e, n) : e, i = t.length - 1, o; i >= 0; i--)
  1201. (o = t[i]) && (s = (r ? o(e, n, s) : o(s)) || s);
  1202. return r && s && lr(e, n, s), s;
  1203. };
  1204. var ke2 = (t, e) => (n, r) => e(n, r, t);
  1205. var se = class extends nt {
  1206. constructor(t, e) {
  1207. super(), this._componentManager = t, this._menuManagerService = e, this._initMenu();
  1208. }
  1209. _initMenu() {
  1210. this._menuManagerService.mergeMenu(ar3), this.disposeWithMe(this._componentManager.register(lt, or)), this.disposeWithMe(this._componentManager.register(mt, cr));
  1211. }
  1212. };
  1213. se = ur([
  1214. ke2(0, ot(n1)),
  1215. ke2(1, m1)
  1216. ], se);
  1217. var ut = Object.defineProperty;
  1218. var dr = Object.getOwnPropertyDescriptor;
  1219. var hr = (t, e, n) => e in t ? ut(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
  1220. var fr = (t, e, n, r) => {
  1221. for (var s = r > 1 ? void 0 : r ? dr(e, n) : e, i = t.length - 1, o; i >= 0; i--)
  1222. (o = t[i]) && (s = (r ? o(e, n, s) : o(s)) || s);
  1223. return r && s && ut(e, n, s), s;
  1224. };
  1225. var _e = (t, e) => (n, r) => e(n, r, t);
  1226. var dt = (t, e, n) => hr(t, typeof e != "symbol" ? e + "" : e, n);
  1227. var pr = "SHEET_NUMFMT_UI_PLUGIN";
  1228. var ie = class extends Ra {
  1229. constructor(t = De2, e, n, r) {
  1230. super(), this._config = t, this._injector = e, this._configService = n, this._renderManagerService = r;
  1231. const { menu: s, ...i } = nu(
  1232. {},
  1233. De2,
  1234. this._config
  1235. );
  1236. s && this._configService.setConfig("menu", s, { merge: true }), this._configService.setConfig(j0, i);
  1237. }
  1238. onStarting() {
  1239. K0(this._injector, [
  1240. [B],
  1241. [re],
  1242. [k2],
  1243. [se]
  1244. ]);
  1245. }
  1246. onRendered() {
  1247. this._registerRenderModules(), Mf(this._injector, [
  1248. [B],
  1249. [re],
  1250. [se]
  1251. ]);
  1252. }
  1253. _registerRenderModules() {
  1254. [
  1255. [Se]
  1256. ].forEach((e) => {
  1257. this.disposeWithMe(this._renderManagerService.registerRenderModule(Fe.UNIVER_SHEET, e));
  1258. });
  1259. }
  1260. };
  1261. dt(ie, "pluginName", pr);
  1262. dt(ie, "type", Fe.UNIVER_SHEET);
  1263. ie = fr([
  1264. OR(fl, O),
  1265. _e(1, ot(Ot)),
  1266. _e(2, SE),
  1267. _e(3, Yx)
  1268. ], ie);
  1269. export {
  1270. ie as UniverSheetsNumfmtUIPlugin
  1271. };
  1272. /*! Bundled license information:
  1273. @univerjs/sheets-numfmt-ui/lib/es/index.js:
  1274. (**
  1275. * @license React
  1276. * react-jsx-runtime.production.min.js
  1277. *
  1278. * Copyright (c) Facebook, Inc. and its affiliates.
  1279. *
  1280. * This source code is licensed under the MIT license found in the
  1281. * LICENSE file in the root directory of this source tree.
  1282. *)
  1283. */
  1284. //# sourceMappingURL=@univerjs_sheets-numfmt-ui.js.map