@govtechsg/sgds-web-component 1.3.0 → 1.3.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/components/Accordion/index.umd.js +41 -16
- package/components/Accordion/index.umd.js.map +1 -1
- package/components/Accordion/sgds-accordion-item.cjs.js +31 -10
- package/components/Accordion/sgds-accordion-item.cjs.js.map +1 -1
- package/components/Accordion/sgds-accordion-item.cjs2.js +1 -1
- package/components/Accordion/sgds-accordion-item.js +31 -10
- package/components/Accordion/sgds-accordion-item.js.map +1 -1
- package/components/Accordion/sgds-accordion-item2.js +1 -1
- package/components/Accordion/sgds-accordion.cjs.js +9 -5
- package/components/Accordion/sgds-accordion.cjs.js.map +1 -1
- package/components/Accordion/sgds-accordion.d.ts +2 -1
- package/components/Accordion/sgds-accordion.js +9 -5
- package/components/Accordion/sgds-accordion.js.map +1 -1
- package/components/index.umd.js +41 -16
- package/components/index.umd.js.map +1 -1
- package/index.umd.js +41 -16
- package/index.umd.js.map +1 -1
- package/package.json +1 -1
package/index.umd.js
CHANGED
|
@@ -3309,6 +3309,7 @@
|
|
|
3309
3309
|
|
|
3310
3310
|
var css_248z$E = css`:host{--accordion-active-color:var(--sgds-primary)}`;
|
|
3311
3311
|
|
|
3312
|
+
const VALID_KEYS = ["Enter", "ArrowUp", "ArrowLeft", "ArrowDown", "ArrowRight"];
|
|
3312
3313
|
/**
|
|
3313
3314
|
* @summary A dropdown mechanism that allow users to either show or hide related content. `SgdsAccordion` is a wrapper to manage the behaviour for multiple `SgdsAccordionItems`
|
|
3314
3315
|
* @slot default - slot for accordion-item
|
|
@@ -3343,10 +3344,8 @@
|
|
|
3343
3344
|
}
|
|
3344
3345
|
});
|
|
3345
3346
|
}
|
|
3346
|
-
async
|
|
3347
|
-
|
|
3348
|
-
// prevented from the outside if a user so desires.
|
|
3349
|
-
if (this.allowMultiple || event.defaultPrevented) {
|
|
3347
|
+
async _onToggle(event) {
|
|
3348
|
+
if (this.allowMultiple) {
|
|
3350
3349
|
// No toggling when `allowMultiple` or the user prevents it.
|
|
3351
3350
|
return;
|
|
3352
3351
|
}
|
|
@@ -3363,6 +3362,11 @@
|
|
|
3363
3362
|
}
|
|
3364
3363
|
});
|
|
3365
3364
|
}
|
|
3365
|
+
async _onKeyboardToggle(event) {
|
|
3366
|
+
if (!VALID_KEYS.includes(event.key))
|
|
3367
|
+
return;
|
|
3368
|
+
return this._onToggle(event);
|
|
3369
|
+
}
|
|
3366
3370
|
render() {
|
|
3367
3371
|
return html$1 `
|
|
3368
3372
|
<div
|
|
@@ -3371,7 +3375,7 @@
|
|
|
3371
3375
|
[`${this.accordionClasses}`]: this.accordionClasses
|
|
3372
3376
|
})}
|
|
3373
3377
|
>
|
|
3374
|
-
<slot @click=${this.
|
|
3378
|
+
<slot @click=${this._onToggle} @keydown=${this._onKeyboardToggle}></slot>
|
|
3375
3379
|
</div>
|
|
3376
3380
|
`;
|
|
3377
3381
|
}
|
|
@@ -3516,7 +3520,7 @@
|
|
|
3516
3520
|
};
|
|
3517
3521
|
}
|
|
3518
3522
|
|
|
3519
|
-
var css_248z$D = css`:host{--accordion-item-padding-y:1rem;--accordion-item-padding-x:1.5rem;--accordion-item-border-radius:0.25rem;--accordion-item-font-weight:700;--accordion-item-line-height:2rem}.accordion-body{line-height:var(--accordion-item-line-height);overflow:hidden;padding:0}.accordion-content{display:block;padding:0 var(--accordion-item-padding-x) var(--accordion-item-padding-y)}.accordion-button{line-height:var(--accordion-item-line-height)}.accordion-button:not(.collapsed){
|
|
3523
|
+
var css_248z$D = css`:host{--accordion-item-padding-y:1rem;--accordion-item-padding-x:1.5rem;--accordion-item-border-radius:0.25rem;--accordion-item-font-weight:700;--accordion-item-line-height:2rem}.accordion-body{line-height:var(--accordion-item-line-height);overflow:hidden;padding:0}.accordion-content{display:block;padding:0 var(--accordion-item-padding-x) var(--accordion-item-padding-y)}.accordion-button{line-height:var(--accordion-item-line-height)}.accordion-button:not(.collapsed){color:var(--accordion-active-color)}.accordion-button svg.bi-chevron-down{height:1.3rem;margin-left:auto;transition:transform .2s ease-in-out;width:1.3rem}.accordion-button:not(.collapsed){box-shadow:none;font-weight:var(--accordion-item-font-weight)}.accordion-button:not(.collapsed) svg.bi-chevron-down{transform:rotate(-180deg)}.accordion-button:after{content:unset}:host([first-of-type]) .accordion-item{border-radius:var(--accordion-item-border-radius) var(--accordion-item-border-radius) 0 0}:host([nth-of-type]) .accordion-item{border-radius:0;border-top:0}:host([last-of-type]) .accordion-item{border-radius:0 0 var(--accordion-item-border-radius) var(--accordion-item-border-radius);border-top:0}.hidden{display:none}`;
|
|
3520
3524
|
|
|
3521
3525
|
/**
|
|
3522
3526
|
*
|
|
@@ -3545,8 +3549,8 @@
|
|
|
3545
3549
|
this.open = false;
|
|
3546
3550
|
}
|
|
3547
3551
|
firstUpdated() {
|
|
3548
|
-
|
|
3549
|
-
|
|
3552
|
+
if (!this.open)
|
|
3553
|
+
this.body.classList.add("hidden");
|
|
3550
3554
|
}
|
|
3551
3555
|
handleSummaryClick() {
|
|
3552
3556
|
if (this.open) {
|
|
@@ -3585,10 +3589,9 @@
|
|
|
3585
3589
|
return;
|
|
3586
3590
|
}
|
|
3587
3591
|
await stopAnimations(this.body);
|
|
3588
|
-
this.body.hidden
|
|
3592
|
+
this.body.classList.remove("hidden");
|
|
3589
3593
|
const { keyframes, options } = getAnimation(this, "accordion.show");
|
|
3590
3594
|
await animateTo(this.body, shimKeyframesHeightAuto(keyframes, this.body.scrollHeight), options);
|
|
3591
|
-
this.body.style.height = "auto";
|
|
3592
3595
|
this.emit("sgds-after-show");
|
|
3593
3596
|
}
|
|
3594
3597
|
else {
|
|
@@ -3600,9 +3603,13 @@
|
|
|
3600
3603
|
}
|
|
3601
3604
|
await stopAnimations(this.body);
|
|
3602
3605
|
const { keyframes, options } = getAnimation(this, "accordion.hide");
|
|
3606
|
+
const animationDuration = options.duration;
|
|
3607
|
+
// Workaround to fix GSIB delay after animateTo.
|
|
3608
|
+
//Setting a timeout of duration slightly less than animation's duraton to prevent case where animation runs faster than .hidden class is added
|
|
3609
|
+
setTimeout(() => {
|
|
3610
|
+
this.body.classList.add("hidden");
|
|
3611
|
+
}, animationDuration - 20);
|
|
3603
3612
|
await animateTo(this.body, shimKeyframesHeightAuto(keyframes, this.body.scrollHeight), options);
|
|
3604
|
-
this.body.hidden = true;
|
|
3605
|
-
this.body.style.height = "auto";
|
|
3606
3613
|
this.emit("sgds-after-hide");
|
|
3607
3614
|
}
|
|
3608
3615
|
}
|
|
@@ -3628,7 +3635,8 @@
|
|
|
3628
3635
|
part="base"
|
|
3629
3636
|
class=${classMap({
|
|
3630
3637
|
"sgds accordion-item": true,
|
|
3631
|
-
[`${this.accordionItemClasses}`]: this.accordionItemClasses
|
|
3638
|
+
[`${this.accordionItemClasses}`]: this.accordionItemClasses,
|
|
3639
|
+
show: this.open
|
|
3632
3640
|
})}
|
|
3633
3641
|
>
|
|
3634
3642
|
<button
|
|
@@ -3645,8 +3653,25 @@
|
|
|
3645
3653
|
@keydown=${this.handleSummaryKeyDown}
|
|
3646
3654
|
>
|
|
3647
3655
|
<slot name="accordion-header"></slot>
|
|
3656
|
+
<svg
|
|
3657
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
3658
|
+
width="16"
|
|
3659
|
+
height="16"
|
|
3660
|
+
fill="currentColor"
|
|
3661
|
+
class="bi bi-chevron-down"
|
|
3662
|
+
viewBox="0 0 16 16"
|
|
3663
|
+
>
|
|
3664
|
+
<path
|
|
3665
|
+
fill-rule="evenodd"
|
|
3666
|
+
d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"
|
|
3667
|
+
/>
|
|
3668
|
+
</svg>
|
|
3648
3669
|
</button>
|
|
3649
|
-
<div
|
|
3670
|
+
<div
|
|
3671
|
+
class=${classMap({
|
|
3672
|
+
"accordion-body": true
|
|
3673
|
+
})}
|
|
3674
|
+
>
|
|
3650
3675
|
<slot name="accordion-content" class="accordion-content" role="region" aria-labelledby="header"></slot>
|
|
3651
3676
|
</div>
|
|
3652
3677
|
</div>
|
|
@@ -3677,14 +3702,14 @@
|
|
|
3677
3702
|
{ height: "0", opacity: "0" },
|
|
3678
3703
|
{ height: "auto", opacity: "1" }
|
|
3679
3704
|
],
|
|
3680
|
-
options: { duration:
|
|
3705
|
+
options: { duration: 350, easing: "ease-in-out" }
|
|
3681
3706
|
});
|
|
3682
3707
|
setDefaultAnimation("accordion.hide", {
|
|
3683
3708
|
keyframes: [
|
|
3684
3709
|
{ height: "auto", opacity: "1" },
|
|
3685
3710
|
{ height: "0", opacity: "0" }
|
|
3686
3711
|
],
|
|
3687
|
-
options: { duration:
|
|
3712
|
+
options: { duration: 350, easing: "ease-in-out" }
|
|
3688
3713
|
});
|
|
3689
3714
|
|
|
3690
3715
|
customElements.define("sgds-accordion", SgdsAccordion);
|