@dou-ui/sheet 0.0.0-stage → 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +10 -2
- package/dist/cell-types.js +20 -0
- package/dist/cell-types.js.map +1 -0
- package/dist/code/code-formula-bar.js +6 -0
- package/dist/code/code-formula-bar.js.map +1 -0
- package/dist/code/code-formula-bar.vue_vue_type_script_setup_true_lang.js +192 -0
- package/dist/code/code-formula-bar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/code/index.js +12 -0
- package/dist/code/index.js.map +1 -0
- package/dist/code/language.js +51 -0
- package/dist/code/language.js.map +1 -0
- package/dist/code/style.d.ts +1 -0
- package/dist/code/style.js +2 -0
- package/dist/collaboration/anchor.js +143 -0
- package/dist/collaboration/anchor.js.map +1 -0
- package/dist/collaboration/index.js +770 -0
- package/dist/collaboration/index.js.map +1 -0
- package/dist/collaboration/peers.js +87 -0
- package/dist/collaboration/peers.js.map +1 -0
- package/dist/collaboration/shared.js +450 -0
- package/dist/collaboration/shared.js.map +1 -0
- package/dist/components/cell-panel.js +6 -0
- package/dist/components/cell-panel.js.map +1 -0
- package/dist/components/cell-panel.vue_vue_type_script_setup_true_lang.js +70 -0
- package/dist/components/cell-panel.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/cell-renders.js +40 -0
- package/dist/components/cell-renders.js.map +1 -0
- package/dist/components/date-panel.js +6 -0
- package/dist/components/date-panel.js.map +1 -0
- package/dist/components/date-panel.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/components/date-panel.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/filter-panel.js +6 -0
- package/dist/components/filter-panel.js.map +1 -0
- package/dist/components/filter-panel.vue_vue_type_script_setup_true_lang.js +259 -0
- package/dist/components/filter-panel.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/format-dialog.js +6 -0
- package/dist/components/format-dialog.js.map +1 -0
- package/dist/components/format-dialog.vue_vue_type_script_setup_true_lang.js +432 -0
- package/dist/components/format-dialog.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/format-list.js +6 -0
- package/dist/components/format-list.js.map +1 -0
- package/dist/components/format-list.vue_vue_type_script_setup_true_lang.js +187 -0
- package/dist/components/format-list.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/format-presets.js +97 -0
- package/dist/components/format-presets.js.map +1 -0
- package/dist/components/option-panel.js +6 -0
- package/dist/components/option-panel.js.map +1 -0
- package/dist/components/option-panel.vue_vue_type_script_setup_true_lang.js +117 -0
- package/dist/components/option-panel.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/sheet-comment.js +6 -0
- package/dist/components/sheet-comment.js.map +1 -0
- package/dist/components/sheet-comment.vue_vue_type_script_setup_true_lang.js +104 -0
- package/dist/components/sheet-comment.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/sheet-formula-bar.js +6 -0
- package/dist/components/sheet-formula-bar.js.map +1 -0
- package/dist/components/sheet-formula-bar.vue_vue_type_script_setup_true_lang.js +124 -0
- package/dist/components/sheet-formula-bar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/sheet-link.js +6 -0
- package/dist/components/sheet-link.js.map +1 -0
- package/dist/components/sheet-link.vue_vue_type_script_setup_true_lang.js +249 -0
- package/dist/components/sheet-link.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/sheet-menu.js +6 -0
- package/dist/components/sheet-menu.js.map +1 -0
- package/dist/components/sheet-menu.vue_vue_type_script_setup_true_lang.js +115 -0
- package/dist/components/sheet-menu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/sheet-name-box.js +6 -0
- package/dist/components/sheet-name-box.js.map +1 -0
- package/dist/components/sheet-name-box.vue_vue_type_script_setup_true_lang.js +91 -0
- package/dist/components/sheet-name-box.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/sheet-note.js +6 -0
- package/dist/components/sheet-note.js.map +1 -0
- package/dist/components/sheet-note.vue_vue_type_script_setup_true_lang.js +146 -0
- package/dist/components/sheet-note.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/sheet-outline.js +6 -0
- package/dist/components/sheet-outline.js.map +1 -0
- package/dist/components/sheet-outline.vue_vue_type_script_setup_true_lang.js +237 -0
- package/dist/components/sheet-outline.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/sheet-tabs.js +6 -0
- package/dist/components/sheet-tabs.js.map +1 -0
- package/dist/components/sheet-tabs.vue_vue_type_script_setup_true_lang.js +487 -0
- package/dist/components/sheet-tabs.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/sheet-toolbar.js +6 -0
- package/dist/components/sheet-toolbar.js.map +1 -0
- package/dist/components/sheet-toolbar.vue_vue_type_script_setup_true_lang.js +1562 -0
- package/dist/components/sheet-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/validation-dialog.js +6 -0
- package/dist/components/validation-dialog.js.map +1 -0
- package/dist/components/validation-dialog.vue_vue_type_script_setup_true_lang.js +370 -0
- package/dist/components/validation-dialog.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/context.js +12 -0
- package/dist/context.js.map +1 -0
- package/dist/core/address.js +256 -0
- package/dist/core/address.js.map +1 -0
- package/dist/core/axis.js +72 -0
- package/dist/core/axis.js.map +1 -0
- package/dist/core/cell-type.js +30 -0
- package/dist/core/cell-type.js.map +1 -0
- package/dist/core/clipboard.js +141 -0
- package/dist/core/clipboard.js.map +1 -0
- package/dist/core/commands.js +63 -0
- package/dist/core/commands.js.map +1 -0
- package/dist/core/comments.js +74 -0
- package/dist/core/comments.js.map +1 -0
- package/dist/core/conditional.js +362 -0
- package/dist/core/conditional.js.map +1 -0
- package/dist/core/csv.js +191 -0
- package/dist/core/csv.js.map +1 -0
- package/dist/core/data.js +118 -0
- package/dist/core/data.js.map +1 -0
- package/dist/core/document.js +187 -0
- package/dist/core/document.js.map +1 -0
- package/dist/core/extension.js +60 -0
- package/dist/core/extension.js.map +1 -0
- package/dist/core/file.js +336 -0
- package/dist/core/file.js.map +1 -0
- package/dist/core/fill.js +153 -0
- package/dist/core/fill.js.map +1 -0
- package/dist/core/find.js +42 -0
- package/dist/core/find.js.map +1 -0
- package/dist/core/format.js +404 -0
- package/dist/core/format.js.map +1 -0
- package/dist/core/group.js +134 -0
- package/dist/core/group.js.map +1 -0
- package/dist/core/history.js +68 -0
- package/dist/core/history.js.map +1 -0
- package/dist/core/index.js +17 -0
- package/dist/core/link.js +34 -0
- package/dist/core/link.js.map +1 -0
- package/dist/core/merge.js +105 -0
- package/dist/core/merge.js.map +1 -0
- package/dist/core/model.js +48 -0
- package/dist/core/model.js.map +1 -0
- package/dist/core/nav.js +44 -0
- package/dist/core/nav.js.map +1 -0
- package/dist/core/paint.js +106 -0
- package/dist/core/paint.js.map +1 -0
- package/dist/core/plain-cell-types.js +54 -0
- package/dist/core/plain-cell-types.js.map +1 -0
- package/dist/core/protect.js +246 -0
- package/dist/core/protect.js.map +1 -0
- package/dist/core/selection.js +37 -0
- package/dist/core/selection.js.map +1 -0
- package/dist/core/transaction.js +1582 -0
- package/dist/core/transaction.js.map +1 -0
- package/dist/core/validation.js +135 -0
- package/dist/core/validation.js.map +1 -0
- package/dist/core/versions.js +161 -0
- package/dist/core/versions.js.map +1 -0
- package/dist/export/color.js +36 -0
- package/dist/export/color.js.map +1 -0
- package/dist/export/draw.js +316 -0
- package/dist/export/draw.js.map +1 -0
- package/dist/export/index.js +390 -0
- package/dist/export/index.js.map +1 -0
- package/dist/formula/edit.js +210 -0
- package/dist/formula/edit.js.map +1 -0
- package/dist/formula/engine.js +526 -0
- package/dist/formula/engine.js.map +1 -0
- package/dist/formula/error.js +39 -0
- package/dist/formula/error.js.map +1 -0
- package/dist/formula/functions.js +1493 -0
- package/dist/formula/functions.js.map +1 -0
- package/dist/formula/help.js +408 -0
- package/dist/formula/help.js.map +1 -0
- package/dist/formula/index.js +7 -0
- package/dist/formula/parse.js +369 -0
- package/dist/formula/parse.js.map +1 -0
- package/dist/formula/values.js +123 -0
- package/dist/formula/values.js.map +1 -0
- package/dist/formulas.js +30 -0
- package/dist/formulas.js.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/locale.js +1312 -0
- package/dist/locale.js.map +1 -0
- package/dist/sheet.js +6 -0
- package/dist/sheet.js.map +1 -0
- package/dist/sheet.vue_vue_type_script_setup_true_lang.js +7166 -0
- package/dist/sheet.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/style.d.ts +1 -0
- package/dist/style.js +17 -0
- package/dist/types/cell-types.d.ts +2 -0
- package/dist/types/code/code-formula-bar.vue.d.ts +3 -0
- package/dist/types/code/index.d.ts +12 -0
- package/dist/types/code/language.d.ts +13 -0
- package/dist/types/collaboration/anchor.d.ts +65 -0
- package/dist/types/collaboration/index.d.ts +59 -0
- package/dist/types/collaboration/peers.d.ts +21 -0
- package/dist/types/collaboration/shared.d.ts +75 -0
- package/dist/types/components/cell-panel.vue.d.ts +20 -0
- package/dist/types/components/cell-renders.d.ts +9 -0
- package/dist/types/components/date-panel.vue.d.ts +9 -0
- package/dist/types/components/filter-panel.vue.d.ts +21 -0
- package/dist/types/components/format-dialog.vue.d.ts +24 -0
- package/dist/types/components/format-list.vue.d.ts +25 -0
- package/dist/types/components/format-presets.d.ts +30 -0
- package/dist/types/components/option-panel.vue.d.ts +13 -0
- package/dist/types/components/sheet-comment.vue.d.ts +29 -0
- package/dist/types/components/sheet-formula-bar.vue.d.ts +3 -0
- package/dist/types/components/sheet-link.vue.d.ts +32 -0
- package/dist/types/components/sheet-menu.vue.d.ts +20 -0
- package/dist/types/components/sheet-name-box.vue.d.ts +3 -0
- package/dist/types/components/sheet-note.vue.d.ts +22 -0
- package/dist/types/components/sheet-outline.vue.d.ts +36 -0
- package/dist/types/components/sheet-tabs.vue.d.ts +9 -0
- package/dist/types/components/sheet-toolbar.vue.d.ts +11 -0
- package/dist/types/components/validation-dialog.vue.d.ts +25 -0
- package/dist/types/context.d.ts +189 -0
- package/dist/types/core/address.d.ts +109 -0
- package/dist/types/core/axis.d.ts +23 -0
- package/dist/types/core/cell-type.d.ts +157 -0
- package/dist/types/core/clipboard.d.ts +48 -0
- package/dist/types/core/commands.d.ts +76 -0
- package/dist/types/core/comments.d.ts +22 -0
- package/dist/types/core/conditional.d.ts +114 -0
- package/dist/types/core/csv.d.ts +93 -0
- package/dist/types/core/data.d.ts +26 -0
- package/dist/types/core/document.d.ts +49 -0
- package/dist/types/core/extension.d.ts +177 -0
- package/dist/types/core/file.d.ts +301 -0
- package/dist/types/core/fill.d.ts +23 -0
- package/dist/types/core/find.d.ts +39 -0
- package/dist/types/core/format.d.ts +47 -0
- package/dist/types/core/group.d.ts +76 -0
- package/dist/types/core/history.d.ts +27 -0
- package/dist/types/core/index.d.ts +33 -0
- package/dist/types/core/link.d.ts +14 -0
- package/dist/types/core/merge.d.ts +26 -0
- package/dist/types/core/model.d.ts +363 -0
- package/dist/types/core/nav.d.ts +15 -0
- package/dist/types/core/paint.d.ts +19 -0
- package/dist/types/core/plain-cell-types.d.ts +6 -0
- package/dist/types/core/protect.d.ts +34 -0
- package/dist/types/core/selection.d.ts +25 -0
- package/dist/types/core/transaction.d.ts +470 -0
- package/dist/types/core/validation.d.ts +55 -0
- package/dist/types/core/versions.d.ts +38 -0
- package/dist/types/export/color.d.ts +7 -0
- package/dist/types/export/draw.d.ts +98 -0
- package/dist/types/export/index.d.ts +47 -0
- package/dist/types/formula/edit.d.ts +62 -0
- package/dist/types/formula/engine.d.ts +99 -0
- package/dist/types/formula/error.d.ts +30 -0
- package/dist/types/formula/functions.d.ts +62 -0
- package/dist/types/formula/help.d.ts +12 -0
- package/dist/types/formula/index.d.ts +13 -0
- package/dist/types/formula/parse.d.ts +92 -0
- package/dist/types/formula/values.d.ts +65 -0
- package/dist/types/formulas.d.ts +32 -0
- package/dist/types/index.d.ts +225 -0
- package/dist/types/locale.d.ts +531 -0
- package/dist/types/sheet.vue.d.ts +60 -0
- package/dist/types/types.d.ts +498 -0
- package/dist/types/use-comments.d.ts +47 -0
- package/dist/types/use-messages.d.ts +7 -0
- package/dist/use-comments.js +130 -0
- package/dist/use-comments.js.map +1 -0
- package/dist/use-messages.js +29 -0
- package/dist/use-messages.js.map +1 -0
- package/package.json +93 -4
|
@@ -0,0 +1,1562 @@
|
|
|
1
|
+
import { boundsOf, columnName, formatRange, inBounds, parseRange } from "../core/address.js";
|
|
2
|
+
import { changeDecimals, formatValue } from "../core/format.js";
|
|
3
|
+
import { rangesOf, ruleRangeText } from "../core/conditional.js";
|
|
4
|
+
import { format } from "../locale.js";
|
|
5
|
+
import { useSheet } from "../context.js";
|
|
6
|
+
import { LOOKS, SCALES, TONES, barSwatch, scaleSwatch, toneKey } from "./format-presets.js";
|
|
7
|
+
import format_dialog_default from "./format-dialog.js";
|
|
8
|
+
import format_list_default from "./format-list.js";
|
|
9
|
+
import validation_dialog_default from "./validation-dialog.js";
|
|
10
|
+
import { DouButton, DouColorPanel, DouDropdown, DouDropdownItem, DouDropdownRadioGroup, DouDropdownSub, DouPopover, DouToggle, DouToggleGroup, DouToolbar, DouToolbarSeparator, DouTooltip } from "dou-ui";
|
|
11
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, useTemplateRef, watch, withCtx } from "vue";
|
|
12
|
+
import { BaselineIcon, BoldIcon, CellsMergeIcon, ChevronDownIcon, DecimalDecreaseIcon, DecimalIncreaseIcon, DownloadIcon, FilterIcon, ItalicIcon, LinkIcon, PaintBucketIcon, PaletteIcon, RedoIcon, ShieldLockIcon, SortAscendingIcon, SortDescendingIcon, SortIcon, StrikethroughIcon, TableCheckIcon, TableFreezeIcon, TableHighlightIcon, TextAlignCenterIcon, TextAlignLeftIcon, TextAlignRightIcon, TextValignBottomIcon, TextValignMiddleIcon, TextValignTopIcon, TypeXIcon, UnderlineIcon, UndoIcon, UploadIcon, WrapTextIcon } from "@dou-ui/icons";
|
|
13
|
+
// src/components/sheet-toolbar.vue?vue&type=script&setup=true&lang.ts
|
|
14
|
+
var _hoisted_1 = { class: "dou-sheet-toolbar" };
|
|
15
|
+
var _hoisted_2 = { class: "dou-sheet-toolbar__trigger" };
|
|
16
|
+
var _hoisted_3 = {
|
|
17
|
+
key: 1,
|
|
18
|
+
class: "dou-sheet-toolbar__text"
|
|
19
|
+
};
|
|
20
|
+
var _hoisted_4 = {
|
|
21
|
+
key: 1,
|
|
22
|
+
class: "dou-sheet-toolbar__text"
|
|
23
|
+
};
|
|
24
|
+
var _hoisted_5 = {
|
|
25
|
+
key: 1,
|
|
26
|
+
class: "dou-sheet-toolbar__text"
|
|
27
|
+
};
|
|
28
|
+
var _hoisted_6 = { class: "dou-sheet-toolbar__format-label" };
|
|
29
|
+
var _hoisted_7 = { class: "dou-sheet-toolbar__example" };
|
|
30
|
+
var _hoisted_8 = { class: "dou-sheet-toolbar__trigger" };
|
|
31
|
+
var _hoisted_9 = ["aria-label"];
|
|
32
|
+
var _hoisted_10 = [
|
|
33
|
+
"aria-pressed",
|
|
34
|
+
"aria-label",
|
|
35
|
+
"title",
|
|
36
|
+
"onClick"
|
|
37
|
+
];
|
|
38
|
+
var _hoisted_11 = [
|
|
39
|
+
"aria-pressed",
|
|
40
|
+
"aria-label",
|
|
41
|
+
"title",
|
|
42
|
+
"onClick"
|
|
43
|
+
];
|
|
44
|
+
var _hoisted_12 = {
|
|
45
|
+
key: 0,
|
|
46
|
+
"aria-hidden": "true"
|
|
47
|
+
};
|
|
48
|
+
var _hoisted_13 = [
|
|
49
|
+
"aria-pressed",
|
|
50
|
+
"aria-expanded",
|
|
51
|
+
"aria-label",
|
|
52
|
+
"title",
|
|
53
|
+
"onClick"
|
|
54
|
+
];
|
|
55
|
+
var _hoisted_14 = {
|
|
56
|
+
key: 0,
|
|
57
|
+
"aria-hidden": "true"
|
|
58
|
+
};
|
|
59
|
+
var _hoisted_15 = { class: "dou-sheet-toolbar__trigger" };
|
|
60
|
+
var _hoisted_16 = { class: "dou-sheet-toolbar__trigger" };
|
|
61
|
+
var _hoisted_17 = { class: "dou-sheet-toolbar__trigger" };
|
|
62
|
+
var _hoisted_18 = { class: "dou-sheet-toolbar__trigger" };
|
|
63
|
+
var _hoisted_19 = { class: "dou-sheet-toolbar__trigger" };
|
|
64
|
+
var _hoisted_20 = { class: "dou-sheet-toolbar__trigger" };
|
|
65
|
+
var _hoisted_21 = ["accept"];
|
|
66
|
+
var sheet_toolbar_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
67
|
+
name: "DouSheetToolbar",
|
|
68
|
+
__name: "sheet-toolbar",
|
|
69
|
+
props: {
|
|
70
|
+
tools: {},
|
|
71
|
+
formats: {},
|
|
72
|
+
fileName: { type: [String, Function] }
|
|
73
|
+
},
|
|
74
|
+
setup(__props) {
|
|
75
|
+
const props = __props;
|
|
76
|
+
const sheet = useSheet();
|
|
77
|
+
const { messages: m, active } = sheet;
|
|
78
|
+
const DEFAULT_TOOLS = [
|
|
79
|
+
"undo",
|
|
80
|
+
"redo",
|
|
81
|
+
"|",
|
|
82
|
+
"format",
|
|
83
|
+
"decimals",
|
|
84
|
+
"|",
|
|
85
|
+
"bold",
|
|
86
|
+
"italic",
|
|
87
|
+
"underline",
|
|
88
|
+
"strike",
|
|
89
|
+
"|",
|
|
90
|
+
"color",
|
|
91
|
+
"fill",
|
|
92
|
+
"|",
|
|
93
|
+
"align",
|
|
94
|
+
"valign",
|
|
95
|
+
"wrap",
|
|
96
|
+
"|",
|
|
97
|
+
"merge",
|
|
98
|
+
"freeze",
|
|
99
|
+
"link",
|
|
100
|
+
"|",
|
|
101
|
+
"sort",
|
|
102
|
+
"filter",
|
|
103
|
+
"conditional",
|
|
104
|
+
"validation",
|
|
105
|
+
"protect",
|
|
106
|
+
"|",
|
|
107
|
+
"clear"
|
|
108
|
+
];
|
|
109
|
+
const BUILT_IN = /* @__PURE__ */ new Set([
|
|
110
|
+
...DEFAULT_TOOLS,
|
|
111
|
+
"export",
|
|
112
|
+
"import"
|
|
113
|
+
]);
|
|
114
|
+
/** The protect menu: locking the selection, then protecting the sheet and the workbook. */
|
|
115
|
+
const PROTECT_COMMANDS = [
|
|
116
|
+
"lock",
|
|
117
|
+
"protect.sheet",
|
|
118
|
+
"protect.workbook"
|
|
119
|
+
];
|
|
120
|
+
/** A tool that isn't built in, ready to draw: an extension's item, or a command by name. */
|
|
121
|
+
function extraTool(item) {
|
|
122
|
+
const name = item.command;
|
|
123
|
+
const info = name ? sheet.commands.get(name) : void 0;
|
|
124
|
+
if (name && !info) throw new Error(`[@dou-ui/sheet] the toolbar item "${item.key}" runs no command: "${name}" is unknown`);
|
|
125
|
+
return {
|
|
126
|
+
key: item.key,
|
|
127
|
+
label: item.label ?? info?.label ?? item.key,
|
|
128
|
+
icon: item.icon ?? info?.icon,
|
|
129
|
+
shortcut: item.shortcut ?? info?.shortcut,
|
|
130
|
+
pressed: item.pressed ?? (name && info.toggle ? sheet.commands.pressed(name) : void 0),
|
|
131
|
+
disabled: item.disabled ?? (name ? !sheet.commands.can(name) : false),
|
|
132
|
+
run: item.run ?? (name ? () => void sheet.commands.run(name) : void 0),
|
|
133
|
+
children: item.children
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/** The extensions' items, by key. */
|
|
137
|
+
const extensionItems = computed(() => {
|
|
138
|
+
const map = /* @__PURE__ */ new Map();
|
|
139
|
+
for (const item of sheet.toolbarItems.value) {
|
|
140
|
+
if (BUILT_IN.has(item.key) || map.has(item.key)) throw new Error(`[@dou-ui/sheet] the toolbar item "${item.key}" is added twice, or has the name of a built-in tool`);
|
|
141
|
+
warnOnce(item);
|
|
142
|
+
map.set(item.key, item);
|
|
143
|
+
}
|
|
144
|
+
return map;
|
|
145
|
+
});
|
|
146
|
+
const warned = /* @__PURE__ */ new Set();
|
|
147
|
+
/** Says once when an item can't show a name or does nothing when pressed. */
|
|
148
|
+
function warnOnce(item) {
|
|
149
|
+
if (process.env.NODE_ENV === "production" || warned.has(item.key)) return;
|
|
150
|
+
warned.add(item.key);
|
|
151
|
+
if (!item.command && !item.label) console.warn(`[@dou-ui/sheet] the toolbar item "${item.key}" has no label or command, so it shows its key`);
|
|
152
|
+
if (!item.command && !item.run && !item.children?.length) console.warn(`[@dou-ui/sheet] the toolbar item "${item.key}" has no run, command or children: pressing it does nothing`);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Built-in tools of one button that an extension's command replaced: they
|
|
156
|
+
* are drawn from the command, with its label, icon and state.
|
|
157
|
+
*/
|
|
158
|
+
const SINGLE = /* @__PURE__ */ new Set([
|
|
159
|
+
"undo",
|
|
160
|
+
"redo",
|
|
161
|
+
"bold",
|
|
162
|
+
"italic",
|
|
163
|
+
"underline",
|
|
164
|
+
"strike",
|
|
165
|
+
"wrap",
|
|
166
|
+
"merge",
|
|
167
|
+
"filter",
|
|
168
|
+
"clear",
|
|
169
|
+
"link"
|
|
170
|
+
]);
|
|
171
|
+
const replaced = (tool) => SINGLE.has(tool) && sheet.commands.get(tool)?.builtin === false;
|
|
172
|
+
/** The tools to show, without separators at either end or two in a row. */
|
|
173
|
+
const tools = computed(() => {
|
|
174
|
+
const list = props.tools ?? [
|
|
175
|
+
...DEFAULT_TOOLS,
|
|
176
|
+
"|",
|
|
177
|
+
...extensionItems.value.keys()
|
|
178
|
+
];
|
|
179
|
+
const out = [];
|
|
180
|
+
for (const tool of list) if (tool !== "|" || out.length && out[out.length - 1] !== "|") out.push(tool);
|
|
181
|
+
if (out[out.length - 1] === "|") out.pop();
|
|
182
|
+
return out;
|
|
183
|
+
});
|
|
184
|
+
/** The tools that aren't built in, by name. */
|
|
185
|
+
const extras = computed(() => {
|
|
186
|
+
const map = /* @__PURE__ */ new Map();
|
|
187
|
+
for (const tool of tools.value) {
|
|
188
|
+
if (replaced(tool)) {
|
|
189
|
+
map.set(tool, extraTool({
|
|
190
|
+
key: tool,
|
|
191
|
+
command: tool
|
|
192
|
+
}));
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (tool === "|" || BUILT_IN.has(tool)) continue;
|
|
196
|
+
const item = extensionItems.value.get(tool);
|
|
197
|
+
if (item) map.set(tool, extraTool(item));
|
|
198
|
+
else if (sheet.commands.has(tool)) map.set(tool, extraTool({
|
|
199
|
+
key: tool,
|
|
200
|
+
command: tool
|
|
201
|
+
}));
|
|
202
|
+
else throw new Error(`[@dou-ui/sheet] the toolbar has no tool "${tool}": it is no built-in tool, item of an extension or command`);
|
|
203
|
+
}
|
|
204
|
+
return map;
|
|
205
|
+
});
|
|
206
|
+
/** Runs a command from a tool, then gives the keys back to the grid after a press. */
|
|
207
|
+
function run(name, arg) {
|
|
208
|
+
sheet.commands.run(name, arg);
|
|
209
|
+
done();
|
|
210
|
+
}
|
|
211
|
+
const can = (name) => sheet.commands.can(name);
|
|
212
|
+
const on = (name) => sheet.commands.pressed(name);
|
|
213
|
+
function runExtra(item) {
|
|
214
|
+
item.run?.();
|
|
215
|
+
done();
|
|
216
|
+
}
|
|
217
|
+
function runChild(child) {
|
|
218
|
+
const name = child.command;
|
|
219
|
+
if (child.run) child.run();
|
|
220
|
+
else if (name) sheet.commands.run(name);
|
|
221
|
+
done();
|
|
222
|
+
}
|
|
223
|
+
const childLabel = (child) => child.label ?? (child.command ? sheet.commands.get(child.command)?.label ?? child.key : child.key);
|
|
224
|
+
const childIcon = (child) => child.icon ?? (child.command ? sheet.commands.get(child.command)?.icon : void 0);
|
|
225
|
+
const childShortcut = (child) => child.shortcut ?? (child.command ? sheet.commands.get(child.command)?.shortcut : void 0);
|
|
226
|
+
const coarse = ref(false);
|
|
227
|
+
onMounted(() => {
|
|
228
|
+
coarse.value = typeof matchMedia !== "undefined" && matchMedia("(pointer: coarse)").matches;
|
|
229
|
+
});
|
|
230
|
+
const childDisabled = (child) => child.disabled ?? (child.command ? !sheet.commands.can(child.command) : false);
|
|
231
|
+
const disabled = computed(() => sheet.readonly.value);
|
|
232
|
+
const style = computed(() => sheet.styleAt(active.value));
|
|
233
|
+
const cellFormat = computed(() => sheet.formatAt(active.value));
|
|
234
|
+
let pointer = false;
|
|
235
|
+
function onPointerDown(event) {
|
|
236
|
+
pointer = true;
|
|
237
|
+
if (event.pointerType === "mouse" && event.target.closest("button")) event.preventDefault();
|
|
238
|
+
}
|
|
239
|
+
function onKeyDown() {
|
|
240
|
+
pointer = false;
|
|
241
|
+
}
|
|
242
|
+
function done() {
|
|
243
|
+
if (pointer) nextTick(() => sheet.focus());
|
|
244
|
+
}
|
|
245
|
+
const menuOpen = ref(null);
|
|
246
|
+
function onMenu(tool, open) {
|
|
247
|
+
if (open) menuOpen.value = tool;
|
|
248
|
+
else if (menuOpen.value === tool) {
|
|
249
|
+
menuOpen.value = null;
|
|
250
|
+
done();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/** Whether more than one cell is selected, so exporting the selection means something. */
|
|
254
|
+
const manySelected = computed(() => {
|
|
255
|
+
const { ranges } = sheet.selection.value;
|
|
256
|
+
if (ranges.length !== 1) return true;
|
|
257
|
+
const { start, end } = ranges[0];
|
|
258
|
+
return start.row !== end.row || start.col !== end.col;
|
|
259
|
+
});
|
|
260
|
+
const exportItems = computed(() => sheet.exporters.value.map((exporter) => {
|
|
261
|
+
const scopes = exporter.scopes.filter((scope) => scope !== "selection" || manySelected.value);
|
|
262
|
+
return {
|
|
263
|
+
name: exporter.name,
|
|
264
|
+
label: exporter.label,
|
|
265
|
+
icon: exporter.icon,
|
|
266
|
+
extension: exporter.extension,
|
|
267
|
+
scopes: scopes.length > 1 ? scopes : [],
|
|
268
|
+
scope: scopes[0]
|
|
269
|
+
};
|
|
270
|
+
}));
|
|
271
|
+
function exportWith(name, scope) {
|
|
272
|
+
done();
|
|
273
|
+
const exporter = sheet.exporters.value.find((e) => e.name === name);
|
|
274
|
+
const fileName = typeof props.fileName === "function" ? props.fileName(exporter, scope ?? exporter.scopes[0]) : props.fileName && `${props.fileName}.${exporter.extension}`;
|
|
275
|
+
sheet.saveFile(name, {
|
|
276
|
+
scope,
|
|
277
|
+
fileName
|
|
278
|
+
}).catch(() => {});
|
|
279
|
+
}
|
|
280
|
+
const picker = useTemplateRef("picker");
|
|
281
|
+
function pickFile() {
|
|
282
|
+
picker.value?.click();
|
|
283
|
+
}
|
|
284
|
+
function onPicked(event) {
|
|
285
|
+
const input = event.target;
|
|
286
|
+
const file = input.files?.[0];
|
|
287
|
+
input.value = "";
|
|
288
|
+
nextTick(() => sheet.focus());
|
|
289
|
+
if (file) sheet.importFile(file).catch(() => {});
|
|
290
|
+
}
|
|
291
|
+
function onPickCancel() {
|
|
292
|
+
nextTick(() => sheet.focus());
|
|
293
|
+
}
|
|
294
|
+
const STYLE = {
|
|
295
|
+
bold: {
|
|
296
|
+
icon: BoldIcon,
|
|
297
|
+
key: "mod+b"
|
|
298
|
+
},
|
|
299
|
+
italic: {
|
|
300
|
+
icon: ItalicIcon,
|
|
301
|
+
key: "mod+i"
|
|
302
|
+
},
|
|
303
|
+
underline: {
|
|
304
|
+
icon: UnderlineIcon,
|
|
305
|
+
key: "mod+u"
|
|
306
|
+
},
|
|
307
|
+
strike: {
|
|
308
|
+
icon: StrikethroughIcon,
|
|
309
|
+
key: "mod+shift+x"
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
const isStyleTool = (tool) => tool in STYLE;
|
|
313
|
+
const formats = computed(() => props.formats ?? [
|
|
314
|
+
{
|
|
315
|
+
label: m.value.formatGeneral,
|
|
316
|
+
format: void 0,
|
|
317
|
+
example: 1234.5
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
label: m.value.formatNumber,
|
|
321
|
+
format: "#,##0.00",
|
|
322
|
+
example: 1234.5
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
label: m.value.formatPercent,
|
|
326
|
+
format: "0.00%",
|
|
327
|
+
example: .1234
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
label: m.value.formatCurrency,
|
|
331
|
+
format: m.value.currencyFormat,
|
|
332
|
+
example: 1234.5
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
label: m.value.formatDate,
|
|
336
|
+
format: "yyyy-mm-dd",
|
|
337
|
+
example: "2026-03-05"
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
label: m.value.formatTime,
|
|
341
|
+
format: "hh:mm",
|
|
342
|
+
example: "09:30"
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
label: m.value.formatText,
|
|
346
|
+
format: "@"
|
|
347
|
+
}
|
|
348
|
+
]);
|
|
349
|
+
/**
|
|
350
|
+
* The option the cell's format is, or is with other decimals or grouping:
|
|
351
|
+
* `¥#,##0.000` is still currency, `0.0%` still percent and `0.0` a number.
|
|
352
|
+
*/
|
|
353
|
+
const formatShown = computed(() => {
|
|
354
|
+
const current = cellFormat.value;
|
|
355
|
+
const exact = formats.value.find((option) => option.format === current);
|
|
356
|
+
if (exact || !current) return exact ?? null;
|
|
357
|
+
const kind = withoutDecimals(current);
|
|
358
|
+
return formats.value.find((option) => option.format && withoutDecimals(option.format) === kind) ?? null;
|
|
359
|
+
});
|
|
360
|
+
const formatLabel = computed(() => formatShown.value?.label ?? m.value.formatCustom);
|
|
361
|
+
const withoutDecimals = (pattern) => changeDecimals(pattern, null, -99).replace(/[#,](?=[#,0]*0)/g, "");
|
|
362
|
+
const exampleOf = (option) => option.example == null ? "" : formatValue(option.example, option.format);
|
|
363
|
+
function setFormat(option) {
|
|
364
|
+
sheet.formatSelection(option.format);
|
|
365
|
+
done();
|
|
366
|
+
}
|
|
367
|
+
const toneLabel = (tone) => m.value[toneKey(tone)];
|
|
368
|
+
const colorOpen = ref(null);
|
|
369
|
+
const custom = ref(null);
|
|
370
|
+
const customColor = ref(null);
|
|
371
|
+
/** The color a tool shows now: a tone, a CSS color, or `null` for none. */
|
|
372
|
+
function colorOf(tool) {
|
|
373
|
+
const s = style.value;
|
|
374
|
+
return tool === "color" ? {
|
|
375
|
+
tone: s.color ? void 0 : s.tone,
|
|
376
|
+
css: s.color
|
|
377
|
+
} : {
|
|
378
|
+
tone: s.background ? void 0 : s.fill,
|
|
379
|
+
css: s.background
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
/** What the mark under the icon is drawn in. */
|
|
383
|
+
function swatchOf(tool) {
|
|
384
|
+
const { tone, css } = colorOf(tool);
|
|
385
|
+
if (css) return css;
|
|
386
|
+
if (!tone) return void 0;
|
|
387
|
+
return tool === "color" ? `var(--dou-color-${tone}-text)` : `var(--dou-color-${tone})`;
|
|
388
|
+
}
|
|
389
|
+
function setColor(tool, value, close = true) {
|
|
390
|
+
sheet.styleSelection(tool === "color" ? {
|
|
391
|
+
tone: value.tone,
|
|
392
|
+
color: value.css
|
|
393
|
+
} : {
|
|
394
|
+
fill: value.tone,
|
|
395
|
+
background: value.css
|
|
396
|
+
});
|
|
397
|
+
if (close) {
|
|
398
|
+
colorOpen.value = null;
|
|
399
|
+
done();
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
/** Opens the color panel, starting from the color the cell shows now. */
|
|
403
|
+
function openCustom(tool, event) {
|
|
404
|
+
custom.value = custom.value === tool ? null : tool;
|
|
405
|
+
const css = colorOf(tool).css;
|
|
406
|
+
if (css) customColor.value = css;
|
|
407
|
+
else {
|
|
408
|
+
const shown = event.currentTarget.closest(".dou-sheet-toolbar__colors")?.querySelector("[aria-pressed=\"true\"]");
|
|
409
|
+
const look = shown && getComputedStyle(shown);
|
|
410
|
+
customColor.value = look && (tool === "color" ? look.color : look.backgroundColor) || null;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
watch(colorOpen, (open) => {
|
|
414
|
+
if (open) return;
|
|
415
|
+
custom.value = null;
|
|
416
|
+
done();
|
|
417
|
+
});
|
|
418
|
+
const ALIGN = [
|
|
419
|
+
{
|
|
420
|
+
value: "left",
|
|
421
|
+
icon: TextAlignLeftIcon,
|
|
422
|
+
label: "alignLeft"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
value: "center",
|
|
426
|
+
icon: TextAlignCenterIcon,
|
|
427
|
+
label: "alignCenter"
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
value: "right",
|
|
431
|
+
icon: TextAlignRightIcon,
|
|
432
|
+
label: "alignRight"
|
|
433
|
+
}
|
|
434
|
+
];
|
|
435
|
+
const VALIGN = [
|
|
436
|
+
{
|
|
437
|
+
value: "top",
|
|
438
|
+
icon: TextValignTopIcon,
|
|
439
|
+
label: "alignTop"
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
value: "middle",
|
|
443
|
+
icon: TextValignMiddleIcon,
|
|
444
|
+
label: "alignMiddle"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
value: "bottom",
|
|
448
|
+
icon: TextValignBottomIcon,
|
|
449
|
+
label: "alignBottom"
|
|
450
|
+
}
|
|
451
|
+
];
|
|
452
|
+
const align = computed(() => ALIGN.find((a) => on(`align.${a.value}`))?.value ?? null);
|
|
453
|
+
const valign = computed(() => VALIGN.find((v) => on(`valign.${v.value}`))?.value ?? "middle");
|
|
454
|
+
const valignIcon = computed(() => VALIGN.find((v) => v.value === valign.value).icon);
|
|
455
|
+
function setAlign(value) {
|
|
456
|
+
if (typeof value === "string") run(`align.${value}`);
|
|
457
|
+
}
|
|
458
|
+
/** The selected ranges, as names such as `D2:D40`. */
|
|
459
|
+
function selectedRanges() {
|
|
460
|
+
const data = sheet.sheet.value;
|
|
461
|
+
const size = {
|
|
462
|
+
rows: data.rowCount ?? 1e3,
|
|
463
|
+
cols: data.colCount ?? 26
|
|
464
|
+
};
|
|
465
|
+
return sheet.selection.value.ranges.map((range) => formatRange(range, size));
|
|
466
|
+
}
|
|
467
|
+
/** The selection as a rule's range, which a new rule starts with: one range, or several. */
|
|
468
|
+
function selectedRange() {
|
|
469
|
+
const ranges = selectedRanges();
|
|
470
|
+
return ranges.length === 1 ? ranges[0] : ranges;
|
|
471
|
+
}
|
|
472
|
+
/** Whether a rule's ranges hold a cell. */
|
|
473
|
+
const ruleHolds = (range, row, col) => rangesOf(range).some((text) => {
|
|
474
|
+
const r = parseRange(text);
|
|
475
|
+
return !!r && inBounds(boundsOf(r), row, col);
|
|
476
|
+
});
|
|
477
|
+
function addFormats(list) {
|
|
478
|
+
if (!list.length) return;
|
|
479
|
+
sheet.transact((tr) => {
|
|
480
|
+
for (const f of list) tr.addConditionalFormat(f);
|
|
481
|
+
}, { action: "format" });
|
|
482
|
+
sheet.announce(format(m.value.formats.added, { range: list.map((f) => ruleRangeText(f.range)).join(", ") }));
|
|
483
|
+
done();
|
|
484
|
+
}
|
|
485
|
+
/** The menu items that open the dialog, and the rule each starts with. */
|
|
486
|
+
const HIGHLIGHTS = [
|
|
487
|
+
"gt",
|
|
488
|
+
"lt",
|
|
489
|
+
"between",
|
|
490
|
+
"eq",
|
|
491
|
+
"contains",
|
|
492
|
+
"duplicates",
|
|
493
|
+
"formula"
|
|
494
|
+
];
|
|
495
|
+
const RANKS = [
|
|
496
|
+
"top",
|
|
497
|
+
"bottom",
|
|
498
|
+
"above",
|
|
499
|
+
"below"
|
|
500
|
+
];
|
|
501
|
+
function startOf(item, range) {
|
|
502
|
+
const look = { ...LOOKS.danger };
|
|
503
|
+
switch (item) {
|
|
504
|
+
case "duplicates": return {
|
|
505
|
+
range,
|
|
506
|
+
duplicates: true,
|
|
507
|
+
style: look
|
|
508
|
+
};
|
|
509
|
+
case "formula": return {
|
|
510
|
+
range,
|
|
511
|
+
formula: "",
|
|
512
|
+
style: look
|
|
513
|
+
};
|
|
514
|
+
case "top": return {
|
|
515
|
+
range,
|
|
516
|
+
top: 10,
|
|
517
|
+
style: look
|
|
518
|
+
};
|
|
519
|
+
case "bottom": return {
|
|
520
|
+
range,
|
|
521
|
+
bottom: 10,
|
|
522
|
+
style: look
|
|
523
|
+
};
|
|
524
|
+
case "above":
|
|
525
|
+
case "below": return {
|
|
526
|
+
range,
|
|
527
|
+
average: item,
|
|
528
|
+
style: look
|
|
529
|
+
};
|
|
530
|
+
default: return {
|
|
531
|
+
range,
|
|
532
|
+
when: { op: item },
|
|
533
|
+
style: look
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
const dialogFormat = ref({
|
|
538
|
+
range: "",
|
|
539
|
+
when: { op: "gt" },
|
|
540
|
+
style: {}
|
|
541
|
+
});
|
|
542
|
+
const dialogTitle = ref("");
|
|
543
|
+
const dialogOpen = ref(false);
|
|
544
|
+
/** The rule being edited, by its place in the list; `-1` adds one. */
|
|
545
|
+
const editing = ref(-1);
|
|
546
|
+
function openFormat(item) {
|
|
547
|
+
dialogFormat.value = startOf(item, selectedRange());
|
|
548
|
+
dialogTitle.value = m.value.formats[item].replace(/…$/, "");
|
|
549
|
+
editing.value = -1;
|
|
550
|
+
dialogOpen.value = true;
|
|
551
|
+
}
|
|
552
|
+
function editFormat(index) {
|
|
553
|
+
dialogFormat.value = conditionals.value[index];
|
|
554
|
+
dialogTitle.value = m.value.formats.editTitle;
|
|
555
|
+
editing.value = index;
|
|
556
|
+
dialogOpen.value = true;
|
|
557
|
+
}
|
|
558
|
+
function applyFormat(f) {
|
|
559
|
+
if (editing.value < 0) return addFormats([f]);
|
|
560
|
+
const list = [...conditionals.value];
|
|
561
|
+
list[editing.value] = f;
|
|
562
|
+
setFormats(list);
|
|
563
|
+
}
|
|
564
|
+
function dialogClosed() {
|
|
565
|
+
if (!listOpen.value) sheet.focus();
|
|
566
|
+
}
|
|
567
|
+
const validations = computed(() => sheet.sheet.value.validations ?? []);
|
|
568
|
+
const ruleOpen = ref(false);
|
|
569
|
+
const rule = ref({
|
|
570
|
+
range: "",
|
|
571
|
+
list: []
|
|
572
|
+
});
|
|
573
|
+
/** The rule being edited, by its place in the sheet's; `-1` adds one. */
|
|
574
|
+
const ruleIndex = ref(-1);
|
|
575
|
+
/** Opens the rule of the active cell, or a new one for the selection. */
|
|
576
|
+
function openValidation() {
|
|
577
|
+
const { row, col } = active.value;
|
|
578
|
+
ruleIndex.value = validations.value.findIndex((r) => ruleHolds(r.range, row, col));
|
|
579
|
+
rule.value = ruleIndex.value >= 0 ? validations.value[ruleIndex.value] : {
|
|
580
|
+
range: selectedRange(),
|
|
581
|
+
list: []
|
|
582
|
+
};
|
|
583
|
+
ruleOpen.value = true;
|
|
584
|
+
}
|
|
585
|
+
function applyValidation(next) {
|
|
586
|
+
const list = [...validations.value];
|
|
587
|
+
if (ruleIndex.value >= 0) list[ruleIndex.value] = next;
|
|
588
|
+
else list.push(next);
|
|
589
|
+
sheet.transact((tr) => tr.setValidations(list), { action: "validation" });
|
|
590
|
+
sheet.announce(format(m.value.validation.added, { range: ruleRangeText(next.range) }));
|
|
591
|
+
}
|
|
592
|
+
function removeValidation() {
|
|
593
|
+
const gone = validations.value[ruleIndex.value];
|
|
594
|
+
if (!gone) return;
|
|
595
|
+
sheet.transact((tr) => tr.setValidations(validations.value.filter((r) => r !== gone)), { action: "validation" });
|
|
596
|
+
sheet.announce(format(m.value.validation.removed, { range: ruleRangeText(gone.range) }));
|
|
597
|
+
}
|
|
598
|
+
const listOpen = ref(false);
|
|
599
|
+
const conditionals = computed(() => sheet.sheet.value.conditionalFormats ?? []);
|
|
600
|
+
function setFormats(next) {
|
|
601
|
+
sheet.transact((tr) => tr.setConditionalFormats(next), { action: "format" });
|
|
602
|
+
}
|
|
603
|
+
function clearFormats(all) {
|
|
604
|
+
const before = conditionals.value.length;
|
|
605
|
+
sheet.transact((tr) => {
|
|
606
|
+
if (all) tr.clearConditionalFormats();
|
|
607
|
+
else for (const range of selectedRanges()) tr.clearConditionalFormats(range);
|
|
608
|
+
}, { action: "format" });
|
|
609
|
+
const count = before - (sheet.sheet.value.conditionalFormats?.length ?? 0);
|
|
610
|
+
sheet.announce(format(m.value.formats.cleared, { count }));
|
|
611
|
+
done();
|
|
612
|
+
}
|
|
613
|
+
function addScale(colors) {
|
|
614
|
+
addFormats([{
|
|
615
|
+
range: selectedRange(),
|
|
616
|
+
scale: [...colors]
|
|
617
|
+
}]);
|
|
618
|
+
}
|
|
619
|
+
function addBar(tone) {
|
|
620
|
+
addFormats([{
|
|
621
|
+
range: selectedRange(),
|
|
622
|
+
bar: tone
|
|
623
|
+
}]);
|
|
624
|
+
}
|
|
625
|
+
const freeze = computed(() => sheet.sheet.value.freeze ?? {});
|
|
626
|
+
function setFreeze(rows, cols) {
|
|
627
|
+
sheet.transact((tr) => tr.updateSheet({ freeze: rows || cols ? {
|
|
628
|
+
rows: rows || void 0,
|
|
629
|
+
cols: cols || void 0
|
|
630
|
+
} : void 0 }), { action: "freeze" });
|
|
631
|
+
done();
|
|
632
|
+
}
|
|
633
|
+
const freezeItems = computed(() => {
|
|
634
|
+
const { row, col } = active.value;
|
|
635
|
+
const f = freeze.value;
|
|
636
|
+
const items = [{
|
|
637
|
+
key: "row1",
|
|
638
|
+
label: m.value.freezeFirstRow,
|
|
639
|
+
rows: 1,
|
|
640
|
+
cols: f.cols ?? 0
|
|
641
|
+
}, {
|
|
642
|
+
key: "col1",
|
|
643
|
+
label: m.value.freezeFirstCol,
|
|
644
|
+
rows: f.rows ?? 0,
|
|
645
|
+
cols: 1
|
|
646
|
+
}];
|
|
647
|
+
if (row > 0) items.push({
|
|
648
|
+
key: "rows",
|
|
649
|
+
label: format(m.value.freezeRows, { n: row + 1 }),
|
|
650
|
+
rows: row + 1,
|
|
651
|
+
cols: f.cols ?? 0
|
|
652
|
+
});
|
|
653
|
+
if (col > 0) items.push({
|
|
654
|
+
key: "cols",
|
|
655
|
+
label: format(m.value.freezeCols, { col: columnName(col) }),
|
|
656
|
+
rows: f.rows ?? 0,
|
|
657
|
+
cols: col + 1
|
|
658
|
+
});
|
|
659
|
+
return items;
|
|
660
|
+
});
|
|
661
|
+
const frozen = computed(() => !!(freeze.value.rows || freeze.value.cols));
|
|
662
|
+
const bar = useTemplateRef("bar");
|
|
663
|
+
const barEl = computed(() => bar.value?.$el ?? null);
|
|
664
|
+
const more = ref({
|
|
665
|
+
start: false,
|
|
666
|
+
end: false
|
|
667
|
+
});
|
|
668
|
+
function measure() {
|
|
669
|
+
const el = barEl.value;
|
|
670
|
+
if (!el) return;
|
|
671
|
+
const start = el.scrollLeft > 1;
|
|
672
|
+
const end = el.scrollLeft + el.clientWidth < el.scrollWidth - 1;
|
|
673
|
+
if (start !== more.value.start || end !== more.value.end) more.value = {
|
|
674
|
+
start,
|
|
675
|
+
end
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
let observer;
|
|
679
|
+
watch(barEl, (el) => {
|
|
680
|
+
observer?.disconnect();
|
|
681
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
682
|
+
observer = new ResizeObserver(measure);
|
|
683
|
+
observer.observe(el);
|
|
684
|
+
}, { flush: "post" });
|
|
685
|
+
onBeforeUnmount(() => observer?.disconnect());
|
|
686
|
+
return (_ctx, _cache) => {
|
|
687
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
688
|
+
createVNode(unref(DouToolbar), {
|
|
689
|
+
ref_key: "bar",
|
|
690
|
+
ref: bar,
|
|
691
|
+
size: "sm",
|
|
692
|
+
class: normalizeClass(["dou-sheet-toolbar__bar", {
|
|
693
|
+
"has-more-start": more.value.start,
|
|
694
|
+
"has-more-end": more.value.end
|
|
695
|
+
}]),
|
|
696
|
+
"aria-label": unref(m).toolbar,
|
|
697
|
+
onPointerdown: onPointerDown,
|
|
698
|
+
onKeydown: onKeyDown,
|
|
699
|
+
onScrollPassive: measure
|
|
700
|
+
}, {
|
|
701
|
+
default: withCtx(() => [
|
|
702
|
+
renderSlot(_ctx.$slots, "start"),
|
|
703
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(tools.value, (tool, i) => {
|
|
704
|
+
return openBlock(), createElementBlock(Fragment, { key: tool === "|" ? `|${i}` : tool }, [tool === "|" ? (openBlock(), createBlock(unref(DouToolbarSeparator), { key: 0 })) : extras.value.get(tool)?.children ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList([extras.value.get(tool)], (item) => {
|
|
705
|
+
return openBlock(), createBlock(unref(DouTooltip), {
|
|
706
|
+
key: item.key,
|
|
707
|
+
content: item.label,
|
|
708
|
+
disabled: menuOpen.value === tool || !item.icon,
|
|
709
|
+
placement: "bottom"
|
|
710
|
+
}, {
|
|
711
|
+
default: withCtx(() => [createElementVNode("span", _hoisted_2, [createVNode(unref(DouDropdown), {
|
|
712
|
+
open: menuOpen.value === tool,
|
|
713
|
+
placement: "bottom-start",
|
|
714
|
+
disabled: item.disabled,
|
|
715
|
+
"onUpdate:open": ($event) => onMenu(tool, $event)
|
|
716
|
+
}, {
|
|
717
|
+
menu: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(item.children, (child) => {
|
|
718
|
+
return openBlock(), createElementBlock(Fragment, { key: child.key }, [child.children?.length ? (openBlock(), createBlock(unref(DouDropdownSub), {
|
|
719
|
+
key: 0,
|
|
720
|
+
title: childLabel(child),
|
|
721
|
+
divided: child.divided
|
|
722
|
+
}, {
|
|
723
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(child.children, (grand) => {
|
|
724
|
+
return openBlock(), createBlock(unref(DouDropdownItem), {
|
|
725
|
+
key: grand.key,
|
|
726
|
+
disabled: childDisabled(grand),
|
|
727
|
+
divided: grand.divided,
|
|
728
|
+
tone: grand.tone,
|
|
729
|
+
shortcut: coarse.value ? void 0 : childShortcut(grand),
|
|
730
|
+
onClick: ($event) => runChild(grand)
|
|
731
|
+
}, createSlots({
|
|
732
|
+
default: withCtx(() => [createTextVNode(" " + toDisplayString(childLabel(grand)), 1)]),
|
|
733
|
+
_: 2
|
|
734
|
+
}, [childIcon(grand) ? {
|
|
735
|
+
name: "prefix",
|
|
736
|
+
fn: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(childIcon(grand))))]),
|
|
737
|
+
key: "0"
|
|
738
|
+
} : void 0]), 1032, [
|
|
739
|
+
"disabled",
|
|
740
|
+
"divided",
|
|
741
|
+
"tone",
|
|
742
|
+
"shortcut",
|
|
743
|
+
"onClick"
|
|
744
|
+
]);
|
|
745
|
+
}), 128))]),
|
|
746
|
+
_: 2
|
|
747
|
+
}, 1032, ["title", "divided"])) : (openBlock(), createBlock(unref(DouDropdownItem), {
|
|
748
|
+
key: 1,
|
|
749
|
+
disabled: childDisabled(child),
|
|
750
|
+
divided: child.divided,
|
|
751
|
+
tone: child.tone,
|
|
752
|
+
shortcut: coarse.value ? void 0 : childShortcut(child),
|
|
753
|
+
onClick: ($event) => runChild(child)
|
|
754
|
+
}, createSlots({
|
|
755
|
+
default: withCtx(() => [createTextVNode(" " + toDisplayString(childLabel(child)), 1)]),
|
|
756
|
+
_: 2
|
|
757
|
+
}, [childIcon(child) ? {
|
|
758
|
+
name: "prefix",
|
|
759
|
+
fn: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(childIcon(child))))]),
|
|
760
|
+
key: "0"
|
|
761
|
+
} : void 0]), 1032, [
|
|
762
|
+
"disabled",
|
|
763
|
+
"divided",
|
|
764
|
+
"tone",
|
|
765
|
+
"shortcut",
|
|
766
|
+
"onClick"
|
|
767
|
+
]))], 64);
|
|
768
|
+
}), 128))]),
|
|
769
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
770
|
+
variant: "ghost",
|
|
771
|
+
class: "dou-sheet-toolbar__menu",
|
|
772
|
+
"aria-label": item.label
|
|
773
|
+
}, {
|
|
774
|
+
trailing: withCtx(() => [createVNode(unref(ChevronDownIcon))]),
|
|
775
|
+
default: withCtx(() => [item.icon ? (openBlock(), createBlock(resolveDynamicComponent(item.icon), { key: 0 })) : (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(item.label), 1))]),
|
|
776
|
+
_: 2
|
|
777
|
+
}, 1032, ["aria-label"])]),
|
|
778
|
+
_: 2
|
|
779
|
+
}, 1032, [
|
|
780
|
+
"open",
|
|
781
|
+
"disabled",
|
|
782
|
+
"onUpdate:open"
|
|
783
|
+
])])]),
|
|
784
|
+
_: 2
|
|
785
|
+
}, 1032, ["content", "disabled"]);
|
|
786
|
+
}), 128)) : extras.value.get(tool) ? (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList([extras.value.get(tool)], (item) => {
|
|
787
|
+
return openBlock(), createBlock(unref(DouTooltip), {
|
|
788
|
+
key: item.key,
|
|
789
|
+
content: item.label,
|
|
790
|
+
shortcut: item.shortcut,
|
|
791
|
+
disabled: !item.icon && !item.shortcut,
|
|
792
|
+
placement: "bottom"
|
|
793
|
+
}, {
|
|
794
|
+
default: withCtx(() => [item.pressed !== void 0 ? (openBlock(), createBlock(unref(DouToggle), {
|
|
795
|
+
key: 0,
|
|
796
|
+
pressed: item.pressed,
|
|
797
|
+
"aria-label": item.label,
|
|
798
|
+
"aria-keyshortcuts": item.shortcut,
|
|
799
|
+
disabled: item.disabled,
|
|
800
|
+
"onUpdate:pressed": ($event) => runExtra(item)
|
|
801
|
+
}, {
|
|
802
|
+
default: withCtx(() => [item.icon ? (openBlock(), createBlock(resolveDynamicComponent(item.icon), { key: 0 })) : (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(item.label), 1))]),
|
|
803
|
+
_: 2
|
|
804
|
+
}, 1032, [
|
|
805
|
+
"pressed",
|
|
806
|
+
"aria-label",
|
|
807
|
+
"aria-keyshortcuts",
|
|
808
|
+
"disabled",
|
|
809
|
+
"onUpdate:pressed"
|
|
810
|
+
])) : (openBlock(), createBlock(unref(DouButton), {
|
|
811
|
+
key: 1,
|
|
812
|
+
variant: "ghost",
|
|
813
|
+
"aria-label": item.label,
|
|
814
|
+
"aria-keyshortcuts": item.shortcut,
|
|
815
|
+
disabled: item.disabled,
|
|
816
|
+
onClick: ($event) => runExtra(item)
|
|
817
|
+
}, {
|
|
818
|
+
default: withCtx(() => [item.icon ? (openBlock(), createBlock(resolveDynamicComponent(item.icon), { key: 0 })) : (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(item.label), 1))]),
|
|
819
|
+
_: 2
|
|
820
|
+
}, 1032, [
|
|
821
|
+
"aria-label",
|
|
822
|
+
"aria-keyshortcuts",
|
|
823
|
+
"disabled",
|
|
824
|
+
"onClick"
|
|
825
|
+
]))]),
|
|
826
|
+
_: 2
|
|
827
|
+
}, 1032, [
|
|
828
|
+
"content",
|
|
829
|
+
"shortcut",
|
|
830
|
+
"disabled"
|
|
831
|
+
]);
|
|
832
|
+
}), 128)) : tool === "undo" || tool === "redo" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
833
|
+
key: 3,
|
|
834
|
+
content: unref(m)[tool],
|
|
835
|
+
shortcut: tool === "undo" ? "mod+z" : "mod+shift+z",
|
|
836
|
+
placement: "bottom"
|
|
837
|
+
}, {
|
|
838
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
839
|
+
variant: "ghost",
|
|
840
|
+
"aria-label": unref(m)[tool],
|
|
841
|
+
disabled: !can(tool),
|
|
842
|
+
onClick: ($event) => run(tool)
|
|
843
|
+
}, {
|
|
844
|
+
default: withCtx(() => [tool === "undo" ? (openBlock(), createBlock(unref(UndoIcon), { key: 0 })) : (openBlock(), createBlock(unref(RedoIcon), { key: 1 }))]),
|
|
845
|
+
_: 2
|
|
846
|
+
}, 1032, [
|
|
847
|
+
"aria-label",
|
|
848
|
+
"disabled",
|
|
849
|
+
"onClick"
|
|
850
|
+
])]),
|
|
851
|
+
_: 2
|
|
852
|
+
}, 1032, ["content", "shortcut"])) : tool === "format" ? (openBlock(), createBlock(unref(DouDropdown), {
|
|
853
|
+
key: 4,
|
|
854
|
+
open: menuOpen.value === tool,
|
|
855
|
+
placement: "bottom-start",
|
|
856
|
+
disabled: disabled.value,
|
|
857
|
+
"onUpdate:open": ($event) => onMenu(tool, $event)
|
|
858
|
+
}, {
|
|
859
|
+
menu: withCtx(() => [createVNode(unref(DouDropdownRadioGroup), { "model-value": formatShown.value ? formats.value.indexOf(formatShown.value) : -1 }, {
|
|
860
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(formats.value, (option, i) => {
|
|
861
|
+
return openBlock(), createBlock(unref(DouDropdownItem), {
|
|
862
|
+
key: option.label,
|
|
863
|
+
value: i,
|
|
864
|
+
class: "dou-sheet-toolbar__format-item",
|
|
865
|
+
onClick: ($event) => setFormat(option)
|
|
866
|
+
}, {
|
|
867
|
+
suffix: withCtx(() => [createElementVNode("span", _hoisted_7, toDisplayString(exampleOf(option)), 1)]),
|
|
868
|
+
default: withCtx(() => [createTextVNode(toDisplayString(option.label) + " ", 1)]),
|
|
869
|
+
_: 2
|
|
870
|
+
}, 1032, ["value", "onClick"]);
|
|
871
|
+
}), 128))]),
|
|
872
|
+
_: 2
|
|
873
|
+
}, 1032, ["model-value"])]),
|
|
874
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
875
|
+
variant: "ghost",
|
|
876
|
+
class: "dou-sheet-toolbar__format",
|
|
877
|
+
"aria-label": `${unref(m).numberFormat}:${formatLabel.value}`
|
|
878
|
+
}, {
|
|
879
|
+
trailing: withCtx(() => [createVNode(unref(ChevronDownIcon))]),
|
|
880
|
+
default: withCtx(() => [createElementVNode("span", _hoisted_6, toDisplayString(formatLabel.value), 1)]),
|
|
881
|
+
_: 1
|
|
882
|
+
}, 8, ["aria-label"])]),
|
|
883
|
+
_: 2
|
|
884
|
+
}, 1032, [
|
|
885
|
+
"open",
|
|
886
|
+
"disabled",
|
|
887
|
+
"onUpdate:open"
|
|
888
|
+
])) : tool === "decimals" ? (openBlock(), createElementBlock(Fragment, { key: 5 }, renderList([-1, 1], (by) => {
|
|
889
|
+
return createVNode(unref(DouTooltip), {
|
|
890
|
+
key: by,
|
|
891
|
+
content: by < 0 ? unref(m).fewerDecimals : unref(m).moreDecimals,
|
|
892
|
+
placement: "bottom"
|
|
893
|
+
}, {
|
|
894
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
895
|
+
variant: "ghost",
|
|
896
|
+
"aria-label": by < 0 ? unref(m).fewerDecimals : unref(m).moreDecimals,
|
|
897
|
+
disabled: !can(by < 0 ? "decimals.fewer" : "decimals.more"),
|
|
898
|
+
onClick: ($event) => run(by < 0 ? "decimals.fewer" : "decimals.more")
|
|
899
|
+
}, {
|
|
900
|
+
default: withCtx(() => [by < 0 ? (openBlock(), createBlock(unref(DecimalDecreaseIcon), { key: 0 })) : (openBlock(), createBlock(unref(DecimalIncreaseIcon), { key: 1 }))]),
|
|
901
|
+
_: 2
|
|
902
|
+
}, 1032, [
|
|
903
|
+
"aria-label",
|
|
904
|
+
"disabled",
|
|
905
|
+
"onClick"
|
|
906
|
+
])]),
|
|
907
|
+
_: 2
|
|
908
|
+
}, 1032, ["content"]);
|
|
909
|
+
}), 64)) : isStyleTool(tool) ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
910
|
+
key: 6,
|
|
911
|
+
content: unref(m)[tool],
|
|
912
|
+
shortcut: STYLE[tool].key,
|
|
913
|
+
placement: "bottom"
|
|
914
|
+
}, {
|
|
915
|
+
default: withCtx(() => [createVNode(unref(DouToggle), {
|
|
916
|
+
pressed: on(tool),
|
|
917
|
+
"aria-label": unref(m)[tool],
|
|
918
|
+
disabled: !can(tool),
|
|
919
|
+
"onUpdate:pressed": ($event) => run(tool, $event)
|
|
920
|
+
}, {
|
|
921
|
+
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(STYLE[tool].icon)))]),
|
|
922
|
+
_: 2
|
|
923
|
+
}, 1032, [
|
|
924
|
+
"pressed",
|
|
925
|
+
"aria-label",
|
|
926
|
+
"disabled",
|
|
927
|
+
"onUpdate:pressed"
|
|
928
|
+
])]),
|
|
929
|
+
_: 2
|
|
930
|
+
}, 1032, ["content", "shortcut"])) : tool === "color" || tool === "fill" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
931
|
+
key: 7,
|
|
932
|
+
content: tool === "color" ? unref(m).textColor : unref(m).fillColor,
|
|
933
|
+
disabled: colorOpen.value === tool,
|
|
934
|
+
placement: "bottom"
|
|
935
|
+
}, {
|
|
936
|
+
default: withCtx(() => [createElementVNode("span", _hoisted_8, [createVNode(unref(DouPopover), {
|
|
937
|
+
open: colorOpen.value === tool,
|
|
938
|
+
placement: "bottom-start",
|
|
939
|
+
disabled: disabled.value,
|
|
940
|
+
"onUpdate:open": ($event) => colorOpen.value = $event ? tool : colorOpen.value === tool ? null : colorOpen.value
|
|
941
|
+
}, {
|
|
942
|
+
content: withCtx(() => [createElementVNode("div", {
|
|
943
|
+
class: "dou-sheet-toolbar__colors",
|
|
944
|
+
"aria-label": tool === "color" ? unref(m).textColor : unref(m).fillColor,
|
|
945
|
+
role: "group"
|
|
946
|
+
}, [
|
|
947
|
+
createElementVNode("button", {
|
|
948
|
+
type: "button",
|
|
949
|
+
class: normalizeClass(["dou-sheet-toolbar__swatch is-default", `is-${tool}`]),
|
|
950
|
+
"aria-pressed": !colorOf(tool).tone && !colorOf(tool).css,
|
|
951
|
+
"aria-label": unref(m).colorDefault,
|
|
952
|
+
title: unref(m).colorDefault,
|
|
953
|
+
onClick: ($event) => setColor(tool, {})
|
|
954
|
+
}, null, 10, _hoisted_10),
|
|
955
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(TONES), (tone) => {
|
|
956
|
+
return openBlock(), createElementBlock("button", {
|
|
957
|
+
key: tone,
|
|
958
|
+
type: "button",
|
|
959
|
+
class: normalizeClass(["dou-sheet-toolbar__swatch", [`is-${tool}`, `is-tone-${tone}`]]),
|
|
960
|
+
"aria-pressed": colorOf(tool).tone === tone,
|
|
961
|
+
"aria-label": toneLabel(tone),
|
|
962
|
+
title: toneLabel(tone),
|
|
963
|
+
onClick: ($event) => setColor(tool, { tone })
|
|
964
|
+
}, [tool === "color" ? (openBlock(), createElementBlock("span", _hoisted_12, "A")) : createCommentVNode("", true)], 10, _hoisted_11);
|
|
965
|
+
}), 128)),
|
|
966
|
+
createElementVNode("button", {
|
|
967
|
+
type: "button",
|
|
968
|
+
class: normalizeClass(["dou-sheet-toolbar__swatch is-custom", `is-${tool}`]),
|
|
969
|
+
"aria-pressed": !!colorOf(tool).css,
|
|
970
|
+
"aria-expanded": custom.value === tool,
|
|
971
|
+
"aria-label": unref(m).colorCustom,
|
|
972
|
+
title: unref(m).colorCustom,
|
|
973
|
+
style: normalizeStyle({ "--dou-sheet-swatch": colorOf(tool).css }),
|
|
974
|
+
onClick: ($event) => openCustom(tool, $event)
|
|
975
|
+
}, [colorOf(tool).css && tool === "color" ? (openBlock(), createElementBlock("span", _hoisted_14, "A")) : !colorOf(tool).css ? (openBlock(), createBlock(unref(PaletteIcon), { key: 1 })) : createCommentVNode("", true)], 14, _hoisted_13)
|
|
976
|
+
], 8, _hoisted_9), custom.value === tool ? (openBlock(), createBlock(unref(DouColorPanel), {
|
|
977
|
+
key: 0,
|
|
978
|
+
modelValue: customColor.value,
|
|
979
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => customColor.value = $event),
|
|
980
|
+
class: "dou-sheet-toolbar__panel",
|
|
981
|
+
bordered: false,
|
|
982
|
+
format: "hex",
|
|
983
|
+
"show-input": "",
|
|
984
|
+
onChange: ($event) => $event && setColor(tool, { css: $event }, false)
|
|
985
|
+
}, null, 8, ["modelValue", "onChange"])) : createCommentVNode("", true)]),
|
|
986
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
987
|
+
variant: "ghost",
|
|
988
|
+
class: normalizeClass(["dou-sheet-toolbar__color", `is-${tool}`]),
|
|
989
|
+
style: normalizeStyle({ "--dou-sheet-swatch": swatchOf(tool) }),
|
|
990
|
+
"aria-label": tool === "color" ? unref(m).textColor : unref(m).fillColor,
|
|
991
|
+
"aria-expanded": colorOpen.value === tool
|
|
992
|
+
}, {
|
|
993
|
+
default: withCtx(() => [tool === "color" ? (openBlock(), createBlock(unref(BaselineIcon), { key: 0 })) : (openBlock(), createBlock(unref(PaintBucketIcon), { key: 1 }))]),
|
|
994
|
+
_: 2
|
|
995
|
+
}, 1032, [
|
|
996
|
+
"class",
|
|
997
|
+
"style",
|
|
998
|
+
"aria-label",
|
|
999
|
+
"aria-expanded"
|
|
1000
|
+
])]),
|
|
1001
|
+
_: 2
|
|
1002
|
+
}, 1032, [
|
|
1003
|
+
"open",
|
|
1004
|
+
"disabled",
|
|
1005
|
+
"onUpdate:open"
|
|
1006
|
+
])])]),
|
|
1007
|
+
_: 2
|
|
1008
|
+
}, 1032, ["content", "disabled"])) : tool === "align" ? (openBlock(), createBlock(unref(DouToggleGroup), {
|
|
1009
|
+
key: 8,
|
|
1010
|
+
type: "single",
|
|
1011
|
+
"model-value": align.value,
|
|
1012
|
+
disabled: disabled.value,
|
|
1013
|
+
"onUpdate:modelValue": setAlign
|
|
1014
|
+
}, {
|
|
1015
|
+
default: withCtx(() => [(openBlock(), createElementBlock(Fragment, null, renderList(ALIGN, (a) => {
|
|
1016
|
+
return createVNode(unref(DouTooltip), {
|
|
1017
|
+
key: a.value,
|
|
1018
|
+
content: unref(m)[a.label],
|
|
1019
|
+
placement: "bottom"
|
|
1020
|
+
}, {
|
|
1021
|
+
default: withCtx(() => [createVNode(unref(DouToggle), {
|
|
1022
|
+
value: a.value,
|
|
1023
|
+
"aria-label": unref(m)[a.label]
|
|
1024
|
+
}, {
|
|
1025
|
+
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(a.icon)))]),
|
|
1026
|
+
_: 2
|
|
1027
|
+
}, 1032, ["value", "aria-label"])]),
|
|
1028
|
+
_: 2
|
|
1029
|
+
}, 1032, ["content"]);
|
|
1030
|
+
}), 64))]),
|
|
1031
|
+
_: 1
|
|
1032
|
+
}, 8, ["model-value", "disabled"])) : tool === "valign" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
1033
|
+
key: 9,
|
|
1034
|
+
content: unref(m).verticalAlign,
|
|
1035
|
+
disabled: menuOpen.value === tool,
|
|
1036
|
+
placement: "bottom"
|
|
1037
|
+
}, {
|
|
1038
|
+
default: withCtx(() => [createElementVNode("span", _hoisted_15, [createVNode(unref(DouDropdown), {
|
|
1039
|
+
open: menuOpen.value === tool,
|
|
1040
|
+
placement: "bottom-start",
|
|
1041
|
+
disabled: disabled.value,
|
|
1042
|
+
"onUpdate:open": ($event) => onMenu(tool, $event)
|
|
1043
|
+
}, {
|
|
1044
|
+
menu: withCtx(() => [createVNode(unref(DouDropdownRadioGroup), { "model-value": valign.value }, {
|
|
1045
|
+
default: withCtx(() => [(openBlock(), createElementBlock(Fragment, null, renderList(VALIGN, (v) => {
|
|
1046
|
+
return createVNode(unref(DouDropdownItem), {
|
|
1047
|
+
key: v.value,
|
|
1048
|
+
value: v.value,
|
|
1049
|
+
disabled: !can(`valign.${v.value}`),
|
|
1050
|
+
onClick: ($event) => run(`valign.${v.value}`)
|
|
1051
|
+
}, {
|
|
1052
|
+
prefix: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(v.icon)))]),
|
|
1053
|
+
default: withCtx(() => [createTextVNode(" " + toDisplayString(unref(m)[v.label]), 1)]),
|
|
1054
|
+
_: 2
|
|
1055
|
+
}, 1032, [
|
|
1056
|
+
"value",
|
|
1057
|
+
"disabled",
|
|
1058
|
+
"onClick"
|
|
1059
|
+
]);
|
|
1060
|
+
}), 64))]),
|
|
1061
|
+
_: 1
|
|
1062
|
+
}, 8, ["model-value"])]),
|
|
1063
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
1064
|
+
variant: "ghost",
|
|
1065
|
+
class: "dou-sheet-toolbar__menu",
|
|
1066
|
+
"aria-label": unref(m).verticalAlign
|
|
1067
|
+
}, {
|
|
1068
|
+
trailing: withCtx(() => [createVNode(unref(ChevronDownIcon))]),
|
|
1069
|
+
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(valignIcon.value)))]),
|
|
1070
|
+
_: 1
|
|
1071
|
+
}, 8, ["aria-label"])]),
|
|
1072
|
+
_: 1
|
|
1073
|
+
}, 8, [
|
|
1074
|
+
"open",
|
|
1075
|
+
"disabled",
|
|
1076
|
+
"onUpdate:open"
|
|
1077
|
+
])])]),
|
|
1078
|
+
_: 2
|
|
1079
|
+
}, 1032, ["content", "disabled"])) : tool === "wrap" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
1080
|
+
key: 10,
|
|
1081
|
+
content: unref(m).wrap,
|
|
1082
|
+
placement: "bottom"
|
|
1083
|
+
}, {
|
|
1084
|
+
default: withCtx(() => [createVNode(unref(DouToggle), {
|
|
1085
|
+
pressed: on("wrap"),
|
|
1086
|
+
"aria-label": unref(m).wrap,
|
|
1087
|
+
disabled: !can("wrap"),
|
|
1088
|
+
"onUpdate:pressed": _cache[1] || (_cache[1] = ($event) => run("wrap", $event))
|
|
1089
|
+
}, {
|
|
1090
|
+
default: withCtx(() => [createVNode(unref(WrapTextIcon))]),
|
|
1091
|
+
_: 1
|
|
1092
|
+
}, 8, [
|
|
1093
|
+
"pressed",
|
|
1094
|
+
"aria-label",
|
|
1095
|
+
"disabled"
|
|
1096
|
+
])]),
|
|
1097
|
+
_: 1
|
|
1098
|
+
}, 8, ["content"])) : tool === "merge" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
1099
|
+
key: 11,
|
|
1100
|
+
content: unref(sheet).commands.get("merge")?.label,
|
|
1101
|
+
placement: "bottom"
|
|
1102
|
+
}, {
|
|
1103
|
+
default: withCtx(() => [createVNode(unref(DouToggle), {
|
|
1104
|
+
pressed: on("merge"),
|
|
1105
|
+
"aria-label": unref(m).mergeCells,
|
|
1106
|
+
disabled: !can("merge"),
|
|
1107
|
+
"onUpdate:pressed": _cache[2] || (_cache[2] = ($event) => run("merge"))
|
|
1108
|
+
}, {
|
|
1109
|
+
default: withCtx(() => [createVNode(unref(CellsMergeIcon))]),
|
|
1110
|
+
_: 1
|
|
1111
|
+
}, 8, [
|
|
1112
|
+
"pressed",
|
|
1113
|
+
"aria-label",
|
|
1114
|
+
"disabled"
|
|
1115
|
+
])]),
|
|
1116
|
+
_: 1
|
|
1117
|
+
}, 8, ["content"])) : tool === "link" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
1118
|
+
key: 12,
|
|
1119
|
+
content: unref(m).link.add,
|
|
1120
|
+
shortcut: "mod+k",
|
|
1121
|
+
placement: "bottom"
|
|
1122
|
+
}, {
|
|
1123
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
1124
|
+
variant: "ghost",
|
|
1125
|
+
"aria-label": unref(m).link.add,
|
|
1126
|
+
disabled: !can("link"),
|
|
1127
|
+
onClick: _cache[3] || (_cache[3] = ($event) => run("link"))
|
|
1128
|
+
}, {
|
|
1129
|
+
default: withCtx(() => [createVNode(unref(LinkIcon))]),
|
|
1130
|
+
_: 1
|
|
1131
|
+
}, 8, ["aria-label", "disabled"])]),
|
|
1132
|
+
_: 1
|
|
1133
|
+
}, 8, ["content"])) : tool === "protect" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
1134
|
+
key: 13,
|
|
1135
|
+
content: unref(m).protect.menu,
|
|
1136
|
+
disabled: menuOpen.value === tool,
|
|
1137
|
+
placement: "bottom"
|
|
1138
|
+
}, {
|
|
1139
|
+
default: withCtx(() => [createElementVNode("span", _hoisted_16, [createVNode(unref(DouDropdown), {
|
|
1140
|
+
open: menuOpen.value === tool,
|
|
1141
|
+
placement: "bottom-start",
|
|
1142
|
+
disabled: disabled.value,
|
|
1143
|
+
"onUpdate:open": ($event) => onMenu(tool, $event)
|
|
1144
|
+
}, {
|
|
1145
|
+
menu: withCtx(() => [(openBlock(), createElementBlock(Fragment, null, renderList(PROTECT_COMMANDS, (name) => {
|
|
1146
|
+
return createVNode(unref(DouDropdownItem), {
|
|
1147
|
+
key: name,
|
|
1148
|
+
disabled: !can(name),
|
|
1149
|
+
divided: name === "protect.sheet",
|
|
1150
|
+
onClick: ($event) => run(name)
|
|
1151
|
+
}, {
|
|
1152
|
+
prefix: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(unref(sheet).commands.get(name)?.icon)))]),
|
|
1153
|
+
default: withCtx(() => [createTextVNode(" " + toDisplayString(unref(sheet).commands.get(name)?.label), 1)]),
|
|
1154
|
+
_: 2
|
|
1155
|
+
}, 1032, [
|
|
1156
|
+
"disabled",
|
|
1157
|
+
"divided",
|
|
1158
|
+
"onClick"
|
|
1159
|
+
]);
|
|
1160
|
+
}), 64))]),
|
|
1161
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
1162
|
+
variant: "ghost",
|
|
1163
|
+
class: normalizeClass(["dou-sheet-toolbar__menu", { "is-on": on("protect.sheet") }]),
|
|
1164
|
+
"aria-label": unref(m).protect.menu
|
|
1165
|
+
}, {
|
|
1166
|
+
trailing: withCtx(() => [createVNode(unref(ChevronDownIcon))]),
|
|
1167
|
+
default: withCtx(() => [createVNode(unref(ShieldLockIcon))]),
|
|
1168
|
+
_: 1
|
|
1169
|
+
}, 8, ["class", "aria-label"])]),
|
|
1170
|
+
_: 1
|
|
1171
|
+
}, 8, [
|
|
1172
|
+
"open",
|
|
1173
|
+
"disabled",
|
|
1174
|
+
"onUpdate:open"
|
|
1175
|
+
])])]),
|
|
1176
|
+
_: 2
|
|
1177
|
+
}, 1032, ["content", "disabled"])) : tool === "freeze" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
1178
|
+
key: 14,
|
|
1179
|
+
content: unref(m).freeze,
|
|
1180
|
+
disabled: menuOpen.value === tool,
|
|
1181
|
+
placement: "bottom"
|
|
1182
|
+
}, {
|
|
1183
|
+
default: withCtx(() => [createElementVNode("span", _hoisted_17, [createVNode(unref(DouDropdown), {
|
|
1184
|
+
open: menuOpen.value === tool,
|
|
1185
|
+
placement: "bottom-start",
|
|
1186
|
+
disabled: disabled.value,
|
|
1187
|
+
"onUpdate:open": ($event) => onMenu(tool, $event)
|
|
1188
|
+
}, {
|
|
1189
|
+
menu: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(freezeItems.value, (item) => {
|
|
1190
|
+
return openBlock(), createBlock(unref(DouDropdownItem), {
|
|
1191
|
+
key: item.key,
|
|
1192
|
+
checked: (freeze.value.rows ?? 0) === item.rows && (freeze.value.cols ?? 0) === item.cols,
|
|
1193
|
+
onClick: ($event) => setFreeze(item.rows, item.cols)
|
|
1194
|
+
}, {
|
|
1195
|
+
default: withCtx(() => [createTextVNode(toDisplayString(item.label), 1)]),
|
|
1196
|
+
_: 2
|
|
1197
|
+
}, 1032, ["checked", "onClick"]);
|
|
1198
|
+
}), 128)), createVNode(unref(DouDropdownItem), {
|
|
1199
|
+
divided: "",
|
|
1200
|
+
disabled: !frozen.value,
|
|
1201
|
+
onClick: _cache[4] || (_cache[4] = ($event) => setFreeze(0, 0))
|
|
1202
|
+
}, {
|
|
1203
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(m).unfreeze), 1)]),
|
|
1204
|
+
_: 1
|
|
1205
|
+
}, 8, ["disabled"])]),
|
|
1206
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
1207
|
+
variant: "ghost",
|
|
1208
|
+
class: normalizeClass(["dou-sheet-toolbar__menu", { "is-on": frozen.value }]),
|
|
1209
|
+
"aria-label": unref(m).freeze
|
|
1210
|
+
}, {
|
|
1211
|
+
trailing: withCtx(() => [createVNode(unref(ChevronDownIcon))]),
|
|
1212
|
+
default: withCtx(() => [createVNode(unref(TableFreezeIcon))]),
|
|
1213
|
+
_: 1
|
|
1214
|
+
}, 8, ["class", "aria-label"])]),
|
|
1215
|
+
_: 1
|
|
1216
|
+
}, 8, [
|
|
1217
|
+
"open",
|
|
1218
|
+
"disabled",
|
|
1219
|
+
"onUpdate:open"
|
|
1220
|
+
])])]),
|
|
1221
|
+
_: 2
|
|
1222
|
+
}, 1032, ["content", "disabled"])) : tool === "sort" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
1223
|
+
key: 15,
|
|
1224
|
+
content: unref(m).filter.sort,
|
|
1225
|
+
disabled: menuOpen.value === tool,
|
|
1226
|
+
placement: "bottom"
|
|
1227
|
+
}, {
|
|
1228
|
+
default: withCtx(() => [createElementVNode("span", _hoisted_18, [createVNode(unref(DouDropdown), {
|
|
1229
|
+
open: menuOpen.value === tool,
|
|
1230
|
+
placement: "bottom-start",
|
|
1231
|
+
disabled: disabled.value,
|
|
1232
|
+
"onUpdate:open": ($event) => onMenu(tool, $event)
|
|
1233
|
+
}, {
|
|
1234
|
+
menu: withCtx(() => [createVNode(unref(DouDropdownItem), {
|
|
1235
|
+
disabled: !can("sort.asc"),
|
|
1236
|
+
onClick: _cache[5] || (_cache[5] = ($event) => run("sort.asc"))
|
|
1237
|
+
}, {
|
|
1238
|
+
prefix: withCtx(() => [createVNode(unref(SortAscendingIcon))]),
|
|
1239
|
+
default: withCtx(() => [createTextVNode(" " + toDisplayString(unref(m).filter.sortAsc), 1)]),
|
|
1240
|
+
_: 1
|
|
1241
|
+
}, 8, ["disabled"]), createVNode(unref(DouDropdownItem), {
|
|
1242
|
+
disabled: !can("sort.desc"),
|
|
1243
|
+
onClick: _cache[6] || (_cache[6] = ($event) => run("sort.desc"))
|
|
1244
|
+
}, {
|
|
1245
|
+
prefix: withCtx(() => [createVNode(unref(SortDescendingIcon))]),
|
|
1246
|
+
default: withCtx(() => [createTextVNode(" " + toDisplayString(unref(m).filter.sortDesc), 1)]),
|
|
1247
|
+
_: 1
|
|
1248
|
+
}, 8, ["disabled"])]),
|
|
1249
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
1250
|
+
variant: "ghost",
|
|
1251
|
+
class: "dou-sheet-toolbar__menu",
|
|
1252
|
+
"aria-label": unref(m).filter.sort
|
|
1253
|
+
}, {
|
|
1254
|
+
trailing: withCtx(() => [createVNode(unref(ChevronDownIcon))]),
|
|
1255
|
+
default: withCtx(() => [createVNode(unref(SortIcon))]),
|
|
1256
|
+
_: 1
|
|
1257
|
+
}, 8, ["aria-label"])]),
|
|
1258
|
+
_: 1
|
|
1259
|
+
}, 8, [
|
|
1260
|
+
"open",
|
|
1261
|
+
"disabled",
|
|
1262
|
+
"onUpdate:open"
|
|
1263
|
+
])])]),
|
|
1264
|
+
_: 2
|
|
1265
|
+
}, 1032, ["content", "disabled"])) : tool === "filter" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
1266
|
+
key: 16,
|
|
1267
|
+
content: unref(sheet).commands.get("filter")?.label,
|
|
1268
|
+
placement: "bottom"
|
|
1269
|
+
}, {
|
|
1270
|
+
default: withCtx(() => [createVNode(unref(DouToggle), {
|
|
1271
|
+
pressed: on("filter"),
|
|
1272
|
+
"aria-label": unref(m).filter.turnOn,
|
|
1273
|
+
disabled: !can("filter"),
|
|
1274
|
+
"onUpdate:pressed": _cache[7] || (_cache[7] = ($event) => run("filter"))
|
|
1275
|
+
}, {
|
|
1276
|
+
default: withCtx(() => [createVNode(unref(FilterIcon))]),
|
|
1277
|
+
_: 1
|
|
1278
|
+
}, 8, [
|
|
1279
|
+
"pressed",
|
|
1280
|
+
"aria-label",
|
|
1281
|
+
"disabled"
|
|
1282
|
+
])]),
|
|
1283
|
+
_: 1
|
|
1284
|
+
}, 8, ["content"])) : tool === "conditional" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
1285
|
+
key: 17,
|
|
1286
|
+
content: unref(m).formats.title,
|
|
1287
|
+
disabled: menuOpen.value === tool,
|
|
1288
|
+
placement: "bottom"
|
|
1289
|
+
}, {
|
|
1290
|
+
default: withCtx(() => [createElementVNode("span", _hoisted_19, [createVNode(unref(DouDropdown), {
|
|
1291
|
+
open: menuOpen.value === tool,
|
|
1292
|
+
placement: "bottom-start",
|
|
1293
|
+
disabled: disabled.value,
|
|
1294
|
+
"onUpdate:open": ($event) => onMenu(tool, $event)
|
|
1295
|
+
}, {
|
|
1296
|
+
menu: withCtx(() => [
|
|
1297
|
+
createVNode(unref(DouDropdownSub), { title: unref(m).formats.highlight }, {
|
|
1298
|
+
default: withCtx(() => [(openBlock(), createElementBlock(Fragment, null, renderList(HIGHLIGHTS, (kind) => {
|
|
1299
|
+
return createVNode(unref(DouDropdownItem), {
|
|
1300
|
+
key: kind,
|
|
1301
|
+
onClick: ($event) => openFormat(kind)
|
|
1302
|
+
}, {
|
|
1303
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(m).formats[kind]), 1)]),
|
|
1304
|
+
_: 2
|
|
1305
|
+
}, 1032, ["onClick"]);
|
|
1306
|
+
}), 64))]),
|
|
1307
|
+
_: 1
|
|
1308
|
+
}, 8, ["title"]),
|
|
1309
|
+
createVNode(unref(DouDropdownSub), { title: unref(m).formats.ranks }, {
|
|
1310
|
+
default: withCtx(() => [(openBlock(), createElementBlock(Fragment, null, renderList(RANKS, (kind) => {
|
|
1311
|
+
return createVNode(unref(DouDropdownItem), {
|
|
1312
|
+
key: kind,
|
|
1313
|
+
onClick: ($event) => openFormat(kind)
|
|
1314
|
+
}, {
|
|
1315
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(m).formats[kind]), 1)]),
|
|
1316
|
+
_: 2
|
|
1317
|
+
}, 1032, ["onClick"]);
|
|
1318
|
+
}), 64))]),
|
|
1319
|
+
_: 1
|
|
1320
|
+
}, 8, ["title"]),
|
|
1321
|
+
createVNode(unref(DouDropdownSub), { title: unref(m).formats.bar }, {
|
|
1322
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(TONES), (tone) => {
|
|
1323
|
+
return openBlock(), createBlock(unref(DouDropdownItem), {
|
|
1324
|
+
key: tone,
|
|
1325
|
+
onClick: ($event) => addBar(tone)
|
|
1326
|
+
}, {
|
|
1327
|
+
prefix: withCtx(() => [createElementVNode("span", {
|
|
1328
|
+
class: "dou-sheet-toolbar__gradient",
|
|
1329
|
+
style: normalizeStyle({ backgroundImage: unref(barSwatch)(tone) })
|
|
1330
|
+
}, null, 4)]),
|
|
1331
|
+
default: withCtx(() => [createTextVNode(" " + toDisplayString(toneLabel(tone)), 1)]),
|
|
1332
|
+
_: 2
|
|
1333
|
+
}, 1032, ["onClick"]);
|
|
1334
|
+
}), 128))]),
|
|
1335
|
+
_: 1
|
|
1336
|
+
}, 8, ["title"]),
|
|
1337
|
+
createVNode(unref(DouDropdownSub), { title: unref(m).formats.scale }, {
|
|
1338
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(SCALES), (colors, key) => {
|
|
1339
|
+
return openBlock(), createBlock(unref(DouDropdownItem), {
|
|
1340
|
+
key,
|
|
1341
|
+
onClick: ($event) => addScale(colors)
|
|
1342
|
+
}, {
|
|
1343
|
+
prefix: withCtx(() => [createElementVNode("span", {
|
|
1344
|
+
class: "dou-sheet-toolbar__gradient",
|
|
1345
|
+
style: normalizeStyle({ backgroundImage: unref(scaleSwatch)(colors) })
|
|
1346
|
+
}, null, 4)]),
|
|
1347
|
+
default: withCtx(() => [createTextVNode(" " + toDisplayString(unref(m).formats.scales[key]), 1)]),
|
|
1348
|
+
_: 2
|
|
1349
|
+
}, 1032, ["onClick"]);
|
|
1350
|
+
}), 128))]),
|
|
1351
|
+
_: 1
|
|
1352
|
+
}, 8, ["title"]),
|
|
1353
|
+
createVNode(unref(DouDropdownItem), {
|
|
1354
|
+
divided: "",
|
|
1355
|
+
onClick: _cache[8] || (_cache[8] = ($event) => clearFormats(false))
|
|
1356
|
+
}, {
|
|
1357
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(m).formats.clearSelection), 1)]),
|
|
1358
|
+
_: 1
|
|
1359
|
+
}),
|
|
1360
|
+
createVNode(unref(DouDropdownItem), {
|
|
1361
|
+
disabled: !conditionals.value.length,
|
|
1362
|
+
onClick: _cache[9] || (_cache[9] = ($event) => clearFormats(true))
|
|
1363
|
+
}, {
|
|
1364
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(m).formats.clearSheet), 1)]),
|
|
1365
|
+
_: 1
|
|
1366
|
+
}, 8, ["disabled"]),
|
|
1367
|
+
createVNode(unref(DouDropdownItem), {
|
|
1368
|
+
divided: "",
|
|
1369
|
+
onClick: _cache[10] || (_cache[10] = ($event) => listOpen.value = true)
|
|
1370
|
+
}, {
|
|
1371
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(m).formats.manage), 1)]),
|
|
1372
|
+
_: 1
|
|
1373
|
+
})
|
|
1374
|
+
]),
|
|
1375
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
1376
|
+
variant: "ghost",
|
|
1377
|
+
class: "dou-sheet-toolbar__menu",
|
|
1378
|
+
"aria-label": unref(m).formats.title
|
|
1379
|
+
}, {
|
|
1380
|
+
trailing: withCtx(() => [createVNode(unref(ChevronDownIcon))]),
|
|
1381
|
+
default: withCtx(() => [createVNode(unref(TableHighlightIcon))]),
|
|
1382
|
+
_: 1
|
|
1383
|
+
}, 8, ["aria-label"])]),
|
|
1384
|
+
_: 1
|
|
1385
|
+
}, 8, [
|
|
1386
|
+
"open",
|
|
1387
|
+
"disabled",
|
|
1388
|
+
"onUpdate:open"
|
|
1389
|
+
])])]),
|
|
1390
|
+
_: 2
|
|
1391
|
+
}, 1032, ["content", "disabled"])) : tool === "export" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
1392
|
+
key: 18,
|
|
1393
|
+
content: unref(m).file.export,
|
|
1394
|
+
disabled: menuOpen.value === tool,
|
|
1395
|
+
placement: "bottom"
|
|
1396
|
+
}, {
|
|
1397
|
+
default: withCtx(() => [createElementVNode("span", _hoisted_20, [createVNode(unref(DouDropdown), {
|
|
1398
|
+
open: menuOpen.value === tool,
|
|
1399
|
+
placement: "bottom-start",
|
|
1400
|
+
"onUpdate:open": ($event) => onMenu(tool, $event)
|
|
1401
|
+
}, {
|
|
1402
|
+
menu: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(exportItems.value, (item) => {
|
|
1403
|
+
return openBlock(), createElementBlock(Fragment, { key: item.name }, [item.scopes.length ? (openBlock(), createBlock(unref(DouDropdownSub), {
|
|
1404
|
+
key: 0,
|
|
1405
|
+
title: item.label
|
|
1406
|
+
}, createSlots({
|
|
1407
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(item.scopes, (scope) => {
|
|
1408
|
+
return openBlock(), createBlock(unref(DouDropdownItem), {
|
|
1409
|
+
key: scope,
|
|
1410
|
+
onClick: ($event) => exportWith(item.name, scope)
|
|
1411
|
+
}, {
|
|
1412
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(m).file[scope]), 1)]),
|
|
1413
|
+
_: 2
|
|
1414
|
+
}, 1032, ["onClick"]);
|
|
1415
|
+
}), 128))]),
|
|
1416
|
+
_: 2
|
|
1417
|
+
}, [item.icon ? {
|
|
1418
|
+
name: "prefix",
|
|
1419
|
+
fn: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(item.icon)))]),
|
|
1420
|
+
key: "0"
|
|
1421
|
+
} : void 0]), 1032, ["title"])) : (openBlock(), createBlock(unref(DouDropdownItem), {
|
|
1422
|
+
key: 1,
|
|
1423
|
+
onClick: ($event) => exportWith(item.name, item.scope)
|
|
1424
|
+
}, createSlots({
|
|
1425
|
+
default: withCtx(() => [createTextVNode(" " + toDisplayString(item.label), 1)]),
|
|
1426
|
+
_: 2
|
|
1427
|
+
}, [item.icon ? {
|
|
1428
|
+
name: "prefix",
|
|
1429
|
+
fn: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(item.icon)))]),
|
|
1430
|
+
key: "0"
|
|
1431
|
+
} : void 0]), 1032, ["onClick"]))], 64);
|
|
1432
|
+
}), 128))]),
|
|
1433
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
1434
|
+
variant: "ghost",
|
|
1435
|
+
class: "dou-sheet-toolbar__menu",
|
|
1436
|
+
"aria-label": unref(m).file.export
|
|
1437
|
+
}, {
|
|
1438
|
+
trailing: withCtx(() => [createVNode(unref(ChevronDownIcon))]),
|
|
1439
|
+
default: withCtx(() => [createVNode(unref(DownloadIcon))]),
|
|
1440
|
+
_: 1
|
|
1441
|
+
}, 8, ["aria-label"])]),
|
|
1442
|
+
_: 1
|
|
1443
|
+
}, 8, ["open", "onUpdate:open"])])]),
|
|
1444
|
+
_: 2
|
|
1445
|
+
}, 1032, ["content", "disabled"])) : tool === "import" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
1446
|
+
key: 19,
|
|
1447
|
+
content: unref(m).file.import,
|
|
1448
|
+
placement: "bottom"
|
|
1449
|
+
}, {
|
|
1450
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
1451
|
+
variant: "ghost",
|
|
1452
|
+
"aria-label": unref(m).file.import,
|
|
1453
|
+
"aria-haspopup": "dialog",
|
|
1454
|
+
disabled: disabled.value,
|
|
1455
|
+
onClick: pickFile
|
|
1456
|
+
}, {
|
|
1457
|
+
default: withCtx(() => [createVNode(unref(UploadIcon))]),
|
|
1458
|
+
_: 1
|
|
1459
|
+
}, 8, ["aria-label", "disabled"])]),
|
|
1460
|
+
_: 1
|
|
1461
|
+
}, 8, ["content"])) : tool === "validation" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
1462
|
+
key: 20,
|
|
1463
|
+
content: unref(m).validation.title,
|
|
1464
|
+
placement: "bottom"
|
|
1465
|
+
}, {
|
|
1466
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
1467
|
+
variant: "ghost",
|
|
1468
|
+
"aria-label": unref(m).validation.title,
|
|
1469
|
+
"aria-haspopup": "dialog",
|
|
1470
|
+
disabled: disabled.value,
|
|
1471
|
+
onClick: openValidation
|
|
1472
|
+
}, {
|
|
1473
|
+
default: withCtx(() => [createVNode(unref(TableCheckIcon))]),
|
|
1474
|
+
_: 1
|
|
1475
|
+
}, 8, ["aria-label", "disabled"])]),
|
|
1476
|
+
_: 1
|
|
1477
|
+
}, 8, ["content"])) : tool === "clear" ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
1478
|
+
key: 21,
|
|
1479
|
+
content: unref(m).clearFormatting,
|
|
1480
|
+
shortcut: "mod+\\",
|
|
1481
|
+
placement: "bottom"
|
|
1482
|
+
}, {
|
|
1483
|
+
default: withCtx(() => [createVNode(unref(DouButton), {
|
|
1484
|
+
variant: "ghost",
|
|
1485
|
+
"aria-label": unref(m).clearFormatting,
|
|
1486
|
+
disabled: !can("clear"),
|
|
1487
|
+
onClick: _cache[11] || (_cache[11] = ($event) => run("clear"))
|
|
1488
|
+
}, {
|
|
1489
|
+
default: withCtx(() => [createVNode(unref(TypeXIcon))]),
|
|
1490
|
+
_: 1
|
|
1491
|
+
}, 8, ["aria-label", "disabled"])]),
|
|
1492
|
+
_: 1
|
|
1493
|
+
}, 8, ["content"])) : createCommentVNode("", true)], 64);
|
|
1494
|
+
}), 128)),
|
|
1495
|
+
renderSlot(_ctx.$slots, "end")
|
|
1496
|
+
]),
|
|
1497
|
+
_: 3
|
|
1498
|
+
}, 8, ["class", "aria-label"]),
|
|
1499
|
+
createElementVNode("input", {
|
|
1500
|
+
ref_key: "picker",
|
|
1501
|
+
ref: picker,
|
|
1502
|
+
type: "file",
|
|
1503
|
+
class: "dou-sheet-toolbar__picker",
|
|
1504
|
+
accept: unref(sheet).importAccept.value,
|
|
1505
|
+
tabindex: "-1",
|
|
1506
|
+
"aria-hidden": "true",
|
|
1507
|
+
onChange: onPicked,
|
|
1508
|
+
onCancel: onPickCancel
|
|
1509
|
+
}, null, 40, _hoisted_21),
|
|
1510
|
+
createVNode(format_dialog_default, {
|
|
1511
|
+
open: dialogOpen.value,
|
|
1512
|
+
"onUpdate:open": _cache[12] || (_cache[12] = ($event) => dialogOpen.value = $event),
|
|
1513
|
+
format: dialogFormat.value,
|
|
1514
|
+
title: dialogTitle.value,
|
|
1515
|
+
styles: unref(sheet).doc.value.styles,
|
|
1516
|
+
messages: unref(m),
|
|
1517
|
+
onApply: applyFormat,
|
|
1518
|
+
onClosed: dialogClosed
|
|
1519
|
+
}, null, 8, [
|
|
1520
|
+
"open",
|
|
1521
|
+
"format",
|
|
1522
|
+
"title",
|
|
1523
|
+
"styles",
|
|
1524
|
+
"messages"
|
|
1525
|
+
]),
|
|
1526
|
+
createVNode(validation_dialog_default, {
|
|
1527
|
+
open: ruleOpen.value,
|
|
1528
|
+
"onUpdate:open": _cache[13] || (_cache[13] = ($event) => ruleOpen.value = $event),
|
|
1529
|
+
rule: rule.value,
|
|
1530
|
+
editing: ruleIndex.value >= 0,
|
|
1531
|
+
messages: unref(m),
|
|
1532
|
+
onApply: applyValidation,
|
|
1533
|
+
onRemove: removeValidation,
|
|
1534
|
+
onClosed: _cache[14] || (_cache[14] = ($event) => unref(sheet).focus())
|
|
1535
|
+
}, null, 8, [
|
|
1536
|
+
"open",
|
|
1537
|
+
"rule",
|
|
1538
|
+
"editing",
|
|
1539
|
+
"messages"
|
|
1540
|
+
]),
|
|
1541
|
+
createVNode(format_list_default, {
|
|
1542
|
+
open: listOpen.value,
|
|
1543
|
+
"onUpdate:open": _cache[15] || (_cache[15] = ($event) => listOpen.value = $event),
|
|
1544
|
+
formats: conditionals.value,
|
|
1545
|
+
styles: unref(sheet).doc.value.styles,
|
|
1546
|
+
messages: unref(m),
|
|
1547
|
+
onChange: setFormats,
|
|
1548
|
+
onEdit: editFormat,
|
|
1549
|
+
onClosed: _cache[16] || (_cache[16] = ($event) => unref(sheet).focus())
|
|
1550
|
+
}, null, 8, [
|
|
1551
|
+
"open",
|
|
1552
|
+
"formats",
|
|
1553
|
+
"styles",
|
|
1554
|
+
"messages"
|
|
1555
|
+
])
|
|
1556
|
+
]);
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
});
|
|
1560
|
+
export { sheet_toolbar_vue_vue_type_script_setup_true_lang_default as default };
|
|
1561
|
+
|
|
1562
|
+
//# sourceMappingURL=sheet-toolbar.vue_vue_type_script_setup_true_lang.js.map
|