@ucalgary-design-system/text-area 1.0.1
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/LICENSE.md +21 -0
- package/README.md +59 -0
- package/index.js +410 -0
- package/package.json +23 -0
package/CHANGELOG.md
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 University of Calgary
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the “Software”), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# TextArea
|
|
2
|
+
|
|
3
|
+
This package provides the **TextArea** web component.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the component using npm:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @ucalgary-design-system/text-area
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Import the component into your application:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import "@ucalgary-design-system/text-area";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Use the component in your HTML:
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<ucds-text-area></ucds-text-area>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
> 💡 Our components automatically load global design tokens when first used. You don’t need to import them manually!
|
|
28
|
+
|
|
29
|
+
## Development
|
|
30
|
+
|
|
31
|
+
Build the component:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm run build
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Alternatively, build from the monorepo root:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm run build -w @ucalgary-design-system/ucds-text-area
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Run storybook from the monorepo root.
|
|
44
|
+
|
|
45
|
+
## Testing
|
|
46
|
+
|
|
47
|
+
Run the test from this package:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npm run test
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Alternatively, run the tests from the monorepo root:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
npm run test -w @ucalgary-design-system/ucds-text-area
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
|
package/index.js
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
import { BaseElement as U, injectGlobalTokens as O } from "@ucalgary-design-system/core";
|
|
2
|
+
import { unsafeCSS as A, nothing as m, html as y } from "lit";
|
|
3
|
+
import "@ucalgary-design-system/helper-components";
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2017 Google LLC
|
|
7
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
8
|
+
*/
|
|
9
|
+
const T = (i) => (t, e) => {
|
|
10
|
+
e !== void 0 ? e.addInitializer(() => {
|
|
11
|
+
customElements.define(i, t);
|
|
12
|
+
}) : customElements.define(i, t);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @license
|
|
16
|
+
* Copyright 2019 Google LLC
|
|
17
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
18
|
+
*/
|
|
19
|
+
const b = globalThis, g = b.ShadowRoot && (b.ShadyCSS === void 0 || b.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, C = Symbol(), S = /* @__PURE__ */ new WeakMap();
|
|
20
|
+
let k = class {
|
|
21
|
+
constructor(t, e, r) {
|
|
22
|
+
if (this._$cssResult$ = !0, r !== C) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
23
|
+
this.cssText = t, this.t = e;
|
|
24
|
+
}
|
|
25
|
+
get styleSheet() {
|
|
26
|
+
let t = this.o;
|
|
27
|
+
const e = this.t;
|
|
28
|
+
if (g && t === void 0) {
|
|
29
|
+
const r = e !== void 0 && e.length === 1;
|
|
30
|
+
r && (t = S.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), r && S.set(e, t));
|
|
31
|
+
}
|
|
32
|
+
return t;
|
|
33
|
+
}
|
|
34
|
+
toString() {
|
|
35
|
+
return this.cssText;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const M = (i) => new k(typeof i == "string" ? i : i + "", void 0, C), R = (i, t) => {
|
|
39
|
+
if (g) i.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
|
|
40
|
+
else for (const e of t) {
|
|
41
|
+
const r = document.createElement("style"), s = b.litNonce;
|
|
42
|
+
s !== void 0 && r.setAttribute("nonce", s), r.textContent = e.cssText, i.appendChild(r);
|
|
43
|
+
}
|
|
44
|
+
}, x = g ? (i) => i : (i) => i instanceof CSSStyleSheet ? ((t) => {
|
|
45
|
+
let e = "";
|
|
46
|
+
for (const r of t.cssRules) e += r.cssText;
|
|
47
|
+
return M(e);
|
|
48
|
+
})(i) : i;
|
|
49
|
+
/**
|
|
50
|
+
* @license
|
|
51
|
+
* Copyright 2017 Google LLC
|
|
52
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
+
*/
|
|
54
|
+
const { is: q, defineProperty: z, getOwnPropertyDescriptor: j, getOwnPropertyNames: D, getOwnPropertySymbols: I, getPrototypeOf: L } = Object, c = globalThis, w = c.trustedTypes, B = w ? w.emptyScript : "", v = c.reactiveElementPolyfillSupport, f = (i, t) => i, $ = { toAttribute(i, t) {
|
|
55
|
+
switch (t) {
|
|
56
|
+
case Boolean:
|
|
57
|
+
i = i ? B : null;
|
|
58
|
+
break;
|
|
59
|
+
case Object:
|
|
60
|
+
case Array:
|
|
61
|
+
i = i == null ? i : JSON.stringify(i);
|
|
62
|
+
}
|
|
63
|
+
return i;
|
|
64
|
+
}, fromAttribute(i, t) {
|
|
65
|
+
let e = i;
|
|
66
|
+
switch (t) {
|
|
67
|
+
case Boolean:
|
|
68
|
+
e = i !== null;
|
|
69
|
+
break;
|
|
70
|
+
case Number:
|
|
71
|
+
e = i === null ? null : Number(i);
|
|
72
|
+
break;
|
|
73
|
+
case Object:
|
|
74
|
+
case Array:
|
|
75
|
+
try {
|
|
76
|
+
e = JSON.parse(i);
|
|
77
|
+
} catch {
|
|
78
|
+
e = null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return e;
|
|
82
|
+
} }, _ = (i, t) => !q(i, t), P = { attribute: !0, type: String, converter: $, reflect: !1, useDefault: !1, hasChanged: _ };
|
|
83
|
+
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), c.litPropertyMetadata ?? (c.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
|
|
84
|
+
class u extends HTMLElement {
|
|
85
|
+
static addInitializer(t) {
|
|
86
|
+
this._$Ei(), (this.l ?? (this.l = [])).push(t);
|
|
87
|
+
}
|
|
88
|
+
static get observedAttributes() {
|
|
89
|
+
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
|
|
90
|
+
}
|
|
91
|
+
static createProperty(t, e = P) {
|
|
92
|
+
if (e.state && (e.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((e = Object.create(e)).wrapped = !0), this.elementProperties.set(t, e), !e.noAccessor) {
|
|
93
|
+
const r = Symbol(), s = this.getPropertyDescriptor(t, r, e);
|
|
94
|
+
s !== void 0 && z(this.prototype, t, s);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
static getPropertyDescriptor(t, e, r) {
|
|
98
|
+
const { get: s, set: o } = j(this.prototype, t) ?? { get() {
|
|
99
|
+
return this[e];
|
|
100
|
+
}, set(a) {
|
|
101
|
+
this[e] = a;
|
|
102
|
+
} };
|
|
103
|
+
return { get: s, set(a) {
|
|
104
|
+
const n = s == null ? void 0 : s.call(this);
|
|
105
|
+
o == null || o.call(this, a), this.requestUpdate(t, n, r);
|
|
106
|
+
}, configurable: !0, enumerable: !0 };
|
|
107
|
+
}
|
|
108
|
+
static getPropertyOptions(t) {
|
|
109
|
+
return this.elementProperties.get(t) ?? P;
|
|
110
|
+
}
|
|
111
|
+
static _$Ei() {
|
|
112
|
+
if (this.hasOwnProperty(f("elementProperties"))) return;
|
|
113
|
+
const t = L(this);
|
|
114
|
+
t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
|
|
115
|
+
}
|
|
116
|
+
static finalize() {
|
|
117
|
+
if (this.hasOwnProperty(f("finalized"))) return;
|
|
118
|
+
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(f("properties"))) {
|
|
119
|
+
const e = this.properties, r = [...D(e), ...I(e)];
|
|
120
|
+
for (const s of r) this.createProperty(s, e[s]);
|
|
121
|
+
}
|
|
122
|
+
const t = this[Symbol.metadata];
|
|
123
|
+
if (t !== null) {
|
|
124
|
+
const e = litPropertyMetadata.get(t);
|
|
125
|
+
if (e !== void 0) for (const [r, s] of e) this.elementProperties.set(r, s);
|
|
126
|
+
}
|
|
127
|
+
this._$Eh = /* @__PURE__ */ new Map();
|
|
128
|
+
for (const [e, r] of this.elementProperties) {
|
|
129
|
+
const s = this._$Eu(e, r);
|
|
130
|
+
s !== void 0 && this._$Eh.set(s, e);
|
|
131
|
+
}
|
|
132
|
+
this.elementStyles = this.finalizeStyles(this.styles);
|
|
133
|
+
}
|
|
134
|
+
static finalizeStyles(t) {
|
|
135
|
+
const e = [];
|
|
136
|
+
if (Array.isArray(t)) {
|
|
137
|
+
const r = new Set(t.flat(1 / 0).reverse());
|
|
138
|
+
for (const s of r) e.unshift(x(s));
|
|
139
|
+
} else t !== void 0 && e.push(x(t));
|
|
140
|
+
return e;
|
|
141
|
+
}
|
|
142
|
+
static _$Eu(t, e) {
|
|
143
|
+
const r = e.attribute;
|
|
144
|
+
return r === !1 ? void 0 : typeof r == "string" ? r : typeof t == "string" ? t.toLowerCase() : void 0;
|
|
145
|
+
}
|
|
146
|
+
constructor() {
|
|
147
|
+
super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
|
|
148
|
+
}
|
|
149
|
+
_$Ev() {
|
|
150
|
+
var t;
|
|
151
|
+
this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this));
|
|
152
|
+
}
|
|
153
|
+
addController(t) {
|
|
154
|
+
var e;
|
|
155
|
+
(this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t));
|
|
156
|
+
}
|
|
157
|
+
removeController(t) {
|
|
158
|
+
var e;
|
|
159
|
+
(e = this._$EO) == null || e.delete(t);
|
|
160
|
+
}
|
|
161
|
+
_$E_() {
|
|
162
|
+
const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
|
|
163
|
+
for (const r of e.keys()) this.hasOwnProperty(r) && (t.set(r, this[r]), delete this[r]);
|
|
164
|
+
t.size > 0 && (this._$Ep = t);
|
|
165
|
+
}
|
|
166
|
+
createRenderRoot() {
|
|
167
|
+
const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
|
|
168
|
+
return R(t, this.constructor.elementStyles), t;
|
|
169
|
+
}
|
|
170
|
+
connectedCallback() {
|
|
171
|
+
var t;
|
|
172
|
+
this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((e) => {
|
|
173
|
+
var r;
|
|
174
|
+
return (r = e.hostConnected) == null ? void 0 : r.call(e);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
enableUpdating(t) {
|
|
178
|
+
}
|
|
179
|
+
disconnectedCallback() {
|
|
180
|
+
var t;
|
|
181
|
+
(t = this._$EO) == null || t.forEach((e) => {
|
|
182
|
+
var r;
|
|
183
|
+
return (r = e.hostDisconnected) == null ? void 0 : r.call(e);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
attributeChangedCallback(t, e, r) {
|
|
187
|
+
this._$AK(t, r);
|
|
188
|
+
}
|
|
189
|
+
_$ET(t, e) {
|
|
190
|
+
var o;
|
|
191
|
+
const r = this.constructor.elementProperties.get(t), s = this.constructor._$Eu(t, r);
|
|
192
|
+
if (s !== void 0 && r.reflect === !0) {
|
|
193
|
+
const a = (((o = r.converter) == null ? void 0 : o.toAttribute) !== void 0 ? r.converter : $).toAttribute(e, r.type);
|
|
194
|
+
this._$Em = t, a == null ? this.removeAttribute(s) : this.setAttribute(s, a), this._$Em = null;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
_$AK(t, e) {
|
|
198
|
+
var o, a;
|
|
199
|
+
const r = this.constructor, s = r._$Eh.get(t);
|
|
200
|
+
if (s !== void 0 && this._$Em !== s) {
|
|
201
|
+
const n = r.getPropertyOptions(s), d = typeof n.converter == "function" ? { fromAttribute: n.converter } : ((o = n.converter) == null ? void 0 : o.fromAttribute) !== void 0 ? n.converter : $;
|
|
202
|
+
this._$Em = s;
|
|
203
|
+
const E = d.fromAttribute(e, n.type);
|
|
204
|
+
this[s] = E ?? ((a = this._$Ej) == null ? void 0 : a.get(s)) ?? E, this._$Em = null;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
requestUpdate(t, e, r) {
|
|
208
|
+
var s;
|
|
209
|
+
if (t !== void 0) {
|
|
210
|
+
const o = this.constructor, a = this[t];
|
|
211
|
+
if (r ?? (r = o.getPropertyOptions(t)), !((r.hasChanged ?? _)(a, e) || r.useDefault && r.reflect && a === ((s = this._$Ej) == null ? void 0 : s.get(t)) && !this.hasAttribute(o._$Eu(t, r)))) return;
|
|
212
|
+
this.C(t, e, r);
|
|
213
|
+
}
|
|
214
|
+
this.isUpdatePending === !1 && (this._$ES = this._$EP());
|
|
215
|
+
}
|
|
216
|
+
C(t, e, { useDefault: r, reflect: s, wrapped: o }, a) {
|
|
217
|
+
r && !(this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Map())).has(t) && (this._$Ej.set(t, a ?? e ?? this[t]), o !== !0 || a !== void 0) || (this._$AL.has(t) || (this.hasUpdated || r || (e = void 0), this._$AL.set(t, e)), s === !0 && this._$Em !== t && (this._$Eq ?? (this._$Eq = /* @__PURE__ */ new Set())).add(t));
|
|
218
|
+
}
|
|
219
|
+
async _$EP() {
|
|
220
|
+
this.isUpdatePending = !0;
|
|
221
|
+
try {
|
|
222
|
+
await this._$ES;
|
|
223
|
+
} catch (e) {
|
|
224
|
+
Promise.reject(e);
|
|
225
|
+
}
|
|
226
|
+
const t = this.scheduleUpdate();
|
|
227
|
+
return t != null && await t, !this.isUpdatePending;
|
|
228
|
+
}
|
|
229
|
+
scheduleUpdate() {
|
|
230
|
+
return this.performUpdate();
|
|
231
|
+
}
|
|
232
|
+
performUpdate() {
|
|
233
|
+
var r;
|
|
234
|
+
if (!this.isUpdatePending) return;
|
|
235
|
+
if (!this.hasUpdated) {
|
|
236
|
+
if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
|
|
237
|
+
for (const [o, a] of this._$Ep) this[o] = a;
|
|
238
|
+
this._$Ep = void 0;
|
|
239
|
+
}
|
|
240
|
+
const s = this.constructor.elementProperties;
|
|
241
|
+
if (s.size > 0) for (const [o, a] of s) {
|
|
242
|
+
const { wrapped: n } = a, d = this[o];
|
|
243
|
+
n !== !0 || this._$AL.has(o) || d === void 0 || this.C(o, void 0, a, d);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
let t = !1;
|
|
247
|
+
const e = this._$AL;
|
|
248
|
+
try {
|
|
249
|
+
t = this.shouldUpdate(e), t ? (this.willUpdate(e), (r = this._$EO) == null || r.forEach((s) => {
|
|
250
|
+
var o;
|
|
251
|
+
return (o = s.hostUpdate) == null ? void 0 : o.call(s);
|
|
252
|
+
}), this.update(e)) : this._$EM();
|
|
253
|
+
} catch (s) {
|
|
254
|
+
throw t = !1, this._$EM(), s;
|
|
255
|
+
}
|
|
256
|
+
t && this._$AE(e);
|
|
257
|
+
}
|
|
258
|
+
willUpdate(t) {
|
|
259
|
+
}
|
|
260
|
+
_$AE(t) {
|
|
261
|
+
var e;
|
|
262
|
+
(e = this._$EO) == null || e.forEach((r) => {
|
|
263
|
+
var s;
|
|
264
|
+
return (s = r.hostUpdated) == null ? void 0 : s.call(r);
|
|
265
|
+
}), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
|
|
266
|
+
}
|
|
267
|
+
_$EM() {
|
|
268
|
+
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
|
|
269
|
+
}
|
|
270
|
+
get updateComplete() {
|
|
271
|
+
return this.getUpdateComplete();
|
|
272
|
+
}
|
|
273
|
+
getUpdateComplete() {
|
|
274
|
+
return this._$ES;
|
|
275
|
+
}
|
|
276
|
+
shouldUpdate(t) {
|
|
277
|
+
return !0;
|
|
278
|
+
}
|
|
279
|
+
update(t) {
|
|
280
|
+
this._$Eq && (this._$Eq = this._$Eq.forEach((e) => this._$ET(e, this[e]))), this._$EM();
|
|
281
|
+
}
|
|
282
|
+
updated(t) {
|
|
283
|
+
}
|
|
284
|
+
firstUpdated(t) {
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
u.elementStyles = [], u.shadowRootOptions = { mode: "open" }, u[f("elementProperties")] = /* @__PURE__ */ new Map(), u[f("finalized")] = /* @__PURE__ */ new Map(), v == null || v({ ReactiveElement: u }), (c.reactiveElementVersions ?? (c.reactiveElementVersions = [])).push("2.1.1");
|
|
288
|
+
/**
|
|
289
|
+
* @license
|
|
290
|
+
* Copyright 2017 Google LLC
|
|
291
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
292
|
+
*/
|
|
293
|
+
const N = { attribute: !0, type: String, converter: $, reflect: !1, hasChanged: _ }, V = (i = N, t, e) => {
|
|
294
|
+
const { kind: r, metadata: s } = e;
|
|
295
|
+
let o = globalThis.litPropertyMetadata.get(s);
|
|
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
|
+
const { name: a } = e;
|
|
298
|
+
return { set(n) {
|
|
299
|
+
const d = t.get.call(this);
|
|
300
|
+
t.set.call(this, n), this.requestUpdate(a, d, i);
|
|
301
|
+
}, init(n) {
|
|
302
|
+
return n !== void 0 && this.C(a, void 0, i, n), n;
|
|
303
|
+
} };
|
|
304
|
+
}
|
|
305
|
+
if (r === "setter") {
|
|
306
|
+
const { name: a } = e;
|
|
307
|
+
return function(n) {
|
|
308
|
+
const d = this[a];
|
|
309
|
+
t.call(this, n), this.requestUpdate(a, d, i);
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
throw Error("Unsupported decorator location: " + r);
|
|
313
|
+
};
|
|
314
|
+
function p(i) {
|
|
315
|
+
return (t, e) => typeof e == "object" ? V(i, t, e) : ((r, s, o) => {
|
|
316
|
+
const a = s.hasOwnProperty(o);
|
|
317
|
+
return s.constructor.createProperty(o, r), a ? Object.getOwnPropertyDescriptor(s, o) : void 0;
|
|
318
|
+
})(i, t, e);
|
|
319
|
+
}
|
|
320
|
+
const J = ":host{display:block}.text-area{display:flex;flex-direction:column;gap:var(--ucds-form-component-intra-spacing);align-items:start;max-width:var(--ucds-form-element-maxwidth)}.text-area textarea{display:block;min-width:115px;width:var(--ucds-form-element-width);height:96px;padding:16px var(--ucds-form-element-horizontal-padding);line-height:16px;color:var(--ucds-color-text-primary);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;resize:none}.text-area textarea:hover{border-color:var(--ucds-color-forms-input-border-hover)}.text-area textarea:focus{outline:var(--ucds-color-action-focus) 2px solid;outline-offset:2px}.text-area textarea::-moz-placeholder{font-style:italic;color:var(--ucds-color-text-secondary);line-height:16px}.text-area textarea::placeholder{font-style:italic;color:var(--ucds-color-text-secondary);line-height:16px}.text-area.error textarea{background-color:var(--ucds-color-feedback-error-background-light);border-color:var(--ucds-color-feedback-error-light)}.text-area.error textarea:hover{border-color:var(--ucds-color-forms-input-border-hover)}.text-area.disabled textarea{color:var(--ucds-color-text-disabled);background-color:transparent;border-color:var(--ucds-color-forms-input-border-disabled)}.text-area.disabled textarea::-moz-placeholder{color:var(--ucds-color-text-disabled)}.text-area.disabled textarea::placeholder{color:var(--ucds-color-text-disabled)}";
|
|
321
|
+
var K = Object.defineProperty, W = Object.getOwnPropertyDescriptor, h = (i, t, e, r) => {
|
|
322
|
+
for (var s = r > 1 ? void 0 : r ? W(t, e) : t, o = i.length - 1, a; o >= 0; o--)
|
|
323
|
+
(a = i[o]) && (s = (r ? a(t, e, s) : a(s)) || s);
|
|
324
|
+
return r && s && K(t, e, s), s;
|
|
325
|
+
};
|
|
326
|
+
let l = class extends U {
|
|
327
|
+
constructor() {
|
|
328
|
+
super(), this.label = "", this.helpText = "", this.errorText = "", this.inputId = "", this.error = !1, this.disabled = !1, this.required = !1, this._value = "", this.internals = this.attachInternals();
|
|
329
|
+
}
|
|
330
|
+
updated(i) {
|
|
331
|
+
i.has("label") && !this.label && console.error("Property 'label' is required and was not set for text-area.");
|
|
332
|
+
}
|
|
333
|
+
get value() {
|
|
334
|
+
return this._value;
|
|
335
|
+
}
|
|
336
|
+
set value(i) {
|
|
337
|
+
const t = this._value;
|
|
338
|
+
i !== t && (this._value = i, this.requestUpdate("value", t), this.internals.setFormValue(this._value));
|
|
339
|
+
}
|
|
340
|
+
handleInput(i) {
|
|
341
|
+
const t = i.target;
|
|
342
|
+
this.value = t.value;
|
|
343
|
+
}
|
|
344
|
+
formResetCallback() {
|
|
345
|
+
this.value = "";
|
|
346
|
+
}
|
|
347
|
+
formStateRestoreCallback(i) {
|
|
348
|
+
this.value = i;
|
|
349
|
+
}
|
|
350
|
+
checkValidity() {
|
|
351
|
+
return this.internals.checkValidity();
|
|
352
|
+
}
|
|
353
|
+
reportValidity() {
|
|
354
|
+
return this.internals.reportValidity();
|
|
355
|
+
}
|
|
356
|
+
render() {
|
|
357
|
+
return y`
|
|
358
|
+
<div class="text-area ${this.disabled ? "disabled" : ""} ${this.required ? "required" : ""} ${this.error ? "error" : ""}">
|
|
359
|
+
${this.label ? y`<form-label for="${this.inputId}" text="${this.label}" ?required="${this.required}" ?disabled="${this.disabled}"></form-label>` : m}
|
|
360
|
+
<textarea
|
|
361
|
+
id="${this.inputId}"
|
|
362
|
+
name="${this.inputId}"
|
|
363
|
+
.value="${this.value}"
|
|
364
|
+
?disabled=${this.disabled}
|
|
365
|
+
?required=${this.required}
|
|
366
|
+
placeholder="${this.placeholder ?? m}"
|
|
367
|
+
@input=${this.handleInput}>
|
|
368
|
+
</textarea>${this.error && this.errorText ? y`
|
|
369
|
+
<form-error-message text="${this.errorText}" ?disabled="${this.disabled}"></form-error-message>` : m}${this.helpText ? y`
|
|
370
|
+
<form-help-message text="${this.helpText}" ?disabled="${this.disabled}"></form-help-message>` : m}
|
|
371
|
+
</div>
|
|
372
|
+
`;
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
l.styles = [
|
|
376
|
+
U.styles,
|
|
377
|
+
A(J)
|
|
378
|
+
];
|
|
379
|
+
l.formAssociated = !0;
|
|
380
|
+
h([
|
|
381
|
+
p({ type: String })
|
|
382
|
+
], l.prototype, "label", 2);
|
|
383
|
+
h([
|
|
384
|
+
p({ type: String, attribute: "help-text" })
|
|
385
|
+
], l.prototype, "helpText", 2);
|
|
386
|
+
h([
|
|
387
|
+
p({ type: String, attribute: "error-text" })
|
|
388
|
+
], l.prototype, "errorText", 2);
|
|
389
|
+
h([
|
|
390
|
+
p({ type: String, attribute: "input-id" })
|
|
391
|
+
], l.prototype, "inputId", 2);
|
|
392
|
+
h([
|
|
393
|
+
p({ type: String, reflect: !0 })
|
|
394
|
+
], l.prototype, "placeholder", 2);
|
|
395
|
+
h([
|
|
396
|
+
p({ type: Boolean, reflect: !0 })
|
|
397
|
+
], l.prototype, "error", 2);
|
|
398
|
+
h([
|
|
399
|
+
p({ type: Boolean, reflect: !0 })
|
|
400
|
+
], l.prototype, "disabled", 2);
|
|
401
|
+
h([
|
|
402
|
+
p({ type: Boolean, reflect: !0 })
|
|
403
|
+
], l.prototype, "required", 2);
|
|
404
|
+
l = h([
|
|
405
|
+
T("ucds-text-area")
|
|
406
|
+
], l);
|
|
407
|
+
O();
|
|
408
|
+
export {
|
|
409
|
+
l as TextArea
|
|
410
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ucalgary-design-system/text-area",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./index.js",
|
|
10
|
+
"require": "./index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"@ucalgary-design-system/core": "^1.0.6",
|
|
15
|
+
"@ucalgary-design-system/tokens": "^1.0.0",
|
|
16
|
+
"@ucalgary-design-system/helper-components": "^1.0.2",
|
|
17
|
+
"lit": "^3.2.1"
|
|
18
|
+
},
|
|
19
|
+
"description": "A web component for TextArea",
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
}
|
|
23
|
+
}
|