ekm-ui 0.3.74 → 0.3.78

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 (264) hide show
  1. package/.turbo/turbo-build.log +128 -128
  2. package/CHANGELOG.md +12 -0
  3. package/dist/accordion.d.ts +28 -21
  4. package/dist/accordion.mjs +1 -1
  5. package/dist/alert-banner.mjs +1 -1
  6. package/dist/avatar.mjs +1 -1
  7. package/dist/badge.mjs +1 -1
  8. package/dist/breadcrumb.mjs +1 -1
  9. package/dist/card-payment-block.css +1 -1
  10. package/dist/card-payment-block.css.map +1 -1
  11. package/dist/card-payment-block.mjs +46 -46
  12. package/dist/checkbox.mjs +1 -1
  13. package/dist/chunk-2OTVEVU7.mjs +11 -0
  14. package/dist/chunk-2OTVEVU7.mjs.map +1 -0
  15. package/dist/{chunk-47S6AX7M.mjs → chunk-2PW7KHXJ.mjs} +1 -1
  16. package/dist/chunk-2PW7KHXJ.mjs.map +1 -0
  17. package/dist/{chunk-CMA7TSQG.mjs → chunk-35VEFUPA.mjs} +4 -4
  18. package/dist/chunk-35VEFUPA.mjs.map +1 -0
  19. package/dist/{chunk-ZWJSMASL.mjs → chunk-3AGRJPPN.mjs} +3 -3
  20. package/dist/chunk-3AGRJPPN.mjs.map +1 -0
  21. package/dist/{chunk-MRJOYGDD.mjs → chunk-3TAXDPV6.mjs} +2 -2
  22. package/dist/{chunk-MRJOYGDD.mjs.map → chunk-3TAXDPV6.mjs.map} +1 -1
  23. package/dist/{chunk-5DQUZENZ.mjs → chunk-6F3XKP3G.mjs} +2 -2
  24. package/dist/chunk-6F3XKP3G.mjs.map +1 -0
  25. package/dist/{chunk-HEKVJKLH.mjs → chunk-6UK5Y6KZ.mjs} +2 -2
  26. package/dist/{chunk-HEKVJKLH.mjs.map → chunk-6UK5Y6KZ.mjs.map} +1 -1
  27. package/dist/{chunk-EWNPNF2B.mjs → chunk-76V2THLN.mjs} +3 -3
  28. package/dist/chunk-76V2THLN.mjs.map +1 -0
  29. package/dist/chunk-7GLTVVKS.mjs +12 -0
  30. package/dist/chunk-7GLTVVKS.mjs.map +1 -0
  31. package/dist/{chunk-UUWBHZKH.mjs → chunk-7MH2LXFV.mjs} +4 -4
  32. package/dist/{chunk-UUWBHZKH.mjs.map → chunk-7MH2LXFV.mjs.map} +1 -1
  33. package/dist/{chunk-7YKZ7D7U.mjs → chunk-ATNP3Z6G.mjs} +2 -2
  34. package/dist/{chunk-25FJ277C.mjs → chunk-AYH56CFA.mjs} +3 -3
  35. package/dist/chunk-AYH56CFA.mjs.map +1 -0
  36. package/dist/{chunk-NEJOZRKV.mjs → chunk-BK5RX7N5.mjs} +2 -2
  37. package/dist/chunk-BK5RX7N5.mjs.map +1 -0
  38. package/dist/{chunk-F6ZWBNIM.mjs → chunk-CIUW5YZ7.mjs} +2 -2
  39. package/dist/chunk-CIUW5YZ7.mjs.map +1 -0
  40. package/dist/{chunk-WMFTYTMD.mjs → chunk-CZC4EJOD.mjs} +3 -3
  41. package/dist/chunk-CZC4EJOD.mjs.map +1 -0
  42. package/dist/{chunk-CEK5K5TU.mjs → chunk-D3VRYN5H.mjs} +4 -4
  43. package/dist/chunk-D3VRYN5H.mjs.map +1 -0
  44. package/dist/{chunk-W3DRXKTC.mjs → chunk-DBTYTFGU.mjs} +2 -2
  45. package/dist/chunk-DBTYTFGU.mjs.map +1 -0
  46. package/dist/{chunk-JCWSMIVA.mjs → chunk-E6KQBM7F.mjs} +2 -2
  47. package/dist/chunk-E6KQBM7F.mjs.map +1 -0
  48. package/dist/{chunk-5FPVCRAI.mjs → chunk-ECOC3JRK.mjs} +1 -1
  49. package/dist/{chunk-5FPVCRAI.mjs.map → chunk-ECOC3JRK.mjs.map} +1 -1
  50. package/dist/{chunk-3LINEESX.mjs → chunk-EH3ZVEVT.mjs} +1 -1
  51. package/dist/chunk-EH3ZVEVT.mjs.map +1 -0
  52. package/dist/{chunk-YJKULMWM.mjs → chunk-EX5FMSQL.mjs} +2 -2
  53. package/dist/chunk-EX5FMSQL.mjs.map +1 -0
  54. package/dist/{chunk-ASCPOK5F.mjs → chunk-FVUORQJX.mjs} +4 -4
  55. package/dist/chunk-FVUORQJX.mjs.map +1 -0
  56. package/dist/{chunk-WFRV27QA.mjs → chunk-G5A3E5IG.mjs} +3 -3
  57. package/dist/chunk-G5A3E5IG.mjs.map +1 -0
  58. package/dist/{chunk-2IL2LP47.mjs → chunk-HOCKBMTF.mjs} +3 -3
  59. package/dist/chunk-HOCKBMTF.mjs.map +1 -0
  60. package/dist/{chunk-FRIXS4BL.mjs → chunk-JPF3K5TD.mjs} +1 -1
  61. package/dist/chunk-JPF3K5TD.mjs.map +1 -0
  62. package/dist/{chunk-AYXC2DCM.mjs → chunk-K2G6O2LX.mjs} +3 -3
  63. package/dist/chunk-K2G6O2LX.mjs.map +1 -0
  64. package/dist/chunk-LVJYP46A.mjs +9 -0
  65. package/dist/chunk-LVJYP46A.mjs.map +1 -0
  66. package/dist/{chunk-VQ3MZS4J.mjs → chunk-MPIWXVKP.mjs} +2 -2
  67. package/dist/chunk-MPIWXVKP.mjs.map +1 -0
  68. package/dist/{chunk-DZABAR36.mjs → chunk-NJC2WLYK.mjs} +2 -2
  69. package/dist/chunk-NJC2WLYK.mjs.map +1 -0
  70. package/dist/{chunk-5CGIKL2Y.mjs → chunk-OG6UBKMG.mjs} +2 -2
  71. package/dist/chunk-OG6UBKMG.mjs.map +1 -0
  72. package/dist/chunk-PEODF7PL.mjs +34 -0
  73. package/dist/chunk-PEODF7PL.mjs.map +1 -0
  74. package/dist/{chunk-FAFXVD4P.mjs → chunk-PJZVMYPN.mjs} +4 -4
  75. package/dist/chunk-PJZVMYPN.mjs.map +1 -0
  76. package/dist/{chunk-KEIDXVZB.mjs → chunk-PT4IH2KW.mjs} +2 -2
  77. package/dist/chunk-PT4IH2KW.mjs.map +1 -0
  78. package/dist/{chunk-MXH3TZWM.mjs → chunk-QFECX4D6.mjs} +1 -1
  79. package/dist/chunk-QFECX4D6.mjs.map +1 -0
  80. package/dist/{chunk-5VH26DHQ.mjs → chunk-QMFUWXJJ.mjs} +1 -1
  81. package/dist/chunk-QMFUWXJJ.mjs.map +1 -0
  82. package/dist/chunk-R4A5DO7E.mjs +12 -0
  83. package/dist/chunk-R4A5DO7E.mjs.map +1 -0
  84. package/dist/{chunk-LQQDRIZN.mjs → chunk-RGCO6BCU.mjs} +3 -3
  85. package/dist/chunk-RGCO6BCU.mjs.map +1 -0
  86. package/dist/{chunk-PPMW7YAZ.mjs → chunk-SFSA2WUE.mjs} +28 -28
  87. package/dist/chunk-SFSA2WUE.mjs.map +1 -0
  88. package/dist/{chunk-XUXHB434.mjs → chunk-SM4TG5VI.mjs} +1 -1
  89. package/dist/chunk-SM4TG5VI.mjs.map +1 -0
  90. package/dist/{chunk-D6H235SZ.mjs → chunk-UPAA75QA.mjs} +1 -1
  91. package/dist/chunk-UPAA75QA.mjs.map +1 -0
  92. package/dist/{chunk-256SAVHD.mjs → chunk-W3XYS7M3.mjs} +1 -1
  93. package/dist/{chunk-256SAVHD.mjs.map → chunk-W3XYS7M3.mjs.map} +1 -1
  94. package/dist/chunk-X2JENUDV.mjs +16 -0
  95. package/dist/chunk-X2JENUDV.mjs.map +1 -0
  96. package/dist/chunk-XBWUYKZW.mjs +10 -0
  97. package/dist/chunk-XBWUYKZW.mjs.map +1 -0
  98. package/dist/{chunk-Q365BFES.mjs → chunk-YJINOUZ7.mjs} +1 -1
  99. package/dist/chunk-YJINOUZ7.mjs.map +1 -0
  100. package/dist/{chunk-4IKXV4FQ.mjs → chunk-Z5YZVKS5.mjs} +2 -2
  101. package/dist/{chunk-ZHCGY4YB.mjs → chunk-ZO5NWKNY.mjs} +2 -2
  102. package/dist/{chunk-ZHCGY4YB.mjs.map → chunk-ZO5NWKNY.mjs.map} +1 -1
  103. package/dist/color-picker.mjs +1 -1
  104. package/dist/dashboard-notification.mjs +1 -1
  105. package/dist/date-range-picker.mjs +4 -4
  106. package/dist/drag-and-drop.css +1 -1
  107. package/dist/drag-and-drop.css.map +1 -1
  108. package/dist/drag-and-drop.mjs +46 -46
  109. package/dist/draggable-stacked-list-item.mjs +2 -2
  110. package/dist/drawer.mjs +1 -1
  111. package/dist/dropdown.mjs +1 -1
  112. package/dist/feature-cards/feature-card.mjs +2 -2
  113. package/dist/featurePageComponents/feature-page-group.mjs +1 -1
  114. package/dist/file-picker/file-listing.d.ts +1 -1
  115. package/dist/file-picker/file-listing.mjs +2 -2
  116. package/dist/file-picker/file-picker.css +1 -1
  117. package/dist/file-picker/file-picker.css.map +1 -1
  118. package/dist/file-picker/file-picker.d.ts +2 -2
  119. package/dist/file-picker/file-picker.mjs +46 -46
  120. package/dist/fixed-alert.mjs +1 -1
  121. package/dist/footer-heart-icon.mjs +1 -1
  122. package/dist/form-row.mjs +2 -2
  123. package/dist/index.css +1 -1
  124. package/dist/index.css.map +1 -1
  125. package/dist/index.mjs +46 -46
  126. package/dist/input-copy.mjs +2 -2
  127. package/dist/label.mjs +1 -1
  128. package/dist/layout/layout.css +1 -1
  129. package/dist/layout/layout.css.map +1 -1
  130. package/dist/layout/layout.mjs +46 -46
  131. package/dist/loading-button.mjs +1 -1
  132. package/dist/love-footer.mjs +2 -2
  133. package/dist/mini-feature-block.mjs +2 -2
  134. package/dist/modal.mjs +1 -1
  135. package/dist/navbar/navbar.mjs +1 -1
  136. package/dist/no-results-block.d.ts +1 -1
  137. package/dist/no-results-block.mjs +1 -1
  138. package/dist/page-header.mjs +2 -2
  139. package/dist/pagination/pagination.mjs +1 -1
  140. package/dist/product-picker/product-drawer.css +1 -1
  141. package/dist/product-picker/product-drawer.css.map +1 -1
  142. package/dist/product-picker/product-drawer.mjs +46 -46
  143. package/dist/product-picker/product-listing.d.ts +1 -1
  144. package/dist/product-picker/product-listing.mjs +2 -2
  145. package/dist/progress-bar.mjs +1 -1
  146. package/dist/radio.mjs +1 -1
  147. package/dist/rich-text-editor/index.mjs +1 -1
  148. package/dist/search/search.mjs +1 -1
  149. package/dist/select.mjs +1 -1
  150. package/dist/sort/sort.mjs +1 -1
  151. package/dist/spinner.mjs +1 -1
  152. package/dist/stacked-list-item.css +1 -1
  153. package/dist/stacked-list-item.css.map +1 -1
  154. package/dist/stacked-list-item.mjs +46 -46
  155. package/dist/table-header/table-header.mjs +3 -3
  156. package/dist/table-result-block.css +1 -1
  157. package/dist/table-result-block.css.map +1 -1
  158. package/dist/table-result-block.mjs +46 -46
  159. package/dist/text-row.mjs +1 -1
  160. package/dist/textarea.mjs +1 -1
  161. package/dist/textinput.mjs +1 -1
  162. package/dist/toast/index.mjs +1 -1
  163. package/dist/toggleswitch.mjs +1 -1
  164. package/dist/tooltip/tooltip.mjs +1 -1
  165. package/dist/video-dashboard-notification.mjs +1 -1
  166. package/dist/video-modal.mjs +1 -1
  167. package/package.json +4 -2
  168. package/src/accordion.tsx +120 -58
  169. package/src/alert-banner.tsx +78 -56
  170. package/src/avatar.tsx +71 -49
  171. package/src/badge.tsx +38 -30
  172. package/src/breadcrumb.tsx +28 -21
  173. package/src/checkbox.tsx +28 -20
  174. package/src/color-picker.tsx +2 -4
  175. package/src/dashboard-notification.tsx +1 -2
  176. package/src/date-range-picker.tsx +208 -139
  177. package/src/drag-and-drop.tsx +4 -4
  178. package/src/draggable-stacked-list-item.tsx +2 -2
  179. package/src/drawer.tsx +2 -2
  180. package/src/dropdown.tsx +91 -73
  181. package/src/featurePageComponents/feature-page-group.tsx +0 -1
  182. package/src/file-picker/file-listing.tsx +86 -38
  183. package/src/file-picker/file-picker.tsx +296 -212
  184. package/src/fixed-alert.tsx +2 -5
  185. package/src/footer-heart-icon.tsx +31 -7
  186. package/src/form-row.tsx +1 -1
  187. package/src/index.tsx +1 -1
  188. package/src/input-copy.tsx +1 -1
  189. package/src/label.tsx +12 -6
  190. package/src/layout/layout.tsx +2 -2
  191. package/src/loading-button.tsx +21 -21
  192. package/src/mini-feature-block.tsx +2 -6
  193. package/src/modal.tsx +46 -34
  194. package/src/navbar/navbar.tsx +1 -1
  195. package/src/no-results-block.tsx +7 -3
  196. package/src/page-header.tsx +13 -8
  197. package/src/pagination/pagination.tsx +1 -1
  198. package/src/product-picker/product-drawer.tsx +226 -144
  199. package/src/product-picker/product-listing.tsx +84 -45
  200. package/src/progress-bar.tsx +39 -25
  201. package/src/radio.tsx +11 -11
  202. package/src/rich-text-editor/headless-editor.ts +5 -5
  203. package/src/search/search.tsx +4 -4
  204. package/src/select.tsx +2 -3
  205. package/src/sort/sort.tsx +33 -31
  206. package/src/spinner.tsx +3 -3
  207. package/src/stacked-list-item.tsx +1 -1
  208. package/src/table-header/table-header.tsx +114 -90
  209. package/src/table-result-block.tsx +12 -10
  210. package/src/text-row.tsx +1 -1
  211. package/src/textarea.tsx +27 -24
  212. package/src/textinput.tsx +31 -28
  213. package/src/toast/index.tsx +4 -4
  214. package/src/toggleswitch.tsx +3 -1
  215. package/src/tooltip/tooltip.tsx +1 -1
  216. package/src/video-dashboard-notification.tsx +0 -2
  217. package/src/video-modal.tsx +2 -5
  218. package/dist/chunk-25FJ277C.mjs.map +0 -1
  219. package/dist/chunk-2IL2LP47.mjs.map +0 -1
  220. package/dist/chunk-3LINEESX.mjs.map +0 -1
  221. package/dist/chunk-47S6AX7M.mjs.map +0 -1
  222. package/dist/chunk-5CGIKL2Y.mjs.map +0 -1
  223. package/dist/chunk-5DQUZENZ.mjs.map +0 -1
  224. package/dist/chunk-5VH26DHQ.mjs.map +0 -1
  225. package/dist/chunk-ASCPOK5F.mjs.map +0 -1
  226. package/dist/chunk-AYXC2DCM.mjs.map +0 -1
  227. package/dist/chunk-CEK5K5TU.mjs.map +0 -1
  228. package/dist/chunk-CMA7TSQG.mjs.map +0 -1
  229. package/dist/chunk-CZNQ24DQ.mjs +0 -16
  230. package/dist/chunk-CZNQ24DQ.mjs.map +0 -1
  231. package/dist/chunk-D6H235SZ.mjs.map +0 -1
  232. package/dist/chunk-DZABAR36.mjs.map +0 -1
  233. package/dist/chunk-EWNPNF2B.mjs.map +0 -1
  234. package/dist/chunk-F6ZWBNIM.mjs.map +0 -1
  235. package/dist/chunk-FAFXVD4P.mjs.map +0 -1
  236. package/dist/chunk-FRIXS4BL.mjs.map +0 -1
  237. package/dist/chunk-HZTQAUGX.mjs +0 -34
  238. package/dist/chunk-HZTQAUGX.mjs.map +0 -1
  239. package/dist/chunk-JACXLYPD.mjs +0 -12
  240. package/dist/chunk-JACXLYPD.mjs.map +0 -1
  241. package/dist/chunk-JCWSMIVA.mjs.map +0 -1
  242. package/dist/chunk-KEIDXVZB.mjs.map +0 -1
  243. package/dist/chunk-LQQDRIZN.mjs.map +0 -1
  244. package/dist/chunk-MXH3TZWM.mjs.map +0 -1
  245. package/dist/chunk-NEJOZRKV.mjs.map +0 -1
  246. package/dist/chunk-PPMW7YAZ.mjs.map +0 -1
  247. package/dist/chunk-Q365BFES.mjs.map +0 -1
  248. package/dist/chunk-REFCK56T.mjs +0 -12
  249. package/dist/chunk-REFCK56T.mjs.map +0 -1
  250. package/dist/chunk-VPLCWU7T.mjs +0 -9
  251. package/dist/chunk-VPLCWU7T.mjs.map +0 -1
  252. package/dist/chunk-VQ3MZS4J.mjs.map +0 -1
  253. package/dist/chunk-W3DRXKTC.mjs.map +0 -1
  254. package/dist/chunk-WFRV27QA.mjs.map +0 -1
  255. package/dist/chunk-WLJEFSES.mjs +0 -10
  256. package/dist/chunk-WLJEFSES.mjs.map +0 -1
  257. package/dist/chunk-WMFTYTMD.mjs.map +0 -1
  258. package/dist/chunk-XUXHB434.mjs.map +0 -1
  259. package/dist/chunk-YJKULMWM.mjs.map +0 -1
  260. package/dist/chunk-ZJATBQ3X.mjs +0 -10
  261. package/dist/chunk-ZJATBQ3X.mjs.map +0 -1
  262. package/dist/chunk-ZWJSMASL.mjs.map +0 -1
  263. /package/dist/{chunk-7YKZ7D7U.mjs.map → chunk-ATNP3Z6G.mjs.map} +0 -0
  264. /package/dist/{chunk-4IKXV4FQ.mjs.map → chunk-Z5YZVKS5.mjs.map} +0 -0
@@ -1,47 +1,54 @@
1
1
  // @ts-nocheck
2
- import { useEffect, useRef, useState, useReducer, useImperativeHandle, forwardRef } from 'react'
3
- import { Drawer } from '../drawer'
4
- import { Button } from '../button'
5
- import { Search} from '../search/search'
6
- import { TableResultBlock } from '../table-result-block'
7
- import { HiClipboardList } from 'react-icons/hi'
8
- import { Listing } from './product-listing'
9
- import PropTypes from 'prop-types'
10
- import pluralize from 'pluralize'
2
+ import pluralize from "pluralize";
3
+ import PropTypes from "prop-types";
4
+ import {
5
+ forwardRef,
6
+ useEffect,
7
+ useImperativeHandle,
8
+ useReducer,
9
+ useRef,
10
+ useState,
11
+ } from "react";
12
+ import { HiClipboardList } from "react-icons/hi";
13
+ import { Button } from "../button";
14
+ import { Drawer } from "../drawer";
15
+ import { Search } from "../search/search";
16
+ import { TableResultBlock } from "../table-result-block";
17
+ import { Listing } from "./product-listing";
11
18
 
12
19
  const Status = Object.freeze({
13
- EMPTY: 'EMPTY',
14
- SEARCH_LOADING: 'SEARCH-LOADING',
15
- LOADING: 'LOADING',
16
- LOADED: 'LOADED',
17
- SELECTED: 'SELECTED',
18
- SEARCH_RESULTS: 'SEARCH-RESULTS',
19
- SEARCH_EMPTY: 'SEARCH-EMPTY',
20
- })
20
+ EMPTY: "EMPTY",
21
+ SEARCH_LOADING: "SEARCH-LOADING",
22
+ LOADING: "LOADING",
23
+ LOADED: "LOADED",
24
+ SELECTED: "SELECTED",
25
+ SEARCH_RESULTS: "SEARCH-RESULTS",
26
+ SEARCH_EMPTY: "SEARCH-EMPTY",
27
+ });
21
28
 
22
29
  const searchCategories = [
23
30
  {
24
- display: 'Name',
25
- value: 'NME',
31
+ display: "Name",
32
+ value: "NME",
26
33
  },
27
34
  {
28
- display: 'Category',
29
- value: 'CAT',
35
+ display: "Category",
36
+ value: "CAT",
30
37
  },
31
- ]
38
+ ];
32
39
 
33
40
  const initialState = Object.freeze({
34
41
  mode: Status.LOADING,
35
- listSize: 'h-5/6',
36
- listBorder: '',
42
+ listSize: "h-5/6",
43
+ listBorder: "",
37
44
  searchDisabled: false,
38
- })
45
+ });
39
46
 
40
47
  function calculateSelectedProducts(obj) {
41
48
  const mutatedOriginalArray = [...obj.orig].filter((x) => {
42
- return !obj.remove.includes(x)
43
- })
44
- return [...mutatedOriginalArray, ...obj.add]
49
+ return !obj.remove.includes(x);
50
+ });
51
+ return [...mutatedOriginalArray, ...obj.add];
45
52
  }
46
53
 
47
54
  function ProductPickerReducer(state, action) {
@@ -49,37 +56,42 @@ function ProductPickerReducer(state, action) {
49
56
  case Status.EMPTY:
50
57
  return {
51
58
  mode: Status.EMPTY,
52
- listSize: 'h-5/6',
53
- listBorder: '',
59
+ listSize: "h-5/6",
60
+ listBorder: "",
54
61
  searchDisabled: true,
55
- }
62
+ };
56
63
  case Status.LOADING:
57
- return initialState
64
+ return initialState;
58
65
  case Status.LOADED:
59
66
  return {
60
67
  mode: Status.LOADED,
61
- listSize: 'h-[87.333333%]',
62
- listBorder: 'border',
68
+ listSize: "h-[87.333333%]",
69
+ listBorder: "border",
63
70
  searchDisabled: false,
64
- }
71
+ };
65
72
  case Status.SELECTED:
66
- return { mode: Status.SELECTED, listSize: 'h-[80%]', listBorder: 'border', searchDisabled: false }
73
+ return {
74
+ mode: Status.SELECTED,
75
+ listSize: "h-[80%]",
76
+ listBorder: "border",
77
+ searchDisabled: false,
78
+ };
67
79
  case Status.SEARCH_RESULTS:
68
80
  return {
69
81
  mode: Status.SEARCH_RESULTS,
70
- listSize: 'h-5/6',
71
- listBorder: 'border',
82
+ listSize: "h-5/6",
83
+ listBorder: "border",
72
84
  searchDisabled: false,
73
- }
85
+ };
74
86
  case Status.SEARCH_EMPTY:
75
87
  return {
76
88
  mode: Status.SEARCH_EMPTY,
77
- listSize: 'h-5/6',
78
- listBorder: '',
89
+ listSize: "h-5/6",
90
+ listBorder: "",
79
91
  searchDisabled: false,
80
- }
92
+ };
81
93
  default:
82
- throw new Error('Unknown file picker state: ' + action.page ?? '')
94
+ throw new Error("Unknown file picker state: " + action.page ?? "");
83
95
  }
84
96
  }
85
97
 
@@ -90,153 +102,201 @@ function ProductPickerReducer(state, action) {
90
102
  * be handled by the parent/calling component eg: fetching the products and passing them to this component.
91
103
  */
92
104
 
93
- export const ProductPicker = forwardRef(function ProductPicker({ show, preSelected = [], onClose, requestCallback, callback }, ref) {
94
- const searchFieldRef = useRef()
95
- const isViewableRef = useRef(false)
96
- const [state, dispatch] = useReducer(ProductPickerReducer, { mode: Status.LOADING, footerBorder: 'border-t' })
97
- const [totalPages, setTotalPages] = useState(0)
98
- const currentPageRef = useRef(1)
99
- const listAttributeRef = useRef({ pages: 0, totalEntries: 0 })
100
- const [fetchData, setFetchData] = useState(false)
101
- const [search, setSearch] = useState({ text: '', category: { display: 'Name', value: 'NME' } })
102
- const [products, setProducts] = useState([])
105
+ export const ProductPicker = forwardRef(function ProductPicker(
106
+ { show, preSelected = [], onClose, requestCallback, callback },
107
+ ref
108
+ ) {
109
+ const searchFieldRef = useRef();
110
+ const isViewableRef = useRef(false);
111
+ const [state, dispatch] = useReducer(ProductPickerReducer, {
112
+ mode: Status.LOADING,
113
+ footerBorder: "border-t",
114
+ });
115
+ const [totalPages, setTotalPages] = useState(0);
116
+ const currentPageRef = useRef(1);
117
+ const listAttributeRef = useRef({ pages: 0, totalEntries: 0 });
118
+ const [fetchData, setFetchData] = useState(false);
119
+ const [search, setSearch] = useState({
120
+ text: "",
121
+ category: { display: "Name", value: "NME" },
122
+ });
123
+ const [products, setProducts] = useState([]);
103
124
  // Selected State
104
- const [session, setSession] = useState({ orig: [], add: [], remove: [], isAll: false }) // handles DEFAULT selection sessions
125
+ const [session, setSession] = useState({
126
+ orig: [],
127
+ add: [],
128
+ remove: [],
129
+ isAll: false,
130
+ }); // handles DEFAULT selection sessions
105
131
 
106
132
  useEffect(() => {
107
133
  // Workaround to ensure the drawer is cleared when it is first opened as its always on the DOM!
108
134
  if (show) {
109
- dispatch({ type: Status.LOADING })
135
+ dispatch({ type: Status.LOADING });
110
136
  // setSelected([])
111
- listAttributeRef.current = { pages: 0, totalEntries: 0 }
112
- clearState()
113
- getProducts(1)
114
- setSession({ ...session, orig: preSelected })
115
- isViewableRef.current = true
137
+ listAttributeRef.current = { pages: 0, totalEntries: 0 };
138
+ clearState();
139
+ getProducts(1);
140
+ setSession({ ...session, orig: preSelected });
141
+ isViewableRef.current = true;
116
142
  }
117
- }, [show])
143
+ }, [show]);
118
144
 
119
145
  useEffect(() => {
120
146
  if (show && state.mode === isViewableRef.current) {
121
- currentPageRef.current = 1
122
- getProducts()
147
+ currentPageRef.current = 1;
148
+ getProducts();
123
149
  }
124
- }, [search.text, search.category.display])
150
+ }, [search.text, search.category.display]);
125
151
 
126
152
  const clearState = () => {
127
- setProducts([])
128
- setSession({ orig: [], add: [], remove: [], isAll: false })
129
- setFetchData(false)
130
- }
153
+ setProducts([]);
154
+ setSession({ orig: [], add: [], remove: [], isAll: false });
155
+ setFetchData(false);
156
+ };
131
157
 
132
158
  const getProducts = (cp = 0) => {
133
- let page = cp === 0 ? currentPageRef.current : cp
159
+ let page = cp === 0 ? currentPageRef.current : cp;
134
160
  requestCallback({
135
161
  SearchText: search.text,
136
162
  PageSize: 11,
137
163
  Page: page,
138
164
  SearchType: search.category.display,
139
- })
140
- }
165
+ });
166
+ };
141
167
 
142
168
  useImperativeHandle(ref, () => ({
143
169
  responseHandler: (response) => {
144
170
  try {
145
- if (search.text?.length > 0) dispatch({ type: Status.SEARCH_RESULTS })
171
+ if (search.text?.length > 0) dispatch({ type: Status.SEARCH_RESULTS });
146
172
  if (response.Result.Data.length > 0 && currentPageRef.current > 1) {
147
- setProducts((products) => [...products, ...response.Result.Data])
173
+ setProducts((products) => [...products, ...response.Result.Data]);
148
174
  } else {
149
- setProducts(response.Result.Data)
175
+ setProducts(response.Result.Data);
150
176
  }
151
177
 
152
- listAttributeRef.current = { pages: response.Result.NumberOfPages, totalEntries: response.Result.Total }
153
- setTotalPages(response.Result.NumberOfPages)
178
+ listAttributeRef.current = {
179
+ pages: response.Result.NumberOfPages,
180
+ totalEntries: response.Result.Total,
181
+ };
182
+ setTotalPages(response.Result.NumberOfPages);
154
183
 
155
184
  if (search.text?.length > 0) {
156
- dispatch({ type: response.Result.Data.length > 0 ? Status.SEARCH_RESULTS : Status.SEARCH_EMPTY })
185
+ dispatch({
186
+ type:
187
+ response.Result.Data.length > 0
188
+ ? Status.SEARCH_RESULTS
189
+ : Status.SEARCH_EMPTY,
190
+ });
157
191
  } else {
158
- dispatch({ type: response.Result.Data.length > 0 ? Status.LOADED : Status.EMPTY })
192
+ dispatch({
193
+ type:
194
+ response.Result.Data.length > 0 ? Status.LOADED : Status.EMPTY,
195
+ });
159
196
  }
160
- if (session.orig.length + session.add.length - session.remove.length > 0) dispatch({ type: Status.SELECTED })
161
- setFetchData(false)
197
+ if (
198
+ session.orig.length + session.add.length - session.remove.length >
199
+ 0
200
+ )
201
+ dispatch({ type: Status.SELECTED });
202
+ setFetchData(false);
162
203
  } catch (error) {
163
- console.error('Error fetching products', error)
164
- dispatch({ type: search.text?.length === 0 ? Status.SEARCH_EMPTY : Status.EMPTY })
204
+ console.error("Error fetching products", error);
205
+ dispatch({
206
+ type: search.text?.length === 0 ? Status.SEARCH_EMPTY : Status.EMPTY,
207
+ });
165
208
  }
166
209
  },
167
- }))
210
+ }));
168
211
 
169
212
  const handleSearchRequest = (searchTerm) => {
170
- const text = searchTerm.text ?? ''
171
- const s = search.text ?? ''
172
- setSearch(searchTerm)
173
- if ((s.length > 0 && text.length === 0) || (s.length === 0 && text.length > 0 && state.mode !== Status.LOADING))
174
- dispatch({ type: Status.LOADING })
175
- }
213
+ const text = searchTerm.text ?? "";
214
+ const s = search.text ?? "";
215
+ setSearch(searchTerm);
216
+ if (
217
+ (s.length > 0 && text.length === 0) ||
218
+ (s.length === 0 && text.length > 0 && state.mode !== Status.LOADING)
219
+ )
220
+ dispatch({ type: Status.LOADING });
221
+ };
176
222
 
177
223
  const handleProductSelection = () => {
178
- callback(session)
179
- handleClose()
180
- }
224
+ callback(session);
225
+ handleClose();
226
+ };
181
227
 
182
228
  const handleClose = () => {
183
- clearState()
184
- isViewableRef.current = false
185
- onClose()
186
- }
229
+ clearState();
230
+ isViewableRef.current = false;
231
+ onClose();
232
+ };
187
233
 
188
234
  const handleListActions = (action) => {
189
235
  switch (action.type) {
190
- case 'FETCH_DATA':
191
- setFetchData(action.payload)
192
- if (currentPageRef.current < listAttributeRef.current.pages && !fetchData) {
236
+ case "FETCH_DATA":
237
+ setFetchData(action.payload);
238
+ if (
239
+ currentPageRef.current < listAttributeRef.current.pages &&
240
+ !fetchData
241
+ ) {
193
242
  // pass in the current page + 1 to get the next page of data then change state as the state is not updated immediately
194
- setFetchData(true)
195
- currentPageRef.current = currentPageRef.current + 1
196
- getProducts()
243
+ setFetchData(true);
244
+ currentPageRef.current = currentPageRef.current + 1;
245
+ getProducts();
197
246
  }
198
- break
199
- case 'SELECTION':
200
- const added = session.add.find((x) => x === action.payload) != null
201
- const removed = session.remove.find((x) => x === action.payload) != null
202
- const preExisted = session.orig.find((x) => x === action.payload) != null
203
- let rem = [...session.remove]
204
- let add = [...session.add]
247
+ break;
248
+ case "SELECTION":
249
+ const added = session.add.find((x) => x === action.payload) != null;
250
+ const removed =
251
+ session.remove.find((x) => x === action.payload) != null;
252
+ const preExisted =
253
+ session.orig.find((x) => x === action.payload) != null;
254
+ let rem = [...session.remove];
255
+ let add = [...session.add];
205
256
  if (preExisted && !removed) {
206
- rem.push(action.payload)
257
+ rem.push(action.payload);
207
258
  } else if (preExisted && removed) {
208
- rem = [...rem].filter((x) => x !== action.payload)
259
+ rem = [...rem].filter((x) => x !== action.payload);
209
260
  } else if (!preExisted && !added) {
210
- add.push(action.payload)
261
+ add.push(action.payload);
211
262
  } else if (!preExisted && added) {
212
- add = [...add].filter((x) => x !== action.payload)
263
+ add = [...add].filter((x) => x !== action.payload);
213
264
  }
214
265
 
215
- setSession({ ...session, add: add, remove: rem })
216
- if (session.orig.length + add.length - rem.length > 0) dispatch({ type: Status.SELECTED })
217
- break
218
- case 'DESELECT_ALL':
219
- setSession({ ...session, orig: [], add: [], remove: [] })
220
- dispatch({ type: Status.LOADED })
221
- break
266
+ setSession({ ...session, add: add, remove: rem });
267
+ if (session.orig.length + add.length - rem.length > 0)
268
+ dispatch({ type: Status.SELECTED });
269
+ break;
270
+ case "DESELECT_ALL":
271
+ setSession({ ...session, orig: [], add: [], remove: [] });
272
+ dispatch({ type: Status.LOADED });
273
+ break;
222
274
  default:
223
- break
275
+ break;
224
276
  }
225
- }
277
+ };
226
278
 
227
279
  const renderList = () => {
228
280
  switch (state.mode) {
229
281
  case Status.EMPTY:
230
282
  return (
231
283
  <TableResultBlock
232
- icon={<HiClipboardList className="mb-4 h-16 w-16 text-gray-500 dark:text-gray-400" />}
284
+ icon={
285
+ <HiClipboardList className="mb-4 h-16 w-16 text-gray-500 dark:text-gray-400" />
286
+ }
233
287
  title="You Have No Products"
234
288
  message="Your products will appear here"
235
289
  spinner={false}
236
290
  />
237
- )
291
+ );
238
292
  case Status.LOADING:
239
- return <TableResultBlock title="Loading Products" message="Please wait this may take a few minutes" spinner />
293
+ return (
294
+ <TableResultBlock
295
+ title="Loading Products"
296
+ message="Please wait this may take a few minutes"
297
+ spinner
298
+ />
299
+ );
240
300
  case Status.SEARCH_RESULTS:
241
301
  case Status.SELECTED:
242
302
  case Status.LOADED:
@@ -250,29 +310,37 @@ export const ProductPicker = forwardRef(function ProductPicker({ show, preSelect
250
310
  pages={totalPages}
251
311
  callback={handleListActions}
252
312
  />
253
- )
313
+ );
254
314
  case Status.SEARCH_EMPTY:
255
315
  return (
256
316
  <TableResultBlock
257
- icon={<HiClipboardList className="mb-4 h-16 w-16 text-gray-500 dark:text-gray-400" />}
317
+ icon={
318
+ <HiClipboardList className="mb-4 h-16 w-16 text-gray-500 dark:text-gray-400" />
319
+ }
258
320
  title="No Products Found"
259
321
  message="No products were found matching your search"
260
322
  />
261
- )
323
+ );
262
324
 
263
325
  default:
264
- break
326
+ break;
265
327
  }
266
- }
328
+ };
267
329
 
268
330
  const renderContent = () => (
269
331
  <>
270
332
  {session.orig.length + session.add.length - session.remove.length > 0 && (
271
333
  <div className="mb-4 rounded-md border border-orange-200 bg-yellow-50 p-4">
272
334
  <p className="text-center text-sm text-yellow-800">
273
- {`${pluralize('product', session.orig.length + session.add.length - session.remove.length, true)} selected.`}
335
+ {`${pluralize(
336
+ "product",
337
+ session.orig.length + session.add.length - session.remove.length,
338
+ true
339
+ )} selected.`}
274
340
  <span
275
- onClick={() => handleListActions({ type: 'DESELECT_ALL', payload: null })}
341
+ onClick={() =>
342
+ handleListActions({ type: "DESELECT_ALL", payload: null })
343
+ }
276
344
  className="cursor-pointer text-primary-600 hover:underline"
277
345
  >{` Clear Selection.`}</span>
278
346
  </p>
@@ -286,29 +354,43 @@ export const ProductPicker = forwardRef(function ProductPicker({ show, preSelect
286
354
  disabled={state.searchDisabled}
287
355
  callback={handleSearchRequest}
288
356
  />
289
- <div className="mt-4 mb-4">
290
- {(state.mode === Status.SEARCH_RESULTS || state.mode === Status.SEARCH_EMPTY) && search.text.length > 0 && (
291
- <span className="ms-1 text-sm font-medium text-gray-500 md:ms-2 dark:text-gray-400">{`Showing results for..."${search.text}"`}</span>
292
- )}
357
+ <div className="mb-4 mt-4">
358
+ {(state.mode === Status.SEARCH_RESULTS ||
359
+ state.mode === Status.SEARCH_EMPTY) &&
360
+ search.text.length > 0 && (
361
+ <span className="ms-1 text-sm font-medium text-gray-500 dark:text-gray-400 md:ms-2">{`Showing results for..."${search.text}"`}</span>
362
+ )}
293
363
  </div>
294
364
  {renderList()}
295
365
  </>
296
- )
366
+ );
297
367
 
298
368
  return (
299
- <Drawer show={show} onClose={handleClose} title="File Picker" onHide={() => {}}>
369
+ <Drawer
370
+ show={show}
371
+ onClose={handleClose}
372
+ title="File Picker"
373
+ onHide={() => {}}
374
+ >
300
375
  <div className="h-full">{show && renderContent()}</div>
301
- <div className={`grid grid-cols-2 grid-flow-col gap-4 bottom-0 mt-0 pt-2 bg-white dark:border-gray-600`} style={{ marginTop: '-50px' }}>
376
+ <div
377
+ className={`bottom-0 mt-0 grid grid-flow-col grid-cols-2 gap-4 bg-white pt-2 dark:border-gray-600`}
378
+ style={{ marginTop: "-50px" }}
379
+ >
302
380
  <Button color="light" onClick={handleClose}>
303
381
  Close
304
382
  </Button>
305
- <Button color="success" onClick={handleProductSelection} disabled={products.length === 0}>
383
+ <Button
384
+ color="success"
385
+ onClick={handleProductSelection}
386
+ disabled={products.length === 0}
387
+ >
306
388
  Add Products
307
389
  </Button>
308
390
  </div>
309
391
  </Drawer>
310
- )
311
- })
392
+ );
393
+ });
312
394
 
313
395
  ProductPicker.propTypes = {
314
396
  /** Show the drawer */
@@ -319,6 +401,6 @@ ProductPicker.propTypes = {
319
401
  onClose: PropTypes.func.isRequired,
320
402
  /** Callback to return the selected products {orig - preselected, add - newly added, remove -items removed from pre-selected} */
321
403
  callback: PropTypes.func.isRequired,
322
- }
404
+ };
323
405
 
324
- ProductPicker.displayName = 'ProductPicker'
406
+ ProductPicker.displayName = "ProductPicker";