quang 19.0.19 → 19.0.21

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 CHANGED
@@ -1,25 +1,105 @@
1
1
  # Quang
2
2
 
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.3.0.
3
+ Quang is a comprehensive Angular component and utility library designed to streamline common operations in Angular applications.
4
4
 
5
- ## Code scaffolding
5
+ ## Project Structure
6
6
 
7
- Run `ng generate component component-name --project quang` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project quang`.
7
+ The library is organized into several functional modules, each focusing on different aspects of application development:
8
8
 
9
- > Note: Don't forget to add `--project quang` or else it will be added to the default project in your `angular.json` file.
9
+ ### [Auth](/projects/quang/auth/README.md)
10
+ Authentication and authorization utilities including:
11
+ - Authentication services and providers
12
+ - Role-based access control directives
13
+ - Authentication guards
14
+ - Token storage management
15
+ - Mobile-specific authentication features
10
16
 
11
- ## Build
17
+ ### [Components](/projects/quang/components/README.md)
18
+ Reusable UI components including:
19
+ - Autocomplete
20
+ - Checkbox
21
+ - Date inputs
22
+ - Form inputs
23
+ - Paginator
24
+ - Select dropdowns
25
+ - Tables
26
+ - WYSIWYG editor
12
27
 
13
- Run `ng build quang` to build the project. The build artifacts will be stored in the `dist/` directory.
28
+ ### [Data Handling](/projects/quang/data-handling)
29
+ Utilities for:
30
+ - Data conversion operations
31
+ - File download helpers
14
32
 
15
- ## Publishing
33
+ ### [Device](/projects/quang/device)
34
+ Device and viewport management utilities including:
35
+ - Resize observable service for responsive design
16
36
 
17
- After building your library with `ng build quang`, go to the dist folder `cd dist/quang` and run `npm publish`.
37
+ ### [Forms](/projects/quang/forms/README.md)
38
+ Form management utilities including:
39
+ - Form group model abstractions
40
+ - Custom form validators
18
41
 
19
- ## Running unit tests
42
+ ### [Loader](/projects/quang/loader/README.md)
43
+ Loading state management including:
44
+ - Loading indicator components
45
+ - Loading state interceptor
46
+ - Loading service
20
47
 
21
- Run `ng test quang` to execute the unit tests via [Karma](https://karma-runner.github.io).
48
+ ### [Network](/projects/quang/network)
49
+ Network request utilities and services.
50
+ - Interceptor utilities
22
51
 
23
- ## Further help
52
+ ### [Overlay](/projects/quang/overlay/README.md)
53
+ Overlay-based UI components including:
54
+ - Modals
55
+ - Popovers
56
+ - Toasts
57
+ - Tooltips
24
58
 
25
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
59
+ ### [Translation](/projects/quang/translation/README.md)
60
+ Internationalization (i18n) utilities including:
61
+ - Translation loader service
62
+ - Translation providers
63
+ - Translation tokens
64
+
65
+ ## Getting Started
66
+
67
+ To use Quang in your project, install it via npm:
68
+
69
+ ```bash
70
+ npm install quang
71
+ ```
72
+
73
+ ## Usage
74
+
75
+ Quang uses standalone components, which means you can import only the specific components you need directly into your application:
76
+
77
+ ```typescript
78
+ // Import services
79
+ import { AuthService } from 'quang/auth';
80
+ import { LoaderService } from 'quang/loader';
81
+
82
+ // Import components
83
+ import { SelectComponent } from 'quang/components/select';
84
+ import { PaginatorComponent } from 'quang/components/paginator';
85
+ import { LoaderComponent } from 'quang/loader';
86
+
87
+ // Import directives
88
+ import { IsAuthenticatedDirective } from 'quang/auth';
89
+ ```
90
+
91
+ You can then use these components directly in your standalone components:
92
+
93
+ ```typescript
94
+ @Component({
95
+ standalone: true,
96
+ imports: [SelectComponent, PaginatorComponent, LoaderComponent, IsAuthenticatedDirective],
97
+ // ...
98
+ })
99
+ export class YourComponent {
100
+ // ...
101
+ }
102
+ ```
103
+
104
+ For more detailed information about each component and feature, please refer to the corresponding README linked in the project structure section.
105
+ `
package/auth/README.md CHANGED
@@ -44,7 +44,7 @@ template.
44
44
 
45
45
  ### QuangHasEveryRoleDirective
46
46
 
47
- This directive shows content only if user is not authenticated.
47
+ This directive shows content only if the user has every specified role.
48
48
 
49
49
  To use it import [QuangHasEveryRoleDirective](./directives/has-every-role.directive.ts) and put it in your template.
50
50
 
@@ -58,7 +58,7 @@ To use it import [QuangHasEveryRoleDirective](./directives/has-every-role.direct
58
58
 
59
59
  ### QuangHasAtLeastOneRoleDirective
60
60
 
61
- This directive shows content only if user is not authenticated.
61
+ This directive shows content only if the user has at least one of the specified roles.
62
62
 
63
63
  To use it import [QuangHasAtLeastOneRoleDirective](./directives/has-at-least-one-role.directive.ts) and put it in your
64
64
  template.
@@ -0,0 +1,55 @@
1
+ # QuangAutocompleteComponent
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
+
14
+ ## Inputs
15
+
16
+ - `selectOptions`: `SelectOption[]` — Array of options to display as suggestions. **(Required)**
17
+ - `syncFormWithText`: `boolean` — If true, the form value is kept in sync with the input text. Default: `false`.
18
+ - `optionListMaxHeight`: `string` — Max height for the dropdown list. Default: `'200px'`.
19
+ - `translateValue`: `boolean` — Whether to translate option values. Default: `true`.
20
+ - `scrollBehaviorOnOpen`: `ScrollBehavior` — Scroll behavior when opening the dropdown. Default: `'smooth'`.
21
+ - `emitOnly`: `boolean` — If true, only emits the value without saving it in ngControl. Default: `false`.
22
+ - `searchTextDebounce`: `number` — Debounce time in milliseconds for search input. Default: `300`.
23
+ - `internalFilterOptions`: `boolean` — If true, filters options internally. Default: `true`.
24
+ - All standard form/label/validation-related inputs inherited from `QuangBaseComponent`:
25
+ - `isReadonly`, `componentLabel`, `componentPlaceholder`, `componentTabIndex`, `componentClass`, `errorMap`, `successMessage`, `helpMessage`, `formControl`
26
+
27
+ ## Outputs
28
+
29
+ - `selectedOption`: Emits the selected value when a suggestion is selected.
30
+ - `searchTextChange`: Emits the current search text as the user types.
31
+ - All standard outputs inherited from `QuangBaseComponent`:
32
+ - `componentBlur`
33
+
34
+ ## Usage
35
+
36
+ ```html
37
+ <quang-autocomplete
38
+ [errorMap]="errors()"
39
+ [isReadonly]="isReadonly()"
40
+ [searchTextDebounce]="500"
41
+ [selectOptions]="stringListFiltered()"
42
+ (searchTextChange)="changeTextTest($event)"
43
+ (selectedOption)="onSelectOption($event)"
44
+ class="col-6"
45
+ componentLabel="form.label.autocompleteAsync"
46
+ formControlName="testInput1"
47
+ successMessage="form.label.success"
48
+ />
49
+ ```
50
+
51
+ ## Notes
52
+
53
+ 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.
54
+
55
+ For more advanced usage and customization, refer to the full documentation and examples in the Quang library.
@@ -0,0 +1,63 @@
1
+ # QuangCheckboxComponent
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)
11
+
12
+ ## Inputs
13
+
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`
19
+
20
+ ## Outputs
21
+
22
+ - `changedHandler`: Emits the updated value when the checkbox state changes.
23
+ - All standard outputs inherited from `QuangBaseComponent`:
24
+ - `componentBlur`
25
+
26
+ ## Usage
27
+
28
+ ```html
29
+ <quang-checkbox
30
+ [errorMap]="errors()"
31
+ [isReadonly]="isReadonly()"
32
+ checkType="checkbox"
33
+ class="col-3"
34
+ componentLabel="form.label.toggle"
35
+ formControlName="toggle"
36
+ labelPosition="top"
37
+ successMessage="form.label.success"
38
+ />
39
+ <quang-checkbox
40
+ [errorMap]="errors()"
41
+ [isReadonly]="isReadonly()"
42
+ checkType="toggle"
43
+ class="col-6"
44
+ componentLabel="form.label.checkbox"
45
+ formControlName="checkbox"
46
+ labelPosition="left"
47
+ successMessage="form.label.success"
48
+ />
49
+ ```
50
+
51
+ ## Styling
52
+
53
+ The component supports the following CSS classes for customization:
54
+
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.
60
+
61
+ ## Notes
62
+
63
+ This component extends the `QuangBaseComponent` and inherits its features, such as label, error messages, and success messages.
@@ -0,0 +1,54 @@
1
+ # QuangDateComponent
2
+
3
+ The `QuangDateComponent` is based on Air Datepicker. It can be fully customized using the input property `datepickerOptions`.
4
+
5
+ ## Features
6
+ - Fully customizable datepicker
7
+ - Based on Air Datepicker
8
+ - Supports date ranges and localization
9
+
10
+ ## Inputs
11
+
12
+ - `datepickerOptions`: `object` — Configuration options for the datepicker. **(Required)**
13
+ - `minDate`: `Date | string` — Minimum selectable date.
14
+ - `maxDate`: `Date | string` — Maximum selectable date.
15
+ - All standard form/label/validation-related inputs inherited from `QuangBaseComponent`:
16
+ - `isReadonly`, `componentLabel`, `componentPlaceholder`, `componentTabIndex`, `componentClass`, `errorMap`, `successMessage`, `helpMessage`, `formControl`
17
+
18
+ ## Outputs
19
+
20
+ - `dateChange`: Emits the selected date when it changes.
21
+ - All standard outputs inherited from `QuangBaseComponent`:
22
+ - `componentBlur`
23
+
24
+ ## Usage
25
+ ```html
26
+ <quang-date
27
+ [minDate]="minDate"
28
+ [maxDate]="maxDate"
29
+ [errorMap]="errors()"
30
+ [formControl]="testForm.controls.testInput"
31
+ [isReadonly]="isReadonly()"
32
+ [timepicker]="true"
33
+ class="col-6"
34
+ componentLabel="form.label.date"
35
+ successMessage="form.label.success"
36
+ >
37
+ <img src="./assets/icons/svg/calendar.svg" />
38
+ </quang-date>
39
+ ```
40
+
41
+ ### Note
42
+ Remember to add the import:
43
+
44
+ `node_modules/quang/components/date/global-date.component.scss`
45
+
46
+ or
47
+
48
+ `quang/components/date/global-date.component.scss`
49
+
50
+ in your global style (suggested "vendors" folder).
51
+
52
+ ## Notes
53
+
54
+ This component extends the `QuangBaseComponent` and inherits its features, such as label, error messages, and success messages.
@@ -0,0 +1,58 @@
1
+ # QuangInputComponent
2
+
3
+ The `QuangInputComponent` must be configured using the `componentType` input property.
4
+
5
+ ## Supported Types
6
+
7
+ - text
8
+ - textarea
9
+ - password
10
+ - email
11
+ - number
12
+ - url
13
+ - search
14
+ - tel
15
+ - color
16
+
17
+ ## Inputs
18
+
19
+ - `componentType`: `'text' | 'textarea' | 'password' | 'email' | 'number' | 'url' | 'search' | 'tel' | 'color'` — Specifies the type of input. **(Required)**
20
+ - `maxLengthText`: `number | null` — Maximum length for text input.
21
+ - `minLengthText`: `number | null` — Minimum length for text input.
22
+ - `minNumber`: `number | undefined` — Minimum value for number input.
23
+ - `maxNumber`: `number | undefined` — Maximum value for number input.
24
+ - `componentStep`: `number` — Step for number input. Default: `1`.
25
+ - `resizable`: `boolean` — If false, disables textarea resizing. Default: `true` (only for textarea).
26
+ - All standard form/label/validation-related inputs inherited from `QuangBaseComponent`:
27
+ - `isReadonly`, `componentLabel`, `componentPlaceholder`, `componentTabIndex`, `componentClass`, `errorMap`, `successMessage`, `helpMessage`, `formControl`
28
+
29
+ ## Outputs
30
+
31
+ - All standard outputs inherited from `QuangBaseComponent`:
32
+ - `componentBlur`
33
+
34
+ ## Usage
35
+
36
+ ```html
37
+ <quang-input
38
+ [errorMap]="errors()"
39
+ componentLabel="form.label.input"
40
+ componentType="text"
41
+ formControlName="testInput"
42
+ />
43
+
44
+ <quang-input
45
+ [errorMap]="errors()"
46
+ [isReadonly]="isReadonly()"
47
+ [maxNumber]="10"
48
+ [minNumber]="0"
49
+ componentLabel="form.label.input"
50
+ componentType="number"
51
+ formControlName="testInput"
52
+ successMessage="form.label.success"
53
+ />
54
+ ```
55
+
56
+ ## Notes
57
+
58
+ This component extends the `QuangBaseComponent` and inherits its features, such as label and validation messages.
@@ -0,0 +1,43 @@
1
+ # QuangPaginatorComponent
2
+
3
+ The `QuangPaginatorComponent` provides controls for navigating through pages of data, supporting configurations for total items, items per page, and current page.
4
+
5
+ ## Features
6
+
7
+ - Pagination controls
8
+ - Configurable total items, items per page, and current page
9
+ - Emits events for page changes
10
+
11
+ ## Inputs
12
+
13
+ - `page`: `number` — Current page number. **(Required)**
14
+ - `pageSize`: `number` — Number of items per page. **(Required)**
15
+ - `sizeList`: `number[]` — List of selectable page sizes. Default: `[]`.
16
+ - `totalItems`: `number` — Total number of items to paginate. **(Required)**
17
+ - `showTotalElementsCount`: `boolean` — Show/hide total items count. Default: `true`.
18
+ - `totalItemsText`: `string` — Translation key for total items label. Default: `'quangPaginator.totalItems'`.
19
+ - `sizeText`: `string` — Translation key for size label. Default: `'quangPaginator.size'`.
20
+ - `pageRangeText`: `string` — Translation key for page range label. Default: `'quangPaginator.pageRange'`.
21
+ - `componentId`, `componentTabIndex`, `componentClass`: Standard component inputs.
22
+
23
+ ## Outputs
24
+
25
+ - `changePage`: Emits the new page number when the user navigates to a different page.
26
+ - `changeSize`: Emits the new page size when the user changes it.
27
+
28
+ ## Usage
29
+
30
+ ```html
31
+ <quang-paginator
32
+ [page]="1"
33
+ [pageSize]="10"
34
+ [sizeList]="[5, 10, 20]"
35
+ [totalItems]="30"
36
+ (changePage)="onChangePage($event)"
37
+ (changeSize)="onChangePageSize($event)"
38
+ />
39
+ ```
40
+
41
+ ## Notes
42
+
43
+ This component provides a user-friendly interface for pagination in lists and tables.
@@ -0,0 +1,54 @@
1
+ # QuangSelectComponent
2
+
3
+ The `QuangSelectComponent` supports single or multiple selections from a dropdown list.
4
+
5
+ ## Features
6
+
7
+ - Single selection
8
+ - Multiple selection
9
+ - Customizable options
10
+
11
+ ## Inputs
12
+
13
+ - `selectOptions`: `SelectOption[]` — Array of options to display in the dropdown. **(Required)**
14
+ - `selectionMode`: `'single' | 'multiple'` — Enables single or multiple selection mode. Default: `'single'`.
15
+ - All standard form/label/validation-related inputs inherited from `QuangBaseComponent`:
16
+ - `isReadonly`, `componentLabel`, `componentPlaceholder`, `componentTabIndex`, `componentClass`, `errorMap`, `successMessage`, `helpMessage`, `formControl`
17
+
18
+ ## Outputs
19
+
20
+ - All standard outputs inherited from `QuangBaseComponent`:
21
+ - `componentBlur`
22
+
23
+ ## Usage
24
+
25
+ ```html
26
+ <quang-select
27
+ [errorMap]="errors()"
28
+ [isReadonly]="isReadonly()"
29
+ [selectOptions]="stringList"
30
+ class="col-4"
31
+ componentLabel="form.label.select"
32
+ componentPlaceholder="Placeholder select singola scelta"
33
+ formControlName="testInput"
34
+ playgroundSourceCode
35
+ selectionMode="single"
36
+ successMessage="form.label.success"
37
+ />
38
+
39
+ <quang-select
40
+ [errorMap]="errors()"
41
+ [isReadonly]="isReadonly()"
42
+ [selectOptions]="numberList"
43
+ class="col-4"
44
+ componentLabel="form.label.multipleSelect"
45
+ componentPlaceholder="Placeholder select scelta multipla"
46
+ formControlName="testInputMultiple"
47
+ selectionMode="multiple"
48
+ successMessage="form.label.success"
49
+ />
50
+ ```
51
+
52
+ ## Notes
53
+
54
+ This component extends the `QuangBaseComponent` and inherits its features, such as label and validation messages.
@@ -0,0 +1,63 @@
1
+ # QuangTableComponent
2
+
3
+ The `QuangTableComponent` allows for displaying data in a tabular format.
4
+
5
+ ## Features
6
+
7
+ - Tabular data display
8
+ - Customizable headers and rows
9
+ - Supports sorting and filtering
10
+
11
+ ## Inputs
12
+
13
+ - `tableConfigurations`: `{ headers: TableHeader[]; rows: any[] }` — Table configuration object containing headers and rows. **(Required)**
14
+ - `stickyTable`: `boolean` — Enables sticky header/columns. Default: `false`.
15
+ - All standard form/label/validation-related inputs inherited from `QuangBaseComponent` (if applicable):
16
+ - `isReadonly`, `componentLabel`, `componentPlaceholder`, `componentTabIndex`, `componentClass`, `errorMap`, `successMessage`, `helpMessage`, `formControl`
17
+
18
+ ## Outputs
19
+
20
+ - `sortChanged`: Emits the sort state when the user changes sorting.
21
+ - `rowClick`: Emits the clicked row data when a row is clicked.
22
+
23
+ ## Usage
24
+
25
+ ### HTML
26
+
27
+ ```html
28
+ <quang-table
29
+ [stickyTable]="true"
30
+ [tableConfigurations]="tableConfig()"
31
+ (sortChanged)="onChangeSort($event)"
32
+ (rowClick)="onRowClick($event)"
33
+ />
34
+ ```
35
+
36
+ ### TypeScript
37
+
38
+ ```typescript
39
+ import { computed, signal } from '@angular/core'
40
+
41
+ // Angular signals for table data and headers
42
+
43
+ tableRows = signal([
44
+ { id: 1, name: 'John Doe', age: 30 },
45
+ { id: 2, name: 'Jane Smith', age: 25 },
46
+ { id: 3, name: 'Alice Johnson', age: 35 },
47
+ ])
48
+
49
+ tableHeaders = [
50
+ { key: 'id', label: 'ID', sortable: true },
51
+ { key: 'name', label: 'Name', sortable: true },
52
+ { key: 'age', label: 'Age', sortable: false },
53
+ ]
54
+
55
+ tableConfig = computed(() => ({
56
+ headers: tableHeaders,
57
+ rows: tableRows(),
58
+ }))
59
+ ```
60
+
61
+ ## Notes
62
+
63
+ This component is highly customizable and can be styled to match your application's design.
@@ -0,0 +1,55 @@
1
+ # QuangWysiwygComponent
2
+
3
+ The `QuangWysiwygComponent` is a rich text editor based on [SunEditor](https://github.com/JiHong88/SunEditor), offering a wide range of formatting options for creating and editing HTML content.
4
+
5
+ ## Features
6
+
7
+ - Rich text editing
8
+ - Wide range of formatting options
9
+ - Supports custom toolbars and plugins
10
+
11
+ ## Inputs
12
+
13
+ - `wysiwygOptions`: `object` — Configuration options for the editor. **(Required)**
14
+ - `minHeight`: `string | undefined` — Minimum height for the editor area. Default: `'200px'`.
15
+ - `highlightColor`: `boolean` — Show/hide the highlight color button in the toolbar. Default: `true`.
16
+ - `isReadonly`: `boolean` — If true, the editor is readonly.
17
+ - `onImageUploadError`: `(errorMessage: any, result: any, core: any) => boolean` — Callback for image upload errors.
18
+ - `onFileDrop`: `(e: any, cleanData: any, maxCharCount: any, core: any) => boolean` — Callback for file drop events.
19
+ - Toolbar button toggles (all `boolean`, default: `true`):
20
+ - `font`, `fontSize`, `formatBlock`, `paragraphStyle`, `blockquote`, `bold`, `underline`, `italic`, `strike`, `fontColor`, `textStyle`, `removeFormat`, `align`, `list`, `table`, `link`, `image`, `fullScreen`, `showBlocks`
21
+ - All standard form/label/validation-related inputs inherited from `QuangBaseComponent`:
22
+ - `componentLabel`, `componentPlaceholder`, `componentTabIndex`, `componentClass`, `errorMap`, `successMessage`, `helpMessage`, `formControl`
23
+
24
+ ## Outputs
25
+
26
+ - All standard outputs inherited from `QuangBaseComponent`:
27
+ - `componentBlur`
28
+
29
+ ## Usage
30
+
31
+ ```html
32
+ <quang-wysiwyg
33
+ [errorMap]="errors()"
34
+ [highlightColor]="highlightColor()"
35
+ [isReadonly]="isReadonly()"
36
+ [minHeight]="wysiwygHeight()"
37
+ [onImageUploadError]="onImageUploadError"
38
+ [wysiwygOptions]="wysiwygOptions"
39
+ componentLabel="form.label.wysiwyg"
40
+ formControlName="testInput"
41
+ successMessage="form.label.success"
42
+ />
43
+ ```
44
+
45
+ ### Note
46
+
47
+ Remember to import:
48
+
49
+ `node_modules/quang/components/wysiwyg/global-wysiswyg.component.scss`
50
+
51
+ or
52
+
53
+ `quang/components/wysiwyg/global-wysiswyg.component.scss`
54
+
55
+ in your global style (suggested "vendors" folder).