igniteui-webcomponents 3.3.0 → 3.4.0
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/CHANGELOG.md +24 -0
- package/README.md +7 -2
- package/components/accordion/accordion.js +3 -1
- package/components/accordion/accordion.js.map +1 -1
- package/components/button/button-base.js +7 -2
- package/components/button/button-base.js.map +1 -1
- package/components/button/themes/button/light/button.base.css.js +1 -1
- package/components/button/themes/button/light/button.base.css.js.map +1 -1
- package/components/button/themes/button/light/button.material.css.js +1 -1
- package/components/button/themes/button/light/button.material.css.js.map +1 -1
- package/components/calendar/common/calendar-base.js +3 -1
- package/components/calendar/common/calendar-base.js.map +1 -1
- package/components/calendar/days-view/days-view.d.ts +2 -0
- package/components/calendar/days-view/days-view.js +17 -5
- package/components/calendar/days-view/days-view.js.map +1 -1
- package/components/checkbox/checkbox-base.js +7 -2
- package/components/checkbox/checkbox-base.js.map +1 -1
- package/components/chip/chip.d.ts +1 -0
- package/components/chip/chip.js +9 -0
- package/components/chip/chip.js.map +1 -1
- package/components/common/decorators/blazorDeepImport.d.ts +4 -0
- package/components/common/decorators/blazorDeepImport.js +2 -0
- package/components/common/decorators/blazorDeepImport.js.map +1 -0
- package/components/common/util.d.ts +1 -0
- package/components/common/util.js +3 -0
- package/components/common/util.js.map +1 -1
- package/components/dialog/dialog.d.ts +69 -0
- package/components/dialog/dialog.js +168 -0
- package/components/dialog/dialog.js.map +1 -0
- package/components/dialog/themes/light/dialog.base.css.d.ts +1 -0
- package/components/dialog/themes/light/dialog.base.css.js +3 -0
- package/components/dialog/themes/light/dialog.base.css.js.map +1 -0
- package/components/dialog/themes/light/dialog.bootstrap.css.d.ts +1 -0
- package/components/dialog/themes/light/dialog.bootstrap.css.js +3 -0
- package/components/dialog/themes/light/dialog.bootstrap.css.js.map +1 -0
- package/components/dialog/themes/light/dialog.fluent.css.d.ts +1 -0
- package/components/dialog/themes/light/dialog.fluent.css.js +3 -0
- package/components/dialog/themes/light/dialog.fluent.css.js.map +1 -0
- package/components/dialog/themes/light/dialog.indigo.css.d.ts +1 -0
- package/components/dialog/themes/light/dialog.indigo.css.js +3 -0
- package/components/dialog/themes/light/dialog.indigo.css.js.map +1 -0
- package/components/dialog/themes/light/dialog.material.css.d.ts +1 -0
- package/components/dialog/themes/light/dialog.material.css.js +3 -0
- package/components/dialog/themes/light/dialog.material.css.js.map +1 -0
- package/components/dropdown/dropdown-group.d.ts +2 -2
- package/components/dropdown/dropdown-group.js +1 -1
- package/components/dropdown/dropdown-group.js.map +1 -1
- package/components/dropdown/dropdown-header.d.ts +1 -1
- package/components/dropdown/dropdown-header.js.map +1 -1
- package/components/dropdown/dropdown-item.d.ts +1 -1
- package/components/dropdown/dropdown-item.js.map +1 -1
- package/components/dropdown/dropdown.d.ts +10 -8
- package/components/dropdown/dropdown.js +15 -10
- package/components/dropdown/dropdown.js.map +1 -1
- package/components/dropdown/themes/light/dropdown-group.base.css.js +1 -1
- package/components/dropdown/themes/light/dropdown-group.base.css.js.map +1 -1
- package/components/dropdown/themes/light/dropdown-group.fluent.css.js +1 -1
- package/components/dropdown/themes/light/dropdown-group.fluent.css.js.map +1 -1
- package/components/dropdown/themes/light/dropdown-item.base.css.js +1 -1
- package/components/dropdown/themes/light/dropdown-item.base.css.js.map +1 -1
- package/components/dropdown/themes/light/dropdown.base.css.js +1 -1
- package/components/dropdown/themes/light/dropdown.base.css.js.map +1 -1
- package/components/dropdown/themes/light/dropdown.fluent.css.js +1 -1
- package/components/dropdown/themes/light/dropdown.fluent.css.js.map +1 -1
- package/components/form/form.js +4 -3
- package/components/form/form.js.map +1 -1
- package/components/icon/icon.js +3 -1
- package/components/icon/icon.js.map +1 -1
- package/components/input/input-base.js +3 -1
- package/components/input/input-base.js.map +1 -1
- package/components/input/input.d.ts +1 -0
- package/components/input/input.js +5 -0
- package/components/input/input.js.map +1 -1
- package/components/input/themes/light/input.base.css.js +1 -1
- package/components/input/themes/light/input.base.css.js.map +1 -1
- package/components/input/themes/light/input.bootstrap.css.js +1 -1
- package/components/input/themes/light/input.bootstrap.css.js.map +1 -1
- package/components/input/themes/light/input.fluent.css.js +1 -1
- package/components/input/themes/light/input.fluent.css.js.map +1 -1
- package/components/input/themes/light/input.indigo.css.js +1 -1
- package/components/input/themes/light/input.indigo.css.js.map +1 -1
- package/components/mask-input/mask-input-base.js +7 -2
- package/components/mask-input/mask-input-base.js.map +1 -1
- package/components/progress/linear-progress.js +1 -0
- package/components/progress/linear-progress.js.map +1 -1
- package/components/progress/themes/circular/circular.progress.base.css.js +1 -1
- package/components/progress/themes/circular/circular.progress.base.css.js.map +1 -1
- package/components/progress/themes/linear/linear.progress.base.css.js +1 -1
- package/components/progress/themes/linear/linear.progress.base.css.js.map +1 -1
- package/components/progress/themes/linear/linear.progress.bootstrap.css.js +1 -1
- package/components/progress/themes/linear/linear.progress.bootstrap.css.js.map +1 -1
- package/components/progress/themes/linear/linear.progress.fluent.css.js +1 -1
- package/components/progress/themes/linear/linear.progress.fluent.css.js.map +1 -1
- package/components/progress/themes/linear/linear.progress.indigo.css.js +1 -1
- package/components/progress/themes/linear/linear.progress.indigo.css.js.map +1 -1
- package/components/radio-group/radio-group.d.ts +0 -1
- package/components/radio-group/radio-group.js +7 -6
- package/components/radio-group/radio-group.js.map +1 -1
- package/components/rating/rating.d.ts +21 -9
- package/components/rating/rating.js +50 -33
- package/components/rating/rating.js.map +1 -1
- package/components/select/select-group.d.ts +31 -0
- package/components/select/select-group.js +69 -0
- package/components/select/select-group.js.map +1 -0
- package/components/select/select-header.d.ts +15 -0
- package/components/select/select-header.js +5 -0
- package/components/select/select-header.js.map +1 -0
- package/components/select/select-item.d.ts +30 -0
- package/components/select/select-item.js +39 -0
- package/components/select/select-item.js.map +1 -0
- package/components/select/select.d.ts +112 -0
- package/components/select/select.js +343 -0
- package/components/select/select.js.map +1 -0
- package/components/select/themes/dark/select.bootstrap.css.d.ts +1 -0
- package/components/select/themes/dark/select.bootstrap.css.js +3 -0
- package/components/select/themes/dark/select.bootstrap.css.js.map +1 -0
- package/components/select/themes/dark/select.fluent.css.d.ts +1 -0
- package/components/select/themes/dark/select.fluent.css.js +3 -0
- package/components/select/themes/dark/select.fluent.css.js.map +1 -0
- package/components/select/themes/dark/select.indigo.css.d.ts +1 -0
- package/components/select/themes/dark/select.indigo.css.js +3 -0
- package/components/select/themes/dark/select.indigo.css.js.map +1 -0
- package/components/select/themes/dark/select.material.css.d.ts +1 -0
- package/components/select/themes/dark/select.material.css.js +3 -0
- package/components/select/themes/dark/select.material.css.js.map +1 -0
- package/components/select/themes/light/select.base.css.d.ts +1 -0
- package/components/select/themes/light/select.base.css.js +3 -0
- package/components/select/themes/light/select.base.css.js.map +1 -0
- package/components/select/themes/light/select.bootstrap.css.d.ts +1 -0
- package/components/select/themes/light/select.bootstrap.css.js +3 -0
- package/components/select/themes/light/select.bootstrap.css.js.map +1 -0
- package/components/select/themes/light/select.fluent.css.d.ts +1 -0
- package/components/select/themes/light/select.fluent.css.js +3 -0
- package/components/select/themes/light/select.fluent.css.js.map +1 -0
- package/components/select/themes/light/select.indigo.css.d.ts +1 -0
- package/components/select/themes/light/select.indigo.css.js +3 -0
- package/components/select/themes/light/select.indigo.css.js.map +1 -0
- package/components/select/themes/light/select.material.css.d.ts +1 -0
- package/components/select/themes/light/select.material.css.js +3 -0
- package/components/select/themes/light/select.material.css.js.map +1 -0
- package/components/slider/range-slider.d.ts +2 -0
- package/components/slider/range-slider.js +61 -0
- package/components/slider/range-slider.js.map +1 -1
- package/components/slider/slider-base.d.ts +7 -8
- package/components/slider/slider-base.js +8 -8
- package/components/slider/slider-base.js.map +1 -1
- package/components/tabs/tabs.d.ts +0 -1
- package/components/tabs/tabs.js +7 -9
- package/components/tabs/tabs.js.map +1 -1
- package/components/toast/toast.d.ts +1 -0
- package/components/toast/toast.js +9 -0
- package/components/toast/toast.js.map +1 -1
- package/components/toggle/toggle.controller.d.ts +7 -2
- package/components/toggle/toggle.controller.js +21 -20
- package/components/toggle/toggle.controller.js.map +1 -1
- package/components/tree/themes/light/tree.base.css.js +1 -1
- package/components/tree/themes/light/tree.base.css.js.map +1 -1
- package/custom-elements.json +613 -14
- package/index.d.ts +5 -0
- package/index.js +5 -0
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/themes/dark/bootstrap.css +1 -1
- package/themes/dark/fluent.css +1 -1
- package/themes/dark/indigo.css +1 -1
- package/themes/dark/material.css +1 -1
- package/vscode-html-custom-data.json +282 -14
|
@@ -5,14 +5,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { html, LitElement, nothing } from 'lit';
|
|
8
|
-
import { property, query,
|
|
8
|
+
import { property, query, queryAssignedNodes, state } from 'lit/decorators.js';
|
|
9
9
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
10
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
11
|
+
import { guard } from 'lit/directives/guard.js';
|
|
11
12
|
import { themes } from '../../theming/theming-decorator.js';
|
|
12
13
|
import { watch } from '../common/decorators/watch.js';
|
|
13
14
|
import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
|
|
14
15
|
import { SizableMixin } from '../common/mixins/sizable.js';
|
|
15
|
-
import { clamp } from '../common/util.js';
|
|
16
|
+
import { clamp, isLTR } from '../common/util.js';
|
|
16
17
|
import { styles } from './rating.base.css.js';
|
|
17
18
|
import { styles as bootstrap } from './rating.bootstrap.css.js';
|
|
18
19
|
import { styles as fluent } from './rating.fluent.css.js';
|
|
@@ -24,6 +25,7 @@ defineComponents(IgcRatingSymbolComponent, IgcIconComponent);
|
|
|
24
25
|
let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmitterMixin(LitElement)) {
|
|
25
26
|
constructor() {
|
|
26
27
|
super();
|
|
28
|
+
this.ratingSymbols = [];
|
|
27
29
|
this.hoverValue = -1;
|
|
28
30
|
this.hoverState = false;
|
|
29
31
|
this.max = 5;
|
|
@@ -41,13 +43,13 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
|
|
|
41
43
|
get hasProjectedSymbols() {
|
|
42
44
|
return this.ratingSymbols.length > 0;
|
|
43
45
|
}
|
|
44
|
-
get isLTR() {
|
|
45
|
-
return (window.getComputedStyle(this).getPropertyValue('direction') === 'ltr');
|
|
46
|
-
}
|
|
47
46
|
get valueText() {
|
|
47
|
+
const value = this.round(this.value);
|
|
48
48
|
return this.valueFormat
|
|
49
|
-
? this.valueFormat
|
|
50
|
-
|
|
49
|
+
? this.valueFormat
|
|
50
|
+
.replace(/\{0\}/gm, `${value}`)
|
|
51
|
+
.replace(/\{1\}/gm, `${this.max}`)
|
|
52
|
+
: `${value} of ${this.max}`;
|
|
51
53
|
}
|
|
52
54
|
handleMaxChange() {
|
|
53
55
|
this.hasProjectedSymbols
|
|
@@ -102,14 +104,15 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
|
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
104
106
|
let result = this.value;
|
|
107
|
+
const ltr = isLTR(this);
|
|
105
108
|
switch (key) {
|
|
106
109
|
case 'ArrowUp':
|
|
107
110
|
case 'ArrowRight':
|
|
108
|
-
result +=
|
|
111
|
+
result += ltr ? this.step : -this.step;
|
|
109
112
|
break;
|
|
110
113
|
case 'ArrowDown':
|
|
111
114
|
case 'ArrowLeft':
|
|
112
|
-
result -=
|
|
115
|
+
result -= ltr ? this.step : -this.step;
|
|
113
116
|
break;
|
|
114
117
|
case 'Home':
|
|
115
118
|
result = this.step;
|
|
@@ -125,7 +128,11 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
|
|
|
125
128
|
this.emitEvent('igcChange', { detail: this.value });
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
|
-
handleSlotChange() {
|
|
131
|
+
handleSlotChange(event) {
|
|
132
|
+
const slot = event.target;
|
|
133
|
+
this.ratingSymbols = slot
|
|
134
|
+
.assignedElements()
|
|
135
|
+
.filter((el) => el instanceof IgcRatingSymbolComponent);
|
|
129
136
|
if (this.hasProjectedSymbols) {
|
|
130
137
|
this.max = this.ratingSymbols.length;
|
|
131
138
|
}
|
|
@@ -133,7 +140,7 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
|
|
|
133
140
|
}
|
|
134
141
|
calcNewValue(x) {
|
|
135
142
|
const { width, left, right } = this.container.getBoundingClientRect();
|
|
136
|
-
const percent = this
|
|
143
|
+
const percent = isLTR(this) ? (x - left) / width : (right - x) / width;
|
|
137
144
|
const value = this.round(this.max * percent + this.step / 2);
|
|
138
145
|
return clamp(value, this.step, this.max);
|
|
139
146
|
}
|
|
@@ -145,21 +152,18 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
|
|
|
145
152
|
value = Math.round(value / this.step) * this.step;
|
|
146
153
|
return Number(value.toFixed(this.getPrecision(this.step)));
|
|
147
154
|
}
|
|
148
|
-
clipSymbol(index,
|
|
155
|
+
clipSymbol(index, isLTR = true) {
|
|
149
156
|
const value = this.hoverState ? this.hoverValue : this.value;
|
|
150
157
|
const progress = index + 1 - value;
|
|
151
158
|
const exclusive = progress === 0 || this.value === index + 1 ? 0 : 1;
|
|
152
159
|
const selection = this.single ? exclusive : progress;
|
|
153
160
|
const activate = (p) => clamp(p * 100, 0, 100);
|
|
154
|
-
const forward = `inset(0 ${activate(
|
|
155
|
-
const backward = `inset(0 0 0 ${activate(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
default:
|
|
161
|
-
return this.isLTR ? forward : backward;
|
|
162
|
-
}
|
|
161
|
+
const forward = `inset(0 ${activate(isLTR ? selection : 1 - selection)}% 0 0)`;
|
|
162
|
+
const backward = `inset(0 0 0 ${activate(isLTR ? 1 - selection : selection)}%)`;
|
|
163
|
+
return {
|
|
164
|
+
backward: isLTR ? backward : forward,
|
|
165
|
+
forward: isLTR ? forward : backward,
|
|
166
|
+
};
|
|
163
167
|
}
|
|
164
168
|
stepUp(n = 1) {
|
|
165
169
|
this.value += this.round(n * this.step);
|
|
@@ -168,17 +172,19 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
|
|
|
168
172
|
this.value -= this.round(n * this.step);
|
|
169
173
|
}
|
|
170
174
|
*renderSymbols() {
|
|
175
|
+
const ltr = isLTR(this);
|
|
171
176
|
for (let i = 0; i < this.max; i++) {
|
|
177
|
+
const { forward, backward } = this.clipSymbol(i, ltr);
|
|
172
178
|
yield html `<igc-rating-symbol exportparts="symbol, full, empty">
|
|
173
179
|
<igc-icon
|
|
174
180
|
collection="internal"
|
|
175
181
|
name="star"
|
|
176
|
-
style=${styleMap({ clipPath:
|
|
182
|
+
style=${styleMap({ clipPath: forward })}
|
|
177
183
|
></igc-icon>
|
|
178
184
|
<igc-icon
|
|
179
185
|
collection="internal"
|
|
180
186
|
name="star_border"
|
|
181
|
-
style=${styleMap({ clipPath:
|
|
187
|
+
style=${styleMap({ clipPath: backward })}
|
|
182
188
|
slot="empty"
|
|
183
189
|
></igc-icon>
|
|
184
190
|
</igc-rating-symbol>`;
|
|
@@ -186,29 +192,40 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
|
|
|
186
192
|
}
|
|
187
193
|
clipProjected() {
|
|
188
194
|
if (this.hasProjectedSymbols) {
|
|
195
|
+
const ltr = isLTR(this);
|
|
189
196
|
this.ratingSymbols.forEach((symbol, i) => {
|
|
190
197
|
var _a, _b;
|
|
191
198
|
const full = (_a = symbol.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('[part="symbol full"]');
|
|
192
199
|
const empty = (_b = symbol.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('[part="symbol empty"]');
|
|
200
|
+
const { forward, backward } = this.clipSymbol(i, ltr);
|
|
193
201
|
if (full) {
|
|
194
|
-
full.style.clipPath =
|
|
202
|
+
full.style.clipPath = forward;
|
|
195
203
|
}
|
|
196
204
|
if (empty) {
|
|
197
|
-
empty.style.clipPath =
|
|
205
|
+
empty.style.clipPath = backward;
|
|
198
206
|
}
|
|
199
207
|
});
|
|
200
208
|
}
|
|
201
209
|
}
|
|
202
210
|
render() {
|
|
203
|
-
|
|
204
|
-
|
|
211
|
+
const props = [
|
|
212
|
+
this.value,
|
|
213
|
+
this.hoverValue,
|
|
214
|
+
this.max,
|
|
215
|
+
this.step,
|
|
216
|
+
this.single,
|
|
217
|
+
this.hoverState,
|
|
218
|
+
this.ratingSymbols,
|
|
219
|
+
];
|
|
205
220
|
return html `
|
|
206
|
-
<label part="label" ?hidden=${!this.label}
|
|
221
|
+
<label part="label" id="rating-label" ?hidden=${!this.label}
|
|
222
|
+
>${this.label}</label
|
|
223
|
+
>
|
|
207
224
|
<div
|
|
208
225
|
part="base"
|
|
209
226
|
role="slider"
|
|
210
227
|
tabindex=${ifDefined(this.disabled ? undefined : 0)}
|
|
211
|
-
aria-
|
|
228
|
+
aria-labelledby="rating-label"
|
|
212
229
|
aria-valuemin="0"
|
|
213
230
|
aria-valuenow=${this.value}
|
|
214
231
|
aria-valuemax=${this.max}
|
|
@@ -223,7 +240,10 @@ let IgcRatingComponent = class IgcRatingComponent extends SizableMixin(EventEmit
|
|
|
223
240
|
@mousemove=${this.hoverPreview ? this.handleMouseMove : nothing}
|
|
224
241
|
>
|
|
225
242
|
<slot @slotchange=${this.handleSlotChange}>
|
|
226
|
-
${
|
|
243
|
+
${guard(props, () => {
|
|
244
|
+
this.clipProjected();
|
|
245
|
+
return this.renderSymbols();
|
|
246
|
+
})}
|
|
227
247
|
</slot>
|
|
228
248
|
</div>
|
|
229
249
|
<label part="value-label" ?hidden=${this.valueLabel.length === 0}>
|
|
@@ -241,9 +261,6 @@ __decorate([
|
|
|
241
261
|
__decorate([
|
|
242
262
|
queryAssignedNodes({ slot: 'value-label', flatten: true })
|
|
243
263
|
], IgcRatingComponent.prototype, "valueLabel", void 0);
|
|
244
|
-
__decorate([
|
|
245
|
-
queryAssignedElements({ selector: 'igc-rating-symbol' })
|
|
246
|
-
], IgcRatingComponent.prototype, "ratingSymbols", void 0);
|
|
247
264
|
__decorate([
|
|
248
265
|
state()
|
|
249
266
|
], IgcRatingComponent.prototype, "hoverValue", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rating.js","sourceRoot":"","sources":["../../../src/components/rating/rating.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EACL,QAAQ,EACR,KAAK,EACL,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,GACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,wBAAwB,MAAM,oBAAoB,CAAC;AAC1D,OAAO,gBAAgB,MAAM,iBAAiB,CAAC;AAE/C,gBAAgB,CAAC,wBAAwB,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ACC;AAG1D;IADC,KAAK,EAAE;sDACkB;AAG1B;IADC,KAAK,EAAE;sDACqB;AAwB7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CACZ;AAIf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACX;AAIhB;IADC,QAAQ,EAAE;gDACU;AAIrB;IADC,QAAQ,EAAE;iDACW;AAQtB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;uDACZ;AAI5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACV;AAIjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACnB;AAIxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;wDAC3C;AAI5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACnB;AAIxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDACN;AAGtB;IADC,KAAK,CAAC,KAAK,CAAC;yDAQZ;AAGD;IADC,KAAK,CAAC,OAAO,CAAC;2DAGd;AAGD;IADC,KAAK,CAAC,MAAM,CAAC;+DAGb;AAGD;IADC,KAAK,CAAC,QAAQ,CAAC;+DAMf;AAhHkB,kBAAkB;IADtC,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;GACjB,kBAAkB,CAsUtC;eAtUoB,kBAAkB","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport {\n property,\n query,\n queryAssignedElements,\n queryAssignedNodes,\n state,\n} from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { themes } from '../../theming/theming-decorator.js';\nimport { watch } from '../common/decorators/watch.js';\nimport { Constructor } from '../common/mixins/constructor.js';\nimport { EventEmitterMixin } from '../common/mixins/event-emitter.js';\nimport { SizableMixin } from '../common/mixins/sizable.js';\nimport { clamp } from '../common/util.js';\nimport { styles } from './rating.base.css.js';\nimport { styles as bootstrap } from './rating.bootstrap.css.js';\nimport { styles as fluent } from './rating.fluent.css.js';\nimport { styles as indigo } from './rating.indigo.css.js';\n\nimport { defineComponents } from '../common/definitions/defineComponents.js';\nimport IgcRatingSymbolComponent from './rating-symbol.js';\nimport IgcIconComponent from '../icon/icon.js';\n\ndefineComponents(IgcRatingSymbolComponent, IgcIconComponent);\n\nexport interface IgcRatingEventMap {\n igcChange: CustomEvent<number>;\n igcHover: CustomEvent<number>;\n}\n\n/**\n * Rating provides insight regarding others' opinions and experiences,\n * and can allow the user to submit a rating of their own\n *\n * @element igc-rating\n *\n * @fires igcChange - Emitted when the value of the control changes.\n * @fires igcHover - Emitted when hover is enabled and the user mouses over a symbol of the rating.\n *\n * @csspart base - The main wrapper which holds all of the rating elements.\n * @csspart label - The label part.\n * @csspart value-label - The value label part.\n * @csspart symbols - A wrapper for all rating symbols.\n * @csspart symbol - The part of the encapsulated default symbol.\n * @csspart full - The part of the encapsulated full symbols.\n * @csspart empty - The part of the encapsulated empty symbols.\n *\n * @cssproperty --symbol-size - The size of the symbols.\n * @cssproperty --symbol-full-color - The color of the filled symbol.\n * @cssproperty --symbol-empty-color - The color of the empty symbol.\n * @cssproperty --symbol-full-filter - The filter(s) used for the filled symbol.\n * @cssproperty --symbol-empty-filter - The filter(s) used for the empty symbol.\n */\n@themes({ fluent, bootstrap, indigo })\nexport default class IgcRatingComponent extends SizableMixin(\n EventEmitterMixin<IgcRatingEventMap, Constructor<LitElement>>(LitElement)\n) {\n public static readonly tagName = 'igc-rating';\n\n public static styles = [styles];\n\n @query('[part=\"symbols\"]', true)\n protected container!: HTMLElement;\n\n @queryAssignedNodes({ slot: 'value-label', flatten: true })\n protected valueLabel!: Array<Node>;\n\n @queryAssignedElements({ selector: 'igc-rating-symbol' })\n protected ratingSymbols!: Array<IgcRatingSymbolComponent>;\n\n @state()\n protected hoverValue = -1;\n\n @state()\n protected hoverState = false;\n\n protected get isInteractive() {\n return !(this.readonly || this.disabled);\n }\n\n protected get hasProjectedSymbols() {\n return this.ratingSymbols.length > 0;\n }\n\n protected get isLTR() {\n return (\n window.getComputedStyle(this).getPropertyValue('direction') === 'ltr'\n );\n }\n\n protected get valueText() {\n return this.valueFormat\n ? this.valueFormat.replace(/\\{0\\}/gm, `${this.value}`)\n : this.value;\n }\n\n /** The maximum value for the rating */\n @property({ type: Number })\n public max = 5;\n\n /** The minimum value change allowed. */\n @property({ type: Number })\n public step = 1;\n\n /** The name attribute of the control */\n @property()\n public name!: string;\n\n /** The label of the control. */\n @property()\n public label!: string;\n\n /**\n * A format string which sets aria-valuetext. All instances of '{0}' will be replaced\n * with the current value of the control.\n * Important for screen-readers and useful for localization.\n */\n @property({ attribute: 'value-format' })\n public valueFormat!: string;\n\n /** The current value of the component */\n @property({ type: Number })\n public value = 0;\n\n /** Sets the disabled state of the component */\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n /** Sets hover preview behavior for the component */\n @property({ type: Boolean, reflect: true, attribute: 'hover-preview' })\n public hoverPreview = false;\n\n /** Sets the readonly state of the component */\n @property({ type: Boolean, reflect: true })\n public readonly = false;\n\n /** Toggles single selection visual mode. */\n @property({ type: Boolean })\n public single = false;\n\n @watch('max')\n protected handleMaxChange() {\n this.hasProjectedSymbols\n ? (this.max = this.ratingSymbols.length)\n : (this.max = Math.max(0, this.max));\n if (this.max < this.value) {\n this.value = this.max;\n }\n }\n\n @watch('value')\n protected handleValueChange() {\n this.value = clamp(this.value, 0, this.max);\n }\n\n @watch('step')\n protected handlePrecisionChange() {\n this.step = !this.single ? clamp(this.step, 0.001, 1) : 1;\n }\n\n @watch('single')\n protected handleSelectionChange() {\n if (this.single) {\n this.step = 1;\n this.value = Math.ceil(this.value);\n }\n }\n\n constructor() {\n super();\n this.addEventListener('keydown', this.handleKeyDown);\n }\n\n protected handleClick({ clientX }: MouseEvent) {\n if (!this.isInteractive) {\n return;\n }\n\n const value = this.calcNewValue(clientX);\n this.value === value ? (this.value = 0) : (this.value = value);\n this.emitEvent('igcChange', { detail: this.value });\n }\n\n protected handleMouseMove({ clientX }: MouseEvent) {\n if (!this.isInteractive) {\n return;\n }\n\n const value = this.calcNewValue(clientX);\n\n if (this.hoverValue !== value) {\n // Since mousemove spams a lot, only emit on a value change\n this.hoverValue = value;\n this.emitEvent('igcHover', { detail: this.hoverValue });\n }\n }\n\n protected handleMouseEnter() {\n if (this.isInteractive) {\n this.hoverState = true;\n }\n }\n\n protected handleMouseLeave() {\n if (this.isInteractive) {\n this.hoverState = false;\n }\n }\n\n protected handleKeyDown({ key }: KeyboardEvent) {\n if (!this.isInteractive) {\n return;\n }\n\n let result = this.value;\n\n switch (key) {\n case 'ArrowUp':\n case 'ArrowRight':\n result += this.isLTR ? this.step : -this.step;\n break;\n case 'ArrowDown':\n case 'ArrowLeft':\n result -= this.isLTR ? this.step : -this.step;\n break;\n case 'Home':\n result = this.step;\n break;\n case 'End':\n result = this.max;\n break;\n default:\n return;\n }\n\n // Verify new value is in bounds and emit\n this.value = clamp(result, 0, this.max);\n\n if (result === this.value) {\n this.emitEvent('igcChange', { detail: this.value });\n }\n }\n\n protected handleSlotChange() {\n if (this.hasProjectedSymbols) {\n this.max = this.ratingSymbols.length;\n }\n this.requestUpdate();\n }\n\n protected calcNewValue(x: number) {\n const { width, left, right } = this.container.getBoundingClientRect();\n const percent = this.isLTR ? (x - left) / width : (right - x) / width;\n const value = this.round(this.max * percent + this.step / 2);\n\n return clamp(value, this.step, this.max);\n }\n\n protected getPrecision(num: number) {\n const [_, decimal] = num.toString().split('.');\n return decimal ? decimal.length : 0;\n }\n\n protected round(value: number) {\n value = Math.round(value / this.step) * this.step;\n return Number(value.toFixed(this.getPrecision(this.step)));\n }\n\n protected clipSymbol(index: number, direction: 'forward' | 'backward') {\n const value = this.hoverState ? this.hoverValue : this.value;\n const progress = index + 1 - value;\n const exclusive = progress === 0 || this.value === index + 1 ? 0 : 1;\n const selection = this.single ? exclusive : progress;\n const activate = (p: number) => clamp(p * 100, 0, 100);\n\n const forward = `inset(0 ${activate(\n this.isLTR ? selection : 1 - selection\n )}% 0 0)`;\n const backward = `inset(0 0 0 ${activate(\n this.isLTR ? 1 - selection : selection\n )}%)`;\n\n switch (direction) {\n case 'backward':\n return this.isLTR ? backward : forward;\n case 'forward':\n default:\n return this.isLTR ? forward : backward;\n }\n }\n\n /**\n * Increments the value of the control by `n` steps multiplied by the\n * step factor.\n */\n public stepUp(n = 1) {\n this.value += this.round(n * this.step);\n }\n\n /**\n * Decrements the value of the control by `n` steps multiplied by\n * the step factor.\n */\n public stepDown(n = 1) {\n this.value -= this.round(n * this.step);\n }\n\n protected *renderSymbols() {\n for (let i = 0; i < this.max; i++) {\n yield html`<igc-rating-symbol exportparts=\"symbol, full, empty\">\n <igc-icon\n collection=\"internal\"\n name=\"star\"\n style=${styleMap({ clipPath: this.clipSymbol(i, 'forward') })}\n ></igc-icon>\n <igc-icon\n collection=\"internal\"\n name=\"star_border\"\n style=${styleMap({ clipPath: this.clipSymbol(i, 'backward') })}\n slot=\"empty\"\n ></igc-icon>\n </igc-rating-symbol>`;\n }\n }\n\n protected clipProjected() {\n if (this.hasProjectedSymbols) {\n this.ratingSymbols.forEach((symbol: IgcRatingSymbolComponent, i) => {\n const full = symbol.shadowRoot?.querySelector(\n '[part=\"symbol full\"]'\n ) as HTMLElement;\n\n const empty = symbol.shadowRoot?.querySelector(\n '[part=\"symbol empty\"]'\n ) as HTMLElement;\n\n if (full) {\n full.style.clipPath = this.clipSymbol(i, 'forward');\n }\n\n if (empty) {\n empty.style.clipPath = this.clipSymbol(i, 'backward');\n }\n });\n }\n }\n\n protected override render() {\n this.clipProjected();\n\n return html`\n <label part=\"label\" ?hidden=${!this.label}>${this.label}</label>\n <div\n part=\"base\"\n role=\"slider\"\n tabindex=${ifDefined(this.disabled ? undefined : 0)}\n aria-label=${this.label ?? nothing}\n aria-valuemin=\"0\"\n aria-valuenow=${this.value}\n aria-valuemax=${this.max}\n aria-valuetext=${this.valueText}\n >\n <div\n aria-hidden=\"true\"\n part=\"symbols\"\n @click=${this.handleClick}\n @mouseenter=${this.hoverPreview ? this.handleMouseEnter : nothing}\n @mouseleave=${this.hoverPreview ? this.handleMouseLeave : nothing}\n @mousemove=${this.hoverPreview ? this.handleMouseMove : nothing}\n >\n <slot @slotchange=${this.handleSlotChange}>\n ${this.renderSymbols()}\n </slot>\n </div>\n <label part=\"value-label\" ?hidden=${this.valueLabel.length === 0}>\n <slot name=\"value-label\"></slot>\n </label>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-rating': IgcRatingComponent;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rating.js","sourceRoot":"","sources":["../../../src/components/rating/rating.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,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AE,cAAc,EAAE,CAAC;uDACZ;AAI5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACV;AAIjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACnB;AAIxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;wDAC3C;AAI5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACnB;AAIxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDACN;AAGtB;IADC,KAAK,CAAC,KAAK,CAAC;yDAQZ;AAGD;IADC,KAAK,CAAC,OAAO,CAAC;2DAGd;AAGD;IADC,KAAK,CAAC,MAAM,CAAC;+DAGb;AAGD;IADC,KAAK,CAAC,QAAQ,CAAC;+DAMf;AAxHkB,kBAAkB;IADtC,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;GACjB,kBAAkB,CAsWtC;eAtWoB,kBAAkB","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property, query, queryAssignedNodes, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { guard } from 'lit/directives/guard.js';\nimport { themes } from '../../theming/theming-decorator.js';\nimport { watch } from '../common/decorators/watch.js';\nimport { Constructor } from '../common/mixins/constructor.js';\nimport { EventEmitterMixin } from '../common/mixins/event-emitter.js';\nimport { SizableMixin } from '../common/mixins/sizable.js';\nimport { clamp, isLTR } from '../common/util.js';\nimport { styles } from './rating.base.css.js';\nimport { styles as bootstrap } from './rating.bootstrap.css.js';\nimport { styles as fluent } from './rating.fluent.css.js';\nimport { styles as indigo } from './rating.indigo.css.js';\n\nimport { defineComponents } from '../common/definitions/defineComponents.js';\nimport IgcRatingSymbolComponent from './rating-symbol.js';\nimport IgcIconComponent from '../icon/icon.js';\n\ndefineComponents(IgcRatingSymbolComponent, IgcIconComponent);\n\nexport interface IgcRatingEventMap {\n igcChange: CustomEvent<number>;\n igcHover: CustomEvent<number>;\n}\n\n/**\n * Rating provides insight regarding others' opinions and experiences,\n * and can allow the user to submit a rating of their own\n *\n * @element igc-rating\n *\n * @fires igcChange - Emitted when the value of the control changes.\n * @fires igcHover - Emitted when hover is enabled and the user mouses over a symbol of the rating.\n *\n * @csspart base - The main wrapper which holds all of the rating elements.\n * @csspart label - The label part.\n * @csspart value-label - The value label part.\n * @csspart symbols - A wrapper for all rating symbols.\n * @csspart symbol - The part of the encapsulated default symbol.\n * @csspart full - The part of the encapsulated full symbols.\n * @csspart empty - The part of the encapsulated empty symbols.\n *\n * @cssproperty --symbol-size - The size of the symbols.\n * @cssproperty --symbol-full-color - The color of the filled symbol.\n * @cssproperty --symbol-empty-color - The color of the empty symbol.\n * @cssproperty --symbol-full-filter - The filter(s) used for the filled symbol.\n * @cssproperty --symbol-empty-filter - The filter(s) used for the empty symbol.\n */\n@themes({ fluent, bootstrap, indigo })\nexport default class IgcRatingComponent extends SizableMixin(\n EventEmitterMixin<IgcRatingEventMap, Constructor<LitElement>>(LitElement)\n) {\n public static readonly tagName = 'igc-rating';\n\n public static styles = [styles];\n\n protected ratingSymbols: Array<IgcRatingSymbolComponent> = [];\n\n @query('[part=\"symbols\"]', true)\n protected container!: HTMLElement;\n\n @queryAssignedNodes({ slot: 'value-label', flatten: true })\n protected valueLabel!: Array<Node>;\n\n @state()\n protected hoverValue = -1;\n\n @state()\n protected hoverState = false;\n\n protected get isInteractive() {\n return !(this.readonly || this.disabled);\n }\n\n protected get hasProjectedSymbols() {\n return this.ratingSymbols.length > 0;\n }\n\n protected get valueText() {\n // Skip IEEE 754 representation for screen readers\n const value = this.round(this.value);\n\n return this.valueFormat\n ? this.valueFormat\n .replace(/\\{0\\}/gm, `${value}`)\n .replace(/\\{1\\}/gm, `${this.max}`)\n : `${value} of ${this.max}`;\n }\n\n /**\n * The maximum value for the rating.\n *\n * If there are projected symbols, the maximum value will be resolved\n * based on the number of symbols.\n */\n @property({ type: Number })\n public max = 5;\n\n /**\n * The minimum value change allowed.\n *\n * Valid values are in the interval between 0 and 1 inclusive.\n */\n @property({ type: Number })\n public step = 1;\n\n /** The name attribute of the control */\n @property()\n public name!: string;\n\n /** The label of the control. */\n @property()\n public label!: string;\n\n /**\n * A format string which sets aria-valuetext. Instances of '{0}' will be replaced\n * with the current value of the control and instances of '{1}' with the maximum value for the control.\n *\n * Important for screen-readers and useful for localization.\n */\n @property({ attribute: 'value-format' })\n public valueFormat!: string;\n\n /** The current value of the component */\n @property({ type: Number })\n public value = 0;\n\n /** Sets the disabled state of the component */\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n /** Sets hover preview behavior for the component */\n @property({ type: Boolean, reflect: true, attribute: 'hover-preview' })\n public hoverPreview = false;\n\n /** Sets the readonly state of the component */\n @property({ type: Boolean, reflect: true })\n public readonly = false;\n\n /** Toggles single selection visual mode. */\n @property({ type: Boolean })\n public single = false;\n\n @watch('max')\n protected handleMaxChange() {\n this.hasProjectedSymbols\n ? (this.max = this.ratingSymbols.length)\n : (this.max = Math.max(0, this.max));\n if (this.max < this.value) {\n this.value = this.max;\n }\n }\n\n @watch('value')\n protected handleValueChange() {\n this.value = clamp(this.value, 0, this.max);\n }\n\n @watch('step')\n protected handlePrecisionChange() {\n this.step = !this.single ? clamp(this.step, 0.001, 1) : 1;\n }\n\n @watch('single')\n protected handleSelectionChange() {\n if (this.single) {\n this.step = 1;\n this.value = Math.ceil(this.value);\n }\n }\n\n constructor() {\n super();\n this.addEventListener('keydown', this.handleKeyDown);\n }\n\n protected handleClick({ clientX }: MouseEvent) {\n if (!this.isInteractive) {\n return;\n }\n\n const value = this.calcNewValue(clientX);\n this.value === value ? (this.value = 0) : (this.value = value);\n this.emitEvent('igcChange', { detail: this.value });\n }\n\n protected handleMouseMove({ clientX }: MouseEvent) {\n if (!this.isInteractive) {\n return;\n }\n\n const value = this.calcNewValue(clientX);\n\n if (this.hoverValue !== value) {\n // Since mousemove spams a lot, only emit on a value change\n this.hoverValue = value;\n this.emitEvent('igcHover', { detail: this.hoverValue });\n }\n }\n\n protected handleMouseEnter() {\n if (this.isInteractive) {\n this.hoverState = true;\n }\n }\n\n protected handleMouseLeave() {\n if (this.isInteractive) {\n this.hoverState = false;\n }\n }\n\n protected handleKeyDown({ key }: KeyboardEvent) {\n if (!this.isInteractive) {\n return;\n }\n\n let result = this.value;\n const ltr = isLTR(this);\n\n switch (key) {\n case 'ArrowUp':\n case 'ArrowRight':\n result += ltr ? this.step : -this.step;\n break;\n case 'ArrowDown':\n case 'ArrowLeft':\n result -= ltr ? this.step : -this.step;\n break;\n case 'Home':\n result = this.step;\n break;\n case 'End':\n result = this.max;\n break;\n default:\n return;\n }\n\n // Verify new value is in bounds and emit\n this.value = clamp(result, 0, this.max);\n\n if (result === this.value) {\n this.emitEvent('igcChange', { detail: this.value });\n }\n }\n\n protected handleSlotChange(event: Event) {\n const slot = event.target as HTMLSlotElement;\n\n this.ratingSymbols = slot\n .assignedElements()\n .filter(\n (el) => el instanceof IgcRatingSymbolComponent\n ) as IgcRatingSymbolComponent[];\n\n if (this.hasProjectedSymbols) {\n this.max = this.ratingSymbols.length;\n }\n\n this.requestUpdate();\n }\n\n protected calcNewValue(x: number) {\n const { width, left, right } = this.container.getBoundingClientRect();\n const percent = isLTR(this) ? (x - left) / width : (right - x) / width;\n const value = this.round(this.max * percent + this.step / 2);\n\n return clamp(value, this.step, this.max);\n }\n\n protected getPrecision(num: number) {\n const [_, decimal] = num.toString().split('.');\n return decimal ? decimal.length : 0;\n }\n\n protected round(value: number) {\n value = Math.round(value / this.step) * this.step;\n return Number(value.toFixed(this.getPrecision(this.step)));\n }\n\n protected clipSymbol(index: number, isLTR = true) {\n const value = this.hoverState ? this.hoverValue : this.value;\n const progress = index + 1 - value;\n const exclusive = progress === 0 || this.value === index + 1 ? 0 : 1;\n const selection = this.single ? exclusive : progress;\n const activate = (p: number) => clamp(p * 100, 0, 100);\n\n const forward = `inset(0 ${activate(\n isLTR ? selection : 1 - selection\n )}% 0 0)`;\n const backward = `inset(0 0 0 ${activate(\n isLTR ? 1 - selection : selection\n )}%)`;\n\n return {\n backward: isLTR ? backward : forward,\n forward: isLTR ? forward : backward,\n };\n }\n\n /**\n * Increments the value of the control by `n` steps multiplied by the\n * step factor.\n */\n public stepUp(n = 1) {\n this.value += this.round(n * this.step);\n }\n\n /**\n * Decrements the value of the control by `n` steps multiplied by\n * the step factor.\n */\n public stepDown(n = 1) {\n this.value -= this.round(n * this.step);\n }\n\n protected *renderSymbols() {\n const ltr = isLTR(this);\n for (let i = 0; i < this.max; i++) {\n const { forward, backward } = this.clipSymbol(i, ltr);\n yield html`<igc-rating-symbol exportparts=\"symbol, full, empty\">\n <igc-icon\n collection=\"internal\"\n name=\"star\"\n style=${styleMap({ clipPath: forward })}\n ></igc-icon>\n <igc-icon\n collection=\"internal\"\n name=\"star_border\"\n style=${styleMap({ clipPath: backward })}\n slot=\"empty\"\n ></igc-icon>\n </igc-rating-symbol>`;\n }\n }\n\n protected clipProjected() {\n if (this.hasProjectedSymbols) {\n const ltr = isLTR(this);\n this.ratingSymbols.forEach((symbol: IgcRatingSymbolComponent, i) => {\n const full = symbol.shadowRoot?.querySelector(\n '[part=\"symbol full\"]'\n ) as HTMLElement;\n\n const empty = symbol.shadowRoot?.querySelector(\n '[part=\"symbol empty\"]'\n ) as HTMLElement;\n const { forward, backward } = this.clipSymbol(i, ltr);\n\n if (full) {\n full.style.clipPath = forward;\n }\n\n if (empty) {\n empty.style.clipPath = backward;\n }\n });\n }\n }\n\n protected override render() {\n const props = [\n this.value,\n this.hoverValue,\n this.max,\n this.step,\n this.single,\n this.hoverState,\n this.ratingSymbols,\n ];\n\n return html`\n <label part=\"label\" id=\"rating-label\" ?hidden=${!this.label}\n >${this.label}</label\n >\n <div\n part=\"base\"\n role=\"slider\"\n tabindex=${ifDefined(this.disabled ? undefined : 0)}\n aria-labelledby=\"rating-label\"\n aria-valuemin=\"0\"\n aria-valuenow=${this.value}\n aria-valuemax=${this.max}\n aria-valuetext=${this.valueText}\n >\n <div\n aria-hidden=\"true\"\n part=\"symbols\"\n @click=${this.handleClick}\n @mouseenter=${this.hoverPreview ? this.handleMouseEnter : nothing}\n @mouseleave=${this.hoverPreview ? this.handleMouseLeave : nothing}\n @mousemove=${this.hoverPreview ? this.handleMouseMove : nothing}\n >\n <slot @slotchange=${this.handleSlotChange}>\n ${guard(props, () => {\n this.clipProjected();\n return this.renderSymbols();\n })}\n </slot>\n </div>\n <label part=\"value-label\" ?hidden=${this.valueLabel.length === 0}>\n <slot name=\"value-label\"></slot>\n </label>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-rating': IgcRatingComponent;\n }\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import IgcDropdownGroupComponent from '../dropdown/dropdown-group.js';
|
|
2
|
+
import IgcSelectItemComponent from './select-item.js';
|
|
3
|
+
/**
|
|
4
|
+
* @element igc-select-group - A container for a group of `igc-select-item` components.
|
|
5
|
+
*
|
|
6
|
+
* @slot label - Contains the group's label.
|
|
7
|
+
* @slot - Intended to contain the items belonging to this group.
|
|
8
|
+
*
|
|
9
|
+
* @csspart label - The native label element.
|
|
10
|
+
*/
|
|
11
|
+
export default class IgcSelectGroupComponent extends IgcDropdownGroupComponent {
|
|
12
|
+
/** @private */
|
|
13
|
+
static readonly tagName = "igc-select-group";
|
|
14
|
+
private observer;
|
|
15
|
+
private controlledItems;
|
|
16
|
+
/** All child `igc-select-item`s. */
|
|
17
|
+
items: Array<IgcSelectItemComponent>;
|
|
18
|
+
protected activeItems: Array<IgcSelectItemComponent>;
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
constructor();
|
|
21
|
+
disconnectedCallback(): void;
|
|
22
|
+
protected getParent(): import("./select.js").default;
|
|
23
|
+
protected firstUpdated(): Promise<void>;
|
|
24
|
+
protected updateControlledItems(mutations: MutationRecord[]): void;
|
|
25
|
+
protected updateDisabled(): void;
|
|
26
|
+
}
|
|
27
|
+
declare global {
|
|
28
|
+
interface HTMLElementTagNameMap {
|
|
29
|
+
'igc-select-group': IgcSelectGroupComponent;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
import { property, queryAssignedElements } from 'lit/decorators.js';
|
|
8
|
+
import { watch } from '../common/decorators/watch.js';
|
|
9
|
+
import IgcDropdownGroupComponent from '../dropdown/dropdown-group.js';
|
|
10
|
+
export default class IgcSelectGroupComponent extends IgcDropdownGroupComponent {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.disabled = false;
|
|
14
|
+
this.observer = new MutationObserver(this.updateControlledItems.bind(this));
|
|
15
|
+
}
|
|
16
|
+
disconnectedCallback() {
|
|
17
|
+
this.observer.disconnect();
|
|
18
|
+
}
|
|
19
|
+
getParent() {
|
|
20
|
+
return this.closest('igc-select');
|
|
21
|
+
}
|
|
22
|
+
async firstUpdated() {
|
|
23
|
+
await this.updateComplete;
|
|
24
|
+
this.controlledItems = this.activeItems;
|
|
25
|
+
this.setAttribute('role', 'presentation');
|
|
26
|
+
this.items.forEach((i) => {
|
|
27
|
+
this.observer.observe(i, {
|
|
28
|
+
attributes: true,
|
|
29
|
+
attributeFilter: ['disabled'],
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
this.updateDisabled();
|
|
33
|
+
}
|
|
34
|
+
updateControlledItems(mutations) {
|
|
35
|
+
mutations.forEach((mutation) => {
|
|
36
|
+
const item = mutation.target;
|
|
37
|
+
if (!this.disabled) {
|
|
38
|
+
this.controlledItems = this.activeItems;
|
|
39
|
+
}
|
|
40
|
+
if (this.disabled && !item.disabled) {
|
|
41
|
+
item.disabled = true;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
updateDisabled() {
|
|
46
|
+
var _a;
|
|
47
|
+
this.disabled
|
|
48
|
+
? this.setAttribute('aria-disabled', 'true')
|
|
49
|
+
: this.removeAttribute('aria-disabled');
|
|
50
|
+
(_a = this.controlledItems) === null || _a === void 0 ? void 0 : _a.forEach((i) => (i.disabled = this.disabled));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
IgcSelectGroupComponent.tagName = 'igc-select-group';
|
|
54
|
+
__decorate([
|
|
55
|
+
queryAssignedElements({ flatten: true, selector: 'igc-select-item' })
|
|
56
|
+
], IgcSelectGroupComponent.prototype, "items", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
queryAssignedElements({
|
|
59
|
+
flatten: true,
|
|
60
|
+
selector: 'igc-select-item:not([disabled])',
|
|
61
|
+
})
|
|
62
|
+
], IgcSelectGroupComponent.prototype, "activeItems", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
property({ reflect: true, type: Boolean })
|
|
65
|
+
], IgcSelectGroupComponent.prototype, "disabled", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
watch('disabled', { waitUntilFirstUpdate: true })
|
|
68
|
+
], IgcSelectGroupComponent.prototype, "updateDisabled", null);
|
|
69
|
+
//# sourceMappingURL=select-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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EvD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAClB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC;aACzC;YAED,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAGS,cAAc;;QACtB,IAAI,CAAC,QAAQ;YACX,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC;YAC5C,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;QAE1C,MAAA,IAAI,CAAC,eAAe,0CAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrE,CAAC;;AApE+B,+BAAO,GAAG,kBAAkB,CAAC;AAO7D;IADC,qBAAqB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC;sDAChB;AAMtD;IAJC,qBAAqB,CAAC;QACrB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,iCAAiC;KAC5C,CAAC;4DACoD;AAGtD;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yDACnB;AA8CxB;IADC,KAAK,CAAC,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;6DAOjD","sourcesContent":["import { property, queryAssignedElements } from 'lit/decorators.js';\nimport { watch } from '../common/decorators/watch.js';\nimport IgcDropdownGroupComponent from '../dropdown/dropdown-group.js';\nimport IgcSelectItemComponent from './select-item.js';\n\n/**\n * @element igc-select-group - A container for a group of `igc-select-item` components.\n *\n * @slot label - Contains the group's label.\n * @slot - Intended to contain the items belonging to this group.\n *\n * @csspart label - The native label element.\n */\nexport default class IgcSelectGroupComponent extends IgcDropdownGroupComponent {\n /** @private */\n public static override readonly tagName = 'igc-select-group';\n\n private observer!: MutationObserver;\n private controlledItems!: Array<IgcSelectItemComponent>;\n\n /** All child `igc-select-item`s. */\n @queryAssignedElements({ flatten: true, selector: 'igc-select-item' })\n public override items!: Array<IgcSelectItemComponent>;\n\n @queryAssignedElements({\n flatten: true,\n selector: 'igc-select-item:not([disabled])',\n })\n protected activeItems!: Array<IgcSelectItemComponent>;\n\n @property({ reflect: true, type: Boolean })\n public disabled = false;\n\n constructor() {\n super();\n\n this.observer = new MutationObserver(this.updateControlledItems.bind(this));\n }\n\n public override disconnectedCallback() {\n this.observer.disconnect();\n }\n\n protected override getParent() {\n return this.closest('igc-select')!;\n }\n\n protected override async firstUpdated() {\n await this.updateComplete;\n this.controlledItems = this.activeItems;\n this.setAttribute('role', 'presentation');\n\n this.items.forEach((i) => {\n this.observer.observe(i, {\n attributes: true,\n attributeFilter: ['disabled'],\n });\n });\n\n this.updateDisabled();\n }\n\n protected updateControlledItems(mutations: MutationRecord[]) {\n mutations.forEach((mutation) => {\n const item = mutation.target as IgcSelectItemComponent;\n\n if (!this.disabled) {\n this.controlledItems = this.activeItems;\n }\n\n if (this.disabled && !item.disabled) {\n item.disabled = true;\n }\n });\n }\n\n @watch('disabled', { waitUntilFirstUpdate: true })\n protected updateDisabled() {\n this.disabled\n ? this.setAttribute('aria-disabled', 'true')\n : this.removeAttribute('aria-disabled');\n\n this.controlledItems?.forEach((i) => (i.disabled = this.disabled));\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-select-group': IgcSelectGroupComponent;\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import IgcDropdownHeaderComponent from '../dropdown/dropdown-header.js';
|
|
2
|
+
/**
|
|
3
|
+
* @element igc-select-header - Represents a header item in a select component.
|
|
4
|
+
*
|
|
5
|
+
* @slot - Renders the header.
|
|
6
|
+
*/
|
|
7
|
+
export default class IgcSelectHeaderComponent extends IgcDropdownHeaderComponent {
|
|
8
|
+
/** @private */
|
|
9
|
+
static readonly tagName = "igc-select-header";
|
|
10
|
+
}
|
|
11
|
+
declare global {
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
'igc-select-header': IgcSelectHeaderComponent;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-header.js","sourceRoot":"","sources":["../../../src/components/select/select-header.ts"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,MAAM,gCAAgC,CAAC;AAOxE,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,0BAA0B;;AAE9C,gCAAO,GAAG,mBAAmB,CAAC","sourcesContent":["import IgcDropdownHeaderComponent from '../dropdown/dropdown-header.js';\n\n/**\n * @element igc-select-header - Represents a header item in a select component.\n *\n * @slot - Renders the header.\n */\nexport default class IgcSelectHeaderComponent extends IgcDropdownHeaderComponent {\n /** @private */\n public static override readonly tagName = 'igc-select-header';\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-select-header': IgcSelectHeaderComponent;\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import IgcDropdownItemComponent from '../dropdown/dropdown-item.js';
|
|
2
|
+
/**
|
|
3
|
+
* Represents an item in a select list.
|
|
4
|
+
*
|
|
5
|
+
* @element igc-select-item
|
|
6
|
+
*
|
|
7
|
+
* @slot - Renders the all content bar the prefix and suffix.
|
|
8
|
+
* @slot prefix - Renders content before the main content area.
|
|
9
|
+
* @slot suffix - Renders content after the main content area.
|
|
10
|
+
*
|
|
11
|
+
* @csspart prefix - The prefix wrapper.
|
|
12
|
+
* @csspart content - The main content wrapper.
|
|
13
|
+
* @csspart suffix - The suffix wrapper.
|
|
14
|
+
*/
|
|
15
|
+
export default class IgcSelectItemComponent extends IgcDropdownItemComponent {
|
|
16
|
+
private content;
|
|
17
|
+
/** @private */
|
|
18
|
+
static readonly tagName = "igc-select-item";
|
|
19
|
+
constructor();
|
|
20
|
+
protected activeChange(): void;
|
|
21
|
+
/** Returns the text of the item without the prefix and suffix content. */
|
|
22
|
+
get textContent(): string;
|
|
23
|
+
/** Sets the textContent of the item without touching the prefix and suffix content. */
|
|
24
|
+
set textContent(value: string);
|
|
25
|
+
}
|
|
26
|
+
declare global {
|
|
27
|
+
interface HTMLElementTagNameMap {
|
|
28
|
+
'igc-select-item': IgcSelectItemComponent;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
import { queryAssignedNodes } from 'lit/decorators.js';
|
|
8
|
+
import { watch } from '../common/decorators/watch.js';
|
|
9
|
+
import IgcDropdownItemComponent from '../dropdown/dropdown-item.js';
|
|
10
|
+
export default class IgcSelectItemComponent extends IgcDropdownItemComponent {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
}
|
|
14
|
+
activeChange() {
|
|
15
|
+
this.tabIndex = this.active ? 0 : -1;
|
|
16
|
+
if (this.active) {
|
|
17
|
+
this.focus();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
get textContent() {
|
|
21
|
+
return this.content
|
|
22
|
+
.map((t) => { var _a; return (_a = t.textContent) === null || _a === void 0 ? void 0 : _a.trim(); })
|
|
23
|
+
.filter((t) => t !== '')
|
|
24
|
+
.join(' ');
|
|
25
|
+
}
|
|
26
|
+
set textContent(value) {
|
|
27
|
+
const text = new Text(value);
|
|
28
|
+
this.content.forEach((n) => n.remove());
|
|
29
|
+
this.appendChild(text);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
IgcSelectItemComponent.tagName = 'igc-select-item';
|
|
33
|
+
__decorate([
|
|
34
|
+
queryAssignedNodes({ flatten: true })
|
|
35
|
+
], IgcSelectItemComponent.prototype, "content", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
watch('active')
|
|
38
|
+
], IgcSelectItemComponent.prototype, "activeChange", null);
|
|
39
|
+
//# sourceMappingURL=select-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-item.js","sourceRoot":"","sources":["../../../src/components/select/select-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,wBAAwB,MAAM,8BAA8B,CAAC;AAepE,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,wBAAwB;IAO1E;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAGS,YAAY;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAErC,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,KAAK,EAAE,CAAC;SACd;IACH,CAAC;IAGD,IAAoB,WAAW;QAC7B,OAAO,IAAI,CAAC,OAAO;aAChB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,MAAA,CAAC,CAAC,WAAW,0CAAE,IAAI,EAAE,CAAA,EAAA,CAAC;aACjC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;aACvB,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAGD,IAAoB,WAAW,CAAC,KAAa;QAC3C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;;AA5B+B,8BAAO,GAAG,iBAAiB,CAAC;AAH5D;IADC,kBAAkB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uDACL;AAUjC;IADC,KAAK,CAAC,QAAQ,CAAC;0DAOf","sourcesContent":["import { queryAssignedNodes } from 'lit/decorators.js';\nimport { watch } from '../common/decorators/watch.js';\nimport IgcDropdownItemComponent from '../dropdown/dropdown-item.js';\n\n/**\n * Represents an item in a select list.\n *\n * @element igc-select-item\n *\n * @slot - Renders the all content bar the prefix and suffix.\n * @slot prefix - Renders content before the main content area.\n * @slot suffix - Renders content after the main content area.\n *\n * @csspart prefix - The prefix wrapper.\n * @csspart content - The main content wrapper.\n * @csspart suffix - The suffix wrapper.\n */\nexport default class IgcSelectItemComponent extends IgcDropdownItemComponent {\n @queryAssignedNodes({ flatten: true })\n private content!: Array<Element>;\n\n /** @private */\n public static override readonly tagName = 'igc-select-item';\n\n constructor() {\n super();\n }\n\n @watch('active')\n protected activeChange() {\n this.tabIndex = this.active ? 0 : -1;\n\n if (this.active) {\n this.focus();\n }\n }\n\n /** Returns the text of the item without the prefix and suffix content. */\n public override get textContent() {\n return this.content\n .map((t) => t.textContent?.trim())\n .filter((t) => t !== '')\n .join(' ');\n }\n\n /** Sets the textContent of the item without touching the prefix and suffix content. */\n public override set textContent(value: string) {\n const text = new Text(value);\n this.content.forEach((n) => n.remove());\n this.appendChild(text);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-select-item': IgcSelectItemComponent;\n }\n}\n"]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Constructor } from '../common/mixins/constructor.js';
|
|
2
|
+
import IgcDropdownComponent, { IgcDropdownEventMap } from '../dropdown/dropdown.js';
|
|
3
|
+
import IgcInputComponent from '../input/input.js';
|
|
4
|
+
import IgcSelectGroupComponent from './select-group.js';
|
|
5
|
+
import IgcSelectItemComponent from './select-item.js';
|
|
6
|
+
export interface IgcSelectEventMap extends IgcDropdownEventMap {
|
|
7
|
+
igcFocus: CustomEvent<void>;
|
|
8
|
+
igcBlur: CustomEvent<void>;
|
|
9
|
+
}
|
|
10
|
+
declare const IgcSelectComponent_base: import("../common/mixins/constructor.js").AbstractConstructor<import("../common/mixins/event-emitter.js").EventEmitterInterface<IgcSelectEventMap>> & Constructor<IgcDropdownComponent>;
|
|
11
|
+
/**
|
|
12
|
+
* @element igc-select
|
|
13
|
+
*
|
|
14
|
+
* @slot - Renders the list of select items.
|
|
15
|
+
* @slot prefix - Renders content before the input.
|
|
16
|
+
* @slot suffix - Renders content after input.
|
|
17
|
+
* @slot header - Renders a container before the list of options.
|
|
18
|
+
* @slot footer - Renders a container after the list of options.
|
|
19
|
+
* @slot helper-text - Renders content below the input.
|
|
20
|
+
* @slot toggle-icon - Renders content inside the suffix container.
|
|
21
|
+
*
|
|
22
|
+
* @fires igcFocus - Emitted when the select gains focus.
|
|
23
|
+
* @fires igcBlur - Emitted when the select loses focus.
|
|
24
|
+
* @fires igcChange - Emitted when the control's checked state changes.
|
|
25
|
+
* @fires igcOpening - Emitted just before the list of options is opened.
|
|
26
|
+
* @fires igcOpened - Emitted after the list of options is opened.
|
|
27
|
+
* @fires igcClosing - Emitter just before the list of options is closed.
|
|
28
|
+
* @fires igcClosed - Emitted after the list of options is closed.
|
|
29
|
+
*
|
|
30
|
+
* @csspart list - The list of options wrapper.
|
|
31
|
+
* @csspart input - The encapsulated igc-input.
|
|
32
|
+
* @csspart label - The encapsulated text label.
|
|
33
|
+
* @csspart prefix - The prefix wrapper.
|
|
34
|
+
* @csspart suffix - The suffix wrapper.
|
|
35
|
+
* @csspart toggle-icon - The toggle icon wrapper.
|
|
36
|
+
* @csspart helper-text - The helper text wrapper.
|
|
37
|
+
*/
|
|
38
|
+
export default class IgcSelectComponent extends IgcSelectComponent_base {
|
|
39
|
+
/** @private */
|
|
40
|
+
static readonly tagName = "igc-select";
|
|
41
|
+
static styles: import("lit").CSSResult;
|
|
42
|
+
private searchTerm;
|
|
43
|
+
private lastKeyTime;
|
|
44
|
+
private readonly targetKeyHandlers;
|
|
45
|
+
protected items: Array<IgcSelectItemComponent>;
|
|
46
|
+
protected groups: Array<IgcSelectGroupComponent>;
|
|
47
|
+
protected helperText: Array<HTMLElement>;
|
|
48
|
+
protected inputSuffix: Array<HTMLElement>;
|
|
49
|
+
protected inputPrefix: Array<HTMLElement>;
|
|
50
|
+
protected selectedItem: IgcSelectItemComponent | null;
|
|
51
|
+
protected target: IgcInputComponent;
|
|
52
|
+
/** The value attribute of the control. */
|
|
53
|
+
value?: string | undefined;
|
|
54
|
+
/** The name attribute of the control. */
|
|
55
|
+
name: string;
|
|
56
|
+
/** The disabled attribute of the control. */
|
|
57
|
+
disabled: boolean;
|
|
58
|
+
/** The required attribute of the control. */
|
|
59
|
+
required: boolean;
|
|
60
|
+
/** The invalid attribute of the control. */
|
|
61
|
+
invalid: boolean;
|
|
62
|
+
/** The outlined attribute of the control. */
|
|
63
|
+
outlined: boolean;
|
|
64
|
+
/** The autofocus attribute of the control. */
|
|
65
|
+
autofocus: boolean;
|
|
66
|
+
/** The label attribute of the control. */
|
|
67
|
+
label: string;
|
|
68
|
+
/** The placeholder attribute of the control. */
|
|
69
|
+
placeholder: string;
|
|
70
|
+
/** Whether the dropdown's width should be the same as the target's one. */
|
|
71
|
+
sameWidth: boolean;
|
|
72
|
+
/** The direction attribute of the control. */
|
|
73
|
+
dir: 'ltr' | 'rtl' | 'auto';
|
|
74
|
+
constructor();
|
|
75
|
+
/** Override the dropdown target focusout behavior to prevent the focus from
|
|
76
|
+
* being returned to the target element when the select loses focus. */
|
|
77
|
+
protected handleFocusout(): void;
|
|
78
|
+
/** Sets focus on the component. */
|
|
79
|
+
focus(options?: FocusOptions): void;
|
|
80
|
+
/** Removes focus from the component. */
|
|
81
|
+
blur(): void;
|
|
82
|
+
/** Checks the validity of the control. */
|
|
83
|
+
reportValidity(): boolean;
|
|
84
|
+
firstUpdated(): Promise<void>;
|
|
85
|
+
protected updateValue(): void;
|
|
86
|
+
protected updateSelected(): void;
|
|
87
|
+
protected validate(): void;
|
|
88
|
+
protected selectNext(): void;
|
|
89
|
+
protected selectPrev(): void;
|
|
90
|
+
protected selectInteractiveItem(index: number): void;
|
|
91
|
+
protected searchItem(event: KeyboardEvent): void;
|
|
92
|
+
protected handleFocus(): void;
|
|
93
|
+
protected handleBlur(): void;
|
|
94
|
+
protected onTargetTabKey(): void;
|
|
95
|
+
protected onTargetEnterKey(): void;
|
|
96
|
+
protected onTargetArrowLeftKeyDown(): void;
|
|
97
|
+
protected onTargetArrowRightKeyDown(): void;
|
|
98
|
+
protected onTargetArrowUpKeyDown(event: KeyboardEvent): void;
|
|
99
|
+
protected onTargetArrowDownKeyDown(event: KeyboardEvent): void;
|
|
100
|
+
protected onTargetHomeKey(): void;
|
|
101
|
+
protected onTargetEndKey(): void;
|
|
102
|
+
protected handleTargetKeyDown(event: KeyboardEvent): void;
|
|
103
|
+
protected get hasPrefixes(): boolean;
|
|
104
|
+
protected get hasSuffixes(): boolean;
|
|
105
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
106
|
+
}
|
|
107
|
+
declare global {
|
|
108
|
+
interface HTMLElementTagNameMap {
|
|
109
|
+
'igc-select': IgcSelectComponent;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export {};
|