@universal-material/web 3.0.68 → 3.0.70
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/app-bar/top-app-bar.js +3 -2
- package/app-bar/top-app-bar.js.map +1 -1
- package/button/button-base.d.ts +1 -0
- package/button/button-base.d.ts.map +1 -1
- package/button/button-base.js +7 -18
- package/button/button-base.js.map +1 -1
- package/button/button-base.styles.d.ts +2 -0
- package/button/button-base.styles.d.ts.map +1 -0
- package/button/button-base.styles.js +16 -0
- package/button/button-base.styles.js.map +1 -0
- package/button/button-set.d.ts +1 -1
- package/button/button-set.d.ts.map +1 -1
- package/button/button-set.js +1 -1
- package/button/button-set.js.map +1 -1
- package/button/button-set.styles.d.ts.map +1 -1
- package/button/button-set.styles.js +0 -19
- package/button/button-set.styles.js.map +1 -1
- package/button/button.d.ts +2 -2
- package/button/button.d.ts.map +1 -1
- package/button/button.js +1 -1
- package/button/button.js.map +1 -1
- package/button/button.styles.d.ts.map +1 -1
- package/button/button.styles.js +0 -100
- package/button/button.styles.js.map +1 -1
- package/button/fab.d.ts +2 -2
- package/button/fab.d.ts.map +1 -1
- package/button/fab.js +1 -1
- package/button/fab.js.map +1 -1
- package/button/fab.styles.d.ts.map +1 -1
- package/button/fab.styles.js +0 -100
- package/button/fab.styles.js.map +1 -1
- package/button/icon-button.d.ts +2 -2
- package/button/icon-button.d.ts.map +1 -1
- package/button/icon-button.js +1 -1
- package/button/icon-button.js.map +1 -1
- package/button/icon-button.styles.d.ts.map +1 -1
- package/button/icon-button.styles.js +0 -100
- package/button/icon-button.styles.js.map +1 -1
- package/card/card-content.js +1 -1
- package/card/card-content.js.map +1 -1
- package/card/card-media.js +1 -1
- package/card/card-media.js.map +1 -1
- package/card/card.js +1 -1
- package/card/card.js.map +1 -1
- package/checkbox/checkbox.js +8 -20
- package/checkbox/checkbox.js.map +1 -1
- package/chip/chip-set.d.ts +1 -1
- package/chip/chip-set.d.ts.map +1 -1
- package/chip/chip-set.js +1 -1
- package/chip/chip-set.js.map +1 -1
- package/chip/chip-set.styles.d.ts.map +1 -1
- package/chip/chip-set.styles.js +0 -19
- package/chip/chip-set.styles.js.map +1 -1
- package/chip/chip.d.ts +1 -1
- package/chip/chip.d.ts.map +1 -1
- package/chip/chip.js +39 -54
- package/chip/chip.js.map +1 -1
- package/chip/chip.styles.d.ts.map +1 -1
- package/chip/chip.styles.js +0 -87
- package/chip/chip.styles.js.map +1 -1
- package/chip-field/chip-field.js +72 -86
- package/chip-field/chip-field.js.map +1 -1
- package/custom-elements.json +2109 -1186
- package/dialog/confirm-dialog-builder.js +6 -22
- package/dialog/confirm-dialog-builder.js.map +1 -1
- package/dialog/dialog-builder.js +4 -17
- package/dialog/dialog-builder.js.map +1 -1
- package/dialog/dialog.js +65 -80
- package/dialog/dialog.js.map +1 -1
- package/dialog/message-dialog-builder.js +3 -19
- package/dialog/message-dialog-builder.js.map +1 -1
- package/elevation/elevation.js +1 -1
- package/elevation/elevation.js.map +1 -1
- package/field/field-base.d.ts +2 -2
- package/field/field-base.d.ts.map +1 -1
- package/field/field-base.js +13 -16
- package/field/field-base.js.map +1 -1
- package/field/field-base.styles.js +1 -1
- package/field/field-base.styles.js.map +1 -1
- package/list/list-item.js +1 -1
- package/list/list-item.js.map +1 -1
- package/list/list.js +1 -1
- package/list/list.js.map +1 -1
- package/menu/menu-item.d.ts +12 -6
- package/menu/menu-item.d.ts.map +1 -1
- package/menu/menu-item.js +49 -31
- package/menu/menu-item.js.map +1 -1
- package/menu/menu-item.styles.d.ts.map +1 -1
- package/menu/menu-item.styles.js +15 -90
- package/menu/menu-item.styles.js.map +1 -1
- package/menu/menu.d.ts +1 -1
- package/menu/menu.d.ts.map +1 -1
- package/menu/menu.js +142 -150
- package/menu/menu.js.map +1 -1
- package/menu/menu.styles.d.ts.map +1 -1
- package/menu/menu.styles.js +1 -0
- package/menu/menu.styles.js.map +1 -1
- package/navigation/drawer-item.d.ts +1 -1
- package/navigation/drawer-item.d.ts.map +1 -1
- package/navigation/drawer-item.js +4 -5
- package/navigation/drawer-item.js.map +1 -1
- package/navigation/drawer-item.styles.d.ts.map +1 -1
- package/navigation/drawer-item.styles.js +0 -87
- package/navigation/drawer-item.styles.js.map +1 -1
- package/navigation/drawer.js +4 -4
- package/navigation/drawer.js.map +1 -1
- package/navigation/side-navigation.js +8 -20
- package/navigation/side-navigation.js.map +1 -1
- package/package.json +18 -18
- package/progress/circular-progress.d.ts +1 -2
- package/progress/circular-progress.d.ts.map +1 -1
- package/progress/circular-progress.js +19 -30
- package/progress/circular-progress.js.map +1 -1
- package/progress/progress-bar.d.ts +1 -2
- package/progress/progress-bar.d.ts.map +1 -1
- package/progress/progress-bar.js +12 -20
- package/progress/progress-bar.js.map +1 -1
- package/radio/radio.js +53 -61
- package/radio/radio.js.map +1 -1
- package/ripple/ripple.js +3 -2
- package/ripple/ripple.js.map +1 -1
- package/select/extended-option.d.ts +5 -0
- package/select/extended-option.d.ts.map +1 -0
- package/select/extended-option.js +2 -0
- package/select/extended-option.js.map +1 -0
- package/select/extended-select.d.ts +6 -0
- package/select/extended-select.d.ts.map +1 -0
- package/select/extended-select.js +2 -0
- package/select/extended-select.js.map +1 -0
- package/select/option.d.ts +10 -0
- package/select/option.d.ts.map +1 -1
- package/select/option.js +84 -74
- package/select/option.js.map +1 -1
- package/select/option.styles.d.ts.map +1 -1
- package/select/option.styles.js +10 -0
- package/select/option.styles.js.map +1 -1
- package/select/select-navigation-controller.d.ts +14 -0
- package/select/select-navigation-controller.d.ts.map +1 -0
- package/select/select-navigation-controller.js +80 -0
- package/select/select-navigation-controller.js.map +1 -0
- package/select/select.d.ts +13 -5
- package/select/select.d.ts.map +1 -1
- package/select/select.js +186 -66
- package/select/select.js.map +1 -1
- package/select/select.styles.d.ts.map +1 -1
- package/select/select.styles.js +25 -6
- package/select/select.styles.js.map +1 -1
- package/shared/button-wrapper.d.ts +2 -0
- package/shared/button-wrapper.d.ts.map +1 -1
- package/shared/button-wrapper.js +18 -22
- package/shared/button-wrapper.js.map +1 -1
- package/shared/button-wrapper.styles.d.ts +2 -0
- package/shared/button-wrapper.styles.d.ts.map +1 -0
- package/shared/button-wrapper.styles.js +63 -0
- package/shared/button-wrapper.styles.js.map +1 -0
- package/shared/compare-text.d.ts +2 -0
- package/shared/compare-text.d.ts.map +1 -0
- package/shared/compare-text.js +5 -0
- package/shared/compare-text.js.map +1 -0
- package/shared/menu-field/menu-field-navigation-controller.d.ts +20 -0
- package/shared/menu-field/menu-field-navigation-controller.d.ts.map +1 -0
- package/shared/menu-field/menu-field-navigation-controller.js +103 -0
- package/shared/menu-field/menu-field-navigation-controller.js.map +1 -0
- package/shared/menu-field/menu-field.d.ts +7 -0
- package/shared/menu-field/menu-field.d.ts.map +1 -0
- package/shared/menu-field/menu-field.js +2 -0
- package/shared/menu-field/menu-field.js.map +1 -0
- package/shared/mixin-attribute-properties.d.ts.map +1 -1
- package/shared/normalize-text.d.ts +1 -1
- package/shared/normalize-text.d.ts.map +1 -1
- package/shared/normalize-text.js +1 -1
- package/shared/normalize-text.js.map +1 -1
- package/shared/selection-control/selection-control-list-item.d.ts.map +1 -1
- package/shared/selection-control/selection-control-list-item.js +7 -7
- package/shared/selection-control/selection-control-list-item.js.map +1 -1
- package/shared/selection-control/selection-control.js +16 -28
- package/shared/selection-control/selection-control.js.map +1 -1
- package/shared/sets/set-base.d.ts +2 -0
- package/shared/sets/set-base.d.ts.map +1 -1
- package/shared/sets/set-base.js +2 -0
- package/shared/sets/set-base.js.map +1 -1
- package/shared/sets/set-base.styles.d.ts +2 -0
- package/shared/sets/set-base.styles.d.ts.map +1 -0
- package/shared/sets/set-base.styles.js +22 -0
- package/shared/sets/set-base.styles.js.map +1 -0
- package/shared/text-field-base/text-field-base.js +6 -6
- package/shared/text-field-base/text-field-base.js.map +1 -1
- package/snackbar/snackbar.d.ts.map +1 -1
- package/snackbar/snackbar.js +13 -7
- package/snackbar/snackbar.js.map +1 -1
- package/switch/switch.js +4 -4
- package/switch/switch.js.map +1 -1
- package/text-field/text-field.d.ts +2 -0
- package/text-field/text-field.d.ts.map +1 -1
- package/text-field/text-field.js +22 -30
- package/text-field/text-field.js.map +1 -1
- package/typeahead/highlight.js +7 -24
- package/typeahead/highlight.js.map +1 -1
- package/typeahead/typeahead.d.ts +3 -3
- package/typeahead/typeahead.d.ts.map +1 -1
- package/typeahead/typeahead.js +178 -204
- package/typeahead/typeahead.js.map +1 -1
package/chip/chip.js
CHANGED
|
@@ -4,21 +4,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
15
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
16
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
|
-
};
|
|
18
|
-
var _UmChip_instances, _UmChip_clickable, _UmChip_toggle, _UmChip_handleRemoveClick, _UmChip_handleTrailingIconSlotChange, _UmChip_handleLeadingIconSlotChange, _UmChip_handleSelectedIconSlotChange;
|
|
19
7
|
import { html, nothing } from 'lit';
|
|
20
8
|
import { customElement, property, query, queryAssignedElements } from 'lit/decorators.js';
|
|
21
|
-
import { styles as baseStyles } from '../shared/base.styles.js';
|
|
22
9
|
import { styles } from './chip.styles.js';
|
|
23
10
|
import { UmButtonWrapper } from '../shared/button-wrapper.js';
|
|
24
11
|
import '../ripple/ripple.js';
|
|
@@ -26,9 +13,8 @@ import '../elevation/elevation.js';
|
|
|
26
13
|
let UmChip = class UmChip extends UmButtonWrapper {
|
|
27
14
|
constructor() {
|
|
28
15
|
super(...arguments);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
_UmChip_toggle.set(this, false);
|
|
16
|
+
this.#clickable = false;
|
|
17
|
+
this.#toggle = false;
|
|
32
18
|
/**
|
|
33
19
|
* Whether the chip is selected or not
|
|
34
20
|
*/
|
|
@@ -64,27 +50,53 @@ let UmChip = class UmChip extends UmButtonWrapper {
|
|
|
64
50
|
*/
|
|
65
51
|
this.hasTrailingIcon = false;
|
|
66
52
|
}
|
|
53
|
+
static { this.styles = [
|
|
54
|
+
UmButtonWrapper.styles,
|
|
55
|
+
styles
|
|
56
|
+
]; }
|
|
57
|
+
#clickable;
|
|
58
|
+
#toggle;
|
|
67
59
|
get clickable() {
|
|
68
|
-
return
|
|
60
|
+
return this.#clickable;
|
|
69
61
|
}
|
|
70
62
|
set clickable(value) {
|
|
71
|
-
|
|
72
|
-
this.renderRipple =
|
|
63
|
+
this.#clickable = value;
|
|
64
|
+
this.renderRipple = this.#clickable || this.#toggle;
|
|
73
65
|
}
|
|
74
66
|
/**
|
|
75
67
|
* When true, the chip will toggle between selected and unselected
|
|
76
68
|
* states
|
|
77
69
|
*/
|
|
78
70
|
get toggle() {
|
|
79
|
-
return
|
|
71
|
+
return this.#toggle;
|
|
80
72
|
}
|
|
81
73
|
set toggle(value) {
|
|
82
|
-
|
|
83
|
-
this.renderRipple =
|
|
74
|
+
this.#toggle = value;
|
|
75
|
+
this.renderRipple = this.#clickable || this.#toggle;
|
|
84
76
|
}
|
|
85
77
|
connectedCallback() {
|
|
86
78
|
super.connectedCallback();
|
|
87
|
-
this.renderRipple =
|
|
79
|
+
this.renderRipple = this.#clickable || this.#toggle;
|
|
80
|
+
}
|
|
81
|
+
#handleRemoveClick(e) {
|
|
82
|
+
e.stopPropagation();
|
|
83
|
+
if (!e.pointerType) {
|
|
84
|
+
this.removeRipple.createRipple();
|
|
85
|
+
}
|
|
86
|
+
const removeEvent = new Event('remove', { cancelable: true });
|
|
87
|
+
this.dispatchEvent(removeEvent);
|
|
88
|
+
if (!removeEvent.defaultPrevented) {
|
|
89
|
+
this.remove();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
#handleTrailingIconSlotChange() {
|
|
93
|
+
this.hasTrailingIcon = this.assignedTrailingIcons.length > 0;
|
|
94
|
+
}
|
|
95
|
+
#handleLeadingIconSlotChange() {
|
|
96
|
+
this.hasLeadingIcon = this.assignedLeadingIcons.length > 0;
|
|
97
|
+
}
|
|
98
|
+
#handleSelectedIconSlotChange() {
|
|
99
|
+
this.hasSelectedIcon = this.assignedSelectedIcons.length > 0;
|
|
88
100
|
}
|
|
89
101
|
handleClick(event) {
|
|
90
102
|
super.handleClick(event);
|
|
@@ -98,7 +110,7 @@ let UmChip = class UmChip extends UmButtonWrapper {
|
|
|
98
110
|
const remove = html `
|
|
99
111
|
<button
|
|
100
112
|
class="icon remove-button focus-ring"
|
|
101
|
-
@click=${
|
|
113
|
+
@click=${this.#handleRemoveClick}>
|
|
102
114
|
<u-ripple id="remove-ripple"></u-ripple>
|
|
103
115
|
<slot name="remove-icon">
|
|
104
116
|
<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 -960 960 960" width="1em" fill="currentColor">
|
|
@@ -112,13 +124,13 @@ let UmChip = class UmChip extends UmButtonWrapper {
|
|
|
112
124
|
<span class="icon leading">
|
|
113
125
|
<slot
|
|
114
126
|
name="leading-icon"
|
|
115
|
-
@slotchange="${
|
|
127
|
+
@slotchange="${this.#handleLeadingIconSlotChange}">
|
|
116
128
|
</slot>
|
|
117
129
|
</span>
|
|
118
130
|
<span class="icon selected">
|
|
119
131
|
<slot
|
|
120
132
|
name="selected-icon"
|
|
121
|
-
@slotchange="${
|
|
133
|
+
@slotchange="${this.#handleSelectedIconSlotChange}">
|
|
122
134
|
<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 -960 960 960" width="1em" fill="currentColor">
|
|
123
135
|
<path d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"/>
|
|
124
136
|
</svg>
|
|
@@ -130,38 +142,11 @@ let UmChip = class UmChip extends UmButtonWrapper {
|
|
|
130
142
|
<slot
|
|
131
143
|
class="icon trailing"
|
|
132
144
|
name="trailing-icon"
|
|
133
|
-
@slotchange="${
|
|
145
|
+
@slotchange="${this.#handleTrailingIconSlotChange}"></slot>
|
|
134
146
|
${this.removable ? remove : nothing}
|
|
135
147
|
</div>`;
|
|
136
148
|
}
|
|
137
149
|
};
|
|
138
|
-
_UmChip_clickable = new WeakMap();
|
|
139
|
-
_UmChip_toggle = new WeakMap();
|
|
140
|
-
_UmChip_instances = new WeakSet();
|
|
141
|
-
_UmChip_handleRemoveClick = function _UmChip_handleRemoveClick(e) {
|
|
142
|
-
e.stopPropagation();
|
|
143
|
-
if (!e.pointerType) {
|
|
144
|
-
this.removeRipple.createRipple();
|
|
145
|
-
}
|
|
146
|
-
const removeEvent = new Event('remove', { cancelable: true });
|
|
147
|
-
this.dispatchEvent(removeEvent);
|
|
148
|
-
if (!removeEvent.defaultPrevented) {
|
|
149
|
-
this.remove();
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
_UmChip_handleTrailingIconSlotChange = function _UmChip_handleTrailingIconSlotChange() {
|
|
153
|
-
this.hasTrailingIcon = this.assignedTrailingIcons.length > 0;
|
|
154
|
-
};
|
|
155
|
-
_UmChip_handleLeadingIconSlotChange = function _UmChip_handleLeadingIconSlotChange() {
|
|
156
|
-
this.hasLeadingIcon = this.assignedLeadingIcons.length > 0;
|
|
157
|
-
};
|
|
158
|
-
_UmChip_handleSelectedIconSlotChange = function _UmChip_handleSelectedIconSlotChange() {
|
|
159
|
-
this.hasSelectedIcon = this.assignedSelectedIcons.length > 0;
|
|
160
|
-
};
|
|
161
|
-
UmChip.styles = [
|
|
162
|
-
baseStyles,
|
|
163
|
-
styles
|
|
164
|
-
];
|
|
165
150
|
__decorate([
|
|
166
151
|
property({ type: Boolean, reflect: true })
|
|
167
152
|
], UmChip.prototype, "selected", void 0);
|
package/chip/chip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.js","sourceRoot":"","sources":["../../src/chip/chip.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chip.js","sourceRoot":"","sources":["../../src/chip/chip.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAsB,OAAO,EAAE,MAAM,KAAK,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1F,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,qBAAqB,CAAC;AAC7B,OAAO,2BAA2B,CAAC;AAG5B,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,eAAe;IAApC;;QAOL,eAAU,GAAG,KAAK,CAAC;QACnB,YAAO,GAAG,KAAK,CAAC;QAEhB;;WAEG;QACyC,aAAQ,GAAG,KAAK,CAAC;QAW7D;;WAEG;QACyC,aAAQ,GAAG,KAAK,CAAC;QAe7D;;WAEG;QACyC,cAAS,GAAG,KAAK,CAAC;QAE9D;;WAEG;QAC0E,qBAAgB,GAAG,KAAK,CAAC;QAEtG;;;;WAIG;QACsE,mBAAc,GAAG,KAAK,CAAC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/decorators.js';\n\nimport { styles } from './chip.styles.js';\n\nimport { UmRipple } from '../ripple/ripple.js';\nimport { UmButtonWrapper } from '../shared/button-wrapper.js';\n\nimport '../ripple/ripple.js';\nimport '../elevation/elevation.js';\n\n@customElement('u-chip')\nexport class UmChip extends UmButtonWrapper {\n\n static override styles = [\n UmButtonWrapper.styles,\n styles\n ];\n\n #clickable = false;\n #toggle = false;\n\n /**\n * Whether the chip is selected or not\n */\n @property({ type: Boolean, reflect: true }) selected = false;\n\n @property({ type: Boolean, reflect: true })\n get clickable(): boolean {\n return this.#clickable;\n }\n set clickable(value: boolean) {\n this.#clickable = value;\n this.renderRipple = this.#clickable || this.#toggle;\n }\n\n /**\n * Adds elevation to the chip\n */\n @property({ type: Boolean, reflect: true }) elevated = false;\n\n /**\n * When true, the chip will toggle between selected and unselected\n * states\n */\n @property({ type: Boolean, reflect: true })\n get toggle(): boolean {\n return this.#toggle;\n }\n set toggle(value: boolean) {\n this.#toggle = value;\n this.renderRipple = this.#clickable || this.#toggle;\n }\n\n /**\n * Add the remove icon\n */\n @property({ type: Boolean, reflect: true }) removable = false;\n\n /**\n * Hide the selected icon\n */\n @property({ type: Boolean, attribute: 'hide-selected-icon', reflect: true }) hideSelectedIcon = false;\n\n /**\n * Whether the chip has a leading icon or not\n *\n * _Note:_ Readonly\n */\n @property({type: Boolean, attribute: 'has-leading-icon', reflect: true}) hasLeadingIcon = false;\n\n /**\n * Whether the chip has a selected icon or not\n *\n * _Note:_ Readonly\n */\n @property({type: Boolean, attribute: 'has-selected-icon', reflect: true}) hasSelectedIcon = false;\n\n /**\n * Whether the chip has a trailing icon or not\n *\n * _Note:_ Readonly\n */\n @property({type: Boolean, attribute: 'has-trailing-icon', reflect: true}) hasTrailingIcon = false;\n\n @queryAssignedElements({slot: 'leading-icon', flatten: true})\n private readonly assignedLeadingIcons!: HTMLElement[];\n\n @queryAssignedElements({slot: 'selected-icon', flatten: true})\n private readonly assignedSelectedIcons!: HTMLElement[];\n\n @queryAssignedElements({slot: 'trailing-icon', flatten: true})\n private readonly assignedTrailingIcons!: HTMLElement[];\n\n @query('#remove-ripple') removeRipple!: UmRipple;\n\n override connectedCallback() {\n super.connectedCallback();\n this.renderRipple = this.#clickable || this.#toggle;\n }\n\n #handleRemoveClick(e: Event) {\n e.stopPropagation();\n\n if (!(<PointerEvent>e).pointerType) {\n this.removeRipple.createRipple();\n }\n\n const removeEvent = new Event('remove', {cancelable: true});\n this.dispatchEvent(removeEvent);\n\n if (!removeEvent.defaultPrevented) {\n this.remove();\n }\n }\n\n #handleTrailingIconSlotChange() {\n this.hasTrailingIcon = this.assignedTrailingIcons.length > 0;\n }\n\n #handleLeadingIconSlotChange() {\n this.hasLeadingIcon = this.assignedLeadingIcons.length > 0;\n }\n\n #handleSelectedIconSlotChange() {\n this.hasSelectedIcon = this.assignedSelectedIcons.length > 0;\n }\n\n protected override handleClick(event: UIEvent): void {\n super.handleClick(event);\n\n if (!this.toggle) {\n return;\n }\n\n this.selected = !this.selected;\n this.dispatchEvent(new Event('change', {bubbles: true}));\n }\n\n protected override renderContent(): HTMLTemplateResult {\n\n const remove = html`\n <button\n class=\"icon remove-button focus-ring\"\n @click=${this.#handleRemoveClick}>\n <u-ripple id=\"remove-ripple\"></u-ripple>\n <slot name=\"remove-icon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"1em\" viewBox=\"0 -960 960 960\" width=\"1em\" fill=\"currentColor\">\n <path d=\"m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z\"/>\n </svg>\n </slot>\n </button>`;\n\n return html`\n <div class=\"container\">\n <div class=\"outline\"></div>\n <span class=\"icon leading\">\n <slot\n name=\"leading-icon\"\n @slotchange=\"${this.#handleLeadingIconSlotChange}\">\n </slot>\n </span>\n <span class=\"icon selected\">\n <slot\n name=\"selected-icon\"\n @slotchange=\"${this.#handleSelectedIconSlotChange}\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"1em\" viewBox=\"0 -960 960 960\" width=\"1em\" fill=\"currentColor\">\n <path d=\"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z\"/>\n </svg>\n </slot>\n </span>\n <div class=\"label\">\n <slot></slot>\n </div>\n <slot\n class=\"icon trailing\"\n name=\"trailing-icon\"\n @slotchange=\"${this.#handleTrailingIconSlotChange}\"></slot>\n ${this.removable ? remove : nothing}\n </div>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'u-chip': UmChip;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.styles.d.ts","sourceRoot":"","sources":["../../src/chip/chip.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"chip.styles.d.ts","sourceRoot":"","sources":["../../src/chip/chip.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAiKlB,CAAC"}
|
package/chip/chip.styles.js
CHANGED
|
@@ -1,92 +1,5 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
2
|
export const styles = css `
|
|
3
|
-
:host,
|
|
4
|
-
* {
|
|
5
|
-
--_focus-ring-outline-offset: var(--u-focus-ring-outline-offset, 2px);
|
|
6
|
-
font-family: var(--u-font-family, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");
|
|
7
|
-
box-sizing: border-box;
|
|
8
|
-
outline: 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
:host(.force-focus-ring) .focus-ring,
|
|
12
|
-
.focus-ring:focus-visible {
|
|
13
|
-
--_color-primary: var(--u-color-primary, rgb(103, 80, 164));
|
|
14
|
-
animation: u-focus-pulse 500ms ease;
|
|
15
|
-
animation-fill-mode: forwards;
|
|
16
|
-
outline-offset: var(--_focus-ring-outline-offset);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@keyframes u-focus-pulse {
|
|
20
|
-
0% {
|
|
21
|
-
outline: 0 solid var(--_color-primary);
|
|
22
|
-
}
|
|
23
|
-
50% {
|
|
24
|
-
outline: 6px solid var(--_color-primary);
|
|
25
|
-
}
|
|
26
|
-
100% {
|
|
27
|
-
outline: 4px solid var(--_color-primary);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
:host {
|
|
31
|
-
--_color-primary: var(--u-color-primary, rgb(103, 80, 164));
|
|
32
|
-
-webkit-tap-highlight-color: transparent;
|
|
33
|
-
--u-elevation-level: 0;
|
|
34
|
-
position: relative;
|
|
35
|
-
display: inline-block;
|
|
36
|
-
font-family: var(--u-font-family, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");
|
|
37
|
-
appearance: none !important;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
:host([disabled]) {
|
|
41
|
-
--u-elevation-level: 0 !important;
|
|
42
|
-
background-color: var(--u-button-disabled-background-color, rgba(var(--u-color-on-surface-rgb, 29, 27, 32), var(--u-button-disabled-background-opacity, 0.12))) !important;
|
|
43
|
-
color: var(--u-button-disabled-text-color, rgba(var(--u-color-on-surface-rgb, 29, 27, 32), var(--u-button-disabled-color, 0.38))) !important;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
:host([disabled]) .button {
|
|
47
|
-
cursor: default;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
* {
|
|
51
|
-
color: inherit;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
u-elevation {
|
|
55
|
-
z-index: -1;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.button {
|
|
59
|
-
cursor: pointer;
|
|
60
|
-
position: absolute;
|
|
61
|
-
inset-inline-start: 0;
|
|
62
|
-
inset-block-start: 0;
|
|
63
|
-
width: 100%;
|
|
64
|
-
height: 100%;
|
|
65
|
-
font-family: inherit;
|
|
66
|
-
border-radius: inherit;
|
|
67
|
-
color: inherit;
|
|
68
|
-
border: none;
|
|
69
|
-
margin: 0;
|
|
70
|
-
padding: 0;
|
|
71
|
-
text-align: center;
|
|
72
|
-
white-space: nowrap;
|
|
73
|
-
background: transparent;
|
|
74
|
-
user-select: none;
|
|
75
|
-
text-decoration: none;
|
|
76
|
-
outline: 0;
|
|
77
|
-
z-index: 0;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.content {
|
|
81
|
-
display: inline-flex;
|
|
82
|
-
align-items: center;
|
|
83
|
-
justify-content: center;
|
|
84
|
-
white-space: nowrap;
|
|
85
|
-
border-radius: inherit;
|
|
86
|
-
width: 100%;
|
|
87
|
-
height: 100%;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
3
|
:host {
|
|
91
4
|
--_height: var(--u-chip-height, 32px);
|
|
92
5
|
--_outline-width: var(--u-chip-outline-width, 1px);
|
package/chip/chip.styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.styles.js","sourceRoot":"","sources":["../../src/chip/chip.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC
|
|
1
|
+
{"version":3,"file":"chip.styles.js","sourceRoot":"","sources":["../../src/chip/chip.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiKzB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css `\n :host {\n --_height: var(--u-chip-height, 32px);\n --_outline-width: var(--u-chip-outline-width, 1px);\n --_outline-color: var(--u-chip-outline-color, var(--u-color-outline, rgb(121, 116, 126)));\n --_shape: var(--u-chip-shape, var(--u-shape-corner-small, 8px));\n --_gap: var(--u-chip-gap, 8px);\n --_icon-size: var(--u-chip-icon-size, 1.125rem);\n --_remove-button-margin: var(--u-chip-remove-button-margin, 2px);\n --_remove-button-size: calc(var(--_height) - var(--_remove-button-margin) * 2);\n --_selected-icon-color: var(--u-chip-selected-icon-color, var(--u-color-on-secondary-container, rgb(29, 25, 43)));\n display: inline-block;\n height: var(--_height);\n border-radius: var(--_shape);\n }\n\n :host(:not([disabled]):not([elevated]):not([selected])) .outline {\n border: var(--_outline-width) solid var(--_outline-color);\n }\n\n :host([elevated]:not([disabled])) {\n --u-elevation-level: var(--u-elevated-chip-elevation-level, 1);\n }\n\n @media (hover: hover) {\n :host([elevated]:not([disabled]):hover) {\n --u-elevation-level: var(--u-elevated-chip-hover-elevation-level, 2);\n }\n }\n .outline {\n position: absolute;\n inset: 0;\n border-radius: inherit;\n pointer-events: none;\n }\n\n .container {\n display: flex;\n align-items: center;\n border-radius: inherit;\n height: 100%;\n padding-inline: var(--u-chip-padding, 16px);\n gap: var(--_gap);\n }\n\n .icon {\n width: var(--_icon-size);\n height: var(--_icon-size);\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: var(--_icon-size);\n }\n\n .leading {\n color: var(--u-chip-leading-icon-color, var(--u-color-primary, rgb(103, 80, 164)));\n }\n\n .selected {\n color: var(--_selected-icon-color);\n }\n\n .trailing {\n color: var(--u-chip-trailing-icon-color, var(--u-color-on-surface-variant, rgb(73, 69, 79)));\n }\n\n .label {\n font-family: var(--u-font-family, var(--u-font-family, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", \"Liberation Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"));\n line-height: var(--u-chip-label-line-height, var(--u-label-l-line-height, 1.25rem));\n font-size: var(--u-chip-label-font-size, var(--u-label-l-font-size, 0.875rem));\n letter-spacing: var(--u-chip-label-letter-spacing, var(--u-label-l-letter-spacing, 0.0071428571rem));\n font-weight: var(--u-chip-label-font-weight, var(--u-label-l-font-weight, var(--u-font-weight-medium, 500)));\n }\n\n .remove-button {\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n width: var(--_remove-button-size);\n height: var(--_remove-button-size);\n cursor: pointer;\n padding: 0;\n margin: 0;\n margin-inline: calc((var(--_remove-button-size) - var(--_icon-size)) * -0.5);\n background: gray;\n border: none;\n border-radius: var(--u-chip-remove-button-border-radius, var(--u-shape-corner-full, 9999px));\n background: none;\n appearance: none;\n outline: 0;\n outline-offset: 0;\n z-index: 1;\n }\n\n ::slotted([slot=remove-icon]),\n ::slotted([slot=selected-icon]),\n ::slotted([slot=leading-icon]),\n ::slotted([slot=trailing-icon]) {\n font-size: inherit !important;\n }\n\n slot[name=selected-icon] {\n display: none;\n }\n\n :host(:not([clickable]):not([toggle])) .button {\n cursor: auto;\n }\n\n :host([selected]:not([hide-selected-icon])) .leading {\n display: none;\n }\n :host([selected]:not([hide-selected-icon])) slot[name=selected-icon] {\n display: contents;\n }\n\n .default-select-icon {\n display: contents;\n }\n\n :host([has-selected-icon]) .default-select-icon {\n display: none;\n }\n\n :host([selected]:not([disabled])) {\n background-color: var(--u-chip-selected-background-color, var(--u-color-secondary-container, rgb(232, 222, 248)));\n }\n :host([selected]:not([disabled])) .leading {\n color: var(--u-chip-selected-leading-icon-color, var(--_selected-icon-color));\n }\n :host([selected]:not([disabled])) .trailing {\n color: var(--u-chip-selected-trailing-icon-color, var(--_selected-icon-color));\n }\n\n :host([has-leading-icon]) .container,\n :host([selected]:not([hide-selected-icon])) .container {\n padding-inline-start: var(--_gap);\n }\n\n :host([has-trailing-icon]) .container,\n :host([removable]) .container {\n padding-inline-end: var(--_gap);\n }\n\n :host(:not([has-leading-icon])) .leading {\n display: none;\n }\n\n :host([hide-selected-icon]) .selected,\n :host(:not([selected])) .selected {\n display: none;\n }\n\n :host(:not([has-trailing-icon])) .trailing {\n display: none;\n }\n\n [part=default-selected-icon] {\n display: contents;\n }\n`;\n"]}
|
package/chip-field/chip-field.js
CHANGED
|
@@ -4,18 +4,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
15
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
16
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
|
-
};
|
|
18
|
-
var _UmChipField_instances, _UmChipField_value, _UmChipField_getChips, _UmChipField_handleBlur, _UmChipField_handleInput, _UmChipField_handleKeyDown, _UmChipField_removeChip, _UmChipField_changed, _UmChipField_valueUpdate, _UmChipField_setEmpty, _UmChipField_dispatchRemoveEvent;
|
|
19
7
|
import { html, nothing } from 'lit';
|
|
20
8
|
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
21
9
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
@@ -24,24 +12,28 @@ import { UmTextFieldBase } from '../shared/text-field-base/text-field-base.js';
|
|
|
24
12
|
let UmChipField = class UmChipField extends UmTextFieldBase {
|
|
25
13
|
constructor() {
|
|
26
14
|
super(...arguments);
|
|
27
|
-
_UmChipField_instances.add(this);
|
|
28
15
|
this.manual = false;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const defaultPrevented =
|
|
16
|
+
this.#value = [];
|
|
17
|
+
this.#removeChip = (index) => () => {
|
|
18
|
+
const defaultPrevented = this.#dispatchRemoveEvent(index);
|
|
32
19
|
if (defaultPrevented) {
|
|
33
20
|
return;
|
|
34
21
|
}
|
|
35
22
|
this.value.splice(index, 1);
|
|
36
|
-
|
|
37
|
-
}
|
|
23
|
+
this.#changed();
|
|
24
|
+
};
|
|
38
25
|
}
|
|
26
|
+
static { this.styles = [
|
|
27
|
+
UmTextFieldBase.styles,
|
|
28
|
+
styles
|
|
29
|
+
]; }
|
|
30
|
+
#value;
|
|
39
31
|
get value() {
|
|
40
|
-
return
|
|
32
|
+
return this.#value;
|
|
41
33
|
}
|
|
42
34
|
set value(value) {
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
this.#value = value;
|
|
36
|
+
this.#valueUpdate();
|
|
45
37
|
}
|
|
46
38
|
setFormValue() {
|
|
47
39
|
const formData = new FormData();
|
|
@@ -56,21 +48,75 @@ let UmChipField = class UmChipField extends UmTextFieldBase {
|
|
|
56
48
|
renderControl() {
|
|
57
49
|
return html `
|
|
58
50
|
<div class="input">
|
|
59
|
-
${(
|
|
51
|
+
${(this.#getChips())}
|
|
60
52
|
<input
|
|
61
53
|
part="input"
|
|
62
54
|
id=${this.id || nothing}
|
|
63
55
|
aria-labelledby="label"
|
|
64
56
|
?disabled=${this.disabled}
|
|
65
57
|
placeholder=${this.placeholder || nothing}
|
|
66
|
-
@blur=${
|
|
67
|
-
@keydown=${
|
|
68
|
-
@input=${
|
|
58
|
+
@blur=${this.#handleBlur}
|
|
59
|
+
@keydown=${this.#handleKeyDown}
|
|
60
|
+
@input=${this.#handleInput}/>
|
|
69
61
|
</div>`;
|
|
70
62
|
}
|
|
63
|
+
#getChips() {
|
|
64
|
+
return this.value
|
|
65
|
+
?.map((item, index) => {
|
|
66
|
+
const leadingIcon = this.leadingIconTemplate
|
|
67
|
+
? html `<span slot="leading-icon">${unsafeHTML(this.leadingIconTemplate(item))}</span>`
|
|
68
|
+
: nothing;
|
|
69
|
+
return html `
|
|
70
|
+
<u-chip
|
|
71
|
+
removable
|
|
72
|
+
@remove=${this.#removeChip(index)}>
|
|
73
|
+
${leadingIcon}
|
|
74
|
+
${this.getItemLabel(item)}
|
|
75
|
+
</u-chip>`;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
#handleBlur() {
|
|
79
|
+
this.requestUpdate();
|
|
80
|
+
}
|
|
81
|
+
#handleInput() {
|
|
82
|
+
this.#setEmpty();
|
|
83
|
+
}
|
|
84
|
+
#handleKeyDown(e) {
|
|
85
|
+
if (!this.manual && e.key === 'Enter') {
|
|
86
|
+
this.add(this.input.value);
|
|
87
|
+
this.input.value = '';
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (e.key === 'Backspace' && this.input.selectionStart === 0 && this.input.selectionEnd === 0) {
|
|
91
|
+
this.#removeChip(this.value.length - 1)();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
71
95
|
add(value) {
|
|
72
96
|
this.value.push(value);
|
|
73
|
-
|
|
97
|
+
this.#changed();
|
|
98
|
+
}
|
|
99
|
+
#removeChip;
|
|
100
|
+
#changed() {
|
|
101
|
+
this.#valueUpdate();
|
|
102
|
+
this.dispatchEvent(new Event('change', { bubbles: true }));
|
|
103
|
+
}
|
|
104
|
+
#valueUpdate() {
|
|
105
|
+
this.#setEmpty();
|
|
106
|
+
this.setFormValue();
|
|
107
|
+
this.requestUpdate();
|
|
108
|
+
}
|
|
109
|
+
#setEmpty() {
|
|
110
|
+
this.empty = !this.value?.length && !this.input?.value;
|
|
111
|
+
}
|
|
112
|
+
#dispatchRemoveEvent(index) {
|
|
113
|
+
const item = this.value[index];
|
|
114
|
+
const event = new CustomEvent('remove', {
|
|
115
|
+
cancelable: true,
|
|
116
|
+
detail: item
|
|
117
|
+
});
|
|
118
|
+
this.dispatchEvent(event);
|
|
119
|
+
return event.defaultPrevented;
|
|
74
120
|
}
|
|
75
121
|
getItemLabel(item) {
|
|
76
122
|
return this.formatter
|
|
@@ -78,66 +124,6 @@ let UmChipField = class UmChipField extends UmTextFieldBase {
|
|
|
78
124
|
: item.toString();
|
|
79
125
|
}
|
|
80
126
|
};
|
|
81
|
-
_UmChipField_value = new WeakMap();
|
|
82
|
-
_UmChipField_removeChip = new WeakMap();
|
|
83
|
-
_UmChipField_instances = new WeakSet();
|
|
84
|
-
_UmChipField_getChips = function _UmChipField_getChips() {
|
|
85
|
-
return this.value
|
|
86
|
-
?.map((item, index) => {
|
|
87
|
-
const leadingIcon = this.leadingIconTemplate
|
|
88
|
-
? html `<span slot="leading-icon">${unsafeHTML(this.leadingIconTemplate(item))}</span>`
|
|
89
|
-
: nothing;
|
|
90
|
-
return html `
|
|
91
|
-
<u-chip
|
|
92
|
-
removable
|
|
93
|
-
@remove=${__classPrivateFieldGet(this, _UmChipField_removeChip, "f").call(this, index)}>
|
|
94
|
-
${leadingIcon}
|
|
95
|
-
${this.getItemLabel(item)}
|
|
96
|
-
</u-chip>`;
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
_UmChipField_handleBlur = function _UmChipField_handleBlur() {
|
|
100
|
-
this.requestUpdate();
|
|
101
|
-
};
|
|
102
|
-
_UmChipField_handleInput = function _UmChipField_handleInput() {
|
|
103
|
-
__classPrivateFieldGet(this, _UmChipField_instances, "m", _UmChipField_setEmpty).call(this);
|
|
104
|
-
};
|
|
105
|
-
_UmChipField_handleKeyDown = function _UmChipField_handleKeyDown(e) {
|
|
106
|
-
if (!this.manual && e.key === 'Enter') {
|
|
107
|
-
this.add(this.input.value);
|
|
108
|
-
this.input.value = '';
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if (e.key === 'Backspace' && this.input.selectionStart === 0 && this.input.selectionEnd === 0) {
|
|
112
|
-
__classPrivateFieldGet(this, _UmChipField_removeChip, "f").call(this, this.value.length - 1)();
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
_UmChipField_changed = function _UmChipField_changed() {
|
|
117
|
-
__classPrivateFieldGet(this, _UmChipField_instances, "m", _UmChipField_valueUpdate).call(this);
|
|
118
|
-
this.dispatchEvent(new Event('change', { bubbles: true }));
|
|
119
|
-
};
|
|
120
|
-
_UmChipField_valueUpdate = function _UmChipField_valueUpdate() {
|
|
121
|
-
__classPrivateFieldGet(this, _UmChipField_instances, "m", _UmChipField_setEmpty).call(this);
|
|
122
|
-
this.setFormValue();
|
|
123
|
-
this.requestUpdate();
|
|
124
|
-
};
|
|
125
|
-
_UmChipField_setEmpty = function _UmChipField_setEmpty() {
|
|
126
|
-
this.empty = !this.value?.length && !this.input?.value;
|
|
127
|
-
};
|
|
128
|
-
_UmChipField_dispatchRemoveEvent = function _UmChipField_dispatchRemoveEvent(index) {
|
|
129
|
-
const item = this.value[index];
|
|
130
|
-
const event = new CustomEvent('remove', {
|
|
131
|
-
cancelable: true,
|
|
132
|
-
detail: item
|
|
133
|
-
});
|
|
134
|
-
this.dispatchEvent(event);
|
|
135
|
-
return event.defaultPrevented;
|
|
136
|
-
};
|
|
137
|
-
UmChipField.styles = [
|
|
138
|
-
UmTextFieldBase.styles,
|
|
139
|
-
styles
|
|
140
|
-
];
|
|
141
127
|
__decorate([
|
|
142
128
|
query('input')
|
|
143
129
|
], UmChipField.prototype, "input", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip-field.js","sourceRoot":"","sources":["../../src/chip-field/chip-field.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chip-field.js","sourceRoot":"","sources":["../../src/chip-field/chip-field.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,IAAI,EAAsB,OAAO,EAAE,MAAM,KAAK,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAGxE,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,eAAe;IAAzC;;QAQsB,WAAM,GAAG,KAAK,CAAC;QAK1C,WAAM,GAAU,EAAE,CAAC;QAoFnB,gBAAW,GAAG,CAAC,KAAa,EAAE,EAAE,CAC9B,GAAG,EAAE;YACH,MAAM,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YAE1D,IAAI,gBAAgB,EAAE,CAAC;gBACrB,OAAO;YACT,CAAC;YAED,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC5B,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClB,CAAC,CAAA;IAmCL,CAAC;aA7IiB,WAAM,GAAmB;QACvC,eAAe,CAAC,MAAM;QACtB,MAAM;KACP,AAHqB,CAGpB;IASF,MAAM,CAAa;IAEnB,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,IAAI,KAAK,CAAC,KAAY;QACpB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAEO,YAAY;QAClB,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AW,CAAC,QAAQ,EAAE;YACtC,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAE1B,OAAO,KAAK,CAAC,gBAAgB,CAAC;IAChC,CAAC;IAEO,YAAY,CAAC,IAAS;QAC5B,OAAO,IAAI,CAAC,SAAS;YACnB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YACtB,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;IACtB,CAAC;;AAvIe;IAAf,KAAK,CAAC,OAAO,CAAC;0CAA0B;AAC7B;IAAX,QAAQ,EAAE;yCAAe;AACC;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;2CAAgB;AAR/B,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA8IvB","sourcesContent":["import { CSSResultGroup } from '@lit/reactive-element/css-tag';\nimport { html, HTMLTemplateResult, nothing } from 'lit';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport { styles } from './chip-field.styles.js';\n\nimport { UmTextFieldBase } from '../shared/text-field-base/text-field-base.js';\n\n@customElement('u-chip-field')\nexport class UmChipField extends UmTextFieldBase {\n static override styles: CSSResultGroup = [\n UmTextFieldBase.styles,\n styles\n ];\n\n @query('input') input!: HTMLInputElement;\n @property() name!: string;\n @property({type: Boolean}) manual = false;\n\n formatter: ((value: any) => string) | undefined;\n leadingIconTemplate: ((value: any) => string) | undefined;\n\n #value: any[] = [];\n\n get value(): any[] {\n return this.#value;\n }\n set value(value: any[]) {\n this.#value = value;\n this.#valueUpdate();\n }\n\n private setFormValue() {\n const formData = new FormData();\n\n for (const item of this.value) {\n formData.append(this.name, this.getItemLabel(item));\n }\n\n this.elementInternals.setFormValue(formData);\n }\n\n override focus() {\n this.input.focus();\n }\n\n protected override renderControl(): HTMLTemplateResult {\n\n return html`\n <div class=\"input\">\n ${(this.#getChips())}\n <input \n part=\"input\"\n id=${this.id || nothing}\n aria-labelledby=\"label\"\n ?disabled=${this.disabled}\n placeholder=${this.placeholder || nothing}\n @blur=${this.#handleBlur}\n @keydown=${this.#handleKeyDown}\n @input=${this.#handleInput}/>\n </div>`\n }\n\n #getChips() {\n return this.value\n ?.map((item, index) => {\n const leadingIcon = this.leadingIconTemplate\n ? html`<span slot=\"leading-icon\">${unsafeHTML(this.leadingIconTemplate(item))}</span>`\n : nothing\n\n return html`\n <u-chip\n removable\n @remove=${this.#removeChip(index)}>\n ${leadingIcon}\n ${this.getItemLabel(item)}\n </u-chip>`;\n });\n }\n\n #handleBlur() {\n this.requestUpdate();\n }\n\n #handleInput() {\n this.#setEmpty();\n }\n\n #handleKeyDown(e: KeyboardEvent) {\n if (!this.manual && e.key === 'Enter') {\n this.add(this.input.value);\n this.input.value = '';\n return;\n }\n\n if (e.key === 'Backspace' && this.input.selectionStart === 0 && this.input.selectionEnd === 0) {\n this.#removeChip(this.value.length - 1)();\n return;\n }\n }\n\n add(value: any) {\n this.value.push(value);\n this.#changed();\n }\n\n #removeChip = (index: number) =>\n () => {\n const defaultPrevented = this.#dispatchRemoveEvent(index);\n\n if (defaultPrevented) {\n return;\n }\n\n this.value.splice(index, 1);\n this.#changed();\n }\n\n #changed() {\n this.#valueUpdate();\n this.dispatchEvent(new Event('change', {bubbles: true}));\n }\n\n #valueUpdate() {\n this.#setEmpty();\n this.setFormValue();\n this.requestUpdate();\n }\n\n #setEmpty() {\n this.empty = !this.value?.length && !this.input?.value;\n }\n\n #dispatchRemoveEvent(index: number): boolean {\n const item = this.value[index];\n\n const event = new CustomEvent('remove', {\n cancelable: true,\n detail: item\n });\n\n this.dispatchEvent(event);\n\n return event.defaultPrevented;\n }\n\n private getItemLabel(item: any) {\n return this.formatter\n ? this.formatter(item)\n : item.toString();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'u-chip-field': UmChipField;\n }\n}\n"]}
|