@charcoal-ui/react 6.0.0-rc.9 → 6.0.1
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/_lib/compat.d.ts.map +1 -1
- package/dist/_lib/createDivComponent.cjs +0 -1
- package/dist/_lib/createDivComponent.cjs.map +1 -1
- package/dist/_lib/createDivComponent.d.ts +1 -1
- package/dist/_lib/createDivComponent.js.map +1 -1
- package/dist/_lib/index.cjs.map +1 -1
- package/dist/_lib/index.js.map +1 -1
- package/dist/_lib/useClassNames.cjs +0 -1
- package/dist/_lib/useClassNames.cjs.map +1 -1
- package/dist/_lib/useClassNames.js.map +1 -1
- package/dist/_lib/useForwardedRef.cjs +1 -1
- package/dist/_lib/useForwardedRef.cjs.map +1 -1
- package/dist/_lib/useForwardedRef.js.map +1 -1
- package/dist/_lib/useIsomorphicLayoutEffect.cjs +0 -1
- package/dist/_lib/useIsomorphicLayoutEffect.cjs.map +1 -1
- package/dist/_lib/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/_lib/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/dist/_lib/useIsomorphicLayoutEffect.js.map +1 -1
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index2.cjs +1 -1
- package/dist/components/Button/index2.cjs.map +1 -1
- package/dist/components/Button/index2.js.map +1 -1
- package/dist/components/Carousel/CarouselItem.cjs +0 -1
- package/dist/components/Carousel/CarouselItem.cjs.map +1 -1
- package/dist/components/Carousel/CarouselItem.d.ts.map +1 -1
- package/dist/components/Carousel/CarouselItem.js.map +1 -1
- package/dist/components/Carousel/carouselStore.cjs.map +1 -1
- package/dist/components/Carousel/carouselStore.js.map +1 -1
- package/dist/components/Carousel/index.d.ts +1 -1
- package/dist/components/Carousel/index.d.ts.map +1 -1
- package/dist/components/Carousel/index2.cjs +0 -1
- package/dist/components/Carousel/index2.cjs.map +1 -1
- package/dist/components/Carousel/index2.js.map +1 -1
- package/dist/components/Carousel/intersectionObserver.cjs.map +1 -1
- package/dist/components/Carousel/intersectionObserver.js.map +1 -1
- package/dist/components/Carousel/resizeObserver.cjs.map +1 -1
- package/dist/components/Carousel/resizeObserver.js.map +1 -1
- package/dist/components/Carousel/store.cjs.map +1 -1
- package/dist/components/Carousel/store.js.map +1 -1
- package/dist/components/Carousel/useCarouselScroller.cjs +0 -1
- package/dist/components/Carousel/useCarouselScroller.cjs.map +1 -1
- package/dist/components/Carousel/useCarouselScroller.js.map +1 -1
- package/dist/components/Checkbox/CheckboxInput/index.d.ts.map +1 -1
- package/dist/components/Checkbox/CheckboxInput/index2.cjs +0 -1
- package/dist/components/Checkbox/CheckboxInput/index2.cjs.map +1 -1
- package/dist/components/Checkbox/CheckboxInput/index2.js.map +1 -1
- package/dist/components/Checkbox/CheckboxWithLabel.cjs +1 -1
- package/dist/components/Checkbox/CheckboxWithLabel.cjs.map +1 -1
- package/dist/components/Checkbox/CheckboxWithLabel.d.ts +2 -2
- package/dist/components/Checkbox/CheckboxWithLabel.d.ts.map +1 -1
- package/dist/components/Checkbox/CheckboxWithLabel.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index2.cjs +0 -1
- package/dist/components/Checkbox/index2.cjs.map +1 -1
- package/dist/components/Checkbox/index2.js.map +1 -1
- package/dist/components/Clickable/index.d.ts +1 -1
- package/dist/components/Clickable/index.d.ts.map +1 -1
- package/dist/components/Clickable/index2.cjs +1 -1
- package/dist/components/Clickable/index2.cjs.map +1 -1
- package/dist/components/Clickable/index2.js.map +1 -1
- package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs +0 -1
- package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/DropdownMenuItem/index2.js.map +1 -1
- package/dist/components/DropdownSelector/DropdownPopover.cjs +0 -1
- package/dist/components/DropdownSelector/DropdownPopover.cjs.map +1 -1
- package/dist/components/DropdownSelector/DropdownPopover.js.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index2.cjs +0 -1
- package/dist/components/DropdownSelector/ListItem/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index2.js.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.cjs +29 -2
- package/dist/components/DropdownSelector/MenuItem/index.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.js +30 -2
- package/dist/components/DropdownSelector/MenuItem/index.js.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.js.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs +0 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.js.map +1 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs +0 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index2.js.map +1 -1
- package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs +0 -1
- package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuList/MenuListContext.js.map +1 -1
- package/dist/components/DropdownSelector/MenuList/index2.cjs +0 -1
- package/dist/components/DropdownSelector/MenuList/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuList/index2.js.map +1 -1
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs +1 -1
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.js.map +1 -1
- package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Popover/index2.cjs +18 -1
- package/dist/components/DropdownSelector/Popover/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/Popover/index2.js +19 -1
- package/dist/components/DropdownSelector/Popover/index2.js.map +1 -1
- package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs +0 -1
- package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs.map +1 -1
- package/dist/components/DropdownSelector/Popover/usePreventScroll.js.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index2.cjs +27 -10
- package/dist/components/DropdownSelector/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/index2.js +26 -9
- package/dist/components/DropdownSelector/index2.js.map +1 -1
- package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs +1 -1
- package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs.map +1 -1
- package/dist/components/DropdownSelector/utils/findPreviewRecursive.js.map +1 -1
- package/dist/components/FieldLabel/index.d.ts.map +1 -1
- package/dist/components/FieldLabel/index2.cjs +1 -1
- package/dist/components/FieldLabel/index2.cjs.map +1 -1
- package/dist/components/FieldLabel/index2.js.map +1 -1
- package/dist/components/HintText/index2.cjs +0 -1
- package/dist/components/HintText/index2.cjs.map +1 -1
- package/dist/components/HintText/index2.js.map +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.cjs.map +1 -1
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/IconButton/index.d.ts +1 -1
- package/dist/components/IconButton/index.d.ts.map +1 -1
- package/dist/components/IconButton/index2.cjs +1 -1
- package/dist/components/IconButton/index2.cjs.map +1 -1
- package/dist/components/IconButton/index2.js.map +1 -1
- package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/index2.cjs +0 -1
- package/dist/components/LoadingSpinner/index2.cjs.map +1 -1
- package/dist/components/LoadingSpinner/index2.js.map +1 -1
- package/dist/components/Modal/Dialog/index2.cjs +1 -1
- package/dist/components/Modal/Dialog/index2.cjs.map +1 -1
- package/dist/components/Modal/Dialog/index2.js.map +1 -1
- package/dist/components/Modal/ModalBackgroundContext.cjs +1 -1
- package/dist/components/Modal/ModalBackgroundContext.cjs.map +1 -1
- package/dist/components/Modal/ModalBackgroundContext.js.map +1 -1
- package/dist/components/Modal/ModalPlumbing.d.ts +3 -3
- package/dist/components/Modal/ModalPlumbing2.cjs +0 -1
- package/dist/components/Modal/ModalPlumbing2.cjs.map +1 -1
- package/dist/components/Modal/ModalPlumbing2.js.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index2.cjs +1 -1
- package/dist/components/Modal/index2.cjs.map +1 -1
- package/dist/components/Modal/index2.js.map +1 -1
- package/dist/components/Modal/useCustomModalOverlay.cjs +1 -1
- package/dist/components/Modal/useCustomModalOverlay.cjs.map +1 -1
- package/dist/components/Modal/useCustomModalOverlay.js.map +1 -1
- package/dist/components/Modal/useTransitionPresence.cjs +1 -3
- package/dist/components/Modal/useTransitionPresence.cjs.map +1 -1
- package/dist/components/Modal/useTransitionPresence.js +1 -2
- package/dist/components/Modal/useTransitionPresence.js.map +1 -1
- package/dist/components/MultiSelect/context.cjs +0 -1
- package/dist/components/MultiSelect/context.cjs.map +1 -1
- package/dist/components/MultiSelect/context.js.map +1 -1
- package/dist/components/MultiSelect/index.d.ts +1 -1
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/index2.cjs +2 -2
- package/dist/components/MultiSelect/index2.cjs.map +1 -1
- package/dist/components/MultiSelect/index2.js.map +1 -1
- package/dist/components/Pagination/PaginationContext.cjs +0 -1
- package/dist/components/Pagination/PaginationContext.cjs.map +1 -1
- package/dist/components/Pagination/PaginationContext.js.map +1 -1
- package/dist/components/Pagination/helper.cjs.map +1 -1
- package/dist/components/Pagination/helper.js.map +1 -1
- package/dist/components/Pagination/index2.cjs +26 -135
- package/dist/components/Pagination/index2.cjs.map +1 -1
- package/dist/components/Pagination/index2.js +86 -182
- package/dist/components/Pagination/index2.js.map +1 -1
- package/dist/components/Radio/RadioGroup/index2.cjs +1 -1
- package/dist/components/Radio/RadioGroup/index2.cjs.map +1 -1
- package/dist/components/Radio/RadioGroup/index2.js.map +1 -1
- package/dist/components/Radio/RadioGroupContext.cjs.map +1 -1
- package/dist/components/Radio/RadioGroupContext.js.map +1 -1
- package/dist/components/Radio/RadioInput/index.d.ts.map +1 -1
- package/dist/components/Radio/RadioInput/index2.cjs +0 -1
- package/dist/components/Radio/RadioInput/index2.cjs.map +1 -1
- package/dist/components/Radio/RadioInput/index2.js.map +1 -1
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/Radio/index2.cjs +2 -2
- package/dist/components/Radio/index2.cjs.map +1 -1
- package/dist/components/Radio/index2.js.map +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.cjs +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.cjs.map +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.js.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index2.cjs +1 -1
- package/dist/components/SegmentedControl/index2.cjs.map +1 -1
- package/dist/components/SegmentedControl/index2.js.map +1 -1
- package/dist/components/Switch/SwitchInput/index.d.ts.map +1 -1
- package/dist/components/Switch/SwitchInput/index2.cjs +0 -1
- package/dist/components/Switch/SwitchInput/index2.cjs.map +1 -1
- package/dist/components/Switch/SwitchInput/index2.js.map +1 -1
- package/dist/components/Switch/SwitchWithLabel.cjs +1 -1
- package/dist/components/Switch/SwitchWithLabel.cjs.map +1 -1
- package/dist/components/Switch/SwitchWithLabel.d.ts +2 -2
- package/dist/components/Switch/SwitchWithLabel.d.ts.map +1 -1
- package/dist/components/Switch/SwitchWithLabel.js.map +1 -1
- package/dist/components/Switch/index.d.ts +1 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/Switch/index2.cjs +0 -1
- package/dist/components/Switch/index2.cjs.map +1 -1
- package/dist/components/Switch/index2.js.map +1 -1
- package/dist/components/TagItem/index.d.ts +1 -1
- package/dist/components/TagItem/index.d.ts.map +1 -1
- package/dist/components/TagItem/index2.cjs +1 -1
- package/dist/components/TagItem/index2.cjs.map +1 -1
- package/dist/components/TagItem/index2.js.map +1 -1
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextArea/index2.cjs +0 -1
- package/dist/components/TextArea/index2.cjs.map +1 -1
- package/dist/components/TextArea/index2.js.map +1 -1
- package/dist/components/TextEllipsis/helper.cjs +2 -1
- package/dist/components/TextEllipsis/helper.cjs.map +1 -1
- package/dist/components/TextEllipsis/helper.d.ts.map +1 -1
- package/dist/components/TextEllipsis/helper.js +1 -1
- package/dist/components/TextEllipsis/helper.js.map +1 -1
- package/dist/components/TextEllipsis/index2.cjs +14 -98
- package/dist/components/TextEllipsis/index2.cjs.map +1 -1
- package/dist/components/TextEllipsis/index2.js +14 -93
- package/dist/components/TextEllipsis/index2.js.map +1 -1
- package/dist/components/TextField/AssistiveText/index.d.ts +1 -1
- package/dist/components/TextField/AssistiveText/index2.cjs.map +1 -1
- package/dist/components/TextField/AssistiveText/index2.js.map +1 -1
- package/dist/components/TextField/index.d.ts +1 -1
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/components/TextField/index2.cjs +1 -1
- package/dist/components/TextField/index2.cjs.map +1 -1
- package/dist/components/TextField/index2.js.map +1 -1
- package/dist/components/TextField/useFocusWithClick.cjs +0 -1
- package/dist/components/TextField/useFocusWithClick.cjs.map +1 -1
- package/dist/components/TextField/useFocusWithClick.js.map +1 -1
- package/dist/core/CharcoalProvider.cjs +1 -1
- package/dist/core/CharcoalProvider.cjs.map +1 -1
- package/dist/core/CharcoalProvider.js.map +1 -1
- package/dist/core/SSRProvider.cjs +1 -1
- package/dist/core/SSRProvider.cjs.map +1 -1
- package/dist/core/SSRProvider.js +1 -1
- package/dist/core/SSRProvider.js.map +1 -1
- package/dist/core/SetThemeScript.cjs +0 -1
- package/dist/core/SetThemeScript.cjs.map +1 -1
- package/dist/core/SetThemeScript.js.map +1 -1
- package/dist/core/themeHelper.cjs +0 -1
- package/dist/core/themeHelper.cjs.map +1 -1
- package/dist/core/themeHelper.d.ts +2 -2
- package/dist/core/themeHelper.d.ts.map +1 -1
- package/dist/core/themeHelper.js.map +1 -1
- package/dist/index.cjs +22 -23
- package/dist/index.css +1422 -1422
- package/dist/layered.css +1422 -1422
- package/dist/layered.css.map +1 -1
- package/package.json +10 -10
- package/src/_lib/compat.ts +1 -7
- package/src/components/Carousel/index.browser.test.tsx +1 -1
- package/src/components/Carousel/intersectionObserver.test.ts +12 -12
- package/src/components/Carousel/resizeObserver.test.ts +1 -1
- package/src/components/DropdownSelector/MenuItem/index.tsx +40 -2
- package/src/components/DropdownSelector/Popover/index.tsx +20 -1
- package/src/components/DropdownSelector/index.browser.test.tsx +94 -0
- package/src/components/DropdownSelector/index.test.tsx +57 -2
- package/src/components/DropdownSelector/index.tsx +37 -12
- package/src/components/FieldLabel/index.tsx +1 -2
- package/src/components/Icon/index.tsx +2 -1
- package/src/components/LoadingSpinner/__snapshots__/index.css.snap +1 -1
- package/src/components/LoadingSpinner/index.css +1 -1
- package/src/components/Modal/__snapshots__/index.css.snap +1 -0
- package/src/components/Pagination/__snapshots__/index.css.snap +1 -1
- package/src/components/Pagination/index.css +1 -1
- package/src/components/TextEllipsis/TextEllipsis.story.tsx +1 -1
- package/src/css.d.ts +1 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import ListItem from "../ListItem/index2.js";
|
|
3
3
|
import { useMenuItemHandleKeyDown } from "./internals/useMenuItemHandleKeyDown.js";
|
|
4
|
-
import { forwardRef } from "react";
|
|
4
|
+
import { forwardRef, useCallback, useRef } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
//#region src/components/DropdownSelector/MenuItem/index.tsx
|
|
@@ -11,12 +11,40 @@ import { jsx } from "react/jsx-runtime";
|
|
|
11
11
|
*/
|
|
12
12
|
const MenuItem = forwardRef(function MenuItem({ className: _, value, disabled, ...props }, ref) {
|
|
13
13
|
const [handleKeyDown, setContextValue] = useMenuItemHandleKeyDown(value);
|
|
14
|
+
const penHandledRef = useRef(false);
|
|
15
|
+
const pointerStartRef = useRef(null);
|
|
16
|
+
const handlePointerDown = useCallback((e) => {
|
|
17
|
+
if (e.pointerType === "pen") pointerStartRef.current = {
|
|
18
|
+
x: e.clientX,
|
|
19
|
+
y: e.clientY
|
|
20
|
+
};
|
|
21
|
+
}, []);
|
|
22
|
+
const handlePointerUp = useCallback((e) => {
|
|
23
|
+
if (e.pointerType !== "pen" || disabled === true) return;
|
|
24
|
+
const start = pointerStartRef.current;
|
|
25
|
+
if (!start) return;
|
|
26
|
+
const dx = Math.abs(e.clientX - start.x);
|
|
27
|
+
const dy = Math.abs(e.clientY - start.y);
|
|
28
|
+
if (dx > 8 || dy > 8) return;
|
|
29
|
+
penHandledRef.current = true;
|
|
30
|
+
setContextValue();
|
|
31
|
+
}, [disabled, setContextValue]);
|
|
32
|
+
const handleClick = useCallback(() => {
|
|
33
|
+
if (penHandledRef.current) {
|
|
34
|
+
penHandledRef.current = false;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (disabled === true) return;
|
|
38
|
+
setContextValue();
|
|
39
|
+
}, [disabled, setContextValue]);
|
|
14
40
|
return /* @__PURE__ */ jsx(ListItem, {
|
|
15
41
|
...props,
|
|
16
42
|
ref,
|
|
17
43
|
"data-key": value,
|
|
18
44
|
onKeyDown: handleKeyDown,
|
|
19
|
-
|
|
45
|
+
onPointerDown: handlePointerDown,
|
|
46
|
+
onPointerUp: handlePointerUp,
|
|
47
|
+
onClick: handleClick,
|
|
20
48
|
tabIndex: -1,
|
|
21
49
|
"aria-disabled": disabled,
|
|
22
50
|
role: "option",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/DropdownSelector/MenuItem/index.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef, useCallback, useRef } from 'react'\nimport ListItem, { ListItemProps } from '../ListItem'\nimport { useMenuItemHandleKeyDown } from './internals/useMenuItemHandleKeyDown'\n\nexport type MenuItemProps<T extends React.ElementType = 'li'> = {\n value?: string\n disabled?: boolean\n} & ListItemProps<T>\n\n/**\n * 上下キーでフォーカス移動でき、エンターキーで選択できるリストの項目\n * 基本的に`<MenuList>`, `<MenuGroup>`と合わせて使用する\n */\nconst MenuItem = forwardRef(function MenuItem<\n T extends React.ElementType = 'li',\n>(\n { className: _, value, disabled, ...props }: MenuItemProps<T>,\n ref: ForwardedRef<HTMLLIElement>,\n) {\n const [handleKeyDown, setContextValue] = useMenuItemHandleKeyDown(value)\n const penHandledRef = useRef(false)\n const pointerStartRef = useRef<{ x: number; y: number } | null>(null)\n\n const handlePointerDown = useCallback(\n (e: React.PointerEvent<HTMLLIElement>) => {\n if (e.pointerType === 'pen') {\n pointerStartRef.current = { x: e.clientX, y: e.clientY }\n }\n },\n [],\n )\n\n const handlePointerUp = useCallback(\n (e: React.PointerEvent<HTMLLIElement>) => {\n if (e.pointerType !== 'pen' || disabled === true) return\n const start = pointerStartRef.current\n if (!start) return\n const dx = Math.abs(e.clientX - start.x)\n const dy = Math.abs(e.clientY - start.y)\n // タップとドラッグを区別するための許容量\n if (dx > 8 || dy > 8) return\n penHandledRef.current = true\n setContextValue()\n },\n [disabled, setContextValue],\n )\n\n const handleClick = useCallback(() => {\n if (penHandledRef.current) {\n penHandledRef.current = false\n return\n }\n if (disabled === true) return\n setContextValue()\n }, [disabled, setContextValue])\n\n return (\n // @ts-expect-error TODO: fix mismatch between MenuItemProps and ListItemProps\n <ListItem\n {...props}\n ref={ref}\n data-key={value}\n onKeyDown={handleKeyDown}\n onPointerDown={handlePointerDown}\n onPointerUp={handlePointerUp}\n onClick={handleClick}\n tabIndex={-1}\n aria-disabled={disabled}\n role=\"option\"\n >\n {props.children}\n </ListItem>\n )\n})\nexport default MenuItem\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,WAAW,WAAW,SAAS,SAGnC,EAAE,WAAW,GAAG,OAAO,UAAU,GAAG,SACpC,KACA;CACA,MAAM,CAAC,eAAe,mBAAmB,yBAAyB,KAAK;CACvE,MAAM,gBAAgB,OAAO,KAAK;CAClC,MAAM,kBAAkB,OAAwC,IAAI;CAEpE,MAAM,oBAAoB,aACvB,MAAyC;EACxC,IAAI,EAAE,gBAAgB,OACpB,gBAAgB,UAAU;GAAE,GAAG,EAAE;GAAS,GAAG,EAAE;EAAQ;CAE3D,GACA,CAAA,CACF;CAEA,MAAM,kBAAkB,aACrB,MAAyC;EACxC,IAAI,EAAE,gBAAgB,SAAS,aAAa,MAAM;EAClD,MAAM,QAAQ,gBAAgB;EAC9B,IAAI,CAAC,OAAO;EACZ,MAAM,KAAK,KAAK,IAAI,EAAE,UAAU,MAAM,CAAC;EACvC,MAAM,KAAK,KAAK,IAAI,EAAE,UAAU,MAAM,CAAC;EAEvC,IAAI,KAAK,KAAK,KAAK,GAAG;EACtB,cAAc,UAAU;EACxB,gBAAgB;CAClB,GACA,CAAC,UAAU,eAAe,CAC5B;CAEA,MAAM,cAAc,kBAAkB;EACpC,IAAI,cAAc,SAAS;GACzB,cAAc,UAAU;GACxB;EACF;EACA,IAAI,aAAa,MAAM;EACvB,gBAAgB;CAClB,GAAG,CAAC,UAAU,eAAe,CAAC;CAE9B,OAEE,oBAAC,UAAD;EACE,GAAI;EACC;EACL,YAAU;EACV,WAAW;EACX,eAAe;EACf,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAe;EACf,MAAK;YAEJ,MAAM;CACC;AAEd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleFocusByKeyBoard.cjs","names":[
|
|
1
|
+
{"version":3,"file":"handleFocusByKeyBoard.cjs","names":[],"sources":["../../../../../src/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.tsx"],"sourcesContent":["/**\n * elementをparentのスクロールビューに入るようにスクロールする\n * parentがスクロール可能でなければelementが見えるようにスクロールする\n *\n * @param element\n * @param parent\n */\nexport function handleFocusByKeyBoard(element: Element, parent: HTMLElement) {\n const isScrollable = parent.scrollHeight > parent.clientHeight\n if (isScrollable) {\n const rect = element.getBoundingClientRect()\n const parentRect = parent.getBoundingClientRect()\n if (rect.bottom > parentRect.bottom) {\n parent.scrollTo({\n top: parent.scrollTop + rect.bottom - parentRect.bottom,\n })\n } else if (rect.top < parentRect.top) {\n parent.scrollTo({\n top: parent.scrollTop - (parentRect.top - rect.top),\n })\n }\n } else {\n scrollIfNeeded(element)\n }\n}\n\n/**\n * 要素が画面外にあればスクロールする、画面内にあればスクロールしない\n * @param element\n */\nfunction scrollIfNeeded(element: Element) {\n const elementRect = element.getBoundingClientRect()\n const isVisible =\n elementRect.top >= 0 &&\n elementRect.bottom <=\n (window.innerHeight || document.documentElement.clientHeight)\n\n if (!isVisible) {\n element.scrollIntoView({\n block: 'nearest',\n })\n }\n}\n"],"mappings":";;;;;;;;;;AAOA,SAAgB,sBAAsB,SAAkB,QAAqB;CAE3E,IADqB,OAAO,eAAe,OAAO,cAChC;EAChB,MAAM,OAAO,QAAQ,sBAAsB;EAC3C,MAAM,aAAa,OAAO,sBAAsB;EAChD,IAAI,KAAK,SAAS,WAAW,QAC3B,OAAO,SAAS,EACd,KAAK,OAAO,YAAY,KAAK,SAAS,WAAW,OACnD,CAAC;OACI,IAAI,KAAK,MAAM,WAAW,KAC/B,OAAO,SAAS,EACd,KAAK,OAAO,aAAa,WAAW,MAAM,KAAK,KACjD,CAAC;CAEL,OACE,eAAe,OAAO;AAE1B;;;;;AAMA,SAAS,eAAe,SAAkB;CACxC,MAAM,cAAc,QAAQ,sBAAsB;CAMlD,IAAI,EAJF,YAAY,OAAO,KACnB,YAAY,WACT,OAAO,eAAe,SAAS,gBAAgB,gBAGlD,QAAQ,eAAe,EACrB,OAAO,UACT,CAAC;AAEL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleFocusByKeyBoard.js","names":[
|
|
1
|
+
{"version":3,"file":"handleFocusByKeyBoard.js","names":[],"sources":["../../../../../src/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.tsx"],"sourcesContent":["/**\n * elementをparentのスクロールビューに入るようにスクロールする\n * parentがスクロール可能でなければelementが見えるようにスクロールする\n *\n * @param element\n * @param parent\n */\nexport function handleFocusByKeyBoard(element: Element, parent: HTMLElement) {\n const isScrollable = parent.scrollHeight > parent.clientHeight\n if (isScrollable) {\n const rect = element.getBoundingClientRect()\n const parentRect = parent.getBoundingClientRect()\n if (rect.bottom > parentRect.bottom) {\n parent.scrollTo({\n top: parent.scrollTop + rect.bottom - parentRect.bottom,\n })\n } else if (rect.top < parentRect.top) {\n parent.scrollTo({\n top: parent.scrollTop - (parentRect.top - rect.top),\n })\n }\n } else {\n scrollIfNeeded(element)\n }\n}\n\n/**\n * 要素が画面外にあればスクロールする、画面内にあればスクロールしない\n * @param element\n */\nfunction scrollIfNeeded(element: Element) {\n const elementRect = element.getBoundingClientRect()\n const isVisible =\n elementRect.top >= 0 &&\n elementRect.bottom <=\n (window.innerHeight || document.documentElement.clientHeight)\n\n if (!isVisible) {\n element.scrollIntoView({\n block: 'nearest',\n })\n }\n}\n"],"mappings":";;;;;;;;;AAOA,SAAgB,sBAAsB,SAAkB,QAAqB;CAE3E,IADqB,OAAO,eAAe,OAAO,cAChC;EAChB,MAAM,OAAO,QAAQ,sBAAsB;EAC3C,MAAM,aAAa,OAAO,sBAAsB;EAChD,IAAI,KAAK,SAAS,WAAW,QAC3B,OAAO,SAAS,EACd,KAAK,OAAO,YAAY,KAAK,SAAS,WAAW,OACnD,CAAC;OACI,IAAI,KAAK,MAAM,WAAW,KAC/B,OAAO,SAAS,EACd,KAAK,OAAO,aAAa,WAAW,MAAM,KAAK,KACjD,CAAC;CAEL,OACE,eAAe,OAAO;AAE1B;;;;;AAMA,SAAS,eAAe,SAAkB;CACxC,MAAM,cAAc,QAAQ,sBAAsB;CAMlD,IAAI,EAJF,YAAY,OAAO,KACnB,YAAY,WACT,OAAO,eAAe,SAAS,gBAAgB,gBAGlD,QAAQ,eAAe,EACrB,OAAO,UACT,CAAC;AAEL"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const require_runtime = require('../../../../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_MenuListContext = require('../../MenuList/MenuListContext.cjs');
|
|
4
3
|
const require_handleFocusByKeyBoard = require('./handleFocusByKeyBoard.cjs');
|
|
5
4
|
let react = require("react");
|
package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMenuItemHandleKeyDown.cjs","names":[
|
|
1
|
+
{"version":3,"file":"useMenuItemHandleKeyDown.cjs","names":[],"sources":["../../../../../src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx"],"sourcesContent":["import { useCallback, useContext } from 'react'\nimport { handleFocusByKeyBoard } from './handleFocusByKeyBoard'\nimport { MenuListContext } from '../../MenuList/MenuListContext'\n\n/**\n * MenuListContextに含まれるvalue間で上下キーでfocusを移動できる\n * EnterキーでMenuListContextに値を設定する\n * 上記2つの処理を含む処理(handleKeyDown)と、Enterキーを押下した処理(setContextValue)を配列で返す\n * @param value\n * @returns\n */\nexport function useMenuItemHandleKeyDown(\n value?: string,\n): [(e: React.KeyboardEvent<HTMLElement>) => void, () => void] {\n const { setValue, root, propsArray } = useContext(MenuListContext)\n const setContextValue = useCallback(() => {\n if (value !== undefined) setValue(value)\n }, [value, setValue])\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n if (e.key === 'Enter') {\n setContextValue()\n } else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n const isForward = e.key === 'ArrowDown'\n // prevent scroll\n e.preventDefault()\n if (!propsArray || value === undefined) return\n const values = propsArray\n .map((props) => props.value)\n .filter((v) => v) as string[]\n let index = values.indexOf(value)\n if (index === -1) return\n\n for (let n = 0; n < values.length; n++) {\n const focusValue = isForward\n ? // prev or last\n index + 1 >= values.length\n ? values[0]\n : values[index + 1]\n : // next or first\n index - 1 < 0\n ? values[values.length - 1]\n : values[index - 1]\n const next = root?.current?.querySelector(\n `[data-key='${focusValue}']`,\n )\n\n if (next instanceof HTMLElement) {\n if (next.ariaDisabled === 'true') {\n index += isForward ? 1 : -1\n continue\n }\n next.focus({ preventScroll: true })\n if (root?.current?.parentElement) {\n handleFocusByKeyBoard(next, root.current.parentElement)\n }\n break\n }\n }\n }\n },\n [setContextValue, propsArray, value, root],\n )\n return [handleKeyDown, setContextValue]\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAgB,yBACd,OAC6D;CAC7D,MAAM,EAAE,UAAU,MAAM,qCAA0B,uCAAe;CACjE,MAAM,+CAAoC;EACxC,IAAI,UAAU,QAAW,SAAS,KAAK;CACzC,GAAG,CAAC,OAAO,QAAQ,CAAC;CA+CpB,OAAO,yBA5CJ,MAAwC;EACvC,IAAI,EAAE,QAAQ,SACZ,gBAAgB;OACX,IAAI,EAAE,QAAQ,aAAa,EAAE,QAAQ,aAAa;GACvD,MAAM,YAAY,EAAE,QAAQ;GAE5B,EAAE,eAAe;GACjB,IAAI,CAAC,cAAc,UAAU,QAAW;GACxC,MAAM,SAAS,WACZ,KAAK,UAAU,MAAM,KAAK,CAAC,CAC3B,QAAQ,MAAM,CAAC;GAClB,IAAI,QAAQ,OAAO,QAAQ,KAAK;GAChC,IAAI,UAAU,IAAI;GAElB,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;IACtC,MAAM,aAAa,YAEf,QAAQ,KAAK,OAAO,SAClB,OAAO,KACP,OAAO,QAAQ,KAEjB,QAAQ,IAAI,IACV,OAAO,OAAO,SAAS,KACvB,OAAO,QAAQ;IACrB,MAAM,OAAO,MAAM,SAAS,cAC1B,cAAc,WAAU,GAC1B;IAEA,IAAI,gBAAgB,aAAa;KAC/B,IAAI,KAAK,iBAAiB,QAAQ;MAChC,SAAS,YAAY,IAAI;MACzB;KACF;KACA,KAAK,MAAM,EAAE,eAAe,KAAK,CAAC;KAClC,IAAI,MAAM,SAAS,eACjB,oDAAsB,MAAM,KAAK,QAAQ,aAAa;KAExD;IACF;GACF;EACF;CACF,GACA;EAAC;EAAiB;EAAY;EAAO;CAAI,CAEnC,GAAe,eAAe;AACxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMenuItemHandleKeyDown.js","names":[
|
|
1
|
+
{"version":3,"file":"useMenuItemHandleKeyDown.js","names":[],"sources":["../../../../../src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx"],"sourcesContent":["import { useCallback, useContext } from 'react'\nimport { handleFocusByKeyBoard } from './handleFocusByKeyBoard'\nimport { MenuListContext } from '../../MenuList/MenuListContext'\n\n/**\n * MenuListContextに含まれるvalue間で上下キーでfocusを移動できる\n * EnterキーでMenuListContextに値を設定する\n * 上記2つの処理を含む処理(handleKeyDown)と、Enterキーを押下した処理(setContextValue)を配列で返す\n * @param value\n * @returns\n */\nexport function useMenuItemHandleKeyDown(\n value?: string,\n): [(e: React.KeyboardEvent<HTMLElement>) => void, () => void] {\n const { setValue, root, propsArray } = useContext(MenuListContext)\n const setContextValue = useCallback(() => {\n if (value !== undefined) setValue(value)\n }, [value, setValue])\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n if (e.key === 'Enter') {\n setContextValue()\n } else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n const isForward = e.key === 'ArrowDown'\n // prevent scroll\n e.preventDefault()\n if (!propsArray || value === undefined) return\n const values = propsArray\n .map((props) => props.value)\n .filter((v) => v) as string[]\n let index = values.indexOf(value)\n if (index === -1) return\n\n for (let n = 0; n < values.length; n++) {\n const focusValue = isForward\n ? // prev or last\n index + 1 >= values.length\n ? values[0]\n : values[index + 1]\n : // next or first\n index - 1 < 0\n ? values[values.length - 1]\n : values[index - 1]\n const next = root?.current?.querySelector(\n `[data-key='${focusValue}']`,\n )\n\n if (next instanceof HTMLElement) {\n if (next.ariaDisabled === 'true') {\n index += isForward ? 1 : -1\n continue\n }\n next.focus({ preventScroll: true })\n if (root?.current?.parentElement) {\n handleFocusByKeyBoard(next, root.current.parentElement)\n }\n break\n }\n }\n }\n },\n [setContextValue, propsArray, value, root],\n )\n return [handleKeyDown, setContextValue]\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAgB,yBACd,OAC6D;CAC7D,MAAM,EAAE,UAAU,MAAM,eAAe,WAAW,eAAe;CACjE,MAAM,kBAAkB,kBAAkB;EACxC,IAAI,UAAU,QAAW,SAAS,KAAK;CACzC,GAAG,CAAC,OAAO,QAAQ,CAAC;CA+CpB,OAAO,CA7Ce,aACnB,MAAwC;EACvC,IAAI,EAAE,QAAQ,SACZ,gBAAgB;OACX,IAAI,EAAE,QAAQ,aAAa,EAAE,QAAQ,aAAa;GACvD,MAAM,YAAY,EAAE,QAAQ;GAE5B,EAAE,eAAe;GACjB,IAAI,CAAC,cAAc,UAAU,QAAW;GACxC,MAAM,SAAS,WACZ,KAAK,UAAU,MAAM,KAAK,CAAC,CAC3B,QAAQ,MAAM,CAAC;GAClB,IAAI,QAAQ,OAAO,QAAQ,KAAK;GAChC,IAAI,UAAU,IAAI;GAElB,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;IACtC,MAAM,aAAa,YAEf,QAAQ,KAAK,OAAO,SAClB,OAAO,KACP,OAAO,QAAQ,KAEjB,QAAQ,IAAI,IACV,OAAO,OAAO,SAAS,KACvB,OAAO,QAAQ;IACrB,MAAM,OAAO,MAAM,SAAS,cAC1B,cAAc,WAAU,GAC1B;IAEA,IAAI,gBAAgB,aAAa;KAC/B,IAAI,KAAK,iBAAiB,QAAQ;MAChC,SAAS,YAAY,IAAI;MACzB;KACF;KACA,KAAK,MAAM,EAAE,eAAe,KAAK,CAAC;KAClC,IAAI,MAAM,SAAS,eACjB,sBAAsB,MAAM,KAAK,QAAQ,aAAa;KAExD;IACF;GACF;EACF;CACF,GACA;EAAC;EAAiB;EAAY;EAAO;CAAI,CAEnC,GAAe,eAAe;AACxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.cjs","names":[
|
|
1
|
+
{"version":3,"file":"index2.cjs","names":[],"sources":["../../../../src/components/DropdownSelector/MenuItemGroup/index.tsx"],"sourcesContent":["import './index.css'\n\nimport MenuItem from '../MenuItem'\nimport { Divider } from '../Divider'\n\ntype MenuItemGroupChild = React.ReactElement<typeof MenuItem | typeof Divider>\n\nexport type MenuItemGroupProps = {\n text: string\n children: MenuItemGroupChild | MenuItemGroupChild[]\n}\n\nexport default function MenuItemGroup(props: MenuItemGroupProps) {\n return (\n <li className=\"charcoal-menu-item-group\" role=\"presentation\">\n <span>{props.text}</span>\n <ul role=\"group\">{props.children}</ul>\n </li>\n )\n}\n"],"mappings":";;;;;AAYA,SAAwB,cAAc,OAA2B;CAC/D,OACE,4CAAC,MAAD;EAAI,WAAU;EAA2B,MAAK;YAA9C,CACE,2CAAC,QAAD,YAAO,MAAM,KAAW,IACxB,2CAAC,MAAD;GAAI,MAAK;aAAS,MAAM;EAAa,EACnC;;AAER"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.js","names":[
|
|
1
|
+
{"version":3,"file":"index2.js","names":[],"sources":["../../../../src/components/DropdownSelector/MenuItemGroup/index.tsx"],"sourcesContent":["import './index.css'\n\nimport MenuItem from '../MenuItem'\nimport { Divider } from '../Divider'\n\ntype MenuItemGroupChild = React.ReactElement<typeof MenuItem | typeof Divider>\n\nexport type MenuItemGroupProps = {\n text: string\n children: MenuItemGroupChild | MenuItemGroupChild[]\n}\n\nexport default function MenuItemGroup(props: MenuItemGroupProps) {\n return (\n <li className=\"charcoal-menu-item-group\" role=\"presentation\">\n <span>{props.text}</span>\n <ul role=\"group\">{props.children}</ul>\n </li>\n )\n}\n"],"mappings":";;;;;AAYA,SAAwB,cAAc,OAA2B;CAC/D,OACE,qBAAC,MAAD;EAAI,WAAU;EAA2B,MAAK;YAA9C,CACE,oBAAC,QAAD,YAAO,MAAM,KAAW,IACxB,oBAAC,MAAD;GAAI,MAAK;aAAS,MAAM;EAAa,EACnC;;AAER"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuListContext.cjs","names":[
|
|
1
|
+
{"version":3,"file":"MenuListContext.cjs","names":[],"sources":["../../../../src/components/DropdownSelector/MenuList/MenuListContext.ts"],"sourcesContent":["import { RefObject, createContext } from 'react'\nimport { DropdownMenuItemProps } from '../DropdownMenuItem'\n\ntype MenuListContextType = {\n root?: RefObject<HTMLUListElement | null>\n value?: string\n propsArray?: DropdownMenuItemProps[]\n setValue: (v: string) => void\n}\n\nexport const MenuListContext = createContext<MenuListContextType>({\n root: undefined,\n value: '',\n propsArray: [],\n setValue: (_v: string) => {\n // empty\n },\n})\n"],"mappings":";;;;AAUA,MAAa,2CAAqD;CAChE,MAAM;CACN,OAAO;CACP,YAAY,CAAA;CACZ,WAAW,OAAe,CACxB;AAEJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuListContext.js","names":[
|
|
1
|
+
{"version":3,"file":"MenuListContext.js","names":[],"sources":["../../../../src/components/DropdownSelector/MenuList/MenuListContext.ts"],"sourcesContent":["import { RefObject, createContext } from 'react'\nimport { DropdownMenuItemProps } from '../DropdownMenuItem'\n\ntype MenuListContextType = {\n root?: RefObject<HTMLUListElement | null>\n value?: string\n propsArray?: DropdownMenuItemProps[]\n setValue: (v: string) => void\n}\n\nexport const MenuListContext = createContext<MenuListContextType>({\n root: undefined,\n value: '',\n propsArray: [],\n setValue: (_v: string) => {\n // empty\n },\n})\n"],"mappings":";;;;AAUA,MAAa,kBAAkB,cAAmC;CAChE,MAAM;CACN,OAAO;CACP,YAAY,CAAA;CACZ,WAAW,OAAe,CACxB;AAEJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.cjs","names":[
|
|
1
|
+
{"version":3,"file":"index2.cjs","names":[],"sources":["../../../../src/components/DropdownSelector/MenuList/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { useMemo, useRef } from 'react'\nimport { MenuListContext } from './MenuListContext'\nimport { getValuesRecursive } from './internals/getValuesRecursive'\nimport MenuItem from '../MenuItem'\nimport { Divider } from '../Divider'\nimport MenuItemGroup from '../MenuItemGroup'\n\ntype MenuListChild = React.ReactElement<\n typeof MenuItem | typeof MenuItemGroup | typeof Divider\n>\n\nexport type MenuListChildren = MenuListChild | MenuListChild[]\n\nexport type MenuListProps = {\n children: MenuListChildren\n value?: string\n onChange?: (v: string) => void\n}\n\nexport default function MenuList(props: MenuListProps) {\n const root = useRef(null)\n const propsArray = useMemo(\n () => getValuesRecursive(props.children),\n [props.children],\n )\n\n return (\n <ul className=\"charcoal-menu-list\" ref={root}>\n <MenuListContext.Provider\n value={{\n value: props.value ?? '',\n root,\n propsArray,\n setValue: (v) => {\n props.onChange?.(v)\n },\n }}\n >\n {props.children}\n </MenuListContext.Provider>\n </ul>\n )\n}\n"],"mappings":";;;;;;;;AAqBA,SAAwB,SAAS,OAAsB;CACrD,MAAM,yBAAc,IAAI;CACxB,MAAM,sCACE,8CAAmB,MAAM,QAAQ,GACvC,CAAC,MAAM,QAAQ,CACjB;CAEA,OACE,2CAAC,MAAD;EAAI,WAAU;EAAqB,KAAK;YACtC,2CAAC,wCAAgB,UAAjB;GACE,OAAO;IACL,OAAO,MAAM,SAAS;IACtB;IACA;IACA,WAAW,MAAM;KACf,MAAM,WAAW,CAAC;IACpB;GACF;aAEC,MAAM;EACiB;CACxB;AAER"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.js","names":[
|
|
1
|
+
{"version":3,"file":"index2.js","names":[],"sources":["../../../../src/components/DropdownSelector/MenuList/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { useMemo, useRef } from 'react'\nimport { MenuListContext } from './MenuListContext'\nimport { getValuesRecursive } from './internals/getValuesRecursive'\nimport MenuItem from '../MenuItem'\nimport { Divider } from '../Divider'\nimport MenuItemGroup from '../MenuItemGroup'\n\ntype MenuListChild = React.ReactElement<\n typeof MenuItem | typeof MenuItemGroup | typeof Divider\n>\n\nexport type MenuListChildren = MenuListChild | MenuListChild[]\n\nexport type MenuListProps = {\n children: MenuListChildren\n value?: string\n onChange?: (v: string) => void\n}\n\nexport default function MenuList(props: MenuListProps) {\n const root = useRef(null)\n const propsArray = useMemo(\n () => getValuesRecursive(props.children),\n [props.children],\n )\n\n return (\n <ul className=\"charcoal-menu-list\" ref={root}>\n <MenuListContext.Provider\n value={{\n value: props.value ?? '',\n root,\n propsArray,\n setValue: (v) => {\n props.onChange?.(v)\n },\n }}\n >\n {props.children}\n </MenuListContext.Provider>\n </ul>\n )\n}\n"],"mappings":";;;;;;;;AAqBA,SAAwB,SAAS,OAAsB;CACrD,MAAM,OAAO,OAAO,IAAI;CACxB,MAAM,aAAa,cACX,mBAAmB,MAAM,QAAQ,GACvC,CAAC,MAAM,QAAQ,CACjB;CAEA,OACE,oBAAC,MAAD;EAAI,WAAU;EAAqB,KAAK;YACtC,oBAAC,gBAAgB,UAAjB;GACE,OAAO;IACL,OAAO,MAAM,SAAS;IACtB;IACA;IACA,WAAW,MAAM;KACf,MAAM,WAAW,CAAC;IACpB;GACF;aAEC,MAAM;EACiB;CACxB;AAER"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
const require_runtime = require('../../../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
let react = require("react");
|
|
4
|
-
react = require_runtime.__toESM(react);
|
|
4
|
+
react = require_runtime.__toESM(react, 1);
|
|
5
5
|
|
|
6
6
|
//#region src/components/DropdownSelector/MenuList/internals/getValuesRecursive.tsx
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getValuesRecursive.cjs","names":[
|
|
1
|
+
{"version":3,"file":"getValuesRecursive.cjs","names":[],"sources":["../../../../../src/components/DropdownSelector/MenuList/internals/getValuesRecursive.tsx"],"sourcesContent":["import * as React from 'react'\nimport MenuItem from '../../MenuItem'\nimport { MenuListChildren } from '..'\nimport MenuItemGroup from '../../MenuItemGroup'\nimport { DropdownMenuItemProps } from '../../DropdownMenuItem'\n\n/**\n * valueというpropsを持つ子要素の値を再起的に探索して配列にする\n *\n * @param children\n * @param value\n * @param values\n * @returns\n */\nexport function getValuesRecursive(children: MenuListChildren) {\n const childArray = React.Children.toArray(children)\n const propsArray: DropdownMenuItemProps[] = []\n for (let i = 0; i < childArray.length; i++) {\n const child = childArray[i]\n if (React.isValidElement(child)) {\n const props = child.props as {\n value?: string\n disabled?: boolean\n children?: React.ReactElement<typeof MenuItem | typeof MenuItemGroup>[]\n }\n if ('value' in props && typeof props.value === 'string') {\n propsArray.push({\n disabled: props.disabled,\n value: props.value,\n })\n }\n if ('children' in props && props.children) {\n propsArray.push(...getValuesRecursive(props.children))\n }\n }\n }\n return propsArray\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAgB,mBAAmB,UAA4B;CAC7D,MAAM,aAAa,MAAM,SAAS,QAAQ,QAAQ;CAClD,MAAM,aAAsC,CAAA;CAC5C,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;EAC1C,MAAM,QAAQ,WAAW;EACzB,IAAI,MAAM,eAAe,KAAK,GAAG;GAC/B,MAAM,QAAQ,MAAM;GAKpB,IAAI,WAAW,SAAS,OAAO,MAAM,UAAU,UAC7C,WAAW,KAAK;IACd,UAAU,MAAM;IAChB,OAAO,MAAM;GACf,CAAC;GAEH,IAAI,cAAc,SAAS,MAAM,UAC/B,WAAW,KAAK,GAAG,mBAAmB,MAAM,QAAQ,CAAC;EAEzD;CACF;CACA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getValuesRecursive.js","names":[
|
|
1
|
+
{"version":3,"file":"getValuesRecursive.js","names":[],"sources":["../../../../../src/components/DropdownSelector/MenuList/internals/getValuesRecursive.tsx"],"sourcesContent":["import * as React from 'react'\nimport MenuItem from '../../MenuItem'\nimport { MenuListChildren } from '..'\nimport MenuItemGroup from '../../MenuItemGroup'\nimport { DropdownMenuItemProps } from '../../DropdownMenuItem'\n\n/**\n * valueというpropsを持つ子要素の値を再起的に探索して配列にする\n *\n * @param children\n * @param value\n * @param values\n * @returns\n */\nexport function getValuesRecursive(children: MenuListChildren) {\n const childArray = React.Children.toArray(children)\n const propsArray: DropdownMenuItemProps[] = []\n for (let i = 0; i < childArray.length; i++) {\n const child = childArray[i]\n if (React.isValidElement(child)) {\n const props = child.props as {\n value?: string\n disabled?: boolean\n children?: React.ReactElement<typeof MenuItem | typeof MenuItemGroup>[]\n }\n if ('value' in props && typeof props.value === 'string') {\n propsArray.push({\n disabled: props.disabled,\n value: props.value,\n })\n }\n if ('children' in props && props.children) {\n propsArray.push(...getValuesRecursive(props.children))\n }\n }\n }\n return propsArray\n}\n"],"mappings":";;;;;;;;;;;;AAcA,SAAgB,mBAAmB,UAA4B;CAC7D,MAAM,aAAa,QAAM,SAAS,QAAQ,QAAQ;CAClD,MAAM,aAAsC,CAAA;CAC5C,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;EAC1C,MAAM,QAAQ,WAAW;EACzB,IAAI,QAAM,eAAe,KAAK,GAAG;GAC/B,MAAM,QAAQ,MAAM;GAKpB,IAAI,WAAW,SAAS,OAAO,MAAM,UAAU,UAC7C,WAAW,KAAK;IACd,UAAU,MAAM;IAChB,OAAO,MAAM;GACf,CAAC;GAEH,IAAI,cAAc,SAAS,MAAM,UAC/B,WAAW,KAAK,GAAG,mBAAmB,MAAM,QAAQ,CAAC;EAEzD;CACF;CACA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/DropdownSelector/Popover/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/DropdownSelector/Popover/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,SAAS,EAAiC,SAAS,EAAE,MAAM,OAAO,CAAA;AAM3E,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,QAAQ,EAAE,SAAS,CAAA;IACnB,UAAU,EAAE,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACrC,UAAU,CAAC,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IAC7C;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAID;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EAAE,YAAY,kDAuElD"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_ModalBackgroundContext = require('../../Modal/ModalBackgroundContext.cjs');
|
|
4
3
|
const require_usePreventScroll = require('./usePreventScroll.cjs');
|
|
5
4
|
require('./index.cjs');
|
|
@@ -31,6 +30,24 @@ function Popover(props) {
|
|
|
31
30
|
toggle: _empty
|
|
32
31
|
});
|
|
33
32
|
require_usePreventScroll.usePreventScroll((0, react.useContext)(require_ModalBackgroundContext.ModalBackgroundContext), props.isOpen);
|
|
33
|
+
const { isOpen, onClose } = props;
|
|
34
|
+
(0, react.useEffect)(() => {
|
|
35
|
+
if (!isOpen) return;
|
|
36
|
+
const handlePointerUp = (e) => {
|
|
37
|
+
if (e.pointerType !== "pen") return;
|
|
38
|
+
const popover = finalPopoverRef.current;
|
|
39
|
+
if (popover !== null && e.composedPath().includes(popover)) return;
|
|
40
|
+
onClose();
|
|
41
|
+
};
|
|
42
|
+
document.addEventListener("pointerup", handlePointerUp, true);
|
|
43
|
+
return () => {
|
|
44
|
+
document.removeEventListener("pointerup", handlePointerUp, true);
|
|
45
|
+
};
|
|
46
|
+
}, [
|
|
47
|
+
isOpen,
|
|
48
|
+
onClose,
|
|
49
|
+
finalPopoverRef
|
|
50
|
+
]);
|
|
34
51
|
if (!props.isOpen) return null;
|
|
35
52
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_aria_Overlay.Overlay, {
|
|
36
53
|
portalContainer: document.body,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.cjs","names":[
|
|
1
|
+
{"version":3,"file":"index2.cjs","names":[],"sources":["../../../../src/components/DropdownSelector/Popover/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { RefObject, useContext, useEffect, useRef, ReactNode } from 'react'\nimport { ModalBackgroundContext } from '../../Modal/ModalBackgroundContext'\nimport { usePreventScroll } from './usePreventScroll'\nimport { DismissButton, Overlay } from 'react-aria/Overlay'\nimport { usePopover } from 'react-aria/usePopover'\n\nexport type PopoverProps = {\n isOpen: boolean\n onClose: () => void\n children: ReactNode\n triggerRef: RefObject<Element | null>\n popoverRef?: RefObject<HTMLDivElement | null>\n /**\n * A tmp workaround for react-aria above 3.27.3 setting overlay element to inert and causing background to be clickable.\n * This may become default at next major.\n * https://github.com/adobe/react-spectrum/pull/8796\n * https://github.com/adobe/react-spectrum/issues/8784\n *\n * @default false\n */\n inertWorkaround?: boolean\n}\n\nconst _empty = () => null\n\n/**\n * 画面の全面に動的に開くことができるコンテナ要素\n * 外の要素をクリックしたり、内部からフォーカスを移動した場合に自動的に閉じる\n *\n * triggerRefの付近に画面内に収まるように表示される\n */\nexport default function Popover(props: PopoverProps) {\n const defaultPopoverRef = useRef<HTMLDivElement>(null)\n const finalPopoverRef =\n props.popoverRef === undefined ? defaultPopoverRef : props.popoverRef\n const { popoverProps, underlayProps } = usePopover(\n {\n triggerRef: props.triggerRef,\n popoverRef: finalPopoverRef,\n containerPadding: 16,\n },\n {\n close: props.onClose,\n isOpen: props.isOpen,\n // never used\n open: _empty,\n setOpen: _empty,\n toggle: _empty,\n },\n )\n\n const modalBackground = useContext(ModalBackgroundContext)\n usePreventScroll(modalBackground, props.isOpen)\n\n // iOS Safari は非インタラクティブな要素へのペン入力で click を合成しないため、\n // click に依存する react-aria の外側判定ではペンで閉じられない。\n // underlay 側では拾えない: react-aria が modal 時に外側を inert にするので\n // underlay 自身がイベントを受け取らなくなる。\n const { isOpen, onClose } = props\n useEffect(() => {\n if (!isOpen) return\n const handlePointerUp = (e: PointerEvent) => {\n if (e.pointerType !== 'pen') return\n const popover = finalPopoverRef.current\n if (popover !== null && e.composedPath().includes(popover)) return\n onClose()\n }\n document.addEventListener('pointerup', handlePointerUp, true)\n return () => {\n document.removeEventListener('pointerup', handlePointerUp, true)\n }\n }, [isOpen, onClose, finalPopoverRef])\n\n if (!props.isOpen) return null\n\n return (\n <Overlay portalContainer={document.body}>\n <div\n {...underlayProps}\n // https://github.com/adobe/react-spectrum/issues/8784#issuecomment-3234771154\n {...(props.inertWorkaround\n ? { 'data-react-aria-top-layer': true, onClick: props.onClose }\n : {})}\n style={{\n position: 'fixed',\n zIndex:\n typeof popoverProps.style?.zIndex === 'number'\n ? popoverProps.style.zIndex - 1\n : 99999,\n inset: 0,\n }}\n />\n {/* @ts-expect-error react types we use does not support react 19 types yet */}\n <div {...popoverProps} ref={finalPopoverRef} className=\"charcoal-popover\">\n <DismissButton onDismiss={() => props.onClose()} />\n <div tabIndex={0} onFocus={props.onClose} />\n {props.children}\n <div tabIndex={0} onFocus={props.onClose} />\n <DismissButton onDismiss={() => props.onClose()} />\n </div>\n </Overlay>\n )\n}\n"],"mappings":";;;;;;;;;;AAyBA,MAAM,eAAe;;;;;;;AAQrB,SAAwB,QAAQ,OAAqB;CACnD,MAAM,sCAA2C,IAAI;CACrD,MAAM,kBACJ,MAAM,eAAe,SAAY,oBAAoB,MAAM;CAC7D,MAAM,EAAE,cAAc,wDACpB;EACE,YAAY,MAAM;EAClB,YAAY;EACZ,kBAAkB;CACpB,GACA;EACE,OAAO,MAAM;EACb,QAAQ,MAAM;EAEd,MAAM;EACN,SAAS;EACT,QAAQ;CACV,CACF;CAGA,gEADmC,qDAClB,GAAiB,MAAM,MAAM;CAM9C,MAAM,EAAE,QAAQ,YAAY;CAC5B,2BAAgB;EACd,IAAI,CAAC,QAAQ;EACb,MAAM,mBAAmB,MAAoB;GAC3C,IAAI,EAAE,gBAAgB,OAAO;GAC7B,MAAM,UAAU,gBAAgB;GAChC,IAAI,YAAY,QAAQ,EAAE,aAAa,CAAC,CAAC,SAAS,OAAO,GAAG;GAC5D,QAAQ;EACV;EACA,SAAS,iBAAiB,aAAa,iBAAiB,IAAI;EAC5D,aAAa;GACX,SAAS,oBAAoB,aAAa,iBAAiB,IAAI;EACjE;CACF,GAAG;EAAC;EAAQ;EAAS;CAAe,CAAC;CAErC,IAAI,CAAC,MAAM,QAAQ,OAAO;CAE1B,OACE,4CAAC,4BAAD;EAAS,iBAAiB,SAAS;YAAnC,CACE,2CAAC,OAAD;GACE,GAAI;GAEJ,GAAK,MAAM,kBACP;IAAE,6BAA6B;IAAM,SAAS,MAAM;GAAQ,IAC5D,CAAC;GACL,OAAO;IACL,UAAU;IACV,QACE,OAAO,aAAa,OAAO,WAAW,WAClC,aAAa,MAAM,SAAS,IAC5B;IACN,OAAO;GACT;EAAE,IAGJ,4CAAC,OAAD;GAAK,GAAI;GAAc,KAAK;GAAiB,WAAU;aAAvD;IACE,2CAAC,kCAAD,EAAe,iBAAiB,MAAM,QAAQ,EAAE;IAChD,2CAAC,OAAD;KAAK,UAAU;KAAG,SAAS,MAAM;IAAQ;IACxC,MAAM;IACP,2CAAC,OAAD;KAAK,UAAU;KAAG,SAAS,MAAM;IAAQ;IACzC,2CAAC,kCAAD,EAAe,iBAAiB,MAAM,QAAQ,EAAE;GAC7C;IACE;;AAEb"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ModalBackgroundContext } from "../../Modal/ModalBackgroundContext.js";
|
|
3
3
|
import { usePreventScroll } from "./usePreventScroll.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import { useContext, useRef } from "react";
|
|
5
|
+
import { useContext, useEffect, useRef } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { DismissButton, Overlay } from "react-aria/Overlay";
|
|
8
8
|
import { usePopover } from "react-aria/usePopover";
|
|
@@ -30,6 +30,24 @@ function Popover(props) {
|
|
|
30
30
|
toggle: _empty
|
|
31
31
|
});
|
|
32
32
|
usePreventScroll(useContext(ModalBackgroundContext), props.isOpen);
|
|
33
|
+
const { isOpen, onClose } = props;
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!isOpen) return;
|
|
36
|
+
const handlePointerUp = (e) => {
|
|
37
|
+
if (e.pointerType !== "pen") return;
|
|
38
|
+
const popover = finalPopoverRef.current;
|
|
39
|
+
if (popover !== null && e.composedPath().includes(popover)) return;
|
|
40
|
+
onClose();
|
|
41
|
+
};
|
|
42
|
+
document.addEventListener("pointerup", handlePointerUp, true);
|
|
43
|
+
return () => {
|
|
44
|
+
document.removeEventListener("pointerup", handlePointerUp, true);
|
|
45
|
+
};
|
|
46
|
+
}, [
|
|
47
|
+
isOpen,
|
|
48
|
+
onClose,
|
|
49
|
+
finalPopoverRef
|
|
50
|
+
]);
|
|
33
51
|
if (!props.isOpen) return null;
|
|
34
52
|
return /* @__PURE__ */ jsxs(Overlay, {
|
|
35
53
|
portalContainer: document.body,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.js","names":[
|
|
1
|
+
{"version":3,"file":"index2.js","names":[],"sources":["../../../../src/components/DropdownSelector/Popover/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { RefObject, useContext, useEffect, useRef, ReactNode } from 'react'\nimport { ModalBackgroundContext } from '../../Modal/ModalBackgroundContext'\nimport { usePreventScroll } from './usePreventScroll'\nimport { DismissButton, Overlay } from 'react-aria/Overlay'\nimport { usePopover } from 'react-aria/usePopover'\n\nexport type PopoverProps = {\n isOpen: boolean\n onClose: () => void\n children: ReactNode\n triggerRef: RefObject<Element | null>\n popoverRef?: RefObject<HTMLDivElement | null>\n /**\n * A tmp workaround for react-aria above 3.27.3 setting overlay element to inert and causing background to be clickable.\n * This may become default at next major.\n * https://github.com/adobe/react-spectrum/pull/8796\n * https://github.com/adobe/react-spectrum/issues/8784\n *\n * @default false\n */\n inertWorkaround?: boolean\n}\n\nconst _empty = () => null\n\n/**\n * 画面の全面に動的に開くことができるコンテナ要素\n * 外の要素をクリックしたり、内部からフォーカスを移動した場合に自動的に閉じる\n *\n * triggerRefの付近に画面内に収まるように表示される\n */\nexport default function Popover(props: PopoverProps) {\n const defaultPopoverRef = useRef<HTMLDivElement>(null)\n const finalPopoverRef =\n props.popoverRef === undefined ? defaultPopoverRef : props.popoverRef\n const { popoverProps, underlayProps } = usePopover(\n {\n triggerRef: props.triggerRef,\n popoverRef: finalPopoverRef,\n containerPadding: 16,\n },\n {\n close: props.onClose,\n isOpen: props.isOpen,\n // never used\n open: _empty,\n setOpen: _empty,\n toggle: _empty,\n },\n )\n\n const modalBackground = useContext(ModalBackgroundContext)\n usePreventScroll(modalBackground, props.isOpen)\n\n // iOS Safari は非インタラクティブな要素へのペン入力で click を合成しないため、\n // click に依存する react-aria の外側判定ではペンで閉じられない。\n // underlay 側では拾えない: react-aria が modal 時に外側を inert にするので\n // underlay 自身がイベントを受け取らなくなる。\n const { isOpen, onClose } = props\n useEffect(() => {\n if (!isOpen) return\n const handlePointerUp = (e: PointerEvent) => {\n if (e.pointerType !== 'pen') return\n const popover = finalPopoverRef.current\n if (popover !== null && e.composedPath().includes(popover)) return\n onClose()\n }\n document.addEventListener('pointerup', handlePointerUp, true)\n return () => {\n document.removeEventListener('pointerup', handlePointerUp, true)\n }\n }, [isOpen, onClose, finalPopoverRef])\n\n if (!props.isOpen) return null\n\n return (\n <Overlay portalContainer={document.body}>\n <div\n {...underlayProps}\n // https://github.com/adobe/react-spectrum/issues/8784#issuecomment-3234771154\n {...(props.inertWorkaround\n ? { 'data-react-aria-top-layer': true, onClick: props.onClose }\n : {})}\n style={{\n position: 'fixed',\n zIndex:\n typeof popoverProps.style?.zIndex === 'number'\n ? popoverProps.style.zIndex - 1\n : 99999,\n inset: 0,\n }}\n />\n {/* @ts-expect-error react types we use does not support react 19 types yet */}\n <div {...popoverProps} ref={finalPopoverRef} className=\"charcoal-popover\">\n <DismissButton onDismiss={() => props.onClose()} />\n <div tabIndex={0} onFocus={props.onClose} />\n {props.children}\n <div tabIndex={0} onFocus={props.onClose} />\n <DismissButton onDismiss={() => props.onClose()} />\n </div>\n </Overlay>\n )\n}\n"],"mappings":";;;;;;;;;;AAyBA,MAAM,eAAe;;;;;;;AAQrB,SAAwB,QAAQ,OAAqB;CACnD,MAAM,oBAAoB,OAAuB,IAAI;CACrD,MAAM,kBACJ,MAAM,eAAe,SAAY,oBAAoB,MAAM;CAC7D,MAAM,EAAE,cAAc,kBAAkB,WACtC;EACE,YAAY,MAAM;EAClB,YAAY;EACZ,kBAAkB;CACpB,GACA;EACE,OAAO,MAAM;EACb,QAAQ,MAAM;EAEd,MAAM;EACN,SAAS;EACT,QAAQ;CACV,CACF;CAGA,iBADwB,WAAW,sBAClB,GAAiB,MAAM,MAAM;CAM9C,MAAM,EAAE,QAAQ,YAAY;CAC5B,gBAAgB;EACd,IAAI,CAAC,QAAQ;EACb,MAAM,mBAAmB,MAAoB;GAC3C,IAAI,EAAE,gBAAgB,OAAO;GAC7B,MAAM,UAAU,gBAAgB;GAChC,IAAI,YAAY,QAAQ,EAAE,aAAa,CAAC,CAAC,SAAS,OAAO,GAAG;GAC5D,QAAQ;EACV;EACA,SAAS,iBAAiB,aAAa,iBAAiB,IAAI;EAC5D,aAAa;GACX,SAAS,oBAAoB,aAAa,iBAAiB,IAAI;EACjE;CACF,GAAG;EAAC;EAAQ;EAAS;CAAe,CAAC;CAErC,IAAI,CAAC,MAAM,QAAQ,OAAO;CAE1B,OACE,qBAAC,SAAD;EAAS,iBAAiB,SAAS;YAAnC,CACE,oBAAC,OAAD;GACE,GAAI;GAEJ,GAAK,MAAM,kBACP;IAAE,6BAA6B;IAAM,SAAS,MAAM;GAAQ,IAC5D,CAAC;GACL,OAAO;IACL,UAAU;IACV,QACE,OAAO,aAAa,OAAO,WAAW,WAClC,aAAa,MAAM,SAAS,IAC5B;IACN,OAAO;GACT;EAAE,IAGJ,qBAAC,OAAD;GAAK,GAAI;GAAc,KAAK;GAAiB,WAAU;aAAvD;IACE,oBAAC,eAAD,EAAe,iBAAiB,MAAM,QAAQ,EAAE;IAChD,oBAAC,OAAD;KAAK,UAAU;KAAG,SAAS,MAAM;IAAQ;IACxC,MAAM;IACP,oBAAC,OAAD;KAAK,UAAU;KAAG,SAAS,MAAM;IAAQ;IACzC,oBAAC,eAAD,EAAe,iBAAiB,MAAM,QAAQ,EAAE;GAC7C;IACE;;AAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreventScroll.cjs","names":[
|
|
1
|
+
{"version":3,"file":"usePreventScroll.cjs","names":[],"sources":["../../../../src/components/DropdownSelector/Popover/usePreventScroll.tsx"],"sourcesContent":["import { useEffect } from 'react'\n\nexport function usePreventScroll(\n element: HTMLElement | null,\n isOpen: boolean,\n useClip = false,\n) {\n useEffect(() => {\n if (isOpen && element) {\n const defaultPaddingRight = element.style.paddingRight\n const defaultOverflow = element.style.overflow\n // eslint-disable-next-line react-compiler/react-compiler\n element.style.paddingRight = `${\n window.innerWidth - element.clientWidth\n }px`\n element.style.overflow = useClip ? 'clip' : 'hidden'\n return () => {\n element.style.paddingRight = defaultPaddingRight\n element.style.overflow = defaultOverflow\n }\n }\n }, [element, isOpen, useClip])\n}\n"],"mappings":";;;;AAEA,SAAgB,iBACd,SACA,QACA,UAAU,OACV;CACA,2BAAgB;EACd,IAAI,UAAU,SAAS;GACrB,MAAM,sBAAsB,QAAQ,MAAM;GAC1C,MAAM,kBAAkB,QAAQ,MAAM;GAEtC,QAAQ,MAAM,eAAe,GAC3B,OAAO,aAAa,QAAQ,YAAW;GAEzC,QAAQ,MAAM,WAAW,UAAU,SAAS;GAC5C,aAAa;IACX,QAAQ,MAAM,eAAe;IAC7B,QAAQ,MAAM,WAAW;GAC3B;EACF;CACF,GAAG;EAAC;EAAS;EAAQ;CAAO,CAAC;AAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreventScroll.js","names":[
|
|
1
|
+
{"version":3,"file":"usePreventScroll.js","names":[],"sources":["../../../../src/components/DropdownSelector/Popover/usePreventScroll.tsx"],"sourcesContent":["import { useEffect } from 'react'\n\nexport function usePreventScroll(\n element: HTMLElement | null,\n isOpen: boolean,\n useClip = false,\n) {\n useEffect(() => {\n if (isOpen && element) {\n const defaultPaddingRight = element.style.paddingRight\n const defaultOverflow = element.style.overflow\n // eslint-disable-next-line react-compiler/react-compiler\n element.style.paddingRight = `${\n window.innerWidth - element.clientWidth\n }px`\n element.style.overflow = useClip ? 'clip' : 'hidden'\n return () => {\n element.style.paddingRight = defaultPaddingRight\n element.style.overflow = defaultOverflow\n }\n }\n }, [element, isOpen, useClip])\n}\n"],"mappings":";;;;AAEA,SAAgB,iBACd,SACA,QACA,UAAU,OACV;CACA,gBAAgB;EACd,IAAI,UAAU,SAAS;GACrB,MAAM,sBAAsB,QAAQ,MAAM;GAC1C,MAAM,kBAAkB,QAAQ,MAAM;GAEtC,QAAQ,MAAM,eAAe,GAC3B,OAAO,aAAa,QAAQ,YAAW;GAEzC,QAAQ,MAAM,WAAW,UAAU,SAAS;GAC5C,aAAa;IACX,QAAQ,MAAM,eAAe;IAC7B,QAAQ,MAAM,WAAW;GAC3B;EACF;CACF,GAAG;EAAC;EAAS;EAAQ;CAAO,CAAC;AAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownSelector/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,EAAE,SAAS,EAA0C,MAAM,OAAO,CAAA;AAKhF,OAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAIvD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAKxC,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CACzC,GAAG,IAAI,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAA;AAEzC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,QAAQ,EACR,SAAiB,EACjB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownSelector/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,EAAE,SAAS,EAA0C,MAAM,OAAO,CAAA;AAKhF,OAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAIvD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAKxC,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CACzC,GAAG,IAAI,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAA;AAEzC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,QAAQ,EACR,SAAiB,EACjB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,qBAAqB,2CA+IvB"}
|
|
@@ -10,7 +10,7 @@ const require_findPreviewRecursive = require('./utils/findPreviewRecursive.cjs')
|
|
|
10
10
|
const require_getValuesRecursive = require('./MenuList/internals/getValuesRecursive.cjs');
|
|
11
11
|
const require_index$4 = require('./MenuList/index2.cjs');
|
|
12
12
|
let react = require("react");
|
|
13
|
-
react = require_runtime.__toESM(react);
|
|
13
|
+
react = require_runtime.__toESM(react, 1);
|
|
14
14
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
15
15
|
let react_aria_useId = require("react-aria/useId");
|
|
16
16
|
let react_aria_VisuallyHidden = require("react-aria/VisuallyHidden");
|
|
@@ -18,6 +18,7 @@ let react_aria_VisuallyHidden = require("react-aria/VisuallyHidden");
|
|
|
18
18
|
//#region src/components/DropdownSelector/index.tsx
|
|
19
19
|
function DropdownSelector({ onChange, showLabel = false, selectRef, ...props }) {
|
|
20
20
|
const triggerRef = (0, react.useRef)(null);
|
|
21
|
+
const penHandledRef = (0, react.useRef)(false);
|
|
21
22
|
const [isOpen, setIsOpen] = (0, react.useState)(false);
|
|
22
23
|
const preview = require_findPreviewRecursive.findPreviewRecursive(props.children, props.value);
|
|
23
24
|
const isPlaceholder = (0, react.useMemo)(() => props.placeholder !== void 0 && preview === void 0, [preview, props.placeholder]);
|
|
@@ -27,6 +28,27 @@ function DropdownSelector({ onChange, showLabel = false, selectRef, ...props })
|
|
|
27
28
|
const handleChange = (0, react.useCallback)((e) => {
|
|
28
29
|
onChange(e.target.value);
|
|
29
30
|
}, [onChange]);
|
|
31
|
+
const handleClose = (0, react.useCallback)(() => {
|
|
32
|
+
setIsOpen(false);
|
|
33
|
+
}, []);
|
|
34
|
+
const handleSelect = (0, react.useCallback)((v) => {
|
|
35
|
+
onChange(v);
|
|
36
|
+
setIsOpen(false);
|
|
37
|
+
}, [onChange]);
|
|
38
|
+
const handleTriggerPointerUp = (0, react.useCallback)((e) => {
|
|
39
|
+
if (e.pointerType !== "pen") return;
|
|
40
|
+
if (props.disabled === true) return;
|
|
41
|
+
penHandledRef.current = true;
|
|
42
|
+
setIsOpen(true);
|
|
43
|
+
}, [props.disabled]);
|
|
44
|
+
const handleTriggerClick = (0, react.useCallback)(() => {
|
|
45
|
+
if (penHandledRef.current) {
|
|
46
|
+
penHandledRef.current = false;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (props.disabled === true) return;
|
|
50
|
+
setIsOpen(true);
|
|
51
|
+
}, [props.disabled]);
|
|
30
52
|
const labelId = (0, react_aria_useId.useId)();
|
|
31
53
|
const describedbyId = (0, react_aria_useId.useId)();
|
|
32
54
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -68,10 +90,8 @@ function DropdownSelector({ onChange, showLabel = false, selectRef, ...props })
|
|
|
68
90
|
"aria-invalid": props.invalid,
|
|
69
91
|
"aria-describedby": props.assistiveText !== void 0 ? describedbyId : void 0,
|
|
70
92
|
disabled: props.disabled,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
setIsOpen(true);
|
|
74
|
-
},
|
|
93
|
+
onPointerUp: handleTriggerPointerUp,
|
|
94
|
+
onClick: handleTriggerClick,
|
|
75
95
|
ref: triggerRef,
|
|
76
96
|
type: "button",
|
|
77
97
|
"data-active": isOpen,
|
|
@@ -86,16 +106,13 @@ function DropdownSelector({ onChange, showLabel = false, selectRef, ...props })
|
|
|
86
106
|
}),
|
|
87
107
|
isOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_DropdownPopover.DropdownPopover, {
|
|
88
108
|
isOpen,
|
|
89
|
-
onClose:
|
|
109
|
+
onClose: handleClose,
|
|
90
110
|
triggerRef,
|
|
91
111
|
value: props.value,
|
|
92
112
|
inertWorkaround: props.inertWorkaround,
|
|
93
113
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$4.default, {
|
|
94
114
|
value: props.value,
|
|
95
|
-
onChange:
|
|
96
|
-
onChange(v);
|
|
97
|
-
setIsOpen(false);
|
|
98
|
-
},
|
|
115
|
+
onChange: handleSelect,
|
|
99
116
|
children: props.children
|
|
100
117
|
})
|
|
101
118
|
}),
|