Skip to content

Commit 28ba31e

Browse files
committed
Merge remote-tracking branch 'origin/master' into rkaraivanov/theme-controller-migration
2 parents f7f9c96 + 2e7c295 commit 28ba31e

File tree

30 files changed

+460
-301
lines changed

30 files changed

+460
-301
lines changed

package-lock.json

Lines changed: 146 additions & 139 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"lint": "npm run lint:biome && npm run lint:lit-analyzer && npm run lint:prettier && npm run lint:styles",
3636
"lint:biome": "biome lint",
3737
"lint:lit-analyzer": "lit-analyzer",
38-
"lint:prettier": "prettier \"**/*.ts\" --check --ignore-path .gitignore",
38+
"lint:prettier": "prettier \"**/*.ts\" --check --experimental-cli --ignore-path .gitignore",
3939
"lint:styles": "stylelint \"src/**/*.scss\"",
4040
"format": "biome check --fix && prettier \"**/*.ts\" --write --ignore-path .gitignore",
4141
"release": "node scripts/gen-changelog.mjs",
@@ -58,41 +58,41 @@
5858
"lit": "^3.3.0"
5959
},
6060
"devDependencies": {
61-
"@biomejs/biome": "2.0.0",
61+
"@biomejs/biome": "~2.0.4",
6262
"@custom-elements-manifest/analyzer": "^0.10.4",
6363
"@igniteui/material-icons-extended": "^3.1.0",
6464
"@open-wc/testing": "^4.0.0",
65-
"@storybook/addon-a11y": "^9.0.11",
66-
"@storybook/addon-docs": "^9.0.11",
67-
"@storybook/addon-links": "^9.0.11",
68-
"@storybook/web-components-vite": "^9.0.11",
65+
"@storybook/addon-a11y": "^9.0.12",
66+
"@storybook/addon-docs": "^9.0.12",
67+
"@storybook/addon-links": "^9.0.12",
68+
"@storybook/web-components-vite": "^9.0.12",
6969
"@types/mocha": "^10.0.10",
7070
"@web/dev-server-esbuild": "^1.0.4",
7171
"@web/test-runner": "^0.20.2",
7272
"@web/test-runner-playwright": "^0.11.1",
7373
"autoprefixer": "^10.4.21",
7474
"browser-sync": "^3.0.4",
7575
"cem-plugin-expanded-types": "^1.4.0",
76-
"concurrently": "^9.1.2",
76+
"concurrently": "^9.2.0",
7777
"custom-element-jet-brains-integration": "^1.7.0",
7878
"custom-element-vs-code-integration": "^1.5.0",
7979
"globby": "^14.1.0",
8080
"husky": "^9.1.7",
81-
"ig-typedoc-theme": "^6.1.0",
81+
"ig-typedoc-theme": "^6.2.0",
8282
"igniteui-theming": "^19.0.0",
8383
"keep-a-changelog": "^2.6.2",
8484
"lint-staged": "^16.1.2",
8585
"lit-analyzer": "^2.0.3",
8686
"madge": "^8.0.0",
8787
"node-watch": "^0.7.4",
88-
"playwright": "^1.53.0",
88+
"playwright": "^1.53.1",
8989
"postcss": "^8.5.6",
90-
"prettier": "^3.5.3",
90+
"prettier": "^3.6.0",
9191
"rimraf": "^6.0.1",
9292
"sass-embedded": "~1.78.0",
9393
"sinon": "^21.0.0",
94-
"storybook": "^9.0.11",
95-
"stylelint": "^16.20.0",
94+
"storybook": "^9.0.12",
95+
"stylelint": "^16.21.0",
9696
"stylelint-config-standard-scss": "^15.0.1",
9797
"stylelint-prettier": "^5.0.3",
9898
"stylelint-scss": "^6.12.1",

src/components/accordion/accordion.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
shiftKey,
1212
} from '../common/controllers/key-bindings.js';
1313
import { registerComponent } from '../common/definitions/register.js';
14-
import { first, last } from '../common/util.js';
14+
import { addSafeEventListener, first, last } from '../common/util.js';
1515
import IgcExpansionPanelComponent from '../expansion-panel/expansion-panel.js';
1616
import { styles } from './themes/accordion.base.css.js';
1717

@@ -52,7 +52,7 @@ export default class IgcAccordionComponent extends LitElement {
5252
constructor() {
5353
super();
5454

55-
this.addEventListener('igcOpening', this.handlePanelOpening);
55+
addSafeEventListener(this, 'igcOpening' as any, this.handlePanelOpening);
5656

5757
addKeybindings(this, {
5858
skip: this.skipKeybinding,

src/components/button-group/button-group.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default class IgcButtonGroupComponent extends EventEmitterMixin<
6262

6363
const buttons = this.toggleButtons;
6464
const idx = buttons.indexOf(
65-
added.length ? last(added).node : last(attributes)
65+
added.length ? last(added).node : last(attributes).node
6666
);
6767

6868
for (const [i, button] of buttons.entries()) {

src/components/calendar/days-view/days-view.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ import { createDateTimeFormatters } from '../../common/localization/intl-formatt
1212
import type { Constructor } from '../../common/mixins/constructor.js';
1313
import { EventEmitterMixin } from '../../common/mixins/event-emitter.js';
1414
import { partMap } from '../../common/part-map.js';
15-
import { chunk, first, last, take } from '../../common/util.js';
15+
import {
16+
addSafeEventListener,
17+
chunk,
18+
first,
19+
last,
20+
take,
21+
} from '../../common/util.js';
1622
import { IgcCalendarBaseComponent } from '../base.js';
1723
import {
1824
areSameMonth,
@@ -139,7 +145,7 @@ export default class IgcDaysViewComponent extends EventEmitterMixin<
139145
bindingDefaults: { preventDefault: true },
140146
}).setActivateHandler(this.handleInteraction);
141147

142-
this.addEventListener('click', this.handleInteraction);
148+
addSafeEventListener(this, 'click', this.handleInteraction);
143149
}
144150

145151
public override connectedCallback() {

src/components/calendar/months-view/months-view.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { createDateTimeFormatters } from '../../common/localization/intl-formatt
1212
import type { Constructor } from '../../common/mixins/constructor.js';
1313
import { EventEmitterMixin } from '../../common/mixins/event-emitter.js';
1414
import { partMap } from '../../common/part-map.js';
15-
import { chunk } from '../../common/util.js';
15+
import { addSafeEventListener, chunk } from '../../common/util.js';
1616
import { areSameMonth, getViewElement, MONTHS_PER_ROW } from '../helpers.js';
1717
import { CalendarDay } from '../model.js';
1818
import { all } from '../themes/year-month.js';
@@ -91,7 +91,7 @@ export default class IgcMonthsViewComponent extends EventEmitterMixin<
9191
bindingDefaults: { preventDefault: true },
9292
}).setActivateHandler(this.handleInteraction);
9393

94-
this.addEventListener('click', this.handleInteraction);
94+
addSafeEventListener(this, 'click', this.handleInteraction);
9595
}
9696

9797
public override connectedCallback() {

src/components/calendar/years-view/years-view.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { registerComponent } from '../../common/definitions/register.js';
1010
import type { Constructor } from '../../common/mixins/constructor.js';
1111
import { EventEmitterMixin } from '../../common/mixins/event-emitter.js';
1212
import { partMap } from '../../common/part-map.js';
13-
import { chunk } from '../../common/util.js';
13+
import { addSafeEventListener, chunk } from '../../common/util.js';
1414
import { getViewElement, getYearRange, YEARS_PER_ROW } from '../helpers.js';
1515
import { CalendarDay } from '../model.js';
1616
import { all } from '../themes/year-month.js';
@@ -72,7 +72,7 @@ export default class IgcYearsViewComponent extends EventEmitterMixin<
7272
bindingDefaults: { preventDefault: true },
7373
}).setActivateHandler(this.handleInteraction);
7474

75-
this.addEventListener('click', this.handleInteraction);
75+
addSafeEventListener(this, 'click', this.handleInteraction);
7676
}
7777

7878
public override connectedCallback() {

src/components/carousel/carousel.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import type { Constructor } from '../common/mixins/constructor.js';
3434
import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
3535
import { partMap } from '../common/part-map.js';
3636
import {
37+
addSafeEventListener,
3738
asNumber,
3839
createCounter,
3940
findElementFromEventPath,
@@ -162,7 +163,7 @@ export default class IgcCarouselComponent extends EventEmitterMixin<
162163
return;
163164
}
164165
const idx = this.slides.indexOf(
165-
added.length ? last(added).node : last(attributes)
166+
added.length ? last(added).node : last(attributes).node
166167
);
167168

168169
for (const [i, slide] of this.slides.entries()) {
@@ -328,13 +329,12 @@ export default class IgcCarouselComponent extends EventEmitterMixin<
328329

329330
addThemingController(this, all);
330331

331-
this.addEventListener('pointerenter', this.handlePointerEnter);
332-
this.addEventListener('pointerleave', this.handlePointerLeave);
333-
this.addEventListener('pointerdown', () => {
332+
addSafeEventListener(this, 'pointerenter', this.handlePointerEnter);
333+
addSafeEventListener(this, 'pointerleave', this.handlePointerLeave);
334+
addSafeEventListener(this, 'pointerdown', () => {
334335
this._hasInnerFocus = false;
335336
});
336-
337-
this.addEventListener('keyup', () => {
337+
addSafeEventListener(this, 'keyup', () => {
338338
this._hasInnerFocus = true;
339339
});
340340

src/components/combo/combo.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
} from '../common/mixins/forms/form-value.js';
2424
import { partMap } from '../common/part-map.js';
2525
import {
26+
addSafeEventListener,
2627
asArray,
2728
equal,
2829
findElementFromEventPath,
@@ -475,8 +476,9 @@ export default class IgcComboComponent<
475476
super();
476477

477478
addThemingController(this, all);
479+
addSafeEventListener(this, 'blur', this._handleBlur);
478480

479-
this.addEventListener('blur', this._handleBlur);
481+
// TODO
480482
this.addEventListener(
481483
'keydown',
482484
this._navigation.navigateHost.bind(this._navigation)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* A utility class that wraps AbortController, allowing its signal to be
3+
* used for event listeners and providing a mechanism to reset it,
4+
* effectively generating a fresh AbortController instance on subsequent access
5+
* after an abort call.
6+
*/
7+
class AbortHandle {
8+
private _controller: AbortController;
9+
10+
constructor() {
11+
this._controller = new AbortController();
12+
}
13+
14+
/**
15+
* Returns the AbortSignal associated with the current AbortController instance.
16+
* This signal can be passed to functions like `addEventListener` or `fetch`.
17+
*/
18+
public get signal(): AbortSignal {
19+
return this._controller.signal;
20+
}
21+
22+
/**
23+
* Aborts the current AbortController instance and immediately creates a new,
24+
* fresh AbortController.
25+
*
26+
* Any operations or event listeners associated with the previous signal
27+
* will be aborted. Subsequent accesses to `signal` will return the
28+
* signal from the new controller.
29+
*/
30+
public abort(reason?: unknown): void {
31+
this._controller.abort(reason);
32+
this._controller = new AbortController();
33+
}
34+
35+
/**
36+
* Resets the controller without triggering an abort.
37+
* This is useful if you want to explicitly get a fresh signal without
38+
* aborting any ongoing operations from the previous signal.
39+
*/
40+
public reset(): void {
41+
this._controller = new AbortController();
42+
}
43+
}
44+
45+
/**
46+
* Creates and returns an `AbortHandle` object that wraps an AbortController,
47+
* providing a resettable AbortSignal. This allows you to use the signal for event
48+
* listeners, fetch requests, or other cancellable operations, and then
49+
* reset the underlying AbortController to get a fresh signal without
50+
* needing to create a new wrapper object.
51+
*/
52+
export function createAbortHandle(): AbortHandle {
53+
return new AbortHandle();
54+
}

0 commit comments

Comments
 (0)