@ucalgary-design-system/text-input 1.0.6 → 1.1.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/CHANGELOG.md +10 -0
- package/index.js +44 -37
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -51,10 +51,10 @@ const M = (i) => new k(typeof i == "string" ? i : i + "", void 0, C), R = (i, t)
|
|
|
51
51
|
* Copyright 2017 Google LLC
|
|
52
52
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
53
|
*/
|
|
54
|
-
const { is: q, defineProperty: z, getOwnPropertyDescriptor: j, getOwnPropertyNames:
|
|
54
|
+
const { is: q, defineProperty: z, getOwnPropertyDescriptor: j, getOwnPropertyNames: I, getOwnPropertySymbols: D, getPrototypeOf: L } = Object, p = globalThis, P = p.trustedTypes, N = P ? P.emptyScript : "", $ = p.reactiveElementPolyfillSupport, f = (i, t) => i, v = { toAttribute(i, t) {
|
|
55
55
|
switch (t) {
|
|
56
56
|
case Boolean:
|
|
57
|
-
i = i ?
|
|
57
|
+
i = i ? N : null;
|
|
58
58
|
break;
|
|
59
59
|
case Object:
|
|
60
60
|
case Array:
|
|
@@ -79,8 +79,8 @@ const { is: q, defineProperty: z, getOwnPropertyDescriptor: j, getOwnPropertyNam
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
return e;
|
|
82
|
-
} }, _ = (i, t) => !q(i, t), x = { attribute: !0, type: String, converter:
|
|
83
|
-
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")),
|
|
82
|
+
} }, _ = (i, t) => !q(i, t), x = { attribute: !0, type: String, converter: v, reflect: !1, useDefault: !1, hasChanged: _ };
|
|
83
|
+
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), p.litPropertyMetadata ?? (p.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
|
|
84
84
|
class u extends HTMLElement {
|
|
85
85
|
static addInitializer(t) {
|
|
86
86
|
this._$Ei(), (this.l ?? (this.l = [])).push(t);
|
|
@@ -116,7 +116,7 @@ class u extends HTMLElement {
|
|
|
116
116
|
static finalize() {
|
|
117
117
|
if (this.hasOwnProperty(f("finalized"))) return;
|
|
118
118
|
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(f("properties"))) {
|
|
119
|
-
const e = this.properties, r = [...
|
|
119
|
+
const e = this.properties, r = [...I(e), ...D(e)];
|
|
120
120
|
for (const s of r) this.createProperty(s, e[s]);
|
|
121
121
|
}
|
|
122
122
|
const t = this[Symbol.metadata];
|
|
@@ -190,7 +190,7 @@ class u extends HTMLElement {
|
|
|
190
190
|
var o;
|
|
191
191
|
const r = this.constructor.elementProperties.get(t), s = this.constructor._$Eu(t, r);
|
|
192
192
|
if (s !== void 0 && r.reflect === !0) {
|
|
193
|
-
const a = (((o = r.converter) == null ? void 0 : o.toAttribute) !== void 0 ? r.converter :
|
|
193
|
+
const a = (((o = r.converter) == null ? void 0 : o.toAttribute) !== void 0 ? r.converter : v).toAttribute(e, r.type);
|
|
194
194
|
this._$Em = t, a == null ? this.removeAttribute(s) : this.setAttribute(s, a), this._$Em = null;
|
|
195
195
|
}
|
|
196
196
|
}
|
|
@@ -198,17 +198,17 @@ class u extends HTMLElement {
|
|
|
198
198
|
var o, a;
|
|
199
199
|
const r = this.constructor, s = r._$Eh.get(t);
|
|
200
200
|
if (s !== void 0 && this._$Em !== s) {
|
|
201
|
-
const n = r.getPropertyOptions(s),
|
|
201
|
+
const n = r.getPropertyOptions(s), c = typeof n.converter == "function" ? { fromAttribute: n.converter } : ((o = n.converter) == null ? void 0 : o.fromAttribute) !== void 0 ? n.converter : v;
|
|
202
202
|
this._$Em = s;
|
|
203
|
-
const E =
|
|
203
|
+
const E = c.fromAttribute(e, n.type);
|
|
204
204
|
this[s] = E ?? ((a = this._$Ej) == null ? void 0 : a.get(s)) ?? E, this._$Em = null;
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
requestUpdate(t, e, r) {
|
|
208
|
-
var
|
|
207
|
+
requestUpdate(t, e, r, s = !1, o) {
|
|
208
|
+
var a;
|
|
209
209
|
if (t !== void 0) {
|
|
210
|
-
const
|
|
211
|
-
if (r ?? (r =
|
|
210
|
+
const n = this.constructor;
|
|
211
|
+
if (s === !1 && (o = this[t]), r ?? (r = n.getPropertyOptions(t)), !((r.hasChanged ?? _)(o, e) || r.useDefault && r.reflect && o === ((a = this._$Ej) == null ? void 0 : a.get(t)) && !this.hasAttribute(n._$Eu(t, r)))) return;
|
|
212
212
|
this.C(t, e, r);
|
|
213
213
|
}
|
|
214
214
|
this.isUpdatePending === !1 && (this._$ES = this._$EP());
|
|
@@ -239,8 +239,8 @@ class u extends HTMLElement {
|
|
|
239
239
|
}
|
|
240
240
|
const s = this.constructor.elementProperties;
|
|
241
241
|
if (s.size > 0) for (const [o, a] of s) {
|
|
242
|
-
const { wrapped: n } = a,
|
|
243
|
-
n !== !0 || this._$AL.has(o) ||
|
|
242
|
+
const { wrapped: n } = a, c = this[o];
|
|
243
|
+
n !== !0 || this._$AL.has(o) || c === void 0 || this.C(o, void 0, a, c);
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
let t = !1;
|
|
@@ -284,20 +284,20 @@ class u extends HTMLElement {
|
|
|
284
284
|
firstUpdated(t) {
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
u.elementStyles = [], u.shadowRootOptions = { mode: "open" }, u[f("elementProperties")] = /* @__PURE__ */ new Map(), u[f("finalized")] = /* @__PURE__ */ new Map(),
|
|
287
|
+
u.elementStyles = [], u.shadowRootOptions = { mode: "open" }, u[f("elementProperties")] = /* @__PURE__ */ new Map(), u[f("finalized")] = /* @__PURE__ */ new Map(), $ == null || $({ ReactiveElement: u }), (p.reactiveElementVersions ?? (p.reactiveElementVersions = [])).push("2.1.2");
|
|
288
288
|
/**
|
|
289
289
|
* @license
|
|
290
290
|
* Copyright 2017 Google LLC
|
|
291
291
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
292
292
|
*/
|
|
293
|
-
const
|
|
293
|
+
const V = { attribute: !0, type: String, converter: v, reflect: !1, hasChanged: _ }, B = (i = V, t, e) => {
|
|
294
294
|
const { kind: r, metadata: s } = e;
|
|
295
295
|
let o = globalThis.litPropertyMetadata.get(s);
|
|
296
296
|
if (o === void 0 && globalThis.litPropertyMetadata.set(s, o = /* @__PURE__ */ new Map()), r === "setter" && ((i = Object.create(i)).wrapped = !0), o.set(e.name, i), r === "accessor") {
|
|
297
297
|
const { name: a } = e;
|
|
298
298
|
return { set(n) {
|
|
299
|
-
const
|
|
300
|
-
t.set.call(this, n), this.requestUpdate(a,
|
|
299
|
+
const c = t.get.call(this);
|
|
300
|
+
t.set.call(this, n), this.requestUpdate(a, c, i, !0, n);
|
|
301
301
|
}, init(n) {
|
|
302
302
|
return n !== void 0 && this.C(a, void 0, i, n), n;
|
|
303
303
|
} };
|
|
@@ -305,27 +305,28 @@ const N = { attribute: !0, type: String, converter: $, reflect: !1, hasChanged:
|
|
|
305
305
|
if (r === "setter") {
|
|
306
306
|
const { name: a } = e;
|
|
307
307
|
return function(n) {
|
|
308
|
-
const
|
|
309
|
-
t.call(this, n), this.requestUpdate(a,
|
|
308
|
+
const c = this[a];
|
|
309
|
+
t.call(this, n), this.requestUpdate(a, c, i, !0, n);
|
|
310
310
|
};
|
|
311
311
|
}
|
|
312
312
|
throw Error("Unsupported decorator location: " + r);
|
|
313
313
|
};
|
|
314
|
-
function
|
|
315
|
-
return (t, e) => typeof e == "object" ?
|
|
314
|
+
function d(i) {
|
|
315
|
+
return (t, e) => typeof e == "object" ? B(i, t, e) : ((r, s, o) => {
|
|
316
316
|
const a = s.hasOwnProperty(o);
|
|
317
317
|
return s.constructor.createProperty(o, r), a ? Object.getOwnPropertyDescriptor(s, o) : void 0;
|
|
318
318
|
})(i, t, e);
|
|
319
319
|
}
|
|
320
|
-
const
|
|
321
|
-
var
|
|
322
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
320
|
+
const F = ":host{display:block}.form-text{display:flex;flex-direction:column;gap:var(--ucds-form-component-intra-spacing);align-items:start;max-width:var(--ucds-form-element-maxwidth)}.form-text input{display:block;height:var(--ucds-form-element-height);width:var(--ucds-form-element-width);padding-left:var(--ucds-form-element-horizontal-padding);padding-right:var(--ucds-form-element-horizontal-padding);line-height:16px;background-color:var(--ucds-color-forms-input-background-rest);border:var(--ucds-form-element-border-width) solid var(--ucds-color-forms-input-border-rest);border-radius:var(--ucds-form-element-border-radius);transition:border-color .5s ease;text-align:left}.form-text input::-moz-placeholder{font-style:italic;color:var(--ucds-color-text-secondary)}.form-text input::placeholder{font-style:italic;color:var(--ucds-color-text-secondary)}.form-text input[error]{background-color:var(--ucds-color-feedback-error-background-light);border-color:var(--ucds-color-feedback-error-light)}.form-text input:hover{border-color:var(--ucds-color-forms-input-border-hover)}.form-text input:focus-visible{outline:var(--ucds-color-action-focus) 2px solid;outline-offset:2px}.form-text.disabled input{color:var(--ucds-color-text-disabled);background-color:transparent;border-color:var(--ucds-color-forms-input-border-disabled)}.form-text.disabled input::-moz-placeholder{color:var(--ucds-color-text-disabled)}.form-text.disabled input::placeholder{color:var(--ucds-color-text-disabled)}";
|
|
321
|
+
var J = Object.defineProperty, K = Object.getOwnPropertyDescriptor, h = (i, t, e, r) => {
|
|
322
|
+
for (var s = r > 1 ? void 0 : r ? K(t, e) : t, o = i.length - 1, a; o >= 0; o--)
|
|
323
323
|
(a = i[o]) && (s = (r ? a(t, e, s) : a(s)) || s);
|
|
324
|
-
return r && s &&
|
|
324
|
+
return r && s && J(t, e, s), s;
|
|
325
325
|
};
|
|
326
|
+
const W = ["text", "email", "password", "tel"];
|
|
326
327
|
let l = class extends U {
|
|
327
328
|
constructor() {
|
|
328
|
-
super(), this.errorText = "", this.helpText = "", this.inputId = "", this.label = "", this._value = "", this.disabled = !1, this.error = !1, this.required = !1, this.internals = this.attachInternals();
|
|
329
|
+
super(), this.errorText = "", this.helpText = "", this.inputId = "", this.label = "", this.type = "text", this._value = "", this.disabled = !1, this.error = !1, this.required = !1, this.internals = this.attachInternals();
|
|
329
330
|
}
|
|
330
331
|
get value() {
|
|
331
332
|
return this._value;
|
|
@@ -334,6 +335,9 @@ let l = class extends U {
|
|
|
334
335
|
const t = this._value;
|
|
335
336
|
i !== t && (this._value = i, this.requestUpdate("value", t), this.internals.setFormValue(this._value));
|
|
336
337
|
}
|
|
338
|
+
willUpdate(i) {
|
|
339
|
+
i.has("type") && (!this.type || !W.includes(this.type)) && (console.warn(`Missing or Invalid input type provided. ${this.type} is not a valid input type. Falling back to 'text'.`), this.type = "text");
|
|
340
|
+
}
|
|
337
341
|
updated(i) {
|
|
338
342
|
i.has("label") && !this.label && console.error("Property 'label' is required and was not set.");
|
|
339
343
|
}
|
|
@@ -358,7 +362,7 @@ let l = class extends U {
|
|
|
358
362
|
<div class="form-text ${this.disabled ? "disabled" : ""} ${this.required ? "required" : ""}">
|
|
359
363
|
${this.label ? y`<form-label for="${this.inputId}" text="${this.label}" ?required="${this.required}" ?disabled="${this.disabled}"></form-label>` : m}
|
|
360
364
|
<input
|
|
361
|
-
type="
|
|
365
|
+
type="${this.type}"
|
|
362
366
|
id="${this.inputId}"
|
|
363
367
|
?disabled=${this.disabled}
|
|
364
368
|
?required=${this.required}
|
|
@@ -374,32 +378,35 @@ let l = class extends U {
|
|
|
374
378
|
};
|
|
375
379
|
l.styles = [
|
|
376
380
|
U.styles,
|
|
377
|
-
A(
|
|
381
|
+
A(F)
|
|
378
382
|
];
|
|
379
383
|
l.formAssociated = !0;
|
|
380
384
|
h([
|
|
381
|
-
|
|
385
|
+
d({ type: String, attribute: "error-text" })
|
|
382
386
|
], l.prototype, "errorText", 2);
|
|
383
387
|
h([
|
|
384
|
-
|
|
388
|
+
d({ type: String, attribute: "help-text" })
|
|
385
389
|
], l.prototype, "helpText", 2);
|
|
386
390
|
h([
|
|
387
|
-
|
|
391
|
+
d({ type: String, attribute: "input-id" })
|
|
388
392
|
], l.prototype, "inputId", 2);
|
|
389
393
|
h([
|
|
390
|
-
|
|
394
|
+
d({ type: String })
|
|
391
395
|
], l.prototype, "label", 2);
|
|
392
396
|
h([
|
|
393
|
-
|
|
397
|
+
d()
|
|
398
|
+
], l.prototype, "type", 2);
|
|
399
|
+
h([
|
|
400
|
+
d({ type: String, reflect: !0 })
|
|
394
401
|
], l.prototype, "placeholder", 2);
|
|
395
402
|
h([
|
|
396
|
-
|
|
403
|
+
d({ type: Boolean, reflect: !0 })
|
|
397
404
|
], l.prototype, "disabled", 2);
|
|
398
405
|
h([
|
|
399
|
-
|
|
406
|
+
d({ type: Boolean, reflect: !0 })
|
|
400
407
|
], l.prototype, "error", 2);
|
|
401
408
|
h([
|
|
402
|
-
|
|
409
|
+
d({ type: Boolean, reflect: !0 })
|
|
403
410
|
], l.prototype, "required", 2);
|
|
404
411
|
l = h([
|
|
405
412
|
T("ucds-text-input")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ucalgary-design-system/text-input",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A web component for TextInput",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -19,5 +19,8 @@
|
|
|
19
19
|
"@ucalgary-design-system/helper-components": "^1.0.2",
|
|
20
20
|
"@ucalgary-design-system/tokens": "^1.0.4",
|
|
21
21
|
"lit": "^3.2.1"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"lerna": "^9.0.3"
|
|
22
25
|
}
|
|
23
26
|
}
|