se-design 1.0.21 → 1.0.23
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/dist/components/Dropdown/index.d.ts +1 -0
- package/dist/components/Popover/index.d.ts +2 -0
- package/dist/index17.js +29 -26
- package/dist/index17.js.map +1 -1
- package/dist/index21.js +9 -9
- package/dist/index21.js.map +1 -1
- package/dist/index23.js +84 -86
- package/dist/index23.js.map +1 -1
- package/dist/index5.js +15 -15
- package/dist/index5.js.map +1 -1
- package/package.json +1 -1
|
@@ -20,5 +20,7 @@ export interface PopoverProps {
|
|
|
20
20
|
disabled?: boolean;
|
|
21
21
|
isWithPortal?: boolean;
|
|
22
22
|
noBorder?: boolean;
|
|
23
|
+
ariaLabel?: string;
|
|
24
|
+
sourceRole?: 'button' | 'combobox';
|
|
23
25
|
}
|
|
24
26
|
export declare const Popover: React.ForwardRefExoticComponent<PopoverProps & React.RefAttributes<PopoverHandle>>;
|
package/dist/index17.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import R, { forwardRef as
|
|
2
|
-
import
|
|
1
|
+
import R, { forwardRef as Y, useState as E, useRef as V, useEffect as C, useImperativeHandle as Z } from "react";
|
|
2
|
+
import ee from "react-dom";
|
|
3
3
|
function H() {
|
|
4
4
|
return H = Object.assign ? Object.assign.bind() : function(v) {
|
|
5
5
|
for (var g = 1; g < arguments.length; g++) {
|
|
@@ -9,7 +9,7 @@ function H() {
|
|
|
9
9
|
return v;
|
|
10
10
|
}, H.apply(null, arguments);
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const re = /* @__PURE__ */ Y(({
|
|
13
13
|
className: v = "",
|
|
14
14
|
automationId: g = "",
|
|
15
15
|
position: f = "bottom-center",
|
|
@@ -19,11 +19,13 @@ const te = /* @__PURE__ */ J(({
|
|
|
19
19
|
renderPopoverSrcElement: F,
|
|
20
20
|
onPopoverToggle: j,
|
|
21
21
|
isPopoverOpen: B,
|
|
22
|
-
disabled:
|
|
22
|
+
disabled: w = !1,
|
|
23
23
|
isWithPortal: b = !1,
|
|
24
|
+
ariaLabel: N,
|
|
25
|
+
sourceRole: W = "button",
|
|
24
26
|
...T
|
|
25
|
-
},
|
|
26
|
-
const [c, u] = E(!1), [
|
|
27
|
+
}, _) => {
|
|
28
|
+
const [c, u] = E(!1), [h, z] = E(f), [X, O] = E(!1), a = V(null), l = V(null), [$, y] = E({
|
|
27
29
|
top: 0,
|
|
28
30
|
left: 0
|
|
29
31
|
}), k = (e = "bottom-center") => {
|
|
@@ -59,8 +61,8 @@ const te = /* @__PURE__ */ J(({
|
|
|
59
61
|
}
|
|
60
62
|
const p = l.current?.getBoundingClientRect(), A = p?.width || 0, d = p?.height || 0;
|
|
61
63
|
if (i + A > n && (i = Math.max(0, n - A)), i < 0 && (i = 0), r + d > s) {
|
|
62
|
-
const U = t.top,
|
|
63
|
-
U >= d || U >
|
|
64
|
+
const U = t.top, Q = s - t.bottom;
|
|
65
|
+
U >= d || U > Q ? (r = t.top - d, r < 0 && (r = 0)) : r = Math.max(0, s - d);
|
|
64
66
|
}
|
|
65
67
|
return r < 0 && (r = t.bottom, r + d > s && (r = Math.max(0, s - d))), {
|
|
66
68
|
top: r,
|
|
@@ -69,14 +71,14 @@ const te = /* @__PURE__ */ J(({
|
|
|
69
71
|
};
|
|
70
72
|
C(() => {
|
|
71
73
|
if (j && j(c), c && !b)
|
|
72
|
-
return document.body.addEventListener("click", q, !0),
|
|
74
|
+
return document.body.addEventListener("click", q, !0), G(), () => document.body.removeEventListener("click", q, !0);
|
|
73
75
|
if (c && b) {
|
|
74
76
|
document.body.addEventListener("click", P, !0), window.addEventListener("scroll", P), window.addEventListener("resize", K);
|
|
75
77
|
const e = setTimeout(() => {
|
|
76
|
-
const t = k(
|
|
78
|
+
const t = k(h);
|
|
77
79
|
D(), t && y(t);
|
|
78
80
|
}, 0), o = setTimeout(() => {
|
|
79
|
-
const t = k(
|
|
81
|
+
const t = k(h);
|
|
80
82
|
t && y(t);
|
|
81
83
|
}, 10);
|
|
82
84
|
return () => {
|
|
@@ -100,7 +102,7 @@ const te = /* @__PURE__ */ J(({
|
|
|
100
102
|
o && document.activeElement === a.current && o.focus();
|
|
101
103
|
}, 0);
|
|
102
104
|
}, [c]);
|
|
103
|
-
const
|
|
105
|
+
const G = () => {
|
|
104
106
|
if (!l.current) return;
|
|
105
107
|
const e = l.current.getBoundingClientRect(), o = window.innerHeight;
|
|
106
108
|
e?.bottom > o ? z(f.includes("left") ? "top-left" : f.includes("right") ? "top-right" : "top-center") : e?.top < 0 && z(f.includes("left") ? "bottom-left" : f.includes("right") ? "bottom-right" : "bottom-center");
|
|
@@ -113,7 +115,7 @@ const te = /* @__PURE__ */ J(({
|
|
|
113
115
|
const o = a.current, t = l.current;
|
|
114
116
|
if (!o) return;
|
|
115
117
|
if (D(), e.type === "scroll" && c) {
|
|
116
|
-
const d = k(
|
|
118
|
+
const d = k(h);
|
|
117
119
|
d && y(d);
|
|
118
120
|
}
|
|
119
121
|
const n = e.target, s = o.contains(n), r = t?.contains(n), p = n.closest?.(".se-design-popover-wrapper");
|
|
@@ -121,7 +123,7 @@ const te = /* @__PURE__ */ J(({
|
|
|
121
123
|
}, K = () => {
|
|
122
124
|
if (c && b && a.current) {
|
|
123
125
|
D();
|
|
124
|
-
const e = k(
|
|
126
|
+
const e = k(h);
|
|
125
127
|
e && y(e);
|
|
126
128
|
}
|
|
127
129
|
}, x = () => {
|
|
@@ -137,10 +139,10 @@ const te = /* @__PURE__ */ J(({
|
|
|
137
139
|
let r = -1;
|
|
138
140
|
e.key === "ArrowDown" ? (e.preventDefault(), e.stopPropagation(), r = s < n.length - 1 ? s + 1 : 0) : e.key === "ArrowUp" ? (e.preventDefault(), e.stopPropagation(), r = s > 0 ? s - 1 : n.length - 1) : e.key === "Home" ? (e.preventDefault(), e.stopPropagation(), r = 0) : e.key === "End" && (e.preventDefault(), e.stopPropagation(), r = n.length - 1), r >= 0 && n[r] ? n[r].focus() : s === -1 && n.length > 0 && n[0].focus();
|
|
139
141
|
};
|
|
140
|
-
|
|
142
|
+
Z(_, () => ({
|
|
141
143
|
togglePopover: x
|
|
142
144
|
}), []);
|
|
143
|
-
const
|
|
145
|
+
const J = {
|
|
144
146
|
"bottom-left": {
|
|
145
147
|
left: "0",
|
|
146
148
|
top: "100%"
|
|
@@ -169,13 +171,13 @@ const te = /* @__PURE__ */ J(({
|
|
|
169
171
|
}
|
|
170
172
|
}, M = T?.noBorder ? "" : "shadow-md border rounded-md";
|
|
171
173
|
return /* @__PURE__ */ R.createElement("div", H({
|
|
172
|
-
className: "se-design-popover-wrapper cursor-pointer relative" + (v.length > 0 ? ` ${v}` : "") + (c ? " open" : "") + (
|
|
174
|
+
className: "se-design-popover-wrapper cursor-pointer relative" + (v.length > 0 ? ` ${v}` : "") + (c ? " open" : "") + (w ? " opacity-50 cursor-not-allowed pointer-events-none" : ""),
|
|
173
175
|
ref: a,
|
|
174
176
|
onClick: (e) => {
|
|
175
|
-
|
|
177
|
+
w || (e.stopPropagation(), x());
|
|
176
178
|
},
|
|
177
179
|
onKeyDown: (e) => {
|
|
178
|
-
if (!
|
|
180
|
+
if (!w)
|
|
179
181
|
if (e.key === "Enter" || e.key === " ") {
|
|
180
182
|
e.preventDefault(), e.stopPropagation();
|
|
181
183
|
const o = c;
|
|
@@ -199,11 +201,12 @@ const te = /* @__PURE__ */ J(({
|
|
|
199
201
|
}
|
|
200
202
|
}, 0));
|
|
201
203
|
},
|
|
202
|
-
role:
|
|
203
|
-
"aria-expanded": c,
|
|
204
|
+
role: W,
|
|
205
|
+
"aria-expanded": c ? "true" : "false",
|
|
204
206
|
"aria-haspopup": "true",
|
|
205
|
-
tabIndex:
|
|
206
|
-
"aria-disabled":
|
|
207
|
+
tabIndex: 0,
|
|
208
|
+
"aria-disabled": w ? "true" : "false",
|
|
209
|
+
"aria-label": N,
|
|
207
210
|
"data-automation-id": g
|
|
208
211
|
}, T), F({
|
|
209
212
|
displayPopover: c,
|
|
@@ -214,7 +217,7 @@ const te = /* @__PURE__ */ J(({
|
|
|
214
217
|
borderColor: "var(--color-gray-200)",
|
|
215
218
|
color: "var(--color-gray-900)",
|
|
216
219
|
backgroundColor: "var(--color-white)",
|
|
217
|
-
...
|
|
220
|
+
...J[h]
|
|
218
221
|
},
|
|
219
222
|
onClick: (e) => e.stopPropagation(),
|
|
220
223
|
onKeyDown: (e) => {
|
|
@@ -226,7 +229,7 @@ const te = /* @__PURE__ */ J(({
|
|
|
226
229
|
"data-automation-id": m
|
|
227
230
|
}, I({
|
|
228
231
|
closePopoverCb: () => u(!1)
|
|
229
|
-
})), b && c &&
|
|
232
|
+
})), b && c && X && /* @__PURE__ */ ee.createPortal(/* @__PURE__ */ R.createElement("div", {
|
|
230
233
|
className: `popover-content-with-portal ${M} ${L == "full" ? "w-full" : "w-max"}`,
|
|
231
234
|
style: {
|
|
232
235
|
position: "fixed",
|
|
@@ -250,6 +253,6 @@ const te = /* @__PURE__ */ J(({
|
|
|
250
253
|
})), document.body));
|
|
251
254
|
});
|
|
252
255
|
export {
|
|
253
|
-
|
|
256
|
+
re as Popover
|
|
254
257
|
};
|
|
255
258
|
//# sourceMappingURL=index17.js.map
|
package/dist/index17.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index17.js","sources":["../src/components/Popover/index.tsx"],"sourcesContent":["import React, { useState, useRef, ReactNode, useEffect, forwardRef, ForwardedRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\n\nexport interface PopoverHandle {\n togglePopover: () => void;\n}\n\nexport interface PopoverProps {\n className?: string;\n automationId?: string;\n popoverContentAutomationId?: string;\n renderPopoverContents: (props: { closePopoverCb: () => void }) => ReactNode;\n renderPopoverSrcElement: (props: { displayPopover: boolean; togglePopover: () => void }) => ReactNode;\n position?: 'bottom-center' | 'bottom-left' | 'bottom-right' | 'top-center' | 'top-left' | 'top-right';\n onPopoverToggle?: (displayPopover: boolean) => void;\n contentWidth?: 'full' | 'max';\n isPopoverOpen?: boolean;\n disabled?: boolean;\n isWithPortal?: boolean;\n noBorder?: boolean;\n}\n\nexport const Popover = forwardRef<PopoverHandle, PopoverProps>(\n (\n {\n className = '',\n automationId = '',\n position = 'bottom-center',\n popoverContentAutomationId = '',\n contentWidth = 'max',\n renderPopoverContents,\n renderPopoverSrcElement,\n onPopoverToggle,\n isPopoverOpen,\n disabled = false,\n isWithPortal = false,\n ...props\n },\n ref: ForwardedRef<PopoverHandle>\n ) => {\n const [displayPopover, setDisplayPopover] = useState(false);\n const [popoverPosition, setPopoverPosition] = useState(position);\n const [isSrcElementVisible, setIsSrcElementVisible] = useState(false);\n const srcElementRef = useRef<HTMLDivElement>(null);\n const popoverContentRef = useRef<HTMLDivElement>(null);\n\n const [portalPosition, setPortalPosition] = useState({ top: 0, left: 0 });\n\n const calculatePositionOfPopover = (position: string = 'bottom-center') => {\n if (!srcElementRef.current) return { top: 0, left: 0 };\n\n let localPosition = position;\n\n const srcRect = srcElementRef.current.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Calculate position for portal\n let top = 0;\n let left = 0;\n\n switch (localPosition) {\n case 'bottom-left':\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n case 'bottom-right':\n top = srcRect.bottom;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'bottom-center':\n top = srcRect.bottom;\n left = srcRect.left + srcRect.width * 0.15;\n break;\n case 'top-left':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.left;\n break;\n case 'top-right':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'top-center':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.left + srcRect.width * 0.15;\n break;\n default:\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n }\n\n // Get popover dimensions if available\n const popoverRect = popoverContentRef.current?.getBoundingClientRect();\n const popoverWidth = popoverRect?.width || 0;\n const popoverHeight = popoverRect?.height || 0;\n\n // Adjust position to keep popover within viewport bounds\n // Horizontal adjustments\n if (left + popoverWidth > viewportWidth) {\n // Popover extends beyond right edge, shift it left\n left = Math.max(0, viewportWidth - popoverWidth);\n }\n if (left < 0) {\n // Popover extends beyond left edge, shift it right\n left = 0;\n }\n\n // Vertical adjustments\n if (top + popoverHeight > viewportHeight) {\n // Popover extends beyond bottom edge\n // Try to position it above the source element\n const spaceAbove = srcRect.top;\n const spaceBelow = viewportHeight - srcRect.bottom;\n \n if (spaceAbove >= popoverHeight || spaceAbove > spaceBelow) {\n // Position above if there's enough space or more space above\n top = srcRect.top - popoverHeight;\n // Ensure it doesn't go above viewport\n if (top < 0) {\n top = 0;\n }\n } else {\n // Keep at bottom but adjust to fit within viewport\n top = Math.max(0, viewportHeight - popoverHeight);\n }\n }\n if (top < 0) {\n // Popover extends beyond top edge, position it below the source element\n top = srcRect.bottom;\n // Ensure it doesn't go below viewport\n if (top + popoverHeight > viewportHeight) {\n top = Math.max(0, viewportHeight - popoverHeight);\n }\n }\n\n return { top, left };\n };\n \n useEffect(() => {\n if (onPopoverToggle) {\n onPopoverToggle(displayPopover);\n }\n\n if (displayPopover && !isWithPortal) {\n document.body.addEventListener('click', clickListener, true);\n checkPopoverPosition();\n return () => document.body.removeEventListener('click', clickListener, true);\n } else if (displayPopover && isWithPortal) {\n document.body.addEventListener('click', clickAndScrollListenerWithPortal, true);\n window.addEventListener('scroll', clickAndScrollListenerWithPortal);\n window.addEventListener('resize', resizeListenerWithPortal);\n\n // Initial position calculation\n const timeout1 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n checkSourceVisibility();\n \n if (position) {\n setPortalPosition(position);\n }\n }, 0);\n\n // Recalculate after popover is rendered to get accurate dimensions\n const timeout2 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }, 10);\n\n return () => {\n document.body.removeEventListener('click', clickAndScrollListenerWithPortal, true);\n window.removeEventListener('scroll', clickAndScrollListenerWithPortal);\n window.removeEventListener('resize', resizeListenerWithPortal);\n clearTimeout(timeout1);\n clearTimeout(timeout2);\n };\n }\n }, [displayPopover, isWithPortal]);\n\n const checkSourceVisibility = () => {\n if (!srcElementRef.current) {\n setIsSrcElementVisible(false);\n return;\n }\n\n const rec = srcElementRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n\n const isVisible = rec.top < viewportHeight && rec.bottom > 0 && rec.left < viewportWidth && rec.right > 0;\n\n setIsSrcElementVisible(isVisible);\n };\n\n useEffect(() => {\n setDisplayPopover(isPopoverOpen ?? false);\n }, [isPopoverOpen]);\n\n useEffect(() => {\n // Focus first focusable element when popover opens\n if (displayPopover && popoverContentRef.current) {\n setTimeout(() => {\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n const firstFocusable = popoverContentRef.current?.querySelector<HTMLElement>(focusableSelectors);\n if (firstFocusable && document.activeElement === srcElementRef.current) {\n firstFocusable.focus();\n }\n }, 0);\n }\n }, [displayPopover]);\n\n //Function to check popover position\n const checkPopoverPosition = () => {\n if (!popoverContentRef.current) return;\n\n const popoverRect = popoverContentRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n\n if (popoverRect?.bottom > viewportHeight) {\n setPopoverPosition(\n position.includes('left') ? 'top-left' : position.includes('right') ? 'top-right' : 'top-center'\n );\n } else if (popoverRect?.top < 0) {\n // If popover extends beyond top of viewport, switch to bottom position\n setPopoverPosition(\n position.includes('left') ? 'bottom-left' : position.includes('right') ? 'bottom-right' : 'bottom-center'\n );\n }\n };\n\n const clickListener = (event: MouseEvent) => {\n const currentDropRef = srcElementRef.current;\n if (!currentDropRef) return;\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = popoverContentRef.current?.contains(target);\n \n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n \n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if ((!isSourcePopover && !isPopoverContent) || isAnotherPopoverSource) {\n setDisplayPopover(false);\n }\n };\n\n const clickAndScrollListenerWithPortal = (event: Event) => {\n const currentDropRef = srcElementRef.current;\n const currentPopoverRef = popoverContentRef.current;\n if (!currentDropRef) return;\n checkSourceVisibility();\n\n // Recalculate position on scroll\n if (event.type === 'scroll' && displayPopover) {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = currentPopoverRef?.contains(target);\n \n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if ((!isSourcePopover && !isPopoverContent) || isAnotherPopoverSource) {\n setDisplayPopover(false);\n }\n };\n\n const resizeListenerWithPortal = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const togglePopover = () => {\n setDisplayPopover((displayPopover) => !displayPopover);\n };\n\n const handleArrowKeyNavigation = (e: React.KeyboardEvent, container: HTMLDivElement | null) => {\n if (!container) return;\n\n // Find all focusable elements within the popover content\n // This includes elements with role=\"menuitem\", role=\"option\", tabIndex >= 0, etc.\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n\n const focusableElements = Array.from(\n container.querySelectorAll<HTMLElement>(focusableSelectors)\n ).filter((el) => {\n // Filter out disabled and hidden elements\n const style = window.getComputedStyle(el);\n return (\n !el.hasAttribute('disabled') &&\n !el.hasAttribute('aria-disabled') &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (el.tabIndex >= 0 || el.hasAttribute('role'))\n );\n });\n\n if (focusableElements.length === 0) return;\n\n const currentIndex = focusableElements.findIndex((el) => el === document.activeElement);\n let nextIndex = -1;\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex < focusableElements.length - 1 ? currentIndex + 1 : 0;\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex > 0 ? currentIndex - 1 : focusableElements.length - 1;\n } else if (e.key === 'Home') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = 0;\n } else if (e.key === 'End') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = focusableElements.length - 1;\n }\n\n if (nextIndex >= 0 && focusableElements[nextIndex]) {\n focusableElements[nextIndex].focus();\n } else if (currentIndex === -1 && focusableElements.length > 0) {\n // If no element is currently focused, focus the first one\n focusableElements[0].focus();\n }\n };\n\n useImperativeHandle(ref, () => ({ togglePopover }), []);\n\n const popoverContentStyle = {\n 'bottom-left': { left: '0', top: '100%' },\n 'bottom-right': { right: '0', top: '100%' },\n 'bottom-center': { left: '50%', transform: 'translateX(-50%)', top: '100%' },\n 'top-left': { left: '0', bottom: '100%' },\n 'top-right': { right: '0', bottom: '100%' },\n 'top-center': { left: '50%', transform: 'translateX(-50%)', bottom: '100%' }\n };\n const popoverContentClasses = props?.noBorder ? '' : 'shadow-md border rounded-md';\n\n return (\n <div\n className={\n 'se-design-popover-wrapper cursor-pointer relative' +\n (className.length > 0 ? ` ${className}` : '') +\n (displayPopover ? ' open' : '') +\n (disabled ? ' opacity-50 cursor-not-allowed pointer-events-none' : '')\n }\n ref={srcElementRef}\n onClick={(e) => {\n if (disabled) return;\n e.stopPropagation();\n togglePopover();\n }}\n onKeyDown={(e) => {\n if (disabled) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n const wasOpen = displayPopover;\n togglePopover();\n // Focus first focusable element when opening\n if (!wasOpen) {\n setTimeout(() => {\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n const firstFocusable = currentRef.querySelector<HTMLElement>(focusableSelectors);\n if (firstFocusable) {\n firstFocusable.focus();\n }\n }\n }, 0);\n }\n } else if (e.key === 'Escape' && displayPopover) {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n } else if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && displayPopover) {\n // Handle arrow keys when popover is open\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n handleArrowKeyNavigation(e, currentRef);\n }\n } else if (e.key === 'ArrowDown' && !displayPopover) {\n // Open popover and focus first item when ArrowDown is pressed\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(true);\n setTimeout(() => {\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n const firstFocusable = currentRef.querySelector<HTMLElement>(focusableSelectors);\n if (firstFocusable) {\n firstFocusable.focus();\n }\n }\n }, 0);\n }\n }}\n role=\"button\"\n aria-expanded={displayPopover}\n aria-haspopup=\"true\"\n tabIndex={disabled ? -1 : 0}\n aria-disabled={disabled}\n data-automation-id={automationId}\n {...props}\n >\n {renderPopoverSrcElement({ displayPopover, togglePopover })}\n\n {displayPopover && !isWithPortal && (\n <div\n className={`popover-content absolute ${popoverContentClasses} z-[1000] ${contentWidth == 'full' ? 'w-full' : 'w-max'}`}\n style={{\n borderColor: 'var(--color-gray-200)',\n color: 'var(--color-gray-900)',\n backgroundColor: 'var(--color-white)',\n ...popoverContentStyle[popoverPosition]\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={(e) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n srcElementRef.current?.focus();\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n }\n }}\n role=\"dialog\"\n aria-modal=\"false\"\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\n </div>\n )}\n {isWithPortal &&\n displayPopover &&\n isSrcElementVisible &&\n ReactDOM.createPortal(\n <div\n className={`popover-content-with-portal ${popoverContentClasses} ${contentWidth == 'full' ? 'w-full' : 'w-max'}`}\n style={{\n position: 'fixed',\n top: portalPosition.top,\n left: portalPosition.left,\n zIndex: 1000,\n borderColor: 'var(--color-gray-200)',\n color: 'var(--color-gray-900)',\n backgroundColor: 'var(--color-white)'\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={(e) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n srcElementRef.current?.focus();\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n }\n }}\n role=\"dialog\"\n aria-modal=\"false\"\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\n </div>,\n document.body\n )}\n </div>\n );\n }\n);\n\n"],"names":["Popover","className","automationId","position","popoverContentAutomationId","contentWidth","renderPopoverContents","renderPopoverSrcElement","onPopoverToggle","isPopoverOpen","disabled","isWithPortal","props","ref","displayPopover","setDisplayPopover","useState","popoverPosition","setPopoverPosition","isSrcElementVisible","setIsSrcElementVisible","srcElementRef","useRef","popoverContentRef","portalPosition","setPortalPosition","top","left","calculatePositionOfPopover","current","localPosition","srcRect","getBoundingClientRect","viewportWidth","window","innerWidth","viewportHeight","innerHeight","bottom","right","width","height","popoverRect","popoverWidth","popoverHeight","Math","max","spaceAbove","spaceBelow","useEffect","document","body","addEventListener","clickListener","checkPopoverPosition","removeEventListener","clickAndScrollListenerWithPortal","resizeListenerWithPortal","timeout1","setTimeout","checkSourceVisibility","timeout2","clearTimeout","rec","isVisible","focusableSelectors","join","firstFocusable","querySelector","activeElement","focus","includes","event","currentDropRef","target","isSourcePopover","contains","isPopoverContent","closestPopoverWrapper","closest","currentPopoverRef","type","togglePopover","handleArrowKeyNavigation","e","container","focusableElements","Array","from","querySelectorAll","filter","el","style","getComputedStyle","hasAttribute","display","visibility","tabIndex","length","currentIndex","findIndex","nextIndex","key","preventDefault","stopPropagation","useImperativeHandle","popoverContentStyle","transform","popoverContentClasses","noBorder","React","createElement","_extends","onClick","onKeyDown","wasOpen","currentRef","role","borderColor","color","backgroundColor","closePopoverCb","ReactDOM","createPortal","zIndex"],"mappings":";;;;;;;;;;;AAsBO,MAAMA,uBACX,CACE;AAAA,EACEC,WAAAA,IAAY;AAAA,EACZC,cAAAA,IAAe;AAAA,EACfC,UAAAA,IAAW;AAAA,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KF,EAAeE;AAAAA,MACpBC,MAAMH,EAAeG;AAAAA,MACrBiG,QAAQ;AAAA,MACRN,aAAa;AAAA,MACbC,OAAO;AAAA,MACPC,iBAAiB;AAAA,IAAA;AAAA,IAEnBP,SAAU7B,CAAAA,MAAMA,EAAEoB,gBAAAA;AAAAA,IAClBU,WAAY9B,CAAAA,MAAM;AAEhB,MAAIA,EAAEkB,QAAQ,YACZlB,EAAEmB,eAAAA,GACFnB,EAAEoB,gBAAAA,GACFzF,EAAkB,EAAK,GACvBM,EAAcQ,SAASyC,MAAAA,MACdc,EAAEkB,QAAQ,eAAelB,EAAEkB,QAAQ,aAAalB,EAAEkB,QAAQ,UAAUlB,EAAEkB,QAAQ,UAEvFnB,EAAyBC,GAAG7D,EAAkBM,OAAO;AAAA,IAEzD;AAAA,IACAwF,MAAK;AAAA,IACL,cAAW;AAAA,IACXxG,KAAKU;AAAAA,IACL,sBAAoBnB;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAEmH,gBAAgBA,MAAM1G,EAAkB,EAAK;AAAA,EAAA,CAAG,CACtE,GACLmC,SAASC,IACX,CACC;AAET,CACF;"}
|
|
1
|
+
{"version":3,"file":"index17.js","sources":["../src/components/Popover/index.tsx"],"sourcesContent":["import React, { useState, useRef, ReactNode, useEffect, forwardRef, ForwardedRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\n\nexport interface PopoverHandle {\n togglePopover: () => void;\n}\n\nexport interface PopoverProps {\n className?: string;\n automationId?: string;\n popoverContentAutomationId?: string;\n renderPopoverContents: (props: { closePopoverCb: () => void }) => ReactNode;\n renderPopoverSrcElement: (props: { displayPopover: boolean; togglePopover: () => void }) => ReactNode;\n position?: 'bottom-center' | 'bottom-left' | 'bottom-right' | 'top-center' | 'top-left' | 'top-right';\n onPopoverToggle?: (displayPopover: boolean) => void;\n contentWidth?: 'full' | 'max';\n isPopoverOpen?: boolean;\n disabled?: boolean;\n isWithPortal?: boolean;\n noBorder?: boolean;\n ariaLabel?: string;\n sourceRole?: 'button' | 'combobox';\n}\n\nexport const Popover = forwardRef<PopoverHandle, PopoverProps>(\n (\n {\n className = '',\n automationId = '',\n position = 'bottom-center',\n popoverContentAutomationId = '',\n contentWidth = 'max',\n renderPopoverContents,\n renderPopoverSrcElement,\n onPopoverToggle,\n isPopoverOpen,\n disabled = false,\n isWithPortal = false,\n ariaLabel,\n sourceRole = 'button',\n ...props\n },\n ref: ForwardedRef<PopoverHandle>\n ) => {\n const [displayPopover, setDisplayPopover] = useState(false);\n const [popoverPosition, setPopoverPosition] = useState(position);\n const [isSrcElementVisible, setIsSrcElementVisible] = useState(false);\n const srcElementRef = useRef<HTMLDivElement>(null);\n const popoverContentRef = useRef<HTMLDivElement>(null);\n\n const [portalPosition, setPortalPosition] = useState({ top: 0, left: 0 });\n\n const calculatePositionOfPopover = (position: string = 'bottom-center') => {\n if (!srcElementRef.current) return { top: 0, left: 0 };\n\n let localPosition = position;\n\n const srcRect = srcElementRef.current.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Calculate position for portal\n let top = 0;\n let left = 0;\n\n switch (localPosition) {\n case 'bottom-left':\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n case 'bottom-right':\n top = srcRect.bottom;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'bottom-center':\n top = srcRect.bottom;\n left = srcRect.left + srcRect.width * 0.15;\n break;\n case 'top-left':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.left;\n break;\n case 'top-right':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'top-center':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.left + srcRect.width * 0.15;\n break;\n default:\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n }\n\n // Get popover dimensions if available\n const popoverRect = popoverContentRef.current?.getBoundingClientRect();\n const popoverWidth = popoverRect?.width || 0;\n const popoverHeight = popoverRect?.height || 0;\n\n // Adjust position to keep popover within viewport bounds\n // Horizontal adjustments\n if (left + popoverWidth > viewportWidth) {\n // Popover extends beyond right edge, shift it left\n left = Math.max(0, viewportWidth - popoverWidth);\n }\n if (left < 0) {\n // Popover extends beyond left edge, shift it right\n left = 0;\n }\n\n // Vertical adjustments\n if (top + popoverHeight > viewportHeight) {\n // Popover extends beyond bottom edge\n // Try to position it above the source element\n const spaceAbove = srcRect.top;\n const spaceBelow = viewportHeight - srcRect.bottom;\n \n if (spaceAbove >= popoverHeight || spaceAbove > spaceBelow) {\n // Position above if there's enough space or more space above\n top = srcRect.top - popoverHeight;\n // Ensure it doesn't go above viewport\n if (top < 0) {\n top = 0;\n }\n } else {\n // Keep at bottom but adjust to fit within viewport\n top = Math.max(0, viewportHeight - popoverHeight);\n }\n }\n if (top < 0) {\n // Popover extends beyond top edge, position it below the source element\n top = srcRect.bottom;\n // Ensure it doesn't go below viewport\n if (top + popoverHeight > viewportHeight) {\n top = Math.max(0, viewportHeight - popoverHeight);\n }\n }\n\n return { top, left };\n };\n \n useEffect(() => {\n if (onPopoverToggle) {\n onPopoverToggle(displayPopover);\n }\n\n if (displayPopover && !isWithPortal) {\n document.body.addEventListener('click', clickListener, true);\n checkPopoverPosition();\n return () => document.body.removeEventListener('click', clickListener, true);\n } else if (displayPopover && isWithPortal) {\n document.body.addEventListener('click', clickAndScrollListenerWithPortal, true);\n window.addEventListener('scroll', clickAndScrollListenerWithPortal);\n window.addEventListener('resize', resizeListenerWithPortal);\n\n // Initial position calculation\n const timeout1 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n checkSourceVisibility();\n \n if (position) {\n setPortalPosition(position);\n }\n }, 0);\n\n // Recalculate after popover is rendered to get accurate dimensions\n const timeout2 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }, 10);\n\n return () => {\n document.body.removeEventListener('click', clickAndScrollListenerWithPortal, true);\n window.removeEventListener('scroll', clickAndScrollListenerWithPortal);\n window.removeEventListener('resize', resizeListenerWithPortal);\n clearTimeout(timeout1);\n clearTimeout(timeout2);\n };\n }\n }, [displayPopover, isWithPortal]);\n\n const checkSourceVisibility = () => {\n if (!srcElementRef.current) {\n setIsSrcElementVisible(false);\n return;\n }\n\n const rec = srcElementRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n\n const isVisible = rec.top < viewportHeight && rec.bottom > 0 && rec.left < viewportWidth && rec.right > 0;\n\n setIsSrcElementVisible(isVisible);\n };\n\n useEffect(() => {\n setDisplayPopover(isPopoverOpen ?? false);\n }, [isPopoverOpen]);\n\n useEffect(() => {\n // Focus first focusable element when popover opens\n if (displayPopover && popoverContentRef.current) {\n setTimeout(() => {\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n const firstFocusable = popoverContentRef.current?.querySelector<HTMLElement>(focusableSelectors);\n if (firstFocusable && document.activeElement === srcElementRef.current) {\n firstFocusable.focus();\n }\n }, 0);\n }\n }, [displayPopover]);\n\n //Function to check popover position\n const checkPopoverPosition = () => {\n if (!popoverContentRef.current) return;\n\n const popoverRect = popoverContentRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n\n if (popoverRect?.bottom > viewportHeight) {\n setPopoverPosition(\n position.includes('left') ? 'top-left' : position.includes('right') ? 'top-right' : 'top-center'\n );\n } else if (popoverRect?.top < 0) {\n // If popover extends beyond top of viewport, switch to bottom position\n setPopoverPosition(\n position.includes('left') ? 'bottom-left' : position.includes('right') ? 'bottom-right' : 'bottom-center'\n );\n }\n };\n\n const clickListener = (event: MouseEvent) => {\n const currentDropRef = srcElementRef.current;\n if (!currentDropRef) return;\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = popoverContentRef.current?.contains(target);\n \n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n \n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if ((!isSourcePopover && !isPopoverContent) || isAnotherPopoverSource) {\n setDisplayPopover(false);\n }\n };\n\n const clickAndScrollListenerWithPortal = (event: Event) => {\n const currentDropRef = srcElementRef.current;\n const currentPopoverRef = popoverContentRef.current;\n if (!currentDropRef) return;\n checkSourceVisibility();\n\n // Recalculate position on scroll\n if (event.type === 'scroll' && displayPopover) {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = currentPopoverRef?.contains(target);\n \n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if ((!isSourcePopover && !isPopoverContent) || isAnotherPopoverSource) {\n setDisplayPopover(false);\n }\n };\n\n const resizeListenerWithPortal = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const togglePopover = () => {\n setDisplayPopover((displayPopover) => !displayPopover);\n };\n\n const handleArrowKeyNavigation = (e: React.KeyboardEvent, container: HTMLDivElement | null) => {\n if (!container) return;\n\n // Find all focusable elements within the popover content\n // This includes elements with role=\"menuitem\", role=\"option\", tabIndex >= 0, etc.\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n\n const focusableElements = Array.from(\n container.querySelectorAll<HTMLElement>(focusableSelectors)\n ).filter((el) => {\n // Filter out disabled and hidden elements\n const style = window.getComputedStyle(el);\n return (\n !el.hasAttribute('disabled') &&\n !el.hasAttribute('aria-disabled') &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (el.tabIndex >= 0 || el.hasAttribute('role'))\n );\n });\n\n if (focusableElements.length === 0) return;\n\n const currentIndex = focusableElements.findIndex((el) => el === document.activeElement);\n let nextIndex = -1;\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex < focusableElements.length - 1 ? currentIndex + 1 : 0;\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex > 0 ? currentIndex - 1 : focusableElements.length - 1;\n } else if (e.key === 'Home') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = 0;\n } else if (e.key === 'End') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = focusableElements.length - 1;\n }\n\n if (nextIndex >= 0 && focusableElements[nextIndex]) {\n focusableElements[nextIndex].focus();\n } else if (currentIndex === -1 && focusableElements.length > 0) {\n // If no element is currently focused, focus the first one\n focusableElements[0].focus();\n }\n };\n\n useImperativeHandle(ref, () => ({ togglePopover }), []);\n\n const popoverContentStyle = {\n 'bottom-left': { left: '0', top: '100%' },\n 'bottom-right': { right: '0', top: '100%' },\n 'bottom-center': { left: '50%', transform: 'translateX(-50%)', top: '100%' },\n 'top-left': { left: '0', bottom: '100%' },\n 'top-right': { right: '0', bottom: '100%' },\n 'top-center': { left: '50%', transform: 'translateX(-50%)', bottom: '100%' }\n };\n const popoverContentClasses = props?.noBorder ? '' : 'shadow-md border rounded-md';\n\n return (\n <div\n className={\n 'se-design-popover-wrapper cursor-pointer relative' +\n (className.length > 0 ? ` ${className}` : '') +\n (displayPopover ? ' open' : '') +\n (disabled ? ' opacity-50 cursor-not-allowed pointer-events-none' : '')\n }\n ref={srcElementRef}\n onClick={(e) => {\n if (disabled) return;\n e.stopPropagation();\n togglePopover();\n }}\n onKeyDown={(e) => {\n if (disabled) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n const wasOpen = displayPopover;\n togglePopover();\n // Focus first focusable element when opening\n if (!wasOpen) {\n setTimeout(() => {\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n const firstFocusable = currentRef.querySelector<HTMLElement>(focusableSelectors);\n if (firstFocusable) {\n firstFocusable.focus();\n }\n }\n }, 0);\n }\n } else if (e.key === 'Escape' && displayPopover) {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n } else if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && displayPopover) {\n // Handle arrow keys when popover is open\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n handleArrowKeyNavigation(e, currentRef);\n }\n } else if (e.key === 'ArrowDown' && !displayPopover) {\n // Open popover and focus first item when ArrowDown is pressed\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(true);\n setTimeout(() => {\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n const firstFocusable = currentRef.querySelector<HTMLElement>(focusableSelectors);\n if (firstFocusable) {\n firstFocusable.focus();\n }\n }\n }, 0);\n }\n }}\n role={sourceRole}\n aria-expanded={displayPopover ? 'true' : 'false'}\n aria-haspopup=\"true\"\n tabIndex={0}\n aria-disabled={disabled ? 'true' : 'false'}\n aria-label={ariaLabel}\n data-automation-id={automationId}\n {...props}\n >\n {renderPopoverSrcElement({ displayPopover, togglePopover })}\n\n {displayPopover && !isWithPortal && (\n <div\n className={`popover-content absolute ${popoverContentClasses} z-[1000] ${contentWidth == 'full' ? 'w-full' : 'w-max'}`}\n style={{\n borderColor: 'var(--color-gray-200)',\n color: 'var(--color-gray-900)',\n backgroundColor: 'var(--color-white)',\n ...popoverContentStyle[popoverPosition]\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={(e) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n srcElementRef.current?.focus();\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n }\n }}\n role=\"dialog\"\n aria-modal=\"false\"\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\n </div>\n )}\n {isWithPortal &&\n displayPopover &&\n isSrcElementVisible &&\n ReactDOM.createPortal(\n <div\n className={`popover-content-with-portal ${popoverContentClasses} ${contentWidth == 'full' ? 'w-full' : 'w-max'}`}\n style={{\n position: 'fixed',\n top: portalPosition.top,\n left: portalPosition.left,\n zIndex: 1000,\n borderColor: 'var(--color-gray-200)',\n color: 'var(--color-gray-900)',\n backgroundColor: 'var(--color-white)'\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={(e) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n srcElementRef.current?.focus();\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n }\n }}\n role=\"dialog\"\n aria-modal=\"false\"\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\n </div>,\n document.body\n )}\n </div>\n );\n }\n);\n\n"],"names":["Popover","className","automationId","position","popoverContentAutomationId","contentWidth","renderPopoverContents","renderPopoverSrcElement","onPopoverToggle","isPopoverOpen","disabled","isWithPortal","ariaLabel","sourceRole","props","ref","displayPopover","setDisplayPopover","useState","popoverPosition","setPopoverPosition","isSrcElementVisible","setIsSrcElementVisible","srcElementRef","useRef","popoverContentRef","portalPosition","setPortalPosition","top","left","calculatePositionOfPopover","current","localPosition","srcRect","getBoundingClientRect","viewportWidth","window","innerWidth","viewportHeight","innerHeight","bottom","right","width","height","popoverRect","popoverWidth","popoverHeight","Math","max","spaceAbove","spaceBelow","useEffect","document","body","addEventListener","clickListener","checkPopoverPosition","removeEventListener","clickAndScrollListenerWithPortal","resizeListenerWithPortal","timeout1","setTimeout","checkSourceVisibility","timeout2","clearTimeout","rec","isVisible","focusableSelectors","join","firstFocusable","querySelector","activeElement","focus","includes","event","currentDropRef","target","isSourcePopover","contains","isPopoverContent","closestPopoverWrapper","closest","currentPopoverRef","type","togglePopover","handleArrowKeyNavigation","e","container","focusableElements","Array","from","querySelectorAll","filter","el","style","getComputedStyle","hasAttribute","display","visibility","tabIndex","length","currentIndex","findIndex","nextIndex","key","preventDefault","stopPropagation","useImperativeHandle","popoverContentStyle","transform","popoverContentClasses","noBorder","React","createElement","_extends","onClick","onKeyDown","wasOpen","currentRef","role","borderColor","color","backgroundColor","closePopoverCb","ReactDOM","createPortal","zIndex"],"mappings":";;;;;;;;;;;AAwBO,MAAMA,uBACX,CACE;AAAA,EACEC,WAAAA,IAAY;AAAA,EACZC,cAAAA,IAAe;AA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AW,+BAA+B6G,CAAqB,IAAIzG,KAAgB,SAAS,WAAW,OAAO;AAAA,IAC9GyF,OAAO;AAAA,MACL3F,UAAU;AAAA,MACVyB,KAAKF,EAAeE;AAAAA,MACpBC,MAAMH,EAAeG;AAAAA,MACrBiG,QAAQ;AAAA,MACRN,aAAa;AAAA,MACbC,OAAO;AAAA,MACPC,iBAAiB;AAAA,IAAA;AAAA,IAEnBP,SAAU7B,CAAAA,MAAMA,EAAEoB,gBAAAA;AAAAA,IAClBU,WAAY9B,CAAAA,MAAM;AAEhB,MAAIA,EAAEkB,QAAQ,YACZlB,EAAEmB,eAAAA,GACFnB,EAAEoB,gBAAAA,GACFzF,EAAkB,EAAK,GACvBM,EAAcQ,SAASyC,MAAAA,MACdc,EAAEkB,QAAQ,eAAelB,EAAEkB,QAAQ,aAAalB,EAAEkB,QAAQ,UAAUlB,EAAEkB,QAAQ,UAEvFnB,EAAyBC,GAAG7D,EAAkBM,OAAO;AAAA,IAEzD;AAAA,IACAwF,MAAK;AAAA,IACL,cAAW;AAAA,IACXxG,KAAKU;AAAAA,IACL,sBAAoBrB;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAEqH,gBAAgBA,MAAM1G,EAAkB,EAAK;AAAA,EAAA,CAAG,CACtE,GACLmC,SAASC,IACX,CACC;AAET,CACF;"}
|
package/dist/index21.js
CHANGED
|
@@ -15,7 +15,7 @@ const I = ({
|
|
|
15
15
|
defaultChecked: c = !1,
|
|
16
16
|
disabled: e = !1,
|
|
17
17
|
onChange: m,
|
|
18
|
-
checkMarkType:
|
|
18
|
+
checkMarkType: r = "",
|
|
19
19
|
label: k = "",
|
|
20
20
|
disabledLabel: h = "",
|
|
21
21
|
containerAutomationId: g = "",
|
|
@@ -26,21 +26,21 @@ const I = ({
|
|
|
26
26
|
l(c);
|
|
27
27
|
}, [c]);
|
|
28
28
|
const p = (t) => {
|
|
29
|
-
e || (l((
|
|
29
|
+
e || (l((o) => !o), m?.(!n, t));
|
|
30
30
|
}, E = (t) => {
|
|
31
31
|
if (!e && (t.key === "Enter" || t.key === " ")) {
|
|
32
32
|
t.preventDefault(), t.stopPropagation();
|
|
33
|
-
const
|
|
34
|
-
l(
|
|
33
|
+
const o = !n;
|
|
34
|
+
l(o);
|
|
35
35
|
const u = t.currentTarget.closest("label")?.querySelector("input");
|
|
36
|
-
u && m?.(
|
|
36
|
+
u && m?.(o, {
|
|
37
37
|
target: u,
|
|
38
38
|
currentTarget: u
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
}, v = () => {
|
|
42
42
|
const t = "focus-visible:outline outline-2 outline-[var(--color-blue-400)] outline-offset-2 rounded";
|
|
43
|
-
return e ? n &&
|
|
43
|
+
return e ? n && r === "tick" ? "disabled-tick" : n && r === "minus-checkbox" ? "disabled-minus-checkbox" : n && !r ? "disabled-tick" : "disabled-default" : r === "minus-checkbox" && n ? `minus-checkbox ${t}` : n ? `checked ${t}` : `unchecked ${t}`;
|
|
44
44
|
}, y = () => e ? "checkbox-label-disabled" : "checkbox-label", d = () => e && h ? h : k, x = crypto.randomUUID();
|
|
45
45
|
return /* @__PURE__ */ s.createElement("div", {
|
|
46
46
|
className: "se-design-checkbox-ctn"
|
|
@@ -49,9 +49,9 @@ const I = ({
|
|
|
49
49
|
htmlFor: x,
|
|
50
50
|
className: `se-design-checkbox ${i} ${v()}`,
|
|
51
51
|
"data-automation-id": g || "checkbox-container",
|
|
52
|
-
tabIndex:
|
|
53
|
-
"aria-checked": n,
|
|
54
|
-
"aria-disabled": e
|
|
52
|
+
tabIndex: 0,
|
|
53
|
+
"aria-checked": n ? "true" : "false",
|
|
54
|
+
"aria-disabled": e ? "true" : "false"
|
|
55
55
|
}, f ? {
|
|
56
56
|
"aria-label": f
|
|
57
57
|
} : {
|
package/dist/index21.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index21.js","sources":["../src/components/Checkbox/index.tsx"],"sourcesContent":["import React, { FC, useState, useEffect } from 'react';\nimport './style.scss';\n\nexport interface CheckboxProps {\n className?: string;\n automationId?: string;\n defaultChecked?: boolean;\n onChange?: (checked: boolean, e: React.ChangeEvent<HTMLInputElement>) => void;\n disabled?: boolean;\n checkMarkType?: 'tick' | 'minus-checkbox' | '';\n label?: string;\n disabledLabel?: string;\n containerAutomationId?: string;\n ariaLabel?: string;\n}\n\nexport const Checkbox: FC<CheckboxProps> = ({\n className = '',\n automationId = '',\n defaultChecked = false,\n disabled = false,\n onChange,\n checkMarkType = '',\n label = '',\n disabledLabel = '',\n containerAutomationId = '',\n ariaLabel = 'Checkbox'\n}) => {\n const [isChecked, setIsChecked] = useState(defaultChecked);\n\n useEffect(() => {\n setIsChecked(defaultChecked);\n }, [defaultChecked]);\n\n const handleClick = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (disabled) return;\n setIsChecked((prev) => (checkMarkType === 'minus-checkbox' ? !prev : !prev));\n onChange?.(!isChecked, e);\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLLabelElement | HTMLSpanElement>) => {\n if (disabled) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n const newChecked = !isChecked;\n setIsChecked(newChecked);\n \n // Create a proper synthetic event for the onChange callback\n const inputElement = e.currentTarget.closest('label')?.querySelector('input');\n if (inputElement) {\n const syntheticEvent = {\n target: inputElement,\n currentTarget: inputElement,\n } as React.ChangeEvent<HTMLInputElement>;\n onChange?.(newChecked, syntheticEvent);\n }\n }\n };\n\n const getCheckBoxClassName = () => {\n const focusClass = 'focus-visible:outline outline-2 outline-[var(--color-blue-400)] outline-offset-2 rounded';\n\n // Handle disabled states with proper checked status\n if (disabled) {\n if (isChecked && checkMarkType === 'tick') return 'disabled-tick';\n if (isChecked && checkMarkType === 'minus-checkbox') return 'disabled-minus-checkbox';\n if (isChecked && !checkMarkType) return 'disabled-tick'; // Default to tick for checked disabled\n return 'disabled-default'; // Unchecked disabled\n }\n\n // Handle enabled states\n if (checkMarkType === 'minus-checkbox' && isChecked) return `minus-checkbox ${focusClass}`;\n return isChecked ? `checked ${focusClass}` : `unchecked ${focusClass}`;\n };\n\n const getLabelClassName = () => {\n return disabled ? 'checkbox-label-disabled' : 'checkbox-label';\n };\n\n const getLabelText = () => {\n if (disabled && disabledLabel) {\n return disabledLabel;\n }\n return label;\n };\n const uniqueId = crypto.randomUUID();\n\n return (\n <div className=\"se-design-checkbox-ctn\">\n <label\n role=\"checkbox\"\n htmlFor={uniqueId}\n className={`se-design-checkbox ${className} ${getCheckBoxClassName()}`}\n data-automation-id={containerAutomationId || 'checkbox-container'}\n tabIndex={
|
|
1
|
+
{"version":3,"file":"index21.js","sources":["../src/components/Checkbox/index.tsx"],"sourcesContent":["import React, { FC, useState, useEffect } from 'react';\nimport './style.scss';\n\nexport interface CheckboxProps {\n className?: string;\n automationId?: string;\n defaultChecked?: boolean;\n onChange?: (checked: boolean, e: React.ChangeEvent<HTMLInputElement>) => void;\n disabled?: boolean;\n checkMarkType?: 'tick' | 'minus-checkbox' | '';\n label?: string;\n disabledLabel?: string;\n containerAutomationId?: string;\n ariaLabel?: string;\n}\n\nexport const Checkbox: FC<CheckboxProps> = ({\n className = '',\n automationId = '',\n defaultChecked = false,\n disabled = false,\n onChange,\n checkMarkType = '',\n label = '',\n disabledLabel = '',\n containerAutomationId = '',\n ariaLabel = 'Checkbox'\n}) => {\n const [isChecked, setIsChecked] = useState(defaultChecked);\n\n useEffect(() => {\n setIsChecked(defaultChecked);\n }, [defaultChecked]);\n\n const handleClick = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (disabled) return;\n setIsChecked((prev) => (checkMarkType === 'minus-checkbox' ? !prev : !prev));\n onChange?.(!isChecked, e);\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLLabelElement | HTMLSpanElement>) => {\n if (disabled) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n const newChecked = !isChecked;\n setIsChecked(newChecked);\n \n // Create a proper synthetic event for the onChange callback\n const inputElement = e.currentTarget.closest('label')?.querySelector('input');\n if (inputElement) {\n const syntheticEvent = {\n target: inputElement,\n currentTarget: inputElement,\n } as React.ChangeEvent<HTMLInputElement>;\n onChange?.(newChecked, syntheticEvent);\n }\n }\n };\n\n const getCheckBoxClassName = () => {\n const focusClass = 'focus-visible:outline outline-2 outline-[var(--color-blue-400)] outline-offset-2 rounded';\n\n // Handle disabled states with proper checked status\n if (disabled) {\n if (isChecked && checkMarkType === 'tick') return 'disabled-tick';\n if (isChecked && checkMarkType === 'minus-checkbox') return 'disabled-minus-checkbox';\n if (isChecked && !checkMarkType) return 'disabled-tick'; // Default to tick for checked disabled\n return 'disabled-default'; // Unchecked disabled\n }\n\n // Handle enabled states\n if (checkMarkType === 'minus-checkbox' && isChecked) return `minus-checkbox ${focusClass}`;\n return isChecked ? `checked ${focusClass}` : `unchecked ${focusClass}`;\n };\n\n const getLabelClassName = () => {\n return disabled ? 'checkbox-label-disabled' : 'checkbox-label';\n };\n\n const getLabelText = () => {\n if (disabled && disabledLabel) {\n return disabledLabel;\n }\n return label;\n };\n const uniqueId = crypto.randomUUID();\n\n return (\n <div className=\"se-design-checkbox-ctn\">\n <label\n role=\"checkbox\"\n htmlFor={uniqueId}\n className={`se-design-checkbox ${className} ${getCheckBoxClassName()}`}\n data-automation-id={containerAutomationId || 'checkbox-container'}\n tabIndex={0}\n aria-checked={isChecked ? 'true' : 'false'}\n aria-disabled={disabled ? 'true' : 'false'}\n {...(ariaLabel ? { 'aria-label': ariaLabel } : { 'aria-labelledby': `${automationId}-label` })}\n onKeyDown={handleKeyDown}\n >\n <input\n id={uniqueId}\n type=\"checkbox\"\n checked={isChecked}\n onChange={handleClick}\n disabled={disabled}\n aria-hidden=\"true\"\n />\n <span className=\"checkbox-item\" data-automation-id={automationId}></span>\n {getLabelText()?.length > 0 && <span className={getLabelClassName()} data-automation-id=\"checkbox-label\">{getLabelText()}</span>}\n </label>\n </div>\n );\n};\n"],"names":["Checkbox","className","automationId","defaultChecked","disabled","onChange","checkMarkType","label","disabledLabel","containerAutomationId","ariaLabel","isChecked","setIsChecked","useState","useEffect","handleClick","e","prev","handleKeyDown","key","preventDefault","stopPropagation","newChecked","inputElement","currentTarget","closest","querySelector","target","getCheckBoxClassName","focusClass","getLabelClassName","getLabelText","uniqueId","crypto","randomUUID","React","createElement","_extends","role","htmlFor","tabIndex","onKeyDown","id","type","checked","length"],"mappings":";;;;;;;;;;;AAgBO,MAAMA,IAA8BA,CAAC;AAAA,EAC1CC,WAAAA,IAAY;AAAA,EACZC,cAAAA,IAAe;AAAA,EACfC,gBAAAA,IAAiB;AAAA,EACjBC,UAAAA,IAAW;AAAA,EACXC,UAAAA;AAAAA,EACAC,eAAAA,IAAgB;AAAA,EAChBC,OAAAA,IAAQ;AAAA,EACRC,eAAAA,IAAgB;AAAA,EAChBC,uBAAAA,IAAwB;AAAA,EACxBC,WAAAA,IAAY;AACd,MAAM;AACJ,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAASV,CAAc;AAEzDW,EAAAA,EAAU,MAAM;AACdF,IAAAA,EAAaT,CAAc;AAAA,EAC7B,GAAG,CAACA,CAAc,CAAC;AAEnB,QAAMY,IAAcA,CAACC,MAA2C;AAC9D,IAAIZ,MACJQ,EAAcK,OAA+C,CAACA,CAAa,GAC3EZ,IAAW,CAACM,GAAWK,CAAC;AAAA,EAC1B,GAEME,IAAgBA,CAACF,MAA+D;AACpF,QAAIZ,CAAAA,MACAY,EAAEG,QAAQ,WAAWH,EAAEG,QAAQ,MAAK;AACtCH,MAAAA,EAAEI,eAAAA,GACFJ,EAAEK,gBAAAA;AACF,YAAMC,IAAa,CAACX;AACpBC,MAAAA,EAAaU,CAAU;AAGvB,YAAMC,IAAeP,EAAEQ,cAAcC,QAAQ,OAAO,GAAGC,cAAc,OAAO;AAC5E,MAAIH,KAKFlB,IAAWiB,GAJY;AAAA,QACrBK,QAAQJ;AAAAA,QACRC,eAAeD;AAAAA,MAAAA,CAEoB;AA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B,EAAAA;AAAAA,IAAqB,sBAAmB;AAAA,EAAA,GAAkBC,EAAAA,CAAqB,CAC1H,CACJ;AAET;"}
|
package/dist/index23.js
CHANGED
|
@@ -1,56 +1,57 @@
|
|
|
1
|
-
import t, { useState as
|
|
2
|
-
import { Popover as
|
|
3
|
-
import { Icon as
|
|
4
|
-
import { Checkbox as
|
|
5
|
-
import { Button as
|
|
6
|
-
import { InputWithIcon as
|
|
7
|
-
const
|
|
8
|
-
const [i,
|
|
1
|
+
import t, { useState as w, useRef as H, useEffect as $ } from "react";
|
|
2
|
+
import { Popover as Y } from "./index17.js";
|
|
3
|
+
import { Icon as A } from "./index5.js";
|
|
4
|
+
import { Checkbox as Z } from "./index21.js";
|
|
5
|
+
import { Button as B } from "./index3.js";
|
|
6
|
+
import { InputWithIcon as ee } from "./index50.js";
|
|
7
|
+
const ce = (o) => {
|
|
8
|
+
const [i, P] = w(!1), [f, x] = w(""), [a, d] = w(() => o?.defaultSelectedValue ? Array.isArray(o?.defaultSelectedValue) ? o?.defaultSelectedValue : [o.defaultSelectedValue] : []), p = H(null), {
|
|
9
9
|
selectBy: s = "",
|
|
10
|
-
optionsUniqueBy:
|
|
11
|
-
displaySelected:
|
|
12
|
-
dropDownOptions:
|
|
13
|
-
defaultText:
|
|
14
|
-
iconColor:
|
|
15
|
-
disabled:
|
|
16
|
-
dropdownClassName:
|
|
17
|
-
hasError:
|
|
18
|
-
errorMessage:
|
|
19
|
-
customDropdownContent:
|
|
20
|
-
isBorderless:
|
|
10
|
+
optionsUniqueBy: n = "",
|
|
11
|
+
displaySelected: L = !1,
|
|
12
|
+
dropDownOptions: h,
|
|
13
|
+
defaultText: m = "Select",
|
|
14
|
+
iconColor: g = "var(--color-gray-700)",
|
|
15
|
+
disabled: y = !1,
|
|
16
|
+
dropdownClassName: M = "",
|
|
17
|
+
hasError: S = !1,
|
|
18
|
+
errorMessage: O = "",
|
|
19
|
+
customDropdownContent: E = null,
|
|
20
|
+
isBorderless: U = !1,
|
|
21
21
|
shouldShowSearch: D = !1,
|
|
22
22
|
searchPlaceholder: R = "Search...",
|
|
23
|
-
searchResultEmptyMessage:
|
|
23
|
+
searchResultEmptyMessage: C = "No results found",
|
|
24
|
+
ariaLabel: j = ""
|
|
24
25
|
} = o;
|
|
25
|
-
|
|
26
|
+
$(() => {
|
|
26
27
|
const e = o?.defaultSelectedValue ? Array.isArray(o?.defaultSelectedValue) ? o?.defaultSelectedValue : [o.defaultSelectedValue] : [];
|
|
27
|
-
|
|
28
|
-
}, [o?.defaultSelectedValue]),
|
|
29
|
-
i ||
|
|
28
|
+
d(e);
|
|
29
|
+
}, [o?.defaultSelectedValue]), $(() => {
|
|
30
|
+
i || x("");
|
|
30
31
|
}, [i]);
|
|
31
|
-
const v = o?.type === "multi-select",
|
|
32
|
-
|
|
33
|
-
}, T = (e) => v ?
|
|
34
|
-
|
|
35
|
-
},
|
|
32
|
+
const v = o?.type === "multi-select", N = () => f.trim() ? (h || []).filter((e) => (e?.[s]?.toString().toLowerCase() || "").includes(f.toLowerCase())) : h || [], k = (e) => {
|
|
33
|
+
d([e]), p.current?.togglePopover(), o?.onOptionClick?.(e);
|
|
34
|
+
}, T = (e) => v ? m : e?.[s] || m, q = () => {
|
|
35
|
+
d([]);
|
|
36
|
+
}, V = (e, r = !1) => {
|
|
36
37
|
if (o?.renderOptionChip)
|
|
37
|
-
return o?.renderOptionChip(e,
|
|
38
|
+
return o?.renderOptionChip(e, r);
|
|
38
39
|
if (v && a?.length > 0) {
|
|
39
|
-
const
|
|
40
|
+
const l = a[0]?.[s] || "", c = a.length - 1;
|
|
40
41
|
return /* @__PURE__ */ t.createElement("div", {
|
|
41
42
|
className: "option-chip flex items-center w-full"
|
|
42
43
|
}, /* @__PURE__ */ t.createElement("div", {
|
|
43
|
-
className: `${
|
|
44
|
-
}, `${
|
|
44
|
+
className: `${c > 0 ? "w-full" : "flex-1"} truncate`
|
|
45
|
+
}, `${m}: ${l}`), c > 0 && /* @__PURE__ */ t.createElement("div", {
|
|
45
46
|
className: "flex-shrink-0"
|
|
46
|
-
}, "+",
|
|
47
|
+
}, "+", c));
|
|
47
48
|
}
|
|
48
49
|
return /* @__PURE__ */ t.createElement("p", {
|
|
49
50
|
className: "option-chip flex flex-1 items-center justify-between"
|
|
50
51
|
}, T(e));
|
|
51
52
|
}, I = () => /* @__PURE__ */ t.createElement("div", {
|
|
52
53
|
className: " w-full relative flex items-center border-b border-[var(--color-gray-300)]"
|
|
53
|
-
}, /* @__PURE__ */ t.createElement(
|
|
54
|
+
}, /* @__PURE__ */ t.createElement(ee, {
|
|
54
55
|
leftIcon: {
|
|
55
56
|
name: "search",
|
|
56
57
|
position: "left",
|
|
@@ -58,8 +59,8 @@ const ae = (o) => {
|
|
|
58
59
|
color: "var(--color-gray-500)"
|
|
59
60
|
}
|
|
60
61
|
},
|
|
61
|
-
value:
|
|
62
|
-
onChange: (e) =>
|
|
62
|
+
value: f,
|
|
63
|
+
onChange: (e) => x(e),
|
|
63
64
|
placeholder: R,
|
|
64
65
|
style: {
|
|
65
66
|
margin: 0,
|
|
@@ -70,58 +71,58 @@ const ae = (o) => {
|
|
|
70
71
|
border: "none",
|
|
71
72
|
outline: "none"
|
|
72
73
|
}
|
|
73
|
-
})), z = (e,
|
|
74
|
-
const
|
|
74
|
+
})), z = (e, r) => {
|
|
75
|
+
const l = e[s], c = a[0]?.[s] || m, G = n?.length ? e[n] == a[0]?.[n] : !0, u = L && l === c && G;
|
|
75
76
|
return /* @__PURE__ */ t.createElement("div", {
|
|
76
77
|
key: `$drop-option-${crypto.randomUUID()}`,
|
|
77
|
-
className: `option break-words px-3 py-2 hover:bg-gray-100 cursor-pointer flex items-center justify-between ${
|
|
78
|
-
onClick: () =>
|
|
79
|
-
onKeyDown: (
|
|
80
|
-
(
|
|
78
|
+
className: `option break-words px-3 py-2 hover:bg-gray-100 cursor-pointer flex items-center justify-between ${u ? "selected" : ""}`,
|
|
79
|
+
onClick: () => k(e),
|
|
80
|
+
onKeyDown: (b) => {
|
|
81
|
+
(b.key === "Enter" || b.key === " ") && (b.preventDefault(), k(e));
|
|
81
82
|
},
|
|
82
83
|
role: "option",
|
|
83
|
-
"aria-selected":
|
|
84
|
+
"aria-selected": u ? "true" : "false",
|
|
84
85
|
tabIndex: 0,
|
|
85
|
-
"data-automation-id": `dropdown-option-${e?.automationId ||
|
|
86
|
-
},
|
|
86
|
+
"data-automation-id": `dropdown-option-${e?.automationId || r}`
|
|
87
|
+
}, V({
|
|
87
88
|
...e,
|
|
88
|
-
isOptionSelected:
|
|
89
|
-
}, !1),
|
|
89
|
+
isOptionSelected: u
|
|
90
|
+
}, !1), u && /* @__PURE__ */ t.createElement(A, {
|
|
90
91
|
name: "checkmark",
|
|
91
|
-
stroke:
|
|
92
|
+
stroke: g
|
|
92
93
|
}));
|
|
93
94
|
}, J = () => {
|
|
94
|
-
const e =
|
|
95
|
+
const e = N();
|
|
95
96
|
return /* @__PURE__ */ t.createElement("div", {
|
|
96
97
|
className: "dropdown-content dropdown-options",
|
|
97
98
|
role: "listbox",
|
|
98
99
|
"aria-label": "Dropdown options"
|
|
99
100
|
}, D && I(), /* @__PURE__ */ t.createElement("div", {
|
|
100
101
|
className: "flex flex-col max-h-80 overflow-y-auto"
|
|
101
|
-
}, e.length > 0 ? e.map((
|
|
102
|
+
}, e.length > 0 ? e.map((r, l) => z(r, l)) : /* @__PURE__ */ t.createElement("div", {
|
|
102
103
|
className: "px-3 py-4 text-center text-[var(--color-gray-500)] text-sm",
|
|
103
104
|
role: "status",
|
|
104
105
|
"aria-live": "polite"
|
|
105
|
-
},
|
|
106
|
-
}, Q = (e,
|
|
107
|
-
let
|
|
108
|
-
e ?
|
|
106
|
+
}, C)));
|
|
107
|
+
}, Q = (e, r) => {
|
|
108
|
+
let l = [];
|
|
109
|
+
e ? l = [...a, r] : l = a?.filter((c) => c[n] !== r[n]), d(l);
|
|
109
110
|
}, W = () => {
|
|
110
|
-
|
|
111
|
+
p.current?.togglePopover(), o?.onApply?.(a);
|
|
111
112
|
}, _ = (e) => {
|
|
112
|
-
const
|
|
113
|
+
const r = a.some((l) => l[n] === e[n]);
|
|
113
114
|
return /* @__PURE__ */ t.createElement("div", {
|
|
114
115
|
key: `$drop-option-${crypto.randomUUID()}`,
|
|
115
116
|
className: "option px-3 py-2 hover:bg-gray-100 cursor-pointer flex items-center justify-between"
|
|
116
|
-
}, /* @__PURE__ */ t.createElement(
|
|
117
|
+
}, /* @__PURE__ */ t.createElement(Z, {
|
|
117
118
|
automationId: "checkbox",
|
|
118
119
|
className: "checkbox",
|
|
119
|
-
defaultChecked:
|
|
120
|
-
onChange: (
|
|
120
|
+
defaultChecked: r,
|
|
121
|
+
onChange: (l) => Q(l, e),
|
|
121
122
|
label: e?.label
|
|
122
123
|
}));
|
|
123
124
|
}, F = () => {
|
|
124
|
-
const e =
|
|
125
|
+
const e = N();
|
|
125
126
|
return /* @__PURE__ */ t.createElement("div", {
|
|
126
127
|
className: "dropdown-content dropdown-options",
|
|
127
128
|
role: "listbox",
|
|
@@ -129,45 +130,40 @@ const ae = (o) => {
|
|
|
129
130
|
"aria-multiselectable": "true"
|
|
130
131
|
}, D && I(), /* @__PURE__ */ t.createElement("div", {
|
|
131
132
|
className: "flex flex-col max-h-80 overflow-y-auto"
|
|
132
|
-
}, e.length > 0 ? e.map((
|
|
133
|
+
}, e.length > 0 ? e.map((r) => _(r)) : /* @__PURE__ */ t.createElement("div", {
|
|
133
134
|
className: "px-3 py-4 text-center text-[var(--color-gray-500)] text-sm",
|
|
134
135
|
role: "status",
|
|
135
136
|
"aria-live": "polite"
|
|
136
|
-
},
|
|
137
|
+
}, C)), /* @__PURE__ */ t.createElement("div", {
|
|
137
138
|
className: "flex items-center justify-end gap-4 p-3 border-t border-[var(--color-gray-200)]"
|
|
138
|
-
}, /* @__PURE__ */ t.createElement(
|
|
139
|
+
}, /* @__PURE__ */ t.createElement(B, {
|
|
139
140
|
label: "Clear",
|
|
140
141
|
type: "link",
|
|
141
142
|
size: "sm",
|
|
142
143
|
onClick: q
|
|
143
|
-
}), /* @__PURE__ */ t.createElement(
|
|
144
|
+
}), /* @__PURE__ */ t.createElement(B, {
|
|
144
145
|
label: "Apply",
|
|
145
146
|
type: "primary",
|
|
146
147
|
size: "sm",
|
|
147
148
|
onClick: W
|
|
148
149
|
})));
|
|
149
150
|
}, K = () => {
|
|
150
|
-
const e = i ? "border-[var(--color-blue-500)]" :
|
|
151
|
+
const e = i ? "border-[var(--color-blue-500)]" : y ? "border-[var(--color-gray-300)]" : "border-[var(--color-gray-600)]", r = S ? "border-[var(--color-red-500)]" : "", l = `dropdown-src-element bg-[var(--color-white)] flex px-3 py-2 ${U ? "border-0" : `border rounded-md ${r || e}`} flex items-center ${M}`;
|
|
151
152
|
return /* @__PURE__ */ t.createElement("div", {
|
|
152
|
-
className:
|
|
153
|
-
role: "combobox",
|
|
154
|
-
"aria-expanded": i,
|
|
155
|
-
"aria-haspopup": "listbox",
|
|
156
|
-
"aria-label": b,
|
|
157
|
-
"aria-disabled": u
|
|
153
|
+
className: l
|
|
158
154
|
}, /* @__PURE__ */ t.createElement("div", {
|
|
159
155
|
className: "flex-1 min-w-0",
|
|
160
156
|
"data-automation-id": o?.dropDownSelectAutomationId || "selected-dropdown-value"
|
|
161
|
-
},
|
|
157
|
+
}, V(a[0], !0)), /* @__PURE__ */ t.createElement("div", {
|
|
162
158
|
className: "flex-shrink-0 ml-2",
|
|
163
159
|
"aria-hidden": "true"
|
|
164
|
-
}, /* @__PURE__ */ t.createElement(
|
|
160
|
+
}, /* @__PURE__ */ t.createElement(A, {
|
|
165
161
|
name: "chevron",
|
|
166
162
|
rotation: i ? "180" : "0",
|
|
167
163
|
className: "transition-transform",
|
|
168
|
-
stroke:
|
|
164
|
+
stroke: g
|
|
169
165
|
})));
|
|
170
|
-
};
|
|
166
|
+
}, X = () => j || "Select option";
|
|
171
167
|
return /* @__PURE__ */ t.createElement("div", {
|
|
172
168
|
className: `se-design-dropdown-container${o?.className ? ` ${o?.className}` : ""}`,
|
|
173
169
|
style: o?.style
|
|
@@ -175,21 +171,23 @@ const ae = (o) => {
|
|
|
175
171
|
className: "se-design-dropdown-label mb-[3px] text-[var(--color-gray-700)] text-sm"
|
|
176
172
|
}, o?.label), /* @__PURE__ */ t.createElement("div", {
|
|
177
173
|
style: o?.style,
|
|
178
|
-
className: `${
|
|
179
|
-
}, /* @__PURE__ */ t.createElement(
|
|
180
|
-
ref:
|
|
181
|
-
renderPopoverContents:
|
|
174
|
+
className: `${y ? "bg-[var(--color-gray-50)] rounded-md cursor-not-allowed" : ""}`
|
|
175
|
+
}, /* @__PURE__ */ t.createElement(Y, {
|
|
176
|
+
ref: p,
|
|
177
|
+
renderPopoverContents: E || (v ? F : J),
|
|
182
178
|
contentWidth: "full",
|
|
183
179
|
renderPopoverSrcElement: K,
|
|
184
|
-
onPopoverToggle: (e) =>
|
|
185
|
-
disabled:
|
|
180
|
+
onPopoverToggle: (e) => P(e),
|
|
181
|
+
disabled: y,
|
|
186
182
|
automationId: o?.dropDownSrcAutomationId,
|
|
187
|
-
popoverContentAutomationId: o?.dropDownContentAutomationId
|
|
188
|
-
|
|
183
|
+
popoverContentAutomationId: o?.dropDownContentAutomationId,
|
|
184
|
+
ariaLabel: X(),
|
|
185
|
+
sourceRole: "combobox"
|
|
186
|
+
})), S && /* @__PURE__ */ t.createElement("div", {
|
|
189
187
|
className: "text-[var(--color-red-500)] text-sm"
|
|
190
|
-
},
|
|
188
|
+
}, O));
|
|
191
189
|
};
|
|
192
190
|
export {
|
|
193
|
-
|
|
191
|
+
ce as Dropdown
|
|
194
192
|
};
|
|
195
193
|
//# sourceMappingURL=index23.js.map
|
package/dist/index23.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index23.js","sources":["../src/components/Dropdown/index.tsx"],"sourcesContent":["import React, { FC, useState, useRef, useEffect } from 'react';\n\nimport { Popover, PopoverHandle } from 'src/components/Popover';\nimport { Icon } from 'components/Icon';\nimport { Checkbox } from '../Checkbox';\nimport { Button } from '../Button';\nimport { InputWithIcon } from '../InputWithIcon';\n\ntype DropdownValue = {\n [key: string]: any;\n};\n\ntype DropdownProps = {\n label?: string;\n type: 'select' | 'multi-select';\n dropDownOptions?: DropdownValue[];\n defaultText?: string;\n selectBy?: string;\n optionsUniqueBy?: string;\n displaySelected?: boolean;\n defaultSelectedValue?: DropdownValue | DropdownValue[];\n onOptionClick?: (selectedValue: DropdownValue) => void;\n style?: React.CSSProperties;\n renderOptionChip?: (option: DropdownValue, srcOption: boolean) => React.ReactNode;\n className?: string;\n iconColor?: string;\n disabled?: boolean;\n dropdownClassName?: string;\n hasError?: boolean;\n errorMessage?: string;\n onApply?: (selectedValue: DropdownValue[]) => void;\n customDropdownContent?: () => React.ReactNode;\n isBorderless?: boolean;\n dropDownSrcAutomationId?: string;\n dropDownSelectAutomationId?: string;\n dropDownContentAutomationId?: string;\n shouldShowSearch?: boolean;\n searchPlaceholder?: string;\n searchResultEmptyMessage?: string;\n};\n\nexport const Dropdown: FC<DropdownProps> = (props) => {\n const [isDropDownOpen, setIsDropDownOpen] = useState(false);\n const [searchQuery, setSearchQuery] = useState('');\n const [selectedDropDownValues, setSelectedDropDownValues] = useState<DropdownValue[]>(() =>\n props?.defaultSelectedValue\n ? Array.isArray(props?.defaultSelectedValue)\n ? props?.defaultSelectedValue\n : [props.defaultSelectedValue]\n : []\n );\n const popoverRef = useRef<HTMLDivElement & PopoverHandle>(null);\n\n const {\n selectBy = '',\n optionsUniqueBy = '',\n displaySelected = false,\n dropDownOptions,\n defaultText = 'Select',\n iconColor = 'var(--color-gray-700)',\n disabled = false,\n dropdownClassName = '',\n hasError = false,\n errorMessage = '',\n customDropdownContent = null,\n isBorderless = false,\n shouldShowSearch = false,\n searchPlaceholder = 'Search...',\n searchResultEmptyMessage = 'No results found'\n } = props;\n\n useEffect(() => {\n const newValues = props?.defaultSelectedValue\n ? Array.isArray(props?.defaultSelectedValue)\n ? props?.defaultSelectedValue\n : [props.defaultSelectedValue]\n : [];\n setSelectedDropDownValues(newValues);\n }, [props?.defaultSelectedValue]);\n\n useEffect(() => {\n if (!isDropDownOpen) {\n setSearchQuery('');\n }\n }, [isDropDownOpen]);\n\n const isMultiSelect = props?.type === 'multi-select';\n\n const getFilteredOptions = () => {\n if (!searchQuery.trim()) {\n return dropDownOptions || [];\n }\n return (dropDownOptions || []).filter((option) => {\n const optionValue = option?.[selectBy]?.toString().toLowerCase() || '';\n return optionValue.includes(searchQuery.toLowerCase());\n });\n };\n\n const handleDropDownOptionClick = (dropDownOption: any) => {\n setSelectedDropDownValues([dropDownOption]);\n popoverRef.current?.togglePopover();\n props?.onOptionClick?.(dropDownOption);\n };\n\n const getSelectedDropDownValue = (option: DropdownValue) => {\n if (isMultiSelect) {\n return defaultText;\n }\n return option?.[selectBy] || defaultText;\n };\n\n const clearSelectedDropDownValues = () => {\n setSelectedDropDownValues([]);\n };\n\n const optionChip = (option: DropdownValue, srcOption: boolean = false) => {\n if (props?.renderOptionChip) {\n return props?.renderOptionChip(option, srcOption);\n }\n\n if (isMultiSelect && selectedDropDownValues?.length > 0) {\n const firstSelectedLabel = selectedDropDownValues[0]?.[selectBy] || '';\n const remainingCount = selectedDropDownValues.length - 1;\n\n // For multiple selections: text takes remaining space, count takes minimum space needed\n return (\n <div className={`option-chip flex items-center w-full`}>\n <div\n className={`${remainingCount > 0 ? 'w-full' : 'flex-1'} truncate`}\n >{`${defaultText}: ${firstSelectedLabel}`}</div>\n {remainingCount > 0 && <div className=\"flex-shrink-0\">+{remainingCount}</div>}\n </div>\n );\n }\n\n return <p className={`option-chip flex flex-1 items-center justify-between`}>{getSelectedDropDownValue(option)}</p>;\n };\n\n const renderSearchBar = () => {\n return (\n <div className=\" w-full relative flex items-center border-b border-[var(--color-gray-300)]\">\n <InputWithIcon\n leftIcon={{ name: 'search', position: 'left', style: { color: 'var(--color-gray-500)' } }}\n value={searchQuery}\n onChange={(value) => setSearchQuery(value)}\n placeholder={searchPlaceholder}\n style={{ margin: 0, gap: 0 }}\n inputStyle={{ width: '100%', border: 'none', outline: 'none' }}\n />\n </div>\n );\n };\n\n const dropDownOptionJsx = (dropDownOption: DropdownValue, index: number) => {\n const optionTxt = dropDownOption[selectBy];\n const dropDownSelectedValue = selectedDropDownValues[0]?.[selectBy] || defaultText;\n const selectByUniqueId = optionsUniqueBy?.length\n ? dropDownOption[optionsUniqueBy] == selectedDropDownValues[0]?.[optionsUniqueBy]\n : true;\n const isOptionSelected = displaySelected && optionTxt === dropDownSelectedValue && selectByUniqueId;\n return (\n <div\n key={`$drop-option-${crypto.randomUUID()}`}\n className={`option break-words px-3 py-2 hover:bg-gray-100 cursor-pointer flex items-center justify-between ${\n isOptionSelected ? 'selected' : ''\n }`}\n onClick={() => handleDropDownOptionClick(dropDownOption)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n handleDropDownOptionClick(dropDownOption);\n }\n }}\n role=\"option\"\n aria-selected={isOptionSelected}\n tabIndex={0}\n data-automation-id={`dropdown-option-${dropDownOption?.automationId || index}`}\n >\n {optionChip({ ...dropDownOption, isOptionSelected }, false)}\n {isOptionSelected && <Icon name=\"checkmark\" stroke={iconColor} />}\n </div>\n );\n };\n\n const renderDropdownContents = () => {\n const filteredOptions = getFilteredOptions();\n return (\n <div className=\"dropdown-content dropdown-options\" role=\"listbox\" aria-label=\"Dropdown options\">\n {shouldShowSearch && renderSearchBar()}\n <div className=\"flex flex-col max-h-80 overflow-y-auto\">\n {filteredOptions.length > 0 ? (\n filteredOptions.map((dropDownOption, index) => dropDownOptionJsx(dropDownOption, index))\n ) : (\n <div className=\"px-3 py-4 text-center text-[var(--color-gray-500)] text-sm\" role=\"status\" aria-live=\"polite\">{searchResultEmptyMessage}</div>\n )}\n </div>\n </div>\n );\n };\n\n const handleMultiSelectDropdownOptionClick = (isSelected: boolean, dropDownOption: DropdownValue) => {\n let newSelectedDropDownValues: DropdownValue[] = [];\n if (isSelected) {\n newSelectedDropDownValues = [...selectedDropDownValues, dropDownOption];\n } else {\n newSelectedDropDownValues = selectedDropDownValues?.filter(\n (option) => option[optionsUniqueBy] !== dropDownOption[optionsUniqueBy]\n );\n }\n setSelectedDropDownValues(newSelectedDropDownValues);\n };\n\n const handleApplySelectedDropDownValues = () => {\n popoverRef.current?.togglePopover();\n props?.onApply?.(selectedDropDownValues);\n };\n\n const multiSelectDropdownOptionJSX = (dropDownOption: DropdownValue) => {\n const isOptionSelected = selectedDropDownValues.some(\n (option) => option[optionsUniqueBy] === dropDownOption[optionsUniqueBy]\n );\n return (\n <div\n key={`$drop-option-${crypto.randomUUID()}`}\n className=\"option px-3 py-2 hover:bg-gray-100 cursor-pointer flex items-center justify-between\"\n >\n <Checkbox\n automationId=\"checkbox\"\n className=\"checkbox\"\n defaultChecked={isOptionSelected}\n onChange={(value) => handleMultiSelectDropdownOptionClick(value, dropDownOption)}\n label={dropDownOption?.label}\n />\n </div>\n );\n };\n\n const renderMultiSelectDropdownContents = () => {\n const filteredOptions = getFilteredOptions();\n return (\n <div className=\"dropdown-content dropdown-options\" role=\"listbox\" aria-label=\"Multi-select dropdown options\" aria-multiselectable=\"true\">\n {shouldShowSearch && renderSearchBar()}\n <div className=\"flex flex-col max-h-80 overflow-y-auto\">\n {filteredOptions.length > 0 ? (\n filteredOptions.map((dropDownOption) => multiSelectDropdownOptionJSX(dropDownOption))\n ) : (\n <div className=\"px-3 py-4 text-center text-[var(--color-gray-500)] text-sm\" role=\"status\" aria-live=\"polite\">{searchResultEmptyMessage}</div>\n )}\n </div>\n <div className=\"flex items-center justify-end gap-4 p-3 border-t border-[var(--color-gray-200)]\">\n <Button label=\"Clear\" type=\"link\" size=\"sm\" onClick={clearSelectedDropDownValues} />\n <Button label=\"Apply\" type=\"primary\" size=\"sm\" onClick={handleApplySelectedDropDownValues} />\n </div>\n </div>\n );\n };\n\n const renderDropdownSelect = () => {\n const borderColor = isDropDownOpen\n ? 'border-[var(--color-blue-500)]'\n : disabled\n ? 'border-[var(--color-gray-300)]'\n : 'border-[var(--color-gray-600)]';\n const errorBorderColor = hasError ? 'border-[var(--color-red-500)]' : '';\n const dropDownSelectClass = `dropdown-src-element bg-[var(--color-white)] flex px-3 py-2 ${\n isBorderless ? 'border-0' : `border rounded-md ${errorBorderColor ? errorBorderColor : borderColor}`\n } flex items-center ${dropdownClassName}`;\n const selectedValue = selectedDropDownValues[0]?.[selectBy] || defaultText;\n const ariaLabel = props?.label ? `${props.label}: ${selectedValue}` : `Select option, currently selected: ${selectedValue}`;\n\n return (\n <div \n className={dropDownSelectClass}\n role=\"combobox\"\n aria-expanded={isDropDownOpen}\n aria-haspopup=\"listbox\"\n aria-label={ariaLabel}\n aria-disabled={disabled}\n >\n <div\n className=\"flex-1 min-w-0\"\n data-automation-id={props?.dropDownSelectAutomationId || 'selected-dropdown-value'}\n >\n {optionChip(selectedDropDownValues[0], true)}\n </div>\n <div className=\"flex-shrink-0 ml-2\" aria-hidden=\"true\">\n <Icon\n name={'chevron'}\n rotation={isDropDownOpen ? '180' : '0'}\n className={`transition-transform`}\n stroke={iconColor}\n />\n </div>\n </div>\n );\n };\n\n return (\n <div\n className={`se-design-dropdown-container${props?.className ? ` ${props?.className}` : ''}`}\n style={props?.style}\n >\n {props?.label && (\n <div className=\"se-design-dropdown-label mb-[3px] text-[var(--color-gray-700)] text-sm\">{props?.label}</div>\n )}\n <div\n style={props?.style}\n className={`${disabled ? 'bg-[var(--color-gray-50)] rounded-md cursor-not-allowed' : ''}`}\n >\n <Popover\n ref={popoverRef}\n renderPopoverContents={\n customDropdownContent\n ? customDropdownContent\n : isMultiSelect\n ? renderMultiSelectDropdownContents\n : renderDropdownContents\n }\n contentWidth={'full'}\n renderPopoverSrcElement={renderDropdownSelect}\n onPopoverToggle={(value) => setIsDropDownOpen(value)}\n disabled={disabled}\n automationId={props?.dropDownSrcAutomationId}\n popoverContentAutomationId={props?.dropDownContentAutomationId}\n />\n </div>\n {hasError && <div className=\"text-[var(--color-red-500)] text-sm\">{errorMessage}</div>}\n </div>\n );\n};\n"],"names":["React__default","useState","useRef","useEffect","Popover","Icon","Checkbox","Button","InputWithIcon","Dropdown","props","isDropDownOpen","setIsDropDownOpen","searchQuery","setSearchQuery","selectedDropDownValues","setSelectedDropDownValues","defaultSelectedValue","Array","isArray","popoverRef","selectBy","optionsUniqueBy","displaySelected","dropDownOptions","defaultText","iconColor","disabled","dropdownClassName","hasError","errorMessage","customDropdownContent","isBorderless","shouldShowSearch","searchPlaceholder","searchResultEmptyMessage","newValues","isMultiSelect","type","getFilteredOptions","trim","filter","option","toString","toLowerCase","includes","handleDropDownOptionClick","dropDownOption","current","togglePopover","onOptionClick","getSelectedDropDownValue","clearSelectedDropDownValues","optionChip","srcOption","renderOptionChip","length","firstSelectedLabel","remainingCount","React","createElement","className","renderSearchBar","leftIcon","name","position","style","color","value","onChange","placeholder","margin","gap","inputStyle","width","border","outline","dropDownOptionJsx","index","optionTxt","dropDownSelectedValue","selectByUniqueId","isOptionSelected","key","crypto","randomUUID","onClick","onKeyDown","e","preventDefault","role","tabIndex","automationId","stroke","renderDropdownContents","filteredOptions","map","handleMultiSelectDropdownOptionClick","isSelected","newSelectedDropDownValues","handleApplySelectedDropDownValues","onApply","multiSelectDropdownOptionJSX","some","defaultChecked","label","renderMultiSelectDropdownContents","size","renderDropdownSelect","borderColor","errorBorderColor","dropDownSelectClass","selectedValue","ariaLabel","dropDownSelectAutomationId","rotation","ref","renderPopoverContents","contentWidth","renderPopoverSrcElement","onPopoverToggle","dropDownSrcAutomationId","popoverContentAutomationId","dropDownContentAutomationId"],"mappings":"AAyCO,OAAAA,KAAA,YAAAC,GAAA,UAAAC,GAAA,aAAAC,SAAA;AAAA,SAAA,WAAAC,SAAA;AAAA,SAAA,QAAAC,SAAA;AAAA,SAAA,YAAAC,SAAA;AAAA,SAAA,UAAAC,SAAA;AAAA,SAAA,iBAAAC,SAAA;AAAA,MAAMC,KAA+BC,CAAAA,MAAU;AACpD,QAAM,CAACC,GA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zC,UAAAA;AAAAA,IACAiE,cAAclF,GAAO+G;AAAAA,IACrBC,4BAA4BhH,GAAOiH;AAAAA,EAAAA,CACpC,CACE,GACJ9F,KAAY8B,gBAAAA,EAAAC,cAAA,OAAA;AAAA,IAAKC,WAAU;AAAA,EAAA,GAAuC/B,CAAkB,CAClF;AAET;"}
|
|
1
|
+
{"version":3,"file":"index23.js","sources":["../src/components/Dropdown/index.tsx"],"sourcesContent":["import React, { FC, useState, useRef, useEffect } from 'react';\n\nimport { Popover, PopoverHandle } from 'src/components/Popover';\nimport { Icon } from 'components/Icon';\nimport { Checkbox } from '../Checkbox';\nimport { Button } from '../Button';\nimport { InputWithIcon } from '../InputWithIcon';\n\ntype DropdownValue = {\n [key: string]: any;\n};\n\ntype DropdownProps = {\n label?: string;\n ariaLabel?: string;\n type: 'select' | 'multi-select';\n dropDownOptions?: DropdownValue[];\n defaultText?: string;\n selectBy?: string;\n optionsUniqueBy?: string;\n displaySelected?: boolean;\n defaultSelectedValue?: DropdownValue | DropdownValue[];\n onOptionClick?: (selectedValue: DropdownValue) => void;\n style?: React.CSSProperties;\n renderOptionChip?: (option: DropdownValue, srcOption: boolean) => React.ReactNode;\n className?: string;\n iconColor?: string;\n disabled?: boolean;\n dropdownClassName?: string;\n hasError?: boolean;\n errorMessage?: string;\n onApply?: (selectedValue: DropdownValue[]) => void;\n customDropdownContent?: () => React.ReactNode;\n isBorderless?: boolean;\n dropDownSrcAutomationId?: string;\n dropDownSelectAutomationId?: string;\n dropDownContentAutomationId?: string;\n shouldShowSearch?: boolean;\n searchPlaceholder?: string;\n searchResultEmptyMessage?: string;\n};\n\nexport const Dropdown: FC<DropdownProps> = (props) => {\n const [isDropDownOpen, setIsDropDownOpen] = useState(false);\n const [searchQuery, setSearchQuery] = useState('');\n const [selectedDropDownValues, setSelectedDropDownValues] = useState<DropdownValue[]>(() =>\n props?.defaultSelectedValue\n ? Array.isArray(props?.defaultSelectedValue)\n ? props?.defaultSelectedValue\n : [props.defaultSelectedValue]\n : []\n );\n const popoverRef = useRef<HTMLDivElement & PopoverHandle>(null);\n\n const {\n selectBy = '',\n optionsUniqueBy = '',\n displaySelected = false,\n dropDownOptions,\n defaultText = 'Select',\n iconColor = 'var(--color-gray-700)',\n disabled = false,\n dropdownClassName = '',\n hasError = false,\n errorMessage = '',\n customDropdownContent = null,\n isBorderless = false,\n shouldShowSearch = false,\n searchPlaceholder = 'Search...',\n searchResultEmptyMessage = 'No results found',\n ariaLabel = ''\n } = props;\n\n useEffect(() => {\n const newValues = props?.defaultSelectedValue\n ? Array.isArray(props?.defaultSelectedValue)\n ? props?.defaultSelectedValue\n : [props.defaultSelectedValue]\n : [];\n setSelectedDropDownValues(newValues);\n }, [props?.defaultSelectedValue]);\n\n useEffect(() => {\n if (!isDropDownOpen) {\n setSearchQuery('');\n }\n }, [isDropDownOpen]);\n\n const isMultiSelect = props?.type === 'multi-select';\n\n const getFilteredOptions = () => {\n if (!searchQuery.trim()) {\n return dropDownOptions || [];\n }\n return (dropDownOptions || []).filter((option) => {\n const optionValue = option?.[selectBy]?.toString().toLowerCase() || '';\n return optionValue.includes(searchQuery.toLowerCase());\n });\n };\n\n const handleDropDownOptionClick = (dropDownOption: any) => {\n setSelectedDropDownValues([dropDownOption]);\n popoverRef.current?.togglePopover();\n props?.onOptionClick?.(dropDownOption);\n };\n\n const getSelectedDropDownValue = (option: DropdownValue) => {\n if (isMultiSelect) {\n return defaultText;\n }\n return option?.[selectBy] || defaultText;\n };\n\n const clearSelectedDropDownValues = () => {\n setSelectedDropDownValues([]);\n };\n\n const optionChip = (option: DropdownValue, srcOption: boolean = false) => {\n if (props?.renderOptionChip) {\n return props?.renderOptionChip(option, srcOption);\n }\n\n if (isMultiSelect && selectedDropDownValues?.length > 0) {\n const firstSelectedLabel = selectedDropDownValues[0]?.[selectBy] || '';\n const remainingCount = selectedDropDownValues.length - 1;\n\n // For multiple selections: text takes remaining space, count takes minimum space needed\n return (\n <div className={`option-chip flex items-center w-full`}>\n <div\n className={`${remainingCount > 0 ? 'w-full' : 'flex-1'} truncate`}\n >{`${defaultText}: ${firstSelectedLabel}`}</div>\n {remainingCount > 0 && <div className=\"flex-shrink-0\">+{remainingCount}</div>}\n </div>\n );\n }\n\n return <p className={`option-chip flex flex-1 items-center justify-between`}>{getSelectedDropDownValue(option)}</p>;\n };\n\n const renderSearchBar = () => {\n return (\n <div className=\" w-full relative flex items-center border-b border-[var(--color-gray-300)]\">\n <InputWithIcon\n leftIcon={{ name: 'search', position: 'left', style: { color: 'var(--color-gray-500)' } }}\n value={searchQuery}\n onChange={(value) => setSearchQuery(value)}\n placeholder={searchPlaceholder}\n style={{ margin: 0, gap: 0 }}\n inputStyle={{ width: '100%', border: 'none', outline: 'none' }}\n />\n </div>\n );\n };\n\n const dropDownOptionJsx = (dropDownOption: DropdownValue, index: number) => {\n const optionTxt = dropDownOption[selectBy];\n const dropDownSelectedValue = selectedDropDownValues[0]?.[selectBy] || defaultText;\n const selectByUniqueId = optionsUniqueBy?.length\n ? dropDownOption[optionsUniqueBy] == selectedDropDownValues[0]?.[optionsUniqueBy]\n : true;\n const isOptionSelected = displaySelected && optionTxt === dropDownSelectedValue && selectByUniqueId;\n return (\n <div\n key={`$drop-option-${crypto.randomUUID()}`}\n className={`option break-words px-3 py-2 hover:bg-gray-100 cursor-pointer flex items-center justify-between ${\n isOptionSelected ? 'selected' : ''\n }`}\n onClick={() => handleDropDownOptionClick(dropDownOption)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n handleDropDownOptionClick(dropDownOption);\n }\n }}\n role=\"option\"\n aria-selected={isOptionSelected ? 'true' : 'false'}\n tabIndex={0}\n data-automation-id={`dropdown-option-${dropDownOption?.automationId || index}`}\n >\n {optionChip({ ...dropDownOption, isOptionSelected }, false)}\n {isOptionSelected && <Icon name=\"checkmark\" stroke={iconColor} />}\n </div>\n );\n };\n\n const renderDropdownContents = () => {\n const filteredOptions = getFilteredOptions();\n return (\n <div className=\"dropdown-content dropdown-options\" role=\"listbox\" aria-label=\"Dropdown options\">\n {shouldShowSearch && renderSearchBar()}\n <div className=\"flex flex-col max-h-80 overflow-y-auto\">\n {filteredOptions.length > 0 ? (\n filteredOptions.map((dropDownOption, index) => dropDownOptionJsx(dropDownOption, index))\n ) : (\n <div className=\"px-3 py-4 text-center text-[var(--color-gray-500)] text-sm\" role=\"status\" aria-live=\"polite\">{searchResultEmptyMessage}</div>\n )}\n </div>\n </div>\n );\n };\n\n const handleMultiSelectDropdownOptionClick = (isSelected: boolean, dropDownOption: DropdownValue) => {\n let newSelectedDropDownValues: DropdownValue[] = [];\n if (isSelected) {\n newSelectedDropDownValues = [...selectedDropDownValues, dropDownOption];\n } else {\n newSelectedDropDownValues = selectedDropDownValues?.filter(\n (option) => option[optionsUniqueBy] !== dropDownOption[optionsUniqueBy]\n );\n }\n setSelectedDropDownValues(newSelectedDropDownValues);\n };\n\n const handleApplySelectedDropDownValues = () => {\n popoverRef.current?.togglePopover();\n props?.onApply?.(selectedDropDownValues);\n };\n\n const multiSelectDropdownOptionJSX = (dropDownOption: DropdownValue) => {\n const isOptionSelected = selectedDropDownValues.some(\n (option) => option[optionsUniqueBy] === dropDownOption[optionsUniqueBy]\n );\n return (\n <div\n key={`$drop-option-${crypto.randomUUID()}`}\n className=\"option px-3 py-2 hover:bg-gray-100 cursor-pointer flex items-center justify-between\"\n >\n <Checkbox\n automationId=\"checkbox\"\n className=\"checkbox\"\n defaultChecked={isOptionSelected}\n onChange={(value) => handleMultiSelectDropdownOptionClick(value, dropDownOption)}\n label={dropDownOption?.label}\n />\n </div>\n );\n };\n\n const renderMultiSelectDropdownContents = () => {\n const filteredOptions = getFilteredOptions();\n return (\n <div className=\"dropdown-content dropdown-options\" role=\"listbox\" aria-label=\"Multi-select dropdown options\" aria-multiselectable=\"true\">\n {shouldShowSearch && renderSearchBar()}\n <div className=\"flex flex-col max-h-80 overflow-y-auto\">\n {filteredOptions.length > 0 ? (\n filteredOptions.map((dropDownOption) => multiSelectDropdownOptionJSX(dropDownOption))\n ) : (\n <div className=\"px-3 py-4 text-center text-[var(--color-gray-500)] text-sm\" role=\"status\" aria-live=\"polite\">{searchResultEmptyMessage}</div>\n )}\n </div>\n <div className=\"flex items-center justify-end gap-4 p-3 border-t border-[var(--color-gray-200)]\">\n <Button label=\"Clear\" type=\"link\" size=\"sm\" onClick={clearSelectedDropDownValues} />\n <Button label=\"Apply\" type=\"primary\" size=\"sm\" onClick={handleApplySelectedDropDownValues} />\n </div>\n </div>\n );\n };\n\n const renderDropdownSelect = () => {\n const borderColor = isDropDownOpen\n ? 'border-[var(--color-blue-500)]'\n : disabled\n ? 'border-[var(--color-gray-300)]'\n : 'border-[var(--color-gray-600)]';\n const errorBorderColor = hasError ? 'border-[var(--color-red-500)]' : '';\n const dropDownSelectClass = `dropdown-src-element bg-[var(--color-white)] flex px-3 py-2 ${\n isBorderless ? 'border-0' : `border rounded-md ${errorBorderColor ? errorBorderColor : borderColor}`\n } flex items-center ${dropdownClassName}`;\n\n return (\n <div className={dropDownSelectClass}>\n <div\n className=\"flex-1 min-w-0\"\n data-automation-id={props?.dropDownSelectAutomationId || 'selected-dropdown-value'}\n >\n {optionChip(selectedDropDownValues[0], true)}\n </div>\n <div className=\"flex-shrink-0 ml-2\" aria-hidden=\"true\">\n <Icon\n name={'chevron'}\n rotation={isDropDownOpen ? '180' : '0'}\n className={`transition-transform`}\n stroke={iconColor}\n />\n </div>\n </div>\n );\n };\n\n const getDropdownAriaLabel = () => {\n return ariaLabel || `Select option`;\n };\n\n return (\n <div\n className={`se-design-dropdown-container${props?.className ? ` ${props?.className}` : ''}`}\n style={props?.style}\n >\n {props?.label && (\n <div className=\"se-design-dropdown-label mb-[3px] text-[var(--color-gray-700)] text-sm\">{props?.label}</div>\n )}\n <div\n style={props?.style}\n className={`${disabled ? 'bg-[var(--color-gray-50)] rounded-md cursor-not-allowed' : ''}`}\n >\n <Popover\n ref={popoverRef}\n renderPopoverContents={\n customDropdownContent\n ? customDropdownContent\n : isMultiSelect\n ? renderMultiSelectDropdownContents\n : renderDropdownContents\n }\n contentWidth={'full'}\n renderPopoverSrcElement={renderDropdownSelect}\n onPopoverToggle={(value) => setIsDropDownOpen(value)}\n disabled={disabled}\n automationId={props?.dropDownSrcAutomationId}\n popoverContentAutomationId={props?.dropDownContentAutomationId}\n ariaLabel={getDropdownAriaLabel()}\n sourceRole=\"combobox\"\n />\n </div>\n {hasError && <div className=\"text-[var(--color-red-500)] text-sm\">{errorMessage}</div>}\n </div>\n );\n};\n"],"names":["React__default","useState","useRef","useEffect","Popover","Icon","Checkbox","Button","InputWithIcon","Dropdown","props","isDropDownOpen","setIsDropDownOpen","searchQuery","setSearchQuery","selectedDropDownValues","setSelectedDropDownValues","defaultSelectedValue","Array","isArray","popoverRef","selectBy","optionsUniqueBy","displaySelected","dropDownOptions","defaultText","iconColor","disabled","dropdownClassName","hasError","errorMessage","customDropdownContent","isBorderless","shouldShowSearch","searchPlaceholder","searchResultEmptyMessage","ariaLabel","newValues","isMultiSelect","type","getFilteredOptions","trim","filter","option","toString","toLowerCase","includes","handleDropDownOptionClick","dropDownOption","current","togglePopover","onOptionClick","getSelectedDropDownValue","clearSelectedDropDownValues","optionChip","srcOption","renderOptionChip","length","firstSelectedLabel","remainingCount","React","createElement","className","renderSearchBar","leftIcon","name","position","style","color","value","onChange","placeholder","margin","gap","inputStyle","width","border","outline","dropDownOptionJsx","index","optionTxt","dropDownSelectedValue","selectByUniqueId","isOptionSelected","key","crypto","randomUUID","onClick","onKeyDown","e","preventDefault","role","tabIndex","automationId","stroke","renderDropdownContents","filteredOptions","map","handleMultiSelectDropdownOptionClick","isSelected","newSelectedDropDownValues","handleApplySelectedDropDownValues","onApply","multiSelectDropdownOptionJSX","some","defaultChecked","label","renderMultiSelectDropdownContents","size","renderDropdownSelect","borderColor","errorBorderColor","dropDownSelectClass","dropDownSelectAutomationId","rotation","getDropdownAriaLabel","ref","renderPopoverContents","contentWidth","renderPopoverSrcElement","onPopoverToggle","dropDownSrcAutomationId","popoverContentAutomationId","dropDownContentAutomationId","sourceRole"],"mappings":"AA0CO,OAAAA,KAAA,YAAAC,GAAA,UAAAC,GAAA,aAAAC,SAAA;AAAA,SAAA,WAAAC,SAAA;AAAA,SAAA,QAAAC,SAAA;AAAA,SAAA,YAAAC,SAAA;AAAA,SAAA,UAAAC,SAAA;AAAA,SAAA,iBAAAC,UAAA;AAAA,MAAMC,KAA+BC,CAAAA,MAAU;AACpD,QAAM,CAACC,GAAgBC,CAAiB,IAAIX,EAAS,EAAK,GACpD,CAACY,GAAaC,CAAc,IAAIb,EAAS,EAAE,GAC3C,CAACc,GAAwBC,CAAyB,IAAIf,EAA0B,MACpFS,GAAOO,uBACHC,MAAMC,QAAQT,GAAOO,oBAAoB,IACvCP,GAAOO,uBACP,CAACP,EAAMO,oBAAoB,IAC7B,EACN,GACMG,IAAalB,EAAuC,IAAI,GAExD;AAAA,IACJmB,UAAAA,IAAW;AAAA,IACXC,iBAAAA,IAAkB;AAAA,IAClBC,iBAAAA,IAAkB;AAAA,IAClBC,iBAAAA;AAAAA,IACAC,aAAAA,IAAc;AAAA,IACdC,WAAAA,IAAY;AAAA,IACZC,UAAAA,IAAW;AAAA,IACXC,mBAAAA,IAAoB;AAAA,IACpBC,UAAAA,IAAW;AAAA,IACXC,cAAAA,IAAe;AAAA,IACfC,uBAAAA,IAAwB;AAAA,IACxBC,cAAAA,IAAe;AAAA,IACfC,kBAAAA,IAAmB;AAAA,IACnBC,mBAAAA,IAAoB;AAAA,IACpBC,0BAAAA,IAA2B;AAAA,IAC3BC,WAAAA,IAAY;AAAA,EAAA,IACV1B;AAEJP,EAAAA,EAAU,MAAM;AACd,UAAMkC,IAAY3B,GAAOO,uBACrBC,MAAMC,QAAQT,GAAOO,oBAAoB,IACvCP,GAAOO,uBACP,CAACP,EAAMO,oBAAoB,IAC7B,CAAA;AACJD,IAAAA,EAA0BqB,CAAS;AAAA,EACrC,GAAG,CAAC3B,GA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;AAAAA,IACLiG,uBACEtF,MAEIO,IACAqE,IACAZ;AAAAA,IAENuB,cAAc;AAAA,IACdC,yBAAyBV;AAAAA,IACzBW,iBAAkBnD,CAAAA,MAAUzD,EAAkByD,CAAK;AAAA,IACnD1C,UAAAA;AAAAA,IACAkE,cAAcnF,GAAO+G;AAAAA,IACrBC,4BAA4BhH,GAAOiH;AAAAA,IACnCvF,WAAW+E,EAAAA;AAAAA,IACXS,YAAW;AAAA,EAAA,CACZ,CACE,GACJ/F,KAAY+B,gBAAAA,EAAAC,cAAA,OAAA;AAAA,IAAKC,WAAU;AAAA,EAAA,GAAuChC,CAAkB,CAClF;AAET;"}
|
package/dist/index5.js
CHANGED
|
@@ -5,8 +5,8 @@ import d from "./index60.js";
|
|
|
5
5
|
import h from "./index61.js";
|
|
6
6
|
import u from "./index62.js";
|
|
7
7
|
import k from "./index63.js";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import A from "./index64.js";
|
|
9
|
+
import x from "./index65.js";
|
|
10
10
|
import w from "./index66.js";
|
|
11
11
|
import I from "./index67.js";
|
|
12
12
|
import y from "./index68.js";
|
|
@@ -59,8 +59,8 @@ import ds from "./index114.js";
|
|
|
59
59
|
import hs from "./index115.js";
|
|
60
60
|
import us from "./index116.js";
|
|
61
61
|
import ks from "./index117.js";
|
|
62
|
-
import
|
|
63
|
-
import
|
|
62
|
+
import As from "./index118.js";
|
|
63
|
+
import xs from "./index119.js";
|
|
64
64
|
import ws from "./index120.js";
|
|
65
65
|
import Is from "./index121.js";
|
|
66
66
|
import ys from "./index122.js";
|
|
@@ -106,8 +106,8 @@ const ro = /* @__PURE__ */ Object.assign({
|
|
|
106
106
|
"/src/assets/icons/attachment.svg": h,
|
|
107
107
|
"/src/assets/icons/back.svg": u,
|
|
108
108
|
"/src/assets/icons/banner-demo-img.svg": k,
|
|
109
|
-
"/src/assets/icons/bell-notification.svg":
|
|
110
|
-
"/src/assets/icons/card.svg":
|
|
109
|
+
"/src/assets/icons/bell-notification.svg": A,
|
|
110
|
+
"/src/assets/icons/card.svg": x,
|
|
111
111
|
"/src/assets/icons/checkbox-disabled-minus.svg": w,
|
|
112
112
|
"/src/assets/icons/checkbox-disabled-tick.svg": I,
|
|
113
113
|
"/src/assets/icons/checkbox-disabled.svg": y,
|
|
@@ -160,8 +160,8 @@ const ro = /* @__PURE__ */ Object.assign({
|
|
|
160
160
|
"/src/assets/icons/outlook.svg": hs,
|
|
161
161
|
"/src/assets/icons/padlock.svg": us,
|
|
162
162
|
"/src/assets/icons/pages.svg": ks,
|
|
163
|
-
"/src/assets/icons/pdf-file.svg":
|
|
164
|
-
"/src/assets/icons/people.svg":
|
|
163
|
+
"/src/assets/icons/pdf-file.svg": As,
|
|
164
|
+
"/src/assets/icons/people.svg": xs,
|
|
165
165
|
"/src/assets/icons/photo.svg": ws,
|
|
166
166
|
"/src/assets/icons/radio-field.svg": Is,
|
|
167
167
|
"/src/assets/icons/radio-filled.svg": ys,
|
|
@@ -198,15 +198,15 @@ const ro = /* @__PURE__ */ Object.assign({
|
|
|
198
198
|
"/src/assets/icons/white-close.svg": _o,
|
|
199
199
|
"/src/assets/icons/widget-demo-image.svg": to
|
|
200
200
|
}), m = (s, _, t, o) => {
|
|
201
|
-
_ && s.hasAttribute("fill") && s.getAttribute("fill") !== "none" && s.setAttribute("fill", _), t && s.hasAttribute("stroke") && s.setAttribute("stroke", t), o && s.hasAttribute("width") && s.setAttribute("width", o.toString()), o && s.hasAttribute("height") && s.setAttribute("height", o.toString()), Array.from(s.children).forEach((
|
|
202
|
-
m(
|
|
201
|
+
_ && s.hasAttribute("fill") && s.getAttribute("fill") !== "none" && s.setAttribute("fill", _), t && s.hasAttribute("stroke") && s.setAttribute("stroke", t), o && s.hasAttribute("width") && s.setAttribute("width", o.toString()), o && s.hasAttribute("height") && s.setAttribute("height", o.toString()), Array.from(s.children).forEach((r) => {
|
|
202
|
+
m(r, _, t);
|
|
203
203
|
});
|
|
204
204
|
}, z_ = (s) => {
|
|
205
205
|
const {
|
|
206
206
|
name: _ = "",
|
|
207
207
|
className: t = "",
|
|
208
208
|
onClick: o,
|
|
209
|
-
fill:
|
|
209
|
+
fill: r,
|
|
210
210
|
stroke: g,
|
|
211
211
|
rotation: v = "0",
|
|
212
212
|
size: a,
|
|
@@ -219,15 +219,15 @@ const ro = /* @__PURE__ */ Object.assign({
|
|
|
219
219
|
}, e = ro[`/src/assets/icons/${_}.svg`];
|
|
220
220
|
return e ? /* @__PURE__ */ c.createElement("div", {
|
|
221
221
|
className: `se-design-svg-wrapper transition-transform duration-250 ease-linear ${o ? "cursor-pointer" : ""} ${t} ${n[v]}`,
|
|
222
|
-
onClick: (
|
|
223
|
-
l &&
|
|
222
|
+
onClick: (i) => {
|
|
223
|
+
l && i.stopPropagation(), o?.();
|
|
224
224
|
},
|
|
225
225
|
"data-automation-id": s?.automationId
|
|
226
226
|
}, /* @__PURE__ */ c.createElement(io, {
|
|
227
227
|
src: e,
|
|
228
228
|
wrapper: "span",
|
|
229
|
-
beforeInjection: (
|
|
230
|
-
|
|
229
|
+
beforeInjection: (i) => {
|
|
230
|
+
i.setAttribute("aria-hidden", "true"), i.setAttribute("role", "none"), m(i, r, g, a);
|
|
231
231
|
}
|
|
232
232
|
})) : (console.error(`Icon "${_}" not found in ICON_MAP.`), null);
|
|
233
233
|
};
|
package/dist/index5.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index5.js","sources":["../src/components/Icon/index.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport { ReactSVG } from 'react-svg';\n\n// Dynamically import icons using Vite's asset handling\nconst ICON_MAP: Record<string, string> = (import.meta as any).glob('/src/assets/icons/*.svg', {\n eager: true,\n query: '?url',\n import: 'default'\n});\n\nexport type IconProps = {\n name: string;\n className?: string;\n onClick?: () => void;\n fill?: string;\n stroke?: string;\n rotation?: '0' | '90' | '180' | '270';\n size?: number;\n shouldStopPropagation?: boolean;\n automationId?: string;\n};\n\nconst applyAttributesToElement = (element: Element, fill?: string, stroke?: string, size?: number) => {\n // Only modify existing attributes\n if (fill && element.hasAttribute('fill')) {\n const currentFill = element.getAttribute('fill');\n // Only update if the current fill is not \"none\"\n if (currentFill !== 'none') {\n element.setAttribute('fill', fill);\n }\n }\n\n if (stroke && element.hasAttribute('stroke')) {\n element.setAttribute('stroke', stroke);\n }\n\n if (size && element.hasAttribute('width')) {\n element.setAttribute('width', size.toString());\n }\n\n if (size && element.hasAttribute('height')) {\n element.setAttribute('height', size.toString());\n }\n\n // Recursively apply to all child elements\n Array.from(element.children).forEach((child) => {\n applyAttributesToElement(child, fill, stroke);\n });\n};\n\nexport const Icon: FC<IconProps> = (props) => {\n const {\n name = '',\n className = '',\n onClick,\n fill,\n stroke,\n rotation = '0',\n size,\n shouldStopPropagation = false\n } = props;\n const iconRotationClasses = {\n '0': '',\n '90': 'rotate-90',\n '180': 'rotate-180',\n '270': '-rotate-90'\n };\n const src = ICON_MAP[`/src/assets/icons/${name}.svg`];\n\n if (!src) {\n console.error(`Icon \"${name}\" not found in ICON_MAP.`);\n return null;\n }\n\n return (\n <div\n className={`se-design-svg-wrapper transition-transform duration-250 ease-linear ${onClick ? 'cursor-pointer' : ''} ${className} ${iconRotationClasses[rotation]}`}\n onClick={(e) => {\n shouldStopPropagation && e.stopPropagation();\n onClick?.();\n }}\n data-automation-id={props?.automationId}\n >\n <ReactSVG\n src={src}\n wrapper=\"span\"\n beforeInjection={(svg) => {\n applyAttributesToElement(svg, fill, stroke, size);\n }}\n />\n </div>\n );\n};\n"],"names":["ICON_MAP","import","applyAttributesToElement","element","fill","stroke","size","hasAttribute","getAttribute","setAttribute","toString","Array","from","children","forEach","child","Icon","props","name","className","onClick","rotation","shouldStopPropagation","iconRotationClasses","src","React","createElement","e","stopPropagation","automationId","ReactSVG","wrapper","beforeInjection","svg","console","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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icon/index.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport { ReactSVG } from 'react-svg';\n\n// Dynamically import icons using Vite's asset handling\nconst ICON_MAP: Record<string, string> = (import.meta as any).glob('/src/assets/icons/*.svg', {\n eager: true,\n query: '?url',\n import: 'default'\n});\n\nexport type IconProps = {\n name: string;\n className?: string;\n onClick?: () => void;\n fill?: string;\n stroke?: string;\n rotation?: '0' | '90' | '180' | '270';\n size?: number;\n shouldStopPropagation?: boolean;\n automationId?: string;\n};\n\nconst applyAttributesToElement = (element: Element, fill?: string, stroke?: string, size?: number) => {\n // Only modify existing attributes\n if (fill && element.hasAttribute('fill')) {\n const currentFill = element.getAttribute('fill');\n // Only update if the current fill is not \"none\"\n if (currentFill !== 'none') {\n element.setAttribute('fill', fill);\n }\n }\n\n if (stroke && element.hasAttribute('stroke')) {\n element.setAttribute('stroke', stroke);\n }\n\n if (size && element.hasAttribute('width')) {\n element.setAttribute('width', size.toString());\n }\n\n if (size && element.hasAttribute('height')) {\n element.setAttribute('height', size.toString());\n }\n\n // Recursively apply to all child elements\n Array.from(element.children).forEach((child) => {\n applyAttributesToElement(child, fill, stroke);\n });\n};\n\nexport const Icon: FC<IconProps> = (props) => {\n const {\n name = '',\n className = '',\n onClick,\n fill,\n stroke,\n rotation = '0',\n size,\n shouldStopPropagation = false\n } = props;\n const iconRotationClasses = {\n '0': '',\n '90': 'rotate-90',\n '180': 'rotate-180',\n '270': '-rotate-90'\n };\n const src = ICON_MAP[`/src/assets/icons/${name}.svg`];\n\n if (!src) {\n console.error(`Icon \"${name}\" not found in ICON_MAP.`);\n return null;\n }\n\n return (\n <div\n className={`se-design-svg-wrapper transition-transform duration-250 ease-linear ${onClick ? 'cursor-pointer' : ''} ${className} ${iconRotationClasses[rotation]}`}\n onClick={(e) => {\n shouldStopPropagation && e.stopPropagation();\n onClick?.();\n }}\n data-automation-id={props?.automationId}\n >\n <ReactSVG\n src={src}\n wrapper=\"span\"\n beforeInjection={(svg) => {\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('role', 'none');\n applyAttributesToElement(svg, fill, stroke, size);\n }}\n />\n </div>\n );\n};\n"],"names":["ICON_MAP","import","applyAttributesToElement","element","fill","stroke","size","hasAttribute","getAttribute","setAttribute","toString","Array","from","children","forEach","child","Icon","props","name","className","onClick","rotation","shouldStopPropagation","iconRotationClasses","src","React","createElement","e","stopPropagation","automationId","ReactSVG","wrapper","beforeInjection","svg","console","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAMA,KAAoCC,uBAAAA,OAAAA;AAAAA,EAAAA,mCAAAA;AAAAA,EAAAA,kCAAAA;AAAAA,EAAAA,4BAAAA;AAAAA,EAAAA,mCAAAA;AAAAA,EAAAA,oCAAAA;AAAAA,EAAAA,8BAAAA;AAAAA,EAAAA,yCAAAA;AAAAA,EAAAA,2CAAAA;AAAAA,EAAAA,8BAAAA;AAAAA,EAAAA,iDAAAA;AAAAA,EAAAA,gDAAAA;AAAAA,EAAAA,2CAAAA;AAAAA,EAAAA,wCAAAA;AAAAA,EAAAA,uCAAAA;AAAAA,EAAAA,6CAAAA;AAAAA,EAAAA,8CAAAA;AAAAA,EAAAA,6CAAAA;AAAAA,EAAAA,wCAAAA;AAAAA,EAAAA,uCAAAA;AAAAA,EAAAA,wCAAAA;AAAAA,EAAAA,mCAAAA;AAAAA,EAAAA,iCAAAA;AAAAA,EAAAA,+BAAAA;AAAAA,EAAAA,+BAAAA;AAAAA,EAAAA,iCAAAA;AAAAA,EAAAA,kCAAAA;AAAAA,EAAAA,6BAAAA;AAAAA,EAAAA,oCAAAA;AAAAA,EAAAA,gCAAAA;AAAAA,EAAAA,iCAAAA;AAAAA,EAAAA,kCAAAA;AAAAA,EAAAA,mCAAAA;AAAAA,EAAAA,qCAAAA;AAAAA,EAAAA,+BAAAA;AAAAA,EAAA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