@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.78 → 2.0.0-next.80
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/.storybook/vitest.setup.ts +24 -0
- package/bundle/openbridge-webcomponents.bundle.js +95 -10
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +97 -5
- package/dist/components/alert-frame/alert-frame.css.js +9 -0
- package/dist/components/alert-frame/alert-frame.css.js.map +1 -1
- package/dist/components/alert-frame/alert-frame.d.ts +6 -1
- package/dist/components/alert-frame/alert-frame.d.ts.map +1 -1
- package/dist/components/alert-frame/alert-frame.js +7 -1
- package/dist/components/alert-frame/alert-frame.js.map +1 -1
- package/dist/components/input/input.d.ts +1 -0
- package/dist/components/input/input.d.ts.map +1 -0
- package/dist/components/input/input.js +2 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/pagination/pagination.d.ts +9 -0
- package/dist/components/pagination/pagination.d.ts.map +1 -1
- package/dist/components/pagination/pagination.js +12 -2
- package/dist/components/pagination/pagination.js.map +1 -1
- package/dist/components/slider/slider.d.ts +14 -1
- package/dist/components/slider/slider.d.ts.map +1 -1
- package/dist/components/slider/slider.js +17 -0
- package/dist/components/slider/slider.js.map +1 -1
- package/dist/components/slider-double/slider-double.d.ts +17 -1
- package/dist/components/slider-double/slider-double.d.ts.map +1 -1
- package/dist/components/slider-double/slider-double.js +15 -0
- package/dist/components/slider-double/slider-double.js.map +1 -1
- package/dist/components/toggle-button-group/toggle-button-group.d.ts +4 -0
- package/dist/components/toggle-button-group/toggle-button-group.d.ts.map +1 -1
- package/dist/components/toggle-button-group/toggle-button-group.js +15 -3
- package/dist/components/toggle-button-group/toggle-button-group.js.map +1 -1
- package/dist/components/toggle-button-vertical-group/toggle-button-vertical-group.d.ts +4 -0
- package/dist/components/toggle-button-vertical-group/toggle-button-vertical-group.d.ts.map +1 -1
- package/dist/components/toggle-button-vertical-group/toggle-button-vertical-group.js +10 -3
- package/dist/components/toggle-button-vertical-group/toggle-button-vertical-group.js.map +1 -1
- package/dist/components/toggle-switch/toggle-switch.d.ts +2 -0
- package/dist/components/toggle-switch/toggle-switch.d.ts.map +1 -1
- package/dist/components/toggle-switch/toggle-switch.js +8 -0
- package/dist/components/toggle-switch/toggle-switch.js.map +1 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.d.ts.map +1 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.js +2 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.js.map +1 -1
- package/package.json +1 -1
- package/src/components/alert-frame/alert-frame.css +9 -0
- package/src/components/alert-frame/alert-frame.ts +10 -1
- package/src/components/input/input.ts +0 -0
- package/src/components/pagination/pagination.ts +25 -2
- package/src/components/slider/slider.ts +27 -1
- package/src/components/slider-double/slider-double.ts +28 -1
- package/src/components/toggle-button-group/toggle-button-group.ts +26 -3
- package/src/components/toggle-button-vertical-group/toggle-button-vertical-group.ts +28 -3
- package/src/components/toggle-switch/toggle-switch.ts +10 -0
- package/src/navigation-instruments/readout-list-item/readout-list-item.ts +2 -1
- package/vitest.config.ts +6 -0
|
@@ -198,6 +198,12 @@ export class ObcAlertFrame extends LitElement {
|
|
|
198
198
|
*/
|
|
199
199
|
@property({type: Boolean, reflect: true}) wrapContent: boolean = false;
|
|
200
200
|
|
|
201
|
+
/**
|
|
202
|
+
* When true, the frame stretches to fill the full width of its container
|
|
203
|
+
* instead of hugging its content. Reflected to an attribute for CSS styling.
|
|
204
|
+
*/
|
|
205
|
+
@property({type: Boolean, reflect: true}) fullWidth: boolean = false;
|
|
206
|
+
|
|
201
207
|
/**
|
|
202
208
|
* If true, the top-left corner will be sharp (not rounded).
|
|
203
209
|
*/
|
|
@@ -231,6 +237,7 @@ export class ObcAlertFrame extends LitElement {
|
|
|
231
237
|
class=${classMap({
|
|
232
238
|
wrapper: true,
|
|
233
239
|
'wrap-content': this.wrapContent,
|
|
240
|
+
'full-width': this.fullWidth,
|
|
234
241
|
['thickness-' + this.thickness]: true,
|
|
235
242
|
[this.type]: true,
|
|
236
243
|
[this.status]: true,
|
|
@@ -339,7 +346,8 @@ export class ObcAlertFrame extends LitElement {
|
|
|
339
346
|
|
|
340
347
|
export function wrapWithAlertFrame(
|
|
341
348
|
options: AlertFrameConfig | boolean | undefined,
|
|
342
|
-
content: HTMLTemplateResult
|
|
349
|
+
content: HTMLTemplateResult,
|
|
350
|
+
fullWidth: boolean = false
|
|
343
351
|
): HTMLTemplateResult {
|
|
344
352
|
if (typeof options !== 'object' || options === null) {
|
|
345
353
|
return content;
|
|
@@ -352,6 +360,7 @@ export function wrapWithAlertFrame(
|
|
|
352
360
|
.showIcon=${options.showIcon ?? false}
|
|
353
361
|
.showAlertCategoryIcon=${options.showAlertCategoryIcon ?? true}
|
|
354
362
|
.wrapContent=${true}
|
|
363
|
+
.fullWidth=${fullWidth}
|
|
355
364
|
>${content}</obc-alert-frame
|
|
356
365
|
>`;
|
|
357
366
|
}
|
|
File without changes
|
|
@@ -42,6 +42,14 @@ export type ObcPaginationNavigateEvent = CustomEvent<{
|
|
|
42
42
|
currentPage: number;
|
|
43
43
|
}>;
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Event fired when a page is selected.
|
|
47
|
+
* @event
|
|
48
|
+
*/
|
|
49
|
+
export type ObcPaginationSelectPageEvent = CustomEvent<{
|
|
50
|
+
page: number;
|
|
51
|
+
}>;
|
|
52
|
+
|
|
45
53
|
/**
|
|
46
54
|
* `obc-pagination` – page navigation component for traversing multi-page content.
|
|
47
55
|
*
|
|
@@ -97,9 +105,11 @@ export type ObcPaginationNavigateEvent = CustomEvent<{
|
|
|
97
105
|
*
|
|
98
106
|
* - `value` – Fired when the current page changes (via user interaction).
|
|
99
107
|
* - `navigate` – Fired when a navigation arrow (first, previous, next, last) is clicked.
|
|
108
|
+
* - `select-page` – Fired when a specific page is selected.
|
|
100
109
|
*
|
|
101
110
|
* @fires value {ObcPaginationValueChangeEvent} Emitted whenever the current page changes.
|
|
102
111
|
* @fires navigate {ObcPaginationNavigateEvent} Emitted when a navigation arrow is clicked.
|
|
112
|
+
* @fires select-page {ObcPaginationSelectPageEvent} Emitted when a specific page is selected.
|
|
103
113
|
*/
|
|
104
114
|
@customElement('obc-pagination')
|
|
105
115
|
export class ObcPagination extends LitElement {
|
|
@@ -195,13 +205,18 @@ export class ObcPagination extends LitElement {
|
|
|
195
205
|
|
|
196
206
|
private setCurrentPage(newPage: number) {
|
|
197
207
|
const page = Math.max(1, Math.min(newPage, this.validatedPages));
|
|
198
|
-
if (page === this.currentPage)
|
|
208
|
+
if (page === this.currentPage) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
|
|
199
212
|
this.currentPage = page;
|
|
200
213
|
this.dispatchEvent(
|
|
201
214
|
new CustomEvent('value', {
|
|
202
215
|
detail: {value: page},
|
|
203
216
|
}) as ObcPaginationValueChangeEvent
|
|
204
217
|
);
|
|
218
|
+
|
|
219
|
+
return true;
|
|
205
220
|
}
|
|
206
221
|
|
|
207
222
|
private dispatchNavigateEvent(
|
|
@@ -215,7 +230,15 @@ export class ObcPagination extends LitElement {
|
|
|
215
230
|
}
|
|
216
231
|
|
|
217
232
|
private handlePageChange = (event: CustomEvent<{value: string}>) => {
|
|
218
|
-
this.setCurrentPage(Number(event.detail.value));
|
|
233
|
+
const success = this.setCurrentPage(Number(event.detail.value));
|
|
234
|
+
|
|
235
|
+
if (success) {
|
|
236
|
+
this.dispatchEvent(
|
|
237
|
+
new CustomEvent('select-page', {
|
|
238
|
+
detail: {page: Number(event.detail.value)},
|
|
239
|
+
}) as ObcPaginationSelectPageEvent
|
|
240
|
+
);
|
|
241
|
+
}
|
|
219
242
|
};
|
|
220
243
|
|
|
221
244
|
private handleFirstClick = () => {
|
|
@@ -26,6 +26,12 @@ export enum ObcSliderVariant {
|
|
|
26
26
|
*/
|
|
27
27
|
export type ObcSliderValueEvent = CustomEvent<number>;
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Custom event type for slider change event (fired after user interaction completes).
|
|
31
|
+
* The event detail contains the new numeric value.
|
|
32
|
+
*/
|
|
33
|
+
export type ObcSliderChangeEvent = CustomEvent<number>;
|
|
34
|
+
|
|
29
35
|
/**
|
|
30
36
|
* `<obc-slider>` – A horizontal slider component for selecting a numeric value within a defined range.
|
|
31
37
|
*
|
|
@@ -85,7 +91,8 @@ export type ObcSliderValueEvent = CustomEvent<number>;
|
|
|
85
91
|
* ---
|
|
86
92
|
*
|
|
87
93
|
* ### Events
|
|
88
|
-
* - `value` – Fired when the slider value changes
|
|
94
|
+
* - `value` – Fired continuously when the slider value changes during user interaction or programmatically. The event detail contains the new value as a number.
|
|
95
|
+
* - `change` – Fired only after user interaction completes (mouse/touch release or button click). The event detail contains the new value as a number.
|
|
89
96
|
*
|
|
90
97
|
* ---
|
|
91
98
|
*
|
|
@@ -121,6 +128,7 @@ export type ObcSliderValueEvent = CustomEvent<number>;
|
|
|
121
128
|
* @slot icon-right - Slot for the right icon button (shown when `hasRightIcon` is true)
|
|
122
129
|
* @attr hugcontainer - If set, the slider will not have any spacing between the slider icons and the container
|
|
123
130
|
* @fires value {ObcSliderValueEvent} - Fired when the value is changed
|
|
131
|
+
* @fires change {ObcSliderChangeEvent} - Fired when user interaction completes and value has changed
|
|
124
132
|
*/
|
|
125
133
|
@customElement('obc-slider')
|
|
126
134
|
export class ObcSlider extends LitElement {
|
|
@@ -233,12 +241,24 @@ export class ObcSlider extends LitElement {
|
|
|
233
241
|
this.dispatchEvent(new CustomEvent('value', {detail: this.value}));
|
|
234
242
|
}
|
|
235
243
|
|
|
244
|
+
/**
|
|
245
|
+
* Fires the `change` event with the current value.
|
|
246
|
+
*
|
|
247
|
+
* @fires change
|
|
248
|
+
*/
|
|
249
|
+
private fireChangeEvent() {
|
|
250
|
+
this.dispatchEvent(
|
|
251
|
+
new CustomEvent('change', {detail: this.value}) as ObcSliderChangeEvent
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
236
255
|
/**
|
|
237
256
|
* Decrements the value by `stepClick` when the left icon button is clicked.
|
|
238
257
|
*/
|
|
239
258
|
onReduceClick() {
|
|
240
259
|
if (this.disabled) return;
|
|
241
260
|
this.onInput(Math.max(this.value - this.stepClick, this.min));
|
|
261
|
+
this.fireChangeEvent();
|
|
242
262
|
}
|
|
243
263
|
|
|
244
264
|
/**
|
|
@@ -247,6 +267,7 @@ export class ObcSlider extends LitElement {
|
|
|
247
267
|
onIncreaseClick() {
|
|
248
268
|
if (this.disabled) return;
|
|
249
269
|
this.onInput(Math.min(this.value + this.stepClick, this.max));
|
|
270
|
+
this.fireChangeEvent();
|
|
250
271
|
}
|
|
251
272
|
|
|
252
273
|
private get slider(): HTMLInputElement {
|
|
@@ -329,6 +350,7 @@ export class ObcSlider extends LitElement {
|
|
|
329
350
|
window.removeEventListener('mousemove', this.onWindowMouseMove);
|
|
330
351
|
window.removeEventListener('mouseup', this.onWindowMouseUp);
|
|
331
352
|
this.stopAnimation();
|
|
353
|
+
this.fireChangeEvent();
|
|
332
354
|
}
|
|
333
355
|
|
|
334
356
|
private onTouchEnd() {
|
|
@@ -336,6 +358,7 @@ export class ObcSlider extends LitElement {
|
|
|
336
358
|
window.removeEventListener('touchmove', this.onWindowTouchMove);
|
|
337
359
|
window.removeEventListener('touchend', this.onWindowTouchEnd);
|
|
338
360
|
this.stopAnimation();
|
|
361
|
+
this.fireChangeEvent();
|
|
339
362
|
}
|
|
340
363
|
|
|
341
364
|
private updateTargetValue(e: MouseEvent | TouchEvent) {
|
|
@@ -454,6 +477,9 @@ export class ObcSlider extends LitElement {
|
|
|
454
477
|
this.value = Number((event.target as HTMLInputElement).value);
|
|
455
478
|
this.dispatchEvent(new CustomEvent('value', {detail: this.value}));
|
|
456
479
|
}}
|
|
480
|
+
@change=${() => {
|
|
481
|
+
this.fireChangeEvent();
|
|
482
|
+
}}
|
|
457
483
|
@mousedown=${this.onMouseDown}
|
|
458
484
|
@touchstart=${this.onTouchStart}
|
|
459
485
|
@mousemove=${this.onMouseMove}
|
|
@@ -29,6 +29,15 @@ export type ObcSliderDoubleValueEvent = CustomEvent<{
|
|
|
29
29
|
high: number;
|
|
30
30
|
}>;
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Event type for change event in obc-slider-double (fired after user interaction completes).
|
|
34
|
+
* Contains the current low and high values of the slider.
|
|
35
|
+
*/
|
|
36
|
+
export type ObcSliderDoubleChangeEvent = CustomEvent<{
|
|
37
|
+
low: number;
|
|
38
|
+
high: number;
|
|
39
|
+
}>;
|
|
40
|
+
|
|
32
41
|
/**
|
|
33
42
|
* `<obc-slider-double>` – A dual-thumb range slider for selecting a value interval within a defined range.
|
|
34
43
|
*
|
|
@@ -86,7 +95,8 @@ export type ObcSliderDoubleValueEvent = CustomEvent<{
|
|
|
86
95
|
* - `hugcontainer` (attribute): If present, removes spacing between slider and container edges.
|
|
87
96
|
*
|
|
88
97
|
* ## Events
|
|
89
|
-
* - `value` – Fired whenever the low or high value changes. Event detail contains `{low, high}`.
|
|
98
|
+
* - `value` – Fired continuously whenever the low or high value changes during user interaction. Event detail contains `{low, high}`.
|
|
99
|
+
* - `change` – Fired only after user interaction completes (mouse release). Event detail contains `{low, high}`.
|
|
90
100
|
*
|
|
91
101
|
* ## Best Practices and Constraints
|
|
92
102
|
* - Ensure `low` is always less than or equal to `high`; the component enforces this automatically.
|
|
@@ -121,6 +131,7 @@ export type ObcSliderDoubleValueEvent = CustomEvent<{
|
|
|
121
131
|
* @slot left-readout - Custom content for the left (low) readout label (rendered when `showLeftReadout` is true)
|
|
122
132
|
* @slot right-readout - Custom content for the right (high) readout label (rendered when `showRightReadout` is true)
|
|
123
133
|
* @fires value {ObcSliderDoubleValueEvent} - Fires when the value is changed
|
|
134
|
+
* @fires change {ObcSliderDoubleChangeEvent} - Fires when user interaction completes
|
|
124
135
|
*/
|
|
125
136
|
@customElement('obc-slider-double')
|
|
126
137
|
export class ObcSliderDouble extends LitElement {
|
|
@@ -281,6 +292,19 @@ export class ObcSliderDouble extends LitElement {
|
|
|
281
292
|
);
|
|
282
293
|
}
|
|
283
294
|
|
|
295
|
+
/**
|
|
296
|
+
* Fires the `change` event with the current low and high values.
|
|
297
|
+
*
|
|
298
|
+
* @fires change
|
|
299
|
+
*/
|
|
300
|
+
private fireChangeEvent() {
|
|
301
|
+
this.dispatchEvent(
|
|
302
|
+
new CustomEvent('change', {
|
|
303
|
+
detail: {low: this.low, high: this.high},
|
|
304
|
+
}) as ObcSliderDoubleChangeEvent
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
|
|
284
308
|
private THUMB_WIDTH = 48;
|
|
285
309
|
private THUMB_VISIBLE_WIDTH = 12;
|
|
286
310
|
|
|
@@ -389,6 +413,7 @@ export class ObcSliderDouble extends LitElement {
|
|
|
389
413
|
window.removeEventListener('mousemove', this.onWindowMouseMove);
|
|
390
414
|
window.removeEventListener('mouseup', this.onWindowMouseUp);
|
|
391
415
|
this.stopAnimation();
|
|
416
|
+
this.fireChangeEvent();
|
|
392
417
|
}
|
|
393
418
|
|
|
394
419
|
private updateTargetValue(e: MouseEvent) {
|
|
@@ -534,6 +559,7 @@ export class ObcSliderDouble extends LitElement {
|
|
|
534
559
|
?disabled=${this.variant === ObcSliderDoubleVariant.NoInput ||
|
|
535
560
|
this.disabled}
|
|
536
561
|
@input=${this.onInput}
|
|
562
|
+
@change=${() => this.fireChangeEvent()}
|
|
537
563
|
/>
|
|
538
564
|
<input
|
|
539
565
|
type="range"
|
|
@@ -545,6 +571,7 @@ export class ObcSliderDouble extends LitElement {
|
|
|
545
571
|
?disabled=${this.variant === ObcSliderDoubleVariant.NoInput ||
|
|
546
572
|
this.disabled}
|
|
547
573
|
@input=${this.onInput}
|
|
574
|
+
@change=${() => this.fireChangeEvent()}
|
|
548
575
|
/>
|
|
549
576
|
<div class="interactive-track"></div>
|
|
550
577
|
<div class="thumb min"></div>
|
|
@@ -14,6 +14,10 @@ export type ObcToggleButtonGroupValueChangeEvent = CustomEvent<{
|
|
|
14
14
|
previousValue: string;
|
|
15
15
|
}>;
|
|
16
16
|
|
|
17
|
+
export type ObcToggleButtonGroupChangeEvent = CustomEvent<{
|
|
18
|
+
value: string;
|
|
19
|
+
}>;
|
|
20
|
+
|
|
17
21
|
/**
|
|
18
22
|
* `<obc-toggle-button-group>` – A segmented control for selecting a single option from a set (also known as a button group or segmented button).
|
|
19
23
|
*
|
|
@@ -122,6 +126,7 @@ export type ObcToggleButtonGroupValueChangeEvent = CustomEvent<{
|
|
|
122
126
|
*
|
|
123
127
|
* @slot - Place one or more `<obc-toggle-button-option>` elements here to define the selectable options.
|
|
124
128
|
* @fires value {CustomEvent<{value: string, previousValue: string}>} Fired when the selected value changes.
|
|
129
|
+
* @fires change {CustomEvent<{value: string}>} Fired when the selected value changes by user interaction.
|
|
125
130
|
*/
|
|
126
131
|
@customElement('obc-toggle-button-group')
|
|
127
132
|
export class ObcToggleButtonGroup extends LitElement {
|
|
@@ -229,7 +234,11 @@ export class ObcToggleButtonGroup extends LitElement {
|
|
|
229
234
|
return Array.from(this.options).find((opt) => !opt.disabled) || null;
|
|
230
235
|
}
|
|
231
236
|
|
|
232
|
-
private updateSelection(
|
|
237
|
+
private updateSelection(
|
|
238
|
+
newValue: string,
|
|
239
|
+
emitValueEvent: boolean = true,
|
|
240
|
+
emitChangeEvent: boolean = false
|
|
241
|
+
) {
|
|
233
242
|
const oldValue = this.value;
|
|
234
243
|
|
|
235
244
|
if (!this.hasAnyEnabledOption()) {
|
|
@@ -264,13 +273,21 @@ export class ObcToggleButtonGroup extends LitElement {
|
|
|
264
273
|
|
|
265
274
|
this.setNoDivider();
|
|
266
275
|
|
|
267
|
-
if (
|
|
276
|
+
if (emitValueEvent && oldValue !== newValue) {
|
|
268
277
|
this.dispatchEvent(
|
|
269
278
|
new CustomEvent('value', {
|
|
270
279
|
detail: {value: newValue, previousValue: oldValue},
|
|
271
280
|
})
|
|
272
281
|
);
|
|
273
282
|
}
|
|
283
|
+
|
|
284
|
+
if (emitChangeEvent && oldValue !== newValue) {
|
|
285
|
+
this.dispatchEvent(
|
|
286
|
+
new CustomEvent('change', {
|
|
287
|
+
detail: {value: newValue},
|
|
288
|
+
})
|
|
289
|
+
);
|
|
290
|
+
}
|
|
274
291
|
}
|
|
275
292
|
|
|
276
293
|
private updateActivated(newValue: string | undefined) {
|
|
@@ -391,8 +408,14 @@ export class ObcToggleButtonGroup extends LitElement {
|
|
|
391
408
|
detail: {value, previousValue: this.value},
|
|
392
409
|
})
|
|
393
410
|
);
|
|
411
|
+
|
|
412
|
+
this.dispatchEvent(
|
|
413
|
+
new CustomEvent('change', {
|
|
414
|
+
detail: {value},
|
|
415
|
+
})
|
|
416
|
+
);
|
|
394
417
|
} else {
|
|
395
|
-
this.updateSelection(value);
|
|
418
|
+
this.updateSelection(value, true, true);
|
|
396
419
|
}
|
|
397
420
|
}
|
|
398
421
|
|
|
@@ -15,6 +15,10 @@ export type ObcToggleButtonVerticalGroupValueChangeEvent = CustomEvent<{
|
|
|
15
15
|
previousValue: string;
|
|
16
16
|
}>;
|
|
17
17
|
|
|
18
|
+
export type ObcToggleButtonVerticalGroupChangeEvent = CustomEvent<{
|
|
19
|
+
value: string;
|
|
20
|
+
}>;
|
|
21
|
+
|
|
18
22
|
/**
|
|
19
23
|
* `<obc-toggle-button-vertical-group>` – A vertically oriented segmented control for selecting a single option from a set.
|
|
20
24
|
*
|
|
@@ -108,6 +112,7 @@ export type ObcToggleButtonVerticalGroupValueChangeEvent = CustomEvent<{
|
|
|
108
112
|
*
|
|
109
113
|
* @slot - Place one or more `<obc-toggle-button-vertical-option>` elements here to define the selectable options.
|
|
110
114
|
* @fires value {CustomEvent<{value: string, previousValue: string}>} Fired when the selected value changes.
|
|
115
|
+
* @fires change {CustomEvent<{value: string}>} Fired when the selected value changes by user interaction.
|
|
111
116
|
*/
|
|
112
117
|
@customElement('obc-toggle-button-vertical-group')
|
|
113
118
|
export class ObcToggleButtonVerticalGroup extends LitElement {
|
|
@@ -182,7 +187,11 @@ export class ObcToggleButtonVerticalGroup extends LitElement {
|
|
|
182
187
|
return Array.from(this.options).find((opt) => !opt.disabled) || null;
|
|
183
188
|
}
|
|
184
189
|
|
|
185
|
-
private updateSelection(
|
|
190
|
+
private updateSelection(
|
|
191
|
+
newValue: string,
|
|
192
|
+
emitValueEvent: boolean = true,
|
|
193
|
+
emitChangeEvent: boolean = false
|
|
194
|
+
) {
|
|
186
195
|
const oldValue = this.value;
|
|
187
196
|
|
|
188
197
|
if (!this.hasAnyEnabledOption()) {
|
|
@@ -217,7 +226,7 @@ export class ObcToggleButtonVerticalGroup extends LitElement {
|
|
|
217
226
|
|
|
218
227
|
this.updateDividers();
|
|
219
228
|
|
|
220
|
-
if (
|
|
229
|
+
if (emitValueEvent && oldValue !== newValue) {
|
|
221
230
|
/**
|
|
222
231
|
* Fired when the selected option changes.
|
|
223
232
|
*
|
|
@@ -232,6 +241,22 @@ export class ObcToggleButtonVerticalGroup extends LitElement {
|
|
|
232
241
|
})
|
|
233
242
|
);
|
|
234
243
|
}
|
|
244
|
+
|
|
245
|
+
if (emitChangeEvent && oldValue !== newValue) {
|
|
246
|
+
/**
|
|
247
|
+
* Fired when the selected value changes by user interaction.
|
|
248
|
+
*
|
|
249
|
+
* The event detail contains the new value:
|
|
250
|
+
* `{ value: string }`
|
|
251
|
+
*
|
|
252
|
+
* @event change
|
|
253
|
+
*/
|
|
254
|
+
this.dispatchEvent(
|
|
255
|
+
new CustomEvent('change', {
|
|
256
|
+
detail: {value: newValue},
|
|
257
|
+
})
|
|
258
|
+
);
|
|
259
|
+
}
|
|
235
260
|
}
|
|
236
261
|
|
|
237
262
|
protected override firstUpdated(changed: PropertyValues) {
|
|
@@ -350,7 +375,7 @@ export class ObcToggleButtonVerticalGroup extends LitElement {
|
|
|
350
375
|
|
|
351
376
|
private onOptionSelected(e: Event): void {
|
|
352
377
|
const {value} = (e as CustomEvent).detail;
|
|
353
|
-
this.updateSelection(value);
|
|
378
|
+
this.updateSelection(value, true, true);
|
|
354
379
|
}
|
|
355
380
|
|
|
356
381
|
override render() {
|
|
@@ -85,6 +85,7 @@ export type ObcToggleSwitchInputEvent = CustomEvent<{
|
|
|
85
85
|
*
|
|
86
86
|
* @slot icon - Leading icon slot (shown when `hasIcon` is true)
|
|
87
87
|
* @fires input - {ObcToggleSwitchInputEvent} Dispatched when the value of the input changes
|
|
88
|
+
* @fires change - Dispatched when the value of the input changes by user interaction
|
|
88
89
|
*/
|
|
89
90
|
@customElement('obc-toggle-switch')
|
|
90
91
|
export class ObcToggleSwitch extends LitElement {
|
|
@@ -162,6 +163,14 @@ export class ObcToggleSwitch extends LitElement {
|
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
|
|
166
|
+
private _fireChangeEvent(e: Event) {
|
|
167
|
+
if (this.disabled) {
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
this.dispatchEvent(new CustomEvent('change'));
|
|
172
|
+
}
|
|
173
|
+
|
|
165
174
|
override render() {
|
|
166
175
|
return html`
|
|
167
176
|
<label
|
|
@@ -190,6 +199,7 @@ export class ObcToggleSwitch extends LitElement {
|
|
|
190
199
|
.checked=${this.checked}
|
|
191
200
|
?disabled=${this.disabled}
|
|
192
201
|
@input=${this._tryChange}
|
|
202
|
+
@change=${this._fireChangeEvent}
|
|
193
203
|
/>
|
|
194
204
|
</div>
|
|
195
205
|
</div>
|
package/vitest.config.ts
CHANGED
|
@@ -36,6 +36,12 @@ export default defineConfig({
|
|
|
36
36
|
test: {
|
|
37
37
|
name: 'storybook',
|
|
38
38
|
setupFiles: ['./.storybook/vitest.setup.ts'],
|
|
39
|
+
// Retry flaky visual snapshots. A retry re-renders the story and takes
|
|
40
|
+
// a fresh screenshot, which is what lets render-time flakiness (e.g.
|
|
41
|
+
// sub-pixel anti-aliasing of <canvas> charts) settle. See the matching
|
|
42
|
+
// beforeEach in .storybook/vitest.setup.ts, which keeps the retry from
|
|
43
|
+
// masking genuine snapshot regressions.
|
|
44
|
+
retry: 3,
|
|
39
45
|
// Enable browser mode
|
|
40
46
|
browser: {
|
|
41
47
|
enabled: true,
|