@gnwebsoft/ui 2.17.0

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.
@@ -0,0 +1,1288 @@
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 _chunkDFFDICTBjs = require('./chunk-DFFDICTB.js');
7
+
8
+ // src/wrappers/DatePickerElement/DatePickerElement.tsx
9
+
10
+
11
+ var _reacthookform = require('react-hook-form');
12
+ var _material = require('@mui/material');
13
+
14
+
15
+ var _xdatepickers = require('@mui/x-date-pickers');
16
+ var _internals = require('@mui/x-date-pickers/internals');
17
+ var _jsxruntime = require('react/jsx-runtime');
18
+ var Component = function DatePickerElement(props) {
19
+ const {
20
+ parseError,
21
+ name,
22
+ required,
23
+ rules = {},
24
+ inputProps,
25
+ control,
26
+ textReadOnly,
27
+ gridProps,
28
+ slotProps,
29
+ transform,
30
+ datePickerProps = {},
31
+ ...rest
32
+ } = props;
33
+ const adapter = _internals.useLocalizationContext.call(void 0, );
34
+ const { disabled, inputRef, onClose } = datePickerProps;
35
+ const {
36
+ field,
37
+ fieldState: { error }
38
+ } = _reacthookform.useController.call(void 0, {
39
+ name,
40
+ control,
41
+ disabled,
42
+ defaultValue: null
43
+ });
44
+ const { value, onChange } = _chunk6JZ35VQJjs.useTransform.call(void 0, {
45
+ value: field.value,
46
+ onChange: field.onChange,
47
+ transform: {
48
+ input: typeof _optionalChain([transform, 'optionalAccess', _3 => _3.input]) === "function" ? transform.input : (newValue) => _chunkDFFDICTBjs.readValueAsDate.call(void 0, adapter, newValue),
49
+ output: typeof _optionalChain([transform, 'optionalAccess', _4 => _4.output]) === "function" ? transform.output : (newValue) => newValue
50
+ }
51
+ });
52
+ const handleInputRef = _material.useForkRef.call(void 0, field.ref, inputRef);
53
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
54
+ _xdatepickers.DatePicker,
55
+ {
56
+ ...rest,
57
+ ...field,
58
+ value,
59
+ inputRef: handleInputRef,
60
+ onClose: (...args) => {
61
+ field.onBlur();
62
+ if (onClose) {
63
+ onClose(...args);
64
+ }
65
+ },
66
+ onChange: (newValue, context) => {
67
+ onChange(newValue, context);
68
+ if (typeof datePickerProps.onChange === "function") {
69
+ datePickerProps.onChange(newValue, context);
70
+ }
71
+ },
72
+ slotProps: {
73
+ ...slotProps,
74
+ textField: {
75
+ ...inputProps,
76
+ required,
77
+ fullWidth: true,
78
+ onBlur: (event) => {
79
+ field.onBlur();
80
+ if (typeof _optionalChain([inputProps, 'optionalAccess', _5 => _5.onBlur]) === "function") {
81
+ inputProps.onBlur(event);
82
+ }
83
+ },
84
+ error: !!error,
85
+ helperText: error ? error.message : _optionalChain([inputProps, 'optionalAccess', _6 => _6.helperText]) || rest.helperText,
86
+ inputProps: {
87
+ readOnly: !!textReadOnly,
88
+ ..._optionalChain([inputProps, 'optionalAccess', _7 => _7.inputProps])
89
+ }
90
+ }
91
+ }
92
+ }
93
+ );
94
+ };
95
+ var DatePickerElement2 = ({
96
+ gridProps,
97
+ ...props
98
+ }) => {
99
+ if (gridProps) {
100
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...gridProps, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, { ...props }) });
101
+ }
102
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, { ...props });
103
+ };
104
+ DatePickerElement2.displayName = "DatePickerElement";
105
+ var DatePickerElement_default = DatePickerElement2;
106
+
107
+ // src/wrappers/PasswordElement/PasswordElement.tsx
108
+ var _react = require('react'); var React = _interopRequireWildcard(_react);
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+ var _Visibility = require('@mui/icons-material/Visibility'); var _Visibility2 = _interopRequireDefault(_Visibility);
117
+ var _VisibilityOff = require('@mui/icons-material/VisibilityOff'); var _VisibilityOff2 = _interopRequireDefault(_VisibilityOff);
118
+
119
+
120
+
121
+
122
+ var Component2 = function PasswordEl(props) {
123
+ const {
124
+ type,
125
+ required,
126
+ iconColor,
127
+ renderIcon = (password2) => password2 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Visibility2.default, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _VisibilityOff2.default, {}),
128
+ slotProps,
129
+ name,
130
+ control,
131
+ component: TextFieldComponent = _material.TextField,
132
+ inputRef,
133
+ onBlur,
134
+ ...rest
135
+ } = props;
136
+ const [password, setPassword] = _react.useState.call(void 0, true);
137
+ const endAdornment = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.InputAdornment, { position: "end", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
138
+ _material.IconButton,
139
+ {
140
+ onMouseDown: (e) => e.preventDefault(),
141
+ onClick: () => setPassword(!password),
142
+ tabIndex: -1,
143
+ color: _nullishCoalesce(iconColor, () => ( "default")),
144
+ children: renderIcon(password)
145
+ }
146
+ ) });
147
+ const {
148
+ field,
149
+ fieldState: { error }
150
+ } = _reacthookform.useController.call(void 0, {
151
+ name,
152
+ control
153
+ });
154
+ const handleInputRef = _material.useForkRef.call(void 0, field.ref, inputRef);
155
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
156
+ _material.TextField,
157
+ {
158
+ ...rest,
159
+ inputRef: handleInputRef,
160
+ type: password ? "password" : "text",
161
+ value: field.value,
162
+ fullWidth: true,
163
+ onChange: (event) => {
164
+ field.onChange(event);
165
+ if (typeof rest.onChange === "function") {
166
+ rest.onChange(event);
167
+ }
168
+ },
169
+ onBlur: (event) => {
170
+ field.onBlur();
171
+ if (typeof onBlur === "function") {
172
+ onBlur(event);
173
+ }
174
+ },
175
+ ...typeof slotProps === "undefined" ? {
176
+ InputProps: {
177
+ endAdornment
178
+ }
179
+ } : {
180
+ slotProps: {
181
+ ...slotProps,
182
+ input: {
183
+ endAdornment,
184
+ ..._optionalChain([slotProps, 'optionalAccess', _8 => _8.input])
185
+ }
186
+ }
187
+ },
188
+ error: !!error,
189
+ helperText: error ? error.message : ""
190
+ }
191
+ );
192
+ };
193
+ var PasswordElement = ({
194
+ gridProps,
195
+ ...props
196
+ }) => {
197
+ if (gridProps) {
198
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...gridProps, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component2, { ...props }) });
199
+ }
200
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component2, { ...props });
201
+ };
202
+ PasswordElement.displayName = "PasswordElement";
203
+ var PasswordElement_default = PasswordElement;
204
+
205
+ // src/wrappers/RadioButtonGroup/RadioButtonGroup.tsx
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+ var Component3 = function RadioButtonGroup(props) {
222
+ const {
223
+ helperText,
224
+ options,
225
+ label,
226
+ name,
227
+ parseError,
228
+ labelKey = "label",
229
+ valueKey = "id",
230
+ disabledKey = "disabled",
231
+ required,
232
+ emptyOptionLabel,
233
+ returnObject,
234
+ row,
235
+ control,
236
+ type,
237
+ labelProps,
238
+ disabled,
239
+ formLabelProps,
240
+ radioProps,
241
+ transform,
242
+ rules = {},
243
+ ...rest
244
+ } = props;
245
+ const theme = _material.useTheme.call(void 0, );
246
+ const {
247
+ field,
248
+ fieldState: { error }
249
+ } = _reacthookform.useController.call(void 0, {
250
+ name,
251
+ disabled,
252
+ control
253
+ });
254
+ const { value, onChange } = _chunk6JZ35VQJjs.useTransform.call(void 0, {
255
+ value: field.value,
256
+ onChange: field.onChange,
257
+ transform: {
258
+ input: typeof _optionalChain([transform, 'optionalAccess', _9 => _9.input]) === "function" ? transform.input : (value2) => {
259
+ return value2 || "";
260
+ },
261
+ output: typeof _optionalChain([transform, 'optionalAccess', _10 => _10.output]) === "function" ? _optionalChain([transform, 'optionalAccess', _11 => _11.output]) : (_event, value2) => {
262
+ if (value2 && type === "number") {
263
+ return Number(value2);
264
+ }
265
+ return value2;
266
+ }
267
+ }
268
+ });
269
+ const onRadioChange = (event, radioValue) => {
270
+ const returnValue = returnObject ? options.find((items) => items[valueKey] === radioValue) : radioValue;
271
+ onChange(event, returnValue);
272
+ if (typeof rest.onChange === "function") {
273
+ rest.onChange(returnValue);
274
+ }
275
+ };
276
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.FormControl, { error: !!error, children: [
277
+ label && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormLabel, { ...formLabelProps, required, error: !!error, children: label }),
278
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.RadioGroup, { onChange: onRadioChange, name, row, value, children: [
279
+ emptyOptionLabel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
280
+ _material.FormControlLabel,
281
+ {
282
+ ...labelProps,
283
+ control: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
284
+ _material.Radio,
285
+ {
286
+ ...radioProps,
287
+ sx: {
288
+ color: error ? theme.palette.error.main : void 0
289
+ },
290
+ checked: !value
291
+ }
292
+ ),
293
+ label: emptyOptionLabel,
294
+ value: ""
295
+ }
296
+ ),
297
+ options.map((option) => {
298
+ const optionKey = option[valueKey];
299
+ const optionDisabled = option[disabledKey] || false;
300
+ if (optionKey === void 0) {
301
+ console.error(
302
+ `RadioButtonGroup: valueKey ${valueKey} does not exist on option`,
303
+ option
304
+ );
305
+ }
306
+ let val = returnObject ? _optionalChain([value, 'optionalAccess', _12 => _12[valueKey]]) : value;
307
+ if (type === "number") {
308
+ val = Number(val);
309
+ }
310
+ const isChecked = val === optionKey;
311
+ return /* @__PURE__ */ _react.createElement.call(void 0,
312
+ _material.FormControlLabel,
313
+ {
314
+ ...labelProps,
315
+ control: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
316
+ _material.Radio,
317
+ {
318
+ ...radioProps,
319
+ sx: {
320
+ color: error ? theme.palette.error.main : void 0
321
+ },
322
+ disabled: disabled || optionDisabled,
323
+ checked: isChecked
324
+ }
325
+ ),
326
+ value: optionKey,
327
+ label: option[labelKey],
328
+ key: optionKey
329
+ }
330
+ );
331
+ })
332
+ ] }),
333
+ error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormHelperText, { children: error.message })
334
+ ] });
335
+ };
336
+ var RadioButtonGroup2 = ({
337
+ gridProps,
338
+ ...props
339
+ }) => {
340
+ if (gridProps) {
341
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...gridProps, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component3, { ...props }) });
342
+ }
343
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component3, { ...props });
344
+ };
345
+ RadioButtonGroup2.displayName = "RadioButtonGroup";
346
+ var RadioButtonGroup_default = RadioButtonGroup2;
347
+
348
+ // src/wrappers/TextFieldElement/TextFieldElement.tsx
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+ var Component4 = function TextFieldElement(props) {
359
+ const {
360
+ rules = {},
361
+ parseError,
362
+ name,
363
+ control,
364
+ component: TextFieldComponent = _material.TextField,
365
+ gridProps,
366
+ transform,
367
+ textFieldProps = {},
368
+ ...rest
369
+ } = props;
370
+ const { type, required, helperText, inputRef, onBlur, disabled } = textFieldProps;
371
+ const {
372
+ field,
373
+ fieldState: { error }
374
+ } = _reacthookform.useController.call(void 0, {
375
+ name,
376
+ control,
377
+ disabled
378
+ });
379
+ const { value, onChange } = _chunk6JZ35VQJjs.useTransform.call(void 0, {
380
+ value: field.value,
381
+ onChange: field.onChange,
382
+ transform: {
383
+ input: typeof _optionalChain([transform, 'optionalAccess', _13 => _13.input]) === "function" ? transform.input : (value2) => {
384
+ return _nullishCoalesce(value2, () => ( ""));
385
+ },
386
+ output: typeof _optionalChain([transform, 'optionalAccess', _14 => _14.output]) === "function" ? transform.output : (event) => {
387
+ const value2 = event.target.value;
388
+ if (type !== "number") {
389
+ return value2;
390
+ }
391
+ if (value2 === "") {
392
+ return null;
393
+ }
394
+ if (value2 == null) {
395
+ return value2;
396
+ }
397
+ return Number(value2);
398
+ }
399
+ }
400
+ });
401
+ const handleInputRef = _material.useForkRef.call(void 0, field.ref, inputRef);
402
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
403
+ TextFieldComponent,
404
+ {
405
+ ...rest,
406
+ name: field.name,
407
+ value,
408
+ onChange: (event) => {
409
+ field.onChange(event);
410
+ if (typeof onChange === "function") {
411
+ onChange(event);
412
+ }
413
+ },
414
+ onBlur: (event) => {
415
+ field.onBlur();
416
+ if (typeof onBlur === "function") {
417
+ onBlur(event);
418
+ }
419
+ },
420
+ fullWidth: true,
421
+ required,
422
+ type,
423
+ error: !!error,
424
+ helperText: error ? error.message : helperText,
425
+ inputRef: handleInputRef
426
+ }
427
+ );
428
+ };
429
+ var TextFieldElement2 = ({
430
+ gridProps,
431
+ ...props
432
+ }) => {
433
+ if (gridProps) {
434
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...gridProps, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component4, { ...props }) });
435
+ }
436
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component4, { ...props });
437
+ };
438
+ TextFieldElement2.displayName = "TextFieldElement";
439
+ var TextFieldElement_default = TextFieldElement2;
440
+
441
+ // src/wrappers/TimePickerElement/TimePickerElement.tsx
442
+
443
+
444
+
445
+
446
+
447
+
448
+
449
+
450
+
451
+ var Component5 = function TimePickerElement(props) {
452
+ const {
453
+ parseError,
454
+ name,
455
+ required,
456
+ rules = {},
457
+ inputProps,
458
+ control,
459
+ textReadOnly,
460
+ slotProps,
461
+ inputRef,
462
+ transform,
463
+ ...rest
464
+ } = props;
465
+ const adapter = _internals.useLocalizationContext.call(void 0, );
466
+ const {
467
+ field,
468
+ fieldState: { error }
469
+ } = _reacthookform.useController.call(void 0, {
470
+ name,
471
+ control,
472
+ disabled: rest.disabled,
473
+ defaultValue: null
474
+ });
475
+ const { value, onChange } = _chunk6JZ35VQJjs.useTransform.call(void 0, {
476
+ value: field.value,
477
+ onChange: field.onChange,
478
+ transform: {
479
+ input: typeof _optionalChain([transform, 'optionalAccess', _15 => _15.input]) === "function" ? transform.input : (newValue) => _chunkDFFDICTBjs.readValueAsDate.call(void 0, adapter, newValue),
480
+ output: typeof _optionalChain([transform, 'optionalAccess', _16 => _16.output]) === "function" ? transform.output : (newValue) => newValue
481
+ }
482
+ });
483
+ const handleInputRef = _material.useForkRef.call(void 0, field.ref, inputRef);
484
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
485
+ _xdatepickers.TimePicker,
486
+ {
487
+ ...rest,
488
+ ...field,
489
+ value,
490
+ inputRef: handleInputRef,
491
+ onClose: (...args) => {
492
+ field.onBlur();
493
+ if (rest.onClose) {
494
+ rest.onClose(...args);
495
+ }
496
+ },
497
+ onChange: (value2, context) => {
498
+ onChange(value2, context);
499
+ if (typeof rest.onChange === "function") {
500
+ rest.onChange(value2, context);
501
+ }
502
+ },
503
+ slotProps: {
504
+ ...slotProps,
505
+ textField: {
506
+ ...inputProps,
507
+ required,
508
+ fullWidth: true,
509
+ error: !!error,
510
+ helperText: error ? error.message : _optionalChain([inputProps, 'optionalAccess', _17 => _17.helperText]) || rest.helperText,
511
+ inputProps: {
512
+ readOnly: textReadOnly,
513
+ ..._optionalChain([inputProps, 'optionalAccess', _18 => _18.inputProps])
514
+ }
515
+ }
516
+ }
517
+ }
518
+ );
519
+ };
520
+ var TimePickerElement2 = ({
521
+ gridProps,
522
+ ...props
523
+ }) => {
524
+ if (gridProps) {
525
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...gridProps, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component5, { ...props }) });
526
+ }
527
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component5, { ...props });
528
+ };
529
+ TimePickerElement2.displayName = "TimePickerElement";
530
+ var TimePickerElement_default = TimePickerElement2;
531
+
532
+ // src/wrappers/AsyncSelect/AsyncSelect.tsx
533
+
534
+ var _TextField = require('@mui/material/TextField'); var _TextField2 = _interopRequireDefault(_TextField);
535
+ var _Autocomplete = require('@mui/material/Autocomplete'); var _Autocomplete2 = _interopRequireDefault(_Autocomplete);
536
+ var _utils = require('@mui/material/utils');
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+ var Component6 = function AsyncSelectElement(props) {
549
+ const {
550
+ name,
551
+ onBlur,
552
+ disabled,
553
+ control,
554
+ gridProps,
555
+ placeholder,
556
+ initialValue,
557
+ label,
558
+ queryFn,
559
+ ...rest
560
+ } = props;
561
+ const {
562
+ field,
563
+ fieldState: { error }
564
+ } = _reacthookform.useController.call(void 0, {
565
+ name,
566
+ control,
567
+ disabled
568
+ });
569
+ const [loading, setLoading] = _react.useState.call(void 0, false);
570
+ const [selectedOption, setSelectedOption] = _react.useState.call(void 0, null);
571
+ const [inputValue, setInputValue] = _react.useState.call(void 0, "");
572
+ const inputValue2 = _react.useMemo.call(void 0, () => inputValue, [inputValue]);
573
+ const setInputValue2 = _react.useCallback.call(void 0,
574
+ (inputValue3) => setInputValue(inputValue3),
575
+ []
576
+ );
577
+ const [options, setOptions] = _react.useState.call(void 0, []);
578
+ const initialValueLoaded = _react.useRef.call(void 0,
579
+ !initialValue ? true : !(initialValue != null && initialValue > 0)
580
+ );
581
+ const fieldValue = _react.useRef.call(void 0, field.value);
582
+ console.log(initialValue, field.value);
583
+ const fetchData = _react.useMemo.call(void 0,
584
+ () => _utils.debounce.call(void 0,
585
+ (payload, callback) => {
586
+ queryFn(payload).then((c) => callback(c));
587
+ },
588
+ 400
589
+ ),
590
+ []
591
+ );
592
+ const fillOptions = (results) => {
593
+ let newOptions = [];
594
+ if (selectedOption) {
595
+ newOptions = [selectedOption];
596
+ }
597
+ if (results) {
598
+ newOptions = [...newOptions, ...results];
599
+ }
600
+ setOptions(newOptions);
601
+ setLoading(false);
602
+ };
603
+ _react.useEffect.call(void 0, () => {
604
+ if (initialValueLoaded.current) return void 0;
605
+ let active = true;
606
+ const payload = {
607
+ query: null,
608
+ initialValue
609
+ };
610
+ setLoading(true);
611
+ fetchData(payload, (results) => {
612
+ if (active) {
613
+ if (!!results && results.length > 0) {
614
+ fillOptions(_optionalChain([results, 'optionalAccess', _19 => _19.filter, 'call', _20 => _20((c) => c.value == initialValue)]));
615
+ setSelectedOption(results[0]);
616
+ field.onChange(results[0].value);
617
+ fieldValue.current = results[0].value;
618
+ }
619
+ initialValueLoaded.current = true;
620
+ setLoading(false);
621
+ }
622
+ });
623
+ return () => {
624
+ active = false;
625
+ };
626
+ }, [initialValue]);
627
+ React.useEffect(() => {
628
+ let active = true;
629
+ if (inputValue2 === "" || initialValueLoaded.current === false) {
630
+ setOptions(selectedOption ? [selectedOption] : []);
631
+ return void 0;
632
+ }
633
+ if (!!fieldValue.current) {
634
+ if (field.value === fieldValue.current) {
635
+ return void 0;
636
+ }
637
+ }
638
+ setLoading(true);
639
+ const payload = {
640
+ query: inputValue2,
641
+ initialValue: null
642
+ };
643
+ fetchData(payload, (results) => {
644
+ if (active) {
645
+ fillOptions(results);
646
+ }
647
+ });
648
+ return () => {
649
+ active = false;
650
+ };
651
+ }, [initialValue, inputValue2, fetchData]);
652
+ const selectRef = _react.useRef.call(void 0, null);
653
+ const handleChange = (_2, selectedOption2, reason) => {
654
+ if (reason === "clear") {
655
+ setSelectedOption(null);
656
+ field.onChange(null);
657
+ } else if (reason === "selectOption" || reason === "removeOption") {
658
+ if (selectedOption2) {
659
+ setSelectedOption(selectedOption2);
660
+ field.onChange(selectedOption2.value);
661
+ fieldValue.current = selectedOption2.value;
662
+ }
663
+ }
664
+ setOptions([]);
665
+ };
666
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
667
+ _Autocomplete2.default,
668
+ {
669
+ ...rest,
670
+ ref: selectRef,
671
+ fullWidth: true,
672
+ loading,
673
+ getOptionLabel: (option) => option.label,
674
+ getOptionKey: (option) => option.value,
675
+ isOptionEqualToValue: (option, val) => option.value === val.value,
676
+ autoComplete: true,
677
+ includeInputInList: true,
678
+ options,
679
+ value: selectedOption,
680
+ filterSelectedOptions: true,
681
+ onChange: handleChange,
682
+ onInputChange: (_2, newInputValue) => {
683
+ setInputValue2(newInputValue);
684
+ },
685
+ renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
686
+ _TextField2.default,
687
+ {
688
+ ...params,
689
+ label,
690
+ error: !!error,
691
+ helperText: error ? error.message : "",
692
+ placeholder,
693
+ slotProps: {
694
+ input: {
695
+ ...params.InputProps,
696
+ endAdornment: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Fragment, { children: [
697
+ loading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.CircularProgress, { color: "inherit", size: 20 }) : null,
698
+ params.InputProps.endAdornment
699
+ ] })
700
+ }
701
+ }
702
+ }
703
+ ),
704
+ renderOption: (props2, option) => {
705
+ const { key, ...optionProps } = props2;
706
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { ...optionProps, children: option.label }, key);
707
+ }
708
+ }
709
+ );
710
+ };
711
+ var AsyncSelectElement2 = ({
712
+ gridProps,
713
+ ...props
714
+ }) => {
715
+ if (gridProps) {
716
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...gridProps, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component6, { ...props }) });
717
+ }
718
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component6, { ...props });
719
+ };
720
+ AsyncSelectElement2.displayName = "AsyncSelectElement";
721
+ var AsyncSelect_default = AsyncSelectElement2;
722
+
723
+ // src/wrappers/AsyncMultiSelect/AsyncMultiSelect.tsx
724
+ var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
725
+
726
+
727
+
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+
741
+
742
+
743
+ var _match = require('autosuggest-highlight/match'); var _match2 = _interopRequireDefault(_match);
744
+ var _parse = require('autosuggest-highlight/parse'); var _parse2 = _interopRequireDefault(_parse);
745
+
746
+ var Component7 = function AsyncSelectMultiElement(props) {
747
+ const {
748
+ name,
749
+ onBlur,
750
+ disabled,
751
+ control,
752
+ gridProps,
753
+ placeholder,
754
+ initialValues,
755
+ label,
756
+ queryFn,
757
+ ...rest
758
+ } = props;
759
+ const {
760
+ field,
761
+ fieldState: { error }
762
+ } = _reacthookform.useController.call(void 0, {
763
+ name,
764
+ control,
765
+ disabled
766
+ });
767
+ const multiSelectRef = _react.useRef.call(void 0, null);
768
+ const [selectedOptions, setSelectedOptions] = _react.useState.call(void 0, []);
769
+ const [inputValue, setInputValue] = _react.useState.call(void 0, "");
770
+ const [options, setOptions] = _react.useState.call(void 0, []);
771
+ const [loading, setLoading] = _react.useState.call(void 0, false);
772
+ const initialValuesLoaded = _react.useRef.call(void 0,
773
+ !(initialValues && initialValues.length > 0)
774
+ );
775
+ const inputValue2 = _react.useMemo.call(void 0, () => inputValue, [inputValue]);
776
+ const setInputValue2 = _react.useCallback.call(void 0,
777
+ (inputValue3) => setInputValue(inputValue3),
778
+ []
779
+ );
780
+ const fetchData = _react.useMemo.call(void 0,
781
+ () => _lodash.debounce.call(void 0,
782
+ (payload, callback) => {
783
+ queryFn(payload).then((c) => callback(c));
784
+ },
785
+ 400
786
+ ),
787
+ []
788
+ );
789
+ const fillOptions = (results) => {
790
+ let newOptions = [];
791
+ if (selectedOptions) {
792
+ newOptions = [...selectedOptions];
793
+ }
794
+ if (results) {
795
+ const newlyAdded = _lodash2.default.differenceBy(
796
+ results,
797
+ selectedOptions,
798
+ (c) => c.value
799
+ );
800
+ newOptions = [...newOptions, ...newlyAdded];
801
+ }
802
+ setOptions(newOptions);
803
+ setLoading(false);
804
+ };
805
+ _react.useEffect.call(void 0, () => {
806
+ if (initialValuesLoaded.current) return void 0;
807
+ let active = true;
808
+ const payload = {
809
+ query: null,
810
+ initialValues
811
+ };
812
+ setLoading(true);
813
+ fetchData(payload, (results) => {
814
+ if (active) {
815
+ setSelectedOptions([...results]);
816
+ field.onChange([...results.map((c) => c.value)]);
817
+ initialValuesLoaded.current = true;
818
+ setLoading(false);
819
+ }
820
+ });
821
+ return () => {
822
+ active = false;
823
+ };
824
+ }, [initialValues]);
825
+ _react.useEffect.call(void 0, () => {
826
+ let active = true;
827
+ if (inputValue2 === "" || initialValuesLoaded.current === false) {
828
+ setOptions(selectedOptions ? [...selectedOptions] : []);
829
+ return void 0;
830
+ }
831
+ setLoading(true);
832
+ const payload = {
833
+ query: inputValue2,
834
+ initialValues: null
835
+ };
836
+ fetchData(payload, (results) => {
837
+ if (active) {
838
+ fillOptions(results);
839
+ }
840
+ });
841
+ return () => {
842
+ active = false;
843
+ };
844
+ }, [initialValues, inputValue2, fetchData]);
845
+ const handleChange = (_2, selectedOptions2, reason) => {
846
+ if (reason === "clear") {
847
+ setSelectedOptions([]);
848
+ field.onChange([]);
849
+ } else if (reason === "selectOption" || reason === "removeOption") {
850
+ setSelectedOptions(selectedOptions2);
851
+ field.onChange(selectedOptions2.map((c) => c.value));
852
+ }
853
+ setOptions([]);
854
+ };
855
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
856
+ _material.Autocomplete,
857
+ {
858
+ ref: multiSelectRef,
859
+ multiple: true,
860
+ loading,
861
+ getOptionLabel: (option) => option.label,
862
+ getOptionKey: (option) => option.value,
863
+ isOptionEqualToValue: (option, val) => option.value === val.value,
864
+ options,
865
+ value: selectedOptions,
866
+ filterSelectedOptions: true,
867
+ onChange: handleChange,
868
+ onInputChange: (_2, newInputValue) => {
869
+ setInputValue2(newInputValue);
870
+ },
871
+ renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
872
+ _material.TextField,
873
+ {
874
+ ...params,
875
+ label,
876
+ error: !!error,
877
+ helperText: error ? error.message : "",
878
+ placeholder,
879
+ slotProps: {
880
+ input: {
881
+ ...params.InputProps,
882
+ endAdornment: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Fragment, { children: [
883
+ loading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.CircularProgress, { color: "inherit", size: 20 }) : null,
884
+ params.InputProps.endAdornment
885
+ ] })
886
+ }
887
+ }
888
+ }
889
+ ),
890
+ renderOption: (props2, option, { inputValue: inputValue3 }) => {
891
+ const { key, ...optionProps } = props2;
892
+ const matches = _match2.default.call(void 0, option.label, inputValue3, { insideWords: true });
893
+ const parts = _parse2.default.call(void 0, option.label, matches);
894
+ 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,
895
+ "span",
896
+ {
897
+ style: {
898
+ fontWeight: part.highlight ? 700 : 400
899
+ },
900
+ children: part.text
901
+ },
902
+ index
903
+ )) }) }, key);
904
+ },
905
+ ...rest
906
+ }
907
+ );
908
+ };
909
+ var AsyncSelectMultiElement2 = ({
910
+ gridProps,
911
+ ...props
912
+ }) => {
913
+ if (gridProps) {
914
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...gridProps, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component7, { ...props }) });
915
+ }
916
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component7, { ...props });
917
+ };
918
+ AsyncSelectMultiElement2.displayName = "AsyncSelectMulti";
919
+ var AsyncMultiSelect_default = AsyncSelectMultiElement2;
920
+
921
+ // src/wrappers/SelectElement/SelectElement.tsx
922
+
923
+
924
+
925
+
926
+
927
+
928
+
929
+
930
+
931
+ var Component8 = function SelectElement(props) {
932
+ const {
933
+ name,
934
+ onBlur,
935
+ onChange,
936
+ disabled,
937
+ options,
938
+ control,
939
+ gridProps,
940
+ loading = false,
941
+ placeholder,
942
+ label,
943
+ ...rest
944
+ } = props;
945
+ const {
946
+ field,
947
+ fieldState: { error }
948
+ } = _reacthookform.useController.call(void 0, {
949
+ name,
950
+ control,
951
+ disabled
952
+ });
953
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
954
+ _material.Autocomplete,
955
+ {
956
+ ...rest,
957
+ value: field.value ? _nullishCoalesce(options.find((option) => {
958
+ return field.value === option.value;
959
+ }), () => ( null)) : null,
960
+ loading,
961
+ options,
962
+ getOptionLabel: (c) => c.label,
963
+ isOptionEqualToValue: (option, value) => option.value === value.value,
964
+ ref: field.ref,
965
+ disabled: field.disabled,
966
+ onChange: (event, newValue, reason) => {
967
+ field.onChange(newValue ? newValue.value : null);
968
+ if (onChange && typeof onChange === "function") {
969
+ onChange(event, newValue, reason);
970
+ }
971
+ },
972
+ onBlur: (event) => {
973
+ field.onBlur();
974
+ if (typeof onBlur === "function") {
975
+ onBlur(event);
976
+ }
977
+ },
978
+ fullWidth: true,
979
+ renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
980
+ _material.TextField,
981
+ {
982
+ ...params,
983
+ fullWidth: true,
984
+ error: !!error,
985
+ helperText: error ? error.message : "",
986
+ placeholder,
987
+ label,
988
+ variant: "outlined"
989
+ }
990
+ )
991
+ }
992
+ );
993
+ };
994
+ var SelectElement2 = ({
995
+ gridProps,
996
+ ...props
997
+ }) => {
998
+ if (gridProps) {
999
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...gridProps, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component8, { ...props }) });
1000
+ }
1001
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component8, { ...props });
1002
+ };
1003
+ SelectElement2.displayName = "SelectElement";
1004
+ var SelectElement_default = SelectElement2;
1005
+
1006
+ // src/wrappers/SelectMultiElement/SelectMultiElement.tsx
1007
+
1008
+
1009
+
1010
+
1011
+
1012
+
1013
+
1014
+
1015
+
1016
+
1017
+
1018
+ var Component9 = function SelectMultiElement(props) {
1019
+ const {
1020
+ name,
1021
+ onBlur,
1022
+ disabled,
1023
+ options,
1024
+ control,
1025
+ loading = false,
1026
+ placeholder,
1027
+ label,
1028
+ ...rest
1029
+ } = props;
1030
+ const {
1031
+ field,
1032
+ fieldState: { error }
1033
+ } = _reacthookform.useController.call(void 0, {
1034
+ name,
1035
+ control,
1036
+ disabled
1037
+ });
1038
+ const [selectedOptions, setSelectedOptions] = _react.useState.call(void 0, []);
1039
+ const handleChange = (_2, selectedOptions2, reason) => {
1040
+ if (reason === "clear") {
1041
+ setSelectedOptions([]);
1042
+ field.onChange([]);
1043
+ } else if (reason === "selectOption" || reason === "removeOption") {
1044
+ setSelectedOptions(selectedOptions2);
1045
+ field.onChange(selectedOptions2.map((c) => c.value));
1046
+ }
1047
+ };
1048
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1049
+ _material.Autocomplete,
1050
+ {
1051
+ multiple: true,
1052
+ value: selectedOptions,
1053
+ loading,
1054
+ options,
1055
+ getOptionLabel: (c) => c.label,
1056
+ isOptionEqualToValue: (option, value) => option.value === value.value,
1057
+ filterSelectedOptions: true,
1058
+ ref: field.ref,
1059
+ disabled: field.disabled,
1060
+ onChange: handleChange,
1061
+ onBlur: (event) => {
1062
+ field.onBlur();
1063
+ if (typeof onBlur === "function") {
1064
+ onBlur(event);
1065
+ }
1066
+ },
1067
+ fullWidth: true,
1068
+ renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1069
+ _material.TextField,
1070
+ {
1071
+ ...params,
1072
+ label,
1073
+ error: !!error,
1074
+ helperText: error ? error.message : "",
1075
+ placeholder,
1076
+ slotProps: {
1077
+ input: {
1078
+ ...params.InputProps,
1079
+ endAdornment: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Fragment, { children: [
1080
+ loading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.CircularProgress, { color: "inherit", size: 20 }) : null,
1081
+ params.InputProps.endAdornment
1082
+ ] })
1083
+ }
1084
+ }
1085
+ }
1086
+ ),
1087
+ ...rest
1088
+ }
1089
+ );
1090
+ };
1091
+ var SelectMultiElement2 = ({
1092
+ gridProps,
1093
+ ...props
1094
+ }) => {
1095
+ if (gridProps) {
1096
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...gridProps, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component9, { ...props }) });
1097
+ }
1098
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component9, { ...props });
1099
+ };
1100
+ SelectMultiElement2.displayName = "SelectMultiElement";
1101
+ var SelectMultiElement_default = SelectMultiElement2;
1102
+
1103
+ // src/wrappers/SelectCascadeElement/SelectCascadeElement.tsx
1104
+
1105
+
1106
+
1107
+
1108
+
1109
+
1110
+
1111
+
1112
+
1113
+
1114
+ var Component10 = function SelectCascadeElement(props) {
1115
+ const {
1116
+ name,
1117
+ onBlur,
1118
+ onChange,
1119
+ disabled,
1120
+ options,
1121
+ control,
1122
+ gridProps,
1123
+ loading = false,
1124
+ placeholder,
1125
+ label,
1126
+ dependsOn,
1127
+ ...rest
1128
+ } = props;
1129
+ const {
1130
+ field,
1131
+ fieldState: { error }
1132
+ } = _reacthookform.useController.call(void 0, {
1133
+ name,
1134
+ control,
1135
+ disabled
1136
+ });
1137
+ const { field: dependentField } = _reacthookform.useController.call(void 0, {
1138
+ name: dependsOn,
1139
+ control,
1140
+ disabled
1141
+ });
1142
+ const parentValueRef = _react.useRef.call(void 0, _nullishCoalesce(dependentField.value, () => ( null)));
1143
+ _react.useEffect.call(void 0, () => {
1144
+ if (!!dependentField.value && _optionalChain([parentValueRef, 'optionalAccess', _21 => _21.current, 'optionalAccess', _22 => _22.value]) !== dependentField.value || dependentField.value === null) {
1145
+ field.onChange(null);
1146
+ }
1147
+ }, [dependentField.value]);
1148
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1149
+ _material.Autocomplete,
1150
+ {
1151
+ ...rest,
1152
+ value: field.value !== null ? _nullishCoalesce(options.find((option) => {
1153
+ return field.value === option.value;
1154
+ }), () => ( null)) : null,
1155
+ size: "small",
1156
+ loading,
1157
+ options,
1158
+ getOptionLabel: (c) => c.label,
1159
+ isOptionEqualToValue: (option, value) => option.value === value.value,
1160
+ ref: field.ref,
1161
+ disabled: field.disabled,
1162
+ onChange: (event, newValue, reason) => {
1163
+ field.onChange(newValue ? newValue.value : null);
1164
+ if (onChange && typeof onChange === "function") {
1165
+ onChange(event, newValue, reason);
1166
+ }
1167
+ },
1168
+ onBlur: (event) => {
1169
+ field.onBlur();
1170
+ if (typeof onBlur === "function") {
1171
+ onBlur(event);
1172
+ }
1173
+ },
1174
+ fullWidth: true,
1175
+ renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1176
+ _material.TextField,
1177
+ {
1178
+ ...params,
1179
+ fullWidth: true,
1180
+ error: !!error,
1181
+ helperText: error ? error.message : "",
1182
+ placeholder,
1183
+ label,
1184
+ variant: "outlined",
1185
+ sx: { "& .MuiInputBase-input": { color: "#3598dc" } }
1186
+ }
1187
+ )
1188
+ }
1189
+ );
1190
+ };
1191
+ var SelectCascadeElement2 = ({
1192
+ gridProps,
1193
+ ...props
1194
+ }) => {
1195
+ if (gridProps) {
1196
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...gridProps, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component10, { ...props }) });
1197
+ }
1198
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component10, { ...props });
1199
+ };
1200
+ SelectCascadeElement2.displayName = "SelectCascadeElement";
1201
+ var SelectCascadeElement_default = SelectCascadeElement2;
1202
+
1203
+ // src/wrappers/CheckboxElement/CheckboxElement.tsx
1204
+
1205
+
1206
+
1207
+
1208
+
1209
+
1210
+
1211
+
1212
+
1213
+
1214
+
1215
+
1216
+ var Component11 = function CheckboxElement(props) {
1217
+ const { name, control, label, labelProps, inputRef, ...rest } = props;
1218
+ const {
1219
+ field,
1220
+ fieldState: { error }
1221
+ } = _reacthookform.useController.call(void 0, {
1222
+ name,
1223
+ control,
1224
+ disabled: rest.disabled
1225
+ });
1226
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.FormControl, { error: !!error, children: [
1227
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormGroup, { row: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1228
+ _material.FormControlLabel,
1229
+ {
1230
+ label: label || "",
1231
+ ...labelProps,
1232
+ control: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1233
+ _material.Checkbox,
1234
+ {
1235
+ ...rest,
1236
+ color: rest.color || "primary",
1237
+ sx: [
1238
+ ...Array.isArray(rest.sx) ? rest.sx : [rest.sx],
1239
+ {
1240
+ color: error ? "error.main" : void 0
1241
+ }
1242
+ ],
1243
+ value: field.value,
1244
+ checked: !!field.value,
1245
+ onChange: (event, newValue) => {
1246
+ field.onChange(event, newValue);
1247
+ if (typeof rest.onChange === "function") {
1248
+ rest.onChange(event, newValue);
1249
+ }
1250
+ }
1251
+ }
1252
+ )
1253
+ }
1254
+ ) }),
1255
+ error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormHelperText, { error: !!error, children: error.message })
1256
+ ] });
1257
+ };
1258
+ var CheckboxElement2 = ({
1259
+ gridProps,
1260
+ ...props
1261
+ }) => {
1262
+ if (gridProps) {
1263
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Grid2, { ...gridProps, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component11, { ...props }) });
1264
+ }
1265
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component11, { ...props });
1266
+ };
1267
+ CheckboxElement2.displayName = "CheckboxElement";
1268
+ var CheckboxElement_default = CheckboxElement2;
1269
+
1270
+ // src/wrappers/Field/index.ts
1271
+ var Field = {
1272
+ Text: TextFieldElement_default,
1273
+ Checkbox: CheckboxElement_default,
1274
+ Date: DatePickerElement_default,
1275
+ RadioGroup: RadioButtonGroup_default,
1276
+ Password: PasswordElement_default,
1277
+ Time: TimePickerElement_default,
1278
+ Select: SelectElement_default,
1279
+ SelectMulti: SelectMultiElement_default,
1280
+ SelectCascade: SelectCascadeElement_default,
1281
+ AsyncSelect: AsyncSelect_default,
1282
+ AsyncMultiSelect: AsyncMultiSelect_default
1283
+ };
1284
+ var Field_default = Field;
1285
+
1286
+
1287
+
1288
+ exports.Field_default = Field_default;