fluent-styles 1.61.0 → 1.62.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.
Files changed (46) hide show
  1. package/README.md +592 -33
  2. package/lib/commonjs/index.js +24 -0
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/tabBar/TabBar.js.map +1 -1
  5. package/lib/commonjs/table/index.js +650 -0
  6. package/lib/commonjs/table/index.js.map +1 -0
  7. package/lib/commonjs/table/usepaginatedquery.js +181 -0
  8. package/lib/commonjs/table/usepaginatedquery.js.map +1 -0
  9. package/lib/module/index.js +2 -0
  10. package/lib/module/index.js.map +1 -1
  11. package/lib/module/tabBar/TabBar.js.map +1 -1
  12. package/lib/module/table/index.js +644 -0
  13. package/lib/module/table/index.js.map +1 -0
  14. package/lib/module/table/usepaginatedquery.js +178 -0
  15. package/lib/module/table/usepaginatedquery.js.map +1 -0
  16. package/lib/typescript/header/index.d.ts +1 -3
  17. package/lib/typescript/header/index.d.ts.map +1 -1
  18. package/lib/typescript/icons/backArrow.d.ts +1 -1
  19. package/lib/typescript/icons/bellFill.d.ts +1 -1
  20. package/lib/typescript/icons/bellOutline.d.ts +1 -1
  21. package/lib/typescript/icons/checkmark.d.ts +1 -1
  22. package/lib/typescript/icons/delete.d.ts +1 -1
  23. package/lib/typescript/icons/downChevron.d.ts +1 -1
  24. package/lib/typescript/icons/error.d.ts +1 -1
  25. package/lib/typescript/icons/forwardArrow.d.ts +1 -1
  26. package/lib/typescript/icons/info.d.ts +1 -1
  27. package/lib/typescript/icons/leftChevron.d.ts +1 -1
  28. package/lib/typescript/icons/rightChevron.d.ts +1 -1
  29. package/lib/typescript/icons/save.d.ts +1 -1
  30. package/lib/typescript/icons/success.d.ts +1 -1
  31. package/lib/typescript/icons/upChevron.d.ts +1 -1
  32. package/lib/typescript/icons/warning.d.ts +1 -1
  33. package/lib/typescript/index.d.ts +2 -0
  34. package/lib/typescript/index.d.ts.map +1 -1
  35. package/lib/typescript/tabBar/TabBar.d.ts +2 -3
  36. package/lib/typescript/tabBar/TabBar.d.ts.map +1 -1
  37. package/lib/typescript/table/index.d.ts +107 -0
  38. package/lib/typescript/table/index.d.ts.map +1 -0
  39. package/lib/typescript/table/usepaginatedquery.d.ts +114 -0
  40. package/lib/typescript/table/usepaginatedquery.d.ts.map +1 -0
  41. package/lib/typescript/utiles/createIcon.d.ts +1 -1
  42. package/package.json +31 -41
  43. package/src/index.ts +2 -0
  44. package/src/tabBar/TabBar.tsx +1 -1
  45. package/src/table/index.tsx +843 -0
  46. package/src/table/usepaginatedquery.tsx +275 -0
@@ -0,0 +1,114 @@
1
+ /**
2
+ * usePaginatedQuery
3
+ *
4
+ * A generic hook that manages page state, loading, error, and data fetching
5
+ * for use with StyledTable's externalPagination mode.
6
+ *
7
+ * Works with:
8
+ * - REST / GraphQL APIs (pass a `fetcher` function)
9
+ * - Realm (pass a `realmQuery` function)
10
+ * - SQLite / WatermelonDB (pass a `fetcher` function)
11
+ * - Any async datasource
12
+ *
13
+ * Usage with REST API:
14
+ * const table = usePaginatedQuery({
15
+ * pageSize: 10,
16
+ * fetcher: async ({ page, pageSize, sortKey, sortDir }) => {
17
+ * const res = await api.get('/orders', { params: { page, pageSize, sortKey, sortDir } })
18
+ * return { data: res.data.items, totalCount: res.data.total }
19
+ * },
20
+ * })
21
+ *
22
+ * Usage with Realm:
23
+ * const table = usePaginatedQuery({
24
+ * pageSize: 10,
25
+ * realmQuery: ({ page, pageSize, sortKey, sortDir }) => {
26
+ * const results = realm.objects('Order')
27
+ * .sorted(sortKey ?? 'createdAt', sortDir === 'desc')
28
+ * const total = results.length
29
+ * const data = results.slice(page * pageSize, (page + 1) * pageSize)
30
+ * return { data: Array.from(data), totalCount: total }
31
+ * },
32
+ * })
33
+ *
34
+ * Then wire into StyledTable:
35
+ * <StyledTable
36
+ * {...table.tableProps}
37
+ * columns={COLUMNS}
38
+ * />
39
+ */
40
+ import type { SortDirection } from "./";
41
+ export interface PaginatedQueryParams {
42
+ page: number;
43
+ pageSize: number;
44
+ sortKey: string | null;
45
+ sortDir: SortDirection;
46
+ search?: string;
47
+ filters?: Record<string, any>;
48
+ }
49
+ export interface PaginatedQueryResult<T> {
50
+ data: T[];
51
+ totalCount: number;
52
+ }
53
+ export interface UsePaginatedQueryOptions<T> {
54
+ pageSize?: number;
55
+ /**
56
+ * Async fetcher for REST / GraphQL / SQLite.
57
+ * Return `{ data, totalCount }`.
58
+ */
59
+ fetcher?: (params: PaginatedQueryParams) => Promise<PaginatedQueryResult<T>>;
60
+ /**
61
+ * Synchronous Realm query function.
62
+ * Called whenever page / sort changes.
63
+ * Return `{ data, totalCount }`.
64
+ */
65
+ realmQuery?: (params: PaginatedQueryParams) => PaginatedQueryResult<T>;
66
+ /** Initial sort column key */
67
+ initialSortKey?: string;
68
+ /** Initial sort direction */
69
+ initialSortDir?: SortDirection;
70
+ /** Initial search string */
71
+ initialSearch?: string;
72
+ /** Initial filter values */
73
+ initialFilters?: Record<string, any>;
74
+ /** Debounce ms for search input changes — default 300 */
75
+ searchDebounce?: number;
76
+ }
77
+ export interface UsePaginatedQueryReturn<T> {
78
+ data: T[];
79
+ loading: boolean;
80
+ error: Error | null;
81
+ totalCount: number;
82
+ totalPages: number;
83
+ page: number;
84
+ pageSize: number;
85
+ setPage: (page: number) => void;
86
+ sortKey: string | null;
87
+ sortDir: SortDirection;
88
+ setSort: (key: string, dir: SortDirection) => void;
89
+ search: string;
90
+ setSearch: (s: string) => void;
91
+ filters: Record<string, any>;
92
+ setFilters: (f: Record<string, any>) => void;
93
+ /** Manually re-fetch the current page (e.g. after a mutation) */
94
+ refresh: () => void;
95
+ /**
96
+ * Spread these directly onto StyledTable:
97
+ * <StyledTable {...table.tableProps} columns={COLUMNS} />
98
+ */
99
+ tableProps: {
100
+ data: T[];
101
+ loading: boolean;
102
+ externalPagination: true;
103
+ currentPage: number;
104
+ totalPages: number;
105
+ totalCount: number;
106
+ pageSize: number;
107
+ onPageChange: (page: number) => void;
108
+ sortKey?: string | null;
109
+ sortDirection: SortDirection;
110
+ onSort: (key: string, dir: SortDirection) => void;
111
+ };
112
+ }
113
+ export declare function usePaginatedQuery<T>(options: UsePaginatedQueryOptions<T>): UsePaginatedQueryReturn<T>;
114
+ //# sourceMappingURL=usepaginatedquery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usepaginatedquery.d.ts","sourceRoot":"","sources":["../../../src/table/usepaginatedquery.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAIxC,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAM,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAG,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAG,aAAa,CAAC;IACxB,MAAM,CAAC,EAAG,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,IAAI,EAAQ,CAAC,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7E;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAEvE,8BAA8B;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,6BAA6B;IAC7B,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B,4BAA4B;IAC5B,aAAa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AAI,EAAE,MAAM,KAAK,IAAI,CAAC;QAC3C,OAAO,CAAC,EAAY,MAAM,GAAG,IAAI,CAAC;QAClC,aAAa,EAAO,aAAa,CAAC;QAClC,MAAM,EAAc,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,KAAK,IAAI,CAAC;KAC/D,CAAC;CACH;AAID,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,OAAO,EAAE,wBAAwB,CAAC,CAAC,CAAC,GACnC,uBAAuB,CAAC,CAAC,CAAC,CAyI5B"}
@@ -32,7 +32,7 @@ type IconProps = {
32
32
  };
33
33
  type IconRenderer = (props: IconProps, svgProps: any) => React.ReactElement;
34
34
  export declare function createIcon(renderer: IconRenderer): {
35
- ({ size, color, strokeWidth, ...props }: IconProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
35
+ ({ size, color, strokeWidth, ...props }: IconProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
36
36
  displayName: string;
37
37
  };
38
38
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fluent-styles",
3
3
  "description": "Develop different styled versions of UI components.",
4
- "version": "1.61.0",
4
+ "version": "1.62.1",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
7
7
  "react-native": "src/index.ts",
@@ -24,10 +24,10 @@
24
24
  "homepage": "https://github.com/suftnetrepo/fluent-styles-next#readme",
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "https://github.com/suftnetrepo/fluent-styles-next.git"
27
+ "url": "https://github.com/suftnetrepo/fluent-styles-next.git"
28
28
  },
29
29
  "bugs": {
30
- "url": "https://github.com/suftnetrepo/fluent-styles-next/issues"
30
+ "url": "https://github.com/suftnetrepo/fluent-styles-next/issues"
31
31
  },
32
32
  "publishConfig": {
33
33
  "registry": "https://registry.npmjs.org"
@@ -52,24 +52,15 @@
52
52
  "release:minor": "release-it minor",
53
53
  "release:patch": "release-it patch"
54
54
  },
55
- "dependencies": {
56
- "color": "^3.2.1",
57
- "fast-deep-equal": "^3.1.3",
58
- "lodash": "^4.17.21",
59
- "react-is": "^18.3.1",
60
- "react-native-popover-view": "^6.1.0",
61
- "rn-placeholder": "^3.0.3"
62
- },
63
- "peerDependencies": {
64
- "react": "*",
65
- "react-native": "*",
66
- "rc-field-form": "*",
67
- "react-native-safe-area-context": "*",
68
- "react-native-svg": "*",
69
- "react-native-vector-icons": ">=10.0.0"
70
- },
71
- "peerDependenciesMeta": {
72
- "react-native-vector-icons": { "optional": true }
55
+ "dependencies": {
56
+ "react-native-popover-view": "^6.1.0"
57
+ },
58
+ "peerDependencies": {
59
+ "react": ">=18",
60
+ "react-native": ">=0.74",
61
+ "react-native-safe-area-context": ">=4",
62
+ "react-native-svg": ">=13",
63
+ "react-native-vector-icons": ">=10"
73
64
  },
74
65
  "devDependencies": {
75
66
  "@commitlint/cli": "^19.8.0",
@@ -78,40 +69,39 @@
78
69
  "@release-it/conventional-changelog": "^10.0.1",
79
70
  "@testing-library/jest-native": "^5.4.3",
80
71
  "@testing-library/react-native": "13.2.0",
81
- "@types/color": "^4.2.0",
82
72
  "@types/jest": "^29.5.14",
83
- "@types/lodash": "^4.17.16",
84
- "@types/react": "^18.3.12",
85
73
  "@types/react-is": "^19.0.0",
86
74
  "@types/react-test-renderer": "^19.1.0",
75
+ "@types/react-native-vector-icons": "^6.4.18",
87
76
  "babel-jest": "^29.7.0",
88
- "core-js": "^3.42.0",
89
77
  "cross-env": "^7.0.3",
90
- "dumi": "~2.4.20",
91
- "dumi-theme-mobile": "^2.3.5",
78
+ "eslint": "^8.57.1",
92
79
  "husky": "^9.1.7",
93
80
  "jest": "^29.7.0",
94
81
  "lint-staged": "^15.5.1",
95
- "rc-field-form": "^2.7.0",
96
- "react": "18.3.1",
97
- "react-native": "0.79.2",
82
+ "prettier": "~3.2.0",
83
+ "react": "19.1.0",
84
+ "react-dom": "19.1.0",
85
+ "react-native": "0.81.4",
86
+ "react-test-renderer": "19.1.0",
87
+ "@types/react": "^19.1.0",
88
+ "@types/react-dom": "^19.1.0",
98
89
  "react-native-builder-bob": "0.30.2",
99
90
  "react-native-safe-area-context": "5.4.0",
100
91
  "react-native-svg": "15.4.0",
92
+ "react-native-vector-icons": "^10.2.0",
101
93
  "react-native-web": "^0.20.0",
102
- "react-test-renderer": "18.2.0",
103
94
  "release-it": "^19.0.2",
104
95
  "ts-jest": "^29.3.2",
105
- "typescript": "~5.3.3",
106
- "eslint": "^8.57.1",
107
- "prettier": "~3.2.0",
108
- "react-native-vector-icons": "^10.2.0",
109
- "@types/react-native-vector-icons": "^6.4.18"
110
- },
111
- "resolutions": {
112
- "@types/react": "^18",
113
- "prettier": "~3.2.0"
96
+ "typescript": "~5.3.3"
114
97
  },
98
+ "overrides": {
99
+ "react": "19.1.0",
100
+ "react-dom": "19.1.0",
101
+ "@types/react": "^19.1.0",
102
+ "prettier": "~3.2.0"
103
+ },
104
+ "prettier": "@fruits-chain/prettier-config-preset",
115
105
  "lint-staged": {
116
106
  "*.{yml,yaml,md}": [
117
107
  "prettier --write"
@@ -121,7 +111,7 @@
121
111
  "prettier --write"
122
112
  ],
123
113
  "*.{js,jsx,ts,tsx}": [
124
- "bash -c 'tsc --noEmit'",
114
+ "bash -c tsc --noEmit",
125
115
  "eslint --fix",
126
116
  "prettier --write"
127
117
  ]
package/src/index.ts CHANGED
@@ -74,4 +74,6 @@ export * from './spinner'
74
74
  export * from './input'
75
75
  export * from './form'
76
76
  export * from './shape/cycle'
77
+ export * from './table'
78
+ export * from './table/usepaginatedquery'
77
79
 
@@ -500,4 +500,4 @@ const S = StyleSheet.create({
500
500
 
501
501
  export const TabBar = memo(TabBarInner) as <T extends TabValue>(
502
502
  p: TabBarProps<T>,
503
- ) => JSX.Element
503
+ ) => React.JSX.Element