@kanda-libs/ks-design-library-new 0.0.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.
- package/LICENSE +21 -0
- package/dist/fonts/GalanoGrotesque/italic/GalanoGrotesqueBlackItalic.woff +0 -0
- package/dist/fonts/GalanoGrotesque/italic/GalanoGrotesqueBoldItalic.woff +0 -0
- package/dist/fonts/GalanoGrotesque/italic/GalanoGrotesqueExtraBoldItalic.woff +0 -0
- package/dist/fonts/GalanoGrotesque/italic/GalanoGrotesqueExtraLightItalic.woff +0 -0
- package/dist/fonts/GalanoGrotesque/italic/GalanoGrotesqueHeavyItalic.woff +0 -0
- package/dist/fonts/GalanoGrotesque/italic/GalanoGrotesqueLightItalic.woff +0 -0
- package/dist/fonts/GalanoGrotesque/italic/GalanoGrotesqueMediumItalic.woff +0 -0
- package/dist/fonts/GalanoGrotesque/italic/GalanoGrotesqueRegularItalic.woff +0 -0
- package/dist/fonts/GalanoGrotesque/italic/GalanoGrotesqueSemiBoldItalic.woff +0 -0
- package/dist/fonts/GalanoGrotesque/italic/GalanoGrotesqueThinItalic.woff +0 -0
- package/dist/fonts/GalanoGrotesque/regular/GalanoGrotesqueBlack.woff +0 -0
- package/dist/fonts/GalanoGrotesque/regular/GalanoGrotesqueBold.woff +0 -0
- package/dist/fonts/GalanoGrotesque/regular/GalanoGrotesqueExtraBold.woff +0 -0
- package/dist/fonts/GalanoGrotesque/regular/GalanoGrotesqueExtraLight.woff +0 -0
- package/dist/fonts/GalanoGrotesque/regular/GalanoGrotesqueHeavy.woff +0 -0
- package/dist/fonts/GalanoGrotesque/regular/GalanoGrotesqueLight.woff +0 -0
- package/dist/fonts/GalanoGrotesque/regular/GalanoGrotesqueMedium.woff +0 -0
- package/dist/fonts/GalanoGrotesque/regular/GalanoGrotesqueRegular.woff +0 -0
- package/dist/fonts/GalanoGrotesque/regular/GalanoGrotesqueSemiBold.woff +0 -0
- package/dist/fonts/GalanoGrotesque/regular/GalanoGrotesqueThin.woff +0 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.esm.mjs +2 -0
- package/dist/index.esm.mjs.map +7 -0
- package/dist/library.css +2053 -0
- package/package.json +117 -0
- package/src/.DS_Store +0 -0
- package/src/@types/assets/index.d.ts +26 -0
- package/src/@types/index.d.ts +207 -0
- package/src/common/helpers.ts +15 -0
- package/src/components/Table/components/Cell/constants.ts +11 -0
- package/src/components/Table/components/Cell/index.tsx +36 -0
- package/src/components/Table/components/Cell/useCellClassNames.ts +23 -0
- package/src/components/Table/components/HeaderButton/Button.tsx +18 -0
- package/src/components/Table/components/HeaderButton/Wrapper.tsx +22 -0
- package/src/components/Table/components/HeaderButton/constants.ts +24 -0
- package/src/components/Table/components/HeaderButton/index.tsx +7 -0
- package/src/components/Table/components/HeaderButton/useWrapperProps.ts +31 -0
- package/src/components/Table/components/HeaderColumn/constants.ts +26 -0
- package/src/components/Table/components/HeaderColumn/index.tsx +38 -0
- package/src/components/Table/components/HeaderColumn/useHeaderColumnProps.ts +31 -0
- package/src/components/Table/components/HeaderGroup/constants.ts +3 -0
- package/src/components/Table/components/HeaderGroup/index.tsx +40 -0
- package/src/components/Table/components/HeaderGroup/useHeaderGroupProps.ts +27 -0
- package/src/components/Table/components/Row/constants.ts +7 -0
- package/src/components/Table/components/Row/index.tsx +40 -0
- package/src/components/Table/components/Row/useRowClassNames.ts +19 -0
- package/src/components/Table/components/SearchInput/index.tsx +22 -0
- package/src/components/Table/components/SearchInput/useSearchInput.ts +30 -0
- package/src/components/Table/helpers/search.ts +96 -0
- package/src/components/Table/index.tsx +64 -0
- package/src/components/Table/useTableProps.ts +54 -0
- package/src/components/index.tsx +1 -0
- package/src/index.ts +2 -0
- package/src/moduleTypes.d.ts +1 -0
- package/src/styles/fonts/GalanoGrotesque/italic/GalanoGrotesqueBlackItalic.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/italic/GalanoGrotesqueBoldItalic.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/italic/GalanoGrotesqueExtraBoldItalic.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/italic/GalanoGrotesqueExtraLightItalic.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/italic/GalanoGrotesqueHeavyItalic.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/italic/GalanoGrotesqueLightItalic.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/italic/GalanoGrotesqueMediumItalic.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/italic/GalanoGrotesqueRegularItalic.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/italic/GalanoGrotesqueSemiBoldItalic.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/italic/GalanoGrotesqueThinItalic.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/regular/GalanoGrotesqueBlack.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/regular/GalanoGrotesqueBold.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/regular/GalanoGrotesqueExtraBold.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/regular/GalanoGrotesqueExtraLight.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/regular/GalanoGrotesqueHeavy.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/regular/GalanoGrotesqueLight.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/regular/GalanoGrotesqueMedium.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/regular/GalanoGrotesqueRegular.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/regular/GalanoGrotesqueSemiBold.woff +0 -0
- package/src/styles/fonts/GalanoGrotesque/regular/GalanoGrotesqueThin.woff +0 -0
- package/src/styles/index.css +2236 -0
- package/src/styles/ks-design-library.css +2236 -0
- package/src/styles/library.css +2053 -0
- package/src/styles/tailwind.css +915 -0
- package/src/theme/plugins/tailwind.plugin.caret-color.js +32 -0
- package/src/theme/plugins/tailwind.plugin.field-error.js +10 -0
- package/src/theme/plugins/tailwind.plugin.field-focus.js +10 -0
- package/src/theme/plugins/tailwind.plugin.field-loading.js +10 -0
- package/src/theme/plugins/tailwind.plugin.group-active.js +10 -0
- package/src/theme/plugins/tailwind.plugin.important.js +14 -0
- package/src/theme/plugins/tailwind.plugin.label-check.js +10 -0
- package/src/theme/plugins/tailwind.plugin.text-style.js +213 -0
- package/src/theme/postcss/tailwind.postcss.config.js +7 -0
- package/src/theme/themeConfig.js +339 -0
- package/src/types.d.ts +58 -0
package/package.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kanda-libs/ks-design-library-new",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Kanda design components library",
|
|
5
|
+
"main": "dist/index.esm.mjs",
|
|
6
|
+
"module": "dist/index.esm.mjs",
|
|
7
|
+
"source": "src/index.ts",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"format": "esm",
|
|
10
|
+
"sideEffects": [
|
|
11
|
+
"**/*.css"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"src"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"clean": "rimraf dist",
|
|
19
|
+
"prebuild": "yarn clean",
|
|
20
|
+
"build": "yarn build:style && yarn build:esbuild",
|
|
21
|
+
"watch": "yarn && yarn clean && tsc && yarn build:style && DEV_WATCH=true yarn build:esbuild && yalc publish",
|
|
22
|
+
"app:dev": "yarn --cwd ./app && yarn --cwd ./app yalc:link && yarn --cwd ./app dev --force --host",
|
|
23
|
+
"build:types": "./node_modules/.bin/dts-bundle-generator --external-inlines=./generated -o dist/index.d.ts src/index.ts",
|
|
24
|
+
"build:style": "npx tailwindcss --postcss ./src/theme/postcss/tailwind.postcss.config.js -i ./src/styles/tailwind.css -c ./tailwind.config.js -o ./src/styles/library.css",
|
|
25
|
+
"watch:style": "npx tailwindcss --postcss ./src/theme/postcss/tailwind.postcss.config.js -i ./src/styles/tailwind.css -c ./tailwind.config.js -o ./src/styles/library.css --watch",
|
|
26
|
+
"build:dev": "APP_ENV=dev yarn build",
|
|
27
|
+
"build:esbuild": "yarn clean && yarn build:style && node build.ts && yarn build:types",
|
|
28
|
+
"lint": "eslint '**/*.{js,ts,tsx}'",
|
|
29
|
+
"type": "tsc --noEmit",
|
|
30
|
+
"bundlesize": "yarn build:style && yarn build:modern && bundlesize",
|
|
31
|
+
"start:app": "yarn clean && tsc && yarn build:style && yarn build:esm && yarn link && yarn --cwd node_modules/react link && yarn --cwd ./app link react ks-design-library && yarn --cwd ./app && yarn --cwd ./app run dev",
|
|
32
|
+
"test:app": "yarn && yarn clean && yarn build && yalc publish && yarn --cwd ./app yalc:link && yarn --cwd ./app && yarn --cwd ./app dev --force"
|
|
33
|
+
},
|
|
34
|
+
"author": "rob@kanda.co.uk",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@babel/runtime": "^7.21.0",
|
|
38
|
+
"@kanda-libs/ks-tailwind-config": "0.2.11",
|
|
39
|
+
"@types/file-saver": "^2.0.5",
|
|
40
|
+
"@types/lodash.get": "^4.4.7",
|
|
41
|
+
"@types/lodash.set": "^4.3.7",
|
|
42
|
+
"@types/node": "^18.11.9",
|
|
43
|
+
"@types/react": "17.0.2",
|
|
44
|
+
"@types/react-dom": "17.0.2",
|
|
45
|
+
"@types/react-timeago": "^4.1.3",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^5.14.0",
|
|
47
|
+
"@typescript-eslint/parser": "^5.14.0",
|
|
48
|
+
"@vitejs/plugin-react": "^1.3.0",
|
|
49
|
+
"autoprefixer": "^10.4.13",
|
|
50
|
+
"bundlesize": "^0.18.1",
|
|
51
|
+
"clsx": "^1.1.1",
|
|
52
|
+
"dts-bundle-generator": "^7.1.0",
|
|
53
|
+
"esbuild": "^0.15.15",
|
|
54
|
+
"esbuild-copy-static-files": "^0.1.0",
|
|
55
|
+
"esbuild-node-externals": "^1.5.0",
|
|
56
|
+
"esbuild-plugin-svgr": "^1.0.1",
|
|
57
|
+
"eslint": "^8.11.0",
|
|
58
|
+
"eslint-config-prettier": "^8.5.0",
|
|
59
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
60
|
+
"eslint-plugin-react": "^7.29.3",
|
|
61
|
+
"eslint-plugin-react-hooks": "^4.3.0",
|
|
62
|
+
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
63
|
+
"lint-staged": "^12.3.5",
|
|
64
|
+
"postcss": "^8.4.20",
|
|
65
|
+
"postcss-100vh-fix": "^1.0.2",
|
|
66
|
+
"prettier": "^2.5.1",
|
|
67
|
+
"react": "^18.0.0",
|
|
68
|
+
"react-dom": "^18.0.0",
|
|
69
|
+
"react-loading-skeleton": "^3.1.0",
|
|
70
|
+
"rimraf": "^3.0.2",
|
|
71
|
+
"tailwindcss": "^3.2.4",
|
|
72
|
+
"tailwindcss-invalid-variant-plugin": "^1.0.3",
|
|
73
|
+
"tsd": "^0.19.1",
|
|
74
|
+
"typescript": "^4.6.3"
|
|
75
|
+
},
|
|
76
|
+
"bundlesize": [
|
|
77
|
+
{
|
|
78
|
+
"path": "./dist/index.cjs.js",
|
|
79
|
+
"maxSize": "10000 kB"
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
"peerDependencies": {
|
|
83
|
+
"clsx": "^1.1.1",
|
|
84
|
+
"react": "^16.8.0 || ^17 || ^18",
|
|
85
|
+
"react-loading-skeleton": "^3.1.0"
|
|
86
|
+
},
|
|
87
|
+
"repository": {
|
|
88
|
+
"type": "git",
|
|
89
|
+
"url": "git+https://github.com/kanda-co/ks-design-library.git"
|
|
90
|
+
},
|
|
91
|
+
"keywords": [
|
|
92
|
+
"design"
|
|
93
|
+
],
|
|
94
|
+
"bugs": {
|
|
95
|
+
"url": "https://github.com/kanda-co/ks-design-library/issues"
|
|
96
|
+
},
|
|
97
|
+
"resolutions": {
|
|
98
|
+
"@types/react": "17.0.2"
|
|
99
|
+
},
|
|
100
|
+
"homepage": "https://github.com/kanda-co/ks-design-library#readme",
|
|
101
|
+
"dependencies": {
|
|
102
|
+
"@kanda-libs/ks-amplitude-provider": "^0.0.7",
|
|
103
|
+
"@kanda-libs/ks-design-library": "^0.2.60",
|
|
104
|
+
"@types/react-table": "^7.7.14",
|
|
105
|
+
"file-saver": "^2.0.5",
|
|
106
|
+
"fuse.js": "^6.6.2",
|
|
107
|
+
"lodash.get": "^4.4.2",
|
|
108
|
+
"lodash.set": "^4.3.2",
|
|
109
|
+
"react-image": "^4.0.3",
|
|
110
|
+
"react-loading-skeleton": "^3.1.0",
|
|
111
|
+
"react-number-format": "^4.6.4",
|
|
112
|
+
"react-table": "^7.7.14",
|
|
113
|
+
"react-teleporter": "^3.0.2",
|
|
114
|
+
"react-toastify": "^9.0.8",
|
|
115
|
+
"use-debounce": "^8.0.4"
|
|
116
|
+
}
|
|
117
|
+
}
|
package/src/.DS_Store
ADDED
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare module '*.svg' {
|
|
2
|
+
import { type FunctionComponent } from 'react';
|
|
3
|
+
export const ReactComponent: FunctionComponent<{
|
|
4
|
+
className?: string;
|
|
5
|
+
children?: JSX.Element | JSX.Element[];
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
}>;
|
|
9
|
+
const src: string;
|
|
10
|
+
export default src;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module '*.jpg' {
|
|
14
|
+
const content: string;
|
|
15
|
+
export default content;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare module '*.png' {
|
|
19
|
+
const content: string;
|
|
20
|
+
export default content;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare module '*.json' {
|
|
24
|
+
const content: string;
|
|
25
|
+
export default content;
|
|
26
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
UseColumnOrderInstanceProps,
|
|
3
|
+
UseColumnOrderState,
|
|
4
|
+
UseExpandedHooks,
|
|
5
|
+
UseExpandedInstanceProps,
|
|
6
|
+
UseExpandedOptions,
|
|
7
|
+
UseExpandedRowProps,
|
|
8
|
+
UseExpandedState,
|
|
9
|
+
UseFiltersColumnOptions,
|
|
10
|
+
UseFiltersColumnProps,
|
|
11
|
+
UseFiltersInstanceProps,
|
|
12
|
+
UseFiltersOptions,
|
|
13
|
+
UseFiltersState,
|
|
14
|
+
UseGlobalFiltersColumnOptions,
|
|
15
|
+
UseGlobalFiltersInstanceProps,
|
|
16
|
+
UseGlobalFiltersOptions,
|
|
17
|
+
UseGlobalFiltersState,
|
|
18
|
+
UseGroupByCellProps,
|
|
19
|
+
UseGroupByColumnOptions,
|
|
20
|
+
UseGroupByColumnProps,
|
|
21
|
+
UseGroupByHooks,
|
|
22
|
+
UseGroupByInstanceProps,
|
|
23
|
+
UseGroupByOptions,
|
|
24
|
+
UseGroupByRowProps,
|
|
25
|
+
UseGroupByState,
|
|
26
|
+
UsePaginationInstanceProps,
|
|
27
|
+
UsePaginationOptions,
|
|
28
|
+
UsePaginationState,
|
|
29
|
+
UseResizeColumnsColumnOptions,
|
|
30
|
+
UseResizeColumnsColumnProps,
|
|
31
|
+
UseResizeColumnsOptions,
|
|
32
|
+
UseResizeColumnsState,
|
|
33
|
+
UseRowSelectHooks,
|
|
34
|
+
UseRowSelectInstanceProps,
|
|
35
|
+
UseRowSelectOptions,
|
|
36
|
+
UseRowSelectRowProps,
|
|
37
|
+
UseRowSelectState,
|
|
38
|
+
UseRowStateCellProps,
|
|
39
|
+
UseRowStateInstanceProps,
|
|
40
|
+
UseRowStateOptions,
|
|
41
|
+
UseRowStateRowProps,
|
|
42
|
+
UseRowStateState,
|
|
43
|
+
UseSortByColumnOptions,
|
|
44
|
+
UseSortByColumnProps,
|
|
45
|
+
UseSortByHooks,
|
|
46
|
+
UseSortByInstanceProps,
|
|
47
|
+
UseSortByOptions,
|
|
48
|
+
UseSortByState,
|
|
49
|
+
TableInstance as TableInstanceType,
|
|
50
|
+
} from 'react-table';
|
|
51
|
+
|
|
52
|
+
declare module 'react-table' {
|
|
53
|
+
// take this file as-is, or comment out the sections that don't apply to your plugin configuration
|
|
54
|
+
|
|
55
|
+
export interface TableOptions<D extends Record<string, unknown>>
|
|
56
|
+
extends UseExpandedOptions<D>,
|
|
57
|
+
UseFiltersOptions<D>,
|
|
58
|
+
UseGlobalFiltersOptions<D>,
|
|
59
|
+
UseGroupByOptions<D>,
|
|
60
|
+
UsePaginationOptions<D>,
|
|
61
|
+
UseResizeColumnsOptions<D>,
|
|
62
|
+
UseRowSelectOptions<D>,
|
|
63
|
+
UseRowStateOptions<D>,
|
|
64
|
+
UseSortByOptions<D>,
|
|
65
|
+
// note that having Record here allows you to add anything to the options, this matches the spirit of the
|
|
66
|
+
// underlying js library, but might be cleaner if it's replaced by a more specific type that matches your
|
|
67
|
+
// feature set, this is a safe default.
|
|
68
|
+
Record<string, any> {}
|
|
69
|
+
|
|
70
|
+
export interface Hooks<
|
|
71
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
72
|
+
> extends UseExpandedHooks<D>,
|
|
73
|
+
UseGroupByHooks<D>,
|
|
74
|
+
UseRowSelectHooks<D>,
|
|
75
|
+
UseSortByHooks<D> {}
|
|
76
|
+
|
|
77
|
+
export interface TableInstance<
|
|
78
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
79
|
+
> extends UseColumnOrderInstanceProps<D>,
|
|
80
|
+
UseExpandedInstanceProps<D>,
|
|
81
|
+
UseFiltersInstanceProps<D>,
|
|
82
|
+
UseGlobalFiltersInstanceProps<D>,
|
|
83
|
+
UseGroupByInstanceProps<D>,
|
|
84
|
+
UsePaginationInstanceProps<D>,
|
|
85
|
+
UseRowSelectInstanceProps<D>,
|
|
86
|
+
UseRowStateInstanceProps<D>,
|
|
87
|
+
UseSortByInstanceProps<D> {}
|
|
88
|
+
|
|
89
|
+
export interface TableState<
|
|
90
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
91
|
+
> extends UseColumnOrderState<D>,
|
|
92
|
+
UseExpandedState<D>,
|
|
93
|
+
UseFiltersState<D>,
|
|
94
|
+
UseGlobalFiltersState<D>,
|
|
95
|
+
UseGroupByState<D>,
|
|
96
|
+
UsePaginationState<D>,
|
|
97
|
+
UseResizeColumnsState<D>,
|
|
98
|
+
UseRowSelectState<D>,
|
|
99
|
+
UseRowStateState<D>,
|
|
100
|
+
UseSortByState<D> {}
|
|
101
|
+
|
|
102
|
+
export interface ColumnInterface<
|
|
103
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
104
|
+
> extends UseFiltersColumnOptions<D>,
|
|
105
|
+
UseGlobalFiltersColumnOptions<D>,
|
|
106
|
+
UseGroupByColumnOptions<D>,
|
|
107
|
+
UseResizeColumnsColumnOptions<D>,
|
|
108
|
+
UseSortByColumnOptions<D> {}
|
|
109
|
+
|
|
110
|
+
export interface ColumnInstance<
|
|
111
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
112
|
+
> extends UseFiltersColumnProps<D>,
|
|
113
|
+
UseGroupByColumnProps<D>,
|
|
114
|
+
UseResizeColumnsColumnProps<D>,
|
|
115
|
+
UseSortByColumnProps<D> {}
|
|
116
|
+
|
|
117
|
+
export interface Cell<
|
|
118
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
119
|
+
V = any,
|
|
120
|
+
> extends UseGroupByCellProps<D>,
|
|
121
|
+
UseRowStateCellProps<D> {}
|
|
122
|
+
|
|
123
|
+
export interface Row<
|
|
124
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
125
|
+
> extends UseExpandedRowProps<D>,
|
|
126
|
+
UseGroupByRowProps<D>,
|
|
127
|
+
UseRowSelectRowProps<D>,
|
|
128
|
+
UseRowStateRowProps<D> {}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// take this file as-is, or comment out the sections that don't apply to your plugin configuration
|
|
132
|
+
|
|
133
|
+
export interface TableOptions<D extends Record<string, unknown>>
|
|
134
|
+
extends UseExpandedOptions<D>,
|
|
135
|
+
UseFiltersOptions<D>,
|
|
136
|
+
UseGlobalFiltersOptions<D>,
|
|
137
|
+
UseGroupByOptions<D>,
|
|
138
|
+
UsePaginationOptions<D>,
|
|
139
|
+
UseResizeColumnsOptions<D>,
|
|
140
|
+
UseRowSelectOptions<D>,
|
|
141
|
+
UseRowStateOptions<D>,
|
|
142
|
+
UseSortByOptions<D>,
|
|
143
|
+
// note that having Record here allows you to add anything to the options, this matches the spirit of the
|
|
144
|
+
// underlying js library, but might be cleaner if it's replaced by a more specific type that matches your
|
|
145
|
+
// feature set, this is a safe default.
|
|
146
|
+
Record<string, any> {}
|
|
147
|
+
|
|
148
|
+
export interface Hooks<
|
|
149
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
150
|
+
> extends UseExpandedHooks<D>,
|
|
151
|
+
UseGroupByHooks<D>,
|
|
152
|
+
UseRowSelectHooks<D>,
|
|
153
|
+
UseSortByHooks<D> {}
|
|
154
|
+
|
|
155
|
+
export interface TableInstance<
|
|
156
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
157
|
+
> extends TableInstanceType<D>,
|
|
158
|
+
UseColumnOrderInstanceProps<D>,
|
|
159
|
+
UseExpandedInstanceProps<D>,
|
|
160
|
+
UseFiltersInstanceProps<D>,
|
|
161
|
+
UseGlobalFiltersInstanceProps<D>,
|
|
162
|
+
UseGroupByInstanceProps<D>,
|
|
163
|
+
UsePaginationInstanceProps<D>,
|
|
164
|
+
UseRowSelectInstanceProps<D>,
|
|
165
|
+
UseRowStateInstanceProps<D>,
|
|
166
|
+
UseSortByInstanceProps<D> {}
|
|
167
|
+
|
|
168
|
+
export interface TableState<
|
|
169
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
170
|
+
> extends UseColumnOrderState<D>,
|
|
171
|
+
UseExpandedState<D>,
|
|
172
|
+
UseFiltersState<D>,
|
|
173
|
+
UseGlobalFiltersState<D>,
|
|
174
|
+
UseGroupByState<D>,
|
|
175
|
+
UsePaginationState<D>,
|
|
176
|
+
UseResizeColumnsState<D>,
|
|
177
|
+
UseRowSelectState<D>,
|
|
178
|
+
UseRowStateState<D>,
|
|
179
|
+
UseSortByState<D> {}
|
|
180
|
+
|
|
181
|
+
export interface ColumnInterface<
|
|
182
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
183
|
+
> extends UseFiltersColumnOptions<D>,
|
|
184
|
+
UseGlobalFiltersColumnOptions<D>,
|
|
185
|
+
UseGroupByColumnOptions<D>,
|
|
186
|
+
UseResizeColumnsColumnOptions<D>,
|
|
187
|
+
UseSortByColumnOptions<D> {}
|
|
188
|
+
|
|
189
|
+
export interface ColumnInstance<
|
|
190
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
191
|
+
> extends UseFiltersColumnProps<D>,
|
|
192
|
+
UseGroupByColumnProps<D>,
|
|
193
|
+
UseResizeColumnsColumnProps<D>,
|
|
194
|
+
UseSortByColumnProps<D> {}
|
|
195
|
+
|
|
196
|
+
export interface Cell<
|
|
197
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
198
|
+
V = any,
|
|
199
|
+
> extends UseGroupByCellProps<D>,
|
|
200
|
+
UseRowStateCellProps<D> {}
|
|
201
|
+
|
|
202
|
+
export interface Row<
|
|
203
|
+
D extends Record<string, unknown> = Record<string, unknown>,
|
|
204
|
+
> extends UseExpandedRowProps<D>,
|
|
205
|
+
UseGroupByRowProps<D>,
|
|
206
|
+
UseRowSelectRowProps<D>,
|
|
207
|
+
UseRowStateRowProps<D> {}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const getWindow = (): Window | undefined => {
|
|
2
|
+
if (typeof window === 'undefined') {
|
|
3
|
+
return undefined;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
return window;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const getDocument = (): Document | undefined => {
|
|
10
|
+
if (typeof document === 'undefined') {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return document;
|
|
15
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const CLASS_NAMES = {
|
|
2
|
+
container: 'flex w-full h-full',
|
|
3
|
+
render:
|
|
4
|
+
'w-full my-auto text-style-g text-neutral-600 whitespace-nowrap overflow-hidden overflow-ellipsis',
|
|
5
|
+
renderLoading: 'w-full my-auto mr-8 text-style-g',
|
|
6
|
+
cell: {
|
|
7
|
+
base: 'h-16 flex',
|
|
8
|
+
compact: 'h-8 flex',
|
|
9
|
+
padding: 'pl-4',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
import type { TableCellProps } from 'react-table';
|
|
3
|
+
import { SkeletonLoader } from '@kanda-libs/ks-design-library';
|
|
4
|
+
import useCellClassNames from './useCellClassNames';
|
|
5
|
+
|
|
6
|
+
export interface CellProps extends TableCellProps {
|
|
7
|
+
index: number;
|
|
8
|
+
render: () => ReactNode;
|
|
9
|
+
compact?: boolean;
|
|
10
|
+
isLoading?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Cell: FunctionComponent<CellProps> = function ({
|
|
14
|
+
render,
|
|
15
|
+
index,
|
|
16
|
+
compact = false,
|
|
17
|
+
isLoading = false,
|
|
18
|
+
...props
|
|
19
|
+
}) {
|
|
20
|
+
const classNames = useCellClassNames(index, compact, isLoading);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div {...props} className={classNames.cell}>
|
|
24
|
+
<div className={classNames.container}>
|
|
25
|
+
<div className={classNames.render}>
|
|
26
|
+
<SkeletonLoader
|
|
27
|
+
isLoading={isLoading}
|
|
28
|
+
afterLoading={<>{render()}</>}
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default Cell;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { CLASS_NAMES } from './constants';
|
|
3
|
+
|
|
4
|
+
export type CellClassNamesHook = {
|
|
5
|
+
cell: string;
|
|
6
|
+
container: string;
|
|
7
|
+
render: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default function useCellClassNames(
|
|
11
|
+
index: number,
|
|
12
|
+
compact: boolean,
|
|
13
|
+
isLoading: boolean,
|
|
14
|
+
): CellClassNamesHook {
|
|
15
|
+
return {
|
|
16
|
+
cell: clsx(
|
|
17
|
+
compact ? CLASS_NAMES.cell.compact : CLASS_NAMES.cell.base,
|
|
18
|
+
index === 0 ? '' : CLASS_NAMES.cell.padding,
|
|
19
|
+
),
|
|
20
|
+
container: CLASS_NAMES.container,
|
|
21
|
+
render: isLoading ? CLASS_NAMES.renderLoading : CLASS_NAMES.render,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FunctionComponent, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { Icon } from '@kanda-libs/ks-design-library';
|
|
3
|
+
import { BUTTON_CLASS_NAMES, ICON_PROPS } from './constants';
|
|
4
|
+
|
|
5
|
+
export interface ButtonProps extends HTMLAttributes<HTMLButtonElement> {
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const Button: FunctionComponent<ButtonProps> = function ({ label, ...props }) {
|
|
10
|
+
return (
|
|
11
|
+
<button className={BUTTON_CLASS_NAMES} {...props}>
|
|
12
|
+
{label}
|
|
13
|
+
<Icon {...ICON_PROPS} />
|
|
14
|
+
</button>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default Button;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import useWrapperProps from './useWrapperProps';
|
|
3
|
+
|
|
4
|
+
export interface WrapperProps {
|
|
5
|
+
index: number;
|
|
6
|
+
children?: JSX.Element | JSX.Element[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const Wrapper: FunctionComponent<WrapperProps> = function ({
|
|
10
|
+
index,
|
|
11
|
+
children,
|
|
12
|
+
}) {
|
|
13
|
+
const { classNames, containerStyle } = useWrapperProps(index);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div className={classNames.container} style={containerStyle}>
|
|
17
|
+
<div className={classNames.flex}>{children}</div>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default Wrapper;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const BUTTON_CLASS_NAMES =
|
|
2
|
+
'flex px-3 py-1.75 h-9 -ml-3 my-auto rounded-lg bg-transparent hover:bg-neutral-100 text-style-g-em text-neutral-500 whitespace-nowrap z-20';
|
|
3
|
+
|
|
4
|
+
export const ICON_PROPS = {
|
|
5
|
+
icon: 'chevron-down',
|
|
6
|
+
stroke: 'neutral-500',
|
|
7
|
+
size: 12,
|
|
8
|
+
className: 'ml-2 my-auto',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const WRAPPER_STYLE = {
|
|
12
|
+
width: 'calc(100% + 16px)',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const WRAPPER_CLASS_NAMES = {
|
|
16
|
+
container: {
|
|
17
|
+
base: 'w-full h-full overflow-hidden',
|
|
18
|
+
padding: 'pl-4 -ml-4',
|
|
19
|
+
},
|
|
20
|
+
flex: {
|
|
21
|
+
base: 'w-full h-full flex',
|
|
22
|
+
padding: 'pl-4',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { WRAPPER_STYLE, WRAPPER_CLASS_NAMES } from './constants';
|
|
4
|
+
|
|
5
|
+
export interface WrapperPropsHook {
|
|
6
|
+
classNames: {
|
|
7
|
+
container: string;
|
|
8
|
+
flex: string;
|
|
9
|
+
};
|
|
10
|
+
containerStyle: CSSProperties;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default function useWrapperProps(index: number): WrapperPropsHook {
|
|
14
|
+
const containerStyle = index === 0 ? WRAPPER_STYLE : {};
|
|
15
|
+
|
|
16
|
+
const classNames = {
|
|
17
|
+
container: clsx(
|
|
18
|
+
WRAPPER_CLASS_NAMES.container.base,
|
|
19
|
+
index === 0 ? WRAPPER_CLASS_NAMES.container.padding : '',
|
|
20
|
+
),
|
|
21
|
+
flex: clsx(
|
|
22
|
+
WRAPPER_CLASS_NAMES.flex.base,
|
|
23
|
+
index === 0 ? '' : WRAPPER_CLASS_NAMES.flex.padding,
|
|
24
|
+
),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
classNames,
|
|
29
|
+
containerStyle,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const CLASS_NAMES = {
|
|
2
|
+
main: 'flex h-14',
|
|
3
|
+
loading: {
|
|
4
|
+
base: 'my-auto w-full mr-8',
|
|
5
|
+
margin: 'ml-4',
|
|
6
|
+
},
|
|
7
|
+
wrapper: {
|
|
8
|
+
padding: 'px-2 pt-2',
|
|
9
|
+
popover: 'pb-1',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const MOVE_LEFT_ITEM_PROPS = {
|
|
14
|
+
name: 'Move column left',
|
|
15
|
+
icon: 'arrow-left',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const MOVE_RIGHT_ITEM_PROPS = {
|
|
19
|
+
name: 'Move column right',
|
|
20
|
+
icon: 'arrow-right',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const HIDE_COLUMN_PROPS = {
|
|
24
|
+
name: 'Hide column',
|
|
25
|
+
icon: 'eye-off',
|
|
26
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SkeletonLoader } from '@kanda-libs/ks-design-library';
|
|
2
|
+
import type { FunctionComponent, ReactNode } from 'react';
|
|
3
|
+
import type { TableHeaderProps } from 'react-table';
|
|
4
|
+
import HeaderButton from '../HeaderButton';
|
|
5
|
+
import useHeaderColumnProps from './useHeaderColumnProps';
|
|
6
|
+
|
|
7
|
+
export interface HeaderColumnProps extends TableHeaderProps {
|
|
8
|
+
index: number;
|
|
9
|
+
isLoading?: boolean;
|
|
10
|
+
popoverButtons?: boolean;
|
|
11
|
+
label: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const HeaderColumn: FunctionComponent<HeaderColumnProps> = function ({
|
|
15
|
+
index,
|
|
16
|
+
isLoading = false,
|
|
17
|
+
popoverButtons = false,
|
|
18
|
+
label,
|
|
19
|
+
...props
|
|
20
|
+
}) {
|
|
21
|
+
const { classNames } = useHeaderColumnProps(index, popoverButtons);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div {...props} className={classNames.main}>
|
|
25
|
+
<SkeletonLoader
|
|
26
|
+
isLoading={isLoading}
|
|
27
|
+
wrapperClassName={classNames.loading}
|
|
28
|
+
afterLoading={
|
|
29
|
+
<HeaderButton.Wrapper index={index}>
|
|
30
|
+
<HeaderButton.Button label={label} />
|
|
31
|
+
</HeaderButton.Wrapper>
|
|
32
|
+
}
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default HeaderColumn;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { CLASS_NAMES } from './constants';
|
|
3
|
+
|
|
4
|
+
export interface HeaderColumnPropsHook {
|
|
5
|
+
classNames: {
|
|
6
|
+
main: string;
|
|
7
|
+
loading: string;
|
|
8
|
+
wrapper: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default function useHeaderColumnProps(
|
|
13
|
+
index: number,
|
|
14
|
+
popoverButtons: boolean,
|
|
15
|
+
): HeaderColumnPropsHook {
|
|
16
|
+
const classNames = {
|
|
17
|
+
...CLASS_NAMES,
|
|
18
|
+
loading: clsx(
|
|
19
|
+
CLASS_NAMES.loading.base,
|
|
20
|
+
index === 0 ? '' : CLASS_NAMES.loading.margin,
|
|
21
|
+
),
|
|
22
|
+
wrapper: clsx(
|
|
23
|
+
CLASS_NAMES.wrapper.padding,
|
|
24
|
+
popoverButtons ? '' : CLASS_NAMES.wrapper.popover,
|
|
25
|
+
),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
classNames,
|
|
30
|
+
};
|
|
31
|
+
}
|