@libs-ui/components-switch 0.2.28 → 0.2.30-6.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.
- package/README.md +162 -2
- package/esm2022/interfaces/switch.interface.mjs +1 -1
- package/esm2022/switch.component.mjs +5 -5
- package/fesm2022/libs-ui-components-switch.mjs +5 -5
- package/fesm2022/libs-ui-components-switch.mjs.map +1 -1
- package/interfaces/switch.interface.d.ts +1 -0
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -1,3 +1,163 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Switch
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Giới thiệu
|
|
4
|
+
|
|
5
|
+
`@libs-ui/components-switch` là component Toggle Switch cho Angular, cho phép người dùng bật/tắt một tùy chọn với trạng thái hai chiều và sự kiện revert.
|
|
6
|
+
|
|
7
|
+
## Tính năng
|
|
8
|
+
|
|
9
|
+
- Kích thước: `'default'` | `'large'`
|
|
10
|
+
- Hỗ trợ vô hiệu hóa switch (`disable`)
|
|
11
|
+
- Two-way binding cho trạng thái `active`
|
|
12
|
+
- Phát ra sự kiện `outSwitch` với payload `{ active: boolean; revert: () => Promise<void> }`
|
|
13
|
+
|
|
14
|
+
## Cài đặt
|
|
15
|
+
|
|
16
|
+
### Yêu cầu
|
|
17
|
+
|
|
18
|
+
- Angular 18.0.0 trở lên
|
|
19
|
+
- Tailwind CSS 3.3.0 trở lên
|
|
20
|
+
|
|
21
|
+
Để cài đặt, sử dụng npm hoặc yarn:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @libs-ui/components-switch
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
hoặc
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
yarn add @libs-ui/components-switch
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Sử dụng
|
|
34
|
+
|
|
35
|
+
### Inline Template
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { Component } from '@angular/core';
|
|
39
|
+
import { LibsUiComponentsSwitchComponent } from '@libs-ui/components-switch';
|
|
40
|
+
|
|
41
|
+
@Component({
|
|
42
|
+
selector: 'app-example',
|
|
43
|
+
standalone: true,
|
|
44
|
+
imports: [LibsUiComponentsSwitchComponent],
|
|
45
|
+
template: `
|
|
46
|
+
<libs_ui-components-switch
|
|
47
|
+
[size]="'large'"
|
|
48
|
+
[disable]="false"
|
|
49
|
+
[(active)]="isOn"
|
|
50
|
+
(outSwitch)="onSwitch($event)">
|
|
51
|
+
</libs_ui-components-switch>
|
|
52
|
+
`
|
|
53
|
+
})
|
|
54
|
+
export class ExampleComponent {
|
|
55
|
+
isOn = false;
|
|
56
|
+
|
|
57
|
+
onSwitch(event: { active: boolean; revert: () => Promise<void> }) {
|
|
58
|
+
console.log('Switch toggled:', event.active);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### File HTML riêng
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { Component } from '@angular/core';
|
|
67
|
+
import { LibsUiComponentsSwitchComponent } from '@libs-ui/components-switch';
|
|
68
|
+
|
|
69
|
+
@Component({
|
|
70
|
+
selector: 'app-example',
|
|
71
|
+
standalone: true,
|
|
72
|
+
imports: [LibsUiComponentsSwitchComponent],
|
|
73
|
+
templateUrl: './example.component.html'
|
|
74
|
+
})
|
|
75
|
+
export class ExampleComponent {
|
|
76
|
+
isOn = true;
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<libs_ui-components-switch
|
|
82
|
+
[size]="'default'"
|
|
83
|
+
[disable]="false"
|
|
84
|
+
[(active)]="isOn"
|
|
85
|
+
(outSwitch)="onSwitch($event)">
|
|
86
|
+
</libs_ui-components-switch>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Công nghệ sử dụng
|
|
90
|
+
|
|
91
|
+
- **Angular 18**: standalone components, Signals
|
|
92
|
+
- **Tailwind CSS**: cho styling
|
|
93
|
+
|
|
94
|
+
## API Reference
|
|
95
|
+
|
|
96
|
+
### Inputs
|
|
97
|
+
|
|
98
|
+
| Tên | Kiểu | Mặc định | Mô tả |
|
|
99
|
+
|---------|----------------------------|-------------|--------------------------------------------------------------|
|
|
100
|
+
| size | `'default' \| 'large'` | `'default'` | Kích thước của switch |
|
|
101
|
+
| disable | `boolean` | `false` | Vô hiệu hóa switch |
|
|
102
|
+
| active | `boolean` | `false` | Trạng thái bật/tắt (two-way binding) |
|
|
103
|
+
|
|
104
|
+
### Outputs
|
|
105
|
+
|
|
106
|
+
| Tên | Kiểu | Mô tả |
|
|
107
|
+
|-----------|----------------------------------------|-----------------------------------------------------------|
|
|
108
|
+
| outSwitch | `(event: ISwitchEvent) => void` | Sự kiện khi toggle, trả về trạng thái và hàm `revert` |
|
|
109
|
+
|
|
110
|
+
### Interfaces
|
|
111
|
+
|
|
112
|
+
#### `ISwitch`
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
export interface ISwitch {
|
|
116
|
+
disable?: boolean;
|
|
117
|
+
active?: boolean;
|
|
118
|
+
action?: (event: ISwitchEvent) => Promise<void>;
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Mô tả cấu hình switch (inputs):
|
|
123
|
+
- `disable`: vô hiệu hóa switch.
|
|
124
|
+
- `active`: trạng thái bật/tắt.
|
|
125
|
+
- `action`: hàm xử lý khi toggle (tùy chọn).
|
|
126
|
+
|
|
127
|
+
#### `ISwitchEvent`
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
export interface ISwitchEvent {
|
|
131
|
+
active: boolean;
|
|
132
|
+
revert: () => Promise<void>;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Mô tả payload của sự kiện `outSwitch`:
|
|
137
|
+
- `active`: trạng thái mới.
|
|
138
|
+
- `revert`: hàm để hoàn nguyên về trạng thái trước đó.
|
|
139
|
+
|
|
140
|
+
## Demo
|
|
141
|
+
|
|
142
|
+
Để xem ví dụ tương tác về component Switch, bạn có thể sử dụng `LibsUiComponentsSwitchDemoComponent` trong ứng dụng của mình:
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import { Component } from '@angular/core';
|
|
146
|
+
import { LibsUiComponentsSwitchDemoComponent } from '@libs-ui/components-switch';
|
|
147
|
+
|
|
148
|
+
@Component({
|
|
149
|
+
selector: 'app-switch-demo',
|
|
150
|
+
standalone: true,
|
|
151
|
+
imports: [LibsUiComponentsSwitchDemoComponent],
|
|
152
|
+
template: `
|
|
153
|
+
<lib-switch-demo></lib-switch-demo>
|
|
154
|
+
`
|
|
155
|
+
})
|
|
156
|
+
export class SwitchDemoComponent {}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Hoặc thêm trực tiếp trong template HTML:
|
|
160
|
+
|
|
161
|
+
```html
|
|
162
|
+
<lib-switch-demo></lib-switch-demo>
|
|
163
|
+
```
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3dpdGNoLmludGVyZmFjZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL2xpYnMtdWkvY29tcG9uZW50cy9zd2l0Y2gvc3JjL2ludGVyZmFjZXMvc3dpdGNoLmludGVyZmFjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGludGVyZmFjZSBJU3dpdGNoIHtcbiAgICBkaXNhYmxlPzogYm9vbGVhbjtcbiAgICBhY3RpdmU/
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3dpdGNoLmludGVyZmFjZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL2xpYnMtdWkvY29tcG9uZW50cy9zd2l0Y2gvc3JjL2ludGVyZmFjZXMvc3dpdGNoLmludGVyZmFjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGludGVyZmFjZSBJU3dpdGNoIHtcbiAgICBkaXNhYmxlPzogYm9vbGVhbjtcbiAgICBhY3RpdmU/OiBib29sZWFuO1xuICAgIGFjdGlvbj86IChldmVudDogSVN3aXRjaEV2ZW50KSA9PiBQcm9taXNlPHZvaWQ+O1xufVxuXG5leHBvcnQgaW50ZXJmYWNlIElTd2l0Y2hFdmVudCB7XG4gICAgYWN0aXZlOiBib29sZWFuO1xuICAgIHJldmVydDogKCkgPT4gUHJvbWlzZTx2b2lkPjtcbn1cbiJdfQ==
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ChangeDetectionStrategy, Component, input, model, output } from '@angular/core';
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
3
|
export class LibsUiComponentsSwitchComponent {
|
|
4
|
-
|
|
4
|
+
// #region PROPERTY
|
|
5
5
|
size = input('default');
|
|
6
6
|
disable = input();
|
|
7
7
|
active = model(false);
|
|
8
|
-
|
|
8
|
+
// #region OUTPUT
|
|
9
9
|
outSwitch = output();
|
|
10
10
|
/* FUNCTIONS */
|
|
11
11
|
async handlerClick(event) {
|
|
@@ -23,10 +23,10 @@ export class LibsUiComponentsSwitchComponent {
|
|
|
23
23
|
this.active.update(value => value ? false : true);
|
|
24
24
|
}
|
|
25
25
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: LibsUiComponentsSwitchComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
26
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.13", type: LibsUiComponentsSwitchComponent, isStandalone: true, selector: "libs_ui-components-switch", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, disable: { classPropertyName: "disable", publicName: "disable", isSignal: true, isRequired: false, transformFunction: null }, active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { active: "activeChange", outSwitch: "outSwitch" }, ngImport: i0, template: "<div [attr.size]=\"size()\"\n [class.libs-ui-switch-container]=\"true\"\n [class.
|
|
26
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.13", type: LibsUiComponentsSwitchComponent, isStandalone: true, selector: "libs_ui-components-switch", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, disable: { classPropertyName: "disable", publicName: "disable", isSignal: true, isRequired: false, transformFunction: null }, active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { active: "activeChange", outSwitch: "outSwitch" }, ngImport: i0, template: "<div [attr.size]=\"size()\"\n [class.libs-ui-switch-container]=\"true\"\n [class.pointer-events-none]=\"disable()\"\n (click)=\"handlerClick($event)\">\n <div [attr.size]=\"size()\"\n [class.libs-ui-switch-bar]=\"true\"\n [class.libs-ui-switch-bar-active]=\"active()\"\n [class.libs-ui-disable-background]=\"!active() && disable()\"\n [class.libs-ui-disable-active-background]=\"active() && disable()\">\n </div>\n <div [attr.size]=\"size()\"\n [class.libs-ui-switch-circle]=\"true\"\n [class.libs-ui-switch-circle-active]=\"active()\">\n </div>\n\n</div>\n", styles: [".libs-ui-switch-container{position:relative;cursor:pointer}.libs-ui-switch-container .libs-ui-switch-bar{width:30px;height:16px;border-radius:8px;background-color:#cdd0d6;transition:all .3s;-webkit-transition:all .3s}.libs-ui-switch-container .libs-ui-switch-bar[size=large]{width:45px;height:24px;border-radius:24px}.libs-ui-switch-container .libs-ui-switch-bar.libs-ui-switch-bar-active{background-color:var(--libs-ui-color-default, #226FF5)}.libs-ui-switch-container .libs-ui-switch-circle{height:12px;width:12px;background-color:#fff;border-radius:50%;position:absolute;top:2px;left:2px;cursor:pointer;transition:left .3s;-webkit-transition:left .3s}.libs-ui-switch-container .libs-ui-switch-circle[size=large]{width:20px;height:20px}.libs-ui-switch-container .libs-ui-switch-circle.libs-ui-switch-circle-active{left:16px}.libs-ui-switch-container .libs-ui-switch-circle.libs-ui-switch-circle-active[size=large]{left:23px}.libs-ui-switch-container .libs-ui-disable-background{background-color:#e6e7ea!important}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
27
27
|
}
|
|
28
28
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: LibsUiComponentsSwitchComponent, decorators: [{
|
|
29
29
|
type: Component,
|
|
30
|
-
args: [{ selector: 'libs_ui-components-switch', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [attr.size]=\"size()\"\n [class.libs-ui-switch-container]=\"true\"\n [class.
|
|
30
|
+
args: [{ selector: 'libs_ui-components-switch', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [attr.size]=\"size()\"\n [class.libs-ui-switch-container]=\"true\"\n [class.pointer-events-none]=\"disable()\"\n (click)=\"handlerClick($event)\">\n <div [attr.size]=\"size()\"\n [class.libs-ui-switch-bar]=\"true\"\n [class.libs-ui-switch-bar-active]=\"active()\"\n [class.libs-ui-disable-background]=\"!active() && disable()\"\n [class.libs-ui-disable-active-background]=\"active() && disable()\">\n </div>\n <div [attr.size]=\"size()\"\n [class.libs-ui-switch-circle]=\"true\"\n [class.libs-ui-switch-circle-active]=\"active()\">\n </div>\n\n</div>\n", styles: [".libs-ui-switch-container{position:relative;cursor:pointer}.libs-ui-switch-container .libs-ui-switch-bar{width:30px;height:16px;border-radius:8px;background-color:#cdd0d6;transition:all .3s;-webkit-transition:all .3s}.libs-ui-switch-container .libs-ui-switch-bar[size=large]{width:45px;height:24px;border-radius:24px}.libs-ui-switch-container .libs-ui-switch-bar.libs-ui-switch-bar-active{background-color:var(--libs-ui-color-default, #226FF5)}.libs-ui-switch-container .libs-ui-switch-circle{height:12px;width:12px;background-color:#fff;border-radius:50%;position:absolute;top:2px;left:2px;cursor:pointer;transition:left .3s;-webkit-transition:left .3s}.libs-ui-switch-container .libs-ui-switch-circle[size=large]{width:20px;height:20px}.libs-ui-switch-container .libs-ui-switch-circle.libs-ui-switch-circle-active{left:16px}.libs-ui-switch-container .libs-ui-switch-circle.libs-ui-switch-circle-active[size=large]{left:23px}.libs-ui-switch-container .libs-ui-disable-background{background-color:#e6e7ea!important}\n"] }]
|
|
31
31
|
}] });
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3dpdGNoLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMtdWkvY29tcG9uZW50cy9zd2l0Y2gvc3JjL3N3aXRjaC5jb21wb25lbnQudHMiLCIuLi8uLi8uLi8uLi8uLi9saWJzLXVpL2NvbXBvbmVudHMvc3dpdGNoL3NyYy9zd2l0Y2guY29tcG9uZW50Lmh0bWwiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLHVCQUF1QixFQUFFLFNBQVMsRUFBRSxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLGVBQWUsQ0FBQzs7QUFZekYsTUFBTSxPQUFPLCtCQUErQjtJQUUxQyxtQkFBbUI7SUFDVixJQUFJLEdBQUcsS0FBSyxDQUFzQixTQUFTLENBQUMsQ0FBQztJQUM3QyxPQUFPLEdBQUcsS0FBSyxFQUFXLENBQUM7SUFDM0IsTUFBTSxHQUFHLEtBQUssQ0FBVSxLQUFLLENBQUMsQ0FBQztJQUV4QyxpQkFBaUI7SUFDUixTQUFTLEdBQUcsTU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O1xuICB9XG5cbiAgcHJpdmF0ZSBhc3luYyBzZXRBY3RpdmVUb2dnbGUoKSB7XG4gICAgdGhpcy5hY3RpdmUudXBkYXRlKHZhbHVlID0+IHZhbHVlID8gZmFsc2UgOiB0cnVlKTtcbiAgfVxufVxuIiwiPGRpdiBbYXR0ci5zaXplXT1cInNpemUoKVwiXG4gIFtjbGFzcy5saWJzLXVpLXN3aXRjaC1jb250YWluZXJdPVwidHJ1ZVwiXG4gIFtjbGFzcy5wb2ludGVyLWV2ZW50cy1ub25lXT1cImRpc2FibGUoKVwiXG4gIChjbGljayk9XCJoYW5kbGVyQ2xpY2soJGV2ZW50KVwiPlxuICA8ZGl2IFthdHRyLnNpemVdPVwic2l6ZSgpXCJcbiAgICBbY2xhc3MubGlicy11aS1zd2l0Y2gtYmFyXT1cInRydWVcIlxuICAgIFtjbGFzcy5saWJzLXVpLXN3aXRjaC1iYXItYWN0aXZlXT1cImFjdGl2ZSgpXCJcbiAgICBbY2xhc3MubGlicy11aS1kaXNhYmxlLWJhY2tncm91bmRdPVwiIWFjdGl2ZSgpICYmIGRpc2FibGUoKVwiXG4gICAgW2NsYXNzLmxpYnMtdWktZGlzYWJsZS1hY3RpdmUtYmFja2dyb3VuZF09XCJhY3RpdmUoKSAmJiBkaXNhYmxlKClcIj5cbiAgPC9kaXY+XG4gIDxkaXYgW2F0dHIuc2l6ZV09XCJzaXplKClcIlxuICAgIFtjbGFzcy5saWJzLXVpLXN3aXRjaC1jaXJjbGVdPVwidHJ1ZVwiXG4gICAgW2NsYXNzLmxpYnMtdWktc3dpdGNoLWNpcmNsZS1hY3RpdmVdPVwiYWN0aXZlKClcIj5cbiAgPC9kaXY+XG5cbjwvZGl2PlxuIl19
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, model, output,
|
|
2
|
+
import { input, model, output, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
|
|
4
4
|
class LibsUiComponentsSwitchComponent {
|
|
5
|
-
|
|
5
|
+
// #region PROPERTY
|
|
6
6
|
size = input('default');
|
|
7
7
|
disable = input();
|
|
8
8
|
active = model(false);
|
|
9
|
-
|
|
9
|
+
// #region OUTPUT
|
|
10
10
|
outSwitch = output();
|
|
11
11
|
/* FUNCTIONS */
|
|
12
12
|
async handlerClick(event) {
|
|
@@ -24,11 +24,11 @@ class LibsUiComponentsSwitchComponent {
|
|
|
24
24
|
this.active.update(value => value ? false : true);
|
|
25
25
|
}
|
|
26
26
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: LibsUiComponentsSwitchComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
27
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.13", type: LibsUiComponentsSwitchComponent, isStandalone: true, selector: "libs_ui-components-switch", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, disable: { classPropertyName: "disable", publicName: "disable", isSignal: true, isRequired: false, transformFunction: null }, active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { active: "activeChange", outSwitch: "outSwitch" }, ngImport: i0, template: "<div [attr.size]=\"size()\"\n [class.libs-ui-switch-container]=\"true\"\n [class.
|
|
27
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.13", type: LibsUiComponentsSwitchComponent, isStandalone: true, selector: "libs_ui-components-switch", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, disable: { classPropertyName: "disable", publicName: "disable", isSignal: true, isRequired: false, transformFunction: null }, active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { active: "activeChange", outSwitch: "outSwitch" }, ngImport: i0, template: "<div [attr.size]=\"size()\"\n [class.libs-ui-switch-container]=\"true\"\n [class.pointer-events-none]=\"disable()\"\n (click)=\"handlerClick($event)\">\n <div [attr.size]=\"size()\"\n [class.libs-ui-switch-bar]=\"true\"\n [class.libs-ui-switch-bar-active]=\"active()\"\n [class.libs-ui-disable-background]=\"!active() && disable()\"\n [class.libs-ui-disable-active-background]=\"active() && disable()\">\n </div>\n <div [attr.size]=\"size()\"\n [class.libs-ui-switch-circle]=\"true\"\n [class.libs-ui-switch-circle-active]=\"active()\">\n </div>\n\n</div>\n", styles: [".libs-ui-switch-container{position:relative;cursor:pointer}.libs-ui-switch-container .libs-ui-switch-bar{width:30px;height:16px;border-radius:8px;background-color:#cdd0d6;transition:all .3s;-webkit-transition:all .3s}.libs-ui-switch-container .libs-ui-switch-bar[size=large]{width:45px;height:24px;border-radius:24px}.libs-ui-switch-container .libs-ui-switch-bar.libs-ui-switch-bar-active{background-color:var(--libs-ui-color-default, #226FF5)}.libs-ui-switch-container .libs-ui-switch-circle{height:12px;width:12px;background-color:#fff;border-radius:50%;position:absolute;top:2px;left:2px;cursor:pointer;transition:left .3s;-webkit-transition:left .3s}.libs-ui-switch-container .libs-ui-switch-circle[size=large]{width:20px;height:20px}.libs-ui-switch-container .libs-ui-switch-circle.libs-ui-switch-circle-active{left:16px}.libs-ui-switch-container .libs-ui-switch-circle.libs-ui-switch-circle-active[size=large]{left:23px}.libs-ui-switch-container .libs-ui-disable-background{background-color:#e6e7ea!important}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
28
28
|
}
|
|
29
29
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: LibsUiComponentsSwitchComponent, decorators: [{
|
|
30
30
|
type: Component,
|
|
31
|
-
args: [{ selector: 'libs_ui-components-switch', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [attr.size]=\"size()\"\n [class.libs-ui-switch-container]=\"true\"\n [class.
|
|
31
|
+
args: [{ selector: 'libs_ui-components-switch', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [attr.size]=\"size()\"\n [class.libs-ui-switch-container]=\"true\"\n [class.pointer-events-none]=\"disable()\"\n (click)=\"handlerClick($event)\">\n <div [attr.size]=\"size()\"\n [class.libs-ui-switch-bar]=\"true\"\n [class.libs-ui-switch-bar-active]=\"active()\"\n [class.libs-ui-disable-background]=\"!active() && disable()\"\n [class.libs-ui-disable-active-background]=\"active() && disable()\">\n </div>\n <div [attr.size]=\"size()\"\n [class.libs-ui-switch-circle]=\"true\"\n [class.libs-ui-switch-circle-active]=\"active()\">\n </div>\n\n</div>\n", styles: [".libs-ui-switch-container{position:relative;cursor:pointer}.libs-ui-switch-container .libs-ui-switch-bar{width:30px;height:16px;border-radius:8px;background-color:#cdd0d6;transition:all .3s;-webkit-transition:all .3s}.libs-ui-switch-container .libs-ui-switch-bar[size=large]{width:45px;height:24px;border-radius:24px}.libs-ui-switch-container .libs-ui-switch-bar.libs-ui-switch-bar-active{background-color:var(--libs-ui-color-default, #226FF5)}.libs-ui-switch-container .libs-ui-switch-circle{height:12px;width:12px;background-color:#fff;border-radius:50%;position:absolute;top:2px;left:2px;cursor:pointer;transition:left .3s;-webkit-transition:left .3s}.libs-ui-switch-container .libs-ui-switch-circle[size=large]{width:20px;height:20px}.libs-ui-switch-container .libs-ui-switch-circle.libs-ui-switch-circle-active{left:16px}.libs-ui-switch-container .libs-ui-switch-circle.libs-ui-switch-circle-active[size=large]{left:23px}.libs-ui-switch-container .libs-ui-disable-background{background-color:#e6e7ea!important}\n"] }]
|
|
32
32
|
}] });
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libs-ui-components-switch.mjs","sources":["../../../../../libs-ui/components/switch/src/switch.component.ts","../../../../../libs-ui/components/switch/src/switch.component.html","../../../../../libs-ui/components/switch/src/libs-ui-components-switch.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, input, model, output } from '@angular/core';\nimport { ISwitchEvent } from './interfaces';\n\n@Component({\n // eslint-disable-next-line @angular-eslint/component-selector\n selector: 'libs_ui-components-switch',\n templateUrl: './switch.component.html',\n styleUrls: ['./switch.component.scss'],\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush\n})\n\nexport class LibsUiComponentsSwitchComponent {\n\n
|
|
1
|
+
{"version":3,"file":"libs-ui-components-switch.mjs","sources":["../../../../../libs-ui/components/switch/src/switch.component.ts","../../../../../libs-ui/components/switch/src/switch.component.html","../../../../../libs-ui/components/switch/src/libs-ui-components-switch.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, input, model, output } from '@angular/core';\nimport { ISwitchEvent } from './interfaces';\n\n@Component({\n // eslint-disable-next-line @angular-eslint/component-selector\n selector: 'libs_ui-components-switch',\n templateUrl: './switch.component.html',\n styleUrls: ['./switch.component.scss'],\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush\n})\n\nexport class LibsUiComponentsSwitchComponent {\n\n // #region PROPERTY\n readonly size = input<'default' | 'large'>('default');\n readonly disable = input<boolean>();\n readonly active = model<boolean>(false);\n\n // #region OUTPUT\n readonly outSwitch = output<ISwitchEvent>();\n\n /* FUNCTIONS */\n protected async handlerClick(event: Event) {\n event.stopPropagation();\n if (this.disable()) {\n return;\n }\n this.setActiveToggle();\n this.outSwitch.emit({\n active: this.active(),\n revert: this.setActiveToggle.bind(this)\n });\n }\n\n private async setActiveToggle() {\n this.active.update(value => value ? false : true);\n }\n}\n","<div [attr.size]=\"size()\"\n [class.libs-ui-switch-container]=\"true\"\n [class.pointer-events-none]=\"disable()\"\n (click)=\"handlerClick($event)\">\n <div [attr.size]=\"size()\"\n [class.libs-ui-switch-bar]=\"true\"\n [class.libs-ui-switch-bar-active]=\"active()\"\n [class.libs-ui-disable-background]=\"!active() && disable()\"\n [class.libs-ui-disable-active-background]=\"active() && disable()\">\n </div>\n <div [attr.size]=\"size()\"\n [class.libs-ui-switch-circle]=\"true\"\n [class.libs-ui-switch-circle-active]=\"active()\">\n </div>\n\n</div>\n","/**\n * Generated bundle index. Do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,QAAA,EAAA,wkBAAA,EAAA,MAAA,EAAA,CAAA,2/BAAA,CAAA,EAAA;;;AETjD;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libs-ui/components-switch",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.306.1",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@angular/
|
|
6
|
-
"@angular/core": "^18.2.0"
|
|
5
|
+
"@angular/core": ">=18.0.0"
|
|
7
6
|
},
|
|
8
7
|
"sideEffects": false,
|
|
9
8
|
"module": "fesm2022/libs-ui-components-switch.mjs",
|