@universal-material/web 3.0.39 → 3.0.41
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/chip/chip.d.ts +9 -4
- package/chip/chip.d.ts.map +1 -1
- package/chip/chip.js +67 -40
- package/chip/chip.js.map +1 -1
- package/chip/chip.styles.d.ts.map +1 -1
- package/chip/chip.styles.js +42 -21
- package/chip/chip.styles.js.map +1 -1
- package/chip-field/chip-field.d.ts +26 -0
- package/chip-field/chip-field.d.ts.map +1 -0
- package/chip-field/chip-field.js +137 -0
- package/chip-field/chip-field.js.map +1 -0
- package/chip-field/chip-field.styles.d.ts +2 -0
- package/chip-field/chip-field.styles.d.ts.map +1 -0
- package/chip-field/chip-field.styles.js +20 -0
- package/chip-field/chip-field.styles.js.map +1 -0
- package/custom-elements.json +4123 -3219
- package/field/field.d.ts +1 -0
- package/field/field.d.ts.map +1 -1
- package/field/field.js +12 -4
- package/field/field.js.map +1 -1
- package/field/field.styles.js +1 -1
- package/field/field.styles.js.map +1 -1
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -1
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/radio/radio.js +1 -1
- package/radio/radio.js.map +1 -1
- package/shared/button-wrapper.d.ts +1 -1
- package/shared/button-wrapper.d.ts.map +1 -1
- package/shared/button-wrapper.js +4 -4
- package/shared/button-wrapper.js.map +1 -1
- package/shared/extract-template-html.d.ts +2 -0
- package/shared/extract-template-html.d.ts.map +1 -0
- package/shared/extract-template-html.js +8 -0
- package/shared/extract-template-html.js.map +1 -0
- package/shared/text-field-base/text-field-base.d.ts +23 -0
- package/shared/text-field-base/text-field-base.d.ts.map +1 -0
- package/shared/text-field-base/text-field-base.js +87 -0
- package/shared/text-field-base/text-field-base.js.map +1 -0
- package/shared/text-field-base/text-field-base.styles.d.ts +2 -0
- package/shared/text-field-base/text-field-base.styles.d.ts.map +1 -0
- package/shared/text-field-base/text-field-base.styles.js +7 -0
- package/shared/text-field-base/text-field-base.styles.js.map +1 -0
- package/text-field/text-field.d.ts +9 -24
- package/text-field/text-field.d.ts.map +1 -1
- package/text-field/text-field.js +29 -96
- package/text-field/text-field.js.map +1 -1
- package/text-field/text-field.styles.d.ts.map +1 -1
- package/text-field/text-field.styles.js +0 -4
- package/text-field/text-field.styles.js.map +1 -1
- package/typeahead/typeahead.d.ts +1 -0
- package/typeahead/typeahead.d.ts.map +1 -1
- package/typeahead/typeahead.js +22 -4
- package/typeahead/typeahead.js.map +1 -1
package/chip/chip.d.ts
CHANGED
|
@@ -20,11 +20,16 @@ export declare class UmChip extends UmButtonWrapper {
|
|
|
20
20
|
* When true, the chip will toggle between selected and unselected
|
|
21
21
|
* states
|
|
22
22
|
*/
|
|
23
|
-
toggle: boolean;
|
|
23
|
+
get toggle(): boolean;
|
|
24
|
+
set toggle(value: boolean);
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* Add the remove icon
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
+
removable: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Hide the selected icon
|
|
31
|
+
*/
|
|
32
|
+
hideSelectedIcon: boolean;
|
|
28
33
|
/**
|
|
29
34
|
* Whether the chip has a leading icon or not
|
|
30
35
|
*
|
|
@@ -46,7 +51,7 @@ export declare class UmChip extends UmButtonWrapper {
|
|
|
46
51
|
private readonly assignedLeadingIcons;
|
|
47
52
|
private readonly assignedSelectedIcons;
|
|
48
53
|
private readonly assignedTrailingIcons;
|
|
49
|
-
|
|
54
|
+
removeRipple: UmRipple;
|
|
50
55
|
protected handleClick(event: UIEvent): void;
|
|
51
56
|
protected renderContent(): HTMLTemplateResult;
|
|
52
57
|
}
|
package/chip/chip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.d.ts","sourceRoot":"","sources":["../../src/chip/chip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,kBAAkB,
|
|
1
|
+
{"version":3,"file":"chip.d.ts","sourceRoot":"","sources":["../../src/chip/chip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,kBAAkB,EAAW,MAAM,KAAK,CAAC;AAMxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,qBAAqB,CAAC;AAC7B,OAAO,2BAA2B,CAAC;AAEnC,qBACa,MAAO,SAAQ,eAAe;;IAEzC,OAAgB,MAAM,4BAGpB;IAKF;;OAEG;IACyC,QAAQ,UAAS;IAE7D,IACI,SAAS,IAAI,OAAO,CAEvB;IACD,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,EAG3B;IAED;;OAEG;IACyC,QAAQ,UAAS;IAE7D;;;OAGG;IACH,IACI,MAAM,IAAI,OAAO,CAEpB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,OAAO,EAGxB;IAED;;OAEG;IACyC,SAAS,UAAS;IAE9D;;OAEG;IAC0E,gBAAgB,UAAS;IAEtG;;;;OAIG;IACsE,cAAc,UAAS;IAEhG;;;;OAIG;IACuE,eAAe,UAAS;IAElG;;;;OAIG;IACuE,eAAe,UAAS;IAGlG,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAiB;IAGtD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAiB;IAGvD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAiB;IAE9B,YAAY,EAAG,QAAQ,CAAC;cA6B9B,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;cAWjC,aAAa,IAAI,kBAAkB;CA0CvD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,QAAQ,EAAE,MAAM,CAAC;KAClB;CACF"}
|
package/chip/chip.js
CHANGED
|
@@ -15,8 +15,8 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
15
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
16
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
17
|
};
|
|
18
|
-
var _UmChip_instances, _UmChip_clickable,
|
|
19
|
-
import { html } from 'lit';
|
|
18
|
+
var _UmChip_instances, _UmChip_clickable, _UmChip_toggle, _UmChip_handleRemoveClick, _UmChip_handleTrailingIconSlotChange, _UmChip_handleLeadingIconSlotChange, _UmChip_handleSelectedIconSlotChange;
|
|
19
|
+
import { html, nothing } from 'lit';
|
|
20
20
|
import { customElement, property, query, queryAssignedElements } from 'lit/decorators.js';
|
|
21
21
|
import { styles as baseStyles } from '../shared/base.styles.js';
|
|
22
22
|
import { styles } from './chip.styles.js';
|
|
@@ -28,6 +28,7 @@ let UmChip = class UmChip extends UmButtonWrapper {
|
|
|
28
28
|
super(...arguments);
|
|
29
29
|
_UmChip_instances.add(this);
|
|
30
30
|
_UmChip_clickable.set(this, false);
|
|
31
|
+
_UmChip_toggle.set(this, false);
|
|
31
32
|
/**
|
|
32
33
|
* Whether the chip is selected or not
|
|
33
34
|
*/
|
|
@@ -37,14 +38,13 @@ let UmChip = class UmChip extends UmButtonWrapper {
|
|
|
37
38
|
*/
|
|
38
39
|
this.elevated = false;
|
|
39
40
|
/**
|
|
40
|
-
*
|
|
41
|
-
* states
|
|
41
|
+
* Add the remove icon
|
|
42
42
|
*/
|
|
43
|
-
this.
|
|
43
|
+
this.removable = false;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Hide the selected icon
|
|
46
46
|
*/
|
|
47
|
-
this.
|
|
47
|
+
this.hideSelectedIcon = false;
|
|
48
48
|
/**
|
|
49
49
|
* Whether the chip has a leading icon or not
|
|
50
50
|
*
|
|
@@ -65,10 +65,22 @@ let UmChip = class UmChip extends UmButtonWrapper {
|
|
|
65
65
|
this.hasTrailingIcon = false;
|
|
66
66
|
}
|
|
67
67
|
get clickable() {
|
|
68
|
-
return __classPrivateFieldGet(this, _UmChip_clickable, "f")
|
|
68
|
+
return __classPrivateFieldGet(this, _UmChip_clickable, "f");
|
|
69
69
|
}
|
|
70
70
|
set clickable(value) {
|
|
71
71
|
__classPrivateFieldSet(this, _UmChip_clickable, value, "f");
|
|
72
|
+
this.renderRipple = __classPrivateFieldGet(this, _UmChip_clickable, "f") || __classPrivateFieldGet(this, _UmChip_toggle, "f");
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* When true, the chip will toggle between selected and unselected
|
|
76
|
+
* states
|
|
77
|
+
*/
|
|
78
|
+
get toggle() {
|
|
79
|
+
return __classPrivateFieldGet(this, _UmChip_toggle, "f");
|
|
80
|
+
}
|
|
81
|
+
set toggle(value) {
|
|
82
|
+
__classPrivateFieldSet(this, _UmChip_toggle, value, "f");
|
|
83
|
+
this.renderRipple = __classPrivateFieldGet(this, _UmChip_clickable, "f") || __classPrivateFieldGet(this, _UmChip_toggle, "f");
|
|
72
84
|
}
|
|
73
85
|
handleClick(event) {
|
|
74
86
|
super.handleClick(event);
|
|
@@ -79,47 +91,59 @@ let UmChip = class UmChip extends UmButtonWrapper {
|
|
|
79
91
|
this.dispatchEvent(new Event('change', { bubbles: true }));
|
|
80
92
|
}
|
|
81
93
|
renderContent() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
@
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
</button>`;
|
|
94
|
-
}
|
|
94
|
+
const remove = html `
|
|
95
|
+
<button
|
|
96
|
+
class="icon remove-button focus-ring"
|
|
97
|
+
@click=${__classPrivateFieldGet(this, _UmChip_instances, "m", _UmChip_handleRemoveClick)}>
|
|
98
|
+
<u-ripple id="remove-ripple"></u-ripple>
|
|
99
|
+
<slot name="remove-icon">
|
|
100
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 -960 960 960" width="1em" fill="currentColor">
|
|
101
|
+
<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"/>
|
|
102
|
+
</svg>
|
|
103
|
+
</slot>
|
|
104
|
+
</button>`;
|
|
95
105
|
return html `
|
|
96
106
|
<div class="container">
|
|
97
107
|
<div class="outline"></div>
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
<span class="icon leading">
|
|
109
|
+
<slot
|
|
110
|
+
name="leading-icon"
|
|
111
|
+
@slotchange="${__classPrivateFieldGet(this, _UmChip_instances, "m", _UmChip_handleLeadingIconSlotChange)}">
|
|
112
|
+
</slot>
|
|
113
|
+
</span>
|
|
114
|
+
<span class="icon selected">
|
|
115
|
+
<slot
|
|
116
|
+
name="selected-icon"
|
|
117
|
+
@slotchange="${__classPrivateFieldGet(this, _UmChip_instances, "m", _UmChip_handleSelectedIconSlotChange)}">
|
|
118
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 -960 960 960" width="1em" fill="currentColor">
|
|
119
|
+
<path d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"/>
|
|
120
|
+
</svg>
|
|
121
|
+
</slot>
|
|
122
|
+
</span>
|
|
108
123
|
<div class="label">
|
|
109
|
-
|
|
124
|
+
<slot></slot>
|
|
110
125
|
</div>
|
|
111
|
-
|
|
126
|
+
<slot
|
|
127
|
+
class="icon trailing"
|
|
128
|
+
name="trailing-icon"
|
|
129
|
+
@slotchange="${__classPrivateFieldGet(this, _UmChip_instances, "m", _UmChip_handleTrailingIconSlotChange)}"></slot>
|
|
130
|
+
${this.removable ? remove : nothing}
|
|
112
131
|
</div>`;
|
|
113
132
|
}
|
|
114
133
|
};
|
|
115
134
|
_UmChip_clickable = new WeakMap();
|
|
135
|
+
_UmChip_toggle = new WeakMap();
|
|
116
136
|
_UmChip_instances = new WeakSet();
|
|
117
|
-
|
|
137
|
+
_UmChip_handleRemoveClick = function _UmChip_handleRemoveClick(e) {
|
|
118
138
|
e.stopPropagation();
|
|
119
139
|
if (!e.pointerType) {
|
|
120
|
-
this.
|
|
140
|
+
this.removeRipple.createRipple();
|
|
141
|
+
}
|
|
142
|
+
const removeEvent = new Event('remove', { cancelable: true });
|
|
143
|
+
this.dispatchEvent(removeEvent);
|
|
144
|
+
if (!removeEvent.defaultPrevented) {
|
|
145
|
+
this.remove();
|
|
121
146
|
}
|
|
122
|
-
this.dispatchEvent(new Event('action'));
|
|
123
147
|
};
|
|
124
148
|
_UmChip_handleTrailingIconSlotChange = function _UmChip_handleTrailingIconSlotChange() {
|
|
125
149
|
this.hasTrailingIcon = this.assignedTrailingIcons.length > 0;
|
|
@@ -145,10 +169,13 @@ __decorate([
|
|
|
145
169
|
], UmChip.prototype, "elevated", void 0);
|
|
146
170
|
__decorate([
|
|
147
171
|
property({ type: Boolean, reflect: true })
|
|
148
|
-
], UmChip.prototype, "toggle",
|
|
172
|
+
], UmChip.prototype, "toggle", null);
|
|
149
173
|
__decorate([
|
|
150
174
|
property({ type: Boolean, reflect: true })
|
|
151
|
-
], UmChip.prototype, "
|
|
175
|
+
], UmChip.prototype, "removable", void 0);
|
|
176
|
+
__decorate([
|
|
177
|
+
property({ type: Boolean, attribute: 'hide-selected-icon', reflect: true })
|
|
178
|
+
], UmChip.prototype, "hideSelectedIcon", void 0);
|
|
152
179
|
__decorate([
|
|
153
180
|
property({ type: Boolean, attribute: 'has-leading-icon', reflect: true })
|
|
154
181
|
], UmChip.prototype, "hasLeadingIcon", void 0);
|
|
@@ -168,8 +195,8 @@ __decorate([
|
|
|
168
195
|
queryAssignedElements({ slot: 'trailing-icon', flatten: true })
|
|
169
196
|
], UmChip.prototype, "assignedTrailingIcons", void 0);
|
|
170
197
|
__decorate([
|
|
171
|
-
query('#
|
|
172
|
-
], UmChip.prototype, "
|
|
198
|
+
query('#remove-ripple')
|
|
199
|
+
], UmChip.prototype, "removeRipple", void 0);
|
|
173
200
|
UmChip = __decorate([
|
|
174
201
|
customElement('u-chip')
|
|
175
202
|
], UmChip);
|
package/chip/chip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.js","sourceRoot":"","sources":["../../src/chip/chip.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAsB,MAAM,KAAK,CAAC;
|
|
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,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAChE,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,4BAAa,KAAK,EAAC;QACnB,yBAAU,KAAK,EAAC;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;QAEhG;;;;WAIG;QACuE,oBAAe,GAAG,KAAK,CAAC;QAElG;;;;WAIG;QACuE,oBAAe,GAAG,KAAK,CAAC;IA6FpG,C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AAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAA0B;AAO7B;IAAxE,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;8CAAwB;AAOtB;IAAzE,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;+CAAyB;AAOxB;IAAzE,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;+CAAyB;AAGjF;IADhB,qBAAqB,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;oDACP;AAGrC;IADhB,qBAAqB,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;qDACP;AAGtC;IADhB,qBAAqB,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;qDACP;AAE9B;IAAxB,KAAK,CAAC,gBAAgB,CAAC;4CAAyB;AAlFtC,MAAM;IADlB,aAAa,CAAC,QAAQ,CAAC;GACX,MAAM,CAoKlB","sourcesContent":["import { html, HTMLTemplateResult, nothing } from 'lit';\nimport { customElement, property, query, queryAssignedElements } from 'lit/decorators.js';\n\nimport { styles as baseStyles } from '../shared/base.styles.js';\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 baseStyles,\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 #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,yBAsPlB,CAAC"}
|
package/chip/chip.styles.js
CHANGED
|
@@ -92,17 +92,14 @@ export const styles = css `
|
|
|
92
92
|
--_shape: var(--u-chip-shape, var(--u-shape-corner-small, 8px));
|
|
93
93
|
--_gap: var(--u-chip-gap, 8px);
|
|
94
94
|
--_icon-size: var(--u-chip-icon-size, 1.125rem);
|
|
95
|
-
--
|
|
96
|
-
--
|
|
95
|
+
--_remove-button-margin: var(--u-chip-remove-button-margin, 2px);
|
|
96
|
+
--_remove-button-size: calc(var(--_height) - var(--_remove-button-margin) * 2);
|
|
97
|
+
--_selected-icon-color: var(--u-chip-selected-icon-color, var(--u-color-on-secondary-container, rgb(29, 25, 43)));
|
|
97
98
|
display: inline-block;
|
|
98
99
|
height: var(--_height);
|
|
99
100
|
border-radius: var(--_shape);
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
:host(:not([disabled])) {
|
|
103
|
-
cursor: pointer;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
103
|
:host(:not([disabled]):not([elevated]):not([selected])) .outline {
|
|
107
104
|
border: var(--_outline-width) solid var(--_outline-color);
|
|
108
105
|
}
|
|
@@ -145,6 +142,10 @@ export const styles = css `
|
|
|
145
142
|
color: var(--u-chip-leading-icon-color, var(--u-color-primary, rgb(103, 80, 164)));
|
|
146
143
|
}
|
|
147
144
|
|
|
145
|
+
.selected {
|
|
146
|
+
color: var(--_selected-icon-color);
|
|
147
|
+
}
|
|
148
|
+
|
|
148
149
|
.trailing {
|
|
149
150
|
color: var(--u-chip-trailing-icon-color, var(--u-color-on-surface-variant, rgb(73, 69, 79)));
|
|
150
151
|
}
|
|
@@ -157,20 +158,20 @@ export const styles = css `
|
|
|
157
158
|
font-weight: var(--u-chip-label-font-weight, var(--u-label-l-font-weight, var(--u-font-weight-medium, 500)));
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
.
|
|
161
|
+
.remove-button {
|
|
161
162
|
display: flex;
|
|
162
163
|
align-items: center;
|
|
163
164
|
justify-content: center;
|
|
164
165
|
position: relative;
|
|
165
|
-
width: var(--
|
|
166
|
-
height: var(--
|
|
166
|
+
width: var(--_remove-button-size);
|
|
167
|
+
height: var(--_remove-button-size);
|
|
167
168
|
cursor: pointer;
|
|
168
169
|
padding: 0;
|
|
169
170
|
margin: 0;
|
|
170
|
-
margin-inline: calc((var(--
|
|
171
|
+
margin-inline: calc((var(--_remove-button-size) - var(--_icon-size)) * -0.5);
|
|
171
172
|
background: gray;
|
|
172
173
|
border: none;
|
|
173
|
-
border-radius: var(--u-chip-
|
|
174
|
+
border-radius: var(--u-chip-remove-button-border-radius, var(--u-shape-corner-full, 9999px));
|
|
174
175
|
background: none;
|
|
175
176
|
appearance: none;
|
|
176
177
|
outline: 0;
|
|
@@ -178,6 +179,8 @@ export const styles = css `
|
|
|
178
179
|
z-index: 1;
|
|
179
180
|
}
|
|
180
181
|
|
|
182
|
+
::slotted([slot=remove-icon]),
|
|
183
|
+
::slotted([slot=selected-icon]),
|
|
181
184
|
::slotted([slot=leading-icon]),
|
|
182
185
|
::slotted([slot=trailing-icon]) {
|
|
183
186
|
font-size: inherit !important;
|
|
@@ -187,32 +190,42 @@ export const styles = css `
|
|
|
187
190
|
display: none;
|
|
188
191
|
}
|
|
189
192
|
|
|
190
|
-
:host(:not([clickable])) .button {
|
|
193
|
+
:host(:not([clickable]):not([toggle])) .button {
|
|
191
194
|
cursor: auto;
|
|
192
195
|
}
|
|
193
196
|
|
|
194
|
-
:host([selected][
|
|
197
|
+
:host([selected]:not([hide-selected-icon])) .leading {
|
|
195
198
|
display: none;
|
|
196
199
|
}
|
|
197
|
-
:host([selected][
|
|
198
|
-
display:
|
|
200
|
+
:host([selected]:not([hide-selected-icon])) slot[name=selected-icon] {
|
|
201
|
+
display: contents;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.default-select-icon {
|
|
205
|
+
display: contents;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
:host([has-selected-icon]) .default-select-icon {
|
|
209
|
+
display: none;
|
|
199
210
|
}
|
|
200
211
|
|
|
201
212
|
:host([selected]:not([disabled])) {
|
|
202
213
|
background-color: var(--u-chip-selected-background-color, var(--u-color-secondary-container, rgb(232, 222, 248)));
|
|
203
214
|
}
|
|
204
215
|
:host([selected]:not([disabled])) .leading {
|
|
205
|
-
color: var(--u-chip-selected-leading-icon-color, var(--
|
|
216
|
+
color: var(--u-chip-selected-leading-icon-color, var(--_selected-icon-color));
|
|
206
217
|
}
|
|
207
218
|
:host([selected]:not([disabled])) .trailing {
|
|
208
|
-
color: var(--u-chip-selected-trailing-icon-color, var(--
|
|
219
|
+
color: var(--u-chip-selected-trailing-icon-color, var(--_selected-icon-color));
|
|
209
220
|
}
|
|
210
221
|
|
|
211
|
-
:host([has-leading-icon]) .container
|
|
222
|
+
:host([has-leading-icon]) .container,
|
|
223
|
+
:host([selected]:not([hide-selected-icon])) .container {
|
|
212
224
|
padding-inline-start: var(--_gap);
|
|
213
225
|
}
|
|
214
226
|
|
|
215
|
-
:host([has-trailing-icon]) .container
|
|
227
|
+
:host([has-trailing-icon]) .container,
|
|
228
|
+
:host([removable]) .container {
|
|
216
229
|
padding-inline-end: var(--_gap);
|
|
217
230
|
}
|
|
218
231
|
|
|
@@ -220,9 +233,17 @@ export const styles = css `
|
|
|
220
233
|
display: none;
|
|
221
234
|
}
|
|
222
235
|
|
|
223
|
-
:host(
|
|
224
|
-
:host(:not([
|
|
236
|
+
:host([hide-selected-icon]) .selected,
|
|
237
|
+
:host(:not([selected])) .selected {
|
|
238
|
+
display: none;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
:host(:not([has-trailing-icon])) .trailing {
|
|
225
242
|
display: none;
|
|
226
243
|
}
|
|
244
|
+
|
|
245
|
+
[part=default-selected-icon] {
|
|
246
|
+
display: contents;
|
|
247
|
+
}
|
|
227
248
|
`;
|
|
228
249
|
//# sourceMappingURL=chip.styles.js.map
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsPzB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css `\n :host,\n * {\n 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 box-sizing: border-box;\n outline: 0;\n }\n\n .focus-ring:focus-visible {\n --_color-primary: var(--u-color-primary, rgb(103, 80, 164));\n animation: u-focus-pulse 500ms ease;\n animation-fill-mode: forwards;\n outline-offset: 2px;\n }\n\n @keyframes u-focus-pulse {\n 0% {\n outline: 0 solid var(--_color-primary);\n }\n 50% {\n outline: 6px solid var(--_color-primary);\n }\n 100% {\n outline: 4px solid var(--_color-primary);\n }\n }\n :host {\n --_color-primary: var(--u-color-primary, rgb(103, 80, 164));\n -webkit-tap-highlight-color: transparent;\n --u-elevation-level: 0;\n position: relative;\n display: inline-block;\n 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 appearance: none !important;\n }\n\n :host([disabled]) {\n --u-elevation-level: 0 !important;\n 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;\n 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;\n }\n\n :host([disabled]) .button {\n cursor: default;\n }\n\n * {\n color: inherit;\n }\n\n u-elevation {\n z-index: -1;\n }\n\n .button {\n cursor: pointer;\n position: absolute;\n inset-inline-start: 0;\n inset-block-start: 0;\n width: 100%;\n height: 100%;\n font-family: inherit;\n border-radius: inherit;\n color: inherit;\n border: none;\n margin: 0;\n padding: 0;\n text-align: center;\n white-space: nowrap;\n background: transparent;\n user-select: none;\n text-decoration: none;\n outline: 0;\n z-index: 0;\n }\n\n .content {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n white-space: nowrap;\n border-radius: inherit;\n width: 100%;\n height: 100%;\n }\n\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"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CSSResultGroup } from '@lit/reactive-element/css-tag';
|
|
2
|
+
import { HTMLTemplateResult } from 'lit';
|
|
3
|
+
import { UmTextFieldBase } from '../shared/text-field-base/text-field-base.js';
|
|
4
|
+
export declare class UmChipField extends UmTextFieldBase {
|
|
5
|
+
#private;
|
|
6
|
+
static styles: CSSResultGroup;
|
|
7
|
+
input: HTMLInputElement;
|
|
8
|
+
name: string;
|
|
9
|
+
manual: boolean;
|
|
10
|
+
formatter: ((value: any) => string) | undefined;
|
|
11
|
+
leadingIconTemplate: ((value: any) => string) | undefined;
|
|
12
|
+
get value(): any[];
|
|
13
|
+
set value(value: any[]);
|
|
14
|
+
private setFormValue;
|
|
15
|
+
focus(): void;
|
|
16
|
+
get empty(): boolean;
|
|
17
|
+
protected renderContent(): HTMLTemplateResult;
|
|
18
|
+
add(value: any): void;
|
|
19
|
+
private getItemLabel;
|
|
20
|
+
}
|
|
21
|
+
declare global {
|
|
22
|
+
interface HTMLElementTagNameMap {
|
|
23
|
+
'u-chip-field': UmChipField;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=chip-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chip-field.d.ts","sourceRoot":"","sources":["../../src/chip-field/chip-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAQ,kBAAkB,EAAW,MAAM,KAAK,CAAC;AAMxD,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAE/E,qBACa,WAAY,SAAQ,eAAe;;IAC9C,OAAgB,MAAM,EAAE,cAAc,CAGpC;IAEc,KAAK,EAAG,gBAAgB,CAAC;IAC7B,IAAI,EAAG,MAAM,CAAC;IACC,MAAM,UAAS;IAE9B,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;IAC5D,mBAAmB,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;IAI1D,IAAI,KAAK,IAAI,GAAG,EAAE,CAEjB;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,EAGrB;IAED,OAAO,CAAC,YAAY;IAUX,KAAK;IAId,IACa,KAAK,IAAI,OAAO,CAE5B;cAEkB,aAAa,IAAI,kBAAkB;IAgDtD,GAAG,CAAC,KAAK,EAAE,GAAG;IAiBd,OAAO,CAAC,YAAY;CAKrB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,WAAW,CAAC;KAC7B;CACF"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
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_handleKeyDown, _UmChipField_removeChip, _UmChipField_updated;
|
|
19
|
+
import { html, nothing } from 'lit';
|
|
20
|
+
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
21
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
22
|
+
import { styles } from './chip-field.styles.js';
|
|
23
|
+
import { UmTextFieldBase } from '../shared/text-field-base/text-field-base.js';
|
|
24
|
+
let UmChipField = class UmChipField extends UmTextFieldBase {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
_UmChipField_instances.add(this);
|
|
28
|
+
this.manual = false;
|
|
29
|
+
_UmChipField_value.set(this, []);
|
|
30
|
+
_UmChipField_removeChip.set(this, (index) => () => {
|
|
31
|
+
this.value.splice(index, 1);
|
|
32
|
+
__classPrivateFieldGet(this, _UmChipField_instances, "m", _UmChipField_updated).call(this);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
get value() {
|
|
36
|
+
return __classPrivateFieldGet(this, _UmChipField_value, "f");
|
|
37
|
+
}
|
|
38
|
+
set value(value) {
|
|
39
|
+
__classPrivateFieldSet(this, _UmChipField_value, value, "f");
|
|
40
|
+
this.setFormValue();
|
|
41
|
+
}
|
|
42
|
+
setFormValue() {
|
|
43
|
+
const formData = new FormData();
|
|
44
|
+
for (const item of this.value) {
|
|
45
|
+
formData.append(this.name, this.getItemLabel(item));
|
|
46
|
+
}
|
|
47
|
+
this.elementInternals.setFormValue(formData);
|
|
48
|
+
}
|
|
49
|
+
focus() {
|
|
50
|
+
this.input.focus();
|
|
51
|
+
}
|
|
52
|
+
get empty() {
|
|
53
|
+
return !this.value?.length && !this.input?.value;
|
|
54
|
+
}
|
|
55
|
+
renderContent() {
|
|
56
|
+
return html `
|
|
57
|
+
${(__classPrivateFieldGet(this, _UmChipField_instances, "m", _UmChipField_getChips).call(this))}
|
|
58
|
+
<input
|
|
59
|
+
part="input"
|
|
60
|
+
id=${this.id || nothing}
|
|
61
|
+
aria-labelledby="label"
|
|
62
|
+
?disabled=${this.disabled}
|
|
63
|
+
placeholder=${this.placeholder || nothing}
|
|
64
|
+
@blur=${__classPrivateFieldGet(this, _UmChipField_instances, "m", _UmChipField_handleBlur)}
|
|
65
|
+
@keydown=${__classPrivateFieldGet(this, _UmChipField_instances, "m", _UmChipField_handleKeyDown)}/>`;
|
|
66
|
+
}
|
|
67
|
+
add(value) {
|
|
68
|
+
this.value.push(value);
|
|
69
|
+
__classPrivateFieldGet(this, _UmChipField_instances, "m", _UmChipField_updated).call(this);
|
|
70
|
+
}
|
|
71
|
+
getItemLabel(item) {
|
|
72
|
+
return this.formatter
|
|
73
|
+
? this.formatter(item)
|
|
74
|
+
: item.toString();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
_UmChipField_value = new WeakMap();
|
|
78
|
+
_UmChipField_removeChip = new WeakMap();
|
|
79
|
+
_UmChipField_instances = new WeakSet();
|
|
80
|
+
_UmChipField_getChips = function _UmChipField_getChips() {
|
|
81
|
+
return this.value
|
|
82
|
+
.map((item, index) => {
|
|
83
|
+
const leadingIcon = this.leadingIconTemplate
|
|
84
|
+
? html `<span slot="leading-icon">${unsafeHTML(this.leadingIconTemplate(item))}</span>`
|
|
85
|
+
: nothing;
|
|
86
|
+
return html `
|
|
87
|
+
<u-chip
|
|
88
|
+
removable
|
|
89
|
+
@remove=${__classPrivateFieldGet(this, _UmChipField_removeChip, "f").call(this, index)}>
|
|
90
|
+
${leadingIcon}
|
|
91
|
+
${this.getItemLabel(item)}
|
|
92
|
+
</u-chip>`;
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
_UmChipField_handleBlur = function _UmChipField_handleBlur() {
|
|
96
|
+
this.requestUpdate();
|
|
97
|
+
};
|
|
98
|
+
_UmChipField_handleKeyDown = function _UmChipField_handleKeyDown(e) {
|
|
99
|
+
if (!this.manual && e.key === 'Enter') {
|
|
100
|
+
this.add(this.input.value);
|
|
101
|
+
this.input.value = '';
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (e.key === 'Backspace' && this.input.selectionStart === 0 && this.input.selectionEnd === 0) {
|
|
105
|
+
__classPrivateFieldGet(this, _UmChipField_removeChip, "f").call(this, this.value.length - 1)();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
_UmChipField_updated = function _UmChipField_updated() {
|
|
110
|
+
this.setFormValue();
|
|
111
|
+
this.requestUpdate();
|
|
112
|
+
this.dispatchEvent(new Event('change', { bubbles: true }));
|
|
113
|
+
};
|
|
114
|
+
UmChipField.styles = [
|
|
115
|
+
UmTextFieldBase.styles,
|
|
116
|
+
styles
|
|
117
|
+
];
|
|
118
|
+
__decorate([
|
|
119
|
+
query('input')
|
|
120
|
+
], UmChipField.prototype, "input", void 0);
|
|
121
|
+
__decorate([
|
|
122
|
+
property()
|
|
123
|
+
], UmChipField.prototype, "name", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
property({ type: Boolean })
|
|
126
|
+
], UmChipField.prototype, "manual", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
property()
|
|
129
|
+
], UmChipField.prototype, "formatter", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
state()
|
|
132
|
+
], UmChipField.prototype, "empty", null);
|
|
133
|
+
UmChipField = __decorate([
|
|
134
|
+
customElement('u-chip-field')
|
|
135
|
+
], UmChipField);
|
|
136
|
+
export { UmChipField };
|
|
137
|
+
//# sourceMappingURL=chip-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\nimport { customElement, property, query, state } 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 @property() 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.setFormValue();\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 @state()\n override get empty(): boolean {\n return !this.value?.length && !this.input?.value;\n }\n\n protected override renderContent(): HTMLTemplateResult {\n\n return html`\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 }\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 #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.#updated();\n }\n\n #removeChip = (index: number) =>\n () => {\n this.value.splice(index, 1);\n this.#updated();\n }\n\n #updated() {\n this.setFormValue();\n this.requestUpdate();\n this.dispatchEvent(new Event('change', {bubbles: true}));\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chip-field.styles.d.ts","sourceRoot":"","sources":["../../src/chip-field/chip-field.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAiBlB,CAAC"}
|