@sveltia/ui 0.89.2 → 0.90.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/dist/components/checkbox/checkbox.svelte +5 -8
- package/dist/components/dialog/dialog.svelte +149 -9
- package/dist/components/emoji/emoji-suggestions.svelte +7 -7
- package/dist/components/grid/grid-col-header.svelte +4 -0
- package/dist/components/grid/grid-head.svelte +1 -1
- package/dist/components/grid/grid-head.svelte.d.ts +1 -1
- package/dist/components/radio/radio.svelte +9 -9
- package/dist/components/resizable-pane/resizable-pane-group.svelte +5 -20
- package/dist/components/resizable-pane/sizing.d.ts +6 -0
- package/dist/components/resizable-pane/sizing.js +31 -0
- package/dist/components/text-editor/code-editor.svelte +22 -39
- package/dist/components/text-editor/constants.js +3 -3
- package/dist/components/text-editor/conversion/editor-components.d.ts +5 -0
- package/dist/components/text-editor/conversion/editor-components.js +228 -0
- package/dist/components/text-editor/{html.d.ts → conversion/html.d.ts} +1 -1
- package/dist/components/text-editor/{html.js → conversion/html.js} +158 -20
- package/dist/components/text-editor/conversion/import.d.ts +12 -0
- package/dist/components/text-editor/conversion/import.js +327 -0
- package/dist/components/text-editor/conversion/paste.d.ts +4 -0
- package/dist/components/text-editor/conversion/paste.js +166 -0
- package/dist/components/text-editor/{transformers → conversion/transformers}/raw-syntax.js +4 -4
- package/dist/components/text-editor/conversion/transformers/table.js +342 -0
- package/dist/components/text-editor/conversion/update.d.ts +6 -0
- package/dist/components/text-editor/conversion/update.js +125 -0
- package/dist/components/text-editor/core.d.ts +50 -26
- package/dist/components/text-editor/core.js +133 -1694
- package/dist/components/text-editor/editing/caret.d.ts +4 -0
- package/dist/components/text-editor/editing/caret.js +248 -0
- package/dist/components/text-editor/editing/commands.d.ts +5 -0
- package/dist/components/text-editor/editing/commands.js +205 -0
- package/dist/components/text-editor/editing/link.d.ts +19 -0
- package/dist/components/text-editor/editing/link.js +222 -0
- package/dist/components/text-editor/{raw-markdown.d.ts → editing/raw-markdown.d.ts} +3 -3
- package/dist/components/text-editor/{raw-markdown.js → editing/raw-markdown.js} +2 -2
- package/dist/components/text-editor/editing/selection.d.ts +5 -0
- package/dist/components/text-editor/editing/selection.js +122 -0
- package/dist/components/text-editor/editing/single-line.d.ts +8 -0
- package/dist/components/text-editor/editing/single-line.js +190 -0
- package/dist/components/text-editor/{table.js → editing/table.js} +1 -1
- package/dist/components/text-editor/lexical-root.svelte +61 -10
- package/dist/components/text-editor/shiki/preload.d.ts +1 -0
- package/dist/components/text-editor/shiki/preload.js +30 -0
- package/dist/components/text-editor/shiki/version.d.ts +1 -1
- package/dist/components/text-editor/shiki/version.js +1 -1
- package/dist/components/text-editor/store.svelte.d.ts +5 -0
- package/dist/components/text-editor/store.svelte.js +55 -1
- package/dist/components/text-editor/text-editor.svelte +29 -41
- package/dist/components/text-editor/toolbar/align-menu-button.svelte +1 -1
- package/dist/components/text-editor/toolbar/code-language-switcher.svelte +2 -1
- package/dist/components/text-editor/toolbar/format-text-button.svelte +6 -2
- package/dist/components/text-editor/toolbar/insert-component.js +1 -1
- package/dist/components/text-editor/toolbar/insert-horizontal-rule-button.svelte +4 -4
- package/dist/components/text-editor/toolbar/insert-link-button.svelte +3 -2
- package/dist/components/text-editor/toolbar/insert-table-button.svelte +7 -3
- package/dist/components/text-editor/toolbar/table-action-menu.svelte +3 -3
- package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte +1 -1
- package/dist/components/text-editor/toolbar/toggle-block-menu-item.svelte +2 -2
- package/dist/components/text-editor/utils.d.ts +1 -0
- package/dist/components/text-editor/utils.js +17 -0
- package/dist/components/text-editor/{emoji-autocomplete.svelte → widgets/emoji-autocomplete.svelte} +3 -3
- package/dist/components/text-editor/{floating-link-editor.svelte → widgets/floating-link-editor.svelte} +36 -79
- package/dist/components/text-editor/{table-cell-menu-button.svelte → widgets/table-cell-menu-button.svelte} +15 -5
- package/dist/components/text-field/date-time-input.svelte +8 -8
- package/dist/components/text-field/text-area.svelte +10 -10
- package/dist/components/text-field/text-input.svelte +7 -7
- package/dist/components/util/modal.svelte +41 -12
- package/dist/components/util/popup.svelte +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/locales/es-ES.yaml +174 -0
- package/dist/services/label.d.ts +8 -0
- package/dist/services/label.js +15 -0
- package/dist/services/popup-position.d.ts +9 -0
- package/dist/services/popup-position.js +52 -55
- package/dist/styles/mixins.scss +69 -0
- package/dist/typedefs.d.ts +28 -1
- package/dist/typedefs.js +16 -1
- package/package.json +13 -11
- package/dist/components/text-editor/transformers/table.js +0 -296
- /package/dist/components/text-editor/{markdown.d.ts → conversion/markdown.d.ts} +0 -0
- /package/dist/components/text-editor/{markdown.js → conversion/markdown.js} +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/block-escape.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/block-escape.js +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/code.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/code.js +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/formatted-code.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/formatted-code.js +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/hr.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/hr.js +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/inline-code.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/inline-code.js +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/link.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/link.js +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/raw-syntax.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/table.d.ts +0 -0
- /package/dist/components/text-editor/{alignment.d.ts → editing/alignment.d.ts} +0 -0
- /package/dist/components/text-editor/{alignment.js → editing/alignment.js} +0 -0
- /package/dist/components/text-editor/{block.d.ts → editing/block.d.ts} +0 -0
- /package/dist/components/text-editor/{block.js → editing/block.js} +0 -0
- /package/dist/components/text-editor/{table.d.ts → editing/table.d.ts} +0 -0
- /package/dist/components/text-editor/{emoji-autocomplete.svelte.d.ts → widgets/emoji-autocomplete.svelte.d.ts} +0 -0
- /package/dist/components/text-editor/{floating-link-editor.svelte.d.ts → widgets/floating-link-editor.svelte.d.ts} +0 -0
- /package/dist/components/text-editor/{table-cell-menu-button.svelte.d.ts → widgets/table-cell-menu-button.svelte.d.ts} +0 -0
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
dialog = $bindable(),
|
|
38
38
|
class: className,
|
|
39
39
|
role = 'dialog',
|
|
40
|
+
modal = true,
|
|
40
41
|
showBackdrop = false,
|
|
41
42
|
lightDismiss = false,
|
|
42
43
|
escapeDismiss = true,
|
|
@@ -62,6 +63,19 @@
|
|
|
62
63
|
dialog?.focus();
|
|
63
64
|
};
|
|
64
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Show the `<dialog>` element, as a modal unless {@link modal} is disabled. A non-modal dialog
|
|
68
|
+
* leaves the rest of the page usable: it isn’t put in the top layer and doesn’t make the page
|
|
69
|
+
* `inert`.
|
|
70
|
+
*/
|
|
71
|
+
const showDialog = () => {
|
|
72
|
+
if (modal) {
|
|
73
|
+
dialog?.showModal();
|
|
74
|
+
} else {
|
|
75
|
+
dialog?.show();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
65
79
|
/**
|
|
66
80
|
* Close the modal.
|
|
67
81
|
* @param {string} returnValue Return value to be used for `<dialog>`.
|
|
@@ -268,7 +282,7 @@
|
|
|
268
282
|
|
|
269
283
|
if (gen !== generation || !dialog || dialog.open) return;
|
|
270
284
|
|
|
271
|
-
|
|
285
|
+
showDialog();
|
|
272
286
|
onOpen?.(new CustomEvent('Open'));
|
|
273
287
|
// Force a style recalculation, so the browser has a state to transition from. This is required
|
|
274
288
|
// because the element may have just been added to the DOM tree.
|
|
@@ -410,6 +424,7 @@
|
|
|
410
424
|
{role}
|
|
411
425
|
class="sui modal {className}"
|
|
412
426
|
class:backdrop={showBackdrop}
|
|
427
|
+
class:non-modal={!modal}
|
|
413
428
|
class:open={setOpenClass}
|
|
414
429
|
class:active={setActiveClass}
|
|
415
430
|
onpointerdown={({ target }) => {
|
|
@@ -425,22 +440,30 @@
|
|
|
425
440
|
return;
|
|
426
441
|
}
|
|
427
442
|
|
|
428
|
-
if (
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
443
|
+
if (lightDismiss && /** @type {HTMLElement | undefined} */ (target)?.matches('dialog')) {
|
|
444
|
+
close('cancel');
|
|
445
|
+
}
|
|
446
|
+
}}
|
|
447
|
+
onkeydown={(event) => {
|
|
448
|
+
// A non-modal dialog gets no `cancel` event from the browser when Escape is pressed, so the
|
|
449
|
+
// key is handled here instead, as long as the focus is within the dialog. Escape that
|
|
450
|
+
// cancels an IME composition is left to the input method, as the browser does for a modal
|
|
451
|
+
if (modal || event.key !== 'Escape' || event.isComposing || event.defaultPrevented) {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
event.preventDefault();
|
|
456
|
+
|
|
457
|
+
if (escapeDismiss) {
|
|
458
|
+
close('cancel');
|
|
435
459
|
}
|
|
436
460
|
}}
|
|
437
461
|
oncancel={(event) => {
|
|
438
462
|
event.preventDefault();
|
|
439
463
|
|
|
440
464
|
// Escape key is pressed
|
|
441
|
-
if (
|
|
442
|
-
|
|
443
|
-
open = false;
|
|
465
|
+
if (escapeDismiss) {
|
|
466
|
+
close('cancel');
|
|
444
467
|
}
|
|
445
468
|
}}
|
|
446
469
|
onclose={() => {
|
|
@@ -454,7 +477,7 @@
|
|
|
454
477
|
// activation in between. Show the dialog again if it shouldn’t be dismissed with Escape,
|
|
455
478
|
// otherwise bring the state in line, so the usual closing steps run.
|
|
456
479
|
if (!escapeDismiss) {
|
|
457
|
-
|
|
480
|
+
showDialog();
|
|
458
481
|
} else {
|
|
459
482
|
open = false;
|
|
460
483
|
}
|
|
@@ -496,6 +519,12 @@ dialog::backdrop {
|
|
|
496
519
|
dialog.backdrop {
|
|
497
520
|
background-color: var(--sui-popup-backdrop-color);
|
|
498
521
|
}
|
|
522
|
+
dialog.non-modal {
|
|
523
|
+
pointer-events: none;
|
|
524
|
+
}
|
|
525
|
+
dialog.non-modal.active > :global(*) {
|
|
526
|
+
pointer-events: auto;
|
|
527
|
+
}
|
|
499
528
|
dialog.open {
|
|
500
529
|
transition-duration: 50ms;
|
|
501
530
|
opacity: 1;
|
|
@@ -259,12 +259,12 @@
|
|
|
259
259
|
overflow-y: auto;
|
|
260
260
|
outline-width: 0 !important;
|
|
261
261
|
width: auto;
|
|
262
|
+
transition-property: opacity, transform;
|
|
262
263
|
color: var(--sui-primary-foreground-color);
|
|
263
264
|
background-color: var(--sui-secondary-background-color-translucent);
|
|
264
265
|
box-shadow: 0 8px 16px var(--sui-popup-shadow-color);
|
|
265
266
|
-webkit-backdrop-filter: blur(16px);
|
|
266
267
|
backdrop-filter: blur(16px);
|
|
267
|
-
transition-property: opacity, transform;
|
|
268
268
|
}
|
|
269
269
|
.content.menu {
|
|
270
270
|
border-width: var(--sui-menu-border-width, 1px);
|
package/dist/index.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ export { default as Placeholder } from "./components/util/placeholder.svelte";
|
|
|
85
85
|
export { default as Popup } from "./components/util/popup.svelte";
|
|
86
86
|
export { default as VisibilityObserver } from "./components/util/visibility-observer.svelte";
|
|
87
87
|
export { IMPORT_UPDATE_TAG } from "./components/text-editor/constants.js";
|
|
88
|
-
export { loadCodeHighlighter } from "./components/text-editor/
|
|
88
|
+
export { loadCodeHighlighter } from "./components/text-editor/shiki/preload.js";
|
|
89
89
|
export { setCodeHighlighterCacheEnabled } from "./components/text-editor/shiki/cache.js";
|
|
90
90
|
export { highlightCodeToHTML } from "./components/text-editor/shiki/facade.js";
|
|
91
91
|
export { setCodeHighlighterLoaders } from "./components/text-editor/shiki/loader.js";
|
package/dist/index.js
CHANGED
|
@@ -85,7 +85,7 @@ export { default as Placeholder } from './components/util/placeholder.svelte';
|
|
|
85
85
|
export { default as Popup } from './components/util/popup.svelte';
|
|
86
86
|
export { default as VisibilityObserver } from './components/util/visibility-observer.svelte';
|
|
87
87
|
export { IMPORT_UPDATE_TAG } from './components/text-editor/constants.js';
|
|
88
|
-
export { loadCodeHighlighter } from './components/text-editor/
|
|
88
|
+
export { loadCodeHighlighter } from './components/text-editor/shiki/preload.js';
|
|
89
89
|
export { setCodeHighlighterCacheEnabled } from './components/text-editor/shiki/cache.js';
|
|
90
90
|
export { highlightCodeToHTML } from './components/text-editor/shiki/facade.js';
|
|
91
91
|
export { setCodeHighlighterLoaders } from './components/text-editor/shiki/loader.js';
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Dialog action button labels
|
|
2
|
+
ok: OK
|
|
3
|
+
cancel: Cancelar
|
|
4
|
+
close: Cerrar
|
|
5
|
+
|
|
6
|
+
# Button to clear content, e.g. search input or calendar date
|
|
7
|
+
clear: Limpiar
|
|
8
|
+
|
|
9
|
+
# Text editor dialog buttons for link/image insertion
|
|
10
|
+
insert: Insertar
|
|
11
|
+
update: Actualizar
|
|
12
|
+
remove: Quitar
|
|
13
|
+
|
|
14
|
+
# Combobox dropdown toggle button aria-labels
|
|
15
|
+
collapse: Contraer
|
|
16
|
+
expand: Expandir
|
|
17
|
+
|
|
18
|
+
# Infobar/toast dismiss button label
|
|
19
|
+
dismiss: Descartar
|
|
20
|
+
|
|
21
|
+
# Alert & infobar status, read out by screen readers before the message (visually hidden)
|
|
22
|
+
alert:
|
|
23
|
+
error: Error
|
|
24
|
+
warning: Advertencia
|
|
25
|
+
info: Información
|
|
26
|
+
success: Éxito
|
|
27
|
+
|
|
28
|
+
# Role descriptions, read out by screen readers in place of the generic “group” role
|
|
29
|
+
role_descriptions:
|
|
30
|
+
disclosure: sección desplegable
|
|
31
|
+
option_group: grupo de opciones
|
|
32
|
+
menu_item_group: grupo de elementos de menú
|
|
33
|
+
checkbox_group: grupo de casillas de verificación
|
|
34
|
+
table_head: encabezado de tabla
|
|
35
|
+
table_body: cuerpo de tabla
|
|
36
|
+
table_foot: pie de tabla
|
|
37
|
+
grid_head: encabezado de cuadrícula
|
|
38
|
+
grid_body: cuerpo de cuadrícula
|
|
39
|
+
grid_foot: pie de cuadrícula
|
|
40
|
+
|
|
41
|
+
# Emoji suggestion listbox aria-label, shared by the text fields and the text editor
|
|
42
|
+
emoji_suggestions: Sugerencias de emojis
|
|
43
|
+
|
|
44
|
+
# Calendar component
|
|
45
|
+
calendar:
|
|
46
|
+
# View switcher group aria-labels and navigation button aria-labels
|
|
47
|
+
year: Año
|
|
48
|
+
previous_decade: Década anterior
|
|
49
|
+
next_decade: Década siguiente
|
|
50
|
+
month: Mes
|
|
51
|
+
previous_month: Mes anterior
|
|
52
|
+
next_month: Mes siguiente
|
|
53
|
+
# “Today” button label in footer
|
|
54
|
+
today: Hoy
|
|
55
|
+
|
|
56
|
+
# Split button component
|
|
57
|
+
split_button:
|
|
58
|
+
# Wrapper aria-label, e.g. “Save Options” when primary button is “Save”
|
|
59
|
+
x_options: Opciones de {$name}
|
|
60
|
+
# Dropdown toggle aria-label
|
|
61
|
+
more_options: Más opciones
|
|
62
|
+
|
|
63
|
+
# Combobox component
|
|
64
|
+
combobox:
|
|
65
|
+
# Placeholder when no option is selected
|
|
66
|
+
select_an_option: Selecciona una opción…
|
|
67
|
+
# Filter input aria-label
|
|
68
|
+
filter_options: Filtrar opciones
|
|
69
|
+
# Empty state message when filter has no matches
|
|
70
|
+
no_matching_options: No se han encontrado opciones que coincidan
|
|
71
|
+
|
|
72
|
+
# Number input component
|
|
73
|
+
number_input:
|
|
74
|
+
# Spin button aria-labels for incrementing/decrementing the number value
|
|
75
|
+
increase: Aumentar
|
|
76
|
+
decrease: Disminuir
|
|
77
|
+
# Description of the allowed range when the number can’t be stepped, e.g. “From 1 to 10”
|
|
78
|
+
range: De {$min} a {$max}
|
|
79
|
+
# Description of the minimum value when the number can’t be stepped
|
|
80
|
+
min: Mínimo {$min}
|
|
81
|
+
# Description of the maximum value when the number can’t be stepped
|
|
82
|
+
max: Máximo {$max}
|
|
83
|
+
|
|
84
|
+
# Password input component
|
|
85
|
+
password_input:
|
|
86
|
+
# Visibility toggle button aria-labels
|
|
87
|
+
show_password: Mostrar la contraseña
|
|
88
|
+
hide_password: Ocultar la contraseña
|
|
89
|
+
|
|
90
|
+
# Secret input component (API keys, tokens, etc.)
|
|
91
|
+
secret_input:
|
|
92
|
+
# Visibility toggle button aria-labels
|
|
93
|
+
show_secret: Mostrar el secreto
|
|
94
|
+
hide_secret: Ocultar el secreto
|
|
95
|
+
|
|
96
|
+
# Select tags component (multi-select)
|
|
97
|
+
select_tags:
|
|
98
|
+
# Listbox aria-label
|
|
99
|
+
selected_options: Opciones seleccionadas
|
|
100
|
+
# Remove button aria-label, e.g. “Remove Option 1”
|
|
101
|
+
remove_x: Quitar {$name}
|
|
102
|
+
|
|
103
|
+
# Text editor component
|
|
104
|
+
text_editor:
|
|
105
|
+
# Toolbar aria-labels
|
|
106
|
+
text_editor: Editor de texto
|
|
107
|
+
code_editor: Editor de código
|
|
108
|
+
# Block style menu button and menu aria-labels
|
|
109
|
+
text_style_options: Opciones de estilo de texto
|
|
110
|
+
show_text_style_options: Mostrar las opciones de estilo de texto
|
|
111
|
+
# Block style menu items
|
|
112
|
+
paragraph: Párrafo
|
|
113
|
+
heading_1: Encabezado 1
|
|
114
|
+
heading_2: Encabezado 2
|
|
115
|
+
heading_3: Encabezado 3
|
|
116
|
+
heading_4: Encabezado 4
|
|
117
|
+
heading_5: Encabezado 5
|
|
118
|
+
heading_6: Encabezado 6
|
|
119
|
+
bulleted_list: Lista con viñetas
|
|
120
|
+
numbered_list: Lista numerada
|
|
121
|
+
blockquote: Cita
|
|
122
|
+
code_block: Bloque de código
|
|
123
|
+
# Inline style button aria-labels
|
|
124
|
+
bold: Negrita
|
|
125
|
+
italic: Cursiva
|
|
126
|
+
strikethrough: Tachado
|
|
127
|
+
code: Código
|
|
128
|
+
link: Enlace
|
|
129
|
+
# Link dialog title
|
|
130
|
+
insert_link: Insertar enlace
|
|
131
|
+
# Floating link editor button aria-labels
|
|
132
|
+
edit_link: Editar enlace
|
|
133
|
+
remove_link: Quitar enlace
|
|
134
|
+
# Link dialog input field labels
|
|
135
|
+
text: Texto
|
|
136
|
+
url: URL
|
|
137
|
+
# Link dialog checkbox label and floating link editor button aria-label
|
|
138
|
+
open_in_new_tab: Abrir en una pestaña nueva
|
|
139
|
+
# Table dialog title
|
|
140
|
+
insert_table: Insertar tabla
|
|
141
|
+
# Table dialog input field labels
|
|
142
|
+
rows: Filas
|
|
143
|
+
columns: Columnas
|
|
144
|
+
# Table menu button and menu aria-labels
|
|
145
|
+
table_options: Opciones de tabla
|
|
146
|
+
show_table_options: Mostrar las opciones de tabla
|
|
147
|
+
# Table menu items
|
|
148
|
+
insert_row_above: Insertar fila arriba
|
|
149
|
+
insert_row_below: Insertar fila abajo
|
|
150
|
+
insert_column_left: Insertar columna a la izquierda
|
|
151
|
+
insert_column_right: Insertar columna a la derecha
|
|
152
|
+
delete_row: Eliminar fila
|
|
153
|
+
delete_column: Eliminar columna
|
|
154
|
+
delete_table: Eliminar tabla
|
|
155
|
+
# Horizontal rule button aria-label
|
|
156
|
+
insert_horizontal_rule: Insertar línea horizontal
|
|
157
|
+
# Alignment menu button and menu aria-labels
|
|
158
|
+
alignment_options: Opciones de alineación
|
|
159
|
+
show_alignment_options: Mostrar las opciones de alineación
|
|
160
|
+
# Alignment menu items
|
|
161
|
+
align_left: Alinear a la izquierda
|
|
162
|
+
align_center: Centrar
|
|
163
|
+
align_right: Alinear a la derecha
|
|
164
|
+
align_justify: Justificar
|
|
165
|
+
# Markdown mode toggle button aria-label
|
|
166
|
+
edit_in_markdown: Editar en Markdown
|
|
167
|
+
# HTML mode toggle button aria-label
|
|
168
|
+
edit_in_html: Editar en HTML
|
|
169
|
+
# Error message when rich text conversion fails
|
|
170
|
+
converter_error: No se ha podido activar el modo de texto enriquecido. Usa el editor de texto sin formato en su lugar.
|
|
171
|
+
# Language selector aria-label
|
|
172
|
+
language: Idioma
|
|
173
|
+
# Plain text mode option in language selector
|
|
174
|
+
plain_text: Texto sin formato
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the labelling attributes of the `<button>` in a `<Checkbox>` or `<Radio>`. An accessible name
|
|
3
|
+
* given as a prop or as a plain `aria-label` attribute takes the place of the visible label, which
|
|
4
|
+
* the button otherwise points at — but only when there is one to point at.
|
|
5
|
+
* @param {object} args Arguments.
|
|
6
|
+
* @param {string} args.id Component ID. The visible label has the `${id}-label` ID.
|
|
7
|
+
* @param {string | undefined} args.ariaLabel Accessible name, if any.
|
|
8
|
+
* @param {boolean} args.hasVisibleLabel Whether the component has a visible label.
|
|
9
|
+
* @returns {{ 'aria-label': string | undefined, 'aria-labelledby': string | undefined }}
|
|
10
|
+
* Attributes.
|
|
11
|
+
*/
|
|
12
|
+
export const getToggleLabelAttrs = ({ id, ariaLabel, hasVisibleLabel }) => ({
|
|
13
|
+
'aria-label': ariaLabel || undefined,
|
|
14
|
+
'aria-labelledby': !ariaLabel && hasVisibleLabel ? `${id}-label` : undefined,
|
|
15
|
+
});
|
|
@@ -16,6 +16,15 @@ export function flip({ position, from, to, size, room, otherRoom }: {
|
|
|
16
16
|
position: PopupPosition;
|
|
17
17
|
cap: number | undefined;
|
|
18
18
|
};
|
|
19
|
+
export function flipEither({ position, sides, size, rooms }: {
|
|
20
|
+
position: PopupPosition;
|
|
21
|
+
sides: [string, string];
|
|
22
|
+
size: number;
|
|
23
|
+
rooms: [number, number];
|
|
24
|
+
}): {
|
|
25
|
+
position: PopupPosition;
|
|
26
|
+
cap: number | undefined;
|
|
27
|
+
};
|
|
19
28
|
export function calculatePopupStyle({ position: preferredPosition, anchorRect, viewport, contentWidth, contentHeight, }: {
|
|
20
29
|
position: PopupPosition;
|
|
21
30
|
anchorRect: {
|
|
@@ -110,6 +110,39 @@ export const flip = ({ position, from, to, size, room, otherRoom }) => {
|
|
|
110
110
|
return { position, cap: room };
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Apply {@link flip} to whichever of the two opposite sides the position is on, if any.
|
|
115
|
+
* @internal
|
|
116
|
+
* @param {object} args Arguments.
|
|
117
|
+
* @param {PopupPosition} args.position Current position.
|
|
118
|
+
* @param {[string, string]} args.sides Parts of the position denoting the two sides, either both
|
|
119
|
+
* prefixes like `bottom-` or both suffixes like `-left`.
|
|
120
|
+
* @param {number} args.size Content size along the axis.
|
|
121
|
+
* @param {[number, number]} args.rooms Room on each side, in the same order as `sides`.
|
|
122
|
+
* @returns {{ position: PopupPosition, cap: number | undefined }} New position, and the size limit
|
|
123
|
+
* if the content doesn’t fit, `undefined` otherwise or if the position is on neither side.
|
|
124
|
+
*/
|
|
125
|
+
export const flipEither = ({ position, sides, size, rooms }) => {
|
|
126
|
+
/**
|
|
127
|
+
* Check if the position is on the given side.
|
|
128
|
+
* @param {string} side Prefix or suffix.
|
|
129
|
+
* @returns {boolean} Result.
|
|
130
|
+
*/
|
|
131
|
+
const isOn = (side) => (side.endsWith('-') ? position.startsWith(side) : position.endsWith(side));
|
|
132
|
+
const [sideA, sideB] = sides;
|
|
133
|
+
const [roomA, roomB] = rooms;
|
|
134
|
+
|
|
135
|
+
if (isOn(sideA)) {
|
|
136
|
+
return flip({ position, from: sideA, to: sideB, size, room: roomA, otherRoom: roomB });
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (isOn(sideB)) {
|
|
140
|
+
return flip({ position, from: sideB, to: sideA, size, room: roomB, otherRoom: roomA });
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return { position, cap: undefined };
|
|
144
|
+
};
|
|
145
|
+
|
|
113
146
|
/**
|
|
114
147
|
* Calculate the popup’s inset and size from the anchor’s rect, the viewport size and the content’s
|
|
115
148
|
* natural size. The position may be altered if the space is limited.
|
|
@@ -145,84 +178,48 @@ export const calculatePopupStyle = ({
|
|
|
145
178
|
let height;
|
|
146
179
|
|
|
147
180
|
/**
|
|
148
|
-
* Apply {@link
|
|
149
|
-
* @param {string}
|
|
150
|
-
* @param {
|
|
151
|
-
* @param {number} room Room on the current side.
|
|
152
|
-
* @param {number} otherRoom Room on the opposite side.
|
|
181
|
+
* Apply {@link flipEither} vertically, keeping any height limit already set if the content fits.
|
|
182
|
+
* @param {[string, string]} sides Parts of the position denoting the two sides.
|
|
183
|
+
* @param {[number, number]} rooms Room on each side.
|
|
153
184
|
*/
|
|
154
|
-
const flipVertically = (
|
|
155
|
-
const result =
|
|
185
|
+
const flipVertically = (sides, rooms) => {
|
|
186
|
+
const result = flipEither({ position, sides, size: contentHeight, rooms });
|
|
156
187
|
|
|
157
188
|
position = result.position;
|
|
158
189
|
height = result.cap ?? height;
|
|
159
190
|
};
|
|
160
191
|
|
|
161
192
|
// Alter the position if the space is limited
|
|
162
|
-
|
|
163
|
-
flipVertically('bottom-', 'top-', bottomMargin, topMargin);
|
|
164
|
-
} else if (position.startsWith('top-')) {
|
|
165
|
-
flipVertically('top-', 'bottom-', topMargin, bottomMargin);
|
|
166
|
-
}
|
|
193
|
+
flipVertically(['bottom-', 'top-'], [bottomMargin, topMargin]);
|
|
167
194
|
|
|
168
195
|
// Only a popup that opens beside its anchor carries a `-top`/`-bottom` suffix, and it grows
|
|
169
196
|
// away from the edge it’s aligned with: down from the anchor’s top, or up from its bottom. It
|
|
170
197
|
// gets the same treatment as the dropdown above — align with the other edge when the content
|
|
171
198
|
// doesn’t fit and that edge has more room, and cap it either way, so a long submenu scrolls
|
|
172
199
|
// instead of running past the viewport
|
|
173
|
-
|
|
174
|
-
flipVertically('-top', '-bottom', downwardMargin, upwardMargin);
|
|
175
|
-
} else if (position.endsWith('-bottom')) {
|
|
176
|
-
flipVertically('-bottom', '-top', upwardMargin, downwardMargin);
|
|
177
|
-
}
|
|
200
|
+
flipVertically(['-top', '-bottom'], [downwardMargin, upwardMargin]);
|
|
178
201
|
|
|
179
202
|
// If the popup overflows the viewport, align it with the anchor’s other edge, but only when that
|
|
180
203
|
// side has more room. Checking each side on its own would flip a popup that fits neither way
|
|
181
204
|
// over and straight back, leaving it on whichever side was checked last
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
room: viewport.width - rect.left - 8,
|
|
189
|
-
otherRoom: rect.right - 8,
|
|
190
|
-
}));
|
|
191
|
-
} else if (position.endsWith('-right')) {
|
|
192
|
-
({ position } = flip({
|
|
193
|
-
position,
|
|
194
|
-
from: '-right',
|
|
195
|
-
to: '-left',
|
|
196
|
-
size: contentWidth,
|
|
197
|
-
room: rect.right - 8,
|
|
198
|
-
otherRoom: viewport.width - rect.left - 8,
|
|
199
|
-
}));
|
|
200
|
-
}
|
|
205
|
+
({ position } = flipEither({
|
|
206
|
+
position,
|
|
207
|
+
sides: ['-left', '-right'],
|
|
208
|
+
size: contentWidth,
|
|
209
|
+
rooms: [viewport.width - rect.left - 8, rect.right - 8],
|
|
210
|
+
}));
|
|
201
211
|
|
|
202
212
|
// The two checks above align a dropdown that opens below or above its anchor, so neither
|
|
203
213
|
// covers a popup that opens beside one — a submenu — running off the edge it opens towards.
|
|
204
214
|
// That gets the same treatment as the vertical flip above: switch to the other side, but only
|
|
205
215
|
// when it has more room, so a submenu with nowhere to go stays where the caller put it. The
|
|
206
216
|
// width isn’t capped here; that’s done with `maxWidth` below.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
room: rightMargin,
|
|
214
|
-
otherRoom: leftMargin,
|
|
215
|
-
}));
|
|
216
|
-
} else if (position.startsWith('left-')) {
|
|
217
|
-
({ position } = flip({
|
|
218
|
-
position,
|
|
219
|
-
from: 'left-',
|
|
220
|
-
to: 'right-',
|
|
221
|
-
size: contentWidth,
|
|
222
|
-
room: leftMargin,
|
|
223
|
-
otherRoom: rightMargin,
|
|
224
|
-
}));
|
|
225
|
-
}
|
|
217
|
+
({ position } = flipEither({
|
|
218
|
+
position,
|
|
219
|
+
sides: ['right-', 'left-'],
|
|
220
|
+
size: contentWidth,
|
|
221
|
+
rooms: [rightMargin, leftMargin],
|
|
222
|
+
}));
|
|
226
223
|
|
|
227
224
|
const top = position.startsWith('bottom-')
|
|
228
225
|
? `${Math.round(rect.bottom)}px`
|
package/dist/styles/mixins.scss
CHANGED
|
@@ -24,6 +24,57 @@
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// The box of a `<TextInput>`, `<TextArea>` or `<DateTimeInput>`. `$line-mode` is `singleline` or
|
|
28
|
+
// `multiline`, picking the padding and line height. `$text-formatting` adds the alignment, indent,
|
|
29
|
+
// case and word spacing options, which don’t apply to a date/time input. The read-only and disabled
|
|
30
|
+
// styles are left to `textbox-disabled`, because a `<TextArea>` clone also matches `:read-only`.
|
|
31
|
+
// Include this after the other declarations, since it ends with nested rules.
|
|
32
|
+
@mixin textbox($line-mode: singleline, $text-formatting: true) {
|
|
33
|
+
border-width: var(--sui-textbox-border-width, 1px);
|
|
34
|
+
border-color: var(--sui-textbox-border-color);
|
|
35
|
+
border-radius: var(--sui-textbox-border-radius);
|
|
36
|
+
padding: var(--sui-textbox-#{$line-mode}-padding);
|
|
37
|
+
color: var(--sui-textbox-foreground-color);
|
|
38
|
+
background-color: var(--sui-textbox-background-color);
|
|
39
|
+
font-family: var(--sui-textbox-font-family);
|
|
40
|
+
font-size: var(--sui-textbox-font-size);
|
|
41
|
+
line-height: var(--sui-textbox-#{$line-mode}-line-height);
|
|
42
|
+
font-weight: var(--sui-textbox-font-weight, var(--sui-font-weight-normal, normal));
|
|
43
|
+
letter-spacing: var(--sui-textbox-letter-spacing, normal);
|
|
44
|
+
transition: all 200ms;
|
|
45
|
+
|
|
46
|
+
@if $text-formatting {
|
|
47
|
+
text-align: var(--sui-textbox-text-align, start);
|
|
48
|
+
text-indent: var(--sui-textbox-text-indent, 0);
|
|
49
|
+
text-transform: var(--sui-textbox-text-transform, none);
|
|
50
|
+
word-spacing: var(--sui-word-spacing-normal, normal);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&:focus {
|
|
54
|
+
color: var(--sui-textbox-foreground-color-focus, var(--sui-textbox-foreground-color));
|
|
55
|
+
background-color: var(
|
|
56
|
+
--sui-textbox-background-color-focus,
|
|
57
|
+
var(--sui-textbox-background-color)
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&[aria-invalid="true"] {
|
|
62
|
+
border-color: var(--sui-error-border-color);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// The read-only and disabled states of a single-line text box, e.g. `<TextInput>`.
|
|
67
|
+
@mixin textbox-disabled {
|
|
68
|
+
&:read-only {
|
|
69
|
+
color: var(--sui-secondary-foreground-color);
|
|
70
|
+
border-color: var(--sui-textbox-border-color) !important;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&:is(:disabled, :read-only) {
|
|
74
|
+
background-color: var(--sui-disabled-background-color);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
27
78
|
// A square button attached to the end of a text field, sharing its border. `$size-property` is the
|
|
28
79
|
// dimension tied to the field height (`width` or `height`), the other one following the aspect
|
|
29
80
|
// ratio.
|
|
@@ -47,6 +98,24 @@
|
|
|
47
98
|
}
|
|
48
99
|
}
|
|
49
100
|
|
|
101
|
+
// The translucent, blurred and shadowed surface of a floating panel, like a `<Popup>`.
|
|
102
|
+
@mixin popup-surface {
|
|
103
|
+
color: var(--sui-primary-foreground-color);
|
|
104
|
+
background-color: var(--sui-secondary-background-color-translucent);
|
|
105
|
+
box-shadow: 0 8px 16px var(--sui-popup-shadow-color);
|
|
106
|
+
-webkit-backdrop-filter: blur(16px);
|
|
107
|
+
backdrop-filter: blur(16px);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// The border of a floating panel, customizable with the CSS variables of `$widget`, e.g. `listbox`
|
|
111
|
+
// or `menu`.
|
|
112
|
+
@mixin popup-border($widget: listbox) {
|
|
113
|
+
border-width: var(--sui-#{$widget}-border-width, 1px);
|
|
114
|
+
border-style: var(--sui-#{$widget}-border-style, solid);
|
|
115
|
+
border-color: var(--sui-#{$widget}-border-color, var(--sui-secondary-border-color));
|
|
116
|
+
border-radius: var(--sui-#{$widget}-border-radius, 4px);
|
|
117
|
+
}
|
|
118
|
+
|
|
50
119
|
// The label wrapper of a checkbox or radio button.
|
|
51
120
|
@mixin toggle-control-wrapper {
|
|
52
121
|
display: inline-flex;
|
package/dist/typedefs.d.ts
CHANGED
|
@@ -141,7 +141,16 @@ export type ModalProps = {
|
|
|
141
141
|
*/
|
|
142
142
|
open?: boolean | undefined;
|
|
143
143
|
/**
|
|
144
|
-
* Whether to show the
|
|
144
|
+
* Whether to show the `<dialog>` element as a modal, which makes the
|
|
145
|
+
* rest of the page `inert` until it’s closed. Default: `true`. If `false`, the page can still be
|
|
146
|
+
* scrolled and used while the dialog is open, and the Escape key only dismisses the dialog while
|
|
147
|
+
* the focus is within it. `lightDismiss` has no effect then, as clicks outside the content go to
|
|
148
|
+
* the page.
|
|
149
|
+
*/
|
|
150
|
+
modal?: boolean | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* Whether to show the backdrop. Default: `false` on a bare
|
|
153
|
+
* modal; components built on it, like `<Dialog>`, may choose another.
|
|
145
154
|
*/
|
|
146
155
|
showBackdrop?: boolean | undefined;
|
|
147
156
|
/**
|
|
@@ -230,6 +239,24 @@ export type DialogProps = {
|
|
|
230
239
|
* Whether to open the dialog.
|
|
231
240
|
*/
|
|
232
241
|
open?: boolean | undefined;
|
|
242
|
+
/**
|
|
243
|
+
* Whether to open the dialog as a modal, which makes the rest of the
|
|
244
|
+
* page `inert` and dims it with a backdrop. Default: `true`. If `false`, the page can still be
|
|
245
|
+
* scrolled and used while the dialog is open, so the user can refer to it before answering.
|
|
246
|
+
*/
|
|
247
|
+
modal?: boolean | undefined;
|
|
248
|
+
/**
|
|
249
|
+
* Whether to dim the page behind the dialog. Default: the value
|
|
250
|
+
* of `modal`. A non-modal dialog can have one as well to make it stand out, while the page behind
|
|
251
|
+
* it can still be scrolled and used.
|
|
252
|
+
*/
|
|
253
|
+
showBackdrop?: boolean | undefined;
|
|
254
|
+
/**
|
|
255
|
+
* Whether the user can move the dialog around by dragging its header,
|
|
256
|
+
* so as to see what’s behind it. The dialog is kept within the viewport, and goes back to the
|
|
257
|
+
* center whenever it’s opened or the viewport is resized. Default: `false`.
|
|
258
|
+
*/
|
|
259
|
+
movable?: boolean | undefined;
|
|
233
260
|
/**
|
|
234
261
|
* Whether to show the Close button on the header.
|
|
235
262
|
*/
|
package/dist/typedefs.js
CHANGED
|
@@ -53,7 +53,13 @@
|
|
|
53
53
|
* @property {'dialog' | 'alertdialog' | 'none'} [role] The `role` attribute on the `<dialog>`
|
|
54
54
|
* element.
|
|
55
55
|
* @property {boolean} [open] Whether to show the modal.
|
|
56
|
-
* @property {boolean} [
|
|
56
|
+
* @property {boolean} [modal] Whether to show the `<dialog>` element as a modal, which makes the
|
|
57
|
+
* rest of the page `inert` until it’s closed. Default: `true`. If `false`, the page can still be
|
|
58
|
+
* scrolled and used while the dialog is open, and the Escape key only dismisses the dialog while
|
|
59
|
+
* the focus is within it. `lightDismiss` has no effect then, as clicks outside the content go to
|
|
60
|
+
* the page.
|
|
61
|
+
* @property {boolean} [showBackdrop] Whether to show the backdrop. Default: `false` on a bare
|
|
62
|
+
* modal; components built on it, like `<Dialog>`, may choose another.
|
|
57
63
|
* @property {boolean} [lightDismiss] Whether to close the modal when the backdrop (outside of the
|
|
58
64
|
* modal) is clicked.
|
|
59
65
|
* @property {boolean} [escapeDismiss] Whether to close the modal when the Escape key is pressed.
|
|
@@ -85,6 +91,15 @@
|
|
|
85
91
|
* @property {'x-small' | 'small' | 'medium' | 'large' | 'x-large'} [size] Width of the dialog.
|
|
86
92
|
* @property {string} [class] The `class` attribute on the `<dialog>` element.
|
|
87
93
|
* @property {boolean} [open] Whether to open the dialog.
|
|
94
|
+
* @property {boolean} [modal] Whether to open the dialog as a modal, which makes the rest of the
|
|
95
|
+
* page `inert` and dims it with a backdrop. Default: `true`. If `false`, the page can still be
|
|
96
|
+
* scrolled and used while the dialog is open, so the user can refer to it before answering.
|
|
97
|
+
* @property {boolean} [showBackdrop] Whether to dim the page behind the dialog. Default: the value
|
|
98
|
+
* of `modal`. A non-modal dialog can have one as well to make it stand out, while the page behind
|
|
99
|
+
* it can still be scrolled and used.
|
|
100
|
+
* @property {boolean} [movable] Whether the user can move the dialog around by dragging its header,
|
|
101
|
+
* so as to see what’s behind it. The dialog is kept within the viewport, and goes back to the
|
|
102
|
+
* center whenever it’s opened or the viewport is resized. Default: `false`.
|
|
88
103
|
* @property {boolean} [showClose] Whether to show the Close button on the header.
|
|
89
104
|
* @property {boolean} [showOk] Whether to show the OK button on the footer.
|
|
90
105
|
* @property {boolean} [showCancel] Whether to show the Cancel button on the footer.
|