@nvidia-elements/core 2.0.1 → 2.0.3
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 +45 -0
- package/README.md +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.132.0/helpers → _@oxc-project_runtime@0.133.0/helpers/esm}/decorate.js +1 -1
- package/dist/accordion/accordion2.js +5 -5
- package/dist/alert/alert-group2.js +2 -2
- package/dist/alert/alert2.js +2 -2
- package/dist/avatar/avatar-group2.js +1 -1
- package/dist/avatar/avatar.examples.js.map +1 -1
- package/dist/avatar/avatar.examples.json +1 -1
- package/dist/avatar/avatar2.js +2 -2
- package/dist/badge/badge2.js +2 -2
- package/dist/breadcrumb/breadcrumb2.js +2 -2
- package/dist/bundles/index.d.ts +6 -17
- package/dist/bundles/index.js +6 -6
- package/dist/button/button2.js +2 -2
- package/dist/button-group/button-group2.js +2 -2
- package/dist/card/card.examples.js.map +1 -1
- package/dist/card/card.examples.json +1 -1
- package/dist/card/card2.js +5 -5
- package/dist/chat-message/chat-message.d.ts +0 -2
- package/dist/chat-message/chat-message2.js +2 -2
- package/dist/chat-message/chat-message2.js.map +1 -1
- package/dist/checkbox/checkbox-group2.js +2 -2
- package/dist/checkbox/checkbox2.js +2 -2
- package/dist/color/color2.js +2 -2
- package/dist/combobox/combobox2.js +8 -8
- package/dist/copy-button/copy-button2.js +2 -2
- package/dist/custom-elements.json +155 -720
- package/dist/data.html.json +26 -3
- package/dist/data.snippets.json +27 -27
- package/dist/date/date2.js +2 -2
- package/dist/datetime/datetime2.js +2 -2
- package/dist/dialog/dialog-footer2.js +2 -2
- package/dist/dialog/dialog-header2.js +2 -2
- package/dist/dialog/dialog2.js +2 -2
- package/dist/divider/divider2.js +2 -2
- package/dist/dot/dot2.js +2 -2
- package/dist/drawer/drawer-content2.js +2 -2
- package/dist/drawer/drawer-footer2.js +2 -2
- package/dist/drawer/drawer-header2.js +2 -2
- package/dist/drawer/drawer2.js +2 -2
- package/dist/dropdown/dropdown-footer2.js +2 -2
- package/dist/dropdown/dropdown-header2.js +2 -2
- package/dist/dropdown/dropdown2.js +2 -2
- package/dist/dropdown-group/dropdown-group.d.ts +0 -1
- package/dist/dropdown-group/dropdown-group.js +2 -2
- package/dist/dropdown-group/dropdown-group.js.map +1 -1
- package/dist/dropzone/dropzone.d.ts +0 -1
- package/dist/dropzone/dropzone2.js +2 -2
- package/dist/dropzone/dropzone2.js.map +1 -1
- package/dist/file/file2.js +1 -1
- package/dist/format-datetime/format-datetime.d.ts +1 -0
- package/dist/format-datetime/format-datetime2.js +2 -2
- package/dist/format-datetime/format-datetime2.js.map +1 -1
- package/dist/format-number/format-number.d.ts +1 -0
- package/dist/format-number/format-number2.js +2 -2
- package/dist/format-number/format-number2.js.map +1 -1
- package/dist/format-relative-time/format-relative-time.d.ts +1 -0
- package/dist/format-relative-time/format-relative-time2.js +6 -3
- package/dist/format-relative-time/format-relative-time2.js.map +1 -1
- package/dist/forms/control/control.js +1 -1
- package/dist/forms/control/control.js.map +1 -1
- package/dist/forms/control/control2.js +39 -21
- package/dist/forms/control/control2.js.map +1 -1
- package/dist/forms/control-group/control-group.js +1 -1
- package/dist/forms/control-group/control-group.js.map +1 -1
- package/dist/forms/control-group/control-group2.js +2 -2
- package/dist/forms/control-group/control-group2.js.map +1 -1
- package/dist/forms/control-message/control-message2.js +2 -2
- package/dist/forms/utils/states.d.ts +6 -3
- package/dist/forms/utils/states.js +40 -32
- package/dist/forms/utils/states.js.map +1 -1
- package/dist/grid/cell/cell2.js +1 -1
- package/dist/grid/column/column2.js +2 -2
- package/dist/grid/footer/footer2.js +2 -2
- package/dist/grid/grid2.js +2 -2
- package/dist/grid/header/header2.js +2 -2
- package/dist/grid/placeholder/placeholder2.js +1 -1
- package/dist/grid/row/row2.js +2 -2
- package/dist/icon/icon2.js +3 -3
- package/dist/icon-button/icon-button2.js +2 -2
- package/dist/index.js +1 -1
- package/dist/input/input-group2.js +1 -1
- package/dist/input/input2.js +2 -2
- package/dist/internal/controllers/keynav-grid.controller.js +22 -18
- package/dist/internal/controllers/keynav-grid.controller.js.map +1 -1
- package/dist/internal/controllers/keynav-list.controller.d.ts +1 -0
- package/dist/internal/controllers/keynav-list.controller.js +6 -1
- package/dist/internal/controllers/keynav-list.controller.js.map +1 -1
- package/dist/internal/controllers/type-native-popover.controller.js +70 -40
- package/dist/internal/controllers/type-native-popover.controller.js.map +1 -1
- package/dist/internal/index.d.ts +0 -9
- package/dist/internal/index.js +20 -29
- package/dist/internal/services/global.service.js +1 -1
- package/dist/internal/services/log.service.js +1 -1
- package/dist/internal/services/log.service.js.map +1 -1
- package/dist/internal/types/index.d.ts +3 -0
- package/dist/internal/types/index.js.map +1 -1
- package/dist/internal/utils/dom.d.ts +1 -1
- package/dist/internal/utils/dom.js +71 -54
- package/dist/internal/utils/dom.js.map +1 -1
- package/dist/logo/logo2.js +2 -2
- package/dist/menu/menu-item2.js +2 -2
- package/dist/menu/menu2.js +2 -2
- package/dist/month/month2.js +2 -2
- package/dist/notification/notification-group2.js +2 -2
- package/dist/notification/notification2.js +2 -2
- package/dist/page/page-panel/page-panel-content2.js +1 -1
- package/dist/page/page-panel/page-panel-footer2.js +2 -2
- package/dist/page/page-panel/page-panel-header2.js +2 -2
- package/dist/page/page-panel/page-panel2.js +2 -2
- package/dist/page/page.examples.js.map +1 -1
- package/dist/page/page.examples.json +1 -1
- package/dist/page/page2.js +2 -2
- package/dist/page-header/page-header2.js +1 -1
- package/dist/page-loader/page-loader2.js +2 -2
- package/dist/pagination/pagination2.js +2 -2
- package/dist/panel/panel2.js +5 -5
- package/dist/password/password2.js +2 -2
- package/dist/preferences-input/preferences-input.js +1 -1
- package/dist/preferences-input/preferences-input.js.map +1 -1
- package/dist/preferences-input/preferences-input2.js +2 -2
- package/dist/progress-bar/progress-bar2.js +2 -2
- package/dist/progress-ring/progress-ring2.js +2 -2
- package/dist/progressive-filter-chip/progressive-filter-chip.examples.js.map +1 -1
- package/dist/progressive-filter-chip/progressive-filter-chip.examples.json +1 -1
- package/dist/progressive-filter-chip/progressive-filter-chip2.js +2 -2
- package/dist/pulse/pulse2.js +2 -2
- package/dist/radio/radio-group2.js +2 -2
- package/dist/radio/radio2.js +2 -2
- package/dist/range/range2.js +2 -2
- package/dist/resize-handle/resize-handle2.js +2 -2
- package/dist/search/search2.js +2 -2
- package/dist/select/select2.js +35 -21
- package/dist/select/select2.js.map +1 -1
- package/dist/skeleton/skeleton2.js +2 -2
- package/dist/sort-button/sort-button2.js +2 -2
- package/dist/sparkline/sparkline.utils.js +4 -2
- package/dist/sparkline/sparkline.utils.js.map +1 -1
- package/dist/sparkline/sparkline2.js +2 -2
- package/dist/star-rating/star-rating2.js +2 -2
- package/dist/steps/steps2.js +3 -3
- package/dist/switch/switch-group2.js +2 -2
- package/dist/switch/switch2.js +2 -2
- package/dist/tabs/tabs-group2.js +2 -2
- package/dist/tabs/tabs.examples.js.map +1 -1
- package/dist/tabs/tabs.examples.json +1 -1
- package/dist/tabs/tabs2.js +3 -3
- package/dist/tag/tag2.js +2 -2
- package/dist/textarea/textarea2.js +1 -1
- package/dist/time/time2.js +2 -2
- package/dist/toast/toast2.js +2 -2
- package/dist/toggletip/toggletip-footer.d.ts +1 -1
- package/dist/toggletip/toggletip-footer2.js +2 -2
- package/dist/toggletip/toggletip-footer2.js.map +1 -1
- package/dist/toggletip/toggletip-header.d.ts +1 -1
- package/dist/toggletip/toggletip-header2.js +2 -2
- package/dist/toggletip/toggletip-header2.js.map +1 -1
- package/dist/toggletip/toggletip2.js +2 -2
- package/dist/toolbar/toolbar2.js +2 -2
- package/dist/tooltip/tooltip2.js +2 -2
- package/dist/tree/tree-node2.js +2 -2
- package/dist/tree/tree2.js +2 -2
- package/dist/week/week2.js +2 -2
- package/package.json +8 -8
- package/dist/internal/controllers/state-active.controller.d.ts +0 -18
- package/dist/internal/controllers/state-active.controller.js +0 -29
- package/dist/internal/controllers/state-active.controller.js.map +0 -1
- package/dist/internal/controllers/state-current.controller.d.ts +0 -18
- package/dist/internal/controllers/state-current.controller.js +0 -28
- package/dist/internal/controllers/state-current.controller.js.map +0 -1
- package/dist/internal/controllers/state-disabled.controller.d.ts +0 -18
- package/dist/internal/controllers/state-disabled.controller.js +0 -20
- package/dist/internal/controllers/state-disabled.controller.js.map +0 -1
- package/dist/internal/controllers/state-pressed.controller.d.ts +0 -18
- package/dist/internal/controllers/state-pressed.controller.js +0 -20
- package/dist/internal/controllers/state-pressed.controller.js.map +0 -1
- package/dist/internal/controllers/type-button.controller.d.ts +0 -18
- package/dist/internal/controllers/type-button.controller.examples.js +0 -6
- package/dist/internal/controllers/type-button.controller.examples.js.map +0 -1
- package/dist/internal/controllers/type-button.controller.examples.json +0 -16
- package/dist/internal/controllers/type-button.controller.js +0 -21
- package/dist/internal/controllers/type-button.controller.js.map +0 -1
- package/dist/internal/controllers/type-command.controller.d.ts +0 -25
- package/dist/internal/controllers/type-command.controller.js +0 -38
- package/dist/internal/controllers/type-command.controller.js.map +0 -1
- package/dist/internal/controllers/type-interest.controller.d.ts +0 -23
- package/dist/internal/controllers/type-interest.controller.js +0 -51
- package/dist/internal/controllers/type-interest.controller.js.map +0 -1
- package/dist/internal/controllers/type-native-popover-trigger.controller.d.ts +0 -16
- package/dist/internal/controllers/type-native-popover-trigger.controller.js +0 -25
- package/dist/internal/controllers/type-native-popover-trigger.controller.js.map +0 -1
- package/dist/internal/controllers/type-submit.controller.d.ts +0 -22
- package/dist/internal/controllers/type-submit.controller.js +0 -49
- package/dist/internal/controllers/type-submit.controller.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state-active.controller.js","names":["#emulateActive","#emulateInactive","#isValidKeyEvent"],"sources":["../../../src/internal/controllers/state-active.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport type { LegacyDecoratorTarget } from '../types/index.js';\nimport { attachInternals } from '../utils/a11y.js';\n\n/**\n * Adds CSS State psuedo-selector :state(active) behavior for keydown space/enter for custom elements\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states\n */\nexport function stateActive<T extends Active>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) =>\n target.addInitializer!((instance: T) => new StateActiveController(instance));\n}\n\ntype Active = ReactiveElement & { disabled: boolean; _internals?: ElementInternals };\n\nexport class StateActiveController<T extends Active> implements ReactiveController {\n #initialized = false;\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n this.host.addEventListener('keypress', this.#emulateActive as EventListener);\n this.host.addEventListener('mousedown', this.#emulateActive as EventListener);\n this.host.addEventListener('keyup', this.#emulateInactive);\n this.host.addEventListener('blur', this.#emulateInactive);\n this.host.addEventListener('mouseup', this.#emulateInactive);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('keypress', this.#emulateActive as EventListener);\n this.host.removeEventListener('mousedown', this.#emulateActive as EventListener);\n this.host.removeEventListener('keyup', this.#emulateInactive);\n this.host.removeEventListener('blur', this.#emulateInactive);\n this.host.removeEventListener('mouseup', this.#emulateInactive);\n }\n\n #emulateActive = (e: KeyboardEvent | PointerEvent) => {\n if (!this.host.disabled && this.#isValidKeyEvent(e)) {\n this.host._internals!.states.add('active');\n }\n\n if (e instanceof KeyboardEvent && e.code === 'Space' && e.target === this.host) {\n e.preventDefault(); // prevent space bar scroll with standard button behavior\n }\n };\n\n #emulateInactive = () => {\n this.host._internals!.states.delete('active');\n };\n\n #isValidKeyEvent(e: KeyboardEvent | PointerEvent) {\n return e instanceof KeyboardEvent ? e.code === 'Space' || e.code === 'Enter' : true;\n }\n}\n"],"mappings":";;AAWA,SAAgB,IAAgD;CAC9D,QAAQ,MACN,EAAO,gBAAiB,MAAgB,IAAI,EAAsB,CAAQ,CAAC;AAC/E;AAIA,IAAa,IAAb,MAAmF;CAEjF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EAMd,AALA,EAAgB,KAAK,IAAI,GACzB,KAAK,KAAK,iBAAiB,YAAY,KAAKA,EAA+B,GAC3E,KAAK,KAAK,iBAAiB,aAAa,KAAKA,EAA+B,GAC5E,KAAK,KAAK,iBAAiB,SAAS,KAAKC,EAAgB,GACzD,KAAK,KAAK,iBAAiB,QAAQ,KAAKA,EAAgB,GACxD,KAAK,KAAK,iBAAiB,WAAW,KAAKA,EAAgB;CAC7D;CAEA,mBAAmB;EAKjB,AAJA,KAAK,KAAK,oBAAoB,YAAY,KAAKD,EAA+B,GAC9E,KAAK,KAAK,oBAAoB,aAAa,KAAKA,EAA+B,GAC/E,KAAK,KAAK,oBAAoB,SAAS,KAAKC,EAAgB,GAC5D,KAAK,KAAK,oBAAoB,QAAQ,KAAKA,EAAgB,GAC3D,KAAK,KAAK,oBAAoB,WAAW,KAAKA,EAAgB;CAChE;CAEA,MAAkB,MAAoC;EAKpD,AAJI,CAAC,KAAK,KAAK,YAAY,KAAKC,GAAiB,CAAC,KAChD,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,GAGvC,aAAa,iBAAiB,EAAE,SAAS,WAAW,EAAE,WAAW,KAAK,QACxE,EAAE,eAAe;CAErB;CAEA,WAAyB;EACvB,KAAK,KAAK,WAAY,OAAO,OAAO,QAAQ;CAC9C;CAEA,GAAiB,GAAiC;EAChD,OAAO,aAAa,gBAAgB,EAAE,SAAS,WAAW,EAAE,SAAS,UAAU;CACjF;AACF"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
-
/**
|
|
3
|
-
* Adds current support for interactive custom elements including CSS State psuedo-selector :state(current) and aria-current.
|
|
4
|
-
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current
|
|
5
|
-
*/
|
|
6
|
-
export declare function stateCurrent<T extends Current>(): ClassDecorator;
|
|
7
|
-
type Current = ReactiveElement & {
|
|
8
|
-
current: 'page' | 'step';
|
|
9
|
-
readOnly?: boolean;
|
|
10
|
-
_internals?: ElementInternals;
|
|
11
|
-
};
|
|
12
|
-
export declare class StateCurrentController<T extends Current> implements ReactiveController {
|
|
13
|
-
private host;
|
|
14
|
-
constructor(host: T);
|
|
15
|
-
hostConnected(): void;
|
|
16
|
-
hostUpdated(): void;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { attachInternals as e } from "../utils/a11y.js";
|
|
2
|
-
//#region src/internal/controllers/state-current.controller.ts
|
|
3
|
-
function t() {
|
|
4
|
-
return (e) => e.addInitializer((e) => new n(e));
|
|
5
|
-
}
|
|
6
|
-
var n = class {
|
|
7
|
-
constructor(e) {
|
|
8
|
-
this.host = e, this.host.addController(this);
|
|
9
|
-
}
|
|
10
|
-
hostConnected() {
|
|
11
|
-
e(this.host);
|
|
12
|
-
}
|
|
13
|
-
hostUpdated() {
|
|
14
|
-
if (this.host.readOnly) {
|
|
15
|
-
this.host._internals.ariaCurrent = null, this.host._internals.states.delete("current");
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (this.host._internals?.states.has("anchor") && this.host.current) {
|
|
19
|
-
this.host._internals.ariaCurrent = null, this.host._internals.states.add("current"), this.host.querySelector("a")?.setAttribute("aria-current", "page");
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
this.host.current !== null && this.host.current !== void 0 && (this.host._internals.ariaCurrent = `${this.host.current}`), this.host.current ? this.host._internals.states.add("current") : this.host._internals.states.delete("current");
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
//#endregion
|
|
26
|
-
export { n as StateCurrentController, t as stateCurrent };
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=state-current.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state-current.controller.js","names":[],"sources":["../../../src/internal/controllers/state-current.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport type { LegacyDecoratorTarget } from '../types/index.js';\nimport { attachInternals } from '../utils/a11y.js';\n\n/**\n * Adds current support for interactive custom elements including CSS State psuedo-selector :state(current) and aria-current.\n * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current\n */\nexport function stateCurrent<T extends Current>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) =>\n target.addInitializer!((instance: T) => new StateCurrentController(instance));\n}\n\ntype Current = ReactiveElement & { current: 'page' | 'step'; readOnly?: boolean; _internals?: ElementInternals };\n\nexport class StateCurrentController<T extends Current> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.readOnly) {\n this.host._internals!.ariaCurrent = null;\n this.host._internals!.states.delete('current');\n return;\n }\n\n if (this.host._internals?.states.has('anchor') && this.host.current) {\n this.host._internals!.ariaCurrent = null;\n this.host._internals!.states.add('current');\n this.host.querySelector('a')?.setAttribute('aria-current', 'page');\n return;\n }\n\n if (this.host.current !== null && this.host.current !== undefined) {\n this.host._internals!.ariaCurrent = `${this.host.current}`;\n }\n\n if (this.host.current) {\n this.host._internals!.states.add('current');\n } else {\n this.host._internals!.states.delete('current');\n }\n }\n}\n"],"mappings":";;AAWA,SAAgB,IAAkD;CAChE,QAAQ,MACN,EAAO,gBAAiB,MAAgB,IAAI,EAAuB,CAAQ,CAAC;AAChF;AAIA,IAAa,IAAb,MAAqF;CACnF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EACZ,IAAI,KAAK,KAAK,UAAU;GAEtB,AADA,KAAK,KAAK,WAAY,cAAc,MACpC,KAAK,KAAK,WAAY,OAAO,OAAO,SAAS;GAC7C;EACF;EAEA,IAAI,KAAK,KAAK,YAAY,OAAO,IAAI,QAAQ,KAAK,KAAK,KAAK,SAAS;GAGnE,AAFA,KAAK,KAAK,WAAY,cAAc,MACpC,KAAK,KAAK,WAAY,OAAO,IAAI,SAAS,GAC1C,KAAK,KAAK,cAAc,GAAG,GAAG,aAAa,gBAAgB,MAAM;GACjE;EACF;EAMA,AAJI,KAAK,KAAK,YAAY,QAAQ,KAAK,KAAK,YAAY,KAAA,MACtD,KAAK,KAAK,WAAY,cAAc,GAAG,KAAK,KAAK,YAG/C,KAAK,KAAK,UACZ,KAAK,KAAK,WAAY,OAAO,IAAI,SAAS,IAE1C,KAAK,KAAK,WAAY,OAAO,OAAO,SAAS;CAEjD;AACF"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
-
/**
|
|
3
|
-
* Adds disabled support for interactive custom elements including CSS State psuedo-selector :state(disabled) and aria-disabled.
|
|
4
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states
|
|
5
|
-
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled
|
|
6
|
-
*/
|
|
7
|
-
export declare function stateDisabled<T extends Disabled>(): ClassDecorator;
|
|
8
|
-
export type Disabled = ReactiveElement & {
|
|
9
|
-
disabled: boolean;
|
|
10
|
-
readOnly?: boolean;
|
|
11
|
-
_internals?: ElementInternals;
|
|
12
|
-
};
|
|
13
|
-
export declare class StateDisabledController<T extends Disabled> implements ReactiveController {
|
|
14
|
-
private host;
|
|
15
|
-
constructor(host: T);
|
|
16
|
-
hostConnected(): void;
|
|
17
|
-
hostUpdated(): void;
|
|
18
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { attachInternals as e } from "../utils/a11y.js";
|
|
2
|
-
//#region src/internal/controllers/state-disabled.controller.ts
|
|
3
|
-
function t() {
|
|
4
|
-
return (e) => e.addInitializer((e) => new n(e));
|
|
5
|
-
}
|
|
6
|
-
var n = class {
|
|
7
|
-
constructor(e) {
|
|
8
|
-
this.host = e, this.host.addController(this);
|
|
9
|
-
}
|
|
10
|
-
hostConnected() {
|
|
11
|
-
e(this.host);
|
|
12
|
-
}
|
|
13
|
-
hostUpdated() {
|
|
14
|
-
this.host.disabled !== null && this.host.disabled !== void 0 ? this.host._internals.ariaDisabled = `${this.host.disabled}` : this.host._internals.ariaDisabled = null, this.host.disabled ? this.host._internals.states.add("disabled") : this.host._internals.states.delete("disabled"), this.host.readOnly && (this.host._internals.ariaDisabled = null);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
//#endregion
|
|
18
|
-
export { n as StateDisabledController, t as stateDisabled };
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=state-disabled.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state-disabled.controller.js","names":[],"sources":["../../../src/internal/controllers/state-disabled.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport type { LegacyDecoratorTarget } from '../types/index.js';\nimport { attachInternals } from '../utils/a11y.js';\n\n/**\n * Adds disabled support for interactive custom elements including CSS State psuedo-selector :state(disabled) and aria-disabled.\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states\n * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled\n */\nexport function stateDisabled<T extends Disabled>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) =>\n target.addInitializer!((instance: T) => new StateDisabledController(instance));\n}\n\nexport type Disabled = ReactiveElement & { disabled: boolean; readOnly?: boolean; _internals?: ElementInternals };\n\nexport class StateDisabledController<T extends Disabled> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.disabled !== null && this.host.disabled !== undefined) {\n this.host._internals!.ariaDisabled = `${this.host.disabled}`;\n } else {\n this.host._internals!.ariaDisabled = null;\n }\n\n if (this.host.disabled) {\n this.host._internals!.states.add('disabled');\n } else {\n this.host._internals!.states.delete('disabled');\n }\n\n if (this.host.readOnly) {\n this.host._internals!.ariaDisabled = null;\n }\n }\n}\n"],"mappings":";;AAYA,SAAgB,IAAoD;CAClE,QAAQ,MACN,EAAO,gBAAiB,MAAgB,IAAI,EAAwB,CAAQ,CAAC;AACjF;AAIA,IAAa,IAAb,MAAuF;CACrF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EAaZ,AAZI,KAAK,KAAK,aAAa,QAAQ,KAAK,KAAK,aAAa,KAAA,IACxD,KAAK,KAAK,WAAY,eAAe,GAAG,KAAK,KAAK,aAElD,KAAK,KAAK,WAAY,eAAe,MAGnC,KAAK,KAAK,WACZ,KAAK,KAAK,WAAY,OAAO,IAAI,UAAU,IAE3C,KAAK,KAAK,WAAY,OAAO,OAAO,UAAU,GAG5C,KAAK,KAAK,aACZ,KAAK,KAAK,WAAY,eAAe;CAEzC;AACF"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
-
/**
|
|
3
|
-
* Adds pressed support for interactive custom elements including CSS State psuedo-selector :state(pressed) and aria-pressed.
|
|
4
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states
|
|
5
|
-
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-pressed
|
|
6
|
-
*/
|
|
7
|
-
export declare function statePressed<T extends Pressed>(): ClassDecorator;
|
|
8
|
-
export type Pressed = ReactiveElement & {
|
|
9
|
-
pressed: boolean;
|
|
10
|
-
readOnly?: boolean;
|
|
11
|
-
_internals?: ElementInternals;
|
|
12
|
-
};
|
|
13
|
-
export declare class StatePressedController<T extends Pressed> implements ReactiveController {
|
|
14
|
-
private host;
|
|
15
|
-
constructor(host: T);
|
|
16
|
-
hostConnected(): void;
|
|
17
|
-
hostUpdated(): void;
|
|
18
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { attachInternals as e } from "../utils/a11y.js";
|
|
2
|
-
//#region src/internal/controllers/state-pressed.controller.ts
|
|
3
|
-
function t() {
|
|
4
|
-
return (e) => e.addInitializer((e) => new n(e));
|
|
5
|
-
}
|
|
6
|
-
var n = class {
|
|
7
|
-
constructor(e) {
|
|
8
|
-
this.host = e, this.host.addController(this);
|
|
9
|
-
}
|
|
10
|
-
hostConnected() {
|
|
11
|
-
e(this.host);
|
|
12
|
-
}
|
|
13
|
-
hostUpdated() {
|
|
14
|
-
this.host.pressed !== null && this.host.pressed !== void 0 && (this.host._internals.ariaPressed = `${this.host.pressed}`), this.host.pressed ? this.host._internals.states.add("pressed") : this.host._internals.states.delete("pressed"), this.host.readOnly && (this.host._internals.ariaPressed = null, this.host._internals.states.delete("pressed"));
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
//#endregion
|
|
18
|
-
export { n as StatePressedController, t as statePressed };
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=state-pressed.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state-pressed.controller.js","names":[],"sources":["../../../src/internal/controllers/state-pressed.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport type { LegacyDecoratorTarget } from '../types/index.js';\nimport { attachInternals } from '../utils/a11y.js';\n\n/**\n * Adds pressed support for interactive custom elements including CSS State psuedo-selector :state(pressed) and aria-pressed.\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states\n * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-pressed\n */\nexport function statePressed<T extends Pressed>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) =>\n target.addInitializer!((instance: T) => new StatePressedController(instance));\n}\n\nexport type Pressed = ReactiveElement & { pressed: boolean; readOnly?: boolean; _internals?: ElementInternals };\n\nexport class StatePressedController<T extends Pressed> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.pressed !== null && this.host.pressed !== undefined) {\n this.host._internals!.ariaPressed = `${this.host.pressed}`;\n }\n\n if (this.host.pressed) {\n this.host._internals!.states.add('pressed');\n } else {\n this.host._internals!.states.delete('pressed');\n }\n\n if (this.host.readOnly) {\n this.host._internals!.ariaPressed = null;\n this.host._internals!.states.delete('pressed');\n }\n }\n}\n"],"mappings":";;AAYA,SAAgB,IAAkD;CAChE,QAAQ,MACN,EAAO,gBAAiB,MAAgB,IAAI,EAAuB,CAAQ,CAAC;AAChF;AAIA,IAAa,IAAb,MAAqF;CACnF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EAWZ,AAVI,KAAK,KAAK,YAAY,QAAQ,KAAK,KAAK,YAAY,KAAA,MACtD,KAAK,KAAK,WAAY,cAAc,GAAG,KAAK,KAAK,YAG/C,KAAK,KAAK,UACZ,KAAK,KAAK,WAAY,OAAO,IAAI,SAAS,IAE1C,KAAK,KAAK,WAAY,OAAO,OAAO,SAAS,GAG3C,KAAK,KAAK,aACZ,KAAK,KAAK,WAAY,cAAc,MACpC,KAAK,KAAK,WAAY,OAAO,OAAO,SAAS;CAEjD;AACF"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
-
/**
|
|
3
|
-
* Adds button support for interactive custom elements including aria-button and focus behavior.
|
|
4
|
-
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role
|
|
5
|
-
*/
|
|
6
|
-
export declare function typeButton<T extends Button>(): ClassDecorator;
|
|
7
|
-
export interface Button extends ReactiveElement {
|
|
8
|
-
readOnly: boolean;
|
|
9
|
-
disabled: boolean;
|
|
10
|
-
_internals?: ElementInternals;
|
|
11
|
-
}
|
|
12
|
-
export declare class TypeButtonController<T extends Button> implements ReactiveController {
|
|
13
|
-
#private;
|
|
14
|
-
private host;
|
|
15
|
-
constructor(host: T);
|
|
16
|
-
hostConnected(): void;
|
|
17
|
-
hostUpdated(): Promise<void>;
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-button.controller.examples.js","names":[],"sources":["../../../src/internal/controllers/type-button.controller.examples.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { css, html, LitElement } from 'lit';\nimport { ButtonFormControlMixin } from '@nvidia-elements/forms/mixins';\nimport '@nvidia-elements/core/card/define.js';\nimport '@nvidia-elements/core/button/define.js';\nimport '@nvidia-elements/core/icon-button/define.js';\n\nexport default {\n title: 'Internal/Controllers'\n}\n\nclass UIButton extends ButtonFormControlMixin(LitElement) {\n static styles = [css`\n :host {\n --background: hsl(0, 0%, 90%);\n --color: hsl(0, 0%, 0%);\n --cursor: pointer;\n display: inline-flex;\n position: relative;\n }\n\n [internal-host] {\n background: var(--background);\n color: var(--color);\n cursor: var(--cursor);\n padding: 8px 12px;\n min-width: 75px;\n text-align: center;\n }\n\n /* element states */\n :host(:hover) {\n --background: hsl(0, 0%, 95%);\n }\n\n :host(:state(active)) {\n --background: hsl(0, 0%, 85%);\n }\n\n :host(:state(pressed)) {\n --background: hsl(0, 0%, 85%);\n }\n\n :host(:state(expanded)) {\n --background: hsl(0, 0%, 85%);\n }\n\n :host(:state(disabled)) {\n --background: hsl(0, 0%, 80%);\n --color: hsl(0, 0%, 60%);\n --cursor: not-allowed;\n }\n\n :host(:state(readonly)) {\n --cursor: initial;\n --color: blue;\n }\n\n /* anchor styles */\n [internal-host]:focus-within {\n outline: Highlight solid 2px;\n outline: 5px auto -webkit-focus-ring-color;\n }\n\n ::slotted(a) {\n color: var(--color) !important;\n text-decoration: none !important;\n outline: 0 !important;\n }\n\n ::slotted(a)::after {\n position: absolute;\n content: '';\n inset: 0;\n display: block;\n }\n `]\n}\n\ncustomElements.get('ui-button') || customElements.define('ui-button', UIButton);\n\n/**\n * Example of custom element button using the button form control mixin.\n * When a custom element applies the mixin it inherits button behaviors and states.\n * @summary Custom button element using ButtonFormControlMixin with pressed, expanded, disabled, and link states.\n * @tags test-case\n */\nexport const TypeButtonDemo = {\n render: () => html`\n<ui-button>button</ui-button>\n<ui-button pressed>pressed</ui-button>\n<ui-button expanded>expanded</ui-button>\n<ui-button selected>selected</ui-button>\n<ui-button disabled>disabled</ui-button>\n<ui-button><a href=\"#\">link</a></ui-button>\n\n<form id=\"type-button-demo-form\" style=\"display: inline-flex;\">\n <ui-button type=\"submit\">submit</ui-button>\n</form>\n<script type=\"module\">\n const form = document.querySelector('#type-button-demo-form');\n form.addEventListener('submit', (e) => {\n e.preventDefault();\n alert('submit!');\n });\n</script>`\n};\n"],"mappings":";AAGA,IAAA,IAAc"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"entrypoint": "@nvidia-elements/core/internal/controllers/type-button.controller.examples.json",
|
|
3
|
-
"items": [
|
|
4
|
-
{
|
|
5
|
-
"id": "internal-controllers-type-button.controller-type-button-demo",
|
|
6
|
-
"name": "TypeButtonDemo",
|
|
7
|
-
"template": "<ui-button>button</ui-button>\n<ui-button pressed>pressed</ui-button>\n<ui-button expanded>expanded</ui-button>\n<ui-button selected>selected</ui-button>\n<ui-button disabled>disabled</ui-button>\n<ui-button><a href=\"#\">link</a></ui-button>\n<form id=\"type-button-demo-form\" style=\"display: inline-flex\">\n <ui-button type=\"submit\">submit</ui-button>\n</form>\n<script type=\"module\">\n const form = document.querySelector(\"#type-button-demo-form\");\n form.addEventListener(\"submit\", (e) => {\n e.preventDefault();\n alert(\"submit!\");\n });\n</script>\n",
|
|
8
|
-
"summary": "Custom button element using ButtonFormControlMixin with pressed, expanded, disabled, and link states.",
|
|
9
|
-
"description": "",
|
|
10
|
-
"composition": false,
|
|
11
|
-
"tags": [
|
|
12
|
-
"test-case"
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
]
|
|
16
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { attachInternals as e } from "../utils/a11y.js";
|
|
2
|
-
//#region src/internal/controllers/type-button.controller.ts
|
|
3
|
-
function t() {
|
|
4
|
-
return (e) => e.addInitializer((e) => new n(e));
|
|
5
|
-
}
|
|
6
|
-
var n = class {
|
|
7
|
-
#e;
|
|
8
|
-
constructor(e) {
|
|
9
|
-
this.host = e, this.host.addController(this);
|
|
10
|
-
}
|
|
11
|
-
hostConnected() {
|
|
12
|
-
e(this.host), this.host.hasAttribute("tabindex") && (this.#e = this.host.tabIndex);
|
|
13
|
-
}
|
|
14
|
-
async hostUpdated() {
|
|
15
|
-
await this.host.updateComplete, this.host._internals.role || (this.host._internals.role = "button"), this.host.tabIndex = this.host.disabled ? -1 : this.#e, this.host.readOnly && (this.host._internals.role = "none", this.host.tabIndex = -1, this.host.removeAttribute("tabindex"));
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
19
|
-
export { n as TypeButtonController, t as typeButton };
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=type-button.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-button.controller.js","names":["#initialTabIndex"],"sources":["../../../src/internal/controllers/type-button.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport type { LegacyDecoratorTarget } from '../types/index.js';\nimport { attachInternals } from '../utils/a11y.js';\n\n/**\n * Adds button support for interactive custom elements including aria-button and focus behavior.\n * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role\n */\nexport function typeButton<T extends Button>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) => target.addInitializer!((instance: T) => new TypeButtonController(instance));\n}\n\nexport interface Button extends ReactiveElement {\n readOnly: boolean;\n disabled: boolean;\n _internals?: ElementInternals;\n}\n\nexport class TypeButtonController<T extends Button> implements ReactiveController {\n #initialTabIndex: number;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n\n if (this.host.hasAttribute('tabindex')) {\n this.#initialTabIndex = this.host.tabIndex;\n }\n }\n\n async hostUpdated() {\n await this.host.updateComplete;\n\n if (!this.host._internals!.role) {\n this.host._internals!.role = 'button';\n }\n\n this.host.tabIndex = this.host.disabled ? -1 : this.#initialTabIndex;\n\n if (this.host.readOnly) {\n this.host._internals!.role = 'none';\n this.host.tabIndex = -1;\n this.host.removeAttribute('tabindex');\n }\n }\n}\n"],"mappings":";;AAWA,SAAgB,IAA+C;CAC7D,QAAQ,MAAkC,EAAO,gBAAiB,MAAgB,IAAI,EAAqB,CAAQ,CAAC;AACtH;AAQA,IAAa,IAAb,MAAkF;CAChF;CAEA,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EAGd,AAFA,EAAgB,KAAK,IAAI,GAErB,KAAK,KAAK,aAAa,UAAU,MACnC,KAAKA,KAAmB,KAAK,KAAK;CAEtC;CAEA,MAAM,cAAc;EASlB,AARA,MAAM,KAAK,KAAK,gBAEX,KAAK,KAAK,WAAY,SACzB,KAAK,KAAK,WAAY,OAAO,WAG/B,KAAK,KAAK,WAAW,KAAK,KAAK,WAAW,KAAK,KAAKA,IAEhD,KAAK,KAAK,aACZ,KAAK,KAAK,WAAY,OAAO,QAC7B,KAAK,KAAK,WAAW,IACrB,KAAK,KAAK,gBAAgB,UAAU;CAExC;AACF"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
-
/**
|
|
3
|
-
* Adds Invoker Commands API support for interactive custom elements.
|
|
4
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API
|
|
5
|
-
*/
|
|
6
|
-
export declare function typeCommand<T extends Command>(): ClassDecorator;
|
|
7
|
-
export type Command = ReactiveElement & HTMLElement & {
|
|
8
|
-
command: string;
|
|
9
|
-
commandfor: string | null;
|
|
10
|
-
commandForElement: HTMLElement | null;
|
|
11
|
-
readOnly: boolean;
|
|
12
|
-
disabled: boolean;
|
|
13
|
-
};
|
|
14
|
-
export declare class TypeCommandController<T extends Command> implements ReactiveController {
|
|
15
|
-
#private;
|
|
16
|
-
private host;
|
|
17
|
-
constructor(host: T, options?: TypeCommandControllerOptions);
|
|
18
|
-
get target(): HTMLElement | null;
|
|
19
|
-
hostUpdated(): Promise<void>;
|
|
20
|
-
hostDisconnected(): void;
|
|
21
|
-
dispatchCommand(): boolean;
|
|
22
|
-
}
|
|
23
|
-
export interface TypeCommandControllerOptions {
|
|
24
|
-
trigger?: 'click' | 'manual';
|
|
25
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { getFlattenedDOMTree as e } from "../utils/dom.js";
|
|
2
|
-
//#region src/internal/controllers/type-command.controller.ts
|
|
3
|
-
function t() {
|
|
4
|
-
return (e) => e.addInitializer((e) => new n(e));
|
|
5
|
-
}
|
|
6
|
-
var n = class {
|
|
7
|
-
#e;
|
|
8
|
-
constructor(e, t = {}) {
|
|
9
|
-
this.host = e, this.#e = t.trigger ?? "click", this.host.addController(this);
|
|
10
|
-
}
|
|
11
|
-
get target() {
|
|
12
|
-
return this.host.commandForElement ? this.host.commandForElement : this.host.commandfor ? e(this.host.getRootNode()).find((e) => e.id === this.host.commandfor) ?? null : null;
|
|
13
|
-
}
|
|
14
|
-
async hostUpdated() {
|
|
15
|
-
await this.host.updateComplete, this.#t();
|
|
16
|
-
}
|
|
17
|
-
hostDisconnected() {
|
|
18
|
-
this.host.removeEventListener("click", this.#n);
|
|
19
|
-
}
|
|
20
|
-
#t() {
|
|
21
|
-
this.#e === "manual" || this.host.readOnly || this.host.disabled ? this.host.removeEventListener("click", this.#n) : this.host.addEventListener("click", this.#n);
|
|
22
|
-
}
|
|
23
|
-
#n = (e) => {
|
|
24
|
-
e.defaultPrevented || this.dispatchCommand();
|
|
25
|
-
};
|
|
26
|
-
dispatchCommand() {
|
|
27
|
-
if (this.host.readOnly || this.host.disabled || !this.host.command) return !1;
|
|
28
|
-
let e = this.target;
|
|
29
|
-
return e ? (e.dispatchEvent(new globalThis.CommandEvent("command", {
|
|
30
|
-
command: this.host.command,
|
|
31
|
-
source: this.host
|
|
32
|
-
})), !0) : ((this.host.commandfor || this.host.commandForElement) && console.warn("commandForElement", this.host.commandfor || this.host.commandForElement, "not found"), !1);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
//#endregion
|
|
36
|
-
export { n as TypeCommandController, t as typeCommand };
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=type-command.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-command.controller.js","names":["#trigger","#updateListener","#triggerCommand"],"sources":["../../../src/internal/controllers/type-command.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport type { LegacyDecoratorTarget } from '../types/index.js';\nimport { getFlattenedDOMTree } from '../utils/dom.js';\n\n/**\n * Adds Invoker Commands API support for interactive custom elements.\n * https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API\n */\nexport function typeCommand<T extends Command>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) =>\n target.addInitializer!((instance: T) => new TypeCommandController(instance));\n}\n\nexport type Command = ReactiveElement &\n HTMLElement & {\n command: string;\n commandfor: string | null;\n commandForElement: HTMLElement | null;\n readOnly: boolean;\n disabled: boolean;\n };\n\nexport class TypeCommandController<T extends Command> implements ReactiveController {\n #trigger: 'click' | 'manual';\n\n constructor(\n private host: T,\n options: TypeCommandControllerOptions = {}\n ) {\n this.#trigger = options.trigger ?? 'click';\n this.host.addController(this);\n }\n\n get target(): HTMLElement | null {\n if (this.host.commandForElement) {\n return this.host.commandForElement;\n }\n\n if (!this.host.commandfor) {\n return null;\n }\n\n return (\n getFlattenedDOMTree(this.host.getRootNode() as HTMLElement).find(el => el.id === this.host.commandfor) ?? null\n );\n }\n\n async hostUpdated() {\n await this.host.updateComplete;\n this.#updateListener();\n }\n\n hostDisconnected() {\n this.host.removeEventListener('click', this.#triggerCommand);\n }\n\n #updateListener() {\n if (this.#trigger === 'manual' || this.host.readOnly || this.host.disabled) {\n this.host.removeEventListener('click', this.#triggerCommand);\n } else {\n this.host.addEventListener('click', this.#triggerCommand);\n }\n }\n\n #triggerCommand = (event: Event) => {\n if (event.defaultPrevented) {\n return;\n }\n\n this.dispatchCommand();\n };\n\n dispatchCommand() {\n if (this.host.readOnly || this.host.disabled || !this.host.command) {\n return false;\n }\n\n const target = this.target;\n if (!target) {\n if (this.host.commandfor || this.host.commandForElement) {\n console.warn('commandForElement', this.host.commandfor || this.host.commandForElement, 'not found');\n }\n return false;\n }\n\n target.dispatchEvent(new globalThis.CommandEvent('command', { command: this.host.command, source: this.host }));\n return true;\n }\n}\n\nexport interface TypeCommandControllerOptions {\n trigger?: 'click' | 'manual';\n}\n"],"mappings":";;AAWA,SAAgB,IAAiD;CAC/D,QAAQ,MACN,EAAO,gBAAiB,MAAgB,IAAI,EAAsB,CAAQ,CAAC;AAC/E;AAWA,IAAa,IAAb,MAAoF;CAClF;CAEA,YACE,GACA,IAAwC,CAAC,GACzC;EAEA,AAJQ,KAAA,OAAA,GAGR,KAAKA,KAAW,EAAQ,WAAW,SACnC,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,IAAI,SAA6B;EAS/B,OARI,KAAK,KAAK,oBACL,KAAK,KAAK,oBAGd,KAAK,KAAK,aAKb,EAAoB,KAAK,KAAK,YAAY,CAAgB,EAAE,MAAK,MAAM,EAAG,OAAO,KAAK,KAAK,UAAU,KAAK,OAJnG;CAMX;CAEA,MAAM,cAAc;EAElB,AADA,MAAM,KAAK,KAAK,gBAChB,KAAKC,GAAgB;CACvB;CAEA,mBAAmB;EACjB,KAAK,KAAK,oBAAoB,SAAS,KAAKC,EAAe;CAC7D;CAEA,KAAkB;EAChB,AAAI,KAAKF,OAAa,YAAY,KAAK,KAAK,YAAY,KAAK,KAAK,WAChE,KAAK,KAAK,oBAAoB,SAAS,KAAKE,EAAe,IAE3D,KAAK,KAAK,iBAAiB,SAAS,KAAKA,EAAe;CAE5D;CAEA,MAAmB,MAAiB;EAC9B,EAAM,oBAIV,KAAK,gBAAgB;CACvB;CAEA,kBAAkB;EAChB,IAAI,KAAK,KAAK,YAAY,KAAK,KAAK,YAAY,CAAC,KAAK,KAAK,SACzD,OAAO;EAGT,IAAM,IAAS,KAAK;EASpB,OARK,KAOL,EAAO,cAAc,IAAI,WAAW,aAAa,WAAW;GAAE,SAAS,KAAK,KAAK;GAAS,QAAQ,KAAK;EAAK,CAAC,CAAC,GACvG,QAPD,KAAK,KAAK,cAAc,KAAK,KAAK,sBACpC,QAAQ,KAAK,qBAAqB,KAAK,KAAK,cAAc,KAAK,KAAK,mBAAmB,WAAW,GAE7F;CAKX;AACF"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
-
export type InterestEvent = Event & {
|
|
3
|
-
source: HTMLElement;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Adds Interest Invoker Commands API support for interactive custom elements.
|
|
7
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/Popover_API/Using_interest_invokers
|
|
8
|
-
*/
|
|
9
|
-
export declare function typeInterest<T extends Interest>(): ClassDecorator;
|
|
10
|
-
export type Interest = ReactiveElement & HTMLElement & {
|
|
11
|
-
interestfor: string | null;
|
|
12
|
-
interestForElement: HTMLElement | null;
|
|
13
|
-
readOnly: boolean;
|
|
14
|
-
disabled: boolean;
|
|
15
|
-
};
|
|
16
|
-
export declare class TypeInterestController<T extends Interest> implements ReactiveController {
|
|
17
|
-
#private;
|
|
18
|
-
private host;
|
|
19
|
-
constructor(host: T);
|
|
20
|
-
hostConnected(): Promise<void>;
|
|
21
|
-
hostUpdated(): Promise<void>;
|
|
22
|
-
hostDisconnected(): void;
|
|
23
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { getFlattenedDOMTree as e } from "../utils/dom.js";
|
|
2
|
-
//#region src/internal/controllers/type-interest.controller.ts
|
|
3
|
-
function t() {
|
|
4
|
-
return (e) => e.addInitializer((e) => new n(e));
|
|
5
|
-
}
|
|
6
|
-
var n = class {
|
|
7
|
-
#e = !1;
|
|
8
|
-
constructor(e) {
|
|
9
|
-
this.host = e, this.host.addController(this);
|
|
10
|
-
}
|
|
11
|
-
async hostConnected() {
|
|
12
|
-
await this.#t();
|
|
13
|
-
}
|
|
14
|
-
async hostUpdated() {
|
|
15
|
-
await this.#t();
|
|
16
|
-
}
|
|
17
|
-
hostDisconnected() {
|
|
18
|
-
this.#n();
|
|
19
|
-
}
|
|
20
|
-
async #t() {
|
|
21
|
-
await this.host.updateComplete, this.#e || (this.#e = !0, this.host.addEventListener("mouseenter", this.#r), this.host.addEventListener("mouseleave", this.#i), this.host.addEventListener("focus", this.#r), this.host.addEventListener("blur", this.#i));
|
|
22
|
-
}
|
|
23
|
-
#n() {
|
|
24
|
-
this.#e = !1, this.host.removeEventListener("mouseenter", this.#r), this.host.removeEventListener("mouseleave", this.#i), this.host.removeEventListener("focus", this.#r), this.host.removeEventListener("blur", this.#i);
|
|
25
|
-
}
|
|
26
|
-
#r = () => {
|
|
27
|
-
if (this.#a(), this.host.interestForElement) {
|
|
28
|
-
let e = new Event("interest", { cancelable: !0 });
|
|
29
|
-
e.source = this.host, this.host.interestForElement.dispatchEvent(e);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
#i = () => {
|
|
33
|
-
if (this.#a(), this.host.interestForElement) {
|
|
34
|
-
let e = new Event("loseinterest", { cancelable: !0 });
|
|
35
|
-
e.source = this.host, this.host.interestForElement.dispatchEvent(e);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
#a() {
|
|
39
|
-
let t = this.host.getAttribute("interestfor");
|
|
40
|
-
t && !this.host.interestForElement && (this.host.interestForElement = e(this.host.getRootNode()).find((e) => e.id === t));
|
|
41
|
-
let n = this.host.getAttribute("popovertarget");
|
|
42
|
-
if (n && !t) {
|
|
43
|
-
let t = e(this.host.getRootNode()).find((e) => e.id === n);
|
|
44
|
-
t && t.popover === "hint" && (this.host.interestForElement = t);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
//#endregion
|
|
49
|
-
export { n as TypeInterestController, t as typeInterest };
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=type-interest.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-interest.controller.js","names":["#setupInterestEvents","#teardownInterestEvents","#interestSetupComplete","#triggerInterest","#triggerLoseInterest","#updateInterestForElement"],"sources":["../../../src/internal/controllers/type-interest.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport type { LegacyDecoratorTarget } from '../types/index.js';\nimport { getFlattenedDOMTree } from '../utils/dom.js';\n\nexport type InterestEvent = Event & {\n source: HTMLElement;\n};\n\n/**\n * Adds Interest Invoker Commands API support for interactive custom elements.\n * https://developer.mozilla.org/en-US/docs/Web/API/Popover_API/Using_interest_invokers\n */\nexport function typeInterest<T extends Interest>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) =>\n target.addInitializer!((instance: T) => new TypeInterestController(instance));\n}\n\nexport type Interest = ReactiveElement &\n HTMLElement & {\n interestfor: string | null;\n interestForElement: HTMLElement | null;\n readOnly: boolean;\n disabled: boolean;\n };\n\nexport class TypeInterestController<T extends Interest> implements ReactiveController {\n #interestSetupComplete = false;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n async hostConnected() {\n await this.#setupInterestEvents();\n }\n\n async hostUpdated() {\n await this.#setupInterestEvents();\n }\n\n hostDisconnected() {\n this.#teardownInterestEvents();\n }\n\n async #setupInterestEvents() {\n await this.host.updateComplete;\n if (!this.#interestSetupComplete) {\n this.#interestSetupComplete = true;\n this.host.addEventListener('mouseenter', this.#triggerInterest);\n this.host.addEventListener('mouseleave', this.#triggerLoseInterest);\n this.host.addEventListener('focus', this.#triggerInterest);\n this.host.addEventListener('blur', this.#triggerLoseInterest);\n }\n }\n\n #teardownInterestEvents() {\n this.#interestSetupComplete = false;\n this.host.removeEventListener('mouseenter', this.#triggerInterest);\n this.host.removeEventListener('mouseleave', this.#triggerLoseInterest);\n this.host.removeEventListener('focus', this.#triggerInterest);\n this.host.removeEventListener('blur', this.#triggerLoseInterest);\n }\n\n #triggerInterest = () => {\n this.#updateInterestForElement();\n if (this.host.interestForElement) {\n const event = new Event('interest', { cancelable: true }) as InterestEvent;\n event.source = this.host;\n this.host.interestForElement.dispatchEvent(event);\n }\n };\n\n #triggerLoseInterest = () => {\n this.#updateInterestForElement();\n if (this.host.interestForElement) {\n const event = new Event('loseinterest', { cancelable: true }) as InterestEvent;\n event.source = this.host;\n this.host.interestForElement.dispatchEvent(event);\n }\n };\n\n // we can only do this on interaction as its too costly to do this on every getter or update of the interestfor attribute, this diverges from the native behavior of the interestfor attribute\n #updateInterestForElement() {\n const interestForIdRef = this.host.getAttribute('interestfor');\n if (interestForIdRef && !this.host.interestForElement) {\n this.host.interestForElement = getFlattenedDOMTree(this.host.getRootNode() as HTMLElement).find(\n el => el.id === interestForIdRef\n )!;\n }\n\n // legacy behavior that allows popovertarget to trigger interestfor behavior for hint type popovers\n const popovertargetIdRef = this.host.getAttribute('popovertarget');\n if (popovertargetIdRef && !interestForIdRef) {\n const target = getFlattenedDOMTree(this.host.getRootNode() as HTMLElement).find(\n el => el.id === popovertargetIdRef\n );\n if (target && target.popover === 'hint') {\n this.host.interestForElement = target;\n }\n }\n }\n}\n"],"mappings":";;AAeA,SAAgB,IAAmD;CACjE,QAAQ,MACN,EAAO,gBAAiB,MAAgB,IAAI,EAAuB,CAAQ,CAAC;AAChF;AAUA,IAAa,IAAb,MAAsF;CACpF,KAAyB;CAEzB,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,MAAM,gBAAgB;EACpB,MAAM,KAAKA,GAAqB;CAClC;CAEA,MAAM,cAAc;EAClB,MAAM,KAAKA,GAAqB;CAClC;CAEA,mBAAmB;EACjB,KAAKC,GAAwB;CAC/B;CAEA,MAAMD,KAAuB;EAE3B,AADA,MAAM,KAAK,KAAK,gBACX,KAAKE,OACR,KAAKA,KAAyB,IAC9B,KAAK,KAAK,iBAAiB,cAAc,KAAKC,EAAgB,GAC9D,KAAK,KAAK,iBAAiB,cAAc,KAAKC,EAAoB,GAClE,KAAK,KAAK,iBAAiB,SAAS,KAAKD,EAAgB,GACzD,KAAK,KAAK,iBAAiB,QAAQ,KAAKC,EAAoB;CAEhE;CAEA,KAA0B;EAKxB,AAJA,KAAKF,KAAyB,IAC9B,KAAK,KAAK,oBAAoB,cAAc,KAAKC,EAAgB,GACjE,KAAK,KAAK,oBAAoB,cAAc,KAAKC,EAAoB,GACrE,KAAK,KAAK,oBAAoB,SAAS,KAAKD,EAAgB,GAC5D,KAAK,KAAK,oBAAoB,QAAQ,KAAKC,EAAoB;CACjE;CAEA,WAAyB;EAEvB,IADA,KAAKC,GAA0B,GAC3B,KAAK,KAAK,oBAAoB;GAChC,IAAM,IAAQ,IAAI,MAAM,YAAY,EAAE,YAAY,GAAK,CAAC;GAExD,AADA,EAAM,SAAS,KAAK,MACpB,KAAK,KAAK,mBAAmB,cAAc,CAAK;EAClD;CACF;CAEA,WAA6B;EAE3B,IADA,KAAKA,GAA0B,GAC3B,KAAK,KAAK,oBAAoB;GAChC,IAAM,IAAQ,IAAI,MAAM,gBAAgB,EAAE,YAAY,GAAK,CAAC;GAE5D,AADA,EAAM,SAAS,KAAK,MACpB,KAAK,KAAK,mBAAmB,cAAc,CAAK;EAClD;CACF;CAGA,KAA4B;EAC1B,IAAM,IAAmB,KAAK,KAAK,aAAa,aAAa;EAC7D,AAAI,KAAoB,CAAC,KAAK,KAAK,uBACjC,KAAK,KAAK,qBAAqB,EAAoB,KAAK,KAAK,YAAY,CAAgB,EAAE,MACzF,MAAM,EAAG,OAAO,CAClB;EAIF,IAAM,IAAqB,KAAK,KAAK,aAAa,eAAe;EACjE,IAAI,KAAsB,CAAC,GAAkB;GAC3C,IAAM,IAAS,EAAoB,KAAK,KAAK,YAAY,CAAgB,EAAE,MACzE,MAAM,EAAG,OAAO,CAClB;GACA,AAAI,KAAU,EAAO,YAAY,WAC/B,KAAK,KAAK,qBAAqB;EAEnC;CACF;AACF"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ReactiveElement, ReactiveController } from 'lit';
|
|
2
|
-
export interface NativePopoverTrigger extends ReactiveElement {
|
|
3
|
-
disabled: boolean;
|
|
4
|
-
popoverTargetAction: 'show' | 'hide' | 'toggle';
|
|
5
|
-
popoverTargetElement: HTMLElement | null;
|
|
6
|
-
popovertarget: string;
|
|
7
|
-
anchor?: HTMLElement;
|
|
8
|
-
}
|
|
9
|
-
export declare function typeNativePopoverTrigger<T extends NativePopoverTrigger>(): ClassDecorator;
|
|
10
|
-
export declare class TypeNativePopoverTriggerController<T extends NativePopoverTrigger> implements ReactiveController {
|
|
11
|
-
#private;
|
|
12
|
-
private host;
|
|
13
|
-
constructor(host: T);
|
|
14
|
-
hostConnected(): void;
|
|
15
|
-
hostDisconnected(): void;
|
|
16
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { getFlattenedDOMTree as e } from "../utils/dom.js";
|
|
2
|
-
import { getHostAnchor as t } from "./type-native-popover.utils.js";
|
|
3
|
-
//#region src/internal/controllers/type-native-popover-trigger.controller.ts
|
|
4
|
-
function n() {
|
|
5
|
-
return (e) => e.addInitializer((e) => new r(e));
|
|
6
|
-
}
|
|
7
|
-
var r = class {
|
|
8
|
-
constructor(e) {
|
|
9
|
-
this.host = e, this.host.addController(this);
|
|
10
|
-
}
|
|
11
|
-
hostConnected() {
|
|
12
|
-
this.host.addEventListener("click", this.#e);
|
|
13
|
-
}
|
|
14
|
-
hostDisconnected() {
|
|
15
|
-
this.host.removeEventListener("click", this.#e);
|
|
16
|
-
}
|
|
17
|
-
#e = () => {
|
|
18
|
-
let n = this.host, r = this.host.popoverTargetElement;
|
|
19
|
-
!r && this.host.popovertarget && (r = e(this.host.getRootNode()).find((e) => e.id === this.host.popovertarget), this.host.popoverTargetElement = r ?? null), r?.anchor && (n = t(r)), r && !this.host.disabled && (this.host.popoverTargetAction === "hide" ? r.hidePopover() : this.host.popoverTargetAction === "show" ? r.showPopover({ source: n }) : r.togglePopover({ source: n }));
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
//#endregion
|
|
23
|
-
export { r as TypeNativePopoverTriggerController, n as typeNativePopoverTrigger };
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=type-native-popover-trigger.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-native-popover-trigger.controller.js","names":["#click"],"sources":["../../../src/internal/controllers/type-native-popover-trigger.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveElement, ReactiveController } from 'lit';\nimport type { LegacyDecoratorTarget } from '../types/index.js';\nimport { getFlattenedDOMTree } from '../utils/dom.js';\nimport { getHostAnchor } from './type-native-popover.utils.js';\n\nexport interface NativePopoverTrigger extends ReactiveElement {\n disabled: boolean;\n popoverTargetAction: 'show' | 'hide' | 'toggle';\n popoverTargetElement: HTMLElement | null;\n popovertarget: string;\n anchor?: HTMLElement;\n}\n\nexport function typeNativePopoverTrigger<T extends NativePopoverTrigger>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) =>\n target.addInitializer!((instance: T) => new TypeNativePopoverTriggerController(instance));\n}\n\nexport class TypeNativePopoverTriggerController<T extends NativePopoverTrigger> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n this.host.addEventListener('click', this.#click);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('click', this.#click);\n }\n\n #click = () => {\n let source = this.host as HTMLElement;\n let popoverTargetElement = this.host.popoverTargetElement;\n\n // we can only do this on interaction as its too costly to do this on every getter or update of the popovertarget attribute, this diverges from the native behavior of the popovertarget attribute\n if (!popoverTargetElement && this.host.popovertarget) {\n popoverTargetElement = getFlattenedDOMTree(this.host.getRootNode()).find(e => e.id === this.host.popovertarget)!;\n this.host.popoverTargetElement = popoverTargetElement ?? null;\n }\n\n // if popover has explicit anchor, use it as the source\n if ((popoverTargetElement as NativePopoverTrigger)?.anchor) {\n source = getHostAnchor(popoverTargetElement as NativePopoverTrigger);\n }\n\n if (popoverTargetElement && !this.host.disabled) {\n if (this.host.popoverTargetAction === 'hide') {\n popoverTargetElement.hidePopover();\n } else if (this.host.popoverTargetAction === 'show') {\n popoverTargetElement.showPopover({ source });\n } else {\n popoverTargetElement.togglePopover({ source });\n }\n }\n };\n}\n"],"mappings":";;;AAgBA,SAAgB,IAA2E;CACzF,QAAQ,MACN,EAAO,gBAAiB,MAAgB,IAAI,EAAmC,CAAQ,CAAC;AAC5F;AAEA,IAAa,IAAb,MAA8G;CAC5G,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,KAAK,KAAK,iBAAiB,SAAS,KAAKA,EAAM;CACjD;CAEA,mBAAmB;EACjB,KAAK,KAAK,oBAAoB,SAAS,KAAKA,EAAM;CACpD;CAEA,WAAe;EACb,IAAI,IAAS,KAAK,MACd,IAAuB,KAAK,KAAK;EAarC,AAVI,CAAC,KAAwB,KAAK,KAAK,kBACrC,IAAuB,EAAoB,KAAK,KAAK,YAAY,CAAC,EAAE,MAAK,MAAK,EAAE,OAAO,KAAK,KAAK,aAAa,GAC9G,KAAK,KAAK,uBAAuB,KAAwB,OAItD,GAA+C,WAClD,IAAS,EAAc,CAA4C,IAGjE,KAAwB,CAAC,KAAK,KAAK,aACjC,KAAK,KAAK,wBAAwB,SACpC,EAAqB,YAAY,IACxB,KAAK,KAAK,wBAAwB,SAC3C,EAAqB,YAAY,EAAE,UAAO,CAAC,IAE3C,EAAqB,cAAc,EAAE,UAAO,CAAC;CAGnD;AACF"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
-
/**
|
|
3
|
-
* Adds Form submit support for interactive custom elements.
|
|
4
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit_event
|
|
5
|
-
*/
|
|
6
|
-
export declare function typeSubmit<T extends Submit>(): ClassDecorator;
|
|
7
|
-
export type Submit = ReactiveElement & HTMLElement & {
|
|
8
|
-
name: string;
|
|
9
|
-
value: string;
|
|
10
|
-
disabled: boolean;
|
|
11
|
-
type: 'button' | 'submit' | 'reset';
|
|
12
|
-
readOnly: boolean;
|
|
13
|
-
form?: HTMLFormElement | null;
|
|
14
|
-
_internals: ElementInternals;
|
|
15
|
-
};
|
|
16
|
-
export declare class TypeSubmitController<T extends Submit> implements ReactiveController {
|
|
17
|
-
#private;
|
|
18
|
-
private host;
|
|
19
|
-
constructor(host: T);
|
|
20
|
-
hostUpdated(): Promise<void>;
|
|
21
|
-
hostDisconnected(): void;
|
|
22
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { stopEvent as e } from "../utils/events.js";
|
|
2
|
-
import { onKeys as t } from "../utils/keynav.js";
|
|
3
|
-
//#region src/internal/controllers/type-submit.controller.ts
|
|
4
|
-
function n() {
|
|
5
|
-
return (e) => e.addInitializer((e) => new r(e));
|
|
6
|
-
}
|
|
7
|
-
var r = class {
|
|
8
|
-
constructor(e) {
|
|
9
|
-
this.host = e, this.host.addController(this);
|
|
10
|
-
}
|
|
11
|
-
async hostUpdated() {
|
|
12
|
-
await this.host.updateComplete, this.#e(), this.#t();
|
|
13
|
-
}
|
|
14
|
-
hostDisconnected() {
|
|
15
|
-
this.#n();
|
|
16
|
-
}
|
|
17
|
-
#e() {
|
|
18
|
-
!this.host.type && !this.host.hasAttribute("type") && this.host.closest("form") && (this.host.type = "submit");
|
|
19
|
-
}
|
|
20
|
-
#t() {
|
|
21
|
-
this.#n(), !this.host.readOnly && !this.host.disabled && (this.host.addEventListener("click", this.#i), this.host.addEventListener("keyup", this.#r));
|
|
22
|
-
}
|
|
23
|
-
#n() {
|
|
24
|
-
this.host.removeEventListener("click", this.#i), this.host.removeEventListener("keyup", this.#r);
|
|
25
|
-
}
|
|
26
|
-
#r = (e) => {
|
|
27
|
-
t(["Enter", "Space"], e, () => this.host.click());
|
|
28
|
-
};
|
|
29
|
-
#i = (t) => {
|
|
30
|
-
if (this.host.disabled) {
|
|
31
|
-
e(t);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
this.host.type === "submit" && this.host.form ? this.#a() : this.host.type === "reset" && this.host.form?.reset();
|
|
35
|
-
};
|
|
36
|
-
#a() {
|
|
37
|
-
this.#s(), this.host.form.addEventListener("submit", () => {
|
|
38
|
-
setTimeout(() => this.#o.remove(), 0);
|
|
39
|
-
}, { once: !0 }), this.host.form.appendChild(this.#o), this.host.form.requestSubmit(this.#o);
|
|
40
|
-
}
|
|
41
|
-
#o;
|
|
42
|
-
#s() {
|
|
43
|
-
this.#o || (this.#o = globalThis.document.createElement("button"), this.#o.type = "submit", this.#o.name = this.host.name ?? "", this.#o.value = this.host.value ?? "", this.#o.style.display = "none");
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
//#endregion
|
|
47
|
-
export { r as TypeSubmitController, n as typeSubmit };
|
|
48
|
-
|
|
49
|
-
//# sourceMappingURL=type-submit.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-submit.controller.js","names":["#setButtonType","#setupNativeButtonBehavior","#removeNativeButtonBehavior","#triggerNativeButtonBehavior","#emulateKeyBoardEventBehavior","#requestSubmit","#createSubmitter","#submitter"],"sources":["../../../src/internal/controllers/type-submit.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport type { LegacyDecoratorTarget } from '../types/index.js';\nimport { stopEvent } from '../utils/events.js';\nimport { onKeys } from '../utils/keynav.js';\n\n/**\n * Adds Form submit support for interactive custom elements.\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit_event\n */\nexport function typeSubmit<T extends Submit>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) => target.addInitializer!((instance: T) => new TypeSubmitController(instance));\n}\n\nexport type Submit = ReactiveElement &\n HTMLElement & {\n name: string;\n value: string;\n disabled: boolean;\n type: 'button' | 'submit' | 'reset';\n readOnly: boolean;\n form?: HTMLFormElement | null;\n _internals: ElementInternals;\n };\n\nexport class TypeSubmitController<T extends Submit> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n async hostUpdated() {\n await this.host.updateComplete;\n this.#setButtonType();\n this.#setupNativeButtonBehavior();\n }\n\n hostDisconnected() {\n this.#removeNativeButtonBehavior();\n }\n\n #setButtonType() {\n if (!this.host.type && !this.host.hasAttribute('type') && this.host.closest('form')) {\n this.host.type = 'submit';\n }\n }\n\n #setupNativeButtonBehavior() {\n this.#removeNativeButtonBehavior();\n if (!this.host.readOnly && !this.host.disabled) {\n this.host.addEventListener('click', this.#triggerNativeButtonBehavior);\n this.host.addEventListener('keyup', this.#emulateKeyBoardEventBehavior);\n }\n }\n\n #removeNativeButtonBehavior() {\n this.host.removeEventListener('click', this.#triggerNativeButtonBehavior);\n this.host.removeEventListener('keyup', this.#emulateKeyBoardEventBehavior);\n }\n\n // when submitting forms with Enter key, default submit button receives click event from the form\n #emulateKeyBoardEventBehavior = (event: KeyboardEvent) => {\n onKeys(['Enter', 'Space'], event, () => this.host.click());\n };\n\n #triggerNativeButtonBehavior = (event: Event) => {\n if (this.host.disabled) {\n stopEvent(event);\n return;\n }\n\n if (this.host.type === 'submit' && this.host.form) {\n this.#requestSubmit();\n } else if (this.host.type === 'reset') {\n this.host.form?.reset();\n }\n };\n\n #requestSubmit() {\n this.#createSubmitter();\n this.host.form!.addEventListener(\n 'submit',\n () => {\n setTimeout(() => this.#submitter.remove(), 0);\n },\n { once: true }\n );\n this.host.form!.appendChild(this.#submitter);\n this.host.form!.requestSubmit(this.#submitter);\n }\n\n #submitter: HTMLButtonElement;\n // https://github.com/WICG/webcomponents/issues/814\n #createSubmitter() {\n if (!this.#submitter) {\n this.#submitter = globalThis.document.createElement('button');\n this.#submitter.type = 'submit';\n this.#submitter.name = this.host.name ?? '';\n this.#submitter.value = this.host.value ?? '';\n this.#submitter.style.display = 'none';\n }\n }\n}\n"],"mappings":";;;AAYA,SAAgB,IAA+C;CAC7D,QAAQ,MAAkC,EAAO,gBAAiB,MAAgB,IAAI,EAAqB,CAAQ,CAAC;AACtH;AAaA,IAAa,IAAb,MAAkF;CAChF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,MAAM,cAAc;EAGlB,AAFA,MAAM,KAAK,KAAK,gBAChB,KAAKA,GAAe,GACpB,KAAKC,GAA2B;CAClC;CAEA,mBAAmB;EACjB,KAAKC,GAA4B;CACnC;CAEA,KAAiB;EACf,AAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAAa,MAAM,KAAK,KAAK,KAAK,QAAQ,MAAM,MAChF,KAAK,KAAK,OAAO;CAErB;CAEA,KAA6B;EAE3B,AADA,KAAKA,GAA4B,GAC7B,CAAC,KAAK,KAAK,YAAY,CAAC,KAAK,KAAK,aACpC,KAAK,KAAK,iBAAiB,SAAS,KAAKC,EAA4B,GACrE,KAAK,KAAK,iBAAiB,SAAS,KAAKC,EAA6B;CAE1E;CAEA,KAA8B;EAE5B,AADA,KAAK,KAAK,oBAAoB,SAAS,KAAKD,EAA4B,GACxE,KAAK,KAAK,oBAAoB,SAAS,KAAKC,EAA6B;CAC3E;CAGA,MAAiC,MAAyB;EACxD,EAAO,CAAC,SAAS,OAAO,GAAG,SAAa,KAAK,KAAK,MAAM,CAAC;CAC3D;CAEA,MAAgC,MAAiB;EAC/C,IAAI,KAAK,KAAK,UAAU;GACtB,EAAU,CAAK;GACf;EACF;EAEA,AAAI,KAAK,KAAK,SAAS,YAAY,KAAK,KAAK,OAC3C,KAAKC,GAAe,IACX,KAAK,KAAK,SAAS,WAC5B,KAAK,KAAK,MAAM,MAAM;CAE1B;CAEA,KAAiB;EAUf,AATA,KAAKC,GAAiB,GACtB,KAAK,KAAK,KAAM,iBACd,gBACM;GACJ,iBAAiB,KAAKC,GAAW,OAAO,GAAG,CAAC;EAC9C,GACA,EAAE,MAAM,GAAK,CACf,GACA,KAAK,KAAK,KAAM,YAAY,KAAKA,EAAU,GAC3C,KAAK,KAAK,KAAM,cAAc,KAAKA,EAAU;CAC/C;CAEA;CAEA,KAAmB;EACjB,AAAK,KAAKA,OACR,KAAKA,KAAa,WAAW,SAAS,cAAc,QAAQ,GAC5D,KAAKA,GAAW,OAAO,UACvB,KAAKA,GAAW,OAAO,KAAK,KAAK,QAAQ,IACzC,KAAKA,GAAW,QAAQ,KAAK,KAAK,SAAS,IAC3C,KAAKA,GAAW,MAAM,UAAU;CAEpC;AACF"}
|