@logosphere-ui/core 0.0.0-alpha.32 → 0.0.0-alpha.33
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/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +39 -37
- package/dist/index.umd.js +454 -286
- package/dist/pagination-AclB9qi1.cjs +169 -0
- package/dist/pagination-BLNrwUSO.js +360 -0
- package/dist/pagination.cjs +1 -0
- package/dist/pagination.js +4 -0
- package/package.json +6 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";const a=require("lit"),n=require("lit/decorators.js"),h=require("lit/directives/live.js");require("./ui-icon-jKyMV1zp.cjs");require("./combobox-BV4AKTqp.cjs");const u=":host{display:block;width:100%}.pagination{display:flex;align-items:center;justify-content:space-between;padding:var(--spacing-4) var(--spacing-6);background-color:var(--color-body-bg);border-top:1px solid var(--color-border);font-family:var(--font-family-base);gap:var(--spacing-4)}.pagination--justify-end{justify-content:flex-end}.pagination--justify-start{justify-content:flex-start}.pagination--justify-center{justify-content:center}.pagination__nav{display:flex;align-items:center;gap:var(--spacing-1)}.pagination__nav-group{display:flex;align-items:center}.pagination__btn{display:flex;align-items:center;justify-content:center;padding:var(--spacing-2);border:none;background:transparent;border-radius:var(--radius-base);cursor:pointer;color:var(--color-secondary);transition:background-color .15s ease,color .15s ease,opacity .15s ease}.pagination__btn:hover:not(:disabled){background-color:var(--color-body-bg-hover)}.pagination__btn:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}.pagination__btn:disabled{opacity:.4;cursor:not-allowed}.pagination__btn--icon{display:flex;align-items:center;justify-content:center;width:32px;height:32px;padding:var(--spacing-2);border:1px solid var(--color-border);background-color:var(--color-body-bg);border-radius:var(--radius-base);cursor:pointer;color:var(--color-secondary);transition:background-color .15s ease,border-color .15s ease,opacity .15s ease}.pagination__btn--icon:hover:not(:disabled){background-color:var(--color-body-bg-hover);border-color:var(--color-border-hover)}.pagination__btn--icon:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}.pagination__btn--icon:disabled{opacity:.4;cursor:not-allowed}.pagination__btn--text{display:flex;align-items:center;justify-content:center;gap:var(--spacing-1);height:32px;min-width:100px;padding:var(--spacing-1) var(--spacing-3);border:1px solid var(--color-border);background-color:var(--color-body-bg);border-radius:var(--radius-base);font-size:var(--font-size-sm);font-weight:var(--font-weight-medium);color:var(--color-secondary);cursor:pointer;transition:all .15s ease}.pagination__btn--text:hover:not(:disabled){background-color:var(--color-body-bg-hover);border-color:var(--color-border-hover)}.pagination__btn--text:disabled{color:var(--color-secondary-disabled);cursor:not-allowed}.pagination__btn--number{display:flex;align-items:center;justify-content:center;min-width:32px;height:32px;padding:var(--spacing-1) var(--spacing-3);border:1px solid var(--color-border);background-color:var(--color-body-bg);border-radius:var(--radius-base);font-size:var(--font-size-sm);font-weight:var(--font-weight-medium);color:var(--color-secondary);cursor:pointer;transition:all .15s ease}.pagination__btn--number:hover:not(:disabled):not(.pagination__btn--active){background-color:var(--color-body-bg-hover)}.pagination__btn--active{background-color:var(--color-secondary);border-color:var(--color-secondary);color:#fff;font-weight:var(--font-weight-semibold)}.pagination__btn--ellipsis{border:none;background:transparent;cursor:default;min-width:32px}.pagination__btn--ellipsis:hover{background:transparent}.pagination__input-container{display:flex;align-items:center;justify-content:center;min-width:32px;height:32px}.pagination__input{width:100%;height:100%;min-width:32px;padding:0;border:1px solid var(--color-border);border-radius:var(--radius-base);background-color:var(--color-body-bg);font-size:var(--font-size-sm);font-weight:var(--font-weight-regular);color:var(--color-body-text);text-align:center;outline:none;transition:border-color .15s ease}.pagination__input:focus{border-color:var(--color-primary)}.pagination__input::-webkit-outer-spin-button,.pagination__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.pagination__input[type=number]{-moz-appearance:textfield}.pagination__separator{font-size:var(--font-size-xs);font-weight:var(--font-weight-regular);color:var(--color-tertiary);line-height:18px;letter-spacing:-.12px;margin-right:var(--spacing-1)}.pagination__info{display:flex;align-items:center;gap:var(--spacing-2)}.pagination__page-info{display:flex;align-items:center;gap:var(--spacing-1);font-size:var(--font-size-xs);line-height:18px;letter-spacing:-.12px}.pagination__page-info-text{color:var(--color-secondary)}.pagination__page-info-separator{color:var(--color-tertiary)}.pagination__total{display:flex;align-items:center;gap:var(--spacing-1);font-size:var(--font-size-xs);line-height:18px;letter-spacing:-.12px}.pagination__total-separator{color:var(--color-tertiary)}.pagination__total-text{color:var(--color-secondary)}.pagination__page-size{display:flex;align-items:center}@media(max-width:768px){.pagination{flex-wrap:wrap;gap:var(--spacing-3);padding:var(--spacing-3) var(--spacing-4)}.pagination__btn--text{min-width:80px;font-size:var(--font-size-xs)}}@media(max-width:480px){.pagination__nav,.pagination__info{flex-wrap:wrap;justify-content:center}}";var b=Object.defineProperty,o=(d,t,e,r)=>{for(var s=void 0,l=d.length-1,p;l>=0;l--)(p=d[l])&&(s=p(t,e,s)||s);return s&&b(t,e,s),s};const c=class c extends a.LitElement{constructor(){super(...arguments),this.variant="default",this.page=1,this.pageSize=25,this.total=0,this.pageSizeOptions=[10,25,50,100],this.showPageSize=!0,this.showTotal=!0,this.disabled=!1,this.prevLabel="Önceki",this.nextLabel="Sonraki",this.pageLabel="Sayfa",this.perPageLabel="/ sayfa",this.totalLabel="kayıt",this.inputValue="1",this.goFirst=()=>{this.canGoPrev&&this.goToPage(1)},this.goPrev=()=>{this.canGoPrev&&this.goToPage(this.page-1)},this.goNext=()=>{this.canGoNext&&this.goToPage(this.page+1)},this.goLast=()=>{this.canGoNext&&this.goToPage(this.totalPages)},this.handleInputChange=t=>{const e=t.target;this.inputValue=e.value},this.handleInputBlur=()=>{const t=parseInt(this.inputValue,10);isNaN(t)?this.inputValue=String(this.page):this.goToPage(t)},this.handleInputKeydown=t=>{t.key==="Enter"&&t.target.blur()},this.handlePageSizeChange=t=>{const e=t.detail?.value?.[0];if(e){const r=e.value;r!==this.pageSize&&(this.pageSize=r,this.page=1,this.emitPageChange())}}}get totalPages(){return Math.max(1,Math.ceil(this.total/this.pageSize))}get canGoPrev(){return this.page>1&&!this.disabled}get canGoNext(){return this.page<this.totalPages&&!this.disabled}firstUpdated(){this.updateComboboxSelection()}updated(t){super.updated(t),t.has("page")&&(this.inputValue=String(this.page)),t.has("pageSize")&&this.updateComboboxSelection()}updateComboboxSelection(){this._combobox&&this.showPageSize&&this._combobox.setSelected(this.selectedPageSizeItem)}emitPageChange(){this.dispatchEvent(new CustomEvent("page-change",{bubbles:!0,composed:!0,detail:{page:this.page,pageSize:this.pageSize,totalPages:this.totalPages}}))}goToPage(t){const e=Math.max(1,Math.min(t,this.totalPages));e!==this.page&&(this.page=e,this.emitPageChange())}get pageSizeItems(){return this.pageSizeOptions.map(t=>({label:`${t} ${this.perPageLabel}`,value:t}))}get selectedPageSizeItem(){return[{label:`${this.pageSize} ${this.perPageLabel}`,value:this.pageSize}]}getPageNumbers(){const t=[],e=this.totalPages,r=this.page,s=1;if(e<=7)for(let l=1;l<=e;l++)t.push(l);else{t.push(1),r>3&&t.push("ellipsis");const l=Math.max(2,r-s),p=Math.min(e-1,r+s);for(let g=l;g<=p;g++)t.includes(g)||t.push(g);r<e-2&&t.push("ellipsis"),t.includes(e)||t.push(e)}return t}renderNavButtons(t=!1){const e=t?"pagination__btn--icon":"pagination__btn";return a.html`
|
|
2
|
+
<div class="pagination__nav-group">
|
|
3
|
+
<button
|
|
4
|
+
type="button"
|
|
5
|
+
class="${e}"
|
|
6
|
+
?disabled=${!this.canGoPrev}
|
|
7
|
+
@click=${this.goFirst}
|
|
8
|
+
aria-label="İlk sayfa"
|
|
9
|
+
>
|
|
10
|
+
<ui-icon name="uil-angle-double-left" size="16"></ui-icon>
|
|
11
|
+
</button>
|
|
12
|
+
<button
|
|
13
|
+
type="button"
|
|
14
|
+
class="${e}"
|
|
15
|
+
?disabled=${!this.canGoPrev}
|
|
16
|
+
@click=${this.goPrev}
|
|
17
|
+
aria-label="Önceki sayfa"
|
|
18
|
+
>
|
|
19
|
+
<ui-icon name="uil-angle-left" size="16"></ui-icon>
|
|
20
|
+
</button>
|
|
21
|
+
</div>
|
|
22
|
+
`}renderNavButtonsAfter(t=!1){const e=t?"pagination__btn--icon":"pagination__btn";return a.html`
|
|
23
|
+
<div class="pagination__nav-group">
|
|
24
|
+
<button
|
|
25
|
+
type="button"
|
|
26
|
+
class="${e}"
|
|
27
|
+
?disabled=${!this.canGoNext}
|
|
28
|
+
@click=${this.goNext}
|
|
29
|
+
aria-label="Sonraki sayfa"
|
|
30
|
+
>
|
|
31
|
+
<ui-icon name="uil-angle-right" size="16"></ui-icon>
|
|
32
|
+
</button>
|
|
33
|
+
<button
|
|
34
|
+
type="button"
|
|
35
|
+
class="${e}"
|
|
36
|
+
?disabled=${!this.canGoNext}
|
|
37
|
+
@click=${this.goLast}
|
|
38
|
+
aria-label="Son sayfa"
|
|
39
|
+
>
|
|
40
|
+
<ui-icon name="uil-angle-double-right" size="16"></ui-icon>
|
|
41
|
+
</button>
|
|
42
|
+
</div>
|
|
43
|
+
`}renderPageInput(){return a.html`
|
|
44
|
+
<div class="pagination__input-container">
|
|
45
|
+
<input
|
|
46
|
+
type="number"
|
|
47
|
+
class="pagination__input"
|
|
48
|
+
.value=${h.live(this.inputValue)}
|
|
49
|
+
min="1"
|
|
50
|
+
max=${this.totalPages}
|
|
51
|
+
?disabled=${this.disabled}
|
|
52
|
+
@input=${this.handleInputChange}
|
|
53
|
+
@blur=${this.handleInputBlur}
|
|
54
|
+
@keydown=${this.handleInputKeydown}
|
|
55
|
+
aria-label="Sayfa numarası"
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
<span class="pagination__separator">/ ${this.totalPages}</span>
|
|
59
|
+
`}renderPrevNextButtons(){return a.html`
|
|
60
|
+
<button
|
|
61
|
+
type="button"
|
|
62
|
+
class="pagination__btn--text"
|
|
63
|
+
?disabled=${!this.canGoPrev}
|
|
64
|
+
@click=${this.goPrev}
|
|
65
|
+
>
|
|
66
|
+
<ui-icon name="uil-angle-left" size="16"></ui-icon>
|
|
67
|
+
${this.prevLabel}
|
|
68
|
+
</button>
|
|
69
|
+
<button
|
|
70
|
+
type="button"
|
|
71
|
+
class="pagination__btn--text"
|
|
72
|
+
?disabled=${!this.canGoNext}
|
|
73
|
+
@click=${this.goNext}
|
|
74
|
+
>
|
|
75
|
+
${this.nextLabel}
|
|
76
|
+
<ui-icon name="uil-angle-right" size="16"></ui-icon>
|
|
77
|
+
</button>
|
|
78
|
+
`}renderPageInfo(){return a.html`
|
|
79
|
+
<div class="pagination__page-info">
|
|
80
|
+
<span class="pagination__page-info-text">${this.pageLabel} ${this.page}</span>
|
|
81
|
+
<span class="pagination__page-info-separator">/</span>
|
|
82
|
+
<span class="pagination__page-info-text">${this.totalPages}</span>
|
|
83
|
+
</div>
|
|
84
|
+
`}renderNumberButtons(){const t=this.getPageNumbers();return a.html`
|
|
85
|
+
${t.map((e,r)=>e==="ellipsis"?a.html`
|
|
86
|
+
<span
|
|
87
|
+
class="pagination__btn--number pagination__btn--ellipsis"
|
|
88
|
+
key="ellipsis-${r}"
|
|
89
|
+
>...</span>
|
|
90
|
+
`:a.html`
|
|
91
|
+
<button
|
|
92
|
+
type="button"
|
|
93
|
+
class="pagination__btn--number ${e===this.page?"pagination__btn--active":""}"
|
|
94
|
+
?disabled=${this.disabled}
|
|
95
|
+
@click=${()=>this.goToPage(e)}
|
|
96
|
+
aria-label="Sayfa ${e}"
|
|
97
|
+
aria-current=${e===this.page?"page":a.nothing}
|
|
98
|
+
>
|
|
99
|
+
${e}
|
|
100
|
+
</button>
|
|
101
|
+
`)}
|
|
102
|
+
`}renderPageSizeDropdown(){return this.showPageSize?a.html`
|
|
103
|
+
<div class="pagination__page-size">
|
|
104
|
+
<logosphere-combobox
|
|
105
|
+
.items=${this.pageSizeItems}
|
|
106
|
+
.disabled=${this.disabled}
|
|
107
|
+
.clearable=${!1}
|
|
108
|
+
optionLabel="label"
|
|
109
|
+
optionValue="value"
|
|
110
|
+
placeholder=""
|
|
111
|
+
@change=${this.handlePageSizeChange}
|
|
112
|
+
></logosphere-combobox>
|
|
113
|
+
</div>
|
|
114
|
+
`:a.nothing}renderTotalInfo(){return this.showTotal?a.html`
|
|
115
|
+
<div class="pagination__total">
|
|
116
|
+
<span class="pagination__total-separator">/</span>
|
|
117
|
+
<span class="pagination__total-text">${this.total} ${this.totalLabel}</span>
|
|
118
|
+
</div>
|
|
119
|
+
`:a.nothing}renderDefault(){return a.html`
|
|
120
|
+
<div class="pagination__nav">
|
|
121
|
+
${this.renderNavButtons()}
|
|
122
|
+
${this.renderPageInput()}
|
|
123
|
+
${this.renderNavButtonsAfter()}
|
|
124
|
+
</div>
|
|
125
|
+
<div class="pagination__info">
|
|
126
|
+
${this.renderPageSizeDropdown()}
|
|
127
|
+
${this.renderTotalInfo()}
|
|
128
|
+
</div>
|
|
129
|
+
`}renderPrevNext(){return a.html`
|
|
130
|
+
<div class="pagination__nav" style="gap: 8px;">
|
|
131
|
+
${this.renderPrevNextButtons()}
|
|
132
|
+
</div>
|
|
133
|
+
<div class="pagination__info">
|
|
134
|
+
${this.renderPageInfo()}
|
|
135
|
+
</div>
|
|
136
|
+
`}renderPrevNextInverted(){return a.html`
|
|
137
|
+
<div class="pagination__info">
|
|
138
|
+
${this.renderPageInfo()}
|
|
139
|
+
</div>
|
|
140
|
+
<div class="pagination__nav" style="gap: 8px;">
|
|
141
|
+
${this.renderPrevNextButtons()}
|
|
142
|
+
</div>
|
|
143
|
+
`}renderPrevNextOnly(){return a.html`
|
|
144
|
+
<div class="pagination__nav" style="gap: 8px; margin-left: auto;">
|
|
145
|
+
${this.renderPrevNextButtons()}
|
|
146
|
+
</div>
|
|
147
|
+
`}renderNumberButtonsVariant(){return a.html`
|
|
148
|
+
<div class="pagination__nav">
|
|
149
|
+
${this.renderNavButtons(!0)}
|
|
150
|
+
${this.renderNumberButtons()}
|
|
151
|
+
${this.renderNavButtonsAfter(!0)}
|
|
152
|
+
</div>
|
|
153
|
+
<div class="pagination__info">
|
|
154
|
+
${this.renderPageSizeDropdown()}
|
|
155
|
+
${this.renderTotalInfo()}
|
|
156
|
+
</div>
|
|
157
|
+
`}render(){const t=this.variant==="prev-next-only"?"pagination--justify-end":"";return a.html`
|
|
158
|
+
<nav
|
|
159
|
+
class="pagination ${t}"
|
|
160
|
+
role="navigation"
|
|
161
|
+
aria-label="Sayfalama"
|
|
162
|
+
>
|
|
163
|
+
${this.variant==="default"?this.renderDefault():a.nothing}
|
|
164
|
+
${this.variant==="prev-next"?this.renderPrevNext():a.nothing}
|
|
165
|
+
${this.variant==="prev-next-inverted"?this.renderPrevNextInverted():a.nothing}
|
|
166
|
+
${this.variant==="prev-next-only"?this.renderPrevNextOnly():a.nothing}
|
|
167
|
+
${this.variant==="number-buttons"?this.renderNumberButtonsVariant():a.nothing}
|
|
168
|
+
</nav>
|
|
169
|
+
`}};c.styles=[a.css`${a.unsafeCSS(u)}`];let i=c;o([n.property({type:String})],i.prototype,"variant");o([n.property({type:Number})],i.prototype,"page");o([n.property({type:Number})],i.prototype,"pageSize");o([n.property({type:Number})],i.prototype,"total");o([n.property({type:Array})],i.prototype,"pageSizeOptions");o([n.property({type:Boolean})],i.prototype,"showPageSize");o([n.property({type:Boolean})],i.prototype,"showTotal");o([n.property({type:Boolean})],i.prototype,"disabled");o([n.property({type:String})],i.prototype,"prevLabel");o([n.property({type:String})],i.prototype,"nextLabel");o([n.property({type:String})],i.prototype,"pageLabel");o([n.property({type:String})],i.prototype,"perPageLabel");o([n.property({type:String})],i.prototype,"totalLabel");o([n.state()],i.prototype,"inputValue");o([n.query("logosphere-combobox")],i.prototype,"_combobox");customElements.get("logosphere-pagination")||customElements.define("logosphere-pagination",i);exports.Pagination=i;
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import { LitElement as h, unsafeCSS as b, css as v, html as i, nothing as p } from "lit";
|
|
2
|
+
import { property as o, state as f, query as _ } from "lit/decorators.js";
|
|
3
|
+
import { live as y } from "lit/directives/live.js";
|
|
4
|
+
import "./ui-icon-Ctn4nGFa.js";
|
|
5
|
+
import "./combobox-CTqEZUg6.js";
|
|
6
|
+
const x = ":host{display:block;width:100%}.pagination{display:flex;align-items:center;justify-content:space-between;padding:var(--spacing-4) var(--spacing-6);background-color:var(--color-body-bg);border-top:1px solid var(--color-border);font-family:var(--font-family-base);gap:var(--spacing-4)}.pagination--justify-end{justify-content:flex-end}.pagination--justify-start{justify-content:flex-start}.pagination--justify-center{justify-content:center}.pagination__nav{display:flex;align-items:center;gap:var(--spacing-1)}.pagination__nav-group{display:flex;align-items:center}.pagination__btn{display:flex;align-items:center;justify-content:center;padding:var(--spacing-2);border:none;background:transparent;border-radius:var(--radius-base);cursor:pointer;color:var(--color-secondary);transition:background-color .15s ease,color .15s ease,opacity .15s ease}.pagination__btn:hover:not(:disabled){background-color:var(--color-body-bg-hover)}.pagination__btn:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}.pagination__btn:disabled{opacity:.4;cursor:not-allowed}.pagination__btn--icon{display:flex;align-items:center;justify-content:center;width:32px;height:32px;padding:var(--spacing-2);border:1px solid var(--color-border);background-color:var(--color-body-bg);border-radius:var(--radius-base);cursor:pointer;color:var(--color-secondary);transition:background-color .15s ease,border-color .15s ease,opacity .15s ease}.pagination__btn--icon:hover:not(:disabled){background-color:var(--color-body-bg-hover);border-color:var(--color-border-hover)}.pagination__btn--icon:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}.pagination__btn--icon:disabled{opacity:.4;cursor:not-allowed}.pagination__btn--text{display:flex;align-items:center;justify-content:center;gap:var(--spacing-1);height:32px;min-width:100px;padding:var(--spacing-1) var(--spacing-3);border:1px solid var(--color-border);background-color:var(--color-body-bg);border-radius:var(--radius-base);font-size:var(--font-size-sm);font-weight:var(--font-weight-medium);color:var(--color-secondary);cursor:pointer;transition:all .15s ease}.pagination__btn--text:hover:not(:disabled){background-color:var(--color-body-bg-hover);border-color:var(--color-border-hover)}.pagination__btn--text:disabled{color:var(--color-secondary-disabled);cursor:not-allowed}.pagination__btn--number{display:flex;align-items:center;justify-content:center;min-width:32px;height:32px;padding:var(--spacing-1) var(--spacing-3);border:1px solid var(--color-border);background-color:var(--color-body-bg);border-radius:var(--radius-base);font-size:var(--font-size-sm);font-weight:var(--font-weight-medium);color:var(--color-secondary);cursor:pointer;transition:all .15s ease}.pagination__btn--number:hover:not(:disabled):not(.pagination__btn--active){background-color:var(--color-body-bg-hover)}.pagination__btn--active{background-color:var(--color-secondary);border-color:var(--color-secondary);color:#fff;font-weight:var(--font-weight-semibold)}.pagination__btn--ellipsis{border:none;background:transparent;cursor:default;min-width:32px}.pagination__btn--ellipsis:hover{background:transparent}.pagination__input-container{display:flex;align-items:center;justify-content:center;min-width:32px;height:32px}.pagination__input{width:100%;height:100%;min-width:32px;padding:0;border:1px solid var(--color-border);border-radius:var(--radius-base);background-color:var(--color-body-bg);font-size:var(--font-size-sm);font-weight:var(--font-weight-regular);color:var(--color-body-text);text-align:center;outline:none;transition:border-color .15s ease}.pagination__input:focus{border-color:var(--color-primary)}.pagination__input::-webkit-outer-spin-button,.pagination__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.pagination__input[type=number]{-moz-appearance:textfield}.pagination__separator{font-size:var(--font-size-xs);font-weight:var(--font-weight-regular);color:var(--color-tertiary);line-height:18px;letter-spacing:-.12px;margin-right:var(--spacing-1)}.pagination__info{display:flex;align-items:center;gap:var(--spacing-2)}.pagination__page-info{display:flex;align-items:center;gap:var(--spacing-1);font-size:var(--font-size-xs);line-height:18px;letter-spacing:-.12px}.pagination__page-info-text{color:var(--color-secondary)}.pagination__page-info-separator{color:var(--color-tertiary)}.pagination__total{display:flex;align-items:center;gap:var(--spacing-1);font-size:var(--font-size-xs);line-height:18px;letter-spacing:-.12px}.pagination__total-separator{color:var(--color-tertiary)}.pagination__total-text{color:var(--color-secondary)}.pagination__page-size{display:flex;align-items:center}@media(max-width:768px){.pagination{flex-wrap:wrap;gap:var(--spacing-3);padding:var(--spacing-3) var(--spacing-4)}.pagination__btn--text{min-width:80px;font-size:var(--font-size-xs)}}@media(max-width:480px){.pagination__nav,.pagination__info{flex-wrap:wrap;justify-content:center}}";
|
|
7
|
+
var m = Object.defineProperty, n = (u, t, e, r) => {
|
|
8
|
+
for (var s = void 0, l = u.length - 1, g; l >= 0; l--)
|
|
9
|
+
(g = u[l]) && (s = g(t, e, s) || s);
|
|
10
|
+
return s && m(t, e, s), s;
|
|
11
|
+
};
|
|
12
|
+
const c = class c extends h {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.variant = "default", this.page = 1, this.pageSize = 25, this.total = 0, this.pageSizeOptions = [10, 25, 50, 100], this.showPageSize = !0, this.showTotal = !0, this.disabled = !1, this.prevLabel = "Önceki", this.nextLabel = "Sonraki", this.pageLabel = "Sayfa", this.perPageLabel = "/ sayfa", this.totalLabel = "kayıt", this.inputValue = "1", this.goFirst = () => {
|
|
15
|
+
this.canGoPrev && this.goToPage(1);
|
|
16
|
+
}, this.goPrev = () => {
|
|
17
|
+
this.canGoPrev && this.goToPage(this.page - 1);
|
|
18
|
+
}, this.goNext = () => {
|
|
19
|
+
this.canGoNext && this.goToPage(this.page + 1);
|
|
20
|
+
}, this.goLast = () => {
|
|
21
|
+
this.canGoNext && this.goToPage(this.totalPages);
|
|
22
|
+
}, this.handleInputChange = (t) => {
|
|
23
|
+
const e = t.target;
|
|
24
|
+
this.inputValue = e.value;
|
|
25
|
+
}, this.handleInputBlur = () => {
|
|
26
|
+
const t = parseInt(this.inputValue, 10);
|
|
27
|
+
isNaN(t) ? this.inputValue = String(this.page) : this.goToPage(t);
|
|
28
|
+
}, this.handleInputKeydown = (t) => {
|
|
29
|
+
t.key === "Enter" && t.target.blur();
|
|
30
|
+
}, this.handlePageSizeChange = (t) => {
|
|
31
|
+
const e = t.detail?.value?.[0];
|
|
32
|
+
if (e) {
|
|
33
|
+
const r = e.value;
|
|
34
|
+
r !== this.pageSize && (this.pageSize = r, this.page = 1, this.emitPageChange());
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
get totalPages() {
|
|
39
|
+
return Math.max(1, Math.ceil(this.total / this.pageSize));
|
|
40
|
+
}
|
|
41
|
+
get canGoPrev() {
|
|
42
|
+
return this.page > 1 && !this.disabled;
|
|
43
|
+
}
|
|
44
|
+
get canGoNext() {
|
|
45
|
+
return this.page < this.totalPages && !this.disabled;
|
|
46
|
+
}
|
|
47
|
+
firstUpdated() {
|
|
48
|
+
this.updateComboboxSelection();
|
|
49
|
+
}
|
|
50
|
+
updated(t) {
|
|
51
|
+
super.updated(t), t.has("page") && (this.inputValue = String(this.page)), t.has("pageSize") && this.updateComboboxSelection();
|
|
52
|
+
}
|
|
53
|
+
updateComboboxSelection() {
|
|
54
|
+
this._combobox && this.showPageSize && this._combobox.setSelected(this.selectedPageSizeItem);
|
|
55
|
+
}
|
|
56
|
+
emitPageChange() {
|
|
57
|
+
this.dispatchEvent(new CustomEvent("page-change", {
|
|
58
|
+
bubbles: !0,
|
|
59
|
+
composed: !0,
|
|
60
|
+
detail: {
|
|
61
|
+
page: this.page,
|
|
62
|
+
pageSize: this.pageSize,
|
|
63
|
+
totalPages: this.totalPages
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
goToPage(t) {
|
|
68
|
+
const e = Math.max(1, Math.min(t, this.totalPages));
|
|
69
|
+
e !== this.page && (this.page = e, this.emitPageChange());
|
|
70
|
+
}
|
|
71
|
+
get pageSizeItems() {
|
|
72
|
+
return this.pageSizeOptions.map((t) => ({
|
|
73
|
+
label: `${t} ${this.perPageLabel}`,
|
|
74
|
+
value: t
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
get selectedPageSizeItem() {
|
|
78
|
+
return [{ label: `${this.pageSize} ${this.perPageLabel}`, value: this.pageSize }];
|
|
79
|
+
}
|
|
80
|
+
getPageNumbers() {
|
|
81
|
+
const t = [], e = this.totalPages, r = this.page, s = 1;
|
|
82
|
+
if (e <= 7)
|
|
83
|
+
for (let l = 1; l <= e; l++) t.push(l);
|
|
84
|
+
else {
|
|
85
|
+
t.push(1), r > 3 && t.push("ellipsis");
|
|
86
|
+
const l = Math.max(2, r - s), g = Math.min(e - 1, r + s);
|
|
87
|
+
for (let d = l; d <= g; d++)
|
|
88
|
+
t.includes(d) || t.push(d);
|
|
89
|
+
r < e - 2 && t.push("ellipsis"), t.includes(e) || t.push(e);
|
|
90
|
+
}
|
|
91
|
+
return t;
|
|
92
|
+
}
|
|
93
|
+
renderNavButtons(t = !1) {
|
|
94
|
+
const e = t ? "pagination__btn--icon" : "pagination__btn";
|
|
95
|
+
return i`
|
|
96
|
+
<div class="pagination__nav-group">
|
|
97
|
+
<button
|
|
98
|
+
type="button"
|
|
99
|
+
class="${e}"
|
|
100
|
+
?disabled=${!this.canGoPrev}
|
|
101
|
+
@click=${this.goFirst}
|
|
102
|
+
aria-label="İlk sayfa"
|
|
103
|
+
>
|
|
104
|
+
<ui-icon name="uil-angle-double-left" size="16"></ui-icon>
|
|
105
|
+
</button>
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
class="${e}"
|
|
109
|
+
?disabled=${!this.canGoPrev}
|
|
110
|
+
@click=${this.goPrev}
|
|
111
|
+
aria-label="Önceki sayfa"
|
|
112
|
+
>
|
|
113
|
+
<ui-icon name="uil-angle-left" size="16"></ui-icon>
|
|
114
|
+
</button>
|
|
115
|
+
</div>
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
renderNavButtonsAfter(t = !1) {
|
|
119
|
+
const e = t ? "pagination__btn--icon" : "pagination__btn";
|
|
120
|
+
return i`
|
|
121
|
+
<div class="pagination__nav-group">
|
|
122
|
+
<button
|
|
123
|
+
type="button"
|
|
124
|
+
class="${e}"
|
|
125
|
+
?disabled=${!this.canGoNext}
|
|
126
|
+
@click=${this.goNext}
|
|
127
|
+
aria-label="Sonraki sayfa"
|
|
128
|
+
>
|
|
129
|
+
<ui-icon name="uil-angle-right" size="16"></ui-icon>
|
|
130
|
+
</button>
|
|
131
|
+
<button
|
|
132
|
+
type="button"
|
|
133
|
+
class="${e}"
|
|
134
|
+
?disabled=${!this.canGoNext}
|
|
135
|
+
@click=${this.goLast}
|
|
136
|
+
aria-label="Son sayfa"
|
|
137
|
+
>
|
|
138
|
+
<ui-icon name="uil-angle-double-right" size="16"></ui-icon>
|
|
139
|
+
</button>
|
|
140
|
+
</div>
|
|
141
|
+
`;
|
|
142
|
+
}
|
|
143
|
+
renderPageInput() {
|
|
144
|
+
return i`
|
|
145
|
+
<div class="pagination__input-container">
|
|
146
|
+
<input
|
|
147
|
+
type="number"
|
|
148
|
+
class="pagination__input"
|
|
149
|
+
.value=${y(this.inputValue)}
|
|
150
|
+
min="1"
|
|
151
|
+
max=${this.totalPages}
|
|
152
|
+
?disabled=${this.disabled}
|
|
153
|
+
@input=${this.handleInputChange}
|
|
154
|
+
@blur=${this.handleInputBlur}
|
|
155
|
+
@keydown=${this.handleInputKeydown}
|
|
156
|
+
aria-label="Sayfa numarası"
|
|
157
|
+
/>
|
|
158
|
+
</div>
|
|
159
|
+
<span class="pagination__separator">/ ${this.totalPages}</span>
|
|
160
|
+
`;
|
|
161
|
+
}
|
|
162
|
+
renderPrevNextButtons() {
|
|
163
|
+
return i`
|
|
164
|
+
<button
|
|
165
|
+
type="button"
|
|
166
|
+
class="pagination__btn--text"
|
|
167
|
+
?disabled=${!this.canGoPrev}
|
|
168
|
+
@click=${this.goPrev}
|
|
169
|
+
>
|
|
170
|
+
<ui-icon name="uil-angle-left" size="16"></ui-icon>
|
|
171
|
+
${this.prevLabel}
|
|
172
|
+
</button>
|
|
173
|
+
<button
|
|
174
|
+
type="button"
|
|
175
|
+
class="pagination__btn--text"
|
|
176
|
+
?disabled=${!this.canGoNext}
|
|
177
|
+
@click=${this.goNext}
|
|
178
|
+
>
|
|
179
|
+
${this.nextLabel}
|
|
180
|
+
<ui-icon name="uil-angle-right" size="16"></ui-icon>
|
|
181
|
+
</button>
|
|
182
|
+
`;
|
|
183
|
+
}
|
|
184
|
+
renderPageInfo() {
|
|
185
|
+
return i`
|
|
186
|
+
<div class="pagination__page-info">
|
|
187
|
+
<span class="pagination__page-info-text">${this.pageLabel} ${this.page}</span>
|
|
188
|
+
<span class="pagination__page-info-separator">/</span>
|
|
189
|
+
<span class="pagination__page-info-text">${this.totalPages}</span>
|
|
190
|
+
</div>
|
|
191
|
+
`;
|
|
192
|
+
}
|
|
193
|
+
renderNumberButtons() {
|
|
194
|
+
const t = this.getPageNumbers();
|
|
195
|
+
return i`
|
|
196
|
+
${t.map(
|
|
197
|
+
(e, r) => e === "ellipsis" ? i`
|
|
198
|
+
<span
|
|
199
|
+
class="pagination__btn--number pagination__btn--ellipsis"
|
|
200
|
+
key="ellipsis-${r}"
|
|
201
|
+
>...</span>
|
|
202
|
+
` : i`
|
|
203
|
+
<button
|
|
204
|
+
type="button"
|
|
205
|
+
class="pagination__btn--number ${e === this.page ? "pagination__btn--active" : ""}"
|
|
206
|
+
?disabled=${this.disabled}
|
|
207
|
+
@click=${() => this.goToPage(e)}
|
|
208
|
+
aria-label="Sayfa ${e}"
|
|
209
|
+
aria-current=${e === this.page ? "page" : p}
|
|
210
|
+
>
|
|
211
|
+
${e}
|
|
212
|
+
</button>
|
|
213
|
+
`
|
|
214
|
+
)}
|
|
215
|
+
`;
|
|
216
|
+
}
|
|
217
|
+
renderPageSizeDropdown() {
|
|
218
|
+
return this.showPageSize ? i`
|
|
219
|
+
<div class="pagination__page-size">
|
|
220
|
+
<logosphere-combobox
|
|
221
|
+
.items=${this.pageSizeItems}
|
|
222
|
+
.disabled=${this.disabled}
|
|
223
|
+
.clearable=${!1}
|
|
224
|
+
optionLabel="label"
|
|
225
|
+
optionValue="value"
|
|
226
|
+
placeholder=""
|
|
227
|
+
@change=${this.handlePageSizeChange}
|
|
228
|
+
></logosphere-combobox>
|
|
229
|
+
</div>
|
|
230
|
+
` : p;
|
|
231
|
+
}
|
|
232
|
+
renderTotalInfo() {
|
|
233
|
+
return this.showTotal ? i`
|
|
234
|
+
<div class="pagination__total">
|
|
235
|
+
<span class="pagination__total-separator">/</span>
|
|
236
|
+
<span class="pagination__total-text">${this.total} ${this.totalLabel}</span>
|
|
237
|
+
</div>
|
|
238
|
+
` : p;
|
|
239
|
+
}
|
|
240
|
+
renderDefault() {
|
|
241
|
+
return i`
|
|
242
|
+
<div class="pagination__nav">
|
|
243
|
+
${this.renderNavButtons()}
|
|
244
|
+
${this.renderPageInput()}
|
|
245
|
+
${this.renderNavButtonsAfter()}
|
|
246
|
+
</div>
|
|
247
|
+
<div class="pagination__info">
|
|
248
|
+
${this.renderPageSizeDropdown()}
|
|
249
|
+
${this.renderTotalInfo()}
|
|
250
|
+
</div>
|
|
251
|
+
`;
|
|
252
|
+
}
|
|
253
|
+
renderPrevNext() {
|
|
254
|
+
return i`
|
|
255
|
+
<div class="pagination__nav" style="gap: 8px;">
|
|
256
|
+
${this.renderPrevNextButtons()}
|
|
257
|
+
</div>
|
|
258
|
+
<div class="pagination__info">
|
|
259
|
+
${this.renderPageInfo()}
|
|
260
|
+
</div>
|
|
261
|
+
`;
|
|
262
|
+
}
|
|
263
|
+
renderPrevNextInverted() {
|
|
264
|
+
return i`
|
|
265
|
+
<div class="pagination__info">
|
|
266
|
+
${this.renderPageInfo()}
|
|
267
|
+
</div>
|
|
268
|
+
<div class="pagination__nav" style="gap: 8px;">
|
|
269
|
+
${this.renderPrevNextButtons()}
|
|
270
|
+
</div>
|
|
271
|
+
`;
|
|
272
|
+
}
|
|
273
|
+
renderPrevNextOnly() {
|
|
274
|
+
return i`
|
|
275
|
+
<div class="pagination__nav" style="gap: 8px; margin-left: auto;">
|
|
276
|
+
${this.renderPrevNextButtons()}
|
|
277
|
+
</div>
|
|
278
|
+
`;
|
|
279
|
+
}
|
|
280
|
+
renderNumberButtonsVariant() {
|
|
281
|
+
return i`
|
|
282
|
+
<div class="pagination__nav">
|
|
283
|
+
${this.renderNavButtons(!0)}
|
|
284
|
+
${this.renderNumberButtons()}
|
|
285
|
+
${this.renderNavButtonsAfter(!0)}
|
|
286
|
+
</div>
|
|
287
|
+
<div class="pagination__info">
|
|
288
|
+
${this.renderPageSizeDropdown()}
|
|
289
|
+
${this.renderTotalInfo()}
|
|
290
|
+
</div>
|
|
291
|
+
`;
|
|
292
|
+
}
|
|
293
|
+
render() {
|
|
294
|
+
const t = this.variant === "prev-next-only" ? "pagination--justify-end" : "";
|
|
295
|
+
return i`
|
|
296
|
+
<nav
|
|
297
|
+
class="pagination ${t}"
|
|
298
|
+
role="navigation"
|
|
299
|
+
aria-label="Sayfalama"
|
|
300
|
+
>
|
|
301
|
+
${this.variant === "default" ? this.renderDefault() : p}
|
|
302
|
+
${this.variant === "prev-next" ? this.renderPrevNext() : p}
|
|
303
|
+
${this.variant === "prev-next-inverted" ? this.renderPrevNextInverted() : p}
|
|
304
|
+
${this.variant === "prev-next-only" ? this.renderPrevNextOnly() : p}
|
|
305
|
+
${this.variant === "number-buttons" ? this.renderNumberButtonsVariant() : p}
|
|
306
|
+
</nav>
|
|
307
|
+
`;
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
c.styles = [v`${b(x)}`];
|
|
311
|
+
let a = c;
|
|
312
|
+
n([
|
|
313
|
+
o({ type: String })
|
|
314
|
+
], a.prototype, "variant");
|
|
315
|
+
n([
|
|
316
|
+
o({ type: Number })
|
|
317
|
+
], a.prototype, "page");
|
|
318
|
+
n([
|
|
319
|
+
o({ type: Number })
|
|
320
|
+
], a.prototype, "pageSize");
|
|
321
|
+
n([
|
|
322
|
+
o({ type: Number })
|
|
323
|
+
], a.prototype, "total");
|
|
324
|
+
n([
|
|
325
|
+
o({ type: Array })
|
|
326
|
+
], a.prototype, "pageSizeOptions");
|
|
327
|
+
n([
|
|
328
|
+
o({ type: Boolean })
|
|
329
|
+
], a.prototype, "showPageSize");
|
|
330
|
+
n([
|
|
331
|
+
o({ type: Boolean })
|
|
332
|
+
], a.prototype, "showTotal");
|
|
333
|
+
n([
|
|
334
|
+
o({ type: Boolean })
|
|
335
|
+
], a.prototype, "disabled");
|
|
336
|
+
n([
|
|
337
|
+
o({ type: String })
|
|
338
|
+
], a.prototype, "prevLabel");
|
|
339
|
+
n([
|
|
340
|
+
o({ type: String })
|
|
341
|
+
], a.prototype, "nextLabel");
|
|
342
|
+
n([
|
|
343
|
+
o({ type: String })
|
|
344
|
+
], a.prototype, "pageLabel");
|
|
345
|
+
n([
|
|
346
|
+
o({ type: String })
|
|
347
|
+
], a.prototype, "perPageLabel");
|
|
348
|
+
n([
|
|
349
|
+
o({ type: String })
|
|
350
|
+
], a.prototype, "totalLabel");
|
|
351
|
+
n([
|
|
352
|
+
f()
|
|
353
|
+
], a.prototype, "inputValue");
|
|
354
|
+
n([
|
|
355
|
+
_("logosphere-combobox")
|
|
356
|
+
], a.prototype, "_combobox");
|
|
357
|
+
customElements.get("logosphere-pagination") || customElements.define("logosphere-pagination", a);
|
|
358
|
+
export {
|
|
359
|
+
a as P
|
|
360
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./pagination-AclB9qi1.cjs");exports.Pagination=i.Pagination;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logosphere-ui/core",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.33",
|
|
4
4
|
"description": "A modern, framework-agnostic UI component library built with Lit and Web Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -76,6 +76,11 @@
|
|
|
76
76
|
"import": "./dist/input.js",
|
|
77
77
|
"require": "./dist/input.cjs"
|
|
78
78
|
},
|
|
79
|
+
"./pagination": {
|
|
80
|
+
"types": "./dist/molecules/Pagination/index.d.ts",
|
|
81
|
+
"import": "./dist/pagination.js",
|
|
82
|
+
"require": "./dist/pagination.cjs"
|
|
83
|
+
},
|
|
79
84
|
"./formfield": {
|
|
80
85
|
"types": "./dist/atoms/FormField/index.d.ts",
|
|
81
86
|
"import": "./dist/formfield.js",
|