godown 3.6.1 → 3.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,54 @@
1
+ import { GlobalStyle } from "../core/global-style.js";
2
+ import { type TemplateResult } from "lit";
3
+ import { type OutlineType } from "../core/outline.js";
4
+ /**
5
+ * {@linkcode Tabs} used to render a set of tabs.
6
+ *
7
+ * It accepts "tabs" to present the sub-content.
8
+ *
9
+ * When "useSlot" is enabled, each item in "tabs" becomes a named slot with the same name as itself,
10
+ * while for non-slot tabs, the content is rendered as a horizontally padded string.
11
+ *
12
+ * When "mouseenter" and "mouseleave" are triggered on an individual tab, the indicator will move.
13
+ *
14
+ * The moving indicator will start from the position of the item that was last entered.
15
+ *
16
+ * If the pointer moves out of the root element or the element is connected to the document,
17
+ * the starting position of the indicator will be regarded as the current selection.
18
+ *
19
+ * Apply "flex-direction: column" to the tabs to arrange them vertically.
20
+ *
21
+ * @csspart root - The root element.
22
+ * @csspart item - The tab items.
23
+ * @csspart indicator - The indicator.
24
+ * @csspart selected - The selected tab item.
25
+ * @csspart hover - The hovered tab item.
26
+ * @fires select - Fires when the tab is selected.
27
+ * @category display
28
+ */
29
+ declare class Tabs extends GlobalStyle {
30
+ outlineType: OutlineType;
31
+ /**
32
+ * Determines whether the tabs should use a slot for their content instead of a string.
33
+ */
34
+ useSlot: boolean;
35
+ /**
36
+ * An array of strings or slot content representing the tabs.
37
+ */
38
+ tabs: string[];
39
+ /**
40
+ * The index of the currently selected tab.
41
+ */
42
+ index: number;
43
+ protected _lastIndex: number;
44
+ protected _items: HTMLCollectionOf<HTMLLIElement>;
45
+ protected _indicators: HTMLCollectionOf<HTMLDivElement>;
46
+ render(): TemplateResult<1>;
47
+ connectedCallback(): void;
48
+ protected _handleMouseLeave(): void;
49
+ move(from: number, to: number): void;
50
+ select(selected: number): void;
51
+ }
52
+ export default Tabs;
53
+ export { Tabs };
54
+ //# sourceMappingURL=tabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../src/components/tabs.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,WAAW,EAAe,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAErD,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOtE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,cAQM,IAAK,SAAQ,WAAW;IAE5B,WAAW,EAAE,WAAW,CAAY;IAEpC;;OAEG;IAEH,OAAO,UAAS;IAEhB;;OAEG;IAEH,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf;;OAEG;IAEH,KAAK,SAAK;IAEV,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAG7B,SAAS,CAAC,MAAM,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAGlD,SAAS,CAAC,WAAW,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAExD,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;IAW3B,iBAAiB,IAAI,IAAI;IAKzB,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAQnC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;IAsCpC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAS/B;AAED,eAAe,IAAI,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ import{__decorate as t}from"tslib";import{godown as i,styles as e,attr as o,tokenList as r,htmlSlot as n}from"@godown/element";import{scopePrefix as s,cssGlobalVars as a,GlobalStyle as d}from"../core/global-style.js";import{css as p,html as l}from"lit";import{property as c,queryAll as h}from"lit/decorators.js";import{OutlineBuilder as u}from"../core/outline.js";const m="tabs",v=s(m),y="hover";let x=class Tabs extends d{constructor(){super(...arguments),this.outlineType="border",this.useSlot=!1,this.index=0}render(){return l`<ul part="root" ${o(this.observedRecord)} @mouseleave="${this._handleMouseLeave}">${this.tabs.map(((t,i)=>l`<li part="${r("item",{selected:this.index===i})}" @mouseenter="${()=>{this.move(this._lastIndex,i),this._lastIndex=i}}" @click="${()=>this.select(i)}">${this.useSlot?n(t):t}<div part="indicator"></div></li>`))}</ul>`}connectedCallback(){super.connectedCallback(),this._lastIndex=this.index}_handleMouseLeave(){const t=this._items[this._lastIndex];t&&t.part.remove(y),this._lastIndex=this.index}move(t,i){if(t===i)return;const{_items:e,_indicators:o}=this,r=e[i];if(!r)return;r.part.add(y);const n=e[t];if(!n)return;n.part.remove(y);const s=o[i],a=o[t];if(!s||!a)return;const d=a.getBoundingClientRect(),p=r.getBoundingClientRect(),l=d.x-p.x,c=d.y-p.y,h=d.width,{style:u}=s;u.transform=`translate3d(${l}px,${c}px,0)`,u.width=h+"px",u.transition=a.style.transition="none",s.getBoundingClientRect(),u.width=u.transform=u.transition=a.style.transition=""}select(t){this.index!==t&&(this.dispatchCustomEvent("select",t),this.move(this._lastIndex,t),this._lastIndex=t,this.index=t)}};t([c({attribute:"outline-type"})],x.prototype,"outlineType",void 0),t([c({type:Boolean})],x.prototype,"useSlot",void 0),t([c({type:Array})],x.prototype,"tabs",void 0),t([c({type:Number})],x.prototype,"index",void 0),t([h("[part~=item]")],x.prototype,"_items",void 0),t([h("[part=indicator]")],x.prototype,"_indicators",void 0),x=t([i(m),e(new u({width:`${v}--outline-width`,color:`${v}--outline-color`}).css,p`:host{${v}--indicator-background:var(${a._colors.darkgray[7]});${v}--outline-color:var(${a.passive});${v}--outline-width:0.075em;${v}--space:0.25em;border-radius:var(${a.borderRadius});cursor:default;display:flex;transition:.2s ease-in-out;width:-moz-fit-content;width:fit-content}[part=root]{border-radius:inherit;display:flex;flex-direction:inherit;gap:var(${v}--space);overflow-x:clip;padding:var(${v}--space);position:relative;transition:inherit;transition-property:width,transform,opacity;z-index:1}[useslot] [part~=item]{padding:0}[part~=item]{display:block;padding:0 .4em;position:relative}[part=indicator],[part~=item]{border-radius:inherit;transition:inherit;transition-property:inherit;width:100%}[part=indicator]{background:var(${v}--indicator-background);height:100%;inset:0;opacity:0;position:absolute;z-index:-1}[part~=selected]{background:var(${v}--indicator-background)}[part~=hover] [part=indicator],[part~=selected] [part=indicator]{opacity:1}`)],x);var b=x;export{x as Tabs,b as default};
2
+ //# sourceMappingURL=tabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.js","sources":["../src/components/tabs.ts"],"sourcesContent":null,"names":["protoName","cssScope","scopePrefix","mouseEnterAddedToken","Tabs","GlobalStyle","constructor","this","outlineType","useSlot","index","render","html","attr","observedRecord","_handleMouseLeave","tabs","map","tab","tokenList","selected","move","_lastIndex","select","htmlSlot","connectedCallback","super","lastItem","_items","part","remove","from","to","_indicators","toItem","add","fromItem","toIndicator","fromIndicator","fromIndicatorRect","getBoundingClientRect","toItemRect","transformX","x","transformY","y","fromWidth","width","style","transform","transition","dispatchCustomEvent","__decorate","property","attribute","prototype","undefined","type","Boolean","Array","Number","queryAll","godown","styles","OutlineBuilder","color","css","cssGlobalVars","_colors","darkgray","passive","borderRadius","Tabs$1"],"mappings":"4WAMA,MAAMA,EAAY,OACZC,EAAWC,EAAYF,GAEvBG,EAAuB,QAmC7B,IAAMC,EAAN,MAAMA,aAAaC,EAAnB,WAAAC,uBAEEC,KAAWC,YAAgB,SAM3BD,KAAOE,SAAG,EAYVF,KAAKG,MAAG,EAUR,MAAAC,GACE,OAAOC,CAAI,mBAGLC,EAAKN,KAAKO,gCACGP,KAAKQ,sBAElBR,KAAKS,KAAKC,KAAI,CAACC,EAAKR,IACbE,CAAI,aAECO,EAAU,OAAQ,CACxBC,SAAUb,KAAKG,QAAUA,qBAEb,KACZH,KAAKc,KAAKd,KAAKe,WAAYZ,GAC3BH,KAAKe,WAAaZ,CAAK,cAEhB,IAAMH,KAAKgB,OAAOb,OAEzBH,KAAKE,QAAUe,EAASN,GAAOA,8CAS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