@ucalgary-design-system/fieldset 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/README.md +57 -0
- package/fieldset.css +1 -0
- package/index.js +380 -0
- package/package.json +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Fieldset
|
|
2
|
+
|
|
3
|
+
This package provides the **Fieldset** web component.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the component using npm:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @ucalgary-design-system/fieldset
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Import the component into your application:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import '@ucalgary-design-system/fieldset';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Use the component in your HTML:
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<ucds-fieldset></ucds-fieldset>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
Build the component:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
npm run build
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Alternatively, build from the monorepo root:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npm run build -w @ucalgary-design-system/ucds-fieldset
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Run storybook from the monorepo root.
|
|
42
|
+
|
|
43
|
+
## Testing
|
|
44
|
+
|
|
45
|
+
Run the test from this package:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npm run test
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Alternatively, run the tests from the monorepo root:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npm run test -w @ucalgary-design-system/ucds-fieldset
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
|
package/fieldset.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--ucds-color-palette-brand-red: #d6001c;--ucds-color-palette-brand-gold: #ffcd00;--ucds-color-palette-brand-light-orange: #ffa300;--ucds-color-palette-brand-dark-orange: #ff7b1f;--ucds-color-palette-brand-berry: #9c0534;--ucds-color-palette-brand-rubine: #ce0058;--ucds-color-palette-brand-brown: #6b3529;--ucds-color-palette-brand-teal: #47a67c;--ucds-color-palette-white: #ffffff;--ucds-color-palette-black: #000000;--ucds-color-palette-gray-100: #2d2d2d;--ucds-color-palette-gray-200: #3d3d3d;--ucds-color-palette-gray-250: #4d4d4d;--ucds-color-palette-gray-300: #5d5d5d;--ucds-color-palette-gray-400: #8d8d8d;--ucds-color-palette-gray-500: #adadad;--ucds-color-palette-gray-600: #c0c0c0;--ucds-color-palette-gray-700: #d8d8d8;--ucds-color-palette-gray-800: #e5e5e5;--ucds-color-palette-gray-900: #f4f4f4;--ucds-color-palette-red-100: #3d0910;--ucds-color-palette-red-200: #5c0e18;--ucds-color-palette-red-300: #7a111f;--ucds-color-palette-red-400: #991022;--ucds-color-palette-red-500: #b70b21;--ucds-color-palette-red-600: #d6001c;--ucds-color-palette-red-700: #df3047;--ucds-color-palette-red-800: #ee0e2c;--ucds-color-palette-red-900: #ffadad;--ucds-color-palette-berry-600: #9c0534;--ucds-color-palette-berry-700: #a6192e;--ucds-color-palette-berry-800: #ea7b8a;--ucds-color-palette-berry-900: #f6ebed;--ucds-color-palette-rubine-600: #ce0058;--ucds-color-palette-rubine-800: #ed0a72;--ucds-color-palette-rubine-900: #ffa3c9;--ucds-color-palette-dark-orange-200: #6b3529;--ucds-color-palette-dark-orange-600: #ff671f;--ucds-color-palette-dark-orange-900: #fff2e9;--ucds-color-palette-light-orange-200: #614e00;--ucds-color-palette-light-orange-600: #ffa300;--ucds-color-palette-light-orange-900: #fff6e7;--ucds-color-palette-brown-600: #6c3302;--ucds-color-palette-brown-900: #ca7d68;--ucds-color-surface-page: #ffffff;--ucds-color-surface-primary: #ffffff;--ucds-color-border-neutral: #8d8d8d;--ucds-color-text-primary: #2d2d2d;--ucds-color-text-primary-inverse: #ffffff;--ucds-color-text-secondary: #5d5d5d;--ucds-color-text-error: #df3047;--ucds-color-text-disabled: #e5e5e5;--ucds-color-icon-primary: #2d2d2d;--ucds-color-icon-primary-inverse: #ffffff;--ucds-color-forms-input-background-rest: #ffffff;--ucds-color-forms-input-background-hover: #9c0534;--ucds-color-forms-input-background-active: #9c0534;--ucds-color-forms-input-background-selected: #9c0534;--ucds-color-forms-input-background-disabled: #e5e5e5;--ucds-color-forms-input-background-error: rgb(255 173 173 / 50%);--ucds-color-forms-input-border-rest: #8d8d8d;--ucds-color-forms-input-border-hover: #3d3d3d;--ucds-color-forms-input-border-active: #3d3d3d;--ucds-color-forms-input-border-selected: #9c0534;--ucds-color-forms-input-border-disabled: #e5e5e5;--ucds-color-forms-input-border-error: #df3047;--ucds-color-forms-input-element-disabled: #f4f4f4;--ucds-color-action-rest: #d6001c;--ucds-color-action-hover: #991022;--ucds-color-action-active: #991022;--ucds-color-action-focus: #4d4d4d;--ucds-color-action-visited: #991022;--ucds-color-action-secondary-rest: #2d2d2d;--ucds-color-action-secondary-hover: #4d4d4d;--ucds-color-action-secondary-active: #4d4d4d;--ucds-color-action-secondary-focus: #4d4d4d;--ucds-color-action-inverse-rest: #ffffff;--ucds-color-action-inverse-hover: #e5e5e5;--ucds-color-action-inverse-active: #e5e5e5;--ucds-color-action-inverse-focus: #ffffff;--ucds-color-feedback-error-light: #df3047;--ucds-color-feedback-error-background-light: rgb(255 173 173 / 50%);--ucds-font-base-size: 16px;--ucds-font-base-line-height: 24px;--ucds-font-base-weight-light: 200;--ucds-font-base-weight-normal: 400;--ucds-font-base-weight-medium: 500;--ucds-font-base-weight-semibold: 600;--ucds-font-base-weight-bold: 700;--ucds-font-sans-serif-family: "Proxima Nova", Arial, Helvetica, sans-serif;--ucds-font-serif-family: "Museo Slab", "Proxima Nova", Arial, Helvetica, sans-serif;--ucds-form-element-border-radius: 8px;--ucds-form-element-border-width: 2px;--ucds-form-element-height: 48px;--ucds-form-element-width: 100%;--ucds-form-element-maxwidth: 555px;--ucds-form-element-horizontal-padding: 16px;--ucds-form-component-intra-spacing: 8px;--ucds-form-component-inter-spacing: 16px}
|
package/index.js
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { unsafeCSS as A, nothing as m, html as p } from "lit";
|
|
2
|
+
import { BaseElement as U } from "@ucalgary-design-system/core";
|
|
3
|
+
import { FormLabel as C } from "@ucalgary-design-system/helper-components";
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2017 Google LLC
|
|
7
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
8
|
+
*/
|
|
9
|
+
const x = (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 y = globalThis, _ = y.ShadowRoot && (y.ShadyCSS === void 0 || y.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, O = Symbol(), S = /* @__PURE__ */ new WeakMap();
|
|
20
|
+
let T = class {
|
|
21
|
+
constructor(t, e, s) {
|
|
22
|
+
if (this._$cssResult$ = !0, s !== O) 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 (_ && t === void 0) {
|
|
29
|
+
const s = e !== void 0 && e.length === 1;
|
|
30
|
+
s && (t = S.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && S.set(e, t));
|
|
31
|
+
}
|
|
32
|
+
return t;
|
|
33
|
+
}
|
|
34
|
+
toString() {
|
|
35
|
+
return this.cssText;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const R = (i) => new T(typeof i == "string" ? i : i + "", void 0, O), M = (i, t) => {
|
|
39
|
+
if (_) i.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
|
|
40
|
+
else for (const e of t) {
|
|
41
|
+
const s = document.createElement("style"), r = y.litNonce;
|
|
42
|
+
r !== void 0 && s.setAttribute("nonce", r), s.textContent = e.cssText, i.appendChild(s);
|
|
43
|
+
}
|
|
44
|
+
}, v = _ ? (i) => i : (i) => i instanceof CSSStyleSheet ? ((t) => {
|
|
45
|
+
let e = "";
|
|
46
|
+
for (const s of t.cssRules) e += s.cssText;
|
|
47
|
+
return R(e);
|
|
48
|
+
})(i) : i;
|
|
49
|
+
/**
|
|
50
|
+
* @license
|
|
51
|
+
* Copyright 2017 Google LLC
|
|
52
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
|
+
*/
|
|
54
|
+
const { is: z, defineProperty: j, getOwnPropertyDescriptor: q, getOwnPropertyNames: k, getOwnPropertySymbols: L, getPrototypeOf: D } = Object, h = globalThis, w = h.trustedTypes, N = w ? w.emptyScript : "", g = h.reactiveElementPolyfillSupport, f = (i, t) => i, $ = { toAttribute(i, t) {
|
|
55
|
+
switch (t) {
|
|
56
|
+
case Boolean:
|
|
57
|
+
i = i ? N : 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
|
+
} }, E = (i, t) => !z(i, t), P = { attribute: !0, type: String, converter: $, reflect: !1, hasChanged: E };
|
|
83
|
+
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), h.litPropertyMetadata ?? (h.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.elementProperties.set(t, e), !e.noAccessor) {
|
|
93
|
+
const s = Symbol(), r = this.getPropertyDescriptor(t, s, e);
|
|
94
|
+
r !== void 0 && j(this.prototype, t, r);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
static getPropertyDescriptor(t, e, s) {
|
|
98
|
+
const { get: r, set: n } = q(this.prototype, t) ?? { get() {
|
|
99
|
+
return this[e];
|
|
100
|
+
}, set(o) {
|
|
101
|
+
this[e] = o;
|
|
102
|
+
} };
|
|
103
|
+
return { get() {
|
|
104
|
+
return r == null ? void 0 : r.call(this);
|
|
105
|
+
}, set(o) {
|
|
106
|
+
const a = r == null ? void 0 : r.call(this);
|
|
107
|
+
n.call(this, o), this.requestUpdate(t, a, s);
|
|
108
|
+
}, configurable: !0, enumerable: !0 };
|
|
109
|
+
}
|
|
110
|
+
static getPropertyOptions(t) {
|
|
111
|
+
return this.elementProperties.get(t) ?? P;
|
|
112
|
+
}
|
|
113
|
+
static _$Ei() {
|
|
114
|
+
if (this.hasOwnProperty(f("elementProperties"))) return;
|
|
115
|
+
const t = D(this);
|
|
116
|
+
t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
|
|
117
|
+
}
|
|
118
|
+
static finalize() {
|
|
119
|
+
if (this.hasOwnProperty(f("finalized"))) return;
|
|
120
|
+
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(f("properties"))) {
|
|
121
|
+
const e = this.properties, s = [...k(e), ...L(e)];
|
|
122
|
+
for (const r of s) this.createProperty(r, e[r]);
|
|
123
|
+
}
|
|
124
|
+
const t = this[Symbol.metadata];
|
|
125
|
+
if (t !== null) {
|
|
126
|
+
const e = litPropertyMetadata.get(t);
|
|
127
|
+
if (e !== void 0) for (const [s, r] of e) this.elementProperties.set(s, r);
|
|
128
|
+
}
|
|
129
|
+
this._$Eh = /* @__PURE__ */ new Map();
|
|
130
|
+
for (const [e, s] of this.elementProperties) {
|
|
131
|
+
const r = this._$Eu(e, s);
|
|
132
|
+
r !== void 0 && this._$Eh.set(r, e);
|
|
133
|
+
}
|
|
134
|
+
this.elementStyles = this.finalizeStyles(this.styles);
|
|
135
|
+
}
|
|
136
|
+
static finalizeStyles(t) {
|
|
137
|
+
const e = [];
|
|
138
|
+
if (Array.isArray(t)) {
|
|
139
|
+
const s = new Set(t.flat(1 / 0).reverse());
|
|
140
|
+
for (const r of s) e.unshift(v(r));
|
|
141
|
+
} else t !== void 0 && e.push(v(t));
|
|
142
|
+
return e;
|
|
143
|
+
}
|
|
144
|
+
static _$Eu(t, e) {
|
|
145
|
+
const s = e.attribute;
|
|
146
|
+
return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0;
|
|
147
|
+
}
|
|
148
|
+
constructor() {
|
|
149
|
+
super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
|
|
150
|
+
}
|
|
151
|
+
_$Ev() {
|
|
152
|
+
var t;
|
|
153
|
+
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));
|
|
154
|
+
}
|
|
155
|
+
addController(t) {
|
|
156
|
+
var e;
|
|
157
|
+
(this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t));
|
|
158
|
+
}
|
|
159
|
+
removeController(t) {
|
|
160
|
+
var e;
|
|
161
|
+
(e = this._$EO) == null || e.delete(t);
|
|
162
|
+
}
|
|
163
|
+
_$E_() {
|
|
164
|
+
const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
|
|
165
|
+
for (const s of e.keys()) this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]);
|
|
166
|
+
t.size > 0 && (this._$Ep = t);
|
|
167
|
+
}
|
|
168
|
+
createRenderRoot() {
|
|
169
|
+
const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
|
|
170
|
+
return M(t, this.constructor.elementStyles), t;
|
|
171
|
+
}
|
|
172
|
+
connectedCallback() {
|
|
173
|
+
var t;
|
|
174
|
+
this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((e) => {
|
|
175
|
+
var s;
|
|
176
|
+
return (s = e.hostConnected) == null ? void 0 : s.call(e);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
enableUpdating(t) {
|
|
180
|
+
}
|
|
181
|
+
disconnectedCallback() {
|
|
182
|
+
var t;
|
|
183
|
+
(t = this._$EO) == null || t.forEach((e) => {
|
|
184
|
+
var s;
|
|
185
|
+
return (s = e.hostDisconnected) == null ? void 0 : s.call(e);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
attributeChangedCallback(t, e, s) {
|
|
189
|
+
this._$AK(t, s);
|
|
190
|
+
}
|
|
191
|
+
_$EC(t, e) {
|
|
192
|
+
var n;
|
|
193
|
+
const s = this.constructor.elementProperties.get(t), r = this.constructor._$Eu(t, s);
|
|
194
|
+
if (r !== void 0 && s.reflect === !0) {
|
|
195
|
+
const o = (((n = s.converter) == null ? void 0 : n.toAttribute) !== void 0 ? s.converter : $).toAttribute(e, s.type);
|
|
196
|
+
this._$Em = t, o == null ? this.removeAttribute(r) : this.setAttribute(r, o), this._$Em = null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
_$AK(t, e) {
|
|
200
|
+
var n;
|
|
201
|
+
const s = this.constructor, r = s._$Eh.get(t);
|
|
202
|
+
if (r !== void 0 && this._$Em !== r) {
|
|
203
|
+
const o = s.getPropertyOptions(r), a = typeof o.converter == "function" ? { fromAttribute: o.converter } : ((n = o.converter) == null ? void 0 : n.fromAttribute) !== void 0 ? o.converter : $;
|
|
204
|
+
this._$Em = r, this[r] = a.fromAttribute(e, o.type), this._$Em = null;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
requestUpdate(t, e, s) {
|
|
208
|
+
if (t !== void 0) {
|
|
209
|
+
if (s ?? (s = this.constructor.getPropertyOptions(t)), !(s.hasChanged ?? E)(this[t], e)) return;
|
|
210
|
+
this.P(t, e, s);
|
|
211
|
+
}
|
|
212
|
+
this.isUpdatePending === !1 && (this._$ES = this._$ET());
|
|
213
|
+
}
|
|
214
|
+
P(t, e, s) {
|
|
215
|
+
this._$AL.has(t) || this._$AL.set(t, e), s.reflect === !0 && this._$Em !== t && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(t);
|
|
216
|
+
}
|
|
217
|
+
async _$ET() {
|
|
218
|
+
this.isUpdatePending = !0;
|
|
219
|
+
try {
|
|
220
|
+
await this._$ES;
|
|
221
|
+
} catch (e) {
|
|
222
|
+
Promise.reject(e);
|
|
223
|
+
}
|
|
224
|
+
const t = this.scheduleUpdate();
|
|
225
|
+
return t != null && await t, !this.isUpdatePending;
|
|
226
|
+
}
|
|
227
|
+
scheduleUpdate() {
|
|
228
|
+
return this.performUpdate();
|
|
229
|
+
}
|
|
230
|
+
performUpdate() {
|
|
231
|
+
var s;
|
|
232
|
+
if (!this.isUpdatePending) return;
|
|
233
|
+
if (!this.hasUpdated) {
|
|
234
|
+
if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
|
|
235
|
+
for (const [n, o] of this._$Ep) this[n] = o;
|
|
236
|
+
this._$Ep = void 0;
|
|
237
|
+
}
|
|
238
|
+
const r = this.constructor.elementProperties;
|
|
239
|
+
if (r.size > 0) for (const [n, o] of r) o.wrapped !== !0 || this._$AL.has(n) || this[n] === void 0 || this.P(n, this[n], o);
|
|
240
|
+
}
|
|
241
|
+
let t = !1;
|
|
242
|
+
const e = this._$AL;
|
|
243
|
+
try {
|
|
244
|
+
t = this.shouldUpdate(e), t ? (this.willUpdate(e), (s = this._$EO) == null || s.forEach((r) => {
|
|
245
|
+
var n;
|
|
246
|
+
return (n = r.hostUpdate) == null ? void 0 : n.call(r);
|
|
247
|
+
}), this.update(e)) : this._$EU();
|
|
248
|
+
} catch (r) {
|
|
249
|
+
throw t = !1, this._$EU(), r;
|
|
250
|
+
}
|
|
251
|
+
t && this._$AE(e);
|
|
252
|
+
}
|
|
253
|
+
willUpdate(t) {
|
|
254
|
+
}
|
|
255
|
+
_$AE(t) {
|
|
256
|
+
var e;
|
|
257
|
+
(e = this._$EO) == null || e.forEach((s) => {
|
|
258
|
+
var r;
|
|
259
|
+
return (r = s.hostUpdated) == null ? void 0 : r.call(s);
|
|
260
|
+
}), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
|
|
261
|
+
}
|
|
262
|
+
_$EU() {
|
|
263
|
+
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
|
|
264
|
+
}
|
|
265
|
+
get updateComplete() {
|
|
266
|
+
return this.getUpdateComplete();
|
|
267
|
+
}
|
|
268
|
+
getUpdateComplete() {
|
|
269
|
+
return this._$ES;
|
|
270
|
+
}
|
|
271
|
+
shouldUpdate(t) {
|
|
272
|
+
return !0;
|
|
273
|
+
}
|
|
274
|
+
update(t) {
|
|
275
|
+
this._$Ej && (this._$Ej = this._$Ej.forEach((e) => this._$EC(e, this[e]))), this._$EU();
|
|
276
|
+
}
|
|
277
|
+
updated(t) {
|
|
278
|
+
}
|
|
279
|
+
firstUpdated(t) {
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
u.elementStyles = [], u.shadowRootOptions = { mode: "open" }, u[f("elementProperties")] = /* @__PURE__ */ new Map(), u[f("finalized")] = /* @__PURE__ */ new Map(), g == null || g({ ReactiveElement: u }), (h.reactiveElementVersions ?? (h.reactiveElementVersions = [])).push("2.0.4");
|
|
283
|
+
/**
|
|
284
|
+
* @license
|
|
285
|
+
* Copyright 2017 Google LLC
|
|
286
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
287
|
+
*/
|
|
288
|
+
const B = { attribute: !0, type: String, converter: $, reflect: !1, hasChanged: E }, F = (i = B, t, e) => {
|
|
289
|
+
const { kind: s, metadata: r } = e;
|
|
290
|
+
let n = globalThis.litPropertyMetadata.get(r);
|
|
291
|
+
if (n === void 0 && globalThis.litPropertyMetadata.set(r, n = /* @__PURE__ */ new Map()), n.set(e.name, i), s === "accessor") {
|
|
292
|
+
const { name: o } = e;
|
|
293
|
+
return { set(a) {
|
|
294
|
+
const b = t.get.call(this);
|
|
295
|
+
t.set.call(this, a), this.requestUpdate(o, b, i);
|
|
296
|
+
}, init(a) {
|
|
297
|
+
return a !== void 0 && this.P(o, void 0, i), a;
|
|
298
|
+
} };
|
|
299
|
+
}
|
|
300
|
+
if (s === "setter") {
|
|
301
|
+
const { name: o } = e;
|
|
302
|
+
return function(a) {
|
|
303
|
+
const b = this[o];
|
|
304
|
+
t.call(this, a), this.requestUpdate(o, b, i);
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
throw Error("Unsupported decorator location: " + s);
|
|
308
|
+
};
|
|
309
|
+
function c(i) {
|
|
310
|
+
return (t, e) => typeof e == "object" ? F(i, t, e) : ((s, r, n) => {
|
|
311
|
+
const o = r.hasOwnProperty(n);
|
|
312
|
+
return r.constructor.createProperty(n, o ? { ...s, wrapped: !0 } : s), o ? Object.getOwnPropertyDescriptor(r, n) : void 0;
|
|
313
|
+
})(i, t, e);
|
|
314
|
+
}
|
|
315
|
+
const I = ":host{display:block}.form-fieldset{width:var(--ucds-form-element-width);max-width:var(--ucds-form-element-maxwidth);display:flex;flex-direction:column;gap:var(--ucds-form-component-intra-spacing)}.form-fieldset fieldset{border:none;padding:0;margin:0;display:flex;flex-direction:column;gap:var(--ucds-form-component-inter-spacing)}.form-fieldset fieldset legend{font-weight:var(--ucds-font-base-weight-bold);margin-bottom:var(--ucds-form-component-inter-spacing);padding:0}.form-fieldset fieldset legend:disabled{color:var(--ucds-color-text-disabled)}.form-fieldset fieldset:not(:last-child){margin-bottom:var(--ucds-form-component-intra-spacing)}";
|
|
316
|
+
var J = Object.defineProperty, K = Object.getOwnPropertyDescriptor, d = (i, t, e, s) => {
|
|
317
|
+
for (var r = s > 1 ? void 0 : s ? K(t, e) : t, n = i.length - 1, o; n >= 0; n--)
|
|
318
|
+
(o = i[n]) && (r = (s ? o(t, e, r) : o(r)) || r);
|
|
319
|
+
return s && r && J(t, e, r), r;
|
|
320
|
+
};
|
|
321
|
+
let l = class extends U {
|
|
322
|
+
constructor() {
|
|
323
|
+
super(...arguments), this.label = "", this.disabled = !1, this.required = !1, this.error = !1;
|
|
324
|
+
}
|
|
325
|
+
// Iterate over children (checkboxes/radios) and update disabled/errored states.
|
|
326
|
+
_updateChildren() {
|
|
327
|
+
if (this.hasChildNodes())
|
|
328
|
+
for (const i of this.children)
|
|
329
|
+
i.disabled = this.disabled, i.errors = this.error, i.error = !1, i.required = !1;
|
|
330
|
+
}
|
|
331
|
+
// Catch & handle any updates to the fieldset disabled/errored states.
|
|
332
|
+
update(i) {
|
|
333
|
+
super.update(i), (i.has("disabled") || i.has("error")) && this._updateChildren();
|
|
334
|
+
}
|
|
335
|
+
// Initialize component and warn if required properties have not been set.
|
|
336
|
+
firstUpdated(i) {
|
|
337
|
+
super.firstUpdated(i), this.label || console.error(`${this.localName}: Property 'label' is required and was not set.`);
|
|
338
|
+
}
|
|
339
|
+
render() {
|
|
340
|
+
return p`
|
|
341
|
+
<div class="form-fieldset">
|
|
342
|
+
<fieldset ?error=${this.error} ?disabled=${this.disabled}>
|
|
343
|
+
${this.label ? p`<legend ?disabled=${this.disabled}>${this.label}${this.required ? p`${C.requiredAsteriskTemplate()}` : m}</legend>` : m}
|
|
344
|
+
<slot>Please provide at least two <ucds-radio> or <ucds-checkbox> child elements</slot>
|
|
345
|
+
</fieldset>
|
|
346
|
+
${this.error && !this.disabled ? p`<form-error-message text="${this.errorText}"></form-error-message>` : m}
|
|
347
|
+
${this.helpText ? p`<form-help-message text="${this.helpText}" ?disabled="${this.disabled}"></form-help-message>` : m}
|
|
348
|
+
</div>
|
|
349
|
+
`;
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
l.styles = [
|
|
353
|
+
U.styles,
|
|
354
|
+
C.styles,
|
|
355
|
+
A(I)
|
|
356
|
+
];
|
|
357
|
+
d([
|
|
358
|
+
c({ type: String })
|
|
359
|
+
], l.prototype, "label", 2);
|
|
360
|
+
d([
|
|
361
|
+
c({ type: Boolean, reflect: !0 })
|
|
362
|
+
], l.prototype, "disabled", 2);
|
|
363
|
+
d([
|
|
364
|
+
c({ type: Boolean, reflect: !0 })
|
|
365
|
+
], l.prototype, "required", 2);
|
|
366
|
+
d([
|
|
367
|
+
c({ type: Boolean, reflect: !0 })
|
|
368
|
+
], l.prototype, "error", 2);
|
|
369
|
+
d([
|
|
370
|
+
c({ type: String, attribute: "error-text" })
|
|
371
|
+
], l.prototype, "errorText", 2);
|
|
372
|
+
d([
|
|
373
|
+
c({ type: String, attribute: "help-text" })
|
|
374
|
+
], l.prototype, "helpText", 2);
|
|
375
|
+
l = d([
|
|
376
|
+
x("ucds-fieldset")
|
|
377
|
+
], l);
|
|
378
|
+
export {
|
|
379
|
+
l as Fieldset
|
|
380
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ucalgary-design-system/fieldset",
|
|
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
|
+
"@ucalgary-design-system/core": "^1.0.1",
|
|
15
|
+
"@ucalgary-design-system/helper-components": "^1.0.1",
|
|
16
|
+
"@ucalgary-design-system/tokens": "^1.0.1",
|
|
17
|
+
"lit": "^3.2.1"
|
|
18
|
+
},
|
|
19
|
+
"description": "A web component for Fieldset",
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
}
|
|
23
|
+
}
|