igniteui-webcomponents 7.2.3 → 7.2.4
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 +14 -0
- package/animations/player.d.ts +4 -11
- package/animations/player.js +3 -9
- package/animations/player.js.map +1 -1
- package/animations/view-transition.d.ts +44 -0
- package/animations/view-transition.js +81 -0
- package/animations/view-transition.js.map +1 -0
- package/components/avatar/avatar.js +7 -7
- package/components/avatar/avatar.js.map +1 -1
- package/components/button/button-base.d.ts +1 -1
- package/components/button/button-base.js +7 -5
- package/components/button/button-base.js.map +1 -1
- package/components/button/icon-button.js +9 -9
- package/components/button/icon-button.js.map +1 -1
- package/components/calendar/calendar.js.map +1 -1
- package/components/calendar/days-view/days-view.js.map +1 -1
- package/components/carousel/carousel.js +1 -2
- package/components/carousel/carousel.js.map +1 -1
- package/components/chat/chat-input.js +4 -4
- package/components/chat/chat-input.js.map +1 -1
- package/components/chat/chat.js +6 -6
- package/components/chat/chat.js.map +1 -1
- package/components/chat/message-attachments.js.map +1 -1
- package/components/checkbox/checkbox.js.map +1 -1
- package/components/combo/combo.d.ts +1 -0
- package/components/combo/combo.js +9 -1
- package/components/combo/combo.js.map +1 -1
- package/components/common/controllers/gestures.js.map +1 -1
- package/components/common/controllers/internals.d.ts +9 -0
- package/components/common/controllers/internals.js +4 -0
- package/components/common/controllers/internals.js.map +1 -1
- package/components/common/controllers/mutation-observer.d.ts +2 -2
- package/components/common/controllers/mutation-observer.js +10 -7
- package/components/common/controllers/mutation-observer.js.map +1 -1
- package/components/common/controllers/slot.d.ts +1 -1
- package/components/common/controllers/slot.js +4 -1
- package/components/common/controllers/slot.js.map +1 -1
- package/components/common/i18n/utils.js.map +1 -1
- package/components/common/mixins/forms/associated.d.ts +1 -1
- package/components/common/mixins/forms/associated.js +21 -13
- package/components/common/mixins/forms/associated.js.map +1 -1
- package/components/common/mixins/forms/types.d.ts +2 -1
- package/components/common/mixins/forms/types.js.map +1 -1
- package/components/common/templates/masked-input.d.ts +2 -0
- package/components/common/templates/masked-input.js +2 -1
- package/components/common/templates/masked-input.js.map +1 -1
- package/components/date-picker/date-picker.d.ts +2 -1
- package/components/date-picker/date-picker.js +6 -0
- package/components/date-picker/date-picker.js.map +1 -1
- package/components/date-range-picker/date-range-mask-parser.js.map +1 -1
- package/components/date-range-picker/date-range-picker.d.ts +2 -1
- package/components/date-range-picker/date-range-picker.js +10 -8
- package/components/date-range-picker/date-range-picker.js.map +1 -1
- package/components/date-range-picker/predefined-ranges-area.js.map +1 -1
- package/components/date-time-input/date-time-input.base.d.ts +15 -0
- package/components/date-time-input/date-time-input.base.js +9 -1
- package/components/date-time-input/date-time-input.base.js.map +1 -1
- package/components/dialog/dialog.js +4 -4
- package/components/dialog/dialog.js.map +1 -1
- package/components/file-input/file-input.js.map +1 -1
- package/components/icon/icon-state.broadcast.js.map +1 -1
- package/components/icon/icon.d.ts +3 -2
- package/components/icon/icon.js +7 -2
- package/components/icon/icon.js.map +1 -1
- package/components/input/input-base.d.ts +15 -0
- package/components/input/input-base.js +8 -1
- package/components/input/input-base.js.map +1 -1
- package/components/input/input.js +1 -0
- package/components/input/input.js.map +1 -1
- package/components/mask-input/mask-input.js +1 -0
- package/components/mask-input/mask-input.js.map +1 -1
- package/components/select/select.d.ts +7 -1
- package/components/select/select.js +12 -1
- package/components/select/select.js.map +1 -1
- package/components/slider/range-slider.js +5 -5
- package/components/slider/range-slider.js.map +1 -1
- package/components/slider/slider-base.js +9 -9
- package/components/slider/slider-base.js.map +1 -1
- package/components/snackbar/snackbar.js +4 -4
- package/components/snackbar/snackbar.js.map +1 -1
- package/components/splitter/splitter.js.map +1 -1
- package/components/stepper/common/animations.js.map +1 -1
- package/components/stepper/step.js.map +1 -1
- package/components/tabs/tabs.js +29 -10
- package/components/tabs/tabs.js.map +1 -1
- package/components/textarea/textarea.js +1 -0
- package/components/textarea/textarea.js.map +1 -1
- package/components/tile-manager/tile.js +14 -13
- package/components/tile-manager/tile.js.map +1 -1
- package/components/tooltip/tooltip.js +8 -8
- package/components/tooltip/tooltip.js.map +1 -1
- package/components/tree/tree-item.js +31 -31
- package/components/tree/tree-item.js.map +1 -1
- package/components/types.js.map +1 -1
- package/components/validation-container/validation-container.d.ts +32 -5
- package/components/validation-container/validation-container.js +74 -64
- package/components/validation-container/validation-container.js.map +1 -1
- package/custom-elements.json +780 -137
- package/igniteui-webcomponents.html-data.json +1 -1
- package/index.d.ts +3 -3
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/igniteui-wc-generate-from-image-design/references/gotchas.md +15 -1
- package/web-types.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [7.2.4] - 2026-06-29
|
|
8
|
+
### Added
|
|
9
|
+
- #### Form associated custom elements with external labels
|
|
10
|
+
- External `<label>` associations are now resolved to the underlying native input of form-associated controls. Associating a label with `IgcInput`, `IgcMaskInput`, `IgcTextarea`, `IgcDateTimeInput`, `IgcSelect`, `IgcCombo`, `IgcDatePicker`, or `IgcDateRangePicker` — either through the `for`/`id` IDREF mechanism or by nesting the component inside the `<label>` — now correctly exposes the label to assistive technologies and focuses the inner input on label activation. [#2263](https://github.com/IgniteUI/igniteui-webcomponents/pull/2263)
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- #### AI-Assisted Development
|
|
14
|
+
- Improved grid related skills [#2250](https://github.com/IgniteUI/igniteui-webcomponents/pull/2250)
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- #### Tabs
|
|
18
|
+
- Prevent selected tab header from scrolling into view on initial render [#2268](https://github.com/IgniteUI/igniteui-webcomponents/pull/2268)
|
|
19
|
+
|
|
7
20
|
## [7.2.3] - 2026-06-18
|
|
8
21
|
### Fixed
|
|
9
22
|
- #### Popover based components
|
|
@@ -1378,6 +1391,7 @@ Initial release of Ignite UI Web Components
|
|
|
1378
1391
|
- Ripple component
|
|
1379
1392
|
- Switch component
|
|
1380
1393
|
|
|
1394
|
+
[7.2.4]: https://github.com/IgniteUI/igniteui-webcomponents/compare/7.2.3...7.2.4
|
|
1381
1395
|
[7.2.3]: https://github.com/IgniteUI/igniteui-webcomponents/compare/7.2.2...7.2.3
|
|
1382
1396
|
[7.2.2]: https://github.com/IgniteUI/igniteui-webcomponents/compare/7.2.1...7.2.2
|
|
1383
1397
|
[7.2.1]: https://github.com/IgniteUI/igniteui-webcomponents/compare/7.2.0...7.2.1
|
package/animations/player.d.ts
CHANGED
|
@@ -2,13 +2,11 @@ import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
|
2
2
|
import type { Ref } from 'lit/directives/ref.js';
|
|
3
3
|
import type { AnimationReferenceMetadata } from './types.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Checks the user's preference for reduced motion.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
transition?: ViewTransition;
|
|
9
|
-
};
|
|
7
|
+
export declare function getPrefersReducedMotion(): boolean;
|
|
10
8
|
/**
|
|
11
|
-
* A ReactiveController for managing Web Animation API (
|
|
9
|
+
* A ReactiveController for managing Web Animation API (WA-API) playback
|
|
12
10
|
* on a host element or a specified target element.
|
|
13
11
|
*
|
|
14
12
|
* It provides methods to play, stop, and coordinate animations, including
|
|
@@ -30,7 +28,7 @@ declare class AnimationController implements ReactiveController {
|
|
|
30
28
|
/** Plays a sequence of keyframes, first cancelling all existing animations on the target. */
|
|
31
29
|
playExclusive(animation: AnimationReferenceMetadata): Promise<boolean>;
|
|
32
30
|
/**
|
|
33
|
-
* Plays a sequence of keyframes using
|
|
31
|
+
* Plays a sequence of keyframes using WA-API.
|
|
34
32
|
* Automatically sets duration to 0 if 'prefers-reduced-motion' is set.
|
|
35
33
|
*/
|
|
36
34
|
play(animation: AnimationReferenceMetadata): Promise<AnimationPlaybackEvent>;
|
|
@@ -43,9 +41,4 @@ declare class AnimationController implements ReactiveController {
|
|
|
43
41
|
* the host element itself.
|
|
44
42
|
*/
|
|
45
43
|
export declare function addAnimationController(host: ReactiveControllerHost & HTMLElement, target?: Ref<HTMLElement> | HTMLElement): AnimationController;
|
|
46
|
-
/**
|
|
47
|
-
* Initiates a View Transition if supported by the browser and not suppressed by
|
|
48
|
-
* the 'prefers-reduced-motion' setting.
|
|
49
|
-
*/
|
|
50
|
-
export declare function startViewTransition(callback?: ViewTransitionUpdateCallback): ViewTransitionResult;
|
|
51
44
|
export type { AnimationController };
|
package/animations/player.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isElement } from '../components/common/util.js';
|
|
2
2
|
const LISTENER_OPTIONS = { once: true };
|
|
3
|
-
function getPrefersReducedMotion() {
|
|
4
|
-
return globalThis?.matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
3
|
+
export function getPrefersReducedMotion() {
|
|
4
|
+
return (globalThis?.matchMedia?.('(prefers-reduced-motion: reduce)').matches ??
|
|
5
|
+
false);
|
|
5
6
|
}
|
|
6
7
|
class AnimationController {
|
|
7
8
|
get _target() {
|
|
@@ -54,11 +55,4 @@ class AnimationController {
|
|
|
54
55
|
export function addAnimationController(host, target) {
|
|
55
56
|
return new AnimationController(host, target);
|
|
56
57
|
}
|
|
57
|
-
export function startViewTransition(callback) {
|
|
58
|
-
if (getPrefersReducedMotion() || !document.startViewTransition) {
|
|
59
|
-
callback?.();
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
return { transition: document.startViewTransition(callback) };
|
|
63
|
-
}
|
|
64
58
|
//# sourceMappingURL=player.js.map
|
package/animations/player.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"player.js","sourceRoot":"","sources":["../../src/animations/player.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,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ref } from 'lit/directives/ref.js';\nimport { isElement } from '../components/common/util.js';\nimport type { AnimationReferenceMetadata } from './types.js';\n\nconst LISTENER_OPTIONS = { once: true } as const;\n\n/**\n * Checks the user's preference for reduced motion.\n */\nexport function getPrefersReducedMotion(): boolean {\n return (\n globalThis?.matchMedia?.('(prefers-reduced-motion: reduce)').matches ??\n false\n );\n}\n\n/**\n * A ReactiveController for managing Web Animation API (WA-API) playback\n * on a host element or a specified target element.\n *\n * It provides methods to play, stop, and coordinate animations, including\n * support for 'height: auto' transitions and reduced motion preference.\n */\nclass AnimationController implements ReactiveController {\n private readonly _host: ReactiveControllerHost & HTMLElement;\n private readonly _ref?: Ref<HTMLElement> | HTMLElement;\n\n /**\n * The actual HTMLElement target for the animations.\n * Prioritizes a passed-in Ref value, then a direct HTMLElement, falling back to the host.\n */\n protected get _target(): HTMLElement {\n if (isElement(this._ref)) {\n return this._ref;\n }\n\n return this._ref?.value ?? this._host;\n }\n\n constructor(\n host: ReactiveControllerHost & HTMLElement,\n ref?: Ref<HTMLElement> | HTMLElement\n ) {\n this._host = host;\n this._ref = ref;\n this._host.addController(this);\n }\n\n /** Pre-processes keyframes, specifically resolving 'auto' height to the element's scrollHeight. */\n private _parseKeyframes(keyframes: Keyframe[]): Keyframe[] {\n const target = this._target;\n\n return keyframes.map((frame) => {\n return frame.height === 'auto'\n ? { ...frame, height: `${target.scrollHeight}px` }\n : frame;\n });\n }\n\n /** @internal */\n public hostConnected(): void {}\n\n /** Plays a sequence of keyframes, first cancelling all existing animations on the target. */\n public async playExclusive(\n animation: AnimationReferenceMetadata\n ): Promise<boolean> {\n await this.cancelAll();\n\n const event = await this.play(animation);\n return event.type === 'finish';\n }\n\n /**\n * Plays a sequence of keyframes using WA-API.\n * Automatically sets duration to 0 if 'prefers-reduced-motion' is set.\n */\n public async play(\n animation: AnimationReferenceMetadata\n ): Promise<AnimationPlaybackEvent> {\n const { steps, options } = animation;\n const duration = getPrefersReducedMotion() ? 0 : (options?.duration ?? 0);\n\n if (!Number.isFinite(duration)) {\n throw new Error('Promise-based animations must be finite.');\n }\n\n return new Promise<AnimationPlaybackEvent>((resolve) => {\n const animation = this._target.animate(this._parseKeyframes(steps), {\n ...options,\n duration,\n });\n\n animation.addEventListener('cancel', resolve, LISTENER_OPTIONS);\n animation.addEventListener('finish', resolve, LISTENER_OPTIONS);\n });\n }\n\n /** Cancels all active animations on the target element. */\n public cancelAll(): Promise<void> {\n for (const animation of this._target.getAnimations()) {\n animation.cancel();\n }\n\n return Promise.resolve();\n }\n}\n\n/**\n * Creates and attaches an animation player instance to the passed in `host` element.\n * The player will run animations on the passed in `target`, or if `target` is undefined,\n * the host element itself.\n */\nexport function addAnimationController(\n host: ReactiveControllerHost & HTMLElement,\n target?: Ref<HTMLElement> | HTMLElement\n): AnimationController {\n return new AnimationController(host, target);\n}\n\nexport type { AnimationController };\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ChildPart, noChange, type TemplateResult } from 'lit';
|
|
2
|
+
import { AsyncDirective, type DirectiveParameters } from 'lit/async-directive.js';
|
|
3
|
+
/**
|
|
4
|
+
* Starts a document view transition and skips it if the user has requested reduced motion.
|
|
5
|
+
*/
|
|
6
|
+
export declare function startViewTransition(callback: ViewTransitionUpdateCallback): ViewTransition;
|
|
7
|
+
/**
|
|
8
|
+
* Starts a scoped view transition on the specified target element and skips it if the user has requested reduced motion.
|
|
9
|
+
*/
|
|
10
|
+
export declare function startScopedViewTransition(target: HTMLElement, callback: ViewTransitionUpdateCallback): ViewTransition | null;
|
|
11
|
+
/**
|
|
12
|
+
* Sets the view transition name for the specified target element.
|
|
13
|
+
*/
|
|
14
|
+
export declare function setTransitionName(target: HTMLElement, name: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Clears the view transition name for the specified target elements.
|
|
17
|
+
*/
|
|
18
|
+
export declare function clearTransitionName(...targets: HTMLElement[]): void;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the active view transition if one is currently in progress, or null otherwise.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getActiveViewTransition(): ViewTransition | null;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the active scoped view transition for the specified target element if one is currently in progress, or null otherwise.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getActiveScopedViewTransition(target: Node): ViewTransition | null;
|
|
27
|
+
declare class ScopedViewTransitionDirective extends AsyncDirective {
|
|
28
|
+
private _isFirstRender;
|
|
29
|
+
render(template: TemplateResult): TemplateResult;
|
|
30
|
+
update(part: ChildPart, [template]: DirectiveParameters<this>): typeof noChange | TemplateResult;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A directive that enables scoped view transitions for a template.
|
|
34
|
+
*
|
|
35
|
+
* When applied, it will start a view transition whenever the template is updated,
|
|
36
|
+
* provided that the parent node supports view transitions.
|
|
37
|
+
* If the user has requested reduced motion, the transition will be skipped.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* This directive is intended to be used with Lit templates inside a component that supports view transitions.
|
|
41
|
+
* It will not work if the parent node does not support view transitions (e.g., if the parent is not a document or element that implements the ViewTransition interface).
|
|
42
|
+
*/
|
|
43
|
+
export declare const scopedViewTransition: (template: TemplateResult) => import("lit-html/directive.js").DirectiveResult<typeof ScopedViewTransitionDirective>;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { noChange } from 'lit';
|
|
2
|
+
import { AsyncDirective, directive, } from 'lit/async-directive.js';
|
|
3
|
+
import { isFunction } from '../components/common/util.js';
|
|
4
|
+
import { getPrefersReducedMotion } from './player.js';
|
|
5
|
+
function hasScopedViewTransition(node) {
|
|
6
|
+
return 'startViewTransition' in node && isFunction(node.startViewTransition);
|
|
7
|
+
}
|
|
8
|
+
export function startViewTransition(callback) {
|
|
9
|
+
const init = globalThis.document?.startViewTransition;
|
|
10
|
+
if (!init) {
|
|
11
|
+
callback();
|
|
12
|
+
const resolved = Promise.resolve();
|
|
13
|
+
return {
|
|
14
|
+
finished: resolved,
|
|
15
|
+
ready: resolved,
|
|
16
|
+
updateCallbackDone: resolved,
|
|
17
|
+
skipTransition: () => { },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const transition = init.call(globalThis.document, callback);
|
|
21
|
+
if (getPrefersReducedMotion()) {
|
|
22
|
+
transition.skipTransition();
|
|
23
|
+
}
|
|
24
|
+
return transition;
|
|
25
|
+
}
|
|
26
|
+
export function startScopedViewTransition(target, callback) {
|
|
27
|
+
if (!hasScopedViewTransition(target)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const transition = target.startViewTransition(callback);
|
|
31
|
+
if (getPrefersReducedMotion()) {
|
|
32
|
+
transition.skipTransition();
|
|
33
|
+
}
|
|
34
|
+
return transition;
|
|
35
|
+
}
|
|
36
|
+
export function setTransitionName(target, name) {
|
|
37
|
+
target.style.viewTransitionName = name;
|
|
38
|
+
}
|
|
39
|
+
export function clearTransitionName(...targets) {
|
|
40
|
+
for (const target of targets) {
|
|
41
|
+
target.style.viewTransitionName = '';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function getActiveViewTransition() {
|
|
45
|
+
return globalThis.document?.activeViewTransition ?? null;
|
|
46
|
+
}
|
|
47
|
+
export function getActiveScopedViewTransition(target) {
|
|
48
|
+
if (!hasScopedViewTransition(target)) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return target.activeViewTransition ?? null;
|
|
52
|
+
}
|
|
53
|
+
class ScopedViewTransitionDirective extends AsyncDirective {
|
|
54
|
+
constructor() {
|
|
55
|
+
super(...arguments);
|
|
56
|
+
this._isFirstRender = true;
|
|
57
|
+
}
|
|
58
|
+
render(template) {
|
|
59
|
+
return template;
|
|
60
|
+
}
|
|
61
|
+
update(part, [template]) {
|
|
62
|
+
if (this._isFirstRender) {
|
|
63
|
+
this._isFirstRender = false;
|
|
64
|
+
return this.render(template);
|
|
65
|
+
}
|
|
66
|
+
const parent = part.parentNode;
|
|
67
|
+
if (!hasScopedViewTransition(parent)) {
|
|
68
|
+
return this.render(template);
|
|
69
|
+
}
|
|
70
|
+
const transition = parent.startViewTransition(() => {
|
|
71
|
+
this.setValue(template);
|
|
72
|
+
return new Promise((resolve) => requestAnimationFrame(resolve));
|
|
73
|
+
});
|
|
74
|
+
if (getPrefersReducedMotion()) {
|
|
75
|
+
transition.skipTransition();
|
|
76
|
+
}
|
|
77
|
+
return noChange;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export const scopedViewTransition = directive(ScopedViewTransitionDirective);
|
|
81
|
+
//# sourceMappingURL=view-transition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-transition.js","sourceRoot":"","sources":["../../src/animations/view-transition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAuB,MAAM,KAAK,CAAC;AACpE,OAAO,EACL,cAAc,EAEd,SAAS,GACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAYtD,SAAS,uBAAuB,CAC9B,IAAU;IAEV,OAAO,qBAAqB,IAAI,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;AAC/E,CAAC;AAKD,MAAM,UAAU,mBAAmB,CACjC,QAAsC;IAEtC,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IAGtD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,QAAQ,EAAE,CAAC;QACX,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAEnC,OAAO;YACL,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE,QAAQ;YACf,kBAAkB,EAAE,QAAQ;YAC5B,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;SACP,CAAC;IACtB,CAAC;IAED,MAAM,UAAU,G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AC,QAAwB;QAC7C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEe,MAAM,CACpB,IAAe,EACf,CAAC,QAAQ,CAA4B;QAErC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;YAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/B,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;QAE/B,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/B,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE;YACjD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACxB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QAEH,IAAI,uBAAuB,EAAE,EAAE,CAAC;YAC9B,UAAU,CAAC,cAAc,EAAE,CAAC;QAC9B,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAaD,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC,6BAA6B,CAAC,CAAC","sourcesContent":["import { type ChildPart, noChange, type TemplateResult } from 'lit';\nimport {\n AsyncDirective,\n type DirectiveParameters,\n directive,\n} from 'lit/async-directive.js';\nimport { isFunction } from '../components/common/util.js';\nimport { getPrefersReducedMotion } from './player.js';\n\ntype ScopedViewTransitionElement = HTMLElement & {\n startViewTransition: (\n callback: () => Promise<unknown> | unknown\n ) => ViewTransition;\n activeViewTransition?: ViewTransition | null;\n};\n\n/**\n * Returns true if the specified node supports scoped view transitions, false otherwise.\n */\nfunction hasScopedViewTransition(\n node: Node\n): node is ScopedViewTransitionElement {\n return 'startViewTransition' in node && isFunction(node.startViewTransition);\n}\n\n/**\n * Starts a document view transition and skips it if the user has requested reduced motion.\n */\nexport function startViewTransition(\n callback: ViewTransitionUpdateCallback\n): ViewTransition {\n const init = globalThis.document?.startViewTransition;\n\n /* c8 ignore next 11 */\n if (!init) {\n callback();\n const resolved = Promise.resolve();\n\n return {\n finished: resolved,\n ready: resolved,\n updateCallbackDone: resolved,\n skipTransition: () => {},\n } as ViewTransition;\n }\n\n const transition = init.call(globalThis.document, callback);\n\n if (getPrefersReducedMotion()) {\n transition.skipTransition();\n }\n\n return transition;\n}\n\n/**\n * Starts a scoped view transition on the specified target element and skips it if the user has requested reduced motion.\n */\nexport function startScopedViewTransition(\n target: HTMLElement,\n callback: ViewTransitionUpdateCallback\n): ViewTransition | null {\n if (!hasScopedViewTransition(target)) {\n return null;\n }\n\n const transition = target.startViewTransition(callback);\n\n if (getPrefersReducedMotion()) {\n transition.skipTransition();\n }\n\n return transition;\n}\n\n/**\n * Sets the view transition name for the specified target element.\n */\nexport function setTransitionName(target: HTMLElement, name: string): void {\n target.style.viewTransitionName = name;\n}\n\n/**\n * Clears the view transition name for the specified target elements.\n */\nexport function clearTransitionName(...targets: HTMLElement[]): void {\n for (const target of targets) {\n target.style.viewTransitionName = '';\n }\n}\n\n/**\n * Returns the active view transition if one is currently in progress, or null otherwise.\n */\nexport function getActiveViewTransition(): ViewTransition | null {\n return globalThis.document?.activeViewTransition ?? null;\n}\n\n/**\n * Returns the active scoped view transition for the specified target element if one is currently in progress, or null otherwise.\n */\nexport function getActiveScopedViewTransition(\n target: Node\n): ViewTransition | null {\n if (!hasScopedViewTransition(target)) {\n return null;\n }\n\n return target.activeViewTransition ?? null;\n}\n\nclass ScopedViewTransitionDirective extends AsyncDirective {\n private _isFirstRender = true;\n\n public override render(template: TemplateResult): TemplateResult {\n return template;\n }\n\n public override update(\n part: ChildPart,\n [template]: DirectiveParameters<this>\n ) {\n if (this._isFirstRender) {\n this._isFirstRender = false;\n return this.render(template);\n }\n\n const parent = part.parentNode;\n\n if (!hasScopedViewTransition(parent)) {\n return this.render(template);\n }\n\n const transition = parent.startViewTransition(() => {\n this.setValue(template);\n return new Promise((resolve) => requestAnimationFrame(resolve));\n });\n\n if (getPrefersReducedMotion()) {\n transition.skipTransition();\n }\n\n return noChange;\n }\n}\n\n/**\n * A directive that enables scoped view transitions for a template.\n *\n * When applied, it will start a view transition whenever the template is updated,\n * provided that the parent node supports view transitions.\n * If the user has requested reduced motion, the transition will be skipped.\n *\n * @remarks\n * This directive is intended to be used with Lit templates inside a component that supports view transitions.\n * It will not work if the parent node does not support view transitions (e.g., if the parent is not a document or element that implements the ViewTransition interface).\n */\nexport const scopedViewTransition = directive(ScopedViewTransitionDirective);\n"]}
|
|
@@ -52,13 +52,13 @@ export default class IgcAvatarComponent extends LitElement {
|
|
|
52
52
|
: html `<slot></slot>`}
|
|
53
53
|
${this.src && !this._hasError
|
|
54
54
|
? html `
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
<img
|
|
56
|
+
part="image"
|
|
57
|
+
alt=${ifDefined(this.alt)}
|
|
58
|
+
src=${ifDefined(this.src)}
|
|
59
|
+
@error=${this._handleError}
|
|
60
|
+
/>
|
|
61
|
+
`
|
|
62
62
|
: nothing}
|
|
63
63
|
</div>
|
|
64
64
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.js","sourceRoot":"","sources":["../../../src/components/avatar/avatar.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE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GAAG,CAAC,UAAU,CAAC,IAAI,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACtE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;gBACtB,mBAAmB,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,QAAQ;aAC/C,CAAC,CAAC;QACL,CAAC;QAED,IAAI,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC;IACH,CAAC;IAES,YAAY;QACpB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAEkB,MAAM;QACvB,OAAO,IAAI,CAAA;;UAGL,IAAI,CAAC,QAAQ;YACX,CAAC,CAAC,IAAI,CAAA,yBAAyB,IAAI,CAAC,QAAQ,SAAS;YACrD,CAAC,CAAC,IAAI,CAAA,eACV;UAEE,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS;YACzB,CAAC,CAAC,IAAI,CAAA;;;wBAGM,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;wBACnB,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;2BAChB,IAAI,CAAC,YAAY;;eAE7B;YACH,CAAC,CAAC,OACN;;KAEH,CAAC;IACJ,CAAC;;AAzEO;IADP,KAAK,EAAE;qDACkB;AAOnB;IADN,QAAQ,EAAE;+CACS;AAOb;IADN,QAAQ,EAAE;+CACS;AAOb;IADN,QAAQ,EAAE;oDACc;AAOlB;IADN,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDACS","sourcesContent":["import { html, LitElement, nothing, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { addThemingController } from '../../theming/theming-controller.js';\nimport { addInternalsController } from '../common/controllers/internals.js';\nimport { registerComponent } from '../common/definitions/register.js';\nimport type { AvatarShape } from '../types.js';\nimport { styles } from './themes/avatar.base.css.js';\nimport { styles as shared } from './themes/shared/avatar.common.css.js';\nimport { all } from './themes/themes.js';\n\n/**\n * An avatar component is used as a representation of a user identity\n * typically in a user profile.\n *\n * @element igc-avatar\n *\n * @slot - Renders an icon inside the default slot.\n *\n * @csspart base - The base wrapper of the avatar.\n * @csspart initials - The initials wrapper of the avatar.\n * @csspart image - The image wrapper of the avatar.\n * @csspart icon - The icon wrapper of the avatar.\n */\nexport default class IgcAvatarComponent extends LitElement {\n public static readonly tagName = 'igc-avatar';\n public static override styles = [styles, shared];\n\n /* blazorSuppress */\n public static register(): void {\n registerComponent(IgcAvatarComponent);\n }\n\n private readonly _internals = addInternalsController(this, {\n initialARIA: {\n role: 'image',\n ariaLabel: 'avatar',\n },\n });\n\n @state()\n private _hasError = false;\n\n /**\n * The image source to use.\n * @attr\n */\n @property()\n public src?: string;\n\n /**\n * Alternative text for the image.\n * @attr\n */\n @property()\n public alt?: string;\n\n /**\n * Initials to use as a fallback when no image is available.\n * @attr\n */\n @property()\n public initials?: string;\n\n /**\n * The shape of the avatar.\n * @attr\n */\n @property({ reflect: true })\n public shape: AvatarShape = 'square';\n\n constructor() {\n super();\n addThemingController(this, all);\n }\n\n protected override willUpdate(changedProperties: PropertyValues<this>): void {\n if (changedProperties.has('initials') || changedProperties.has('alt')) {\n this._internals.setARIA({\n ariaRoleDescription: this.alt ?? this.initials,\n });\n }\n\n if (changedProperties.has('src')) {\n this._hasError = false;\n }\n }\n\n protected _handleError(): void {\n this._hasError = true;\n }\n\n protected override render() {\n return html`\n <div part=\"base\">\n ${\n this.initials\n ? html`<span part=\"initials\">${this.initials}</span>`\n : html`<slot></slot>`\n }\n ${\n this.src && !this._hasError\n ? html`\n <img\n part=\"image\"\n alt=${ifDefined(this.alt)}\n src=${ifDefined(this.src)}\n @error=${this._handleError}\n />\n `\n : nothing\n }\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-avatar': IgcAvatarComponent;\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ export interface IgcButtonEventMap {
|
|
|
4
4
|
focus: FocusEvent;
|
|
5
5
|
blur: FocusEvent;
|
|
6
6
|
}
|
|
7
|
-
declare const IgcButtonBaseComponent_base: Constructor<import("../common
|
|
7
|
+
declare const IgcButtonBaseComponent_base: Constructor<import("../common/mixins/event-emitter.js").EventEmitterInterface<IgcButtonEventMap>> & Constructor<LitElement>;
|
|
8
8
|
/**
|
|
9
9
|
* Abstract base class shared by `igc-button` and `igc-icon-button`.
|
|
10
10
|
*
|
|
@@ -12,7 +12,7 @@ import { addIdRefResolver } from '../common/controllers/id-resolver.js';
|
|
|
12
12
|
import { addInternalsController } from '../common/controllers/internals.js';
|
|
13
13
|
import { blazorDeepImport } from '../common/decorators/blazorDeepImport.js';
|
|
14
14
|
import { shadowOptions } from '../common/decorators/shadow-options.js';
|
|
15
|
-
import { EventEmitterMixin } from '../common
|
|
15
|
+
import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
|
|
16
16
|
import { partMap } from '../common/part-map.js';
|
|
17
17
|
import { bindIf, getElementByIdFromRoot } from '../common/util.js';
|
|
18
18
|
let IgcButtonBaseComponent = class IgcButtonBaseComponent extends EventEmitterMixin(LitElement) {
|
|
@@ -59,10 +59,12 @@ let IgcButtonBaseComponent = class IgcButtonBaseComponent extends EventEmitterMi
|
|
|
59
59
|
return this._internals.form;
|
|
60
60
|
}
|
|
61
61
|
firstUpdated() {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
this.updateComplete.then(() => {
|
|
63
|
+
if (this._commandfor) {
|
|
64
|
+
this._commandForElement = getElementByIdFromRoot(this, this._commandfor);
|
|
65
|
+
this.requestUpdate();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
66
68
|
}
|
|
67
69
|
_handleClick() {
|
|
68
70
|
switch (this.type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-base.js","sourceRoot":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ClB,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;mBACpB,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;cAC7B,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;;UAEvB,IAAI,CAAC,cAAc,EAAE;;KAE1B,CAAC;IACJ,CAAC;IAIkB,MAAM;QACvB,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IAC7E,CAAC;;AA5NgB;IADhB,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC;6DAC0C;AAkBhE;IADN,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAC0B;AAS/C;IADN,QAAQ,EAAE;oDACU;AASd;IADN,QAAQ,EAAE;wDACc;AAWlB;IADN,QAAQ,EAAE;sDAC6C;AAUjD;IADN,QAAQ,EAAE;mDACS;AASpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sDAI1C;AAaM;IADN,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uDACJ;AAQxB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;wDAUrC;AAvHmB,sBAAsB;IAF3C,gBAAgB;IAChB,aAAa,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;GAClB,sBAAsB,CAiP3C","sourcesContent":["import { html, LitElement, type TemplateResult } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { addKeyboardFocusRing } from '../common/controllers/focus-ring.js';\nimport { addIdRefResolver } from '../common/controllers/id-resolver.js';\nimport { addInternalsController } from '../common/controllers/internals.js';\nimport { blazorDeepImport } from '../common/decorators/blazorDeepImport.js';\nimport { shadowOptions } from '../common/decorators/shadow-options.js';\nimport type { Constructor } from '../common/mixins/constructor.js';\nimport { EventEmitterMixin } from '../common//mixins/event-emitter.js';\nimport { partMap } from '../common/part-map.js';\nimport { bindIf, getElementByIdFromRoot } from '../common/util.js';\n\nexport interface IgcButtonEventMap {\n // For analyzer meta only:\n /* skipWCPrefix */\n focus: FocusEvent;\n /* skipWCPrefix */\n blur: FocusEvent;\n}\n\n/**\n * Abstract base class shared by `igc-button` and `igc-icon-button`.\n *\n * Provides common form-association behavior, link-button rendering\n * (renders as `<a>` when `href` is set), keyboard focus-ring management,\n * and the Invoker Commands API (`command` / `commandfor`).\n *\n * Concrete subclasses must implement `_renderContent()` to supply the\n * visual content projected inside the native `<button>` or `<a>` element.\n */\n@blazorDeepImport\n@shadowOptions({ delegatesFocus: true })\nexport abstract class IgcButtonBaseComponent extends EventEmitterMixin<\n IgcButtonEventMap,\n Constructor<LitElement>\n>(LitElement) {\n public static readonly formAssociated = true;\n\n //#region Internal state\n\n private readonly _focusRingManager = addKeyboardFocusRing(this);\n private readonly _internals = addInternalsController(this);\n private readonly _resolver = addIdRefResolver(\n this,\n this._resolveCommandForElement\n );\n\n private _disabled = false;\n private _commandfor: string | null = null;\n private _commandForElement: Element | null = null;\n\n @query('[part=\"base\"]', true)\n private readonly _nativeButton?: HTMLButtonElement | HTMLAnchorElement;\n\n //#endregion\n\n //#region Public properties\n\n /* alternateName: displayType */\n /**\n * The type of the button, which determines its behavior and semantics.\n * - `'button'` – no default action; useful for custom JavaScript handlers.\n * - `'submit'` – submits the associated form when clicked.\n * - `'reset'` – resets the associated form fields to their initial values.\n *\n * Ignored when the button is rendered as a link (i.e. `href` is set).\n * @attr type\n * @default 'button'\n */\n @property({ reflect: true })\n public type: 'button' | 'reset' | 'submit' = 'button';\n\n /**\n * The URL the button points to. When set, the component renders as an\n * `<a>` element instead of a `<button>`, enabling navigation on click.\n * Use together with `target`, `download`, and `rel` for full anchor semantics.\n * @attr href\n */\n @property()\n public href?: string;\n\n /**\n * Prompts the browser to download the linked resource rather than navigating\n * to it. The optional value is used as the suggested file name.\n * Only effective when `href` is set.\n * @attr download\n */\n @property()\n public download?: string;\n\n /**\n * Where to open the linked document. Only effective when `href` is set.\n * - `'_self'` – current browsing context (default browser behavior).\n * - `'_blank'` – new tab or window.\n * - `'_parent'` – parent browsing context; falls back to `_self` if none.\n * - `'_top'` – top-level browsing context; falls back to `_self` if none.\n * @attr target\n */\n @property()\n public target?: '_blank' | '_parent' | '_self' | '_top';\n\n /**\n * The relationship between the current document and the linked URL.\n * Accepts a space-separated list of link types (e.g. `'noopener noreferrer'`).\n * Only effective when `href` is set. When `target=\"_blank\"` is used,\n * setting `rel=\"noopener noreferrer\"` is strongly recommended for security.\n * @attr rel\n */\n @property()\n public rel?: string;\n\n /**\n * When set, the button will be disabled and non-interactive.\n *\n * @attr disabled\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public set disabled(value: boolean) {\n this._disabled = value;\n this.toggleAttribute('disabled', Boolean(this._disabled));\n }\n\n public get disabled(): boolean {\n return this._disabled;\n }\n\n /**\n * The command to invoke on the target element specified by `commandfor`.\n * Part of the [Invoker Commands](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API) API.\n * Custom commands must start with two dashes (e.g. `'--my-command'`).\n * @attr command\n */\n @property({ reflect: true })\n public command?: string;\n\n /**\n * The ID of the target element for the invoker command.\n * Part of the [Invoker Commands API](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API).\n * @attr commandfor\n */\n @property({ attribute: 'commandfor' })\n public set commandfor(value: string | null) {\n this._commandfor = value;\n if (value) {\n this._resolver.observe();\n this._commandForElement = getElementByIdFromRoot(this, value);\n } else {\n this._commandForElement = null;\n this._resolver.unobserve();\n }\n }\n\n public get commandfor(): string | null {\n return this._commandfor;\n }\n\n /* blazorCSSuppress */\n /* alternateType: object */\n /**\n * The target element for the invoker command. Resolved from the `commandfor` ID.\n */\n public get commandForElement(): Element | null {\n return this._commandForElement;\n }\n\n /* blazorCSSuppress */\n /* alternateType: object */\n public set commandForElement(value: Element | null) {\n this._commandForElement = value;\n this.requestUpdate();\n }\n\n /* blazorCSSuppress */\n /* alternateType: object */\n /**\n * The `<form>` element the button is associated with.\n * Resolved through the standard form-association mechanism — either the\n * closest ancestor `<form>` or the form referenced by the button's `form`\n * attribute. Returns `null` when no form is associated.\n * Relevant only when `type` is `'submit'` or `'reset'`.\n */\n public get form(): HTMLFormElement | null {\n return this._internals.form;\n }\n\n //#endregion\n\n //#region Lifecycle\n\n protected override firstUpdated(): void {\n if (this._commandfor) {\n this._commandForElement = getElementByIdFromRoot(this, this._commandfor);\n this.requestUpdate();\n }\n }\n\n //#endregion\n\n //#region Event handlers\n\n protected _handleClick(): void {\n switch (this.type) {\n case 'submit':\n this.form?.requestSubmit();\n break;\n case 'reset':\n this.form?.reset();\n break;\n }\n }\n\n protected formDisabledCallback(state: boolean): void {\n this._disabled = state;\n this.requestUpdate();\n }\n\n //#endregion\n\n private _resolveCommandForElement(ids: Set<string>): void {\n if (this._commandfor && ids.has(this._commandfor)) {\n this._commandForElement = getElementByIdFromRoot(this, this._commandfor);\n this.requestUpdate();\n }\n }\n\n //#region Public API\n\n /** Simulates a mouse click on the button, triggering its click handler and any associated form action. */\n public override click(): void {\n this._nativeButton?.click();\n }\n\n //#endregion\n\n private _renderButton() {\n return html`\n <button\n command=${ifDefined(this.command)}\n .commandForElement=${this._commandForElement}\n part=${partMap({ base: true, focused: this._focusRingManager.focused })}\n aria-label=${bindIf(this.ariaLabel, this.ariaLabel)}\n ?disabled=${this.disabled}\n type=${ifDefined(this.type)}\n @click=${this._handleClick}\n >\n ${this._renderContent()}\n </button>\n `;\n }\n\n private _renderLinkButton() {\n return html`\n <a\n part=${partMap({ base: true, focused: this._focusRingManager.focused })}\n role=\"button\"\n aria-label=${bindIf(this.ariaLabel, this.ariaLabel)}\n aria-disabled=${this.disabled}\n href=${ifDefined(this.href)}\n target=${ifDefined(this.target)}\n download=${ifDefined(this.download)}\n rel=${ifDefined(this.rel)}\n >\n ${this._renderContent()}\n </a>\n `;\n }\n\n protected abstract _renderContent(): TemplateResult;\n\n protected override render() {\n return this.href != null ? this._renderLinkButton() : this._renderButton();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"button-base.js","sourceRoot":"","sources":["../../../src/components/button/button-base.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAsB5D,IAAe,sBAAsB,GAArC,MAAe,sBAAuB,SAAQ,iBAAiB,CAGpE,UAAU,CAAC;IAHN;;QAQY,sBAAiB,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAC/C,eAAU,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAC1C,cAAS,GAAG,gBAAgB,CAC3C,IAAI,EACJ,IAAI,CAAC,yBAAyB,CAC/B,CAAC;QAEM,cAAS,GAAG,KAAK,CAAC;QAClB,gBAAW,GAAkB,IAAI,CAAC;QAClC,uBAAkB,GAAmB,IAAI,CAAC;QAqB3C,SAAI,GAAkC,QAAQ,CAAC;IAgNxD,CAAC;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lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { addKeyboardFocusRing } from '../common/controllers/focus-ring.js';\nimport { addIdRefResolver } from '../common/controllers/id-resolver.js';\nimport { addInternalsController } from '../common/controllers/internals.js';\nimport { blazorDeepImport } from '../common/decorators/blazorDeepImport.js';\nimport { shadowOptions } from '../common/decorators/shadow-options.js';\nimport type { Constructor } from '../common/mixins/constructor.js';\nimport { EventEmitterMixin } from '../common/mixins/event-emitter.js';\nimport { partMap } from '../common/part-map.js';\nimport { bindIf, getElementByIdFromRoot } from '../common/util.js';\n\nexport interface IgcButtonEventMap {\n // For analyzer meta only:\n /* skipWCPrefix */\n focus: FocusEvent;\n /* skipWCPrefix */\n blur: FocusEvent;\n}\n\n/**\n * Abstract base class shared by `igc-button` and `igc-icon-button`.\n *\n * Provides common form-association behavior, link-button rendering\n * (renders as `<a>` when `href` is set), keyboard focus-ring management,\n * and the Invoker Commands API (`command` / `commandfor`).\n *\n * Concrete subclasses must implement `_renderContent()` to supply the\n * visual content projected inside the native `<button>` or `<a>` element.\n */\n@blazorDeepImport\n@shadowOptions({ delegatesFocus: true })\nexport abstract class IgcButtonBaseComponent extends EventEmitterMixin<\n IgcButtonEventMap,\n Constructor<LitElement>\n>(LitElement) {\n public static readonly formAssociated = true;\n\n //#region Internal state\n\n private readonly _focusRingManager = addKeyboardFocusRing(this);\n private readonly _internals = addInternalsController(this);\n private readonly _resolver = addIdRefResolver(\n this,\n this._resolveCommandForElement\n );\n\n private _disabled = false;\n private _commandfor: string | null = null;\n private _commandForElement: Element | null = null;\n\n @query('[part=\"base\"]', true)\n private readonly _nativeButton?: HTMLButtonElement | HTMLAnchorElement;\n\n //#endregion\n\n //#region Public properties\n\n /* alternateName: displayType */\n /**\n * The type of the button, which determines its behavior and semantics.\n * - `'button'` – no default action; useful for custom JavaScript handlers.\n * - `'submit'` – submits the associated form when clicked.\n * - `'reset'` – resets the associated form fields to their initial values.\n *\n * Ignored when the button is rendered as a link (i.e. `href` is set).\n * @attr type\n * @default 'button'\n */\n @property({ reflect: true })\n public type: 'button' | 'reset' | 'submit' = 'button';\n\n /**\n * The URL the button points to. When set, the component renders as an\n * `<a>` element instead of a `<button>`, enabling navigation on click.\n * Use together with `target`, `download`, and `rel` for full anchor semantics.\n * @attr href\n */\n @property()\n public href?: string;\n\n /**\n * Prompts the browser to download the linked resource rather than navigating\n * to it. The optional value is used as the suggested file name.\n * Only effective when `href` is set.\n * @attr download\n */\n @property()\n public download?: string;\n\n /**\n * Where to open the linked document. Only effective when `href` is set.\n * - `'_self'` – current browsing context (default browser behavior).\n * - `'_blank'` – new tab or window.\n * - `'_parent'` – parent browsing context; falls back to `_self` if none.\n * - `'_top'` – top-level browsing context; falls back to `_self` if none.\n * @attr target\n */\n @property()\n public target?: '_blank' | '_parent' | '_self' | '_top';\n\n /**\n * The relationship between the current document and the linked URL.\n * Accepts a space-separated list of link types (e.g. `'noopener noreferrer'`).\n * Only effective when `href` is set. When `target=\"_blank\"` is used,\n * setting `rel=\"noopener noreferrer\"` is strongly recommended for security.\n * @attr rel\n */\n @property()\n public rel?: string;\n\n /**\n * When set, the button will be disabled and non-interactive.\n *\n * @attr disabled\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public set disabled(value: boolean) {\n this._disabled = value;\n this.toggleAttribute('disabled', Boolean(this._disabled));\n }\n\n public get disabled(): boolean {\n return this._disabled;\n }\n\n /**\n * The command to invoke on the target element specified by `commandfor`.\n * Part of the [Invoker Commands](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API) API.\n * Custom commands must start with two dashes (e.g. `'--my-command'`).\n * @attr command\n */\n @property({ reflect: true })\n public command?: string;\n\n /**\n * The ID of the target element for the invoker command.\n * Part of the [Invoker Commands API](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API).\n * @attr commandfor\n */\n @property({ attribute: 'commandfor' })\n public set commandfor(value: string | null) {\n this._commandfor = value;\n if (value) {\n this._resolver.observe();\n this._commandForElement = getElementByIdFromRoot(this, value);\n } else {\n this._commandForElement = null;\n this._resolver.unobserve();\n }\n }\n\n public get commandfor(): string | null {\n return this._commandfor;\n }\n\n /* blazorCSSuppress */\n /* alternateType: object */\n /**\n * The target element for the invoker command. Resolved from the `commandfor` ID.\n */\n public get commandForElement(): Element | null {\n return this._commandForElement;\n }\n\n /* blazorCSSuppress */\n /* alternateType: object */\n public set commandForElement(value: Element | null) {\n this._commandForElement = value;\n this.requestUpdate();\n }\n\n /* blazorCSSuppress */\n /* alternateType: object */\n /**\n * The `<form>` element the button is associated with.\n * Resolved through the standard form-association mechanism — either the\n * closest ancestor `<form>` or the form referenced by the button's `form`\n * attribute. Returns `null` when no form is associated.\n * Relevant only when `type` is `'submit'` or `'reset'`.\n */\n public get form(): HTMLFormElement | null {\n return this._internals.form;\n }\n\n //#endregion\n\n //#region Lifecycle\n\n protected override firstUpdated(): void {\n this.updateComplete.then(() => {\n if (this._commandfor) {\n this._commandForElement = getElementByIdFromRoot(\n this,\n this._commandfor\n );\n this.requestUpdate();\n }\n });\n }\n\n //#endregion\n\n //#region Event handlers\n\n protected _handleClick(): void {\n switch (this.type) {\n case 'submit':\n this.form?.requestSubmit();\n break;\n case 'reset':\n this.form?.reset();\n break;\n }\n }\n\n protected formDisabledCallback(state: boolean): void {\n this._disabled = state;\n this.requestUpdate();\n }\n\n //#endregion\n\n private _resolveCommandForElement(ids: Set<string>): void {\n if (this._commandfor && ids.has(this._commandfor)) {\n this._commandForElement = getElementByIdFromRoot(this, this._commandfor);\n this.requestUpdate();\n }\n }\n\n //#region Public API\n\n /** Simulates a mouse click on the button, triggering its click handler and any associated form action. */\n public override click(): void {\n this._nativeButton?.click();\n }\n\n //#endregion\n\n private _renderButton() {\n return html`\n <button\n command=${ifDefined(this.command)}\n .commandForElement=${this._commandForElement}\n part=${partMap({ base: true, focused: this._focusRingManager.focused })}\n aria-label=${bindIf(this.ariaLabel, this.ariaLabel)}\n ?disabled=${this.disabled}\n type=${ifDefined(this.type)}\n @click=${this._handleClick}\n >\n ${this._renderContent()}\n </button>\n `;\n }\n\n private _renderLinkButton() {\n return html`\n <a\n part=${partMap({ base: true, focused: this._focusRingManager.focused })}\n role=\"button\"\n aria-label=${bindIf(this.ariaLabel, this.ariaLabel)}\n aria-disabled=${this.disabled}\n href=${ifDefined(this.href)}\n target=${ifDefined(this.target)}\n download=${ifDefined(this.download)}\n rel=${ifDefined(this.rel)}\n >\n ${this._renderContent()}\n </a>\n `;\n }\n\n protected abstract _renderContent(): TemplateResult;\n\n protected override render() {\n return this.href != null ? this._renderLinkButton() : this._renderButton();\n }\n}\n"]}
|
|
@@ -32,15 +32,15 @@ export default class IgcIconButtonComponent extends IgcButtonBaseComponent {
|
|
|
32
32
|
return html `
|
|
33
33
|
${this.name || this.mirrored
|
|
34
34
|
? html `
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
<igc-icon
|
|
36
|
+
part="icon"
|
|
37
|
+
name=${ifDefined(this.name)}
|
|
38
|
+
collection=${ifDefined(this.collection)}
|
|
39
|
+
?mirrored=${this.mirrored}
|
|
40
|
+
aria-hidden="true"
|
|
41
|
+
></igc-icon>
|
|
42
|
+
<slot></slot>
|
|
43
|
+
`
|
|
44
44
|
: html `<slot></slot>`}
|
|
45
45
|
`;
|
|
46
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-button.js","sourceRoot":"","sources":["../../../src/components/button/icon-button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAA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AE,UAAU,CAAC,CAAC;IACjD,CAAC;IAIS,oBAAoB,CAC5B,IAAY,EACZ,QAAgB,EAChB,UAAU,GAAG,SAAS;QAEtB,yBAAyB,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IACxD,CAAC;;AAtEM;IADN,QAAQ,EAAE;oDACU;AAOd;IADN,QAAQ,EAAE;0DACgB;AAQpB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wDACJ;AAWjB;IADN,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uDACoB;AA4BhC;IADf,aAAa,EAAE;0DAOf;AAIS;IADT,aAAa,EAAE;kEAOf","sourcesContent":["import { html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { addThemingController } from '../../theming/theming-controller.js';\nimport { blazorInclude } from '../common/decorators/blazorInclude.js';\nimport { registerComponent } from '../common/definitions/register.js';\nimport IgcIconComponent from '../icon/icon.js';\nimport {\n registerIcon as registerIcon_impl,\n registerIconFromText as registerIconFromText_impl,\n} from '../icon/icon.registry.js';\nimport type { IconButtonVariant } from '../types.js';\nimport { IgcButtonBaseComponent } from './button-base.js';\nimport { styles } from './themes/icon-button/icon-button.base.css.js';\nimport { styles as shared } from './themes/icon-button/shared/icon-button.common.css.js';\nimport { all } from './themes/icon-button/themes.js';\n\n/**\n * A button that displays a single icon, designed for compact, icon-only\n * interactions such as toolbar actions, floating action buttons, or inline\n * controls.\n *\n * The icon is sourced from the icon registry via the `name` and `collection`\n * attributes. Like the normal button, it can render as an anchor element when\n * `href` is set and is fully form-associated.\n *\n * @element igc-icon-button\n *\n * @slot - Optional label rendered alongside the icon, useful for\n * accessibility or augmented layouts.\n *\n * @csspart base - The wrapping element of the icon button.\n * @csspart icon - The icon element of the icon button.\n */\nexport default class IgcIconButtonComponent extends IgcButtonBaseComponent {\n public static readonly tagName = 'igc-icon-button';\n protected static styles = [styles, shared];\n\n /* blazorSuppress */\n public static register(): void {\n registerComponent(IgcIconButtonComponent, IgcIconComponent);\n }\n\n /* alternateName: iconName */\n /**\n * The name of the icon to display.\n * @attr name\n */\n @property()\n public name?: string;\n\n /**\n * The collection the icon belongs to.\n * @attr collection\n */\n @property()\n public collection?: string;\n\n /**\n * Determines whether the icon should be mirrored in right-to-left contexts.\n * @attr mirrored\n * @default false\n */\n @property({ type: Boolean })\n public mirrored = false;\n\n /**\n * The variant of the button which determines its visual appearance.\n * - `contained` – filled background; highest visual emphasis (default).\n * - `outlined` – transparent background with a visible border.\n * - `flat` – no background or border; lowest visual emphasis.\n * @attr variant\n * @default 'contained'\n */\n @property({ reflect: true })\n public variant: IconButtonVariant = 'contained';\n\n constructor() {\n super();\n addThemingController(this, all);\n }\n\n protected _renderContent() {\n return html`\n ${\n this.name || this.mirrored\n ? html`\n <igc-icon\n part=\"icon\"\n name=${ifDefined(this.name)}\n collection=${ifDefined(this.collection)}\n ?mirrored=${this.mirrored}\n aria-hidden=\"true\"\n ></igc-icon>\n <slot></slot>\n `\n : html`<slot></slot>`\n }\n `;\n }\n\n /* c8 ignore next 8 */\n @blazorInclude()\n protected async registerIcon(\n name: string,\n url: string,\n collection = 'default'\n ) {\n await registerIcon_impl(name, url, collection);\n }\n\n /* c8 ignore next 8 */\n @blazorInclude()\n protected registerIconFromText(\n name: string,\n iconText: string,\n collection = 'default'\n ) {\n registerIconFromText_impl(name, iconText, collection);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-icon-button': IgcIconButtonComponent;\n }\n}\n"]}
|