@universal-material/web 3.0.38 → 3.0.40
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 +11 -4
- package/chip/chip.d.ts.map +1 -1
- package/chip/chip.js +83 -39
- package/chip/chip.js.map +1 -1
- package/chip/chip.styles.d.ts.map +1 -1
- package/chip/chip.styles.js +45 -20
- package/chip/chip.styles.js.map +1 -1
- package/chip-field/chip-field.d.ts +25 -0
- package/chip-field/chip-field.d.ts.map +1 -0
- package/chip-field/chip-field.js +133 -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 +2639 -1671
- 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 -0
- package/shared/button-wrapper.d.ts.map +1 -1
- package/shared/button-wrapper.js +7 -3
- 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
|
@@ -10,6 +10,8 @@ export declare class UmChip extends UmButtonWrapper {
|
|
|
10
10
|
* Whether the chip is selected or not
|
|
11
11
|
*/
|
|
12
12
|
selected: boolean;
|
|
13
|
+
get clickable(): boolean;
|
|
14
|
+
set clickable(value: boolean);
|
|
13
15
|
/**
|
|
14
16
|
* Adds elevation to the chip
|
|
15
17
|
*/
|
|
@@ -18,11 +20,16 @@ export declare class UmChip extends UmButtonWrapper {
|
|
|
18
20
|
* When true, the chip will toggle between selected and unselected
|
|
19
21
|
* states
|
|
20
22
|
*/
|
|
21
|
-
toggle: boolean;
|
|
23
|
+
get toggle(): boolean;
|
|
24
|
+
set toggle(value: boolean);
|
|
22
25
|
/**
|
|
23
|
-
*
|
|
26
|
+
* Add the remove icon
|
|
24
27
|
*/
|
|
25
|
-
|
|
28
|
+
removable: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Hide the selected icon
|
|
31
|
+
*/
|
|
32
|
+
hideSelectedIcon: boolean;
|
|
26
33
|
/**
|
|
27
34
|
* Whether the chip has a leading icon or not
|
|
28
35
|
*
|
|
@@ -44,7 +51,7 @@ export declare class UmChip extends UmButtonWrapper {
|
|
|
44
51
|
private readonly assignedLeadingIcons;
|
|
45
52
|
private readonly assignedSelectedIcons;
|
|
46
53
|
private readonly assignedTrailingIcons;
|
|
47
|
-
|
|
54
|
+
removeRipple: UmRipple;
|
|
48
55
|
protected handleClick(event: UIEvent): void;
|
|
49
56
|
protected renderContent(): HTMLTemplateResult;
|
|
50
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
|
@@ -9,8 +9,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
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
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
|
|
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
|
+
import { html, nothing } from 'lit';
|
|
14
20
|
import { customElement, property, query, queryAssignedElements } from 'lit/decorators.js';
|
|
15
21
|
import { styles as baseStyles } from '../shared/base.styles.js';
|
|
16
22
|
import { styles } from './chip.styles.js';
|
|
@@ -21,6 +27,8 @@ let UmChip = class UmChip extends UmButtonWrapper {
|
|
|
21
27
|
constructor() {
|
|
22
28
|
super(...arguments);
|
|
23
29
|
_UmChip_instances.add(this);
|
|
30
|
+
_UmChip_clickable.set(this, false);
|
|
31
|
+
_UmChip_toggle.set(this, false);
|
|
24
32
|
/**
|
|
25
33
|
* Whether the chip is selected or not
|
|
26
34
|
*/
|
|
@@ -30,14 +38,13 @@ let UmChip = class UmChip extends UmButtonWrapper {
|
|
|
30
38
|
*/
|
|
31
39
|
this.elevated = false;
|
|
32
40
|
/**
|
|
33
|
-
*
|
|
34
|
-
* states
|
|
41
|
+
* Add the remove icon
|
|
35
42
|
*/
|
|
36
|
-
this.
|
|
43
|
+
this.removable = false;
|
|
37
44
|
/**
|
|
38
|
-
*
|
|
45
|
+
* Hide the selected icon
|
|
39
46
|
*/
|
|
40
|
-
this.
|
|
47
|
+
this.hideSelectedIcon = false;
|
|
41
48
|
/**
|
|
42
49
|
* Whether the chip has a leading icon or not
|
|
43
50
|
*
|
|
@@ -57,6 +64,24 @@ let UmChip = class UmChip extends UmButtonWrapper {
|
|
|
57
64
|
*/
|
|
58
65
|
this.hasTrailingIcon = false;
|
|
59
66
|
}
|
|
67
|
+
get clickable() {
|
|
68
|
+
return __classPrivateFieldGet(this, _UmChip_clickable, "f");
|
|
69
|
+
}
|
|
70
|
+
set clickable(value) {
|
|
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");
|
|
84
|
+
}
|
|
60
85
|
handleClick(event) {
|
|
61
86
|
super.handleClick(event);
|
|
62
87
|
if (!this.toggle) {
|
|
@@ -66,46 +91,59 @@ let UmChip = class UmChip extends UmButtonWrapper {
|
|
|
66
91
|
this.dispatchEvent(new Event('change', { bubbles: true }));
|
|
67
92
|
}
|
|
68
93
|
renderContent() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
@
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
</button>`;
|
|
81
|
-
}
|
|
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>`;
|
|
82
105
|
return html `
|
|
83
106
|
<div class="container">
|
|
84
107
|
<div class="outline"></div>
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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>
|
|
95
123
|
<div class="label">
|
|
96
|
-
|
|
124
|
+
<slot></slot>
|
|
97
125
|
</div>
|
|
98
|
-
|
|
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}
|
|
99
131
|
</div>`;
|
|
100
132
|
}
|
|
101
133
|
};
|
|
134
|
+
_UmChip_clickable = new WeakMap();
|
|
135
|
+
_UmChip_toggle = new WeakMap();
|
|
102
136
|
_UmChip_instances = new WeakSet();
|
|
103
|
-
|
|
137
|
+
_UmChip_handleRemoveClick = function _UmChip_handleRemoveClick(e) {
|
|
104
138
|
e.stopPropagation();
|
|
105
139
|
if (!e.pointerType) {
|
|
106
|
-
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();
|
|
107
146
|
}
|
|
108
|
-
this.dispatchEvent(new Event('action'));
|
|
109
147
|
};
|
|
110
148
|
_UmChip_handleTrailingIconSlotChange = function _UmChip_handleTrailingIconSlotChange() {
|
|
111
149
|
this.hasTrailingIcon = this.assignedTrailingIcons.length > 0;
|
|
@@ -123,15 +161,21 @@ UmChip.styles = [
|
|
|
123
161
|
__decorate([
|
|
124
162
|
property({ type: Boolean, reflect: true })
|
|
125
163
|
], UmChip.prototype, "selected", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
property({ type: Boolean, reflect: true })
|
|
166
|
+
], UmChip.prototype, "clickable", null);
|
|
126
167
|
__decorate([
|
|
127
168
|
property({ type: Boolean, reflect: true })
|
|
128
169
|
], UmChip.prototype, "elevated", void 0);
|
|
129
170
|
__decorate([
|
|
130
171
|
property({ type: Boolean, reflect: true })
|
|
131
|
-
], UmChip.prototype, "toggle",
|
|
172
|
+
], UmChip.prototype, "toggle", null);
|
|
132
173
|
__decorate([
|
|
133
174
|
property({ type: Boolean, reflect: true })
|
|
134
|
-
], 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);
|
|
135
179
|
__decorate([
|
|
136
180
|
property({ type: Boolean, attribute: 'has-leading-icon', reflect: true })
|
|
137
181
|
], UmChip.prototype, "hasLeadingIcon", void 0);
|
|
@@ -151,8 +195,8 @@ __decorate([
|
|
|
151
195
|
queryAssignedElements({ slot: 'trailing-icon', flatten: true })
|
|
152
196
|
], UmChip.prototype, "assignedTrailingIcons", void 0);
|
|
153
197
|
__decorate([
|
|
154
|
-
query('#
|
|
155
|
-
], UmChip.prototype, "
|
|
198
|
+
query('#remove-ripple')
|
|
199
|
+
], UmChip.prototype, "removeRipple", void 0);
|
|
156
200
|
UmChip = __decorate([
|
|
157
201
|
customElement('u-chip')
|
|
158
202
|
], UmChip);
|
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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rC;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,28 +190,42 @@ export const styles = css `
|
|
|
187
190
|
display: none;
|
|
188
191
|
}
|
|
189
192
|
|
|
190
|
-
:host([
|
|
193
|
+
:host(:not([clickable]):not([toggle])) .button {
|
|
194
|
+
cursor: auto;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
:host([selected]:not([hide-selected-icon])) .leading {
|
|
191
198
|
display: none;
|
|
192
199
|
}
|
|
193
|
-
:host([selected][
|
|
194
|
-
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;
|
|
195
210
|
}
|
|
196
211
|
|
|
197
212
|
:host([selected]:not([disabled])) {
|
|
198
213
|
background-color: var(--u-chip-selected-background-color, var(--u-color-secondary-container, rgb(232, 222, 248)));
|
|
199
214
|
}
|
|
200
215
|
:host([selected]:not([disabled])) .leading {
|
|
201
|
-
color: var(--u-chip-selected-leading-icon-color, var(--
|
|
216
|
+
color: var(--u-chip-selected-leading-icon-color, var(--_selected-icon-color));
|
|
202
217
|
}
|
|
203
218
|
:host([selected]:not([disabled])) .trailing {
|
|
204
|
-
color: var(--u-chip-selected-trailing-icon-color, var(--
|
|
219
|
+
color: var(--u-chip-selected-trailing-icon-color, var(--_selected-icon-color));
|
|
205
220
|
}
|
|
206
221
|
|
|
207
|
-
:host([has-leading-icon]) .container
|
|
222
|
+
:host([has-leading-icon]) .container,
|
|
223
|
+
:host([selected]:not([hide-selected-icon])) .container {
|
|
208
224
|
padding-inline-start: var(--_gap);
|
|
209
225
|
}
|
|
210
226
|
|
|
211
|
-
:host([has-trailing-icon]) .container
|
|
227
|
+
:host([has-trailing-icon]) .container,
|
|
228
|
+
:host([removable]) .container {
|
|
212
229
|
padding-inline-end: var(--_gap);
|
|
213
230
|
}
|
|
214
231
|
|
|
@@ -216,9 +233,17 @@ export const styles = css `
|
|
|
216
233
|
display: none;
|
|
217
234
|
}
|
|
218
235
|
|
|
219
|
-
:host(
|
|
220
|
-
:host(:not([
|
|
236
|
+
:host([hide-selected-icon]) .selected,
|
|
237
|
+
:host(:not([selected])) .selected {
|
|
221
238
|
display: none;
|
|
222
239
|
}
|
|
240
|
+
|
|
241
|
+
:host(:not([has-trailing-icon])) .trailing {
|
|
242
|
+
display: none;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
[part=default-selected-icon] {
|
|
246
|
+
display: contents;
|
|
247
|
+
}
|
|
223
248
|
`;
|
|
224
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,25 @@
|
|
|
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
|
+
formatter: ((value: any) => string) | undefined;
|
|
10
|
+
leadingIconTemplate: ((value: any) => string) | undefined;
|
|
11
|
+
get value(): any[];
|
|
12
|
+
set value(value: any[]);
|
|
13
|
+
private setFormValue;
|
|
14
|
+
focus(): void;
|
|
15
|
+
get empty(): boolean;
|
|
16
|
+
protected renderContent(): HTMLTemplateResult;
|
|
17
|
+
add(value: any): void;
|
|
18
|
+
private getItemLabel;
|
|
19
|
+
}
|
|
20
|
+
declare global {
|
|
21
|
+
interface HTMLElementTagNameMap {
|
|
22
|
+
'u-chip-field': UmChipField;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# 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;IAEd,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,133 @@
|
|
|
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_emit;
|
|
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
|
+
_UmChipField_value.set(this, []);
|
|
29
|
+
_UmChipField_removeChip.set(this, (index) => () => {
|
|
30
|
+
this.value.splice(index, 1);
|
|
31
|
+
__classPrivateFieldGet(this, _UmChipField_instances, "m", _UmChipField_emit).call(this);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
get value() {
|
|
35
|
+
return __classPrivateFieldGet(this, _UmChipField_value, "f");
|
|
36
|
+
}
|
|
37
|
+
set value(value) {
|
|
38
|
+
__classPrivateFieldSet(this, _UmChipField_value, value, "f");
|
|
39
|
+
this.setFormValue();
|
|
40
|
+
}
|
|
41
|
+
setFormValue() {
|
|
42
|
+
const formData = new FormData();
|
|
43
|
+
for (const item of this.value) {
|
|
44
|
+
formData.append(this.name, this.getItemLabel(item));
|
|
45
|
+
}
|
|
46
|
+
this.elementInternals.setFormValue(formData);
|
|
47
|
+
}
|
|
48
|
+
focus() {
|
|
49
|
+
this.input.focus();
|
|
50
|
+
}
|
|
51
|
+
get empty() {
|
|
52
|
+
return !this.value?.length && !this.input?.value;
|
|
53
|
+
}
|
|
54
|
+
renderContent() {
|
|
55
|
+
return html `
|
|
56
|
+
${(__classPrivateFieldGet(this, _UmChipField_instances, "m", _UmChipField_getChips).call(this))}
|
|
57
|
+
<input
|
|
58
|
+
part="input"
|
|
59
|
+
id=${this.id || nothing}
|
|
60
|
+
aria-labelledby="label"
|
|
61
|
+
?disabled=${this.disabled}
|
|
62
|
+
placeholder=${this.placeholder || nothing}
|
|
63
|
+
@blur=${__classPrivateFieldGet(this, _UmChipField_instances, "m", _UmChipField_handleBlur)}
|
|
64
|
+
@keydown=${__classPrivateFieldGet(this, _UmChipField_instances, "m", _UmChipField_handleKeyDown)}/>`;
|
|
65
|
+
}
|
|
66
|
+
add(value) {
|
|
67
|
+
this.value.push(value);
|
|
68
|
+
__classPrivateFieldGet(this, _UmChipField_instances, "m", _UmChipField_emit).call(this);
|
|
69
|
+
this.requestUpdate();
|
|
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 (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_emit = function _UmChipField_emit() {
|
|
110
|
+
this.setFormValue();
|
|
111
|
+
this.dispatchEvent(new Event('change', { bubbles: true }));
|
|
112
|
+
};
|
|
113
|
+
UmChipField.styles = [
|
|
114
|
+
UmTextFieldBase.styles,
|
|
115
|
+
styles
|
|
116
|
+
];
|
|
117
|
+
__decorate([
|
|
118
|
+
query('input')
|
|
119
|
+
], UmChipField.prototype, "input", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
property()
|
|
122
|
+
], UmChipField.prototype, "name", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
property()
|
|
125
|
+
], UmChipField.prototype, "formatter", void 0);
|
|
126
|
+
__decorate([
|
|
127
|
+
state()
|
|
128
|
+
], UmChipField.prototype, "empty", null);
|
|
129
|
+
UmChipField = __decorate([
|
|
130
|
+
customElement('u-chip-field')
|
|
131
|
+
], UmChipField);
|
|
132
|
+
export { UmChipField };
|
|
133
|
+
//# sourceMappingURL=chip-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAGxE,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,eAAe;IAAzC;;;QAYL,6BAAgB,EAAE,EAAC;QAmFnB,kCAAc,CAAC,KAAa,EAAE,EAAE,CAC9B,GAAG,EAAE;YACH,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC5B,uBAAA,IAAI,iDAAM,MAAV,IAAI,CAAQ,CAAC;QACf,CAAC,EAAA;IAYL,CAAC;IAjGC,IAAI,KAAK;QACP,OAAO,uBA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AC3D,CAAC;AAvGe,kBAAM,GAAmB;IACvC,eAAe,CAAC,MAAM;IACtB,MAAM;CACP,AAHqB,CAGpB;AAEc;IAAf,KAAK,CAAC,OAAO,CAAC;0CAA0B;AAC7B;IAAX,QAAQ,EAAE;yCAAe;AAEd;IAAX,QAAQ,EAAE;8CAAiD;AA4B5D;IADC,KAAK,EAAE;wCAGP;AAvCU,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA+GvB","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, 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\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 (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.#emit();\n this.requestUpdate();\n }\n\n #removeChip = (index: number) =>\n () => {\n this.value.splice(index, 1);\n this.#emit();\n }\n\n #emit() {\n this.setFormValue();\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"]}
|