@leankylin-sheet/react 5.2.52 → 5.2.54

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.
@@ -6,6 +6,10 @@ type Props = {
6
6
  onCancel?: () => void;
7
7
  containerStyle?: React.CSSProperties;
8
8
  contentStyle?: React.CSSProperties;
9
+ title?: string;
10
+ iconType?: "warning" | "info";
11
+ confirmText?: string;
12
+ danger?: boolean;
9
13
  children?: React.ReactNode;
10
14
  };
11
15
  declare const Dialog: React.FC<Props>;
@@ -3,6 +3,10 @@ type Props = {
3
3
  type: "ok" | "yesno";
4
4
  onOk?: () => void;
5
5
  onCancel?: () => void;
6
+ title?: string;
7
+ iconType?: "warning" | "info";
8
+ confirmText?: string;
9
+ danger?: boolean;
6
10
  children?: React.ReactNode;
7
11
  };
8
12
  declare const MessageBox: React.FC<Props>;
@@ -1,4 +1,12 @@
1
+ import React from "react";
2
+ type AlertOptions = {
3
+ title?: string;
4
+ icon?: "warning" | "info";
5
+ confirmText?: string;
6
+ danger?: boolean;
7
+ };
1
8
  export declare function useAlert(): {
2
- showAlert: (message: string, type?: "ok" | "yesno", onOk?: () => void, onCancel?: () => void) => void;
9
+ showAlert: (message: React.ReactNode, type?: "ok" | "yesno", onOk?: () => void, onCancel?: () => void, options?: AlertOptions) => void;
3
10
  hideAlert: () => void;
4
11
  };
12
+ export {};
package/dist/index.css CHANGED
@@ -1205,10 +1205,9 @@ html::-webkit-scrollbar-button {
1205
1205
  .leankylin-dialog {
1206
1206
  max-width: 90%;
1207
1207
  max-height: 90%;
1208
- overflow: scroll;
1209
- border-radius: 6px;
1208
+ border-radius: 8px;
1210
1209
  background: white;
1211
- box-shadow: rgb(0 0 0 / 10%) 5px 5px 30px;
1210
+ box-shadow: 0 2px 12px rgb(0 0 0 / 15%);
1212
1211
  box-sizing: border-box;
1213
1212
  overflow: auto;
1214
1213
  }
@@ -1217,55 +1216,127 @@ html::-webkit-scrollbar-button {
1217
1216
  display: flex;
1218
1217
  align-items: center;
1219
1218
  justify-content: center;
1219
+ padding-top: 12px;
1220
+ padding-bottom: 20px;
1220
1221
  }
1221
1222
 
1222
1223
  .leankylin-dialog-box-content {
1223
1224
  padding: 0px 25px;
1224
1225
  }
1225
1226
 
1226
- .leankylin-dialog-box-button-container {
1227
- padding-top: 10px;
1228
- padding-bottom: 20px;
1229
- }
1230
-
1231
1227
  .leankylin-message-box-button {
1232
1228
  display: inline-flex;
1233
1229
  align-items: center;
1234
- padding: 6px 12px;
1235
- margin: 0 8px;
1230
+ padding: 6px 14px;
1231
+ margin: 0 6px;
1236
1232
  border: none;
1237
1233
  border-radius: 4px;
1238
1234
  font-size: 14px;
1239
1235
  line-height: 20px;
1240
1236
  outline: none;
1241
1237
  cursor: pointer;
1238
+ -webkit-user-select: none;
1239
+ -moz-user-select: none;
1240
+ user-select: none;
1242
1241
  }
1243
1242
 
1244
1243
  .leankylin-message-box-button.button-default {
1245
- color: rgb(38, 42, 51);
1246
- background-color: rgb(255, 255, 255);
1247
- border: 1px solid rgb(235, 235, 235);
1244
+ color: #333333;
1245
+ background-color: #ffffff;
1246
+ border: 1px solid #dddddd;
1247
+ }
1248
+
1249
+ .leankylin-message-box-button.button-default:hover {
1250
+ background-color: #f5f5f5;
1248
1251
  }
1249
1252
 
1250
1253
  .leankylin-message-box-button.button-primary {
1251
1254
  color: white;
1252
- background-color: #0188FB;
1255
+ background-color: #0188fb;
1256
+ }
1257
+
1258
+ .leankylin-message-box-button.button-primary:hover {
1259
+ background-color: #1677ff;
1260
+ }
1261
+
1262
+ .leankylin-message-box-button.button-danger {
1263
+ color: white;
1264
+ border: none;
1265
+ outline: none;
1266
+ background-color: #fa541c;
1267
+ }
1268
+
1269
+ .leankylin-message-box-button.button-danger:hover {
1270
+ background-color: #ff7a45;
1271
+ }
1272
+
1273
+ .leankylin-message-box-button.button-danger:focus-visible {
1274
+ outline: none;
1253
1275
  }
1254
1276
 
1255
1277
  .leankylin-modal-dialog-header {
1278
+ position: relative;
1256
1279
  outline: 0;
1257
1280
  display: flex;
1258
1281
  justify-content: flex-end;
1282
+ padding: 4px 4px 0;
1283
+ }
1284
+
1285
+ .leankylin-modal-dialog-title {
1286
+ position: absolute;
1287
+ left: 50%;
1288
+ top: 50%;
1289
+ transform: translate(-50%, -50%);
1290
+ font-size: 15px;
1291
+ font-weight: 600;
1292
+ color: #1f2329;
1293
+ white-space: nowrap;
1259
1294
  }
1260
1295
 
1261
1296
  .leankylin-modal-dialog-icon-close {
1262
- color: #d4d4d4;
1263
- opacity: 0.3;
1297
+ color: #999999;
1298
+ opacity: 0.5;
1299
+ display: flex;
1300
+ align-items: center;
1264
1301
  }
1265
1302
 
1266
1303
  .leankylin-modal-dialog-icon-close:hover {
1267
- opacity: 0.7;
1304
+ opacity: 1;
1305
+ }
1306
+
1307
+ .leankylin-dialog-icon {
1308
+ display: flex;
1309
+ align-items: center;
1310
+ justify-content: center;
1311
+ margin-bottom: 8px;
1268
1312
  }
1313
+
1314
+ .leankylin-dialog-icon-warning,
1315
+ .leankylin-dialog-icon-info {
1316
+ display: flex;
1317
+ align-items: center;
1318
+ justify-content: center;
1319
+ width: 40px;
1320
+ height: 40px;
1321
+ border-radius: 50%;
1322
+ }
1323
+
1324
+ .leankylin-dialog-icon-warning {
1325
+ background: #fff1e8;
1326
+ color: #fa541c;
1327
+ }
1328
+
1329
+ .leankylin-dialog-icon-info {
1330
+ background: #e6f4ff;
1331
+ color: #0188fb;
1332
+ }
1333
+
1334
+ .leankylin-dialog-tip {
1335
+ font-size: 12px;
1336
+ color: #8f959e;
1337
+ line-height: 18px;
1338
+ }
1339
+
1269
1340
  /* 查找替换弹出框样式 */
1270
1341
  #leankylin-search-replace {
1271
1342
  position: absolute;
@@ -1205,10 +1205,9 @@ html::-webkit-scrollbar-button {
1205
1205
  .leankylin-dialog {
1206
1206
  max-width: 90%;
1207
1207
  max-height: 90%;
1208
- overflow: scroll;
1209
- border-radius: 6px;
1208
+ border-radius: 8px;
1210
1209
  background: white;
1211
- box-shadow: rgb(0 0 0 / 10%) 5px 5px 30px;
1210
+ box-shadow: 0 2px 12px rgb(0 0 0 / 15%);
1212
1211
  box-sizing: border-box;
1213
1212
  overflow: auto;
1214
1213
  }
@@ -1217,55 +1216,127 @@ html::-webkit-scrollbar-button {
1217
1216
  display: flex;
1218
1217
  align-items: center;
1219
1218
  justify-content: center;
1219
+ padding-top: 12px;
1220
+ padding-bottom: 20px;
1220
1221
  }
1221
1222
 
1222
1223
  .leankylin-dialog-box-content {
1223
1224
  padding: 0px 25px;
1224
1225
  }
1225
1226
 
1226
- .leankylin-dialog-box-button-container {
1227
- padding-top: 10px;
1228
- padding-bottom: 20px;
1229
- }
1230
-
1231
1227
  .leankylin-message-box-button {
1232
1228
  display: inline-flex;
1233
1229
  align-items: center;
1234
- padding: 6px 12px;
1235
- margin: 0 8px;
1230
+ padding: 6px 14px;
1231
+ margin: 0 6px;
1236
1232
  border: none;
1237
1233
  border-radius: 4px;
1238
1234
  font-size: 14px;
1239
1235
  line-height: 20px;
1240
1236
  outline: none;
1241
1237
  cursor: pointer;
1238
+ -webkit-user-select: none;
1239
+ -moz-user-select: none;
1240
+ user-select: none;
1242
1241
  }
1243
1242
 
1244
1243
  .leankylin-message-box-button.button-default {
1245
- color: rgb(38, 42, 51);
1246
- background-color: rgb(255, 255, 255);
1247
- border: 1px solid rgb(235, 235, 235);
1244
+ color: #333333;
1245
+ background-color: #ffffff;
1246
+ border: 1px solid #dddddd;
1247
+ }
1248
+
1249
+ .leankylin-message-box-button.button-default:hover {
1250
+ background-color: #f5f5f5;
1248
1251
  }
1249
1252
 
1250
1253
  .leankylin-message-box-button.button-primary {
1251
1254
  color: white;
1252
- background-color: #0188FB;
1255
+ background-color: #0188fb;
1256
+ }
1257
+
1258
+ .leankylin-message-box-button.button-primary:hover {
1259
+ background-color: #1677ff;
1260
+ }
1261
+
1262
+ .leankylin-message-box-button.button-danger {
1263
+ color: white;
1264
+ border: none;
1265
+ outline: none;
1266
+ background-color: #fa541c;
1267
+ }
1268
+
1269
+ .leankylin-message-box-button.button-danger:hover {
1270
+ background-color: #ff7a45;
1271
+ }
1272
+
1273
+ .leankylin-message-box-button.button-danger:focus-visible {
1274
+ outline: none;
1253
1275
  }
1254
1276
 
1255
1277
  .leankylin-modal-dialog-header {
1278
+ position: relative;
1256
1279
  outline: 0;
1257
1280
  display: flex;
1258
1281
  justify-content: flex-end;
1282
+ padding: 4px 4px 0;
1283
+ }
1284
+
1285
+ .leankylin-modal-dialog-title {
1286
+ position: absolute;
1287
+ left: 50%;
1288
+ top: 50%;
1289
+ transform: translate(-50%, -50%);
1290
+ font-size: 15px;
1291
+ font-weight: 600;
1292
+ color: #1f2329;
1293
+ white-space: nowrap;
1259
1294
  }
1260
1295
 
1261
1296
  .leankylin-modal-dialog-icon-close {
1262
- color: #d4d4d4;
1263
- opacity: 0.3;
1297
+ color: #999999;
1298
+ opacity: 0.5;
1299
+ display: flex;
1300
+ align-items: center;
1264
1301
  }
1265
1302
 
1266
1303
  .leankylin-modal-dialog-icon-close:hover {
1267
- opacity: 0.7;
1304
+ opacity: 1;
1305
+ }
1306
+
1307
+ .leankylin-dialog-icon {
1308
+ display: flex;
1309
+ align-items: center;
1310
+ justify-content: center;
1311
+ margin-bottom: 8px;
1268
1312
  }
1313
+
1314
+ .leankylin-dialog-icon-warning,
1315
+ .leankylin-dialog-icon-info {
1316
+ display: flex;
1317
+ align-items: center;
1318
+ justify-content: center;
1319
+ width: 40px;
1320
+ height: 40px;
1321
+ border-radius: 50%;
1322
+ }
1323
+
1324
+ .leankylin-dialog-icon-warning {
1325
+ background: #fff1e8;
1326
+ color: #fa541c;
1327
+ }
1328
+
1329
+ .leankylin-dialog-icon-info {
1330
+ background: #e6f4ff;
1331
+ color: #0188fb;
1332
+ }
1333
+
1334
+ .leankylin-dialog-tip {
1335
+ font-size: 12px;
1336
+ color: #8f959e;
1337
+ line-height: 18px;
1338
+ }
1339
+
1269
1340
  /* 查找替换弹出框样式 */
1270
1341
  #leankylin-search-replace {
1271
1342
  position: absolute;
package/dist/index.esm.js CHANGED
@@ -1398,17 +1398,24 @@ var Dialog = function Dialog(_ref) {
1398
1398
  onCancel = _ref.onCancel,
1399
1399
  children = _ref.children,
1400
1400
  containerStyle = _ref.containerStyle,
1401
- contentStyle = _ref.contentStyle;
1401
+ contentStyle = _ref.contentStyle,
1402
+ title = _ref.title,
1403
+ iconType = _ref.iconType,
1404
+ confirmText = _ref.confirmText,
1405
+ danger = _ref.danger;
1402
1406
  var _useContext = useContext(WorkbookContext),
1403
1407
  context = _useContext.context;
1404
1408
  var _locale = locale(context),
1405
1409
  button = _locale.button;
1410
+ var confirmBtnClass = ["leankylin-message-box-button", danger ? "button-danger" : type === "ok" ? "button-default" : "button-primary"].filter(Boolean).join(" ");
1406
1411
  return /*#__PURE__*/React.createElement("div", {
1407
1412
  className: "leankylin-dialog",
1408
1413
  style: containerStyle
1409
1414
  }, /*#__PURE__*/React.createElement("div", {
1410
1415
  className: "leankylin-modal-dialog-header"
1411
- }, /*#__PURE__*/React.createElement("div", {
1416
+ }, title && /*#__PURE__*/React.createElement("div", {
1417
+ className: "leankylin-modal-dialog-title"
1418
+ }, title), /*#__PURE__*/React.createElement("div", {
1412
1419
  className: "leankylin-modal-dialog-icon-close",
1413
1420
  onClick: onCancel
1414
1421
  }, /*#__PURE__*/React.createElement(SVGIcon, {
@@ -1420,18 +1427,63 @@ var Dialog = function Dialog(_ref) {
1420
1427
  }))), /*#__PURE__*/React.createElement("div", {
1421
1428
  className: "leankylin-dialog-box-content",
1422
1429
  style: contentStyle
1423
- }, children), type != null && ( /*#__PURE__*/React.createElement("div", {
1430
+ }, iconType === "warning" && ( /*#__PURE__*/React.createElement("div", {
1431
+ className: "leankylin-dialog-icon"
1432
+ }, /*#__PURE__*/React.createElement("div", {
1433
+ className: "leankylin-dialog-icon-warning"
1434
+ }, /*#__PURE__*/React.createElement("svg", {
1435
+ width: "22",
1436
+ height: "22",
1437
+ viewBox: "0 0 24 24",
1438
+ fill: "none",
1439
+ xmlns: "http://www.w3.org/2000/svg"
1440
+ }, /*#__PURE__*/React.createElement("path", {
1441
+ d: "M12 2.5 22.5 21H1.5L12 2.5Z",
1442
+ fill: "currentColor"
1443
+ }), /*#__PURE__*/React.createElement("path", {
1444
+ d: "M12 9.5v5",
1445
+ stroke: "white",
1446
+ strokeWidth: "2",
1447
+ strokeLinecap: "round"
1448
+ }), /*#__PURE__*/React.createElement("circle", {
1449
+ cx: "12",
1450
+ cy: "17.6",
1451
+ r: "1.3",
1452
+ fill: "white"
1453
+ }))))), iconType === "info" && ( /*#__PURE__*/React.createElement("div", {
1454
+ className: "leankylin-dialog-icon"
1455
+ }, /*#__PURE__*/React.createElement("div", {
1456
+ className: "leankylin-dialog-icon-info"
1457
+ }, /*#__PURE__*/React.createElement("svg", {
1458
+ width: "22",
1459
+ height: "22",
1460
+ viewBox: "0 0 24 24",
1461
+ fill: "none",
1462
+ xmlns: "http://www.w3.org/2000/svg"
1463
+ }, /*#__PURE__*/React.createElement("circle", {
1464
+ cx: "12",
1465
+ cy: "12",
1466
+ r: "9.5",
1467
+ fill: "currentColor"
1468
+ }), /*#__PURE__*/React.createElement("path", {
1469
+ d: "M12 11v5.5",
1470
+ stroke: "white",
1471
+ strokeWidth: "2",
1472
+ strokeLinecap: "round"
1473
+ }), /*#__PURE__*/React.createElement("circle", {
1474
+ cx: "12",
1475
+ cy: "7.4",
1476
+ r: "1.3",
1477
+ fill: "white"
1478
+ }))))), children), type != null && ( /*#__PURE__*/React.createElement("div", {
1424
1479
  className: "leankylin-dialog-box-button-container"
1425
- }, type === "ok" ? ( /*#__PURE__*/React.createElement("div", {
1426
- className: "leankylin-message-box-button button-default",
1427
- onClick: onOk
1428
- }, button.confirm)) : ( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1429
- className: "leankylin-message-box-button button-primary",
1480
+ }, /*#__PURE__*/React.createElement("div", {
1481
+ className: confirmBtnClass,
1430
1482
  onClick: onOk
1431
- }, button.confirm), /*#__PURE__*/React.createElement("div", {
1483
+ }, confirmText || button.confirm), type === "yesno" && ( /*#__PURE__*/React.createElement("div", {
1432
1484
  className: "leankylin-message-box-button button-default",
1433
1485
  onClick: onCancel
1434
- }, button.cancel))))));
1486
+ }, button.cancel)))));
1435
1487
  };
1436
1488
 
1437
1489
  var MessageBox = function MessageBox(_ref) {
@@ -1439,18 +1491,28 @@ var MessageBox = function MessageBox(_ref) {
1439
1491
  type = _ref$type === void 0 ? "yesno" : _ref$type,
1440
1492
  onOk = _ref.onOk,
1441
1493
  onCancel = _ref.onCancel,
1494
+ title = _ref.title,
1495
+ iconType = _ref.iconType,
1496
+ confirmText = _ref.confirmText,
1497
+ danger = _ref.danger,
1442
1498
  children = _ref.children;
1443
1499
  return /*#__PURE__*/React.createElement(Dialog, {
1444
1500
  type: type,
1445
1501
  onOk: onOk,
1446
1502
  onCancel: onCancel,
1503
+ title: title,
1504
+ iconType: iconType,
1505
+ confirmText: confirmText,
1506
+ danger: danger,
1447
1507
  contentStyle: {
1448
- width: 300,
1449
- paddingTop: 20,
1450
- paddingBottom: 30,
1508
+ width: 280,
1509
+ paddingTop: 12,
1510
+ paddingBottom: 20,
1451
1511
  display: "flex",
1512
+ flexDirection: "column",
1452
1513
  justifyContent: "center",
1453
- alignItems: "center"
1514
+ alignItems: "center",
1515
+ gap: 4
1454
1516
  }
1455
1517
  }, children);
1456
1518
  };
@@ -1506,10 +1568,15 @@ function useAlert() {
1506
1568
  var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ok";
1507
1569
  var onOk = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : hideModal;
1508
1570
  var onCancel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : hideModal;
1571
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
1509
1572
  showModal( /*#__PURE__*/React.createElement(MessageBox, {
1510
1573
  type: type,
1511
1574
  onOk: onOk,
1512
- onCancel: onCancel
1575
+ onCancel: onCancel,
1576
+ title: options.title,
1577
+ iconType: options.icon,
1578
+ confirmText: options.confirmText,
1579
+ danger: options.danger
1513
1580
  }, message));
1514
1581
  }, [hideModal, showModal]);
1515
1582
  return {
@@ -7787,9 +7854,9 @@ var SheetTab = function SheetTab() {
7787
7854
  id: "luckysheet-sheet-area"
7788
7855
  }, /*#__PURE__*/React.createElement("div", {
7789
7856
  id: "luckysheet-sheet-content"
7790
- }, context.allowEdit && ( /*#__PURE__*/React.createElement("div", {
7857
+ }, context.allowEdit && context.showAddSheetButton && ( /*#__PURE__*/React.createElement("div", {
7791
7858
  className: "leankylin-sheettab-button",
7792
- onClick: onAddSheetClick
7859
+ onClick: context.onAddSheetClick || onAddSheetClick
7793
7860
  }, /*#__PURE__*/React.createElement(SVGIcon, {
7794
7861
  name: "plus",
7795
7862
  width: 16,
@@ -10154,7 +10221,7 @@ var SheetTabContextMenu = function SheetTabContextMenu() {
10154
10221
  return _.isUndefined(singleSheet.hide) || singleSheet.hide !== 1;
10155
10222
  });
10156
10223
  if (context.luckysheetfile.length > 1 && shownSheets.length > 1) {
10157
- showAlert(sheetconfig.confirmDelete, "yesno", function () {
10224
+ showAlert("".concat(sheetconfig.confirmDelete, "\"").concat(sheet.name, "\"\uFF1F"), "yesno", function () {
10158
10225
  setContext(function (ctx) {
10159
10226
  deleteSheet(ctx, sheet.id);
10160
10227
  }, {
@@ -10163,6 +10230,9 @@ var SheetTabContextMenu = function SheetTabContextMenu() {
10163
10230
  }
10164
10231
  });
10165
10232
  hideAlert();
10233
+ }, undefined, {
10234
+ confirmText: sheetconfig.delete,
10235
+ danger: true
10166
10236
  });
10167
10237
  } else {
10168
10238
  showAlert(sheetconfig.noMoreSheet, "ok");
@@ -11638,6 +11708,10 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
11638
11708
  }
11639
11709
  draftCtx.lang = mergedSettings.lang;
11640
11710
  draftCtx.allowEdit = mergedSettings.allowEdit;
11711
+ draftCtx.showAddSheetButton = mergedSettings.showAddSheetButton;
11712
+ draftCtx.onAddSheetClick = mergedSettings.onAddSheetClick;
11713
+ draftCtx.onSheetRename = mergedSettings.onSheetRename;
11714
+ draftCtx.onSheetDelete = mergedSettings.onSheetDelete;
11641
11715
  draftCtx.hooks = mergedSettings.hooks;
11642
11716
  if (_.isEmpty(draftCtx.currentSheetId)) {
11643
11717
  initSheetIndex(draftCtx);
@@ -11715,7 +11789,7 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
11715
11789
  }, {
11716
11790
  noHistory: true
11717
11791
  });
11718
- }, [context.currentSheetId, context.luckysheetfile.length, originalData, mergedSettings.defaultRowHeight, mergedSettings.defaultColWidth, mergedSettings.column, mergedSettings.row, mergedSettings.defaultFontSize, mergedSettings.devicePixelRatio, mergedSettings.lang, mergedSettings.allowEdit, mergedSettings.hooks, mergedSettings.generateSheetId, setContextWithProduce, initSheetData, mergedSettings.rowHeaderWidth, mergedSettings.columnHeaderHeight, mergedSettings.addRows]);
11792
+ }, [context.currentSheetId, context.luckysheetfile.length, originalData, mergedSettings.defaultRowHeight, mergedSettings.defaultColWidth, mergedSettings.column, mergedSettings.row, mergedSettings.defaultFontSize, mergedSettings.devicePixelRatio, mergedSettings.lang, mergedSettings.allowEdit, mergedSettings.showAddSheetButton, mergedSettings.onAddSheetClick, mergedSettings.onSheetRename, mergedSettings.onSheetDelete, mergedSettings.hooks, mergedSettings.generateSheetId, setContextWithProduce, initSheetData, mergedSettings.rowHeaderWidth, mergedSettings.columnHeaderHeight, mergedSettings.addRows]);
11719
11793
  var onKeyDown = useCallback(function (e) {
11720
11794
  var nativeEvent = e.nativeEvent;
11721
11795
  if ((e.ctrlKey || e.metaKey) && mergedSettings.disabledKeyboardCodes.includes(e.code)) {