@charcoal-ui/react 6.0.0-rc.7 → 6.0.0-rc.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/dist/_lib/createDivComponent.cjs +20 -0
  2. package/dist/_lib/createDivComponent.cjs.map +1 -0
  3. package/dist/_lib/createDivComponent.js +19 -0
  4. package/dist/_lib/createDivComponent.js.map +1 -0
  5. package/dist/_lib/index.cjs +22 -0
  6. package/dist/_lib/index.cjs.map +1 -0
  7. package/dist/_lib/index.js +20 -0
  8. package/dist/_lib/index.js.map +1 -0
  9. package/dist/_lib/useClassNames.cjs +15 -0
  10. package/dist/_lib/useClassNames.cjs.map +1 -0
  11. package/dist/_lib/useClassNames.js +14 -0
  12. package/dist/_lib/useClassNames.js.map +1 -0
  13. package/dist/_lib/useForwardedRef.cjs +19 -0
  14. package/dist/_lib/useForwardedRef.cjs.map +1 -0
  15. package/dist/_lib/useForwardedRef.js +17 -0
  16. package/dist/_lib/useForwardedRef.js.map +1 -0
  17. package/dist/_lib/useIsomorphicLayoutEffect.cjs +13 -0
  18. package/dist/_lib/useIsomorphicLayoutEffect.cjs.map +1 -0
  19. package/dist/_lib/useIsomorphicLayoutEffect.js +12 -0
  20. package/dist/_lib/useIsomorphicLayoutEffect.js.map +1 -0
  21. package/dist/_virtual/_rolldown/runtime.cjs +30 -0
  22. package/dist/components/Button/index2.cjs +26 -0
  23. package/dist/components/Button/index2.cjs.map +1 -0
  24. package/dist/components/Button/index2.js +24 -0
  25. package/dist/components/Button/index2.js.map +1 -0
  26. package/dist/components/Carousel/CarouselItem.cjs +46 -0
  27. package/dist/components/Carousel/CarouselItem.cjs.map +1 -0
  28. package/dist/components/Carousel/CarouselItem.js +45 -0
  29. package/dist/components/Carousel/CarouselItem.js.map +1 -0
  30. package/dist/components/Carousel/carouselStore.cjs +38 -0
  31. package/dist/components/Carousel/carouselStore.cjs.map +1 -0
  32. package/dist/components/Carousel/carouselStore.js +37 -0
  33. package/dist/components/Carousel/carouselStore.js.map +1 -0
  34. package/dist/components/Carousel/index2.cjs +145 -0
  35. package/dist/components/Carousel/index2.cjs.map +1 -0
  36. package/dist/components/Carousel/index2.js +144 -0
  37. package/dist/components/Carousel/index2.js.map +1 -0
  38. package/dist/components/Carousel/intersectionObserver.cjs +46 -0
  39. package/dist/components/Carousel/intersectionObserver.cjs.map +1 -0
  40. package/dist/components/Carousel/intersectionObserver.js +45 -0
  41. package/dist/components/Carousel/intersectionObserver.js.map +1 -0
  42. package/dist/components/Carousel/resizeObserver.cjs +34 -0
  43. package/dist/components/Carousel/resizeObserver.cjs.map +1 -0
  44. package/dist/components/Carousel/resizeObserver.js +33 -0
  45. package/dist/components/Carousel/resizeObserver.js.map +1 -0
  46. package/dist/components/Carousel/store.cjs +24 -0
  47. package/dist/components/Carousel/store.cjs.map +1 -0
  48. package/dist/components/Carousel/store.js +23 -0
  49. package/dist/components/Carousel/store.js.map +1 -0
  50. package/dist/components/Carousel/useCarouselScroller.cjs +149 -0
  51. package/dist/components/Carousel/useCarouselScroller.cjs.map +1 -0
  52. package/dist/components/Carousel/useCarouselScroller.js +148 -0
  53. package/dist/components/Carousel/useCarouselScroller.js.map +1 -0
  54. package/dist/components/Checkbox/CheckboxInput/index2.cjs +29 -0
  55. package/dist/components/Checkbox/CheckboxInput/index2.cjs.map +1 -0
  56. package/dist/components/Checkbox/CheckboxInput/index2.js +28 -0
  57. package/dist/components/Checkbox/CheckboxInput/index2.js.map +1 -0
  58. package/dist/components/Checkbox/CheckboxWithLabel.cjs +23 -0
  59. package/dist/components/Checkbox/CheckboxWithLabel.cjs.map +1 -0
  60. package/dist/components/Checkbox/CheckboxWithLabel.js +21 -0
  61. package/dist/components/Checkbox/CheckboxWithLabel.js.map +1 -0
  62. package/dist/components/Checkbox/index2.cjs +34 -0
  63. package/dist/components/Checkbox/index2.cjs.map +1 -0
  64. package/dist/components/Checkbox/index2.js +33 -0
  65. package/dist/components/Checkbox/index2.js.map +1 -0
  66. package/dist/components/Clickable/index2.cjs +21 -0
  67. package/dist/components/Clickable/index2.cjs.map +1 -0
  68. package/dist/components/Clickable/index2.js +19 -0
  69. package/dist/components/Clickable/index2.js.map +1 -0
  70. package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs +44 -0
  71. package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs.map +1 -0
  72. package/dist/components/DropdownSelector/DropdownMenuItem/index2.js +43 -0
  73. package/dist/components/DropdownSelector/DropdownMenuItem/index2.js.map +1 -0
  74. package/dist/components/DropdownSelector/DropdownPopover.cjs +41 -0
  75. package/dist/components/DropdownSelector/DropdownPopover.cjs.map +1 -0
  76. package/dist/components/DropdownSelector/DropdownPopover.js +40 -0
  77. package/dist/components/DropdownSelector/DropdownPopover.js.map +1 -0
  78. package/dist/components/DropdownSelector/ListItem/index2.cjs +19 -0
  79. package/dist/components/DropdownSelector/ListItem/index2.cjs.map +1 -0
  80. package/dist/components/DropdownSelector/ListItem/index2.js +18 -0
  81. package/dist/components/DropdownSelector/ListItem/index2.js.map +1 -0
  82. package/dist/components/DropdownSelector/MenuItem/index.cjs +30 -0
  83. package/dist/components/DropdownSelector/MenuItem/index.cjs.map +1 -0
  84. package/dist/components/DropdownSelector/MenuItem/index.js +29 -0
  85. package/dist/components/DropdownSelector/MenuItem/index.js.map +1 -0
  86. package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.cjs +30 -0
  87. package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.cjs.map +1 -0
  88. package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.js +29 -0
  89. package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.js.map +1 -0
  90. package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs +53 -0
  91. package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs.map +1 -0
  92. package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.js +52 -0
  93. package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.js.map +1 -0
  94. package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs +20 -0
  95. package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs.map +1 -0
  96. package/dist/components/DropdownSelector/MenuItemGroup/index2.js +19 -0
  97. package/dist/components/DropdownSelector/MenuItemGroup/index2.js.map +1 -0
  98. package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs +15 -0
  99. package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs.map +1 -0
  100. package/dist/components/DropdownSelector/MenuList/MenuListContext.js +14 -0
  101. package/dist/components/DropdownSelector/MenuList/MenuListContext.js.map +1 -0
  102. package/dist/components/DropdownSelector/MenuList/index2.cjs +32 -0
  103. package/dist/components/DropdownSelector/MenuList/index2.cjs.map +1 -0
  104. package/dist/components/DropdownSelector/MenuList/index2.js +31 -0
  105. package/dist/components/DropdownSelector/MenuList/index2.js.map +1 -0
  106. package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs +34 -0
  107. package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs.map +1 -0
  108. package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.js +32 -0
  109. package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.js.map +1 -0
  110. package/dist/components/DropdownSelector/Popover/index2.cjs +71 -0
  111. package/dist/components/DropdownSelector/Popover/index2.cjs.map +1 -0
  112. package/dist/components/DropdownSelector/Popover/index2.js +70 -0
  113. package/dist/components/DropdownSelector/Popover/index2.js.map +1 -0
  114. package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs +27 -0
  115. package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs.map +1 -0
  116. package/dist/components/DropdownSelector/Popover/usePreventScroll.js +26 -0
  117. package/dist/components/DropdownSelector/Popover/usePreventScroll.js.map +1 -0
  118. package/dist/components/DropdownSelector/index2.cjs +113 -0
  119. package/dist/components/DropdownSelector/index2.cjs.map +1 -0
  120. package/dist/components/DropdownSelector/index2.js +111 -0
  121. package/dist/components/DropdownSelector/index2.js.map +1 -0
  122. package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs +34 -0
  123. package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs.map +1 -0
  124. package/dist/components/DropdownSelector/utils/findPreviewRecursive.js +32 -0
  125. package/dist/components/DropdownSelector/utils/findPreviewRecursive.js.map +1 -0
  126. package/dist/components/FieldLabel/index2.cjs +35 -0
  127. package/dist/components/FieldLabel/index2.cjs.map +1 -0
  128. package/dist/components/FieldLabel/index2.js +33 -0
  129. package/dist/components/FieldLabel/index2.js.map +1 -0
  130. package/dist/components/HintText/index2.cjs +25 -0
  131. package/dist/components/HintText/index2.cjs.map +1 -0
  132. package/dist/components/HintText/index2.js +24 -0
  133. package/dist/components/HintText/index2.js.map +1 -0
  134. package/dist/components/Icon/index.cjs +39 -0
  135. package/dist/components/Icon/index.cjs.map +1 -0
  136. package/dist/components/Icon/index.js +37 -0
  137. package/dist/components/Icon/index.js.map +1 -0
  138. package/dist/components/IconButton/index2.cjs +46 -0
  139. package/dist/components/IconButton/index2.cjs.map +1 -0
  140. package/dist/components/IconButton/index2.js +44 -0
  141. package/dist/components/IconButton/index2.js.map +1 -0
  142. package/dist/components/LoadingSpinner/index2.cjs +43 -0
  143. package/dist/components/LoadingSpinner/index2.cjs.map +1 -0
  144. package/dist/components/LoadingSpinner/index2.js +41 -0
  145. package/dist/components/LoadingSpinner/index2.js.map +1 -0
  146. package/dist/components/Modal/Dialog/index2.cjs +30 -0
  147. package/dist/components/Modal/Dialog/index2.cjs.map +1 -0
  148. package/dist/components/Modal/Dialog/index2.js +28 -0
  149. package/dist/components/Modal/Dialog/index2.js.map +1 -0
  150. package/dist/components/Modal/ModalBackgroundContext.cjs +14 -0
  151. package/dist/components/Modal/ModalBackgroundContext.cjs.map +1 -0
  152. package/dist/components/Modal/ModalBackgroundContext.js +12 -0
  153. package/dist/components/Modal/ModalBackgroundContext.js.map +1 -0
  154. package/dist/components/Modal/ModalPlumbing2.cjs +30 -0
  155. package/dist/components/Modal/ModalPlumbing2.cjs.map +1 -0
  156. package/dist/components/Modal/ModalPlumbing2.js +26 -0
  157. package/dist/components/Modal/ModalPlumbing2.js.map +1 -0
  158. package/dist/components/Modal/index2.cjs +121 -0
  159. package/dist/components/Modal/index2.cjs.map +1 -0
  160. package/dist/components/Modal/index2.js +118 -0
  161. package/dist/components/Modal/index2.js.map +1 -0
  162. package/dist/components/Modal/useCustomModalOverlay.cjs +48 -0
  163. package/dist/components/Modal/useCustomModalOverlay.cjs.map +1 -0
  164. package/dist/components/Modal/useCustomModalOverlay.js +45 -0
  165. package/dist/components/Modal/useCustomModalOverlay.js.map +1 -0
  166. package/dist/components/Modal/useTransitionPresence.cjs +57 -0
  167. package/dist/components/Modal/useTransitionPresence.cjs.map +1 -0
  168. package/dist/components/Modal/useTransitionPresence.js +56 -0
  169. package/dist/components/Modal/useTransitionPresence.js.map +1 -0
  170. package/dist/components/MultiSelect/context.cjs +19 -0
  171. package/dist/components/MultiSelect/context.cjs.map +1 -0
  172. package/dist/components/MultiSelect/context.js +18 -0
  173. package/dist/components/MultiSelect/context.js.map +1 -0
  174. package/dist/components/MultiSelect/index2.cjs +97 -0
  175. package/dist/components/MultiSelect/index2.cjs.map +1 -0
  176. package/dist/components/MultiSelect/index2.js +93 -0
  177. package/dist/components/MultiSelect/index2.js.map +1 -0
  178. package/dist/components/Pagination/PaginationContext.cjs +16 -0
  179. package/dist/components/Pagination/PaginationContext.cjs.map +1 -0
  180. package/dist/components/Pagination/PaginationContext.js +14 -0
  181. package/dist/components/Pagination/PaginationContext.js.map +1 -0
  182. package/dist/components/Pagination/helper.cjs +63 -0
  183. package/dist/components/Pagination/helper.cjs.map +1 -0
  184. package/dist/components/Pagination/helper.js +61 -0
  185. package/dist/components/Pagination/helper.js.map +1 -0
  186. package/dist/components/Pagination/index2.cjs +301 -0
  187. package/dist/components/Pagination/index2.cjs.map +1 -0
  188. package/dist/components/Pagination/index2.js +288 -0
  189. package/dist/components/Pagination/index2.js.map +1 -0
  190. package/dist/components/Radio/RadioGroup/index2.cjs +49 -0
  191. package/dist/components/Radio/RadioGroup/index2.cjs.map +1 -0
  192. package/dist/components/Radio/RadioGroup/index2.js +47 -0
  193. package/dist/components/Radio/RadioGroup/index2.js.map +1 -0
  194. package/dist/components/Radio/RadioGroupContext.cjs +20 -0
  195. package/dist/components/Radio/RadioGroupContext.cjs.map +1 -0
  196. package/dist/components/Radio/RadioGroupContext.js +18 -0
  197. package/dist/components/Radio/RadioGroupContext.js.map +1 -0
  198. package/dist/components/Radio/RadioInput/index2.cjs +27 -0
  199. package/dist/components/Radio/RadioInput/index2.cjs.map +1 -0
  200. package/dist/components/Radio/RadioInput/index2.js +26 -0
  201. package/dist/components/Radio/RadioInput/index2.js.map +1 -0
  202. package/dist/components/Radio/index2.cjs +42 -0
  203. package/dist/components/Radio/index2.cjs.map +1 -0
  204. package/dist/components/Radio/index2.js +39 -0
  205. package/dist/components/Radio/index2.js.map +1 -0
  206. package/dist/components/SegmentedControl/RadioGroupContext.cjs +24 -0
  207. package/dist/components/SegmentedControl/RadioGroupContext.cjs.map +1 -0
  208. package/dist/components/SegmentedControl/RadioGroupContext.js +21 -0
  209. package/dist/components/SegmentedControl/RadioGroupContext.js.map +1 -0
  210. package/dist/components/SegmentedControl/index2.cjs +72 -0
  211. package/dist/components/SegmentedControl/index2.cjs.map +1 -0
  212. package/dist/components/SegmentedControl/index2.js +70 -0
  213. package/dist/components/SegmentedControl/index2.js.map +1 -0
  214. package/dist/components/Switch/SwitchInput/index2.cjs +25 -0
  215. package/dist/components/Switch/SwitchInput/index2.cjs.map +1 -0
  216. package/dist/components/Switch/SwitchInput/index2.js +24 -0
  217. package/dist/components/Switch/SwitchInput/index2.js.map +1 -0
  218. package/dist/components/Switch/SwitchWithLabel.cjs +23 -0
  219. package/dist/components/Switch/SwitchWithLabel.cjs.map +1 -0
  220. package/dist/components/Switch/SwitchWithLabel.js +21 -0
  221. package/dist/components/Switch/SwitchWithLabel.js.map +1 -0
  222. package/dist/components/Switch/index2.cjs +37 -0
  223. package/dist/components/Switch/index2.cjs.map +1 -0
  224. package/dist/components/Switch/index2.js +36 -0
  225. package/dist/components/Switch/index2.js.map +1 -0
  226. package/dist/components/TagItem/index2.cjs +57 -0
  227. package/dist/components/TagItem/index2.cjs.map +1 -0
  228. package/dist/components/TagItem/index2.js +55 -0
  229. package/dist/components/TagItem/index2.js.map +1 -0
  230. package/dist/components/TextArea/index2.cjs +134 -0
  231. package/dist/components/TextArea/index2.cjs.map +1 -0
  232. package/dist/components/TextArea/index2.js +133 -0
  233. package/dist/components/TextArea/index2.js.map +1 -0
  234. package/dist/components/TextEllipsis/helper.cjs +31 -0
  235. package/dist/components/TextEllipsis/helper.cjs.map +1 -0
  236. package/dist/components/TextEllipsis/helper.js +30 -0
  237. package/dist/components/TextEllipsis/helper.js.map +1 -0
  238. package/dist/components/TextEllipsis/index2.cjs +119 -0
  239. package/dist/components/TextEllipsis/index2.cjs.map +1 -0
  240. package/dist/components/TextEllipsis/index2.js +114 -0
  241. package/dist/components/TextEllipsis/index2.js.map +1 -0
  242. package/dist/components/TextField/AssistiveText/index2.cjs +10 -0
  243. package/dist/components/TextField/AssistiveText/index2.cjs.map +1 -0
  244. package/dist/components/TextField/AssistiveText/index2.js +10 -0
  245. package/dist/components/TextField/AssistiveText/index2.js.map +1 -0
  246. package/dist/components/TextField/index2.cjs +101 -0
  247. package/dist/components/TextField/index2.cjs.map +1 -0
  248. package/dist/components/TextField/index2.js +100 -0
  249. package/dist/components/TextField/index2.js.map +1 -0
  250. package/dist/components/TextField/useFocusWithClick.cjs +23 -0
  251. package/dist/components/TextField/useFocusWithClick.cjs.map +1 -0
  252. package/dist/components/TextField/useFocusWithClick.js +22 -0
  253. package/dist/components/TextField/useFocusWithClick.js.map +1 -0
  254. package/dist/core/CharcoalProvider.cjs +16 -0
  255. package/dist/core/CharcoalProvider.cjs.map +1 -0
  256. package/dist/core/CharcoalProvider.js +14 -0
  257. package/dist/core/CharcoalProvider.js.map +1 -0
  258. package/dist/core/OverlayProvider.js +4 -0
  259. package/dist/core/SSRProvider.cjs +15 -0
  260. package/dist/core/SSRProvider.cjs.map +1 -0
  261. package/dist/core/SSRProvider.js +14 -0
  262. package/dist/core/SSRProvider.js.map +1 -0
  263. package/dist/core/SetThemeScript.cjs +45 -0
  264. package/dist/core/SetThemeScript.cjs.map +1 -0
  265. package/dist/core/SetThemeScript.js +43 -0
  266. package/dist/core/SetThemeScript.js.map +1 -0
  267. package/dist/core/themeHelper.cjs +154 -0
  268. package/dist/core/themeHelper.cjs.map +1 -0
  269. package/dist/core/themeHelper.js +143 -0
  270. package/dist/core/themeHelper.js.map +1 -0
  271. package/dist/index.cjs +81 -12
  272. package/dist/index.css +799 -799
  273. package/dist/index.js +31 -12
  274. package/dist/layered.css +802 -802
  275. package/dist/layered.css.map +1 -1
  276. package/package.json +5 -5
  277. package/dist/index.cjs.map +0 -1
  278. package/dist/index.js.map +0 -1
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
3
+ const require_index = require('../../Icon/index.cjs');
4
+ const require_MenuListContext = require('../MenuList/MenuListContext.cjs');
5
+ const require_index$1 = require('../MenuItem/index.cjs');
6
+ require('./index.cjs');
7
+ let react = require("react");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+
10
+ //#region src/components/DropdownSelector/DropdownMenuItem/index.tsx
11
+ /**
12
+ * DropdownSelectorの選択肢として使うMenuItem
13
+ */
14
+ function DropdownMenuItem(props) {
15
+ const { value: ctxValue } = (0, react.useContext)(require_MenuListContext.MenuListContext);
16
+ const isSelected = props.value === ctxValue;
17
+ const { children, secondary, ...rest } = props;
18
+ const fullWidthClassName = props.contentFullWidth ? "charcoal-dropdown-selector-menu-fullwidth" : "";
19
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$1.default, {
20
+ ...rest,
21
+ "aria-selected": isSelected,
22
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
23
+ className: fullWidthClassName,
24
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
25
+ className: `charcoal-dropdown-selector-menu-item-container ${fullWidthClassName}`,
26
+ children: [isSelected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, {
27
+ className: "charcoal-dropdown-selector-menu-item-icon",
28
+ name: "16/Check"
29
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
30
+ className: `charcoal-dropdown-selector-menu-item ${fullWidthClassName}`,
31
+ "data-selected": isSelected,
32
+ children
33
+ })]
34
+ }), secondary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
35
+ className: "charcoal-dropdown-selector-menu-secondary",
36
+ children: secondary
37
+ })]
38
+ })
39
+ });
40
+ }
41
+
42
+ //#endregion
43
+ exports.default = DropdownMenuItem;
44
+ //# sourceMappingURL=index2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.cjs","names":["MenuItem","MenuItemProps","MenuListContext","ReactNode","useContext","Icon","DropdownMenuItemProps","Omit","secondary","contentFullWidth","DropdownMenuItem","props","value","ctxValue","isSelected","children","rest","fullWidthClassName"],"sources":["../../../../src/components/DropdownSelector/DropdownMenuItem/index.tsx"],"sourcesContent":["import './index.css'\n\nimport MenuItem, { MenuItemProps } from '../MenuItem'\nimport { MenuListContext } from '../MenuList/MenuListContext'\nimport { ReactNode, useContext } from 'react'\nimport Icon from '../../Icon'\n\nexport type DropdownMenuItemProps = Omit<MenuItemProps, 'as'> & {\n secondary?: ReactNode\n contentFullWidth?: boolean\n}\n\n/**\n * DropdownSelectorの選択肢として使うMenuItem\n */\nexport default function DropdownMenuItem(props: DropdownMenuItemProps) {\n const { value: ctxValue } = useContext(MenuListContext)\n const isSelected = props.value === ctxValue\n const { children, secondary, ...rest } = props\n\n const fullWidthClassName = props.contentFullWidth\n ? 'charcoal-dropdown-selector-menu-fullwidth'\n : ''\n\n return (\n <MenuItem {...rest} aria-selected={isSelected}>\n <div className={fullWidthClassName}>\n <div\n className={`charcoal-dropdown-selector-menu-item-container ${\n fullWidthClassName\n }`}\n >\n {isSelected && (\n <Icon\n className=\"charcoal-dropdown-selector-menu-item-icon\"\n name=\"16/Check\"\n />\n )}\n <span\n className={`charcoal-dropdown-selector-menu-item ${fullWidthClassName}`}\n data-selected={isSelected}\n >\n {children}\n </span>\n </div>\n {secondary && (\n <span className=\"charcoal-dropdown-selector-menu-secondary\">\n {secondary}\n </span>\n )}\n </div>\n </MenuItem>\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,SAAwBU,iBAAiBC,OAA8B;CACrE,MAAM,EAAEC,OAAOC,mCAAwBX,wCAAgB;CACvD,MAAMY,aAAaH,MAAMC,UAAUC;CACnC,MAAM,EAAEE,UAAUP,WAAW,GAAGQ,SAASL;CAEzC,MAAMM,qBAAqBN,MAAMF,mBAC7B,8CACA;CAEJ,OACE,2CAAC,yBAAD;EAAU,GAAIO;EAAM,iBAAeF;YACjC,4CAAC,OAAD;GAAK,WAAWG;aAAhB,CACE,4CAAC,OAAD;IACE,WAAW,kDACTA;cAFJ,CAKGH,cACC,2CAAC,uBAAD;KACE,WAAU;KACV,MAAK;KAER,GACD,2CAAC,QAAD;KACE,WAAW,wCAAwCG;KACnD,iBAAeH;KAEdC;KACG,EACH;OACJP,aACC,2CAAC,QAAD;IAAM,WAAU;cACbA;IAEJ,EACE;;EACI"}
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import Icon from "../../Icon/index.js";
3
+ import { MenuListContext } from "../MenuList/MenuListContext.js";
4
+ import MenuItem from "../MenuItem/index.js";
5
+ /* empty css */
6
+ import { useContext } from "react";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+
9
+ //#region src/components/DropdownSelector/DropdownMenuItem/index.tsx
10
+ /**
11
+ * DropdownSelectorの選択肢として使うMenuItem
12
+ */
13
+ function DropdownMenuItem(props) {
14
+ const { value: ctxValue } = useContext(MenuListContext);
15
+ const isSelected = props.value === ctxValue;
16
+ const { children, secondary, ...rest } = props;
17
+ const fullWidthClassName = props.contentFullWidth ? "charcoal-dropdown-selector-menu-fullwidth" : "";
18
+ return /* @__PURE__ */ jsx(MenuItem, {
19
+ ...rest,
20
+ "aria-selected": isSelected,
21
+ children: /* @__PURE__ */ jsxs("div", {
22
+ className: fullWidthClassName,
23
+ children: [/* @__PURE__ */ jsxs("div", {
24
+ className: `charcoal-dropdown-selector-menu-item-container ${fullWidthClassName}`,
25
+ children: [isSelected && /* @__PURE__ */ jsx(Icon, {
26
+ className: "charcoal-dropdown-selector-menu-item-icon",
27
+ name: "16/Check"
28
+ }), /* @__PURE__ */ jsx("span", {
29
+ className: `charcoal-dropdown-selector-menu-item ${fullWidthClassName}`,
30
+ "data-selected": isSelected,
31
+ children
32
+ })]
33
+ }), secondary && /* @__PURE__ */ jsx("span", {
34
+ className: "charcoal-dropdown-selector-menu-secondary",
35
+ children: secondary
36
+ })]
37
+ })
38
+ });
39
+ }
40
+
41
+ //#endregion
42
+ export { DropdownMenuItem as default };
43
+ //# sourceMappingURL=index2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.js","names":["MenuItem","MenuItemProps","MenuListContext","ReactNode","useContext","Icon","DropdownMenuItemProps","Omit","secondary","contentFullWidth","DropdownMenuItem","props","value","ctxValue","isSelected","children","rest","fullWidthClassName"],"sources":["../../../../src/components/DropdownSelector/DropdownMenuItem/index.tsx"],"sourcesContent":["import './index.css'\n\nimport MenuItem, { MenuItemProps } from '../MenuItem'\nimport { MenuListContext } from '../MenuList/MenuListContext'\nimport { ReactNode, useContext } from 'react'\nimport Icon from '../../Icon'\n\nexport type DropdownMenuItemProps = Omit<MenuItemProps, 'as'> & {\n secondary?: ReactNode\n contentFullWidth?: boolean\n}\n\n/**\n * DropdownSelectorの選択肢として使うMenuItem\n */\nexport default function DropdownMenuItem(props: DropdownMenuItemProps) {\n const { value: ctxValue } = useContext(MenuListContext)\n const isSelected = props.value === ctxValue\n const { children, secondary, ...rest } = props\n\n const fullWidthClassName = props.contentFullWidth\n ? 'charcoal-dropdown-selector-menu-fullwidth'\n : ''\n\n return (\n <MenuItem {...rest} aria-selected={isSelected}>\n <div className={fullWidthClassName}>\n <div\n className={`charcoal-dropdown-selector-menu-item-container ${\n fullWidthClassName\n }`}\n >\n {isSelected && (\n <Icon\n className=\"charcoal-dropdown-selector-menu-item-icon\"\n name=\"16/Check\"\n />\n )}\n <span\n className={`charcoal-dropdown-selector-menu-item ${fullWidthClassName}`}\n data-selected={isSelected}\n >\n {children}\n </span>\n </div>\n {secondary && (\n <span className=\"charcoal-dropdown-selector-menu-secondary\">\n {secondary}\n </span>\n )}\n </div>\n </MenuItem>\n )\n}\n"],"mappings":";;;;;;;;;;;;AAeA,SAAwBU,iBAAiBC,OAA8B;CACrE,MAAM,EAAEC,OAAOC,aAAaT,WAAWF,gBAAgB;CACvD,MAAMY,aAAaH,MAAMC,UAAUC;CACnC,MAAM,EAAEE,UAAUP,WAAW,GAAGQ,SAASL;CAEzC,MAAMM,qBAAqBN,MAAMF,mBAC7B,8CACA;CAEJ,OACE,oBAAC,UAAD;EAAU,GAAIO;EAAM,iBAAeF;YACjC,qBAAC,OAAD;GAAK,WAAWG;aAAhB,CACE,qBAAC,OAAD;IACE,WAAW,kDACTA;cAFJ,CAKGH,cACC,oBAAC,MAAD;KACE,WAAU;KACV,MAAK;KAER,GACD,oBAAC,QAAD;KACE,WAAW,wCAAwCG;KACnD,iBAAeH;KAEdC;KACG,EACH;OACJP,aACC,oBAAC,QAAD;IAAM,WAAU;cACbA;IAEJ,EACE;;EACI"}
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
+ const require_index = require('./Popover/index2.cjs');
4
+ let react = require("react");
5
+ let react_jsx_runtime = require("react/jsx-runtime");
6
+
7
+ //#region src/components/DropdownSelector/DropdownPopover.tsx
8
+ /**
9
+ * DropdownSelectorの選択肢をを表示するためのPopover
10
+ * triggerRefの要素と同じ幅になる
11
+ * 表示の際にvalueが等しいDropdownMenuItemを中央に表示する
12
+ */
13
+ function DropdownPopover({ children, ...props }) {
14
+ const ref = (0, react.useRef)(null);
15
+ (0, react.useEffect)(() => {
16
+ if (props.isOpen && ref.current && props.triggerRef.current) ref.current.style.width = `${props.triggerRef.current.clientWidth}px`;
17
+ }, [props.triggerRef, props.isOpen]);
18
+ (0, react.useEffect)(() => {
19
+ if (props.isOpen) if (props.value !== void 0 && props.value !== "") {
20
+ const windowScrollY = window.scrollY;
21
+ const windowScrollX = window.scrollX;
22
+ document.querySelector(`[data-key="${props.value.toString()}"]`)?.focus();
23
+ window.scrollTo(windowScrollX, windowScrollY);
24
+ } else {
25
+ const el = ref.current?.querySelector("[role='option']");
26
+ if (el instanceof HTMLElement) el.focus();
27
+ }
28
+ }, [props.value, props.isOpen]);
29
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, {
30
+ isOpen: props.isOpen,
31
+ onClose: props.onClose,
32
+ popoverRef: ref,
33
+ triggerRef: props.triggerRef,
34
+ inertWorkaround: props.inertWorkaround,
35
+ children
36
+ });
37
+ }
38
+
39
+ //#endregion
40
+ exports.DropdownPopover = DropdownPopover;
41
+ //# sourceMappingURL=DropdownPopover.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropdownPopover.cjs","names":["Key","useEffect","useRef","Popover","PopoverProps","DropdownPopoverProps","value","DropdownPopover","children","props","ref","HTMLDivElement","isOpen","current","triggerRef","style","width","clientWidth","undefined","windowScrollY","window","scrollY","windowScrollX","scrollX","selectedElement","document","querySelector","toString","HTMLElement","focus","scrollTo","el","onClose","inertWorkaround"],"sources":["../../../src/components/DropdownSelector/DropdownPopover.tsx"],"sourcesContent":["import { Key, useEffect, useRef } from 'react'\nimport Popover, { PopoverProps } from './Popover'\n\ntype DropdownPopoverProps = PopoverProps & {\n value?: Key\n}\n\n/**\n * DropdownSelectorの選択肢をを表示するためのPopover\n * triggerRefの要素と同じ幅になる\n * 表示の際にvalueが等しいDropdownMenuItemを中央に表示する\n */\nexport function DropdownPopover({ children, ...props }: DropdownPopoverProps) {\n const ref = useRef<HTMLDivElement>(null)\n useEffect(() => {\n if (props.isOpen && ref.current && props.triggerRef.current) {\n ref.current.style.width = `${props.triggerRef.current.clientWidth}px`\n }\n }, [props.triggerRef, props.isOpen])\n\n useEffect(() => {\n if (props.isOpen) {\n if (props.value !== undefined && props.value !== '') {\n // windowのスクロールを維持したまま選択肢をPopoverの中心に表示する\n const windowScrollY = window.scrollY\n const windowScrollX = window.scrollX\n const selectedElement = document.querySelector(\n `[data-key=\"${props.value.toString()}\"]`,\n ) as HTMLElement | undefined\n selectedElement?.focus()\n window.scrollTo(windowScrollX, windowScrollY)\n } else {\n const el = ref.current?.querySelector(\"[role='option']\")\n if (el instanceof HTMLElement) {\n el.focus()\n }\n }\n }\n }, [props.value, props.isOpen])\n\n return (\n <Popover\n isOpen={props.isOpen}\n onClose={props.onClose}\n popoverRef={ref}\n triggerRef={props.triggerRef}\n inertWorkaround={props.inertWorkaround}\n >\n {children}\n </Popover>\n )\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgBO,gBAAgB,EAAEC,UAAU,GAAGC,SAA+B;CAC5E,MAAMC,wBAA6B,KAAK;CACxCT,2BAAgB;EACd,IAAIQ,MAAMG,UAAUF,IAAIG,WAAWJ,MAAMK,WAAWD,SAClDH,IAAIG,QAAQE,MAAMC,QAAQ,GAAGP,MAAMK,WAAWD,QAAQI,YAAW;IAElE,CAACR,MAAMK,YAAYL,MAAMG,OAAO,CAAC;CAEpCX,2BAAgB;EACd,IAAIQ,MAAMG,QACR,IAAIH,MAAMH,UAAUY,UAAaT,MAAMH,UAAU,IAAI;GAEnD,MAAMa,gBAAgBC,OAAOC;GAC7B,MAAMC,gBAAgBF,OAAOG;GAI7BC,AAHwBC,SAASC,cAC/B,cAAcjB,MAAMH,MAAMqB,UAAU,CAAA,IAEvB,EAAEE,OAAO;GACxBT,OAAOU,SAASR,eAAeH,cAAc;SACxC;GACL,MAAMY,KAAKrB,IAAIG,SAASa,cAAc,kBAAkB;GACxD,IAAIK,cAAcH,aAChBG,GAAGF,OAAO;;IAIf,CAACpB,MAAMH,OAAOG,MAAMG,OAAO,CAAC;CAE/B,OACE,2CAAC,uBAAD;EACE,QAAQH,MAAMG;EACd,SAASH,MAAMuB;EACf,YAAYtB;EACZ,YAAYD,MAAMK;EAClB,iBAAiBL,MAAMwB;EAEtBzB;EACO"}
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import Popover from "./Popover/index2.js";
3
+ import { useEffect, useRef } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+
6
+ //#region src/components/DropdownSelector/DropdownPopover.tsx
7
+ /**
8
+ * DropdownSelectorの選択肢をを表示するためのPopover
9
+ * triggerRefの要素と同じ幅になる
10
+ * 表示の際にvalueが等しいDropdownMenuItemを中央に表示する
11
+ */
12
+ function DropdownPopover({ children, ...props }) {
13
+ const ref = useRef(null);
14
+ useEffect(() => {
15
+ if (props.isOpen && ref.current && props.triggerRef.current) ref.current.style.width = `${props.triggerRef.current.clientWidth}px`;
16
+ }, [props.triggerRef, props.isOpen]);
17
+ useEffect(() => {
18
+ if (props.isOpen) if (props.value !== void 0 && props.value !== "") {
19
+ const windowScrollY = window.scrollY;
20
+ const windowScrollX = window.scrollX;
21
+ document.querySelector(`[data-key="${props.value.toString()}"]`)?.focus();
22
+ window.scrollTo(windowScrollX, windowScrollY);
23
+ } else {
24
+ const el = ref.current?.querySelector("[role='option']");
25
+ if (el instanceof HTMLElement) el.focus();
26
+ }
27
+ }, [props.value, props.isOpen]);
28
+ return /* @__PURE__ */ jsx(Popover, {
29
+ isOpen: props.isOpen,
30
+ onClose: props.onClose,
31
+ popoverRef: ref,
32
+ triggerRef: props.triggerRef,
33
+ inertWorkaround: props.inertWorkaround,
34
+ children
35
+ });
36
+ }
37
+
38
+ //#endregion
39
+ export { DropdownPopover };
40
+ //# sourceMappingURL=DropdownPopover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropdownPopover.js","names":["Key","useEffect","useRef","Popover","PopoverProps","DropdownPopoverProps","value","DropdownPopover","children","props","ref","HTMLDivElement","isOpen","current","triggerRef","style","width","clientWidth","undefined","windowScrollY","window","scrollY","windowScrollX","scrollX","selectedElement","document","querySelector","toString","HTMLElement","focus","scrollTo","el","onClose","inertWorkaround"],"sources":["../../../src/components/DropdownSelector/DropdownPopover.tsx"],"sourcesContent":["import { Key, useEffect, useRef } from 'react'\nimport Popover, { PopoverProps } from './Popover'\n\ntype DropdownPopoverProps = PopoverProps & {\n value?: Key\n}\n\n/**\n * DropdownSelectorの選択肢をを表示するためのPopover\n * triggerRefの要素と同じ幅になる\n * 表示の際にvalueが等しいDropdownMenuItemを中央に表示する\n */\nexport function DropdownPopover({ children, ...props }: DropdownPopoverProps) {\n const ref = useRef<HTMLDivElement>(null)\n useEffect(() => {\n if (props.isOpen && ref.current && props.triggerRef.current) {\n ref.current.style.width = `${props.triggerRef.current.clientWidth}px`\n }\n }, [props.triggerRef, props.isOpen])\n\n useEffect(() => {\n if (props.isOpen) {\n if (props.value !== undefined && props.value !== '') {\n // windowのスクロールを維持したまま選択肢をPopoverの中心に表示する\n const windowScrollY = window.scrollY\n const windowScrollX = window.scrollX\n const selectedElement = document.querySelector(\n `[data-key=\"${props.value.toString()}\"]`,\n ) as HTMLElement | undefined\n selectedElement?.focus()\n window.scrollTo(windowScrollX, windowScrollY)\n } else {\n const el = ref.current?.querySelector(\"[role='option']\")\n if (el instanceof HTMLElement) {\n el.focus()\n }\n }\n }\n }, [props.value, props.isOpen])\n\n return (\n <Popover\n isOpen={props.isOpen}\n onClose={props.onClose}\n popoverRef={ref}\n triggerRef={props.triggerRef}\n inertWorkaround={props.inertWorkaround}\n >\n {children}\n </Popover>\n )\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgBO,gBAAgB,EAAEC,UAAU,GAAGC,SAA+B;CAC5E,MAAMC,MAAMR,OAAuB,KAAK;CACxCD,gBAAgB;EACd,IAAIQ,MAAMG,UAAUF,IAAIG,WAAWJ,MAAMK,WAAWD,SAClDH,IAAIG,QAAQE,MAAMC,QAAQ,GAAGP,MAAMK,WAAWD,QAAQI,YAAW;IAElE,CAACR,MAAMK,YAAYL,MAAMG,OAAO,CAAC;CAEpCX,gBAAgB;EACd,IAAIQ,MAAMG,QACR,IAAIH,MAAMH,UAAUY,UAAaT,MAAMH,UAAU,IAAI;GAEnD,MAAMa,gBAAgBC,OAAOC;GAC7B,MAAMC,gBAAgBF,OAAOG;GAI7BC,AAHwBC,SAASC,cAC/B,cAAcjB,MAAMH,MAAMqB,UAAU,CAAA,IAEvB,EAAEE,OAAO;GACxBT,OAAOU,SAASR,eAAeH,cAAc;SACxC;GACL,MAAMY,KAAKrB,IAAIG,SAASa,cAAc,kBAAkB;GACxD,IAAIK,cAAcH,aAChBG,GAAGF,OAAO;;IAIf,CAACpB,MAAMH,OAAOG,MAAMG,OAAO,CAAC;CAE/B,OACE,oBAAC,SAAD;EACE,QAAQH,MAAMG;EACd,SAASH,MAAMuB;EACf,YAAYtB;EACZ,YAAYD,MAAMK;EAClB,iBAAiBL,MAAMwB;EAEtBzB;EACO"}
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
3
+ const require_useClassNames = require('../../../_lib/useClassNames.cjs');
4
+ require('./index.cjs');
5
+ let react = require("react");
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+
8
+ //#region src/components/DropdownSelector/ListItem/index.tsx
9
+ const ListItem = (0, react.forwardRef)(function ListItem({ as, className, ...props }, ref) {
10
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)((0, react.useMemo)(() => as ?? "li", [as]), {
11
+ className: require_useClassNames.useClassNames("charcoal-list-item", className),
12
+ ref,
13
+ ...props
14
+ });
15
+ });
16
+
17
+ //#endregion
18
+ exports.default = ListItem;
19
+ //# sourceMappingURL=index2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.cjs","names":["ForwardedRef","forwardRef","ReactNode","useMemo","JSX","useClassNames","CustomJSXElement","IntrinsicElements","React","JSXElementConstructor","ListItemProps","ElementType","children","as","T","Omit","ComponentPropsWithRef","ListItem","className","props","ref","HTMLLIElement","Component","classNames","p","Element"],"sources":["../../../../src/components/DropdownSelector/ListItem/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { ForwardedRef, forwardRef, ReactNode, useMemo, type JSX } from 'react'\nimport { useClassNames } from '../../../_lib/useClassNames'\n\nexport type CustomJSXElement =\n | keyof JSX.IntrinsicElements\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | React.JSXElementConstructor<any>\n\nexport type ListItemProps<T extends React.ElementType = 'li'> = {\n children?: ReactNode\n as?: T\n} & Omit<React.ComponentPropsWithRef<T>, 'children' | 'as'>\n\nconst ListItem = forwardRef(function ListItem<T extends React.ElementType>(\n { as, className, ...props }: ListItemProps<T>,\n ref: ForwardedRef<HTMLLIElement>,\n) {\n const Component = useMemo(() => as ?? 'li', [as])\n const classNames = useClassNames('charcoal-list-item', className)\n return <Component className={classNames} ref={ref} {...props} />\n}) as <T extends React.ElementType = 'li'>(p: ListItemProps<T>) => JSX.Element\n\nexport default ListItem\n"],"mappings":";;;;;;;;AAeA,MAAMiB,iCAAsB,SAASA,SACnC,EAAEJ,IAAIK,WAAW,GAAGC,SACpBC,KACA;CAGA,OAAO,oEAFyBP,MAAM,MAAM,CAACA,GAAG,CAE/B,EAAV;EAAW,WADCR,oCAAc,sBAAsBa,UAChB;EAAOE;EAAK,GAAID;EAAS;EAChE"}
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { useClassNames } from "../../../_lib/useClassNames.js";
3
+ /* empty css */
4
+ import { forwardRef, useMemo } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/components/DropdownSelector/ListItem/index.tsx
8
+ const ListItem = forwardRef(function ListItem({ as, className, ...props }, ref) {
9
+ return /* @__PURE__ */ jsx(useMemo(() => as ?? "li", [as]), {
10
+ className: useClassNames("charcoal-list-item", className),
11
+ ref,
12
+ ...props
13
+ });
14
+ });
15
+
16
+ //#endregion
17
+ export { ListItem as default };
18
+ //# sourceMappingURL=index2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.js","names":["ForwardedRef","forwardRef","ReactNode","useMemo","JSX","useClassNames","CustomJSXElement","IntrinsicElements","React","JSXElementConstructor","ListItemProps","ElementType","children","as","T","Omit","ComponentPropsWithRef","ListItem","className","props","ref","HTMLLIElement","Component","classNames","p","Element"],"sources":["../../../../src/components/DropdownSelector/ListItem/index.tsx"],"sourcesContent":["import './index.css'\n\nimport { ForwardedRef, forwardRef, ReactNode, useMemo, type JSX } from 'react'\nimport { useClassNames } from '../../../_lib/useClassNames'\n\nexport type CustomJSXElement =\n | keyof JSX.IntrinsicElements\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | React.JSXElementConstructor<any>\n\nexport type ListItemProps<T extends React.ElementType = 'li'> = {\n children?: ReactNode\n as?: T\n} & Omit<React.ComponentPropsWithRef<T>, 'children' | 'as'>\n\nconst ListItem = forwardRef(function ListItem<T extends React.ElementType>(\n { as, className, ...props }: ListItemProps<T>,\n ref: ForwardedRef<HTMLLIElement>,\n) {\n const Component = useMemo(() => as ?? 'li', [as])\n const classNames = useClassNames('charcoal-list-item', className)\n return <Component className={classNames} ref={ref} {...props} />\n}) as <T extends React.ElementType = 'li'>(p: ListItemProps<T>) => JSX.Element\n\nexport default ListItem\n"],"mappings":";;;;;;;AAeA,MAAMiB,WAAWhB,WAAW,SAASgB,SACnC,EAAEJ,IAAIK,WAAW,GAAGC,SACpBC,KACA;CAGA,OAAO,oBAFWjB,cAAcU,MAAM,MAAM,CAACA,GAAG,CAE/B,EAAV;EAAW,WADCR,cAAc,sBAAsBa,UAChB;EAAOE;EAAK,GAAID;EAAS;EAChE"}
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
3
+ const require_index = require('../ListItem/index2.cjs');
4
+ const require_useMenuItemHandleKeyDown = require('./internals/useMenuItemHandleKeyDown.cjs');
5
+ let react = require("react");
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+
8
+ //#region src/components/DropdownSelector/MenuItem/index.tsx
9
+ /**
10
+ * 上下キーでフォーカス移動でき、エンターキーで選択できるリストの項目
11
+ * 基本的に`<MenuList>`, `<MenuGroup>`と合わせて使用する
12
+ */
13
+ const MenuItem = (0, react.forwardRef)(function MenuItem({ className: _, value, disabled, ...props }, ref) {
14
+ const [handleKeyDown, setContextValue] = require_useMenuItemHandleKeyDown.useMenuItemHandleKeyDown(value);
15
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, {
16
+ ...props,
17
+ ref,
18
+ "data-key": value,
19
+ onKeyDown: handleKeyDown,
20
+ onClick: disabled === true ? void 0 : setContextValue,
21
+ tabIndex: -1,
22
+ "aria-disabled": disabled,
23
+ role: "option",
24
+ children: props.children
25
+ });
26
+ });
27
+
28
+ //#endregion
29
+ exports.default = MenuItem;
30
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["ForwardedRef","forwardRef","ListItem","ListItemProps","useMenuItemHandleKeyDown","MenuItemProps","React","ElementType","value","disabled","T","MenuItem","className","_","props","ref","HTMLLIElement","handleKeyDown","setContextValue","undefined","children"],"sources":["../../../../src/components/DropdownSelector/MenuItem/index.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } 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 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 onClick={disabled === true ? undefined : setContextValue}\n tabIndex={-1}\n aria-disabled={disabled}\n role=\"option\"\n >\n {props.children}\n </ListItem>\n )\n})\nexport default MenuItem\n"],"mappings":";;;;;;;;;;;;AAaA,MAAMW,iCAAsB,SAASA,SAGnC,EAAEC,WAAWC,GAAGL,OAAOC,UAAU,GAAGK,SACpCC,KACA;CACA,MAAM,CAACE,eAAeC,mBAAmBd,0DAAyBI,MAAM;CACxE,OAEE,2CAAC,uBAAD;EACE,GAAIM;EACCC;EACL,YAAUP;EACV,WAAWS;EACX,SAASR,aAAa,OAAOU,SAAYD;EACzC,UAAU;EACV,iBAAeT;EACf,MAAK;YAEJK,MAAMM;EACC;EAEZ"}
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import ListItem from "../ListItem/index2.js";
3
+ import { useMenuItemHandleKeyDown } from "./internals/useMenuItemHandleKeyDown.js";
4
+ import { forwardRef } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/components/DropdownSelector/MenuItem/index.tsx
8
+ /**
9
+ * 上下キーでフォーカス移動でき、エンターキーで選択できるリストの項目
10
+ * 基本的に`<MenuList>`, `<MenuGroup>`と合わせて使用する
11
+ */
12
+ const MenuItem = forwardRef(function MenuItem({ className: _, value, disabled, ...props }, ref) {
13
+ const [handleKeyDown, setContextValue] = useMenuItemHandleKeyDown(value);
14
+ return /* @__PURE__ */ jsx(ListItem, {
15
+ ...props,
16
+ ref,
17
+ "data-key": value,
18
+ onKeyDown: handleKeyDown,
19
+ onClick: disabled === true ? void 0 : setContextValue,
20
+ tabIndex: -1,
21
+ "aria-disabled": disabled,
22
+ role: "option",
23
+ children: props.children
24
+ });
25
+ });
26
+
27
+ //#endregion
28
+ export { MenuItem as default };
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ForwardedRef","forwardRef","ListItem","ListItemProps","useMenuItemHandleKeyDown","MenuItemProps","React","ElementType","value","disabled","T","MenuItem","className","_","props","ref","HTMLLIElement","handleKeyDown","setContextValue","undefined","children"],"sources":["../../../../src/components/DropdownSelector/MenuItem/index.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } 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 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 onClick={disabled === true ? undefined : setContextValue}\n tabIndex={-1}\n aria-disabled={disabled}\n role=\"option\"\n >\n {props.children}\n </ListItem>\n )\n})\nexport default MenuItem\n"],"mappings":";;;;;;;;;;;AAaA,MAAMW,WAAWV,WAAW,SAASU,SAGnC,EAAEC,WAAWC,GAAGL,OAAOC,UAAU,GAAGK,SACpCC,KACA;CACA,MAAM,CAACE,eAAeC,mBAAmBd,yBAAyBI,MAAM;CACxE,OAEE,oBAAC,UAAD;EACE,GAAIM;EACCC;EACL,YAAUP;EACV,WAAWS;EACX,SAASR,aAAa,OAAOU,SAAYD;EACzC,UAAU;EACV,iBAAeT;EACf,MAAK;YAEJK,MAAMM;EACC;EAEZ"}
@@ -0,0 +1,30 @@
1
+ "use client";
2
+
3
+ //#region src/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.tsx
4
+ /**
5
+ * elementをparentのスクロールビューに入るようにスクロールする
6
+ * parentがスクロール可能でなければelementが見えるようにスクロールする
7
+ *
8
+ * @param element
9
+ * @param parent
10
+ */
11
+ function handleFocusByKeyBoard(element, parent) {
12
+ if (parent.scrollHeight > parent.clientHeight) {
13
+ const rect = element.getBoundingClientRect();
14
+ const parentRect = parent.getBoundingClientRect();
15
+ if (rect.bottom > parentRect.bottom) parent.scrollTo({ top: parent.scrollTop + rect.bottom - parentRect.bottom });
16
+ else if (rect.top < parentRect.top) parent.scrollTo({ top: parent.scrollTop - (parentRect.top - rect.top) });
17
+ } else scrollIfNeeded(element);
18
+ }
19
+ /**
20
+ * 要素が画面外にあればスクロールする、画面内にあればスクロールしない
21
+ * @param element
22
+ */
23
+ function scrollIfNeeded(element) {
24
+ const elementRect = element.getBoundingClientRect();
25
+ if (!(elementRect.top >= 0 && elementRect.bottom <= (window.innerHeight || document.documentElement.clientHeight))) element.scrollIntoView({ block: "nearest" });
26
+ }
27
+
28
+ //#endregion
29
+ exports.handleFocusByKeyBoard = handleFocusByKeyBoard;
30
+ //# sourceMappingURL=handleFocusByKeyBoard.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleFocusByKeyBoard.cjs","names":["handleFocusByKeyBoard","element","Element","parent","HTMLElement","isScrollable","scrollHeight","clientHeight","rect","getBoundingClientRect","parentRect","bottom","scrollTo","top","scrollTop","scrollIfNeeded","elementRect","isVisible","window","innerHeight","document","documentElement","scrollIntoView","block"],"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,SAAgBA,sBAAsBC,SAAkBE,QAAqB;CAE3E,IADqBA,OAAOG,eAAeH,OAAOI,cAChC;EAChB,MAAMC,OAAOP,QAAQQ,uBAAuB;EAC5C,MAAMC,aAAaP,OAAOM,uBAAuB;EACjD,IAAID,KAAKG,SAASD,WAAWC,QAC3BR,OAAOS,SAAS,EACdC,KAAKV,OAAOW,YAAYN,KAAKG,SAASD,WAAWC,QAClD,CAAC;OACG,IAAIH,KAAKK,MAAMH,WAAWG,KAC/BV,OAAOS,SAAS,EACdC,KAAKV,OAAOW,aAAaJ,WAAWG,MAAML,KAAKK,MAChD,CAAC;QAGJE,eAAed,QAAQ;;;;;;AAQ3B,SAASc,eAAed,SAAkB;CACxC,MAAMe,cAAcf,QAAQQ,uBAAuB;CAMnD,IAAI,EAJFO,YAAYH,OAAO,KACnBG,YAAYL,WACTO,OAAOC,eAAeC,SAASC,gBAAgBd,gBAGlDN,QAAQqB,eAAe,EACrBC,OAAO,WACR,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ //#region src/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.tsx
3
+ /**
4
+ * elementをparentのスクロールビューに入るようにスクロールする
5
+ * parentがスクロール可能でなければelementが見えるようにスクロールする
6
+ *
7
+ * @param element
8
+ * @param parent
9
+ */
10
+ function handleFocusByKeyBoard(element, parent) {
11
+ if (parent.scrollHeight > parent.clientHeight) {
12
+ const rect = element.getBoundingClientRect();
13
+ const parentRect = parent.getBoundingClientRect();
14
+ if (rect.bottom > parentRect.bottom) parent.scrollTo({ top: parent.scrollTop + rect.bottom - parentRect.bottom });
15
+ else if (rect.top < parentRect.top) parent.scrollTo({ top: parent.scrollTop - (parentRect.top - rect.top) });
16
+ } else scrollIfNeeded(element);
17
+ }
18
+ /**
19
+ * 要素が画面外にあればスクロールする、画面内にあればスクロールしない
20
+ * @param element
21
+ */
22
+ function scrollIfNeeded(element) {
23
+ const elementRect = element.getBoundingClientRect();
24
+ if (!(elementRect.top >= 0 && elementRect.bottom <= (window.innerHeight || document.documentElement.clientHeight))) element.scrollIntoView({ block: "nearest" });
25
+ }
26
+
27
+ //#endregion
28
+ export { handleFocusByKeyBoard };
29
+ //# sourceMappingURL=handleFocusByKeyBoard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleFocusByKeyBoard.js","names":["handleFocusByKeyBoard","element","Element","parent","HTMLElement","isScrollable","scrollHeight","clientHeight","rect","getBoundingClientRect","parentRect","bottom","scrollTo","top","scrollTop","scrollIfNeeded","elementRect","isVisible","window","innerHeight","document","documentElement","scrollIntoView","block"],"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,SAAgBA,sBAAsBC,SAAkBE,QAAqB;CAE3E,IADqBA,OAAOG,eAAeH,OAAOI,cAChC;EAChB,MAAMC,OAAOP,QAAQQ,uBAAuB;EAC5C,MAAMC,aAAaP,OAAOM,uBAAuB;EACjD,IAAID,KAAKG,SAASD,WAAWC,QAC3BR,OAAOS,SAAS,EACdC,KAAKV,OAAOW,YAAYN,KAAKG,SAASD,WAAWC,QAClD,CAAC;OACG,IAAIH,KAAKK,MAAMH,WAAWG,KAC/BV,OAAOS,SAAS,EACdC,KAAKV,OAAOW,aAAaJ,WAAWG,MAAML,KAAKK,MAChD,CAAC;QAGJE,eAAed,QAAQ;;;;;;AAQ3B,SAASc,eAAed,SAAkB;CACxC,MAAMe,cAAcf,QAAQQ,uBAAuB;CAMnD,IAAI,EAJFO,YAAYH,OAAO,KACnBG,YAAYL,WACTO,OAAOC,eAAeC,SAASC,gBAAgBd,gBAGlDN,QAAQqB,eAAe,EACrBC,OAAO,WACR,CAAC"}
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ const require_runtime = require('../../../../_virtual/_rolldown/runtime.cjs');
3
+ const require_MenuListContext = require('../../MenuList/MenuListContext.cjs');
4
+ const require_handleFocusByKeyBoard = require('./handleFocusByKeyBoard.cjs');
5
+ let react = require("react");
6
+
7
+ //#region src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx
8
+ /**
9
+ * MenuListContextに含まれるvalue間で上下キーでfocusを移動できる
10
+ * EnterキーでMenuListContextに値を設定する
11
+ * 上記2つの処理を含む処理(handleKeyDown)と、Enterキーを押下した処理(setContextValue)を配列で返す
12
+ * @param value
13
+ * @returns
14
+ */
15
+ function useMenuItemHandleKeyDown(value) {
16
+ const { setValue, root, propsArray } = (0, react.useContext)(require_MenuListContext.MenuListContext);
17
+ const setContextValue = (0, react.useCallback)(() => {
18
+ if (value !== void 0) setValue(value);
19
+ }, [value, setValue]);
20
+ return [(0, react.useCallback)((e) => {
21
+ if (e.key === "Enter") setContextValue();
22
+ else if (e.key === "ArrowUp" || e.key === "ArrowDown") {
23
+ const isForward = e.key === "ArrowDown";
24
+ e.preventDefault();
25
+ if (!propsArray || value === void 0) return;
26
+ const values = propsArray.map((props) => props.value).filter((v) => v);
27
+ let index = values.indexOf(value);
28
+ if (index === -1) return;
29
+ for (let n = 0; n < values.length; n++) {
30
+ const focusValue = isForward ? index + 1 >= values.length ? values[0] : values[index + 1] : index - 1 < 0 ? values[values.length - 1] : values[index - 1];
31
+ const next = root?.current?.querySelector(`[data-key='${focusValue}']`);
32
+ if (next instanceof HTMLElement) {
33
+ if (next.ariaDisabled === "true") {
34
+ index += isForward ? 1 : -1;
35
+ continue;
36
+ }
37
+ next.focus({ preventScroll: true });
38
+ if (root?.current?.parentElement) require_handleFocusByKeyBoard.handleFocusByKeyBoard(next, root.current.parentElement);
39
+ break;
40
+ }
41
+ }
42
+ }
43
+ }, [
44
+ setContextValue,
45
+ propsArray,
46
+ value,
47
+ root
48
+ ]), setContextValue];
49
+ }
50
+
51
+ //#endregion
52
+ exports.useMenuItemHandleKeyDown = useMenuItemHandleKeyDown;
53
+ //# sourceMappingURL=useMenuItemHandleKeyDown.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuItemHandleKeyDown.cjs","names":["useCallback","useContext","handleFocusByKeyBoard","MenuListContext","useMenuItemHandleKeyDown","value","e","React","KeyboardEvent","HTMLElement","setValue","root","propsArray","setContextValue","undefined","handleKeyDown","key","isForward","preventDefault","values","map","props","filter","v","index","indexOf","n","length","focusValue","next","current","querySelector","ariaDisabled","focus","preventScroll","parentElement"],"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,SAAgBI,yBACdC,OAC6D;CAC7D,MAAM,EAAEK,UAAUC,MAAMC,qCAA0BT,wCAAgB;CAClE,MAAMU,+CAAoC;EACxC,IAAIR,UAAUS,QAAWJ,SAASL,MAAM;IACvC,CAACA,OAAOK,SAAS,CAAC;CA+CrB,OAAO,yBA5CJJ,MAAwC;EACvC,IAAIA,EAAEU,QAAQ,SACZH,iBAAiB;OACZ,IAAIP,EAAEU,QAAQ,aAAaV,EAAEU,QAAQ,aAAa;GACvD,MAAMC,YAAYX,EAAEU,QAAQ;GAE5BV,EAAEY,gBAAgB;GAClB,IAAI,CAACN,cAAcP,UAAUS,QAAW;GACxC,MAAMK,SAASP,WACZQ,KAAKC,UAAUA,MAAMhB,MAAM,CAC3BiB,QAAQC,MAAMA,EAAE;GACnB,IAAIC,QAAQL,OAAOM,QAAQpB,MAAM;GACjC,IAAImB,UAAU,IAAI;GAElB,KAAK,IAAIE,IAAI,GAAGA,IAAIP,OAAOQ,QAAQD,KAAK;IACtC,MAAME,aAAaX,YAEfO,QAAQ,KAAKL,OAAOQ,SAClBR,OAAO,KACPA,OAAOK,QAAQ,KAEjBA,QAAQ,IAAI,IACVL,OAAOA,OAAOQ,SAAS,KACvBR,OAAOK,QAAQ;IACrB,MAAMK,OAAOlB,MAAMmB,SAASC,cAC1B,cAAcH,WAAU,IACzB;IAED,IAAIC,gBAAgBpB,aAAa;KAC/B,IAAIoB,KAAKG,iBAAiB,QAAQ;MAChCR,SAASP,YAAY,IAAI;MACzB;;KAEFY,KAAKI,MAAM,EAAEC,eAAe,MAAM,CAAC;KACnC,IAAIvB,MAAMmB,SAASK,eACjBjC,oDAAsB2B,MAAMlB,KAAKmB,QAAQK,cAAc;KAEzD;;;;IAKR;EAACtB;EAAiBD;EAAYP;EAAOM;EACvC,CACqB,EAAEE,gBAAgB"}
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { MenuListContext } from "../../MenuList/MenuListContext.js";
3
+ import { handleFocusByKeyBoard } from "./handleFocusByKeyBoard.js";
4
+ import { useCallback, useContext } from "react";
5
+
6
+ //#region src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx
7
+ /**
8
+ * MenuListContextに含まれるvalue間で上下キーでfocusを移動できる
9
+ * EnterキーでMenuListContextに値を設定する
10
+ * 上記2つの処理を含む処理(handleKeyDown)と、Enterキーを押下した処理(setContextValue)を配列で返す
11
+ * @param value
12
+ * @returns
13
+ */
14
+ function useMenuItemHandleKeyDown(value) {
15
+ const { setValue, root, propsArray } = useContext(MenuListContext);
16
+ const setContextValue = useCallback(() => {
17
+ if (value !== void 0) setValue(value);
18
+ }, [value, setValue]);
19
+ return [useCallback((e) => {
20
+ if (e.key === "Enter") setContextValue();
21
+ else if (e.key === "ArrowUp" || e.key === "ArrowDown") {
22
+ const isForward = e.key === "ArrowDown";
23
+ e.preventDefault();
24
+ if (!propsArray || value === void 0) return;
25
+ const values = propsArray.map((props) => props.value).filter((v) => v);
26
+ let index = values.indexOf(value);
27
+ if (index === -1) return;
28
+ for (let n = 0; n < values.length; n++) {
29
+ const focusValue = isForward ? index + 1 >= values.length ? values[0] : values[index + 1] : index - 1 < 0 ? values[values.length - 1] : values[index - 1];
30
+ const next = root?.current?.querySelector(`[data-key='${focusValue}']`);
31
+ if (next instanceof HTMLElement) {
32
+ if (next.ariaDisabled === "true") {
33
+ index += isForward ? 1 : -1;
34
+ continue;
35
+ }
36
+ next.focus({ preventScroll: true });
37
+ if (root?.current?.parentElement) handleFocusByKeyBoard(next, root.current.parentElement);
38
+ break;
39
+ }
40
+ }
41
+ }
42
+ }, [
43
+ setContextValue,
44
+ propsArray,
45
+ value,
46
+ root
47
+ ]), setContextValue];
48
+ }
49
+
50
+ //#endregion
51
+ export { useMenuItemHandleKeyDown };
52
+ //# sourceMappingURL=useMenuItemHandleKeyDown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMenuItemHandleKeyDown.js","names":["useCallback","useContext","handleFocusByKeyBoard","MenuListContext","useMenuItemHandleKeyDown","value","e","React","KeyboardEvent","HTMLElement","setValue","root","propsArray","setContextValue","undefined","handleKeyDown","key","isForward","preventDefault","values","map","props","filter","v","index","indexOf","n","length","focusValue","next","current","querySelector","ariaDisabled","focus","preventScroll","parentElement"],"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,SAAgBI,yBACdC,OAC6D;CAC7D,MAAM,EAAEK,UAAUC,MAAMC,eAAeX,WAAWE,gBAAgB;CAClE,MAAMU,kBAAkBb,kBAAkB;EACxC,IAAIK,UAAUS,QAAWJ,SAASL,MAAM;IACvC,CAACA,OAAOK,SAAS,CAAC;CA+CrB,OAAO,CA7CeV,aACnBM,MAAwC;EACvC,IAAIA,EAAEU,QAAQ,SACZH,iBAAiB;OACZ,IAAIP,EAAEU,QAAQ,aAAaV,EAAEU,QAAQ,aAAa;GACvD,MAAMC,YAAYX,EAAEU,QAAQ;GAE5BV,EAAEY,gBAAgB;GAClB,IAAI,CAACN,cAAcP,UAAUS,QAAW;GACxC,MAAMK,SAASP,WACZQ,KAAKC,UAAUA,MAAMhB,MAAM,CAC3BiB,QAAQC,MAAMA,EAAE;GACnB,IAAIC,QAAQL,OAAOM,QAAQpB,MAAM;GACjC,IAAImB,UAAU,IAAI;GAElB,KAAK,IAAIE,IAAI,GAAGA,IAAIP,OAAOQ,QAAQD,KAAK;IACtC,MAAME,aAAaX,YAEfO,QAAQ,KAAKL,OAAOQ,SAClBR,OAAO,KACPA,OAAOK,QAAQ,KAEjBA,QAAQ,IAAI,IACVL,OAAOA,OAAOQ,SAAS,KACvBR,OAAOK,QAAQ;IACrB,MAAMK,OAAOlB,MAAMmB,SAASC,cAC1B,cAAcH,WAAU,IACzB;IAED,IAAIC,gBAAgBpB,aAAa;KAC/B,IAAIoB,KAAKG,iBAAiB,QAAQ;MAChCR,SAASP,YAAY,IAAI;MACzB;;KAEFY,KAAKI,MAAM,EAAEC,eAAe,MAAM,CAAC;KACnC,IAAIvB,MAAMmB,SAASK,eACjBjC,sBAAsB2B,MAAMlB,KAAKmB,QAAQK,cAAc;KAEzD;;;;IAKR;EAACtB;EAAiBD;EAAYP;EAAOM;EACvC,CACqB,EAAEE,gBAAgB"}
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
3
+ require('./index.cjs');
4
+ let react_jsx_runtime = require("react/jsx-runtime");
5
+
6
+ //#region src/components/DropdownSelector/MenuItemGroup/index.tsx
7
+ function MenuItemGroup(props) {
8
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
9
+ className: "charcoal-menu-item-group",
10
+ role: "presentation",
11
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: props.text }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
12
+ role: "group",
13
+ children: props.children
14
+ })]
15
+ });
16
+ }
17
+
18
+ //#endregion
19
+ exports.default = MenuItemGroup;
20
+ //# sourceMappingURL=index2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.cjs","names":["MenuItem","Divider","MenuItemGroupChild","React","ReactElement","MenuItemGroupProps","text","children","MenuItemGroup","props"],"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,SAAwBQ,cAAcC,OAA2B;CAC/D,OACE,4CAAC,MAAD;EAAI,WAAU;EAA2B,MAAK;YAA9C,CACE,2CAAC,QAAD,YAAOA,MAAMH,MAAW,GACxB,2CAAC,MAAD;GAAI,MAAK;aAASG,MAAMF;GAAa,EAClC"}
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ /* empty css */
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+
5
+ //#region src/components/DropdownSelector/MenuItemGroup/index.tsx
6
+ function MenuItemGroup(props) {
7
+ return /* @__PURE__ */ jsxs("li", {
8
+ className: "charcoal-menu-item-group",
9
+ role: "presentation",
10
+ children: [/* @__PURE__ */ jsx("span", { children: props.text }), /* @__PURE__ */ jsx("ul", {
11
+ role: "group",
12
+ children: props.children
13
+ })]
14
+ });
15
+ }
16
+
17
+ //#endregion
18
+ export { MenuItemGroup as default };
19
+ //# sourceMappingURL=index2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.js","names":["MenuItem","Divider","MenuItemGroupChild","React","ReactElement","MenuItemGroupProps","text","children","MenuItemGroup","props"],"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,SAAwBQ,cAAcC,OAA2B;CAC/D,OACE,qBAAC,MAAD;EAAI,WAAU;EAA2B,MAAK;YAA9C,CACE,oBAAC,QAAD,YAAOA,MAAMH,MAAW,GACxB,oBAAC,MAAD;GAAI,MAAK;aAASG,MAAMF;GAAa,EAClC"}
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
3
+ let react = require("react");
4
+
5
+ //#region src/components/DropdownSelector/MenuList/MenuListContext.ts
6
+ const MenuListContext = (0, react.createContext)({
7
+ root: void 0,
8
+ value: "",
9
+ propsArray: [],
10
+ setValue: (_v) => {}
11
+ });
12
+
13
+ //#endregion
14
+ exports.MenuListContext = MenuListContext;
15
+ //# sourceMappingURL=MenuListContext.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuListContext.cjs","names":["RefObject","createContext","DropdownMenuItemProps","MenuListContextType","root","HTMLUListElement","value","propsArray","setValue","v","MenuListContext","undefined","_v"],"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,MAAaU,2CAAqD;CAChEN,MAAMO;CACNL,OAAO;CACPC,YAAY,EAAE;CACdC,WAAWI,OAAe;CAG3B,CAAC"}