ud-components 0.1.7 → 0.1.8
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,9 +1,9 @@
|
|
|
1
1
|
import * as i1$3 from '@angular/common';
|
|
2
2
|
import { CommonModule, formatDate, NgClass, AsyncPipe, NgStyle, DatePipe, NgTemplateOutlet, NgSwitch } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { ViewChild, Input, CUSTOM_ELEMENTS_SCHEMA, Component, Inject, Pipe, Injectable, inject, DestroyRef, EventEmitter, TemplateRef, ContentChild, Output, ViewContainerRef, Directive, ContentChildren, input, effect, ViewChildren } from '@angular/core';
|
|
4
|
+
import { ViewChild, Input, CUSTOM_ELEMENTS_SCHEMA, Component, Inject, Pipe, Injectable, inject, DestroyRef, EventEmitter, TemplateRef, ContentChild, Output, ViewContainerRef, Directive, ContentChildren, input, effect, ViewChildren, forwardRef, HostBinding } from '@angular/core';
|
|
5
5
|
import * as i1 from '@angular/forms';
|
|
6
|
-
import { FormsModule, FormGroup, FormControl, ReactiveFormsModule, ControlContainer } from '@angular/forms';
|
|
6
|
+
import { FormsModule, FormGroup, FormControl, ReactiveFormsModule, ControlContainer, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
7
7
|
import * as i1$1 from '@angular/material/snack-bar';
|
|
8
8
|
import { MAT_SNACK_BAR_DATA } from '@angular/material/snack-bar';
|
|
9
9
|
import { interval, map, of, debounceTime, distinctUntilChanged, switchMap, iif, isObservable, Subject, startWith, takeUntil } from 'rxjs';
|
|
@@ -2273,6 +2273,80 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
|
|
|
2273
2273
|
type: Input
|
|
2274
2274
|
}] } });
|
|
2275
2275
|
|
|
2276
|
+
class ToggleComponent {
|
|
2277
|
+
size = 'md';
|
|
2278
|
+
label;
|
|
2279
|
+
labelPosition = 'right';
|
|
2280
|
+
ariaLabel;
|
|
2281
|
+
get isSm() {
|
|
2282
|
+
return this.size === 'sm';
|
|
2283
|
+
}
|
|
2284
|
+
get isMd() {
|
|
2285
|
+
return this.size === 'md';
|
|
2286
|
+
}
|
|
2287
|
+
get isLg() {
|
|
2288
|
+
return this.size === 'lg';
|
|
2289
|
+
}
|
|
2290
|
+
checked = false;
|
|
2291
|
+
isDisabled = false;
|
|
2292
|
+
onChange = () => { };
|
|
2293
|
+
onTouched = () => { };
|
|
2294
|
+
toggle() {
|
|
2295
|
+
if (this.isDisabled)
|
|
2296
|
+
return;
|
|
2297
|
+
this.checked = !this.checked;
|
|
2298
|
+
this.onChange(this.checked);
|
|
2299
|
+
this.onTouched();
|
|
2300
|
+
}
|
|
2301
|
+
writeValue(value) {
|
|
2302
|
+
this.checked = !!value;
|
|
2303
|
+
}
|
|
2304
|
+
registerOnChange(fn) {
|
|
2305
|
+
this.onChange = fn;
|
|
2306
|
+
}
|
|
2307
|
+
registerOnTouched(fn) {
|
|
2308
|
+
this.onTouched = fn;
|
|
2309
|
+
}
|
|
2310
|
+
setDisabledState(isDisabled) {
|
|
2311
|
+
this.isDisabled = isDisabled;
|
|
2312
|
+
}
|
|
2313
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: ToggleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2314
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: ToggleComponent, isStandalone: true, selector: "ud-toggle", inputs: { size: "size", label: "label", labelPosition: "labelPosition", ariaLabel: "ariaLabel" }, host: { properties: { "class.size-sm": "this.isSm", "class.size-md": "this.isMd", "class.size-lg": "this.isLg" } }, providers: [
|
|
2315
|
+
{
|
|
2316
|
+
provide: NG_VALUE_ACCESSOR,
|
|
2317
|
+
useExisting: forwardRef(() => ToggleComponent),
|
|
2318
|
+
multi: true,
|
|
2319
|
+
},
|
|
2320
|
+
], ngImport: i0, template: "<button\n type=\"button\"\n class=\"ud-toggle\"\n [class.checked]=\"checked\"\n [class.disabled]=\"isDisabled\"\n [class.label-left]=\"labelPosition === 'left'\"\n role=\"switch\"\n [attr.aria-checked]=\"checked\"\n [attr.aria-label]=\"ariaLabel || label\"\n [disabled]=\"isDisabled || null\"\n (click)=\"toggle()\">\n @if (label && labelPosition === 'left') {\n <span class=\"toggle-label\">{{ label }}</span>\n }\n <span class=\"track\" aria-hidden=\"true\">\n <span class=\"thumb\">\n <span class=\"thumb-core\"></span>\n </span>\n </span>\n @if (label && labelPosition === 'right') {\n <span class=\"toggle-label\">{{ label }}</span>\n }\n</button>\n", styles: ["@import\"https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500&display=swap\";:host{display:inline-flex;align-items:center;--toggle-track-off: #d2d6de;--toggle-track-on: #1b2535;--toggle-thumb: #ffffff;--toggle-glow: rgba(27, 37, 53, .14);--toggle-label-color: #4a5568;--toggle-font: \"DM Sans\", system-ui, sans-serif;--toggle-duration: .3s;--toggle-spring: cubic-bezier(.34, 1.56, .64, 1)}:host(.size-sm){--track-w: 28px;--track-h: 16px;--thumb-d: 12px;--thumb-inset: 2px}:host(.size-md){--track-w: 44px;--track-h: 24px;--thumb-d: 18px;--thumb-inset: 3px}:host(.size-lg){--track-w: 56px;--track-h: 32px;--thumb-d: 24px;--thumb-inset: 4px}.ud-toggle{display:inline-flex;align-items:center;gap:.6rem;background:none;border:none;padding:0;cursor:pointer;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;outline:none}.ud-toggle:focus-visible .track{outline:2px solid var(--toggle-track-on);outline-offset:2px}.ud-toggle.disabled{opacity:.38;cursor:not-allowed;pointer-events:none}.track{position:relative;display:block;width:var(--track-w);height:var(--track-h);border-radius:999px;background:var(--toggle-track-off);box-shadow:inset 0 1px 3px #0000002e,inset 0 0 0 1px #0000000f;transition:background var(--toggle-duration) ease;flex-shrink:0}.ud-toggle.checked .track{background:var(--toggle-track-on);box-shadow:inset 0 1px 3px #0000004d,inset 0 0 0 1px #00000026}.thumb{position:absolute;top:50%;left:0;width:var(--thumb-d);height:var(--thumb-d);border-radius:50%;background:var(--toggle-thumb);transform:translateY(-50%) translate(var(--thumb-inset));box-shadow:0 1px 2px #00000038,0 2px 6px #00000024;transition:transform var(--toggle-duration) var(--toggle-spring),box-shadow .22s ease;display:flex;align-items:center;justify-content:center}.ud-toggle.checked .thumb{transform:translateY(-50%) translate(calc(var(--track-w) - var(--thumb-d) - var(--thumb-inset)));box-shadow:0 1px 2px #0000002e,0 2px 6px #0000001a,0 0 0 4px var(--toggle-glow)}.thumb-core{width:4px;height:4px;border-radius:50%;background:#0000001a;transition:opacity .2s ease,transform .3s var(--toggle-spring)}:host(.size-sm) .thumb-core{display:none}.ud-toggle.checked .thumb-core{background:#1b25352e;transform:scale(1.4)}.toggle-label{font-family:var(--toggle-font);font-size:.875rem;font-weight:500;color:var(--toggle-label-color);line-height:1;white-space:nowrap}:host(.size-sm) .toggle-label{font-size:.8rem}:host(.size-lg) .toggle-label{font-size:.95rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
2321
|
+
}
|
|
2322
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: ToggleComponent, decorators: [{
|
|
2323
|
+
type: Component,
|
|
2324
|
+
args: [{ selector: 'ud-toggle', standalone: true, imports: [CommonModule], providers: [
|
|
2325
|
+
{
|
|
2326
|
+
provide: NG_VALUE_ACCESSOR,
|
|
2327
|
+
useExisting: forwardRef(() => ToggleComponent),
|
|
2328
|
+
multi: true,
|
|
2329
|
+
},
|
|
2330
|
+
], template: "<button\n type=\"button\"\n class=\"ud-toggle\"\n [class.checked]=\"checked\"\n [class.disabled]=\"isDisabled\"\n [class.label-left]=\"labelPosition === 'left'\"\n role=\"switch\"\n [attr.aria-checked]=\"checked\"\n [attr.aria-label]=\"ariaLabel || label\"\n [disabled]=\"isDisabled || null\"\n (click)=\"toggle()\">\n @if (label && labelPosition === 'left') {\n <span class=\"toggle-label\">{{ label }}</span>\n }\n <span class=\"track\" aria-hidden=\"true\">\n <span class=\"thumb\">\n <span class=\"thumb-core\"></span>\n </span>\n </span>\n @if (label && labelPosition === 'right') {\n <span class=\"toggle-label\">{{ label }}</span>\n }\n</button>\n", styles: ["@import\"https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500&display=swap\";:host{display:inline-flex;align-items:center;--toggle-track-off: #d2d6de;--toggle-track-on: #1b2535;--toggle-thumb: #ffffff;--toggle-glow: rgba(27, 37, 53, .14);--toggle-label-color: #4a5568;--toggle-font: \"DM Sans\", system-ui, sans-serif;--toggle-duration: .3s;--toggle-spring: cubic-bezier(.34, 1.56, .64, 1)}:host(.size-sm){--track-w: 28px;--track-h: 16px;--thumb-d: 12px;--thumb-inset: 2px}:host(.size-md){--track-w: 44px;--track-h: 24px;--thumb-d: 18px;--thumb-inset: 3px}:host(.size-lg){--track-w: 56px;--track-h: 32px;--thumb-d: 24px;--thumb-inset: 4px}.ud-toggle{display:inline-flex;align-items:center;gap:.6rem;background:none;border:none;padding:0;cursor:pointer;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;outline:none}.ud-toggle:focus-visible .track{outline:2px solid var(--toggle-track-on);outline-offset:2px}.ud-toggle.disabled{opacity:.38;cursor:not-allowed;pointer-events:none}.track{position:relative;display:block;width:var(--track-w);height:var(--track-h);border-radius:999px;background:var(--toggle-track-off);box-shadow:inset 0 1px 3px #0000002e,inset 0 0 0 1px #0000000f;transition:background var(--toggle-duration) ease;flex-shrink:0}.ud-toggle.checked .track{background:var(--toggle-track-on);box-shadow:inset 0 1px 3px #0000004d,inset 0 0 0 1px #00000026}.thumb{position:absolute;top:50%;left:0;width:var(--thumb-d);height:var(--thumb-d);border-radius:50%;background:var(--toggle-thumb);transform:translateY(-50%) translate(var(--thumb-inset));box-shadow:0 1px 2px #00000038,0 2px 6px #00000024;transition:transform var(--toggle-duration) var(--toggle-spring),box-shadow .22s ease;display:flex;align-items:center;justify-content:center}.ud-toggle.checked .thumb{transform:translateY(-50%) translate(calc(var(--track-w) - var(--thumb-d) - var(--thumb-inset)));box-shadow:0 1px 2px #0000002e,0 2px 6px #0000001a,0 0 0 4px var(--toggle-glow)}.thumb-core{width:4px;height:4px;border-radius:50%;background:#0000001a;transition:opacity .2s ease,transform .3s var(--toggle-spring)}:host(.size-sm) .thumb-core{display:none}.ud-toggle.checked .thumb-core{background:#1b25352e;transform:scale(1.4)}.toggle-label{font-family:var(--toggle-font);font-size:.875rem;font-weight:500;color:var(--toggle-label-color);line-height:1;white-space:nowrap}:host(.size-sm) .toggle-label{font-size:.8rem}:host(.size-lg) .toggle-label{font-size:.95rem}\n"] }]
|
|
2331
|
+
}], propDecorators: { size: [{
|
|
2332
|
+
type: Input
|
|
2333
|
+
}], label: [{
|
|
2334
|
+
type: Input
|
|
2335
|
+
}], labelPosition: [{
|
|
2336
|
+
type: Input
|
|
2337
|
+
}], ariaLabel: [{
|
|
2338
|
+
type: Input
|
|
2339
|
+
}], isSm: [{
|
|
2340
|
+
type: HostBinding,
|
|
2341
|
+
args: ['class.size-sm']
|
|
2342
|
+
}], isMd: [{
|
|
2343
|
+
type: HostBinding,
|
|
2344
|
+
args: ['class.size-md']
|
|
2345
|
+
}], isLg: [{
|
|
2346
|
+
type: HostBinding,
|
|
2347
|
+
args: ['class.size-lg']
|
|
2348
|
+
}] } });
|
|
2349
|
+
|
|
2276
2350
|
/*
|
|
2277
2351
|
* Public API Surface of ud-components
|
|
2278
2352
|
*/
|
|
@@ -2282,5 +2356,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
|
|
|
2282
2356
|
* Generated bundle index. Do not edit.
|
|
2283
2357
|
*/
|
|
2284
2358
|
|
|
2285
|
-
export { ActionType, ApplicationStatus, CapitalizePipe, CarouselComponent, CustomInputComponent, CustomSnackbarComponent, CustomTableComponent, DateOperator, DynamicComponentComponent, EditViewComponent, EditViewSectionDirective, FileInputComponent, FilterType, IconColor, KpiComponent, KpiDataType, KpiPillType, KpiProgressBarType, ModalComponent, ModalInputType, MultiSelectComponent, NumberOperator, PillComponent, PillToggleComponent, PluralizePipe, ProgressBarComponent, Role, SafePipe, SingularPipe, SnackbarType, StringOperator, SummaryViewComponent, TableDisplayColumnType, TabsComponent, TelInputComponent, TextInputComponent, TranslateWrapperService, UdButtonComponent, capitalize, formatLocalDate, formatLocalDateTime, formatLocalDateTimeLongForm, formatLocalTime, formatLocalTimeWithMinutes, formatLocalTimeWithMinutesAmPm, formatMonthYear, formatPhoneNumber, formatStringDate, formatStringDateTime, generateTimeOptions, inListValidator, parseLocalDate, pluralize, spaceCase, updateArray };
|
|
2359
|
+
export { ActionType, ApplicationStatus, CapitalizePipe, CarouselComponent, CustomInputComponent, CustomSnackbarComponent, CustomTableComponent, DateOperator, DynamicComponentComponent, EditViewComponent, EditViewSectionDirective, FileInputComponent, FilterType, IconColor, KpiComponent, KpiDataType, KpiPillType, KpiProgressBarType, ModalComponent, ModalInputType, MultiSelectComponent, NumberOperator, PillComponent, PillToggleComponent, PluralizePipe, ProgressBarComponent, Role, SafePipe, SingularPipe, SnackbarType, StringOperator, SummaryViewComponent, TableDisplayColumnType, TabsComponent, TelInputComponent, TextInputComponent, ToggleComponent, TranslateWrapperService, UdButtonComponent, capitalize, formatLocalDate, formatLocalDateTime, formatLocalDateTimeLongForm, formatLocalTime, formatLocalTimeWithMinutes, formatLocalTimeWithMinutesAmPm, formatMonthYear, formatPhoneNumber, formatStringDate, formatStringDateTime, generateTimeOptions, inListValidator, parseLocalDate, pluralize, spaceCase, updateArray };
|
|
2286
2360
|
//# sourceMappingURL=ud-components.mjs.map
|