ngx-strata 0.4.3-beta.2 → 0.4.4
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/assets/styles/components/input-field.scss +84 -5
- package/assets/styles/components/item.scss +13 -2
- package/assets/styles/components/modal.scss +5 -3
- package/dist/strata/strata.css +1 -1
- package/fesm2022/ngx-strata.mjs +100 -8
- package/fesm2022/ngx-strata.mjs.map +1 -1
- package/package.json +1 -1
- package/skills/ngx-strata/components/input-field.md +9 -2
- package/types/ngx-strata.d.ts +18 -4
package/fesm2022/ngx-strata.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, Injectable, provideAppInitializer, makeEnvironmentProviders, DOCUMENT, signal, computed, effect, InjectionToken, provideEnvironmentInitializer, ElementRef, input, model, output, Directive, Renderer2, DestroyRef, Pipe, HostBinding, Component, contentChildren, forwardRef, contentChild, HostListener, ViewContainerRef, viewChild, Injector, LOCALE_ID, viewChildren,
|
|
2
|
+
import { inject, Injectable, provideAppInitializer, makeEnvironmentProviders, DOCUMENT, signal, computed, effect, InjectionToken, provideEnvironmentInitializer, ElementRef, input, model, output, Directive, Renderer2, DestroyRef, Pipe, HostBinding, Component, contentChildren, forwardRef, contentChild, HostListener, ViewContainerRef, viewChild, booleanAttribute, numberAttribute, Injector, LOCALE_ID, viewChildren, ContentChildren, TemplateRef } from '@angular/core';
|
|
3
3
|
import { Observable, tap, map, fromEvent, switchMap, filter } from 'rxjs';
|
|
4
4
|
import { HttpClient } from '@angular/common/http';
|
|
5
5
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
@@ -2060,12 +2060,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImpor
|
|
|
2060
2060
|
}] });
|
|
2061
2061
|
|
|
2062
2062
|
class StrataInputFieldComponent {
|
|
2063
|
+
hostElement = inject((ElementRef));
|
|
2063
2064
|
size = input('md', /* @ts-ignore */
|
|
2064
2065
|
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
2066
|
+
disabled = input(undefined, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: (value) => value === undefined || value === null || value === '' ? undefined : booleanAttribute(value) });
|
|
2067
|
+
maxLength = input(undefined, { ...(ngDevMode ? { debugName: "maxLength" } : /* istanbul ignore next */ {}), transform: (value) => value === undefined || value === null || value === '' ? undefined : numberAttribute(value) });
|
|
2068
|
+
showCharacterCounter = input(false, { ...(ngDevMode ? { debugName: "showCharacterCounter" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2069
|
+
characterCounterFormatter = input(undefined, /* @ts-ignore */
|
|
2070
|
+
...(ngDevMode ? [{ debugName: "characterCounterFormatter" }] : /* istanbul ignore next */ []));
|
|
2065
2071
|
iconComponents = contentChildren(StrataIconComponent, { ...(ngDevMode ? { debugName: "iconComponents" } : /* istanbul ignore next */ {}), descendants: true });
|
|
2066
2072
|
inputField = contentChild(StrataNativeInputRefDirective, { ...(ngDevMode ? { debugName: "inputField" } : /* istanbul ignore next */ {}), descendants: true });
|
|
2067
2073
|
pendingFocus = signal(false, /* @ts-ignore */
|
|
2068
2074
|
...(ngDevMode ? [{ debugName: "pendingFocus" }] : /* istanbul ignore next */ []));
|
|
2075
|
+
currentLength = signal(0, /* @ts-ignore */
|
|
2076
|
+
...(ngDevMode ? [{ debugName: "currentLength" }] : /* istanbul ignore next */ []));
|
|
2077
|
+
nativeMaxLength = signal(undefined, /* @ts-ignore */
|
|
2078
|
+
...(ngDevMode ? [{ debugName: "nativeMaxLength" }] : /* istanbul ignore next */ []));
|
|
2079
|
+
nativeDisabled = signal(false, /* @ts-ignore */
|
|
2080
|
+
...(ngDevMode ? [{ debugName: "nativeDisabled" }] : /* istanbul ignore next */ []));
|
|
2081
|
+
effectiveMaxLength = computed(() => this.maxLength() ?? this.nativeMaxLength(), /* @ts-ignore */
|
|
2082
|
+
...(ngDevMode ? [{ debugName: "effectiveMaxLength" }] : /* istanbul ignore next */ []));
|
|
2083
|
+
effectiveDisabled = computed(() => (this.disabled() ?? false) || this.nativeDisabled(), /* @ts-ignore */
|
|
2084
|
+
...(ngDevMode ? [{ debugName: "effectiveDisabled" }] : /* istanbul ignore next */ []));
|
|
2085
|
+
counterText = computed(() => {
|
|
2086
|
+
const current = this.currentLength();
|
|
2087
|
+
const max = this.effectiveMaxLength();
|
|
2088
|
+
const formatter = this.characterCounterFormatter();
|
|
2089
|
+
if (formatter) {
|
|
2090
|
+
return formatter(current, max);
|
|
2091
|
+
}
|
|
2092
|
+
if (max !== undefined) {
|
|
2093
|
+
return `${current} / ${max}`;
|
|
2094
|
+
}
|
|
2095
|
+
return `${current}`;
|
|
2096
|
+
}, /* @ts-ignore */
|
|
2097
|
+
...(ngDevMode ? [{ debugName: "counterText" }] : /* istanbul ignore next */ []));
|
|
2069
2098
|
constructor() {
|
|
2070
2099
|
effect(() => {
|
|
2071
2100
|
const input = this.inputField();
|
|
@@ -2074,30 +2103,93 @@ class StrataInputFieldComponent {
|
|
|
2074
2103
|
this.pendingFocus.set(false);
|
|
2075
2104
|
}
|
|
2076
2105
|
});
|
|
2106
|
+
effect(() => {
|
|
2107
|
+
const explicitDisabled = this.disabled();
|
|
2108
|
+
const input = this.nativeInput;
|
|
2109
|
+
if (input && explicitDisabled !== undefined && input.disabled !== explicitDisabled) {
|
|
2110
|
+
input.disabled = explicitDisabled;
|
|
2111
|
+
if (this.nativeDisabled() !== explicitDisabled) {
|
|
2112
|
+
this.nativeDisabled.set(explicitDisabled);
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
});
|
|
2077
2116
|
}
|
|
2078
2117
|
ngAfterViewInit() {
|
|
2079
2118
|
setTimeout(() => this.iconComponents().forEach((icon) => icon.size.set('sm')), 1);
|
|
2119
|
+
this.syncNativeState();
|
|
2120
|
+
}
|
|
2121
|
+
ngAfterContentChecked() {
|
|
2122
|
+
this.syncNativeState();
|
|
2123
|
+
}
|
|
2124
|
+
onNativeInput() {
|
|
2125
|
+
this.syncNativeState();
|
|
2080
2126
|
}
|
|
2081
2127
|
focus() {
|
|
2128
|
+
if (this.effectiveDisabled()) {
|
|
2129
|
+
return;
|
|
2130
|
+
}
|
|
2082
2131
|
this.pendingFocus.set(true);
|
|
2083
2132
|
}
|
|
2084
2133
|
blur() {
|
|
2085
|
-
this.
|
|
2134
|
+
this.nativeInput?.blur();
|
|
2086
2135
|
}
|
|
2087
2136
|
get nativeInput() {
|
|
2088
|
-
return this.inputField()?.el.nativeElement
|
|
2137
|
+
return (this.inputField()?.el.nativeElement ??
|
|
2138
|
+
this.hostElement.nativeElement.querySelector('input, textarea') ??
|
|
2139
|
+
undefined);
|
|
2140
|
+
}
|
|
2141
|
+
syncNativeState() {
|
|
2142
|
+
const input = this.nativeInput;
|
|
2143
|
+
if (!input) {
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2146
|
+
const explicitMax = this.maxLength();
|
|
2147
|
+
if (explicitMax !== undefined) {
|
|
2148
|
+
const maxStr = String(explicitMax);
|
|
2149
|
+
if (input.getAttribute('maxlength') !== maxStr) {
|
|
2150
|
+
input.setAttribute('maxlength', maxStr);
|
|
2151
|
+
}
|
|
2152
|
+
if (input.value.length > explicitMax) {
|
|
2153
|
+
input.value = input.value.slice(0, explicitMax);
|
|
2154
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
else {
|
|
2158
|
+
const attr = input.getAttribute('maxlength');
|
|
2159
|
+
const parsed = attr !== null && attr !== '' ? parseInt(attr, 10) : undefined;
|
|
2160
|
+
const validMax = parsed !== undefined && !isNaN(parsed) && parsed >= 0 ? parsed : undefined;
|
|
2161
|
+
if (this.nativeMaxLength() !== validMax) {
|
|
2162
|
+
this.nativeMaxLength.set(validMax);
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
const explicitDisabled = this.disabled();
|
|
2166
|
+
if (explicitDisabled !== undefined && input.disabled !== explicitDisabled) {
|
|
2167
|
+
input.disabled = explicitDisabled;
|
|
2168
|
+
}
|
|
2169
|
+
const isInputDisabled = input.disabled || input.hasAttribute('disabled');
|
|
2170
|
+
if (this.nativeDisabled() !== isInputDisabled) {
|
|
2171
|
+
this.nativeDisabled.set(isInputDisabled);
|
|
2172
|
+
}
|
|
2173
|
+
const currentLen = input.value.length;
|
|
2174
|
+
if (this.currentLength() !== currentLen) {
|
|
2175
|
+
this.currentLength.set(currentLen);
|
|
2176
|
+
}
|
|
2089
2177
|
}
|
|
2090
2178
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: StrataInputFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2091
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.
|
|
2179
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: StrataInputFieldComponent, isStandalone: true, selector: "st-input-field", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, maxLength: { classPropertyName: "maxLength", publicName: "maxLength", isSignal: true, isRequired: false, transformFunction: null }, showCharacterCounter: { classPropertyName: "showCharacterCounter", publicName: "showCharacterCounter", isSignal: true, isRequired: false, transformFunction: null }, characterCounterFormatter: { classPropertyName: "characterCounterFormatter", publicName: "characterCounterFormatter", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "input": "onNativeInput()", "change": "onNativeInput()" }, properties: { "class.st-size-sm": "size() === \"sm\"", "class.st-size-md": "size() === \"md\"", "class.st-size-lg": "size() === \"lg\"", "class.st-disabled": "effectiveDisabled()", "attr.aria-disabled": "effectiveDisabled() ? \"true\" : null" } }, queries: [{ propertyName: "iconComponents", predicate: StrataIconComponent, descendants: true, isSignal: true }, { propertyName: "inputField", first: true, predicate: StrataNativeInputRefDirective, descendants: true, isSignal: true }], ngImport: i0, template: "<ng-content select=\"label\"></ng-content>\n<div class=\"st-input-wrapper\">\n <div class=\"affix\">\n <ng-content select=\"[prefix]\"></ng-content>\n </div>\n <ng-content select=\"input,textarea\"></ng-content>\n <div class=\"affix\">\n <ng-content select=\"[suffix]\"></ng-content>\n </div>\n</div>\n@if (showCharacterCounter()) {\n <div class=\"st-input-field-footer\">\n <span class=\"st-input-field-counter\" aria-live=\"polite\">{{ counterText() }}</span>\n </div>\n}\n" });
|
|
2092
2180
|
}
|
|
2093
2181
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: StrataInputFieldComponent, decorators: [{
|
|
2094
2182
|
type: Component,
|
|
2095
2183
|
args: [{ selector: 'st-input-field', imports: [], host: {
|
|
2096
2184
|
'[class.st-size-sm]': 'size() === "sm"',
|
|
2097
2185
|
'[class.st-size-md]': 'size() === "md"',
|
|
2098
|
-
'[class.st-size-lg]': 'size() === "lg"'
|
|
2099
|
-
|
|
2100
|
-
|
|
2186
|
+
'[class.st-size-lg]': 'size() === "lg"',
|
|
2187
|
+
'[class.st-disabled]': 'effectiveDisabled()',
|
|
2188
|
+
'[attr.aria-disabled]': 'effectiveDisabled() ? "true" : null',
|
|
2189
|
+
'(input)': 'onNativeInput()',
|
|
2190
|
+
'(change)': 'onNativeInput()'
|
|
2191
|
+
}, template: "<ng-content select=\"label\"></ng-content>\n<div class=\"st-input-wrapper\">\n <div class=\"affix\">\n <ng-content select=\"[prefix]\"></ng-content>\n </div>\n <ng-content select=\"input,textarea\"></ng-content>\n <div class=\"affix\">\n <ng-content select=\"[suffix]\"></ng-content>\n </div>\n</div>\n@if (showCharacterCounter()) {\n <div class=\"st-input-field-footer\">\n <span class=\"st-input-field-counter\" aria-live=\"polite\">{{ counterText() }}</span>\n </div>\n}\n" }]
|
|
2192
|
+
}], ctorParameters: () => [], propDecorators: { size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], maxLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxLength", required: false }] }], showCharacterCounter: [{ type: i0.Input, args: [{ isSignal: true, alias: "showCharacterCounter", required: false }] }], characterCounterFormatter: [{ type: i0.Input, args: [{ isSignal: true, alias: "characterCounterFormatter", required: false }] }], iconComponents: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => StrataIconComponent), { ...{ descendants: true }, isSignal: true }] }], inputField: [{ type: i0.ContentChild, args: [i0.forwardRef(() => StrataNativeInputRefDirective), { ...{
|
|
2101
2193
|
descendants: true
|
|
2102
2194
|
}, isSignal: true }] }] } });
|
|
2103
2195
|
|
|
@@ -3997,7 +4089,7 @@ class StrataSingleSelectComponent {
|
|
|
3997
4089
|
useExisting: forwardRef(() => StrataSingleSelectComponent),
|
|
3998
4090
|
multi: true
|
|
3999
4091
|
}
|
|
4000
|
-
], queries: [{ propertyName: "selectItems", predicate: StrataSelectItemComponent, isSignal: true }, { propertyName: "triggerTemplate", first: true, predicate: StrataSelectTriggerDirective, descendants: true, read: TemplateRef, isSignal: true }], viewQueries: [{ propertyName: "inputField", first: true, predicate: StrataInputFieldComponent, descendants: true, isSignal: true }], ngImport: i0, template: "@if (label()) {\n<label class=\"st-label\" [for]=\"name()\"> {{ label() }}</label>\n}\n<div class=\"single-select-input\" [class.disabled]=\"effectiveDisabled()\" [id]=\"name()\" #singleSelectInput (click)=\"toggle($event)\" (keydown.space)=\"toggle($event)\" (keydown.enter)=\"toggle($event)\" (keydown.escape)=\"open.set(false)\" [attr.data-open]=\"open()\"\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\" [stOverlay]=\"selector\" [overlayOpen]=\"open()\" [overlayPlacement]=\"placement()\">\n @if (selectedItem()) {\n @if (triggerTemplate()) {\n <ng-container *ngTemplateOutlet=\"triggerTemplate()!\"></ng-container>\n } @else {\n {{ selectedItem()!.text() }}\n }\n } @else {\n <span class=\"placeholder-text\">{{ placeholder() }}</span>\n }\n\n <st-icon name=\"expand-up-down\"></st-icon>\n</div>\n\n<ng-template #selector>\n <div class=\"single-select-selector\" #singleSelectSelector [class.full-width]=\"fullWidth()\">\n @if (searchable()) {\n <st-input-field>\n <input stInput #searchField type=\"text\" [value]=\"searchQuery() || ''\" (input)=\"searchQuery.set($any($event.target).value); onSearchChange(searchQuery())\" [placeholder]=\"searchPlaceholder()\" />\n <button stButton variant=\"ghost\" [class.visible]=\"searchQuery() !== undefined && searchQuery()!.length > 0\" suffix\n size=\"sm\" (click)=\"searchQuery.set(undefined); onSearchChange(undefined)\">\n x\n </button>\n </st-input-field>\n }\n <div class=\"single-select-items-container\">\n <ng-content select=\"st-select-item\"></ng-content>\n </div>\n </div>\n</ng-template>", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: StrataIconComponent, selector: "st-icon", inputs: ["name", "size", "ariaLabel"], outputs: ["sizeChange"] }, { kind: "directive", type: StrataOverlayDirective, selector: "[stOverlay]", inputs: ["stOverlay", "overlayOpen", "overlayPlacement", "overlayOffset", "overlayFitViewport"], outputs: ["overlayOpenChange"] }, { kind: "component", type: StrataInputFieldComponent, selector: "st-input-field", inputs: ["size"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: StrataNativeInputRefDirective, selector: "input[stInput], textarea[stInput]" }, { kind: "directive", type: StrataButtonDirective, selector: "[stButton]", inputs: ["variant", "size", "fullWidth"] }] });
|
|
4092
|
+
], queries: [{ propertyName: "selectItems", predicate: StrataSelectItemComponent, isSignal: true }, { propertyName: "triggerTemplate", first: true, predicate: StrataSelectTriggerDirective, descendants: true, read: TemplateRef, isSignal: true }], viewQueries: [{ propertyName: "inputField", first: true, predicate: StrataInputFieldComponent, descendants: true, isSignal: true }], ngImport: i0, template: "@if (label()) {\n<label class=\"st-label\" [for]=\"name()\"> {{ label() }}</label>\n}\n<div class=\"single-select-input\" [class.disabled]=\"effectiveDisabled()\" [id]=\"name()\" #singleSelectInput (click)=\"toggle($event)\" (keydown.space)=\"toggle($event)\" (keydown.enter)=\"toggle($event)\" (keydown.escape)=\"open.set(false)\" [attr.data-open]=\"open()\"\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\" [stOverlay]=\"selector\" [overlayOpen]=\"open()\" [overlayPlacement]=\"placement()\">\n @if (selectedItem()) {\n @if (triggerTemplate()) {\n <ng-container *ngTemplateOutlet=\"triggerTemplate()!\"></ng-container>\n } @else {\n {{ selectedItem()!.text() }}\n }\n } @else {\n <span class=\"placeholder-text\">{{ placeholder() }}</span>\n }\n\n <st-icon name=\"expand-up-down\"></st-icon>\n</div>\n\n<ng-template #selector>\n <div class=\"single-select-selector\" #singleSelectSelector [class.full-width]=\"fullWidth()\">\n @if (searchable()) {\n <st-input-field>\n <input stInput #searchField type=\"text\" [value]=\"searchQuery() || ''\" (input)=\"searchQuery.set($any($event.target).value); onSearchChange(searchQuery())\" [placeholder]=\"searchPlaceholder()\" />\n <button stButton variant=\"ghost\" [class.visible]=\"searchQuery() !== undefined && searchQuery()!.length > 0\" suffix\n size=\"sm\" (click)=\"searchQuery.set(undefined); onSearchChange(undefined)\">\n x\n </button>\n </st-input-field>\n }\n <div class=\"single-select-items-container\">\n <ng-content select=\"st-select-item\"></ng-content>\n </div>\n </div>\n</ng-template>", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: StrataIconComponent, selector: "st-icon", inputs: ["name", "size", "ariaLabel"], outputs: ["sizeChange"] }, { kind: "directive", type: StrataOverlayDirective, selector: "[stOverlay]", inputs: ["stOverlay", "overlayOpen", "overlayPlacement", "overlayOffset", "overlayFitViewport"], outputs: ["overlayOpenChange"] }, { kind: "component", type: StrataInputFieldComponent, selector: "st-input-field", inputs: ["size", "disabled", "maxLength", "showCharacterCounter", "characterCounterFormatter"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: StrataNativeInputRefDirective, selector: "input[stInput], textarea[stInput]" }, { kind: "directive", type: StrataButtonDirective, selector: "[stButton]", inputs: ["variant", "size", "fullWidth"] }] });
|
|
4001
4093
|
}
|
|
4002
4094
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: StrataSingleSelectComponent, decorators: [{
|
|
4003
4095
|
type: Component,
|