@knovator/pagecreator-admin 1.2.4 → 1.2.6

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 (165) hide show
  1. package/index.cjs +7714 -0
  2. package/index.css +2 -0
  3. package/index.js +7700 -0
  4. package/package.json +42 -38
  5. package/src/{index.ts → index.d.ts} +0 -1
  6. package/src/lib/api/index.d.ts +10 -0
  7. package/src/lib/api/list.d.ts +56 -0
  8. package/src/lib/components/Page/AddButton/AddButton.d.ts +3 -0
  9. package/src/lib/components/Page/AddButton/{index.ts → index.d.ts} +0 -1
  10. package/src/lib/components/Page/Form/PageForm.d.ts +4 -0
  11. package/src/lib/components/Page/Form/{index.ts → index.d.ts} +0 -1
  12. package/src/lib/components/Page/Page/Page.d.ts +13 -0
  13. package/src/lib/components/Page/Page/{index.ts → index.d.ts} +0 -1
  14. package/src/lib/components/Page/PageFormActions/PageFormActions.d.ts +4 -0
  15. package/src/lib/components/Page/PageFormActions/{index.ts → index.d.ts} +0 -1
  16. package/src/lib/components/Page/PageFormWrapper/PageFormWrapper.d.ts +4 -0
  17. package/src/lib/components/Page/PageFormWrapper/{index.ts → index.d.ts} +0 -1
  18. package/src/lib/components/Page/Pagination/PagePagination.d.ts +3 -0
  19. package/src/lib/components/Page/Pagination/{index.ts → index.d.ts} +0 -1
  20. package/src/lib/components/Page/Search/PageSearch.d.ts +3 -0
  21. package/src/lib/components/Page/Search/{index.tsx → index.d.ts} +0 -1
  22. package/src/lib/components/Page/Table/PageTable.d.ts +4 -0
  23. package/src/lib/components/Page/Table/{index.ts → index.d.ts} +0 -1
  24. package/src/lib/components/Page/{index.ts → index.d.ts} +0 -1
  25. package/src/lib/components/Widget/AddButton/AddButton.d.ts +3 -0
  26. package/src/lib/components/Widget/AddButton/{index.ts → index.d.ts} +0 -1
  27. package/src/lib/components/Widget/Form/ItemsAccordian.d.ts +4 -0
  28. package/src/lib/components/Widget/Form/Tabs/TabItem.d.ts +4 -0
  29. package/src/lib/components/Widget/Form/Tabs/Tabs.d.ts +4 -0
  30. package/src/lib/components/Widget/Form/Tabs/{index.ts → index.d.ts} +0 -1
  31. package/src/lib/components/Widget/Form/WidgetForm.d.ts +4 -0
  32. package/src/lib/components/Widget/Form/{index.ts → index.d.ts} +0 -1
  33. package/src/lib/components/Widget/Pagination/WidgetPagination.d.ts +3 -0
  34. package/src/lib/components/Widget/Pagination/{index.ts → index.d.ts} +0 -1
  35. package/src/lib/components/Widget/Search/WidgetSearch.d.ts +3 -0
  36. package/src/lib/components/Widget/Search/{index.tsx → index.d.ts} +0 -1
  37. package/src/lib/components/Widget/Table/WidgetTable.d.ts +4 -0
  38. package/src/lib/components/Widget/Table/{index.ts → index.d.ts} +0 -1
  39. package/src/lib/components/Widget/Widget/Widget.d.ts +13 -0
  40. package/src/lib/components/Widget/Widget/{index.ts → index.d.ts} +0 -1
  41. package/src/lib/components/Widget/WidgetFormActions/WidgetFormActions.d.ts +4 -0
  42. package/src/lib/components/Widget/WidgetFormActions/{index.ts → index.d.ts} +0 -1
  43. package/src/lib/components/Widget/WidgetFormWrapper/WidgetFormWrapper.d.ts +4 -0
  44. package/src/lib/components/Widget/WidgetFormWrapper/{index.ts → index.d.ts} +0 -1
  45. package/src/lib/components/Widget/{index.tsx → index.d.ts} +0 -1
  46. package/src/lib/components/common/Accordian/Accordian.d.ts +13 -0
  47. package/src/lib/components/common/Accordian/{index.ts → index.d.ts} +0 -1
  48. package/src/lib/components/common/Button/Button.d.ts +4 -0
  49. package/src/lib/components/common/Button/{index.ts → index.d.ts} +0 -1
  50. package/src/lib/components/common/ConfirmPopover/ConfirmPopover.d.ts +4 -0
  51. package/src/lib/components/common/ConfirmPopover/{index.ts → index.d.ts} +0 -1
  52. package/src/lib/components/common/DNDItemsList/DNDItemsList.d.ts +4 -0
  53. package/src/lib/components/common/DNDItemsList/{index.ts → index.d.ts} +0 -1
  54. package/src/lib/components/common/DeleteModal/DeleteModal.d.ts +4 -0
  55. package/src/lib/components/common/DeleteModal/index.d.ts +2 -0
  56. package/src/lib/components/common/Drawer/Drawer.d.ts +9 -0
  57. package/src/lib/components/common/Drawer/{index.ts → index.d.ts} +0 -1
  58. package/src/lib/components/common/Form/Form.d.ts +15 -0
  59. package/src/lib/components/common/Form/SimpleForm.d.ts +18 -0
  60. package/src/lib/components/common/Form/{index.ts → index.d.ts} +0 -1
  61. package/src/lib/components/common/FormActions/FormActions.d.ts +10 -0
  62. package/src/lib/components/common/FormActions/{index.ts → index.d.ts} +0 -1
  63. package/src/lib/components/common/ImageUpload/ImageUpload.d.ts +4 -0
  64. package/src/lib/components/common/ImageUpload/index.d.ts +2 -0
  65. package/src/lib/components/common/Input/Checkbox.d.ts +4 -0
  66. package/src/lib/components/common/Input/Input.d.ts +4 -0
  67. package/src/lib/components/common/Input/ReactSelect.d.ts +4 -0
  68. package/src/lib/components/common/Input/Select.d.ts +4 -0
  69. package/src/lib/components/common/Input/SrcSet.d.ts +4 -0
  70. package/src/lib/components/common/Input/index.d.ts +12 -0
  71. package/src/lib/components/common/Modal/Modal.d.ts +8 -0
  72. package/src/lib/components/common/Modal/index.d.ts +2 -0
  73. package/src/lib/components/common/Pagination/Pagination.d.ts +4 -0
  74. package/src/lib/components/common/Pagination/{index.ts → index.d.ts} +0 -1
  75. package/src/lib/components/common/Table/Table.d.ts +4 -0
  76. package/src/lib/components/common/Table/{index.ts → index.d.ts} +0 -1
  77. package/src/lib/components/common/Toggle/Toggle.d.ts +4 -0
  78. package/src/lib/components/common/Toggle/{index.ts → index.d.ts} +0 -1
  79. package/src/lib/constants/common.d.ts +122 -0
  80. package/src/lib/context/PageContext.d.ts +7 -0
  81. package/src/lib/context/ProviderContext.d.ts +5 -0
  82. package/src/lib/context/WidgetContext.d.ts +7 -0
  83. package/src/lib/helper/utils.d.ts +10 -0
  84. package/src/lib/hooks/usePage.d.ts +43 -0
  85. package/src/lib/hooks/usePagination.d.ts +15 -0
  86. package/src/lib/hooks/useWidget.d.ts +46 -0
  87. package/src/lib/icons/chevronDown.d.ts +4 -0
  88. package/src/lib/icons/chevronLeft.d.ts +4 -0
  89. package/src/lib/icons/chevronRight.d.ts +4 -0
  90. package/src/lib/icons/chevronUp.d.ts +4 -0
  91. package/src/lib/icons/close.d.ts +4 -0
  92. package/src/lib/icons/pencil.d.ts +4 -0
  93. package/src/lib/icons/plus.d.ts +4 -0
  94. package/src/lib/icons/trash.d.ts +4 -0
  95. package/src/lib/types/api.d.ts +34 -0
  96. package/src/lib/types/common.d.ts +29 -0
  97. package/src/lib/types/components.d.ts +420 -0
  98. package/src/lib/types/context.d.ts +135 -0
  99. package/index.d.ts +0 -1
  100. package/src/lib/api/index.ts +0 -70
  101. package/src/lib/api/list.ts +0 -59
  102. package/src/lib/components/Page/AddButton/AddButton.tsx +0 -16
  103. package/src/lib/components/Page/Form/PageForm.tsx +0 -194
  104. package/src/lib/components/Page/Page/Page.tsx +0 -151
  105. package/src/lib/components/Page/PageFormActions/PageFormActions.tsx +0 -50
  106. package/src/lib/components/Page/PageFormWrapper/PageFormWrapper.tsx +0 -16
  107. package/src/lib/components/Page/Pagination/PagePagination.tsx +0 -26
  108. package/src/lib/components/Page/Search/PageSearch.tsx +0 -32
  109. package/src/lib/components/Page/Table/PageTable.tsx +0 -36
  110. package/src/lib/components/Widget/AddButton/AddButton.tsx +0 -16
  111. package/src/lib/components/Widget/Form/ItemsAccordian.tsx +0 -354
  112. package/src/lib/components/Widget/Form/Tabs/TabItem.tsx +0 -43
  113. package/src/lib/components/Widget/Form/Tabs/Tabs.tsx +0 -190
  114. package/src/lib/components/Widget/Form/WidgetForm.tsx +0 -771
  115. package/src/lib/components/Widget/Pagination/WidgetPagination.tsx +0 -26
  116. package/src/lib/components/Widget/Search/WidgetSearch.tsx +0 -32
  117. package/src/lib/components/Widget/Table/WidgetTable.tsx +0 -70
  118. package/src/lib/components/Widget/Widget/Widget.tsx +0 -173
  119. package/src/lib/components/Widget/WidgetFormActions/WidgetFormActions.tsx +0 -50
  120. package/src/lib/components/Widget/WidgetFormWrapper/WidgetFormWrapper.tsx +0 -16
  121. package/src/lib/components/common/Accordian/Accordian.tsx +0 -56
  122. package/src/lib/components/common/Button/Button.tsx +0 -45
  123. package/src/lib/components/common/ConfirmPopover/ConfirmPopover.tsx +0 -47
  124. package/src/lib/components/common/DNDItemsList/DNDItemsList.tsx +0 -53
  125. package/src/lib/components/common/DeleteModal/DeleteModal.tsx +0 -72
  126. package/src/lib/components/common/DeleteModal/index.tsx +0 -3
  127. package/src/lib/components/common/Drawer/Drawer.tsx +0 -79
  128. package/src/lib/components/common/Form/Form.tsx +0 -256
  129. package/src/lib/components/common/Form/SimpleForm.tsx +0 -314
  130. package/src/lib/components/common/FormActions/FormActions.tsx +0 -37
  131. package/src/lib/components/common/ImageUpload/ImageUpload.tsx +0 -113
  132. package/src/lib/components/common/ImageUpload/index.tsx +0 -3
  133. package/src/lib/components/common/Input/Checkbox.tsx +0 -25
  134. package/src/lib/components/common/Input/Input.tsx +0 -51
  135. package/src/lib/components/common/Input/ReactSelect.tsx +0 -60
  136. package/src/lib/components/common/Input/Select.tsx +0 -47
  137. package/src/lib/components/common/Input/SrcSet.tsx +0 -143
  138. package/src/lib/components/common/Input/index.ts +0 -20
  139. package/src/lib/components/common/Modal/Modal.tsx +0 -57
  140. package/src/lib/components/common/Modal/index.tsx +0 -3
  141. package/src/lib/components/common/Pagination/Pagination.tsx +0 -88
  142. package/src/lib/components/common/Table/Table.tsx +0 -133
  143. package/src/lib/components/common/Toggle/Toggle.tsx +0 -23
  144. package/src/lib/constants/common.ts +0 -145
  145. package/src/lib/context/PageContext.tsx +0 -100
  146. package/src/lib/context/ProviderContext.tsx +0 -52
  147. package/src/lib/context/WidgetContext.tsx +0 -127
  148. package/src/lib/helper/utils.ts +0 -46
  149. package/src/lib/hooks/usePage.tsx +0 -307
  150. package/src/lib/hooks/usePagination.tsx +0 -41
  151. package/src/lib/hooks/useWidget.tsx +0 -503
  152. package/src/lib/icons/chevronDown.tsx +0 -21
  153. package/src/lib/icons/chevronLeft.tsx +0 -20
  154. package/src/lib/icons/chevronRight.tsx +0 -20
  155. package/src/lib/icons/chevronUp.tsx +0 -21
  156. package/src/lib/icons/close.tsx +0 -21
  157. package/src/lib/icons/pencil.tsx +0 -21
  158. package/src/lib/icons/plus.tsx +0 -23
  159. package/src/lib/icons/trash.tsx +0 -21
  160. package/src/lib/types/api.ts +0 -44
  161. package/src/lib/types/common.ts +0 -31
  162. package/src/lib/types/components.ts +0 -427
  163. package/src/lib/types/context.ts +0 -184
  164. package/src/styles/index.css +0 -469
  165. /package/src/lib/types/{index.ts → index.d.ts} +0 -0
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import Pagination from '../../common/Pagination';
3
- import { useWidgetState } from '../../../context/WidgetContext';
4
- import { useProviderState } from '../../../context/ProviderContext';
5
-
6
- const WidgetPagination = () => {
7
- const { commonTranslations } = useProviderState();
8
- const { totalPages, totalRecords, currentPage, pageSize, setCurrentPage } =
9
- useWidgetState();
10
- return (
11
- <Pagination
12
- ofText={commonTranslations.of}
13
- pageText={commonTranslations.page}
14
- showingText={commonTranslations.showing}
15
- nextContent={commonTranslations.next}
16
- previousContent={commonTranslations.previous}
17
- totalPages={totalPages}
18
- totalRecords={totalRecords}
19
- currentPage={currentPage}
20
- pageSize={pageSize}
21
- setCurrentPage={setCurrentPage}
22
- />
23
- );
24
- };
25
-
26
- export default WidgetPagination;
@@ -1,32 +0,0 @@
1
- import React, { useRef, useState } from 'react';
2
- import Input from '../../common/Input';
3
- import { useWidgetState } from '../../../context/WidgetContext';
4
-
5
- const WidgetSearch = () => {
6
- const { changeSearch, widgetTranslations, canList, setCurrentPage } =
7
- useWidgetState();
8
- const callerRef = useRef<NodeJS.Timeout | null>(null);
9
- const [searchVal, setSearchVal] = useState<string>();
10
-
11
- const onChangeSearch = (str: string) => {
12
- setSearchVal(str);
13
- changeSearch(str);
14
- if (callerRef.current) clearTimeout(callerRef.current);
15
-
16
- callerRef.current = setTimeout(() => {
17
- setCurrentPage(1);
18
- }, 300);
19
- };
20
-
21
- return (
22
- <Input
23
- type="search"
24
- value={searchVal}
25
- disabled={!canList}
26
- onChange={(e) => onChangeSearch(e.target.value)}
27
- placeholder={widgetTranslations.searchPlaceholder}
28
- />
29
- );
30
- };
31
-
32
- export default WidgetSearch;
@@ -1,70 +0,0 @@
1
- import React, { useCallback } from 'react';
2
- import Table from '../../common/Table';
3
- import ToggleWidget from '../../common/Toggle';
4
- import { useWidgetState } from '../../../context/WidgetContext';
5
- import {
6
- CombineObjectType,
7
- DerivedTableProps,
8
- ObjectType,
9
- ValuesType,
10
- } from '../../../types';
11
- import { useProviderState } from '../../../context/ProviderContext';
12
-
13
- const WidgetTable = ({ extraActions, extraColumns }: DerivedTableProps) => {
14
- const { commonTranslations, switchClass } = useProviderState();
15
- const {
16
- list,
17
- canUpdate,
18
- canDelete,
19
- canPartialUpdate,
20
- onChangeFormState,
21
- onPartialUpdateWidget,
22
- loading,
23
- loader,
24
- } = useWidgetState();
25
- const updateClosure = useCallback(
26
- (item: ObjectType, key: string, value: ValuesType) => {
27
- onPartialUpdateWidget({ [key]: value }, item['_id']);
28
- },
29
- [onPartialUpdateWidget]
30
- );
31
- const onUpdateClick = (item: CombineObjectType) =>
32
- onChangeFormState('UPDATE', item);
33
- const onDeleteClick = (item: CombineObjectType) =>
34
- onChangeFormState('DELETE', item);
35
-
36
- const dataKeys: any[] = [
37
- { label: commonTranslations.name, dataKey: 'name', highlight: true },
38
- { label: commonTranslations.code, dataKey: 'code' },
39
- ];
40
- if (canPartialUpdate)
41
- dataKeys.push({
42
- label: commonTranslations.active,
43
- dataKey: 'isActive',
44
- Cell: ({ row }: any) =>
45
- canPartialUpdate ? (
46
- <ToggleWidget
47
- switchClass={switchClass}
48
- isChecked={row?.isActive}
49
- onChange={(status) => updateClosure(row, 'isActive', status)}
50
- />
51
- ) : null,
52
- });
53
-
54
- return (
55
- <Table
56
- data={list}
57
- loader={loader}
58
- loading={loading}
59
- dataKeys={dataKeys}
60
- actionsLabel={commonTranslations.actions}
61
- extraColumns={extraColumns}
62
- extraActions={extraActions}
63
- actions={{
64
- edit: canUpdate ? onUpdateClick : false,
65
- delete: canDelete ? onDeleteClick : false,
66
- }}
67
- />
68
- );
69
- };
70
- export default WidgetTable;
@@ -1,173 +0,0 @@
1
- import React, { useRef } from 'react';
2
- import useWidget from '../../../hooks/useWidget';
3
- import WidgetContextProvider from '../../../context/WidgetContext';
4
- import {
5
- TRANSLATION_PAIRS_WIDGET,
6
- DEFAULT_PERMISSIONS,
7
- } from '../../../constants/common';
8
- import { WidgetProps } from '../../../types';
9
-
10
- import Table from '../Table';
11
- import WidgetForm from '../Form';
12
- import AddButton from '../AddButton';
13
- import Pagination from '../Pagination';
14
- import WidgetSearch from '../Search';
15
- import Drawer from '../../common/Drawer';
16
- import DeleteModal from '../../common/DeleteModal';
17
- import WidgetFormActions from '../WidgetFormActions';
18
- import WiddgetFormWrapper from '../WidgetFormWrapper';
19
- import { useProviderState } from '../../../context/ProviderContext';
20
-
21
- const Widget = ({
22
- routes,
23
- loader,
24
- explicitForm = false,
25
- imageBaseUrl,
26
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
27
- // @ts-ignore
28
- permissions = {},
29
- preConfirmDelete,
30
- formatListItem,
31
- formatOptionLabel,
32
- imageMaxSize,
33
- translations,
34
- children,
35
- }: WidgetProps) => {
36
- const { commonTranslations } = useProviderState();
37
- const derivedPermissions = Object.assign(DEFAULT_PERMISSIONS, permissions);
38
- const widgetFormRef = useRef<HTMLFormElement | null>(null);
39
- const derivedT = {
40
- ...TRANSLATION_PAIRS_WIDGET,
41
- ...(translations || {}),
42
- };
43
- const {
44
- list,
45
- loading,
46
- searchText,
47
- changeSearch,
48
- onChangeFormState,
49
- formState,
50
- onCloseForm,
51
- onWidgetFormSubmit,
52
- itemData,
53
- getWidgets,
54
- onCofirmDeleteWidget,
55
- onImageRemove,
56
- onImageUpload,
57
- onPartialUpdateWidget,
58
- itemsTypes,
59
- widgetTypes,
60
- getCollectionData,
61
- collectionData,
62
- collectionDataLoading,
63
- // Pagination
64
- totalPages,
65
- totalRecords,
66
- currentPage,
67
- pageSize,
68
- languages,
69
- setCurrentPage,
70
- } = useWidget({
71
- canList: derivedPermissions.list,
72
- routes,
73
- defaultLimit: 10,
74
- preConfirmDelete,
75
- imageBaseUrl,
76
- });
77
- return (
78
- <WidgetContextProvider
79
- loading={loading}
80
- list={list}
81
- languages={languages}
82
- imageBaseUrl={imageBaseUrl}
83
- onChangeFormState={onChangeFormState}
84
- searchText={searchText}
85
- changeSearch={changeSearch}
86
- loader={loader}
87
- onWidgetFormSubmit={onWidgetFormSubmit}
88
- data={itemData}
89
- getWidgets={getWidgets}
90
- onImageRemove={onImageRemove}
91
- onImageUpload={onImageUpload}
92
- onPartialUpdateWidget={onPartialUpdateWidget}
93
- itemsTypes={itemsTypes}
94
- widgetTypes={widgetTypes}
95
- getCollectionData={getCollectionData}
96
- collectionData={collectionData}
97
- collectionDataLoading={collectionDataLoading}
98
- formatListItem={formatListItem}
99
- formatOptionLabel={formatOptionLabel}
100
- // Pagination
101
- totalPages={totalPages}
102
- totalRecords={totalRecords}
103
- currentPage={currentPage}
104
- pageSize={pageSize}
105
- setCurrentPage={setCurrentPage}
106
- // Permissions
107
- canAdd={derivedPermissions.add}
108
- canDelete={derivedPermissions.delete}
109
- canList={derivedPermissions.list}
110
- canUpdate={derivedPermissions.update}
111
- canPartialUpdate={derivedPermissions.partialUpdate}
112
- formState={formState}
113
- closeForm={onCloseForm}
114
- imageMaxSize={imageMaxSize}
115
- widgetTranslations={translations}
116
- >
117
- {children ? (
118
- children
119
- ) : (
120
- <>
121
- <AddButton />
122
- <WidgetSearch />
123
- <div className="khb_table-wrapper">
124
- <Table />
125
- <Pagination />
126
- </div>
127
- </>
128
- )}
129
-
130
- {!explicitForm && (
131
- <Drawer
132
- open={formState === 'ADD' || formState === 'UPDATE'}
133
- onClose={onCloseForm}
134
- title={
135
- formState === 'ADD'
136
- ? derivedT.addWidgetTitle
137
- : formState === 'UPDATE'
138
- ? derivedT.updateWidgetTitle
139
- : ''
140
- }
141
- footerContent={<WidgetFormActions formRef={widgetFormRef} />}
142
- >
143
- <WidgetForm formRef={widgetFormRef} />
144
- </Drawer>
145
- )}
146
- {itemData && (
147
- <DeleteModal
148
- formState={formState}
149
- itemData={itemData}
150
- onClose={onCloseForm}
151
- onConfirmDelete={onCofirmDeleteWidget}
152
- confirmationRequired={commonTranslations.confirmationRequired}
153
- confirm={commonTranslations.confirm}
154
- lossOfData={commonTranslations.lossOfData}
155
- permanentlyDelete={commonTranslations.permanentlyDelete}
156
- pleaseType={commonTranslations.pleaseType}
157
- toProceedOrCancel={commonTranslations.toProceedOrCancel}
158
- typeHerePlaceholder={commonTranslations.typeHerePlaceholder}
159
- />
160
- )}
161
- </WidgetContextProvider>
162
- );
163
- };
164
-
165
- Widget.Table = Table;
166
- Widget.Form = WidgetForm;
167
- Widget.AddButton = AddButton;
168
- Widget.Search = WidgetSearch;
169
- Widget.Pagination = Pagination;
170
- Widget.FormWrapper = WiddgetFormWrapper;
171
- Widget.FormActions = WidgetFormActions;
172
-
173
- export default Widget;
@@ -1,50 +0,0 @@
1
- import React from 'react';
2
- import FormActions from '../../common/FormActions';
3
- import { FormActionWrapperProps } from '../../../types';
4
- import { CALLBACK_CODES } from '../../../constants/common';
5
- import { useWidgetState } from '../../../context/WidgetContext';
6
- import { useProviderState } from '../../../context/ProviderContext';
7
-
8
- const WidgetFormActions = ({ formRef }: FormActionWrapperProps) => {
9
- const { onError, commonTranslations } = useProviderState();
10
- const { closeForm, loading, canAdd, canUpdate, formState } = useWidgetState();
11
- const onSubmitClick = (
12
- e?: React.MouseEvent<HTMLButtonElement, MouseEvent>
13
- ) => {
14
- if (!formRef) {
15
- return onError(
16
- CALLBACK_CODES.INTERNAL,
17
- 'error',
18
- `formRef is required to submit the form!`
19
- );
20
- } else if (!formRef.current) {
21
- return onError(
22
- CALLBACK_CODES.INTERNAL,
23
- 'error',
24
- `formRef is empty, make sure it's passed as 'formRef' prop to the form!`
25
- );
26
- }
27
- // formRef is provided
28
- e?.preventDefault();
29
- formRef.current?.dispatchEvent(
30
- new Event('submit', { cancelable: true, bubbles: true })
31
- );
32
- };
33
-
34
- if (!canAdd && !canUpdate) return null;
35
- return (
36
- <FormActions
37
- loading={loading}
38
- primaryLabel={
39
- formState === 'ADD'
40
- ? commonTranslations.create
41
- : commonTranslations.update
42
- }
43
- onPrimaryButtonClick={onSubmitClick}
44
- onSecondaryButtonClick={closeForm}
45
- secondaryLabel={commonTranslations.cancel}
46
- />
47
- );
48
- };
49
-
50
- export default WidgetFormActions;
@@ -1,16 +0,0 @@
1
- import { FormWrapperProps } from '../../../types';
2
- import { useWidgetState } from '../../../context/WidgetContext';
3
-
4
- const WiddgetFormWrapper = ({ children }: FormWrapperProps) => {
5
- const { formState, closeForm } = useWidgetState();
6
-
7
- return typeof children === 'function'
8
- ? children({
9
- formState,
10
- onClose: closeForm,
11
- open: formState === 'ADD' || formState === 'UPDATE',
12
- })
13
- : null;
14
- };
15
-
16
- export default WiddgetFormWrapper;
@@ -1,56 +0,0 @@
1
- import classNames from 'classnames';
2
- import React from 'react';
3
- import ChevronDown from '../../../icons/chevronDown';
4
- import ChevronUp from '../../../icons/chevronUp';
5
-
6
- interface AccordianProps {
7
- id?: string;
8
- collapseId?: string;
9
- className?: string;
10
- children?: React.ReactNode;
11
- open?: boolean;
12
- onToggle?: (status: boolean) => void;
13
- title?: string;
14
- footerContent?: React.ReactNode;
15
- }
16
-
17
- const Accordian = ({
18
- id,
19
- className,
20
- children,
21
- open,
22
- onToggle,
23
- title,
24
- collapseId,
25
- footerContent,
26
- }: AccordianProps) => {
27
- return (
28
- <div>
29
- <h2 id={id}>
30
- <button
31
- type="button"
32
- className="khb_accordian-header"
33
- data-accordion-target={`#${collapseId}`}
34
- aria-expanded="true"
35
- aria-controls={collapseId}
36
- onClick={() => onToggle && onToggle(!open)}
37
- >
38
- <span>{title}</span>
39
- {open ? <ChevronUp /> : <ChevronDown />}
40
- </button>
41
- </h2>
42
- <div
43
- id={collapseId}
44
- className={classNames('khb_accordian-body', { hidden: !open })}
45
- aria-labelledby={id}
46
- >
47
- <div className="khb_accordian-content">{children}</div>
48
- {footerContent && (
49
- <div className="khb_accordian-footer">{footerContent}</div>
50
- )}
51
- </div>
52
- </div>
53
- );
54
- };
55
-
56
- export default Accordian;
@@ -1,45 +0,0 @@
1
- import React from 'react';
2
- import classNames from 'classnames';
3
- import { ButtonProps } from '../../../types';
4
-
5
- const Button = ({
6
- type = 'primary',
7
- size = 'base',
8
- onClick,
9
- className,
10
- children,
11
- disabled,
12
- loading,
13
- }: ButtonProps) => {
14
- return (
15
- <button
16
- className={classNames(
17
- 'khb_btn',
18
- `khb_btn-${type}`,
19
- `khb_btn-${size}`,
20
- className
21
- )}
22
- onClick={onClick}
23
- disabled={disabled || loading}
24
- >
25
- {loading && (
26
- <svg
27
- className="khb_btn-loader"
28
- xmlns="http://www.w3.org/2000/svg"
29
- width="12"
30
- height="13"
31
- viewBox="0 0 12 13"
32
- >
33
- <path
34
- // style={{ fill: kind }}
35
- d="M5.5,12a1,1,0,1,1,1,1A1,1,0,0,1,5.5,12ZM1.75,10.5A1.25,1.25,0,1,1,3,11.75,1.25,1.25,0,0,1,1.75,10.5Zm7.531.031a.75.75,0,1,1,.75.75A.75.75,0,0,1,9.281,10.531ZM0,7A1.5,1.5,0,1,1,1.5,8.5,1.5,1.5,0,0,1,0,7ZM11,7a.5.5,0,1,1,.5.5A.5.5,0,0,1,11,7ZM1.875,4.637a1.62,1.62,0,0,1,0-2.275,1.582,1.582,0,0,1,2.253,0,1.62,1.62,0,0,1,0,2.275,1.582,1.582,0,0,1-2.253,0ZM4.5,2a2,2,0,1,1,2,2A2,2,0,0,1,4.5,2ZM9.75,3.5a.25.25,0,1,1,.25.25A.25.25,0,0,1,9.75,3.5Z"
36
- />
37
- </svg>
38
- )}
39
-
40
- {children}
41
- </button>
42
- );
43
- };
44
-
45
- export default Button;
@@ -1,47 +0,0 @@
1
- /* eslint-disable jsx-a11y/no-static-element-interactions */
2
- /* eslint-disable jsx-a11y/click-events-have-key-events */
3
- /* eslint-disable react/no-unstable-nested-components */
4
- import React, { useState } from 'react';
5
- import { Popover } from 'react-tiny-popover';
6
- import { ConfirmPopoverProps } from '../../../types';
7
- import Button from '../Button';
8
-
9
- const ConfirmPopOver = ({
10
- children,
11
- onConfirm,
12
- title,
13
- confirmText = 'Yes',
14
- cancelText = 'No',
15
- }: ConfirmPopoverProps) => {
16
- const [isPopoverOpen, setIsPopoverOpen] = useState(false);
17
-
18
- const onConfirmClick = () => {
19
- setIsPopoverOpen(false);
20
- onConfirm();
21
- };
22
-
23
- return (
24
- <Popover
25
- containerClassName="khb_confirm-popover"
26
- isOpen={isPopoverOpen}
27
- padding={10}
28
- onClickOutside={() => setIsPopoverOpen(false)}
29
- content={() => (
30
- <div className="khb_confirm-popover-content">
31
- <div className="khb_confirm-popover-title">{title}</div>
32
- <div className="khb_confirm-popover-footer">
33
- <Button type="secondary" onClick={() => setIsPopoverOpen(false)}>
34
- {cancelText}
35
- </Button>
36
- <Button type="primary" onClick={onConfirmClick}>
37
- {confirmText}
38
- </Button>
39
- </div>
40
- </div>
41
- )}
42
- >
43
- <div onClick={() => setIsPopoverOpen(true)}>{children}</div>
44
- </Popover>
45
- );
46
- };
47
- export default ConfirmPopOver;
@@ -1,53 +0,0 @@
1
- import React from 'react';
2
- import { DNDItemsListProps } from '../../../types';
3
- import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
4
-
5
- const DNDItemsList = ({
6
- onDragEnd,
7
- items,
8
- formatItem,
9
- listCode,
10
- }: DNDItemsListProps) => {
11
- return (
12
- <DragDropContext onDragEnd={onDragEnd}>
13
- <Droppable droppableId="droppable">
14
- {(droppableProvided) => (
15
- <div
16
- className="khb_DND-items"
17
- ref={droppableProvided.innerRef}
18
- {...droppableProvided.droppableProps}
19
- >
20
- {items
21
- ? items.map((item, index) => (
22
- <Draggable
23
- key={item.value}
24
- draggableId={item.value}
25
- index={index}
26
- >
27
- {(provided) => (
28
- <div
29
- className="khb_DND-item"
30
- key={item.value}
31
- ref={provided.innerRef}
32
- {...provided.draggableProps}
33
- {...provided.dragHandleProps}
34
- >
35
- {typeof formatItem === 'function' && listCode ? (
36
- formatItem(listCode, item)
37
- ) : (
38
- <p className="khb_DND-item-text">{item.label}</p>
39
- )}
40
- </div>
41
- )}
42
- </Draggable>
43
- ))
44
- : null}
45
- {droppableProvided.placeholder}
46
- </div>
47
- )}
48
- </Droppable>
49
- </DragDropContext>
50
- );
51
- };
52
-
53
- export default DNDItemsList;
@@ -1,72 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import Button from '../Button';
3
- import Input from '../Input';
4
- import Modal from '../Modal';
5
- import { DeleteModalProps } from '../../../types';
6
- import { TRANSLATION_PAIRS_COMMON } from '../../../constants/common';
7
-
8
- const DeleteModal = ({
9
- formState,
10
- onClose,
11
- itemData,
12
- onConfirmDelete,
13
- confirmationRequired,
14
- permanentlyDelete,
15
- lossOfData,
16
- pleaseType,
17
- toProceedOrCancel,
18
- confirm,
19
- typeHerePlaceholder,
20
- }: DeleteModalProps) => {
21
- const [userInput, setUserInput] = useState<string>('');
22
- useEffect(() => {
23
- setUserInput('');
24
- }, [formState]);
25
- return itemData ? (
26
- <Modal
27
- open={formState === 'DELETE' && itemData ? true : false}
28
- onClose={onClose}
29
- title={
30
- confirmationRequired || TRANSLATION_PAIRS_COMMON.confirmationRequired
31
- }
32
- >
33
- <div className="khb_delete-header">
34
- <p>
35
- {permanentlyDelete || TRANSLATION_PAIRS_COMMON.permanentlyDelete}{' '}
36
- <b>{itemData['name']}</b>
37
- </p>
38
- </div>
39
- <div className="khb_delete-content">
40
- <p>{lossOfData || TRANSLATION_PAIRS_COMMON.lossOfData}</p>
41
- <p className="khb_delete-note">
42
- {pleaseType || TRANSLATION_PAIRS_COMMON.pleaseType}{' '}
43
- <b className="text-black font-bold">{itemData['name']}</b>{' '}
44
- {toProceedOrCancel || TRANSLATION_PAIRS_COMMON.toProceedOrCancel}
45
- </p>
46
- </div>
47
- <div className="khb_delete-actions">
48
- <Input
49
- placeholder={
50
- typeHerePlaceholder || TRANSLATION_PAIRS_COMMON.typeHerePlaceholder
51
- }
52
- wrapperClassName="w-full"
53
- className="khb_delete-input"
54
- value={userInput}
55
- onChange={(e) => setUserInput(e.target.value)}
56
- />
57
- <div className="khb_delete-buttons">
58
- <Button
59
- disabled={
60
- userInput.toString().trim() !== itemData?.['name']?.trim()
61
- }
62
- onClick={onConfirmDelete}
63
- >
64
- {confirm || TRANSLATION_PAIRS_COMMON.confirm}
65
- </Button>
66
- </div>
67
- </div>
68
- </Modal>
69
- ) : null;
70
- };
71
-
72
- export default DeleteModal;
@@ -1,3 +0,0 @@
1
- import DeleteModal from "./DeleteModal"
2
-
3
- export default DeleteModal