@gnwebsoft/ui 3.0.0 → 3.0.2

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 (74) hide show
  1. package/README.md +688 -0
  2. package/dist/chunk-4H3AFH7A.js +505 -0
  3. package/dist/chunk-DE62KYFK.js +122 -0
  4. package/dist/chunk-DEPJRTVT.js +1 -0
  5. package/dist/chunk-EBRUE2WR.cjs +493 -0
  6. package/dist/chunk-FD57PCAC.cjs +1 -0
  7. package/dist/chunk-H3GQLELL.js +2025 -0
  8. package/dist/chunk-MVPLBJRK.cjs +1 -0
  9. package/dist/chunk-OJF67RNM.js +1 -0
  10. package/dist/chunk-OT7COE7R.cjs +2025 -0
  11. package/dist/chunk-R2YK4LTT.cjs +122 -0
  12. package/dist/chunk-U6SDYCWF.js +493 -0
  13. package/dist/chunk-ZC7FGYL2.cjs +505 -0
  14. package/dist/components/index.cjs +25 -0
  15. package/dist/components/index.d.cts +752 -0
  16. package/dist/components/index.d.ts +664 -15
  17. package/dist/components/index.js +25 -24
  18. package/dist/enhanced-z-I7EHVS.d.cts +134 -0
  19. package/dist/enhanced-z-I7EHVS.d.ts +134 -0
  20. package/dist/hooks/index.cjs +12 -0
  21. package/dist/hooks/index.d.cts +95 -0
  22. package/dist/hooks/index.d.ts +82 -4
  23. package/dist/hooks/index.js +12 -7
  24. package/dist/index.cjs +127 -0
  25. package/dist/index.d.cts +14 -0
  26. package/dist/index.d.ts +4 -8
  27. package/dist/index.js +127 -58
  28. package/dist/types/index.cjs +2 -0
  29. package/dist/types/index.d.cts +241 -0
  30. package/dist/types/index.d.ts +212 -15
  31. package/dist/types/index.js +2 -1
  32. package/dist/utils/index.cjs +45 -0
  33. package/dist/utils/index.d.cts +366 -0
  34. package/dist/utils/index.d.ts +317 -10
  35. package/dist/utils/index.js +45 -22
  36. package/dist/wrappers/index.cjs +54 -0
  37. package/dist/wrappers/index.d.cts +1684 -0
  38. package/dist/wrappers/index.d.ts +1601 -118
  39. package/dist/wrappers/index.js +54 -8
  40. package/package.json +139 -92
  41. package/dist/AsyncSelectPayload-Cz4bgak0.d.mts +0 -10
  42. package/dist/AsyncSelectPayload-Cz4bgak0.d.ts +0 -10
  43. package/dist/OptionItem-oN6XnOTJ.d.mts +0 -14
  44. package/dist/OptionItem-oN6XnOTJ.d.ts +0 -14
  45. package/dist/chunk-2JFL7TS5.mjs +0 -0
  46. package/dist/chunk-5HOGPCEO.mjs +0 -1427
  47. package/dist/chunk-6BGQA4BQ.js +0 -1
  48. package/dist/chunk-6JZ35VQJ.js +0 -19
  49. package/dist/chunk-6NOXJGU2.js +0 -1427
  50. package/dist/chunk-7M2VOCYN.js +0 -1
  51. package/dist/chunk-BWQUYXUW.mjs +0 -1634
  52. package/dist/chunk-D3J7MWAU.js +0 -1634
  53. package/dist/chunk-EVPUCTZA.mjs +0 -0
  54. package/dist/chunk-FSU3H777.mjs +0 -473
  55. package/dist/chunk-GFSTK7KN.mjs +0 -19
  56. package/dist/chunk-I7EIUZKK.js +0 -332
  57. package/dist/chunk-JKUOV3MN.js +0 -473
  58. package/dist/chunk-RQS44YC7.mjs +0 -332
  59. package/dist/components/index.d.mts +0 -103
  60. package/dist/components/index.mjs +0 -24
  61. package/dist/hooks/index.d.mts +0 -17
  62. package/dist/hooks/index.mjs +0 -7
  63. package/dist/index.d.mts +0 -18
  64. package/dist/index.mjs +0 -58
  65. package/dist/types/index.d.mts +0 -44
  66. package/dist/types/index.mjs +0 -1
  67. package/dist/utils/index.d.mts +0 -59
  68. package/dist/utils/index.mjs +0 -22
  69. package/dist/wrappers/index.d.mts +0 -201
  70. package/dist/wrappers/index.mjs +0 -8
  71. package/dist/wrappers2/index.d.mts +0 -247
  72. package/dist/wrappers2/index.d.ts +0 -247
  73. package/dist/wrappers2/index.js +0 -8
  74. package/dist/wrappers2/index.mjs +0 -8
@@ -1,332 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/utils/api.ts
2
- var makeRequest = async (url, options = {}) => {
3
- const response = await fetch(url, options);
4
- if (response.ok) {
5
- const apiData = await response.json();
6
- return {
7
- apiData,
8
- status: response.status
9
- };
10
- } else if (response.status === 404) {
11
- const apiData = await response.json();
12
- const data = {
13
- status: response.status,
14
- title: apiData.title
15
- };
16
- return data;
17
- }
18
- const apiResponse = await response.json();
19
- return apiResponse;
20
- };
21
- var api = class {
22
- static async filter(url, postModel) {
23
- const alteredOptions = {
24
- headers: {
25
- "Content-Type": "application/json",
26
- Authorization: `Bearer ${localStorage.getItem("serviceToken")}`
27
- },
28
- body: JSON.stringify({ ...postModel, ...postModel.filterModel }),
29
- method: "POST"
30
- };
31
- const apiResponse = await makeRequest(url, alteredOptions);
32
- return apiResponse;
33
- }
34
- static async post(url, body = {}) {
35
- const alteredOptions = {
36
- headers: {
37
- "Content-Type": "application/json",
38
- Authorization: `Bearer ${localStorage.getItem("serviceToken")}`
39
- },
40
- body: JSON.stringify(body),
41
- method: "POST"
42
- };
43
- const apiResponse = await makeRequest(url, alteredOptions);
44
- return apiResponse;
45
- }
46
- static async get(url) {
47
- const alteredOptions = {
48
- headers: {
49
- "Content-Type": "application/json",
50
- Authorization: `Bearer ${localStorage.getItem("serviceToken")}`
51
- },
52
- method: "GET"
53
- };
54
- const data = await makeRequest(url, alteredOptions);
55
- return data;
56
- }
57
- static async delete(url) {
58
- const alteredOptions = {
59
- headers: {
60
- "Content-Type": "application/json",
61
- Authorization: `Bearer ${localStorage.getItem("serviceToken")}`
62
- },
63
- method: "DELETE"
64
- };
65
- const data = await makeRequest(url, alteredOptions);
66
- return data;
67
- }
68
- static async put(url, body = {}) {
69
- const alteredOptions = {
70
- headers: {
71
- "Content-Type": "application/json",
72
- Authorization: `Bearer ${localStorage.getItem("serviceToken")}`
73
- },
74
- body: JSON.stringify(body),
75
- method: "PUT"
76
- };
77
- const apiResponse = await makeRequest(url, alteredOptions);
78
- return apiResponse;
79
- }
80
- static async fetch(url, options = {}) {
81
- const alteredOptions = {
82
- headers: {
83
- "Content-Type": "application/json",
84
- Authorization: `Bearer ${localStorage.getItem("serviceToken")}`
85
- },
86
- ...options
87
- };
88
- const result = await fetch(url, alteredOptions);
89
- return result;
90
- }
91
- static async tempFetch(url, options = {}) {
92
- const alteredOptions = {
93
- headers: {
94
- "Content-Type": "application/json"
95
- },
96
- ...options
97
- };
98
- const apiResponse = await makeRequest(url, alteredOptions);
99
- return apiResponse;
100
- }
101
- static async upload(url, formData) {
102
- const alteredOptions = {
103
- headers: {
104
- Authorization: `Bearer ${localStorage.getItem("serviceToken")}`
105
- },
106
- body: formData,
107
- method: "POST"
108
- };
109
- const apiResponse = await makeRequest(url, alteredOptions);
110
- return apiResponse;
111
- }
112
- };
113
-
114
- // src/utils/api2.ts
115
- var makeRequest2 = async (url, options = {}) => {
116
- const response = await fetch(url, options);
117
- if (response.ok) {
118
- const apiData = await response.json();
119
- return {
120
- apiData,
121
- status: response.status
122
- };
123
- } else if (response.status === 404) {
124
- const apiData = await response.json();
125
- const data = {
126
- status: response.status,
127
- title: apiData.title
128
- };
129
- return data;
130
- }
131
- const apiResponse = await response.json();
132
- return apiResponse;
133
- };
134
- var api2 = class {
135
- static async filter(url, postModel) {
136
- const alteredOptions = {
137
- headers: {
138
- "Content-Type": "application/json",
139
- Authorization: `Bearer ${sessionStorage.getItem("serviceToken")}`
140
- },
141
- body: JSON.stringify({ ...postModel, ...postModel.filterModel }),
142
- method: "POST"
143
- };
144
- const apiResponse = await makeRequest2(url, alteredOptions);
145
- return apiResponse;
146
- }
147
- static async post(url, body = {}) {
148
- const alteredOptions = {
149
- headers: {
150
- "Content-Type": "application/json",
151
- Authorization: `Bearer ${sessionStorage.getItem("serviceToken")}`
152
- },
153
- body: JSON.stringify(body),
154
- method: "POST"
155
- };
156
- const apiResponse = await makeRequest2(url, alteredOptions);
157
- return apiResponse;
158
- }
159
- static async get(url) {
160
- const alteredOptions = {
161
- headers: {
162
- "Content-Type": "application/json",
163
- Authorization: `Bearer ${sessionStorage.getItem("serviceToken")}`
164
- },
165
- method: "GET"
166
- };
167
- const data = await makeRequest2(url, alteredOptions);
168
- return data;
169
- }
170
- static async delete(url) {
171
- const alteredOptions = {
172
- headers: {
173
- "Content-Type": "application/json",
174
- Authorization: `Bearer ${sessionStorage.getItem("serviceToken")}`
175
- },
176
- method: "DELETE"
177
- };
178
- const data = await makeRequest2(url, alteredOptions);
179
- return data;
180
- }
181
- static async put(url, body = {}) {
182
- const alteredOptions = {
183
- headers: {
184
- "Content-Type": "application/json",
185
- Authorization: `Bearer ${sessionStorage.getItem("serviceToken")}`
186
- },
187
- body: JSON.stringify(body),
188
- method: "PUT"
189
- };
190
- const apiResponse = await makeRequest2(url, alteredOptions);
191
- return apiResponse;
192
- }
193
- static async fetch(url, options = {}) {
194
- const alteredOptions = {
195
- headers: {
196
- "Content-Type": "application/json",
197
- Authorization: `Bearer ${sessionStorage.getItem("serviceToken")}`
198
- },
199
- ...options
200
- };
201
- const result = await fetch(url, alteredOptions);
202
- return result;
203
- }
204
- static async tempFetch(url, options = {}) {
205
- const alteredOptions = {
206
- headers: {
207
- "Content-Type": "application/json"
208
- },
209
- ...options
210
- };
211
- const apiResponse = await makeRequest2(url, alteredOptions);
212
- return apiResponse;
213
- }
214
- static async upload(url, formData) {
215
- const alteredOptions = {
216
- headers: {
217
- Authorization: `Bearer ${sessionStorage.getItem("serviceToken")}`
218
- },
219
- body: formData,
220
- method: "POST"
221
- };
222
- const apiResponse = await makeRequest2(url, alteredOptions);
223
- return apiResponse;
224
- }
225
- };
226
-
227
- // src/utils/flattenObjectKeys.ts
228
- var isNested = (obj) => typeof obj === "object" && obj !== null;
229
- var isArray = (obj) => Array.isArray(obj);
230
- var flattenObjectKeys = (obj, prefix = "") => {
231
- if (!isNested(obj)) {
232
- return {
233
- [prefix]: obj
234
- };
235
- }
236
- return Object.keys(obj).reduce((acc, key) => {
237
- const currentPrefix = prefix.length ? `${prefix}.` : "";
238
- if (isNested(obj[key]) && Object.keys(obj[key]).length) {
239
- if (isArray(obj[key]) && obj[key].length) {
240
- obj[key].forEach((item, index) => {
241
- Object.assign(
242
- acc,
243
- flattenObjectKeys(item, `${currentPrefix + key}.${index}`)
244
- );
245
- });
246
- } else {
247
- Object.assign(acc, flattenObjectKeys(obj[key], currentPrefix + key));
248
- }
249
- acc[currentPrefix + key] = obj[key];
250
- } else {
251
- acc[currentPrefix + key] = obj[key];
252
- }
253
- return acc;
254
- }, {});
255
- };
256
-
257
- // src/utils/getTimezone.ts
258
- function getTimezone(adapter, value) {
259
- return value == null || !adapter.utils.isValid(value) ? null : adapter.utils.getTimezone(value);
260
- }
261
-
262
- // src/utils/handleServerErrors.ts
263
- var handleServerErrors = function handleServerErrors2(args) {
264
- const { errors, setError } = args;
265
- for (const key in errors) {
266
- const isKeyInVariables = Object.keys(flattenObjectKeys(errors)).includes(
267
- key
268
- );
269
- if (!isKeyInVariables) {
270
- continue;
271
- }
272
- const fieldError = errors[key];
273
- let errorMessage = "";
274
- if (Array.isArray(fieldError)) {
275
- errorMessage = fieldError.join(" ");
276
- }
277
- if (typeof fieldError === "string") {
278
- errorMessage = fieldError;
279
- }
280
- if (typeof fieldError === "boolean" && fieldError) {
281
- errorMessage = "Field is not valid.";
282
- }
283
- setError(key, {
284
- message: errorMessage
285
- });
286
- }
287
- };
288
-
289
- // src/utils/propertyExists.ts
290
- function propertyExists(obj, prop) {
291
- return typeof obj === "object" && obj !== null && Object.prototype.hasOwnProperty.call(obj, prop);
292
- }
293
-
294
- // src/utils/readValueAsDate.ts
295
- function readValueAsDate(adapter, value) {
296
- if (typeof value === "string") {
297
- if (value === "") {
298
- return null;
299
- }
300
- return adapter.utils.date(value);
301
- }
302
- return value;
303
- }
304
-
305
- // src/utils/removeLeadingTrailingSlashes.ts
306
- var removeLeadingTrailingSlashes = (route) => {
307
- return route.replace(/^\/|\/$/g, "");
308
- };
309
-
310
- // src/utils/schemaTools.ts
311
- var _dayjs = require('dayjs'); var _dayjs2 = _interopRequireDefault(_dayjs);
312
- var _zod = require('zod');
313
- var schemaTools = {
314
- date: ({ message }) => _zod.z.coerce.string().transform((c) => c === "null" || c === "undefined" ? null : c).refine((c) => !!c, { message }).refine((c) => !!c ? _dayjs2.default.call(void 0, c).isValid() : true, {
315
- message: message ? message : "Invalid date"
316
- }),
317
- nullableDate: ({ message } = {}) => _zod.z.coerce.string().transform((c) => c === "null" ? null : c).transform((c) => c === "undefined" ? null : c).refine((c) => !c && c != null ? _dayjs2.default.call(void 0, c).isValid() : true, {
318
- message: message ? message : "Invalid date"
319
- })
320
- };
321
-
322
-
323
-
324
-
325
-
326
-
327
-
328
-
329
-
330
-
331
-
332
- exports.api = api; exports.api2 = api2; exports.flattenObjectKeys = flattenObjectKeys; exports.getTimezone = getTimezone; exports.handleServerErrors = handleServerErrors; exports.propertyExists = propertyExists; exports.readValueAsDate = readValueAsDate; exports.removeLeadingTrailingSlashes = removeLeadingTrailingSlashes; exports.schemaTools = schemaTools;