@knovator/pagecreator-admin 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,207 @@
1
- # admin
1
+ <a name="readme-top"></a>
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ [![Contributors][contributors-shield]][contributors-url]
4
+ [![Forks][forks-shield]][forks-url]
5
+ [![Stargazers][stars-shield]][stars-url]
6
+ [![Issues][issues-shield]][issues-url]
4
7
 
5
- ## Running unit tests
6
8
 
7
- Run `nx test admin` to execute the unit tests via [Jest](https://jestjs.io).
9
+ <!-- PROJECT LOGO -->
10
+ <br />
11
+ <div align="center">
12
+ <!-- <a href="https://github.com/knovator/pagecreator">
13
+ <img src="images/logo.png" alt="Logo" width="80" height="80">
14
+ </a> -->
15
+
16
+ <h3 align="center">@knovator/pagecreator-admin</h3>
17
+
18
+ <p align="center">
19
+ Plug & Play functionality to Build dynamic pages on the fly.
20
+ <br />
21
+ <a href="https://github.com/knovator/pagecreator"><strong>Explore the docs »</strong></a>
22
+ <br />
23
+ <br />
24
+ <a href="https://github.com/knovator/pagecreator">View Demo</a>
25
+ ·
26
+ <a href="https://github.com/knovator/pagecreator/issues">Report Bug</a>
27
+ ·
28
+ <a href="https://github.com/knovator/pagecreator/issues">Request Feature</a>
29
+ </p>
30
+ </div>
31
+
32
+
33
+
34
+ <!-- TABLE OF CONTENTS -->
35
+ <details>
36
+ <summary>Table of Contents</summary>
37
+ <ol>
38
+ <li>
39
+ <a href="#about-the-project">About The Project</a>
40
+ <ul>
41
+ <li><a href="#built-with">Built With</a></li>
42
+ </ul>
43
+ </li>
44
+ <li>
45
+ <a href="#getting-started">Getting Started</a>
46
+ <ul>
47
+ <li><a href="#prerequisites">Prerequisites</a></li>
48
+ <li><a href="#installation">Installation</a></li>
49
+ </ul>
50
+ </li>
51
+ <li><a href="#usage">Usage</a></li>
52
+ <li><a href="#roadmap">Roadmap</a></li>
53
+ <li><a href="#contributing">Contributing</a></li>
54
+ <li><a href="#license">License</a></li>
55
+ <li><a href="#contact">Contact</a></li>
56
+ <li><a href="#acknowledgments">Acknowledgments</a></li>
57
+ </ol>
58
+ </details>
59
+
60
+
61
+
62
+ <!-- ABOUT THE PROJECT -->
63
+ ## About The Project
64
+
65
+ <!-- [![Product Name Screen Shot][product-screenshot]](https://example.com) -->
66
+ `@knovator/pagecreator-admin` provides `Widget` and `Page` components to integrate in UI to builds view that manage **widgets** and **page** data.
67
+
68
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
69
+
70
+
71
+ ### Built With
72
+
73
+ * [ReatJS](https://reactjs.org/)
74
+ * [Nx](https://nx.dev/)
75
+ * [TailwindCSS](https://tailwindcss.com/)
76
+ * [react-hook-form](https://www.npmjs.com/package/react-hook-form)
77
+ * [react-transition-group](https://www.npmjs.com/package/react-transition-group)
78
+ * [react-beautiful-dnd](https://www.npmjs.com/package/react-beautiful-dnd)
79
+ * [react-dropzone](https://www.npmjs.com/package/react-dropzone)
80
+ * [react-select](https://react-select.com/)
81
+ * [@knovator/api](https://www.npmjs.com/package/@knovator/api)
82
+
83
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
84
+
85
+
86
+
87
+ <!-- GETTING STARTED -->
88
+ ## Getting Started
89
+
90
+ `@knovator/pagecreator-admin` is designed to be used in ReactJS/NextJS project.
91
+
92
+ ### Prerequisites
93
+
94
+ We can use `@knovator/pagecreator-admin` in React/Next application, we can create one using following commands
95
+ * Project
96
+ ```sh
97
+ npx create-react-app my-app
98
+ # or
99
+ npx create-next-app@latest
100
+ ```
101
+ * API
102
+ - Keep your backend application ready according to the steps mentioned in [@knovator/pagecreator-node](https://github.com/knovator/pagecreator/tree/main/libs/node)
103
+
104
+
105
+ ### Installation
106
+
107
+
108
+ 1. Install NPM packages
109
+ ```sh
110
+ npm install @knovator/pagecreator-admin
111
+ # or
112
+ yarn add @knovator/pagecreator-admin
113
+ ```
114
+
115
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
116
+
117
+
118
+
119
+ <!-- USAGE EXAMPLES -->
120
+ ## Usage
121
+
122
+ ### Provider
123
+
124
+ `@knovator/pagecreator-admin` uses **Context API**, to support communication between components. So, `Widget`/`Page` components should be wrapped by Provider.
125
+ ```jsx
126
+ import { Provider } from '@knovator/pagecreator-admin';
127
+
128
+ <Provider
129
+ ...
130
+ >
131
+ ...
132
+ </Provider>
133
+ ```
134
+ **Props**
135
+ - `token`
136
+ - JWT token to be sent along the requests
137
+ - `baseUrl`
138
+ - Base API url, without forward slash at end i.e. `https://api.xyz.in`
139
+ - `onError(callback_code, code, message) (optional)`
140
+ - callback to execute on error
141
+ - `onSuccess(callback_code, code, message) (optional)`
142
+ - callback to execute on success
143
+ - `onLogout (optional)`
144
+ - callback to execute on API request with unauthorized code in body
145
+ - `switchClass`
146
+ - `class` name to apply to `Toggle` component, default is `khb_switch`
147
+ - `widgetRoutesPrefix`
148
+ - Prefix to apply after `baseUrl` while calling `widget` API
149
+ - `tilesRoutesPrefix`
150
+ - Prefix to apply after `baseUrl` while calling `tiles` API
151
+ - `pageRoutesPrefix`
152
+ - Prefix to apply after `baseUrl` while calling `page` API
153
+
154
+ ### [Widget](widget.md)
155
+ ### [Page](page.md)
156
+
157
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
158
+
159
+
160
+ <!-- CONTRIBUTING -->
161
+ ## Contributing
162
+
163
+ Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
164
+
165
+ If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
166
+ Don't forget to give the project a star! Thanks again!
167
+
168
+ 1. Fork the Project
169
+ 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
170
+ 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
171
+ 4. Push to the Branch (`git push origin feature/AmazingFeature`)
172
+ 5. Open a Pull Request
173
+
174
+ <p align="right">(<a href="#top">back to top</a>)</p>
175
+
176
+
177
+
178
+ <!-- LICENSE -->
179
+ ## License
180
+
181
+ Distributed under the MIT License. See `LICENSE.txt` for more information.
182
+
183
+ <p align="right">(<a href="#top">back to top</a>)</p>
184
+
185
+
186
+ <!-- CONTACT -->
187
+ ## Contact
188
+
189
+ Knovator Technologies
190
+ - Twitter [@knovator](https://twitter.com/knovator)
191
+ - Web [https://knovator.com/](https://knovator.com/)
192
+
193
+ Project Link: [https://github.com/knovator/masters-admin](https://github.com/knovator/masters-admin)
194
+
195
+ <p align="right">(<a href="#top">back to top</a>)</p>
196
+
197
+ <!-- MARKDOWN LINKS & IMAGES -->
198
+ <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
199
+ [contributors-shield]: https://img.shields.io/github/contributors/knovator/pagecreator.svg?style=for-the-badge
200
+ [contributors-url]: https://github.com/knovator/pagecreator/graphs/contributors
201
+ [forks-shield]: https://img.shields.io/github/forks/knovator/pagecreator.svg?style=for-the-badge
202
+ [forks-url]: https://github.com/knovator/pagecreator/network/members
203
+ [stars-shield]: https://img.shields.io/github/stars/knovator/pagecreator.svg?style=for-the-badge
204
+ [stars-url]: https://github.com/knovator/pagecreator/stargazers
205
+ [issues-shield]: https://img.shields.io/github/issues/knovator/pagecreator.svg?style=for-the-badge
206
+ [issues-url]: https://github.com/knovator/pagecreator/issues
207
+ [product-screenshot]: images/screenshot.png
package/index.js CHANGED
@@ -4,8 +4,8 @@ import fetchUrl, { setAPIConfig } from '@knovator/api';
4
4
  import classNames from 'classnames';
5
5
  import ReactSelect from 'react-select';
6
6
  import { useForm, Controller } from 'react-hook-form';
7
- import CSSTransition from 'react-transition-group/CSSTransition';
8
7
  import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
8
+ import CSSTransition from 'react-transition-group/CSSTransition';
9
9
  import { useDropzone } from 'react-dropzone';
10
10
 
11
11
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -3472,6 +3472,45 @@ const PageSearch = () => {
3472
3472
  });
3473
3473
  };
3474
3474
 
3475
+ var call$7 = functionCall;
3476
+ var hasOwn$1 = hasOwnProperty_1;
3477
+ var isPrototypeOf$2 = objectIsPrototypeOf;
3478
+ var regExpFlags = regexpFlags$1;
3479
+
3480
+ var RegExpPrototype$1 = RegExp.prototype;
3481
+
3482
+ var regexpGetFlags = function (R) {
3483
+ var flags = R.flags;
3484
+ return flags === undefined && !('flags' in RegExpPrototype$1) && !hasOwn$1(R, 'flags') && isPrototypeOf$2(RegExpPrototype$1, R)
3485
+ ? call$7(regExpFlags, R) : flags;
3486
+ };
3487
+
3488
+ var PROPER_FUNCTION_NAME = functionName.PROPER;
3489
+ var defineBuiltIn$2 = defineBuiltIn$7;
3490
+ var anObject$5 = anObject$f;
3491
+ var $toString = toString$6;
3492
+ var fails$3 = fails$n;
3493
+ var getRegExpFlags = regexpGetFlags;
3494
+
3495
+ var TO_STRING = 'toString';
3496
+ var RegExpPrototype = RegExp.prototype;
3497
+ var nativeToString = RegExpPrototype[TO_STRING];
3498
+
3499
+ var NOT_GENERIC = fails$3(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
3500
+ // FF44- RegExp#toString has a wrong name
3501
+ var INCORRECT_NAME = PROPER_FUNCTION_NAME && nativeToString.name != TO_STRING;
3502
+
3503
+ // `RegExp.prototype.toString` method
3504
+ // https://tc39.es/ecma262/#sec-regexp.prototype.tostring
3505
+ if (NOT_GENERIC || INCORRECT_NAME) {
3506
+ defineBuiltIn$2(RegExp.prototype, TO_STRING, function toString() {
3507
+ var R = anObject$5(this);
3508
+ var pattern = $toString(R.source);
3509
+ var flags = $toString(getRegExpFlags(R));
3510
+ return '/' + pattern + '/' + flags;
3511
+ }, { unsafe: true });
3512
+ }
3513
+
3475
3514
  var aCallable$6 = aCallable$8;
3476
3515
  var toObject = toObject$5;
3477
3516
  var IndexedObject = indexedObject;
@@ -3515,11 +3554,11 @@ var arrayReduce = {
3515
3554
  right: createMethod(true)
3516
3555
  };
3517
3556
 
3518
- var fails$3 = fails$n;
3557
+ var fails$2 = fails$n;
3519
3558
 
3520
3559
  var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
3521
3560
  var method = [][METHOD_NAME];
3522
- return !!method && fails$3(function () {
3561
+ return !!method && fails$2(function () {
3523
3562
  // eslint-disable-next-line no-useless-call -- required for testing
3524
3563
  method.call(null, argument || function () { return 1; }, 1);
3525
3564
  });
@@ -3550,45 +3589,6 @@ $$7({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
3550
3589
  }
3551
3590
  });
3552
3591
 
3553
- var call$7 = functionCall;
3554
- var hasOwn$1 = hasOwnProperty_1;
3555
- var isPrototypeOf$2 = objectIsPrototypeOf;
3556
- var regExpFlags = regexpFlags$1;
3557
-
3558
- var RegExpPrototype$1 = RegExp.prototype;
3559
-
3560
- var regexpGetFlags = function (R) {
3561
- var flags = R.flags;
3562
- return flags === undefined && !('flags' in RegExpPrototype$1) && !hasOwn$1(R, 'flags') && isPrototypeOf$2(RegExpPrototype$1, R)
3563
- ? call$7(regExpFlags, R) : flags;
3564
- };
3565
-
3566
- var PROPER_FUNCTION_NAME = functionName.PROPER;
3567
- var defineBuiltIn$2 = defineBuiltIn$7;
3568
- var anObject$5 = anObject$f;
3569
- var $toString = toString$6;
3570
- var fails$2 = fails$n;
3571
- var getRegExpFlags = regexpGetFlags;
3572
-
3573
- var TO_STRING = 'toString';
3574
- var RegExpPrototype = RegExp.prototype;
3575
- var nativeToString = RegExpPrototype[TO_STRING];
3576
-
3577
- var NOT_GENERIC = fails$2(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
3578
- // FF44- RegExp#toString has a wrong name
3579
- var INCORRECT_NAME = PROPER_FUNCTION_NAME && nativeToString.name != TO_STRING;
3580
-
3581
- // `RegExp.prototype.toString` method
3582
- // https://tc39.es/ecma262/#sec-regexp.prototype.tostring
3583
- if (NOT_GENERIC || INCORRECT_NAME) {
3584
- defineBuiltIn$2(RegExp.prototype, TO_STRING, function toString() {
3585
- var R = anObject$5(this);
3586
- var pattern = $toString(R.source);
3587
- var flags = $toString(getRegExpFlags(R));
3588
- return '/' + pattern + '/' + flags;
3589
- }, { unsafe: true });
3590
- }
3591
-
3592
3592
  var $$6 = _export;
3593
3593
  var $parseInt = numberParseInt;
3594
3594
 
@@ -3642,20 +3642,10 @@ const Form = /*#__PURE__*/forwardRef(({
3642
3642
  setValue(key, updates[key]);
3643
3643
  });
3644
3644
  }
3645
- }, [setValue, updates]); // setting default values
3646
-
3647
- useEffect(() => {
3648
- if (isEmpty(data)) {
3649
- const defaultValues = schema.reduce((values, schemaItem) => {
3650
- if (typeof schemaItem.defaultValue !== 'undefined') values[schemaItem.accessor] = schemaItem.defaultValue;
3651
- return values;
3652
- }, {});
3653
- reset(defaultValues);
3654
- }
3655
- }, [data, reset, schema]);
3645
+ }, [setValue, updates]);
3656
3646
 
3657
3647
  const inputRenderer = schema => {
3658
- var _a, _b, _c, _d, _e, _f, _g, _h;
3648
+ var _a, _b, _c, _d, _e, _f;
3659
3649
 
3660
3650
  let input;
3661
3651
  if (typeof schema.show !== 'undefined' && !schema.show) return null;
@@ -3699,18 +3689,191 @@ const Form = /*#__PURE__*/forwardRef(({
3699
3689
  break;
3700
3690
 
3701
3691
  case 'select':
3702
- input = jsx(Input.Select, {
3703
- options: schema.options,
3692
+ input = jsx(Controller, {
3693
+ control: control,
3694
+ name: schema.accessor,
3695
+ render: ({
3696
+ field
3697
+ }) => {
3698
+ var _a, _b;
3699
+
3700
+ return jsx(Input.Select, {
3701
+ options: schema.options,
3702
+ label: schema.label,
3703
+ error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
3704
+ onChange: e => field.onChange(e.target.value),
3705
+ value: field.value,
3706
+ className: "w-full",
3707
+ disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable,
3708
+ required: schema.required,
3709
+ wrapperClassName: schema.wrapperClassName
3710
+ });
3711
+ }
3712
+ });
3713
+ break;
3714
+
3715
+ case 'text':
3716
+ case 'number':
3717
+ case 'url':
3718
+ default:
3719
+ input = jsx(Input, {
3720
+ rest: register(schema.accessor, schema.validations || {}),
3704
3721
  label: schema.label,
3705
3722
  error: (_f = (_e = errors[schema.accessor]) === null || _e === void 0 ? void 0 : _e.message) === null || _f === void 0 ? void 0 : _f.toString(),
3706
- rest: register(schema.accessor, schema.validations || {}),
3707
- className: "w-full",
3723
+ type: schema.type,
3724
+ className: "w-full p-2",
3725
+ placeholder: schema.placeholder,
3708
3726
  disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable,
3709
3727
  required: schema.required,
3728
+ onInput: schema.onInput,
3729
+ wrapperClassName: schema.wrapperClassName
3730
+ });
3731
+ break;
3732
+ }
3733
+ } else if (schema.Input) {
3734
+ input = jsxs("div", Object.assign({
3735
+ className: "kms_input-wrapper"
3736
+ }, {
3737
+ children: [jsx("label", Object.assign({
3738
+ className: "kms_input-label"
3739
+ }, {
3740
+ children: schema.label
3741
+ })), jsx(Controller, {
3742
+ control: control,
3743
+ name: schema.accessor,
3744
+ rules: schema.validations,
3745
+ render: ({
3746
+ field
3747
+ }) => {
3748
+ var _a, _b; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
3749
+
3750
+
3751
+ return schema.Input({
3752
+ field,
3753
+ error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
3754
+ disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable,
3755
+ setError: msg => setError.call(null, schema.accessor, {
3756
+ type: 'custom',
3757
+ message: msg
3758
+ })
3759
+ });
3760
+ }
3761
+ })]
3762
+ }));
3763
+ } else throw new Error(`Please provide Input or type prop to render input Labeled ${schema.label}`);
3764
+
3765
+ return input;
3766
+ };
3767
+
3768
+ const onFormSubmit = e => __awaiter(void 0, void 0, void 0, function* () {
3769
+ e.preventDefault();
3770
+ handleSubmit(data => {
3771
+ const formattedData = schema.reduce((values, schemaItem) => {
3772
+ // Do not add field if editing is disabled for it
3773
+ if (_isUpdating && typeof schemaItem.editable !== 'undefined' && !schemaItem.editable) return values;
3774
+
3775
+ if (schemaItem.type === 'number') {
3776
+ values[schemaItem.accessor] = data[schemaItem.accessor] === '' ? null : parseInt(data[schemaItem.accessor]);
3777
+ } else values[schemaItem.accessor] = data[schemaItem.accessor];
3778
+
3779
+ return values;
3780
+ }, {});
3781
+ onSubmit(formattedData);
3782
+ })();
3783
+ });
3784
+
3785
+ return jsx("form", Object.assign({
3786
+ onSubmit: onFormSubmit,
3787
+ ref: ref,
3788
+ className: "khb-form-items"
3789
+ }, {
3790
+ children: schema.map((schema, i) => jsx(React.Fragment, {
3791
+ children: inputRenderer(schema)
3792
+ }, i))
3793
+ }));
3794
+ });
3795
+
3796
+ const SimpleForm = /*#__PURE__*/forwardRef(({
3797
+ schema,
3798
+ onSubmit,
3799
+ isUpdating: _isUpdating = false,
3800
+ enable: _enable = true,
3801
+ register,
3802
+ errors,
3803
+ handleSubmit,
3804
+ setValue,
3805
+ control,
3806
+ setError
3807
+ }, ref) => {
3808
+ const inputRenderer = schema => {
3809
+ var _a, _b, _c, _d, _e, _f;
3810
+
3811
+ let input;
3812
+ if (typeof schema.show !== 'undefined' && !schema.show) return null;
3813
+
3814
+ if (schema.type) {
3815
+ switch (schema.type) {
3816
+ case 'ReactSelect':
3817
+ input = jsx(CustomReactSelect, {
3818
+ options: schema.options,
3819
+ disabled: !_enable,
3820
+ label: schema.label,
3821
+ error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
3822
+ onChange: value => {
3823
+ if (value) {
3824
+ setValue(schema.accessor, Array.isArray(value) ? value.map(item => item.value) : value.value);
3825
+ if (schema.onChange) schema.onChange(value);
3826
+ }
3827
+ },
3828
+ selectedOptions: schema.selectedOptions,
3829
+ required: schema.required,
3830
+ isMulti: schema.isMulti,
3831
+ isSearchable: schema.isSearchable,
3832
+ onSearch: schema.onSearch,
3833
+ isLoading: schema.isLoading,
3834
+ placeholder: schema.placeholder,
3835
+ wrapperClassName: schema.wrapperClassName,
3836
+ formatOptionLabel: schema.formatOptionLabel
3837
+ });
3838
+ break;
3839
+
3840
+ case 'checkbox':
3841
+ input = jsx(Input.Checkbox, {
3842
+ error: (_d = (_c = errors[schema.accessor]) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.toString(),
3843
+ switchClass: schema.switchClass,
3844
+ label: schema.label,
3845
+ rest: register(schema.accessor, schema.validations || {}),
3846
+ className: "block",
3847
+ disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable,
3710
3848
  wrapperClassName: schema.wrapperClassName
3711
3849
  });
3712
3850
  break;
3713
3851
 
3852
+ case 'select':
3853
+ input = jsx(Controller, {
3854
+ control: control,
3855
+ name: schema.accessor,
3856
+ render: ({
3857
+ field
3858
+ }) => {
3859
+ var _a, _b;
3860
+
3861
+ return jsx(Input.Select, {
3862
+ options: schema.options,
3863
+ label: schema.label,
3864
+ error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
3865
+ // onChange={(e) => field.onChange(e.target.value)}
3866
+ rest: field,
3867
+ // value={field.value}
3868
+ className: "w-full",
3869
+ disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable,
3870
+ required: schema.required,
3871
+ wrapperClassName: schema.wrapperClassName
3872
+ });
3873
+ }
3874
+ });
3875
+ break;
3876
+
3714
3877
  case 'text':
3715
3878
  case 'number':
3716
3879
  case 'url':
@@ -3718,7 +3881,7 @@ const Form = /*#__PURE__*/forwardRef(({
3718
3881
  input = jsx(Input, {
3719
3882
  rest: register(schema.accessor, schema.validations || {}),
3720
3883
  label: schema.label,
3721
- error: (_h = (_g = errors[schema.accessor]) === null || _g === void 0 ? void 0 : _g.message) === null || _h === void 0 ? void 0 : _h.toString(),
3884
+ error: (_f = (_e = errors[schema.accessor]) === null || _e === void 0 ? void 0 : _e.message) === null || _f === void 0 ? void 0 : _f.toString(),
3722
3885
  type: schema.type,
3723
3886
  className: "w-full p-2",
3724
3887
  placeholder: schema.placeholder,
@@ -3792,125 +3955,17 @@ const Form = /*#__PURE__*/forwardRef(({
3792
3955
  }));
3793
3956
  });
3794
3957
 
3795
- const Close = ({
3796
- srText,
3797
- className
3958
+ const DNDItemsList = ({
3959
+ onDragEnd,
3960
+ items,
3961
+ formatItem,
3962
+ listCode
3798
3963
  }) => {
3799
- return jsxs(Fragment, {
3800
- children: [srText ? jsx("span", Object.assign({
3801
- className: "khb_sr-only"
3802
- }, {
3803
- children: srText
3804
- })) : null, jsx("svg", Object.assign({
3805
- className: className,
3806
- xmlns: "http://www.w3.org/2000/svg",
3807
- viewBox: "-6 -6 24 24",
3808
- width: "24",
3809
- fill: "currentColor"
3810
- }, {
3811
- children: jsx("path", {
3812
- d: "M7.314 5.9l3.535-3.536A1 1 0 1 0 9.435.95L5.899 4.485 2.364.95A1 1 0 1 0 .95 2.364l3.535 3.535L.95 9.435a1 1 0 1 0 1.414 1.414l3.535-3.535 3.536 3.535a1 1 0 1 0 1.414-1.414L7.314 5.899z"
3813
- })
3814
- }))]
3815
- });
3816
- };
3817
-
3818
- const Drawer = ({
3819
- children,
3820
- open,
3821
- onClose,
3822
- title,
3823
- footerContent
3824
- }) => {
3825
- const nodeRef = useRef(null);
3826
- return jsx(CSSTransition, Object.assign({
3827
- ref: nodeRef,
3828
- in: open,
3829
- timeout: {
3830
- enter: 250,
3831
- exit: 350
3832
- },
3833
- classNames: "khb_drawer",
3834
- mountOnEnter: true,
3835
- unmountOnExit: true
3836
- }, {
3837
- children: jsx("div", Object.assign({
3838
- className: "khb_drawer-wrapper-1",
3839
- "aria-labelledby": "modal",
3840
- role: "dialog",
3841
- "aria-modal": "true",
3842
- ref: nodeRef,
3843
- "data-testid": "drawer"
3844
- }, {
3845
- children: jsxs("div", Object.assign({
3846
- className: "khb_drawer-wrapper-2"
3847
- }, {
3848
- children: [jsx("div", {
3849
- className: "khb_drawer-backdrop",
3850
- role: "button",
3851
- onClick: onClose,
3852
- onKeyDown: onClose,
3853
- tabIndex: 0
3854
- }), jsx("div", Object.assign({
3855
- className: "khb_drawer-container-1"
3856
- }, {
3857
- children: jsxs("div", Object.assign({
3858
- className: "khb_drawer-container-2"
3859
- }, {
3860
- children: [jsx("div", Object.assign({
3861
- className: "khb_drawer-close-section"
3862
- }, {
3863
- children: jsxs("button", Object.assign({
3864
- type: "button",
3865
- className: "khb_drawer-close-btn",
3866
- onClick: onClose,
3867
- "data-testid": "drawer-close"
3868
- }, {
3869
- children: [jsx("span", Object.assign({
3870
- className: "khb_sr-only"
3871
- }, {
3872
- children: "Close panel"
3873
- })), jsx(Close, {})]
3874
- }))
3875
- })), jsxs("div", Object.assign({
3876
- className: "khb_drawer-main"
3877
- }, {
3878
- children: [jsx("div", Object.assign({
3879
- className: "khb_drawer-header"
3880
- }, {
3881
- children: jsx("p", Object.assign({
3882
- className: "khb_drawer-header-title"
3883
- }, {
3884
- children: title
3885
- }))
3886
- })), jsx("div", Object.assign({
3887
- className: "relative flex-1 px-6 py-6 overflow-auto"
3888
- }, {
3889
- children: children
3890
- })), footerContent && jsx("div", Object.assign({
3891
- className: "khb_drawer-footer"
3892
- }, {
3893
- children: footerContent
3894
- }))]
3895
- }))]
3896
- }))
3897
- }))]
3898
- }))
3899
- }))
3900
- }));
3901
- };
3902
-
3903
- const DNDItemsList = ({
3904
- onDragEnd,
3905
- items,
3906
- formatItem,
3907
- listCode
3908
- }) => {
3909
- return jsx(DragDropContext, Object.assign({
3910
- onDragEnd: onDragEnd
3911
- }, {
3912
- children: jsx(Droppable, Object.assign({
3913
- droppableId: "droppable"
3964
+ return jsx(DragDropContext, Object.assign({
3965
+ onDragEnd: onDragEnd
3966
+ }, {
3967
+ children: jsx(Droppable, Object.assign({
3968
+ droppableId: "droppable"
3914
3969
  }, {
3915
3970
  children: droppableProvided => jsxs("div", Object.assign({
3916
3971
  className: "khb_DND-items",
@@ -3936,79 +3991,13 @@ const DNDItemsList = ({
3936
3991
  }));
3937
3992
  };
3938
3993
 
3939
- const FormActions = ({
3940
- loading: _loading = false,
3941
- primaryLabel: _primaryLabel = 'Submit',
3942
- secondaryLabel: _secondaryLabel = 'Cancel',
3943
- onPrimaryButtonClick,
3944
- onSecondaryButtonClick
3945
- }) => {
3946
- return jsxs(Fragment, {
3947
- children: [jsx(Button, Object.assign({
3948
- type: "secondary",
3949
- disabled: _loading,
3950
- onClick: onSecondaryButtonClick
3951
- }, {
3952
- children: _secondaryLabel
3953
- })), jsx(Button, Object.assign({
3954
- onClick: onPrimaryButtonClick,
3955
- disabled: _loading
3956
- }, {
3957
- children: _primaryLabel
3958
- }))]
3959
- });
3960
- };
3961
-
3962
- const PageFormActions = ({
3963
- formRef
3964
- }) => {
3965
- const {
3966
- onError
3967
- } = useProviderState();
3968
- const {
3969
- closeForm,
3970
- loading,
3971
- canAdd,
3972
- canUpdate,
3973
- t
3974
- } = usePageState();
3975
-
3976
- const onSubmitClick = e => {
3977
- var _a;
3978
-
3979
- if (!formRef) {
3980
- return onError(CALLBACK_CODES.INTERNAL, 'error', `formRef is required to submit the form!`);
3981
- } else if (!formRef.current) {
3982
- return onError(CALLBACK_CODES.INTERNAL, 'error', `formRef is empty, make sure it's passed as 'ref' prop to the form!`);
3983
- } // formRef is provided
3984
-
3985
-
3986
- e === null || e === void 0 ? void 0 : e.preventDefault();
3987
- (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new Event('submit', {
3988
- cancelable: true,
3989
- bubbles: true
3990
- }));
3991
- };
3992
-
3993
- if (!canAdd && !canUpdate) return null;
3994
- return jsx(FormActions, {
3995
- loading: loading,
3996
- primaryLabel: t('saveButtonText'),
3997
- onPrimaryButtonClick: onSubmitClick,
3998
- onSecondaryButtonClick: closeForm,
3999
- secondaryLabel: t('cancelButtonText')
4000
- });
4001
- };
4002
-
4003
3994
  const PageForm = ({
4004
- onClose,
4005
- open,
4006
- formState,
4007
3995
  formRef
4008
3996
  }) => {
4009
3997
  const {
4010
3998
  t,
4011
3999
  data,
4000
+ formState,
4012
4001
  onPageFormSubmit,
4013
4002
  selectedWidgets,
4014
4003
  setSelectedWidgets,
@@ -4069,31 +4058,22 @@ const PageForm = ({
4069
4058
  onChange: widgets => setSelectedWidgets(widgets)
4070
4059
  }];
4071
4060
  if (!canAdd && !canUpdate) return null;
4072
- return jsx(Drawer, Object.assign({
4073
- open: open,
4074
- onClose: onClose,
4075
- title: formState === 'ADD' ? t('page.addPageTitle') : formState === 'UPDATE' ? t('page.updatePageTitle') : '',
4076
- footerContent: jsx(PageFormActions, {
4077
- formRef: formRef
4078
- })
4061
+ return jsxs("div", Object.assign({
4062
+ className: "khb_form"
4079
4063
  }, {
4080
- children: jsxs("div", Object.assign({
4081
- className: "khb_form"
4082
- }, {
4083
- children: [jsx(Form, {
4084
- schema: pageFormSchema,
4085
- onSubmit: onPageFormSubmit,
4086
- ref: formRef,
4087
- data: data,
4088
- isUpdating: formState === 'UPDATE',
4089
- updates: {
4090
- widgets: selectedWidgets.map(widget => widget.value)
4091
- }
4092
- }), jsx(DNDItemsList, {
4093
- onDragEnd: onDragEnd,
4094
- items: selectedWidgets
4095
- })]
4096
- }))
4064
+ children: [jsx(Form, {
4065
+ schema: pageFormSchema,
4066
+ onSubmit: onPageFormSubmit,
4067
+ ref: formRef,
4068
+ data: data,
4069
+ isUpdating: formState === 'UPDATE',
4070
+ updates: {
4071
+ widgets: selectedWidgets.map(widget => widget.value)
4072
+ }
4073
+ }), jsx(DNDItemsList, {
4074
+ onDragEnd: onDragEnd,
4075
+ items: selectedWidgets
4076
+ })]
4097
4077
  }));
4098
4078
  };
4099
4079
 
@@ -4265,6 +4245,29 @@ const PagePagination = () => {
4265
4245
  });
4266
4246
  };
4267
4247
 
4248
+ const Close = ({
4249
+ srText,
4250
+ className
4251
+ }) => {
4252
+ return jsxs(Fragment, {
4253
+ children: [srText ? jsx("span", Object.assign({
4254
+ className: "khb_sr-only"
4255
+ }, {
4256
+ children: srText
4257
+ })) : null, jsx("svg", Object.assign({
4258
+ className: className,
4259
+ xmlns: "http://www.w3.org/2000/svg",
4260
+ viewBox: "-6 -6 24 24",
4261
+ width: "24",
4262
+ fill: "currentColor"
4263
+ }, {
4264
+ children: jsx("path", {
4265
+ d: "M7.314 5.9l3.535-3.536A1 1 0 1 0 9.435.95L5.899 4.485 2.364.95A1 1 0 1 0 .95 2.364l3.535 3.535L.95 9.435a1 1 0 1 0 1.414 1.414l3.535-3.535 3.536 3.535a1 1 0 1 0 1.414-1.414L7.314 5.899z"
4266
+ })
4267
+ }))]
4268
+ });
4269
+ };
4270
+
4268
4271
  const Modal = ({
4269
4272
  open,
4270
4273
  onClose,
@@ -4399,6 +4402,155 @@ const DeleteModal = ({
4399
4402
  })) : null;
4400
4403
  };
4401
4404
 
4405
+ const Drawer = ({
4406
+ children,
4407
+ open,
4408
+ onClose,
4409
+ title,
4410
+ footerContent
4411
+ }) => {
4412
+ const nodeRef = useRef(null);
4413
+ return jsx(CSSTransition, Object.assign({
4414
+ ref: nodeRef,
4415
+ in: open,
4416
+ timeout: {
4417
+ enter: 250,
4418
+ exit: 350
4419
+ },
4420
+ classNames: "khb_drawer",
4421
+ mountOnEnter: true,
4422
+ unmountOnExit: true
4423
+ }, {
4424
+ children: jsx("div", Object.assign({
4425
+ className: "khb_drawer-wrapper-1",
4426
+ "aria-labelledby": "modal",
4427
+ role: "dialog",
4428
+ "aria-modal": "true",
4429
+ ref: nodeRef,
4430
+ "data-testid": "drawer"
4431
+ }, {
4432
+ children: jsxs("div", Object.assign({
4433
+ className: "khb_drawer-wrapper-2"
4434
+ }, {
4435
+ children: [jsx("div", {
4436
+ className: "khb_drawer-backdrop",
4437
+ role: "button",
4438
+ onClick: onClose,
4439
+ onKeyDown: onClose,
4440
+ tabIndex: 0
4441
+ }), jsx("div", Object.assign({
4442
+ className: "khb_drawer-container-1"
4443
+ }, {
4444
+ children: jsxs("div", Object.assign({
4445
+ className: "khb_drawer-container-2"
4446
+ }, {
4447
+ children: [jsx("div", Object.assign({
4448
+ className: "khb_drawer-close-section"
4449
+ }, {
4450
+ children: jsxs("button", Object.assign({
4451
+ type: "button",
4452
+ className: "khb_drawer-close-btn",
4453
+ onClick: onClose,
4454
+ "data-testid": "drawer-close"
4455
+ }, {
4456
+ children: [jsx("span", Object.assign({
4457
+ className: "khb_sr-only"
4458
+ }, {
4459
+ children: "Close panel"
4460
+ })), jsx(Close, {})]
4461
+ }))
4462
+ })), jsxs("div", Object.assign({
4463
+ className: "khb_drawer-main"
4464
+ }, {
4465
+ children: [jsx("div", Object.assign({
4466
+ className: "khb_drawer-header"
4467
+ }, {
4468
+ children: jsx("p", Object.assign({
4469
+ className: "khb_drawer-header-title"
4470
+ }, {
4471
+ children: title
4472
+ }))
4473
+ })), jsx("div", Object.assign({
4474
+ className: "relative flex-1 px-6 py-6 overflow-auto"
4475
+ }, {
4476
+ children: children
4477
+ })), footerContent && jsx("div", Object.assign({
4478
+ className: "khb_drawer-footer"
4479
+ }, {
4480
+ children: footerContent
4481
+ }))]
4482
+ }))]
4483
+ }))
4484
+ }))]
4485
+ }))
4486
+ }))
4487
+ }));
4488
+ };
4489
+
4490
+ const FormActions = ({
4491
+ loading: _loading = false,
4492
+ primaryLabel: _primaryLabel = 'Submit',
4493
+ secondaryLabel: _secondaryLabel = 'Cancel',
4494
+ onPrimaryButtonClick,
4495
+ onSecondaryButtonClick
4496
+ }) => {
4497
+ return jsxs(Fragment, {
4498
+ children: [jsx(Button, Object.assign({
4499
+ type: "secondary",
4500
+ disabled: _loading,
4501
+ onClick: onSecondaryButtonClick
4502
+ }, {
4503
+ children: _secondaryLabel
4504
+ })), jsx(Button, Object.assign({
4505
+ onClick: onPrimaryButtonClick,
4506
+ disabled: _loading
4507
+ }, {
4508
+ children: _primaryLabel
4509
+ }))]
4510
+ });
4511
+ };
4512
+
4513
+ const PageFormActions = ({
4514
+ formRef
4515
+ }) => {
4516
+ const {
4517
+ onError
4518
+ } = useProviderState();
4519
+ const {
4520
+ closeForm,
4521
+ loading,
4522
+ canAdd,
4523
+ canUpdate,
4524
+ t
4525
+ } = usePageState();
4526
+
4527
+ const onSubmitClick = e => {
4528
+ var _a;
4529
+
4530
+ if (!formRef) {
4531
+ return onError(CALLBACK_CODES.INTERNAL, 'error', `formRef is required to submit the form!`);
4532
+ } else if (!formRef.current) {
4533
+ return onError(CALLBACK_CODES.INTERNAL, 'error', `formRef is empty, make sure it's passed as 'ref' prop to the form!`);
4534
+ } // formRef is provided
4535
+
4536
+
4537
+ e === null || e === void 0 ? void 0 : e.preventDefault();
4538
+ (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new Event('submit', {
4539
+ cancelable: true,
4540
+ bubbles: true
4541
+ }));
4542
+ };
4543
+
4544
+ if (!canAdd && !canUpdate) return null;
4545
+ return jsx(FormActions, {
4546
+ loading: loading,
4547
+ primaryLabel: t('saveButtonText'),
4548
+ onPrimaryButtonClick: onSubmitClick,
4549
+ onSecondaryButtonClick: closeForm,
4550
+ secondaryLabel: t('cancelButtonText')
4551
+ });
4552
+ };
4553
+
4402
4554
  const PageFormWrapper = ({
4403
4555
  children
4404
4556
  }) => {
@@ -4485,9 +4637,6 @@ const Page = ({
4485
4637
  })
4486
4638
  }, {
4487
4639
  children: jsx(PageForm, {
4488
- open: formState === 'ADD' || formState === 'UPDATE',
4489
- onClose: onCloseForm,
4490
- formState: formState,
4491
4640
  formRef: formRef
4492
4641
  })
4493
4642
  })), itemData && jsx(DeleteModal, {
@@ -4804,28 +4953,33 @@ const useWidget = ({
4804
4953
 
4805
4954
 
4806
4955
  const onWidgetFormSubmit = data => __awaiter(void 0, void 0, void 0, function* () {
4807
- setLoading(true);
4808
- const code = formState === 'ADD' ? CALLBACK_CODES.CREATE : CALLBACK_CODES.UPDATE;
4809
- const api = getApiType({
4810
- routes,
4811
- action: formState === 'ADD' ? 'CREATE' : 'UPDATE',
4812
- prefix: widgetRoutesPrefix,
4813
- id: itemData === null || itemData === void 0 ? void 0 : itemData['_id']
4814
- });
4815
- const response = yield commonApi({
4816
- baseUrl,
4817
- token,
4818
- data,
4819
- url: api.url,
4820
- method: api.method,
4821
- onError: handleError(code)
4822
- });
4956
+ try {
4957
+ setLoading(true);
4958
+ const code = formState === 'ADD' ? CALLBACK_CODES.CREATE : CALLBACK_CODES.UPDATE;
4959
+ const api = getApiType({
4960
+ routes,
4961
+ action: formState === 'ADD' ? 'CREATE' : 'UPDATE',
4962
+ prefix: widgetRoutesPrefix,
4963
+ id: itemData === null || itemData === void 0 ? void 0 : itemData['_id']
4964
+ });
4965
+ const response = yield commonApi({
4966
+ baseUrl,
4967
+ token,
4968
+ data,
4969
+ url: api.url,
4970
+ method: api.method,
4971
+ onError: handleError(code)
4972
+ });
4823
4973
 
4824
- if ((response === null || response === void 0 ? void 0 : response.code) === 'SUCCESS') {
4974
+ if ((response === null || response === void 0 ? void 0 : response.code) === 'SUCCESS') {
4975
+ setLoading(false);
4976
+ onSuccess(code, response === null || response === void 0 ? void 0 : response.code, response === null || response === void 0 ? void 0 : response.message);
4977
+ getWidgets();
4978
+ onCloseForm();
4979
+ }
4980
+ } catch (error) {
4825
4981
  setLoading(false);
4826
- onSuccess(code, response === null || response === void 0 ? void 0 : response.code, response === null || response === void 0 ? void 0 : response.message);
4827
- getWidgets();
4828
- onCloseForm();
4982
+ onError(CALLBACK_CODES.UPDATE, INTERNAL_ERROR_CODE, error.message);
4829
4983
  }
4830
4984
  });
4831
4985
 
@@ -6608,9 +6762,20 @@ const TileItemsAccordian = ({
6608
6762
  };
6609
6763
 
6610
6764
  const WidgetForm = ({
6611
- formState,
6612
6765
  formRef
6613
6766
  }) => {
6767
+ const {
6768
+ register,
6769
+ formState: {
6770
+ errors
6771
+ },
6772
+ handleSubmit,
6773
+ reset,
6774
+ setValue,
6775
+ control,
6776
+ watch,
6777
+ setError
6778
+ } = useForm();
6614
6779
  const {
6615
6780
  baseUrl,
6616
6781
  switchClass
@@ -6621,6 +6786,7 @@ const WidgetForm = ({
6621
6786
  canAdd,
6622
6787
  canUpdate,
6623
6788
  tilesList,
6789
+ formState,
6624
6790
  widgetTypes,
6625
6791
  selectionTypes,
6626
6792
  onTileFormSubmit,
@@ -6680,6 +6846,11 @@ const WidgetForm = ({
6680
6846
  setTilesEnabled(true);
6681
6847
  }
6682
6848
  }, [formState]);
6849
+ useEffect(() => {
6850
+ if (!isEmpty(data)) {
6851
+ reset(data);
6852
+ }
6853
+ }, [data, reset]);
6683
6854
 
6684
6855
  const onChangeSearch = str => {
6685
6856
  if (callerRef.current) clearTimeout(callerRef.current);
@@ -6744,8 +6915,14 @@ const WidgetForm = ({
6744
6915
  return temporaryData;
6745
6916
  });
6746
6917
  }
6747
- }; // Schemas
6918
+ };
6748
6919
 
6920
+ useEffect(() => {
6921
+ const subscription = watch((value, {
6922
+ name
6923
+ }) => onWidgetFormInputChange(value, name));
6924
+ return () => subscription.unsubscribe();
6925
+ }, [watch, onWidgetFormInputChange]); // Schemas
6749
6926
 
6750
6927
  const widgetFormSchema = [{
6751
6928
  label: `${t('widget.name')}`,
@@ -6908,17 +7085,22 @@ const WidgetForm = ({
6908
7085
  return jsxs("div", Object.assign({
6909
7086
  className: "khb_form"
6910
7087
  }, {
6911
- children: [jsx(Form, {
7088
+ children: [jsx(SimpleForm, {
6912
7089
  schema: widgetFormSchema,
6913
7090
  onSubmit: onFormSubmit,
6914
7091
  ref: formRef,
6915
- data: data,
6916
7092
  isUpdating: formState === 'UPDATE',
6917
- watcher: onWidgetFormInputChange
7093
+ register: register,
7094
+ errors: errors,
7095
+ handleSubmit: handleSubmit,
7096
+ setValue: setValue,
7097
+ control: control,
7098
+ setError: setError
6918
7099
  }), !tilesEnabled && jsx(DNDItemsList, {
6919
7100
  items: selectedCollectionItems,
6920
7101
  onDragEnd: onCollectionIndexChange,
6921
- formatItem: formatListItem
7102
+ formatItem: formatListItem,
7103
+ listCode: selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value
6922
7104
  }), tilesEnabled && jsx(Fragment, {
6923
7105
  children: jsx(TileItemsAccordian, {
6924
7106
  collapseId: "imageItems",
@@ -7157,9 +7339,6 @@ const Widget = ({
7157
7339
  })
7158
7340
  }, {
7159
7341
  children: jsx(WidgetForm, {
7160
- open: formState === 'ADD' || formState === 'UPDATE',
7161
- onClose: onCloseForm,
7162
- formState: formState,
7163
7342
  formRef: widgetFormRef
7164
7343
  })
7165
7344
  })), itemData && jsx(DeleteModal, {
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { FormProps } from '../../../types';
3
- declare const PageForm: ({ onClose, open, formState, formRef }: FormProps) => JSX.Element | null;
3
+ declare const PageForm: ({ formRef }: FormProps) => JSX.Element | null;
4
4
  export default PageForm;
@@ -4,7 +4,7 @@ declare const Page: {
4
4
  ({ t, loader, explicitForm, children, permissions, }: PageProps): JSX.Element;
5
5
  Table: () => JSX.Element | null;
6
6
  Search: () => JSX.Element;
7
- Form: ({ onClose, open, formState, formRef }: import("../../../types").FormProps) => JSX.Element | null;
7
+ Form: ({ formRef }: import("../../../types").FormProps) => JSX.Element | null;
8
8
  AddButton: () => JSX.Element;
9
9
  Pagination: () => JSX.Element;
10
10
  FormActions: ({ formRef }: import("../../../types").FormActionWrapperProps) => JSX.Element | null;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { FormProps } from '../../../types';
3
- declare const WidgetForm: ({ formState, formRef }: FormProps) => JSX.Element | null;
3
+ declare const WidgetForm: ({ formRef }: FormProps) => JSX.Element | null;
4
4
  export default WidgetForm;
@@ -3,7 +3,7 @@ import { WidgetProps } from '../../../types';
3
3
  declare const Widget: {
4
4
  ({ t, routes, loader, explicitForm, permissions, preConfirmDelete, formatListItem, formatOptionLabel, children, }: WidgetProps): JSX.Element;
5
5
  Table: () => JSX.Element | null;
6
- Form: ({ formState, formRef }: import("../../../types").FormProps) => JSX.Element | null;
6
+ Form: ({ formRef }: import("../../../types").FormProps) => JSX.Element | null;
7
7
  AddButton: () => JSX.Element;
8
8
  Search: () => JSX.Element;
9
9
  Pagination: () => JSX.Element;
@@ -0,0 +1,17 @@
1
+ import React, { MutableRefObject } from 'react';
2
+ import { CombineObjectType, SchemaType } from '../../../types';
3
+ interface SimpleFormProps {
4
+ schema: SchemaType[];
5
+ isUpdating?: boolean;
6
+ onSubmit: (data: CombineObjectType) => void;
7
+ enable?: boolean;
8
+ ref: MutableRefObject<HTMLFormElement | null>;
9
+ register: any;
10
+ errors: any;
11
+ handleSubmit: any;
12
+ setValue: any;
13
+ control: any;
14
+ setError: any;
15
+ }
16
+ declare const SimpleForm: React.ForwardRefExoticComponent<Pick<SimpleFormProps, "schema" | "onSubmit" | "isUpdating" | "enable" | "register" | "errors" | "handleSubmit" | "setValue" | "control" | "setError"> & React.RefAttributes<HTMLFormElement | null>>;
17
+ export default SimpleForm;
@@ -1,2 +1,4 @@
1
1
  import Form from "./Form";
2
+ import SimpleForm from "./SimpleForm";
2
3
  export default Form;
4
+ export { SimpleForm };
@@ -125,9 +125,6 @@ export interface SchemaType extends ReactSelectProps {
125
125
  wrapperClassName?: string;
126
126
  }
127
127
  export interface FormProps {
128
- open: boolean;
129
- onClose: () => void;
130
- formState: FormActionTypes | undefined;
131
128
  formRef: MutableRefObject<HTMLFormElement | null>;
132
129
  }
133
130
  export interface InputRendererProps {
@@ -176,7 +173,6 @@ export interface SchemaType extends ReactSelectProps {
176
173
  label: string;
177
174
  }[];
178
175
  isMulti?: boolean;
179
- defaultValue?: string | number | boolean;
180
176
  placeholder?: string;
181
177
  required?: boolean;
182
178
  onChange?: (e: any) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knovator/pagecreator-admin",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "dependencies": {
5
5
  "classnames": "^2.3.1",
6
6
  "react-beautiful-dnd": "^13.1.0",