import * as i0 from '@angular/core';
import { input, booleanAttribute, output, inject, ElementRef, Injector, runInInjectionContext, effect, ChangeDetectionStrategy, Component } from '@angular/core';
import '@ui5/webcomponents/dist/TextArea.js';
import * as i1 from '@fundamental-ngx/ui5-webcomponents/utils';
import { GenericControlValueAccessor } from '@fundamental-ngx/ui5-webcomponents/utils';

class TextArea {
    constructor() {
        /**
         * Defines the value of the component.
         */
        this.value = input("", ...(ngDevMode ? [{ debugName: "value" }] : []));
        /**
         * Indicates whether the user can interact with the component or not.
      
      **Note:** A disabled component is completely noninteractive.
         */
        this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines whether the component is read-only.
      
      **Note:** A read-only component is not editable,
      but still provides visual feedback upon user interaction.
         */
        this.readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines whether the component is required.
         */
        this.required = input(false, ...(ngDevMode ? [{ debugName: "required", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines a short hint intended to aid the user with data entry when the component has no value.
         */
        this.placeholder = input(...(ngDevMode ? [undefined, { debugName: "placeholder" }] : []));
        /**
         * Defines the value state of the component.
      
      **Note:** If `maxlength` property is set,
      the component turns into "Critical" state once the characters exceeds the limit.
      In this case, only the "Negative" state is considered and can be applied.
         */
        this.valueState = input("None", ...(ngDevMode ? [{ debugName: "valueState" }] : []));
        /**
         * Defines the number of visible text rows for the component.
      
      **Notes:**
      
      - If the `growing` property is enabled, this property defines the minimum rows to be displayed
      in the textarea.
      - The CSS `height` property wins over the `rows` property, if both are set.
         */
        this.rows = input(0, ...(ngDevMode ? [{ debugName: "rows" }] : []));
        /**
         * Defines the maximum number of characters that the `value` can have.
         */
        this.maxlength = input(...(ngDevMode ? [undefined, { debugName: "maxlength" }] : []));
        /**
         * Determines whether the characters exceeding the maximum allowed character count are visible
      in the component.
      
      If set to `false`, the user is not allowed to enter more characters than what is set in the
      `maxlength` property.
      If set to `true` the characters exceeding the `maxlength` value are selected on
      paste and the counter below the component displays their number.
         */
        this.showExceededText = input(false, ...(ngDevMode ? [{ debugName: "showExceededText", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Enables the component to automatically grow and shrink dynamically with its content.
         */
        this.growing = input(false, ...(ngDevMode ? [{ debugName: "growing", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines the maximum number of rows that the component can grow.
         */
        this.growingMaxRows = input(0, ...(ngDevMode ? [{ debugName: "growingMaxRows" }] : []));
        /**
         * Determines the name by which the component will be identified upon submission in an HTML form.
      
      **Note:** This property is only applicable within the context of an HTML Form element.
         */
        this.name = input(...(ngDevMode ? [undefined, { debugName: "name" }] : []));
        /**
         * Defines the accessible ARIA name of the component.
         */
        this.accessibleName = input(...(ngDevMode ? [undefined, { debugName: "accessibleName" }] : []));
        /**
         * Receives id(or many ids) of the elements that label the textarea.
         */
        this.accessibleNameRef = input(...(ngDevMode ? [undefined, { debugName: "accessibleNameRef" }] : []));
        /**
         * Defines the accessible description of the component.
         */
        this.accessibleDescription = input(...(ngDevMode ? [undefined, { debugName: "accessibleDescription" }] : []));
        /**
         * Receives id(or many ids) of the elements that describe the textarea.
         */
        this.accessibleDescriptionRef = input(...(ngDevMode ? [undefined, { debugName: "accessibleDescriptionRef" }] : [])); // className is now passed
        /**
         * Fired when the text has changed and the focus leaves the component.
         */
        this.ui5Change = output();
        /**
         * Fired when the value of the component changes at each keystroke or when
      something is pasted.
         */
        this.ui5Input = output();
        /**
         * Fired when some text has been selected.
         */
        this.ui5Select = output();
        /**
         * Fired when textarea is scrolled.
         */
        this.ui5Scroll = output();
        /**
         * Available slots for content projection in this component.
         *
         * Slots allow you to insert custom content into predefined areas of the web component.
         * Use the `slot` attribute on child elements to target specific slots.
         *
         * - **valueStateMessage**: Defines the value state message that will be displayed as pop up under the component.
      The value state message slot should contain only one root element.
       
      **Note:** If not specified, a default text (in the respective language) will be displayed.
      
      **Note:** The `valueStateMessage` would be displayed if the component has
      `valueState` of type `Information`, `Critical` or `Negative`.
         *
         * @example
         * ```html
         * <ui5-textarea>
         *   <div slot="header">Custom header content</div>
         *   <p>Default slot content</p>
         * </ui5-textarea>
         * ```
         *
         * @readonly
         * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_templates_and_slots | MDN Web Components Slots}
         */
        this.slots = [
            {
                "name": "valueStateMessage",
                "description": "Defines the value state message that will be displayed as pop up under the component.\nThe value state message slot should contain only one root element.\n \n**Note:** If not specified, a default text (in the respective language) will be displayed.\n\n**Note:** The `valueStateMessage` would be displayed if the component has\n`valueState` of type `Information`, `Critical` or `Negative`.",
                "since": "1.0.0-rc.7"
            }
        ];
        this.elementRef = inject(ElementRef);
        this.injector = inject(Injector);
    }
    get element() {
        return this.elementRef.nativeElement;
    }
    ngAfterViewInit() {
        const wcElement = this.element;
        const inputsToSync = [
            'value',
            'disabled',
            'readonly',
            'required',
            'placeholder',
            'valueState',
            'rows',
            'maxlength',
            'showExceededText',
            'growing',
            'growingMaxRows',
            'name',
            'accessibleName',
            'accessibleNameRef',
            'accessibleDescription',
            'accessibleDescriptionRef',
        ];
        // Synchronize inputs (properties)
        for (const inputName of inputsToSync) {
            // Find the corresponding camelCase signal property on the Angular component
            const signalName = inputName.replace(/-./g, (x) => x[1].toUpperCase());
            // Use the Injector to run the effect in the correct context
            if (this[signalName] && typeof this[signalName] === 'function') {
                runInInjectionContext(this.injector, () => {
                    effect(() => {
                        // Read the signal value
                        const value = this[signalName]();
                        if (wcElement) {
                            // Write the value to the Web Component's property
                            wcElement[inputName] = value;
                        }
                    });
                });
            }
        }
        const outputsToSync = [
            'ui5Change',
            'ui5Input',
            'ui5Select',
            'ui5Scroll',
        ];
        // Synchronize outputs (events)
        for (const outputName of outputsToSync) {
            // Map Angular output name to UI5 web component event name
            const eventName = outputName.replace('ui5', '').replace(/([A-Z])/g, '-$1').toLowerCase().substring(1);
            // Ensure the output property exists and has an emit function before adding listener
            if (this[outputName] && typeof this[outputName].emit === 'function' && wcElement.addEventListener) {
                // Cast the listener to the correct type to satisfy TypeScript
                wcElement.addEventListener(eventName, (e) => {
                    this[outputName].emit(e);
                });
            }
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: TextArea, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.1.4", type: TextArea, isStandalone: true, selector: "ui5-textarea, [ui5-textarea]", inputs: { value: { classPropertyName: "value", publicName: "value", 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 }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, valueState: { classPropertyName: "valueState", publicName: "valueState", isSignal: true, isRequired: false, transformFunction: null }, rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: false, transformFunction: null }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, showExceededText: { classPropertyName: "showExceededText", publicName: "showExceededText", isSignal: true, isRequired: false, transformFunction: null }, growing: { classPropertyName: "growing", publicName: "growing", isSignal: true, isRequired: false, transformFunction: null }, growingMaxRows: { classPropertyName: "growingMaxRows", publicName: "growingMaxRows", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, accessibleName: { classPropertyName: "accessibleName", publicName: "accessibleName", isSignal: true, isRequired: false, transformFunction: null }, accessibleNameRef: { classPropertyName: "accessibleNameRef", publicName: "accessibleNameRef", isSignal: true, isRequired: false, transformFunction: null }, accessibleDescription: { classPropertyName: "accessibleDescription", publicName: "accessibleDescription", isSignal: true, isRequired: false, transformFunction: null }, accessibleDescriptionRef: { classPropertyName: "accessibleDescriptionRef", publicName: "accessibleDescriptionRef", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ui5Change: "ui5Change", ui5Input: "ui5Input", ui5Select: "ui5Select", ui5Scroll: "ui5Scroll" }, exportAs: ["ui5TextArea"], hostDirectives: [{ directive: i1.GenericControlValueAccessor }], ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: TextArea, decorators: [{
            type: Component,
            args: [{
                    standalone: true,
                    selector: 'ui5-textarea, [ui5-textarea]',
                    template: '<ng-content></ng-content>',
                    exportAs: 'ui5TextArea',
                    hostDirectives: [GenericControlValueAccessor],
                    changeDetection: ChangeDetectionStrategy.OnPush,
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { TextArea };
//# sourceMappingURL=fundamental-ngx-ui5-webcomponents-text-area.mjs.map
