Selaa lähdekoodia

Update v0.1.3

杜府 3 vuotta sitten
vanhempi
sitoutus
36abe978e0

+ 1 - 1
components/package.json

@@ -1,6 +1,6 @@
 {
     "name": "stdf",
-    "version": "0.1.2",
+    "version": "0.1.3",
     "description": "Mobile Web component library based on Svelte and Tailwind",
     "main": "index.js",
     "scripts": {

+ 12 - 8
components/src/pagination/Pagination.svelte

@@ -64,6 +64,10 @@
     // only one page text
     export let onePageText = paginationLang.defaultOnlyOnePage;
 
+    // 连续模式
+    // continuous mode
+    export let continuous = false;
+
     // 总页数
     // totalPage
     $: totalPage = Math.ceil(total / pageSize);
@@ -235,19 +239,19 @@
         <div class="flex-1 py-2 border border-transparent">{onePageText}</div>
     {:else if totalPage > 1 && totalPage <= maxShowPage}
         {#each new Array(totalPage) as item, index}
-            <Page active={current === index + 1} {type} {radius} on:click={() => clickItemFunc(index + 1)}>
+            <Page active={current === index + 1} {type} {radius} on:click={() => !continuous && clickItemFunc(index + 1)}>
                 {index + 1}
             </Page>
         {/each}
     {:else}
-        <Page active={current === 1} {type} {radius} on:click={() => clickItemFunc(1)}>1</Page>
+        <Page active={current === 1} {type} {radius} on:click={() => !continuous && clickItemFunc(1)}>1</Page>
         {#if showPreEllipsis}
             <!-- svelte-ignore a11y-click-events-have-key-events -->
             <div
                 class="flex-1 py-2 border {showPreOmitPage
                     ? typeClass[type] || typeClass.border
                     : 'border-transparent' + (type === 'bold' ? ' opacity-50' : '')} {radiusClass[radius] || radiusClass.base}"
-                on:click={clickPreEllipsisFunc}
+                on:click={!continuous && clickPreEllipsisFunc}
             >
                 {#if type === 'bold' && showPreOmitPage}
                     <Icon name="ri-more-fill" size={18} />
@@ -258,14 +262,14 @@
         {/if}
         {#if !showPreEllipsis && current <= maxShowPage - 1}
             {#each new Array(maxShowPage - 3) as item, index}
-                <Page active={current === index + 2} {type} {radius} on:click={() => clickItemFunc(index + 2)}>
+                <Page active={current === index + 2} {type} {radius} on:click={() => !continuous && clickItemFunc(index + 2)}>
                     {index + 2}
                 </Page>
             {/each}
         {/if}
         {#if middleShowPage.length > 0}
             {#each middleShowPage as item, index}
-                <Page active={index === (middleShowPage.length - 1) / 2} {type} {radius} on:click={() => clickItemFunc(item)}>
+                <Page active={index === (middleShowPage.length - 1) / 2} {type} {radius} on:click={() => !continuous && clickItemFunc(item)}>
                     {item}
                 </Page>
             {/each}
@@ -276,7 +280,7 @@
                     active={current === totalPage + index + 3 - maxShowPage}
                     {type}
                     {radius}
-                    on:click={() => clickItemFunc(totalPage + index + 3 - maxShowPage)}
+                    on:click={() => !continuous && clickItemFunc(totalPage + index + 3 - maxShowPage)}
                 >
                     {totalPage + index + 3 - maxShowPage}
                 </Page>
@@ -288,7 +292,7 @@
                 class="flex-1 py-2 border {showNextOmitPage
                     ? typeClass[type] || typeClass.border
                     : 'border-transparent' + (type === 'bold' ? ' opacity-50' : '')} {radiusClass[radius] || radiusClass.base}"
-                on:click={clickNextEllipsisFunc}
+                on:click={!continuous && clickNextEllipsisFunc}
             >
                 {#if type === 'bold' && showNextOmitPage}
                     <Icon name="ri-more-fill" size={18} />
@@ -297,7 +301,7 @@
                 {/if}
             </div>
         {/if}
-        <Page active={current === totalPage} {type} {radius} on:click={() => clickItemFunc(totalPage)}>{totalPage}</Page>
+        <Page active={current === totalPage} {type} {radius} on:click={() => !continuous && clickItemFunc(totalPage)}>{totalPage}</Page>
     {/if}
     <!-- svelte-ignore a11y-click-events-have-key-events -->
     <div

+ 1 - 1
demo/package.json

@@ -13,7 +13,7 @@
         "@sveltejs/vite-plugin-svelte": "^2.0.2",
         "autoprefixer": "^10.4.13",
         "postcss": "^8.4.19",
-        "stdf": "^0.1.2",
+        "stdf": "^0.1.3",
         "svelte": "^3.55.1",
         "svelte-spa-router": "^3.3.0",
         "tailwindcss": "^3.2.4",

+ 4 - 0
demo/src/pages/pagination/PaginationDemo.svelte

@@ -124,4 +124,8 @@
 </div>
 <Pagination {pageSize} total={totalData} on:change={changePageFunc} />
 
+<div class="mx-4 mt-8 font-bold text-lg">连续模式</div>
+<div class="mx-4 mb-4 text-xs">只允许点击上下页</div>
+<Pagination {total} continuous />
+
 <div class="pb-10" />

+ 4 - 0
demo/src/pages/pagination/PaginationDemo_en.svelte

@@ -124,4 +124,8 @@
 </div>
 <Pagination {pageSize} total={totalData} on:change={changePageFunc} />
 
+<div class="mx-4 mt-8 font-bold text-lg">Continuous mode</div>
+<div class="mx-4 mb-4 text-xs">Only click on the previous page and next page</div>
+<Pagination {total} continuous />
+
 <div class="pb-10" />

+ 1 - 0
doc/components/pagination/api.md

@@ -14,6 +14,7 @@
 | injClass         | String  | ''                                       | Class                               | N    | 注入 CSS 名称。。    |
 | noDataText       | String  | 当前语言的 common.noData                 | -                                   | N    | 无数据显示文本。     |
 | onePageText      | String  | 当前语言的 pagination.defaultOnlyOnePage | -                                   | N    | 仅一页显示文本。     |
+| continuous       | Boolean | false                                    | true/false                          | N    | 是否是连续模式。     |
 
 ## Pagination Events
 

+ 1 - 0
doc/components/pagination/api_en.md

@@ -14,6 +14,7 @@
 | injClass         | String  | ''                                             | Class                               | N        | Injected CSS class name.                                         |
 | noDataText       | String  | Current language common.noData                 | -                                   | N        | Text to display when there is no data.                           |
 | onePageText      | String  | Current language pagination.defaultOnlyOnePage | -                                   | N        | Text to display when there is only one page.                     |
+| continuous       | Boolean | false                                          | true/false                          | N        | Whether it is a continuous mode.                                 |
 
 ## Pagination Events
 

+ 3 - 1
doc/components/pagination/guide.md

@@ -1,11 +1,13 @@
 ## 设计思路
 
-私以为,分页不应该是上滑加载下一页,这种交互会让用户无心理预期而产生不适,所以 STDF 的分页组件交互满足以下几个条件:
+私以为,分页不应该是上滑加载下一页,这种交互会让用户无心理预期而产生不适,所以 STDF 的分页组件交互默认满足以下几个条件:
 
 -   页码变化事件必须是用户主动触发。
 -   无论何时都须同时显示上一页、下一页、首页、尾页、当前页,用户对全部数据有预期且可直接点击跳转到这些关键页码。
 -   移动端横向显示区域有限,即便如此,也可以通过点击省略页码跳转到任意页码。
 
+当然,你也可以配置为**连续模式**,即只允许点击上一页、下一页,比如一些后端接口必须根据上一页数据查询下一页数据的情况。但这样无疑会降低用户体验。
+
 ## 事件监听
 
 Pagination 组件对外暴露了三个事件:change、next、pre,分别对应页码变化、下一页、上一页。next 和 pre 事件同时也会触发 change 事件,请按需监听。

+ 3 - 1
doc/components/pagination/guide_en.md

@@ -1,11 +1,13 @@
 ## Design Concept
 
-In my opinion, pagination should not be based on scrolling up to load the next page. This interaction can cause user uncomfortable as there is no psychological expectation. Therefore, the STDF pagination component should meet the following conditions:
+In my opinion, pagination should not be based on scrolling up to load the next page. This interaction can cause user uncomfortable as there is no psychological expectation. Therefore, the STDF pagination component meet the following conditions by default:
 
 -   The page change event must be triggered by the user.
 -   The previous page, next page, first page, last page, and current page must always be displayed, and the user can directly click to jump to these key page numbers.
 -   On mobile devices, the horizontal display area is limited. Nevertheless, users can still click on the ellipsis to jump to any page number.
 
+Of course, you can also configure it to **continuous mode**, that is, you are only allowed to click on the previous page and the next page. For example, some backend APIs must query the next page of data based on the previous page. But this will undoubtedly reduce the user experience.
+
 ## Event Listening
 
 The Pagination component exposes three events to the outside: change, next, and pre, corresponding to page number changes, next page, and previous page, respectively. The next and pre events will also trigger the change event, so listen as needed.

+ 6 - 0
doc/components/pagination/version.md

@@ -14,6 +14,12 @@
 
 <font size=1>2022-07-18</font> -->
 
+## 0.1.3
+
+-   [!tag|A|0|]支持是否使用连续模式,即只允许点击上一页、下一页。
+
+<font size=1>2023-07-16</font>
+
 ## 0.1.2
 
 -   [!tag|O|0|]细节优化。当 type 为 bold 且展开此省略页码时,省略号 Icon 也会加粗,使其与高亮页码文字样式逻辑匹配。

+ 6 - 0
doc/components/pagination/version_en.md

@@ -14,6 +14,12 @@
 
 <font size=1>2022-07-18</font> -->
 
+## 0.1.3
+
+-   [!tag|A|0|]Supports whether to use continuous mode, that is, only allows clicking the previous page and the next page.
+
+<font size=1>2023-07-16</font>
+
 ## 0.1.2
 
 -   [!tag|O|0|]Fine-tune details. When type is set to bold and the ellipsis page numbers are expanded, the ellipsis icon will also be bold, matching the style logic of the highlighted page number text.

+ 4 - 0
doc/guide/changelog.md

@@ -1,3 +1,7 @@
+## 0.1.3
+
+-   Pagination 新增 Props。详见 [Pagination](https://stdf.design/#/components?nav=pagination&tab=4)。
+
 ## 0.1.2
 
 -   Pagination 细节优化。详见 [Pagination](https://stdf.design/#/components?nav=pagination&tab=4)。

+ 4 - 0
doc/guide/changelog_en.md

@@ -1,3 +1,7 @@
+## 0.1.3
+
+-   Pagination add Props. Please see [Pagination](https://stdf.design/#/components?nav=pagination&tab=4).
+
 ## 0.1.2
 
 -   Pagination fine-tuning. Please see [Pagination](https://stdf.design/#/components?nav=pagination&tab=4).