@svgrid/enterprise 3.0.1 → 3.0.2
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/dist/SvFormulaBar.svelte +606 -0
- package/dist/SvFormulaBar.svelte.d.ts +62 -0
- package/dist/SvPivotDesigner.svelte +65 -14
- package/dist/SvRibbonIcon.svelte +46 -0
- package/dist/SvRibbonIcon.svelte.d.ts +17 -0
- package/dist/SvSchemaChart.svelte +4 -2
- package/dist/SvSheet.svelte +4114 -0
- package/dist/SvSheet.svelte.d.ts +142 -0
- package/dist/SvSheetComment.svelte +98 -0
- package/dist/SvSheetComment.svelte.d.ts +22 -0
- package/dist/SvSheetConditionalFormat.svelte +162 -0
- package/dist/SvSheetConditionalFormat.svelte.d.ts +14 -0
- package/dist/SvSheetDataValidation.svelte +249 -0
- package/dist/SvSheetDataValidation.svelte.d.ts +14 -0
- package/dist/SvSheetFilterMenu.svelte +217 -0
- package/dist/SvSheetFilterMenu.svelte.d.ts +17 -0
- package/dist/SvSheetFindReplace.svelte +132 -0
- package/dist/SvSheetFindReplace.svelte.d.ts +10 -0
- package/dist/SvSheetFormatCells.svelte +421 -0
- package/dist/SvSheetFormatCells.svelte.d.ts +17 -0
- package/dist/SvSheetGoalSeek.svelte +144 -0
- package/dist/SvSheetGoalSeek.svelte.d.ts +12 -0
- package/dist/SvSheetInsertFunction.svelte +147 -0
- package/dist/SvSheetInsertFunction.svelte.d.ts +8 -0
- package/dist/SvSheetListPicker.svelte +89 -0
- package/dist/SvSheetListPicker.svelte.d.ts +16 -0
- package/dist/SvSheetManageRules.svelte +185 -0
- package/dist/SvSheetManageRules.svelte.d.ts +16 -0
- package/dist/SvSheetNameManager.svelte +225 -0
- package/dist/SvSheetNameManager.svelte.d.ts +11 -0
- package/dist/SvSheetPasteSpecial.svelte +105 -0
- package/dist/SvSheetPasteSpecial.svelte.d.ts +12 -0
- package/dist/SvSheetRemoveDuplicates.svelte +149 -0
- package/dist/SvSheetRemoveDuplicates.svelte.d.ts +12 -0
- package/dist/SvSheetRibbon.svelte +1201 -0
- package/dist/SvSheetRibbon.svelte.d.ts +34 -0
- package/dist/SvSheetSizeDialog.svelte +58 -0
- package/dist/SvSheetSizeDialog.svelte.d.ts +11 -0
- package/dist/SvSheetTabs.svelte +441 -0
- package/dist/SvSheetTabs.svelte.d.ts +36 -0
- package/dist/SvSheetTabs.test-harness.svelte.d.ts +17 -0
- package/dist/SvSheetTabs.test-harness.svelte.js +22 -0
- package/dist/SvSheetTextToColumns.svelte +172 -0
- package/dist/SvSheetTextToColumns.svelte.d.ts +13 -0
- package/dist/SvSheetValidationAlert.svelte +83 -0
- package/dist/SvSheetValidationAlert.svelte.d.ts +15 -0
- package/dist/cdn/svgrid-enterprise.svelte-external.js +18997 -5396
- package/dist/designer/assets/GridMenus-BlsvL_aU.js +8 -0
- package/dist/designer/assets/SvChartMenu-BYO9cYdy.css +1 -0
- package/dist/designer/assets/SvChartMenu-D9hEeHar.js +1 -0
- package/dist/designer/assets/SvDateRangeInput-BBRzrQeg.js +1 -0
- package/dist/designer/assets/SvDateTimePicker-DARvKUL2.js +1 -0
- package/dist/designer/assets/SvGridCellEditor-C7uQXYds.js +4 -0
- package/dist/designer/assets/SvGridChart-B8j1SSy3.js +3 -0
- package/dist/designer/assets/SvGridChart-BgLuPO7I.css +1 -0
- package/dist/designer/assets/SvGridChartBuilder-08YWWeqY.css +1 -0
- package/dist/designer/assets/SvGridChartBuilder-kvyIU_Rl.js +1 -0
- package/dist/designer/assets/SvGridChartPanel-4Pc8y5yO.css +1 -0
- package/dist/designer/assets/SvGridChartPanel-pT6ITc2P.js +4 -0
- package/dist/designer/assets/{SvGridChartView-DUc-1RUf.css → SvGridChartView-7msfnWZT.css} +1 -1
- package/dist/designer/assets/SvGridChartView-bg281UA1.js +1 -0
- package/dist/designer/assets/SvListBox-BDS66lmZ.js +110 -0
- package/dist/designer/assets/SvMenuList-DJ47ba1h.css +1 -0
- package/dist/designer/assets/SvMenuList-Dgq2D5VN.js +1 -0
- package/dist/designer/assets/SvTabs-DKmwb5p1.css +1 -0
- package/dist/designer/assets/SvTabs-UFCMTHXS.js +1 -0
- package/dist/designer/assets/chart-cIPUsbM5.js +1 -0
- package/dist/designer/assets/chart-export-B6bkQ3X8.js +11 -0
- package/dist/designer/assets/chart-export-pdf-BbA28-gt.js +11 -0
- package/dist/designer/assets/chart-panel-messages-DtTxpBUU.js +1 -0
- package/dist/designer/assets/chart-summary-Czu_5epb.js +1 -0
- package/dist/designer/assets/chart-trend-D5I5VEe8.js +1 -0
- package/dist/designer/assets/chart-validate-BMqM-qkF.js +1 -0
- package/dist/designer/assets/column-resize-BYDzR1Ve.js +1 -0
- package/dist/designer/assets/date-format-B8JbEtIG.js +1 -0
- package/dist/designer/assets/date-format-DKS-z0xS.css +1 -0
- package/dist/designer/assets/editor-contract-Bpoa7A5g.js +1 -0
- package/dist/designer/assets/focus-trap-CAreAhlU.js +1 -0
- package/dist/designer/assets/index-CMFgAoVV.css +1 -0
- package/dist/designer/assets/{index-C_a9Cj8Y.js → index-DwU7CAMm.js} +291 -290
- package/dist/designer/assets/list-option-BP_dWS66.js +1 -0
- package/dist/designer/assets/row-resize-DLktcqUK.js +1 -0
- package/dist/designer/assets/src-CITpcm6b.js +1 -0
- package/dist/designer/assets/src-EdI3Xqds.js +58 -0
- package/dist/designer/index.html +23 -14
- package/dist/export-pdf.d.ts +89 -0
- package/dist/export-pdf.js +130 -0
- package/dist/export.js +17 -10
- package/dist/index.d.ts +64 -1
- package/dist/index.js +68 -1
- package/dist/install.js +5 -0
- package/dist/node/studio.js +64 -2
- package/dist/pivot-chart.d.ts +25 -1
- package/dist/pivot-chart.js +25 -69
- package/dist/sheet/address.d.ts +43 -0
- package/dist/sheet/address.js +81 -0
- package/dist/sheet/ast.d.ts +94 -0
- package/dist/sheet/ast.js +56 -0
- package/dist/sheet/auto-filter.d.ts +66 -0
- package/dist/sheet/auto-filter.js +147 -0
- package/dist/sheet/autocomplete.d.ts +42 -0
- package/dist/sheet/autocomplete.js +162 -0
- package/dist/sheet/coerce.d.ts +31 -0
- package/dist/sheet/coerce.js +122 -0
- package/dist/sheet/commands.d.ts +89 -0
- package/dist/sheet/commands.js +230 -0
- package/dist/sheet/comments.d.ts +29 -0
- package/dist/sheet/comments.js +73 -0
- package/dist/sheet/conditional-formats.d.ts +144 -0
- package/dist/sheet/conditional-formats.js +316 -0
- package/dist/sheet/deps.d.ts +60 -0
- package/dist/sheet/deps.js +199 -0
- package/dist/sheet/document.d.ts +150 -0
- package/dist/sheet/document.js +264 -0
- package/dist/sheet/edit-keys.d.ts +14 -0
- package/dist/sheet/edit-keys.js +40 -0
- package/dist/sheet/entry.d.ts +31 -0
- package/dist/sheet/entry.js +76 -0
- package/dist/sheet/evaluate.d.ts +61 -0
- package/dist/sheet/evaluate.js +337 -0
- package/dist/sheet/find-replace.d.ts +62 -0
- package/dist/sheet/find-replace.js +152 -0
- package/dist/sheet/format-store.d.ts +99 -0
- package/dist/sheet/format-store.js +233 -0
- package/dist/sheet/freeze.d.ts +54 -0
- package/dist/sheet/freeze.js +58 -0
- package/dist/sheet/function-catalog.d.ts +10 -0
- package/dist/sheet/function-catalog.js +94 -0
- package/dist/sheet/functions.d.ts +28 -0
- package/dist/sheet/functions.js +362 -0
- package/dist/sheet/goal-seek.d.ts +73 -0
- package/dist/sheet/goal-seek.js +153 -0
- package/dist/sheet/index.d.ts +53 -0
- package/dist/sheet/index.js +53 -0
- package/dist/sheet/merges.d.ts +71 -0
- package/dist/sheet/merges.js +137 -0
- package/dist/sheet/names.d.ts +31 -0
- package/dist/sheet/names.js +87 -0
- package/dist/sheet/navigate.d.ts +52 -0
- package/dist/sheet/navigate.js +135 -0
- package/dist/sheet/number-format.d.ts +63 -0
- package/dist/sheet/number-format.js +508 -0
- package/dist/sheet/palette.d.ts +19 -0
- package/dist/sheet/palette.js +84 -0
- package/dist/sheet/parse.d.ts +13 -0
- package/dist/sheet/parse.js +108 -0
- package/dist/sheet/paste-special.d.ts +164 -0
- package/dist/sheet/paste-special.js +592 -0
- package/dist/sheet/protection.d.ts +21 -0
- package/dist/sheet/protection.js +48 -0
- package/dist/sheet/rects.d.ts +45 -0
- package/dist/sheet/rects.js +112 -0
- package/dist/sheet/refs.d.ts +82 -0
- package/dist/sheet/refs.js +266 -0
- package/dist/sheet/ribbon-icons.d.ts +31 -0
- package/dist/sheet/ribbon-icons.js +350 -0
- package/dist/sheet/ribbon.d.ts +173 -0
- package/dist/sheet/ribbon.js +753 -0
- package/dist/sheet/shortcuts.d.ts +164 -0
- package/dist/sheet/shortcuts.js +623 -0
- package/dist/sheet/structure.d.ts +87 -0
- package/dist/sheet/structure.js +166 -0
- package/dist/sheet/tables.d.ts +70 -0
- package/dist/sheet/tables.js +147 -0
- package/dist/sheet/tokenize.d.ts +54 -0
- package/dist/sheet/tokenize.js +304 -0
- package/dist/sheet/transforms.d.ts +76 -0
- package/dist/sheet/transforms.js +154 -0
- package/dist/sheet/validation.d.ts +92 -0
- package/dist/sheet/validation.js +241 -0
- package/dist/sheet/workbook.d.ts +72 -0
- package/dist/sheet/workbook.js +409 -0
- package/dist/sheet-enable.d.ts +6 -0
- package/dist/sheet-enable.js +46 -0
- package/dist/studio/ui-components.generated.js +63 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -4
- package/dist/designer/assets/GridMenus-B1JtIN21.js +0 -8
- package/dist/designer/assets/SvDateRangeInput-CjO7nn_x.js +0 -1
- package/dist/designer/assets/SvDateTimePicker-ByBD_ov6.js +0 -1
- package/dist/designer/assets/SvField-YDLipR6O.css +0 -1
- package/dist/designer/assets/SvField-cj1PFNgZ.js +0 -1
- package/dist/designer/assets/SvGridCellEditor-0W1L2hJ1.js +0 -2
- package/dist/designer/assets/SvGridChart-DBOR4xcz.js +0 -2
- package/dist/designer/assets/SvGridChart-fkMWeh1J.css +0 -1
- package/dist/designer/assets/SvGridChartPanel-symrhNnR.js +0 -11
- package/dist/designer/assets/SvGridChartView-BmRxq6mU.js +0 -1
- package/dist/designer/assets/SvListBox-1oUF6Iav.js +0 -110
- package/dist/designer/assets/chart-DXFganU8.js +0 -1
- package/dist/designer/assets/column-resize-C_inr5zT.js +0 -1
- package/dist/designer/assets/date-format-DGagAqRc.css +0 -1
- package/dist/designer/assets/date-format-onlYDsrY.js +0 -1
- package/dist/designer/assets/easing-zaypKrr0.js +0 -3
- package/dist/designer/assets/index-k2stW6L8.css +0 -1
- package/dist/designer/assets/row-resize-B0FWHcNr.js +0 -1
- package/dist/designer/assets/src-D9p27OGC.js +0 -58
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Excel's Convert Text to Columns Wizard, the delimited page: pick the
|
|
4
|
+
* delimiter (guessed from the column first), see the split in a preview,
|
|
5
|
+
* Finish writes the fields into the columns to the right of the source
|
|
6
|
+
* inside one batch, so the whole split is one Ctrl+Z.
|
|
7
|
+
*/
|
|
8
|
+
import { untrack } from 'svelte'
|
|
9
|
+
import { SvModal } from '@svgrid/grid'
|
|
10
|
+
import type { GridCommandContext } from '@svgrid/grid/shortcuts'
|
|
11
|
+
import type { Workbook } from './sheet/workbook'
|
|
12
|
+
import { textToColumns, guessDelimiter } from './sheet/transforms'
|
|
13
|
+
import { colToLetters } from './sheet/address'
|
|
14
|
+
|
|
15
|
+
type Props = {
|
|
16
|
+
open?: boolean
|
|
17
|
+
workbook: Workbook
|
|
18
|
+
cmd: () => GridCommandContext | null
|
|
19
|
+
/** Called after the split, so the shell repaints and refocuses. */
|
|
20
|
+
onDone: (message: string) => void
|
|
21
|
+
onClose?: () => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let { open = $bindable(false), workbook, cmd, onDone, onClose }: Props = $props()
|
|
25
|
+
|
|
26
|
+
const DELIMITERS = [
|
|
27
|
+
{ id: 'tab', label: 'Tab', sep: '\t' },
|
|
28
|
+
{ id: 'semicolon', label: 'Semicolon', sep: ';' },
|
|
29
|
+
{ id: 'comma', label: 'Comma', sep: ',' },
|
|
30
|
+
{ id: 'space', label: 'Space', sep: ' ' },
|
|
31
|
+
{ id: 'other', label: 'Other', sep: '' },
|
|
32
|
+
] as const
|
|
33
|
+
type DelimiterId = (typeof DELIMITERS)[number]['id']
|
|
34
|
+
|
|
35
|
+
let delimiter = $state<DelimiterId>('comma')
|
|
36
|
+
let other = $state('|')
|
|
37
|
+
let collapse = $state(false)
|
|
38
|
+
let trim = $state(true)
|
|
39
|
+
let column = $state<{ index: number; top: number; texts: string[] }>({ index: 0, top: 0, texts: [] })
|
|
40
|
+
|
|
41
|
+
const separator = $derived(
|
|
42
|
+
delimiter === 'other' ? other : DELIMITERS.find((d) => d.id === delimiter)!.sep,
|
|
43
|
+
)
|
|
44
|
+
const preview = $derived.by(() =>
|
|
45
|
+
textToColumns(column.texts.slice(0, 6), {
|
|
46
|
+
delimiters: separator ? [separator] : [','],
|
|
47
|
+
collapse,
|
|
48
|
+
trim,
|
|
49
|
+
}),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The column under the selection, from the selection's first row (a
|
|
54
|
+
* whole-column selection starts at the top) down to the last used row.
|
|
55
|
+
*/
|
|
56
|
+
$effect(() => {
|
|
57
|
+
if (!open) return
|
|
58
|
+
untrack(prepare)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
function prepare() {
|
|
62
|
+
const c = cmd()
|
|
63
|
+
const range = c?.ranges[c.ranges.length - 1]
|
|
64
|
+
const left = range ? range[1] : (c?.activeCell?.colIndex ?? 0)
|
|
65
|
+
const top = range ? range[0] : (c?.activeCell?.rowIndex ?? 0)
|
|
66
|
+
const bottom = Math.max(workbook.rowCount(workbook.active) - 1, top)
|
|
67
|
+
const texts = Array.from({ length: bottom - top + 1 }, (_, i) => workbook.getRaw(workbook.active, top + i, left))
|
|
68
|
+
column = { index: left, top, texts }
|
|
69
|
+
const guess = guessDelimiter(texts.filter((t) => t !== ''))
|
|
70
|
+
const known = DELIMITERS.find((d) => d.sep === guess && d.id !== 'other')
|
|
71
|
+
if (known) delimiter = known.id
|
|
72
|
+
else if (guess) { delimiter = 'other'; other = guess }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function finish() {
|
|
76
|
+
const c = cmd()
|
|
77
|
+
if (!c) return
|
|
78
|
+
const { rows, width } = textToColumns(column.texts, {
|
|
79
|
+
delimiters: separator ? [separator] : [','],
|
|
80
|
+
collapse,
|
|
81
|
+
trim,
|
|
82
|
+
})
|
|
83
|
+
c.batch(() => {
|
|
84
|
+
rows.forEach((fields, r) => {
|
|
85
|
+
for (let i = 0; i < width; i += 1) {
|
|
86
|
+
c.setCellValue(column.top + r, column.index + i, fields[i] ?? '')
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
open = false
|
|
91
|
+
c.setSelection(column.top, column.index)
|
|
92
|
+
c.extendSelection(column.top + rows.length - 1, column.index + width - 1)
|
|
93
|
+
onDone(`Split ${rows.length} rows into ${width} columns.`)
|
|
94
|
+
onClose?.()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function close() {
|
|
98
|
+
open = false
|
|
99
|
+
onClose?.()
|
|
100
|
+
}
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<SvModal bind:open onClose={onClose} title="Convert Text to Columns Wizard" size="md">
|
|
104
|
+
<div class="sv-sheet-dialog" role="group" aria-label="Convert Text to Columns">
|
|
105
|
+
<p class="lead">Choose the delimiter your data contains. The preview shows how it splits.</p>
|
|
106
|
+
<fieldset class="group">
|
|
107
|
+
<legend>Delimiters</legend>
|
|
108
|
+
{#each DELIMITERS as d (d.id)}
|
|
109
|
+
<label class="check">
|
|
110
|
+
<input type="radio" name="sheet-delimiter" value={d.id} bind:group={delimiter} />
|
|
111
|
+
{d.label}
|
|
112
|
+
{#if d.id === 'other'}
|
|
113
|
+
<input class="other" type="text" maxlength="1" bind:value={other} aria-label="Other delimiter" />
|
|
114
|
+
{/if}
|
|
115
|
+
</label>
|
|
116
|
+
{/each}
|
|
117
|
+
</fieldset>
|
|
118
|
+
<div class="checks">
|
|
119
|
+
<label class="check"><input type="checkbox" bind:checked={collapse} /> Treat consecutive delimiters as one</label>
|
|
120
|
+
<label class="check"><input type="checkbox" bind:checked={trim} /> Trim spaces around each field</label>
|
|
121
|
+
</div>
|
|
122
|
+
<div class="preview" aria-label="Data preview">
|
|
123
|
+
<table>
|
|
124
|
+
<tbody>
|
|
125
|
+
{#each preview.rows as fields, i (i)}
|
|
126
|
+
<tr>{#each fields as field, j (j)}<td>{field}</td>{/each}</tr>
|
|
127
|
+
{/each}
|
|
128
|
+
</tbody>
|
|
129
|
+
</table>
|
|
130
|
+
</div>
|
|
131
|
+
<p class="status">
|
|
132
|
+
{column.texts.length} rows in column {colToLetters(column.index)}
|
|
133
|
+
become {preview.width} column{preview.width === 1 ? '' : 's'} from column {colToLetters(column.index)}.
|
|
134
|
+
Anything already in those columns is replaced.
|
|
135
|
+
</p>
|
|
136
|
+
</div>
|
|
137
|
+
{#snippet footer()}
|
|
138
|
+
<div class="sv-sheet-dialog-buttons">
|
|
139
|
+
<button type="button" class="btn primary" onclick={finish} disabled={column.texts.length === 0}>Finish</button>
|
|
140
|
+
<button type="button" class="btn" onclick={close}>Cancel</button>
|
|
141
|
+
</div>
|
|
142
|
+
{/snippet}
|
|
143
|
+
</SvModal>
|
|
144
|
+
|
|
145
|
+
<style>
|
|
146
|
+
.lead { margin: 0; }
|
|
147
|
+
.group {
|
|
148
|
+
display: flex;
|
|
149
|
+
flex-wrap: wrap;
|
|
150
|
+
gap: 6px 16px;
|
|
151
|
+
margin: 0;
|
|
152
|
+
padding: 6px 10px 8px;
|
|
153
|
+
border: 1px solid var(--sg-border, #d1d1d1);
|
|
154
|
+
border-radius: var(--sg-radius, 3px);
|
|
155
|
+
}
|
|
156
|
+
.group legend { padding: 0 4px; font-weight: 600; }
|
|
157
|
+
.other { width: 32px !important; height: 22px !important; padding: 0 4px !important; text-align: center; }
|
|
158
|
+
.preview {
|
|
159
|
+
max-height: 150px;
|
|
160
|
+
overflow: auto;
|
|
161
|
+
border: 1px solid var(--sg-border, #d1d1d1);
|
|
162
|
+
border-radius: var(--sg-radius, 3px);
|
|
163
|
+
background: var(--sg-bg, #fff);
|
|
164
|
+
}
|
|
165
|
+
.preview table { border-collapse: collapse; font-size: 12px; }
|
|
166
|
+
.preview td {
|
|
167
|
+
padding: 3px 8px;
|
|
168
|
+
border-right: 1px solid var(--sg-border, #e5e5e5);
|
|
169
|
+
border-bottom: 1px solid var(--sg-border, #e5e5e5);
|
|
170
|
+
white-space: nowrap;
|
|
171
|
+
}
|
|
172
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GridCommandContext } from '@svgrid/grid/shortcuts';
|
|
2
|
+
import type { Workbook } from './sheet/workbook.js';
|
|
3
|
+
type Props = {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
workbook: Workbook;
|
|
6
|
+
cmd: () => GridCommandContext | null;
|
|
7
|
+
/** Called after the split, so the shell repaints and refocuses. */
|
|
8
|
+
onDone: (message: string) => void;
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
};
|
|
11
|
+
declare const SvSheetTextToColumns: import("svelte").Component<Props, {}, "open">;
|
|
12
|
+
type SvSheetTextToColumns = ReturnType<typeof SvSheetTextToColumns>;
|
|
13
|
+
export default SvSheetTextToColumns;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The box Excel shows when an entry breaks a validation rule. Stop: the
|
|
4
|
+
* message, Retry (the cell reopens with the entry) and Cancel. Warning:
|
|
5
|
+
* the message, "Continue?", Yes (the entry lands anyway), No (retry) and
|
|
6
|
+
* Cancel. Enter takes the first button, Escape cancels.
|
|
7
|
+
*/
|
|
8
|
+
import { SvModal } from '@svgrid/grid'
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
open?: boolean
|
|
12
|
+
alert: { style: 'stop' | 'warning'; title: string; message: string } | null
|
|
13
|
+
onRetry: () => void
|
|
14
|
+
/** Warning only: keep the entry. */
|
|
15
|
+
onAccept: () => void
|
|
16
|
+
onCancel: () => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let { open = $bindable(false), alert, onRetry, onAccept, onCancel }: Props = $props()
|
|
20
|
+
let first = $state<HTMLButtonElement | null>(null)
|
|
21
|
+
|
|
22
|
+
$effect(() => {
|
|
23
|
+
if (!open) return
|
|
24
|
+
queueMicrotask(() => first?.focus())
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
function done(fn: () => void) {
|
|
28
|
+
open = false
|
|
29
|
+
fn()
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<SvModal bind:open onClose={onCancel} title={alert?.title ?? 'Data validation'} size="sm">
|
|
34
|
+
<div class="sv-sheet-dialog alert" role="alertdialog" aria-describedby="sv-sheet-validation-message">
|
|
35
|
+
<span class="mark" class:warning={alert?.style === 'warning'} aria-hidden="true">{alert?.style === 'warning' ? '!' : '×'}</span>
|
|
36
|
+
<div>
|
|
37
|
+
<p id="sv-sheet-validation-message" class="message">{alert?.message}</p>
|
|
38
|
+
{#if alert?.style === 'warning'}<p class="message">Continue?</p>{/if}
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
{#snippet footer()}
|
|
42
|
+
<div class="sv-sheet-dialog-buttons">
|
|
43
|
+
{#if alert?.style === 'warning'}
|
|
44
|
+
<button bind:this={first} type="button" class="btn primary" onclick={() => done(onAccept)}>Yes</button>
|
|
45
|
+
<button type="button" class="btn" onclick={() => done(onRetry)}>No</button>
|
|
46
|
+
{:else}
|
|
47
|
+
<button bind:this={first} type="button" class="btn primary" onclick={() => done(onRetry)}>Retry</button>
|
|
48
|
+
{/if}
|
|
49
|
+
<button type="button" class="btn" onclick={() => done(onCancel)}>Cancel</button>
|
|
50
|
+
</div>
|
|
51
|
+
{/snippet}
|
|
52
|
+
</SvModal>
|
|
53
|
+
|
|
54
|
+
<style>
|
|
55
|
+
.alert {
|
|
56
|
+
flex-direction: row;
|
|
57
|
+
align-items: flex-start;
|
|
58
|
+
gap: 14px;
|
|
59
|
+
min-width: 300px;
|
|
60
|
+
max-width: 420px;
|
|
61
|
+
}
|
|
62
|
+
.mark {
|
|
63
|
+
flex: 0 0 auto;
|
|
64
|
+
width: 32px;
|
|
65
|
+
height: 32px;
|
|
66
|
+
display: grid;
|
|
67
|
+
place-items: center;
|
|
68
|
+
font-size: 20px;
|
|
69
|
+
font-weight: 700;
|
|
70
|
+
line-height: 1;
|
|
71
|
+
color: var(--sg-on-accent, #fff);
|
|
72
|
+
background: var(--sg-danger, #c42b1c);
|
|
73
|
+
border-radius: 50%;
|
|
74
|
+
}
|
|
75
|
+
.mark.warning {
|
|
76
|
+
color: #242424;
|
|
77
|
+
background: var(--sg-warning, #f2c811);
|
|
78
|
+
}
|
|
79
|
+
.message {
|
|
80
|
+
margin: 0 0 6px;
|
|
81
|
+
white-space: pre-wrap;
|
|
82
|
+
}
|
|
83
|
+
</style>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
open?: boolean;
|
|
3
|
+
alert: {
|
|
4
|
+
style: 'stop' | 'warning';
|
|
5
|
+
title: string;
|
|
6
|
+
message: string;
|
|
7
|
+
} | null;
|
|
8
|
+
onRetry: () => void;
|
|
9
|
+
/** Warning only: keep the entry. */
|
|
10
|
+
onAccept: () => void;
|
|
11
|
+
onCancel: () => void;
|
|
12
|
+
};
|
|
13
|
+
declare const SvSheetValidationAlert: import("svelte").Component<Props, {}, "open">;
|
|
14
|
+
type SvSheetValidationAlert = ReturnType<typeof SvSheetValidationAlert>;
|
|
15
|
+
export default SvSheetValidationAlert;
|