@molecule/app-ui-angular 1.0.5 → 1.1.1
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/README.md +11742 -1145
- package/dist/components/accordion.component.d.ts +114 -0
- package/dist/components/accordion.component.d.ts.map +1 -0
- package/dist/components/accordion.component.js +286 -0
- package/dist/components/accordion.component.js.map +1 -0
- package/dist/components/alert.component.d.ts +81 -37
- package/dist/components/alert.component.d.ts.map +1 -1
- package/dist/components/alert.component.js +232 -146
- package/dist/components/alert.component.js.map +1 -1
- package/dist/components/auth-guard.component.d.ts +94 -0
- package/dist/components/auth-guard.component.d.ts.map +1 -0
- package/dist/components/auth-guard.component.js +212 -0
- package/dist/components/auth-guard.component.js.map +1 -0
- package/dist/components/avatar.component.d.ts +97 -0
- package/dist/components/avatar.component.d.ts.map +1 -0
- package/dist/components/avatar.component.js +216 -0
- package/dist/components/avatar.component.js.map +1 -0
- package/dist/components/badge.component.d.ts +27 -12
- package/dist/components/badge.component.d.ts.map +1 -1
- package/dist/components/badge.component.js +47 -47
- package/dist/components/badge.component.js.map +1 -1
- package/dist/components/button.component.d.ts +96 -14
- package/dist/components/button.component.d.ts.map +1 -1
- package/dist/components/button.component.js +232 -87
- package/dist/components/button.component.js.map +1 -1
- package/dist/components/card.component.d.ts +135 -0
- package/dist/components/card.component.d.ts.map +1 -0
- package/dist/components/card.component.js +291 -0
- package/dist/components/card.component.js.map +1 -0
- package/dist/components/checkbox.component.d.ts +102 -29
- package/dist/components/checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox.component.js +222 -113
- package/dist/components/checkbox.component.js.map +1 -1
- package/dist/components/confirm-button.component.d.ts +130 -0
- package/dist/components/confirm-button.component.d.ts.map +1 -0
- package/dist/components/confirm-button.component.js +322 -0
- package/dist/components/confirm-button.component.js.map +1 -0
- package/dist/components/confirm-dialog.component.d.ts +60 -0
- package/dist/components/confirm-dialog.component.d.ts.map +1 -0
- package/dist/components/confirm-dialog.component.js +152 -0
- package/dist/components/confirm-dialog.component.js.map +1 -0
- package/dist/components/dropdown.component.d.ts +313 -0
- package/dist/components/dropdown.component.d.ts.map +1 -0
- package/dist/components/dropdown.component.js +919 -0
- package/dist/components/dropdown.component.js.map +1 -0
- package/dist/components/empty-state.component.d.ts +73 -0
- package/dist/components/empty-state.component.d.ts.map +1 -0
- package/dist/components/empty-state.component.js +180 -0
- package/dist/components/empty-state.component.js.map +1 -0
- package/dist/components/floating-input.component.d.ts +86 -0
- package/dist/components/floating-input.component.d.ts.map +1 -0
- package/dist/components/floating-input.component.js +167 -0
- package/dist/components/floating-input.component.js.map +1 -0
- package/dist/components/form-field.component.d.ts +111 -0
- package/dist/components/form-field.component.d.ts.map +1 -0
- package/dist/components/form-field.component.js +300 -0
- package/dist/components/form-field.component.js.map +1 -0
- package/dist/components/form.component.d.ts +77 -0
- package/dist/components/form.component.d.ts.map +1 -0
- package/dist/components/form.component.js +222 -0
- package/dist/components/form.component.js.map +1 -0
- package/dist/components/icon.component.d.ts +85 -0
- package/dist/components/icon.component.d.ts.map +1 -0
- package/dist/components/icon.component.js +187 -0
- package/dist/components/icon.component.js.map +1 -0
- package/dist/components/index.d.ts +49 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +49 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/input.component.d.ts +157 -54
- package/dist/components/input.component.d.ts.map +1 -1
- package/dist/components/input.component.js +437 -222
- package/dist/components/input.component.js.map +1 -1
- package/dist/components/label.component.d.ts +29 -0
- package/dist/components/label.component.d.ts.map +1 -0
- package/dist/components/label.component.js +60 -0
- package/dist/components/label.component.js.map +1 -0
- package/dist/components/language-picker.component.d.ts +124 -0
- package/dist/components/language-picker.component.d.ts.map +1 -0
- package/dist/components/language-picker.component.js +305 -0
- package/dist/components/language-picker.component.js.map +1 -0
- package/dist/components/layout.component.d.ts +167 -0
- package/dist/components/layout.component.d.ts.map +1 -0
- package/dist/components/layout.component.js +364 -0
- package/dist/components/layout.component.js.map +1 -0
- package/dist/components/load-error-banner.component.d.ts +103 -0
- package/dist/components/load-error-banner.component.d.ts.map +1 -0
- package/dist/components/load-error-banner.component.js +263 -0
- package/dist/components/load-error-banner.component.js.map +1 -0
- package/dist/components/modal.component.d.ts +125 -95
- package/dist/components/modal.component.d.ts.map +1 -1
- package/dist/components/modal.component.js +458 -271
- package/dist/components/modal.component.js.map +1 -1
- package/dist/components/molecule/alert.component.d.ts +77 -0
- package/dist/components/molecule/alert.component.d.ts.map +1 -0
- package/dist/components/molecule/alert.component.js +229 -0
- package/dist/components/molecule/alert.component.js.map +1 -0
- package/dist/components/molecule/badge.component.d.ts +27 -0
- package/dist/components/molecule/badge.component.d.ts.map +1 -0
- package/dist/components/molecule/badge.component.js +79 -0
- package/dist/components/molecule/badge.component.js.map +1 -0
- package/dist/components/molecule/button.component.d.ts +38 -0
- package/dist/components/molecule/button.component.d.ts.map +1 -0
- package/dist/components/molecule/button.component.js +137 -0
- package/dist/components/molecule/button.component.js.map +1 -0
- package/dist/components/molecule/checkbox.component.d.ts +53 -0
- package/dist/components/molecule/checkbox.component.d.ts.map +1 -0
- package/dist/components/molecule/checkbox.component.js +166 -0
- package/dist/components/molecule/checkbox.component.js.map +1 -0
- package/dist/components/molecule/index.d.ts +18 -0
- package/dist/components/molecule/index.d.ts.map +1 -0
- package/dist/components/molecule/index.js +18 -0
- package/dist/components/molecule/index.js.map +1 -0
- package/dist/components/molecule/input.component.d.ts +93 -0
- package/dist/components/molecule/input.component.d.ts.map +1 -0
- package/dist/components/molecule/input.component.js +314 -0
- package/dist/components/molecule/input.component.js.map +1 -0
- package/dist/components/molecule/modal.component.d.ts +148 -0
- package/dist/components/molecule/modal.component.d.ts.map +1 -0
- package/dist/components/molecule/modal.component.js +382 -0
- package/dist/components/molecule/modal.component.js.map +1 -0
- package/dist/components/molecule/radio-group.component.d.ts +63 -0
- package/dist/components/molecule/radio-group.component.d.ts.map +1 -0
- package/dist/components/molecule/radio-group.component.js +208 -0
- package/dist/components/molecule/radio-group.component.js.map +1 -0
- package/dist/components/molecule/select.component.d.ts +72 -0
- package/dist/components/molecule/select.component.d.ts.map +1 -0
- package/dist/components/molecule/select.component.js +274 -0
- package/dist/components/molecule/select.component.js.map +1 -0
- package/dist/components/molecule/spinner.component.d.ts +42 -0
- package/dist/components/molecule/spinner.component.d.ts.map +1 -0
- package/dist/components/molecule/spinner.component.js +122 -0
- package/dist/components/molecule/spinner.component.js.map +1 -0
- package/dist/components/molecule/switch.component.d.ts +54 -0
- package/dist/components/molecule/switch.component.d.ts.map +1 -0
- package/dist/components/molecule/switch.component.js +148 -0
- package/dist/components/molecule/switch.component.js.map +1 -0
- package/dist/components/molecule/toast.component.d.ts +98 -0
- package/dist/components/molecule/toast.component.d.ts.map +1 -0
- package/dist/components/molecule/toast.component.js +305 -0
- package/dist/components/molecule/toast.component.js.map +1 -0
- package/dist/components/molecule/tooltip.component.d.ts +77 -0
- package/dist/components/molecule/tooltip.component.d.ts.map +1 -0
- package/dist/components/molecule/tooltip.component.js +316 -0
- package/dist/components/molecule/tooltip.component.js.map +1 -0
- package/dist/components/optimistic-toggle-button.component.d.ts +125 -0
- package/dist/components/optimistic-toggle-button.component.d.ts.map +1 -0
- package/dist/components/optimistic-toggle-button.component.js +296 -0
- package/dist/components/optimistic-toggle-button.component.js.map +1 -0
- package/dist/components/page-header.component.d.ts +77 -0
- package/dist/components/page-header.component.d.ts.map +1 -0
- package/dist/components/page-header.component.js +225 -0
- package/dist/components/page-header.component.js.map +1 -0
- package/dist/components/page-shell.component.d.ts +101 -0
- package/dist/components/page-shell.component.d.ts.map +1 -0
- package/dist/components/page-shell.component.js +221 -0
- package/dist/components/page-shell.component.js.map +1 -0
- package/dist/components/pagination.component.d.ts +137 -0
- package/dist/components/pagination.component.d.ts.map +1 -0
- package/dist/components/pagination.component.js +419 -0
- package/dist/components/pagination.component.js.map +1 -0
- package/dist/components/panel-close.component.d.ts +43 -0
- package/dist/components/panel-close.component.d.ts.map +1 -0
- package/dist/components/panel-close.component.js +75 -0
- package/dist/components/panel-close.component.js.map +1 -0
- package/dist/components/progress.component.d.ts +84 -0
- package/dist/components/progress.component.d.ts.map +1 -0
- package/dist/components/progress.component.js +219 -0
- package/dist/components/progress.component.js.map +1 -0
- package/dist/components/prompt-dialog.component.d.ts +121 -0
- package/dist/components/prompt-dialog.component.d.ts.map +1 -0
- package/dist/components/prompt-dialog.component.js +332 -0
- package/dist/components/prompt-dialog.component.js.map +1 -0
- package/dist/components/radio-group.component.d.ts +66 -34
- package/dist/components/radio-group.component.d.ts.map +1 -1
- package/dist/components/radio-group.component.js +146 -125
- package/dist/components/radio-group.component.js.map +1 -1
- package/dist/components/responsive-app-shell.component.d.ts +408 -0
- package/dist/components/responsive-app-shell.component.d.ts.map +1 -0
- package/dist/components/responsive-app-shell.component.js +1144 -0
- package/dist/components/responsive-app-shell.component.js.map +1 -0
- package/dist/components/select.component.d.ts +135 -38
- package/dist/components/select.component.d.ts.map +1 -1
- package/dist/components/select.component.js +373 -181
- package/dist/components/select.component.js.map +1 -1
- package/dist/components/separator.component.d.ts +39 -0
- package/dist/components/separator.component.d.ts.map +1 -0
- package/dist/components/separator.component.js +73 -0
- package/dist/components/separator.component.js.map +1 -0
- package/dist/components/sidebar-user-card.component.d.ts +106 -0
- package/dist/components/sidebar-user-card.component.d.ts.map +1 -0
- package/dist/components/sidebar-user-card.component.js +277 -0
- package/dist/components/sidebar-user-card.component.js.map +1 -0
- package/dist/components/skeleton.component.d.ts +100 -0
- package/dist/components/skeleton.component.d.ts.map +1 -0
- package/dist/components/skeleton.component.js +214 -0
- package/dist/components/skeleton.component.js.map +1 -0
- package/dist/components/spinner.component.d.ts +36 -19
- package/dist/components/spinner.component.d.ts.map +1 -1
- package/dist/components/spinner.component.js +69 -71
- package/dist/components/spinner.component.js.map +1 -1
- package/dist/components/switch.component.d.ts +72 -29
- package/dist/components/switch.component.d.ts.map +1 -1
- package/dist/components/switch.component.js +163 -91
- package/dist/components/switch.component.js.map +1 -1
- package/dist/components/table.component.d.ts +193 -0
- package/dist/components/table.component.d.ts.map +1 -0
- package/dist/components/table.component.js +550 -0
- package/dist/components/table.component.js.map +1 -0
- package/dist/components/tabs.component.d.ts +140 -0
- package/dist/components/tabs.component.d.ts.map +1 -0
- package/dist/components/tabs.component.js +390 -0
- package/dist/components/tabs.component.js.map +1 -0
- package/dist/components/template-outlet.directive.d.ts +50 -0
- package/dist/components/template-outlet.directive.d.ts.map +1 -0
- package/dist/components/template-outlet.directive.js +81 -0
- package/dist/components/template-outlet.directive.js.map +1 -0
- package/dist/components/textarea.component.d.ts +151 -0
- package/dist/components/textarea.component.d.ts.map +1 -0
- package/dist/components/textarea.component.js +340 -0
- package/dist/components/textarea.component.js.map +1 -0
- package/dist/components/theme-toggle.component.d.ts +58 -0
- package/dist/components/theme-toggle.component.d.ts.map +1 -0
- package/dist/components/theme-toggle.component.js +124 -0
- package/dist/components/theme-toggle.component.js.map +1 -0
- package/dist/components/toast.component.d.ts +237 -49
- package/dist/components/toast.component.d.ts.map +1 -1
- package/dist/components/toast.component.js +636 -201
- package/dist/components/toast.component.js.map +1 -1
- package/dist/components/tooltip.component.d.ts +95 -45
- package/dist/components/tooltip.component.d.ts.map +1 -1
- package/dist/components/tooltip.component.js +372 -221
- package/dist/components/tooltip.component.js.map +1 -1
- package/dist/components/user-menu-popover.component.d.ts +283 -0
- package/dist/components/user-menu-popover.component.d.ts.map +1 -0
- package/dist/components/user-menu-popover.component.js +646 -0
- package/dist/components/user-menu-popover.component.js.map +1 -0
- package/dist/components/user-menu.component.d.ts +95 -0
- package/dist/components/user-menu.component.d.ts.map +1 -0
- package/dist/components/user-menu.component.js +218 -0
- package/dist/components/user-menu.component.js.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-is-desktop.d.ts +22 -0
- package/dist/hooks/use-is-desktop.d.ts.map +1 -0
- package/dist/hooks/use-is-desktop.js +37 -0
- package/dist/hooks/use-is-desktop.js.map +1 -0
- package/dist/index.d.ts +32 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -17
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utilities/dom-context.d.ts +42 -0
- package/dist/utilities/dom-context.d.ts.map +1 -0
- package/dist/utilities/dom-context.js +66 -0
- package/dist/utilities/dom-context.js.map +1 -0
- package/dist/utilities/focus.d.ts +32 -0
- package/dist/utilities/focus.d.ts.map +1 -0
- package/dist/utilities/focus.js +47 -0
- package/dist/utilities/focus.js.map +1 -0
- package/dist/utilities/form-field-context.d.ts +34 -0
- package/dist/utilities/form-field-context.d.ts.map +1 -0
- package/dist/utilities/form-field-context.js +28 -0
- package/dist/utilities/form-field-context.js.map +1 -0
- package/dist/utilities/form-submit-error.d.ts +17 -0
- package/dist/utilities/form-submit-error.d.ts.map +1 -0
- package/dist/utilities/form-submit-error.js +42 -0
- package/dist/utilities/form-submit-error.js.map +1 -0
- package/dist/utilities/icon-markup.d.ts +17 -0
- package/dist/utilities/icon-markup.d.ts.map +1 -0
- package/dist/utilities/icon-markup.js +46 -0
- package/dist/utilities/icon-markup.js.map +1 -0
- package/dist/utilities/ids.d.ts +15 -0
- package/dist/utilities/ids.d.ts.map +1 -0
- package/dist/utilities/ids.js +19 -0
- package/dist/utilities/ids.js.map +1 -0
- package/dist/utilities/index.d.ts +11 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +11 -0
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/initials.d.ts +13 -0
- package/dist/utilities/initials.d.ts.map +1 -0
- package/dist/utilities/initials.js +23 -0
- package/dist/utilities/initials.js.map +1 -0
- package/dist/utilities/node-value.d.ts +31 -0
- package/dist/utilities/node-value.d.ts.map +1 -0
- package/dist/utilities/node-value.js +37 -0
- package/dist/utilities/node-value.js.map +1 -0
- package/dist/utilities/optimistic-value.d.ts +81 -0
- package/dist/utilities/optimistic-value.d.ts.map +1 -0
- package/dist/utilities/optimistic-value.js +154 -0
- package/dist/utilities/optimistic-value.js.map +1 -0
- package/dist/utilities/render-icon.d.ts +77 -7
- package/dist/utilities/render-icon.d.ts.map +1 -1
- package/dist/utilities/render-icon.js +123 -33
- package/dist/utilities/render-icon.js.map +1 -1
- package/dist/utilities/rest-attrs.d.ts +21 -0
- package/dist/utilities/rest-attrs.d.ts.map +1 -0
- package/dist/utilities/rest-attrs.js +37 -0
- package/dist/utilities/rest-attrs.js.map +1 -0
- package/dist/utilities/style.d.ts +23 -0
- package/dist/utilities/style.d.ts.map +1 -0
- package/dist/utilities/style.js +86 -0
- package/dist/utilities/style.js.map +1 -0
- package/package.json +10 -5
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a `TemplateRef` where the host element sits (Angular's
|
|
3
|
+
* `NgTemplateOutlet` without the `@angular/common` dependency).
|
|
4
|
+
*
|
|
5
|
+
* Used for node-valued props the adapter passes as `TemplateRef`s: a data
|
|
6
|
+
* prop's `icon` (`items[0].icon`), render functions, or a node that must be
|
|
7
|
+
* placed inside a template's own structure rather than projected directly.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { Directive, inject, Input, ViewContainerRef, } from '@angular/core';
|
|
12
|
+
import * as i0 from "@angular/core";
|
|
13
|
+
/**
|
|
14
|
+
* Instantiates a template at the directive's host position and re-instantiates
|
|
15
|
+
* it when the template changes.
|
|
16
|
+
*/
|
|
17
|
+
export class MolTemplateOutlet {
|
|
18
|
+
vcr = inject(ViewContainerRef);
|
|
19
|
+
current = null;
|
|
20
|
+
view;
|
|
21
|
+
/** The live context object shared with the rendered view. */
|
|
22
|
+
context = {};
|
|
23
|
+
/**
|
|
24
|
+
* The template to render (a React node value in template form).
|
|
25
|
+
*
|
|
26
|
+
* @param template - The template, or null/undefined to render nothing.
|
|
27
|
+
*/
|
|
28
|
+
set molTemplateOutlet(template) {
|
|
29
|
+
if (template === this.current)
|
|
30
|
+
return;
|
|
31
|
+
this.current = template ?? null;
|
|
32
|
+
this.view?.destroy();
|
|
33
|
+
this.view = undefined;
|
|
34
|
+
if (this.current)
|
|
35
|
+
this.view = this.vcr.createEmbeddedView(this.current, this.context);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The template context (React's render-function arguments, e.g. a table
|
|
39
|
+
* cell's `{ $implicit, a0, a1, a2 }`). The properties of the view's own
|
|
40
|
+
* context object are updated in place — replacing the object is deprecated.
|
|
41
|
+
*
|
|
42
|
+
* @param context - The context object.
|
|
43
|
+
*/
|
|
44
|
+
set molTemplateOutletContext(context) {
|
|
45
|
+
const next = context ?? {};
|
|
46
|
+
for (const key of Object.keys(this.context)) {
|
|
47
|
+
if (!(key in next))
|
|
48
|
+
delete this.context[key];
|
|
49
|
+
}
|
|
50
|
+
Object.assign(this.context, next);
|
|
51
|
+
this.view?.markForCheck();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The current template context.
|
|
55
|
+
* @returns The context object.
|
|
56
|
+
*/
|
|
57
|
+
get molTemplateOutletContext() {
|
|
58
|
+
return this.context;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The template currently rendered.
|
|
62
|
+
* @returns The template, or null.
|
|
63
|
+
*/
|
|
64
|
+
get molTemplateOutlet() {
|
|
65
|
+
return this.current;
|
|
66
|
+
}
|
|
67
|
+
static ɵfac = function MolTemplateOutlet_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MolTemplateOutlet)(); };
|
|
68
|
+
static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: MolTemplateOutlet, selectors: [["", "molTemplateOutlet", ""]], inputs: { molTemplateOutlet: "molTemplateOutlet", molTemplateOutletContext: "molTemplateOutletContext" } });
|
|
69
|
+
}
|
|
70
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MolTemplateOutlet, [{
|
|
71
|
+
type: Directive,
|
|
72
|
+
args: [{
|
|
73
|
+
selector: '[molTemplateOutlet]',
|
|
74
|
+
standalone: true,
|
|
75
|
+
}]
|
|
76
|
+
}], null, { molTemplateOutlet: [{
|
|
77
|
+
type: Input
|
|
78
|
+
}], molTemplateOutletContext: [{
|
|
79
|
+
type: Input
|
|
80
|
+
}] }); })();
|
|
81
|
+
//# sourceMappingURL=template-outlet.directive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-outlet.directive.js","sourceRoot":"","sources":["../../src/components/template-outlet.directive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,SAAS,EAET,MAAM,EACN,KAAK,EAEL,gBAAgB,GACjB,MAAM,eAAe,CAAA;;AAEtB;;;GAGG;AAKH,MAAM,OAAO,iBAAiB;IACX,GAAG,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACvC,OAAO,GAAgC,IAAI,CAAA;IAC3C,IAAI,CAA2B;IACvC,6DAA6D;IACrD,OAAO,GAA4B,EAAE,CAAA;IAE7C;;;;OAIG;IACH,IAAa,iBAAiB,CAAC,QAAiD;QAC9E,IAAI,QAAQ,KAAK,IAAI,CAAC,OAAO;YAAE,OAAM;QACrC,IAAI,CAAC,OAAO,GAAG,QAAQ,IAAI,IAAI,CAAA;QAC/B,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAA;QACrB,IAAI,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IACvF,CAAC;IAED;;;;;;OAMG;IACH,IAAa,wBAAwB,CAAC,OAAmD;QACvF,MAAM,IAAI,GAAG,OAAO,IAAI,EAAE,CAAA;QAC1B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC9C,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QACjC,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,CAAA;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAI,wBAAwB;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED;;;OAGG;IACH,IAAI,iBAAiB;QACnB,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;2GAlDU,iBAAiB;6DAAjB,iBAAiB;;iFAAjB,iBAAiB;cAJ7B,SAAS;eAAC;gBACT,QAAQ,EAAE,qBAAqB;gBAC/B,UAAU,EAAE,IAAI;aACjB;;kBAaE,KAAK;;kBAeL,KAAK"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Textarea component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type AfterViewChecked, type AfterViewInit, ElementRef, EventEmitter } from '@angular/core';
|
|
7
|
+
import type { Size, UIClassMap } from '@molecule/app-ui';
|
|
8
|
+
import type { FormFieldContext } from '../utilities/form-field-context.js';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
/**
|
|
11
|
+
* Textarea component.
|
|
12
|
+
*
|
|
13
|
+
* The host is the `div.inputWrapper` React renders. React's textarea
|
|
14
|
+
* `onChange` fires on `input` events; a controlled `value` is restored after
|
|
15
|
+
* user input exactly like React's controlled-input state restore.
|
|
16
|
+
* `autoResize` recomputes the inline height after every check and on real
|
|
17
|
+
* `input` events (matching React's effect + native listener pair).
|
|
18
|
+
*/
|
|
19
|
+
export declare class Textarea implements AfterViewInit, AfterViewChecked {
|
|
20
|
+
/** Textarea size. */
|
|
21
|
+
size?: Size;
|
|
22
|
+
/** Field label. */
|
|
23
|
+
label?: string;
|
|
24
|
+
/** Error message (associates via aria-describedby). */
|
|
25
|
+
error?: string;
|
|
26
|
+
/** Hint text (shown without an error). */
|
|
27
|
+
hint?: string;
|
|
28
|
+
/** Whether the box resizes to its content. */
|
|
29
|
+
autoResize?: boolean;
|
|
30
|
+
/** Minimum rendered rows (autoResize floor). */
|
|
31
|
+
minRows?: number;
|
|
32
|
+
/** Maximum rendered rows (autoResize ceiling). */
|
|
33
|
+
maxRows?: number;
|
|
34
|
+
/** Extra classes joined onto the textarea classes. */
|
|
35
|
+
className?: string;
|
|
36
|
+
/** Inline style object (React camelCase). */
|
|
37
|
+
style?: Record<string, unknown>;
|
|
38
|
+
/** `data-testid` for the textarea. */
|
|
39
|
+
testId?: string;
|
|
40
|
+
/** Disables the textarea. */
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
/** Marks the textarea required (label styling). */
|
|
43
|
+
required?: boolean;
|
|
44
|
+
/** Controlled value. */
|
|
45
|
+
value?: string;
|
|
46
|
+
/** Uncontrolled initial value. */
|
|
47
|
+
defaultValue?: string;
|
|
48
|
+
/** Placeholder text. */
|
|
49
|
+
placeholder?: string;
|
|
50
|
+
/** Form field name. */
|
|
51
|
+
name?: string;
|
|
52
|
+
/** Explicit textarea id. */
|
|
53
|
+
id?: string;
|
|
54
|
+
/** Explicit rows attribute. */
|
|
55
|
+
rows?: number;
|
|
56
|
+
/** Fires the raw `input` event (React's textarea onChange). */
|
|
57
|
+
readonly change: EventEmitter<Event>;
|
|
58
|
+
/** The native textarea (React's `...rest` spread target). */
|
|
59
|
+
textareaEl?: ElementRef<HTMLTextAreaElement>;
|
|
60
|
+
private readonly host;
|
|
61
|
+
/** The `aria-describedby` the caller spread onto the host (React's rest). */
|
|
62
|
+
private restDescribedBy;
|
|
63
|
+
/** Whether the rest-describedby value was captured. */
|
|
64
|
+
private restDescribedByCaptured;
|
|
65
|
+
/**
|
|
66
|
+
* The current class map.
|
|
67
|
+
* @returns The UIClassMap.
|
|
68
|
+
*/
|
|
69
|
+
cm(): UIClassMap;
|
|
70
|
+
/**
|
|
71
|
+
* The textarea id (`id`, `name`, or a stable generated id; the DOM
|
|
72
|
+
* normalizer renumbers generated ids in order of appearance, like React's
|
|
73
|
+
* `useId`).
|
|
74
|
+
* @returns The id value.
|
|
75
|
+
*/
|
|
76
|
+
textareaId(): string;
|
|
77
|
+
/**
|
|
78
|
+
* The aria-describedby target (error or hint paragraph).
|
|
79
|
+
* @returns The id or null.
|
|
80
|
+
*/
|
|
81
|
+
describedBy(): string | null;
|
|
82
|
+
/**
|
|
83
|
+
* The nearest enclosing `FormField` context (React's cloned props).
|
|
84
|
+
* @returns The context, or null.
|
|
85
|
+
*/
|
|
86
|
+
fieldContext(): FormFieldContext | null;
|
|
87
|
+
/**
|
|
88
|
+
* The final `aria-describedby`: a rest-provided value first, then the
|
|
89
|
+
* enclosing FormField's error/hint target (React's cloneElement join).
|
|
90
|
+
* @returns The attribute value, or null.
|
|
91
|
+
*/
|
|
92
|
+
mergedDescribedBy(): string | null;
|
|
93
|
+
/**
|
|
94
|
+
* Computes the textarea class list.
|
|
95
|
+
* @returns The class string.
|
|
96
|
+
*/
|
|
97
|
+
classes(): string;
|
|
98
|
+
/**
|
|
99
|
+
* Serializes the inline style for the textarea: `autoResize` neutralizes the
|
|
100
|
+
* bond's min-height class (`minHeight: 0`, `resize: none`) and the caller's
|
|
101
|
+
* style still wins, exactly like React's spread.
|
|
102
|
+
* @returns The style attribute text.
|
|
103
|
+
*/
|
|
104
|
+
hostStyle(): string | null;
|
|
105
|
+
/**
|
|
106
|
+
* React's textarea onChange: the `input` event, with the controlled value
|
|
107
|
+
* restored afterwards and the autoResize height recomputed (React listens
|
|
108
|
+
* for native `input` events on the element itself).
|
|
109
|
+
*
|
|
110
|
+
* @param event - The native input event.
|
|
111
|
+
*/
|
|
112
|
+
handleInput(event: Event): void;
|
|
113
|
+
/**
|
|
114
|
+
* The native change event never reaches the host (its `change` output
|
|
115
|
+
* binding would record it a second time; React's onChange already fired on
|
|
116
|
+
* the input event).
|
|
117
|
+
*
|
|
118
|
+
* @param event - The native change event.
|
|
119
|
+
*/
|
|
120
|
+
handleChange(event: Event): void;
|
|
121
|
+
/**
|
|
122
|
+
* Sizes the box to its content: React's `resize()` — height `auto`, then
|
|
123
|
+
* clamp `scrollHeight` between `minRows * lineHeight` and
|
|
124
|
+
* `maxRows * lineHeight` (`lineHeight` falls back to 20 when the computed
|
|
125
|
+
* value does not parse, matching React's `parseInt(...) || 20`).
|
|
126
|
+
*/
|
|
127
|
+
resize(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Moves rest attributes onto the textarea, applies the initial value (React
|
|
130
|
+
* sets a textarea's value through the PROPERTY — the `value` attribute is
|
|
131
|
+
* never rendered) and runs the first autoResize pass (React's mount effect).
|
|
132
|
+
*/
|
|
133
|
+
ngAfterViewInit(): void;
|
|
134
|
+
/**
|
|
135
|
+
* Re-applies a controlled value and recomputes the autoResize height after
|
|
136
|
+
* every check (React re-runs the value effect whenever `value` changes;
|
|
137
|
+
* running here covers that and any other input change in one place).
|
|
138
|
+
*/
|
|
139
|
+
ngAfterViewChecked(): void;
|
|
140
|
+
/**
|
|
141
|
+
* Writes the value to the textarea's value property: the controlled
|
|
142
|
+
* `value` every check, the `defaultValue` only at mount (uncontrolled
|
|
143
|
+
* typing afterwards is the user's, exactly like React).
|
|
144
|
+
*
|
|
145
|
+
* @param initial - Whether this is the mount pass.
|
|
146
|
+
*/
|
|
147
|
+
private applyValue;
|
|
148
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<Textarea, never>;
|
|
149
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<Textarea, "div[mol-textarea]", never, { "size": { "alias": "size"; "required": false; }; "label": { "alias": "label"; "required": false; }; "error": { "alias": "error"; "required": false; }; "hint": { "alias": "hint"; "required": false; }; "autoResize": { "alias": "autoResize"; "required": false; }; "minRows": { "alias": "minRows"; "required": false; }; "maxRows": { "alias": "maxRows"; "required": false; }; "className": { "alias": "className"; "required": false; }; "style": { "alias": "style"; "required": false; }; "testId": { "alias": "testId"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "required": { "alias": "required"; "required": false; }; "value": { "alias": "value"; "required": false; }; "defaultValue": { "alias": "defaultValue"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "name": { "alias": "name"; "required": false; }; "id": { "alias": "id"; "required": false; }; "rows": { "alias": "rows"; "required": false; }; }, { "change": "change"; }, never, never, true, never>;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=textarea.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textarea.component.d.ts","sourceRoot":"","sources":["../../src/components/textarea.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAElB,UAAU,EACV,YAAY,EAIb,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;;AAK1E;;;;;;;;GAQG;AACH,qBAwDa,QAAS,YAAW,aAAa,EAAE,gBAAgB;IAC9D,qBAAqB;IACrB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,8CAA8C;IAC9C,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MA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AAE,KAAK,GAAG,IAAI;IAS/B;;;;;;OAMG;IACH,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAIhC;;;;;OAKG;IACH,MAAM,IAAI,IAAI;IAWd;;;;OAIG;IACH,eAAe,IAAI,IAAI;IAUvB;;;;OAIG;IACH,kBAAkB,IAAI,IAAI;IAK1B;;;;;;OAMG;IACH,OAAO,CAAC,UAAU;yCAjMP,QAAQ;2CAAR,QAAQ;CA2MpB"}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Textarea component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Component, ElementRef, EventEmitter, inject, Output, ViewChild, } from '@angular/core';
|
|
7
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
8
|
+
import { fieldContext } from '../utilities/form-field-context.js';
|
|
9
|
+
import { moveRestAttributes } from '../utilities/rest-attrs.js';
|
|
10
|
+
import { styleText } from '../utilities/style.js';
|
|
11
|
+
import * as i0 from "@angular/core";
|
|
12
|
+
const _c0 = ["textareaEl"];
|
|
13
|
+
const _c1 = a0 => ({ required: a0 });
|
|
14
|
+
function Textarea_Conditional_0_Template(rf, ctx) { if (rf & 1) {
|
|
15
|
+
i0.ɵɵdomElementStart(0, "label");
|
|
16
|
+
i0.ɵɵtext(1);
|
|
17
|
+
i0.ɵɵdomElementEnd();
|
|
18
|
+
} if (rf & 2) {
|
|
19
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
20
|
+
i0.ɵɵclassMap(ctx_r0.cm().cn(ctx_r0.cm().label(i0.ɵɵpureFunction1(4, _c1, !!ctx_r0.required)), ctx_r0.cm().labelBlock));
|
|
21
|
+
i0.ɵɵattribute("for", ctx_r0.textareaId());
|
|
22
|
+
i0.ɵɵadvance();
|
|
23
|
+
i0.ɵɵtextInterpolate(ctx_r0.label);
|
|
24
|
+
} }
|
|
25
|
+
function Textarea_Conditional_3_Template(rf, ctx) { if (rf & 1) {
|
|
26
|
+
i0.ɵɵdomElementStart(0, "p");
|
|
27
|
+
i0.ɵɵtext(1);
|
|
28
|
+
i0.ɵɵdomElementEnd();
|
|
29
|
+
} if (rf & 2) {
|
|
30
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
31
|
+
i0.ɵɵclassMap(ctx_r0.cm().formError);
|
|
32
|
+
i0.ɵɵattribute("id", ctx_r0.textareaId() + "-error");
|
|
33
|
+
i0.ɵɵadvance();
|
|
34
|
+
i0.ɵɵtextInterpolate(ctx_r0.error);
|
|
35
|
+
} }
|
|
36
|
+
function Textarea_Conditional_4_Template(rf, ctx) { if (rf & 1) {
|
|
37
|
+
i0.ɵɵdomElementStart(0, "p");
|
|
38
|
+
i0.ɵɵtext(1);
|
|
39
|
+
i0.ɵɵdomElementEnd();
|
|
40
|
+
} if (rf & 2) {
|
|
41
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
42
|
+
i0.ɵɵclassMap(ctx_r0.cm().formHint);
|
|
43
|
+
i0.ɵɵattribute("id", ctx_r0.textareaId() + "-hint");
|
|
44
|
+
i0.ɵɵadvance();
|
|
45
|
+
i0.ɵɵtextInterpolate(ctx_r0.hint);
|
|
46
|
+
} }
|
|
47
|
+
/**
|
|
48
|
+
* Textarea component.
|
|
49
|
+
*
|
|
50
|
+
* The host is the `div.inputWrapper` React renders. React's textarea
|
|
51
|
+
* `onChange` fires on `input` events; a controlled `value` is restored after
|
|
52
|
+
* user input exactly like React's controlled-input state restore.
|
|
53
|
+
* `autoResize` recomputes the inline height after every check and on real
|
|
54
|
+
* `input` events (matching React's effect + native listener pair).
|
|
55
|
+
*/
|
|
56
|
+
export class Textarea {
|
|
57
|
+
/** Textarea size. */
|
|
58
|
+
size;
|
|
59
|
+
/** Field label. */
|
|
60
|
+
label;
|
|
61
|
+
/** Error message (associates via aria-describedby). */
|
|
62
|
+
error;
|
|
63
|
+
/** Hint text (shown without an error). */
|
|
64
|
+
hint;
|
|
65
|
+
/** Whether the box resizes to its content. */
|
|
66
|
+
autoResize;
|
|
67
|
+
/** Minimum rendered rows (autoResize floor). */
|
|
68
|
+
minRows;
|
|
69
|
+
/** Maximum rendered rows (autoResize ceiling). */
|
|
70
|
+
maxRows;
|
|
71
|
+
/** Extra classes joined onto the textarea classes. */
|
|
72
|
+
className;
|
|
73
|
+
/** Inline style object (React camelCase). */
|
|
74
|
+
style;
|
|
75
|
+
/** `data-testid` for the textarea. */
|
|
76
|
+
testId;
|
|
77
|
+
/** Disables the textarea. */
|
|
78
|
+
disabled;
|
|
79
|
+
/** Marks the textarea required (label styling). */
|
|
80
|
+
required;
|
|
81
|
+
/** Controlled value. */
|
|
82
|
+
value;
|
|
83
|
+
/** Uncontrolled initial value. */
|
|
84
|
+
defaultValue;
|
|
85
|
+
/** Placeholder text. */
|
|
86
|
+
placeholder;
|
|
87
|
+
/** Form field name. */
|
|
88
|
+
name;
|
|
89
|
+
/** Explicit textarea id. */
|
|
90
|
+
id;
|
|
91
|
+
/** Explicit rows attribute. */
|
|
92
|
+
rows;
|
|
93
|
+
/** Fires the raw `input` event (React's textarea onChange). */
|
|
94
|
+
change = new EventEmitter();
|
|
95
|
+
/** The native textarea (React's `...rest` spread target). */
|
|
96
|
+
textareaEl;
|
|
97
|
+
host = inject(ElementRef);
|
|
98
|
+
/** The `aria-describedby` the caller spread onto the host (React's rest). */
|
|
99
|
+
restDescribedBy = null;
|
|
100
|
+
/** Whether the rest-describedby value was captured. */
|
|
101
|
+
restDescribedByCaptured = false;
|
|
102
|
+
/**
|
|
103
|
+
* The current class map.
|
|
104
|
+
* @returns The UIClassMap.
|
|
105
|
+
*/
|
|
106
|
+
cm() {
|
|
107
|
+
return getClassMap();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The textarea id (`id`, `name`, or a stable generated id; the DOM
|
|
111
|
+
* normalizer renumbers generated ids in order of appearance, like React's
|
|
112
|
+
* `useId`).
|
|
113
|
+
* @returns The id value.
|
|
114
|
+
*/
|
|
115
|
+
textareaId() {
|
|
116
|
+
return this.id || this.fieldContext()?.id || this.name || 'r0';
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The aria-describedby target (error or hint paragraph).
|
|
120
|
+
* @returns The id or null.
|
|
121
|
+
*/
|
|
122
|
+
describedBy() {
|
|
123
|
+
if (this.error)
|
|
124
|
+
return `${this.textareaId()}-error`;
|
|
125
|
+
if (this.hint)
|
|
126
|
+
return `${this.textareaId()}-hint`;
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The nearest enclosing `FormField` context (React's cloned props).
|
|
131
|
+
* @returns The context, or null.
|
|
132
|
+
*/
|
|
133
|
+
fieldContext() {
|
|
134
|
+
return fieldContext(this.host.nativeElement);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The final `aria-describedby`: a rest-provided value first, then the
|
|
138
|
+
* enclosing FormField's error/hint target (React's cloneElement join).
|
|
139
|
+
* @returns The attribute value, or null.
|
|
140
|
+
*/
|
|
141
|
+
mergedDescribedBy() {
|
|
142
|
+
const target = this.fieldContext()?.describedBy;
|
|
143
|
+
if (target)
|
|
144
|
+
return [this.restDescribedBy, target].filter(Boolean).join(' ');
|
|
145
|
+
return this.restDescribedBy ?? this.describedBy();
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Computes the textarea class list.
|
|
149
|
+
* @returns The class string.
|
|
150
|
+
*/
|
|
151
|
+
classes() {
|
|
152
|
+
return this.cm().cn(this.cm().textarea({ error: !!this.error, size: this.size }), this.className);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Serializes the inline style for the textarea: `autoResize` neutralizes the
|
|
156
|
+
* bond's min-height class (`minHeight: 0`, `resize: none`) and the caller's
|
|
157
|
+
* style still wins, exactly like React's spread.
|
|
158
|
+
* @returns The style attribute text.
|
|
159
|
+
*/
|
|
160
|
+
hostStyle() {
|
|
161
|
+
return styleText(this.autoResize ? { minHeight: 0, resize: 'none', ...this.style } : this.style);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* React's textarea onChange: the `input` event, with the controlled value
|
|
165
|
+
* restored afterwards and the autoResize height recomputed (React listens
|
|
166
|
+
* for native `input` events on the element itself).
|
|
167
|
+
*
|
|
168
|
+
* @param event - The native input event.
|
|
169
|
+
*/
|
|
170
|
+
handleInput(event) {
|
|
171
|
+
event.stopPropagation();
|
|
172
|
+
this.change.emit(event);
|
|
173
|
+
const textarea = this.textareaEl?.nativeElement;
|
|
174
|
+
if (this.value !== undefined && textarea && textarea.value !== this.value)
|
|
175
|
+
textarea.value = this.value;
|
|
176
|
+
this.resize();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The native change event never reaches the host (its `change` output
|
|
180
|
+
* binding would record it a second time; React's onChange already fired on
|
|
181
|
+
* the input event).
|
|
182
|
+
*
|
|
183
|
+
* @param event - The native change event.
|
|
184
|
+
*/
|
|
185
|
+
handleChange(event) {
|
|
186
|
+
event.stopPropagation();
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Sizes the box to its content: React's `resize()` — height `auto`, then
|
|
190
|
+
* clamp `scrollHeight` between `minRows * lineHeight` and
|
|
191
|
+
* `maxRows * lineHeight` (`lineHeight` falls back to 20 when the computed
|
|
192
|
+
* value does not parse, matching React's `parseInt(...) || 20`).
|
|
193
|
+
*/
|
|
194
|
+
resize() {
|
|
195
|
+
const element = this.textareaEl?.nativeElement;
|
|
196
|
+
if (!this.autoResize || !element)
|
|
197
|
+
return;
|
|
198
|
+
element.style.height = 'auto';
|
|
199
|
+
const lineHeight = parseInt(window.getComputedStyle(element).lineHeight) || 20;
|
|
200
|
+
const minHeight = (this.minRows ?? 3) * lineHeight;
|
|
201
|
+
const maxHeight = this.maxRows ? this.maxRows * lineHeight : Infinity;
|
|
202
|
+
const newHeight = Math.min(Math.max(element.scrollHeight, minHeight), maxHeight);
|
|
203
|
+
element.style.height = `${newHeight}px`;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Moves rest attributes onto the textarea, applies the initial value (React
|
|
207
|
+
* sets a textarea's value through the PROPERTY — the `value` attribute is
|
|
208
|
+
* never rendered) and runs the first autoResize pass (React's mount effect).
|
|
209
|
+
*/
|
|
210
|
+
ngAfterViewInit() {
|
|
211
|
+
if (!this.restDescribedByCaptured) {
|
|
212
|
+
this.restDescribedBy = this.host.nativeElement.getAttribute('aria-describedby');
|
|
213
|
+
this.restDescribedByCaptured = true;
|
|
214
|
+
}
|
|
215
|
+
moveRestAttributes(this.host.nativeElement, this.textareaEl?.nativeElement);
|
|
216
|
+
this.applyValue(true);
|
|
217
|
+
this.resize();
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Re-applies a controlled value and recomputes the autoResize height after
|
|
221
|
+
* every check (React re-runs the value effect whenever `value` changes;
|
|
222
|
+
* running here covers that and any other input change in one place).
|
|
223
|
+
*/
|
|
224
|
+
ngAfterViewChecked() {
|
|
225
|
+
this.applyValue(false);
|
|
226
|
+
this.resize();
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Writes the value to the textarea's value property: the controlled
|
|
230
|
+
* `value` every check, the `defaultValue` only at mount (uncontrolled
|
|
231
|
+
* typing afterwards is the user's, exactly like React).
|
|
232
|
+
*
|
|
233
|
+
* @param initial - Whether this is the mount pass.
|
|
234
|
+
*/
|
|
235
|
+
applyValue(initial) {
|
|
236
|
+
const textarea = this.textareaEl?.nativeElement;
|
|
237
|
+
if (!textarea)
|
|
238
|
+
return;
|
|
239
|
+
if (this.value !== undefined) {
|
|
240
|
+
const next = String(this.value);
|
|
241
|
+
if (textarea.value !== next)
|
|
242
|
+
textarea.value = next;
|
|
243
|
+
}
|
|
244
|
+
else if (initial && this.defaultValue !== undefined && textarea.value === '') {
|
|
245
|
+
textarea.value = String(this.defaultValue);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
static ɵfac = function Textarea_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Textarea)(); };
|
|
249
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Textarea, selectors: [["div", "mol-textarea", ""]], viewQuery: function Textarea_Query(rf, ctx) { if (rf & 1) {
|
|
250
|
+
i0.ɵɵviewQuery(_c0, 5);
|
|
251
|
+
} if (rf & 2) {
|
|
252
|
+
let _t;
|
|
253
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.textareaEl = _t.first);
|
|
254
|
+
} }, hostVars: 2, hostBindings: function Textarea_HostBindings(rf, ctx) { if (rf & 2) {
|
|
255
|
+
i0.ɵɵclassMap(ctx.cm().inputWrapper);
|
|
256
|
+
} }, inputs: { size: "size", label: "label", error: "error", hint: "hint", autoResize: "autoResize", minRows: "minRows", maxRows: "maxRows", className: "className", style: "style", testId: "testId", disabled: "disabled", required: "required", value: "value", defaultValue: "defaultValue", placeholder: "placeholder", name: "name", id: "id", rows: "rows" }, outputs: { change: "change" }, decls: 5, vars: 15, consts: [["textareaEl", ""], [3, "class"], [3, "input", "change", "disabled"]], template: function Textarea_Template(rf, ctx) { if (rf & 1) {
|
|
257
|
+
i0.ɵɵconditionalCreate(0, Textarea_Conditional_0_Template, 2, 6, "label", 1);
|
|
258
|
+
i0.ɵɵdomElementStart(1, "textarea", 2, 0);
|
|
259
|
+
i0.ɵɵdomListener("input", function Textarea_Template_textarea_input_1_listener($event) { return ctx.handleInput($event); })("change", function Textarea_Template_textarea_change_1_listener($event) { return ctx.handleChange($event); });
|
|
260
|
+
i0.ɵɵdomElementEnd();
|
|
261
|
+
i0.ɵɵconditionalCreate(3, Textarea_Conditional_3_Template, 2, 4, "p", 1);
|
|
262
|
+
i0.ɵɵconditionalCreate(4, Textarea_Conditional_4_Template, 2, 4, "p", 1);
|
|
263
|
+
} if (rf & 2) {
|
|
264
|
+
i0.ɵɵconditional(ctx.label ? 0 : -1);
|
|
265
|
+
i0.ɵɵadvance();
|
|
266
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
267
|
+
i0.ɵɵdomProperty("disabled", ctx.disabled);
|
|
268
|
+
i0.ɵɵattribute("id", ctx.textareaId())("name", ctx.name)("placeholder", ctx.placeholder)("required", ctx.required ? "" : null)("rows", ctx.rows || ctx.minRows || 3)("aria-invalid", ctx.error || ctx.fieldContext()?.invalid ? "true" : "false")("aria-describedby", ctx.mergedDescribedBy())("style", ctx.hostStyle(), i0.ɵɵsanitizeStyle)("data-testid", ctx.testId);
|
|
269
|
+
i0.ɵɵadvance(2);
|
|
270
|
+
i0.ɵɵconditional(ctx.error ? 3 : -1);
|
|
271
|
+
i0.ɵɵadvance();
|
|
272
|
+
i0.ɵɵconditional(ctx.hint && !ctx.error ? 4 : -1);
|
|
273
|
+
} }, encapsulation: 2 });
|
|
274
|
+
}
|
|
275
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Textarea, [{
|
|
276
|
+
type: Component,
|
|
277
|
+
args: [{
|
|
278
|
+
selector: 'div[mol-textarea]',
|
|
279
|
+
standalone: true,
|
|
280
|
+
inputs: [
|
|
281
|
+
'size',
|
|
282
|
+
'label',
|
|
283
|
+
'error',
|
|
284
|
+
'hint',
|
|
285
|
+
'autoResize',
|
|
286
|
+
'minRows',
|
|
287
|
+
'maxRows',
|
|
288
|
+
'className',
|
|
289
|
+
'style',
|
|
290
|
+
'testId',
|
|
291
|
+
'disabled',
|
|
292
|
+
'required',
|
|
293
|
+
'value',
|
|
294
|
+
'defaultValue',
|
|
295
|
+
'placeholder',
|
|
296
|
+
'name',
|
|
297
|
+
'id',
|
|
298
|
+
'rows',
|
|
299
|
+
],
|
|
300
|
+
host: {
|
|
301
|
+
'[class]': 'cm().inputWrapper',
|
|
302
|
+
},
|
|
303
|
+
template: `@if (label) {
|
|
304
|
+
<label
|
|
305
|
+
[attr.for]="textareaId()"
|
|
306
|
+
[class]="cm().cn(cm().label({ required: !!required }), cm().labelBlock)"
|
|
307
|
+
>{{ label }}</label
|
|
308
|
+
>
|
|
309
|
+
}
|
|
310
|
+
<textarea
|
|
311
|
+
[attr.id]="textareaId()"
|
|
312
|
+
[attr.name]="name"
|
|
313
|
+
[attr.placeholder]="placeholder"
|
|
314
|
+
[disabled]="disabled"
|
|
315
|
+
[attr.required]="required ? '' : null"
|
|
316
|
+
[attr.rows]="rows || minRows || 3"
|
|
317
|
+
[attr.aria-invalid]="error || fieldContext()?.invalid ? 'true' : 'false'"
|
|
318
|
+
[attr.aria-describedby]="mergedDescribedBy()"
|
|
319
|
+
[class]="classes()"
|
|
320
|
+
[attr.style]="hostStyle()"
|
|
321
|
+
[attr.data-testid]="testId"
|
|
322
|
+
(input)="handleInput($event)"
|
|
323
|
+
(change)="handleChange($event)"
|
|
324
|
+
#textareaEl
|
|
325
|
+
></textarea>
|
|
326
|
+
@if (error) {
|
|
327
|
+
<p [attr.id]="textareaId() + '-error'" [class]="cm().formError">{{ error }}</p>
|
|
328
|
+
}
|
|
329
|
+
@if (hint && !error) {
|
|
330
|
+
<p [attr.id]="textareaId() + '-hint'" [class]="cm().formHint">{{ hint }}</p>
|
|
331
|
+
}`,
|
|
332
|
+
}]
|
|
333
|
+
}], null, { change: [{
|
|
334
|
+
type: Output
|
|
335
|
+
}], textareaEl: [{
|
|
336
|
+
type: ViewChild,
|
|
337
|
+
args: ['textareaEl']
|
|
338
|
+
}] }); })();
|
|
339
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Textarea, { className: "Textarea", filePath: "components/textarea.component.ts", lineNumber: 91 }); })();
|
|
340
|
+
//# sourceMappingURL=textarea.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textarea.component.js","sourceRoot":"","sources":["../../src/components/textarea.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,MAAM,EACN,MAAM,EACN,SAAS,GACV,MAAM,eAAe,C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,KAAK,EAAE,EAAE,CAAC;YAC/E,QAAQ,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC;kGA1MU,QAAQ;6DAAR,QAAQ;;;;;;YAAR,cAAA,QAAI,cAAI;;YA9BR,4EAAa;YAOtB,yCAeC;YAFC,AADA,gGAAS,uBAAmB,IAAC,kFACnB,wBAAoB,IAAC;YAEhC,oBAAW;YACZ,wEAAa;YAGb,wEAAsB;;YA1Bb,oCAMR;YAUC,cAAmB;YAAnB,4BAAmB;YALnB,0CAAqB;;YAYvB,eAEC;YAFD,oCAEC;YACD,cAEC;YAFD,iDAEC;;;iFAEQ,QAAQ;cAxDpB,SAAS;eAAC;gBACT,QAAQ,EAAE,mBAAmB;gBAC7B,UAAU,EAAE,IAAI;gBAChB,MAAM,EAAE;oBACN,MAAM;oBACN,OAAO;oBACP,OAAO;oBACP,MAAM;oBACN,YAAY;oBACZ,SAAS;oBACT,SAAS;oBACT,WAAW;oBACX,OAAO;oBACP,QAAQ;oBACR,UAAU;oBACV,UAAU;oBACV,OAAO;oBACP,cAAc;oBACd,aAAa;oBACb,MAAM;oBACN,IAAI;oBACJ,MAAM;iBACP;gBACD,IAAI,EAAE;oBACJ,SAAS,EAAE,mBAAmB;iBAC/B;gBACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4BN;aACL;;kBAwCE,MAAM;;kBAGN,SAAS;mBAAC,YAAY;;kFA1CZ,QAAQ"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { IconName } from '@molecule/app-icons';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* ThemeToggle component.
|
|
5
|
+
*
|
|
6
|
+
* Button that flips the wired theme bond between light and dark. The host is
|
|
7
|
+
* the `<button>` itself (`button[mol-theme-toggle]`), matching React's root
|
|
8
|
+
* exactly. Ships React's conventions out of the box: `data-mol-id`,
|
|
9
|
+
* `data-mode`, `aria-pressed` and the `theme.toggle` i18n `aria-label`.
|
|
10
|
+
* Extra attributes (`data-*`, `title`, …) land on the host — React's spread
|
|
11
|
+
* target — and unknown props like `disabled` bind the host attribute
|
|
12
|
+
* directly, so the browser suppresses the click exactly as React does.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ThemeToggle {
|
|
15
|
+
/** i18n key for the `aria-label` (default `theme.toggle`). */
|
|
16
|
+
ariaLabelKey?: string;
|
|
17
|
+
/** Fallback `aria-label` if the i18n key is missing. */
|
|
18
|
+
ariaLabelDefault?: string;
|
|
19
|
+
/** Icon name rendered in dark mode (default `moon`). */
|
|
20
|
+
darkIcon?: IconName;
|
|
21
|
+
/** Icon name rendered in light mode (default `sun`). */
|
|
22
|
+
lightIcon?: IconName;
|
|
23
|
+
/** Pixel size for the rendered icon (default 20). */
|
|
24
|
+
iconSize?: number;
|
|
25
|
+
/** Extra classes joined onto the toggle classes. */
|
|
26
|
+
className?: string;
|
|
27
|
+
/** Theme state and actions, read in the component's injection context. */
|
|
28
|
+
readonly theme: import("@molecule/app-angular").UseThemeResult;
|
|
29
|
+
/**
|
|
30
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
31
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
32
|
+
* does not).
|
|
33
|
+
*/
|
|
34
|
+
private readonly i18n;
|
|
35
|
+
/**
|
|
36
|
+
* The current theme mode.
|
|
37
|
+
* @returns `'light'` or `'dark'`.
|
|
38
|
+
*/
|
|
39
|
+
mode(): 'light' | 'dark';
|
|
40
|
+
/**
|
|
41
|
+
* The localized `aria-label`.
|
|
42
|
+
* @returns The translated label text.
|
|
43
|
+
*/
|
|
44
|
+
labelText(): string;
|
|
45
|
+
/**
|
|
46
|
+
* Computes the toggle class list.
|
|
47
|
+
* @returns The class string.
|
|
48
|
+
*/
|
|
49
|
+
classes(): string;
|
|
50
|
+
/**
|
|
51
|
+
* The rendered icon pixel size.
|
|
52
|
+
* @returns The size (default 20 when a later-bound write left it unset).
|
|
53
|
+
*/
|
|
54
|
+
iconSizePx(): number;
|
|
55
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ThemeToggle, never>;
|
|
56
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ThemeToggle, "button[mol-theme-toggle]", never, { "ariaLabelKey": { "alias": "ariaLabelKey"; "required": false; }; "ariaLabelDefault": { "alias": "ariaLabelDefault"; "required": false; }; "darkIcon": { "alias": "darkIcon"; "required": false; }; "lightIcon": { "alias": "lightIcon"; "required": false; }; "iconSize": { "alias": "iconSize"; "required": false; }; "className": { "alias": "className"; "required": false; }; }, {}, never, never, true, never>;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=theme-toggle.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-toggle.component.d.ts","sourceRoot":"","sources":["../../src/components/theme-toggle.component.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;;AAMnD;;;;;;;;;;GAUG;AACH,qBAoBa,WAAW;IACtB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wDAAwD;IACxD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,wDAAwD;IACxD,SAAS,CAAC,EAAE,QAAQ,CAAA;IACpB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,iDAAa;IAE3B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmB;IAExC;;;OAGG;IACH,IAAI,IAAI,OAAO,GAAG,MAAM;IAIxB;;;OAGG;IACH,SAAS,IAAI,MAAM;IAUnB;;;OAGG;IACH,OAAO,IAAI,MAAM;IAKjB;;;OAGG;IACH,UAAU,IAAI,MAAM;yCA3DT,WAAW;2CAAX,WAAW;CA8DvB"}
|