typo3-typescript-sources 13.4.26 → 14.0.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/.github/workflows/sync-and-publish.yml +114 -66
- package/.last-synced-tag +1 -1
- package/README-TYPO3.md +1 -1
- package/README.md +8 -1
- package/backend/action-button/deferred-action.ts +2 -0
- package/backend/action-button/immediate-action.ts +2 -0
- package/backend/ajax-data-handler.ts +1 -116
- package/backend/clipboard-panel.ts +5 -5
- package/backend/code-editor/element/code-mirror-element.ts +1 -1
- package/backend/code-editor/stream-parser/typoscript.ts +1 -1
- package/backend/color-picker.ts +5 -4
- package/backend/color-scheme-switch.ts +1 -1
- package/backend/column-selector-button.ts +1 -1
- package/backend/context-menu-actions.ts +1 -0
- package/backend/context-menu.ts +3 -3
- package/backend/copy-to-clipboard.ts +1 -1
- package/backend/date-time-picker.ts +10 -16
- package/backend/drag-tooltip.ts +1 -1
- package/backend/drag-uploader.ts +34 -36
- package/backend/element/alert-element.ts +2 -2
- package/backend/element/breadcrumb.ts +306 -0
- package/backend/element/combobox-element.ts +712 -0
- package/backend/element/dispatch-modal-button.ts +1 -1
- package/backend/element/draggable-resizable-element.ts +1 -1
- package/backend/element/editable-page-title.ts +6 -5
- package/backend/element/icon-element.ts +2 -2
- package/backend/element/pagination.ts +4 -4
- package/backend/element/progress-bar-element.ts +2 -2
- package/backend/element/progress-tracker-element.ts +2 -2
- package/backend/element/pseudo-button.ts +1 -1
- package/backend/element/qrcode-element.ts +129 -0
- package/backend/element/spinner-element.ts +1 -1
- package/backend/element/thumbnail-element.ts +3 -0
- package/backend/form-engine/container/files-control-container.ts +4 -4
- package/backend/form-engine/container/flex-form-section-container.ts +0 -1
- package/backend/form-engine/container/inline-control-container.ts +4 -4
- package/backend/form-engine/container/site-language-container.ts +2 -2
- package/backend/form-engine/element/abstract-sortable-select-items.ts +2 -2
- package/backend/form-engine/element/color-element.ts +2 -1
- package/backend/form-engine/element/datetime-element.ts +2 -1
- package/backend/form-engine/element/extra/char-counter.ts +1 -1
- package/backend/form-engine/element/online-media-form-element.ts +1 -1
- package/backend/form-engine/element/select-country-element.ts +82 -0
- package/backend/form-engine/element/select-tree-toolbar.ts +20 -18
- package/backend/form-engine/element/select-tree.ts +6 -1
- package/backend/form-engine/element/suggest/result-container.ts +1 -1
- package/backend/form-engine/element/suggest/result-item.ts +1 -1
- package/backend/form-engine/element/table-wizard-element.ts +1 -1
- package/backend/form-engine/field-control/password-generator.ts +2 -1
- package/backend/form-engine/field-wizard/value-picker.ts +7 -34
- package/backend/form-engine/inline-relation/inline-response-interface.ts +0 -1
- package/backend/form-engine-link-browser-adapter.ts +1 -5
- package/backend/form-engine-review.ts +2 -2
- package/backend/form-engine-suggest.ts +1 -1
- package/backend/form-engine-validation.ts +19 -80
- package/backend/form-engine.ts +40 -42
- package/backend/grid-editor.ts +4 -4
- package/backend/hotkeys/hotkey-storage.ts +18 -3
- package/backend/hotkeys.ts +46 -27
- package/backend/image-manipulation.ts +4 -4
- package/backend/layout-module/drag-drop.ts +1 -1
- package/backend/link-browser.ts +1 -11
- package/backend/live-search/element/backend-search.ts +1 -1
- package/backend/live-search/element/hint.ts +1 -1
- package/backend/live-search/element/provider/default-result-item.ts +1 -1
- package/backend/live-search/element/provider/page-provider-result-item.ts +1 -1
- package/backend/live-search/element/result/item/action/action-container.ts +1 -1
- package/backend/live-search/element/result/item/action/action.ts +2 -2
- package/backend/live-search/element/result/item/item-container.ts +2 -2
- package/backend/live-search/element/result/item/item.ts +1 -1
- package/backend/live-search/element/result/result-container.ts +1 -6
- package/backend/live-search/element/result/result-detail-container.ts +1 -1
- package/backend/live-search/element/result/result-pagination.ts +2 -3
- package/backend/live-search/element/search-option-item.ts +1 -1
- package/backend/live-search/live-search-shortcut.ts +14 -1
- package/backend/localization/finisher/noop-finisher.ts +48 -0
- package/backend/localization/finisher/redirect-finisher.ts +55 -0
- package/backend/localization/finisher/reload-finisher.ts +45 -0
- package/backend/localization/localization-button.ts +52 -0
- package/backend/localization/localization-finisher.ts +50 -0
- package/backend/localization/localization-wizard.ts +451 -0
- package/backend/localization/steps/confirm-step.ts +61 -0
- package/backend/localization/steps/content-record-selection-step.ts +389 -0
- package/backend/localization/steps/finisher-step.ts +179 -0
- package/backend/localization/steps/handler-selection-step.ts +200 -0
- package/backend/localization/steps/mode-step.ts +199 -0
- package/backend/localization/steps/source-language-step.ts +187 -0
- package/backend/localization/steps/target-language-step.ts +195 -0
- package/backend/localization.ts +2 -377
- package/backend/login/pasted-password-checker.ts +22 -0
- package/backend/login-refresh.ts +1 -1
- package/backend/login.ts +32 -5
- package/backend/modal.ts +108 -81
- package/backend/module/iframe.ts +1 -1
- package/backend/module/router.ts +12 -18
- package/backend/module-menu.ts +7 -2
- package/backend/multi-record-selection-edit-action.ts +1 -0
- package/backend/multi-step-wizard.ts +50 -50
- package/backend/new-content-element-wizard-button.ts +1 -1
- package/backend/new-record-wizard.ts +102 -9
- package/backend/notification.ts +3 -3
- package/backend/pagetsconfig/pagetsconfig-includes.ts +1 -1
- package/backend/record-download-button.ts +2 -3
- package/backend/record-usage/record-usage-store.ts +65 -0
- package/backend/recordlist.ts +70 -0
- package/backend/resource/resource.ts +4 -0
- package/backend/security/element/csp-reports.ts +7 -85
- package/backend/security/element/sudo-mode.ts +1 -1
- package/backend/settings/editor/editable-setting.ts +2 -1
- package/backend/settings/editor.ts +18 -6
- package/backend/settings/type/base.ts +1 -1
- package/backend/settings/type/bool.ts +1 -1
- package/backend/settings/type/color.ts +1 -1
- package/backend/settings/type/int.ts +2 -2
- package/backend/settings/type/number.ts +2 -2
- package/backend/settings/type/page.ts +1 -1
- package/backend/settings/type/string.ts +2 -2
- package/backend/settings/type/stringlist.ts +1 -1
- package/backend/settings/type/url.ts +43 -0
- package/backend/storage/abstract-client-storage.ts +1 -1
- package/backend/storage/module-state-storage.ts +5 -0
- package/backend/switch-user.ts +1 -1
- package/backend/tests/form-engine-validation-test.ts +12 -12
- package/backend/tests/login/pasted-password-checker-test.ts +43 -0
- package/backend/toolbar/live-search.ts +2 -7
- package/backend/tree/file-storage-browser.ts +1 -1
- package/backend/tree/file-storage-tree-container.ts +9 -5
- package/backend/tree/file-storage-tree.ts +13 -1
- package/backend/tree/page-browser.ts +3 -3
- package/backend/tree/page-tree-element.ts +11 -8
- package/backend/tree/tree-module-state.ts +1 -1
- package/backend/tree/tree-node-toggle.ts +1 -1
- package/backend/tree/tree-toolbar.ts +4 -3
- package/backend/tree/tree.ts +5 -5
- package/backend/user-settings-manager.ts +25 -1
- package/backend/utility/dom-helper.ts +11 -1
- package/backend/utility/format-utility.ts +30 -0
- package/backend/utility.ts +0 -21
- package/backend/viewport/content-container.ts +4 -1
- package/backend/viewport/resizable-navigation.ts +3 -3
- package/backend/wizard/move-content-element.ts +2 -2
- package/core/ajax/ajax-request.ts +5 -2
- package/core/authentication/mfa-provider/totp.ts +1 -1
- package/core/directive/markdown.ts +2 -2
- package/core/event/throttle-event.ts +1 -1
- package/core/factory/url-factory.ts +73 -0
- package/core/lit-helper.ts +2 -2
- package/core/tests/factory/url-factory-test.ts +105 -0
- package/dashboard/dashboard.ts +100 -5
- package/extensionmanager/distribution-image.ts +1 -1
- package/filelist/context-menu-actions.ts +21 -16
- package/filelist/file-delete.ts +1 -1
- package/filelist/file-list-actions.ts +9 -1
- package/filelist/file-list-rename-handler.ts +7 -4
- package/filelist/file-list-replace-handler.ts +141 -0
- package/filelist/file-list.ts +1 -0
- package/filelist/{create-folder.ts → resource-creation.ts} +2 -2
- package/form/backend/form-editor/component/property-grid-editor.ts +4 -4
- package/form/backend/form-editor/core.ts +1 -2
- package/form/backend/form-manager/view-model.ts +28 -67
- package/install/installer.ts +4 -4
- package/install/module/maintenance/reference-index.ts +154 -0
- package/install/renderable/flash-message.ts +1 -1
- package/install/renderable/info-box.ts +1 -1
- package/install/renderable/language-packs.ts +3 -3
- package/install/renderable/offset-group.ts +1 -1
- package/install/renderable/wrap-group.ts +1 -1
- package/install/router.ts +2 -1
- package/package.json +2 -2
- package/rte-ckeditor/ckeditor5.ts +3 -3
- package/rte-ckeditor/plugin/typo3-link.ts +2 -33
- package/rte-ckeditor/rte-link-browser.ts +1 -0
- package/scheduler/form-engine/element/timing-options-element.ts +74 -0
- package/scheduler/new-scheduler-task-wizard-button.ts +51 -0
- package/scheduler/scheduler-add-group.ts +28 -0
- package/scheduler/scheduler.ts +3 -359
- package/scheduler/setup-check-button.ts +50 -0
- package/styleguide/element/theme-switcher-element.ts +2 -1
- package/sys-note/element/delete-button.ts +1 -1
- package/tstemplate/template-analyzer.ts +1 -1
- package/viewpage/main.ts +5 -3
- package/workspaces/backend.ts +34 -31
- package/workspaces/preview.ts +6 -8
- package/workspaces/renderable/comment-view.ts +3 -3
- package/workspaces/renderable/diff-view.ts +3 -3
- package/workspaces/renderable/history-view.ts +3 -3
- package/workspaces/renderable/record-information.ts +2 -2
- package/workspaces/renderable/record-table.ts +26 -6
- package/workspaces/renderable/send-to-stage-form.ts +1 -9
- package/workspaces/toolbar/workspaces-menu.ts +5 -3
- package/workspaces/workspaces.ts +1 -36
- package/backend/document-save-actions.ts +0 -159
- package/backend/hotkeys/events.ts +0 -47
- package/backend/hotkeys/hotkey-struct.ts +0 -58
- package/backend/hotkeys/negotiator.ts +0 -53
- package/backend/wizard.ts +0 -331
- package/filelist/file-replace.ts +0 -37
- package/lowlevel/reference-index.ts +0 -44
- package/scheduler/scheduler-editable-group-name.ts +0 -307
|
@@ -0,0 +1,712 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the TYPO3 CMS project.
|
|
3
|
+
*
|
|
4
|
+
* It is free software; you can redistribute it and/or modify it
|
|
5
|
+
* under the terms of the GNU General Public License, either version 2
|
|
6
|
+
* of the License, or any later version.
|
|
7
|
+
*
|
|
8
|
+
* For the full copyright and license information, please read the
|
|
9
|
+
* LICENSE.txt file that was distributed with this source code.
|
|
10
|
+
*
|
|
11
|
+
* The TYPO3 project - inspiring people to share!
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { html, LitElement, css, type TemplateResult } from 'lit';
|
|
15
|
+
import { customElement, property, state } from 'lit/decorators';
|
|
16
|
+
import type { PropertyValues } from '@lit/reactive-element';
|
|
17
|
+
import '@typo3/backend/element/icon-element';
|
|
18
|
+
|
|
19
|
+
export interface ComboboxOption {
|
|
20
|
+
value: string;
|
|
21
|
+
label: string;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
icon?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const Action = {
|
|
27
|
+
INPUT: 'input',
|
|
28
|
+
NAVIGATION: 'navigation',
|
|
29
|
+
} as const;
|
|
30
|
+
type ACTION = typeof Action[keyof typeof Action];
|
|
31
|
+
|
|
32
|
+
const SelectionIntent = {
|
|
33
|
+
NONE: 'none',
|
|
34
|
+
CURRENT: 'current',
|
|
35
|
+
} as const;
|
|
36
|
+
type SELECTIONINTENT = typeof SelectionIntent[keyof typeof SelectionIntent];
|
|
37
|
+
|
|
38
|
+
let idCounter = 0;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Individual choice element for combobox
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* <typo3-backend-combobox-choice value="1" icon="actions-add">Option 1</typo3-backend-combobox-choice>
|
|
45
|
+
*/
|
|
46
|
+
@customElement('typo3-backend-combobox-choice')
|
|
47
|
+
export class ComboboxChoiceElement extends LitElement {
|
|
48
|
+
static override styles = css`
|
|
49
|
+
*,
|
|
50
|
+
*::before,
|
|
51
|
+
*::after {
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
:host {
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
width: 100%;
|
|
59
|
+
user-select: none;
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
@property({ type: String }) value: string = '';
|
|
64
|
+
@property({ type: String }) icon: string = '';
|
|
65
|
+
@property({ type: Boolean }) disabled: boolean = false;
|
|
66
|
+
@state() private isSelected: boolean = false;
|
|
67
|
+
|
|
68
|
+
public override connectedCallback(): void {
|
|
69
|
+
super.connectedCallback();
|
|
70
|
+
this.setAttribute('role', 'option');
|
|
71
|
+
this.setAttribute('aria-selected', 'false');
|
|
72
|
+
|
|
73
|
+
// If no value is provided, use the text content
|
|
74
|
+
if (!this.value && this.textContent) {
|
|
75
|
+
this.value = this.textContent.trim();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
this.updateAriaLabel();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public setSelected(selected: boolean): void {
|
|
82
|
+
this.isSelected = selected;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
protected override updated(changedProperties: Map<string | number | symbol, unknown>): void {
|
|
86
|
+
if (changedProperties.has('value')) {
|
|
87
|
+
this.updateAriaLabel();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
protected override render(): TemplateResult {
|
|
92
|
+
const label = this.getLabel();
|
|
93
|
+
const showValue = this.value && this.value !== label;
|
|
94
|
+
|
|
95
|
+
return html`
|
|
96
|
+
<span class="indicator" part="indicator">
|
|
97
|
+
<typo3-backend-icon identifier="${this.isSelected ? 'actions-check' : 'miscellaneous-placeholder'}" size="small" aria-hidden="true"></typo3-backend-icon>
|
|
98
|
+
</span>
|
|
99
|
+
${this.icon ? html`
|
|
100
|
+
<typo3-backend-icon identifier="${this.icon}" size="small" part="icon"></typo3-backend-icon>` : ''}
|
|
101
|
+
<span class="content" part="content">
|
|
102
|
+
${label}
|
|
103
|
+
${showValue ? html`<span class="value" part="value">(${this.value})</span>` : ''}
|
|
104
|
+
</span>
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private getLabel(): string {
|
|
109
|
+
return this.textContent?.trim() || this.value;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private updateAriaLabel(): void {
|
|
113
|
+
const label = this.getLabel();
|
|
114
|
+
const valueText = this.value && this.value !== label ? ` (${this.value})` : '';
|
|
115
|
+
this.setAttribute('aria-label', `${label}${valueText}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @example Enhancing an existing input:
|
|
121
|
+
* <typo3-backend-combobox>
|
|
122
|
+
* <input type="text" class="form-control" name="example" placeholder="Select or type...">
|
|
123
|
+
* <typo3-backend-combobox-choice value="1">Option 1</typo3-backend-combobox-choice>
|
|
124
|
+
* <typo3-backend-combobox-choice value="2">Option 2</typo3-backend-combobox-choice>
|
|
125
|
+
* </typo3-backend-combobox>
|
|
126
|
+
*/
|
|
127
|
+
@customElement('typo3-backend-combobox')
|
|
128
|
+
export class ComboboxElement extends LitElement {
|
|
129
|
+
|
|
130
|
+
static override styles = css`
|
|
131
|
+
*,
|
|
132
|
+
*::before,
|
|
133
|
+
*::after {
|
|
134
|
+
box-sizing: border-box;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
:host {
|
|
138
|
+
position: relative;
|
|
139
|
+
display: block;
|
|
140
|
+
width: 100%;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.controls {
|
|
144
|
+
position: absolute;
|
|
145
|
+
top: 50%;
|
|
146
|
+
inset-inline-end: 0;
|
|
147
|
+
transform: translateY(-50%);
|
|
148
|
+
display: flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
gap: 0.25rem;
|
|
151
|
+
padding-inline-end: var(--typo3-form-combobox-padding-x, 0.75rem);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.clear-button {
|
|
155
|
+
display: flex;
|
|
156
|
+
align-items: center;
|
|
157
|
+
justify-content: center;
|
|
158
|
+
cursor: pointer;
|
|
159
|
+
color: inherit;
|
|
160
|
+
opacity: 0.3;
|
|
161
|
+
transition: opacity 0.2s ease;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.clear-button:hover {
|
|
165
|
+
opacity: .5;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.separator {
|
|
169
|
+
width: 1px;
|
|
170
|
+
height: 1.25rem;
|
|
171
|
+
background-color: var(--typo3-input-border-color, currentColor);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.indicator {
|
|
175
|
+
display: flex;
|
|
176
|
+
align-items: center;
|
|
177
|
+
justify-content: center;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.listbox {
|
|
181
|
+
position: absolute;
|
|
182
|
+
top: 100%;
|
|
183
|
+
left: 0;
|
|
184
|
+
width: 100%;
|
|
185
|
+
z-index: 1000;
|
|
186
|
+
}
|
|
187
|
+
`;
|
|
188
|
+
|
|
189
|
+
@state()
|
|
190
|
+
public isOpen: boolean = false;
|
|
191
|
+
|
|
192
|
+
@property({ type: Boolean, reflect: true, attribute: 'data-has-value' })
|
|
193
|
+
private inputHasValue: boolean = false;
|
|
194
|
+
|
|
195
|
+
@state()
|
|
196
|
+
private highlightedIndex: number = -1;
|
|
197
|
+
|
|
198
|
+
@state()
|
|
199
|
+
private inputIsDisabledOrReadonly: boolean = false;
|
|
200
|
+
|
|
201
|
+
private choiceIdCounter: number = 0;
|
|
202
|
+
private delayedCloseTimeout: number = null;
|
|
203
|
+
private internalId: string = null;
|
|
204
|
+
private lastAction: ACTION | null = null;
|
|
205
|
+
private lastHighlightedIndex: number | null = null;
|
|
206
|
+
private userSelectionIntent: SELECTIONINTENT | null = null;
|
|
207
|
+
|
|
208
|
+
constructor() {
|
|
209
|
+
super();
|
|
210
|
+
this.addEventListener('click', this.handleChoiceClick);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
public override focus(options?: FocusOptions): void {
|
|
214
|
+
this.getInput()?.focus(options);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
public override blur(): void {
|
|
218
|
+
this.getInput()?.blur();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
protected override willUpdate(changedProperties: PropertyValues<this>): void {
|
|
222
|
+
if (
|
|
223
|
+
changedProperties.has('isOpen') &&
|
|
224
|
+
this.isOpen &&
|
|
225
|
+
this.userSelectionIntent !== SelectionIntent.NONE
|
|
226
|
+
) {
|
|
227
|
+
const currentChoice = this.findCurrentSelectionChoice();
|
|
228
|
+
if (currentChoice) {
|
|
229
|
+
const choices = this.getChoiceElements();
|
|
230
|
+
const index = choices.indexOf(currentChoice);
|
|
231
|
+
this.setHighlightedIndex(index);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
protected override render(): TemplateResult {
|
|
237
|
+
const input = this.getInput();
|
|
238
|
+
|
|
239
|
+
if (input) {
|
|
240
|
+
input.setAttribute('aria-expanded', this.isOpen.toString());
|
|
241
|
+
input.setAttribute('aria-activedescendant', this.getActiveDescendantId());
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return html`
|
|
245
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
246
|
+
${!this.inputIsDisabledOrReadonly ? html`
|
|
247
|
+
<div class="controls" part="controls">
|
|
248
|
+
${this.inputHasValue ? html`
|
|
249
|
+
<span
|
|
250
|
+
class="clear-button"
|
|
251
|
+
part="clear-button"
|
|
252
|
+
@click=${this.handleClearClick}
|
|
253
|
+
aria-label="Clear value"
|
|
254
|
+
tabindex="-1"
|
|
255
|
+
>
|
|
256
|
+
<typo3-backend-icon identifier="actions-close" size="small" aria-hidden="true"></typo3-backend-icon>
|
|
257
|
+
</span>
|
|
258
|
+
<span class="separator" part="separator"></span>
|
|
259
|
+
` : ''}
|
|
260
|
+
<span class="indicator" part="indicator" tabindex="-1" @click="${this.handleIndicatorClick}" style="cursor: pointer">
|
|
261
|
+
<typo3-backend-icon identifier="actions-chevron-expand" size="small" aria-hidden="true"></typo3-backend-icon>
|
|
262
|
+
</span>
|
|
263
|
+
</div>
|
|
264
|
+
<div class="listbox" part="listbox" role="listbox" id="${this.getId()}-listbox" ?hidden=${!this.isOpen}>
|
|
265
|
+
<slot name="choices"></slot>
|
|
266
|
+
</div>
|
|
267
|
+
` : ''}
|
|
268
|
+
`;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
protected override firstUpdated(): void {
|
|
272
|
+
// Set up input element attributes for accessibility
|
|
273
|
+
this.setup();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
protected override updated(changedProperties: PropertyValues<this>): void {
|
|
277
|
+
// Position dropdown when it opens
|
|
278
|
+
if (changedProperties.has('isOpen')) {
|
|
279
|
+
if (this.isOpen) {
|
|
280
|
+
this.positionDropdown();
|
|
281
|
+
this.scrollToHighlightedOption();
|
|
282
|
+
} else {
|
|
283
|
+
this.setHighlightedIndex(-1);
|
|
284
|
+
this.lastAction = null;
|
|
285
|
+
this.userSelectionIntent = null;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private getId(): string {
|
|
291
|
+
this.internalId ??= this.id !== '' ? this.id : 'combobox-' + idCounter++;
|
|
292
|
+
return this.internalId;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private positionDropdown(): void {
|
|
296
|
+
const listbox = this.shadowRoot?.querySelector('.listbox') as HTMLElement;
|
|
297
|
+
if (!listbox) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const hostRect = this.getBoundingClientRect();
|
|
302
|
+
const viewportHeight = window.innerHeight;
|
|
303
|
+
const scrollY = window.scrollY;
|
|
304
|
+
|
|
305
|
+
const computedStyle = window.getComputedStyle(listbox);
|
|
306
|
+
const maxHeight = computedStyle.maxHeight !== 'none'
|
|
307
|
+
? parseFloat(computedStyle.maxHeight)
|
|
308
|
+
: Infinity;
|
|
309
|
+
|
|
310
|
+
const naturalHeight = Math.min(listbox.scrollHeight, maxHeight);
|
|
311
|
+
|
|
312
|
+
const spaceBelow = viewportHeight - (hostRect.bottom - scrollY);
|
|
313
|
+
const spaceAbove = hostRect.top - scrollY;
|
|
314
|
+
|
|
315
|
+
const preferAbove = spaceBelow < naturalHeight && spaceAbove > spaceBelow;
|
|
316
|
+
const availableSpace = preferAbove ? spaceAbove : spaceBelow;
|
|
317
|
+
|
|
318
|
+
requestAnimationFrame(() => {
|
|
319
|
+
if (preferAbove) {
|
|
320
|
+
listbox.style.top = 'auto';
|
|
321
|
+
listbox.style.bottom = '100%';
|
|
322
|
+
if (naturalHeight > availableSpace) {
|
|
323
|
+
listbox.style.maxHeight = `${Math.floor(availableSpace)}px`;
|
|
324
|
+
} else {
|
|
325
|
+
listbox.style.removeProperty('max-height');
|
|
326
|
+
}
|
|
327
|
+
} else {
|
|
328
|
+
listbox.style.top = '100%';
|
|
329
|
+
listbox.style.bottom = 'auto';
|
|
330
|
+
if (naturalHeight > availableSpace) {
|
|
331
|
+
listbox.style.maxHeight = `${Math.floor(availableSpace)}px`;
|
|
332
|
+
} else {
|
|
333
|
+
listbox.style.removeProperty('max-height');
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
private scrollToHighlightedOption(): void {
|
|
340
|
+
if (this.highlightedIndex < 0) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const choices = this.getChoiceElements();
|
|
345
|
+
const highlightedChoice = choices[this.highlightedIndex];
|
|
346
|
+
if (highlightedChoice) {
|
|
347
|
+
highlightedChoice.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
private selectChoiceOption(index: number): void {
|
|
352
|
+
const choices = this.getChoiceElements();
|
|
353
|
+
const choiceElement = choices[index];
|
|
354
|
+
|
|
355
|
+
if (!choiceElement || choiceElement.disabled) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const newValue = choiceElement.value;
|
|
360
|
+
const input = this.getInput();
|
|
361
|
+
if (input) {
|
|
362
|
+
input.value = newValue;
|
|
363
|
+
this.dispatchInputEvents(input);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
this.updateInputHasValue();
|
|
367
|
+
this.updateSelectedState();
|
|
368
|
+
this.setHighlightedIndex(index);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
private setHighlightedIndex(index: number): void {
|
|
372
|
+
const choices = this.getChoiceElements();
|
|
373
|
+
choices.forEach((choice, i) => {
|
|
374
|
+
choice.setAttribute('aria-selected', i === index ? 'true' : 'false');
|
|
375
|
+
});
|
|
376
|
+
this.highlightedIndex = index;
|
|
377
|
+
this.scrollToHighlightedOption();
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
private getNextHighlightIndex(direction: number, totalOptions: number): number {
|
|
381
|
+
if (this.highlightedIndex < 0) {
|
|
382
|
+
const { lastHighlightedIndex } = this;
|
|
383
|
+
if (lastHighlightedIndex !== null && lastHighlightedIndex !== -1) {
|
|
384
|
+
this.lastHighlightedIndex = null;
|
|
385
|
+
return lastHighlightedIndex;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const currentChoice = this.findCurrentSelectionChoice();
|
|
389
|
+
if (currentChoice) {
|
|
390
|
+
const choices = this.getChoiceElements();
|
|
391
|
+
return choices.indexOf(currentChoice);
|
|
392
|
+
}
|
|
393
|
+
return direction > 0 ? 0 : totalOptions - 1;
|
|
394
|
+
}
|
|
395
|
+
if (direction > 0) {
|
|
396
|
+
return Math.min(this.highlightedIndex + 1, totalOptions - 1);
|
|
397
|
+
}
|
|
398
|
+
return Math.max(this.highlightedIndex - 1, 0);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
private setup(): void {
|
|
402
|
+
this.setupInputAttributes();
|
|
403
|
+
this.setupChoiceElements();
|
|
404
|
+
|
|
405
|
+
this.updateInputHasValue();
|
|
406
|
+
this.updateSelectedState();
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
private handleSlotChange(): void {
|
|
410
|
+
// Re-setup when slot content changes
|
|
411
|
+
this.setup();
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
private setupChoiceElements(): void {
|
|
415
|
+
const choices = this.querySelectorAll<ComboboxChoiceElement>('typo3-backend-combobox-choice:not([slot="choices"])');
|
|
416
|
+
choices.forEach((choice) => {
|
|
417
|
+
// Move choice elements to the choices slot
|
|
418
|
+
choice.slot = 'choices';
|
|
419
|
+
choice.tabIndex = -1;
|
|
420
|
+
|
|
421
|
+
// Ensure unique IDs for accessibility
|
|
422
|
+
if (!choice.id) {
|
|
423
|
+
choice.id = `${this.getId()}-option-${++this.choiceIdCounter}`;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
choice.addEventListener('mouseenter', this.handleChoiceMouseEnter);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
private readonly handleChoiceMouseEnter = (event: Event): void => {
|
|
431
|
+
const choice = event.currentTarget as ComboboxChoiceElement;
|
|
432
|
+
const choices = this.getChoiceElements();
|
|
433
|
+
const index = choices.indexOf(choice);
|
|
434
|
+
if (index >= 0) {
|
|
435
|
+
this.setHighlightedIndex(index);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
private setupInputAttributes(): void {
|
|
440
|
+
const input = this.getInput();
|
|
441
|
+
if (input) {
|
|
442
|
+
// Remove existing listeners to avoid duplicates
|
|
443
|
+
input.removeEventListener('formengine:input:initialized', this.handleInputInit);
|
|
444
|
+
input.removeEventListener('input', this.handleInputInput);
|
|
445
|
+
input.removeEventListener('pointerdown', this.handleInputPointerdown);
|
|
446
|
+
input.removeEventListener('blur', this.handleInputBlur);
|
|
447
|
+
input.removeEventListener('keydown', this.handleInputKeydown);
|
|
448
|
+
|
|
449
|
+
input.setAttribute('role', 'combobox');
|
|
450
|
+
input.setAttribute('aria-expanded', 'false');
|
|
451
|
+
input.setAttribute('aria-haspopup', 'listbox');
|
|
452
|
+
input.setAttribute('aria-controls', `${this.getId()}-listbox`);
|
|
453
|
+
input.setAttribute('autocomplete', 'off');
|
|
454
|
+
|
|
455
|
+
// Add event listeners to existing input
|
|
456
|
+
input.addEventListener('formengine:input:initialized', this.handleInputInit);
|
|
457
|
+
input.addEventListener('input', this.handleInputInput);
|
|
458
|
+
input.addEventListener('pointerdown', this.handleInputPointerdown);
|
|
459
|
+
input.addEventListener('blur', this.handleInputBlur);
|
|
460
|
+
input.addEventListener('keydown', this.handleInputKeydown);
|
|
461
|
+
|
|
462
|
+
// Initialize disabled state
|
|
463
|
+
this.updateInputDisabledState();
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
private getInput(): HTMLInputElement | null {
|
|
469
|
+
const slot = this.shadowRoot?.querySelector('slot:not([name])') as HTMLSlotElement;
|
|
470
|
+
if (!slot) {
|
|
471
|
+
return null;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const assignedElements = slot.assignedElements();
|
|
475
|
+
return assignedElements.find(el => el.tagName === 'INPUT') as HTMLInputElement | null;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
private setOpen(): void {
|
|
479
|
+
const input = this.getInput();
|
|
480
|
+
this.updateInputDisabledState();
|
|
481
|
+
if (input?.disabled || input?.readOnly) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
this.isOpen = true;
|
|
486
|
+
if (this.delayedCloseTimeout !== null) {
|
|
487
|
+
clearTimeout(this.delayedCloseTimeout);
|
|
488
|
+
this.delayedCloseTimeout = null;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
private readonly handleInputInit = (): void => {
|
|
493
|
+
this.updateInputHasValue();
|
|
494
|
+
this.updateSelectedState();
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
private readonly handleInputInput = (): void => {
|
|
498
|
+
this.lastAction = Action.INPUT;
|
|
499
|
+
if (this.highlightedIndex !== -1) {
|
|
500
|
+
this.lastHighlightedIndex = this.highlightedIndex;
|
|
501
|
+
this.setHighlightedIndex(-1);
|
|
502
|
+
}
|
|
503
|
+
this.updateInputHasValue();
|
|
504
|
+
this.updateSelectedState();
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
private readonly handleInputPointerdown = (e: PointerEvent): void => {
|
|
508
|
+
if (e.button !== 0) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
this.setOpen();
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
private immediateClose(): void {
|
|
515
|
+
this.isOpen = false;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
private dispatchClose(): void {
|
|
519
|
+
if (this.delayedCloseTimeout !== null) {
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
this.delayedCloseTimeout = setTimeout(() => {
|
|
523
|
+
this.immediateClose();
|
|
524
|
+
}, 100);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
private readonly handleInputBlur = (event: FocusEvent): void => {
|
|
528
|
+
if (!this.contains(event.relatedTarget as Node)) {
|
|
529
|
+
this.dispatchClose();
|
|
530
|
+
} else {
|
|
531
|
+
// Regain focus if focus was lost because associated,
|
|
532
|
+
// supportive elements were clicked
|
|
533
|
+
this.getInput()?.focus();
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
private readonly handleInputKeydown = (event: KeyboardEvent): void => {
|
|
538
|
+
const input = this.getInput();
|
|
539
|
+
if (input?.disabled || input?.readOnly) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
const choiceElements = this.getChoiceElements();
|
|
544
|
+
const totalOptions = choiceElements.length;
|
|
545
|
+
|
|
546
|
+
switch (event.key) {
|
|
547
|
+
case 'ArrowDown':
|
|
548
|
+
event.preventDefault();
|
|
549
|
+
event.stopPropagation();
|
|
550
|
+
if (event.altKey && !this.isOpen) {
|
|
551
|
+
this.userSelectionIntent = SelectionIntent.NONE;
|
|
552
|
+
} else {
|
|
553
|
+
this.lastAction = Action.NAVIGATION;
|
|
554
|
+
this.setHighlightedIndex(this.getNextHighlightIndex(1, totalOptions));
|
|
555
|
+
}
|
|
556
|
+
this.setOpen();
|
|
557
|
+
break;
|
|
558
|
+
case 'ArrowUp':
|
|
559
|
+
event.preventDefault();
|
|
560
|
+
event.stopPropagation();
|
|
561
|
+
if (event.altKey && !this.isOpen) {
|
|
562
|
+
this.userSelectionIntent = SelectionIntent.NONE;
|
|
563
|
+
} else {
|
|
564
|
+
this.lastAction = Action.NAVIGATION;
|
|
565
|
+
this.setHighlightedIndex(this.getNextHighlightIndex(-1, totalOptions));
|
|
566
|
+
}
|
|
567
|
+
this.setOpen();
|
|
568
|
+
break;
|
|
569
|
+
case 'Enter':
|
|
570
|
+
if (this.isOpen) {
|
|
571
|
+
if (this.highlightedIndex >= 0 && this.lastAction === Action.NAVIGATION) {
|
|
572
|
+
event.preventDefault();
|
|
573
|
+
this.selectChoiceOption(this.highlightedIndex);
|
|
574
|
+
}
|
|
575
|
+
this.immediateClose();
|
|
576
|
+
}
|
|
577
|
+
break;
|
|
578
|
+
case 'Tab':
|
|
579
|
+
if (this.isOpen) {
|
|
580
|
+
if (this.highlightedIndex >= 0 && this.lastAction === Action.NAVIGATION) {
|
|
581
|
+
this.selectChoiceOption(this.highlightedIndex);
|
|
582
|
+
}
|
|
583
|
+
this.immediateClose();
|
|
584
|
+
if (!event.shiftKey) {
|
|
585
|
+
event.preventDefault();
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
break;
|
|
589
|
+
case 'Escape':
|
|
590
|
+
event.preventDefault();
|
|
591
|
+
this.lastAction = Action.NAVIGATION;
|
|
592
|
+
if (this.isOpen) {
|
|
593
|
+
// First ESC closes the dropdown
|
|
594
|
+
this.isOpen = false;
|
|
595
|
+
event.stopPropagation();
|
|
596
|
+
} else {
|
|
597
|
+
// Second ESC (or ESC when dropdown is closed) clears the value
|
|
598
|
+
const input = this.getInput();
|
|
599
|
+
if (input && input.value && !input.readOnly && !input.disabled) {
|
|
600
|
+
this.clearInput();
|
|
601
|
+
// Prevent dropdown from opening after clearing
|
|
602
|
+
this.isOpen = false;
|
|
603
|
+
event.stopPropagation();
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
break;
|
|
607
|
+
default:
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
private getChoiceElements(): ComboboxChoiceElement[] {
|
|
613
|
+
return Array.from(this.querySelectorAll('typo3-backend-combobox-choice'));
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
private findCurrentSelectionChoice(): ComboboxChoiceElement | null {
|
|
617
|
+
const input = this.getInput();
|
|
618
|
+
if (!input?.value) {
|
|
619
|
+
return null;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
const choiceElements = this.getChoiceElements();
|
|
623
|
+
return choiceElements.find((element) => element.value === input.value) || null;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
private getActiveDescendantId(): string {
|
|
628
|
+
const choices = this.getChoiceElements();
|
|
629
|
+
return this.highlightedIndex >= 0 ? choices[this.highlightedIndex]?.id || '' : '';
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
private updateSelectedState(): void {
|
|
633
|
+
const input = this.getInput();
|
|
634
|
+
const choiceElements = this.getChoiceElements();
|
|
635
|
+
choiceElements.forEach((element) => {
|
|
636
|
+
const isSelected = element.value === input?.value;
|
|
637
|
+
element.setSelected(isSelected);
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
private updateInputHasValue(): void {
|
|
642
|
+
const input = this.getInput();
|
|
643
|
+
this.inputHasValue = (input?.value || '').length > 0;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
private updateInputDisabledState(): void {
|
|
647
|
+
const input = this.getInput();
|
|
648
|
+
this.inputIsDisabledOrReadonly = input?.disabled || input?.readOnly || false;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
private dispatchInputEvents(input: HTMLInputElement): void {
|
|
652
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
653
|
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
private clearInput(): void {
|
|
657
|
+
const input = this.getInput();
|
|
658
|
+
if (input) {
|
|
659
|
+
input.value = '';
|
|
660
|
+
this.dispatchInputEvents(input);
|
|
661
|
+
this.updateInputHasValue();
|
|
662
|
+
this.setHighlightedIndex(-1);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
private readonly handleClearClick = (event: Event): void => {
|
|
667
|
+
event.stopPropagation();
|
|
668
|
+
this.clearInput();
|
|
669
|
+
this.getInput()?.focus();
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
private readonly handleIndicatorClick = (event: Event): void => {
|
|
673
|
+
event.stopPropagation();
|
|
674
|
+
if (this.isOpen) {
|
|
675
|
+
this.immediateClose();
|
|
676
|
+
} else {
|
|
677
|
+
this.setOpen();
|
|
678
|
+
this.getInput()?.focus();
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
private readonly handleChoiceClick = (event: Event): void => {
|
|
683
|
+
const target = event.target as HTMLElement;
|
|
684
|
+
const choice = target.closest('typo3-backend-combobox-choice');
|
|
685
|
+
const input = this.getInput();
|
|
686
|
+
|
|
687
|
+
if (choice && !choice.disabled) {
|
|
688
|
+
const choices = this.getChoiceElements();
|
|
689
|
+
const index = choices.indexOf(choice);
|
|
690
|
+
if (index >= 0) {
|
|
691
|
+
this.selectChoiceOption(index);
|
|
692
|
+
this.immediateClose();
|
|
693
|
+
input.focus();
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// Handle clicks on the host to focus input and open the listbox
|
|
699
|
+
if (input && target !== input) {
|
|
700
|
+
input.focus();
|
|
701
|
+
this.setOpen();
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
declare global {
|
|
708
|
+
interface HTMLElementTagNameMap {
|
|
709
|
+
'typo3-backend-combobox': ComboboxElement;
|
|
710
|
+
'typo3-backend-combobox-choice': ComboboxChoiceElement;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* The TYPO3 project - inspiring people to share!
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { customElement, property } from 'lit/decorators
|
|
14
|
+
import { customElement, property } from 'lit/decorators';
|
|
15
15
|
import { PseudoButtonLitElement } from '@typo3/backend/element/pseudo-button';
|
|
16
16
|
import Modal from '@typo3/backend/modal';
|
|
17
17
|
import { SeverityEnum } from '@typo3/backend/enum/severity';
|