@knovator/pagecreator-admin 1.2.2 → 1.2.3

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 (166) hide show
  1. package/README.md +205 -205
  2. package/index.d.ts +1 -0
  3. package/package.json +38 -42
  4. package/src/{index.d.ts → index.ts} +1 -0
  5. package/src/lib/api/index.ts +70 -0
  6. package/src/lib/api/list.ts +59 -0
  7. package/src/lib/components/Page/AddButton/AddButton.tsx +16 -0
  8. package/src/lib/components/Page/AddButton/{index.d.ts → index.ts} +1 -0
  9. package/src/lib/components/Page/Form/PageForm.tsx +194 -0
  10. package/src/lib/components/Page/Form/{index.d.ts → index.ts} +1 -0
  11. package/src/lib/components/Page/Page/Page.tsx +151 -0
  12. package/src/lib/components/Page/Page/{index.d.ts → index.ts} +1 -0
  13. package/src/lib/components/Page/PageFormActions/PageFormActions.tsx +50 -0
  14. package/src/lib/components/Page/PageFormActions/{index.d.ts → index.ts} +1 -0
  15. package/src/lib/components/Page/PageFormWrapper/PageFormWrapper.tsx +16 -0
  16. package/src/lib/components/Page/PageFormWrapper/{index.d.ts → index.ts} +1 -0
  17. package/src/lib/components/Page/Pagination/PagePagination.tsx +26 -0
  18. package/src/lib/components/Page/Pagination/{index.d.ts → index.ts} +1 -0
  19. package/src/lib/components/Page/Search/PageSearch.tsx +32 -0
  20. package/src/lib/components/Page/Search/{index.d.ts → index.tsx} +1 -0
  21. package/src/lib/components/Page/Table/PageTable.tsx +36 -0
  22. package/src/lib/components/Page/Table/{index.d.ts → index.ts} +1 -0
  23. package/src/lib/components/Page/{index.d.ts → index.ts} +1 -0
  24. package/src/lib/components/Widget/AddButton/AddButton.tsx +16 -0
  25. package/src/lib/components/Widget/AddButton/{index.d.ts → index.ts} +1 -0
  26. package/src/lib/components/Widget/Form/ItemsAccordian.tsx +354 -0
  27. package/src/lib/components/Widget/Form/Tabs/TabItem.tsx +43 -0
  28. package/src/lib/components/Widget/Form/Tabs/Tabs.tsx +190 -0
  29. package/src/lib/components/Widget/Form/Tabs/{index.d.ts → index.ts} +1 -0
  30. package/src/lib/components/Widget/Form/WidgetForm.tsx +771 -0
  31. package/src/lib/components/Widget/Form/{index.d.ts → index.ts} +1 -0
  32. package/src/lib/components/Widget/Pagination/WidgetPagination.tsx +26 -0
  33. package/src/lib/components/Widget/Pagination/{index.d.ts → index.ts} +1 -0
  34. package/src/lib/components/Widget/Search/WidgetSearch.tsx +32 -0
  35. package/src/lib/components/Widget/Search/{index.d.ts → index.tsx} +1 -0
  36. package/src/lib/components/Widget/Table/WidgetTable.tsx +70 -0
  37. package/src/lib/components/Widget/Table/{index.d.ts → index.ts} +1 -0
  38. package/src/lib/components/Widget/Widget/Widget.tsx +173 -0
  39. package/src/lib/components/Widget/Widget/{index.d.ts → index.ts} +1 -0
  40. package/src/lib/components/Widget/WidgetFormActions/WidgetFormActions.tsx +50 -0
  41. package/src/lib/components/Widget/WidgetFormActions/{index.d.ts → index.ts} +1 -0
  42. package/src/lib/components/Widget/WidgetFormWrapper/WidgetFormWrapper.tsx +16 -0
  43. package/src/lib/components/Widget/WidgetFormWrapper/{index.d.ts → index.ts} +1 -0
  44. package/src/lib/components/Widget/{index.d.ts → index.tsx} +1 -0
  45. package/src/lib/components/common/Accordian/Accordian.tsx +56 -0
  46. package/src/lib/components/common/Accordian/{index.d.ts → index.ts} +1 -0
  47. package/src/lib/components/common/Button/Button.tsx +45 -0
  48. package/src/lib/components/common/Button/{index.d.ts → index.ts} +1 -0
  49. package/src/lib/components/common/ConfirmPopover/ConfirmPopover.tsx +47 -0
  50. package/src/lib/components/common/ConfirmPopover/{index.d.ts → index.ts} +1 -0
  51. package/src/lib/components/common/DNDItemsList/DNDItemsList.tsx +53 -0
  52. package/src/lib/components/common/DNDItemsList/{index.d.ts → index.ts} +1 -0
  53. package/src/lib/components/common/DeleteModal/DeleteModal.tsx +72 -0
  54. package/src/lib/components/common/DeleteModal/index.tsx +3 -0
  55. package/src/lib/components/common/Drawer/Drawer.tsx +79 -0
  56. package/src/lib/components/common/Drawer/{index.d.ts → index.ts} +1 -0
  57. package/src/lib/components/common/Form/Form.tsx +256 -0
  58. package/src/lib/components/common/Form/SimpleForm.tsx +314 -0
  59. package/src/lib/components/common/Form/{index.d.ts → index.ts} +1 -0
  60. package/src/lib/components/common/FormActions/FormActions.tsx +37 -0
  61. package/src/lib/components/common/FormActions/{index.d.ts → index.ts} +1 -0
  62. package/src/lib/components/common/ImageUpload/ImageUpload.tsx +113 -0
  63. package/src/lib/components/common/ImageUpload/index.tsx +3 -0
  64. package/src/lib/components/common/Input/Checkbox.tsx +25 -0
  65. package/src/lib/components/common/Input/Input.tsx +51 -0
  66. package/src/lib/components/common/Input/ReactSelect.tsx +60 -0
  67. package/src/lib/components/common/Input/Select.tsx +47 -0
  68. package/src/lib/components/common/Input/SrcSet.tsx +143 -0
  69. package/src/lib/components/common/Input/index.ts +20 -0
  70. package/src/lib/components/common/Modal/Modal.tsx +57 -0
  71. package/src/lib/components/common/Modal/index.tsx +3 -0
  72. package/src/lib/components/common/Pagination/Pagination.tsx +88 -0
  73. package/src/lib/components/common/Pagination/{index.d.ts → index.ts} +1 -0
  74. package/src/lib/components/common/Table/Table.tsx +133 -0
  75. package/src/lib/components/common/Table/{index.d.ts → index.ts} +1 -0
  76. package/src/lib/components/common/Toggle/Toggle.tsx +23 -0
  77. package/src/lib/components/common/Toggle/{index.d.ts → index.ts} +1 -0
  78. package/src/lib/constants/common.ts +145 -0
  79. package/src/lib/context/PageContext.tsx +100 -0
  80. package/src/lib/context/ProviderContext.tsx +52 -0
  81. package/src/lib/context/WidgetContext.tsx +127 -0
  82. package/src/lib/helper/utils.ts +46 -0
  83. package/src/lib/hooks/usePage.tsx +307 -0
  84. package/src/lib/hooks/usePagination.tsx +41 -0
  85. package/src/lib/hooks/useWidget.tsx +503 -0
  86. package/src/lib/icons/chevronDown.tsx +21 -0
  87. package/src/lib/icons/chevronLeft.tsx +20 -0
  88. package/src/lib/icons/chevronRight.tsx +20 -0
  89. package/src/lib/icons/chevronUp.tsx +21 -0
  90. package/src/lib/icons/close.tsx +21 -0
  91. package/src/lib/icons/pencil.tsx +21 -0
  92. package/src/lib/icons/plus.tsx +23 -0
  93. package/src/lib/icons/trash.tsx +21 -0
  94. package/src/lib/types/api.ts +44 -0
  95. package/src/lib/types/common.ts +31 -0
  96. package/src/lib/types/components.ts +427 -0
  97. package/src/lib/types/context.ts +184 -0
  98. package/src/styles/index.css +469 -0
  99. package/index.cjs +0 -7714
  100. package/index.css +0 -2258
  101. package/index.js +0 -7700
  102. package/src/lib/api/index.d.ts +0 -10
  103. package/src/lib/api/list.d.ts +0 -56
  104. package/src/lib/components/Page/AddButton/AddButton.d.ts +0 -3
  105. package/src/lib/components/Page/Form/PageForm.d.ts +0 -4
  106. package/src/lib/components/Page/Page/Page.d.ts +0 -13
  107. package/src/lib/components/Page/PageFormActions/PageFormActions.d.ts +0 -4
  108. package/src/lib/components/Page/PageFormWrapper/PageFormWrapper.d.ts +0 -4
  109. package/src/lib/components/Page/Pagination/PagePagination.d.ts +0 -3
  110. package/src/lib/components/Page/Search/PageSearch.d.ts +0 -3
  111. package/src/lib/components/Page/Table/PageTable.d.ts +0 -4
  112. package/src/lib/components/Widget/AddButton/AddButton.d.ts +0 -3
  113. package/src/lib/components/Widget/Form/ItemsAccordian.d.ts +0 -4
  114. package/src/lib/components/Widget/Form/Tabs/TabItem.d.ts +0 -4
  115. package/src/lib/components/Widget/Form/Tabs/Tabs.d.ts +0 -4
  116. package/src/lib/components/Widget/Form/WidgetForm.d.ts +0 -4
  117. package/src/lib/components/Widget/Pagination/WidgetPagination.d.ts +0 -3
  118. package/src/lib/components/Widget/Search/WidgetSearch.d.ts +0 -3
  119. package/src/lib/components/Widget/Table/WidgetTable.d.ts +0 -4
  120. package/src/lib/components/Widget/Widget/Widget.d.ts +0 -13
  121. package/src/lib/components/Widget/WidgetFormActions/WidgetFormActions.d.ts +0 -4
  122. package/src/lib/components/Widget/WidgetFormWrapper/WidgetFormWrapper.d.ts +0 -4
  123. package/src/lib/components/common/Accordian/Accordian.d.ts +0 -13
  124. package/src/lib/components/common/Button/Button.d.ts +0 -4
  125. package/src/lib/components/common/ConfirmPopover/ConfirmPopover.d.ts +0 -4
  126. package/src/lib/components/common/DNDItemsList/DNDItemsList.d.ts +0 -4
  127. package/src/lib/components/common/DeleteModal/DeleteModal.d.ts +0 -4
  128. package/src/lib/components/common/DeleteModal/index.d.ts +0 -2
  129. package/src/lib/components/common/Drawer/Drawer.d.ts +0 -9
  130. package/src/lib/components/common/Form/Form.d.ts +0 -15
  131. package/src/lib/components/common/Form/SimpleForm.d.ts +0 -18
  132. package/src/lib/components/common/FormActions/FormActions.d.ts +0 -10
  133. package/src/lib/components/common/ImageUpload/ImageUpload.d.ts +0 -4
  134. package/src/lib/components/common/ImageUpload/index.d.ts +0 -2
  135. package/src/lib/components/common/Input/Checkbox.d.ts +0 -4
  136. package/src/lib/components/common/Input/Input.d.ts +0 -4
  137. package/src/lib/components/common/Input/ReactSelect.d.ts +0 -4
  138. package/src/lib/components/common/Input/Select.d.ts +0 -4
  139. package/src/lib/components/common/Input/SrcSet.d.ts +0 -4
  140. package/src/lib/components/common/Input/index.d.ts +0 -12
  141. package/src/lib/components/common/Modal/Modal.d.ts +0 -8
  142. package/src/lib/components/common/Modal/index.d.ts +0 -2
  143. package/src/lib/components/common/Pagination/Pagination.d.ts +0 -4
  144. package/src/lib/components/common/Table/Table.d.ts +0 -4
  145. package/src/lib/components/common/Toggle/Toggle.d.ts +0 -4
  146. package/src/lib/constants/common.d.ts +0 -122
  147. package/src/lib/context/PageContext.d.ts +0 -7
  148. package/src/lib/context/ProviderContext.d.ts +0 -5
  149. package/src/lib/context/WidgetContext.d.ts +0 -7
  150. package/src/lib/helper/utils.d.ts +0 -10
  151. package/src/lib/hooks/usePage.d.ts +0 -43
  152. package/src/lib/hooks/usePagination.d.ts +0 -15
  153. package/src/lib/hooks/useWidget.d.ts +0 -46
  154. package/src/lib/icons/chevronDown.d.ts +0 -4
  155. package/src/lib/icons/chevronLeft.d.ts +0 -4
  156. package/src/lib/icons/chevronRight.d.ts +0 -4
  157. package/src/lib/icons/chevronUp.d.ts +0 -4
  158. package/src/lib/icons/close.d.ts +0 -4
  159. package/src/lib/icons/pencil.d.ts +0 -4
  160. package/src/lib/icons/plus.d.ts +0 -4
  161. package/src/lib/icons/trash.d.ts +0 -4
  162. package/src/lib/types/api.d.ts +0 -34
  163. package/src/lib/types/common.d.ts +0 -29
  164. package/src/lib/types/components.d.ts +0 -420
  165. package/src/lib/types/context.d.ts +0 -135
  166. /package/src/lib/types/{index.d.ts → index.ts} +0 -0
package/README.md CHANGED
@@ -1,206 +1,206 @@
1
- <a name="readme-top"></a>
2
-
3
- [![Contributors][contributors-shield]][contributors-url]
4
- [![Forks][forks-shield]][forks-url]
5
- [![Stargazers][stars-shield]][stars-url]
6
- [![Issues][issues-shield]][issues-url]
7
-
8
-
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
- Create one reactjs/nextjs application if you don't have one,
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
- 1. Add pagecreator package
108
- ```sh
109
- npm install @knovator/pagecreator-admin
110
- # or
111
- yarn add @knovator/pagecreator-admin
112
- ```
113
-
114
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
115
-
116
-
117
-
118
- <!-- USAGE EXAMPLES -->
119
- ## Usage
120
-
121
- ### Provider
122
-
123
- In order to support communication between components `@knovator/pagecreator-admin` uses **Context API**. So, `Widget`/`Page` components should be wrapped by Provider.
124
- ```jsx
125
- import { Provider } from '@knovator/pagecreator-admin';
126
-
127
- <Provider
128
- ...
129
- >
130
- ...
131
- </Provider>
132
- ```
133
- **Props**
134
- - `token`
135
- - JWT token to be sent along the requests
136
- - `baseUrl`
137
- - Base API url, without forward slash at end i.e. `https://api.xyz.in`
138
- - `onError(callback_code, code, message) (optional)`
139
- - callback to execute on error
140
- - `onSuccess(callback_code, code, message) (optional)`
141
- - callback to execute on success
142
- - `onLogout (optional)`
143
- - callback to execute on API request with unauthorized code in body
144
- - `switchClass`
145
- - `class` name to apply to `Toggle` component, default is `khb_switch`
146
- - `widgetRoutesPrefix`
147
- - Prefix to apply after `baseUrl` while calling `widget` API
148
- - `itemsRoutesPrefix`
149
- - Prefix to apply after `baseUrl` while calling `items` API
150
- - `pageRoutesPrefix`
151
- - Prefix to apply after `baseUrl` while calling `page` API
152
-
153
- ### [Widget](widget.md)
154
- ### [Page](page.md)
155
-
156
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
157
-
158
-
159
- <!-- CONTRIBUTING -->
160
- ## Contributing
161
-
162
- Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
163
-
164
- 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".
165
- Don't forget to give the project a star! Thanks again!
166
-
167
- 1. Fork the Project
168
- 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
169
- 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
170
- 4. Push to the Branch (`git push origin feature/AmazingFeature`)
171
- 5. Open a Pull Request
172
-
173
- <p align="right">(<a href="#top">back to top</a>)</p>
174
-
175
-
176
-
177
- <!-- LICENSE -->
178
- ## License
179
-
180
- Distributed under the MIT License. See `LICENSE.txt` for more information.
181
-
182
- <p align="right">(<a href="#top">back to top</a>)</p>
183
-
184
-
185
- <!-- CONTACT -->
186
- ## Contact
187
-
188
- Knovator Technologies
189
- - Twitter [@knovator](https://twitter.com/knovator)
190
- - Web [https://knovator.com/](https://knovator.com/)
191
-
192
- Project Link: [https://github.com/knovator/masters-admin](https://github.com/knovator/masters-admin)
193
-
194
- <p align="right">(<a href="#top">back to top</a>)</p>
195
-
196
- <!-- MARKDOWN LINKS & IMAGES -->
197
- <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
198
- [contributors-shield]: https://img.shields.io/github/contributors/knovator/pagecreator.svg?style=for-the-badge
199
- [contributors-url]: https://github.com/knovator/pagecreator/graphs/contributors
200
- [forks-shield]: https://img.shields.io/github/forks/knovator/pagecreator.svg?style=for-the-badge
201
- [forks-url]: https://github.com/knovator/pagecreator/network/members
202
- [stars-shield]: https://img.shields.io/github/stars/knovator/pagecreator.svg?style=for-the-badge
203
- [stars-url]: https://github.com/knovator/pagecreator/stargazers
204
- [issues-shield]: https://img.shields.io/github/issues/knovator/pagecreator.svg?style=for-the-badge
205
- [issues-url]: https://github.com/knovator/pagecreator/issues
1
+ <a name="readme-top"></a>
2
+
3
+ [![Contributors][contributors-shield]][contributors-url]
4
+ [![Forks][forks-shield]][forks-url]
5
+ [![Stargazers][stars-shield]][stars-url]
6
+ [![Issues][issues-shield]][issues-url]
7
+
8
+
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
+ Create one reactjs/nextjs application if you don't have one,
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
+ 1. Add pagecreator package
108
+ ```sh
109
+ npm install @knovator/pagecreator-admin
110
+ # or
111
+ yarn add @knovator/pagecreator-admin
112
+ ```
113
+
114
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
115
+
116
+
117
+
118
+ <!-- USAGE EXAMPLES -->
119
+ ## Usage
120
+
121
+ ### Provider
122
+
123
+ In order to support communication between components `@knovator/pagecreator-admin` uses **Context API**. So, `Widget`/`Page` components should be wrapped by Provider.
124
+ ```jsx
125
+ import { Provider } from '@knovator/pagecreator-admin';
126
+
127
+ <Provider
128
+ ...
129
+ >
130
+ ...
131
+ </Provider>
132
+ ```
133
+ **Props**
134
+ - `token`
135
+ - JWT token to be sent along the requests
136
+ - `baseUrl`
137
+ - Base API url, without forward slash at end i.e. `https://api.xyz.in`
138
+ - `onError(callback_code, code, message) (optional)`
139
+ - callback to execute on error
140
+ - `onSuccess(callback_code, code, message) (optional)`
141
+ - callback to execute on success
142
+ - `onLogout (optional)`
143
+ - callback to execute on API request with unauthorized code in body
144
+ - `switchClass`
145
+ - `class` name to apply to `Toggle` component, default is `khb_switch`
146
+ - `widgetRoutesPrefix`
147
+ - Prefix to apply after `baseUrl` while calling `widget` API
148
+ - `itemsRoutesPrefix`
149
+ - Prefix to apply after `baseUrl` while calling `items` API
150
+ - `pageRoutesPrefix`
151
+ - Prefix to apply after `baseUrl` while calling `page` API
152
+
153
+ ### [Widget](widget.md)
154
+ ### [Page](page.md)
155
+
156
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
157
+
158
+
159
+ <!-- CONTRIBUTING -->
160
+ ## Contributing
161
+
162
+ Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
163
+
164
+ 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".
165
+ Don't forget to give the project a star! Thanks again!
166
+
167
+ 1. Fork the Project
168
+ 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
169
+ 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
170
+ 4. Push to the Branch (`git push origin feature/AmazingFeature`)
171
+ 5. Open a Pull Request
172
+
173
+ <p align="right">(<a href="#top">back to top</a>)</p>
174
+
175
+
176
+
177
+ <!-- LICENSE -->
178
+ ## License
179
+
180
+ Distributed under the MIT License. See `LICENSE.txt` for more information.
181
+
182
+ <p align="right">(<a href="#top">back to top</a>)</p>
183
+
184
+
185
+ <!-- CONTACT -->
186
+ ## Contact
187
+
188
+ Knovator Technologies
189
+ - Twitter [@knovator](https://twitter.com/knovator)
190
+ - Web [https://knovator.com/](https://knovator.com/)
191
+
192
+ Project Link: [https://github.com/knovator/masters-admin](https://github.com/knovator/masters-admin)
193
+
194
+ <p align="right">(<a href="#top">back to top</a>)</p>
195
+
196
+ <!-- MARKDOWN LINKS & IMAGES -->
197
+ <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
198
+ [contributors-shield]: https://img.shields.io/github/contributors/knovator/pagecreator.svg?style=for-the-badge
199
+ [contributors-url]: https://github.com/knovator/pagecreator/graphs/contributors
200
+ [forks-shield]: https://img.shields.io/github/forks/knovator/pagecreator.svg?style=for-the-badge
201
+ [forks-url]: https://github.com/knovator/pagecreator/network/members
202
+ [stars-shield]: https://img.shields.io/github/stars/knovator/pagecreator.svg?style=for-the-badge
203
+ [stars-url]: https://github.com/knovator/pagecreator/stargazers
204
+ [issues-shield]: https://img.shields.io/github/issues/knovator/pagecreator.svg?style=for-the-badge
205
+ [issues-url]: https://github.com/knovator/pagecreator/issues
206
206
  [product-screenshot]: images/screenshot.png
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ declare module '@knovator/api';
package/package.json CHANGED
@@ -1,42 +1,38 @@
1
- {
2
- "name": "@knovator/pagecreator-admin",
3
- "version": "1.2.2",
4
- "dependencies": {
5
- "classnames": "^2.3.1",
6
- "react-beautiful-dnd": "^13.1.0",
7
- "react-transition-group": "^4.4.5",
8
- "react-hook-form": "^7.34.2",
9
- "react-dropzone": "^14.2.2",
10
- "react-select": "^5.4.0",
11
- "react-tabs": "^6.0.0",
12
- "react-tiny-popover": "^7.2.0"
13
- },
14
- "peerDependencies": {
15
- "react": "^18 | ^17",
16
- "@knovator/api": "^0.0.10"
17
- },
18
- "repository": {
19
- "type": "git",
20
- "url": "git@github.com:knovator/pagecreator.git"
21
- },
22
- "keywords": [
23
- "pagecreator",
24
- "pagebuilder",
25
- "knovator",
26
- "chavda-bhavik"
27
- ],
28
- "author": "knovator (https://knovator.com/)",
29
- "files": [
30
- "src",
31
- "package.json",
32
- "README.md",
33
- "index.css",
34
- "index.d.ts",
35
- "index.js",
36
- "index.cjs"
37
- ],
38
- "module": "./index.js",
39
- "main": "./index.cjs",
40
- "type": "module",
41
- "types": "./src/index.d.ts"
42
- }
1
+ {
2
+ "name": "@knovator/pagecreator-admin",
3
+ "version":"1.2.3",
4
+ "dependencies": {
5
+ "classnames": "^2.3.1",
6
+ "react-beautiful-dnd": "^13.1.0",
7
+ "react-transition-group": "^4.4.5",
8
+ "react-hook-form": "^7.34.2",
9
+ "react-dropzone": "^14.2.2",
10
+ "react-select": "^5.4.0",
11
+ "react-tabs": "^6.0.0",
12
+ "react-tiny-popover": "^7.2.0"
13
+ },
14
+ "peerDependencies": {
15
+ "react": "^18 | ^17",
16
+ "@knovator/api": "^0.0.10"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git@github.com:knovator/pagecreator.git"
21
+ },
22
+ "keywords": [
23
+ "pagecreator",
24
+ "pagebuilder",
25
+ "knovator",
26
+ "chavda-bhavik"
27
+ ],
28
+ "author": "knovator (https://knovator.com/)",
29
+ "files": [
30
+ "src",
31
+ "package.json",
32
+ "README.md",
33
+ "index.css",
34
+ "index.d.ts",
35
+ "index.js",
36
+ "index.cjs"
37
+ ]
38
+ }
@@ -2,4 +2,5 @@ import './styles/index.css';
2
2
  import { Page } from './lib/components/Page';
3
3
  import { Widget } from './lib/components/Widget';
4
4
  import Provider from './lib/context/ProviderContext';
5
+
5
6
  export { Widget, Provider, Page };
@@ -0,0 +1,70 @@
1
+ import fetchUrl, { setAPIConfig } from '@knovator/api';
2
+ import apiList from './list';
3
+ import {
4
+ ACTION_TYPES,
5
+ API_TYPE,
6
+ BaseAPIProps,
7
+ Routes_Input,
8
+ ResponseType,
9
+ } from '../types';
10
+
11
+ const handleError = (error: Error) => {
12
+ console.log(error);
13
+ };
14
+
15
+ const commonApi = async ({
16
+ data,
17
+ config,
18
+
19
+ baseUrl,
20
+ token,
21
+
22
+ url,
23
+ method,
24
+
25
+ onError = handleError,
26
+ }: BaseAPIProps): Promise<ResponseType> => {
27
+ let apiToken = token;
28
+ if (typeof token === 'function') {
29
+ apiToken = await token();
30
+ }
31
+ setAPIConfig({
32
+ baseUrl,
33
+ tokenPrefix: 'jwt',
34
+ getToken: apiToken,
35
+ onError,
36
+ });
37
+ const response: ResponseType = (await fetchUrl({
38
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
39
+ // @ts-ignore
40
+ type: method,
41
+ url,
42
+ data,
43
+ config,
44
+ })) as ResponseType;
45
+ return response;
46
+ };
47
+
48
+ const getApiType = ({
49
+ routes,
50
+ action,
51
+ prefix,
52
+ id,
53
+ }: {
54
+ routes?: Routes_Input;
55
+ action: ACTION_TYPES;
56
+ prefix: string;
57
+ id?: string;
58
+ }): API_TYPE => {
59
+ let route: API_TYPE;
60
+ if (routes && typeof routes[action] === 'function') {
61
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
62
+ route = routes[action]!({ prefix, id });
63
+ } else {
64
+ route = apiList[action]({ prefix, id });
65
+ }
66
+ return route;
67
+ };
68
+
69
+ export default commonApi;
70
+ export { getApiType };
@@ -0,0 +1,59 @@
1
+ import { API_INPUT_TYPE } from '../types';
2
+
3
+ const apiList = {
4
+ GET_ONE: ({ prefix, id }: API_INPUT_TYPE) => ({
5
+ url: `${prefix}/${id}`,
6
+ method: 'GET',
7
+ }),
8
+ LIST: ({ prefix }: API_INPUT_TYPE) => ({
9
+ url: `${prefix}/list`,
10
+ method: 'POST',
11
+ }),
12
+ CREATE: ({ prefix }: API_INPUT_TYPE) => ({
13
+ url: `${prefix}`,
14
+ method: 'POST',
15
+ }),
16
+ UPDATE: ({ prefix, id }: API_INPUT_TYPE) => ({
17
+ url: `${prefix}/${id}`,
18
+ method: 'PUT',
19
+ }),
20
+ PARTIAL_UPDATE: ({ prefix, id }: API_INPUT_TYPE) => ({
21
+ url: `${prefix}/${id}`,
22
+ method: 'PATCH',
23
+ }),
24
+ DELETE: ({ prefix, id }: API_INPUT_TYPE) => ({
25
+ url: `${prefix}/${id}`,
26
+ method: 'DELETE',
27
+ }),
28
+ WIDGET_TYPES: ({ prefix }: API_INPUT_TYPE) => ({
29
+ url: `${prefix}/widget-types`,
30
+ method: 'GET',
31
+ }),
32
+ SELECTION_TYPES: ({ prefix }: API_INPUT_TYPE) => ({
33
+ url: `${prefix}/selection-types`,
34
+ method: 'GET',
35
+ }),
36
+ ITEM: ({ prefix, id }: API_INPUT_TYPE) => ({
37
+ url: `${prefix}/${id}`,
38
+ method: 'GET',
39
+ }),
40
+ COLLECTION_DATA: ({ prefix }: API_INPUT_TYPE) => ({
41
+ url: `${prefix}/collection-data`,
42
+ method: 'POST',
43
+ }),
44
+ LANGUAGES: ({ prefix }: API_INPUT_TYPE) => ({
45
+ url: `${prefix}/languages`,
46
+ method: 'GET',
47
+ }),
48
+ // Image Upload API
49
+ IMAGE_UPLOAD: ({ prefix }: API_INPUT_TYPE) => ({
50
+ url: `${prefix}/upload`,
51
+ method: 'post',
52
+ }),
53
+ IMAGE_REMOVE: ({ prefix, id }: API_INPUT_TYPE) => ({
54
+ url: `${prefix}/${id}/delete`,
55
+ method: 'DELETE',
56
+ }),
57
+ };
58
+
59
+ export default apiList;
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import Button from "../../common/Button";
3
+ import { usePageState } from "../../../context/PageContext";
4
+ import { useProviderState } from '../../../context/ProviderContext';
5
+
6
+ const AddButton = () => {
7
+ const { commonTranslations } = useProviderState();
8
+ const { onChangeFormState, canAdd } = usePageState();
9
+ return (
10
+ <Button disabled={!canAdd} onClick={() => onChangeFormState('ADD')}>
11
+ {commonTranslations.add}
12
+ </Button>
13
+ );
14
+ };
15
+
16
+ export default AddButton;
@@ -1,2 +1,3 @@
1
1
  import AddButton from "./AddButton";
2
+
2
3
  export default AddButton;