@getflip/swirl-components 0.97.0 → 0.98.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/components.json +395 -3
- package/dist/cjs/index-506fe4ea.js +20 -8
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-accordion-item.cjs.entry.js +76 -0
- package/dist/cjs/swirl-accordion.cjs.entry.js +34 -0
- package/dist/cjs/swirl-app-layout_7.cjs.entry.js +2 -75
- package/dist/cjs/swirl-color-input.cjs.entry.js +78 -0
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-modal.cjs.entry.js +1 -1
- package/dist/cjs/v4-8e8d6fbc.js +77 -0
- package/dist/collection/collection-manifest.json +4 -1
- package/dist/collection/components/swirl-accordion/swirl-accordion.css +7 -0
- package/dist/collection/components/swirl-accordion/swirl-accordion.js +33 -0
- package/dist/collection/components/swirl-accordion/swirl-accordion.spec.js +67 -0
- package/dist/collection/components/swirl-accordion/swirl-accordion.stories.js +64 -0
- package/dist/collection/components/swirl-accordion-item/swirl-accordion-item.css +155 -0
- package/dist/collection/components/swirl-accordion-item/swirl-accordion-item.js +246 -0
- package/dist/collection/components/swirl-accordion-item/swirl-accordion-item.spec.js +87 -0
- package/dist/collection/components/swirl-accordion-item/swirl-accordion-item.stories.js +34 -0
- package/dist/collection/components/swirl-color-input/swirl-color-input.css +68 -0
- package/dist/collection/components/swirl-color-input/swirl-color-input.js +292 -0
- package/dist/collection/components/swirl-color-input/swirl-color-input.spec.js +62 -0
- package/dist/collection/components/swirl-color-input/swirl-color-input.stories.js +22 -0
- package/dist/collection/components/swirl-modal/swirl-modal.css +4 -0
- package/dist/components/swirl-accordion-item.d.ts +11 -0
- package/dist/components/swirl-accordion-item.js +113 -0
- package/dist/components/swirl-accordion.d.ts +11 -0
- package/dist/components/swirl-accordion.js +49 -0
- package/dist/components/swirl-color-input.d.ts +11 -0
- package/dist/components/swirl-color-input.js +102 -0
- package/dist/components/swirl-icon.js +1 -35
- package/dist/components/swirl-icon2.js +37 -0
- package/dist/components/swirl-modal.js +1 -1
- package/dist/components/swirl-resource-list-item2.js +1 -74
- package/dist/components/v4.js +75 -0
- package/dist/esm/index-99d0060d.js +20 -8
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-accordion-item.entry.js +72 -0
- package/dist/esm/swirl-accordion.entry.js +30 -0
- package/dist/esm/swirl-app-layout_7.entry.js +1 -74
- package/dist/esm/swirl-color-input.entry.js +74 -0
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-modal.entry.js +1 -1
- package/dist/esm/v4-fa4bb814.js +75 -0
- package/dist/swirl-components/p-19b890a3.js +1 -0
- package/dist/swirl-components/p-230745da.entry.js +1 -0
- package/dist/swirl-components/p-244a747a.entry.js +1 -0
- package/dist/swirl-components/{p-0fc0cd2c.entry.js → p-342bb04d.entry.js} +1 -1
- package/dist/swirl-components/p-b1648433.entry.js +1 -0
- package/dist/swirl-components/p-e8231bad.entry.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-accordion/swirl-accordion.d.ts +6 -0
- package/dist/types/components/swirl-accordion/swirl-accordion.stories.d.ts +14 -0
- package/dist/types/components/swirl-accordion-item/swirl-accordion-item.d.ts +30 -0
- package/dist/types/components/swirl-accordion-item/swirl-accordion-item.stories.d.ts +14 -0
- package/dist/types/components/swirl-color-input/swirl-color-input.d.ts +24 -0
- package/dist/types/components/swirl-color-input/swirl-color-input.stories.d.ts +14 -0
- package/dist/types/components.d.ts +97 -4
- package/package.json +1 -1
- package/vscode-data.json +82 -0
- package/dist/swirl-components/p-8a00faee.entry.js +0 -1
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { h, Host, } from "@stencil/core";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
export class SwirlColorInput {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.onChange = (event) => {
|
|
6
|
+
const el = event.target;
|
|
7
|
+
this.value = el.value;
|
|
8
|
+
};
|
|
9
|
+
this.onBlur = (event) => {
|
|
10
|
+
this.inputBlur.emit(event);
|
|
11
|
+
};
|
|
12
|
+
this.onFocus = (event) => {
|
|
13
|
+
this.inputFocus.emit(event);
|
|
14
|
+
this.handleAutoSelect(event);
|
|
15
|
+
};
|
|
16
|
+
this.onInput = (event) => {
|
|
17
|
+
this.onChange(event);
|
|
18
|
+
};
|
|
19
|
+
this.autoFocus = undefined;
|
|
20
|
+
this.autoSelect = undefined;
|
|
21
|
+
this.disabled = undefined;
|
|
22
|
+
this.swirlAriaDescribedby = undefined;
|
|
23
|
+
this.inline = undefined;
|
|
24
|
+
this.invalid = undefined;
|
|
25
|
+
this.placeholder = undefined;
|
|
26
|
+
this.required = undefined;
|
|
27
|
+
this.value = undefined;
|
|
28
|
+
}
|
|
29
|
+
componentDidLoad() {
|
|
30
|
+
// see https://stackoverflow.com/a/27314017
|
|
31
|
+
if (this.autoFocus) {
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
this.inputEl.focus();
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
watchValue(newValue, oldValue) {
|
|
38
|
+
if (newValue !== oldValue) {
|
|
39
|
+
this.valueChange.emit(newValue);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
handleAutoSelect(event) {
|
|
43
|
+
if (!this.autoSelect) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
event.target.select();
|
|
47
|
+
}
|
|
48
|
+
render() {
|
|
49
|
+
const ariaInvalid = this.invalid === true || this.invalid === false
|
|
50
|
+
? String(this.invalid)
|
|
51
|
+
: undefined;
|
|
52
|
+
const className = classnames("color-input", {
|
|
53
|
+
"color-input--inline": this.inline,
|
|
54
|
+
});
|
|
55
|
+
return (h(Host, null, h("div", { class: className }, h("input", { "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, autoFocus: this.autoFocus, class: "color-input__input", disabled: this.disabled, maxLength: 9, onBlur: this.onBlur, onFocus: this.onFocus, onInput: this.onInput, placeholder: this.placeholder, ref: (el) => (this.inputEl = el), required: this.required, spellcheck: "false", type: "text", value: this.value }), h("span", { class: "color-input__preview", style: {
|
|
56
|
+
backgroundColor: this.disabled
|
|
57
|
+
? "var(--s-border-subdued)"
|
|
58
|
+
: this.value,
|
|
59
|
+
} }))));
|
|
60
|
+
}
|
|
61
|
+
static get is() { return "swirl-color-input"; }
|
|
62
|
+
static get encapsulation() { return "scoped"; }
|
|
63
|
+
static get originalStyleUrls() {
|
|
64
|
+
return {
|
|
65
|
+
"$": ["swirl-color-input.css"]
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
static get styleUrls() {
|
|
69
|
+
return {
|
|
70
|
+
"$": ["swirl-color-input.css"]
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
static get properties() {
|
|
74
|
+
return {
|
|
75
|
+
"autoFocus": {
|
|
76
|
+
"type": "boolean",
|
|
77
|
+
"mutable": false,
|
|
78
|
+
"complexType": {
|
|
79
|
+
"original": "boolean",
|
|
80
|
+
"resolved": "boolean",
|
|
81
|
+
"references": {}
|
|
82
|
+
},
|
|
83
|
+
"required": false,
|
|
84
|
+
"optional": true,
|
|
85
|
+
"docs": {
|
|
86
|
+
"tags": [],
|
|
87
|
+
"text": ""
|
|
88
|
+
},
|
|
89
|
+
"attribute": "auto-focus",
|
|
90
|
+
"reflect": false
|
|
91
|
+
},
|
|
92
|
+
"autoSelect": {
|
|
93
|
+
"type": "boolean",
|
|
94
|
+
"mutable": false,
|
|
95
|
+
"complexType": {
|
|
96
|
+
"original": "boolean",
|
|
97
|
+
"resolved": "boolean",
|
|
98
|
+
"references": {}
|
|
99
|
+
},
|
|
100
|
+
"required": false,
|
|
101
|
+
"optional": true,
|
|
102
|
+
"docs": {
|
|
103
|
+
"tags": [],
|
|
104
|
+
"text": ""
|
|
105
|
+
},
|
|
106
|
+
"attribute": "auto-select",
|
|
107
|
+
"reflect": false
|
|
108
|
+
},
|
|
109
|
+
"disabled": {
|
|
110
|
+
"type": "boolean",
|
|
111
|
+
"mutable": false,
|
|
112
|
+
"complexType": {
|
|
113
|
+
"original": "boolean",
|
|
114
|
+
"resolved": "boolean",
|
|
115
|
+
"references": {}
|
|
116
|
+
},
|
|
117
|
+
"required": false,
|
|
118
|
+
"optional": true,
|
|
119
|
+
"docs": {
|
|
120
|
+
"tags": [],
|
|
121
|
+
"text": ""
|
|
122
|
+
},
|
|
123
|
+
"attribute": "disabled",
|
|
124
|
+
"reflect": false
|
|
125
|
+
},
|
|
126
|
+
"swirlAriaDescribedby": {
|
|
127
|
+
"type": "string",
|
|
128
|
+
"mutable": false,
|
|
129
|
+
"complexType": {
|
|
130
|
+
"original": "string",
|
|
131
|
+
"resolved": "string",
|
|
132
|
+
"references": {}
|
|
133
|
+
},
|
|
134
|
+
"required": false,
|
|
135
|
+
"optional": true,
|
|
136
|
+
"docs": {
|
|
137
|
+
"tags": [],
|
|
138
|
+
"text": ""
|
|
139
|
+
},
|
|
140
|
+
"attribute": "swirl-aria-describedby",
|
|
141
|
+
"reflect": false
|
|
142
|
+
},
|
|
143
|
+
"inline": {
|
|
144
|
+
"type": "boolean",
|
|
145
|
+
"mutable": false,
|
|
146
|
+
"complexType": {
|
|
147
|
+
"original": "boolean",
|
|
148
|
+
"resolved": "boolean",
|
|
149
|
+
"references": {}
|
|
150
|
+
},
|
|
151
|
+
"required": false,
|
|
152
|
+
"optional": true,
|
|
153
|
+
"docs": {
|
|
154
|
+
"tags": [],
|
|
155
|
+
"text": ""
|
|
156
|
+
},
|
|
157
|
+
"attribute": "inline",
|
|
158
|
+
"reflect": false
|
|
159
|
+
},
|
|
160
|
+
"invalid": {
|
|
161
|
+
"type": "boolean",
|
|
162
|
+
"mutable": false,
|
|
163
|
+
"complexType": {
|
|
164
|
+
"original": "boolean",
|
|
165
|
+
"resolved": "boolean",
|
|
166
|
+
"references": {}
|
|
167
|
+
},
|
|
168
|
+
"required": false,
|
|
169
|
+
"optional": true,
|
|
170
|
+
"docs": {
|
|
171
|
+
"tags": [],
|
|
172
|
+
"text": ""
|
|
173
|
+
},
|
|
174
|
+
"attribute": "invalid",
|
|
175
|
+
"reflect": false
|
|
176
|
+
},
|
|
177
|
+
"placeholder": {
|
|
178
|
+
"type": "string",
|
|
179
|
+
"mutable": false,
|
|
180
|
+
"complexType": {
|
|
181
|
+
"original": "string",
|
|
182
|
+
"resolved": "string",
|
|
183
|
+
"references": {}
|
|
184
|
+
},
|
|
185
|
+
"required": false,
|
|
186
|
+
"optional": true,
|
|
187
|
+
"docs": {
|
|
188
|
+
"tags": [],
|
|
189
|
+
"text": ""
|
|
190
|
+
},
|
|
191
|
+
"attribute": "placeholder",
|
|
192
|
+
"reflect": false
|
|
193
|
+
},
|
|
194
|
+
"required": {
|
|
195
|
+
"type": "boolean",
|
|
196
|
+
"mutable": false,
|
|
197
|
+
"complexType": {
|
|
198
|
+
"original": "boolean",
|
|
199
|
+
"resolved": "boolean",
|
|
200
|
+
"references": {}
|
|
201
|
+
},
|
|
202
|
+
"required": false,
|
|
203
|
+
"optional": true,
|
|
204
|
+
"docs": {
|
|
205
|
+
"tags": [],
|
|
206
|
+
"text": ""
|
|
207
|
+
},
|
|
208
|
+
"attribute": "required",
|
|
209
|
+
"reflect": false
|
|
210
|
+
},
|
|
211
|
+
"value": {
|
|
212
|
+
"type": "string",
|
|
213
|
+
"mutable": true,
|
|
214
|
+
"complexType": {
|
|
215
|
+
"original": "string",
|
|
216
|
+
"resolved": "string",
|
|
217
|
+
"references": {}
|
|
218
|
+
},
|
|
219
|
+
"required": false,
|
|
220
|
+
"optional": true,
|
|
221
|
+
"docs": {
|
|
222
|
+
"tags": [],
|
|
223
|
+
"text": ""
|
|
224
|
+
},
|
|
225
|
+
"attribute": "value",
|
|
226
|
+
"reflect": true
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
static get events() {
|
|
231
|
+
return [{
|
|
232
|
+
"method": "inputBlur",
|
|
233
|
+
"name": "inputBlur",
|
|
234
|
+
"bubbles": true,
|
|
235
|
+
"cancelable": true,
|
|
236
|
+
"composed": true,
|
|
237
|
+
"docs": {
|
|
238
|
+
"tags": [],
|
|
239
|
+
"text": ""
|
|
240
|
+
},
|
|
241
|
+
"complexType": {
|
|
242
|
+
"original": "FocusEvent",
|
|
243
|
+
"resolved": "FocusEvent",
|
|
244
|
+
"references": {
|
|
245
|
+
"FocusEvent": {
|
|
246
|
+
"location": "global"
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}, {
|
|
251
|
+
"method": "inputFocus",
|
|
252
|
+
"name": "inputFocus",
|
|
253
|
+
"bubbles": true,
|
|
254
|
+
"cancelable": true,
|
|
255
|
+
"composed": true,
|
|
256
|
+
"docs": {
|
|
257
|
+
"tags": [],
|
|
258
|
+
"text": ""
|
|
259
|
+
},
|
|
260
|
+
"complexType": {
|
|
261
|
+
"original": "FocusEvent",
|
|
262
|
+
"resolved": "FocusEvent",
|
|
263
|
+
"references": {
|
|
264
|
+
"FocusEvent": {
|
|
265
|
+
"location": "global"
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}, {
|
|
270
|
+
"method": "valueChange",
|
|
271
|
+
"name": "valueChange",
|
|
272
|
+
"bubbles": true,
|
|
273
|
+
"cancelable": true,
|
|
274
|
+
"composed": true,
|
|
275
|
+
"docs": {
|
|
276
|
+
"tags": [],
|
|
277
|
+
"text": ""
|
|
278
|
+
},
|
|
279
|
+
"complexType": {
|
|
280
|
+
"original": "string",
|
|
281
|
+
"resolved": "string",
|
|
282
|
+
"references": {}
|
|
283
|
+
}
|
|
284
|
+
}];
|
|
285
|
+
}
|
|
286
|
+
static get watchers() {
|
|
287
|
+
return [{
|
|
288
|
+
"propName": "value",
|
|
289
|
+
"methodName": "watchValue"
|
|
290
|
+
}];
|
|
291
|
+
}
|
|
292
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { newSpecPage } from "@stencil/core/testing";
|
|
2
|
+
import { SwirlColorInput } from "./swirl-color-input";
|
|
3
|
+
describe("swirl-color-input", () => {
|
|
4
|
+
it("renders the input with props", async () => {
|
|
5
|
+
const page = await newSpecPage({
|
|
6
|
+
components: [SwirlColorInput],
|
|
7
|
+
html: `<swirl-color-input
|
|
8
|
+
disabled="true"
|
|
9
|
+
swirl-aria-describedby="id"
|
|
10
|
+
invalid="true"
|
|
11
|
+
required="true"
|
|
12
|
+
value="#ff0000">
|
|
13
|
+
</swirl-color-input>`,
|
|
14
|
+
});
|
|
15
|
+
expect(page.root).toEqualHtml(`
|
|
16
|
+
<swirl-color-input disabled="true"
|
|
17
|
+
swirl-aria-describedby="id"
|
|
18
|
+
invalid="true"
|
|
19
|
+
required="true"
|
|
20
|
+
value="#ff0000">
|
|
21
|
+
<div class="color-input">
|
|
22
|
+
<input aria-describedby="id"
|
|
23
|
+
aria-disabled="true"
|
|
24
|
+
aria-invalid="true"
|
|
25
|
+
class="color-input__input"
|
|
26
|
+
disabled=""
|
|
27
|
+
maxlength="9"
|
|
28
|
+
required=""
|
|
29
|
+
spellcheck="false"
|
|
30
|
+
type="text"
|
|
31
|
+
value="#ff0000">
|
|
32
|
+
<span class="color-input__preview" style="background-color: var(--s-border-subdued);"></span>
|
|
33
|
+
</div>
|
|
34
|
+
</swirl-color-input>
|
|
35
|
+
`);
|
|
36
|
+
});
|
|
37
|
+
it("shows a preview", async () => {
|
|
38
|
+
const page = await newSpecPage({
|
|
39
|
+
components: [SwirlColorInput],
|
|
40
|
+
html: `<swirl-color-input value="Value"></swirl-color-input>`,
|
|
41
|
+
});
|
|
42
|
+
const input = page.root.querySelector(".color-input__input");
|
|
43
|
+
input.value = "#ccddee";
|
|
44
|
+
input.dispatchEvent(new Event("input"));
|
|
45
|
+
await page.waitForChanges();
|
|
46
|
+
expect(page.root.querySelector(".color-input__preview").style
|
|
47
|
+
.backgroundColor).toEqual("#ccddee");
|
|
48
|
+
});
|
|
49
|
+
it("fires valueChange events", async () => {
|
|
50
|
+
const page = await newSpecPage({
|
|
51
|
+
components: [SwirlColorInput],
|
|
52
|
+
html: `<swirl-color-input value="Value"></swirl-color-input>`,
|
|
53
|
+
});
|
|
54
|
+
const spy = jest.fn();
|
|
55
|
+
const input = page.root.querySelector(".color-input__input");
|
|
56
|
+
page.root.addEventListener("valueChange", spy);
|
|
57
|
+
input.value = "New Value";
|
|
58
|
+
input.dispatchEvent(new Event("input"));
|
|
59
|
+
expect(spy).toHaveBeenCalled();
|
|
60
|
+
expect(spy.mock.calls[0][0].detail).toBe("New Value");
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { generateStoryElement } from "../../utils";
|
|
2
|
+
import Docs from "./swirl-color-input.mdx";
|
|
3
|
+
export default {
|
|
4
|
+
component: "swirl-color-input",
|
|
5
|
+
tags: ["autodocs"],
|
|
6
|
+
parameters: {
|
|
7
|
+
docs: {
|
|
8
|
+
page: Docs,
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
title: "Components/SwirlColorInput",
|
|
12
|
+
};
|
|
13
|
+
const Template = (args) => {
|
|
14
|
+
const formControl = document.createElement("swirl-form-control");
|
|
15
|
+
const element = generateStoryElement("swirl-color-input", args);
|
|
16
|
+
formControl.setAttribute("label", "Color input");
|
|
17
|
+
formControl.setAttribute("disabled", args.disabled ? "true" : "false");
|
|
18
|
+
formControl.append("\n ", element, "\n");
|
|
19
|
+
return formControl;
|
|
20
|
+
};
|
|
21
|
+
export const SwirlColorInput = Template.bind({});
|
|
22
|
+
SwirlColorInput.args = {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SwirlAccordionItem extends Components.SwirlAccordionItem, HTMLElement {}
|
|
4
|
+
export const SwirlAccordionItem: {
|
|
5
|
+
prototype: SwirlAccordionItem;
|
|
6
|
+
new (): SwirlAccordionItem;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { c as classnames } from './index2.js';
|
|
3
|
+
import { d as defineCustomElement$3 } from './swirl-icon2.js';
|
|
4
|
+
import { d as defineCustomElement$2 } from './swirl-text2.js';
|
|
5
|
+
import { v as v4 } from './v4.js';
|
|
6
|
+
|
|
7
|
+
const swirlAccordionItemCss = ":host{display:block}:host *{box-sizing:border-box}:host(:last-child) .accordion-item{border-bottom:0.0625rem solid var(--s-border-default)}.accordion-item{display:grid;align-content:start;border-top:0.0625rem solid var(--s-border-default);transition:grid-template-rows 0.15s;grid-template-rows:auto 0fr;will-change:grid-template-rows}@media (prefers-reduced-motion){.accordion-item{transition:none}}.accordion-item--expanded{grid-template-rows:auto 1fr}.accordion-item--expanded .accordion-item__content{padding-top:var(--s-space-16);padding-bottom:var(--s-space-16);animation:accordion-overflow 0.01s;animation-delay:0.15s;animation-fill-mode:forwards}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.accordion-item--expanded .accordion-item__content{padding-top:var(--s-space-8)}}.accordion-item__heading{margin:0;padding:0;font-size:var(--s-font-size-base);font-weight:var(--s-font-weight-semibold)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.accordion-item__heading{font-size:var(--s-font-size-sm)}}.accordion-item__toggle{display:flex;width:100%;padding:0;padding-top:var(--s-space-16);padding-bottom:var(--s-space-16);align-items:center;border:none;color:var(--s-text-default);background-color:var(--s-surface-default);font:inherit;line-height:var(--s-line-height-lg);text-align:start;cursor:pointer;gap:var(--s-space-16)}.accordion-item__toggle:hover{background-color:var(--s-surface-hovered)}.accordion-item__toggle:active{background-color:var(--s-surface-pressed)}.accordion-item__toggle:disabled{color:var(--s-text-disabled);background-color:var(--s-surface-default);cursor:default}.accordion-item__toggle:disabled .text{color:var(--s-text-disabled)}.accordion-item__toggle:focus:not(:focus-visible){outline:none}.accordion-item__toggle:focus-visible{outline-color:var(--s-focus-default)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.accordion-item__toggle{line-height:var(--s-line-height-sm)}}.accordion-item__toggle-text{flex-grow:1}.accordion-item__icon{display:inline-flex;padding-right:var(--s-space-8);flex-shrink:0}.accordion-item__content{overflow:hidden;padding-top:0;padding-bottom:0;transition:padding-top 0.15s, padding-bottom 0.15s;animation:accordion-display 0.01s;animation-delay:0.15s;animation-fill-mode:forwards}@media (prefers-reduced-motion){.accordion-item__content{transition:none}}@keyframes accordion-overflow{from{overflow:hidden}to{overflow:visible}}@keyframes accordion-display{from{display:block}to{display:none}}";
|
|
8
|
+
|
|
9
|
+
const SwirlAccordionItem$1 = /*@__PURE__*/ proxyCustomElement(class SwirlAccordionItem extends HTMLElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.__registerHost();
|
|
13
|
+
this.__attachShadow();
|
|
14
|
+
this.expansionChange = createEvent(this, "expansionChange", 7);
|
|
15
|
+
this.id = `accordion-item-${v4()}`;
|
|
16
|
+
this.headingId = `${this.id}-heading`;
|
|
17
|
+
this.onHeadingClick = () => {
|
|
18
|
+
this.toggle();
|
|
19
|
+
};
|
|
20
|
+
this.description = undefined;
|
|
21
|
+
this.disabled = undefined;
|
|
22
|
+
this.heading = undefined;
|
|
23
|
+
this.headingLevel = 2;
|
|
24
|
+
this.initiallyOpen = undefined;
|
|
25
|
+
this.expanded = false;
|
|
26
|
+
}
|
|
27
|
+
componentWillLoad() {
|
|
28
|
+
this.accordion = this.el.closest("swirl-accordion");
|
|
29
|
+
this.expanded = (this.initiallyOpen && !this.disabled) || false;
|
|
30
|
+
if (!Boolean(this.accordion)) {
|
|
31
|
+
throw new Error("[Swirl] swirl-accordion-item must be a child of a swirl-accordion.");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Collapsed the accordion item.
|
|
36
|
+
*/
|
|
37
|
+
async collapse() {
|
|
38
|
+
if (!this.expanded || this.disabled) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.expanded = false;
|
|
42
|
+
this.expansionChange.emit(this.expanded);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Expands the accordion item.
|
|
46
|
+
*/
|
|
47
|
+
async expand() {
|
|
48
|
+
if (this.expanded || this.disabled) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.expanded = true;
|
|
52
|
+
this.expansionChange.emit(this.expanded);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Toggles the accordion item.
|
|
56
|
+
*/
|
|
57
|
+
async toggle() {
|
|
58
|
+
if (this.expanded) {
|
|
59
|
+
this.collapse();
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.expand();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
render() {
|
|
66
|
+
const HeadingTag = `h${this.headingLevel}`;
|
|
67
|
+
const className = classnames("accordion-item", {
|
|
68
|
+
"accordion-item--expanded": this.expanded,
|
|
69
|
+
});
|
|
70
|
+
return (h(Host, null, h("div", { class: className }, h(HeadingTag, { class: "accordion-item__heading" }, h("button", { "aria-controls": this.id, "aria-expanded": String(this.expanded), class: "accordion-item__toggle", disabled: this.disabled, id: this.headingId, onClick: this.onHeadingClick, type: "button" }, h("span", { class: "accordion-item__toggle-text" }, this.heading, this.description && (h("swirl-text", { as: "span", color: "subdued", size: "sm" }, this.description))), h("span", { class: "accordion-item__icon" }, !this.expanded && (h("swirl-icon", { glyph: "chevron-right", size: 20 })), this.expanded && (h("swirl-icon", { glyph: "expand-more", size: 20 }))))), h("div", { "aria-labelledby": this.headingId, class: "accordion-item__content", id: this.id, role: "region" }, h("slot", null)))));
|
|
71
|
+
}
|
|
72
|
+
get el() { return this; }
|
|
73
|
+
static get style() { return swirlAccordionItemCss; }
|
|
74
|
+
}, [1, "swirl-accordion-item", {
|
|
75
|
+
"description": [1],
|
|
76
|
+
"disabled": [4],
|
|
77
|
+
"heading": [1],
|
|
78
|
+
"headingLevel": [2, "heading-level"],
|
|
79
|
+
"initiallyOpen": [4, "initially-open"],
|
|
80
|
+
"expanded": [32],
|
|
81
|
+
"collapse": [64],
|
|
82
|
+
"expand": [64],
|
|
83
|
+
"toggle": [64]
|
|
84
|
+
}]);
|
|
85
|
+
function defineCustomElement$1() {
|
|
86
|
+
if (typeof customElements === "undefined") {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const components = ["swirl-accordion-item", "swirl-icon", "swirl-text"];
|
|
90
|
+
components.forEach(tagName => { switch (tagName) {
|
|
91
|
+
case "swirl-accordion-item":
|
|
92
|
+
if (!customElements.get(tagName)) {
|
|
93
|
+
customElements.define(tagName, SwirlAccordionItem$1);
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
case "swirl-icon":
|
|
97
|
+
if (!customElements.get(tagName)) {
|
|
98
|
+
defineCustomElement$3();
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
case "swirl-text":
|
|
102
|
+
if (!customElements.get(tagName)) {
|
|
103
|
+
defineCustomElement$2();
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
} });
|
|
107
|
+
}
|
|
108
|
+
defineCustomElement$1();
|
|
109
|
+
|
|
110
|
+
const SwirlAccordionItem = SwirlAccordionItem$1;
|
|
111
|
+
const defineCustomElement = defineCustomElement$1;
|
|
112
|
+
|
|
113
|
+
export { SwirlAccordionItem, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SwirlAccordion extends Components.SwirlAccordion, HTMLElement {}
|
|
4
|
+
export const SwirlAccordion: {
|
|
5
|
+
prototype: SwirlAccordion;
|
|
6
|
+
new (): SwirlAccordion;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
|
|
3
|
+
const swirlAccordionCss = ":host{display:block}:host *{box-sizing:border-box}";
|
|
4
|
+
|
|
5
|
+
const SwirlAccordion$1 = /*@__PURE__*/ proxyCustomElement(class SwirlAccordion extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.__registerHost();
|
|
9
|
+
this.__attachShadow();
|
|
10
|
+
}
|
|
11
|
+
componentDidLoad() {
|
|
12
|
+
this.el.addEventListener("expansionChange", (event) => {
|
|
13
|
+
if (event.detail) {
|
|
14
|
+
this.collapseInactiveItems(event.target);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
collapseInactiveItems(activeItem) {
|
|
19
|
+
Array.from(this.el.querySelectorAll("swirl-accordion-item")).forEach((item) => {
|
|
20
|
+
if (item !== activeItem) {
|
|
21
|
+
item.collapse();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
return (h(Host, null, h("slot", null)));
|
|
27
|
+
}
|
|
28
|
+
get el() { return this; }
|
|
29
|
+
static get style() { return swirlAccordionCss; }
|
|
30
|
+
}, [1, "swirl-accordion"]);
|
|
31
|
+
function defineCustomElement$1() {
|
|
32
|
+
if (typeof customElements === "undefined") {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const components = ["swirl-accordion"];
|
|
36
|
+
components.forEach(tagName => { switch (tagName) {
|
|
37
|
+
case "swirl-accordion":
|
|
38
|
+
if (!customElements.get(tagName)) {
|
|
39
|
+
customElements.define(tagName, SwirlAccordion$1);
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
} });
|
|
43
|
+
}
|
|
44
|
+
defineCustomElement$1();
|
|
45
|
+
|
|
46
|
+
const SwirlAccordion = SwirlAccordion$1;
|
|
47
|
+
const defineCustomElement = defineCustomElement$1;
|
|
48
|
+
|
|
49
|
+
export { SwirlAccordion, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SwirlColorInput extends Components.SwirlColorInput, HTMLElement {}
|
|
4
|
+
export const SwirlColorInput: {
|
|
5
|
+
prototype: SwirlColorInput;
|
|
6
|
+
new (): SwirlColorInput;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|