@knovator/pagecreator-admin 1.2.9 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/index.cjs +7876 -0
  2. package/index.css +2 -0
  3. package/index.js +7862 -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 +37 -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/settings.d.ts +4 -0
  95. package/src/lib/icons/trash.d.ts +4 -0
  96. package/src/lib/types/api.d.ts +34 -0
  97. package/src/lib/types/common.d.ts +30 -0
  98. package/src/lib/types/components.d.ts +421 -0
  99. package/src/lib/types/context.d.ts +135 -0
  100. package/index.d.ts +0 -1
  101. package/src/lib/api/index.ts +0 -70
  102. package/src/lib/api/list.ts +0 -59
  103. package/src/lib/components/Page/AddButton/AddButton.tsx +0 -16
  104. package/src/lib/components/Page/Form/PageForm.tsx +0 -194
  105. package/src/lib/components/Page/Page/Page.tsx +0 -151
  106. package/src/lib/components/Page/PageFormActions/PageFormActions.tsx +0 -50
  107. package/src/lib/components/Page/PageFormWrapper/PageFormWrapper.tsx +0 -16
  108. package/src/lib/components/Page/Pagination/PagePagination.tsx +0 -26
  109. package/src/lib/components/Page/Search/PageSearch.tsx +0 -32
  110. package/src/lib/components/Page/Table/PageTable.tsx +0 -36
  111. package/src/lib/components/Widget/AddButton/AddButton.tsx +0 -16
  112. package/src/lib/components/Widget/Form/ItemsAccordian.tsx +0 -354
  113. package/src/lib/components/Widget/Form/Tabs/TabItem.tsx +0 -43
  114. package/src/lib/components/Widget/Form/Tabs/Tabs.tsx +0 -190
  115. package/src/lib/components/Widget/Form/WidgetForm.tsx +0 -771
  116. package/src/lib/components/Widget/Pagination/WidgetPagination.tsx +0 -26
  117. package/src/lib/components/Widget/Search/WidgetSearch.tsx +0 -32
  118. package/src/lib/components/Widget/Table/WidgetTable.tsx +0 -70
  119. package/src/lib/components/Widget/Widget/Widget.tsx +0 -173
  120. package/src/lib/components/Widget/WidgetFormActions/WidgetFormActions.tsx +0 -50
  121. package/src/lib/components/Widget/WidgetFormWrapper/WidgetFormWrapper.tsx +0 -16
  122. package/src/lib/components/common/Accordian/Accordian.tsx +0 -56
  123. package/src/lib/components/common/Button/Button.tsx +0 -45
  124. package/src/lib/components/common/ConfirmPopover/ConfirmPopover.tsx +0 -47
  125. package/src/lib/components/common/DNDItemsList/DNDItemsList.tsx +0 -77
  126. package/src/lib/components/common/DeleteModal/DeleteModal.tsx +0 -72
  127. package/src/lib/components/common/DeleteModal/index.tsx +0 -3
  128. package/src/lib/components/common/Drawer/Drawer.tsx +0 -79
  129. package/src/lib/components/common/Form/Form.tsx +0 -256
  130. package/src/lib/components/common/Form/SimpleForm.tsx +0 -314
  131. package/src/lib/components/common/FormActions/FormActions.tsx +0 -37
  132. package/src/lib/components/common/ImageUpload/ImageUpload.tsx +0 -113
  133. package/src/lib/components/common/ImageUpload/index.tsx +0 -3
  134. package/src/lib/components/common/Input/Checkbox.tsx +0 -25
  135. package/src/lib/components/common/Input/Input.tsx +0 -51
  136. package/src/lib/components/common/Input/ReactSelect.tsx +0 -61
  137. package/src/lib/components/common/Input/Select.tsx +0 -47
  138. package/src/lib/components/common/Input/SrcSet.tsx +0 -143
  139. package/src/lib/components/common/Input/index.ts +0 -20
  140. package/src/lib/components/common/Modal/Modal.tsx +0 -57
  141. package/src/lib/components/common/Modal/index.tsx +0 -3
  142. package/src/lib/components/common/Pagination/Pagination.tsx +0 -88
  143. package/src/lib/components/common/Table/Table.tsx +0 -133
  144. package/src/lib/components/common/Toggle/Toggle.tsx +0 -23
  145. package/src/lib/constants/common.ts +0 -145
  146. package/src/lib/context/PageContext.tsx +0 -100
  147. package/src/lib/context/ProviderContext.tsx +0 -52
  148. package/src/lib/context/WidgetContext.tsx +0 -127
  149. package/src/lib/helper/utils.ts +0 -46
  150. package/src/lib/hooks/usePage.tsx +0 -306
  151. package/src/lib/hooks/usePagination.tsx +0 -41
  152. package/src/lib/hooks/useWidget.tsx +0 -503
  153. package/src/lib/icons/chevronDown.tsx +0 -21
  154. package/src/lib/icons/chevronLeft.tsx +0 -20
  155. package/src/lib/icons/chevronRight.tsx +0 -20
  156. package/src/lib/icons/chevronUp.tsx +0 -21
  157. package/src/lib/icons/close.tsx +0 -21
  158. package/src/lib/icons/pencil.tsx +0 -21
  159. package/src/lib/icons/plus.tsx +0 -23
  160. package/src/lib/icons/settings.tsx +0 -35
  161. package/src/lib/icons/trash.tsx +0 -21
  162. package/src/lib/types/api.ts +0 -44
  163. package/src/lib/types/common.ts +0 -31
  164. package/src/lib/types/components.ts +0 -428
  165. package/src/lib/types/context.ts +0 -184
  166. package/src/styles/index.css +0 -481
  167. /package/src/lib/types/{index.ts → index.d.ts} +0 -0
@@ -1,113 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { useDropzone } from 'react-dropzone';
3
- import SmallCancel from '../../../icons/close';
4
- import { ImageUploadProps } from '../../../types';
5
- import { build_path, isEmpty, isString } from '../../../helper/utils';
6
-
7
- const ImageUpload = ({
8
- className,
9
- text,
10
- maxSize,
11
- setImgId,
12
- onError,
13
- error,
14
- imgId = '',
15
- onImageUpload,
16
- onImageRemove,
17
- clearError,
18
- baseUrl,
19
- disabled = false,
20
- }: ImageUploadProps) => {
21
- const [img, setImg] = useState<string | undefined>(undefined);
22
- const { getRootProps, getInputProps } = useDropzone({
23
- // accept: {
24
- // "image/*": [".jpeg,.jpg,.png"],
25
- // },
26
- noClick: true,
27
- multiple: false,
28
- minSize: 0,
29
- maxSize,
30
- onDrop: async (acceptedFiles, rejectedFiles) => {
31
- try {
32
- if (typeof clearError === 'function') clearError();
33
- if (acceptedFiles?.length > 0) {
34
- const regex = /\.(png|jpeg|jpg|webp|svg|gif)$/gi;
35
- const files = acceptedFiles.filter((file) => regex.test(file.name));
36
- if (files[0]) {
37
- const response = await onImageUpload(files[0]);
38
- if (response) {
39
- setImg(response.fileUrl);
40
- setImgId(response.fileId);
41
- }
42
- } else
43
- throw new Error(
44
- 'Only .png, .jpg, .jpeg, .web, or .svg image types are supported.'
45
- );
46
- } else if (
47
- rejectedFiles?.[0]?.errors?.[0]?.message ===
48
- 'File size must be smaller than 10485760 bytes'
49
- ) {
50
- throw new Error('File is larger than 10mb');
51
- }
52
- } catch (error) {
53
- onError((error as Error).message);
54
- }
55
- },
56
- });
57
-
58
- const onRemoveFile = async (event: React.MouseEvent<HTMLButtonElement>) => {
59
- event.preventDefault();
60
- try {
61
- if (onImageRemove && imgId)
62
- await onImageRemove(typeof imgId === 'string' ? imgId : imgId['_id']);
63
-
64
- setImgId(null);
65
- setImg('');
66
- } catch (error) {
67
- onError((error as Error).message);
68
- }
69
- };
70
-
71
- useEffect(() => {
72
- if (imgId && typeof imgId === 'object') {
73
- setImg(build_path(baseUrl, imgId['uri']));
74
- }
75
- }, [baseUrl, imgId]);
76
-
77
- const showImage = (fileUrl: string) => {
78
- return (
79
- <div className="khb_img-wrapper">
80
- <img src={`${fileUrl}`} alt="" className="khb_img-wrapper-img" />
81
- {!disabled && (
82
- <button onClick={onRemoveFile} className="khb_img-wrapper-del">
83
- <SmallCancel />
84
- </button>
85
- )}
86
- </div>
87
- );
88
- };
89
-
90
- if (!isEmpty(img) && isString(img) && img) {
91
- return (
92
- <div className="khb_img-upload-wrapper-1">
93
- <div className="khb_img-upload-wrapper-2">
94
- <div>{showImage(img)}</div>
95
- </div>
96
- </div>
97
- );
98
- }
99
-
100
- return (
101
- <>
102
- <div {...getRootProps()} className="khb_img-upload-wrapper-1">
103
- <input disabled={disabled} {...getInputProps()} id="file-upload" />
104
- <label htmlFor="file-upload" className="khb_img-upload-wrapper-2">
105
- <div className={className}>{text}</div>
106
- </label>
107
- </div>
108
- {error && <p className="khb_input-error">{error}</p>}
109
- </>
110
- );
111
- };
112
-
113
- export default React.memo(ImageUpload);
@@ -1,3 +0,0 @@
1
- import ImageUpload from "./ImageUpload"
2
-
3
- export default ImageUpload
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- import classNames from 'classnames';
3
- import { CheckboxProps } from '../../../types';
4
-
5
- const Checkbox = ({
6
- rest,
7
- label,
8
- error,
9
- wrapperClassName,
10
- disabled,
11
- switchClass,
12
- }: CheckboxProps) => {
13
- return (
14
- <div className={classNames('khb_input-wrapper', wrapperClassName)}>
15
- {label && <label className="khb_input-label">{label}</label>}
16
- <label className={switchClass || 'khb_switch'} data-testid="khb_switch">
17
- <input type="checkbox" disabled={disabled} {...rest} />
18
- <span className="slider round" />
19
- </label>
20
- {error && <p className="khb_input-error">{error}</p>}
21
- </div>
22
- );
23
- };
24
-
25
- export default Checkbox;
@@ -1,51 +0,0 @@
1
- import React from 'react';
2
- import classNames from 'classnames';
3
- import { InputProps } from '../../../types';
4
-
5
- const Input = ({
6
- label,
7
- id,
8
- placeholder,
9
- type,
10
- size = 'base',
11
- required,
12
- error,
13
- className,
14
- disabled,
15
- rest,
16
- onInput,
17
- onBlur,
18
- value,
19
- info,
20
- onChange,
21
- wrapperClassName,
22
- }: InputProps) => {
23
- return (
24
- <div className={classNames('khb_input-wrapper', wrapperClassName)}>
25
- {label && (
26
- <label className="khb_input-label">
27
- {label}
28
- {required ? (
29
- <span className="khb_input-label-required">*</span>
30
- ) : null}
31
- </label>
32
- )}
33
- <input
34
- className={classNames('khb_input', `khb_input-${size}`, className)}
35
- type={type}
36
- placeholder={placeholder}
37
- disabled={disabled}
38
- id={id}
39
- value={value}
40
- onChange={onChange}
41
- {...rest}
42
- onInput={onInput}
43
- onBlur={onBlur}
44
- />
45
- {error && <p className="khb_input-error ">{error}</p>}
46
- {info && <p className="khb_input-info">{info}</p>}
47
- </div>
48
- );
49
- };
50
-
51
- export default Input;
@@ -1,61 +0,0 @@
1
- import React from 'react';
2
- import classNames from 'classnames';
3
- import ReactSelect from 'react-select/async';
4
- import { ReactSelectProps } from '../../../types';
5
-
6
- const CustomReactSelect = ({
7
- onChange,
8
- label,
9
- error,
10
- className,
11
- isMulti,
12
- selectedOptions = [],
13
- required,
14
- isLoading,
15
- isSearchable,
16
- loadOptions,
17
- placeholder,
18
- wrapperClassName,
19
- formatOptionLabel,
20
- listCode,
21
- customStyles,
22
- selectKey,
23
- }: ReactSelectProps) => {
24
- return (
25
- <div className={wrapperClassName}>
26
- {label && (
27
- <label className="khb_input-label">
28
- {label}
29
- {required ? (
30
- <span className="khb_input-label-required">*</span>
31
- ) : null}
32
- </label>
33
- )}
34
- <ReactSelect
35
- key={selectKey}
36
- data-testid={`input-select-${label}`}
37
- value={selectedOptions}
38
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
39
- // @ts-ignore
40
- onChange={onChange}
41
- className={classNames(className)}
42
- isMulti={isMulti}
43
- defaultOptions
44
- isSearchable={isSearchable}
45
- isLoading={isLoading}
46
- loadOptions={loadOptions}
47
- placeholder={placeholder}
48
- formatOptionLabel={
49
- formatOptionLabel
50
- ? (option: { [key: string]: any }) =>
51
- formatOptionLabel(listCode!, option)
52
- : undefined
53
- }
54
- styles={customStyles}
55
- />
56
- {error && <p className="khb_input-error ">{error}</p>}
57
- </div>
58
- );
59
- };
60
-
61
- export default CustomReactSelect;
@@ -1,47 +0,0 @@
1
- import React from 'react';
2
- import classNames from 'classnames';
3
- import { SelectProps } from '../../../types';
4
-
5
- const Select = ({
6
- onChange,
7
- value,
8
- rest,
9
- label,
10
- error,
11
- options = [],
12
- size = 'base',
13
- className,
14
- disabled,
15
- required,
16
- wrapperClassName,
17
- }: SelectProps) => {
18
- return (
19
- <div className={classNames('khb_input-wrapper', wrapperClassName)}>
20
- {label && (
21
- <label className="khb_input-label">
22
- {label}
23
- {required ? (
24
- <span className="khb_input-label-required">*</span>
25
- ) : null}
26
- </label>
27
- )}
28
- <select
29
- data-testid={`input-select-${label}`}
30
- value={value}
31
- onChange={onChange}
32
- className={classNames('khb_input', `khb_input-${size}`, className)}
33
- disabled={disabled}
34
- {...rest}
35
- >
36
- {options.map((option, index) => (
37
- <option value={option.value} key={index} data-testid="select-option">
38
- {option.label}
39
- </option>
40
- ))}
41
- </select>
42
- {error && <p className="khb_input-error ">{error}</p>}
43
- </div>
44
- );
45
- };
46
-
47
- export default Select;
@@ -1,143 +0,0 @@
1
- import React from 'react';
2
- import classNames from 'classnames';
3
- import { useFieldArray } from 'react-hook-form';
4
- import Close from '../../../icons/close';
5
- import Plus from '../../../icons/plus';
6
- import { InputProps, InputSizes, SrcSetMessageProps } from '../../../types';
7
-
8
- const SrcSetInput = ({
9
- size,
10
- className,
11
- rest,
12
- error,
13
- placeholder,
14
- disabled = false,
15
- }: {
16
- size: InputSizes;
17
- rest: any;
18
- index: number;
19
- error?: string;
20
- className?: string;
21
- placeholder?: string;
22
- disabled?: boolean;
23
- }) => {
24
- return (
25
- <div>
26
- <input
27
- className={classNames('khb_input', `khb_input-${size}`, className)}
28
- type={'number'}
29
- placeholder={placeholder}
30
- disabled={disabled}
31
- {...(rest || {})}
32
- />
33
- {error && <p className="khb_input-error">{error}</p>}
34
- </div>
35
- );
36
- };
37
-
38
- const SrcSet = ({
39
- label,
40
- size = 'base',
41
- required,
42
- error,
43
- className,
44
- register,
45
- wrapperClassName,
46
- control,
47
- errors,
48
- name,
49
- disabled = false,
50
-
51
- screenSizeRequired,
52
- heightRequired,
53
- minHeight,
54
- minScreenSize,
55
- minWidth,
56
- widthRequired,
57
- }: InputProps & SrcSetMessageProps) => {
58
- const { fields, append, remove } = useFieldArray({
59
- control,
60
- name: name!,
61
- });
62
-
63
- return (
64
- <div className={classNames('khb_input-wrapper', wrapperClassName)}>
65
- {label && (
66
- <label className="khb_input-label">
67
- {label}
68
- {required ? (
69
- <span className="khb_input-label-required">*</span>
70
- ) : null}
71
- </label>
72
- )}
73
- <div className="khb_input-srcset-items">
74
- {fields?.map((item, index) => (
75
- <div key={index} className="khb_input-srcset">
76
- <SrcSetInput
77
- error={errors?.[index]?.['screenSize']?.message?.toString()}
78
- index={index}
79
- className={className}
80
- size={size}
81
- placeholder="Screen Size"
82
- rest={register(`${name}.${index}.screenSize`, {
83
- required: screenSizeRequired,
84
- validate: (value: string) =>
85
- Number(value) <= 0 ? minScreenSize : true,
86
- })}
87
- disabled={disabled}
88
- />
89
-
90
- <span className="p-2">=</span>
91
- <SrcSetInput
92
- error={errors?.[index]?.['width']?.message?.toString()}
93
- index={index}
94
- rest={register(`${name}.${index}.width`, {
95
- required: widthRequired,
96
- validate: (value: string) =>
97
- Number(value) <= 0 ? minWidth : true,
98
- })}
99
- className={className}
100
- size={size}
101
- placeholder="Width"
102
- disabled={disabled}
103
- />
104
-
105
- <span className="p-2">x</span>
106
- <SrcSetInput
107
- error={errors?.[index]?.['height']?.message?.toString()}
108
- index={index}
109
- rest={register(`${name}.${index}.height`, {
110
- required: heightRequired,
111
- validate: (value: string) =>
112
- Number(value) <= 0 ? minHeight : true,
113
- })}
114
- className={className}
115
- size={size}
116
- placeholder="Height"
117
- disabled={disabled}
118
- />
119
- <button
120
- type="button"
121
- className="khb_btn khb_btn-danger khb_btn-xs"
122
- onClick={() => remove(index)}
123
- disabled={disabled}
124
- >
125
- <Close />
126
- </button>
127
- </div>
128
- ))}
129
- <button
130
- type="button"
131
- disabled={disabled}
132
- onClick={() => append({ screenSize: '', width: '', height: '' })}
133
- className="khb_btn khb_btn-primary khb_btn-xs"
134
- >
135
- <Plus className="khb_srcset-remove" />
136
- </button>
137
- </div>
138
- {error && <p className="khb_input-error ">{error}</p>}
139
- </div>
140
- );
141
- };
142
-
143
- export default SrcSet;
@@ -1,20 +0,0 @@
1
- import Checkbox from "./Checkbox";
2
- import Input from "./Input";
3
- import Select from "./Select";
4
- import ReactSelect from "./ReactSelect";
5
- import SrcSet from './SrcSet';
6
-
7
- export default Object.assign<
8
- typeof Input,
9
- {
10
- Select: typeof Select;
11
- ReactSelect: typeof ReactSelect;
12
- Checkbox: typeof Checkbox;
13
- SrcSet: typeof SrcSet;
14
- }
15
- >(Input, {
16
- Select,
17
- ReactSelect,
18
- Checkbox,
19
- SrcSet,
20
- });
@@ -1,57 +0,0 @@
1
- import React, { useRef } from "react";
2
- import CSSTransition from "react-transition-group/CSSTransition";
3
-
4
- import CloseIcon from "../../../icons/close";
5
-
6
- interface ModalProps extends React.PropsWithChildren {
7
- open: boolean;
8
- onClose: () => void;
9
- title?: string;
10
- }
11
-
12
- const Modal = ({ open, onClose, title, children }: ModalProps) => {
13
- const nodeRef = useRef(null);
14
- return (
15
- <CSSTransition
16
- ref={nodeRef}
17
- in={open}
18
- timeout={{ enter: 250, exit: 350 }}
19
- classNames="khb_modal"
20
- mountOnEnter
21
- unmountOnExit
22
- >
23
- <div className="khb_modal-wrapper-1" ref={nodeRef} data-testid="modal">
24
- <div className="khb_modal-wrapper-2">
25
- <div
26
- className="khb_modal-backdrop"
27
- role="button"
28
- onClick={onClose}
29
- onKeyDown={onClose}
30
- tabIndex={0}
31
- />
32
- <div className="khb_modal-container-1">
33
- <div className="khb_modal-container-2">
34
- <div className="khb_modal-main">
35
- <div className="khb_modal-header">
36
- <span className="khb_modal-title">{title}</span>
37
- <button
38
- className="khb_modal-close"
39
- onClick={onClose}
40
- onKeyDown={onClose}
41
- tabIndex={-1}
42
- data-testid="modal-close"
43
- >
44
- <CloseIcon />
45
- </button>
46
- </div>
47
- <div className="p-4">{children}</div>
48
- </div>
49
- </div>
50
- </div>
51
- </div>
52
- </div>
53
- </CSSTransition>
54
- );
55
- };
56
-
57
- export default Modal;
@@ -1,3 +0,0 @@
1
- import Modal from "./Modal"
2
-
3
- export default Modal
@@ -1,88 +0,0 @@
1
- import React from 'react';
2
- import { PaginationProps } from '../../../types';
3
- import { TRANSLATION_PAIRS_COMMON } from '../../../constants/common';
4
- import ChevronLeft from '../../../icons/chevronLeft';
5
- import ChevronRight from '../../../icons/chevronRight';
6
- import Button from '../Button';
7
- import Input from '../Input';
8
-
9
- const Pagination = ({
10
- currentPage,
11
- pageSize,
12
- totalPages,
13
- totalRecords,
14
- setCurrentPage,
15
- showingText = TRANSLATION_PAIRS_COMMON.showing,
16
- pageText = TRANSLATION_PAIRS_COMMON.page,
17
- ofText = TRANSLATION_PAIRS_COMMON.of,
18
- previousContent,
19
- nextContent,
20
- }: PaginationProps) => {
21
- const updatePagination = (newValue: number | string | undefined) => {
22
- if (newValue && typeof newValue === 'number') {
23
- if (newValue <= 0) {
24
- newValue = 1;
25
- } else if (newValue > totalPages) {
26
- newValue = totalPages;
27
- }
28
- setCurrentPage(newValue);
29
- }
30
- };
31
- const onPaginationButtonClick = (dir: 'next' | 'previous') => {
32
- if (dir === 'next') {
33
- updatePagination(currentPage + 1);
34
- } else {
35
- updatePagination(currentPage - 1);
36
- }
37
- };
38
- return (
39
- <nav className="khb_pagination" aria-label="Table navigation">
40
- <span className="khb_pagination-total">
41
- {showingText}{' '}
42
- <span className="khb_pagination-total-showing">
43
- {!totalRecords ? 0 : (currentPage - 1) * pageSize + 1}
44
- </span>{' '}
45
- -{' '}
46
- <span className="khb_pagination-total-showing">
47
- {Math.min(currentPage * pageSize, totalRecords)}
48
- </span>{' '}
49
- {ofText} {totalRecords}
50
- </span>
51
- <ul className="khb_pagination-actions">
52
- <Button
53
- size="xs"
54
- type="secondary"
55
- className="khb_pagination-previous"
56
- disabled={currentPage - 1 <= 0}
57
- onClick={() => onPaginationButtonClick('previous')}
58
- >
59
- {previousContent || <ChevronLeft srText="Previous" />}
60
- </Button>
61
- <div className="khb_pagination-pager">
62
- {pageText}{' '}
63
- <Input
64
- className="mx-2"
65
- size="xs"
66
- type="number"
67
- id="page"
68
- value={currentPage}
69
- onChange={(e) => updatePagination(Number(e.target.value))}
70
- disabled={!totalRecords}
71
- />{' '}
72
- / {totalPages}
73
- </div>
74
- <Button
75
- size="xs"
76
- type="secondary"
77
- className="khb_pagination-next"
78
- disabled={currentPage >= totalPages}
79
- onClick={() => onPaginationButtonClick('next')}
80
- >
81
- {nextContent || <ChevronRight srText="Next" />}
82
- </Button>
83
- </ul>
84
- </nav>
85
- );
86
- };
87
-
88
- export default Pagination;