@pixerate/editor-svelte 0.23.0 → 0.25.0
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/README.md +4 -2
- package/dist/ExportDocxButton.svelte +48 -0
- package/dist/ExportDocxButton.svelte.d.ts +13 -0
- package/dist/ExportDocxButton.svelte.d.ts.map +1 -0
- package/dist/StylesGallery.svelte +169 -0
- package/dist/StylesGallery.svelte.d.ts +27 -0
- package/dist/StylesGallery.svelte.d.ts.map +1 -0
- package/dist/canvas/AnimationTimeline.svelte +217 -0
- package/dist/canvas/AnimationTimeline.svelte.d.ts +20 -0
- package/dist/canvas/AnimationTimeline.svelte.d.ts.map +1 -0
- package/dist/canvas/CanvasComponentsPanel.svelte +73 -0
- package/dist/canvas/CanvasComponentsPanel.svelte.d.ts +13 -0
- package/dist/canvas/CanvasComponentsPanel.svelte.d.ts.map +1 -0
- package/dist/canvas/CanvasInstanceInspector.svelte +136 -0
- package/dist/canvas/CanvasInstanceInspector.svelte.d.ts +16 -0
- package/dist/canvas/CanvasInstanceInspector.svelte.d.ts.map +1 -0
- package/dist/canvas/TokenBindingPicker.svelte +93 -0
- package/dist/canvas/TokenBindingPicker.svelte.d.ts +20 -0
- package/dist/canvas/TokenBindingPicker.svelte.d.ts.map +1 -0
- package/dist/canvas/TokenModeSwitcher.svelte +55 -0
- package/dist/canvas/TokenModeSwitcher.svelte.d.ts +18 -0
- package/dist/canvas/TokenModeSwitcher.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasAnimation.svelte.d.ts +98 -0
- package/dist/canvas/createCanvasAnimation.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasAnimation.svelte.js +79 -0
- package/dist/canvas/createCanvasArrange.svelte.d.ts +4 -0
- package/dist/canvas/createCanvasArrange.svelte.d.ts.map +1 -1
- package/dist/canvas/createCanvasAutoLayout.svelte.d.ts.map +1 -1
- package/dist/canvas/createCanvasComponents.svelte.d.ts +68 -0
- package/dist/canvas/createCanvasComponents.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasComponents.svelte.js +31 -0
- package/dist/canvas/createCanvasTokens.svelte.d.ts +31 -0
- package/dist/canvas/createCanvasTokens.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasTokens.svelte.js +50 -0
- package/dist/canvas/index.d.ts +12 -0
- package/dist/canvas/index.d.ts.map +1 -1
- package/dist/canvas/index.js +16 -0
- package/dist/docxExport.svelte.d.ts +26 -0
- package/dist/docxExport.svelte.d.ts.map +1 -0
- package/dist/docxExport.svelte.js +36 -0
- package/dist/fileImport.svelte.d.ts +8 -1
- package/dist/fileImport.svelte.d.ts.map +1 -1
- package/dist/fileImport.svelte.js +11 -1
- package/dist/generation/AssetMentionChips.svelte +130 -0
- package/dist/generation/AssetMentionChips.svelte.d.ts +21 -0
- package/dist/generation/AssetMentionChips.svelte.d.ts.map +1 -0
- package/dist/generation/GenerationHistory.svelte +161 -0
- package/dist/generation/GenerationHistory.svelte.d.ts +28 -0
- package/dist/generation/GenerationHistory.svelte.d.ts.map +1 -0
- package/dist/generation/index.d.ts +7 -0
- package/dist/generation/index.d.ts.map +1 -1
- package/dist/generation/index.js +3 -0
- package/dist/generation/records.svelte.d.ts +18 -0
- package/dist/generation/records.svelte.d.ts.map +1 -0
- package/dist/generation/records.svelte.js +66 -0
- package/dist/image-editor/ImageEditor.svelte +72 -1
- package/dist/image-editor/ImageEditor.svelte.d.ts.map +1 -1
- package/dist/image-editor/RefineEdgePanel.svelte +180 -0
- package/dist/image-editor/RefineEdgePanel.svelte.d.ts +13 -0
- package/dist/image-editor/RefineEdgePanel.svelte.d.ts.map +1 -0
- package/dist/image-editor/SelectionOptionsBar.svelte +135 -0
- package/dist/image-editor/SelectionOptionsBar.svelte.d.ts +15 -0
- package/dist/image-editor/SelectionOptionsBar.svelte.d.ts.map +1 -0
- package/dist/image-editor/index.d.ts +6 -0
- package/dist/image-editor/index.d.ts.map +1 -1
- package/dist/image-editor/index.js +2 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/paragraphStyles.svelte.d.ts +30 -0
- package/dist/paragraphStyles.svelte.d.ts.map +1 -0
- package/dist/paragraphStyles.svelte.js +44 -0
- package/dist/review/TrackedChangesList.svelte +67 -0
- package/dist/review/TrackedChangesList.svelte.d.ts +13 -0
- package/dist/review/TrackedChangesList.svelte.d.ts.map +1 -0
- package/dist/review/index.d.ts +3 -0
- package/dist/review/index.d.ts.map +1 -1
- package/dist/review/index.js +1 -0
- package/dist/review/review.svelte.d.ts +6 -0
- package/dist/review/review.svelte.d.ts.map +1 -1
- package/dist/review/review.svelte.js +3 -0
- package/dist/spreadsheet/FormulaBar.svelte +13 -4
- package/dist/spreadsheet/FormulaBar.svelte.d.ts.map +1 -1
- package/dist/spreadsheet/FormulaHints.svelte +7 -5
- package/dist/spreadsheet/FormulaHints.svelte.d.ts +3 -0
- package/dist/spreadsheet/FormulaHints.svelte.d.ts.map +1 -1
- package/dist/spreadsheet/NameManager.svelte +165 -0
- package/dist/spreadsheet/NameManager.svelte.d.ts +11 -0
- package/dist/spreadsheet/NameManager.svelte.d.ts.map +1 -0
- package/dist/spreadsheet/SheetTabs.svelte +161 -0
- package/dist/spreadsheet/SheetTabs.svelte.d.ts +10 -0
- package/dist/spreadsheet/SheetTabs.svelte.d.ts.map +1 -0
- package/dist/spreadsheet/SpreadsheetConditionalFormatPanel.svelte +184 -0
- package/dist/spreadsheet/SpreadsheetConditionalFormatPanel.svelte.d.ts +9 -0
- package/dist/spreadsheet/SpreadsheetConditionalFormatPanel.svelte.d.ts.map +1 -0
- package/dist/spreadsheet/SpreadsheetContextMenu.svelte +9 -4
- package/dist/spreadsheet/SpreadsheetContextMenu.svelte.d.ts +5 -1
- package/dist/spreadsheet/SpreadsheetContextMenu.svelte.d.ts.map +1 -1
- package/dist/spreadsheet/SpreadsheetDataValidationPanel.svelte +141 -0
- package/dist/spreadsheet/SpreadsheetDataValidationPanel.svelte.d.ts +9 -0
- package/dist/spreadsheet/SpreadsheetDataValidationPanel.svelte.d.ts.map +1 -0
- package/dist/spreadsheet/SpreadsheetEditor.svelte +273 -19
- package/dist/spreadsheet/SpreadsheetEditor.svelte.d.ts +8 -0
- package/dist/spreadsheet/SpreadsheetEditor.svelte.d.ts.map +1 -1
- package/dist/spreadsheet/SpreadsheetGroupRow.svelte +31 -3
- package/dist/spreadsheet/SpreadsheetGroupRow.svelte.d.ts +6 -0
- package/dist/spreadsheet/SpreadsheetGroupRow.svelte.d.ts.map +1 -1
- package/dist/spreadsheet/SpreadsheetValidationDialog.svelte +92 -0
- package/dist/spreadsheet/SpreadsheetValidationDialog.svelte.d.ts +9 -0
- package/dist/spreadsheet/SpreadsheetValidationDialog.svelte.d.ts.map +1 -0
- package/dist/spreadsheet/index.d.ts +10 -0
- package/dist/spreadsheet/index.d.ts.map +1 -1
- package/dist/spreadsheet/index.js +6 -0
- package/dist/spreadsheet/spreadsheet.svelte.d.ts +56 -3
- package/dist/spreadsheet/spreadsheet.svelte.d.ts.map +1 -1
- package/dist/spreadsheet/spreadsheet.svelte.js +105 -6
- package/dist/spreadsheet/viewport.svelte.d.ts +26 -0
- package/dist/spreadsheet/viewport.svelte.d.ts.map +1 -0
- package/dist/spreadsheet/viewport.svelte.js +93 -0
- package/dist/tables/InsertTableGrid.svelte +85 -0
- package/dist/tables/InsertTableGrid.svelte.d.ts +21 -0
- package/dist/tables/InsertTableGrid.svelte.d.ts.map +1 -0
- package/dist/tables/TableBubbleMenu.svelte +43 -0
- package/dist/tables/TableBubbleMenu.svelte.d.ts +18 -0
- package/dist/tables/TableBubbleMenu.svelte.d.ts.map +1 -0
- package/dist/tables/TableToolbar.svelte +81 -0
- package/dist/tables/TableToolbar.svelte.d.ts +19 -0
- package/dist/tables/TableToolbar.svelte.d.ts.map +1 -0
- package/dist/tables/index.d.ts +12 -0
- package/dist/tables/index.d.ts.map +1 -0
- package/dist/tables/index.js +4 -0
- package/dist/tables/tableMenu.svelte.d.ts +21 -0
- package/dist/tables/tableMenu.svelte.d.ts.map +1 -0
- package/dist/tables/tableMenu.svelte.js +27 -0
- package/dist/tokens/TokenSwatch.svelte +14 -0
- package/dist/tokens/TokenSwatch.svelte.d.ts +8 -0
- package/dist/tokens/TokenSwatch.svelte.d.ts.map +1 -0
- package/dist/tokens/TokensPanel.svelte +323 -0
- package/dist/tokens/TokensPanel.svelte.d.ts +14 -0
- package/dist/tokens/TokensPanel.svelte.d.ts.map +1 -0
- package/dist/tokens/createTokens.svelte.d.ts +31 -0
- package/dist/tokens/createTokens.svelte.d.ts.map +1 -0
- package/dist/tokens/createTokens.svelte.js +43 -0
- package/dist/tokens/index.d.ts +7 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +3 -0
- package/package.json +10 -2
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getNameManagerRows, parseFormula, type SpreadsheetNameRow } from '@pixerate/editor/spreadsheet';
|
|
3
|
+
import type { createReactiveSpreadsheet } from './spreadsheet.svelte.js';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
sheetState: ReturnType<typeof createReactiveSpreadsheet>;
|
|
7
|
+
readOnly?: boolean;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { sheetState, readOnly = false, onClose, class: className = '' }: Props = $props();
|
|
13
|
+
|
|
14
|
+
interface Draft {
|
|
15
|
+
/** The name being edited (null for a new one). */
|
|
16
|
+
original: { name: string; sheetId?: string } | null;
|
|
17
|
+
name: string;
|
|
18
|
+
refersTo: string;
|
|
19
|
+
/** Sheet id, or '' for workbook scope. */
|
|
20
|
+
scope: string;
|
|
21
|
+
comment: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const EMPTY_DRAFT: Draft = { original: null, name: '', refersTo: '=', scope: '', comment: '' };
|
|
25
|
+
|
|
26
|
+
let draft = $state<Draft>({ ...EMPTY_DRAFT });
|
|
27
|
+
let error = $state<string | null>(null);
|
|
28
|
+
|
|
29
|
+
const rows = $derived.by(() => {
|
|
30
|
+
void sheetState.document;
|
|
31
|
+
void sheetState.names;
|
|
32
|
+
return getNameManagerRows(sheetState.controller);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
function edit(row: SpreadsheetNameRow) {
|
|
36
|
+
error = null;
|
|
37
|
+
draft = {
|
|
38
|
+
original: { name: row.name, sheetId: row.sheetId },
|
|
39
|
+
name: row.name,
|
|
40
|
+
refersTo: row.refersTo,
|
|
41
|
+
scope: row.sheetId ?? '',
|
|
42
|
+
comment: row.comment ?? ''
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function save(e: SubmitEvent) {
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
const scope = draft.scope ? { sheet: draft.scope } : {};
|
|
49
|
+
try {
|
|
50
|
+
// Check before changing anything, so a failed edit keeps the old name.
|
|
51
|
+
const invalid = sheetState.controller.validateDefinedName(draft.name.trim());
|
|
52
|
+
if (invalid) throw new Error(invalid);
|
|
53
|
+
const formula = draft.refersTo.trim().startsWith('=') ? draft.refersTo.trim() : `=${draft.refersTo.trim()}`;
|
|
54
|
+
try {
|
|
55
|
+
parseFormula(formula);
|
|
56
|
+
} catch (err: any) {
|
|
57
|
+
throw new Error(`There's a problem with this formula: ${err?.message ?? formula}`);
|
|
58
|
+
}
|
|
59
|
+
const original = draft.original;
|
|
60
|
+
if (original) {
|
|
61
|
+
const originalScope = original.sheetId ? { sheet: original.sheetId } : {};
|
|
62
|
+
if ((original.sheetId ?? '') !== draft.scope) {
|
|
63
|
+
sheetState.deleteName(original.name, originalScope);
|
|
64
|
+
} else if (original.name !== draft.name.trim()) {
|
|
65
|
+
sheetState.renameName(original.name, draft.name.trim(), originalScope);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
sheetState.defineName(draft.name.trim(), draft.refersTo, { ...scope, comment: draft.comment || undefined });
|
|
69
|
+
draft = { ...EMPTY_DRAFT };
|
|
70
|
+
error = null;
|
|
71
|
+
} catch (err: any) {
|
|
72
|
+
error = err?.message ?? String(err);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function remove(row: SpreadsheetNameRow) {
|
|
77
|
+
sheetState.deleteName(row.name, row.sheetId ? { sheet: row.sheetId } : {});
|
|
78
|
+
if (draft.original?.name === row.name && (draft.original.sheetId ?? '') === (row.sheetId ?? '')) draft = { ...EMPTY_DRAFT };
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<!--
|
|
83
|
+
A simple Name Manager: lists defined names (name, current value, formula,
|
|
84
|
+
scope) and adds, edits, renames and deletes them. Renaming a name rewrites
|
|
85
|
+
the formulas that use it; deleting one leaves them showing #NAME?.
|
|
86
|
+
-->
|
|
87
|
+
<section aria-label="Name Manager" class="flex flex-col gap-2 text-xs {className}" data-name-manager="">
|
|
88
|
+
<div class="flex items-center justify-between">
|
|
89
|
+
<h3 class="m-0 text-sm font-semibold">Name Manager</h3>
|
|
90
|
+
{#if onClose}
|
|
91
|
+
<button type="button" aria-label="Close Name Manager" class="rounded px-2 hover:bg-muted" onclick={onClose}>×</button>
|
|
92
|
+
{/if}
|
|
93
|
+
</div>
|
|
94
|
+
<table class="w-full border-collapse">
|
|
95
|
+
<thead>
|
|
96
|
+
<tr class="text-left text-muted-foreground">
|
|
97
|
+
<th class="px-1 font-medium">Name</th>
|
|
98
|
+
<th class="px-1 font-medium">Value</th>
|
|
99
|
+
<th class="px-1 font-medium">Refers to</th>
|
|
100
|
+
<th class="px-1 font-medium">Scope</th>
|
|
101
|
+
{#if !readOnly}<th class="px-1"></th>{/if}
|
|
102
|
+
</tr>
|
|
103
|
+
</thead>
|
|
104
|
+
<tbody>
|
|
105
|
+
{#if rows.length === 0}
|
|
106
|
+
<tr><td colspan="5" class="px-1 py-2 text-muted-foreground">No names yet.</td></tr>
|
|
107
|
+
{/if}
|
|
108
|
+
{#each rows as row (`${row.sheetId ?? ''}!${row.name}`)}
|
|
109
|
+
<tr data-name={row.name} class="border-t border-border" title={row.comment}>
|
|
110
|
+
<td class="px-1 py-0.5 font-mono font-semibold">{row.name}</td>
|
|
111
|
+
<td class="px-1 py-0.5">{row.value}</td>
|
|
112
|
+
<td class="px-1 py-0.5 font-mono">{row.refersTo}</td>
|
|
113
|
+
<td class="px-1 py-0.5">{row.scopeLabel}</td>
|
|
114
|
+
{#if !readOnly}
|
|
115
|
+
<td class="whitespace-nowrap px-1 py-0.5 text-right">
|
|
116
|
+
<button type="button" aria-label="Edit {row.name}" class="rounded px-1 hover:bg-muted" onclick={() => edit(row)}>Edit</button>
|
|
117
|
+
<button type="button" aria-label="Delete {row.name}" class="rounded px-1 text-destructive hover:bg-muted" onclick={() => remove(row)}>
|
|
118
|
+
Delete
|
|
119
|
+
</button>
|
|
120
|
+
</td>
|
|
121
|
+
{/if}
|
|
122
|
+
</tr>
|
|
123
|
+
{/each}
|
|
124
|
+
</tbody>
|
|
125
|
+
</table>
|
|
126
|
+
{#if !readOnly}
|
|
127
|
+
<form
|
|
128
|
+
class="grid grid-cols-[auto_1fr] items-center gap-x-2 gap-y-1"
|
|
129
|
+
onsubmit={save}
|
|
130
|
+
aria-label={draft.original ? `Edit name ${draft.original.name}` : 'New name'}
|
|
131
|
+
>
|
|
132
|
+
<label for="pixerate-name-manager-name">Name</label>
|
|
133
|
+
<input id="pixerate-name-manager-name" class="rounded border border-border bg-background px-1 py-0.5" bind:value={draft.name} />
|
|
134
|
+
<label for="pixerate-name-manager-refers">Refers to</label>
|
|
135
|
+
<input id="pixerate-name-manager-refers" class="rounded border border-border bg-background px-1 py-0.5 font-mono" bind:value={draft.refersTo} />
|
|
136
|
+
<label for="pixerate-name-manager-scope">Scope</label>
|
|
137
|
+
<select id="pixerate-name-manager-scope" class="rounded border border-border bg-background px-1 py-0.5" bind:value={draft.scope}>
|
|
138
|
+
<option value="">Workbook</option>
|
|
139
|
+
{#each sheetState.sheets as sheet (sheet.id)}
|
|
140
|
+
<option value={sheet.id}>{sheet.name}</option>
|
|
141
|
+
{/each}
|
|
142
|
+
</select>
|
|
143
|
+
<label for="pixerate-name-manager-comment">Comment</label>
|
|
144
|
+
<input id="pixerate-name-manager-comment" class="rounded border border-border bg-background px-1 py-0.5" bind:value={draft.comment} />
|
|
145
|
+
<div class="col-span-2 flex gap-2">
|
|
146
|
+
<button type="submit" class="rounded bg-primary px-2 py-0.5 text-primary-foreground">{draft.original ? 'Save' : 'Add name'}</button>
|
|
147
|
+
{#if draft.original}
|
|
148
|
+
<button
|
|
149
|
+
type="button"
|
|
150
|
+
class="rounded px-2 py-0.5 hover:bg-muted"
|
|
151
|
+
onclick={() => {
|
|
152
|
+
draft = { ...EMPTY_DRAFT };
|
|
153
|
+
error = null;
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
Cancel
|
|
157
|
+
</button>
|
|
158
|
+
{/if}
|
|
159
|
+
</div>
|
|
160
|
+
</form>
|
|
161
|
+
{/if}
|
|
162
|
+
{#if error}
|
|
163
|
+
<div role="alert" class="text-destructive">{error}</div>
|
|
164
|
+
{/if}
|
|
165
|
+
</section>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { createReactiveSpreadsheet } from './spreadsheet.svelte.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
sheetState: ReturnType<typeof createReactiveSpreadsheet>;
|
|
4
|
+
readOnly?: boolean;
|
|
5
|
+
onClose?: () => void;
|
|
6
|
+
class?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const NameManager: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type NameManager = ReturnType<typeof NameManager>;
|
|
10
|
+
export default NameManager;
|
|
11
|
+
//# sourceMappingURL=NameManager.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NameManager.svelte.d.ts","sourceRoot":"","sources":["../../src/spreadsheet/NameManager.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAGvE,UAAU,KAAK;IACb,UAAU,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAwJH,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getSheetTabMenuItems, sheetDropIndex, type SpreadsheetMenuItem } from '@pixerate/editor/spreadsheet';
|
|
3
|
+
import type { createReactiveSpreadsheet } from './spreadsheet.svelte.js';
|
|
4
|
+
import SpreadsheetContextMenu from './SpreadsheetContextMenu.svelte';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
sheetState: ReturnType<typeof createReactiveSpreadsheet>;
|
|
8
|
+
readOnly?: boolean;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { sheetState, readOnly = false, class: className = '' }: Props = $props();
|
|
13
|
+
|
|
14
|
+
let renaming = $state<{ id: string; draft: string } | null>(null);
|
|
15
|
+
let error = $state<string | null>(null);
|
|
16
|
+
let menu = $state<{ x: number; y: number; items: SpreadsheetMenuItem[] } | null>(null);
|
|
17
|
+
let dragFrom: number | null = null;
|
|
18
|
+
let dropTarget = $state<{ index: number; after: boolean } | null>(null);
|
|
19
|
+
let renameInput = $state<HTMLInputElement | null>(null);
|
|
20
|
+
|
|
21
|
+
// Focus and select the name when the rename field opens.
|
|
22
|
+
$effect(() => {
|
|
23
|
+
if (!renameInput) return;
|
|
24
|
+
renameInput.focus();
|
|
25
|
+
renameInput.select();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
function commitRename(cancelOnError: boolean) {
|
|
29
|
+
if (!renaming) return;
|
|
30
|
+
const current = renaming;
|
|
31
|
+
const sheet = sheetState.sheets.find((s) => s.id === current.id);
|
|
32
|
+
const name = current.draft.trim();
|
|
33
|
+
if (!sheet || !name || name === sheet.name) {
|
|
34
|
+
renaming = null;
|
|
35
|
+
error = null;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
sheetState.renameSheet(current.id, name);
|
|
40
|
+
renaming = null;
|
|
41
|
+
error = null;
|
|
42
|
+
} catch (err: any) {
|
|
43
|
+
error = err?.message ?? String(err);
|
|
44
|
+
if (cancelOnError) renaming = null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function dropAfter(e: DragEvent): boolean {
|
|
49
|
+
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
|
|
50
|
+
return e.clientX > rect.left + rect.width / 2;
|
|
51
|
+
}
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<!--
|
|
55
|
+
The workbook's sheet tabs: click to switch, double-click to rename, drag to
|
|
56
|
+
reorder, right-click for insert / rename / duplicate / move / delete
|
|
57
|
+
(delete asks to confirm), and a `+` button to add a sheet.
|
|
58
|
+
-->
|
|
59
|
+
<div class="flex flex-col {className}" data-sheet-tabs="">
|
|
60
|
+
<div role="tablist" aria-label="Sheets" class="flex items-center gap-0.5 overflow-x-auto border-t border-border bg-muted px-1 py-1 text-xs">
|
|
61
|
+
{#each sheetState.sheets as sheet, index (sheet.id)}
|
|
62
|
+
{#if renaming?.id === sheet.id}
|
|
63
|
+
<input
|
|
64
|
+
bind:this={renameInput}
|
|
65
|
+
aria-label="Sheet name"
|
|
66
|
+
class="w-32 rounded border border-primary bg-background px-2 py-0.5 text-xs outline-none"
|
|
67
|
+
value={renaming.draft}
|
|
68
|
+
oninput={(e) => {
|
|
69
|
+
if (renaming) renaming = { id: renaming.id, draft: e.currentTarget.value };
|
|
70
|
+
}}
|
|
71
|
+
onkeydown={(e) => {
|
|
72
|
+
e.stopPropagation();
|
|
73
|
+
if (e.key === 'Enter') commitRename(false);
|
|
74
|
+
else if (e.key === 'Escape') {
|
|
75
|
+
renaming = null;
|
|
76
|
+
error = null;
|
|
77
|
+
}
|
|
78
|
+
}}
|
|
79
|
+
onblur={() => commitRename(true)}
|
|
80
|
+
/>
|
|
81
|
+
{:else}
|
|
82
|
+
<button
|
|
83
|
+
type="button"
|
|
84
|
+
role="tab"
|
|
85
|
+
aria-selected={sheet.active}
|
|
86
|
+
data-sheet-id={sheet.id}
|
|
87
|
+
draggable={!readOnly}
|
|
88
|
+
title={readOnly ? sheet.name : `${sheet.name} — double-click to rename, drag to move`}
|
|
89
|
+
class="whitespace-nowrap rounded px-3 py-0.5 {sheet.active
|
|
90
|
+
? 'bg-background font-semibold text-foreground shadow-sm'
|
|
91
|
+
: 'text-muted-foreground hover:bg-background/60'} {dropTarget?.index === index
|
|
92
|
+
? dropTarget.after
|
|
93
|
+
? 'border-r-2 border-primary'
|
|
94
|
+
: 'border-l-2 border-primary'
|
|
95
|
+
: ''}"
|
|
96
|
+
onclick={() => sheetState.setActiveSheet(sheet.id)}
|
|
97
|
+
ondblclick={() => {
|
|
98
|
+
if (readOnly) return;
|
|
99
|
+
error = null;
|
|
100
|
+
renaming = { id: sheet.id, draft: sheet.name };
|
|
101
|
+
}}
|
|
102
|
+
oncontextmenu={(e) => {
|
|
103
|
+
if (readOnly) return;
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
menu = {
|
|
106
|
+
x: e.clientX,
|
|
107
|
+
y: e.clientY,
|
|
108
|
+
items: getSheetTabMenuItems(sheetState.controller, sheet.id, { onError: (message) => (error = message) })
|
|
109
|
+
};
|
|
110
|
+
}}
|
|
111
|
+
ondragstart={(e) => {
|
|
112
|
+
dragFrom = index;
|
|
113
|
+
e.dataTransfer?.setData('text/plain', sheet.id);
|
|
114
|
+
if (e.dataTransfer) e.dataTransfer.effectAllowed = 'move';
|
|
115
|
+
}}
|
|
116
|
+
ondragover={(e) => {
|
|
117
|
+
if (dragFrom === null) return;
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
const after = dropAfter(e);
|
|
120
|
+
if (dropTarget?.index !== index || dropTarget.after !== after) dropTarget = { index, after };
|
|
121
|
+
}}
|
|
122
|
+
ondragleave={() => (dropTarget = null)}
|
|
123
|
+
ondrop={(e) => {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
const from = dragFrom;
|
|
126
|
+
dragFrom = null;
|
|
127
|
+
dropTarget = null;
|
|
128
|
+
if (from === null) return;
|
|
129
|
+
sheetState.moveSheet(sheetState.sheets[from].id, sheetDropIndex(from, index, dropAfter(e)));
|
|
130
|
+
}}
|
|
131
|
+
ondragend={() => {
|
|
132
|
+
dragFrom = null;
|
|
133
|
+
dropTarget = null;
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
{sheet.name}
|
|
137
|
+
</button>
|
|
138
|
+
{/if}
|
|
139
|
+
{/each}
|
|
140
|
+
{#if !readOnly}
|
|
141
|
+
<button
|
|
142
|
+
type="button"
|
|
143
|
+
aria-label="Add sheet"
|
|
144
|
+
title="Add sheet"
|
|
145
|
+
class="rounded px-2 py-0.5 text-muted-foreground hover:bg-background/60"
|
|
146
|
+
onclick={() => {
|
|
147
|
+
error = null;
|
|
148
|
+
sheetState.addSheet();
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
+
|
|
152
|
+
</button>
|
|
153
|
+
{/if}
|
|
154
|
+
</div>
|
|
155
|
+
{#if error}
|
|
156
|
+
<div role="alert" class="px-2 py-1 text-xs text-destructive">{error}</div>
|
|
157
|
+
{/if}
|
|
158
|
+
{#if menu}
|
|
159
|
+
<SpreadsheetContextMenu items={menu.items} x={menu.x} y={menu.y} ariaLabel="Sheet actions" onClose={() => (menu = null)} />
|
|
160
|
+
{/if}
|
|
161
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { createReactiveSpreadsheet } from './spreadsheet.svelte.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
sheetState: ReturnType<typeof createReactiveSpreadsheet>;
|
|
4
|
+
readOnly?: boolean;
|
|
5
|
+
class?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const SheetTabs: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type SheetTabs = ReturnType<typeof SheetTabs>;
|
|
9
|
+
export default SheetTabs;
|
|
10
|
+
//# sourceMappingURL=SheetTabs.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SheetTabs.svelte.d.ts","sourceRoot":"","sources":["../../src/spreadsheet/SheetTabs.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAIvE,UAAU,KAAK;IACb,UAAU,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA8HH,QAAA,MAAM,SAAS,2CAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
CONDITIONAL_FORMAT_ICON_SETS,
|
|
4
|
+
CONDITIONAL_FORMAT_PRESETS,
|
|
5
|
+
CONDITIONAL_FORMAT_STYLE_PRESETS,
|
|
6
|
+
CONDITIONAL_FORMAT_TIME_PERIODS,
|
|
7
|
+
createConditionalFormatRule,
|
|
8
|
+
describeConditionalFormat,
|
|
9
|
+
formatRuleRanges,
|
|
10
|
+
getConditionalFormatCss,
|
|
11
|
+
conditionalFormatStyleString,
|
|
12
|
+
parseRuleRanges,
|
|
13
|
+
type ConditionalFormatIconSet,
|
|
14
|
+
type ConditionalFormatPresetKind,
|
|
15
|
+
type ConditionalFormatRule,
|
|
16
|
+
type ConditionalFormatTimePeriod
|
|
17
|
+
} from '@pixerate/editor/spreadsheet';
|
|
18
|
+
import type { createReactiveSpreadsheet } from './spreadsheet.svelte.js';
|
|
19
|
+
|
|
20
|
+
interface Props {
|
|
21
|
+
sheetState: ReturnType<typeof createReactiveSpreadsheet>;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let { sheetState, onClose }: Props = $props();
|
|
26
|
+
|
|
27
|
+
const inputClass = 'w-full rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground';
|
|
28
|
+
const buttonClass = 'rounded border border-border px-2 py-0.5 hover:bg-muted disabled:opacity-40';
|
|
29
|
+
const selectionText = () => (sheetState.selectedRange ? formatRuleRanges([sheetState.selectedRange]) : 'A1');
|
|
30
|
+
|
|
31
|
+
let rules = $derived(sheetState.document.table?.conditionalFormats ?? []);
|
|
32
|
+
let kind = $state<ConditionalFormatPresetKind>('greaterThan');
|
|
33
|
+
let appliesTo = $state(selectionText());
|
|
34
|
+
let value = $state('');
|
|
35
|
+
let value2 = $state('');
|
|
36
|
+
let text = $state('');
|
|
37
|
+
let formula = $state('=');
|
|
38
|
+
let rank = $state('10');
|
|
39
|
+
let period = $state<ConditionalFormatTimePeriod>('today');
|
|
40
|
+
let iconSet = $state<ConditionalFormatIconSet>('3TrafficLights1');
|
|
41
|
+
let color = $state('#638ec6');
|
|
42
|
+
let styleId = $state(CONDITIONAL_FORMAT_STYLE_PRESETS[0].id);
|
|
43
|
+
let preset = $derived(CONDITIONAL_FORMAT_PRESETS.find((p) => p.kind === kind)!);
|
|
44
|
+
let ranges = $derived(parseRuleRanges(appliesTo));
|
|
45
|
+
|
|
46
|
+
function add() {
|
|
47
|
+
if (!ranges) return;
|
|
48
|
+
sheetState.addConditionalFormat(
|
|
49
|
+
createConditionalFormatRule({
|
|
50
|
+
kind,
|
|
51
|
+
ranges,
|
|
52
|
+
value,
|
|
53
|
+
value2,
|
|
54
|
+
text,
|
|
55
|
+
formula,
|
|
56
|
+
rank: Number(rank) || 10,
|
|
57
|
+
period,
|
|
58
|
+
iconSet,
|
|
59
|
+
color,
|
|
60
|
+
style: CONDITIONAL_FORMAT_STYLE_PRESETS.find((s) => s.id === styleId)?.style
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Swatch showing a rule's look (fill, font colour, bold) or its kind. */
|
|
66
|
+
function swatchStyle(rule: ConditionalFormatRule): string {
|
|
67
|
+
if (rule.type === 'colorScale') return `background: linear-gradient(90deg, ${rule.stops.map((s) => s.color).join(', ')});`;
|
|
68
|
+
if (rule.type === 'dataBar') return `background: ${rule.color ?? '#638ec6'};`;
|
|
69
|
+
if (rule.type === 'iconSet') return '';
|
|
70
|
+
return conditionalFormatStyleString(getConditionalFormatCss(rule.style));
|
|
71
|
+
}
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<!-- Conditional formatting manager: rules in priority order and a form to add one. -->
|
|
75
|
+
<div
|
|
76
|
+
role="dialog"
|
|
77
|
+
aria-label="Conditional formatting rules"
|
|
78
|
+
tabindex="-1"
|
|
79
|
+
class="fixed right-4 top-16 z-40 flex max-h-[calc(100vh-5rem)] w-80 flex-col overflow-y-auto rounded-md border border-border bg-popover p-3 text-xs text-popover-foreground shadow-lg"
|
|
80
|
+
style="background: var(--popover, var(--background, #fff));"
|
|
81
|
+
onkeydown={(e) => {
|
|
82
|
+
e.stopPropagation();
|
|
83
|
+
if (e.key === 'Escape') onClose();
|
|
84
|
+
}}
|
|
85
|
+
oncontextmenu={(e) => e.stopPropagation()}
|
|
86
|
+
>
|
|
87
|
+
<div class="mb-2 flex items-center justify-between">
|
|
88
|
+
<h2 class="text-sm font-semibold">Conditional formatting</h2>
|
|
89
|
+
<button type="button" aria-label="Close" class="px-1 text-muted-foreground hover:text-foreground" onclick={onClose}>✕</button>
|
|
90
|
+
</div>
|
|
91
|
+
<ol class="mb-3 flex flex-col gap-1" aria-label="Rules in priority order">
|
|
92
|
+
{#if rules.length === 0}
|
|
93
|
+
<li class="text-muted-foreground">No rules on this sheet.</li>
|
|
94
|
+
{/if}
|
|
95
|
+
{#each rules as rule, i (rule.id)}
|
|
96
|
+
<li data-rule-id={rule.id} class="flex items-center gap-1.5 rounded border border-border px-1.5 py-1">
|
|
97
|
+
<span aria-hidden="true" class="inline-flex h-4 w-6 shrink-0 items-center justify-center rounded-sm border border-border" style={swatchStyle(rule)}
|
|
98
|
+
>{rule.type === 'iconSet' ? '●' : rule.type === 'colorScale' || rule.type === 'dataBar' ? '' : 'Aa'}</span
|
|
99
|
+
>
|
|
100
|
+
<div class="min-w-0 flex-1">
|
|
101
|
+
<div class="truncate" title={describeConditionalFormat(rule)}>{describeConditionalFormat(rule)}</div>
|
|
102
|
+
<div class="truncate font-mono text-[10px] text-muted-foreground">{formatRuleRanges(rule.ranges)}</div>
|
|
103
|
+
</div>
|
|
104
|
+
<label class="flex items-center gap-0.5 text-[10px]" title="Stop if true">
|
|
105
|
+
<input
|
|
106
|
+
type="checkbox"
|
|
107
|
+
aria-label="Stop if true"
|
|
108
|
+
checked={!!rule.stopIfTrue}
|
|
109
|
+
onchange={(e) => sheetState.updateConditionalFormat(rule.id, { stopIfTrue: (e.currentTarget as HTMLInputElement).checked })}
|
|
110
|
+
/>
|
|
111
|
+
Stop
|
|
112
|
+
</label>
|
|
113
|
+
<button type="button" aria-label="Move up" class={buttonClass} disabled={i === 0} onclick={() => sheetState.moveConditionalFormat(rule.id, { by: -1 })}>▲</button>
|
|
114
|
+
<button
|
|
115
|
+
type="button"
|
|
116
|
+
aria-label="Move down"
|
|
117
|
+
class={buttonClass}
|
|
118
|
+
disabled={i === rules.length - 1}
|
|
119
|
+
onclick={() => sheetState.moveConditionalFormat(rule.id, { by: 1 })}>▼</button
|
|
120
|
+
>
|
|
121
|
+
<button type="button" aria-label="Delete rule" class={buttonClass} onclick={() => sheetState.deleteConditionalFormat(rule.id)}>✕</button>
|
|
122
|
+
</li>
|
|
123
|
+
{/each}
|
|
124
|
+
</ol>
|
|
125
|
+
|
|
126
|
+
<fieldset class="flex flex-col gap-1.5 border-t border-border pt-2">
|
|
127
|
+
<legend class="sr-only">New rule</legend>
|
|
128
|
+
<label class="flex flex-col gap-0.5">
|
|
129
|
+
Format cells
|
|
130
|
+
<select aria-label="Rule type" class={inputClass} bind:value={kind}>
|
|
131
|
+
{#each CONDITIONAL_FORMAT_PRESETS as p (p.kind)}
|
|
132
|
+
<option value={p.kind}>{p.label}</option>
|
|
133
|
+
{/each}
|
|
134
|
+
</select>
|
|
135
|
+
</label>
|
|
136
|
+
{#if preset.fields.includes('value')}
|
|
137
|
+
<input aria-label="Value" placeholder="Value or =formula" class={inputClass} bind:value />
|
|
138
|
+
{/if}
|
|
139
|
+
{#if preset.fields.includes('value2')}
|
|
140
|
+
<input aria-label="Second value" placeholder="and" class={inputClass} bind:value={value2} />
|
|
141
|
+
{/if}
|
|
142
|
+
{#if preset.fields.includes('text')}
|
|
143
|
+
<input aria-label="Text" placeholder="Text" class={inputClass} bind:value={text} />
|
|
144
|
+
{/if}
|
|
145
|
+
{#if preset.fields.includes('formula')}
|
|
146
|
+
<input aria-label="Formula" placeholder="=$A1>10" class={inputClass} bind:value={formula} />
|
|
147
|
+
{/if}
|
|
148
|
+
{#if preset.fields.includes('rank')}
|
|
149
|
+
<input aria-label="Rank" type="number" min="1" class={inputClass} bind:value={rank} />
|
|
150
|
+
{/if}
|
|
151
|
+
{#if preset.fields.includes('period')}
|
|
152
|
+
<select aria-label="Period" class={inputClass} bind:value={period}>
|
|
153
|
+
{#each CONDITIONAL_FORMAT_TIME_PERIODS as p (p.period)}
|
|
154
|
+
<option value={p.period}>{p.label}</option>
|
|
155
|
+
{/each}
|
|
156
|
+
</select>
|
|
157
|
+
{/if}
|
|
158
|
+
{#if preset.fields.includes('iconSet')}
|
|
159
|
+
<select aria-label="Icon set" class={inputClass} bind:value={iconSet}>
|
|
160
|
+
{#each CONDITIONAL_FORMAT_ICON_SETS as set (set)}
|
|
161
|
+
<option value={set}>{set}</option>
|
|
162
|
+
{/each}
|
|
163
|
+
</select>
|
|
164
|
+
{/if}
|
|
165
|
+
{#if preset.fields.includes('color')}
|
|
166
|
+
<input aria-label="Bar colour" type="color" class="h-6 w-12" bind:value={color} />
|
|
167
|
+
{/if}
|
|
168
|
+
{#if preset.usesStyle}
|
|
169
|
+
<select aria-label="Style" class={inputClass} bind:value={styleId}>
|
|
170
|
+
{#each CONDITIONAL_FORMAT_STYLE_PRESETS as s (s.id)}
|
|
171
|
+
<option value={s.id}>{s.label}</option>
|
|
172
|
+
{/each}
|
|
173
|
+
</select>
|
|
174
|
+
{/if}
|
|
175
|
+
<label class="flex flex-col gap-0.5">
|
|
176
|
+
Applies to
|
|
177
|
+
<input aria-label="Applies to" class="{inputClass} font-mono" bind:value={appliesTo} />
|
|
178
|
+
</label>
|
|
179
|
+
<div class="flex justify-between gap-2">
|
|
180
|
+
<button type="button" class={buttonClass} onclick={() => (appliesTo = selectionText())}>Use selection</button>
|
|
181
|
+
<button type="button" class={buttonClass} disabled={!ranges} onclick={add}>Add rule</button>
|
|
182
|
+
</div>
|
|
183
|
+
</fieldset>
|
|
184
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { createReactiveSpreadsheet } from './spreadsheet.svelte.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
sheetState: ReturnType<typeof createReactiveSpreadsheet>;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
}
|
|
6
|
+
declare const SpreadsheetConditionalFormatPanel: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type SpreadsheetConditionalFormatPanel = ReturnType<typeof SpreadsheetConditionalFormatPanel>;
|
|
8
|
+
export default SpreadsheetConditionalFormatPanel;
|
|
9
|
+
//# sourceMappingURL=SpreadsheetConditionalFormatPanel.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpreadsheetConditionalFormatPanel.svelte.d.ts","sourceRoot":"","sources":["../../src/spreadsheet/SpreadsheetConditionalFormatPanel.svelte.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAGvE,UAAU,KAAK;IACb,UAAU,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;IACzD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAoJH,QAAA,MAAM,iCAAiC,2CAAwC,CAAC;AAChF,KAAK,iCAAiC,GAAG,UAAU,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAC9F,eAAe,iCAAiC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { clampMenuPosition, runSpreadsheetMenuItem, type SpreadsheetMenuItem } from '@pixerate/editor/spreadsheet';
|
|
2
|
+
import { clampMenuPosition, runSpreadsheetMenuItem, type SpreadsheetMenuItem, type SpreadsheetPanelId } from '@pixerate/editor/spreadsheet';
|
|
3
3
|
|
|
4
4
|
// Gap kept between the menu and the viewport edges.
|
|
5
5
|
const VIEWPORT_MARGIN = 4;
|
|
@@ -9,9 +9,13 @@
|
|
|
9
9
|
x: number;
|
|
10
10
|
y: number;
|
|
11
11
|
onClose: () => void;
|
|
12
|
+
/** Accessible name of the menu (default "Table actions"). */
|
|
13
|
+
ariaLabel?: string;
|
|
14
|
+
/** Opens a panel for items with `panel` (conditional formatting, data validation). */
|
|
15
|
+
onOpenPanel?: (panel: SpreadsheetPanelId) => void;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
|
-
let { items, x, y, onClose }: Props = $props();
|
|
18
|
+
let { items, x, y, onClose, onOpenPanel, ariaLabel = 'Table actions' }: Props = $props();
|
|
15
19
|
let menuEl = $state<HTMLDivElement | null>(null);
|
|
16
20
|
let measured = $state<{ x: number; y: number } | null>(null);
|
|
17
21
|
const position = $derived(measured ?? { x, y });
|
|
@@ -51,7 +55,7 @@
|
|
|
51
55
|
<div
|
|
52
56
|
bind:this={menuEl}
|
|
53
57
|
role="menu"
|
|
54
|
-
aria-label=
|
|
58
|
+
aria-label={ariaLabel}
|
|
55
59
|
tabindex="-1"
|
|
56
60
|
class="fixed z-50 min-w-[14rem] rounded-md border border-border bg-popover py-1 text-xs text-popover-foreground shadow-lg"
|
|
57
61
|
style="left: {position.x}px; top: {position.y}px; max-height: calc(100vh - {VIEWPORT_MARGIN * 2}px); overflow-y: auto; background: var(--popover, var(--background, #fff));"
|
|
@@ -73,7 +77,8 @@
|
|
|
73
77
|
: ''}"
|
|
74
78
|
onclick={() => {
|
|
75
79
|
onClose();
|
|
76
|
-
|
|
80
|
+
if (item.panel) onOpenPanel?.(item.panel);
|
|
81
|
+
else runSpreadsheetMenuItem(item);
|
|
77
82
|
}}
|
|
78
83
|
>
|
|
79
84
|
{item.label}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { type SpreadsheetMenuItem } from '@pixerate/editor/spreadsheet';
|
|
1
|
+
import { type SpreadsheetMenuItem, type SpreadsheetPanelId } from '@pixerate/editor/spreadsheet';
|
|
2
2
|
interface Props {
|
|
3
3
|
items: SpreadsheetMenuItem[];
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
6
6
|
onClose: () => void;
|
|
7
|
+
/** Accessible name of the menu (default "Table actions"). */
|
|
8
|
+
ariaLabel?: string;
|
|
9
|
+
/** Opens a panel for items with `panel` (conditional formatting, data validation). */
|
|
10
|
+
onOpenPanel?: (panel: SpreadsheetPanelId) => void;
|
|
7
11
|
}
|
|
8
12
|
declare const SpreadsheetContextMenu: import("svelte").Component<Props, {}, "">;
|
|
9
13
|
type SpreadsheetContextMenu = ReturnType<typeof SpreadsheetContextMenu>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpreadsheetContextMenu.svelte.d.ts","sourceRoot":"","sources":["../../src/spreadsheet/SpreadsheetContextMenu.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAA6C,KAAK,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"SpreadsheetContextMenu.svelte.d.ts","sourceRoot":"","sources":["../../src/spreadsheet/SpreadsheetContextMenu.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAA6C,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAG1I,UAAU,KAAK;IACb,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACnD;AAgEH,QAAA,MAAM,sBAAsB,2CAAwC,CAAC;AACrE,KAAK,sBAAsB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACxE,eAAe,sBAAsB,CAAC"}
|