@juspay/svelte-ui-components 2.136.8 → 2.136.9
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.
|
@@ -9,9 +9,18 @@
|
|
|
9
9
|
triggerClasses,
|
|
10
10
|
classes,
|
|
11
11
|
testId,
|
|
12
|
-
disabled = false
|
|
12
|
+
disabled = false,
|
|
13
|
+
panelId
|
|
13
14
|
}: AccordionProperties = $props();
|
|
14
15
|
|
|
16
|
+
/* The trigger and the panel are siblings, not ancestor/descendant, so nothing in the
|
|
17
|
+
markup tells assistive technology which region the trigger's aria-expanded refers to.
|
|
18
|
+
A generated id keeps that link automatic -- consumers pass no id and get correct
|
|
19
|
+
wiring -- while `panelId` lets a caller supply their own when they need to reference
|
|
20
|
+
the panel from elsewhere too. */
|
|
21
|
+
const uid = $props.id();
|
|
22
|
+
const effectivePanelId = $derived(panelId ?? `accordion-panel-${uid}`);
|
|
23
|
+
|
|
15
24
|
function handleTriggerClick(): void {
|
|
16
25
|
if (disabled) {
|
|
17
26
|
return;
|
|
@@ -28,6 +37,7 @@
|
|
|
28
37
|
role="button"
|
|
29
38
|
tabindex={disabled ? -1 : 0}
|
|
30
39
|
aria-expanded={expand}
|
|
40
|
+
aria-controls={effectivePanelId}
|
|
31
41
|
aria-disabled={disabled}
|
|
32
42
|
onclick={handleTriggerClick}
|
|
33
43
|
onkeydown={(event) => {
|
|
@@ -42,6 +52,7 @@
|
|
|
42
52
|
{/if}
|
|
43
53
|
|
|
44
54
|
<div
|
|
55
|
+
id={effectivePanelId}
|
|
45
56
|
class="accordion {classes ?? ''}"
|
|
46
57
|
class:expanded={expand}
|
|
47
58
|
data-pw={typeof testId === 'string' ? testId : null}
|
|
@@ -17,6 +17,13 @@ export type OptionalAccordionProperties = {
|
|
|
17
17
|
* can be shown open or closed under external (controlled) state.
|
|
18
18
|
*/
|
|
19
19
|
disabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* `id` for the collapsible panel, which the built-in trigger references via
|
|
22
|
+
* `aria-controls`. Defaults to a generated, per-instance id, so the trigger and
|
|
23
|
+
* panel are always linked without any caller involvement. Supply one only when
|
|
24
|
+
* something else needs to reference the panel by a known id.
|
|
25
|
+
*/
|
|
26
|
+
panelId?: string;
|
|
20
27
|
};
|
|
21
28
|
export type AccordionEventProperties = {
|
|
22
29
|
ontoggle?: (expanded: boolean) => void;
|
package/dist-wc/index.js
CHANGED
|
@@ -11760,78 +11760,85 @@ var root$49 = /* @__PURE__ */ from_html("<div role=\"button\"><!></div>"), root_
|
|
|
11760
11760
|
code: ".accordion-trigger.svelte-1p9ezsm {cursor:var(--accordion-trigger-cursor, pointer);}.accordion-trigger.disabled.svelte-1p9ezsm {cursor:var(--accordion-trigger-disabled-cursor, not-allowed);}.accordion.svelte-1p9ezsm {display:grid;grid-template-rows:0fr;overflow:hidden;transition:grid-template-rows var(--accordion-transition, 0.2s ease-out);}.accordion.expanded.svelte-1p9ezsm {grid-template-rows:1fr;}.accordion-content.svelte-1p9ezsm {min-height:0;}"
|
|
11761
11761
|
};
|
|
11762
11762
|
function Accordion(e, t) {
|
|
11763
|
+
let n = props_id();
|
|
11763
11764
|
push(t, !0), append_styles$1(e, $$css$47);
|
|
11764
|
-
let
|
|
11765
|
-
function
|
|
11766
|
-
|
|
11765
|
+
let i = prop(t, "expand", 15, !1), a = prop(t, "children", 7), o = prop(t, "trigger", 7), s = prop(t, "ontoggle", 7), c = prop(t, "triggerClasses", 7), l = prop(t, "classes", 7), u = prop(t, "testId", 7), f = prop(t, "disabled", 7, !1), p = prop(t, "panelId", 7), h = /* @__PURE__ */ user_derived(() => p() ?? `accordion-panel-${n}`);
|
|
11766
|
+
function S() {
|
|
11767
|
+
f() || (i(!i()), s()?.(i()));
|
|
11767
11768
|
}
|
|
11768
|
-
var
|
|
11769
|
+
var C = {
|
|
11769
11770
|
get expand() {
|
|
11770
|
-
return
|
|
11771
|
+
return i();
|
|
11771
11772
|
},
|
|
11772
11773
|
set expand(e = !1) {
|
|
11773
|
-
|
|
11774
|
+
i(e), flushSync();
|
|
11774
11775
|
},
|
|
11775
11776
|
get children() {
|
|
11776
|
-
return
|
|
11777
|
+
return a();
|
|
11777
11778
|
},
|
|
11778
11779
|
set children(e) {
|
|
11779
|
-
|
|
11780
|
+
a(e), flushSync();
|
|
11780
11781
|
},
|
|
11781
11782
|
get trigger() {
|
|
11782
|
-
return
|
|
11783
|
+
return o();
|
|
11783
11784
|
},
|
|
11784
11785
|
set trigger(e) {
|
|
11785
|
-
|
|
11786
|
+
o(e), flushSync();
|
|
11786
11787
|
},
|
|
11787
11788
|
get ontoggle() {
|
|
11788
|
-
return
|
|
11789
|
+
return s();
|
|
11789
11790
|
},
|
|
11790
11791
|
set ontoggle(e) {
|
|
11791
|
-
|
|
11792
|
+
s(e), flushSync();
|
|
11792
11793
|
},
|
|
11793
11794
|
get triggerClasses() {
|
|
11794
|
-
return
|
|
11795
|
+
return c();
|
|
11795
11796
|
},
|
|
11796
11797
|
set triggerClasses(e) {
|
|
11797
|
-
|
|
11798
|
+
c(e), flushSync();
|
|
11798
11799
|
},
|
|
11799
11800
|
get classes() {
|
|
11800
|
-
return
|
|
11801
|
+
return l();
|
|
11801
11802
|
},
|
|
11802
11803
|
set classes(e) {
|
|
11803
|
-
|
|
11804
|
+
l(e), flushSync();
|
|
11804
11805
|
},
|
|
11805
11806
|
get testId() {
|
|
11806
|
-
return
|
|
11807
|
+
return u();
|
|
11807
11808
|
},
|
|
11808
11809
|
set testId(e) {
|
|
11809
|
-
|
|
11810
|
+
u(e), flushSync();
|
|
11810
11811
|
},
|
|
11811
11812
|
get disabled() {
|
|
11812
|
-
return
|
|
11813
|
+
return f();
|
|
11813
11814
|
},
|
|
11814
11815
|
set disabled(e = !1) {
|
|
11815
|
-
|
|
11816
|
+
f(e), flushSync();
|
|
11817
|
+
},
|
|
11818
|
+
get panelId() {
|
|
11819
|
+
return p();
|
|
11820
|
+
},
|
|
11821
|
+
set panelId(e) {
|
|
11822
|
+
p(e), flushSync();
|
|
11816
11823
|
}
|
|
11817
|
-
},
|
|
11824
|
+
}, k = root_1$42(), R = first_child(k), G = (e) => {
|
|
11818
11825
|
var t = root$49();
|
|
11819
|
-
let
|
|
11820
|
-
snippet(child(t),
|
|
11821
|
-
|
|
11822
|
-
}), delegated("click", t,
|
|
11823
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
11826
|
+
let n;
|
|
11827
|
+
snippet(child(t), o, () => ({ expanded: i() })), reset(t), template_effect(() => {
|
|
11828
|
+
n = set_class(t, 1, `accordion-trigger ${c() ?? "" ?? ""}`, "svelte-1p9ezsm", n, { disabled: f() }), set_attribute(t, "tabindex", f() ? -1 : 0), set_attribute(t, "aria-expanded", i()), set_attribute(t, "aria-controls", get(h)), set_attribute(t, "aria-disabled", f());
|
|
11829
|
+
}), delegated("click", t, S), delegated("keydown", t, (e) => {
|
|
11830
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), S());
|
|
11824
11831
|
}), append(e, t);
|
|
11825
11832
|
};
|
|
11826
|
-
if_block(
|
|
11827
|
-
|
|
11833
|
+
if_block(R, (e) => {
|
|
11834
|
+
o() && e(G);
|
|
11828
11835
|
});
|
|
11829
|
-
var
|
|
11830
|
-
let
|
|
11831
|
-
var
|
|
11832
|
-
return snippet(child(
|
|
11833
|
-
|
|
11834
|
-
}), append(e,
|
|
11836
|
+
var te = sibling(R, 2);
|
|
11837
|
+
let ne;
|
|
11838
|
+
var re = child(te);
|
|
11839
|
+
return snippet(child(re), () => a() ?? noop), reset(re), reset(te), template_effect(() => {
|
|
11840
|
+
set_attribute(te, "id", get(h)), ne = set_class(te, 1, `accordion ${l() ?? "" ?? ""}`, "svelte-1p9ezsm", ne, { expanded: i() }), set_attribute(te, "data-pw", typeof u() == "string" ? u() : null), set_attribute(te, "testid", typeof u() == "string" ? u() : null);
|
|
11841
|
+
}), append(e, k), pop(C);
|
|
11835
11842
|
}
|
|
11836
11843
|
delegate(["click", "keydown"]), create_custom_element(Accordion, {
|
|
11837
11844
|
expand: {},
|
|
@@ -11841,7 +11848,8 @@ delegate(["click", "keydown"]), create_custom_element(Accordion, {
|
|
|
11841
11848
|
triggerClasses: {},
|
|
11842
11849
|
classes: {},
|
|
11843
11850
|
testId: {},
|
|
11844
|
-
disabled: {}
|
|
11851
|
+
disabled: {},
|
|
11852
|
+
panelId: {}
|
|
11845
11853
|
}, [], [], { mode: "open" });
|
|
11846
11854
|
//#endregion
|
|
11847
11855
|
//#region src/wc/components/Accordion.wc.svelte
|
|
@@ -11874,6 +11882,10 @@ customElements.define("sui-accordion", create_custom_element(Accordion_wc, {
|
|
|
11874
11882
|
testId: {
|
|
11875
11883
|
attribute: "test-id",
|
|
11876
11884
|
type: "String"
|
|
11885
|
+
},
|
|
11886
|
+
panelId: {
|
|
11887
|
+
attribute: "panel-id",
|
|
11888
|
+
type: "String"
|
|
11877
11889
|
}
|
|
11878
11890
|
}, ["default"], [], { mode: "open" }));
|
|
11879
11891
|
//#endregion
|