@sveltia/ui 0.7.5 → 0.8.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/package/components/alert/alert.svelte +4 -4
- package/package/components/alert/alert.svelte.d.ts +2 -2
- package/package/components/button/button.svelte +5 -3
- package/package/components/button/button.svelte.d.ts +6 -4
- package/package/components/button/select-button-group.svelte +9 -5
- package/package/components/button/select-button.svelte +5 -4
- package/package/components/button/select-button.svelte.d.ts +2 -0
- package/package/components/calendar/calendar.svelte +20 -14
- package/package/components/checkbox/checkbox-group.svelte +6 -5
- package/package/components/checkbox/checkbox.svelte +6 -4
- package/package/components/checkbox/checkbox.svelte.d.ts +2 -2
- package/package/components/dialog/alert-dialog.svelte +50 -0
- package/package/components/dialog/alert-dialog.svelte.d.ts +55 -0
- package/package/components/dialog/confirmation-dialog.svelte +55 -0
- package/package/components/dialog/confirmation-dialog.svelte.d.ts +57 -0
- package/package/components/dialog/dialog.svelte +165 -221
- package/package/components/dialog/dialog.svelte.d.ts +20 -12
- package/package/components/dialog/prompt-dialog.svelte +87 -0
- package/package/components/dialog/prompt-dialog.svelte.d.ts +72 -0
- package/package/components/disclosure/disclosure.svelte +3 -2
- package/package/components/divider/divider.svelte +1 -1
- package/package/components/divider/spacer.svelte +1 -12
- package/package/components/divider/spacer.svelte.d.ts +0 -2
- package/package/components/drawer/drawer.svelte +119 -209
- package/package/components/drawer/drawer.svelte.d.ts +13 -9
- package/package/components/grid/grid-body.svelte +51 -0
- package/package/components/grid/grid-body.svelte.d.ts +36 -0
- package/package/components/grid/grid-cell.svelte +22 -0
- package/package/components/grid/grid-cell.svelte.d.ts +34 -0
- package/package/components/grid/grid-col-header.svelte +22 -0
- package/package/components/grid/grid-col-header.svelte.d.ts +34 -0
- package/package/components/grid/grid-foot.svelte +27 -0
- package/package/components/grid/grid-foot.svelte.d.ts +34 -0
- package/package/components/grid/grid-head.svelte +27 -0
- package/package/components/grid/grid-head.svelte.d.ts +34 -0
- package/package/components/grid/grid-row-header.svelte +23 -0
- package/package/components/grid/grid-row-header.svelte.d.ts +34 -0
- package/package/components/grid/grid-row.svelte +37 -0
- package/package/components/grid/grid-row.svelte.d.ts +44 -0
- package/package/components/grid/grid.svelte +52 -0
- package/package/components/grid/grid.svelte.d.ts +42 -0
- package/package/components/icon/icon.svelte +6 -7
- package/package/components/icon/icon.svelte.d.ts +0 -2
- package/package/components/listbox/listbox.svelte +3 -3
- package/package/components/listbox/option-group.svelte +6 -5
- package/package/components/listbox/option.svelte +7 -28
- package/package/components/listbox/option.svelte.d.ts +2 -0
- package/package/components/menu/menu-button.svelte +26 -16
- package/package/components/menu/menu-button.svelte.d.ts +2 -2
- package/package/components/menu/menu-item-checkbox.svelte +5 -4
- package/package/components/menu/menu-item-checkbox.svelte.d.ts +2 -0
- package/package/components/menu/menu-item-group.svelte +4 -3
- package/package/components/menu/menu-item-radio.svelte +5 -4
- package/package/components/menu/menu-item-radio.svelte.d.ts +2 -0
- package/package/components/menu/menu-item.svelte +7 -5
- package/package/components/menu/menu-item.svelte.d.ts +4 -2
- package/package/components/menu/menu.svelte +1 -1
- package/package/components/radio/radio-group.svelte +5 -5
- package/package/components/radio/radio.svelte +5 -2
- package/package/components/radio/radio.svelte.d.ts +2 -0
- package/package/components/select/combobox.svelte +11 -9
- package/package/components/slider/slider.svelte +12 -5
- package/package/components/switch/switch.svelte +3 -2
- package/package/components/switch/switch.svelte.d.ts +2 -2
- package/package/components/table/table-body.svelte +31 -3
- package/package/components/table/table-body.svelte.d.ts +2 -0
- package/package/components/table/table-cell.svelte +3 -4
- package/package/components/table/table-cell.svelte.d.ts +1 -1
- package/package/components/table/table-col-header.svelte +1 -2
- package/package/components/table/table-foot.svelte +7 -3
- package/package/components/table/table-head.svelte +7 -3
- package/package/components/table/table-row-header.svelte +1 -2
- package/package/components/table/table-row.svelte +1 -14
- package/package/components/table/table-row.svelte.d.ts +0 -8
- package/package/components/table/table.svelte +5 -17
- package/package/components/table/table.svelte.d.ts +1 -7
- package/package/components/tabs/tab-list.svelte +7 -5
- package/package/components/tabs/tab-panel.svelte +1 -1
- package/package/components/tabs/tab.svelte +2 -1
- package/package/components/tabs/tab.svelte.d.ts +2 -0
- package/package/components/text-field/markdown-editor.svelte +30 -6
- package/package/components/text-field/markdown-editor.svelte.d.ts +2 -0
- package/package/components/text-field/number-input.svelte +36 -6
- package/package/components/text-field/number-input.svelte.d.ts +2 -0
- package/package/components/text-field/password-input.svelte +34 -8
- package/package/components/text-field/password-input.svelte.d.ts +2 -0
- package/package/components/text-field/search-bar.svelte +39 -11
- package/package/components/text-field/search-bar.svelte.d.ts +5 -0
- package/package/components/text-field/text-area.svelte +21 -2
- package/package/components/text-field/text-area.svelte.d.ts +2 -0
- package/package/components/text-field/text-input.svelte +22 -4
- package/package/components/text-field/text-input.svelte.d.ts +7 -2
- package/package/components/toast/toast.svelte +47 -17
- package/package/components/toast/toast.svelte.d.ts +7 -3
- package/package/components/toolbar/toolbar.svelte +3 -4
- package/package/components/util/app-shell.svelte +26 -27
- package/package/components/util/group.svelte +2 -2
- package/package/components/util/modal.svelte +220 -0
- package/package/components/util/modal.svelte.d.ts +83 -0
- package/package/components/util/popup.svelte +81 -127
- package/package/components/util/popup.svelte.d.ts +22 -18
- package/package/components/util/portal.svelte +1 -1
- package/package/index.d.ts +12 -0
- package/package/index.js +12 -0
- package/package/locales/en.d.ts +1 -0
- package/package/locales/en.js +1 -0
- package/package/locales/ja.d.ts +1 -0
- package/package/locales/ja.js +1 -0
- package/package/services/group.js +51 -13
- package/package/styles/core.scss +9 -26
- package/package/styles/variables.scss +12 -0
- package/package/typedef.d.ts +1 -0
- package/package/typedef.js +5 -0
- package/package.json +97 -1
|
@@ -5,289 +5,232 @@
|
|
|
5
5
|
@see https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/
|
|
6
6
|
-->
|
|
7
7
|
<script>
|
|
8
|
-
import { createEventDispatcher, onMount } from 'svelte';
|
|
9
8
|
import { _ } from 'svelte-i18n';
|
|
9
|
+
import { getRandomId } from '../../services/util';
|
|
10
10
|
import Button from '../button/button.svelte';
|
|
11
11
|
import Spacer from '../divider/spacer.svelte';
|
|
12
12
|
import Icon from '../icon/icon.svelte';
|
|
13
|
+
import Modal from '../util/modal.svelte';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* The `class` attribute on the content element.
|
|
16
17
|
* @type {string}
|
|
17
18
|
*/
|
|
18
19
|
let className = '';
|
|
19
|
-
|
|
20
20
|
export { className as class };
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The `role` attribute on the `<dialog>` element.
|
|
23
|
+
* @type {'dialog' | 'alertdialog'}
|
|
24
|
+
*/
|
|
25
|
+
export let role = 'dialog';
|
|
26
26
|
/**
|
|
27
27
|
* Width of the dialog.
|
|
28
28
|
* @type {('small' | 'medium' | 'large' | 'x-large')}
|
|
29
29
|
*/
|
|
30
30
|
export let size = 'medium';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Whether to open the dialog.
|
|
33
|
+
* @type {boolean}
|
|
34
|
+
*/
|
|
35
|
+
export let open = false;
|
|
36
|
+
/**
|
|
37
|
+
* Text label displayed on the header. Required.
|
|
38
|
+
* @type {string}
|
|
39
|
+
*/
|
|
40
|
+
export let title;
|
|
41
|
+
/**
|
|
42
|
+
* Whether to show the Close button on the header.
|
|
43
|
+
* @type {boolean}
|
|
44
|
+
*/
|
|
38
45
|
export let showClose = false;
|
|
39
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Whether to show the OK button on the footer.
|
|
48
|
+
* @type {boolean}
|
|
49
|
+
*/
|
|
50
|
+
export let showOk = true;
|
|
51
|
+
/**
|
|
52
|
+
* Text label displayed on the OK button.
|
|
53
|
+
* @type {string}
|
|
54
|
+
*/
|
|
40
55
|
export let okLabel = '';
|
|
41
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Whether to disable the OK button.
|
|
58
|
+
* @type {boolean}
|
|
59
|
+
*/
|
|
42
60
|
export let okDisabled = false;
|
|
43
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Whether to show the Cancel button on the footer.
|
|
63
|
+
* @type {boolean}
|
|
64
|
+
*/
|
|
65
|
+
export let showCancel = true;
|
|
66
|
+
/**
|
|
67
|
+
* Text label displayed on the Cancel button.
|
|
68
|
+
* @type {string}
|
|
69
|
+
*/
|
|
44
70
|
export let cancelLabel = '';
|
|
45
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Whether to disable the Cancel button.
|
|
73
|
+
* @type {boolean}
|
|
74
|
+
*/
|
|
46
75
|
export let cancelDisabled = false;
|
|
47
|
-
|
|
48
|
-
export let closeOnBackdropClick = false;
|
|
49
|
-
|
|
50
|
-
const dispatch = createEventDispatcher();
|
|
51
|
-
/** @type {?HTMLDialogElement} */
|
|
52
|
-
let dialog;
|
|
53
|
-
/** @type {?HTMLFormElement} */
|
|
54
|
-
let form;
|
|
55
|
-
let showDialog = false;
|
|
56
|
-
let showContent = false;
|
|
57
|
-
|
|
58
76
|
/**
|
|
59
|
-
*
|
|
77
|
+
* Whether to close the modal when the backdrop (outside of the modal) is clicked.
|
|
78
|
+
* @type {boolean}
|
|
60
79
|
*/
|
|
61
|
-
|
|
62
|
-
(document.querySelector('.sui.app-shell') ?? document.body).appendChild(dialog);
|
|
63
|
-
showContent = true;
|
|
64
|
-
|
|
65
|
-
if (modal) {
|
|
66
|
-
dialog.showModal();
|
|
67
|
-
} else {
|
|
68
|
-
dialog.show();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
window.requestAnimationFrame(() => {
|
|
72
|
-
showDialog = true;
|
|
73
|
-
});
|
|
74
|
-
};
|
|
80
|
+
export let lightDismiss = false;
|
|
75
81
|
|
|
76
82
|
/**
|
|
77
|
-
*
|
|
83
|
+
* The ID of the drawer.
|
|
84
|
+
* @type {string}
|
|
78
85
|
*/
|
|
79
|
-
const
|
|
80
|
-
showDialog = false;
|
|
81
|
-
|
|
82
|
-
await new Promise((resolve) => {
|
|
83
|
-
form.addEventListener('transitionend', () => resolve(), { once: true });
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
showContent = false;
|
|
87
|
-
dialog?.close();
|
|
88
|
-
dialog?.remove();
|
|
89
|
-
|
|
90
|
-
if (['ok', 'cancel'].includes(dialog?.returnValue)) {
|
|
91
|
-
dispatch(dialog?.returnValue);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
dispatch('close', dialog?.returnValue);
|
|
95
|
-
};
|
|
96
|
-
|
|
86
|
+
const id = getRandomId('dialog');
|
|
97
87
|
/**
|
|
98
|
-
*
|
|
88
|
+
* a reference to the modal component.
|
|
89
|
+
* @type {Modal}
|
|
99
90
|
*/
|
|
100
|
-
|
|
101
|
-
if (dialog) {
|
|
102
|
-
if (open) {
|
|
103
|
-
openDialog();
|
|
104
|
-
} else {
|
|
105
|
-
closeDialog();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
$: {
|
|
111
|
-
void open;
|
|
112
|
-
toggleDialog();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
onMount(() => {
|
|
116
|
-
dialog.remove();
|
|
117
|
-
|
|
118
|
-
// onUnmount
|
|
119
|
-
return () => {
|
|
120
|
-
dialog?.close();
|
|
121
|
-
dialog?.remove();
|
|
122
|
-
};
|
|
123
|
-
});
|
|
91
|
+
let modal;
|
|
124
92
|
</script>
|
|
125
93
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
class="
|
|
130
|
-
|
|
131
|
-
aria-
|
|
94
|
+
<Modal
|
|
95
|
+
{role}
|
|
96
|
+
{id}
|
|
97
|
+
class="dialog"
|
|
98
|
+
aria-label={$$slots.header ? undefined : title}
|
|
99
|
+
aria-labelledby={$$slots.header ? title : `${id}-title`}
|
|
100
|
+
aria-describedby="{id}-body"
|
|
101
|
+
bind:open
|
|
102
|
+
showBackdrop
|
|
103
|
+
{lightDismiss}
|
|
132
104
|
{...$$restProps}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
on:
|
|
140
|
-
// Cancelled with the Escape key
|
|
141
|
-
open = false;
|
|
142
|
-
}}
|
|
105
|
+
bind:this={modal}
|
|
106
|
+
on:opening
|
|
107
|
+
on:open
|
|
108
|
+
on:ok
|
|
109
|
+
on:cancel
|
|
110
|
+
on:closing
|
|
111
|
+
on:close
|
|
143
112
|
>
|
|
144
|
-
<
|
|
145
|
-
{#if
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
{
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
{/if}
|
|
113
|
+
<div role="none" class="content {className} {size}">
|
|
114
|
+
{#if title || showClose || $$slots.header || $$slots['header-extra']}
|
|
115
|
+
<div role="none" class="header">
|
|
116
|
+
{#if $$slots.header}
|
|
117
|
+
<slot name="header" />
|
|
118
|
+
{:else}
|
|
119
|
+
<div role="none" id="{id}-title" class="title">
|
|
120
|
+
{title}
|
|
121
|
+
</div>
|
|
122
|
+
<Spacer flex={true} />
|
|
123
|
+
{#if $$slots['header-extra']}
|
|
124
|
+
<slot name="header-extra" />
|
|
125
|
+
{/if}
|
|
126
|
+
{#if showClose}
|
|
127
|
+
<Button
|
|
128
|
+
variant="ghost"
|
|
129
|
+
iconic
|
|
130
|
+
aria-label={$_('_sui.close')}
|
|
131
|
+
aria-controls={id}
|
|
132
|
+
on:click={() => {
|
|
133
|
+
modal.close('close');
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
<Icon slot="start-icon" name="close" />
|
|
137
|
+
</Button>
|
|
170
138
|
{/if}
|
|
171
|
-
|
|
172
|
-
{/if}
|
|
173
|
-
<div class="main">
|
|
174
|
-
<slot />
|
|
139
|
+
{/if}
|
|
175
140
|
</div>
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
141
|
+
{/if}
|
|
142
|
+
<div role="none" id="{id}-body" class="body">
|
|
143
|
+
<slot />
|
|
144
|
+
</div>
|
|
145
|
+
{#if showOk || showCancel || $$slots.footer || $$slots['footer-extra']}
|
|
146
|
+
<div role="none" class="footer">
|
|
147
|
+
{#if $$slots.footer}
|
|
148
|
+
<slot name="footer" />
|
|
149
|
+
{:else}
|
|
150
|
+
{#if $$slots['footer-extra']}
|
|
151
|
+
<slot name="footer-extra" />
|
|
152
|
+
{/if}
|
|
153
|
+
<Spacer flex={true} />
|
|
154
|
+
{#if showOk}
|
|
155
|
+
<Button
|
|
156
|
+
variant="primary"
|
|
157
|
+
label={okLabel || $_('_sui.ok')}
|
|
158
|
+
disabled={okDisabled}
|
|
159
|
+
on:click={() => {
|
|
160
|
+
modal.close('ok');
|
|
161
|
+
}}
|
|
162
|
+
/>
|
|
163
|
+
{/if}
|
|
164
|
+
{#if showCancel}
|
|
165
|
+
<Button
|
|
166
|
+
variant="secondary"
|
|
167
|
+
label={cancelLabel || $_('_sui.cancel')}
|
|
168
|
+
disabled={cancelDisabled}
|
|
169
|
+
on:click={() => {
|
|
170
|
+
modal.close('cancel');
|
|
171
|
+
}}
|
|
172
|
+
/>
|
|
207
173
|
{/if}
|
|
208
|
-
|
|
209
|
-
|
|
174
|
+
{/if}
|
|
175
|
+
</div>
|
|
210
176
|
{/if}
|
|
211
|
-
</
|
|
212
|
-
</
|
|
177
|
+
</div>
|
|
178
|
+
</Modal>
|
|
213
179
|
|
|
214
|
-
<style
|
|
215
|
-
|
|
216
|
-
justify-content: center;
|
|
217
|
-
align-items: center;
|
|
218
|
-
outline: 0;
|
|
219
|
-
background-color: var(--sui-popup-backdrop-color);
|
|
220
|
-
}
|
|
221
|
-
dialog.open form {
|
|
222
|
-
opacity: 1;
|
|
223
|
-
transform: scale(100%);
|
|
224
|
-
transition-duration: 100ms;
|
|
225
|
-
}
|
|
226
|
-
dialog:not(.open) {
|
|
227
|
-
pointer-events: none !important;
|
|
228
|
-
}
|
|
229
|
-
dialog:not(.open) form {
|
|
230
|
-
opacity: 0;
|
|
231
|
-
transform: scale(90%);
|
|
232
|
-
pointer-events: none;
|
|
233
|
-
transition-duration: 200ms;
|
|
234
|
-
}
|
|
235
|
-
dialog:not(.open) :global(*) {
|
|
236
|
-
pointer-events: none !important;
|
|
237
|
-
}
|
|
238
|
-
dialog :global(a),
|
|
239
|
-
dialog :global(input[aria-disabled="false"]),
|
|
240
|
-
dialog :global(textarea[aria-disabled="false"]),
|
|
241
|
-
dialog :global(button[aria-disabled="false"]),
|
|
242
|
-
dialog :global([tabindex="0"]) {
|
|
243
|
-
pointer-events: all;
|
|
244
|
-
}
|
|
245
|
-
dialog form {
|
|
180
|
+
<style>.content {
|
|
181
|
+
position: relative;
|
|
246
182
|
display: flex;
|
|
247
183
|
flex-direction: column;
|
|
248
184
|
border-radius: 4px;
|
|
249
|
-
max-width: calc(
|
|
185
|
+
max-width: calc(100dvw - 32px);
|
|
250
186
|
background-color: var(--sui-secondary-background-color-translucent);
|
|
251
|
-
-webkit-backdrop-filter: blur(32px);
|
|
252
|
-
backdrop-filter: blur(32px);
|
|
253
187
|
box-shadow: 0 8px 16px var(--sui-popup-shadow-color);
|
|
254
|
-
|
|
255
|
-
|
|
188
|
+
-webkit-backdrop-filter: blur(16px);
|
|
189
|
+
backdrop-filter: blur(16px);
|
|
190
|
+
transition-property: transform;
|
|
191
|
+
}
|
|
192
|
+
:global(dialog.open) .content {
|
|
193
|
+
transition-duration: 150ms;
|
|
194
|
+
transform: scale(100%);
|
|
195
|
+
}
|
|
196
|
+
:global(dialog:not(.open)) .content {
|
|
197
|
+
transition-duration: 300ms;
|
|
198
|
+
transform: scale(90%);
|
|
256
199
|
}
|
|
257
|
-
|
|
200
|
+
.content.small {
|
|
258
201
|
width: 400px;
|
|
259
202
|
max-height: 400px;
|
|
260
203
|
}
|
|
261
204
|
@media (max-height: 400px) {
|
|
262
|
-
|
|
263
|
-
max-height: calc(
|
|
205
|
+
.content.small {
|
|
206
|
+
max-height: calc(100dvh - 32px);
|
|
264
207
|
}
|
|
265
208
|
}
|
|
266
|
-
|
|
209
|
+
.content.medium {
|
|
267
210
|
width: 600px;
|
|
268
211
|
max-height: 600px;
|
|
269
212
|
}
|
|
270
213
|
@media (max-height: 600px) {
|
|
271
|
-
|
|
272
|
-
max-height: calc(
|
|
214
|
+
.content.medium {
|
|
215
|
+
max-height: calc(100dvh - 32px);
|
|
273
216
|
}
|
|
274
217
|
}
|
|
275
|
-
|
|
218
|
+
.content.large {
|
|
276
219
|
width: 800px;
|
|
277
220
|
max-height: 800px;
|
|
278
221
|
}
|
|
279
222
|
@media (max-height: 800px) {
|
|
280
|
-
|
|
281
|
-
max-height: calc(
|
|
223
|
+
.content.large {
|
|
224
|
+
max-height: calc(100dvh - 32px);
|
|
282
225
|
}
|
|
283
226
|
}
|
|
284
|
-
|
|
227
|
+
.content.x-large {
|
|
285
228
|
width: 1000px;
|
|
286
229
|
max-height: 1000px;
|
|
287
230
|
}
|
|
288
231
|
@media (max-height: 1000px) {
|
|
289
|
-
|
|
290
|
-
max-height: calc(
|
|
232
|
+
.content.x-large {
|
|
233
|
+
max-height: calc(100dvh - 32px);
|
|
291
234
|
}
|
|
292
235
|
}
|
|
293
236
|
|
|
@@ -295,7 +238,7 @@ dialog.x-large form {
|
|
|
295
238
|
.footer {
|
|
296
239
|
display: flex;
|
|
297
240
|
align-items: center;
|
|
298
|
-
gap:
|
|
241
|
+
gap: 4px;
|
|
299
242
|
}
|
|
300
243
|
|
|
301
244
|
.header {
|
|
@@ -314,8 +257,9 @@ dialog.x-large form {
|
|
|
314
257
|
margin: 0 24px 24px;
|
|
315
258
|
}
|
|
316
259
|
|
|
317
|
-
.
|
|
260
|
+
.body {
|
|
318
261
|
overflow: auto;
|
|
319
262
|
margin: 24px 24px;
|
|
320
263
|
white-space: normal;
|
|
264
|
+
line-height: var(--sui-line-height-compact);
|
|
321
265
|
}</style>
|
|
@@ -8,21 +8,25 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export default class Dialog extends SvelteComponent<{
|
|
10
10
|
[x: string]: any;
|
|
11
|
+
title: string;
|
|
11
12
|
class?: string;
|
|
12
|
-
title?: string;
|
|
13
13
|
size?: "small" | "medium" | "large" | "x-large";
|
|
14
|
+
role?: "dialog" | "alertdialog";
|
|
14
15
|
open?: boolean;
|
|
15
|
-
|
|
16
|
-
showCancel?: boolean;
|
|
17
|
-
showOk?: boolean;
|
|
16
|
+
lightDismiss?: boolean;
|
|
18
17
|
showClose?: boolean;
|
|
18
|
+
showOk?: boolean;
|
|
19
19
|
okLabel?: string;
|
|
20
20
|
okDisabled?: boolean;
|
|
21
|
+
showCancel?: boolean;
|
|
21
22
|
cancelLabel?: string;
|
|
22
23
|
cancelDisabled?: boolean;
|
|
23
|
-
closeOnBackdropClick?: boolean;
|
|
24
24
|
}, {
|
|
25
|
-
|
|
25
|
+
opening: CustomEvent<any>;
|
|
26
|
+
open: CustomEvent<any>;
|
|
27
|
+
ok: CustomEvent<any>;
|
|
28
|
+
cancel: CustomEvent<any>;
|
|
29
|
+
closing: CustomEvent<any>;
|
|
26
30
|
close: CustomEvent<any>;
|
|
27
31
|
} & {
|
|
28
32
|
[evt: string]: CustomEvent<any>;
|
|
@@ -41,22 +45,26 @@ import { SvelteComponent } from "svelte";
|
|
|
41
45
|
declare const __propDef: {
|
|
42
46
|
props: {
|
|
43
47
|
[x: string]: any;
|
|
48
|
+
title: string;
|
|
44
49
|
class?: string;
|
|
45
|
-
title?: string;
|
|
46
50
|
size?: ('small' | 'medium' | 'large' | 'x-large');
|
|
51
|
+
role?: 'dialog' | 'alertdialog';
|
|
47
52
|
open?: boolean;
|
|
48
|
-
|
|
49
|
-
showCancel?: boolean;
|
|
50
|
-
showOk?: boolean;
|
|
53
|
+
lightDismiss?: boolean;
|
|
51
54
|
showClose?: boolean;
|
|
55
|
+
showOk?: boolean;
|
|
52
56
|
okLabel?: string;
|
|
53
57
|
okDisabled?: boolean;
|
|
58
|
+
showCancel?: boolean;
|
|
54
59
|
cancelLabel?: string;
|
|
55
60
|
cancelDisabled?: boolean;
|
|
56
|
-
closeOnBackdropClick?: boolean;
|
|
57
61
|
};
|
|
58
62
|
events: {
|
|
59
|
-
|
|
63
|
+
opening: CustomEvent<any>;
|
|
64
|
+
open: CustomEvent<any>;
|
|
65
|
+
ok: CustomEvent<any>;
|
|
66
|
+
cancel: CustomEvent<any>;
|
|
67
|
+
closing: CustomEvent<any>;
|
|
60
68
|
close: CustomEvent<any>;
|
|
61
69
|
} & {
|
|
62
70
|
[evt: string]: CustomEvent<any>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
A modal prompt dialog. It shows the OK and Cancel buttons as well as a textbox, just like
|
|
4
|
+
`window.prompt()`.
|
|
5
|
+
@see https://w3c.github.io/aria/#alertdialog
|
|
6
|
+
@see https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/
|
|
7
|
+
@see https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt
|
|
8
|
+
-->
|
|
9
|
+
<script>
|
|
10
|
+
import TextInput from '../text-field/text-input.svelte';
|
|
11
|
+
import Dialog from './dialog.svelte';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The `class` attribute on the `<dialog>` element.
|
|
15
|
+
* @type {string}
|
|
16
|
+
*/
|
|
17
|
+
let className = '';
|
|
18
|
+
export { className as class };
|
|
19
|
+
/**
|
|
20
|
+
* Whether to open the dialog.
|
|
21
|
+
* @type {boolean}
|
|
22
|
+
*/
|
|
23
|
+
export let open = false;
|
|
24
|
+
/**
|
|
25
|
+
* Text label displayed on the header. Required.
|
|
26
|
+
* @type {string}
|
|
27
|
+
*/
|
|
28
|
+
export let title;
|
|
29
|
+
/**
|
|
30
|
+
* Text label displayed on the OK button.
|
|
31
|
+
* @type {string}
|
|
32
|
+
*/
|
|
33
|
+
export let okLabel = '';
|
|
34
|
+
/**
|
|
35
|
+
* Text label displayed on the Cancel button.
|
|
36
|
+
* @type {string}
|
|
37
|
+
*/
|
|
38
|
+
export let cancelLabel = '';
|
|
39
|
+
/**
|
|
40
|
+
* Value entered on the textbox.
|
|
41
|
+
* @type {string}
|
|
42
|
+
*/
|
|
43
|
+
export let value = '';
|
|
44
|
+
/**
|
|
45
|
+
* Extra attributes for the `<TextInput>`
|
|
46
|
+
* @type {object}
|
|
47
|
+
*/
|
|
48
|
+
export let textboxAttrs = {};
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<Dialog
|
|
52
|
+
role="alertdialog"
|
|
53
|
+
class={className}
|
|
54
|
+
bind:open
|
|
55
|
+
{title}
|
|
56
|
+
{okLabel}
|
|
57
|
+
{cancelLabel}
|
|
58
|
+
{...$$restProps}
|
|
59
|
+
on:opening
|
|
60
|
+
on:open
|
|
61
|
+
on:ok
|
|
62
|
+
on:cancel
|
|
63
|
+
on:closing
|
|
64
|
+
on:close
|
|
65
|
+
>
|
|
66
|
+
<slot />
|
|
67
|
+
<div class="input-outer">
|
|
68
|
+
{#if $$slots.input}
|
|
69
|
+
<slot name="input" />
|
|
70
|
+
{:else}
|
|
71
|
+
<TextInput
|
|
72
|
+
bind:value
|
|
73
|
+
flex
|
|
74
|
+
autofocus
|
|
75
|
+
{...textboxAttrs}
|
|
76
|
+
on:input
|
|
77
|
+
on:keydown
|
|
78
|
+
on:keyup
|
|
79
|
+
on:keypress
|
|
80
|
+
/>
|
|
81
|
+
{/if}
|
|
82
|
+
</div>
|
|
83
|
+
</Dialog>
|
|
84
|
+
|
|
85
|
+
<style>.input-outer {
|
|
86
|
+
margin: 12px 0 0;
|
|
87
|
+
}</style>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} PromptDialogProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} PromptDialogEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} PromptDialogSlots */
|
|
4
|
+
/**
|
|
5
|
+
* A modal prompt dialog. It shows the OK and Cancel buttons as well as a textbox, just like
|
|
6
|
+
* `window.prompt()`.
|
|
7
|
+
* @see https://w3c.github.io/aria/#alertdialog
|
|
8
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/
|
|
9
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt
|
|
10
|
+
*/
|
|
11
|
+
export default class PromptDialog extends SvelteComponent<{
|
|
12
|
+
[x: string]: any;
|
|
13
|
+
title: string;
|
|
14
|
+
class?: string;
|
|
15
|
+
value?: string;
|
|
16
|
+
open?: boolean;
|
|
17
|
+
okLabel?: string;
|
|
18
|
+
cancelLabel?: string;
|
|
19
|
+
textboxAttrs?: object;
|
|
20
|
+
}, {
|
|
21
|
+
opening: CustomEvent<any>;
|
|
22
|
+
open: CustomEvent<any>;
|
|
23
|
+
ok: CustomEvent<any>;
|
|
24
|
+
cancel: CustomEvent<any>;
|
|
25
|
+
closing: CustomEvent<any>;
|
|
26
|
+
close: CustomEvent<any>;
|
|
27
|
+
input: Event;
|
|
28
|
+
keydown: KeyboardEvent;
|
|
29
|
+
keyup: KeyboardEvent;
|
|
30
|
+
keypress: KeyboardEvent;
|
|
31
|
+
} & {
|
|
32
|
+
[evt: string]: CustomEvent<any>;
|
|
33
|
+
}, {
|
|
34
|
+
default: {};
|
|
35
|
+
input: {};
|
|
36
|
+
}> {
|
|
37
|
+
}
|
|
38
|
+
export type PromptDialogProps = typeof __propDef.props;
|
|
39
|
+
export type PromptDialogEvents = typeof __propDef.events;
|
|
40
|
+
export type PromptDialogSlots = typeof __propDef.slots;
|
|
41
|
+
import { SvelteComponent } from "svelte";
|
|
42
|
+
declare const __propDef: {
|
|
43
|
+
props: {
|
|
44
|
+
[x: string]: any;
|
|
45
|
+
title: string;
|
|
46
|
+
class?: string;
|
|
47
|
+
value?: string;
|
|
48
|
+
open?: boolean;
|
|
49
|
+
okLabel?: string;
|
|
50
|
+
cancelLabel?: string;
|
|
51
|
+
textboxAttrs?: object;
|
|
52
|
+
};
|
|
53
|
+
events: {
|
|
54
|
+
opening: CustomEvent<any>;
|
|
55
|
+
open: CustomEvent<any>;
|
|
56
|
+
ok: CustomEvent<any>;
|
|
57
|
+
cancel: CustomEvent<any>;
|
|
58
|
+
closing: CustomEvent<any>;
|
|
59
|
+
close: CustomEvent<any>;
|
|
60
|
+
input: Event;
|
|
61
|
+
keydown: KeyboardEvent;
|
|
62
|
+
keyup: KeyboardEvent;
|
|
63
|
+
keypress: KeyboardEvent;
|
|
64
|
+
} & {
|
|
65
|
+
[evt: string]: CustomEvent<any>;
|
|
66
|
+
};
|
|
67
|
+
slots: {
|
|
68
|
+
default: {};
|
|
69
|
+
input: {};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export {};
|