@gnwebsoft/ui 3.0.1 → 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 (66) 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 -6
  27. package/dist/index.js +127 -54
  28. package/dist/types/index.cjs +2 -0
  29. package/dist/types/index.d.cts +241 -0
  30. package/dist/types/index.d.ts +205 -20
  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 -9
  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 -88
  41. package/dist/AsyncSelectPayload-Cz4bgak0.d.mts +0 -10
  42. package/dist/AsyncSelectPayload-Cz4bgak0.d.ts +0 -10
  43. package/dist/chunk-2JFL7TS5.mjs +0 -0
  44. package/dist/chunk-6BGQA4BQ.js +0 -1
  45. package/dist/chunk-6JZ35VQJ.js +0 -19
  46. package/dist/chunk-7M2VOCYN.js +0 -1
  47. package/dist/chunk-BWQUYXUW.mjs +0 -1634
  48. package/dist/chunk-D3J7MWAU.js +0 -1634
  49. package/dist/chunk-EVPUCTZA.mjs +0 -0
  50. package/dist/chunk-FSU3H777.mjs +0 -473
  51. package/dist/chunk-GFSTK7KN.mjs +0 -19
  52. package/dist/chunk-I7EIUZKK.js +0 -332
  53. package/dist/chunk-JKUOV3MN.js +0 -473
  54. package/dist/chunk-RQS44YC7.mjs +0 -332
  55. package/dist/components/index.d.mts +0 -103
  56. package/dist/components/index.mjs +0 -24
  57. package/dist/hooks/index.d.mts +0 -17
  58. package/dist/hooks/index.mjs +0 -7
  59. package/dist/index.d.mts +0 -16
  60. package/dist/index.mjs +0 -54
  61. package/dist/types/index.d.mts +0 -56
  62. package/dist/types/index.mjs +0 -1
  63. package/dist/utils/index.d.mts +0 -58
  64. package/dist/utils/index.mjs +0 -22
  65. package/dist/wrappers/index.d.mts +0 -201
  66. package/dist/wrappers/index.mjs +0 -8
@@ -1,1634 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
- var _chunk6JZ35VQJjs = require('./chunk-6JZ35VQJ.js');
4
-
5
-
6
- var _chunkI7EIUZKKjs = require('./chunk-I7EIUZKK.js');
7
-
8
- // src/wrappers/DatePickerElement/DatePickerElement.tsx
9
- var _react = require('react'); var React = _interopRequireWildcard(_react);
10
- var _reacthookform = require('react-hook-form');
11
- var _xdatepickers = require('@mui/x-date-pickers');
12
- var _material = require('@mui/material');
13
- var _internals = require('@mui/x-date-pickers/internals');
14
- var _jsxruntime = require('react/jsx-runtime');
15
- function readValueAsDate2(adapter, value) {
16
- if (typeof value === "string") {
17
- if (value === "") {
18
- return null;
19
- }
20
- return adapter.utils.date(value);
21
- }
22
- return value;
23
- }
24
- function useTransform2(options) {
25
- const value = typeof _optionalChain([options, 'access', _3 => _3.transform, 'optionalAccess', _4 => _4.input]) === "function" ? options.transform.input(options.value) : options.value;
26
- const onChange = _react.useCallback.call(void 0,
27
- (...event) => {
28
- if (typeof _optionalChain([options, 'access', _5 => _5.transform, 'optionalAccess', _6 => _6.output]) === "function") {
29
- options.onChange(options.transform.output(...event));
30
- } else {
31
- options.onChange(...event);
32
- }
33
- },
34
- [options]
35
- );
36
- return {
37
- value,
38
- onChange
39
- };
40
- }
41
- var Component = function DatePickerElement(props) {
42
- const {
43
- name,
44
- required,
45
- inputProps,
46
- control,
47
- textReadOnly,
48
- label,
49
- placeholder,
50
- slotProps,
51
- datePickerProps = {},
52
- transform,
53
- sx,
54
- ...rest
55
- } = props;
56
- const adapter = _internals.useLocalizationContext.call(void 0, );
57
- const theme = _material.useTheme.call(void 0, );
58
- const { disabled, inputRef, onClose, ...restDatePickerProps } = datePickerProps;
59
- const {
60
- field,
61
- fieldState: { error }
62
- } = _reacthookform.useController.call(void 0, {
63
- name,
64
- control,
65
- defaultValue: null
66
- });
67
- const { value, onChange } = useTransform2({
68
- value: field.value,
69
- onChange: field.onChange,
70
- transform: {
71
- input: typeof _optionalChain([transform, 'optionalAccess', _7 => _7.input]) === "function" ? transform.input : (newValue) => readValueAsDate2(adapter, newValue),
72
- output: (outputValue, context) => {
73
- if (outputValue === null) return null;
74
- return outputValue;
75
- }
76
- }
77
- });
78
- const handleInputRef = _material.useForkRef.call(void 0, field.ref, inputRef);
79
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
80
- _xdatepickers.DatePicker,
81
- {
82
- ...rest,
83
- ...restDatePickerProps,
84
- ...field,
85
- value,
86
- label,
87
- disabled,
88
- ...datePickerProps,
89
- inputRef: handleInputRef,
90
- onClose: (...args) => {
91
- field.onBlur();
92
- if (onClose) {
93
- onClose(...args);
94
- }
95
- },
96
- onChange: (newValue, context) => {
97
- onChange(newValue, context);
98
- if (typeof datePickerProps.onChange === "function") {
99
- datePickerProps.onChange(newValue, context);
100
- }
101
- },
102
- sx: {
103
- "& .MuiOutlinedInput-root": {
104
- bgcolor: disabled ? theme.palette.action.disabledBackground : "transparent"
105
- },
106
- "& .MuiInputLabel-asterisk": { color: "red" },
107
- "& .MuiInputBase-input": {
108
- cursor: disabled ? "not-allowed" : "default"
109
- },
110
- ...sx
111
- },
112
- slotProps: {
113
- ...slotProps,
114
- actionBar: {
115
- actions: ["clear", "today", "cancel", "accept"]
116
- },
117
- textField: {
118
- ...inputProps,
119
- required,
120
- placeholder,
121
- fullWidth: true,
122
- onBlur: (event) => {
123
- field.onBlur();
124
- if (typeof _optionalChain([inputProps, 'optionalAccess', _8 => _8.onBlur]) === "function") {
125
- inputProps.onBlur(event);
126
- }
127
- },
128
- error: !!error,
129
- helperText: error ? error.message : _optionalChain([inputProps, 'optionalAccess', _9 => _9.helperText]) || rest.helperText,
130
- inputProps: {
131
- readOnly: !!textReadOnly,
132
- ..._optionalChain([inputProps, 'optionalAccess', _10 => _10.inputProps])
133
- }
134
- }
135
- }
136
- }
137
- );
138
- };
139
- var DatePickerElement2 = ({
140
- gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
141
- ...props
142
- }) => {
143
- if (gridProps) {
144
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
145
- _material.Grid2,
146
- {
147
- ...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
148
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, { ...props })
149
- }
150
- );
151
- }
152
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, { ...props });
153
- };
154
- DatePickerElement2.displayName = "DatePickerElement";
155
- var DatePickerElement_default = DatePickerElement2;
156
-
157
- // src/wrappers/PasswordElement/PasswordElement.tsx
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
- var _Visibility = require('@mui/icons-material/Visibility'); var _Visibility2 = _interopRequireDefault(_Visibility);
167
- var _VisibilityOff = require('@mui/icons-material/VisibilityOff'); var _VisibilityOff2 = _interopRequireDefault(_VisibilityOff);
168
-
169
-
170
-
171
-
172
- var Component2 = function PasswordEl(props) {
173
- const {
174
- type,
175
- required,
176
- iconColor,
177
- renderIcon = (password2) => password2 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Visibility2.default, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _VisibilityOff2.default, {}),
178
- slotProps,
179
- name,
180
- control,
181
- component: TextFieldComponent = _material.TextField,
182
- inputRef,
183
- onBlur,
184
- ...rest
185
- } = props;
186
- const [password, setPassword] = _react.useState.call(void 0, true);
187
- const endAdornment = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.InputAdornment, { position: "end", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
188
- _material.IconButton,
189
- {
190
- onMouseDown: (e) => e.preventDefault(),
191
- onClick: () => setPassword(!password),
192
- tabIndex: -1,
193
- color: _nullishCoalesce(iconColor, () => ( "default")),
194
- children: renderIcon(password)
195
- }
196
- ) });
197
- const {
198
- field,
199
- fieldState: { error }
200
- } = _reacthookform.useController.call(void 0, {
201
- name,
202
- control
203
- });
204
- const handleInputRef = _material.useForkRef.call(void 0, field.ref, inputRef);
205
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
206
- _material.TextField,
207
- {
208
- ...rest,
209
- inputRef: handleInputRef,
210
- type: password ? "password" : "text",
211
- value: field.value,
212
- fullWidth: true,
213
- onChange: (event) => {
214
- field.onChange(event);
215
- if (typeof rest.onChange === "function") {
216
- rest.onChange(event);
217
- }
218
- },
219
- onBlur: (event) => {
220
- field.onBlur();
221
- if (typeof onBlur === "function") {
222
- onBlur(event);
223
- }
224
- },
225
- ...typeof slotProps === "undefined" ? {
226
- InputProps: {
227
- endAdornment
228
- }
229
- } : {
230
- slotProps: {
231
- ...slotProps,
232
- input: {
233
- endAdornment,
234
- ..._optionalChain([slotProps, 'optionalAccess', _11 => _11.input])
235
- }
236
- }
237
- },
238
- error: !!error,
239
- helperText: error ? error.message : ""
240
- }
241
- );
242
- };
243
- var PasswordElement = ({
244
- gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
245
- ...props
246
- }) => {
247
- if (gridProps) {
248
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
249
- _material.Grid2,
250
- {
251
- ...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
252
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component2, { ...props })
253
- }
254
- );
255
- }
256
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component2, { ...props });
257
- };
258
- PasswordElement.displayName = "PasswordElement";
259
- var PasswordElement_default = PasswordElement;
260
-
261
- // src/wrappers/RadioButtonGroup/RadioButtonGroup.tsx
262
-
263
-
264
-
265
-
266
-
267
-
268
-
269
-
270
-
271
-
272
-
273
-
274
-
275
-
276
-
277
- var Component3 = function RadioButtonGroup(props) {
278
- const {
279
- helperText,
280
- options,
281
- label,
282
- name,
283
- parseError,
284
- labelKey = "label",
285
- valueKey = "id",
286
- disabledKey = "disabled",
287
- required,
288
- emptyOptionLabel,
289
- returnObject,
290
- row,
291
- control,
292
- type,
293
- labelProps,
294
- disabled,
295
- formLabelProps,
296
- radioProps,
297
- transform,
298
- rules = {},
299
- ...rest
300
- } = props;
301
- const theme = _material.useTheme.call(void 0, );
302
- const {
303
- field,
304
- fieldState: { error }
305
- } = _reacthookform.useController.call(void 0, {
306
- name,
307
- disabled,
308
- control
309
- });
310
- const { value, onChange } = _chunk6JZ35VQJjs.useTransform.call(void 0, {
311
- value: field.value,
312
- onChange: field.onChange,
313
- transform: {
314
- input: typeof _optionalChain([transform, 'optionalAccess', _12 => _12.input]) === "function" ? transform.input : (value2) => {
315
- return value2 || "";
316
- },
317
- output: typeof _optionalChain([transform, 'optionalAccess', _13 => _13.output]) === "function" ? _optionalChain([transform, 'optionalAccess', _14 => _14.output]) : (_event, value2) => {
318
- if (value2 && type === "number") {
319
- return Number(value2);
320
- }
321
- return value2;
322
- }
323
- }
324
- });
325
- const onRadioChange = (event, radioValue) => {
326
- const returnValue = returnObject ? options.find((items) => items[valueKey] === radioValue) : radioValue;
327
- onChange(event, returnValue);
328
- if (typeof rest.onChange === "function") {
329
- rest.onChange(returnValue);
330
- }
331
- };
332
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.FormControl, { error: !!error, children: [
333
- label && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormLabel, { ...formLabelProps, required, error: !!error, children: label }),
334
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.RadioGroup, { onChange: onRadioChange, name, row, value, children: [
335
- emptyOptionLabel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
336
- _material.FormControlLabel,
337
- {
338
- ...labelProps,
339
- control: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
340
- _material.Radio,
341
- {
342
- ...radioProps,
343
- sx: {
344
- color: error ? theme.palette.error.main : void 0
345
- },
346
- checked: !value
347
- }
348
- ),
349
- label: emptyOptionLabel,
350
- value: ""
351
- }
352
- ),
353
- options.map((option) => {
354
- const optionKey = option[valueKey];
355
- const optionDisabled = option[disabledKey] || false;
356
- if (optionKey === void 0) {
357
- console.error(
358
- `RadioButtonGroup: valueKey ${valueKey} does not exist on option`,
359
- option
360
- );
361
- }
362
- let val = returnObject ? _optionalChain([value, 'optionalAccess', _15 => _15[valueKey]]) : value;
363
- if (type === "number") {
364
- val = Number(val);
365
- }
366
- const isChecked = val === optionKey;
367
- return /* @__PURE__ */ _react.createElement.call(void 0,
368
- _material.FormControlLabel,
369
- {
370
- ...labelProps,
371
- control: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
372
- _material.Radio,
373
- {
374
- ...radioProps,
375
- sx: {
376
- color: error ? theme.palette.error.main : void 0
377
- },
378
- disabled: disabled || optionDisabled,
379
- checked: isChecked
380
- }
381
- ),
382
- value: optionKey,
383
- label: option[labelKey],
384
- key: optionKey
385
- }
386
- );
387
- })
388
- ] }),
389
- error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormHelperText, { children: error.message })
390
- ] });
391
- };
392
- var RadioButtonGroup2 = ({
393
- gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
394
- ...props
395
- }) => {
396
- if (gridProps) {
397
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
398
- _material.Grid2,
399
- {
400
- ...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
401
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component3, { ...props })
402
- }
403
- );
404
- }
405
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component3, { ...props });
406
- };
407
- RadioButtonGroup2.displayName = "RadioButtonGroup";
408
- var RadioButtonGroup_default = RadioButtonGroup2;
409
-
410
- // src/wrappers/TextFieldElement/TextFieldElement.tsx
411
-
412
-
413
-
414
-
415
-
416
-
417
-
418
-
419
-
420
-
421
- var Component4 = function TextFieldElement(props) {
422
- const {
423
- rules = {},
424
- parseError,
425
- name,
426
- control,
427
- component: TextFieldComponent = _material.TextField,
428
- gridProps,
429
- transform,
430
- label,
431
- placeholder,
432
- textFieldProps = {},
433
- variant,
434
- sx,
435
- ...rest
436
- } = props;
437
- const {
438
- type,
439
- required,
440
- helperText,
441
- inputRef,
442
- onBlur,
443
- disabled,
444
- ...restTextProps
445
- } = textFieldProps;
446
- const {
447
- field,
448
- fieldState: { error }
449
- } = _reacthookform.useController.call(void 0, {
450
- name,
451
- control
452
- });
453
- const theme = _material.useTheme.call(void 0, );
454
- const { value, onChange } = _chunk6JZ35VQJjs.useTransform.call(void 0, {
455
- value: field.value,
456
- onChange: field.onChange,
457
- transform: {
458
- input: typeof _optionalChain([transform, 'optionalAccess', _16 => _16.input]) === "function" ? transform.input : (value2) => {
459
- return _nullishCoalesce(value2, () => ( ""));
460
- },
461
- output: typeof _optionalChain([transform, 'optionalAccess', _17 => _17.output]) === "function" ? transform.output : (event) => {
462
- const value2 = event.target.value;
463
- if (type !== "number") {
464
- return value2;
465
- }
466
- if (value2 === "") {
467
- return null;
468
- }
469
- if (value2 == null) {
470
- return value2;
471
- }
472
- return Number(value2);
473
- }
474
- }
475
- });
476
- const handleInputRef = _material.useForkRef.call(void 0, field.ref, inputRef);
477
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
478
- TextFieldComponent,
479
- {
480
- ...rest,
481
- ...restTextProps,
482
- name: field.name,
483
- value,
484
- onChange: (event) => {
485
- field.onChange(event);
486
- if (typeof onChange === "function") {
487
- onChange(event);
488
- }
489
- },
490
- onBlur: (event) => {
491
- field.onBlur();
492
- if (typeof onBlur === "function") {
493
- onBlur(event);
494
- }
495
- },
496
- disabled,
497
- label,
498
- placeholder,
499
- fullWidth: true,
500
- required,
501
- type,
502
- error: !!error,
503
- helperText: error ? error.message : helperText,
504
- inputRef: handleInputRef,
505
- variant: variant ? variant : "outlined",
506
- size: "small",
507
- sx: {
508
- "& .MuiInputLabel-asterisk": { color: "red" },
509
- "& .MuiInputBase-input": {
510
- cursor: disabled ? "not-allowed" : "default"
511
- },
512
- bgcolor: disabled ? theme.palette.action.disabledBackground : "transparent",
513
- ...sx
514
- }
515
- }
516
- );
517
- };
518
- var TextFieldElement2 = ({
519
- gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
520
- ...props
521
- }) => {
522
- if (gridProps) {
523
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
524
- _material.Grid2,
525
- {
526
- ...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
527
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component4, { ...props })
528
- }
529
- );
530
- }
531
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component4, { ...props });
532
- };
533
- TextFieldElement2.displayName = "TextFieldElement";
534
- var TextFieldElement_default = TextFieldElement2;
535
-
536
- // src/wrappers/TimePickerElement/TimePickerElement.tsx
537
-
538
-
539
-
540
-
541
-
542
-
543
-
544
-
545
-
546
- var Component5 = function TimePickerElement(props) {
547
- const {
548
- parseError,
549
- name,
550
- required,
551
- rules = {},
552
- inputProps,
553
- control,
554
- textReadOnly,
555
- slotProps,
556
- inputRef,
557
- transform,
558
- ...rest
559
- } = props;
560
- const adapter = _internals.useLocalizationContext.call(void 0, );
561
- const {
562
- field,
563
- fieldState: { error }
564
- } = _reacthookform.useController.call(void 0, {
565
- name,
566
- control,
567
- disabled: rest.disabled,
568
- defaultValue: null
569
- });
570
- const { value, onChange } = _chunk6JZ35VQJjs.useTransform.call(void 0, {
571
- value: field.value,
572
- onChange: field.onChange,
573
- transform: {
574
- input: typeof _optionalChain([transform, 'optionalAccess', _18 => _18.input]) === "function" ? transform.input : (newValue) => _chunkI7EIUZKKjs.readValueAsDate.call(void 0, adapter, newValue),
575
- output: typeof _optionalChain([transform, 'optionalAccess', _19 => _19.output]) === "function" ? transform.output : (newValue) => newValue
576
- }
577
- });
578
- const handleInputRef = _material.useForkRef.call(void 0, field.ref, inputRef);
579
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
580
- _xdatepickers.TimePicker,
581
- {
582
- ...rest,
583
- ...field,
584
- value,
585
- inputRef: handleInputRef,
586
- onClose: (...args) => {
587
- field.onBlur();
588
- if (rest.onClose) {
589
- rest.onClose(...args);
590
- }
591
- },
592
- onChange: (value2, context) => {
593
- onChange(value2, context);
594
- if (typeof rest.onChange === "function") {
595
- rest.onChange(value2, context);
596
- }
597
- },
598
- slotProps: {
599
- ...slotProps,
600
- textField: {
601
- ...inputProps,
602
- required,
603
- fullWidth: true,
604
- error: !!error,
605
- helperText: error ? error.message : _optionalChain([inputProps, 'optionalAccess', _20 => _20.helperText]) || rest.helperText,
606
- inputProps: {
607
- readOnly: textReadOnly,
608
- ..._optionalChain([inputProps, 'optionalAccess', _21 => _21.inputProps])
609
- }
610
- }
611
- }
612
- }
613
- );
614
- };
615
- var TimePickerElement2 = ({
616
- gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
617
- ...props
618
- }) => {
619
- if (gridProps) {
620
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
621
- _material.Grid2,
622
- {
623
- ...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
624
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component5, { ...props })
625
- }
626
- );
627
- }
628
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component5, { ...props });
629
- };
630
- TimePickerElement2.displayName = "TimePickerElement";
631
- var TimePickerElement_default = TimePickerElement2;
632
-
633
- // src/wrappers/AsyncSelect/AsyncSelectElement.tsx
634
-
635
-
636
-
637
-
638
-
639
-
640
-
641
-
642
-
643
-
644
- var _utils = require('@mui/material/utils');
645
- var _TextField = require('@mui/material/TextField'); var _TextField2 = _interopRequireDefault(_TextField);
646
- var _Autocomplete = require('@mui/material/Autocomplete'); var _Autocomplete2 = _interopRequireDefault(_Autocomplete);
647
-
648
-
649
- var Component6 = function AsyncSelectElement(props) {
650
- const {
651
- name,
652
- onBlur,
653
- disabled,
654
- control,
655
- gridProps,
656
- placeholder,
657
- initialValue,
658
- label,
659
- queryFn,
660
- variant,
661
- labelKey = "Label",
662
- valueKey = "Value",
663
- sx,
664
- ...rest
665
- } = props;
666
- const {
667
- field,
668
- fieldState: { error }
669
- } = _reacthookform.useController.call(void 0, {
670
- name,
671
- control
672
- });
673
- const theme = _material.useTheme.call(void 0, );
674
- const [loading, setLoading] = _react.useState.call(void 0, false);
675
- const [selectedOption, setSelectedOption] = _react.useState.call(void 0, null);
676
- const [inputValue, setInputValue] = _react.useState.call(void 0, "");
677
- const inputValue2 = _react.useMemo.call(void 0, () => inputValue, [inputValue]);
678
- const setInputValue2 = _react.useCallback.call(void 0,
679
- (newValue) => setInputValue(newValue),
680
- []
681
- );
682
- const [options, setOptions] = _react.useState.call(void 0, []);
683
- const initialValueLoaded = _react.useRef.call(void 0,
684
- !initialValue ? true : !(initialValue != null)
685
- );
686
- const fieldValue = _react.useRef.call(void 0, field.value);
687
- const fetchData = _react.useMemo.call(void 0,
688
- () => _utils.debounce.call(void 0,
689
- (payload, callback) => {
690
- queryFn(payload).then((c) => callback(c));
691
- },
692
- 400
693
- ),
694
- []
695
- );
696
- const fillOptions = (results) => {
697
- let newOptions = [];
698
- if (selectedOption) {
699
- newOptions = [selectedOption];
700
- }
701
- if (results) {
702
- newOptions = [...newOptions, ...results];
703
- }
704
- setOptions(newOptions);
705
- setLoading(false);
706
- };
707
- _react.useEffect.call(void 0, () => {
708
- if (initialValueLoaded.current) return void 0;
709
- let active = true;
710
- const payload = {
711
- query: null,
712
- initialValue
713
- };
714
- setLoading(true);
715
- fetchData(payload, (results) => {
716
- if (active) {
717
- if (!!results && results.length > 0) {
718
- fillOptions(_optionalChain([results, 'optionalAccess', _22 => _22.filter, 'call', _23 => _23((c) => c.Value == initialValue)]));
719
- setSelectedOption(results[0]);
720
- field.onChange(results[0].Value);
721
- fieldValue.current = results[0].Value;
722
- }
723
- initialValueLoaded.current = true;
724
- setLoading(false);
725
- }
726
- });
727
- return () => {
728
- active = false;
729
- };
730
- }, [initialValue]);
731
- React.useEffect(() => {
732
- let active = true;
733
- if (inputValue2 === "" || initialValueLoaded.current === false) {
734
- setOptions(selectedOption ? [selectedOption] : []);
735
- setLoading(false);
736
- return void 0;
737
- }
738
- if (fieldValue.current) {
739
- if (field.value === fieldValue.current) {
740
- return void 0;
741
- }
742
- }
743
- setLoading(true);
744
- const payload = {
745
- query: inputValue2,
746
- initialValue: null
747
- };
748
- fetchData(payload, (results) => {
749
- if (active) {
750
- fillOptions(results);
751
- }
752
- });
753
- return () => {
754
- active = false;
755
- };
756
- }, [initialValue, inputValue2, fetchData]);
757
- const selectRef = _react.useRef.call(void 0, null);
758
- const handleChange = (_2, newSelectedOption, reason) => {
759
- if (reason === "clear") {
760
- setSelectedOption(null);
761
- field.onChange(null);
762
- setLoading(false);
763
- } else if (reason === "selectOption" || reason === "removeOption") {
764
- if (newSelectedOption) {
765
- setSelectedOption(newSelectedOption);
766
- field.onChange(newSelectedOption.Value);
767
- fieldValue.current = newSelectedOption.Value;
768
- setLoading(false);
769
- }
770
- }
771
- setOptions([]);
772
- setLoading(false);
773
- };
774
- _react.useEffect.call(void 0, () => {
775
- if (!field.value) {
776
- setInputValue("");
777
- setSelectedOption(null);
778
- setLoading(false);
779
- }
780
- }, [field.value]);
781
- const getOptionValue = (option) => {
782
- if (typeof option === "string") return option;
783
- return option ? option[valueKey] : null;
784
- };
785
- const getOptionLabel = (option) => {
786
- if (typeof option === "string") return option;
787
- return option ? option[labelKey] : "";
788
- };
789
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
790
- _Autocomplete2.default,
791
- {
792
- ...rest,
793
- ref: selectRef,
794
- fullWidth: true,
795
- loading,
796
- getOptionLabel,
797
- getOptionKey: getOptionValue,
798
- isOptionEqualToValue: (option, value) => getOptionValue(option) === getOptionValue(value),
799
- autoComplete: true,
800
- disabled,
801
- includeInputInList: true,
802
- options,
803
- filterOptions: (x) => x,
804
- value: selectedOption,
805
- filterSelectedOptions: true,
806
- onChange: handleChange,
807
- onInputChange: (_2, newInputValue) => {
808
- setInputValue2(newInputValue);
809
- },
810
- noOptionsText: "Type Something...",
811
- renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
812
- _TextField2.default,
813
- {
814
- ...params,
815
- label,
816
- error: !!error,
817
- helperText: error ? error.message : "",
818
- placeholder,
819
- slotProps: {
820
- input: {
821
- ...params.InputProps,
822
- endAdornment: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Fragment, { children: [
823
- loading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.CircularProgress, { color: "inherit", size: 20 }) : null,
824
- params.InputProps.endAdornment
825
- ] })
826
- }
827
- },
828
- variant: variant ? variant : "outlined",
829
- sx: {
830
- "& .MuiInputBase-input": {
831
- cursor: disabled ? "not-allowed" : "default"
832
- },
833
- bgcolor: disabled ? theme.palette.action.disabledBackground : "transparent",
834
- ...sx
835
- }
836
- }
837
- ),
838
- renderOption: (renderProps, option) => {
839
- const { key, ...optionProps } = renderProps;
840
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { ...optionProps, children: option.Label }, key);
841
- }
842
- }
843
- );
844
- };
845
- var AsyncSelectElement2 = ({
846
- gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
847
- ...props
848
- }) => {
849
- if (gridProps) {
850
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
851
- _material.Grid2,
852
- {
853
- ...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
854
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component6, { ...props })
855
- }
856
- );
857
- }
858
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component6, { ...props });
859
- };
860
- AsyncSelectElement2.displayName = "AsyncSelectElement";
861
- var AsyncSelectElement_default = AsyncSelectElement2;
862
-
863
- // src/wrappers/AsyncMultiSelect/AsyncMultiSelect.tsx
864
- var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
865
-
866
-
867
-
868
-
869
-
870
-
871
-
872
-
873
-
874
-
875
-
876
-
877
-
878
-
879
-
880
-
881
-
882
- var _match = require('autosuggest-highlight/match'); var _match2 = _interopRequireDefault(_match);
883
- var _parse = require('autosuggest-highlight/parse'); var _parse2 = _interopRequireDefault(_parse);
884
-
885
- var Component7 = function AsyncSelectMultiElement(props) {
886
- const {
887
- name,
888
- onBlur,
889
- disabled,
890
- control,
891
- gridProps,
892
- placeholder,
893
- initialValues,
894
- label,
895
- queryFn,
896
- variant,
897
- sx,
898
- ...rest
899
- } = props;
900
- const {
901
- field,
902
- fieldState: { error }
903
- } = _reacthookform.useController.call(void 0, {
904
- name,
905
- control
906
- });
907
- const theme = _material.useTheme.call(void 0, );
908
- const multiSelectRef = _react.useRef.call(void 0, null);
909
- const [selectedOptions, setSelectedOptions] = _react.useState.call(void 0, []);
910
- const [inputValue, setInputValue] = _react.useState.call(void 0, "");
911
- const [options, setOptions] = _react.useState.call(void 0, []);
912
- const [loading, setLoading] = _react.useState.call(void 0, false);
913
- const initialValuesLoaded = _react.useRef.call(void 0,
914
- !(initialValues && initialValues.length > 0)
915
- );
916
- const inputValue2 = _react.useMemo.call(void 0, () => inputValue, [inputValue]);
917
- const setInputValue2 = _react.useCallback.call(void 0,
918
- (inputValue3) => setInputValue(inputValue3),
919
- []
920
- );
921
- const fetchData = _react.useMemo.call(void 0,
922
- () => _lodash.debounce.call(void 0,
923
- (payload, callback) => {
924
- queryFn(payload).then((c) => callback(c));
925
- },
926
- 400
927
- ),
928
- []
929
- );
930
- const fillOptions = (results) => {
931
- let newOptions = [];
932
- if (selectedOptions) {
933
- newOptions = [...selectedOptions];
934
- }
935
- if (results) {
936
- const newlyAdded = _lodash2.default.differenceBy(
937
- results,
938
- selectedOptions,
939
- (c) => c.Value
940
- );
941
- newOptions = [...newOptions, ...newlyAdded];
942
- }
943
- setOptions(newOptions);
944
- setLoading(false);
945
- };
946
- _react.useEffect.call(void 0, () => {
947
- if (initialValuesLoaded.current) return void 0;
948
- let active = true;
949
- const payload = {
950
- query: null,
951
- initialValues
952
- };
953
- setLoading(true);
954
- fetchData(payload, (results) => {
955
- if (active) {
956
- setSelectedOptions([...results]);
957
- field.onChange([...results.map((c) => c.Value)]);
958
- initialValuesLoaded.current = true;
959
- setLoading(false);
960
- }
961
- });
962
- return () => {
963
- active = false;
964
- };
965
- }, [initialValues]);
966
- _react.useEffect.call(void 0, () => {
967
- let active = true;
968
- if (inputValue2 === "" || initialValuesLoaded.current === false) {
969
- setOptions(selectedOptions ? [...selectedOptions] : []);
970
- return void 0;
971
- }
972
- setLoading(true);
973
- const payload = {
974
- query: inputValue2,
975
- initialValues: null
976
- };
977
- fetchData(payload, (results) => {
978
- if (active) {
979
- fillOptions(results);
980
- }
981
- });
982
- return () => {
983
- active = false;
984
- };
985
- }, [initialValues, inputValue2, fetchData]);
986
- const handleChange = (_2, selectedOptions2, reason) => {
987
- if (reason === "clear") {
988
- setSelectedOptions([]);
989
- field.onChange([]);
990
- } else if (reason === "selectOption" || reason === "removeOption") {
991
- setSelectedOptions(selectedOptions2);
992
- field.onChange(selectedOptions2.map((c) => c.Value));
993
- }
994
- setOptions([]);
995
- };
996
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
997
- _material.Autocomplete,
998
- {
999
- ref: multiSelectRef,
1000
- multiple: true,
1001
- loading,
1002
- getOptionLabel: (option) => option.Label,
1003
- getOptionKey: (option) => option.Value,
1004
- isOptionEqualToValue: (option, val) => option.Value === val.Value,
1005
- options,
1006
- value: selectedOptions,
1007
- disabled,
1008
- filterSelectedOptions: true,
1009
- onChange: handleChange,
1010
- onInputChange: (_2, newInputValue) => {
1011
- setInputValue2(newInputValue);
1012
- },
1013
- renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1014
- _material.TextField,
1015
- {
1016
- ...params,
1017
- label,
1018
- error: !!error,
1019
- helperText: error ? error.message : "",
1020
- placeholder,
1021
- slotProps: {
1022
- input: {
1023
- ...params.InputProps,
1024
- endAdornment: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Fragment, { children: [
1025
- loading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.CircularProgress, { color: "inherit", size: 20 }) : null,
1026
- params.InputProps.endAdornment
1027
- ] })
1028
- }
1029
- },
1030
- variant: variant ? variant : "outlined",
1031
- sx: {
1032
- "& .MuiInputBase-input": {
1033
- cursor: disabled ? "not-allowed" : "default"
1034
- },
1035
- bgcolor: disabled ? theme.palette.action.disabledBackground : "transparent",
1036
- ...sx
1037
- }
1038
- }
1039
- ),
1040
- renderOption: (props2, option, { inputValue: inputValue3 }) => {
1041
- const { key, ...optionProps } = props2;
1042
- const matches = _match2.default.call(void 0, option.Label, inputValue3, { insideWords: true });
1043
- const parts = _parse2.default.call(void 0, option.Label, matches);
1044
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { ...optionProps, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { children: parts.map((part, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1045
- "span",
1046
- {
1047
- style: {
1048
- fontWeight: part.highlight ? 700 : 400
1049
- },
1050
- children: part.text
1051
- },
1052
- index
1053
- )) }) }, key);
1054
- },
1055
- ...rest
1056
- }
1057
- );
1058
- };
1059
- var AsyncSelectMultiElement2 = ({
1060
- gridProps,
1061
- ...props
1062
- }) => {
1063
- if (gridProps) {
1064
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1065
- _material.Grid2,
1066
- {
1067
- ...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
1068
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component7, { ...props })
1069
- }
1070
- );
1071
- }
1072
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component7, { ...props });
1073
- };
1074
- AsyncSelectMultiElement2.displayName = "AsyncSelectMulti";
1075
- var AsyncMultiSelect_default = AsyncSelectMultiElement2;
1076
-
1077
- // src/wrappers/SelectElement/SelectElement.tsx
1078
-
1079
-
1080
-
1081
-
1082
-
1083
-
1084
-
1085
-
1086
-
1087
-
1088
- var Component8 = function SelectElement(props) {
1089
- const {
1090
- name,
1091
- control,
1092
- onChange,
1093
- isEdit,
1094
- options,
1095
- label,
1096
- sx,
1097
- variant,
1098
- disabled,
1099
- labelKey = "Label",
1100
- valueKey = "Value",
1101
- placeholder,
1102
- textFieldProps = {},
1103
- ...rest
1104
- } = props;
1105
- const { required } = textFieldProps;
1106
- const {
1107
- field,
1108
- fieldState: { error }
1109
- } = _reacthookform.useController.call(void 0, {
1110
- name,
1111
- control
1112
- });
1113
- const theme = _material.useTheme.call(void 0, );
1114
- const getOptionValue = _react.useCallback.call(void 0,
1115
- (option) => {
1116
- if (typeof option === "string") return option;
1117
- return option ? option[valueKey] : null;
1118
- },
1119
- [valueKey]
1120
- );
1121
- const getOptionLabel = _react.useCallback.call(void 0,
1122
- (option) => {
1123
- if (typeof option === "string") return option;
1124
- return option ? String(option[labelKey]) : "";
1125
- },
1126
- [labelKey]
1127
- );
1128
- const handleChange = (event, newValue, reason) => {
1129
- const option = newValue;
1130
- field.onChange(option ? getOptionValue(option) : null);
1131
- _optionalChain([onChange, 'optionalCall', _24 => _24(event, newValue, reason)]);
1132
- };
1133
- _react.useEffect.call(void 0, () => {
1134
- if (!isEdit && options.length === 1 && (field.value == null || field.value == void 0 || field.value === "")) {
1135
- const defaultOption = options[0];
1136
- const defaultValue = getOptionValue(defaultOption);
1137
- field.onChange(defaultValue);
1138
- }
1139
- }, [isEdit, options]);
1140
- const autocompleteValue = _react.useMemo.call(void 0,
1141
- () => _nullishCoalesce(options.find((option) => getOptionValue(option) === field.value), () => ( null)),
1142
- [field.value, options, getOptionValue]
1143
- );
1144
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1145
- _material.Autocomplete,
1146
- {
1147
- ...rest,
1148
- filterSelectedOptions: false,
1149
- options,
1150
- value: autocompleteValue,
1151
- onChange: handleChange,
1152
- disabled,
1153
- getOptionLabel: (option) => getOptionLabel(option),
1154
- ref: field.ref,
1155
- isOptionEqualToValue: (option, value) => getOptionValue(option) === getOptionValue(value),
1156
- renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1157
- _material.TextField,
1158
- {
1159
- ...params,
1160
- fullWidth: true,
1161
- required,
1162
- error: !!error,
1163
- helperText: error ? error.message : "",
1164
- label,
1165
- placeholder,
1166
- variant: variant ? variant : "outlined",
1167
- sx: {
1168
- "& .MuiOutlinedInput-root": {
1169
- bgcolor: disabled ? theme.palette.action.disabledBackground : "transparent"
1170
- },
1171
- "& .MuiInputLabel-asterisk": { color: "red" },
1172
- "& .MuiInputBase-input": {
1173
- cursor: disabled ? "not-allowed" : "default"
1174
- },
1175
- ...sx
1176
- }
1177
- }
1178
- )
1179
- }
1180
- );
1181
- };
1182
- var SelectElement2 = ({
1183
- gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
1184
- ...props
1185
- }) => {
1186
- if (gridProps) {
1187
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1188
- _material.Grid2,
1189
- {
1190
- ...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
1191
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component8, { ...props })
1192
- }
1193
- );
1194
- }
1195
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component8, { ...props });
1196
- };
1197
- SelectElement2.displayName = "SelectElement";
1198
- var SelectElement_default = SelectElement2;
1199
-
1200
- // src/wrappers/SelectMultiElement/SelectMultiElement.tsx
1201
-
1202
-
1203
- var _CheckBox = require('@mui/icons-material/CheckBox'); var _CheckBox2 = _interopRequireDefault(_CheckBox);
1204
- var _CheckBoxOutlineBlank = require('@mui/icons-material/CheckBoxOutlineBlank'); var _CheckBoxOutlineBlank2 = _interopRequireDefault(_CheckBoxOutlineBlank);
1205
-
1206
-
1207
- var Component9 = function SelectMultiElement(props) {
1208
- const {
1209
- name,
1210
- control,
1211
- onBlur,
1212
- disabled,
1213
- options,
1214
- loading = false,
1215
- placeholder,
1216
- label,
1217
- variant,
1218
- sx,
1219
- labelKey = "Label",
1220
- valueKey = "Value",
1221
- ...rest
1222
- } = props;
1223
- const {
1224
- field,
1225
- fieldState: { error }
1226
- } = _reacthookform.useController.call(void 0, {
1227
- name,
1228
- control
1229
- });
1230
- const getOptionValue = (option) => {
1231
- if (typeof option === "string") return option;
1232
- return option ? option[valueKey] : null;
1233
- };
1234
- const getOptionLabel = (option) => {
1235
- if (typeof option === "string") return option;
1236
- return option ? option[labelKey] : "";
1237
- };
1238
- const selectedValue = field.value && Array.isArray(field.value) ? options.filter((option) => field.value.includes(getOptionValue(option))) : [];
1239
- const handleChange = (_2, selectedOptions, reason) => {
1240
- if (reason === "clear") {
1241
- field.onChange([]);
1242
- } else if (reason === "selectOption" || reason === "removeOption") {
1243
- const newValues = selectedOptions.map((option) => getOptionValue(option));
1244
- field.onChange(newValues);
1245
- }
1246
- };
1247
- const icon = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _CheckBoxOutlineBlank2.default, { fontSize: "small" });
1248
- const checkedIcon = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _CheckBox2.default, { fontSize: "small" });
1249
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1250
- _material.Autocomplete,
1251
- {
1252
- multiple: true,
1253
- value: selectedValue,
1254
- loading,
1255
- options,
1256
- getOptionLabel,
1257
- isOptionEqualToValue: (option, value) => getOptionValue(option) === getOptionValue(value),
1258
- filterSelectedOptions: true,
1259
- disableCloseOnSelect: true,
1260
- ref: field.ref,
1261
- disabled: _nullishCoalesce(disabled, () => ( field.disabled)),
1262
- onChange: handleChange,
1263
- onBlur: (event) => {
1264
- field.onBlur();
1265
- if (typeof onBlur === "function") {
1266
- onBlur(event);
1267
- }
1268
- },
1269
- fullWidth: true,
1270
- renderOption: (props1, option, { selected }) => {
1271
- const { key, ...optionProps } = props1;
1272
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { ...optionProps, children: [
1273
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Checkbox, { icon, checkedIcon, checked: selected }),
1274
- getOptionLabel(option)
1275
- ] }, key);
1276
- },
1277
- renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1278
- _material.TextField,
1279
- {
1280
- ...params,
1281
- label,
1282
- error: !!error,
1283
- helperText: error ? error.message : "",
1284
- placeholder,
1285
- slotProps: {
1286
- input: {
1287
- ...params.InputProps,
1288
- endAdornment: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Fragment, { children: [
1289
- loading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.CircularProgress, { color: "inherit", size: 20 }) : null,
1290
- params.InputProps.endAdornment
1291
- ] })
1292
- }
1293
- },
1294
- variant: variant ? variant : "outlined",
1295
- sx: {
1296
- ...sx
1297
- }
1298
- }
1299
- ),
1300
- ...rest
1301
- }
1302
- );
1303
- };
1304
- var SelectMultiElement2 = ({
1305
- gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
1306
- ...props
1307
- }) => {
1308
- if (gridProps) {
1309
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component9, { ...props }) });
1310
- }
1311
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component9, { ...props });
1312
- };
1313
- SelectMultiElement2.displayName = "SelectMultiElement";
1314
- var SelectMultiElement_default = SelectMultiElement2;
1315
-
1316
- // src/wrappers/SelectCascadeElement/SelectCascadeElement.tsx
1317
-
1318
-
1319
-
1320
-
1321
-
1322
-
1323
-
1324
-
1325
-
1326
-
1327
-
1328
- var Component10 = function SelectCascadeElement(props) {
1329
- const {
1330
- labelKey = "Label",
1331
- valueKey = "Value",
1332
- name,
1333
- onBlur,
1334
- onChange,
1335
- disabled,
1336
- options,
1337
- control,
1338
- loading = false,
1339
- placeholder,
1340
- label,
1341
- dependsOn,
1342
- textFieldProps = {},
1343
- variant,
1344
- sx,
1345
- isEdit = false,
1346
- ...rest
1347
- } = props;
1348
- const { required } = textFieldProps;
1349
- const getOptionKey = _react.useCallback.call(void 0,
1350
- (option) => {
1351
- if (typeof option === "string" || typeof option === "number") return option;
1352
- const key = option ? option[valueKey] : void 0;
1353
- return key !== void 0 && key !== null ? String(key) : "";
1354
- },
1355
- [valueKey]
1356
- );
1357
- const getOptionLabel = _react.useCallback.call(void 0,
1358
- (option) => {
1359
- if (typeof option === "string") return option;
1360
- return option ? String(option[labelKey]) : "";
1361
- },
1362
- [labelKey]
1363
- );
1364
- const isOptionEqualToValue = (option, value) => getOptionKey(option) === getOptionKey(value);
1365
- const {
1366
- field,
1367
- fieldState: { error }
1368
- } = _reacthookform.useController.call(void 0, {
1369
- name,
1370
- control
1371
- });
1372
- const theme = _material.useTheme.call(void 0, );
1373
- const { field: dependentField } = _reacthookform.useController.call(void 0, {
1374
- name: dependsOn,
1375
- control
1376
- });
1377
- const parentValueRef = _react.useRef.call(void 0, _nullishCoalesce(dependentField.value, () => ( null)));
1378
- const [hasAutoSelected, setHasAutoSelected] = _react.useState.call(void 0, false);
1379
- _react.useEffect.call(void 0, () => {
1380
- if (!!dependentField.value && _optionalChain([parentValueRef, 'optionalAccess', _25 => _25.current]) !== dependentField.value || dependentField.value === null) {
1381
- field.onChange(null);
1382
- setHasAutoSelected(false);
1383
- }
1384
- }, [dependentField.value]);
1385
- _react.useEffect.call(void 0, () => {
1386
- if (isEdit && !disabled && options.length === 1 && field.value == null && !hasAutoSelected) {
1387
- field.onChange(getOptionKey(options[0]));
1388
- setHasAutoSelected(true);
1389
- } else {
1390
- if (options.length === 1 && field.value == null && !hasAutoSelected) {
1391
- field.onChange(getOptionKey(options[0]));
1392
- setHasAutoSelected(true);
1393
- }
1394
- }
1395
- }, [
1396
- options,
1397
- field.value,
1398
- field.onChange,
1399
- hasAutoSelected,
1400
- isEdit,
1401
- disabled,
1402
- field,
1403
- getOptionKey,
1404
- dependentField.onChange
1405
- ]);
1406
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1407
- _material.Autocomplete,
1408
- {
1409
- ...rest,
1410
- value: options.map((option) => getOptionKey(option) === field.value ? option : null).find(Boolean) || null,
1411
- size: "small",
1412
- loading,
1413
- options,
1414
- getOptionKey,
1415
- getOptionLabel,
1416
- isOptionEqualToValue,
1417
- ref: field.ref,
1418
- disabled: dependentField.value == null || disabled,
1419
- onChange: (event, newValue, reason) => {
1420
- field.onChange(newValue ? getOptionKey(newValue) : null);
1421
- if (onChange && typeof onChange === "function") {
1422
- onChange(event, newValue, reason);
1423
- }
1424
- },
1425
- onBlur: (event) => {
1426
- field.onBlur();
1427
- if (typeof onBlur === "function") {
1428
- onBlur(event);
1429
- }
1430
- },
1431
- fullWidth: true,
1432
- renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1433
- _material.TextField,
1434
- {
1435
- ...params,
1436
- fullWidth: true,
1437
- error: !!error,
1438
- required,
1439
- helperText: error ? error.message : "",
1440
- placeholder,
1441
- label,
1442
- variant: variant ? variant : "outlined",
1443
- sx: {
1444
- "& .MuiOutlinedInput-root": {
1445
- bgcolor: disabled || dependentField.value == null ? theme.palette.action.disabledBackground : "transparent"
1446
- },
1447
- "& .MuiInputLabel-asterisk": { color: "red" },
1448
- "& .MuiInputBase-input": {
1449
- cursor: disabled || dependentField.value == null ? "not-allowed" : "default"
1450
- },
1451
- ...sx
1452
- }
1453
- }
1454
- )
1455
- }
1456
- );
1457
- };
1458
- var SelectCascadeElement2 = ({
1459
- gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
1460
- ...props
1461
- }) => {
1462
- if (gridProps) {
1463
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component10, { ...props }) });
1464
- }
1465
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component10, { ...props });
1466
- };
1467
- SelectCascadeElement2.displayName = "SelectCascadeElement";
1468
- var SelectCascadeElement_default = SelectCascadeElement2;
1469
-
1470
- // src/wrappers/CheckboxElement/CheckboxElement.tsx
1471
-
1472
-
1473
-
1474
-
1475
-
1476
-
1477
-
1478
-
1479
-
1480
-
1481
-
1482
-
1483
- var Component11 = function CheckboxElement(props) {
1484
- const { name, control, label, labelProps, inputRef, ...rest } = props;
1485
- const {
1486
- field,
1487
- fieldState: { error }
1488
- } = _reacthookform.useController.call(void 0, {
1489
- name,
1490
- control,
1491
- disabled: rest.disabled
1492
- });
1493
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.FormControl, { error: !!error, children: [
1494
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormGroup, { row: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1495
- _material.FormControlLabel,
1496
- {
1497
- label: label || "",
1498
- ...labelProps,
1499
- control: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1500
- _material.Checkbox,
1501
- {
1502
- ...rest,
1503
- color: rest.color || "primary",
1504
- sx: [
1505
- ...Array.isArray(rest.sx) ? rest.sx : [rest.sx],
1506
- {
1507
- color: error ? "error.main" : void 0
1508
- }
1509
- ],
1510
- value: field.value,
1511
- checked: !!field.value,
1512
- onChange: (event, newValue) => {
1513
- field.onChange(event, newValue);
1514
- if (typeof rest.onChange === "function") {
1515
- rest.onChange(event, newValue);
1516
- }
1517
- }
1518
- }
1519
- )
1520
- }
1521
- ) }),
1522
- error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormHelperText, { error: !!error, children: error.message })
1523
- ] });
1524
- };
1525
- var CheckboxElement2 = ({
1526
- gridProps,
1527
- ...props
1528
- }) => {
1529
- if (gridProps) {
1530
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component11, { ...props }) });
1531
- }
1532
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component11, { ...props });
1533
- };
1534
- CheckboxElement2.displayName = "CheckboxElement";
1535
- var CheckboxElement_default = CheckboxElement2;
1536
-
1537
- // src/wrappers/CheckboxGroup/CheckboxGroup.tsx
1538
-
1539
-
1540
-
1541
-
1542
-
1543
-
1544
-
1545
-
1546
-
1547
-
1548
-
1549
-
1550
-
1551
- var Component12 = function CheckboxGroup(props) {
1552
- const { name, control, label, labelProps, inputRef, options, ...rest } = props;
1553
- const {
1554
- field,
1555
- fieldState: { error }
1556
- } = _reacthookform.useController.call(void 0, {
1557
- name,
1558
- control,
1559
- disabled: rest.disabled
1560
- });
1561
- const [selectedValues, setSelectedValues] = _react.useState.call(void 0,
1562
- options.filter((c) => _optionalChain([field, 'access', _26 => _26.value, 'optionalAccess', _27 => _27.includes, 'call', _28 => _28(c.Value)])).map((c) => c.Value) || []
1563
- );
1564
- _react.useEffect.call(void 0, () => {
1565
- field.onChange(selectedValues ? [...selectedValues] : []);
1566
- }, [selectedValues]);
1567
- const handleChange = (event) => {
1568
- const value = parseInt(event.target.value, 10);
1569
- if (event.target.checked) {
1570
- setSelectedValues([...selectedValues, value]);
1571
- } else {
1572
- setSelectedValues(selectedValues.filter((item) => item !== value));
1573
- }
1574
- };
1575
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.FormControl, { error: !!error, children: [
1576
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormGroup, { row: true, children: options.map((option) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1577
- _material.FormControlLabel,
1578
- {
1579
- label: option.Label,
1580
- ...labelProps,
1581
- control: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1582
- _material.Checkbox,
1583
- {
1584
- ...rest,
1585
- color: rest.color || "primary",
1586
- sx: [
1587
- ...Array.isArray(rest.sx) ? rest.sx : [rest.sx],
1588
- {
1589
- color: error ? "error.main" : void 0
1590
- }
1591
- ],
1592
- value: option.Value,
1593
- checked: selectedValues.includes(option.Value),
1594
- onChange: handleChange
1595
- }
1596
- )
1597
- },
1598
- `${option.Value}`
1599
- )) }),
1600
- error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormHelperText, { error: !!error, children: error.message })
1601
- ] });
1602
- };
1603
- var CheckboxGroup2 = ({
1604
- gridProps,
1605
- ...props
1606
- }) => {
1607
- if (gridProps) {
1608
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component12, { ...props }) });
1609
- }
1610
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component12, { ...props });
1611
- };
1612
- CheckboxGroup2.displayName = "CheckboxGroup";
1613
- var CheckboxGroup_default = CheckboxGroup2;
1614
-
1615
- // src/wrappers/Field/index.ts
1616
- var Field = {
1617
- Text: TextFieldElement_default,
1618
- Checkbox: CheckboxElement_default,
1619
- Date: DatePickerElement_default,
1620
- RadioGroup: RadioButtonGroup_default,
1621
- Password: PasswordElement_default,
1622
- Time: TimePickerElement_default,
1623
- Select: SelectElement_default,
1624
- SelectMulti: SelectMultiElement_default,
1625
- SelectCascade: SelectCascadeElement_default,
1626
- AsyncSelect: AsyncSelectElement_default,
1627
- AsyncMultiSelect: AsyncMultiSelect_default,
1628
- CheckboxGroup: CheckboxGroup_default
1629
- };
1630
- var Field_default = Field;
1631
-
1632
-
1633
-
1634
- exports.Field_default = Field_default;