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.
- package/.turbo/turbo-build.log +128 -128
- package/CHANGELOG.md +12 -0
- package/dist/accordion.d.ts +28 -21
- package/dist/accordion.mjs +1 -1
- package/dist/alert-banner.mjs +1 -1
- package/dist/avatar.mjs +1 -1
- package/dist/badge.mjs +1 -1
- package/dist/breadcrumb.mjs +1 -1
- package/dist/card-payment-block.css +1 -1
- package/dist/card-payment-block.css.map +1 -1
- package/dist/card-payment-block.mjs +46 -46
- package/dist/checkbox.mjs +1 -1
- package/dist/chunk-2OTVEVU7.mjs +11 -0
- package/dist/chunk-2OTVEVU7.mjs.map +1 -0
- package/dist/{chunk-47S6AX7M.mjs → chunk-2PW7KHXJ.mjs} +1 -1
- package/dist/chunk-2PW7KHXJ.mjs.map +1 -0
- package/dist/{chunk-CMA7TSQG.mjs → chunk-35VEFUPA.mjs} +4 -4
- package/dist/chunk-35VEFUPA.mjs.map +1 -0
- package/dist/{chunk-ZWJSMASL.mjs → chunk-3AGRJPPN.mjs} +3 -3
- package/dist/chunk-3AGRJPPN.mjs.map +1 -0
- package/dist/{chunk-MRJOYGDD.mjs → chunk-3TAXDPV6.mjs} +2 -2
- package/dist/{chunk-MRJOYGDD.mjs.map → chunk-3TAXDPV6.mjs.map} +1 -1
- package/dist/{chunk-5DQUZENZ.mjs → chunk-6F3XKP3G.mjs} +2 -2
- package/dist/chunk-6F3XKP3G.mjs.map +1 -0
- package/dist/{chunk-HEKVJKLH.mjs → chunk-6UK5Y6KZ.mjs} +2 -2
- package/dist/{chunk-HEKVJKLH.mjs.map → chunk-6UK5Y6KZ.mjs.map} +1 -1
- package/dist/{chunk-EWNPNF2B.mjs → chunk-76V2THLN.mjs} +3 -3
- package/dist/chunk-76V2THLN.mjs.map +1 -0
- package/dist/chunk-7GLTVVKS.mjs +12 -0
- package/dist/chunk-7GLTVVKS.mjs.map +1 -0
- package/dist/{chunk-UUWBHZKH.mjs → chunk-7MH2LXFV.mjs} +4 -4
- package/dist/{chunk-UUWBHZKH.mjs.map → chunk-7MH2LXFV.mjs.map} +1 -1
- package/dist/{chunk-7YKZ7D7U.mjs → chunk-ATNP3Z6G.mjs} +2 -2
- package/dist/{chunk-25FJ277C.mjs → chunk-AYH56CFA.mjs} +3 -3
- package/dist/chunk-AYH56CFA.mjs.map +1 -0
- package/dist/{chunk-NEJOZRKV.mjs → chunk-BK5RX7N5.mjs} +2 -2
- package/dist/chunk-BK5RX7N5.mjs.map +1 -0
- package/dist/{chunk-F6ZWBNIM.mjs → chunk-CIUW5YZ7.mjs} +2 -2
- package/dist/chunk-CIUW5YZ7.mjs.map +1 -0
- package/dist/{chunk-WMFTYTMD.mjs → chunk-CZC4EJOD.mjs} +3 -3
- package/dist/chunk-CZC4EJOD.mjs.map +1 -0
- package/dist/{chunk-CEK5K5TU.mjs → chunk-D3VRYN5H.mjs} +4 -4
- package/dist/chunk-D3VRYN5H.mjs.map +1 -0
- package/dist/{chunk-W3DRXKTC.mjs → chunk-DBTYTFGU.mjs} +2 -2
- package/dist/chunk-DBTYTFGU.mjs.map +1 -0
- package/dist/{chunk-JCWSMIVA.mjs → chunk-E6KQBM7F.mjs} +2 -2
- package/dist/chunk-E6KQBM7F.mjs.map +1 -0
- package/dist/{chunk-5FPVCRAI.mjs → chunk-ECOC3JRK.mjs} +1 -1
- package/dist/{chunk-5FPVCRAI.mjs.map → chunk-ECOC3JRK.mjs.map} +1 -1
- package/dist/{chunk-3LINEESX.mjs → chunk-EH3ZVEVT.mjs} +1 -1
- package/dist/chunk-EH3ZVEVT.mjs.map +1 -0
- package/dist/{chunk-YJKULMWM.mjs → chunk-EX5FMSQL.mjs} +2 -2
- package/dist/chunk-EX5FMSQL.mjs.map +1 -0
- package/dist/{chunk-ASCPOK5F.mjs → chunk-FVUORQJX.mjs} +4 -4
- package/dist/chunk-FVUORQJX.mjs.map +1 -0
- package/dist/{chunk-WFRV27QA.mjs → chunk-G5A3E5IG.mjs} +3 -3
- package/dist/chunk-G5A3E5IG.mjs.map +1 -0
- package/dist/{chunk-2IL2LP47.mjs → chunk-HOCKBMTF.mjs} +3 -3
- package/dist/chunk-HOCKBMTF.mjs.map +1 -0
- package/dist/{chunk-FRIXS4BL.mjs → chunk-JPF3K5TD.mjs} +1 -1
- package/dist/chunk-JPF3K5TD.mjs.map +1 -0
- package/dist/{chunk-AYXC2DCM.mjs → chunk-K2G6O2LX.mjs} +3 -3
- package/dist/chunk-K2G6O2LX.mjs.map +1 -0
- package/dist/chunk-LVJYP46A.mjs +9 -0
- package/dist/chunk-LVJYP46A.mjs.map +1 -0
- package/dist/{chunk-VQ3MZS4J.mjs → chunk-MPIWXVKP.mjs} +2 -2
- package/dist/chunk-MPIWXVKP.mjs.map +1 -0
- package/dist/{chunk-DZABAR36.mjs → chunk-NJC2WLYK.mjs} +2 -2
- package/dist/chunk-NJC2WLYK.mjs.map +1 -0
- package/dist/{chunk-5CGIKL2Y.mjs → chunk-OG6UBKMG.mjs} +2 -2
- package/dist/chunk-OG6UBKMG.mjs.map +1 -0
- package/dist/chunk-PEODF7PL.mjs +34 -0
- package/dist/chunk-PEODF7PL.mjs.map +1 -0
- package/dist/{chunk-FAFXVD4P.mjs → chunk-PJZVMYPN.mjs} +4 -4
- package/dist/chunk-PJZVMYPN.mjs.map +1 -0
- package/dist/{chunk-KEIDXVZB.mjs → chunk-PT4IH2KW.mjs} +2 -2
- package/dist/chunk-PT4IH2KW.mjs.map +1 -0
- package/dist/{chunk-MXH3TZWM.mjs → chunk-QFECX4D6.mjs} +1 -1
- package/dist/chunk-QFECX4D6.mjs.map +1 -0
- package/dist/{chunk-5VH26DHQ.mjs → chunk-QMFUWXJJ.mjs} +1 -1
- package/dist/chunk-QMFUWXJJ.mjs.map +1 -0
- package/dist/chunk-R4A5DO7E.mjs +12 -0
- package/dist/chunk-R4A5DO7E.mjs.map +1 -0
- package/dist/{chunk-LQQDRIZN.mjs → chunk-RGCO6BCU.mjs} +3 -3
- package/dist/chunk-RGCO6BCU.mjs.map +1 -0
- package/dist/{chunk-PPMW7YAZ.mjs → chunk-SFSA2WUE.mjs} +28 -28
- package/dist/chunk-SFSA2WUE.mjs.map +1 -0
- package/dist/{chunk-XUXHB434.mjs → chunk-SM4TG5VI.mjs} +1 -1
- package/dist/chunk-SM4TG5VI.mjs.map +1 -0
- package/dist/{chunk-D6H235SZ.mjs → chunk-UPAA75QA.mjs} +1 -1
- package/dist/chunk-UPAA75QA.mjs.map +1 -0
- package/dist/{chunk-256SAVHD.mjs → chunk-W3XYS7M3.mjs} +1 -1
- package/dist/{chunk-256SAVHD.mjs.map → chunk-W3XYS7M3.mjs.map} +1 -1
- package/dist/chunk-X2JENUDV.mjs +16 -0
- package/dist/chunk-X2JENUDV.mjs.map +1 -0
- package/dist/chunk-XBWUYKZW.mjs +10 -0
- package/dist/chunk-XBWUYKZW.mjs.map +1 -0
- package/dist/{chunk-Q365BFES.mjs → chunk-YJINOUZ7.mjs} +1 -1
- package/dist/chunk-YJINOUZ7.mjs.map +1 -0
- package/dist/{chunk-4IKXV4FQ.mjs → chunk-Z5YZVKS5.mjs} +2 -2
- package/dist/{chunk-ZHCGY4YB.mjs → chunk-ZO5NWKNY.mjs} +2 -2
- package/dist/{chunk-ZHCGY4YB.mjs.map → chunk-ZO5NWKNY.mjs.map} +1 -1
- package/dist/color-picker.mjs +1 -1
- package/dist/dashboard-notification.mjs +1 -1
- package/dist/date-range-picker.mjs +4 -4
- package/dist/drag-and-drop.css +1 -1
- package/dist/drag-and-drop.css.map +1 -1
- package/dist/drag-and-drop.mjs +46 -46
- package/dist/draggable-stacked-list-item.mjs +2 -2
- package/dist/drawer.mjs +1 -1
- package/dist/dropdown.mjs +1 -1
- package/dist/feature-cards/feature-card.mjs +2 -2
- package/dist/featurePageComponents/feature-page-group.mjs +1 -1
- package/dist/file-picker/file-listing.d.ts +1 -1
- package/dist/file-picker/file-listing.mjs +2 -2
- package/dist/file-picker/file-picker.css +1 -1
- package/dist/file-picker/file-picker.css.map +1 -1
- package/dist/file-picker/file-picker.d.ts +2 -2
- package/dist/file-picker/file-picker.mjs +46 -46
- package/dist/fixed-alert.mjs +1 -1
- package/dist/footer-heart-icon.mjs +1 -1
- package/dist/form-row.mjs +2 -2
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.mjs +46 -46
- package/dist/input-copy.mjs +2 -2
- package/dist/label.mjs +1 -1
- package/dist/layout/layout.css +1 -1
- package/dist/layout/layout.css.map +1 -1
- package/dist/layout/layout.mjs +46 -46
- package/dist/loading-button.mjs +1 -1
- package/dist/love-footer.mjs +2 -2
- package/dist/mini-feature-block.mjs +2 -2
- package/dist/modal.mjs +1 -1
- package/dist/navbar/navbar.mjs +1 -1
- package/dist/no-results-block.d.ts +1 -1
- package/dist/no-results-block.mjs +1 -1
- package/dist/page-header.mjs +2 -2
- package/dist/pagination/pagination.mjs +1 -1
- package/dist/product-picker/product-drawer.css +1 -1
- package/dist/product-picker/product-drawer.css.map +1 -1
- package/dist/product-picker/product-drawer.mjs +46 -46
- package/dist/product-picker/product-listing.d.ts +1 -1
- package/dist/product-picker/product-listing.mjs +2 -2
- package/dist/progress-bar.mjs +1 -1
- package/dist/radio.mjs +1 -1
- package/dist/rich-text-editor/index.mjs +1 -1
- package/dist/search/search.mjs +1 -1
- package/dist/select.mjs +1 -1
- package/dist/sort/sort.mjs +1 -1
- package/dist/spinner.mjs +1 -1
- package/dist/stacked-list-item.css +1 -1
- package/dist/stacked-list-item.css.map +1 -1
- package/dist/stacked-list-item.mjs +46 -46
- package/dist/table-header/table-header.mjs +3 -3
- package/dist/table-result-block.css +1 -1
- package/dist/table-result-block.css.map +1 -1
- package/dist/table-result-block.mjs +46 -46
- package/dist/text-row.mjs +1 -1
- package/dist/textarea.mjs +1 -1
- package/dist/textinput.mjs +1 -1
- package/dist/toast/index.mjs +1 -1
- package/dist/toggleswitch.mjs +1 -1
- package/dist/tooltip/tooltip.mjs +1 -1
- package/dist/video-dashboard-notification.mjs +1 -1
- package/dist/video-modal.mjs +1 -1
- package/package.json +4 -2
- package/src/accordion.tsx +120 -58
- package/src/alert-banner.tsx +78 -56
- package/src/avatar.tsx +71 -49
- package/src/badge.tsx +38 -30
- package/src/breadcrumb.tsx +28 -21
- package/src/checkbox.tsx +28 -20
- package/src/color-picker.tsx +2 -4
- package/src/dashboard-notification.tsx +1 -2
- package/src/date-range-picker.tsx +208 -139
- package/src/drag-and-drop.tsx +4 -4
- package/src/draggable-stacked-list-item.tsx +2 -2
- package/src/drawer.tsx +2 -2
- package/src/dropdown.tsx +91 -73
- package/src/featurePageComponents/feature-page-group.tsx +0 -1
- package/src/file-picker/file-listing.tsx +86 -38
- package/src/file-picker/file-picker.tsx +296 -212
- package/src/fixed-alert.tsx +2 -5
- package/src/footer-heart-icon.tsx +31 -7
- package/src/form-row.tsx +1 -1
- package/src/index.tsx +1 -1
- package/src/input-copy.tsx +1 -1
- package/src/label.tsx +12 -6
- package/src/layout/layout.tsx +2 -2
- package/src/loading-button.tsx +21 -21
- package/src/mini-feature-block.tsx +2 -6
- package/src/modal.tsx +46 -34
- package/src/navbar/navbar.tsx +1 -1
- package/src/no-results-block.tsx +7 -3
- package/src/page-header.tsx +13 -8
- package/src/pagination/pagination.tsx +1 -1
- package/src/product-picker/product-drawer.tsx +226 -144
- package/src/product-picker/product-listing.tsx +84 -45
- package/src/progress-bar.tsx +39 -25
- package/src/radio.tsx +11 -11
- package/src/rich-text-editor/headless-editor.ts +5 -5
- package/src/search/search.tsx +4 -4
- package/src/select.tsx +2 -3
- package/src/sort/sort.tsx +33 -31
- package/src/spinner.tsx +3 -3
- package/src/stacked-list-item.tsx +1 -1
- package/src/table-header/table-header.tsx +114 -90
- package/src/table-result-block.tsx +12 -10
- package/src/text-row.tsx +1 -1
- package/src/textarea.tsx +27 -24
- package/src/textinput.tsx +31 -28
- package/src/toast/index.tsx +4 -4
- package/src/toggleswitch.tsx +3 -1
- package/src/tooltip/tooltip.tsx +1 -1
- package/src/video-dashboard-notification.tsx +0 -2
- package/src/video-modal.tsx +2 -5
- package/dist/chunk-25FJ277C.mjs.map +0 -1
- package/dist/chunk-2IL2LP47.mjs.map +0 -1
- package/dist/chunk-3LINEESX.mjs.map +0 -1
- package/dist/chunk-47S6AX7M.mjs.map +0 -1
- package/dist/chunk-5CGIKL2Y.mjs.map +0 -1
- package/dist/chunk-5DQUZENZ.mjs.map +0 -1
- package/dist/chunk-5VH26DHQ.mjs.map +0 -1
- package/dist/chunk-ASCPOK5F.mjs.map +0 -1
- package/dist/chunk-AYXC2DCM.mjs.map +0 -1
- package/dist/chunk-CEK5K5TU.mjs.map +0 -1
- package/dist/chunk-CMA7TSQG.mjs.map +0 -1
- package/dist/chunk-CZNQ24DQ.mjs +0 -16
- package/dist/chunk-CZNQ24DQ.mjs.map +0 -1
- package/dist/chunk-D6H235SZ.mjs.map +0 -1
- package/dist/chunk-DZABAR36.mjs.map +0 -1
- package/dist/chunk-EWNPNF2B.mjs.map +0 -1
- package/dist/chunk-F6ZWBNIM.mjs.map +0 -1
- package/dist/chunk-FAFXVD4P.mjs.map +0 -1
- package/dist/chunk-FRIXS4BL.mjs.map +0 -1
- package/dist/chunk-HZTQAUGX.mjs +0 -34
- package/dist/chunk-HZTQAUGX.mjs.map +0 -1
- package/dist/chunk-JACXLYPD.mjs +0 -12
- package/dist/chunk-JACXLYPD.mjs.map +0 -1
- package/dist/chunk-JCWSMIVA.mjs.map +0 -1
- package/dist/chunk-KEIDXVZB.mjs.map +0 -1
- package/dist/chunk-LQQDRIZN.mjs.map +0 -1
- package/dist/chunk-MXH3TZWM.mjs.map +0 -1
- package/dist/chunk-NEJOZRKV.mjs.map +0 -1
- package/dist/chunk-PPMW7YAZ.mjs.map +0 -1
- package/dist/chunk-Q365BFES.mjs.map +0 -1
- package/dist/chunk-REFCK56T.mjs +0 -12
- package/dist/chunk-REFCK56T.mjs.map +0 -1
- package/dist/chunk-VPLCWU7T.mjs +0 -9
- package/dist/chunk-VPLCWU7T.mjs.map +0 -1
- package/dist/chunk-VQ3MZS4J.mjs.map +0 -1
- package/dist/chunk-W3DRXKTC.mjs.map +0 -1
- package/dist/chunk-WFRV27QA.mjs.map +0 -1
- package/dist/chunk-WLJEFSES.mjs +0 -10
- package/dist/chunk-WLJEFSES.mjs.map +0 -1
- package/dist/chunk-WMFTYTMD.mjs.map +0 -1
- package/dist/chunk-XUXHB434.mjs.map +0 -1
- package/dist/chunk-YJKULMWM.mjs.map +0 -1
- package/dist/chunk-ZJATBQ3X.mjs +0 -10
- package/dist/chunk-ZJATBQ3X.mjs.map +0 -1
- package/dist/chunk-ZWJSMASL.mjs.map +0 -1
- /package/dist/{chunk-7YKZ7D7U.mjs.map → chunk-ATNP3Z6G.mjs.map} +0 -0
- /package/dist/{chunk-4IKXV4FQ.mjs.map → chunk-Z5YZVKS5.mjs.map} +0 -0
package/src/dropdown.tsx
CHANGED
|
@@ -1,117 +1,128 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
|
-
import { variantProps } from
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
const DropdownContext = createContext()
|
|
2
|
+
import { variantProps } from "classname-variants/react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { createContext, useContext, useEffect, useState } from "react";
|
|
5
|
+
import { BiChevronDown } from "react-icons/bi";
|
|
6
|
+
const DropdownContext = createContext();
|
|
7
7
|
|
|
8
8
|
// BUTTON CLASSES
|
|
9
9
|
const buttonProps = variantProps({
|
|
10
|
-
base: 'focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium text-sm py-2.5 text-center inline-flex items-center dark:text-white',
|
|
10
|
+
base: 'focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium text-sm py-2.5 text-center inline-flex items-center dark:text-white w-full md:w-auto',
|
|
11
11
|
variants: {
|
|
12
12
|
color: {
|
|
13
|
-
blue:
|
|
14
|
-
gray:
|
|
13
|
+
blue: "text-white bg-blue-700 hover:bg-blue-800 dark:bg-blue-600 dark:hover:bg-blue-700 focus:ring-blue-300",
|
|
14
|
+
gray: "text-white bg-gray-400 hover:bg-gray-600 dark:bg-gray-600 dark:hover:bg-gray-700 focus:ring-gray-300",
|
|
15
15
|
lightGray:
|
|
16
|
-
|
|
17
|
-
green:
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
"text-slate-700 bg-white focus:ring-slate-300 border border-gray-300 dark:bg-gray-700 dark:border-gray-600 focus:ring-blue-300",
|
|
17
|
+
green:
|
|
18
|
+
"text-white bg-green-700 hover:bg-green-800 dark:bg-green-600 dark:hover:bg-green-700 focus:ring-green-300",
|
|
19
|
+
red: "text-white bg-red-700 hover:bg-red-800 dark:bg-red-600 dark:hover:bg-red-700 focus:ring-red-300",
|
|
20
|
+
yellow:
|
|
21
|
+
"text-white bg-yellow-700 hover:bg-yellow-800 dark:bg-yellow-600 dark:hover:bg-yellow-700 focus:ring-yellow-300",
|
|
20
22
|
},
|
|
21
23
|
size: {
|
|
22
|
-
sm:
|
|
23
|
-
md:
|
|
24
|
-
lg:
|
|
24
|
+
sm: "px-5 py-1.5",
|
|
25
|
+
md: "px-5 py-2.5",
|
|
26
|
+
lg: "px-5 py-3.5",
|
|
25
27
|
// WORKAROUND: Compound variants don't work with classname-variants/react (revisit later)
|
|
26
|
-
rsm:
|
|
27
|
-
rmd:
|
|
28
|
-
rlg:
|
|
28
|
+
rsm: "px-2.5 py-2.5",
|
|
29
|
+
rmd: "px-3.5 py-3.5",
|
|
30
|
+
rlg: "px-4.5 py-4.5",
|
|
29
31
|
},
|
|
30
32
|
type: {
|
|
31
|
-
rect:
|
|
32
|
-
round:
|
|
33
|
+
rect: "rounded-lg",
|
|
34
|
+
round: "rounded-full",
|
|
33
35
|
},
|
|
34
36
|
defaultVariants: {
|
|
35
|
-
color:
|
|
36
|
-
size:
|
|
37
|
-
type:
|
|
37
|
+
color: "blue",
|
|
38
|
+
size: "md",
|
|
39
|
+
type: "rect",
|
|
38
40
|
},
|
|
39
41
|
},
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
const DropdownState = Object.freeze({
|
|
43
|
-
OPEN: 'open',
|
|
44
|
-
CLOSED: 'closed',
|
|
45
|
-
})
|
|
42
|
+
});
|
|
46
43
|
|
|
47
44
|
export function Dropdown({ id, label, type, color, size, children }) {
|
|
48
|
-
const [showDropdown, setShowDropdown] = useState(
|
|
49
|
-
|
|
50
|
-
const currState = showDropdown
|
|
51
|
-
setShowDropdown(currState === DropdownState.CLOSED ? DropdownState.OPEN : DropdownState.CLOSED)
|
|
52
|
-
}
|
|
53
|
-
|
|
45
|
+
const [showDropdown, setShowDropdown] = useState(false)
|
|
46
|
+
|
|
54
47
|
useEffect(() => {
|
|
48
|
+
|
|
55
49
|
const handleClickOutside = (e) => {
|
|
56
|
-
if (e.target.id === id) return
|
|
57
|
-
setShowDropdown(
|
|
50
|
+
if (e.target.id === id || e.target.id === `${id}-span` || e.target.id === `${id}-chevron`) return
|
|
51
|
+
setShowDropdown(false)
|
|
58
52
|
}
|
|
59
53
|
|
|
60
|
-
document.addEventListener(
|
|
54
|
+
document.addEventListener("click", handleClickOutside);
|
|
61
55
|
|
|
62
56
|
return () => {
|
|
63
|
-
document.removeEventListener(
|
|
64
|
-
}
|
|
65
|
-
}, [])
|
|
57
|
+
document.removeEventListener("click", handleClickOutside);
|
|
58
|
+
};
|
|
59
|
+
}, []);
|
|
60
|
+
|
|
61
|
+
const handleShowDropdown = () => {
|
|
62
|
+
setShowDropdown(prevState => !prevState)
|
|
63
|
+
}
|
|
64
|
+
|
|
66
65
|
|
|
67
66
|
return (
|
|
68
67
|
<div className="relative">
|
|
69
68
|
<DropdownContext.Provider value={{ showDropdown, setShowDropdown }}>
|
|
70
|
-
<button id={id}
|
|
71
|
-
{
|
|
72
|
-
{
|
|
69
|
+
<button id={id}
|
|
70
|
+
{...buttonProps({ color, size, type })}
|
|
71
|
+
data-dropdown-toggle={`${id}-dropdown`}
|
|
72
|
+
type="button"
|
|
73
|
+
onClick={() => handleShowDropdown(true)}
|
|
74
|
+
>
|
|
75
|
+
<span id={`${id}-span`}className='flex-auto' >{label}</span>
|
|
76
|
+
{type === 'rect' && <span id={`${id}-chevron`} className='items-right flex justify-end'><BiChevronDown className="pointer-events-none" /></span>}
|
|
73
77
|
</button>
|
|
74
78
|
<div
|
|
75
|
-
id={`${id}-dropdown`}
|
|
76
|
-
className={
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
id={`${showDropdown}${id}-dropdown`}
|
|
80
|
+
className={
|
|
81
|
+
`z-50 mt-2 absolute w-full md:w-44 bg-white divide-y divide-gray-100 rounded-lg shadow dark:bg-gray-700 ${
|
|
82
|
+
showDropdown ? '' : 'hidden'
|
|
83
|
+
}`}
|
|
79
84
|
>
|
|
80
|
-
<ul
|
|
85
|
+
<ul
|
|
86
|
+
className="py-2 text-sm text-gray-700 dark:text-gray-200"
|
|
87
|
+
aria-labelledby="dropdownDefaultButton"
|
|
88
|
+
>
|
|
81
89
|
{children}
|
|
82
90
|
</ul>
|
|
83
91
|
</div>
|
|
84
92
|
</DropdownContext.Provider>
|
|
85
93
|
</div>
|
|
86
|
-
)
|
|
94
|
+
);
|
|
87
95
|
}
|
|
88
96
|
|
|
89
97
|
export function DropdownDivider() {
|
|
90
98
|
return (
|
|
91
99
|
<li>
|
|
92
|
-
<hr className="h-px
|
|
100
|
+
<hr className="my-2 h-px border-0 bg-gray-200 dark:bg-gray-700" />
|
|
93
101
|
</li>
|
|
94
|
-
)
|
|
102
|
+
);
|
|
95
103
|
}
|
|
96
104
|
|
|
97
105
|
export function DropdownItem({ callback, children }) {
|
|
98
|
-
const context = useContext(DropdownContext)
|
|
106
|
+
const context = useContext(DropdownContext);
|
|
99
107
|
|
|
100
108
|
const handleSelection = () => {
|
|
101
|
-
context.setShowDropdown(false)
|
|
102
|
-
callback()
|
|
103
|
-
}
|
|
109
|
+
context.setShowDropdown(false);
|
|
110
|
+
callback();
|
|
111
|
+
};
|
|
104
112
|
return (
|
|
105
113
|
<li>
|
|
106
|
-
<div
|
|
114
|
+
<div
|
|
115
|
+
className="block cursor-pointer px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"
|
|
116
|
+
onClick={handleSelection}
|
|
117
|
+
>
|
|
107
118
|
{children}
|
|
108
119
|
</div>
|
|
109
120
|
</li>
|
|
110
|
-
)
|
|
121
|
+
);
|
|
111
122
|
}
|
|
112
123
|
|
|
113
|
-
Dropdown.Divider = DropdownDivider
|
|
114
|
-
Dropdown.Item = DropdownItem
|
|
124
|
+
Dropdown.Divider = DropdownDivider;
|
|
125
|
+
Dropdown.Item = DropdownItem;
|
|
115
126
|
|
|
116
127
|
Dropdown.propTypes = {
|
|
117
128
|
/** Unique id for the dropdown */
|
|
@@ -119,25 +130,32 @@ Dropdown.propTypes = {
|
|
|
119
130
|
/** Components to be rendered as Part of the Compound Component*/
|
|
120
131
|
children: PropTypes.node.isRequired,
|
|
121
132
|
/** Shape of the button rectangle or round */
|
|
122
|
-
type: PropTypes.oneOf([
|
|
133
|
+
type: PropTypes.oneOf(["rect", "round"]),
|
|
123
134
|
/** Size of the button sm,md,lg used for rectangle and rsm, rmd, rlg used for a round button */
|
|
124
|
-
size: PropTypes.oneOf([
|
|
135
|
+
size: PropTypes.oneOf(["sm", "md", "lg", "rsm", "rmd", "rlg"]),
|
|
125
136
|
/** Colour of the button based upon predefined values */
|
|
126
|
-
color: PropTypes.oneOf([
|
|
137
|
+
color: PropTypes.oneOf([
|
|
138
|
+
"blue",
|
|
139
|
+
"gray",
|
|
140
|
+
"lightGray",
|
|
141
|
+
"green",
|
|
142
|
+
"red",
|
|
143
|
+
"yellow",
|
|
144
|
+
]),
|
|
127
145
|
/** Rectangle should have a text label eg:'Dropdown' and a round type should take an icon element eg:'...' */
|
|
128
146
|
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
|
|
129
|
-
}
|
|
147
|
+
};
|
|
130
148
|
Dropdown.defaultProps = {
|
|
131
|
-
type:
|
|
132
|
-
size:
|
|
133
|
-
color:
|
|
134
|
-
label:
|
|
135
|
-
}
|
|
149
|
+
type: "rect",
|
|
150
|
+
size: "md",
|
|
151
|
+
color: "blue",
|
|
152
|
+
label: "Dropdown",
|
|
153
|
+
};
|
|
136
154
|
DropdownItem.propTypes = {
|
|
137
155
|
/** Returns value of the dropdown item selected*/
|
|
138
156
|
callback: PropTypes.func.isRequired,
|
|
139
|
-
}
|
|
157
|
+
};
|
|
140
158
|
|
|
141
|
-
Dropdown.displayName =
|
|
142
|
-
DropdownDivider.displayName =
|
|
143
|
-
DropdownItem.displayName =
|
|
159
|
+
Dropdown.displayName = "Dropdown";
|
|
160
|
+
DropdownDivider.displayName = "Dropdown.Divider";
|
|
161
|
+
DropdownItem.displayName = "Dropdown.Item";
|
|
@@ -1,72 +1,107 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { Radio } from "../radio";
|
|
5
5
|
|
|
6
6
|
// FOR USE WITH THE FILE PICKER COMPONENT - ONLY
|
|
7
7
|
|
|
8
|
-
export default function Listing({
|
|
9
|
-
|
|
8
|
+
export default function Listing({
|
|
9
|
+
border,
|
|
10
|
+
files,
|
|
11
|
+
isMore,
|
|
12
|
+
selected,
|
|
13
|
+
page,
|
|
14
|
+
pages,
|
|
15
|
+
callback,
|
|
16
|
+
}) {
|
|
17
|
+
const scrollRef = useRef();
|
|
10
18
|
|
|
11
19
|
useEffect(() => {
|
|
12
|
-
const element = document.querySelector(
|
|
13
|
-
if (element && !element.hasAttribute(
|
|
14
|
-
|
|
20
|
+
const element = document.querySelector("#img-file-list");
|
|
21
|
+
if (element && !element.hasAttribute("scroll"))
|
|
22
|
+
scrollRef.current.addEventListener("scroll", handleScroll);
|
|
23
|
+
if (scrollRef.current != null) scrollRef.current.scrollTop = 0;
|
|
15
24
|
return () => {
|
|
16
|
-
const element = document.querySelector(
|
|
17
|
-
if (element && element.hasAttribute(
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
const element = document.querySelector("#img-file-list");
|
|
26
|
+
if (element && element.hasAttribute("scroll"))
|
|
27
|
+
scrollRef.current.removeEventListener("scroll", handleScroll);
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
20
30
|
|
|
21
31
|
const handleScroll = () => {
|
|
22
|
-
if (!isMore) return
|
|
23
|
-
const offset =
|
|
24
|
-
|
|
32
|
+
if (!isMore) return;
|
|
33
|
+
const offset =
|
|
34
|
+
scrollRef.current.scrollHeight - scrollRef.current.offsetHeight;
|
|
35
|
+
const scroll = Math.floor(scrollRef.current.scrollTop);
|
|
25
36
|
// the '-2 & +2' is used as a buffer, otherwise '==' positioning of the scroll becomes too accurate.
|
|
26
37
|
if (scroll == offset || scroll + 2 == offset || scroll - 2 == offset) {
|
|
27
|
-
callback({ type:
|
|
38
|
+
callback({ type: "FETCH_DATA", payload: true });
|
|
28
39
|
}
|
|
29
|
-
}
|
|
40
|
+
};
|
|
30
41
|
|
|
31
42
|
const handleImageSelection = (fileName) => {
|
|
32
|
-
callback({
|
|
33
|
-
|
|
43
|
+
callback({
|
|
44
|
+
type: "SELECTION",
|
|
45
|
+
payload: selected === fileName ? "" : fileName,
|
|
46
|
+
});
|
|
47
|
+
};
|
|
34
48
|
|
|
35
49
|
return (
|
|
36
|
-
<div
|
|
50
|
+
<div
|
|
51
|
+
id="img-file-list"
|
|
52
|
+
ref={scrollRef}
|
|
53
|
+
className={`${border} overflow-y-auto rounded-md border`}
|
|
54
|
+
>
|
|
37
55
|
{(files || []).map((f) => {
|
|
38
|
-
return
|
|
56
|
+
return (
|
|
57
|
+
<FileRow
|
|
58
|
+
key={`file-row-${f.Name}`}
|
|
59
|
+
file={f}
|
|
60
|
+
selected={selected === f.Name}
|
|
61
|
+
callback={handleImageSelection}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
39
64
|
})}
|
|
40
65
|
{isMore && page < pages && <InfiniteLoader />}
|
|
41
66
|
</div>
|
|
42
|
-
)
|
|
67
|
+
);
|
|
43
68
|
}
|
|
44
69
|
|
|
45
70
|
function FileRow({ file, selected = false, callback }) {
|
|
46
71
|
return (
|
|
47
72
|
<div
|
|
48
|
-
className={`flex items-center
|
|
73
|
+
className={`mb-1 mt-1 flex items-center pb-4 pt-4 ${
|
|
74
|
+
selected && "bg-blue-50"
|
|
75
|
+
} cursor-pointer justify-between border-b border-gray-100`}
|
|
49
76
|
onClick={() => {
|
|
50
|
-
callback(file)
|
|
77
|
+
callback(file);
|
|
51
78
|
}}
|
|
52
79
|
>
|
|
53
|
-
<div className="flex items-center
|
|
80
|
+
<div className="ml-3 flex items-center">
|
|
54
81
|
<div className="flex-shrink-0">
|
|
55
82
|
<Radio id={file.Name} name={file.Name} checked={selected} readOnly />
|
|
56
83
|
</div>
|
|
57
84
|
<div className="ml-4">
|
|
58
|
-
<img
|
|
85
|
+
<img
|
|
86
|
+
className="h-10 w-10 rounded-md"
|
|
87
|
+
src={`https://files.ekmcdn.com/${file.Uri}`}
|
|
88
|
+
alt=""
|
|
89
|
+
/>
|
|
59
90
|
</div>
|
|
60
91
|
<div className="ml-4">
|
|
61
92
|
<div className=" font-medium text-gray-900">{file.Name}</div>
|
|
62
|
-
{file.Size &&
|
|
93
|
+
{file.Size && (
|
|
94
|
+
<div className="text-xs text-gray-500">{file.Size}</div>
|
|
95
|
+
)}
|
|
63
96
|
</div>
|
|
64
97
|
</div>
|
|
65
98
|
<div className="ml-4 flex-shrink-0">
|
|
66
|
-
<span className="
|
|
99
|
+
<span className="mr-3 text-sm text-gray-500">
|
|
100
|
+
{writeDate(file.LastWriteTime)}
|
|
101
|
+
</span>
|
|
67
102
|
</div>
|
|
68
103
|
</div>
|
|
69
|
-
)
|
|
104
|
+
);
|
|
70
105
|
}
|
|
71
106
|
|
|
72
107
|
Listing.propTypes = {
|
|
@@ -84,7 +119,7 @@ Listing.propTypes = {
|
|
|
84
119
|
pages: PropTypes.number,
|
|
85
120
|
/** Callback function to handle events */
|
|
86
121
|
callback: PropTypes.func,
|
|
87
|
-
}
|
|
122
|
+
};
|
|
88
123
|
|
|
89
124
|
FileRow.propTypes = {
|
|
90
125
|
/** File object to display */
|
|
@@ -93,15 +128,15 @@ FileRow.propTypes = {
|
|
|
93
128
|
selected: PropTypes.bool,
|
|
94
129
|
/** Callback function to handle events */
|
|
95
130
|
callback: PropTypes.func,
|
|
96
|
-
}
|
|
131
|
+
};
|
|
97
132
|
|
|
98
133
|
function InfiniteLoader() {
|
|
99
134
|
return (
|
|
100
|
-
<div className="flex justify-center
|
|
135
|
+
<div className="mb-1 mt-1 flex justify-center pb-4 pt-4">
|
|
101
136
|
<div role="status">
|
|
102
137
|
<svg
|
|
103
138
|
aria-hidden="true"
|
|
104
|
-
className="inline-block
|
|
139
|
+
className="inline-block h-8 w-8 animate-spin fill-gray-600 text-gray-200 dark:fill-gray-300 dark:text-gray-600"
|
|
105
140
|
viewBox="0 0 100 101"
|
|
106
141
|
fill="none"
|
|
107
142
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -117,15 +152,28 @@ function InfiniteLoader() {
|
|
|
117
152
|
</svg>
|
|
118
153
|
</div>
|
|
119
154
|
</div>
|
|
120
|
-
)
|
|
155
|
+
);
|
|
121
156
|
}
|
|
122
157
|
|
|
123
158
|
function writeDate(date) {
|
|
124
159
|
try {
|
|
125
|
-
const d = new Date(date)
|
|
126
|
-
const months = [
|
|
127
|
-
|
|
160
|
+
const d = new Date(date);
|
|
161
|
+
const months = [
|
|
162
|
+
"January",
|
|
163
|
+
"February",
|
|
164
|
+
"March",
|
|
165
|
+
"April",
|
|
166
|
+
"May",
|
|
167
|
+
"June",
|
|
168
|
+
"July",
|
|
169
|
+
"August",
|
|
170
|
+
"September",
|
|
171
|
+
"October",
|
|
172
|
+
"November",
|
|
173
|
+
"December",
|
|
174
|
+
];
|
|
175
|
+
return d.getDate() + " " + months[d.getMonth()] + " " + d.getFullYear();
|
|
128
176
|
} catch (err) {
|
|
129
|
-
return
|
|
177
|
+
return "Unknown";
|
|
130
178
|
}
|
|
131
179
|
}
|