angular-ui-controls 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +126 -2
- 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/fesm2022/angular-ui-controls-editor-build-Cm2HSXEy.mjs +2 -0
- package/fesm2022/angular-ui-controls-editor-build-Cm2HSXEy.mjs.map +1 -0
- package/fesm2022/angular-ui-controls-forms.mjs +865 -0
- package/fesm2022/angular-ui-controls-forms.mjs.map +1 -0
- package/fesm2022/angular-ui-controls-text-input.mjs +1210 -0
- package/fesm2022/angular-ui-controls-text-input.mjs.map +1 -0
- package/fesm2022/angular-ui-controls.mjs +7181 -0
- package/fesm2022/angular-ui-controls.mjs.map +1 -0
- package/forms/index.d.ts +425 -0
- package/forms/index.d.ts.map +1 -0
- package/index.d.ts +4345 -0
- package/index.d.ts.map +1 -0
- package/package.json +82 -3
- package/text-input/index.d.ts +609 -0
- package/text-input/index.d.ts.map +1 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# SearchableSelectComponent
|
|
2
|
+
|
|
3
|
+
Searchable option list.
|
|
4
|
+
|
|
5
|
+
Selector `ui-searchable-select`.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { SearchableSelectComponent } from 'angular-ui-controls/forms';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Add `SearchableSelectComponent` to the host component's imports. Add `FormsModule` for this example.
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<ui-searchable-select
|
|
17
|
+
inputId="department"
|
|
18
|
+
label="Department"
|
|
19
|
+
[(ngModel)]="department"
|
|
20
|
+
[options]="departments"
|
|
21
|
+
labelKey="name"
|
|
22
|
+
valueKey="id"
|
|
23
|
+
[hideAllOption]="true"
|
|
24
|
+
/>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Example fields in the host component.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
department: number | null = null;
|
|
31
|
+
departments = [
|
|
32
|
+
{ id: 1, name: 'Engineering' },
|
|
33
|
+
{ id: 2, name: 'Design' },
|
|
34
|
+
{ id: 3, name: 'Support' },
|
|
35
|
+
...Array.from({ length: 75 }, (_, i) => ({ id: i + 4, name: 'Regional office ' + (i + 1) })),
|
|
36
|
+
];
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Use Angular Forms or `[(value)]` for binding. The tables include inherited bindings. The Required column refers to whether the template must supply the input.
|
|
40
|
+
|
|
41
|
+
## Inputs
|
|
42
|
+
|
|
43
|
+
| Input | Type | Required | Default | Description |
|
|
44
|
+
| --------------------------------- | -------------------------- | -------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
45
|
+
| `itemSize` | `number` | No | `36` | Height in pixels of each option for virtual scrolling (defaults to 36px). |
|
|
46
|
+
| `inputId` | `string` | Yes | — | Identifier assigned to the inner control. Set `idPrefix` to add a prefix. |
|
|
47
|
+
| `label` | `string` | No | `''` | Label text or translation key displayed for this control. |
|
|
48
|
+
| `showSearch` | `boolean` | No | `true` | Enable the search in the option. |
|
|
49
|
+
| `errorMessage` | `string` | No | `''` | Error message shown when validation fails. |
|
|
50
|
+
| `required` | `boolean` | No | `false` | Marks the control as required. Configure any parent-form validators separately. |
|
|
51
|
+
| `fieldName` | `string \| number` | No | `undefined` | Consumer-defined field identifier included in event metadata. |
|
|
52
|
+
| `selectPlaceholder` | `string` | No | `''` | Placeholder text for the select field. |
|
|
53
|
+
| `searchPlaceholder` | `string` | No | `''` | Placeholder text for search input. |
|
|
54
|
+
| `readonly` | `boolean` | No | `false` | Requests the existing read-only behavior without disabling the parent form control. |
|
|
55
|
+
| `showToggleAllCheckbox` | `boolean` | No | `false` | Displays "Select All" checkbox. |
|
|
56
|
+
| `noEntriesFoundLabel` | `string` | No | `'No Entries Found'` | Label shown when no entries are found. |
|
|
57
|
+
| `toggleAllCheckboxTooltipMessage` | `string` | No | `''` | Tooltip message for select-all checkbox. |
|
|
58
|
+
| `showSearchCheckbox` | `boolean` | No | `false` | Shows checkbox in search area. |
|
|
59
|
+
| `multiple` | `boolean` | No | `false` | Enables the existing multiple-selection mode. |
|
|
60
|
+
| `options` | `SearchableSelectOption[]` | No | `[]` | Options rendered by the control; use the label/value key inputs for object options. |
|
|
61
|
+
| `labelKey` | `string` | No | `''` | Property name read from an option object to obtain its visible label. |
|
|
62
|
+
| `valueKey` | `string` | No | `''` | Property name used to identify or extract an option value. |
|
|
63
|
+
| `hiddenKey` | `string` | No | `'isHidden'` | Key in option object used to determine if the option should be hidden from dropdown. Defaults to 'isHidden'. |
|
|
64
|
+
| `serverSideSearch` | `boolean` | No | `false` | Enables server-side/external search by bypassing local pipe filtering. |
|
|
65
|
+
| `searchStartsWith` | `boolean` | No | `false` | Configuration for search starts with. |
|
|
66
|
+
| `showClearIcon` | `boolean` | No | `false` | To clear the selected dropdown list. |
|
|
67
|
+
| `enableAllOption` | `boolean` | No | `false` | Key used to map model value to option. |
|
|
68
|
+
| `hideAllOption` | `boolean` | No | `false` | Removes the "All" option that is otherwise added automatically in multi-select mode. |
|
|
69
|
+
| `enableSorting` | `boolean` | No | `false` | Key used to enable / disable sorting. |
|
|
70
|
+
| `singleLineOption` | `boolean` | No | `false` | Keeps each option on a single line with ellipsis; full text is shown in a tooltip on hover when truncated. |
|
|
71
|
+
| `sortAscending` | `boolean` | No | `true` | Defines whether the list should be sorted in ascending order. |
|
|
72
|
+
| `sortKey` | `string` | No | `''` | Key used to sort the array. |
|
|
73
|
+
| `disabled` | `boolean` | No | `false` | Disables the control. Angular Forms can also update this state through setDisabledState. Uses Angular boolean attribute coercion. |
|
|
74
|
+
| `idPrefix` | `string` | No | `''` | Optional namespace prepended to inner control IDs to distinguish repeated instances. |
|
|
75
|
+
| `value` | `any` | No | `null` | Canonical value binding. Programmatic writes never emit user change events. |
|
|
76
|
+
|
|
77
|
+
## Outputs
|
|
78
|
+
|
|
79
|
+
| Output | Payload | When it fires |
|
|
80
|
+
| ------------------ | -------------------------------------- | ----------------------------------------------------------------------- |
|
|
81
|
+
| `selectAllChange` | `SearchableSelectToggleAllEvent` | Emits when the select-all action runs. |
|
|
82
|
+
| `selectionChange` | `SearchableSelectSelectionChangeEvent` | Emits when the selection handler processes a selection. |
|
|
83
|
+
| `panelOpenChange` | `SearchableSelectOpenCloseEvent` | Emits when the select panel open state changes. |
|
|
84
|
+
| `panelOpened` | `SearchableSelectFieldInfo` | Emits when the select panel opens. |
|
|
85
|
+
| `panelClosed` | `SearchableSelectFieldInfo` | Emits when the select panel closes. |
|
|
86
|
+
| `blurred` | `SearchableSelectFieldInfo` | Emits when the control loses focus. |
|
|
87
|
+
| `optionClicked` | `SearchableSelectOptionClickEvent` | Emits when an option is clicked. |
|
|
88
|
+
| `searchTextChange` | `string` | Emits the updated search string for consumer filtering. |
|
|
89
|
+
| `valueChange` | `any` | Emits the raw value once per committed user edit. Supports `[(value)]`. |
|
|
90
|
+
|
|
91
|
+
## Local option and event types
|
|
92
|
+
|
|
93
|
+
These declarations describe the payload and option shapes. Import availability depends on the package entry point.
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
export type SearchableSelectOption =
|
|
97
|
+
| string
|
|
98
|
+
| number
|
|
99
|
+
| SearchableSelectOptionItem
|
|
100
|
+
| Record<string, any>;
|
|
101
|
+
|
|
102
|
+
export interface SearchableSelectOptionItem {
|
|
103
|
+
[key: string]: any;
|
|
104
|
+
isDisabled?: boolean;
|
|
105
|
+
isHidden?: boolean;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface SearchableSelectToggleAllEvent extends SearchableSelectFieldInfo {
|
|
109
|
+
/** True if all options are selected, false if cleared */
|
|
110
|
+
selectAllValue: boolean;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface SearchableSelectFieldInfo {
|
|
114
|
+
/** Current value(s) bound to the select */
|
|
115
|
+
value: any;
|
|
116
|
+
/** @deprecated Use value. */
|
|
117
|
+
modelValue: any;
|
|
118
|
+
|
|
119
|
+
/** Field identifier used in parent component */
|
|
120
|
+
fieldName: string | number;
|
|
121
|
+
/** @deprecated Use fieldName. */
|
|
122
|
+
textFieldName: string | number;
|
|
123
|
+
|
|
124
|
+
/** Optional reference to native input element */
|
|
125
|
+
inputRef?: Element | null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface SearchableSelectSelectionChangeEvent extends SearchableSelectFieldInfo {
|
|
129
|
+
/** MatSelect change event containing selected value(s) */
|
|
130
|
+
selectionChange: MatSelectChange | null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface SearchableSelectOpenCloseEvent extends SearchableSelectFieldInfo {
|
|
134
|
+
/** Boolean indicating whether the dropdown is opened or closed */
|
|
135
|
+
isOpen: boolean;
|
|
136
|
+
/** @deprecated Use isOpen. */
|
|
137
|
+
selectionChange: boolean;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface SearchableSelectOptionClickEvent {
|
|
141
|
+
/** The clicked option */
|
|
142
|
+
activeOption: SearchableSelectOption;
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Public instance properties
|
|
147
|
+
|
|
148
|
+
These TypeScript properties include state exposed by the class. Use the Inputs and Outputs tables for Angular template bindings.
|
|
149
|
+
|
|
150
|
+
| Property | Type | Description |
|
|
151
|
+
| -------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------ |
|
|
152
|
+
| `searchText` | `string` | Search text entered by the user. |
|
|
153
|
+
| `hasSelectedValue` | `boolean` | — |
|
|
154
|
+
| `selectedValue` | `any` | Internal model bound to mat-select. |
|
|
155
|
+
| `inputModelValue` | `any` | **Deprecated.** Use selectedValue for direct component access. |
|
|
156
|
+
| `internalSelectList` | `any[]` | — |
|
|
157
|
+
| `modelValue` | `any` | Internal model getter/setter backed by the shared control value. |
|
|
158
|
+
| `filterConditionStartWith` | `boolean` | Enable/disable search in the starting/conatin mode. |
|
|
159
|
+
| `hiddenOptions` | `Signal<any[]>` | — |
|
|
160
|
+
| `trackByFn` | `(index: number, item: any) => any` | — |
|
|
161
|
+
| `compareObjects` | `(option1: any, option2: any) => boolean` | — |
|
|
162
|
+
| `onChangeCallback` | `(value: T \| null) => void` | Standard change and touch callbacks. |
|
|
163
|
+
| `onTouchedCallback` | `() => void` | — |
|
|
164
|
+
| `effectiveId` | `string` | Plain string property bound in template [id]="effectiveId" (zero function or CD overhead). |
|
|
165
|
+
|
|
166
|
+
## Public instance methods
|
|
167
|
+
|
|
168
|
+
The list includes Angular Forms plumbing and component event handlers as well as methods called directly by consumers.
|
|
169
|
+
|
|
170
|
+
| Method | Signature | Description |
|
|
171
|
+
| ----------------------- | --------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
172
|
+
| `writeValue` | `(value: any): void` | Intercept values written by Angular Forms framework (e.g., ngModel). |
|
|
173
|
+
| `getSelectedModelValue` | `(selectedValue: any): any` | — |
|
|
174
|
+
| `handleSelectionChange` | `(event: MatSelectChange): void` | Emits when the selected value changes in the dropdown. |
|
|
175
|
+
| `toggleSelectAll` | `(selectAllValue: boolean): void` | Handles select-all toggle action from search checkbox. |
|
|
176
|
+
| `handleOpenedChange` | `(isOpen: boolean): void` | — |
|
|
177
|
+
| `openedChange` | `(opened: boolean): void` | Emits when the open state of the dropdown changes. |
|
|
178
|
+
| `opened` | `(): void` | Emits when the dropdown panel is opened. |
|
|
179
|
+
| `closed` | `(): void` | Emits when the dropdown panel is closed. |
|
|
180
|
+
| `blur` | `(): void` | Emits when the select element loses focus. |
|
|
181
|
+
| `optionClick` | `(selectedOption: any): void` | Emits when a select option is clicked. |
|
|
182
|
+
| `searchTextModelChange` | `(changedSearchText: string): void` | — |
|
|
183
|
+
| `isTooltipDisabled` | `(optionRef: unknown, text: string): boolean` | — |
|
|
184
|
+
| `getTriggerText` | `(): string` | — |
|
|
185
|
+
| `optionSelectionChange` | `(event: any, option: any): void` | — |
|
|
186
|
+
| `open` | `(): void` | Opens the dropdown panel programmatically. |
|
|
187
|
+
| `clearSelect` | `(): void` | — |
|
|
188
|
+
| `configureId` | `(): void` | — |
|
|
189
|
+
| `commitValue` | `(value?: any \| null): void` | Commit a view edit after the inner control has updated its local model. |
|
|
190
|
+
| `handleFocusOut` | `(event: FocusEvent): void` | Touch the outer control only when focus leaves the whole composite control. |
|
|
191
|
+
| `registerOnChange` | `(fn: (value: any \| null) => void): void` | Registers a callback function that is called when the control's value changes in the UI. |
|
|
192
|
+
| `registerOnTouched` | `(fn: () => void): void` | Registers a callback function that is called when the control is touched. |
|
|
193
|
+
| `setDisabledState` | `(isDisabled: boolean): void` | Updates the disabled state from the form model. |
|
|
194
|
+
|
|
195
|
+
[Component source](https://github.com/Abhilash-A-S/angular-ui-controls/blob/develop/projects/ui-controls/src/lib/component/searchable-select/searchable-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,93 @@
|
|
|
1
|
+
# SegmentedControlComponent
|
|
2
|
+
|
|
3
|
+
A compact row of choices.
|
|
4
|
+
|
|
5
|
+
Selector `ui-segmented-control`.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { SegmentedControlComponent } from 'angular-ui-controls';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Add `SegmentedControlComponent` to the host component's imports. Add `FormsModule` for this example. Import `SegmentOption` from `angular-ui-controls` for the example options.
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<ui-segmented-control [options]="segmentOptions" [(ngModel)]="segment" />
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Example fields in the host component.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
segment = 'daily';
|
|
23
|
+
segmentOptions: SegmentOption[] = [
|
|
24
|
+
{ label: 'Daily', value: 'daily' },
|
|
25
|
+
{ label: 'Weekly', value: 'weekly' },
|
|
26
|
+
{ label: 'Monthly', value: 'monthly' },
|
|
27
|
+
];
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Use Angular Forms or `[(value)]` for binding. The tables include inherited bindings. The Required column refers to whether the template must supply the input.
|
|
31
|
+
|
|
32
|
+
## Inputs
|
|
33
|
+
|
|
34
|
+
| Input | Type | Required | Default | Description |
|
|
35
|
+
| ---------- | -------------- | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
36
|
+
| `options` | `TabOption[]` | No | `[]` | Options rendered by the control; use the label/value key inputs for object options. |
|
|
37
|
+
| `size` | `'md' \| 'lg'` | No | `'md'` | Segmented-control size: md or lg. |
|
|
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` | `any` | No | `null` | Canonical value binding. Programmatic writes never emit user change events. |
|
|
41
|
+
|
|
42
|
+
## Outputs
|
|
43
|
+
|
|
44
|
+
| Output | Payload | When it fires |
|
|
45
|
+
| ----------------- | ---------- | ----------------------------------------------------------------------- |
|
|
46
|
+
| `selectionChange` | `any` | Emits when the selection handler processes a selection. |
|
|
47
|
+
| `widthCalculated` | `number[]` | Emits measured segment widths in pixels, in option order. |
|
|
48
|
+
| `valueChange` | `any` | Emits the raw value once per committed user edit. Supports `[(value)]`. |
|
|
49
|
+
|
|
50
|
+
## Local option and event types
|
|
51
|
+
|
|
52
|
+
These declarations describe the payload and option shapes. Import availability depends on the package entry point.
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
export interface TabOption {
|
|
56
|
+
label: string;
|
|
57
|
+
value: any;
|
|
58
|
+
disabled?: boolean;
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Public instance properties
|
|
63
|
+
|
|
64
|
+
These TypeScript properties include state exposed by the class. Use the Inputs and Outputs tables for Angular template bindings.
|
|
65
|
+
|
|
66
|
+
| Property | Type | Description |
|
|
67
|
+
| ------------------- | ---------------------------- | ------------------------------------------------------------------------------------------ |
|
|
68
|
+
| `buttons` | `QueryList<ElementRef>` | — |
|
|
69
|
+
| `buttonWidths` | `number[]` | — |
|
|
70
|
+
| `activeIndex` | `number` | — |
|
|
71
|
+
| `activeOffset` | `number` | — |
|
|
72
|
+
| `activeWidth` | `number` | — |
|
|
73
|
+
| `onChangeCallback` | `(value: T \| null) => void` | Standard change and touch callbacks. |
|
|
74
|
+
| `onTouchedCallback` | `() => void` | — |
|
|
75
|
+
| `effectiveId` | `string` | Plain string property bound in template [id]="effectiveId" (zero function or CD overhead). |
|
|
76
|
+
|
|
77
|
+
## Public instance methods
|
|
78
|
+
|
|
79
|
+
The list includes Angular Forms plumbing and component event handlers as well as methods called directly by consumers.
|
|
80
|
+
|
|
81
|
+
| Method | Signature | Description |
|
|
82
|
+
| ------------------- | ------------------------------------------ | ---------------------------------------------------------------------------------------- |
|
|
83
|
+
| `calculateWidths` | `(): void` | — |
|
|
84
|
+
| `select` | `(value: any): void` | — |
|
|
85
|
+
| `configureId` | `(): void` | — |
|
|
86
|
+
| `commitValue` | `(value?: any \| null): void` | Commit a view edit after the inner control has updated its local model. |
|
|
87
|
+
| `handleFocusOut` | `(event: FocusEvent): void` | Touch the outer control only when focus leaves the whole composite control. |
|
|
88
|
+
| `writeValue` | `(value: any \| null): void` | Writes a new value from the form model to the view. |
|
|
89
|
+
| `registerOnChange` | `(fn: (value: any \| null) => void): void` | Registers a callback function that is called when the control's value changes in the UI. |
|
|
90
|
+
| `registerOnTouched` | `(fn: () => void): void` | Registers a callback function that is called when the control is touched. |
|
|
91
|
+
| `setDisabledState` | `(isDisabled: boolean): void` | Updates the disabled state from the form model. |
|
|
92
|
+
|
|
93
|
+
[Component source](https://github.com/Abhilash-A-S/angular-ui-controls/blob/develop/projects/ui-controls/src/lib/component/segmented-control/segmented-control.component.ts) · [Playground example](https://github.com/Abhilash-A-S/angular-ui-controls/blob/develop/projects/demo/src/app.component.html)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# SelectionListComponent
|
|
2
|
+
|
|
3
|
+
A list of selectable items.
|
|
4
|
+
|
|
5
|
+
Selector `ui-selection-list`.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { SelectionListComponent } from 'angular-ui-controls';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Add `SelectionListComponent` to the host component's imports. Add `FormsModule` for this example.
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<ui-selection-list
|
|
17
|
+
inputId="features"
|
|
18
|
+
label="Features"
|
|
19
|
+
[(ngModel)]="selectedFeatures"
|
|
20
|
+
[options]="featureOptions"
|
|
21
|
+
labelKey="name"
|
|
22
|
+
valueKey="id"
|
|
23
|
+
[multiple]="true"
|
|
24
|
+
/>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Example fields in the host component.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
selectedFeatures: string[] = ['dark-mode'];
|
|
31
|
+
featureOptions = [
|
|
32
|
+
{ id: 'dark-mode', name: 'Dark mode' },
|
|
33
|
+
{ id: 'email-digest', name: 'Email digest' },
|
|
34
|
+
{ id: 'audit-log', name: 'Audit log' },
|
|
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
|
+
| `tooltip` | `string` | No | `''` | Tooltip text displayed on hover. |
|
|
46
|
+
| `label` | `string` | No | `''` | Label text or translation key displayed for this control. |
|
|
47
|
+
| `errorMessage` | `string` | No | `''` | Error message displayed for validation. |
|
|
48
|
+
| `required` | `boolean` | No | `false` | Marks the control as required. Configure any parent-form validators separately. |
|
|
49
|
+
| `multiple` | `boolean` | No | `true` | Enables the existing multiple-selection mode. |
|
|
50
|
+
| `options` | `any[]` | No | `[]` | Options rendered by the control; use the label/value key inputs for object options. |
|
|
51
|
+
| `labelKey` | `string` | No | `''` | Property name read from an option object to obtain its visible label. |
|
|
52
|
+
| `valueKey` | `string` | No | `''` | Property name used to identify or extract an option value. |
|
|
53
|
+
| `fieldName` | `string \| number` | No | `undefined` | Consumer-defined field identifier included in event metadata. |
|
|
54
|
+
| `disabled` | `boolean` | No | `false` | Disables the control. Angular Forms can also update this state through setDisabledState. Uses Angular boolean attribute coercion. |
|
|
55
|
+
| `idPrefix` | `string` | No | `''` | Optional namespace prepended to inner control IDs to distinguish repeated instances. |
|
|
56
|
+
| `value` | `any` | No | `null` | Canonical value binding. Programmatic writes never emit user change events. |
|
|
57
|
+
|
|
58
|
+
## Outputs
|
|
59
|
+
|
|
60
|
+
| Output | Payload | When it fires |
|
|
61
|
+
| ----------------- | ----------------------------------- | ----------------------------------------------------------------------- |
|
|
62
|
+
| `selectionChange` | `SelectionListSelectionChangeEvent` | Emits when the selection handler processes a selection. |
|
|
63
|
+
| `modelChange` | `SelectionListModelChangeEvent` | Emits a model-change event with field metadata. |
|
|
64
|
+
| `valueChange` | `any` | Emits the raw value once per committed user edit. Supports `[(value)]`. |
|
|
65
|
+
|
|
66
|
+
## Local option and event types
|
|
67
|
+
|
|
68
|
+
These declarations describe the payload and option shapes. Import availability depends on the package entry point.
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
export interface SelectionListSelectionChangeEvent extends SelectionListFieldInfo {
|
|
72
|
+
selectionChangeEvent: MatSelectionListChange;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface SelectionListFieldInfo {
|
|
76
|
+
/** Native input element reference (if inputId is provided) */
|
|
77
|
+
inputRef?: Element | null;
|
|
78
|
+
|
|
79
|
+
/** Current selected value(s) bound to the model */
|
|
80
|
+
modelValue: any;
|
|
81
|
+
|
|
82
|
+
/** Field name identifier provided by parent */
|
|
83
|
+
textFieldName: string | number;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface SelectionListModelChangeEvent extends SelectionListFieldInfo {
|
|
87
|
+
modelChangeEvent: any;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Public instance properties
|
|
92
|
+
|
|
93
|
+
These TypeScript properties include state exposed by the class. Use the Inputs and Outputs tables for Angular template bindings.
|
|
94
|
+
|
|
95
|
+
| Property | Type | Description |
|
|
96
|
+
| ------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------ |
|
|
97
|
+
| `modelValue` | `any` | Internal model getter/setter backed by the shared control value. |
|
|
98
|
+
| `inputModelValue` | `any` | **Deprecated.** Use value for direct component access. |
|
|
99
|
+
| `trackByFn` | `(index: number, item: any) => any` | Track by function for performance optimization. |
|
|
100
|
+
| `onChangeCallback` | `(value: T \| null) => void` | Standard change and touch callbacks. |
|
|
101
|
+
| `onTouchedCallback` | `() => void` | — |
|
|
102
|
+
| `effectiveId` | `string` | Plain string property bound in template [id]="effectiveId" (zero function or CD overhead). |
|
|
103
|
+
|
|
104
|
+
## Public instance methods
|
|
105
|
+
|
|
106
|
+
The list includes Angular Forms plumbing and component event handlers as well as methods called directly by consumers.
|
|
107
|
+
|
|
108
|
+
| Method | Signature | Description |
|
|
109
|
+
| ------------------- | --------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
110
|
+
| `modelValueChange` | `(val: any): void` | Emits updated model value when ngModel changes. |
|
|
111
|
+
| `selectionChanged` | `(changeValue: MatSelectionListChange): void` | Handles selection change event. |
|
|
112
|
+
| `configureId` | `(): void` | — |
|
|
113
|
+
| `commitValue` | `(value?: any \| null): void` | Commit a view edit after the inner control has updated its local model. |
|
|
114
|
+
| `handleFocusOut` | `(event: FocusEvent): void` | Touch the outer control only when focus leaves the whole composite control. |
|
|
115
|
+
| `writeValue` | `(value: any \| null): void` | Writes a new value from the form model to the view. |
|
|
116
|
+
| `registerOnChange` | `(fn: (value: any \| null) => void): void` | Registers a callback function that is called when the control's value changes in the UI. |
|
|
117
|
+
| `registerOnTouched` | `(fn: () => void): void` | Registers a callback function that is called when the control is touched. |
|
|
118
|
+
| `setDisabledState` | `(isDisabled: boolean): void` | Updates the disabled state from the form model. |
|
|
119
|
+
|
|
120
|
+
[Component source](https://github.com/Abhilash-A-S/angular-ui-controls/blob/develop/projects/ui-controls/src/lib/component/selection-list/selection-list.component.ts) · [Playground example](https://github.com/Abhilash-A-S/angular-ui-controls/blob/develop/projects/demo/src/app.component.html)
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# SlideToggleComponent
|
|
2
|
+
|
|
3
|
+
On/off setting.
|
|
4
|
+
|
|
5
|
+
Selector `ui-slide-toggle`.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { SlideToggleComponent } from 'angular-ui-controls';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Add `SlideToggleComponent` to the host component's imports. Add `FormsModule` for this example.
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<ui-slide-toggle
|
|
17
|
+
inputId="notifications"
|
|
18
|
+
label="Enable notifications"
|
|
19
|
+
[(ngModel)]="notificationsEnabled"
|
|
20
|
+
/>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Example fields in the host component.
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
notificationsEnabled = true;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Use Angular Forms or `[(value)]` for binding. The tables include inherited bindings. The Required column refers to whether the template must supply the input.
|
|
30
|
+
|
|
31
|
+
## Inputs
|
|
32
|
+
|
|
33
|
+
| Input | Type | Required | Default | Description |
|
|
34
|
+
| ---------------------- | --------------------------------- | -------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
35
|
+
| `inputId` | `string` | Yes | — | Identifier assigned to the inner control. Set `idPrefix` to add a prefix. |
|
|
36
|
+
| `required` | `boolean` | No | `false` | Marks the control as required. Configure any parent-form validators separately. |
|
|
37
|
+
| `disableRipple` | `boolean` | No | `false` | Disable ripple animation effect. |
|
|
38
|
+
| `color` | `'primary' \| 'accent' \| 'warn'` | No | `'primary'` | Theme color: 'primary' \| 'accent' \| 'warn'. |
|
|
39
|
+
| `labelPosition` | `'before' \| 'after'` | No | `'after'` | Label position: 'before' \| 'after'. |
|
|
40
|
+
| `label` | `string` | No | `''` | Label text or translation key displayed for this control. |
|
|
41
|
+
| `errorMessage` | `string` | No | `''` | Optional error message when required validation fails. |
|
|
42
|
+
| `fieldName` | `string \| number` | No | `undefined` | Consumer-defined field identifier included in event metadata. |
|
|
43
|
+
| `preventToggleOnClick` | `boolean` | No | `false` | Whether to prevent the slide toggle from changing its value on click. |
|
|
44
|
+
| `disabled` | `boolean` | No | `false` | Disables the control. Angular Forms can also update this state through setDisabledState. Uses Angular boolean attribute coercion. |
|
|
45
|
+
| `idPrefix` | `string` | No | `''` | Optional namespace prepended to inner control IDs to distinguish repeated instances. |
|
|
46
|
+
| `value` | `boolean \| null` | No | `null` | Canonical value binding. Programmatic writes never emit user change events. |
|
|
47
|
+
|
|
48
|
+
## Outputs
|
|
49
|
+
|
|
50
|
+
| Output | Payload | When it fires |
|
|
51
|
+
| -------------- | ---------------------- | ----------------------------------------------------------------------- |
|
|
52
|
+
| `stateChange` | `SlideToggleFieldInfo` | Emits when a permitted toggle state change is processed. |
|
|
53
|
+
| `toggleChange` | `SlideToggleFieldInfo` | Emits when a permitted toggle action is processed. |
|
|
54
|
+
| `clicked` | `SlideToggleFieldInfo` | Emits when the existing click handler runs. |
|
|
55
|
+
| `valueChange` | `boolean \| null` | Emits the raw value once per committed user edit. Supports `[(value)]`. |
|
|
56
|
+
|
|
57
|
+
## Local option and event types
|
|
58
|
+
|
|
59
|
+
These declarations describe the payload and option shapes. Import availability depends on the package entry point.
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
export interface SlideToggleFieldInfo {
|
|
63
|
+
/** Currently selected slider value */
|
|
64
|
+
modelValue: boolean;
|
|
65
|
+
|
|
66
|
+
/** Field identifier used by parent component */
|
|
67
|
+
textFieldName: string | number;
|
|
68
|
+
|
|
69
|
+
/** Optional native input element reference */
|
|
70
|
+
inputRef?: Element | null;
|
|
71
|
+
changeEvent?: MouseEvent;
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Public instance properties
|
|
76
|
+
|
|
77
|
+
These TypeScript properties include state exposed by the class. Use the Inputs and Outputs tables for Angular template bindings.
|
|
78
|
+
|
|
79
|
+
| Property | Type | Description |
|
|
80
|
+
| ------------------- | ---------------------------- | ------------------------------------------------------------------------------------------ |
|
|
81
|
+
| `isChecked` | `boolean` | Internal two-way bound value for the toggle (true/false). |
|
|
82
|
+
| `inputModelValue` | `boolean` | **Deprecated.** Use isChecked for direct component access. |
|
|
83
|
+
| `onChangeCallback` | `(value: T \| null) => void` | Standard change and touch callbacks. |
|
|
84
|
+
| `onTouchedCallback` | `() => void` | — |
|
|
85
|
+
| `effectiveId` | `string` | Plain string property bound in template [id]="effectiveId" (zero function or CD overhead). |
|
|
86
|
+
|
|
87
|
+
## Public instance methods
|
|
88
|
+
|
|
89
|
+
The list includes Angular Forms plumbing and component event handlers as well as methods called directly by consumers.
|
|
90
|
+
|
|
91
|
+
| Method | Signature | Description |
|
|
92
|
+
| --------------------- | ---------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
93
|
+
| `onToggleValueChange` | `(event: MatSlideToggleChange): void` | Handles the Material change event. |
|
|
94
|
+
| `onToggleChange` | `(): void` | Called when the toggle is toggled. |
|
|
95
|
+
| `handleOnClick` | `(changeValue: MouseEvent): void` | Called when the toggle is clicked. |
|
|
96
|
+
| `handleOverlayClick` | `(event: MouseEvent): void` | Handles click on the overlay blocker when toggle clicks are prevented. |
|
|
97
|
+
| `configureId` | `(): void` | — |
|
|
98
|
+
| `commitValue` | `(value?: boolean \| null): void` | Commit a view edit after the inner control has updated its local model. |
|
|
99
|
+
| `handleFocusOut` | `(event: FocusEvent): void` | Touch the outer control only when focus leaves the whole composite control. |
|
|
100
|
+
| `writeValue` | `(value: boolean \| null): void` | Writes a new value from the form model to the view. |
|
|
101
|
+
| `registerOnChange` | `(fn: (value: boolean \| null) => void): void` | Registers a callback function that is called when the control's value changes in the UI. |
|
|
102
|
+
| `registerOnTouched` | `(fn: () => void): void` | Registers a callback function that is called when the control is touched. |
|
|
103
|
+
| `setDisabledState` | `(isDisabled: boolean): void` | Updates the disabled state from the form model. |
|
|
104
|
+
|
|
105
|
+
[Component source](https://github.com/Abhilash-A-S/angular-ui-controls/blob/develop/projects/ui-controls/src/lib/component/slide-toggle/slide-toggle.component.ts) · [Playground example](https://github.com/Abhilash-A-S/angular-ui-controls/blob/develop/projects/demo/src/app.component.html)
|