@ngneers/controls 0.0.1-pre4 → 0.0.1-pre6
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/fesm2022/ngneers-controls-accordion.mjs +32 -32
- package/fesm2022/ngneers-controls-accordion.mjs.map +1 -1
- package/fesm2022/ngneers-controls-api-ng.mjs +19 -19
- package/fesm2022/ngneers-controls-api-ng.mjs.map +1 -1
- package/fesm2022/ngneers-controls-api-resize.mjs +706 -0
- package/fesm2022/ngneers-controls-api-resize.mjs.map +1 -0
- package/fesm2022/ngneers-controls-avatar.mjs +13 -13
- package/fesm2022/ngneers-controls-avatar.mjs.map +1 -1
- package/fesm2022/ngneers-controls-base.mjs +89 -64
- package/fesm2022/ngneers-controls-base.mjs.map +1 -1
- package/fesm2022/ngneers-controls-breadcrumb.mjs +18 -18
- package/fesm2022/ngneers-controls-breadcrumb.mjs.map +1 -1
- package/fesm2022/ngneers-controls-button-group.mjs +8 -8
- package/fesm2022/ngneers-controls-button-group.mjs.map +1 -1
- package/fesm2022/ngneers-controls-button.mjs +16 -10
- package/fesm2022/ngneers-controls-button.mjs.map +1 -1
- package/fesm2022/{ngneers-controls-calendar-time-C7UnIFzU.mjs → ngneers-controls-calendar-time-Bzlv9Vkn.mjs} +9 -9
- package/fesm2022/{ngneers-controls-calendar-time-C7UnIFzU.mjs.map → ngneers-controls-calendar-time-Bzlv9Vkn.mjs.map} +1 -1
- package/fesm2022/ngneers-controls-calendar.mjs +54 -54
- package/fesm2022/ngneers-controls-calendar.mjs.map +1 -1
- package/fesm2022/ngneers-controls-checkbox.mjs +9 -9
- package/fesm2022/ngneers-controls-checkbox.mjs.map +1 -1
- package/fesm2022/ngneers-controls-chip.mjs +6 -6
- package/fesm2022/ngneers-controls-chip.mjs.map +1 -1
- package/fesm2022/ngneers-controls-defer.mjs +10 -10
- package/fesm2022/ngneers-controls-defer.mjs.map +1 -1
- package/fesm2022/ngneers-controls-dialog.mjs +37 -39
- package/fesm2022/ngneers-controls-dialog.mjs.map +1 -1
- package/fesm2022/ngneers-controls-directives.mjs +45 -39
- package/fesm2022/ngneers-controls-directives.mjs.map +1 -1
- package/fesm2022/ngneers-controls-drawer.mjs +28 -28
- package/fesm2022/ngneers-controls-drawer.mjs.map +1 -1
- package/fesm2022/ngneers-controls-edit-inplace.mjs +15 -15
- package/fesm2022/ngneers-controls-edit-inplace.mjs.map +1 -1
- package/fesm2022/ngneers-controls-filter.mjs +192 -44
- package/fesm2022/ngneers-controls-filter.mjs.map +1 -1
- package/fesm2022/{ngneers-controls-i18n-de-CdTPeBiR.mjs → ngneers-controls-i18n-de-CF0xTWEX.mjs} +9 -5
- package/fesm2022/ngneers-controls-i18n-de-CF0xTWEX.mjs.map +1 -0
- package/fesm2022/{ngneers-controls-i18n-en-Cfp2pOLY.mjs → ngneers-controls-i18n-en-8B7xAjH2.mjs} +9 -5
- package/fesm2022/ngneers-controls-i18n-en-8B7xAjH2.mjs.map +1 -0
- package/fesm2022/ngneers-controls-i18n.mjs +5 -5
- package/fesm2022/ngneers-controls-i18n.mjs.map +1 -1
- package/fesm2022/ngneers-controls-icon.mjs +10 -10
- package/fesm2022/ngneers-controls-icon.mjs.map +1 -1
- package/fesm2022/ngneers-controls-inplace.mjs +18 -18
- package/fesm2022/ngneers-controls-inplace.mjs.map +1 -1
- package/fesm2022/ngneers-controls-input-field.mjs +15 -15
- package/fesm2022/ngneers-controls-input-field.mjs.map +1 -1
- package/fesm2022/ngneers-controls-input-mask.mjs +8 -8
- package/fesm2022/ngneers-controls-input-mask.mjs.map +1 -1
- package/fesm2022/ngneers-controls-input.mjs +7 -6
- package/fesm2022/ngneers-controls-input.mjs.map +1 -1
- package/fesm2022/ngneers-controls-item-view.mjs +33 -33
- package/fesm2022/ngneers-controls-item-view.mjs.map +1 -1
- package/fesm2022/ngneers-controls-list-box.mjs +31 -31
- package/fesm2022/ngneers-controls-list-box.mjs.map +1 -1
- package/fesm2022/ngneers-controls-menu.mjs +32 -32
- package/fesm2022/ngneers-controls-menu.mjs.map +1 -1
- package/fesm2022/ngneers-controls-message.mjs +4 -4
- package/fesm2022/ngneers-controls-message.mjs.map +1 -1
- package/fesm2022/ngneers-controls-paginator.mjs +12 -12
- package/fesm2022/ngneers-controls-paginator.mjs.map +1 -1
- package/fesm2022/ngneers-controls-popover.mjs +13 -13
- package/fesm2022/ngneers-controls-popover.mjs.map +1 -1
- package/fesm2022/ngneers-controls-progress.mjs +16 -16
- package/fesm2022/ngneers-controls-progress.mjs.map +1 -1
- package/fesm2022/ngneers-controls-scroller.mjs +74 -39
- package/fesm2022/ngneers-controls-scroller.mjs.map +1 -1
- package/fesm2022/ngneers-controls-select-button.mjs +6 -6
- package/fesm2022/ngneers-controls-select-button.mjs.map +1 -1
- package/fesm2022/ngneers-controls-select.mjs +46 -46
- package/fesm2022/ngneers-controls-select.mjs.map +1 -1
- package/fesm2022/ngneers-controls-slider.mjs +12 -12
- package/fesm2022/ngneers-controls-slider.mjs.map +1 -1
- package/fesm2022/ngneers-controls-spinner.mjs +7 -7
- package/fesm2022/ngneers-controls-spinner.mjs.map +1 -1
- package/fesm2022/ngneers-controls-splitter.mjs +141 -328
- package/fesm2022/ngneers-controls-splitter.mjs.map +1 -1
- package/fesm2022/ngneers-controls-switch.mjs +3 -3
- package/fesm2022/ngneers-controls-table.mjs +1520 -80
- package/fesm2022/ngneers-controls-table.mjs.map +1 -1
- package/fesm2022/ngneers-controls-tabs.mjs +40 -39
- package/fesm2022/ngneers-controls-tabs.mjs.map +1 -1
- package/fesm2022/ngneers-controls-tag.mjs +4 -4
- package/fesm2022/ngneers-controls-tag.mjs.map +1 -1
- package/fesm2022/ngneers-controls-toast.mjs +18 -18
- package/fesm2022/ngneers-controls-toast.mjs.map +1 -1
- package/fesm2022/ngneers-controls-toggle-button.mjs +9 -9
- package/fesm2022/ngneers-controls-toggle-button.mjs.map +1 -1
- package/fesm2022/ngneers-controls-tooltip.mjs +37 -45
- package/fesm2022/ngneers-controls-tooltip.mjs.map +1 -1
- package/fesm2022/ngneers-controls-utils-ng.mjs +9 -9
- package/fesm2022/ngneers-controls-utils-ng.mjs.map +1 -1
- package/package.json +14 -10
- package/types/ngneers-controls-api-ng.d.ts +2 -2
- package/types/ngneers-controls-api-resize.d.ts +318 -0
- package/types/ngneers-controls-base.d.ts +8 -0
- package/types/ngneers-controls-breadcrumb.d.ts +1 -1
- package/types/ngneers-controls-button.d.ts +13 -8
- package/types/ngneers-controls-calendar.d.ts +5 -1
- package/types/ngneers-controls-checkbox.d.ts +1 -1
- package/types/ngneers-controls-directives.d.ts +7 -1
- package/types/ngneers-controls-drawer.d.ts +4 -0
- package/types/ngneers-controls-edit-inplace.d.ts +4 -0
- package/types/ngneers-controls-filter.d.ts +53 -4
- package/types/ngneers-controls-i18n.d.ts +4 -0
- package/types/ngneers-controls-icon.d.ts +1 -1
- package/types/ngneers-controls-input-field.d.ts +4 -0
- package/types/ngneers-controls-input.d.ts +1 -1
- package/types/ngneers-controls-list-box.d.ts +5 -1
- package/types/ngneers-controls-menu.d.ts +1 -1
- package/types/ngneers-controls-paginator.d.ts +4 -0
- package/types/ngneers-controls-popover.d.ts +1 -1
- package/types/ngneers-controls-scroller.d.ts +12 -2
- package/types/ngneers-controls-select.d.ts +6 -2
- package/types/ngneers-controls-spinner.d.ts +1 -1
- package/types/ngneers-controls-splitter.d.ts +29 -59
- package/types/ngneers-controls-table.d.ts +392 -24
- package/types/ngneers-controls-toast.d.ts +1 -1
- package/types/ngneers-controls-tooltip.d.ts +1 -7
- package/fesm2022/ngneers-controls-i18n-de-CdTPeBiR.mjs.map +0 -1
- package/fesm2022/ngneers-controls-i18n-en-Cfp2pOLY.mjs.map +0 -1
|
@@ -8,37 +8,37 @@ import { templateTypesFn } from '@ngneers/controls/api/ng';
|
|
|
8
8
|
|
|
9
9
|
class InplaceTemplates extends NgnBase {
|
|
10
10
|
// Display template
|
|
11
|
-
_userDisplayTemplate = contentChild('display', ...(ngDevMode ? [{ debugName: "_userDisplayTemplate" }] : []));
|
|
11
|
+
_userDisplayTemplate = contentChild('display', ...(ngDevMode ? [{ debugName: "_userDisplayTemplate" }] : /* istanbul ignore next */ []));
|
|
12
12
|
/**
|
|
13
13
|
* Set a custom template for the display.
|
|
14
14
|
* Can also be set using an `<ng-template>` element with `#display` template reference variable.
|
|
15
15
|
*/
|
|
16
|
-
templateDisplay = input(null, ...(ngDevMode ? [{ debugName: "templateDisplay" }] : []));
|
|
17
|
-
displayTemplate = computed(() => this._userDisplayTemplate() ?? this.templateDisplay(), ...(ngDevMode ? [{ debugName: "displayTemplate" }] : []));
|
|
16
|
+
templateDisplay = input(null, ...(ngDevMode ? [{ debugName: "templateDisplay" }] : /* istanbul ignore next */ []));
|
|
17
|
+
displayTemplate = computed(() => this._userDisplayTemplate() ?? this.templateDisplay(), ...(ngDevMode ? [{ debugName: "displayTemplate" }] : /* istanbul ignore next */ []));
|
|
18
18
|
/**
|
|
19
19
|
* Context for the display template.
|
|
20
20
|
*/
|
|
21
|
-
templateDisplayContext = input(...(ngDevMode ? [undefined, { debugName: "templateDisplayContext" }] : []));
|
|
21
|
+
templateDisplayContext = input(...(ngDevMode ? [undefined, { debugName: "templateDisplayContext" }] : /* istanbul ignore next */ []));
|
|
22
22
|
// Content template
|
|
23
|
-
_userContentTemplate = contentChild('content', ...(ngDevMode ? [{ debugName: "_userContentTemplate" }] : []));
|
|
23
|
+
_userContentTemplate = contentChild('content', ...(ngDevMode ? [{ debugName: "_userContentTemplate" }] : /* istanbul ignore next */ []));
|
|
24
24
|
/**
|
|
25
25
|
* Set a custom template for the content.
|
|
26
26
|
* Can also be set using an `<ng-template>` element with `#content` template reference variable.
|
|
27
27
|
*/
|
|
28
|
-
templateContent = input(null, ...(ngDevMode ? [{ debugName: "templateContent" }] : []));
|
|
29
|
-
contentTemplate = computed(() => this._userContentTemplate() ?? this.templateContent(), ...(ngDevMode ? [{ debugName: "contentTemplate" }] : []));
|
|
28
|
+
templateContent = input(null, ...(ngDevMode ? [{ debugName: "templateContent" }] : /* istanbul ignore next */ []));
|
|
29
|
+
contentTemplate = computed(() => this._userContentTemplate() ?? this.templateContent(), ...(ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []));
|
|
30
30
|
/**
|
|
31
31
|
* Context for the content template.
|
|
32
32
|
*/
|
|
33
|
-
templateContentContext = input(...(ngDevMode ? [undefined, { debugName: "templateContentContext" }] : []));
|
|
33
|
+
templateContentContext = input(...(ngDevMode ? [undefined, { debugName: "templateContentContext" }] : /* istanbul ignore next */ []));
|
|
34
34
|
/**
|
|
35
35
|
* Types for the drawer templates.
|
|
36
36
|
*/
|
|
37
37
|
templateTypes = templateTypesFn();
|
|
38
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.
|
|
39
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.
|
|
38
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: InplaceTemplates, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
39
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.2", type: InplaceTemplates, isStandalone: true, inputs: { templateDisplay: { classPropertyName: "templateDisplay", publicName: "templateDisplay", isSignal: true, isRequired: false, transformFunction: null }, templateDisplayContext: { classPropertyName: "templateDisplayContext", publicName: "templateDisplayContext", isSignal: true, isRequired: false, transformFunction: null }, templateContent: { classPropertyName: "templateContent", publicName: "templateContent", isSignal: true, isRequired: false, transformFunction: null }, templateContentContext: { classPropertyName: "templateContentContext", publicName: "templateContentContext", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "_userDisplayTemplate", first: true, predicate: ["display"], descendants: true, isSignal: true }, { propertyName: "_userContentTemplate", first: true, predicate: ["content"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0 });
|
|
40
40
|
}
|
|
41
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.
|
|
41
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: InplaceTemplates, decorators: [{
|
|
42
42
|
type: Directive
|
|
43
43
|
}], propDecorators: { _userDisplayTemplate: [{ type: i0.ContentChild, args: ['display', { isSignal: true }] }], templateDisplay: [{ type: i0.Input, args: [{ isSignal: true, alias: "templateDisplay", required: false }] }], templateDisplayContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "templateDisplayContext", required: false }] }], _userContentTemplate: [{ type: i0.ContentChild, args: ['content', { isSignal: true }] }], templateContent: [{ type: i0.Input, args: [{ isSignal: true, alias: "templateContent", required: false }] }], templateContentContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "templateContentContext", required: false }] }] } });
|
|
44
44
|
|
|
@@ -54,22 +54,22 @@ class NgnInplace extends InplaceTemplates {
|
|
|
54
54
|
/**
|
|
55
55
|
* Controls the visibility of the content.
|
|
56
56
|
*/
|
|
57
|
-
contentVisible = model(false, ...(ngDevMode ? [{ debugName: "contentVisible" }] : []));
|
|
57
|
+
contentVisible = model(false, ...(ngDevMode ? [{ debugName: "contentVisible" }] : /* istanbul ignore next */ []));
|
|
58
58
|
/**
|
|
59
59
|
* Whether the content is loaded lazily.
|
|
60
60
|
* @default true
|
|
61
61
|
*/
|
|
62
|
-
lazy = input(true, { ...(ngDevMode ? { debugName: "lazy" } : {}), transform: booleanAttribute });
|
|
62
|
+
lazy = input(true, { ...(ngDevMode ? { debugName: "lazy" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
63
63
|
/**
|
|
64
64
|
* Whether the content is cached when closed.
|
|
65
65
|
* @default false
|
|
66
66
|
*/
|
|
67
|
-
cache = input(false, { ...(ngDevMode ? { debugName: "cache" } : {}), transform: booleanAttribute });
|
|
67
|
+
cache = input(false, { ...(ngDevMode ? { debugName: "cache" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
68
68
|
/**
|
|
69
69
|
* Explicitly apply disabled state styling
|
|
70
70
|
* @default false
|
|
71
71
|
*/
|
|
72
|
-
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : {}), transform: booleanAttribute });
|
|
72
|
+
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
73
73
|
/**
|
|
74
74
|
* Switches to the content view.
|
|
75
75
|
*/
|
|
@@ -91,10 +91,10 @@ class NgnInplace extends InplaceTemplates {
|
|
|
91
91
|
toggle() {
|
|
92
92
|
this.contentVisible.update(v => !v);
|
|
93
93
|
}
|
|
94
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.
|
|
95
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.
|
|
94
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: NgnInplace, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
95
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.2", type: NgnInplace, isStandalone: true, selector: "ngn-inplace", inputs: { contentVisible: { classPropertyName: "contentVisible", publicName: "contentVisible", isSignal: true, isRequired: false, transformFunction: null }, lazy: { classPropertyName: "lazy", publicName: "lazy", isSignal: true, isRequired: false, transformFunction: null }, cache: { classPropertyName: "cache", publicName: "cache", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { contentVisible: "contentVisibleChange" }, providers: [provideSelf(NgnInplace)], usesInheritance: true, ngImport: i0, template: "@if (contentVisible()) {\r\n <div [ptInt]=\"this\" [ptClass]=\"'content'\">\r\n <ngn-defer\r\n [open]=\"contentVisible()\"\r\n [lazyContent]=\"contentTemplate()\"\r\n [lazyContentContext]=\"templateContentContext() ?? { $implicit: { close: closeContent } }\"\r\n [lazy]=\"lazy()\"\r\n [cache]=\"cache()\"\r\n />\r\n </div>\r\n} @else {\r\n <button [ptInt]=\"this\" [ptClass]=\"'display'\" role=\"button\" (click)=\"switchToContent()\">\r\n <ng-container\r\n [ngTemplateOutlet]=\"displayTemplate()\"\r\n [ngTemplateOutletContext]=\"templateDisplayContext()\"\r\n />\r\n </button>\r\n}\r\n", dependencies: [{ kind: "directive", type: NgnPt, selector: "[ptInt]", inputs: ["ptInt", "ptClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: NgnDefer, selector: "ngn-defer", inputs: ["lazyContent", "lazyContentContext", "open", "lazy", "cache", "hiddenOnClosed"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
96
96
|
}
|
|
97
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.
|
|
97
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: NgnInplace, decorators: [{
|
|
98
98
|
type: Component,
|
|
99
99
|
args: [{ changeDetection: ChangeDetectionStrategy.OnPush, selector: 'ngn-inplace', imports: [NgnPt, NgTemplateOutlet, NgnDefer], providers: [provideSelf(NgnInplace)], template: "@if (contentVisible()) {\r\n <div [ptInt]=\"this\" [ptClass]=\"'content'\">\r\n <ngn-defer\r\n [open]=\"contentVisible()\"\r\n [lazyContent]=\"contentTemplate()\"\r\n [lazyContentContext]=\"templateContentContext() ?? { $implicit: { close: closeContent } }\"\r\n [lazy]=\"lazy()\"\r\n [cache]=\"cache()\"\r\n />\r\n </div>\r\n} @else {\r\n <button [ptInt]=\"this\" [ptClass]=\"'display'\" role=\"button\" (click)=\"switchToContent()\">\r\n <ng-container\r\n [ngTemplateOutlet]=\"displayTemplate()\"\r\n [ngTemplateOutletContext]=\"templateDisplayContext()\"\r\n />\r\n </button>\r\n}\r\n" }]
|
|
100
100
|
}], propDecorators: { contentVisible: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentVisible", required: false }] }, { type: i0.Output, args: ["contentVisibleChange"] }], lazy: [{ type: i0.Input, args: [{ isSignal: true, alias: "lazy", required: false }] }], cache: [{ type: i0.Input, args: [{ isSignal: true, alias: "cache", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngneers-controls-inplace.mjs","sources":["../../src/inplace/inplace-templates.ts","../../src/inplace/inplace.ts","../../src/inplace/inplace.html","../../src/inplace/ngneers-controls-inplace.ts"],"sourcesContent":["import { computed, contentChild, Directive, input, TemplateRef } from '@angular/core';\r\nimport { templateTypesFn } from '@ngneers/controls/api/ng';\r\nimport { NgnBase } from '@ngneers/controls/base';\r\n\r\nimport type { ContentTemplateType } from './types';\r\n\r\n@Directive()\r\nexport abstract class InplaceTemplates extends NgnBase<'inplace'> {\r\n // Display template\r\n private readonly _userDisplayTemplate = contentChild<TemplateRef<unknown>>('display');\r\n /**\r\n * Set a custom template for the display.\r\n * Can also be set using an `<ng-template>` element with `#display` template reference variable.\r\n */\r\n public readonly templateDisplay = input<TemplateRef<unknown> | null>(null);\r\n protected readonly displayTemplate = computed(\r\n () => this._userDisplayTemplate() ?? this.templateDisplay()\r\n );\r\n /**\r\n * Context for the display template.\r\n */\r\n public readonly templateDisplayContext = input<unknown>();\r\n\r\n // Content template\r\n private readonly _userContentTemplate =\r\n contentChild<TemplateRef<typeof this.templateTypes.content>>('content');\r\n /**\r\n * Set a custom template for the content.\r\n * Can also be set using an `<ng-template>` element with `#content` template reference variable.\r\n */\r\n public readonly templateContent = input<TemplateRef<typeof this.templateTypes.content> | null>(\r\n null\r\n );\r\n protected readonly contentTemplate = computed(\r\n () => this._userContentTemplate() ?? this.templateContent()\r\n );\r\n /**\r\n * Context for the content template.\r\n */\r\n public readonly templateContentContext = input<unknown>();\r\n\r\n /**\r\n * Types for the drawer templates.\r\n */\r\n public readonly templateTypes = templateTypesFn<{\r\n /**\r\n * Type of the template variable for the display template.\r\n */\r\n content: ContentTemplateType;\r\n }>();\r\n}\r\n","import { NgTemplateOutlet } from '@angular/common';\r\nimport { booleanAttribute, Component, input, model, ChangeDetectionStrategy } from '@angular/core';\r\nimport { NgnPt, provideSelf } from '@ngneers/controls/base';\r\nimport { NgnDefer } from '@ngneers/controls/defer';\r\nimport { inplaceControlTemplate } from '@ngneers/controls-themes/templates/inplace';\r\n\r\nimport { InplaceTemplates } from './inplace-templates';\r\n\r\n/**\r\n * @category control\r\n */\r\n@Component({\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n selector: 'ngn-inplace',\r\n templateUrl: './inplace.html',\r\n imports: [NgnPt, NgTemplateOutlet, NgnDefer],\r\n providers: [provideSelf(NgnInplace)],\r\n})\r\nexport class NgnInplace extends InplaceTemplates {\r\n protected readonly theme = this.injectThemeTemplate(inplaceControlTemplate, {\r\n root: true,\r\n disabled: () => this.disabled(),\r\n });\r\n\r\n protected readonly closeContent = this.switchToDisplay.bind(this);\r\n\r\n /**\r\n * Controls the visibility of the content.\r\n */\r\n public readonly contentVisible = model<boolean>(false);\r\n /**\r\n * Whether the content is loaded lazily.\r\n * @default true\r\n */\r\n public readonly lazy = input(true, { transform: booleanAttribute });\r\n /**\r\n * Whether the content is cached when closed.\r\n * @default false\r\n */\r\n public readonly cache = input(false, { transform: booleanAttribute });\r\n /**\r\n * Explicitly apply disabled state styling\r\n * @default false\r\n */\r\n public readonly disabled = input(false, { transform: booleanAttribute });\r\n\r\n /**\r\n * Switches to the content view.\r\n */\r\n public switchToContent() {\r\n if (this.disabled()) {\r\n return;\r\n }\r\n this.contentVisible.set(true);\r\n }\r\n\r\n /**\r\n * Switches to the display view.\r\n */\r\n public switchToDisplay() {\r\n this.contentVisible.set(false);\r\n }\r\n\r\n /**\r\n * Toggles between the display and content views.\r\n */\r\n public toggle() {\r\n this.contentVisible.update(v => !v);\r\n }\r\n}\r\n","@if (contentVisible()) {\r\n <div [ptInt]=\"this\" [ptClass]=\"'content'\">\r\n <ngn-defer\r\n [open]=\"contentVisible()\"\r\n [lazyContent]=\"contentTemplate()\"\r\n [lazyContentContext]=\"templateContentContext() ?? { $implicit: { close: closeContent } }\"\r\n [lazy]=\"lazy()\"\r\n [cache]=\"cache()\"\r\n />\r\n </div>\r\n} @else {\r\n <button [ptInt]=\"this\" [ptClass]=\"'display'\" role=\"button\" (click)=\"switchToContent()\">\r\n <ng-container\r\n [ngTemplateOutlet]=\"displayTemplate()\"\r\n [ngTemplateOutletContext]=\"templateDisplayContext()\"\r\n />\r\n </button>\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAOM,MAAgB,gBAAiB,SAAQ,OAAkB,CAAA;;AAE9C,IAAA,oBAAoB,GAAG,YAAY,CAAuB,SAAS,
|
|
1
|
+
{"version":3,"file":"ngneers-controls-inplace.mjs","sources":["../../src/inplace/inplace-templates.ts","../../src/inplace/inplace.ts","../../src/inplace/inplace.html","../../src/inplace/ngneers-controls-inplace.ts"],"sourcesContent":["import { computed, contentChild, Directive, input, TemplateRef } from '@angular/core';\r\nimport { templateTypesFn } from '@ngneers/controls/api/ng';\r\nimport { NgnBase } from '@ngneers/controls/base';\r\n\r\nimport type { ContentTemplateType } from './types';\r\n\r\n@Directive()\r\nexport abstract class InplaceTemplates extends NgnBase<'inplace'> {\r\n // Display template\r\n private readonly _userDisplayTemplate = contentChild<TemplateRef<unknown>>('display');\r\n /**\r\n * Set a custom template for the display.\r\n * Can also be set using an `<ng-template>` element with `#display` template reference variable.\r\n */\r\n public readonly templateDisplay = input<TemplateRef<unknown> | null>(null);\r\n protected readonly displayTemplate = computed(\r\n () => this._userDisplayTemplate() ?? this.templateDisplay()\r\n );\r\n /**\r\n * Context for the display template.\r\n */\r\n public readonly templateDisplayContext = input<unknown>();\r\n\r\n // Content template\r\n private readonly _userContentTemplate =\r\n contentChild<TemplateRef<typeof this.templateTypes.content>>('content');\r\n /**\r\n * Set a custom template for the content.\r\n * Can also be set using an `<ng-template>` element with `#content` template reference variable.\r\n */\r\n public readonly templateContent = input<TemplateRef<typeof this.templateTypes.content> | null>(\r\n null\r\n );\r\n protected readonly contentTemplate = computed(\r\n () => this._userContentTemplate() ?? this.templateContent()\r\n );\r\n /**\r\n * Context for the content template.\r\n */\r\n public readonly templateContentContext = input<unknown>();\r\n\r\n /**\r\n * Types for the drawer templates.\r\n */\r\n public readonly templateTypes = templateTypesFn<{\r\n /**\r\n * Type of the template variable for the display template.\r\n */\r\n content: ContentTemplateType;\r\n }>();\r\n}\r\n","import { NgTemplateOutlet } from '@angular/common';\r\nimport { booleanAttribute, Component, input, model, ChangeDetectionStrategy } from '@angular/core';\r\nimport { NgnPt, provideSelf } from '@ngneers/controls/base';\r\nimport { NgnDefer } from '@ngneers/controls/defer';\r\nimport { inplaceControlTemplate } from '@ngneers/controls-themes/templates/inplace';\r\n\r\nimport { InplaceTemplates } from './inplace-templates';\r\n\r\n/**\r\n * @category control\r\n */\r\n@Component({\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n selector: 'ngn-inplace',\r\n templateUrl: './inplace.html',\r\n imports: [NgnPt, NgTemplateOutlet, NgnDefer],\r\n providers: [provideSelf(NgnInplace)],\r\n})\r\nexport class NgnInplace extends InplaceTemplates {\r\n protected readonly theme = this.injectThemeTemplate(inplaceControlTemplate, {\r\n root: true,\r\n disabled: () => this.disabled(),\r\n });\r\n\r\n protected readonly closeContent = this.switchToDisplay.bind(this);\r\n\r\n /**\r\n * Controls the visibility of the content.\r\n */\r\n public readonly contentVisible = model<boolean>(false);\r\n /**\r\n * Whether the content is loaded lazily.\r\n * @default true\r\n */\r\n public readonly lazy = input(true, { transform: booleanAttribute });\r\n /**\r\n * Whether the content is cached when closed.\r\n * @default false\r\n */\r\n public readonly cache = input(false, { transform: booleanAttribute });\r\n /**\r\n * Explicitly apply disabled state styling\r\n * @default false\r\n */\r\n public readonly disabled = input(false, { transform: booleanAttribute });\r\n\r\n /**\r\n * Switches to the content view.\r\n */\r\n public switchToContent() {\r\n if (this.disabled()) {\r\n return;\r\n }\r\n this.contentVisible.set(true);\r\n }\r\n\r\n /**\r\n * Switches to the display view.\r\n */\r\n public switchToDisplay() {\r\n this.contentVisible.set(false);\r\n }\r\n\r\n /**\r\n * Toggles between the display and content views.\r\n */\r\n public toggle() {\r\n this.contentVisible.update(v => !v);\r\n }\r\n}\r\n","@if (contentVisible()) {\r\n <div [ptInt]=\"this\" [ptClass]=\"'content'\">\r\n <ngn-defer\r\n [open]=\"contentVisible()\"\r\n [lazyContent]=\"contentTemplate()\"\r\n [lazyContentContext]=\"templateContentContext() ?? { $implicit: { close: closeContent } }\"\r\n [lazy]=\"lazy()\"\r\n [cache]=\"cache()\"\r\n />\r\n </div>\r\n} @else {\r\n <button [ptInt]=\"this\" [ptClass]=\"'display'\" role=\"button\" (click)=\"switchToContent()\">\r\n <ng-container\r\n [ngTemplateOutlet]=\"displayTemplate()\"\r\n [ngTemplateOutletContext]=\"templateDisplayContext()\"\r\n />\r\n </button>\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAOM,MAAgB,gBAAiB,SAAQ,OAAkB,CAAA;;AAE9C,IAAA,oBAAoB,GAAG,YAAY,CAAuB,SAAS,2FAAC;AACrF;;;AAGG;AACa,IAAA,eAAe,GAAG,KAAK,CAA8B,IAAI,sFAAC;AACvD,IAAA,eAAe,GAAG,QAAQ,CAC3C,MAAM,IAAI,CAAC,oBAAoB,EAAE,IAAI,IAAI,CAAC,eAAe,EAAE,sFAC5D;AACD;;AAEG;IACa,sBAAsB,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,wBAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAW;;AAGxC,IAAA,oBAAoB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BtC;;AAEG;;;;"}
|
|
@@ -22,53 +22,53 @@ class NgnInputField extends NgnBase {
|
|
|
22
22
|
* Label for the input field
|
|
23
23
|
* @default null
|
|
24
24
|
*/
|
|
25
|
-
label = input(null, ...(ngDevMode ? [{ debugName: "label" }] : []));
|
|
25
|
+
label = input(null, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
26
26
|
/**
|
|
27
27
|
* Sets the `aria-labelledby` attribute on the input element
|
|
28
28
|
* @default null
|
|
29
29
|
*/
|
|
30
|
-
labelledBy = input(null, ...(ngDevMode ? [{ debugName: "labelledBy" }] : []));
|
|
30
|
+
labelledBy = input(null, ...(ngDevMode ? [{ debugName: "labelledBy" }] : /* istanbul ignore next */ []));
|
|
31
31
|
/**
|
|
32
32
|
* The kind of label presentation
|
|
33
33
|
* @todo add link to custom kind documentation subsection label
|
|
34
34
|
* @default undefined
|
|
35
35
|
*/
|
|
36
|
-
labelKind = input(undefined, ...(ngDevMode ? [{ debugName: "labelKind" }] : []));
|
|
36
|
+
labelKind = input(undefined, ...(ngDevMode ? [{ debugName: "labelKind" }] : /* istanbul ignore next */ []));
|
|
37
37
|
/**
|
|
38
38
|
* ID for the input element
|
|
39
39
|
*/
|
|
40
|
-
inputId = input(generateElementId(), ...(ngDevMode ? [{ debugName: "inputId" }] : []));
|
|
40
|
+
inputId = input(generateElementId(), ...(ngDevMode ? [{ debugName: "inputId" }] : /* istanbul ignore next */ []));
|
|
41
41
|
/**
|
|
42
42
|
* Show clear button
|
|
43
43
|
* @default false
|
|
44
44
|
*/
|
|
45
|
-
showClearButton = input(false, { ...(ngDevMode ? { debugName: "showClearButton" } : {}), transform: booleanAttribute });
|
|
45
|
+
showClearButton = input(false, { ...(ngDevMode ? { debugName: "showClearButton" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
46
46
|
/**
|
|
47
47
|
* Custom icon for the clear button. Use with `showClearButton`.
|
|
48
48
|
*/
|
|
49
|
-
iconClearButton = input(...(ngDevMode ? [undefined, { debugName: "iconClearButton" }] : []));
|
|
49
|
+
iconClearButton = input(...(ngDevMode ? [undefined, { debugName: "iconClearButton" }] : /* istanbul ignore next */ []));
|
|
50
50
|
/**
|
|
51
51
|
* Tabindex for the input field itself.
|
|
52
52
|
* When another focusable (input) element is present inside the input field, this should be set to -1.
|
|
53
53
|
* @default -1
|
|
54
54
|
*/
|
|
55
|
-
tabindex = input(-1, ...(ngDevMode ? [{ debugName: "tabindex" }] : []));
|
|
55
|
+
tabindex = input(-1, ...(ngDevMode ? [{ debugName: "tabindex" }] : /* istanbul ignore next */ []));
|
|
56
56
|
/**
|
|
57
57
|
* Explicitly apply invalid state styling
|
|
58
58
|
* @default false
|
|
59
59
|
*/
|
|
60
|
-
invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : {}), transform: booleanAttribute });
|
|
60
|
+
invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
61
61
|
/**
|
|
62
62
|
* Explicitly apply readonly state styling
|
|
63
63
|
* @default false
|
|
64
64
|
*/
|
|
65
|
-
readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : {}), transform: booleanAttribute });
|
|
65
|
+
readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
66
66
|
/**
|
|
67
67
|
* Explicitly apply disabled state styling
|
|
68
68
|
* @default false
|
|
69
69
|
*/
|
|
70
|
-
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : {}), transform: booleanAttribute });
|
|
71
|
-
_ngnInput = contentChild(NgnInput, ...(ngDevMode ? [{ debugName: "_ngnInput" }] : []));
|
|
70
|
+
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
71
|
+
_ngnInput = contentChild(NgnInput, ...(ngDevMode ? [{ debugName: "_ngnInput" }] : /* istanbul ignore next */ []));
|
|
72
72
|
constructor() {
|
|
73
73
|
super();
|
|
74
74
|
this.initializeAutoThemeClasses('labelKind', this.labelKind);
|
|
@@ -111,16 +111,16 @@ class NgnInputField extends NgnBase {
|
|
|
111
111
|
inputElement.focus();
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.
|
|
115
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.
|
|
114
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: NgnInputField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
115
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.2", type: NgnInputField, isStandalone: true, selector: "ngn-input-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, labelledBy: { classPropertyName: "labelledBy", publicName: "labelledBy", isSignal: true, isRequired: false, transformFunction: null }, labelKind: { classPropertyName: "labelKind", publicName: "labelKind", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, showClearButton: { classPropertyName: "showClearButton", publicName: "showClearButton", isSignal: true, isRequired: false, transformFunction: null }, iconClearButton: { classPropertyName: "iconClearButton", publicName: "iconClearButton", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "inert": "disabled()" } }, providers: [
|
|
116
116
|
{
|
|
117
117
|
provide: INPUT_FIELD,
|
|
118
118
|
useExisting: forwardRef(() => NgnInputField),
|
|
119
119
|
},
|
|
120
120
|
provideSelf(NgnInputField),
|
|
121
|
-
], queries: [{ propertyName: "_ngnInput", first: true, predicate: NgnInput, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "@if (label(); as label) {\r\n <label [ptInt]=\"this\" [ptClass]=\"'label'\" [for]=\"inputId()\">{{ label }}</label>\r\n}\r\n<!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events -->\r\n<div\r\n [ptInt]=\"this\"\r\n [ptClass]=\"{\r\n root: !hasParentInputfield,\r\n invalid: invalid(),\r\n readonly: readonly(),\r\n disabled: disabled(),\r\n }\"\r\n (click)=\"clicked($event)\"\r\n [tabindex]=\"tabindex()\"\r\n>\r\n <ng-content select=\"input, textarea\" />\r\n @if (showClearButton()) {\r\n <button\r\n tabindex=\"-1\"\r\n [ptInt]=\"this\"\r\n [ptClass]=\"'clear-button'\"\r\n ngnButton\r\n type=\"button\"\r\n [kind]=\"'icon'\"\r\n inline\r\n (click)=\"clearButtonClicked($event)\"\r\n [attr.aria-label]=\"i18n['inputField_clearInput']()\"\r\n >\r\n <ngn-icon defaultIcon=\"xmark\" [icon]=\"iconClearButton()\" />\r\n </button>\r\n }\r\n <ng-content />\r\n</div>\r\n", dependencies: [{ kind: "directive", type: NgnPt, selector: "[ptInt]", inputs: ["ptInt", "ptClass"] }, { kind: "component", type: NgnIcon, selector: "ngn-icon", inputs: ["defaultIcon", "icon"] }, { kind: "directive", type: NgnButton, selector: "button[ngnButton], a[ngnButton]", inputs: ["inline"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
121
|
+
], queries: [{ propertyName: "_ngnInput", first: true, predicate: NgnInput, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "@if (label(); as label) {\r\n <label [ptInt]=\"this\" [ptClass]=\"'label'\" [for]=\"inputId()\">{{ label }}</label>\r\n}\r\n<!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events -->\r\n<div\r\n [ptInt]=\"this\"\r\n [ptClass]=\"{\r\n root: !hasParentInputfield,\r\n invalid: invalid(),\r\n readonly: readonly(),\r\n disabled: disabled(),\r\n }\"\r\n (click)=\"clicked($event)\"\r\n [tabindex]=\"tabindex()\"\r\n>\r\n <ng-content select=\"input, textarea\" />\r\n @if (showClearButton()) {\r\n <button\r\n tabindex=\"-1\"\r\n [ptInt]=\"this\"\r\n [ptClass]=\"'clear-button'\"\r\n ngnButton\r\n type=\"button\"\r\n [kind]=\"'icon'\"\r\n inline\r\n (click)=\"clearButtonClicked($event)\"\r\n [attr.aria-label]=\"i18n['inputField_clearInput']()\"\r\n >\r\n <ngn-icon defaultIcon=\"xmark\" [icon]=\"iconClearButton()\" />\r\n </button>\r\n }\r\n <ng-content />\r\n</div>\r\n", dependencies: [{ kind: "directive", type: NgnPt, selector: "[ptInt]", inputs: ["ptInt", "ptClass"] }, { kind: "component", type: NgnIcon, selector: "ngn-icon", inputs: ["defaultIcon", "icon"] }, { kind: "directive", type: NgnButton, selector: "button[ngnButton], a[ngnButton]", inputs: ["inline"], exportAs: ["ngnButton"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
122
122
|
}
|
|
123
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.
|
|
123
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: NgnInputField, decorators: [{
|
|
124
124
|
type: Component,
|
|
125
125
|
args: [{ changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgnPt, NgnIcon, NgnButton], selector: 'ngn-input-field', host: {
|
|
126
126
|
'[inert]': 'disabled()',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngneers-controls-input-field.mjs","sources":["../../src/input-field/token.ts","../../src/input-field/input-field.ts","../../src/input-field/input-field.html","../../src/input-field/ngneers-controls-input-field.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\n\r\nimport { NgnInputField } from './input-field';\r\n\r\nexport const INPUT_FIELD = new InjectionToken<NgnInputField>('Inputfield');\r\n","import {\r\n booleanAttribute,\r\n Component,\r\n forwardRef,\r\n inject,\r\n input,\r\n ChangeDetectionStrategy,\r\n effect,\r\n contentChild,\r\n} from '@angular/core';\r\nimport { NgnBase, provideSelf, NgnPt } from '@ngneers/controls/base';\r\nimport { NgnButton } from '@ngneers/controls/button';\r\nimport { I18n } from '@ngneers/controls/i18n';\r\nimport { NgnIcon } from '@ngneers/controls/icon';\r\nimport { NgnInput } from '@ngneers/controls/input';\r\nimport { generateElementId } from '@ngneers/controls/utils-ng';\r\nimport { inputFieldControlTemplate } from '@ngneers/controls-themes/templates/input-field';\r\n\r\nimport { INPUT_FIELD } from './token';\r\n\r\nimport type { CustomKind, IconType } from '@ngneers/controls-custom-types';\r\n\r\n/**\r\n * @category control\r\n */\r\n@Component({\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n imports: [NgnPt, NgnIcon, NgnButton],\r\n selector: 'ngn-input-field',\r\n templateUrl: './input-field.html',\r\n host: {\r\n '[inert]': 'disabled()',\r\n },\r\n providers: [\r\n {\r\n provide: INPUT_FIELD,\r\n useExisting: forwardRef(() => NgnInputField),\r\n },\r\n provideSelf(NgnInputField),\r\n ],\r\n})\r\nexport class NgnInputField extends NgnBase<'inputField'> {\r\n protected readonly theme = this.injectThemeTemplate(inputFieldControlTemplate, 'host');\r\n protected readonly i18n = inject(I18n).translations;\r\n private readonly _parentInputfield = inject(INPUT_FIELD, { optional: true, skipSelf: true });\r\n protected readonly hasParentInputfield = !!this._parentInputfield;\r\n\r\n /**\r\n * Label for the input field\r\n * @default null\r\n */\r\n public readonly label = input<string | null>(null);\r\n /**\r\n * Sets the `aria-labelledby` attribute on the input element\r\n * @default null\r\n */\r\n public readonly labelledBy = input<string | null>(null);\r\n /**\r\n * The kind of label presentation\r\n * @todo add link to custom kind documentation subsection label\r\n * @default undefined\r\n */\r\n public readonly labelKind = input<CustomKind<'inputFieldLabel'>>(undefined as never);\r\n /**\r\n * ID for the input element\r\n */\r\n public readonly inputId = input<string>(generateElementId());\r\n /**\r\n * Show clear button\r\n * @default false\r\n */\r\n public readonly showClearButton = input(false, { transform: booleanAttribute });\r\n /**\r\n * Custom icon for the clear button. Use with `showClearButton`.\r\n */\r\n public readonly iconClearButton = input<IconType>();\r\n /**\r\n * Tabindex for the input field itself.\r\n * When another focusable (input) element is present inside the input field, this should be set to -1.\r\n * @default -1\r\n */\r\n public readonly tabindex = input<number>(-1);\r\n /**\r\n * Explicitly apply invalid state styling\r\n * @default false\r\n */\r\n public readonly invalid = input(false, { transform: booleanAttribute });\r\n /**\r\n * Explicitly apply readonly state styling\r\n * @default false\r\n */\r\n public readonly readonly = input(false, { transform: booleanAttribute });\r\n /**\r\n * Explicitly apply disabled state styling\r\n * @default false\r\n */\r\n public readonly disabled = input(false, { transform: booleanAttribute });\r\n\r\n private readonly _ngnInput = contentChild(NgnInput);\r\n\r\n constructor() {\r\n super();\r\n this.initializeAutoThemeClasses('labelKind', this.labelKind);\r\n effect(() => {\r\n const ngnInput = this._ngnInput();\r\n if (!ngnInput) {\r\n return;\r\n }\r\n ngnInput.element.nativeElement.id = this.inputId();\r\n });\r\n effect(() => {\r\n const ngnInput = this._ngnInput();\r\n if (!ngnInput) {\r\n return;\r\n }\r\n const labelledBy = this.labelledBy();\r\n ngnInput.element.nativeElement.setAttribute('aria-labelledby', labelledBy ?? '');\r\n });\r\n }\r\n\r\n protected clicked(event: MouseEvent) {\r\n // Prevent click event from propagating to parent input field\r\n if (this.hasParentInputfield) {\r\n return;\r\n }\r\n if (event.target instanceof HTMLElement) {\r\n // Focus the input element when the input field is clicked\r\n const inputElement = event.target.querySelector('input, textarea');\r\n if (inputElement) {\r\n (inputElement as HTMLInputElement | HTMLTextAreaElement).focus();\r\n }\r\n }\r\n }\r\n\r\n protected clearButtonClicked(event: MouseEvent) {\r\n event.stopPropagation();\r\n const inputElement = this.element.nativeElement.querySelector('input, textarea');\r\n if (inputElement) {\r\n (inputElement as HTMLInputElement | HTMLTextAreaElement).value = '';\r\n inputElement.dispatchEvent(new Event('input', { bubbles: true }));\r\n inputElement.dispatchEvent(new Event('change', { bubbles: true }));\r\n (inputElement as HTMLInputElement | HTMLTextAreaElement).focus();\r\n }\r\n }\r\n}\r\n","@if (label(); as label) {\r\n <label [ptInt]=\"this\" [ptClass]=\"'label'\" [for]=\"inputId()\">{{ label }}</label>\r\n}\r\n<!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events -->\r\n<div\r\n [ptInt]=\"this\"\r\n [ptClass]=\"{\r\n root: !hasParentInputfield,\r\n invalid: invalid(),\r\n readonly: readonly(),\r\n disabled: disabled(),\r\n }\"\r\n (click)=\"clicked($event)\"\r\n [tabindex]=\"tabindex()\"\r\n>\r\n <ng-content select=\"input, textarea\" />\r\n @if (showClearButton()) {\r\n <button\r\n tabindex=\"-1\"\r\n [ptInt]=\"this\"\r\n [ptClass]=\"'clear-button'\"\r\n ngnButton\r\n type=\"button\"\r\n [kind]=\"'icon'\"\r\n inline\r\n (click)=\"clearButtonClicked($event)\"\r\n [attr.aria-label]=\"i18n['inputField_clearInput']()\"\r\n >\r\n <ngn-icon defaultIcon=\"xmark\" [icon]=\"iconClearButton()\" />\r\n </button>\r\n }\r\n <ng-content />\r\n</div>\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;MAIa,WAAW,GAAG,IAAI,cAAc,CAAgB,YAAY;;ACkBzE;;AAEG;AAiBG,MAAO,aAAc,SAAQ,OAAqB,CAAA;IACnC,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,yBAAyB,EAAE,MAAM,CAAC;AACnE,IAAA,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,YAAY;AAClC,IAAA,iBAAiB,GAAG,MAAM,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,C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A,EAAA,CAAA,EAAA,eAAA,EAAA,uBAAuB,CAAC,MAAM,EAAA,OAAA,EACtC,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,EAAA,QAAA,EAC1B,iBAAiB,EAAA,IAAA,EAErB;AACJ,wBAAA,SAAS,EAAE,YAAY;qBACxB,EAAA,SAAA,EACU;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,WAAW;AACpB,4BAAA,WAAW,EAAE,UAAU,CAAC,mBAAmB,CAAC;AAC7C,yBAAA;AACD,wBAAA,WAAW,CAAA,aAAA,CAAe;AAC3B,qBAAA,EAAA,QAAA,EAAA,q9BAAA,EAAA;glCA2DyC,QAAQ,CAAA,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AElGpD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngneers-controls-input-field.mjs","sources":["../../src/input-field/token.ts","../../src/input-field/input-field.ts","../../src/input-field/input-field.html","../../src/input-field/ngneers-controls-input-field.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\n\r\nimport { NgnInputField } from './input-field';\r\n\r\nexport const INPUT_FIELD = new InjectionToken<NgnInputField>('Inputfield');\r\n","import {\r\n booleanAttribute,\r\n Component,\r\n forwardRef,\r\n inject,\r\n input,\r\n ChangeDetectionStrategy,\r\n effect,\r\n contentChild,\r\n} from '@angular/core';\r\nimport { NgnBase, provideSelf, NgnPt } from '@ngneers/controls/base';\r\nimport { NgnButton } from '@ngneers/controls/button';\r\nimport { I18n } from '@ngneers/controls/i18n';\r\nimport { NgnIcon } from '@ngneers/controls/icon';\r\nimport { NgnInput } from '@ngneers/controls/input';\r\nimport { generateElementId } from '@ngneers/controls/utils-ng';\r\nimport { inputFieldControlTemplate } from '@ngneers/controls-themes/templates/input-field';\r\n\r\nimport { INPUT_FIELD } from './token';\r\n\r\nimport type { CustomKind, IconType } from '@ngneers/controls-custom-types';\r\n\r\n/**\r\n * @category control\r\n */\r\n@Component({\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n imports: [NgnPt, NgnIcon, NgnButton],\r\n selector: 'ngn-input-field',\r\n templateUrl: './input-field.html',\r\n host: {\r\n '[inert]': 'disabled()',\r\n },\r\n providers: [\r\n {\r\n provide: INPUT_FIELD,\r\n useExisting: forwardRef(() => NgnInputField),\r\n },\r\n provideSelf(NgnInputField),\r\n ],\r\n})\r\nexport class NgnInputField extends NgnBase<'inputField'> {\r\n protected readonly theme = this.injectThemeTemplate(inputFieldControlTemplate, 'host');\r\n protected readonly i18n = inject(I18n).translations;\r\n private readonly _parentInputfield = inject(INPUT_FIELD, { optional: true, skipSelf: true });\r\n protected readonly hasParentInputfield = !!this._parentInputfield;\r\n\r\n /**\r\n * Label for the input field\r\n * @default null\r\n */\r\n public readonly label = input<string | null>(null);\r\n /**\r\n * Sets the `aria-labelledby` attribute on the input element\r\n * @default null\r\n */\r\n public readonly labelledBy = input<string | null>(null);\r\n /**\r\n * The kind of label presentation\r\n * @todo add link to custom kind documentation subsection label\r\n * @default undefined\r\n */\r\n public readonly labelKind = input<CustomKind<'inputFieldLabel'>>(undefined as never);\r\n /**\r\n * ID for the input element\r\n */\r\n public readonly inputId = input<string>(generateElementId());\r\n /**\r\n * Show clear button\r\n * @default false\r\n */\r\n public readonly showClearButton = input(false, { transform: booleanAttribute });\r\n /**\r\n * Custom icon for the clear button. Use with `showClearButton`.\r\n */\r\n public readonly iconClearButton = input<IconType>();\r\n /**\r\n * Tabindex for the input field itself.\r\n * When another focusable (input) element is present inside the input field, this should be set to -1.\r\n * @default -1\r\n */\r\n public readonly tabindex = input<number>(-1);\r\n /**\r\n * Explicitly apply invalid state styling\r\n * @default false\r\n */\r\n public readonly invalid = input(false, { transform: booleanAttribute });\r\n /**\r\n * Explicitly apply readonly state styling\r\n * @default false\r\n */\r\n public readonly readonly = input(false, { transform: booleanAttribute });\r\n /**\r\n * Explicitly apply disabled state styling\r\n * @default false\r\n */\r\n public readonly disabled = input(false, { transform: booleanAttribute });\r\n\r\n private readonly _ngnInput = contentChild(NgnInput);\r\n\r\n constructor() {\r\n super();\r\n this.initializeAutoThemeClasses('labelKind', this.labelKind);\r\n effect(() => {\r\n const ngnInput = this._ngnInput();\r\n if (!ngnInput) {\r\n return;\r\n }\r\n ngnInput.element.nativeElement.id = this.inputId();\r\n });\r\n effect(() => {\r\n const ngnInput = this._ngnInput();\r\n if (!ngnInput) {\r\n return;\r\n }\r\n const labelledBy = this.labelledBy();\r\n ngnInput.element.nativeElement.setAttribute('aria-labelledby', labelledBy ?? '');\r\n });\r\n }\r\n\r\n protected clicked(event: MouseEvent) {\r\n // Prevent click event from propagating to parent input field\r\n if (this.hasParentInputfield) {\r\n return;\r\n }\r\n if (event.target instanceof HTMLElement) {\r\n // Focus the input element when the input field is clicked\r\n const inputElement = event.target.querySelector('input, textarea');\r\n if (inputElement) {\r\n (inputElement as HTMLInputElement | HTMLTextAreaElement).focus();\r\n }\r\n }\r\n }\r\n\r\n protected clearButtonClicked(event: MouseEvent) {\r\n event.stopPropagation();\r\n const inputElement = this.element.nativeElement.querySelector('input, textarea');\r\n if (inputElement) {\r\n (inputElement as HTMLInputElement | HTMLTextAreaElement).value = '';\r\n inputElement.dispatchEvent(new Event('input', { bubbles: true }));\r\n inputElement.dispatchEvent(new Event('change', { bubbles: true }));\r\n (inputElement as HTMLInputElement | HTMLTextAreaElement).focus();\r\n }\r\n }\r\n}\r\n","@if (label(); as label) {\r\n <label [ptInt]=\"this\" [ptClass]=\"'label'\" [for]=\"inputId()\">{{ label }}</label>\r\n}\r\n<!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events -->\r\n<div\r\n [ptInt]=\"this\"\r\n [ptClass]=\"{\r\n root: !hasParentInputfield,\r\n invalid: invalid(),\r\n readonly: readonly(),\r\n disabled: disabled(),\r\n }\"\r\n (click)=\"clicked($event)\"\r\n [tabindex]=\"tabindex()\"\r\n>\r\n <ng-content select=\"input, textarea\" />\r\n @if (showClearButton()) {\r\n <button\r\n tabindex=\"-1\"\r\n [ptInt]=\"this\"\r\n [ptClass]=\"'clear-button'\"\r\n ngnButton\r\n type=\"button\"\r\n [kind]=\"'icon'\"\r\n inline\r\n (click)=\"clearButtonClicked($event)\"\r\n [attr.aria-label]=\"i18n['inputField_clearInput']()\"\r\n >\r\n <ngn-icon defaultIcon=\"xmark\" [icon]=\"iconClearButton()\" />\r\n </button>\r\n }\r\n <ng-content />\r\n</div>\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;MAIa,WAAW,GAAG,IAAI,cAAc,CAAgB,YAAY;;ACkBzE;;AAEG;AAiBG,MAAO,aAAc,SAAQ,OAAqB,CAAA;IACnC,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,yBAAyB,EAAE,MAAM,CAAC;AACnE,IAAA,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,YAAY;AAClC,IAAA,iBAAiB,GAAG,MAAM,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACzE,IAAA,mBAAmB,GAAG,CAAC,CAAC,IAAI,CAAC,iBAAiB;AAEjE;;;AAGG;AACa,IAAA,KAAK,GAAG,KAAK,CAAgB,IAAI,4EAAC;AAClD;;;AAGG;AACa,IAAA,UAAU,GAAG,KAAK,CAAgB,IAAI,iFAAC;AACvD;;;;AAIG;AACa,IAAA,SAAS,GAAG,KAAK,CAAgC,SAAkB,gFAAC;AACpF;;AAEG;AACa,IAAA,OAAO,GAAG,KAAK,CAAS,iBAAiB,EAAE,8EAAC;AAC5D;;;AAGG;IACa,eAAe,GAAG,KAAK,CAAC,KAAK,uFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;AAC/E;;AAEG;IACa,eAAe,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,iBAAA,EAAA,C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,CAAA;;AElGpD;;AAEG;;;;"}
|
|
@@ -210,9 +210,9 @@ class NgnInputMask extends NgnBase {
|
|
|
210
210
|
/**
|
|
211
211
|
* The mask to apply to the input. Can be a predefined mask key, a custom mask configuration, or a string pattern.
|
|
212
212
|
*/
|
|
213
|
-
mask = input(null, ...(ngDevMode ? [{ debugName: "mask" }] : []));
|
|
213
|
+
mask = input(null, ...(ngDevMode ? [{ debugName: "mask" }] : /* istanbul ignore next */ []));
|
|
214
214
|
_ngnInput = contentChild.required(NgnInput);
|
|
215
|
-
_inputElement = computed(() => this._ngnInput().element.nativeElement, ...(ngDevMode ? [{ debugName: "_inputElement" }] : []));
|
|
215
|
+
_inputElement = computed(() => this._ngnInput().element.nativeElement, ...(ngDevMode ? [{ debugName: "_inputElement" }] : /* istanbul ignore next */ []));
|
|
216
216
|
constructor() {
|
|
217
217
|
super();
|
|
218
218
|
domEventHandler(this._inputElement, 'keydown', event => this.onKeyDown(event));
|
|
@@ -230,8 +230,8 @@ class NgnInputMask extends NgnBase {
|
|
|
230
230
|
// Update the current input value
|
|
231
231
|
this.currentInputValue.set(event.target.value);
|
|
232
232
|
}
|
|
233
|
-
currentInputValue = signal('', ...(ngDevMode ? [{ debugName: "currentInputValue" }] : []));
|
|
234
|
-
_mask = computed(() => this._maskHelper.ensureMask(this.mask()), ...(ngDevMode ? [{ debugName: "_mask" }] : []));
|
|
233
|
+
currentInputValue = signal('', ...(ngDevMode ? [{ debugName: "currentInputValue" }] : /* istanbul ignore next */ []));
|
|
234
|
+
_mask = computed(() => this._maskHelper.ensureMask(this.mask()), ...(ngDevMode ? [{ debugName: "_mask" }] : /* istanbul ignore next */ []));
|
|
235
235
|
maskWatermark = computed(() => {
|
|
236
236
|
const mask = this._mask();
|
|
237
237
|
if (!mask)
|
|
@@ -244,7 +244,7 @@ class NgnInputMask extends NgnBase {
|
|
|
244
244
|
})
|
|
245
245
|
.join('');
|
|
246
246
|
return maskString.substring(this.currentInputValue().length, maskString.length);
|
|
247
|
-
}, ...(ngDevMode ? [{ debugName: "maskWatermark" }] : []));
|
|
247
|
+
}, ...(ngDevMode ? [{ debugName: "maskWatermark" }] : /* istanbul ignore next */ []));
|
|
248
248
|
onKeyDown(event) {
|
|
249
249
|
const mask = this._mask();
|
|
250
250
|
if (!mask)
|
|
@@ -266,10 +266,10 @@ class NgnInputMask extends NgnBase {
|
|
|
266
266
|
});
|
|
267
267
|
this._inputElement().dispatchEvent(new Event('input', { bubbles: true }));
|
|
268
268
|
}
|
|
269
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.
|
|
270
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.
|
|
269
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: NgnInputMask, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
270
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.2", type: NgnInputMask, isStandalone: true, selector: "ngn-input-mask", inputs: { mask: { classPropertyName: "mask", publicName: "mask", isSignal: true, isRequired: false, transformFunction: null } }, providers: [provideSelf(NgnInputMask)], queries: [{ propertyName: "_ngnInput", first: true, predicate: NgnInput, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div [ptInt]=\"this\" [ptClass]=\"'root'\">\r\n <ng-content />\r\n <span [ptInt]=\"this\" [ptClass]=\"'mask'\">\r\n <span [ptInt]=\"this\" [ptClass]=\"'mask-placeholder'\" aria-hidden=\"true\" style=\"opacity: 0\">{{\r\n currentInputValue()\r\n }}</span>\r\n <span [ptInt]=\"this\" [ptClass]=\"'mask-text'\">{{ maskWatermark() }}</span>\r\n </span>\r\n</div>\r\n", dependencies: [{ kind: "directive", type: NgnPt, selector: "[ptInt]", inputs: ["ptInt", "ptClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
271
271
|
}
|
|
272
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.
|
|
272
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: NgnInputMask, decorators: [{
|
|
273
273
|
type: Component,
|
|
274
274
|
args: [{ changeDetection: ChangeDetectionStrategy.OnPush, selector: 'ngn-input-mask', imports: [NgnPt], providers: [provideSelf(NgnInputMask)], template: "<div [ptInt]=\"this\" [ptClass]=\"'root'\">\r\n <ng-content />\r\n <span [ptInt]=\"this\" [ptClass]=\"'mask'\">\r\n <span [ptInt]=\"this\" [ptClass]=\"'mask-placeholder'\" aria-hidden=\"true\" style=\"opacity: 0\">{{\r\n currentInputValue()\r\n }}</span>\r\n <span [ptInt]=\"this\" [ptClass]=\"'mask-text'\">{{ maskWatermark() }}</span>\r\n </span>\r\n</div>\r\n" }]
|
|
275
275
|
}], ctorParameters: () => [], propDecorators: { mask: [{ type: i0.Input, args: [{ isSignal: true, alias: "mask", required: false }] }], _ngnInput: [{ type: i0.ContentChild, args: [i0.forwardRef(() => NgnInput), { isSignal: true }] }] } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngneers-controls-input-mask.mjs","sources":["../../src/input-mask/masks.ts","../../src/input-mask/helper.ts","../../src/input-mask/input-mask.ts","../../src/input-mask/input-mask.html","../../src/input-mask/ngneers-controls-input-mask.ts"],"sourcesContent":["import type { InputMaskCfg } from './types';\r\n\r\nconst time = [\r\n {\r\n accepts: /^\\d$/,\r\n default: '0',\r\n placeholder: 'H',\r\n },\r\n {\r\n accepts: /^\\d$/,\r\n default: '0',\r\n placeholder: 'H',\r\n },\r\n ':',\r\n {\r\n accepts: /^\\d$/,\r\n default: '0',\r\n placeholder: 'M',\r\n },\r\n {\r\n accepts: /^\\d$/,\r\n default: '0',\r\n placeholder: 'M',\r\n },\r\n] as const satisfies InputMaskCfg;\r\n\r\nconst timeSeconds = [\r\n ...time,\r\n ':',\r\n {\r\n accepts: /^\\d$/,\r\n default: '0',\r\n placeholder: 'S',\r\n },\r\n {\r\n accepts: /^\\d$/,\r\n default: '0',\r\n placeholder: 'S',\r\n },\r\n] as const satisfies InputMaskCfg;\r\n\r\nexport const MASKS = {\r\n time,\r\n timeSeconds,\r\n} as const satisfies Record<string, InputMaskCfg>;\r\n","import { MASKS } from './masks';\r\n\r\nimport type { InputMaskCfg } from './types';\r\n\r\n// Interface for communicating with the parent component\r\ntype MaskData = {\r\n updateValue: (element: HTMLInputElement, value: string, position: number) => void;\r\n};\r\n\r\n/**\r\n * Helper class for handling masked input functionality\r\n */\r\nexport class MaskHelper {\r\n private readonly _data: MaskData;\r\n\r\n constructor(data: MaskData) {\r\n this._data = data;\r\n }\r\n\r\n /**\r\n * Ensure the mask is in the correct format\r\n * Converts string masks to TextFieldMaskCfg format\r\n * Returns null if no mask is provided\r\n */\r\n public ensureMask(mask: InputMaskCfg | string | null): InputMaskCfg | null {\r\n if (!mask) return null;\r\n if (typeof mask === 'string') {\r\n if (mask === 'time') {\r\n return MASKS.time;\r\n }\r\n // Convert string mask to TextFieldMaskCfg\r\n // 0 => digit, A => letter, * => alphanumeric\r\n return mask.split('').map(char => {\r\n if (char === '0') {\r\n return { placeholder: char, accepts: /\\d/, default: '0' };\r\n } else if (char === 'A') {\r\n return { placeholder: char, accepts: /[a-zA-Z]/, default: 'A' };\r\n } else if (char === '*') {\r\n return { placeholder: char, accepts: /[a-zA-Z0-9]/, default: 'A' };\r\n }\r\n return char;\r\n });\r\n }\r\n return mask;\r\n }\r\n\r\n /**\r\n * Handle key down events to manage special keys like Backspace and Delete\r\n */\r\n public handleKeyDown(event: KeyboardEvent, mask: InputMaskCfg): void {\r\n if (!mask || this._shouldIgnoreEvent(event)) {\r\n return;\r\n }\r\n const el = event.target as HTMLInputElement;\r\n const key = event.key;\r\n const currentPosition = el.selectionStart ?? 0;\r\n\r\n if (this._isSpecialKey(key)) {\r\n this._handleSpecialKey(event, el, key, currentPosition, mask);\r\n }\r\n }\r\n\r\n /**\r\n * Handle before input event to manage character input with mask validation\r\n */\r\n public handleBeforeInput(event: InputEvent, mask: InputMaskCfg): void {\r\n const el = event.target as HTMLInputElement;\r\n const key = event.data;\r\n const currentPosition = el.selectionStart ?? 0;\r\n\r\n if (!key) {\r\n // If no key data, just return\r\n return;\r\n }\r\n\r\n // Route to appropriate handler based on key type\r\n if (!this._isSpecialKey(key)) {\r\n this._handleCharacterInput(event, el, key, currentPosition, mask);\r\n }\r\n }\r\n\r\n /**\r\n * Check if the event should be ignored (modifier keys)\r\n */\r\n private _shouldIgnoreEvent(event: KeyboardEvent): boolean {\r\n return event.ctrlKey || event.metaKey || event.altKey;\r\n }\r\n\r\n /**\r\n * Check if key is a special key (Backspace/Delete)\r\n */\r\n private _isSpecialKey(key: string): boolean {\r\n return key.length > 1;\r\n }\r\n\r\n /**\r\n * Handle special keys like Backspace and Delete\r\n */\r\n private _handleSpecialKey(\r\n event: KeyboardEvent,\r\n el: HTMLInputElement,\r\n key: string,\r\n currentPosition: number,\r\n mask: InputMaskCfg\r\n ): void {\r\n if (key === 'Backspace' && currentPosition > 0) {\r\n const maskEntry = mask[currentPosition - 1];\r\n if (!maskEntry) {\r\n return;\r\n }\r\n // Get the default character for this position\r\n const defaultChar = typeof maskEntry === 'string' ? maskEntry : maskEntry.default;\r\n\r\n if (currentPosition === el.value.length) {\r\n return;\r\n }\r\n\r\n const newVal =\r\n el.value.slice(0, currentPosition - 1) + defaultChar + el.value.slice(currentPosition);\r\n\r\n this._data.updateValue(el, newVal, currentPosition - 1);\r\n event.preventDefault();\r\n } else if (key === 'Delete' && currentPosition < el.value.length) {\r\n const maskEntry = mask[currentPosition];\r\n if (!maskEntry) {\r\n return;\r\n }\r\n // Get the default character for this position\r\n const defaultChar = typeof maskEntry === 'string' ? maskEntry : maskEntry.default;\r\n const newVal =\r\n el.value.slice(0, currentPosition) + defaultChar + el.value.slice(currentPosition + 1);\r\n\r\n this._data.updateValue(el, newVal, currentPosition + 1);\r\n event.preventDefault();\r\n }\r\n }\r\n\r\n /**\r\n * Handle regular character input with mask validation\r\n */\r\n private _handleCharacterInput(\r\n event: InputEvent,\r\n el: HTMLInputElement,\r\n key: string,\r\n currentPosition: number,\r\n mask: InputMaskCfg\r\n ): void {\r\n // Skip over static characters and find the next input position\r\n const { position, autoPrintChars } = this._processStaticCharacters(el, currentPosition, mask);\r\n const maskEntry = mask[position];\r\n\r\n // Check if we're at a valid input position\r\n if (!maskEntry || typeof maskEntry === 'string') {\r\n event.preventDefault();\r\n return;\r\n }\r\n\r\n // Validate the character against the mask requirements\r\n if (!maskEntry.accepts.test(key)) {\r\n event.preventDefault();\r\n setTimeout(() => {\r\n // Ensure the cursor position is set after the value update for android compatibility\r\n el.setSelectionRange(position, position);\r\n });\r\n return;\r\n }\r\n\r\n // Build the new value with auto-inserted static characters\r\n const newVal =\r\n el.value.slice(0, position) + autoPrintChars + key + el.value.slice(position + 1);\r\n\r\n this._data.updateValue(el, newVal, position + 1);\r\n event.preventDefault();\r\n }\r\n\r\n /**\r\n * Process static characters in the mask and auto-insert them\r\n * Returns the next input position and any static characters to insert\r\n */\r\n private _processStaticCharacters(\r\n el: HTMLInputElement,\r\n startPosition: number,\r\n mask: InputMaskCfg\r\n ): { position: number; autoPrintChars: string } {\r\n let currentPosition = startPosition;\r\n let autoPrintChars = '';\r\n let currentMaskEntry = mask[currentPosition];\r\n\r\n // Skip over static characters and collect them for auto-insertion\r\n while (currentMaskEntry && typeof currentMaskEntry === 'string') {\r\n if (el.value.charAt(currentPosition) !== currentMaskEntry) {\r\n autoPrintChars += currentMaskEntry;\r\n }\r\n currentPosition++;\r\n currentMaskEntry = mask[currentPosition];\r\n }\r\n\r\n return { position: currentPosition, autoPrintChars };\r\n }\r\n}\r\n","import {\r\n afterRenderEffect,\r\n Component,\r\n computed,\r\n contentChild,\r\n input,\r\n signal,\r\n ChangeDetectionStrategy,\r\n} from '@angular/core';\r\nimport { domEventHandler } from '@ngneers/controls/api/ng';\r\nimport { NgnBase, provideSelf, NgnPt } from '@ngneers/controls/base';\r\nimport { NgnInput } from '@ngneers/controls/input';\r\nimport { inputMaskControlTemplate } from '@ngneers/controls-themes/templates/input-mask';\r\n\r\nimport { MaskHelper } from './helper';\r\n\r\nimport type { InputMaskCfg } from './types';\r\n\r\n/**\r\n * @category control\r\n */\r\n@Component({\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n selector: 'ngn-input-mask',\r\n templateUrl: './input-mask.html',\r\n imports: [NgnPt],\r\n providers: [provideSelf(NgnInputMask)],\r\n})\r\nexport class NgnInputMask extends NgnBase<'inputMask'> {\r\n protected readonly theme = this.injectThemeTemplate(inputMaskControlTemplate);\r\n /**\r\n * The mask to apply to the input. Can be a predefined mask key, a custom mask configuration, or a string pattern.\r\n */\r\n public readonly mask = input<'time' | InputMaskCfg | string | null>(null);\r\n\r\n private readonly _ngnInput = contentChild.required<NgnInput>(NgnInput);\r\n private readonly _inputElement = computed(\r\n () => this._ngnInput().element.nativeElement as HTMLInputElement\r\n );\r\n\r\n constructor() {\r\n super();\r\n domEventHandler(this._inputElement, 'keydown', event => this.onKeyDown(event));\r\n domEventHandler(this._inputElement, 'beforeinput', event => this.onBeforeInput(event));\r\n\r\n afterRenderEffect(() => {\r\n if (this._ngnInput().value() !== this.currentInputValue()) {\r\n this.currentInputValue.set(this._ngnInput().value() ?? '');\r\n }\r\n });\r\n }\r\n\r\n private readonly _maskHelper = new MaskHelper({\r\n updateValue: (e, v, i) => this._updateValue(e, v, i),\r\n });\r\n\r\n protected onInput(event: Event) {\r\n // Update the current input value\r\n this.currentInputValue.set((event.target as HTMLInputElement).value);\r\n }\r\n\r\n protected readonly currentInputValue = signal<string>('');\r\n\r\n private readonly _mask = computed(() => this._maskHelper.ensureMask(this.mask()));\r\n\r\n protected readonly maskWatermark = computed(() => {\r\n const mask = this._mask();\r\n if (!mask) return null;\r\n const maskString = mask\r\n .map(entry => {\r\n if (typeof entry === 'string') return entry;\r\n return entry.placeholder;\r\n })\r\n .join('');\r\n return maskString.substring(this.currentInputValue().length, maskString.length);\r\n });\r\n\r\n protected onKeyDown(event: KeyboardEvent) {\r\n const mask = this._mask();\r\n if (!mask) return;\r\n this._maskHelper.handleKeyDown(event, mask);\r\n }\r\n\r\n protected onBeforeInput(event: Event) {\r\n const mask = this._mask();\r\n if (!mask) return;\r\n this._maskHelper.handleBeforeInput(event as InputEvent, mask);\r\n }\r\n\r\n private _updateValue(el: HTMLInputElement, newValue: string, cursorPosition: number): void {\r\n el.value = newValue;\r\n this.currentInputValue.set(newValue);\r\n setTimeout(() => {\r\n // Ensure the cursor position is set after the value update for android compatibility\r\n el.setSelectionRange(cursorPosition, cursorPosition);\r\n });\r\n this._inputElement().dispatchEvent(new Event('input', { bubbles: true }));\r\n }\r\n}\r\n","<div [ptInt]=\"this\" [ptClass]=\"'root'\">\r\n <ng-content />\r\n <span [ptInt]=\"this\" [ptClass]=\"'mask'\">\r\n <span [ptInt]=\"this\" [ptClass]=\"'mask-placeholder'\" aria-hidden=\"true\" style=\"opacity: 0\">{{\r\n currentInputValue()\r\n }}</span>\r\n <span [ptInt]=\"this\" [ptClass]=\"'mask-text'\">{{ maskWatermark() }}</span>\r\n </span>\r\n</div>\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAEA,MAAM,IAAI,GAAG;AACX,IAAA;AACE,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,OAAO,EAAE,GAAG;AACZ,QAAA,WAAW,EAAE,GAAG;AACjB,KAAA;AACD,IAAA;AACE,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,OAAO,EAAE,GAAG;AACZ,QAAA,WAAW,EAAE,GAAG;AACjB,KAAA;IACD,GAAG;AACH,IAAA;AACE,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,OAAO,EAAE,GAAG;AACZ,QAAA,WAAW,EAAE,GAAG;AACjB,KAAA;AACD,IAAA;AACE,QAAA,OAAO,EAAE,MAAM;AACf,QAA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,EAAA,eAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECnCvE,6XASA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EDgBY,KAAK,EAAA,QAAA,EAAA,SAAA,EAAA,MAAA,EAAA,CAAA,OAAA,EAAA,SAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAGJ,YAAY,EAAA,UAAA,EAAA,CAAA;kBAPxB,SAAS;AACS,YAAA,IAAA,EAAA,CAAA,EAAA,eAAA,EAAA,uBAAuB,CAAC,MAAM,EAAA,QAAA,EACrC,gBAAgB,EAAA,OAAA,EAEjB,CAAC,KAAK,CAAC,EAAA,SAAA,EACL,CAAC,WAAW,CAAA,YAAA,CAAc,CAAC,EAAA,QAAA,EAAA,6XAAA,EAAA;gNASuB,QAAQ,CAAA,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEnCvE;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngneers-controls-input-mask.mjs","sources":["../../src/input-mask/masks.ts","../../src/input-mask/helper.ts","../../src/input-mask/input-mask.ts","../../src/input-mask/input-mask.html","../../src/input-mask/ngneers-controls-input-mask.ts"],"sourcesContent":["import type { InputMaskCfg } from './types';\r\n\r\nconst time = [\r\n {\r\n accepts: /^\\d$/,\r\n default: '0',\r\n placeholder: 'H',\r\n },\r\n {\r\n accepts: /^\\d$/,\r\n default: '0',\r\n placeholder: 'H',\r\n },\r\n ':',\r\n {\r\n accepts: /^\\d$/,\r\n default: '0',\r\n placeholder: 'M',\r\n },\r\n {\r\n accepts: /^\\d$/,\r\n default: '0',\r\n placeholder: 'M',\r\n },\r\n] as const satisfies InputMaskCfg;\r\n\r\nconst timeSeconds = [\r\n ...time,\r\n ':',\r\n {\r\n accepts: /^\\d$/,\r\n default: '0',\r\n placeholder: 'S',\r\n },\r\n {\r\n accepts: /^\\d$/,\r\n default: '0',\r\n placeholder: 'S',\r\n },\r\n] as const satisfies InputMaskCfg;\r\n\r\nexport const MASKS = {\r\n time,\r\n timeSeconds,\r\n} as const satisfies Record<string, InputMaskCfg>;\r\n","import { MASKS } from './masks';\r\n\r\nimport type { InputMaskCfg } from './types';\r\n\r\n// Interface for communicating with the parent component\r\ntype MaskData = {\r\n updateValue: (element: HTMLInputElement, value: string, position: number) => void;\r\n};\r\n\r\n/**\r\n * Helper class for handling masked input functionality\r\n */\r\nexport class MaskHelper {\r\n private readonly _data: MaskData;\r\n\r\n constructor(data: MaskData) {\r\n this._data = data;\r\n }\r\n\r\n /**\r\n * Ensure the mask is in the correct format\r\n * Converts string masks to TextFieldMaskCfg format\r\n * Returns null if no mask is provided\r\n */\r\n public ensureMask(mask: InputMaskCfg | string | null): InputMaskCfg | null {\r\n if (!mask) return null;\r\n if (typeof mask === 'string') {\r\n if (mask === 'time') {\r\n return MASKS.time;\r\n }\r\n // Convert string mask to TextFieldMaskCfg\r\n // 0 => digit, A => letter, * => alphanumeric\r\n return mask.split('').map(char => {\r\n if (char === '0') {\r\n return { placeholder: char, accepts: /\\d/, default: '0' };\r\n } else if (char === 'A') {\r\n return { placeholder: char, accepts: /[a-zA-Z]/, default: 'A' };\r\n } else if (char === '*') {\r\n return { placeholder: char, accepts: /[a-zA-Z0-9]/, default: 'A' };\r\n }\r\n return char;\r\n });\r\n }\r\n return mask;\r\n }\r\n\r\n /**\r\n * Handle key down events to manage special keys like Backspace and Delete\r\n */\r\n public handleKeyDown(event: KeyboardEvent, mask: InputMaskCfg): void {\r\n if (!mask || this._shouldIgnoreEvent(event)) {\r\n return;\r\n }\r\n const el = event.target as HTMLInputElement;\r\n const key = event.key;\r\n const currentPosition = el.selectionStart ?? 0;\r\n\r\n if (this._isSpecialKey(key)) {\r\n this._handleSpecialKey(event, el, key, currentPosition, mask);\r\n }\r\n }\r\n\r\n /**\r\n * Handle before input event to manage character input with mask validation\r\n */\r\n public handleBeforeInput(event: InputEvent, mask: InputMaskCfg): void {\r\n const el = event.target as HTMLInputElement;\r\n const key = event.data;\r\n const currentPosition = el.selectionStart ?? 0;\r\n\r\n if (!key) {\r\n // If no key data, just return\r\n return;\r\n }\r\n\r\n // Route to appropriate handler based on key type\r\n if (!this._isSpecialKey(key)) {\r\n this._handleCharacterInput(event, el, key, currentPosition, mask);\r\n }\r\n }\r\n\r\n /**\r\n * Check if the event should be ignored (modifier keys)\r\n */\r\n private _shouldIgnoreEvent(event: KeyboardEvent): boolean {\r\n return event.ctrlKey || event.metaKey || event.altKey;\r\n }\r\n\r\n /**\r\n * Check if key is a special key (Backspace/Delete)\r\n */\r\n private _isSpecialKey(key: string): boolean {\r\n return key.length > 1;\r\n }\r\n\r\n /**\r\n * Handle special keys like Backspace and Delete\r\n */\r\n private _handleSpecialKey(\r\n event: KeyboardEvent,\r\n el: HTMLInputElement,\r\n key: string,\r\n currentPosition: number,\r\n mask: InputMaskCfg\r\n ): void {\r\n if (key === 'Backspace' && currentPosition > 0) {\r\n const maskEntry = mask[currentPosition - 1];\r\n if (!maskEntry) {\r\n return;\r\n }\r\n // Get the default character for this position\r\n const defaultChar = typeof maskEntry === 'string' ? maskEntry : maskEntry.default;\r\n\r\n if (currentPosition === el.value.length) {\r\n return;\r\n }\r\n\r\n const newVal =\r\n el.value.slice(0, currentPosition - 1) + defaultChar + el.value.slice(currentPosition);\r\n\r\n this._data.updateValue(el, newVal, currentPosition - 1);\r\n event.preventDefault();\r\n } else if (key === 'Delete' && currentPosition < el.value.length) {\r\n const maskEntry = mask[currentPosition];\r\n if (!maskEntry) {\r\n return;\r\n }\r\n // Get the default character for this position\r\n const defaultChar = typeof maskEntry === 'string' ? maskEntry : maskEntry.default;\r\n const newVal =\r\n el.value.slice(0, currentPosition) + defaultChar + el.value.slice(currentPosition + 1);\r\n\r\n this._data.updateValue(el, newVal, currentPosition + 1);\r\n event.preventDefault();\r\n }\r\n }\r\n\r\n /**\r\n * Handle regular character input with mask validation\r\n */\r\n private _handleCharacterInput(\r\n event: InputEvent,\r\n el: HTMLInputElement,\r\n key: string,\r\n currentPosition: number,\r\n mask: InputMaskCfg\r\n ): void {\r\n // Skip over static characters and find the next input position\r\n const { position, autoPrintChars } = this._processStaticCharacters(el, currentPosition, mask);\r\n const maskEntry = mask[position];\r\n\r\n // Check if we're at a valid input position\r\n if (!maskEntry || typeof maskEntry === 'string') {\r\n event.preventDefault();\r\n return;\r\n }\r\n\r\n // Validate the character against the mask requirements\r\n if (!maskEntry.accepts.test(key)) {\r\n event.preventDefault();\r\n setTimeout(() => {\r\n // Ensure the cursor position is set after the value update for android compatibility\r\n el.setSelectionRange(position, position);\r\n });\r\n return;\r\n }\r\n\r\n // Build the new value with auto-inserted static characters\r\n const newVal =\r\n el.value.slice(0, position) + autoPrintChars + key + el.value.slice(position + 1);\r\n\r\n this._data.updateValue(el, newVal, position + 1);\r\n event.preventDefault();\r\n }\r\n\r\n /**\r\n * Process static characters in the mask and auto-insert them\r\n * Returns the next input position and any static characters to insert\r\n */\r\n private _processStaticCharacters(\r\n el: HTMLInputElement,\r\n startPosition: number,\r\n mask: InputMaskCfg\r\n ): { position: number; autoPrintChars: string } {\r\n let currentPosition = startPosition;\r\n let autoPrintChars = '';\r\n let currentMaskEntry = mask[currentPosition];\r\n\r\n // Skip over static characters and collect them for auto-insertion\r\n while (currentMaskEntry && typeof currentMaskEntry === 'string') {\r\n if (el.value.charAt(currentPosition) !== currentMaskEntry) {\r\n autoPrintChars += currentMaskEntry;\r\n }\r\n currentPosition++;\r\n currentMaskEntry = mask[currentPosition];\r\n }\r\n\r\n return { position: currentPosition, autoPrintChars };\r\n }\r\n}\r\n","import {\r\n afterRenderEffect,\r\n Component,\r\n computed,\r\n contentChild,\r\n input,\r\n signal,\r\n ChangeDetectionStrategy,\r\n} from '@angular/core';\r\nimport { domEventHandler } from '@ngneers/controls/api/ng';\r\nimport { NgnBase, provideSelf, NgnPt } from '@ngneers/controls/base';\r\nimport { NgnInput } from '@ngneers/controls/input';\r\nimport { inputMaskControlTemplate } from '@ngneers/controls-themes/templates/input-mask';\r\n\r\nimport { MaskHelper } from './helper';\r\n\r\nimport type { InputMaskCfg } from './types';\r\n\r\n/**\r\n * @category control\r\n */\r\n@Component({\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n selector: 'ngn-input-mask',\r\n templateUrl: './input-mask.html',\r\n imports: [NgnPt],\r\n providers: [provideSelf(NgnInputMask)],\r\n})\r\nexport class NgnInputMask extends NgnBase<'inputMask'> {\r\n protected readonly theme = this.injectThemeTemplate(inputMaskControlTemplate);\r\n /**\r\n * The mask to apply to the input. Can be a predefined mask key, a custom mask configuration, or a string pattern.\r\n */\r\n public readonly mask = input<'time' | InputMaskCfg | string | null>(null);\r\n\r\n private readonly _ngnInput = contentChild.required<NgnInput>(NgnInput);\r\n private readonly _inputElement = computed(\r\n () => this._ngnInput().element.nativeElement as HTMLInputElement\r\n );\r\n\r\n constructor() {\r\n super();\r\n domEventHandler(this._inputElement, 'keydown', event => this.onKeyDown(event));\r\n domEventHandler(this._inputElement, 'beforeinput', event => this.onBeforeInput(event));\r\n\r\n afterRenderEffect(() => {\r\n if (this._ngnInput().value() !== this.currentInputValue()) {\r\n this.currentInputValue.set(this._ngnInput().value() ?? '');\r\n }\r\n });\r\n }\r\n\r\n private readonly _maskHelper = new MaskHelper({\r\n updateValue: (e, v, i) => this._updateValue(e, v, i),\r\n });\r\n\r\n protected onInput(event: Event) {\r\n // Update the current input value\r\n this.currentInputValue.set((event.target as HTMLInputElement).value);\r\n }\r\n\r\n protected readonly currentInputValue = signal<string>('');\r\n\r\n private readonly _mask = computed(() => this._maskHelper.ensureMask(this.mask()));\r\n\r\n protected readonly maskWatermark = computed(() => {\r\n const mask = this._mask();\r\n if (!mask) return null;\r\n const maskString = mask\r\n .map(entry => {\r\n if (typeof entry === 'string') return entry;\r\n return entry.placeholder;\r\n })\r\n .join('');\r\n return maskString.substring(this.currentInputValue().length, maskString.length);\r\n });\r\n\r\n protected onKeyDown(event: KeyboardEvent) {\r\n const mask = this._mask();\r\n if (!mask) return;\r\n this._maskHelper.handleKeyDown(event, mask);\r\n }\r\n\r\n protected onBeforeInput(event: Event) {\r\n const mask = this._mask();\r\n if (!mask) return;\r\n this._maskHelper.handleBeforeInput(event as InputEvent, mask);\r\n }\r\n\r\n private _updateValue(el: HTMLInputElement, newValue: string, cursorPosition: number): void {\r\n el.value = newValue;\r\n this.currentInputValue.set(newValue);\r\n setTimeout(() => {\r\n // Ensure the cursor position is set after the value update for android compatibility\r\n el.setSelectionRange(cursorPosition, cursorPosition);\r\n });\r\n this._inputElement().dispatchEvent(new Event('input', { bubbles: true }));\r\n }\r\n}\r\n","<div [ptInt]=\"this\" [ptClass]=\"'root'\">\r\n <ng-content />\r\n <span [ptInt]=\"this\" [ptClass]=\"'mask'\">\r\n <span [ptInt]=\"this\" [ptClass]=\"'mask-placeholder'\" aria-hidden=\"true\" style=\"opacity: 0\">{{\r\n currentInputValue()\r\n }}</span>\r\n <span [ptInt]=\"this\" [ptClass]=\"'mask-text'\">{{ maskWatermark() }}</span>\r\n </span>\r\n</div>\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAEA,MAAM,IAAI,GAAG;AACX,IAAA;AACE,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,OAAO,EAAE,GAAG;AACZ,QAAA,WAAW,EAAE,GAAG;AACjB,KAAA;AACD,IAAA;AACE,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,OAAO,EAAE,GAAG;AACZ,QAAA,WAAW,EAAE,GAAG;AACjB,KAAA;IACD,GAAG;AACH,IAAA;AACE,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,OAAO,EAAE,GAAG;AACZ,QAAA,WAAW,EAAE,GAAG;AACjB,KAAA;AACD,IAAA;AACE,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,OAAO,EAAE,GAAG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IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECnCvE,6XASA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EDgBY,KAAK,EAAA,QAAA,EAAA,SAAA,EAAA,MAAA,EAAA,CAAA,OAAA,EAAA,SAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAGJ,YAAY,EAAA,UAAA,EAAA,CAAA;kBAPxB,SAAS;AACS,YAAA,IAAA,EAAA,CAAA,EAAA,eAAA,EAAA,uBAAuB,CAAC,MAAM,EAAA,QAAA,EACrC,gBAAgB,EAAA,OAAA,EAEjB,CAAC,KAAK,CAAC,EAAA,SAAA,EACL,CAAC,WAAW,CAAA,YAAA,CAAc,CAAC,EAAA,QAAA,EAAA,6XAAA,EAAA;gNASuB,QAAQ,CAAA,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEnCvE;;AAEG;;;;"}
|
|
@@ -9,7 +9,7 @@ import { inputFieldControlTemplate } from '@ngneers/controls-themes/templates/in
|
|
|
9
9
|
* @category control
|
|
10
10
|
*/
|
|
11
11
|
class NgnInput extends NgnBase {
|
|
12
|
-
hasParentInputfield = signal(false, ...(ngDevMode ? [{ debugName: "hasParentInputfield" }] : []));
|
|
12
|
+
hasParentInputfield = signal(false, ...(ngDevMode ? [{ debugName: "hasParentInputfield" }] : /* istanbul ignore next */ []));
|
|
13
13
|
theme = this.injectThemeTemplate(inputControlTemplate, {
|
|
14
14
|
root: true,
|
|
15
15
|
invalid: () => this.invalid(),
|
|
@@ -20,8 +20,8 @@ class NgnInput extends NgnBase {
|
|
|
20
20
|
* Explicitly apply invalid state styling
|
|
21
21
|
* @default false
|
|
22
22
|
*/
|
|
23
|
-
invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : {}), transform: booleanAttribute });
|
|
24
|
-
value = model('', ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
23
|
+
invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
24
|
+
value = model('', ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
25
25
|
_input = this.element.nativeElement;
|
|
26
26
|
ngAfterViewInit() {
|
|
27
27
|
this.hasParentInputfield.set(!!this.element.nativeElement.closest('ngn-input-field'));
|
|
@@ -47,10 +47,10 @@ class NgnInput extends NgnBase {
|
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.
|
|
51
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.
|
|
50
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: NgnInput, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
51
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.2", type: NgnInput, isStandalone: true, selector: "input[ngnInput], textarea[ngnInput]", inputs: { invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { properties: { "class": "(hasParentInputfield() ? \"\" : ` ${inputFieldTheme.class(\"root\")}`)" } }, providers: [provideSelf(NgnInput)], exportAs: ["ngnInput"], usesInheritance: true, ngImport: i0 });
|
|
52
52
|
}
|
|
53
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.
|
|
53
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: NgnInput, decorators: [{
|
|
54
54
|
type: Directive,
|
|
55
55
|
args: [{
|
|
56
56
|
selector: 'input[ngnInput], textarea[ngnInput]',
|
|
@@ -58,6 +58,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
|
|
|
58
58
|
'[class]': '(hasParentInputfield() ? "" : ` ${inputFieldTheme.class("root")}`)',
|
|
59
59
|
},
|
|
60
60
|
providers: [provideSelf(NgnInput)],
|
|
61
|
+
exportAs: 'ngnInput',
|
|
61
62
|
}]
|
|
62
63
|
}], ctorParameters: () => [], propDecorators: { invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
|
|
63
64
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngneers-controls-input.mjs","sources":["../../src/input/input.ts","../../src/input/ngneers-controls-input.ts"],"sourcesContent":["import {\r\n type AfterViewInit,\r\n booleanAttribute,\r\n Directive,\r\n effect,\r\n input,\r\n model,\r\n runInInjectionContext,\r\n signal,\r\n} from '@angular/core';\r\nimport { domEventSignal } from '@ngneers/controls/api/ng';\r\nimport { NgnBase, provideSelf } from '@ngneers/controls/base';\r\nimport { inputControlTemplate } from '@ngneers/controls-themes/templates/input';\r\nimport { inputFieldControlTemplate } from '@ngneers/controls-themes/templates/input-field';\r\n\r\n/**\r\n * @category control\r\n */\r\n@Directive({\r\n selector: 'input[ngnInput], textarea[ngnInput]',\r\n host: {\r\n '[class]': '(hasParentInputfield() ? \"\" : ` ${inputFieldTheme.class(\"root\")}`)',\r\n },\r\n providers: [provideSelf(NgnInput)],\r\n})\r\nexport class NgnInput extends NgnBase<'input'> implements AfterViewInit {\r\n protected readonly hasParentInputfield = signal(false);\r\n\r\n protected readonly theme = this.injectThemeTemplate(inputControlTemplate, {\r\n root: true,\r\n invalid: () => this.invalid(),\r\n empty: () => !this.value(),\r\n });\r\n protected readonly inputFieldTheme = this.injectThemeTemplate<true>(inputFieldControlTemplate);\r\n /**\r\n * Explicitly apply invalid state styling\r\n * @default false\r\n */\r\n public readonly invalid = input(false, { transform: booleanAttribute });\r\n\r\n public readonly value = model<string | null>('');\r\n\r\n private readonly _input = this.element.nativeElement as HTMLInputElement;\r\n\r\n public ngAfterViewInit() {\r\n this.hasParentInputfield.set(!!this.element.nativeElement.closest('ngn-input-field'));\r\n const changeEvent = domEventSignal(\r\n this.element.nativeElement as HTMLInputElement,\r\n 'change',\r\n this.injector\r\n );\r\n const inputEvent = domEventSignal(\r\n this.element.nativeElement as HTMLInputElement,\r\n 'input',\r\n this.injector\r\n );\r\n\r\n runInInjectionContext(this.injector, () => {\r\n effect(() => {\r\n const _changeEvent = changeEvent();\r\n const _inputEvent = inputEvent();\r\n if (!_changeEvent && !_inputEvent) {\r\n return;\r\n }\r\n const val = this._input.value;\r\n this.value.set(val ?? '');\r\n });\r\n });\r\n }\r\n\r\n constructor() {\r\n super();\r\n effect(() => {\r\n if (this._input.value !== this.value()) {\r\n this._input.value = this.value() || '';\r\n }\r\n });\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAeA;;AAEG;
|
|
1
|
+
{"version":3,"file":"ngneers-controls-input.mjs","sources":["../../src/input/input.ts","../../src/input/ngneers-controls-input.ts"],"sourcesContent":["import {\r\n type AfterViewInit,\r\n booleanAttribute,\r\n Directive,\r\n effect,\r\n input,\r\n model,\r\n runInInjectionContext,\r\n signal,\r\n} from '@angular/core';\r\nimport { domEventSignal } from '@ngneers/controls/api/ng';\r\nimport { NgnBase, provideSelf } from '@ngneers/controls/base';\r\nimport { inputControlTemplate } from '@ngneers/controls-themes/templates/input';\r\nimport { inputFieldControlTemplate } from '@ngneers/controls-themes/templates/input-field';\r\n\r\n/**\r\n * @category control\r\n */\r\n@Directive({\r\n selector: 'input[ngnInput], textarea[ngnInput]',\r\n host: {\r\n '[class]': '(hasParentInputfield() ? \"\" : ` ${inputFieldTheme.class(\"root\")}`)',\r\n },\r\n providers: [provideSelf(NgnInput)],\r\n exportAs: 'ngnInput',\r\n})\r\nexport class NgnInput extends NgnBase<'input'> implements AfterViewInit {\r\n protected readonly hasParentInputfield = signal(false);\r\n\r\n protected readonly theme = this.injectThemeTemplate(inputControlTemplate, {\r\n root: true,\r\n invalid: () => this.invalid(),\r\n empty: () => !this.value(),\r\n });\r\n protected readonly inputFieldTheme = this.injectThemeTemplate<true>(inputFieldControlTemplate);\r\n /**\r\n * Explicitly apply invalid state styling\r\n * @default false\r\n */\r\n public readonly invalid = input(false, { transform: booleanAttribute });\r\n\r\n public readonly value = model<string | null>('');\r\n\r\n private readonly _input = this.element.nativeElement as HTMLInputElement;\r\n\r\n public ngAfterViewInit() {\r\n this.hasParentInputfield.set(!!this.element.nativeElement.closest('ngn-input-field'));\r\n const changeEvent = domEventSignal(\r\n this.element.nativeElement as HTMLInputElement,\r\n 'change',\r\n this.injector\r\n );\r\n const inputEvent = domEventSignal(\r\n this.element.nativeElement as HTMLInputElement,\r\n 'input',\r\n this.injector\r\n );\r\n\r\n runInInjectionContext(this.injector, () => {\r\n effect(() => {\r\n const _changeEvent = changeEvent();\r\n const _inputEvent = inputEvent();\r\n if (!_changeEvent && !_inputEvent) {\r\n return;\r\n }\r\n const val = this._input.value;\r\n this.value.set(val ?? '');\r\n });\r\n });\r\n }\r\n\r\n constructor() {\r\n super();\r\n effect(() => {\r\n if (this._input.value !== this.value()) {\r\n this._input.value = this.value() || '';\r\n }\r\n });\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAeA;;AAEG;AASG,MAAO,QAAS,SAAQ,OAAgB,CAAA;AACzB,IAAA,mBAAmB,GAAG,MAAM,CAAC,KAAK,0FAAC;AAEnC,IAAA,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,EAAE;AACxE,QAAA,IAAI,EAAE,IAAI;AACV,QAAA,OAAO,EAAE,MAAM,IAAI,CAA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