{"version":3,"file":"ng-primitives-textarea.mjs","sources":["../../../../packages/ng-primitives/textarea/src/textarea/textarea-state.ts","../../../../packages/ng-primitives/textarea/src/textarea/textarea.ts","../../../../packages/ng-primitives/textarea/src/ng-primitives-textarea.ts"],"sourcesContent":["import { computed, Signal, signal, WritableSignal } from '@angular/core';\nimport { ngpFormControl } from 'ng-primitives/form-field';\nimport { ngpInteractions } from 'ng-primitives/interactions';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { attrBinding, controlled, createPrimitive } from 'ng-primitives/state';\nimport { uniqueId } from 'ng-primitives/utils';\n\n/**\n * Public state surface for the Textarea primitive.\n */\nexport interface NgpTextareaState {\n  /**\n   * The id of the textarea.\n   */\n  readonly id: Signal<string>;\n  /**\n   * Whether the textarea is disabled.\n   */\n  readonly disabled: WritableSignal<boolean>;\n\n  /**\n   * Set the disabled state of the textarea.\n   */\n  setDisabled(disabled: boolean): void;\n}\n\n/**\n * Inputs for configuring the Textarea primitive.\n */\nexport interface NgpTextareaProps {\n  /**\n   * The id of the textarea.\n   */\n  readonly id?: Signal<string>;\n  /**\n   * Whether the textarea is disabled.\n   */\n  readonly disabled?: Signal<boolean>;\n}\n\nexport const [NgpTextareaStateToken, ngpTextarea, injectTextareaState, provideTextareaState] =\n  createPrimitive(\n    'NgpTextarea',\n    ({\n      id = signal(uniqueId('ngp-textarea')),\n      disabled: _disabled = signal(false),\n    }: NgpTextareaProps) => {\n      const element = injectElementRef();\n      const disabled = controlled(_disabled);\n\n      // Setup form control bindings first so we can incorporate the form\n      // control's disabled status (e.g. a disabled ReactiveForms control).\n      const status = ngpFormControl({ id, disabled });\n      const isDisabled = computed(() => status().disabled ?? disabled());\n\n      ngpInteractions({ hover: true, press: true, focus: true, disabled: isDisabled });\n\n      // Host bindings. `data-disabled` is bound by `ngpFormControl` using the\n      // combined disabled state, so it is not duplicated here.\n      attrBinding(element, 'id', id);\n      attrBinding(element, 'disabled', () => (isDisabled() ? '' : null));\n\n      function setDisabled(value: boolean) {\n        disabled.set(value);\n      }\n\n      return { id, disabled, setDisabled } satisfies NgpTextareaState;\n    },\n  );\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input } from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { ngpTextarea, provideTextareaState } from './textarea-state';\n\n@Directive({\n  selector: '[ngpTextarea]',\n  exportAs: 'ngpTextarea',\n  providers: [provideTextareaState({ inherit: false })],\n})\nexport class NgpTextarea {\n  /**\n   * The id of the textarea. If not provided, a unique id will be generated.\n   */\n  readonly id = input<string>(uniqueId('ngp-textarea'));\n\n  /**\n   * Whether the element is disabled.\n   */\n  readonly disabled = input<boolean, BooleanInput>(false, {\n    transform: booleanAttribute,\n  });\n\n  /**\n   * The state of the textarea.\n   */\n  protected readonly state = ngpTextarea({\n    id: this.id,\n    disabled: this.disabled,\n  });\n\n  /**\n   * Set the disabled state of the textarea.\n   * @param value The disabled state.\n   */\n  setDisabled(value: boolean): void {\n    this.state.setDisabled(value);\n  }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAwCO,MAAM,CAAC,qBAAqB,EAAE,WAAW,EAAE,mBAAmB,EAAE,oBAAoB,CAAC,GAC1F,eAAe,CACb,aAAa,EACb,CAAC,EACC,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,EACrC,QAAQ,EAAE,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,GAClB,KAAI;AACrB,IAAA,MAAM,OAAO,GAAG,gBAAgB,EAAE;AAClC,IAAA,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,CAAC;;;IAItC,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;AAC/C,IAAA,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,MAAM,EAAE,CAAC,QAAQ,IAAI,QAAQ,EAAE,iFAAC;AAElE,IAAA,e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