@sdcorejs/angular 21.2.6 → 22.2.6
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/assets/fonts/fonts.scss +2 -2
- package/assets/images/coming-soon.svg +6 -6
- package/assets/images/data-empty.svg +2 -2
- package/assets/images/expired.svg +6 -6
- package/assets/images/file-error.svg +6 -6
- package/assets/images/filter-empty.svg +2 -2
- package/assets/images/filter-required.svg +2 -2
- package/assets/images/forbidden.svg +2 -2
- package/assets/images/image-error.svg +8 -8
- package/assets/images/maintenance.svg +3 -3
- package/assets/images/not-found.svg +2 -2
- package/assets/images/offline.svg +5 -5
- package/assets/images/submitted.svg +5 -5
- package/assets/images/success.svg +3 -3
- package/assets/images/unauthorized.svg +2 -2
- package/assets/images/unknown-error.svg +2 -2
- package/fesm2022/sdcorejs-angular-components-anchor.mjs +46 -29
- package/fesm2022/sdcorejs-angular-components-anchor.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs +167 -94
- package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-audit-diff.mjs +20 -13
- package/fesm2022/sdcorejs-angular-components-audit-diff.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-autoid-inspector.mjs +65 -40
- package/fesm2022/sdcorejs-angular-components-autoid-inspector.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-avatar.mjs +15 -9
- package/fesm2022/sdcorejs-angular-components-avatar.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-badge.mjs +31 -17
- package/fesm2022/sdcorejs-angular-components-badge.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-breadcrumb.mjs +17 -10
- package/fesm2022/sdcorejs-angular-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-button.mjs +17 -10
- package/fesm2022/sdcorejs-angular-components-button.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-card.mjs +28 -17
- package/fesm2022/sdcorejs-angular-components-card.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-chart.mjs +52 -32
- package/fesm2022/sdcorejs-angular-components-chart.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-ckeditor-styles.mjs +3 -3
- package/fesm2022/sdcorejs-angular-components-ckeditor-styles.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-code-editor.mjs +15 -9
- package/fesm2022/sdcorejs-angular-components-code-editor.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-data-state.mjs +32 -19
- package/fesm2022/sdcorejs-angular-components-data-state.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-editor.mjs +38 -21
- package/fesm2022/sdcorejs-angular-components-editor.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-form-generic.mjs +396 -306
- package/fesm2022/sdcorejs-angular-components-form-generic.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-history.mjs +10 -10
- package/fesm2022/sdcorejs-angular-components-history.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-import-excel.mjs +13 -13
- package/fesm2022/sdcorejs-angular-components-import-excel.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-inform.mjs +42 -24
- package/fesm2022/sdcorejs-angular-components-inform.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-job-progress.mjs +39 -21
- package/fesm2022/sdcorejs-angular-components-job-progress.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-mini-editor.mjs +9 -8
- package/fesm2022/sdcorejs-angular-components-mini-editor.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs +22 -14
- package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-modal.mjs +21 -12
- package/fesm2022/sdcorejs-angular-components-modal.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-operator.mjs +17 -10
- package/fesm2022/sdcorejs-angular-components-operator.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-org-chart.mjs +26 -16
- package/fesm2022/sdcorejs-angular-components-org-chart.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-preview.mjs +288 -147
- package/fesm2022/sdcorejs-angular-components-preview.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-query-bar.mjs +279 -153
- package/fesm2022/sdcorejs-angular-components-query-bar.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-query-builder.mjs +69 -36
- package/fesm2022/sdcorejs-angular-components-query-builder.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-quick-action.mjs +3 -3
- package/fesm2022/sdcorejs-angular-components-quick-action.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-section.mjs +17 -13
- package/fesm2022/sdcorejs-angular-components-section.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-side-drawer.mjs +26 -16
- package/fesm2022/sdcorejs-angular-components-side-drawer.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-splitter.mjs +58 -37
- package/fesm2022/sdcorejs-angular-components-splitter.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-stepper.mjs +36 -21
- package/fesm2022/sdcorejs-angular-components-stepper.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-tab-router.mjs +27 -23
- package/fesm2022/sdcorejs-angular-components-tab-router.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-tab.mjs +34 -20
- package/fesm2022/sdcorejs-angular-components-tab.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-table.mjs +442 -277
- package/fesm2022/sdcorejs-angular-components-table.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-tree.mjs +86 -46
- package/fesm2022/sdcorejs-angular-components-tree.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-upload-file.mjs +67 -41
- package/fesm2022/sdcorejs-angular-components-upload-file.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-view.mjs +25 -14
- package/fesm2022/sdcorejs-angular-components-view.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-configurations.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-directives.mjs +42 -33
- package/fesm2022/sdcorejs-angular-directives.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs +85 -44
- package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-checkbox.mjs +15 -9
- package/fesm2022/sdcorejs-angular-forms-checkbox.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs +41 -24
- package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-chip.mjs +37 -22
- package/fesm2022/sdcorejs-angular-forms-chip.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-date-range.mjs +55 -30
- package/fesm2022/sdcorejs-angular-forms-date-range.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-date.mjs +63 -34
- package/fesm2022/sdcorejs-angular-forms-date.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-datetime.mjs +65 -35
- package/fesm2022/sdcorejs-angular-forms-datetime.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-directives.mjs +12 -12
- package/fesm2022/sdcorejs-angular-forms-directives.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-entity-picker.mjs +94 -53
- package/fesm2022/sdcorejs-angular-forms-entity-picker.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-inline-text.mjs +33 -18
- package/fesm2022/sdcorejs-angular-forms-inline-text.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-input-color.mjs +25 -14
- package/fesm2022/sdcorejs-angular-forms-input-color.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-input-number.mjs +66 -35
- package/fesm2022/sdcorejs-angular-forms-input-number.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-input.mjs +94 -49
- package/fesm2022/sdcorejs-angular-forms-input.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-label.mjs +3 -3
- package/fesm2022/sdcorejs-angular-forms-label.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-models.mjs +13 -8
- package/fesm2022/sdcorejs-angular-forms-models.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-radio.mjs +41 -22
- package/fesm2022/sdcorejs-angular-forms-radio.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-select.mjs +116 -61
- package/fesm2022/sdcorejs-angular-forms-select.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-switch.mjs +21 -12
- package/fesm2022/sdcorejs-angular-forms-switch.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-textarea.mjs +48 -26
- package/fesm2022/sdcorejs-angular-forms-textarea.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-time-range.mjs +83 -43
- package/fesm2022/sdcorejs-angular-forms-time-range.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-time.mjs +72 -38
- package/fesm2022/sdcorejs-angular-forms-time.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-tree-select.mjs +76 -41
- package/fesm2022/sdcorejs-angular-forms-tree-select.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms.mjs +4 -4
- package/fesm2022/sdcorejs-angular-forms.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-handlers.mjs +3 -3
- package/fesm2022/sdcorejs-angular-handlers.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-i18n.mjs +12 -9
- package/fesm2022/sdcorejs-angular-i18n.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-interceptors.mjs +6 -6
- package/fesm2022/sdcorejs-angular-interceptors.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-auth.mjs +11 -10
- package/fesm2022/sdcorejs-angular-modules-auth.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-icon.mjs +19 -11
- package/fesm2022/sdcorejs-angular-modules-icon.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-keycloak.mjs +7 -7
- package/fesm2022/sdcorejs-angular-modules-keycloak.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-layout.mjs +387 -247
- package/fesm2022/sdcorejs-angular-modules-layout.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-permission.mjs +13 -11
- package/fesm2022/sdcorejs-angular-modules-permission.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-pipes.mjs +25 -25
- package/fesm2022/sdcorejs-angular-pipes.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-api.mjs +10 -10
- package/fesm2022/sdcorejs-angular-services-api.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-cache.mjs +3 -3
- package/fesm2022/sdcorejs-angular-services-cache.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-confirm.mjs +6 -6
- package/fesm2022/sdcorejs-angular-services-confirm.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-excel.mjs +3 -3
- package/fesm2022/sdcorejs-angular-services-excel.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-loading.mjs +3 -3
- package/fesm2022/sdcorejs-angular-services-loading.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-notify.mjs +21 -16
- package/fesm2022/sdcorejs-angular-services-notify.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-persistence.mjs +3 -3
- package/fesm2022/sdcorejs-angular-services-persistence.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-storage.mjs +3 -3
- package/fesm2022/sdcorejs-angular-services-storage.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-task.mjs +19 -11
- package/fesm2022/sdcorejs-angular-services-task.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-unsaved-changes.mjs +17 -10
- package/fesm2022/sdcorejs-angular-services-unsaved-changes.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-viewport.mjs +15 -9
- package/fesm2022/sdcorejs-angular-services-viewport.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-utilities-data-state.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-utilities-extensions.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-utilities-models.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-utilities-read-state.mjs +2 -1
- package/fesm2022/sdcorejs-angular-utilities-read-state.mjs.map +1 -1
- package/package.json +11 -11
|
@@ -21,20 +21,27 @@ import { SdIcon } from '@sdcorejs/angular/modules/icon';
|
|
|
21
21
|
*/
|
|
22
22
|
class SdInlineText {
|
|
23
23
|
/** Uncontrolled value (two-way). Ignored when `[control]` is provided. */
|
|
24
|
-
value = model('',
|
|
24
|
+
value = model('', /* @ts-ignore */
|
|
25
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
25
26
|
/** Optional external FormControl (controlled mode) — used by sd-input / sd-input-number. */
|
|
26
|
-
control = input(undefined,
|
|
27
|
-
|
|
27
|
+
control = input(undefined, /* @ts-ignore */
|
|
28
|
+
...(ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []));
|
|
29
|
+
placeholder = input('', /* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
28
31
|
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
29
32
|
/** Show a hover/value-gated clear-× (default `true`). */
|
|
30
33
|
clearable = input(true, { ...(ngDevMode ? { debugName: "clearable" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
31
34
|
/** `'auto'` derives state from focus + value; pass an explicit value (e.g. `'error'`) to override. */
|
|
32
|
-
state = input('auto',
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
state = input('auto', /* @ts-ignore */
|
|
36
|
+
...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
37
|
+
chrome = input('standalone', /* @ts-ignore */
|
|
38
|
+
...(ngDevMode ? [{ debugName: "chrome" }] : /* istanbul ignore next */ []));
|
|
39
|
+
autoId = input(undefined, /* @ts-ignore */
|
|
40
|
+
...(ngDevMode ? [{ debugName: "autoId" }] : /* istanbul ignore next */ []));
|
|
35
41
|
autofocus = input(false, { ...(ngDevMode ? { debugName: "autofocus" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
36
42
|
/** Lower bound (chars) so short/empty values keep a clickable target. */
|
|
37
|
-
minSize = input(2,
|
|
43
|
+
minSize = input(2, /* @ts-ignore */
|
|
44
|
+
...(ngDevMode ? [{ debugName: "minSize" }] : /* istanbul ignore next */ []));
|
|
38
45
|
cleared = output();
|
|
39
46
|
keyupEnter = output();
|
|
40
47
|
keydownEscape = output();
|
|
@@ -44,10 +51,13 @@ class SdInlineText {
|
|
|
44
51
|
sdPaste = output();
|
|
45
52
|
sdCompositionStart = output();
|
|
46
53
|
sdCompositionEnd = output();
|
|
47
|
-
inputRef = viewChild('inputEl',
|
|
54
|
+
inputRef = viewChild('inputEl', /* @ts-ignore */
|
|
55
|
+
...(ngDevMode ? [{ debugName: "inputRef" }] : /* istanbul ignore next */ []));
|
|
48
56
|
/** Bumped on input/blur/composition + bound-control changes so size/state methods re-eval under OnPush. */
|
|
49
|
-
tick = signal(0,
|
|
50
|
-
|
|
57
|
+
tick = signal(0, /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "tick" }] : /* istanbul ignore next */ []));
|
|
59
|
+
focused = signal(false, /* @ts-ignore */
|
|
60
|
+
...(ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []));
|
|
51
61
|
constructor() {
|
|
52
62
|
// why: a bound control's value can change programmatically (sd-input-number reformats
|
|
53
63
|
// on blur) without a DOM input event — subscribe so the size/state still refresh.
|
|
@@ -73,14 +83,18 @@ class SdInlineText {
|
|
|
73
83
|
const c = this.control();
|
|
74
84
|
const raw = c ? c.value : this.value();
|
|
75
85
|
return raw == null ? '' : String(raw);
|
|
76
|
-
},
|
|
77
|
-
|
|
86
|
+
}, /* @ts-ignore */
|
|
87
|
+
...(ngDevMode ? [{ debugName: "currentText" }] : /* istanbul ignore next */ []));
|
|
88
|
+
hasValue = computed(() => this.currentText().length > 0, /* @ts-ignore */
|
|
89
|
+
...(ngDevMode ? [{ debugName: "hasValue" }] : /* istanbul ignore next */ []));
|
|
78
90
|
sizeOf = computed(() => {
|
|
79
91
|
const text = this.currentText();
|
|
80
92
|
const base = text.length > 0 ? text.length : this.placeholder().length;
|
|
81
93
|
return Math.max(this.minSize(), base);
|
|
82
|
-
},
|
|
83
|
-
|
|
94
|
+
}, /* @ts-ignore */
|
|
95
|
+
...(ngDevMode ? [{ debugName: "sizeOf" }] : /* istanbul ignore next */ []));
|
|
96
|
+
showClear = computed(() => this.clearable() && this.hasValue() && !this.disabled(), /* @ts-ignore */
|
|
97
|
+
...(ngDevMode ? [{ debugName: "showClear" }] : /* istanbul ignore next */ []));
|
|
84
98
|
effectiveState = computed(() => {
|
|
85
99
|
const s = this.state();
|
|
86
100
|
if (s !== 'auto')
|
|
@@ -88,7 +102,8 @@ class SdInlineText {
|
|
|
88
102
|
if (this.focused())
|
|
89
103
|
return 'focus';
|
|
90
104
|
return this.hasValue() ? 'active' : 'pending';
|
|
91
|
-
},
|
|
105
|
+
}, /* @ts-ignore */
|
|
106
|
+
...(ngDevMode ? [{ debugName: "effectiveState" }] : /* istanbul ignore next */ []));
|
|
92
107
|
// ── event handlers ─────────────────────────────────────────────────────────
|
|
93
108
|
onInput(ev) {
|
|
94
109
|
const el = ev.target;
|
|
@@ -145,10 +160,10 @@ class SdInlineText {
|
|
|
145
160
|
blur() {
|
|
146
161
|
this.inputRef()?.nativeElement.blur();
|
|
147
162
|
}
|
|
148
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
149
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
163
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: SdInlineText, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
164
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: SdInlineText, isStandalone: true, selector: "sd-inline-text", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, control: { classPropertyName: "control", publicName: "control", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, clearable: { classPropertyName: "clearable", publicName: "clearable", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, chrome: { classPropertyName: "chrome", publicName: "chrome", isSignal: true, isRequired: false, transformFunction: null }, autoId: { classPropertyName: "autoId", publicName: "autoId", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, minSize: { classPropertyName: "minSize", publicName: "minSize", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", cleared: "cleared", keyupEnter: "keyupEnter", keydownEscape: "keydownEscape", sdFocus: "sdFocus", sdBlur: "sdBlur", sdKeydown: "sdKeydown", sdPaste: "sdPaste", sdCompositionStart: "sdCompositionStart", sdCompositionEnd: "sdCompositionEnd" }, host: { properties: { "class.sd-inline-text--standalone": "chrome() === 'standalone'", "class.sd-inline-text--seamless": "chrome() === 'seamless'", "attr.data-state": "effectiveState()" }, classAttribute: "sd-inline-text" }, viewQueries: [{ propertyName: "inputRef", first: true, predicate: ["inputEl"], descendants: true, isSignal: true }], ngImport: i0, template: "@let _autoId = autoId();\n@let _placeholder = placeholder();\n@let _sizeOf = sizeOf();\n@let _control = control();\n\n@if (_control) {\n <input\n #inputEl\n class=\"sd-inline-text__input\"\n type=\"text\"\n [formControl]=\"_control\"\n [placeholder]=\"_placeholder\"\n [size]=\"_sizeOf\"\n [attr.data-autoId]=\"_autoId\"\n (input)=\"onInput($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (keyup)=\"onKeyup($event)\"\n (keydown)=\"onKeydown($event)\"\n (paste)=\"onPaste($event)\"\n (compositionstart)=\"onCompositionStart($event)\"\n (compositionend)=\"onCompositionEnd($event)\" />\n} @else {\n <input\n #inputEl\n class=\"sd-inline-text__input\"\n type=\"text\"\n [value]=\"currentText()\"\n [disabled]=\"disabled()\"\n [placeholder]=\"_placeholder\"\n [size]=\"_sizeOf\"\n [attr.data-autoId]=\"_autoId\"\n (input)=\"onInput($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (keyup)=\"onKeyup($event)\"\n (keydown)=\"onKeydown($event)\"\n (paste)=\"onPaste($event)\"\n (compositionstart)=\"onCompositionStart($event)\"\n (compositionend)=\"onCompositionEnd($event)\" />\n}\n\n@if (showClear()) {\n <button type=\"button\" class=\"sd-inline-text__clear\" (click)=\"clear($event)\" aria-label=\"Clear\" tabindex=\"-1\">\n <sd-icon name=\"close\"></sd-icon>\n </button>\n}\n", styles: [":host{display:inline-flex;align-items:center;max-width:100%;font:inherit;color:inherit}.sd-inline-text__input{appearance:none;border:0;outline:0;background:transparent;font:inherit;color:inherit;padding:0;min-width:0;max-width:240px}:host(.sd-inline-text--standalone){border-radius:4px;padding:1px 6px;background-color:#0000000a;transition:background-color .15s ease,box-shadow .15s ease}:host(.sd-inline-text--standalone):hover{background-color:#00000014}:host(.sd-inline-text--standalone)[data-state=focus]{background-color:#0000000f;box-shadow:inset 0 0 0 1px var(--sd-primary, #1f6feb)}:host(.sd-inline-text--standalone)[data-state=error]{box-shadow:inset 0 0 0 1px var(--sd-error, #b32626)}:host(.sd-inline-text--standalone) .sd-inline-text__clear{display:none}:host(.sd-inline-text--standalone):hover .sd-inline-text__clear,:host(.sd-inline-text--standalone)[data-state=focus] .sd-inline-text__clear{display:inline-flex}:host(.sd-inline-text--seamless) .sd-inline-text__input{font-weight:500}:host(.sd-inline-text--seamless) .sd-inline-text__input::placeholder{font-style:italic}:host(.sd-inline-text--seamless)[data-state=active] .sd-inline-text__input{color:var(--sd-primary, #1f6feb)}:host(.sd-inline-text--seamless)[data-state=error] .sd-inline-text__input{color:var(--sd-error, #b32626)}.sd-inline-text__clear{display:inline-flex;align-items:center;margin-left:4px;padding:0;border:0;background:transparent;cursor:pointer;line-height:0;color:var(--sd-text-secondary, #6b7280);transition:color .15s ease}.sd-inline-text__clear sd-icon{font-size:16px;width:16px;height:16px}.sd-inline-text__clear:hover{color:var(--sd-error, #b32626)}\n"], dependencies: [{ kind: "component", type: SdIcon, selector: "sd-icon", inputs: ["name", "fontIcon", "color", "set", "fontSet", "size", "strokeWidth", "absoluteStrokeWidth", "ariaLabel"] }, { kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
150
165
|
}
|
|
151
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
166
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: SdInlineText, decorators: [{
|
|
152
167
|
type: Component,
|
|
153
168
|
args: [{ selector: 'sd-inline-text', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [SdIcon, CommonModule, ReactiveFormsModule], host: {
|
|
154
169
|
class: 'sd-inline-text',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdcorejs-angular-forms-inline-text.mjs","sources":["../../../projects/sdcorejs-angular/forms/inline-text/src/inline-text.component.ts","../../../projects/sdcorejs-angular/forms/inline-text/src/inline-text.component.html","../../../projects/sdcorejs-angular/forms/inline-text/sdcorejs-angular-forms-inline-text.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n afterNextRender,\n booleanAttribute,\n ChangeDetectionStrategy,\n Component,\n computed,\n effect,\n ElementRef,\n input,\n model,\n output,\n signal,\n viewChild,\n} from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SdFormControl } from '@sdcorejs/angular/forms/models';\nimport { SdIcon } from '@sdcorejs/angular/modules/icon';\n\n/** Visual / `data-state` of the inline input. `'auto'` derives from focus + value. */\nexport type SdInlineTextState = 'auto' | 'pending' | 'active' | 'focus' | 'error';\n/** `'standalone'` draws its own affordance (hover bg + focus ring); `'seamless'` defers all chrome to the host. */\nexport type SdInlineTextChrome = 'standalone' | 'seamless';\n\n/**\n * Borderless, content-hugging text input — the seamless primitive shared by\n * `sd-input` / `sd-input-number` (`viewed='inline'`) and the query-bar / query-builder chips.\n *\n * why: a native `<input>` inside `mat-form-field` cannot hug its content, so inline-edit\n * looked like a full-width input rather than text. This primitive renders a raw `<input>`\n * sized via the native `size` attribute (clamped) so the click/hover target tracks the value.\n *\n * It is intentionally unopinionated about commit/parse/format: it forwards the raw DOM events\n * (focus / blur / keydown / paste / composition / Enter / Escape) so each consumer keeps its own\n * logic (e.g. sd-input-number's vi-VN formatting). Two binding modes:\n * - **uncontrolled** via `[(value)]` — used by the chips' signal drafts;\n * - **controlled** via `[control]` (an external `SdFormControl`) — used by the form controls.\n */\n@Component({\n selector: 'sd-inline-text',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [SdIcon, CommonModule, ReactiveFormsModule],\n templateUrl: './inline-text.component.html',\n styleUrl: './inline-text.component.scss',\n host: {\n class: 'sd-inline-text',\n '[class.sd-inline-text--standalone]': \"chrome() === 'standalone'\",\n '[class.sd-inline-text--seamless]': \"chrome() === 'seamless'\",\n '[attr.data-state]': 'effectiveState()',\n },\n})\nexport class SdInlineText {\n /** Uncontrolled value (two-way). Ignored when `[control]` is provided. */\n readonly value = model<string>('');\n /** Optional external FormControl (controlled mode) — used by sd-input / sd-input-number. */\n readonly control = input<SdFormControl | undefined>(undefined);\n readonly placeholder = input<string>('');\n readonly disabled = input(false, { transform: booleanAttribute });\n /** Show a hover/value-gated clear-× (default `true`). */\n readonly clearable = input(true, { transform: booleanAttribute });\n /** `'auto'` derives state from focus + value; pass an explicit value (e.g. `'error'`) to override. */\n readonly state = input<SdInlineTextState>('auto');\n readonly chrome = input<SdInlineTextChrome>('standalone');\n readonly autoId = input<string | undefined>(undefined);\n readonly autofocus = input(false, { transform: booleanAttribute });\n /** Lower bound (chars) so short/empty values keep a clickable target. */\n readonly minSize = input(2);\n\n readonly cleared = output<void>();\n readonly keyupEnter = output<void>();\n readonly keydownEscape = output<void>();\n readonly sdFocus = output<FocusEvent>();\n readonly sdBlur = output<FocusEvent>();\n readonly sdKeydown = output<KeyboardEvent>();\n readonly sdPaste = output<ClipboardEvent>();\n readonly sdCompositionStart = output<CompositionEvent>();\n readonly sdCompositionEnd = output<CompositionEvent>();\n\n private readonly inputRef = viewChild<ElementRef<HTMLInputElement>>('inputEl');\n\n /** Bumped on input/blur/composition + bound-control changes so size/state methods re-eval under OnPush. */\n protected readonly tick = signal(0);\n protected readonly focused = signal(false);\n\n constructor() {\n // why: a bound control's value can change programmatically (sd-input-number reformats\n // on blur) without a DOM input event — subscribe so the size/state still refresh.\n effect(onCleanup => {\n const c = this.control();\n if (!c) return;\n const sub = c.valueChanges.subscribe(() => this.tick.update(n => n + 1));\n onCleanup(() => sub.unsubscribe());\n });\n\n afterNextRender(() => {\n if (this.autofocus()) this.focus();\n });\n }\n\n /**\n * Current text — from the bound control in controlled mode, else the value model.\n * why: `tick` is a tracked dependency so the computed re-runs when a bound control's\n * value changes programmatically (control.value itself is not a signal).\n */\n protected readonly currentText = computed<string>(() => {\n this.tick();\n const c = this.control();\n const raw = c ? c.value : this.value();\n return raw == null ? '' : String(raw);\n });\n\n protected readonly hasValue = computed(() => this.currentText().length > 0);\n\n protected readonly sizeOf = computed(() => {\n const text = this.currentText();\n const base = text.length > 0 ? text.length : this.placeholder().length;\n return Math.max(this.minSize(), base);\n });\n\n protected readonly showClear = computed(() => this.clearable() && this.hasValue() && !this.disabled());\n\n protected readonly effectiveState = computed<SdInlineTextState>(() => {\n const s = this.state();\n if (s !== 'auto') return s;\n if (this.focused()) return 'focus';\n return this.hasValue() ? 'active' : 'pending';\n });\n\n // ── event handlers ─────────────────────────────────────────────────────────\n protected onInput(ev: Event): void {\n const el = ev.target as HTMLInputElement;\n // why: only the uncontrolled mode owns the value model; in controlled mode the bound\n // FormControl carries the value natively (ReactiveForms), so we must not double-write.\n if (!this.control()) this.value.set(el.value);\n this.tick.update(n => n + 1);\n }\n\n protected onFocus(ev: FocusEvent): void {\n this.focused.set(true);\n this.sdFocus.emit(ev);\n }\n\n protected onBlur(ev: FocusEvent): void {\n this.focused.set(false);\n this.tick.update(n => n + 1);\n this.sdBlur.emit(ev);\n }\n\n protected onKeyup(ev: KeyboardEvent): void {\n if (ev.key === 'Enter') this.keyupEnter.emit();\n }\n\n protected onKeydown(ev: KeyboardEvent): void {\n if (ev.key === 'Escape') this.keydownEscape.emit();\n this.sdKeydown.emit(ev);\n }\n\n protected onPaste(ev: ClipboardEvent): void {\n this.sdPaste.emit(ev);\n }\n\n protected onCompositionStart(ev: CompositionEvent): void {\n this.sdCompositionStart.emit(ev);\n }\n\n protected onCompositionEnd(ev: CompositionEvent): void {\n this.tick.update(n => n + 1);\n this.sdCompositionEnd.emit(ev);\n }\n\n protected clear(ev: Event): void {\n ev.stopPropagation();\n const c = this.control();\n if (c) c.setValue('');\n else this.value.set('');\n this.tick.update(n => n + 1);\n this.cleared.emit();\n }\n\n // ── public API ───────────────────────────────────────────────────────────\n /** Focus the native input. */\n focus(): void {\n this.inputRef()?.nativeElement.focus();\n }\n\n /** Blur the native input. */\n blur(): void {\n this.inputRef()?.nativeElement.blur();\n }\n}\n","@let _autoId = autoId();\n@let _placeholder = placeholder();\n@let _sizeOf = sizeOf();\n@let _control = control();\n\n@if (_control) {\n <input\n #inputEl\n class=\"sd-inline-text__input\"\n type=\"text\"\n [formControl]=\"_control\"\n [placeholder]=\"_placeholder\"\n [size]=\"_sizeOf\"\n [attr.data-autoId]=\"_autoId\"\n (input)=\"onInput($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (keyup)=\"onKeyup($event)\"\n (keydown)=\"onKeydown($event)\"\n (paste)=\"onPaste($event)\"\n (compositionstart)=\"onCompositionStart($event)\"\n (compositionend)=\"onCompositionEnd($event)\" />\n} @else {\n <input\n #inputEl\n class=\"sd-inline-text__input\"\n type=\"text\"\n [value]=\"currentText()\"\n [disabled]=\"disabled()\"\n [placeholder]=\"_placeholder\"\n [size]=\"_sizeOf\"\n [attr.data-autoId]=\"_autoId\"\n (input)=\"onInput($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (keyup)=\"onKeyup($event)\"\n (keydown)=\"onKeydown($event)\"\n (paste)=\"onPaste($event)\"\n (compositionstart)=\"onCompositionStart($event)\"\n (compositionend)=\"onCompositionEnd($event)\" />\n}\n\n@if (showClear()) {\n <button type=\"button\" class=\"sd-inline-text__clear\" (click)=\"clear($event)\" aria-label=\"Clear\" tabindex=\"-1\">\n <sd-icon name=\"close\"></sd-icon>\n </button>\n}\n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UAAA,EACd,IAAI,EAAA,eAAA,EACC,uBAAuB,CAAC,MAAM,EAAA,OAAA,EACtC,CAAC,MAAM,EAAE,YAAY,EAAE,mBAAmB,CAAC,EAAA,IAAA,EAG9C;AACJ,wBAAA,KAAK,EAAE,gBAAgB;AACvB,wBAAA,oCAAoC,EAAE,2BAA2B;AACjE,wBAAA,kCAAkC,EAAE,yBAAyB;AAC7D,wBAAA,mBAAmB,EAAE,kBAAkB;AACxC,qBAAA,EAAA,QAAA,EAAA,04CAAA,EAAA,MAAA,EAAA,CAAA,+mDAAA,CAAA,EAAA;qkDA6BmE,SAAS,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AE/E/E;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"sdcorejs-angular-forms-inline-text.mjs","sources":["../../../projects/sdcorejs-angular/forms/inline-text/src/inline-text.component.ts","../../../projects/sdcorejs-angular/forms/inline-text/src/inline-text.component.html","../../../projects/sdcorejs-angular/forms/inline-text/sdcorejs-angular-forms-inline-text.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n afterNextRender,\n booleanAttribute,\n ChangeDetectionStrategy,\n Component,\n computed,\n effect,\n ElementRef,\n input,\n model,\n output,\n signal,\n viewChild,\n} from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SdFormControl } from '@sdcorejs/angular/forms/models';\nimport { SdIcon } from '@sdcorejs/angular/modules/icon';\n\n/** Visual / `data-state` of the inline input. `'auto'` derives from focus + value. */\nexport type SdInlineTextState = 'auto' | 'pending' | 'active' | 'focus' | 'error';\n/** `'standalone'` draws its own affordance (hover bg + focus ring); `'seamless'` defers all chrome to the host. */\nexport type SdInlineTextChrome = 'standalone' | 'seamless';\n\n/**\n * Borderless, content-hugging text input — the seamless primitive shared by\n * `sd-input` / `sd-input-number` (`viewed='inline'`) and the query-bar / query-builder chips.\n *\n * why: a native `<input>` inside `mat-form-field` cannot hug its content, so inline-edit\n * looked like a full-width input rather than text. This primitive renders a raw `<input>`\n * sized via the native `size` attribute (clamped) so the click/hover target tracks the value.\n *\n * It is intentionally unopinionated about commit/parse/format: it forwards the raw DOM events\n * (focus / blur / keydown / paste / composition / Enter / Escape) so each consumer keeps its own\n * logic (e.g. sd-input-number's vi-VN formatting). Two binding modes:\n * - **uncontrolled** via `[(value)]` — used by the chips' signal drafts;\n * - **controlled** via `[control]` (an external `SdFormControl`) — used by the form controls.\n */\n@Component({\n selector: 'sd-inline-text',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [SdIcon, CommonModule, ReactiveFormsModule],\n templateUrl: './inline-text.component.html',\n styleUrl: './inline-text.component.scss',\n host: {\n class: 'sd-inline-text',\n '[class.sd-inline-text--standalone]': \"chrome() === 'standalone'\",\n '[class.sd-inline-text--seamless]': \"chrome() === 'seamless'\",\n '[attr.data-state]': 'effectiveState()',\n },\n})\nexport class SdInlineText {\n /** Uncontrolled value (two-way). Ignored when `[control]` is provided. */\n readonly value = model<string>('');\n /** Optional external FormControl (controlled mode) — used by sd-input / sd-input-number. */\n readonly control = input<SdFormControl | undefined>(undefined);\n readonly placeholder = input<string>('');\n readonly disabled = input(false, { transform: booleanAttribute });\n /** Show a hover/value-gated clear-× (default `true`). */\n readonly clearable = input(true, { transform: booleanAttribute });\n /** `'auto'` derives state from focus + value; pass an explicit value (e.g. `'error'`) to override. */\n readonly state = input<SdInlineTextState>('auto');\n readonly chrome = input<SdInlineTextChrome>('standalone');\n readonly autoId = input<string | undefined>(undefined);\n readonly autofocus = input(false, { transform: booleanAttribute });\n /** Lower bound (chars) so short/empty values keep a clickable target. */\n readonly minSize = input(2);\n\n readonly cleared = output<void>();\n readonly keyupEnter = output<void>();\n readonly keydownEscape = output<void>();\n readonly sdFocus = output<FocusEvent>();\n readonly sdBlur = output<FocusEvent>();\n readonly sdKeydown = output<KeyboardEvent>();\n readonly sdPaste = output<ClipboardEvent>();\n readonly sdCompositionStart = output<CompositionEvent>();\n readonly sdCompositionEnd = output<CompositionEvent>();\n\n private readonly inputRef = viewChild<ElementRef<HTMLInputElement>>('inputEl');\n\n /** Bumped on input/blur/composition + bound-control changes so size/state methods re-eval under OnPush. */\n protected readonly tick = signal(0);\n protected readonly focused = signal(false);\n\n constructor() {\n // why: a bound control's value can change programmatically (sd-input-number reformats\n // on blur) without a DOM input event — subscribe so the size/state still refresh.\n effect(onCleanup => {\n const c = this.control();\n if (!c) return;\n const sub = c.valueChanges.subscribe(() => this.tick.update(n => n + 1));\n onCleanup(() => sub.unsubscribe());\n });\n\n afterNextRender(() => {\n if (this.autofocus()) this.focus();\n });\n }\n\n /**\n * Current text — from the bound control in controlled mode, else the value model.\n * why: `tick` is a tracked dependency so the computed re-runs when a bound control's\n * value changes programmatically (control.value itself is not a signal).\n */\n protected readonly currentText = computed<string>(() => {\n this.tick();\n const c = this.control();\n const raw = c ? c.value : this.value();\n return raw == null ? '' : String(raw);\n });\n\n protected readonly hasValue = computed(() => this.currentText().length > 0);\n\n protected readonly sizeOf = computed(() => {\n const text = this.currentText();\n const base = text.length > 0 ? text.length : this.placeholder().length;\n return Math.max(this.minSize(), base);\n });\n\n protected readonly showClear = computed(() => this.clearable() && this.hasValue() && !this.disabled());\n\n protected readonly effectiveState = computed<SdInlineTextState>(() => {\n const s = this.state();\n if (s !== 'auto') return s;\n if (this.focused()) return 'focus';\n return this.hasValue() ? 'active' : 'pending';\n });\n\n // ── event handlers ─────────────────────────────────────────────────────────\n protected onInput(ev: Event): void {\n const el = ev.target as HTMLInputElement;\n // why: only the uncontrolled mode owns the value model; in controlled mode the bound\n // FormControl carries the value natively (ReactiveForms), so we must not double-write.\n if (!this.control()) this.value.set(el.value);\n this.tick.update(n => n + 1);\n }\n\n protected onFocus(ev: FocusEvent): void {\n this.focused.set(true);\n this.sdFocus.emit(ev);\n }\n\n protected onBlur(ev: FocusEvent): void {\n this.focused.set(false);\n this.tick.update(n => n + 1);\n this.sdBlur.emit(ev);\n }\n\n protected onKeyup(ev: KeyboardEvent): void {\n if (ev.key === 'Enter') this.keyupEnter.emit();\n }\n\n protected onKeydown(ev: KeyboardEvent): void {\n if (ev.key === 'Escape') this.keydownEscape.emit();\n this.sdKeydown.emit(ev);\n }\n\n protected onPaste(ev: ClipboardEvent): void {\n this.sdPaste.emit(ev);\n }\n\n protected onCompositionStart(ev: CompositionEvent): void {\n this.sdCompositionStart.emit(ev);\n }\n\n protected onCompositionEnd(ev: CompositionEvent): void {\n this.tick.update(n => n + 1);\n this.sdCompositionEnd.emit(ev);\n }\n\n protected clear(ev: Event): void {\n ev.stopPropagation();\n const c = this.control();\n if (c) c.setValue('');\n else this.value.set('');\n this.tick.update(n => n + 1);\n this.cleared.emit();\n }\n\n // ── public API ───────────────────────────────────────────────────────────\n /** Focus the native input. */\n focus(): void {\n this.inputRef()?.nativeElement.focus();\n }\n\n /** Blur the native input. */\n blur(): void {\n this.inputRef()?.nativeElement.blur();\n }\n}\n","@let _autoId = autoId();\n@let _placeholder = placeholder();\n@let _sizeOf = sizeOf();\n@let _control = control();\n\n@if (_control) {\n <input\n #inputEl\n class=\"sd-inline-text__input\"\n type=\"text\"\n [formControl]=\"_control\"\n [placeholder]=\"_placeholder\"\n [size]=\"_sizeOf\"\n [attr.data-autoId]=\"_autoId\"\n (input)=\"onInput($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (keyup)=\"onKeyup($event)\"\n (keydown)=\"onKeydown($event)\"\n (paste)=\"onPaste($event)\"\n (compositionstart)=\"onCompositionStart($event)\"\n (compositionend)=\"onCompositionEnd($event)\" />\n} @else {\n <input\n #inputEl\n class=\"sd-inline-text__input\"\n type=\"text\"\n [value]=\"currentText()\"\n [disabled]=\"disabled()\"\n [placeholder]=\"_placeholder\"\n [size]=\"_sizeOf\"\n [attr.data-autoId]=\"_autoId\"\n (input)=\"onInput($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (keyup)=\"onKeyup($event)\"\n (keydown)=\"onKeydown($event)\"\n (paste)=\"onPaste($event)\"\n (compositionstart)=\"onCompositionStart($event)\"\n (compositionend)=\"onCompositionEnd($event)\" />\n}\n\n@if (showClear()) {\n <button type=\"button\" class=\"sd-inline-text__clear\" (click)=\"clear($event)\" aria-label=\"Clear\" tabindex=\"-1\">\n <sd-icon name=\"close\"></sd-icon>\n </button>\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAwBA;;;;;;;;;;;;;AAaG;MAeU,YAAY,CAAA;;IAEd,KAAK,GAAG,KAAK,CAAS,EAAE;8EAAC;;IAEzB,OAAO,GAAG,KAAK,CAA4B,SAAS;gFAAC;IACrD,WAAW,GAAG,KAAK,CAAS,EAAE;oFAAC;IAC/B,QAAQ,GAAG,KAAK,CAAC,KAAK,gFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;;IAExD,SAAS,GAAG,KAAK,CAAC,IAAI,iFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;;IAExD,KAAK,GAAG,KAAK,CAAoB,MAAM;8EAAC;IACxC,MAAM,GAAG,KAAK,CAAqB,YAAY;+EAAC;IAChD,MAAM,GAAG,KAAK,CAAqB,SAAS;+EAAC;IAC7C,SAAS,GAAG,KAAK,CAAC,KAAK,iFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;;IAEzD,OAAO,GAAG,KAAK,CAAC,CAAC;gFAAC;IAElB,OAAO,GAAG,MAAM,EAAQ;IACxB,UAAU,GAAG,MAAM,EAAQ;IAC3B,aAAa,GAAG,MAAM,EAAQ;IAC9B,OAAO,GAAG,MAAM,EAAc;IAC9B,MAAM,GAAG,MAAM,EAAc;IAC7B,SAAS,GAAG,MAAM,EAAiB;IACnC,OAAO,GAAG,MAAM,EAAkB;IAClC,kBAAkB,GAAG,MAAM,EAAoB;IAC/C,gBAAgB,GAAG,MAAM,EAAoB;IAErC,QAAQ,GAAG,SAAS,CAA+B,SAAS;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CAAA;kBAdxB,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,gBAAgB,EAAA,UAAA,EACd,IAAI,EAAA,eAAA,EACC,uBAAuB,CAAC,MAAM,EAAA,OAAA,EACtC,CAAC,MAAM,EAAE,YAAY,EAAE,mBAAmB,CAAC,EAAA,IAAA,EAG9C;AACJ,wBAAA,KAAK,EAAE,gBAAgB;AACvB,wBAAA,oCAAoC,EAAE,2BAA2B;AACjE,wBAAA,kCAAkC,EAAE,yBAAyB;AAC7D,wBAAA,mBAAmB,EAAE,kBAAkB;AACxC,qBAAA,EAAA,QAAA,EAAA,04CAAA,EAAA,MAAA,EAAA,CAAA,+mDAAA,CAAA,EAAA;qkDA6BmE,SAAS,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AE/E/E;;AAEG;;"}
|
|
@@ -15,15 +15,23 @@ class SdInputColor {
|
|
|
15
15
|
// ==========================================
|
|
16
16
|
// Inputs (forwarded to <sd-input>)
|
|
17
17
|
// ==========================================
|
|
18
|
-
label = input(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
label = input(/* @ts-ignore */
|
|
19
|
+
...(ngDevMode ? [undefined, { debugName: "label" }] : /* istanbul ignore next */ []));
|
|
20
|
+
helperText = input(/* @ts-ignore */
|
|
21
|
+
...(ngDevMode ? [undefined, { debugName: "helperText" }] : /* istanbul ignore next */ []));
|
|
22
|
+
placeholder = input('#RRGGBB', /* @ts-ignore */
|
|
23
|
+
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
24
|
+
size = input('md', /* @ts-ignore */
|
|
25
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
26
|
+
appearance = input(undefined, /* @ts-ignore */
|
|
27
|
+
...(ngDevMode ? [{ debugName: "appearance" }] : /* istanbul ignore next */ []));
|
|
23
28
|
// why: type as `any` — the inner <sd-input> applies the FormGroup|NgForm transform.
|
|
24
|
-
form = input(undefined,
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
form = input(undefined, /* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [{ debugName: "form" }] : /* istanbul ignore next */ []));
|
|
31
|
+
name = input(/* @ts-ignore */
|
|
32
|
+
...(ngDevMode ? [undefined, { debugName: "name" }] : /* istanbul ignore next */ []));
|
|
33
|
+
autoId = input(/* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [undefined, { debugName: "autoId" }] : /* istanbul ignore next */ []));
|
|
27
35
|
required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
28
36
|
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
29
37
|
readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
@@ -52,7 +60,8 @@ class SdInputColor {
|
|
|
52
60
|
// ==========================================
|
|
53
61
|
// ViewChild
|
|
54
62
|
// ==========================================
|
|
55
|
-
picker = viewChild('picker',
|
|
63
|
+
picker = viewChild('picker', /* @ts-ignore */
|
|
64
|
+
...(ngDevMode ? [{ debugName: "picker" }] : /* istanbul ignore next */ []));
|
|
56
65
|
// ==========================================
|
|
57
66
|
// Derived state
|
|
58
67
|
// ==========================================
|
|
@@ -74,7 +83,8 @@ class SdInputColor {
|
|
|
74
83
|
if (/^#[0-9A-Fa-f]{8}$/.test(v))
|
|
75
84
|
return v.slice(0, 7);
|
|
76
85
|
return '#000000';
|
|
77
|
-
},
|
|
86
|
+
}, /* @ts-ignore */
|
|
87
|
+
...(ngDevMode ? [{ debugName: "pickerSafeValue" }] : /* istanbul ignore next */ []));
|
|
78
88
|
// Swatch shows the raw model value when valid; otherwise transparent so the
|
|
79
89
|
// user gets visual feedback that the hex string is malformed.
|
|
80
90
|
swatchColor = computed(() => {
|
|
@@ -82,7 +92,8 @@ class SdInputColor {
|
|
|
82
92
|
if (!v)
|
|
83
93
|
return 'transparent';
|
|
84
94
|
return this.#hexRegex.test(v) ? v : 'transparent';
|
|
85
|
-
},
|
|
95
|
+
}, /* @ts-ignore */
|
|
96
|
+
...(ngDevMode ? [{ debugName: "swatchColor" }] : /* istanbul ignore next */ []));
|
|
86
97
|
// ==========================================
|
|
87
98
|
// Handlers
|
|
88
99
|
// ==========================================
|
|
@@ -116,10 +127,10 @@ class SdInputColor {
|
|
|
116
127
|
this.valueModel.set(null);
|
|
117
128
|
this.sdChange.emit(null);
|
|
118
129
|
};
|
|
119
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
120
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "
|
|
130
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: SdInputColor, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
131
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.1.5", type: SdInputColor, isStandalone: true, selector: "sd-input-color", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, helperText: { classPropertyName: "helperText", publicName: "helperText", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, autoId: { classPropertyName: "autoId", publicName: "autoId", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", 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 }, clearable: { classPropertyName: "clearable", publicName: "clearable", isSignal: true, isRequired: false, transformFunction: null }, hideInlineError: { classPropertyName: "hideInlineError", publicName: "hideInlineError", isSignal: true, isRequired: false, transformFunction: null }, viewed: { classPropertyName: "viewed", publicName: "viewed", isSignal: true, isRequired: false, transformFunction: null }, valueModel: { classPropertyName: "valueModel", publicName: "model", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueModel: "modelChange", sdChange: "sdChange" }, viewQueries: [{ propertyName: "picker", first: true, predicate: ["picker"], descendants: true, isSignal: true }], ngImport: i0, template: "<sd-input\n [label]=\"label()\"\n [helperText]=\"helperText()\"\n [placeholder]=\"placeholder()\"\n [size]=\"size()\"\n [appearance]=\"appearance() ?? undefined\"\n [form]=\"form()\"\n [name]=\"name() ?? ''\"\n [autoId]=\"autoId()\"\n [required]=\"required()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [clearable]=\"clearable()\"\n [hideInlineError]=\"hideInlineError()\"\n [viewed]=\"viewed()\"\n [pattern]=\"hexPattern\"\n patternErrorMessage=\"M\u00E3 m\u00E0u HEX kh\u00F4ng h\u1EE3p l\u1EC7 (vd #1565C0)\"\n [model]=\"valueModel()\"\n (sdChange)=\"onInputChange($event)\">\n <ng-template sdSuffixDef>\n <div class=\"sd-input-color__suffix\">\n <!-- why: n\u00FAt clear do <sd-input> t\u1EF1 render (built-in, hover-gated). \u1EDE \u0111\u00E2y\n ch\u1EC9 chi\u1EBFu swatch + native picker. onInputChange coerce '' \u2192 null n\u00EAn\n clear c\u1EE7a sd-input v\u1EABn cho ra model r\u1ED7ng \u0111\u00FAng ngh\u0129a. -->\n <button\n type=\"button\"\n class=\"sd-input-color__swatch\"\n [style.background]=\"swatchColor()\"\n [class.sd-input-color__swatch--empty]=\"swatchColor() === 'transparent'\"\n [disabled]=\"disabled() || readonly() || isViewed()\"\n (click)=\"openPicker()\"\n title=\"M\u1EDF b\u1EA3ng ch\u1ECDn m\u00E0u\"\n aria-label=\"M\u1EDF b\u1EA3ng ch\u1ECDn m\u00E0u\"></button>\n <!-- why: GI\u1EEE aria-hidden \u1EDF \u0111\u00E2y. \u0110\u00E2y l\u00E0 proxy thu\u1EA7n: tabindex=\"-1\" (ngo\u00E0i tab order),\n width/height 0, opacity 0, pointer-events:none \u2014 ng\u01B0\u1EDDi d\u00F9ng kh\u00F4ng th\u1EC3 t\u1EDBi \u0111\u01B0\u1EE3c, v\u00E0\n openPicker() ch\u1EC9 .click() ch\u1EE9 kh\u00F4ng .focus(). Control th\u1EADt l\u00E0 <button> ngay tr\u00EAn,\n \u0111\u00E3 c\u00F3 accessible name. N\u1EBFu b\u1ECF aria-hidden, AT s\u1EBD \u0111\u1ECDc th\u1EEBa m\u1ED9t \"color picker\" ma. -->\n <input\n #picker\n type=\"color\"\n class=\"sd-input-color__hidden-picker\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n [value]=\"pickerSafeValue()\"\n (input)=\"onPickerChange($event)\" />\n </div>\n </ng-template>\n</sd-input>\n", styles: [":host{display:block;--sd-input-color-swatch-size: 22px;--sd-input-color-swatch-border: rgba(0, 0, 0, .12);--sd-input-color-swatch-checker: linear-gradient(45deg, #ddd 25%, transparent 25%), linear-gradient(-45deg, #ddd 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ddd 75%), linear-gradient(-45deg, transparent 75%, #ddd 75%)}.sd-input-color__suffix{position:relative;display:inline-flex;align-items:center;gap:4px}.sd-input-color__swatch{width:var(--sd-input-color-swatch-size);height:var(--sd-input-color-swatch-size);border-radius:4px;border:1px solid var(--sd-input-color-swatch-border);padding:0;margin:0;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;background:transparent;transition:transform 80ms ease,box-shadow 80ms ease;position:relative;overflow:hidden}.sd-input-color__swatch:hover:not(:disabled){transform:scale(1.06);box-shadow:0 0 0 2px #1565c02e}.sd-input-color__swatch:disabled{cursor:not-allowed;opacity:.5}.sd-input-color__swatch.sd-input-color__swatch--empty{background-color:#fff;background-image:var(--sd-input-color-swatch-checker);background-size:8px 8px;background-position:0 0,0 4px,4px -4px,-4px 0}.sd-input-color__hidden-picker{position:absolute;width:0;height:0;padding:0;border:0;opacity:0;pointer-events:none;right:0;top:50%}\n"], dependencies: [{ kind: "component", type: SdInput, selector: "sd-input", inputs: ["autoId", "name", "appearance", "floatLabel", "size", "form", "label", "helperText", "placeholder", "type", "mask", "hideInlineError", "blurOnEnter", "clearable", "required", "readonly", "disabled", "viewed", "minlength", "maxlength", "pattern", "patternErrorMessage", "validator", "inlineError", "hyperlink", "model"], outputs: ["modelChange", "sdChange", "sdFocus", "sdBlur", "keyupEnter", "cleared", "sdFocusForceBlur"] }, { kind: "directive", type: SdSuffixDefDirective, selector: "[sdSuffixDef]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
121
132
|
}
|
|
122
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
133
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: SdInputColor, decorators: [{
|
|
123
134
|
type: Component,
|
|
124
135
|
args: [{ selector: 'sd-input-color', standalone: true, imports: [SdInput, SdSuffixDefDirective], changeDetection: ChangeDetectionStrategy.OnPush, template: "<sd-input\n [label]=\"label()\"\n [helperText]=\"helperText()\"\n [placeholder]=\"placeholder()\"\n [size]=\"size()\"\n [appearance]=\"appearance() ?? undefined\"\n [form]=\"form()\"\n [name]=\"name() ?? ''\"\n [autoId]=\"autoId()\"\n [required]=\"required()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [clearable]=\"clearable()\"\n [hideInlineError]=\"hideInlineError()\"\n [viewed]=\"viewed()\"\n [pattern]=\"hexPattern\"\n patternErrorMessage=\"M\u00E3 m\u00E0u HEX kh\u00F4ng h\u1EE3p l\u1EC7 (vd #1565C0)\"\n [model]=\"valueModel()\"\n (sdChange)=\"onInputChange($event)\">\n <ng-template sdSuffixDef>\n <div class=\"sd-input-color__suffix\">\n <!-- why: n\u00FAt clear do <sd-input> t\u1EF1 render (built-in, hover-gated). \u1EDE \u0111\u00E2y\n ch\u1EC9 chi\u1EBFu swatch + native picker. onInputChange coerce '' \u2192 null n\u00EAn\n clear c\u1EE7a sd-input v\u1EABn cho ra model r\u1ED7ng \u0111\u00FAng ngh\u0129a. -->\n <button\n type=\"button\"\n class=\"sd-input-color__swatch\"\n [style.background]=\"swatchColor()\"\n [class.sd-input-color__swatch--empty]=\"swatchColor() === 'transparent'\"\n [disabled]=\"disabled() || readonly() || isViewed()\"\n (click)=\"openPicker()\"\n title=\"M\u1EDF b\u1EA3ng ch\u1ECDn m\u00E0u\"\n aria-label=\"M\u1EDF b\u1EA3ng ch\u1ECDn m\u00E0u\"></button>\n <!-- why: GI\u1EEE aria-hidden \u1EDF \u0111\u00E2y. \u0110\u00E2y l\u00E0 proxy thu\u1EA7n: tabindex=\"-1\" (ngo\u00E0i tab order),\n width/height 0, opacity 0, pointer-events:none \u2014 ng\u01B0\u1EDDi d\u00F9ng kh\u00F4ng th\u1EC3 t\u1EDBi \u0111\u01B0\u1EE3c, v\u00E0\n openPicker() ch\u1EC9 .click() ch\u1EE9 kh\u00F4ng .focus(). Control th\u1EADt l\u00E0 <button> ngay tr\u00EAn,\n \u0111\u00E3 c\u00F3 accessible name. N\u1EBFu b\u1ECF aria-hidden, AT s\u1EBD \u0111\u1ECDc th\u1EEBa m\u1ED9t \"color picker\" ma. -->\n <input\n #picker\n type=\"color\"\n class=\"sd-input-color__hidden-picker\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n [value]=\"pickerSafeValue()\"\n (input)=\"onPickerChange($event)\" />\n </div>\n </ng-template>\n</sd-input>\n", styles: [":host{display:block;--sd-input-color-swatch-size: 22px;--sd-input-color-swatch-border: rgba(0, 0, 0, .12);--sd-input-color-swatch-checker: linear-gradient(45deg, #ddd 25%, transparent 25%), linear-gradient(-45deg, #ddd 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ddd 75%), linear-gradient(-45deg, transparent 75%, #ddd 75%)}.sd-input-color__suffix{position:relative;display:inline-flex;align-items:center;gap:4px}.sd-input-color__swatch{width:var(--sd-input-color-swatch-size);height:var(--sd-input-color-swatch-size);border-radius:4px;border:1px solid var(--sd-input-color-swatch-border);padding:0;margin:0;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;background:transparent;transition:transform 80ms ease,box-shadow 80ms ease;position:relative;overflow:hidden}.sd-input-color__swatch:hover:not(:disabled){transform:scale(1.06);box-shadow:0 0 0 2px #1565c02e}.sd-input-color__swatch:disabled{cursor:not-allowed;opacity:.5}.sd-input-color__swatch.sd-input-color__swatch--empty{background-color:#fff;background-image:var(--sd-input-color-swatch-checker);background-size:8px 8px;background-position:0 0,0 4px,4px -4px,-4px 0}.sd-input-color__hidden-picker{position:absolute;width:0;height:0;padding:0;border:0;opacity:0;pointer-events:none;right:0;top:50%}\n"] }]
|
|
125
136
|
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], helperText: [{ type: i0.Input, args: [{ isSignal: true, alias: "helperText", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], appearance: [{ type: i0.Input, args: [{ isSignal: true, alias: "appearance", required: false }] }], form: [{ type: i0.Input, args: [{ isSignal: true, alias: "form", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], autoId: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoId", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], clearable: [{ type: i0.Input, args: [{ isSignal: true, alias: "clearable", required: false }] }], hideInlineError: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideInlineError", required: false }] }], viewed: [{ type: i0.Input, args: [{ isSignal: true, alias: "viewed", required: false }] }], valueModel: [{ type: i0.Input, args: [{ isSignal: true, alias: "model", required: false }] }, { type: i0.Output, args: ["modelChange"] }], sdChange: [{ type: i0.Output, args: ["sdChange"] }], picker: [{ type: i0.ViewChild, args: ['picker', { isSignal: true }] }] } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdcorejs-angular-forms-input-color.mjs","sources":["../../../projects/sdcorejs-angular/forms/input-color/src/input-color.component.ts","../../../projects/sdcorejs-angular/forms/input-color/src/input-color.component.html","../../../projects/sdcorejs-angular/forms/input-color/sdcorejs-angular-forms-input-color.ts"],"sourcesContent":["import { booleanAttribute, ChangeDetectionStrategy, Component, computed, ElementRef, input, model, output, viewChild } from '@angular/core';\nimport { MatFormFieldAppearance } from '@angular/material/form-field';\nimport { SdInput } from '@sdcorejs/angular/forms/input';\nimport { SdSuffixDefDirective } from '@sdcorejs/angular/forms/directives';\nimport { SdViewed, SdViewedInput, sdViewedInline, sdViewedTransform } from '@sdcorejs/angular/forms/models';\nimport { Size } from '@sdcorejs/utils/models';\n\n// why: matches #RGB, #RRGGBB, #RRGGBBAA. Capital + lowercase hex allowed.\n// Native <input type=\"color\"> only emits #RRGGBB, so we canonicalize before\n// feeding the picker (expand 3-char, strip alpha) and let the swatch render\n// the raw model value when it's a valid hex.\nexport const SD_INPUT_COLOR_HEX_PATTERN = '^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$';\n\n@Component({\n selector: 'sd-input-color',\n standalone: true,\n imports: [SdInput, SdSuffixDefDirective],\n templateUrl: './input-color.component.html',\n styleUrl: './input-color.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class SdInputColor {\n readonly hexPattern = SD_INPUT_COLOR_HEX_PATTERN;\n readonly #hexRegex = new RegExp(SD_INPUT_COLOR_HEX_PATTERN);\n\n // ==========================================\n // Inputs (forwarded to <sd-input>)\n // ==========================================\n readonly label = input<string | undefined>();\n readonly helperText = input<string | undefined>();\n readonly placeholder = input<string>('#RRGGBB');\n readonly size = input<Size>('md');\n readonly appearance = input<MatFormFieldAppearance | undefined>(undefined);\n // why: type as `any` — the inner <sd-input> applies the FormGroup|NgForm transform.\n\n readonly form = input<any>(undefined);\n readonly name = input<string | undefined>();\n readonly autoId = input<string | undefined>();\n\n readonly required = input(false, { transform: booleanAttribute });\n readonly disabled = input(false, { transform: booleanAttribute });\n readonly readonly = input(false, { transform: booleanAttribute });\n /** Whether the inner `<sd-input>` should render its clear button. */\n readonly clearable = input(false, { transform: booleanAttribute });\n readonly hideInlineError = input(false, { transform: booleanAttribute });\n /** Display mode — forwarded to the inner `<sd-input>`. `'inline'` = borderless inline-edit; disabled `'inline'` → static. */\n readonly viewed = input<SdViewed, SdViewedInput>(false, { transform: sdViewedTransform });\n\n // Tri-state `viewed` — dùng chung primitive như các control khác thay vì so sánh thô.\n // why: `viewed` là tri-state (boolean | 'inline') và `'inline'` là TRUTHY. Guard cũ\n // `if (this.viewed()) return` trong openPicker()/clear() vì thế khoá luôn chế độ inline —\n // ở inline (vốn VẪN sửa được) thì bảng chọn màu của OS và clear() lập trình đều chết.\n // sdViewedInline cho isViewed() = đúng `true` (và hạ disabled+'inline' xuống static),\n // khớp với template vốn đã gate swatch bằng `viewed() === true`.\n readonly #viewedState = sdViewedInline(this.viewed, undefined, this.disabled);\n /** `true` when `viewed === true` (static view — no editor, no picker). */\n readonly isViewed = this.#viewedState.isViewed;\n /** `true` when `viewed === 'inline'` and the control is still editable. */\n readonly isInline = this.#viewedState.isInline;\n\n // Two-way model — same alias as <sd-input>\n readonly valueModel = model<string | null | undefined>(undefined, { alias: 'model' });\n\n // ==========================================\n // Outputs\n // ==========================================\n readonly sdChange = output<string | null | undefined>();\n\n // ==========================================\n // ViewChild\n // ==========================================\n readonly picker = viewChild<ElementRef<HTMLInputElement>>('picker');\n\n // ==========================================\n // Derived state\n // ==========================================\n // why: <input type=\"color\"> only accepts #RRGGBB. Expand 3-char hex; strip\n // alpha from 8-char. Fallback to #000000 for empty/invalid so the OS picker\n // always opens on something.\n readonly pickerSafeValue = computed<string>(() => {\n const v = this.valueModel();\n if (!v) return '#000000';\n if (/^#[0-9A-Fa-f]{6}$/.test(v)) return v;\n if (/^#[0-9A-Fa-f]{3}$/.test(v)) {\n const r = v[1];\n const g = v[2];\n const b = v[3];\n return `#${r}${r}${g}${g}${b}${b}`;\n }\n if (/^#[0-9A-Fa-f]{8}$/.test(v)) return v.slice(0, 7);\n return '#000000';\n });\n\n // Swatch shows the raw model value when valid; otherwise transparent so the\n // user gets visual feedback that the hex string is malformed.\n readonly swatchColor = computed<string>(() => {\n const v = this.valueModel();\n if (!v) return 'transparent';\n return this.#hexRegex.test(v) ? v : 'transparent';\n });\n\n // ==========================================\n // Handlers\n // ==========================================\n // why: <sd-input> built-in clear bắn null khi clear (thao tác chủ động) → coi\n // như \"không có màu\". Chuỗi rỗng cũng quy về null. Set model = null (không phải\n // undefined): undefined chỉ dành cho trạng thái pristine chưa từng thao tác.\n onInputChange = (v: unknown): void => {\n const str = v == null || v === '' ? null : String(v);\n this.valueModel.set(str);\n this.sdChange.emit(str);\n };\n\n openPicker = (): void => {\n if (this.disabled() || this.readonly() || this.isViewed()) return;\n this.picker()?.nativeElement.click();\n };\n\n onPickerChange = (ev: Event): void => {\n const v = (ev.target as HTMLInputElement).value;\n this.valueModel.set(v);\n this.sdChange.emit(v);\n };\n\n // why: nút clear hiển thị giờ do <sd-input> render. Giữ method public này cho\n // consumer gọi tay (programmatic). No-op khi không sửa được hoặc đã rỗng.\n clear = (ev?: Event): void => {\n ev?.stopPropagation();\n if (this.required() || this.disabled() || this.readonly() || this.isViewed()) return;\n const v = this.valueModel();\n if (v == null || v === '') return;\n this.valueModel.set(null);\n this.sdChange.emit(null);\n };\n}\n","<sd-input\n [label]=\"label()\"\n [helperText]=\"helperText()\"\n [placeholder]=\"placeholder()\"\n [size]=\"size()\"\n [appearance]=\"appearance() ?? undefined\"\n [form]=\"form()\"\n [name]=\"name() ?? ''\"\n [autoId]=\"autoId()\"\n [required]=\"required()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [clearable]=\"clearable()\"\n [hideInlineError]=\"hideInlineError()\"\n [viewed]=\"viewed()\"\n [pattern]=\"hexPattern\"\n patternErrorMessage=\"Mã màu HEX không hợp lệ (vd #1565C0)\"\n [model]=\"valueModel()\"\n (sdChange)=\"onInputChange($event)\">\n <ng-template sdSuffixDef>\n <div class=\"sd-input-color__suffix\">\n <!-- why: nút clear do <sd-input> tự render (built-in, hover-gated). Ở đây\n chỉ chiếu swatch + native picker. onInputChange coerce '' → null nên\n clear của sd-input vẫn cho ra model rỗng đúng nghĩa. -->\n <button\n type=\"button\"\n class=\"sd-input-color__swatch\"\n [style.background]=\"swatchColor()\"\n [class.sd-input-color__swatch--empty]=\"swatchColor() === 'transparent'\"\n [disabled]=\"disabled() || readonly() || isViewed()\"\n (click)=\"openPicker()\"\n title=\"Mở bảng chọn màu\"\n aria-label=\"Mở bảng chọn màu\"></button>\n <!-- why: GIỮ aria-hidden ở đây. Đây là proxy thuần: tabindex=\"-1\" (ngoài tab order),\n width/height 0, opacity 0, pointer-events:none — người dùng không thể tới được, và\n openPicker() chỉ .click() chứ không .focus(). Control thật là <button> ngay trên,\n đã có accessible name. Nếu bỏ aria-hidden, AT sẽ đọc thừa một \"color picker\" ma. -->\n <input\n #picker\n type=\"color\"\n class=\"sd-input-color__hidden-picker\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n [value]=\"pickerSafeValue()\"\n (input)=\"onPickerChange($event)\" />\n </div>\n </ng-template>\n</sd-input>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AA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;"}
|
|
1
|
+
{"version":3,"file":"sdcorejs-angular-forms-input-color.mjs","sources":["../../../projects/sdcorejs-angular/forms/input-color/src/input-color.component.ts","../../../projects/sdcorejs-angular/forms/input-color/src/input-color.component.html","../../../projects/sdcorejs-angular/forms/input-color/sdcorejs-angular-forms-input-color.ts"],"sourcesContent":["import { booleanAttribute, ChangeDetectionStrategy, Component, computed, ElementRef, input, model, output, viewChild } from '@angular/core';\nimport { MatFormFieldAppearance } from '@angular/material/form-field';\nimport { SdInput } from '@sdcorejs/angular/forms/input';\nimport { SdSuffixDefDirective } from '@sdcorejs/angular/forms/directives';\nimport { SdViewed, SdViewedInput, sdViewedInline, sdViewedTransform } from '@sdcorejs/angular/forms/models';\nimport { Size } from '@sdcorejs/utils/models';\n\n// why: matches #RGB, #RRGGBB, #RRGGBBAA. Capital + lowercase hex allowed.\n// Native <input type=\"color\"> only emits #RRGGBB, so we canonicalize before\n// feeding the picker (expand 3-char, strip alpha) and let the swatch render\n// the raw model value when it's a valid hex.\nexport const SD_INPUT_COLOR_HEX_PATTERN = '^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$';\n\n@Component({\n selector: 'sd-input-color',\n standalone: true,\n imports: [SdInput, SdSuffixDefDirective],\n templateUrl: './input-color.component.html',\n styleUrl: './input-color.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class SdInputColor {\n readonly hexPattern = SD_INPUT_COLOR_HEX_PATTERN;\n readonly #hexRegex = new RegExp(SD_INPUT_COLOR_HEX_PATTERN);\n\n // ==========================================\n // Inputs (forwarded to <sd-input>)\n // ==========================================\n readonly label = input<string | undefined>();\n readonly helperText = input<string | undefined>();\n readonly placeholder = input<string>('#RRGGBB');\n readonly size = input<Size>('md');\n readonly appearance = input<MatFormFieldAppearance | undefined>(undefined);\n // why: type as `any` — the inner <sd-input> applies the FormGroup|NgForm transform.\n\n readonly form = input<any>(undefined);\n readonly name = input<string | undefined>();\n readonly autoId = input<string | undefined>();\n\n readonly required = input(false, { transform: booleanAttribute });\n readonly disabled = input(false, { transform: booleanAttribute });\n readonly readonly = input(false, { transform: booleanAttribute });\n /** Whether the inner `<sd-input>` should render its clear button. */\n readonly clearable = input(false, { transform: booleanAttribute });\n readonly hideInlineError = input(false, { transform: booleanAttribute });\n /** Display mode — forwarded to the inner `<sd-input>`. `'inline'` = borderless inline-edit; disabled `'inline'` → static. */\n readonly viewed = input<SdViewed, SdViewedInput>(false, { transform: sdViewedTransform });\n\n // Tri-state `viewed` — dùng chung primitive như các control khác thay vì so sánh thô.\n // why: `viewed` là tri-state (boolean | 'inline') và `'inline'` là TRUTHY. Guard cũ\n // `if (this.viewed()) return` trong openPicker()/clear() vì thế khoá luôn chế độ inline —\n // ở inline (vốn VẪN sửa được) thì bảng chọn màu của OS và clear() lập trình đều chết.\n // sdViewedInline cho isViewed() = đúng `true` (và hạ disabled+'inline' xuống static),\n // khớp với template vốn đã gate swatch bằng `viewed() === true`.\n readonly #viewedState = sdViewedInline(this.viewed, undefined, this.disabled);\n /** `true` when `viewed === true` (static view — no editor, no picker). */\n readonly isViewed = this.#viewedState.isViewed;\n /** `true` when `viewed === 'inline'` and the control is still editable. */\n readonly isInline = this.#viewedState.isInline;\n\n // Two-way model — same alias as <sd-input>\n readonly valueModel = model<string | null | undefined>(undefined, { alias: 'model' });\n\n // ==========================================\n // Outputs\n // ==========================================\n readonly sdChange = output<string | null | undefined>();\n\n // ==========================================\n // ViewChild\n // ==========================================\n readonly picker = viewChild<ElementRef<HTMLInputElement>>('picker');\n\n // ==========================================\n // Derived state\n // ==========================================\n // why: <input type=\"color\"> only accepts #RRGGBB. Expand 3-char hex; strip\n // alpha from 8-char. Fallback to #000000 for empty/invalid so the OS picker\n // always opens on something.\n readonly pickerSafeValue = computed<string>(() => {\n const v = this.valueModel();\n if (!v) return '#000000';\n if (/^#[0-9A-Fa-f]{6}$/.test(v)) return v;\n if (/^#[0-9A-Fa-f]{3}$/.test(v)) {\n const r = v[1];\n const g = v[2];\n const b = v[3];\n return `#${r}${r}${g}${g}${b}${b}`;\n }\n if (/^#[0-9A-Fa-f]{8}$/.test(v)) return v.slice(0, 7);\n return '#000000';\n });\n\n // Swatch shows the raw model value when valid; otherwise transparent so the\n // user gets visual feedback that the hex string is malformed.\n readonly swatchColor = computed<string>(() => {\n const v = this.valueModel();\n if (!v) return 'transparent';\n return this.#hexRegex.test(v) ? v : 'transparent';\n });\n\n // ==========================================\n // Handlers\n // ==========================================\n // why: <sd-input> built-in clear bắn null khi clear (thao tác chủ động) → coi\n // như \"không có màu\". Chuỗi rỗng cũng quy về null. Set model = null (không phải\n // undefined): undefined chỉ dành cho trạng thái pristine chưa từng thao tác.\n onInputChange = (v: unknown): void => {\n const str = v == null || v === '' ? null : String(v);\n this.valueModel.set(str);\n this.sdChange.emit(str);\n };\n\n openPicker = (): void => {\n if (this.disabled() || this.readonly() || this.isViewed()) return;\n this.picker()?.nativeElement.click();\n };\n\n onPickerChange = (ev: Event): void => {\n const v = (ev.target as HTMLInputElement).value;\n this.valueModel.set(v);\n this.sdChange.emit(v);\n };\n\n // why: nút clear hiển thị giờ do <sd-input> render. Giữ method public này cho\n // consumer gọi tay (programmatic). No-op khi không sửa được hoặc đã rỗng.\n clear = (ev?: Event): void => {\n ev?.stopPropagation();\n if (this.required() || this.disabled() || this.readonly() || this.isViewed()) return;\n const v = this.valueModel();\n if (v == null || v === '') return;\n this.valueModel.set(null);\n this.sdChange.emit(null);\n };\n}\n","<sd-input\n [label]=\"label()\"\n [helperText]=\"helperText()\"\n [placeholder]=\"placeholder()\"\n [size]=\"size()\"\n [appearance]=\"appearance() ?? undefined\"\n [form]=\"form()\"\n [name]=\"name() ?? ''\"\n [autoId]=\"autoId()\"\n [required]=\"required()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [clearable]=\"clearable()\"\n [hideInlineError]=\"hideInlineError()\"\n [viewed]=\"viewed()\"\n [pattern]=\"hexPattern\"\n patternErrorMessage=\"Mã màu HEX không hợp lệ (vd #1565C0)\"\n [model]=\"valueModel()\"\n (sdChange)=\"onInputChange($event)\">\n <ng-template sdSuffixDef>\n <div class=\"sd-input-color__suffix\">\n <!-- why: nút clear do <sd-input> tự render (built-in, hover-gated). Ở đây\n chỉ chiếu swatch + native picker. onInputChange coerce '' → null nên\n clear của sd-input vẫn cho ra model rỗng đúng nghĩa. -->\n <button\n type=\"button\"\n class=\"sd-input-color__swatch\"\n [style.background]=\"swatchColor()\"\n [class.sd-input-color__swatch--empty]=\"swatchColor() === 'transparent'\"\n [disabled]=\"disabled() || readonly() || isViewed()\"\n (click)=\"openPicker()\"\n title=\"Mở bảng chọn màu\"\n aria-label=\"Mở bảng chọn màu\"></button>\n <!-- why: GIỮ aria-hidden ở đây. Đây là proxy thuần: tabindex=\"-1\" (ngoài tab order),\n width/height 0, opacity 0, pointer-events:none — người dùng không thể tới được, và\n openPicker() chỉ .click() chứ không .focus(). Control thật là <button> ngay trên,\n đã có accessible name. Nếu bỏ aria-hidden, AT sẽ đọc thừa một \"color picker\" ma. -->\n <input\n #picker\n type=\"color\"\n class=\"sd-input-color__hidden-picker\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n [value]=\"pickerSafeValue()\"\n (input)=\"onPickerChange($event)\" />\n </div>\n </ng-template>\n</sd-input>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAOA;AACA;AACA;AACA;AACO,MAAM,0BAA0B,GAAG;MAU7B,YAAY,CAAA;IACd,UAAU,GAAG,0BAA0B;AACvC,IAAA,SAAS,GAAG,IAAI,MAAM,CAAC,0BAA0B,CAAC;;;;AAKlD,IAAA,KAAK,GAAG,KAAK;yFAAsB;AACnC,IAAA,UAAU,GAAG,KAAK;8FAAsB;IACxC,WAAW,GAAG,KAAK,CAAS,SAAS;oFAAC;IACtC,IAAI,GAAG,KAAK,CAAO,IAAI;6EAAC;IACxB,UAAU,GAAG,KAAK,CAAqC,SA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