@umbraco-ui/uui-menu-item 1.2.0 → 1.3.0-rc.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/lib/index.js +35 -33
- package/lib/uui-menu-item.element.d.ts +4 -4
- package/package.json +6 -6
package/lib/index.js
CHANGED
|
@@ -34,9 +34,24 @@ let UUIMenuItemElement = class extends SelectOnlyMixin(
|
|
|
34
34
|
this.hasChildren = false;
|
|
35
35
|
this.loading = false;
|
|
36
36
|
this.iconSlotHasContent = false;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
this._labelButtonChanged = (label) => {
|
|
38
|
+
this.selectableTarget = label || this;
|
|
39
|
+
};
|
|
40
|
+
this._iconSlotChanged = (e) => {
|
|
41
|
+
this.iconSlotHasContent = e.target.assignedNodes({ flatten: true }).length > 0;
|
|
42
|
+
};
|
|
43
|
+
this._onCaretClicked = () => {
|
|
44
|
+
const eventName = this.showChildren ? UUIMenuItemEvent.HIDE_CHILDREN : UUIMenuItemEvent.SHOW_CHILDREN;
|
|
45
|
+
const event = new UUIMenuItemEvent(eventName, { cancelable: true });
|
|
46
|
+
this.dispatchEvent(event);
|
|
47
|
+
if (event.defaultPrevented)
|
|
48
|
+
return;
|
|
49
|
+
this.showChildren = !this.showChildren;
|
|
50
|
+
};
|
|
51
|
+
this._onLabelClicked = () => {
|
|
52
|
+
const event = new UUIMenuItemEvent(UUIMenuItemEvent.CLICK_LABEL);
|
|
53
|
+
this.dispatchEvent(event);
|
|
54
|
+
};
|
|
40
55
|
}
|
|
41
56
|
connectedCallback() {
|
|
42
57
|
super.connectedCallback();
|
|
@@ -45,43 +60,30 @@ let UUIMenuItemElement = class extends SelectOnlyMixin(
|
|
|
45
60
|
demandCustomElement(this, "uui-symbol-expand");
|
|
46
61
|
demandCustomElement(this, "uui-loader-bar");
|
|
47
62
|
}
|
|
48
|
-
iconSlotChanged(e) {
|
|
49
|
-
this.iconSlotHasContent = e.target.assignedNodes({ flatten: true }).length > 0;
|
|
50
|
-
}
|
|
51
|
-
onCaretClicked() {
|
|
52
|
-
this.showChildren = !this.showChildren;
|
|
53
|
-
const eventName = this.showChildren ? UUIMenuItemEvent.SHOW_CHILDREN : UUIMenuItemEvent.HIDE_CHILDREN;
|
|
54
|
-
const event = new UUIMenuItemEvent(eventName);
|
|
55
|
-
this.dispatchEvent(event);
|
|
56
|
-
}
|
|
57
|
-
onLabelClicked() {
|
|
58
|
-
const event = new UUIMenuItemEvent(UUIMenuItemEvent.CLICK_LABEL);
|
|
59
|
-
this.dispatchEvent(event);
|
|
60
|
-
}
|
|
61
63
|
_renderLabelInside() {
|
|
62
64
|
return html` <slot
|
|
63
65
|
name="icon"
|
|
64
66
|
id="icon"
|
|
65
67
|
style=${this.iconSlotHasContent ? "" : "display: none;"}
|
|
66
|
-
@slotchange=${this.
|
|
68
|
+
@slotchange=${this._iconSlotChanged}></slot>
|
|
67
69
|
${this.renderLabel()}
|
|
68
70
|
<slot name="badge" id="badge"> </slot>`;
|
|
69
71
|
}
|
|
70
72
|
_renderLabelAsAnchor() {
|
|
71
73
|
if (this.disabled) {
|
|
72
|
-
return html` <span id="label-button" ${ref(this.
|
|
74
|
+
return html` <span id="label-button" ${ref(this._labelButtonChanged)}>
|
|
73
75
|
${this._renderLabelInside()}
|
|
74
76
|
</span>`;
|
|
75
77
|
}
|
|
76
78
|
return html` <a
|
|
77
79
|
id="label-button"
|
|
78
|
-
${ref(this.
|
|
80
|
+
${ref(this._labelButtonChanged)}
|
|
79
81
|
href=${ifDefined(this.href)}
|
|
80
82
|
target=${ifDefined(this.target || void 0)}
|
|
81
83
|
rel=${ifDefined(
|
|
82
84
|
this.target === "_blank" ? "noopener noreferrer" : void 0
|
|
83
85
|
)}
|
|
84
|
-
@click=${this.
|
|
86
|
+
@click=${this._onLabelClicked}
|
|
85
87
|
?disabled=${this.disabled}
|
|
86
88
|
aria-label="${this.label}">
|
|
87
89
|
${this._renderLabelInside()}
|
|
@@ -90,8 +92,8 @@ let UUIMenuItemElement = class extends SelectOnlyMixin(
|
|
|
90
92
|
_renderLabelAsButton() {
|
|
91
93
|
return html` <button
|
|
92
94
|
id="label-button"
|
|
93
|
-
${ref(this.
|
|
94
|
-
@click=${this.
|
|
95
|
+
${ref(this._labelButtonChanged)}
|
|
96
|
+
@click=${this._onLabelClicked}
|
|
95
97
|
?disabled=${this.disabled}
|
|
96
98
|
aria-label="${this.label}">
|
|
97
99
|
${this._renderLabelInside()}
|
|
@@ -100,7 +102,7 @@ let UUIMenuItemElement = class extends SelectOnlyMixin(
|
|
|
100
102
|
render() {
|
|
101
103
|
return html`
|
|
102
104
|
<div id="menu-item" aria-label="menuitem" role="menuitem">
|
|
103
|
-
${this.hasChildren ? html`<button id="caret-button" @click=${this.
|
|
105
|
+
${this.hasChildren ? html`<button id="caret-button" @click=${this._onCaretClicked}>
|
|
104
106
|
<uui-symbol-expand ?open=${this.showChildren}></uui-symbol-expand>
|
|
105
107
|
</button>` : ""}
|
|
106
108
|
${this.href ? this._renderLabelAsAnchor() : this._renderLabelAsButton()}
|
|
@@ -138,25 +140,25 @@ UUIMenuItemElement.styles = [
|
|
|
138
140
|
:host(:not([active], [selected], [disabled]))
|
|
139
141
|
#menu-item
|
|
140
142
|
#caret-button:hover {
|
|
141
|
-
background-color: var(--uui-color-surface-emphasis,
|
|
143
|
+
background-color: var(--uui-color-surface-emphasis,var(--uui-palette-white-dark));
|
|
142
144
|
}
|
|
143
145
|
:host(:not([active], [selected], [disabled]))
|
|
144
146
|
#menu-item
|
|
145
147
|
#label-button:hover,
|
|
146
148
|
:host(:not([active], [selected])) #menu-item #caret-button:hover {
|
|
147
|
-
color: var(--uui-color-interactive-emphasis
|
|
149
|
+
color: var(--uui-color-interactive-emphasis,var(--uui-palette-violet-blue));
|
|
148
150
|
}
|
|
149
151
|
|
|
150
152
|
:host([active]) #label-button,
|
|
151
153
|
:host([active]) #caret-button {
|
|
152
|
-
color: var(--uui-color-current-contrast
|
|
154
|
+
color: var(--uui-color-current-contrast,var(--uui-palette-space-cadet));
|
|
153
155
|
}
|
|
154
156
|
:host([active]) #label-button-background {
|
|
155
|
-
background-color: var(--uui-color-current
|
|
157
|
+
background-color: var(--uui-color-current,var(--uui-palette-spanish-pink));
|
|
156
158
|
}
|
|
157
159
|
:host([active]) #label-button:hover ~ #label-button-background,
|
|
158
160
|
:host([active]) #caret-button:hover {
|
|
159
|
-
background-color: var(--uui-color-current-emphasis,
|
|
161
|
+
background-color: var(--uui-color-current-emphasis,var(--uui-palette-spanish-pink-light));
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
:host([selected]) #label-button,
|
|
@@ -164,16 +166,16 @@ UUIMenuItemElement.styles = [
|
|
|
164
166
|
color: var(--uui-color-selected-contrast,#fff);
|
|
165
167
|
}
|
|
166
168
|
:host([selected]) #label-button-background {
|
|
167
|
-
background-color: var(--uui-color-selected
|
|
169
|
+
background-color: var(--uui-color-selected,var(--uui-palette-violet-blue));
|
|
168
170
|
}
|
|
169
171
|
:host([selected]) #label-button:hover ~ #label-button-background,
|
|
170
172
|
:host([selected]) #caret-button:hover {
|
|
171
|
-
background-color: var(--uui-color-selected-emphasis,
|
|
173
|
+
background-color: var(--uui-color-selected-emphasis,var(--uui-palette-violet-blue-light));
|
|
172
174
|
}
|
|
173
175
|
|
|
174
176
|
:host([disabled]) #menu-item {
|
|
175
|
-
color: var(--uui-color-disabled-contrast
|
|
176
|
-
background-color: var(--uui-color-disabled
|
|
177
|
+
color: var(--uui-color-disabled-contrast,var(--uui-palette-grey));
|
|
178
|
+
background-color: var(--uui-color-disabled,var(--uui-palette-sand));
|
|
177
179
|
}
|
|
178
180
|
:host([disabled]) #label-button {
|
|
179
181
|
cursor: default;
|
|
@@ -229,7 +231,7 @@ UUIMenuItemElement.styles = [
|
|
|
229
231
|
display: flex;
|
|
230
232
|
align-items: center;
|
|
231
233
|
justify-content: center;
|
|
232
|
-
color: var(--uui-color-interactive
|
|
234
|
+
color: var(--uui-color-interactive,var(--uui-palette-space-cadet));
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
#label-button-background {
|
|
@@ -56,11 +56,11 @@ export declare class UUIMenuItemElement extends UUIMenuItemElement_base {
|
|
|
56
56
|
*/
|
|
57
57
|
target?: '_blank' | '_parent' | '_self' | '_top';
|
|
58
58
|
private iconSlotHasContent;
|
|
59
|
-
labelButtonChanged(label?: Element | undefined): void;
|
|
60
59
|
connectedCallback(): void;
|
|
61
|
-
private
|
|
62
|
-
private
|
|
63
|
-
private
|
|
60
|
+
private _labelButtonChanged;
|
|
61
|
+
private _iconSlotChanged;
|
|
62
|
+
private _onCaretClicked;
|
|
63
|
+
private _onLabelClicked;
|
|
64
64
|
private _renderLabelInside;
|
|
65
65
|
private _renderLabelAsAnchor;
|
|
66
66
|
private _renderLabelAsButton;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umbraco-ui/uui-menu-item",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-rc.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Umbraco",
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
"custom-elements.json"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@umbraco-ui/uui-base": "1.
|
|
34
|
-
"@umbraco-ui/uui-loader-bar": "1.
|
|
35
|
-
"@umbraco-ui/uui-symbol-expand": "1.
|
|
33
|
+
"@umbraco-ui/uui-base": "1.3.0-rc.0",
|
|
34
|
+
"@umbraco-ui/uui-loader-bar": "1.3.0-rc.0",
|
|
35
|
+
"@umbraco-ui/uui-symbol-expand": "1.3.0-rc.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js",
|
|
39
|
-
"clean": "tsc --build --clean && rimraf dist lib/*.js lib/**/*.js custom-elements.json",
|
|
39
|
+
"clean": "tsc --build --clean && rimraf -g dist lib/*.js lib/**/*.js custom-elements.json",
|
|
40
40
|
"analyze": "web-component-analyzer **/*.element.ts --outFile custom-elements.json"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://uui.umbraco.com/?path=/story/uui-menu-item",
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "45c3824056586d9817efb3f61dc0bef5478747f0"
|
|
47
47
|
}
|