@sustaina/shared-ui 1.1.5
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 +107 -0
- package/dist/index.css +64 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +457 -0
- package/dist/index.d.ts +457 -0
- package/dist/index.js +4897 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4842 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +123 -0
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Sustaina - Shared UI
|
|
2
|
+
|
|
3
|
+
# 📦 Installation
|
|
4
|
+
|
|
5
|
+
To use `@sustaina/shared-ui` in your project, follow these steps carefully.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Install UI package and required dependencies
|
|
10
|
+
|
|
11
|
+
Make sure you've installed [TailwindCSS](https://tailwindcss.com/docs/installation) and [shadcn/ui](https://ui.shadcn.com/docs/installation/manual) before installing our library. **Don’t skip this.**
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @sustaina/shared-ui
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
### Peer Dependencies
|
|
20
|
+
|
|
21
|
+
You must manually install these peer dependencies in your host project:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install react react-dom react-hook-form
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Supported versions:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
33
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
34
|
+
"react-hook-form": "^7.61.1"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
> ⚠️ If your project doesn't match the version ranges above, you may get runtime or type errors.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 3. Add `@sustaina/shared-ui` to your CSS
|
|
44
|
+
|
|
45
|
+
To make styling work with our components, add this to your `index.css` or root CSS file:
|
|
46
|
+
|
|
47
|
+
```css
|
|
48
|
+
@import "@sustaina/shared-ui/styles.css"; /* this include styles/theme.css already */
|
|
49
|
+
@source "../../node_modules/@sustaina/shared-ui/dist"; /* depend your root CSS file locate. */
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
# Usage
|
|
55
|
+
|
|
56
|
+
Import `@sustaina/shared-ui` components within your React component files:
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { Button } from "@sustaina/shared-ui";
|
|
60
|
+
|
|
61
|
+
export default function MyComponent() {
|
|
62
|
+
return <Button color="primary">Click me!</Button>;
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
# Developer Notes
|
|
69
|
+
|
|
70
|
+
## CSS and Custom Styling
|
|
71
|
+
|
|
72
|
+
- **Prefer Tailwind classes inline** whenever possible.
|
|
73
|
+
- If additional CSS is needed, include it in your components.
|
|
74
|
+
- **Important:** After running `npm run build`, always check `dist/index.css` to ensure your custom styles are included in the final build.
|
|
75
|
+
|
|
76
|
+
- **Use `styles/theme.css` for global customizations**:
|
|
77
|
+
- Store custom shorthand colors, CSS variables, or utility classes here.
|
|
78
|
+
- <span style="color:red; font-weight:bold; text-decoration:underline; font-style:italic;">These styles will be available to consumers when they import the library `Go check step 3`.</span>
|
|
79
|
+
- Example:
|
|
80
|
+
```css
|
|
81
|
+
@theme {
|
|
82
|
+
--color-sus-primary-1: #000;
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
- **Reference:** [Tailwind Theme Variable Namespaces](https://tailwindcss.com/docs/theme#theme-variable-namespaces)
|
|
86
|
+
|
|
87
|
+
## Including External Files in the Build
|
|
88
|
+
|
|
89
|
+
- **Add your files to `copy-files-to-dist.js`**:
|
|
90
|
+
- This script handles copying files into the `dist` folder during the build process.
|
|
91
|
+
- Example entry:
|
|
92
|
+
```js
|
|
93
|
+
const filesToCopy = [
|
|
94
|
+
{
|
|
95
|
+
from: "./src/styles/theme.css",
|
|
96
|
+
to: "./dist/index.css",
|
|
97
|
+
mode: "prepend" // "replace" | "append" | "prepend"
|
|
98
|
+
}
|
|
99
|
+
];
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
- **How `mode` works:**
|
|
103
|
+
- `"replace"` → overwrite the destination file completely.
|
|
104
|
+
- `"append"` → add content at the end of the destination file.
|
|
105
|
+
- `"prepend"` → add content at the beginning of the destination file.
|
|
106
|
+
- This script handles copying files into the `dist` folder during the build process.
|
|
107
|
+
- **Note:** This will happen automatically when you run `npm run build`.
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
@theme {
|
|
2
|
+
/* core colors */
|
|
3
|
+
--color-sus-primary-1: rgba(65, 135, 92, 1);
|
|
4
|
+
--color-sus-primary-2: #77ab8a;
|
|
5
|
+
--color-sus-primary-3: #dfeae3;
|
|
6
|
+
--color-sus-secondary-1: rgba(164, 144, 83, 1);
|
|
7
|
+
--color-sus-secondary-2: #ab9555;
|
|
8
|
+
--color-sus-black: rgba(0, 0, 0, 1);
|
|
9
|
+
--color-sus-gray: #808080;
|
|
10
|
+
--color-sus-lightgray: rgba(0, 0, 0, 0.2);
|
|
11
|
+
--color-sus-offwhite: rgba(248, 250, 252, 1);
|
|
12
|
+
--color-sus-info: rgba(46, 112, 226, 1);
|
|
13
|
+
--color-sus-error: rgba(195, 42, 44, 1);
|
|
14
|
+
--color-sus-warning: rgba(255, 193, 7, 1);
|
|
15
|
+
--color-sus-success: rgba(55, 154, 42, 1);
|
|
16
|
+
/* uxui designer don't put this color to core colors? */
|
|
17
|
+
--color-sus-green-1: #127035;
|
|
18
|
+
--color-sus-green-2: #379a2a;
|
|
19
|
+
--color-sus-gray-1: #afb4c3;
|
|
20
|
+
--color-sus-gray-2: #f7f4f4;
|
|
21
|
+
--color-sus-gray-3: #eaeaea;
|
|
22
|
+
--color-sus-gray-4: #f7fcf9;
|
|
23
|
+
--color-sus-gray-5: #41875c;
|
|
24
|
+
--color-sus-primary-1-hover: rgba(50, 100, 70, 1);
|
|
25
|
+
--color-sus-primary-2-hover: #8db89c;
|
|
26
|
+
--color-sus-primary-3-hover: #eff5f1;
|
|
27
|
+
--color-sus-primary-1-active: #dfeae3;
|
|
28
|
+
--color-sus-secondary-hover: #907b46;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* src/components/advanceSearch/styles/index.css */
|
|
32
|
+
.clear-button {
|
|
33
|
+
width: 15px;
|
|
34
|
+
height: 15px;
|
|
35
|
+
font-weight: bold;
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
background-color: black;
|
|
38
|
+
color: white;
|
|
39
|
+
border: 1px solid black;
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
transition: background-color 0.15s ease;
|
|
44
|
+
padding: 0;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
}
|
|
47
|
+
.clear-button:hover {
|
|
48
|
+
background-color: #333;
|
|
49
|
+
}
|
|
50
|
+
.clear-button .icon {
|
|
51
|
+
width: 13px;
|
|
52
|
+
height: 13px;
|
|
53
|
+
}
|
|
54
|
+
.circle-btn {
|
|
55
|
+
width: 24px;
|
|
56
|
+
height: 24px;
|
|
57
|
+
border-radius: 50%;
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
padding: 0;
|
|
62
|
+
aspect-ratio: 1/1;
|
|
63
|
+
}
|
|
64
|
+
/*# sourceMappingURL=index.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/advanceSearch/styles/index.css"],"sourcesContent":[".clear-button {\n width: 15px;\n height: 15px;\n font-weight: bold;\n border-radius: 50%;\n background-color: black;\n color: white;\n border: 1px solid black;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background-color 0.15s ease;\n padding: 0;\n cursor: pointer;\n}\n\n.clear-button:hover {\n background-color: #333; /* เข้มขึ้นเวลา hover */\n}\n\n.clear-button .icon {\n width: 13px;\n height: 13px;\n}\n\n.circle-btn {\n width: 24px; /* small size */\n height: 24px; /* same as width */\n border-radius: 50%; /* perfect circle */\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0; /* remove default button padding */\n aspect-ratio: 1/1; /* force square, prevents oval */\n}\n"],"mappings":";AAAA,CAAC;AACC,SAAO;AACP,UAAQ;AACR,eAAa;AACb,iBAAe;AACf,oBAAkB;AAClB,SAAO;AACP,UAAQ,IAAI,MAAM;AAClB,WAAS;AACT,eAAa;AACb,mBAAiB;AACjB,cAAY,iBAAiB,MAAM;AACnC,WAAS;AACT,UAAQ;AACV;AAEA,CAhBC,YAgBY;AACX,oBAAkB;AACpB;AAEA,CApBC,aAoBa,CAAC;AACb,SAAO;AACP,UAAQ;AACV;AAEA,CAAC;AACC,SAAO;AACP,UAAQ;AACR,iBAAe;AACf,WAAS;AACT,eAAa;AACb,mBAAiB;AACjB,WAAS;AACT,gBAAc,CAAC,CAAC;AAClB;","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React$1 from 'react';
|
|
3
|
+
import React__default, { CSSProperties, ReactNode } from 'react';
|
|
4
|
+
import { FieldValues, FieldPath, ControllerProps, UseFormGetFieldState } from 'react-hook-form';
|
|
5
|
+
import { Header, RowData as RowData$1, Column as Column$1, Table as Table$1, ColumnDef, ColumnFiltersState, OnChangeFn, FilterFnOption, SortingState, ColumnOrderState, VisibilityState, ColumnPinningState, GroupingState, GroupingOptions, ColumnResizeMode, RowSelectionState, Row, ExpandedState, HeaderGroup, Cell, HeaderContext } from '@tanstack/react-table';
|
|
6
|
+
import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
|
|
7
|
+
import { VariantProps } from 'class-variance-authority';
|
|
8
|
+
import { ClassValue } from 'clsx';
|
|
9
|
+
import * as zustand from 'zustand';
|
|
10
|
+
|
|
11
|
+
type FormErrorMessageProps = React__default.ComponentProps<"p"> & {
|
|
12
|
+
errorClassName?: string;
|
|
13
|
+
};
|
|
14
|
+
declare function FormErrorMessage({ className, errorClassName, ...props }: FormErrorMessageProps): react_jsx_runtime.JSX.Element | null;
|
|
15
|
+
|
|
16
|
+
type FormFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = ControllerProps<TFieldValues, TName>;
|
|
17
|
+
type FormFieldContextValue<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
|
|
18
|
+
name: TName;
|
|
19
|
+
};
|
|
20
|
+
declare const FormFieldContext: React$1.Context<FormFieldContextValue<FieldValues, string>>;
|
|
21
|
+
declare function FormField<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: FormFieldProps<TFieldValues, TName>): react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
type FormItemProps = React__default.ComponentProps<"div">;
|
|
24
|
+
type FormItemContextValue = {
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
declare const FormItemContext: React__default.Context<FormItemContextValue>;
|
|
28
|
+
declare function FormItem({ children, ...props }: FormItemProps): react_jsx_runtime.JSX.Element;
|
|
29
|
+
|
|
30
|
+
type FormLabelProps = React__default.ComponentProps<"label"> & {
|
|
31
|
+
errorClassName?: string;
|
|
32
|
+
required?: boolean;
|
|
33
|
+
};
|
|
34
|
+
declare function FormLabel({ children, className, errorClassName, required, ...props }: FormLabelProps): react_jsx_runtime.JSX.Element;
|
|
35
|
+
|
|
36
|
+
type UseFormFieldOptions = {
|
|
37
|
+
skipValidationIfNoContext?: boolean;
|
|
38
|
+
};
|
|
39
|
+
type UseFormFieldReturn = ReturnType<UseFormGetFieldState<any>> & {
|
|
40
|
+
prefixId: string | undefined;
|
|
41
|
+
name: string | undefined;
|
|
42
|
+
formItemId: string | undefined;
|
|
43
|
+
formLabelId: string | undefined;
|
|
44
|
+
formErrorMessageId: string | undefined;
|
|
45
|
+
};
|
|
46
|
+
declare function useFormField(options?: UseFormFieldOptions): UseFormFieldReturn;
|
|
47
|
+
|
|
48
|
+
type TextInputProps = React__default.ComponentProps<"input">;
|
|
49
|
+
declare function TextInput({ className, ...props }: TextInputProps): react_jsx_runtime.JSX.Element;
|
|
50
|
+
|
|
51
|
+
type NumberInputProps = React__default.ComponentProps<"input">;
|
|
52
|
+
declare function NumberInput({ className, ...props }: NumberInputProps): react_jsx_runtime.JSX.Element;
|
|
53
|
+
|
|
54
|
+
declare function TableContainer({ className, children, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
55
|
+
declare function Table({ className, ...props }: React$1.ComponentProps<"table">): react_jsx_runtime.JSX.Element;
|
|
56
|
+
declare function TableHeader({ className, ...props }: React$1.ComponentProps<"thead">): react_jsx_runtime.JSX.Element;
|
|
57
|
+
declare function TableBody({ className, ...props }: React$1.ComponentProps<"tbody">): react_jsx_runtime.JSX.Element;
|
|
58
|
+
declare function TableRow({ className, ...props }: React$1.ComponentProps<"tr">): react_jsx_runtime.JSX.Element;
|
|
59
|
+
|
|
60
|
+
type ColumnResizerProps = {
|
|
61
|
+
header: Header<any, any>;
|
|
62
|
+
className?: string;
|
|
63
|
+
style?: CSSProperties;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
type DataTableColumnFilterProps<TData extends RowData$1> = {
|
|
67
|
+
column: Column$1<TData>;
|
|
68
|
+
table: Table$1<TData>;
|
|
69
|
+
};
|
|
70
|
+
type DataTableFilterConfig = {
|
|
71
|
+
enabled: boolean;
|
|
72
|
+
manual?: boolean;
|
|
73
|
+
maxDepth?: number;
|
|
74
|
+
filterFromLeafRows?: boolean;
|
|
75
|
+
};
|
|
76
|
+
type DataTableColumnFilter = {
|
|
77
|
+
enabled?: boolean;
|
|
78
|
+
initialState?: ColumnFiltersState;
|
|
79
|
+
state?: ColumnFiltersState;
|
|
80
|
+
onFilterChange?: OnChangeFn<ColumnFiltersState>;
|
|
81
|
+
};
|
|
82
|
+
type DataTableGlobalFilter<TData extends RowData$1> = {
|
|
83
|
+
enabled?: boolean;
|
|
84
|
+
initialState?: any;
|
|
85
|
+
state?: any;
|
|
86
|
+
filterFn?: FilterFnOption<TData>;
|
|
87
|
+
onFilterChange?: OnChangeFn<any>;
|
|
88
|
+
canColumnFilterable?: (column: Column$1<TData, unknown>) => boolean;
|
|
89
|
+
};
|
|
90
|
+
type DataTableFilters<TData extends RowData$1> = DataTableFilterConfig & {
|
|
91
|
+
column?: DataTableColumnFilter;
|
|
92
|
+
global?: DataTableGlobalFilter<TData>;
|
|
93
|
+
};
|
|
94
|
+
type DataTableColumnSorting = {
|
|
95
|
+
enabled: boolean;
|
|
96
|
+
manual?: boolean;
|
|
97
|
+
initialState?: SortingState;
|
|
98
|
+
state?: SortingState;
|
|
99
|
+
sortDescFirst?: boolean;
|
|
100
|
+
onSortingChange?: OnChangeFn<SortingState>;
|
|
101
|
+
};
|
|
102
|
+
type DataTableRowSelection<TData> = {
|
|
103
|
+
enabled: boolean;
|
|
104
|
+
initialState?: RowSelectionState;
|
|
105
|
+
state?: RowSelectionState;
|
|
106
|
+
canRowSelectable?: boolean | ((row: Row<TData>) => boolean);
|
|
107
|
+
multiSelect?: boolean;
|
|
108
|
+
onSelectionChange?: OnChangeFn<RowSelectionState>;
|
|
109
|
+
};
|
|
110
|
+
type DataTableColumnPinning = {
|
|
111
|
+
enabled: boolean;
|
|
112
|
+
initialState?: ColumnPinningState;
|
|
113
|
+
state?: ColumnPinningState;
|
|
114
|
+
onPinningChange?: OnChangeFn<ColumnPinningState>;
|
|
115
|
+
};
|
|
116
|
+
type DataTableColumnOrdering = {
|
|
117
|
+
enabled: boolean;
|
|
118
|
+
initialState?: string[];
|
|
119
|
+
state?: string[];
|
|
120
|
+
onOrderChange?: OnChangeFn<ColumnOrderState>;
|
|
121
|
+
};
|
|
122
|
+
type DataTableColumnVisibility = {
|
|
123
|
+
enabled: boolean;
|
|
124
|
+
initialState?: VisibilityState;
|
|
125
|
+
state?: VisibilityState;
|
|
126
|
+
onVisibilityChange?: OnChangeFn<VisibilityState>;
|
|
127
|
+
};
|
|
128
|
+
type DataTableRowExpansion<TData extends RowData$1> = {
|
|
129
|
+
enabled: boolean;
|
|
130
|
+
manual?: boolean;
|
|
131
|
+
initialState?: ExpandedState;
|
|
132
|
+
state?: ExpandedState;
|
|
133
|
+
onExpandedChange?: OnChangeFn<ExpandedState>;
|
|
134
|
+
isRowExpanded?: (row: Row<TData>) => boolean;
|
|
135
|
+
canRowExpand?: (row: Row<TData>) => boolean;
|
|
136
|
+
};
|
|
137
|
+
type DataTableColumnGrouping = {
|
|
138
|
+
manual?: boolean;
|
|
139
|
+
enabled: boolean;
|
|
140
|
+
groupedMode?: false | "reorder" | "remove";
|
|
141
|
+
initialState?: GroupingState;
|
|
142
|
+
state?: GroupingState;
|
|
143
|
+
customAggregationFns?: GroupingOptions["aggregationFns"];
|
|
144
|
+
onGroupingChange?: OnChangeFn<GroupingState>;
|
|
145
|
+
};
|
|
146
|
+
type DataTableRowClickHandler<TData extends RowData$1> = (rowData: TData, info: {
|
|
147
|
+
event: React.MouseEvent<HTMLTableRowElement>;
|
|
148
|
+
row: Row<TData>;
|
|
149
|
+
table: Table$1<TData>;
|
|
150
|
+
}) => void;
|
|
151
|
+
type DataTableRowIdKeyHandler<TData extends RowData$1> = (originalRow: TData, index: number, parent?: Row<TData>) => string;
|
|
152
|
+
type DataTableHeaderCell<TData extends RowData$1> = {
|
|
153
|
+
id: string;
|
|
154
|
+
columnId: string;
|
|
155
|
+
content: React.ReactNode;
|
|
156
|
+
originalCell: Header<TData, unknown>;
|
|
157
|
+
};
|
|
158
|
+
type DataTableRenderHeaderProps<TData extends RowData$1> = {
|
|
159
|
+
headerGroup: HeaderGroup<TData>;
|
|
160
|
+
table: Table$1<TData>;
|
|
161
|
+
cells: DataTableHeaderCell<TData>[];
|
|
162
|
+
};
|
|
163
|
+
type DataTableRenderHeaderHandler<TData extends RowData$1> = (props: DataTableRenderHeaderProps<TData>) => React.ReactNode;
|
|
164
|
+
type DataTableRowCell<TData extends RowData$1> = {
|
|
165
|
+
id: string;
|
|
166
|
+
columnId: string;
|
|
167
|
+
content: React.ReactNode;
|
|
168
|
+
originalCell: Cell<TData, unknown>;
|
|
169
|
+
};
|
|
170
|
+
type DataTableRenderRowProps<TData extends RowData$1> = {
|
|
171
|
+
row: Row<TData>;
|
|
172
|
+
cells: DataTableRowCell<TData>[];
|
|
173
|
+
table: Table$1<TData>;
|
|
174
|
+
};
|
|
175
|
+
type DataTableRenderRowHandler<TData extends RowData$1> = (props: DataTableRenderRowProps<TData>) => React.ReactNode;
|
|
176
|
+
type DataTableChildrenKeyHandler<TData> = (originalRow: TData, index: number) => TData[] | undefined;
|
|
177
|
+
type DatatableColumnResizing = {
|
|
178
|
+
enabled: boolean;
|
|
179
|
+
resizeMode?: ColumnResizeMode;
|
|
180
|
+
};
|
|
181
|
+
type DataTableComponentProps<TData> = {
|
|
182
|
+
containerProps?: React.ComponentProps<typeof TableContainer>;
|
|
183
|
+
tableProps?: React.ComponentProps<typeof Table>;
|
|
184
|
+
tableHeaderProps?: React.ComponentProps<typeof TableHeader>;
|
|
185
|
+
tableBodyProps?: React.ComponentProps<typeof TableBody>;
|
|
186
|
+
tableDataRowProps?: React.ComponentProps<typeof TableRow> | ((info: {
|
|
187
|
+
row: Row<TData>;
|
|
188
|
+
table: Table$1<TData>;
|
|
189
|
+
}) => React.ComponentProps<typeof TableRow>);
|
|
190
|
+
columnResizerProps?: Omit<ColumnResizerProps, "header">;
|
|
191
|
+
};
|
|
192
|
+
type ContentSlot = {
|
|
193
|
+
content: React.ReactNode;
|
|
194
|
+
wrapperProps?: React.ComponentProps<"div">;
|
|
195
|
+
};
|
|
196
|
+
type DataTableStatusContent = {
|
|
197
|
+
initialLoading?: ContentSlot;
|
|
198
|
+
fetchingMore?: ContentSlot;
|
|
199
|
+
noMoreData?: ContentSlot;
|
|
200
|
+
emptyData?: ContentSlot;
|
|
201
|
+
emptyFilteredData?: ContentSlot;
|
|
202
|
+
};
|
|
203
|
+
type DataTableScrollFetch = {
|
|
204
|
+
enabled: boolean;
|
|
205
|
+
fetchMore?: () => void;
|
|
206
|
+
hasMore?: boolean;
|
|
207
|
+
isFetchingMore?: boolean;
|
|
208
|
+
};
|
|
209
|
+
type DataTableProps<TData extends RowData$1> = {
|
|
210
|
+
data: TData[];
|
|
211
|
+
columns: ColumnDef<TData, any>[];
|
|
212
|
+
filters?: DataTableFilters<TData>;
|
|
213
|
+
sorting?: DataTableColumnSorting;
|
|
214
|
+
columnOrder?: DataTableColumnOrdering;
|
|
215
|
+
columnVisibility?: DataTableColumnVisibility;
|
|
216
|
+
columnPinning?: DataTableColumnPinning;
|
|
217
|
+
columnGrouping?: DataTableColumnGrouping;
|
|
218
|
+
columnResizing?: DatatableColumnResizing;
|
|
219
|
+
rowSelection?: DataTableRowSelection<TData>;
|
|
220
|
+
rowExpansion?: DataTableRowExpansion<TData>;
|
|
221
|
+
scrollFetch?: DataTableScrollFetch;
|
|
222
|
+
components?: DataTableComponentProps<TData>;
|
|
223
|
+
statusContent?: DataTableStatusContent;
|
|
224
|
+
tableRef?: React.RefObject<Table$1<TData> | null>;
|
|
225
|
+
isInitialLoading?: boolean;
|
|
226
|
+
debug?: boolean;
|
|
227
|
+
rowIdKey?: DataTableRowIdKeyHandler<TData>;
|
|
228
|
+
childrenKey?: DataTableChildrenKeyHandler<TData>;
|
|
229
|
+
onRowClick?: DataTableRowClickHandler<TData>;
|
|
230
|
+
};
|
|
231
|
+
declare const DataTable: <TData extends RowData$1>({ tableRef, isInitialLoading, columns, data, filters, sorting, columnOrder, columnVisibility, columnPinning, columnGrouping, columnResizing, rowSelection, rowExpansion, scrollFetch, statusContent, rowIdKey, childrenKey, onRowClick, debug, components }: DataTableProps<TData>) => react_jsx_runtime.JSX.Element;
|
|
232
|
+
|
|
233
|
+
declare module "@tanstack/react-table" {
|
|
234
|
+
interface ColumnMeta<TData extends RowData> {
|
|
235
|
+
headerProps?: React.ComponentProps<"th">;
|
|
236
|
+
cellProps?: React.ComponentProps<"td">;
|
|
237
|
+
useColumnSizing?: boolean;
|
|
238
|
+
renderColumnFilter?: (props: DataTableColumnFilterProps<TData>) => ReactNode;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
declare function compareAlphanumeric(aStr: string, bStr: string): number;
|
|
243
|
+
|
|
244
|
+
declare function booleanToSelectValue(value: boolean | undefined, options?: {
|
|
245
|
+
fallbackUndefinedValue?: string;
|
|
246
|
+
}): string;
|
|
247
|
+
declare function selectValueToBoolean(value: string): boolean | undefined;
|
|
248
|
+
declare function renderContentSlot(slot: ContentSlot, defaultWrapperProps?: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element | null;
|
|
249
|
+
|
|
250
|
+
type SorterProps = {
|
|
251
|
+
show?: boolean;
|
|
252
|
+
};
|
|
253
|
+
type HeaderCellProps<TData = any, TValue = any> = {
|
|
254
|
+
label: React.ReactNode;
|
|
255
|
+
context: HeaderContext<TData, TValue>;
|
|
256
|
+
rootClassName?: string;
|
|
257
|
+
labelClassName?: string;
|
|
258
|
+
sorterProps?: SorterProps;
|
|
259
|
+
};
|
|
260
|
+
declare const HeaderCell: ({ rootClassName, labelClassName, context, label, sorterProps }: HeaderCellProps) => react_jsx_runtime.JSX.Element;
|
|
261
|
+
|
|
262
|
+
declare const buttonVariants: (props?: ({
|
|
263
|
+
variant?: "link" | "default" | "outline" | "cancel" | "destructive" | "secondary" | "ghost" | "defaultSelect" | "defaultOutline" | null | undefined;
|
|
264
|
+
size?: "default" | "option" | "icon" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-md" | "icon-lg" | null | undefined;
|
|
265
|
+
active?: boolean | null | undefined;
|
|
266
|
+
} & class_variance_authority_dist_types.ClassProp) | undefined) => string;
|
|
267
|
+
declare function Button({ className, variant, size, active, asChild, ...props }: React$1.ComponentProps<'button'> & VariantProps<typeof buttonVariants> & {
|
|
268
|
+
asChild?: boolean;
|
|
269
|
+
active?: boolean;
|
|
270
|
+
}): react_jsx_runtime.JSX.Element;
|
|
271
|
+
|
|
272
|
+
type Column = {
|
|
273
|
+
id: string;
|
|
274
|
+
};
|
|
275
|
+
type GridPayload<TColumn extends {
|
|
276
|
+
id: string;
|
|
277
|
+
} = Column> = {
|
|
278
|
+
ordering: TColumn["id"][];
|
|
279
|
+
visibility: Record<TColumn["id"], boolean>;
|
|
280
|
+
pinning: {
|
|
281
|
+
left: TColumn["id"][];
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
type GridSettingsModalProps = {
|
|
286
|
+
isOpen: boolean;
|
|
287
|
+
headerClassname?: string;
|
|
288
|
+
descriptionClassname?: string;
|
|
289
|
+
addButtonClassname?: string;
|
|
290
|
+
saveButtonClassname?: string;
|
|
291
|
+
availableColumns: Column[];
|
|
292
|
+
currentColumns: Column[];
|
|
293
|
+
limit?: number;
|
|
294
|
+
onClose: () => void;
|
|
295
|
+
onSaveColumns?: (payload: GridPayload) => void;
|
|
296
|
+
};
|
|
297
|
+
declare const GridSettingsModal: ({ isOpen, headerClassname, descriptionClassname, addButtonClassname, saveButtonClassname, availableColumns, currentColumns, limit, onClose, onSaveColumns }: GridSettingsModalProps) => react_jsx_runtime.JSX.Element;
|
|
298
|
+
|
|
299
|
+
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
|
|
300
|
+
[K in Keys]: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
|
301
|
+
}[Keys];
|
|
302
|
+
type NavbarBaseProps = {
|
|
303
|
+
className?: string;
|
|
304
|
+
title?: React__default.ReactNode;
|
|
305
|
+
subTitle?: React__default.ReactNode;
|
|
306
|
+
headImageURL?: string;
|
|
307
|
+
headImageURLClassName?: string;
|
|
308
|
+
tooltipTitle?: string;
|
|
309
|
+
tooltipIcon?: React__default.ReactNode;
|
|
310
|
+
tooltipdescription?: React__default.ReactNode;
|
|
311
|
+
mainButtonText?: React__default.ReactNode;
|
|
312
|
+
mainButtonClassName?: string;
|
|
313
|
+
mainButtonDisable?: boolean;
|
|
314
|
+
subButtonText?: React__default.ReactNode;
|
|
315
|
+
subButtonClassName?: string;
|
|
316
|
+
subButtonDisable?: boolean;
|
|
317
|
+
onMainButtonClick?: () => void;
|
|
318
|
+
onSubButtonClick?: () => void;
|
|
319
|
+
searchButton?: React__default.ReactNode;
|
|
320
|
+
};
|
|
321
|
+
type NavbarProps = RequireAtLeastOne<NavbarBaseProps, "title" | "headImageURL">;
|
|
322
|
+
declare const _default: React__default.MemoExoticComponent<({ className, title, subTitle, headImageURL, headImageURLClassName, tooltipTitle, tooltipIcon, tooltipdescription, mainButtonText, mainButtonClassName, mainButtonDisable, subButtonText, subButtonClassName, subButtonDisable, onMainButtonClick, onSubButtonClick, searchButton }: NavbarProps) => react_jsx_runtime.JSX.Element>;
|
|
323
|
+
|
|
324
|
+
type FieldType = "text" | "number" | "date" | "datetime" | "checkbox" | "dropdown" | "lookup";
|
|
325
|
+
type Option = {
|
|
326
|
+
value: string;
|
|
327
|
+
label: string;
|
|
328
|
+
};
|
|
329
|
+
interface FieldSchemaBase<T extends FieldType> {
|
|
330
|
+
name: string;
|
|
331
|
+
type: T;
|
|
332
|
+
label?: string;
|
|
333
|
+
}
|
|
334
|
+
interface DropdownFieldSchema extends FieldSchemaBase<"dropdown"> {
|
|
335
|
+
options: Option[];
|
|
336
|
+
}
|
|
337
|
+
type TextFieldSchema = FieldSchemaBase<"text">;
|
|
338
|
+
type NumberFieldSchema = FieldSchemaBase<"number">;
|
|
339
|
+
type DateFieldSchema = FieldSchemaBase<"date">;
|
|
340
|
+
type DateTimeFieldSchema = FieldSchemaBase<"datetime">;
|
|
341
|
+
type CheckboxFieldSchema = FieldSchemaBase<"checkbox">;
|
|
342
|
+
type LookupFieldSchema = FieldSchemaBase<"lookup">;
|
|
343
|
+
type FieldSchema = DropdownFieldSchema | TextFieldSchema | NumberFieldSchema | DateFieldSchema | DateTimeFieldSchema | CheckboxFieldSchema | LookupFieldSchema;
|
|
344
|
+
interface AdvanceSearchProps {
|
|
345
|
+
fields: FieldSchema[];
|
|
346
|
+
portalId: string;
|
|
347
|
+
limitRows?: number;
|
|
348
|
+
iconColor?: string;
|
|
349
|
+
onSearch?: (param: Record<string, unknown>) => void;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
declare const AdvanceSearch: React__default.FC<AdvanceSearchProps>;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Utility function to intelligently combine class names using `clsx`
|
|
356
|
+
* and resolve Tailwind CSS class conflicts using `tailwind-merge`.
|
|
357
|
+
*
|
|
358
|
+
* This function is commonly used in React or other frontend frameworks
|
|
359
|
+
* to conditionally merge Tailwind classes and avoid class duplication or conflict,
|
|
360
|
+
* especially when combining utility variants like `bg-red-500` and `bg-blue-500`.
|
|
361
|
+
*
|
|
362
|
+
* @param {...ClassValue[]} args - A variadic list of class values. Each can be:
|
|
363
|
+
* - string: e.g. `"px-4 py-2"`
|
|
364
|
+
* - object: e.g. `{ 'text-red-500': isError }`
|
|
365
|
+
* - array: e.g. `['bg-blue-500', conditionalClass]`
|
|
366
|
+
* These will be normalized and merged by `clsx`, then conflict-resolved by `tailwind-merge`.
|
|
367
|
+
*
|
|
368
|
+
* @returns {string} A single string of valid Tailwind class names with conflicts resolved.
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```tsx
|
|
372
|
+
* <button className={cn("px-4 py-2", isPrimary && "bg-blue-500", "bg-red-500")} />
|
|
373
|
+
* // Result: "px-4 py-2 bg-blue-500" (if isPrimary is true)
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* @see https://github.com/lukeed/clsx - `clsx` docs for conditional class logic
|
|
377
|
+
* @see https://github.com/dcastil/tailwind-merge - `tailwind-merge` docs for conflict resolution
|
|
378
|
+
*/
|
|
379
|
+
declare function cn(...args: ClassValue[]): string;
|
|
380
|
+
|
|
381
|
+
type TanstackTableInstance$1 = {
|
|
382
|
+
getAllColumns(): any[];
|
|
383
|
+
};
|
|
384
|
+
declare function getColumnIdFromTable<T extends TanstackTableInstance$1>(table: T): {
|
|
385
|
+
availableColumns: {
|
|
386
|
+
id: any;
|
|
387
|
+
}[];
|
|
388
|
+
currentColumns: {
|
|
389
|
+
id: any;
|
|
390
|
+
}[];
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
type TanstackTableInstance = {
|
|
394
|
+
getAllColumns(): any[];
|
|
395
|
+
getVisibleLeafColumns(): any[];
|
|
396
|
+
};
|
|
397
|
+
type UseGridSettingsStoreActions = {
|
|
398
|
+
setAvailableColumns: (cols: Column[]) => void;
|
|
399
|
+
setCurrentColumns: (cols: Column[]) => void;
|
|
400
|
+
setPayload: (payload: GridPayload) => void;
|
|
401
|
+
reset: () => void;
|
|
402
|
+
extractColumns: (table: TanstackTableInstance) => {
|
|
403
|
+
availableColumns: Column[];
|
|
404
|
+
currentColumns: Column[];
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
type UseGridSettingsStoreState = {
|
|
408
|
+
availableColumns: Column[];
|
|
409
|
+
currentColumns: Column[];
|
|
410
|
+
payload: GridPayload;
|
|
411
|
+
};
|
|
412
|
+
declare const useGridSettingsStore: zustand.UseBoundStore<zustand.StoreApi<UseGridSettingsStoreState & UseGridSettingsStoreActions>>;
|
|
413
|
+
|
|
414
|
+
type UseHoverResult = {
|
|
415
|
+
ref: React__default.RefCallback<HTMLElement>;
|
|
416
|
+
hovering: boolean;
|
|
417
|
+
};
|
|
418
|
+
declare const useHover: () => UseHoverResult;
|
|
419
|
+
|
|
420
|
+
type UseIntersectionObserverOptions = {
|
|
421
|
+
root?: Element | Document | null;
|
|
422
|
+
rootMargin?: string;
|
|
423
|
+
threshold?: number | number[];
|
|
424
|
+
freezeOnceVisible?: boolean;
|
|
425
|
+
onChange?: (isIntersecting: boolean, entry: IntersectionObserverEntry) => void;
|
|
426
|
+
initialIsIntersecting?: boolean;
|
|
427
|
+
};
|
|
428
|
+
type IntersectionReturn = [
|
|
429
|
+
(node?: Element | null) => void,
|
|
430
|
+
boolean,
|
|
431
|
+
IntersectionObserverEntry | undefined
|
|
432
|
+
] & {
|
|
433
|
+
ref: (node?: Element | null) => void;
|
|
434
|
+
isIntersecting: boolean;
|
|
435
|
+
entry?: IntersectionObserverEntry;
|
|
436
|
+
};
|
|
437
|
+
declare const useIntersectionObserver: ({ threshold, root, rootMargin, freezeOnceVisible, initialIsIntersecting, onChange }?: UseIntersectionObserverOptions) => IntersectionReturn;
|
|
438
|
+
|
|
439
|
+
type UseMediaQueryOptions = {
|
|
440
|
+
query: string;
|
|
441
|
+
};
|
|
442
|
+
type UseMediaQueryResult = boolean;
|
|
443
|
+
declare const useMediaQuery: ({ query }: UseMediaQueryOptions) => UseMediaQueryResult;
|
|
444
|
+
|
|
445
|
+
type UseScreenSizeResult = {
|
|
446
|
+
isMobile: boolean;
|
|
447
|
+
isTablet: boolean;
|
|
448
|
+
isDesktop: boolean;
|
|
449
|
+
};
|
|
450
|
+
type Breakpoints = {
|
|
451
|
+
mobile?: string;
|
|
452
|
+
tablet?: string;
|
|
453
|
+
desktop?: string;
|
|
454
|
+
};
|
|
455
|
+
declare const useScreenSize: (breakpoints?: Breakpoints) => UseScreenSizeResult;
|
|
456
|
+
|
|
457
|
+
export { AdvanceSearch, type Breakpoints, Button, type Column, type ContentSlot, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, type FieldSchema, FormErrorMessage, type FormErrorMessageProps, FormField, FormFieldContext, type FormFieldContextValue, type FormFieldProps, FormItem, FormItemContext, type FormItemContextValue, type FormItemProps, FormLabel, type FormLabelProps, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, _default as Navbar, type NavbarProps, NumberInput, type NumberInputProps, type SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UseScreenSizeResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, useScreenSize };
|