@gov-design-system-ce/components 4.6.3 → 4.6.4
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/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -1
- package/dist/cjs/core.cjs.js +1 -1
- package/dist/cjs/gov-banner.cjs.entry.js +3 -3
- package/dist/cjs/gov-banner.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-banner.entry.cjs.js.map +1 -1
- package/dist/cjs/gov-flex_3.cjs.entry.js +1 -1
- package/dist/cjs/gov-form-autocomplete.cjs.entry.js +67 -23
- package/dist/cjs/gov-form-autocomplete.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-autocomplete.entry.cjs.js.map +1 -1
- package/dist/cjs/gov-form-file.cjs.entry.js +32 -3
- package/dist/cjs/gov-form-file.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-file.entry.cjs.js.map +1 -1
- package/dist/cjs/gov-form-search.cjs.entry.js +1 -1
- package/dist/cjs/gov-form-search.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-search.entry.cjs.js.map +1 -1
- package/dist/cjs/gov-form-select.cjs.entry.js +8 -15
- package/dist/cjs/gov-form-select.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-select.entry.cjs.js.map +1 -1
- package/dist/cjs/gov-tooltip.gov-tooltip-content.entry.cjs.js.map +1 -1
- package/dist/cjs/gov-tooltip_2.cjs.entry.js +34 -9
- package/dist/cjs/gov-tooltip_2.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-wizard-item.cjs.entry.js +2 -2
- package/dist/cjs/gov-wizard.cjs.entry.js +1 -1
- package/dist/cjs/index-BEF5cZxd.js +4 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/gov-banner/gov-banner.js +4 -4
- package/dist/collection/components/gov-banner/gov-banner.js.map +1 -1
- package/dist/collection/components/gov-form/autocomplete/autocomplete.utils.js +14 -0
- package/dist/collection/components/gov-form/autocomplete/autocomplete.utils.js.map +1 -0
- package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.js +76 -22
- package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.js.map +1 -1
- package/dist/collection/components/gov-form/file/gov-form-file.js +34 -3
- package/dist/collection/components/gov-form/file/gov-form-file.js.map +1 -1
- package/dist/collection/components/gov-form/search/gov-form-search.js +2 -2
- package/dist/collection/components/gov-form/search/gov-form-search.js.map +1 -1
- package/dist/collection/components/gov-form/select/gov-form-select.js +8 -15
- package/dist/collection/components/gov-form/select/gov-form-select.js.map +1 -1
- package/dist/collection/components/gov-tooltip/gov-tooltip-content.js +22 -1
- package/dist/collection/components/gov-tooltip/gov-tooltip-content.js.map +1 -1
- package/dist/collection/components/gov-tooltip/gov-tooltip.js +31 -8
- package/dist/collection/components/gov-tooltip/gov-tooltip.js.map +1 -1
- package/dist/collection/components/gov-wizard/gov-wizard-item.js +2 -2
- package/dist/collection/components/gov-wizard/gov-wizard.js +1 -1
- package/dist/components/gov-accordion-item.js +1 -1
- package/dist/components/gov-accordion.js +1 -1
- package/dist/components/gov-attachments-item.js +1 -1
- package/dist/components/gov-attachments.js +1 -1
- package/dist/components/gov-backdrop.js +1 -1
- package/dist/components/gov-banner.js +1 -1
- package/dist/components/gov-banner.js.map +1 -1
- package/dist/components/gov-blockquote.js +1 -1
- package/dist/components/gov-breadcrumbs.js +1 -1
- package/dist/components/gov-breadcrumbs.js.map +1 -1
- package/dist/components/gov-button.js +1 -1
- package/dist/components/gov-card.js +1 -1
- package/dist/components/gov-chip.js +1 -1
- package/dist/components/gov-collapsible.js +1 -1
- package/dist/components/gov-collapsible.js.map +1 -1
- package/dist/components/gov-container.js +1 -1
- package/dist/components/gov-control-group.js +1 -1
- package/dist/components/gov-cookiebar.js +1 -1
- package/dist/components/gov-dialog.js +1 -1
- package/dist/components/gov-dropdown.js +1 -1
- package/dist/components/gov-empty.js +1 -1
- package/dist/components/gov-error-code.js +1 -1
- package/dist/components/gov-flex.js +1 -1
- package/dist/components/gov-form-autocomplete.js +1 -1
- package/dist/components/gov-form-checkbox-group.js +1 -1
- package/dist/components/gov-form-checkbox.js +1 -1
- package/dist/components/gov-form-control.js +1 -1
- package/dist/components/gov-form-file.js +1 -1
- package/dist/components/gov-form-file.js.map +1 -1
- package/dist/components/gov-form-group.js +1 -1
- package/dist/components/gov-form-input.js +1 -1
- package/dist/components/gov-form-message.js +1 -1
- package/dist/components/gov-form-multi-select.js +1 -1
- package/dist/components/gov-form-multi-select.js.map +1 -1
- package/dist/components/gov-form-radio-group.js +1 -1
- package/dist/components/gov-form-radio.js +1 -1
- package/dist/components/gov-form-range.js +1 -1
- package/dist/components/gov-form-range.js.map +1 -1
- package/dist/components/gov-form-search.js +1 -1
- package/dist/components/gov-form-search.js.map +1 -1
- package/dist/components/gov-form-select.js +1 -1
- package/dist/components/gov-form-switch.js +1 -1
- package/dist/components/gov-grid-item.js +1 -1
- package/dist/components/gov-grid.js +1 -1
- package/dist/components/gov-icon.js +1 -1
- package/dist/components/gov-infobar.js +1 -1
- package/dist/components/gov-layout-column.js +1 -1
- package/dist/components/gov-layout.js +1 -1
- package/dist/components/gov-link.js +1 -1
- package/dist/components/gov-loading.js +1 -1
- package/dist/components/gov-message.js +1 -1
- package/dist/components/gov-pagination.js +1 -1
- package/dist/components/gov-skeleton.js +1 -1
- package/dist/components/gov-spacer.js +1 -1
- package/dist/components/gov-stepper-item.js +1 -1
- package/dist/components/gov-stepper.js +1 -1
- package/dist/components/gov-tabs-item.js +1 -1
- package/dist/components/gov-tabs.js +1 -1
- package/dist/components/gov-tag.js +1 -1
- package/dist/components/gov-theme-switch.js +1 -1
- package/dist/components/gov-tile.js +1 -1
- package/dist/components/gov-toast.js +1 -1
- package/dist/components/gov-tooltip-content.js +1 -1
- package/dist/components/gov-tooltip.js +1 -1
- package/dist/components/gov-wizard-item.js +1 -1
- package/dist/components/gov-wizard.js +1 -1
- package/dist/components/{p-DKo9A5gq.js → p-BHRF-5cf.js} +2 -2
- package/dist/components/{p-9imLQpxb.js → p-BSr8e18S.js} +2 -2
- package/dist/components/{p-BNnuBQvo.js → p-BxS4InzB.js} +2 -2
- package/dist/components/{p-CfaJM4SA.js → p-CMmyR4-k.js} +2 -2
- package/dist/components/{p-B0KFtEn3.js → p-CU0plGZP.js} +2 -2
- package/dist/components/{p-BrdXh0mI.js → p-CXPP9vec.js} +2 -2
- package/dist/components/{p-djqfSbq-.js → p-C_URF9Su.js} +2 -2
- package/dist/components/{p-yqJEurSE.js → p-CnKqUwf9.js} +2 -2
- package/dist/components/p-DEthsMuE.js +2 -0
- package/dist/components/p-DEthsMuE.js.map +1 -0
- package/dist/components/{p-Bv5L0j6n.js → p-DN5pb9xA.js} +2 -2
- package/dist/components/{p-DesycS6d.js → p-iTwUkISB.js} +2 -2
- package/dist/components/{p-BZTY3MxF.js → p-ibUK7mfI.js} +2 -2
- package/dist/components/p-keC6luw7.js +2 -0
- package/dist/components/p-keC6luw7.js.map +1 -0
- package/dist/components/p-pJ_vPAO0.js +2 -0
- package/dist/components/p-pJ_vPAO0.js.map +1 -0
- package/dist/components/p-yIpIIG5A.js +2 -0
- package/dist/components/p-yIpIIG5A.js.map +1 -0
- package/dist/core/core.css +47 -47
- package/dist/core/core.esm.js +1 -1
- package/dist/core/gov-banner.entry.esm.js.map +1 -1
- package/dist/core/gov-form-autocomplete.entry.esm.js.map +1 -1
- package/dist/core/gov-form-file.entry.esm.js.map +1 -1
- package/dist/core/gov-form-search.entry.esm.js.map +1 -1
- package/dist/core/gov-form-select.entry.esm.js.map +1 -1
- package/dist/core/gov-tooltip.gov-tooltip-content.entry.esm.js.map +1 -1
- package/dist/core/{p-4da8ac1d.entry.js → p-10991f00.entry.js} +2 -2
- package/dist/core/p-19300834.entry.js +2 -0
- package/dist/core/{p-bd389bfd.entry.js.map → p-19300834.entry.js.map} +1 -1
- package/dist/core/p-4e2faea7.entry.js +2 -0
- package/dist/core/p-4e2faea7.entry.js.map +1 -0
- package/dist/core/p-7f513718.entry.js +2 -0
- package/dist/core/p-7f513718.entry.js.map +1 -0
- package/dist/core/p-8d47e346.entry.js +2 -0
- package/dist/core/p-8d47e346.entry.js.map +1 -0
- package/dist/core/p-DQuL1Twl.js.map +1 -1
- package/dist/core/p-afe254cb.entry.js +2 -0
- package/dist/core/p-afe254cb.entry.js.map +1 -0
- package/dist/core/{p-469f14db.entry.js → p-bec959c4.entry.js} +2 -2
- package/dist/core/p-d9d29f50.entry.js +2 -0
- package/dist/core/p-d9d29f50.entry.js.map +1 -0
- package/dist/core/{p-4d365881.entry.js → p-f75ad657.entry.js} +2 -2
- package/dist/esm/app-globals-DQuL1Twl.js.map +1 -1
- package/dist/esm/core.js +1 -1
- package/dist/esm/gov-banner.entry.js +3 -3
- package/dist/esm/gov-banner.entry.js.map +1 -1
- package/dist/esm/gov-flex_3.entry.js +1 -1
- package/dist/esm/gov-form-autocomplete.entry.js +68 -24
- package/dist/esm/gov-form-autocomplete.entry.js.map +1 -1
- package/dist/esm/gov-form-file.entry.js +32 -3
- package/dist/esm/gov-form-file.entry.js.map +1 -1
- package/dist/esm/gov-form-search.entry.js +1 -1
- package/dist/esm/gov-form-search.entry.js.map +1 -1
- package/dist/esm/gov-form-select.entry.js +8 -15
- package/dist/esm/gov-form-select.entry.js.map +1 -1
- package/dist/esm/gov-tooltip.gov-tooltip-content.entry.js.map +1 -1
- package/dist/esm/gov-tooltip_2.entry.js +34 -9
- package/dist/esm/gov-tooltip_2.entry.js.map +1 -1
- package/dist/esm/gov-wizard-item.entry.js +2 -2
- package/dist/esm/gov-wizard.entry.js +1 -1
- package/dist/esm/index-ClISz4NF.js +4 -4
- package/dist/esm/loader.js +1 -1
- package/dist/hydrate/index.js +154 -60
- package/dist/hydrate/index.mjs +154 -60
- package/dist/types/Users/jf/dev/designSystem/gov-design-system/packages/core/.stencil/packages/core/stencil.config.d.ts +2 -0
- package/dist/types/components/gov-form/autocomplete/autocomplete.utils.d.ts +2 -0
- package/dist/types/components/gov-form/autocomplete/gov-form-autocomplete.d.ts +9 -0
- package/dist/types/components/gov-form/file/gov-form-file.d.ts +1 -0
- package/dist/types/components/gov-form/select/gov-form-select.d.ts +1 -1
- package/dist/types/components/gov-tooltip/gov-tooltip-content.d.ts +4 -0
- package/dist/types/components/gov-tooltip/gov-tooltip.d.ts +3 -0
- package/dist/types/components.d.ts +20 -2
- package/package.json +2 -2
- package/readme.md +9 -0
- package/dist/components/p-DFu5UVoP.js +0 -2
- package/dist/components/p-DFu5UVoP.js.map +0 -1
- package/dist/components/p-DMVQRz4f.js +0 -2
- package/dist/components/p-DMVQRz4f.js.map +0 -1
- package/dist/components/p-UDT3DloZ.js +0 -2
- package/dist/components/p-UDT3DloZ.js.map +0 -1
- package/dist/components/p-x3w8Mun_.js +0 -2
- package/dist/components/p-x3w8Mun_.js.map +0 -1
- package/dist/core/p-11fc3899.entry.js +0 -2
- package/dist/core/p-11fc3899.entry.js.map +0 -1
- package/dist/core/p-33b462c9.entry.js +0 -2
- package/dist/core/p-33b462c9.entry.js.map +0 -1
- package/dist/core/p-3e5ae012.entry.js +0 -2
- package/dist/core/p-3e5ae012.entry.js.map +0 -1
- package/dist/core/p-bd389bfd.entry.js +0 -2
- package/dist/core/p-c21bc8f9.entry.js +0 -2
- package/dist/core/p-c21bc8f9.entry.js.map +0 -1
- package/dist/core/p-def34832.entry.js +0 -2
- package/dist/core/p-def34832.entry.js.map +0 -1
- package/dist/types/work/packages/core/.stencil/packages/core/stencil.config.d.ts +0 -2
- /package/dist/components/{p-DKo9A5gq.js.map → p-BHRF-5cf.js.map} +0 -0
- /package/dist/components/{p-9imLQpxb.js.map → p-BSr8e18S.js.map} +0 -0
- /package/dist/components/{p-BNnuBQvo.js.map → p-BxS4InzB.js.map} +0 -0
- /package/dist/components/{p-CfaJM4SA.js.map → p-CMmyR4-k.js.map} +0 -0
- /package/dist/components/{p-B0KFtEn3.js.map → p-CU0plGZP.js.map} +0 -0
- /package/dist/components/{p-BrdXh0mI.js.map → p-CXPP9vec.js.map} +0 -0
- /package/dist/components/{p-djqfSbq-.js.map → p-C_URF9Su.js.map} +0 -0
- /package/dist/components/{p-yqJEurSE.js.map → p-CnKqUwf9.js.map} +0 -0
- /package/dist/components/{p-Bv5L0j6n.js.map → p-DN5pb9xA.js.map} +0 -0
- /package/dist/components/{p-DesycS6d.js.map → p-iTwUkISB.js.map} +0 -0
- /package/dist/components/{p-BZTY3MxF.js.map → p-ibUK7mfI.js.map} +0 -0
- /package/dist/core/{p-4da8ac1d.entry.js.map → p-10991f00.entry.js.map} +0 -0
- /package/dist/core/{p-469f14db.entry.js.map → p-bec959c4.entry.js.map} +0 -0
- /package/dist/core/{p-4d365881.entry.js.map → p-f75ad657.entry.js.map} +0 -0
|
@@ -233,7 +233,7 @@ export namespace Components {
|
|
|
233
233
|
"background": BannerBackgroundsType;
|
|
234
234
|
/**
|
|
235
235
|
* Banner’s foreground
|
|
236
|
-
* @default BannerForeground.
|
|
236
|
+
* @default BannerForeground.IMAGE
|
|
237
237
|
*/
|
|
238
238
|
"foreground": BannerForegroundsType;
|
|
239
239
|
/**
|
|
@@ -690,6 +690,11 @@ export namespace Components {
|
|
|
690
690
|
* Indicates the entered value does not conform to the format expected by the application.
|
|
691
691
|
*/
|
|
692
692
|
"invalid": boolean;
|
|
693
|
+
/**
|
|
694
|
+
* Maximum number of items shown from a static `options` list (0 = unlimited). Applies only when no async search callback is set.
|
|
695
|
+
* @default 10
|
|
696
|
+
*/
|
|
697
|
+
"maxOptions": number;
|
|
693
698
|
/**
|
|
694
699
|
* Maximum length (number of characters) of value
|
|
695
700
|
*/
|
|
@@ -2057,6 +2062,10 @@ export namespace Components {
|
|
|
2057
2062
|
* @default false
|
|
2058
2063
|
*/
|
|
2059
2064
|
"isVisible": boolean;
|
|
2065
|
+
/**
|
|
2066
|
+
* Tooltip text. When set, renders the HTML message; otherwise the default `<slot/>` is used.
|
|
2067
|
+
*/
|
|
2068
|
+
"message"?: string;
|
|
2060
2069
|
/**
|
|
2061
2070
|
* Indicates display of tooltip content
|
|
2062
2071
|
* @default null
|
|
@@ -3169,7 +3178,7 @@ declare namespace LocalJSX {
|
|
|
3169
3178
|
"background"?: BannerBackgroundsType;
|
|
3170
3179
|
/**
|
|
3171
3180
|
* Banner’s foreground
|
|
3172
|
-
* @default BannerForeground.
|
|
3181
|
+
* @default BannerForeground.IMAGE
|
|
3173
3182
|
*/
|
|
3174
3183
|
"foreground"?: BannerForegroundsType;
|
|
3175
3184
|
/**
|
|
@@ -3610,6 +3619,11 @@ declare namespace LocalJSX {
|
|
|
3610
3619
|
* Indicates the entered value does not conform to the format expected by the application.
|
|
3611
3620
|
*/
|
|
3612
3621
|
"invalid"?: boolean;
|
|
3622
|
+
/**
|
|
3623
|
+
* Maximum number of items shown from a static `options` list (0 = unlimited). Applies only when no async search callback is set.
|
|
3624
|
+
* @default 10
|
|
3625
|
+
*/
|
|
3626
|
+
"maxOptions"?: number;
|
|
3613
3627
|
/**
|
|
3614
3628
|
* Maximum length (number of characters) of value
|
|
3615
3629
|
*/
|
|
@@ -5004,6 +5018,10 @@ declare namespace LocalJSX {
|
|
|
5004
5018
|
* @default false
|
|
5005
5019
|
*/
|
|
5006
5020
|
"isVisible"?: boolean;
|
|
5021
|
+
/**
|
|
5022
|
+
* Tooltip text. When set, renders the HTML message; otherwise the default `<slot/>` is used.
|
|
5023
|
+
*/
|
|
5024
|
+
"message"?: string;
|
|
5007
5025
|
/**
|
|
5008
5026
|
* Indicates display of tooltip content
|
|
5009
5027
|
* @default null
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@gov-design-system-ce/components",
|
|
3
3
|
"description": "This package includes Gov Design System Web Components and related utilities.",
|
|
4
4
|
"author": "Zdeněk Vítek",
|
|
5
|
-
"version": "4.6.
|
|
5
|
+
"version": "4.6.4",
|
|
6
6
|
"license": "EUPL v1.2 Licensed",
|
|
7
7
|
"main": "./dist/index.cjs.js",
|
|
8
8
|
"unpkg": "./dist/core/core.esm.js",
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@gov-design-system-ce/icons": "^4.0.0",
|
|
26
26
|
"@gov-design-system-ce/fonts": "^4.0.0",
|
|
27
|
-
"@gov-design-system-ce/styles": "^4.6.
|
|
27
|
+
"@gov-design-system-ce/styles": "^4.6.4"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/readme.md
ADDED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{p as t,H as s,c as i,h as e,a as o}from"./index.js";import{t as h,b as a}from"./p-DKo9A5gq.js";import{v as n}from"./p-BKP-F1qP.js";import{c as l}from"./p-vN03FcXN.js";import{d as r,t as c,h as m}from"./p-CQvUntGY.js";import{F as u,a as f}from"./p-9imLQpxb.js";import{p as d}from"./p-B0hcuYXk.js";import{A as p,a as v,i as g}from"./p-CXgom82_.js";import{d as b}from"./p-djqfSbq-.js";import{d as y}from"./p-Bv5L0j6n.js";import{d as k}from"./p-BrdXh0mI.js";import{d as j}from"./p-BNnuBQvo.js";const w=t(class t extends s{constructor(){super();this.__registerHost();this.govFocus=i(this,"gov-focus");this.govBlur=i(this,"gov-blur");this.govInput=i(this,"gov-input");this.govSelect=i(this,"gov-select");this.templateResolver=t=>t[this.nameKey];this.value="";this.size="m";this.nameKey="name";this.required=false;this.disabled=false;this.minlength=3;this.throttleTime=200;this.messageEmpty="Nebyly nalezeny žádné výsledky";this.processing=false;this.arrowCounter=-1;this.list=[];this.inheritedAttributes={};this.listBoxId=l("GovListBox")}validateSize(t){n(f,t,u.root)}watchOptions(t){this.setOptions(d(t)).catch()}onArrowUp(){if(this.arrowCounter>0){this.arrowCounter=this.arrowCounter-1;this.moveToView().finally()}}onArrowDown(){if(this.arrowCounter<this.list.length-1){this.arrowCounter=this.arrowCounter+1;this.moveToView().finally()}}async moveToView(){await r(200);const t=this.listRef.offsetHeight;const s=this.listRef.querySelector('li[aria-selected="true"]');if(s&&t){const t=s.offsetTop;this.listRef.scrollTo({top:t,behavior:"smooth"})}}doSearch(){if(Number.isInteger(this.minlength)&&this.isValueAccepted===false&&this.minlength){this.list=[];this.arrowCounter=-1;this.processing=false;return}if(this.searchCallback){this.processing=true;this.searchCallback(this.value).then((t=>this.list=t)).catch((()=>this.list=[])).finally((()=>{this.arrowCounter=-1;this.processing=false}))}}clearList(){const t=d(this.options);if(t.length===0){this.list=[]}}get isValueAccepted(){if(typeof this.value==="string"){return this.value.length>=this.minlength}else{return false}}componentDidLoad(){this.attributeObserver=new p(this.host,((t,s)=>{this.onAriaAttributeChange(t,s)}));this.attributeObserver.startObserving(v)}componentWillLoad(){this.validateSize(this.size);this.inheritedAttributes=g(this.host)}disconnectedCallback(){var t;(t=this.attributeObserver)===null||t===void 0?void 0:t.stopObserving()}onAriaAttributeChange(t,s){this.host.removeAttribute(t);this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[t]:s})}render(){return e(o,{key:"531610863e3752a4e07f0b6c3b946c475a6420c6",class:u.root,size:this.size},e("gov-form-input",Object.assign({key:"82f74fc8139c85cddb4e206c5d82286107135fff",placeholder:this.placeholder,name:this.name,disabled:this.disabled,readonly:this.readonly,autocomplete:false,size:this.size,required:this.required,invalid:this.invalid,success:this.success,role:"searchbox",value:this.value,minlength:this.minlength,maxlength:this.maxlength,"on-gov-input":c(this.onInputHandler.bind(this),this.throttleTime),"on-gov-keyup":this.onKeyUpHandler.bind(this),"on-gov-keydown":this.onKeyDownHandler.bind(this),"on-gov-focus":this.onFocusHandler.bind(this),"on-gov-blur":this.onBlurHandler.bind(this)},this.inheritedAttributes,{"aria-autocomplete":"list","aria-owns":[this.listBoxId,this.inheritedAttributes["aria-owns"]].join(" "),"aria-expanded":a(this.list.length&&this.focused?true:false),ref:t=>this.inputRef=t}),e("slot",{key:"d27f897ff5c405adc14640a7e8508319df7b5ff9",name:"validation-icon"}),e("slot",{key:"da5ec2879f9c6ba7c57a68cc2515539016a6ec43",name:"icon-end"})),e("ul",{key:"cbb3514f12fe3c506d7bcf2c3aa86b78303ac398",class:u.list,role:"listbox","aria-hidden":h(!this.focused),hidden:!this.focused,id:this.listBoxId,ref:t=>this.listRef=t},this.focused&&this.list.length===0&&this.processing===false&&this.isValueAccepted&&this.messageEmpty?e("li",{class:u.empty},this.messageEmpty):null,this.focused&&this.processing===true&&this.isValueAccepted?e("li",{class:u.loading},e("gov-skeleton",{size:"m"})):null,this.focused?this.list.map(((t,s)=>{const i=this.arrowCounter===s;return e("li",{class:u.item,innerHTML:this.templateResolver(t,i),role:"option","aria-posinset":s,tabindex:i?0:-1,"aria-setsize":this.list.length,onTouchStart:t=>this.onSelectHandler(t,s),onMouseDown:t=>this.onSelectHandler(t,s),"aria-selected":h(i)},e("slot",{name:"list-item-left"}),e("slot",{name:"list-item-right"}))})):null))}onFocusHandler(t){this.focused=true;this.arrowCounter=-1;if(this.isValueAccepted&&this.searchCallback){this.doSearch()}t.stopPropagation();this.govFocus.emit({originalEvent:t,component:u.root,value:this.value,selected:null})}onBlurHandler(t){this.focused=false;this.clearList();this.arrowCounter=-1;t.stopPropagation();this.govBlur.emit({originalEvent:t,component:u.root,value:this.value,selected:null})}onInputHandler(t){this.value=t.target.value;t.stopPropagation();this.govInput.emit({originalEvent:t,component:u.root,value:this.value,selected:null});this.doSearch()}onSelectHandler(t,s=-1){let i=null;if(s>-1){i=this.list[s]}else if(m(this.arrowCounter,this.list)){i=this.list[this.arrowCounter]}if(i){this.govSelect.emit({component:u.root,value:this.value,selected:i,originalEvent:t});this.clearList();if(m(this.nameKey,i)&&typeof i[this.nameKey]==="string"){this.value=i[this.nameKey]}}}onKeyUpHandler(t){const s=t.detail.originalEvent;t.stopPropagation();s.stopPropagation();if(s.keyCode===38)this.onArrowUp();else if(s.keyCode===40)this.onArrowDown();else if(s.keyCode===13){t.preventDefault();s.preventDefault();this.onSelectHandler(t)}}onKeyDownHandler(t){const s=t.detail.originalEvent;t.stopPropagation();s.stopPropagation();if(s.keyCode===13){t.preventDefault();s.preventDefault()}}async setFocus(t){return this.inputRef.focus(t)}async setBlur(){return this.inputRef.blur()}async setOptions(t){this.list=Array.isArray(t)?t:[];this.arrowCounter=-1}async clearValue(){this.value="";this.inputRef.value="";await this.inputRef.clearValue()}async setProcessing(t){this.processing=t}async setSearchCallback(t){this.searchCallback=t}async setTemplateResolver(t){this.templateResolver=t}get host(){return this}static get watchers(){return{size:["validateSize"],options:["watchOptions"]}}},[4,"gov-form-autocomplete",{value:[1537],options:[1537],identifier:[1],success:[4],size:[1],nameKey:[1,"name-key"],name:[1],required:[4],disabled:[516],placeholder:[1],readonly:[4],invalid:[4],minlength:[2],maxlength:[2],throttleTime:[2,"throttle-time"],messageEmpty:[1,"message-empty"],focused:[32],processing:[32],arrowCounter:[32],list:[32],inheritedAttributes:[32],setFocus:[64],setBlur:[64],setOptions:[64],clearValue:[64],setProcessing:[64],setSearchCallback:[64],setTemplateResolver:[64]},undefined,{size:["validateSize"],options:["watchOptions"]}]);function E(){if(typeof customElements==="undefined"){return}const t=["gov-form-autocomplete","gov-button","gov-form-input","gov-icon","gov-skeleton"];t.forEach((t=>{switch(t){case"gov-form-autocomplete":if(!customElements.get(t)){customElements.define(t,w)}break;case"gov-button":if(!customElements.get(t)){b()}break;case"gov-form-input":if(!customElements.get(t)){y()}break;case"gov-icon":if(!customElements.get(t)){k()}break;case"gov-skeleton":if(!customElements.get(t)){j()}break}}))}E();export{w as G,E as d};
|
|
2
|
-
//# sourceMappingURL=p-DFu5UVoP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["GovFormAutocomplete","__stencil_proxyCustomElement","HTMLElement","constructor","this","templateResolver","item","nameKey","value","size","required","disabled","minlength","throttleTime","messageEmpty","processing","arrowCounter","list","inheritedAttributes","listBoxId","createID","validateSize","newValue","validateProp","FormAutocompleteSizes","FormAutocompleteClass","root","watchOptions","setOptions","propsValueToArray","catch","onArrowUp","moveToView","finally","onArrowDown","length","delay","heightOfList","listRef","offsetHeight","selected","querySelector","offsetTop","scrollTo","top","behavior","doSearch","Number","isInteger","isValueAccepted","searchCallback","then","response","clearList","areOptions","options","componentDidLoad","attributeObserver","AttributeObserver","host","attributeName","onAriaAttributeChange","startObserving","ariaAttributes","componentWillLoad","inheritAriaAttributes","disconnectedCallback","_a","stopObserving","removeAttribute","Object","assign","render","h","Host","key","class","placeholder","name","readonly","autocomplete","invalid","success","role","maxlength","throttle","onInputHandler","bind","onKeyUpHandler","onKeyDownHandler","onFocusHandler","onBlurHandler","join","booleanString","focused","ref","el","inputRef","toBoolAttr","hidden","id","empty","loading","map","index","isSelected","innerHTML","tabindex","onTouchStart","e","onSelectHandler","onMouseDown","stopPropagation","govFocus","emit","originalEvent","component","govBlur","target","govInput","has","govSelect","event","detail","keyCode","preventDefault","setFocus","focus","setBlur","blur","Array","isArray","clearValue","setProcessing","status","setSearchCallback","callback","setTemplateResolver"],"sources":["../../../packages/core/src/components/gov-form/autocomplete/gov-form-autocomplete.tsx"],"sourcesContent":["import {Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch} from '@stencil/core'\nimport {booleanString, toBoolAttr} from '../../../helpers/Dom/template'\nimport {validateProp} from '../../../helpers/Validate/props'\nimport {Nullable} from '../../../types/interfaces'\nimport {createID} from '../../../utils/string.utils'\nimport {delay, has, throttle} from '../../../utils/utils'\nimport {FormInputEvent} from '../input/gov-form-input.types'\nimport {FormAutocompleteClass, FormAutocompleteSizes, SizesType,} from './constants'\nimport {FormAutocompleteEvent, GovFormAutocompleteItem} from './gov-form-autocomplete.types'\nimport {propsValueToArray} from \"../../../utils/array.utils\";\nimport {AttributeObserver, Attributes} from \"../../../helpers/Dom/attribute\";\nimport {ariaAttributes} from \"../../../helpers/Accessibility/attributes\";\nimport {inheritAriaAttributes} from \"../../../helpers/Accessibility/accessibility\";\n\n@Component({\n\ttag: 'gov-form-autocomplete',\n})\nexport class GovFormAutocomplete {\n\tprivate inputRef?: HTMLGovFormInputElement\n\tprivate listRef?: HTMLUListElement\n\tprivate readonly listBoxId: string\n\tprivate searchCallback: (value: string) => Promise<GovFormAutocompleteItem[]>\n\tprivate templateResolver: (item: GovFormAutocompleteItem, selected: boolean) => string = item => item[this.nameKey]\n\tprivate attributeObserver: AttributeObserver\n\n\tconstructor() {\n\t\tthis.listBoxId = createID('GovListBox')\n\t}\n\n\t@Element() host: HTMLGovFormInputElement\n\t/**\n\t * Value of input\n\t */\n\t@Prop({reflect: true, mutable: true}) value = ''\n\t/**\n\t * Options of autocomplete\n\t */\n\t@Prop({reflect: true, mutable: true}) options?: string | GovFormAutocompleteItem[]\n\t/**\n\t * Custom input identifier.\n\t */\n\t@Prop({attribute: 'identifier'}) readonly identifier: string\n\t/**\n\t * Indicates the entered value of child form element does conform to the format expected by the application.\n\t */\n\t@Prop() readonly success: boolean\n\t/**\n\t * Input’s size.\n\t */\n\t@Prop() readonly size?: SizesType = 'm'\n\t/**\n\t * Main key name in the object\n\t */\n\t@Prop({attribute: 'name-key'}) readonly nameKey: string = 'name'\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the input component disabled.\n\t * This prevents users from being able to interact with the select, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop({reflect: true}) readonly disabled: boolean = false\n\t/**\n\t * Text that appears in the form control when it has no value set\n\t */\n\t@Prop() readonly placeholder: string\n\t/**\n\t * The value is not editable\n\t */\n\t@Prop() readonly readonly: boolean\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Minimum length (number of characters) of value\n\t */\n\t@Prop() readonly minlength: number = 3\n\t/**\n\t * Maximum length (number of characters) of value\n\t */\n\t@Prop() readonly maxlength: number\n\t/**\n\t * Input throttle in milliseconds\n\t */\n\t@Prop() readonly throttleTime: number = 200\n\t/**\n\t * Custom message for when there is a blank sheet\n\t */\n\t@Prop({attribute: 'message-empty'}) readonly messageEmpty: string = 'Nebyly nalezeny žádné výsledky'\n\t/**\n\t * Emitted when the input has focus.\n\t */\n\t@Event({eventName: 'gov-focus'}) govFocus: EventEmitter<FormAutocompleteEvent>\n\t/**\n\t * Emitted when the input loses focus.\n\t */\n\t@Event({eventName: 'gov-blur'}) govBlur: EventEmitter<FormAutocompleteEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({eventName: 'gov-input'}) govInput: EventEmitter<FormAutocompleteEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({eventName: 'gov-select'}) govSelect: EventEmitter<FormAutocompleteEvent>\n\n\t@State() focused: boolean\n\t@State() processing = false\n\t@State() arrowCounter = -1\n\t@State() list: GovFormAutocompleteItem[] = []\n\t@State() inheritedAttributes: Attributes = {}\n\n\t@Watch('size')\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormAutocompleteSizes, newValue, FormAutocompleteClass.root)\n\t}\n\n\t@Watch('options')\n\twatchOptions(newValue: string | GovFormAutocompleteItem[]): void {\n\t\tthis.setOptions(propsValueToArray(newValue)).catch()\n\t}\n\n\tprivate onArrowUp() {\n\t\tif (this.arrowCounter > 0) {\n\t\t\tthis.arrowCounter = this.arrowCounter - 1\n\t\t\tthis.moveToView().finally()\n\t\t}\n\t}\n\n\tprivate onArrowDown() {\n\t\tif (this.arrowCounter < this.list.length - 1) {\n\t\t\tthis.arrowCounter = this.arrowCounter + 1\n\t\t\tthis.moveToView().finally()\n\t\t}\n\t}\n\n\tprivate async moveToView() {\n\t\tawait delay(200)\n\t\tconst heightOfList = this.listRef.offsetHeight\n\t\tconst selected = this.listRef.querySelector('li[aria-selected=\"true\"]') as HTMLUListElement\n\t\tif (selected && heightOfList) {\n\t\t\tconst offsetTop = selected.offsetTop\n\t\t\tthis.listRef.scrollTo({top: offsetTop, behavior: 'smooth'})\n\t\t}\n\t}\n\n\tprivate doSearch() {\n\t\tif (Number.isInteger(this.minlength) && this.isValueAccepted === false && this.minlength) {\n\t\t\tthis.list = []\n\t\t\tthis.arrowCounter = -1\n\t\t\tthis.processing = false\n\t\t\treturn\n\t\t}\n\t\tif (this.searchCallback) {\n\t\t\tthis.processing = true\n\t\t\tthis.searchCallback(this.value)\n\t\t\t\t.then(response => (this.list = response))\n\t\t\t\t.catch(() => (this.list = []))\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis.arrowCounter = -1\n\t\t\t\t\tthis.processing = false\n\t\t\t\t})\n\t\t}\n\t}\n\n\tprivate clearList() {\n\t\tconst areOptions = propsValueToArray<GovFormAutocompleteItem[]>(this.options)\n\t\tif (areOptions.length === 0) {\n\t\t\tthis.list = []\n\t\t}\n\t}\n\n\tget isValueAccepted() {\n\t\tif (typeof this.value === 'string') {\n\t\t\treturn this.value.length >= this.minlength\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tcomponentDidLoad() {\n\t\tthis.attributeObserver = new AttributeObserver(this.host, (attributeName, newValue) => {\n\t\t\tthis.onAriaAttributeChange(attributeName, newValue);\n\t\t});\n\n\t\tthis.attributeObserver.startObserving(ariaAttributes);\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateSize(this.size)\n\t\tthis.inheritedAttributes = inheritAriaAttributes(this.host);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.attributeObserver?.stopObserving();\n\t}\n\n\tonAriaAttributeChange(attributeName: string, newValue: string) {\n\t\tthis.host.removeAttribute(attributeName)\n\t\tthis.inheritedAttributes = {...this.inheritedAttributes, [attributeName]: newValue};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={FormAutocompleteClass.root} size={this.size}>\n\t\t\t\t<gov-form-input\n\t\t\t\t\tplaceholder={this.placeholder}\n\t\t\t\t\tname={this.name}\n\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\treadonly={this.readonly}\n\t\t\t\t\tautocomplete={false}\n\t\t\t\t\tsize={this.size}\n\t\t\t\t\trequired={this.required}\n\t\t\t\t\tinvalid={this.invalid}\n\t\t\t\t\tsuccess={this.success}\n\t\t\t\t\trole={'searchbox'}\n\t\t\t\t\tvalue={this.value}\n\t\t\t\t\tminlength={this.minlength}\n\t\t\t\t\tmaxlength={this.maxlength}\n\t\t\t\t\ton-gov-input={throttle(this.onInputHandler.bind(this), this.throttleTime)}\n\t\t\t\t\ton-gov-keyup={this.onKeyUpHandler.bind(this)}\n\t\t\t\t\ton-gov-keydown={this.onKeyDownHandler.bind(this)}\n\t\t\t\t\ton-gov-focus={this.onFocusHandler.bind(this)}\n\t\t\t\t\ton-gov-blur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t{...this.inheritedAttributes}\n\t\t\t\t\taria-autocomplete={'list'}\n\t\t\t\t\taria-owns={[this.listBoxId, this.inheritedAttributes['aria-owns']].join(' ')}\n\t\t\t\t\taria-expanded={booleanString(this.list.length && this.focused ? true : false)}\n\t\t\t\t\tref={el => (this.inputRef = el as HTMLGovFormInputElement)}\n\t\t\t\t>\n\t\t\t\t\t<slot name=\"validation-icon\" />\n\t\t\t\t\t<slot name=\"icon-end\" />\n\t\t\t\t</gov-form-input>\n\t\t\t\t<ul class={FormAutocompleteClass.list}\n\t\t\t\t\trole={'listbox'}\n\t\t\t\t\taria-hidden={toBoolAttr(!this.focused)}\n\t\t\t\t\thidden={!this.focused}\n\t\t\t\t\tid={this.listBoxId}\n\t\t\t\t\tref={el => (this.listRef = el as HTMLUListElement)}>\n\t\t\t\t\t{this.focused && this.list.length === 0 && this.processing === false && this.isValueAccepted && this.messageEmpty ? (\n\t\t\t\t\t\t<li class={FormAutocompleteClass.empty}>{this.messageEmpty}</li>\n\t\t\t\t\t) : null}\n\t\t\t\t\t{this.focused && this.processing === true && this.isValueAccepted ? (\n\t\t\t\t\t\t<li class={FormAutocompleteClass.loading}>\n\t\t\t\t\t\t\t<gov-skeleton size=\"m\"></gov-skeleton>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t) : null}\n\t\t\t\t\t{this.focused ? this.list.map((item, index) => {\n\t\t\t\t\t\tconst isSelected = this.arrowCounter === index\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<li\n\t\t\t\t\t\t\t\tclass={FormAutocompleteClass.item}\n\t\t\t\t\t\t\t\tinnerHTML={this.templateResolver(item, isSelected)}\n\t\t\t\t\t\t\t\trole={'option'}\n\t\t\t\t\t\t\t\taria-posinset={index}\n\t\t\t\t\t\t\t\ttabindex={isSelected ? 0 : -1}\n\t\t\t\t\t\t\t\taria-setsize={this.list.length}\n\t\t\t\t\t\t\t\tonTouchStart={(e: TouchEvent) => this.onSelectHandler(e, index)}\n\t\t\t\t\t\t\t\tonMouseDown={(e: PointerEvent) => this.onSelectHandler(e, index)}\n\t\t\t\t\t\t\t\taria-selected={toBoolAttr(isSelected)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<slot name=\"list-item-left\"/>\n\t\t\t\t\t\t\t\t<slot name=\"list-item-right\"/>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t)\n\t\t\t\t\t}) : null}\n\t\t\t\t</ul>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\tthis.focused = true\n\t\tthis.arrowCounter = -1\n\t\tif (this.isValueAccepted && this.searchCallback) {\n\t\t\tthis.doSearch()\n\t\t}\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\toriginalEvent: e,\n\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\tvalue: this.value,\n\t\t\tselected: null,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\tthis.focused = false\n\t\tthis.clearList();\n\t\tthis.arrowCounter = -1\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\toriginalEvent: e,\n\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\tvalue: this.value,\n\t\t\tselected: null,\n\t\t})\n\t}\n\n\tprivate onInputHandler(e: InputEvent) {\n\t\tthis.value = (e.target as HTMLGovFormInputElement).value\n\t\te.stopPropagation()\n\t\tthis.govInput.emit({\n\t\t\toriginalEvent: e,\n\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\tvalue: this.value,\n\t\t\tselected: null,\n\t\t})\n\t\tthis.doSearch()\n\t}\n\n\tprivate onSelectHandler(e: PointerEvent | CustomEvent | TouchEvent, index = -1) {\n\t\tlet selected: Nullable<GovFormAutocompleteItem> = null\n\t\tif (index > -1) {\n\t\t\tselected = this.list[index]\n\t\t} else if (has(this.arrowCounter, this.list)) {\n\t\t\tselected = this.list[this.arrowCounter]\n\t\t}\n\t\tif (selected) {\n\t\t\tthis.govSelect.emit({\n\t\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\t\tvalue: this.value,\n\t\t\t\tselected: selected,\n\t\t\t\toriginalEvent: e,\n\t\t\t})\n\t\t\tthis.clearList();\n\t\t\tif (has(this.nameKey, selected) && typeof selected[this.nameKey] === 'string') {\n\t\t\t\tthis.value = selected[this.nameKey]\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate onKeyUpHandler(e: CustomEvent) {\n\t\tconst event = (e.detail as FormInputEvent).originalEvent as KeyboardEvent\n\t\te.stopPropagation()\n\t\tevent.stopPropagation()\n\t\tif (event.keyCode === 38) this.onArrowUp()\n\t\telse if (event.keyCode === 40) this.onArrowDown()\n\t\telse if (event.keyCode === 13) {\n\t\t\te.preventDefault()\n\t\t\tevent.preventDefault()\n\t\t\tthis.onSelectHandler(e)\n\t\t}\n\t}\n\n\tprivate onKeyDownHandler(e: CustomEvent) {\n\t\tconst event = (e.detail as FormInputEvent).originalEvent as KeyboardEvent\n\t\te.stopPropagation()\n\t\tevent.stopPropagation()\n\t\tif (event.keyCode === 13) {\n\t\t\te.preventDefault()\n\t\t\tevent.preventDefault()\n\t\t}\n\t}\n\n\t/**\n\t * Focus main input element\n\t */\n\t@Method()\n\tasync setFocus(options?: FocusOptions): Promise<void> {\n\t\treturn this.inputRef.focus(options)\n\t}\n\n\t/**\n\t * Blur main input element\n\t */\n\t@Method()\n\tasync setBlur(): Promise<void> {\n\t\treturn this.inputRef.blur()\n\t}\n\n\t/**\n\t * Set options for list\n\t */\n\t@Method()\n\tasync setOptions(options: GovFormAutocompleteItem[]): Promise<void> {\n\t\tthis.list = Array.isArray(options) ? options : []\n\t\tthis.arrowCounter = -1\n\t}\n\n\t/**\n\t * Clears whisperer value\n\t */\n\t@Method()\n\tasync clearValue(): Promise<void> {\n\t\tthis.value = ''\n\t\tthis.inputRef.value = ''\n\n\t\tawait this.inputRef.clearValue()\n\t}\n\n\t/**\n\t * Clears whisperer value\n\t */\n\t@Method()\n\tasync setProcessing(status: boolean): Promise<void> {\n\t\tthis.processing = status\n\t}\n\n\t/**\n\t * Set a custom asynchronous function for the whisperer\n\t */\n\t@Method()\n\tasync setSearchCallback(callback: (value: string) => Promise<any>) {\n\t\tthis.searchCallback = callback\n\t}\n\n\t/**\n\t * Setting a custom whisper result template\n\t * @param callback\n\t */\n\t@Method()\n\tasync setTemplateResolver(callback: (item: GovFormAutocompleteItem) => string) {\n\t\tthis.templateResolver = callback\n\t}\n}\n"],"mappings":"ufAiBaA,EAAmBC,EAAA,MAAAD,UAAAE,EAQ/B,WAAAC,G,sKAHQC,KAAgBC,iBAAiEC,GAAQA,EAAKF,KAAKG,SAWrEH,KAAKI,MAAG,GAgB7BJ,KAAIK,KAAe,IAIIL,KAAOG,QAAW,OASzCH,KAAQM,SAAY,MAKLN,KAAQO,SAAY,MAgBnCP,KAASQ,UAAW,EAQpBR,KAAYS,aAAW,IAIKT,KAAYU,aAAW,iCAmB3DV,KAAUW,WAAG,MACbX,KAAYY,cAAG,EACfZ,KAAIa,KAA8B,GAClCb,KAAmBc,oBAAe,GA3F1Cd,KAAKe,UAAYC,EAAS,aAC1B,CA6FD,YAAAC,CAAaC,GACZC,EAAaC,EAAuBF,EAAUG,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AApB,CAAiBoB,GACxB,MAAMa,EAASb,EAAEc,OAA0BR,cAC3CN,EAAEG,kBACFU,EAAMV,kBACN,GAAIU,EAAME,UAAY,GAAI,CACzBf,EAAEgB,iBACFH,EAAMG,gB,EAQR,cAAMC,CAASvE,GACd,OAAOnD,KAAK6F,SAAS8B,MAAMxE,E,CAO5B,aAAMyE,GACL,OAAO5H,KAAK6F,SAASgC,M,CAOtB,gBAAMrG,CAAW2B,GAChBnD,KAAKa,KAAOiH,MAAMC,QAAQ5E,GAAWA,EAAU,GAC/CnD,KAAKY,cAAe,C,CAOrB,gBAAMoH,GACLhI,KAAKI,MAAQ,GACbJ,KAAK6F,SAASzF,MAAQ,SAEhBJ,KAAK6F,SAASmC,Y,CAOrB,mBAAMC,CAAcC,GACnBlI,KAAKW,WAAauH,C,CAOnB,uBAAMC,CAAkBC,GACvBpI,KAAK8C,eAAiBsF,C,CAQvB,yBAAMC,CAAoBD,GACzBpI,KAAKC,iBAAmBmI,C","ignoreList":[]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{p as i,H as t,h as s,a as e}from"./index.js";import{v as o}from"./p-BKP-F1qP.js";import{T as h,a as n,b as a,c as r,d as l}from"./p-DfI_0WW6.js";import{c as d}from"./p-vN03FcXN.js";import{g as c}from"./p-DKo9A5gq.js";import{d as f}from"./p-DrPpH_9c.js";import{t as p}from"./p-Cjg0wpDG.js";const u=i(class i extends t{constructor(){super();this.__registerHost();this.tooltipContentId=undefined;this.tooltipId=undefined;this.color=h.PRIMARY;this.size=n._M;this.position="right";this.message=undefined;this.icon=undefined;this.persist=false;this.h=c(this.host);this.tooltipId=d("GovTooltip");this.tooltipContentId=d("GovContentTooltip")}validateColor(i){o(h,i,a.root)}validateSize(i){o(n,i,a.root)}validatePosition(i){o(r,i,a.root)}rerenderMessage(){this.createContentWrapper()}connectedCallback(){this.createContentWrapper();this.registerListeners()}componentWillLoad(){this.validateColor(this.color);this.validateSize(this.size);this.validatePosition(this.position)}componentDidUpdate(){this.createContentWrapper()}disconnectedCallback(){this.removeContent()}createContentWrapper(){var i;if(this.tooltipContent){if(this.message){this.tooltipContent.innerHTML=this.message}else if(this.insideContent){this.tooltipContent.innerHTML=this.insideContent.innerHTML}return}let t;if(this.insideContent){t=this.insideContent}else{t=f().createElement(l.root);t.innerHTML=this.message}t.setAttribute("id",(i=this.identifier)!==null&&i!==void 0?i:this.tooltipContentId);t.setAttribute("parent-id",this.tooltipId);t.setAttribute("color",this.color);t.setAttribute("size",this.size);f().body.appendChild(t)}get tooltipContent(){var i;return f().body.querySelector(`#${(i=this.identifier)!==null&&i!==void 0?i:this.tooltipContentId}`)}get insideContent(){return this.host.querySelector(l.root)}registerListeners(){this.host.addEventListener("click",(i=>{i.preventDefault();this.persist=true;if(this.tooltipContent){this.tooltipContent.setAttribute("persist","true")}this.showTooltip()}));this.host.addEventListener("mouseenter",(i=>{i.preventDefault();this.showTooltip()}));this.host.addEventListener("mouseleave",(i=>{i.preventDefault();if(this.persist===false){this.hideTooltip()}}))}verifyPositionSpace(){const i=12;const t=window.innerWidth-(window.innerWidth-document.documentElement.clientWidth);const s=this.host.getBoundingClientRect();const e=this.host.offsetWidth;const o=this.host.offsetHeight;const h=this.tooltipContent.offsetWidth;const n=this.tooltipContent.offsetHeight;const a={left:s.left+document.documentElement.scrollLeft,top:s.top+document.documentElement.scrollTop};const l=a.left+i+s.width+h<=t;const d=a.left>h;if(this.position===r.LEFT||this.position===r.RIGHT){this.tooltipContent.style.top=a.top-(n-o)/2+"px";if(l===false&&d===false){this.position=r.TOP;this.tooltipContent.setAttribute("position",r.TOP)}if(d&&l===false&&this.position===r.RIGHT){this.position=r.LEFT}if(l&&d===false&&this.position===r.LEFT){this.position=r.RIGHT}}if(this.position===r.RIGHT){this.tooltipContent.setAttribute("position",r.RIGHT);this.tooltipContent.style.left=a.left+i+s.width+"px"}if(this.position===r.LEFT){this.tooltipContent.setAttribute("position",r.LEFT);this.tooltipContent.style.left=a.left-(h+i)+"px"}if(this.position===r.TOP||this.position===r.BOTTOM){if(h>e){let s=a.left-(h-e)/2;const o=s<0;const n=s+h>t;if(o&&n){this.tooltipContent.style.width="auto";this.tooltipContent.style.left=i+"px";this.tooltipContent.style.right=i+"px"}else{if(o){s=i}if(n){s=s-(t-(s+h+i))*-1}this.tooltipContent.style.left=s+"px"}}else{const i=a.left+(e-h)/2;this.tooltipContent.style.left=i+"px"}}if(this.position===r.TOP){this.tooltipContent.setAttribute("position",r.TOP);this.tooltipContent.style.top=a.top-(n+i)+"px"}if(this.position===r.BOTTOM){this.tooltipContent.setAttribute("position",r.BOTTOM);this.tooltipContent.style.top=a.top+(o+i)+"px"}this.tooltipContent.style.opacity="1"}showTooltip(){if(this.tooltipContent){this.tooltipContent.style.opacity="0";this.tooltipContent.hidden=false;this.tooltipContent.setAttribute("is-visible","true");p((()=>{this.verifyPositionSpace()}))}}hideTooltip(){if(this.tooltipContent){this.tooltipContent.setAttribute("is-visible","false");this.tooltipContent.setAttribute("persist","false");this.tooltipContent.removeAttribute("style")}}removeContent(){const i=document.getElementById(this.tooltipContentId);if(i){i.remove()}}render(){var i;return s(e,{key:"dd78d93d3b5ba4bc3a128435f58467c9bd6def43",id:this.tooltipId,class:this.h.classes(a.root),position:this.position},s("span",{key:"2ede8642a4cf998367da3756c795847195c0f694",role:"button",tabindex:0,onKeyPress:()=>this.showTooltip(),onBlur:()=>{if(this.persist===false){this.hideTooltip()}},"aria-describedby":(i=this.identifier)!==null&&i!==void 0?i:this.tooltipContentId},s("slot",{key:"9607b4c9b24766f70b53c6372e6e7219e7a3a6fd"})))}async show(){this.showTooltip()}async hide(){this.persist=false;this.hideTooltip()}get host(){return this}static get watchers(){return{color:["validateColor"],size:["validateSize"],position:["validatePosition"],message:["rerenderMessage"]}}},[4,"gov-tooltip",{color:[1],size:[1],position:[1025],message:[1],identifier:[1],icon:[516],persist:[32],show:[64],hide:[64]},undefined,{color:["validateColor"],size:["validateSize"],position:["validatePosition"],message:["rerenderMessage"]}]);function m(){if(typeof customElements==="undefined"){return}const i=["gov-tooltip"];i.forEach((i=>{switch(i){case"gov-tooltip":if(!customElements.get(i)){customElements.define(i,u)}break}}))}m();export{u as G,m as d};
|
|
2
|
-
//# sourceMappingURL=p-DMVQRz4f.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["GovTooltip","__stencil_proxyCustomElement","HTMLElement","constructor","this","tooltipContentId","undefined","tooltipId","color","TooltipColors","PRIMARY","size","TooltipSize","_M","position","message","icon","persist","h","govHost","host","createID","validateColor","newValue","validateProp","TooltipClass","root","validateSize","validatePosition","TooltipPosition","rerenderMessage","createContentWrapper","connectedCallback","registerListeners","componentWillLoad","componentDidUpdate","disconnectedCallback","removeContent","tooltipContent","innerHTML","insideContent","content","documentNode","createElement","TooltipContentClass","setAttribute","_a","identifier","body","appendChild","querySelector","addEventListener","e","preventDefault","showTooltip","hideTooltip","verifyPositionSpace","offset","windowWidth","window","innerWidth","document","documentElement","clientWidth","trigger","getBoundingClientRect","trgWidth","offsetWidth","trgHeight","offsetHeight","contentWidth","contentHeight","triggerPos","left","scrollLeft","top","scrollTop","isRightSpace","width","isLeftSpace","LEFT","RIGHT","style","TOP","BOTTOM","leftPosition","isNotLeftSpace","isNotRightSpace","right","opacity","hidden","tick","removeAttribute","contentEl","getElementById","remove","render","Host","key","id","class","classes","role","tabindex","onKeyPress","onBlur","show","hide"],"sources":["../../../packages/core/src/components/gov-tooltip/gov-tooltip.tsx"],"sourcesContent":["import {Component, Element, h, Host, Method, Prop, State, Watch} from \"@stencil/core\"\nimport {validateProp} from \"../../helpers/Validate/props\"\nimport {\n\tTooltipClass,\n\tTooltipContentClass,\n\tTooltipPosition,\n\tTooltipPositionType,\n\tTooltipSize,\n\tTooltipSizeType,\n\tTooltipColors,\n\tTooltipColorType,\n} from \"./constants\"\nimport {createID} from \"../../utils/string.utils\"\nimport {govHost} from \"../../helpers/Dom/template\"\nimport {GovHost} from \"../../helpers/Dom/template.types\"\nimport {documentNode} from \"../../helpers/Dom/win\";\nimport {Nullable} from \"../../utils/helpers.types\";\nimport {tick} from \"../../utils/stencil.utils\";\n\n@Component({\n\ttag: \"gov-tooltip\",\n})\nexport class GovTooltip {\n\tprivate h: GovHost\n\tprivate readonly tooltipContentId = undefined\n\tprivate readonly tooltipId = undefined\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.tooltipId = createID(\"GovTooltip\")\n\t\tthis.tooltipContentId = createID(\"GovContentTooltip\")\n\t}\n\n\t@Element() host: HTMLGovTooltipElement\n\t/**\n\t * Style variation of the tooltip\n\t */\n\t@Prop() readonly color?: TooltipColorType = TooltipColors.PRIMARY\n\t/**\n\t * Tooltip’s size.\n\t */\n\t@Prop() readonly size?: TooltipSizeType = TooltipSize._M\n\t/**\n\t * Tooltip display position\n\t */\n\t@Prop({mutable: true}) position: TooltipPositionType = \"right\"\n\t/**\n\t * Information contained in the tooltip\n\t */\n\t@Prop() readonly message: string = undefined\n\t/**\n\t * Custom tooltip identifier.\n\t */\n\t@Prop({attribute: \"identifier\"}) readonly identifier: string\n\t/**\n\t * Trigger is just an icon\n\t */\n\t@Prop({reflect: true}) readonly icon: boolean = undefined\n\n\t@State() persist = false\n\n\t@Watch(\"color\")\n\tvalidateColor(newValue: string): void {\n\t\tvalidateProp(TooltipColors, newValue, TooltipClass.root)\n\t}\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(TooltipSize, newValue, TooltipClass.root)\n\t}\n\n\t@Watch(\"position\")\n\tvalidatePosition(newValue: string): void {\n\t\tvalidateProp(TooltipPosition, newValue, TooltipClass.root)\n\t}\n\n\t@Watch(\"message\")\n\trerenderMessage(): void {\n\t\tthis.createContentWrapper();\n\t}\n\n\tconnectedCallback() {\n\t\tthis.createContentWrapper()\n\t\tthis.registerListeners()\n\t}\n\n\tcomponentWillLoad(): void {\n\t\tthis.validateColor(this.color)\n\t\tthis.validateSize(this.size)\n\t\tthis.validatePosition(this.position)\n\t}\n\n\tcomponentDidUpdate() {\n\t\tthis.createContentWrapper()\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.removeContent()\n\t}\n\n\tprivate createContentWrapper() {\n\t\tif (this.tooltipContent) {\n\t\t\tif (this.message) {\n\t\t\t\tthis.tooltipContent.innerHTML = this.message\n\t\t\t} else if (this.insideContent) {\n\t\t\t\tthis.tooltipContent.innerHTML = this.insideContent.innerHTML\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tlet content: HTMLGovTooltipContentElement;\n\t\tif (this.insideContent) {\n\t\t\tcontent = this.insideContent\n\t\t} else {\n\t\t\tcontent = documentNode().createElement(TooltipContentClass.root) as HTMLGovTooltipContentElement\n\t\t\tcontent.innerHTML = this.message\n\t\t}\n\n\t\tcontent.setAttribute(\"id\", this.identifier ?? this.tooltipContentId)\n\t\tcontent.setAttribute(\"parent-id\", this.tooltipId)\n\t\tcontent.setAttribute(\"color\", this.color)\n\t\tcontent.setAttribute(\"size\", this.size)\n\t\tdocumentNode().body.appendChild(content)\n\t}\n\n\tprivate get tooltipContent(): Nullable<HTMLGovTooltipContentElement> {\n\t\treturn documentNode().body.querySelector(`#${this.identifier ?? this.tooltipContentId}`);\n\t}\n\n\tprivate get insideContent(): Nullable<HTMLGovTooltipContentElement> {\n\t\treturn this.host.querySelector(TooltipContentClass.root)\n\t}\n\n\tprivate registerListeners() {\n\t\tthis.host.addEventListener(\"click\", e => {\n\t\t\te.preventDefault()\n\t\t\tthis.persist = true\n\t\t\tif (this.tooltipContent) {\n\t\t\t\tthis.tooltipContent.setAttribute(\"persist\", \"true\")\n\t\t\t}\n\t\t\tthis.showTooltip()\n\t\t})\n\t\tthis.host.addEventListener(\"mouseenter\", e => {\n\t\t\te.preventDefault()\n\t\t\tthis.showTooltip()\n\t\t})\n\t\tthis.host.addEventListener(\"mouseleave\", e => {\n\t\t\te.preventDefault()\n\t\t\tif (this.persist === false) {\n\t\t\t\tthis.hideTooltip()\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate verifyPositionSpace() {\n\t\tconst offset = 12\n\t\tconst windowWidth = window.innerWidth - (window.innerWidth - document.documentElement.clientWidth);\n\t\tconst trigger = this.host.getBoundingClientRect()\n\t\tconst trgWidth = this.host.offsetWidth\n\t\tconst trgHeight = this.host.offsetHeight\n\t\tconst contentWidth = this.tooltipContent.offsetWidth\n\t\tconst contentHeight = this.tooltipContent.offsetHeight\n\t\tconst triggerPos = {\n\t\t\tleft: trigger.left + document.documentElement.scrollLeft,\n\t\t\ttop: trigger.top + document.documentElement.scrollTop,\n\t\t}\n\n\t\tconst isRightSpace = ((triggerPos.left + offset + trigger.width) + contentWidth) <= windowWidth;\n\t\tconst isLeftSpace = triggerPos.left > contentWidth;\n\n\t\t// LEFT/RIGHT\n\t\tif (this.position === TooltipPosition.LEFT || this.position === TooltipPosition.RIGHT) {\n\t\t\tthis.tooltipContent.style.top = (triggerPos.top - ((contentHeight - trgHeight) / 2)) + \"px\";\n\t\t\tif (isRightSpace === false && isLeftSpace === false) {\n\t\t\t\tthis.position = TooltipPosition.TOP\n\t\t\t\tthis.tooltipContent.setAttribute(\"position\", TooltipPosition.TOP)\n\t\t\t}\n\t\t\tif (isLeftSpace && isRightSpace === false && this.position === TooltipPosition.RIGHT) {\n\t\t\t\tthis.position = TooltipPosition.LEFT\n\t\t\t}\n\t\t\tif (isRightSpace && isLeftSpace === false && this.position === TooltipPosition.LEFT) {\n\t\t\t\tthis.position = TooltipPosition.RIGHT\n\t\t\t}\n\t\t}\n\t\tif (this.position === TooltipPosition.RIGHT) {\n\t\t\tthis.tooltipContent.setAttribute(\"position\", TooltipPosition.RIGHT)\n\t\t\tthis.tooltipContent.style.left = (triggerPos.left + offset + trigger.width) + \"px\"\n\t\t}\n\t\tif (this.position === TooltipPosition.LEFT) {\n\t\t\tthis.tooltipContent.setAttribute(\"position\", TooltipPosition.LEFT)\n\t\t\tthis.tooltipContent.style.left = (triggerPos.left - (contentWidth + offset)) + \"px\"\n\t\t}\n\n\t\t// LEFT/RIGHT FOR TOP/BOTTOM\n\t\tif (this.position === TooltipPosition.TOP || this.position === TooltipPosition.BOTTOM) {\n\t\t\tif (contentWidth > trgWidth) {\n\t\t\t\tlet leftPosition = (triggerPos.left - ((contentWidth - trgWidth) / 2));\n\t\t\t\tconst isNotLeftSpace = leftPosition < 0;\n\t\t\t\tconst isNotRightSpace = (leftPosition + contentWidth) > windowWidth;\n\t\t\t\tif (isNotLeftSpace && isNotRightSpace) {\n\t\t\t\t\tthis.tooltipContent.style.width = \"auto\";\n\t\t\t\t\tthis.tooltipContent.style.left = offset + \"px\";\n\t\t\t\t\tthis.tooltipContent.style.right = offset + \"px\";\n\t\t\t\t} else {\n\t\t\t\t\tif (isNotLeftSpace) {\n\t\t\t\t\t\tleftPosition = offset\n\t\t\t\t\t}\n\t\t\t\t\tif (isNotRightSpace) {\n\t\t\t\t\t\tleftPosition = leftPosition - ((windowWidth - (leftPosition + contentWidth + offset)) * -1)\n\t\t\t\t\t}\n\t\t\t\t\tthis.tooltipContent.style.left = leftPosition + \"px\"\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst leftPosition = (triggerPos.left + ((trgWidth - contentWidth) / 2))\n\n\t\t\t\tthis.tooltipContent.style.left = leftPosition + \"px\"\n\t\t\t}\n\t\t}\n\t\tif (this.position === TooltipPosition.TOP) {\n\t\t\tthis.tooltipContent.setAttribute(\"position\", TooltipPosition.TOP)\n\t\t\tthis.tooltipContent.style.top = (triggerPos.top - (contentHeight + offset)) + \"px\"\n\t\t}\n\t\tif (this.position === TooltipPosition.BOTTOM) {\n\t\t\tthis.tooltipContent.setAttribute(\"position\", TooltipPosition.BOTTOM)\n\t\t\tthis.tooltipContent.style.top = (triggerPos.top + (trgHeight + offset)) + \"px\"\n\t\t}\n\n\t\tthis.tooltipContent.style.opacity = '1'\n\n\t}\n\n\tprivate showTooltip() {\n\t\tif (this.tooltipContent) {\n\t\t\tthis.tooltipContent.style.opacity = '0'\n\t\t\tthis.tooltipContent.hidden = false\n\t\t\tthis.tooltipContent.setAttribute(\"is-visible\", \"true\")\n\t\t\ttick(() => {\n\t\t\t\tthis.verifyPositionSpace()\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate hideTooltip() {\n\t\tif (this.tooltipContent) {\n\t\t\tthis.tooltipContent.setAttribute(\"is-visible\", \"false\")\n\t\t\tthis.tooltipContent.setAttribute(\"persist\", \"false\")\n\t\t\tthis.tooltipContent.removeAttribute('style')\n\t\t}\n\t}\n\n\tprivate removeContent() {\n\t\tconst contentEl = document.getElementById(this.tooltipContentId)\n\t\tif (contentEl) {\n\t\t\tcontentEl.remove()\n\t\t}\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host\n\t\t\t\tid={this.tooltipId}\n\t\t\t\tclass={this.h.classes(TooltipClass.root)}\n\t\t\t\tposition={this.position}>\n\t\t\t\t<span role={'button'}\n\t\t\t\t\t\t\ttabindex={0}\n\t\t\t\t\t\t\tonKeyPress={() => this.showTooltip()}\n\t\t\t\t\t\t\tonBlur={() => {\n\t\t\t\t\t\t\t\tif (this.persist === false) {\n\t\t\t\t\t\t\t\t\tthis.hideTooltip()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\taria-describedby={this.identifier ?? this.tooltipContentId}><slot/></span>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\t/**\n\t * Showing the modal\n\t */\n\t@Method()\n\tasync show(): Promise<void> {\n\t\tthis.showTooltip()\n\t}\n\n\t/**\n\t * Hiding the modal\n\t */\n\t@Method()\n\tasync hide(): Promise<void> {\n\t\tthis.persist = false\n\t\tthis.hideTooltip()\n\t}\n}\n"],"mappings":"8SAsBaA,EAAUC,EAAA,MAAAD,UAAAE,EAKtB,WAAAC,G,8BAHiBC,KAAgBC,iBAAGC,UACnBF,KAASG,UAAGD,UAYZF,KAAAI,MAA2BC,EAAcC,QAIzCN,KAAAO,KAAyBC,EAAYC,GAI/BT,KAAQU,SAAwB,QA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C,KAAKC,kBAAkBa,EAAO,QAAAgF,IAAA,8C,CASzE,UAAMQ,GACLtG,KAAKkD,a,CAON,UAAMqD,GACLvG,KAAKa,QAAU,MACfb,KAAKmD,a","ignoreList":[]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{p as t,H as s,h as e,a as i}from"./index.js";import{T as o,a as n,d as c}from"./p-DfI_0WW6.js";import{t as a}from"./p-DKo9A5gq.js";import{d as l}from"./p-djqfSbq-.js";import{d as r}from"./p-BrdXh0mI.js";const d=t(class t extends s{constructor(){super();this.__registerHost();this.color=o.PRIMARY;this.size=n._M;this.persist=false;this.isVisible=false;this.parentId=null}visibleContent(t){clearTimeout(this.timeout);if(t===false){this.timeout=setTimeout((()=>{this.host.style.visibility="hidden"}),250)}else{this.host.style.visibility="visible"}}hideContent(){this.isVisible=false;this.persist=false;const t=document.getElementById(this.parentId);if(t){t.hide().catch()}}render(){return e(i,{key:"71d259cc8d7247030767f8ac36a6875f9c16ffea",class:c.root,role:"tooltip",hidden:!this.isVisible,"aria-hidden":!a(this.isVisible),"is-visible":this.isVisible},e("slot",{key:"06d883340271717da9d0b8de6c35339cd5c9dfb9"}),this.persist?e("gov-button",{"on-gov-click":this.hideContent.bind(this),color:this.color,size:this.size,type:"base"},e("gov-icon",{slot:"icon-start",name:"x-lg",type:"components"})):null)}get host(){return this}static get watchers(){return{isVisible:["visibleContent"]}}},[4,"gov-tooltip-content",{color:[1],size:[1],persist:[4],isVisible:[1028,"is-visible"],parentId:[1,"parent-id"]},undefined,{isVisible:["visibleContent"]}]);function h(){if(typeof customElements==="undefined"){return}const t=["gov-tooltip-content","gov-button","gov-icon"];t.forEach((t=>{switch(t){case"gov-tooltip-content":if(!customElements.get(t)){customElements.define(t,d)}break;case"gov-button":if(!customElements.get(t)){l()}break;case"gov-icon":if(!customElements.get(t)){r()}break}}))}h();export{d as G,h as d};
|
|
2
|
-
//# sourceMappingURL=p-UDT3DloZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["GovTooltipContent","__stencil_proxyCustomElement","HTMLElement","constructor","this","color","TooltipColors","PRIMARY","size","TooltipSize","_M","persist","isVisible","parentId","visibleContent","newValue","clearTimeout","timeout","setTimeout","host","style","visibility","hideContent","parentEl","document","getElementById","hide","catch","render","h","Host","key","class","TooltipContentClass","root","role","hidden","toBoolAttr","bind","type","slot","name"],"sources":["../../../packages/core/src/components/gov-tooltip/gov-tooltip-content.tsx"],"sourcesContent":["import { Component, Element, h, Host, Prop, Watch } from \"@stencil/core\"\nimport { TooltipContentClass, TooltipSize, TooltipSizeType, TooltipColors, TooltipColorType } from \"./constants\"\nimport { toBoolAttr } from \"../../helpers/Dom/template\"\n\n@Component({\n\ttag: \"gov-tooltip-content\",\n})\nexport class GovTooltipContent {\n\tprivate timeout\n\n\t@Element() host: HTMLGovTooltipContentElement\n\t/**\n\t * Style variation of the tooltip\n\t */\n\t@Prop() readonly color?: TooltipColorType = TooltipColors.PRIMARY\n\t/**\n\t * Tooltip’s size.\n\t */\n\t@Prop() readonly size?: TooltipSizeType = TooltipSize._M\n\t/**\n\t * Tooltip is still visible.\n\t */\n\t@Prop() persist?: boolean = false\n\t/**\n\t * Indicates display of tooltip content\n\t */\n\t@Prop({ attribute: \"is-visible\", mutable: true }) isVisible = false\n\t/**\n\t * Indicates display of tooltip content\n\t */\n\t@Prop({ attribute: \"parent-id\" }) parentId: string = null\n\n\t@Watch(\"isVisible\")\n\tvisibleContent(newValue: boolean): void {\n\t\tclearTimeout(this.timeout)\n\t\tif (newValue === false) {\n\t\t\tthis.timeout = setTimeout(() => {\n\t\t\t\tthis.host.style.visibility = \"hidden\"\n\t\t\t}, 250)\n\t\t} else {\n\t\t\tthis.host.style.visibility = \"visible\"\n\t\t}\n\t}\n\n\thideContent() {\n\t\tthis.isVisible = false\n\t\tthis.persist = false\n\t\tconst parentEl = document.getElementById(this.parentId) as HTMLGovTooltipElement\n\t\tif (parentEl) {\n\t\t\tparentEl.hide().catch()\n\t\t}\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host\n\t\t\t\tclass={TooltipContentClass.root}\n\t\t\t\trole={\"tooltip\"}\n\t\t\t\thidden={!this.isVisible}\n\t\t\t\taria-hidden={!toBoolAttr(this.isVisible)}\n\t\t\t\tis-visible={this.isVisible}>\n\t\t\t\t<slot></slot>\n\t\t\t\t{this.persist ? (\n\t\t\t\t\t<gov-button\n\t\t\t\t\t\ton-gov-click={this.hideContent.bind(this)}\n\t\t\t\t\t\tcolor={this.color}\n\t\t\t\t\t\tsize={this.size}\n\t\t\t\t\t\ttype={\"base\"}>\n\t\t\t\t\t\t<gov-icon slot={\"icon-start\"} name={\"x-lg\"} type={\"components\"}></gov-icon>\n\t\t\t\t\t</gov-button>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n}\n"],"mappings":"wNAOaA,EAAiBC,EAAA,MAAAD,UAAAE,EAH9B,WAAAC,G,8BAUkBC,KAAAC,MAA2BC,EAAcC,QAIzCH,KAAAI,KAAyBC,EAAYC,GAI9CN,KAAOO,QAAa,MAIsBP,KAASQ,UAAG,MAI5BR,KAAQS,SAAW,IA4CrD,CAzCA,cAAAC,CAAeC,GACdC,aAAaZ,KAAKa,SAClB,GAAIF,IAAa,MAAO,CACvBX,KAAKa,QAAUC,YAAW,KACzBd,KAAKe,KAAKC,MAAMC,WAAa,QAAQ,GACnC,I,KACG,CACNjB,KAAKe,KAAKC,MAAMC,WAAa,S,EAI/B,WAAAC,GACClB,KAAKQ,UAAY,MACjBR,KAAKO,QAAU,MACf,MAAMY,EAAWC,SAASC,eAAerB,KAAKS,UAC9C,GAAIU,EAAU,CACbA,EAASG,OAAOC,O,EAIlB,MAAAC,GACC,OACCC,EAACC,EAAI,CAAAC,IAAA,2CACJC,MAAOC,EAAoBC,KAC3BC,KAAM,UACNC,QAAShC,KAAKQ,UAAS,eACTyB,EAAWjC,KAAKQ,WAClB,aAAAR,KAAKQ,WACjBiB,EAAa,QAAAE,IAAA,6CACZ3B,KAAKO,QACLkB,EACe,6BAAAzB,KAAKkB,YAAYgB,KAAKlC,MACpCC,MAAOD,KAAKC,MACZG,KAAMJ,KAAKI,KACX+B,KAAM,QACNV,EAAU,YAAAW,KAAM,aAAcC,KAAM,OAAQF,KAAM,gBAEhD,K","ignoreList":[]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{p as t,H as s,c as e,h as i,a}from"./index.js";import{g as o,d as n,e as c}from"./p-9imLQpxb.js";import{g as h,t as r,c as l}from"./p-DKo9A5gq.js";import{v as d}from"./p-BKP-F1qP.js";import{c as f}from"./p-vN03FcXN.js";import{p as u}from"./p-B0hcuYXk.js";import{t as m}from"./p-Cjg0wpDG.js";import{A as p,a as v,i as b}from"./p-CXgom82_.js";import{d as g}from"./p-BrdXh0mI.js";const w=t(class t extends s{constructor(){super();this.__registerHost();this.govFocus=e(this,"gov-focus");this.govBlur=e(this,"gov-blur");this.govChange=e(this,"gov-change");this.size="m";this.required=false;this.disabled=false;this.optionsState=[];this.inheritedAttributes={};this.h=h(this.host);this.f=o(this.h);this.selectId=f("GovSelect")}validateSize(t){d(c,t,n.root)}watchOptions(t){this.optionsState=u(t)}watchControlAttrs(){this.passControlAttrs()}watchValue(){this.markSelectedValue()}passControlAttrs(){this.f.passAttrToControl("size",this.size);this.f.passAttrToControl("invalid",r(this.invalid));this.f.passAttrToControl("success",r(this.success));this.f.passAttrToControl("disabled",r(this.disabled));this.f.passAttrToControl("type","select")}componentDidLoad(){this.attributeObserver=new p(this.host,((t,s)=>{this.onAriaAttributeChange(t,s)}));this.attributeObserver.startObserving(v)}disconnectedCallback(){var t;(t=this.attributeObserver)===null||t===void 0?void 0:t.stopObserving()}componentWillLoad(){this.validateSize(this.size);this.markSelectedValue();this.optionsState=u(this.options);this.inheritedAttributes=b(this.host)}async componentDidRender(){this.passControlAttrs();this.f.passAttrToLabel("required",String(this.required));m((()=>this.markSelectedValue()))}onAriaAttributeChange(t,s){this.host.removeAttribute(t);this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[t]:s})}markSelectedValue(){this.host.querySelectorAll("option").forEach((t=>{if(t.value===this.value){t.setAttribute("selected","selected")}else{t.removeAttribute("selected")}}))}render(){return i(a,{key:"92b4679d9a9fb77628934ed90e00b1eafc593a3e",class:n.root,size:this.size},this.h.hasSlot("prefix")&&i("slot",{key:"b51835a8b6254898a064a41c75f95cc746d46d57",name:"prefix"}),i("span",{key:"2324839a4c3821a46fcdace4755961a96216dadc",class:"element"},i("select",Object.assign({key:"df1fe5989b6d427c0f48d673f951a4b1f5f8b728",id:this.identifier||this.selectId,onFocus:this.onFocusHandler.bind(this),onChange:this.onChangeHandler.bind(this),onBlur:this.onBlurHandler.bind(this),required:this.required,name:this.name,disabled:this.disabled,ref:t=>this.selectRef=t},this.inheritedAttributes,{"aria-disabled":l(this.disabled),"aria-required":l(this.required),"aria-invalid":l(this.invalid)}),i("slot",{key:"bc12463c981b174aa49a791f360d6001230c3fc4"}),Array.isArray(this.optionsState)&&this.optionsState.map((t=>{var s;return i("option",{value:t.value,selected:t.value===this.value,disabled:t===null||t===void 0?void 0:t.disabled},(s=t.label)!==null&&s!==void 0?s:t.value)}))),this.success&&i("gov-icon",{key:"def96c72b9bd804797472954d591e16d25860036",class:"validation-icon",name:"check-lg",type:"components"}),this.invalid&&i("gov-icon",{key:"e20c8d4bac094529ff51d8412ae2105401edcf98",class:"validation-icon",name:"exclamation-lg",type:"components"}),i("gov-icon",{key:"e004aae985d9de1202fb50c06f5baa4d12c19fd2",class:"arrow-icon",name:"chevron-down",type:"components"})),this.h.hasSlot("sufix")&&i("slot",{key:"72b7791037616836108a7420d13b21bf44fdeb85",name:"sufix"}))}onFocusHandler(t){this.focused=true;this.govFocus.emit({component:n.root,originalEvent:t,value:this.value})}onBlurHandler(t){this.focused=false;this.govBlur.emit({component:n.root,originalEvent:t,value:this.value})}onChangeHandler(t){this.value=t.target.value;t.stopPropagation();this.govChange.emit({component:n.root,originalEvent:t,value:this.value})}async setFocus(t){return this.selectRef.focus(t)}async getRef(){return this.selectRef}get host(){return this}static get watchers(){return{size:["validateSize","watchControlAttrs"],options:["watchOptions"],disabled:["watchControlAttrs"],invalid:["watchControlAttrs"],success:["watchControlAttrs"],value:["watchValue"]}}},[4,"gov-form-select",{value:[1537],options:[1537],identifier:[1],size:[1],name:[1],required:[4],success:[516],disabled:[516],invalid:[4],focused:[32],optionsState:[32],inheritedAttributes:[32],setFocus:[64],getRef:[64]},undefined,{size:["validateSize","watchControlAttrs"],options:["watchOptions"],disabled:["watchControlAttrs"],invalid:["watchControlAttrs"],success:["watchControlAttrs"],value:["watchValue"]}]);function y(){if(typeof customElements==="undefined"){return}const t=["gov-form-select","gov-icon"];t.forEach((t=>{switch(t){case"gov-form-select":if(!customElements.get(t)){customElements.define(t,w)}break;case"gov-icon":if(!customElements.get(t)){g()}break}}))}y();export{w as G,y as d};
|
|
2
|
-
//# sourceMappingURL=p-x3w8Mun_.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["GovFormSelect","__stencil_proxyCustomElement","HTMLElement","constructor","this","size","required","disabled","optionsState","inheritedAttributes","h","govHost","host","f","govForm","selectId","createID","validateSize","newValue","validateProp","FormSelectSizes","FormSelectClass","root","watchOptions","propsValueToArray","watchControlAttrs","passControlAttrs","watchValue","markSelectedValue","passAttrToControl","toBoolAttr","invalid","success","componentDidLoad","attributeObserver","AttributeObserver","attributeName","onAriaAttributeChange","startObserving","ariaAttributes","disconnectedCallback","_a","stopObserving","componentWillLoad","options","inheritAriaAttributes","componentDidRender","passAttrToLabel","String","tick","removeAttribute","Object","assign","querySelectorAll","forEach","option","value","setAttribute","render","Host","key","class","hasSlot","name","id","identifier","onFocus","onFocusHandler","bind","onChange","onChangeHandler","onBlur","onBlurHandler","ref","el","selectRef","toBoolAttrIfDefined","Array","isArray","map","selected","label","type","e","focused","govFocus","emit","component","originalEvent","govBlur","target","stopPropagation","govChange","setFocus","focus","getRef"],"sources":["../../../packages/core/src/components/gov-form/select/gov-form-select.tsx"],"sourcesContent":["import {Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch} from '@stencil/core'\nimport {govForm} from '../../../helpers/Dom/form'\nimport {GovForm} from '../../../helpers/Dom/form.types'\nimport {govHost, toBoolAttr, toBoolAttrIfDefined} from '../../../helpers/Dom/template'\nimport {GovHost} from '../../../helpers/Dom/template.types'\nimport {validateProp} from '../../../helpers/Validate/props'\nimport {createID} from '../../../utils/string.utils'\nimport {FormSelectClass, FormSelectSizes, FormSelectSizesType,} from './constants'\nimport {FormSelectEvent, FormSelectOption} from './gov-form-select.types'\nimport {propsValueToArray} from \"../../../utils/array.utils\";\nimport {tick} from \"../../../utils/stencil.utils\";\nimport {AttributeObserver, Attributes} from \"../../../helpers/Dom/attribute\";\nimport {ariaAttributes} from \"../../../helpers/Accessibility/attributes\";\nimport {inheritAriaAttributes} from \"../../../helpers/Accessibility/accessibility\";\n\n@Component({\n\ttag: 'gov-form-select',\n})\nexport class GovFormSelect {\n\tprivate f: GovForm\n\tprivate readonly h: GovHost\n\tprivate selectRef?: HTMLSelectElement\n\tprivate attributeObserver: AttributeObserver\n\n\tprivate readonly selectId: string\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t\tthis.selectId = createID('GovSelect')\n\t}\n\n\t@Element() host: HTMLGovFormSelectElement\n\t/**\n\t * Value of select\n\t */\n\t@Prop({reflect: true, mutable: true}) value: string\n\t/**\n\t * Options of select\n\t */\n\t@Prop({reflect: true, mutable: true}) options?: string | FormSelectOption[]\n\t/**\n\t * Custom select identifier.\n\t */\n\t@Prop({attribute: 'identifier'}) readonly identifier: string\n\t/**\n\t * Select’s size.\n\t */\n\t@Prop() readonly size?: FormSelectSizesType = 'm'\n\t/**\n\t * Name of the select.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Indicates the entered value of child form element does conform to the format expected by the application.\n\t */\n\t@Prop({reflect: true}) readonly success: boolean\n\t/**\n\t * Makes the select component disabled.\n\t * This prevents users from being able to interact with the select, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop({reflect: true}) readonly disabled: boolean = false\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Emitted when the select has focus.\n\t */\n\t@Event({eventName: 'gov-focus'}) govFocus: EventEmitter<FormSelectEvent>\n\t/**\n\t * Emitted when the select loses focus.\n\t */\n\t@Event({eventName: 'gov-blur'}) govBlur: EventEmitter<FormSelectEvent>\n\t/**\n\t * Emitted when the select change value.\n\t */\n\t@Event({eventName: 'gov-change'}) govChange: EventEmitter<FormSelectEvent>\n\t@State() focused: boolean\n\t@State() optionsState: FormSelectOption[] = []\n\n\t@Watch('size')\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormSelectSizes, newValue, FormSelectClass.root)\n\t}\n\n\t@Watch('options')\n\twatchOptions(newValue: string | FormSelectOption[]): void {\n\t\tthis.optionsState = propsValueToArray(newValue)\n\t}\n\n\t@Watch('disabled')\n\t@Watch('invalid')\n\t@Watch('success')\n\t@Watch('size')\n\twatchControlAttrs(): void {\n\t\tthis.passControlAttrs()\n\t}\n\n\t@Watch('value')\n\twatchValue(): void {\n\t\tthis.markSelectedValue()\n\t}\n\n\t@State() inheritedAttributes: Attributes = {}\n\n\tprivate passControlAttrs() {\n\t\tthis.f.passAttrToControl('size', this.size)\n\t\tthis.f.passAttrToControl('invalid', toBoolAttr(this.invalid))\n\t\tthis.f.passAttrToControl('success', toBoolAttr(this.success))\n\t\tthis.f.passAttrToControl('disabled', toBoolAttr(this.disabled))\n\t\tthis.f.passAttrToControl('type', 'select')\n\t}\n\n\tcomponentDidLoad() {\n\t\tthis.attributeObserver = new AttributeObserver(this.host, (attributeName, newValue) => {\n\t\t\tthis.onAriaAttributeChange(attributeName, newValue);\n\t\t});\n\n\t\tthis.attributeObserver.startObserving(ariaAttributes);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.attributeObserver?.stopObserving();\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateSize(this.size)\n\n\t\tthis.markSelectedValue()\n\n\t\tthis.optionsState = propsValueToArray(this.options)\n\t\tthis.inheritedAttributes = inheritAriaAttributes(this.host);\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.passControlAttrs()\n\t\tthis.f.passAttrToLabel('required', String(this.required))\n\t\ttick(() => this.markSelectedValue())\n\t}\n\n\tonAriaAttributeChange(attributeName: string, newValue: string) {\n\t\tthis.host.removeAttribute(attributeName)\n\t\tthis.inheritedAttributes = {...this.inheritedAttributes, [attributeName]: newValue};\n\t}\n\n\tprivate markSelectedValue() {\n\t\tthis.host.querySelectorAll('option').forEach((option: HTMLOptionElement) => {\n\t\t\tif (option.value === this.value) {\n\t\t\t\toption.setAttribute('selected', 'selected')\n\t\t\t} else {\n\t\t\t\toption.removeAttribute('selected')\n\t\t\t}\n\t\t})\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={FormSelectClass.root} size={this.size}>\n\t\t\t\t{this.h.hasSlot('prefix') && <slot name=\"prefix\"></slot>}\n\t\t\t\t<span class=\"element\">\n\t\t\t\t\t<select\n\t\t\t\t\t\tid={this.identifier || this.selectId}\n\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\tref={el => (this.selectRef = el as HTMLSelectElement)}\n\t\t\t\t\t\t{...this.inheritedAttributes}\n\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t>\n\t\t\t\t\t\t<slot />\n\t\t\t\t\t\t{Array.isArray(this.optionsState) && this.optionsState.map((option) => {\n\t\t\t\t\t\t\treturn (<option value={option.value} selected={option.value === this.value}\n\t\t\t\t\t\t\t\t\t\t\tdisabled={option?.disabled}>{option.label ?? option.value}</option>)\n\t\t\t\t\t\t})}\n\t\t\t\t\t</select>\n\t\t\t\t\t{this.success && <gov-icon class=\"validation-icon\" name=\"check-lg\" type=\"components\"></gov-icon>}\n\t\t\t\t\t{this.invalid && <gov-icon class=\"validation-icon\" name=\"exclamation-lg\" type=\"components\"></gov-icon>}\n\t\t\t\t\t<gov-icon class=\"arrow-icon\" name=\"chevron-down\" type=\"components\"></gov-icon>\n\t\t\t\t</span>\n\t\t\t\t{this.h.hasSlot('sufix') && <slot name=\"sufix\"></slot>}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\tthis.focused = true\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormSelectClass.root,\n\t\t\toriginalEvent: e,\n\t\t\tvalue: this.value,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\tthis.focused = false\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormSelectClass.root,\n\t\t\toriginalEvent: e,\n\t\t\tvalue: this.value,\n\t\t})\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\tthis.value = (e.target as HTMLSelectElement).value\n\t\te.stopPropagation()\n\t\tthis.govChange.emit({\n\t\t\tcomponent: FormSelectClass.root,\n\t\t\toriginalEvent: e,\n\t\t\tvalue: this.value,\n\t\t})\n\t}\n\n\t/**\n\t * Returns the current state of the component\n\t */\n\t@Method()\n\tasync setFocus(options?: FocusOptions): Promise<void> {\n\t\treturn this.selectRef.focus(options)\n\t}\n\n\t/**\n\t * Returns an instance of the native html select element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLSelectElement> {\n\t\treturn this.selectRef\n\t}\n}\n"],"mappings":"sYAkBaA,EAAaC,EAAA,MAAAD,UAAAE,EAQzB,WAAAC,G,oIAsBiBC,KAAIC,KAAyB,IAS7BD,KAAQE,SAAY,MASLF,KAAQG,SAAY,MAkB3CH,KAAYI,aAAuB,GAyBnCJ,KAAmBK,oBAAe,GAlF1CL,KAAKM,EAAIC,EAAQP,KAAKQ,MACtBR,KAAKS,EAAIC,EAAQV,KAAKM,GACtBN,KAAKW,SAAWC,EAAS,YACzB,CAyDD,YAAAC,CAAaC,GACZC,EAAaC,EAAiBF,EAAUG,EAAgBC,K,CAIzD,YAAAC,CAAaL,GACZd,KAAKI,aAAegB,EAAkBN,E,CAOvC,iBAAAO,GACCrB,KAAKsB,kB,CAIN,UAAAC,GACCvB,KAAKwB,mB,CAKE,gBAAAF,GACPtB,KAAKS,EAAEgB,kBAAkB,OAAQzB,KAAKC,MACtCD,KAAKS,EAAEgB,kBAAkB,UAAWC,EAAW1B,KAAK2B,UACpD3B,KAAKS,EAAEgB,kBAAkB,UAAWC,EAAW1B,KAAK4B,UACpD5B,KAAKS,EAAEgB,kBAAkB,WAAYC,EAAW1B,KAAKG,WACrDH,KAAKS,EAAEgB,kBAAkB,OAAQ,S,CAGlC,gBAAAI,GACC7B,KAAK8B,kBAAoB,IAAIC,EAAkB/B,KAAKQ,MAAM,CAACwB,EAAelB,KACzEd,KAAKiC,sBAAsBD,EAAelB,EAAS,IAGpDd,KAAK8B,kBAAkBI,eAAeC,E,CAGvC,oBAAAC,G,OACCC,EAAArC,KAAK8B,qBAAmB,MAAAO,SAAA,SAAAA,EAAAC,e,CAGzB,iBAAAC,GACCvC,KAAKa,aAAab,KAAKC,MAEvBD,KAAKwB,oBAELxB,KAAKI,aAAegB,EAAkBpB,KAAKwC,SAC3CxC,KAAKK,oBAAsBoC,EA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cY_.js";import{g as c,a as n,t as l}from"./p-CoD1xawt.js";import{v as d}from"./p-NOJjz9dT.js";import{c as p}from"./p-vN03FcXN.js";import{p as m}from"./p-Ccwpa1ck.js";import{t as f}from"./p-Cjg0wpDG.js";import{A as v,a as u}from"./p-Bz_RzYFb.js";import{i as b}from"./p-CzXeijOj.js";import"./p-BcQO4NH2.js";import"./p-CQvUntGY.js";import"./p-EeKNA85D.js";import"./p-U40vKHrs.js";import"./p-DYcNEwSZ.js";import"./p-DBXGhafv.js";import"./p-CgDnDrq5.js";import"./p-DNztiAH0.js";const g=class{constructor(i){t(this,i);this.govFocus=s(this,"gov-focus");this.govBlur=s(this,"gov-blur");this.govChange=s(this,"gov-change");this.size="m";this.required=false;this.disabled=false;this.optionsState=[];this.inheritedAttributes={};this.h=c(this.host);this.f=o(this.h);this.selectId=p("GovSelect")}validateSize(t){d(r,t,h.root)}watchOptions(t){this.optionsState=m(t)}watchControlAttrs(){this.passControlAttrs()}watchValue(){this.markSelectedValue()}passControlAttrs(){this.f.passAttrToControl("size",this.size);this.f.passAttrToControl("invalid",n(this.invalid));this.f.passAttrToControl("success",n(this.success));this.f.passAttrToControl("disabled",n(this.disabled));this.f.passAttrToControl("type","select")}componentDidLoad(){this.attributeObserver=new v(this.host,((t,s)=>{this.onAriaAttributeChange(t,s)}));this.attributeObserver.startObserving(u)}disconnectedCallback(){var t;(t=this.attributeObserver)===null||t===void 0?void 0:t.stopObserving()}componentWillLoad(){this.validateSize(this.size);this.markSelectedValue();this.optionsState=m(this.options);this.inheritedAttributes=b(this.host)}async componentDidRender(){this.passControlAttrs();this.f.passAttrToLabel("required",String(this.required));f((()=>this.markSelectedValue()))}onAriaAttributeChange(t,s){this.host.removeAttribute(t);this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[t]:s})}markSelectedValue(){this.host.querySelectorAll("option").forEach((t=>{if(t.value===this.value){t.setAttribute("selected","selected")}else{t.removeAttribute("selected")}}))}render(){return i(e,{key:"92b4679d9a9fb77628934ed90e00b1eafc593a3e",class:h.root,size:this.size},this.h.hasSlot("prefix")&&i("slot",{key:"b51835a8b6254898a064a41c75f95cc746d46d57",name:"prefix"}),i("span",{key:"2324839a4c3821a46fcdace4755961a96216dadc",class:"element"},i("select",Object.assign({key:"df1fe5989b6d427c0f48d673f951a4b1f5f8b728",id:this.identifier||this.selectId,onFocus:this.onFocusHandler.bind(this),onChange:this.onChangeHandler.bind(this),onBlur:this.onBlurHandler.bind(this),required:this.required,name:this.name,disabled:this.disabled,ref:t=>this.selectRef=t},this.inheritedAttributes,{"aria-disabled":l(this.disabled),"aria-required":l(this.required),"aria-invalid":l(this.invalid)}),i("slot",{key:"bc12463c981b174aa49a791f360d6001230c3fc4"}),Array.isArray(this.optionsState)&&this.optionsState.map((t=>{var s;return i("option",{value:t.value,selected:t.value===this.value,disabled:t===null||t===void 0?void 0:t.disabled},(s=t.label)!==null&&s!==void 0?s:t.value)}))),this.success&&i("gov-icon",{key:"def96c72b9bd804797472954d591e16d25860036",class:"validation-icon",name:"check-lg",type:"components"}),this.invalid&&i("gov-icon",{key:"e20c8d4bac094529ff51d8412ae2105401edcf98",class:"validation-icon",name:"exclamation-lg",type:"components"}),i("gov-icon",{key:"e004aae985d9de1202fb50c06f5baa4d12c19fd2",class:"arrow-icon",name:"chevron-down",type:"components"})),this.h.hasSlot("sufix")&&i("slot",{key:"72b7791037616836108a7420d13b21bf44fdeb85",name:"sufix"}))}onFocusHandler(t){this.focused=true;this.govFocus.emit({component:h.root,originalEvent:t,value:this.value})}onBlurHandler(t){this.focused=false;this.govBlur.emit({component:h.root,originalEvent:t,value:this.value})}onChangeHandler(t){this.value=t.target.value;t.stopPropagation();this.govChange.emit({component:h.root,originalEvent:t,value:this.value})}async setFocus(t){return this.selectRef.focus(t)}async getRef(){return this.selectRef}get host(){return a(this)}static get watchers(){return{size:["validateSize","watchControlAttrs"],options:["watchOptions"],disabled:["watchControlAttrs"],invalid:["watchControlAttrs"],success:["watchControlAttrs"],value:["watchValue"]}}};export{g as gov_form_select};
|
|
2
|
-
//# sourceMappingURL=p-11fc3899.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["GovFormSelect","constructor","hostRef","this","size","required","disabled","optionsState","inheritedAttributes","h","govHost","host","f","govForm","selectId","createID","validateSize","newValue","validateProp","FormSelectSizes","FormSelectClass","root","watchOptions","propsValueToArray","watchControlAttrs","passControlAttrs","watchValue","markSelectedValue","passAttrToControl","toBoolAttr","invalid","success","componentDidLoad","attributeObserver","AttributeObserver","attributeName","onAriaAttributeChange","startObserving","ariaAttributes","disconnectedCallback","_a","stopObserving","componentWillLoad","options","inheritAriaAttributes","componentDidRender","passAttrToLabel","String","tick","removeAttribute","Object","assign","querySelectorAll","forEach","option","value","setAttribute","render","Host","key","class","hasSlot","name","id","identifier","onFocus","onFocusHandler","bind","onChange","onChangeHandler","onBlur","onBlurHandler","ref","el","selectRef","toBoolAttrIfDefined","Array","isArray","map","selected","label","type","e","focused","govFocus","emit","component","originalEvent","govBlur","target","stopPropagation","govChange","setFocus","focus","getRef"],"sources":["../../../packages/core/src/components/gov-form/select/gov-form-select.tsx"],"sourcesContent":["import {Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch} from '@stencil/core'\nimport {govForm} from '../../../helpers/Dom/form'\nimport {GovForm} from '../../../helpers/Dom/form.types'\nimport {govHost, toBoolAttr, toBoolAttrIfDefined} from '../../../helpers/Dom/template'\nimport {GovHost} from '../../../helpers/Dom/template.types'\nimport {validateProp} from '../../../helpers/Validate/props'\nimport {createID} from '../../../utils/string.utils'\nimport {FormSelectClass, FormSelectSizes, FormSelectSizesType,} from './constants'\nimport {FormSelectEvent, FormSelectOption} from './gov-form-select.types'\nimport {propsValueToArray} from \"../../../utils/array.utils\";\nimport {tick} from \"../../../utils/stencil.utils\";\nimport {AttributeObserver, Attributes} from \"../../../helpers/Dom/attribute\";\nimport {ariaAttributes} from \"../../../helpers/Accessibility/attributes\";\nimport {inheritAriaAttributes} from \"../../../helpers/Accessibility/accessibility\";\n\n@Component({\n\ttag: 'gov-form-select',\n})\nexport class GovFormSelect {\n\tprivate f: GovForm\n\tprivate readonly h: GovHost\n\tprivate selectRef?: HTMLSelectElement\n\tprivate attributeObserver: AttributeObserver\n\n\tprivate readonly selectId: string\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t\tthis.selectId = createID('GovSelect')\n\t}\n\n\t@Element() host: HTMLGovFormSelectElement\n\t/**\n\t * Value of select\n\t */\n\t@Prop({reflect: true, mutable: true}) value: string\n\t/**\n\t * Options of select\n\t */\n\t@Prop({reflect: true, mutable: true}) options?: string | FormSelectOption[]\n\t/**\n\t * Custom select identifier.\n\t */\n\t@Prop({attribute: 'identifier'}) readonly identifier: string\n\t/**\n\t * Select’s size.\n\t */\n\t@Prop() readonly size?: FormSelectSizesType = 'm'\n\t/**\n\t * Name of the select.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Indicates the entered value of child form element does conform to the format expected by the application.\n\t */\n\t@Prop({reflect: true}) readonly success: boolean\n\t/**\n\t * Makes the select component disabled.\n\t * This prevents users from being able to interact with the select, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop({reflect: true}) readonly disabled: boolean = false\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Emitted when the select has focus.\n\t */\n\t@Event({eventName: 'gov-focus'}) govFocus: EventEmitter<FormSelectEvent>\n\t/**\n\t * Emitted when the select loses focus.\n\t */\n\t@Event({eventName: 'gov-blur'}) govBlur: EventEmitter<FormSelectEvent>\n\t/**\n\t * Emitted when the select change value.\n\t */\n\t@Event({eventName: 'gov-change'}) govChange: EventEmitter<FormSelectEvent>\n\t@State() focused: boolean\n\t@State() optionsState: FormSelectOption[] = []\n\n\t@Watch('size')\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormSelectSizes, newValue, FormSelectClass.root)\n\t}\n\n\t@Watch('options')\n\twatchOptions(newValue: string | FormSelectOption[]): void {\n\t\tthis.optionsState = propsValueToArray(newValue)\n\t}\n\n\t@Watch('disabled')\n\t@Watch('invalid')\n\t@Watch('success')\n\t@Watch('size')\n\twatchControlAttrs(): void {\n\t\tthis.passControlAttrs()\n\t}\n\n\t@Watch('value')\n\twatchValue(): void {\n\t\tthis.markSelectedValue()\n\t}\n\n\t@State() inheritedAttributes: Attributes = {}\n\n\tprivate passControlAttrs() {\n\t\tthis.f.passAttrToControl('size', this.size)\n\t\tthis.f.passAttrToControl('invalid', toBoolAttr(this.invalid))\n\t\tthis.f.passAttrToControl('success', toBoolAttr(this.success))\n\t\tthis.f.passAttrToControl('disabled', toBoolAttr(this.disabled))\n\t\tthis.f.passAttrToControl('type', 'select')\n\t}\n\n\tcomponentDidLoad() {\n\t\tthis.attributeObserver = new AttributeObserver(this.host, (attributeName, newValue) => {\n\t\t\tthis.onAriaAttributeChange(attributeName, newValue);\n\t\t});\n\n\t\tthis.attributeObserver.startObserving(ariaAttributes);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.attributeObserver?.stopObserving();\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateSize(this.size)\n\n\t\tthis.markSelectedValue()\n\n\t\tthis.optionsState = propsValueToArray(this.options)\n\t\tthis.inheritedAttributes = inheritAriaAttributes(this.host);\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.passControlAttrs()\n\t\tthis.f.passAttrToLabel('required', String(this.required))\n\t\ttick(() => this.markSelectedValue())\n\t}\n\n\tonAriaAttributeChange(attributeName: string, newValue: string) {\n\t\tthis.host.removeAttribute(attributeName)\n\t\tthis.inheritedAttributes = {...this.inheritedAttributes, [attributeName]: newValue};\n\t}\n\n\tprivate markSelectedValue() {\n\t\tthis.host.querySelectorAll('option').forEach((option: HTMLOptionElement) => {\n\t\t\tif (option.value === this.value) {\n\t\t\t\toption.setAttribute('selected', 'selected')\n\t\t\t} else {\n\t\t\t\toption.removeAttribute('selected')\n\t\t\t}\n\t\t})\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={FormSelectClass.root} size={this.size}>\n\t\t\t\t{this.h.hasSlot('prefix') && <slot name=\"prefix\"></slot>}\n\t\t\t\t<span class=\"element\">\n\t\t\t\t\t<select\n\t\t\t\t\t\tid={this.identifier || this.selectId}\n\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\tref={el => (this.selectRef = el as HTMLSelectElement)}\n\t\t\t\t\t\t{...this.inheritedAttributes}\n\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t>\n\t\t\t\t\t\t<slot />\n\t\t\t\t\t\t{Array.isArray(this.optionsState) && this.optionsState.map((option) => {\n\t\t\t\t\t\t\treturn (<option value={option.value} selected={option.value === this.value}\n\t\t\t\t\t\t\t\t\t\t\tdisabled={option?.disabled}>{option.label ?? option.value}</option>)\n\t\t\t\t\t\t})}\n\t\t\t\t\t</select>\n\t\t\t\t\t{this.success && <gov-icon class=\"validation-icon\" name=\"check-lg\" type=\"components\"></gov-icon>}\n\t\t\t\t\t{this.invalid && <gov-icon class=\"validation-icon\" name=\"exclamation-lg\" type=\"components\"></gov-icon>}\n\t\t\t\t\t<gov-icon class=\"arrow-icon\" name=\"chevron-down\" type=\"components\"></gov-icon>\n\t\t\t\t</span>\n\t\t\t\t{this.h.hasSlot('sufix') && <slot name=\"sufix\"></slot>}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\tthis.focused = true\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormSelectClass.root,\n\t\t\toriginalEvent: e,\n\t\t\tvalue: this.value,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\tthis.focused = false\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormSelectClass.root,\n\t\t\toriginalEvent: e,\n\t\t\tvalue: this.value,\n\t\t})\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\tthis.value = (e.target as HTMLSelectElement).value\n\t\te.stopPropagation()\n\t\tthis.govChange.emit({\n\t\t\tcomponent: FormSelectClass.root,\n\t\t\toriginalEvent: e,\n\t\t\tvalue: this.value,\n\t\t})\n\t}\n\n\t/**\n\t * Returns the current state of the component\n\t */\n\t@Method()\n\tasync setFocus(options?: FocusOptions): Promise<void> {\n\t\treturn this.selectRef.focus(options)\n\t}\n\n\t/**\n\t * Returns an instance of the native html select element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLSelectElement> {\n\t\treturn this.selectRef\n\t}\n}\n"],"mappings":"ykBAkBaA,EAAa,MAQzB,WAAAC,CAAAC,G,gHAsBiBC,KAAIC,KAAyB,IAS7BD,KAAQE,SAAY,MASLF,KAAQG,SAAY,MAkB3CH,KAAYI,aAAuB,GAyBnCJ,KAAmBK,oBAAe,GAlF1CL,KAAKM,EAAIC,EAAQP,KAAKQ,MACtBR,KAAKS,EAAIC,EAAQV,KAAKM,GACtBN,KAAKW,SAAWC,EAAS,YACzB,CAyDD,YAAAC,CAAaC,GACZC,EAAaC,EAAiBF,EAAUG,EAAgBC,K,CAIzD,YAAAC,CAAaL,GACZd,KAAKI,aAAegB,EAAkBN,E,CAOvC,iBAAAO,GACCrB,KAAKsB,kB,CAIN,UAA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tB/E,KAAKgF,QAAU,KACfhF,KAAKiF,SAASC,KAAK,CAClBC,UAAWlE,EAAgBC,KAC3BkE,cAAeL,EACf3B,MAAOpD,KAAKoD,O,CAIN,aAAAgB,CAAcW,GACrB/E,KAAKgF,QAAU,MACfhF,KAAKqF,QAAQH,KAAK,CACjBC,UAAWlE,EAAgBC,KAC3BkE,cAAeL,EACf3B,MAAOpD,KAAKoD,O,CAIN,eAAAc,CAAgBa,GACvB/E,KAAKoD,MAAS2B,EAAEO,OAA6BlC,MAC7C2B,EAAEQ,kBACFvF,KAAKwF,UAAUN,KAAK,CACnBC,UAAWlE,EAAgBC,KAC3BkE,cAAeL,EACf3B,MAAOpD,KAAKoD,O,CAQd,cAAMqC,CAASjD,GACd,OAAOxC,KAAKuE,UAAUmB,MAAMlD,E,CAO7B,YAAMmD,GACL,OAAO3F,KAAKuE,S","ignoreList":[]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as s,c as t,h as i,H as e,g as h}from"./p-ClISz4NF.js";import{a,b as o}from"./p-CoD1xawt.js";import{v as n}from"./p-NOJjz9dT.js";import{c as l}from"./p-vN03FcXN.js";import{d as r,t as c,h as f}from"./p-CQvUntGY.js";import{F as p,a as d}from"./p-DYcNEwSZ.js";import{p as u}from"./p-Ccwpa1ck.js";import{A as m,a as v}from"./p-Bz_RzYFb.js";import{i as g}from"./p-CzXeijOj.js";import"./p-CgDnDrq5.js";import"./p-BcQO4NH2.js";import"./p-DNztiAH0.js";const b=class{constructor(i){s(this,i);this.govFocus=t(this,"gov-focus");this.govBlur=t(this,"gov-blur");this.govInput=t(this,"gov-input");this.govSelect=t(this,"gov-select");this.templateResolver=s=>s[this.nameKey];this.value="";this.size="m";this.nameKey="name";this.required=false;this.disabled=false;this.minlength=3;this.throttleTime=200;this.messageEmpty="Nebyly nalezeny žádné výsledky";this.processing=false;this.arrowCounter=-1;this.list=[];this.inheritedAttributes={};this.listBoxId=l("GovListBox")}validateSize(s){n(d,s,p.root)}watchOptions(s){this.setOptions(u(s)).catch()}onArrowUp(){if(this.arrowCounter>0){this.arrowCounter=this.arrowCounter-1;this.moveToView().finally()}}onArrowDown(){if(this.arrowCounter<this.list.length-1){this.arrowCounter=this.arrowCounter+1;this.moveToView().finally()}}async moveToView(){await r(200);const s=this.listRef.offsetHeight;const t=this.listRef.querySelector('li[aria-selected="true"]');if(t&&s){const s=t.offsetTop;this.listRef.scrollTo({top:s,behavior:"smooth"})}}doSearch(){if(Number.isInteger(this.minlength)&&this.isValueAccepted===false&&this.minlength){this.list=[];this.arrowCounter=-1;this.processing=false;return}if(this.searchCallback){this.processing=true;this.searchCallback(this.value).then((s=>this.list=s)).catch((()=>this.list=[])).finally((()=>{this.arrowCounter=-1;this.processing=false}))}}clearList(){const s=u(this.options);if(s.length===0){this.list=[]}}get isValueAccepted(){if(typeof this.value==="string"){return this.value.length>=this.minlength}else{return false}}componentDidLoad(){this.attributeObserver=new m(this.host,((s,t)=>{this.onAriaAttributeChange(s,t)}));this.attributeObserver.startObserving(v)}componentWillLoad(){this.validateSize(this.size);this.inheritedAttributes=g(this.host)}disconnectedCallback(){var s;(s=this.attributeObserver)===null||s===void 0?void 0:s.stopObserving()}onAriaAttributeChange(s,t){this.host.removeAttribute(s);this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[s]:t})}render(){return i(e,{key:"531610863e3752a4e07f0b6c3b946c475a6420c6",class:p.root,size:this.size},i("gov-form-input",Object.assign({key:"82f74fc8139c85cddb4e206c5d82286107135fff",placeholder:this.placeholder,name:this.name,disabled:this.disabled,readonly:this.readonly,autocomplete:false,size:this.size,required:this.required,invalid:this.invalid,success:this.success,role:"searchbox",value:this.value,minlength:this.minlength,maxlength:this.maxlength,"on-gov-input":c(this.onInputHandler.bind(this),this.throttleTime),"on-gov-keyup":this.onKeyUpHandler.bind(this),"on-gov-keydown":this.onKeyDownHandler.bind(this),"on-gov-focus":this.onFocusHandler.bind(this),"on-gov-blur":this.onBlurHandler.bind(this)},this.inheritedAttributes,{"aria-autocomplete":"list","aria-owns":[this.listBoxId,this.inheritedAttributes["aria-owns"]].join(" "),"aria-expanded":o(this.list.length&&this.focused?true:false),ref:s=>this.inputRef=s}),i("slot",{key:"d27f897ff5c405adc14640a7e8508319df7b5ff9",name:"validation-icon"}),i("slot",{key:"da5ec2879f9c6ba7c57a68cc2515539016a6ec43",name:"icon-end"})),i("ul",{key:"cbb3514f12fe3c506d7bcf2c3aa86b78303ac398",class:p.list,role:"listbox","aria-hidden":a(!this.focused),hidden:!this.focused,id:this.listBoxId,ref:s=>this.listRef=s},this.focused&&this.list.length===0&&this.processing===false&&this.isValueAccepted&&this.messageEmpty?i("li",{class:p.empty},this.messageEmpty):null,this.focused&&this.processing===true&&this.isValueAccepted?i("li",{class:p.loading},i("gov-skeleton",{size:"m"})):null,this.focused?this.list.map(((s,t)=>{const e=this.arrowCounter===t;return i("li",{class:p.item,innerHTML:this.templateResolver(s,e),role:"option","aria-posinset":t,tabindex:e?0:-1,"aria-setsize":this.list.length,onTouchStart:s=>this.onSelectHandler(s,t),onMouseDown:s=>this.onSelectHandler(s,t),"aria-selected":a(e)},i("slot",{name:"list-item-left"}),i("slot",{name:"list-item-right"}))})):null))}onFocusHandler(s){this.focused=true;this.arrowCounter=-1;if(this.isValueAccepted&&this.searchCallback){this.doSearch()}s.stopPropagation();this.govFocus.emit({originalEvent:s,component:p.root,value:this.value,selected:null})}onBlurHandler(s){this.focused=false;this.clearList();this.arrowCounter=-1;s.stopPropagation();this.govBlur.emit({originalEvent:s,component:p.root,value:this.value,selected:null})}onInputHandler(s){this.value=s.target.value;s.stopPropagation();this.govInput.emit({originalEvent:s,component:p.root,value:this.value,selected:null});this.doSearch()}onSelectHandler(s,t=-1){let i=null;if(t>-1){i=this.list[t]}else if(f(this.arrowCounter,this.list)){i=this.list[this.arrowCounter]}if(i){this.govSelect.emit({component:p.root,value:this.value,selected:i,originalEvent:s});this.clearList();if(f(this.nameKey,i)&&typeof i[this.nameKey]==="string"){this.value=i[this.nameKey]}}}onKeyUpHandler(s){const t=s.detail.originalEvent;s.stopPropagation();t.stopPropagation();if(t.keyCode===38)this.onArrowUp();else if(t.keyCode===40)this.onArrowDown();else if(t.keyCode===13){s.preventDefault();t.preventDefault();this.onSelectHandler(s)}}onKeyDownHandler(s){const t=s.detail.originalEvent;s.stopPropagation();t.stopPropagation();if(t.keyCode===13){s.preventDefault();t.preventDefault()}}async setFocus(s){return this.inputRef.focus(s)}async setBlur(){return this.inputRef.blur()}async setOptions(s){this.list=Array.isArray(s)?s:[];this.arrowCounter=-1}async clearValue(){this.value="";this.inputRef.value="";await this.inputRef.clearValue()}async setProcessing(s){this.processing=s}async setSearchCallback(s){this.searchCallback=s}async setTemplateResolver(s){this.templateResolver=s}get host(){return h(this)}static get watchers(){return{size:["validateSize"],options:["watchOptions"]}}};export{b as gov_form_autocomplete};
|
|
2
|
-
//# sourceMappingURL=p-33b462c9.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["GovFormAutocomplete","constructor","hostRef","this","templateResolver","item","nameKey","value","size","required","disabled","minlength","throttleTime","messageEmpty","processing","arrowCounter","list","inheritedAttributes","listBoxId","createID","validateSize","newValue","validateProp","FormAutocompleteSizes","FormAutocompleteClass","root","watchOptions","setOptions","propsValueToArray","catch","onArrowUp","moveToView","finally","onArrowDown","length","delay","heightOfList","listRef","offsetHeight","selected","querySelector","offsetTop","scrollTo","top","behavior","doSearch","Number","isInteger","isValueAccepted","searchCallback","then","response","clearList","areOptions","options","componentDidLoad","attributeObserver","AttributeObserver","host","attributeName","onAriaAttributeChange","startObserving","ariaAttributes","componentWillLoad","inheritAriaAttributes","disconnectedCallback","_a","stopObserving","removeAttribute","Object","assign","render","h","Host","key","class","placeholder","name","readonly","autocomplete","invalid","success","role","maxlength","throttle","onInputHandler","bind","onKeyUpHandler","onKeyDownHandler","onFocusHandler","onBlurHandler","join","booleanString","focused","ref","el","inputRef","toBoolAttr","hidden","id","empty","loading","map","index","isSelected","innerHTML","tabindex","onTouchStart","e","onSelectHandler","onMouseDown","stopPropagation","govFocus","emit","originalEvent","component","govBlur","target","govInput","has","govSelect","event","detail","keyCode","preventDefault","setFocus","focus","setBlur","blur","Array","isArray","clearValue","setProcessing","status","setSearchCallback","callback","setTemplateResolver"],"sources":["../../../packages/core/src/components/gov-form/autocomplete/gov-form-autocomplete.tsx"],"sourcesContent":["import {Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch} from '@stencil/core'\nimport {booleanString, toBoolAttr} from '../../../helpers/Dom/template'\nimport {validateProp} from '../../../helpers/Validate/props'\nimport {Nullable} from '../../../types/interfaces'\nimport {createID} from '../../../utils/string.utils'\nimport {delay, has, throttle} from '../../../utils/utils'\nimport {FormInputEvent} from '../input/gov-form-input.types'\nimport {FormAutocompleteClass, FormAutocompleteSizes, SizesType,} from './constants'\nimport {FormAutocompleteEvent, GovFormAutocompleteItem} from './gov-form-autocomplete.types'\nimport {propsValueToArray} from \"../../../utils/array.utils\";\nimport {AttributeObserver, Attributes} from \"../../../helpers/Dom/attribute\";\nimport {ariaAttributes} from \"../../../helpers/Accessibility/attributes\";\nimport {inheritAriaAttributes} from \"../../../helpers/Accessibility/accessibility\";\n\n@Component({\n\ttag: 'gov-form-autocomplete',\n})\nexport class GovFormAutocomplete {\n\tprivate inputRef?: HTMLGovFormInputElement\n\tprivate listRef?: HTMLUListElement\n\tprivate readonly listBoxId: string\n\tprivate searchCallback: (value: string) => Promise<GovFormAutocompleteItem[]>\n\tprivate templateResolver: (item: GovFormAutocompleteItem, selected: boolean) => string = item => item[this.nameKey]\n\tprivate attributeObserver: AttributeObserver\n\n\tconstructor() {\n\t\tthis.listBoxId = createID('GovListBox')\n\t}\n\n\t@Element() host: HTMLGovFormInputElement\n\t/**\n\t * Value of input\n\t */\n\t@Prop({reflect: true, mutable: true}) value = ''\n\t/**\n\t * Options of autocomplete\n\t */\n\t@Prop({reflect: true, mutable: true}) options?: string | GovFormAutocompleteItem[]\n\t/**\n\t * Custom input identifier.\n\t */\n\t@Prop({attribute: 'identifier'}) readonly identifier: string\n\t/**\n\t * Indicates the entered value of child form element does conform to the format expected by the application.\n\t */\n\t@Prop() readonly success: boolean\n\t/**\n\t * Input’s size.\n\t */\n\t@Prop() readonly size?: SizesType = 'm'\n\t/**\n\t * Main key name in the object\n\t */\n\t@Prop({attribute: 'name-key'}) readonly nameKey: string = 'name'\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the input component disabled.\n\t * This prevents users from being able to interact with the select, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop({reflect: true}) readonly disabled: boolean = false\n\t/**\n\t * Text that appears in the form control when it has no value set\n\t */\n\t@Prop() readonly placeholder: string\n\t/**\n\t * The value is not editable\n\t */\n\t@Prop() readonly readonly: boolean\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Minimum length (number of characters) of value\n\t */\n\t@Prop() readonly minlength: number = 3\n\t/**\n\t * Maximum length (number of characters) of value\n\t */\n\t@Prop() readonly maxlength: number\n\t/**\n\t * Input throttle in milliseconds\n\t */\n\t@Prop() readonly throttleTime: number = 200\n\t/**\n\t * Custom message for when there is a blank sheet\n\t */\n\t@Prop({attribute: 'message-empty'}) readonly messageEmpty: string = 'Nebyly nalezeny žádné výsledky'\n\t/**\n\t * Emitted when the input has focus.\n\t */\n\t@Event({eventName: 'gov-focus'}) govFocus: EventEmitter<FormAutocompleteEvent>\n\t/**\n\t * Emitted when the input loses focus.\n\t */\n\t@Event({eventName: 'gov-blur'}) govBlur: EventEmitter<FormAutocompleteEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({eventName: 'gov-input'}) govInput: EventEmitter<FormAutocompleteEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({eventName: 'gov-select'}) govSelect: EventEmitter<FormAutocompleteEvent>\n\n\t@State() focused: boolean\n\t@State() processing = false\n\t@State() arrowCounter = -1\n\t@State() list: GovFormAutocompleteItem[] = []\n\t@State() inheritedAttributes: Attributes = {}\n\n\t@Watch('size')\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormAutocompleteSizes, newValue, FormAutocompleteClass.root)\n\t}\n\n\t@Watch('options')\n\twatchOptions(newValue: string | GovFormAutocompleteItem[]): void {\n\t\tthis.setOptions(propsValueToArray(newValue)).catch()\n\t}\n\n\tprivate onArrowUp() {\n\t\tif (this.arrowCounter > 0) {\n\t\t\tthis.arrowCounter = this.arrowCounter - 1\n\t\t\tthis.moveToView().finally()\n\t\t}\n\t}\n\n\tprivate onArrowDown() {\n\t\tif (this.arrowCounter < this.list.length - 1) {\n\t\t\tthis.arrowCounter = this.arrowCounter + 1\n\t\t\tthis.moveToView().finally()\n\t\t}\n\t}\n\n\tprivate async moveToView() {\n\t\tawait delay(200)\n\t\tconst heightOfList = this.listRef.offsetHeight\n\t\tconst selected = this.listRef.querySelector('li[aria-selected=\"true\"]') as HTMLUListElement\n\t\tif (selected && heightOfList) {\n\t\t\tconst offsetTop = selected.offsetTop\n\t\t\tthis.listRef.scrollTo({top: offsetTop, behavior: 'smooth'})\n\t\t}\n\t}\n\n\tprivate doSearch() {\n\t\tif (Number.isInteger(this.minlength) && this.isValueAccepted === false && this.minlength) {\n\t\t\tthis.list = []\n\t\t\tthis.arrowCounter = -1\n\t\t\tthis.processing = false\n\t\t\treturn\n\t\t}\n\t\tif (this.searchCallback) {\n\t\t\tthis.processing = true\n\t\t\tthis.searchCallback(this.value)\n\t\t\t\t.then(response => (this.list = response))\n\t\t\t\t.catch(() => (this.list = []))\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis.arrowCounter = -1\n\t\t\t\t\tthis.processing = false\n\t\t\t\t})\n\t\t}\n\t}\n\n\tprivate clearList() {\n\t\tconst areOptions = propsValueToArray<GovFormAutocompleteItem[]>(this.options)\n\t\tif (areOptions.length === 0) {\n\t\t\tthis.list = []\n\t\t}\n\t}\n\n\tget isValueAccepted() {\n\t\tif (typeof this.value === 'string') {\n\t\t\treturn this.value.length >= this.minlength\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tcomponentDidLoad() {\n\t\tthis.attributeObserver = new AttributeObserver(this.host, (attributeName, newValue) => {\n\t\t\tthis.onAriaAttributeChange(attributeName, newValue);\n\t\t});\n\n\t\tthis.attributeObserver.startObserving(ariaAttributes);\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateSize(this.size)\n\t\tthis.inheritedAttributes = inheritAriaAttributes(this.host);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.attributeObserver?.stopObserving();\n\t}\n\n\tonAriaAttributeChange(attributeName: string, newValue: string) {\n\t\tthis.host.removeAttribute(attributeName)\n\t\tthis.inheritedAttributes = {...this.inheritedAttributes, [attributeName]: newValue};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={FormAutocompleteClass.root} size={this.size}>\n\t\t\t\t<gov-form-input\n\t\t\t\t\tplaceholder={this.placeholder}\n\t\t\t\t\tname={this.name}\n\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\treadonly={this.readonly}\n\t\t\t\t\tautocomplete={false}\n\t\t\t\t\tsize={this.size}\n\t\t\t\t\trequired={this.required}\n\t\t\t\t\tinvalid={this.invalid}\n\t\t\t\t\tsuccess={this.success}\n\t\t\t\t\trole={'searchbox'}\n\t\t\t\t\tvalue={this.value}\n\t\t\t\t\tminlength={this.minlength}\n\t\t\t\t\tmaxlength={this.maxlength}\n\t\t\t\t\ton-gov-input={throttle(this.onInputHandler.bind(this), this.throttleTime)}\n\t\t\t\t\ton-gov-keyup={this.onKeyUpHandler.bind(this)}\n\t\t\t\t\ton-gov-keydown={this.onKeyDownHandler.bind(this)}\n\t\t\t\t\ton-gov-focus={this.onFocusHandler.bind(this)}\n\t\t\t\t\ton-gov-blur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t{...this.inheritedAttributes}\n\t\t\t\t\taria-autocomplete={'list'}\n\t\t\t\t\taria-owns={[this.listBoxId, this.inheritedAttributes['aria-owns']].join(' ')}\n\t\t\t\t\taria-expanded={booleanString(this.list.length && this.focused ? true : false)}\n\t\t\t\t\tref={el => (this.inputRef = el as HTMLGovFormInputElement)}\n\t\t\t\t>\n\t\t\t\t\t<slot name=\"validation-icon\" />\n\t\t\t\t\t<slot name=\"icon-end\" />\n\t\t\t\t</gov-form-input>\n\t\t\t\t<ul class={FormAutocompleteClass.list}\n\t\t\t\t\trole={'listbox'}\n\t\t\t\t\taria-hidden={toBoolAttr(!this.focused)}\n\t\t\t\t\thidden={!this.focused}\n\t\t\t\t\tid={this.listBoxId}\n\t\t\t\t\tref={el => (this.listRef = el as HTMLUListElement)}>\n\t\t\t\t\t{this.focused && this.list.length === 0 && this.processing === false && this.isValueAccepted && this.messageEmpty ? (\n\t\t\t\t\t\t<li class={FormAutocompleteClass.empty}>{this.messageEmpty}</li>\n\t\t\t\t\t) : null}\n\t\t\t\t\t{this.focused && this.processing === true && this.isValueAccepted ? (\n\t\t\t\t\t\t<li class={FormAutocompleteClass.loading}>\n\t\t\t\t\t\t\t<gov-skeleton size=\"m\"></gov-skeleton>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t) : null}\n\t\t\t\t\t{this.focused ? this.list.map((item, index) => {\n\t\t\t\t\t\tconst isSelected = this.arrowCounter === index\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<li\n\t\t\t\t\t\t\t\tclass={FormAutocompleteClass.item}\n\t\t\t\t\t\t\t\tinnerHTML={this.templateResolver(item, isSelected)}\n\t\t\t\t\t\t\t\trole={'option'}\n\t\t\t\t\t\t\t\taria-posinset={index}\n\t\t\t\t\t\t\t\ttabindex={isSelected ? 0 : -1}\n\t\t\t\t\t\t\t\taria-setsize={this.list.length}\n\t\t\t\t\t\t\t\tonTouchStart={(e: TouchEvent) => this.onSelectHandler(e, index)}\n\t\t\t\t\t\t\t\tonMouseDown={(e: PointerEvent) => this.onSelectHandler(e, index)}\n\t\t\t\t\t\t\t\taria-selected={toBoolAttr(isSelected)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<slot name=\"list-item-left\"/>\n\t\t\t\t\t\t\t\t<slot name=\"list-item-right\"/>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t)\n\t\t\t\t\t}) : null}\n\t\t\t\t</ul>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\tthis.focused = true\n\t\tthis.arrowCounter = -1\n\t\tif (this.isValueAccepted && this.searchCallback) {\n\t\t\tthis.doSearch()\n\t\t}\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\toriginalEvent: e,\n\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\tvalue: this.value,\n\t\t\tselected: null,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\tthis.focused = false\n\t\tthis.clearList();\n\t\tthis.arrowCounter = -1\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\toriginalEvent: e,\n\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\tvalue: this.value,\n\t\t\tselected: null,\n\t\t})\n\t}\n\n\tprivate onInputHandler(e: InputEvent) {\n\t\tthis.value = (e.target as HTMLGovFormInputElement).value\n\t\te.stopPropagation()\n\t\tthis.govInput.emit({\n\t\t\toriginalEvent: e,\n\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\tvalue: this.value,\n\t\t\tselected: null,\n\t\t})\n\t\tthis.doSearch()\n\t}\n\n\tprivate onSelectHandler(e: PointerEvent | CustomEvent | TouchEvent, index = -1) {\n\t\tlet selected: Nullable<GovFormAutocompleteItem> = null\n\t\tif (index > -1) {\n\t\t\tselected = this.list[index]\n\t\t} else if (has(this.arrowCounter, this.list)) {\n\t\t\tselected = this.list[this.arrowCounter]\n\t\t}\n\t\tif (selected) {\n\t\t\tthis.govSelect.emit({\n\t\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\t\tvalue: this.value,\n\t\t\t\tselected: selected,\n\t\t\t\toriginalEvent: e,\n\t\t\t})\n\t\t\tthis.clearList();\n\t\t\tif (has(this.nameKey, selected) && typeof selected[this.nameKey] === 'string') {\n\t\t\t\tthis.value = selected[this.nameKey]\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate onKeyUpHandler(e: CustomEvent) {\n\t\tconst event = (e.detail as FormInputEvent).originalEvent as KeyboardEvent\n\t\te.stopPropagation()\n\t\tevent.stopPropagation()\n\t\tif (event.keyCode === 38) this.onArrowUp()\n\t\telse if (event.keyCode === 40) this.onArrowDown()\n\t\telse if (event.keyCode === 13) {\n\t\t\te.preventDefault()\n\t\t\tevent.preventDefault()\n\t\t\tthis.onSelectHandler(e)\n\t\t}\n\t}\n\n\tprivate onKeyDownHandler(e: CustomEvent) {\n\t\tconst event = (e.detail as FormInputEvent).originalEvent as KeyboardEvent\n\t\te.stopPropagation()\n\t\tevent.stopPropagation()\n\t\tif (event.keyCode === 13) {\n\t\t\te.preventDefault()\n\t\t\tevent.preventDefault()\n\t\t}\n\t}\n\n\t/**\n\t * Focus main input element\n\t */\n\t@Method()\n\tasync setFocus(options?: FocusOptions): Promise<void> {\n\t\treturn this.inputRef.focus(options)\n\t}\n\n\t/**\n\t * Blur main input element\n\t */\n\t@Method()\n\tasync setBlur(): Promise<void> {\n\t\treturn this.inputRef.blur()\n\t}\n\n\t/**\n\t * Set options for list\n\t */\n\t@Method()\n\tasync setOptions(options: GovFormAutocompleteItem[]): Promise<void> {\n\t\tthis.list = Array.isArray(options) ? options : []\n\t\tthis.arrowCounter = -1\n\t}\n\n\t/**\n\t * Clears whisperer value\n\t */\n\t@Method()\n\tasync clearValue(): Promise<void> {\n\t\tthis.value = ''\n\t\tthis.inputRef.value = ''\n\n\t\tawait this.inputRef.clearValue()\n\t}\n\n\t/**\n\t * Clears whisperer value\n\t */\n\t@Method()\n\tasync setProcessing(status: boolean): Promise<void> {\n\t\tthis.processing = status\n\t}\n\n\t/**\n\t * Set a custom asynchronous function for the whisperer\n\t */\n\t@Method()\n\tasync setSearchCallback(callback: (value: string) => Promise<any>) {\n\t\tthis.searchCallback = callback\n\t}\n\n\t/**\n\t * Setting a custom whisper result template\n\t * @param callback\n\t */\n\t@Method()\n\tasync setTemplateResolver(callback: (item: GovFormAutocompleteItem) => string) {\n\t\tthis.templateResolver = callback\n\t}\n}\n"],"mappings":"4cAiBaA,EAAmB,MAQ/B,WAAAC,CAAAC,G,kJAHQC,KAAgBC,iBAAiEC,GAAQA,EAAKF,KAAKG,SAWrEH,KAAKI,MAAG,GAgB7BJ,KAAIK,KAAe,IAIIL,KAAOG,QAAW,OASzCH,KAAQM,SAAY,MAKLN,KAAQO,SAAY,MAgBnCP,KAASQ,UAAW,EAQpBR,KAAYS,aAAW,IAIKT,KAAYU,aAAW,iCAmB3DV,KAAUW,WAAG,MACbX,KAAYY,cAAG,EACfZ,KAAIa,KAA8B,GAClCb,KAAmBc,oBAAe,GA3F1Cd,KAAKe,UAAYC,EAAS,aAC1B,CA6FD,YAAAC,CAAaC,GACZC,EAAaC,EAAuBF,EAAUG,EAAsBC,K,CAIrE,YAAAC,CAAaL,GACZlB,KAAKwB,WAAWC,EAAkBP,IAAWQ,O,CAGtC,SAAAC,GACP,GAAI3B,KAAKY,aAAe,EAAG,CAC1BZ,KAAKY,aAAeZ,KAAKY,aAAe,EACxCZ,KAAK4B,aAAaC,S,EAIZ,WAAAC,GACP,GAAI9B,KAAKY,aAAeZ,KAAKa,KAAKkB,OAAS,EAAG,CAC7C/B,KAAKY,aAAeZ,KAAKY,aAAe,EACxCZ,KAAK4B,aAAaC,S,EAIZ,gBAAMD,SACPI,EAAM,KACZ,MAAMC,EAAejC,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oH,GACLhI,KAAKI,MAAQ,GACbJ,KAAK6F,SAASzF,MAAQ,SAEhBJ,KAAK6F,SAASmC,Y,CAOrB,mBAAMC,CAAcC,GACnBlI,KAAKW,WAAauH,C,CAOnB,uBAAMC,CAAkBC,GACvBpI,KAAK8C,eAAiBsF,C,CAQvB,yBAAMC,CAAoBD,GACzBpI,KAAKC,iBAAmBmI,C","ignoreList":[]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as t,h as s,H as i,g as e}from"./p-ClISz4NF.js";import{v as o}from"./p-NOJjz9dT.js";import{C as h}from"./p-U40vKHrs.js";import{S as n}from"./p-BcQO4NH2.js";import{p as a}from"./p-CQvUntGY.js";import{c as r}from"./p-vN03FcXN.js";import{g as l,a as c}from"./p-CoD1xawt.js";import{d}from"./p-CgDnDrq5.js";import{t as f}from"./p-Cjg0wpDG.js";const p=a(h,["PRIMARY","NEUTRAL"]);const u=a(n,["_S","_M","_L"]);var v;(function(t){t["TOP"]="top";t["RIGHT"]="right";t["BOTTOM"]="bottom";t["LEFT"]="left"})(v||(v={}));const m={root:"gov-tooltip"};const b={root:"gov-tooltip-content"};const g=class{constructor(s){t(this,s);this.tooltipContentId=undefined;this.tooltipId=undefined;this.color=p.PRIMARY;this.size=u._M;this.position="right";this.message=undefined;this.icon=undefined;this.persist=false;this.h=l(this.host);this.tooltipId=r("GovTooltip");this.tooltipContentId=r("GovContentTooltip")}validateColor(t){o(p,t,m.root)}validateSize(t){o(u,t,m.root)}validatePosition(t){o(v,t,m.root)}rerenderMessage(){this.createContentWrapper()}connectedCallback(){this.createContentWrapper();this.registerListeners()}componentWillLoad(){this.validateColor(this.color);this.validateSize(this.size);this.validatePosition(this.position)}componentDidUpdate(){this.createContentWrapper()}disconnectedCallback(){this.removeContent()}createContentWrapper(){var t;if(this.tooltipContent){if(this.message){this.tooltipContent.innerHTML=this.message}else if(this.insideContent){this.tooltipContent.innerHTML=this.insideContent.innerHTML}return}let s;if(this.insideContent){s=this.insideContent}else{s=d().createElement(b.root);s.innerHTML=this.message}s.setAttribute("id",(t=this.identifier)!==null&&t!==void 0?t:this.tooltipContentId);s.setAttribute("parent-id",this.tooltipId);s.setAttribute("color",this.color);s.setAttribute("size",this.size);d().body.appendChild(s)}get tooltipContent(){var t;return d().body.querySelector(`#${(t=this.identifier)!==null&&t!==void 0?t:this.tooltipContentId}`)}get insideContent(){return this.host.querySelector(b.root)}registerListeners(){this.host.addEventListener("click",(t=>{t.preventDefault();this.persist=true;if(this.tooltipContent){this.tooltipContent.setAttribute("persist","true")}this.showTooltip()}));this.host.addEventListener("mouseenter",(t=>{t.preventDefault();this.showTooltip()}));this.host.addEventListener("mouseleave",(t=>{t.preventDefault();if(this.persist===false){this.hideTooltip()}}))}verifyPositionSpace(){const t=12;const s=window.innerWidth-(window.innerWidth-document.documentElement.clientWidth);const i=this.host.getBoundingClientRect();const e=this.host.offsetWidth;const o=this.host.offsetHeight;const h=this.tooltipContent.offsetWidth;const n=this.tooltipContent.offsetHeight;const a={left:i.left+document.documentElement.scrollLeft,top:i.top+document.documentElement.scrollTop};const r=a.left+t+i.width+h<=s;const l=a.left>h;if(this.position===v.LEFT||this.position===v.RIGHT){this.tooltipContent.style.top=a.top-(n-o)/2+"px";if(r===false&&l===false){this.position=v.TOP;this.tooltipContent.setAttribute("position",v.TOP)}if(l&&r===false&&this.position===v.RIGHT){this.position=v.LEFT}if(r&&l===false&&this.position===v.LEFT){this.position=v.RIGHT}}if(this.position===v.RIGHT){this.tooltipContent.setAttribute("position",v.RIGHT);this.tooltipContent.style.left=a.left+t+i.width+"px"}if(this.position===v.LEFT){this.tooltipContent.setAttribute("position",v.LEFT);this.tooltipContent.style.left=a.left-(h+t)+"px"}if(this.position===v.TOP||this.position===v.BOTTOM){if(h>e){let i=a.left-(h-e)/2;const o=i<0;const n=i+h>s;if(o&&n){this.tooltipContent.style.width="auto";this.tooltipContent.style.left=t+"px";this.tooltipContent.style.right=t+"px"}else{if(o){i=t}if(n){i=i-(s-(i+h+t))*-1}this.tooltipContent.style.left=i+"px"}}else{const t=a.left+(e-h)/2;this.tooltipContent.style.left=t+"px"}}if(this.position===v.TOP){this.tooltipContent.setAttribute("position",v.TOP);this.tooltipContent.style.top=a.top-(n+t)+"px"}if(this.position===v.BOTTOM){this.tooltipContent.setAttribute("position",v.BOTTOM);this.tooltipContent.style.top=a.top+(o+t)+"px"}this.tooltipContent.style.opacity="1"}showTooltip(){if(this.tooltipContent){this.tooltipContent.style.opacity="0";this.tooltipContent.hidden=false;this.tooltipContent.setAttribute("is-visible","true");f((()=>{this.verifyPositionSpace()}))}}hideTooltip(){if(this.tooltipContent){this.tooltipContent.setAttribute("is-visible","false");this.tooltipContent.setAttribute("persist","false");this.tooltipContent.removeAttribute("style")}}removeContent(){const t=document.getElementById(this.tooltipContentId);if(t){t.remove()}}render(){var t;return s(i,{key:"dd78d93d3b5ba4bc3a128435f58467c9bd6def43",id:this.tooltipId,class:this.h.classes(m.root),position:this.position},s("span",{key:"2ede8642a4cf998367da3756c795847195c0f694",role:"button",tabindex:0,onKeyPress:()=>this.showTooltip(),onBlur:()=>{if(this.persist===false){this.hideTooltip()}},"aria-describedby":(t=this.identifier)!==null&&t!==void 0?t:this.tooltipContentId},s("slot",{key:"9607b4c9b24766f70b53c6372e6e7219e7a3a6fd"})))}async show(){this.showTooltip()}async hide(){this.persist=false;this.hideTooltip()}get host(){return e(this)}static get watchers(){return{color:["validateColor"],size:["validateSize"],position:["validatePosition"],message:["rerenderMessage"]}}};const C=class{constructor(s){t(this,s);this.color=p.PRIMARY;this.size=u._M;this.persist=false;this.isVisible=false;this.parentId=null}visibleContent(t){clearTimeout(this.timeout);if(t===false){this.timeout=setTimeout((()=>{this.host.style.visibility="hidden"}),250)}else{this.host.style.visibility="visible"}}hideContent(){this.isVisible=false;this.persist=false;const t=document.getElementById(this.parentId);if(t){t.hide().catch()}}render(){return s(i,{key:"71d259cc8d7247030767f8ac36a6875f9c16ffea",class:b.root,role:"tooltip",hidden:!this.isVisible,"aria-hidden":!c(this.isVisible),"is-visible":this.isVisible},s("slot",{key:"06d883340271717da9d0b8de6c35339cd5c9dfb9"}),this.persist?s("gov-button",{"on-gov-click":this.hideContent.bind(this),color:this.color,size:this.size,type:"base"},s("gov-icon",{slot:"icon-start",name:"x-lg",type:"components"})):null)}get host(){return e(this)}static get watchers(){return{isVisible:["visibleContent"]}}};export{g as gov_tooltip,C as gov_tooltip_content};
|
|
2
|
-
//# sourceMappingURL=p-3e5ae012.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["TooltipColors","pick","Colors","TooltipSize","Sizes","TooltipPosition","TooltipClass","root","TooltipContentClass","GovTooltip","constructor","hostRef","this","tooltipContentId","undefined","tooltipId","color","PRIMARY","size","_M","position","message","icon","persist","h","govHost","host","createID","validateColor","newValue","validateProp","validateSize","validatePosition","rerenderMessage","createContentWrapper","connectedCallback","registerListeners","componentWillLoad","componentDidUpdate","disconnectedCallback","removeContent","tooltipContent","innerHTML","insideContent","content","documentNode","createElement","setAttribute","_a","identifier","body","appendChild","querySelector","addEventListener","e","preventDefault","showTooltip","hideTooltip","verifyPositionSpace","offset","windowWidth","window","innerWidth","document","documentElement","clientWidth","trigger","getBoundingClientRect","trgWidth","offsetWidth","trgHeight","offsetHeight","contentWidth","contentHeight","triggerPos","left","scrollLeft","top","scrollTop","isRightSpace","width","isLeftSpace","LEFT","RIGHT","style","TOP","BOTTOM","leftPosition","isNotLeftSpace","isNotRightSpace","right","opacity","hidden","tick","removeAttribute","contentEl","getElementById","remove","render","Host","key","id","class","classes","role","tabindex","onKeyPress","onBlur","show","hide","GovTooltipContent","isVisible","parentId","visibleContent","clearTimeout","timeout","setTimeout","visibility","hideContent","parentEl","catch","toBoolAttr","bind","type","slot","name"],"sources":["../../../packages/core/src/components/gov-tooltip/constants.tsx","../../../packages/core/src/components/gov-tooltip/gov-tooltip.tsx","../../../packages/core/src/components/gov-tooltip/gov-tooltip-content.tsx"],"sourcesContent":["import { Colors } from '../../core/constants/colors'\nimport { Sizes } from '../../core/constants/sizes'\nimport { ValueOf } from '../../types/interfaces'\nimport { pick } from '../../utils/utils'\n\nexport const TooltipColors = pick(Colors, ['PRIMARY', 'NEUTRAL'])\nexport type TooltipColorType = `${ValueOf<typeof TooltipColors>}`\n\nexport const TooltipSize = pick(Sizes, ['_S', '_M', '_L'])\nexport type TooltipSizeType = `${ValueOf<typeof TooltipSize>}`\n\nexport enum TooltipPosition {\n\tTOP = 'top',\n\tRIGHT = 'right',\n\tBOTTOM = 'bottom',\n\tLEFT = 'left',\n}\nexport type TooltipPositionType = `${ValueOf<typeof TooltipPosition>}`\n\nexport const TooltipClass = {\n\troot: 'gov-tooltip',\n}\n\nexport const TooltipContentClass = {\n\troot: 'gov-tooltip-content',\n}\n","import {Component, Element, h, Host, Method, Prop, State, Watch} from \"@stencil/core\"\nimport {validateProp} from \"../../helpers/Validate/props\"\nimport {\n\tTooltipClass,\n\tTooltipContentClass,\n\tTooltipPosition,\n\tTooltipPositionType,\n\tTooltipSize,\n\tTooltipSizeType,\n\tTooltipColors,\n\tTooltipColorType,\n} from \"./constants\"\nimport {createID} from \"../../utils/string.utils\"\nimport {govHost} from \"../../helpers/Dom/template\"\nimport {GovHost} from \"../../helpers/Dom/template.types\"\nimport {documentNode} from \"../../helpers/Dom/win\";\nimport {Nullable} from \"../../utils/helpers.types\";\nimport {tick} from \"../../utils/stencil.utils\";\n\n@Component({\n\ttag: \"gov-tooltip\",\n})\nexport class GovTooltip {\n\tprivate h: GovHost\n\tprivate readonly tooltipContentId = undefined\n\tprivate readonly tooltipId = undefined\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.tooltipId = createID(\"GovTooltip\")\n\t\tthis.tooltipContentId = createID(\"GovContentTooltip\")\n\t}\n\n\t@Element() host: HTMLGovTooltipElement\n\t/**\n\t * Style variation of the tooltip\n\t */\n\t@Prop() readonly color?: TooltipColorType = TooltipColors.PRIMARY\n\t/**\n\t * Tooltip’s size.\n\t */\n\t@Prop() readonly size?: TooltipSizeType = TooltipSize._M\n\t/**\n\t * Tooltip display position\n\t */\n\t@Prop({mutable: true}) position: TooltipPositionType = \"right\"\n\t/**\n\t * Information contained in the tooltip\n\t */\n\t@Prop() readonly message: string = undefined\n\t/**\n\t * Custom tooltip identifier.\n\t */\n\t@Prop({attribute: \"identifier\"}) readonly identifier: string\n\t/**\n\t * Trigger is just an icon\n\t */\n\t@Prop({reflect: true}) readonly icon: boolean = undefined\n\n\t@State() persist = false\n\n\t@Watch(\"color\")\n\tvalidateColor(newValue: string): void {\n\t\tvalidateProp(TooltipColors, newValue, TooltipClass.root)\n\t}\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(TooltipSize, newValue, TooltipClass.root)\n\t}\n\n\t@Watch(\"position\")\n\tvalidatePosition(newValue: string): void {\n\t\tvalidateProp(TooltipPosition, newValue, TooltipClass.root)\n\t}\n\n\t@Watch(\"message\")\n\trerenderMessage(): void {\n\t\tthis.createContentWrapper();\n\t}\n\n\tconnectedCallback() {\n\t\tthis.createContentWrapper()\n\t\tthis.registerListeners()\n\t}\n\n\tcomponentWillLoad(): void {\n\t\tthis.validateColor(this.color)\n\t\tthis.validateSize(this.size)\n\t\tthis.validatePosition(this.position)\n\t}\n\n\tcomponentDidUpdate() {\n\t\tthis.createContentWrapper()\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.removeContent()\n\t}\n\n\tprivate createContentWrapper() {\n\t\tif (this.tooltipContent) {\n\t\t\tif (this.message) {\n\t\t\t\tthis.tooltipContent.innerHTML = this.message\n\t\t\t} else if (this.insideContent) {\n\t\t\t\tthis.tooltipContent.innerHTML = this.insideContent.innerHTML\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tlet content: HTMLGovTooltipContentElement;\n\t\tif (this.insideContent) {\n\t\t\tcontent = this.insideContent\n\t\t} else {\n\t\t\tcontent = documentNode().createElement(TooltipContentClass.root) as HTMLGovTooltipContentElement\n\t\t\tcontent.innerHTML = this.message\n\t\t}\n\n\t\tcontent.setAttribute(\"id\", this.identifier ?? this.tooltipContentId)\n\t\tcontent.setAttribute(\"parent-id\", this.tooltipId)\n\t\tcontent.setAttribute(\"color\", this.color)\n\t\tcontent.setAttribute(\"size\", this.size)\n\t\tdocumentNode().body.appendChild(content)\n\t}\n\n\tprivate get tooltipContent(): Nullable<HTMLGovTooltipContentElement> {\n\t\treturn documentNode().body.querySelector(`#${this.identifier ?? this.tooltipContentId}`);\n\t}\n\n\tprivate get insideContent(): Nullable<HTMLGovTooltipContentElement> {\n\t\treturn this.host.querySelector(TooltipContentClass.root)\n\t}\n\n\tprivate registerListeners() {\n\t\tthis.host.addEventListener(\"click\", e => {\n\t\t\te.preventDefault()\n\t\t\tthis.persist = true\n\t\t\tif (this.tooltipContent) {\n\t\t\t\tthis.tooltipContent.setAttribute(\"persist\", \"true\")\n\t\t\t}\n\t\t\tthis.showTooltip()\n\t\t})\n\t\tthis.host.addEventListener(\"mouseenter\", e => {\n\t\t\te.preventDefault()\n\t\t\tthis.showTooltip()\n\t\t})\n\t\tthis.host.addEventListener(\"mouseleave\", e => {\n\t\t\te.preventDefault()\n\t\t\tif (this.persist === false) {\n\t\t\t\tthis.hideTooltip()\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate verifyPositionSpace() {\n\t\tconst offset = 12\n\t\tconst windowWidth = window.innerWidth - (window.innerWidth - document.documentElement.clientWidth);\n\t\tconst trigger = this.host.getBoundingClientRect()\n\t\tconst trgWidth = this.host.offsetWidth\n\t\tconst trgHeight = this.host.offsetHeight\n\t\tconst contentWidth = this.tooltipContent.offsetWidth\n\t\tconst contentHeight = this.tooltipContent.offsetHeight\n\t\tconst triggerPos = {\n\t\t\tleft: trigger.left + document.documentElement.scrollLeft,\n\t\t\ttop: trigger.top + document.documentElement.scrollTop,\n\t\t}\n\n\t\tconst isRightSpace = ((triggerPos.left + offset + trigger.width) + contentWidth) <= windowWidth;\n\t\tconst isLeftSpace = triggerPos.left > contentWidth;\n\n\t\t// LEFT/RIGHT\n\t\tif (this.position === TooltipPosition.LEFT || this.position === TooltipPosition.RIGHT) {\n\t\t\tthis.tooltipContent.style.top = (triggerPos.top - ((contentHeight - trgHeight) / 2)) + \"px\";\n\t\t\tif (isRightSpace === false && isLeftSpace === false) {\n\t\t\t\tthis.position = TooltipPosition.TOP\n\t\t\t\tthis.tooltipContent.setAttribute(\"position\", TooltipPosition.TOP)\n\t\t\t}\n\t\t\tif (isLeftSpace && isRightSpace === false && this.position === TooltipPosition.RIGHT) {\n\t\t\t\tthis.position = TooltipPosition.LEFT\n\t\t\t}\n\t\t\tif (isRightSpace && isLeftSpace === false && this.position === TooltipPosition.LEFT) {\n\t\t\t\tthis.position = TooltipPosition.RIGHT\n\t\t\t}\n\t\t}\n\t\tif (this.position === TooltipPosition.RIGHT) {\n\t\t\tthis.tooltipContent.setAttribute(\"position\", TooltipPosition.RIGHT)\n\t\t\tthis.tooltipContent.style.left = (triggerPos.left + offset + trigger.width) + \"px\"\n\t\t}\n\t\tif (this.position === TooltipPosition.LEFT) {\n\t\t\tthis.tooltipContent.setAttribute(\"position\", TooltipPosition.LEFT)\n\t\t\tthis.tooltipContent.style.left = (triggerPos.left - (contentWidth + offset)) + \"px\"\n\t\t}\n\n\t\t// LEFT/RIGHT FOR TOP/BOTTOM\n\t\tif (this.position === TooltipPosition.TOP || this.position === TooltipPosition.BOTTOM) {\n\t\t\tif (contentWidth > trgWidth) {\n\t\t\t\tlet leftPosition = (triggerPos.left - ((contentWidth - trgWidth) / 2));\n\t\t\t\tconst isNotLeftSpace = leftPosition < 0;\n\t\t\t\tconst isNotRightSpace = (leftPosition + contentWidth) > windowWidth;\n\t\t\t\tif (isNotLeftSpace && isNotRightSpace) {\n\t\t\t\t\tthis.tooltipContent.style.width = \"auto\";\n\t\t\t\t\tthis.tooltipContent.style.left = offset + \"px\";\n\t\t\t\t\tthis.tooltipContent.style.right = offset + \"px\";\n\t\t\t\t} else {\n\t\t\t\t\tif (isNotLeftSpace) {\n\t\t\t\t\t\tleftPosition = offset\n\t\t\t\t\t}\n\t\t\t\t\tif (isNotRightSpace) {\n\t\t\t\t\t\tleftPosition = leftPosition - ((windowWidth - (leftPosition + contentWidth + offset)) * -1)\n\t\t\t\t\t}\n\t\t\t\t\tthis.tooltipContent.style.left = leftPosition + \"px\"\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst leftPosition = (triggerPos.left + ((trgWidth - contentWidth) / 2))\n\n\t\t\t\tthis.tooltipContent.style.left = leftPosition + \"px\"\n\t\t\t}\n\t\t}\n\t\tif (this.position === TooltipPosition.TOP) {\n\t\t\tthis.tooltipContent.setAttribute(\"position\", TooltipPosition.TOP)\n\t\t\tthis.tooltipContent.style.top = (triggerPos.top - (contentHeight + offset)) + \"px\"\n\t\t}\n\t\tif (this.position === TooltipPosition.BOTTOM) {\n\t\t\tthis.tooltipContent.setAttribute(\"position\", TooltipPosition.BOTTOM)\n\t\t\tthis.tooltipContent.style.top = (triggerPos.top + (trgHeight + offset)) + \"px\"\n\t\t}\n\n\t\tthis.tooltipContent.style.opacity = '1'\n\n\t}\n\n\tprivate showTooltip() {\n\t\tif (this.tooltipContent) {\n\t\t\tthis.tooltipContent.style.opacity = '0'\n\t\t\tthis.tooltipContent.hidden = false\n\t\t\tthis.tooltipContent.setAttribute(\"is-visible\", \"true\")\n\t\t\ttick(() => {\n\t\t\t\tthis.verifyPositionSpace()\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate hideTooltip() {\n\t\tif (this.tooltipContent) {\n\t\t\tthis.tooltipContent.setAttribute(\"is-visible\", \"false\")\n\t\t\tthis.tooltipContent.setAttribute(\"persist\", \"false\")\n\t\t\tthis.tooltipContent.removeAttribute('style')\n\t\t}\n\t}\n\n\tprivate removeContent() {\n\t\tconst contentEl = document.getElementById(this.tooltipContentId)\n\t\tif (contentEl) {\n\t\t\tcontentEl.remove()\n\t\t}\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host\n\t\t\t\tid={this.tooltipId}\n\t\t\t\tclass={this.h.classes(TooltipClass.root)}\n\t\t\t\tposition={this.position}>\n\t\t\t\t<span role={'button'}\n\t\t\t\t\t\t\ttabindex={0}\n\t\t\t\t\t\t\tonKeyPress={() => this.showTooltip()}\n\t\t\t\t\t\t\tonBlur={() => {\n\t\t\t\t\t\t\t\tif (this.persist === false) {\n\t\t\t\t\t\t\t\t\tthis.hideTooltip()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\taria-describedby={this.identifier ?? this.tooltipContentId}><slot/></span>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\t/**\n\t * Showing the modal\n\t */\n\t@Method()\n\tasync show(): Promise<void> {\n\t\tthis.showTooltip()\n\t}\n\n\t/**\n\t * Hiding the modal\n\t */\n\t@Method()\n\tasync hide(): Promise<void> {\n\t\tthis.persist = false\n\t\tthis.hideTooltip()\n\t}\n}\n","import { Component, Element, h, Host, Prop, Watch } from \"@stencil/core\"\nimport { TooltipContentClass, TooltipSize, TooltipSizeType, TooltipColors, TooltipColorType } from \"./constants\"\nimport { toBoolAttr } from \"../../helpers/Dom/template\"\n\n@Component({\n\ttag: \"gov-tooltip-content\",\n})\nexport class GovTooltipContent {\n\tprivate timeout\n\n\t@Element() host: HTMLGovTooltipContentElement\n\t/**\n\t * Style variation of the tooltip\n\t */\n\t@Prop() readonly color?: TooltipColorType = TooltipColors.PRIMARY\n\t/**\n\t * Tooltip’s size.\n\t */\n\t@Prop() readonly size?: TooltipSizeType = TooltipSize._M\n\t/**\n\t * Tooltip is still visible.\n\t */\n\t@Prop() persist?: boolean = false\n\t/**\n\t * Indicates display of tooltip content\n\t */\n\t@Prop({ attribute: \"is-visible\", mutable: true }) isVisible = false\n\t/**\n\t * Indicates display of tooltip content\n\t */\n\t@Prop({ attribute: \"parent-id\" }) parentId: string = null\n\n\t@Watch(\"isVisible\")\n\tvisibleContent(newValue: boolean): void {\n\t\tclearTimeout(this.timeout)\n\t\tif (newValue === false) {\n\t\t\tthis.timeout = setTimeout(() => {\n\t\t\t\tthis.host.style.visibility = \"hidden\"\n\t\t\t}, 250)\n\t\t} else {\n\t\t\tthis.host.style.visibility = \"visible\"\n\t\t}\n\t}\n\n\thideContent() {\n\t\tthis.isVisible = false\n\t\tthis.persist = false\n\t\tconst parentEl = document.getElementById(this.parentId) as HTMLGovTooltipElement\n\t\tif (parentEl) {\n\t\t\tparentEl.hide().catch()\n\t\t}\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host\n\t\t\t\tclass={TooltipContentClass.root}\n\t\t\t\trole={\"tooltip\"}\n\t\t\t\thidden={!this.isVisible}\n\t\t\t\taria-hidden={!toBoolAttr(this.isVisible)}\n\t\t\t\tis-visible={this.isVisible}>\n\t\t\t\t<slot></slot>\n\t\t\t\t{this.persist ? (\n\t\t\t\t\t<gov-button\n\t\t\t\t\t\ton-gov-click={this.hideContent.bind(this)}\n\t\t\t\t\t\tcolor={this.color}\n\t\t\t\t\t\tsize={this.size}\n\t\t\t\t\t\ttype={\"base\"}>\n\t\t\t\t\t\t<gov-icon slot={\"icon-start\"} name={\"x-lg\"} type={\"components\"}></gov-icon>\n\t\t\t\t\t</gov-button>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n}\n"],"mappings":"2VAKO,MAAMA,EAAgBC,EAAKC,EAAQ,CAAC,UAAW,YAG/C,MAAMC,EAAcF,EAAKG,EAAO,CAAC,KAAM,KAAM,OAGpD,IAAYC,GAAZ,SAAYA,GACXA,EAAA,aACAA,EAAA,iBACAA,EAAA,mBACAA,EAAA,cACA,EALD,CAAYA,MAKX,KAGM,MAAMC,EAAe,CAC3BC,KAAM,eAGA,MAAMC,EAAsB,CAClCD,KAAM,uB,MCFME,EAAU,MAKtB,WAAAC,CAAAC,G,UAHiBC,KAAgBC,iBAAGC,UACnBF,KAASG,UAAGD,UAYZF,KAAAI,MAA2BhB,EAAciB,QAIz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p-CQvUntGY.js";import{S as c}from"./p-BcQO4NH2.js";r(c,["_S","_M","_L"]);r(o,["PRIMARY","NEUTRAL"]);const b={root:"gov-form-search"};const f=class{constructor(t){s(this,t);this.size="m";this.color="neutral"}render(){return t(e,{key:"8694237120321b5cea6dbe4c4152edfde30228a1",class:b.root,color:this.color,size:this.size},t("slot",{key:"4c382e33221ff8b874a7f8544d94261298c3cf28",name:"input"}),t("slot",{key:"3b56d19118f2b75964a9ed62ae2210e7705ba4a5",name:"button-erase"}),t("slot",{key:"c829a3df01bc53fab6b3022aac353ebe06b088db",name:"button"}))}get host(){return a(this)}};export{f as gov_form_search};
|
|
2
|
-
//# sourceMappingURL=p-bd389bfd.entry.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as t,c as s,h as i,H as e,g as o}from"./p-ClISz4NF.js";import{c as h}from"./p-vN03FcXN.js";import{g as n,a,t as l}from"./p-CoD1xawt.js";import{g as r}from"./p-B6CqPcY_.js";import{i as c}from"./p-CzXeijOj.js";import{A as f,a as d}from"./p-Bz_RzYFb.js";import"./p-BcQO4NH2.js";import"./p-CQvUntGY.js";import"./p-EeKNA85D.js";import"./p-U40vKHrs.js";import"./p-DYcNEwSZ.js";import"./p-DBXGhafv.js";const m={root:"gov-form-file",area:"gov-form-file__area",input:"gov-form-file__input",inputFocus:"gov-form-file__input-focus",attachments:"gov-form-file__attachments"};function p(t){const s=["bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];let i=0,e=parseInt(t,10)||0;while(e>=1024&&++i){e=e/1024}return e.toFixed(e<10&&i>0?1:0)+" "+s[i]}function u(t,s){if(typeof s==="string"&&s.length){return s.replace(/\s/g,"").split(",").filter((s=>new RegExp(s.replace("*",".*")).test(t.type))).length>0}else{return true}}function v(t,s){const i=Math.round(t.size);return i<=s}const g=class{constructor(i){t(this,i);this.govFocus=s(this,"gov-focus");this.govBlur=s(this,"gov-blur");this.govFiles=s(this,"gov-files");this.govAddFile=s(this,"gov-add-file");this.govRemoveFile=s(this,"gov-remove-file");this.eventsRegistered=false;this.expanded=false;this.required=false;this.disabled=false;this.resetAfterPick=false;this.ignoreFileDuplicationCheck=false;this.displayAttachments=true;this.multiple=false;this.maxFileSize=-1;this.errorSize="Soubor je větší než povolená velikost {FILE_SIZE}";this.errorAccept="Soubor tohoto typu není povolen";this.accessibleAttachmentsLabel="Přílohy";this.files=[];this.inheritedAttributes={};this.fileId=h("GovInputFile");this.h=n(this.host);this.f=r(this.h)}watchControlAttrs(){this.passControlAttrs()}passControlAttrs(){this.f.passAttrToControl("invalid",a(this.invalid));this.f.passAttrToControl("disabled",a(this.disabled));this.f.passAttrToControl("type","File")}registerListeners(){if(this.eventsRegistered){return}this.eventsRegistered=true;function t(){this.areaRef.classList.add("highlight")}function s(){this.areaRef.classList.remove("highlight")}this.inputRef.addEventListener("change",(t=>{t.preventDefault();t.stopPropagation();const s=t.target.files;if(this.resetAfterPick){if(s.length){this.validateFiles(s)}}else{this.validateFiles(s)}}),false);if(this.expanded){const i=["dragover","dragleave"];const e=["dragenter","dragover","mouseenter"];const o=["dragleave","mouseleave"];i.map((t=>this.inputRef.addEventListener(t,this.preventDefaults.bind(this),false)));e.map((s=>this.inputRef.addEventListener(s,t.bind(this),false)));o.forEach((t=>this.inputRef.addEventListener(t,s.bind(this),false)))}}preventDefaults(t){t.preventDefault();t.stopPropagation()}handleDrop(t){const s=t.dataTransfer;this.validateFiles(s.files)}validateFiles(t){let s=[];Array.from(t).map((t=>{const i=this.files.find((s=>s.file.name===t.name&&s.file.size===t.size))||null;if(i===null||this.ignoreFileDuplicationCheck){const i=typeof this.maxFileSize==="number"&&this.maxFileSize>0?v(t,this.maxFileSize):true;const e=u(t,this.accept);const o={id:h("GovFormFile"),file:t,acceptValid:e,sizeValid:i};if(this.displayAttachments){this.files=[...this.files,o]}else{s=[...s,o]}this.govAddFile.emit({component:m.root,file:o})}}));this.govFiles.emit({component:m.root,files:s.length?s:this.files});if(this.resetAfterPick){this.reset().finally()}}componentDidLoad(){this.attributeObserver=new f(this.host,((t,s)=>{this.onAriaAttributeChange(t,s)}));this.attributeObserver.startObserving(d)}componentWillLoad(){this.f.passAttrToLabel("required",String(this.required));this.passControlAttrs();this.inheritedAttributes=c(this.host)}async componentDidRender(){this.registerListeners()}disconnectedCallback(){var t;(t=this.attributeObserver)===null||t===void 0?void 0:t.stopObserving()}onAriaAttributeChange(t,s){this.host.removeAttribute(t);this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[t]:s})}render(){return i(e,{key:"0f005cd699699df5d67c1ae5a1ce69bcbe14df08",class:this.h.classes([m.root]),invalid:l(this.invalid),expanded:l(this.expanded)},i("div",{key:"85de8e3bbbed08f63a93b874799b2e76311320dd",class:m.area,ref:t=>this.areaRef=t},i("slot",{key:"d67d074f20d899d81c37118eeb872eace16be983"}),i("input",Object.assign({key:"b0be06c28155cd0bfd13aa6926f05718fe58ca2d",class:m.input,ref:t=>this.inputRef=t,id:this.identifier||this.fileId,type:"file",name:this.name,accept:this.accept,multiple:this.multiple,onChange:this.onChangeHandler.bind(this),onFocus:this.onFocusHandler.bind(this),onBlur:this.onBlurHandler.bind(this),required:this.required,disabled:this.disabled},this.inheritedAttributes,{"aria-required":l(this.required),"aria-invalid":l(this.invalid),"aria-disabled":l(this.disabled)})),i("div",{key:"bf27e1a3806a4334ec9476171c64a5dfe96a1040",class:m.inputFocus})),this.h.hasSlot("attachments")?i("div",{class:m.attachments},i("slot",{name:"attachments"})):null,this.files.length&&this.displayAttachments?i("div",{class:m.attachments},i("gov-attachments",{label:this.accessibleAttachmentsLabel,"accessible-label":this.accessibleAttachmentsLabel},this.files.map((t=>i("gov-attachments-item",{"accessible-remove-labelledby":t.id,"on-gov-remove":()=>this.onRemoveFileHandler(t)},t.file.name,i("span",{slot:"name"},t.file.name),t.acceptValid===false?i("gov-form-message",{slot:"message",color:"error"},i("gov-icon",{slot:"icon",name:"exclamation-triangle-fill",type:"components"}),t.acceptValid===false?this.errorAccept:null):null,t.sizeValid===false?i("gov-form-message",{slot:"message",color:"error"},i("gov-icon",{slot:"icon",name:"exclamation-triangle-fill",type:"components"}),this.errorSize.replace("{FILE_SIZE}",p(this.maxFileSize))):null,i("span",{slot:"info"},"(",p(t.file.size),")")))))):null)}onRemoveFileHandler(t){const s=this.files.findIndex((s=>s.id===t.id));if(s!==-1){const t=this.files;const i=this.files[s];t.splice(s,1);this.files=[...t];this.govRemoveFile.emit({component:m.root,file:i});this.govFiles.emit({component:m.root,files:t})}}onFocusHandler(t){t.stopPropagation();this.govFocus.emit({component:m.root,originalEvent:t})}onBlurHandler(t){t.stopPropagation();this.govBlur.emit({component:m.root,originalEvent:t})}onChangeHandler(t){t.stopPropagation()}async getRef(){return this.inputRef}async getAreaRef(){return this.areaRef}async reset(){this.files=[];this.inputRef.value=""}get host(){return o(this)}static get watchers(){return{disabled:["watchControlAttrs"],invalid:["watchControlAttrs"]}}};export{g as gov_form_file};
|
|
2
|
-
//# sourceMappingURL=p-c21bc8f9.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["FormFileClass","root","area","input","inputFocus","attachments","formatBytes","bytes","units","l","n","parseInt","toFixed","fileAcceptValidation","file","accept","length","replace","split","filter","RegExp","test","type","fileSizeValidation","maxSize","fileSize","Math","round","size","GovFormFile","constructor","hostRef","this","eventsRegistered","expanded","required","disabled","resetAfterPick","ignoreFileDuplicationCheck","displayAttachments","multiple","maxFileSize","errorSize","errorAccept","accessibleAttachmentsLabel","files","inheritedAttributes","fileId","createID","h","govHost","host","f","govForm","watchControlAttrs","passControlAttrs","passAttrToControl","toBoolAttr","invalid","registerListeners","highlight","areaRef","classList","add","unhighlight","remove","inputRef","addEventListener","e","preventDefault","stopPropagation","target","validateFiles","events","inEvents","outEvents","map","eventName","preventDefaults","bind","forEach","handleDrop","dataTransfer","filesBuffer","Array","from","isFile","find","item","name","isSizeValid","isAcceptValid","newFile","id","acceptValid","sizeValid","govAddFile","emit","component","govFiles","reset","finally","componentDidLoad","attributeObserver","AttributeObserver","attributeName","newValue","onAriaAttributeChange","startObserving","ariaAttributes","componentWillLoad","passAttrToLabel","String","inheritAriaAttributes","componentDidRender","disconnectedCallback","_a","stopObserving","removeAttribute","Object","assign","render","Host","key","class","classes","toBoolAttrIfDefined","ref","el","identifier","onChange","onChangeHandler","onFocus","onFocusHandler","onBlur","onBlurHandler","hasSlot","label","onRemoveFileHandler","slot","color","index","findIndex","removeFile","splice","govRemoveFile","govFocus","originalEvent","govBlur","getRef","getAreaRef","value"],"sources":["../../../packages/core/src/components/gov-form/file/constants.ts","../../../packages/core/src/utils/file.utils.ts","../../../packages/core/src/components/gov-form/file/gov-form-file.tsx"],"sourcesContent":["export const FormFileClass = {\n\troot: 'gov-form-file',\n\tarea: 'gov-form-file__area',\n\tinput: 'gov-form-file__input',\n\tinputFocus: 'gov-form-file__input-focus',\n\tattachments: 'gov-form-file__attachments',\n}\n","export function formatBytes(bytes: any): string {\n\tconst units = ['bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']\n\tlet l = 0,\n\t\tn = parseInt(bytes, 10) || 0\n\n\twhile (n >= 1024 && ++l) {\n\t\tn = n / 1024\n\t}\n\n\treturn n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l]\n}\n\nexport function fileAcceptValidation(file: File, accept: string): boolean {\n\tif (typeof accept === 'string' && accept.length) {\n\t\treturn (\n\t\t\taccept\n\t\t\t\t.replace(/\\s/g, '')\n\t\t\t\t.split(',')\n\t\t\t\t.filter(accept => {\n\t\t\t\t\treturn new RegExp(accept.replace('*', '.*')).test(file.type)\n\t\t\t\t}).length > 0\n\t\t)\n\t} else {\n\t\treturn true\n\t}\n}\n\nexport function fileSizeValidation(file: File, maxSize: number): boolean {\n\tconst fileSize = Math.round(file.size)\n\treturn fileSize <= maxSize\n}\n","import {Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch} from \"@stencil/core\"\nimport {createID} from \"../../../utils/string.utils\"\nimport {FormFileClass} from \"./constants\"\nimport {govHost, toBoolAttr, toBoolAttrIfDefined} from \"../../../helpers/Dom/template\"\nimport {fileAcceptValidation, fileSizeValidation, formatBytes} from \"../../../utils/file.utils\"\nimport {GovForm} from \"../../../helpers/Dom/form.types\"\nimport {GovHost} from \"../../../helpers/Dom/template.types\"\nimport {govForm} from \"../../../helpers/Dom/form\"\nimport {GovFormFileEvent, GovFormFileItem} from \"./gov-form-file.types\"\nimport {inheritAriaAttributes} from \"../../../helpers/Accessibility/accessibility\";\nimport {AttributeObserver, Attributes} from \"../../../helpers/Dom/attribute\";\nimport {ariaAttributes} from \"../../../helpers/Accessibility/attributes\";\n\n@Component({\n\ttag: \"gov-form-file\",\n})\nexport class GovFormFile {\n\tprivate f: GovForm\n\tprivate readonly h: GovHost\n\n\tprivate areaRef?: HTMLDivElement\n\tprivate inputRef?: HTMLInputElement\n\tprivate readonly fileId: string\n\tprivate attributeObserver: AttributeObserver\n\tprivate eventsRegistered = false\n\n\tconstructor() {\n\t\tthis.fileId = createID(\"GovInputFile\")\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormFileElement\n\t/**\n\t * Expands the file input to fill 100% of the container width.\n\t */\n\t@Prop() readonly expanded: boolean = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the File component disabled.\n\t * This prevents users from being able to interact with the File, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop({reflect: true}) readonly disabled: boolean = false\n\t/**\n\t * After selecting the files, the main input element will be reset.\n\t * The propagation of the event with the selected files will not be affected.\n\t */\n\t@Prop({attribute: \"reset-after-pick\"}) readonly resetAfterPick: boolean = false\n\t/**\n\t * Selected files will not be checked for duplicates based on name and size.\n\t */\n\t@Prop({attribute: \"ignore-file-duplication-check\"}) readonly ignoreFileDuplicationCheck: boolean = false\n\t/**\n\t * Show list of attachments\n\t */\n\t@Prop({attribute: \"display-attachments\"}) readonly displayAttachments: boolean = true\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept\n\t */\n\t@Prop() readonly accept: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/multiple\n\t */\n\t@Prop() readonly multiple: boolean = false\n\t/**\n\t * Maximum embedded file size\n\t */\n\t@Prop({attribute: \"max-file-size\"}) readonly maxFileSize: number = -1\n\t/**\n\t * Custom File identifier.\n\t */\n\t@Prop({attribute: \"identifier\"}) readonly identifier: string\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Error message when the maximum file size is exceeded\n\t */\n\t@Prop({attribute: \"error-size\"}) readonly errorSize: string = \"Soubor je větší než povolená velikost {FILE_SIZE}\"\n\t/**\n\t * Insert unsupported file error message\n\t */\n\t@Prop({attribute: \"error-accept\"}) readonly errorAccept: string = \"Soubor tohoto typu není povolen\"\n\t/**\n\t * Adds accessible label for the list of attachments.\n\t */\n\t@Prop({attribute: \"accessible-attachments-label\"}) readonly accessibleAttachmentsLabel: string = \"Přílohy\"\n\t/**\n\t * Emitted when the File has focus.\n\t */\n\t@Event({eventName: \"gov-focus\"}) govFocus: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Emitted when the File loses focus.\n\t */\n\t@Event({eventName: \"gov-blur\"}) govBlur: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when the list of inserted files is changed\n\t */\n\t@Event({eventName: \"gov-files\"}) govFiles: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a new file is added\n\t */\n\t@Event({eventName: \"gov-add-file\"}) govAddFile: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a file is removed from the list\n\t */\n\t@Event({eventName: \"gov-remove-file\"}) govRemoveFile: EventEmitter<GovFormFileEvent>\n\n\n\t@Watch(\"disabled\")\n\t@Watch(\"invalid\")\n\twatchControlAttrs(): void {\n\t\tthis.passControlAttrs()\n\t}\n\n\t@State() files: GovFormFileItem[] = []\n\t@State() inheritedAttributes: Attributes = {}\n\n\n\n\tprivate passControlAttrs() {\n\t\tthis.f.passAttrToControl(\"invalid\", toBoolAttr(this.invalid))\n\t\tthis.f.passAttrToControl(\"disabled\", toBoolAttr(this.disabled))\n\t\tthis.f.passAttrToControl(\"type\", \"File\")\n\t}\n\n\n\tprivate registerListeners() {\n\t\tif (this.eventsRegistered) {\n\t\t\treturn\n\t\t}\n\t\tthis.eventsRegistered = true\n\n\t\tfunction highlight() {\n\t\t\tthis.areaRef.classList.add(\"highlight\")\n\t\t}\n\n\t\tfunction unhighlight() {\n\t\t\tthis.areaRef.classList.remove(\"highlight\")\n\t\t}\n\n\t\tthis.inputRef.addEventListener(\n\t\t\t\"change\",\n\t\t\te => {\n\t\t\t\te.preventDefault()\n\t\t\t\te.stopPropagation()\n\t\t\t\tconst files = (e.target as HTMLInputElement).files\n\t\t\t\tif (this.resetAfterPick) {\n\t\t\t\t\tif (files.length) {\n\t\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t}\n\t\t\t},\n\t\t\tfalse,\n\t\t)\n\n\t\tif (this.expanded) {\n\t\t\tconst events = [\"dragover\", \"dragleave\"]\n\t\t\tconst inEvents = [\"dragenter\", \"dragover\", \"mouseenter\"]\n\t\t\tconst outEvents = [\"dragleave\", \"mouseleave\"]\n\n\t\t\tevents.map(eventName => this.inputRef.addEventListener(eventName, this.preventDefaults.bind(this), false))\n\t\t\tinEvents.map(eventName => this.inputRef.addEventListener(eventName, highlight.bind(this), false))\n\t\t\toutEvents.forEach(eventName => this.inputRef.addEventListener(eventName, unhighlight.bind(this), false))\n\t\t}\n\t}\n\n\tpreventDefaults(e) {\n\t\te.preventDefault()\n\t\te.stopPropagation()\n\t}\n\n\thandleDrop(e: DragEvent) {\n\t\tconst dataTransfer = e.dataTransfer\n\t\tthis.validateFiles(dataTransfer.files)\n\t}\n\n\tprivate validateFiles(files: FileList) {\n\t\tlet filesBuffer: GovFormFileItem[] = []\n\t\tArray.from(files).map(file => {\n\t\t\tconst isFile = this.files.find(item => item.file.name === file.name && item.file.size === file.size) || null\n\t\t\tif (isFile === null || this.ignoreFileDuplicationCheck) {\n\t\t\t\tconst isSizeValid = typeof this.maxFileSize === \"number\" && this.maxFileSize > 0 ? fileSizeValidation(file, this.maxFileSize) : true\n\t\t\t\tconst isAcceptValid = fileAcceptValidation(file, this.accept)\n\t\t\t\tconst newFile = {\n\t\t\t\t\tid: createID(\"GovFormFile\"),\n\t\t\t\t\tfile,\n\t\t\t\t\tacceptValid: isAcceptValid,\n\t\t\t\t\tsizeValid: isSizeValid,\n\t\t\t\t}\n\t\t\t\tif (this.displayAttachments) {\n\t\t\t\t\tthis.files = [...this.files, newFile]\n\t\t\t\t} else {\n\t\t\t\t\tfilesBuffer = [...filesBuffer, newFile]\n\t\t\t\t}\n\t\t\t\tthis.govAddFile.emit({\n\t\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\t\tfile: newFile,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\n\t\tthis.govFiles.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\tfiles: filesBuffer.length ? filesBuffer : this.files,\n\t\t})\n\n\t\tif (this.resetAfterPick) {\n\t\t\tthis.reset().finally()\n\t\t}\n\t}\n\n\tcomponentDidLoad() {\n\t\tthis.attributeObserver = new AttributeObserver(this.host, (attributeName, newValue) => {\n\t\t\tthis.onAriaAttributeChange(attributeName, newValue);\n\t\t});\n\n\t\tthis.attributeObserver.startObserving(ariaAttributes);\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.f.passAttrToLabel(\"required\", String(this.required))\n\t\tthis.passControlAttrs()\n\t\tthis.inheritedAttributes = inheritAriaAttributes(this.host);\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.registerListeners()\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.attributeObserver?.stopObserving();\n\t}\n\n\tonAriaAttributeChange(attributeName: string, newValue: string) {\n\t\tthis.host.removeAttribute(attributeName)\n\t\tthis.inheritedAttributes = {...this.inheritedAttributes, [attributeName]: newValue};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={this.h.classes([FormFileClass.root])}\n\t\t\t\t invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t expanded={toBoolAttrIfDefined(this.expanded)}>\n\t\t\t\t<div class={FormFileClass.area} ref={el => (this.areaRef = el as HTMLDivElement)}>\n\t\t\t\t\t<slot/>\n\t\t\t\t\t<input\n\t\t\t\t\t\tclass={FormFileClass.input}\n\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\tid={this.identifier || this.fileId}\n\t\t\t\t\t\ttype=\"file\"\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\taccept={this.accept}\n\t\t\t\t\t\tmultiple={this.multiple}\n\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t{...this.inheritedAttributes}\n\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t/>\n\t\t\t\t\t<div class={FormFileClass.inputFocus}/>\n\t\t\t\t</div>\n\n\t\t\t\t{this.h.hasSlot(\"attachments\") ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<slot name={\"attachments\"}/>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\n\t\t\t\t{this.files.length && this.displayAttachments ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<gov-attachments label={this.accessibleAttachmentsLabel}\n\t\t\t\t\t\t\t\t\t\t accessible-label={this.accessibleAttachmentsLabel}>\n\t\t\t\t\t\t\t{this.files.map(item => (\n\t\t\t\t\t\t\t\t<gov-attachments-item accessible-remove-labelledby={item.id}\n\t\t\t\t\t\t\t\t\t\t\t\t\t on-gov-remove={() => this.onRemoveFileHandler(item)}>\n\t\t\t\t\t\t\t\t\t{item.file.name}\n\t\t\t\t\t\t\t\t\t<span slot=\"name\">{item.file.name}</span>\n\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? this.errorAccept : null}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t{item.sizeValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{this.errorSize.replace(\"{FILE_SIZE}\", formatBytes(this.maxFileSize))}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t<span slot=\"info\">({formatBytes(item.file.size)})</span>\n\t\t\t\t\t\t\t\t</gov-attachments-item>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</gov-attachments>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onRemoveFileHandler(file: GovFormFileItem) {\n\t\tconst index = this.files.findIndex(item => item.id === file.id)\n\t\tif (index !== -1) {\n\t\t\tconst files = this.files\n\t\t\tconst removeFile = this.files[index]\n\t\t\tfiles.splice(index, 1)\n\t\t\tthis.files = [...files]\n\t\t\tthis.govRemoveFile.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfile: removeFile,\n\t\t\t})\n\t\t\tthis.govFiles.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfiles,\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\te.stopPropagation()\n\t}\n\n\t/**\n\t * Returns the reference of the native element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Returns the reference of the native area element\n\t */\n\t@Method()\n\tasync getAreaRef(): Promise<HTMLDivElement> {\n\t\treturn this.areaRef\n\t}\n\n\t/**\n\t * Remove all files from component state\n\t */\n\t@Method()\n\tasync reset(): Promise<void> {\n\t\tthis.files = []\n\t\tthis.inputRef.value = '';\n\t}\n}\n"],"mappings":"oZAAO,MAAMA,EAAgB,CAC5BC,KAAM,gBACNC,KAAM,sBACNC,MAAO,uBACPC,WAAY,6BACZC,YAAa,8BCLR,SAAUC,EAAYC,GAC3B,MAAMC,EAAQ,CAAC,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