@dreamworld/dw-chip-select 1.0.1 → 1.1.0-support-shimmer.1
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/demo/dw-chip-select-demo.js +14 -1
- package/dw-chip-select.js +14 -7
- package/dw-chip.js +17 -0
- package/package.json +1 -1
|
@@ -24,12 +24,25 @@ export class DwChipSelectDemo extends LitElement {
|
|
|
24
24
|
`,
|
|
25
25
|
];
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
static get properties() {
|
|
29
|
+
return {
|
|
30
|
+
paymentTypes: { type: Array}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
firstUpdated() {
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
this.paymentTypes = PaymentTypes
|
|
37
|
+
}, 1000)
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
render() {
|
|
28
41
|
return html`
|
|
29
42
|
<dw-chip-select
|
|
30
43
|
label="Filter"
|
|
31
44
|
.valueExpression=${"name"}
|
|
32
|
-
.items=${
|
|
45
|
+
.items=${this.paymentTypes}
|
|
33
46
|
.valueTextProvider=${(item) => item.label}
|
|
34
47
|
@change=${this._onChange}
|
|
35
48
|
></dw-chip-select>
|
package/dw-chip-select.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { css, html, LitElement, nothing } from "lit";
|
|
2
2
|
import { repeat } from "lit/directives/repeat.js";
|
|
3
3
|
|
|
4
|
+
// View Elements
|
|
5
|
+
import "./dw-chip.js";
|
|
6
|
+
|
|
4
7
|
// Styles
|
|
5
8
|
import * as TypographyLiterals from "@dreamworld/material-styles/typography-literals.js";
|
|
6
9
|
|
|
7
10
|
// Utils
|
|
8
|
-
import { ChipTypes, KeyCode } from "./utils";
|
|
9
|
-
import isEqual from "lodash-es/isEqual.js";
|
|
10
11
|
import cloneDeep from "lodash-es/cloneDeep.js";
|
|
12
|
+
import isEqual from "lodash-es/isEqual.js";
|
|
13
|
+
import { ChipTypes, KeyCode } from "./utils";
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
const shimmerData = Array(3).fill({});
|
|
13
16
|
|
|
14
17
|
export class DwChipSelect extends LitElement {
|
|
15
18
|
static get styles() {
|
|
@@ -131,7 +134,11 @@ export class DwChipSelect extends LitElement {
|
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
get _renderChipList() {
|
|
134
|
-
if (!this.items
|
|
137
|
+
if (!this.items) {
|
|
138
|
+
return html`<div class="chip-wrapper">${repeat(shimmerData, () => html`<dw-chip shimmer></dw-chip>`)}</div>`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (this.items.length === 0) {
|
|
135
142
|
return nothing;
|
|
136
143
|
}
|
|
137
144
|
|
|
@@ -156,7 +163,7 @@ export class DwChipSelect extends LitElement {
|
|
|
156
163
|
|
|
157
164
|
this.addEventListener("focusin", this._onFocusIn);
|
|
158
165
|
this.addEventListener("focusout", this._onFocusOut);
|
|
159
|
-
this.addEventListener(
|
|
166
|
+
this.addEventListener("mousedown", this._onMouseDown);
|
|
160
167
|
|
|
161
168
|
window.addEventListener("keydown", this._onKeyDown);
|
|
162
169
|
}
|
|
@@ -166,7 +173,7 @@ export class DwChipSelect extends LitElement {
|
|
|
166
173
|
|
|
167
174
|
this.removeEventListener("focusin", this._onFocusIn);
|
|
168
175
|
this.removeEventListener("focusout", this._onFocusOut);
|
|
169
|
-
this.removeEventListener(
|
|
176
|
+
this.removeEventListener("mousedown", this._onMouseDown);
|
|
170
177
|
|
|
171
178
|
window.removeEventListener("keydown", this._onKeyDown);
|
|
172
179
|
}
|
|
@@ -242,7 +249,7 @@ export class DwChipSelect extends LitElement {
|
|
|
242
249
|
}
|
|
243
250
|
|
|
244
251
|
_onFocusIn() {
|
|
245
|
-
this.mouseDowned ? this.mouseDowned = false : this._activatedIndex = 0;
|
|
252
|
+
this.mouseDowned ? (this.mouseDowned = false) : (this._activatedIndex = 0);
|
|
246
253
|
this.focused = true;
|
|
247
254
|
}
|
|
248
255
|
|
package/dw-chip.js
CHANGED
|
@@ -47,6 +47,14 @@ export class DwChip extends LitElement {
|
|
|
47
47
|
.show {
|
|
48
48
|
width: max-content;
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
.shimmer {
|
|
52
|
+
background: var(--dw-chip-select-shimmer-gradiant, linear-gradient(to right, #f1efef, #f9f8f8, #e7e5e5));
|
|
53
|
+
height: 20px;
|
|
54
|
+
width: 64px;
|
|
55
|
+
flex: 1;
|
|
56
|
+
border-radius: 4px;
|
|
57
|
+
}
|
|
50
58
|
`;
|
|
51
59
|
}
|
|
52
60
|
|
|
@@ -84,6 +92,12 @@ export class DwChip extends LitElement {
|
|
|
84
92
|
* Default: 'done'
|
|
85
93
|
*/
|
|
86
94
|
icon: { type: String },
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Input property
|
|
98
|
+
* Whether to show shimmer view or not
|
|
99
|
+
*/
|
|
100
|
+
shimmer: { type: Boolean },
|
|
87
101
|
};
|
|
88
102
|
}
|
|
89
103
|
|
|
@@ -94,6 +108,9 @@ export class DwChip extends LitElement {
|
|
|
94
108
|
}
|
|
95
109
|
|
|
96
110
|
render() {
|
|
111
|
+
if (this.shimmer) {
|
|
112
|
+
return html`<div class="shimmer"></div>`;
|
|
113
|
+
}
|
|
97
114
|
return html`
|
|
98
115
|
<dw-ripple
|
|
99
116
|
primary
|
package/package.json
CHANGED