@exmg/exm-chip-input 1.1.8 → 1.1.10-alpha.19
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/dist/exm-chip-input-dropdown.d.ts +1 -0
- package/dist/exm-chip-input-dropdown.js +38 -39
- package/dist/exm-chip-input.d.ts +2 -0
- package/dist/exm-chip-input.js +25 -7
- package/dist/styles/exm-chip-input-css.js +4 -5
- package/dist/styles/exm-chip-input-dropdown-css.js +3 -13
- package/dist/styles/exm-chips-shared-css.d.ts +1 -0
- package/dist/styles/exm-chips-shared-css.js +77 -0
- package/package.json +5 -8
|
@@ -7,10 +7,12 @@ import '@material/web/icon/icon.js';
|
|
|
7
7
|
import '@material/web/menu/menu.js';
|
|
8
8
|
import './dropdown/dropdown-container.js';
|
|
9
9
|
import { ChipSet } from '@material/web/chips/internal/chip-set.js';
|
|
10
|
-
import { html } from 'lit';
|
|
10
|
+
import { html, nothing } from 'lit';
|
|
11
11
|
import { property, state } from 'lit/decorators.js';
|
|
12
12
|
import { repeat } from 'lit/directives/repeat.js';
|
|
13
13
|
import { style } from './styles/exm-chip-input-dropdown-css.js';
|
|
14
|
+
import { sharedChipStyle } from './styles/exm-chips-shared-css.js';
|
|
15
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
14
16
|
/**
|
|
15
17
|
*
|
|
16
18
|
* @final
|
|
@@ -22,6 +24,7 @@ let ExmChipInputDropdown = class ExmChipInputDropdown extends ChipSet {
|
|
|
22
24
|
this.label = '';
|
|
23
25
|
this.dropdownTitle = 'Select items';
|
|
24
26
|
this.btnAddText = 'Add items';
|
|
27
|
+
this.supportingText = '';
|
|
25
28
|
this.menuOpen = false;
|
|
26
29
|
// Add event listeners in the constructor
|
|
27
30
|
this.addEventListener('click', this._onSelect);
|
|
@@ -60,47 +63,40 @@ let ExmChipInputDropdown = class ExmChipInputDropdown extends ChipSet {
|
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
render() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
66
|
+
const containerClasses = { 'has-label': !!this.label };
|
|
67
|
+
const labelClasses = { 'not-empty': (this.selectedChips || []).length > 0, 'has-focus': this.menuOpen };
|
|
68
|
+
return html `
|
|
69
|
+
<div class="container ${classMap(containerClasses)}">
|
|
70
|
+
<div class="background"></div>
|
|
71
|
+
<div class="label ${classMap(labelClasses)}">${this.label}</div>
|
|
72
|
+
<div class="input-container" id="input-container" @click="${this.onOpenClick}">
|
|
73
|
+
<div class="selected-chips">
|
|
74
|
+
${repeat(this.selectedChips || [], (chip) => chip.value, (chip) => html `<md-input-chip
|
|
75
|
+
label="${chip.label}"
|
|
76
|
+
data-value=${chip.value}
|
|
77
|
+
selected
|
|
78
|
+
@remove=${() => this._removeSelected(chip.value)}
|
|
79
|
+
></md-input-chip>`)}
|
|
80
|
+
</div>
|
|
81
|
+
<md-menu
|
|
82
|
+
anchor="input-container"
|
|
83
|
+
menu-corner="start-start"
|
|
84
|
+
anchor-corner="end-start"
|
|
85
|
+
default-focus="none"
|
|
86
|
+
role="dialog"
|
|
79
87
|
aria-label="${this.dropdownTitle} controls"
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
.open=${this.menuOpen}
|
|
89
|
+
@closed=${this.onMenuClosed}
|
|
90
|
+
@keydown=${this.onKeydown}
|
|
82
91
|
>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
<dropdown-container .dropdownTitle=${this.dropdownTitle}
|
|
93
|
+
><slot @slotchange=${this.updateTabIndicesOverride}></slot
|
|
94
|
+
></dropdown-container>
|
|
95
|
+
</md-menu>
|
|
86
96
|
</div>
|
|
87
|
-
|
|
88
|
-
anchor="button"
|
|
89
|
-
menu-corner="start-start"
|
|
90
|
-
anchor-corner="end-start"
|
|
91
|
-
default-focus="none"
|
|
92
|
-
role="dialog"
|
|
93
|
-
aria-label="${this.dropdownTitle} controls"
|
|
94
|
-
.open=${this.menuOpen}
|
|
95
|
-
@closed=${this.onMenuClosed}
|
|
96
|
-
@keydown=${this.onKeydown}
|
|
97
|
-
>
|
|
98
|
-
<dropdown-container .dropdownTitle=${this.dropdownTitle}
|
|
99
|
-
><slot @slotchange=${this.updateTabIndicesOverride}></slot
|
|
100
|
-
></dropdown-container>
|
|
101
|
-
</md-menu>
|
|
97
|
+
${this.supportingText ? html `<div class="supporting-text">${this.supportingText}</div>` : nothing}
|
|
102
98
|
</div>
|
|
103
|
-
|
|
99
|
+
`;
|
|
104
100
|
}
|
|
105
101
|
updateTabIndicesOverride() {
|
|
106
102
|
// The chip that should be focusable is either the chip that currently has
|
|
@@ -131,7 +127,7 @@ let ExmChipInputDropdown = class ExmChipInputDropdown extends ChipSet {
|
|
|
131
127
|
}
|
|
132
128
|
}
|
|
133
129
|
};
|
|
134
|
-
ExmChipInputDropdown.styles = [style];
|
|
130
|
+
ExmChipInputDropdown.styles = [sharedChipStyle, style];
|
|
135
131
|
__decorate([
|
|
136
132
|
property({ type: String })
|
|
137
133
|
], ExmChipInputDropdown.prototype, "label", void 0);
|
|
@@ -144,6 +140,9 @@ __decorate([
|
|
|
144
140
|
__decorate([
|
|
145
141
|
property({ type: Array })
|
|
146
142
|
], ExmChipInputDropdown.prototype, "selectedChips", void 0);
|
|
143
|
+
__decorate([
|
|
144
|
+
property({ type: String, attribute: 'supporting-text' })
|
|
145
|
+
], ExmChipInputDropdown.prototype, "supportingText", void 0);
|
|
147
146
|
__decorate([
|
|
148
147
|
state()
|
|
149
148
|
], ExmChipInputDropdown.prototype, "menuOpen", void 0);
|
package/dist/exm-chip-input.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ declare global {
|
|
|
11
11
|
*/
|
|
12
12
|
export declare class ExmChipInput extends ChipSet {
|
|
13
13
|
label: string;
|
|
14
|
+
supportingText: string;
|
|
15
|
+
chipCount: number;
|
|
14
16
|
static styles: import("lit").CSSResult[];
|
|
15
17
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
16
18
|
private updateTabIndicesOverride;
|
package/dist/exm-chip-input.js
CHANGED
|
@@ -3,8 +3,10 @@ import { customElement } from 'lit/decorators/custom-element.js';
|
|
|
3
3
|
import { style } from './styles/exm-chip-input-css.js';
|
|
4
4
|
import { ChipSet } from '@material/web/chips/internal/chip-set.js';
|
|
5
5
|
import { styles } from '@material/web/chips/internal/chip-set-styles.js';
|
|
6
|
-
import { html } from 'lit';
|
|
7
|
-
import { property } from 'lit/decorators.js';
|
|
6
|
+
import { html, nothing } from 'lit';
|
|
7
|
+
import { property, state } from 'lit/decorators.js';
|
|
8
|
+
import { sharedChipStyle } from './styles/exm-chips-shared-css.js';
|
|
9
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
8
10
|
/**
|
|
9
11
|
*
|
|
10
12
|
* @final
|
|
@@ -14,17 +16,27 @@ let ExmChipInput = class ExmChipInput extends ChipSet {
|
|
|
14
16
|
constructor() {
|
|
15
17
|
super(...arguments);
|
|
16
18
|
this.label = '';
|
|
19
|
+
this.supportingText = '';
|
|
20
|
+
this.chipCount = 0;
|
|
17
21
|
}
|
|
18
22
|
render() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
const containerClasses = { 'has-label': !!this.label };
|
|
24
|
+
const labelClasses = { 'not-empty': this.chipCount > 0 };
|
|
25
|
+
return html `
|
|
26
|
+
<div class="container ${classMap(containerClasses)}">
|
|
27
|
+
<div class="background"></div>
|
|
28
|
+
<div class="state-layer"></div>
|
|
29
|
+
<div class="label ${classMap(labelClasses)}">${this.label}</div>
|
|
30
|
+
<div class="items"><slot @slotchange=${this.updateTabIndicesOverride}></slot></div>
|
|
31
|
+
${this.supportingText ? html `<div class="supporting-text">${this.supportingText}</div>` : nothing}
|
|
32
|
+
</div>
|
|
33
|
+
`;
|
|
23
34
|
}
|
|
24
35
|
updateTabIndicesOverride() {
|
|
25
36
|
// The chip that should be focusable is either the chip that currently has
|
|
26
37
|
// focus or the first chip that can be focused.
|
|
27
38
|
const { chips } = this;
|
|
39
|
+
this.chipCount = chips.length;
|
|
28
40
|
let chipToFocus;
|
|
29
41
|
for (const chip of chips) {
|
|
30
42
|
const isChipFocusable = chip.alwaysFocusable || !chip.disabled;
|
|
@@ -47,10 +59,16 @@ let ExmChipInput = class ExmChipInput extends ChipSet {
|
|
|
47
59
|
}
|
|
48
60
|
}
|
|
49
61
|
};
|
|
50
|
-
ExmChipInput.styles = [styles, style];
|
|
62
|
+
ExmChipInput.styles = [styles, sharedChipStyle, style];
|
|
51
63
|
__decorate([
|
|
52
64
|
property({ type: String })
|
|
53
65
|
], ExmChipInput.prototype, "label", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
property({ type: String, attribute: 'supporting-text' })
|
|
68
|
+
], ExmChipInput.prototype, "supportingText", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
state()
|
|
71
|
+
], ExmChipInput.prototype, "chipCount", void 0);
|
|
54
72
|
ExmChipInput = __decorate([
|
|
55
73
|
customElement('exm-chip-input')
|
|
56
74
|
], ExmChipInput);
|
|
@@ -4,14 +4,13 @@ export const style = css `
|
|
|
4
4
|
display: block;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
.
|
|
8
|
-
|
|
9
|
-
font-size: 1rem;
|
|
10
|
-
font-weight: 500;
|
|
11
|
-
margin-bottom: 0.5rem;
|
|
7
|
+
.container {
|
|
8
|
+
overflow: hidden;
|
|
12
9
|
}
|
|
13
10
|
|
|
14
11
|
.items {
|
|
12
|
+
grid-area: 2/1/3/2;
|
|
13
|
+
padding: 16px;
|
|
15
14
|
display: flex;
|
|
16
15
|
flex-wrap: wrap;
|
|
17
16
|
gap: 0.3rem;
|
|
@@ -4,21 +4,11 @@ export const style = css `
|
|
|
4
4
|
display: block;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
.label {
|
|
8
|
-
display: block;
|
|
9
|
-
font-size: 1rem;
|
|
10
|
-
font-weight: 500;
|
|
11
|
-
margin-bottom: 0.5rem;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.add {
|
|
15
|
-
display: flex;
|
|
16
|
-
align-items: center;
|
|
17
|
-
margin-top: 0.5rem;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
7
|
.input-container {
|
|
8
|
+
grid-area: 2/1/3/2;
|
|
21
9
|
position: relative;
|
|
10
|
+
min-height: 32px;
|
|
11
|
+
padding: 16px;
|
|
22
12
|
}
|
|
23
13
|
|
|
24
14
|
.selected-chips {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sharedChipStyle: import("lit").CSSResult;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const sharedChipStyle = css `
|
|
3
|
+
.container {
|
|
4
|
+
display: grid;
|
|
5
|
+
grid-template-rows: 0px auto auto;
|
|
6
|
+
border-top-right-radius: 4px;
|
|
7
|
+
border-top-left-radius: 4px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.container.has-label {
|
|
11
|
+
grid-template-rows: 2rem auto auto;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.background {
|
|
15
|
+
grid-area: 1/1/3/2;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.background {
|
|
19
|
+
background-color: var(--editor-code-background-color, var(--md-sys-color-surface-container-highest));
|
|
20
|
+
border-bottom: 1px solid var(--editor-border-color-focus, var(--md-sys-color-primary));
|
|
21
|
+
border-top-right-radius: inherit;
|
|
22
|
+
border-top-left-radius: inherit;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.container:hover .state-layer {
|
|
26
|
+
background-color: var(--editor-code-background-focus-color, var(--md-sys-color-on-surface-variant));
|
|
27
|
+
border-top-right-radius: inherit;
|
|
28
|
+
border-top-left-radius: inherit;
|
|
29
|
+
opacity: 0.08;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.label {
|
|
33
|
+
grid-area: 1/1/2/2;
|
|
34
|
+
font-size: 1rem;
|
|
35
|
+
padding: 0.5rem 0 0 1rem;
|
|
36
|
+
transition: all 200ms ease;
|
|
37
|
+
transform: scale(1) translateY(0px);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.label.has-focus {
|
|
41
|
+
color: var(--editor-label-focus-color, var(--md-sys-color-primary));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.label.has-focus,
|
|
45
|
+
.label.not-empty {
|
|
46
|
+
padding: 0.5rem 0 0 1rem;
|
|
47
|
+
font-size: 0.7rem;
|
|
48
|
+
transition: all 200ms ease;
|
|
49
|
+
transform: scale(1) translateY(0px);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.supporting-text {
|
|
53
|
+
grid-area: 3/1/4/2;
|
|
54
|
+
|
|
55
|
+
color: var(--md-filled-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));
|
|
56
|
+
display: flex;
|
|
57
|
+
font-family: var(
|
|
58
|
+
--md-filled-field-supporting-text-font,
|
|
59
|
+
var(--md-sys-typescale-body-small-font, var(--md-ref-typeface-plain, Roboto))
|
|
60
|
+
);
|
|
61
|
+
font-size: var(--md-filled-field-supporting-text-size, var(--md-sys-typescale-body-small-size, 0.75rem));
|
|
62
|
+
line-height: var(
|
|
63
|
+
--md-filled-field-supporting-text-line-height,
|
|
64
|
+
var(--md-sys-typescale-body-small-line-height, 1rem)
|
|
65
|
+
);
|
|
66
|
+
font-weight: var(
|
|
67
|
+
--md-filled-field-supporting-text-weight,
|
|
68
|
+
var(--md-sys-typescale-body-small-weight, var(--md-ref-typeface-weight-regular, 400))
|
|
69
|
+
);
|
|
70
|
+
gap: 16px;
|
|
71
|
+
justify-content: space-between;
|
|
72
|
+
padding-inline-start: var(--md-filled-field-supporting-text-leading-space, 16px);
|
|
73
|
+
padding-inline-end: var(--md-filled-field-supporting-text-trailing-space, 16px);
|
|
74
|
+
padding-top: var(--md-filled-field-supporting-text-top-space, 4px);
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
//# sourceMappingURL=exm-chips-shared-css.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exmg/exm-chip-input",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10-alpha.19+20be399",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,15 +11,12 @@
|
|
|
11
11
|
"./exm-chip-input-dropdown.js": "./dist/exm-chip-input-dropdown.js",
|
|
12
12
|
"./exm-chip.js": "./dist/exm-chip.js"
|
|
13
13
|
},
|
|
14
|
-
"
|
|
15
|
-
"@exmg/lit-base": "^3.0.
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@exmg/lit-base": "^3.0.3",
|
|
16
16
|
"@material/web": "^2.2.0",
|
|
17
|
-
"lit": "^3.
|
|
17
|
+
"lit": "^3.2.1",
|
|
18
18
|
"tslib": "^2.6.2"
|
|
19
19
|
},
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"@exmg/lit-cli": "1.1.13"
|
|
22
|
-
},
|
|
23
20
|
"keywords": [
|
|
24
21
|
"web-components",
|
|
25
22
|
"lit",
|
|
@@ -42,5 +39,5 @@
|
|
|
42
39
|
"publishConfig": {
|
|
43
40
|
"access": "public"
|
|
44
41
|
},
|
|
45
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "20be399892ecc54f71f080f17a677a370d9f2b9c"
|
|
46
43
|
}
|