onchain-uikit 3.9.4-alpha85 → 3.9.4-alpha89

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.
@@ -42063,14 +42063,16 @@ const zhCN = {
42063
42063
  import: "导入",
42064
42064
  saveDatabase: "保存",
42065
42065
  generate: "实例生成作业指导书",
42066
- AddImageSingle: "插入图片"
42066
+ AddImageSingle: "插入图片",
42067
+ AddAttachmentButtonOperation: "插入附件"
42067
42068
  },
42068
42069
  shortcut: {
42069
42070
  export: "导出",
42070
42071
  import: "导入",
42071
42072
  saveDatabase: "保存",
42072
42073
  generate: "实例生成作业指导书",
42073
- AddImageSingle: "插入图片"
42074
+ AddImageSingle: "插入图片",
42075
+ AddAttachmentButtonOperation: "插入附件"
42074
42076
  }
42075
42077
  }, enUS = {
42076
42078
  customMenu: {
@@ -114550,6 +114552,14 @@ function generateShortUuid() {
114550
114552
  return Math.random().toString(36).substring(2, 8);
114551
114553
  }
114552
114554
  IconBase.displayName = "UniverIcon";
114555
+ var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "g", attrs: { fill: "currentColor", clipPath: "url(#add-attachment-single_clip0_1451_20)" }, children: [{ tag: "path", attrs: { d: "M8.00381 4.83154C8.33518 4.83154 8.60381 5.10017 8.60381 5.43154V7.3999H10.5671C10.8985 7.3999 11.1671 7.66853 11.1671 7.9999C11.1671 8.33127 10.8985 8.5999 10.5671 8.5999H8.60381V10.569C8.60381 10.9004 8.33518 11.169 8.00381 11.169C7.67244 11.169 7.40381 10.9004 7.40381 10.569V8.5999H5.42959C5.09822 8.5999 4.82959 8.33127 4.82959 7.9999C4.82959 7.66853 5.09822 7.3999 5.42959 7.3999H7.40381V5.43154C7.40381 5.10017 7.67244 4.83154 8.00381 4.83154Z" } }, { tag: "path", attrs: { d: "M0.978027 7.9999C0.978027 4.12183 4.12183 0.978027 7.9999 0.978027C11.878 0.978027 15.0218 4.12183 15.0218 7.9999C15.0218 11.878 11.878 15.0218 7.9999 15.0218C4.12183 15.0218 0.978027 11.878 0.978027 7.9999ZM7.9999 2.17803C4.78457 2.17803 2.17803 4.78457 2.17803 7.9999C2.17803 11.2152 4.78457 13.8218 7.9999 13.8218C11.2152 13.8218 13.8218 11.2152 13.8218 7.9999C13.8218 4.78457 11.2152 2.17803 7.9999 2.17803Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, { tag: "defs", attrs: {}, children: [{ tag: "clipPath", attrs: { id: "add-attachment-single_clip0_1451_20" }, children: [{ tag: "path", attrs: { fill: "#fff", d: "M0 0H16V16H0z" } }] }] }], defIds: ["add-attachment-single_clip0_1451_20"] }, AddAttachmentSingle = forwardRef$1(function($3, t3) {
114556
+ return createElement(IconBase, Object.assign({}, $3, {
114557
+ id: "add-attachment-single",
114558
+ ref: t3,
114559
+ icon: element$3
114560
+ }));
114561
+ });
114562
+ AddAttachmentSingle.displayName = "AddAttachmentSingle";
114553
114563
  var element$2 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] }, AddImageSingle = forwardRef$1(function($3, t3) {
114554
114564
  return createElement(IconBase, Object.assign({}, $3, {
114555
114565
  id: "add-image-single",
@@ -114574,8 +114584,8 @@ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width:
114574
114584
  }));
114575
114585
  });
114576
114586
  ExportSingle.displayName = "ExportSingle";
114577
- const OperationId$2 = "custom-menu.operation.AddImageSingle", SaveDataBaseButtonOperation = ($3) => ({
114578
- id: OperationId$2,
114587
+ const OperationId$3 = "custom-menu.operation.AddImageSingle", SaveDataBaseButtonOperation = ($3) => ({
114588
+ id: OperationId$3,
114579
114589
  type: Fr$7.OPERATION,
114580
114590
  handler: async (t3) => {
114581
114591
  var S8, x8, R8, A8;
@@ -114589,10 +114599,10 @@ const OperationId$2 = "custom-menu.operation.AddImageSingle", SaveDataBaseButton
114589
114599
  return (A8 = $3 == null ? void 0 : $3.after) == null || A8.call($3, $8), !0;
114590
114600
  }
114591
114601
  });
114592
- function CustomMenuItemExportButtonFactory$1() {
114602
+ function CustomMenuItemExportButtonFactory$2() {
114593
114603
  return {
114594
114604
  // Bind the command id, clicking the button will trigger this command
114595
- id: OperationId$2,
114605
+ id: OperationId$3,
114596
114606
  // The type of the menu item, in this case, it is a button
114597
114607
  type: k1$2.BUTTON,
114598
114608
  // The icon of the button, which needs to be registered in ComponentManager
@@ -114606,7 +114616,7 @@ function CustomMenuItemExportButtonFactory$1() {
114606
114616
  const CustomSaveDatabaseMenu = ($3) => ({
114607
114617
  operation: SaveDataBaseButtonOperation($3),
114608
114618
  // shortcut: ExportShortcutItem,
114609
- menu: CustomMenuItemExportButtonFactory$1,
114619
+ menu: CustomMenuItemExportButtonFactory$2,
114610
114620
  icon: { name: "AddImageSingle", component: AddImageSingle }
114611
114621
  });
114612
114622
  let nanoid$1 = ($3 = 21) => crypto.getRandomValues(new Uint8Array($3)).reduce((t3, h3) => (h3 &= 63, h3 < 36 ? t3 += h3.toString(36) : h3 < 62 ? t3 += (h3 - 26).toString(36).toUpperCase() : h3 > 62 ? t3 += "-" : t3 += "_", t3), "");
@@ -160026,28 +160036,30 @@ const waitUserSelectExcelFile = ($3) => {
160026
160036
  console.log("error", A3), self.postMessage({ error: A3 });
160027
160037
  }
160028
160038
  });
160029
- }), OperationId$1 = "custom-menu.operation.import", ImportButtonOperation = ($3) => ({
160030
- id: OperationId$1,
160039
+ }), OperationId$2 = "custom-menu.operation.import", ImportButtonOperation = ($3) => ({
160040
+ id: OperationId$2,
160031
160041
  type: Fr$7.OPERATION,
160032
160042
  handler: async (t3) => {
160033
- var A3;
160034
- const h3 = t3.get(Vn$6), k3 = (A3 = h3.getCurrentUnitForType(Ft$6.UNIVER_SHEET)) == null ? void 0 : A3.getUnitId();
160043
+ var A3, $8, S8;
160044
+ (A3 = $3 == null ? void 0 : $3.before) == null || A3.call($3);
160045
+ const h3 = t3.get(Vn$6), k3 = ($8 = h3.getCurrentUnitForType(Ft$6.UNIVER_SHEET)) == null ? void 0 : $8.getUnitId();
160035
160046
  try {
160036
- const $8 = await getExportExcel({ onCancel: () => {
160037
- var S8;
160038
- return (S8 = $3 == null ? void 0 : $3.after) == null ? void 0 : S8.call($3, { error: { message: "取消导入" } });
160047
+ const x8 = await getExportExcel({ onCancel: () => {
160048
+ var R8;
160049
+ return (R8 = $3 == null ? void 0 : $3.after) == null ? void 0 : R8.call($3, { error: { message: "取消导入" } });
160039
160050
  } });
160040
160051
  k3 && (h3.disposeUnit(k3), h3.createUnit(Ft$6.UNIVER_SHEET, {})), setTimeout(() => {
160041
- var x8;
160042
- const S8 = h3.createUnit(Ft$6.UNIVER_SHEET, $8 || {});
160043
- (x8 = $3 == null ? void 0 : $3.after) == null || x8.call($3, { workbook: S8 });
160052
+ var A8;
160053
+ const R8 = h3.createUnit(Ft$6.UNIVER_SHEET, x8 || {});
160054
+ (A8 = $3 == null ? void 0 : $3.after) == null || A8.call($3, { workbook: R8 });
160044
160055
  }, 200);
160045
- } catch {
160056
+ } catch (x8) {
160057
+ (S8 = $3 == null ? void 0 : $3.after) == null || S8.call($3, { error: x8 });
160046
160058
  }
160047
160059
  return !0;
160048
160060
  }
160049
160061
  }), ImportShortcutItem = {
160050
- id: OperationId$1,
160062
+ id: OperationId$2,
160051
160063
  description: "shortcut.import",
160052
160064
  group: "1_common-edit",
160053
160065
  binding: T1$2.CTRL_COMMAND | T1$2.SHIFT | Re$6.I
@@ -160055,7 +160067,7 @@ const waitUserSelectExcelFile = ($3) => {
160055
160067
  function CustomMenuItemImportButtonFactory() {
160056
160068
  return {
160057
160069
  // Bind the command id, clicking the button will trigger this command
160058
- id: OperationId$1,
160070
+ id: OperationId$2,
160059
160071
  // The type of the menu item, in this case, it is a button
160060
160072
  type: k1$2.BUTTON,
160061
160073
  // The icon of the button, which needs to be registered in ComponentManager
@@ -160074,8 +160086,8 @@ const CustomImportMenu = ($3) => ({
160074
160086
  shortcut: ImportShortcutItem,
160075
160087
  menu: CustomMenuItemImportButtonFactory,
160076
160088
  icon: { name: "DownloadSingle", component: DownloadSingle }
160077
- }), OperationId = "custom-menu.operation.export", ExportButtonOperation = ($3) => ({
160078
- id: OperationId,
160089
+ }), OperationId$1 = "custom-menu.operation.export", ExportButtonOperation = ($3) => ({
160090
+ id: OperationId$1,
160079
160091
  type: Fr$7.OPERATION,
160080
160092
  handler: async (t3) => {
160081
160093
  var S8, x8, R8;
@@ -160100,15 +160112,15 @@ const CustomImportMenu = ($3) => ({
160100
160112
  }), !0;
160101
160113
  }
160102
160114
  }), ExportShortcutItem = {
160103
- id: OperationId,
160115
+ id: OperationId$1,
160104
160116
  description: "shortcut.export",
160105
160117
  group: "1_common-edit",
160106
160118
  binding: T1$2.CTRL_COMMAND | T1$2.SHIFT | Re$6.E
160107
160119
  };
160108
- function CustomMenuItemExportButtonFactory() {
160120
+ function CustomMenuItemExportButtonFactory$1() {
160109
160121
  return {
160110
160122
  // Bind the command id, clicking the button will trigger this command
160111
- id: OperationId,
160123
+ id: OperationId$1,
160112
160124
  // The type of the menu item, in this case, it is a button
160113
160125
  type: k1$2.BUTTON,
160114
160126
  // The icon of the button, which needs to be registered in ComponentManager
@@ -160122,46 +160134,39 @@ function CustomMenuItemExportButtonFactory() {
160122
160134
  const CustomExportMenu = ($3) => ({
160123
160135
  operation: ExportButtonOperation($3),
160124
160136
  shortcut: ExportShortcutItem,
160125
- menu: CustomMenuItemExportButtonFactory,
160137
+ menu: CustomMenuItemExportButtonFactory$1,
160126
160138
  icon: { name: "ExportSingle", component: ExportSingle }
160127
- }), registerPlugin = ($3, { getUniverSnapshot: t3, saveDatabase: h3 }) => {
160139
+ }), OperationId = "custom-menu.operation.AddAttachmentSingle", AddAttachmentButtonOperation = ($3) => ({
160140
+ id: OperationId,
160141
+ type: Fr$7.OPERATION,
160142
+ handler: async (t3) => {
160143
+ var k3, A3;
160144
+ const h3 = await ((k3 = $3 == null ? void 0 : $3.before) == null ? void 0 : k3.call($3));
160145
+ return $3 != null && $3.before && !h3 ? !1 : ((A3 = $3 == null ? void 0 : $3.after) == null || A3.call($3, {}), !0);
160146
+ }
160147
+ });
160148
+ function CustomMenuItemExportButtonFactory() {
160149
+ return {
160150
+ // Bind the command id, clicking the button will trigger this command
160151
+ id: OperationId,
160152
+ // The type of the menu item, in this case, it is a button
160153
+ type: k1$2.BUTTON,
160154
+ // The icon of the button, which needs to be registered in ComponentManager
160155
+ icon: "AddAttachmentSingle",
160156
+ // The tooltip of the button. Prioritize matching internationalization. If no match is found, the original string will be displayed
160157
+ tooltip: "customMenu.AddAttachmentButtonOperation",
160158
+ // The title of the button. Prioritize matching internationalization. If no match is found, the original string will be displayed
160159
+ title: "customMenu.AddAttachmentButtonOperation"
160160
+ };
160161
+ }
160162
+ const selectAttachemnt = ($3) => ({
160163
+ operation: AddAttachmentButtonOperation($3),
160164
+ menu: CustomMenuItemExportButtonFactory,
160165
+ icon: { name: "AddAttachmentSingle", component: AddAttachmentSingle }
160166
+ }), registerPlugin = ($3, { getUniverSnapshot: t3, saveDatabase: h3, addAttachment: k3 }) => {
160128
160167
  $3.registerPlugin(UniverSheetsCustomMenuPlugin, {
160129
160168
  instance: $3,
160130
160169
  menu: [
160131
- // CustomGenerateMenu({
160132
- // before: async () => {
160133
- // return true;
160134
- // // loading.value = true;
160135
- // },
160136
- // after: (data) => {
160137
- // const snapshotData = JSON.parse(JSON.stringify(data.snapshot));
160138
- // const copyData = snapshotData.sheets;
160139
- // Object.keys(copyData).forEach((item) => {
160140
- // Object.keys(copyData[item].cellData).forEach((rowIndex) => {
160141
- // Object.keys(copyData[item].cellData[rowIndex]).forEach((colIndex) => {
160142
- // const value = copyData[item].cellData[rowIndex][colIndex].v;
160143
- // if (value && typeof value === 'string') {
160144
- // copyData[item].cellData[rowIndex][colIndex].v = value.replace(/[{{|}}]/g, '');
160145
- // }
160146
- // });
160147
- // });
160148
- // });
160149
- // LuckyExcel.transformUniverToExcel({
160150
- // snapshot: snapshotData,
160151
- // fileName: '导出.xlsx',
160152
- // getBuffer: false,
160153
- // success: () => {
160154
- // // console.log('success', buffer);
160155
- // message.success('实例生成成功');
160156
- // },
160157
- // error: (error: Error) => {
160158
- // console.log('error', error);
160159
- // // config?.after?.(error);
160160
- // // self.postMessage({ error });
160161
- // },
160162
- // });
160163
- // },
160164
- // }),
160165
160170
  /**
160166
160171
  * 获取当前excel的json
160167
160172
  */
@@ -160169,15 +160174,17 @@ const CustomExportMenu = ($3) => ({
160169
160174
  before: async () => !0,
160170
160175
  after: h3
160171
160176
  }),
160177
+ selectAttachemnt({
160178
+ before: async () => !0,
160179
+ after: k3
160180
+ }),
160172
160181
  CustomImportMenu({
160173
- before: () => {
160174
- },
160175
- after: ({ error: k3 }) => {
160176
- }
160182
+ // before: addAttahment,
160183
+ // after: addAttahment,
160177
160184
  }),
160178
160185
  CustomExportMenu({
160179
160186
  snapshot: t3,
160180
- after: (k3) => {
160187
+ after: (A3) => {
160181
160188
  }
160182
160189
  })
160183
160190
  ]
@@ -284528,44 +284535,63 @@ const univerConfig = {
284528
284535
  }), t3.onDragEnd && t3.onDragEnd(k3);
284529
284536
  }
284530
284537
  });
284531
- }, OnChainUniverExcel = React__default.forwardRef(($3, t3) => {
284538
+ }, OnChainUniverExcel = forwardRef$1(($3, t3) => {
284532
284539
  const h3 = useRef();
284533
284540
  useEffect(() => {
284534
- x8();
284541
+ T8();
284535
284542
  }, []);
284536
- const k3 = async (R8) => {
284537
- const A8 = $3.onGetInitData && await $3.onGetInitData();
284538
- A8 && R8.createUnit(Ft$6.UNIVER_SHEET, A8);
284543
+ const k3 = async (M8) => {
284544
+ const N8 = $3.onGetInitData && await $3.onGetInitData();
284545
+ N8 && M8.createUnit(Ft$6.UNIVER_SHEET, N8);
284539
284546
  };
284540
284547
  function A3() {
284541
- const R8 = document.createElement("input");
284542
- R8.type = "file", R8.accept = "image/*", R8.onchange = async (A8) => {
284543
- const I8 = A8.target.files[0];
284544
- if (!I8) return;
284545
- const T8 = new FileReader();
284546
- T8.onload = async function(M8) {
284547
- var W8;
284548
- const N8 = M8.target.result, O8 = (W8 = h3.current) == null ? void 0 : W8.getActiveWorkbook(), V8 = O8 == null ? void 0 : O8.getActiveSheet().getActiveCell();
284549
- V8 == null || V8.insertCellImageAsync(N8);
284550
- }, T8.readAsDataURL(I8);
284551
- }, R8.click();
284552
- }
284553
- const $8 = (R8) => {
284554
- A3();
284555
- }, S8 = () => {
284556
- var A8;
284557
- const R8 = (A8 = h3.current) == null ? void 0 : A8.getActiveWorkbook();
284558
- if (!R8)
284548
+ var O8;
284549
+ const M8 = (O8 = h3.current) == null ? void 0 : O8.getActiveWorkbook();
284550
+ return M8 == null ? void 0 : M8.getActiveSheet().getActiveCell();
284551
+ }
284552
+ function $8() {
284553
+ const M8 = document.createElement("input");
284554
+ M8.type = "file", M8.accept = "image/*", M8.onchange = async (N8) => {
284555
+ const O8 = N8.target.files[0];
284556
+ if (!O8) return;
284557
+ const V8 = new FileReader();
284558
+ V8.onload = async function(W8) {
284559
+ const X8 = W8.target.result, G8 = A3();
284560
+ G8 == null || G8.insertCellImageAsync(X8), G8 == null || G8.setVerticalAlignment("middle"), G8 == null || G8.setHorizontalAlignment("center");
284561
+ }, V8.readAsDataURL(O8);
284562
+ }, M8.click();
284563
+ }
284564
+ function S8(M8) {
284565
+ const N8 = A3();
284566
+ N8 == null || N8.insertCellImageAsync(M8), N8 == null || N8.setVerticalAlignment("middle"), N8 == null || N8.setHorizontalAlignment("center");
284567
+ }
284568
+ function x8(M8, N8) {
284569
+ N8 == null || N8.setVerticalAlignment("middle"), N8 == null || N8.setHorizontalAlignment("center"), N8 == null || N8.setValue(M8);
284570
+ }
284571
+ const R8 = (M8) => {
284572
+ $8();
284573
+ }, A8 = () => {
284574
+ var N8;
284575
+ const M8 = (N8 = h3.current) == null ? void 0 : N8.getActiveWorkbook();
284576
+ if (!M8)
284559
284577
  throw new Error("Workbook is not initialized");
284560
- return R8.save();
284561
- }, x8 = () => {
284562
- const { univerAPI: R8, univer: A8 } = x$2(univerConfig);
284563
- registerPlugin(A8, { saveDatabase: $8, getUniverSnapshot: S8 }), h3.current = R8, A8.createUnit(Ft$6.UNIVER_SHEET, {}), registerEvent(R8, {
284578
+ return M8.save();
284579
+ }, I8 = () => {
284580
+ var M8;
284581
+ (M8 = $3.attachment) == null || M8.onChangeVisible(!0);
284582
+ }, T8 = () => {
284583
+ const { univerAPI: M8, univer: N8 } = x$2(univerConfig);
284584
+ registerPlugin(N8, { saveDatabase: R8, getUniverSnapshot: A8, addAttachment: I8 }), h3.current = M8, N8.createUnit(Ft$6.UNIVER_SHEET, {}), registerEvent(M8, {
284564
284585
  data: $3.dragDataRef,
284565
284586
  onDragEnd: $3.onDragEnd
284566
- }), k3(A8);
284587
+ }), k3(N8);
284567
284588
  };
284568
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: "app", style: { height: "100%", width: "100%" } });
284589
+ return useImperativeHandle(t3, () => ({
284590
+ univerAPI: h3.current,
284591
+ insertImageToActiveCell: S8,
284592
+ getActiveCell: A3,
284593
+ setCellValueToRange: x8
284594
+ })), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: "app", style: { height: "100%", width: "100%" } });
284569
284595
  });
284570
284596
  export {
284571
284597
  OnChainUniverExcel as default,