@xui/form-field 2.0.0-alpha.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/README.md +7 -0
- package/fesm2022/xui-form-field.mjs +102 -0
- package/fesm2022/xui-form-field.mjs.map +1 -0
- package/index.d.ts +16 -0
- package/lib/error.component.d.ts +5 -0
- package/lib/form-field.component.d.ts +11 -0
- package/lib/hint.component.d.ts +5 -0
- package/package.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Component, contentChild, contentChildren, computed, effect, NgModule } from '@angular/core';
|
|
3
|
+
import { XCoreFormFieldControl } from '@xui/core/form-field';
|
|
4
|
+
|
|
5
|
+
class XuiErrorComponent {
|
|
6
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: XuiErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
7
|
+
/** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.3", type: XuiErrorComponent, isStandalone: true, selector: "xui-error", host: { classAttribute: "block text-error text-sm font-medium" }, ngImport: i0, template: '<ng-content />', isInline: true });
|
|
8
|
+
}
|
|
9
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: XuiErrorComponent, decorators: [{
|
|
10
|
+
type: Component,
|
|
11
|
+
args: [{
|
|
12
|
+
selector: 'xui-error',
|
|
13
|
+
template: '<ng-content />',
|
|
14
|
+
host: {
|
|
15
|
+
class: 'block text-error text-sm font-medium'
|
|
16
|
+
}
|
|
17
|
+
}]
|
|
18
|
+
}] });
|
|
19
|
+
|
|
20
|
+
class XuiFormFieldComponent {
|
|
21
|
+
control = contentChild(XCoreFormFieldControl);
|
|
22
|
+
errorChildren = contentChildren(XuiErrorComponent);
|
|
23
|
+
hasDisplayedMessage = computed(() => this.errorChildren() && this.errorChildren().length > 0 && this.control()?.errorState() ? 'error' : 'hint');
|
|
24
|
+
constructor() {
|
|
25
|
+
effect(() => {
|
|
26
|
+
if (!this.control()) {
|
|
27
|
+
throw new Error('xui-form-field must contain an XCoreFormFieldControl.');
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: XuiFormFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
32
|
+
/** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.3", type: XuiFormFieldComponent, isStandalone: true, selector: "xui-form-field", host: { classAttribute: "block space-y-2" }, queries: [{ propertyName: "control", first: true, predicate: XCoreFormFieldControl, descendants: true, isSignal: true }, { propertyName: "errorChildren", predicate: XuiErrorComponent, isSignal: true }], ngImport: i0, template: `
|
|
33
|
+
<ng-content></ng-content>
|
|
34
|
+
|
|
35
|
+
@switch (hasDisplayedMessage()) {
|
|
36
|
+
@case ('error') {
|
|
37
|
+
<ng-content select="xui-error"></ng-content>
|
|
38
|
+
}
|
|
39
|
+
@default {
|
|
40
|
+
<ng-content select="xui-hint"></ng-content>
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`, isInline: true });
|
|
44
|
+
}
|
|
45
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: XuiFormFieldComponent, decorators: [{
|
|
46
|
+
type: Component,
|
|
47
|
+
args: [{
|
|
48
|
+
selector: 'xui-form-field',
|
|
49
|
+
imports: [],
|
|
50
|
+
template: `
|
|
51
|
+
<ng-content></ng-content>
|
|
52
|
+
|
|
53
|
+
@switch (hasDisplayedMessage()) {
|
|
54
|
+
@case ('error') {
|
|
55
|
+
<ng-content select="xui-error"></ng-content>
|
|
56
|
+
}
|
|
57
|
+
@default {
|
|
58
|
+
<ng-content select="xui-hint"></ng-content>
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`,
|
|
62
|
+
host: {
|
|
63
|
+
class: 'block space-y-2'
|
|
64
|
+
}
|
|
65
|
+
}]
|
|
66
|
+
}], ctorParameters: () => [] });
|
|
67
|
+
|
|
68
|
+
class XuiHintComponent {
|
|
69
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: XuiHintComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
70
|
+
/** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.3", type: XuiHintComponent, isStandalone: true, selector: "xui-hint", host: { classAttribute: "block text-sm text-foreground/50" }, ngImport: i0, template: '<ng-content />', isInline: true });
|
|
71
|
+
}
|
|
72
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: XuiHintComponent, decorators: [{
|
|
73
|
+
type: Component,
|
|
74
|
+
args: [{
|
|
75
|
+
selector: 'xui-hint',
|
|
76
|
+
template: '<ng-content />',
|
|
77
|
+
host: {
|
|
78
|
+
class: 'block text-sm text-foreground/50'
|
|
79
|
+
}
|
|
80
|
+
}]
|
|
81
|
+
}] });
|
|
82
|
+
|
|
83
|
+
const XuiFormFieldImports = [XuiFormFieldComponent, XuiErrorComponent, XuiHintComponent];
|
|
84
|
+
class XuiFormFieldModule {
|
|
85
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: XuiFormFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
86
|
+
/** @nocollapse */ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.3", ngImport: i0, type: XuiFormFieldModule, imports: [XuiFormFieldComponent, XuiErrorComponent, XuiHintComponent], exports: [XuiFormFieldComponent, XuiErrorComponent, XuiHintComponent] });
|
|
87
|
+
/** @nocollapse */ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: XuiFormFieldModule });
|
|
88
|
+
}
|
|
89
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: XuiFormFieldModule, decorators: [{
|
|
90
|
+
type: NgModule,
|
|
91
|
+
args: [{
|
|
92
|
+
imports: [...XuiFormFieldImports],
|
|
93
|
+
exports: [...XuiFormFieldImports]
|
|
94
|
+
}]
|
|
95
|
+
}] });
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Generated bundle index. Do not edit.
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
export { XuiErrorComponent, XuiFormFieldComponent, XuiFormFieldImports, XuiFormFieldModule, XuiHintComponent };
|
|
102
|
+
//# sourceMappingURL=xui-form-field.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xui-form-field.mjs","sources":["../../../../../../libs/ui/form-field/xui/src/lib/error.component.ts","../../../../../../libs/ui/form-field/xui/src/lib/form-field.component.ts","../../../../../../libs/ui/form-field/xui/src/lib/hint.component.ts","../../../../../../libs/ui/form-field/xui/src/index.ts","../../../../../../libs/ui/form-field/xui/src/xui-form-field.ts"],"sourcesContent":["import { Component } from '@angular/core';\n\n@Component({\n selector: 'xui-error',\n template: '<ng-content />',\n host: {\n class: 'block text-error text-sm font-medium'\n }\n})\nexport class XuiErrorComponent {}\n","import { Component, computed, contentChild, contentChildren, effect } from '@angular/core';\nimport { XCoreFormFieldControl } from '@xui/core/form-field';\nimport { XuiErrorComponent } from './error.component';\n\n@Component({\n selector: 'xui-form-field',\n imports: [],\n template: `\n <ng-content></ng-content>\n\n @switch (hasDisplayedMessage()) {\n @case ('error') {\n <ng-content select=\"xui-error\"></ng-content>\n }\n @default {\n <ng-content select=\"xui-hint\"></ng-content>\n }\n }\n `,\n host: {\n class: 'block space-y-2'\n }\n})\nexport class XuiFormFieldComponent {\n readonly control = contentChild(XCoreFormFieldControl);\n readonly errorChildren = contentChildren(XuiErrorComponent);\n\n protected readonly hasDisplayedMessage = computed<'error' | 'hint'>(() =>\n this.errorChildren() && this.errorChildren().length > 0 && this.control()?.errorState() ? 'error' : 'hint'\n );\n\n constructor() {\n effect(() => {\n if (!this.control()) {\n throw new Error('xui-form-field must contain an XCoreFormFieldControl.');\n }\n });\n }\n}\n","import { Component } from '@angular/core';\n\n@Component({\n selector: 'xui-hint',\n template: '<ng-content />',\n host: {\n class: 'block text-sm text-foreground/50'\n }\n})\nexport class XuiHintComponent {}\n","import { NgModule } from '@angular/core';\nimport { XuiErrorComponent } from './lib/error.component';\nimport { XuiFormFieldComponent } from './lib/form-field.component';\nimport { XuiHintComponent } from './lib/hint.component';\nexport * from './lib/error.component';\nexport * from './lib/form-field.component';\nexport * from './lib/hint.component';\n\nexport const XuiFormFieldImports = [XuiFormFieldComponent, XuiErrorComponent, XuiHintComponent] as const;\n\n@NgModule({\n imports: [...XuiFormFieldImports],\n exports: [...XuiFormFieldImports]\n})\nexport class XuiFormFieldModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MASa,iBAAiB,CAAA;0HAAjB,iBAAiB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAjB,uBAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,iBAAiB,uIALlB,gBAAgB,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA;;2FAKf,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAP7B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,WAAW;AAC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,EAAA,CAAA;;2FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAJ9B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE,CAAC,GAAG,mBAAmB,CAAC;AACjC,oBAAA,OAAO,EAAE,CAAC,GAAG,mBAAmB;AACjC,iBAAA;;;ACbD;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { XuiErrorComponent } from './lib/error.component';
|
|
2
|
+
import { XuiFormFieldComponent } from './lib/form-field.component';
|
|
3
|
+
import { XuiHintComponent } from './lib/hint.component';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import * as i1 from "./lib/form-field.component";
|
|
6
|
+
import * as i2 from "./lib/error.component";
|
|
7
|
+
import * as i3 from "./lib/hint.component";
|
|
8
|
+
export * from './lib/error.component';
|
|
9
|
+
export * from './lib/form-field.component';
|
|
10
|
+
export * from './lib/hint.component';
|
|
11
|
+
export declare const XuiFormFieldImports: readonly [typeof XuiFormFieldComponent, typeof XuiErrorComponent, typeof XuiHintComponent];
|
|
12
|
+
export declare class XuiFormFieldModule {
|
|
13
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<XuiFormFieldModule, never>;
|
|
14
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<XuiFormFieldModule, never, [typeof i1.XuiFormFieldComponent, typeof i2.XuiErrorComponent, typeof i3.XuiHintComponent], [typeof i1.XuiFormFieldComponent, typeof i2.XuiErrorComponent, typeof i3.XuiHintComponent]>;
|
|
15
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<XuiFormFieldModule>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { XCoreFormFieldControl } from '@xui/core/form-field';
|
|
2
|
+
import { XuiErrorComponent } from './error.component';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class XuiFormFieldComponent {
|
|
5
|
+
readonly control: import("@angular/core").Signal<XCoreFormFieldControl | undefined>;
|
|
6
|
+
readonly errorChildren: import("@angular/core").Signal<readonly XuiErrorComponent[]>;
|
|
7
|
+
protected readonly hasDisplayedMessage: import("@angular/core").Signal<"error" | "hint">;
|
|
8
|
+
constructor();
|
|
9
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<XuiFormFieldComponent, never>;
|
|
10
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<XuiFormFieldComponent, "xui-form-field", never, {}, {}, ["control", "errorChildren"], ["*", "xui-error", "xui-hint"], true, never>;
|
|
11
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xui/form-field",
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"@angular/core": "19",
|
|
10
|
+
"@xui/core": "2"
|
|
11
|
+
},
|
|
12
|
+
"module": "fesm2022/xui-form-field.mjs",
|
|
13
|
+
"typings": "index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": {
|
|
16
|
+
"default": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./index.d.ts",
|
|
20
|
+
"default": "./fesm2022/xui-form-field.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"tslib": "^2.3.0"
|
|
25
|
+
}
|
|
26
|
+
}
|