ngx-com 0.0.21 → 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.
- package/fesm2022/ngx-com-components-calendar.mjs +341 -43
- package/fesm2022/ngx-com-components-calendar.mjs.map +1 -1
- package/fesm2022/ngx-com-components-form-field.mjs +2 -2
- package/fesm2022/ngx-com-components-form-field.mjs.map +1 -1
- package/fesm2022/ngx-com-components-native-control.mjs +170 -0
- package/fesm2022/ngx-com-components-native-control.mjs.map +1 -0
- package/fesm2022/ngx-com-components-switch.mjs +16 -7
- package/fesm2022/ngx-com-components-switch.mjs.map +1 -1
- package/package.json +5 -1
- package/types/ngx-com-components-calendar.d.ts +158 -22
- package/types/ngx-com-components-native-control.d.ts +99 -0
- package/types/ngx-com-components-switch.d.ts +7 -2
|
@@ -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 };
|
|
@@ -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
|
|
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; }; "
|
|
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 };
|