dgz-ui-shared 1.1.24 → 1.1.25

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 (77) hide show
  1. package/README.md +236 -31
  2. package/dist/dgz-ui-shared.css +1 -1
  3. package/dist/types/components/actions/Actions.d.ts +9 -0
  4. package/dist/types/components/actions/Actions.d.ts.map +1 -1
  5. package/dist/types/components/confirm/Confirm.d.ts +7 -0
  6. package/dist/types/components/confirm/Confirm.d.ts.map +1 -1
  7. package/dist/types/components/confirm/PasswordConfirm.d.ts +4 -0
  8. package/dist/types/components/confirm/PasswordConfirm.d.ts.map +1 -1
  9. package/dist/types/components/datatable/DataTable.d.ts +20 -0
  10. package/dist/types/components/datatable/DataTable.d.ts.map +1 -1
  11. package/dist/types/components/datatable/MyTable.d.ts +16 -0
  12. package/dist/types/components/datatable/MyTable.d.ts.map +1 -1
  13. package/dist/types/components/datepicker/DateRangePicker.d.ts +9 -0
  14. package/dist/types/components/datepicker/DateRangePicker.d.ts.map +1 -1
  15. package/dist/types/components/filters/FilterWrapper.d.ts +17 -0
  16. package/dist/types/components/filters/FilterWrapper.d.ts.map +1 -1
  17. package/dist/types/components/filters/Search.d.ts +7 -0
  18. package/dist/types/components/filters/Search.d.ts.map +1 -1
  19. package/dist/types/components/filters/SearchWithCtrl.d.ts +5 -0
  20. package/dist/types/components/filters/SearchWithCtrl.d.ts.map +1 -1
  21. package/dist/types/components/form/MyCheckbox.d.ts +4 -0
  22. package/dist/types/components/form/MyCheckbox.d.ts.map +1 -1
  23. package/dist/types/components/form/MyDatePicker.d.ts +5 -0
  24. package/dist/types/components/form/MyDatePicker.d.ts.map +1 -1
  25. package/dist/types/components/form/MyDateRangePicker.d.ts +5 -0
  26. package/dist/types/components/form/MyDateRangePicker.d.ts.map +1 -1
  27. package/dist/types/components/form/MyHtmlEditor.d.ts +5 -0
  28. package/dist/types/components/form/MyHtmlEditor.d.ts.map +1 -1
  29. package/dist/types/components/form/MyInput.d.ts +4 -0
  30. package/dist/types/components/form/MyInput.d.ts.map +1 -1
  31. package/dist/types/components/form/MyMaskInput.d.ts +5 -0
  32. package/dist/types/components/form/MyMaskInput.d.ts.map +1 -1
  33. package/dist/types/components/form/MyRadio.d.ts +4 -0
  34. package/dist/types/components/form/MyRadio.d.ts.map +1 -1
  35. package/dist/types/components/form/MySelect.d.ts +5 -0
  36. package/dist/types/components/form/MySelect.d.ts.map +1 -1
  37. package/dist/types/components/form/MySwitch.d.ts +4 -0
  38. package/dist/types/components/form/MySwitch.d.ts.map +1 -1
  39. package/dist/types/components/form/MyTextarea.d.ts +4 -0
  40. package/dist/types/components/form/MyTextarea.d.ts.map +1 -1
  41. package/dist/types/components/form/MyTimePicker.d.ts +6 -0
  42. package/dist/types/components/form/MyTimePicker.d.ts.map +1 -1
  43. package/dist/types/components/gallery/MyGallery.d.ts +22 -0
  44. package/dist/types/components/gallery/MyGallery.d.ts.map +1 -1
  45. package/dist/types/components/modal/MyModal.d.ts +9 -0
  46. package/dist/types/components/modal/MyModal.d.ts.map +1 -1
  47. package/dist/types/components/pagination/MyLimitSelect.d.ts +6 -0
  48. package/dist/types/components/pagination/MyLimitSelect.d.ts.map +1 -1
  49. package/dist/types/components/pagination/MyPagination.d.ts +6 -0
  50. package/dist/types/components/pagination/MyPagination.d.ts.map +1 -1
  51. package/dist/types/components/tooltip/MyTooltip.d.ts +6 -0
  52. package/dist/types/components/tooltip/MyTooltip.d.ts.map +1 -1
  53. package/dist/types/contexts/ThemeProviderContext.d.ts +5 -0
  54. package/dist/types/contexts/ThemeProviderContext.d.ts.map +1 -1
  55. package/dist/types/enums/ThemeMode.d.ts +3 -0
  56. package/dist/types/enums/ThemeMode.d.ts.map +1 -1
  57. package/dist/types/hooks/useColumns.d.ts +6 -0
  58. package/dist/types/hooks/useColumns.d.ts.map +1 -1
  59. package/dist/types/hooks/useDataTable.d.ts +6 -0
  60. package/dist/types/hooks/useDataTable.d.ts.map +1 -1
  61. package/dist/types/hooks/useFilter.d.ts +11 -0
  62. package/dist/types/hooks/useFilter.d.ts.map +1 -1
  63. package/dist/types/providers/ThemeProvider.d.ts +14 -0
  64. package/dist/types/providers/ThemeProvider.d.ts.map +1 -1
  65. package/dist/types/schemas/createConfirmPasswordSchema.d.ts +9 -0
  66. package/dist/types/schemas/createConfirmPasswordSchema.d.ts.map +1 -1
  67. package/dist/types/stores/useColumnsStore.d.ts +8 -0
  68. package/dist/types/stores/useColumnsStore.d.ts.map +1 -1
  69. package/dist/types/stores/useDateRangeStore.d.ts +8 -0
  70. package/dist/types/stores/useDateRangeStore.d.ts.map +1 -1
  71. package/dist/types/types/column.type.d.ts +15 -0
  72. package/dist/types/types/column.type.d.ts.map +1 -1
  73. package/dist/types/types/translation-args.type.d.ts +3 -0
  74. package/dist/types/types/translation-args.type.d.ts.map +1 -1
  75. package/dist/types/utils/day.d.ts +4 -0
  76. package/dist/types/utils/day.d.ts.map +1 -1
  77. package/package.json +2 -2
package/README.md CHANGED
@@ -1,31 +1,236 @@
1
- - Actions
2
- - Confirm
3
- - ConfirmContainer
4
- - DataTable
5
- - DateRangePicker
6
- - Empty
7
- - ExportData
8
- - FilterWrapper
9
- - Loader
10
- - MyCheckbox
11
- - MyDatePicker
12
- - MyDateRangePicker
13
- - MyGallery
14
- - MyHtmlEditor
15
- - MyInput
16
- - MyLimitSelect
17
- - MyMaskInput
18
- - MyModal
19
- - MyPagination
20
- - MyRadio
21
- - MySelect
22
- - MySwitch
23
- - MyTable
24
- - MyTextarea
25
- - MyTimePicker
26
- - MyTooltip
27
- - ScrollArea
28
- - Search
29
- - SearchWithCtrl
30
- - Spin
31
- - ThemeToggle
1
+ # dgz-ui-shared
2
+
3
+ A robust, shared UI library built for React applications using TypeScript, Tailwind CSS, and `dgz-ui`. This library provides a collection of high-level components, hooks, and utilities to streamline development, featuring advanced data tables, form integrations, and responsive design patterns.
4
+
5
+ ## Features
6
+
7
+ - **Advanced Data Table**: A feature-rich table component with server-side pagination, sorting, filtering, searching, column visibility management, and export capabilities.
8
+ - **Form Components**: Wrappers for common form inputs (`Input`, `Select`, `DatePicker`, `Checkbox`, etc.) seamlessly integrated with `react-hook-form` and `zod` validation.
9
+ - **Confirmation Dialogs**: Promise-based confirmation modals (including password confirmation) via the `useConfirm` hook.
10
+ - **UI Patterns**: Ready-to-use components for Modals, Galleries, Tooltips, and Loaders.
11
+ - **Theming**: Built-in dark/light mode support with `ThemeProvider` and `ThemeToggle`.
12
+ - **Responsive Utilities**: Hooks for managing media queries and responsive layouts.
13
+ - **Internationalization**: Built with `i18next` support for easy localization.
14
+
15
+ ## Installation
16
+
17
+ Install the package via npm:
18
+
19
+ ```bash
20
+ npm install dgz-ui-shared
21
+ ```
22
+
23
+ Ensure you have the required peer dependencies installed:
24
+
25
+ ```bash
26
+ npm install react react-dom dayjs
27
+ ```
28
+
29
+ ## Setup
30
+
31
+ ### 1. Import Styles
32
+
33
+ Import the library's CSS in your main entry file (e.g., `main.tsx` or `App.tsx`):
34
+
35
+ ```tsx
36
+ import 'dgz-ui-shared/dist/dgz-ui-shared.css';
37
+ ```
38
+
39
+ ### 2. Theme Provider
40
+
41
+ Wrap your application with the `ThemeProvider` to enable theme management:
42
+
43
+ ```tsx
44
+ import { ThemeProvider } from 'dgz-ui-shared/providers';
45
+
46
+ function App() {
47
+ return (
48
+ <ThemeProvider defaultTheme="system" storageKey="vite-ui-theme">
49
+ <YourApp />
50
+ </ThemeProvider>
51
+ );
52
+ }
53
+ ```
54
+
55
+ ## Usage Examples
56
+
57
+ ### Data Table
58
+
59
+ The `DataTable` component is the centerpiece of this library. It handles complex data presentation needs with minimal boilerplate.
60
+
61
+ ```tsx
62
+ import { DataTable } from 'dgz-ui-shared/components/datatable';
63
+ import { useDataTable } from 'dgz-ui-shared/hooks';
64
+
65
+ const MyUserTable = () => {
66
+ // Define columns
67
+ const columns = [
68
+ { key: 'name', dataIndex: 'name', name: 'Name', sortable: true },
69
+ { key: 'email', dataIndex: 'email', name: 'Email' },
70
+ { key: 'role', dataIndex: 'role', name: 'Role' },
71
+ ];
72
+
73
+ // Example data source (usually from an API)
74
+ const dataSource = {
75
+ docs: [
76
+ { id: 1, name: 'John Doe', email: 'john@example.com', role: 'Admin' },
77
+ // ... more data
78
+ ],
79
+ page: 1,
80
+ limit: 10,
81
+ totalPages: 5,
82
+ total: 50,
83
+ };
84
+
85
+ const handleParamChange = (params) => {
86
+ console.log('Fetch new data with:', params);
87
+ };
88
+
89
+ return (
90
+ <DataTable
91
+ tableKey="user-table"
92
+ rowKey="id"
93
+ columns={columns}
94
+ dataSource={dataSource}
95
+ onParamChange={handleParamChange}
96
+ hasPagination
97
+ hasSearch
98
+ hasColumnsVisibilityDropdown
99
+ hasCheckbox
100
+ />
101
+ );
102
+ };
103
+ ```
104
+
105
+ ### Form Components
106
+
107
+ Use the `My*` form components to build accessible, validated forms with `react-hook-form`.
108
+
109
+ ```tsx
110
+ import { useForm } from 'react-hook-form';
111
+ import { MyInput, MySelect } from 'dgz-ui-shared/components/form';
112
+ import { Button } from 'dgz-ui/button'; // Assuming you have base UI components
113
+
114
+ const SignUpForm = () => {
115
+ const { control, handleSubmit } = useForm();
116
+
117
+ const onSubmit = (data) => console.log(data);
118
+
119
+ return (
120
+ <form onSubmit={handleSubmit(onSubmit)} className="space-y-4">
121
+ <MyInput
122
+ control={control}
123
+ name="username"
124
+ label="Username"
125
+ required
126
+ placeholder="Enter your username"
127
+ />
128
+
129
+ <MySelect
130
+ control={control}
131
+ name="role"
132
+ label="Role"
133
+ options={[
134
+ { value: 'admin', label: 'Admin' },
135
+ { value: 'user', label: 'User' },
136
+ ]}
137
+ />
138
+
139
+ <Button type="submit">Submit</Button>
140
+ </form>
141
+ );
142
+ };
143
+ ```
144
+
145
+ ### Confirmation Dialogs
146
+
147
+ Trigger confirmation modals programmatically using `useConfirm`.
148
+
149
+ ```tsx
150
+ import { useConfirm } from 'dgz-ui-shared/hooks';
151
+ import { Button } from 'dgz-ui/button';
152
+
153
+ const DeleteButton = () => {
154
+ const { confirm } = useConfirm();
155
+
156
+ const handleDelete = () => {
157
+ confirm({
158
+ onConfirm: () => {
159
+ console.log('Item deleted!');
160
+ },
161
+ });
162
+ };
163
+
164
+ return <Button onClick={handleDelete}>Delete Item</Button>;
165
+ };
166
+ ```
167
+
168
+ ### Image Gallery
169
+
170
+ Display a responsive grid of images with a fullscreen viewer.
171
+
172
+ ```tsx
173
+ import { MyGallery } from 'dgz-ui-shared/components/gallery';
174
+
175
+ const images = [
176
+ {
177
+ id: '1',
178
+ src: 'https://example.com/large.jpg',
179
+ thumbnail: 'https://example.com/thumb.jpg',
180
+ alt: 'Example Image',
181
+ title: 'Beautiful Scenery',
182
+ },
183
+ ];
184
+
185
+ const GalleryPage = () => {
186
+ return <MyGallery images={images} hasInfo />;
187
+ };
188
+ ```
189
+
190
+ ## Available Components
191
+
192
+ | Category | Components |
193
+ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
194
+ | **Data Display** | `DataTable`, `MyTable`, `MyGallery` |
195
+ | **Form** | `MyInput`, `MySelect`, `MyCheckbox`, `MyRadio`, `MySwitch`, `MyTextarea`, `MyDatePicker`, `MyDateRangePicker`, `MyTimePicker`, `MyHtmlEditor`, `MyMaskInput` |
196
+ | **Feedback** | `Loader`, `Spin`, `Empty` |
197
+ | **Overlays** | `MyModal`, `Confirm`, `PasswordConfirm`, `MyTooltip` |
198
+ | **Navigation** | `MyPagination`, `MyLimitSelect` |
199
+ | **Utils** | `ThemeToggle`, `ExportData`, `FilterWrapper`, `Search` |
200
+
201
+ ## Hooks
202
+
203
+ | Hook | Description |
204
+ | -------------------- | ---------------------------------------------------- |
205
+ | `useDataTable` | Manages row selection and table state. |
206
+ | `useColumns` | Manages column visibility and persistence. |
207
+ | `useConfirm` | Provides imperative API for confirmation dialogs. |
208
+ | `useTheme` | Access and toggle current theme (light/dark/system). |
209
+ | `useFilter` | Syncs filter state with URL parameters or form. |
210
+ | `useMediaQuerySizes` | Responsive breakpoints helpers. |
211
+
212
+ ## Development
213
+
214
+ Clone the repository and install dependencies:
215
+
216
+ ```bash
217
+ git clone https://github.com/Alisher1119/dgz-ui-shared.git
218
+ cd dgz-ui-shared
219
+ npm install
220
+ ```
221
+
222
+ ### Available Scripts
223
+
224
+ - `npm run dev`: Start the development server (Vite).
225
+ - `npm run build`: Build the library for production.
226
+ - `npm run lint`: Lint the codebase.
227
+ - `npm run format`: Format code with Prettier.
228
+ - `npm run test`: Run tests with Vitest.
229
+
230
+ ## License
231
+
232
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
233
+
234
+ ## Author
235
+
236
+ [Alisher Khayrillaev](https://github.com/Alisher1119)