@ni/nimble-angular 12.1.0 → 12.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ni/nimble-angular",
3
- "version": "12.1.0",
3
+ "version": "12.1.2",
4
4
  "description": "Angular components for the NI Nimble Design System",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "@angular/core": "^12.1.0",
20
20
  "@angular/forms": "^12.1.0",
21
21
  "@angular/router": "^12.1.0",
22
- "@ni/nimble-components": "^15.1.0"
22
+ "@ni/nimble-components": "^15.1.1"
23
23
  },
24
24
  "dependencies": {
25
25
  "tslib": "^2.2.0"
@@ -0,0 +1,87 @@
1
+ /**
2
+ * [Nimble]
3
+ * Copied from https://github.com/angular/angular/blob/14.2.6/packages/forms/src/directives/control_value_accessor.ts
4
+ * with the following modifications:
5
+ * - Commented out ControlValueAccessor which is exported from @angular/forms
6
+ * - Commented out NG_VALUE_ACCESSOR which is exported from @angular/forms
7
+ */
8
+ /**
9
+ * @license
10
+ * Copyright Google LLC All Rights Reserved.
11
+ *
12
+ * Use of this source code is governed by an MIT-style license that can be
13
+ * found in the LICENSE file at https://angular.io/license
14
+ */
15
+ import { ElementRef, Renderer2 } from '@angular/core';
16
+ import * as i0 from "@angular/core";
17
+ /**
18
+ * @description
19
+ * Defines an interface that acts as a bridge between the Angular forms API and a
20
+ * native element in the DOM.
21
+ *
22
+ * Implement this interface to create a custom form control directive
23
+ * that integrates with Angular forms.
24
+ *
25
+ * @see DefaultValueAccessor
26
+ *
27
+ * @publicApi
28
+ */
29
+ /**
30
+ * Base class for all ControlValueAccessor classes defined in Forms package.
31
+ * Contains common logic and utility functions.
32
+ *
33
+ * Note: this is an *internal-only* class and should not be extended or used directly in
34
+ * applications code.
35
+ */
36
+ export declare class BaseControlValueAccessor {
37
+ private _renderer;
38
+ private _elementRef;
39
+ /**
40
+ * The registered callback function called when a change or input event occurs on the input
41
+ * element.
42
+ * @nodoc
43
+ */
44
+ onChange: (_: any) => void;
45
+ /**
46
+ * The registered callback function called when a blur event occurs on the input element.
47
+ * @nodoc
48
+ */
49
+ onTouched: () => void;
50
+ constructor(_renderer: Renderer2, _elementRef: ElementRef);
51
+ /**
52
+ * Helper method that sets a property on a target element using the current Renderer
53
+ * implementation.
54
+ * @nodoc
55
+ */
56
+ protected setProperty(key: string, value: any): void;
57
+ /**
58
+ * Registers a function called when the control is touched.
59
+ * @nodoc
60
+ */
61
+ registerOnTouched(fn: () => void): void;
62
+ /**
63
+ * Registers a function called when the control value changes.
64
+ * @nodoc
65
+ */
66
+ registerOnChange(fn: (_: any) => {}): void;
67
+ /**
68
+ * Sets the "disabled" property on the range input element.
69
+ * @nodoc
70
+ */
71
+ setDisabledState(isDisabled: boolean): void;
72
+ static ɵfac: i0.ɵɵFactoryDeclaration<BaseControlValueAccessor, never>;
73
+ static ɵdir: i0.ɵɵDirectiveDeclaration<BaseControlValueAccessor, never, never, {}, {}, never>;
74
+ }
75
+ /**
76
+ * Base class for all built-in ControlValueAccessor classes (except DefaultValueAccessor, which is
77
+ * used in case no other CVAs can be found). We use this class to distinguish between default CVA,
78
+ * built-in CVAs and custom CVAs, so that Forms logic can recognize built-in CVAs and treat custom
79
+ * ones with higher priority (when both built-in and custom CVAs are present).
80
+ *
81
+ * Note: this is an *internal-only* class and should not be extended or used directly in
82
+ * applications code.
83
+ */
84
+ export declare class BuiltInControlValueAccessor extends BaseControlValueAccessor {
85
+ static ɵfac: i0.ɵɵFactoryDeclaration<BuiltInControlValueAccessor, never>;
86
+ static ɵdir: i0.ɵɵDirectiveDeclaration<BuiltInControlValueAccessor, never, never, {}, {}, never>;
87
+ }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * [Nimble]
3
+ * Copied from https://github.com/angular/angular/blob/14.2.6/packages/forms/src/directives/radio_control_value_accessor.ts
4
+ * with the following modifications:
5
+ * - Changed throwNameError() to throw Error instead of RuntimeError. This makes the file compile with Angular version 12.
6
+ * - Removed now-unused import for RuntimeErrorCode and RuntimeError
7
+ * - Updated import of ControlValueAccessor, NgControl, and NG_VALUE_ACCESSOR to pull from package export
8
+ */
9
+ /**
10
+ * @license
11
+ * Copyright Google LLC All Rights Reserved.
12
+ *
13
+ * Use of this source code is governed by an MIT-style license that can be
14
+ * found in the LICENSE file at https://angular.io/license
15
+ */
16
+ import { ElementRef, Injector, OnDestroy, OnInit, Renderer2 } from '@angular/core';
17
+ import { BuiltInControlValueAccessor } from './control_value_accessor';
18
+ import { ControlValueAccessor, NgControl } from '@angular/forms';
19
+ import * as i0 from "@angular/core";
20
+ export declare const RADIO_VALUE_ACCESSOR: any;
21
+ /**
22
+ * Internal-only NgModule that works as a host for the `RadioControlRegistry` tree-shakable
23
+ * provider. Note: the `InternalFormsSharedModule` can not be used here directly, since it's
24
+ * declared *after* the `RadioControlRegistry` class and the `providedIn` doesn't support
25
+ * `forwardRef` logic.
26
+ */
27
+ export declare class RadioControlRegistryModule {
28
+ static ɵfac: i0.ɵɵFactoryDeclaration<RadioControlRegistryModule, never>;
29
+ static ɵmod: i0.ɵɵNgModuleDeclaration<RadioControlRegistryModule, never, never, never>;
30
+ static ɵinj: i0.ɵɵInjectorDeclaration<RadioControlRegistryModule>;
31
+ }
32
+ /**
33
+ * @description
34
+ * Class used by Angular to track radio buttons. For internal use only.
35
+ */
36
+ export declare class RadioControlRegistry {
37
+ private _accessors;
38
+ /**
39
+ * @description
40
+ * Adds a control to the internal registry. For internal use only.
41
+ */
42
+ add(control: NgControl, accessor: RadioControlValueAccessor): void;
43
+ /**
44
+ * @description
45
+ * Removes a control from the internal registry. For internal use only.
46
+ */
47
+ remove(accessor: RadioControlValueAccessor): void;
48
+ /**
49
+ * @description
50
+ * Selects a radio button. For internal use only.
51
+ */
52
+ select(accessor: RadioControlValueAccessor): void;
53
+ private _isSameGroup;
54
+ static ɵfac: i0.ɵɵFactoryDeclaration<RadioControlRegistry, never>;
55
+ static ɵprov: i0.ɵɵInjectableDeclaration<RadioControlRegistry>;
56
+ }
57
+ /**
58
+ * @description
59
+ * The `ControlValueAccessor` for writing radio control values and listening to radio control
60
+ * changes. The value accessor is used by the `FormControlDirective`, `FormControlName`, and
61
+ * `NgModel` directives.
62
+ *
63
+ * @usageNotes
64
+ *
65
+ * ### Using radio buttons with reactive form directives
66
+ *
67
+ * The follow example shows how to use radio buttons in a reactive form. When using radio buttons in
68
+ * a reactive form, radio buttons in the same group should have the same `formControlName`.
69
+ * Providing a `name` attribute is optional.
70
+ *
71
+ * {@example forms/ts/reactiveRadioButtons/reactive_radio_button_example.ts region='Reactive'}
72
+ *
73
+ * @ngModule ReactiveFormsModule
74
+ * @ngModule FormsModule
75
+ * @publicApi
76
+ */
77
+ export declare class RadioControlValueAccessor extends BuiltInControlValueAccessor implements ControlValueAccessor, OnDestroy, OnInit {
78
+ private _registry;
79
+ private _injector;
80
+ /** @internal */
81
+ _state: boolean;
82
+ /** @internal */
83
+ _control: NgControl;
84
+ /** @internal */
85
+ _fn: Function;
86
+ /**
87
+ * The registered callback function called when a change event occurs on the input element.
88
+ * Note: we declare `onChange` here (also used as host listener) as a function with no arguments
89
+ * to override the `onChange` function (which expects 1 argument) in the parent
90
+ * `BaseControlValueAccessor` class.
91
+ * @nodoc
92
+ */
93
+ onChange: () => void;
94
+ /**
95
+ * @description
96
+ * Tracks the name of the radio input element.
97
+ */
98
+ name: string;
99
+ /**
100
+ * @description
101
+ * Tracks the name of the `FormControl` bound to the directive. The name corresponds
102
+ * to a key in the parent `FormGroup` or `FormArray`.
103
+ */
104
+ formControlName: string;
105
+ /**
106
+ * @description
107
+ * Tracks the value of the radio input element
108
+ */
109
+ value: any;
110
+ constructor(renderer: Renderer2, elementRef: ElementRef, _registry: RadioControlRegistry, _injector: Injector);
111
+ /** @nodoc */
112
+ ngOnInit(): void;
113
+ /** @nodoc */
114
+ ngOnDestroy(): void;
115
+ /**
116
+ * Sets the "checked" property value on the radio input element.
117
+ * @nodoc
118
+ */
119
+ writeValue(value: any): void;
120
+ /**
121
+ * Registers a function called when the control value changes.
122
+ * @nodoc
123
+ */
124
+ registerOnChange(fn: (_: any) => {}): void;
125
+ /**
126
+ * Sets the "value" on the radio input element and unchecks it.
127
+ *
128
+ * @param value
129
+ */
130
+ fireUncheck(value: any): void;
131
+ private _checkName;
132
+ static ɵfac: i0.ɵɵFactoryDeclaration<RadioControlValueAccessor, never>;
133
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RadioControlValueAccessor, "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", never, { "name": "name"; "formControlName": "formControlName"; "value": "value"; }, {}, never>;
134
+ }