{"version":3,"file":"sdcorejs-angular-forms-models.mjs","sources":["../../../projects/sdcorejs-angular/forms/models/src/sd-form.configuration.ts","../../../projects/sdcorejs-angular/forms/models/src/sd-form-control.model.ts","../../../projects/sdcorejs-angular/forms/models/src/sd-custom-validator.model.ts","../../../projects/sdcorejs-angular/forms/models/src/form-control-state.ts","../../../projects/sdcorejs-angular/forms/models/src/sd-viewed.ts","../../../projects/sdcorejs-angular/forms/models/src/sd-form-control-connector.ts","../../../projects/sdcorejs-angular/forms/models/sdcorejs-angular-forms-models.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { MatFormFieldAppearance } from '@angular/material/form-field';\n\nexport interface ISdFormConfiguration {\n  appearance?: MatFormFieldAppearance;\n}\n\nexport const SD_FORM_CONFIGURATION = new InjectionToken<ISdFormConfiguration>('sd.form.configuration');\n","import { FormControl, AsyncValidatorFn, ValidatorFn, FormControlOptions, FormControlState } from '@angular/forms';\nimport { Subject } from 'rxjs';\n\nexport class SdFormControl extends FormControl {\n  sdChanges: Subject<boolean> = new Subject<boolean>();\n  untouchChanges: Subject<boolean> = new Subject<boolean>();\n  touchChanges: Subject<boolean> = new Subject<boolean>();\n  pristineChanges: Subject<boolean> = new Subject<boolean>();\n  constructor(\n    formState?: FormControlState<any>,\n    validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null,\n    asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null\n  ) {\n    super(formState, validatorOrOpts, asyncValidator);\n  }\n\n  override markAsUntouched(opts?: { onlySelf?: boolean; emitEvent?: boolean }): void {\n    super.markAsUntouched(opts);\n    this.untouchChanges.next(true);\n    this.sdChanges.next(true);\n  }\n\n  override markAsTouched(opts?: { onlySelf?: boolean; emitEvent?: boolean }): void {\n    super.markAsTouched(opts);\n    this.touchChanges.next(true);\n    this.sdChanges.next(true);\n  }\n\n  override markAsPristine(opts?: { onlySelf?: boolean; emitEvent?: boolean }): void {\n    super.markAsPristine(opts);\n    this.pristineChanges.next(true);\n    this.sdChanges.next(true);\n  }\n}\n","import { AbstractControl, AsyncValidatorFn, ValidatorFn } from '@angular/forms';\n\nexport type SdCustomValidator = (value: any) => string | Promise<string>;\n\n/**\n * Inline-error sentinel validator. Returns `{ inlineError: true }` so the form\n * template can render `<mat-error>{{ inlineError }}</mat-error>` whenever the\n * host component has a non-empty `[inlineError]` input. The error message\n * itself is read from the input — this validator only flags the state.\n *\n * why: each form component (input, textarea, select, checkbox, radio, switch,\n * date, datetime, input-number, autocomplete) previously declared the same\n * private `customInlineErrorValidator()` method. Centralized here so adding\n * another form component does not silently re-introduce the duplicate.\n */\nexport const SdInlineErrorValidator: ValidatorFn = (): Record<string, unknown> | null => ({ inlineError: true });\n\nexport const HandleSdCustomValidator = (func: SdCustomValidator): AsyncValidatorFn => {\n  return async (c: AbstractControl): Promise<Record<string, any> | null> => {\n    const value = c.value === 0 ? c.value : c.value || null;\n    if (func && typeof func === 'function') {\n      const result = func(value);\n      if (result instanceof Promise) {\n        const message = await result;\n        if (message) {\n          return {\n            customValidator: message,\n          };\n        }\n        return null;\n      }\n      if (result) {\n        return {\n          customValidator: result,\n        };\n      }\n      return null;\n    }\n    return null;\n  };\n};\n","import { DestroyRef, EffectRef, Signal, computed, effect, inject, signal, untracked } from '@angular/core';\nimport { AbstractControl } from '@angular/forms';\nimport { Subscription } from 'rxjs';\nimport { startWith } from 'rxjs/operators';\n\nexport interface SdFormControlSnapshot<T> {\n  value: T | undefined;\n  disabled: boolean;\n  invalid: boolean;\n  touched: boolean;\n}\n\n/**\n * Wrap an AbstractControl Signal into a reactive snapshot signal.\n *\n * Re-emits on every value, status, touched, or dirty change so\n * downstream consumers can derive `data-disabled`, `data-value`,\n * `data-empty`, and `data-invalid` host-binding attributes from a\n * single, lazily evaluated signal.\n *\n * \"invalid\" is intentionally gated on `touched || dirty` so validation\n * errors are not surfaced until the user has interacted with the field.\n *\n * Must be called inside an Angular injection context (constructor,\n * field initialiser, or `runInInjectionContext`).\n */\nexport function sdFormControlState<T = unknown>(control: Signal<AbstractControl<T> | null | undefined>): Signal<SdFormControlSnapshot<T>> {\n  // A tick counter incremented on every control event (value, status,\n  // touched, dirty). Written only from the effect below — never inside\n  // a computed() — satisfying Angular's no-side-effect-in-reactive rule.\n  const tick = signal(0);\n  const destroyRef = inject(DestroyRef);\n\n  // Holds the active RxJS subscription so it can be torn down when the\n  // control instance changes or the host component is destroyed.\n  let subscription: Subscription | null = null;\n\n  // An effect re-runs whenever the control Signal changes, tears down the\n  // old subscription and creates a fresh one for the incoming control.\n  // `AbstractControl.events` (Angular 14+) covers value, status, touched,\n  // and dirty changes — a superset of valueChanges + statusChanges.\n  const effectRef: EffectRef = effect(() => {\n    const c = control(); // tracked — effect re-runs on change\n    // effect() runs asynchronously; the old subscription is torn down on the next\n    // scheduled run, not synchronously on signal change. A one-tick window of\n    // double-subscription is harmless due to computed() memoization.\n    subscription?.unsubscribe();\n    subscription = null;\n\n    if (c) {\n      subscription = c.events.pipe(startWith(null)).subscribe(() => {\n        // Increment outside reactive context to avoid Angular's\n        // \"signal written from computed / template\" error.\n        untracked(() => tick.update(n => n + 1));\n      });\n    }\n  });\n\n  // Clean up effect and subscription when host component is destroyed.\n  destroyRef.onDestroy(() => {\n    effectRef.destroy();\n    subscription?.unsubscribe();\n  });\n\n  return computed((): SdFormControlSnapshot<T> => {\n    const _control = control();\n    tick(); // reactive dependency — recomputes on every control event\n\n    if (!_control) {\n      return { value: undefined, disabled: false, invalid: false, touched: false };\n    }\n\n    return {\n      value: _control.value as T,\n      disabled: _control.disabled,\n      invalid: _control.invalid && (_control.touched || _control.dirty),\n      touched: _control.touched,\n    };\n  });\n}\n","import { booleanAttribute, computed, Signal } from '@angular/core';\n\n/**\n * Three display states shared by sd-form-controls:\n * - `false`  → full edit chrome (input / dropdown).\n * - `true`   → static read-only view (`<sd-view>` text), no editor.\n * - `'inline'` → the editor is STILL rendered (so its panel works), but its chrome is\n *   hidden; the `<sd-view>` text is the visible face / trigger. Click the text to open\n *   the picker's panel. The text is retained while the panel is open — it only changes\n *   when a new value is committed (JIRA-style click-to-edit).\n */\nexport type SdViewed = boolean | 'inline';\nexport type SdViewedInput = SdViewed | '' | null | undefined;\n\n/**\n * `viewed` input transform. Keeps `booleanAttribute` coercion so a bare attribute\n * (`<sd-select viewed>`) still resolves to `true`, but intercepts the literal\n * `'inline'` first — `booleanAttribute('inline')` would otherwise coerce it to `true`.\n */\nexport function sdViewedTransform(v: SdViewedInput): SdViewed {\n  return v === 'inline' ? 'inline' : booleanAttribute(v);\n}\n\nexport interface SdViewedInlineApi {\n  /** `viewed() === 'inline'` — editor rendered but chrome hidden; sd-view text is the trigger face. */\n  readonly isInline: Signal<boolean>;\n  /** `viewed() === true` — static read-only view (no editor rendered). */\n  readonly isViewed: Signal<boolean>;\n  /** Open the picker from the inline text face. No-op unless `'inline'`. */\n  enterInlineEdit(): void;\n}\n\n/**\n * Compose the tri-state `viewed` semantics into a control. `open` opens the control's\n * native picker (mat-select panel / mat-calendar / overlay). In `'inline'` mode the editor\n * is always rendered (chrome hidden via CSS), so `open()` can fire immediately on click —\n * no render-swap, the view text never disappears.\n *\n * @param viewed   the control's `viewed` input signal.\n * @param open     opens the control's picker; called by `enterInlineEdit`.\n * @param disabled the control's disabled state. why: a disabled `'inline'` field must behave\n *   like `viewed=true` (static, NOT click-to-edit) — you can't edit a disabled control.\n */\nexport function sdViewedInline(viewed: Signal<SdViewed>, open?: () => void, disabled?: Signal<boolean>): SdViewedInlineApi {\n  // why: disabled biến 'inline' thành static view (isInline=false, isViewed=true) — không cho sửa.\n  const isInline = computed(() => viewed() === 'inline' && !disabled?.());\n  const isViewed = computed(() => viewed() === true || (viewed() === 'inline' && !!disabled?.()));\n  const enterInlineEdit = (): void => {\n    if (isInline()) open?.();\n  };\n  return { isInline, isViewed, enterInlineEdit };\n}\n","import { Signal, computed, effect, untracked } from '@angular/core';\nimport { AbstractControl, AsyncValidatorFn, FormGroup, NgForm, ValidatorFn, Validators } from '@angular/forms';\n\nimport { sdFormControlState } from './form-control-state';\nimport { SdViewed } from './sd-viewed';\n\nexport type ɵSdFormControlParent = FormGroup | NgForm | { readonly form: unknown } | null | undefined;\n\ninterface ɵSdFormControlConnectorBaseOptions<TControl> {\n  /** Parent form source. NgForm and wrapper values are unwrapped on every rebind. */\n  readonly form: Signal<ɵSdFormControlParent>;\n  /** Registration name. Empty names intentionally leave the control unregistered. */\n  readonly name: Signal<string | null | undefined>;\n  /** Canonical control registered in the parent form. */\n  readonly control: Signal<AbstractControl<TControl>>;\n  readonly validators?: Signal<ValidatorFn | readonly ValidatorFn[] | null | undefined>;\n  readonly asyncValidators?: Signal<AsyncValidatorFn | readonly AsyncValidatorFn[] | null | undefined>;\n  /** Adds/removes Validators.required while preserving validators supplied above. */\n  readonly required?: Signal<boolean | null | undefined>;\n  readonly disabled?: Signal<boolean | null | undefined>;\n  /** UI-only read-only policy. This never disables the Angular control. */\n  readonly readonly?: Signal<boolean | null | undefined>;\n  /** Exact SDCoreJS display policy. This never disables the Angular control. */\n  readonly viewed?: Signal<SdViewed | null | undefined>;\n  /** Component-local validation message. Visibility is interaction-gated in state. */\n  readonly validationError?: Signal<string | null | undefined>;\n}\n\ninterface ɵSdFormControlRegistrationOptions<TControl> extends ɵSdFormControlConnectorBaseOptions<TControl> {\n  readonly model?: never;\n  readonly writeModel?: never;\n  readonly modelToControl?: never;\n  readonly controlToModel?: never;\n  readonly modelEquals?: never;\n  readonly controlEquals?: never;\n}\n\ninterface ɵSdFormControlIdentityOptions<TValue> extends ɵSdFormControlConnectorBaseOptions<TValue> {\n  readonly model: Signal<TValue>;\n  readonly writeModel: (value: TValue) => void;\n  readonly modelToControl?: never;\n  readonly controlToModel?: never;\n  readonly modelEquals?: (left: TValue, right: TValue) => boolean;\n  readonly controlEquals?: (left: TValue, right: TValue) => boolean;\n}\n\ninterface ɵSdFormControlAdaptedOptions<TModel, TControl> extends ɵSdFormControlConnectorBaseOptions<TControl> {\n  readonly model: Signal<TModel>;\n  readonly writeModel: (value: TModel) => void;\n  readonly modelToControl: (value: TModel) => TControl;\n  readonly controlToModel: (value: TControl) => TModel;\n  readonly modelEquals?: (left: TModel, right: TModel) => boolean;\n  readonly controlEquals?: (left: TControl, right: TControl) => boolean;\n}\n\ntype ɵSdTypesExactlyMatch<TLeft, TRight> = [TLeft] extends [TRight] ? ([TRight] extends [TLeft] ? true : false) : false;\n\n/**\n * @internal Unstable connector contract for cross-entrypoint SDCoreJS controls.\n * Consumers must use registration-only, same-type identity binding, or provide\n * both adapters when model and control representations differ.\n */\nexport type ɵSdFormControlConnectorOptions<TModel, TControl> =\n  | ɵSdFormControlRegistrationOptions<TControl>\n  | ɵSdFormControlAdaptedOptions<TModel, TControl>\n  | (ɵSdTypesExactlyMatch<TModel, TControl> extends true ? ɵSdFormControlIdentityOptions<TModel> : never);\n\ntype ɵSdFormControlBindingOptions<TModel, TControl> =\n  | ɵSdFormControlIdentityOptions<TControl>\n  | ɵSdFormControlAdaptedOptions<TModel, TControl>;\n\ntype ɵSdFormControlImplementationOptions<TModel, TControl> =\n  | ɵSdFormControlRegistrationOptions<TControl>\n  | ɵSdFormControlBindingOptions<TModel, TControl>;\n\nexport interface ɵSdFormControlConnectorState<TControl> {\n  readonly value: TControl | undefined;\n  readonly disabled: boolean;\n  readonly invalid: boolean;\n  readonly touched: boolean;\n  readonly dirty: boolean;\n  readonly required: boolean;\n  readonly readonly: boolean;\n  readonly viewed: SdViewed;\n  readonly isViewed: boolean;\n  readonly isInline: boolean;\n  readonly showValidationError: boolean;\n  readonly validationError: string | undefined;\n}\n\nexport interface ɵSdFormControlConnector<TControl = unknown> {\n  readonly state: Signal<ɵSdFormControlConnectorState<TControl>>;\n  markAsTouched(): void;\n  markAsUntouched(): void;\n  markAsDirty(): void;\n  markAsPristine(): void;\n}\n\n/** Coerces the form shapes accepted by SDCoreJS controls into one FormGroup. */\nexport function ɵsdCoerceFormGroup(value: unknown): FormGroup | undefined {\n  if (value instanceof NgForm) return value.form;\n  if (value instanceof FormGroup) return value;\n  if (typeof value !== 'object' || value === null || !('form' in value)) return undefined;\n\n  const wrappedForm = (value as { readonly form: unknown }).form;\n  return wrappedForm instanceof FormGroup ? wrappedForm : undefined;\n}\n\nfunction normalizeValidatorList<TValidator extends ValidatorFn | AsyncValidatorFn>(\n  value: TValidator | readonly TValidator[] | null | undefined\n): TValidator[] {\n  if (!value) return [];\n  return typeof value === 'function' ? [value] : [...value];\n}\n\nfunction hasModelBinding<TModel, TControl>(\n  options: ɵSdFormControlImplementationOptions<TModel, TControl>\n): options is ɵSdFormControlBindingOptions<TModel, TControl> {\n  return options.model !== undefined && options.writeModel !== undefined;\n}\n\nfunction readControlValue<TModel, TControl>(options: ɵSdFormControlBindingOptions<TModel, TControl>): TControl {\n  if (options.modelToControl) return options.modelToControl(options.model());\n  return options.model();\n}\n\nfunction writeModelValue<TModel, TControl>(options: ɵSdFormControlBindingOptions<TModel, TControl>, controlValue: TControl): void {\n  if (options.controlToModel) {\n    const modelValue = options.controlToModel(controlValue);\n    if (!(options.modelEquals ?? Object.is)(options.model(), modelValue)) options.writeModel(modelValue);\n    return;\n  }\n\n  if (!(options.modelEquals ?? Object.is)(options.model(), controlValue)) options.writeModel(controlValue);\n}\n\n/**\n * Connects the signal-based SDCoreJS model contract to an Angular control.\n * Registration and subscriptions are rebound transactionally, and cleanup only\n * removes a control while the connector still owns that exact registration.\n */\nexport function ɵsdFormControlConnector<TModel, TControl>(\n  options: ɵSdFormControlConnectorOptions<TModel, TControl>\n): ɵSdFormControlConnector<TControl>;\nexport function ɵsdFormControlConnector<TModel, TControl>(\n  options: ɵSdFormControlImplementationOptions<TModel, TControl>\n): ɵSdFormControlConnector<TControl> {\n  const controlEquals = options.controlEquals ?? Object.is;\n  const controlState = sdFormControlState(options.control);\n  const state = computed((): ɵSdFormControlConnectorState<TControl> => {\n    const snapshot = controlState();\n    const required = !!options.required?.();\n    const readonly = !!options.readonly?.();\n    const viewed = options.viewed?.() ?? false;\n    const validationError = options.validationError?.() || undefined;\n    const showValidationError = snapshot.invalid && validationError !== undefined;\n\n    return {\n      ...snapshot,\n      dirty: options.control().dirty,\n      required,\n      readonly,\n      viewed,\n      isViewed: viewed === true,\n      isInline: viewed === 'inline',\n      showValidationError,\n      validationError: showValidationError ? validationError : undefined,\n    };\n  });\n\n  effect(onCleanup => {\n    const formGroup = ɵsdCoerceFormGroup(options.form());\n    const name = options.name();\n    const control = options.control();\n\n    if (!formGroup || !name) return;\n\n    const current = formGroup.get(name);\n    const ownsRegistration = !current;\n    if (ownsRegistration) formGroup.addControl(name, control);\n\n    onCleanup(() => {\n      if (ownsRegistration && formGroup.get(name) === control) formGroup.removeControl(name);\n    });\n  });\n\n  if (hasModelBinding(options)) {\n    effect(() => {\n      const control = options.control();\n      const controlValue = readControlValue(options);\n\n      untracked(() => {\n        if (!controlEquals(control.value, controlValue)) {\n          control.setValue(controlValue, { emitEvent: false });\n        }\n      });\n    });\n  }\n\n  if (hasModelBinding(options)) {\n    effect(onCleanup => {\n      const control = options.control();\n      const subscription = control.valueChanges.subscribe(controlValue => {\n        writeModelValue(options, controlValue);\n      });\n      onCleanup(() => subscription.unsubscribe());\n    });\n  }\n\n  if (options.validators || options.asyncValidators || options.required) {\n    effect(onCleanup => {\n      const control = options.control();\n      const requestedValidators = normalizeValidatorList(options.validators?.());\n      if (options.required?.()) requestedValidators.push(Validators.required);\n      const validatorsToAdd = [...new Set(requestedValidators)].filter(validator => !control.hasValidator(validator));\n      const asyncValidatorsToAdd = [...new Set(normalizeValidatorList(options.asyncValidators?.()))].filter(\n        validator => !control.hasAsyncValidator(validator)\n      );\n\n      untracked(() => {\n        if (validatorsToAdd.length > 0) control.addValidators(validatorsToAdd);\n        if (asyncValidatorsToAdd.length > 0) control.addAsyncValidators(asyncValidatorsToAdd);\n        control.updateValueAndValidity({ emitEvent: false });\n      });\n\n      onCleanup(() => {\n        untracked(() => {\n          if (validatorsToAdd.length > 0) control.removeValidators(validatorsToAdd);\n          if (asyncValidatorsToAdd.length > 0) control.removeAsyncValidators(asyncValidatorsToAdd);\n          control.updateValueAndValidity({ emitEvent: false });\n        });\n      });\n    });\n  }\n\n  if (options.disabled) {\n    effect(onCleanup => {\n      const control = options.control();\n      const disabled = !!options.disabled!();\n      const previousDisabled = control.disabled;\n      let appliedDisabled: boolean | undefined;\n\n      untracked(() => {\n        if (disabled !== control.disabled) {\n          appliedDisabled = disabled;\n          if (disabled) control.disable({ emitEvent: false });\n          else control.enable({ emitEvent: false });\n        }\n      });\n\n      onCleanup(() => {\n        if (appliedDisabled === undefined || control.disabled !== appliedDisabled) return;\n\n        untracked(() => {\n          if (previousDisabled) control.disable({ emitEvent: false });\n          else control.enable({ emitEvent: false });\n        });\n      });\n    });\n  }\n\n  return {\n    state,\n    markAsTouched: () => options.control().markAsTouched(),\n    markAsUntouched: () => options.control().markAsUntouched(),\n    markAsDirty: () => options.control().markAsDirty(),\n    markAsPristine: () => options.control().markAsPristine(),\n  };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAOa,qBAAqB,GAAG,IAAI,cAAc,CAAuB,uBAAuB;;ACJ/F,MAAO,aAAc,SAAQ,WAAW,CAAA;AAC5C,IAAA,SAAS,GAAqB,IAAI,OAAO,EAAW;AACpD,IAAA,cAAc,GAAqB,IAAI,OAAO,EAAW;AACzD,IAAA,YAAY,GAAqB,IAAI,OAAO,EAAW;AACvD,IAAA,eAAe,GAAqB,IAAI,OAAO,EAAW;AAC1D,IAAA,WAAA,CACE,SAAiC,EACjC,eAAyE,EACzE,cAA6D,EAAA;AAE7D,QAAA,KAAK,CAAC,SAAS,EAAE,eAAe,EAAE,cAAc,CAAC;IACnD;AAES,IAAA,eAAe,CAAC,IAAkD,EAAA;AACzE,QAAA,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC;AAC3B,QAAA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;AAC9B,QAAA,IAAI,CAAC,S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