@xui/label 2.0.0-alpha.20 → 2.0.0-alpha.22

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.
@@ -30,13 +30,31 @@ const labelVariants = cva([
30
30
  error: 'auto'
31
31
  }
32
32
  });
33
+ /**
34
+ * Styles a `<label>` and keeps it in step with the control it names.
35
+ *
36
+ * ```html
37
+ * <label xuiLabel for="email">Email</label>
38
+ * <label xuiLabel>Email <input xuiInput /></label>
39
+ * ```
40
+ *
41
+ * Composes `XLabel` from `@xui/core/label`, so it mirrors the bound control's `ng-invalid`/`ng-touched`
42
+ * state and its `data-disabled`: an invalid, touched field turns its label red and a disabled one dims
43
+ * it, with no binding on the label itself.
44
+ */
33
45
  class XuiLabel {
34
46
  // TODO: check the implementation of this component
35
47
  xLabel = inject(XLabel, { host: true });
48
+ /** Extra classes, merged into the directive's own rather than replacing them. */
36
49
  class = input('', /* @ts-ignore */
37
50
  ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
51
+ /** Reserved for future label styles; `default` is currently the only one. */
38
52
  variant = input('default', /* @ts-ignore */
39
53
  ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
54
+ /**
55
+ * Whether to render the error appearance. `auto` (the default) follows the wrapped control's
56
+ * `ng-invalid.ng-touched` state; `true` forces it on for a control the label cannot see.
57
+ */
40
58
  error = input('auto', /* @ts-ignore */
41
59
  ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
42
60
  /** Follows the `error` input until `setError` overrides it. */
@@ -1 +1 @@
1
- {"version":3,"file":"xui-label.mjs","sources":["../../../../../../libs/ui/label/xui/src/lib/label.ts","../../../../../../libs/ui/label/xui/src/index.ts","../../../../../../libs/ui/label/xui/src/xui-label.ts"],"sourcesContent":["import { Directive, computed, inject, input, linkedSignal } from '@angular/core';\nimport { xui } from '@xui/core';\nimport { XLabel } 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 XuiLabelVariants = VariantProps<typeof labelVariants>;\n\n@Directive({\n selector: '[xuiLabel]',\n exportAs: 'xuiLabel',\n hostDirectives: [\n {\n directive: XLabel,\n inputs: ['id']\n }\n ],\n host: {\n '[class]': 'computedClass()'\n }\n})\nexport class XuiLabel {\n // TODO: check the implementation of this component\n\n private readonly xLabel = inject(XLabel, { host: true });\n\n readonly class = input<ClassValue>('');\n readonly variant = input<XuiLabelVariants['variant']>('default');\n readonly error = input<XuiLabelVariants['error']>('auto');\n\n /** Follows the `error` input until `setError` overrides it. */\n private readonly errorState = linkedSignal(this.error);\n\n protected readonly computedClass = computed(() =>\n xui(\n labelVariants({\n variant: this.variant(),\n error: this.errorState(),\n disabled: this.xLabel?.dataDisabled() ?? 'auto'\n }),\n this.class()\n )\n );\n\n setError(error: XuiLabelVariants['error']): void {\n this.errorState.set(error);\n }\n}\n","import { XuiLabel } from './lib/label';\n\nexport * from './lib/label';\n\nexport const XuiLabelImports = [XuiLabel] as const;\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,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A,iBAAA,EAAA,OAAA,EAAA,UAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,OAAA,EAAA,EAAA,iBAAA,EAAA,SAAA,EAAA,UAAA,EAAA,SAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,KAAA,EAAA,EAAA,iBAAA,EAAA,OAAA,EAAA,UAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,OAAA,EAAA,iBAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,UAAA,CAAA,EAAA,cAAA,EAAA,CAAA,EAAA,SAAA,EAAA,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,CAAA,IAAA,EAAA,IAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAR,QAAQ,EAAA,UAAA,EAAA,CAAA;kBAbpB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,QAAQ,EAAE,UAAU;AACpB,oBAAA,cAAc,EAAE;AACd,wBAAA;AACE,4BAAA,SAAS,EAAE,MAAM;4BACjB,MAAM,EAAE,CAAC,IAAI;AACd;AACF,qBAAA;AACD,oBAAA,IAAI,EAAE;AACJ,wBAAA,SAAS,EAAE;AACZ;AACF,iBAAA;;;AC5CM,MAAM,eAAe,GAAG,CAAC,QAAQ;;ACJxC;;AAEG;;;;"}
1
+ {"version":3,"file":"xui-label.mjs","sources":["../../../../../../libs/ui/label/xui/src/lib/label.ts","../../../../../../libs/ui/label/xui/src/index.ts","../../../../../../libs/ui/label/xui/src/xui-label.ts"],"sourcesContent":["import { Directive, computed, inject, input, linkedSignal } from '@angular/core';\nimport { xui } from '@xui/core';\nimport { XLabel } 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 XuiLabelVariants = VariantProps<typeof labelVariants>;\n\n/**\n * Styles a `<label>` and keeps it in step with the control it names.\n *\n * ```html\n * <label xuiLabel for=\"email\">Email</label>\n * <label xuiLabel>Email <input xuiInput /></label>\n * ```\n *\n * Composes `XLabel` from `@xui/core/label`, so it mirrors the bound control's `ng-invalid`/`ng-touched`\n * state and its `data-disabled`: an invalid, touched field turns its label red and a disabled one dims\n * it, with no binding on the label itself.\n */\n@Directive({\n selector: '[xuiLabel]',\n exportAs: 'xuiLabel',\n hostDirectives: [\n {\n directive: XLabel,\n inputs: ['id']\n }\n ],\n host: {\n '[class]': 'computedClass()'\n }\n})\nexport class XuiLabel {\n // TODO: check the implementation of this component\n\n private readonly xLabel = inject(XLabel, { host: true });\n\n /** Extra classes, merged into the directive's own rather than replacing them. */\n readonly class = input<ClassValue>('');\n /** Reserved for future label styles; `default` is currently the only one. */\n readonly variant = input<XuiLabelVariants['variant']>('default');\n /**\n * Whether to render the error appearance. `auto` (the default) follows the wrapped control's\n * `ng-invalid.ng-touched` state; `true` forces it on for a control the label cannot see.\n */\n readonly error = input<XuiLabelVariants['error']>('auto');\n\n /** Follows the `error` input until `setError` overrides it. */\n private readonly errorState = linkedSignal(this.error);\n\n protected readonly computedClass = computed(() =>\n xui(\n labelVariants({\n variant: this.variant(),\n error: this.errorState(),\n disabled: this.xLabel?.dataDisabled() ?? 'auto'\n }),\n this.class()\n )\n );\n\n setError(error: XuiLabelVariants['error']): void {\n this.errorState.set(error);\n }\n}\n","import { XuiLabel } from './lib/label';\n\nexport * from './lib/label';\n\nexport const XuiLabelImports = [XuiLabel] as const;\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;AAIH;;;;;;;;;;;AAWG;MAcU,QAAQ,CAAA;;IAGF,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;IAG/C,KAAK,GAAG,KAAK,CAAa,EAAE;8EAAC;;IAE7B,OAAO,GAAG,KAAK,CAA8B,SAAS;gFAAC;AAChE;;;AAGG;IACM,KAAK,GAAG,KAAK,CAA4B,MAAM;8EAAC;;AAGxC,IAAA,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK;mFAAC;IAEnC,aAAa,GAAG,QAAQ,CAAC,MAC1C,GAAG,CACD,aAAa,CAAC;AAC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,UAAA,EAAA,CAAA;kBAbpB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,QAAQ,EAAE,UAAU;AACpB,oBAAA,cAAc,EAAE;AACd,wBAAA;AACE,4BAAA,SAAS,EAAE,MAAM;4BACjB,MAAM,EAAE,CAAC,IAAI;AACd;AACF,qBAAA;AACD,oBAAA,IAAI,EAAE;AACJ,wBAAA,SAAS,EAAE;AACZ;AACF,iBAAA;;;ACxDM,MAAM,eAAe,GAAG,CAAC,QAAQ;;ACJxC;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xui/label",
3
- "version": "2.0.0-alpha.20",
3
+ "version": "2.0.0-alpha.22",
4
4
  "description": "Modern Angular 22 UI Library based on TailwindCSS",
5
5
  "keywords": [
6
6
  "angular",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@angular/core": "22",
40
- "@xui/core": "2.0.0-alpha.20",
40
+ "@xui/core": "2.0.0-alpha.22",
41
41
  "class-variance-authority": "^0.7.1",
42
42
  "clsx": "^2.1.1"
43
43
  },
@@ -10,10 +10,28 @@ declare const labelVariants: (props?: ({
10
10
  disabled?: boolean | "auto" | null | undefined;
11
11
  } & class_variance_authority_types.ClassProp) | undefined) => string;
12
12
  type XuiLabelVariants = VariantProps<typeof labelVariants>;
13
+ /**
14
+ * Styles a `<label>` and keeps it in step with the control it names.
15
+ *
16
+ * ```html
17
+ * <label xuiLabel for="email">Email</label>
18
+ * <label xuiLabel>Email <input xuiInput /></label>
19
+ * ```
20
+ *
21
+ * Composes `XLabel` from `@xui/core/label`, so it mirrors the bound control's `ng-invalid`/`ng-touched`
22
+ * state and its `data-disabled`: an invalid, touched field turns its label red and a disabled one dims
23
+ * it, with no binding on the label itself.
24
+ */
13
25
  declare class XuiLabel {
14
26
  private readonly xLabel;
27
+ /** Extra classes, merged into the directive's own rather than replacing them. */
15
28
  readonly class: _angular_core.InputSignal<ClassValue>;
29
+ /** Reserved for future label styles; `default` is currently the only one. */
16
30
  readonly variant: _angular_core.InputSignal<"default" | null | undefined>;
31
+ /**
32
+ * Whether to render the error appearance. `auto` (the default) follows the wrapped control's
33
+ * `ng-invalid.ng-touched` state; `true` forces it on for a control the label cannot see.
34
+ */
17
35
  readonly error: _angular_core.InputSignal<boolean | "auto" | null | undefined>;
18
36
  /** Follows the `error` input until `setError` overrides it. */
19
37
  private readonly errorState;