nicklabs-ui 1.0.104 → 1.0.106
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/README.md +60 -3
- package/dist/index.mjs +993 -908
- package/dist/nicklabs-ui.css +1 -1
- package/dist/src/components/NList.vue.d.ts +21 -3
- package/dist/src/components/NTable.vue.d.ts +21 -2
- package/dist/src/types/components/table.d.ts +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A Vue 3 component library with glassmorphism design, built for modern web applications.
|
|
4
4
|
|
|
5
|
-
**Version**: 1.0.
|
|
5
|
+
**Version**: 1.0.106 | **Framework**: Vue 3.5+
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -880,6 +880,8 @@ A type-safe, sortable data table with support for batch selection and action slo
|
|
|
880
880
|
| `emptyTitle` | `string` | `"目前沒有資料"` | Title when no data |
|
|
881
881
|
| `emptyDescription` | `string` | — | Description when no data |
|
|
882
882
|
| `itemKey` | `string` | `"id"` | Unique key field |
|
|
883
|
+
| `stickyActions` | `boolean` | `false` | Pin the actions column to the right edge during horizontal scroll. Also pinned automatically when any column has `sticky: true` |
|
|
884
|
+
| `stickyBatch` | `boolean` | `false` | Pin the leftmost batch column to the left edge during horizontal scroll |
|
|
883
885
|
|
|
884
886
|
**Events**
|
|
885
887
|
|
|
@@ -894,7 +896,8 @@ A type-safe, sortable data table with support for batch selection and action slo
|
|
|
894
896
|
|------|-------------|
|
|
895
897
|
| `batch` | Content in the batch selection header column |
|
|
896
898
|
| `actions-header` | Custom header text for the actions column (default: "操作") |
|
|
897
|
-
| `
|
|
899
|
+
| `item` | Custom cell renderer for a row (scoped: `{ item, index, sticky }`). Render one `<td>` per column; for a sticky column, spread `v-bind="sticky(columnKey)"` onto its `<td>` |
|
|
900
|
+
| `actions` | Custom action buttons per row (scoped: `{ item, index }`) |
|
|
898
901
|
| `empty` | Custom empty state content |
|
|
899
902
|
|
|
900
903
|
**NTableColumn Interface**
|
|
@@ -904,9 +907,47 @@ interface NTableColumn {
|
|
|
904
907
|
key: string // Data field key
|
|
905
908
|
label: string // Column header text
|
|
906
909
|
sortable?: boolean
|
|
910
|
+
sticky?: boolean // Pin this column to the right edge (header + actions pinned together)
|
|
907
911
|
}
|
|
908
912
|
```
|
|
909
913
|
|
|
914
|
+
**Sticky columns**
|
|
915
|
+
|
|
916
|
+
For wide tables that scroll horizontally, mark columns with `sticky: true` to pin them to the right edge. The actions column is pinned automatically whenever any column is sticky (or set `stickyActions` to pin only the actions column). Offsets are measured at runtime, so columns can be any width.
|
|
917
|
+
|
|
918
|
+
The header `<th>` is pinned by the component, but the body `<td>` is rendered by you in the `item` slot — so the slot exposes a `sticky(key)` helper that returns the binding to spread onto the matching `<td>`:
|
|
919
|
+
|
|
920
|
+
```vue
|
|
921
|
+
<template>
|
|
922
|
+
<NTable :columns="columns" :items="rows" sticky-actions>
|
|
923
|
+
<template #item="{ item, sticky }">
|
|
924
|
+
<td>{{ item.name }}</td>
|
|
925
|
+
<td>{{ item.email }}</td>
|
|
926
|
+
<td>{{ item.phone }}</td>
|
|
927
|
+
<!-- Sticky cells: spread the binding so the body cell pins with its header -->
|
|
928
|
+
<td v-bind="sticky('role')">{{ item.role }}</td>
|
|
929
|
+
<td v-bind="sticky('status')">{{ item.status }}</td>
|
|
930
|
+
</template>
|
|
931
|
+
|
|
932
|
+
<template #actions>
|
|
933
|
+
<NButton size="sm" variant="ghost" intent="primary">Edit</NButton>
|
|
934
|
+
</template>
|
|
935
|
+
</NTable>
|
|
936
|
+
</template>
|
|
937
|
+
|
|
938
|
+
<script setup lang="ts">
|
|
939
|
+
import type { NTableColumn } from 'nicklabs-ui'
|
|
940
|
+
|
|
941
|
+
const columns: NTableColumn[] = [
|
|
942
|
+
{ key: 'name', label: 'Name' },
|
|
943
|
+
{ key: 'email', label: 'Email' },
|
|
944
|
+
{ key: 'phone', label: 'Phone' },
|
|
945
|
+
{ key: 'role', label: 'Role', sticky: true }, // pinned right
|
|
946
|
+
{ key: 'status', label: 'Status', sticky: true }, // pinned right
|
|
947
|
+
]
|
|
948
|
+
</script>
|
|
949
|
+
```
|
|
950
|
+
|
|
910
951
|
**Usage**
|
|
911
952
|
|
|
912
953
|
```vue
|
|
@@ -1111,6 +1152,8 @@ A full-featured data management component combining table, pagination, filtering
|
|
|
1111
1152
|
| `emptyTitle` | `string` | `"目前沒有資料"` | Empty state title |
|
|
1112
1153
|
| `emptyDescription` | `string` | `"可以點擊上方的按鈕來新增資料或重新整理"` | Empty state description |
|
|
1113
1154
|
| `emptyIcon` | `string` | — | Custom SVG string for empty state |
|
|
1155
|
+
| `stickyActions` | `boolean` | `false` | Pin the actions column to the right edge. Also pinned automatically when any column has `sticky: true` |
|
|
1156
|
+
| `stickyBatch` | `boolean` | `false` | Pin the leftmost batch (select-all) column to the left edge (requires `batchDeletable`) |
|
|
1114
1157
|
|
|
1115
1158
|
**Events**
|
|
1116
1159
|
|
|
@@ -1131,7 +1174,7 @@ A full-featured data management component combining table, pagination, filtering
|
|
|
1131
1174
|
| Slot | Description |
|
|
1132
1175
|
|------|-------------|
|
|
1133
1176
|
| `toolbar` | Extra toolbar content (alongside create/refresh buttons) |
|
|
1134
|
-
| `item` | Custom cell renderer (scoped: `{ item,
|
|
1177
|
+
| `item` | Custom cell renderer (scoped: `{ item, index, sticky }`). For a sticky column, spread `v-bind="sticky(columnKey)"` onto its `<td>` |
|
|
1135
1178
|
| `actions` | Custom action buttons per row (scoped: `{ item, index }`) |
|
|
1136
1179
|
| `actions-header` | Custom header text for the actions column |
|
|
1137
1180
|
|
|
@@ -1169,6 +1212,19 @@ interface User {
|
|
|
1169
1212
|
</script>
|
|
1170
1213
|
```
|
|
1171
1214
|
|
|
1215
|
+
> **Sticky columns.** NList renders through [NTable](#ntable), so the same sticky behavior applies. Mark trailing columns with `sticky: true` to pin them right (the actions column follows automatically), and set `stickyBatch` to pin the select-all checkbox column left. The `item` slot exposes a `sticky(key)` helper — spread `v-bind="sticky(columnKey)"` onto the matching `<td>`:
|
|
1216
|
+
>
|
|
1217
|
+
> ```vue
|
|
1218
|
+
> <NList :items="users" :columns="columns" updatable deletable batch-deletable sticky-batch>
|
|
1219
|
+
> <template #item="{ item, sticky }">
|
|
1220
|
+
> <td>{{ item.name }}</td>
|
|
1221
|
+
> <td>{{ item.email }}</td>
|
|
1222
|
+
> <td v-bind="sticky('role')">{{ item.role }}</td>
|
|
1223
|
+
> </template>
|
|
1224
|
+
> </NList>
|
|
1225
|
+
> <!-- columns: [..., { key: 'role', label: 'Role', sticky: true }] -->
|
|
1226
|
+
> ```
|
|
1227
|
+
|
|
1172
1228
|
---
|
|
1173
1229
|
|
|
1174
1230
|
#### NTag
|
|
@@ -2289,6 +2345,7 @@ interface NTableColumn {
|
|
|
2289
2345
|
key: string
|
|
2290
2346
|
label: string
|
|
2291
2347
|
sortable?: boolean
|
|
2348
|
+
sticky?: boolean // Pin this column to the right edge on horizontal scroll
|
|
2292
2349
|
}
|
|
2293
2350
|
|
|
2294
2351
|
type NTableSortOrder = 'asc' | 'desc' | null
|