@payloadcms/ui 4.0.0-internal.183b315 → 4.0.0-internal.293e026
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/css/colors.css +107 -60
- package/dist/elements/Chip/index.css +1 -1
- package/dist/elements/Combobox/index.css +8 -8
- package/dist/elements/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/elements/DatePicker/DatePicker.js +4 -2
- package/dist/elements/DatePicker/DatePicker.js.map +1 -1
- package/dist/elements/DatePicker/index.css +5 -0
- package/dist/elements/DatePicker/index.js +1 -1
- package/dist/elements/DatePicker/index.js.map +1 -1
- package/dist/elements/GroupByControl/index.d.ts.map +1 -1
- package/dist/elements/GroupByControl/index.js +3 -0
- package/dist/elements/GroupByControl/index.js.map +1 -1
- package/dist/elements/ListControls/index.d.ts.map +1 -1
- package/dist/elements/ListControls/index.js +1 -1
- package/dist/elements/ListControls/index.js.map +1 -1
- package/dist/elements/ListSelection/index.css +1 -1
- package/dist/elements/Pill/index.css +1 -1
- package/dist/elements/PillSelector/index.css +1 -1
- package/dist/elements/Popup/index.d.ts.map +1 -1
- package/dist/elements/Popup/index.js +27 -10
- package/dist/elements/Popup/index.js.map +1 -1
- package/dist/elements/ReactSelect/index.css +53 -52
- package/dist/elements/ReactSelect/index.d.ts.map +1 -1
- package/dist/elements/ReactSelect/index.js +68 -9
- package/dist/elements/ReactSelect/index.js.map +1 -1
- package/dist/elements/ReactSelect/types.d.ts +6 -1
- package/dist/elements/ReactSelect/types.d.ts.map +1 -1
- package/dist/elements/ReactSelect/types.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Blocks/index.js +1 -2
- package/dist/elements/Table/DefaultCell/fields/Blocks/index.js.map +1 -1
- package/dist/elements/TimezonePicker/index.css +73 -24
- package/dist/elements/TimezonePicker/index.d.ts.map +1 -1
- package/dist/elements/TimezonePicker/index.js +31 -4
- package/dist/elements/TimezonePicker/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.css +1 -1
- package/dist/elements/WhereBuilder/Condition/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js +3 -0
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/exports/client/index.d.ts +1 -1
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +1 -1
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/shared/index.js +1 -1
- package/dist/exports/shared/index.js.map +2 -2
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +6 -11
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Group/index.css +1 -1
- package/dist/fields/Join/index.js +1 -1
- package/dist/fields/Join/index.js.map +1 -1
- package/dist/fields/Relationship/select-components/MultiValueLabel/index.css +3 -3
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.js +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/icons/Dots/index.css +4 -4
- package/dist/providers/ListQuery/index.d.ts.map +1 -1
- package/dist/providers/ListQuery/index.js +1 -8
- package/dist/providers/ListQuery/index.js.map +1 -1
- package/dist/providers/Theme/index.d.ts +17 -2
- package/dist/providers/Theme/index.d.ts.map +1 -1
- package/dist/providers/Theme/index.js +122 -73
- package/dist/providers/Theme/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js +1 -1
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/traverseFields.js +1 -1
- package/dist/utilities/buildFieldSchemaMap/traverseFields.js.map +1 -1
- package/dist/utilities/copyDataFromLocale.js +1 -1
- package/dist/utilities/copyDataFromLocale.js.map +1 -1
- package/dist/utilities/renderTable.js +1 -1
- package/dist/utilities/renderTable.js.map +1 -1
- package/dist/utilities/traverseForLocalizedFields.d.ts.map +1 -1
- package/dist/utilities/traverseForLocalizedFields.js +3 -0
- package/dist/utilities/traverseForLocalizedFields.js.map +1 -1
- package/dist/views/List/index.js +2 -2
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/Verify/index.client.d.ts +4 -0
- package/dist/views/Verify/index.client.d.ts.map +1 -1
- package/dist/views/Verify/index.client.js +81 -0
- package/dist/views/Verify/index.client.js.map +1 -1
- package/dist/views/Verify/index.css +38 -0
- package/dist/views/Verify/index.d.ts +1 -1
- package/dist/views/Verify/index.d.ts.map +1 -1
- package/dist/views/Verify/index.js +13 -19
- package/dist/views/Verify/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js +2 -2
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js +3 -3
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js.map +1 -1
- package/package.json +4 -4
- package/dist/views/Unauthorized/index.scss +0 -14
- package/dist/views/Verify/index.scss +0 -18
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
4
|
export * as PopupList from './PopupButtonList/index.js';
|
|
5
5
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
import { useEffectEvent } from '../../hooks/useEffectEvent.js';
|
|
8
|
+
import { ThemeProvider } from '../../providers/Theme/index.js';
|
|
8
9
|
import './index.css';
|
|
9
10
|
import { PopupTrigger } from './PopupTrigger/index.js';
|
|
10
11
|
const baseClass = 'popup';
|
|
@@ -230,10 +231,19 @@ export const Popup = props => {
|
|
|
230
231
|
// /////////////////////////////////////
|
|
231
232
|
useEffect(() => {
|
|
232
233
|
if (!active) {
|
|
234
|
+
const popup_1 = popupRef.current;
|
|
235
|
+
if (popup_1) {
|
|
236
|
+
// Clear inline position styles so the CSS `top: -9999px` rule on
|
|
237
|
+
// `.popup__hidden-content` takes effect. Without this, the inline
|
|
238
|
+
// styles set during positioning would win over the CSS rule, keeping
|
|
239
|
+
// portaled children (e.g. a ReactSelect menu) visually on-screen.
|
|
240
|
+
popup_1.style.top = '';
|
|
241
|
+
popup_1.style.left = '';
|
|
242
|
+
}
|
|
233
243
|
return;
|
|
234
244
|
}
|
|
235
|
-
const
|
|
236
|
-
if (!
|
|
245
|
+
const popup_2 = popupRef.current;
|
|
246
|
+
if (!popup_2) {
|
|
237
247
|
return;
|
|
238
248
|
}
|
|
239
249
|
// /////////////////////////////////////
|
|
@@ -262,7 +272,7 @@ export const Popup = props => {
|
|
|
262
272
|
if (openedViaKeyboardRef.current) {
|
|
263
273
|
// Use requestAnimationFrame to ensure DOM is ready.
|
|
264
274
|
requestAnimationFrame(() => {
|
|
265
|
-
const firstFocusable =
|
|
275
|
+
const firstFocusable = popup_2.querySelector(TABBABLE_SELECTOR);
|
|
266
276
|
firstFocusable?.focus();
|
|
267
277
|
});
|
|
268
278
|
}
|
|
@@ -279,7 +289,7 @@ export const Popup = props => {
|
|
|
279
289
|
});
|
|
280
290
|
document.addEventListener('mousedown', handleClickOutside);
|
|
281
291
|
document.addEventListener('keydown', handleKeyDown);
|
|
282
|
-
|
|
292
|
+
popup_2.addEventListener('click', handleActionableClick);
|
|
283
293
|
return () => {
|
|
284
294
|
cancelAnimationFrame(rafId);
|
|
285
295
|
window.removeEventListener('resize', updatePosition);
|
|
@@ -288,7 +298,7 @@ export const Popup = props => {
|
|
|
288
298
|
});
|
|
289
299
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
290
300
|
document.removeEventListener('keydown', handleKeyDown);
|
|
291
|
-
|
|
301
|
+
popup_2.removeEventListener('click', handleActionableClick);
|
|
292
302
|
};
|
|
293
303
|
}, [active]);
|
|
294
304
|
useEffect(() => {
|
|
@@ -333,11 +343,18 @@ export const Popup = props => {
|
|
|
333
343
|
"data-popup-id": id || undefined,
|
|
334
344
|
"data-theme": theme === 'auto' ? undefined : theme,
|
|
335
345
|
ref: popupRef,
|
|
336
|
-
children: [/*#__PURE__*/
|
|
346
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
337
347
|
className: `${baseClass}__scroll-container${showScrollbar ? ` ${baseClass}__scroll-container--show-scrollbar` : ''}`,
|
|
338
|
-
children:
|
|
339
|
-
|
|
340
|
-
|
|
348
|
+
children: theme === 'auto' ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
349
|
+
children: [render?.({
|
|
350
|
+
close: () => setActive(false)
|
|
351
|
+
}), children]
|
|
352
|
+
}) : /*#__PURE__*/_jsxs(ThemeProvider, {
|
|
353
|
+
theme: theme,
|
|
354
|
+
children: [render?.({
|
|
355
|
+
close: () => setActive(false)
|
|
356
|
+
}), children]
|
|
357
|
+
})
|
|
341
358
|
}), caret && /*#__PURE__*/_jsx("div", {
|
|
342
359
|
className: `${baseClass}__caret`
|
|
343
360
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["PopupList","React","useCallback","useEffect","useRef","useState","createPortal","useEffectEvent","PopupTrigger","baseClass","TABBABLE_SELECTOR","map","s","join","Popup","props","id","button","buttonClassName","buttonSize","buttonType","caret","children","className","disabled","forceOpen","horizontalAlign","initActive","noBackground","onToggleClose","onToggleOpen","portalClassName","render","renderButton","showOnHover","showScrollbar","size","theme","verticalAlign","popupRef","triggerRef","openedViaKeyboardRef","mounted","setMounted","active","setActiveInternal","isOnTop","setIsOnTop","setActive","isActive","viaKeyboard","current","updatePosition","trigger","popup","triggerRect","getBoundingClientRect","popupRect","offset","top","onTop","bottom","window","scrollY","height","innerHeight","topIfAbove","left","right","width","Math","max","min","innerWidth","triggerCenter","caretLeft","newTop","round","newLeft","scrollX","newCaretLeft","style","getPropertyValue","setProperty","handleClickOutside","e","target","isOutsidePopup","contains","isOutsideTrigger","clickedPopupContent","closest","isInsideChildPopup","handleKeyDown","key","preventDefault","querySelector","focus","focusable","Array","from","querySelectorAll","length","currentIndex","findIndex","el","document","activeElement","goBackward","shiftKey","nextIndex","handleActionableClick","actionable","rafId","requestAnimationFrame","firstFocusable","addEventListener","capture","passive","cancelAnimationFrame","removeEventListener","undefined","Trigger","_jsx","_jsxs","filter","Boolean","ref","onMouseEnter","onMouseLeave","role","tabIndex","close","body"],"sources":["../../../src/elements/Popup/index.tsx"],"sourcesContent":["'use client'\nimport type { CSSProperties } from 'react'\n\nexport * as PopupList from './PopupButtonList/index.js'\n\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEffectEvent } from '../../hooks/useEffectEvent.js'\nimport './index.css'\nimport { PopupTrigger } from './PopupTrigger/index.js'\n\nconst baseClass = 'popup'\n\n/**\n * Selector for all elements the browser considers tabbable.\n */\nconst TABBABLE_SELECTOR = [\n 'a[href]',\n 'button:not(:disabled)',\n 'input:not(:disabled):not([type=\"hidden\"])',\n 'select:not(:disabled)',\n 'textarea:not(:disabled)',\n '[tabindex]',\n '[contenteditable]:not([contenteditable=\"false\"])',\n 'audio[controls]',\n 'video[controls]',\n 'summary',\n]\n .map((s) => `${s}:not([tabindex=\"-1\"])`)\n .join(', ')\n\nexport type PopupProps = {\n backgroundColor?: CSSProperties['backgroundColor']\n boundingRef?: React.RefObject<HTMLElement>\n button?: React.ReactNode\n /**\n * The class name to apply to the button that triggers the popup.\n */\n buttonClassName?: string\n buttonSize?: 'large' | 'medium'\n buttonType?: 'custom' | 'default'\n caret?: boolean\n children?: React.ReactNode\n /**\n * The class name to apply to the popup container containing the trigger.\n * This does not wrap the actual popup content, which is rendered in a portal.\n */\n className?: string\n disabled?: boolean\n /**\n * Force control the open state of the popup, regardless of the trigger.\n */\n forceOpen?: boolean\n /**\n * Preferred horizontal alignment of the popup, if there is enough space available.\n *\n * @default 'left'\n */\n horizontalAlign?: 'center' | 'left' | 'right'\n id?: string\n initActive?: boolean\n noBackground?: boolean\n onToggleClose?: () => void\n onToggleOpen?: (active: boolean) => void\n /**\n * Class name to apply to the portal container.\n */\n portalClassName?: string\n render?: (args: { close: () => void }) => React.ReactNode\n /**\n * Render prop for custom trigger button. Receives onClick/onKeyDown/aria props.\n * When provided, `button` and `buttonType` are ignored.\n */\n renderButton?: (props: {\n active: boolean\n 'aria-expanded': boolean\n 'aria-haspopup': true\n onClick: React.MouseEventHandler\n onKeyDown: React.KeyboardEventHandler\n }) => React.ReactNode\n showOnHover?: boolean\n /**\n * By default, the scrollbar is hidden. If you want to show it, set this to true.\n * In both cases, the container is still scrollable.\n *\n * @default false\n */\n showScrollbar?: boolean\n size?: 'fit-content' | 'large' | 'medium' | 'small'\n /**\n * Theme for the popup content. Defaults to 'dark'.\n * Set to 'auto' to inherit the current theme.\n *\n * @default 'dark'\n */\n theme?: 'auto' | 'dark' | 'light'\n /**\n * Preferred vertical alignment of the popup (position below or above the trigger),\n * if there is enough space available.\n *\n * If the popup is too close to the edge of the viewport, it will flip to the opposite side\n * regardless of the preferred vertical alignment.\n *\n * @default 'bottom'\n */\n verticalAlign?: 'bottom' | 'top'\n}\n\n/**\n * Component that renders a popup, as well as a button that triggers the popup.\n *\n * The popup is rendered in a portal, and is automatically positioned above / below the trigger,\n * depending on the verticalAlign prop and the space available.\n */\nexport const Popup: React.FC<PopupProps> = (props) => {\n const {\n id,\n button,\n buttonClassName,\n buttonSize,\n buttonType = 'default',\n caret = true,\n children,\n className,\n disabled,\n forceOpen,\n horizontalAlign = 'left',\n initActive = false,\n noBackground,\n onToggleClose,\n onToggleOpen,\n portalClassName,\n render,\n renderButton,\n showOnHover = false,\n showScrollbar = false,\n size = 'medium',\n theme = 'dark',\n verticalAlign = 'bottom',\n } = props\n\n const popupRef = useRef<HTMLDivElement>(null)\n const triggerRef = useRef<HTMLDivElement>(null)\n\n /**\n * Keeps track of whether the popup was opened via keyboard.\n * This is used to determine whether to autofocus the first element in the popup.\n * If the popup was opened via mouse, we do not want to autofocus the first element.\n */\n const openedViaKeyboardRef = useRef(false)\n\n const [mounted, setMounted] = useState(false)\n const [active, setActiveInternal] = useState(initActive)\n const [isOnTop, setIsOnTop] = useState(verticalAlign === 'top')\n\n // Track when component is mounted to avoid SSR/client hydration mismatch\n useEffect(() => {\n setMounted(true)\n }, [])\n\n const setActive = useCallback(\n (isActive: boolean, viaKeyboard = false) => {\n if (isActive) {\n openedViaKeyboardRef.current = viaKeyboard\n onToggleOpen?.(true)\n } else {\n onToggleClose?.()\n }\n setActiveInternal(isActive)\n },\n [onToggleClose, onToggleOpen],\n )\n\n // /////////////////////////////////////\n // Position Calculation\n //\n // Calculates and applies popup position relative to trigger.\n // Always checks viewport bounds (for flipping), but only updates\n // styles if the calculated position differs from current position.\n // /////////////////////////////////////\n\n const updatePosition = useEffectEvent(() => {\n const trigger = triggerRef.current\n const popup = popupRef.current\n if (!trigger || !popup) {\n return\n }\n\n const triggerRect = trigger.getBoundingClientRect()\n const popupRect = popup.getBoundingClientRect()\n\n // Gap between the popup and the trigger/viewport edges (in pixels)\n const offset = 10\n\n // /////////////////////////////////////\n // Vertical Positioning\n // Calculates the `top` position in absolute page coordinates.\n // Uses `verticalAlign` prop as the preferred direction, but flips\n // to the opposite side if there's not enough viewport space.\n // /////////////////////////////////////\n\n let top: number\n let onTop = verticalAlign === 'top'\n\n if (verticalAlign === 'bottom') {\n top = triggerRect.bottom + window.scrollY + offset\n\n if (triggerRect.bottom + popupRect.height + offset > window.innerHeight) {\n // Try to flip above — only do so if there's actually enough room\n const topIfAbove = triggerRect.top + window.scrollY - popupRect.height - offset\n if (topIfAbove >= window.scrollY) {\n top = topIfAbove\n onTop = true\n }\n // else: not enough room above either — keep below and let it overflow rather than going off-screen\n }\n } else {\n top = triggerRect.top + window.scrollY - popupRect.height - offset\n\n if (triggerRect.top - popupRect.height - offset < 0) {\n top = triggerRect.bottom + window.scrollY + offset\n onTop = false\n }\n }\n\n setIsOnTop(onTop)\n\n // /////////////////////////////////////\n // Horizontal Positioning\n // Calculates the `left` position based on `horizontalAlign` prop:\n // - 'left': aligns popup's left edge with trigger's left edge\n // - 'right': aligns popup's right edge with trigger's right edge\n // - 'center': centers popup horizontally relative to trigger\n // Then clamps to keep the popup within viewport bounds.\n // /////////////////////////////////////\n\n let left =\n horizontalAlign === 'right'\n ? triggerRect.right - popupRect.width\n : horizontalAlign === 'center'\n ? triggerRect.left + triggerRect.width / 2 - popupRect.width / 2\n : triggerRect.left\n\n left = Math.max(offset, Math.min(left, window.innerWidth - popupRect.width - offset))\n\n // /////////////////////////////////////\n // Caret Positioning\n // Positions the caret arrow to point at the trigger's horizontal center.\n // Clamps between 12px from edges to prevent caret from overflowing the popup.\n // /////////////////////////////////////\n\n const triggerCenter = triggerRect.left + triggerRect.width / 2\n const caretLeft = Math.max(12, Math.min(triggerCenter - left, popupRect.width - 12))\n\n // /////////////////////////////////////\n // Apply Styles (only if changed)\n // Compares calculated position with current styles to avoid unnecessary\n // DOM updates during scroll. This prevents visual lag by relying on the absolute\n // positioning where possible (popup slightly lags behind when scrolling really fast),\n // while still allowing position changes when needed (e.g., sticky parent, viewport flip).\n // Values are rounded to match browser's CSS precision and avoid false updates.\n // /////////////////////////////////////\n\n const newTop = `${Math.round(top)}px`\n const newLeft = `${Math.round(left + window.scrollX)}px`\n const newCaretLeft = `${Math.round(caretLeft)}px`\n\n if (popup.style.top !== newTop) {\n popup.style.top = newTop\n }\n if (popup.style.left !== newLeft) {\n popup.style.left = newLeft\n }\n if (popup.style.getPropertyValue('--caret-left') !== newCaretLeft) {\n popup.style.setProperty('--caret-left', newCaretLeft)\n }\n })\n\n // /////////////////////////////////////\n // Click Outside Handler\n // Closes popup when clicking outside both the popup and trigger.\n // Distinguishes between parent and child popups:\n // - Click in child popup: parent stays open\n // - Click in parent popup: child closes\n // /////////////////////////////////////\n\n const handleClickOutside = useEffectEvent((e: MouseEvent) => {\n const target = e.target as Node\n const isOutsidePopup = !popupRef.current?.contains(target)\n const isOutsideTrigger = !triggerRef.current?.contains(target)\n\n // Check if click is inside a popup portal\n const clickedPopupContent = (target as Element).closest?.('.popup__content')\n\n // If the clicked popup contains this popup's trigger, it's a parent popup\n // and we should close. If it doesn't contain our trigger, it's a child popup\n // and we should stay open to avoid closing parent when interacting with child.\n const isInsideChildPopup =\n clickedPopupContent && !clickedPopupContent.contains(triggerRef.current)\n\n if (isOutsidePopup && isOutsideTrigger && !isInsideChildPopup) {\n setActive(false)\n }\n })\n\n // /////////////////////////////////////\n // Keyboard Navigation\n // Handles keyboard interactions when popup is open:\n // - Escape: closes popup and returns focus to trigger\n // - Tab/Shift+Tab: cycles through focusable items with wrapping\n // - ArrowUp/ArrowDown: same as Shift+Tab/Tab for menu-style navigation\n // Focus is managed manually to support elements the browser might skip.\n // /////////////////////////////////////\n\n const handleKeyDown = useEffectEvent((e: KeyboardEvent) => {\n const popup = popupRef.current\n if (!popup || !active) {\n return\n }\n\n if (e.key === 'Escape') {\n e.preventDefault()\n setActive(false)\n triggerRef.current?.querySelector<HTMLElement>('button, [tabindex=\"0\"]')?.focus()\n return\n }\n\n if (e.key === 'Tab' || e.key === 'ArrowDown' || e.key === 'ArrowUp') {\n const focusable = Array.from(popup.querySelectorAll<HTMLElement>(TABBABLE_SELECTOR))\n if (focusable.length === 0) {\n return\n }\n\n e.preventDefault()\n\n const currentIndex = focusable.findIndex((el) => el === document.activeElement)\n const goBackward = e.key === 'ArrowUp' || (e.key === 'Tab' && e.shiftKey)\n\n let nextIndex: number\n if (currentIndex === -1) {\n nextIndex = goBackward ? focusable.length - 1 : 0\n } else if (goBackward) {\n nextIndex = currentIndex === 0 ? focusable.length - 1 : currentIndex - 1\n } else {\n nextIndex = currentIndex === focusable.length - 1 ? 0 : currentIndex + 1\n }\n\n focusable[nextIndex].focus()\n }\n })\n\n // /////////////////////////////////////\n // Click Handler for Actionable Elements\n // Closes popup when buttons/links inside are clicked (includes Enter/Space activation).\n // /////////////////////////////////////\n\n const handleActionableClick = useEffectEvent((e: MouseEvent) => {\n const target = e.target as HTMLElement\n\n // Allow opting out with data-popup-prevent-close attribute on element or ancestor\n if (target.closest('[data-popup-prevent-close]')) {\n return\n }\n\n // Check if the clicked element or any ancestor is an actionable element\n const actionable = target.closest('button, a[href], [role=\"button\"], [role=\"menuitem\"]')\n if (actionable && popupRef.current?.contains(actionable)) {\n setActive(false)\n }\n })\n\n // /////////////////////////////////////\n // Effect: Setup/Teardown position and focus management\n // /////////////////////////////////////\n\n useEffect(() => {\n if (!active) {\n return\n }\n\n const popup = popupRef.current\n if (!popup) {\n return\n }\n\n // /////////////////////////////////////\n // Initial Position\n // Calculate and apply popup position.\n // getBoundingClientRect() forces synchronous layout.\n //\n // We call updatePosition() twice: once synchronously (so the popup\n // snaps to roughly the right place immediately rather than flashing\n // from -9999px) and once in a requestAnimationFrame, which fires\n // after the browser has finished laying out the newly-visible popup\n // content. The rAF call is the authoritative one — it catches cases\n // where the popup height wasn't stable yet during the first call\n // (e.g. ColumnSelector content rendering after hidden → visible\n // class switch), which was causing incorrect flip-to-top decisions.\n // /////////////////////////////////////\n\n updatePosition()\n const rafId = requestAnimationFrame(() => {\n updatePosition()\n })\n\n // /////////////////////////////////////\n // Focus Management\n // When opened via keyboard, autofocus the first focusable button.\n // When opened via mouse, skip autofocus to avoid unwanted highlights.\n // /////////////////////////////////////\n\n if (openedViaKeyboardRef.current) {\n // Use requestAnimationFrame to ensure DOM is ready.\n requestAnimationFrame(() => {\n const firstFocusable = popup.querySelector<HTMLElement>(TABBABLE_SELECTOR)\n firstFocusable?.focus()\n })\n }\n\n // /////////////////////////////////////\n // Event Listeners\n // - resize/scroll: recalculate position (only applies styles if changed)\n // - mousedown: detect clicks outside to close\n // - keydown: handle keyboard navigation\n // /////////////////////////////////////\n\n window.addEventListener('resize', updatePosition)\n window.addEventListener('scroll', updatePosition, { capture: true, passive: true })\n document.addEventListener('mousedown', handleClickOutside)\n document.addEventListener('keydown', handleKeyDown)\n popup.addEventListener('click', handleActionableClick)\n\n return () => {\n cancelAnimationFrame(rafId)\n window.removeEventListener('resize', updatePosition)\n window.removeEventListener('scroll', updatePosition, { capture: true })\n document.removeEventListener('mousedown', handleClickOutside)\n document.removeEventListener('keydown', handleKeyDown)\n popup.removeEventListener('click', handleActionableClick)\n }\n }, [active])\n\n useEffect(() => {\n if (forceOpen !== undefined) {\n setActive(forceOpen)\n }\n }, [forceOpen, setActive])\n\n const Trigger = (\n <PopupTrigger\n active={active}\n button={button}\n buttonType={buttonType}\n className={buttonClassName}\n disabled={disabled}\n noBackground={noBackground}\n renderButton={renderButton}\n setActive={setActive}\n size={buttonSize}\n />\n )\n\n return (\n <div className={[baseClass, className].filter(Boolean).join(' ')} id={id}>\n <div className={`${baseClass}__trigger-wrap`} ref={triggerRef}>\n {showOnHover ? (\n <div\n className={`${baseClass}__on-hover-watch`}\n onMouseEnter={() => setActive(true)}\n onMouseLeave={() => setActive(false)}\n role=\"button\"\n tabIndex={0}\n >\n {Trigger}\n </div>\n ) : (\n Trigger\n )}\n </div>\n\n {mounted\n ? // We need to make sure the popup is part of the DOM (although invisible), even if it's not active.\n // This ensures that components within the popup, like modals, do not unmount when the popup closes.\n // Otherwise, modals opened from the popup will close unexpectedly when clicking within the modal, since\n // that closes the popup due to the click outside handler.\n createPortal(\n <div\n className={\n active\n ? [\n `${baseClass}__content`,\n `${baseClass}--size-${size}`,\n isOnTop ? `${baseClass}--v-top` : `${baseClass}--v-bottom`,\n portalClassName,\n ]\n .filter(Boolean)\n .join(' ')\n : // Do not share any class names between active and disabled popups, to make sure\n // tests do not accidentally target inactive popups.\n `${baseClass}__hidden-content`\n }\n data-popup-id={id || undefined}\n data-theme={theme === 'auto' ? undefined : theme}\n ref={popupRef}\n >\n <div\n className={`${baseClass}__scroll-container${showScrollbar ? ` ${baseClass}__scroll-container--show-scrollbar` : ''}`}\n >\n {render?.({ close: () => setActive(false) })}\n {children}\n </div>\n {caret && <div className={`${baseClass}__caret`} />}\n </div>,\n document.body,\n )\n : null}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,SAAS,MAAM;AAE3B,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAChE,SAASC,YAAY,QAAQ;AAE7B,SAASC,cAAc,QAAQ;AAC/B,OAAO;AACP,SAASC,YAAY,QAAQ;AAE7B,MAAMC,SAAA,GAAY;AAElB;;;AAGA,MAAMC,iBAAA,GAAoB,CACxB,WACA,yBACA,6CACA,yBACA,2BACA,cACA,oDACA,mBACA,mBACA,UACD,CACEC,GAAG,CAAEC,CAAA,IAAM,GAAGA,CAAA,uBAAwB,EACtCC,IAAI,CAAC;AA+ER;;;;;;AAMA,OAAO,MAAMC,KAAA,GAA+BC,KAAA;EAC1C,MAAM;IACJC,EAAE;IACFC,MAAM;IACNC,eAAe;IACfC,UAAU;IACVC,UAAA,GAAa,SAAS;IACtBC,KAAA,GAAQ,IAAI;IACZC,QAAQ;IACRC,SAAS;IACTC,QAAQ;IACRC,SAAS;IACTC,eAAA,GAAkB,MAAM;IACxBC,UAAA,GAAa,KAAK;IAClBC,YAAY;IACZC,aAAa;IACbC,YAAY;IACZC,eAAe;IACfC,MAAM;IACNC,YAAY;IACZC,WAAA,GAAc,KAAK;IACnBC,aAAA,GAAgB,KAAK;IACrBC,IAAA,GAAO,QAAQ;IACfC,KAAA,GAAQ,MAAM;IACdC,aAAA,GAAgB;EAAQ,CACzB,GAAGvB,KAAA;EAEJ,MAAMwB,QAAA,GAAWnC,MAAA,CAAuB;EACxC,MAAMoC,UAAA,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BiF,YAAA,EAAcA,CAAA,KAAMjF,SAAA,CAAU;QAC9BkF,IAAA,EAAK;QACLC,QAAA,EAAU;kBAETT;WAGHA;QAIHhF,OAAA;IAEG;IACA;IACA;;IACApC,YAAA,cACEsH,KAAA,CAAC;MACCrG,SAAA,EACEqB,MAAA,GACI,CACE,GAAGnC,SAAA,WAAoB,EACvB,GAAGA,SAAA,UAAmB2B,IAAA,EAAM,EAC5BU,OAAA,GAAU,GAAGrC,SAAA,SAAkB,GAAG,GAAGA,SAAA,YAAqB,EAC1DsB,eAAA,CACD,CACE8F,MAAM,CAACC,OAAA,EACPjH,IAAI,CAAC;MAER;MACA,GAAGJ,SAAA,kBAA2B;MAEpC,iBAAeO,EAAA,IAAMyG,SAAA;MACrB,cAAYpF,KAAA,KAAU,SAASoF,SAAA,GAAYpF,KAAA;MAC3C0F,GAAA,EAAKxF,QAAA;8BAELqF,KAAA,CAAC;QACCrG,SAAA,EAAW,GAAGd,SAAA,qBAA8B0B,aAAA,GAAgB,IAAI1B,SAAA,oCAA6C,GAAG,IAAI;mBAEnHuB,MAAA,GAAS;UAAEoG,KAAA,EAAOA,CAAA,KAAMpF,SAAA,CAAU;QAAO,IACzC1B,QAAA;UAEFD,KAAA,iBAASsG,IAAA,CAAC;QAAIpG,SAAA,EAAW,GAAGd,SAAA;;QAE/BiG,QAAA,CAAS2B,IAAI,IAEf;;AAGV","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["PopupList","React","useCallback","useEffect","useRef","useState","createPortal","useEffectEvent","ThemeProvider","PopupTrigger","baseClass","TABBABLE_SELECTOR","map","s","join","Popup","props","id","button","buttonClassName","buttonSize","buttonType","caret","children","className","disabled","forceOpen","horizontalAlign","initActive","noBackground","onToggleClose","onToggleOpen","portalClassName","render","renderButton","showOnHover","showScrollbar","size","theme","verticalAlign","popupRef","triggerRef","openedViaKeyboardRef","mounted","setMounted","active","setActiveInternal","isOnTop","setIsOnTop","setActive","isActive","viaKeyboard","current","updatePosition","trigger","popup","triggerRect","getBoundingClientRect","popupRect","offset","top","onTop","bottom","window","scrollY","height","innerHeight","topIfAbove","left","right","width","Math","max","min","innerWidth","triggerCenter","caretLeft","newTop","round","newLeft","scrollX","newCaretLeft","style","getPropertyValue","setProperty","handleClickOutside","e","target","isOutsidePopup","contains","isOutsideTrigger","clickedPopupContent","closest","isInsideChildPopup","handleKeyDown","key","preventDefault","querySelector","focus","focusable","Array","from","querySelectorAll","length","currentIndex","findIndex","el","document","activeElement","goBackward","shiftKey","nextIndex","handleActionableClick","actionable","rafId","requestAnimationFrame","firstFocusable","addEventListener","capture","passive","cancelAnimationFrame","removeEventListener","undefined","Trigger","_jsx","_jsxs","filter","Boolean","ref","onMouseEnter","onMouseLeave","role","tabIndex","_Fragment","close","body"],"sources":["../../../src/elements/Popup/index.tsx"],"sourcesContent":["'use client'\nimport type { CSSProperties } from 'react'\n\nexport * as PopupList from './PopupButtonList/index.js'\n\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEffectEvent } from '../../hooks/useEffectEvent.js'\nimport { ThemeProvider } from '../../providers/Theme/index.js'\nimport './index.css'\nimport { PopupTrigger } from './PopupTrigger/index.js'\n\nconst baseClass = 'popup'\n\n/**\n * Selector for all elements the browser considers tabbable.\n */\nconst TABBABLE_SELECTOR = [\n 'a[href]',\n 'button:not(:disabled)',\n 'input:not(:disabled):not([type=\"hidden\"])',\n 'select:not(:disabled)',\n 'textarea:not(:disabled)',\n '[tabindex]',\n '[contenteditable]:not([contenteditable=\"false\"])',\n 'audio[controls]',\n 'video[controls]',\n 'summary',\n]\n .map((s) => `${s}:not([tabindex=\"-1\"])`)\n .join(', ')\n\nexport type PopupProps = {\n backgroundColor?: CSSProperties['backgroundColor']\n boundingRef?: React.RefObject<HTMLElement>\n button?: React.ReactNode\n /**\n * The class name to apply to the button that triggers the popup.\n */\n buttonClassName?: string\n buttonSize?: 'large' | 'medium'\n buttonType?: 'custom' | 'default'\n caret?: boolean\n children?: React.ReactNode\n /**\n * The class name to apply to the popup container containing the trigger.\n * This does not wrap the actual popup content, which is rendered in a portal.\n */\n className?: string\n disabled?: boolean\n /**\n * Force control the open state of the popup, regardless of the trigger.\n */\n forceOpen?: boolean\n /**\n * Preferred horizontal alignment of the popup, if there is enough space available.\n *\n * @default 'left'\n */\n horizontalAlign?: 'center' | 'left' | 'right'\n id?: string\n initActive?: boolean\n noBackground?: boolean\n onToggleClose?: () => void\n onToggleOpen?: (active: boolean) => void\n /**\n * Class name to apply to the portal container.\n */\n portalClassName?: string\n render?: (args: { close: () => void }) => React.ReactNode\n /**\n * Render prop for custom trigger button. Receives onClick/onKeyDown/aria props.\n * When provided, `button` and `buttonType` are ignored.\n */\n renderButton?: (props: {\n active: boolean\n 'aria-expanded': boolean\n 'aria-haspopup': true\n onClick: React.MouseEventHandler\n onKeyDown: React.KeyboardEventHandler\n }) => React.ReactNode\n showOnHover?: boolean\n /**\n * By default, the scrollbar is hidden. If you want to show it, set this to true.\n * In both cases, the container is still scrollable.\n *\n * @default false\n */\n showScrollbar?: boolean\n size?: 'fit-content' | 'large' | 'medium' | 'small'\n /**\n * Theme for the popup content. Defaults to 'dark'.\n * Set to 'auto' to inherit the current theme.\n *\n * @default 'dark'\n */\n theme?: 'auto' | 'dark' | 'light'\n /**\n * Preferred vertical alignment of the popup (position below or above the trigger),\n * if there is enough space available.\n *\n * If the popup is too close to the edge of the viewport, it will flip to the opposite side\n * regardless of the preferred vertical alignment.\n *\n * @default 'bottom'\n */\n verticalAlign?: 'bottom' | 'top'\n}\n\n/**\n * Component that renders a popup, as well as a button that triggers the popup.\n *\n * The popup is rendered in a portal, and is automatically positioned above / below the trigger,\n * depending on the verticalAlign prop and the space available.\n */\nexport const Popup: React.FC<PopupProps> = (props) => {\n const {\n id,\n button,\n buttonClassName,\n buttonSize,\n buttonType = 'default',\n caret = true,\n children,\n className,\n disabled,\n forceOpen,\n horizontalAlign = 'left',\n initActive = false,\n noBackground,\n onToggleClose,\n onToggleOpen,\n portalClassName,\n render,\n renderButton,\n showOnHover = false,\n showScrollbar = false,\n size = 'medium',\n theme = 'dark',\n verticalAlign = 'bottom',\n } = props\n\n const popupRef = useRef<HTMLDivElement>(null)\n const triggerRef = useRef<HTMLDivElement>(null)\n\n /**\n * Keeps track of whether the popup was opened via keyboard.\n * This is used to determine whether to autofocus the first element in the popup.\n * If the popup was opened via mouse, we do not want to autofocus the first element.\n */\n const openedViaKeyboardRef = useRef(false)\n\n const [mounted, setMounted] = useState(false)\n const [active, setActiveInternal] = useState(initActive)\n const [isOnTop, setIsOnTop] = useState(verticalAlign === 'top')\n\n // Track when component is mounted to avoid SSR/client hydration mismatch\n useEffect(() => {\n setMounted(true)\n }, [])\n\n const setActive = useCallback(\n (isActive: boolean, viaKeyboard = false) => {\n if (isActive) {\n openedViaKeyboardRef.current = viaKeyboard\n onToggleOpen?.(true)\n } else {\n onToggleClose?.()\n }\n setActiveInternal(isActive)\n },\n [onToggleClose, onToggleOpen],\n )\n\n // /////////////////////////////////////\n // Position Calculation\n //\n // Calculates and applies popup position relative to trigger.\n // Always checks viewport bounds (for flipping), but only updates\n // styles if the calculated position differs from current position.\n // /////////////////////////////////////\n\n const updatePosition = useEffectEvent(() => {\n const trigger = triggerRef.current\n const popup = popupRef.current\n if (!trigger || !popup) {\n return\n }\n\n const triggerRect = trigger.getBoundingClientRect()\n const popupRect = popup.getBoundingClientRect()\n\n // Gap between the popup and the trigger/viewport edges (in pixels)\n const offset = 10\n\n // /////////////////////////////////////\n // Vertical Positioning\n // Calculates the `top` position in absolute page coordinates.\n // Uses `verticalAlign` prop as the preferred direction, but flips\n // to the opposite side if there's not enough viewport space.\n // /////////////////////////////////////\n\n let top: number\n let onTop = verticalAlign === 'top'\n\n if (verticalAlign === 'bottom') {\n top = triggerRect.bottom + window.scrollY + offset\n\n if (triggerRect.bottom + popupRect.height + offset > window.innerHeight) {\n // Try to flip above — only do so if there's actually enough room\n const topIfAbove = triggerRect.top + window.scrollY - popupRect.height - offset\n if (topIfAbove >= window.scrollY) {\n top = topIfAbove\n onTop = true\n }\n // else: not enough room above either — keep below and let it overflow rather than going off-screen\n }\n } else {\n top = triggerRect.top + window.scrollY - popupRect.height - offset\n\n if (triggerRect.top - popupRect.height - offset < 0) {\n top = triggerRect.bottom + window.scrollY + offset\n onTop = false\n }\n }\n\n setIsOnTop(onTop)\n\n // /////////////////////////////////////\n // Horizontal Positioning\n // Calculates the `left` position based on `horizontalAlign` prop:\n // - 'left': aligns popup's left edge with trigger's left edge\n // - 'right': aligns popup's right edge with trigger's right edge\n // - 'center': centers popup horizontally relative to trigger\n // Then clamps to keep the popup within viewport bounds.\n // /////////////////////////////////////\n\n let left =\n horizontalAlign === 'right'\n ? triggerRect.right - popupRect.width\n : horizontalAlign === 'center'\n ? triggerRect.left + triggerRect.width / 2 - popupRect.width / 2\n : triggerRect.left\n\n left = Math.max(offset, Math.min(left, window.innerWidth - popupRect.width - offset))\n\n // /////////////////////////////////////\n // Caret Positioning\n // Positions the caret arrow to point at the trigger's horizontal center.\n // Clamps between 12px from edges to prevent caret from overflowing the popup.\n // /////////////////////////////////////\n\n const triggerCenter = triggerRect.left + triggerRect.width / 2\n const caretLeft = Math.max(12, Math.min(triggerCenter - left, popupRect.width - 12))\n\n // /////////////////////////////////////\n // Apply Styles (only if changed)\n // Compares calculated position with current styles to avoid unnecessary\n // DOM updates during scroll. This prevents visual lag by relying on the absolute\n // positioning where possible (popup slightly lags behind when scrolling really fast),\n // while still allowing position changes when needed (e.g., sticky parent, viewport flip).\n // Values are rounded to match browser's CSS precision and avoid false updates.\n // /////////////////////////////////////\n\n const newTop = `${Math.round(top)}px`\n const newLeft = `${Math.round(left + window.scrollX)}px`\n const newCaretLeft = `${Math.round(caretLeft)}px`\n\n if (popup.style.top !== newTop) {\n popup.style.top = newTop\n }\n if (popup.style.left !== newLeft) {\n popup.style.left = newLeft\n }\n if (popup.style.getPropertyValue('--caret-left') !== newCaretLeft) {\n popup.style.setProperty('--caret-left', newCaretLeft)\n }\n })\n\n // /////////////////////////////////////\n // Click Outside Handler\n // Closes popup when clicking outside both the popup and trigger.\n // Distinguishes between parent and child popups:\n // - Click in child popup: parent stays open\n // - Click in parent popup: child closes\n // /////////////////////////////////////\n\n const handleClickOutside = useEffectEvent((e: MouseEvent) => {\n const target = e.target as Node\n const isOutsidePopup = !popupRef.current?.contains(target)\n const isOutsideTrigger = !triggerRef.current?.contains(target)\n\n // Check if click is inside a popup portal\n const clickedPopupContent = (target as Element).closest?.('.popup__content')\n\n // If the clicked popup contains this popup's trigger, it's a parent popup\n // and we should close. If it doesn't contain our trigger, it's a child popup\n // and we should stay open to avoid closing parent when interacting with child.\n const isInsideChildPopup =\n clickedPopupContent && !clickedPopupContent.contains(triggerRef.current)\n\n if (isOutsidePopup && isOutsideTrigger && !isInsideChildPopup) {\n setActive(false)\n }\n })\n\n // /////////////////////////////////////\n // Keyboard Navigation\n // Handles keyboard interactions when popup is open:\n // - Escape: closes popup and returns focus to trigger\n // - Tab/Shift+Tab: cycles through focusable items with wrapping\n // - ArrowUp/ArrowDown: same as Shift+Tab/Tab for menu-style navigation\n // Focus is managed manually to support elements the browser might skip.\n // /////////////////////////////////////\n\n const handleKeyDown = useEffectEvent((e: KeyboardEvent) => {\n const popup = popupRef.current\n if (!popup || !active) {\n return\n }\n\n if (e.key === 'Escape') {\n e.preventDefault()\n setActive(false)\n triggerRef.current?.querySelector<HTMLElement>('button, [tabindex=\"0\"]')?.focus()\n return\n }\n\n if (e.key === 'Tab' || e.key === 'ArrowDown' || e.key === 'ArrowUp') {\n const focusable = Array.from(popup.querySelectorAll<HTMLElement>(TABBABLE_SELECTOR))\n if (focusable.length === 0) {\n return\n }\n\n e.preventDefault()\n\n const currentIndex = focusable.findIndex((el) => el === document.activeElement)\n const goBackward = e.key === 'ArrowUp' || (e.key === 'Tab' && e.shiftKey)\n\n let nextIndex: number\n if (currentIndex === -1) {\n nextIndex = goBackward ? focusable.length - 1 : 0\n } else if (goBackward) {\n nextIndex = currentIndex === 0 ? focusable.length - 1 : currentIndex - 1\n } else {\n nextIndex = currentIndex === focusable.length - 1 ? 0 : currentIndex + 1\n }\n\n focusable[nextIndex].focus()\n }\n })\n\n // /////////////////////////////////////\n // Click Handler for Actionable Elements\n // Closes popup when buttons/links inside are clicked (includes Enter/Space activation).\n // /////////////////////////////////////\n\n const handleActionableClick = useEffectEvent((e: MouseEvent) => {\n const target = e.target as HTMLElement\n\n // Allow opting out with data-popup-prevent-close attribute on element or ancestor\n if (target.closest('[data-popup-prevent-close]')) {\n return\n }\n\n // Check if the clicked element or any ancestor is an actionable element\n const actionable = target.closest('button, a[href], [role=\"button\"], [role=\"menuitem\"]')\n if (actionable && popupRef.current?.contains(actionable)) {\n setActive(false)\n }\n })\n\n // /////////////////////////////////////\n // Effect: Setup/Teardown position and focus management\n // /////////////////////////////////////\n\n useEffect(() => {\n if (!active) {\n const popup = popupRef.current\n if (popup) {\n // Clear inline position styles so the CSS `top: -9999px` rule on\n // `.popup__hidden-content` takes effect. Without this, the inline\n // styles set during positioning would win over the CSS rule, keeping\n // portaled children (e.g. a ReactSelect menu) visually on-screen.\n popup.style.top = ''\n popup.style.left = ''\n }\n return\n }\n\n const popup = popupRef.current\n if (!popup) {\n return\n }\n\n // /////////////////////////////////////\n // Initial Position\n // Calculate and apply popup position.\n // getBoundingClientRect() forces synchronous layout.\n //\n // We call updatePosition() twice: once synchronously (so the popup\n // snaps to roughly the right place immediately rather than flashing\n // from -9999px) and once in a requestAnimationFrame, which fires\n // after the browser has finished laying out the newly-visible popup\n // content. The rAF call is the authoritative one — it catches cases\n // where the popup height wasn't stable yet during the first call\n // (e.g. ColumnSelector content rendering after hidden → visible\n // class switch), which was causing incorrect flip-to-top decisions.\n // /////////////////////////////////////\n\n updatePosition()\n const rafId = requestAnimationFrame(() => {\n updatePosition()\n })\n\n // /////////////////////////////////////\n // Focus Management\n // When opened via keyboard, autofocus the first focusable button.\n // When opened via mouse, skip autofocus to avoid unwanted highlights.\n // /////////////////////////////////////\n\n if (openedViaKeyboardRef.current) {\n // Use requestAnimationFrame to ensure DOM is ready.\n requestAnimationFrame(() => {\n const firstFocusable = popup.querySelector<HTMLElement>(TABBABLE_SELECTOR)\n firstFocusable?.focus()\n })\n }\n\n // /////////////////////////////////////\n // Event Listeners\n // - resize/scroll: recalculate position (only applies styles if changed)\n // - mousedown: detect clicks outside to close\n // - keydown: handle keyboard navigation\n // /////////////////////////////////////\n\n window.addEventListener('resize', updatePosition)\n window.addEventListener('scroll', updatePosition, { capture: true, passive: true })\n document.addEventListener('mousedown', handleClickOutside)\n document.addEventListener('keydown', handleKeyDown)\n popup.addEventListener('click', handleActionableClick)\n\n return () => {\n cancelAnimationFrame(rafId)\n window.removeEventListener('resize', updatePosition)\n window.removeEventListener('scroll', updatePosition, { capture: true })\n document.removeEventListener('mousedown', handleClickOutside)\n document.removeEventListener('keydown', handleKeyDown)\n popup.removeEventListener('click', handleActionableClick)\n }\n }, [active])\n\n useEffect(() => {\n if (forceOpen !== undefined) {\n setActive(forceOpen)\n }\n }, [forceOpen, setActive])\n\n const Trigger = (\n <PopupTrigger\n active={active}\n button={button}\n buttonType={buttonType}\n className={buttonClassName}\n disabled={disabled}\n noBackground={noBackground}\n renderButton={renderButton}\n setActive={setActive}\n size={buttonSize}\n />\n )\n\n return (\n <div className={[baseClass, className].filter(Boolean).join(' ')} id={id}>\n <div className={`${baseClass}__trigger-wrap`} ref={triggerRef}>\n {showOnHover ? (\n <div\n className={`${baseClass}__on-hover-watch`}\n onMouseEnter={() => setActive(true)}\n onMouseLeave={() => setActive(false)}\n role=\"button\"\n tabIndex={0}\n >\n {Trigger}\n </div>\n ) : (\n Trigger\n )}\n </div>\n\n {mounted\n ? // We need to make sure the popup is part of the DOM (although invisible), even if it's not active.\n // This ensures that components within the popup, like modals, do not unmount when the popup closes.\n // Otherwise, modals opened from the popup will close unexpectedly when clicking within the modal, since\n // that closes the popup due to the click outside handler.\n createPortal(\n <div\n className={\n active\n ? [\n `${baseClass}__content`,\n `${baseClass}--size-${size}`,\n isOnTop ? `${baseClass}--v-top` : `${baseClass}--v-bottom`,\n portalClassName,\n ]\n .filter(Boolean)\n .join(' ')\n : // Do not share any class names between active and disabled popups, to make sure\n // tests do not accidentally target inactive popups.\n `${baseClass}__hidden-content`\n }\n data-popup-id={id || undefined}\n data-theme={theme === 'auto' ? undefined : theme}\n ref={popupRef}\n >\n <div\n className={`${baseClass}__scroll-container${showScrollbar ? ` ${baseClass}__scroll-container--show-scrollbar` : ''}`}\n >\n {theme === 'auto' ? (\n <>\n {render?.({ close: () => setActive(false) })}\n {children}\n </>\n ) : (\n <ThemeProvider theme={theme}>\n {render?.({ close: () => setActive(false) })}\n {children}\n </ThemeProvider>\n )}\n </div>\n {caret && <div className={`${baseClass}__caret`} />}\n </div>,\n document.body,\n )\n : null}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,SAAS,MAAM;AAE3B,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAChE,SAASC,YAAY,QAAQ;AAE7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAC9B,OAAO;AACP,SAASC,YAAY,QAAQ;AAE7B,MAAMC,SAAA,GAAY;AAElB;;;AAGA,MAAMC,iBAAA,GAAoB,CACxB,WACA,yBACA,6CACA,yBACA,2BACA,cACA,oDACA,mBACA,mBACA,UACD,CACEC,GAAG,CAAEC,CAAA,IAAM,GAAGA,CAAA,uBAAwB,EACtCC,IAAI,CAAC;AA+ER;;;;;;AAMA,OAAO,MAAMC,KAAA,GAA+BC,KAAA;EAC1C,MAAM;IACJC,EAAE;IACFC,MAAM;IACNC,eAAe;IACfC,UAAU;IACVC,UAAA,GAAa,SAAS;IACtBC,KAAA,GAAQ,IAAI;IACZC,QAAQ;IACRC,SAAS;IACTC,QAAQ;IACRC,SAAS;IACTC,eAAA,GAAkB,MAAM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EqG,KAAA,EAAOA,CAAA,KAAMrF,SAAA,CAAU;UAAO,IACzC1B,QAAA;0BAGHsG,KAAA,CAACrH,aAAA;UAAc8B,KAAA,EAAOA,KAAA;qBACnBL,MAAA,GAAS;YAAEqG,KAAA,EAAOA,CAAA,KAAMrF,SAAA,CAAU;UAAO,IACzC1B,QAAA;;UAIND,KAAA,iBAASsG,IAAA,CAAC;QAAIpG,SAAA,EAAW,GAAGd,SAAA;;QAE/BiG,QAAA,CAAS4B,IAAI,IAEf;;AAGV","ignoreList":[]}
|
|
@@ -44,10 +44,6 @@
|
|
|
44
44
|
color: var(--color-text-tertiary);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
.rs__menu-notice {
|
|
48
|
-
padding: 0.625rem 0.75rem;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
47
|
.rs__indicator {
|
|
52
48
|
padding: 0 0.25rem;
|
|
53
49
|
cursor: pointer;
|
|
@@ -72,54 +68,6 @@
|
|
|
72
68
|
padding: 0;
|
|
73
69
|
}
|
|
74
70
|
|
|
75
|
-
.rs__menu {
|
|
76
|
-
z-index: 4;
|
|
77
|
-
border-radius: var(--radius-medium);
|
|
78
|
-
box-shadow: var(--elevation-400-menu-panel);
|
|
79
|
-
background: var(--color-bg);
|
|
80
|
-
overflow: hidden;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.rs__menu--placement-bottom {
|
|
84
|
-
margin-top: var(--spacer-1);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.rs__menu--placement-top {
|
|
88
|
-
margin-bottom: var(--spacer-1);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.rs__menu-list {
|
|
92
|
-
max-height: calc(var(--spacer-6) * 5);
|
|
93
|
-
overflow-y: auto;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.rs__group-heading {
|
|
97
|
-
color: var(--color-text-tertiary);
|
|
98
|
-
padding: var(--spacer-2-5) var(--spacer-3) var(--spacer-1);
|
|
99
|
-
font-family: var(--text-body-medium-font-family);
|
|
100
|
-
font-size: var(--text-body-medium-font-size);
|
|
101
|
-
font-weight: var(--text-body-medium-font-weight);
|
|
102
|
-
line-height: var(--text-body-medium-line-height);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.rs__option {
|
|
106
|
-
font-family: var(--text-body-medium-font-family);
|
|
107
|
-
font-size: var(--text-body-medium-font-size);
|
|
108
|
-
font-weight: var(--text-body-medium-font-weight);
|
|
109
|
-
line-height: var(--text-body-medium-line-height);
|
|
110
|
-
padding-inline: var(--spacer-3) var(--spacer-1);
|
|
111
|
-
padding-block: var(--spacer-2);
|
|
112
|
-
color: var(--color-text);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.rs__option--is-focused {
|
|
116
|
-
background-color: var(--color-bg-secondary);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.rs__option--is-selected {
|
|
120
|
-
background-color: var(--color-bg-selected);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
71
|
&.rs--is-disabled .rs__control {
|
|
124
72
|
background: var(--field-color-bg-disabled);
|
|
125
73
|
border-color: var(--field-color-border-disabled);
|
|
@@ -133,6 +81,59 @@
|
|
|
133
81
|
}
|
|
134
82
|
}
|
|
135
83
|
|
|
84
|
+
/* Menu rules are top-level so they apply when the menu is portaled to document.body */
|
|
85
|
+
.rs__menu-notice {
|
|
86
|
+
padding: 0.625rem 0.75rem;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.rs__menu {
|
|
90
|
+
z-index: 4;
|
|
91
|
+
border-radius: var(--radius-medium);
|
|
92
|
+
box-shadow: var(--elevation-400-menu-panel);
|
|
93
|
+
background: var(--color-bg);
|
|
94
|
+
/* overflow: clip; */
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.rs__menu--placement-bottom {
|
|
98
|
+
margin-top: var(--spacer-1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.rs__menu--placement-top {
|
|
102
|
+
margin-bottom: var(--spacer-1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.rs__menu-list {
|
|
106
|
+
max-height: calc(var(--spacer-6) * 5);
|
|
107
|
+
overflow-y: auto;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.rs__group-heading {
|
|
111
|
+
color: var(--color-text-tertiary);
|
|
112
|
+
padding: var(--spacer-2-5) var(--spacer-3) var(--spacer-1);
|
|
113
|
+
font-family: var(--text-body-medium-font-family);
|
|
114
|
+
font-size: var(--text-body-medium-font-size);
|
|
115
|
+
font-weight: var(--text-body-medium-font-weight);
|
|
116
|
+
line-height: var(--text-body-medium-line-height);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.rs__option {
|
|
120
|
+
font-family: var(--text-body-medium-font-family);
|
|
121
|
+
font-size: var(--text-body-medium-font-size);
|
|
122
|
+
font-weight: var(--text-body-medium-font-weight);
|
|
123
|
+
line-height: var(--text-body-medium-line-height);
|
|
124
|
+
padding-inline: var(--spacer-3) var(--spacer-1);
|
|
125
|
+
padding-block: var(--spacer-2);
|
|
126
|
+
color: var(--color-text);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.rs__option--is-focused {
|
|
130
|
+
background-color: var(--color-bg-secondary);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.rs__option--is-selected {
|
|
134
|
+
background-color: var(--color-bg-selected);
|
|
135
|
+
}
|
|
136
|
+
|
|
136
137
|
.react-select--error {
|
|
137
138
|
div.rs__control {
|
|
138
139
|
border: var(--stroke-width-small) solid var(--field-color-border-error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/ReactSelect/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/ReactSelect/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAA2B,MAAM,OAAO,CAAA;AAI/C,OAAO,KAAK,EAAU,uBAAuB,EAAE,MAAM,YAAY,CAAA;AACjE,YAAY,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAexC,OAAO,aAAa,CAAA;AA0RpB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAQzD,CAAA"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
import { arrayMove } from '@dnd-kit/sortable';
|
|
5
6
|
import { getTranslation } from '@payloadcms/translations';
|
|
6
7
|
import React, { useEffect, useId } from 'react';
|
|
7
|
-
import Select from 'react-select';
|
|
8
|
+
import Select, { components as rsComponents } from 'react-select';
|
|
8
9
|
import CreatableSelect from 'react-select/creatable';
|
|
10
|
+
import { useTheme } from '../../providers/Theme/index.js';
|
|
9
11
|
import { useTranslation } from '../../providers/Translation/index.js';
|
|
10
12
|
import { DraggableSortable } from '../DraggableSortable/index.js';
|
|
11
13
|
import { ShimmerEffect } from '../ShimmerEffect/index.js';
|
|
@@ -23,6 +25,32 @@ const createOption = label => ({
|
|
|
23
25
|
label,
|
|
24
26
|
value: label
|
|
25
27
|
});
|
|
28
|
+
// Propagates the nearest scoped theme (via ThemeProvider) into the portal div,
|
|
29
|
+
// falling back to the global theme. Ensures dropdown menus portaled to
|
|
30
|
+
// document.body inherit the correct theme (e.g. dark Popup).
|
|
31
|
+
function ThemedMenuPortal(props) {
|
|
32
|
+
const $ = _c(3);
|
|
33
|
+
const {
|
|
34
|
+
theme
|
|
35
|
+
} = useTheme();
|
|
36
|
+
const menuPortalTheme = props.selectProps?.customProps?.menuPortalTheme;
|
|
37
|
+
const t0 = menuPortalTheme ?? theme;
|
|
38
|
+
let t1;
|
|
39
|
+
if ($[0] !== props || $[1] !== t0) {
|
|
40
|
+
t1 = _jsx(rsComponents.MenuPortal, {
|
|
41
|
+
...props,
|
|
42
|
+
innerProps: {
|
|
43
|
+
"data-theme": t0
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
$[0] = props;
|
|
47
|
+
$[1] = t0;
|
|
48
|
+
$[2] = t1;
|
|
49
|
+
} else {
|
|
50
|
+
t1 = $[2];
|
|
51
|
+
}
|
|
52
|
+
return t1;
|
|
53
|
+
}
|
|
26
54
|
const SelectAdapter = props => {
|
|
27
55
|
const {
|
|
28
56
|
i18n,
|
|
@@ -37,6 +65,7 @@ const SelectAdapter = props => {
|
|
|
37
65
|
}, []);
|
|
38
66
|
const {
|
|
39
67
|
className,
|
|
68
|
+
classNames: externalClassNames,
|
|
40
69
|
components,
|
|
41
70
|
customProps,
|
|
42
71
|
disabled = false,
|
|
@@ -46,6 +75,8 @@ const SelectAdapter = props => {
|
|
|
46
75
|
isCreatable,
|
|
47
76
|
isLoading,
|
|
48
77
|
isSearchable = true,
|
|
78
|
+
menuPortalTarget: menuPortalTargetProp,
|
|
79
|
+
menuPosition: menuPositionProp,
|
|
49
80
|
noOptionsMessage = () => t('general:noOptions'),
|
|
50
81
|
numberOnly = false,
|
|
51
82
|
onChange,
|
|
@@ -57,6 +88,8 @@ const SelectAdapter = props => {
|
|
|
57
88
|
styles: externalStyles,
|
|
58
89
|
value
|
|
59
90
|
} = props;
|
|
91
|
+
const menuPortalTarget = menuPortalTargetProp === undefined ? typeof document !== 'undefined' ? document.body : null : menuPortalTargetProp;
|
|
92
|
+
const menuPosition = menuPositionProp ?? (menuPortalTarget ? 'fixed' : undefined);
|
|
60
93
|
const loadingMessage = () => t('general:loading') + '...';
|
|
61
94
|
const classes = [className, 'react-select', showError && 'react-select--error'].filter(Boolean).join(' ');
|
|
62
95
|
const styles = {
|
|
@@ -68,16 +101,26 @@ const SelectAdapter = props => {
|
|
|
68
101
|
zIndex: undefined,
|
|
69
102
|
...externalStyles?.menu?.(rsStyles, state)
|
|
70
103
|
}),
|
|
104
|
+
// When portaling to document.body, the portal container needs an explicit
|
|
105
|
+
// z-index so the menu appears above drawers and dialogs. unstyled={true}
|
|
106
|
+
// strips react-select's default zIndex:9999 from the portal container.
|
|
107
|
+
...(menuPortalTarget && {
|
|
108
|
+
menuPortal: (rsStyles_0, state_0) => ({
|
|
109
|
+
...rsStyles_0,
|
|
110
|
+
zIndex: 9999,
|
|
111
|
+
...externalStyles?.menuPortal?.(rsStyles_0, state_0)
|
|
112
|
+
})
|
|
113
|
+
}),
|
|
71
114
|
// Remove the default react-select min-height so our CSS can control it
|
|
72
|
-
control: (
|
|
73
|
-
...
|
|
115
|
+
control: (rsStyles_1, state_1) => ({
|
|
116
|
+
...rsStyles_1,
|
|
74
117
|
minHeight: undefined,
|
|
75
|
-
...externalStyles?.control?.(
|
|
118
|
+
...externalStyles?.control?.(rsStyles_1, state_1)
|
|
76
119
|
}),
|
|
77
120
|
// Allow external option styles to override emotion defaults
|
|
78
|
-
option: (
|
|
79
|
-
...
|
|
80
|
-
...externalStyles?.option?.(
|
|
121
|
+
option: (rsStyles_2, state_2) => ({
|
|
122
|
+
...rsStyles_2,
|
|
123
|
+
...externalStyles?.option?.(rsStyles_2, state_2)
|
|
81
124
|
})
|
|
82
125
|
};
|
|
83
126
|
if (!hasMounted) {
|
|
@@ -94,13 +137,19 @@ const SelectAdapter = props => {
|
|
|
94
137
|
className: classes,
|
|
95
138
|
classNamePrefix: "rs",
|
|
96
139
|
classNames: {
|
|
97
|
-
|
|
140
|
+
...externalClassNames,
|
|
141
|
+
menu: state_3 => {
|
|
142
|
+
const placement = state_3.placement ? `rs__menu--placement-${state_3.placement}` : '';
|
|
143
|
+
const external = externalClassNames?.menu?.(state_3) ?? '';
|
|
144
|
+
return [placement, external].filter(Boolean).join(' ');
|
|
145
|
+
}
|
|
98
146
|
},
|
|
99
147
|
components: {
|
|
100
148
|
ClearIndicator,
|
|
101
149
|
Control,
|
|
102
150
|
DropdownIndicator,
|
|
103
151
|
Input,
|
|
152
|
+
MenuPortal: ThemedMenuPortal,
|
|
104
153
|
MultiValue,
|
|
105
154
|
MultiValueLabel,
|
|
106
155
|
MultiValueRemove,
|
|
@@ -116,6 +165,8 @@ const SelectAdapter = props => {
|
|
|
116
165
|
isSearchable: isSearchable,
|
|
117
166
|
loadingMessage: loadingMessage,
|
|
118
167
|
menuPlacement: "auto",
|
|
168
|
+
menuPortalTarget: menuPortalTarget,
|
|
169
|
+
menuPosition: menuPosition,
|
|
119
170
|
noOptionsMessage: noOptionsMessage,
|
|
120
171
|
onChange: onChange,
|
|
121
172
|
onMenuClose: onMenuClose,
|
|
@@ -164,13 +215,19 @@ const SelectAdapter = props => {
|
|
|
164
215
|
className: classes,
|
|
165
216
|
classNamePrefix: "rs",
|
|
166
217
|
classNames: {
|
|
167
|
-
|
|
218
|
+
...externalClassNames,
|
|
219
|
+
menu: state_4 => {
|
|
220
|
+
const placement_0 = state_4.placement ? `rs__menu--placement-${state_4.placement}` : '';
|
|
221
|
+
const external_0 = externalClassNames?.menu?.(state_4) ?? '';
|
|
222
|
+
return [placement_0, external_0].filter(Boolean).join(' ');
|
|
223
|
+
}
|
|
168
224
|
},
|
|
169
225
|
components: {
|
|
170
226
|
ClearIndicator,
|
|
171
227
|
Control,
|
|
172
228
|
DropdownIndicator,
|
|
173
229
|
Input,
|
|
230
|
+
MenuPortal: ThemedMenuPortal,
|
|
174
231
|
MultiValue,
|
|
175
232
|
MultiValueLabel,
|
|
176
233
|
MultiValueRemove,
|
|
@@ -186,6 +243,8 @@ const SelectAdapter = props => {
|
|
|
186
243
|
isSearchable: isSearchable,
|
|
187
244
|
loadingMessage: loadingMessage,
|
|
188
245
|
menuPlacement: "auto",
|
|
246
|
+
menuPortalTarget: menuPortalTarget,
|
|
247
|
+
menuPosition: menuPosition,
|
|
189
248
|
noOptionsMessage: noOptionsMessage,
|
|
190
249
|
onChange: onChange,
|
|
191
250
|
onInputChange: newValue => setInputValue(newValue),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["arrayMove","getTranslation","React","useEffect","useId","Select","CreatableSelect","useTranslation","DraggableSortable","ShimmerEffect","ClearIndicator","Control","DropdownIndicator","Input","generateMultiValueDraggableID","MultiValue","MultiValueLabel","MultiValueRemove","SingleValue","ValueContainer","createOption","label","value","SelectAdapter","props","i18n","t","inputValue","setInputValue","useState","uuid","hasMounted","setHasMounted","className","components","customProps","disabled","filterOption","undefined","getOptionValue","isClearable","isCreatable","isLoading","isSearchable","noOptionsMessage","numberOnly","onChange","onMenuClose","onMenuOpen","options","placeholder","showError","styles","externalStyles","loadingMessage","classes","filter","Boolean","join","menu","rsStyles","state","zIndex","control","minHeight","option","_jsx","height","captureMenuScroll","classNamePrefix","classNames","placement","instanceId","isDisabled","menuPlacement","unstyled","handleKeyDown","event","acceptableKeys","isNumber","test","key","isActionKey","includes","preventDefault","trim","nativeEvent","isComposing","onInputChange","newValue","onKeyDown","SortableSelect","draggableIDs","Array","isArray","map","optionValue","ids","onDragEnd","moveFromIndex","moveToIndex","sorted","ReactSelect","isMulti","isSortable"],"sources":["../../../src/elements/ReactSelect/index.tsx"],"sourcesContent":["'use client'\nimport type { KeyboardEventHandler } from 'react'\n\nimport { arrayMove } from '@dnd-kit/sortable'\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useEffect, useId } from 'react'\nimport Select, { type StylesConfig } from 'react-select'\nimport CreatableSelect from 'react-select/creatable'\n\nimport type { Option, ReactSelectAdapterProps } from './types.js'\nexport type { Option } from './types.js'\n\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { DraggableSortable } from '../DraggableSortable/index.js'\nimport { ShimmerEffect } from '../ShimmerEffect/index.js'\nimport { ClearIndicator } from './ClearIndicator/index.js'\nimport { Control } from './Control/index.js'\nimport { DropdownIndicator } from './DropdownIndicator/index.js'\nimport { Input } from './Input/index.js'\nimport { generateMultiValueDraggableID, MultiValue } from './MultiValue/index.js'\nimport { MultiValueLabel } from './MultiValueLabel/index.js'\nimport { MultiValueRemove } from './MultiValueRemove/index.js'\nimport { SingleValue } from './SingleValue/index.js'\nimport { ValueContainer } from './ValueContainer/index.js'\nimport './index.css'\n\nconst createOption = (label: string) => ({\n label,\n value: label,\n})\n\nconst SelectAdapter: React.FC<ReactSelectAdapterProps> = (props) => {\n const { i18n, t } = useTranslation()\n const [inputValue, setInputValue] = React.useState('') // for creatable select\n const uuid = useId()\n const [hasMounted, setHasMounted] = React.useState(false)\n\n useEffect(() => {\n setHasMounted(true)\n }, [])\n\n const {\n className,\n components,\n customProps,\n disabled = false,\n filterOption = undefined,\n getOptionValue,\n isClearable = true,\n isCreatable,\n isLoading,\n isSearchable = true,\n noOptionsMessage = () => t('general:noOptions'),\n numberOnly = false,\n onChange,\n onMenuClose,\n onMenuOpen,\n options,\n placeholder = t('general:selectValue'),\n showError,\n styles: externalStyles,\n value,\n } = props\n\n const loadingMessage = () => t('general:loading') + '...'\n\n const classes = [className, 'react-select', showError && 'react-select--error']\n .filter(Boolean)\n .join(' ')\n\n const styles: StylesConfig<Option> = {\n // Remove the default react-select z-index from the menu so that our custom\n // z-index in the \"payload-default\" css layer can take effect, in such a way\n // that end users can easily override it as with other styles.\n menu: (rsStyles, state) => ({\n ...rsStyles,\n zIndex: undefined,\n ...externalStyles?.menu?.(rsStyles, state),\n }),\n // Remove the default react-select min-height so our CSS can control it\n control: (rsStyles, state) => ({\n ...rsStyles,\n minHeight: undefined,\n ...externalStyles?.control?.(rsStyles, state),\n }),\n // Allow external option styles to override emotion defaults\n option: (rsStyles, state) => ({\n ...rsStyles,\n ...externalStyles?.option?.(rsStyles, state),\n }),\n }\n\n if (!hasMounted) {\n return <ShimmerEffect height=\"var(--field-min-height)\" />\n }\n\n if (!isCreatable) {\n return (\n <Select\n captureMenuScroll\n customProps={customProps}\n isLoading={isLoading}\n {...props}\n className={classes}\n classNamePrefix=\"rs\"\n classNames={{\n menu: (state) => (state.placement ? `rs__menu--placement-${state.placement}` : ''),\n }}\n components={{\n ClearIndicator,\n Control,\n DropdownIndicator,\n Input,\n MultiValue,\n MultiValueLabel,\n MultiValueRemove,\n SingleValue,\n ValueContainer,\n ...components,\n }}\n filterOption={filterOption}\n getOptionValue={getOptionValue}\n instanceId={uuid}\n isClearable={isClearable}\n isDisabled={disabled}\n isSearchable={isSearchable}\n loadingMessage={loadingMessage}\n menuPlacement=\"auto\"\n noOptionsMessage={noOptionsMessage}\n onChange={onChange}\n onMenuClose={onMenuClose}\n onMenuOpen={onMenuOpen}\n options={options}\n placeholder={getTranslation(placeholder, i18n)}\n styles={styles}\n unstyled={true}\n value={value}\n />\n )\n }\n const handleKeyDown: KeyboardEventHandler = (event) => {\n if (numberOnly === true) {\n const acceptableKeys = [\n 'Tab',\n 'Escape',\n 'Backspace',\n 'Enter',\n 'ArrowRight',\n 'ArrowLeft',\n 'ArrowUp',\n 'ArrowDown',\n ]\n const isNumber = !/\\D/.test(event.key)\n const isActionKey = acceptableKeys.includes(event.key)\n if (!isNumber && !isActionKey) {\n event.preventDefault()\n return\n }\n }\n if (!value || !inputValue || inputValue.trim() === '') {\n return\n }\n if (filterOption && !filterOption(null, inputValue)) {\n return\n }\n if (event.nativeEvent.isComposing) {\n return\n }\n switch (event.key) {\n case 'Enter':\n case 'Tab':\n onChange([...(value as Option[]), createOption(inputValue)])\n setInputValue('')\n event.preventDefault()\n break\n default:\n break\n }\n }\n\n return (\n <CreatableSelect\n captureMenuScroll\n isLoading={isLoading}\n {...props}\n className={classes}\n classNamePrefix=\"rs\"\n classNames={{\n menu: (state) => (state.placement ? `rs__menu--placement-${state.placement}` : ''),\n }}\n components={{\n ClearIndicator,\n Control,\n DropdownIndicator,\n Input,\n MultiValue,\n MultiValueLabel,\n MultiValueRemove,\n SingleValue,\n ValueContainer,\n ...components,\n }}\n filterOption={filterOption}\n inputValue={inputValue}\n instanceId={uuid}\n isClearable={isClearable}\n isDisabled={disabled}\n isSearchable={isSearchable}\n loadingMessage={loadingMessage}\n menuPlacement=\"auto\"\n noOptionsMessage={noOptionsMessage}\n onChange={onChange}\n onInputChange={(newValue) => setInputValue(newValue)}\n onKeyDown={handleKeyDown}\n onMenuClose={onMenuClose}\n onMenuOpen={onMenuOpen}\n options={options}\n placeholder={getTranslation(placeholder, i18n)}\n styles={styles}\n unstyled={true}\n value={value}\n />\n )\n}\n\nconst SortableSelect: React.FC<ReactSelectAdapterProps> = (props) => {\n const { getOptionValue, onChange, value } = props\n\n let draggableIDs: string[] = []\n if (value) {\n draggableIDs = (Array.isArray(value) ? value : [value]).map((optionValue) => {\n return generateMultiValueDraggableID(optionValue, getOptionValue)\n })\n }\n\n return (\n <DraggableSortable\n className=\"react-select-container\"\n ids={draggableIDs}\n onDragEnd={({ moveFromIndex, moveToIndex }) => {\n let sorted = value\n if (value && Array.isArray(value)) {\n sorted = arrayMove(value, moveFromIndex, moveToIndex)\n }\n onChange(sorted)\n }}\n >\n <SelectAdapter {...props} />\n </DraggableSortable>\n )\n}\n\nexport const ReactSelect: React.FC<ReactSelectAdapterProps> = (props) => {\n const { isMulti, isSortable } = props\n\n if (isMulti && isSortable) {\n return <SortableSelect {...props} />\n }\n\n return <SelectAdapter {...props} />\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,SAAS,EAAEC,KAAK,QAAQ;AACxC,OAAOC,MAAA,MAAmC;AAC1C,OAAOC,eAAA,MAAqB;AAK5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,OAAO,QAAQ;AACxB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,KAAK,QAAQ;AACtB,SAASC,6BAA6B,EAAEC,UAAU,QAAQ;AAC1D,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAEP,MAAMC,YAAA,GAAgBC,KAAA,KAAmB;EAC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A,GAASrG,SAAA,CAAUsB,KAAA,EAAO6E,aAAA,EAAeC,WAAA;MAC3C;MACAtD,QAAA,CAASuD,MAAA;IACX;cAEA,aAAAnC,IAAA,CAAC3C,aAAA;MAAe,GAAGC;;;AAGzB;AAEA,OAAO,MAAM8E,WAAA,GAAkD9E,KAAA;EAC7D,MAAM;IAAE+E,OAAO;IAAEC;EAAU,CAAE,GAAGhF,KAAA;EAEhC,IAAI+E,OAAA,IAAWC,UAAA,EAAY;IACzB,oBAAOtC,IAAA,CAACyB,cAAA;MAAgB,GAAGnE;;EAC7B;EAEA,oBAAO0C,IAAA,CAAC3C,aAAA;IAAe,GAAGC;;AAC5B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","arrayMove","getTranslation","React","useEffect","useId","Select","components","rsComponents","CreatableSelect","useTheme","useTranslation","DraggableSortable","ShimmerEffect","ClearIndicator","Control","DropdownIndicator","Input","generateMultiValueDraggableID","MultiValue","MultiValueLabel","MultiValueRemove","SingleValue","ValueContainer","createOption","label","value","ThemedMenuPortal","props","$","theme","menuPortalTheme","selectProps","customProps","t0","t1","_jsx","MenuPortal","innerProps","SelectAdapter","i18n","t","inputValue","setInputValue","useState","uuid","hasMounted","setHasMounted","className","classNames","externalClassNames","disabled","filterOption","undefined","getOptionValue","isClearable","isCreatable","isLoading","isSearchable","menuPortalTarget","menuPortalTargetProp","menuPosition","menuPositionProp","noOptionsMessage","numberOnly","onChange","onMenuClose","onMenuOpen","options","placeholder","showError","styles","externalStyles","document","body","loadingMessage","classes","filter","Boolean","join","menu","rsStyles","state","zIndex","menuPortal","control","minHeight","option","height","captureMenuScroll","classNamePrefix","placement","external","instanceId","isDisabled","menuPlacement","unstyled","handleKeyDown","event","acceptableKeys","isNumber","test","key","isActionKey","includes","preventDefault","trim","nativeEvent","isComposing","onInputChange","newValue","onKeyDown","SortableSelect","draggableIDs","Array","isArray","map","optionValue","ids","onDragEnd","moveFromIndex","moveToIndex","sorted","ReactSelect","isMulti","isSortable"],"sources":["../../../src/elements/ReactSelect/index.tsx"],"sourcesContent":["'use client'\nimport type { JSX, KeyboardEventHandler } from 'react'\nimport type { GroupBase, MenuProps, StylesConfig } from 'react-select'\n\nimport { arrayMove } from '@dnd-kit/sortable'\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useEffect, useId } from 'react'\nimport Select, { components as rsComponents } from 'react-select'\nimport CreatableSelect from 'react-select/creatable'\n\nimport type { Option, ReactSelectAdapterProps } from './types.js'\nexport type { Option } from './types.js'\n\nimport { useTheme } from '../../providers/Theme/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { DraggableSortable } from '../DraggableSortable/index.js'\nimport { ShimmerEffect } from '../ShimmerEffect/index.js'\nimport { ClearIndicator } from './ClearIndicator/index.js'\nimport { Control } from './Control/index.js'\nimport { DropdownIndicator } from './DropdownIndicator/index.js'\nimport { Input } from './Input/index.js'\nimport { generateMultiValueDraggableID, MultiValue } from './MultiValue/index.js'\nimport { MultiValueLabel } from './MultiValueLabel/index.js'\nimport { MultiValueRemove } from './MultiValueRemove/index.js'\nimport { SingleValue } from './SingleValue/index.js'\nimport { ValueContainer } from './ValueContainer/index.js'\nimport './index.css'\n\nconst createOption = (label: string) => ({\n label,\n value: label,\n})\n\n// Propagates the nearest scoped theme (via ThemeProvider) into the portal div,\n// falling back to the global theme. Ensures dropdown menus portaled to\n// document.body inherit the correct theme (e.g. dark Popup).\nfunction ThemedMenuPortal<Opt, IsMulti extends boolean, Group extends GroupBase<Opt>>(\n props: React.ComponentProps<typeof rsComponents.MenuPortal<Opt, IsMulti, Group>>,\n) {\n const { theme } = useTheme()\n const menuPortalTheme = (props.selectProps as any)?.customProps?.menuPortalTheme\n return (\n <rsComponents.MenuPortal\n {...props}\n innerProps={{ 'data-theme': menuPortalTheme ?? theme } as JSX.IntrinsicElements['div']}\n />\n )\n}\n\nconst SelectAdapter: React.FC<ReactSelectAdapterProps> = (props) => {\n const { i18n, t } = useTranslation()\n const [inputValue, setInputValue] = React.useState('') // for creatable select\n const uuid = useId()\n const [hasMounted, setHasMounted] = React.useState(false)\n\n useEffect(() => {\n setHasMounted(true)\n }, [])\n\n const {\n className,\n classNames: externalClassNames,\n components,\n customProps,\n disabled = false,\n filterOption = undefined,\n getOptionValue,\n isClearable = true,\n isCreatable,\n isLoading,\n isSearchable = true,\n menuPortalTarget: menuPortalTargetProp,\n menuPosition: menuPositionProp,\n noOptionsMessage = () => t('general:noOptions'),\n numberOnly = false,\n onChange,\n onMenuClose,\n onMenuOpen,\n options,\n placeholder = t('general:selectValue'),\n showError,\n styles: externalStyles,\n value,\n } = props\n\n const menuPortalTarget =\n menuPortalTargetProp === undefined\n ? typeof document !== 'undefined'\n ? document.body\n : null\n : menuPortalTargetProp\n\n const menuPosition = menuPositionProp ?? (menuPortalTarget ? 'fixed' : undefined)\n\n const loadingMessage = () => t('general:loading') + '...'\n\n const classes = [className, 'react-select', showError && 'react-select--error']\n .filter(Boolean)\n .join(' ')\n\n const styles: StylesConfig<Option> = {\n // Remove the default react-select z-index from the menu so that our custom\n // z-index in the \"payload-default\" css layer can take effect, in such a way\n // that end users can easily override it as with other styles.\n menu: (rsStyles, state) => ({\n ...rsStyles,\n zIndex: undefined,\n ...externalStyles?.menu?.(rsStyles, state),\n }),\n // When portaling to document.body, the portal container needs an explicit\n // z-index so the menu appears above drawers and dialogs. unstyled={true}\n // strips react-select's default zIndex:9999 from the portal container.\n ...(menuPortalTarget && {\n menuPortal: (rsStyles, state) => ({\n ...rsStyles,\n zIndex: 9999,\n ...externalStyles?.menuPortal?.(rsStyles, state),\n }),\n }),\n // Remove the default react-select min-height so our CSS can control it\n control: (rsStyles, state) => ({\n ...rsStyles,\n minHeight: undefined,\n ...externalStyles?.control?.(rsStyles, state),\n }),\n // Allow external option styles to override emotion defaults\n option: (rsStyles, state) => ({\n ...rsStyles,\n ...externalStyles?.option?.(rsStyles, state),\n }),\n }\n\n if (!hasMounted) {\n return <ShimmerEffect height=\"var(--field-min-height)\" />\n }\n\n if (!isCreatable) {\n return (\n <Select<Option, boolean, GroupBase<Option>>\n captureMenuScroll\n customProps={customProps}\n isLoading={isLoading}\n {...props}\n className={classes}\n classNamePrefix=\"rs\"\n classNames={{\n ...externalClassNames,\n menu: (state: MenuProps<Option, boolean, GroupBase<Option>>) => {\n const placement = state.placement ? `rs__menu--placement-${state.placement}` : ''\n const external = externalClassNames?.menu?.(state) ?? ''\n return [placement, external].filter(Boolean).join(' ')\n },\n }}\n components={{\n ClearIndicator,\n Control,\n DropdownIndicator,\n Input,\n MenuPortal: ThemedMenuPortal,\n MultiValue,\n MultiValueLabel,\n MultiValueRemove,\n SingleValue,\n ValueContainer,\n ...components,\n }}\n filterOption={filterOption}\n getOptionValue={getOptionValue}\n instanceId={uuid}\n isClearable={isClearable}\n isDisabled={disabled}\n isSearchable={isSearchable}\n loadingMessage={loadingMessage}\n menuPlacement=\"auto\"\n menuPortalTarget={menuPortalTarget}\n menuPosition={menuPosition}\n noOptionsMessage={noOptionsMessage}\n onChange={onChange}\n onMenuClose={onMenuClose}\n onMenuOpen={onMenuOpen}\n options={options}\n placeholder={getTranslation(placeholder, i18n)}\n styles={styles}\n unstyled={true}\n value={value}\n />\n )\n }\n const handleKeyDown: KeyboardEventHandler = (event) => {\n if (numberOnly === true) {\n const acceptableKeys = [\n 'Tab',\n 'Escape',\n 'Backspace',\n 'Enter',\n 'ArrowRight',\n 'ArrowLeft',\n 'ArrowUp',\n 'ArrowDown',\n ]\n const isNumber = !/\\D/.test(event.key)\n const isActionKey = acceptableKeys.includes(event.key)\n if (!isNumber && !isActionKey) {\n event.preventDefault()\n return\n }\n }\n if (!value || !inputValue || inputValue.trim() === '') {\n return\n }\n if (filterOption && !filterOption(null, inputValue)) {\n return\n }\n if (event.nativeEvent.isComposing) {\n return\n }\n switch (event.key) {\n case 'Enter':\n case 'Tab':\n onChange([...(value as Option[]), createOption(inputValue)])\n setInputValue('')\n event.preventDefault()\n break\n default:\n break\n }\n }\n\n return (\n <CreatableSelect<Option, boolean, GroupBase<Option>>\n captureMenuScroll\n isLoading={isLoading}\n {...props}\n className={classes}\n classNamePrefix=\"rs\"\n classNames={{\n ...externalClassNames,\n menu: (state: MenuProps<Option, boolean, GroupBase<Option>>) => {\n const placement = state.placement ? `rs__menu--placement-${state.placement}` : ''\n const external = externalClassNames?.menu?.(state) ?? ''\n return [placement, external].filter(Boolean).join(' ')\n },\n }}\n components={{\n ClearIndicator,\n Control,\n DropdownIndicator,\n Input,\n MenuPortal: ThemedMenuPortal,\n MultiValue,\n MultiValueLabel,\n MultiValueRemove,\n SingleValue,\n ValueContainer,\n ...components,\n }}\n filterOption={filterOption}\n inputValue={inputValue}\n instanceId={uuid}\n isClearable={isClearable}\n isDisabled={disabled}\n isSearchable={isSearchable}\n loadingMessage={loadingMessage}\n menuPlacement=\"auto\"\n menuPortalTarget={menuPortalTarget}\n menuPosition={menuPosition}\n noOptionsMessage={noOptionsMessage}\n onChange={onChange}\n onInputChange={(newValue) => setInputValue(newValue)}\n onKeyDown={handleKeyDown}\n onMenuClose={onMenuClose}\n onMenuOpen={onMenuOpen}\n options={options}\n placeholder={getTranslation(placeholder, i18n)}\n styles={styles}\n unstyled={true}\n value={value}\n />\n )\n}\n\nconst SortableSelect: React.FC<ReactSelectAdapterProps> = (props) => {\n const { getOptionValue, onChange, value } = props\n\n let draggableIDs: string[] = []\n if (value) {\n draggableIDs = (Array.isArray(value) ? value : [value]).map((optionValue) => {\n return generateMultiValueDraggableID(optionValue, getOptionValue)\n })\n }\n\n return (\n <DraggableSortable\n className=\"react-select-container\"\n ids={draggableIDs}\n onDragEnd={({ moveFromIndex, moveToIndex }) => {\n let sorted = value\n if (value && Array.isArray(value)) {\n sorted = arrayMove(value, moveFromIndex, moveToIndex)\n }\n onChange(sorted)\n }}\n >\n <SelectAdapter {...props} />\n </DraggableSortable>\n )\n}\n\nexport const ReactSelect: React.FC<ReactSelectAdapterProps> = (props) => {\n const { isMulti, isSortable } = props\n\n if (isMul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