@vialiq/web-components 0.21.0 → 0.22.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/index.d.ts +2 -0
- package/index.js +1 -0
- package/input/vi-input.js +1 -1
- package/label/index.d.ts +2 -0
- package/label/index.d.ts.map +1 -0
- package/label/index.js +1 -0
- package/label/vi-label.d.ts +53 -0
- package/label/vi-label.d.ts.map +1 -0
- package/label/vi-label.js +552 -0
- package/package.json +12 -3
package/index.d.ts
CHANGED
|
@@ -46,4 +46,6 @@ export { ViComboboxItem } from './combobox/vi-combobox-item.js';
|
|
|
46
46
|
export { ViDatePicker, VIALIQ_CHANGE } from './date-picker/vi-date-picker.js';
|
|
47
47
|
export { ViDatePickerInput } from './date-picker/vi-date-picker-input.js';
|
|
48
48
|
export type { DatePickerMode, DatePickerChangeDetail } from './date-picker/types.js';
|
|
49
|
+
export { ViLabel } from './label/vi-label.js';
|
|
50
|
+
export type { LabelSize } from './label/vi-label.js';
|
|
49
51
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -27,3 +27,4 @@ export { ViCombobox } from './combobox/vi-combobox.js';
|
|
|
27
27
|
export { ViComboboxItem } from './combobox/vi-combobox-item.js';
|
|
28
28
|
export { VIALIQ_CHANGE, ViDatePicker } from './date-picker/vi-date-picker.js';
|
|
29
29
|
export { ViDatePickerInput } from './date-picker/vi-date-picker-input.js';
|
|
30
|
+
export { ViLabel } from './label/vi-label.js';
|
package/input/vi-input.js
CHANGED
|
@@ -5,7 +5,7 @@ import { V as ValidityMixin } from '../validity-mixin-DO0ycRH2.js';
|
|
|
5
5
|
import { V as ViElement } from '../vi-element-C6GfDPs3.js';
|
|
6
6
|
import { i as ifNonEmpty } from '../if-non-empty-DX8UGa-B.js';
|
|
7
7
|
|
|
8
|
-
const inputStyles = "@charset \"UTF-8\";@layer reset,components,utilities;@layer components{.input-field{display:flex;flex-direction:column;gap:var(--vi-input-spacing-field-gap, var(--vi-spacing-xs, 8px));width:100%}.input-control{appearance:none;-webkit-appearance:none;display:block;width:100%;box-sizing:border-box;min-height:var(--vi-input-sizing-min-height, 40px);border:var(--vi-border-width-thin, 1px) solid var(--vi-input-border-color, var(--vi-outline, #e5e7eb));border-radius:var(--vi-input-shape-border-radius, var(--vi-border-radius-lg, 8px));padding:var(--vi-input-spacing-padding-block, var(--vi-spacing-xs, 8px)) var(--vi-input-spacing-padding-inline, var(--vi-spacing-sm, 16px));font-family:var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);font-size:var(--vi-input-typography-font-size, var(--vi-font-size-base, 16px));font-weight:var(--vi-font-weight-normal, 400);line-height:var(--vi-input-typography-line-height, var(--vi-line-height-normal, 1.5));color:var(--vi-input-text-color, var(--vi-text-primary, #111827));background-color:var(--vi-input-background-color, var(--vi-color-background, #ffffff));transition:border-color .15s ease,box-shadow .15s ease}.input-control:hover:not(:focus-visible){border-color:var(--vi-input-border-color-hover, var(--vi-text-secondary, #4b5563))}.input-control:focus-visible,.input-control:focus{outline:var(--vi-border-width-base, 2px) solid var(--vi-input-focus-ring-color, var(--vi-focus, #3676d0));outline-offset:0;box-shadow:0 0 0 3px var(--vi-input-focus-ring-glow, var(--vi-color-blue-200, #cee6ff))}.input-control::placeholder{color:var(--vi-input-placeholder-color, var(--vi-text-secondary, #4b5563))}.input-helper{font-size:var(--vi-input-helper-size, var(--vi-font-size-xs, 12px));line-height:var(--vi-input-helper-leading, var(--vi-line-height-normal, 1.5));color:var(--vi-input-helper-color, var(--vi-text-helper, #9e9e9e))}.input-error{font-size:var(--vi-input-error-size, var(--vi-font-size-xs, 12px));line-height:var(--vi-input-error-leading, var(--vi-line-height-normal, 1.5));color:var(--vi-input-error-color, var(--vi-color-error, #ef4444))}@media(prefers-reduced-motion:reduce){.input-control{transition:none}}}:host{display:block;outline:none}:host([disabled]){
|
|
8
|
+
const inputStyles = "@charset \"UTF-8\";@layer reset,components,utilities;@layer components{.input-field{display:flex;flex-direction:column;gap:var(--vi-input-spacing-field-gap, var(--vi-spacing-xs, 8px));width:100%}.input-control{appearance:none;-webkit-appearance:none;display:block;width:100%;box-sizing:border-box;min-height:var(--vi-input-sizing-min-height, 40px);border:var(--vi-border-width-thin, 1px) solid var(--vi-input-border-color, var(--vi-outline, #e5e7eb));border-radius:var(--vi-input-shape-border-radius, var(--vi-border-radius-lg, 8px));padding:var(--vi-input-spacing-padding-block, var(--vi-spacing-xs, 8px)) var(--vi-input-spacing-padding-inline, var(--vi-spacing-sm, 16px));font-family:var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);font-size:var(--vi-input-typography-font-size, var(--vi-font-size-base, 16px));font-weight:var(--vi-font-weight-normal, 400);line-height:var(--vi-input-typography-line-height, var(--vi-line-height-normal, 1.5));color:var(--vi-input-text-color, var(--vi-text-primary, #111827));background-color:var(--vi-input-background-color, var(--vi-color-background, #ffffff));transition:border-color .15s ease,box-shadow .15s ease}.input-control:hover:not(:focus-visible){border-color:var(--vi-input-border-color-hover, var(--vi-text-secondary, #4b5563))}.input-control:focus-visible,.input-control:focus{outline:var(--vi-border-width-base, 2px) solid var(--vi-input-focus-ring-color, var(--vi-focus, #3676d0));outline-offset:0;box-shadow:0 0 0 3px var(--vi-input-focus-ring-glow, var(--vi-color-blue-200, #cee6ff))}.input-control::placeholder{color:var(--vi-input-placeholder-color, var(--vi-text-secondary, #4b5563))}.input-control:disabled{cursor:not-allowed;background-color:var(--vi-input-bg-disabled, var(--vi-layer-disabled, #f3f4f6));color:var(--vi-input-text-disabled, var(--vi-text-disabled, #9e9e9e));border-color:var(--vi-input-border-disabled, var(--vi-border-02, #eeeeee))}.input-helper{font-size:var(--vi-input-helper-size, var(--vi-font-size-xs, 12px));line-height:var(--vi-input-helper-leading, var(--vi-line-height-normal, 1.5));color:var(--vi-input-helper-color, var(--vi-text-helper, #9e9e9e))}.input-error{font-size:var(--vi-input-error-size, var(--vi-font-size-xs, 12px));line-height:var(--vi-input-error-leading, var(--vi-line-height-normal, 1.5));color:var(--vi-input-error-color, var(--vi-color-error, #ef4444))}@media(prefers-reduced-motion:reduce){.input-control{transition:none}}}:host{display:block;outline:none}:host([disabled]){cursor:not-allowed}:host([status=invalid]){--vi-input-border-color: var(--vi-color-error, #ef4444);--vi-input-border-color-hover: var(--vi-color-error, #ef4444);--vi-input-focus-ring-color: var(--vi-color-error, #ef4444);--vi-input-focus-ring-glow: var(--vi-color-red-100, #ffccce);--vi-input-label-color: var(--vi-color-error, #ef4444)}:host([status=valid]){--vi-input-border-color: var(--vi-color-success, #489167);--vi-input-border-color-hover: var(--vi-color-success, #489167);--vi-input-focus-ring-color: var(--vi-color-success, #489167);--vi-input-focus-ring-glow: var(--vi-color-green-100, #e6f0eb)}.input-validation{font-family:var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);font-size:var(--vi-font-size-xs, 12px);line-height:var(--vi-line-height-normal, 1.5);letter-spacing:var(--vi-letter-spacing-wider, .05em);color:var(--vi-input-helper-color, var(--vi-text-helper, #9e9e9e))}.input-validation--invalid{color:var(--vi-input-error-color, var(--vi-color-error, #ef4444))}.input-validation--valid{color:var(--vi-input-success-color, var(--vi-color-success, #489167))}::slotted([slot=helper]){font-family:var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);font-size:var(--vi-font-size-xs, 12px);line-height:var(--vi-line-height-normal, 1.5);letter-spacing:var(--vi-letter-spacing-wider, .05em);color:var(--vi-input-helper-color, var(--vi-text-helper, #9e9e9e))}:host([size=xs]){--vi-input-spacing-padding-block: 2px;--vi-input-spacing-padding-inline: 8px;--vi-input-typography-font-size: var(--vi-font-size-xs, 12px)}:host([size=sm]){--vi-input-spacing-padding-block: 4px;--vi-input-spacing-padding-inline: 12px;--vi-input-typography-font-size: var(--vi-font-size-sm, 14px)}:host([size=lg]){--vi-input-spacing-padding-block: 12px;--vi-input-spacing-padding-inline: 20px;--vi-input-typography-font-size: var(--vi-font-size-lg, 18px)}";
|
|
9
9
|
|
|
10
10
|
function applyDecs2203RFactory() {
|
|
11
11
|
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
package/label/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../libs/web-components/src/label/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
package/label/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ViLabel } from './vi-label.js';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { ViElement } from '../base/vi-element.js';
|
|
3
|
+
export type LabelSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
export type LabelLayout = 'stacked' | 'inline';
|
|
5
|
+
export type LabelType = 'default' | 'primary' | 'secondary';
|
|
6
|
+
/**
|
|
7
|
+
* `vi-label`
|
|
8
|
+
*
|
|
9
|
+
* A styled `<label>` element for associating visible text with form controls.
|
|
10
|
+
*
|
|
11
|
+
* @element vi-label
|
|
12
|
+
*
|
|
13
|
+
* @attr {string} for - ID of the associated control
|
|
14
|
+
* @attr {boolean} required - Show required `*` indicator
|
|
15
|
+
* @attr {boolean} optional - Show "(optional)" text
|
|
16
|
+
* @attr {boolean} disabled - Muted disabled styling
|
|
17
|
+
* @attr {string} size - Font size variant ('sm', 'md', 'lg')
|
|
18
|
+
*
|
|
19
|
+
* @slot - Default slot for label text
|
|
20
|
+
* @slot tooltip - Inline help icon that triggers a tooltip
|
|
21
|
+
*
|
|
22
|
+
* @csspart label - The `<label>` element
|
|
23
|
+
* @csspart required-indicator - The `*` asterisk `<span>`
|
|
24
|
+
* @csspart optional-indicator - The "(optional)" `<span>`
|
|
25
|
+
* @csspart tooltip-trigger - Tooltip icon wrapper
|
|
26
|
+
*/
|
|
27
|
+
export declare class ViLabel extends ViElement {
|
|
28
|
+
static styles: import('lit').CSSResult;
|
|
29
|
+
/** ID of the associated control */
|
|
30
|
+
accessor for: string;
|
|
31
|
+
/** Show required `*` indicator */
|
|
32
|
+
accessor required: boolean;
|
|
33
|
+
/** Show "(optional)" text */
|
|
34
|
+
accessor optional: boolean;
|
|
35
|
+
/** Muted disabled styling */
|
|
36
|
+
accessor disabled: boolean;
|
|
37
|
+
/** Font size variant */
|
|
38
|
+
accessor size: LabelSize;
|
|
39
|
+
/** Layout spacing behavior */
|
|
40
|
+
accessor layout: LabelLayout;
|
|
41
|
+
/** Semantic text color */
|
|
42
|
+
accessor type: LabelType;
|
|
43
|
+
private _hasTooltip;
|
|
44
|
+
private _handleSlotChange;
|
|
45
|
+
private _handleClick;
|
|
46
|
+
render(): TemplateResult;
|
|
47
|
+
}
|
|
48
|
+
declare global {
|
|
49
|
+
interface HTMLElementTagNameMap {
|
|
50
|
+
'vi-label': ViLabel;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=vi-label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vi-label.d.ts","sourceRoot":"","sources":["../../../../libs/web-components/src/label/vi-label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAGzE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC3C,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC/C,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBACa,OAAQ,SAAQ,SAAS;IACpC,OAAgB,MAAM,0BAEpB;IAEF,mCAAmC;IACP,QAAQ,CAAC,GAAG,SAAM;IAE9C,kCAAkC;IACL,QAAQ,CAAC,QAAQ,UAAS;IAEvD,6BAA6B;IACA,QAAQ,CAAC,QAAQ,UAAS;IAEvD,6BAA6B;IACe,QAAQ,CAAC,QAAQ,UAAS;IAEtE,wBAAwB;IACI,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAQ;IAE5D,8BAA8B;IACa,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAa;IAEpF,0BAA0B;IACiB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAa;IAEhF,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,YAAY;IAeX,MAAM,IAAI,cAAc;CA6BlC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,OAAO,CAAC;KACrB;CACF"}
|
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
import { unsafeCSS, css, nothing, html } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import { V as ViElement } from '../vi-element-C6GfDPs3.js';
|
|
5
|
+
|
|
6
|
+
const labelStyles = "@charset \"UTF-8\";@layer reset,components,utilities;@layer components{.vi-label{--vi-label-font-size: var(--vi-font-size-sm, var(--vi-font-size-sm, 14px));--vi-label-font-weight: var(--vi-font-weight-medium, var(--vi-font-weight-medium, 500));--vi-label-color: var(--vi-text-primary, var(--vi-text-primary, #111827));--vi-label-color-disabled: var(--vi-text-disabled, var(--vi-text-disabled, #9e9e9e));--vi-label-required-color: var(--vi-color-error, var(--vi-color-error, #ef4444));--vi-label-optional-color: var(--vi-text-helper, var(--vi-text-helper, #9e9e9e));--vi-label-gap: 4px}.vi-label{display:inline-flex;align-items:center;gap:var(--vi-label-gap);font-size:var(--vi-label-font-size);font-weight:var(--vi-label-font-weight);color:var(--vi-label-color);line-height:1.5;margin:0}.vi-label.size-sm{--vi-label-font-size: var(--vi-font-size-xs, var(--vi-font-size-xs, 12px))}.vi-label.size-lg{--vi-label-font-size: var(--vi-font-size-base, var(--vi-font-size-base, 16px))}.vi-label.is-disabled{color:var(--vi-label-color-disabled);cursor:default}.vi-label-required{color:var(--vi-label-required-color)}.vi-label-optional{color:var(--vi-label-optional-color);font-weight:400}}:host{vertical-align:middle}:host([layout=stacked]){display:block;margin-bottom:var(--vi-label-margin-bottom, 8px)}:host([layout=inline]){display:inline-flex;align-items:center;margin-right:var(--vi-label-margin-inline, 12px);margin-bottom:0}:host([type=primary]) .vi-label{--vi-label-color: var(--vi-color-text-primary, var(--vi-text-primary, #111827))}:host([type=secondary]) .vi-label{--vi-label-color: var(--vi-color-text-secondary, var(--vi-text-secondary, #4b5563))}";
|
|
7
|
+
|
|
8
|
+
function applyDecs2203RFactory() {
|
|
9
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
10
|
+
return function addInitializer(initializer) {
|
|
11
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
12
|
+
assertCallable(initializer, "An initializer");
|
|
13
|
+
initializers.push(initializer);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
17
|
+
var kindStr;
|
|
18
|
+
switch(kind){
|
|
19
|
+
case 1:
|
|
20
|
+
kindStr = "accessor";
|
|
21
|
+
break;
|
|
22
|
+
case 2:
|
|
23
|
+
kindStr = "method";
|
|
24
|
+
break;
|
|
25
|
+
case 3:
|
|
26
|
+
kindStr = "getter";
|
|
27
|
+
break;
|
|
28
|
+
case 4:
|
|
29
|
+
kindStr = "setter";
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
kindStr = "field";
|
|
33
|
+
}
|
|
34
|
+
var ctx = {
|
|
35
|
+
kind: kindStr,
|
|
36
|
+
name: isPrivate ? "#" + name : name,
|
|
37
|
+
static: isStatic,
|
|
38
|
+
private: isPrivate,
|
|
39
|
+
metadata: metadata
|
|
40
|
+
};
|
|
41
|
+
var decoratorFinishedRef = {
|
|
42
|
+
v: false
|
|
43
|
+
};
|
|
44
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
45
|
+
var get, set;
|
|
46
|
+
if (kind === 0) {
|
|
47
|
+
if (isPrivate) {
|
|
48
|
+
get = desc.get;
|
|
49
|
+
set = desc.set;
|
|
50
|
+
} else {
|
|
51
|
+
get = function() {
|
|
52
|
+
return this[name];
|
|
53
|
+
};
|
|
54
|
+
set = function(v) {
|
|
55
|
+
this[name] = v;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
} else if (kind === 2) {
|
|
59
|
+
get = function() {
|
|
60
|
+
return desc.value;
|
|
61
|
+
};
|
|
62
|
+
} else {
|
|
63
|
+
if (kind === 1 || kind === 3) {
|
|
64
|
+
get = function() {
|
|
65
|
+
return desc.get.call(this);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (kind === 1 || kind === 4) {
|
|
69
|
+
set = function(v) {
|
|
70
|
+
desc.set.call(this, v);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
ctx.access = get && set ? {
|
|
75
|
+
get: get,
|
|
76
|
+
set: set
|
|
77
|
+
} : get ? {
|
|
78
|
+
get: get
|
|
79
|
+
} : {
|
|
80
|
+
set: set
|
|
81
|
+
};
|
|
82
|
+
try {
|
|
83
|
+
return dec(value, ctx);
|
|
84
|
+
} finally{
|
|
85
|
+
decoratorFinishedRef.v = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
89
|
+
if (decoratorFinishedRef.v) {
|
|
90
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function assertCallable(fn, hint) {
|
|
94
|
+
if (typeof fn !== "function") {
|
|
95
|
+
throw new TypeError(hint + " must be a function");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function assertValidReturnValue(kind, value) {
|
|
99
|
+
var type = typeof value;
|
|
100
|
+
if (kind === 1) {
|
|
101
|
+
if (type !== "object" || value === null) {
|
|
102
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
103
|
+
}
|
|
104
|
+
if (value.get !== undefined) {
|
|
105
|
+
assertCallable(value.get, "accessor.get");
|
|
106
|
+
}
|
|
107
|
+
if (value.set !== undefined) {
|
|
108
|
+
assertCallable(value.set, "accessor.set");
|
|
109
|
+
}
|
|
110
|
+
if (value.init !== undefined) {
|
|
111
|
+
assertCallable(value.init, "accessor.init");
|
|
112
|
+
}
|
|
113
|
+
} else if (type !== "function") {
|
|
114
|
+
var hint;
|
|
115
|
+
if (kind === 0) {
|
|
116
|
+
hint = "field";
|
|
117
|
+
} else if (kind === 10) {
|
|
118
|
+
hint = "class";
|
|
119
|
+
} else {
|
|
120
|
+
hint = "method";
|
|
121
|
+
}
|
|
122
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
126
|
+
var decs = decInfo[0];
|
|
127
|
+
var desc, init, value;
|
|
128
|
+
if (isPrivate) {
|
|
129
|
+
if (kind === 0 || kind === 1) {
|
|
130
|
+
desc = {
|
|
131
|
+
get: decInfo[3],
|
|
132
|
+
set: decInfo[4]
|
|
133
|
+
};
|
|
134
|
+
} else if (kind === 3) {
|
|
135
|
+
desc = {
|
|
136
|
+
get: decInfo[3]
|
|
137
|
+
};
|
|
138
|
+
} else if (kind === 4) {
|
|
139
|
+
desc = {
|
|
140
|
+
set: decInfo[3]
|
|
141
|
+
};
|
|
142
|
+
} else {
|
|
143
|
+
desc = {
|
|
144
|
+
value: decInfo[3]
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
} else if (kind !== 0) {
|
|
148
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
149
|
+
}
|
|
150
|
+
if (kind === 1) {
|
|
151
|
+
value = {
|
|
152
|
+
get: desc.get,
|
|
153
|
+
set: desc.set
|
|
154
|
+
};
|
|
155
|
+
} else if (kind === 2) {
|
|
156
|
+
value = desc.value;
|
|
157
|
+
} else if (kind === 3) {
|
|
158
|
+
value = desc.get;
|
|
159
|
+
} else if (kind === 4) {
|
|
160
|
+
value = desc.set;
|
|
161
|
+
}
|
|
162
|
+
var newValue, get, set;
|
|
163
|
+
if (typeof decs === "function") {
|
|
164
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
165
|
+
if (newValue !== void 0) {
|
|
166
|
+
assertValidReturnValue(kind, newValue);
|
|
167
|
+
if (kind === 0) {
|
|
168
|
+
init = newValue;
|
|
169
|
+
} else if (kind === 1) {
|
|
170
|
+
init = newValue.init;
|
|
171
|
+
get = newValue.get || value.get;
|
|
172
|
+
set = newValue.set || value.set;
|
|
173
|
+
value = {
|
|
174
|
+
get: get,
|
|
175
|
+
set: set
|
|
176
|
+
};
|
|
177
|
+
} else {
|
|
178
|
+
value = newValue;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
for(var i = decs.length - 1; i >= 0; i--){
|
|
183
|
+
var dec = decs[i];
|
|
184
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
185
|
+
if (newValue !== void 0) {
|
|
186
|
+
assertValidReturnValue(kind, newValue);
|
|
187
|
+
var newInit;
|
|
188
|
+
if (kind === 0) {
|
|
189
|
+
newInit = newValue;
|
|
190
|
+
} else if (kind === 1) {
|
|
191
|
+
newInit = newValue.init;
|
|
192
|
+
get = newValue.get || value.get;
|
|
193
|
+
set = newValue.set || value.set;
|
|
194
|
+
value = {
|
|
195
|
+
get: get,
|
|
196
|
+
set: set
|
|
197
|
+
};
|
|
198
|
+
} else {
|
|
199
|
+
value = newValue;
|
|
200
|
+
}
|
|
201
|
+
if (newInit !== void 0) {
|
|
202
|
+
if (init === void 0) {
|
|
203
|
+
init = newInit;
|
|
204
|
+
} else if (typeof init === "function") {
|
|
205
|
+
init = [
|
|
206
|
+
init,
|
|
207
|
+
newInit
|
|
208
|
+
];
|
|
209
|
+
} else {
|
|
210
|
+
init.push(newInit);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (kind === 0 || kind === 1) {
|
|
217
|
+
if (init === void 0) {
|
|
218
|
+
init = function(instance, init) {
|
|
219
|
+
return init;
|
|
220
|
+
};
|
|
221
|
+
} else if (typeof init !== "function") {
|
|
222
|
+
var ownInitializers = init;
|
|
223
|
+
init = function(instance, init) {
|
|
224
|
+
var value = init;
|
|
225
|
+
for(var i = 0; i < ownInitializers.length; i++){
|
|
226
|
+
value = ownInitializers[i].call(instance, value);
|
|
227
|
+
}
|
|
228
|
+
return value;
|
|
229
|
+
};
|
|
230
|
+
} else {
|
|
231
|
+
var originalInitializer = init;
|
|
232
|
+
init = function(instance, init) {
|
|
233
|
+
return originalInitializer.call(instance, init);
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
ret.push(init);
|
|
237
|
+
}
|
|
238
|
+
if (kind !== 0) {
|
|
239
|
+
if (kind === 1) {
|
|
240
|
+
desc.get = value.get;
|
|
241
|
+
desc.set = value.set;
|
|
242
|
+
} else if (kind === 2) {
|
|
243
|
+
desc.value = value;
|
|
244
|
+
} else if (kind === 3) {
|
|
245
|
+
desc.get = value;
|
|
246
|
+
} else if (kind === 4) {
|
|
247
|
+
desc.set = value;
|
|
248
|
+
}
|
|
249
|
+
if (isPrivate) {
|
|
250
|
+
if (kind === 1) {
|
|
251
|
+
ret.push(function(instance, args) {
|
|
252
|
+
return value.get.call(instance, args);
|
|
253
|
+
});
|
|
254
|
+
ret.push(function(instance, args) {
|
|
255
|
+
return value.set.call(instance, args);
|
|
256
|
+
});
|
|
257
|
+
} else if (kind === 2) {
|
|
258
|
+
ret.push(value);
|
|
259
|
+
} else {
|
|
260
|
+
ret.push(function(instance, args) {
|
|
261
|
+
return value.call(instance, args);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
Object.defineProperty(base, name, desc);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
270
|
+
var ret = [];
|
|
271
|
+
var protoInitializers;
|
|
272
|
+
var staticInitializers;
|
|
273
|
+
var existingProtoNonFields = new Map();
|
|
274
|
+
var existingStaticNonFields = new Map();
|
|
275
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
276
|
+
var decInfo = decInfos[i];
|
|
277
|
+
if (!Array.isArray(decInfo)) continue;
|
|
278
|
+
var kind = decInfo[1];
|
|
279
|
+
var name = decInfo[2];
|
|
280
|
+
var isPrivate = decInfo.length > 3;
|
|
281
|
+
var isStatic = kind >= 5;
|
|
282
|
+
var base;
|
|
283
|
+
var initializers;
|
|
284
|
+
if (isStatic) {
|
|
285
|
+
base = Class;
|
|
286
|
+
kind = kind - 5;
|
|
287
|
+
staticInitializers = staticInitializers || [];
|
|
288
|
+
initializers = staticInitializers;
|
|
289
|
+
} else {
|
|
290
|
+
base = Class.prototype;
|
|
291
|
+
protoInitializers = protoInitializers || [];
|
|
292
|
+
initializers = protoInitializers;
|
|
293
|
+
}
|
|
294
|
+
if (kind !== 0 && !isPrivate) {
|
|
295
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
296
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
297
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
|
298
|
+
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
299
|
+
} else if (!existingKind && kind > 2) {
|
|
300
|
+
existingNonFields.set(name, kind);
|
|
301
|
+
} else {
|
|
302
|
+
existingNonFields.set(name, true);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
306
|
+
}
|
|
307
|
+
pushInitializers(ret, protoInitializers);
|
|
308
|
+
pushInitializers(ret, staticInitializers);
|
|
309
|
+
return ret;
|
|
310
|
+
}
|
|
311
|
+
function pushInitializers(ret, initializers) {
|
|
312
|
+
if (initializers) {
|
|
313
|
+
ret.push(function(instance) {
|
|
314
|
+
for(var i = 0; i < initializers.length; i++){
|
|
315
|
+
initializers[i].call(instance);
|
|
316
|
+
}
|
|
317
|
+
return instance;
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
322
|
+
if (classDecs.length > 0) {
|
|
323
|
+
var initializers = [];
|
|
324
|
+
var newClass = targetClass;
|
|
325
|
+
var name = targetClass.name;
|
|
326
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
327
|
+
var decoratorFinishedRef = {
|
|
328
|
+
v: false
|
|
329
|
+
};
|
|
330
|
+
try {
|
|
331
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
332
|
+
kind: "class",
|
|
333
|
+
name: name,
|
|
334
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
335
|
+
metadata
|
|
336
|
+
});
|
|
337
|
+
} finally{
|
|
338
|
+
decoratorFinishedRef.v = true;
|
|
339
|
+
}
|
|
340
|
+
if (nextNewClass !== undefined) {
|
|
341
|
+
assertValidReturnValue(10, nextNewClass);
|
|
342
|
+
newClass = nextNewClass;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return [
|
|
346
|
+
defineMetadata(newClass, metadata),
|
|
347
|
+
function() {
|
|
348
|
+
for(var i = 0; i < initializers.length; i++){
|
|
349
|
+
initializers[i].call(newClass);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
];
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function defineMetadata(Class, metadata) {
|
|
356
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
357
|
+
configurable: true,
|
|
358
|
+
enumerable: true,
|
|
359
|
+
value: metadata
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
363
|
+
if (parentClass !== void 0) {
|
|
364
|
+
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
365
|
+
}
|
|
366
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
367
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
368
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
369
|
+
return {
|
|
370
|
+
e: e,
|
|
371
|
+
get c () {
|
|
372
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
378
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
379
|
+
}
|
|
380
|
+
function _identity(x) {
|
|
381
|
+
return x;
|
|
382
|
+
}
|
|
383
|
+
var _dec, _initClass, _ViElement, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, /** ID of the associated control */ _init_for, /** Show required `*` indicator */ _init_required, /** Show "(optional)" text */ _init_optional, /** Muted disabled styling */ _init_disabled, /** Font size variant */ _init_size, /** Layout spacing behavior */ _init_layout, /** Semantic text color */ _init_type, _initProto;
|
|
384
|
+
let _ViLabel;
|
|
385
|
+
_dec = customElement('vi-label'), _dec1 = property({
|
|
386
|
+
type: String
|
|
387
|
+
}), _dec2 = property({
|
|
388
|
+
type: Boolean
|
|
389
|
+
}), _dec3 = property({
|
|
390
|
+
type: Boolean
|
|
391
|
+
}), _dec4 = property({
|
|
392
|
+
type: Boolean,
|
|
393
|
+
reflect: true
|
|
394
|
+
}), _dec5 = property({
|
|
395
|
+
type: String
|
|
396
|
+
}), _dec6 = property({
|
|
397
|
+
type: String,
|
|
398
|
+
reflect: true
|
|
399
|
+
}), _dec7 = property({
|
|
400
|
+
type: String,
|
|
401
|
+
reflect: true
|
|
402
|
+
});
|
|
403
|
+
new class extends _identity {
|
|
404
|
+
constructor(){
|
|
405
|
+
super(_ViLabel), _initClass();
|
|
406
|
+
}
|
|
407
|
+
static{
|
|
408
|
+
class ViLabel extends (_ViElement = ViElement) {
|
|
409
|
+
static{
|
|
410
|
+
({ e: [_init_for, _init_required, _init_optional, _init_disabled, _init_size, _init_layout, _init_type, _initProto], c: [_ViLabel, _initClass] } = _apply_decs_2203_r(this, [
|
|
411
|
+
[
|
|
412
|
+
_dec1,
|
|
413
|
+
1,
|
|
414
|
+
"for"
|
|
415
|
+
],
|
|
416
|
+
[
|
|
417
|
+
_dec2,
|
|
418
|
+
1,
|
|
419
|
+
"required"
|
|
420
|
+
],
|
|
421
|
+
[
|
|
422
|
+
_dec3,
|
|
423
|
+
1,
|
|
424
|
+
"optional"
|
|
425
|
+
],
|
|
426
|
+
[
|
|
427
|
+
_dec4,
|
|
428
|
+
1,
|
|
429
|
+
"disabled"
|
|
430
|
+
],
|
|
431
|
+
[
|
|
432
|
+
_dec5,
|
|
433
|
+
1,
|
|
434
|
+
"size"
|
|
435
|
+
],
|
|
436
|
+
[
|
|
437
|
+
_dec6,
|
|
438
|
+
1,
|
|
439
|
+
"layout"
|
|
440
|
+
],
|
|
441
|
+
[
|
|
442
|
+
_dec7,
|
|
443
|
+
1,
|
|
444
|
+
"type"
|
|
445
|
+
]
|
|
446
|
+
], [
|
|
447
|
+
_dec
|
|
448
|
+
], _ViElement));
|
|
449
|
+
}
|
|
450
|
+
static styles = css`
|
|
451
|
+
${unsafeCSS(labelStyles)}
|
|
452
|
+
`;
|
|
453
|
+
#___private_for_1 = (_initProto(this), _init_for(this, ''));
|
|
454
|
+
get for() {
|
|
455
|
+
return this.#___private_for_1;
|
|
456
|
+
}
|
|
457
|
+
set for(_v) {
|
|
458
|
+
this.#___private_for_1 = _v;
|
|
459
|
+
}
|
|
460
|
+
#___private_required_2 = _init_required(this, false);
|
|
461
|
+
get required() {
|
|
462
|
+
return this.#___private_required_2;
|
|
463
|
+
}
|
|
464
|
+
set required(_v) {
|
|
465
|
+
this.#___private_required_2 = _v;
|
|
466
|
+
}
|
|
467
|
+
#___private_optional_3 = _init_optional(this, false);
|
|
468
|
+
get optional() {
|
|
469
|
+
return this.#___private_optional_3;
|
|
470
|
+
}
|
|
471
|
+
set optional(_v) {
|
|
472
|
+
this.#___private_optional_3 = _v;
|
|
473
|
+
}
|
|
474
|
+
#___private_disabled_4 = _init_disabled(this, false);
|
|
475
|
+
get disabled() {
|
|
476
|
+
return this.#___private_disabled_4;
|
|
477
|
+
}
|
|
478
|
+
set disabled(_v) {
|
|
479
|
+
this.#___private_disabled_4 = _v;
|
|
480
|
+
}
|
|
481
|
+
#___private_size_5 = _init_size(this, 'md');
|
|
482
|
+
get size() {
|
|
483
|
+
return this.#___private_size_5;
|
|
484
|
+
}
|
|
485
|
+
set size(_v) {
|
|
486
|
+
this.#___private_size_5 = _v;
|
|
487
|
+
}
|
|
488
|
+
#___private_layout_6 = _init_layout(this, 'stacked');
|
|
489
|
+
get layout() {
|
|
490
|
+
return this.#___private_layout_6;
|
|
491
|
+
}
|
|
492
|
+
set layout(_v) {
|
|
493
|
+
this.#___private_layout_6 = _v;
|
|
494
|
+
}
|
|
495
|
+
#___private_type_7 = _init_type(this, 'default');
|
|
496
|
+
get type() {
|
|
497
|
+
return this.#___private_type_7;
|
|
498
|
+
}
|
|
499
|
+
set type(_v) {
|
|
500
|
+
this.#___private_type_7 = _v;
|
|
501
|
+
}
|
|
502
|
+
_hasTooltip = false;
|
|
503
|
+
_handleSlotChange(e) {
|
|
504
|
+
const slot = e.target;
|
|
505
|
+
const nodes = slot.assignedNodes({
|
|
506
|
+
flatten: true
|
|
507
|
+
});
|
|
508
|
+
this._hasTooltip = nodes.some((node)=>node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim()));
|
|
509
|
+
this.requestUpdate();
|
|
510
|
+
}
|
|
511
|
+
_handleClick(e) {
|
|
512
|
+
if (this.disabled || !this.for) return;
|
|
513
|
+
e.preventDefault();
|
|
514
|
+
// Cross shadow boundary workaround
|
|
515
|
+
const rootNode = this.getRootNode();
|
|
516
|
+
const target = rootNode.getElementById(this.for);
|
|
517
|
+
if (target) {
|
|
518
|
+
target.focus();
|
|
519
|
+
if ('click' in target && typeof target.click === 'function') {
|
|
520
|
+
target.click();
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
render() {
|
|
525
|
+
const classes = {
|
|
526
|
+
'vi-label': true,
|
|
527
|
+
[`size-${this.size}`]: true,
|
|
528
|
+
'is-disabled': this.disabled
|
|
529
|
+
};
|
|
530
|
+
return html`
|
|
531
|
+
<label part="label" class=${classMap(classes)} for=${this.for || nothing} @click=${this._handleClick}>
|
|
532
|
+
<slot></slot>
|
|
533
|
+
|
|
534
|
+
${this.required ? html`
|
|
535
|
+
<span part="required-indicator" class="vi-label-required" aria-hidden="true">*</span>
|
|
536
|
+
` : nothing}
|
|
537
|
+
|
|
538
|
+
${this.optional && !this.required ? html`
|
|
539
|
+
<span part="optional-indicator" class="vi-label-optional">(optional)</span>
|
|
540
|
+
` : nothing}
|
|
541
|
+
|
|
542
|
+
<span part="tooltip-trigger" style=${!this._hasTooltip ? 'display: none;' : nothing}>
|
|
543
|
+
<slot name="tooltip" @slotchange=${this._handleSlotChange}></slot>
|
|
544
|
+
</span>
|
|
545
|
+
</label>
|
|
546
|
+
`;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}();
|
|
551
|
+
|
|
552
|
+
export { _ViLabel as ViLabel };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vialiq/web-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -111,12 +111,20 @@
|
|
|
111
111
|
"./date-picker/vi-date-picker-input": {
|
|
112
112
|
"types": "./date-picker/vi-date-picker-input.d.ts",
|
|
113
113
|
"default": "./date-picker/vi-date-picker-input.js"
|
|
114
|
+
},
|
|
115
|
+
"./label": {
|
|
116
|
+
"types": "./label/index.d.ts",
|
|
117
|
+
"default": "./label/index.js"
|
|
118
|
+
},
|
|
119
|
+
"./label/vi-label": {
|
|
120
|
+
"types": "./label/vi-label.d.ts",
|
|
121
|
+
"default": "./label/vi-label.js"
|
|
114
122
|
}
|
|
115
123
|
},
|
|
116
124
|
"peerDependencies": {
|
|
117
125
|
"@floating-ui/dom": ">=1.0.0",
|
|
118
|
-
"@vialiq/flux-ui": "^0.
|
|
119
|
-
"@vialiq/icons": "^0.4.
|
|
126
|
+
"@vialiq/flux-ui": "^0.18.0",
|
|
127
|
+
"@vialiq/icons": "^0.4.1",
|
|
120
128
|
"flatpickr": ">=4.6.0",
|
|
121
129
|
"lit": "^3.0.0"
|
|
122
130
|
},
|
|
@@ -140,6 +148,7 @@
|
|
|
140
148
|
"tooltip/",
|
|
141
149
|
"badge/",
|
|
142
150
|
"date-picker/",
|
|
151
|
+
"label/",
|
|
143
152
|
"README.md"
|
|
144
153
|
],
|
|
145
154
|
"peerDependenciesMeta": {
|