funda-ui 1.0.272

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 (246) hide show
  1. package/BackToTop/index.css +34 -0
  2. package/BackToTop/index.d.ts +11 -0
  3. package/BackToTop/index.js +458 -0
  4. package/CascadingSelect/index.css +159 -0
  5. package/CascadingSelect/index.d.ts +56 -0
  6. package/CascadingSelect/index.js +958 -0
  7. package/CascadingSelectE2E/index.css +159 -0
  8. package/CascadingSelectE2E/index.d.ts +60 -0
  9. package/CascadingSelectE2E/index.js +1126 -0
  10. package/Checkbox/index.d.ts +30 -0
  11. package/Checkbox/index.js +226 -0
  12. package/ColorPicker/index.css +38 -0
  13. package/ColorPicker/index.d.ts +27 -0
  14. package/ColorPicker/index.js +246 -0
  15. package/DigitalClock/index.d.ts +7 -0
  16. package/DigitalClock/index.js +208 -0
  17. package/DropdownMenu/index.css +127 -0
  18. package/DropdownMenu/index.d.ts +37 -0
  19. package/DropdownMenu/index.js +237 -0
  20. package/DynamicFields/index.d.ts +26 -0
  21. package/DynamicFields/index.js +412 -0
  22. package/File/index.d.ts +36 -0
  23. package/File/index.js +473 -0
  24. package/Input/index.d.ts +42 -0
  25. package/Input/index.js +286 -0
  26. package/LiveSearch/index.d.ts +37 -0
  27. package/LiveSearch/index.js +1195 -0
  28. package/ModalDialog/index.d.ts +60 -0
  29. package/ModalDialog/index.js +725 -0
  30. package/ModeSwitch/index.d.ts +17 -0
  31. package/ModeSwitch/index.js +202 -0
  32. package/MultiFuncSelect/index.css +178 -0
  33. package/MultiFuncSelect/index.d.ts +67 -0
  34. package/MultiFuncSelect/index.js +1826 -0
  35. package/MultilevelDropdownMenu/index.css +35 -0
  36. package/MultilevelDropdownMenu/index.d.ts +25 -0
  37. package/MultilevelDropdownMenu/index.js +464 -0
  38. package/Pagination/index.d.ts +49 -0
  39. package/Pagination/index.js +341 -0
  40. package/README.md +108 -0
  41. package/Radio/index.d.ts +31 -0
  42. package/Radio/index.js +246 -0
  43. package/RangeSlider/index.css +149 -0
  44. package/RangeSlider/index.d.ts +21 -0
  45. package/RangeSlider/index.js +730 -0
  46. package/ScrollReveal/index.css +23 -0
  47. package/ScrollReveal/index.d.ts +21 -0
  48. package/ScrollReveal/index.js +216 -0
  49. package/Scrollbar/index.css +168 -0
  50. package/Scrollbar/index.d.ts +15 -0
  51. package/Scrollbar/index.js +605 -0
  52. package/SearchBar/index.d.ts +32 -0
  53. package/SearchBar/index.js +246 -0
  54. package/Select/index.d.ts +34 -0
  55. package/Select/index.js +331 -0
  56. package/ShowMoreLess/index.css +23 -0
  57. package/ShowMoreLess/index.d.ts +30 -0
  58. package/ShowMoreLess/index.js +202 -0
  59. package/Switch/index.d.ts +29 -0
  60. package/Switch/index.js +211 -0
  61. package/Table/index.css +533 -0
  62. package/Table/index.d.ts +25 -0
  63. package/Table/index.js +2113 -0
  64. package/Tabs/index.d.ts +3 -0
  65. package/Tabs/index.js +323 -0
  66. package/TagInput/index.css +90 -0
  67. package/TagInput/index.d.ts +28 -0
  68. package/TagInput/index.js +370 -0
  69. package/Textarea/index.d.ts +30 -0
  70. package/Textarea/index.js +242 -0
  71. package/Toast/index.css +95 -0
  72. package/Toast/index.d.ts +35 -0
  73. package/Toast/index.js +340 -0
  74. package/Tooltip/index.css +240 -0
  75. package/Tooltip/index.d.ts +19 -0
  76. package/Tooltip/index.js +200 -0
  77. package/Tree/index.css +225 -0
  78. package/Tree/index.d.ts +37 -0
  79. package/Tree/index.js +1406 -0
  80. package/all.d.ts +33 -0
  81. package/all.js +35 -0
  82. package/lib/cjs/BackToTop/index.d.ts +11 -0
  83. package/lib/cjs/BackToTop/index.js +458 -0
  84. package/lib/cjs/CascadingSelect/index.d.ts +56 -0
  85. package/lib/cjs/CascadingSelect/index.js +958 -0
  86. package/lib/cjs/CascadingSelectE2E/index.d.ts +60 -0
  87. package/lib/cjs/CascadingSelectE2E/index.js +1126 -0
  88. package/lib/cjs/Checkbox/index.d.ts +30 -0
  89. package/lib/cjs/Checkbox/index.js +226 -0
  90. package/lib/cjs/ColorPicker/index.d.ts +27 -0
  91. package/lib/cjs/ColorPicker/index.js +246 -0
  92. package/lib/cjs/DigitalClock/index.d.ts +7 -0
  93. package/lib/cjs/DigitalClock/index.js +208 -0
  94. package/lib/cjs/DropdownMenu/index.d.ts +37 -0
  95. package/lib/cjs/DropdownMenu/index.js +237 -0
  96. package/lib/cjs/DynamicFields/index.d.ts +26 -0
  97. package/lib/cjs/DynamicFields/index.js +412 -0
  98. package/lib/cjs/File/index.d.ts +36 -0
  99. package/lib/cjs/File/index.js +473 -0
  100. package/lib/cjs/Input/index.d.ts +42 -0
  101. package/lib/cjs/Input/index.js +286 -0
  102. package/lib/cjs/LiveSearch/index.d.ts +37 -0
  103. package/lib/cjs/LiveSearch/index.js +1195 -0
  104. package/lib/cjs/ModalDialog/index.d.ts +60 -0
  105. package/lib/cjs/ModalDialog/index.js +725 -0
  106. package/lib/cjs/ModeSwitch/index.d.ts +17 -0
  107. package/lib/cjs/ModeSwitch/index.js +202 -0
  108. package/lib/cjs/MultiFuncSelect/index.d.ts +67 -0
  109. package/lib/cjs/MultiFuncSelect/index.js +1826 -0
  110. package/lib/cjs/MultilevelDropdownMenu/index.d.ts +25 -0
  111. package/lib/cjs/MultilevelDropdownMenu/index.js +464 -0
  112. package/lib/cjs/Pagination/index.d.ts +49 -0
  113. package/lib/cjs/Pagination/index.js +341 -0
  114. package/lib/cjs/Radio/index.d.ts +31 -0
  115. package/lib/cjs/Radio/index.js +246 -0
  116. package/lib/cjs/RangeSlider/index.d.ts +21 -0
  117. package/lib/cjs/RangeSlider/index.js +730 -0
  118. package/lib/cjs/ScrollReveal/index.d.ts +21 -0
  119. package/lib/cjs/ScrollReveal/index.js +216 -0
  120. package/lib/cjs/Scrollbar/index.d.ts +15 -0
  121. package/lib/cjs/Scrollbar/index.js +605 -0
  122. package/lib/cjs/SearchBar/index.d.ts +32 -0
  123. package/lib/cjs/SearchBar/index.js +246 -0
  124. package/lib/cjs/Select/index.d.ts +34 -0
  125. package/lib/cjs/Select/index.js +331 -0
  126. package/lib/cjs/ShowMoreLess/index.d.ts +30 -0
  127. package/lib/cjs/ShowMoreLess/index.js +202 -0
  128. package/lib/cjs/Switch/index.d.ts +29 -0
  129. package/lib/cjs/Switch/index.js +211 -0
  130. package/lib/cjs/Table/index.d.ts +25 -0
  131. package/lib/cjs/Table/index.js +2113 -0
  132. package/lib/cjs/Tabs/index.d.ts +3 -0
  133. package/lib/cjs/Tabs/index.js +323 -0
  134. package/lib/cjs/TagInput/index.d.ts +28 -0
  135. package/lib/cjs/TagInput/index.js +370 -0
  136. package/lib/cjs/Textarea/index.d.ts +30 -0
  137. package/lib/cjs/Textarea/index.js +242 -0
  138. package/lib/cjs/Toast/index.d.ts +35 -0
  139. package/lib/cjs/Toast/index.js +340 -0
  140. package/lib/cjs/Tooltip/index.d.ts +19 -0
  141. package/lib/cjs/Tooltip/index.js +200 -0
  142. package/lib/cjs/Tree/index.d.ts +37 -0
  143. package/lib/cjs/Tree/index.js +1406 -0
  144. package/lib/cjs/index.d.ts +33 -0
  145. package/lib/cjs/index.js +35 -0
  146. package/lib/css/BackToTop/index.css +34 -0
  147. package/lib/css/CascadingSelect/index.css +159 -0
  148. package/lib/css/CascadingSelectE2E/index.css +159 -0
  149. package/lib/css/ColorPicker/index.css +38 -0
  150. package/lib/css/DropdownMenu/index.css +127 -0
  151. package/lib/css/MultiFuncSelect/index.css +178 -0
  152. package/lib/css/MultilevelDropdownMenu/index.css +35 -0
  153. package/lib/css/RangeSlider/index.css +149 -0
  154. package/lib/css/ScrollReveal/index.css +23 -0
  155. package/lib/css/Scrollbar/index.css +168 -0
  156. package/lib/css/ShowMoreLess/index.css +23 -0
  157. package/lib/css/Table/index.css +533 -0
  158. package/lib/css/TagInput/index.css +90 -0
  159. package/lib/css/Toast/index.css +95 -0
  160. package/lib/css/Tooltip/index.css +240 -0
  161. package/lib/css/Tree/index.css +225 -0
  162. package/lib/esm/BackToTop/index.scss +47 -0
  163. package/lib/esm/BackToTop/index.tsx +182 -0
  164. package/lib/esm/BackToTop/utils/easing.js +200 -0
  165. package/lib/esm/BackToTop/utils/performance.js +52 -0
  166. package/lib/esm/CascadingSelect/Group.tsx +39 -0
  167. package/lib/esm/CascadingSelect/index.scss +214 -0
  168. package/lib/esm/CascadingSelect/index.tsx +922 -0
  169. package/lib/esm/CascadingSelect/utils/performance.js +52 -0
  170. package/lib/esm/CascadingSelectE2E/Group.tsx +39 -0
  171. package/lib/esm/CascadingSelectE2E/index.scss +214 -0
  172. package/lib/esm/CascadingSelectE2E/index.tsx +1091 -0
  173. package/lib/esm/CascadingSelectE2E/utils/performance.js +52 -0
  174. package/lib/esm/Checkbox/index.tsx +160 -0
  175. package/lib/esm/ColorPicker/index.scss +48 -0
  176. package/lib/esm/ColorPicker/index.tsx +187 -0
  177. package/lib/esm/DigitalClock/index.tsx +72 -0
  178. package/lib/esm/DigitalClock/utils/useInterval.js +43 -0
  179. package/lib/esm/DropdownMenu/Option.tsx +27 -0
  180. package/lib/esm/DropdownMenu/index.scss +180 -0
  181. package/lib/esm/DropdownMenu/index.tsx +148 -0
  182. package/lib/esm/DynamicFields/index.tsx +386 -0
  183. package/lib/esm/File/index.tsx +302 -0
  184. package/lib/esm/Input/index.tsx +233 -0
  185. package/lib/esm/LiveSearch/index.tsx +582 -0
  186. package/lib/esm/LiveSearch/utils/performance.js +52 -0
  187. package/lib/esm/LiveSearch/utils/useThrottle.js +36 -0
  188. package/lib/esm/ModalDialog/index.tsx +479 -0
  189. package/lib/esm/ModalDialog/plugins/BSL/bodyScrollLock.es6.js +262 -0
  190. package/lib/esm/ModalDialog/plugins/BSL/index.ts +2 -0
  191. package/lib/esm/ModeSwitch/index.tsx +82 -0
  192. package/lib/esm/MultiFuncSelect/index.scss +269 -0
  193. package/lib/esm/MultiFuncSelect/index.tsx +1597 -0
  194. package/lib/esm/MultiFuncSelect/utils/performance.js +52 -0
  195. package/lib/esm/MultiFuncSelect/utils/tree.js +103 -0
  196. package/lib/esm/MultiFuncSelect/utils/useThrottle.js +36 -0
  197. package/lib/esm/MultilevelDropdownMenu/MenuList.tsx +230 -0
  198. package/lib/esm/MultilevelDropdownMenu/index.scss +75 -0
  199. package/lib/esm/MultilevelDropdownMenu/index.tsx +71 -0
  200. package/lib/esm/MultilevelDropdownMenu/utils/dom.js +81 -0
  201. package/lib/esm/Pagination/index.tsx +230 -0
  202. package/lib/esm/Pagination/pagination-navigators.tsx +60 -0
  203. package/lib/esm/Radio/index.tsx +201 -0
  204. package/lib/esm/RangeSlider/index.scss +184 -0
  205. package/lib/esm/RangeSlider/index.tsx +223 -0
  206. package/lib/esm/ScrollReveal/index.scss +27 -0
  207. package/lib/esm/ScrollReveal/index.tsx +146 -0
  208. package/lib/esm/Scrollbar/index.scss +217 -0
  209. package/lib/esm/Scrollbar/index.tsx +497 -0
  210. package/lib/esm/Scrollbar/utils/performance.js +52 -0
  211. package/lib/esm/SearchBar/index.tsx +181 -0
  212. package/lib/esm/Select/index.tsx +276 -0
  213. package/lib/esm/ShowMoreLess/index.scss +27 -0
  214. package/lib/esm/ShowMoreLess/index.tsx +144 -0
  215. package/lib/esm/Switch/index.tsx +143 -0
  216. package/lib/esm/Table/TableColgroup.tsx +29 -0
  217. package/lib/esm/Table/TableField.tsx +40 -0
  218. package/lib/esm/Table/TableFieldRow.tsx +212 -0
  219. package/lib/esm/Table/TableHeaders.tsx +146 -0
  220. package/lib/esm/Table/TableRow.tsx +127 -0
  221. package/lib/esm/Table/TableSummaries.tsx +36 -0
  222. package/lib/esm/Table/index.scss +364 -0
  223. package/lib/esm/Table/index.tsx +576 -0
  224. package/lib/esm/Table/table-utils.ts +65 -0
  225. package/lib/esm/Table/utils/dom.js +81 -0
  226. package/lib/esm/Table/utils/performance.js +52 -0
  227. package/lib/esm/Tabs/TabList.tsx +42 -0
  228. package/lib/esm/Tabs/TabPanel.tsx +34 -0
  229. package/lib/esm/Tabs/Tabs.tsx +232 -0
  230. package/lib/esm/Tabs/index.tsx +3 -0
  231. package/lib/esm/TagInput/index.scss +125 -0
  232. package/lib/esm/TagInput/index.tsx +314 -0
  233. package/lib/esm/Textarea/index.tsx +178 -0
  234. package/lib/esm/Toast/Item.tsx +75 -0
  235. package/lib/esm/Toast/index.scss +120 -0
  236. package/lib/esm/Toast/index.tsx +249 -0
  237. package/lib/esm/Tooltip/index.scss +327 -0
  238. package/lib/esm/Tooltip/index.tsx +142 -0
  239. package/lib/esm/Tree/TreeList.tsx +503 -0
  240. package/lib/esm/Tree/index.scss +375 -0
  241. package/lib/esm/Tree/index.tsx +301 -0
  242. package/lib/esm/Tree/init-height.tsx +27 -0
  243. package/lib/esm/Tree/utils/convert-tree.js +29 -0
  244. package/lib/esm/Tree/utils/dom.js +81 -0
  245. package/lib/esm/index.js +31 -0
  246. package/package.json +40 -0
@@ -0,0 +1,230 @@
1
+ import React from 'react';
2
+ import { paginationNavigators } from './pagination-navigators';
3
+
4
+
5
+ type PaginationProps = {
6
+ /** The class name of the navigation wrapper */
7
+ wrapperClassName?: string;
8
+ /** The class name of the navigation */
9
+ navClassName?: string;
10
+ /** An API URL Path. Use `{page}` characters to place a placeholder. such as `/mypage/{page}` */
11
+ apiUrl: string;
12
+ /** The range of pages displayed */
13
+ pageRangeDisplayed: number;
14
+ /** The currently selected page number. */
15
+ activePage: number;
16
+ /** The total number of pages. */
17
+ totalPages: number;
18
+ /** Label for the previous button. */
19
+ previousLabel?: React.ReactNode;
20
+ /** Label for the next button. */
21
+ nextLabel?: React.ReactNode;
22
+ /** Label for the first button. */
23
+ firstLabel?: React.ReactNode;
24
+ /** Label for the last button. */
25
+ lastLabel?: React.ReactNode;
26
+ /** Label for ellipsis */
27
+ breakLabel?: React.ReactNode;
28
+ /** Set the alignment of the control */
29
+ align?: string | null;
30
+ /** Only display the previous and next buttons. */
31
+ onlyPrevNext?: boolean;
32
+ /** The classname for the active page */
33
+ activeClass?: string;
34
+ /** The classname on tag li of the previous button */
35
+ previousClass?: string;
36
+ /** The classname on tag li of the next button */
37
+ nextClass?: string;
38
+ /** The classname on tag li of the first button */
39
+ firstClass?: string;
40
+ /** The classname on tag li of the last button */
41
+ lastClass?: string;
42
+ /** The classname for disabled buttons */
43
+ disabledClass?: string;
44
+ /** The activation button is symmetrical on the left and right sides. */
45
+ symmetry?: boolean;
46
+ /** -- */
47
+ style?: React.CSSProperties;
48
+ /** The method to call when a page is clicked. Exposes the current page number as an argument. */
49
+ onChange?: (param: any) => void;
50
+
51
+
52
+ };
53
+
54
+ const Pagination = (props: PaginationProps) => {
55
+ const {
56
+ wrapperClassName,
57
+ navClassName,
58
+ apiUrl,
59
+ pageRangeDisplayed,
60
+ activePage,
61
+ totalPages,
62
+ previousLabel,
63
+ nextLabel,
64
+ firstLabel,
65
+ lastLabel,
66
+ breakLabel,
67
+ align,
68
+ onlyPrevNext,
69
+ activeClass,
70
+ previousClass,
71
+ nextClass,
72
+ firstClass,
73
+ lastClass,
74
+ disabledClass,
75
+ symmetry,
76
+ style,
77
+ onChange
78
+ } = props;
79
+
80
+
81
+ function handleClick(parameter: any) {
82
+
83
+ switch (parameter) {
84
+ case "prev":
85
+ onChange?.(activePage - 1);
86
+ break;
87
+ case "next":
88
+ onChange?.(activePage + 1);
89
+ break;
90
+ case "first":
91
+ onChange?.(1);
92
+ break;
93
+ case "last":
94
+ onChange?.(totalPages);
95
+ break;
96
+ default:
97
+ onChange?.(1);
98
+ break;
99
+ }
100
+ }
101
+
102
+ const visibleNavigators = pageRangeDisplayed ? pageRangeDisplayed : 3;
103
+
104
+ let alignClassName = '';
105
+ switch (align) {
106
+ case 'left':
107
+ alignClassName = ' justify-content-start';
108
+ break;
109
+ case 'right':
110
+ alignClassName = ' justify-content-end';
111
+ break;
112
+ case 'center':
113
+ alignClassName = ' justify-content-center';
114
+ break;
115
+ }
116
+
117
+ const _activeClassName = activeClass ? activeClass : 'active',
118
+ _previousClassName = previousClass ? previousClass : 'prev',
119
+ _nextClassName = nextClass ? nextClass : 'next',
120
+ _firstClassName = firstClass ? firstClass : 'first',
121
+ _lastClassName = lastClass ? lastClass : 'last',
122
+ _disabledClassName = disabledClass ? disabledClass :'disabled',
123
+ _onlyPrevNextButtons = typeof (onlyPrevNext) === 'undefined' ? false : onlyPrevNext,
124
+ _symmetry = typeof (symmetry) === 'undefined' ? false : symmetry;
125
+
126
+
127
+ //get navigation array
128
+ //------------------------------------------
129
+ const navArr = paginationNavigators(visibleNavigators, totalPages, activePage, true, _symmetry);
130
+
131
+
132
+ // Use ellipsis to extend page numbers
133
+ //------------------------------------------
134
+ let _ellipsis = breakLabel ? breakLabel : '';
135
+ let _ellipsisArr: any[any] = [];
136
+ let _ellipsisEnabled = false;
137
+
138
+ if (_ellipsis !== '') _ellipsisArr = [totalPages - 1, totalPages];
139
+ if (activePage + 2 >= totalPages) {
140
+ _ellipsisArr = [];
141
+ _ellipsis = '';
142
+ }
143
+
144
+ const _ellipsisElements = _ellipsisArr.map((item: any, i: number) => {
145
+ if (item > 0 && item <= totalPages && !_onlyPrevNextButtons) {
146
+ //Delete values whose display range is more than the total
147
+ if (navArr.indexOf(item) === -1) {
148
+ _ellipsisEnabled = true;
149
+
150
+ return (
151
+ <li key={i} className={activePage === item ? `page-item ${_activeClassName}` : `page-item`}>
152
+ <a className="page-link" href={apiUrl.replace('{page}', item)} onClick={(e) => {
153
+ e.preventDefault();
154
+ onChange?.(item);
155
+ }}>{item}</a>
156
+ </li>
157
+ );
158
+ }
159
+ }
160
+ });
161
+
162
+ return (
163
+ <>
164
+
165
+ <nav className={wrapperClassName || wrapperClassName === '' ? wrapperClassName : "mb-3 position-relative"} style={style}>
166
+ <ul className={navClassName ? `${navClassName} ${alignClassName}` : `pagination ${alignClassName}`}>
167
+ {firstLabel ? (
168
+ <li className={activePage > 1 ? `page-item ${_firstClassName}` : `page-item ${_firstClassName} ${_disabledClassName}`}>
169
+ <a tabIndex={activePage > 1 ? 0 : -1} aria-disabled={activePage > 1 ? 'false' : 'true'}className="page-link" href={apiUrl.replace('{page}', '1')} onClick={(e) => { e.preventDefault(); handleClick('first'); }}>
170
+ {firstLabel || null}
171
+ </a>
172
+ </li>
173
+ ) : ''}
174
+
175
+ {previousLabel ? (
176
+ <li className={activePage > 1 ? `page-item ${_previousClassName}` : `page-item ${_previousClassName} ${_disabledClassName}`}>
177
+ <a tabIndex={activePage > 1 ? 0 : -1} aria-disabled={activePage > 1 ? 'false' : 'true'}className="page-link" href={apiUrl.replace('{page}', (activePage - 1) as any)} onClick={(e) => { e.preventDefault(); handleClick('prev'); }}>
178
+ {previousLabel || null}
179
+ </a>
180
+ </li>
181
+ ) : ''}
182
+
183
+
184
+ {
185
+ navArr.map((item: any, i: number) => {
186
+ if (item > 0 && item <= totalPages && !_onlyPrevNextButtons) {
187
+ return (
188
+ <li key={i} className={activePage === item ? `page-item ${_activeClassName}` : `page-item`}>
189
+ <a className="page-link" href={apiUrl.replace('{page}', item)} onClick={(e) => {
190
+ e.preventDefault();
191
+ onChange?.(item);
192
+ }}>{item}</a>
193
+ </li>
194
+ );
195
+ }
196
+
197
+ })
198
+ }
199
+
200
+
201
+ {_ellipsis !== '' && _ellipsisEnabled ? <><li className="page-item"><span className="page-link">{_ellipsis}</span></li></> : ''}
202
+ {_ellipsisElements}
203
+
204
+ {nextLabel ? (
205
+ <li className={activePage < totalPages ? `page-item ${_nextClassName}` : `page-item ${_nextClassName} ${_disabledClassName}`}>
206
+ <a tabIndex={activePage < totalPages ? 0 : -1} aria-disabled={activePage < totalPages ? 'false' : 'true'} className="page-link" href={apiUrl.replace('{page}', (activePage + 1) as any)} onClick={(e) => { e.preventDefault(); handleClick('next'); }}>
207
+ {nextLabel || null}
208
+ </a>
209
+ </li>
210
+ ) : ''}
211
+
212
+
213
+ {lastLabel ? (
214
+ <li className={activePage < totalPages ? `page-item ${_lastClassName}` : `page-item ${_lastClassName} ${_disabledClassName}`}>
215
+ <a tabIndex={activePage < totalPages ? 0 : -1} aria-disabled={activePage < totalPages ? 'false' : 'true'} className="page-link" href={apiUrl.replace('{page}', totalPages as any)} onClick={(e) => { e.preventDefault(); handleClick('last'); }}>
216
+ {lastLabel || null}
217
+ </a>
218
+ </li>
219
+ ) : ''}
220
+
221
+ </ul>
222
+
223
+ </nav>
224
+
225
+
226
+ </>
227
+ )
228
+ };
229
+
230
+ export default Pagination;
@@ -0,0 +1,60 @@
1
+
2
+ /*
3
+ * Generate page navigators
4
+ *
5
+ * @param {Number} visibleNavigators - The range of pages displayed.
6
+ * @param {Number} totalPages - The total number of pages.
7
+ * @param {Number} activePage - The currently selected page number.
8
+ * @param {Boolean} adjustmentEnabled - Whether to complete the page number range.
9
+ * @param {Boolean} symmetry - The activation button is symmetrical on the left and right sides.
10
+ * @return {Array} - Return an array.
11
+ */
12
+ export function paginationNavigators(visibleNavigators: number, totalPages: number, activePage: number, adjustmentEnabled = true, symmetry = false) {
13
+
14
+ // Generate a sequence of numbers
15
+ // Since the array is initialized with `undefined` on each position,
16
+ // the value of `v` below will be `undefined`
17
+
18
+ let result: any[number] = [];
19
+ if ((activePage + visibleNavigators - 1) < totalPages) {
20
+ result = Array.from({ length: visibleNavigators }, (v, k) => k + activePage);
21
+ } else {
22
+ let diff = totalPages - activePage;
23
+ if (diff >= 0) {
24
+ result = Array.from({ length: diff + 1 }, (v, k) => k + activePage);
25
+ }
26
+
27
+ }
28
+
29
+ //Shift the elements forward to complete the display range
30
+ const adjustmentResult = ( arr: any[] ) => {
31
+ if ( arr.length < totalPages ) {
32
+ let adjustment = visibleNavigators - arr.length;
33
+ for (let i = 1; i <= adjustment; i++) {
34
+ arr.unshift(activePage - i);
35
+ }
36
+ }
37
+ return arr;
38
+ };
39
+
40
+ if ( adjustmentEnabled ) result = adjustmentResult(result);
41
+
42
+
43
+ // symmetrical on the left and right sides
44
+ if ( symmetry ) {
45
+ if ( totalPages > activePage ) {
46
+ const totalDisplayedPages = visibleNavigators + (visibleNavigators - 1);
47
+ const activedPageIndex = result.indexOf(activePage);
48
+ const leftSideTotal = (visibleNavigators - 1) - activedPageIndex;
49
+
50
+ for (let i = 1; i <= leftSideTotal; i++) {
51
+ result.unshift(activePage - i - activedPageIndex);
52
+ }
53
+ }
54
+ }
55
+
56
+
57
+ return result;
58
+ }
59
+
60
+ export default paginationNavigators;
@@ -0,0 +1,201 @@
1
+ import React, { useId, useRef, useState, useEffect } from 'react';
2
+
3
+ declare module 'react' {
4
+ interface ReactI18NextChildren<T> {
5
+ children?: any;
6
+ }
7
+ }
8
+
9
+ type RadioOptionChangeFnType = (arg1: any, arg2: any) => void;
10
+
11
+
12
+ type RadioProps = {
13
+ wrapperClassName?: string;
14
+ value?: string;
15
+ label?: React.ReactNode | string;
16
+ name?: string;
17
+ disabled?: any;
18
+ required?: any;
19
+ options: string;
20
+ inline?: boolean;
21
+ /** -- */
22
+ id?: string;
23
+ style?: React.CSSProperties;
24
+ tabIndex?: number;
25
+ [key: `data-${string}`]: string | undefined;
26
+ /** This function is called whenever the data is updated.
27
+ * Exposes the JSON format data about the option as an argument.
28
+ */
29
+ onClick?: RadioOptionChangeFnType | null;
30
+ onChange?: RadioOptionChangeFnType | null;
31
+ onBlur?: (e: any) => void;
32
+ onFocus?: (e: any) => void;
33
+ };
34
+
35
+ const Radio = (props: RadioProps) => {
36
+ const {
37
+ wrapperClassName,
38
+ disabled,
39
+ required,
40
+ value,
41
+ label,
42
+ name,
43
+ id,
44
+ options,
45
+ inline,
46
+ style,
47
+ tabIndex,
48
+ onClick,
49
+ onChange,
50
+ onBlur,
51
+ onFocus,
52
+ ...attributes
53
+ } = props;
54
+
55
+ const uniqueID = useId();
56
+ const idRes = id || uniqueID;
57
+ const rootRef = useRef<any>(null);
58
+ const [val, setVal] = useState<any>(null);
59
+
60
+ // Determine whether it is in JSON format
61
+ function isJSON(str: any) {
62
+
63
+ if (typeof (str) === 'string' && str.length > 0) {
64
+
65
+ if (str.replace(/\"\"/g, '').replace(/\,/g, '') == '[{}]') {
66
+ return false;
67
+ } else {
68
+
69
+ if (/^[\],:{}\s]*$/.test(str.replace(/\\["\\\/bfnrtu]/g, '@').
70
+ replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
71
+ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
72
+
73
+ return true;
74
+
75
+ } else {
76
+ return false;
77
+ }
78
+
79
+ }
80
+
81
+ } else {
82
+
83
+ if (
84
+ typeof (str) === 'object' &&
85
+ Object.prototype.toString.call(str) === '[object Object]' &&
86
+ !str.length
87
+ ) {
88
+ return true;
89
+ } else {
90
+ return false;
91
+ }
92
+
93
+ }
94
+
95
+ }
96
+
97
+ function handleFocus(event: any) {
98
+ event.target.parentElement.classList.add('focus');
99
+
100
+ //
101
+ onFocus?.(event);
102
+ }
103
+
104
+
105
+ function handleChange(event: any) {
106
+ const _val = event.target.value;
107
+
108
+ setVal(_val);
109
+
110
+
111
+ //----
112
+ //remove focus style
113
+ [].slice.call(rootRef.current.querySelectorAll('.form-check-input')).forEach( (el: any) => {
114
+ el.parentElement?.classList.remove('focus');
115
+ });
116
+
117
+
118
+ //
119
+ if (typeof (onChange) === 'function') {
120
+ onChange(event, _val);
121
+ }
122
+ if (typeof (onClick) === 'function') {
123
+ onClick(event, _val);
124
+ }
125
+
126
+
127
+ }
128
+
129
+
130
+ function handleBlur(event: any) {
131
+
132
+ //----
133
+ //remove focus style
134
+ event.target.parentElement.classList.remove('focus');
135
+
136
+ //
137
+ onBlur?.(event);
138
+ }
139
+
140
+
141
+
142
+ // Get all options from option prop
143
+ const selectOptions = isJSON(options) ? JSON.parse(options) : null;
144
+ const optionKeys = selectOptions === null ? [] : Object.keys(selectOptions);
145
+ const optionValues = selectOptions === null ? [] : Object.values(selectOptions).map((item: any) => item.toString() );
146
+
147
+
148
+
149
+ const radioOptionsList = optionKeys.map((radioOption, index) => {
150
+ const requiredVal = index === 0 ? required || null : null;
151
+
152
+
153
+ return <div key={index} className={inline ? `form-check form-check-inline` : `form-check`}>
154
+ <input
155
+ tabIndex={tabIndex || 0}
156
+ type="radio"
157
+ className="form-check-input"
158
+ id={`field-${uniqueID}-${index}`}
159
+ name={name}
160
+ value={optionValues[index] as string}
161
+ required={requiredVal}
162
+ disabled={disabled || null}
163
+ onChange={handleChange}
164
+ onClick={typeof (onClick) === 'function' ? handleChange : () => void(0)}
165
+ onFocus={handleFocus}
166
+ onBlur={handleBlur}
167
+ checked={val == optionValues[index]} // component status will not change if defaultChecked is used
168
+ style={style}
169
+ {...attributes}
170
+ />
171
+ <label className="form-check-label" htmlFor={`field-${uniqueID}-${index}`} dangerouslySetInnerHTML={{
172
+ __html: radioOption
173
+ }}></label>
174
+ </div>;
175
+
176
+ });
177
+
178
+
179
+
180
+ useEffect(() => {
181
+ setVal(value);
182
+ }, [value, options]);
183
+
184
+
185
+
186
+ return (
187
+ <>
188
+
189
+ <div className={wrapperClassName || wrapperClassName === '' ? wrapperClassName : "mb-3 position-relative"} ref={rootRef}>
190
+ {label ? <><label htmlFor={idRes} className="form-label">{label}</label></> : null}
191
+ <div id={idRes}>
192
+ {radioOptionsList}
193
+ </div>
194
+ </div>
195
+
196
+
197
+ </>
198
+ )
199
+ };
200
+
201
+ export default Radio;
@@ -0,0 +1,184 @@
1
+ /* ======================================================
2
+ <!-- Range Slider -->
3
+ /* ====================================================== */
4
+
5
+ $thumb-size: 16px;
6
+ $control-height: 0.75rem;
7
+
8
+ @mixin track-styles {
9
+ appearance: none;
10
+ background: transparent;
11
+ border: transparent;
12
+ }
13
+
14
+ @mixin thumb-styles {
15
+ appearance: none;
16
+ pointer-events: all;
17
+ width: $thumb-size;
18
+ height: $thumb-size;
19
+ border-radius: 0px;
20
+ border: 0 none;
21
+ cursor: grab;
22
+
23
+ &:active {
24
+ cursor: grabbing;
25
+ }
26
+ }
27
+
28
+ .range-slider__wrapper {
29
+
30
+ --range-slider-grab: #0b5ed7;
31
+ --range-slider-active-grab-box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25);
32
+ --range-slider-active-grab-border-color: #86b7fe;
33
+ --range-slider-rail: #e9ecef;
34
+ --range-slider-inner-rail: #0d6efd;
35
+
36
+
37
+ > div:not(.range-slider__control-wrapper) {
38
+ width: 49% !important;
39
+ display: inline-block !important;
40
+ margin-left: 0 !important;
41
+ margin-right: 0 !important;
42
+ margin-block-start: 0 !important;
43
+ margin-block-end: 0 !important;
44
+ padding-left: 0 !important;
45
+ padding-right: 0 !important;
46
+ padding-block-start: 0 !important;
47
+ padding-block-end: 0 !important;
48
+ opacity: 0;
49
+ pointer-events: none;
50
+ }
51
+
52
+ .range-slider__control-wrapper {
53
+ width: calc(100% - $thumb-size);
54
+
55
+ .range-slider__input {
56
+ width: calc(100% + #{$thumb-size});
57
+ margin: 0 calc(#{$thumb-size} / -2);
58
+ position: absolute;
59
+ height: $thumb-size;
60
+
61
+ [type=range] {
62
+ position: absolute;
63
+ width: 100%;
64
+ pointer-events: none;
65
+ appearance: none;
66
+ height: 100%;
67
+ opacity: 0;
68
+ z-index: 3;
69
+ padding: 0;
70
+
71
+
72
+ &:disabled {
73
+ display: none;
74
+ }
75
+
76
+ &::-ms-track {
77
+ @include track-styles;
78
+ }
79
+
80
+ &::-moz-range-track {
81
+ @include track-styles;
82
+ }
83
+
84
+ &:focus::-webkit-slider-runnable-track {
85
+ @include track-styles;
86
+ }
87
+
88
+ &::-ms-thumb {
89
+ @include thumb-styles;
90
+ }
91
+
92
+ &::-moz-range-thumb {
93
+ @include thumb-styles;
94
+ }
95
+
96
+ &::-webkit-slider-thumb {
97
+ @include thumb-styles;
98
+ }
99
+ }
100
+ }
101
+
102
+
103
+ .range-slider__placeholder {
104
+ width: 100%;
105
+ position: absolute;
106
+ height: $thumb-size;
107
+
108
+ .range-slider__placeholder-grab {
109
+ width: $thumb-size;
110
+ height: $thumb-size;
111
+ border-radius: 50%;
112
+ position: absolute;
113
+ background: var(--range-slider-grab);
114
+ top: 50%;
115
+ margin-left: calc(#{$thumb-size} / -2);
116
+ transform: translate3d(0, -50%, 0);
117
+ z-index: 2;
118
+ transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
119
+
120
+ &.active {
121
+ box-shadow: var(--range-slider-active-grab-box-shadow);
122
+ border-color: var(--range-slider-active-grab-border-color);
123
+ }
124
+
125
+ &.inactive {
126
+ display: none;
127
+ }
128
+ }
129
+
130
+ .range-slider__placeholder-rail {
131
+ position: absolute;
132
+ width: 100%;
133
+ top: 50%;
134
+ transform: translateY(-50%);
135
+ height: 6px;
136
+ border-radius: 3px;
137
+ background: var(--range-slider-rail);
138
+
139
+ .range-slider__placeholder-inner-rail {
140
+ position: absolute;
141
+ height: 100%;
142
+ background: var(--range-slider-inner-rail);
143
+ opacity: 0.5;
144
+ }
145
+
146
+
147
+ }
148
+
149
+ }
150
+
151
+ .range-slider__input,
152
+ .range-slider__placeholder {
153
+ top: $control-height;
154
+ }
155
+
156
+
157
+ &.disabled .range-slider__placeholder {
158
+ filter: grayscale(1);
159
+ }
160
+
161
+
162
+
163
+ }
164
+
165
+ &.only-one {
166
+ .range-slider__control-wrapper {
167
+
168
+ .range-slider__placeholder {
169
+
170
+ .range-slider__placeholder-rail {
171
+ background: var(--range-slider-rail);
172
+
173
+ .range-slider__placeholder-inner-rail {
174
+ background: var(--range-slider-rail);
175
+ }
176
+
177
+ }
178
+
179
+ }
180
+ }
181
+
182
+ }
183
+
184
+ }