gridjs-spreadsheet 26.4.5 → 26.5.1

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/example/pom.xml CHANGED
@@ -17,7 +17,7 @@
17
17
  </repositories>
18
18
  <groupId>com.aspose.gridjs</groupId>
19
19
  <artifactId>gridjsdemo</artifactId>
20
- <version>26.4</version>
20
+ <version>26.5</version>
21
21
  <name>gridjsdemo</name>
22
22
  <description>GridJs Demo project for Spring Boot</description>
23
23
  <properties>
@@ -51,12 +51,12 @@
51
51
  <dependency>
52
52
  <groupId>com.aspose</groupId>
53
53
  <artifactId>aspose-cells</artifactId>
54
- <version>26.4</version>
54
+ <version>26.5</version>
55
55
  </dependency>
56
56
  <dependency>
57
57
  <groupId>com.aspose</groupId>
58
58
  <artifactId>aspose-cells</artifactId>
59
- <version>26.4</version>
59
+ <version>26.5</version>
60
60
  <classifier>gridjs</classifier>
61
61
  </dependency>
62
62
  <!-- <dependency>
package/index.d.ts CHANGED
@@ -41,6 +41,11 @@ declare module 'gridjs-spreadsheet' {
41
41
  redactionReasons?: string[];
42
42
  /** Default redaction color */
43
43
  redactionDefaultColor?: string;
44
+ /**
45
+ * Custom toolbar buttons injected before the "more" dropdown.
46
+ * Each item defines a tag, tooltip, icon, and onClick handler.
47
+ */
48
+ customToolbarButtons?: CustomToolbarButtonConfig[];
44
49
  /**
45
50
  * Custom callback for adding new redaction reason.
46
51
  * If provided, replaces the default modal dialog.
@@ -72,6 +77,7 @@ declare module 'gridjs-spreadsheet' {
72
77
  export type REDACTION_REASON_INSERTED = 'redactionReason-inserted';
73
78
  export type REDACTION_REASON_CLEARED = 'redactionReason-cleared';
74
79
  export type REDACTION_TRANSPARENCY_TOGGLED = 'redactionTransparency-toggled';
80
+ export type CUSTOM_BUTTON = 'custom-button';
75
81
  export type UPDATE_SERVER_ERROR = 'updateServerError';
76
82
  export type UPDATE_CELL_ERROR = 'updateCellError';
77
83
 
@@ -84,6 +90,64 @@ declare module 'gridjs-spreadsheet' {
84
90
  eci: number;
85
91
  }
86
92
 
93
+ /** Icon descriptor for a custom toolbar button (choose one form) */
94
+ export interface CustomToolbarButtonIcon {
95
+ /** Image URL used as background-image */
96
+ url?: string;
97
+ /** CSS class applied to the inner icon element (user supplies CSS) */
98
+ className?: string;
99
+ /** Raw HTML fragment, e.g. inline <svg>...</svg> */
100
+ html?: string;
101
+ /** Plain text / emoji, e.g. '��' */
102
+ text?: string;
103
+ /** Width in px when using `url` (default: 16) */
104
+ width?: number;
105
+ /** Height in px when using `url` (default: 16) */
106
+ height?: number;
107
+ }
108
+
109
+ /** Runtime instance of a custom toolbar button (passed to onClick and `custom-button` event) */
110
+ export interface CustomToolbarButton {
111
+ /** Unique tag identifier */
112
+ tag: string;
113
+ /** Tooltip text */
114
+ tip: string;
115
+ /** Reference to the owning Spreadsheet instance (injected by Toolbar) */
116
+ spreadsheet: Spreadsheet;
117
+ /** Original config passed in via Options.customToolbarButtons */
118
+ config: CustomToolbarButtonConfig;
119
+ /** Update the icon at runtime */
120
+ setIcon(iconConfig: CustomToolbarButtonIcon): void;
121
+ /** Update the tooltip text at runtime */
122
+ setTooltip(text: string): void;
123
+ /** Toggle active (highlighted) state */
124
+ setActive(active: boolean): void;
125
+ /** Toggle disabled state (click events suppressed) */
126
+ setDisabled(disabled: boolean): void;
127
+ /** Show the button */
128
+ show(): void;
129
+ /** Hide the button */
130
+ hide(): void;
131
+ }
132
+
133
+ /** Configuration for a single custom toolbar button */
134
+ export interface CustomToolbarButtonConfig {
135
+ /** Unique identifier; forwarded as the second argument of the `custom-button` change event */
136
+ tag: string;
137
+ /** Tooltip shown on hover */
138
+ tooltip?: string;
139
+ /** Icon descriptor (url / className / html / text) */
140
+ icon?: CustomToolbarButtonIcon;
141
+ /** Click handler; `button` is the CustomToolbarButton instance, `spreadsheet` is the Spreadsheet instance */
142
+ onClick?: (button: CustomToolbarButton, spreadsheet: Spreadsheet) => void;
143
+ /** Initial active state */
144
+ active?: boolean;
145
+ /** Initial disabled state */
146
+ disabled?: boolean;
147
+ /** Optional fixed button width in px */
148
+ width?: number;
149
+ }
150
+
87
151
  export interface RedactionData {
88
152
  id: string;
89
153
  originId?: string;
@@ -189,6 +253,10 @@ declare module 'gridjs-spreadsheet' {
189
253
  envt: REDACTION_TRANSPARENCY_TOGGLED,
190
254
  callback: (isTransparent: boolean) => void
191
255
  ): void;
256
+ (
257
+ envt: CUSTOM_BUTTON,
258
+ callback: (tag: string, button: CustomToolbarButton) => void
259
+ ): void;
192
260
  (
193
261
  envt: UPDATE_SERVER_ERROR,
194
262
  callback: (...args: any[]) => void
@@ -270,6 +338,8 @@ declare module 'gridjs-spreadsheet' {
270
338
 
271
339
  export default class Spreadsheet {
272
340
  constructor(container: string | HTMLElement, opts?: Options);
341
+ /** Build version string (injected at compile time) */
342
+ readonly version: string;
273
343
  on: SpreadsheetEventHandler;
274
344
  /**
275
345
  * retrieve cell
@@ -307,6 +377,50 @@ declare module 'gridjs-spreadsheet' {
307
377
  */
308
378
  deleteSheet(): void;
309
379
 
380
+ /**
381
+ * insert a redaction shape on a target shape/image
382
+ * @param reason redaction reason text
383
+ * @param color background color
384
+ * @param targetId target shape/image id
385
+ * @param sheetName sheet name, defaults to active sheet
386
+ */
387
+ insertRedactionForShape(reason: string, color: string, targetId: string, sheetName?: string): Promise<void>;
388
+
389
+ /**
390
+ * insert a redaction on a cell range
391
+ * @param reason redaction reason text
392
+ * @param color background color
393
+ * @param range cell range {sri, sci, eri, eci}
394
+ * @param sheetName sheet name, defaults to active sheet
395
+ */
396
+ insertRedactionForRange(reason: string, color: string, range: CellRange, sheetName?: string): Promise<void>;
397
+
398
+ /**
399
+ * remove a redaction by id
400
+ * @param id redaction id
401
+ * @param sheetName sheet name, defaults to active sheet
402
+ */
403
+ removeRedaction(id: string, sheetName?: string): Promise<void>;
404
+
405
+ /**
406
+ * sync redaction operations from history records
407
+ * @param historyOprArray array of operation history records
408
+ * @param isSyncToServer whether to sync to server
409
+ */
410
+ syncRedactionOprClient(historyOprArray: any[], isSyncToServer?: boolean): Promise<void>;
411
+
412
+ /**
413
+ * burn all redactions permanently
414
+ */
415
+ burnAllRedactions(): void;
416
+
417
+ /**
418
+ * clear all redaction shapes on a sheet or sheets array
419
+ * @param sheetNameOrArray sheet name, array of sheet names, or null for active sheet
420
+ * @param isSyncToServer whether to sync to server
421
+ */
422
+ clearRedactionClient(sheetNameOrArray?: string | string[] | null, isSyncToServer?: boolean): Promise<void>;
423
+
310
424
  /**
311
425
  * load data
312
426
  * @param json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gridjs-spreadsheet",
3
- "version": "26.4.5",
3
+ "version": "26.5.1",
4
4
  "description": "this is the client side script for GridJs which is a lightweight, scalable, and customizable toolkit that provides cross-platform web applications, enables convenient development for editing or viewing Excel/Spreadsheet files, offers simple deployment, and provides easy-to-use APIs based on JSON format.",
5
5
  "types": "index.d.ts",
6
6
  "main": "xspreadsheet.js",
package/readme.md CHANGED
@@ -399,6 +399,14 @@ v26.4.3:
399
399
 
400
400
  - Add boundary check for redaction
401
401
 
402
+ v26.5:
403
+
404
+ - Support add custom buttons in toolbar
405
+
406
+ v26.5:
407
+
408
+ - Improve date picker
409
+
402
410
  ## License
403
411
 
404
412
  MIT
package/xspreadsheet.css CHANGED
@@ -405,26 +405,102 @@ body {
405
405
  background-color: #f4f5f8;
406
406
  opacity: 0.9;
407
407
  z-index: 12;
408
+ display: flex;
409
+ }
410
+ .x-spreadsheet-scrollbar .x-spreadsheet-scrollbar-track {
411
+ flex: 1 1 auto;
412
+ align-self: center;
413
+ min-width: 0;
414
+ min-height: 0;
415
+ }
416
+ .x-spreadsheet-scrollbar .x-spreadsheet-scrollbar-content {
417
+ background: #ddd;
418
+ }
419
+ .x-spreadsheet-scrollbar .x-spreadsheet-scrollbar-button {
420
+ position: relative;
421
+ box-sizing: border-box;
422
+ flex: 0 0 15px;
423
+ width: 15px;
424
+ height: 15px;
425
+ margin: 0;
426
+ padding: 0;
427
+ border: 1px solid #c7ccd6;
428
+ background: #eef1f6;
429
+ cursor: default;
430
+ outline: none;
431
+ }
432
+ .x-spreadsheet-scrollbar .x-spreadsheet-scrollbar-button::before {
433
+ content: '';
434
+ position: absolute;
435
+ left: 50%;
436
+ top: 50%;
437
+ width: 0;
438
+ height: 0;
439
+ transform: translate(-50%, -50%);
440
+ }
441
+ .x-spreadsheet-scrollbar .x-spreadsheet-scrollbar-button:hover {
442
+ background: #e1e6ef;
443
+ }
444
+ .x-spreadsheet-scrollbar .x-spreadsheet-scrollbar-button:active {
445
+ background: #d7dde8;
408
446
  }
409
447
  .x-spreadsheet-scrollbar.horizontal {
410
448
  right: 15px;
449
+ height: 15px;
450
+ flex-direction: row;
451
+ }
452
+ .x-spreadsheet-scrollbar.horizontal .x-spreadsheet-scrollbar-track {
453
+ height: 12px;
411
454
  overflow-x: scroll;
412
455
  overflow-y: hidden;
413
- height: 12px;
414
- /* 固定高度,避免覆盖表格内容 */
415
456
  }
416
- .x-spreadsheet-scrollbar.horizontal > div {
457
+ .x-spreadsheet-scrollbar.horizontal .x-spreadsheet-scrollbar-button {
458
+ width: 15px;
459
+ height: 15px;
460
+ border-top-width: 0;
461
+ border-bottom-width: 0;
462
+ }
463
+ .x-spreadsheet-scrollbar.horizontal .x-spreadsheet-scrollbar-button.decrease::before {
464
+ border-top: 4px solid transparent;
465
+ border-right: 5px solid #4f5b6b;
466
+ border-bottom: 4px solid transparent;
467
+ }
468
+ .x-spreadsheet-scrollbar.horizontal .x-spreadsheet-scrollbar-button.increase::before {
469
+ border-top: 4px solid transparent;
470
+ border-bottom: 4px solid transparent;
471
+ border-left: 5px solid #4f5b6b;
472
+ }
473
+ .x-spreadsheet-scrollbar.horizontal .x-spreadsheet-scrollbar-content {
417
474
  height: 1px;
418
- background: #ddd;
419
475
  }
420
476
  .x-spreadsheet-scrollbar.vertical {
421
477
  bottom: 15px;
478
+ width: 15px;
479
+ flex-direction: column;
480
+ }
481
+ .x-spreadsheet-scrollbar.vertical .x-spreadsheet-scrollbar-track {
482
+ width: 12px;
422
483
  overflow-x: hidden;
423
484
  overflow-y: scroll;
424
485
  }
425
- .x-spreadsheet-scrollbar.vertical > div {
486
+ .x-spreadsheet-scrollbar.vertical .x-spreadsheet-scrollbar-button {
487
+ width: 15px;
488
+ height: 15px;
489
+ border-left-width: 0;
490
+ border-right-width: 0;
491
+ }
492
+ .x-spreadsheet-scrollbar.vertical .x-spreadsheet-scrollbar-button.decrease::before {
493
+ border-right: 4px solid transparent;
494
+ border-bottom: 5px solid #4f5b6b;
495
+ border-left: 4px solid transparent;
496
+ }
497
+ .x-spreadsheet-scrollbar.vertical .x-spreadsheet-scrollbar-button.increase::before {
498
+ border-top: 5px solid #4f5b6b;
499
+ border-right: 4px solid transparent;
500
+ border-left: 4px solid transparent;
501
+ }
502
+ .x-spreadsheet-scrollbar.vertical .x-spreadsheet-scrollbar-content {
426
503
  width: 1px;
427
- background: #ddd;
428
504
  }
429
505
  /* @{css-prefix}-overlayer */
430
506
  .x-spreadsheet-overlayer {
@@ -919,6 +995,21 @@ body {
919
995
  .x-spreadsheet-toolbar .x-spreadsheet-toolbar-more {
920
996
  padding: 0 6px 6px;
921
997
  text-align: left;
998
+ display: flex;
999
+ flex-wrap: wrap;
1000
+ align-items: center;
1001
+ gap: 2px;
1002
+ }
1003
+ .x-spreadsheet-toolbar .x-spreadsheet-toolbar-more .x-spreadsheet-toolbar-btn {
1004
+ display: inline-flex !important;
1005
+ align-items: center;
1006
+ }
1007
+ .x-spreadsheet-toolbar .x-spreadsheet-toolbar-more .x-spreadsheet-dropdown {
1008
+ width: auto !important;
1009
+ max-width: 180px;
1010
+ }
1011
+ .x-spreadsheet-toolbar .x-spreadsheet-toolbar-more .x-spreadsheet-dropdown .x-spreadsheet-dropdown-title {
1012
+ max-width: 150px !important;
922
1013
  }
923
1014
  .x-spreadsheet-toolbar .x-spreadsheet-toolbar-more .x-spreadsheet-toolbar-divider {
924
1015
  margin-top: 0;
@@ -1033,27 +1124,83 @@ body {
1033
1124
  user-select: none;
1034
1125
  }
1035
1126
  .x-spreadsheet-calendar .calendar-header {
1127
+ display: flex;
1128
+ align-items: center;
1129
+ justify-content: space-between;
1036
1130
  font-weight: 700;
1037
1131
  line-height: 30px;
1038
1132
  text-align: center;
1039
1133
  width: 100%;
1040
- float: left;
1041
1134
  background: #f9fafb;
1042
1135
  }
1043
1136
  .x-spreadsheet-calendar .calendar-header .calendar-header-left {
1044
- padding-left: 5px;
1045
- float: left;
1137
+ flex: 1;
1138
+ display: inline-flex;
1139
+ align-items: center;
1140
+ justify-content: center;
1141
+ gap: 4px;
1142
+ min-width: 0;
1046
1143
  }
1047
- .x-spreadsheet-calendar .calendar-header .calendar-header-right {
1048
- float: right;
1144
+ .x-spreadsheet-calendar .calendar-header .calendar-title-button {
1145
+ height: 24px;
1146
+ min-width: 52px;
1147
+ padding: 0 8px;
1148
+ border: 1px solid transparent;
1149
+ border-radius: 4px;
1150
+ background: transparent;
1151
+ color: inherit;
1152
+ font: inherit;
1153
+ line-height: 22px;
1154
+ cursor: pointer;
1049
1155
  }
1050
- .x-spreadsheet-calendar .calendar-header .calendar-header-right a {
1051
- padding: 3px 0;
1052
- margin-right: 2px;
1156
+ .x-spreadsheet-calendar .calendar-header .calendar-title-button:hover {
1157
+ border-color: #d8e6f7;
1158
+ background: #edf5ff;
1159
+ color: #2185D0;
1160
+ }
1161
+ .x-spreadsheet-calendar .calendar-header .calendar-prev,
1162
+ .x-spreadsheet-calendar .calendar-header .calendar-next {
1163
+ flex: 0 0 28px;
1164
+ height: 30px;
1165
+ display: inline-flex;
1166
+ align-items: center;
1167
+ justify-content: center;
1168
+ border: 1px solid transparent;
1053
1169
  border-radius: 2px;
1170
+ color: inherit;
1171
+ cursor: pointer;
1054
1172
  }
1055
- .x-spreadsheet-calendar .calendar-header .calendar-header-right a:hover {
1056
- background: rgba(0, 0, 0, 0.08);
1173
+ .x-spreadsheet-calendar .calendar-header .calendar-prev:hover,
1174
+ .x-spreadsheet-calendar .calendar-header .calendar-next:hover {
1175
+ border-color: #d8e6f7;
1176
+ background: #edf5ff;
1177
+ color: #2185D0;
1178
+ }
1179
+ .x-spreadsheet-calendar .calendar-footer {
1180
+ display: flex;
1181
+ align-items: center;
1182
+ justify-content: flex-end;
1183
+ min-height: 36px;
1184
+ padding: 0 10px;
1185
+ border-top: 1px solid #eef0f3;
1186
+ background: #fff;
1187
+ }
1188
+ .x-spreadsheet-calendar .calendar-footer-button {
1189
+ height: 26px;
1190
+ min-width: 46px;
1191
+ padding: 0 8px;
1192
+ border: 1px solid transparent;
1193
+ border-radius: 4px;
1194
+ background: transparent;
1195
+ color: #2185D0;
1196
+ font-weight: 700;
1197
+ line-height: 24px;
1198
+ cursor: pointer;
1199
+ }
1200
+ .x-spreadsheet-calendar .calendar-footer-button:hover {
1201
+ border-color: #d8e6f7;
1202
+ background: #edf5ff;
1203
+ color: #2185D0;
1057
1204
  }
1058
1205
  .x-spreadsheet-calendar .calendar-body {
1059
1206
  border-collapse: collapse;
@@ -1068,17 +1215,57 @@ body {
1068
1215
  line-height: 30px;
1069
1216
  padding: 0;
1070
1217
  }
1218
+ .x-spreadsheet-calendar .calendar-body td > .cell {
1219
+ border: 1px solid transparent;
1220
+ border-radius: 2px;
1221
+ cursor: pointer;
1222
+ }
1071
1223
  .x-spreadsheet-calendar .calendar-body td > .cell:hover {
1072
- background: #ecf6fd;
1224
+ border-color: #d8e6f7;
1225
+ background: #edf5ff;
1226
+ color: #2185D0;
1073
1227
  }
1074
1228
  .x-spreadsheet-calendar .calendar-body td > .cell.active,
1075
1229
  .x-spreadsheet-calendar .calendar-body td > .cell.active:hover {
1076
1230
  background: #ecf6fd;
1077
1231
  color: #2185D0;
1078
1232
  }
1233
+ .x-spreadsheet-calendar .calendar-body td > .cell.today {
1234
+ color: #2185D0;
1235
+ }
1079
1236
  .x-spreadsheet-calendar .calendar-body td > .cell.disabled {
1080
1237
  pointer-events: none;
1081
1238
  opacity: 0.5;
1239
+ cursor: default;
1240
+ }
1241
+ .x-spreadsheet-calendar .calendar-body td > .cell.out-range {
1242
+ color: rgba(0, 0, 0, 0.35);
1243
+ }
1244
+ .x-spreadsheet-calendar .calendar-body.month-mode td,
1245
+ .x-spreadsheet-calendar .calendar-body.year-mode td {
1246
+ width: 33.33333333%;
1247
+ min-width: 64px;
1248
+ line-height: 42px;
1249
+ }
1250
+ .x-spreadsheet-calendar .calendar-body.month-mode td > .cell,
1251
+ .x-spreadsheet-calendar .calendar-body.year-mode td > .cell {
1252
+ margin: 4px 8px;
1253
+ border-radius: 6px;
1254
+ border: 1px solid transparent;
1255
+ }
1256
+ .x-spreadsheet-calendar .calendar-body.month-mode td > .cell:hover,
1257
+ .x-spreadsheet-calendar .calendar-body.year-mode td > .cell:hover {
1258
+ border-color: #d8e6f7;
1259
+ background: #edf5ff;
1260
+ color: #2185D0;
1261
+ }
1262
+ .x-spreadsheet-calendar .calendar-body.month-mode td > .cell.active,
1263
+ .x-spreadsheet-calendar .calendar-body.year-mode td > .cell.active,
1264
+ .x-spreadsheet-calendar .calendar-body.month-mode td > .cell.active:hover,
1265
+ .x-spreadsheet-calendar .calendar-body.year-mode td > .cell.active:hover {
1266
+ border-color: #2185D0;
1267
+ background: #2185D0;
1268
+ color: #fff;
1082
1269
  }
1083
1270
  .x-spreadsheet-datepicker {
1084
1271
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);