wcs-core 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +59 -90
- package/dist/cjs/accessibility-e99b032d.js +68 -0
- package/dist/cjs/accessibility-e99b032d.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/wcs-checkbox.cjs.entry.js +1 -0
- package/dist/cjs/wcs-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-counter.cjs.entry.js +1 -0
- package/dist/cjs/wcs-counter.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-dropdown.cjs.entry.js +3 -5
- package/dist/cjs/wcs-dropdown.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-grid.cjs.entry.js +1 -1
- package/dist/cjs/wcs-grid.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-input.cjs.entry.js +1 -3
- package/dist/cjs/wcs-input.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-modal.cjs.entry.js +68 -6
- package/dist/cjs/wcs-modal.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-native-select.cjs.entry.js +19 -0
- package/dist/cjs/wcs-native-select.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-radio-group.cjs.entry.js +48 -4
- package/dist/cjs/wcs-radio-group.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-radio.cjs.entry.js +17 -4
- package/dist/cjs/wcs-radio.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-tab.cjs.entry.js +1 -1
- package/dist/cjs/wcs-tab.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-tabs.cjs.entry.js +37 -1
- package/dist/cjs/wcs-tabs.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-textarea.cjs.entry.js +3 -2
- package/dist/cjs/wcs-textarea.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/checkbox/checkbox.js +1 -0
- package/dist/collection/components/checkbox/checkbox.js.map +1 -1
- package/dist/collection/components/counter/counter.js +1 -0
- package/dist/collection/components/counter/counter.js.map +1 -1
- package/dist/collection/components/dropdown/dropdown.js +1 -0
- package/dist/collection/components/dropdown/dropdown.js.map +1 -1
- package/dist/collection/components/grid/grid.js +1 -1
- package/dist/collection/components/grid/grid.js.map +1 -1
- package/dist/collection/components/input/input.js +2 -4
- package/dist/collection/components/input/input.js.map +1 -1
- package/dist/collection/components/modal/modal.js +71 -6
- package/dist/collection/components/modal/modal.js.map +1 -1
- package/dist/collection/components/native-select/{native-select.component.js → native-select.js} +58 -7
- package/dist/collection/components/native-select/native-select.js.map +1 -0
- package/dist/collection/components/radio/radio.css +13 -1
- package/dist/collection/components/radio/{radio.component.js → radio.js} +37 -4
- package/dist/collection/components/radio/radio.js.map +1 -0
- package/dist/collection/components/radio-group/radio-group.js +60 -4
- package/dist/collection/components/radio-group/radio-group.js.map +1 -1
- package/dist/collection/components/tab/tab.js +1 -1
- package/dist/collection/components/tab/tab.js.map +1 -1
- package/dist/collection/components/tabs/tabs.js +54 -1
- package/dist/collection/components/tabs/tabs.js.map +1 -1
- package/dist/collection/components/textarea/textarea.js +8 -4
- package/dist/collection/components/textarea/textarea.js.map +1 -1
- package/dist/collection/utils/accessibility.js +58 -0
- package/dist/collection/utils/accessibility.js.map +1 -1
- package/dist/esm/accessibility-ffa12842.js +65 -0
- package/dist/esm/accessibility-ffa12842.js.map +1 -0
- package/dist/esm/{helpers-1f7170dd.js → helpers-1d55b67f.js} +2 -2
- package/dist/esm/{helpers-1f7170dd.js.map → helpers-1d55b67f.js.map} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/wcs-button.entry.js +1 -1
- package/dist/esm/wcs-checkbox.entry.js +1 -0
- package/dist/esm/wcs-checkbox.entry.js.map +1 -1
- package/dist/esm/wcs-com-nav-category.entry.js +1 -1
- package/dist/esm/wcs-com-nav-submenu.entry.js +1 -1
- package/dist/esm/wcs-com-nav.entry.js +1 -1
- package/dist/esm/wcs-counter.entry.js +2 -1
- package/dist/esm/wcs-counter.entry.js.map +1 -1
- package/dist/esm/wcs-dropdown-item.entry.js +1 -1
- package/dist/esm/wcs-dropdown.entry.js +3 -5
- package/dist/esm/wcs-dropdown.entry.js.map +1 -1
- package/dist/esm/wcs-galactic-menu.entry.js +1 -1
- package/dist/esm/wcs-grid.entry.js +1 -1
- package/dist/esm/wcs-grid.entry.js.map +1 -1
- package/dist/esm/wcs-input.entry.js +2 -4
- package/dist/esm/wcs-input.entry.js.map +1 -1
- package/dist/esm/wcs-modal.entry.js +69 -7
- package/dist/esm/wcs-modal.entry.js.map +1 -1
- package/dist/esm/wcs-native-select.entry.js +19 -0
- package/dist/esm/wcs-native-select.entry.js.map +1 -1
- package/dist/esm/wcs-nav-item.entry.js +1 -1
- package/dist/esm/wcs-radio-group.entry.js +48 -4
- package/dist/esm/wcs-radio-group.entry.js.map +1 -1
- package/dist/esm/wcs-radio.entry.js +18 -5
- package/dist/esm/wcs-radio.entry.js.map +1 -1
- package/dist/esm/wcs-select_2.entry.js +1 -1
- package/dist/esm/wcs-tab.entry.js +1 -1
- package/dist/esm/wcs-tab.entry.js.map +1 -1
- package/dist/esm/wcs-tabs.entry.js +37 -1
- package/dist/esm/wcs-tabs.entry.js.map +1 -1
- package/dist/esm/wcs-textarea.entry.js +4 -3
- package/dist/esm/wcs-textarea.entry.js.map +1 -1
- package/dist/esm/wcs.js +1 -1
- package/dist/types/components/input/input.d.ts +1 -3
- package/dist/types/components/modal/modal.d.ts +25 -5
- package/dist/types/components/native-select/{native-select.component.d.ts → native-select.d.ts} +22 -5
- package/dist/types/components/radio/{radio.component.d.ts → radio.d.ts} +2 -0
- package/dist/types/components/radio-group/radio-group.d.ts +3 -0
- package/dist/types/components/tabs/tabs.d.ts +13 -0
- package/dist/types/components/textarea/textarea.d.ts +2 -2
- package/dist/types/components.d.ts +74 -24
- package/dist/types/utils/accessibility.d.ts +2 -0
- package/dist/wcs/p-0f8db386.js +2 -0
- package/dist/wcs/p-0f8db386.js.map +1 -0
- package/dist/wcs/{p-4b4d53e2.entry.js → p-1f8c73eb.entry.js} +2 -2
- package/dist/wcs/{p-554ca93c.entry.js → p-2185bf8b.entry.js} +2 -2
- package/dist/wcs/{p-22480bd8.entry.js → p-2f63d6c5.entry.js} +2 -2
- package/dist/wcs/p-2f63d6c5.entry.js.map +1 -0
- package/dist/wcs/p-39821dd2.entry.js +2 -0
- package/dist/wcs/p-39821dd2.entry.js.map +1 -0
- package/dist/wcs/{p-84afb8af.entry.js → p-3b1fc676.entry.js} +2 -2
- package/dist/wcs/{p-12ac2547.js → p-3dc6b507.js} +2 -2
- package/dist/wcs/p-4ffe4539.entry.js +2 -0
- package/dist/wcs/p-4ffe4539.entry.js.map +1 -0
- package/dist/wcs/p-61cab06f.entry.js +2 -0
- package/dist/wcs/p-61cab06f.entry.js.map +1 -0
- package/dist/wcs/{p-15058c29.entry.js → p-6de70331.entry.js} +2 -2
- package/dist/wcs/p-6de70331.entry.js.map +1 -0
- package/dist/wcs/{p-b6cd196d.entry.js → p-7269272f.entry.js} +2 -2
- package/dist/wcs/{p-966a241e.entry.js → p-7519a270.entry.js} +2 -2
- package/dist/wcs/{p-6b66ce85.entry.js → p-8c4ed883.entry.js} +2 -2
- package/dist/wcs/p-8c4ed883.entry.js.map +1 -0
- package/dist/wcs/p-8fed8b1c.entry.js +2 -0
- package/dist/wcs/p-8fed8b1c.entry.js.map +1 -0
- package/dist/wcs/{p-d2da0c9f.entry.js → p-ac106663.entry.js} +2 -2
- package/dist/wcs/{p-d2da0c9f.entry.js.map → p-ac106663.entry.js.map} +1 -1
- package/dist/wcs/{p-b229a91c.entry.js → p-cb90bc3a.entry.js} +2 -2
- package/dist/wcs/{p-f82e7a61.entry.js → p-e348058b.entry.js} +2 -2
- package/dist/wcs/{p-405140f9.entry.js → p-ec84d6fd.entry.js} +2 -2
- package/dist/wcs/{p-26c4c983.entry.js → p-ed3132be.entry.js} +2 -2
- package/dist/wcs/p-ed3132be.entry.js.map +1 -0
- package/dist/wcs/p-f06f48f3.entry.js +2 -0
- package/dist/wcs/{p-6acbf38a.entry.js.map → p-f06f48f3.entry.js.map} +1 -1
- package/dist/wcs/p-f20b9024.entry.js +2 -0
- package/dist/wcs/p-f20b9024.entry.js.map +1 -0
- package/dist/wcs/p-f489793d.entry.js +2 -0
- package/dist/wcs/p-f489793d.entry.js.map +1 -0
- package/dist/wcs/wcs.esm.js +1 -1
- package/dist/wcs/wcs.esm.js.map +1 -1
- package/package.json +3 -2
- package/dist/collection/components/native-select/native-select.component.js.map +0 -1
- package/dist/collection/components/radio/radio.component.js.map +0 -1
- package/dist/wcs/p-069555a1.entry.js +0 -2
- package/dist/wcs/p-069555a1.entry.js.map +0 -1
- package/dist/wcs/p-07b8cd36.entry.js +0 -2
- package/dist/wcs/p-07b8cd36.entry.js.map +0 -1
- package/dist/wcs/p-15058c29.entry.js.map +0 -1
- package/dist/wcs/p-22480bd8.entry.js.map +0 -1
- package/dist/wcs/p-26c4c983.entry.js.map +0 -1
- package/dist/wcs/p-64dd7356.entry.js +0 -2
- package/dist/wcs/p-64dd7356.entry.js.map +0 -1
- package/dist/wcs/p-6acbf38a.entry.js +0 -2
- package/dist/wcs/p-6b66ce85.entry.js.map +0 -1
- package/dist/wcs/p-732b2faa.entry.js +0 -2
- package/dist/wcs/p-732b2faa.entry.js.map +0 -1
- package/dist/wcs/p-94d95b99.entry.js +0 -2
- package/dist/wcs/p-94d95b99.entry.js.map +0 -1
- package/dist/wcs/p-b856f2f6.entry.js +0 -2
- package/dist/wcs/p-b856f2f6.entry.js.map +0 -1
- /package/dist/wcs/{p-4b4d53e2.entry.js.map → p-1f8c73eb.entry.js.map} +0 -0
- /package/dist/wcs/{p-554ca93c.entry.js.map → p-2185bf8b.entry.js.map} +0 -0
- /package/dist/wcs/{p-84afb8af.entry.js.map → p-3b1fc676.entry.js.map} +0 -0
- /package/dist/wcs/{p-12ac2547.js.map → p-3dc6b507.js.map} +0 -0
- /package/dist/wcs/{p-b6cd196d.entry.js.map → p-7269272f.entry.js.map} +0 -0
- /package/dist/wcs/{p-966a241e.entry.js.map → p-7519a270.entry.js.map} +0 -0
- /package/dist/wcs/{p-b229a91c.entry.js.map → p-cb90bc3a.entry.js.map} +0 -0
- /package/dist/wcs/{p-f82e7a61.entry.js.map → p-e348058b.entry.js.map} +0 -0
- /package/dist/wcs/{p-405140f9.entry.js.map → p-ec84d6fd.entry.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"wcs-radio.entry.js","mappings":";;;AAAA,MAAM,QAAQ,GAAG,
|
|
1
|
+
{"file":"wcs-radio.entry.js","mappings":";;;AAAA,MAAM,QAAQ,GAAG,63FAA63F;;MCuBj4F,KAAK;;;;IACN,YAAO,GAAG,UAAU,cAAc,EAAE,EAAE,CAAC;gBAGiB,OAAO;;;mBAOvB,KAAK;oBAIjB,KAAK;;;EAOzC,SAAS,CAAC,MAAqB;IAC3B,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE;MAChE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;MACpB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;KACxB;GACJ;EAGD,cAAc,CAAC,QAAiB;IAC5B,IAAG,QAAQ,EAAE;MACT,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;KACxB;SAAM;MACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;KACxB;GACJ;EAED,iBAAiB;IACb,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;;MAE1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC;KACxC;GACJ;EAED,gBAAgB;IACZ,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACzD,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;MACrC,IAAI,CAAC,oBAAoB,EAAE,CAAC;MAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;KACvB,CAAC,CAAA;GACL;EAED,oBAAoB;IAChB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;MACpB,KAAK,EAAE,IAAI,CAAC,KAAK;MACjB,MAAM,EAAE,IAAI,CAAC,EAAE;MACf,KAAK,EAAE,IAAI,CAAC,KAAK;KACpB,CAAC,CAAC;GACN;EAED,MAAM;IAEF,QACI,EAAC,IAAI,kBAAC,IAAI,EAAC,QAAQ,KAAM,IAAI,CAAC,QAAQ,GAAG,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAC,GAAG,EAAE,IACxD,aACI,EAAE,EAAE,IAAI,CAAC,OAAO,EAChB,IAAI,EAAC,OAAO,EACZ,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,mBACR,IAAI,CAAC,QAAQ,GAAG,MAAM,GAAG,IAAI,kBAC9B,GAAG,IAAI,CAAC,OAAO,EAAE,GACjC,EACF,aAAO,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,IAAG,IAAI,CAAC,KAAK,CAAS,CACpD,EACT;GACL;;;;;;;AAGL,IAAI,cAAc,GAAG,CAAC,CAAC;;;;;","names":[],"sources":["./src/components/radio/radio.scss?tag=wcs-radio&encapsulation=shadow","./src/components/radio/radio.tsx"],"sourcesContent":["@import '../../style/focus-outline.scss';\n\n:host {\n width: fit-content;\n}\n\n:host([mode=radio]:focus-within) {\n transition: none;\n @include focus-outline($border-radius: 0.5rem, $outline-offset: 0);\n}\n\n:host([mode=horizontal]:focus-within) {\n transition: none;\n @include focus-outline($border-radius: 0.5rem, $outline-offset: 2px);\n}\n\n:host([mode=radio]),\n:host([mode=horizontal]) {\n input {\n position: absolute;\n opacity: 0;\n height: 1px;\n width: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n\n label {\n margin-bottom: 0;\n color: var(--wcs-text-medium);\n background-color: transparent;\n font-weight: 500 !important;\n display: inline-block;\n\n &:before {\n border-radius: 50%;\n border: 2px solid var(--wcs-text-disabled);\n position: relative;\n width: 1.125rem;\n height: 1.125rem;\n pointer-events: none;\n content: \"\";\n background-color: var(--wcs-white);\n }\n\n &:after {\n transition: 0.175s ease-in-out;\n position: relative;\n width: 1.125rem;\n height: 1.125rem;\n content: \"\";\n background: no-repeat 50% / 50% 50%;\n }\n }\n}\n\n:host([disabled]) {\n label {\n color: var(--wcs-text-disabled);\n cursor: not-allowed;\n }\n}\n\n:host(:not([disabled])) {\n label {\n cursor: pointer;\n }\n}\n\n:host([mode=radio][checked]),\n:host([mode=horizontal][checked]) {\n label {\n color: var(--wcs-primary);\n\n &:before {\n border-color: var(--wcs-primary);\n background-color: var(--wcs-primary);\n outline: solid 2px var(--wcs-white);\n outline-offset: -4px;\n }\n }\n}\n\n:host([mode=radio]:hover):not([disabled]),\n:host([mode=horizontal]:hover):not([disabled]) {\n label {\n color: var(--wcs-primary);\n\n &:before {\n border-color: var(--wcs-primary);\n }\n }\n}\n\n:host([mode=radio]) {\n label {\n padding: 0.125rem;\n border: none;\n transition: 0.175s ease-in-out;\n\n &:before {\n transition: 0.175s ease-in-out;\n margin-right: var(--wcs-base-margin);\n display: inline-block;\n top: 3px;\n box-sizing: border-box;\n }\n\n &:empty::before {\n margin-right: 0;\n }\n }\n}\n\n:host([mode=horizontal]) {\n height: fit-content;\n label {\n &:before {\n transition: background-color 0.175s ease-in-out;\n margin: auto auto var(--wcs-base-margin);\n display: block;\n }\n\n &:empty::before {\n margin-bottom: 0;\n }\n }\n}\n\n:host([mode=option]) {\n padding: var(--wcs-base-margin) calc(var(--wcs-base-margin) / 2);\n font-weight: 500 !important;\n\n input {\n position: absolute;\n z-index: -1;\n opacity: 0;\n box-sizing: border-box;\n padding: 0;\n }\n\n label {\n padding: 5px calc(2 * var(--wcs-base-margin));\n margin-bottom: 0;\n color: var(--wcs-white);\n white-space: nowrap;\n border-radius: 0.4375rem;\n transition: 0.175s ease-in-out;\n }\n}\n\n:host([mode=option]:focus-within) {\n label {\n @include focus-outline(var(--wcs-white), 0.4375rem, 0.1rem);\n }\n}\n\n:host([mode=option][checked]) {\n label {\n font-weight: 500 !important;\n color: var(--wcs-primary);\n background-color: var(--wcs-white);\n }\n}\n","import {\n Component,\n ComponentInterface,\n h,\n Host,\n Prop,\n Element,\n Event,\n EventEmitter,\n Listen,\n Watch\n} from '@stencil/core';\nimport { RadioChosedEvent } from './radio-interface';\nimport { RadioGroupMode } from '../radio-group/radio-group-interface';\nimport { isEnterKey, isSpaceKey } from '../../utils/helpers';\n\n@Component({\n tag: 'wcs-radio',\n styleUrl: 'radio.scss',\n shadow: {\n delegatesFocus: true\n }\n})\nexport class Radio implements ComponentInterface {\n private inputId = `wcs-rb-${radioButtonIds++}`;\n private inputEl: HTMLInputElement;\n @Element() private el!: HTMLWcsRadioElement;\n @Prop({ reflect: true, mutable: false }) mode: RadioGroupMode = 'radio';\n\n @Prop({ mutable: true, reflect: true }) value: any | any[] | undefined | null;\n @Prop({ mutable: true, reflect: true }) label: string;\n /**\n * If `true`, the radio is selected. \n */\n @Prop({mutable: true, reflect: true}) checked = false;\n /**\n * If `true`, the user cannot interact with the radio.\n */\n @Prop({ mutable: true }) disabled = false;\n // FIXME renommer l'évènement c'est pas un onclick mais un onchange\n @Event({eventName: 'wcsRadioClick' }) wcsRadioClick: EventEmitter<RadioChosedEvent>\n \n @Prop() name: string;\n\n @Listen('keydown')\n onKeyDown(_event: KeyboardEvent) {\n if ((isSpaceKey(_event) || isEnterKey(_event)) && !this.el.checked) {\n this.checked = true;\n this.inputEl.click(); // input[radio].checked = true does not trigger any event => input[radio].click() emit a change event\n }\n }\n \n @Watch(\"checked\")\n checkedChanged(newValue: boolean) {\n if(newValue) {\n this.inputEl.click();\n } else {\n this.inputEl.click();\n }\n }\n\n componentWillLoad(): Promise<void> | void {\n if (this.value === undefined) {\n // If no value was given we use the text content instead.\n this.value = this.el.innerText || '';\n }\n }\n\n componentDidLoad() {\n this.inputEl = this.el.shadowRoot.querySelector('input');\n this.inputEl.addEventListener('change', _ => {\n this.emitRadioChangeEvent();\n this.checked = true;\n })\n }\n\n emitRadioChangeEvent() {\n this.wcsRadioClick.emit({\n label: this.label,\n source: this.el,\n value: this.value\n });\n }\n\n render() {\n \n return (\n <Host slot=\"option\" {...(this.disabled ? {tabIndex: -1} : {})}>\n <input\n id={this.inputId}\n type=\"radio\"\n name={this.name}\n value={this.value}\n checked={this.checked} // Initial checked state of native input\n disabled={this.disabled}\n aria-disabled={this.disabled ? 'true' : null}\n aria-checked={`${this.checked}`}\n />\n <label htmlFor={`${this.inputId}`}>{this.label}</label>\n </Host>\n );\n }\n}\n\nlet radioButtonIds = 0;\n"],"version":3}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { h, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-dc4d96d4.js';
|
|
2
2
|
import { S as SelectArrow } from './select-arrow-81d069f7.js';
|
|
3
|
-
import {
|
|
3
|
+
import { s as generateUniqueId, l as findItemLabel, a as isEnterKey, n as isDownArrowKey, i as isSpaceKey, q as isRightArrowKey, o as isUpArrowKey, p as isLeftArrowKey, t as isPageDownKey, u as isPageUpKey, e as isHomeKey, b as isEscapeKey, m as isTabKey, v as isElement } from './helpers-1d55b67f.js';
|
|
4
4
|
import { w as isEqual } from './isEqual-20881bca.js';
|
|
5
5
|
import { c as createPopper } from './popper-c7cca1bc.js';
|
|
6
6
|
import { M as MDCRipple } from './component-5ce0752a.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"wcs-tab.entry.js","mappings":";;MAUa,GAAG;;;;;;;EAiBZ,gBAAgB;IACZ,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;GACzB;EAED,MAAM;IACF,QACI,EAAC,IAAI,IAAC,IAAI,EAAC,SAAS,
|
|
1
|
+
{"file":"wcs-tab.entry.js","mappings":";;MAUa,GAAG;;;;;;;EAiBZ,gBAAgB;IACZ,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;GACzB;EAED,MAAM;IACF,QACI,EAAC,IAAI,IAAC,IAAI,EAAC,SAAS,EAAC,IAAI,EAAE,UAAU,IACjC,eAAa,CACV,EACT;GACL;;;;;","names":[],"sources":["./src/components/tab/tab.tsx"],"sourcesContent":["import { Component, Prop, h, Host, Event, EventEmitter } from '@stencil/core';\n\n/**\n * Tab content component.\n * Use this component to specify the content of a component.\n */\n@Component({\n tag: 'wcs-tab',\n shadow: true,\n})\nexport class Tab {\n /**\n * The header you want to be displayed for this tab.\n */\n @Prop({ reflect: true }) header: string;\n\n @Prop() itemKey: any;\n\n // TODO: See if there is a solution that doesn't pollute the API.\n /**\n * Do not use, meant for internal use only.\n * @inner\n * @ignore\n */\n @Event()\n tabLoaded!: EventEmitter<void>;\n\n componentDidLoad() {\n this.tabLoaded.emit();\n }\n\n render() {\n return (\n <Host slot=\"wcs-tab\" role={\"tabpanel\"}>\n <slot></slot>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -6,11 +6,13 @@ const Tabs = class {
|
|
|
6
6
|
constructor(hostRef) {
|
|
7
7
|
registerInstance(this, hostRef);
|
|
8
8
|
this.tabChange = createEvent(this, "tabChange", 7);
|
|
9
|
+
this.tabsId = tabsId++;
|
|
9
10
|
this.align = 'start';
|
|
10
11
|
this.selectedIndex = 0;
|
|
11
12
|
this.selectedKey = undefined;
|
|
12
13
|
this.headersOnly = false;
|
|
13
14
|
this.gutter = undefined;
|
|
15
|
+
this.description = undefined;
|
|
14
16
|
this.headers = [];
|
|
15
17
|
this.currentActiveTabIndex = 0;
|
|
16
18
|
}
|
|
@@ -87,6 +89,22 @@ const Tabs = class {
|
|
|
87
89
|
}
|
|
88
90
|
break;
|
|
89
91
|
}
|
|
92
|
+
case 'Home': {
|
|
93
|
+
const firstTab = this.el.shadowRoot.querySelector('.wcs-tab-header:first-child');
|
|
94
|
+
if (firstTab) {
|
|
95
|
+
firstTab.focus();
|
|
96
|
+
ev.preventDefault();
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case 'End': {
|
|
101
|
+
const lastTab = this.el.shadowRoot.querySelector('.wcs-tab-header:last-child');
|
|
102
|
+
if (lastTab) {
|
|
103
|
+
lastTab.focus();
|
|
104
|
+
ev.preventDefault();
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
90
108
|
}
|
|
91
109
|
}
|
|
92
110
|
refreshHeaders() {
|
|
@@ -133,7 +151,24 @@ const Tabs = class {
|
|
|
133
151
|
this.tabs.forEach((el) => el.setAttribute('style', 'display: none;'));
|
|
134
152
|
}
|
|
135
153
|
render() {
|
|
136
|
-
return (h(Host, null, h("div", { class: "wcs-tabs-headers" }, this.headers.map((header, idx) => h("div", { class: 'wcs-tab-header ' + (this.currentActiveTabIndex === idx ? 'active' : ''), onClick: () => this.selectTabAndEmitChangeEvent(idx), onKeyDown: evt => this.handleKeyDown(evt, idx), tabIndex: this.currentActiveTabIndex === idx ? 0 : -1 }, h("span", null, header)))), h("div", { class: "wcs-tabs" }, h("slot", { name: "wcs-tab" }))));
|
|
154
|
+
return (h(Host, null, h("div", { class: "wcs-tabs-headers", role: "tablist", "aria-label": this.description }, this.headers.map((header, idx) => h("div", { class: 'wcs-tab-header ' + (this.currentActiveTabIndex === idx ? 'active' : ''), onClick: () => this.selectTabAndEmitChangeEvent(idx), onKeyDown: evt => this.handleKeyDown(evt, idx), tabIndex: this.currentActiveTabIndex === idx ? 0 : -1, role: "tab", id: `tabs-id-${this.tabsId}-tab-id-${idx}`, "aria-controls": `tabs-id-${this.tabsId}-tab-panel-${idx}`, "aria-label": header, "aria-selected": this.currentActiveTabIndex === idx ? 'true' : 'false' }, h("span", null, header)))), h("div", { class: "wcs-tabs" }, h("slot", { onSlotchange: () => this.onTabsSlotChange(), name: "wcs-tab" }))));
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Observe when a new tab panel is added to the slot to let's handle accessibility properties for tabs panel:
|
|
158
|
+
* - id: to let header tab refers it proper panel
|
|
159
|
+
* - aria-label: take the same name as it's referenced header name
|
|
160
|
+
*
|
|
161
|
+
* @private
|
|
162
|
+
*/
|
|
163
|
+
onTabsSlotChange() {
|
|
164
|
+
let tabId = 0;
|
|
165
|
+
this.tabs.forEach(tab => {
|
|
166
|
+
tab.setAttribute("aria-label", this.headers.at(tabId));
|
|
167
|
+
// set an ID to set aria-controls on header tab
|
|
168
|
+
// (https://www.w3.org/WAI/ARIA/apg/patterns/tabs/examples/tabs-automatic/#:~:text=Refers%20to%20the%20element)
|
|
169
|
+
tab.setAttribute("id", `tabs-id-${this.tabsId}-tab-panel-${tabId}`);
|
|
170
|
+
tabId++;
|
|
171
|
+
});
|
|
137
172
|
}
|
|
138
173
|
get el() { return getElement(this); }
|
|
139
174
|
static get watchers() { return {
|
|
@@ -141,6 +176,7 @@ const Tabs = class {
|
|
|
141
176
|
"selectedKey": ["selectedTabkeyChanged"]
|
|
142
177
|
}; }
|
|
143
178
|
};
|
|
179
|
+
let tabsId = 0;
|
|
144
180
|
Tabs.style = tabsCss;
|
|
145
181
|
|
|
146
182
|
export { Tabs as wcs_tabs };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"wcs-tabs.entry.js","mappings":";;AAAA,MAAM,OAAO,GAAG,sjCAAsjC;;MCiCzjC,IAAI;;;;iBAIoC,OAAO;yBAMxB,CAAC;;uBAQF,KAAK;;mBAYC,EAAE;iCAEE,CAAC;;EAG1C,oBAAoB,CAAC,QAAgB;IACjC,IAAI,CAAC,qBAAqB,GAAG,Q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E,CAAC,YAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC;GAC5F;EAED,MAAM;IACF,QACI,EAAC,IAAI,QACD,WAAK,KAAK,EAAC,kBAAkB,IACxB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,KAC1B,WAAK,KAAK,EAAE,iBAAiB,IAAI,IAAI,CAAC,qBAAqB,KAAK,GAAG,GAAG,QAAQ,GAAG,EAAE,CAAC,EAC/E,OAAO,EAAE,MAAM,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,EACpD,SAAS,EAAE,GAAG,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,EAC9C,QAAQ,EAAE,IAAI,CAAC,qBAAqB,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,IAEtD,gBAAO,MAAM,CAAQ,CACnB,CACT,CACC,EACN,WAAK,KAAK,EAAC,UAAU,IACjB,YAAM,IAAI,EAAC,SAAS,GAAE,CACpB,CACH,EACT;GACL;;;;;;;;;;;","names":[],"sources":["./src/components/tabs/tabs.scss?tag=wcs-tabs&encapsulation=shadow","./src/components/tabs/tabs.tsx"],"sourcesContent":["@import '../../style/focus-outline.scss';\n\n:host {\n --wcs-tabs-padding-bottom: 16px;\n}\n\n:host([align=start]) .wcs-tabs-headers {\n justify-content: start;\n}\n\n:host([align=end]) .wcs-tabs-headers {\n justify-content: end;\n}\n\n:host([align=center]) .wcs-tabs-headers {\n justify-content: center;\n}\n\n.wcs-tabs-headers {\n padding-top: 4px;\n overflow-x: auto;\n display: flex;\n position: relative;\n}\n\n:host([gutter]) {\n .wcs-tabs-headers {\n border-bottom: var(--wcs-tabs-headers-border-bottom);\n }\n}\n\n.wcs-tab-header {\n padding: 8px 24px 16px 0;\n display: flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n outline: none;\n\n span {\n text-align: center;\n color: var(--wcs-text-disabled);\n font-size: 1rem;\n font-weight: 400;\n }\n\n\n &:focus,\n &:hover {\n span {\n color: var(--wcs-primary);\n }\n }\n\n &:focus-visible > span {\n @include focus-outline;\n }\n}\n\n\n.active {\n span {\n font-weight: 500;\n color: var(--wcs-primary);\n position: relative;\n }\n\n span::after {\n position: absolute;\n bottom: calc(var(--wcs-tabs-padding-bottom) * -1);\n left: 0;\n width: 100%;\n height: 0.3125rem;\n content: \"\";\n background-color: var(--wcs-primary);\n border-radius: 3px;\n }\n}\n","import {\n Component,\n Prop,\n Element,\n State,\n ComponentInterface,\n Event,\n EventEmitter,\n Watch,\n h,\n Host,\n Listen\n} from '@stencil/core';\n\nimport { WcsTabsAlignment, WcsTabChangeEvent } from './tabs-interface';\n\n/**\n * Tabs component to switch between tab content.\n * Use in conjuction with `wcs-tab`.\n *\n * @example\n * ```html\n * <wcs-tabs>\n * <wcs-tab header=\"One\">The content !</wcs-tab>\n * <wcs-tab header=\"Two\">More content !</wcs-tab>\n * </wcs-tabs>\n * ```\n */\n@Component({\n tag: 'wcs-tabs',\n styleUrl: 'tabs.scss',\n shadow: true,\n})\nexport class Tabs implements ComponentInterface {\n /**\n * Tab headers alignment.\n */\n @Prop({reflect: true}) align: WcsTabsAlignment = 'start';\n\n /**\n * Current selected tab index.\n * Starts at 0.\n */\n @Prop() selectedIndex: number = 0;\n\n @Prop() selectedKey: any;\n\n /**\n * Whether to skip rendering the tabpanel with the content of the selected tab. Use this prop if you plan to\n * separately render the tab content.\n */\n @Prop() headersOnly: boolean = false;\n /** Determines if tabs header should have a border at the bottom */\n @Prop() gutter: boolean;\n\n /**\n *\n * Emitted when the selected tab change.\n */\n @Event() tabChange!: EventEmitter<WcsTabChangeEvent>;\n\n @Element() private el!: HTMLWcsTabsElement;\n\n @State() private headers: string[] = [];\n\n @State() private currentActiveTabIndex = 0;\n\n @Watch('selectedIndex')\n selectedIndexChanged(newValue: number) {\n this.currentActiveTabIndex = newValue;\n }\n\n @Watch('selectedKey')\n selectedTabkeyChanged(newValue: any) {\n this.updateCurrentActiveIndexByTabKey(newValue);\n }\n\n private emitActiveTabChange() {\n this.tabChange.emit({\n tabName: this.headers[this.currentActiveTabIndex],\n tabIndex: this.currentActiveTabIndex,\n selectedKey: this.tabs[this.currentActiveTabIndex].itemKey\n });\n }\n\n private updateCurrentActiveIndexByTabKey(newValue: any) {\n for (let i = 0; i < this.tabs.length; i++) {\n const tab = this.tabs[i];\n if (tab.itemKey === newValue) {\n this.currentActiveTabIndex = i;\n }\n }\n }\n\n @Listen('tabLoaded')\n onTabLoaded() {\n this.refreshHeaders();\n }\n\n componentDidLoad() {\n this.putTabsInCorrectDivIfTheyAreNot();\n this.refreshHeaders();\n if (this.selectedIndex) {\n this.currentActiveTabIndex = this.selectedIndex;\n }\n if (this.selectedKey) {\n this.updateCurrentActiveIndexByTabKey(this.selectedKey);\n }\n }\n\n // XXX: Firefox < 63\n private putTabsInCorrectDivIfTheyAreNot() {\n const tabDiv = this.el.shadowRoot.querySelector('.wcs-tabs');\n if (tabDiv.querySelector('slot') === null) {\n Array.from(this.el.querySelectorAll('wcs-tab'))\n .filter(node => node.parentNode !== tabDiv)\n .forEach(tab => {\n if (tab.parentElement.isEqualNode(this.el)) {\n this.el.removeChild(tab);\n tabDiv.appendChild(tab);\n }\n });\n }\n }\n\n handleKeyDown(ev: KeyboardEvent, tabIndex: number) {\n const target = ev.target as HTMLDivElement;\n switch (ev.key) {\n case ' ':\n case 'Enter': {\n this.currentActiveTabIndex = tabIndex;\n this.emitActiveTabChange();\n ev.preventDefault();\n break;\n }\n case 'ArrowLeft': {\n if (target.previousElementSibling?.classList.contains('wcs-tab-header')) {\n (target.previousElementSibling as HTMLDivElement).focus();\n ev.preventDefault();\n }\n break;\n }\n case 'ArrowRight': {\n if (target.nextElementSibling?.classList.contains('wcs-tab-header')) {\n (target.nextElementSibling as HTMLDivElement).focus();\n ev.preventDefault();\n }\n break;\n }\n }\n }\n\n private refreshHeaders() {\n this.headers = [];\n this.tabs\n .forEach(x => {\n this.headers.push(x.getAttribute('header'));\n });\n }\n\n private get tabs() {\n const tabsEl = this.el.shadowRoot.querySelector('.wcs-tabs');\n // FIXME: problem with this selector being too greedy in ff < 63\n const tabs = this.el.shadowRoot.querySelectorAll('.wcs-tabs > wcs-tab');\n\n return tabs.length !== 0\n ? tabs\n : tabsEl?.querySelector('slot')\n ? tabsEl?.querySelector('slot')?.assignedElements() as unknown as NodeListOf<HTMLWcsTabElement>\n : [];\n }\n\n private selectTabAndEmitChangeEvent(index: number) {\n this.currentActiveTabIndex = index;\n this.emitActiveTabChange()\n }\n\n componentWillUpdate() {\n if (!this.headersOnly) {\n this.updateTabVisibility();\n } else {\n this.hideAllTabsContent();\n }\n }\n\n private updateTabVisibility() {\n this.tabs.forEach((el: HTMLWcsTabElement, idx: number) => {\n if (idx !== this.currentActiveTabIndex) {\n el.setAttribute('style', 'display: none;');\n } else {\n el.setAttribute('style', 'display: block;');\n }\n });\n }\n\n private hideAllTabsContent() {\n this.tabs.forEach((el: HTMLWcsTabElement) => el.setAttribute('style', 'display: none;'));\n }\n\n render() {\n return (\n <Host>\n <div class=\"wcs-tabs-headers\">\n {this.headers.map((header, idx) =>\n <div class={'wcs-tab-header ' + (this.currentActiveTabIndex === idx ? 'active' : '')}\n onClick={() => this.selectTabAndEmitChangeEvent(idx)}\n onKeyDown={evt => this.handleKeyDown(evt, idx)}\n tabIndex={this.currentActiveTabIndex === idx ? 0 : -1}\n >\n <span>{header}</span>\n </div>\n )}\n </div>\n <div class=\"wcs-tabs\">\n <slot name=\"wcs-tab\"/>\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"wcs-tabs.entry.js","mappings":";;AAAA,MAAM,OAAO,GAAG,sjCAAsjC;;MCiCzjC,IAAI;;;;IAuCL,WAAM,GAAW,MAAM,EAAE,CAAC;iBAnCe,OAAO;yBAMxB,CAAC;;uBAQF,KAAK;;;mBAiBC,EAAE;iCAEE,CAAC;;EAK1C,oBAAoB,CAAC,QAAgB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AAI,CAAC,qBAAqB,KAAK,GAAG,GAAG,MAAM,GAAG,OAAO,IAErE,gBAAO,MAAM,CAAQ,CACnB,CACT,CACC,EACN,WAAK,KAAK,EAAC,UAAU,IACjB,YAAM,YAAY,EAAE,MAAM,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAC,SAAS,GAAE,CACjE,CACH,EACT;GACL;;;;;;;;EASO,gBAAgB;IACpB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG;MACjB,GAAG,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;;;MAGvD,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,WAAW,IAAI,CAAC,MAAM,cAAc,KAAK,EAAE,CAAC,CAAC;MACpE,KAAK,EAAE,CAAC;KACX,CAAC,CAAC;GACN;;;;;;;AAGL,IAAI,MAAM,GAAG,CAAC,CAAC;;;;;","names":[],"sources":["./src/components/tabs/tabs.scss?tag=wcs-tabs&encapsulation=shadow","./src/components/tabs/tabs.tsx"],"sourcesContent":["@import '../../style/focus-outline.scss';\n\n:host {\n --wcs-tabs-padding-bottom: 16px;\n}\n\n:host([align=start]) .wcs-tabs-headers {\n justify-content: start;\n}\n\n:host([align=end]) .wcs-tabs-headers {\n justify-content: end;\n}\n\n:host([align=center]) .wcs-tabs-headers {\n justify-content: center;\n}\n\n.wcs-tabs-headers {\n padding-top: 4px;\n overflow-x: auto;\n display: flex;\n position: relative;\n}\n\n:host([gutter]) {\n .wcs-tabs-headers {\n border-bottom: var(--wcs-tabs-headers-border-bottom);\n }\n}\n\n.wcs-tab-header {\n padding: 8px 24px 16px 0;\n display: flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n outline: none;\n\n span {\n text-align: center;\n color: var(--wcs-text-disabled);\n font-size: 1rem;\n font-weight: 400;\n }\n\n\n &:focus,\n &:hover {\n span {\n color: var(--wcs-primary);\n }\n }\n\n &:focus-visible > span {\n @include focus-outline;\n }\n}\n\n\n.active {\n span {\n font-weight: 500;\n color: var(--wcs-primary);\n position: relative;\n }\n\n span::after {\n position: absolute;\n bottom: calc(var(--wcs-tabs-padding-bottom) * -1);\n left: 0;\n width: 100%;\n height: 0.3125rem;\n content: \"\";\n background-color: var(--wcs-primary);\n border-radius: 3px;\n }\n}\n","import {\n Component,\n Prop,\n Element,\n State,\n ComponentInterface,\n Event,\n EventEmitter,\n Watch,\n h,\n Host,\n Listen\n} from '@stencil/core';\n\nimport { WcsTabsAlignment, WcsTabChangeEvent } from './tabs-interface';\n\n/**\n * Tabs component to switch between tab content.\n * Use in conjuction with `wcs-tab`.\n *\n * @example\n * ```html\n * <wcs-tabs>\n * <wcs-tab header=\"One\">The content !</wcs-tab>\n * <wcs-tab header=\"Two\">More content !</wcs-tab>\n * </wcs-tabs>\n * ```\n */\n@Component({\n tag: 'wcs-tabs',\n styleUrl: 'tabs.scss',\n shadow: true,\n})\nexport class Tabs implements ComponentInterface {\n /**\n * Tab headers alignment.\n */\n @Prop({reflect: true}) align: WcsTabsAlignment = 'start';\n\n /**\n * Current selected tab index.\n * Starts at 0.\n */\n @Prop() selectedIndex: number = 0;\n\n @Prop() selectedKey: any;\n\n /**\n * Whether to skip rendering the tabpanel with the content of the selected tab. Use this prop if you plan to\n * separately render the tab content.\n */\n @Prop() headersOnly: boolean = false;\n /** Determines if tabs header should have a border at the bottom */\n @Prop() gutter: boolean;\n\n /**\n * Description is used to provide aria-label for the tabs container which has `role=\"tablist\"`.\n */\n @Prop() description: string;\n\n /**\n *\n * Emitted when the selected tab change.\n */\n @Event() tabChange!: EventEmitter<WcsTabChangeEvent>;\n\n @Element() private el!: HTMLWcsTabsElement;\n\n @State() private headers: string[] = [];\n\n @State() private currentActiveTabIndex = 0;\n\n private tabsId: number = tabsId++;\n\n @Watch('selectedIndex')\n selectedIndexChanged(newValue: number) {\n this.currentActiveTabIndex = newValue;\n }\n\n @Watch('selectedKey')\n selectedTabkeyChanged(newValue: any) {\n this.updateCurrentActiveIndexByTabKey(newValue);\n }\n\n private emitActiveTabChange() {\n this.tabChange.emit({\n tabName: this.headers[this.currentActiveTabIndex],\n tabIndex: this.currentActiveTabIndex,\n selectedKey: this.tabs[this.currentActiveTabIndex].itemKey\n });\n }\n\n private updateCurrentActiveIndexByTabKey(newValue: any) {\n for (let i = 0; i < this.tabs.length; i++) {\n const tab = this.tabs[i];\n if (tab.itemKey === newValue) {\n this.currentActiveTabIndex = i;\n }\n }\n }\n\n @Listen('tabLoaded')\n onTabLoaded() {\n this.refreshHeaders();\n }\n\n componentDidLoad() {\n this.putTabsInCorrectDivIfTheyAreNot();\n this.refreshHeaders();\n if (this.selectedIndex) {\n this.currentActiveTabIndex = this.selectedIndex;\n }\n if (this.selectedKey) {\n this.updateCurrentActiveIndexByTabKey(this.selectedKey);\n }\n }\n\n // XXX: Firefox < 63\n private putTabsInCorrectDivIfTheyAreNot() {\n const tabDiv = this.el.shadowRoot.querySelector('.wcs-tabs');\n if (tabDiv.querySelector('slot') === null) {\n Array.from(this.el.querySelectorAll('wcs-tab'))\n .filter(node => node.parentNode !== tabDiv)\n .forEach(tab => {\n if (tab.parentElement.isEqualNode(this.el)) {\n this.el.removeChild(tab);\n tabDiv.appendChild(tab);\n }\n });\n }\n }\n\n handleKeyDown(ev: KeyboardEvent, tabIndex: number) {\n const target = ev.target as HTMLDivElement;\n switch (ev.key) {\n case ' ':\n case 'Enter': {\n this.currentActiveTabIndex = tabIndex;\n this.emitActiveTabChange();\n ev.preventDefault();\n break;\n }\n case 'ArrowLeft': {\n if (target.previousElementSibling?.classList.contains('wcs-tab-header')) {\n (target.previousElementSibling as HTMLDivElement).focus();\n ev.preventDefault();\n }\n break;\n }\n case 'ArrowRight': {\n if (target.nextElementSibling?.classList.contains('wcs-tab-header')) {\n (target.nextElementSibling as HTMLDivElement).focus();\n ev.preventDefault();\n }\n break;\n }\n case 'Home': {\n const firstTab = this.el.shadowRoot.querySelector('.wcs-tab-header:first-child');\n if (firstTab) {\n (firstTab as HTMLDivElement).focus();\n ev.preventDefault();\n }\n break;\n }\n case 'End': {\n const lastTab = this.el.shadowRoot.querySelector('.wcs-tab-header:last-child');\n if (lastTab) {\n (lastTab as HTMLDivElement).focus();\n ev.preventDefault();\n }\n break;\n }\n }\n }\n\n private refreshHeaders() {\n this.headers = [];\n this.tabs\n .forEach(x => {\n this.headers.push(x.getAttribute('header'));\n });\n }\n\n private get tabs() {\n const tabsEl = this.el.shadowRoot.querySelector('.wcs-tabs');\n // FIXME: problem with this selector being too greedy in ff < 63\n const tabs = this.el.shadowRoot.querySelectorAll('.wcs-tabs > wcs-tab');\n\n return tabs.length !== 0\n ? tabs\n : tabsEl?.querySelector('slot')\n ? tabsEl?.querySelector('slot')?.assignedElements() as unknown as NodeListOf<HTMLWcsTabElement>\n : [];\n }\n\n private selectTabAndEmitChangeEvent(index: number) {\n this.currentActiveTabIndex = index;\n this.emitActiveTabChange()\n }\n\n componentWillUpdate() {\n if (!this.headersOnly) {\n this.updateTabVisibility();\n } else {\n this.hideAllTabsContent();\n }\n }\n\n private updateTabVisibility() {\n this.tabs.forEach((el: HTMLWcsTabElement, idx: number) => {\n if (idx !== this.currentActiveTabIndex) {\n el.setAttribute('style', 'display: none;');\n } else {\n el.setAttribute('style', 'display: block;');\n }\n });\n }\n\n private hideAllTabsContent() {\n this.tabs.forEach((el: HTMLWcsTabElement) => el.setAttribute('style', 'display: none;'));\n }\n\n render() {\n return (\n <Host>\n <div class=\"wcs-tabs-headers\" role=\"tablist\" aria-label={this.description}>\n {this.headers.map((header, idx) =>\n <div class={'wcs-tab-header ' + (this.currentActiveTabIndex === idx ? 'active' : '')}\n onClick={() => this.selectTabAndEmitChangeEvent(idx)}\n onKeyDown={evt => this.handleKeyDown(evt, idx)}\n tabIndex={this.currentActiveTabIndex === idx ? 0 : -1}\n role=\"tab\"\n id={`tabs-id-${this.tabsId}-tab-id-${idx}`}\n // aria-controls refers to ID of the tab panel related to the header\n aria-controls={`tabs-id-${this.tabsId}-tab-panel-${idx}`}\n aria-label={header}\n aria-selected={this.currentActiveTabIndex === idx ? 'true' : 'false'}\n >\n <span>{header}</span>\n </div>\n )}\n </div>\n <div class=\"wcs-tabs\">\n <slot onSlotchange={() => this.onTabsSlotChange()} name=\"wcs-tab\"/>\n </div>\n </Host>\n );\n }\n\n /**\n * Observe when a new tab panel is added to the slot to let's handle accessibility properties for tabs panel:\n * - id: to let header tab refers it proper panel\n * - aria-label: take the same name as it's referenced header name\n * \n * @private\n */\n private onTabsSlotChange() {\n let tabId = 0;\n this.tabs.forEach(tab => {\n tab.setAttribute(\"aria-label\", this.headers.at(tabId));\n // set an ID to set aria-controls on header tab \n // (https://www.w3.org/WAI/ARIA/apg/patterns/tabs/examples/tabs-automatic/#:~:text=Refers%20to%20the%20element)\n tab.setAttribute(\"id\", `tabs-id-${this.tabsId}-tab-panel-${tabId}`);\n tabId++;\n });\n }\n}\n\nlet tabsId = 0;\n"],"version":3}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, a as readTask, h, H as Host, g as getElement } from './index-dc4d96d4.js';
|
|
2
|
-
import { j as debounceEvent, k as inheritAttributes, r as raf, l as findItemLabel } from './helpers-
|
|
2
|
+
import { j as debounceEvent, k as inheritAttributes, r as raf, l as findItemLabel } from './helpers-1d55b67f.js';
|
|
3
3
|
|
|
4
4
|
const textareaCss = ":host{--wcs-textarea-icon-color:var(--wcs-text-medium);--wcs-internal-textarea-border-radius-left:var(--wcs-textarea-border-radius-left, var(--wcs-border-radius));--wcs-internal-textarea-border-radius-right:var(--wcs-textarea-border-radius-right, var(--wcs-border-radius));--wcs-internal-textarea-border-width:2px;--wcs-textarea-max-height:unset;display:flex;flex-direction:row;width:100%;border-radius:var(--wcs-internal-textarea-border-radius-left) var(--wcs-internal-textarea-border-radius-right) var(--wcs-internal-textarea-border-radius-right) var(--wcs-internal-textarea-border-radius-left);background-color:var(--wcs-light);border:var(--wcs-internal-textarea-border-width) solid var(--wcs-light);background-clip:padding-box}:host ::placeholder{font-weight:400;font-style:italic}:host textarea{overflow:auto;flex:1;width:100%;box-sizing:border-box;min-height:var(--wcs-size-m);max-height:var(--wcs-textarea-max-height);background-color:transparent;font-family:var(--wcs-font-sans-serif);color:var(--wcs-primary);font-weight:var(--wcs-font-weight-form-value) !important;border:none;padding:calc(var(--wcs-padding) / 2 - var(--wcs-internal-textarea-border-width) / 2) calc(var(--wcs-padding) - var(--wcs-internal-textarea-border-width));font-size:1rem;line-height:1.5}:host textarea:focus{box-shadow:none;outline:0}:host wcs-mat-icon{position:relative;margin-top:7px;margin-left:8px;margin-right:-8px}:host([disabled]) textarea{color:var(--wcs-text-disabled);cursor:not-allowed}:host([state=error]){border-color:var(--wcs-red) !important}:host(:focus-within){border:dashed var(--wcs-internal-textarea-border-width) var(--wcs-primary)}:host(:focus-within) wcs-mat-icon{color:var(--wcs-primary)}";
|
|
5
5
|
|
|
@@ -113,8 +113,8 @@ const Textarea = class {
|
|
|
113
113
|
raf(() => this.runAutoGrow());
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
|
-
*
|
|
117
|
-
* `textarea
|
|
116
|
+
* @deprecated use the native focus method instead
|
|
117
|
+
* Sets focus on the native `textarea` in `wcs-textarea`.
|
|
118
118
|
*/
|
|
119
119
|
async setFocus() {
|
|
120
120
|
if (this.nativeInput) {
|
|
@@ -175,6 +175,7 @@ const Textarea = class {
|
|
|
175
175
|
const style = Object.assign({}, (this.resize && { 'resize': this.resize }));
|
|
176
176
|
return (h(Host, { "aria-disabled": this.disabled ? 'true' : null }, this.icon ? (h("wcs-mat-icon", { icon: this.icon, size: "m" })) : null, h("textarea", Object.assign({ class: "native-textarea", "aria-labelledby": label ? labelId : null, ref: el => this.nativeInput = el, autoCapitalize: this.autocapitalize, autoFocus: this.autofocus, enterKeyHint: this.enterkeyhint, inputMode: this.inputmode, disabled: this.disabled, maxLength: this.maxlength, minLength: this.minlength, name: this.name, placeholder: this.placeholder || '', readOnly: this.readonly, required: this.required, spellcheck: this.spellcheck, cols: this.cols, rows: this.rows, wrap: this.wrap, onInput: this.onInput, onBlur: this.onBlur, onFocus: this.onFocus, onKeyDown: this.onKeyDown, style: style }, this.inheritedAttributes), value)));
|
|
177
177
|
}
|
|
178
|
+
static get delegatesFocus() { return true; }
|
|
178
179
|
get el() { return getElement(this); }
|
|
179
180
|
static get watchers() { return {
|
|
180
181
|
"debounce": ["debounceChanged"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"wcs-textarea.entry.js","mappings":";;;AAAA,MAAM,WAAW,GAAG,mqDAAmqD;;MC6B1qD,QAAQ;;;;;;;IAET,YAAO,GAAG,gBAAgB,WAAW,EAAE,EAAE,CAAC;IAC1C,qBAAgB,GAAG,KAAK,CAAC;IACzB,wBAAmB,GAAyB,EAAE,CAAC;IAsR/C,YAAO,GAAG,CAAC,EAAS;MACxB,IAAI,IAAI,CAAC,WAAW,EAAE;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;OACvC;MACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAmB,CAAC,CAAC;KAC3C,CAAA;IAEO,YAAO,GAAG,CAAC,EAAc;MAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;MACrB,IAAI,CAAC,WAAW,EAAE,CAAC;MAEnB,IAAI,IAAI,CAAC,eAAe,EAAE;QACtB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;OAC1B;KACJ,CAAA;IAEO,WAAM,GAAG,CAAC,EAAc;MAC5B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;MACtB,IAAI,CAAC,WAAW,EAAE,CAAC;MAEnB,IAAI,IAAI,CAAC,eAAe,EAAE;QACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;OAC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E,IAAI,CAAC,UAAU,EAC3B,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,KAAK,EAAE,KAAK,IACR,IAAI,CAAC,mBAAmB,GAEnC,KAAK,CACG,CACF,EACT;GACL;;;;;;;AAGL,IAAI,WAAW,GAAG,CAAC,CAAC;;;;;","names":[],"sources":["./src/components/textarea/textarea.scss?tag=wcs-textarea&encapsulation=shadow","./src/components/textarea/textarea.tsx"],"sourcesContent":["@import '../../style/focus-outline.scss';\n\n:host {\n --wcs-textarea-icon-color: var(--wcs-text-medium);\n --wcs-internal-textarea-border-radius-left: var(--wcs-textarea-border-radius-left, var(--wcs-border-radius));\n --wcs-internal-textarea-border-radius-right: var(--wcs-textarea-border-radius-right, var(--wcs-border-radius));\n --wcs-internal-textarea-border-width: 2px;\n --wcs-textarea-max-height: unset;\n display: flex;\n flex-direction: row;\n width: 100%;\n border-radius: var(--wcs-internal-textarea-border-radius-left) var(--wcs-internal-textarea-border-radius-right) var(--wcs-internal-textarea-border-radius-right) var(--wcs-internal-textarea-border-radius-left);\n background-color: var(--wcs-light);\n border: var(--wcs-internal-textarea-border-width) solid var(--wcs-light);\n background-clip: padding-box;\n\n ::placeholder {\n font-weight: 400;\n font-style: italic;\n }\n\n textarea {\n overflow: auto;\n flex: 1;\n width: 100%;\n box-sizing: border-box;\n min-height: var(--wcs-size-m);\n max-height: var(--wcs-textarea-max-height);\n background-color: transparent;\n font-family: var(--wcs-font-sans-serif);\n color: var(--wcs-primary);\n font-weight: var(--wcs-font-weight-form-value) !important;\n border: none;\n // On divise --wcs-internal-input-border-width par deux car la valeur du padding est appliquée en haut et en bas\n padding: calc(calc(var(--wcs-padding) / 2) - calc(var(--wcs-internal-textarea-border-width) / 2)) calc(var(--wcs-padding) - var(--wcs-internal-textarea-border-width));\n font-size: 1rem;\n line-height: 1.5;\n }\n\n textarea:focus {\n box-shadow: none;\n outline: 0;\n }\n\n wcs-mat-icon {\n position: relative;\n margin-top: 7px;\n margin-left: 8px;\n margin-right: -8px;\n }\n}\n\n:host([disabled]) {\n textarea {\n color: var(--wcs-text-disabled);\n cursor: not-allowed;\n }\n}\n\n:host([state=error]) {\n border-color: var(--wcs-red) !important;\n}\n\n:host(:focus-within) {\n border: dashed var(--wcs-internal-textarea-border-width) var(--wcs-primary);\n\n wcs-mat-icon {\n color: var(--wcs-primary);\n }\n}\n","import {\n Component,\n ComponentInterface,\n Method,\n Prop,\n State,\n Watch,\n h,\n Host,\n EventEmitter,\n Element,\n Event,\n Build,\n readTask\n} from '@stencil/core';\nimport { debounceEvent, findItemLabel, inheritAttributes, raf } from '../../utils/helpers';\nimport { TextareaChangeEventDetail } from './textarea-interface';\n\n/**\n * Mainly inspired from Ionic Textarea Component\n *\n * @cssprop --wcs-textarea-max-height - Max height of the text area component\n *\n */\n@Component({\n tag: 'wcs-textarea',\n styleUrl: 'textarea.scss',\n shadow: true,\n})\nexport class Textarea implements ComponentInterface {\n private nativeInput?: HTMLTextAreaElement;\n private inputId = `wcs-textarea-${textareaIds++}`;\n private didBlurAfterEdit = false;\n private inheritedAttributes: { [k: string]: any } = {};\n\n /**\n * This is required for a WebKit bug which requires us to\n * blur and focus an input to properly focus the input in\n * an item with delegatesFocus. It will no longer be needed\n * with iOS 14.\n *\n * @internal\n */\n @Prop() fireFocusEvents = true;\n\n @Element() private el!: HTMLElement;\n\n @State() private hasFocus = false;\n\n /**\n * Indicates whether and how the text value should be automatically capitalized as it is entered/edited by the user.\n */\n @Prop() autocapitalize = 'none';\n\n /**\n * This Boolean attribute lets you specify that a form control should have input focus when the page loads.\n */\n @Prop() autofocus = false;\n\n /**\n * If `true`, the value will be cleared after focus upon edit. Defaults to `true` when `type` is `\"password\"`, `false` for all other types.\n */\n @Prop({mutable: true}) clearOnEdit = false;\n\n /**\n * Set the amount of time, in milliseconds, to wait to trigger the `wcsChange` event after each keystroke. This also impacts form bindings such as `ngModel` or `v-model`.\n */\n @Prop() debounce = 0;\n\n @Watch('debounce')\n protected debounceChanged() {\n this.wcsChange = debounceEvent(this.wcsChange, this.debounce);\n }\n\n /**\n * If `true`, the user cannot interact with the textarea.\n */\n @Prop() disabled = false;\n\n /**\n * Name of the material icon to add to the input\n */\n @Prop() icon: string;\n\n /**\n * A hint to the browser for which keyboard to display.\n * Possible values: `\"none\"`, `\"text\"`, `\"tel\"`, `\"url\"`,\n * `\"email\"`, `\"numeric\"`, `\"decimal\"`, and `\"search\"`.\n */\n @Prop() inputmode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';\n\n /**\n * A hint to the browser for which enter key to display.\n * Possible values: `\"enter\"`, `\"done\"`, `\"go\"`, `\"next\"`,\n * `\"previous\"`, `\"search\"`, and `\"send\"`.\n */\n @Prop() enterkeyhint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the maximum number of characters that the user can enter.\n */\n @Prop() maxlength?: number;\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the minimum number of characters that the user can enter.\n */\n @Prop() minlength?: number;\n\n /**\n * The name of the control, which is submitted with the form data.\n */\n @Prop() name: string = this.inputId;\n\n /**\n * Instructional text that shows before the input has a value.\n */\n @Prop() placeholder?: string | null;\n\n /**\n * If `true`, the user cannot modify the value.\n */\n @Prop() readonly = false;\n\n /**\n * If `true`, the user must fill in a value before submitting a form.\n */\n @Prop() required = false;\n\n /**\n * If `true`, the element will have its spelling and grammar checked.\n */\n @Prop() spellcheck = false;\n\n /**\n * Specifies the state of the input. By default the input is in an initial state but you can set it to 'error' state if the data given by the user is not valid.\n */\n @Prop({reflect: true}) state: 'initial' | 'error' = 'initial';\n\n /**\n * The visible width of the text control, in average character widths. If it is specified, it must be a positive integer.\n */\n @Prop() cols?: number;\n\n /**\n * The number of visible text lines for the control.\n */\n @Prop() rows?: number;\n\n /**\n * Indicates how the control wraps text.\n */\n @Prop() wrap?: 'hard' | 'soft' | 'off';\n\n /**\n * If `true`, the element height will increase based on the value.\n */\n @Prop() autoGrow = false;\n\n /**\n * The value of the textarea.\n */\n @Prop({mutable: true}) value?: string | null = '';\n\n /**\n * Indicates how the textarea should be resizable.\n * Possible values 'both' | 'none' | 'vertical' | 'horizontal'\n */\n @Prop({reflect: true}) resize?: 'both' | 'none' | 'vertical' | 'horizontal';\n\n /**\n * Update the native input element when the value changes\n */\n @Watch('value')\n protected valueChanged() {\n const nativeInput = this.nativeInput;\n const value = this.getValue();\n if (nativeInput && nativeInput.value !== value) {\n nativeInput.value = value;\n }\n this.runAutoGrow();\n this.wcsChange.emit({value});\n }\n\n /**\n * Emitted when the input value has changed.\n */\n @Event() wcsChange!: EventEmitter<TextareaChangeEventDetail>;\n\n /**\n * Emitted when a keyboard input occurred.\n */\n @Event() wcsInput!: EventEmitter<KeyboardEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() wcsBlur!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input has focus.\n */\n @Event() wcsFocus!: EventEmitter<FocusEvent>;\n\n connectedCallback() {\n this.debounceChanged();\n if (Build.isBrowser) {\n document.dispatchEvent(new CustomEvent('wcsInputDidLoad', {\n detail: this.el\n }));\n }\n }\n\n disconnectedCallback() {\n if (Build.isBrowser) {\n document.dispatchEvent(new CustomEvent('wcsInputDidUnload', {\n detail: this.el\n }));\n }\n }\n\n componentWillLoad() {\n this.inheritedAttributes = inheritAttributes(this.el, ['title']);\n }\n\n componentDidLoad() {\n raf(() => this.runAutoGrow());\n }\n\n private runAutoGrow() {\n const nativeInput = this.nativeInput;\n if (nativeInput && this.autoGrow) {\n readTask(() => {\n nativeInput.style.height = 'auto';\n nativeInput.style.height = nativeInput.scrollHeight + 'px';\n });\n }\n }\n\n /**\n * This method make the textarea automatically adopt the size of the content without a scroll bar\n */\n @Method()\n async fitContent() {\n raf(() => this.runAutoGrow());\n }\n\n /**\n * Sets focus on the native `textarea` in `wcs-textarea`. Use this method instead of the global\n * `textarea.focus()`.\n */\n @Method()\n async setFocus() {\n if (this.nativeInput) {\n this.nativeInput.focus();\n }\n }\n\n /**\n * Sets blur on the native `textarea` in `wcs-textarea`. Use this method instead of the global\n * `textarea.blur()`.\n * @internal\n */\n @Method()\n async setBlur() {\n if (this.nativeInput) {\n this.nativeInput.blur();\n }\n }\n\n /**\n * Returns the native `<textarea>` element used under the hood.\n */\n @Method()\n getInputElement(): Promise<HTMLTextAreaElement> {\n // tslint:disable-next-line:no-non-null-assertion\n return Promise.resolve(this.nativeInput!);\n }\n\n /**\n * Check if we need to clear the text input if clearOnEdit is enabled\n */\n private checkClearOnEdit() {\n if (!this.clearOnEdit) {\n return;\n }\n\n // Did the input value change after it was blurred and edited?\n if (this.didBlurAfterEdit && this.hasValue()) {\n // Clear the input\n this.value = '';\n }\n\n // Reset the flag\n this.didBlurAfterEdit = false;\n }\n\n private focusChange() {\n // If clearOnEdit is enabled and the input blurred but has a value, set a flag\n if (this.clearOnEdit && !this.hasFocus && this.hasValue()) {\n this.didBlurAfterEdit = true;\n }\n }\n\n private hasValue(): boolean {\n return this.getValue() !== '';\n }\n\n private getValue(): string {\n return this.value || '';\n }\n\n private onInput = (ev: Event) => {\n if (this.nativeInput) {\n this.value = this.nativeInput.value;\n }\n this.wcsInput.emit(ev as KeyboardEvent);\n }\n\n private onFocus = (ev: FocusEvent) => {\n this.hasFocus = true;\n this.focusChange();\n\n if (this.fireFocusEvents) {\n this.wcsFocus.emit(ev);\n }\n }\n\n private onBlur = (ev: FocusEvent) => {\n this.hasFocus = false;\n this.focusChange();\n\n if (this.fireFocusEvents) {\n this.wcsBlur.emit(ev);\n }\n }\n\n private onKeyDown = () => {\n this.checkClearOnEdit();\n }\n\n render() {\n const value = this.getValue();\n const labelId = this.inputId + '-lbl';\n const label = findItemLabel(this.el);\n if (label) {\n label.id = labelId;\n }\n const style = {\n ...(this.resize && {'resize': this.resize})\n }\n\n return (\n <Host\n aria-disabled={this.disabled ? 'true' : null}\n >\n {this.icon ? (<wcs-mat-icon icon={this.icon} size=\"m\"></wcs-mat-icon>) : null}\n <textarea\n class=\"native-textarea\"\n aria-labelledby={label ? labelId : null}\n ref={el => this.nativeInput = el}\n autoCapitalize={this.autocapitalize}\n autoFocus={this.autofocus}\n enterKeyHint={this.enterkeyhint}\n inputMode={this.inputmode}\n disabled={this.disabled}\n maxLength={this.maxlength}\n minLength={this.minlength}\n name={this.name}\n placeholder={this.placeholder || ''}\n readOnly={this.readonly}\n required={this.required}\n spellcheck={this.spellcheck}\n cols={this.cols}\n rows={this.rows}\n wrap={this.wrap}\n onInput={this.onInput}\n onBlur={this.onBlur}\n onFocus={this.onFocus}\n onKeyDown={this.onKeyDown}\n style={style}\n {...this.inheritedAttributes}\n >\n {value}\n </textarea>\n </Host>\n );\n }\n}\n\nlet textareaIds = 0;\n"],"version":3}
|
|
1
|
+
{"file":"wcs-textarea.entry.js","mappings":";;;AAAA,MAAM,WAAW,GAAG,mqDAAmqD;;MC+B1qD,QAAQ;;;;;;;IAET,YAAO,GAAG,gBAAgB,WAAW,EAAE,EAAE,CAAC;IAC1C,qBAAgB,GAAG,KAAK,CAAC;IACzB,wBAAmB,GAAyB,EAAE,CAAC;IAsR/C,YAAO,GAAG,CAAC,EAAS;MACxB,IAAI,IAAI,CAAC,WAAW,EAAE;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;OACvC;MACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAmB,CAAC,CAAC;KAC3C,CAAA;IAEO,YAAO,GAAG,CAAC,EAAc;MAC7B,IAAI,CAAC,Q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AAS,EAAE,IAAI,CAAC,SAAS,EACzB,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE,EACnC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,KAAK,EAAE,KAAK,IACR,IAAI,CAAC,mBAAmB,GAEnC,KAAK,CACG,CACF,EACT;GACL;;;;;;;;AAGL,IAAI,WAAW,GAAG,CAAC,CAAC;;;;;","names":[],"sources":["./src/components/textarea/textarea.scss?tag=wcs-textarea&encapsulation=shadow","./src/components/textarea/textarea.tsx"],"sourcesContent":["@import '../../style/focus-outline.scss';\n\n:host {\n --wcs-textarea-icon-color: var(--wcs-text-medium);\n --wcs-internal-textarea-border-radius-left: var(--wcs-textarea-border-radius-left, var(--wcs-border-radius));\n --wcs-internal-textarea-border-radius-right: var(--wcs-textarea-border-radius-right, var(--wcs-border-radius));\n --wcs-internal-textarea-border-width: 2px;\n --wcs-textarea-max-height: unset;\n display: flex;\n flex-direction: row;\n width: 100%;\n border-radius: var(--wcs-internal-textarea-border-radius-left) var(--wcs-internal-textarea-border-radius-right) var(--wcs-internal-textarea-border-radius-right) var(--wcs-internal-textarea-border-radius-left);\n background-color: var(--wcs-light);\n border: var(--wcs-internal-textarea-border-width) solid var(--wcs-light);\n background-clip: padding-box;\n\n ::placeholder {\n font-weight: 400;\n font-style: italic;\n }\n\n textarea {\n overflow: auto;\n flex: 1;\n width: 100%;\n box-sizing: border-box;\n min-height: var(--wcs-size-m);\n max-height: var(--wcs-textarea-max-height);\n background-color: transparent;\n font-family: var(--wcs-font-sans-serif);\n color: var(--wcs-primary);\n font-weight: var(--wcs-font-weight-form-value) !important;\n border: none;\n // On divise --wcs-internal-input-border-width par deux car la valeur du padding est appliquée en haut et en bas\n padding: calc(calc(var(--wcs-padding) / 2) - calc(var(--wcs-internal-textarea-border-width) / 2)) calc(var(--wcs-padding) - var(--wcs-internal-textarea-border-width));\n font-size: 1rem;\n line-height: 1.5;\n }\n\n textarea:focus {\n box-shadow: none;\n outline: 0;\n }\n\n wcs-mat-icon {\n position: relative;\n margin-top: 7px;\n margin-left: 8px;\n margin-right: -8px;\n }\n}\n\n:host([disabled]) {\n textarea {\n color: var(--wcs-text-disabled);\n cursor: not-allowed;\n }\n}\n\n:host([state=error]) {\n border-color: var(--wcs-red) !important;\n}\n\n:host(:focus-within) {\n border: dashed var(--wcs-internal-textarea-border-width) var(--wcs-primary);\n\n wcs-mat-icon {\n color: var(--wcs-primary);\n }\n}\n","import {\n Component,\n ComponentInterface,\n Method,\n Prop,\n State,\n Watch,\n h,\n Host,\n EventEmitter,\n Element,\n Event,\n Build,\n readTask\n} from '@stencil/core';\nimport { debounceEvent, findItemLabel, inheritAttributes, raf } from '../../utils/helpers';\nimport { TextareaChangeEventDetail } from './textarea-interface';\n\n/**\n * Mainly inspired from Ionic Textarea Component\n *\n * @cssprop --wcs-textarea-max-height - Max height of the text area component\n *\n */\n@Component({\n tag: 'wcs-textarea',\n styleUrl: 'textarea.scss',\n shadow: {\n delegatesFocus: true\n },\n})\nexport class Textarea implements ComponentInterface {\n private nativeInput?: HTMLTextAreaElement;\n private inputId = `wcs-textarea-${textareaIds++}`;\n private didBlurAfterEdit = false;\n private inheritedAttributes: { [k: string]: any } = {};\n\n /**\n * This is required for a WebKit bug which requires us to\n * blur and focus an input to properly focus the input in\n * an item with delegatesFocus. It will no longer be needed\n * with iOS 14.\n *\n * @internal\n */\n @Prop() fireFocusEvents = true;\n\n @Element() private el!: HTMLElement;\n\n @State() private hasFocus = false;\n\n /**\n * Indicates whether and how the text value should be automatically capitalized as it is entered/edited by the user.\n */\n @Prop() autocapitalize = 'none';\n\n /**\n * This Boolean attribute lets you specify that a form control should have input focus when the page loads.\n */\n @Prop() autofocus = false;\n\n /**\n * If `true`, the value will be cleared after focus upon edit. Defaults to `true` when `type` is `\"password\"`, `false` for all other types.\n */\n @Prop({mutable: true}) clearOnEdit = false;\n\n /**\n * Set the amount of time, in milliseconds, to wait to trigger the `wcsChange` event after each keystroke. This also impacts form bindings such as `ngModel` or `v-model`.\n */\n @Prop() debounce = 0;\n\n @Watch('debounce')\n protected debounceChanged() {\n this.wcsChange = debounceEvent(this.wcsChange, this.debounce);\n }\n\n /**\n * If `true`, the user cannot interact with the textarea.\n */\n @Prop() disabled = false;\n\n /**\n * Name of the material icon to add to the input\n */\n @Prop() icon: string;\n\n /**\n * A hint to the browser for which keyboard to display.\n * Possible values: `\"none\"`, `\"text\"`, `\"tel\"`, `\"url\"`,\n * `\"email\"`, `\"numeric\"`, `\"decimal\"`, and `\"search\"`.\n */\n @Prop() inputmode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';\n\n /**\n * A hint to the browser for which enter key to display.\n * Possible values: `\"enter\"`, `\"done\"`, `\"go\"`, `\"next\"`,\n * `\"previous\"`, `\"search\"`, and `\"send\"`.\n */\n @Prop() enterkeyhint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the maximum number of characters that the user can enter.\n */\n @Prop() maxlength?: number;\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the minimum number of characters that the user can enter.\n */\n @Prop() minlength?: number;\n\n /**\n * The name of the control, which is submitted with the form data.\n */\n @Prop() name: string = this.inputId;\n\n /**\n * Instructional text that shows before the input has a value.\n */\n @Prop() placeholder?: string | null;\n\n /**\n * If `true`, the user cannot modify the value.\n */\n @Prop() readonly = false;\n\n /**\n * If `true`, the user must fill in a value before submitting a form.\n */\n @Prop() required = false;\n\n /**\n * If `true`, the element will have its spelling and grammar checked.\n */\n @Prop() spellcheck = false;\n\n /**\n * Specifies the state of the input. By default the input is in an initial state but you can set it to 'error' state if the data given by the user is not valid.\n */\n @Prop({reflect: true}) state: 'initial' | 'error' = 'initial';\n\n /**\n * The visible width of the text control, in average character widths. If it is specified, it must be a positive integer.\n */\n @Prop() cols?: number;\n\n /**\n * The number of visible text lines for the control.\n */\n @Prop() rows?: number;\n\n /**\n * Indicates how the control wraps text.\n */\n @Prop() wrap?: 'hard' | 'soft' | 'off';\n\n /**\n * If `true`, the element height will increase based on the value.\n */\n @Prop() autoGrow = false;\n\n /**\n * The value of the textarea.\n */\n @Prop({mutable: true}) value?: string | null = '';\n\n /**\n * Indicates how the textarea should be resizable.\n * Possible values 'both' | 'none' | 'vertical' | 'horizontal'\n */\n @Prop({reflect: true}) resize?: 'both' | 'none' | 'vertical' | 'horizontal';\n\n /**\n * Update the native input element when the value changes\n */\n @Watch('value')\n protected valueChanged() {\n const nativeInput = this.nativeInput;\n const value = this.getValue();\n if (nativeInput && nativeInput.value !== value) {\n nativeInput.value = value;\n }\n this.runAutoGrow();\n this.wcsChange.emit({value});\n }\n\n /**\n * Emitted when the input value has changed.\n */\n @Event() wcsChange!: EventEmitter<TextareaChangeEventDetail>;\n\n /**\n * Emitted when a keyboard input occurred.\n */\n @Event() wcsInput!: EventEmitter<KeyboardEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() wcsBlur!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input has focus.\n */\n @Event() wcsFocus!: EventEmitter<FocusEvent>;\n\n connectedCallback() {\n this.debounceChanged();\n if (Build.isBrowser) {\n document.dispatchEvent(new CustomEvent('wcsInputDidLoad', {\n detail: this.el\n }));\n }\n }\n\n disconnectedCallback() {\n if (Build.isBrowser) {\n document.dispatchEvent(new CustomEvent('wcsInputDidUnload', {\n detail: this.el\n }));\n }\n }\n\n componentWillLoad() {\n this.inheritedAttributes = inheritAttributes(this.el, ['title']);\n }\n\n componentDidLoad() {\n raf(() => this.runAutoGrow());\n }\n\n private runAutoGrow() {\n const nativeInput = this.nativeInput;\n if (nativeInput && this.autoGrow) {\n readTask(() => {\n nativeInput.style.height = 'auto';\n nativeInput.style.height = nativeInput.scrollHeight + 'px';\n });\n }\n }\n\n /**\n * This method make the textarea automatically adopt the size of the content without a scroll bar\n */\n @Method()\n async fitContent() {\n raf(() => this.runAutoGrow());\n }\n\n /**\n * @deprecated use the native focus method instead \n * Sets focus on the native `textarea` in `wcs-textarea`.\n */\n @Method()\n async setFocus() {\n if (this.nativeInput) {\n this.nativeInput.focus();\n }\n }\n\n /**\n * Sets blur on the native `textarea` in `wcs-textarea`. Use this method instead of the global\n * `textarea.blur()`.\n * @internal\n */\n @Method()\n async setBlur() {\n if (this.nativeInput) {\n this.nativeInput.blur();\n }\n }\n\n /**\n * Returns the native `<textarea>` element used under the hood.\n */\n @Method()\n getInputElement(): Promise<HTMLTextAreaElement> {\n // tslint:disable-next-line:no-non-null-assertion\n return Promise.resolve(this.nativeInput!);\n }\n\n /**\n * Check if we need to clear the text input if clearOnEdit is enabled\n */\n private checkClearOnEdit() {\n if (!this.clearOnEdit) {\n return;\n }\n\n // Did the input value change after it was blurred and edited?\n if (this.didBlurAfterEdit && this.hasValue()) {\n // Clear the input\n this.value = '';\n }\n\n // Reset the flag\n this.didBlurAfterEdit = false;\n }\n\n private focusChange() {\n // If clearOnEdit is enabled and the input blurred but has a value, set a flag\n if (this.clearOnEdit && !this.hasFocus && this.hasValue()) {\n this.didBlurAfterEdit = true;\n }\n }\n\n private hasValue(): boolean {\n return this.getValue() !== '';\n }\n\n private getValue(): string {\n return this.value || '';\n }\n\n private onInput = (ev: Event) => {\n if (this.nativeInput) {\n this.value = this.nativeInput.value;\n }\n this.wcsInput.emit(ev as KeyboardEvent);\n }\n\n private onFocus = (ev: FocusEvent) => {\n this.hasFocus = true;\n this.focusChange();\n\n if (this.fireFocusEvents) {\n this.wcsFocus.emit(ev);\n }\n }\n\n private onBlur = (ev: FocusEvent) => {\n this.hasFocus = false;\n this.focusChange();\n\n if (this.fireFocusEvents) {\n this.wcsBlur.emit(ev);\n }\n }\n\n private onKeyDown = () => {\n this.checkClearOnEdit();\n }\n\n render() {\n const value = this.getValue();\n const labelId = this.inputId + '-lbl';\n const label = findItemLabel(this.el);\n if (label) {\n label.id = labelId;\n }\n const style = {\n ...(this.resize && {'resize': this.resize})\n }\n\n return (\n <Host\n aria-disabled={this.disabled ? 'true' : null}\n >\n {this.icon ? (<wcs-mat-icon icon={this.icon} size=\"m\"></wcs-mat-icon>) : null}\n <textarea\n class=\"native-textarea\"\n aria-labelledby={label ? labelId : null}\n ref={el => this.nativeInput = el}\n autoCapitalize={this.autocapitalize}\n autoFocus={this.autofocus}\n enterKeyHint={this.enterkeyhint}\n inputMode={this.inputmode}\n disabled={this.disabled}\n maxLength={this.maxlength}\n minLength={this.minlength}\n name={this.name}\n placeholder={this.placeholder || ''}\n readOnly={this.readonly}\n required={this.required}\n spellcheck={this.spellcheck}\n cols={this.cols}\n rows={this.rows}\n wrap={this.wrap}\n onInput={this.onInput}\n onBlur={this.onBlur}\n onFocus={this.onFocus}\n onKeyDown={this.onKeyDown}\n style={style}\n {...this.inheritedAttributes}\n >\n {value}\n </textarea>\n </Host>\n );\n }\n}\n\nlet textareaIds = 0;\n"],"version":3}
|
package/dist/esm/wcs.js
CHANGED
|
@@ -17,7 +17,7 @@ const patchBrowser = () => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
patchBrowser().then(options => {
|
|
20
|
-
return bootstrapLazy([["wcs-editable-field",[[1,"wcs-editable-field",{"type":[1],"label":[1],"readonly":[4],"value":[1032],"validateFn":[16],"formatFn":[16],"errorMsg":[1,"error-msg"],"size":[513],"currentState":[32],"isError":[32]},[[8,"click","onWindowClickEvent"]]]]],["wcs-horizontal-stepper",[[1,"wcs-horizontal-stepper",{"currentStep":[1026,"current-step"],"steps":[16],"mode":[1],"checkOnComplete":[4,"check-on-complete"],"internalCurrentStep":[32],"previous":[64],"next":[64]}]]],["wcs-counter",[[
|
|
20
|
+
return bootstrapLazy([["wcs-editable-field",[[1,"wcs-editable-field",{"type":[1],"label":[1],"readonly":[4],"value":[1032],"validateFn":[16],"formatFn":[16],"errorMsg":[1,"error-msg"],"size":[513],"currentState":[32],"isError":[32]},[[8,"click","onWindowClickEvent"]]]]],["wcs-horizontal-stepper",[[1,"wcs-horizontal-stepper",{"currentStep":[1026,"current-step"],"steps":[16],"mode":[1],"checkOnComplete":[4,"check-on-complete"],"internalCurrentStep":[32],"previous":[64],"next":[64]}]]],["wcs-counter",[[17,"wcs-counter",{"size":[513],"label":[1],"min":[1026],"max":[1026],"step":[1026],"value":[1026],"displayedValue":[32]}]]],["wcs-grid",[[1,"wcs-grid",{"serverMode":[4,"server-mode"],"data":[16],"loading":[4],"selectionConfig":[1,"selection-config"],"selectedItems":[8,"selected-items"],"wcsGridPaginationId":[1,"wcs-grid-pagination-id"],"rowIdPath":[1,"row-id-path"],"columns":[32],"paginationEl":[32],"rows":[32]},[[0,"wcsHiddenChange","onHiddenColumnChange"],[0,"wcsSortChange","sortChangeEventHandler"],[0,"wcsGridPaginationChange","paginationChangeEventHandler"],[8,"wcsGridPaginationChange","paginationChangeEventHandlerOutside"]]]]],["wcs-grid-pagination",[[1,"wcs-grid-pagination",{"availablePageSizes":[16],"currentPage":[2,"current-page"],"pageSize":[2,"page-size"],"itemsCount":[2,"items-count"],"pageCount":[2,"page-count"]}]]],["wcs-modal",[[4,"wcs-modal",{"withoutBackdrop":[516,"without-backdrop"],"show":[516],"showCloseButton":[516,"show-close-button"],"size":[1],"hideActions":[516,"hide-actions"]},[[4,"keydown","onKeyDown"]]]]],["wcs-dropdown",[[17,"wcs-dropdown",{"noArrow":[4,"no-arrow"],"mode":[1],"shape":[1],"disabled":[4],"placement":[1],"expanded":[32]},[[8,"click","onWindowClickEvent"],[0,"wcsDropdownItemClick","dropdownItemClick"],[0,"keydown","onKeyDown"]]]]],["wcs-galactic-menu",[[1,"wcs-galactic-menu",{"text":[1],"showPopoverMenu":[32]},[[8,"click","onWindowClickEvent"]]]]],["wcs-input",[[17,"wcs-input",{"fireFocusEvents":[4,"fire-focus-events"],"accept":[1],"autocapitalize":[1],"autocomplete":[1],"autocorrect":[1],"autofocus":[4],"clearInput":[4,"clear-input"],"clearOnEdit":[4,"clear-on-edit"],"debounce":[2],"prefixLabel":[1,"prefix-label"],"suffixLabel":[1,"suffix-label"],"disabled":[4],"enterkeyhint":[1],"size":[513],"icon":[1],"inputmode":[1],"max":[1],"maxlength":[2],"min":[1],"minlength":[2],"multiple":[4],"name":[1],"pattern":[1],"placeholder":[1],"readonly":[4],"required":[4],"spellcheck":[4],"state":[513],"step":[1],"type":[1],"value":[1032],"hasFocus":[32],"passwordReveal":[32],"setFocus":[64],"setBlur":[64],"getInputElement":[64]}]]],["wcs-textarea",[[17,"wcs-textarea",{"fireFocusEvents":[4,"fire-focus-events"],"autocapitalize":[1],"autofocus":[4],"clearOnEdit":[1028,"clear-on-edit"],"debounce":[2],"disabled":[4],"icon":[1],"inputmode":[1],"enterkeyhint":[1],"maxlength":[2],"minlength":[2],"name":[1],"placeholder":[1],"readonly":[4],"required":[4],"spellcheck":[4],"state":[513],"cols":[2],"rows":[2],"wrap":[1],"autoGrow":[4,"auto-grow"],"value":[1025],"resize":[513],"hasFocus":[32],"fitContent":[64],"setFocus":[64],"setBlur":[64],"getInputElement":[64]}]]],["wcs-accordion",[[1,"wcs-accordion",{"hideActionText":[516,"hide-action-text"],"highlight":[516],"groupContentWithHeader":[516,"group-content-with-header"]},[[0,"wcsOpenChange","wcsOpenChangeHandler"]]]]],["wcs-accordion-content",[[1,"wcs-accordion-content"]]],["wcs-accordion-header",[[1,"wcs-accordion-header"]]],["wcs-accordion-panel",[[1,"wcs-accordion-panel",{"open":[1540],"hideActionText":[516,"hide-action-text"],"highlight":[516],"groupContentWithHeader":[516,"group-content-with-header"],"close":[64]}]]],["wcs-action-bar",[[1,"wcs-action-bar",{"gutter":[4],"hasTabs":[32]}]]],["wcs-app",[[1,"wcs-app"]]],["wcs-badge",[[1,"wcs-badge",{"shape":[1],"color":[1]}]]],["wcs-card",[[1,"wcs-card",{"mode":[1537]}]]],["wcs-card-body",[[1,"wcs-card-body"]]],["wcs-com-nav",[[1,"wcs-com-nav",{"appName":[1,"app-name"],"mobileMenuOpen":[32],"currentActiveSizing":[32]},[[0,"wcsClickOnFinalAction","onClickOnFinalAction"],[0,"wcsCategoryItemClicked","onClickOnFinalActionCat"],[8,"keydown","exitMobileMenuOnKeyDown"]]]]],["wcs-com-nav-category",[[1,"wcs-com-nav-category",{"label":[1],"categoryOpen":[32],"close":[64],"open":[64]},[[8,"click","onWindowClickEvent"],[8,"wcsCategoryOpened","onSubmenuOpened"]]]]],["wcs-com-nav-submenu",[[1,"wcs-com-nav-submenu",{"label":[1],"panelTitle":[1,"panel-title"],"panelDescription":[1,"panel-description"],"menuOpen":[32],"close":[64],"open":[64]},[[8,"click","onWindowClickEvent"],[8,"wcsSubmenuOpened","onSubmenuOpened"],[8,"keydown","onEscapeKeyDown"],[0,"wcsCategoryItemClicked","wcsCategoryItemClickedHandler"]]]]],["wcs-divider",[[1,"wcs-divider"]]],["wcs-dropdown-divider",[[1,"wcs-dropdown-divider"]]],["wcs-dropdown-header",[[1,"wcs-dropdown-header"]]],["wcs-dropdown-item",[[4,"wcs-dropdown-item",null,[[1,"mousedown","onMouseDown"],[0,"keydown","onKeyDown"]]]]],["wcs-field",[[1,"wcs-field"]]],["wcs-field-content",[[1,"wcs-field-content"]]],["wcs-field-label",[[1,"wcs-field-label"]]],["wcs-footer",[[1,"wcs-footer"]]],["wcs-galactic",[[1,"wcs-galactic",{"text":[1],"show":[32]}]]],["wcs-grid-column",[[1,"wcs-grid-column",{"path":[1],"name":[1],"sort":[4],"sortFn":[16],"formatter":[16],"sortOrder":[1025,"sort-order"],"width":[1],"customCells":[4,"custom-cells"],"hidden":[4]}]]],["wcs-grid-custom-cell",[[1,"wcs-grid-custom-cell",{"columnId":[1,"column-id"],"rowId":[8,"row-id"]}]]],["wcs-header",[[1,"wcs-header"]]],["wcs-hint",[[1,"wcs-hint",{"small":[1540]}]]],["wcs-icon",[[0,"wcs-icon",{"icon":[1],"size":[1]}]]],["wcs-label",[[1,"wcs-label",{"required":[516]}]]],["wcs-list-item",[[1,"wcs-list-item",{"activated":[1028]}]]],["wcs-list-item-properties",[[1,"wcs-list-item-properties"]]],["wcs-list-item-property",[[1,"wcs-list-item-property"]]],["wcs-native-select",[[1,"wcs-native-select",{"size":[513],"expanded":[32],"disabled":[32],"updateStyles":[64]}]]],["wcs-nav",[[1,"wcs-nav"]]],["wcs-nav-item",[[4,"wcs-nav-item",{"text":[513],"href":[513]},[[0,"keydown","onKeyDown"]]]]],["wcs-progress-radial",[[1,"wcs-progress-radial",{"size":[2],"showLabel":[4,"show-label"],"value":[2]}]]],["wcs-radio-group",[[1,"wcs-radio-group",{"value":[8],"name":[520],"mode":[513]},[[0,"wcsRadioClick","selectedOptionChanged"],[0,"keydown","handleKeyDown"],[0,"keyup","handleKeyUp"]]]]],["wcs-skeleton-circle",[[1,"wcs-skeleton-circle",{"animation":[513],"radius":[514]}]]],["wcs-skeleton-rectangle",[[1,"wcs-skeleton-rectangle",{"animation":[513],"rounded":[516],"height":[513],"width":[513]}]]],["wcs-skeleton-text",[[1,"wcs-skeleton-text",{"animation":[513],"height":[1]}]]],["wcs-switch",[[1,"wcs-switch",{"name":[1],"checked":[516],"labelAlignment":[513,"label-alignment"],"disabled":[4]}]]],["wcs-tab",[[1,"wcs-tab",{"header":[513],"itemKey":[8,"item-key"]}]]],["wcs-tabs",[[1,"wcs-tabs",{"align":[513],"selectedIndex":[2,"selected-index"],"selectedKey":[8,"selected-key"],"headersOnly":[4,"headers-only"],"gutter":[4],"description":[1],"headers":[32],"currentActiveTabIndex":[32]},[[0,"tabLoaded","onTabLoaded"]]]]],["wcs-tooltip",[[1,"wcs-tooltip",{"for":[1],"position":[513],"interactive":[4],"maxWidth":[8,"max-width"],"delay":[2],"duration":[2],"trigger":[1],"theme":[1],"content":[1],"appendTo":[1,"append-to"],"hide":[64],"show":[64],"disable":[64],"enable":[64]}]]],["wcs-progress-bar",[[1,"wcs-progress-bar",{"small":[4],"showLabel":[4,"show-label"],"value":[2]}]]],["wcs-radio",[[17,"wcs-radio",{"mode":[513],"value":[1544],"label":[1537],"checked":[1540],"disabled":[1028],"name":[1]},[[0,"keydown","onKeyDown"]]]]],["wcs-select_2",[[4,"wcs-select-option",{"disabled":[1540],"selected":[1540],"value":[8],"chipColor":[1,"chip-color"],"chipBackgroundColor":[1,"chip-background-color"],"multiple":[1540]},[[1,"mousedown","onMouseDown"],[0,"keydown","handleKeydown"]]],[1,"wcs-select",{"size":[513],"value":[1032],"placeholder":[1537],"disabled":[1028],"multiple":[516],"chips":[516],"name":[1],"compareWith":[16],"expanded":[32],"hasLoaded":[32],"displayText":[32],"focused":[32],"overlayDirection":[32],"open":[64],"close":[64]},[[1,"mousedown","onMouseDown"],[8,"click","onWindowClickEvent"],[0,"keydown","onKeyDown"],[0,"wcsSelectOptionClick","selectedOptionChanged"]]]]],["wcs-error_2",[[1,"wcs-error"],[1,"wcs-form-field",{"isError":[1540,"is-error"],"hasPrefix":[32],"hasSuffix":[32],"spiedElement":[32]}]]],["wcs-checkbox",[[17,"wcs-checkbox",{"name":[1],"indeterminate":[1540],"checked":[1540],"labelAlignment":[1537,"label-alignment"],"disabled":[4]}]]],["wcs-button",[[17,"wcs-button",{"type":[1025],"href":[1],"target":[1],"disabled":[516],"ripple":[4],"size":[513],"shape":[513],"mode":[513],"loading":[1028]},[[0,"click","onClick"]]]]],["wcs-mat-icon",[[1,"wcs-mat-icon",{"icon":[1],"size":[1],"family":[1]}]]],["wcs-spinner",[[1,"wcs-spinner",{"mode":[513]}]]]], options);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
//# sourceMappingURL=wcs.js.map
|
|
@@ -173,9 +173,7 @@ export declare class Input implements ComponentInterface {
|
|
|
173
173
|
disconnectedCallback(): void;
|
|
174
174
|
/**
|
|
175
175
|
* @deprecated use the native focus method instead
|
|
176
|
-
*
|
|
177
|
-
* Sets focus on the native `input` in `wcs-input`. Use this method instead of the global
|
|
178
|
-
* `input.focus()`.
|
|
176
|
+
* Sets focus on the native `input` in `wcs-input`.
|
|
179
177
|
*/
|
|
180
178
|
setFocus(): Promise<void>;
|
|
181
179
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EventEmitter } from '../../stencil-public-runtime';
|
|
1
|
+
import { EventEmitter, ComponentInterface } from '../../stencil-public-runtime';
|
|
2
2
|
import { ModalSize } from './modal-interface';
|
|
3
|
-
export declare class Modal {
|
|
3
|
+
export declare class Modal implements ComponentInterface {
|
|
4
|
+
el: HTMLElement;
|
|
4
5
|
/**
|
|
5
6
|
* Specifies whether the component should display a backdrop on the entire page
|
|
6
7
|
*/
|
|
@@ -27,8 +28,27 @@ export declare class Modal {
|
|
|
27
28
|
* Specifies whether the component should hide the actions slot or not
|
|
28
29
|
*/
|
|
29
30
|
hideActions: boolean;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Give an unique id
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
private modalId;
|
|
36
|
+
private firstFocusableElement;
|
|
37
|
+
private lastFocusableElement;
|
|
38
|
+
/**
|
|
39
|
+
* This attribute is used to determine whether the show attribute has changed since the last rendering.
|
|
40
|
+
* This allows us to call the focus method on the first element of the modal when the show attribute changes to true.
|
|
41
|
+
* This call is made in the componentDidRender method
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
private showAttributeChangedMarker;
|
|
45
|
+
componentDidLoad(): void;
|
|
46
|
+
componentDidRender(): void;
|
|
47
|
+
onShowChange(): void;
|
|
48
|
+
private updateFocusableElements;
|
|
33
49
|
private close;
|
|
50
|
+
onKeyDown(event: KeyboardEvent): void;
|
|
51
|
+
private onCloseButtonClick;
|
|
52
|
+
private handleSlotContentChange;
|
|
53
|
+
render(): any;
|
|
34
54
|
}
|
package/dist/types/components/native-select/{native-select.component.d.ts → native-select.d.ts}
RENAMED
|
@@ -2,15 +2,21 @@ import { ComponentInterface } from '../../stencil-public-runtime';
|
|
|
2
2
|
import { WcsSize } from "../../shared-types";
|
|
3
3
|
export type WcsNativeSelectSize = Extract<WcsSize, 'l' | 'm'>;
|
|
4
4
|
/**
|
|
5
|
-
* The `wcs-native-select` component is designed to accept a native
|
|
6
|
-
* allows developers to bind the
|
|
7
|
-
* properties of the
|
|
5
|
+
* The `wcs-native-select` component is designed to accept a native `<select>` element as a slotted child. This choice
|
|
6
|
+
* allows developers to bind the `<select>` element using the framework of their choice, without the need to re-expose all the
|
|
7
|
+
* properties of the `<select>` and `<option>` elements in this component.
|
|
8
8
|
*
|
|
9
|
-
* The component wraps the native
|
|
9
|
+
* The component wraps the native `<select>` element and provides custom styles and behavior, while preserving the native
|
|
10
10
|
* functionality and accessibility.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* ### ✅ Guidance
|
|
13
13
|
*
|
|
14
|
+
* - To have a placeholder, you must have an option as child which has `selected` attribute and `disabled`
|
|
15
|
+
* attribute. You can add the `hidden` attribute to don't show the placeholder option in the options overlay.
|
|
16
|
+
*
|
|
17
|
+
* ### Example usage
|
|
18
|
+
*
|
|
19
|
+
* ```html
|
|
14
20
|
* <wcs-native-select>
|
|
15
21
|
* <select>
|
|
16
22
|
* <option value="option1">Option 1</option>
|
|
@@ -18,6 +24,12 @@ export type WcsNativeSelectSize = Extract<WcsSize, 'l' | 'm'>;
|
|
|
18
24
|
* <option value="option3">Option 3</option>
|
|
19
25
|
* </select>
|
|
20
26
|
* </wcs-native-select>
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* ### Note
|
|
30
|
+
* - We did not find a way to detect when the select is reset, if you want to apply the placeholder style when the
|
|
31
|
+
* select is reset, you have to call the `updateStyles()` method manually.
|
|
32
|
+
* - It is strongly recommended to use select-native when you don't have to support the multi-selection feature
|
|
21
33
|
*/
|
|
22
34
|
export declare class NativeSelect implements ComponentInterface {
|
|
23
35
|
/**
|
|
@@ -37,6 +49,7 @@ export declare class NativeSelect implements ComponentInterface {
|
|
|
37
49
|
private readonly SLOTTED_SELECT_TRACKED_ATTRIBUTES_LIST;
|
|
38
50
|
componentWillLoad(): void;
|
|
39
51
|
private onSelectedOptionChange;
|
|
52
|
+
private _updateStyles;
|
|
40
53
|
private isPlaceholderOptionSelected;
|
|
41
54
|
/**
|
|
42
55
|
* This method should always unset all styles modified by the `applyPlaceholderStylesOnNativeSlottedSelectElement()`
|
|
@@ -52,5 +65,9 @@ export declare class NativeSelect implements ComponentInterface {
|
|
|
52
65
|
private applyPlaceholderStylesOnNativeSlottedSelectElement;
|
|
53
66
|
private updateHostAttributeWithSlottedSelect;
|
|
54
67
|
disconnectedCallback(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Use this method to force the component to update its styles. It can be useful when the select is reset (with a placeholder).
|
|
70
|
+
*/
|
|
71
|
+
updateStyles(): Promise<void>;
|
|
55
72
|
render(): any;
|
|
56
73
|
}
|
|
@@ -17,7 +17,9 @@ export declare class Radio implements ComponentInterface {
|
|
|
17
17
|
*/
|
|
18
18
|
disabled: boolean;
|
|
19
19
|
wcsRadioClick: EventEmitter<RadioChosedEvent>;
|
|
20
|
+
name: string;
|
|
20
21
|
onKeyDown(_event: KeyboardEvent): void;
|
|
22
|
+
checkedChanged(newValue: boolean): void;
|
|
21
23
|
componentWillLoad(): Promise<void> | void;
|
|
22
24
|
componentDidLoad(): void;
|
|
23
25
|
emitRadioChangeEvent(): void;
|
|
@@ -11,7 +11,10 @@ export declare class RadioGroup implements ComponentInterface {
|
|
|
11
11
|
onValueChangeHandler(newValue: any): void;
|
|
12
12
|
componentDidLoad(): void;
|
|
13
13
|
private get options();
|
|
14
|
+
private get optionsNotDisabled();
|
|
14
15
|
selectedOptionChanged(event: CustomEvent<RadioChosedEvent>): void;
|
|
16
|
+
handleKeyDown(ev: KeyboardEvent): void;
|
|
17
|
+
handleKeyUp(ev: KeyboardEvent): Promise<void>;
|
|
15
18
|
private updateOptionsState;
|
|
16
19
|
render(): any;
|
|
17
20
|
}
|
|
@@ -30,6 +30,10 @@ export declare class Tabs implements ComponentInterface {
|
|
|
30
30
|
headersOnly: boolean;
|
|
31
31
|
/** Determines if tabs header should have a border at the bottom */
|
|
32
32
|
gutter: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Description is used to provide aria-label for the tabs container which has `role="tablist"`.
|
|
35
|
+
*/
|
|
36
|
+
description: string;
|
|
33
37
|
/**
|
|
34
38
|
*
|
|
35
39
|
* Emitted when the selected tab change.
|
|
@@ -38,6 +42,7 @@ export declare class Tabs implements ComponentInterface {
|
|
|
38
42
|
private el;
|
|
39
43
|
private headers;
|
|
40
44
|
private currentActiveTabIndex;
|
|
45
|
+
private tabsId;
|
|
41
46
|
selectedIndexChanged(newValue: number): void;
|
|
42
47
|
selectedTabkeyChanged(newValue: any): void;
|
|
43
48
|
private emitActiveTabChange;
|
|
@@ -53,4 +58,12 @@ export declare class Tabs implements ComponentInterface {
|
|
|
53
58
|
private updateTabVisibility;
|
|
54
59
|
private hideAllTabsContent;
|
|
55
60
|
render(): any;
|
|
61
|
+
/**
|
|
62
|
+
* Observe when a new tab panel is added to the slot to let's handle accessibility properties for tabs panel:
|
|
63
|
+
* - id: to let header tab refers it proper panel
|
|
64
|
+
* - aria-label: take the same name as it's referenced header name
|
|
65
|
+
*
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
private onTabsSlotChange;
|
|
56
69
|
}
|
|
@@ -146,8 +146,8 @@ export declare class Textarea implements ComponentInterface {
|
|
|
146
146
|
*/
|
|
147
147
|
fitContent(): Promise<void>;
|
|
148
148
|
/**
|
|
149
|
-
*
|
|
150
|
-
* `textarea
|
|
149
|
+
* @deprecated use the native focus method instead
|
|
150
|
+
* Sets focus on the native `textarea` in `wcs-textarea`.
|
|
151
151
|
*/
|
|
152
152
|
setFocus(): Promise<void>;
|
|
153
153
|
/**
|