Skip to content

Commit 360c3ae

Browse files
committed
Merge branch 'main' into v15/dev
2 parents e29f620 + d1e119d commit 360c3ae

File tree

11 files changed

+109
-24
lines changed

11 files changed

+109
-24
lines changed

package-lock.json

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
"typescript": "^5.5.3",
263263
"typescript-eslint": "^8.0.1",
264264
"typescript-json-schema": "^0.64.0",
265-
"vite": "^5.3.4",
265+
"vite": "^5.4.6",
266266
"vite-plugin-static-copy": "^1.0.6",
267267
"vite-tsconfig-paths": "^4.3.2",
268268
"web-component-analyzer": "^2.0.0"

src/packages/core/components/multiple-color-picker-input/multiple-color-picker-input.element.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class UmbMultipleColorPickerInputElement extends UUIFormControlMixin(UmbL
175175
<div id="sorter-wrapper">
176176
${repeat(
177177
this._items,
178-
(item) => item.value,
178+
(item, index) => index,
179179
(item, index) => html`
180180
<umb-multiple-color-picker-item-input
181181
label=${item.label}
@@ -185,6 +185,7 @@ export class UmbMultipleColorPickerInputElement extends UUIFormControlMixin(UmbL
185185
?disabled=${this.disabled}
186186
?readonly=${this.readonly}
187187
?showLabels=${this.showLabels}
188+
@enter=${this.#onAdd}
188189
@change=${(event: UmbChangeEvent) => this.#onChange(event, index)}
189190
@delete=${(event: UmbDeleteEvent) => this.#deleteItem(event, index)}>
190191
</umb-multiple-color-picker-item-input>

src/packages/core/components/multiple-color-picker-input/multiple-color-picker-item-input.element.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,25 @@ export class UmbMultipleColorPickerItemInputElement extends UUIFormControlMixin(
8484
this.dispatchEvent(new UmbInputEvent());
8585
}
8686

87+
#onLabelKeydown(event: KeyboardEvent) {
88+
event.stopPropagation();
89+
const target = event.currentTarget as UUIInputElement;
90+
if (event.key === 'Enter' && target.value) {
91+
this.dispatchEvent(new CustomEvent('enter'));
92+
}
93+
}
94+
8795
#onLabelChange(event: UUIInputEvent) {
8896
event.stopPropagation();
8997
this.label = event.target.value as string;
9098
this.dispatchEvent(new UmbChangeEvent());
9199
}
92100

101+
#onValueKeydown(event: KeyboardEvent) {
102+
event.stopPropagation();
103+
if (event.key === 'Enter') this.#onColorClick();
104+
}
105+
93106
#onValueChange(event: UUIInputEvent) {
94107
event.stopPropagation();
95108
this.value = event.target.value as string;
@@ -145,6 +158,7 @@ export class UmbMultipleColorPickerItemInputElement extends UUIFormControlMixin(
145158
placeholder=${this.localize.term('general_value')}
146159
required=${this.required}
147160
required-message="Value is missing"
161+
@keydown=${this.#onValueKeydown}
148162
@input=${this.#onValueInput}
149163
@change=${this.#onValueChange}>
150164
<uui-color-swatch
@@ -162,6 +176,7 @@ export class UmbMultipleColorPickerItemInputElement extends UUIFormControlMixin(
162176
label=${this.localize.term('placeholders_label')}
163177
placeholder=${this.localize.term('placeholders_label')}
164178
value=${ifDefined(this.label)}
179+
@keydown=${this.#onLabelKeydown}
165180
@input="${this.#onLabelInput}"
166181
@change="${this.#onLabelChange}"
167182
?disabled=${this.disabled}
@@ -210,6 +225,12 @@ export class UmbMultipleColorPickerItemInputElement extends UUIFormControlMixin(
210225
padding: var(--uui-size-1);
211226
}
212227
228+
uui-color-swatch:focus-within {
229+
outline: 2px solid var(--uui-color-selected);
230+
outline-offset: 0;
231+
border-radius: var(--uui-border-radius);
232+
}
233+
213234
.color-wrapper {
214235
position: relative;
215236
flex: 1;

src/packages/core/tree/tree-picker-modal/tree-picker-modal.element.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ export class UmbTreePickerModalElement<TreeItemType extends UmbTreeItemModelBase
5353
super.updated(_changedProperties);
5454

5555
if (_changedProperties.has('data')) {
56-
this.#pickerContext.search.updateConfig({ ...this.data?.search });
56+
if (this.data?.search) {
57+
this.#pickerContext.search.updateConfig({ ...this.data?.search });
58+
}
5759

5860
const multiple = this.data?.multiple ?? false;
5961
this.#pickerContext.selection.setMultiple(multiple);

src/packages/core/utils/selection-manager/selection.manager.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ describe('UmbSelectionManager', () => {
7676
it('has a clearSelection method', () => {
7777
expect(manager).to.have.property('clearSelection').that.is.a('function');
7878
});
79+
80+
it('has a setAllowLimitation method', () => {
81+
expect(manager).to.have.property('setAllowLimitation').that.is.a('function');
82+
});
7983
});
8084
});
8185

@@ -150,6 +154,15 @@ describe('UmbSelectionManager', () => {
150154
manager.select('3');
151155
expect(manager.getSelection()).to.deep.equal([]);
152156
});
157+
158+
it('can not select an item if it does not pass the allow function', () => {
159+
manager.setAllowLimitation((item) => item !== '2');
160+
expect(() => manager.select('2')).to.throw();
161+
expect(manager.getSelection()).to.deep.equal([]);
162+
163+
manager.select('1');
164+
expect(manager.getSelection()).to.deep.equal(['1']);
165+
});
153166
});
154167

155168
describe('Deselect', () => {

src/packages/core/utils/selection-manager/selection.manager.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export class UmbSelectionManager<ValueType extends string | null = string | null
1818
#multiple = new UmbBooleanState(false);
1919
public readonly multiple = this.#multiple.asObservable();
2020

21+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
22+
#allow = (unique: ValueType) => true;
23+
2124
constructor(host: UmbControllerHost) {
2225
super(host);
2326
}
@@ -109,6 +112,9 @@ export class UmbSelectionManager<ValueType extends string | null = string | null
109112
public select(unique: ValueType) {
110113
if (this.getSelectable() === false) return;
111114
if (this.isSelected(unique)) return;
115+
if (this.#allow(unique) === false) {
116+
throw new Error('The item is now allowed to be selected');
117+
}
112118
const newSelection = this.getMultiple() ? [...this.getSelection(), unique] : [unique];
113119
this.#selection.setValue(newSelection);
114120
this.getHostElement().dispatchEvent(new UmbSelectedEvent(unique));
@@ -146,4 +152,13 @@ export class UmbSelectionManager<ValueType extends string | null = string | null
146152
if (this.getSelectable() === false) return;
147153
this.#selection.setValue([]);
148154
}
155+
156+
/**
157+
* Sets a function that determines if an item is selectable or not.
158+
* @param compareFn A function that determines if an item is selectable or not.
159+
* @memberof UmbSelectionManager
160+
*/
161+
public setAllowLimitation(compareFn: (unique: ValueType) => boolean): void {
162+
this.#allow = compareFn;
163+
}
149164
}

src/packages/core/workspace/components/workspace-action-menu/workspace-action-menu.element.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ export class UmbWorkspaceActionMenuElement extends UmbLitElement {
7878
}
7979
8080
#popover-trigger {
81-
--uui-button-padding-top-factor: 0.5;
82-
--uui-button-padding-bottom-factor: 0.1;
81+
--uui-button-padding-top-factor: 0;
82+
--uui-button-padding-bottom-factor: 0.125;
8383
}
8484
`,
8585
];

src/packages/documents/documents/modals/schedule-modal/document-schedule-modal.element.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ export class UmbDocumentScheduleModalElement extends UmbModalBaseElement<
4141
this.#selectionManager.setMultiple(true);
4242
this.#selectionManager.setSelectable(true);
4343

44+
const pickableFilter = this.data?.pickableFilter;
45+
46+
if (pickableFilter) {
47+
this.#selectionManager.setAllowLimitation((unique) => {
48+
const option = this.data?.options.find((o) => o.unique === unique);
49+
return option ? pickableFilter(option) : true;
50+
});
51+
}
52+
4453
// Only display variants that are relevant to pick from, i.e. variants that are draft or published with pending changes:
4554
this._options =
4655
this.data?.options.filter(

src/packages/documents/documents/modals/shared/document-variant-language-picker.element.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import { UmbDocumentVariantState, type UmbDocumentVariantOptionModel } from '../../types.js';
2-
import { css, customElement, html, nothing, property, repeat, state } from '@umbraco-cms/backoffice/external/lit';
2+
import {
3+
css,
4+
customElement,
5+
html,
6+
nothing,
7+
property,
8+
repeat,
9+
state,
10+
type PropertyValues,
11+
} from '@umbraco-cms/backoffice/external/lit';
312
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
413
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
514
import type { UmbSelectionManager } from '@umbraco-cms/backoffice/utils';
@@ -37,6 +46,17 @@ export class UmbDocumentVariantLanguagePickerElement extends UmbLitElement {
3746
@property({ attribute: false })
3847
public pickableFilter?: (item: UmbDocumentVariantOptionModel) => boolean;
3948

49+
protected override updated(_changedProperties: PropertyValues): void {
50+
super.updated(_changedProperties);
51+
52+
if (this.selectionManager && this.pickableFilter) {
53+
this.#selectionManager.setAllowLimitation((unique) => {
54+
const option = this.variantLanguageOptions.find((o) => o.unique === unique);
55+
return option ? this.pickableFilter!(option) : true;
56+
});
57+
}
58+
}
59+
4060
override render() {
4161
return this.variantLanguageOptions.length
4262
? repeat(

0 commit comments

Comments
 (0)