ngx-com 0.0.20 → 0.0.22

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.
@@ -0,0 +1,99 @@
1
+ import * as i0 from '@angular/core';
2
+ import { DoCheck, InputSignal, InputSignalWithTransform, Signal } from '@angular/core';
3
+ import { NgControl } from '@angular/forms';
4
+ import { ErrorStateMatcher } from 'ngx-com/components/form-field';
5
+ import { VariantProps } from 'class-variance-authority';
6
+
7
+ /**
8
+ * Size type for native control.
9
+ */
10
+ type NativeControlSize = 'sm' | 'default' | 'lg';
11
+ /**
12
+ * Visual variant for native control.
13
+ */
14
+ type NativeControlVariant = 'outline' | 'filled' | 'ghost';
15
+ /**
16
+ * CVA variants for the native control directive.
17
+ *
18
+ * @tokens `--color-input-border`, `--color-input-background`, `--color-input-foreground`,
19
+ * `--color-input-placeholder`, `--color-disabled`, `--color-disabled-foreground`,
20
+ * `--color-ring`, `--color-warn`, `--color-muted`, `--color-border`,
21
+ * `--radius-input`
22
+ */
23
+ declare const nativeControlVariants: (props?: {
24
+ variant?: NativeControlVariant;
25
+ size?: NativeControlSize;
26
+ error?: boolean;
27
+ }) => string;
28
+ type NativeControlVariants = VariantProps<typeof nativeControlVariants>;
29
+
30
+ /**
31
+ * Standalone styling directive for native `<input>`, `<select>`, and `<textarea>` elements.
32
+ *
33
+ * Applies consistent borders, background, text color, focus outline, disabled state,
34
+ * error state, and size scaling via CVA. Integrates with both Reactive Forms (via NgControl)
35
+ * and Signal Forms (via `invalid`/`touched` inputs set by `[formField]`).
36
+ *
37
+ * For full form integration (label, hint, error), use `com-form-field` + `comInput`.
38
+ *
39
+ * @tokens `--color-input-border`, `--color-input-background`, `--color-input-foreground`,
40
+ * `--color-input-placeholder`, `--color-disabled`, `--color-disabled-foreground`,
41
+ * `--color-ring`, `--color-warn`, `--color-muted`, `--color-border`,
42
+ * `--radius-input`
43
+ *
44
+ * @example Basic usage
45
+ * ```html
46
+ * <input comNativeControl placeholder="Enter your name" />
47
+ * ```
48
+ *
49
+ * @example Variants
50
+ * ```html
51
+ * <input comNativeControl variant="outline" placeholder="Outline (default)" />
52
+ * <input comNativeControl variant="filled" placeholder="Filled" />
53
+ * <input comNativeControl variant="ghost" placeholder="Ghost" />
54
+ * ```
55
+ *
56
+ * @example Reactive Forms
57
+ * ```html
58
+ * <input comNativeControl [formControl]="nameCtrl" />
59
+ * ```
60
+ *
61
+ * @example Signal Forms
62
+ * ```html
63
+ * <input comNativeControl [formField]="myForm.name" />
64
+ * ```
65
+ */
66
+ declare class ComNativeControl implements DoCheck {
67
+ private readonly defaultErrorStateMatcher;
68
+ private readonly parentForm;
69
+ private readonly parentFormGroup;
70
+ /** NgControl bound to this element (if using reactive forms). */
71
+ readonly ngControl: NgControl | null;
72
+ /** Whether the form system is Signal Forms (no NgControl present). */
73
+ private readonly isSignalForms;
74
+ /** Visual variant — outline (bordered), filled (bg fill), or ghost (transparent) */
75
+ readonly variant: InputSignal<NativeControlVariant>;
76
+ /** Control size — affects height, padding, and font size */
77
+ readonly size: InputSignal<NativeControlSize>;
78
+ /** Consumer CSS classes — merged with variant classes via mergeClasses() */
79
+ readonly userClass: InputSignal<string>;
80
+ /** Custom error state matcher (overrides the default). */
81
+ readonly errorStateMatcher: InputSignal<ErrorStateMatcher | undefined>;
82
+ readonly sfInvalid: InputSignalWithTransform<boolean, unknown>;
83
+ readonly sfTouched: InputSignalWithTransform<boolean, unknown>;
84
+ /**
85
+ * Reactive Forms error state — imperatively updated in DoCheck because
86
+ * NgControl properties (touched, invalid) are not signals.
87
+ */
88
+ private readonly _reactiveErrorState;
89
+ /** Whether the control is in an error state. */
90
+ readonly errorState: Signal<boolean>;
91
+ /** @internal Computed host class from CVA + consumer overrides */
92
+ protected readonly computedClass: Signal<string>;
93
+ ngDoCheck(): void;
94
+ static ɵfac: i0.ɵɵFactoryDeclaration<ComNativeControl, never>;
95
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ComNativeControl, "input[comNativeControl], select[comNativeControl], textarea[comNativeControl]", ["comNativeControl"], { "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "errorStateMatcher": { "alias": "errorStateMatcher"; "required": false; "isSignal": true; }; "sfInvalid": { "alias": "invalid"; "required": false; "isSignal": true; }; "sfTouched": { "alias": "touched"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
96
+ }
97
+
98
+ export { ComNativeControl, nativeControlVariants };
99
+ export type { NativeControlSize, NativeControlVariant, NativeControlVariants };
@@ -130,8 +130,10 @@ declare class ComRadioGroup implements ControlValueAccessor {
130
130
  readonly variant: InputSignal<RadioVariant>;
131
131
  readonly errorMessage: InputSignal<string>;
132
132
  readonly errorStateMatcher: InputSignal<ErrorStateMatcher | undefined>;
133
- /** Internal signal to track when control is touched, used to trigger error state re-evaluation. */
134
- private readonly _touched;
133
+ /** Tracks touched state writable by both CVA callback and Signal Forms [formField]. */
134
+ readonly touched: ModelSignal<boolean>;
135
+ readonly invalid: InputSignal<boolean>;
136
+ readonly sfErrors: InputSignal<readonly unknown[]>;
135
137
  readonly ariaLabel: InputSignal<string | null>;
136
138
  readonly ariaLabelledby: InputSignal<string | null>;
137
139
  readonly ariaDescribedby: InputSignal<string | null>;
@@ -169,7 +171,7 @@ declare class ComRadioGroup implements ControlValueAccessor {
169
171
  /** Focuses the previous non-disabled radio (with cyclic wrap). */
170
172
  focusPrevious(currentValue: string): void;
171
173
  static ɵfac: i0.ɵɵFactoryDeclaration<ComRadioGroup, never>;
172
- static ɵcmp: i0.ɵɵComponentDeclaration<ComRadioGroup, "com-radio-group", ["comRadioGroup"], { "name": { "alias": "name"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "errorMessage": { "alias": "errorMessage"; "required": false; "isSignal": true; }; "errorStateMatcher": { "alias": "errorStateMatcher"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; "ariaDescribedby": { "alias": "aria-describedby"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "disabled": "disabledChange"; "selectionChange": "selectionChange"; }, never, ["*"], true, never>;
174
+ static ɵcmp: i0.ɵɵComponentDeclaration<ComRadioGroup, "com-radio-group", ["comRadioGroup"], { "name": { "alias": "name"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "errorMessage": { "alias": "errorMessage"; "required": false; "isSignal": true; }; "errorStateMatcher": { "alias": "errorStateMatcher"; "required": false; "isSignal": true; }; "touched": { "alias": "touched"; "required": false; "isSignal": true; }; "invalid": { "alias": "invalid"; "required": false; "isSignal": true; }; "sfErrors": { "alias": "errors"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; "ariaDescribedby": { "alias": "aria-describedby"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "disabled": "disabledChange"; "touched": "touchedChange"; "selectionChange": "selectionChange"; }, never, ["*"], true, never>;
173
175
  }
174
176
 
175
177
  /** Event emitted when a radio is selected. */
@@ -0,0 +1,75 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InputSignal, InputSignalWithTransform, Signal } from '@angular/core';
3
+ import { VariantProps } from 'class-variance-authority';
4
+
5
+ /**
6
+ * Orientation type for separator direction.
7
+ */
8
+ type SeparatorOrientation = 'horizontal' | 'vertical';
9
+ /**
10
+ * Variant type for separator appearance.
11
+ */
12
+ type SeparatorVariant = 'default' | 'subtle';
13
+ /**
14
+ * CVA variants for the separator directive.
15
+ *
16
+ * @tokens `--color-border`, `--color-border-subtle`
17
+ */
18
+ declare const separatorVariants: (props?: {
19
+ orientation?: SeparatorOrientation;
20
+ variant?: SeparatorVariant;
21
+ }) => string;
22
+ type SeparatorVariants = VariantProps<typeof separatorVariants>;
23
+
24
+ /**
25
+ * Separator directive — applies a visual divider to any host element.
26
+ *
27
+ * Works on `<hr>`, `<div>`, or any other element. Supports horizontal and
28
+ * vertical orientations, a subtle color variant, and a decorative mode that
29
+ * hides the separator from assistive technology.
30
+ *
31
+ * @tokens `--color-border`, `--color-border-subtle`
32
+ *
33
+ * @example Horizontal divider
34
+ * ```html
35
+ * <hr comSeparator />
36
+ * ```
37
+ *
38
+ * @example Vertical divider
39
+ * ```html
40
+ * <div comSeparator orientation="vertical" class="h-6"></div>
41
+ * ```
42
+ *
43
+ * @example Subtle variant
44
+ * ```html
45
+ * <hr comSeparator variant="subtle" />
46
+ * ```
47
+ *
48
+ * @example Decorative (hidden from screen readers)
49
+ * ```html
50
+ * <hr comSeparator decorative />
51
+ * ```
52
+ */
53
+ declare class ComSeparator {
54
+ /** Direction of the separator line */
55
+ readonly orientation: InputSignal<SeparatorOrientation>;
56
+ /** Color intensity — `default` uses border-border, `subtle` uses border-border-subtle */
57
+ readonly variant: InputSignal<SeparatorVariant>;
58
+ /** When true, hides the separator from assistive technology */
59
+ readonly decorative: InputSignalWithTransform<boolean, unknown>;
60
+ /** Consumer CSS classes — merged with variant classes via mergeClasses() */
61
+ readonly userClass: InputSignal<string>;
62
+ /** @internal Computed host class from CVA + consumer overrides */
63
+ protected readonly computedClass: Signal<string>;
64
+ /** @internal Role attribute — separator when semantic, none when decorative */
65
+ protected readonly computedRole: Signal<string>;
66
+ /** @internal Aria-orientation — set only when not decorative */
67
+ protected readonly computedAriaOrientation: Signal<string | null>;
68
+ /** @internal Aria-hidden — true only when decorative */
69
+ protected readonly computedAriaHidden: Signal<'true' | null>;
70
+ static ɵfac: i0.ɵɵFactoryDeclaration<ComSeparator, never>;
71
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ComSeparator, "[comSeparator]", ["comSeparator"], { "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "decorative": { "alias": "decorative"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
72
+ }
73
+
74
+ export { ComSeparator, separatorVariants };
75
+ export type { SeparatorOrientation, SeparatorVariant, SeparatorVariants };
@@ -79,12 +79,16 @@ declare class ComSwitch implements ControlValueAccessor {
79
79
  readonly variant: InputSignal<SwitchVariant>;
80
80
  readonly checked: ModelSignal<boolean>;
81
81
  readonly disabled: ModelSignal<boolean>;
82
- readonly value: InputSignal<string | undefined>;
82
+ readonly htmlValue: InputSignal<string | undefined>;
83
83
  readonly name: InputSignal<string | undefined>;
84
84
  readonly id: InputSignal<string | undefined>;
85
85
  readonly ariaLabel: InputSignal<string | null>;
86
86
  readonly ariaLabelledby: InputSignal<string | null>;
87
87
  readonly ariaDescribedby: InputSignal<string | null>;
88
+ readonly touched: ModelSignal<boolean>;
89
+ readonly invalid: InputSignal<boolean>;
90
+ readonly sfErrors: InputSignal<readonly unknown[]>;
91
+ readonly sfRequired: InputSignal<boolean>;
88
92
  readonly changed: OutputEmitterRef<SwitchChange>;
89
93
  readonly inputId: Signal<string>;
90
94
  protected readonly trackClasses: Signal<string>;
@@ -97,13 +101,14 @@ declare class ComSwitch implements ControlValueAccessor {
97
101
  registerOnChange(fn: (value: boolean) => void): void;
98
102
  registerOnTouched(fn: () => void): void;
99
103
  setDisabledState(isDisabled: boolean): void;
104
+ protected onBlur(): void;
100
105
  protected onInputChange(event: Event): void;
101
106
  /** Focuses this switch's input element. */
102
107
  focus(): void;
103
108
  /** Toggles the switch state programmatically. */
104
109
  toggle(): void;
105
110
  static ɵfac: i0.ɵɵFactoryDeclaration<ComSwitch, never>;
106
- static ɵcmp: i0.ɵɵComponentDeclaration<ComSwitch, "com-switch", ["comSwitch"], { "size": { "alias": "size"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; "ariaDescribedby": { "alias": "aria-describedby"; "required": false; "isSignal": true; }; }, { "checked": "checkedChange"; "disabled": "disabledChange"; "changed": "changed"; }, never, ["*"], true, never>;
111
+ static ɵcmp: i0.ɵɵComponentDeclaration<ComSwitch, "com-switch", ["comSwitch"], { "size": { "alias": "size"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "htmlValue": { "alias": "value"; "required": false; "isSignal": true; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; "ariaDescribedby": { "alias": "aria-describedby"; "required": false; "isSignal": true; }; "touched": { "alias": "touched"; "required": false; "isSignal": true; }; "invalid": { "alias": "invalid"; "required": false; "isSignal": true; }; "sfErrors": { "alias": "errors"; "required": false; "isSignal": true; }; "sfRequired": { "alias": "required"; "required": false; "isSignal": true; }; }, { "checked": "checkedChange"; "disabled": "disabledChange"; "touched": "touchedChange"; "changed": "changed"; }, never, ["*"], true, never>;
107
112
  }
108
113
 
109
114
  export { ComSwitch, SWITCH_LABEL_SIZES, SWITCH_THUMB_SIZES, SWITCH_THUMB_TRANSLATE, switchTrackVariants };