@abgov/react-components 4.0.0-alpha.143 → 4.0.0-alpha.144
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/lib/popover/popover.d.ts +3 -2
- package/package.json +1 -1
- package/react-components.esm.js +182 -26
- package/react-components.umd.js +185 -28
package/lib/popover/popover.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { FC, ReactNode } from "react";
|
|
2
|
-
|
|
2
|
+
import { Margins } from "../../common/styling";
|
|
3
|
+
interface WCProps extends Margins {
|
|
3
4
|
maxwidth?: string;
|
|
4
5
|
padded?: boolean;
|
|
5
6
|
}
|
|
@@ -10,7 +11,7 @@ declare global {
|
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
interface Props {
|
|
14
|
+
interface Props extends Margins {
|
|
14
15
|
target?: ReactNode;
|
|
15
16
|
testId?: string;
|
|
16
17
|
maxWidth?: string;
|
package/package.json
CHANGED
package/react-components.esm.js
CHANGED
|
@@ -14539,11 +14539,11 @@ function create_if_block$7(ctx) {
|
|
|
14539
14539
|
ctx[1]);
|
|
14540
14540
|
set_style(section, "padding",
|
|
14541
14541
|
/*paddedContent*/
|
|
14542
|
-
ctx[
|
|
14542
|
+
ctx[9] ? 'var(--goa-space-m)' : '0');
|
|
14543
14543
|
attr(div1, "class", "popover-container");
|
|
14544
14544
|
set_custom_element_data(goa_focus_trap, "active",
|
|
14545
14545
|
/*_isContentVisible*/
|
|
14546
|
-
ctx[
|
|
14546
|
+
ctx[6]);
|
|
14547
14547
|
},
|
|
14548
14548
|
|
|
14549
14549
|
m(target, anchor) {
|
|
@@ -14553,11 +14553,14 @@ function create_if_block$7(ctx) {
|
|
|
14553
14553
|
append(goa_focus_trap, div1);
|
|
14554
14554
|
append(div1, section);
|
|
14555
14555
|
append(section, slot);
|
|
14556
|
+
/*section_binding*/
|
|
14557
|
+
|
|
14558
|
+
ctx[14](section);
|
|
14556
14559
|
|
|
14557
14560
|
if (!mounted) {
|
|
14558
14561
|
dispose = listen(div0, "click",
|
|
14559
14562
|
/*closePopover*/
|
|
14560
|
-
ctx[
|
|
14563
|
+
ctx[11]);
|
|
14561
14564
|
mounted = true;
|
|
14562
14565
|
}
|
|
14563
14566
|
},
|
|
@@ -14573,23 +14576,26 @@ function create_if_block$7(ctx) {
|
|
|
14573
14576
|
|
|
14574
14577
|
if (dirty &
|
|
14575
14578
|
/*paddedContent*/
|
|
14576
|
-
|
|
14579
|
+
512) {
|
|
14577
14580
|
set_style(section, "padding",
|
|
14578
14581
|
/*paddedContent*/
|
|
14579
|
-
ctx[
|
|
14582
|
+
ctx[9] ? 'var(--goa-space-m)' : '0');
|
|
14580
14583
|
}
|
|
14581
14584
|
|
|
14582
14585
|
if (dirty &
|
|
14583
14586
|
/*_isContentVisible*/
|
|
14584
|
-
|
|
14587
|
+
64) {
|
|
14585
14588
|
set_custom_element_data(goa_focus_trap, "active",
|
|
14586
14589
|
/*_isContentVisible*/
|
|
14587
|
-
ctx[
|
|
14590
|
+
ctx[6]);
|
|
14588
14591
|
}
|
|
14589
14592
|
},
|
|
14590
14593
|
|
|
14591
14594
|
d(detaching) {
|
|
14592
14595
|
if (detaching) detach(goa_focus_trap);
|
|
14596
|
+
/*section_binding*/
|
|
14597
|
+
|
|
14598
|
+
ctx[14](null);
|
|
14593
14599
|
mounted = false;
|
|
14594
14600
|
dispose();
|
|
14595
14601
|
}
|
|
@@ -14601,11 +14607,12 @@ function create_fragment$h(ctx) {
|
|
|
14601
14607
|
let div1;
|
|
14602
14608
|
let div0;
|
|
14603
14609
|
let t;
|
|
14610
|
+
let div1_style_value;
|
|
14604
14611
|
let mounted;
|
|
14605
14612
|
let dispose;
|
|
14606
14613
|
let if_block =
|
|
14607
14614
|
/*_isContentVisible*/
|
|
14608
|
-
ctx[
|
|
14615
|
+
ctx[6] && create_if_block$7(ctx);
|
|
14609
14616
|
return {
|
|
14610
14617
|
c() {
|
|
14611
14618
|
div1 = element("div");
|
|
@@ -14620,6 +14627,15 @@ function create_fragment$h(ctx) {
|
|
|
14620
14627
|
attr(div1, "data-testid",
|
|
14621
14628
|
/*testid*/
|
|
14622
14629
|
ctx[0]);
|
|
14630
|
+
attr(div1, "style", div1_style_value = calculateMargin(
|
|
14631
|
+
/*mt*/
|
|
14632
|
+
ctx[2],
|
|
14633
|
+
/*mr*/
|
|
14634
|
+
ctx[3],
|
|
14635
|
+
/*mb*/
|
|
14636
|
+
ctx[4],
|
|
14637
|
+
/*ml*/
|
|
14638
|
+
ctx[5]));
|
|
14623
14639
|
},
|
|
14624
14640
|
|
|
14625
14641
|
m(target, anchor) {
|
|
@@ -14627,14 +14643,14 @@ function create_fragment$h(ctx) {
|
|
|
14627
14643
|
append(div1, div0);
|
|
14628
14644
|
/*div0_binding*/
|
|
14629
14645
|
|
|
14630
|
-
ctx[
|
|
14646
|
+
ctx[13](div0);
|
|
14631
14647
|
append(div1, t);
|
|
14632
14648
|
if (if_block) if_block.m(div1, null);
|
|
14633
14649
|
|
|
14634
14650
|
if (!mounted) {
|
|
14635
14651
|
dispose = listen(div0, "click",
|
|
14636
14652
|
/*showPopover*/
|
|
14637
|
-
ctx[
|
|
14653
|
+
ctx[10]);
|
|
14638
14654
|
mounted = true;
|
|
14639
14655
|
}
|
|
14640
14656
|
},
|
|
@@ -14642,7 +14658,7 @@ function create_fragment$h(ctx) {
|
|
|
14642
14658
|
p(ctx, [dirty]) {
|
|
14643
14659
|
if (
|
|
14644
14660
|
/*_isContentVisible*/
|
|
14645
|
-
ctx[
|
|
14661
|
+
ctx[6]) {
|
|
14646
14662
|
if (if_block) {
|
|
14647
14663
|
if_block.p(ctx, dirty);
|
|
14648
14664
|
} else {
|
|
@@ -14662,6 +14678,20 @@ function create_fragment$h(ctx) {
|
|
|
14662
14678
|
/*testid*/
|
|
14663
14679
|
ctx[0]);
|
|
14664
14680
|
}
|
|
14681
|
+
|
|
14682
|
+
if (dirty &
|
|
14683
|
+
/*mt, mr, mb, ml*/
|
|
14684
|
+
60 && div1_style_value !== (div1_style_value = calculateMargin(
|
|
14685
|
+
/*mt*/
|
|
14686
|
+
ctx[2],
|
|
14687
|
+
/*mr*/
|
|
14688
|
+
ctx[3],
|
|
14689
|
+
/*mb*/
|
|
14690
|
+
ctx[4],
|
|
14691
|
+
/*ml*/
|
|
14692
|
+
ctx[5]))) {
|
|
14693
|
+
attr(div1, "style", div1_style_value);
|
|
14694
|
+
}
|
|
14665
14695
|
},
|
|
14666
14696
|
|
|
14667
14697
|
i: noop,
|
|
@@ -14671,7 +14701,7 @@ function create_fragment$h(ctx) {
|
|
|
14671
14701
|
if (detaching) detach(div1);
|
|
14672
14702
|
/*div0_binding*/
|
|
14673
14703
|
|
|
14674
|
-
ctx[
|
|
14704
|
+
ctx[13](null);
|
|
14675
14705
|
if (if_block) if_block.d();
|
|
14676
14706
|
mounted = false;
|
|
14677
14707
|
dispose();
|
|
@@ -14680,6 +14710,25 @@ function create_fragment$h(ctx) {
|
|
|
14680
14710
|
};
|
|
14681
14711
|
}
|
|
14682
14712
|
|
|
14713
|
+
function getBoundingClientRectWithMargins(el) {
|
|
14714
|
+
const rect = el.getBoundingClientRect();
|
|
14715
|
+
const style = window.getComputedStyle(el);
|
|
14716
|
+
const mTop = parseInt(style.marginTop, 10) || 0;
|
|
14717
|
+
const mRight = parseInt(style.marginRight, 10) || 0;
|
|
14718
|
+
const mBottom = parseInt(style.marginBottom, 10) || 0;
|
|
14719
|
+
const mLeft = parseInt(style.marginLeft, 10) || 0;
|
|
14720
|
+
return {
|
|
14721
|
+
top: rect.top - mTop,
|
|
14722
|
+
right: rect.right + mRight,
|
|
14723
|
+
bottom: rect.bottom + mBottom,
|
|
14724
|
+
left: rect.left - mLeft,
|
|
14725
|
+
width: rect.width + mLeft + mRight,
|
|
14726
|
+
height: rect.height + mTop + mBottom,
|
|
14727
|
+
x: rect.x - mLeft,
|
|
14728
|
+
y: rect.y - mTop
|
|
14729
|
+
};
|
|
14730
|
+
}
|
|
14731
|
+
|
|
14683
14732
|
function instance$f($$self, $$props, $$invalidate) {
|
|
14684
14733
|
let paddedContent;
|
|
14685
14734
|
let {
|
|
@@ -14695,6 +14744,20 @@ function instance$f($$self, $$props, $$invalidate) {
|
|
|
14695
14744
|
|
|
14696
14745
|
let _targetEl;
|
|
14697
14746
|
|
|
14747
|
+
let _popoverEl;
|
|
14748
|
+
|
|
14749
|
+
let {
|
|
14750
|
+
mt = null
|
|
14751
|
+
} = $$props;
|
|
14752
|
+
let {
|
|
14753
|
+
mr = null
|
|
14754
|
+
} = $$props;
|
|
14755
|
+
let {
|
|
14756
|
+
mb = null
|
|
14757
|
+
} = $$props;
|
|
14758
|
+
let {
|
|
14759
|
+
ml = null
|
|
14760
|
+
} = $$props;
|
|
14698
14761
|
onMount(async () => {
|
|
14699
14762
|
await tick();
|
|
14700
14763
|
addFocusEventListener();
|
|
@@ -14703,12 +14766,14 @@ function instance$f($$self, $$props, $$invalidate) {
|
|
|
14703
14766
|
removeEventListeners();
|
|
14704
14767
|
});
|
|
14705
14768
|
|
|
14706
|
-
function showPopover() {
|
|
14707
|
-
$$invalidate(
|
|
14769
|
+
async function showPopover() {
|
|
14770
|
+
$$invalidate(6, _isContentVisible = true);
|
|
14771
|
+
await tick();
|
|
14772
|
+
setPopoverPosition();
|
|
14708
14773
|
}
|
|
14709
14774
|
|
|
14710
14775
|
function closePopover() {
|
|
14711
|
-
$$invalidate(
|
|
14776
|
+
$$invalidate(6, _isContentVisible = false);
|
|
14712
14777
|
}
|
|
14713
14778
|
|
|
14714
14779
|
const onInputKeyDown = e => {
|
|
@@ -14726,6 +14791,30 @@ function instance$f($$self, $$props, $$invalidate) {
|
|
|
14726
14791
|
}
|
|
14727
14792
|
};
|
|
14728
14793
|
|
|
14794
|
+
function setPopoverPosition() {
|
|
14795
|
+
// Get target and content rectangles
|
|
14796
|
+
const targetRect = getBoundingClientRectWithMargins(_targetEl);
|
|
14797
|
+
const contentRect = getBoundingClientRectWithMargins(_popoverEl); // Calculate available space above and below the target element
|
|
14798
|
+
|
|
14799
|
+
const spaceAbove = targetRect.top;
|
|
14800
|
+
const spaceBelow = window.innerHeight - targetRect.bottom; // Determine if there's more space above or below the target element
|
|
14801
|
+
|
|
14802
|
+
const displayAbove = spaceAbove > contentRect.height && spaceAbove > spaceBelow && spaceBelow < contentRect.height; // If there's more space above, display the popover above the target element
|
|
14803
|
+
|
|
14804
|
+
if (displayAbove) {
|
|
14805
|
+
$$invalidate(8, _popoverEl.style.top = `${-contentRect.height - targetRect.height - 4}px`, _popoverEl);
|
|
14806
|
+
} else {
|
|
14807
|
+
$$invalidate(8, _popoverEl.style.top = '0px', _popoverEl);
|
|
14808
|
+
} // Move the popover to the left if it is too far to the right and only if there is space to the left
|
|
14809
|
+
|
|
14810
|
+
|
|
14811
|
+
if (window.innerWidth - targetRect.right < contentRect.width && targetRect.left > contentRect.width) {
|
|
14812
|
+
$$invalidate(8, _popoverEl.style.left = `-${contentRect.width - targetRect.width}px`, _popoverEl);
|
|
14813
|
+
} else {
|
|
14814
|
+
$$invalidate(8, _popoverEl.style.left = '0px', _popoverEl);
|
|
14815
|
+
}
|
|
14816
|
+
}
|
|
14817
|
+
|
|
14729
14818
|
function addFocusEventListener() {
|
|
14730
14819
|
_targetEl.addEventListener("focus", onFocus, true);
|
|
14731
14820
|
}
|
|
@@ -14744,31 +14833,42 @@ function instance$f($$self, $$props, $$invalidate) {
|
|
|
14744
14833
|
function div0_binding($$value) {
|
|
14745
14834
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
14746
14835
|
_targetEl = $$value;
|
|
14747
|
-
$$invalidate(
|
|
14836
|
+
$$invalidate(7, _targetEl);
|
|
14837
|
+
});
|
|
14838
|
+
}
|
|
14839
|
+
|
|
14840
|
+
function section_binding($$value) {
|
|
14841
|
+
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
14842
|
+
_popoverEl = $$value;
|
|
14843
|
+
$$invalidate(8, _popoverEl);
|
|
14748
14844
|
});
|
|
14749
14845
|
}
|
|
14750
14846
|
|
|
14751
14847
|
$$self.$$set = $$props => {
|
|
14752
14848
|
if ('testid' in $$props) $$invalidate(0, testid = $$props.testid);
|
|
14753
14849
|
if ('maxwidth' in $$props) $$invalidate(1, maxwidth = $$props.maxwidth);
|
|
14754
|
-
if ('padded' in $$props) $$invalidate(
|
|
14850
|
+
if ('padded' in $$props) $$invalidate(12, padded = $$props.padded);
|
|
14851
|
+
if ('mt' in $$props) $$invalidate(2, mt = $$props.mt);
|
|
14852
|
+
if ('mr' in $$props) $$invalidate(3, mr = $$props.mr);
|
|
14853
|
+
if ('mb' in $$props) $$invalidate(4, mb = $$props.mb);
|
|
14854
|
+
if ('ml' in $$props) $$invalidate(5, ml = $$props.ml);
|
|
14755
14855
|
};
|
|
14756
14856
|
|
|
14757
14857
|
$$self.$$.update = () => {
|
|
14758
14858
|
if ($$self.$$.dirty &
|
|
14759
14859
|
/*padded*/
|
|
14760
|
-
|
|
14761
|
-
$$invalidate(
|
|
14860
|
+
4096) {
|
|
14861
|
+
$$invalidate(9, paddedContent = toBoolean(padded));
|
|
14762
14862
|
}
|
|
14763
14863
|
};
|
|
14764
14864
|
|
|
14765
|
-
return [testid, maxwidth, _isContentVisible, _targetEl, paddedContent, showPopover, closePopover, padded, div0_binding];
|
|
14865
|
+
return [testid, maxwidth, mt, mr, mb, ml, _isContentVisible, _targetEl, _popoverEl, paddedContent, showPopover, closePopover, padded, div0_binding, section_binding];
|
|
14766
14866
|
}
|
|
14767
14867
|
|
|
14768
14868
|
class Popover extends SvelteElement {
|
|
14769
14869
|
constructor(options) {
|
|
14770
14870
|
super();
|
|
14771
|
-
this.shadowRoot.innerHTML = `<style>:host{box-sizing:border-box;font-family:var(--goa-font-family-sans);font-size:var(--goa-font-size-4)}.popover-target{width:fit-content;cursor:pointer}.popover-target:focus{outline:var(--goa-border-width-l) solid var(--goa-color-interactive-focus)}.popover-content{position:absolute;left:0;right:0;margin-top:3px;list-style-type:none;background:var(--goa-color-greyscale-white);
|
|
14871
|
+
this.shadowRoot.innerHTML = `<style>:host{box-sizing:border-box;font-family:var(--goa-font-family-sans);font-size:var(--goa-font-size-4)}.popover-target{width:fit-content;cursor:pointer}.popover-target:focus{outline:var(--goa-border-width-l) solid var(--goa-color-interactive-focus)}.popover-content{position:absolute;left:0;right:0;margin-top:3px;list-style-type:none;background:var(--goa-color-greyscale-white);outline:none;filter:drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.2));z-index:99;width:max-content}.popover-background{cursor:default;position:fixed;z-index:98;inset:0}.popover-container{position:relative}</style>`;
|
|
14772
14872
|
init(this, {
|
|
14773
14873
|
target: this.shadowRoot,
|
|
14774
14874
|
props: attribute_to_object(this.attributes),
|
|
@@ -14776,7 +14876,11 @@ class Popover extends SvelteElement {
|
|
|
14776
14876
|
}, instance$f, create_fragment$h, safe_not_equal, {
|
|
14777
14877
|
testid: 0,
|
|
14778
14878
|
maxwidth: 1,
|
|
14779
|
-
padded:
|
|
14879
|
+
padded: 12,
|
|
14880
|
+
mt: 2,
|
|
14881
|
+
mr: 3,
|
|
14882
|
+
mb: 4,
|
|
14883
|
+
ml: 5
|
|
14780
14884
|
}, null);
|
|
14781
14885
|
|
|
14782
14886
|
if (options) {
|
|
@@ -14792,7 +14896,7 @@ class Popover extends SvelteElement {
|
|
|
14792
14896
|
}
|
|
14793
14897
|
|
|
14794
14898
|
static get observedAttributes() {
|
|
14795
|
-
return ["testid", "maxwidth", "padded"];
|
|
14899
|
+
return ["testid", "maxwidth", "padded", "mt", "mr", "mb", "ml"];
|
|
14796
14900
|
}
|
|
14797
14901
|
|
|
14798
14902
|
get testid() {
|
|
@@ -14818,7 +14922,7 @@ class Popover extends SvelteElement {
|
|
|
14818
14922
|
}
|
|
14819
14923
|
|
|
14820
14924
|
get padded() {
|
|
14821
|
-
return this.$$.ctx[
|
|
14925
|
+
return this.$$.ctx[12];
|
|
14822
14926
|
}
|
|
14823
14927
|
|
|
14824
14928
|
set padded(padded) {
|
|
@@ -14828,6 +14932,50 @@ class Popover extends SvelteElement {
|
|
|
14828
14932
|
flush();
|
|
14829
14933
|
}
|
|
14830
14934
|
|
|
14935
|
+
get mt() {
|
|
14936
|
+
return this.$$.ctx[2];
|
|
14937
|
+
}
|
|
14938
|
+
|
|
14939
|
+
set mt(mt) {
|
|
14940
|
+
this.$$set({
|
|
14941
|
+
mt
|
|
14942
|
+
});
|
|
14943
|
+
flush();
|
|
14944
|
+
}
|
|
14945
|
+
|
|
14946
|
+
get mr() {
|
|
14947
|
+
return this.$$.ctx[3];
|
|
14948
|
+
}
|
|
14949
|
+
|
|
14950
|
+
set mr(mr) {
|
|
14951
|
+
this.$$set({
|
|
14952
|
+
mr
|
|
14953
|
+
});
|
|
14954
|
+
flush();
|
|
14955
|
+
}
|
|
14956
|
+
|
|
14957
|
+
get mb() {
|
|
14958
|
+
return this.$$.ctx[4];
|
|
14959
|
+
}
|
|
14960
|
+
|
|
14961
|
+
set mb(mb) {
|
|
14962
|
+
this.$$set({
|
|
14963
|
+
mb
|
|
14964
|
+
});
|
|
14965
|
+
flush();
|
|
14966
|
+
}
|
|
14967
|
+
|
|
14968
|
+
get ml() {
|
|
14969
|
+
return this.$$.ctx[5];
|
|
14970
|
+
}
|
|
14971
|
+
|
|
14972
|
+
set ml(ml) {
|
|
14973
|
+
this.$$set({
|
|
14974
|
+
ml
|
|
14975
|
+
});
|
|
14976
|
+
flush();
|
|
14977
|
+
}
|
|
14978
|
+
|
|
14831
14979
|
}
|
|
14832
14980
|
|
|
14833
14981
|
customElements.define("goa-popover", Popover);
|
|
@@ -22852,12 +23000,20 @@ const GoAPopover = ({
|
|
|
22852
23000
|
testId,
|
|
22853
23001
|
maxWidth,
|
|
22854
23002
|
padded,
|
|
22855
|
-
children
|
|
23003
|
+
children,
|
|
23004
|
+
mt,
|
|
23005
|
+
mr,
|
|
23006
|
+
mb,
|
|
23007
|
+
ml
|
|
22856
23008
|
}) => {
|
|
22857
23009
|
return jsxs("goa-popover", Object.assign({
|
|
22858
23010
|
"data-testid": testId,
|
|
22859
23011
|
maxwidth: maxWidth,
|
|
22860
|
-
padded: padded
|
|
23012
|
+
padded: padded,
|
|
23013
|
+
mt: mt,
|
|
23014
|
+
mr: mr,
|
|
23015
|
+
mb: mb,
|
|
23016
|
+
ml: ml
|
|
22861
23017
|
}, {
|
|
22862
23018
|
children: [children, target && jsx("div", Object.assign({
|
|
22863
23019
|
slot: "target"
|
package/react-components.umd.js
CHANGED
|
@@ -14587,11 +14587,11 @@
|
|
|
14587
14587
|
ctx[1]);
|
|
14588
14588
|
set_style(section, "padding",
|
|
14589
14589
|
/*paddedContent*/
|
|
14590
|
-
ctx[
|
|
14590
|
+
ctx[9] ? 'var(--goa-space-m)' : '0');
|
|
14591
14591
|
attr(div1, "class", "popover-container");
|
|
14592
14592
|
set_custom_element_data(goa_focus_trap, "active",
|
|
14593
14593
|
/*_isContentVisible*/
|
|
14594
|
-
ctx[
|
|
14594
|
+
ctx[6]);
|
|
14595
14595
|
},
|
|
14596
14596
|
|
|
14597
14597
|
m(target, anchor) {
|
|
@@ -14601,11 +14601,14 @@
|
|
|
14601
14601
|
append(goa_focus_trap, div1);
|
|
14602
14602
|
append(div1, section);
|
|
14603
14603
|
append(section, slot);
|
|
14604
|
+
/*section_binding*/
|
|
14605
|
+
|
|
14606
|
+
ctx[14](section);
|
|
14604
14607
|
|
|
14605
14608
|
if (!mounted) {
|
|
14606
14609
|
dispose = listen(div0, "click",
|
|
14607
14610
|
/*closePopover*/
|
|
14608
|
-
ctx[
|
|
14611
|
+
ctx[11]);
|
|
14609
14612
|
mounted = true;
|
|
14610
14613
|
}
|
|
14611
14614
|
},
|
|
@@ -14621,23 +14624,26 @@
|
|
|
14621
14624
|
|
|
14622
14625
|
if (dirty &
|
|
14623
14626
|
/*paddedContent*/
|
|
14624
|
-
|
|
14627
|
+
512) {
|
|
14625
14628
|
set_style(section, "padding",
|
|
14626
14629
|
/*paddedContent*/
|
|
14627
|
-
ctx[
|
|
14630
|
+
ctx[9] ? 'var(--goa-space-m)' : '0');
|
|
14628
14631
|
}
|
|
14629
14632
|
|
|
14630
14633
|
if (dirty &
|
|
14631
14634
|
/*_isContentVisible*/
|
|
14632
|
-
|
|
14635
|
+
64) {
|
|
14633
14636
|
set_custom_element_data(goa_focus_trap, "active",
|
|
14634
14637
|
/*_isContentVisible*/
|
|
14635
|
-
ctx[
|
|
14638
|
+
ctx[6]);
|
|
14636
14639
|
}
|
|
14637
14640
|
},
|
|
14638
14641
|
|
|
14639
14642
|
d(detaching) {
|
|
14640
14643
|
if (detaching) detach(goa_focus_trap);
|
|
14644
|
+
/*section_binding*/
|
|
14645
|
+
|
|
14646
|
+
ctx[14](null);
|
|
14641
14647
|
mounted = false;
|
|
14642
14648
|
dispose();
|
|
14643
14649
|
}
|
|
@@ -14649,11 +14655,12 @@
|
|
|
14649
14655
|
let div1;
|
|
14650
14656
|
let div0;
|
|
14651
14657
|
let t;
|
|
14658
|
+
let div1_style_value;
|
|
14652
14659
|
let mounted;
|
|
14653
14660
|
let dispose;
|
|
14654
14661
|
let if_block =
|
|
14655
14662
|
/*_isContentVisible*/
|
|
14656
|
-
ctx[
|
|
14663
|
+
ctx[6] && create_if_block$7(ctx);
|
|
14657
14664
|
return {
|
|
14658
14665
|
c() {
|
|
14659
14666
|
div1 = element("div");
|
|
@@ -14668,6 +14675,15 @@
|
|
|
14668
14675
|
attr(div1, "data-testid",
|
|
14669
14676
|
/*testid*/
|
|
14670
14677
|
ctx[0]);
|
|
14678
|
+
attr(div1, "style", div1_style_value = calculateMargin(
|
|
14679
|
+
/*mt*/
|
|
14680
|
+
ctx[2],
|
|
14681
|
+
/*mr*/
|
|
14682
|
+
ctx[3],
|
|
14683
|
+
/*mb*/
|
|
14684
|
+
ctx[4],
|
|
14685
|
+
/*ml*/
|
|
14686
|
+
ctx[5]));
|
|
14671
14687
|
},
|
|
14672
14688
|
|
|
14673
14689
|
m(target, anchor) {
|
|
@@ -14675,14 +14691,14 @@
|
|
|
14675
14691
|
append(div1, div0);
|
|
14676
14692
|
/*div0_binding*/
|
|
14677
14693
|
|
|
14678
|
-
ctx[
|
|
14694
|
+
ctx[13](div0);
|
|
14679
14695
|
append(div1, t);
|
|
14680
14696
|
if (if_block) if_block.m(div1, null);
|
|
14681
14697
|
|
|
14682
14698
|
if (!mounted) {
|
|
14683
14699
|
dispose = listen(div0, "click",
|
|
14684
14700
|
/*showPopover*/
|
|
14685
|
-
ctx[
|
|
14701
|
+
ctx[10]);
|
|
14686
14702
|
mounted = true;
|
|
14687
14703
|
}
|
|
14688
14704
|
},
|
|
@@ -14690,7 +14706,7 @@
|
|
|
14690
14706
|
p(ctx, [dirty]) {
|
|
14691
14707
|
if (
|
|
14692
14708
|
/*_isContentVisible*/
|
|
14693
|
-
ctx[
|
|
14709
|
+
ctx[6]) {
|
|
14694
14710
|
if (if_block) {
|
|
14695
14711
|
if_block.p(ctx, dirty);
|
|
14696
14712
|
} else {
|
|
@@ -14710,6 +14726,20 @@
|
|
|
14710
14726
|
/*testid*/
|
|
14711
14727
|
ctx[0]);
|
|
14712
14728
|
}
|
|
14729
|
+
|
|
14730
|
+
if (dirty &
|
|
14731
|
+
/*mt, mr, mb, ml*/
|
|
14732
|
+
60 && div1_style_value !== (div1_style_value = calculateMargin(
|
|
14733
|
+
/*mt*/
|
|
14734
|
+
ctx[2],
|
|
14735
|
+
/*mr*/
|
|
14736
|
+
ctx[3],
|
|
14737
|
+
/*mb*/
|
|
14738
|
+
ctx[4],
|
|
14739
|
+
/*ml*/
|
|
14740
|
+
ctx[5]))) {
|
|
14741
|
+
attr(div1, "style", div1_style_value);
|
|
14742
|
+
}
|
|
14713
14743
|
},
|
|
14714
14744
|
|
|
14715
14745
|
i: noop,
|
|
@@ -14719,7 +14749,7 @@
|
|
|
14719
14749
|
if (detaching) detach(div1);
|
|
14720
14750
|
/*div0_binding*/
|
|
14721
14751
|
|
|
14722
|
-
ctx[
|
|
14752
|
+
ctx[13](null);
|
|
14723
14753
|
if (if_block) if_block.d();
|
|
14724
14754
|
mounted = false;
|
|
14725
14755
|
dispose();
|
|
@@ -14728,7 +14758,33 @@
|
|
|
14728
14758
|
};
|
|
14729
14759
|
}
|
|
14730
14760
|
|
|
14761
|
+
function getBoundingClientRectWithMargins(el) {
|
|
14762
|
+
const rect = el.getBoundingClientRect();
|
|
14763
|
+
const style = window.getComputedStyle(el);
|
|
14764
|
+
const mTop = parseInt(style.marginTop, 10) || 0;
|
|
14765
|
+
const mRight = parseInt(style.marginRight, 10) || 0;
|
|
14766
|
+
const mBottom = parseInt(style.marginBottom, 10) || 0;
|
|
14767
|
+
const mLeft = parseInt(style.marginLeft, 10) || 0;
|
|
14768
|
+
return {
|
|
14769
|
+
top: rect.top - mTop,
|
|
14770
|
+
right: rect.right + mRight,
|
|
14771
|
+
bottom: rect.bottom + mBottom,
|
|
14772
|
+
left: rect.left - mLeft,
|
|
14773
|
+
width: rect.width + mLeft + mRight,
|
|
14774
|
+
height: rect.height + mTop + mBottom,
|
|
14775
|
+
x: rect.x - mLeft,
|
|
14776
|
+
y: rect.y - mTop
|
|
14777
|
+
};
|
|
14778
|
+
}
|
|
14779
|
+
|
|
14731
14780
|
function instance$f($$self, $$props, $$invalidate) {
|
|
14781
|
+
const showPopover = _async(function () {
|
|
14782
|
+
$$invalidate(6, _isContentVisible = true);
|
|
14783
|
+
return _call(tick, function () {
|
|
14784
|
+
setPopoverPosition();
|
|
14785
|
+
});
|
|
14786
|
+
});
|
|
14787
|
+
|
|
14732
14788
|
let paddedContent;
|
|
14733
14789
|
let {
|
|
14734
14790
|
testid = ""
|
|
@@ -14743,6 +14799,20 @@
|
|
|
14743
14799
|
|
|
14744
14800
|
let _targetEl;
|
|
14745
14801
|
|
|
14802
|
+
let _popoverEl;
|
|
14803
|
+
|
|
14804
|
+
let {
|
|
14805
|
+
mt = null
|
|
14806
|
+
} = $$props;
|
|
14807
|
+
let {
|
|
14808
|
+
mr = null
|
|
14809
|
+
} = $$props;
|
|
14810
|
+
let {
|
|
14811
|
+
mb = null
|
|
14812
|
+
} = $$props;
|
|
14813
|
+
let {
|
|
14814
|
+
ml = null
|
|
14815
|
+
} = $$props;
|
|
14746
14816
|
onMount(function () {
|
|
14747
14817
|
return _call(tick, function () {
|
|
14748
14818
|
addFocusEventListener();
|
|
@@ -14752,12 +14822,8 @@
|
|
|
14752
14822
|
removeEventListeners();
|
|
14753
14823
|
});
|
|
14754
14824
|
|
|
14755
|
-
function showPopover() {
|
|
14756
|
-
$$invalidate(2, _isContentVisible = true);
|
|
14757
|
-
}
|
|
14758
|
-
|
|
14759
14825
|
function closePopover() {
|
|
14760
|
-
$$invalidate(
|
|
14826
|
+
$$invalidate(6, _isContentVisible = false);
|
|
14761
14827
|
}
|
|
14762
14828
|
|
|
14763
14829
|
const onInputKeyDown = e => {
|
|
@@ -14775,6 +14841,30 @@
|
|
|
14775
14841
|
}
|
|
14776
14842
|
};
|
|
14777
14843
|
|
|
14844
|
+
function setPopoverPosition() {
|
|
14845
|
+
// Get target and content rectangles
|
|
14846
|
+
const targetRect = getBoundingClientRectWithMargins(_targetEl);
|
|
14847
|
+
const contentRect = getBoundingClientRectWithMargins(_popoverEl); // Calculate available space above and below the target element
|
|
14848
|
+
|
|
14849
|
+
const spaceAbove = targetRect.top;
|
|
14850
|
+
const spaceBelow = window.innerHeight - targetRect.bottom; // Determine if there's more space above or below the target element
|
|
14851
|
+
|
|
14852
|
+
const displayAbove = spaceAbove > contentRect.height && spaceAbove > spaceBelow && spaceBelow < contentRect.height; // If there's more space above, display the popover above the target element
|
|
14853
|
+
|
|
14854
|
+
if (displayAbove) {
|
|
14855
|
+
$$invalidate(8, _popoverEl.style.top = `${-contentRect.height - targetRect.height - 4}px`, _popoverEl);
|
|
14856
|
+
} else {
|
|
14857
|
+
$$invalidate(8, _popoverEl.style.top = '0px', _popoverEl);
|
|
14858
|
+
} // Move the popover to the left if it is too far to the right and only if there is space to the left
|
|
14859
|
+
|
|
14860
|
+
|
|
14861
|
+
if (window.innerWidth - targetRect.right < contentRect.width && targetRect.left > contentRect.width) {
|
|
14862
|
+
$$invalidate(8, _popoverEl.style.left = `-${contentRect.width - targetRect.width}px`, _popoverEl);
|
|
14863
|
+
} else {
|
|
14864
|
+
$$invalidate(8, _popoverEl.style.left = '0px', _popoverEl);
|
|
14865
|
+
}
|
|
14866
|
+
}
|
|
14867
|
+
|
|
14778
14868
|
function addFocusEventListener() {
|
|
14779
14869
|
_targetEl.addEventListener("focus", onFocus, true);
|
|
14780
14870
|
}
|
|
@@ -14793,31 +14883,42 @@
|
|
|
14793
14883
|
function div0_binding($$value) {
|
|
14794
14884
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
14795
14885
|
_targetEl = $$value;
|
|
14796
|
-
$$invalidate(
|
|
14886
|
+
$$invalidate(7, _targetEl);
|
|
14887
|
+
});
|
|
14888
|
+
}
|
|
14889
|
+
|
|
14890
|
+
function section_binding($$value) {
|
|
14891
|
+
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
14892
|
+
_popoverEl = $$value;
|
|
14893
|
+
$$invalidate(8, _popoverEl);
|
|
14797
14894
|
});
|
|
14798
14895
|
}
|
|
14799
14896
|
|
|
14800
14897
|
$$self.$$set = $$props => {
|
|
14801
14898
|
if ('testid' in $$props) $$invalidate(0, testid = $$props.testid);
|
|
14802
14899
|
if ('maxwidth' in $$props) $$invalidate(1, maxwidth = $$props.maxwidth);
|
|
14803
|
-
if ('padded' in $$props) $$invalidate(
|
|
14900
|
+
if ('padded' in $$props) $$invalidate(12, padded = $$props.padded);
|
|
14901
|
+
if ('mt' in $$props) $$invalidate(2, mt = $$props.mt);
|
|
14902
|
+
if ('mr' in $$props) $$invalidate(3, mr = $$props.mr);
|
|
14903
|
+
if ('mb' in $$props) $$invalidate(4, mb = $$props.mb);
|
|
14904
|
+
if ('ml' in $$props) $$invalidate(5, ml = $$props.ml);
|
|
14804
14905
|
};
|
|
14805
14906
|
|
|
14806
14907
|
$$self.$$.update = () => {
|
|
14807
14908
|
if ($$self.$$.dirty &
|
|
14808
14909
|
/*padded*/
|
|
14809
|
-
|
|
14810
|
-
$$invalidate(
|
|
14910
|
+
4096) {
|
|
14911
|
+
$$invalidate(9, paddedContent = toBoolean(padded));
|
|
14811
14912
|
}
|
|
14812
14913
|
};
|
|
14813
14914
|
|
|
14814
|
-
return [testid, maxwidth, _isContentVisible, _targetEl, paddedContent, showPopover, closePopover, padded, div0_binding];
|
|
14915
|
+
return [testid, maxwidth, mt, mr, mb, ml, _isContentVisible, _targetEl, _popoverEl, paddedContent, showPopover, closePopover, padded, div0_binding, section_binding];
|
|
14815
14916
|
}
|
|
14816
14917
|
|
|
14817
14918
|
class Popover extends SvelteElement {
|
|
14818
14919
|
constructor(options) {
|
|
14819
14920
|
super();
|
|
14820
|
-
this.shadowRoot.innerHTML = `<style>:host{box-sizing:border-box;font-family:var(--goa-font-family-sans);font-size:var(--goa-font-size-4)}.popover-target{width:fit-content;cursor:pointer}.popover-target:focus{outline:var(--goa-border-width-l) solid var(--goa-color-interactive-focus)}.popover-content{position:absolute;left:0;right:0;margin-top:3px;list-style-type:none;background:var(--goa-color-greyscale-white);
|
|
14921
|
+
this.shadowRoot.innerHTML = `<style>:host{box-sizing:border-box;font-family:var(--goa-font-family-sans);font-size:var(--goa-font-size-4)}.popover-target{width:fit-content;cursor:pointer}.popover-target:focus{outline:var(--goa-border-width-l) solid var(--goa-color-interactive-focus)}.popover-content{position:absolute;left:0;right:0;margin-top:3px;list-style-type:none;background:var(--goa-color-greyscale-white);outline:none;filter:drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.2));z-index:99;width:max-content}.popover-background{cursor:default;position:fixed;z-index:98;inset:0}.popover-container{position:relative}</style>`;
|
|
14821
14922
|
init(this, {
|
|
14822
14923
|
target: this.shadowRoot,
|
|
14823
14924
|
props: attribute_to_object(this.attributes),
|
|
@@ -14825,7 +14926,11 @@
|
|
|
14825
14926
|
}, instance$f, create_fragment$h, safe_not_equal, {
|
|
14826
14927
|
testid: 0,
|
|
14827
14928
|
maxwidth: 1,
|
|
14828
|
-
padded:
|
|
14929
|
+
padded: 12,
|
|
14930
|
+
mt: 2,
|
|
14931
|
+
mr: 3,
|
|
14932
|
+
mb: 4,
|
|
14933
|
+
ml: 5
|
|
14829
14934
|
}, null);
|
|
14830
14935
|
|
|
14831
14936
|
if (options) {
|
|
@@ -14841,7 +14946,7 @@
|
|
|
14841
14946
|
}
|
|
14842
14947
|
|
|
14843
14948
|
static get observedAttributes() {
|
|
14844
|
-
return ["testid", "maxwidth", "padded"];
|
|
14949
|
+
return ["testid", "maxwidth", "padded", "mt", "mr", "mb", "ml"];
|
|
14845
14950
|
}
|
|
14846
14951
|
|
|
14847
14952
|
get testid() {
|
|
@@ -14867,7 +14972,7 @@
|
|
|
14867
14972
|
}
|
|
14868
14973
|
|
|
14869
14974
|
get padded() {
|
|
14870
|
-
return this.$$.ctx[
|
|
14975
|
+
return this.$$.ctx[12];
|
|
14871
14976
|
}
|
|
14872
14977
|
|
|
14873
14978
|
set padded(padded) {
|
|
@@ -14877,6 +14982,50 @@
|
|
|
14877
14982
|
flush();
|
|
14878
14983
|
}
|
|
14879
14984
|
|
|
14985
|
+
get mt() {
|
|
14986
|
+
return this.$$.ctx[2];
|
|
14987
|
+
}
|
|
14988
|
+
|
|
14989
|
+
set mt(mt) {
|
|
14990
|
+
this.$$set({
|
|
14991
|
+
mt
|
|
14992
|
+
});
|
|
14993
|
+
flush();
|
|
14994
|
+
}
|
|
14995
|
+
|
|
14996
|
+
get mr() {
|
|
14997
|
+
return this.$$.ctx[3];
|
|
14998
|
+
}
|
|
14999
|
+
|
|
15000
|
+
set mr(mr) {
|
|
15001
|
+
this.$$set({
|
|
15002
|
+
mr
|
|
15003
|
+
});
|
|
15004
|
+
flush();
|
|
15005
|
+
}
|
|
15006
|
+
|
|
15007
|
+
get mb() {
|
|
15008
|
+
return this.$$.ctx[4];
|
|
15009
|
+
}
|
|
15010
|
+
|
|
15011
|
+
set mb(mb) {
|
|
15012
|
+
this.$$set({
|
|
15013
|
+
mb
|
|
15014
|
+
});
|
|
15015
|
+
flush();
|
|
15016
|
+
}
|
|
15017
|
+
|
|
15018
|
+
get ml() {
|
|
15019
|
+
return this.$$.ctx[5];
|
|
15020
|
+
}
|
|
15021
|
+
|
|
15022
|
+
set ml(ml) {
|
|
15023
|
+
this.$$set({
|
|
15024
|
+
ml
|
|
15025
|
+
});
|
|
15026
|
+
flush();
|
|
15027
|
+
}
|
|
15028
|
+
|
|
14880
15029
|
}
|
|
14881
15030
|
|
|
14882
15031
|
customElements.define("goa-popover", Popover);
|
|
@@ -22896,11 +23045,19 @@
|
|
|
22896
23045
|
testId = _a.testId,
|
|
22897
23046
|
maxWidth = _a.maxWidth,
|
|
22898
23047
|
padded = _a.padded,
|
|
22899
|
-
children = _a.children
|
|
23048
|
+
children = _a.children,
|
|
23049
|
+
mt = _a.mt,
|
|
23050
|
+
mr = _a.mr,
|
|
23051
|
+
mb = _a.mb,
|
|
23052
|
+
ml = _a.ml;
|
|
22900
23053
|
return jsxRuntime.jsxs("goa-popover", __assign({
|
|
22901
23054
|
"data-testid": testId,
|
|
22902
23055
|
maxwidth: maxWidth,
|
|
22903
|
-
padded: padded
|
|
23056
|
+
padded: padded,
|
|
23057
|
+
mt: mt,
|
|
23058
|
+
mr: mr,
|
|
23059
|
+
mb: mb,
|
|
23060
|
+
ml: ml
|
|
22904
23061
|
}, {
|
|
22905
23062
|
children: [children, target && jsxRuntime.jsx("div", __assign({
|
|
22906
23063
|
slot: "target"
|