@neural-ui/core 1.7.1 → 1.7.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/bottom-sheet/package.json +4 -0
- package/confirm-popup/package.json +4 -0
- package/data-view/package.json +4 -0
- package/fesm2022/neural-ui-core-alert.mjs +48 -21
- package/fesm2022/neural-ui-core-alert.mjs.map +1 -1
- package/fesm2022/neural-ui-core-autocomplete.mjs +153 -71
- package/fesm2022/neural-ui-core-autocomplete.mjs.map +1 -1
- package/fesm2022/neural-ui-core-block-ui.mjs +2 -2
- package/fesm2022/neural-ui-core-block-ui.mjs.map +1 -1
- package/fesm2022/neural-ui-core-bottom-sheet.mjs +121 -0
- package/fesm2022/neural-ui-core-bottom-sheet.mjs.map +1 -0
- package/fesm2022/neural-ui-core-breadcrumb.mjs +2 -2
- package/fesm2022/neural-ui-core-breadcrumb.mjs.map +1 -1
- package/fesm2022/neural-ui-core-button.mjs +2 -2
- package/fesm2022/neural-ui-core-button.mjs.map +1 -1
- package/fesm2022/neural-ui-core-calendar.mjs +2 -2
- package/fesm2022/neural-ui-core-calendar.mjs.map +1 -1
- package/fesm2022/neural-ui-core-checkbox.mjs +69 -39
- package/fesm2022/neural-ui-core-checkbox.mjs.map +1 -1
- package/fesm2022/neural-ui-core-chip.mjs +2 -2
- package/fesm2022/neural-ui-core-chip.mjs.map +1 -1
- package/fesm2022/neural-ui-core-code-block.mjs +2 -2
- package/fesm2022/neural-ui-core-code-block.mjs.map +1 -1
- package/fesm2022/neural-ui-core-confirm-popup.mjs +105 -0
- package/fesm2022/neural-ui-core-confirm-popup.mjs.map +1 -0
- package/fesm2022/neural-ui-core-dashboard-grid.mjs +9 -3
- package/fesm2022/neural-ui-core-dashboard-grid.mjs.map +1 -1
- package/fesm2022/neural-ui-core-data-view.mjs +386 -0
- package/fesm2022/neural-ui-core-data-view.mjs.map +1 -0
- package/fesm2022/neural-ui-core-date-input.mjs +185 -10
- package/fesm2022/neural-ui-core-date-input.mjs.map +1 -1
- package/fesm2022/neural-ui-core-empty-state.mjs +19 -5
- package/fesm2022/neural-ui-core-empty-state.mjs.map +1 -1
- package/fesm2022/neural-ui-core-form-field.mjs +81 -0
- package/fesm2022/neural-ui-core-form-field.mjs.map +1 -0
- package/fesm2022/neural-ui-core-inline-editor.mjs +428 -0
- package/fesm2022/neural-ui-core-inline-editor.mjs.map +1 -0
- package/fesm2022/neural-ui-core-input-mask.mjs +110 -0
- package/fesm2022/neural-ui-core-input-mask.mjs.map +1 -0
- package/fesm2022/neural-ui-core-input.mjs +2 -2
- package/fesm2022/neural-ui-core-input.mjs.map +1 -1
- package/fesm2022/neural-ui-core-listbox.mjs +219 -0
- package/fesm2022/neural-ui-core-listbox.mjs.map +1 -0
- package/fesm2022/neural-ui-core-menu.mjs +229 -0
- package/fesm2022/neural-ui-core-menu.mjs.map +1 -0
- package/fesm2022/neural-ui-core-modal.mjs +34 -10
- package/fesm2022/neural-ui-core-modal.mjs.map +1 -1
- package/fesm2022/neural-ui-core-multiselect.mjs +170 -179
- package/fesm2022/neural-ui-core-multiselect.mjs.map +1 -1
- package/fesm2022/neural-ui-core-number-input.mjs +2 -2
- package/fesm2022/neural-ui-core-number-input.mjs.map +1 -1
- package/fesm2022/neural-ui-core-panel.mjs +92 -0
- package/fesm2022/neural-ui-core-panel.mjs.map +1 -0
- package/fesm2022/neural-ui-core-password.mjs +106 -0
- package/fesm2022/neural-ui-core-password.mjs.map +1 -0
- package/fesm2022/neural-ui-core-pick-list.mjs +133 -0
- package/fesm2022/neural-ui-core-pick-list.mjs.map +1 -0
- package/fesm2022/neural-ui-core-select.mjs +128 -166
- package/fesm2022/neural-ui-core-select.mjs.map +1 -1
- package/fesm2022/neural-ui-core-sidebar.mjs +14 -3
- package/fesm2022/neural-ui-core-sidebar.mjs.map +1 -1
- package/fesm2022/neural-ui-core-slider.mjs +2 -2
- package/fesm2022/neural-ui-core-slider.mjs.map +1 -1
- package/fesm2022/neural-ui-core-spinner.mjs +19 -9
- package/fesm2022/neural-ui-core-spinner.mjs.map +1 -1
- package/fesm2022/neural-ui-core-split-button.mjs +2 -2
- package/fesm2022/neural-ui-core-split-button.mjs.map +1 -1
- package/fesm2022/neural-ui-core-table.mjs +503 -62
- package/fesm2022/neural-ui-core-table.mjs.map +1 -1
- package/fesm2022/neural-ui-core-tabs.mjs +11 -4
- package/fesm2022/neural-ui-core-tabs.mjs.map +1 -1
- package/fesm2022/neural-ui-core-tags.mjs +134 -0
- package/fesm2022/neural-ui-core-tags.mjs.map +1 -0
- package/fesm2022/neural-ui-core-textarea.mjs +2 -2
- package/fesm2022/neural-ui-core-textarea.mjs.map +1 -1
- package/fesm2022/neural-ui-core-toggle-button-group.mjs +2 -2
- package/fesm2022/neural-ui-core-toggle-button-group.mjs.map +1 -1
- package/fesm2022/neural-ui-core-toolbar.mjs +16 -4
- package/fesm2022/neural-ui-core-toolbar.mjs.map +1 -1
- package/fesm2022/neural-ui-core-tree-select.mjs +259 -0
- package/fesm2022/neural-ui-core-tree-select.mjs.map +1 -0
- package/fesm2022/neural-ui-core-tree-table.mjs +267 -8
- package/fesm2022/neural-ui-core-tree-table.mjs.map +1 -1
- package/fesm2022/neural-ui-core-tree.mjs +15 -14
- package/fesm2022/neural-ui-core-tree.mjs.map +1 -1
- package/fesm2022/neural-ui-core-uploader.mjs +103 -12
- package/fesm2022/neural-ui-core-uploader.mjs.map +1 -1
- package/form-field/package.json +4 -0
- package/inline-editor/package.json +4 -0
- package/input-mask/package.json +4 -0
- package/listbox/package.json +4 -0
- package/menu/package.json +4 -0
- package/package.json +53 -1
- package/panel/package.json +4 -0
- package/password/package.json +4 -0
- package/pick-list/package.json +4 -0
- package/styles/_tokens.scss +33 -17
- package/tags/package.json +4 -0
- package/tree-select/package.json +4 -0
- package/types/neural-ui-core-alert.d.ts +2 -1
- package/types/neural-ui-core-autocomplete.d.ts +22 -2
- package/types/neural-ui-core-bottom-sheet.d.ts +20 -0
- package/types/neural-ui-core-checkbox.d.ts +6 -1
- package/types/neural-ui-core-confirm-popup.d.ts +38 -0
- package/types/neural-ui-core-dashboard-grid.d.ts +1 -0
- package/types/neural-ui-core-data-view.d.ts +95 -0
- package/types/neural-ui-core-date-input.d.ts +35 -5
- package/types/neural-ui-core-empty-state.d.ts +11 -1
- package/types/neural-ui-core-form-field.d.ts +33 -0
- package/types/neural-ui-core-inline-editor.d.ts +66 -0
- package/types/neural-ui-core-input-mask.d.ts +26 -0
- package/types/neural-ui-core-listbox.d.ts +54 -0
- package/types/neural-ui-core-menu.d.ts +49 -0
- package/types/neural-ui-core-modal.d.ts +10 -2
- package/types/neural-ui-core-multiselect.d.ts +10 -1
- package/types/neural-ui-core-panel.d.ts +25 -0
- package/types/neural-ui-core-password.d.ts +29 -0
- package/types/neural-ui-core-pick-list.d.ts +40 -0
- package/types/neural-ui-core-select.d.ts +7 -1
- package/types/neural-ui-core-sidebar.d.ts +5 -1
- package/types/neural-ui-core-spinner.d.ts +4 -2
- package/types/neural-ui-core-table.d.ts +89 -5
- package/types/neural-ui-core-tabs.d.ts +2 -0
- package/types/neural-ui-core-tags.d.ts +32 -0
- package/types/neural-ui-core-toolbar.d.ts +8 -2
- package/types/neural-ui-core-tree-select.d.ts +57 -0
- package/types/neural-ui-core-tree-table.d.ts +111 -4
- package/types/neural-ui-core-tree.d.ts +1 -1
- package/types/neural-ui-core-uploader.d.ts +26 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neural-ui-core-form-field.mjs","sources":["../../../../projects/ui-core/form-field/neu-form-field.component.ts","../../../../projects/ui-core/form-field/neural-ui-core-form-field.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, ViewEncapsulation, computed, input } from '@angular/core';\n\nexport type NeuFormFieldSize = 'sm' | 'md' | 'lg';\n\n@Component({\n selector: 'neu-form-field',\n imports: [],\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { '[class]': 'classes()' },\n template: `\n @if (label()) {\n <label class=\"neu-form-field__label\" [attr.for]=\"forId() || null\">{{ label() }}</label>\n }\n <div class=\"neu-form-field__control\">\n @if (prefix()) {\n <span class=\"neu-form-field__prefix\">{{ prefix() }}</span>\n }\n <ng-content />\n @if (suffix()) {\n <span class=\"neu-form-field__suffix\">{{ suffix() }}</span>\n }\n </div>\n @if (error()) {\n <p class=\"neu-form-field__error\" role=\"alert\">{{ error() }}</p>\n } @else if (hint()) {\n <p class=\"neu-form-field__hint\">{{ hint() }}</p>\n }\n `,\n styleUrl: './neu-form-field.component.scss',\n})\nexport class NeuFormFieldComponent {\n readonly label = input('');\n readonly hint = input('');\n readonly error = input('');\n readonly prefix = input('');\n readonly suffix = input('');\n readonly forId = input('');\n readonly size = input<NeuFormFieldSize>('md');\n\n readonly classes = computed(() => ({\n 'neu-form-field': true,\n [`neu-form-field--${this.size()}`]: true,\n 'neu-form-field--error': !!this.error(),\n }));\n}\n\n@Component({\n selector: 'neu-input-group',\n imports: [],\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { '[class]': 'classes()' },\n template: `<ng-content />`,\n styleUrl: './neu-form-field.component.scss',\n})\nexport class NeuInputGroupComponent {\n readonly size = input<NeuFormFieldSize>('md');\n readonly attached = input(true);\n readonly classes = computed(() => ({\n 'neu-input-group': true,\n [`neu-input-group--${this.size()}`]: true,\n 'neu-input-group--attached': this.attached(),\n }));\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;MA+Ba,qBAAqB,CAAA;AACvB,IAAA,KAAK,GAAG,KAAK,CAAC,EAAE,4EAAC;AACjB,IAAA,IAAI,GAAG,KAAK,CAAC,EAAE,2EAAC;AAChB,IAAA,KAAK,GAAG,KAAK,CAAC,EAAE,4EAAC;AACjB,IAAA,MAAM,GAAG,KAAK,CAAC,EAAE,6EAAC;AAClB,IAAA,MAAM,GAAG,KAAK,CAAC,EAAE,6EAAC;AAClB,IAAA,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AA,OAAO,GAAG,QAAQ,CAAC,OAAO;AACjC,QAAA,iBAAiB,EAAE,IAAI;QACvB,CAAC,CAAA,iBAAA,EAAoB,IAAI,CAAC,IAAI,EAAE,CAAA,CAAE,GAAG,IAAI;AACzC,QAAA,2BAA2B,EAAE,IAAI,CAAC,QAAQ,EAAE;AAC7C,KAAA,CAAC,8EAAC;wGAPQ,sBAAsB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAtB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,sBAAsB,6XAHvB,CAAA,cAAA,CAAgB,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,6xBAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;4FAGf,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBATlC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,iBAAiB,WAClB,EAAE,EAAA,aAAA,EACI,iBAAiB,CAAC,IAAI,EAAA,eAAA,EACpB,uBAAuB,CAAC,MAAM,QACzC,EAAE,SAAS,EAAE,WAAW,EAAE,YACtB,CAAA,cAAA,CAAgB,EAAA,MAAA,EAAA,CAAA,6xBAAA,CAAA,EAAA;;;ACrD5B;;AAEG;;;;"}
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, ElementRef, input, output, signal, computed, effect, forwardRef, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/forms';
|
|
4
|
+
import { FormControl, ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
5
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
|
+
import { NeuButtonComponent } from '@neural-ui/core/button';
|
|
7
|
+
import { NeuIconComponent } from '@neural-ui/core/icon';
|
|
8
|
+
import { NeuInputComponent } from '@neural-ui/core/input';
|
|
9
|
+
import { NeuDateInputComponent } from '@neural-ui/core/date-input';
|
|
10
|
+
import { NeuNumberInputComponent } from '@neural-ui/core/number-input';
|
|
11
|
+
import { NeuSelectComponent } from '@neural-ui/core/select';
|
|
12
|
+
import { NeuTextareaComponent } from '@neural-ui/core/textarea';
|
|
13
|
+
|
|
14
|
+
class NeuInlineEditorComponent {
|
|
15
|
+
_host = inject((ElementRef));
|
|
16
|
+
value = input(null, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
17
|
+
type = input('text', ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
18
|
+
size = input('sm', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
19
|
+
options = input([], ...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
20
|
+
placeholder = input('', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
21
|
+
emptyLabel = input('Empty', ...(ngDevMode ? [{ debugName: "emptyLabel" }] : /* istanbul ignore next */ []));
|
|
22
|
+
editLabel = input('Edit value', ...(ngDevMode ? [{ debugName: "editLabel" }] : /* istanbul ignore next */ []));
|
|
23
|
+
saveLabel = input('Save value', ...(ngDevMode ? [{ debugName: "saveLabel" }] : /* istanbul ignore next */ []));
|
|
24
|
+
cancelLabel = input('Cancel edit', ...(ngDevMode ? [{ debugName: "cancelLabel" }] : /* istanbul ignore next */ []));
|
|
25
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
26
|
+
readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
|
|
27
|
+
startInEdit = input(false, ...(ngDevMode ? [{ debugName: "startInEdit" }] : /* istanbul ignore next */ []));
|
|
28
|
+
saveOnBlur = input(false, ...(ngDevMode ? [{ debugName: "saveOnBlur" }] : /* istanbul ignore next */ []));
|
|
29
|
+
min = input(-Infinity, ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
|
|
30
|
+
max = input(Infinity, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
31
|
+
step = input(1, ...(ngDevMode ? [{ debugName: "step" }] : /* istanbul ignore next */ []));
|
|
32
|
+
rows = input(3, ...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
|
|
33
|
+
valueChange = output();
|
|
34
|
+
editStart = output();
|
|
35
|
+
editCancel = output();
|
|
36
|
+
editCommit = output();
|
|
37
|
+
stringControl = new FormControl(null);
|
|
38
|
+
numberControl = new FormControl(0, { nonNullable: true });
|
|
39
|
+
editing = signal(false, ...(ngDevMode ? [{ debugName: "editing" }] : /* istanbul ignore next */ []));
|
|
40
|
+
_value = signal(null, ...(ngDevMode ? [{ debugName: "_value" }] : /* istanbul ignore next */ []));
|
|
41
|
+
_snapshot = signal(null, ...(ngDevMode ? [{ debugName: "_snapshot" }] : /* istanbul ignore next */ []));
|
|
42
|
+
_cvaDisabled = signal(false, ...(ngDevMode ? [{ debugName: "_cvaDisabled" }] : /* istanbul ignore next */ []));
|
|
43
|
+
_onChange = () => { };
|
|
44
|
+
_onTouched = () => { };
|
|
45
|
+
isDisabled = computed(() => this.disabled() || this._cvaDisabled(), ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
|
|
46
|
+
isEmpty = computed(() => {
|
|
47
|
+
const value = this._value();
|
|
48
|
+
return value === null || value === undefined || value === '';
|
|
49
|
+
}, ...(ngDevMode ? [{ debugName: "isEmpty" }] : /* istanbul ignore next */ []));
|
|
50
|
+
displayValue = computed(() => {
|
|
51
|
+
if (this.isEmpty())
|
|
52
|
+
return this.emptyLabel();
|
|
53
|
+
const current = this._value();
|
|
54
|
+
if (this.type() === 'select') {
|
|
55
|
+
return this.options().find((option) => option.value === current)?.label ?? String(current);
|
|
56
|
+
}
|
|
57
|
+
return String(current);
|
|
58
|
+
}, ...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
|
|
59
|
+
constructor() {
|
|
60
|
+
effect(() => {
|
|
61
|
+
this._setValue(this.value(), false);
|
|
62
|
+
});
|
|
63
|
+
effect(() => {
|
|
64
|
+
if (this.startInEdit() && !this.editing()) {
|
|
65
|
+
this.beginEdit();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
this.stringControl.valueChanges.pipe(takeUntilDestroyed()).subscribe((value) => {
|
|
69
|
+
if (this.type() !== 'number') {
|
|
70
|
+
this._value.set(value);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
this.numberControl.valueChanges.pipe(takeUntilDestroyed()).subscribe((value) => {
|
|
74
|
+
if (this.type() === 'number') {
|
|
75
|
+
this._value.set(Number.isFinite(value) ? value : null);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
writeValue(value) {
|
|
80
|
+
this._setValue(value, false);
|
|
81
|
+
}
|
|
82
|
+
registerOnChange(fn) {
|
|
83
|
+
this._onChange = fn;
|
|
84
|
+
}
|
|
85
|
+
registerOnTouched(fn) {
|
|
86
|
+
this._onTouched = fn;
|
|
87
|
+
}
|
|
88
|
+
setDisabledState(isDisabled) {
|
|
89
|
+
this._cvaDisabled.set(isDisabled);
|
|
90
|
+
this._syncDisabledState();
|
|
91
|
+
}
|
|
92
|
+
beginEdit() {
|
|
93
|
+
if (this.isDisabled() || this.readonly())
|
|
94
|
+
return;
|
|
95
|
+
this._snapshot.set(this._value());
|
|
96
|
+
this._syncControls(this._value());
|
|
97
|
+
this.editing.set(true);
|
|
98
|
+
this.editStart.emit(this._value());
|
|
99
|
+
queueMicrotask(() => this._focusFirstControl());
|
|
100
|
+
}
|
|
101
|
+
commit() {
|
|
102
|
+
if (this.isDisabled())
|
|
103
|
+
return;
|
|
104
|
+
const previousValue = this._snapshot();
|
|
105
|
+
const value = this.type() === 'number' ? this.numberControl.value : this.stringControl.value;
|
|
106
|
+
const normalized = this._normalizeValue(value);
|
|
107
|
+
this._setValue(normalized, true);
|
|
108
|
+
this.editing.set(false);
|
|
109
|
+
this._onTouched();
|
|
110
|
+
this.editCommit.emit({ previousValue, value: normalized });
|
|
111
|
+
}
|
|
112
|
+
cancel() {
|
|
113
|
+
const previousValue = this._snapshot();
|
|
114
|
+
this._setValue(previousValue, false);
|
|
115
|
+
this.editing.set(false);
|
|
116
|
+
this._onTouched();
|
|
117
|
+
this.editCancel.emit(previousValue);
|
|
118
|
+
}
|
|
119
|
+
onEditKeydown(event) {
|
|
120
|
+
if (event.key === 'Escape') {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
this.cancel();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (event.key === 'Enter' && this.type() !== 'textarea') {
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
this.commit();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
onEditFocusout(event) {
|
|
131
|
+
if (!this.saveOnBlur() || !this.editing())
|
|
132
|
+
return;
|
|
133
|
+
const nextTarget = event.relatedTarget;
|
|
134
|
+
if (nextTarget && this._host.nativeElement.contains(nextTarget))
|
|
135
|
+
return;
|
|
136
|
+
queueMicrotask(() => {
|
|
137
|
+
if (this.editing()) {
|
|
138
|
+
this.commit();
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
hostClasses() {
|
|
143
|
+
return {
|
|
144
|
+
'neu-inline-editor': true,
|
|
145
|
+
[`neu-inline-editor--${this.size()}`]: true,
|
|
146
|
+
'neu-inline-editor--editing': this.editing(),
|
|
147
|
+
'neu-inline-editor--disabled': this.isDisabled(),
|
|
148
|
+
'neu-inline-editor--readonly': this.readonly(),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
_setValue(value, emit) {
|
|
152
|
+
const normalized = this._normalizeValue(value);
|
|
153
|
+
this._value.set(normalized);
|
|
154
|
+
this._syncControls(normalized);
|
|
155
|
+
if (emit) {
|
|
156
|
+
this.valueChange.emit(normalized);
|
|
157
|
+
this._onChange(normalized);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
_normalizeValue(value) {
|
|
161
|
+
if (value === undefined)
|
|
162
|
+
return null;
|
|
163
|
+
if (this.type() === 'number') {
|
|
164
|
+
const next = typeof value === 'number' ? value : Number(value);
|
|
165
|
+
return Number.isFinite(next) ? next : null;
|
|
166
|
+
}
|
|
167
|
+
return value === null ? null : String(value);
|
|
168
|
+
}
|
|
169
|
+
_syncControls(value) {
|
|
170
|
+
this.stringControl.setValue(value === null ? null : String(value), { emitEvent: false });
|
|
171
|
+
this.numberControl.setValue(typeof value === 'number' ? value : Number(value ?? 0), {
|
|
172
|
+
emitEvent: false,
|
|
173
|
+
});
|
|
174
|
+
this._syncDisabledState();
|
|
175
|
+
}
|
|
176
|
+
_syncDisabledState() {
|
|
177
|
+
const method = this.isDisabled() ? 'disable' : 'enable';
|
|
178
|
+
this.stringControl[method]({ emitEvent: false });
|
|
179
|
+
this.numberControl[method]({ emitEvent: false });
|
|
180
|
+
}
|
|
181
|
+
_focusFirstControl() {
|
|
182
|
+
const control = this._host.nativeElement.querySelector('.neu-input__field, .neu-number-input__field, .neu-select__trigger, .neu-textarea__field');
|
|
183
|
+
control?.focus();
|
|
184
|
+
}
|
|
185
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.17", ngImport: i0, type: NeuInlineEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
186
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.17", type: NeuInlineEditorComponent, isStandalone: true, selector: "neu-inline-editor", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, emptyLabel: { classPropertyName: "emptyLabel", publicName: "emptyLabel", isSignal: true, isRequired: false, transformFunction: null }, editLabel: { classPropertyName: "editLabel", publicName: "editLabel", isSignal: true, isRequired: false, transformFunction: null }, saveLabel: { classPropertyName: "saveLabel", publicName: "saveLabel", isSignal: true, isRequired: false, transformFunction: null }, cancelLabel: { classPropertyName: "cancelLabel", publicName: "cancelLabel", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, startInEdit: { classPropertyName: "startInEdit", publicName: "startInEdit", isSignal: true, isRequired: false, transformFunction: null }, saveOnBlur: { classPropertyName: "saveOnBlur", publicName: "saveOnBlur", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", editStart: "editStart", editCancel: "editCancel", editCommit: "editCommit" }, host: { properties: { "class": "hostClasses()", "attr.aria-disabled": "isDisabled()" } }, providers: [
|
|
187
|
+
{
|
|
188
|
+
provide: NG_VALUE_ACCESSOR,
|
|
189
|
+
useExisting: forwardRef(() => NeuInlineEditorComponent),
|
|
190
|
+
multi: true,
|
|
191
|
+
},
|
|
192
|
+
], ngImport: i0, template: `
|
|
193
|
+
@if (editing()) {
|
|
194
|
+
<div
|
|
195
|
+
class="neu-inline-editor__edit"
|
|
196
|
+
(keydown)="onEditKeydown($event)"
|
|
197
|
+
(focusout)="onEditFocusout($event)"
|
|
198
|
+
>
|
|
199
|
+
@switch (type()) {
|
|
200
|
+
@case ('select') {
|
|
201
|
+
<neu-select
|
|
202
|
+
class="neu-inline-editor__control"
|
|
203
|
+
[options]="options()"
|
|
204
|
+
[formControl]="stringControl"
|
|
205
|
+
[size]="size()"
|
|
206
|
+
[floatingLabel]="false"
|
|
207
|
+
[placeholder]="placeholder()"
|
|
208
|
+
[disabled]="isDisabled()"
|
|
209
|
+
/>
|
|
210
|
+
}
|
|
211
|
+
@case ('number') {
|
|
212
|
+
<neu-number-input
|
|
213
|
+
class="neu-inline-editor__control"
|
|
214
|
+
[formControl]="numberControl"
|
|
215
|
+
[size]="size()"
|
|
216
|
+
[min]="min()"
|
|
217
|
+
[max]="max()"
|
|
218
|
+
[step]="step()"
|
|
219
|
+
/>
|
|
220
|
+
}
|
|
221
|
+
@case ('textarea') {
|
|
222
|
+
<neu-textarea
|
|
223
|
+
class="neu-inline-editor__control"
|
|
224
|
+
[formControl]="stringControl"
|
|
225
|
+
[size]="size()"
|
|
226
|
+
[label]="placeholder()"
|
|
227
|
+
[disabled]="isDisabled()"
|
|
228
|
+
[rows]="rows()"
|
|
229
|
+
/>
|
|
230
|
+
}
|
|
231
|
+
@case ('date') {
|
|
232
|
+
<neu-date-input
|
|
233
|
+
class="neu-inline-editor__control"
|
|
234
|
+
[formControl]="stringControl"
|
|
235
|
+
[size]="size()"
|
|
236
|
+
[placeholder]="placeholder()"
|
|
237
|
+
[disabled]="isDisabled()"
|
|
238
|
+
/>
|
|
239
|
+
}
|
|
240
|
+
@default {
|
|
241
|
+
<neu-input
|
|
242
|
+
class="neu-inline-editor__control"
|
|
243
|
+
[formControl]="stringControl"
|
|
244
|
+
[size]="size()"
|
|
245
|
+
[floatingLabel]="false"
|
|
246
|
+
[placeholder]="placeholder()"
|
|
247
|
+
[disabled]="isDisabled()"
|
|
248
|
+
/>
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
<div class="neu-inline-editor__actions">
|
|
253
|
+
<button
|
|
254
|
+
neu-button
|
|
255
|
+
type="button"
|
|
256
|
+
variant="primary"
|
|
257
|
+
[size]="size()"
|
|
258
|
+
icon="lucideCheck"
|
|
259
|
+
[iconOnly]="true"
|
|
260
|
+
[ariaLabel]="saveLabel()"
|
|
261
|
+
[disabled]="isDisabled()"
|
|
262
|
+
(click)="commit()"
|
|
263
|
+
></button>
|
|
264
|
+
<button
|
|
265
|
+
neu-button
|
|
266
|
+
type="button"
|
|
267
|
+
variant="ghost"
|
|
268
|
+
[size]="size()"
|
|
269
|
+
icon="lucideX"
|
|
270
|
+
[iconOnly]="true"
|
|
271
|
+
[ariaLabel]="cancelLabel()"
|
|
272
|
+
(click)="cancel()"
|
|
273
|
+
></button>
|
|
274
|
+
</div>
|
|
275
|
+
</div>
|
|
276
|
+
} @else {
|
|
277
|
+
<button
|
|
278
|
+
neu-button
|
|
279
|
+
class="neu-inline-editor__display"
|
|
280
|
+
type="button"
|
|
281
|
+
variant="ghost"
|
|
282
|
+
[size]="size()"
|
|
283
|
+
[disabled]="isDisabled() || readonly()"
|
|
284
|
+
[attr.aria-label]="editLabel()"
|
|
285
|
+
(click)="beginEdit()"
|
|
286
|
+
>
|
|
287
|
+
<span class="neu-inline-editor__value" [class.neu-inline-editor__value--empty]="isEmpty()">
|
|
288
|
+
{{ displayValue() }}
|
|
289
|
+
</span>
|
|
290
|
+
@if (!readonly()) {
|
|
291
|
+
<neu-icon name="lucidePencil" size="14px" aria-hidden="true" />
|
|
292
|
+
}
|
|
293
|
+
</button>
|
|
294
|
+
}
|
|
295
|
+
`, isInline: true, styles: [".neu-inline-editor{display:inline-flex;min-width:0;max-width:100%;vertical-align:middle}.neu-inline-editor__display{display:inline-flex;align-items:center;gap:var(--neu-space-2, .5rem);min-width:0;max-width:100%;padding:0;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer;border-radius:var(--neu-radius-sm, 6px)}.neu-inline-editor__display:focus-visible{outline:none;box-shadow:var(--neu-focus-ring, 0 0 0 3px rgba(14, 165, 233, .2))}.neu-inline-editor__display:disabled{cursor:not-allowed;opacity:.6}.neu-inline-editor__value{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.neu-inline-editor__value--empty{color:var(--neu-text-muted, #64748b);font-style:italic}.neu-inline-editor__edit{display:inline-flex;align-items:center;gap:var(--neu-space-2, .5rem);min-width:min(100%,260px);max-width:100%}.neu-inline-editor__control{flex:1 1 auto;min-width:8rem}.neu-inline-editor__actions{display:inline-flex;align-items:center;gap:var(--neu-space-1, .25rem);flex:0 0 auto}.neu-inline-editor--sm .neu-inline-editor__edit{min-width:min(100%,220px)}.neu-inline-editor--lg .neu-inline-editor__edit{min-width:min(100%,320px)}@media(max-width:480px){.neu-inline-editor{width:100%}.neu-inline-editor__edit{width:100%;flex-wrap:wrap}.neu-inline-editor__control{flex-basis:100%}}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: NeuButtonComponent, selector: "button[neu-button]", inputs: ["variant", "size", "disabled", "loading", "fullWidth", "icon", "iconPosition", "iconOnly", "ariaLabel"], outputs: ["neuClick"] }, { kind: "component", type: NeuIconComponent, selector: "neu-icon", inputs: ["name", "strokeWidth", "size"] }, { kind: "component", type: NeuInputComponent, selector: "neu-input", inputs: ["type", "label", "placeholder", "floatingLabel", "size", "hint", "errorMessage", "disabled", "autocomplete", "startIcon", "endIcon", "icon", "iconPosition", "inputId", "name", "required", "readonly", "maxlength", "minlength", "min", "max", "pattern"] }, { kind: "component", type: NeuDateInputComponent, selector: "neu-date-input", inputs: ["type", "label", "hint", "errorMessage", "disabled", "size", "readonly", "name", "inputId", "required", "min", "max", "step", "locale", "disabledDates", "multiple", "showMonthYearPicker", "yearRange", "placeholder", "dateFormat", "floatingLabel", "presets"], outputs: ["rangeChange"] }, { kind: "component", type: NeuNumberInputComponent, selector: "neu-number-input", inputs: ["min", "max", "step", "label", "floatingLabel", "decrementLabel", "incrementLabel", "vertical", "stacked", "size"], outputs: ["valueChange"] }, { kind: "component", type: NeuSelectComponent, selector: "neu-select", inputs: ["options", "label", "placeholder", "errorMessage", "hint", "disabled", "floatingLabel", "size", "searchable", "searchPlaceholder", "loading", "loadingLabel", "clearable", "virtualScroll", "virtualScrollVisibleItems", "noResultsMessage", "clearAriaLabel", "urlParam"], outputs: ["selectionChange"] }, { kind: "component", type: NeuTextareaComponent, selector: "neu-textarea", inputs: ["label", "rows", "size", "autoResize", "resizable", "errorMessage", "hint", "disabled", "readonly", "required", "name", "maxlength"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
296
|
+
}
|
|
297
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImport: i0, type: NeuInlineEditorComponent, decorators: [{
|
|
298
|
+
type: Component,
|
|
299
|
+
args: [{ selector: 'neu-inline-editor', imports: [
|
|
300
|
+
ReactiveFormsModule,
|
|
301
|
+
NeuButtonComponent,
|
|
302
|
+
NeuIconComponent,
|
|
303
|
+
NeuInputComponent,
|
|
304
|
+
NeuDateInputComponent,
|
|
305
|
+
NeuNumberInputComponent,
|
|
306
|
+
NeuSelectComponent,
|
|
307
|
+
NeuTextareaComponent,
|
|
308
|
+
], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
309
|
+
{
|
|
310
|
+
provide: NG_VALUE_ACCESSOR,
|
|
311
|
+
useExisting: forwardRef(() => NeuInlineEditorComponent),
|
|
312
|
+
multi: true,
|
|
313
|
+
},
|
|
314
|
+
], host: {
|
|
315
|
+
'[class]': 'hostClasses()',
|
|
316
|
+
'[attr.aria-disabled]': 'isDisabled()',
|
|
317
|
+
}, template: `
|
|
318
|
+
@if (editing()) {
|
|
319
|
+
<div
|
|
320
|
+
class="neu-inline-editor__edit"
|
|
321
|
+
(keydown)="onEditKeydown($event)"
|
|
322
|
+
(focusout)="onEditFocusout($event)"
|
|
323
|
+
>
|
|
324
|
+
@switch (type()) {
|
|
325
|
+
@case ('select') {
|
|
326
|
+
<neu-select
|
|
327
|
+
class="neu-inline-editor__control"
|
|
328
|
+
[options]="options()"
|
|
329
|
+
[formControl]="stringControl"
|
|
330
|
+
[size]="size()"
|
|
331
|
+
[floatingLabel]="false"
|
|
332
|
+
[placeholder]="placeholder()"
|
|
333
|
+
[disabled]="isDisabled()"
|
|
334
|
+
/>
|
|
335
|
+
}
|
|
336
|
+
@case ('number') {
|
|
337
|
+
<neu-number-input
|
|
338
|
+
class="neu-inline-editor__control"
|
|
339
|
+
[formControl]="numberControl"
|
|
340
|
+
[size]="size()"
|
|
341
|
+
[min]="min()"
|
|
342
|
+
[max]="max()"
|
|
343
|
+
[step]="step()"
|
|
344
|
+
/>
|
|
345
|
+
}
|
|
346
|
+
@case ('textarea') {
|
|
347
|
+
<neu-textarea
|
|
348
|
+
class="neu-inline-editor__control"
|
|
349
|
+
[formControl]="stringControl"
|
|
350
|
+
[size]="size()"
|
|
351
|
+
[label]="placeholder()"
|
|
352
|
+
[disabled]="isDisabled()"
|
|
353
|
+
[rows]="rows()"
|
|
354
|
+
/>
|
|
355
|
+
}
|
|
356
|
+
@case ('date') {
|
|
357
|
+
<neu-date-input
|
|
358
|
+
class="neu-inline-editor__control"
|
|
359
|
+
[formControl]="stringControl"
|
|
360
|
+
[size]="size()"
|
|
361
|
+
[placeholder]="placeholder()"
|
|
362
|
+
[disabled]="isDisabled()"
|
|
363
|
+
/>
|
|
364
|
+
}
|
|
365
|
+
@default {
|
|
366
|
+
<neu-input
|
|
367
|
+
class="neu-inline-editor__control"
|
|
368
|
+
[formControl]="stringControl"
|
|
369
|
+
[size]="size()"
|
|
370
|
+
[floatingLabel]="false"
|
|
371
|
+
[placeholder]="placeholder()"
|
|
372
|
+
[disabled]="isDisabled()"
|
|
373
|
+
/>
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
<div class="neu-inline-editor__actions">
|
|
378
|
+
<button
|
|
379
|
+
neu-button
|
|
380
|
+
type="button"
|
|
381
|
+
variant="primary"
|
|
382
|
+
[size]="size()"
|
|
383
|
+
icon="lucideCheck"
|
|
384
|
+
[iconOnly]="true"
|
|
385
|
+
[ariaLabel]="saveLabel()"
|
|
386
|
+
[disabled]="isDisabled()"
|
|
387
|
+
(click)="commit()"
|
|
388
|
+
></button>
|
|
389
|
+
<button
|
|
390
|
+
neu-button
|
|
391
|
+
type="button"
|
|
392
|
+
variant="ghost"
|
|
393
|
+
[size]="size()"
|
|
394
|
+
icon="lucideX"
|
|
395
|
+
[iconOnly]="true"
|
|
396
|
+
[ariaLabel]="cancelLabel()"
|
|
397
|
+
(click)="cancel()"
|
|
398
|
+
></button>
|
|
399
|
+
</div>
|
|
400
|
+
</div>
|
|
401
|
+
} @else {
|
|
402
|
+
<button
|
|
403
|
+
neu-button
|
|
404
|
+
class="neu-inline-editor__display"
|
|
405
|
+
type="button"
|
|
406
|
+
variant="ghost"
|
|
407
|
+
[size]="size()"
|
|
408
|
+
[disabled]="isDisabled() || readonly()"
|
|
409
|
+
[attr.aria-label]="editLabel()"
|
|
410
|
+
(click)="beginEdit()"
|
|
411
|
+
>
|
|
412
|
+
<span class="neu-inline-editor__value" [class.neu-inline-editor__value--empty]="isEmpty()">
|
|
413
|
+
{{ displayValue() }}
|
|
414
|
+
</span>
|
|
415
|
+
@if (!readonly()) {
|
|
416
|
+
<neu-icon name="lucidePencil" size="14px" aria-hidden="true" />
|
|
417
|
+
}
|
|
418
|
+
</button>
|
|
419
|
+
}
|
|
420
|
+
`, styles: [".neu-inline-editor{display:inline-flex;min-width:0;max-width:100%;vertical-align:middle}.neu-inline-editor__display{display:inline-flex;align-items:center;gap:var(--neu-space-2, .5rem);min-width:0;max-width:100%;padding:0;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer;border-radius:var(--neu-radius-sm, 6px)}.neu-inline-editor__display:focus-visible{outline:none;box-shadow:var(--neu-focus-ring, 0 0 0 3px rgba(14, 165, 233, .2))}.neu-inline-editor__display:disabled{cursor:not-allowed;opacity:.6}.neu-inline-editor__value{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.neu-inline-editor__value--empty{color:var(--neu-text-muted, #64748b);font-style:italic}.neu-inline-editor__edit{display:inline-flex;align-items:center;gap:var(--neu-space-2, .5rem);min-width:min(100%,260px);max-width:100%}.neu-inline-editor__control{flex:1 1 auto;min-width:8rem}.neu-inline-editor__actions{display:inline-flex;align-items:center;gap:var(--neu-space-1, .25rem);flex:0 0 auto}.neu-inline-editor--sm .neu-inline-editor__edit{min-width:min(100%,220px)}.neu-inline-editor--lg .neu-inline-editor__edit{min-width:min(100%,320px)}@media(max-width:480px){.neu-inline-editor{width:100%}.neu-inline-editor__edit{width:100%;flex-wrap:wrap}.neu-inline-editor__control{flex-basis:100%}}\n"] }]
|
|
421
|
+
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], emptyLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyLabel", required: false }] }], editLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "editLabel", required: false }] }], saveLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "saveLabel", required: false }] }], cancelLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "cancelLabel", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], startInEdit: [{ type: i0.Input, args: [{ isSignal: true, alias: "startInEdit", required: false }] }], saveOnBlur: [{ type: i0.Input, args: [{ isSignal: true, alias: "saveOnBlur", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], editStart: [{ type: i0.Output, args: ["editStart"] }], editCancel: [{ type: i0.Output, args: ["editCancel"] }], editCommit: [{ type: i0.Output, args: ["editCommit"] }] } });
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Generated bundle index. Do not edit.
|
|
425
|
+
*/
|
|
426
|
+
|
|
427
|
+
export { NeuInlineEditorComponent };
|
|
428
|
+
//# sourceMappingURL=neural-ui-core-inline-editor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neural-ui-core-inline-editor.mjs","sources":["../../../../projects/ui-core/inline-editor/neu-inline-editor.component.ts","../../../../projects/ui-core/inline-editor/neural-ui-core-inline-editor.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n ViewEncapsulation,\n computed,\n effect,\n forwardRef,\n inject,\n input,\n output,\n signal,\n viewChild,\n} from '@angular/core';\nimport { ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { NeuButtonComponent } from '@neural-ui/core/button';\nimport { NeuIconComponent } from '@neural-ui/core/icon';\nimport { NeuInputComponent } from '@neural-ui/core/input';\nimport { NeuDateInputComponent } from '@neural-ui/core/date-input';\nimport { NeuNumberInputComponent } from '@neural-ui/core/number-input';\nimport { NeuSelectComponent, NeuSelectOption } from '@neural-ui/core/select';\nimport { NeuTextareaComponent } from '@neural-ui/core/textarea';\n\nexport type NeuInlineEditorType = 'text' | 'number' | 'select' | 'textarea' | 'date';\nexport type NeuInlineEditorSize = 'sm' | 'md' | 'lg';\n\nexport interface NeuInlineEditorCommitEvent<T = string | number | null> {\n previousValue: T;\n value: T;\n}\n\n@Component({\n selector: 'neu-inline-editor',\n imports: [\n ReactiveFormsModule,\n NeuButtonComponent,\n NeuIconComponent,\n NeuInputComponent,\n NeuDateInputComponent,\n NeuNumberInputComponent,\n NeuSelectComponent,\n NeuTextareaComponent,\n ],\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => NeuInlineEditorComponent),\n multi: true,\n },\n ],\n host: {\n '[class]': 'hostClasses()',\n '[attr.aria-disabled]': 'isDisabled()',\n },\n template: `\n @if (editing()) {\n <div\n class=\"neu-inline-editor__edit\"\n (keydown)=\"onEditKeydown($event)\"\n (focusout)=\"onEditFocusout($event)\"\n >\n @switch (type()) {\n @case ('select') {\n <neu-select\n class=\"neu-inline-editor__control\"\n [options]=\"options()\"\n [formControl]=\"stringControl\"\n [size]=\"size()\"\n [floatingLabel]=\"false\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"isDisabled()\"\n />\n }\n @case ('number') {\n <neu-number-input\n class=\"neu-inline-editor__control\"\n [formControl]=\"numberControl\"\n [size]=\"size()\"\n [min]=\"min()\"\n [max]=\"max()\"\n [step]=\"step()\"\n />\n }\n @case ('textarea') {\n <neu-textarea\n class=\"neu-inline-editor__control\"\n [formControl]=\"stringControl\"\n [size]=\"size()\"\n [label]=\"placeholder()\"\n [disabled]=\"isDisabled()\"\n [rows]=\"rows()\"\n />\n }\n @case ('date') {\n <neu-date-input\n class=\"neu-inline-editor__control\"\n [formControl]=\"stringControl\"\n [size]=\"size()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"isDisabled()\"\n />\n }\n @default {\n <neu-input\n class=\"neu-inline-editor__control\"\n [formControl]=\"stringControl\"\n [size]=\"size()\"\n [floatingLabel]=\"false\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"isDisabled()\"\n />\n }\n }\n\n <div class=\"neu-inline-editor__actions\">\n <button\n neu-button\n type=\"button\"\n variant=\"primary\"\n [size]=\"size()\"\n icon=\"lucideCheck\"\n [iconOnly]=\"true\"\n [ariaLabel]=\"saveLabel()\"\n [disabled]=\"isDisabled()\"\n (click)=\"commit()\"\n ></button>\n <button\n neu-button\n type=\"button\"\n variant=\"ghost\"\n [size]=\"size()\"\n icon=\"lucideX\"\n [iconOnly]=\"true\"\n [ariaLabel]=\"cancelLabel()\"\n (click)=\"cancel()\"\n ></button>\n </div>\n </div>\n } @else {\n <button\n neu-button\n class=\"neu-inline-editor__display\"\n type=\"button\"\n variant=\"ghost\"\n [size]=\"size()\"\n [disabled]=\"isDisabled() || readonly()\"\n [attr.aria-label]=\"editLabel()\"\n (click)=\"beginEdit()\"\n >\n <span class=\"neu-inline-editor__value\" [class.neu-inline-editor__value--empty]=\"isEmpty()\">\n {{ displayValue() }}\n </span>\n @if (!readonly()) {\n <neu-icon name=\"lucidePencil\" size=\"14px\" aria-hidden=\"true\" />\n }\n </button>\n }\n `,\n styleUrl: './neu-inline-editor.component.scss',\n})\nexport class NeuInlineEditorComponent implements ControlValueAccessor {\n private readonly _host = inject(ElementRef<HTMLElement>);\n\n readonly value = input<string | number | null>(null);\n readonly type = input<NeuInlineEditorType>('text');\n readonly size = input<NeuInlineEditorSize>('sm');\n readonly options = input<NeuSelectOption[]>([]);\n readonly placeholder = input('');\n readonly emptyLabel = input('Empty');\n readonly editLabel = input('Edit value');\n readonly saveLabel = input('Save value');\n readonly cancelLabel = input('Cancel edit');\n readonly disabled = input(false);\n readonly readonly = input(false);\n readonly startInEdit = input(false);\n readonly saveOnBlur = input(false);\n readonly min = input(-Infinity);\n readonly max = input(Infinity);\n readonly step = input(1);\n readonly rows = input(3);\n\n readonly valueChange = output<string | number | null>();\n readonly editStart = output<string | number | null>();\n readonly editCancel = output<string | number | null>();\n readonly editCommit = output<NeuInlineEditorCommitEvent>();\n\n readonly stringControl = new FormControl<string | null>(null);\n readonly numberControl = new FormControl<number>(0, { nonNullable: true });\n readonly editing = signal(false);\n private readonly _value = signal<string | number | null>(null);\n private readonly _snapshot = signal<string | number | null>(null);\n private readonly _cvaDisabled = signal(false);\n private _onChange: (value: string | number | null) => void = () => {};\n private _onTouched: () => void = () => {};\n\n readonly isDisabled = computed(() => this.disabled() || this._cvaDisabled());\n readonly isEmpty = computed(() => {\n const value = this._value();\n return value === null || value === undefined || value === '';\n });\n readonly displayValue = computed(() => {\n if (this.isEmpty()) return this.emptyLabel();\n const current = this._value();\n if (this.type() === 'select') {\n return this.options().find((option) => option.value === current)?.label ?? String(current);\n }\n return String(current);\n });\n\n constructor() {\n effect(() => {\n this._setValue(this.value(), false);\n });\n\n effect(() => {\n if (this.startInEdit() && !this.editing()) {\n this.beginEdit();\n }\n });\n\n this.stringControl.valueChanges.pipe(takeUntilDestroyed()).subscribe((value) => {\n if (this.type() !== 'number') {\n this._value.set(value);\n }\n });\n this.numberControl.valueChanges.pipe(takeUntilDestroyed()).subscribe((value) => {\n if (this.type() === 'number') {\n this._value.set(Number.isFinite(value) ? value : null);\n }\n });\n }\n\n writeValue(value: string | number | null): void {\n this._setValue(value, false);\n }\n\n registerOnChange(fn: (value: string | number | null) => void): void {\n this._onChange = fn;\n }\n\n registerOnTouched(fn: () => void): void {\n this._onTouched = fn;\n }\n\n setDisabledState(isDisabled: boolean): void {\n this._cvaDisabled.set(isDisabled);\n this._syncDisabledState();\n }\n\n beginEdit(): void {\n if (this.isDisabled() || this.readonly()) return;\n this._snapshot.set(this._value());\n this._syncControls(this._value());\n this.editing.set(true);\n this.editStart.emit(this._value());\n queueMicrotask(() => this._focusFirstControl());\n }\n\n commit(): void {\n if (this.isDisabled()) return;\n const previousValue = this._snapshot();\n const value = this.type() === 'number' ? this.numberControl.value : this.stringControl.value;\n const normalized = this._normalizeValue(value);\n this._setValue(normalized, true);\n this.editing.set(false);\n this._onTouched();\n this.editCommit.emit({ previousValue, value: normalized });\n }\n\n cancel(): void {\n const previousValue = this._snapshot();\n this._setValue(previousValue, false);\n this.editing.set(false);\n this._onTouched();\n this.editCancel.emit(previousValue);\n }\n\n onEditKeydown(event: KeyboardEvent): void {\n if (event.key === 'Escape') {\n event.preventDefault();\n this.cancel();\n return;\n }\n if (event.key === 'Enter' && this.type() !== 'textarea') {\n event.preventDefault();\n this.commit();\n }\n }\n\n onEditFocusout(event: FocusEvent): void {\n if (!this.saveOnBlur() || !this.editing()) return;\n const nextTarget = event.relatedTarget as Node | null;\n if (nextTarget && this._host.nativeElement.contains(nextTarget)) return;\n queueMicrotask(() => {\n if (this.editing()) {\n this.commit();\n }\n });\n }\n\n hostClasses(): Record<string, boolean> {\n return {\n 'neu-inline-editor': true,\n [`neu-inline-editor--${this.size()}`]: true,\n 'neu-inline-editor--editing': this.editing(),\n 'neu-inline-editor--disabled': this.isDisabled(),\n 'neu-inline-editor--readonly': this.readonly(),\n };\n }\n\n private _setValue(value: string | number | null | undefined, emit: boolean): void {\n const normalized = this._normalizeValue(value);\n this._value.set(normalized);\n this._syncControls(normalized);\n if (emit) {\n this.valueChange.emit(normalized);\n this._onChange(normalized);\n }\n }\n\n private _normalizeValue(value: string | number | null | undefined): string | number | null {\n if (value === undefined) return null;\n if (this.type() === 'number') {\n const next = typeof value === 'number' ? value : Number(value);\n return Number.isFinite(next) ? next : null;\n }\n return value === null ? null : String(value);\n }\n\n private _syncControls(value: string | number | null): void {\n this.stringControl.setValue(value === null ? null : String(value), { emitEvent: false });\n this.numberControl.setValue(typeof value === 'number' ? value : Number(value ?? 0), {\n emitEvent: false,\n });\n this._syncDisabledState();\n }\n\n private _syncDisabledState(): void {\n const method = this.isDisabled() ? 'disable' : 'enable';\n this.stringControl[method]({ emitEvent: false });\n this.numberControl[method]({ emitEvent: false });\n }\n\n private _focusFirstControl(): void {\n const control = (this._host.nativeElement as HTMLElement).querySelector(\n '.neu-input__field, .neu-number-input__field, .neu-select__trigger, .neu-textarea__field',\n ) as HTMLElement | null;\n control?.focus();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;;;;;MAmKa,wBAAwB,CAAA;AAClB,IAAA,KAAK,GAAG,MAAM,EAAC,UAAuB,EAAC;AAE/C,IAAA,KAAK,GAAG,KAAK,CAAyB,IAAI,4EAAC;AAC3C,IAAA,IAAI,GAAG,KAAK,CAAsB,MAAM,2EAAC;AACzC,IAAA,IAAI,GAAG,KAAK,CAAsB,IAAI,2EAAC;AACvC,IAAA,OAAO,GAAG,KAAK,CAAoB,EAAE,8EAAC;AACtC,IAAA,WAAW,GAAG,KAAK,CAAC,EAAE,kFAAC;AACvB,IAAA,UAAU,GAAG,KAAK,CAAC,OAAO,iFAAC;AAC3B,IAAA,SAAS,GAAG,KAAK,CAAC,YAAY,gFAAC;AAC/B,IAAA,SAAS,GAAG,KAAK,CAAC,YAAY,gFAAC;AAC/B,IAAA,WAAW,GAAG,KAAK,CAAC,aAAa,kFAAC;AAClC,IAAA,QAAQ,GAAG,KAAK,CAAC,KAAK,+EAAC;AACvB,IAAA,QAAQ,GAAG,KAAK,CAAC,KAAK,+EAAC;AACvB,IAAA,WAAW,GAAG,KAAK,CAAC,KAAK,kFAAC;AAC1B,IAAA,UAAU,GAAG,KAAK,CAAC,KAAK,iFAAC;AACzB,IAAA,GAAG,GAAG,KAAK,CAAC,CAAC,QAAQ,0EAAC;AACtB,IAAA,GAAG,GAAG,KAAK,CAAC,QAAQ,0EAAC;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,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;4FAyHX,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBAnIpC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,mBAAmB,EAAA,OAAA,EACpB;wBACP,mBAAmB;wBACnB,kBAAkB;wBAClB,gBAAgB;wBAChB,iBAAiB;wBACjB,qBAAqB;wBACrB,uBAAuB;wBACvB,kBAAkB;wBAClB,oBAAoB;AACrB,qBAAA,EAAA,aAAA,EACc,iBAAiB,CAAC,IAAI,mBACpB,uBAAuB,CAAC,MAAM,EAAA,SAAA,EACpC;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,iBAAiB;AAC1B,4BAAA,WAAW,EAAE,UAAU,CAAC,8BAA8B,CAAC;AACvD,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;qBACF,EAAA,IAAA,EACK;AACJ,wBAAA,SAAS,EAAE,eAAe;AAC1B,wBAAA,sBAAsB,EAAE,cAAc;qBACvC,EAAA,QAAA,EACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuGT,EAAA,CAAA,EAAA,MAAA,EAAA,CAAA,mzCAAA,CAAA,EAAA;;;AChKH;;AAEG;;;;"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, output, signal, forwardRef, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
|
|
3
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
|
|
5
|
+
class NeuInputMaskComponent {
|
|
6
|
+
mask = input('', ...(ngDevMode ? [{ debugName: "mask" }] : /* istanbul ignore next */ []));
|
|
7
|
+
label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
8
|
+
placeholder = input('', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
9
|
+
hint = input('', ...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
10
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
11
|
+
valueChange = output();
|
|
12
|
+
inputId = `neu-input-mask-${Math.random().toString(36).slice(2)}`;
|
|
13
|
+
value = signal('', ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
14
|
+
cvaDisabled = signal(false, ...(ngDevMode ? [{ debugName: "cvaDisabled" }] : /* istanbul ignore next */ []));
|
|
15
|
+
onChange = () => { };
|
|
16
|
+
onTouched = () => { };
|
|
17
|
+
writeValue(value) {
|
|
18
|
+
this.value.set(value ?? '');
|
|
19
|
+
}
|
|
20
|
+
registerOnChange(fn) {
|
|
21
|
+
this.onChange = fn;
|
|
22
|
+
}
|
|
23
|
+
registerOnTouched(fn) {
|
|
24
|
+
this.onTouched = fn;
|
|
25
|
+
}
|
|
26
|
+
setDisabledState(isDisabled) {
|
|
27
|
+
this.cvaDisabled.set(isDisabled);
|
|
28
|
+
}
|
|
29
|
+
onInput(raw) {
|
|
30
|
+
const masked = this.applyMask(raw);
|
|
31
|
+
this.value.set(masked);
|
|
32
|
+
this.onChange(masked);
|
|
33
|
+
this.valueChange.emit(masked);
|
|
34
|
+
}
|
|
35
|
+
applyMask(raw) {
|
|
36
|
+
const mask = this.mask();
|
|
37
|
+
if (!mask) {
|
|
38
|
+
return raw;
|
|
39
|
+
}
|
|
40
|
+
const chars = raw.replace(/\W/g, '').split('');
|
|
41
|
+
let result = '';
|
|
42
|
+
for (const token of mask) {
|
|
43
|
+
const char = chars[0];
|
|
44
|
+
if (!char) {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
if (token === '9' && /\d/.test(char)) {
|
|
48
|
+
result += chars.shift();
|
|
49
|
+
}
|
|
50
|
+
else if (token === 'A' && /[a-z]/i.test(char)) {
|
|
51
|
+
result += chars.shift();
|
|
52
|
+
}
|
|
53
|
+
else if (token === '*' && /[a-z0-9]/i.test(char)) {
|
|
54
|
+
result += chars.shift();
|
|
55
|
+
}
|
|
56
|
+
else if (!['9', 'A', '*'].includes(token)) {
|
|
57
|
+
result += token;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
chars.shift();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.17", ngImport: i0, type: NeuInputMaskComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
66
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.17", type: NeuInputMaskComponent, isStandalone: true, selector: "neu-input-mask", inputs: { mask: { classPropertyName: "mask", publicName: "mask", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange" }, host: { classAttribute: "neu-input-mask" }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NeuInputMaskComponent), multi: true }], ngImport: i0, template: `
|
|
67
|
+
@if (label()) {
|
|
68
|
+
<label class="neu-input-mask__label" [for]="inputId">{{ label() }}</label>
|
|
69
|
+
}
|
|
70
|
+
<input
|
|
71
|
+
class="neu-input-mask__control"
|
|
72
|
+
[id]="inputId"
|
|
73
|
+
[placeholder]="placeholder()"
|
|
74
|
+
[value]="value()"
|
|
75
|
+
[disabled]="disabled() || cvaDisabled()"
|
|
76
|
+
(input)="onInput($any($event.target).value)"
|
|
77
|
+
(blur)="onTouched()"
|
|
78
|
+
/>
|
|
79
|
+
@if (hint()) {
|
|
80
|
+
<p class="neu-input-mask__hint">{{ hint() }}</p>
|
|
81
|
+
}
|
|
82
|
+
`, isInline: true, styles: [".neu-input-mask{display:grid;gap:.375rem}.neu-input-mask__label{font-size:.875rem;font-weight:600;color:var(--neu-text, #111827)}.neu-input-mask__control{min-height:2.5rem;border:1px solid var(--neu-border, #d1d5db);border-radius:.625rem;background:var(--neu-surface, #fff);color:var(--neu-text, #111827);padding:0 .75rem}.neu-input-mask__hint{color:var(--neu-text-muted, #6b7280);font-size:.8125rem}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
83
|
+
}
|
|
84
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImport: i0, type: NeuInputMaskComponent, decorators: [{
|
|
85
|
+
type: Component,
|
|
86
|
+
args: [{ selector: 'neu-input-mask', imports: [], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NeuInputMaskComponent), multi: true }], host: { class: 'neu-input-mask' }, template: `
|
|
87
|
+
@if (label()) {
|
|
88
|
+
<label class="neu-input-mask__label" [for]="inputId">{{ label() }}</label>
|
|
89
|
+
}
|
|
90
|
+
<input
|
|
91
|
+
class="neu-input-mask__control"
|
|
92
|
+
[id]="inputId"
|
|
93
|
+
[placeholder]="placeholder()"
|
|
94
|
+
[value]="value()"
|
|
95
|
+
[disabled]="disabled() || cvaDisabled()"
|
|
96
|
+
(input)="onInput($any($event.target).value)"
|
|
97
|
+
(blur)="onTouched()"
|
|
98
|
+
/>
|
|
99
|
+
@if (hint()) {
|
|
100
|
+
<p class="neu-input-mask__hint">{{ hint() }}</p>
|
|
101
|
+
}
|
|
102
|
+
`, styles: [".neu-input-mask{display:grid;gap:.375rem}.neu-input-mask__label{font-size:.875rem;font-weight:600;color:var(--neu-text, #111827)}.neu-input-mask__control{min-height:2.5rem;border:1px solid var(--neu-border, #d1d5db);border-radius:.625rem;background:var(--neu-surface, #fff);color:var(--neu-text, #111827);padding:0 .75rem}.neu-input-mask__hint{color:var(--neu-text-muted, #6b7280);font-size:.8125rem}\n"] }]
|
|
103
|
+
}], propDecorators: { mask: [{ type: i0.Input, args: [{ isSignal: true, alias: "mask", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }] } });
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Generated bundle index. Do not edit.
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
export { NeuInputMaskComponent };
|
|
110
|
+
//# sourceMappingURL=neural-ui-core-input-mask.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neural-ui-core-input-mask.mjs","sources":["../../../../projects/ui-core/input-mask/neu-input-mask.component.ts","../../../../projects/ui-core/input-mask/neural-ui-core-input-mask.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, ViewEncapsulation, forwardRef, input, output, signal } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\n\n@Component({\n selector: 'neu-input-mask',\n imports: [],\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NeuInputMaskComponent), multi: true }],\n host: { class: 'neu-input-mask' },\n template: `\n @if (label()) {\n <label class=\"neu-input-mask__label\" [for]=\"inputId\">{{ label() }}</label>\n }\n <input\n class=\"neu-input-mask__control\"\n [id]=\"inputId\"\n [placeholder]=\"placeholder()\"\n [value]=\"value()\"\n [disabled]=\"disabled() || cvaDisabled()\"\n (input)=\"onInput($any($event.target).value)\"\n (blur)=\"onTouched()\"\n />\n @if (hint()) {\n <p class=\"neu-input-mask__hint\">{{ hint() }}</p>\n }\n `,\n styleUrl: './neu-input-mask.component.scss',\n})\nexport class NeuInputMaskComponent implements ControlValueAccessor {\n readonly mask = input('');\n readonly label = input('');\n readonly placeholder = input('');\n readonly hint = input('');\n readonly disabled = input(false);\n readonly valueChange = output<string>();\n readonly inputId = `neu-input-mask-${Math.random().toString(36).slice(2)}`;\n readonly value = signal('');\n readonly cvaDisabled = signal(false);\n private onChange: (value: string) => void = () => {};\n onTouched: () => void = () => {};\n\n writeValue(value: string | null): void {\n this.value.set(value ?? '');\n }\n\n registerOnChange(fn: (value: string) => void): void {\n this.onChange = fn;\n }\n\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n setDisabledState(isDisabled: boolean): void {\n this.cvaDisabled.set(isDisabled);\n }\n\n onInput(raw: string): void {\n const masked = this.applyMask(raw);\n this.value.set(masked);\n this.onChange(masked);\n this.valueChange.emit(masked);\n }\n\n private applyMask(raw: string): string {\n const mask = this.mask();\n if (!mask) {\n return raw;\n }\n const chars = raw.replace(/\\W/g, '').split('');\n let result = '';\n for (const token of mask) {\n const char = chars[0];\n if (!char) {\n break;\n }\n if (token === '9' && /\\d/.test(char)) {\n result += chars.shift();\n } else if (token === 'A' && /[a-z]/i.test(char)) {\n result += chars.shift();\n } else if (token === '*' && /[a-z0-9]/i.test(char)) {\n result += chars.shift();\n } else if (!['9', 'A', '*'].includes(token)) {\n result += token;\n } else {\n chars.shift();\n }\n }\n return result;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;MA6Ba,qBAAqB,CAAA;AACvB,IAAA,IAAI,GAAG,KAAK,CAAC,EAAE,2EAAC;AAChB,IAAA,KAAK,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