@thalassic/ui 0.1.1 → 0.3.0
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.txt +21 -0
- package/features/button/button.scss +2 -42
- package/features/divider/divider.scss +91 -0
- package/features/form/input/input.scss +6 -0
- package/fesm2022/thalassic-ui.mjs +199 -61
- package/fesm2022/thalassic-ui.mjs.map +1 -1
- package/package.json +2 -1
- package/styles/components/_index.scss +1 -0
- package/styles/components/button/_button-appearance.scss +136 -0
- package/{features/button/button-color.scss → styles/components/button/_button-color.scss} +9 -9
- package/{features/button/button-size.scss → styles/components/button/_button-size.scss} +20 -15
- package/styles/components/button/_button.scss +49 -0
- package/styles/components/button/_index.scss +4 -0
- package/styles/components/form/{form-control/_form-control-group-size.scss → _form-control-group-size.scss} +7 -0
- package/styles/components/form/{form-control/_form-control-group.scss → _form-control-group.scss} +1 -0
- package/styles/components/form/{form-control/_form-control-size.scss → _form-control-size.scss} +7 -0
- package/styles/components/form/_index.scss +4 -0
- package/types/thalassic-ui.d.ts +125 -22
- package/features/button/button-appearance.scss +0 -144
- package/index.scss +0 -1
- package/styles/components/form/form-control/_index.scss +0 -5
- /package/styles/components/form/{form-control/_form-control-addon.scss → _form-control-addon.scss} +0 -0
- /package/styles/components/form/{form-control/_form-control.scss → _form-control.scss} +0 -0
- /package/styles/{_index.scss → index.scss} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NgTemplateOutlet, isPlatformBrowser } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { InjectionToken, inject, Injectable, input, computed, Component, booleanAttribute,
|
|
3
|
+
import { InjectionToken, inject, Injectable, input, computed, Component, booleanAttribute, Directive, model, contentChild, forwardRef, DOCUMENT, RendererFactory2, PLATFORM_ID, signal, effect, makeEnvironmentProviders, provideEnvironmentInitializer } from '@angular/core';
|
|
4
4
|
import { RouterLink } from '@angular/router';
|
|
5
5
|
import { rxResource } from '@angular/core/rxjs-interop';
|
|
6
6
|
import { HttpClient } from '@angular/common/http';
|
|
@@ -101,36 +101,23 @@ const DEFAULT_BUTTON_CONFIG = {
|
|
|
101
101
|
appearance: 'filled',
|
|
102
102
|
size: 'md',
|
|
103
103
|
type: 'button',
|
|
104
|
+
fluid: false,
|
|
104
105
|
};
|
|
105
106
|
|
|
106
107
|
const BUTTON_CONFIG = new InjectionToken('BUTTON_CONFIG', {
|
|
107
108
|
factory: () => DEFAULT_BUTTON_CONFIG,
|
|
108
109
|
});
|
|
109
110
|
|
|
110
|
-
class
|
|
111
|
+
class ButtonBase {
|
|
111
112
|
// Injections
|
|
112
|
-
_routerLink = inject(RouterLink, { optional: true });
|
|
113
113
|
_config = inject(BUTTON_CONFIG);
|
|
114
|
-
|
|
115
|
-
label = input(...(ngDevMode ? [undefined, { debugName: "label" }] : []));
|
|
116
|
-
type = input(this._config.type, ...(ngDevMode ? [{ debugName: "type" }] : []));
|
|
114
|
+
APPLY_HOST_CLASSES = true;
|
|
117
115
|
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : {}), transform: booleanAttribute });
|
|
118
|
-
icon = input(false, { ...(ngDevMode ? { debugName: "icon" } : {}), transform: (value) => {
|
|
119
|
-
if (typeof value === 'string' && value === '')
|
|
120
|
-
return true;
|
|
121
|
-
else if (typeof value === 'string')
|
|
122
|
-
return value;
|
|
123
|
-
else
|
|
124
|
-
return booleanAttribute(value);
|
|
125
|
-
} });
|
|
126
116
|
color = input(this._config.color, ...(ngDevMode ? [{ debugName: "color" }] : []));
|
|
127
117
|
appearance = input(this._config.appearance, ...(ngDevMode ? [{ debugName: "appearance" }] : []));
|
|
128
118
|
size = input(this._config.size, ...(ngDevMode ? [{ debugName: "size" }] : []));
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// Computed
|
|
132
|
-
isLink = computed(() => Boolean(this._routerLink || this.href()), ...(ngDevMode ? [{ debugName: "isLink" }] : []));
|
|
133
|
-
isIconString = computed(() => typeof this.icon() === 'string', ...(ngDevMode ? [{ debugName: "isIconString" }] : []));
|
|
119
|
+
/** Whether the button stretches to fill its container's width. */
|
|
120
|
+
fluid = input(this._config.fluid, { ...(ngDevMode ? { debugName: "fluid" } : {}), transform: booleanAttribute });
|
|
134
121
|
classes = computed(() => {
|
|
135
122
|
const className = 'tls-button';
|
|
136
123
|
const array = [className];
|
|
@@ -141,18 +128,116 @@ class Button {
|
|
|
141
128
|
array.push(`${className}--disabled`);
|
|
142
129
|
if (this.icon())
|
|
143
130
|
array.push(`${className}--icon-only`);
|
|
131
|
+
if (this.fluid())
|
|
132
|
+
array.push(`${className}--fluid`);
|
|
144
133
|
return array;
|
|
145
134
|
}, ...(ngDevMode ? [{ debugName: "classes" }] : []));
|
|
135
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ButtonBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
136
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.1", type: ButtonBase, isStandalone: true, inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, fluid: { classPropertyName: "fluid", publicName: "fluid", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "APPLY_HOST_CLASSES ? classes() : null" } }, ngImport: i0 });
|
|
137
|
+
}
|
|
138
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ButtonBase, decorators: [{
|
|
139
|
+
type: Directive,
|
|
140
|
+
args: [{
|
|
141
|
+
host: {
|
|
142
|
+
'[class]': 'APPLY_HOST_CLASSES ? classes() : null',
|
|
143
|
+
},
|
|
144
|
+
}]
|
|
145
|
+
}], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], appearance: [{ type: i0.Input, args: [{ isSignal: true, alias: "appearance", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], fluid: [{ type: i0.Input, args: [{ isSignal: true, alias: "fluid", required: false }] }] } });
|
|
146
|
+
|
|
147
|
+
class Button extends ButtonBase {
|
|
148
|
+
// Injections
|
|
149
|
+
_routerLink = inject(RouterLink, { optional: true });
|
|
150
|
+
APPLY_HOST_CLASSES = false;
|
|
151
|
+
// Inputs
|
|
152
|
+
/** The text label displayed inside the button. Takes priority over projected content. */
|
|
153
|
+
label = input(...(ngDevMode ? [undefined, { debugName: "label" }] : []));
|
|
154
|
+
type = input(this._config.type, ...(ngDevMode ? [{ debugName: "type" }] : []));
|
|
155
|
+
/**
|
|
156
|
+
* Icon to display on the button. Accepts:
|
|
157
|
+
* - A string icon name to render a specific icon.
|
|
158
|
+
* - An empty string or boolean `true` to render an icon-only button (using a projected icon).
|
|
159
|
+
* - `false` to render no icon.
|
|
160
|
+
*/
|
|
161
|
+
icon = input(false, { ...(ngDevMode ? { debugName: "icon" } : {}), transform: (value) => {
|
|
162
|
+
if (typeof value === 'string' && value === '')
|
|
163
|
+
return true;
|
|
164
|
+
else if (typeof value === 'string')
|
|
165
|
+
return value;
|
|
166
|
+
else
|
|
167
|
+
return booleanAttribute(value);
|
|
168
|
+
} });
|
|
169
|
+
/** An optional URL that causes the button to render as an anchor link. */
|
|
170
|
+
href = input(null, ...(ngDevMode ? [{ debugName: "href" }] : []));
|
|
171
|
+
tabindex = input('0', ...(ngDevMode ? [{ debugName: "tabindex" }] : []));
|
|
172
|
+
// Computed
|
|
173
|
+
isLink = computed(() => Boolean(this._routerLink || this.href()), ...(ngDevMode ? [{ debugName: "isLink" }] : []));
|
|
174
|
+
isIconString = computed(() => typeof this.icon() === 'string', ...(ngDevMode ? [{ debugName: "isIconString" }] : []));
|
|
146
175
|
String = String;
|
|
147
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Button, deps:
|
|
148
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: Button, isStandalone: true, selector: "tls-button", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null },
|
|
176
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Button, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
177
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: Button, isStandalone: true, selector: "tls-button", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, href: { classPropertyName: "href", publicName: "href", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "tabindex": "-1" } }, usesInheritance: true, ngImport: i0, template: "@if (isLink()) {\n <a\n role=\"link\"\n [class]=\"classes()\"\n [attr.href]=\"href()\"\n [tabindex]=\"tabindex()\"\n [attr.aria-disabled]=\"disabled()\"\n >\n <ng-container [ngTemplateOutlet]=\"contentTemplate\"></ng-container>\n </a>\n} @else {\n <button\n role=\"button\"\n [class]=\"classes()\"\n [type]=\"type()\"\n [tabindex]=\"tabindex()\"\n [disabled]=\"disabled()\"\n [attr.aria-disabled]=\"disabled()\"\n >\n <ng-container [ngTemplateOutlet]=\"contentTemplate\"></ng-container>\n </button>\n}\n\n<!-- Content -->\n<ng-template #contentTemplate>\n @if (icon()) {\n @if (isIconString()) {\n <tls-icon [iconSrc]=\"String(icon())\" />\n } @else {\n <ng-container *ngTemplateOutlet=\"projectedContentTemplate\"></ng-container>\n }\n } @else {\n @if (label()) {\n {{ label() }}\n } @else {\n <ng-container *ngTemplateOutlet=\"projectedContentTemplate\"></ng-container>\n }\n }\n</ng-template>\n\n<ng-template #projectedContentTemplate>\n <ng-content></ng-content>\n</ng-template>\n", styles: [":host{width:fit-content;display:inline-block}:host:focus-visible{outline:none}:host:has(.tls-button.tls-button--fluid){width:100%}\n"], dependencies: [{ kind: "component", type: Icon, selector: "tls-icon", inputs: ["iconSrc", "alt", "allowedSources"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
149
178
|
}
|
|
150
179
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Button, decorators: [{
|
|
151
180
|
type: Component,
|
|
152
181
|
args: [{ selector: 'tls-button', imports: [Icon, NgTemplateOutlet], host: {
|
|
153
182
|
'[tabindex]': '-1',
|
|
154
|
-
}, template: "@if (isLink()) {\n <a\n role=\"link\"\n [class]=\"classes()\"\n [href]=\"href()\"\n [tabindex]=\"tabindex()\"\n [attr.aria-disabled]=\"disabled()\"\n >\n <ng-container [ngTemplateOutlet]=\"contentTemplate\"></ng-container>\n </a>\n} @else {\n <button\n role=\"button\"\n [class]=\"classes()\"\n [type]=\"type()\"\n [tabindex]=\"tabindex()\"\n [disabled]=\"disabled()\"\n [attr.aria-disabled]=\"disabled()\"\n >\n <ng-container [ngTemplateOutlet]=\"contentTemplate\"></ng-container>\n </button>\n}\n\n<!-- Content -->\n<ng-template #contentTemplate>\n
|
|
155
|
-
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }],
|
|
183
|
+
}, template: "@if (isLink()) {\n <a\n role=\"link\"\n [class]=\"classes()\"\n [attr.href]=\"href()\"\n [tabindex]=\"tabindex()\"\n [attr.aria-disabled]=\"disabled()\"\n >\n <ng-container [ngTemplateOutlet]=\"contentTemplate\"></ng-container>\n </a>\n} @else {\n <button\n role=\"button\"\n [class]=\"classes()\"\n [type]=\"type()\"\n [tabindex]=\"tabindex()\"\n [disabled]=\"disabled()\"\n [attr.aria-disabled]=\"disabled()\"\n >\n <ng-container [ngTemplateOutlet]=\"contentTemplate\"></ng-container>\n </button>\n}\n\n<!-- Content -->\n<ng-template #contentTemplate>\n @if (icon()) {\n @if (isIconString()) {\n <tls-icon [iconSrc]=\"String(icon())\" />\n } @else {\n <ng-container *ngTemplateOutlet=\"projectedContentTemplate\"></ng-container>\n }\n } @else {\n @if (label()) {\n {{ label() }}\n } @else {\n <ng-container *ngTemplateOutlet=\"projectedContentTemplate\"></ng-container>\n }\n }\n</ng-template>\n\n<ng-template #projectedContentTemplate>\n <ng-content></ng-content>\n</ng-template>\n", styles: [":host{width:fit-content;display:inline-block}:host:focus-visible{outline:none}:host:has(.tls-button.tls-button--fluid){width:100%}\n"] }]
|
|
184
|
+
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], href: [{ type: i0.Input, args: [{ isSignal: true, alias: "href", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }] } });
|
|
185
|
+
|
|
186
|
+
class ButtonDirective extends ButtonBase {
|
|
187
|
+
/**
|
|
188
|
+
* Whether the button is in icon-only mode (uses a projected icon).
|
|
189
|
+
* - `true` to render an icon-only button.
|
|
190
|
+
* - `false` (default) to render a standard button with no icon-only styling.
|
|
191
|
+
*/
|
|
192
|
+
icon = input(false, { ...(ngDevMode ? { debugName: "icon" } : {}), transform: booleanAttribute });
|
|
193
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ButtonDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
194
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.1", type: ButtonDirective, isStandalone: true, selector: "[tlsButton]", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i0 });
|
|
195
|
+
}
|
|
196
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ButtonDirective, decorators: [{
|
|
197
|
+
type: Directive,
|
|
198
|
+
args: [{
|
|
199
|
+
selector: '[tlsButton]',
|
|
200
|
+
}]
|
|
201
|
+
}], propDecorators: { icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }] } });
|
|
202
|
+
|
|
203
|
+
const DEFAULT_DIVIDER_CONFIG = {
|
|
204
|
+
orientation: 'horizontal',
|
|
205
|
+
position: 'center',
|
|
206
|
+
variant: 'solid',
|
|
207
|
+
flush: false,
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const DIVIDER_CONFIG = new InjectionToken('DIVIDER_CONFIG', {
|
|
211
|
+
factory: () => DEFAULT_DIVIDER_CONFIG,
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
class Divider {
|
|
215
|
+
_config = inject(DIVIDER_CONFIG);
|
|
216
|
+
orientation = input(this._config.orientation, ...(ngDevMode ? [{ debugName: "orientation" }] : []));
|
|
217
|
+
position = input(this._config.position, ...(ngDevMode ? [{ debugName: "position" }] : []));
|
|
218
|
+
variant = input(this._config.variant, ...(ngDevMode ? [{ debugName: "variant" }] : []));
|
|
219
|
+
flush = input(this._config.flush, { ...(ngDevMode ? { debugName: "flush" } : {}), transform: booleanAttribute });
|
|
220
|
+
hostClasses = computed(() => {
|
|
221
|
+
const className = 'tls-divider';
|
|
222
|
+
const array = [className];
|
|
223
|
+
array.push(`${className}--${this.orientation()}`);
|
|
224
|
+
array.push(`${className}--${this.position()}`);
|
|
225
|
+
array.push(`${className}--${this.variant()}`);
|
|
226
|
+
if (this.flush())
|
|
227
|
+
array.push(`${className}--flush`);
|
|
228
|
+
return array;
|
|
229
|
+
}, ...(ngDevMode ? [{ debugName: "hostClasses" }] : []));
|
|
230
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Divider, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
231
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.1", type: Divider, isStandalone: true, selector: "tls-divider", inputs: { orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, flush: { classPropertyName: "flush", publicName: "flush", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "separator" }, properties: { "aria-orientation": "orientation()", "class": "hostClasses()" } }, ngImport: i0, template: "<span class=\"tls-divider-line tls-divider-line--start\"></span>\n<div class=\"tls-divider-content\">\n <ng-content></ng-content>\n</div>\n<span class=\"tls-divider-line tls-divider-line--end\"></span>\n", styles: [":host.tls-divider{--tls-divider-line-color: var(--color-outline-variant);--tls-divider-line-size: 1px;--tls-divider-content-gap: var(--spacing-3);--tls-divider-inset: 5%;display:flex;align-items:center;justify-content:center;gap:var(--tls-divider-content-gap)}:host.tls-divider .tls-divider-content{min-width:fit-content}:host.tls-divider:has(.tls-divider-content:empty) .tls-divider-content{display:none}:host.tls-divider:has(.tls-divider-content:empty) .tls-divider-line.tls-divider-line--start{display:none}:host.tls-divider.tls-divider--horizontal .tls-divider-line{border-right-width:0;border-bottom-width:var(--tls-divider-line-size)}:host.tls-divider.tls-divider--vertical{flex-direction:column}:host.tls-divider.tls-divider--vertical .tls-divider-line{border-right-width:var(--tls-divider-line-size);border-bottom-width:0}:host.tls-divider.tls-divider--start .tls-divider-line.tls-divider-line--start{flex-basis:var(--tls-divider-inset)}:host.tls-divider.tls-divider--start.tls-divider--flush .tls-divider-line.tls-divider-line--start{display:none}:host.tls-divider.tls-divider--end .tls-divider-line.tls-divider-line--end{flex-basis:var(--tls-divider-inset)}:host.tls-divider.tls-divider--end.tls-divider--flush .tls-divider-line.tls-divider-line--end{display:none}:host.tls-divider.tls-divider--dashed{--tls-divider-line-variant: dashed}:host.tls-divider.tls-divider--dotted{--tls-divider-line-variant: dotted}:host.tls-divider.tls-divider--solid{--tls-divider-line-variant: solid}:host.tls-divider .tls-divider-line{flex-basis:100%;flex-grow:1;border-top-width:0;border-left-width:0;border-style:var(--tls-divider-line-variant);border-color:var(--tls-divider-line-color)}\n"] });
|
|
232
|
+
}
|
|
233
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Divider, decorators: [{
|
|
234
|
+
type: Component,
|
|
235
|
+
args: [{ selector: 'tls-divider', imports: [], host: {
|
|
236
|
+
role: 'separator',
|
|
237
|
+
'[aria-orientation]': 'orientation()',
|
|
238
|
+
'[class]': 'hostClasses()',
|
|
239
|
+
}, template: "<span class=\"tls-divider-line tls-divider-line--start\"></span>\n<div class=\"tls-divider-content\">\n <ng-content></ng-content>\n</div>\n<span class=\"tls-divider-line tls-divider-line--end\"></span>\n", styles: [":host.tls-divider{--tls-divider-line-color: var(--color-outline-variant);--tls-divider-line-size: 1px;--tls-divider-content-gap: var(--spacing-3);--tls-divider-inset: 5%;display:flex;align-items:center;justify-content:center;gap:var(--tls-divider-content-gap)}:host.tls-divider .tls-divider-content{min-width:fit-content}:host.tls-divider:has(.tls-divider-content:empty) .tls-divider-content{display:none}:host.tls-divider:has(.tls-divider-content:empty) .tls-divider-line.tls-divider-line--start{display:none}:host.tls-divider.tls-divider--horizontal .tls-divider-line{border-right-width:0;border-bottom-width:var(--tls-divider-line-size)}:host.tls-divider.tls-divider--vertical{flex-direction:column}:host.tls-divider.tls-divider--vertical .tls-divider-line{border-right-width:var(--tls-divider-line-size);border-bottom-width:0}:host.tls-divider.tls-divider--start .tls-divider-line.tls-divider-line--start{flex-basis:var(--tls-divider-inset)}:host.tls-divider.tls-divider--start.tls-divider--flush .tls-divider-line.tls-divider-line--start{display:none}:host.tls-divider.tls-divider--end .tls-divider-line.tls-divider-line--end{flex-basis:var(--tls-divider-inset)}:host.tls-divider.tls-divider--end.tls-divider--flush .tls-divider-line.tls-divider-line--end{display:none}:host.tls-divider.tls-divider--dashed{--tls-divider-line-variant: dashed}:host.tls-divider.tls-divider--dotted{--tls-divider-line-variant: dotted}:host.tls-divider.tls-divider--solid{--tls-divider-line-variant: solid}:host.tls-divider .tls-divider-line{flex-basis:100%;flex-grow:1;border-top-width:0;border-left-width:0;border-style:var(--tls-divider-line-variant);border-color:var(--tls-divider-line-color)}\n"] }]
|
|
240
|
+
}], propDecorators: { orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], flush: [{ type: i0.Input, args: [{ isSignal: true, alias: "flush", required: false }] }] } });
|
|
156
241
|
|
|
157
242
|
const DEFAULT_FORM_ITEM_ERROR_MESSAGES = {
|
|
158
243
|
required: () => 'This field is required',
|
|
@@ -351,6 +436,7 @@ const DEFAULT_INPUT_CONFIG = {
|
|
|
351
436
|
size: 'md',
|
|
352
437
|
type: 'text',
|
|
353
438
|
placeholder: '',
|
|
439
|
+
fluid: false,
|
|
354
440
|
};
|
|
355
441
|
|
|
356
442
|
const INPUT_CONFIG = new InjectionToken('INPUT_CONFIG', {
|
|
@@ -366,10 +452,13 @@ class Input extends ValueFormControl {
|
|
|
366
452
|
inputId = input(null, ...(ngDevMode ? [{ debugName: "inputId" }] : []));
|
|
367
453
|
placeholder = input(this._config.placeholder, ...(ngDevMode ? [{ debugName: "placeholder" }] : []));
|
|
368
454
|
size = input(this._config.size, ...(ngDevMode ? [{ debugName: "size" }] : []));
|
|
455
|
+
fluid = input(this._config.fluid, { ...(ngDevMode ? { debugName: "fluid" } : {}), transform: booleanAttribute });
|
|
369
456
|
classes = computed(() => {
|
|
370
457
|
const className = 'tls-form-control';
|
|
371
458
|
const array = [className];
|
|
372
459
|
array.push(`${className}--${this.size()}`);
|
|
460
|
+
if (this.fluid())
|
|
461
|
+
array.push(`${className}--fluid`);
|
|
373
462
|
return array.concat(this.controlClasses());
|
|
374
463
|
}, ...(ngDevMode ? [{ debugName: "classes" }] : []));
|
|
375
464
|
// Protected methods
|
|
@@ -378,23 +467,28 @@ class Input extends ValueFormControl {
|
|
|
378
467
|
this.value.set(target.value);
|
|
379
468
|
}
|
|
380
469
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Input, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
381
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.1", type: Input, isStandalone: true, selector: "tls-input", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => Input) }], usesInheritance: true, ngImport: i0, template: "<input\n [type]=\"type()\"\n [name]=\"name()\"\n [class]=\"classes()\"\n [attr.id]=\"inputId()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [value]=\"value()\"\n (input)=\"onInput($event)\"\n (blur)=\"touched.set(true)\"\n/>\n", styles: [":host{display:inline-block}\n"] });
|
|
470
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.1", type: Input, isStandalone: true, selector: "tls-input", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, fluid: { classPropertyName: "fluid", publicName: "fluid", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => Input) }], usesInheritance: true, ngImport: i0, template: "<input\n [type]=\"type()\"\n [name]=\"name()\"\n [class]=\"classes()\"\n [attr.id]=\"inputId()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [value]=\"value()\"\n (input)=\"onInput($event)\"\n (blur)=\"touched.set(true)\"\n/>\n", styles: [":host{width:auto;display:inline-block}:host:has(.tls-form-control.tls-form-control--fluid){width:100%}\n"] });
|
|
382
471
|
}
|
|
383
472
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Input, decorators: [{
|
|
384
473
|
type: Component,
|
|
385
|
-
args: [{ selector: 'tls-input', providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => Input) }], template: "<input\n [type]=\"type()\"\n [name]=\"name()\"\n [class]=\"classes()\"\n [attr.id]=\"inputId()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [value]=\"value()\"\n (input)=\"onInput($event)\"\n (blur)=\"touched.set(true)\"\n/>\n", styles: [":host{display:inline-block}\n"] }]
|
|
386
|
-
}], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }] } });
|
|
474
|
+
args: [{ selector: 'tls-input', providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => Input) }], template: "<input\n [type]=\"type()\"\n [name]=\"name()\"\n [class]=\"classes()\"\n [attr.id]=\"inputId()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [value]=\"value()\"\n (input)=\"onInput($event)\"\n (blur)=\"touched.set(true)\"\n/>\n", styles: [":host{width:auto;display:inline-block}:host:has(.tls-form-control.tls-form-control--fluid){width:100%}\n"] }]
|
|
475
|
+
}], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], fluid: [{ type: i0.Input, args: [{ isSignal: true, alias: "fluid", required: false }] }] } });
|
|
387
476
|
|
|
388
477
|
class InputDirective {
|
|
389
|
-
|
|
478
|
+
// Injections
|
|
479
|
+
_config = inject(INPUT_CONFIG);
|
|
480
|
+
size = input(this._config.size, ...(ngDevMode ? [{ debugName: "size" }] : []));
|
|
481
|
+
fluid = input(this._config.fluid, { ...(ngDevMode ? { debugName: "fluid" } : {}), transform: booleanAttribute });
|
|
390
482
|
classes = computed(() => {
|
|
391
483
|
const className = 'tls-form-control';
|
|
392
484
|
const array = [className];
|
|
393
485
|
array.push(`${className}--${this.size()}`);
|
|
486
|
+
if (this.fluid())
|
|
487
|
+
array.push(`${className}--fluid`);
|
|
394
488
|
return array;
|
|
395
489
|
}, ...(ngDevMode ? [{ debugName: "classes" }] : []));
|
|
396
490
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: InputDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
397
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.1", type: InputDirective, isStandalone: true, selector: "[tlsInput]", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()" } }, ngImport: i0 });
|
|
491
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.1", type: InputDirective, isStandalone: true, selector: "[tlsInput]", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, fluid: { classPropertyName: "fluid", publicName: "fluid", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()" } }, ngImport: i0 });
|
|
398
492
|
}
|
|
399
493
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: InputDirective, decorators: [{
|
|
400
494
|
type: Directive,
|
|
@@ -404,11 +498,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
404
498
|
'[class]': 'classes()',
|
|
405
499
|
},
|
|
406
500
|
}]
|
|
407
|
-
}], propDecorators: { size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }] } });
|
|
501
|
+
}], propDecorators: { size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], fluid: [{ type: i0.Input, args: [{ isSignal: true, alias: "fluid", required: false }] }] } });
|
|
408
502
|
|
|
409
503
|
const DEFAULT_PASSWORD_CONFIG = {
|
|
410
504
|
size: 'md',
|
|
411
505
|
placeholder: '',
|
|
506
|
+
fluid: false,
|
|
412
507
|
};
|
|
413
508
|
|
|
414
509
|
const PASSWORD_CONFIG = new InjectionToken('PASSWORD_CONFIG', {
|
|
@@ -422,10 +517,13 @@ class Password extends ValueFormControl {
|
|
|
422
517
|
inputId = input(null, ...(ngDevMode ? [{ debugName: "inputId" }] : []));
|
|
423
518
|
placeholder = input(this._config.placeholder, ...(ngDevMode ? [{ debugName: "placeholder" }] : []));
|
|
424
519
|
size = input(this._config.size, ...(ngDevMode ? [{ debugName: "size" }] : []));
|
|
520
|
+
fluid = input(this._config.fluid, { ...(ngDevMode ? { debugName: "fluid" } : {}), transform: booleanAttribute });
|
|
425
521
|
classes = computed(() => {
|
|
426
522
|
const className = 'tls-form-control-group';
|
|
427
523
|
const array = [className];
|
|
428
524
|
array.push(`${className}--${this.size()}`);
|
|
525
|
+
if (this.fluid())
|
|
526
|
+
array.push(`${className}--fluid`);
|
|
429
527
|
return array;
|
|
430
528
|
}, ...(ngDevMode ? [{ debugName: "classes" }] : []));
|
|
431
529
|
type = computed(() => (this.visible() ? 'text' : 'password'), ...(ngDevMode ? [{ debugName: "type" }] : []));
|
|
@@ -440,14 +538,14 @@ class Password extends ValueFormControl {
|
|
|
440
538
|
this.visible.update(prev => !prev);
|
|
441
539
|
}
|
|
442
540
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Password, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
443
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.1", type: Password, isStandalone: true, selector: "tls-password", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", visible: "visibleChange" }, host: { properties: { "class": "classes()" } }, providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => Password) }], usesInheritance: true, ngImport: i0, template: "<input\n [type]=\"type()\"\n [name]=\"name()\"\n [class]=\"controlClasses()\"\n [attr.id]=\"inputId()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [value]=\"value()\"\n (input)=\"onInput($event)\"\n (blur)=\"touched.set(true)\"\n/>\n<button class=\"tls-password-toggle tls-form-control-addon\" (click)=\"toggle()\">\n <span class=\"tls-password-toggle__item\" [class.tls-password-toggle__item--hidden]=\"visible()\">\n <span class=\"text-label-md\">Show</span>\n </span>\n <span class=\"tls-password-toggle__item\" [class.tls-password-toggle__item--hidden]=\"!visible()\">\n <span class=\"text-label-md\">Hide</span>\n </span>\n</button>\n", styles: [":host{display:inline-flex}:host .tls-password-toggle{display:grid;align-items:center}:host .tls-password-toggle:focus-visible{outline:var(--control-focus-ring-width) solid var(--control-focus-ring-color);outline-offset:var(--control-focus-ring-offset);border-radius:var(--radius-md)}:host .tls-password-toggle__item{grid-area:1/1;text-align:center}:host .tls-password-toggle__item--hidden{visibility:hidden}\n"] });
|
|
541
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.1", type: Password, isStandalone: true, selector: "tls-password", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, fluid: { classPropertyName: "fluid", publicName: "fluid", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", visible: "visibleChange" }, host: { properties: { "class": "classes()" } }, providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => Password) }], usesInheritance: true, ngImport: i0, template: "<input\n [type]=\"type()\"\n [name]=\"name()\"\n [class]=\"controlClasses()\"\n [attr.id]=\"inputId()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [value]=\"value()\"\n (input)=\"onInput($event)\"\n (blur)=\"touched.set(true)\"\n/>\n<button class=\"tls-password-toggle tls-form-control-addon\" (click)=\"toggle()\">\n <span class=\"tls-password-toggle__item\" [class.tls-password-toggle__item--hidden]=\"visible()\">\n <span class=\"text-label-md\">Show</span>\n </span>\n <span class=\"tls-password-toggle__item\" [class.tls-password-toggle__item--hidden]=\"!visible()\">\n <span class=\"text-label-md\">Hide</span>\n </span>\n</button>\n", styles: [":host{display:inline-flex}:host .tls-password-toggle{display:grid;align-items:center}:host .tls-password-toggle:focus-visible{outline:var(--control-focus-ring-width) solid var(--control-focus-ring-color);outline-offset:var(--control-focus-ring-offset);border-radius:var(--radius-md)}:host .tls-password-toggle__item{grid-area:1/1;text-align:center}:host .tls-password-toggle__item--hidden{visibility:hidden}\n"] });
|
|
444
542
|
}
|
|
445
543
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Password, decorators: [{
|
|
446
544
|
type: Component,
|
|
447
545
|
args: [{ selector: 'tls-password', host: {
|
|
448
546
|
'[class]': 'classes()',
|
|
449
547
|
}, providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => Password) }], template: "<input\n [type]=\"type()\"\n [name]=\"name()\"\n [class]=\"controlClasses()\"\n [attr.id]=\"inputId()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [value]=\"value()\"\n (input)=\"onInput($event)\"\n (blur)=\"touched.set(true)\"\n/>\n<button class=\"tls-password-toggle tls-form-control-addon\" (click)=\"toggle()\">\n <span class=\"tls-password-toggle__item\" [class.tls-password-toggle__item--hidden]=\"visible()\">\n <span class=\"text-label-md\">Show</span>\n </span>\n <span class=\"tls-password-toggle__item\" [class.tls-password-toggle__item--hidden]=\"!visible()\">\n <span class=\"text-label-md\">Hide</span>\n </span>\n</button>\n", styles: [":host{display:inline-flex}:host .tls-password-toggle{display:grid;align-items:center}:host .tls-password-toggle:focus-visible{outline:var(--control-focus-ring-width) solid var(--control-focus-ring-color);outline-offset:var(--control-focus-ring-offset);border-radius:var(--radius-md)}:host .tls-password-toggle__item{grid-area:1/1;text-align:center}:host .tls-password-toggle__item--hidden{visibility:hidden}\n"] }]
|
|
450
|
-
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }, { type: i0.Output, args: ["visibleChange"] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }] } });
|
|
548
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }, { type: i0.Output, args: ["visibleChange"] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], fluid: [{ type: i0.Input, args: [{ isSignal: true, alias: "fluid", required: false }] }] } });
|
|
451
549
|
|
|
452
550
|
const DEFAULT_RADIO_BUTTON_CONFIG = {};
|
|
453
551
|
|
|
@@ -542,13 +640,16 @@ const DARK_THEME_CLASS = 'tls-dark';
|
|
|
542
640
|
|
|
543
641
|
const DEFAULT_THEME_CONFIG = {
|
|
544
642
|
defaultTheme: 'system',
|
|
545
|
-
localStorageKey: 'tls-theme',
|
|
643
|
+
localStorageKey: 'tls-theme-preference',
|
|
546
644
|
};
|
|
547
645
|
|
|
548
646
|
const THEME_CONFIG = new InjectionToken('THEME_CONFIG', {
|
|
549
647
|
factory: () => DEFAULT_THEME_CONFIG,
|
|
550
648
|
});
|
|
551
649
|
|
|
650
|
+
/**
|
|
651
|
+
* Service responsible for managing the application's theme (light/dark/system).
|
|
652
|
+
*/
|
|
552
653
|
class ThemeService {
|
|
553
654
|
// Injections
|
|
554
655
|
_config = inject(THEME_CONFIG);
|
|
@@ -560,62 +661,94 @@ class ThemeService {
|
|
|
560
661
|
LS_THEME = this._config.localStorageKey;
|
|
561
662
|
// Private
|
|
562
663
|
_currentTheme = signal('light', ...(ngDevMode ? [{ debugName: "_currentTheme" }] : []));
|
|
664
|
+
_currentThemePreference = signal('light', ...(ngDevMode ? [{ debugName: "_currentThemePreference" }] : []));
|
|
563
665
|
constructor() {
|
|
564
666
|
this._initTheme();
|
|
565
667
|
effect(() => {
|
|
566
668
|
if (this._isBrowser)
|
|
567
|
-
localStorage.setItem(this.LS_THEME, this.
|
|
669
|
+
localStorage.setItem(this.LS_THEME, this._currentThemePreference());
|
|
568
670
|
});
|
|
569
671
|
}
|
|
570
672
|
// Accessors
|
|
673
|
+
/**
|
|
674
|
+
* A readonly signal of the currently applied theme (`'light'` or `'dark'`).
|
|
675
|
+
* Reflects the resolved theme even when the preference is `'system'`.
|
|
676
|
+
*/
|
|
571
677
|
get currentTheme() {
|
|
572
678
|
return this._currentTheme.asReadonly();
|
|
573
679
|
}
|
|
680
|
+
/**
|
|
681
|
+
* A readonly signal of the user's selected theme preference (`'light'`, `'dark'`, or `'system'`).
|
|
682
|
+
*/
|
|
683
|
+
get currentThemePreference() {
|
|
684
|
+
return this._currentThemePreference.asReadonly();
|
|
685
|
+
}
|
|
574
686
|
// Public methods
|
|
687
|
+
/**
|
|
688
|
+
* Toggles between `'light'` and `'dark'` themes based on the currently applied theme.
|
|
689
|
+
* Does not toggle to `'system'`.
|
|
690
|
+
*/
|
|
575
691
|
toggle() {
|
|
576
692
|
this.setTheme(this._currentTheme() === 'light' ? 'dark' : 'light');
|
|
577
693
|
}
|
|
578
|
-
|
|
694
|
+
/**
|
|
695
|
+
* Sets the theme preference and applies the corresponding theme to the document.
|
|
696
|
+
* When `'system'` is passed, the theme is resolved from the OS color scheme preference.
|
|
697
|
+
*
|
|
698
|
+
* @param preference - The desired theme preference: `'light'`, `'dark'`, or `'system'`.
|
|
699
|
+
*/
|
|
700
|
+
setTheme(preference) {
|
|
701
|
+
this._currentThemePreference.set(preference);
|
|
702
|
+
if (preference === 'system') {
|
|
703
|
+
this._applyTheme(this._detectSystemTheme());
|
|
704
|
+
}
|
|
705
|
+
else {
|
|
706
|
+
this._applyTheme(preference);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
// Private methods
|
|
710
|
+
/**
|
|
711
|
+
* Applies the given theme to the document root element by toggling theme CSS classes.
|
|
712
|
+
*
|
|
713
|
+
* @param theme - The theme to apply: `'light'` or `'dark'`.
|
|
714
|
+
*/
|
|
715
|
+
_applyTheme(theme) {
|
|
579
716
|
const documentElement = this._document.documentElement;
|
|
580
|
-
const lightThemeClass = LIGHT_THEME_CLASS;
|
|
581
|
-
const darkThemeClass = DARK_THEME_CLASS;
|
|
582
717
|
if (theme === 'dark') {
|
|
583
|
-
this._renderer.removeClass(documentElement,
|
|
584
|
-
this._renderer.addClass(documentElement,
|
|
718
|
+
this._renderer.removeClass(documentElement, LIGHT_THEME_CLASS);
|
|
719
|
+
this._renderer.addClass(documentElement, DARK_THEME_CLASS);
|
|
585
720
|
this._currentTheme.set('dark');
|
|
586
721
|
}
|
|
587
722
|
else {
|
|
588
|
-
this._renderer.removeClass(documentElement,
|
|
589
|
-
this._renderer.addClass(documentElement,
|
|
723
|
+
this._renderer.removeClass(documentElement, DARK_THEME_CLASS);
|
|
724
|
+
this._renderer.addClass(documentElement, LIGHT_THEME_CLASS);
|
|
590
725
|
this._currentTheme.set('light');
|
|
591
726
|
}
|
|
592
727
|
}
|
|
593
|
-
|
|
728
|
+
/**
|
|
729
|
+
* Detects the OS-level color scheme preference using the `prefers-color-scheme` media query.
|
|
730
|
+
*
|
|
731
|
+
* @returns `'dark'` if the OS prefers dark mode, otherwise `'light'`.
|
|
732
|
+
*/
|
|
594
733
|
_detectSystemTheme() {
|
|
595
734
|
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
596
735
|
}
|
|
736
|
+
/**
|
|
737
|
+
* Initializes the theme on app startup (browser only).
|
|
738
|
+
* Reads the stored preference from localStorage, falling back to the configured default.
|
|
739
|
+
* Also registers a listener for OS color scheme changes to reactively update the theme
|
|
740
|
+
* when the preference is `'system'`.
|
|
741
|
+
*/
|
|
597
742
|
_initTheme() {
|
|
598
743
|
if (!this._isBrowser)
|
|
599
744
|
return;
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
_initDefaultTheme() {
|
|
608
|
-
if (this._config.defaultTheme === 'system') {
|
|
609
|
-
this.setTheme(this._detectSystemTheme());
|
|
610
|
-
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
|
611
|
-
if (!localStorage.getItem(this.LS_THEME)) {
|
|
612
|
-
this.setTheme(event.matches ? 'dark' : 'light');
|
|
613
|
-
}
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
else {
|
|
617
|
-
this.setTheme(this._config.defaultTheme);
|
|
618
|
-
}
|
|
745
|
+
const stored = localStorage.getItem(this.LS_THEME);
|
|
746
|
+
this.setTheme(stored ?? this._config.defaultTheme);
|
|
747
|
+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
|
748
|
+
if (this._currentThemePreference() === 'system') {
|
|
749
|
+
this._applyTheme(event.matches ? 'dark' : 'light');
|
|
750
|
+
}
|
|
751
|
+
});
|
|
619
752
|
}
|
|
620
753
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
621
754
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ThemeService });
|
|
@@ -649,6 +782,10 @@ const provideThalassicUIConfig = (config) => {
|
|
|
649
782
|
provide: BUTTON_CONFIG,
|
|
650
783
|
useValue: mergeConfig(DEFAULT_BUTTON_CONFIG, config.components.button),
|
|
651
784
|
},
|
|
785
|
+
{
|
|
786
|
+
provide: DIVIDER_CONFIG,
|
|
787
|
+
useValue: mergeConfig(DEFAULT_DIVIDER_CONFIG, config.components.divider),
|
|
788
|
+
},
|
|
652
789
|
{ provide: INPUT_CONFIG, useValue: mergeConfig(DEFAULT_INPUT_CONFIG, config.components.input) },
|
|
653
790
|
{
|
|
654
791
|
provide: PASSWORD_CONFIG,
|
|
@@ -670,6 +807,7 @@ const provideTheme = (config) => {
|
|
|
670
807
|
return makeEnvironmentProviders([
|
|
671
808
|
{ provide: THEME_CONFIG, useValue: { ...DEFAULT_THEME_CONFIG, ...config } },
|
|
672
809
|
ThemeService,
|
|
810
|
+
provideEnvironmentInitializer(() => inject(ThemeService)),
|
|
673
811
|
]);
|
|
674
812
|
};
|
|
675
813
|
|
|
@@ -677,5 +815,5 @@ const provideTheme = (config) => {
|
|
|
677
815
|
* Generated bundle index. Do not edit.
|
|
678
816
|
*/
|
|
679
817
|
|
|
680
|
-
export { BUTTON_CONFIG, Button, CHECKBOX_CONFIG, Checkbox, DEFAULT_BUTTON_CONFIG, DEFAULT_CHECKBOX_CONFIG, DEFAULT_FORM_ITEM_CONFIG, DEFAULT_ICON_CONFIG, DEFAULT_INPUT_CONFIG, DEFAULT_PASSWORD_CONFIG, DEFAULT_RADIO_BUTTON_CONFIG, DEFAULT_SWITCH_CONFIG, FORM_ITEM_CONFIG, FormItem, ICON_CONFIG, INPUT_CONFIG, Icon, Input, InputDirective, PASSWORD_CONFIG, Password, RADIO_BUTTON_CONFIG, RadioButton, SWITCH_CONFIG, Switch, ThemeService, provideThalassicUIConfig, provideTheme };
|
|
818
|
+
export { BUTTON_CONFIG, Button, ButtonDirective, CHECKBOX_CONFIG, Checkbox, DEFAULT_BUTTON_CONFIG, DEFAULT_CHECKBOX_CONFIG, DEFAULT_DIVIDER_CONFIG, DEFAULT_FORM_ITEM_CONFIG, DEFAULT_ICON_CONFIG, DEFAULT_INPUT_CONFIG, DEFAULT_PASSWORD_CONFIG, DEFAULT_RADIO_BUTTON_CONFIG, DEFAULT_SWITCH_CONFIG, DIVIDER_CONFIG, Divider, FORM_ITEM_CONFIG, FormItem, ICON_CONFIG, INPUT_CONFIG, Icon, Input, InputDirective, PASSWORD_CONFIG, Password, RADIO_BUTTON_CONFIG, RadioButton, SWITCH_CONFIG, Switch, ThemeService, provideThalassicUIConfig, provideTheme };
|
|
681
819
|
//# sourceMappingURL=thalassic-ui.mjs.map
|