quang 20.1.8 → 20.2.1

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.
@@ -1,73 +1,90 @@
1
1
  # QuangAutocompleteComponent
2
2
 
3
- The `QuangAutocompleteComponent` provides real-time suggestions as the user types, allowing for easy selection from a list of filtered options. It is designed to be flexible and customizable for a variety of use cases in Angular forms.
4
-
5
- ## Features
6
-
7
- - Real-time suggestions as the user types
8
- - Easy selection from filtered options
9
- - Customizable suggestion list and display
10
- - Supports Angular Reactive Forms and Template-driven Forms
11
- - Configurable debounce for search input
12
- - Readonly and validation support
13
- - **Multiple selection with chips** (with horizontal/vertical display)
14
- - Keyboard navigation and chip deletion (Backspace)
15
- - Focus management for chips (Backspace focuses last chip, second Backspace deletes it)
3
+ The `QuangAutocompleteComponent` is a comprehensive autocomplete input with real-time suggestions, multiple selection capabilities, and chip management. It provides intelligent filtering, keyboard navigation, and seamless integration with Angular forms while supporting both single and multiple selection modes.
16
4
 
17
5
  ## Inputs
18
6
 
19
- - `selectOptions`: `SelectOption[]` — Array of options to display as suggestions. **(Required)**
20
- - `multiple`: `boolean` — Enable multiple selection mode (chips). Default: `false`.
21
- - `multiSelectDisplayMode`: `'vertical' | 'horizontal'` — Display chips vertically or horizontally. Default: `'vertical'`.
22
- - `chipMaxLength`: `number` — Maximum length (in characters) for a single chip label. Default: `0` (no limit).
23
- - `syncFormWithText`: `boolean` — If true, the form value is kept in sync with the input text. Default: `false`.
24
- - `optionListMaxHeight`: `string` — Max height for the dropdown list. Default: `'200px'`.
25
- - `translateValue`: `boolean` — Whether to translate option values. Default: `true`.
26
- - `scrollBehaviorOnOpen`: `ScrollBehavior` — Scroll behavior when opening the dropdown. Default: `'smooth'`.
27
- - `emitOnly`: `boolean` — If true, only emits the value without saving it in ngControl. Default: `false`.
28
- - `searchTextDebounce`: `number` — Debounce time in milliseconds for search input. Default: `300`.
29
- - `internalFilterOptions`: `boolean` — If true, filters options internally. Default: `true`.
30
- - All standard form/label/validation-related inputs inherited from `QuangBaseComponent`:
31
- - `isReadonly`, `componentLabel`, `componentPlaceholder`, `componentTabIndex`, `componentClass`, `errorMap`, `successMessage`, `helpMessage`, `formControl`
7
+ - `selectOptions`: `SelectOption[]` — Array of available options for selection. Each option should have `value` and `label` properties. **(Required)**
8
+ - `multiple`: `boolean` — Enable multiple selection mode with chip display. Default: `false`
9
+ - `multiSelectDisplayMode`: `'vertical' | 'horizontal'` — Layout direction for chips in multiple mode. Horizontal mode includes scroll support. Default: `'vertical'`
10
+ - `chipMaxLength`: `number` — Maximum character length for chip labels. Longer labels will be truncated with ellipsis. Default: `0` (no limit)
11
+ - `syncFormWithText`: `boolean` — Synchronize form control value with input text as user types. Useful for free-text input with suggestions. Default: `false`
12
+ - `optionListMaxHeight`: `string` — Maximum height for dropdown option list with CSS units. Default: `'200px'`
13
+ - `translateValue`: `boolean` — Enable translation of option values through QuangTranslationService. Default: `true`
14
+ - `scrollBehaviorOnOpen`: `ScrollBehavior` — Scroll behavior when opening dropdown ('smooth' or 'instant'). Default: `'smooth'`
15
+ - `emitOnly`: `boolean` — Only emit selection events without updating form control. Useful for read-only suggestion display. Default: `false`
16
+ - `searchTextDebounce`: `number` — Debounce delay in milliseconds for search input to optimize performance. Default: `300`
17
+ - `internalFilterOptions`: `boolean` — Use built-in filtering logic. Disable for custom external filtering via searchTextChange event. Default: `true`
18
+ - `isReadonly`: `boolean` — Set component to read-only mode. Inherited from `QuangBaseComponent`
19
+ - `componentLabel`: `string` Label text for the component. Inherited from `QuangBaseComponent`
20
+ - `componentPlaceholder`: `string` — Placeholder text for the input. Inherited from `QuangBaseComponent`
21
+ - `componentTabIndex`: `number` — Tab index for accessibility. Inherited from `QuangBaseComponent`
22
+ - `componentClass`: `string | string[]` — Additional CSS classes. Inherited from `QuangBaseComponent`
23
+ - `errorMap`: `{[key: string]: string}` — Custom error messages. Inherited from `QuangBaseComponent`
24
+ - `successMessage`: `string` — Success message to display. Inherited from `QuangBaseComponent`
25
+ - `helpMessage`: `string` — Help text for the component. Inherited from `QuangBaseComponent`
26
+ - `formControl`: `FormControl` — Form control for reactive forms. Inherited from `QuangBaseComponent`
32
27
 
33
28
  ## Outputs
34
29
 
35
- - `selectedOption`: Emits the selected value when a suggestion is selected.
36
- - `searchTextChange`: Emits the current search text as the user types.
37
- - All standard outputs inherited from `QuangBaseComponent`:
38
- - `componentBlur`
30
+ - `selectedOption`: `EventEmitter<string | number | null>` — Emitted when an option is selected in single mode. Provides the selected option's value
31
+ - `searchTextChange`: `EventEmitter<string>` Emitted when search text changes after debounce period. Use for external filtering or API calls
32
+ - `componentBlur`: `EventEmitter<void>` Emitted when component loses focus. Inherited from `QuangBaseComponent`
39
33
 
40
- ## Multiple/Chip Mode
34
+ ## Usage
41
35
 
42
- - When `multiple` is `true`, selected options are displayed as removable chips.
43
- - Chips can be displayed horizontally or vertically using `multiSelectDisplayMode`.
44
- - Chips have a close button for removal. When the input is empty, pressing Backspace focuses the last chip; pressing Backspace again deletes it.
45
- - Focus is managed for accessibility: after deleting a chip, focus moves to the previous chip or input.
46
- - Chip container supports horizontal scrolling with the mouse wheel in horizontal mode.
47
- - You can limit chip label length with `chipMaxLength`.
36
+ ### Basic Single Selection
48
37
 
49
- ## Usage
38
+ ```html
39
+ <quang-autocomplete
40
+ [selectOptions]="countryOptions"
41
+ formControlName="country"
42
+ >
43
+ </quang-autocomplete>
44
+ ```
45
+
46
+ ### Multiple Selection with Chips
50
47
 
51
48
  ```html
52
49
  <quang-autocomplete
50
+ [selectOptions]="skillOptions"
53
51
  [multiple]="true"
54
- [multiSelectDisplayMode]="'horizontal'"
55
- [chipMaxLength]="12"
56
- [errorMap]="errors()"
57
- [isReadonly]="isReadonly()"
58
- [searchTextDebounce]="500"
59
- [selectOptions]="stringListFiltered()"
60
- (searchTextChange)="changeTextTest($event)"
61
- (selectedOption)="onSelectOption($event)"
62
- class="col-6"
63
- componentLabel="form.label.autocompleteAsync"
64
- formControlName="testInput1"
65
- successMessage="form.label.success"
66
- />
52
+ formControlName="skills"
53
+ >
54
+ </quang-autocomplete>
55
+ ```
56
+
57
+ #### TypeScript Example
58
+
59
+ ```typescript
60
+ export class MyComponent {
61
+ countryOptions: SelectOption[] = [
62
+ { value: 'us', label: 'United States' },
63
+ { value: 'ca', label: 'Canada' },
64
+ { value: 'uk', label: 'United Kingdom' }
65
+ ]
66
+
67
+ skillOptions: SelectOption[] = [
68
+ { value: 'angular', label: 'Angular' },
69
+ { value: 'typescript', label: 'TypeScript' },
70
+ { value: 'javascript', label: 'JavaScript' }
71
+ ]
72
+
73
+ onOptionSelected(value: string | number | null): void {
74
+ console.log('Selected:', value)
75
+ }
76
+
77
+ onSearchChange(searchTerm: string): void {
78
+ // Handle external filtering
79
+ }
80
+ }
67
81
  ```
68
82
 
69
- ## Notes
83
+ ### Translation Integration
70
84
 
71
- This component extends the `QuangBaseComponent` and inherits its features, such as label and validation messages. It is recommended to use with Angular Reactive Forms for best results.
85
+ The component uses QuangTranslationService for all text content:
72
86
 
73
- For more advanced usage and customization, refer to the full documentation and examples in the Quang library.
87
+ - **Automatic Translation**: Option labels and component messages are translated automatically
88
+ - **Key Support**: Use translation keys as labels for automatic localization
89
+ - **Fallback Handling**: Provides fallback display when translations are unavailable
90
+ - **Dynamic Language Switching**: Responds to language changes without component reload
@@ -1,63 +1,73 @@
1
1
  # QuangCheckboxComponent
2
2
 
3
- The `QuangCheckboxComponent` can be used as a standard checkbox or as a toggle switch by setting the `checkType` input.
4
-
5
- ## Features
6
-
7
- - Standard checkbox functionality
8
- - Toggle switch mode
9
- - Configurable label position
10
- - Validation feedback (success and error messages)
3
+ The `QuangCheckboxComponent` is a versatile checkbox and toggle switch component that provides flexible label positioning, comprehensive validation feedback, and seamless integration with Angular forms. It supports both traditional checkbox and modern toggle switch modes with extensive customization options.
11
4
 
12
5
  ## Inputs
13
6
 
14
- - `checkType`: `'checkbox' | 'toggle'` — Specifies the type of the component. **(Required)**
15
- - `labelPosition`: `'top' | 'left' | 'right' | 'bottom'` — Position of the label. Default: `'top'`.
16
- - `removeMargin`: `boolean` — Removes the default margin. Default: `false`.
17
- - All standard form/label/validation-related inputs inherited from `QuangBaseComponent`:
18
- - `isReadonly`, `componentLabel`, `componentPlaceholder`, `componentTabIndex`, `componentClass`, `errorMap`, `successMessage`, `helpMessage`, `formControl`
7
+ - `checkType`: `'checkbox' | 'toggle'` — Specifies the input type. Checkbox renders as traditional checkmark input, toggle renders as modern switch control. **(Required)**
8
+ - `labelPosition`: `'top' | 'left' | 'right' | 'bottom'` — Position of the label relative to the input control. Affects layout direction and spacing. Default: `'top'`
9
+ - `removeMargin`: `boolean` — Removes default bottom margin and form-check class. Useful for custom layouts or tight spacing requirements. Default: `false`
10
+ - `isReadonly`: `boolean` — Set component to read-only mode. Inherited from `QuangBaseComponent`
11
+ - `componentLabel`: `string` Label text for the component. Inherited from `QuangBaseComponent`
12
+ - `componentPlaceholder`: `string` — Placeholder text for the input. Inherited from `QuangBaseComponent`
13
+ - `componentTabIndex`: `number` — Tab index for accessibility. Inherited from `QuangBaseComponent`
14
+ - `componentClass`: `string | string[]` — Additional CSS classes. Inherited from `QuangBaseComponent`
15
+ - `errorMap`: `{[key: string]: string}` — Custom error messages. Inherited from `QuangBaseComponent`
16
+ - `successMessage`: `string` — Success message to display. Inherited from `QuangBaseComponent`
17
+ - `helpMessage`: `string` — Help text for the component. Inherited from `QuangBaseComponent`
18
+ - `formControl`: `FormControl` — Form control for reactive forms. Inherited from `QuangBaseComponent`
19
19
 
20
20
  ## Outputs
21
21
 
22
- - `changedHandler`: Emits the updated value when the checkbox state changes.
23
- - All standard outputs inherited from `QuangBaseComponent`:
24
- - `componentBlur`
22
+ - `changedHandler`: `EventEmitter<boolean>` Emitted when checkbox state changes. Provides the new boolean value (true for checked, false for unchecked)
23
+ - `componentBlur`: `EventEmitter<void>` Emitted when component loses focus. Inherited from `QuangBaseComponent`
25
24
 
26
25
  ## Usage
27
26
 
27
+ ### Basic Checkbox
28
+
28
29
  ```html
29
30
  <quang-checkbox
30
- [errorMap]="errors()"
31
- [isReadonly]="isReadonly()"
32
31
  checkType="checkbox"
33
- class="col-3"
34
- componentLabel="form.label.toggle"
35
- formControlName="toggle"
36
- labelPosition="top"
37
- successMessage="form.label.success"
38
- />
32
+ componentLabel="form.label.agreeToTerms"
33
+ formControlName="agreeToTerms"
34
+ >
35
+ </quang-checkbox>
36
+ ```
37
+
38
+ ### Toggle Switch
39
+
40
+ ```html
39
41
  <quang-checkbox
40
- [errorMap]="errors()"
41
- [isReadonly]="isReadonly()"
42
42
  checkType="toggle"
43
- class="col-6"
44
- componentLabel="form.label.checkbox"
45
- formControlName="checkbox"
43
+ componentLabel="form.label.enableNotifications"
46
44
  labelPosition="left"
47
- successMessage="form.label.success"
48
- />
45
+ formControlName="notifications"
46
+ >
47
+ </quang-checkbox>
49
48
  ```
50
49
 
51
- ## Styling
50
+ #### TypeScript Example
52
51
 
53
- The component supports the following CSS classes for customization:
52
+ ```typescript
53
+ export class MyComponent {
54
+ form = this.fb.group({
55
+ agreeToTerms: [false, Validators.requiredTrue],
56
+ enableNotifications: [true]
57
+ })
58
+
59
+ onToggleChange(isChecked: boolean): void {
60
+ console.log('Checkbox state changed:', isChecked)
61
+ // Handle state change
62
+ }
63
+ }
64
+ ```
54
65
 
55
- - `.label-top`: Positions the label above the checkbox.
56
- - `.label-bottom`: Positions the label below the checkbox.
57
- - `.label-left`: Positions the label to the left of the checkbox.
58
- - `.label-right`: Positions the label to the right of the checkbox.
59
- - `.toggle-wrapper`: Styles the component as a toggle switch.
66
+ ### Translation Integration
60
67
 
61
- ## Notes
68
+ The component uses QuangTranslationService for all text content:
62
69
 
63
- This component extends the `QuangBaseComponent` and inherits its features, such as label, error messages, and success messages.
70
+ - **Automatic Translation**: All labels, help text, and error messages are automatically translated
71
+ - **Key Support**: Use translation keys for all text content
72
+ - **Fallback Handling**: Provides graceful fallback when translations are unavailable
73
+ - **Dynamic Language**: Responds to language changes without component reload