@ucalgary-design-system/core 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.
Files changed (4) hide show
  1. package/README.md +34 -0
  2. package/core.css +1 -0
  3. package/index.js +320 -0
  4. package/package.json +19 -0
package/index.js ADDED
@@ -0,0 +1,320 @@
1
+ import { css as g, LitElement as v } from "lit";
2
+ /**
3
+ * @license
4
+ * Copyright 2017 Google LLC
5
+ * SPDX-License-Identifier: BSD-3-Clause
6
+ */
7
+ const P = (r) => (t, e) => {
8
+ e !== void 0 ? e.addInitializer(() => {
9
+ customElements.define(r, t);
10
+ }) : customElements.define(r, t);
11
+ };
12
+ /**
13
+ * @license
14
+ * Copyright 2019 Google LLC
15
+ * SPDX-License-Identifier: BSD-3-Clause
16
+ */
17
+ const l = globalThis, y = l.ShadowRoot && (l.ShadyCSS === void 0 || l.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, S = Symbol(), m = /* @__PURE__ */ new WeakMap();
18
+ let w = class {
19
+ constructor(t, e, s) {
20
+ if (this._$cssResult$ = !0, s !== S) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
21
+ this.cssText = t, this.t = e;
22
+ }
23
+ get styleSheet() {
24
+ let t = this.o;
25
+ const e = this.t;
26
+ if (y && t === void 0) {
27
+ const s = e !== void 0 && e.length === 1;
28
+ s && (t = m.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && m.set(e, t));
29
+ }
30
+ return t;
31
+ }
32
+ toString() {
33
+ return this.cssText;
34
+ }
35
+ };
36
+ const U = (r) => new w(typeof r == "string" ? r : r + "", void 0, S), C = (r, t) => {
37
+ if (y) r.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
38
+ else for (const e of t) {
39
+ const s = document.createElement("style"), i = l.litNonce;
40
+ i !== void 0 && s.setAttribute("nonce", i), s.textContent = e.cssText, r.appendChild(s);
41
+ }
42
+ }, E = y ? (r) => r : (r) => r instanceof CSSStyleSheet ? ((t) => {
43
+ let e = "";
44
+ for (const s of t.cssRules) e += s.cssText;
45
+ return U(e);
46
+ })(r) : r;
47
+ /**
48
+ * @license
49
+ * Copyright 2017 Google LLC
50
+ * SPDX-License-Identifier: BSD-3-Clause
51
+ */
52
+ const { is: O, defineProperty: A, getOwnPropertyDescriptor: R, getOwnPropertyNames: z, getOwnPropertySymbols: x, getPrototypeOf: M } = Object, a = globalThis, $ = a.trustedTypes, T = $ ? $.emptyScript : "", p = a.reactiveElementPolyfillSupport, c = (r, t) => r, u = { toAttribute(r, t) {
53
+ switch (t) {
54
+ case Boolean:
55
+ r = r ? T : null;
56
+ break;
57
+ case Object:
58
+ case Array:
59
+ r = r == null ? r : JSON.stringify(r);
60
+ }
61
+ return r;
62
+ }, fromAttribute(r, t) {
63
+ let e = r;
64
+ switch (t) {
65
+ case Boolean:
66
+ e = r !== null;
67
+ break;
68
+ case Number:
69
+ e = r === null ? null : Number(r);
70
+ break;
71
+ case Object:
72
+ case Array:
73
+ try {
74
+ e = JSON.parse(r);
75
+ } catch {
76
+ e = null;
77
+ }
78
+ }
79
+ return e;
80
+ } }, b = (r, t) => !O(r, t), _ = { attribute: !0, type: String, converter: u, reflect: !1, hasChanged: b };
81
+ Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), a.litPropertyMetadata ?? (a.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
82
+ class h extends HTMLElement {
83
+ static addInitializer(t) {
84
+ this._$Ei(), (this.l ?? (this.l = [])).push(t);
85
+ }
86
+ static get observedAttributes() {
87
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
88
+ }
89
+ static createProperty(t, e = _) {
90
+ if (e.state && (e.attribute = !1), this._$Ei(), this.elementProperties.set(t, e), !e.noAccessor) {
91
+ const s = Symbol(), i = this.getPropertyDescriptor(t, s, e);
92
+ i !== void 0 && A(this.prototype, t, i);
93
+ }
94
+ }
95
+ static getPropertyDescriptor(t, e, s) {
96
+ const { get: i, set: o } = R(this.prototype, t) ?? { get() {
97
+ return this[e];
98
+ }, set(n) {
99
+ this[e] = n;
100
+ } };
101
+ return { get() {
102
+ return i == null ? void 0 : i.call(this);
103
+ }, set(n) {
104
+ const d = i == null ? void 0 : i.call(this);
105
+ o.call(this, n), this.requestUpdate(t, d, s);
106
+ }, configurable: !0, enumerable: !0 };
107
+ }
108
+ static getPropertyOptions(t) {
109
+ return this.elementProperties.get(t) ?? _;
110
+ }
111
+ static _$Ei() {
112
+ if (this.hasOwnProperty(c("elementProperties"))) return;
113
+ const t = M(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(c("finalized"))) return;
118
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(c("properties"))) {
119
+ const e = this.properties, s = [...z(e), ...x(e)];
120
+ for (const i of s) this.createProperty(i, e[i]);
121
+ }
122
+ const t = this[Symbol.metadata];
123
+ if (t !== null) {
124
+ const e = litPropertyMetadata.get(t);
125
+ if (e !== void 0) for (const [s, i] of e) this.elementProperties.set(s, i);
126
+ }
127
+ this._$Eh = /* @__PURE__ */ new Map();
128
+ for (const [e, s] of this.elementProperties) {
129
+ const i = this._$Eu(e, s);
130
+ i !== void 0 && this._$Eh.set(i, e);
131
+ }
132
+ this.elementStyles = this.finalizeStyles(this.styles);
133
+ }
134
+ static finalizeStyles(t) {
135
+ const e = [];
136
+ if (Array.isArray(t)) {
137
+ const s = new Set(t.flat(1 / 0).reverse());
138
+ for (const i of s) e.unshift(E(i));
139
+ } else t !== void 0 && e.push(E(t));
140
+ return e;
141
+ }
142
+ static _$Eu(t, e) {
143
+ const s = e.attribute;
144
+ return s === !1 ? void 0 : typeof s == "string" ? s : 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 s of e.keys()) this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]);
164
+ t.size > 0 && (this._$Ep = t);
165
+ }
166
+ createRenderRoot() {
167
+ const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
168
+ return C(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 s;
174
+ return (s = e.hostConnected) == null ? void 0 : s.call(e);
175
+ });
176
+ }
177
+ enableUpdating(t) {
178
+ }
179
+ disconnectedCallback() {
180
+ var t;
181
+ (t = this._$EO) == null || t.forEach((e) => {
182
+ var s;
183
+ return (s = e.hostDisconnected) == null ? void 0 : s.call(e);
184
+ });
185
+ }
186
+ attributeChangedCallback(t, e, s) {
187
+ this._$AK(t, s);
188
+ }
189
+ _$EC(t, e) {
190
+ var o;
191
+ const s = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, s);
192
+ if (i !== void 0 && s.reflect === !0) {
193
+ const n = (((o = s.converter) == null ? void 0 : o.toAttribute) !== void 0 ? s.converter : u).toAttribute(e, s.type);
194
+ this._$Em = t, n == null ? this.removeAttribute(i) : this.setAttribute(i, n), this._$Em = null;
195
+ }
196
+ }
197
+ _$AK(t, e) {
198
+ var o;
199
+ const s = this.constructor, i = s._$Eh.get(t);
200
+ if (i !== void 0 && this._$Em !== i) {
201
+ const n = s.getPropertyOptions(i), d = typeof n.converter == "function" ? { fromAttribute: n.converter } : ((o = n.converter) == null ? void 0 : o.fromAttribute) !== void 0 ? n.converter : u;
202
+ this._$Em = i, this[i] = d.fromAttribute(e, n.type), this._$Em = null;
203
+ }
204
+ }
205
+ requestUpdate(t, e, s) {
206
+ if (t !== void 0) {
207
+ if (s ?? (s = this.constructor.getPropertyOptions(t)), !(s.hasChanged ?? b)(this[t], e)) return;
208
+ this.P(t, e, s);
209
+ }
210
+ this.isUpdatePending === !1 && (this._$ES = this._$ET());
211
+ }
212
+ P(t, e, s) {
213
+ this._$AL.has(t) || this._$AL.set(t, e), s.reflect === !0 && this._$Em !== t && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(t);
214
+ }
215
+ async _$ET() {
216
+ this.isUpdatePending = !0;
217
+ try {
218
+ await this._$ES;
219
+ } catch (e) {
220
+ Promise.reject(e);
221
+ }
222
+ const t = this.scheduleUpdate();
223
+ return t != null && await t, !this.isUpdatePending;
224
+ }
225
+ scheduleUpdate() {
226
+ return this.performUpdate();
227
+ }
228
+ performUpdate() {
229
+ var s;
230
+ if (!this.isUpdatePending) return;
231
+ if (!this.hasUpdated) {
232
+ if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
233
+ for (const [o, n] of this._$Ep) this[o] = n;
234
+ this._$Ep = void 0;
235
+ }
236
+ const i = this.constructor.elementProperties;
237
+ if (i.size > 0) for (const [o, n] of i) n.wrapped !== !0 || this._$AL.has(o) || this[o] === void 0 || this.P(o, this[o], n);
238
+ }
239
+ let t = !1;
240
+ const e = this._$AL;
241
+ try {
242
+ t = this.shouldUpdate(e), t ? (this.willUpdate(e), (s = this._$EO) == null || s.forEach((i) => {
243
+ var o;
244
+ return (o = i.hostUpdate) == null ? void 0 : o.call(i);
245
+ }), this.update(e)) : this._$EU();
246
+ } catch (i) {
247
+ throw t = !1, this._$EU(), i;
248
+ }
249
+ t && this._$AE(e);
250
+ }
251
+ willUpdate(t) {
252
+ }
253
+ _$AE(t) {
254
+ var e;
255
+ (e = this._$EO) == null || e.forEach((s) => {
256
+ var i;
257
+ return (i = s.hostUpdated) == null ? void 0 : i.call(s);
258
+ }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
259
+ }
260
+ _$EU() {
261
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
262
+ }
263
+ get updateComplete() {
264
+ return this.getUpdateComplete();
265
+ }
266
+ getUpdateComplete() {
267
+ return this._$ES;
268
+ }
269
+ shouldUpdate(t) {
270
+ return !0;
271
+ }
272
+ update(t) {
273
+ this._$Ej && (this._$Ej = this._$Ej.forEach((e) => this._$EC(e, this[e]))), this._$EU();
274
+ }
275
+ updated(t) {
276
+ }
277
+ firstUpdated(t) {
278
+ }
279
+ }
280
+ h.elementStyles = [], h.shadowRootOptions = { mode: "open" }, h[c("elementProperties")] = /* @__PURE__ */ new Map(), h[c("finalized")] = /* @__PURE__ */ new Map(), p == null || p({ ReactiveElement: h }), (a.reactiveElementVersions ?? (a.reactiveElementVersions = [])).push("2.0.4");
281
+ var k = Object.getOwnPropertyDescriptor, L = (r, t, e, s) => {
282
+ for (var i = s > 1 ? void 0 : s ? k(t, e) : t, o = r.length - 1, n; o >= 0; o--)
283
+ (n = r[o]) && (i = n(i) || i);
284
+ return i;
285
+ };
286
+ let f = class extends v {
287
+ };
288
+ f.styles = g`
289
+
290
+ :host {
291
+ font-family: var(--ucds-font-sans-serif-family);
292
+ font-size: var(--ucds-font-base-size);
293
+ line-height: var(--ucds-font-base-line-height);
294
+ color: var(--ucds-color-text-primary);
295
+
296
+ /* Try to make font rendering consistent across various systems. */
297
+ -webkit-font-smoothing: antialiased;
298
+ text-rendering: optimizeLegibility;
299
+
300
+ *,
301
+ *:before,
302
+ *:after {
303
+ box-sizing: border-box;
304
+ }
305
+ }
306
+
307
+ button,
308
+ input,
309
+ textarea,
310
+ select {
311
+ font: inherit;
312
+ color: inherit;
313
+ }
314
+ `;
315
+ f = L([
316
+ P("base-element")
317
+ ], f);
318
+ export {
319
+ f as BaseElement
320
+ };
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@ucalgary-design-system/core",
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
+ "dependencies": {
14
+ "lit": "^3.2.1"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ }
19
+ }