@cupra/ui-kit 2.0.0-canary.126 → 2.0.0-canary.127
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/components/ds-select/ds-select.cjs +7 -6
- package/dist/cjs/components/ds-theme-provider/ds-theme-provider.cjs +1 -1
- package/dist/cjs/decorators/customUiKitElement.cjs +1 -1
- package/dist/cjs/utils/IconsManager.cjs +1 -1
- package/dist/cjs/utils/PubSub.cjs +1 -1
- package/dist/cjs/utils/StylesRegistry/StylesRegistry.cjs +1 -1
- package/dist/cjs/utils/cssWithTokens.cjs +1 -1
- package/dist/cjs/utils/htmlWithTokens.cjs +1 -1
- package/dist/cjs/utils/version.cjs +1 -1
- package/dist/esm/components/ds-select/ds-select.js +28 -18
- package/dist/esm/components/ds-theme-provider/ds-theme-provider.js +1 -1
- package/dist/esm/decorators/customUiKitElement.js +1 -1
- package/dist/esm/utils/IconsManager.js +1 -1
- package/dist/esm/utils/PubSub.js +1 -1
- package/dist/esm/utils/StylesRegistry/StylesRegistry.js +1 -1
- package/dist/esm/utils/cssWithTokens.js +1 -1
- package/dist/esm/utils/htmlWithTokens.js +1 -1
- package/dist/esm/utils/version.js +1 -1
- package/dist/types/components/ds-select/ds-select.d.ts +4 -1
- package/dist/types/components/ds-select/ds-select.types.d.ts +2 -0
- package/dist-react/cjs/components/ds-select/ds-select.cjs +7 -6
- package/dist-react/cjs/components/ds-theme-provider/ds-theme-provider.cjs +1 -1
- package/dist-react/cjs/decorators/customUiKitElement.cjs +1 -1
- package/dist-react/cjs/utils/IconsManager.cjs +1 -1
- package/dist-react/cjs/utils/PubSub.cjs +1 -1
- package/dist-react/cjs/utils/StylesRegistry/StylesRegistry.cjs +1 -1
- package/dist-react/cjs/utils/cssWithTokens.cjs +1 -1
- package/dist-react/cjs/utils/htmlWithTokens.cjs +1 -1
- package/dist-react/cjs/utils/version.cjs +1 -1
- package/dist-react/esm/components/ds-select/ds-select.js +28 -18
- package/dist-react/esm/components/ds-theme-provider/ds-theme-provider.js +1 -1
- package/dist-react/esm/decorators/customUiKitElement.js +1 -1
- package/dist-react/esm/utils/IconsManager.js +1 -1
- package/dist-react/esm/utils/PubSub.js +1 -1
- package/dist-react/esm/utils/StylesRegistry/StylesRegistry.js +1 -1
- package/dist-react/esm/utils/cssWithTokens.js +1 -1
- package/dist-react/esm/utils/htmlWithTokens.js +1 -1
- package/dist-react/esm/utils/version.js +1 -1
- package/dist-react/types/components/ds-select/ds-select.d.ts +4 -1
- package/dist-react/types/components/ds-select/ds-select.types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require(`../ds-theme-provider/themeContext.cjs`);const e=require(`../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);const t=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.cjs`),n=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.cjs`),r=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query.cjs`),i=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query-assigned-elements.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/decorators.cjs`);const a=require(`../../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.cjs`),o=require(`../base/UiKitElement.cjs`),s=require(`../../decorators/customUiKitElement.cjs`),c=require(`../../utils/booleanConverter.cjs`),l=require(`../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/directives/class-map.cjs`);const u=require(`./controllers/SelectKeyboardController.cjs`),d=require(`./styles/common.styles.cjs`);var f,p=class extends o.UiKitElement{static{f=this}constructor(...e){super(...e),this.mode=`light`,this.size=`large`,this.variant=`primary`,this.readonly=!1,this._open=!1,this.nativeSelect=null,this.nativeLabel=null,this.nativeOptions=[],this.
|
|
1
|
+
require(`../ds-theme-provider/themeContext.cjs`);const e=require(`../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);const t=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.cjs`),n=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.cjs`),r=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query.cjs`),i=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query-assigned-elements.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/decorators.cjs`);const a=require(`../../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.cjs`),o=require(`../base/UiKitElement.cjs`),s=require(`../../decorators/customUiKitElement.cjs`),c=require(`../../utils/booleanConverter.cjs`),l=require(`../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/directives/class-map.cjs`);const u=require(`./controllers/SelectKeyboardController.cjs`),d=require(`./styles/common.styles.cjs`);var f,p=class extends o.UiKitElement{static{f=this}constructor(...e){super(...e),this.mode=`light`,this.size=`large`,this.variant=`primary`,this.readonly=!1,this.iconName=void 0,this._open=!1,this._keyboardNavigating=!1,this.nativeSelect=null,this.nativeLabel=null,this.nativeOptions=[],this.keyboardFocusIndex=-1,this.hasForcedError=!1,this.handleMutations=e=>{e.forEach(e=>{e.type===`childList`&&this.syncNativeOptions()}),this.requestUpdate()},this.syncNativeOptions=()=>{this.nativeOptions=Array.from(this.nativeSelect.options)},this.handleOpen=()=>{this.readonly||(this._open=!0,this.keyboardFocusIndex=this.findSelectedOptionIndex(),this.focusDisplaySelect())},this.handleClose=()=>{this._open=!1},this.handleClickDisplaySelect=()=>{this._open?this.handleClose():(this._keyboardNavigating=!1,this.handleOpen())},this.handleKeydown=e=>{this._open?(this._keyboardNavigating=!0,u.SelectKeyboardController.handleKeydownWhenOpen(e,{commit:()=>this.commitSelection(),navigateNext:()=>this.advanceSelection(1),navigatePrev:()=>this.advanceSelection(-1),navigateFirst:()=>this.advanceToFirst(),navigateLast:()=>this.advanceToLast(),close:this.handleClose})):u.SelectKeyboardController.handleKeydownWhenClosed(e,{open:()=>{this._keyboardNavigating=!0,this.handleOpen()}})}}static{this.styles=[d.commonStyles]}static{this.ARIA_OPTION_PREFIX=`option-`}firstUpdated(){queueMicrotask(()=>this.initializeNativeSelect())}disconnectedCallback(){super.disconnectedCallback(),this.cleanup()}initializeNativeSelect(){this.nativeSelect=this.nativeSelects?.[0],this.nativeLabel=this.nativeLabels?.[0],this.nativeSelect&&(this.syncNativeOptions(),this.setupNativeElementsAttributes(),this.setupEventListeners())}handleChangeForcedError(){this.hasForcedError=this.forcedError?.length>0}setupNativeElementsAttributes(){this.nativeSelect.setAttribute(`aria-hidden`,`true`),this.nativeSelect.setAttribute(`tabindex`,`-1`)}setupEventListeners(){this.nativeSelect.addEventListener(`change`,this.syncNativeOptions),this.observer=new MutationObserver(this.handleMutations),this.observer.observe(this.nativeSelect,{childList:!0,subtree:!0,attributes:!0})}cleanup(){this.nativeSelect?.removeEventListener(`change`,this.syncNativeOptions),this.observer?.disconnect()}findSelectedOptionIndex(){let e=this.nativeOptions.findIndex(e=>e.value===this.nativeSelect.value);return this.nativeOptions[e]?.hidden?this.nativeOptions.findIndex(e=>!e.hidden):e}focusDisplaySelect(){this.updateComplete.then(()=>{this.displaySelect?.focus()})}advanceToFirst(){if(this.nativeOptions.length){let e=this.nativeOptions.findIndex(e=>!e.hidden);this.advanceSelection(e-this.keyboardFocusIndex)}}advanceToLast(){if(this.nativeOptions.length){let e=-1;for(let t=this.nativeOptions.length-1;t>=0;t--)if(!this.nativeOptions[t].hidden){e=t;break}this.advanceSelection(e-this.keyboardFocusIndex)}}advanceSelection(e){let t=this.nativeOptions.length;this.keyboardFocusIndex=(this.keyboardFocusIndex+e+t)%t,this.shouldSkipHiddenOption()?this.advanceSelection(Math.sign(e)):this.scrollToActive(this.nativeOptions[this.keyboardFocusIndex])}shouldSkipHiddenOption(){return this.nativeOptions.some(e=>!e.hidden)&&this.nativeOptions[this.keyboardFocusIndex].hidden}scrollToActive(e){e?.scrollIntoView?.({block:`nearest`})}commitSelection(e=this.keyboardFocusIndex){this.handleClose();let t=this.nativeOptions[e];this.nativeSelect&&t?.value&&this.updateNativeSelectValue(t.value)}updateNativeSelectValue(e){this.nativeSelect.value=e,[`input`,`change`].forEach(e=>this.nativeSelect.dispatchEvent(new Event(e,{bubbles:!0,composed:!0})))}get containerClasses(){return{container:!0,open:this._open,disabled:!!this.nativeSelect?.disabled,readonly:!!this.readonly,filled:!!this.nativeOptions?.find(e=>e.selected&&!e.hidden)?.selected,invalid:!this.nativeSelect?.validity.valid,error:this.hasForcedError,[this.size]:!!this.size,[this.mode]:!!this.mode,[this.variant]:!!this.variant}}set open(e){this._open=e}get open(){return this._open}render(){return e.x`
|
|
2
2
|
<slot @slotchange=${this.initializeNativeSelect}></slot>
|
|
3
3
|
<div class=${l.e(this.containerClasses)}>
|
|
4
4
|
${this.displaySelectTemplate}
|
|
@@ -8,7 +8,7 @@ require(`../ds-theme-provider/themeContext.cjs`);const e=require(`../../node_mod
|
|
|
8
8
|
<slot name="forced-error" @slotchange=${this.handleChangeForcedError}></slot>
|
|
9
9
|
<slot name="invalid-error"></slot>
|
|
10
10
|
</div>
|
|
11
|
-
`}get iconTemplate(){return this.componentFactory.createIcon({class:`icon`,"icon-name":this._open?`arrow-up`:`arrow-down`})}get displaySelectTemplate(){let t=this.nativeOptions.find(e=>e.selected),n=Array.from(t?.childNodes||[])?.map(e=>{let t=e.cloneNode(!0);if(e.nodeType!==3)return t;if(e.textContent.trim()===``)return``;let n=document.createElement(`span`);return n.classList.add(`text`),n.appendChild(t),n});return e.x`
|
|
11
|
+
`}get iconTemplate(){return this.componentFactory.createIcon({class:`icon`,"icon-name":this._open?`arrow-up`:`arrow-down`})}get leftIconTemplate(){return this.iconName?this.componentFactory.createIcon({class:`left-icon`,"icon-name":this.iconName}):e.E}get displaySelectTemplate(){let t=this.nativeOptions.find(e=>e.selected),n=Array.from(t?.childNodes||[])?.map(e=>{let t=e.cloneNode(!0);if(e.nodeType!==3)return t;if(e.textContent.trim()===``)return``;let n=document.createElement(`span`);return n.classList.add(`text`),n.appendChild(t),n});return e.x`
|
|
12
12
|
<div class="select-outline">
|
|
13
13
|
<div class="select-container">
|
|
14
14
|
<label id="display-label" class="label">${this.nativeLabel?.innerText}</label>
|
|
@@ -25,24 +25,25 @@ require(`../ds-theme-provider/themeContext.cjs`);const e=require(`../../node_mod
|
|
|
25
25
|
@keydown=${this.handleKeydown}
|
|
26
26
|
@blur=${this.handleClose}
|
|
27
27
|
>
|
|
28
|
+
${this.leftIconTemplate}
|
|
28
29
|
<span class="select-content">${n}</span>
|
|
29
30
|
${this.iconTemplate}
|
|
30
31
|
</div>
|
|
31
32
|
</div>
|
|
32
33
|
</div>
|
|
33
|
-
`}get activeDescendantId(){return this._open&&this.
|
|
34
|
+
`}get activeDescendantId(){return this._open&&this.keyboardFocusIndex>=0?`${f.ARIA_OPTION_PREFIX}${this.nativeOptions[this.keyboardFocusIndex].value}`:``}get optionsContainerTemplate(){return e.x`
|
|
34
35
|
<div id="options-container" class="options-container" role="listbox">
|
|
35
36
|
${this.nativeOptions.map((t,n)=>t.hidden?e.E:this.renderOptionClone(t,n))}
|
|
36
37
|
</div>
|
|
37
38
|
`}renderOptionClone(t,n){let r=Array.from(t.childNodes).map(e=>e.cloneNode(!0));return e.x`
|
|
38
39
|
<div
|
|
39
40
|
id="${f.ARIA_OPTION_PREFIX}${t.value}"
|
|
40
|
-
class=${l.e({option:!0,
|
|
41
|
+
class=${l.e({option:!0,"keyboard-focused":n===this.keyboardFocusIndex&&this._keyboardNavigating,selected:t.value===this.nativeSelect.value})}
|
|
41
42
|
role="option"
|
|
42
43
|
aria-selected="${t.value===this.nativeSelect.value}"
|
|
43
44
|
tabindex="-1"
|
|
44
|
-
@mousedown=${()=>
|
|
45
|
+
@mousedown=${()=>this.commitSelection(n)}
|
|
45
46
|
>
|
|
46
47
|
${r}
|
|
47
48
|
</div>
|
|
48
|
-
`}};a.__decorate([t.n({type:String})],p.prototype,`mode`,void 0),a.__decorate([t.n({type:String})],p.prototype,`size`,void 0),a.__decorate([t.n({type:String})],p.prototype,`variant`,void 0),a.__decorate([t.n({type:Boolean,converter:c.booleanConverter,reflect:!0})],p.prototype,`readonly`,void 0),a.__decorate([n.r()],p.prototype,`_open`,void 0),a.__decorate([n.r()],p.prototype,`nativeOptions`,void 0),a.__decorate([n.r()],p.prototype,`
|
|
49
|
+
`}};a.__decorate([t.n({type:String})],p.prototype,`mode`,void 0),a.__decorate([t.n({type:String})],p.prototype,`size`,void 0),a.__decorate([t.n({type:String})],p.prototype,`variant`,void 0),a.__decorate([t.n({type:Boolean,converter:c.booleanConverter,reflect:!0})],p.prototype,`readonly`,void 0),a.__decorate([t.n({type:String,attribute:`icon-name`})],p.prototype,`iconName`,void 0),a.__decorate([n.r()],p.prototype,`_open`,void 0),a.__decorate([n.r()],p.prototype,`_keyboardNavigating`,void 0),a.__decorate([n.r()],p.prototype,`nativeOptions`,void 0),a.__decorate([n.r()],p.prototype,`keyboardFocusIndex`,void 0),a.__decorate([n.r()],p.prototype,`hasForcedError`,void 0),a.__decorate([i.o({slot:``,selector:`select`,flatten:!0})],p.prototype,`nativeSelects`,void 0),a.__decorate([i.o({slot:``,selector:`label`,flatten:!0})],p.prototype,`nativeLabels`,void 0),a.__decorate([i.o({slot:`forced-error`,flatten:!0})],p.prototype,`forcedError`,void 0),a.__decorate([r.e(`.select`)],p.prototype,`displaySelect`,void 0),p=f=a.__decorate([s.customUiKitElement(`ds-select`)],p);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
const e=require(`../../node_modules/.pnpm/@lit_context@1.1.6/node_modules/@lit/context/lib/decorators/provide.cjs`),t=require(`./themeContext.cjs`),n=require(`../../core/theme.constants.cjs`),r=require(`../../utils/PubSub.cjs`),i=require(`../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.cjs`),a=require(`../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);const o=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.cjs`),s=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/decorators.cjs`);const c=require(`../../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.cjs`),l=require(`../../decorators/customUiKitElement.cjs`),u=require(`../../utils/booleanConverter.cjs`),d=require(`../../styles/source/shared/fonts-config.cjs`);var f=class extends a.i{constructor(...e){super(...e),this.loadFonts=!0,this.loadStyles=!0,this.cssLoaded=!1,this.loadedFonts=new Set}updated(e){super.updated(e),e.has(`theme`)&&(r.pubSub.publish(`theme`,this.theme),sessionStorage?.setItem(n.THEME_STORAGE_KEY,this.theme),typeof FontFace<`u`&&document?.fonts&&this.loadThemeFonts(),this.loadThemeStyles().then(()=>{this.cssLoaded=!0,this.dispatchEvent(new CustomEvent(`ui-kit:ready`,{bubbles:!0,composed:!0}))}))}loadThemeFonts(){d.fontsConfig[this.theme]?.fonts.forEach(e=>{this.loadThemeFont(e)})}async loadThemeFont({weight:e,name:t,file:n}){if(!this.loadFonts)return Promise.resolve();let r=`${t}-${e}`;if(this.loadedFonts.has(r))return;let i=new FontFace(t,`url('https://ds-assets.cupra.com/fonts/${this.theme}/${n}.woff2') format('woff2'),
|
|
2
2
|
url('https://ds-assets.cupra.com/fonts/${this.theme}/${n}.woff') format('woff'),
|
|
3
3
|
url('https://ds-assets.cupra.com/fonts/${this.theme}/${n}.ttf') format('truetype'),
|
|
4
|
-
url('https://ds-assets.cupra.com/fonts/${this.theme}/${n}.otf') format('opentype')`,{style:`normal`,weight:e,display:`swap`});try{await i.load(),document.fonts.add(i),this.loadedFonts.add(r)}catch(n){console.error(`Error loading "${t}" font with "${e}" weight:`,n)}}loadThemeStyles(){return this.loadStyles?new Promise((e,t)=>{let n=`/2.0.0-canary.
|
|
4
|
+
url('https://ds-assets.cupra.com/fonts/${this.theme}/${n}.otf') format('opentype')`,{style:`normal`,weight:e,display:`swap`});try{await i.load(),document.fonts.add(i),this.loadedFonts.add(r)}catch(n){console.error(`Error loading "${t}" font with "${e}" weight:`,n)}}loadThemeStyles(){return this.loadStyles?new Promise((e,t)=>{let n=`/2.0.0-canary.127`,r=`https://ds-assets.cupra.com${n}/styles/${this.theme}/theme.css`;if(document.head.querySelector(`link[href="${r}"]`))e();else{let i=`ui-kit-theme-${n}`,a=document.getElementById(i),o=document.createElement(`link`);o.id=i,o.rel=`stylesheet`,o.href=r,o.onload=()=>e(),o.onerror=()=>t(Error(`Failed to load theme CSS: ${r}`)),document.head.appendChild(o),a?.remove()}}):Promise.resolve()}render(){return this.cssLoaded?i.x`<slot></slot>`:i.E}};c.__decorate([o.n({type:Boolean,converter:u.booleanConverter,attribute:`load-fonts`})],f.prototype,`loadFonts`,void 0),c.__decorate([o.n({type:Boolean,converter:u.booleanConverter,attribute:`load-styles`})],f.prototype,`loadStyles`,void 0),c.__decorate([e.e({context:t.themeContext}),o.n({type:String})],f.prototype,`theme`,void 0),c.__decorate([s.r()],f.prototype,`cssLoaded`,void 0),c.__decorate([s.r()],f.prototype,`loadedFonts`,void 0),f=c.__decorate([l.customUiKitElement(`ds-theme-provider`)],f);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../utils/version.cjs`),t=require(`../utils/componentFactory.cjs`);function n(n,r){return function(i){if(!i?.prototype)throw TypeError(`@customUiKitElement requires a class that extends HTMLElement.`);let a=typeof __UIKIT_TARGET__<`u`&&__UIKIT_TARGET__===`react`,o=a?`${n}${e.VERSION_TAG_SUFFIX}`:n;if(globalThis?.customElements?.get(o))return;let s=r?.skipTagAsComponentName?[]:[n];Array.isArray(r?.extendComponentNames)&&(s=[...r.extendComponentNames,...s]),globalThis?.customElements?.define?.(o,class extends i{constructor(...e){super(...e),this.componentFactory=a?t.reactFactory:t.standardFactory}static{this.componentName=s}connectedCallback(){i.prototype.connectedCallback?.call(this),this.setAttribute(`data-ui-kit-version`,`2.0.0-canary.
|
|
1
|
+
const e=require(`../utils/version.cjs`),t=require(`../utils/componentFactory.cjs`);function n(n,r){return function(i){if(!i?.prototype)throw TypeError(`@customUiKitElement requires a class that extends HTMLElement.`);let a=typeof __UIKIT_TARGET__<`u`&&__UIKIT_TARGET__===`react`,o=a?`${n}${e.VERSION_TAG_SUFFIX}`:n;if(globalThis?.customElements?.get(o))return;let s=r?.skipTagAsComponentName?[]:[n];Array.isArray(r?.extendComponentNames)&&(s=[...r.extendComponentNames,...s]),globalThis?.customElements?.define?.(o,class extends i{constructor(...e){super(...e),this.componentFactory=a?t.reactFactory:t.standardFactory}static{this.componentName=s}connectedCallback(){i.prototype.connectedCallback?.call(this),this.setAttribute(`data-ui-kit-version`,`2.0.0-canary.127`)}})}}exports.customUiKitElement=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../core/theme.constants.cjs`),t=require(`./PubSub.cjs`);var n=class{constructor(){this.icons={},this.handleChangeTheme=e=>{if(this.theme===e)return;this.theme=e;let t=Object.keys(this.icons);this.icons={},t.forEach(e=>this.fetchIcon(e))},this.fetchIcon=async(t,n={})=>{let r=typeof sessionStorage<`u`?sessionStorage?.getItem(e.THEME_STORAGE_KEY):null;!this.theme&&r&&(this.theme=r);let i=this.icons[t];if(i)return await i;let a=this.loadIcon(t,n).catch(e=>{throw delete this.icons[t],e});return this.icons[t]=a,a},this.loadIcon=(e,{cache:t=`force-cache`,...n})=>!this.theme||typeof fetch>`u`?Promise.resolve(`<svg class="ds-icon"></svg>`):fetch(`https://ds-assets.cupra.com/icons/${this.theme}/${e}.svg`,{cache:t,...n}).then(e=>e.text()).catch(t=>{if(t?.name===`AbortError`)throw t;return console.error(`Failed to fetch icon "${e}":`,t),``}),t.pubSub.subscribe(`theme`,this.handleChangeTheme)}},r=Symbol.for(`@cupra/ui-kit/icons-manager/2.0.0-canary.
|
|
1
|
+
const e=require(`../core/theme.constants.cjs`),t=require(`./PubSub.cjs`);var n=class{constructor(){this.icons={},this.handleChangeTheme=e=>{if(this.theme===e)return;this.theme=e;let t=Object.keys(this.icons);this.icons={},t.forEach(e=>this.fetchIcon(e))},this.fetchIcon=async(t,n={})=>{let r=typeof sessionStorage<`u`?sessionStorage?.getItem(e.THEME_STORAGE_KEY):null;!this.theme&&r&&(this.theme=r);let i=this.icons[t];if(i)return await i;let a=this.loadIcon(t,n).catch(e=>{throw delete this.icons[t],e});return this.icons[t]=a,a},this.loadIcon=(e,{cache:t=`force-cache`,...n})=>!this.theme||typeof fetch>`u`?Promise.resolve(`<svg class="ds-icon"></svg>`):fetch(`https://ds-assets.cupra.com/icons/${this.theme}/${e}.svg`,{cache:t,...n}).then(e=>e.text()).catch(t=>{if(t?.name===`AbortError`)throw t;return console.error(`Failed to fetch icon "${e}":`,t),``}),t.pubSub.subscribe(`theme`,this.handleChangeTheme)}},r=Symbol.for(`@cupra/ui-kit/icons-manager/2.0.0-canary.127`),i=globalThis,a=i[r];a||(a=new n,Object.defineProperty(i,r,{value:a,writable:!1,configurable:!1,enumerable:!1}));var o=a;exports.iconsManager=o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=class{constructor(){this.subscribers={},this.lastPublishedData={}}subscribe(e,t){return this.subscribers[e]||(this.subscribers[e]=[]),this.subscribers[e].push(t),this.lastPublishedData[e]}unsubscribe(e,t){this.subscribers[e]&&(this.subscribers[e]=this.subscribers[e].filter(e=>e!==t))}publish(e,t){this.lastPublishedData[e]=t,this.subscribers[e]&&this.subscribers[e].forEach(n=>{try{n(t)}catch(t){console.error(`Error in subscriber for event "${e}":`,t)}})}},t=Symbol.for(`@cupra/ui-kit/pubsub/2.0.0-canary.
|
|
1
|
+
var e=class{constructor(){this.subscribers={},this.lastPublishedData={}}subscribe(e,t){return this.subscribers[e]||(this.subscribers[e]=[]),this.subscribers[e].push(t),this.lastPublishedData[e]}unsubscribe(e,t){this.subscribers[e]&&(this.subscribers[e]=this.subscribers[e].filter(e=>e!==t))}publish(e,t){this.lastPublishedData[e]=t,this.subscribers[e]&&this.subscribers[e].forEach(n=>{try{n(t)}catch(t){console.error(`Error in subscriber for event "${e}":`,t)}})}},t=Symbol.for(`@cupra/ui-kit/pubsub/2.0.0-canary.127`),n=globalThis,r=n[t];r||(r=new e,Object.defineProperty(n,t,{value:r,writable:!1,configurable:!1,enumerable:!1}));var i=r;exports.pubSub=i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=require(`../concurrencyLimit.cjs`).concurrencyLimit(20),t=class t{constructor(){this.stylePromises=new Map,this.getStyles=async({componentName:t,theme:n})=>{if(!n||!t)return;let r=`https://ds-assets.cupra.com/2.0.0-canary.
|
|
1
|
+
var e=require(`../concurrencyLimit.cjs`).concurrencyLimit(20),t=class t{constructor(){this.stylePromises=new Map,this.getStyles=async({componentName:t,theme:n})=>{if(!n||!t)return;let r=`https://ds-assets.cupra.com/2.0.0-canary.127/styles/${n}/components/${t}.css`,i=this.getCachedStyleSheetPromise({url:r});if(i)return i;let a=e(()=>this.fetchStyle({url:r})).then(e=>(e||this.stylePromises.delete(r),e));return this.stylePromises.set(r,a),this.stylePromises.get(r)}}async fetchStyle({url:e}){try{if(typeof fetch>`u`)return;let t=await fetch(e,{cache:`force-cache`});if(t.ok)return t.text()}catch(t){console.error(`Failed to fetch Style Sheet "${e}":`,t)}}getCachedStyleSheetPromise({url:e}){return this.stylePromises.get(e)}static getInstance(){return t.instance||=new t,t.instance}}.getInstance();exports.stylesRegistry=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.cjs`);require(`../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);function t(t,...n){return e.i`${e.r(String.raw({raw:t},...n).replace(/(--private-[\w-]+)(?=\s*[):,])/g,`$1-v2-0-0-canary-
|
|
1
|
+
const e=require(`../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.cjs`);require(`../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);function t(t,...n){return e.i`${e.r(String.raw({raw:t},...n).replace(/(--private-[\w-]+)(?=\s*[):,])/g,`$1-v2-0-0-canary-127`))}`}exports.cssWithTokens=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.cjs`);require(`../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);const t=require(`../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/unsafe-html.cjs`);require(`../node_modules/.pnpm/lit@3.3.1/node_modules/lit/directives/unsafe-html.cjs`);function n(n,...r){return e.x`${t.o(String.raw({raw:n},...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g,`$1-v2-0-0-canary-
|
|
1
|
+
const e=require(`../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.cjs`);require(`../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);const t=require(`../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/unsafe-html.cjs`);require(`../node_modules/.pnpm/lit@3.3.1/node_modules/lit/directives/unsafe-html.cjs`);function n(n,...r){return e.x`${t.o(String.raw({raw:n},...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g,`$1-v2-0-0-canary-127`))}`}exports.htmlWithTokens=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`2.0.0-canary.
|
|
1
|
+
var e=`2.0.0-canary.127`,t=`--v${e.replaceAll(`.`,`-`)}`;exports.VERSION=e,exports.VERSION_TAG_SUFFIX=t;
|
|
@@ -20,27 +20,29 @@ var p, m = class extends s {
|
|
|
20
20
|
p = this;
|
|
21
21
|
}
|
|
22
22
|
constructor(...e) {
|
|
23
|
-
super(...e), this.mode = "light", this.size = "large", this.variant = "primary", this.readonly = !1, this._open = !1, this.nativeSelect = null, this.nativeLabel = null, this.nativeOptions = [], this.
|
|
23
|
+
super(...e), this.mode = "light", this.size = "large", this.variant = "primary", this.readonly = !1, this.iconName = void 0, this._open = !1, this._keyboardNavigating = !1, this.nativeSelect = null, this.nativeLabel = null, this.nativeOptions = [], this.keyboardFocusIndex = -1, this.hasForcedError = !1, this.handleMutations = (e) => {
|
|
24
24
|
e.forEach((e) => {
|
|
25
25
|
e.type === "childList" && this.syncNativeOptions();
|
|
26
26
|
}), this.requestUpdate();
|
|
27
27
|
}, this.syncNativeOptions = () => {
|
|
28
28
|
this.nativeOptions = Array.from(this.nativeSelect.options);
|
|
29
29
|
}, this.handleOpen = () => {
|
|
30
|
-
this.readonly || (this._open = !0, this.
|
|
30
|
+
this.readonly || (this._open = !0, this.keyboardFocusIndex = this.findSelectedOptionIndex(), this.focusDisplaySelect());
|
|
31
31
|
}, this.handleClose = () => {
|
|
32
32
|
this._open = !1;
|
|
33
33
|
}, this.handleClickDisplaySelect = () => {
|
|
34
|
-
this._open ? this.handleClose() : this.handleOpen();
|
|
34
|
+
this._open ? this.handleClose() : (this._keyboardNavigating = !1, this.handleOpen());
|
|
35
35
|
}, this.handleKeydown = (e) => {
|
|
36
|
-
this._open ? d.handleKeydownWhenOpen(e, {
|
|
36
|
+
this._open ? (this._keyboardNavigating = !0, d.handleKeydownWhenOpen(e, {
|
|
37
37
|
commit: () => this.commitSelection(),
|
|
38
38
|
navigateNext: () => this.advanceSelection(1),
|
|
39
39
|
navigatePrev: () => this.advanceSelection(-1),
|
|
40
40
|
navigateFirst: () => this.advanceToFirst(),
|
|
41
41
|
navigateLast: () => this.advanceToLast(),
|
|
42
42
|
close: this.handleClose
|
|
43
|
-
}) : d.handleKeydownWhenClosed(e, { open:
|
|
43
|
+
})) : d.handleKeydownWhenClosed(e, { open: () => {
|
|
44
|
+
this._keyboardNavigating = !0, this.handleOpen();
|
|
45
|
+
} });
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
static {
|
|
@@ -86,7 +88,7 @@ var p, m = class extends s {
|
|
|
86
88
|
advanceToFirst() {
|
|
87
89
|
if (this.nativeOptions.length) {
|
|
88
90
|
let e = this.nativeOptions.findIndex((e) => !e.hidden);
|
|
89
|
-
this.advanceSelection(e - this.
|
|
91
|
+
this.advanceSelection(e - this.keyboardFocusIndex);
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
advanceToLast() {
|
|
@@ -96,23 +98,23 @@ var p, m = class extends s {
|
|
|
96
98
|
e = t;
|
|
97
99
|
break;
|
|
98
100
|
}
|
|
99
|
-
this.advanceSelection(e - this.
|
|
101
|
+
this.advanceSelection(e - this.keyboardFocusIndex);
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
advanceSelection(e) {
|
|
103
105
|
let t = this.nativeOptions.length;
|
|
104
|
-
this.
|
|
106
|
+
this.keyboardFocusIndex = (this.keyboardFocusIndex + e + t) % t, this.shouldSkipHiddenOption() ? this.advanceSelection(Math.sign(e)) : this.scrollToActive(this.nativeOptions[this.keyboardFocusIndex]);
|
|
105
107
|
}
|
|
106
108
|
shouldSkipHiddenOption() {
|
|
107
|
-
return this.nativeOptions.some((e) => !e.hidden) && this.nativeOptions[this.
|
|
109
|
+
return this.nativeOptions.some((e) => !e.hidden) && this.nativeOptions[this.keyboardFocusIndex].hidden;
|
|
108
110
|
}
|
|
109
111
|
scrollToActive(e) {
|
|
110
112
|
e?.scrollIntoView?.({ block: "nearest" });
|
|
111
113
|
}
|
|
112
|
-
commitSelection() {
|
|
114
|
+
commitSelection(e = this.keyboardFocusIndex) {
|
|
113
115
|
this.handleClose();
|
|
114
|
-
let
|
|
115
|
-
this.nativeSelect &&
|
|
116
|
+
let t = this.nativeOptions[e];
|
|
117
|
+
this.nativeSelect && t?.value && this.updateNativeSelectValue(t.value);
|
|
116
118
|
}
|
|
117
119
|
updateNativeSelectValue(e) {
|
|
118
120
|
this.nativeSelect.value = e, ["input", "change"].forEach((e) => this.nativeSelect.dispatchEvent(new Event(e, {
|
|
@@ -159,6 +161,12 @@ var p, m = class extends s {
|
|
|
159
161
|
"icon-name": this._open ? "arrow-up" : "arrow-down"
|
|
160
162
|
});
|
|
161
163
|
}
|
|
164
|
+
get leftIconTemplate() {
|
|
165
|
+
return this.iconName ? this.componentFactory.createIcon({
|
|
166
|
+
class: "left-icon",
|
|
167
|
+
"icon-name": this.iconName
|
|
168
|
+
}) : e;
|
|
169
|
+
}
|
|
162
170
|
get displaySelectTemplate() {
|
|
163
171
|
let e = this.nativeOptions.find((e) => e.selected), n = Array.from(e?.childNodes || [])?.map((e) => {
|
|
164
172
|
let t = e.cloneNode(!0);
|
|
@@ -184,6 +192,7 @@ var p, m = class extends s {
|
|
|
184
192
|
@keydown=${this.handleKeydown}
|
|
185
193
|
@blur=${this.handleClose}
|
|
186
194
|
>
|
|
195
|
+
${this.leftIconTemplate}
|
|
187
196
|
<span class="select-content">${n}</span>
|
|
188
197
|
${this.iconTemplate}
|
|
189
198
|
</div>
|
|
@@ -192,7 +201,7 @@ var p, m = class extends s {
|
|
|
192
201
|
`;
|
|
193
202
|
}
|
|
194
203
|
get activeDescendantId() {
|
|
195
|
-
return this._open && this.
|
|
204
|
+
return this._open && this.keyboardFocusIndex >= 0 ? `${p.ARIA_OPTION_PREFIX}${this.nativeOptions[this.keyboardFocusIndex].value}` : "";
|
|
196
205
|
}
|
|
197
206
|
get optionsContainerTemplate() {
|
|
198
207
|
return t`
|
|
@@ -208,15 +217,13 @@ var p, m = class extends s {
|
|
|
208
217
|
id="${p.ARIA_OPTION_PREFIX}${e.value}"
|
|
209
218
|
class=${u({
|
|
210
219
|
option: !0,
|
|
211
|
-
|
|
220
|
+
"keyboard-focused": n === this.keyboardFocusIndex && this._keyboardNavigating,
|
|
212
221
|
selected: e.value === this.nativeSelect.value
|
|
213
222
|
})}
|
|
214
223
|
role="option"
|
|
215
224
|
aria-selected="${e.value === this.nativeSelect.value}"
|
|
216
225
|
tabindex="-1"
|
|
217
|
-
@mousedown=${() =>
|
|
218
|
-
this.activeIndex = n, this.commitSelection();
|
|
219
|
-
}}
|
|
226
|
+
@mousedown=${() => this.commitSelection(n)}
|
|
220
227
|
>
|
|
221
228
|
${r}
|
|
222
229
|
</div>
|
|
@@ -227,7 +234,10 @@ o([n({ type: String })], m.prototype, "mode", void 0), o([n({ type: String })],
|
|
|
227
234
|
type: Boolean,
|
|
228
235
|
converter: l,
|
|
229
236
|
reflect: !0
|
|
230
|
-
})], m.prototype, "readonly", void 0), o([
|
|
237
|
+
})], m.prototype, "readonly", void 0), o([n({
|
|
238
|
+
type: String,
|
|
239
|
+
attribute: "icon-name"
|
|
240
|
+
})], m.prototype, "iconName", void 0), o([r()], m.prototype, "_open", void 0), o([r()], m.prototype, "_keyboardNavigating", void 0), o([r()], m.prototype, "nativeOptions", void 0), o([r()], m.prototype, "keyboardFocusIndex", void 0), o([r()], m.prototype, "hasForcedError", void 0), o([a({
|
|
231
241
|
slot: "",
|
|
232
242
|
selector: "select",
|
|
233
243
|
flatten: !0
|
|
@@ -50,7 +50,7 @@ var p = class extends o {
|
|
|
50
50
|
}
|
|
51
51
|
loadThemeStyles() {
|
|
52
52
|
return this.loadStyles ? new Promise((e, t) => {
|
|
53
|
-
let n = "/2.0.0-canary.
|
|
53
|
+
let n = "/2.0.0-canary.127", r = `https://ds-assets.cupra.com${n}/styles/${this.theme}/theme.css`;
|
|
54
54
|
if (document.head.querySelector(`link[href="${r}"]`)) e();
|
|
55
55
|
else {
|
|
56
56
|
let i = `ui-kit-theme-${n}`, a = document.getElementById(i), o = document.createElement("link");
|
|
@@ -15,7 +15,7 @@ function r(r, i) {
|
|
|
15
15
|
this.componentName = c;
|
|
16
16
|
}
|
|
17
17
|
connectedCallback() {
|
|
18
|
-
a.prototype.connectedCallback?.call(this), this.setAttribute("data-ui-kit-version", "2.0.0-canary.
|
|
18
|
+
a.prototype.connectedCallback?.call(this), this.setAttribute("data-ui-kit-version", "2.0.0-canary.127");
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
};
|
|
@@ -25,7 +25,7 @@ var n = class {
|
|
|
25
25
|
return console.error(`Failed to fetch icon "${e}":`, t), "";
|
|
26
26
|
}), t.subscribe("theme", this.handleChangeTheme);
|
|
27
27
|
}
|
|
28
|
-
}, r = Symbol.for("@cupra/ui-kit/icons-manager/2.0.0-canary.
|
|
28
|
+
}, r = Symbol.for("@cupra/ui-kit/icons-manager/2.0.0-canary.127"), i = globalThis, a = i[r];
|
|
29
29
|
a || (a = new n(), Object.defineProperty(i, r, {
|
|
30
30
|
value: a,
|
|
31
31
|
writable: !1,
|
package/dist/esm/utils/PubSub.js
CHANGED
|
@@ -18,7 +18,7 @@ var e = class {
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
}, t = Symbol.for("@cupra/ui-kit/pubsub/2.0.0-canary.
|
|
21
|
+
}, t = Symbol.for("@cupra/ui-kit/pubsub/2.0.0-canary.127"), n = globalThis, r = n[t];
|
|
22
22
|
r || (r = new e(), Object.defineProperty(n, t, {
|
|
23
23
|
value: r,
|
|
24
24
|
writable: !1,
|
|
@@ -4,7 +4,7 @@ var t = e(20), n = class e {
|
|
|
4
4
|
constructor() {
|
|
5
5
|
this.stylePromises = /* @__PURE__ */ new Map(), this.getStyles = async ({ componentName: e, theme: n }) => {
|
|
6
6
|
if (!n || !e) return;
|
|
7
|
-
let r = `https://ds-assets.cupra.com/2.0.0-canary.
|
|
7
|
+
let r = `https://ds-assets.cupra.com/2.0.0-canary.127/styles/${n}/components/${e}.css`, i = this.getCachedStyleSheetPromise({ url: r });
|
|
8
8
|
if (i) return i;
|
|
9
9
|
let a = t(() => this.fetchStyle({ url: r })).then((e) => (e || this.stylePromises.delete(r), e));
|
|
10
10
|
return this.stylePromises.set(r, a), this.stylePromises.get(r);
|
|
@@ -2,7 +2,7 @@ import { i as e, r as t } from "../node_modules/.pnpm/@lit_reactive-element@2.1.
|
|
|
2
2
|
import "../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.js";
|
|
3
3
|
//#region src/utils/cssWithTokens.ts
|
|
4
4
|
function n(n, ...r) {
|
|
5
|
-
return e`${t(String.raw({ raw: n }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v2-0-0-canary-
|
|
5
|
+
return e`${t(String.raw({ raw: n }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v2-0-0-canary-127"))}`;
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
8
|
export { n as cssWithTokens };
|
|
@@ -4,7 +4,7 @@ import { o as t } from "../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-ht
|
|
|
4
4
|
import "../node_modules/.pnpm/lit@3.3.1/node_modules/lit/directives/unsafe-html.js";
|
|
5
5
|
//#region src/utils/htmlWithTokens.ts
|
|
6
6
|
function n(n, ...r) {
|
|
7
|
-
return e`${t(String.raw({ raw: n }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v2-0-0-canary-
|
|
7
|
+
return e`${t(String.raw({ raw: n }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v2-0-0-canary-127"))}`;
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
10
|
export { n as htmlWithTokens };
|
|
@@ -8,11 +8,13 @@ export declare class DsSelect extends UiKitElement {
|
|
|
8
8
|
size: DsSelectAttrs['size'];
|
|
9
9
|
variant: DsSelectAttrs['variant'];
|
|
10
10
|
readonly: DsSelectAttrs['readonly'];
|
|
11
|
+
iconName: DsSelectAttrs['icon-name'];
|
|
11
12
|
private _open;
|
|
13
|
+
private _keyboardNavigating;
|
|
12
14
|
private nativeSelect;
|
|
13
15
|
private nativeLabel;
|
|
14
16
|
private nativeOptions;
|
|
15
|
-
|
|
17
|
+
keyboardFocusIndex: number;
|
|
16
18
|
hasForcedError: boolean;
|
|
17
19
|
private nativeSelects;
|
|
18
20
|
private nativeLabels;
|
|
@@ -54,6 +56,7 @@ export declare class DsSelect extends UiKitElement {
|
|
|
54
56
|
get open(): boolean;
|
|
55
57
|
render(): import("lit").TemplateResult<1>;
|
|
56
58
|
protected get iconTemplate(): any;
|
|
59
|
+
protected get leftIconTemplate(): any;
|
|
57
60
|
private get displaySelectTemplate();
|
|
58
61
|
private get activeDescendantId();
|
|
59
62
|
private get optionsContainerTemplate();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { DsIconAttrs } from '../ds-icon/ds-icon.types.ts';
|
|
1
2
|
import type { CommonAttrs } from '../../types/types.ts';
|
|
2
3
|
export interface DsSelectAttrs extends CommonAttrs {
|
|
3
4
|
mode?: 'dark' | 'light';
|
|
4
5
|
size?: 'large' | 'medium';
|
|
5
6
|
variant?: 'primary' | 'secondary' | (string & {});
|
|
6
7
|
readonly?: boolean;
|
|
8
|
+
'icon-name'?: DsIconAttrs['icon-name'];
|
|
7
9
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require(`../ds-theme-provider/themeContext.cjs`);const e=require(`../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);const t=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.cjs`),n=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.cjs`),r=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query.cjs`),i=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query-assigned-elements.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/decorators.cjs`);const a=require(`../../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.cjs`),o=require(`../base/UiKitElement.cjs`),s=require(`../../decorators/customUiKitElement.cjs`),c=require(`../../utils/booleanConverter.cjs`),l=require(`../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/directives/class-map.cjs`);const u=require(`./controllers/SelectKeyboardController.cjs`),d=require(`./styles/common.styles.cjs`);var f,p=class extends o.UiKitElement{static{f=this}constructor(...e){super(...e),this.mode=`light`,this.size=`large`,this.variant=`primary`,this.readonly=!1,this._open=!1,this.nativeSelect=null,this.nativeLabel=null,this.nativeOptions=[],this.
|
|
1
|
+
require(`../ds-theme-provider/themeContext.cjs`);const e=require(`../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);const t=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.cjs`),n=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.cjs`),r=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query.cjs`),i=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query-assigned-elements.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/decorators.cjs`);const a=require(`../../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.cjs`),o=require(`../base/UiKitElement.cjs`),s=require(`../../decorators/customUiKitElement.cjs`),c=require(`../../utils/booleanConverter.cjs`),l=require(`../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/directives/class-map.cjs`);const u=require(`./controllers/SelectKeyboardController.cjs`),d=require(`./styles/common.styles.cjs`);var f,p=class extends o.UiKitElement{static{f=this}constructor(...e){super(...e),this.mode=`light`,this.size=`large`,this.variant=`primary`,this.readonly=!1,this.iconName=void 0,this._open=!1,this._keyboardNavigating=!1,this.nativeSelect=null,this.nativeLabel=null,this.nativeOptions=[],this.keyboardFocusIndex=-1,this.hasForcedError=!1,this.handleMutations=e=>{e.forEach(e=>{e.type===`childList`&&this.syncNativeOptions()}),this.requestUpdate()},this.syncNativeOptions=()=>{this.nativeOptions=Array.from(this.nativeSelect.options)},this.handleOpen=()=>{this.readonly||(this._open=!0,this.keyboardFocusIndex=this.findSelectedOptionIndex(),this.focusDisplaySelect())},this.handleClose=()=>{this._open=!1},this.handleClickDisplaySelect=()=>{this._open?this.handleClose():(this._keyboardNavigating=!1,this.handleOpen())},this.handleKeydown=e=>{this._open?(this._keyboardNavigating=!0,u.SelectKeyboardController.handleKeydownWhenOpen(e,{commit:()=>this.commitSelection(),navigateNext:()=>this.advanceSelection(1),navigatePrev:()=>this.advanceSelection(-1),navigateFirst:()=>this.advanceToFirst(),navigateLast:()=>this.advanceToLast(),close:this.handleClose})):u.SelectKeyboardController.handleKeydownWhenClosed(e,{open:()=>{this._keyboardNavigating=!0,this.handleOpen()}})}}static{this.styles=[d.commonStyles]}static{this.ARIA_OPTION_PREFIX=`option-`}firstUpdated(){queueMicrotask(()=>this.initializeNativeSelect())}disconnectedCallback(){super.disconnectedCallback(),this.cleanup()}initializeNativeSelect(){this.nativeSelect=this.nativeSelects?.[0],this.nativeLabel=this.nativeLabels?.[0],this.nativeSelect&&(this.syncNativeOptions(),this.setupNativeElementsAttributes(),this.setupEventListeners())}handleChangeForcedError(){this.hasForcedError=this.forcedError?.length>0}setupNativeElementsAttributes(){this.nativeSelect.setAttribute(`aria-hidden`,`true`),this.nativeSelect.setAttribute(`tabindex`,`-1`)}setupEventListeners(){this.nativeSelect.addEventListener(`change`,this.syncNativeOptions),this.observer=new MutationObserver(this.handleMutations),this.observer.observe(this.nativeSelect,{childList:!0,subtree:!0,attributes:!0})}cleanup(){this.nativeSelect?.removeEventListener(`change`,this.syncNativeOptions),this.observer?.disconnect()}findSelectedOptionIndex(){let e=this.nativeOptions.findIndex(e=>e.value===this.nativeSelect.value);return this.nativeOptions[e]?.hidden?this.nativeOptions.findIndex(e=>!e.hidden):e}focusDisplaySelect(){this.updateComplete.then(()=>{this.displaySelect?.focus()})}advanceToFirst(){if(this.nativeOptions.length){let e=this.nativeOptions.findIndex(e=>!e.hidden);this.advanceSelection(e-this.keyboardFocusIndex)}}advanceToLast(){if(this.nativeOptions.length){let e=-1;for(let t=this.nativeOptions.length-1;t>=0;t--)if(!this.nativeOptions[t].hidden){e=t;break}this.advanceSelection(e-this.keyboardFocusIndex)}}advanceSelection(e){let t=this.nativeOptions.length;this.keyboardFocusIndex=(this.keyboardFocusIndex+e+t)%t,this.shouldSkipHiddenOption()?this.advanceSelection(Math.sign(e)):this.scrollToActive(this.nativeOptions[this.keyboardFocusIndex])}shouldSkipHiddenOption(){return this.nativeOptions.some(e=>!e.hidden)&&this.nativeOptions[this.keyboardFocusIndex].hidden}scrollToActive(e){e?.scrollIntoView?.({block:`nearest`})}commitSelection(e=this.keyboardFocusIndex){this.handleClose();let t=this.nativeOptions[e];this.nativeSelect&&t?.value&&this.updateNativeSelectValue(t.value)}updateNativeSelectValue(e){this.nativeSelect.value=e,[`input`,`change`].forEach(e=>this.nativeSelect.dispatchEvent(new Event(e,{bubbles:!0,composed:!0})))}get containerClasses(){return{container:!0,open:this._open,disabled:!!this.nativeSelect?.disabled,readonly:!!this.readonly,filled:!!this.nativeOptions?.find(e=>e.selected&&!e.hidden)?.selected,invalid:!this.nativeSelect?.validity.valid,error:this.hasForcedError,[this.size]:!!this.size,[this.mode]:!!this.mode,[this.variant]:!!this.variant}}set open(e){this._open=e}get open(){return this._open}render(){return e.x`
|
|
2
2
|
<slot @slotchange=${this.initializeNativeSelect}></slot>
|
|
3
3
|
<div class=${l.e(this.containerClasses)}>
|
|
4
4
|
${this.displaySelectTemplate}
|
|
@@ -8,7 +8,7 @@ require(`../ds-theme-provider/themeContext.cjs`);const e=require(`../../node_mod
|
|
|
8
8
|
<slot name="forced-error" @slotchange=${this.handleChangeForcedError}></slot>
|
|
9
9
|
<slot name="invalid-error"></slot>
|
|
10
10
|
</div>
|
|
11
|
-
`}get iconTemplate(){return this.componentFactory.createIcon({class:`icon`,"icon-name":this._open?`arrow-up`:`arrow-down`})}get displaySelectTemplate(){let t=this.nativeOptions.find(e=>e.selected),n=Array.from(t?.childNodes||[])?.map(e=>{let t=e.cloneNode(!0);if(e.nodeType!==3)return t;if(e.textContent.trim()===``)return``;let n=document.createElement(`span`);return n.classList.add(`text`),n.appendChild(t),n});return e.x`
|
|
11
|
+
`}get iconTemplate(){return this.componentFactory.createIcon({class:`icon`,"icon-name":this._open?`arrow-up`:`arrow-down`})}get leftIconTemplate(){return this.iconName?this.componentFactory.createIcon({class:`left-icon`,"icon-name":this.iconName}):e.E}get displaySelectTemplate(){let t=this.nativeOptions.find(e=>e.selected),n=Array.from(t?.childNodes||[])?.map(e=>{let t=e.cloneNode(!0);if(e.nodeType!==3)return t;if(e.textContent.trim()===``)return``;let n=document.createElement(`span`);return n.classList.add(`text`),n.appendChild(t),n});return e.x`
|
|
12
12
|
<div class="select-outline">
|
|
13
13
|
<div class="select-container">
|
|
14
14
|
<label id="display-label" class="label">${this.nativeLabel?.innerText}</label>
|
|
@@ -25,24 +25,25 @@ require(`../ds-theme-provider/themeContext.cjs`);const e=require(`../../node_mod
|
|
|
25
25
|
@keydown=${this.handleKeydown}
|
|
26
26
|
@blur=${this.handleClose}
|
|
27
27
|
>
|
|
28
|
+
${this.leftIconTemplate}
|
|
28
29
|
<span class="select-content">${n}</span>
|
|
29
30
|
${this.iconTemplate}
|
|
30
31
|
</div>
|
|
31
32
|
</div>
|
|
32
33
|
</div>
|
|
33
|
-
`}get activeDescendantId(){return this._open&&this.
|
|
34
|
+
`}get activeDescendantId(){return this._open&&this.keyboardFocusIndex>=0?`${f.ARIA_OPTION_PREFIX}${this.nativeOptions[this.keyboardFocusIndex].value}`:``}get optionsContainerTemplate(){return e.x`
|
|
34
35
|
<div id="options-container" class="options-container" role="listbox">
|
|
35
36
|
${this.nativeOptions.map((t,n)=>t.hidden?e.E:this.renderOptionClone(t,n))}
|
|
36
37
|
</div>
|
|
37
38
|
`}renderOptionClone(t,n){let r=Array.from(t.childNodes).map(e=>e.cloneNode(!0));return e.x`
|
|
38
39
|
<div
|
|
39
40
|
id="${f.ARIA_OPTION_PREFIX}${t.value}"
|
|
40
|
-
class=${l.e({option:!0,
|
|
41
|
+
class=${l.e({option:!0,"keyboard-focused":n===this.keyboardFocusIndex&&this._keyboardNavigating,selected:t.value===this.nativeSelect.value})}
|
|
41
42
|
role="option"
|
|
42
43
|
aria-selected="${t.value===this.nativeSelect.value}"
|
|
43
44
|
tabindex="-1"
|
|
44
|
-
@mousedown=${()=>
|
|
45
|
+
@mousedown=${()=>this.commitSelection(n)}
|
|
45
46
|
>
|
|
46
47
|
${r}
|
|
47
48
|
</div>
|
|
48
|
-
`}};a.__decorate([t.n({type:String})],p.prototype,`mode`,void 0),a.__decorate([t.n({type:String})],p.prototype,`size`,void 0),a.__decorate([t.n({type:String})],p.prototype,`variant`,void 0),a.__decorate([t.n({type:Boolean,converter:c.booleanConverter,reflect:!0})],p.prototype,`readonly`,void 0),a.__decorate([n.r()],p.prototype,`_open`,void 0),a.__decorate([n.r()],p.prototype,`nativeOptions`,void 0),a.__decorate([n.r()],p.prototype,`
|
|
49
|
+
`}};a.__decorate([t.n({type:String})],p.prototype,`mode`,void 0),a.__decorate([t.n({type:String})],p.prototype,`size`,void 0),a.__decorate([t.n({type:String})],p.prototype,`variant`,void 0),a.__decorate([t.n({type:Boolean,converter:c.booleanConverter,reflect:!0})],p.prototype,`readonly`,void 0),a.__decorate([t.n({type:String,attribute:`icon-name`})],p.prototype,`iconName`,void 0),a.__decorate([n.r()],p.prototype,`_open`,void 0),a.__decorate([n.r()],p.prototype,`_keyboardNavigating`,void 0),a.__decorate([n.r()],p.prototype,`nativeOptions`,void 0),a.__decorate([n.r()],p.prototype,`keyboardFocusIndex`,void 0),a.__decorate([n.r()],p.prototype,`hasForcedError`,void 0),a.__decorate([i.o({slot:``,selector:`select`,flatten:!0})],p.prototype,`nativeSelects`,void 0),a.__decorate([i.o({slot:``,selector:`label`,flatten:!0})],p.prototype,`nativeLabels`,void 0),a.__decorate([i.o({slot:`forced-error`,flatten:!0})],p.prototype,`forcedError`,void 0),a.__decorate([r.e(`.select`)],p.prototype,`displaySelect`,void 0),p=f=a.__decorate([s.customUiKitElement(`ds-select`)],p);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
const e=require(`../../node_modules/.pnpm/@lit_context@1.1.6/node_modules/@lit/context/lib/decorators/provide.cjs`),t=require(`./themeContext.cjs`),n=require(`../../core/theme.constants.cjs`),r=require(`../../utils/PubSub.cjs`),i=require(`../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.cjs`),a=require(`../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);const o=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.cjs`),s=require(`../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.cjs`);require(`../../node_modules/.pnpm/lit@3.3.1/node_modules/lit/decorators.cjs`);const c=require(`../../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.cjs`),l=require(`../../decorators/customUiKitElement.cjs`),u=require(`../../utils/booleanConverter.cjs`),d=require(`../../styles/source/shared/fonts-config.cjs`);var f=class extends a.i{constructor(...e){super(...e),this.loadFonts=!0,this.loadStyles=!0,this.cssLoaded=!1,this.loadedFonts=new Set}updated(e){super.updated(e),e.has(`theme`)&&(r.pubSub.publish(`theme`,this.theme),sessionStorage?.setItem(n.THEME_STORAGE_KEY,this.theme),typeof FontFace<`u`&&document?.fonts&&this.loadThemeFonts(),this.loadThemeStyles().then(()=>{this.cssLoaded=!0,this.dispatchEvent(new CustomEvent(`ui-kit:ready`,{bubbles:!0,composed:!0}))}))}loadThemeFonts(){d.fontsConfig[this.theme]?.fonts.forEach(e=>{this.loadThemeFont(e)})}async loadThemeFont({weight:e,name:t,file:n}){if(!this.loadFonts)return Promise.resolve();let r=`${t}-${e}`;if(this.loadedFonts.has(r))return;let i=new FontFace(t,`url('https://ds-assets.cupra.com/fonts/${this.theme}/${n}.woff2') format('woff2'),
|
|
2
2
|
url('https://ds-assets.cupra.com/fonts/${this.theme}/${n}.woff') format('woff'),
|
|
3
3
|
url('https://ds-assets.cupra.com/fonts/${this.theme}/${n}.ttf') format('truetype'),
|
|
4
|
-
url('https://ds-assets.cupra.com/fonts/${this.theme}/${n}.otf') format('opentype')`,{style:`normal`,weight:e,display:`swap`});try{await i.load(),document.fonts.add(i),this.loadedFonts.add(r)}catch(n){console.error(`Error loading "${t}" font with "${e}" weight:`,n)}}loadThemeStyles(){return this.loadStyles?new Promise((e,t)=>{let n=`/2.0.0-canary.
|
|
4
|
+
url('https://ds-assets.cupra.com/fonts/${this.theme}/${n}.otf') format('opentype')`,{style:`normal`,weight:e,display:`swap`});try{await i.load(),document.fonts.add(i),this.loadedFonts.add(r)}catch(n){console.error(`Error loading "${t}" font with "${e}" weight:`,n)}}loadThemeStyles(){return this.loadStyles?new Promise((e,t)=>{let n=`/2.0.0-canary.127`,r=`https://ds-assets.cupra.com${n}/styles/${this.theme}/theme.css`;if(document.head.querySelector(`link[href="${r}"]`))e();else{let i=`ui-kit-theme-${n}`,a=document.getElementById(i),o=document.createElement(`link`);o.id=i,o.rel=`stylesheet`,o.href=r,o.onload=()=>e(),o.onerror=()=>t(Error(`Failed to load theme CSS: ${r}`)),document.head.appendChild(o),a?.remove()}}):Promise.resolve()}render(){return this.cssLoaded?i.x`<slot></slot>`:i.E}};c.__decorate([o.n({type:Boolean,converter:u.booleanConverter,attribute:`load-fonts`})],f.prototype,`loadFonts`,void 0),c.__decorate([o.n({type:Boolean,converter:u.booleanConverter,attribute:`load-styles`})],f.prototype,`loadStyles`,void 0),c.__decorate([e.e({context:t.themeContext}),o.n({type:String})],f.prototype,`theme`,void 0),c.__decorate([s.r()],f.prototype,`cssLoaded`,void 0),c.__decorate([s.r()],f.prototype,`loadedFonts`,void 0),f=c.__decorate([l.customUiKitElement(`ds-theme-provider`)],f);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../utils/version.cjs`),t=require(`../utils/componentFactory.cjs`);function n(n,r){return function(i){if(!i?.prototype)throw TypeError(`@customUiKitElement requires a class that extends HTMLElement.`);let a=`${n}${e.VERSION_TAG_SUFFIX}`;if(globalThis?.customElements?.get(a))return;let o=r?.skipTagAsComponentName?[]:[n];Array.isArray(r?.extendComponentNames)&&(o=[...r.extendComponentNames,...o]),globalThis?.customElements?.define?.(a,class extends i{constructor(...e){super(...e),this.componentFactory=t.reactFactory}static{this.componentName=o}connectedCallback(){i.prototype.connectedCallback?.call(this),this.setAttribute(`data-ui-kit-version`,`2.0.0-canary.
|
|
1
|
+
const e=require(`../utils/version.cjs`),t=require(`../utils/componentFactory.cjs`);function n(n,r){return function(i){if(!i?.prototype)throw TypeError(`@customUiKitElement requires a class that extends HTMLElement.`);let a=`${n}${e.VERSION_TAG_SUFFIX}`;if(globalThis?.customElements?.get(a))return;let o=r?.skipTagAsComponentName?[]:[n];Array.isArray(r?.extendComponentNames)&&(o=[...r.extendComponentNames,...o]),globalThis?.customElements?.define?.(a,class extends i{constructor(...e){super(...e),this.componentFactory=t.reactFactory}static{this.componentName=o}connectedCallback(){i.prototype.connectedCallback?.call(this),this.setAttribute(`data-ui-kit-version`,`2.0.0-canary.127`)}})}}exports.customUiKitElement=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../core/theme.constants.cjs`),t=require(`./PubSub.cjs`);var n=class{constructor(){this.icons={},this.handleChangeTheme=e=>{if(this.theme===e)return;this.theme=e;let t=Object.keys(this.icons);this.icons={},t.forEach(e=>this.fetchIcon(e))},this.fetchIcon=async(t,n={})=>{let r=typeof sessionStorage<`u`?sessionStorage?.getItem(e.THEME_STORAGE_KEY):null;!this.theme&&r&&(this.theme=r);let i=this.icons[t];if(i)return await i;let a=this.loadIcon(t,n).catch(e=>{throw delete this.icons[t],e});return this.icons[t]=a,a},this.loadIcon=(e,{cache:t=`force-cache`,...n})=>!this.theme||typeof fetch>`u`?Promise.resolve(`<svg class="ds-icon"></svg>`):fetch(`https://ds-assets.cupra.com/icons/${this.theme}/${e}.svg`,{cache:t,...n}).then(e=>e.text()).catch(t=>{if(t?.name===`AbortError`)throw t;return console.error(`Failed to fetch icon "${e}":`,t),``}),t.pubSub.subscribe(`theme`,this.handleChangeTheme)}},r=Symbol.for(`@cupra/ui-kit/icons-manager/2.0.0-canary.
|
|
1
|
+
const e=require(`../core/theme.constants.cjs`),t=require(`./PubSub.cjs`);var n=class{constructor(){this.icons={},this.handleChangeTheme=e=>{if(this.theme===e)return;this.theme=e;let t=Object.keys(this.icons);this.icons={},t.forEach(e=>this.fetchIcon(e))},this.fetchIcon=async(t,n={})=>{let r=typeof sessionStorage<`u`?sessionStorage?.getItem(e.THEME_STORAGE_KEY):null;!this.theme&&r&&(this.theme=r);let i=this.icons[t];if(i)return await i;let a=this.loadIcon(t,n).catch(e=>{throw delete this.icons[t],e});return this.icons[t]=a,a},this.loadIcon=(e,{cache:t=`force-cache`,...n})=>!this.theme||typeof fetch>`u`?Promise.resolve(`<svg class="ds-icon"></svg>`):fetch(`https://ds-assets.cupra.com/icons/${this.theme}/${e}.svg`,{cache:t,...n}).then(e=>e.text()).catch(t=>{if(t?.name===`AbortError`)throw t;return console.error(`Failed to fetch icon "${e}":`,t),``}),t.pubSub.subscribe(`theme`,this.handleChangeTheme)}},r=Symbol.for(`@cupra/ui-kit/icons-manager/2.0.0-canary.127`),i=globalThis,a=i[r];a||(a=new n,Object.defineProperty(i,r,{value:a,writable:!1,configurable:!1,enumerable:!1}));var o=a;exports.iconsManager=o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=class{constructor(){this.subscribers={},this.lastPublishedData={}}subscribe(e,t){return this.subscribers[e]||(this.subscribers[e]=[]),this.subscribers[e].push(t),this.lastPublishedData[e]}unsubscribe(e,t){this.subscribers[e]&&(this.subscribers[e]=this.subscribers[e].filter(e=>e!==t))}publish(e,t){this.lastPublishedData[e]=t,this.subscribers[e]&&this.subscribers[e].forEach(n=>{try{n(t)}catch(t){console.error(`Error in subscriber for event "${e}":`,t)}})}},t=Symbol.for(`@cupra/ui-kit/pubsub/2.0.0-canary.
|
|
1
|
+
var e=class{constructor(){this.subscribers={},this.lastPublishedData={}}subscribe(e,t){return this.subscribers[e]||(this.subscribers[e]=[]),this.subscribers[e].push(t),this.lastPublishedData[e]}unsubscribe(e,t){this.subscribers[e]&&(this.subscribers[e]=this.subscribers[e].filter(e=>e!==t))}publish(e,t){this.lastPublishedData[e]=t,this.subscribers[e]&&this.subscribers[e].forEach(n=>{try{n(t)}catch(t){console.error(`Error in subscriber for event "${e}":`,t)}})}},t=Symbol.for(`@cupra/ui-kit/pubsub/2.0.0-canary.127`),n=globalThis,r=n[t];r||(r=new e,Object.defineProperty(n,t,{value:r,writable:!1,configurable:!1,enumerable:!1}));var i=r;exports.pubSub=i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=require(`../concurrencyLimit.cjs`).concurrencyLimit(20),t=class t{constructor(){this.stylePromises=new Map,this.getStyles=async({componentName:t,theme:n})=>{if(!n||!t)return;let r=`https://ds-assets.cupra.com/2.0.0-canary.
|
|
1
|
+
var e=require(`../concurrencyLimit.cjs`).concurrencyLimit(20),t=class t{constructor(){this.stylePromises=new Map,this.getStyles=async({componentName:t,theme:n})=>{if(!n||!t)return;let r=`https://ds-assets.cupra.com/2.0.0-canary.127/styles/${n}/components/${t}.css`,i=this.getCachedStyleSheetPromise({url:r});if(i)return i;let a=e(()=>this.fetchStyle({url:r})).then(e=>(e||this.stylePromises.delete(r),e));return this.stylePromises.set(r,a),this.stylePromises.get(r)}}async fetchStyle({url:e}){try{if(typeof fetch>`u`)return;let t=await fetch(e,{cache:`force-cache`});if(t.ok)return t.text()}catch(t){console.error(`Failed to fetch Style Sheet "${e}":`,t)}}getCachedStyleSheetPromise({url:e}){return this.stylePromises.get(e)}static getInstance(){return t.instance||=new t,t.instance}}.getInstance();exports.stylesRegistry=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.cjs`);require(`../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);function t(t,...n){return e.i`${e.r(String.raw({raw:t},...n).replace(/(--private-[\w-]+)(?=\s*[):,])/g,`$1-v2-0-0-canary-
|
|
1
|
+
const e=require(`../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.cjs`);require(`../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);function t(t,...n){return e.i`${e.r(String.raw({raw:t},...n).replace(/(--private-[\w-]+)(?=\s*[):,])/g,`$1-v2-0-0-canary-127`))}`}exports.cssWithTokens=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.cjs`);require(`../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);const t=require(`../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/unsafe-html.cjs`);require(`../node_modules/.pnpm/lit@3.3.1/node_modules/lit/directives/unsafe-html.cjs`);function n(n,...r){return e.x`${t.o(String.raw({raw:n},...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g,`$1-v2-0-0-canary-
|
|
1
|
+
const e=require(`../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.cjs`);require(`../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.cjs`);const t=require(`../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/unsafe-html.cjs`);require(`../node_modules/.pnpm/lit@3.3.1/node_modules/lit/directives/unsafe-html.cjs`);function n(n,...r){return e.x`${t.o(String.raw({raw:n},...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g,`$1-v2-0-0-canary-127`))}`}exports.htmlWithTokens=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`2.0.0-canary.
|
|
1
|
+
var e=`2.0.0-canary.127`,t=`--v${e.replaceAll(`.`,`-`)}`;exports.VERSION=e,exports.VERSION_TAG_SUFFIX=t;
|
|
@@ -20,27 +20,29 @@ var p, m = class extends s {
|
|
|
20
20
|
p = this;
|
|
21
21
|
}
|
|
22
22
|
constructor(...e) {
|
|
23
|
-
super(...e), this.mode = "light", this.size = "large", this.variant = "primary", this.readonly = !1, this._open = !1, this.nativeSelect = null, this.nativeLabel = null, this.nativeOptions = [], this.
|
|
23
|
+
super(...e), this.mode = "light", this.size = "large", this.variant = "primary", this.readonly = !1, this.iconName = void 0, this._open = !1, this._keyboardNavigating = !1, this.nativeSelect = null, this.nativeLabel = null, this.nativeOptions = [], this.keyboardFocusIndex = -1, this.hasForcedError = !1, this.handleMutations = (e) => {
|
|
24
24
|
e.forEach((e) => {
|
|
25
25
|
e.type === "childList" && this.syncNativeOptions();
|
|
26
26
|
}), this.requestUpdate();
|
|
27
27
|
}, this.syncNativeOptions = () => {
|
|
28
28
|
this.nativeOptions = Array.from(this.nativeSelect.options);
|
|
29
29
|
}, this.handleOpen = () => {
|
|
30
|
-
this.readonly || (this._open = !0, this.
|
|
30
|
+
this.readonly || (this._open = !0, this.keyboardFocusIndex = this.findSelectedOptionIndex(), this.focusDisplaySelect());
|
|
31
31
|
}, this.handleClose = () => {
|
|
32
32
|
this._open = !1;
|
|
33
33
|
}, this.handleClickDisplaySelect = () => {
|
|
34
|
-
this._open ? this.handleClose() : this.handleOpen();
|
|
34
|
+
this._open ? this.handleClose() : (this._keyboardNavigating = !1, this.handleOpen());
|
|
35
35
|
}, this.handleKeydown = (e) => {
|
|
36
|
-
this._open ? d.handleKeydownWhenOpen(e, {
|
|
36
|
+
this._open ? (this._keyboardNavigating = !0, d.handleKeydownWhenOpen(e, {
|
|
37
37
|
commit: () => this.commitSelection(),
|
|
38
38
|
navigateNext: () => this.advanceSelection(1),
|
|
39
39
|
navigatePrev: () => this.advanceSelection(-1),
|
|
40
40
|
navigateFirst: () => this.advanceToFirst(),
|
|
41
41
|
navigateLast: () => this.advanceToLast(),
|
|
42
42
|
close: this.handleClose
|
|
43
|
-
}) : d.handleKeydownWhenClosed(e, { open:
|
|
43
|
+
})) : d.handleKeydownWhenClosed(e, { open: () => {
|
|
44
|
+
this._keyboardNavigating = !0, this.handleOpen();
|
|
45
|
+
} });
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
static {
|
|
@@ -86,7 +88,7 @@ var p, m = class extends s {
|
|
|
86
88
|
advanceToFirst() {
|
|
87
89
|
if (this.nativeOptions.length) {
|
|
88
90
|
let e = this.nativeOptions.findIndex((e) => !e.hidden);
|
|
89
|
-
this.advanceSelection(e - this.
|
|
91
|
+
this.advanceSelection(e - this.keyboardFocusIndex);
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
advanceToLast() {
|
|
@@ -96,23 +98,23 @@ var p, m = class extends s {
|
|
|
96
98
|
e = t;
|
|
97
99
|
break;
|
|
98
100
|
}
|
|
99
|
-
this.advanceSelection(e - this.
|
|
101
|
+
this.advanceSelection(e - this.keyboardFocusIndex);
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
advanceSelection(e) {
|
|
103
105
|
let t = this.nativeOptions.length;
|
|
104
|
-
this.
|
|
106
|
+
this.keyboardFocusIndex = (this.keyboardFocusIndex + e + t) % t, this.shouldSkipHiddenOption() ? this.advanceSelection(Math.sign(e)) : this.scrollToActive(this.nativeOptions[this.keyboardFocusIndex]);
|
|
105
107
|
}
|
|
106
108
|
shouldSkipHiddenOption() {
|
|
107
|
-
return this.nativeOptions.some((e) => !e.hidden) && this.nativeOptions[this.
|
|
109
|
+
return this.nativeOptions.some((e) => !e.hidden) && this.nativeOptions[this.keyboardFocusIndex].hidden;
|
|
108
110
|
}
|
|
109
111
|
scrollToActive(e) {
|
|
110
112
|
e?.scrollIntoView?.({ block: "nearest" });
|
|
111
113
|
}
|
|
112
|
-
commitSelection() {
|
|
114
|
+
commitSelection(e = this.keyboardFocusIndex) {
|
|
113
115
|
this.handleClose();
|
|
114
|
-
let
|
|
115
|
-
this.nativeSelect &&
|
|
116
|
+
let t = this.nativeOptions[e];
|
|
117
|
+
this.nativeSelect && t?.value && this.updateNativeSelectValue(t.value);
|
|
116
118
|
}
|
|
117
119
|
updateNativeSelectValue(e) {
|
|
118
120
|
this.nativeSelect.value = e, ["input", "change"].forEach((e) => this.nativeSelect.dispatchEvent(new Event(e, {
|
|
@@ -159,6 +161,12 @@ var p, m = class extends s {
|
|
|
159
161
|
"icon-name": this._open ? "arrow-up" : "arrow-down"
|
|
160
162
|
});
|
|
161
163
|
}
|
|
164
|
+
get leftIconTemplate() {
|
|
165
|
+
return this.iconName ? this.componentFactory.createIcon({
|
|
166
|
+
class: "left-icon",
|
|
167
|
+
"icon-name": this.iconName
|
|
168
|
+
}) : e;
|
|
169
|
+
}
|
|
162
170
|
get displaySelectTemplate() {
|
|
163
171
|
let e = this.nativeOptions.find((e) => e.selected), n = Array.from(e?.childNodes || [])?.map((e) => {
|
|
164
172
|
let t = e.cloneNode(!0);
|
|
@@ -184,6 +192,7 @@ var p, m = class extends s {
|
|
|
184
192
|
@keydown=${this.handleKeydown}
|
|
185
193
|
@blur=${this.handleClose}
|
|
186
194
|
>
|
|
195
|
+
${this.leftIconTemplate}
|
|
187
196
|
<span class="select-content">${n}</span>
|
|
188
197
|
${this.iconTemplate}
|
|
189
198
|
</div>
|
|
@@ -192,7 +201,7 @@ var p, m = class extends s {
|
|
|
192
201
|
`;
|
|
193
202
|
}
|
|
194
203
|
get activeDescendantId() {
|
|
195
|
-
return this._open && this.
|
|
204
|
+
return this._open && this.keyboardFocusIndex >= 0 ? `${p.ARIA_OPTION_PREFIX}${this.nativeOptions[this.keyboardFocusIndex].value}` : "";
|
|
196
205
|
}
|
|
197
206
|
get optionsContainerTemplate() {
|
|
198
207
|
return t`
|
|
@@ -208,15 +217,13 @@ var p, m = class extends s {
|
|
|
208
217
|
id="${p.ARIA_OPTION_PREFIX}${e.value}"
|
|
209
218
|
class=${u({
|
|
210
219
|
option: !0,
|
|
211
|
-
|
|
220
|
+
"keyboard-focused": n === this.keyboardFocusIndex && this._keyboardNavigating,
|
|
212
221
|
selected: e.value === this.nativeSelect.value
|
|
213
222
|
})}
|
|
214
223
|
role="option"
|
|
215
224
|
aria-selected="${e.value === this.nativeSelect.value}"
|
|
216
225
|
tabindex="-1"
|
|
217
|
-
@mousedown=${() =>
|
|
218
|
-
this.activeIndex = n, this.commitSelection();
|
|
219
|
-
}}
|
|
226
|
+
@mousedown=${() => this.commitSelection(n)}
|
|
220
227
|
>
|
|
221
228
|
${r}
|
|
222
229
|
</div>
|
|
@@ -227,7 +234,10 @@ o([n({ type: String })], m.prototype, "mode", void 0), o([n({ type: String })],
|
|
|
227
234
|
type: Boolean,
|
|
228
235
|
converter: l,
|
|
229
236
|
reflect: !0
|
|
230
|
-
})], m.prototype, "readonly", void 0), o([
|
|
237
|
+
})], m.prototype, "readonly", void 0), o([n({
|
|
238
|
+
type: String,
|
|
239
|
+
attribute: "icon-name"
|
|
240
|
+
})], m.prototype, "iconName", void 0), o([r()], m.prototype, "_open", void 0), o([r()], m.prototype, "_keyboardNavigating", void 0), o([r()], m.prototype, "nativeOptions", void 0), o([r()], m.prototype, "keyboardFocusIndex", void 0), o([r()], m.prototype, "hasForcedError", void 0), o([a({
|
|
231
241
|
slot: "",
|
|
232
242
|
selector: "select",
|
|
233
243
|
flatten: !0
|
|
@@ -50,7 +50,7 @@ var p = class extends o {
|
|
|
50
50
|
}
|
|
51
51
|
loadThemeStyles() {
|
|
52
52
|
return this.loadStyles ? new Promise((e, t) => {
|
|
53
|
-
let n = "/2.0.0-canary.
|
|
53
|
+
let n = "/2.0.0-canary.127", r = `https://ds-assets.cupra.com${n}/styles/${this.theme}/theme.css`;
|
|
54
54
|
if (document.head.querySelector(`link[href="${r}"]`)) e();
|
|
55
55
|
else {
|
|
56
56
|
let i = `ui-kit-theme-${n}`, a = document.getElementById(i), o = document.createElement("link");
|
|
@@ -15,7 +15,7 @@ function n(n, r) {
|
|
|
15
15
|
this.componentName = o;
|
|
16
16
|
}
|
|
17
17
|
connectedCallback() {
|
|
18
|
-
i.prototype.connectedCallback?.call(this), this.setAttribute("data-ui-kit-version", "2.0.0-canary.
|
|
18
|
+
i.prototype.connectedCallback?.call(this), this.setAttribute("data-ui-kit-version", "2.0.0-canary.127");
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
};
|
|
@@ -25,7 +25,7 @@ var n = class {
|
|
|
25
25
|
return console.error(`Failed to fetch icon "${e}":`, t), "";
|
|
26
26
|
}), t.subscribe("theme", this.handleChangeTheme);
|
|
27
27
|
}
|
|
28
|
-
}, r = Symbol.for("@cupra/ui-kit/icons-manager/2.0.0-canary.
|
|
28
|
+
}, r = Symbol.for("@cupra/ui-kit/icons-manager/2.0.0-canary.127"), i = globalThis, a = i[r];
|
|
29
29
|
a || (a = new n(), Object.defineProperty(i, r, {
|
|
30
30
|
value: a,
|
|
31
31
|
writable: !1,
|
|
@@ -18,7 +18,7 @@ var e = class {
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
}, t = Symbol.for("@cupra/ui-kit/pubsub/2.0.0-canary.
|
|
21
|
+
}, t = Symbol.for("@cupra/ui-kit/pubsub/2.0.0-canary.127"), n = globalThis, r = n[t];
|
|
22
22
|
r || (r = new e(), Object.defineProperty(n, t, {
|
|
23
23
|
value: r,
|
|
24
24
|
writable: !1,
|
|
@@ -4,7 +4,7 @@ var t = e(20), n = class e {
|
|
|
4
4
|
constructor() {
|
|
5
5
|
this.stylePromises = /* @__PURE__ */ new Map(), this.getStyles = async ({ componentName: e, theme: n }) => {
|
|
6
6
|
if (!n || !e) return;
|
|
7
|
-
let r = `https://ds-assets.cupra.com/2.0.0-canary.
|
|
7
|
+
let r = `https://ds-assets.cupra.com/2.0.0-canary.127/styles/${n}/components/${e}.css`, i = this.getCachedStyleSheetPromise({ url: r });
|
|
8
8
|
if (i) return i;
|
|
9
9
|
let a = t(() => this.fetchStyle({ url: r })).then((e) => (e || this.stylePromises.delete(r), e));
|
|
10
10
|
return this.stylePromises.set(r, a), this.stylePromises.get(r);
|
|
@@ -2,7 +2,7 @@ import { i as e, r as t } from "../node_modules/.pnpm/@lit_reactive-element@2.1.
|
|
|
2
2
|
import "../node_modules/.pnpm/lit@3.3.1/node_modules/lit/index.js";
|
|
3
3
|
//#region src/utils/cssWithTokens.ts
|
|
4
4
|
function n(n, ...r) {
|
|
5
|
-
return e`${t(String.raw({ raw: n }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v2-0-0-canary-
|
|
5
|
+
return e`${t(String.raw({ raw: n }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v2-0-0-canary-127"))}`;
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
8
|
export { n as cssWithTokens };
|
|
@@ -4,7 +4,7 @@ import { o as t } from "../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-ht
|
|
|
4
4
|
import "../node_modules/.pnpm/lit@3.3.1/node_modules/lit/directives/unsafe-html.js";
|
|
5
5
|
//#region src/utils/htmlWithTokens.ts
|
|
6
6
|
function n(n, ...r) {
|
|
7
|
-
return e`${t(String.raw({ raw: n }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v2-0-0-canary-
|
|
7
|
+
return e`${t(String.raw({ raw: n }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v2-0-0-canary-127"))}`;
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
10
|
export { n as htmlWithTokens };
|
|
@@ -8,11 +8,13 @@ export declare class DsSelect extends UiKitElement {
|
|
|
8
8
|
size: DsSelectAttrs['size'];
|
|
9
9
|
variant: DsSelectAttrs['variant'];
|
|
10
10
|
readonly: DsSelectAttrs['readonly'];
|
|
11
|
+
iconName: DsSelectAttrs['icon-name'];
|
|
11
12
|
private _open;
|
|
13
|
+
private _keyboardNavigating;
|
|
12
14
|
private nativeSelect;
|
|
13
15
|
private nativeLabel;
|
|
14
16
|
private nativeOptions;
|
|
15
|
-
|
|
17
|
+
keyboardFocusIndex: number;
|
|
16
18
|
hasForcedError: boolean;
|
|
17
19
|
private nativeSelects;
|
|
18
20
|
private nativeLabels;
|
|
@@ -54,6 +56,7 @@ export declare class DsSelect extends UiKitElement {
|
|
|
54
56
|
get open(): boolean;
|
|
55
57
|
render(): import("lit").TemplateResult<1>;
|
|
56
58
|
protected get iconTemplate(): any;
|
|
59
|
+
protected get leftIconTemplate(): any;
|
|
57
60
|
private get displaySelectTemplate();
|
|
58
61
|
private get activeDescendantId();
|
|
59
62
|
private get optionsContainerTemplate();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { DsIconAttrs } from '../ds-icon/ds-icon.types.ts';
|
|
1
2
|
import type { CommonAttrs } from '../../types/types.ts';
|
|
2
3
|
export interface DsSelectAttrs extends CommonAttrs {
|
|
3
4
|
mode?: 'dark' | 'light';
|
|
4
5
|
size?: 'large' | 'medium';
|
|
5
6
|
variant?: 'primary' | 'secondary' | (string & {});
|
|
6
7
|
readonly?: boolean;
|
|
8
|
+
'icon-name'?: DsIconAttrs['icon-name'];
|
|
7
9
|
}
|