@trendyol/baklava 3.3.0-beta.23 → 3.3.0-beta.25
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/baklava-react.d.ts +12 -0
- package/dist/baklava-react.d.ts.map +1 -1
- package/dist/baklava-react.js +1 -1
- package/dist/baklava-react.js.map +3 -3
- package/dist/baklava-vue.d.ts +1 -0
- package/dist/baklava.d.ts +1 -0
- package/dist/baklava.d.ts.map +1 -1
- package/dist/baklava.js +1 -1
- package/dist/{chunk-OAF3R4PW.js → chunk-2IJL7HNY.js} +2 -2
- package/dist/chunk-2IJL7HNY.js.map +7 -0
- package/dist/chunk-4BLKAURK.js +16 -0
- package/dist/chunk-4BLKAURK.js.map +7 -0
- package/dist/chunk-7VMGFJ5X.js +2 -0
- package/dist/chunk-7VMGFJ5X.js.map +7 -0
- package/dist/chunk-APLBTZ36.js +24 -0
- package/dist/chunk-APLBTZ36.js.map +7 -0
- package/dist/chunk-DE3A37FL.js +20 -0
- package/dist/chunk-DE3A37FL.js.map +7 -0
- package/dist/chunk-DIGACNOH.js +21 -0
- package/dist/chunk-DIGACNOH.js.map +7 -0
- package/dist/chunk-ERL6CBPO.js +31 -0
- package/dist/chunk-ERL6CBPO.js.map +7 -0
- package/dist/chunk-GFBXJPT6.js +50 -0
- package/dist/chunk-GFBXJPT6.js.map +7 -0
- package/dist/{chunk-5VEXMTA4.js → chunk-H4WETBHJ.js} +2 -2
- package/dist/chunk-H4WETBHJ.js.map +7 -0
- package/dist/chunk-HYBPEELZ.js +5 -0
- package/dist/chunk-HYBPEELZ.js.map +7 -0
- package/dist/chunk-HZV6GUII.js +26 -0
- package/dist/chunk-HZV6GUII.js.map +7 -0
- package/dist/chunk-IDRA37BX.js +59 -0
- package/dist/chunk-IDRA37BX.js.map +7 -0
- package/dist/chunk-LEAVDIGF.js +2 -0
- package/dist/chunk-LEAVDIGF.js.map +7 -0
- package/dist/chunk-MWFGDECP.js +35 -0
- package/dist/chunk-MWFGDECP.js.map +7 -0
- package/dist/chunk-MWG4TBH7.js +27 -0
- package/dist/chunk-MWG4TBH7.js.map +7 -0
- package/dist/chunk-NXVLNG4L.js +65 -0
- package/dist/chunk-NXVLNG4L.js.map +7 -0
- package/dist/chunk-OTAAXK2L.js +84 -0
- package/dist/chunk-OTAAXK2L.js.map +7 -0
- package/dist/chunk-OXHRXOBD.js +32 -0
- package/dist/chunk-OXHRXOBD.js.map +7 -0
- package/dist/{chunk-CAIHRZ24.js → chunk-Q5D7W6YP.js} +2 -2
- package/dist/{chunk-GMVJABPT.js → chunk-QDYWH7BU.js} +2 -2
- package/dist/chunk-QDYWH7BU.js.map +7 -0
- package/dist/chunk-RER7OLAQ.js +22 -0
- package/dist/chunk-RER7OLAQ.js.map +7 -0
- package/dist/chunk-SBCJY5IU.js +34 -0
- package/dist/{chunk-75V3FKJS.js.map → chunk-SBCJY5IU.js.map} +2 -2
- package/dist/chunk-STZJ3LBU.js +37 -0
- package/dist/{chunk-KBNVATXF.js.map → chunk-STZJ3LBU.js.map} +2 -2
- package/dist/{chunk-4BZSILLM.js → chunk-T5MEA7JO.js} +2 -2
- package/dist/chunk-T5MEA7JO.js.map +7 -0
- package/dist/chunk-TUUQIEDI.js +25 -0
- package/dist/chunk-TUUQIEDI.js.map +7 -0
- package/dist/{chunk-BNUJWONI.js → chunk-UOGCEUXK.js} +2 -2
- package/dist/chunk-UOGCEUXK.js.map +7 -0
- package/dist/chunk-WPESQSKX.js +31 -0
- package/dist/chunk-WPESQSKX.js.map +7 -0
- package/dist/chunk-X5XH4HTW.js +17 -0
- package/dist/chunk-X5XH4HTW.js.map +7 -0
- package/dist/{chunk-IGNJQVQF.js → chunk-ZE7GYACV.js} +2 -2
- package/dist/chunk-ZE7GYACV.js.map +7 -0
- package/dist/{chunk-N4GAO7FQ.js → chunk-ZJBBQHF3.js} +2 -2
- package/dist/chunk-ZLJF4SVG.js +4 -0
- package/dist/chunk-ZLJF4SVG.js.map +7 -0
- package/dist/components/accordion-group/accordion/bl-accordion.js +1 -1
- package/dist/components/accordion-group/bl-accordion-group.js +1 -1
- package/dist/components/alert/bl-alert.js +1 -1
- package/dist/components/badge/bl-badge.js +1 -1
- package/dist/components/button/bl-button.js +1 -1
- package/dist/components/calendar/bl-calendar.d.ts.map +1 -1
- package/dist/components/calendar/bl-calendar.js +1 -1
- package/dist/components/checkbox-group/bl-checkbox-group.js +1 -1
- package/dist/components/checkbox-group/checkbox/bl-checkbox.js +1 -1
- package/dist/components/datepicker/bl-datepicker.js +1 -1
- package/dist/components/dialog/bl-dialog.js +1 -1
- package/dist/components/drawer/bl-drawer.js +1 -1
- package/dist/components/dropdown/bl-dropdown.js +1 -1
- package/dist/components/dropdown/group/bl-dropdown-group.js +1 -1
- package/dist/components/dropdown/item/bl-dropdown-item.js +1 -1
- package/dist/components/input/bl-input.js +1 -1
- package/dist/components/notification/bl-notification.js +1 -1
- package/dist/components/notification/bl-notification.stories.d.ts.map +1 -1
- package/dist/components/notification/bl-notification.stories.js +30 -196
- package/dist/components/notification/bl-notification.stories.js.map +3 -3
- package/dist/components/notification/card/bl-notification-card.js +1 -1
- package/dist/components/pagination/bl-pagination.js +1 -1
- package/dist/components/popover/bl-popover.js +1 -1
- package/dist/components/progress-indicator/bl-progress-indicator.js +1 -1
- package/dist/components/radio-group/bl-radio-group.js +1 -1
- package/dist/components/radio-group/radio/bl-radio.js +1 -1
- package/dist/components/select/bl-select.js +1 -1
- package/dist/components/select/option/bl-select-option.js +1 -1
- package/dist/components/spinner/bl-spinner.js +1 -1
- package/dist/components/split-button/bl-split-button.js +1 -1
- package/dist/components/switch/bl-switch.js +1 -1
- package/dist/components/tab-group/bl-tab-group.js +1 -1
- package/dist/components/tab-group/tab/bl-tab.js +1 -1
- package/dist/components/table/table-cell/bl-table-cell.js +1 -1
- package/dist/components/table/table-header/bl-table-header.js +1 -1
- package/dist/components/table/table-header-cell/bl-table-header-cell.js +1 -1
- package/dist/components/table/table-row/bl-table-row.js +1 -1
- package/dist/components/tag/bl-tag.d.ts +52 -0
- package/dist/components/tag/bl-tag.d.ts.map +1 -0
- package/dist/components/tag/bl-tag.js +2 -0
- package/dist/components/tag/bl-tag.js.map +7 -0
- package/dist/components/tag/bl-tag.test.d.ts +2 -0
- package/dist/components/tag/bl-tag.test.d.ts.map +1 -0
- package/dist/components/textarea/bl-textarea.js +1 -1
- package/dist/components/tooltip/bl-tooltip.js +1 -1
- package/dist/custom-elements.json +112 -0
- package/package.json +1 -1
- package/dist/chunk-4BZSILLM.js.map +0 -7
- package/dist/chunk-4QFXDW3W.js +0 -31
- package/dist/chunk-4QFXDW3W.js.map +0 -7
- package/dist/chunk-5VEXMTA4.js.map +0 -7
- package/dist/chunk-73RGV4UX.js +0 -16
- package/dist/chunk-73RGV4UX.js.map +0 -7
- package/dist/chunk-757CMI4A.js +0 -78
- package/dist/chunk-757CMI4A.js.map +0 -7
- package/dist/chunk-75V3FKJS.js +0 -34
- package/dist/chunk-BNUJWONI.js.map +0 -7
- package/dist/chunk-CJDCQC7C.js +0 -50
- package/dist/chunk-CJDCQC7C.js.map +0 -7
- package/dist/chunk-FCEMOH4J.js +0 -27
- package/dist/chunk-FCEMOH4J.js.map +0 -7
- package/dist/chunk-FTQX7CEW.js +0 -35
- package/dist/chunk-FTQX7CEW.js.map +0 -7
- package/dist/chunk-FVBGMXMC.js +0 -17
- package/dist/chunk-FVBGMXMC.js.map +0 -7
- package/dist/chunk-GMVJABPT.js.map +0 -7
- package/dist/chunk-GXDVWGFU.js +0 -32
- package/dist/chunk-GXDVWGFU.js.map +0 -7
- package/dist/chunk-IGNJQVQF.js.map +0 -7
- package/dist/chunk-ILK55FB6.js +0 -65
- package/dist/chunk-ILK55FB6.js.map +0 -7
- package/dist/chunk-J45OQI7D.js +0 -20
- package/dist/chunk-J45OQI7D.js.map +0 -7
- package/dist/chunk-JAZGOWKA.js +0 -2
- package/dist/chunk-JAZGOWKA.js.map +0 -7
- package/dist/chunk-KBNVATXF.js +0 -37
- package/dist/chunk-NGJM4NWA.js +0 -4
- package/dist/chunk-NGJM4NWA.js.map +0 -7
- package/dist/chunk-OAF3R4PW.js.map +0 -7
- package/dist/chunk-QMVEWMEI.js +0 -20
- package/dist/chunk-QMVEWMEI.js.map +0 -7
- package/dist/chunk-S6HEBXIR.js +0 -84
- package/dist/chunk-S6HEBXIR.js.map +0 -7
- package/dist/chunk-T5EQ4OXS.js +0 -2
- package/dist/chunk-T5EQ4OXS.js.map +0 -7
- package/dist/chunk-UZJOCLOO.js +0 -21
- package/dist/chunk-UZJOCLOO.js.map +0 -7
- package/dist/chunk-VU6LRFZR.js +0 -26
- package/dist/chunk-VU6LRFZR.js.map +0 -7
- package/dist/chunk-WXWKIQAK.js +0 -22
- package/dist/chunk-WXWKIQAK.js.map +0 -7
- package/dist/chunk-X73CSBRO.js +0 -24
- package/dist/chunk-X73CSBRO.js.map +0 -7
- package/dist/chunk-YZRAUVUQ.js +0 -31
- package/dist/chunk-YZRAUVUQ.js.map +0 -7
- /package/dist/{chunk-CAIHRZ24.js.map → chunk-Q5D7W6YP.js.map} +0 -0
- /package/dist/{chunk-N4GAO7FQ.js.map → chunk-ZJBBQHF3.js.map} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import{b as y,c as g,d as D,e as H,f as $}from"./chunk-AYJMIZZ3.js";import{a as Y}from"./chunk-DINNT5P2.js";import{a as N,b as L,c as R}from"./chunk-7GK5LKBV.js";import{a as k,b as A,c as M,d as S}from"./chunk-5MOOXA2X.js";import{a as P,b as w,c as z,f as C}from"./chunk-4OT5AMS5.js";import{d as v}from"./chunk-IZ2LK5GK.js";var I=(s,f,t)=>{let o=new Map;for(let n=f;n<=t;n++)o.set(s[n],n);return o},V=L(class extends R{constructor(s){if(super(s),s.type!==N.CHILD)throw Error("repeat() can only be used in text expressions")}ct(s,f,t){let o;t===void 0?t=f:f!==void 0&&(o=f);let n=[],i=[],a=0;for(let c of s)n[a]=o?o(c,a):a,i[a]=t(c,a),a++;return{values:i,keys:n}}render(s,f,t){return this.ct(s,f,t).values}update(s,[f,t,o]){var n;let i=H(s),{values:a,keys:c}=this.ct(f,t,o);if(!Array.isArray(i))return this.ut=c,a;let p=(n=this.ut)!==null&&n!==void 0?n:this.ut=[],m=[],b,x,e=0,l=i.length-1,r=0,d=a.length-1;for(;e<=l&&r<=d;)if(i[e]===null)e++;else if(i[l]===null)l--;else if(p[e]===c[r])m[r]=g(i[e],a[r]),e++,r++;else if(p[l]===c[d])m[d]=g(i[l],a[d]),l--,d--;else if(p[e]===c[d])m[d]=g(i[e],a[d]),y(s,m[d+1],i[e]),e++,d--;else if(p[l]===c[r])m[r]=g(i[l],a[r]),y(s,i[e],i[l]),l--,r++;else if(b===void 0&&(b=I(c,r,d),x=I(p,e,l)),b.has(p[e]))if(b.has(p[l])){let h=x.get(c[r]),T=h!==void 0?i[h]:null;if(T===null){let E=y(s,i[e]);g(E,a[r]),m[r]=E}else m[r]=g(T,a[r]),y(s,i[e],T),i[h]=null;r++}else $(i[l]),l--;else $(i[e]),e++;for(;r<=d;){let h=y(s,m[d+1]);g(h,a[r]),m[r++]=h}for(;e<=l;){let h=i[e++];h!==null&&$(h)}return this.ut=c,D(s,m),z}});var X=P`:host{--bl-notification-width:396px;--bl-notification-gap:var(--bl-size-2xs);--bl-notification-animation-duration:0.3s}.wrapper{--margin:var(--bl-size-xl);display:flex;flex-direction:column-reverse;position:fixed;top:0;inset-inline-end:0;max-width:var(--bl-notification-width);margin:var(--margin);width:calc(100% - var(--margin) * 2);z-index:var(--bl-index-notification)}@media screen and (max-width:480px){.wrapper{flex-direction:column;max-width:100%}}.notification{will-change:transform height margin;animation:slide-in-right var(--bl-notification-animation-duration) ease;margin-bottom:var(--bl-notification-gap);touch-action:none}:host(:has([dir=rtl])) .notification{animation:slide-in-left var(--bl-notification-animation-duration) ease}.notification[data-slide=top]{animation:slide-in-top var(--bl-notification-animation-duration) ease}:host([no-animation]) .notification{animation:none}.notification.removing{animation:slide-out-right var(--bl-notification-animation-duration) ease forwards,size-to-zero var(--bl-notification-animation-duration) ease var(--bl-notification-animation-duration) forwards}.notification[data-slide=top].removing{animation:slide-out-top var(--bl-notification-animation-duration) ease forwards,size-to-zero var(--bl-notification-animation-duration) ease var(--bl-notification-animation-duration) forwards}:host([no-animation]) .notification.removing{animation:0 size-to-zero}@media (prefers-reduced-motion){.notification.removing{animation:0 size-to-zero}.notification{animation:none}}@keyframes slide-in-right{from{transform:translateX(var(--travel-distance,10px));height:0;opacity:0;margin:0}}@keyframes slide-in-left{from{transform:translateX(var(--travel-distance,-10px));height:0;opacity:0;margin:0}}@keyframes slide-out-right{to{transform:translateX(var(--travel-distance,10px));opacity:0}}@keyframes slide-in-top{from{transform:translateY(var(--travel-distance,-10px));height:0;opacity:0;margin:0}}@keyframes slide-out-top{to{transform:translateY(var(--travel-distance,-10px));opacity:0}}@keyframes size-to-zero{to{height:0;margin:0}}`,B=X;var G=-50,u=class extends C{constructor(){super(...arguments);this.noAnimation=!1;this.duration=7;this.notifications=[];this.touchStartY=0}static get styles(){return[B]}get notificationList(){return this.notifications}get touchStart(){return{y:this.touchStartY}}get isMobile(){return window.matchMedia("(max-width: 480px)").matches}addNotification(t){let o=Math.random().toString(36).substr(2,9),n={...t,id:o,duration:t.duration||this.duration,remove:()=>this.removeNotification(o)},i=[...this.notifications,n];return this.notifications=i,n}async removeNotification(t){return new Promise(o=>{var i;let n=(i=this.shadowRoot)==null?void 0:i.getElementById(t);if(!n){o(!1);return}n.style.height=`${n.clientHeight}px`,n.addEventListener("animationend",({animationName:a})=>{a==="size-to-zero"&&(this.notifications=this.notifications.filter(c=>c.id!==t),o(!0))}),n.classList.add("removing")})}handleTouchStart(t){this.isMobile&&(t.stopPropagation(),this.touchStartY=t.touches[0].clientY)}handleTouchMove(t){if(!this.isMobile)return;t.stopPropagation();let o=t.currentTarget,n=t.touches[0].clientY,i=Math.min(n-this.touchStartY,0);o.style.transform=`translateY(${i}px)`}handleTouchEnd(t){if(!this.isMobile)return;t.stopPropagation();let o=t.currentTarget,i=t.changedTouches[0].clientY-this.touchStartY;i<G?(o.style.setProperty("--travel-distance",`${i-10}px`),this.removeNotification(o.id)):(o.style.transition="transform 0.3s ease",o.style.transform="translateY(0px)",o.addEventListener("transitionend",()=>{o.style.transition="",o.style.transform=""})),this.touchStartY=0}renderActionSlot(t,o){let n=t==="primary-action"?o.primaryAction:o.secondaryAction;return!n||!n.label?"":w`<bl-button slot="${t}" @bl-click=${()=>n.onClick(o)}>
|
|
2
|
+
${n.label}
|
|
3
|
+
</bl-button>`}render(){return w`
|
|
4
|
+
<div class="wrapper">
|
|
5
|
+
${V(this.notifications,t=>t.id,t=>{let{caption:o,description:n,icon:i=!0,variant:a="info",id:c,duration:p=this.duration,permanent:m}=t,b=this.renderActionSlot("primary-action",t),x=this.renderActionSlot("secondary-action",t);return w`
|
|
6
|
+
<bl-notification-card
|
|
7
|
+
id="${c}"
|
|
8
|
+
class="notification"
|
|
9
|
+
data-slide=${this.isMobile?"top":"right"}
|
|
10
|
+
duration=${p}
|
|
11
|
+
caption="${Y(o)}"
|
|
12
|
+
icon=${i}
|
|
13
|
+
variant=${Y(a)}
|
|
14
|
+
?permanent=${m}
|
|
15
|
+
@bl-notification-card-request-close=${e=>{e.preventDefault(),this.removeNotification(c)}}
|
|
16
|
+
@touchstart=${this.handleTouchStart}
|
|
17
|
+
@touchmove=${this.handleTouchMove}
|
|
18
|
+
@touchend=${this.handleTouchEnd}
|
|
19
|
+
>
|
|
20
|
+
${n} ${b} ${x}
|
|
21
|
+
</bl-notification-card>
|
|
22
|
+
`})}
|
|
23
|
+
</div>
|
|
24
|
+
`}};v([A({type:Boolean,attribute:"no-animation",reflect:!0})],u.prototype,"noAnimation",2),v([A({type:Number})],u.prototype,"duration",2),v([M()],u.prototype,"notifications",2),v([S({passive:!0})],u.prototype,"handleTouchStart",1),v([S({passive:!0})],u.prototype,"handleTouchMove",1),v([S({passive:!0})],u.prototype,"handleTouchEnd",1),u=v([k("bl-notification")],u);export{G as a,u as b};
|
|
25
|
+
/*! Bundled license information:
|
|
26
|
+
|
|
27
|
+
lit-html/directives/repeat.js:
|
|
28
|
+
(**
|
|
29
|
+
* @license
|
|
30
|
+
* Copyright 2017 Google LLC
|
|
31
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
32
|
+
*)
|
|
33
|
+
*/
|
|
34
|
+
//# sourceMappingURL=chunk-SBCJY5IU.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../node_modules/lit-html/src/directives/repeat.ts", "../src/components/notification/bl-notification.css", "../src/components/notification/bl-notification.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {ChildPart, noChange} from '../lit-html.js';\nimport {directive, Directive, PartInfo, PartType} from '../directive.js';\nimport {\n insertPart,\n getCommittedValue,\n removePart,\n setCommittedValue,\n setChildPartValue,\n} from '../directive-helpers.js';\n\nexport type KeyFn<T> = (item: T, index: number) => unknown;\nexport type ItemTemplate<T> = (item: T, index: number) => unknown;\n\n// Helper for generating a map of array item to its index over a subset\n// of an array (used to lazily generate `newKeyToIndexMap` and\n// `oldKeyToIndexMap`)\nconst generateMap = (list: unknown[], start: number, end: number) => {\n const map = new Map<unknown, number>();\n for (let i = start; i <= end; i++) {\n map.set(list[i], i);\n }\n return map;\n};\n\nclass RepeatDirective extends Directive {\n private _itemKeys?: unknown[];\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.CHILD) {\n throw new Error('repeat() can only be used in text expressions');\n }\n }\n\n private _getValuesAndKeys<T>(\n items: Iterable<T>,\n keyFnOrTemplate: KeyFn<T> | ItemTemplate<T>,\n template?: ItemTemplate<T>\n ) {\n let keyFn: KeyFn<T> | undefined;\n if (template === undefined) {\n template = keyFnOrTemplate;\n } else if (keyFnOrTemplate !== undefined) {\n keyFn = keyFnOrTemplate as KeyFn<T>;\n }\n const keys = [];\n const values = [];\n let index = 0;\n for (const item of items) {\n keys[index] = keyFn ? keyFn(item, index) : index;\n values[index] = template!(item, index);\n index++;\n }\n return {\n values,\n keys,\n };\n }\n\n render<T>(items: Iterable<T>, template: ItemTemplate<T>): Array<unknown>;\n render<T>(\n items: Iterable<T>,\n keyFn: KeyFn<T> | ItemTemplate<T>,\n template: ItemTemplate<T>\n ): Array<unknown>;\n render<T>(\n items: Iterable<T>,\n keyFnOrTemplate: KeyFn<T> | ItemTemplate<T>,\n template?: ItemTemplate<T>\n ) {\n return this._getValuesAndKeys(items, keyFnOrTemplate, template).values;\n }\n\n override update<T>(\n containerPart: ChildPart,\n [items, keyFnOrTemplate, template]: [\n Iterable<T>,\n KeyFn<T> | ItemTemplate<T>,\n ItemTemplate<T>\n ]\n ) {\n // Old part & key lists are retrieved from the last update (which may\n // be primed by hydration)\n const oldParts = getCommittedValue(\n containerPart\n ) as Array<ChildPart | null>;\n const {values: newValues, keys: newKeys} = this._getValuesAndKeys(\n items,\n keyFnOrTemplate,\n template\n );\n\n // We check that oldParts, the committed value, is an Array as an\n // indicator that the previous value came from a repeat() call. If\n // oldParts is not an Array then this is the first render and we return\n // an array for lit-html's array handling to render, and remember the\n // keys.\n if (!Array.isArray(oldParts)) {\n this._itemKeys = newKeys;\n return newValues;\n }\n\n // In SSR hydration it's possible for oldParts to be an array but for us\n // to not have item keys because the update() hasn't run yet. We set the\n // keys to an empty array. This will cause all oldKey/newKey comparisons\n // to fail and execution to fall to the last nested brach below which\n // reuses the oldPart.\n const oldKeys = (this._itemKeys ??= []);\n\n // New part list will be built up as we go (either reused from\n // old parts or created for new keys in this update). This is\n // saved in the above cache at the end of the update.\n const newParts: ChildPart[] = [];\n\n // Maps from key to index for current and previous update; these\n // are generated lazily only when needed as a performance\n // optimization, since they are only required for multiple\n // non-contiguous changes in the list, which are less common.\n let newKeyToIndexMap!: Map<unknown, number>;\n let oldKeyToIndexMap!: Map<unknown, number>;\n\n // Head and tail pointers to old parts and new values\n let oldHead = 0;\n let oldTail = oldParts.length - 1;\n let newHead = 0;\n let newTail = newValues.length - 1;\n\n // Overview of O(n) reconciliation algorithm (general approach\n // based on ideas found in ivi, vue, snabbdom, etc.):\n //\n // * We start with the list of old parts and new values (and\n // arrays of their respective keys), head/tail pointers into\n // each, and we build up the new list of parts by updating\n // (and when needed, moving) old parts or creating new ones.\n // The initial scenario might look like this (for brevity of\n // the diagrams, the numbers in the array reflect keys\n // associated with the old parts or new values, although keys\n // and parts/values are actually stored in parallel arrays\n // indexed using the same head/tail pointers):\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [ , , , , , , ]\n // newKeys: [0, 2, 1, 4, 3, 7, 6] <- reflects the user's new\n // item order\n // newHead ^ ^ newTail\n //\n // * Iterate old & new lists from both sides, updating,\n // swapping, or removing parts at the head/tail locations\n // until neither head nor tail can move.\n //\n // * Example below: keys at head pointers match, so update old\n // part 0 in-place (no need to move it) and record part 0 in\n // the `newParts` list. The last thing we do is advance the\n // `oldHead` and `newHead` pointers (will be reflected in the\n // next diagram).\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [0, , , , , , ] <- heads matched: update 0\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance both oldHead\n // & newHead\n // newHead ^ ^ newTail\n //\n // * Example below: head pointers don't match, but tail\n // pointers do, so update part 6 in place (no need to move\n // it), and record part 6 in the `newParts` list. Last,\n // advance the `oldTail` and `oldHead` pointers.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [0, , , , , , 6] <- tails matched: update 6\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance both oldTail\n // & newTail\n // newHead ^ ^ newTail\n //\n // * If neither head nor tail match; next check if one of the\n // old head/tail items was removed. We first need to generate\n // the reverse map of new keys to index (`newKeyToIndexMap`),\n // which is done once lazily as a performance optimization,\n // since we only hit this case if multiple non-contiguous\n // changes were made. Note that for contiguous removal\n // anywhere in the list, the head and tails would advance\n // from either end and pass each other before we get to this\n // case and removals would be handled in the final while loop\n // without needing to generate the map.\n //\n // * Example below: The key at `oldTail` was removed (no longer\n // in the `newKeyToIndexMap`), so remove that part from the\n // DOM and advance just the `oldTail` pointer.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [0, , , , , , 6] <- 5 not in new map: remove\n // newKeys: [0, 2, 1, 4, 3, 7, 6] 5 and advance oldTail\n // newHead ^ ^ newTail\n //\n // * Once head and tail cannot move, any mismatches are due to\n // either new or moved items; if a new key is in the previous\n // \"old key to old index\" map, move the old part to the new\n // location, otherwise create and insert a new part. Note\n // that when moving an old part we null its position in the\n // oldParts array if it lies between the head and tail so we\n // know to skip it when the pointers get there.\n //\n // * Example below: neither head nor tail match, and neither\n // were removed; so find the `newHead` key in the\n // `oldKeyToIndexMap`, and move that old part's DOM into the\n // next head position (before `oldParts[oldHead]`). Last,\n // null the part in the `oldPart` array since it was\n // somewhere in the remaining oldParts still to be scanned\n // (between the head and tail pointers) so that we know to\n // skip that old part on future iterations.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, , , , , 6] <- stuck: update & move 2\n // newKeys: [0, 2, 1, 4, 3, 7, 6] into place and advance\n // newHead\n // newHead ^ ^ newTail\n //\n // * Note that for moves/insertions like the one above, a part\n // inserted at the head pointer is inserted before the\n // current `oldParts[oldHead]`, and a part inserted at the\n // tail pointer is inserted before `newParts[newTail+1]`. The\n // seeming asymmetry lies in the fact that new parts are\n // moved into place outside in, so to the right of the head\n // pointer are old parts, and to the right of the tail\n // pointer are new parts.\n //\n // * We always restart back from the top of the algorithm,\n // allowing matching and simple updates in place to\n // continue...\n //\n // * Example below: the head pointers once again match, so\n // simply update part 1 and record it in the `newParts`\n // array. Last, advance both head pointers.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, , , , 6] <- heads matched: update 1\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance both oldHead\n // & newHead\n // newHead ^ ^ newTail\n //\n // * As mentioned above, items that were moved as a result of\n // being stuck (the final else clause in the code below) are\n // marked with null, so we always advance old pointers over\n // these so we're comparing the next actual old value on\n // either end.\n //\n // * Example below: `oldHead` is null (already placed in\n // newParts), so advance `oldHead`.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6] <- old head already used:\n // newParts: [0, 2, 1, , , , 6] advance oldHead\n // newKeys: [0, 2, 1, 4, 3, 7, 6]\n // newHead ^ ^ newTail\n //\n // * Note it's not critical to mark old parts as null when they\n // are moved from head to tail or tail to head, since they\n // will be outside the pointer range and never visited again.\n //\n // * Example below: Here the old tail key matches the new head\n // key, so the part at the `oldTail` position and move its\n // DOM to the new head position (before `oldParts[oldHead]`).\n // Last, advance `oldTail` and `newHead` pointers.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, 4, , , 6] <- old tail matches new\n // newKeys: [0, 2, 1, 4, 3, 7, 6] head: update & move 4,\n // advance oldTail & newHead\n // newHead ^ ^ newTail\n //\n // * Example below: Old and new head keys match, so update the\n // old head part in place, and advance the `oldHead` and\n // `newHead` pointers.\n //\n // oldHead v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, 4, 3, ,6] <- heads match: update 3\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance oldHead &\n // newHead\n // newHead ^ ^ newTail\n //\n // * Once the new or old pointers move past each other then all\n // we have left is additions (if old list exhausted) or\n // removals (if new list exhausted). Those are handled in the\n // final while loops at the end.\n //\n // * Example below: `oldHead` exceeded `oldTail`, so we're done\n // with the main loop. Create the remaining part and insert\n // it at the new head position, and the update is complete.\n //\n // (oldHead > oldTail)\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, 4, 3, 7 ,6] <- create and insert 7\n // newKeys: [0, 2, 1, 4, 3, 7, 6]\n // newHead ^ newTail\n //\n // * Note that the order of the if/else clauses is not\n // important to the algorithm, as long as the null checks\n // come first (to ensure we're always working on valid old\n // parts) and that the final else clause comes last (since\n // that's where the expensive moves occur). The order of\n // remaining clauses is is just a simple guess at which cases\n // will be most common.\n //\n // * Note, we could calculate the longest\n // increasing subsequence (LIS) of old items in new position,\n // and only move those not in the LIS set. However that costs\n // O(nlogn) time and adds a bit more code, and only helps\n // make rare types of mutations require fewer moves. The\n // above handles removes, adds, reversal, swaps, and single\n // moves of contiguous items in linear time, in the minimum\n // number of moves. As the number of multiple moves where LIS\n // might help approaches a random shuffle, the LIS\n // optimization becomes less helpful, so it seems not worth\n // the code at this point. Could reconsider if a compelling\n // case arises.\n\n while (oldHead <= oldTail && newHead <= newTail) {\n if (oldParts[oldHead] === null) {\n // `null` means old part at head has already been used\n // below; skip\n oldHead++;\n } else if (oldParts[oldTail] === null) {\n // `null` means old part at tail has already been used\n // below; skip\n oldTail--;\n } else if (oldKeys[oldHead] === newKeys[newHead]) {\n // Old head matches new head; update in place\n newParts[newHead] = setChildPartValue(\n oldParts[oldHead]!,\n newValues[newHead]\n );\n oldHead++;\n newHead++;\n } else if (oldKeys[oldTail] === newKeys[newTail]) {\n // Old tail matches new tail; update in place\n newParts[newTail] = setChildPartValue(\n oldParts[oldTail]!,\n newValues[newTail]\n );\n oldTail--;\n newTail--;\n } else if (oldKeys[oldHead] === newKeys[newTail]) {\n // Old head matches new tail; update and move to new tail\n newParts[newTail] = setChildPartValue(\n oldParts[oldHead]!,\n newValues[newTail]\n );\n insertPart(containerPart, newParts[newTail + 1], oldParts[oldHead]!);\n oldHead++;\n newTail--;\n } else if (oldKeys[oldTail] === newKeys[newHead]) {\n // Old tail matches new head; update and move to new head\n newParts[newHead] = setChildPartValue(\n oldParts[oldTail]!,\n newValues[newHead]\n );\n insertPart(containerPart, oldParts[oldHead]!, oldParts[oldTail]!);\n oldTail--;\n newHead++;\n } else {\n if (newKeyToIndexMap === undefined) {\n // Lazily generate key-to-index maps, used for removals &\n // moves below\n newKeyToIndexMap = generateMap(newKeys, newHead, newTail);\n oldKeyToIndexMap = generateMap(oldKeys, oldHead, oldTail);\n }\n if (!newKeyToIndexMap.has(oldKeys[oldHead])) {\n // Old head is no longer in new list; remove\n removePart(oldParts[oldHead]!);\n oldHead++;\n } else if (!newKeyToIndexMap.has(oldKeys[oldTail])) {\n // Old tail is no longer in new list; remove\n removePart(oldParts[oldTail]!);\n oldTail--;\n } else {\n // Any mismatches at this point are due to additions or\n // moves; see if we have an old part we can reuse and move\n // into place\n const oldIndex = oldKeyToIndexMap.get(newKeys[newHead]);\n const oldPart = oldIndex !== undefined ? oldParts[oldIndex] : null;\n if (oldPart === null) {\n // No old part for this value; create a new one and\n // insert it\n const newPart = insertPart(containerPart, oldParts[oldHead]!);\n setChildPartValue(newPart, newValues[newHead]);\n newParts[newHead] = newPart;\n } else {\n // Reuse old part\n newParts[newHead] = setChildPartValue(oldPart, newValues[newHead]);\n insertPart(containerPart, oldParts[oldHead]!, oldPart);\n // This marks the old part as having been used, so that\n // it will be skipped in the first two checks above\n oldParts[oldIndex as number] = null;\n }\n newHead++;\n }\n }\n }\n // Add parts for any remaining new values\n while (newHead <= newTail) {\n // For all remaining additions, we insert before last new\n // tail, since old pointers are no longer valid\n const newPart = insertPart(containerPart, newParts[newTail + 1]);\n setChildPartValue(newPart, newValues[newHead]);\n newParts[newHead++] = newPart;\n }\n // Remove any remaining unused old parts\n while (oldHead <= oldTail) {\n const oldPart = oldParts[oldHead++];\n if (oldPart !== null) {\n removePart(oldPart);\n }\n }\n\n // Save order of new parts for next round\n this._itemKeys = newKeys;\n // Directly set part value, bypassing it's dirty-checking\n setCommittedValue(containerPart, newParts);\n return noChange;\n }\n}\n\nexport interface RepeatDirectiveFn {\n <T>(\n items: Iterable<T>,\n keyFnOrTemplate: KeyFn<T> | ItemTemplate<T>,\n template?: ItemTemplate<T>\n ): unknown;\n <T>(items: Iterable<T>, template: ItemTemplate<T>): unknown;\n <T>(\n items: Iterable<T>,\n keyFn: KeyFn<T> | ItemTemplate<T>,\n template: ItemTemplate<T>\n ): unknown;\n}\n\n/**\n * A directive that repeats a series of values (usually `TemplateResults`)\n * generated from an iterable, and updates those items efficiently when the\n * iterable changes based on user-provided `keys` associated with each item.\n *\n * Note that if a `keyFn` is provided, strict key-to-DOM mapping is maintained,\n * meaning previous DOM for a given key is moved into the new position if\n * needed, and DOM will never be reused with values for different keys (new DOM\n * will always be created for new keys). This is generally the most efficient\n * way to use `repeat` since it performs minimum unnecessary work for insertions\n * and removals.\n *\n * The `keyFn` takes two parameters, the item and its index, and returns a unique key value.\n *\n * ```js\n * html`\n * <ol>\n * ${repeat(this.items, (item) => item.id, (item, index) => {\n * return html`<li>${index}: ${item.name}</li>`;\n * })}\n * </ol>\n * `\n * ```\n *\n * **Important**: If providing a `keyFn`, keys *must* be unique for all items in a\n * given call to `repeat`. The behavior when two or more items have the same key\n * is undefined.\n *\n * If no `keyFn` is provided, this directive will perform similar to mapping\n * items to values, and DOM will be reused against potentially different items.\n */\nexport const repeat = directive(RepeatDirective) as RepeatDirectiveFn;\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {RepeatDirective};\n", "import {css} from 'lit';\nexport const styles = css`:host{--bl-notification-width:396px;--bl-notification-gap:var(--bl-size-2xs);--bl-notification-animation-duration:0.3s}.wrapper{--margin:var(--bl-size-xl);display:flex;flex-direction:column-reverse;position:fixed;top:0;inset-inline-end:0;max-width:var(--bl-notification-width);margin:var(--margin);width:calc(100% - var(--margin) * 2);z-index:var(--bl-index-notification)}@media screen and (max-width: 480px){.wrapper{flex-direction:column;max-width:100%}}.notification{will-change:transform height margin;animation:slide-in-right var(--bl-notification-animation-duration) ease;margin-bottom:var(--bl-notification-gap);touch-action:none}:host(:has([dir=\"rtl\"])) .notification{animation:slide-in-left var(--bl-notification-animation-duration) ease}.notification[data-slide=\"top\"]{animation:slide-in-top var(--bl-notification-animation-duration) ease}:host([no-animation]) .notification{animation:none}.notification.removing{animation:slide-out-right var(--bl-notification-animation-duration) ease forwards,size-to-zero var(--bl-notification-animation-duration) ease var(--bl-notification-animation-duration) forwards}.notification[data-slide=\"top\"].removing{animation:slide-out-top var(--bl-notification-animation-duration) ease forwards,size-to-zero var(--bl-notification-animation-duration) ease var(--bl-notification-animation-duration) forwards}:host([no-animation]) .notification.removing{animation:size-to-zero 0}@media (prefers-reduced-motion){.notification.removing{animation:size-to-zero 0}.notification{animation:none}}@keyframes slide-in-right{from{transform:translateX(var(--travel-distance, 10px));height:0;opacity:0;margin:0}}@keyframes slide-in-left{from{transform:translateX(var(--travel-distance, -10px));height:0;opacity:0;margin:0}}@keyframes slide-out-right{to{transform:translateX(var(--travel-distance, 10px));opacity:0}}@keyframes slide-in-top{from{transform:translateY(var(--travel-distance, -10px));height:0;opacity:0;margin:0}}@keyframes slide-out-top{to{transform:translateY(var(--travel-distance, -10px));opacity:0}}@keyframes size-to-zero{to{height:0;margin:0}}`;\nexport default styles;\n", "import { CSSResultGroup, html, LitElement, TemplateResult } from \"lit\";\nimport { customElement, eventOptions, property, state } from \"lit/decorators.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport BlAlert from \"../alert/bl-alert\";\nimport { BaklavaIcon } from \"../icon/icon-list\";\nimport style from \"./bl-notification.css\";\nimport BlNotificationCard, { CloseSource, NotificationVariant } from \"./card/bl-notification-card\";\n\ntype Action = {\n label: string;\n onClick: (notification: Notification) => void;\n};\n\nexport type NotificationProps = {\n caption?: string;\n description: string;\n icon?: boolean | BaklavaIcon;\n variant?: NotificationVariant;\n primaryAction?: Action;\n secondaryAction?: Action;\n duration?: number;\n permanent?: boolean;\n};\n\nexport type Notification = NotificationProps & {\n id: string;\n remove: () => Promise<boolean>;\n};\n\nexport const SWIPE_UP_THRESHOLD = -50;\n\n/**\n * @tag bl-notification\n * @summary Baklava Notification component\n */\n\n@customElement(\"bl-notification\")\nexport default class BlNotification extends LitElement {\n static get styles(): CSSResultGroup {\n return [style];\n }\n\n /**\n * Disable animations.\n * It will not be possible to use animations if the user has disabled them.\n * Animations will respect the user's preferences regardless of this property.\n */\n @property({ type: Boolean, attribute: \"no-animation\", reflect: true })\n noAnimation = false;\n\n /**\n * Sets the default duration of notifications in seconds\n */\n @property({ type: Number })\n duration = 7;\n\n @state()\n private notifications: Notification[] = [];\n\n public get notificationList() {\n return this.notifications;\n }\n\n private touchStartY = 0;\n\n public get touchStart() {\n return {\n y: this.touchStartY,\n };\n }\n\n private get isMobile() {\n return window.matchMedia(\"(max-width: 480px)\").matches;\n }\n\n /**\n * Adds a notification to the list of notifications.\n * @param {NotificationProps} props Notification properties\n * @returns {Notification} A notification object with a remove method.\n */\n public addNotification(props: NotificationProps) {\n // TODO id generation\n const id = Math.random().toString(36).substr(2, 9);\n const notification: Notification = {\n ...props,\n id,\n duration: props.duration || this.duration,\n remove: () => this.removeNotification(id),\n };\n\n const newNotifications = [...this.notifications, notification];\n\n this.notifications = newNotifications;\n\n return notification;\n }\n\n /**\n * Removes a notification from the list of notifications.\n * @param {string} id Notification id\n * @returns {Promise<boolean>} A promise that resolves with a boolean indicating whether the notification was removed.\n */\n public async removeNotification(id: string): Promise<boolean> {\n return new Promise(resolve => {\n const notificationEl = this.shadowRoot?.getElementById(id) as BlAlert;\n\n if (!notificationEl) {\n resolve(false);\n return;\n }\n\n notificationEl.style.height = `${notificationEl.clientHeight}px`;\n notificationEl.addEventListener(\"animationend\", ({ animationName }: AnimationEvent) => {\n if (animationName !== \"size-to-zero\") {\n return;\n }\n\n this.notifications = this.notifications.filter(notification => notification.id !== id);\n resolve(true);\n });\n\n notificationEl.classList.add(\"removing\");\n });\n }\n\n @eventOptions({ passive: true })\n private handleTouchStart(event: TouchEvent) {\n if (!this.isMobile) {\n return;\n }\n\n event.stopPropagation();\n\n this.touchStartY = event.touches[0].clientY;\n }\n\n @eventOptions({ passive: true })\n private handleTouchMove(event: TouchEvent) {\n if (!this.isMobile) {\n return;\n }\n event.stopPropagation();\n\n const currentTarget = event.currentTarget as BlNotificationCard;\n\n const currentY = event.touches[0].clientY;\n // Allow only moving up\n const movedY = Math.min(currentY - this.touchStartY, 0);\n\n currentTarget.style.transform = `translateY(${movedY}px)`;\n }\n\n @eventOptions({ passive: true })\n private handleTouchEnd(event: TouchEvent) {\n if (!this.isMobile) {\n return;\n }\n event.stopPropagation();\n\n const currentTarget = event.currentTarget as BlNotificationCard;\n\n const currentY = event.changedTouches[0].clientY;\n const movedY = currentY - this.touchStartY;\n\n if (movedY < SWIPE_UP_THRESHOLD) {\n currentTarget.style.setProperty(\"--travel-distance\", `${movedY - 10}px`);\n this.removeNotification(currentTarget.id);\n } else {\n currentTarget.style.transition = \"transform 0.3s ease\";\n currentTarget.style.transform = \"translateY(0px)\";\n\n currentTarget.addEventListener(\"transitionend\", () => {\n currentTarget.style.transition = \"\";\n currentTarget.style.transform = \"\";\n });\n }\n\n this.touchStartY = 0;\n }\n\n private renderActionSlot(\n slotName: \"primary-action\" | \"secondary-action\",\n notification: Notification\n ) {\n const action =\n slotName === \"primary-action\" ? notification.primaryAction : notification.secondaryAction;\n\n if (!action || !action.label) {\n return \"\";\n }\n\n return html`<bl-button slot=\"${slotName}\" @bl-click=${() => action.onClick(notification)}>\n ${action.label}\n </bl-button>`;\n }\n\n render(): TemplateResult {\n return html`\n <div class=\"wrapper\">\n ${repeat(\n this.notifications,\n notification => notification.id,\n notification => {\n const {\n caption,\n description,\n icon = true,\n variant = \"info\",\n id,\n duration = this.duration,\n permanent,\n } = notification;\n\n const actionButton = this.renderActionSlot(\"primary-action\", notification);\n const secondaryActionButton = this.renderActionSlot(\"secondary-action\", notification);\n\n return html`\n <bl-notification-card\n id=\"${id}\"\n class=\"notification\"\n data-slide=${this.isMobile ? \"top\" : \"right\"}\n duration=${duration}\n caption=\"${ifDefined(caption)}\"\n icon=${icon}\n variant=${ifDefined(variant)}\n ?permanent=${permanent}\n @bl-notification-card-request-close=${(\n event: CustomEvent<{ source: CloseSource }>\n ) => {\n // We will run animations on the notification card\n // so we need to prevent the default close behavior\n event.preventDefault();\n this.removeNotification(id);\n }}\n @touchstart=${this.handleTouchStart}\n @touchmove=${this.handleTouchMove}\n @touchend=${this.handleTouchEnd}\n >\n ${description} ${actionButton} ${secondaryActionButton}\n </bl-notification-card>\n `;\n }\n )}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bl-notification\": BlNotification;\n }\n}\n"],
|
|
5
|
-
"mappings": "oUAsBA,IAAMA,EAAc,CAACC,EAAiBC,EAAeC,IAAAA,CACnD,IAAMC,EAAM,IAAIC,IAChB,QAASC,EAAIJ,EAAOI,GAAKH,EAAKG,IAC5BF,EAAIG,IAAIN,EAAKK,CAAAA,EAAIA,CAAAA,EAEnB,OAAOF,CAAG,EAqcCI,EAASC,EAlctB,cAA8BC,CAAAA,CAG5BC,YAAYC,EAAAA,CAEV,GADAC,MAAMD,CAAAA,EACFA,EAASE,OAASC,EAASC,MAC7B,MAAUC,MAAM,+CAAA,CAEnB,CAEOC,GACNC,EACAC,EACAC,EAAAA,CAEA,IAAIC,EACAD,IADAC,OAEFD,EAAWD,EACFA,IADEA,SAEXE,EAAQF,GAEV,IAAMG,EAAO,CAAA,EACPC,EAAS,CAAA,EACXC,EAAQ,EACZ,QAAWC,KAAQP,EACjBI,EAAKE,CAAAA,EAASH,EAAQA,EAAMI,EAAMD,CAAAA,EAASA,EAC3CD,EAAOC,CAAAA,EAASJ,EAAUK,EAAMD,CAAAA,EAChCA,IAEF,MAAO,CACLD,OAAAA,EACAD,KAAAA,CAAAA,CAEH,CAQDI,OACER,EACAC,EACAC,EAAAA,CAEA,OAAOO,KAAKV,GAAkBC,EAAOC,EAAiBC,CAAAA,EAAUG,MAC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A,CAAAA,EACvDA,IACAE,YAEIL,IAMJ,SAHEA,EAAmBzC,EAAYkC,EAASY,EAASC,CAAAA,EACjDL,EAAmB1C,EAAYsC,EAASK,EAASC,CAAAA,GAE9CH,EAAiBS,IAAIZ,EAAQK,CAAAA,CAAAA,EAI3B,GAAKF,EAAiBS,IAAIZ,EAAQM,CAAAA,CAAAA,EAIlC,CAIL,IAAMO,EAAWT,EAAiBU,IAAIlB,EAAQY,CAAAA,CAAAA,EACxCO,EAAUF,IAAVE,OAAmCtB,EAASoB,CAAAA,EAAY,KAC9D,GAAIE,IAAY,KAAM,CAGpB,IAAMC,EAAUL,EAAWnB,EAAeC,EAASY,CAAAA,CAAAA,EACnDK,EAAkBM,EAASrB,EAAUa,CAAAA,CAAAA,EACrCN,EAASM,CAAAA,EAAWQ,OAGpBd,EAASM,CAAAA,EAAWE,EAAkBK,EAASpB,EAAUa,CAAAA,CAAAA,EACzDG,EAAWnB,EAAeC,EAASY,CAAAA,EAAWU,CAAAA,EAG9CtB,EAASoB,CAAAA,EAAsB,KAEjCL,SAtBAS,EAAWxB,EAASa,CAAAA,CAAAA,EACpBA,SALAW,EAAWxB,EAASY,CAAAA,CAAAA,EACpBA,IA8BN,KAAOG,GAAWC,GAAS,CAGzB,IAAMO,EAAUL,EAAWnB,EAAeU,EAASO,EAAU,CAAA,CAAA,EAC7DC,EAAkBM,EAASrB,EAAUa,CAAAA,CAAAA,EACrCN,EAASM,GAAAA,EAAaQ,EAGxB,KAAOX,GAAWC,GAAS,CACzB,IAAMS,EAAUtB,EAASY,GAAAA,EACrBU,IAAY,MACdE,EAAWF,CAAAA,EAQf,OAHAzB,KAAKS,GAAYH,EAEjBsB,EAAkB1B,EAAeU,CAAAA,EAC1BiB,CACR,CAAA,CAAA,EC/aI,IAAMC,EAASC,
|
|
4
|
+
"sourcesContent": ["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {ChildPart, noChange} from '../lit-html.js';\nimport {directive, Directive, PartInfo, PartType} from '../directive.js';\nimport {\n insertPart,\n getCommittedValue,\n removePart,\n setCommittedValue,\n setChildPartValue,\n} from '../directive-helpers.js';\n\nexport type KeyFn<T> = (item: T, index: number) => unknown;\nexport type ItemTemplate<T> = (item: T, index: number) => unknown;\n\n// Helper for generating a map of array item to its index over a subset\n// of an array (used to lazily generate `newKeyToIndexMap` and\n// `oldKeyToIndexMap`)\nconst generateMap = (list: unknown[], start: number, end: number) => {\n const map = new Map<unknown, number>();\n for (let i = start; i <= end; i++) {\n map.set(list[i], i);\n }\n return map;\n};\n\nclass RepeatDirective extends Directive {\n private _itemKeys?: unknown[];\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.CHILD) {\n throw new Error('repeat() can only be used in text expressions');\n }\n }\n\n private _getValuesAndKeys<T>(\n items: Iterable<T>,\n keyFnOrTemplate: KeyFn<T> | ItemTemplate<T>,\n template?: ItemTemplate<T>\n ) {\n let keyFn: KeyFn<T> | undefined;\n if (template === undefined) {\n template = keyFnOrTemplate;\n } else if (keyFnOrTemplate !== undefined) {\n keyFn = keyFnOrTemplate as KeyFn<T>;\n }\n const keys = [];\n const values = [];\n let index = 0;\n for (const item of items) {\n keys[index] = keyFn ? keyFn(item, index) : index;\n values[index] = template!(item, index);\n index++;\n }\n return {\n values,\n keys,\n };\n }\n\n render<T>(items: Iterable<T>, template: ItemTemplate<T>): Array<unknown>;\n render<T>(\n items: Iterable<T>,\n keyFn: KeyFn<T> | ItemTemplate<T>,\n template: ItemTemplate<T>\n ): Array<unknown>;\n render<T>(\n items: Iterable<T>,\n keyFnOrTemplate: KeyFn<T> | ItemTemplate<T>,\n template?: ItemTemplate<T>\n ) {\n return this._getValuesAndKeys(items, keyFnOrTemplate, template).values;\n }\n\n override update<T>(\n containerPart: ChildPart,\n [items, keyFnOrTemplate, template]: [\n Iterable<T>,\n KeyFn<T> | ItemTemplate<T>,\n ItemTemplate<T>\n ]\n ) {\n // Old part & key lists are retrieved from the last update (which may\n // be primed by hydration)\n const oldParts = getCommittedValue(\n containerPart\n ) as Array<ChildPart | null>;\n const {values: newValues, keys: newKeys} = this._getValuesAndKeys(\n items,\n keyFnOrTemplate,\n template\n );\n\n // We check that oldParts, the committed value, is an Array as an\n // indicator that the previous value came from a repeat() call. If\n // oldParts is not an Array then this is the first render and we return\n // an array for lit-html's array handling to render, and remember the\n // keys.\n if (!Array.isArray(oldParts)) {\n this._itemKeys = newKeys;\n return newValues;\n }\n\n // In SSR hydration it's possible for oldParts to be an array but for us\n // to not have item keys because the update() hasn't run yet. We set the\n // keys to an empty array. This will cause all oldKey/newKey comparisons\n // to fail and execution to fall to the last nested brach below which\n // reuses the oldPart.\n const oldKeys = (this._itemKeys ??= []);\n\n // New part list will be built up as we go (either reused from\n // old parts or created for new keys in this update). This is\n // saved in the above cache at the end of the update.\n const newParts: ChildPart[] = [];\n\n // Maps from key to index for current and previous update; these\n // are generated lazily only when needed as a performance\n // optimization, since they are only required for multiple\n // non-contiguous changes in the list, which are less common.\n let newKeyToIndexMap!: Map<unknown, number>;\n let oldKeyToIndexMap!: Map<unknown, number>;\n\n // Head and tail pointers to old parts and new values\n let oldHead = 0;\n let oldTail = oldParts.length - 1;\n let newHead = 0;\n let newTail = newValues.length - 1;\n\n // Overview of O(n) reconciliation algorithm (general approach\n // based on ideas found in ivi, vue, snabbdom, etc.):\n //\n // * We start with the list of old parts and new values (and\n // arrays of their respective keys), head/tail pointers into\n // each, and we build up the new list of parts by updating\n // (and when needed, moving) old parts or creating new ones.\n // The initial scenario might look like this (for brevity of\n // the diagrams, the numbers in the array reflect keys\n // associated with the old parts or new values, although keys\n // and parts/values are actually stored in parallel arrays\n // indexed using the same head/tail pointers):\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [ , , , , , , ]\n // newKeys: [0, 2, 1, 4, 3, 7, 6] <- reflects the user's new\n // item order\n // newHead ^ ^ newTail\n //\n // * Iterate old & new lists from both sides, updating,\n // swapping, or removing parts at the head/tail locations\n // until neither head nor tail can move.\n //\n // * Example below: keys at head pointers match, so update old\n // part 0 in-place (no need to move it) and record part 0 in\n // the `newParts` list. The last thing we do is advance the\n // `oldHead` and `newHead` pointers (will be reflected in the\n // next diagram).\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [0, , , , , , ] <- heads matched: update 0\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance both oldHead\n // & newHead\n // newHead ^ ^ newTail\n //\n // * Example below: head pointers don't match, but tail\n // pointers do, so update part 6 in place (no need to move\n // it), and record part 6 in the `newParts` list. Last,\n // advance the `oldTail` and `oldHead` pointers.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [0, , , , , , 6] <- tails matched: update 6\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance both oldTail\n // & newTail\n // newHead ^ ^ newTail\n //\n // * If neither head nor tail match; next check if one of the\n // old head/tail items was removed. We first need to generate\n // the reverse map of new keys to index (`newKeyToIndexMap`),\n // which is done once lazily as a performance optimization,\n // since we only hit this case if multiple non-contiguous\n // changes were made. Note that for contiguous removal\n // anywhere in the list, the head and tails would advance\n // from either end and pass each other before we get to this\n // case and removals would be handled in the final while loop\n // without needing to generate the map.\n //\n // * Example below: The key at `oldTail` was removed (no longer\n // in the `newKeyToIndexMap`), so remove that part from the\n // DOM and advance just the `oldTail` pointer.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [0, , , , , , 6] <- 5 not in new map: remove\n // newKeys: [0, 2, 1, 4, 3, 7, 6] 5 and advance oldTail\n // newHead ^ ^ newTail\n //\n // * Once head and tail cannot move, any mismatches are due to\n // either new or moved items; if a new key is in the previous\n // \"old key to old index\" map, move the old part to the new\n // location, otherwise create and insert a new part. Note\n // that when moving an old part we null its position in the\n // oldParts array if it lies between the head and tail so we\n // know to skip it when the pointers get there.\n //\n // * Example below: neither head nor tail match, and neither\n // were removed; so find the `newHead` key in the\n // `oldKeyToIndexMap`, and move that old part's DOM into the\n // next head position (before `oldParts[oldHead]`). Last,\n // null the part in the `oldPart` array since it was\n // somewhere in the remaining oldParts still to be scanned\n // (between the head and tail pointers) so that we know to\n // skip that old part on future iterations.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, , , , , 6] <- stuck: update & move 2\n // newKeys: [0, 2, 1, 4, 3, 7, 6] into place and advance\n // newHead\n // newHead ^ ^ newTail\n //\n // * Note that for moves/insertions like the one above, a part\n // inserted at the head pointer is inserted before the\n // current `oldParts[oldHead]`, and a part inserted at the\n // tail pointer is inserted before `newParts[newTail+1]`. The\n // seeming asymmetry lies in the fact that new parts are\n // moved into place outside in, so to the right of the head\n // pointer are old parts, and to the right of the tail\n // pointer are new parts.\n //\n // * We always restart back from the top of the algorithm,\n // allowing matching and simple updates in place to\n // continue...\n //\n // * Example below: the head pointers once again match, so\n // simply update part 1 and record it in the `newParts`\n // array. Last, advance both head pointers.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, , , , 6] <- heads matched: update 1\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance both oldHead\n // & newHead\n // newHead ^ ^ newTail\n //\n // * As mentioned above, items that were moved as a result of\n // being stuck (the final else clause in the code below) are\n // marked with null, so we always advance old pointers over\n // these so we're comparing the next actual old value on\n // either end.\n //\n // * Example below: `oldHead` is null (already placed in\n // newParts), so advance `oldHead`.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6] <- old head already used:\n // newParts: [0, 2, 1, , , , 6] advance oldHead\n // newKeys: [0, 2, 1, 4, 3, 7, 6]\n // newHead ^ ^ newTail\n //\n // * Note it's not critical to mark old parts as null when they\n // are moved from head to tail or tail to head, since they\n // will be outside the pointer range and never visited again.\n //\n // * Example below: Here the old tail key matches the new head\n // key, so the part at the `oldTail` position and move its\n // DOM to the new head position (before `oldParts[oldHead]`).\n // Last, advance `oldTail` and `newHead` pointers.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, 4, , , 6] <- old tail matches new\n // newKeys: [0, 2, 1, 4, 3, 7, 6] head: update & move 4,\n // advance oldTail & newHead\n // newHead ^ ^ newTail\n //\n // * Example below: Old and new head keys match, so update the\n // old head part in place, and advance the `oldHead` and\n // `newHead` pointers.\n //\n // oldHead v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, 4, 3, ,6] <- heads match: update 3\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance oldHead &\n // newHead\n // newHead ^ ^ newTail\n //\n // * Once the new or old pointers move past each other then all\n // we have left is additions (if old list exhausted) or\n // removals (if new list exhausted). Those are handled in the\n // final while loops at the end.\n //\n // * Example below: `oldHead` exceeded `oldTail`, so we're done\n // with the main loop. Create the remaining part and insert\n // it at the new head position, and the update is complete.\n //\n // (oldHead > oldTail)\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, 4, 3, 7 ,6] <- create and insert 7\n // newKeys: [0, 2, 1, 4, 3, 7, 6]\n // newHead ^ newTail\n //\n // * Note that the order of the if/else clauses is not\n // important to the algorithm, as long as the null checks\n // come first (to ensure we're always working on valid old\n // parts) and that the final else clause comes last (since\n // that's where the expensive moves occur). The order of\n // remaining clauses is is just a simple guess at which cases\n // will be most common.\n //\n // * Note, we could calculate the longest\n // increasing subsequence (LIS) of old items in new position,\n // and only move those not in the LIS set. However that costs\n // O(nlogn) time and adds a bit more code, and only helps\n // make rare types of mutations require fewer moves. The\n // above handles removes, adds, reversal, swaps, and single\n // moves of contiguous items in linear time, in the minimum\n // number of moves. As the number of multiple moves where LIS\n // might help approaches a random shuffle, the LIS\n // optimization becomes less helpful, so it seems not worth\n // the code at this point. Could reconsider if a compelling\n // case arises.\n\n while (oldHead <= oldTail && newHead <= newTail) {\n if (oldParts[oldHead] === null) {\n // `null` means old part at head has already been used\n // below; skip\n oldHead++;\n } else if (oldParts[oldTail] === null) {\n // `null` means old part at tail has already been used\n // below; skip\n oldTail--;\n } else if (oldKeys[oldHead] === newKeys[newHead]) {\n // Old head matches new head; update in place\n newParts[newHead] = setChildPartValue(\n oldParts[oldHead]!,\n newValues[newHead]\n );\n oldHead++;\n newHead++;\n } else if (oldKeys[oldTail] === newKeys[newTail]) {\n // Old tail matches new tail; update in place\n newParts[newTail] = setChildPartValue(\n oldParts[oldTail]!,\n newValues[newTail]\n );\n oldTail--;\n newTail--;\n } else if (oldKeys[oldHead] === newKeys[newTail]) {\n // Old head matches new tail; update and move to new tail\n newParts[newTail] = setChildPartValue(\n oldParts[oldHead]!,\n newValues[newTail]\n );\n insertPart(containerPart, newParts[newTail + 1], oldParts[oldHead]!);\n oldHead++;\n newTail--;\n } else if (oldKeys[oldTail] === newKeys[newHead]) {\n // Old tail matches new head; update and move to new head\n newParts[newHead] = setChildPartValue(\n oldParts[oldTail]!,\n newValues[newHead]\n );\n insertPart(containerPart, oldParts[oldHead]!, oldParts[oldTail]!);\n oldTail--;\n newHead++;\n } else {\n if (newKeyToIndexMap === undefined) {\n // Lazily generate key-to-index maps, used for removals &\n // moves below\n newKeyToIndexMap = generateMap(newKeys, newHead, newTail);\n oldKeyToIndexMap = generateMap(oldKeys, oldHead, oldTail);\n }\n if (!newKeyToIndexMap.has(oldKeys[oldHead])) {\n // Old head is no longer in new list; remove\n removePart(oldParts[oldHead]!);\n oldHead++;\n } else if (!newKeyToIndexMap.has(oldKeys[oldTail])) {\n // Old tail is no longer in new list; remove\n removePart(oldParts[oldTail]!);\n oldTail--;\n } else {\n // Any mismatches at this point are due to additions or\n // moves; see if we have an old part we can reuse and move\n // into place\n const oldIndex = oldKeyToIndexMap.get(newKeys[newHead]);\n const oldPart = oldIndex !== undefined ? oldParts[oldIndex] : null;\n if (oldPart === null) {\n // No old part for this value; create a new one and\n // insert it\n const newPart = insertPart(containerPart, oldParts[oldHead]!);\n setChildPartValue(newPart, newValues[newHead]);\n newParts[newHead] = newPart;\n } else {\n // Reuse old part\n newParts[newHead] = setChildPartValue(oldPart, newValues[newHead]);\n insertPart(containerPart, oldParts[oldHead]!, oldPart);\n // This marks the old part as having been used, so that\n // it will be skipped in the first two checks above\n oldParts[oldIndex as number] = null;\n }\n newHead++;\n }\n }\n }\n // Add parts for any remaining new values\n while (newHead <= newTail) {\n // For all remaining additions, we insert before last new\n // tail, since old pointers are no longer valid\n const newPart = insertPart(containerPart, newParts[newTail + 1]);\n setChildPartValue(newPart, newValues[newHead]);\n newParts[newHead++] = newPart;\n }\n // Remove any remaining unused old parts\n while (oldHead <= oldTail) {\n const oldPart = oldParts[oldHead++];\n if (oldPart !== null) {\n removePart(oldPart);\n }\n }\n\n // Save order of new parts for next round\n this._itemKeys = newKeys;\n // Directly set part value, bypassing it's dirty-checking\n setCommittedValue(containerPart, newParts);\n return noChange;\n }\n}\n\nexport interface RepeatDirectiveFn {\n <T>(\n items: Iterable<T>,\n keyFnOrTemplate: KeyFn<T> | ItemTemplate<T>,\n template?: ItemTemplate<T>\n ): unknown;\n <T>(items: Iterable<T>, template: ItemTemplate<T>): unknown;\n <T>(\n items: Iterable<T>,\n keyFn: KeyFn<T> | ItemTemplate<T>,\n template: ItemTemplate<T>\n ): unknown;\n}\n\n/**\n * A directive that repeats a series of values (usually `TemplateResults`)\n * generated from an iterable, and updates those items efficiently when the\n * iterable changes based on user-provided `keys` associated with each item.\n *\n * Note that if a `keyFn` is provided, strict key-to-DOM mapping is maintained,\n * meaning previous DOM for a given key is moved into the new position if\n * needed, and DOM will never be reused with values for different keys (new DOM\n * will always be created for new keys). This is generally the most efficient\n * way to use `repeat` since it performs minimum unnecessary work for insertions\n * and removals.\n *\n * The `keyFn` takes two parameters, the item and its index, and returns a unique key value.\n *\n * ```js\n * html`\n * <ol>\n * ${repeat(this.items, (item) => item.id, (item, index) => {\n * return html`<li>${index}: ${item.name}</li>`;\n * })}\n * </ol>\n * `\n * ```\n *\n * **Important**: If providing a `keyFn`, keys *must* be unique for all items in a\n * given call to `repeat`. The behavior when two or more items have the same key\n * is undefined.\n *\n * If no `keyFn` is provided, this directive will perform similar to mapping\n * items to values, and DOM will be reused against potentially different items.\n */\nexport const repeat = directive(RepeatDirective) as RepeatDirectiveFn;\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {RepeatDirective};\n", "import {css} from 'lit';\nexport const styles = css`:host{--bl-notification-width:396px;--bl-notification-gap:var(--bl-size-2xs);--bl-notification-animation-duration:0.3s}.wrapper{--margin:var(--bl-size-xl);display:flex;flex-direction:column-reverse;position:fixed;top:0;inset-inline-end:0;max-width:var(--bl-notification-width);margin:var(--margin);width:calc(100% - var(--margin) * 2);z-index:var(--bl-index-notification)}@media screen and (max-width:480px){.wrapper{flex-direction:column;max-width:100%}}.notification{will-change:transform height margin;animation:slide-in-right var(--bl-notification-animation-duration) ease;margin-bottom:var(--bl-notification-gap);touch-action:none}:host(:has([dir=rtl])) .notification{animation:slide-in-left var(--bl-notification-animation-duration) ease}.notification[data-slide=top]{animation:slide-in-top var(--bl-notification-animation-duration) ease}:host([no-animation]) .notification{animation:none}.notification.removing{animation:slide-out-right var(--bl-notification-animation-duration) ease forwards,size-to-zero var(--bl-notification-animation-duration) ease var(--bl-notification-animation-duration) forwards}.notification[data-slide=top].removing{animation:slide-out-top var(--bl-notification-animation-duration) ease forwards,size-to-zero var(--bl-notification-animation-duration) ease var(--bl-notification-animation-duration) forwards}:host([no-animation]) .notification.removing{animation:0 size-to-zero}@media (prefers-reduced-motion){.notification.removing{animation:0 size-to-zero}.notification{animation:none}}@keyframes slide-in-right{from{transform:translateX(var(--travel-distance,10px));height:0;opacity:0;margin:0}}@keyframes slide-in-left{from{transform:translateX(var(--travel-distance,-10px));height:0;opacity:0;margin:0}}@keyframes slide-out-right{to{transform:translateX(var(--travel-distance,10px));opacity:0}}@keyframes slide-in-top{from{transform:translateY(var(--travel-distance,-10px));height:0;opacity:0;margin:0}}@keyframes slide-out-top{to{transform:translateY(var(--travel-distance,-10px));opacity:0}}@keyframes size-to-zero{to{height:0;margin:0}}`;\nexport default styles;\n", "import { CSSResultGroup, html, LitElement, TemplateResult } from \"lit\";\nimport { customElement, eventOptions, property, state } from \"lit/decorators.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport BlAlert from \"../alert/bl-alert\";\nimport { BaklavaIcon } from \"../icon/icon-list\";\nimport style from \"./bl-notification.css\";\nimport BlNotificationCard, { CloseSource, NotificationVariant } from \"./card/bl-notification-card\";\n\ntype Action = {\n label: string;\n onClick: (notification: Notification) => void;\n};\n\nexport type NotificationProps = {\n caption?: string;\n description: string;\n icon?: boolean | BaklavaIcon;\n variant?: NotificationVariant;\n primaryAction?: Action;\n secondaryAction?: Action;\n duration?: number;\n permanent?: boolean;\n};\n\nexport type Notification = NotificationProps & {\n id: string;\n remove: () => Promise<boolean>;\n};\n\nexport const SWIPE_UP_THRESHOLD = -50;\n\n/**\n * @tag bl-notification\n * @summary Baklava Notification component\n */\n\n@customElement(\"bl-notification\")\nexport default class BlNotification extends LitElement {\n static get styles(): CSSResultGroup {\n return [style];\n }\n\n /**\n * Disable animations.\n * It will not be possible to use animations if the user has disabled them.\n * Animations will respect the user's preferences regardless of this property.\n */\n @property({ type: Boolean, attribute: \"no-animation\", reflect: true })\n noAnimation = false;\n\n /**\n * Sets the default duration of notifications in seconds\n */\n @property({ type: Number })\n duration = 7;\n\n @state()\n private notifications: Notification[] = [];\n\n public get notificationList() {\n return this.notifications;\n }\n\n private touchStartY = 0;\n\n public get touchStart() {\n return {\n y: this.touchStartY,\n };\n }\n\n private get isMobile() {\n return window.matchMedia(\"(max-width: 480px)\").matches;\n }\n\n /**\n * Adds a notification to the list of notifications.\n * @param {NotificationProps} props Notification properties\n * @returns {Notification} A notification object with a remove method.\n */\n public addNotification(props: NotificationProps) {\n // TODO id generation\n const id = Math.random().toString(36).substr(2, 9);\n const notification: Notification = {\n ...props,\n id,\n duration: props.duration || this.duration,\n remove: () => this.removeNotification(id),\n };\n\n const newNotifications = [...this.notifications, notification];\n\n this.notifications = newNotifications;\n\n return notification;\n }\n\n /**\n * Removes a notification from the list of notifications.\n * @param {string} id Notification id\n * @returns {Promise<boolean>} A promise that resolves with a boolean indicating whether the notification was removed.\n */\n public async removeNotification(id: string): Promise<boolean> {\n return new Promise(resolve => {\n const notificationEl = this.shadowRoot?.getElementById(id) as BlAlert;\n\n if (!notificationEl) {\n resolve(false);\n return;\n }\n\n notificationEl.style.height = `${notificationEl.clientHeight}px`;\n notificationEl.addEventListener(\"animationend\", ({ animationName }: AnimationEvent) => {\n if (animationName !== \"size-to-zero\") {\n return;\n }\n\n this.notifications = this.notifications.filter(notification => notification.id !== id);\n resolve(true);\n });\n\n notificationEl.classList.add(\"removing\");\n });\n }\n\n @eventOptions({ passive: true })\n private handleTouchStart(event: TouchEvent) {\n if (!this.isMobile) {\n return;\n }\n\n event.stopPropagation();\n\n this.touchStartY = event.touches[0].clientY;\n }\n\n @eventOptions({ passive: true })\n private handleTouchMove(event: TouchEvent) {\n if (!this.isMobile) {\n return;\n }\n event.stopPropagation();\n\n const currentTarget = event.currentTarget as BlNotificationCard;\n\n const currentY = event.touches[0].clientY;\n // Allow only moving up\n const movedY = Math.min(currentY - this.touchStartY, 0);\n\n currentTarget.style.transform = `translateY(${movedY}px)`;\n }\n\n @eventOptions({ passive: true })\n private handleTouchEnd(event: TouchEvent) {\n if (!this.isMobile) {\n return;\n }\n event.stopPropagation();\n\n const currentTarget = event.currentTarget as BlNotificationCard;\n\n const currentY = event.changedTouches[0].clientY;\n const movedY = currentY - this.touchStartY;\n\n if (movedY < SWIPE_UP_THRESHOLD) {\n currentTarget.style.setProperty(\"--travel-distance\", `${movedY - 10}px`);\n this.removeNotification(currentTarget.id);\n } else {\n currentTarget.style.transition = \"transform 0.3s ease\";\n currentTarget.style.transform = \"translateY(0px)\";\n\n currentTarget.addEventListener(\"transitionend\", () => {\n currentTarget.style.transition = \"\";\n currentTarget.style.transform = \"\";\n });\n }\n\n this.touchStartY = 0;\n }\n\n private renderActionSlot(\n slotName: \"primary-action\" | \"secondary-action\",\n notification: Notification\n ) {\n const action =\n slotName === \"primary-action\" ? notification.primaryAction : notification.secondaryAction;\n\n if (!action || !action.label) {\n return \"\";\n }\n\n return html`<bl-button slot=\"${slotName}\" @bl-click=${() => action.onClick(notification)}>\n ${action.label}\n </bl-button>`;\n }\n\n render(): TemplateResult {\n return html`\n <div class=\"wrapper\">\n ${repeat(\n this.notifications,\n notification => notification.id,\n notification => {\n const {\n caption,\n description,\n icon = true,\n variant = \"info\",\n id,\n duration = this.duration,\n permanent,\n } = notification;\n\n const actionButton = this.renderActionSlot(\"primary-action\", notification);\n const secondaryActionButton = this.renderActionSlot(\"secondary-action\", notification);\n\n return html`\n <bl-notification-card\n id=\"${id}\"\n class=\"notification\"\n data-slide=${this.isMobile ? \"top\" : \"right\"}\n duration=${duration}\n caption=\"${ifDefined(caption)}\"\n icon=${icon}\n variant=${ifDefined(variant)}\n ?permanent=${permanent}\n @bl-notification-card-request-close=${(\n event: CustomEvent<{ source: CloseSource }>\n ) => {\n // We will run animations on the notification card\n // so we need to prevent the default close behavior\n event.preventDefault();\n this.removeNotification(id);\n }}\n @touchstart=${this.handleTouchStart}\n @touchmove=${this.handleTouchMove}\n @touchend=${this.handleTouchEnd}\n >\n ${description} ${actionButton} ${secondaryActionButton}\n </bl-notification-card>\n `;\n }\n )}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bl-notification\": BlNotification;\n }\n}\n"],
|
|
5
|
+
"mappings": "oUAsBA,IAAMA,EAAc,CAACC,EAAiBC,EAAeC,IAAAA,CACnD,IAAMC,EAAM,IAAIC,IAChB,QAASC,EAAIJ,EAAOI,GAA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AgBA4B,EAAA,CADPC,EAAa,CAAE,QAAS,EAAK,CAAC,GAnHZ7B,EAoHX,8BApHWA,EAArB4B,EAAA,CADCC,EAAc,iBAAiB,GACX7B",
|
|
6
6
|
"names": ["generateMap", "list", "start", "end", "map", "Map", "i", "set", "repeat", "directive", "Directive", "constructor", "partInfo", "super", "type", "PartType", "CHILD", "Error", "_getValuesAndKeys", "items", "keyFnOrTemplate", "template", "keyFn", "keys", "values", "index", "item", "render", "this", "update", "containerPart", "oldParts", "getCommittedValue", "newValues", "newKeys", "Array", "isArray", "_itemKeys", "oldKeys", "_a", "newParts", "newKeyToIndexMap", "oldKeyToIndexMap", "oldHead", "oldTail", "length", "newHead", "newTail", "setChildPartValue", "insertPart", "has", "oldIndex", "get", "oldPart", "newPart", "removePart", "setCommittedValue", "noChange", "styles", "i", "bl_notification_default", "SWIPE_UP_THRESHOLD", "BlNotification", "s", "bl_notification_default", "props", "id", "notification", "newNotifications", "resolve", "_a", "notificationEl", "animationName", "event", "currentTarget", "currentY", "movedY", "slotName", "action", "x", "c", "caption", "description", "icon", "variant", "duration", "permanent", "actionButton", "secondaryActionButton", "l", "__decorateClass", "e", "t"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import{b as k}from"./chunk-23PSWIUF.js";import{c as $}from"./chunk-EG7U7PM3.js";import{a as z}from"./chunk-XDUIVR6I.js";import{a as w}from"./chunk-6LT7O7T2.js";import{a as s}from"./chunk-DINNT5P2.js";import{a as c}from"./chunk-GRL4DWKG.js";import{a as f,b as y,c as x}from"./chunk-7GK5LKBV.js";import{a as b,b as a,c as u,e as m}from"./chunk-5MOOXA2X.js";import{a as v,b as d,c as g,f as p}from"./chunk-4OT5AMS5.js";import{d as r}from"./chunk-IZ2LK5GK.js";var C="important",I=" !"+C,S=y(class extends x{constructor(o){var l;if(super(o),o.type!==f.ATTRIBUTE||o.name!=="style"||((l=o.strings)===null||l===void 0?void 0:l.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(o){return Object.keys(o).reduce((l,e)=>{let i=o[e];return i==null?l:l+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(o,[l]){let{style:e}=o.element;if(this.ht===void 0){this.ht=new Set;for(let i in l)this.ht.add(i);return this.render(l)}this.ht.forEach(i=>{l[i]==null&&(this.ht.delete(i),i.includes("-")?e.removeProperty(i):e[i]="")});for(let i in l){let n=l[i];if(n!=null){this.ht.add(i);let h=typeof n=="string"&&n.endsWith(I);i.includes("-")||h?e.setProperty(i,h?n.slice(0,-11):n,h?C:""):e[i]=n}}return g}});var L=v`:host{display:inline-block;width:200px;position:relative}.wrapper{--row-count:1;--maxrow-count: ;--line-height:var(--bl-font-title-3-line-height);--scroll-height:var(--line-height);--padding-vertical:var(--bl-size-2xs);--padding-horizontal:var(--bl-size-xs);--label-padding:var(--bl-size-3xs);--border-size:1px;--default-scroll-height:calc((var(--row-count) * var(--line-height)) + var(--padding-vertical));--height:max(var(--scroll-height), var(--default-scroll-height));--input-font:var(--bl-font-body-text-2);--border-radius:var(--bl-size-3xs);--border-color:var(--bl-color-neutral-lighter);--background-color:var(--bl-color-neutral-full);display:flex;flex-direction:column;position:relative;gap:var(--bl-size-3xs)}.input-wrapper{border:solid var(--border-size) var(--border-color);border-radius:var(--border-radius);padding:0 calc(var(--padding-horizontal) - var(--label-padding) - var(--border-size));padding-top:var(--padding-vertical);display:flex;box-sizing:border-box;background-color:var(--background-color);margin:0;width:0;min-width:100%}textarea{--parent-padding:calc(var(--padding-horizontal) - var(--label-padding) - var(--border-size));width:100%;align-self:stretch;outline:0;font:var(--input-font);padding:0 calc(var(--padding-horizontal) - var(--border-size));padding-bottom:var(--padding-vertical);margin:0 calc(-1 * var(--parent-padding));border:none;border-radius:var(--border-radius);color:var(--bl-color-neutral-darker);resize:vertical;background-color:transparent;display:block}:host([size=large]) .wrapper{--padding-vertical:var(--bl-size-xs);--padding-horizontal:var(--bl-size-m)}:host([size=small]) .wrapper{--padding-vertical:var(--bl-size-3xs);--padding-horizontal:var(--bl-size-xs);--input-font:var(--bl-font-body-text-3);--line-height:var(--bl-font-title-4-line-height)}textarea:disabled{background-color:var(--bl-color-neutral-lightest);color:var(--bl-color-neutral-light);cursor:not-allowed}:host([disabled]) .wrapper{--background-color:var(--bl-color-neutral-lightest)}:host([expand]) textarea{overflow:hidden;resize:none;height:var(--height)}:host([expand][max-rows]) textarea{--maxrow-height:calc((var(--maxrow-count) * var(--line-height)) + var(--padding-vertical));overflow-y:scroll;height:min(var(--height),var(--maxrow-height))}.wrapper:focus-within{--border-color:var(--bl-color-primary)}.dirty.invalid,.dirty.max-len-invalid{--border-color:var(--bl-color-danger)}:host([label]) ::placeholder{color:transparent;transition:color .4s ease-out}.input-wrapper legend,label{padding:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}label{max-width:max-content;position:absolute;transition:.1s ease-in;font:var(--bl-font-title-3-regular);top:var(--padding-vertical);inset-inline-start:var(--padding-horizontal);inset-inline-end:var(--padding-horizontal);pointer-events:none;color:var(--bl-color-neutral-light)}.input-wrapper legend{height:0;visibility:hidden;display:none}.input-wrapper legend span{padding:0 var(--label-padding);display:inline-block;opacity:0;visibility:visible}:where(.wrapper:focus-within,.wrapper.has-value) label{top:0;inset-inline-start:var(--padding-horizontal);transform:translateY(-50%);font:var(--bl-font-caption);color:var(--bl-color-neutral-dark);pointer-events:initial;z-index:var(--bl-index-base)}:host([label]) :where(.wrapper:focus-within,.wrapper.has-value) legend{max-width:100%;font:var(--bl-font-caption);display:block}:host ::placeholder,:host([label-fixed]) ::placeholder{color:var(--bl-color-neutral-light)}:host([label-fixed]) label{position:static;transition:none;transform:none;pointer-events:initial;font:var(--bl-font-caption);color:var(--bl-color-neutral-dark);background-color:initial;padding:0}:host([label-fixed]) legend{display:none}.hint{display:none;font:var(--bl-font-body-text-3)}.dirty.invalid .hint,:host([character-counter]) .hint,:host([help-text]) .hint{display:flex;gap:var(--bl-size-3xs)}.hint>*{margin:0;padding:0}.help-text,.invalid-text{flex:1}.counter-text{color:var(--bl-color-neutral-dark);margin-inline-start:auto}:where(.max-len-invalid,.dirty.invalid) .hint>.counter-text{color:var(--bl-color-danger)}.dirty.invalid label{color:var(--bl-color-danger)}.invalid-text{display:none;color:var(--bl-color-danger)}.help-text{color:var(--bl-color-neutral-dark)}:where(.dirty.max-len-invalid,.dirty.invalid) .hint>.invalid-text{display:inline-block}.dirty.invalid .hint>.help-text{display:none}`,E=L;var t=class extends z(p){constructor(){super(...arguments);this.name="";this.required=!1;this.disabled=!1;this.expand=!1;this.size="medium";this.labelFixed=!1;this.characterCounter=!1;this.value="";this.rows=4;this.autofocus=!1;this.spellchecker="false";this.customScrollHeight=null;this.inputId=Math.random().toString(36).substring(2);this.onError=()=>{this.onInvalid(this.internals.validity)};this.dirty=!1}static get styles(){return[E]}connectedCallback(){var e;super.connectedCallback(),(e=this.internals.form)==null||e.addEventListener("submit",()=>{this.reportValidity()})}inputHandler(e){this.autoResize();let i=e.target.value;this.value=i,this.setValue(this.value),this.onInput(i)}changeHandler(e){let i=e.target.value;this.dirty=!0,this.value=i,this.setValue(this.value),this.onChange(i)}firstUpdated(){this.setValue(this.value),this.autoResize()}async updated(e){e.has("rows")&&this.autoResize(),e.has("value")&&(this.setValue(this.value),await this.validationComplete,this.requestUpdate()),e.has("error")&&this.error&&!this.dirty&&this.reportValidity()}setCustomValidity(e){this.validationTarget.setCustomValidity(e)}reportValidity(){return this.dirty=!0,this.checkValidity()}valueChangedCallback(e){this.value=e}validityCallback(){var e;return this.customInvalidText||((e=this.validationTarget)==null?void 0:e.validationMessage)}autoResize(){if(!this.expand)return;this.validationTarget.style.height="auto";let e=this.validationTarget.scrollHeight;this.customScrollHeight=`${e}px`,this.validationTarget.style.removeProperty("height")}render(){let e=this.internals.validity.tooLong,i=this.checkValidity()?"":d`<p class="invalid-text">${this.validationMessage}</p>`,n=this.helpText?d`<p class="help-text">${this.helpText}</p>`:"",h=this.label?d`<label for="${this.inputId}">${this.label}</label>`:"",V=this.characterCounter&&this.maxlength?`${this.value.length}/${this.maxlength}`:this.characterCounter?`${this.value.length}`:"",M=this.characterCounter?d`<p class="counter-text">${V}</p>`:"",R={wrapper:!0,"has-value":this.value!==null&&this.value!=="",dirty:this.dirty,"max-len-invalid":e,invalid:!this.checkValidity()},H={"--row-count":`${this.rows}`,"--maxrow-count":this.maxRows?`${this.maxRows}`:null,"--scroll-height":this.customScrollHeight};return d`
|
|
2
|
+
<div style=${S(H)} class=${w(R)}>
|
|
3
|
+
${h}
|
|
4
|
+
<fieldset class="input-wrapper">
|
|
5
|
+
<legend><span>${this.label}</span></legend>
|
|
6
|
+
<textarea
|
|
7
|
+
id="${this.inputId}"
|
|
8
|
+
name="${s(this.name)}"
|
|
9
|
+
.value=${$(this.value)}
|
|
10
|
+
?autofocus=${this.autofocus}
|
|
11
|
+
autocomplete="${s(this.autocomplete)}"
|
|
12
|
+
inputmode="${s(this.inputmode)}"
|
|
13
|
+
placeholder="${s(this.placeholder)}"
|
|
14
|
+
minlength="${s(this.minlength)}"
|
|
15
|
+
rows="${s(this.rows)}"
|
|
16
|
+
?required=${this.required}
|
|
17
|
+
?disabled=${this.disabled}
|
|
18
|
+
spellcheck="${this.spellchecker}"
|
|
19
|
+
@change=${this.changeHandler}
|
|
20
|
+
@input=${this.inputHandler}
|
|
21
|
+
@invalid=${this.onError}
|
|
22
|
+
>
|
|
23
|
+
</textarea>
|
|
24
|
+
</fieldset>
|
|
25
|
+
<div class="hint">${i}${n}${M}</div>
|
|
26
|
+
</div>
|
|
27
|
+
`}};t.shadowRootOptions={...p.shadowRootOptions,delegatesFocus:!0},t.formControlValidators=k,r([m("textarea")],t.prototype,"validationTarget",2),r([a({reflect:!0,type:String})],t.prototype,"error",2),r([a({type:String,reflect:!0})],t.prototype,"name",2),r([a({type:Boolean,reflect:!0})],t.prototype,"required",2),r([a({type:Boolean,reflect:!0})],t.prototype,"disabled",2),r([a({type:Boolean,reflect:!0})],t.prototype,"expand",2),r([a({type:Number,reflect:!0,attribute:"max-rows"})],t.prototype,"maxRows",2),r([a({type:String,reflect:!0})],t.prototype,"size",2),r([a({reflect:!0})],t.prototype,"label",2),r([a({type:Boolean,attribute:"label-fixed",reflect:!0})],t.prototype,"labelFixed",2),r([a({reflect:!0})],t.prototype,"placeholder",2),r([a({type:Boolean,attribute:"character-counter",reflect:!0})],t.prototype,"characterCounter",2),r([a({type:String,attribute:"help-text",reflect:!0})],t.prototype,"helpText",2),r([a({type:String,attribute:"invalid-text",reflect:!0})],t.prototype,"customInvalidText",2),r([a({type:Number,reflect:!0})],t.prototype,"minlength",2),r([a({type:Number,reflect:!0})],t.prototype,"maxlength",2),r([a({reflect:!0})],t.prototype,"value",2),r([a({type:Number,reflect:!0})],t.prototype,"rows",2),r([a({type:String,reflect:!0})],t.prototype,"inputmode",2),r([a({type:Boolean,reflect:!0})],t.prototype,"autofocus",2),r([a({type:String,reflect:!0})],t.prototype,"autocomplete",2),r([a({type:String,reflect:!0,attribute:"spellcheck"})],t.prototype,"spellchecker",2),r([c("bl-input")],t.prototype,"onInput",2),r([c("bl-change")],t.prototype,"onChange",2),r([c("bl-invalid")],t.prototype,"onInvalid",2),r([u()],t.prototype,"customScrollHeight",2),r([u()],t.prototype,"dirty",2),t=r([b("bl-textarea")],t);export{t as a};
|
|
28
|
+
/*! Bundled license information:
|
|
29
|
+
|
|
30
|
+
lit-html/directives/style-map.js:
|
|
31
|
+
(**
|
|
32
|
+
* @license
|
|
33
|
+
* Copyright 2018 Google LLC
|
|
34
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
35
|
+
*)
|
|
36
|
+
*/
|
|
37
|
+
//# sourceMappingURL=chunk-STZJ3LBU.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../node_modules/lit-html/src/directives/style-map.ts", "../src/components/textarea/bl-textarea.css", "../src/components/textarea/bl-textarea.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {AttributePart, noChange} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n PartInfo,\n PartType,\n} from '../directive.js';\n\n/**\n * A key-value set of CSS properties and values.\n *\n * The key should be either a valid CSS property name string, like\n * `'background-color'`, or a valid JavaScript camel case property name\n * for CSSStyleDeclaration like `backgroundColor`.\n */\nexport interface StyleInfo {\n [name: string]: string | number | undefined | null;\n}\n\nconst important = 'important';\n// The leading space is important\nconst importantFlag = ' !' + important;\n// How many characters to remove from a value, as a negative number\nconst flagTrim = 0 - importantFlag.length;\n\nclass StyleMapDirective extends Directive {\n _previousStyleProperties?: Set<string>;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (\n partInfo.type !== PartType.ATTRIBUTE ||\n partInfo.name !== 'style' ||\n (partInfo.strings?.length as number) > 2\n ) {\n throw new Error(\n 'The `styleMap` directive must be used in the `style` attribute ' +\n 'and must be the only part in the attribute.'\n );\n }\n }\n\n render(styleInfo: Readonly<StyleInfo>) {\n return Object.keys(styleInfo).reduce((style, prop) => {\n const value = styleInfo[prop];\n if (value == null) {\n return style;\n }\n // Convert property names from camel-case to dash-case, i.e.:\n // `backgroundColor` -> `background-color`\n // Vendor-prefixed names need an extra `-` appended to front:\n // `webkitAppearance` -> `-webkit-appearance`\n // Exception is any property name containing a dash, including\n // custom properties; we assume these are already dash-cased i.e.:\n // `--my-button-color` --> `--my-button-color`\n prop = prop.includes('-')\n ? prop\n : prop\n .replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, '-$&')\n .toLowerCase();\n return style + `${prop}:${value};`;\n }, '');\n }\n\n override update(part: AttributePart, [styleInfo]: DirectiveParameters<this>) {\n const {style} = part.element as HTMLElement;\n\n if (this._previousStyleProperties === undefined) {\n this._previousStyleProperties = new Set();\n for (const name in styleInfo) {\n this._previousStyleProperties.add(name);\n }\n return this.render(styleInfo);\n }\n\n // Remove old properties that no longer exist in styleInfo\n // We use forEach() instead of for-of so that re don't require down-level\n // iteration.\n this._previousStyleProperties!.forEach((name) => {\n // If the name isn't in styleInfo or it's null/undefined\n if (styleInfo[name] == null) {\n this._previousStyleProperties!.delete(name);\n if (name.includes('-')) {\n style.removeProperty(name);\n } else {\n // Note reset using empty string (vs null) as IE11 does not always\n // reset via null (https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style#setting_styles)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (style as any)[name] = '';\n }\n }\n });\n\n // Add or update properties\n for (const name in styleInfo) {\n const value = styleInfo[name];\n if (value != null) {\n this._previousStyleProperties.add(name);\n const isImportant =\n typeof value === 'string' && value.endsWith(importantFlag);\n if (name.includes('-') || isImportant) {\n style.setProperty(\n name,\n isImportant\n ? (value as string).slice(0, flagTrim)\n : (value as string),\n isImportant ? important : ''\n );\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (style as any)[name] = value;\n }\n }\n }\n return noChange;\n }\n}\n\n/**\n * A directive that applies CSS properties to an element.\n *\n * `styleMap` can only be used in the `style` attribute and must be the only\n * expression in the attribute. It takes the property names in the\n * {@link StyleInfo styleInfo} object and adds the properties to the inline\n * style of the element.\n *\n * Property names with dashes (`-`) are assumed to be valid CSS\n * property names and set on the element's style object using `setProperty()`.\n * Names without dashes are assumed to be camelCased JavaScript property names\n * and set on the element's style object using property assignment, allowing the\n * style object to translate JavaScript-style names to CSS property names.\n *\n * For example `styleMap({backgroundColor: 'red', 'border-top': '5px', '--size':\n * '0'})` sets the `background-color`, `border-top` and `--size` properties.\n *\n * @param styleInfo\n * @see {@link https://lit.dev/docs/templates/directives/#stylemap styleMap code samples on Lit.dev}\n */\nexport const styleMap = directive(StyleMapDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {StyleMapDirective};\n", "import {css} from 'lit';\nexport const styles = css`:host{display:inline-block;width:200px;position:relative}.wrapper{--row-count:1;--maxrow-count: ;--line-height:var(--bl-font-title-3-line-height);--scroll-height:var(--line-height);--padding-vertical:var(--bl-size-2xs);--padding-horizontal:var(--bl-size-xs);--label-padding:var(--bl-size-3xs);--border-size:1px;--default-scroll-height:calc((var(--row-count) * var(--line-height)) + var(--padding-vertical));--height:max(var(--scroll-height), var(--default-scroll-height));--input-font:var(--bl-font-body-text-2);--border-radius:var(--bl-size-3xs);--border-color:var(--bl-color-neutral-lighter);--background-color:var(--bl-color-neutral-full);display:flex;flex-direction:column;position:relative;gap:var(--bl-size-3xs)}.input-wrapper{border:solid var(--border-size) var(--border-color);border-radius:var(--border-radius);padding:0 calc(var(--padding-horizontal) - var(--label-padding) - var(--border-size));padding-top:var(--padding-vertical);display:flex;box-sizing:border-box;background-color:var(--background-color);margin:0;width:0;min-width:100%}textarea{--parent-padding:calc(var(--padding-horizontal) - var(--label-padding) - var(--border-size));width:100%;align-self:stretch;outline:none;font:var(--input-font);padding:0 calc(var(--padding-horizontal) - var(--border-size));padding-bottom:var(--padding-vertical);margin:0 calc(-1 * var(--parent-padding));border:none;border-radius:var(--border-radius);color:var(--bl-color-neutral-darker);resize:vertical;background-color:transparent;display:block}:host([size=\"large\"]) .wrapper{--padding-vertical:var(--bl-size-xs);--padding-horizontal:var(--bl-size-m)}:host([size=\"small\"]) .wrapper{--padding-vertical:var(--bl-size-3xs);--padding-horizontal:var(--bl-size-xs);--input-font:var(--bl-font-body-text-3);--line-height:var(--bl-font-title-4-line-height)}textarea:disabled{background-color:var(--bl-color-neutral-lightest);color:var(--bl-color-neutral-light);cursor:not-allowed}:host([disabled]) .wrapper{--background-color:var(--bl-color-neutral-lightest)}:host([expand]) textarea{overflow:hidden;resize:none;height:var(--height)}:host([expand][max-rows]) textarea{--maxrow-height:calc((var(--maxrow-count) * var(--line-height)) + var(--padding-vertical));overflow-y:scroll;height:min(var(--height), var(--maxrow-height))}.wrapper:focus-within{--border-color:var(--bl-color-primary)}.dirty.max-len-invalid,.dirty.invalid{--border-color:var(--bl-color-danger)}:host([label]) ::placeholder{color:transparent;transition:color ease-out 0.4s}.input-wrapper legend,label{padding:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}label{max-width:max-content;position:absolute;transition:all ease-in 0.1s;font:var(--bl-font-title-3-regular);top:var(--padding-vertical);inset-inline-start:var(--padding-horizontal);inset-inline-end:var(--padding-horizontal);pointer-events:none;color:var(--bl-color-neutral-light)}.input-wrapper legend{height:0;visibility:hidden;display:none}.input-wrapper legend span{padding:0 var(--label-padding);display:inline-block;opacity:0;visibility:visible}:where(.wrapper:focus-within, .wrapper.has-value) label{top:0;inset-inline-start:var(--padding-horizontal);transform:translateY(-50%);font:var(--bl-font-caption);color:var(--bl-color-neutral-dark);pointer-events:initial;z-index:var(--bl-index-base)}:host([label]) :where(.wrapper:focus-within, .wrapper.has-value) legend{max-width:100%;font:var(--bl-font-caption);display:block}:host ::placeholder,:host([label-fixed]) ::placeholder{color:var(--bl-color-neutral-light)}:host([label-fixed]) label{position:static;transition:none;transform:none;pointer-events:initial;font:var(--bl-font-caption);color:var(--bl-color-neutral-dark);background-color:initial;padding:0}:host([label-fixed]) legend{display:none}.hint{display:none;font:var(--bl-font-body-text-3)}:host([character-counter]) .hint,:host([help-text]) .hint,.dirty.invalid .hint{display:flex;gap:var(--bl-size-3xs)}.hint > *{margin:0;padding:0}.help-text,.invalid-text{flex:1}.counter-text{color:var(--bl-color-neutral-dark);margin-inline-start:auto}:where(.max-len-invalid, .dirty.invalid) .hint > .counter-text{color:var(--bl-color-danger)}.dirty.invalid label{color:var(--bl-color-danger)}.invalid-text{display:none;color:var(--bl-color-danger)}.help-text{color:var(--bl-color-neutral-dark)}:where(.dirty.max-len-invalid, .dirty.invalid) .hint > .invalid-text{display:inline-block}.dirty.invalid .hint > .help-text{display:none}`;\nexport default styles;\n", "import { CSSResultGroup, html, LitElement, PropertyValues, TemplateResult } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { live } from \"lit/directives/live.js\";\nimport { styleMap } from \"lit/directives/style-map.js\";\nimport { FormControlMixin } from \"@open-wc/form-control\";\nimport \"element-internals-polyfill\";\nimport { event, EventDispatcher } from \"../../utilities/event\";\nimport { textAreaValidators } from \"../../utilities/form-control\";\nimport style from \"./bl-textarea.css\";\n\nexport type TextareaSize = \"small\" | \"medium\" | \"large\";\n/**\n * @tag bl-textarea\n * @summary Baklava Textarea component\n */\n@customElement(\"bl-textarea\")\nexport default class BlTextarea extends FormControlMixin(LitElement) {\n static get styles(): CSSResultGroup {\n return [style];\n }\n static shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n static formControlValidators = textAreaValidators;\n\n @query(\"textarea\")\n validationTarget: HTMLTextAreaElement;\n\n @property({ reflect: true, type: String })\n error: string;\n\n /**\n * Name of textarea\n */\n @property({ type: String, reflect: true })\n name = \"\";\n\n /**\n * Makes textarea a mandatory field\n */\n @property({ type: Boolean, reflect: true })\n required = false;\n\n /**\n * Disables the textarea\n */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /**\n * Sets expandity\n */\n @property({ type: Boolean, reflect: true })\n expand = false;\n\n /**\n * Sets max row when expand is true\n */\n @property({ type: Number, reflect: true, attribute: \"max-rows\" })\n maxRows?: number;\n\n /**\n * Sets textarea size.\n */\n @property({ type: String, reflect: true })\n size?: TextareaSize = \"medium\";\n\n /**\n * Sets label of the textarea\n */\n @property({ reflect: true })\n label?: string;\n\n /**\n * Makes label as fixed positioned\n */\n @property({ type: Boolean, attribute: \"label-fixed\", reflect: true })\n labelFixed = false;\n\n /**\n * Sets placeholder of the textarea\n */\n @property({ reflect: true })\n placeholder?: string;\n\n /**\n * Enables showing character counter.\n */\n @property({ type: Boolean, attribute: \"character-counter\", reflect: true })\n characterCounter = false;\n\n /**\n * Adds help text\n */\n @property({ type: String, attribute: \"help-text\", reflect: true })\n helpText?: string;\n\n /**\n * Set custom error message\n */\n @property({ type: String, attribute: \"invalid-text\", reflect: true })\n customInvalidText?: string;\n\n /**\n * Sets minimum length of the textarea\n */\n @property({ type: Number, reflect: true })\n minlength?: number;\n\n /**\n * Sets max length of textarea\n */\n @property({ type: Number, reflect: true })\n maxlength?: number;\n\n /**\n * Sets initial value of the textarea\n */\n @property({ reflect: true })\n value = \"\";\n\n /**\n * Sets textarea visible row count.\n */\n @property({ type: Number, reflect: true })\n rows?: number = 4;\n\n /**\n * Sets the input mode of the field for asking browser to show the desired keyboard.\n */\n @property({ type: String, reflect: true })\n inputmode: \"none\" | \"text\" | \"decimal\" | \"numeric\" | \"tel\" | \"search\" | \"email\" | \"url\";\n\n /**\n * Sets input to get keyboard focus automatically\n */\n @property({ type: Boolean, reflect: true })\n autofocus = false;\n\n /**\n * Hints browser to autocomplete this field.\n */\n @property({ type: String, reflect: true })\n autocomplete: string;\n\n /**\n * Enables/disables spellcheck feature inside the textarea\n */\n @property({ type: String, reflect: true, attribute: \"spellcheck\" })\n spellchecker: \"true\" | \"false\" = \"false\";\n\n @event(\"bl-input\") private onInput: EventDispatcher<string>;\n\n @event(\"bl-change\") private onChange: EventDispatcher<string>;\n\n @event(\"bl-invalid\") private onInvalid: EventDispatcher<ValidityState>;\n\n @state()\n private customScrollHeight: string | null = null;\n\n private inputId = Math.random().toString(36).substring(2);\n\n connectedCallback() {\n super.connectedCallback();\n this.internals.form?.addEventListener(\"submit\", () => {\n this.reportValidity();\n });\n }\n\n private onError = (): void => {\n this.onInvalid(this.internals.validity);\n };\n\n private inputHandler(event: Event) {\n this.autoResize();\n\n const value = (event.target as HTMLTextAreaElement).value;\n\n this.value = value;\n this.setValue(this.value);\n this.onInput(value);\n }\n\n private changeHandler(event: Event) {\n const value = (event.target as HTMLTextAreaElement).value;\n\n this.dirty = true;\n this.value = value;\n this.setValue(this.value);\n this.onChange(value);\n }\n\n firstUpdated() {\n this.setValue(this.value);\n this.autoResize();\n }\n\n protected async updated(changedProperties: PropertyValues) {\n if (changedProperties.has(\"rows\")) {\n this.autoResize();\n }\n\n if (changedProperties.has(\"value\")) {\n this.setValue(this.value);\n\n await this.validationComplete;\n\n this.requestUpdate();\n }\n\n if (changedProperties.has(\"error\") && this.error && !this.dirty) {\n this.reportValidity();\n }\n }\n\n /**\n * Sets a custom validity on the form element.\n * @param message\n */\n setCustomValidity(message: string) {\n this.validationTarget.setCustomValidity(message);\n }\n\n reportValidity() {\n this.dirty = true;\n return this.checkValidity();\n }\n\n valueChangedCallback(value: string): void {\n this.value = value;\n }\n\n validityCallback(): string | void {\n return this.customInvalidText || this.validationTarget?.validationMessage;\n }\n\n private autoResize() {\n if (!this.expand) {\n return;\n }\n\n this.validationTarget.style.height = \"auto\";\n const scrollHeight = this.validationTarget.scrollHeight;\n\n this.customScrollHeight = `${scrollHeight}px`;\n this.validationTarget.style.removeProperty(\"height\");\n }\n\n @state() private dirty = false;\n\n render(): TemplateResult {\n const maxLengthInvalid = this.internals.validity.tooLong;\n const invalidMessage = !this.checkValidity()\n ? html`<p class=\"invalid-text\">${this.validationMessage}</p>`\n : \"\";\n const helpMessage = this.helpText ? html`<p class=\"help-text\">${this.helpText}</p>` : \"\";\n\n const label = this.label ? html`<label for=\"${this.inputId}\">${this.label}</label>` : \"\";\n const characterCounterText =\n this.characterCounter && this.maxlength\n ? `${this.value.length}/${this.maxlength}`\n : this.characterCounter\n ? `${this.value.length}`\n : \"\";\n const characterCounter = this.characterCounter\n ? html`<p class=\"counter-text\">${characterCounterText}</p>`\n : \"\";\n\n const wrapperClasses = {\n \"wrapper\": true,\n \"has-value\": this.value !== null && this.value !== \"\",\n \"dirty\": this.dirty,\n \"max-len-invalid\": maxLengthInvalid,\n \"invalid\": !this.checkValidity(),\n };\n\n const styles = {\n \"--row-count\": `${this.rows}`,\n \"--maxrow-count\": this.maxRows ? `${this.maxRows}` : null,\n \"--scroll-height\": this.customScrollHeight,\n };\n\n return html`\n <div style=${styleMap(styles)} class=${classMap(wrapperClasses)}>\n ${label}\n <fieldset class=\"input-wrapper\">\n <legend><span>${this.label}</span></legend>\n <textarea\n id=\"${this.inputId}\"\n name=\"${ifDefined(this.name)}\"\n .value=${live(this.value)}\n ?autofocus=${this.autofocus}\n autocomplete=\"${ifDefined(this.autocomplete)}\"\n inputmode=\"${ifDefined(this.inputmode)}\"\n placeholder=\"${ifDefined(this.placeholder)}\"\n minlength=\"${ifDefined(this.minlength)}\"\n rows=\"${ifDefined(this.rows)}\"\n ?required=${this.required}\n ?disabled=${this.disabled}\n spellcheck=\"${this.spellchecker}\"\n @change=${this.changeHandler}\n @input=${this.inputHandler}\n @invalid=${this.onError}\n >\n </textarea>\n </fieldset>\n <div class=\"hint\">${invalidMessage}${helpMessage}${characterCounter}</div>\n </div>\n `;\n }\n}\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bl-textarea\": BlTextarea;\n }\n}\n"],
|
|
5
|
-
"mappings": "wcA0BA,IAAMA,EAAY,YAEZC,EAAgB,KAAOD,EAqHhBE,EAAWC,EAjHxB,cAAgCC,CAAAA,CAG9BC,YAAYC,EAAAA,CAAAA,IAAAA,EAEV,GADAC,MAAMD,CAAAA,EAEJA,EAASE,OAASC,EAASC,WAC3BJ,EAASK,OAAS,WACjBC,EAAAN,EAASO,WADDF,MACCE,IAAAA,OAAAA,OAAAA,EAASC,QAAoB,EAEvC,MAAUC,MACR,4GAAA,CAIL,CAEDC,OAAOC,EAAAA,CACL,OAAOC,OAAOC,KAAKF,CAAAA,EAAWG,OAAO,CAACC,EAAOC,IAAAA,CAC3C,IAAMC,EAAQN,EAAUK,CAAAA,EACxB,OAAIC,GAAS,KACJF,EAcFA,EAAQ,GALfC,EAAOA,EAAKE,SAAS,GAAA,EACjBF,EACAA,EACGG,QAAQ,oCAAqC,KAAA,EAC7CC,YAAAA,KACmBH,IAAQ,EACjC,EAAA,CACJ,CAEQI,OAAOC,EAAAA,CAAsBX,CAAAA,EAAAA,CACpC,GAAA,CAAMI,MAACA,CAAAA,EAASO,EAAKC,QAErB,GAAIC,KAAKC,KAAT,OAAiD,CAC/CD,KAAKC,GAA2B,IAAIC,IACpC,QAAWrB,KAAQM,EACjBa,KAAKC,GAAyBE,IAAItB,CAAAA,EAEpC,OAAOmB,KAAKd,OAAOC,CAAAA,EAMrBa,KAAKC,GAA0BG,QAASvB,GAAAA,CAElCM,EAAUN,CAAAA,GAAS,OACrBmB,KAAKC,GAA0BI,OAAOxB,CAAAA,EAClCA,EAAKa,SAAS,GAAA,EAChBH,EAAMe,eAAezB,CAAAA,EAKpBU,EAAcV,CAAAA,EAAQ,GAE1B,CAAA,EAIH,QAAWA,KAAQM,EAAW,CAC5B,IAAMM,EAAQN,EAAUN,CAAAA,EACxB,GAAIY,GAAS,KAAM,CACjBO,KAAKC,GAAyBE,IAAItB,CAAAA,EAClC,IAAM0B,EACa,OAAVd,GAAU,UAAYA,EAAMe,SAASrC,CAAAA,EAC1CU,EAAKa,SAAS,GAAA,GAAQa,EACxBhB,EAAMkB,YACJ5B,EACA0B,EACKd,EAAiBiB,MAAM,EAAA,GAjFvB,EAkFAjB,EACLc,EAAcrC,EAAY,EAAA,EAI3BqB,EAAcV,CAAAA,EAAQY,GAI7B,OAAOkB,CACR,CAAA,CAAA,ECzHI,IAAMC,EAASC,
|
|
4
|
+
"sourcesContent": ["/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {AttributePart, noChange} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n PartInfo,\n PartType,\n} from '../directive.js';\n\n/**\n * A key-value set of CSS properties and values.\n *\n * The key should be either a valid CSS property name string, like\n * `'background-color'`, or a valid JavaScript camel case property name\n * for CSSStyleDeclaration like `backgroundColor`.\n */\nexport interface StyleInfo {\n [name: string]: string | number | undefined | null;\n}\n\nconst important = 'important';\n// The leading space is important\nconst importantFlag = ' !' + important;\n// How many characters to remove from a value, as a negative number\nconst flagTrim = 0 - importantFlag.length;\n\nclass StyleMapDirective extends Directive {\n _previousStyleProperties?: Set<string>;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (\n partInfo.type !== PartType.ATTRIBUTE ||\n partInfo.name !== 'style' ||\n (partInfo.strings?.length as number) > 2\n ) {\n throw new Error(\n 'The `styleMap` directive must be used in the `style` attribute ' +\n 'and must be the only part in the attribute.'\n );\n }\n }\n\n render(styleInfo: Readonly<StyleInfo>) {\n return Object.keys(styleInfo).reduce((style, prop) => {\n const value = styleInfo[prop];\n if (value == null) {\n return style;\n }\n // Convert property names from camel-case to dash-case, i.e.:\n // `backgroundColor` -> `background-color`\n // Vendor-prefixed names need an extra `-` appended to front:\n // `webkitAppearance` -> `-webkit-appearance`\n // Exception is any property name containing a dash, including\n // custom properties; we assume these are already dash-cased i.e.:\n // `--my-button-color` --> `--my-button-color`\n prop = prop.includes('-')\n ? prop\n : prop\n .replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, '-$&')\n .toLowerCase();\n return style + `${prop}:${value};`;\n }, '');\n }\n\n override update(part: AttributePart, [styleInfo]: DirectiveParameters<this>) {\n const {style} = part.element as HTMLElement;\n\n if (this._previousStyleProperties === undefined) {\n this._previousStyleProperties = new Set();\n for (const name in styleInfo) {\n this._previousStyleProperties.add(name);\n }\n return this.render(styleInfo);\n }\n\n // Remove old properties that no longer exist in styleInfo\n // We use forEach() instead of for-of so that re don't require down-level\n // iteration.\n this._previousStyleProperties!.forEach((name) => {\n // If the name isn't in styleInfo or it's null/undefined\n if (styleInfo[name] == null) {\n this._previousStyleProperties!.delete(name);\n if (name.includes('-')) {\n style.removeProperty(name);\n } else {\n // Note reset using empty string (vs null) as IE11 does not always\n // reset via null (https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style#setting_styles)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (style as any)[name] = '';\n }\n }\n });\n\n // Add or update properties\n for (const name in styleInfo) {\n const value = styleInfo[name];\n if (value != null) {\n this._previousStyleProperties.add(name);\n const isImportant =\n typeof value === 'string' && value.endsWith(importantFlag);\n if (name.includes('-') || isImportant) {\n style.setProperty(\n name,\n isImportant\n ? (value as string).slice(0, flagTrim)\n : (value as string),\n isImportant ? important : ''\n );\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (style as any)[name] = value;\n }\n }\n }\n return noChange;\n }\n}\n\n/**\n * A directive that applies CSS properties to an element.\n *\n * `styleMap` can only be used in the `style` attribute and must be the only\n * expression in the attribute. It takes the property names in the\n * {@link StyleInfo styleInfo} object and adds the properties to the inline\n * style of the element.\n *\n * Property names with dashes (`-`) are assumed to be valid CSS\n * property names and set on the element's style object using `setProperty()`.\n * Names without dashes are assumed to be camelCased JavaScript property names\n * and set on the element's style object using property assignment, allowing the\n * style object to translate JavaScript-style names to CSS property names.\n *\n * For example `styleMap({backgroundColor: 'red', 'border-top': '5px', '--size':\n * '0'})` sets the `background-color`, `border-top` and `--size` properties.\n *\n * @param styleInfo\n * @see {@link https://lit.dev/docs/templates/directives/#stylemap styleMap code samples on Lit.dev}\n */\nexport const styleMap = directive(StyleMapDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {StyleMapDirective};\n", "import {css} from 'lit';\nexport const styles = css`:host{display:inline-block;width:200px;position:relative}.wrapper{--row-count:1;--maxrow-count: ;--line-height:var(--bl-font-title-3-line-height);--scroll-height:var(--line-height);--padding-vertical:var(--bl-size-2xs);--padding-horizontal:var(--bl-size-xs);--label-padding:var(--bl-size-3xs);--border-size:1px;--default-scroll-height:calc((var(--row-count) * var(--line-height)) + var(--padding-vertical));--height:max(var(--scroll-height), var(--default-scroll-height));--input-font:var(--bl-font-body-text-2);--border-radius:var(--bl-size-3xs);--border-color:var(--bl-color-neutral-lighter);--background-color:var(--bl-color-neutral-full);display:flex;flex-direction:column;position:relative;gap:var(--bl-size-3xs)}.input-wrapper{border:solid var(--border-size) var(--border-color);border-radius:var(--border-radius);padding:0 calc(var(--padding-horizontal) - var(--label-padding) - var(--border-size));padding-top:var(--padding-vertical);display:flex;box-sizing:border-box;background-color:var(--background-color);margin:0;width:0;min-width:100%}textarea{--parent-padding:calc(var(--padding-horizontal) - var(--label-padding) - var(--border-size));width:100%;align-self:stretch;outline:0;font:var(--input-font);padding:0 calc(var(--padding-horizontal) - var(--border-size));padding-bottom:var(--padding-vertical);margin:0 calc(-1 * var(--parent-padding));border:none;border-radius:var(--border-radius);color:var(--bl-color-neutral-darker);resize:vertical;background-color:transparent;display:block}:host([size=large]) .wrapper{--padding-vertical:var(--bl-size-xs);--padding-horizontal:var(--bl-size-m)}:host([size=small]) .wrapper{--padding-vertical:var(--bl-size-3xs);--padding-horizontal:var(--bl-size-xs);--input-font:var(--bl-font-body-text-3);--line-height:var(--bl-font-title-4-line-height)}textarea:disabled{background-color:var(--bl-color-neutral-lightest);color:var(--bl-color-neutral-light);cursor:not-allowed}:host([disabled]) .wrapper{--background-color:var(--bl-color-neutral-lightest)}:host([expand]) textarea{overflow:hidden;resize:none;height:var(--height)}:host([expand][max-rows]) textarea{--maxrow-height:calc((var(--maxrow-count) * var(--line-height)) + var(--padding-vertical));overflow-y:scroll;height:min(var(--height),var(--maxrow-height))}.wrapper:focus-within{--border-color:var(--bl-color-primary)}.dirty.invalid,.dirty.max-len-invalid{--border-color:var(--bl-color-danger)}:host([label]) ::placeholder{color:transparent;transition:color .4s ease-out}.input-wrapper legend,label{padding:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}label{max-width:max-content;position:absolute;transition:.1s ease-in;font:var(--bl-font-title-3-regular);top:var(--padding-vertical);inset-inline-start:var(--padding-horizontal);inset-inline-end:var(--padding-horizontal);pointer-events:none;color:var(--bl-color-neutral-light)}.input-wrapper legend{height:0;visibility:hidden;display:none}.input-wrapper legend span{padding:0 var(--label-padding);display:inline-block;opacity:0;visibility:visible}:where(.wrapper:focus-within,.wrapper.has-value) label{top:0;inset-inline-start:var(--padding-horizontal);transform:translateY(-50%);font:var(--bl-font-caption);color:var(--bl-color-neutral-dark);pointer-events:initial;z-index:var(--bl-index-base)}:host([label]) :where(.wrapper:focus-within,.wrapper.has-value) legend{max-width:100%;font:var(--bl-font-caption);display:block}:host ::placeholder,:host([label-fixed]) ::placeholder{color:var(--bl-color-neutral-light)}:host([label-fixed]) label{position:static;transition:none;transform:none;pointer-events:initial;font:var(--bl-font-caption);color:var(--bl-color-neutral-dark);background-color:initial;padding:0}:host([label-fixed]) legend{display:none}.hint{display:none;font:var(--bl-font-body-text-3)}.dirty.invalid .hint,:host([character-counter]) .hint,:host([help-text]) .hint{display:flex;gap:var(--bl-size-3xs)}.hint>*{margin:0;padding:0}.help-text,.invalid-text{flex:1}.counter-text{color:var(--bl-color-neutral-dark);margin-inline-start:auto}:where(.max-len-invalid,.dirty.invalid) .hint>.counter-text{color:var(--bl-color-danger)}.dirty.invalid label{color:var(--bl-color-danger)}.invalid-text{display:none;color:var(--bl-color-danger)}.help-text{color:var(--bl-color-neutral-dark)}:where(.dirty.max-len-invalid,.dirty.invalid) .hint>.invalid-text{display:inline-block}.dirty.invalid .hint>.help-text{display:none}`;\nexport default styles;\n", "import { CSSResultGroup, html, LitElement, PropertyValues, TemplateResult } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { live } from \"lit/directives/live.js\";\nimport { styleMap } from \"lit/directives/style-map.js\";\nimport { FormControlMixin } from \"@open-wc/form-control\";\nimport \"element-internals-polyfill\";\nimport { event, EventDispatcher } from \"../../utilities/event\";\nimport { textAreaValidators } from \"../../utilities/form-control\";\nimport style from \"./bl-textarea.css\";\n\nexport type TextareaSize = \"small\" | \"medium\" | \"large\";\n/**\n * @tag bl-textarea\n * @summary Baklava Textarea component\n */\n@customElement(\"bl-textarea\")\nexport default class BlTextarea extends FormControlMixin(LitElement) {\n static get styles(): CSSResultGroup {\n return [style];\n }\n static shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n static formControlValidators = textAreaValidators;\n\n @query(\"textarea\")\n validationTarget: HTMLTextAreaElement;\n\n @property({ reflect: true, type: String })\n error: string;\n\n /**\n * Name of textarea\n */\n @property({ type: String, reflect: true })\n name = \"\";\n\n /**\n * Makes textarea a mandatory field\n */\n @property({ type: Boolean, reflect: true })\n required = false;\n\n /**\n * Disables the textarea\n */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /**\n * Sets expandity\n */\n @property({ type: Boolean, reflect: true })\n expand = false;\n\n /**\n * Sets max row when expand is true\n */\n @property({ type: Number, reflect: true, attribute: \"max-rows\" })\n maxRows?: number;\n\n /**\n * Sets textarea size.\n */\n @property({ type: String, reflect: true })\n size?: TextareaSize = \"medium\";\n\n /**\n * Sets label of the textarea\n */\n @property({ reflect: true })\n label?: string;\n\n /**\n * Makes label as fixed positioned\n */\n @property({ type: Boolean, attribute: \"label-fixed\", reflect: true })\n labelFixed = false;\n\n /**\n * Sets placeholder of the textarea\n */\n @property({ reflect: true })\n placeholder?: string;\n\n /**\n * Enables showing character counter.\n */\n @property({ type: Boolean, attribute: \"character-counter\", reflect: true })\n characterCounter = false;\n\n /**\n * Adds help text\n */\n @property({ type: String, attribute: \"help-text\", reflect: true })\n helpText?: string;\n\n /**\n * Set custom error message\n */\n @property({ type: String, attribute: \"invalid-text\", reflect: true })\n customInvalidText?: string;\n\n /**\n * Sets minimum length of the textarea\n */\n @property({ type: Number, reflect: true })\n minlength?: number;\n\n /**\n * Sets max length of textarea\n */\n @property({ type: Number, reflect: true })\n maxlength?: number;\n\n /**\n * Sets initial value of the textarea\n */\n @property({ reflect: true })\n value = \"\";\n\n /**\n * Sets textarea visible row count.\n */\n @property({ type: Number, reflect: true })\n rows?: number = 4;\n\n /**\n * Sets the input mode of the field for asking browser to show the desired keyboard.\n */\n @property({ type: String, reflect: true })\n inputmode: \"none\" | \"text\" | \"decimal\" | \"numeric\" | \"tel\" | \"search\" | \"email\" | \"url\";\n\n /**\n * Sets input to get keyboard focus automatically\n */\n @property({ type: Boolean, reflect: true })\n autofocus = false;\n\n /**\n * Hints browser to autocomplete this field.\n */\n @property({ type: String, reflect: true })\n autocomplete: string;\n\n /**\n * Enables/disables spellcheck feature inside the textarea\n */\n @property({ type: String, reflect: true, attribute: \"spellcheck\" })\n spellchecker: \"true\" | \"false\" = \"false\";\n\n @event(\"bl-input\") private onInput: EventDispatcher<string>;\n\n @event(\"bl-change\") private onChange: EventDispatcher<string>;\n\n @event(\"bl-invalid\") private onInvalid: EventDispatcher<ValidityState>;\n\n @state()\n private customScrollHeight: string | null = null;\n\n private inputId = Math.random().toString(36).substring(2);\n\n connectedCallback() {\n super.connectedCallback();\n this.internals.form?.addEventListener(\"submit\", () => {\n this.reportValidity();\n });\n }\n\n private onError = (): void => {\n this.onInvalid(this.internals.validity);\n };\n\n private inputHandler(event: Event) {\n this.autoResize();\n\n const value = (event.target as HTMLTextAreaElement).value;\n\n this.value = value;\n this.setValue(this.value);\n this.onInput(value);\n }\n\n private changeHandler(event: Event) {\n const value = (event.target as HTMLTextAreaElement).value;\n\n this.dirty = true;\n this.value = value;\n this.setValue(this.value);\n this.onChange(value);\n }\n\n firstUpdated() {\n this.setValue(this.value);\n this.autoResize();\n }\n\n protected async updated(changedProperties: PropertyValues) {\n if (changedProperties.has(\"rows\")) {\n this.autoResize();\n }\n\n if (changedProperties.has(\"value\")) {\n this.setValue(this.value);\n\n await this.validationComplete;\n\n this.requestUpdate();\n }\n\n if (changedProperties.has(\"error\") && this.error && !this.dirty) {\n this.reportValidity();\n }\n }\n\n /**\n * Sets a custom validity on the form element.\n * @param message\n */\n setCustomValidity(message: string) {\n this.validationTarget.setCustomValidity(message);\n }\n\n reportValidity() {\n this.dirty = true;\n return this.checkValidity();\n }\n\n valueChangedCallback(value: string): void {\n this.value = value;\n }\n\n validityCallback(): string | void {\n return this.customInvalidText || this.validationTarget?.validationMessage;\n }\n\n private autoResize() {\n if (!this.expand) {\n return;\n }\n\n this.validationTarget.style.height = \"auto\";\n const scrollHeight = this.validationTarget.scrollHeight;\n\n this.customScrollHeight = `${scrollHeight}px`;\n this.validationTarget.style.removeProperty(\"height\");\n }\n\n @state() private dirty = false;\n\n render(): TemplateResult {\n const maxLengthInvalid = this.internals.validity.tooLong;\n const invalidMessage = !this.checkValidity()\n ? html`<p class=\"invalid-text\">${this.validationMessage}</p>`\n : \"\";\n const helpMessage = this.helpText ? html`<p class=\"help-text\">${this.helpText}</p>` : \"\";\n\n const label = this.label ? html`<label for=\"${this.inputId}\">${this.label}</label>` : \"\";\n const characterCounterText =\n this.characterCounter && this.maxlength\n ? `${this.value.length}/${this.maxlength}`\n : this.characterCounter\n ? `${this.value.length}`\n : \"\";\n const characterCounter = this.characterCounter\n ? html`<p class=\"counter-text\">${characterCounterText}</p>`\n : \"\";\n\n const wrapperClasses = {\n \"wrapper\": true,\n \"has-value\": this.value !== null && this.value !== \"\",\n \"dirty\": this.dirty,\n \"max-len-invalid\": maxLengthInvalid,\n \"invalid\": !this.checkValidity(),\n };\n\n const styles = {\n \"--row-count\": `${this.rows}`,\n \"--maxrow-count\": this.maxRows ? `${this.maxRows}` : null,\n \"--scroll-height\": this.customScrollHeight,\n };\n\n return html`\n <div style=${styleMap(styles)} class=${classMap(wrapperClasses)}>\n ${label}\n <fieldset class=\"input-wrapper\">\n <legend><span>${this.label}</span></legend>\n <textarea\n id=\"${this.inputId}\"\n name=\"${ifDefined(this.name)}\"\n .value=${live(this.value)}\n ?autofocus=${this.autofocus}\n autocomplete=\"${ifDefined(this.autocomplete)}\"\n inputmode=\"${ifDefined(this.inputmode)}\"\n placeholder=\"${ifDefined(this.placeholder)}\"\n minlength=\"${ifDefined(this.minlength)}\"\n rows=\"${ifDefined(this.rows)}\"\n ?required=${this.required}\n ?disabled=${this.disabled}\n spellcheck=\"${this.spellchecker}\"\n @change=${this.changeHandler}\n @input=${this.inputHandler}\n @invalid=${this.onError}\n >\n </textarea>\n </fieldset>\n <div class=\"hint\">${invalidMessage}${helpMessage}${characterCounter}</div>\n </div>\n `;\n }\n}\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bl-textarea\": BlTextarea;\n }\n}\n"],
|
|
5
|
+
"mappings": "wcA0BA,IAAMA,EAAY,YAEZC,EAAgB,KAAOD,EAqHhBE,EAAWC,EAjHxB,cAAgCC,CAAAA,CAG9BC,YAAYC,EAAAA,CAAAA,IAAAA,EAEV,GADAC,MAAMD,CAAAA,EAEJA,EAASE,OAASC,EAASC,WAC3BJ,EAASK,OAAS,WACjBC,EAAAN,EAASO,WADDF,MACCE,IAAAA,OAAAA,OAAAA,EAASC,QAAoB,EAEvC,MAAUC,MACR,4GAAA,CAIL,CAEDC,OAAOC,EAAAA,CACL,OAAOC,OAAOC,KAAKF,CAAAA,EAAWG,OAAO,CAACC,EAAOC,IAAAA,CAC3C,IAAMC,EAAQN,EAAUK,CAAAA,EACxB,OAAIC,GAAS,KACJF,EAcFA,EAAQ,GALfC,EAAOA,EAAKE,SAAS,GAAA,EACjBF,EACAA,EACGG,QAAQ,oCAAqC,KAAA,EAC7CC,YAAAA,KACmBH,IAAQ,EACjC,EAAA,CACJ,CAEQI,OAAOC,EAAAA,CAAsBX,CAAAA,EAAAA,CACpC,GAAA,CAAMI,MAACA,CAAAA,EAASO,EAAKC,QAErB,GAAIC,KAAKC,KAAT,OAAiD,CAC/CD,KAAKC,GAA2B,IAAIC,IACpC,QAAWrB,KAAQM,EACjBa,KAAKC,GAAyBE,IAAItB,CAAAA,EAEpC,OAAOmB,KAAKd,OAAOC,CAAAA,EAMrBa,KAAKC,GAA0BG,QAASvB,GAAAA,CAElCM,EAAUN,CAAAA,GAAS,OACrBmB,KAAKC,GAA0BI,OAAOxB,CAAAA,EAClCA,EAAKa,SAAS,GAAA,EAChBH,EAAMe,eAAezB,CAAAA,EAKpBU,EAAcV,CAAAA,EAAQ,GAE1B,CAAA,EAIH,Q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AAA,CADCE,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GAvHvBxB,EAwHnB,yBAMAsB,EAAA,CADCE,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GA7HtBxB,EA8HnB,4BAMAsB,EAAA,CADCE,EAAS,CAAE,KAAM,OAAQ,QAAS,GAAM,UAAW,YAAa,CAAC,GAnI/CxB,EAoInB,4BAE2BsB,EAAA,CAA1BjB,EAAM,UAAU,GAtIEL,EAsIQ,uBAECsB,EAAA,CAA3BjB,EAAM,WAAW,GAxICL,EAwIS,wBAECsB,EAAA,CAA5BjB,EAAM,YAAY,GA1IAL,EA0IU,yBAGrBsB,EAAA,CADPG,EAAM,GA5IYzB,EA6IX,kCA0FSsB,EAAA,CAAhBG,EAAM,GAvOYzB,EAuOF,qBAvOEA,EAArBsB,EAAA,CADCE,EAAc,aAAa,GACPxB",
|
|
6
6
|
"names": ["important", "importantFlag", "styleMap", "directive", "Directive", "constructor", "partInfo", "super", "type", "PartType", "ATTRIBUTE", "name", "_a", "strings", "length", "Error", "render", "styleInfo", "Object", "keys", "reduce", "style", "prop", "value", "includes", "replace", "toLowerCase", "update", "part", "element", "this", "_previousStyleProperties", "Set", "add", "forEach", "delete", "removeProperty", "isImportant", "endsWith", "setProperty", "slice", "noChange", "styles", "i", "bl_textarea_default", "BlTextarea", "FormControlMixin", "s", "bl_textarea_default", "_a", "event", "value", "changedProperties", "message", "scrollHeight", "maxLengthInvalid", "invalidMessage", "x", "helpMessage", "label", "characterCounterText", "characterCounter", "wrapperClasses", "styles", "o", "l", "textAreaValidators", "__decorateClass", "i", "e", "t"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as l,b as t}from"./chunk-5MOOXA2X.js";import{a as i,b as r,f as a}from"./chunk-4OT5AMS5.js";import{d as o}from"./chunk-IZ2LK5GK.js";var c=i`:host{display:inline-block;max-width:100%}.badge{--bg-color:var(--bl-badge-bg-color, var(--bl-color-primary-contrast));--color:var(--bl-badge-color, var(--bl-color-primary));--font:var(--bl-font-title-4-medium);--padding-vertical:var(--bl-size-4xs);--padding-horizontal:var(--bl-size-3xs);--margin-icon:var(--bl-size-3xs);--icon-size:var(--bl-size-s);--height:var(--bl-size-xl);display:flex;gap:var(--margin-icon);justify-content:center;align-items:center;box-sizing:border-box;width:100%;border:none;border-radius:var(--bl-size-4xs);margin:0;padding:var(--padding-vertical) var(--padding-horizontal);background-color:var(--bg-color);color:var(--color
|
|
1
|
+
import{a as l,b as t}from"./chunk-5MOOXA2X.js";import{a as i,b as r,f as a}from"./chunk-4OT5AMS5.js";import{d as o}from"./chunk-IZ2LK5GK.js";var c=i`:host{display:inline-block;max-width:100%}.badge{--bg-color:var(--bl-badge-bg-color, var(--bl-color-primary-contrast));--color:var(--bl-badge-color, var(--bl-color-primary));--font:var(--bl-font-title-4-medium);--padding-vertical:var(--bl-size-4xs);--padding-horizontal:var(--bl-size-3xs);--margin-icon:var(--bl-size-3xs);--icon-size:var(--bl-size-s);--height:var(--bl-size-xl);display:flex;gap:var(--margin-icon);justify-content:center;align-items:center;box-sizing:border-box;width:100%;border:none;border-radius:var(--bl-size-4xs);margin:0;padding:var(--padding-vertical) var(--padding-horizontal);background-color:var(--bg-color);color:var(--color,#fff);font:var(--font);font-kerning:none;height:var(--height)}:host([size=small]) .badge{--font:var(--bl-font-caption);--height:var(--bl-size-m)}:host([size=large]) .badge{--font:var(--bl-font-title-3-medium);--padding-vertical:var(--bl-size-2xs);--padding-horizontal:var(--bl-size-2xs);--height:var(--bl-size-2xl);--icon-size:var(--bl-size-m)}:host ::slotted(bl-icon){font-size:var(--icon-size)}:host([size=small]) bl-icon{display:none}`,n=c;var e=class extends a{constructor(){super(...arguments);this.size="medium"}static get styles(){return[n]}render(){let s=this.icon?r`<bl-icon name=${this.icon}></bl-icon>`:"";return r`<span class="badge">
|
|
2
2
|
<slot name="icon">${s}</slot>
|
|
3
3
|
<slot></slot>
|
|
4
4
|
</span>`}};o([t({type:String,reflect:!0})],e.prototype,"size",2),o([t({type:String})],e.prototype,"icon",2),e=o([l("bl-badge")],e);export{e as a};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-T5MEA7JO.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/badge/bl-badge.css", "../src/components/badge/bl-badge.ts"],
|
|
4
|
+
"sourcesContent": ["import {css} from 'lit';\nexport const styles = css`:host{display:inline-block;max-width:100%}.badge{--bg-color:var(--bl-badge-bg-color, var(--bl-color-primary-contrast));--color:var(--bl-badge-color, var(--bl-color-primary));--font:var(--bl-font-title-4-medium);--padding-vertical:var(--bl-size-4xs);--padding-horizontal:var(--bl-size-3xs);--margin-icon:var(--bl-size-3xs);--icon-size:var(--bl-size-s);--height:var(--bl-size-xl);display:flex;gap:var(--margin-icon);justify-content:center;align-items:center;box-sizing:border-box;width:100%;border:none;border-radius:var(--bl-size-4xs);margin:0;padding:var(--padding-vertical) var(--padding-horizontal);background-color:var(--bg-color);color:var(--color,#fff);font:var(--font);font-kerning:none;height:var(--height)}:host([size=small]) .badge{--font:var(--bl-font-caption);--height:var(--bl-size-m)}:host([size=large]) .badge{--font:var(--bl-font-title-3-medium);--padding-vertical:var(--bl-size-2xs);--padding-horizontal:var(--bl-size-2xs);--height:var(--bl-size-2xl);--icon-size:var(--bl-size-m)}:host ::slotted(bl-icon){font-size:var(--icon-size)}:host([size=small]) bl-icon{display:none}`;\nexport default styles;\n", "import { CSSResultGroup, html, LitElement, TemplateResult } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport \"../icon/bl-icon\";\nimport { BaklavaIcon } from \"../icon/icon-list\";\nimport style from \"./bl-badge.css\";\n\nexport type BadgeSize = \"small\" | \"medium\" | \"large\";\n\n/**\n * @tag bl-badge\n * @summary Baklava Badge component\n *\n * @cssproperty [--bl-badge-bg-color=--bl-color-primary-contrast] Sets the background color of badge\n * @cssproperty [--bl-badge-color=--bl-color-primary] Sets the color of badge\n */\n\n@customElement(\"bl-badge\")\nexport default class BlBadge extends LitElement {\n static get styles(): CSSResultGroup {\n return [style];\n }\n\n /**\n * Sets the badge size\n */\n @property({ type: String, reflect: true })\n size: BadgeSize = \"medium\";\n\n /**\n * Sets the name of the icon\n */\n @property({ type: String })\n icon?: BaklavaIcon;\n\n render(): TemplateResult {\n const icon = this.icon ? html`<bl-icon name=${this.icon}></bl-icon>` : \"\";\n\n return html`<span class=\"badge\">\n <slot name=\"icon\">${icon}</slot>\n <slot></slot>\n </span>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bl-badge\": BlBadge;\n }\n}\n"],
|
|
5
|
+
"mappings": "6IACO,IAAMA,EAAS,qkCACfC,EAAQD,ECef,IAAqBE,EAArB,cAAqCC,CAAW,CAAhD,kCASE,UAAkB,SARlB,WAAW,QAAyB,CAClC,MAAO,CAACC,CAAK,CACf,CAcA,QAAyB,CACvB,IAAMC,EAAO,KAAK,KAAOC,kBAAqB,KAAK,kBAAoB,GAEvE,OAAOA;AAAA,0BACeD;AAAA;AAAA,YAGxB,CACF,EAhBEE,EAAA,CADCC,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GARtBN,EASnB,oBAMAK,EAAA,CADCC,EAAS,CAAE,KAAM,MAAO,CAAC,GAdPN,EAenB,oBAfmBA,EAArBK,EAAA,CADCC,EAAc,UAAU,GACJN",
|
|
6
|
+
"names": ["styles", "bl_badge_default", "BlBadge", "s", "bl_badge_default", "icon", "x", "__decorateClass", "e"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import{a as c}from"./chunk-GRL4DWKG.js";import{a as n,b as r}from"./chunk-5MOOXA2X.js";import{a as i,b as l,d as o,f as s}from"./chunk-4OT5AMS5.js";import{d as t}from"./chunk-IZ2LK5GK.js";var v=i`:host{display:inline-block;max-width:100%}.tag{--bg-color:var(--bl-color-neutral-full);--color:var(--bl-color-neutral-darker);--font:var(--bl-font-title-4-medium);--padding-vertical:var(--bl-size-2xs);--padding-horizontal:var(--bl-size-xs);--margin-icon:var(--bl-size-3xs);--icon-size:var(--bl-size-m);--height:var(--bl-size-2xl);--border-radius:var(--bl-size-m);--remove-icon-size:var(--bl-size-s);display:flex;gap:var(--margin-icon);justify-content:center;align-items:center;box-sizing:border-box;overflow:hidden;width:100%;border:1px solid var(--bl-color-neutral-lighter);border-radius:var(--border-radius);padding-block:var(--padding-vertical);padding-inline:var(--padding-horizontal);background-color:var(--bg-color);color:var(--color,#fff);font:var(--font);font-kerning:none;height:var(--height)}:host([variant=selectable]) .tag{cursor:pointer;user-select:none}:host([variant=selectable]) .tag.__ONLY_FOR_STORYBOOK_DEMONSTRATION_HOVER__,:host([variant=selectable]) .tag:hover{background-color:var(--bl-color-neutral-lightest)}:host([variant=selectable][selected]) .tag{border-color:var(--bl-color-neutral-darker);background-color:var(--bl-color-neutral-darker);--color:var(--bl-color-neutral-full)}:host([variant=selectable][disabled]) .tag{background-color:var(--bl-color-neutral-lightest);border-color:var(--bl-color-neutral-lightest);color:var(--bl-color-neutral-light);cursor:not-allowed}:host([variant=removable]) .remove-button{--bl-border-radius-m:var(--bl-border-radius-circle)}:host([size=small]) .tag{--font:var(--bl-font-title-4-medium);--height:var(--bl-size-xl);--icon-size:var(--bl-size-s);--border-radius:var(--bl-size-xs);--padding-vertical:0px;--padding-horizontal:var(--bl-size-2xs);--remove-icon-size:var(--bl-size-xs)}:host([size=large]) .tag{--font:var(--bl-font-title-3-medium);--padding-vertical:var(--bl-size-2xs);--padding-horizontal:var(--bl-size-m);--height:var(--bl-size-3xl);--icon-size:var(--bl-size-m);--border-radius:var(--bl-size-l)}:host([variant=removable][size=small]) .tag{--padding-horizontal:var(--bl-size-2xs) 0px}:host([variant=removable]) .tag{--padding-horizontal:var(--bl-size-xs) var(--bl-size-3xs)}:host([variant=removable][size=large]) .tag{--padding-horizontal:var(--bl-size-m) var(--bl-size-2xs)}slot[name=icon] bl-icon{font-size:var(--icon-size);color:var(--color)}`,b=v;var e=class extends s{constructor(){super(...arguments);this.size="medium";this.variant="selectable";this.selected=!1;this.disabled=!1;this.value=null;this._handleClick=()=>{this.variant==="selectable"&&(this.selected=!this.selected),this._onBlTagClick({selected:this.selected,value:this.value})}}static get styles(){return[b]}_removeButtonTemplate(){let a=this.size==="large"?"medium":"small";return l`
|
|
2
|
+
<bl-button
|
|
3
|
+
icon="close"
|
|
4
|
+
size=${a}
|
|
5
|
+
label="Remove"
|
|
6
|
+
variant="tertiary"
|
|
7
|
+
kind="neutral"
|
|
8
|
+
class="remove-button"
|
|
9
|
+
?disabled=${this.disabled}
|
|
10
|
+
@bl-click=${this._handleClick}
|
|
11
|
+
></bl-button>
|
|
12
|
+
`}_iconTemplate(){return this.icon?l`<bl-icon name=${this.icon}></bl-icon>`:o}render(){let a=l`<button
|
|
13
|
+
class="tag"
|
|
14
|
+
role="checkbox"
|
|
15
|
+
@click=${this._handleClick}
|
|
16
|
+
?disabled=${this.disabled}
|
|
17
|
+
>
|
|
18
|
+
${this._iconTemplate()}
|
|
19
|
+
<slot></slot>
|
|
20
|
+
</button>`,d=l`<div class="tag">
|
|
21
|
+
${this._iconTemplate()}
|
|
22
|
+
<slot></slot>
|
|
23
|
+
${this._removeButtonTemplate()}
|
|
24
|
+
</div>`;return this.variant==="selectable"?a:d}};t([r({type:String,reflect:!0})],e.prototype,"size",2),t([r({type:String,reflect:!0})],e.prototype,"variant",2),t([r({type:String})],e.prototype,"icon",2),t([r({type:Boolean,reflect:!0})],e.prototype,"selected",2),t([r({type:Boolean,reflect:!0})],e.prototype,"disabled",2),t([r({type:String,reflect:!0})],e.prototype,"value",2),t([c("bl-tag-click")],e.prototype,"_onBlTagClick",2),e=t([n("bl-tag")],e);export{e as a};
|
|
25
|
+
//# sourceMappingURL=chunk-TUUQIEDI.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/tag/bl-tag.css", "../src/components/tag/bl-tag.ts"],
|
|
4
|
+
"sourcesContent": ["import {css} from 'lit';\nexport const styles = css`:host{display:inline-block;max-width:100%}.tag{--bg-color:var(--bl-color-neutral-full);--color:var(--bl-color-neutral-darker);--font:var(--bl-font-title-4-medium);--padding-vertical:var(--bl-size-2xs);--padding-horizontal:var(--bl-size-xs);--margin-icon:var(--bl-size-3xs);--icon-size:var(--bl-size-m);--height:var(--bl-size-2xl);--border-radius:var(--bl-size-m);--remove-icon-size:var(--bl-size-s);display:flex;gap:var(--margin-icon);justify-content:center;align-items:center;box-sizing:border-box;overflow:hidden;width:100%;border:1px solid var(--bl-color-neutral-lighter);border-radius:var(--border-radius);padding-block:var(--padding-vertical);padding-inline:var(--padding-horizontal);background-color:var(--bg-color);color:var(--color,#fff);font:var(--font);font-kerning:none;height:var(--height)}:host([variant=selectable]) .tag{cursor:pointer;user-select:none}:host([variant=selectable]) .tag.__ONLY_FOR_STORYBOOK_DEMONSTRATION_HOVER__,:host([variant=selectable]) .tag:hover{background-color:var(--bl-color-neutral-lightest)}:host([variant=selectable][selected]) .tag{border-color:var(--bl-color-neutral-darker);background-color:var(--bl-color-neutral-darker);--color:var(--bl-color-neutral-full)}:host([variant=selectable][disabled]) .tag{background-color:var(--bl-color-neutral-lightest);border-color:var(--bl-color-neutral-lightest);color:var(--bl-color-neutral-light);cursor:not-allowed}:host([variant=removable]) .remove-button{--bl-border-radius-m:var(--bl-border-radius-circle)}:host([size=small]) .tag{--font:var(--bl-font-title-4-medium);--height:var(--bl-size-xl);--icon-size:var(--bl-size-s);--border-radius:var(--bl-size-xs);--padding-vertical:0px;--padding-horizontal:var(--bl-size-2xs);--remove-icon-size:var(--bl-size-xs)}:host([size=large]) .tag{--font:var(--bl-font-title-3-medium);--padding-vertical:var(--bl-size-2xs);--padding-horizontal:var(--bl-size-m);--height:var(--bl-size-3xl);--icon-size:var(--bl-size-m);--border-radius:var(--bl-size-l)}:host([variant=removable][size=small]) .tag{--padding-horizontal:var(--bl-size-2xs) 0px}:host([variant=removable]) .tag{--padding-horizontal:var(--bl-size-xs) var(--bl-size-3xs)}:host([variant=removable][size=large]) .tag{--padding-horizontal:var(--bl-size-m) var(--bl-size-2xs)}slot[name=icon] bl-icon{font-size:var(--icon-size);color:var(--color)}`;\nexport default styles;\n", "import { CSSResultGroup, html, LitElement, nothing, TemplateResult } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { event, EventDispatcher } from \"../../utilities/event\";\nimport \"../button/bl-button\";\nimport \"../icon/bl-icon\";\nimport { BaklavaIcon } from \"../icon/icon-list\";\nimport style from \"./bl-tag.css\";\n\nexport type TagSize = \"small\" | \"medium\" | \"large\";\ntype TagVariant = \"selectable\" | \"removable\";\n\n/**\n * @tag bl-tag\n * @summary Baklava Tag component\n */\n@customElement(\"bl-tag\")\nexport default class BlTag extends LitElement {\n static get styles(): CSSResultGroup {\n return [style];\n }\n\n /**\n * Sets the tag size\n */\n @property({ type: String, reflect: true })\n size: TagSize = \"medium\";\n\n /**\n * Sets the tag variant\n */\n @property({ type: String, reflect: true })\n variant: TagVariant = \"selectable\";\n\n /**\n * Sets the name of the icon\n */\n @property({ type: String })\n icon?: BaklavaIcon;\n\n /**\n * Sets the selected state of the tag\n */\n @property({ type: Boolean, reflect: true })\n selected = false;\n\n /**\n * Disables the tag\n */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /**\n * Sets the value of the tag\n */\n @property({ type: String, reflect: true })\n value: string | null = null;\n\n /**\n * Dispatches when the tag is clicked\n */\n @event(\"bl-tag-click\") private _onBlTagClick: EventDispatcher<{\n value: string | null;\n selected: boolean;\n }>;\n\n private _handleClick = () => {\n if (this.variant === \"selectable\") this.selected = !this.selected;\n this._onBlTagClick({ selected: this.selected, value: this.value });\n };\n\n private _removeButtonTemplate() {\n const removeIconSize = this.size === \"large\" ? \"medium\" : \"small\";\n\n return html`\n <bl-button\n icon=\"close\"\n size=${removeIconSize}\n label=\"Remove\"\n variant=\"tertiary\"\n kind=\"neutral\"\n class=\"remove-button\"\n ?disabled=${this.disabled}\n @bl-click=${this._handleClick}\n ></bl-button>\n `;\n }\n\n private _iconTemplate() {\n if (!this.icon) return nothing;\n return html`<bl-icon name=${this.icon}></bl-icon>`;\n }\n\n render(): TemplateResult {\n const selectableVariant = html`<button\n class=\"tag\"\n role=\"checkbox\"\n @click=${this._handleClick}\n ?disabled=${this.disabled}\n >\n ${this._iconTemplate()}\n <slot></slot>\n </button>`;\n\n const removableVariant = html`<div class=\"tag\">\n ${this._iconTemplate()}\n <slot></slot>\n ${this._removeButtonTemplate()}\n </div>`;\n\n if (this.variant === \"selectable\") return selectableVariant;\n return removableVariant;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bl-tag\": BlTag;\n }\n}\n"],
|
|
5
|
+
"mappings": "4LACO,IAAMA,EAAS,qxEACfC,EAAQD,ECcf,IAAqBE,EAArB,cAAmC,CAAW,CAA9C,kCASE,UAAgB,SAMhB,aAAsB,aAYtB,cAAW,GAMX,cAAW,GAMX,WAAuB,KAUvB,KAAQ,aAAe,IAAM,CACvB,KAAK,UAAY,eAAc,KAAK,SAAW,CAAC,KAAK,UACzD,KAAK,cAAc,CAAE,SAAU,KAAK,SAAU,MAAO,KAAK,KAAM,CAAC,CACnE,EAnDA,WAAW,QAAyB,CAClC,MAAO,CAACC,CAAK,CACf,CAmDQ,uBAAwB,CAC9B,IAAMC,EAAiB,KAAK,OAAS,QAAU,SAAW,QAE1D,OAAOC;AAAA;AAAA;AAAA,eAGID;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKK,KAAK;AAAA,oBACL,KAAK;AAAA;AAAA,KAGvB,CAEQ,eAAgB,CACtB,OAAK,KAAK,KACHC,kBAAqB,KAAK,kBADVC,CAEzB,CAEA,QAAyB,CACvB,IAAMC,EAAoBF;AAAA;AAAA;AAAA,eAGf,KAAK;AAAA,kBACF,KAAK;AAAA;AAAA,QAEf,KAAK,cAAc;AAAA;AAAA,eAIjBG,EAAmBH;AAAA,QACrB,KAAK,cAAc;AAAA;AAAA,QAEnB,KAAK,sBAAsB;AAAA,YAG/B,OAAI,KAAK,UAAY,aAAqBE,EACnCC,CACT,CACF,EAvFEC,EAAA,CADCC,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GARtBR,EASnB,oBAMAO,EAAA,CADCC,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAdtBR,EAenB,uBAMAO,EAAA,CADCC,EAAS,CAAE,KAAM,MAAO,CAAC,GApBPR,EAqBnB,oBAMAO,EAAA,CADCC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GA1BvBR,EA2BnB,wBAMAO,EAAA,CADCC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GAhCvBR,EAiCnB,wBAMAO,EAAA,CADCC,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAtCtBR,EAuCnB,qBAK+BO,EAAA,CAA9BE,EAAM,cAAc,GA5CFT,EA4CY,6BA5CZA,EAArBO,EAAA,CADCC,EAAc,QAAQ,GACFR",
|
|
6
|
+
"names": ["styles", "bl_tag_default", "BlTag", "bl_tag_default", "removeIconSize", "x", "A", "selectableVariant", "removableVariant", "__decorateClass", "e", "event"]
|
|
7
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as w,b as f,c as E,d as y,e as x,f as _,g as k,h as M}from"./chunk-EZSEQHRH.js";import{a as g}from"./chunk-6LT7O7T2.js";import{a as l}from"./chunk-GRL4DWKG.js";import{a as u,b as a,c as n,e as s}from"./chunk-5MOOXA2X.js";import{a as c,b as m,f as b}from"./chunk-4OT5AMS5.js";import{d as o}from"./chunk-IZ2LK5GK.js";function z(i){return typeof i=="string"?document.getElementById(i):i instanceof Element?i:null}var S=c`:host{display:contents}.popover{--arrow-display:var(--bl-popover-arrow-display, none);--background-color:var(--bl-popover-background-color, var(--bl-color-neutral-full));--border-color:var(--bl-popover-border-color, var(--bl-color-primary-highlight));--border-size:var(--bl-popover-border-size, 1px);--padding:var(--bl-popover-padding, var(--bl-size-m));--border-radius:var(--bl-popover-border-radius, var(--bl-size-3xs));--position:var(--bl-popover-position, fixed);--max-width:var(--bl-popover-max-width, 100vw);--max-viewport:calc(100vw - var(--bl-size-s));position:var(--position);box-sizing:border-box;border:var(--border-size) solid var(--border-color);padding:var(--padding);border-radius:var(--border-radius);z-index:var(--bl-index-popover);max-width:min(var(--max-viewport),
|
|
1
|
+
import{a as w,b as f,c as E,d as y,e as x,f as _,g as k,h as M}from"./chunk-EZSEQHRH.js";import{a as g}from"./chunk-6LT7O7T2.js";import{a as l}from"./chunk-GRL4DWKG.js";import{a as u,b as a,c as n,e as s}from"./chunk-5MOOXA2X.js";import{a as c,b as m,f as b}from"./chunk-4OT5AMS5.js";import{d as o}from"./chunk-IZ2LK5GK.js";function z(i){return typeof i=="string"?document.getElementById(i):i instanceof Element?i:null}var S=c`:host{display:contents}.popover{--arrow-display:var(--bl-popover-arrow-display, none);--background-color:var(--bl-popover-background-color, var(--bl-color-neutral-full));--border-color:var(--bl-popover-border-color, var(--bl-color-primary-highlight));--border-size:var(--bl-popover-border-size, 1px);--padding:var(--bl-popover-padding, var(--bl-size-m));--border-radius:var(--bl-popover-border-radius, var(--bl-size-3xs));--position:var(--bl-popover-position, fixed);--max-width:var(--bl-popover-max-width, 100vw);--max-viewport:calc(100vw - var(--bl-size-s));position:var(--position);box-sizing:border-box;border:var(--border-size) solid var(--border-color);padding:var(--padding);border-radius:var(--border-radius);z-index:var(--bl-index-popover);max-width:min(var(--max-viewport),var(--max-width));width:max-content;hyphens:auto;background-color:var(--background-color);font:var(--bl-font-title-3-regular);color:var(--bl-color-neutral-darker)}.popover:not(.visible){visibility:hidden}.arrow{--arrow-rotation:45deg;--size:var(--bl-size-2xs);--arrow-position:calc((var(--size) / -2) - var(--border-size));box-sizing:border-box;display:var(--arrow-display);position:absolute;background-color:var(--background-color);width:var(--size);height:var(--size);transform:rotate(var(--arrow-rotation));border:var(--border-size) solid var(--border-color);border-bottom:none;border-inline-end:none}.popover[data-placement*=bottom] .arrow{top:var(--arrow-position)}.popover[data-placement*=top] .arrow{--arrow-rotation:225deg;bottom:var(--arrow-position)}.popover[data-placement*=left] .arrow{--arrow-rotation:135deg;right:var(--arrow-position)}.popover[data-placement*=right] .arrow{--arrow-rotation:315deg;left:var(--arrow-position)}`,C=S;var t=class extends b{constructor(){super(...arguments);this.placement="bottom";this.fitSize=!1;this.offset=8;this._visible=!1;this._handleClickOutside=e=>{let r=e.composedPath();!r.includes(this._target)&&!r.includes(this)&&this.hide()}}static get styles(){return[C]}get target(){return this._target}set target(e){let r=z(e);if(!r){console.warn("BlPopover target only accepts an Element instance or a string id of a DOM element.");return}this._target=r}get visible(){return this._visible}connectedCallback(){super.connectedCallback(),this._handlePopoverShowEvent=this._handlePopoverShowEvent.bind(this),this._handleKeydownEvent=this._handleKeydownEvent.bind(this),this._handleClickOutside=this._handleClickOutside.bind(this)}disconnectedCallback(){super.disconnectedCallback(),this.popoverAutoUpdateCleanup&&this.popoverAutoUpdateCleanup()}show(){this._visible=!0,this.setPopover(),this.onBlPopoverShow(""),document.addEventListener("click",this._handleClickOutside),document.addEventListener("keydown",this._handleKeydownEvent),document.addEventListener("bl-popover-show",this._handlePopoverShowEvent)}hide(){this._visible=!1,document.removeEventListener("click",this._handleClickOutside),document.removeEventListener("keydown",this._handleKeydownEvent),document.removeEventListener("bl-popover-show",this._handlePopoverShowEvent),this.onBlPopoverHide("",{bubbles:!1})}render(){let e=g({popover:!0,visible:this._visible});return m` <div class=${e}>
|
|
2
2
|
<slot id="popover" aria-live=${this._visible?"polite":"off"}></slot>
|
|
3
3
|
<div class="arrow" aria-hidden="true"></div>
|
|
4
4
|
</div>`}getMiddleware(){let e=[];return e.push(y(this.offset),E(),f(),x({padding:4})),this.fitSize&&e.push(_({apply(r){r.elements.floating&&r.elements.reference&&Object.assign(r.elements.floating.style,{"min-width":`${r.elements.reference.getBoundingClientRect().width}px`})}})),e.push(w({element:this.arrow,padding:5})),e}setPopover(){this.target&&(this.popoverAutoUpdateCleanup=k(this.target,this._popover,()=>{M(this.target,this._popover,{placement:this.placement,strategy:"fixed",middleware:this.getMiddleware()}).then(({x:e,y:r,placement:d,middlewareData:p})=>{if(Object.assign(this._popover.style,{left:`${e}px`,top:`${r}px`}),this._popover.dataset.placement=d,p.arrow){let{x:v,y:h}=p.arrow;Object.assign(this.arrow.style,{left:v!=null?`${v}px`:"",top:h!=null?`${h}px`:""})}})}))}_handlePopoverShowEvent(e){if(e.target!==this){let{parentElement:r}=e.target;!this.contains(r)&&e.target.tagName===this.tagName&&this.hide()}}_handleKeydownEvent(e){e.key==="Escape"&&this.visible&&(e.preventDefault(),this.hide())}};o([a({type:String})],t.prototype,"placement",2),o([a({type:Boolean,attribute:"fit-size"})],t.prototype,"fitSize",2),o([a({type:Number})],t.prototype,"offset",2),o([s(".popover")],t.prototype,"_popover",2),o([s(".arrow")],t.prototype,"arrow",2),o([l("bl-popover-show")],t.prototype,"onBlPopoverShow",2),o([l("bl-popover-hide")],t.prototype,"onBlPopoverHide",2),o([n()],t.prototype,"_target",2),o([a()],t.prototype,"target",1),o([n()],t.prototype,"_visible",2),t=o([u("bl-popover")],t);export{z as a,t as b};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-UOGCEUXK.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utilities/elements.ts", "../src/components/popover/bl-popover.css", "../src/components/popover/bl-popover.ts"],
|
|
4
|
+
"sourcesContent": ["export function getMiddleOfElement(element: Element) {\n const { x, y, width, height } = element.getBoundingClientRect();\n\n return {\n x: Math.floor(x + window.pageXOffset + width / 2),\n y: Math.floor(y + window.pageYOffset + height / 2),\n };\n}\n\nexport function getTarget(value: string | Element): Element | null {\n if (typeof value === \"string\") {\n return document.getElementById(value) as Element;\n } else if (value instanceof Element) {\n return value;\n }\n\n return null;\n}\n", "import {css} from 'lit';\nexport const styles = css`:host{display:contents}.popover{--arrow-display:var(--bl-popover-arrow-display, none);--background-color:var(--bl-popover-background-color, var(--bl-color-neutral-full));--border-color:var(--bl-popover-border-color, var(--bl-color-primary-highlight));--border-size:var(--bl-popover-border-size, 1px);--padding:var(--bl-popover-padding, var(--bl-size-m));--border-radius:var(--bl-popover-border-radius, var(--bl-size-3xs));--position:var(--bl-popover-position, fixed);--max-width:var(--bl-popover-max-width, 100vw);--max-viewport:calc(100vw - var(--bl-size-s));position:var(--position);box-sizing:border-box;border:var(--border-size) solid var(--border-color);padding:var(--padding);border-radius:var(--border-radius);z-index:var(--bl-index-popover);max-width:min(var(--max-viewport),var(--max-width));width:max-content;hyphens:auto;background-color:var(--background-color);font:var(--bl-font-title-3-regular);color:var(--bl-color-neutral-darker)}.popover:not(.visible){visibility:hidden}.arrow{--arrow-rotation:45deg;--size:var(--bl-size-2xs);--arrow-position:calc((var(--size) / -2) - var(--border-size));box-sizing:border-box;display:var(--arrow-display);position:absolute;background-color:var(--background-color);width:var(--size);height:var(--size);transform:rotate(var(--arrow-rotation));border:var(--border-size) solid var(--border-color);border-bottom:none;border-inline-end:none}.popover[data-placement*=bottom] .arrow{top:var(--arrow-position)}.popover[data-placement*=top] .arrow{--arrow-rotation:225deg;bottom:var(--arrow-position)}.popover[data-placement*=left] .arrow{--arrow-rotation:135deg;right:var(--arrow-position)}.popover[data-placement*=right] .arrow{--arrow-rotation:315deg;left:var(--arrow-position)}`;\nexport default styles;\n", "import { CSSResultGroup, html, LitElement, TemplateResult } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport {\n arrow,\n autoUpdate,\n computePosition,\n flip,\n inline,\n Middleware,\n MiddlewareState,\n offset,\n shift,\n size,\n} from \"@floating-ui/dom\";\nimport { getTarget } from \"../../utilities/elements\";\nimport { event, EventDispatcher } from \"../../utilities/event\";\nimport style from \"./bl-popover.css\";\n\nexport type Placement =\n | \"top-start\"\n | \"top\"\n | \"top-end\"\n | \"bottom-start\"\n | \"bottom\"\n | \"bottom-end\"\n | \"left-start\"\n | \"left\"\n | \"left-end\"\n | \"right-start\"\n | \"right\"\n | \"right-end\";\n\n/**\n * @tag bl-popover\n * @summary Baklava Popover component\n *\n * @cssproperty [--bl-popover-arrow-display=none] - Sets the display of popovers arrow. Set as `block` to make arrow visible.\n * @cssproperty [--bl-popover-background-color=--bl-color-neutral-full] - Sets the background color of popover.\n * @cssproperty [--bl-popover-border-color=--bl-color-primary-highlight] - Sets the border color of popover.\n * @cssproperty [--bl-popover-border-size=1px] - Sets the border size of popover. You can set it to `0px` to not have a border (if you use a custom background color). Always use with a length unit.\n * @cssproperty [--bl-popover-padding=--bl-size-m] - Sets the padding of popover.\n * @cssproperty [--bl-popbover-border-radius=--bl-size-3xs] - Sets the border radius of popover.\n * @cssproperty [--bl-popover-max-width=100vw] - Sets the maximum width of the popover (including border and padding).\n * @cssproperty [--bl-popover-position=fixed] - Sets the position of popover. You can set it to `absolute` if parent element is a fixed positioned element like drawer or dialog.\n */\n@customElement(\"bl-popover\")\nexport default class BlPopover extends LitElement {\n /**\n * Sets placement of the popover\n */\n @property({ type: String })\n placement: Placement = \"bottom\";\n /**\n * Sets size of popover same as trigger element\n */\n @property({ type: Boolean, attribute: \"fit-size\" })\n fitSize = false;\n /**\n * Sets the distance between popover and target/trigger element\n */\n @property({ type: Number })\n offset = 8;\n @query(\".popover\") private _popover: HTMLElement;\n @query(\".arrow\") private arrow: HTMLElement;\n /**\n * Fires when the popover is shown\n */\n @event(\"bl-popover-show\") private onBlPopoverShow: EventDispatcher<string>;\n /**\n * Fires when popover becomes hidden\n */\n @event(\"bl-popover-hide\") private onBlPopoverHide: EventDispatcher<string>;\n private popoverAutoUpdateCleanup: () => void;\n\n static get styles(): CSSResultGroup {\n return [style];\n }\n\n /**\n * Target elements state\n */\n @state() _target: string | Element;\n\n /**\n * Sets the target element of the popover to align and trigger.\n * It can be a string id of the target element or can be a direct Element reference of it.\n */\n @property()\n get target(): string | Element {\n return this._target;\n }\n\n set target(value: string | Element) {\n const target = getTarget(value);\n\n if (!target) {\n console.warn(\n \"BlPopover target only accepts an Element instance or a string id of a DOM element.\"\n );\n return;\n }\n\n this._target = target;\n }\n\n /**\n * Visibility state\n */\n @state() private _visible = false;\n\n /**\n * Gives the visibility status of the popover\n */\n get visible(): boolean {\n return this._visible;\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n this._handlePopoverShowEvent = this._handlePopoverShowEvent.bind(this);\n this._handleKeydownEvent = this._handleKeydownEvent.bind(this);\n this._handleClickOutside = this._handleClickOutside.bind(this);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n this.popoverAutoUpdateCleanup && this.popoverAutoUpdateCleanup();\n }\n\n /**\n * Shows popover\n */\n show() {\n this._visible = true;\n\n this.setPopover();\n this.onBlPopoverShow(\"\");\n document.addEventListener(\"click\", this._handleClickOutside);\n document.addEventListener(\"keydown\", this._handleKeydownEvent);\n document.addEventListener(\"bl-popover-show\", this._handlePopoverShowEvent);\n }\n\n /**\n * Hides popover\n */\n hide() {\n this._visible = false;\n document.removeEventListener(\"click\", this._handleClickOutside);\n document.removeEventListener(\"keydown\", this._handleKeydownEvent);\n document.removeEventListener(\"bl-popover-show\", this._handlePopoverShowEvent);\n this.onBlPopoverHide(\"\", { bubbles: false });\n }\n\n render(): TemplateResult {\n const classes = classMap({\n popover: true,\n visible: this._visible,\n });\n\n return html` <div class=${classes}>\n <slot id=\"popover\" aria-live=${this._visible ? \"polite\" : \"off\"}></slot>\n <div class=\"arrow\" aria-hidden=\"true\"></div>\n </div>`;\n }\n\n private getMiddleware(): Middleware[] {\n const middlewareParams: Middleware[] = [];\n\n middlewareParams.push(offset(this.offset), inline(), flip(), shift({ padding: 4 }));\n\n if (this.fitSize) {\n middlewareParams.push(\n size({\n apply(args: MiddlewareState) {\n if (args.elements.floating && args.elements.reference) {\n Object.assign(args.elements.floating.style, {\n \"min-width\": `${args.elements.reference.getBoundingClientRect().width}px`,\n });\n }\n },\n })\n );\n }\n\n middlewareParams.push(arrow({ element: this.arrow, padding: 5 }));\n\n return middlewareParams;\n }\n\n private _handleClickOutside = (event: MouseEvent) => {\n const eventPath = event.composedPath() as HTMLElement[];\n\n if (!eventPath.includes(this._target as HTMLElement) && !eventPath.includes(this)) {\n this.hide();\n }\n };\n\n private setPopover() {\n if (this.target) {\n this.popoverAutoUpdateCleanup = autoUpdate(this.target as Element, this._popover, () => {\n computePosition(this.target as Element, this._popover, {\n placement: this.placement,\n strategy: \"fixed\",\n middleware: this.getMiddleware(),\n }).then(({ x, y, placement, middlewareData }) => {\n Object.assign(this._popover.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n\n this._popover.dataset.placement = placement;\n\n if (middlewareData.arrow) {\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n\n Object.assign(this.arrow.style, {\n left: arrowX != null ? `${arrowX}px` : \"\",\n top: arrowY != null ? `${arrowY}px` : \"\",\n });\n }\n });\n });\n }\n }\n\n private _handlePopoverShowEvent(event: Event) {\n if (event.target !== this) {\n const { parentElement } = event.target as HTMLElement;\n const isNestedPopover = this.contains(parentElement);\n\n if (!isNestedPopover && (event.target as HTMLElement).tagName === this.tagName) {\n this.hide();\n }\n }\n }\n\n private _handleKeydownEvent(event: KeyboardEvent) {\n if (event.key === \"Escape\" && this.visible) {\n event.preventDefault();\n this.hide();\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bl-popover\": BlPopover;\n }\n}\n"],
|
|
5
|
+
"mappings": "oUASO,SAASA,EAAUC,EAAyC,CACjE,OAAI,OAAOA,GAAU,SACZ,SAAS,eAAeA,CAAK,EAC3BA,aAAiB,QACnBA,EAGF,IACT,CChBO,IAAMC,EAASC,+rDACfC,EAAQF,EC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AC,EAEL,CAEQ,wBAAwBvB,EAAc,CAC5C,GAAIA,EAAM,SAAW,KAAM,CACzB,GAAM,CAAE,cAAAwB,CAAc,EAAIxB,EAAM,OAG5B,CAFoB,KAAK,SAASwB,CAAa,GAE1BxB,EAAM,OAAuB,UAAY,KAAK,SACrE,KAAK,KAAK,EAGhB,CAEQ,oBAAoBA,EAAsB,CAC5CA,EAAM,MAAQ,UAAY,KAAK,UACjCA,EAAM,eAAe,EACrB,KAAK,KAAK,EAEd,CACF,EAjMEyB,EAAA,CADCC,EAAS,CAAE,KAAM,MAAO,CAAC,GAJP5B,EAKnB,yBAKA2B,EAAA,CADCC,EAAS,CAAE,KAAM,QAAS,UAAW,UAAW,CAAC,GAT/B5B,EAUnB,uBAKA2B,EAAA,CADCC,EAAS,CAAE,KAAM,MAAO,CAAC,GAdP5B,EAenB,sBAC2B2B,EAAA,CAA1BE,EAAM,UAAU,GAhBE7B,EAgBQ,wBACF2B,EAAA,CAAxBE,EAAM,QAAQ,GAjBI7B,EAiBM,qBAIS2B,EAAA,CAAjCzB,EAAM,iBAAiB,GArBLF,EAqBe,+BAIA2B,EAAA,CAAjCzB,EAAM,iBAAiB,GAzBLF,EAyBe,+BAUzB2B,EAAA,CAARG,EAAM,GAnCY9B,EAmCV,uBAOL2B,EAAA,CADHC,EAAS,GAzCS5B,EA0Cf,sBAoBa2B,EAAA,CAAhBG,EAAM,GA9DY9B,EA8DF,wBA9DEA,EAArB2B,EAAA,CADCC,EAAc,YAAY,GACN5B",
|
|
6
|
+
"names": ["getTarget", "value", "styles", "i", "bl_popover_default", "BlPopover", "s", "event", "eventPath", "bl_popover_default", "value", "target", "getTarget", "classes", "o", "x", "middlewareParams", "offset", "inline", "flip", "shift", "size", "args", "arrow", "autoUpdate", "computePosition", "y", "placement", "middlewareData", "arrowX", "arrowY", "parentElement", "__decorateClass", "e", "i", "t"]
|
|
7
|
+
}
|