@vialiq/web-components 0.1.3 → 0.3.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/base/focus-trap-mixin.d.ts +121 -0
- package/base/focus-trap-mixin.d.ts.map +1 -0
- package/base/focusable-mixin.d.ts +82 -0
- package/base/focusable-mixin.d.ts.map +1 -0
- package/base/focusable-selector.d.ts +80 -0
- package/base/focusable-selector.d.ts.map +1 -0
- package/base/if-non-empty.d.ts +62 -0
- package/base/if-non-empty.d.ts.map +1 -0
- package/base/validity-mixin.d.ts +231 -0
- package/base/validity-mixin.d.ts.map +1 -0
- package/base/vi-element.d.ts +12 -0
- package/base/vi-element.d.ts.map +1 -0
- package/button/index.d.ts +2 -0
- package/button/index.d.ts.map +1 -0
- package/button/vi-button.d.ts +68 -0
- package/button/vi-button.d.ts.map +1 -0
- package/button/vi-button.js +3 -152
- package/focusable-mixin-CmxOyPX5.js +155 -0
- package/icons/registry.d.ts +29 -0
- package/icons/registry.d.ts.map +1 -0
- package/icons/vi-icon.d.ts +47 -0
- package/icons/vi-icon.d.ts.map +1 -0
- package/index.d.ts +14 -0
- package/index.js +3 -0
- package/input/index.d.ts +3 -0
- package/input/index.d.ts.map +1 -0
- package/input/vi-input.d.ts +89 -0
- package/input/vi-input.d.ts.map +1 -0
- package/input/vi-input.js +723 -0
- package/package.json +20 -3
- package/validity-mixin-BjmXwgWk.js +216 -0
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
import { unsafeCSS, css, html } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { F as FocusableMixin } from '../focusable-mixin-CmxOyPX5.js';
|
|
4
|
+
import { V as ValidityMixin } from '../validity-mixin-BjmXwgWk.js';
|
|
5
|
+
import { V as ViElement } from '../vi-element-C6GfDPs3.js';
|
|
6
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ifNonEmpty — conditional attribute directive
|
|
10
|
+
*
|
|
11
|
+
* A wrapper around Lit's `ifDefined` that additionally removes the attribute
|
|
12
|
+
* when the value is an empty string. Use this for every optional string
|
|
13
|
+
* attribute on inner native elements where `""` and "absent" have different
|
|
14
|
+
* meaning for browsers and screen readers.
|
|
15
|
+
*
|
|
16
|
+
* Problem with raw `ifDefined`:
|
|
17
|
+
* - `ifDefined(undefined)` → removes the attribute ✅
|
|
18
|
+
* - `ifDefined(null)` → removes the attribute ✅
|
|
19
|
+
* - `ifDefined('')` → sets attribute to "" ❌
|
|
20
|
+
*
|
|
21
|
+
* With `ifNonEmpty`:
|
|
22
|
+
* - `ifNonEmpty(undefined)` → removes the attribute ✅
|
|
23
|
+
* - `ifNonEmpty(null)` → removes the attribute ✅
|
|
24
|
+
* - `ifNonEmpty('')` → removes the attribute ✅
|
|
25
|
+
* - `ifNonEmpty('hello')` → sets attribute to "hello" ✅
|
|
26
|
+
*
|
|
27
|
+
* Why it matters — real screen reader / browser bugs caused by `=""`:
|
|
28
|
+
* - `placeholder=""` → JAWS/NVDA still announce it as an empty placeholder
|
|
29
|
+
* - `aria-label=""` → NVDA reads "blank" instead of deriving the name elsewhere
|
|
30
|
+
* - `aria-describedby=""`→ browsers may still look for id="" element
|
|
31
|
+
* - `title=""` → browsers show an empty tooltip on hover in some engines
|
|
32
|
+
*
|
|
33
|
+
* ---
|
|
34
|
+
*
|
|
35
|
+
* USAGE
|
|
36
|
+
*
|
|
37
|
+
* Import in any shadow template that has optional string attributes:
|
|
38
|
+
*
|
|
39
|
+
* import { ifNonEmpty } from '../base/if-non-empty.js';
|
|
40
|
+
*
|
|
41
|
+
* In the template:
|
|
42
|
+
*
|
|
43
|
+
* // ✅ Use ifNonEmpty for optional string attributes on inner native elements
|
|
44
|
+
* <input
|
|
45
|
+
* placeholder=${ifNonEmpty(this.placeholder)}
|
|
46
|
+
* aria-label=${ifNonEmpty(this.label)}
|
|
47
|
+
* aria-describedby=${ifNonEmpty(this._descriptionId)}
|
|
48
|
+
* />
|
|
49
|
+
*
|
|
50
|
+
* // ❌ Do NOT use for boolean attributes — Lit has ?attr=${bool} for that
|
|
51
|
+
* // ❌ Do NOT use for property bindings — Lit has .prop=${val} for that
|
|
52
|
+
* // ❌ Do NOT use for event bindings — Lit has @event=${handler} for that
|
|
53
|
+
*
|
|
54
|
+
* ---
|
|
55
|
+
*
|
|
56
|
+
* WHEN TO USE vs NOT USE
|
|
57
|
+
*
|
|
58
|
+
* Use ifNonEmpty when:
|
|
59
|
+
* - The attribute is optional (component has a prop that defaults to '')
|
|
60
|
+
* - The inner native element is a standard HTML element (input, button, a, etc.)
|
|
61
|
+
* - The attribute has accessibility or UI meaning when absent vs present
|
|
62
|
+
*
|
|
63
|
+
* Skip ifNonEmpty when:
|
|
64
|
+
* - The attribute is always required (e.g. type="button" is never absent)
|
|
65
|
+
* - You need the attribute to literally be "" (rare, document when intentional)
|
|
66
|
+
* - The binding is to a custom element property — use .prop=${val} instead
|
|
67
|
+
*/ const ifNonEmpty = (value)=>ifDefined(value === '' ? undefined : value ?? undefined);
|
|
68
|
+
|
|
69
|
+
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-color-grey-300, #e0e0e0));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-color-foreground, #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-color-grey-500, #9e9e9e))}.input-control:focus-visible,.input-control:focus{outline:var(--vi-border-width-base, 2px) solid var(--vi-input-focus-ring-color, var(--vi-color-primary, #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-color-grey-500, #9e9e9e))}.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-color-grey-500, #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]){opacity:.6;cursor:not-allowed;pointer-events:none}:host([status=invalid]){--vi-input-border-color: var(--vi-color-error, #ef4444);--vi-input-border-color-hover: var(--vi-color-red-700, #db231b);--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-green-700, #265a3d);--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-color-grey-500, #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-color-grey-500, #9e9e9e))}";
|
|
70
|
+
|
|
71
|
+
function applyDecs2203RFactory() {
|
|
72
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
73
|
+
return function addInitializer(initializer) {
|
|
74
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
75
|
+
assertCallable(initializer, "An initializer");
|
|
76
|
+
initializers.push(initializer);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
80
|
+
var kindStr;
|
|
81
|
+
switch(kind){
|
|
82
|
+
case 1:
|
|
83
|
+
kindStr = "accessor";
|
|
84
|
+
break;
|
|
85
|
+
case 2:
|
|
86
|
+
kindStr = "method";
|
|
87
|
+
break;
|
|
88
|
+
case 3:
|
|
89
|
+
kindStr = "getter";
|
|
90
|
+
break;
|
|
91
|
+
case 4:
|
|
92
|
+
kindStr = "setter";
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
kindStr = "field";
|
|
96
|
+
}
|
|
97
|
+
var ctx = {
|
|
98
|
+
kind: kindStr,
|
|
99
|
+
name: isPrivate ? "#" + name : name,
|
|
100
|
+
static: isStatic,
|
|
101
|
+
private: isPrivate,
|
|
102
|
+
metadata: metadata
|
|
103
|
+
};
|
|
104
|
+
var decoratorFinishedRef = {
|
|
105
|
+
v: false
|
|
106
|
+
};
|
|
107
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
108
|
+
var get, set;
|
|
109
|
+
if (kind === 0) {
|
|
110
|
+
if (isPrivate) {
|
|
111
|
+
get = desc.get;
|
|
112
|
+
set = desc.set;
|
|
113
|
+
} else {
|
|
114
|
+
get = function() {
|
|
115
|
+
return this[name];
|
|
116
|
+
};
|
|
117
|
+
set = function(v) {
|
|
118
|
+
this[name] = v;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
} else if (kind === 2) {
|
|
122
|
+
get = function() {
|
|
123
|
+
return desc.value;
|
|
124
|
+
};
|
|
125
|
+
} else {
|
|
126
|
+
if (kind === 1 || kind === 3) {
|
|
127
|
+
get = function() {
|
|
128
|
+
return desc.get.call(this);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
if (kind === 1 || kind === 4) {
|
|
132
|
+
set = function(v) {
|
|
133
|
+
desc.set.call(this, v);
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
ctx.access = get && set ? {
|
|
138
|
+
get: get,
|
|
139
|
+
set: set
|
|
140
|
+
} : get ? {
|
|
141
|
+
get: get
|
|
142
|
+
} : {
|
|
143
|
+
set: set
|
|
144
|
+
};
|
|
145
|
+
try {
|
|
146
|
+
return dec(value, ctx);
|
|
147
|
+
} finally{
|
|
148
|
+
decoratorFinishedRef.v = true;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
152
|
+
if (decoratorFinishedRef.v) {
|
|
153
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function assertCallable(fn, hint) {
|
|
157
|
+
if (typeof fn !== "function") {
|
|
158
|
+
throw new TypeError(hint + " must be a function");
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function assertValidReturnValue(kind, value) {
|
|
162
|
+
var type = typeof value;
|
|
163
|
+
if (kind === 1) {
|
|
164
|
+
if (type !== "object" || value === null) {
|
|
165
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
166
|
+
}
|
|
167
|
+
if (value.get !== undefined) {
|
|
168
|
+
assertCallable(value.get, "accessor.get");
|
|
169
|
+
}
|
|
170
|
+
if (value.set !== undefined) {
|
|
171
|
+
assertCallable(value.set, "accessor.set");
|
|
172
|
+
}
|
|
173
|
+
if (value.init !== undefined) {
|
|
174
|
+
assertCallable(value.init, "accessor.init");
|
|
175
|
+
}
|
|
176
|
+
} else if (type !== "function") {
|
|
177
|
+
var hint;
|
|
178
|
+
if (kind === 0) {
|
|
179
|
+
hint = "field";
|
|
180
|
+
} else if (kind === 10) {
|
|
181
|
+
hint = "class";
|
|
182
|
+
} else {
|
|
183
|
+
hint = "method";
|
|
184
|
+
}
|
|
185
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
189
|
+
var decs = decInfo[0];
|
|
190
|
+
var desc, init, value;
|
|
191
|
+
if (isPrivate) {
|
|
192
|
+
if (kind === 0 || kind === 1) {
|
|
193
|
+
desc = {
|
|
194
|
+
get: decInfo[3],
|
|
195
|
+
set: decInfo[4]
|
|
196
|
+
};
|
|
197
|
+
} else if (kind === 3) {
|
|
198
|
+
desc = {
|
|
199
|
+
get: decInfo[3]
|
|
200
|
+
};
|
|
201
|
+
} else if (kind === 4) {
|
|
202
|
+
desc = {
|
|
203
|
+
set: decInfo[3]
|
|
204
|
+
};
|
|
205
|
+
} else {
|
|
206
|
+
desc = {
|
|
207
|
+
value: decInfo[3]
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
} else if (kind !== 0) {
|
|
211
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
212
|
+
}
|
|
213
|
+
if (kind === 1) {
|
|
214
|
+
value = {
|
|
215
|
+
get: desc.get,
|
|
216
|
+
set: desc.set
|
|
217
|
+
};
|
|
218
|
+
} else if (kind === 2) {
|
|
219
|
+
value = desc.value;
|
|
220
|
+
} else if (kind === 3) {
|
|
221
|
+
value = desc.get;
|
|
222
|
+
} else if (kind === 4) {
|
|
223
|
+
value = desc.set;
|
|
224
|
+
}
|
|
225
|
+
var newValue, get, set;
|
|
226
|
+
if (typeof decs === "function") {
|
|
227
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
228
|
+
if (newValue !== void 0) {
|
|
229
|
+
assertValidReturnValue(kind, newValue);
|
|
230
|
+
if (kind === 0) {
|
|
231
|
+
init = newValue;
|
|
232
|
+
} else if (kind === 1) {
|
|
233
|
+
init = newValue.init;
|
|
234
|
+
get = newValue.get || value.get;
|
|
235
|
+
set = newValue.set || value.set;
|
|
236
|
+
value = {
|
|
237
|
+
get: get,
|
|
238
|
+
set: set
|
|
239
|
+
};
|
|
240
|
+
} else {
|
|
241
|
+
value = newValue;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
} else {
|
|
245
|
+
for(var i = decs.length - 1; i >= 0; i--){
|
|
246
|
+
var dec = decs[i];
|
|
247
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
248
|
+
if (newValue !== void 0) {
|
|
249
|
+
assertValidReturnValue(kind, newValue);
|
|
250
|
+
var newInit;
|
|
251
|
+
if (kind === 0) {
|
|
252
|
+
newInit = newValue;
|
|
253
|
+
} else if (kind === 1) {
|
|
254
|
+
newInit = newValue.init;
|
|
255
|
+
get = newValue.get || value.get;
|
|
256
|
+
set = newValue.set || value.set;
|
|
257
|
+
value = {
|
|
258
|
+
get: get,
|
|
259
|
+
set: set
|
|
260
|
+
};
|
|
261
|
+
} else {
|
|
262
|
+
value = newValue;
|
|
263
|
+
}
|
|
264
|
+
if (newInit !== void 0) {
|
|
265
|
+
if (init === void 0) {
|
|
266
|
+
init = newInit;
|
|
267
|
+
} else if (typeof init === "function") {
|
|
268
|
+
init = [
|
|
269
|
+
init,
|
|
270
|
+
newInit
|
|
271
|
+
];
|
|
272
|
+
} else {
|
|
273
|
+
init.push(newInit);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (kind === 0 || kind === 1) {
|
|
280
|
+
if (init === void 0) {
|
|
281
|
+
init = function(instance, init) {
|
|
282
|
+
return init;
|
|
283
|
+
};
|
|
284
|
+
} else if (typeof init !== "function") {
|
|
285
|
+
var ownInitializers = init;
|
|
286
|
+
init = function(instance, init) {
|
|
287
|
+
var value = init;
|
|
288
|
+
for(var i = 0; i < ownInitializers.length; i++){
|
|
289
|
+
value = ownInitializers[i].call(instance, value);
|
|
290
|
+
}
|
|
291
|
+
return value;
|
|
292
|
+
};
|
|
293
|
+
} else {
|
|
294
|
+
var originalInitializer = init;
|
|
295
|
+
init = function(instance, init) {
|
|
296
|
+
return originalInitializer.call(instance, init);
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
ret.push(init);
|
|
300
|
+
}
|
|
301
|
+
if (kind !== 0) {
|
|
302
|
+
if (kind === 1) {
|
|
303
|
+
desc.get = value.get;
|
|
304
|
+
desc.set = value.set;
|
|
305
|
+
} else if (kind === 2) {
|
|
306
|
+
desc.value = value;
|
|
307
|
+
} else if (kind === 3) {
|
|
308
|
+
desc.get = value;
|
|
309
|
+
} else if (kind === 4) {
|
|
310
|
+
desc.set = value;
|
|
311
|
+
}
|
|
312
|
+
if (isPrivate) {
|
|
313
|
+
if (kind === 1) {
|
|
314
|
+
ret.push(function(instance, args) {
|
|
315
|
+
return value.get.call(instance, args);
|
|
316
|
+
});
|
|
317
|
+
ret.push(function(instance, args) {
|
|
318
|
+
return value.set.call(instance, args);
|
|
319
|
+
});
|
|
320
|
+
} else if (kind === 2) {
|
|
321
|
+
ret.push(value);
|
|
322
|
+
} else {
|
|
323
|
+
ret.push(function(instance, args) {
|
|
324
|
+
return value.call(instance, args);
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
} else {
|
|
328
|
+
Object.defineProperty(base, name, desc);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
333
|
+
var ret = [];
|
|
334
|
+
var protoInitializers;
|
|
335
|
+
var staticInitializers;
|
|
336
|
+
var existingProtoNonFields = new Map();
|
|
337
|
+
var existingStaticNonFields = new Map();
|
|
338
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
339
|
+
var decInfo = decInfos[i];
|
|
340
|
+
if (!Array.isArray(decInfo)) continue;
|
|
341
|
+
var kind = decInfo[1];
|
|
342
|
+
var name = decInfo[2];
|
|
343
|
+
var isPrivate = decInfo.length > 3;
|
|
344
|
+
var isStatic = kind >= 5;
|
|
345
|
+
var base;
|
|
346
|
+
var initializers;
|
|
347
|
+
if (isStatic) {
|
|
348
|
+
base = Class;
|
|
349
|
+
kind = kind - 5;
|
|
350
|
+
staticInitializers = staticInitializers || [];
|
|
351
|
+
initializers = staticInitializers;
|
|
352
|
+
} else {
|
|
353
|
+
base = Class.prototype;
|
|
354
|
+
protoInitializers = protoInitializers || [];
|
|
355
|
+
initializers = protoInitializers;
|
|
356
|
+
}
|
|
357
|
+
if (kind !== 0 && !isPrivate) {
|
|
358
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
359
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
360
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
|
361
|
+
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);
|
|
362
|
+
} else if (!existingKind && kind > 2) {
|
|
363
|
+
existingNonFields.set(name, kind);
|
|
364
|
+
} else {
|
|
365
|
+
existingNonFields.set(name, true);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
369
|
+
}
|
|
370
|
+
pushInitializers(ret, protoInitializers);
|
|
371
|
+
pushInitializers(ret, staticInitializers);
|
|
372
|
+
return ret;
|
|
373
|
+
}
|
|
374
|
+
function pushInitializers(ret, initializers) {
|
|
375
|
+
if (initializers) {
|
|
376
|
+
ret.push(function(instance) {
|
|
377
|
+
for(var i = 0; i < initializers.length; i++){
|
|
378
|
+
initializers[i].call(instance);
|
|
379
|
+
}
|
|
380
|
+
return instance;
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
385
|
+
if (classDecs.length > 0) {
|
|
386
|
+
var initializers = [];
|
|
387
|
+
var newClass = targetClass;
|
|
388
|
+
var name = targetClass.name;
|
|
389
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
390
|
+
var decoratorFinishedRef = {
|
|
391
|
+
v: false
|
|
392
|
+
};
|
|
393
|
+
try {
|
|
394
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
395
|
+
kind: "class",
|
|
396
|
+
name: name,
|
|
397
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
398
|
+
metadata
|
|
399
|
+
});
|
|
400
|
+
} finally{
|
|
401
|
+
decoratorFinishedRef.v = true;
|
|
402
|
+
}
|
|
403
|
+
if (nextNewClass !== undefined) {
|
|
404
|
+
assertValidReturnValue(10, nextNewClass);
|
|
405
|
+
newClass = nextNewClass;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return [
|
|
409
|
+
defineMetadata(newClass, metadata),
|
|
410
|
+
function() {
|
|
411
|
+
for(var i = 0; i < initializers.length; i++){
|
|
412
|
+
initializers[i].call(newClass);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
];
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
function defineMetadata(Class, metadata) {
|
|
419
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
420
|
+
configurable: true,
|
|
421
|
+
enumerable: true,
|
|
422
|
+
value: metadata
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
426
|
+
if (parentClass !== void 0) {
|
|
427
|
+
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
428
|
+
}
|
|
429
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
430
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
431
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
432
|
+
return {
|
|
433
|
+
e: e,
|
|
434
|
+
get c () {
|
|
435
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
441
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
442
|
+
}
|
|
443
|
+
function _identity(x) {
|
|
444
|
+
return x;
|
|
445
|
+
}
|
|
446
|
+
var _dec, _initClass, _ValidityMixin, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, // ── ValidityMixin contract — must be declared as @property —————————————
|
|
447
|
+
_init_status, _init_required, _init_validityMessage, // ── Public API ─────────────────────────────────────────────────────────────
|
|
448
|
+
/** Input type. Controls the keyboard/picker on mobile and browser validation hints. */ _init_type, /** Native input placeholder text. */ _init_placeholder, /** Form field name. Submitted with the form when set. */ _init_name, /** Current value. Synced to ElementInternals for form participation. */ _init_value, /** When true, disables the input and removes it from the tab order. */ _init_disabled, /** When true, the value cannot be edited but is still submitted. */ _init_readonly, _initProto;
|
|
449
|
+
let _ViInput;
|
|
450
|
+
_dec = customElement('vi-input'), _dec1 = property({
|
|
451
|
+
reflect: true
|
|
452
|
+
}), _dec2 = property({
|
|
453
|
+
type: Boolean,
|
|
454
|
+
reflect: true
|
|
455
|
+
}), _dec3 = property(), _dec4 = property({
|
|
456
|
+
type: String,
|
|
457
|
+
reflect: true
|
|
458
|
+
}), _dec5 = property(), _dec6 = property(), _dec7 = property(), _dec8 = property({
|
|
459
|
+
type: Boolean,
|
|
460
|
+
reflect: true
|
|
461
|
+
}), _dec9 = property({
|
|
462
|
+
type: Boolean,
|
|
463
|
+
reflect: true
|
|
464
|
+
});
|
|
465
|
+
new class extends _identity {
|
|
466
|
+
constructor(){
|
|
467
|
+
super(_ViInput), _initClass();
|
|
468
|
+
}
|
|
469
|
+
static{
|
|
470
|
+
class ViInput extends (_ValidityMixin = ValidityMixin(FocusableMixin(ViElement))) {
|
|
471
|
+
static{
|
|
472
|
+
({ e: [_init_status, _init_required, _init_validityMessage, _init_type, _init_placeholder, _init_name, _init_value, _init_disabled, _init_readonly, _initProto], c: [_ViInput, _initClass] } = _apply_decs_2203_r(this, [
|
|
473
|
+
[
|
|
474
|
+
_dec1,
|
|
475
|
+
1,
|
|
476
|
+
"status"
|
|
477
|
+
],
|
|
478
|
+
[
|
|
479
|
+
_dec2,
|
|
480
|
+
1,
|
|
481
|
+
"required"
|
|
482
|
+
],
|
|
483
|
+
[
|
|
484
|
+
_dec3,
|
|
485
|
+
1,
|
|
486
|
+
"validityMessage"
|
|
487
|
+
],
|
|
488
|
+
[
|
|
489
|
+
_dec4,
|
|
490
|
+
1,
|
|
491
|
+
"type"
|
|
492
|
+
],
|
|
493
|
+
[
|
|
494
|
+
_dec5,
|
|
495
|
+
1,
|
|
496
|
+
"placeholder"
|
|
497
|
+
],
|
|
498
|
+
[
|
|
499
|
+
_dec6,
|
|
500
|
+
1,
|
|
501
|
+
"name"
|
|
502
|
+
],
|
|
503
|
+
[
|
|
504
|
+
_dec7,
|
|
505
|
+
1,
|
|
506
|
+
"value"
|
|
507
|
+
],
|
|
508
|
+
[
|
|
509
|
+
_dec8,
|
|
510
|
+
1,
|
|
511
|
+
"disabled"
|
|
512
|
+
],
|
|
513
|
+
[
|
|
514
|
+
_dec9,
|
|
515
|
+
1,
|
|
516
|
+
"readonly"
|
|
517
|
+
]
|
|
518
|
+
], [
|
|
519
|
+
_dec
|
|
520
|
+
], _ValidityMixin));
|
|
521
|
+
}
|
|
522
|
+
static formAssociated = true;
|
|
523
|
+
static styles = css`
|
|
524
|
+
${unsafeCSS(inputStyles)}
|
|
525
|
+
`;
|
|
526
|
+
_internals = (_initProto(this), this.attachInternals());
|
|
527
|
+
get _focusableElement() {
|
|
528
|
+
return this.shadowRoot?.querySelector('input') ?? null;
|
|
529
|
+
}
|
|
530
|
+
#___private_status_1 = _init_status(this, 'default');
|
|
531
|
+
get status() {
|
|
532
|
+
return this.#___private_status_1;
|
|
533
|
+
}
|
|
534
|
+
set status(_v) {
|
|
535
|
+
this.#___private_status_1 = _v;
|
|
536
|
+
}
|
|
537
|
+
#___private_required_2 = _init_required(this, false);
|
|
538
|
+
get required() {
|
|
539
|
+
return this.#___private_required_2;
|
|
540
|
+
}
|
|
541
|
+
set required(_v) {
|
|
542
|
+
this.#___private_required_2 = _v;
|
|
543
|
+
}
|
|
544
|
+
#___private_validityMessage_3 = _init_validityMessage(this, '');
|
|
545
|
+
get validityMessage() {
|
|
546
|
+
return this.#___private_validityMessage_3;
|
|
547
|
+
}
|
|
548
|
+
set validityMessage(_v) {
|
|
549
|
+
this.#___private_validityMessage_3 = _v;
|
|
550
|
+
}
|
|
551
|
+
#___private_type_4 = _init_type(this, 'text');
|
|
552
|
+
get type() {
|
|
553
|
+
return this.#___private_type_4;
|
|
554
|
+
}
|
|
555
|
+
set type(_v) {
|
|
556
|
+
this.#___private_type_4 = _v;
|
|
557
|
+
}
|
|
558
|
+
#___private_placeholder_5 = _init_placeholder(this, '');
|
|
559
|
+
get placeholder() {
|
|
560
|
+
return this.#___private_placeholder_5;
|
|
561
|
+
}
|
|
562
|
+
set placeholder(_v) {
|
|
563
|
+
this.#___private_placeholder_5 = _v;
|
|
564
|
+
}
|
|
565
|
+
#___private_name_6 = _init_name(this, '');
|
|
566
|
+
get name() {
|
|
567
|
+
return this.#___private_name_6;
|
|
568
|
+
}
|
|
569
|
+
set name(_v) {
|
|
570
|
+
this.#___private_name_6 = _v;
|
|
571
|
+
}
|
|
572
|
+
#___private_value_7 = _init_value(this, '');
|
|
573
|
+
get value() {
|
|
574
|
+
return this.#___private_value_7;
|
|
575
|
+
}
|
|
576
|
+
set value(_v) {
|
|
577
|
+
this.#___private_value_7 = _v;
|
|
578
|
+
}
|
|
579
|
+
#___private_disabled_8 = _init_disabled(this, false);
|
|
580
|
+
get disabled() {
|
|
581
|
+
return this.#___private_disabled_8;
|
|
582
|
+
}
|
|
583
|
+
set disabled(_v) {
|
|
584
|
+
this.#___private_disabled_8 = _v;
|
|
585
|
+
}
|
|
586
|
+
#___private_readonly_9 = _init_readonly(this, false);
|
|
587
|
+
get readonly() {
|
|
588
|
+
return this.#___private_readonly_9;
|
|
589
|
+
}
|
|
590
|
+
set readonly(_v) {
|
|
591
|
+
this.#___private_readonly_9 = _v;
|
|
592
|
+
}
|
|
593
|
+
// ── ValidityMixin hook ─────────────────────────────────────────────────────
|
|
594
|
+
// _testValidity is declared protected in ValidityInterface, but TypeScript's
|
|
595
|
+
// mixin intersection type does not always surface protected members for
|
|
596
|
+
// `override` checking. The method is still an override at runtime.
|
|
597
|
+
_testValidity() {
|
|
598
|
+
if (this._internals.validity.customError) {
|
|
599
|
+
return {
|
|
600
|
+
customError: true
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
const input = this._focusableElement;
|
|
604
|
+
if (input) {
|
|
605
|
+
if (input.value !== this.value) {
|
|
606
|
+
input.value = this.value;
|
|
607
|
+
}
|
|
608
|
+
const validity = input.validity;
|
|
609
|
+
if (!validity.valid) {
|
|
610
|
+
this.validityMessage = input.validationMessage;
|
|
611
|
+
return {
|
|
612
|
+
badInput: validity.badInput,
|
|
613
|
+
customError: validity.customError,
|
|
614
|
+
patternMismatch: validity.patternMismatch,
|
|
615
|
+
rangeOverflow: validity.rangeOverflow,
|
|
616
|
+
rangeUnderflow: validity.rangeUnderflow,
|
|
617
|
+
stepMismatch: validity.stepMismatch,
|
|
618
|
+
tooLong: validity.tooLong,
|
|
619
|
+
tooShort: validity.tooShort,
|
|
620
|
+
typeMismatch: validity.typeMismatch,
|
|
621
|
+
valueMissing: validity.valueMissing
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
} else if (this.required && !this.value) {
|
|
625
|
+
this.validityMessage = 'Please fill out this field.';
|
|
626
|
+
return {
|
|
627
|
+
valueMissing: true
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
return {};
|
|
631
|
+
}
|
|
632
|
+
// ── Lifecycle ──────────────────────────────────────────────────────────────
|
|
633
|
+
updated(changed) {
|
|
634
|
+
super.updated(changed);
|
|
635
|
+
if (changed.has('value')) {
|
|
636
|
+
this._internals.setFormValue(this.value);
|
|
637
|
+
}
|
|
638
|
+
if (changed.has('disabled')) {
|
|
639
|
+
this._setHostFocusable(!this.disabled);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
/** Resets value and validation state when the associated form resets. */ formResetCallback() {
|
|
643
|
+
this.value = this.getAttribute('value') ?? '';
|
|
644
|
+
this.status = 'default';
|
|
645
|
+
this.validityMessage = '';
|
|
646
|
+
}
|
|
647
|
+
/** Keeps disabled in sync when a containing fieldset or form is disabled. */ formDisabledCallback(disabled) {
|
|
648
|
+
this.disabled = disabled;
|
|
649
|
+
}
|
|
650
|
+
// ── Event handlers ─────────────────────────────────────────────────────────
|
|
651
|
+
_onInput(e) {
|
|
652
|
+
e.stopPropagation();
|
|
653
|
+
const input = e.target;
|
|
654
|
+
this.value = input.value;
|
|
655
|
+
this.dispatchEvent(new CustomEvent('vialiq-input', {
|
|
656
|
+
detail: {
|
|
657
|
+
value: this.value
|
|
658
|
+
},
|
|
659
|
+
bubbles: true,
|
|
660
|
+
composed: true
|
|
661
|
+
}));
|
|
662
|
+
}
|
|
663
|
+
_onChange(e) {
|
|
664
|
+
e.stopPropagation();
|
|
665
|
+
const input = e.target;
|
|
666
|
+
this.value = input.value;
|
|
667
|
+
this.dispatchEvent(new CustomEvent('vialiq-change', {
|
|
668
|
+
detail: {
|
|
669
|
+
value: this.value
|
|
670
|
+
},
|
|
671
|
+
bubbles: true,
|
|
672
|
+
composed: true
|
|
673
|
+
}));
|
|
674
|
+
}
|
|
675
|
+
// ── Render ─────────────────────────────────────────────────────────────────
|
|
676
|
+
get _helperContent() {
|
|
677
|
+
return html`<span id="helper-text" class="input-helper" part="helper"
|
|
678
|
+
><slot name="helper"></slot
|
|
679
|
+
></span>`;
|
|
680
|
+
}
|
|
681
|
+
get _validationMessage() {
|
|
682
|
+
if (!this.validityMessage) return html``;
|
|
683
|
+
const cls = this.status === 'invalid' ? 'input-validation--invalid' : this.status === 'valid' ? 'input-validation--valid' : '';
|
|
684
|
+
return html`<span
|
|
685
|
+
id="validation-message"
|
|
686
|
+
class="input-validation ${cls}"
|
|
687
|
+
part="validation"
|
|
688
|
+
role="alert"
|
|
689
|
+
aria-live="polite"
|
|
690
|
+
>${this.validityMessage}</span
|
|
691
|
+
>`;
|
|
692
|
+
}
|
|
693
|
+
render() {
|
|
694
|
+
const { type, placeholder, name, value, disabled, required, readonly } = this;
|
|
695
|
+
return html`
|
|
696
|
+
<div class="input-field" part="field">
|
|
697
|
+
<input
|
|
698
|
+
class="input-control"
|
|
699
|
+
part="input"
|
|
700
|
+
tabindex="0"
|
|
701
|
+
type=${type}
|
|
702
|
+
.value=${value}
|
|
703
|
+
?disabled=${disabled}
|
|
704
|
+
?readonly=${readonly}
|
|
705
|
+
?required=${required}
|
|
706
|
+
aria-required=${ifNonEmpty(required ? 'true' : '')}
|
|
707
|
+
aria-invalid=${this.status === 'invalid' ? 'true' : 'false'}
|
|
708
|
+
aria-describedby=${this.validityMessage ? 'helper-text validation-message' : 'helper-text'}
|
|
709
|
+
aria-errormessage=${ifNonEmpty(this.status === 'invalid' && this.validityMessage ? 'validation-message' : '')}
|
|
710
|
+
placeholder=${ifNonEmpty(placeholder)}
|
|
711
|
+
name=${ifNonEmpty(name)}
|
|
712
|
+
@input=${this._onInput}
|
|
713
|
+
@change=${this._onChange}
|
|
714
|
+
/>
|
|
715
|
+
${this._helperContent} ${this._validationMessage}
|
|
716
|
+
</div>
|
|
717
|
+
`;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}();
|
|
722
|
+
|
|
723
|
+
export { _ViInput as ViInput };
|