@sbb-esta/lyne-elements-experimental 5.3.0 → 5.4.1
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/autocomplete-grid.pure.js +1 -1
- package/core.js +1 -1
- package/custom-elements.json +891 -4
- package/development/autocomplete-grid.pure.js +3 -4
- package/development/core.js +2 -1
- package/development/easter-egg/easter-egg.component.d.ts +80 -0
- package/development/easter-egg/i18n.d.ts +10 -0
- package/development/easter-egg/svgs.d.ts +10 -0
- package/development/easter-egg.d.ts +1 -0
- package/development/easter-egg.js +9 -0
- package/development/easter-egg.pure.d.ts +2 -0
- package/development/easter-egg.pure.js +758 -0
- package/development/journey-summary.pure.js +13 -8
- package/development/pearl-chain-time.pure.js +13 -8
- package/development/pearl-chain.pure.js +2 -1
- package/development/seat-reservation/seat-reservation/seat-reservation-base-element.d.ts +4 -0
- package/development/seat-reservation.pure.js +34 -21
- package/development/timetable-row.pure.js +13 -8
- package/easter-egg.js +1 -0
- package/easter-egg.pure.js +567 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/journey-summary.pure.js +1 -1
- package/package.json +12 -2
- package/pearl-chain-time.pure.js +1 -1
- package/pearl-chain.pure.js +2 -2
- package/seat-reservation.pure.js +8 -6
- package/timetable-row.pure.js +1 -1
|
@@ -9,4 +9,4 @@ import{miniButtonStyle as e}from"@sbb-esta/lyne-elements/button.pure.js";import{
|
|
|
9
9
|
<span class="sbb-autocomplete-grid-row">
|
|
10
10
|
<slot></slot>
|
|
11
11
|
</span>
|
|
12
|
-
`}};let k=0;const A=c;var j=class extends _{constructor(){super(...arguments),this.overlayId=`sbb-autocomplete-grid-${++k}`,this.panelRole=`grid`,this._activeColumnIndex=0}static{this.elementName=`sbb-autocomplete-grid`}static{this.role=A?`grid`:null}get options(){return Array.from(this.querySelectorAll?.(`sbb-autocomplete-grid-option`)??[])}syncNegative(){this.querySelectorAll?.(`sbb-divider, sbb-autocomplete-grid-button, sbb-option-hint`).forEach(e=>e.negative=this.negative),this.querySelectorAll?.(`sbb-autocomplete-grid-row, sbb-autocomplete-grid-option, sbb-autocomplete-grid-optgroup`).forEach(e=>u(e).toggle(`negative`,this.negative))}openedPanelKeyboardInteraction(e){if(this.isOpen)switch(e.key){case`Enter`:this.selectByKeyboard(e);break;case`ArrowDown`:case`ArrowUp`:this.setNextActiveOption(e);break;case`ArrowRight`:case`ArrowLeft`:this._setNextHorizontalActiveElement(e)
|
|
12
|
+
`}};let k=0;const A=c;var j=class extends _{constructor(){super(...arguments),this.overlayId=`sbb-autocomplete-grid-${++k}`,this.panelRole=`grid`,this._activeColumnIndex=0}static{this.elementName=`sbb-autocomplete-grid`}static{this.role=A?`grid`:null}get options(){return Array.from(this.querySelectorAll?.(`sbb-autocomplete-grid-option`)??[])}syncNegative(){this.querySelectorAll?.(`sbb-divider, sbb-autocomplete-grid-button, sbb-option-hint`).forEach(e=>e.negative=this.negative),this.querySelectorAll?.(`sbb-autocomplete-grid-row, sbb-autocomplete-grid-option, sbb-autocomplete-grid-optgroup`).forEach(e=>u(e).toggle(`negative`,this.negative))}openedPanelKeyboardInteraction(e){if(this.isOpen)switch(e.key){case`Enter`:this.selectByKeyboard(e);break;case`ArrowDown`:case`ArrowUp`:this.setNextActiveOption(e);break;case`ArrowRight`:case`ArrowLeft`:this._setNextHorizontalActiveElement(e)}}selectByKeyboard(e){this.activeOption&&(e.preventDefault(),this._activeColumnIndex===0?this.activeOption.selectViaUserInteraction(!0):this.activeOption.closest(`sbb-autocomplete-grid-row`)?.querySelectorAll(`sbb-autocomplete-grid-button`)[this._activeColumnIndex-1]?.click())}setNextActiveOption(e){let t=this.options.filter(e=>!e.matches(`:is(:state(disabled),[state--disabled])`));if(this.activeOption?.setActive(!1),this.triggerElement.ariaActiveDescendantElement=null,Array.from(this.querySelectorAll?.(`sbb-autocomplete-grid-row :is(:state(focus-visible),[state--focus-visible])`)??[]).forEach(e=>u(e).delete(`focus-visible`)),this._activeColumnIndex=0,!t.length){this.activeOption=null;return}let n=this.activeOption?t.indexOf(this.activeOption):-1,r=o(e,n,t.length);this.activeOption=t[r],this.activeOption.setActive(!0),this.triggerElement.ariaActiveDescendantElement=this.activeOption,this.activeOption.scrollIntoView({block:`nearest`}),e&&e.preventDefault(),this.autoSelectActiveOption&&e&&this.setPendingSelection(this.activeOption)}_setNextHorizontalActiveElement(e){if(!this.activeOption)return;let t=Array.from(this.activeOption?.closest(`sbb-autocomplete-grid-row`)?.querySelectorAll(`sbb-autocomplete-grid-option, sbb-autocomplete-grid-button`)??[])?.filter(e=>!e.matches(`:is(:state(disabled),[state--disabled])`));if(!t.length)return;let n=o(e,this._activeColumnIndex,t.length),r=t[n];r instanceof T?r.setActive(!0):u(r).add(`focus-visible`);let i=t[this._activeColumnIndex];i instanceof T?i.setActive(!1):u(i).delete(`focus-visible`),this.triggerElement.ariaActiveDescendantElement=r,r.scrollIntoView({block:`nearest`}),this._activeColumnIndex=n}resetActiveElement(){this._activeColumnIndex!==0&&this.activeOption?.closest(`sbb-autocomplete-grid-row`)?.querySelectorAll(`sbb-autocomplete-grid-button`).forEach(e=>u(e).delete(`focus-visible`)),this.activeOption?.setActive(!1),this.activeOption=null,this._activeColumnIndex=0,this.triggerElement&&(this.triggerElement.ariaActiveDescendantElement=null)}setTriggerAttributes(e){l(e,A?this.id:this.overlayId,!1,`grid`)}};export{y as SbbAutocompleteGridButtonElement,x as SbbAutocompleteGridCellElement,j as SbbAutocompleteGridElement,S as SbbAutocompleteGridOptgroupElement,T as SbbAutocompleteGridOptionElement,O as SbbAutocompleteGridRowElement,w as autocompleteGridOptionId};
|
package/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i18nDurationDay as e,i18nDurationHour as t,i18nDurationMinute as n,i18nWalkingDistanceArrival as r,i18nWalkingDistanceDeparture as i}from"@sbb-esta/lyne-elements/core.js";import{html as a,nothing as o}from"lit";import"@sbb-esta/lyne-elements/icon.pure.js";const s=6e4,c=36e5,l=Symbol.for(`constructDateFrom`);function u(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&l in e?e[l](t):e instanceof Date?new e.constructor(t):new Date(t)}function d(e,t){return u(t||e,e)}function f(e,t,n){let r=d(e,n?.in);return isNaN(t)?u(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function p(e,t,n){return u(n?.in||e,+d(e)+t)}function m(e,t,n){return p(e,t*c,n)}function h(e){let t=d(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function g(e,...t){let n=u.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function _(e,t){let n=d(e,t?.in);return n.setHours(0,0,0,0),n}function v(e,t,n){let[r,i]=g(n?.in,e,t),a=_(r),o=_(i),s=+a-h(a),c=+o-h(o);return Math.round((s-c)/864e5)}function y(e,t,n){let r=d(e,n?.in);return r.setTime(r.getTime()+t*s),r}function b(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function x(e){return!(!b(e)&&typeof e!=`number`||isNaN(+d(e)))}function S(e,t,n){let[r,i]=g(n?.in,e,t),a=C(r,i),o=Math.abs(v(r,i));r.setDate(r.getDate()-a*o);let s=a*(o-Number(C(r,i)===-a));return s===0?0:s}function C(e,t){let n=e.getFullYear()-t.getFullYear()||e.getMonth()-t.getMonth()||e.getDate()-t.getDate()||e.getHours()-t.getHours()||e.getMinutes()-t.getMinutes()||e.getSeconds()-t.getSeconds()||e.getMilliseconds()-t.getMilliseconds();return n<0?-1:n>0?1:n}function w(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function T(e,t,n){let[r,i]=g(n?.in,e,t),a=(r-+i)/c;return w(n?.roundingMethod)(a)}function E(e,t){return d(e)-+d(t)}function D(e,t,n){let r=E(e,t)/s;return w(n?.roundingMethod)(r)}function O(e,t,n){return f(e,-t,n)}function k(e,t){let n=()=>u(t?.in,NaN),r=t?.additionalDigits??2,i=ne(e),a;if(i.date){let e=re(i.date,r);a=M(e.restDateString,e.year)}if(!a||isNaN(+a))return n();let o=+a,s=0,c;if(i.time&&(s=P(i.time),isNaN(s)))return n();if(i.timezone){if(c=I(i.timezone),isNaN(c))return n()}else{let e=new Date(o+s),n=d(0,t?.in);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}return d(o+s+c,t?.in)}const A={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},j=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,ee=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,te=/^([+-])(\d{2})(?::?(\d{2}))?$/;function ne(e){let t={},n=e.split(A.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],A.timeZoneDelimiter.test(t.date)&&(t.date=e.split(A.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=A.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function re(e,t){let n=RegExp(`^(?:(\\d{4}|[+-]\\d{`+(4+t)+`})|(\\d{2}|[+-]\\d{`+(2+t)+`})$)`),r=e.match(n);if(!r)return{year:NaN,restDateString:``};let i=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?i:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function M(e,t){if(t===null)return new Date(NaN);let n=e.match(j);if(!n)return new Date(NaN);let r=!!n[4],i=N(n[1]),a=N(n[2])-1,o=N(n[3]),s=N(n[4]),c=N(n[5])-1;if(r)return H(t,s,c)?L(t,s,c):new Date(NaN);{let e=new Date(0);return!B(t,a,o)||!V(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function N(e){return e?parseInt(e):1}function P(e){let t=e.match(ee);if(!t)return NaN;let n=F(t[1]),r=F(t[2]),i=F(t[3]);return U(n,r,i)?n*c+r*s+i*1e3:NaN}function F(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function I(e){if(e===`Z`)return 0;let t=e.match(te);if(!t)return 0;let n=t[1]===`+`?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return W(r,i)?n*(r*c+i*s):NaN}function L(e,t,n){let r=new Date(0);r.setUTCFullYear(e,0,4);let i=r.getUTCDay()||7,a=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}const R=[31,null,31,30,31,30,31,31,30,31,30,31];function z(e){return e%400==0||e%4==0&&e%100!=0}function B(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(R[t]||(z(e)?29:28))}function V(e,t){return t>=1&&t<=(z(e)?366:365)}function H(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function U(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function W(e,t){return t>=0&&t<=59}function G(e,t,n){return m(e,-t,n)}function K(e){if(e
|
|
1
|
+
import{i18nDurationDay as e,i18nDurationHour as t,i18nDurationMinute as n,i18nWalkingDistanceArrival as r,i18nWalkingDistanceDeparture as i}from"@sbb-esta/lyne-elements/core.js";import{html as a,nothing as o}from"lit";import"@sbb-esta/lyne-elements/icon.pure.js";const s=6e4,c=36e5,l=Symbol.for(`constructDateFrom`);function u(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&l in e?e[l](t):e instanceof Date?new e.constructor(t):new Date(t)}function d(e,t){return u(t||e,e)}function f(e,t,n){let r=d(e,n?.in);return isNaN(t)?u(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function p(e,t,n){return u(n?.in||e,+d(e)+t)}function m(e,t,n){return p(e,t*c,n)}function h(e){let t=d(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function g(e,...t){let n=u.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function _(e,t){let n=d(e,t?.in);return n.setHours(0,0,0,0),n}function v(e,t,n){let[r,i]=g(n?.in,e,t),a=_(r),o=_(i),s=+a-h(a),c=+o-h(o);return Math.round((s-c)/864e5)}function y(e,t,n){let r=d(e,n?.in);return r.setTime(r.getTime()+t*s),r}function b(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function x(e){return!(!b(e)&&typeof e!=`number`||isNaN(+d(e)))}function S(e,t,n){let[r,i]=g(n?.in,e,t),a=C(r,i),o=Math.abs(v(r,i));r.setDate(r.getDate()-a*o);let s=a*(o-Number(C(r,i)===-a));return s===0?0:s}function C(e,t){let n=e.getFullYear()-t.getFullYear()||e.getMonth()-t.getMonth()||e.getDate()-t.getDate()||e.getHours()-t.getHours()||e.getMinutes()-t.getMinutes()||e.getSeconds()-t.getSeconds()||e.getMilliseconds()-t.getMilliseconds();return n<0?-1:n>0?1:n}function w(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function T(e,t,n){let[r,i]=g(n?.in,e,t),a=(r-+i)/c;return w(n?.roundingMethod)(a)}function E(e,t){return d(e)-+d(t)}function D(e,t,n){let r=E(e,t)/s;return w(n?.roundingMethod)(r)}function O(e,t,n){return f(e,-t,n)}function k(e,t){let n=()=>u(t?.in,NaN),r=t?.additionalDigits??2,i=ne(e),a;if(i.date){let e=re(i.date,r);a=M(e.restDateString,e.year)}if(!a||isNaN(+a))return n();let o=+a,s=0,c;if(i.time&&(s=P(i.time),isNaN(s)))return n();if(i.timezone){if(c=I(i.timezone),isNaN(c))return n()}else{let e=new Date(o+s),n=d(0,t?.in);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}return d(o+s+c,t?.in)}const A={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},j=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,ee=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,te=/^([+-])(\d{2})(?::?(\d{2}))?$/;function ne(e){let t={},n=e.split(A.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],A.timeZoneDelimiter.test(t.date)&&(t.date=e.split(A.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=A.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function re(e,t){let n=RegExp(`^(?:(\\d{4}|[+-]\\d{`+(4+t)+`})|(\\d{2}|[+-]\\d{`+(2+t)+`})$)`),r=e.match(n);if(!r)return{year:NaN,restDateString:``};let i=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?i:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function M(e,t){if(t===null)return new Date(NaN);let n=e.match(j);if(!n)return new Date(NaN);let r=!!n[4],i=N(n[1]),a=N(n[2])-1,o=N(n[3]),s=N(n[4]),c=N(n[5])-1;if(r)return H(t,s,c)?L(t,s,c):new Date(NaN);{let e=new Date(0);return!B(t,a,o)||!V(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function N(e){return e?parseInt(e):1}function P(e){let t=e.match(ee);if(!t)return NaN;let n=F(t[1]),r=F(t[2]),i=F(t[3]);return U(n,r,i)?n*c+r*s+i*1e3:NaN}function F(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function I(e){if(e===`Z`)return 0;let t=e.match(te);if(!t)return 0;let n=t[1]===`+`?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return W(r,i)?n*(r*c+i*s):NaN}function L(e,t,n){let r=new Date(0);r.setUTCFullYear(e,0,4);let i=r.getUTCDay()||7,a=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}const R=[31,null,31,30,31,30,31,31,30,31,30,31];function z(e){return e%400==0||e%4==0&&e%100!=0}function B(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(R[t]||(z(e)?29:28))}function V(e,t){return t>=1&&t<=(z(e)?366:365)}function H(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function U(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function W(e,t){return t>=0&&t<=59}function G(e,t,n){return m(e,-t,n)}function K(e){if(!(!e||!x(k(e)))){if(e.includes(`Z`))return new Date(e.replace(`Z`,``));if(e.includes(`T`)){let t=e.split(`T`);if(t[1]&&(t[1].includes(`+`)||t[1].includes(`-`)))return new Date(`${t[0]}T${t[1].split(/[+-]/)[0]}`)}return new Date(e)}}const q=(r,i)=>{let a=[],o=[],s=y(0,r),c=S(s,0);c>0&&(a.push(`${c} d`),i&&o.push(`${c} ${c>1?e.multiple.long[i]:e.single.long[i]}`),s=O(s,c));let l=T(s,0);l>0&&(a.push(`${l} h`),i&&o.push(`${l} ${l>1?t.multiple.long[i]:t.single.long[i]}`),s=G(s,l));let u=D(s,0);return u>0&&(a.push(`${u} min`),i&&o.push(`${u} ${u>1?n.multiple.long[i]:n.single.long[i]}`)),{short:a.join(` `),long:o.join(` `)}},J=e=>e?.__typename===`PTRideLeg`,Y=e=>e?.__typename===`PTConnectionLeg`,X=e=>{let t=e?.text?.template&&e.text.template.indexOf(`(`)+1,n=e?.text?.template?.substring(t||0,e?.text?.template.indexOf(`)`));return{duration:n&&+n.substring(0,n.length-1)||0,text:e?.text?.template?.split(`(`)[0]||``}};function Z(e,t){let n=Y(e)?e:null,r=n?n?.notices?.filter(e=>t.includes(e.name))[0]:null;return r?{duration:n?.duration||0,text:r?.text?.template||``,icon:`walk-small`}:null}function ie(e,t,n,r){let a=J(e)?e?.serviceJourney?.notices?.filter(e=>[`CI`].includes(e.name))[0]:null,o=a&&X(a);return a?{duration:(o?.duration||0)+(t||0),text:n?i[r]:o?.text||``,icon:n?`wheelchair-small`:`sa-${a?.name?.toLowerCase()}`}:null}function ae(e,t,n,i){let a=J(e)?e?.serviceJourney?.notices?.filter(e=>[`CO`].includes(e.name))[0]:null,o=a&&X(a);return a?{duration:(o?.duration||0)+(t||0),text:n?r[i]:o?.text||``,icon:n?`wheelchair-small`:`sa-${a?.name?.toLowerCase()}`}:null}function Q(e,t,n,s,c){return a`
|
|
2
2
|
<span class="sbb-pearl-chain__time-transfer sbb-pearl-chain__time-transfer--${t}-${c}">
|
|
3
3
|
<sbb-icon name=${t}></sbb-icon>
|
|
4
4
|
<time datetime=${e+`M`}>
|