angular-ui-controls 0.1.0-rc.2 → 0.1.0-rc.4
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/README.md +98 -46
- package/docs/api/README.md +29 -0
- package/docs/api/abbreviation-textarea.md +118 -0
- package/docs/api/action-menu.md +86 -0
- package/docs/api/advanced-select.md +214 -0
- package/docs/api/autocomplete.md +134 -0
- package/docs/api/checkbox.md +98 -0
- package/docs/api/date-picker.md +152 -0
- package/docs/api/date-range-picker.md +175 -0
- package/docs/api/date-time-picker.md +159 -0
- package/docs/api/file-upload.md +85 -0
- package/docs/api/number-input.md +162 -0
- package/docs/api/password-input.md +142 -0
- package/docs/api/pdf-viewer.md +50 -0
- package/docs/api/radio-group.md +126 -0
- package/docs/api/rich-text-editor.md +86 -0
- package/docs/api/search-filter.md +192 -0
- package/docs/api/search-input.md +160 -0
- package/docs/api/searchable-select.md +195 -0
- package/docs/api/segmented-control.md +93 -0
- package/docs/api/selection-list.md +120 -0
- package/docs/api/slide-toggle.md +105 -0
- package/docs/api/text-area.md +148 -0
- package/docs/api/text-input.md +159 -0
- package/docs/api/time-input.md +99 -0
- package/docs/api/time-picker.md +130 -0
- package/package.json +20 -4
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# AdvancedSelectComponent
|
|
2
|
+
|
|
3
|
+
Grouped options and multiple selection.
|
|
4
|
+
|
|
5
|
+
Selector `ui-advanced-select`.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { AdvancedSelectComponent } from 'angular-ui-controls';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Add `AdvancedSelectComponent` to the host component's imports. Add `FormsModule` for this example.
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<ui-advanced-select
|
|
17
|
+
inputId="advancedDepartments"
|
|
18
|
+
label="Roles (grouped)"
|
|
19
|
+
[(ngModel)]="advancedDepartments"
|
|
20
|
+
[options]="groupedRoles"
|
|
21
|
+
[grouped]="true"
|
|
22
|
+
groupLabelKey="groupName"
|
|
23
|
+
groupChildrenKey="items"
|
|
24
|
+
labelKey="name"
|
|
25
|
+
valueKey="id"
|
|
26
|
+
[multiple]="true"
|
|
27
|
+
/>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Example fields in the host component.
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
advancedDepartments: number[] = [];
|
|
34
|
+
groupedRoles = [
|
|
35
|
+
{
|
|
36
|
+
groupName: 'Engineering',
|
|
37
|
+
items: [
|
|
38
|
+
{ id: 101, name: 'Frontend' },
|
|
39
|
+
{ id: 102, name: 'Backend' },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
groupName: 'Product',
|
|
44
|
+
items: [
|
|
45
|
+
{ id: 201, name: 'Designer' },
|
|
46
|
+
{ id: 202, name: 'PM' },
|
|
47
|
+
...Array.from({ length: 75 }, (_, index) => ({
|
|
48
|
+
id: 203 + index,
|
|
49
|
+
name: `Product role ${index + 1}`,
|
|
50
|
+
})),
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Use Angular Forms or `[(value)]` for binding. The tables include inherited bindings. The Required column refers to whether the template must supply the input.
|
|
57
|
+
|
|
58
|
+
## Inputs
|
|
59
|
+
|
|
60
|
+
| Input | Type | Required | Default | Description |
|
|
61
|
+
| --------------------------------- | --------------------- | -------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
62
|
+
| `itemSize` | `number` | No | `36` | Height in pixels of each option for virtual scrolling (defaults to 36px). |
|
|
63
|
+
| `inputId` | `string` | Yes | — | Identifier assigned to the inner control. Set `idPrefix` to add a prefix. |
|
|
64
|
+
| `label` | `string` | No | `''` | Label text or translation key displayed for this control. |
|
|
65
|
+
| `showSearch` | `boolean` | No | `true` | Enable the search in the option. |
|
|
66
|
+
| `errorMessage` | `string` | No | `''` | Error message shown when validation fails. |
|
|
67
|
+
| `required` | `boolean` | No | `false` | Marks the control as required. Configure any parent-form validators separately. |
|
|
68
|
+
| `fieldName` | `string \| number` | No | `undefined` | Consumer-defined field identifier included in event metadata. |
|
|
69
|
+
| `selectPlaceholder` | `string` | No | `''` | Placeholder text for the select field. |
|
|
70
|
+
| `searchPlaceholder` | `string` | No | `''` | Placeholder text for search input. |
|
|
71
|
+
| `readonly` | `boolean` | No | `false` | Requests the existing read-only behavior without disabling the parent form control. |
|
|
72
|
+
| `showToggleAllCheckbox` | `boolean` | No | `false` | Displays "Select All" checkbox. |
|
|
73
|
+
| `noEntriesFoundLabel` | `string` | No | `'No records found'` | Label shown when no entries are found. |
|
|
74
|
+
| `toggleAllCheckboxTooltipMessage` | `string` | No | `''` | Tooltip message for select-all checkbox. |
|
|
75
|
+
| `showSearchCheckbox` | `boolean` | No | `false` | **Deprecated.** Use showToggleAllCheckbox. |
|
|
76
|
+
| `multiple` | `boolean` | No | `false` | Enables the existing multiple-selection mode. |
|
|
77
|
+
| `options` | `any[]` | No | `[]` | Options rendered by the control; use the label/value key inputs for object options. |
|
|
78
|
+
| `labelKey` | `string` | No | `''` | Property name read from an option object to obtain its visible label. |
|
|
79
|
+
| `valueKey` | `string` | No | `''` | Property name used to identify or extract an option value. |
|
|
80
|
+
| `hiddenKey` | `string` | No | `'isHidden'` | Key in option object used to determine if the option should be hidden from dropdown. Defaults to 'isHidden'. |
|
|
81
|
+
| `grouped` | `boolean` | No | `false` | Enables grouped select display. |
|
|
82
|
+
| `isGroupingEnabled` | `boolean` | No | `false` | **Deprecated.** Use grouped. |
|
|
83
|
+
| `groupLabelKey` | `string` | No | `''` | Property key for group label (defaults to ''). |
|
|
84
|
+
| `groupChildrenKey` | `string` | No | `''` | Property key for group child options array (defaults to ''). |
|
|
85
|
+
| `enableAllOption` | `boolean` | No | `false` | Key used to map model value to option. |
|
|
86
|
+
| `enableSorting` | `boolean` | No | `false` | Key used to enable / disable sorting. |
|
|
87
|
+
| `sortAscending` | `boolean` | No | `true` | Defines whether the list should be sorted in ascending order. |
|
|
88
|
+
| `sortKey` | `string` | No | `''` | Key used to sort the array. |
|
|
89
|
+
| `showClearIcon` | `boolean` | No | `false` | To clear the selected dropdown list. |
|
|
90
|
+
| `displayFields` | `string[]` | No | `[]` | Conatins the multiple options. |
|
|
91
|
+
| `layoutMode` | `'split' \| 'inline'` | No | `'inline'` | Option text layout: inline joins the display fields; split separates primary and secondary fields. |
|
|
92
|
+
| `serverSideSearch` | `boolean` | No | `false` | Enables server-side/external search by bypassing local pipe filtering. |
|
|
93
|
+
| `singleLineOption` | `boolean` | No | `false` | Keeps each option on a single line with ellipsis; full text is shown in a tooltip on hover when truncated. |
|
|
94
|
+
| `searchStartsWith` | `boolean` | No | `false` | Configuration for search starts with. |
|
|
95
|
+
| `disabled` | `boolean` | No | `false` | Disables the control. Angular Forms can also update this state through setDisabledState. Uses Angular boolean attribute coercion. |
|
|
96
|
+
| `idPrefix` | `string` | No | `''` | Optional namespace prepended to inner control IDs to distinguish repeated instances. |
|
|
97
|
+
| `value` | `any` | No | `null` | Canonical value binding. Programmatic writes never emit user change events. |
|
|
98
|
+
|
|
99
|
+
## Outputs
|
|
100
|
+
|
|
101
|
+
| Output | Payload | When it fires |
|
|
102
|
+
| ------------------ | -------------------------------------- | ----------------------------------------------------------------------- |
|
|
103
|
+
| `selectAllChange` | `SearchableSelectToggleAllEvent` | Emits when the select-all action runs. |
|
|
104
|
+
| `selectionChange` | `SearchableSelectSelectionChangeEvent` | Emits when the selection handler processes a selection. |
|
|
105
|
+
| `panelOpenChange` | `SearchableSelectOpenCloseEvent` | Emits when the select panel open state changes. |
|
|
106
|
+
| `panelOpened` | `SearchableSelectFieldInfo` | Emits when the select panel opens. |
|
|
107
|
+
| `panelClosed` | `SearchableSelectFieldInfo` | Emits when the select panel closes. |
|
|
108
|
+
| `blurred` | `SearchableSelectFieldInfo` | Emits when the control loses focus. |
|
|
109
|
+
| `optionClicked` | `SearchableSelectOptionClickEvent` | Emits when an option is clicked. |
|
|
110
|
+
| `searchTextChange` | `string` | Emits the updated search string for consumer filtering. |
|
|
111
|
+
| `valueChange` | `any` | Emits the raw value once per committed user edit. Supports `[(value)]`. |
|
|
112
|
+
|
|
113
|
+
## Local option and event types
|
|
114
|
+
|
|
115
|
+
These declarations describe the payload and option shapes. Import availability depends on the package entry point.
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
export interface SearchableSelectToggleAllEvent extends SearchableSelectFieldInfo {
|
|
119
|
+
/** True if all options are selected, false if cleared */
|
|
120
|
+
selectAllValue: boolean;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface SearchableSelectFieldInfo {
|
|
124
|
+
/** Current value(s) bound to the select */
|
|
125
|
+
value: any;
|
|
126
|
+
/** @deprecated Use value. */
|
|
127
|
+
modelValue: any;
|
|
128
|
+
|
|
129
|
+
/** Field identifier used in parent component */
|
|
130
|
+
fieldName: string | number;
|
|
131
|
+
/** @deprecated Use fieldName. */
|
|
132
|
+
textFieldName: string | number;
|
|
133
|
+
|
|
134
|
+
/** Optional reference to native input element */
|
|
135
|
+
inputRef?: Element | null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface SearchableSelectSelectionChangeEvent extends SearchableSelectFieldInfo {
|
|
139
|
+
/** MatSelect change event containing selected value(s) */
|
|
140
|
+
selectionChange: MatSelectChange | null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface SearchableSelectOpenCloseEvent extends SearchableSelectFieldInfo {
|
|
144
|
+
/** Boolean indicating whether the dropdown is opened or closed */
|
|
145
|
+
isOpen: boolean;
|
|
146
|
+
/** @deprecated Use isOpen. */
|
|
147
|
+
selectionChange: boolean;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface SearchableSelectOptionClickEvent {
|
|
151
|
+
/** The clicked option */
|
|
152
|
+
activeOption: SearchableSelectOption;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export type SearchableSelectOption = any;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Public instance properties
|
|
159
|
+
|
|
160
|
+
These TypeScript properties include state exposed by the class. Use the Inputs and Outputs tables for Angular template bindings.
|
|
161
|
+
|
|
162
|
+
| Property | Type | Description |
|
|
163
|
+
| -------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------ |
|
|
164
|
+
| `internalSelectList` | `any[]` | — |
|
|
165
|
+
| `rawOptionsList` | `any[]` | — |
|
|
166
|
+
| `hasNoMatchingEntries` | `boolean` | — |
|
|
167
|
+
| `searchText` | `string` | Search text entered by the user. |
|
|
168
|
+
| `hasSelectedValue` | `boolean` | Internal model bound to mat-select. |
|
|
169
|
+
| `selectedValue` | `any` | — |
|
|
170
|
+
| `inputModelValue` | `any` | **Deprecated.** Use selectedValue for direct component access. |
|
|
171
|
+
| `modelValue` | `any` | Internal model getter/setter backed by the shared control value. |
|
|
172
|
+
| `filterConditionStartWith` | `boolean` | Enable/disable search in the starting/conatin mode. |
|
|
173
|
+
| `hiddenOptions` | `Signal<any[]>` | — |
|
|
174
|
+
| `trackByFn` | `(index: number, item: any) => any` | — |
|
|
175
|
+
| `compareObjects` | `(option1: any, option2: any) => boolean` | — |
|
|
176
|
+
| `secondaryFields` | `string[]` | Secondary fields for split layout (excludes primary display key). |
|
|
177
|
+
| `onChangeCallback` | `(value: T \| null) => void` | Standard change and touch callbacks. |
|
|
178
|
+
| `onTouchedCallback` | `() => void` | — |
|
|
179
|
+
| `effectiveId` | `string` | Plain string property bound in template [id]="effectiveId" (zero function or CD overhead). |
|
|
180
|
+
|
|
181
|
+
## Public instance methods
|
|
182
|
+
|
|
183
|
+
The list includes Angular Forms plumbing and component event handlers as well as methods called directly by consumers.
|
|
184
|
+
|
|
185
|
+
| Method | Signature | Description |
|
|
186
|
+
| ----------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
187
|
+
| `writeValue` | `(newValue: any): void` | — |
|
|
188
|
+
| `handleOpenedChange` | `(isOpen: boolean): void` | — |
|
|
189
|
+
| `getSelectedModelValue` | `(selectedValue: any): any` | — |
|
|
190
|
+
| `applyFilter` | `(): void` | — |
|
|
191
|
+
| `getTriggerText` | `(): string` | Formats the trigger display text for the closed select input. |
|
|
192
|
+
| `configureModelValue` | `(newValue: any): void` | Maps the incoming model value to a matching option from the select list using the configured valueKey. |
|
|
193
|
+
| `optionSelectionChange` | `(event: any, option: any): void` | — |
|
|
194
|
+
| `handleSelectionChange` | `(selectionChange: MatSelectChange): void` | Emits when the selected value changes in the dropdown. |
|
|
195
|
+
| `toggleSelectAll` | `(selectAllValue: boolean): void` | Handles select-all toggle action from search checkbox. |
|
|
196
|
+
| `openedChange` | `(opened: boolean): void` | Emits when the open state of the dropdown changes. |
|
|
197
|
+
| `opened` | `(): void` | Emits when the dropdown panel is opened. |
|
|
198
|
+
| `closed` | `(): void` | Emits when the dropdown panel is closed. |
|
|
199
|
+
| `blur` | `(): void` | Emits when the select element loses focus. |
|
|
200
|
+
| `optionClick` | `(selectedOption: any): void` | Emits when a select option is clicked. |
|
|
201
|
+
| `rebuildGroupedList` | `(): void` | — |
|
|
202
|
+
| `searchTextModelChange` | `(changedSearchText: string): void` | — |
|
|
203
|
+
| `getOptionText` | `(option: any): string` | Formats option text for tooltip and display matching the rendered layout. |
|
|
204
|
+
| `isTooltipDisabled` | `(optionRef: unknown, text: string): boolean` | — |
|
|
205
|
+
| `open` | `(): void` | Opens the dropdown panel programmatically. |
|
|
206
|
+
| `clearSelect` | `(): void` | — |
|
|
207
|
+
| `configureId` | `(): void` | — |
|
|
208
|
+
| `commitValue` | `(value?: any \| null): void` | Commit a view edit after the inner control has updated its local model. |
|
|
209
|
+
| `handleFocusOut` | `(event: FocusEvent): void` | Touch the outer control only when focus leaves the whole composite control. |
|
|
210
|
+
| `registerOnChange` | `(fn: (value: any \| null) => void): void` | Registers a callback function that is called when the control's value changes in the UI. |
|
|
211
|
+
| `registerOnTouched` | `(fn: () => void): void` | Registers a callback function that is called when the control is touched. |
|
|
212
|
+
| `setDisabledState` | `(isDisabled: boolean): void` | Updates the disabled state from the form model. |
|
|
213
|
+
|
|
214
|
+
[Component source](https://github.com/Abhilash-A-S/angular-ui-controls/blob/develop/projects/ui-controls/src/lib/component/advanced-select/advanced-select.component.ts) · [Playground example](https://github.com/Abhilash-A-S/angular-ui-controls/blob/develop/projects/demo/src/app.component.html)
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# AutocompleteComponent
|
|
2
|
+
|
|
3
|
+
Suggestions while typing.
|
|
4
|
+
|
|
5
|
+
Selector `ui-autocomplete`.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { AutocompleteComponent } from 'angular-ui-controls';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Add `AutocompleteComponent` to the host component's imports. Add `FormsModule` for this example.
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<ui-autocomplete
|
|
17
|
+
inputId="country"
|
|
18
|
+
label="Country"
|
|
19
|
+
[(ngModel)]="country"
|
|
20
|
+
[options]="countries"
|
|
21
|
+
labelKey="label"
|
|
22
|
+
valueKey="code"
|
|
23
|
+
/>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Example fields in the host component.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
country: string | null = null;
|
|
30
|
+
countries = [
|
|
31
|
+
{ code: 'IN', label: 'India' },
|
|
32
|
+
{ code: 'US', label: 'United States' },
|
|
33
|
+
{ code: 'DE', label: 'Germany' },
|
|
34
|
+
{ code: 'JP', label: 'Japan' },
|
|
35
|
+
];
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Use Angular Forms or `[(value)]` for binding. The tables include inherited bindings. The Required column refers to whether the template must supply the input.
|
|
39
|
+
|
|
40
|
+
## Inputs
|
|
41
|
+
|
|
42
|
+
| Input | Type | Required | Default | Description |
|
|
43
|
+
| ------------------------ | ------------------------------------------------------------------------------------------------ | -------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
44
|
+
| `inputId` | `string` | Yes | — | Identifier assigned to the inner control. Set `idPrefix` to add a prefix. |
|
|
45
|
+
| `readonly` | `boolean` | No | `false` | Requests the existing read-only behavior without disabling the parent form control. |
|
|
46
|
+
| `required` | `boolean` | No | `false` | Marks the control as required. Configure any parent-form validators separately. |
|
|
47
|
+
| `options` | `any[]` | No | `[]` | Options rendered by the control; use the label/value key inputs for object options. |
|
|
48
|
+
| `label` | `string` | No | `''` | Label text or translation key displayed for this control. |
|
|
49
|
+
| `maxLength` | `number` | No | `0` | Maximum character length for the autocomplete input. |
|
|
50
|
+
| `labelKey` | `string` | No | `''` | Property name read from an option object to obtain its visible label. |
|
|
51
|
+
| `valueKey` | `string` | No | `''` | Property name used to identify or extract an option value. |
|
|
52
|
+
| `optionNgClass` | `\| ((option: any) => string \| string[] \| Set<string> \| Record<string, boolean>) \| null` | No | `null` | Optional resolver returning an ngClass value for each option (conditional coloring/styling). Receives the raw option and may return a string, string[] or { className: boolean } map. |
|
|
53
|
+
| `panelClass` | `string \| string[]` | No | `''` | Additional CSS class or classes applied to the existing overlay panel. |
|
|
54
|
+
| `errorMessage` | `string` | No | `''` | to show error message. |
|
|
55
|
+
| `virtualScroll` | `boolean` | No | `false` | Renders the options inside a cdk virtual scroll viewport (use for large lists). |
|
|
56
|
+
| `singleLineOption` | `boolean` | No | `false` | Keeps each option on a single line with ellipsis; full text is shown in a tooltip on hover when truncated. |
|
|
57
|
+
| `virtualScrollItemSize` | `number` | No | `48` | Height (px) of a single option row; must match the rendered mat-option height when virtualScroll is on. |
|
|
58
|
+
| `virtualScrollMaxHeight` | `number` | No | `256` | Maximum height (px) of the virtual scroll viewport (mat-autocomplete panel max-height is 256px). |
|
|
59
|
+
| `autocompleteModel` | `AutocompleteModel` | No | `{ value: '', fieldId: '', fieldName: '' }` | Autocomplete value and field metadata object; its value is synchronized with the shared control value. |
|
|
60
|
+
| `fieldName` | `string \| number` | No | `undefined` | Consumer-defined field identifier included in event metadata. |
|
|
61
|
+
| `placeholder` | `string` | No | `''` | Hint text or translation key displayed while the control is empty. |
|
|
62
|
+
| `disabled` | `boolean` | No | `false` | Disables the control. Angular Forms can also update this state through setDisabledState. Uses Angular boolean attribute coercion. |
|
|
63
|
+
| `idPrefix` | `string` | No | `''` | Optional namespace prepended to inner control IDs to distinguish repeated instances. |
|
|
64
|
+
| `value` | `any` | No | `null` | Canonical value binding. Programmatic writes never emit user change events. |
|
|
65
|
+
|
|
66
|
+
## Outputs
|
|
67
|
+
|
|
68
|
+
| Output | Payload | When it fires |
|
|
69
|
+
| -------------- | ------- | --------------------------------------------------------------------------- |
|
|
70
|
+
| `valueChanged` | `any` | Emits the existing value-change payload; remains separate from modelChange. |
|
|
71
|
+
| `modelChange` | `any` | Emits a model-change event with field metadata. |
|
|
72
|
+
| `inputChanged` | `any` | Emits when the user edits the field. |
|
|
73
|
+
| `focusGained` | `any` | Emits when the inner field gains focus. |
|
|
74
|
+
| `focusLost` | `any` | Emits when the inner field loses focus. |
|
|
75
|
+
| `keyPressed` | `any` | Emits on the inner field keydown event. |
|
|
76
|
+
| `keyReleased` | `any` | Emits on the inner field keyup event. |
|
|
77
|
+
| `enterPressed` | `any` | Emits when Enter is released in the inner field. |
|
|
78
|
+
| `valueChange` | `any` | Emits the raw value once per committed user edit. Supports `[(value)]`. |
|
|
79
|
+
|
|
80
|
+
## Local option and event types
|
|
81
|
+
|
|
82
|
+
These declarations describe the payload and option shapes. Import availability depends on the package entry point.
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
export interface AutocompleteModel {
|
|
86
|
+
value?: any;
|
|
87
|
+
fieldId?: string | number;
|
|
88
|
+
fieldName?: string | number;
|
|
89
|
+
textFieldName?: string | number;
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Public instance properties
|
|
94
|
+
|
|
95
|
+
These TypeScript properties include state exposed by the class. Use the Inputs and Outputs tables for Angular template bindings.
|
|
96
|
+
|
|
97
|
+
| Property | Type | Description |
|
|
98
|
+
| ----------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
99
|
+
| `searchText` | `string` | — |
|
|
100
|
+
| `panelClassList` | `string` | — |
|
|
101
|
+
| `autoComplete` | `NgModel` | — |
|
|
102
|
+
| `autoCompleteBindvalue` | `(autocompleteOption: any) => string` | Determines the display value for an autocomplete option. Priority: 1. labelKey of the list item matching a bound primitive value (e.g. an id) 2. valueKey 3. labelKey 4. fallback to the option itself. |
|
|
103
|
+
| `trackByFn` | `(index: number, option: any) => any` | Track function for cdkVirtualFor. |
|
|
104
|
+
| `onChangeCallback` | `(value: T \| null) => void` | Standard change and touch callbacks. |
|
|
105
|
+
| `onTouchedCallback` | `() => void` | — |
|
|
106
|
+
| `effectiveId` | `string` | Plain string property bound in template [id]="effectiveId" (zero function or CD overhead). |
|
|
107
|
+
|
|
108
|
+
## Public instance methods
|
|
109
|
+
|
|
110
|
+
The list includes Angular Forms plumbing and component event handlers as well as methods called directly by consumers.
|
|
111
|
+
|
|
112
|
+
| Method | Signature | Description |
|
|
113
|
+
| ------------------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
114
|
+
| `searchTextChanges` | `(changeEvent: Event): void` | Handles changes in the input text field. Updates the local searchText value. If the input is cleared, resets the autocomplete model and emits a selection change event. |
|
|
115
|
+
| `modelValueChange` | `(): void` | Emits an event whenever the bound model value changes. Typically triggered by Angular's ngModelChange. |
|
|
116
|
+
| `inputChange` | `(): void` | Emits an event on every input value change (typing). Used for live search or filtering behaviors. |
|
|
117
|
+
| `focusChange` | `(): void` | Emits an event when the input field gains focus. |
|
|
118
|
+
| `blurChange` | `(): void` | Emits an event when the input field loses focus. |
|
|
119
|
+
| `keydownHandle` | `(event: KeyboardEvent): void` | Emits the raw keyboard event when a key is pressed down. |
|
|
120
|
+
| `keyupHandle` | `(event: KeyboardEvent): void` | Emits the raw keyboard event when a key is released. |
|
|
121
|
+
| `keyEnterHandle` | `(event: Event): void` | Emits an event when the Enter key is pressed. |
|
|
122
|
+
| `onSelectionChange` | `(): void` | Handles selection changes from the autocomplete dropdown. Emits the selected value and resets the search text. |
|
|
123
|
+
| `getViewportHeight` | `(count?: number): number` | Calculates the virtual scroll viewport height so short lists don't leave empty space and long lists are capped. |
|
|
124
|
+
| `onPanelOpened` | `(): void` | The viewport is measured while the overlay is being attached, so re-measure once the panel is rendered to avoid a blank list. |
|
|
125
|
+
| `onPanelClosed` | `(): void` | Reset the virtual scroll position so the next open starts from the top. |
|
|
126
|
+
| `configureId` | `(): void` | — |
|
|
127
|
+
| `commitValue` | `(value?: any \| null): void` | Commit a view edit after the inner control has updated its local model. |
|
|
128
|
+
| `handleFocusOut` | `(event: FocusEvent): void` | Touch the outer control only when focus leaves the whole composite control. |
|
|
129
|
+
| `writeValue` | `(value: any \| null): void` | Writes a new value from the form model to the view. |
|
|
130
|
+
| `registerOnChange` | `(fn: (value: any \| null) => void): void` | Registers a callback function that is called when the control's value changes in the UI. |
|
|
131
|
+
| `registerOnTouched` | `(fn: () => void): void` | Registers a callback function that is called when the control is touched. |
|
|
132
|
+
| `setDisabledState` | `(isDisabled: boolean): void` | Updates the disabled state from the form model. |
|
|
133
|
+
|
|
134
|
+
[Component source](https://github.com/Abhilash-A-S/angular-ui-controls/blob/develop/projects/ui-controls/src/lib/component/autocomplete/autocomplete.component.ts) · [Playground example](https://github.com/Abhilash-A-S/angular-ui-controls/blob/develop/projects/demo/src/app.component.html)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# CheckboxComponent
|
|
2
|
+
|
|
3
|
+
Boolean selection.
|
|
4
|
+
|
|
5
|
+
Selector `ui-checkbox`.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { CheckboxComponent } from 'angular-ui-controls';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Add `CheckboxComponent` to the host component's imports. Add `FormsModule` for this example.
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<ui-checkbox inputId="updates" label="Receive updates" [(ngModel)]="updates" />
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Example fields in the host component.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
updates = false;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Use Angular Forms or `[(value)]` for binding. The tables include inherited bindings. The Required column refers to whether the template must supply the input.
|
|
26
|
+
|
|
27
|
+
## Inputs
|
|
28
|
+
|
|
29
|
+
| Input | Type | Required | Default | Description |
|
|
30
|
+
| --------------- | ------------------ | -------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
31
|
+
| `inputId` | `string` | Yes | — | Identifier assigned to the inner control. Set `idPrefix` to add a prefix. |
|
|
32
|
+
| `tooltip` | `string` | No | `''` | Tooltip text displayed on hover. |
|
|
33
|
+
| `label` | `string` | No | `''` | Label text or translation key displayed for this control. |
|
|
34
|
+
| `errorMessage` | `string` | No | `''` | Error message displayed for validation. |
|
|
35
|
+
| `required` | `boolean` | No | `false` | Marks the control as required. Configure any parent-form validators separately. |
|
|
36
|
+
| `fieldName` | `string \| number` | No | `undefined` | Consumer-defined field identifier included in event metadata. |
|
|
37
|
+
| `indeterminate` | `boolean` | No | `false` | The indeterminate state is typically used in a "select all" scenario, where it indicates that some but not all child items are selected. |
|
|
38
|
+
| `disabled` | `boolean` | No | `false` | Disables the control. Angular Forms can also update this state through setDisabledState. Uses Angular boolean attribute coercion. |
|
|
39
|
+
| `idPrefix` | `string` | No | `''` | Optional namespace prepended to inner control IDs to distinguish repeated instances. |
|
|
40
|
+
| `value` | `boolean \| null` | No | `null` | Canonical value binding. Programmatic writes never emit user change events. |
|
|
41
|
+
|
|
42
|
+
## Outputs
|
|
43
|
+
|
|
44
|
+
| Output | Payload | When it fires |
|
|
45
|
+
| -------------- | -------------------------- | ----------------------------------------------------------------------- |
|
|
46
|
+
| `clicked` | `MouseEvent` | Emits when the existing click handler runs. |
|
|
47
|
+
| `modelChange` | `CheckboxFieldInfo` | Emits a model-change event with field metadata. |
|
|
48
|
+
| `inputChanged` | `CheckboxInputChangeEvent` | Emits when the user edits the field. |
|
|
49
|
+
| `valueChange` | `boolean \| null` | Emits the raw value once per committed user edit. Supports `[(value)]`. |
|
|
50
|
+
|
|
51
|
+
## Local option and event types
|
|
52
|
+
|
|
53
|
+
These declarations describe the payload and option shapes. Import availability depends on the package entry point.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
export interface CheckboxFieldInfo {
|
|
57
|
+
inputRef?: Element | null;
|
|
58
|
+
modelValue: boolean;
|
|
59
|
+
textFieldName: string | number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface CheckboxInputChangeEvent extends CheckboxFieldInfo {
|
|
63
|
+
changeEvent: Event | MatCheckboxChange;
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Public instance properties
|
|
68
|
+
|
|
69
|
+
These TypeScript properties include state exposed by the class. Use the Inputs and Outputs tables for Angular template bindings.
|
|
70
|
+
|
|
71
|
+
| Property | Type | Description |
|
|
72
|
+
| ------------------- | ---------------------------- | ------------------------------------------------------------------------------------------ |
|
|
73
|
+
| `isChecked` | `boolean` | Internal model bound to checkbox. |
|
|
74
|
+
| `inputModelValue` | `boolean` | **Deprecated.** Use isChecked for direct component access. |
|
|
75
|
+
| `modelValue` | `boolean` | Internal model alias for template/fieldInfo compatibility. |
|
|
76
|
+
| `onChangeCallback` | `(value: T \| null) => void` | Standard change and touch callbacks. |
|
|
77
|
+
| `onTouchedCallback` | `() => void` | — |
|
|
78
|
+
| `effectiveId` | `string` | Plain string property bound in template [id]="effectiveId" (zero function or CD overhead). |
|
|
79
|
+
|
|
80
|
+
## Public instance methods
|
|
81
|
+
|
|
82
|
+
The list includes Angular Forms plumbing and component event handlers as well as methods called directly by consumers.
|
|
83
|
+
|
|
84
|
+
| Method | Signature | Description |
|
|
85
|
+
| ------------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
86
|
+
| `modelValueChange` | `(): void` | Emits updated model value when ngModel changes. |
|
|
87
|
+
| `inputChange` | `(changeValue: Event, typeofChange: string): void` | Emits input event details along with field info. |
|
|
88
|
+
| `onChangeHandle` | `(changeValue: MatCheckboxChange, typeofChange: string): void` | Handles checkbox change event. |
|
|
89
|
+
| `onCheckboxClick` | `(event: MouseEvent): void` | Emits click event when checkbox is clicked. |
|
|
90
|
+
| `configureId` | `(): void` | — |
|
|
91
|
+
| `commitValue` | `(value?: boolean \| null): void` | Commit a view edit after the inner control has updated its local model. |
|
|
92
|
+
| `handleFocusOut` | `(event: FocusEvent): void` | Touch the outer control only when focus leaves the whole composite control. |
|
|
93
|
+
| `writeValue` | `(value: boolean \| null): void` | Writes a new value from the form model to the view. |
|
|
94
|
+
| `registerOnChange` | `(fn: (value: boolean \| null) => void): void` | Registers a callback function that is called when the control's value changes in the UI. |
|
|
95
|
+
| `registerOnTouched` | `(fn: () => void): void` | Registers a callback function that is called when the control is touched. |
|
|
96
|
+
| `setDisabledState` | `(isDisabled: boolean): void` | Updates the disabled state from the form model. |
|
|
97
|
+
|
|
98
|
+
[Component source](https://github.com/Abhilash-A-S/angular-ui-controls/blob/develop/projects/ui-controls/src/lib/component/checkbox/checkbox.component.ts) · [Playground example](https://github.com/Abhilash-A-S/angular-ui-controls/blob/develop/projects/demo/src/app.component.html)
|