@xui/label 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-label.mjs +73 -0
- package/fesm2022/xui-label.mjs.map +1 -0
- package/index.d.ts +1 -0
- package/lib/label.directive.d.ts +23 -0
- package/package.json +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, input, computed, signal, Directive } from '@angular/core';
|
|
3
|
+
import { xui } from '@xui/core';
|
|
4
|
+
import * as i1 from '@xui/core/label';
|
|
5
|
+
import { XCoreLabelDirective } from '@xui/core/label';
|
|
6
|
+
import { cva } from 'class-variance-authority';
|
|
7
|
+
|
|
8
|
+
// TODO: theme - disabled, etc.
|
|
9
|
+
const labelVariants = cva([
|
|
10
|
+
'text-sm font-medium leading-none',
|
|
11
|
+
'[&.ng-invalid.ng-touched]:text-error',
|
|
12
|
+
'[&>[xuiInput]]:my-1 [&:has([xuiInput]:disabled)]:cursor-not-allowed [&:has([xuiInput]:disabled)]:opacity-70'
|
|
13
|
+
], {
|
|
14
|
+
variants: {
|
|
15
|
+
variant: {
|
|
16
|
+
default: ''
|
|
17
|
+
},
|
|
18
|
+
error: {
|
|
19
|
+
auto: '[&:has([xuiInput].ng-invalid.ng-touched)]:text-error',
|
|
20
|
+
true: 'text-error'
|
|
21
|
+
},
|
|
22
|
+
disabled: {
|
|
23
|
+
auto: '[&:has([xuiInput]:disabled)]:opacity-70',
|
|
24
|
+
true: 'opacity-70',
|
|
25
|
+
false: ''
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: {
|
|
29
|
+
variant: 'default',
|
|
30
|
+
error: 'auto'
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
class XuiLabelDirective {
|
|
34
|
+
xCore = inject(XCoreLabelDirective, { host: true });
|
|
35
|
+
class = input('');
|
|
36
|
+
variant = input('default');
|
|
37
|
+
error = input('auto');
|
|
38
|
+
state = computed(() => ({
|
|
39
|
+
error: signal(this.error())
|
|
40
|
+
}));
|
|
41
|
+
computedClass = computed(() => xui(labelVariants({
|
|
42
|
+
variant: this.variant(),
|
|
43
|
+
error: this.state().error(),
|
|
44
|
+
disabled: this.xCore?.dataDisabled() ?? 'auto'
|
|
45
|
+
}), this.class()));
|
|
46
|
+
setError(error) {
|
|
47
|
+
this.state().error.set(error);
|
|
48
|
+
}
|
|
49
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: XuiLabelDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
50
|
+
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.3", type: XuiLabelDirective, isStandalone: true, selector: "[xuiLabel]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClass()" } }, hostDirectives: [{ directive: i1.XCoreLabelDirective, inputs: ["id", "id"] }], ngImport: i0 });
|
|
51
|
+
}
|
|
52
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: XuiLabelDirective, decorators: [{
|
|
53
|
+
type: Directive,
|
|
54
|
+
args: [{
|
|
55
|
+
selector: '[xuiLabel]',
|
|
56
|
+
hostDirectives: [
|
|
57
|
+
{
|
|
58
|
+
directive: XCoreLabelDirective,
|
|
59
|
+
inputs: ['id']
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
host: {
|
|
63
|
+
'[class]': 'computedClass()'
|
|
64
|
+
}
|
|
65
|
+
}]
|
|
66
|
+
}] });
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Generated bundle index. Do not edit.
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
export { XuiLabelDirective, labelVariants };
|
|
73
|
+
//# sourceMappingURL=xui-label.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xui-label.mjs","sources":["../../../../../../libs/ui/label/xui/src/lib/label.directive.ts","../../../../../../libs/ui/label/xui/src/xui-label.ts"],"sourcesContent":["import { Directive, computed, inject, input, signal } from '@angular/core';\nimport { xui } from '@xui/core';\nimport { XCoreLabelDirective } from '@xui/core/label';\nimport { type VariantProps, cva } from 'class-variance-authority';\nimport type { ClassValue } from 'clsx';\n\n// TODO: theme - disabled, etc.\nexport const labelVariants = cva(\n [\n 'text-sm font-medium leading-none',\n '[&.ng-invalid.ng-touched]:text-error',\n '[&>[xuiInput]]:my-1 [&:has([xuiInput]:disabled)]:cursor-not-allowed [&:has([xuiInput]:disabled)]:opacity-70'\n ],\n {\n variants: {\n variant: {\n default: ''\n },\n error: {\n auto: '[&:has([xuiInput].ng-invalid.ng-touched)]:text-error',\n true: 'text-error'\n },\n disabled: {\n auto: '[&:has([xuiInput]:disabled)]:opacity-70',\n true: 'opacity-70',\n false: ''\n }\n },\n defaultVariants: {\n variant: 'default',\n error: 'auto'\n }\n }\n);\nexport type LabelVariants = VariantProps<typeof labelVariants>;\n\n@Directive({\n selector: '[xuiLabel]',\n hostDirectives: [\n {\n directive: XCoreLabelDirective,\n inputs: ['id']\n }\n ],\n host: {\n '[class]': 'computedClass()'\n }\n})\nexport class XuiLabelDirective {\n private readonly xCore = inject(XCoreLabelDirective, { host: true });\n\n readonly class = input<ClassValue>('');\n readonly variant = input<LabelVariants['variant']>('default');\n readonly error = input<LabelVariants['error']>('auto');\n\n protected readonly state = computed(() => ({\n error: signal(this.error())\n }));\n\n protected readonly computedClass = computed(() =>\n xui(\n labelVariants({\n variant: this.variant(),\n error: this.state().error(),\n disabled: this.xCore?.dataDisabled() ?? 'auto'\n }),\n this.class()\n )\n );\n\n setError(error: LabelVariants['error']): void {\n this.state().error.set(error);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAMA;AACO,MAAM,aAAa,GAAG,GAAG,CAC9B;IACE,kCAAkC;IAClC,sCAAsC;IACtC;CACD,EACD;AACE,IAAA,QAAQ,EAAE;AACR,QAAA,OAAO,EAAE;AACP,YAAA,OAAO,EAAE;AACV,SAAA;AACD,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,sDAAsD;AAC5D,YAAA,IAAI,EAAE;AACP,SAAA;AACD,QAAA,QAAQ,EAAE;AACR,YAAA,IAAI,EAAE,yCAAyC;AAC/C,YAAA,IAAI,EAAE,YAAY;AAClB,YAAA,KAAK,EAAE;AACR;AACF,KAAA;AACD,IAAA,eAAe,EAAE;AACf,QAAA,OAAO,EAAE,SAAS;AAClB,QAAA,KAAK,EAAE;AACR;AACF,CAAA;MAgBU,iBAAiB,CAAA;IACX,KAAK,GAAG,MAAM,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAE3D,IAAA,KAAK,GAAG,KAAK,CAAa,EAAE,CAAC;AAC7B,IAAA,OAAO,GAAG,KAAK,CAA2B,SAAS,CAAC;AACpD,IAAA,KAAK,GAAG,KAAK,CAAyB,MAAM,CAAC;AAEnC,IAAA,KAAK,GAAG,QAAQ,CAAC,OAAO;AACzC,QAAA,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE;AAC3B,KAAA,CAAC,CAAC;IAEgB,aAAa,GAAG,QAAQ,CAAC,MAC1C,GAAG,CACD,aAAa,CAAC;AACZ,QAAA,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;AACvB,QAAA,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE;QAC3B,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI;AACzC,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,CAAC,IAAI;AACd;AACF,qBAAA;AACD,oBAAA,IAAI,EAAE;AACJ,wBAAA,SAAS,EAAE;AACZ;AACF,iBAAA;;;AC/CD;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/label.directive';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import type { ClassValue } from 'clsx';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import * as i1 from "@xui/core/label";
|
|
5
|
+
export declare const labelVariants: (props?: ({
|
|
6
|
+
variant?: "default" | null | undefined;
|
|
7
|
+
error?: boolean | "auto" | null | undefined;
|
|
8
|
+
disabled?: boolean | "auto" | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
10
|
+
export type LabelVariants = VariantProps<typeof labelVariants>;
|
|
11
|
+
export declare class XuiLabelDirective {
|
|
12
|
+
private readonly xCore;
|
|
13
|
+
readonly class: import("@angular/core").InputSignal<ClassValue>;
|
|
14
|
+
readonly variant: import("@angular/core").InputSignal<"default" | null | undefined>;
|
|
15
|
+
readonly error: import("@angular/core").InputSignal<boolean | "auto" | null | undefined>;
|
|
16
|
+
protected readonly state: import("@angular/core").Signal<{
|
|
17
|
+
error: import("@angular/core").WritableSignal<boolean | "auto" | null | undefined>;
|
|
18
|
+
}>;
|
|
19
|
+
protected readonly computedClass: import("@angular/core").Signal<string>;
|
|
20
|
+
setError(error: LabelVariants['error']): void;
|
|
21
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<XuiLabelDirective, never>;
|
|
22
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<XuiLabelDirective, "[xuiLabel]", never, { "class": { "alias": "class"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; }, {}, never, never, true, [{ directive: typeof i1.XCoreLabelDirective; inputs: { "id": "id"; }; outputs: {}; }]>;
|
|
23
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xui/label",
|
|
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
|
+
"class-variance-authority": "^0.7.1",
|
|
12
|
+
"clsx": "^2.1.1"
|
|
13
|
+
},
|
|
14
|
+
"module": "fesm2022/xui-label.mjs",
|
|
15
|
+
"typings": "index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
"./package.json": {
|
|
18
|
+
"default": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./index.d.ts",
|
|
22
|
+
"default": "./fesm2022/xui-label.mjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"tslib": "^2.3.0"
|
|
27
|
+
}
|
|
28
|
+
}
|