@pan-stack/ui 0.0.0-stage → 0.2.31
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/LICENSE.txt +41 -0
- package/README.md +7 -2
- package/dist/hooks.d.ts +190 -0
- package/dist/hooks.js +1 -0
- package/dist/i18n/locales/common/ar.json +171 -0
- package/dist/i18n/locales/common/de.json +171 -0
- package/dist/i18n/locales/common/en.json +171 -0
- package/dist/i18n/locales/common/es.json +171 -0
- package/dist/i18n/locales/common/fr.json +171 -0
- package/dist/i18n/locales/common/hi.json +171 -0
- package/dist/i18n/locales/common/id.json +171 -0
- package/dist/i18n/locales/common/it.json +171 -0
- package/dist/i18n/locales/common/ja.json +171 -0
- package/dist/i18n/locales/common/ko.json +171 -0
- package/dist/i18n/locales/common/pt-BR.json +171 -0
- package/dist/i18n/locales/common/ru.json +171 -0
- package/dist/i18n/locales/common/th.json +171 -0
- package/dist/i18n/locales/common/tr.json +171 -0
- package/dist/i18n/locales/common/vi.json +171 -0
- package/dist/i18n/locales/common/zh-CN.json +171 -0
- package/dist/index.d.ts +4428 -0
- package/dist/index.js +20 -0
- package/dist/lib.d.ts +107 -0
- package/dist/lib.js +1 -0
- package/dist/new-types.d.ts +200 -0
- package/dist/styles/globals.css +808 -0
- package/package.json +115 -4
- package/postcss.config.mjs +6 -0
- package/shims/next-link.js +1 -0
- package/shims/next-navigation.js +1 -0
package/dist/lib.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { i18n, Resource } from 'i18next';
|
|
2
|
+
export { i18n as I18n, default as i18n } from 'i18next';
|
|
3
|
+
export { I18nextProvider } from 'react-i18next';
|
|
4
|
+
import { VisibilityState, ColumnFiltersState, PaginationState, SortingState } from '@tanstack/react-table';
|
|
5
|
+
import { ClassValue } from 'clsx';
|
|
6
|
+
|
|
7
|
+
declare function slugify(title: unknown): string;
|
|
8
|
+
declare function stringToFilterString(title: string): string;
|
|
9
|
+
declare function numberToVietnameseText(value: number | string, unit?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Chuyển tên tiếng Việt thành mã code (A-Z, 0-9, _).
|
|
12
|
+
* Bỏ dấu đúng cách để không mất chữ (ví dụ: "Cơ quan tiến hành tố dụng" → "CO_QUAN_TIEN_HANH_TO_DUNG").
|
|
13
|
+
*/
|
|
14
|
+
declare function vietnameseNameToCode(name: string, maxLength?: number): string;
|
|
15
|
+
declare function filterSelectOptions(input: string, option: {
|
|
16
|
+
label: unknown;
|
|
17
|
+
}): boolean;
|
|
18
|
+
declare const repairOptions: (options: {
|
|
19
|
+
label: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}[], request: boolean, keyword: string) => {
|
|
22
|
+
label: string;
|
|
23
|
+
value: string;
|
|
24
|
+
}[];
|
|
25
|
+
declare const lowerCaseFirstLetter: (str: string) => string;
|
|
26
|
+
|
|
27
|
+
declare const defaultNS = "common";
|
|
28
|
+
declare const fallbackLng = "vi";
|
|
29
|
+
declare const supportedLngs: string[];
|
|
30
|
+
declare function createI18nInstance(lng?: string, loadPath?: string): i18n;
|
|
31
|
+
/**
|
|
32
|
+
* Factory cho app HOST đã có resource tĩnh sẵn trong bundle (không cần fetch HTTP như
|
|
33
|
+
* `createI18nInstance`) — dùng khi app tự merge resource JSON của mình (namespace riêng) rồi truyền
|
|
34
|
+
* vào đây, thay vì tự `import i18next from 'i18next'` + `initReactI18next` trực tiếp. Đây là điểm
|
|
35
|
+
* duy nhất app host cần gọi để KHÔNG phải khai `i18next`/`react-i18next` trong package.json của
|
|
36
|
+
* mình — DS là nơi sở hữu 2 lib này.
|
|
37
|
+
*
|
|
38
|
+
* Interpolation dùng mặc định `{{var}}` (chuẩn i18next) — khác `createI18nInstance` (dùng `{var}`
|
|
39
|
+
* cho HTTP backend load trực tiếp file JSON gốc chưa qua adapt).
|
|
40
|
+
*/
|
|
41
|
+
declare function createStaticI18nInstance(config: {
|
|
42
|
+
resources: Resource;
|
|
43
|
+
lng: string;
|
|
44
|
+
defaultNS?: string;
|
|
45
|
+
ns?: string[];
|
|
46
|
+
}): i18n;
|
|
47
|
+
|
|
48
|
+
interface TableState {
|
|
49
|
+
keyword: string;
|
|
50
|
+
filter: ColumnFiltersState;
|
|
51
|
+
sorting: SortingState;
|
|
52
|
+
pagination: PaginationState;
|
|
53
|
+
columnVisibility?: VisibilityState;
|
|
54
|
+
uiState?: UiState;
|
|
55
|
+
sortFilter?: string[];
|
|
56
|
+
}
|
|
57
|
+
/** Dạng xem của cùng MỘT bảng: hàng bảng (`table`) hay thẻ (`cards`). */
|
|
58
|
+
type DataViewMode = 'table' | 'cards';
|
|
59
|
+
interface UiState {
|
|
60
|
+
showTime?: boolean;
|
|
61
|
+
showAdvancedFilter?: boolean;
|
|
62
|
+
showColumnFilter?: boolean;
|
|
63
|
+
density?: 'small' | 'middle' | 'large' | 'xlarge';
|
|
64
|
+
/**
|
|
65
|
+
* Dạng xem đang chọn. Chỉ có tác dụng khi `<DataTable cards={…}>` — không khai `cards` thì
|
|
66
|
+
* bảng chỉ có một dạng và khóa này bị bỏ qua. Lưu cùng `uiState` (localStorage theo `pageName`)
|
|
67
|
+
* nên người dùng chọn một lần là nhớ, giống `density`.
|
|
68
|
+
*/
|
|
69
|
+
view?: DataViewMode;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Serialize table state to URL query parameters
|
|
73
|
+
*/
|
|
74
|
+
declare function serializeTableState(state: TableState): URLSearchParams;
|
|
75
|
+
declare const DEFAULT_PAGE_SIZE = 10;
|
|
76
|
+
declare const DEFAULT_UI_STATE: UiState;
|
|
77
|
+
declare const DEFAULT_SORTING: SortingState;
|
|
78
|
+
declare const DEFAULT_FILTER: ColumnFiltersState;
|
|
79
|
+
declare const DEFAULT_COLUMN_VISIBILITY: VisibilityState;
|
|
80
|
+
declare const DEFAULT_PAGINATION: PaginationState;
|
|
81
|
+
declare const DEFAULT_TABLE_STATE: TableState;
|
|
82
|
+
/**
|
|
83
|
+
* Deserialize URL query parameters to table state
|
|
84
|
+
*/
|
|
85
|
+
declare function deserializeTableState(searchParams: URLSearchParams, defaultState?: TableState): TableState;
|
|
86
|
+
/**
|
|
87
|
+
* Generate localStorage key for table state
|
|
88
|
+
*/
|
|
89
|
+
declare function getTableStateKey(pageName: string, keyObject?: Record<string, string | number>): string;
|
|
90
|
+
/**
|
|
91
|
+
* Save table state to localStorage
|
|
92
|
+
*/
|
|
93
|
+
declare function saveTableStateToLocalStorage(pageName: string, keyObject: Record<string, string | number> | undefined, state: TableState): void;
|
|
94
|
+
/**
|
|
95
|
+
* Load table state from localStorage
|
|
96
|
+
*/
|
|
97
|
+
declare function loadTableStateFromLocalStorage(pageName: string, keyObject: Record<string, string | number> | undefined): TableState | null;
|
|
98
|
+
/**
|
|
99
|
+
* Clear table state from localStorage
|
|
100
|
+
*/
|
|
101
|
+
declare function clearTableStateFromLocalStorage(pageName: string, keyObject: Record<string, string | number> | undefined): void;
|
|
102
|
+
declare function clearAllTableStateFromLocalStorage(): void;
|
|
103
|
+
|
|
104
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
105
|
+
|
|
106
|
+
export { DEFAULT_COLUMN_VISIBILITY, DEFAULT_FILTER, DEFAULT_PAGE_SIZE, DEFAULT_PAGINATION, DEFAULT_SORTING, DEFAULT_TABLE_STATE, DEFAULT_UI_STATE, clearAllTableStateFromLocalStorage, clearTableStateFromLocalStorage, cn, createI18nInstance, createStaticI18nInstance, defaultNS, deserializeTableState, fallbackLng, filterSelectOptions, getTableStateKey, loadTableStateFromLocalStorage, lowerCaseFirstLetter, numberToVietnameseText, repairOptions, saveTableStateToLocalStorage, serializeTableState, slugify, stringToFilterString, supportedLngs, vietnameseNameToCode };
|
|
107
|
+
export type { DataViewMode, TableState, UiState };
|
package/dist/lib.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{doReadNumber as U,ReadingConfig as y}from"read-vietnamese-number";import C from"slugify";var h=new y;h.unit=["\u0111\u1ED3ng"];function D(t){return C(typeof t=="string"?t:"",{lower:!0,strict:!0})}function d(t){let r;return r=t.normalize("NFC").toLowerCase().trim(),r=r.replace(/á|à|ả|ạ|ã|ă|ắ|ằ|ẳ|ẵ|ặ|â|ấ|ầ|ẩ|ẫ|ậ/gi,"a"),r=r.replace(/é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ/gi,"e"),r=r.replace(/i|í|ì|ỉ|ĩ|ị/gi,"i"),r=r.replace(/ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ/gi,"o"),r=r.replace(/ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự/gi,"u"),r=r.replace(/ý|ỳ|ỷ|ỹ|ỵ/gi,"y"),r=r.replace(/đ/gi,"d"),r=r.replace(/\s\s+/g," "),r}function O(t,r){let e=new y;e.unit=[r??"\u0111\u1ED3ng"];let o=U(`${t}`,e);return o.length>0?(o[0]?.toUpperCase()??"")+o.slice(1):""}function k(t,r=50){if(!t||typeof t!="string")return"";let e=t.normalize("NFC").toLowerCase().trim();return e=e.replace(/á|à|ả|ạ|ã|ă|ắ|ằ|ẳ|ẵ|ặ|â|ấ|ầ|ẩ|ẫ|ậ/g,"a"),e=e.replace(/é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ/g,"e"),e=e.replace(/i|í|ì|ỉ|ĩ|ị/g,"i"),e=e.replace(/ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ/g,"o"),e=e.replace(/ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự/g,"u"),e=e.replace(/ý|ỳ|ỷ|ỹ|ỵ/g,"y"),e=e.replace(/đ/g,"d"),e=e.replace(/[^a-z0-9\s]/g,"").replace(/\s+/g," ").trim(),e.toUpperCase().replace(/\s+/g,"_").substring(0,r)}function I(t,r){let o=(typeof r?.label=="string"?r.label:String(r?.label??"")).normalize("NFC").toLowerCase();return o.indexOf(t.toLowerCase())>=0||d(o).indexOf(d(t).toLowerCase())>=0}var _=(t,r,e)=>!t||t.length===0?[]:r?t:t.filter(a=>{let n=a.label!==null?a.label:"-";return I(e,{label:n})}),R=t=>t?.charAt(0)?.toLocaleLowerCase()+t?.slice(1);import b from"i18next";import V from"i18next-http-backend";import{initReactI18next as L}from"react-i18next";var c="common",g="vi",w=["vi","en"];function $(t=g,r="/locales/{{ns}}/{{lng}}.json"){let e=b.createInstance();return e.use(V).use(L).init({lng:t,fallbackLng:g,defaultNS:c,supportedLngs:w,ns:[c],backend:{loadPath:r},interpolation:{prefix:"{",suffix:"}",escapeValue:!1}}),e}function z(t){let r=b.createInstance();return r.use(L).init({resources:t.resources,lng:t.lng,fallbackLng:g,defaultNS:t.defaultNS??"translation",ns:t.ns??[t.defaultNS??"translation",c],interpolation:{escapeValue:!1}}),r}import{I18nextProvider as ge}from"react-i18next";function j(t){let r=new URLSearchParams;if(r.set("page",String(t.pagination.pageIndex+1)),r.set("pageSize",String(t.pagination.pageSize)),t.sorting.length>0){let e=t.sorting[0];e&&(r.set("sortBy",e.id),r.set("sortDir",e.desc?"desc":"asc"))}return t.keyword&&r.set("keyword",t.keyword),t.filter.forEach(e=>{if(Array.isArray(e.value))e.value.length>0&&typeof e.value[0]=="object"&&e.value[0]!==null&&"value"in e.value[0]&&"label"in e.value[0]?r.set(`filter[${e.id}]`,`combobox:${JSON.stringify(e.value)}`):r.set(`filter[${e.id}]`,e.value.join(","));else if(typeof e.value=="string"&&e.value)r.set(`filter[${e.id}]`,e.value);else if(e.value&&typeof e.value=="object"&&"from"in e.value){let o=e.value;if(o.from){let a=typeof o.from=="string"?o.from:o.from.toISOString().split("T")[0],n=typeof o.to=="string"?o.to:o.to?.toISOString().split("T")[0]||a;r.set(`filter[${e.id}]`,`${a},${n}`)}}else if(e.value&&typeof e.value=="object"&&"value"in e.value&&"label"in e.value){let o=e.value;r.set(`filter[${e.id}]`,`combobox:${JSON.stringify(o)}`)}}),r}var m=10,T={showTime:!0,showAdvancedFilter:!1,density:"large"},v=[],F=[],A={},E={pageIndex:0,pageSize:m},N={keyword:"",filter:F,sorting:v,pagination:E,columnVisibility:A,uiState:T};function B(t,r=N){let e={keyword:"",filter:[],sorting:[],pagination:{pageIndex:Math.max(0,parseInt(t.get("page")||"1")-1),pageSize:parseInt(t.get("pageSize")||String(m))},uiState:T},o=t.get("sortBy"),a=t.get("sortDir");o&&(e.sorting=[{id:o,desc:a==="desc"}]);let n=t.get("keyword");n&&(e.keyword=n);for(let[p,s]of t.entries())if(p.startsWith("filter[")&&p.endsWith("]")){let l=p.slice(7,-1);if(s.startsWith("combobox:"))try{let i=JSON.parse(s.substring(9));e.filter.push({id:l,value:i})}catch(i){console.warn("Failed to parse combobox filter value:",i)}else if(l==="createdAt"&&s.includes(",")){let[i,x]=s.split(","),S=i?new Date(i):void 0,f=x?new Date(x):void 0;S&&!isNaN(S.getTime())&&e.filter.push({id:l,value:{from:S,to:f&&!isNaN(f.getTime())?f:void 0}})}else e.filter.push({id:l,value:s})}return e}function u(t,r){let e=localStorage.getItem("userId")||"-";if(!r||Object.keys(r).length===0)return`tableState:${e}:${t}`;let a=Object.keys(r).sort().map(n=>`${n}:${r[n]}`).join("|");return`tableState:${t}:${a}`}function M(t,r,e){if(t)try{let o=u(t,r);localStorage.setItem(o,JSON.stringify(e))}catch(o){console.warn("Failed to save table state to localStorage:",o)}}function G(t,r){if(!t)return null;try{let e=u(t,r),o=localStorage.getItem(e);if(o)return JSON.parse(o)}catch(e){console.warn("Failed to load table state from localStorage:",e)}return null}function P(t,r){try{let e=u(t,r);localStorage.removeItem(e)}catch(e){console.warn("Failed to clear table state from localStorage:",e)}}function J(){try{Object.keys(localStorage).forEach(r=>{r.startsWith("tableState:")&&localStorage.removeItem(r)})}catch(t){console.warn("Failed to clear all table state from localStorage:",t)}}import{clsx as K}from"clsx";import{twMerge as W}from"tailwind-merge";function Y(...t){return W(K(t))}export{A as DEFAULT_COLUMN_VISIBILITY,F as DEFAULT_FILTER,m as DEFAULT_PAGE_SIZE,E as DEFAULT_PAGINATION,v as DEFAULT_SORTING,N as DEFAULT_TABLE_STATE,T as DEFAULT_UI_STATE,ge as I18nextProvider,J as clearAllTableStateFromLocalStorage,P as clearTableStateFromLocalStorage,Y as cn,$ as createI18nInstance,z as createStaticI18nInstance,c as defaultNS,B as deserializeTableState,g as fallbackLng,I as filterSelectOptions,u as getTableStateKey,b as i18n,G as loadTableStateFromLocalStorage,R as lowerCaseFirstLetter,O as numberToVietnameseText,_ as repairOptions,M as saveTableStateToLocalStorage,j as serializeTableState,D as slugify,d as stringToFilterString,w as supportedLngs,k as vietnameseNameToCode};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/* VÌ SAO 19 FILE PHẢI `import type {} from '.../new-types'`
|
|
2
|
+
*
|
|
3
|
+
* File này khai `declare module '@tanstack/react-table'` để thêm `meta.title` / `meta.filter` /
|
|
4
|
+
* `meta.sort` — cả hệ bảng dựa vào. Nhưng nó là .d.ts KHÔNG AI IMPORT, nên nó chỉ vào chương
|
|
5
|
+
* trình khi tsconfig TỰ LIỆT KÊ: site/tsconfig.json và panui-studio/tsconfig.json đều phải chép
|
|
6
|
+
* tay dòng `"../src/new-types.d.ts"` vào `include`.
|
|
7
|
+
*
|
|
8
|
+
* Tức mọi app DÙNG thư viện này phải biết một luật bất thành văn. App do `panui codegen --app`
|
|
9
|
+
* sinh ra thì không biết, và hệ quả ĐO ĐƯỢC (20/09) là app sinh ra không typecheck:
|
|
10
|
+
* src/mi/table/data-table-cards.tsx: Property 'title' does not exist on type 'ColumnMeta'
|
|
11
|
+
* Nó sống được lâu vì CI chưa từng biên dịch mã sinh ra.
|
|
12
|
+
*
|
|
13
|
+
* `import type {}` kéo file vào ĐỒ THỊ IMPORT: augmentation bật cho toàn chương trình và bị xoá
|
|
14
|
+
* sạch khi biên dịch (không có import lúc chạy). Đặt ở CHÍNH file cần nó, không gom vào một file
|
|
15
|
+
* trung tâm — vì chương trình của người dùng chỉ chứa những file họ thật sự import: đo được là
|
|
16
|
+
* đặt riêng ở data-table-helper.tsx thì app sinh ra VẪN đỏ, do nó chỉ nạp data-table-cards.tsx.
|
|
17
|
+
*
|
|
18
|
+
* Đo: bỏ file này khỏi `include` ⇒ 233 lỗi; sau khi 19 file khai ⇒ chỉ còn lỗi ở file .test.tsx
|
|
19
|
+
* (người dùng thư viện không biên dịch test, và tsconfig của repo vẫn phủ chúng).
|
|
20
|
+
*/
|
|
21
|
+
/* eslint-disable @typescript-eslint/triple-slash-reference */
|
|
22
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
|
|
23
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
24
|
+
/// <reference types="@tanstack/react-table" />
|
|
25
|
+
import { UiState } from './lib/table-state-utils'
|
|
26
|
+
import '@tanstack/react-table'
|
|
27
|
+
import { LucideProps } from 'lucide-react'
|
|
28
|
+
|
|
29
|
+
import { Any } from './types'
|
|
30
|
+
|
|
31
|
+
type FilterDateRange = {
|
|
32
|
+
type: 'date-range'
|
|
33
|
+
placeholder?: string
|
|
34
|
+
// Nút preset nhanh (Hôm nay / 7 ngày / 30 ngày / Tháng này). true = bộ mặc định đầy đủ.
|
|
35
|
+
presets?: boolean | ('today' | '7d' | '30d' | 'month')[]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type FilterDate = {
|
|
39
|
+
type: 'date'
|
|
40
|
+
placeholder?: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type FilterNumberRange = {
|
|
44
|
+
type: 'number-range'
|
|
45
|
+
placeholder?: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type FilterQuery = {
|
|
49
|
+
operator: 'contains' | 'eq' | 'date' | 'date-range' | 'number-range' | 'value' | 'keywords'
|
|
50
|
+
field?: string
|
|
51
|
+
toField?: string
|
|
52
|
+
valueType?: 'string' | 'boolean'
|
|
53
|
+
datePrecision?: 'date' | 'datetime'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
type FilterText = {
|
|
57
|
+
type: 'text'
|
|
58
|
+
placeholder?: string
|
|
59
|
+
debounceMs?: number
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
type FilterStatic = {
|
|
63
|
+
type: 'static'
|
|
64
|
+
content?: string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type FilterPhone = {
|
|
68
|
+
type: 'phone'
|
|
69
|
+
placeholder?: string
|
|
70
|
+
debounceMs?: number
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
type FilterSelect = {
|
|
74
|
+
type: 'select'
|
|
75
|
+
placeholder?: string
|
|
76
|
+
multiple?: boolean
|
|
77
|
+
dataType?: 'string' | 'number' | 'boolean'
|
|
78
|
+
options?: {
|
|
79
|
+
label: string
|
|
80
|
+
value: string
|
|
81
|
+
icon?: React.ReactNode | ForwardRefExoticComponent<Omit<LucideProps, 'ref'> & RefAttributes<SVGSVGElement>>
|
|
82
|
+
}[]
|
|
83
|
+
clearOtherFilters?: string[]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type FilterCombobox = {
|
|
87
|
+
type: 'combobox'
|
|
88
|
+
placeholder?: string
|
|
89
|
+
multiple?: boolean
|
|
90
|
+
apiRequest?: (keyword?: string) => Promise<
|
|
91
|
+
{
|
|
92
|
+
label: string
|
|
93
|
+
value: string
|
|
94
|
+
}[]
|
|
95
|
+
>
|
|
96
|
+
options?: {
|
|
97
|
+
label: string
|
|
98
|
+
value: string
|
|
99
|
+
icon?: React.ReactNode | ForwardRefExoticComponent<Omit<LucideProps, 'ref'> & RefAttributes<SVGSVGElement>>
|
|
100
|
+
}[]
|
|
101
|
+
clearOtherFilters?: string[]
|
|
102
|
+
searchable?: boolean
|
|
103
|
+
disabled?: boolean
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type FilterTab = {
|
|
107
|
+
type: 'tab'
|
|
108
|
+
placeholder?: string
|
|
109
|
+
options: {
|
|
110
|
+
label: string
|
|
111
|
+
value: string
|
|
112
|
+
count?: number
|
|
113
|
+
colorCount?: 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info' | 'purple' | 'pink' | 'neutral'
|
|
114
|
+
badgeClassName?: string
|
|
115
|
+
className?: string
|
|
116
|
+
}[]
|
|
117
|
+
showCount?: boolean
|
|
118
|
+
includeAllOption?: boolean
|
|
119
|
+
allLabel?: string
|
|
120
|
+
clearOtherFilters?: string[]
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
type FilterTree = {
|
|
124
|
+
type: 'tree'
|
|
125
|
+
placeholder?: string
|
|
126
|
+
multiple?: boolean
|
|
127
|
+
options?: {
|
|
128
|
+
id: string
|
|
129
|
+
value: string
|
|
130
|
+
label: string
|
|
131
|
+
code?: string
|
|
132
|
+
parentId?: string
|
|
133
|
+
children?: Any[]
|
|
134
|
+
}[]
|
|
135
|
+
clearOtherFilters?: string[]
|
|
136
|
+
disabled?: boolean
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
type FilterSprint = {
|
|
140
|
+
type: 'sprint'
|
|
141
|
+
placeholder?: string
|
|
142
|
+
projectId?: string
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
declare module '@tanstack/react-table' {
|
|
146
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
147
|
+
title?: string
|
|
148
|
+
showToggle?: boolean
|
|
149
|
+
customHeader?: boolean
|
|
150
|
+
filter?: (
|
|
151
|
+
| FilterDateRange
|
|
152
|
+
| FilterDate
|
|
153
|
+
| FilterNumberRange
|
|
154
|
+
| FilterCombobox
|
|
155
|
+
| FilterText
|
|
156
|
+
| FilterPhone
|
|
157
|
+
| FilterSelect
|
|
158
|
+
| FilterTree
|
|
159
|
+
| FilterTab
|
|
160
|
+
| FilterStatic
|
|
161
|
+
| FilterSprint
|
|
162
|
+
) & {
|
|
163
|
+
dataType?: 'string' | 'number' | 'boolean'
|
|
164
|
+
position?: 'default' | 'advanced' | 'column'
|
|
165
|
+
label?: string // If not provided, use the column title
|
|
166
|
+
query?: FilterQuery
|
|
167
|
+
}
|
|
168
|
+
sort?: {
|
|
169
|
+
field?: string
|
|
170
|
+
}
|
|
171
|
+
cellClassName?: string
|
|
172
|
+
/** Ô không xuống dòng; cột nở theo nội dung (kèm table w-max). */
|
|
173
|
+
nowrap?: boolean
|
|
174
|
+
/** Cột tự co theo nội dung — bỏ qua size mặc định 150 của TanStack. */
|
|
175
|
+
autoWidth?: boolean
|
|
176
|
+
/** Ép dùng columnDef.size kể cả khi = 150 (default TanStack). */
|
|
177
|
+
fixedSize?: boolean
|
|
178
|
+
headerWrap?: boolean
|
|
179
|
+
|
|
180
|
+
isTreeColumn?: boolean
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
interface TableMeta<TData extends unknown> {
|
|
184
|
+
isLoading?: boolean
|
|
185
|
+
isFetching?: boolean
|
|
186
|
+
total?: number
|
|
187
|
+
error?: unknown
|
|
188
|
+
uiState?: UiState
|
|
189
|
+
getShowTime: () => boolean
|
|
190
|
+
setUiState?: (updater: Partial<UiState> | ((prev: UiState) => UiState)) => void
|
|
191
|
+
setKeyword?: (keyword: string) => void
|
|
192
|
+
getKeyword?: () => string
|
|
193
|
+
initialized?: boolean
|
|
194
|
+
reset: () => void
|
|
195
|
+
reload: () => void
|
|
196
|
+
sortFilter?: string[]
|
|
197
|
+
resetFiltersToInitial?: boolean
|
|
198
|
+
resetFiltersToInitialFunction?: () => void
|
|
199
|
+
}
|
|
200
|
+
}
|