smarthr-ui 99.1.0 → 99.2.0

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 (238) hide show
  1. package/lib/components/Calendar/Calendar.cjs +7 -3
  2. package/lib/components/Calendar/Calendar.cjs.map +1 -1
  3. package/lib/components/Calendar/Calendar.js +8 -4
  4. package/lib/components/Calendar/Calendar.js.map +1 -1
  5. package/lib/components/Checkbox/Checkbox.cjs +7 -5
  6. package/lib/components/Checkbox/Checkbox.cjs.map +1 -1
  7. package/lib/components/Checkbox/Checkbox.js +8 -6
  8. package/lib/components/Checkbox/Checkbox.js.map +1 -1
  9. package/lib/components/Chip/Chip.cjs +3 -9
  10. package/lib/components/Chip/Chip.cjs.map +1 -1
  11. package/lib/components/Chip/Chip.d.ts +3 -22
  12. package/lib/components/Chip/Chip.js +3 -9
  13. package/lib/components/Chip/Chip.js.map +1 -1
  14. package/lib/components/Combobox/ItemButton.cjs +5 -39
  15. package/lib/components/Combobox/ItemButton.cjs.map +1 -1
  16. package/lib/components/Combobox/ItemButton.d.ts +3 -7
  17. package/lib/components/Combobox/ItemButton.js +6 -40
  18. package/lib/components/Combobox/ItemButton.js.map +1 -1
  19. package/lib/components/Combobox/MultiCombobox/MultiCombobox.cjs +237 -192
  20. package/lib/components/Combobox/MultiCombobox/MultiCombobox.cjs.map +1 -1
  21. package/lib/components/Combobox/MultiCombobox/MultiCombobox.d.ts +1 -1
  22. package/lib/components/Combobox/MultiCombobox/MultiCombobox.js +238 -193
  23. package/lib/components/Combobox/MultiCombobox/MultiCombobox.js.map +1 -1
  24. package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.cjs +62 -51
  25. package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.cjs.map +1 -1
  26. package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.d.ts +2 -2
  27. package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.js +63 -52
  28. package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.js.map +1 -1
  29. package/lib/components/Combobox/SingleCombobox/SingleCombobox.cjs +144 -155
  30. package/lib/components/Combobox/SingleCombobox/SingleCombobox.cjs.map +1 -1
  31. package/lib/components/Combobox/SingleCombobox/SingleCombobox.js +145 -156
  32. package/lib/components/Combobox/SingleCombobox/SingleCombobox.js.map +1 -1
  33. package/lib/components/Combobox/useListbox.cjs +156 -124
  34. package/lib/components/Combobox/useListbox.cjs.map +1 -1
  35. package/lib/components/Combobox/useListbox.d.ts +1 -1
  36. package/lib/components/Combobox/useListbox.js +157 -125
  37. package/lib/components/Combobox/useListbox.js.map +1 -1
  38. package/lib/components/Dialog/ControlledActionDialog/ActionDialogContentInner.cjs.map +1 -1
  39. package/lib/components/Dialog/ControlledActionDialog/ActionDialogContentInner.d.ts +1 -1
  40. package/lib/components/Dialog/ControlledActionDialog/ActionDialogContentInner.js.map +1 -1
  41. package/lib/components/Dialog/ControlledFormDialog/FormDialogContentInner.cjs.map +1 -1
  42. package/lib/components/Dialog/ControlledFormDialog/FormDialogContentInner.d.ts +1 -1
  43. package/lib/components/Dialog/ControlledFormDialog/FormDialogContentInner.js.map +1 -1
  44. package/lib/components/Dialog/DialogContentInner.cjs +17 -9
  45. package/lib/components/Dialog/DialogContentInner.cjs.map +1 -1
  46. package/lib/components/Dialog/DialogContentInner.js +18 -10
  47. package/lib/components/Dialog/DialogContentInner.js.map +1 -1
  48. package/lib/components/Dialog/ModelessDialog/ModelessDialog.cjs +4 -4
  49. package/lib/components/Dialog/ModelessDialog/ModelessDialog.cjs.map +1 -1
  50. package/lib/components/Dialog/ModelessDialog/ModelessDialog.js +4 -4
  51. package/lib/components/Dialog/ModelessDialog/ModelessDialog.js.map +1 -1
  52. package/lib/components/Dialog/RemoteDialogTrigger/ActionDialog.cjs +2 -2
  53. package/lib/components/Dialog/RemoteDialogTrigger/ActionDialog.cjs.map +1 -1
  54. package/lib/components/Dialog/RemoteDialogTrigger/ActionDialog.d.ts +1 -1
  55. package/lib/components/Dialog/RemoteDialogTrigger/ActionDialog.js +1 -1
  56. package/lib/components/Dialog/RemoteDialogTrigger/ActionDialog.js.map +1 -1
  57. package/lib/components/Dialog/RemoteDialogTrigger/FormDialog.cjs +2 -2
  58. package/lib/components/Dialog/RemoteDialogTrigger/FormDialog.cjs.map +1 -1
  59. package/lib/components/Dialog/RemoteDialogTrigger/FormDialog.d.ts +1 -1
  60. package/lib/components/Dialog/RemoteDialogTrigger/FormDialog.js +1 -1
  61. package/lib/components/Dialog/RemoteDialogTrigger/FormDialog.js.map +1 -1
  62. package/lib/components/Dialog/RemoteDialogTrigger/MessageDialog.cjs +2 -2
  63. package/lib/components/Dialog/RemoteDialogTrigger/MessageDialog.cjs.map +1 -1
  64. package/lib/components/Dialog/RemoteDialogTrigger/MessageDialog.d.ts +1 -1
  65. package/lib/components/Dialog/RemoteDialogTrigger/MessageDialog.js +1 -1
  66. package/lib/components/Dialog/RemoteDialogTrigger/MessageDialog.js.map +1 -1
  67. package/lib/components/Dialog/RemoteDialogTrigger/RemoteDialogTrigger.cjs +2 -2
  68. package/lib/components/Dialog/RemoteDialogTrigger/RemoteDialogTrigger.cjs.map +1 -1
  69. package/lib/components/Dialog/RemoteDialogTrigger/RemoteDialogTrigger.js +1 -1
  70. package/lib/components/Dialog/RemoteDialogTrigger/RemoteDialogTrigger.js.map +1 -1
  71. package/lib/components/Dialog/RemoteDialogTrigger/StepFormDialog.cjs +2 -2
  72. package/lib/components/Dialog/RemoteDialogTrigger/StepFormDialog.cjs.map +1 -1
  73. package/lib/components/Dialog/RemoteDialogTrigger/StepFormDialog.d.ts +1 -1
  74. package/lib/components/Dialog/RemoteDialogTrigger/StepFormDialog.js +1 -1
  75. package/lib/components/Dialog/RemoteDialogTrigger/StepFormDialog.js.map +1 -1
  76. package/lib/components/Dialog/{useRemoteTrigger.cjs → RemoteDialogTrigger/useRemoteTrigger.cjs} +1 -1
  77. package/lib/components/Dialog/RemoteDialogTrigger/useRemoteTrigger.cjs.map +1 -0
  78. package/lib/components/Dialog/{useRemoteTrigger.js → RemoteDialogTrigger/useRemoteTrigger.js} +1 -1
  79. package/lib/components/Dialog/RemoteDialogTrigger/useRemoteTrigger.js.map +1 -0
  80. package/lib/components/DropZone/DropZone.cjs +4 -5
  81. package/lib/components/DropZone/DropZone.cjs.map +1 -1
  82. package/lib/components/DropZone/DropZone.js +4 -5
  83. package/lib/components/DropZone/DropZone.js.map +1 -1
  84. package/lib/components/Dropdown/Dropdown.cjs +60 -40
  85. package/lib/components/Dropdown/Dropdown.cjs.map +1 -1
  86. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  87. package/lib/components/Dropdown/Dropdown.js +62 -42
  88. package/lib/components/Dropdown/Dropdown.js.map +1 -1
  89. package/lib/components/Dropdown/DropdownContentInner.cjs +1 -1
  90. package/lib/components/Dropdown/DropdownContentInner.cjs.map +1 -1
  91. package/lib/components/Dropdown/DropdownContentInner.js +1 -1
  92. package/lib/components/Dropdown/DropdownContentInner.js.map +1 -1
  93. package/lib/components/Dropdown/DropdownTrigger.cjs +3 -3
  94. package/lib/components/Dropdown/DropdownTrigger.cjs.map +1 -1
  95. package/lib/components/Dropdown/DropdownTrigger.js +3 -3
  96. package/lib/components/Dropdown/DropdownTrigger.js.map +1 -1
  97. package/lib/components/Dropdown/FilterDropdown/FilterDropdown.cjs +15 -38
  98. package/lib/components/Dropdown/FilterDropdown/FilterDropdown.cjs.map +1 -1
  99. package/lib/components/Dropdown/FilterDropdown/FilterDropdown.js +15 -38
  100. package/lib/components/Dropdown/FilterDropdown/FilterDropdown.js.map +1 -1
  101. package/lib/components/Dropdown/SortDropdown/useSortDropdown.cjs +3 -7
  102. package/lib/components/Dropdown/SortDropdown/useSortDropdown.cjs.map +1 -1
  103. package/lib/components/Dropdown/SortDropdown/useSortDropdown.js +4 -8
  104. package/lib/components/Dropdown/SortDropdown/useSortDropdown.js.map +1 -1
  105. package/lib/components/FileViewer/FileViewer.cjs +3 -29
  106. package/lib/components/FileViewer/FileViewer.cjs.map +1 -1
  107. package/lib/components/FileViewer/FileViewer.js +4 -30
  108. package/lib/components/FileViewer/FileViewer.js.map +1 -1
  109. package/lib/components/FileViewer/SearchController.cjs +0 -1
  110. package/lib/components/FileViewer/SearchController.cjs.map +1 -1
  111. package/lib/components/FileViewer/SearchController.js +0 -1
  112. package/lib/components/FileViewer/SearchController.js.map +1 -1
  113. package/lib/components/Heading/Heading.cjs +5 -2
  114. package/lib/components/Heading/Heading.cjs.map +1 -1
  115. package/lib/components/Heading/Heading.d.ts +41 -2
  116. package/lib/components/Heading/Heading.js +6 -3
  117. package/lib/components/Heading/Heading.js.map +1 -1
  118. package/lib/components/Heading/PageHeading/PageHeading.cjs +9 -6
  119. package/lib/components/Heading/PageHeading/PageHeading.cjs.map +1 -1
  120. package/lib/components/Heading/PageHeading/PageHeading.d.ts +1 -1
  121. package/lib/components/Heading/PageHeading/PageHeading.js +10 -7
  122. package/lib/components/Heading/PageHeading/PageHeading.js.map +1 -1
  123. package/lib/components/InputFile/FilePreviewDialog.cjs +28 -5
  124. package/lib/components/InputFile/FilePreviewDialog.cjs.map +1 -1
  125. package/lib/components/InputFile/FilePreviewDialog.js +29 -6
  126. package/lib/components/InputFile/FilePreviewDialog.js.map +1 -1
  127. package/lib/components/InputFile/parts.cjs +4 -4
  128. package/lib/components/InputFile/parts.cjs.map +1 -1
  129. package/lib/components/InputFile/parts.js +4 -4
  130. package/lib/components/InputFile/parts.js.map +1 -1
  131. package/lib/components/Table/TableScroller.cjs +6 -20
  132. package/lib/components/Table/TableScroller.cjs.map +1 -1
  133. package/lib/components/Table/TableScroller.js +6 -20
  134. package/lib/components/Table/TableScroller.js.map +1 -1
  135. package/lib/components/Table/useTableHeadCellCount.cjs +4 -0
  136. package/lib/components/Table/useTableHeadCellCount.cjs.map +1 -1
  137. package/lib/components/Table/useTableHeadCellCount.js +4 -0
  138. package/lib/components/Table/useTableHeadCellCount.js.map +1 -1
  139. package/lib/components/Text/Text.cjs +3 -3
  140. package/lib/components/Text/Text.cjs.map +1 -1
  141. package/lib/components/Text/Text.d.ts +4 -2
  142. package/lib/components/Text/Text.js +4 -4
  143. package/lib/components/Text/Text.js.map +1 -1
  144. package/lib/components/TextLink/TextLink.cjs +9 -7
  145. package/lib/components/TextLink/TextLink.cjs.map +1 -1
  146. package/lib/components/TextLink/TextLink.js +9 -7
  147. package/lib/components/TextLink/TextLink.js.map +1 -1
  148. package/lib/components/Timeline/TimelineItem.cjs +3 -1
  149. package/lib/components/Timeline/TimelineItem.cjs.map +1 -1
  150. package/lib/components/Timeline/TimelineItem.js +3 -1
  151. package/lib/components/Timeline/TimelineItem.js.map +1 -1
  152. package/lib/components/Tooltip/Tooltip.cjs +58 -38
  153. package/lib/components/Tooltip/Tooltip.cjs.map +1 -1
  154. package/lib/components/Tooltip/Tooltip.js +59 -39
  155. package/lib/components/Tooltip/Tooltip.js.map +1 -1
  156. package/lib/components/VisuallyHiddenText/VisuallyHiddenText.cjs +3 -3
  157. package/lib/components/VisuallyHiddenText/VisuallyHiddenText.cjs.map +1 -1
  158. package/lib/components/VisuallyHiddenText/VisuallyHiddenText.d.ts +3 -2
  159. package/lib/components/VisuallyHiddenText/VisuallyHiddenText.js +4 -4
  160. package/lib/components/VisuallyHiddenText/VisuallyHiddenText.js.map +1 -1
  161. package/lib/hooks/usePortal.cjs +9 -5
  162. package/lib/hooks/usePortal.cjs.map +1 -1
  163. package/lib/hooks/usePortal.d.ts +3 -2
  164. package/lib/hooks/usePortal.js +9 -5
  165. package/lib/hooks/usePortal.js.map +1 -1
  166. package/lib/intl/locales/en_us.json.cjs +8 -5
  167. package/lib/intl/locales/en_us.json.cjs.map +1 -1
  168. package/lib/intl/locales/en_us.json.js +8 -5
  169. package/lib/intl/locales/en_us.json.js.map +1 -1
  170. package/lib/intl/locales/id_id.json.cjs +5 -2
  171. package/lib/intl/locales/id_id.json.cjs.map +1 -1
  172. package/lib/intl/locales/id_id.json.js +5 -2
  173. package/lib/intl/locales/id_id.json.js.map +1 -1
  174. package/lib/intl/locales/index.d.ts +25 -0
  175. package/lib/intl/locales/ja.cjs +1 -0
  176. package/lib/intl/locales/ja.cjs.map +1 -1
  177. package/lib/intl/locales/ja.d.ts +1 -0
  178. package/lib/intl/locales/ja.js +1 -0
  179. package/lib/intl/locales/ja.js.map +1 -1
  180. package/lib/intl/locales/ja.json.cjs +1 -0
  181. package/lib/intl/locales/ja.json.cjs.map +1 -1
  182. package/lib/intl/locales/ja.json.js +1 -0
  183. package/lib/intl/locales/ja.json.js.map +1 -1
  184. package/lib/intl/locales/ja_easy.json.cjs +8 -5
  185. package/lib/intl/locales/ja_easy.json.cjs.map +1 -1
  186. package/lib/intl/locales/ja_easy.json.js +8 -5
  187. package/lib/intl/locales/ja_easy.json.js.map +1 -1
  188. package/lib/intl/locales/ko_kr.json.cjs +8 -5
  189. package/lib/intl/locales/ko_kr.json.cjs.map +1 -1
  190. package/lib/intl/locales/ko_kr.json.js +8 -5
  191. package/lib/intl/locales/ko_kr.json.js.map +1 -1
  192. package/lib/intl/locales/pt_br.json.cjs +5 -2
  193. package/lib/intl/locales/pt_br.json.cjs.map +1 -1
  194. package/lib/intl/locales/pt_br.json.js +5 -2
  195. package/lib/intl/locales/pt_br.json.js.map +1 -1
  196. package/lib/intl/locales/vi_vn.json.cjs +8 -5
  197. package/lib/intl/locales/vi_vn.json.cjs.map +1 -1
  198. package/lib/intl/locales/vi_vn.json.js +8 -5
  199. package/lib/intl/locales/vi_vn.json.js.map +1 -1
  200. package/lib/intl/locales/zh_hans_cn.json.cjs +10 -7
  201. package/lib/intl/locales/zh_hans_cn.json.cjs.map +1 -1
  202. package/lib/intl/locales/zh_hans_cn.json.js +10 -7
  203. package/lib/intl/locales/zh_hans_cn.json.js.map +1 -1
  204. package/lib/intl/locales/zh_hant_tw.json.cjs +8 -5
  205. package/lib/intl/locales/zh_hant_tw.json.cjs.map +1 -1
  206. package/lib/intl/locales/zh_hant_tw.json.js +8 -5
  207. package/lib/intl/locales/zh_hant_tw.json.js.map +1 -1
  208. package/lib/libs/delegate.cjs +13 -0
  209. package/lib/libs/delegate.cjs.map +1 -0
  210. package/lib/libs/delegate.d.ts +3 -0
  211. package/lib/libs/delegate.js +11 -0
  212. package/lib/libs/delegate.js.map +1 -0
  213. package/lib/vendor/.pnpm/{react-draggable@4.7.0_react-dom@19.2.8_react@19.2.8__react@19.2.8/vendor/react-draggable/build/cjs/chunk-RXGSR3JC.cjs → react-draggable@4.7.1_react-dom@19.2.8_react@19.2.8__react@19.2.8/vendor/react-draggable/build/cjs/chunk-ACOTSM7X.cjs} +38 -22
  214. package/lib/vendor/.pnpm/react-draggable@4.7.1_react-dom@19.2.8_react@19.2.8__react@19.2.8/vendor/react-draggable/build/cjs/chunk-ACOTSM7X.cjs.map +1 -0
  215. package/lib/vendor/.pnpm/{react-draggable@4.7.0_react-dom@19.2.8_react@19.2.8__react@19.2.8/vendor/react-draggable/build/cjs/chunk-RXGSR3JC.js → react-draggable@4.7.1_react-dom@19.2.8_react@19.2.8__react@19.2.8/vendor/react-draggable/build/cjs/chunk-ACOTSM7X.js} +38 -22
  216. package/lib/vendor/.pnpm/react-draggable@4.7.1_react-dom@19.2.8_react@19.2.8__react@19.2.8/vendor/react-draggable/build/cjs/chunk-ACOTSM7X.js.map +1 -0
  217. package/lib/vendor/.pnpm/{react-draggable@4.7.0_react-dom@19.2.8_react@19.2.8__react@19.2.8 → react-draggable@4.7.1_react-dom@19.2.8_react@19.2.8__react@19.2.8}/vendor/react-draggable/build/cjs/cjs.cjs +3 -3
  218. package/lib/vendor/.pnpm/{react-draggable@4.7.0_react-dom@19.2.8_react@19.2.8__react@19.2.8 → react-draggable@4.7.1_react-dom@19.2.8_react@19.2.8__react@19.2.8}/vendor/react-draggable/build/cjs/cjs.cjs.map +1 -1
  219. package/lib/vendor/.pnpm/{react-draggable@4.7.0_react-dom@19.2.8_react@19.2.8__react@19.2.8 → react-draggable@4.7.1_react-dom@19.2.8_react@19.2.8__react@19.2.8}/vendor/react-draggable/build/cjs/cjs.js +2 -2
  220. package/lib/vendor/.pnpm/{react-draggable@4.7.0_react-dom@19.2.8_react@19.2.8__react@19.2.8 → react-draggable@4.7.1_react-dom@19.2.8_react@19.2.8__react@19.2.8}/vendor/react-draggable/build/cjs/cjs.js.map +1 -1
  221. package/metadata.json +1 -1
  222. package/package.json +4 -4
  223. package/smarthr-ui.css +105 -42
  224. package/lib/components/Combobox/useFocusControl.cjs +0 -60
  225. package/lib/components/Combobox/useFocusControl.cjs.map +0 -1
  226. package/lib/components/Combobox/useFocusControl.d.ts +0 -7
  227. package/lib/components/Combobox/useFocusControl.js +0 -58
  228. package/lib/components/Combobox/useFocusControl.js.map +0 -1
  229. package/lib/components/Dialog/useBodyScrollLock.cjs +0 -21
  230. package/lib/components/Dialog/useBodyScrollLock.cjs.map +0 -1
  231. package/lib/components/Dialog/useBodyScrollLock.d.ts +0 -1
  232. package/lib/components/Dialog/useBodyScrollLock.js +0 -19
  233. package/lib/components/Dialog/useBodyScrollLock.js.map +0 -1
  234. package/lib/components/Dialog/useRemoteTrigger.cjs.map +0 -1
  235. package/lib/components/Dialog/useRemoteTrigger.js.map +0 -1
  236. package/lib/vendor/.pnpm/react-draggable@4.7.0_react-dom@19.2.8_react@19.2.8__react@19.2.8/vendor/react-draggable/build/cjs/chunk-RXGSR3JC.cjs.map +0 -1
  237. package/lib/vendor/.pnpm/react-draggable@4.7.0_react-dom@19.2.8_react@19.2.8__react@19.2.8/vendor/react-draggable/build/cjs/chunk-RXGSR3JC.js.map +0 -1
  238. /package/lib/components/Dialog/{useRemoteTrigger.d.ts → RemoteDialogTrigger/useRemoteTrigger.d.ts} +0 -0
@@ -5,6 +5,7 @@ var jsxRuntime = require('react/jsx-runtime');
5
5
  var dayjs_min = require('../../_virtual/dayjs.min.cjs');
6
6
  var React = require('react');
7
7
  var index = require('./../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.19_ts-node@10.9.2_@swc_core@1.15.46_@types_node@20.19.43_typescript@5.9.3__/vendor/tailwind-variants/dist/index.cjs');
8
+ var hooks_useLatest = require('../../hooks/useLatest.cjs');
8
9
  require('../../intl/IntlProvider.cjs');
9
10
  require('react-intl');
10
11
  var intl_useDateFormat = require('../../intl/useDateFormat.cjs');
@@ -121,9 +122,12 @@ const Calendar = React.forwardRef(({ from = components_Calendar_calendarHelper.m
121
122
  const YearMonthRender = React.memo(({ children, className }) => jsxRuntime.jsx("div", { className: className, children: children }));
122
123
  const YearSelectButton = React.memo(({ handleClick, ...rest }) => (jsxRuntime.jsx(components_Button_Button.Button, { ...rest, onClick: handleClick, size: "S", children: jsxRuntime.jsx(components_Icon_FaIcon.FaCaretDownIcon, { alt: jsxRuntime.jsx(intl_Localizer.Localizer, { id: "smarthr-ui/Calendar/selectYear", defaultText: "\u5E74\u3092\u9078\u629E\u3059\u308B" }) }) })));
123
124
  const MonthDirectionCluster = React.memo(({ isSelectingYear, directionMonth: { prev, next }, from, to, setCurrentMonth, className }) => {
124
- const onClickMonthPrev = React.useCallback(() => setCurrentMonth(prev), [prev, setCurrentMonth]);
125
- const onClickMonthNext = React.useCallback(() => setCurrentMonth(next), [next, setCurrentMonth]);
126
- return (jsxRuntime.jsxs(components_Layout_Cluster_Cluster.Cluster, { gap: 0.5, className: className, children: [jsxRuntime.jsx(components_Button_Button.Button, { disabled: isSelectingYear || prev.isBefore(from, 'month'), onClick: onClickMonthPrev, size: "S", className: "smarthr-ui-Calendar-monthButtonPrev", children: jsxRuntime.jsx(components_Icon_FaIcon.FaChevronLeftIcon, { alt: jsxRuntime.jsx(intl_Localizer.Localizer, { id: "smarthr-ui/Calendar/previousMonth", defaultText: "\u524D\u306E\u6708\u3078" }) }) }), jsxRuntime.jsx(components_Button_Button.Button, { disabled: isSelectingYear || next.isAfter(to, 'month'), onClick: onClickMonthNext, size: "S", className: "smarthr-ui-Calendar-monthButtonNext", children: jsxRuntime.jsx(components_Icon_FaIcon.FaChevronRightIcon, { alt: jsxRuntime.jsx(intl_Localizer.Localizer, { id: "smarthr-ui/Calendar/nextMonth", defaultText: "\u6B21\u306E\u6708\u3078" }) }) })] }));
125
+ const latest = hooks_useLatest.useLatest({ prev, next, setCurrentMonth });
126
+ const functions = React.useMemo(() => ({
127
+ handleClickMonthPrev: () => latest.setCurrentMonth(latest.prev),
128
+ handleClickMonthNext: () => latest.setCurrentMonth(latest.next),
129
+ }), [latest]);
130
+ return (jsxRuntime.jsxs(components_Layout_Cluster_Cluster.Cluster, { gap: 0.5, className: className, children: [jsxRuntime.jsx(components_Button_Button.Button, { disabled: isSelectingYear || prev.isBefore(from, 'month'), onClick: functions.handleClickMonthPrev, size: "S", className: "smarthr-ui-Calendar-monthButtonPrev", children: jsxRuntime.jsx(components_Icon_FaIcon.FaChevronLeftIcon, { alt: jsxRuntime.jsx(intl_Localizer.Localizer, { id: "smarthr-ui/Calendar/previousMonth", defaultText: "\u524D\u306E\u6708\u3078" }) }) }), jsxRuntime.jsx(components_Button_Button.Button, { disabled: isSelectingYear || next.isAfter(to, 'month'), onClick: functions.handleClickMonthNext, size: "S", className: "smarthr-ui-Calendar-monthButtonNext", children: jsxRuntime.jsx(components_Icon_FaIcon.FaChevronRightIcon, { alt: jsxRuntime.jsx(intl_Localizer.Localizer, { id: "smarthr-ui/Calendar/nextMonth", defaultText: "\u6B21\u306E\u6708\u3078" }) }) })] }));
127
131
  });
128
132
 
129
133
  exports.Calendar = Calendar;
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.cjs","sources":["../../../src/components/Calendar/Calendar.tsx"],"sourcesContent":["'use client'\n\nimport dayjs from 'dayjs'\nimport {\n type ComponentProps,\n type MouseEvent,\n type PropsWithChildren,\n forwardRef,\n memo,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useState,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { Localizer, useDateFormat } from '../../intl'\nimport { Button } from '../Button'\nimport { FaCaretDownIcon, FaChevronLeftIcon, FaChevronRightIcon } from '../Icon'\nimport { Cluster } from '../Layout'\n\nimport { CalendarTable } from './CalendarTable'\nimport { YearPicker } from './YearPicker'\nimport { getFromDate, getMonthArray, getToDate, isBetween, minDate } from './calendarHelper'\n\ntype BaseProps = {\n /** 選択可能な開始日 */\n from?: Date\n /** 選択可能な終了日 */\n to?: Date\n /** トリガのセレクトイベントを処理するハンドラ */\n onSelectDate: (e: MouseEvent, date: Date) => void\n /** 選択された日付 */\n value?: Date\n}\ntype Props = BaseProps & Omit<ComponentProps<'div'>, keyof BaseProps>\n\ntype DayJsType = ReturnType<typeof dayjs>\n\nconst classNameGenerator = tv({\n slots: {\n container:\n 'smarthr-ui-Calendar shr-inline-block shr-overflow-hidden shr-rounded-m shr-bg-white shr-text-black shr-shadow-layer-3 forced-colors:shr-border-shorthand forced-colors:shr-shadow-none',\n header: 'smarthr-ui-Calendar-header shr-border-b-shorthand shr-flex shr-items-center shr-p-1',\n yearMonth: 'smarthr-ui-Calendar-yearMonth shr-me-0.5 shr-text-base shr-font-bold',\n monthButtons: 'smarthr-ui-Calendar-monthButtons shr-ms-auto shr-flex',\n tableLayout: 'shr-relative',\n yearSelectButton:\n 'smarthr-ui-Calendar-selectingYear [&[aria-expanded=\"true\"]_.smarthr-ui-Icon]:shr-rotate-180',\n },\n})\n\nexport const Calendar = forwardRef<HTMLDivElement, Props>(\n ({ from = minDate, to, onSelectDate, value, className, ...rest }, ref) => {\n const { formatDate, getWeekStartDay } = useDateFormat()\n\n const classNames = useMemo(() => {\n const { container, yearMonth, header, monthButtons, tableLayout, yearSelectButton } =\n classNameGenerator()\n\n return {\n container: container({ className }),\n header: header(),\n yearMonth: yearMonth(),\n monthButtons: monthButtons(),\n tableLayout: tableLayout(),\n yearSelectButton: yearSelectButton(),\n }\n }, [className])\n\n const formattedFrom = useMemo(() => {\n const date = getFromDate(from)\n const day = dayjs(date)\n\n return {\n day,\n date,\n year: day.year(),\n }\n }, [from])\n const formattedTo = useMemo(() => {\n const date = getToDate(to)\n const day = dayjs(date)\n\n return {\n day,\n date,\n year: day.year(),\n }\n }, [to])\n\n const isValidValue = useMemo(\n () => value && isBetween(value, formattedFrom.date, formattedTo.date),\n [value, formattedFrom.date, formattedTo.date],\n )\n\n const [currentMonth, setCurrentMonth] = useState(() => {\n if (isValidValue) {\n return dayjs(value)\n }\n\n const today = dayjs()\n\n return formattedTo.day.isBefore(today)\n ? formattedTo.day\n : formattedFrom.day.isAfter(today)\n ? formattedFrom.day\n : today\n })\n const [isSelectingYear, setIsSelectingYear] = useState(false)\n\n const yearPickerId = useId()\n\n useEffect(() => {\n if (isValidValue) {\n setCurrentMonth(dayjs(value))\n }\n }, [value, isValidValue])\n\n const calculatedCurrentMonth = useMemo(() => {\n const d = currentMonth.toDate()\n\n return {\n prev: currentMonth.subtract(1, 'month'),\n next: currentMonth.add(1, 'month'),\n day: currentMonth,\n months: getMonthArray(d, getWeekStartDay()),\n yearMonthText: formatDate({\n date: d,\n parts: ['year', 'month'],\n options: {\n disableSlashInJa: true,\n capitalizeFirstLetter: true,\n },\n }),\n selectedText: currentMonth.toString(),\n }\n }, [currentMonth, formatDate, getWeekStartDay])\n\n const functions = useMemo(\n () => ({\n handleSelectYear: (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation()\n\n const year = parseInt(e.currentTarget.value, 10)\n\n setCurrentMonth((prev) => prev.year(year))\n setIsSelectingYear(false)\n },\n handleClickSelectYear: (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation()\n setIsSelectingYear((current) => !current)\n },\n }),\n [],\n )\n\n return (\n <div {...rest} ref={ref} className={classNames.container}>\n <header className={classNames.header}>\n <YearMonthRender className={classNames.yearMonth}>\n {calculatedCurrentMonth.yearMonthText}\n </YearMonthRender>\n <YearSelectButton\n aria-expanded={isSelectingYear}\n aria-controls={yearPickerId}\n handleClick={functions.handleClickSelectYear}\n className={classNames.yearSelectButton}\n />\n <MonthDirectionCluster\n isSelectingYear={isSelectingYear}\n directionMonth={calculatedCurrentMonth}\n from={formattedFrom.day}\n to={formattedTo.day}\n setCurrentMonth={setCurrentMonth}\n className={classNames.monthButtons}\n />\n </header>\n <div className={classNames.tableLayout}>\n <YearPicker\n fromYear={formattedFrom.year}\n toYear={formattedTo.year}\n selectedYear={value?.getFullYear()}\n handleSelectYear={functions.handleSelectYear}\n isDisplayed={isSelectingYear}\n id={yearPickerId}\n />\n <CalendarTable\n current={calculatedCurrentMonth}\n from={formattedFrom.date}\n to={formattedTo.date}\n onSelectDate={onSelectDate}\n selectedDayText={isValidValue ? calculatedCurrentMonth.selectedText : ''}\n />\n </div>\n </div>\n )\n },\n)\n\nconst YearMonthRender = memo<PropsWithChildren<{ className: string }>>(\n ({ children, className }) => <div className={className}>{children}</div>,\n)\n\nconst YearSelectButton = memo<{\n 'aria-expanded': boolean\n 'aria-controls': string\n handleClick: (e: MouseEvent<HTMLButtonElement>) => void\n className: string\n}>(({ handleClick, ...rest }) => (\n <Button {...rest} onClick={handleClick} size=\"S\">\n <FaCaretDownIcon\n alt={<Localizer id=\"smarthr-ui/Calendar/selectYear\" defaultText=\"年を選択する\" />}\n />\n </Button>\n))\n\nconst MonthDirectionCluster = memo<{\n isSelectingYear: boolean\n directionMonth: {\n prev: DayJsType\n next: DayJsType\n }\n from: DayJsType\n to: DayJsType\n setCurrentMonth: (day: DayJsType) => void\n className: string\n}>(({ isSelectingYear, directionMonth: { prev, next }, from, to, setCurrentMonth, className }) => {\n const onClickMonthPrev = useCallback(() => setCurrentMonth(prev), [prev, setCurrentMonth])\n const onClickMonthNext = useCallback(() => setCurrentMonth(next), [next, setCurrentMonth])\n\n return (\n <Cluster gap={0.5} className={className}>\n <Button\n disabled={isSelectingYear || prev.isBefore(from, 'month')}\n onClick={onClickMonthPrev}\n size=\"S\"\n className=\"smarthr-ui-Calendar-monthButtonPrev\"\n >\n <FaChevronLeftIcon\n alt={<Localizer id=\"smarthr-ui/Calendar/previousMonth\" defaultText=\"前の月へ\" />}\n />\n </Button>\n <Button\n disabled={isSelectingYear || next.isAfter(to, 'month')}\n onClick={onClickMonthNext}\n size=\"S\"\n className=\"smarthr-ui-Calendar-monthButtonNext\"\n >\n <FaChevronRightIcon\n alt={<Localizer id=\"smarthr-ui/Calendar/nextMonth\" defaultText=\"次の月へ\" />}\n />\n </Button>\n </Cluster>\n )\n})\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;AACE;AACE;AAEA;AACA;AACA;AACA;AACA;AAED;AACF;AAEM;;AAIH;AACE;;AAIE;;;;;;;AAOJ;AAEA;AACE;AACA;;;;AAKE;;AAEJ;AACA;AACE;AACA;;;;AAKE;;AAEJ;AAEA;;;AAOI;;AAGF;AAEA;;;;;AAKF;;AAGA;;;AAII;;AAEJ;AAEA;AACE;;;;AAKE;AACA;;AAEE;AACA;AACA;AACE;AACA;AACD;;AAEH;;;AAIJ;AAEI;;AAGE;AAEA;;;AAGF;;;;;AAQJ;AAwCF;AAGF;AAIA;AAaA;AAWE;AACA;;AA0BF;;"}
1
+ {"version":3,"file":"Calendar.cjs","sources":["../../../src/components/Calendar/Calendar.tsx"],"sourcesContent":["'use client'\n\nimport dayjs from 'dayjs'\nimport {\n type ComponentProps,\n type MouseEvent,\n type PropsWithChildren,\n forwardRef,\n memo,\n useEffect,\n useId,\n useMemo,\n useState,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { useLatest } from '../../hooks/useLatest'\nimport { Localizer, useDateFormat } from '../../intl'\nimport { Button } from '../Button'\nimport { FaCaretDownIcon, FaChevronLeftIcon, FaChevronRightIcon } from '../Icon'\nimport { Cluster } from '../Layout'\n\nimport { CalendarTable } from './CalendarTable'\nimport { YearPicker } from './YearPicker'\nimport { getFromDate, getMonthArray, getToDate, isBetween, minDate } from './calendarHelper'\n\ntype BaseProps = {\n /** 選択可能な開始日 */\n from?: Date\n /** 選択可能な終了日 */\n to?: Date\n /** トリガのセレクトイベントを処理するハンドラ */\n onSelectDate: (e: MouseEvent, date: Date) => void\n /** 選択された日付 */\n value?: Date\n}\ntype Props = BaseProps & Omit<ComponentProps<'div'>, keyof BaseProps>\n\ntype DayJsType = ReturnType<typeof dayjs>\n\nconst classNameGenerator = tv({\n slots: {\n container:\n 'smarthr-ui-Calendar shr-inline-block shr-overflow-hidden shr-rounded-m shr-bg-white shr-text-black shr-shadow-layer-3 forced-colors:shr-border-shorthand forced-colors:shr-shadow-none',\n header: 'smarthr-ui-Calendar-header shr-border-b-shorthand shr-flex shr-items-center shr-p-1',\n yearMonth: 'smarthr-ui-Calendar-yearMonth shr-me-0.5 shr-text-base shr-font-bold',\n monthButtons: 'smarthr-ui-Calendar-monthButtons shr-ms-auto shr-flex',\n tableLayout: 'shr-relative',\n yearSelectButton:\n 'smarthr-ui-Calendar-selectingYear [&[aria-expanded=\"true\"]_.smarthr-ui-Icon]:shr-rotate-180',\n },\n})\n\nexport const Calendar = forwardRef<HTMLDivElement, Props>(\n ({ from = minDate, to, onSelectDate, value, className, ...rest }, ref) => {\n const { formatDate, getWeekStartDay } = useDateFormat()\n\n const classNames = useMemo(() => {\n const { container, yearMonth, header, monthButtons, tableLayout, yearSelectButton } =\n classNameGenerator()\n\n return {\n container: container({ className }),\n header: header(),\n yearMonth: yearMonth(),\n monthButtons: monthButtons(),\n tableLayout: tableLayout(),\n yearSelectButton: yearSelectButton(),\n }\n }, [className])\n\n const formattedFrom = useMemo(() => {\n const date = getFromDate(from)\n const day = dayjs(date)\n\n return {\n day,\n date,\n year: day.year(),\n }\n }, [from])\n const formattedTo = useMemo(() => {\n const date = getToDate(to)\n const day = dayjs(date)\n\n return {\n day,\n date,\n year: day.year(),\n }\n }, [to])\n\n const isValidValue = useMemo(\n () => value && isBetween(value, formattedFrom.date, formattedTo.date),\n [value, formattedFrom.date, formattedTo.date],\n )\n\n const [currentMonth, setCurrentMonth] = useState(() => {\n if (isValidValue) {\n return dayjs(value)\n }\n\n const today = dayjs()\n\n return formattedTo.day.isBefore(today)\n ? formattedTo.day\n : formattedFrom.day.isAfter(today)\n ? formattedFrom.day\n : today\n })\n const [isSelectingYear, setIsSelectingYear] = useState(false)\n\n const yearPickerId = useId()\n\n useEffect(() => {\n if (isValidValue) {\n setCurrentMonth(dayjs(value))\n }\n }, [value, isValidValue])\n\n const calculatedCurrentMonth = useMemo(() => {\n const d = currentMonth.toDate()\n\n return {\n prev: currentMonth.subtract(1, 'month'),\n next: currentMonth.add(1, 'month'),\n day: currentMonth,\n months: getMonthArray(d, getWeekStartDay()),\n yearMonthText: formatDate({\n date: d,\n parts: ['year', 'month'],\n options: {\n disableSlashInJa: true,\n capitalizeFirstLetter: true,\n },\n }),\n selectedText: currentMonth.toString(),\n }\n }, [currentMonth, formatDate, getWeekStartDay])\n\n const functions = useMemo(\n () => ({\n handleSelectYear: (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation()\n\n const year = parseInt(e.currentTarget.value, 10)\n\n setCurrentMonth((prev) => prev.year(year))\n setIsSelectingYear(false)\n },\n handleClickSelectYear: (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation()\n setIsSelectingYear((current) => !current)\n },\n }),\n [],\n )\n\n return (\n <div {...rest} ref={ref} className={classNames.container}>\n <header className={classNames.header}>\n <YearMonthRender className={classNames.yearMonth}>\n {calculatedCurrentMonth.yearMonthText}\n </YearMonthRender>\n <YearSelectButton\n aria-expanded={isSelectingYear}\n aria-controls={yearPickerId}\n handleClick={functions.handleClickSelectYear}\n className={classNames.yearSelectButton}\n />\n <MonthDirectionCluster\n isSelectingYear={isSelectingYear}\n directionMonth={calculatedCurrentMonth}\n from={formattedFrom.day}\n to={formattedTo.day}\n setCurrentMonth={setCurrentMonth}\n className={classNames.monthButtons}\n />\n </header>\n <div className={classNames.tableLayout}>\n <YearPicker\n fromYear={formattedFrom.year}\n toYear={formattedTo.year}\n selectedYear={value?.getFullYear()}\n handleSelectYear={functions.handleSelectYear}\n isDisplayed={isSelectingYear}\n id={yearPickerId}\n />\n <CalendarTable\n current={calculatedCurrentMonth}\n from={formattedFrom.date}\n to={formattedTo.date}\n onSelectDate={onSelectDate}\n selectedDayText={isValidValue ? calculatedCurrentMonth.selectedText : ''}\n />\n </div>\n </div>\n )\n },\n)\n\nconst YearMonthRender = memo<PropsWithChildren<{ className: string }>>(\n ({ children, className }) => <div className={className}>{children}</div>,\n)\n\nconst YearSelectButton = memo<{\n 'aria-expanded': boolean\n 'aria-controls': string\n handleClick: (e: MouseEvent<HTMLButtonElement>) => void\n className: string\n}>(({ handleClick, ...rest }) => (\n <Button {...rest} onClick={handleClick} size=\"S\">\n <FaCaretDownIcon\n alt={<Localizer id=\"smarthr-ui/Calendar/selectYear\" defaultText=\"年を選択する\" />}\n />\n </Button>\n))\n\nconst MonthDirectionCluster = memo<{\n isSelectingYear: boolean\n directionMonth: {\n prev: DayJsType\n next: DayJsType\n }\n from: DayJsType\n to: DayJsType\n setCurrentMonth: (day: DayJsType) => void\n className: string\n}>(({ isSelectingYear, directionMonth: { prev, next }, from, to, setCurrentMonth, className }) => {\n const latest = useLatest({ prev, next, setCurrentMonth })\n\n const functions = useMemo(\n () => ({\n handleClickMonthPrev: () => latest.setCurrentMonth(latest.prev),\n handleClickMonthNext: () => latest.setCurrentMonth(latest.next),\n }),\n [latest],\n )\n\n return (\n <Cluster gap={0.5} className={className}>\n <Button\n disabled={isSelectingYear || prev.isBefore(from, 'month')}\n onClick={functions.handleClickMonthPrev}\n size=\"S\"\n className=\"smarthr-ui-Calendar-monthButtonPrev\"\n >\n <FaChevronLeftIcon\n alt={<Localizer id=\"smarthr-ui/Calendar/previousMonth\" defaultText=\"前の月へ\" />}\n />\n </Button>\n <Button\n disabled={isSelectingYear || next.isAfter(to, 'month')}\n onClick={functions.handleClickMonthNext}\n size=\"S\"\n className=\"smarthr-ui-Calendar-monthButtonNext\"\n >\n <FaChevronRightIcon\n alt={<Localizer id=\"smarthr-ui/Calendar/nextMonth\" defaultText=\"次の月へ\" />}\n />\n </Button>\n </Cluster>\n )\n})\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;AACE;AACE;AAEA;AACA;AACA;AACA;AACA;AAED;AACF;AAEM;;AAIH;AACE;;AAIE;;;;;;;AAOJ;AAEA;AACE;AACA;;;;AAKE;;AAEJ;AACA;AACE;AACA;;;;AAKE;;AAEJ;AAEA;;;AAOI;;AAGF;AAEA;;;;;AAKF;;AAGA;;;AAII;;AAEJ;AAEA;AACE;;;;AAKE;AACA;;AAEE;AACA;AACA;AACE;AACA;AACD;;AAEH;;;AAIJ;AAEI;;AAGE;AAEA;;;AAGF;;;;;AAQJ;AAwCF;AAGF;AAIA;AAaA;AAWE;AAEA;;;AAIG;;AA4BL;;"}
@@ -1,8 +1,9 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import dayjs from '../../_virtual/dayjs.min.js';
4
- import { forwardRef, useMemo, useState, useId, useEffect, memo, useCallback } from 'react';
4
+ import { forwardRef, useMemo, useState, useId, useEffect, memo } from 'react';
5
5
  import { tv as ce } from './../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.19_ts-node@10.9.2_@swc_core@1.15.46_@types_node@20.19.43_typescript@5.9.3__/vendor/tailwind-variants/dist/index.js';
6
+ import { useLatest } from '../../hooks/useLatest.js';
6
7
  import '../../intl/IntlProvider.js';
7
8
  import 'react-intl';
8
9
  import { useDateFormat } from '../../intl/useDateFormat.js';
@@ -119,9 +120,12 @@ const Calendar = forwardRef(({ from = minDate, to, onSelectDate, value, classNam
119
120
  const YearMonthRender = memo(({ children, className }) => jsx("div", { className: className, children: children }));
120
121
  const YearSelectButton = memo(({ handleClick, ...rest }) => (jsx(Button, { ...rest, onClick: handleClick, size: "S", children: jsx(FaCaretDownIcon, { alt: jsx(Localizer, { id: "smarthr-ui/Calendar/selectYear", defaultText: "\u5E74\u3092\u9078\u629E\u3059\u308B" }) }) })));
121
122
  const MonthDirectionCluster = memo(({ isSelectingYear, directionMonth: { prev, next }, from, to, setCurrentMonth, className }) => {
122
- const onClickMonthPrev = useCallback(() => setCurrentMonth(prev), [prev, setCurrentMonth]);
123
- const onClickMonthNext = useCallback(() => setCurrentMonth(next), [next, setCurrentMonth]);
124
- return (jsxs(Cluster, { gap: 0.5, className: className, children: [jsx(Button, { disabled: isSelectingYear || prev.isBefore(from, 'month'), onClick: onClickMonthPrev, size: "S", className: "smarthr-ui-Calendar-monthButtonPrev", children: jsx(FaChevronLeftIcon, { alt: jsx(Localizer, { id: "smarthr-ui/Calendar/previousMonth", defaultText: "\u524D\u306E\u6708\u3078" }) }) }), jsx(Button, { disabled: isSelectingYear || next.isAfter(to, 'month'), onClick: onClickMonthNext, size: "S", className: "smarthr-ui-Calendar-monthButtonNext", children: jsx(FaChevronRightIcon, { alt: jsx(Localizer, { id: "smarthr-ui/Calendar/nextMonth", defaultText: "\u6B21\u306E\u6708\u3078" }) }) })] }));
123
+ const latest = useLatest({ prev, next, setCurrentMonth });
124
+ const functions = useMemo(() => ({
125
+ handleClickMonthPrev: () => latest.setCurrentMonth(latest.prev),
126
+ handleClickMonthNext: () => latest.setCurrentMonth(latest.next),
127
+ }), [latest]);
128
+ return (jsxs(Cluster, { gap: 0.5, className: className, children: [jsx(Button, { disabled: isSelectingYear || prev.isBefore(from, 'month'), onClick: functions.handleClickMonthPrev, size: "S", className: "smarthr-ui-Calendar-monthButtonPrev", children: jsx(FaChevronLeftIcon, { alt: jsx(Localizer, { id: "smarthr-ui/Calendar/previousMonth", defaultText: "\u524D\u306E\u6708\u3078" }) }) }), jsx(Button, { disabled: isSelectingYear || next.isAfter(to, 'month'), onClick: functions.handleClickMonthNext, size: "S", className: "smarthr-ui-Calendar-monthButtonNext", children: jsx(FaChevronRightIcon, { alt: jsx(Localizer, { id: "smarthr-ui/Calendar/nextMonth", defaultText: "\u6B21\u306E\u6708\u3078" }) }) })] }));
125
129
  });
126
130
 
127
131
  export { Calendar };
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.js","sources":["../../../src/components/Calendar/Calendar.tsx"],"sourcesContent":["'use client'\n\nimport dayjs from 'dayjs'\nimport {\n type ComponentProps,\n type MouseEvent,\n type PropsWithChildren,\n forwardRef,\n memo,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useState,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { Localizer, useDateFormat } from '../../intl'\nimport { Button } from '../Button'\nimport { FaCaretDownIcon, FaChevronLeftIcon, FaChevronRightIcon } from '../Icon'\nimport { Cluster } from '../Layout'\n\nimport { CalendarTable } from './CalendarTable'\nimport { YearPicker } from './YearPicker'\nimport { getFromDate, getMonthArray, getToDate, isBetween, minDate } from './calendarHelper'\n\ntype BaseProps = {\n /** 選択可能な開始日 */\n from?: Date\n /** 選択可能な終了日 */\n to?: Date\n /** トリガのセレクトイベントを処理するハンドラ */\n onSelectDate: (e: MouseEvent, date: Date) => void\n /** 選択された日付 */\n value?: Date\n}\ntype Props = BaseProps & Omit<ComponentProps<'div'>, keyof BaseProps>\n\ntype DayJsType = ReturnType<typeof dayjs>\n\nconst classNameGenerator = tv({\n slots: {\n container:\n 'smarthr-ui-Calendar shr-inline-block shr-overflow-hidden shr-rounded-m shr-bg-white shr-text-black shr-shadow-layer-3 forced-colors:shr-border-shorthand forced-colors:shr-shadow-none',\n header: 'smarthr-ui-Calendar-header shr-border-b-shorthand shr-flex shr-items-center shr-p-1',\n yearMonth: 'smarthr-ui-Calendar-yearMonth shr-me-0.5 shr-text-base shr-font-bold',\n monthButtons: 'smarthr-ui-Calendar-monthButtons shr-ms-auto shr-flex',\n tableLayout: 'shr-relative',\n yearSelectButton:\n 'smarthr-ui-Calendar-selectingYear [&[aria-expanded=\"true\"]_.smarthr-ui-Icon]:shr-rotate-180',\n },\n})\n\nexport const Calendar = forwardRef<HTMLDivElement, Props>(\n ({ from = minDate, to, onSelectDate, value, className, ...rest }, ref) => {\n const { formatDate, getWeekStartDay } = useDateFormat()\n\n const classNames = useMemo(() => {\n const { container, yearMonth, header, monthButtons, tableLayout, yearSelectButton } =\n classNameGenerator()\n\n return {\n container: container({ className }),\n header: header(),\n yearMonth: yearMonth(),\n monthButtons: monthButtons(),\n tableLayout: tableLayout(),\n yearSelectButton: yearSelectButton(),\n }\n }, [className])\n\n const formattedFrom = useMemo(() => {\n const date = getFromDate(from)\n const day = dayjs(date)\n\n return {\n day,\n date,\n year: day.year(),\n }\n }, [from])\n const formattedTo = useMemo(() => {\n const date = getToDate(to)\n const day = dayjs(date)\n\n return {\n day,\n date,\n year: day.year(),\n }\n }, [to])\n\n const isValidValue = useMemo(\n () => value && isBetween(value, formattedFrom.date, formattedTo.date),\n [value, formattedFrom.date, formattedTo.date],\n )\n\n const [currentMonth, setCurrentMonth] = useState(() => {\n if (isValidValue) {\n return dayjs(value)\n }\n\n const today = dayjs()\n\n return formattedTo.day.isBefore(today)\n ? formattedTo.day\n : formattedFrom.day.isAfter(today)\n ? formattedFrom.day\n : today\n })\n const [isSelectingYear, setIsSelectingYear] = useState(false)\n\n const yearPickerId = useId()\n\n useEffect(() => {\n if (isValidValue) {\n setCurrentMonth(dayjs(value))\n }\n }, [value, isValidValue])\n\n const calculatedCurrentMonth = useMemo(() => {\n const d = currentMonth.toDate()\n\n return {\n prev: currentMonth.subtract(1, 'month'),\n next: currentMonth.add(1, 'month'),\n day: currentMonth,\n months: getMonthArray(d, getWeekStartDay()),\n yearMonthText: formatDate({\n date: d,\n parts: ['year', 'month'],\n options: {\n disableSlashInJa: true,\n capitalizeFirstLetter: true,\n },\n }),\n selectedText: currentMonth.toString(),\n }\n }, [currentMonth, formatDate, getWeekStartDay])\n\n const functions = useMemo(\n () => ({\n handleSelectYear: (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation()\n\n const year = parseInt(e.currentTarget.value, 10)\n\n setCurrentMonth((prev) => prev.year(year))\n setIsSelectingYear(false)\n },\n handleClickSelectYear: (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation()\n setIsSelectingYear((current) => !current)\n },\n }),\n [],\n )\n\n return (\n <div {...rest} ref={ref} className={classNames.container}>\n <header className={classNames.header}>\n <YearMonthRender className={classNames.yearMonth}>\n {calculatedCurrentMonth.yearMonthText}\n </YearMonthRender>\n <YearSelectButton\n aria-expanded={isSelectingYear}\n aria-controls={yearPickerId}\n handleClick={functions.handleClickSelectYear}\n className={classNames.yearSelectButton}\n />\n <MonthDirectionCluster\n isSelectingYear={isSelectingYear}\n directionMonth={calculatedCurrentMonth}\n from={formattedFrom.day}\n to={formattedTo.day}\n setCurrentMonth={setCurrentMonth}\n className={classNames.monthButtons}\n />\n </header>\n <div className={classNames.tableLayout}>\n <YearPicker\n fromYear={formattedFrom.year}\n toYear={formattedTo.year}\n selectedYear={value?.getFullYear()}\n handleSelectYear={functions.handleSelectYear}\n isDisplayed={isSelectingYear}\n id={yearPickerId}\n />\n <CalendarTable\n current={calculatedCurrentMonth}\n from={formattedFrom.date}\n to={formattedTo.date}\n onSelectDate={onSelectDate}\n selectedDayText={isValidValue ? calculatedCurrentMonth.selectedText : ''}\n />\n </div>\n </div>\n )\n },\n)\n\nconst YearMonthRender = memo<PropsWithChildren<{ className: string }>>(\n ({ children, className }) => <div className={className}>{children}</div>,\n)\n\nconst YearSelectButton = memo<{\n 'aria-expanded': boolean\n 'aria-controls': string\n handleClick: (e: MouseEvent<HTMLButtonElement>) => void\n className: string\n}>(({ handleClick, ...rest }) => (\n <Button {...rest} onClick={handleClick} size=\"S\">\n <FaCaretDownIcon\n alt={<Localizer id=\"smarthr-ui/Calendar/selectYear\" defaultText=\"年を選択する\" />}\n />\n </Button>\n))\n\nconst MonthDirectionCluster = memo<{\n isSelectingYear: boolean\n directionMonth: {\n prev: DayJsType\n next: DayJsType\n }\n from: DayJsType\n to: DayJsType\n setCurrentMonth: (day: DayJsType) => void\n className: string\n}>(({ isSelectingYear, directionMonth: { prev, next }, from, to, setCurrentMonth, className }) => {\n const onClickMonthPrev = useCallback(() => setCurrentMonth(prev), [prev, setCurrentMonth])\n const onClickMonthNext = useCallback(() => setCurrentMonth(next), [next, setCurrentMonth])\n\n return (\n <Cluster gap={0.5} className={className}>\n <Button\n disabled={isSelectingYear || prev.isBefore(from, 'month')}\n onClick={onClickMonthPrev}\n size=\"S\"\n className=\"smarthr-ui-Calendar-monthButtonPrev\"\n >\n <FaChevronLeftIcon\n alt={<Localizer id=\"smarthr-ui/Calendar/previousMonth\" defaultText=\"前の月へ\" />}\n />\n </Button>\n <Button\n disabled={isSelectingYear || next.isAfter(to, 'month')}\n onClick={onClickMonthNext}\n size=\"S\"\n className=\"smarthr-ui-Calendar-monthButtonNext\"\n >\n <FaChevronRightIcon\n alt={<Localizer id=\"smarthr-ui/Calendar/nextMonth\" defaultText=\"次の月へ\" />}\n />\n </Button>\n </Cluster>\n )\n})\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;AACE;AACE;AAEA;AACA;AACA;AACA;AACA;AAED;AACF;AAEM;;AAIH;AACE;;AAIE;;;;;;;AAOJ;AAEA;AACE;AACA;;;;AAKE;;AAEJ;AACA;AACE;AACA;;;;AAKE;;AAEJ;AAEA;;;AAOI;;AAGF;AAEA;;;;;AAKF;;AAGA;;;AAII;;AAEJ;AAEA;AACE;;;;AAKE;AACA;;AAEE;AACA;AACA;AACE;AACA;AACD;;AAEH;;;AAIJ;AAEI;;AAGE;AAEA;;;AAGF;;;;;AAQJ;AAwCF;AAGF;AAIA;AAaA;AAWE;AACA;;AA0BF;;"}
1
+ {"version":3,"file":"Calendar.js","sources":["../../../src/components/Calendar/Calendar.tsx"],"sourcesContent":["'use client'\n\nimport dayjs from 'dayjs'\nimport {\n type ComponentProps,\n type MouseEvent,\n type PropsWithChildren,\n forwardRef,\n memo,\n useEffect,\n useId,\n useMemo,\n useState,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { useLatest } from '../../hooks/useLatest'\nimport { Localizer, useDateFormat } from '../../intl'\nimport { Button } from '../Button'\nimport { FaCaretDownIcon, FaChevronLeftIcon, FaChevronRightIcon } from '../Icon'\nimport { Cluster } from '../Layout'\n\nimport { CalendarTable } from './CalendarTable'\nimport { YearPicker } from './YearPicker'\nimport { getFromDate, getMonthArray, getToDate, isBetween, minDate } from './calendarHelper'\n\ntype BaseProps = {\n /** 選択可能な開始日 */\n from?: Date\n /** 選択可能な終了日 */\n to?: Date\n /** トリガのセレクトイベントを処理するハンドラ */\n onSelectDate: (e: MouseEvent, date: Date) => void\n /** 選択された日付 */\n value?: Date\n}\ntype Props = BaseProps & Omit<ComponentProps<'div'>, keyof BaseProps>\n\ntype DayJsType = ReturnType<typeof dayjs>\n\nconst classNameGenerator = tv({\n slots: {\n container:\n 'smarthr-ui-Calendar shr-inline-block shr-overflow-hidden shr-rounded-m shr-bg-white shr-text-black shr-shadow-layer-3 forced-colors:shr-border-shorthand forced-colors:shr-shadow-none',\n header: 'smarthr-ui-Calendar-header shr-border-b-shorthand shr-flex shr-items-center shr-p-1',\n yearMonth: 'smarthr-ui-Calendar-yearMonth shr-me-0.5 shr-text-base shr-font-bold',\n monthButtons: 'smarthr-ui-Calendar-monthButtons shr-ms-auto shr-flex',\n tableLayout: 'shr-relative',\n yearSelectButton:\n 'smarthr-ui-Calendar-selectingYear [&[aria-expanded=\"true\"]_.smarthr-ui-Icon]:shr-rotate-180',\n },\n})\n\nexport const Calendar = forwardRef<HTMLDivElement, Props>(\n ({ from = minDate, to, onSelectDate, value, className, ...rest }, ref) => {\n const { formatDate, getWeekStartDay } = useDateFormat()\n\n const classNames = useMemo(() => {\n const { container, yearMonth, header, monthButtons, tableLayout, yearSelectButton } =\n classNameGenerator()\n\n return {\n container: container({ className }),\n header: header(),\n yearMonth: yearMonth(),\n monthButtons: monthButtons(),\n tableLayout: tableLayout(),\n yearSelectButton: yearSelectButton(),\n }\n }, [className])\n\n const formattedFrom = useMemo(() => {\n const date = getFromDate(from)\n const day = dayjs(date)\n\n return {\n day,\n date,\n year: day.year(),\n }\n }, [from])\n const formattedTo = useMemo(() => {\n const date = getToDate(to)\n const day = dayjs(date)\n\n return {\n day,\n date,\n year: day.year(),\n }\n }, [to])\n\n const isValidValue = useMemo(\n () => value && isBetween(value, formattedFrom.date, formattedTo.date),\n [value, formattedFrom.date, formattedTo.date],\n )\n\n const [currentMonth, setCurrentMonth] = useState(() => {\n if (isValidValue) {\n return dayjs(value)\n }\n\n const today = dayjs()\n\n return formattedTo.day.isBefore(today)\n ? formattedTo.day\n : formattedFrom.day.isAfter(today)\n ? formattedFrom.day\n : today\n })\n const [isSelectingYear, setIsSelectingYear] = useState(false)\n\n const yearPickerId = useId()\n\n useEffect(() => {\n if (isValidValue) {\n setCurrentMonth(dayjs(value))\n }\n }, [value, isValidValue])\n\n const calculatedCurrentMonth = useMemo(() => {\n const d = currentMonth.toDate()\n\n return {\n prev: currentMonth.subtract(1, 'month'),\n next: currentMonth.add(1, 'month'),\n day: currentMonth,\n months: getMonthArray(d, getWeekStartDay()),\n yearMonthText: formatDate({\n date: d,\n parts: ['year', 'month'],\n options: {\n disableSlashInJa: true,\n capitalizeFirstLetter: true,\n },\n }),\n selectedText: currentMonth.toString(),\n }\n }, [currentMonth, formatDate, getWeekStartDay])\n\n const functions = useMemo(\n () => ({\n handleSelectYear: (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation()\n\n const year = parseInt(e.currentTarget.value, 10)\n\n setCurrentMonth((prev) => prev.year(year))\n setIsSelectingYear(false)\n },\n handleClickSelectYear: (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation()\n setIsSelectingYear((current) => !current)\n },\n }),\n [],\n )\n\n return (\n <div {...rest} ref={ref} className={classNames.container}>\n <header className={classNames.header}>\n <YearMonthRender className={classNames.yearMonth}>\n {calculatedCurrentMonth.yearMonthText}\n </YearMonthRender>\n <YearSelectButton\n aria-expanded={isSelectingYear}\n aria-controls={yearPickerId}\n handleClick={functions.handleClickSelectYear}\n className={classNames.yearSelectButton}\n />\n <MonthDirectionCluster\n isSelectingYear={isSelectingYear}\n directionMonth={calculatedCurrentMonth}\n from={formattedFrom.day}\n to={formattedTo.day}\n setCurrentMonth={setCurrentMonth}\n className={classNames.monthButtons}\n />\n </header>\n <div className={classNames.tableLayout}>\n <YearPicker\n fromYear={formattedFrom.year}\n toYear={formattedTo.year}\n selectedYear={value?.getFullYear()}\n handleSelectYear={functions.handleSelectYear}\n isDisplayed={isSelectingYear}\n id={yearPickerId}\n />\n <CalendarTable\n current={calculatedCurrentMonth}\n from={formattedFrom.date}\n to={formattedTo.date}\n onSelectDate={onSelectDate}\n selectedDayText={isValidValue ? calculatedCurrentMonth.selectedText : ''}\n />\n </div>\n </div>\n )\n },\n)\n\nconst YearMonthRender = memo<PropsWithChildren<{ className: string }>>(\n ({ children, className }) => <div className={className}>{children}</div>,\n)\n\nconst YearSelectButton = memo<{\n 'aria-expanded': boolean\n 'aria-controls': string\n handleClick: (e: MouseEvent<HTMLButtonElement>) => void\n className: string\n}>(({ handleClick, ...rest }) => (\n <Button {...rest} onClick={handleClick} size=\"S\">\n <FaCaretDownIcon\n alt={<Localizer id=\"smarthr-ui/Calendar/selectYear\" defaultText=\"年を選択する\" />}\n />\n </Button>\n))\n\nconst MonthDirectionCluster = memo<{\n isSelectingYear: boolean\n directionMonth: {\n prev: DayJsType\n next: DayJsType\n }\n from: DayJsType\n to: DayJsType\n setCurrentMonth: (day: DayJsType) => void\n className: string\n}>(({ isSelectingYear, directionMonth: { prev, next }, from, to, setCurrentMonth, className }) => {\n const latest = useLatest({ prev, next, setCurrentMonth })\n\n const functions = useMemo(\n () => ({\n handleClickMonthPrev: () => latest.setCurrentMonth(latest.prev),\n handleClickMonthNext: () => latest.setCurrentMonth(latest.next),\n }),\n [latest],\n )\n\n return (\n <Cluster gap={0.5} className={className}>\n <Button\n disabled={isSelectingYear || prev.isBefore(from, 'month')}\n onClick={functions.handleClickMonthPrev}\n size=\"S\"\n className=\"smarthr-ui-Calendar-monthButtonPrev\"\n >\n <FaChevronLeftIcon\n alt={<Localizer id=\"smarthr-ui/Calendar/previousMonth\" defaultText=\"前の月へ\" />}\n />\n </Button>\n <Button\n disabled={isSelectingYear || next.isAfter(to, 'month')}\n onClick={functions.handleClickMonthNext}\n size=\"S\"\n className=\"smarthr-ui-Calendar-monthButtonNext\"\n >\n <FaChevronRightIcon\n alt={<Localizer id=\"smarthr-ui/Calendar/nextMonth\" defaultText=\"次の月へ\" />}\n />\n </Button>\n </Cluster>\n )\n})\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;AACE;AACE;AAEA;AACA;AACA;AACA;AACA;AAED;AACF;AAEM;;AAIH;AACE;;AAIE;;;;;;;AAOJ;AAEA;AACE;AACA;;;;AAKE;;AAEJ;AACA;AACE;AACA;;;;AAKE;;AAEJ;AAEA;;;AAOI;;AAGF;AAEA;;;;;AAKF;;AAGA;;;AAII;;AAEJ;AAEA;AACE;;;;AAKE;AACA;;AAEE;AACA;AACA;AACE;AACA;AACD;;AAEH;;;AAIJ;AAEI;;AAGE;AAEA;;;AAGF;;;;;AAQJ;AAwCF;AAGF;AAIA;AAaA;AAWE;AAEA;;;AAIG;;AA4BL;;"}
@@ -59,19 +59,21 @@ const Checkbox = React.forwardRef(({ checked, mixed, error, className, children,
59
59
  };
60
60
  }, [className]);
61
61
  const inputRef = React.useRef(null);
62
+ const defaultId = React.useId();
63
+ const checkBoxId = id || defaultId;
62
64
  React.useImperativeHandle(ref, () => inputRef.current);
63
65
  React.useEffect(() => {
64
66
  if (inputRef.current) {
65
67
  inputRef.current.indeterminate = !!(checked && mixed);
66
68
  }
67
69
  }, [checked, mixed]);
68
- const defaultId = React.useId();
69
- const checkBoxId = id || defaultId;
70
- return (jsxRuntime.jsxs("span", { "data-disabled": disabled, className: classNames.wrapper, children: [jsxRuntime.jsxs("span", { className: classNames.innerWrapper, children: [jsxRuntime.jsx("input", { ...rest, ref: inputRef, type: "checkbox", id: checkBoxId, checked: checked, disabled: disabled, "aria-invalid": error || undefined, className: classNames.input, "data-smarthr-ui-input": "true" }), jsxRuntime.jsx(AriaHiddenBox, { className: classNames.box }), jsxRuntime.jsx(CheckIconArea, { mixed: mixed, className: classNames.iconWrap, iconClassName: classNames.icon })] }), jsxRuntime.jsx(LabeledChildren, { htmlFor: checkBoxId, className: classNames.label, children: children })] }));
70
+ return (jsxRuntime.jsxs("span", { "data-disabled": disabled, className: classNames.wrapper, children: [jsxRuntime.jsxs("span", { className: classNames.innerWrapper, children: [jsxRuntime.jsx("input", { ...rest, ref: inputRef, type: "checkbox", id: checkBoxId, checked: checked, disabled: disabled, "aria-invalid": error || undefined, className: classNames.input, "data-smarthr-ui-input": "true" }), jsxRuntime.jsx(AriaHiddenBox, { className: classNames.box }), jsxRuntime.jsx(CheckIconArea, { mixed: mixed, classNames: classNames })] }), children && (jsxRuntime.jsx("label", { htmlFor: checkBoxId, className: classNames.label, children: children }))] }));
71
71
  });
72
72
  const AriaHiddenBox = React.memo(({ className }) => (jsxRuntime.jsx("span", { className: className, "aria-hidden": "true" })));
73
- const CheckIconArea = React.memo(({ mixed, className, iconClassName }) => (jsxRuntime.jsx("span", { className: className, children: mixed ? (jsxRuntime.jsx(components_Icon_FaIcon.FaMinusIcon, { className: iconClassName })) : (jsxRuntime.jsx(components_Icon_FaIcon.FaCheckIcon, { className: iconClassName })) })));
74
- const LabeledChildren = React.memo(({ children, htmlFor, className }) => children && (jsxRuntime.jsx("label", { htmlFor: htmlFor, className: className, children: children })));
73
+ const CheckIconArea = React.memo(({ mixed, classNames }) => {
74
+ const Icon = mixed ? components_Icon_FaIcon.FaMinusIcon : components_Icon_FaIcon.FaCheckIcon;
75
+ return (jsxRuntime.jsx("span", { className: classNames.iconWrap, children: jsxRuntime.jsx(Icon, { className: classNames.icon }) }));
76
+ });
75
77
 
76
78
  exports.Checkbox = Checkbox;
77
79
  //# sourceMappingURL=Checkbox.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.cjs","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ComponentPropsWithRef,\n type PropsWithChildren,\n forwardRef,\n memo,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { FaCheckIcon, FaMinusIcon } from '../Icon'\n\nexport type Props = PropsWithChildren<\n ComponentPropsWithRef<'input'> & {\n /** `true` のとき、チェック状態を `mixed` にする */\n mixed?: boolean\n /** チェックボックスにエラーがあるかどうか */\n error?: boolean\n }\n>\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: 'smarthr-ui-Checkbox shr-inline-flex shr-items-baseline',\n box: [\n 'shr-border-shorthand shr-pointer-events-none shr-absolute shr-box-border shr-h-full shr-w-full shr-rounded-s shr-bg-white',\n 'contrast-more:shr-border-high-contrast',\n /* 強制カラーモードのときは、ブラウザ標準のUIを表示する */\n 'forced-colors:shr-hidden',\n 'peer-checked:shr-border-main peer-checked:shr-bg-main contrast-more:peer-checked:shr-border-high-contrast',\n 'peer-indeterminate:shr-border-main peer-indeterminate:shr-bg-main contrast-more:peer-indeterminate:shr-border-high-contrast',\n 'peer-disabled:shr-border-disabled peer-disabled:shr-bg-white-darken',\n 'peer-disabled:peer-checked:shr-border-default peer-disabled:peer-checked:shr-bg-border',\n 'peer-disabled:peer-indeterminate:shr-border-default peer-disabled:peer-indeterminate:shr-bg-border',\n 'peer-focus-visible:shr-focus-indicator--outer',\n 'peer-hover:shr-shadow-input-hover',\n 'shr-border-default',\n 'peer-[[aria-invalid]]:shr-border-danger',\n ],\n input: [\n 'smarthr-ui-Checkbox-checkbox shr-peer shr-absolute shr-left-0 shr-top-0 shr-m-0 shr-h-full shr-w-full shr-cursor-pointer shr-opacity-0 disabled:shr-pointer-events-none',\n /* 強制カラーモードのときは、ブラウザ標準のUIを表示する */\n 'forced-colors:shr-static forced-colors:shr-opacity-100',\n ],\n icon: 'shr-fill-current',\n iconWrap: [\n 'shr-pointer-events-none shr-absolute shr-left-1/2 shr-top-1/2 shr-inline-block shr-h-[theme(fontSize.2xs)] shr-w-[theme(fontSize.2xs)] -shr-translate-x-1/2 -shr-translate-y-1/2 shr-text-2xs',\n 'shr-text-transparent peer-checked:shr-text-white peer-indeterminate:shr-text-white',\n 'peer-disabled:peer-checked:shr-text-white-darken peer-disabled:peer-indeterminate:shr-text-white-darken',\n 'forced-colors:shr-hidden',\n ],\n innerWrapper:\n 'shr-relative shr-box-border shr-inline-block shr-h-[theme(fontSize.base)] shr-w-[theme(fontSize.base)] shr-shrink-0 shr-translate-y-[0.125em] shr-leading-none',\n label: [\n 'smarthr-ui-Checkbox-label shr-ms-0.5 shr-cursor-pointer shr-text-base shr-leading-tight',\n '[[data-disabled=true]>&]:shr-pointer-events-none [[data-disabled=true]>&]:shr-cursor-not-allowed [[data-disabled=true]>&]:shr-text-disabled',\n ],\n },\n})\n\nexport const Checkbox = forwardRef<HTMLInputElement, Props>(\n ({ checked, mixed, error, className, children, disabled, id, ...rest }, ref) => {\n const classNames = useMemo(() => {\n const { wrapper, innerWrapper, box, input, iconWrap, icon, label } = classNameGenerator()\n\n return {\n wrapper: wrapper({ className }),\n innerWrapper: innerWrapper(),\n box: box(),\n input: input(),\n iconWrap: iconWrap(),\n icon: icon(),\n label: label(),\n }\n }, [className])\n\n const inputRef = useRef<HTMLInputElement>(null)\n\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n ref,\n () => inputRef.current,\n )\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.indeterminate = !!(checked && mixed)\n }\n }, [checked, mixed])\n\n const defaultId = useId()\n const checkBoxId = id || defaultId\n\n return (\n <span data-disabled={disabled} className={classNames.wrapper}>\n <span className={classNames.innerWrapper}>\n <input\n {...rest}\n ref={inputRef}\n type=\"checkbox\"\n id={checkBoxId}\n checked={checked}\n disabled={disabled}\n aria-invalid={error || undefined}\n className={classNames.input}\n data-smarthr-ui-input=\"true\"\n />\n <AriaHiddenBox className={classNames.box} />\n <CheckIconArea\n mixed={mixed}\n className={classNames.iconWrap}\n iconClassName={classNames.icon}\n />\n </span>\n\n <LabeledChildren htmlFor={checkBoxId} className={classNames.label}>\n {children}\n </LabeledChildren>\n </span>\n )\n },\n)\n\nconst AriaHiddenBox = memo<{ className: string }>(({ className }) => (\n <span className={className} aria-hidden=\"true\" />\n))\n\nconst CheckIconArea = memo<Pick<Props, 'mixed'> & { className: string; iconClassName: string }>(\n ({ mixed, className, iconClassName }) => (\n <span className={className}>\n {mixed ? (\n <FaMinusIcon className={iconClassName} />\n ) : (\n <FaCheckIcon className={iconClassName} />\n )}\n </span>\n ),\n)\n\nconst LabeledChildren = memo<PropsWithChildren<{ className: string; htmlFor: string }>>(\n ({ children, htmlFor, className }) =>\n children && (\n <label htmlFor={htmlFor} className={className}>\n {children}\n </label>\n ),\n)\n"],"names":[],"mappings":";;;;;;;;;;AA0BA;AACE;AACE;AACA;;;;;;;;;;;;;;AAcC;AACD;;;;AAIC;AACD;AACA;;;;;AAKC;AACD;AAEA;;;AAGC;AACF;AACF;AAEM;AAEH;AACE;;AAGE;;;;;;;;AAQJ;AAEA;;;AAQE;AACE;;AAEJ;AAEA;AACA;;AA6BF;AAGF;AAIA;AAYA;;"}
1
+ {"version":3,"file":"Checkbox.cjs","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ComponentPropsWithRef,\n type PropsWithChildren,\n forwardRef,\n memo,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { FaCheckIcon, FaMinusIcon } from '../Icon'\n\nexport type Props = PropsWithChildren<\n ComponentPropsWithRef<'input'> & {\n /** `true` のとき、チェック状態を `mixed` にする */\n mixed?: boolean\n /** チェックボックスにエラーがあるかどうか */\n error?: boolean\n }\n>\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: 'smarthr-ui-Checkbox shr-inline-flex shr-items-baseline',\n box: [\n 'shr-border-shorthand shr-pointer-events-none shr-absolute shr-box-border shr-h-full shr-w-full shr-rounded-s shr-bg-white',\n 'contrast-more:shr-border-high-contrast',\n /* 強制カラーモードのときは、ブラウザ標準のUIを表示する */\n 'forced-colors:shr-hidden',\n 'peer-checked:shr-border-main peer-checked:shr-bg-main contrast-more:peer-checked:shr-border-high-contrast',\n 'peer-indeterminate:shr-border-main peer-indeterminate:shr-bg-main contrast-more:peer-indeterminate:shr-border-high-contrast',\n 'peer-disabled:shr-border-disabled peer-disabled:shr-bg-white-darken',\n 'peer-disabled:peer-checked:shr-border-default peer-disabled:peer-checked:shr-bg-border',\n 'peer-disabled:peer-indeterminate:shr-border-default peer-disabled:peer-indeterminate:shr-bg-border',\n 'peer-focus-visible:shr-focus-indicator--outer',\n 'peer-hover:shr-shadow-input-hover',\n 'shr-border-default',\n 'peer-[[aria-invalid]]:shr-border-danger',\n ],\n input: [\n 'smarthr-ui-Checkbox-checkbox shr-peer shr-absolute shr-left-0 shr-top-0 shr-m-0 shr-h-full shr-w-full shr-cursor-pointer shr-opacity-0 disabled:shr-pointer-events-none',\n /* 強制カラーモードのときは、ブラウザ標準のUIを表示する */\n 'forced-colors:shr-static forced-colors:shr-opacity-100',\n ],\n icon: 'shr-fill-current',\n iconWrap: [\n 'shr-pointer-events-none shr-absolute shr-left-1/2 shr-top-1/2 shr-inline-block shr-h-[theme(fontSize.2xs)] shr-w-[theme(fontSize.2xs)] -shr-translate-x-1/2 -shr-translate-y-1/2 shr-text-2xs',\n 'shr-text-transparent peer-checked:shr-text-white peer-indeterminate:shr-text-white',\n 'peer-disabled:peer-checked:shr-text-white-darken peer-disabled:peer-indeterminate:shr-text-white-darken',\n 'forced-colors:shr-hidden',\n ],\n innerWrapper:\n 'shr-relative shr-box-border shr-inline-block shr-h-[theme(fontSize.base)] shr-w-[theme(fontSize.base)] shr-shrink-0 shr-translate-y-[0.125em] shr-leading-none',\n label: [\n 'smarthr-ui-Checkbox-label shr-ms-0.5 shr-cursor-pointer shr-text-base shr-leading-tight',\n '[[data-disabled=true]>&]:shr-pointer-events-none [[data-disabled=true]>&]:shr-cursor-not-allowed [[data-disabled=true]>&]:shr-text-disabled',\n ],\n },\n})\n\nexport const Checkbox = forwardRef<HTMLInputElement, Props>(\n ({ checked, mixed, error, className, children, disabled, id, ...rest }, ref) => {\n const classNames = useMemo(() => {\n const { wrapper, innerWrapper, box, input, iconWrap, icon, label } = classNameGenerator()\n\n return {\n wrapper: wrapper({ className }),\n innerWrapper: innerWrapper(),\n box: box(),\n input: input(),\n iconWrap: iconWrap(),\n icon: icon(),\n label: label(),\n }\n }, [className])\n\n const inputRef = useRef<HTMLInputElement>(null)\n\n const defaultId = useId()\n const checkBoxId = id || defaultId\n\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n ref,\n () => inputRef.current,\n )\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.indeterminate = !!(checked && mixed)\n }\n }, [checked, mixed])\n\n return (\n <span data-disabled={disabled} className={classNames.wrapper}>\n <span className={classNames.innerWrapper}>\n <input\n {...rest}\n ref={inputRef}\n type=\"checkbox\"\n id={checkBoxId}\n checked={checked}\n disabled={disabled}\n aria-invalid={error || undefined}\n className={classNames.input}\n data-smarthr-ui-input=\"true\"\n />\n <AriaHiddenBox className={classNames.box} />\n <CheckIconArea mixed={mixed} classNames={classNames} />\n </span>\n\n {children && (\n <label htmlFor={checkBoxId} className={classNames.label}>\n {children}\n </label>\n )}\n </span>\n )\n },\n)\n\nconst AriaHiddenBox = memo<{ className: string }>(({ className }) => (\n <span className={className} aria-hidden=\"true\" />\n))\n\nconst CheckIconArea = memo<\n Pick<Props, 'mixed'> & { classNames: { iconWrap: string; icon: string } }\n>(({ mixed, classNames }) => {\n const Icon = mixed ? FaMinusIcon : FaCheckIcon\n\n return (\n <span className={classNames.iconWrap}>\n <Icon className={classNames.icon} />\n </span>\n )\n})\n"],"names":[],"mappings":";;;;;;;;;;AA0BA;AACE;AACE;AACA;;;;;;;;;;;;;;AAcC;AACD;;;;AAIC;AACD;AACA;;;;;AAKC;AACD;AAEA;;;AAGC;AACF;AACF;AAEM;AAEH;AACE;;AAGE;;;;;;;;AAQJ;AAEA;AAEA;AACA;;;AAQE;AACE;;AAEJ;;AA2BF;AAGF;AAIA;;AAKE;AAKF;;"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { forwardRef, useMemo, useRef, useImperativeHandle, useEffect, useId, memo } from 'react';
3
+ import { forwardRef, useMemo, useRef, useId, useImperativeHandle, useEffect, memo } from 'react';
4
4
  import { tv as ce } from './../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.19_ts-node@10.9.2_@swc_core@1.15.46_@types_node@20.19.43_typescript@5.9.3__/vendor/tailwind-variants/dist/index.js';
5
5
  import { FaMinusIcon, FaCheckIcon } from '../Icon/FaIcon.js';
6
6
  import '../Icon/generateIcon.js';
@@ -57,19 +57,21 @@ const Checkbox = forwardRef(({ checked, mixed, error, className, children, disab
57
57
  };
58
58
  }, [className]);
59
59
  const inputRef = useRef(null);
60
+ const defaultId = useId();
61
+ const checkBoxId = id || defaultId;
60
62
  useImperativeHandle(ref, () => inputRef.current);
61
63
  useEffect(() => {
62
64
  if (inputRef.current) {
63
65
  inputRef.current.indeterminate = !!(checked && mixed);
64
66
  }
65
67
  }, [checked, mixed]);
66
- const defaultId = useId();
67
- const checkBoxId = id || defaultId;
68
- return (jsxs("span", { "data-disabled": disabled, className: classNames.wrapper, children: [jsxs("span", { className: classNames.innerWrapper, children: [jsx("input", { ...rest, ref: inputRef, type: "checkbox", id: checkBoxId, checked: checked, disabled: disabled, "aria-invalid": error || undefined, className: classNames.input, "data-smarthr-ui-input": "true" }), jsx(AriaHiddenBox, { className: classNames.box }), jsx(CheckIconArea, { mixed: mixed, className: classNames.iconWrap, iconClassName: classNames.icon })] }), jsx(LabeledChildren, { htmlFor: checkBoxId, className: classNames.label, children: children })] }));
68
+ return (jsxs("span", { "data-disabled": disabled, className: classNames.wrapper, children: [jsxs("span", { className: classNames.innerWrapper, children: [jsx("input", { ...rest, ref: inputRef, type: "checkbox", id: checkBoxId, checked: checked, disabled: disabled, "aria-invalid": error || undefined, className: classNames.input, "data-smarthr-ui-input": "true" }), jsx(AriaHiddenBox, { className: classNames.box }), jsx(CheckIconArea, { mixed: mixed, classNames: classNames })] }), children && (jsx("label", { htmlFor: checkBoxId, className: classNames.label, children: children }))] }));
69
69
  });
70
70
  const AriaHiddenBox = memo(({ className }) => (jsx("span", { className: className, "aria-hidden": "true" })));
71
- const CheckIconArea = memo(({ mixed, className, iconClassName }) => (jsx("span", { className: className, children: mixed ? (jsx(FaMinusIcon, { className: iconClassName })) : (jsx(FaCheckIcon, { className: iconClassName })) })));
72
- const LabeledChildren = memo(({ children, htmlFor, className }) => children && (jsx("label", { htmlFor: htmlFor, className: className, children: children })));
71
+ const CheckIconArea = memo(({ mixed, classNames }) => {
72
+ const Icon = mixed ? FaMinusIcon : FaCheckIcon;
73
+ return (jsx("span", { className: classNames.iconWrap, children: jsx(Icon, { className: classNames.icon }) }));
74
+ });
73
75
 
74
76
  export { Checkbox };
75
77
  //# sourceMappingURL=Checkbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ComponentPropsWithRef,\n type PropsWithChildren,\n forwardRef,\n memo,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { FaCheckIcon, FaMinusIcon } from '../Icon'\n\nexport type Props = PropsWithChildren<\n ComponentPropsWithRef<'input'> & {\n /** `true` のとき、チェック状態を `mixed` にする */\n mixed?: boolean\n /** チェックボックスにエラーがあるかどうか */\n error?: boolean\n }\n>\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: 'smarthr-ui-Checkbox shr-inline-flex shr-items-baseline',\n box: [\n 'shr-border-shorthand shr-pointer-events-none shr-absolute shr-box-border shr-h-full shr-w-full shr-rounded-s shr-bg-white',\n 'contrast-more:shr-border-high-contrast',\n /* 強制カラーモードのときは、ブラウザ標準のUIを表示する */\n 'forced-colors:shr-hidden',\n 'peer-checked:shr-border-main peer-checked:shr-bg-main contrast-more:peer-checked:shr-border-high-contrast',\n 'peer-indeterminate:shr-border-main peer-indeterminate:shr-bg-main contrast-more:peer-indeterminate:shr-border-high-contrast',\n 'peer-disabled:shr-border-disabled peer-disabled:shr-bg-white-darken',\n 'peer-disabled:peer-checked:shr-border-default peer-disabled:peer-checked:shr-bg-border',\n 'peer-disabled:peer-indeterminate:shr-border-default peer-disabled:peer-indeterminate:shr-bg-border',\n 'peer-focus-visible:shr-focus-indicator--outer',\n 'peer-hover:shr-shadow-input-hover',\n 'shr-border-default',\n 'peer-[[aria-invalid]]:shr-border-danger',\n ],\n input: [\n 'smarthr-ui-Checkbox-checkbox shr-peer shr-absolute shr-left-0 shr-top-0 shr-m-0 shr-h-full shr-w-full shr-cursor-pointer shr-opacity-0 disabled:shr-pointer-events-none',\n /* 強制カラーモードのときは、ブラウザ標準のUIを表示する */\n 'forced-colors:shr-static forced-colors:shr-opacity-100',\n ],\n icon: 'shr-fill-current',\n iconWrap: [\n 'shr-pointer-events-none shr-absolute shr-left-1/2 shr-top-1/2 shr-inline-block shr-h-[theme(fontSize.2xs)] shr-w-[theme(fontSize.2xs)] -shr-translate-x-1/2 -shr-translate-y-1/2 shr-text-2xs',\n 'shr-text-transparent peer-checked:shr-text-white peer-indeterminate:shr-text-white',\n 'peer-disabled:peer-checked:shr-text-white-darken peer-disabled:peer-indeterminate:shr-text-white-darken',\n 'forced-colors:shr-hidden',\n ],\n innerWrapper:\n 'shr-relative shr-box-border shr-inline-block shr-h-[theme(fontSize.base)] shr-w-[theme(fontSize.base)] shr-shrink-0 shr-translate-y-[0.125em] shr-leading-none',\n label: [\n 'smarthr-ui-Checkbox-label shr-ms-0.5 shr-cursor-pointer shr-text-base shr-leading-tight',\n '[[data-disabled=true]>&]:shr-pointer-events-none [[data-disabled=true]>&]:shr-cursor-not-allowed [[data-disabled=true]>&]:shr-text-disabled',\n ],\n },\n})\n\nexport const Checkbox = forwardRef<HTMLInputElement, Props>(\n ({ checked, mixed, error, className, children, disabled, id, ...rest }, ref) => {\n const classNames = useMemo(() => {\n const { wrapper, innerWrapper, box, input, iconWrap, icon, label } = classNameGenerator()\n\n return {\n wrapper: wrapper({ className }),\n innerWrapper: innerWrapper(),\n box: box(),\n input: input(),\n iconWrap: iconWrap(),\n icon: icon(),\n label: label(),\n }\n }, [className])\n\n const inputRef = useRef<HTMLInputElement>(null)\n\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n ref,\n () => inputRef.current,\n )\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.indeterminate = !!(checked && mixed)\n }\n }, [checked, mixed])\n\n const defaultId = useId()\n const checkBoxId = id || defaultId\n\n return (\n <span data-disabled={disabled} className={classNames.wrapper}>\n <span className={classNames.innerWrapper}>\n <input\n {...rest}\n ref={inputRef}\n type=\"checkbox\"\n id={checkBoxId}\n checked={checked}\n disabled={disabled}\n aria-invalid={error || undefined}\n className={classNames.input}\n data-smarthr-ui-input=\"true\"\n />\n <AriaHiddenBox className={classNames.box} />\n <CheckIconArea\n mixed={mixed}\n className={classNames.iconWrap}\n iconClassName={classNames.icon}\n />\n </span>\n\n <LabeledChildren htmlFor={checkBoxId} className={classNames.label}>\n {children}\n </LabeledChildren>\n </span>\n )\n },\n)\n\nconst AriaHiddenBox = memo<{ className: string }>(({ className }) => (\n <span className={className} aria-hidden=\"true\" />\n))\n\nconst CheckIconArea = memo<Pick<Props, 'mixed'> & { className: string; iconClassName: string }>(\n ({ mixed, className, iconClassName }) => (\n <span className={className}>\n {mixed ? (\n <FaMinusIcon className={iconClassName} />\n ) : (\n <FaCheckIcon className={iconClassName} />\n )}\n </span>\n ),\n)\n\nconst LabeledChildren = memo<PropsWithChildren<{ className: string; htmlFor: string }>>(\n ({ children, htmlFor, className }) =>\n children && (\n <label htmlFor={htmlFor} className={className}>\n {children}\n </label>\n ),\n)\n"],"names":[],"mappings":";;;;;;;;AA0BA;AACE;AACE;AACA;;;;;;;;;;;;;;AAcC;AACD;;;;AAIC;AACD;AACA;;;;;AAKC;AACD;AAEA;;;AAGC;AACF;AACF;AAEM;AAEH;AACE;;AAGE;;;;;;;;AAQJ;AAEA;;;AAQE;AACE;;AAEJ;AAEA;AACA;;AA6BF;AAGF;AAIA;AAYA;;"}
1
+ {"version":3,"file":"Checkbox.js","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ComponentPropsWithRef,\n type PropsWithChildren,\n forwardRef,\n memo,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { FaCheckIcon, FaMinusIcon } from '../Icon'\n\nexport type Props = PropsWithChildren<\n ComponentPropsWithRef<'input'> & {\n /** `true` のとき、チェック状態を `mixed` にする */\n mixed?: boolean\n /** チェックボックスにエラーがあるかどうか */\n error?: boolean\n }\n>\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: 'smarthr-ui-Checkbox shr-inline-flex shr-items-baseline',\n box: [\n 'shr-border-shorthand shr-pointer-events-none shr-absolute shr-box-border shr-h-full shr-w-full shr-rounded-s shr-bg-white',\n 'contrast-more:shr-border-high-contrast',\n /* 強制カラーモードのときは、ブラウザ標準のUIを表示する */\n 'forced-colors:shr-hidden',\n 'peer-checked:shr-border-main peer-checked:shr-bg-main contrast-more:peer-checked:shr-border-high-contrast',\n 'peer-indeterminate:shr-border-main peer-indeterminate:shr-bg-main contrast-more:peer-indeterminate:shr-border-high-contrast',\n 'peer-disabled:shr-border-disabled peer-disabled:shr-bg-white-darken',\n 'peer-disabled:peer-checked:shr-border-default peer-disabled:peer-checked:shr-bg-border',\n 'peer-disabled:peer-indeterminate:shr-border-default peer-disabled:peer-indeterminate:shr-bg-border',\n 'peer-focus-visible:shr-focus-indicator--outer',\n 'peer-hover:shr-shadow-input-hover',\n 'shr-border-default',\n 'peer-[[aria-invalid]]:shr-border-danger',\n ],\n input: [\n 'smarthr-ui-Checkbox-checkbox shr-peer shr-absolute shr-left-0 shr-top-0 shr-m-0 shr-h-full shr-w-full shr-cursor-pointer shr-opacity-0 disabled:shr-pointer-events-none',\n /* 強制カラーモードのときは、ブラウザ標準のUIを表示する */\n 'forced-colors:shr-static forced-colors:shr-opacity-100',\n ],\n icon: 'shr-fill-current',\n iconWrap: [\n 'shr-pointer-events-none shr-absolute shr-left-1/2 shr-top-1/2 shr-inline-block shr-h-[theme(fontSize.2xs)] shr-w-[theme(fontSize.2xs)] -shr-translate-x-1/2 -shr-translate-y-1/2 shr-text-2xs',\n 'shr-text-transparent peer-checked:shr-text-white peer-indeterminate:shr-text-white',\n 'peer-disabled:peer-checked:shr-text-white-darken peer-disabled:peer-indeterminate:shr-text-white-darken',\n 'forced-colors:shr-hidden',\n ],\n innerWrapper:\n 'shr-relative shr-box-border shr-inline-block shr-h-[theme(fontSize.base)] shr-w-[theme(fontSize.base)] shr-shrink-0 shr-translate-y-[0.125em] shr-leading-none',\n label: [\n 'smarthr-ui-Checkbox-label shr-ms-0.5 shr-cursor-pointer shr-text-base shr-leading-tight',\n '[[data-disabled=true]>&]:shr-pointer-events-none [[data-disabled=true]>&]:shr-cursor-not-allowed [[data-disabled=true]>&]:shr-text-disabled',\n ],\n },\n})\n\nexport const Checkbox = forwardRef<HTMLInputElement, Props>(\n ({ checked, mixed, error, className, children, disabled, id, ...rest }, ref) => {\n const classNames = useMemo(() => {\n const { wrapper, innerWrapper, box, input, iconWrap, icon, label } = classNameGenerator()\n\n return {\n wrapper: wrapper({ className }),\n innerWrapper: innerWrapper(),\n box: box(),\n input: input(),\n iconWrap: iconWrap(),\n icon: icon(),\n label: label(),\n }\n }, [className])\n\n const inputRef = useRef<HTMLInputElement>(null)\n\n const defaultId = useId()\n const checkBoxId = id || defaultId\n\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n ref,\n () => inputRef.current,\n )\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.indeterminate = !!(checked && mixed)\n }\n }, [checked, mixed])\n\n return (\n <span data-disabled={disabled} className={classNames.wrapper}>\n <span className={classNames.innerWrapper}>\n <input\n {...rest}\n ref={inputRef}\n type=\"checkbox\"\n id={checkBoxId}\n checked={checked}\n disabled={disabled}\n aria-invalid={error || undefined}\n className={classNames.input}\n data-smarthr-ui-input=\"true\"\n />\n <AriaHiddenBox className={classNames.box} />\n <CheckIconArea mixed={mixed} classNames={classNames} />\n </span>\n\n {children && (\n <label htmlFor={checkBoxId} className={classNames.label}>\n {children}\n </label>\n )}\n </span>\n )\n },\n)\n\nconst AriaHiddenBox = memo<{ className: string }>(({ className }) => (\n <span className={className} aria-hidden=\"true\" />\n))\n\nconst CheckIconArea = memo<\n Pick<Props, 'mixed'> & { classNames: { iconWrap: string; icon: string } }\n>(({ mixed, classNames }) => {\n const Icon = mixed ? FaMinusIcon : FaCheckIcon\n\n return (\n <span className={classNames.iconWrap}>\n <Icon className={classNames.icon} />\n </span>\n )\n})\n"],"names":[],"mappings":";;;;;;;;AA0BA;AACE;AACE;AACA;;;;;;;;;;;;;;AAcC;AACD;;;;AAIC;AACD;AACA;;;;;AAKC;AACD;AAEA;;;AAGC;AACF;AACF;AAEM;AAEH;AACE;;AAGE;;;;;;;;AAQJ;AAEA;AAEA;AACA;;;AAQE;AACE;;AAEJ;;AA2BF;AAGF;AAIA;;AAKE;AAKF;;"}
@@ -9,6 +9,7 @@ const classNameGenerator = index.tv({
9
9
  'smarthr-ui-Chip',
10
10
  'shr-border-shorthand shr-rounded-full shr-bg-white shr-leading-none shr-text-black',
11
11
  'contrast-more:shr-border-high-contrast',
12
+ 'data-[disabled]:shr-bg-white/50 data-[disabled]:shr-text-disabled',
12
13
  ],
13
14
  variants: {
14
15
  color: {
@@ -21,18 +22,11 @@ const classNameGenerator = index.tv({
21
22
  size: {
22
23
  S: 'shr-px-0.5 shr-py-0.25 shr-text-sm',
23
24
  },
24
- disabled: {
25
- true: 'shr-bg-white/50 shr-text-disabled',
26
- },
27
- },
28
- defaultVariants: {
29
- size: 'S',
30
- color: 'grey',
31
25
  },
32
26
  });
33
27
  const Chip = ({ size, color, disabled, className, ...rest }) => {
34
- const actualClassName = React.useMemo(() => classNameGenerator({ size, color, disabled, className }), [size, color, disabled, className]);
35
- return jsxRuntime.jsx("span", { ...rest, className: actualClassName });
28
+ const actualClassName = React.useMemo(() => classNameGenerator({ size: size || 'S', color: color || 'grey', className }), [size, color, className]);
29
+ return jsxRuntime.jsx("span", { ...rest, "data-disabled": disabled || undefined, className: actualClassName });
36
30
  };
37
31
 
38
32
  exports.Chip = Chip;
@@ -1 +1 @@
1
- {"version":3,"file":"Chip.cjs","sources":["../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import { type ComponentPropsWithoutRef, type FC, type PropsWithChildren, useMemo } from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\ntype Props = PropsWithChildren<\n VariantProps<typeof classNameGenerator> & ComponentPropsWithoutRef<'span'>\n>\n\nconst classNameGenerator = tv({\n base: [\n 'smarthr-ui-Chip',\n 'shr-border-shorthand shr-rounded-full shr-bg-white shr-leading-none shr-text-black',\n 'contrast-more:shr-border-high-contrast',\n ],\n variants: {\n color: {\n grey: 'shr-border-grey-20',\n blue: 'shr-border-main',\n green: 'shr-border-green',\n orange: 'shr-border-orange',\n red: 'shr-border-danger',\n },\n size: {\n S: 'shr-px-0.5 shr-py-0.25 shr-text-sm',\n },\n disabled: {\n true: 'shr-bg-white/50 shr-text-disabled',\n },\n },\n defaultVariants: {\n size: 'S',\n color: 'grey',\n },\n})\n\nexport const Chip: FC<Props> = ({ size, color, disabled, className, ...rest }) => {\n const actualClassName = useMemo(\n () => classNameGenerator({ size, color, disabled, className }),\n [size, color, disabled, className],\n )\n return <span {...rest} className={actualClassName} />\n}\n"],"names":["tv","useMemo","_jsx"],"mappings":";;;;;;AAOA,MAAM,kBAAkB,GAAGA,QAAE,CAAC;AAC5B,IAAA,IAAI,EAAE;QACJ,iBAAiB;QACjB,oFAAoF;QACpF,wCAAwC;AACzC,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,oBAAoB;AAC1B,YAAA,IAAI,EAAE,iBAAiB;AACvB,YAAA,KAAK,EAAE,kBAAkB;AACzB,YAAA,MAAM,EAAE,mBAAmB;AAC3B,YAAA,GAAG,EAAE,mBAAmB;AACzB,SAAA;AACD,QAAA,IAAI,EAAE;AACJ,YAAA,CAAC,EAAE,oCAAoC;AACxC,SAAA;AACD,QAAA,QAAQ,EAAE;AACR,YAAA,IAAI,EAAE,mCAAmC;AAC1C,SAAA;AACF,KAAA;AACD,IAAA,eAAe,EAAE;AACf,QAAA,IAAI,EAAE,GAAG;AACT,QAAA,KAAK,EAAE,MAAM;AACd,KAAA;AACF,CAAA,CAAC;AAEK,MAAM,IAAI,GAAc,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,KAAI;AAC/E,IAAA,MAAM,eAAe,GAAGC,aAAO,CAC7B,MAAM,kBAAkB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAC9D,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CACnC;AACD,IAAA,OAAOC,4BAAU,IAAI,EAAE,SAAS,EAAE,eAAe,GAAI;AACvD;;;;"}
1
+ {"version":3,"file":"Chip.cjs","sources":["../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import { type ComponentPropsWithoutRef, type FC, type PropsWithChildren, useMemo } from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\ntype Props = PropsWithChildren<\n VariantProps<typeof classNameGenerator> &\n ComponentPropsWithoutRef<'span'> & { disabled?: boolean }\n>\n\nconst classNameGenerator = tv({\n base: [\n 'smarthr-ui-Chip',\n 'shr-border-shorthand shr-rounded-full shr-bg-white shr-leading-none shr-text-black',\n 'contrast-more:shr-border-high-contrast',\n 'data-[disabled]:shr-bg-white/50 data-[disabled]:shr-text-disabled',\n ],\n variants: {\n color: {\n grey: 'shr-border-grey-20',\n blue: 'shr-border-main',\n green: 'shr-border-green',\n orange: 'shr-border-orange',\n red: 'shr-border-danger',\n },\n size: {\n S: 'shr-px-0.5 shr-py-0.25 shr-text-sm',\n },\n },\n})\n\nexport const Chip: FC<Props> = ({ size, color, disabled, className, ...rest }) => {\n const actualClassName = useMemo(\n () => classNameGenerator({ size: size || 'S', color: color || 'grey', className }),\n [size, color, className],\n )\n\n return <span {...rest} data-disabled={disabled || undefined} className={actualClassName} />\n}\n"],"names":["tv","useMemo","_jsx"],"mappings":";;;;;;AAQA,MAAM,kBAAkB,GAAGA,QAAE,CAAC;AAC5B,IAAA,IAAI,EAAE;QACJ,iBAAiB;QACjB,oFAAoF;QACpF,wCAAwC;QACxC,mEAAmE;AACpE,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,oBAAoB;AAC1B,YAAA,IAAI,EAAE,iBAAiB;AACvB,YAAA,KAAK,EAAE,kBAAkB;AACzB,YAAA,MAAM,EAAE,mBAAmB;AAC3B,YAAA,GAAG,EAAE,mBAAmB;AACzB,SAAA;AACD,QAAA,IAAI,EAAE;AACJ,YAAA,CAAC,EAAE,oCAAoC;AACxC,SAAA;AACF,KAAA;AACF,CAAA,CAAC;AAEK,MAAM,IAAI,GAAc,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,KAAI;AAC/E,IAAA,MAAM,eAAe,GAAGC,aAAO,CAC7B,MAAM,kBAAkB,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,GAAG,EAAE,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,SAAS,EAAE,CAAC,EAClF,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CACzB;IAED,OAAOC,cAAA,CAAA,MAAA,EAAA,EAAA,GAAU,IAAI,EAAA,eAAA,EAAiB,QAAQ,IAAI,SAAS,EAAE,SAAS,EAAE,eAAe,EAAA,CAAI;AAC7F;;;;"}
@@ -1,6 +1,8 @@
1
1
  import { type ComponentPropsWithoutRef, type FC, type PropsWithChildren } from 'react';
2
2
  import { type VariantProps } from 'tailwind-variants';
3
- type Props = PropsWithChildren<VariantProps<typeof classNameGenerator> & ComponentPropsWithoutRef<'span'>>;
3
+ type Props = PropsWithChildren<VariantProps<typeof classNameGenerator> & ComponentPropsWithoutRef<'span'> & {
4
+ disabled?: boolean;
5
+ }>;
4
6
  declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
5
7
  color: {
6
8
  grey: string;
@@ -12,9 +14,6 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
12
14
  size: {
13
15
  S: string;
14
16
  };
15
- disabled: {
16
- true: string;
17
- };
18
17
  }, undefined, string[], import("tailwind-variants/dist/config").TVConfig<{
19
18
  color: {
20
19
  grey: string;
@@ -26,9 +25,6 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
26
25
  size: {
27
26
  S: string;
28
27
  };
29
- disabled: {
30
- true: string;
31
- };
32
28
  }, {
33
29
  color: {
34
30
  grey: string;
@@ -40,9 +36,6 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
40
36
  size: {
41
37
  S: string;
42
38
  };
43
- disabled: {
44
- true: string;
45
- };
46
39
  }>, {
47
40
  color: {
48
41
  grey: string;
@@ -54,9 +47,6 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
54
47
  size: {
55
48
  S: string;
56
49
  };
57
- disabled: {
58
- true: string;
59
- };
60
50
  }, undefined, import("tailwind-variants").TVReturnType<{
61
51
  color: {
62
52
  grey: string;
@@ -68,9 +58,6 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
68
58
  size: {
69
59
  S: string;
70
60
  };
71
- disabled: {
72
- true: string;
73
- };
74
61
  }, undefined, string[], import("tailwind-variants/dist/config").TVConfig<{
75
62
  color: {
76
63
  grey: string;
@@ -82,9 +69,6 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
82
69
  size: {
83
70
  S: string;
84
71
  };
85
- disabled: {
86
- true: string;
87
- };
88
72
  }, {
89
73
  color: {
90
74
  grey: string;
@@ -96,9 +80,6 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
96
80
  size: {
97
81
  S: string;
98
82
  };
99
- disabled: {
100
- true: string;
101
- };
102
83
  }>, unknown, unknown, undefined>>;
103
84
  export declare const Chip: FC<Props>;
104
85
  export {};
@@ -7,6 +7,7 @@ const classNameGenerator = ce({
7
7
  'smarthr-ui-Chip',
8
8
  'shr-border-shorthand shr-rounded-full shr-bg-white shr-leading-none shr-text-black',
9
9
  'contrast-more:shr-border-high-contrast',
10
+ 'data-[disabled]:shr-bg-white/50 data-[disabled]:shr-text-disabled',
10
11
  ],
11
12
  variants: {
12
13
  color: {
@@ -19,18 +20,11 @@ const classNameGenerator = ce({
19
20
  size: {
20
21
  S: 'shr-px-0.5 shr-py-0.25 shr-text-sm',
21
22
  },
22
- disabled: {
23
- true: 'shr-bg-white/50 shr-text-disabled',
24
- },
25
- },
26
- defaultVariants: {
27
- size: 'S',
28
- color: 'grey',
29
23
  },
30
24
  });
31
25
  const Chip = ({ size, color, disabled, className, ...rest }) => {
32
- const actualClassName = useMemo(() => classNameGenerator({ size, color, disabled, className }), [size, color, disabled, className]);
33
- return jsx("span", { ...rest, className: actualClassName });
26
+ const actualClassName = useMemo(() => classNameGenerator({ size: size || 'S', color: color || 'grey', className }), [size, color, className]);
27
+ return jsx("span", { ...rest, "data-disabled": disabled || undefined, className: actualClassName });
34
28
  };
35
29
 
36
30
  export { Chip };
@@ -1 +1 @@
1
- {"version":3,"file":"Chip.js","sources":["../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import { type ComponentPropsWithoutRef, type FC, type PropsWithChildren, useMemo } from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\ntype Props = PropsWithChildren<\n VariantProps<typeof classNameGenerator> & ComponentPropsWithoutRef<'span'>\n>\n\nconst classNameGenerator = tv({\n base: [\n 'smarthr-ui-Chip',\n 'shr-border-shorthand shr-rounded-full shr-bg-white shr-leading-none shr-text-black',\n 'contrast-more:shr-border-high-contrast',\n ],\n variants: {\n color: {\n grey: 'shr-border-grey-20',\n blue: 'shr-border-main',\n green: 'shr-border-green',\n orange: 'shr-border-orange',\n red: 'shr-border-danger',\n },\n size: {\n S: 'shr-px-0.5 shr-py-0.25 shr-text-sm',\n },\n disabled: {\n true: 'shr-bg-white/50 shr-text-disabled',\n },\n },\n defaultVariants: {\n size: 'S',\n color: 'grey',\n },\n})\n\nexport const Chip: FC<Props> = ({ size, color, disabled, className, ...rest }) => {\n const actualClassName = useMemo(\n () => classNameGenerator({ size, color, disabled, className }),\n [size, color, disabled, className],\n )\n return <span {...rest} className={actualClassName} />\n}\n"],"names":["tv","_jsx"],"mappings":";;;;AAOA,MAAM,kBAAkB,GAAGA,EAAE,CAAC;AAC5B,IAAA,IAAI,EAAE;QACJ,iBAAiB;QACjB,oFAAoF;QACpF,wCAAwC;AACzC,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,oBAAoB;AAC1B,YAAA,IAAI,EAAE,iBAAiB;AACvB,YAAA,KAAK,EAAE,kBAAkB;AACzB,YAAA,MAAM,EAAE,mBAAmB;AAC3B,YAAA,GAAG,EAAE,mBAAmB;AACzB,SAAA;AACD,QAAA,IAAI,EAAE;AACJ,YAAA,CAAC,EAAE,oCAAoC;AACxC,SAAA;AACD,QAAA,QAAQ,EAAE;AACR,YAAA,IAAI,EAAE,mCAAmC;AAC1C,SAAA;AACF,KAAA;AACD,IAAA,eAAe,EAAE;AACf,QAAA,IAAI,EAAE,GAAG;AACT,QAAA,KAAK,EAAE,MAAM;AACd,KAAA;AACF,CAAA,CAAC;AAEK,MAAM,IAAI,GAAc,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,KAAI;AAC/E,IAAA,MAAM,eAAe,GAAG,OAAO,CAC7B,MAAM,kBAAkB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAC9D,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CACnC;AACD,IAAA,OAAOC,iBAAU,IAAI,EAAE,SAAS,EAAE,eAAe,GAAI;AACvD;;;;"}
1
+ {"version":3,"file":"Chip.js","sources":["../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import { type ComponentPropsWithoutRef, type FC, type PropsWithChildren, useMemo } from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\ntype Props = PropsWithChildren<\n VariantProps<typeof classNameGenerator> &\n ComponentPropsWithoutRef<'span'> & { disabled?: boolean }\n>\n\nconst classNameGenerator = tv({\n base: [\n 'smarthr-ui-Chip',\n 'shr-border-shorthand shr-rounded-full shr-bg-white shr-leading-none shr-text-black',\n 'contrast-more:shr-border-high-contrast',\n 'data-[disabled]:shr-bg-white/50 data-[disabled]:shr-text-disabled',\n ],\n variants: {\n color: {\n grey: 'shr-border-grey-20',\n blue: 'shr-border-main',\n green: 'shr-border-green',\n orange: 'shr-border-orange',\n red: 'shr-border-danger',\n },\n size: {\n S: 'shr-px-0.5 shr-py-0.25 shr-text-sm',\n },\n },\n})\n\nexport const Chip: FC<Props> = ({ size, color, disabled, className, ...rest }) => {\n const actualClassName = useMemo(\n () => classNameGenerator({ size: size || 'S', color: color || 'grey', className }),\n [size, color, className],\n )\n\n return <span {...rest} data-disabled={disabled || undefined} className={actualClassName} />\n}\n"],"names":["tv","_jsx"],"mappings":";;;;AAQA,MAAM,kBAAkB,GAAGA,EAAE,CAAC;AAC5B,IAAA,IAAI,EAAE;QACJ,iBAAiB;QACjB,oFAAoF;QACpF,wCAAwC;QACxC,mEAAmE;AACpE,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,oBAAoB;AAC1B,YAAA,IAAI,EAAE,iBAAiB;AACvB,YAAA,KAAK,EAAE,kBAAkB;AACzB,YAAA,MAAM,EAAE,mBAAmB;AAC3B,YAAA,GAAG,EAAE,mBAAmB;AACzB,SAAA;AACD,QAAA,IAAI,EAAE;AACJ,YAAA,CAAC,EAAE,oCAAoC;AACxC,SAAA;AACF,KAAA;AACF,CAAA,CAAC;AAEK,MAAM,IAAI,GAAc,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,KAAI;AAC/E,IAAA,MAAM,eAAe,GAAG,OAAO,CAC7B,MAAM,kBAAkB,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,GAAG,EAAE,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,SAAS,EAAE,CAAC,EAClF,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CACzB;IAED,OAAOC,GAAA,CAAA,MAAA,EAAA,EAAA,GAAU,IAAI,EAAA,eAAA,EAAiB,QAAQ,IAAI,SAAS,EAAE,SAAS,EAAE,eAAe,EAAA,CAAI;AAC7F;;;;"}
@@ -3,7 +3,6 @@
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
  var React = require('react');
5
5
  var index = require('./../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.19_ts-node@10.9.2_@swc_core@1.15.46_@types_node@20.19.43_typescript@5.9.3__/vendor/tailwind-variants/dist/index.cjs');
6
- var hooks_useLatest = require('../../hooks/useLatest.cjs');
7
6
  require('../../intl/IntlProvider.cjs');
8
7
  require('react-intl');
9
8
  var intl_Localizer = require('../../intl/Localizer.cjs');
@@ -29,44 +28,11 @@ const classNameGenerator = index.tv({
29
28
  },
30
29
  },
31
30
  });
32
- const ItemButton = ({ option, onAdd, onSelect, onMouseOver, activeRef }) => {
33
- const latest = hooks_useLatest.useLatest({ onAdd, onSelect, onMouseOver, option });
34
- const handleMouseOver = React.useCallback(() => {
35
- latest.onMouseOver(latest.option);
36
- }, [latest]);
37
- const handleAddClick = React.useCallback(() => {
38
- latest.onAdd?.(latest.option);
39
- }, [latest]);
40
- const handleSelectClick = React.useCallback(() => {
41
- latest.onSelect(latest.option);
42
- }, [latest]);
43
- const commonAttrs = {
44
- id: option.id,
45
- label: option.item.label,
46
- activeRef,
47
- onMouseOver: handleMouseOver,
48
- };
49
- return option.isNew ? (jsxRuntime.jsx(AddButton, { ...commonAttrs, onClick: handleAddClick })) : (jsxRuntime.jsx(SelectButton, { ...commonAttrs, disabled: option.item.disabled, selected: option.selected, onClick: handleSelectClick }));
31
+ const CLASS_NAMES = {
32
+ new: classNameGenerator({ new: true }),
33
+ select: classNameGenerator({ new: false }),
50
34
  };
51
- const typedMemo = React.memo;
52
- const Memoized = typedMemo(ItemButton);
53
- const AddButton = React.memo(({ id, label, activeRef, onClick, onMouseOver }) => {
54
- const className = classNameGenerator({
55
- new: true,
56
- });
57
- return (jsxRuntime.jsx("button", { ref: activeRef, type: "button", role: "option", "aria-selected": false, id: id, "data-active": !!activeRef, onClick: onClick,
58
- // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
59
- onMouseOver: onMouseOver, className: className, children: jsxRuntime.jsx(MemoizedNewIconWithText, { label: label }) }));
60
- });
61
- const MemoizedNewIconWithText = React.memo(({ label }) => (jsxRuntime.jsx(components_Text_Text.Text, { color: "TEXT_LINK", icon: jsxRuntime.jsx(components_Icon_FaIcon.FaCirclePlusIcon, { color: "TEXT_LINK" }), children: jsxRuntime.jsx(intl_Localizer.Localizer, { id: "smarthr-ui/Combobox/addItemButtonLabel", defaultText: "\u300C{name}\u300D\u3092\u8FFD\u52A0", values: { name: label } }) })));
62
- const SelectButton = React.memo(({ id, label, disabled, selected, activeRef, onClick, onMouseOver }) => {
63
- const className = classNameGenerator({
64
- new: false,
65
- });
66
- return (jsxRuntime.jsx("button", { ref: activeRef, type: "button", role: "option", id: id, disabled: disabled, "aria-selected": selected, "data-active": !!activeRef, onClick: onClick,
67
- // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
68
- onMouseOver: onMouseOver, className: className, children: label }));
69
- });
35
+ const ItemButton = React.memo(({ id, label, disabled, selected, isNew, activeRef }) => (jsxRuntime.jsx("button", { ref: activeRef, type: "button", role: "option", id: id, "data-active": !!activeRef, "aria-selected": isNew ? false : selected, disabled: isNew ? undefined : disabled, className: isNew ? CLASS_NAMES.new : CLASS_NAMES.select, children: isNew ? (jsxRuntime.jsx(components_Text_Text.Text, { color: "TEXT_LINK", icon: jsxRuntime.jsx(components_Icon_FaIcon.FaCirclePlusIcon, { color: "TEXT_LINK" }), children: jsxRuntime.jsx(intl_Localizer.Localizer, { id: "smarthr-ui/Combobox/addItemButtonLabel", defaultText: "\u300C{name}\u300D\u3092\u8FFD\u52A0", values: { name: label } }) })) : (label) })));
70
36
 
71
- exports.ItemButton = Memoized;
37
+ exports.ItemButton = ItemButton;
72
38
  //# sourceMappingURL=ItemButton.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ItemButton.cjs","sources":["../../../src/components/Combobox/ItemButton.tsx"],"sourcesContent":["import { type ReactNode, type RefObject, memo, useCallback } from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { useLatest } from '../../hooks/useLatest'\nimport { Localizer } from '../../intl'\nimport { FaCirclePlusIcon } from '../Icon'\nimport { Text } from '../Text'\n\nimport type { ComboboxOption } from './types'\n\ntype Props<T> = {\n option: ComboboxOption<T>\n onAdd?: (option: ComboboxOption<T>) => void\n onSelect: (option: ComboboxOption<T>) => void\n onMouseOver: (option: ComboboxOption<T>) => void\n activeRef: RefObject<HTMLButtonElement> | undefined\n}\n\nconst classNameGenerator = tv({\n base: [\n 'shr-block shr-min-w-full shr-cursor-pointer shr-border-none shr-px-1 shr-py-0.5 shr-text-left shr-text-base shr-leading-tight',\n 'aria-selected:shr-text-white',\n 'disabled:shr-cursor-not-allowed disabled:shr-text-disabled',\n 'data-[active=true]:shr-bg-white-darken data-[active=true]:aria-selected:shr-bg-main-darken',\n 'data-[active=false]:shr-bg-white data-[active=false]:aria-selected:shr-bg-main',\n ],\n variants: {\n new: {\n true: 'smarthr-ui-Combobox-addButton shr-flex shr-items-center',\n false: 'smarthr-ui-Combobox-selectButton',\n },\n },\n})\n\nconst ItemButton = <T,>({ option, onAdd, onSelect, onMouseOver, activeRef }: Props<T>) => {\n const latest = useLatest({ onAdd, onSelect, onMouseOver, option })\n\n const handleMouseOver = useCallback(() => {\n latest.onMouseOver(latest.option)\n }, [latest])\n\n const handleAddClick = useCallback(() => {\n latest.onAdd?.(latest.option)\n }, [latest])\n\n const handleSelectClick = useCallback(() => {\n latest.onSelect(latest.option)\n }, [latest])\n\n const commonAttrs = {\n id: option.id,\n label: option.item.label,\n activeRef,\n onMouseOver: handleMouseOver,\n }\n\n return option.isNew ? (\n <AddButton {...commonAttrs} onClick={handleAddClick} />\n ) : (\n <SelectButton\n {...commonAttrs}\n disabled={option.item.disabled}\n selected={option.selected}\n onClick={handleSelectClick}\n />\n )\n}\nconst typedMemo: <T>(c: T) => T = memo\nconst Memoized = typedMemo(ItemButton)\nexport { Memoized as ItemButton }\n\nconst AddButton = memo<{\n id: string\n label: ReactNode\n activeRef: RefObject<HTMLButtonElement> | undefined\n onClick?: () => void\n onMouseOver: () => void\n}>(({ id, label, activeRef, onClick, onMouseOver }) => {\n const className = classNameGenerator({\n new: true,\n })\n\n return (\n <button\n ref={activeRef}\n type=\"button\"\n role=\"option\"\n aria-selected={false}\n id={id}\n data-active={!!activeRef}\n onClick={onClick}\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\n onMouseOver={onMouseOver}\n className={className}\n >\n <MemoizedNewIconWithText label={label} />\n </button>\n )\n})\n\nconst MemoizedNewIconWithText = memo<{ label: ReactNode }>(({ label }) => (\n <Text color=\"TEXT_LINK\" icon={<FaCirclePlusIcon color=\"TEXT_LINK\" />}>\n <Localizer\n id=\"smarthr-ui/Combobox/addItemButtonLabel\"\n defaultText=\"「{name}」を追加\"\n values={{ name: label }}\n />\n </Text>\n))\n\nconst SelectButton = memo<{\n id: string\n label: ReactNode\n disabled?: boolean\n selected: boolean\n activeRef: RefObject<HTMLButtonElement> | undefined\n onClick: () => void\n onMouseOver: () => void\n}>(({ id, label, disabled, selected, activeRef, onClick, onMouseOver }) => {\n const className = classNameGenerator({\n new: false,\n })\n\n return (\n <button\n ref={activeRef}\n type=\"button\"\n role=\"option\"\n id={id}\n disabled={disabled}\n aria-selected={selected}\n data-active={!!activeRef}\n onClick={onClick}\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\n onMouseOver={onMouseOver}\n className={className}\n >\n {label}\n </button>\n )\n})\n"],"names":["tv","useLatest","useCallback","_jsx","memo","Text","FaCirclePlusIcon","Localizer"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAM,kBAAkB,GAAGA,QAAE,CAAC;AAC5B,IAAA,IAAI,EAAE;QACJ,+HAA+H;QAC/H,8BAA8B;QAC9B,4DAA4D;QAC5D,4FAA4F;QAC5F,gFAAgF;AACjF,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,GAAG,EAAE;AACH,YAAA,IAAI,EAAE,yDAAyD;AAC/D,YAAA,KAAK,EAAE,kCAAkC;AAC1C,SAAA;AACF,KAAA;AACF,CAAA,CAAC;AAEF,MAAM,UAAU,GAAG,CAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAY,KAAI;AACvF,IAAA,MAAM,MAAM,GAAGC,yBAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AAElE,IAAA,MAAM,eAAe,GAAGC,iBAAW,CAAC,MAAK;AACvC,QAAA,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;AACnC,IAAA,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AAEZ,IAAA,MAAM,cAAc,GAAGA,iBAAW,CAAC,MAAK;QACtC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;AAC/B,IAAA,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AAEZ,IAAA,MAAM,iBAAiB,GAAGA,iBAAW,CAAC,MAAK;AACzC,QAAA,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;AAChC,IAAA,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AAEZ,IAAA,MAAM,WAAW,GAAG;QAClB,EAAE,EAAE,MAAM,CAAC,EAAE;AACb,QAAA,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK;QACxB,SAAS;AACT,QAAA,WAAW,EAAE,eAAe;KAC7B;IAED,OAAO,MAAM,CAAC,KAAK,IACjBC,eAAC,SAAS,EAAA,EAAA,GAAK,WAAW,EAAE,OAAO,EAAE,cAAc,EAAA,CAAI,KAEvDA,cAAA,CAAC,YAAY,EAAA,EAAA,GACP,WAAW,EACf,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,EAC9B,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,OAAO,EAAE,iBAAiB,EAAA,CAC1B,CACH;AACH,CAAC;AACD,MAAM,SAAS,GAAmBC,UAAI;AACtC,MAAM,QAAQ,GAAG,SAAS,CAAC,UAAU;AAGrC,MAAM,SAAS,GAAGA,UAAI,CAMnB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,KAAI;IACpD,MAAM,SAAS,GAAG,kBAAkB,CAAC;AACnC,QAAA,GAAG,EAAE,IAAI;AACV,KAAA,CAAC;IAEF,QACED,cAAA,CAAA,QAAA,EAAA,EACE,GAAG,EAAE,SAAS,EACd,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,QAAQ,mBACE,KAAK,EACpB,EAAE,EAAE,EAAE,EAAA,aAAA,EACO,CAAC,CAAC,SAAS,EACxB,OAAO,EAAE,OAAO;;AAEhB,QAAA,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EAAA,QAAA,EAEpBA,cAAA,CAAC,uBAAuB,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,CAAI,EAAA,CAClC;AAEb,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAGC,UAAI,CAAuB,CAAC,EAAE,KAAK,EAAE,MACnED,cAAA,CAACE,yBAAI,EAAA,EAAC,KAAK,EAAC,WAAW,EAAC,IAAI,EAAEF,cAAA,CAACG,uCAAgB,EAAA,EAAC,KAAK,EAAC,WAAW,EAAA,CAAG,EAAA,QAAA,EAClEH,cAAA,CAACI,wBAAS,EAAA,EACR,EAAE,EAAC,wCAAwC,EAC3C,WAAW,EAAC,sCAAa,EACzB,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAA,CACvB,EAAA,CACG,CACR,CAAC;AAEF,MAAM,YAAY,GAAGH,UAAI,CAQtB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,KAAI;IACxE,MAAM,SAAS,GAAG,kBAAkB,CAAC;AACnC,QAAA,GAAG,EAAE,KAAK;AACX,KAAA,CAAC;AAEF,IAAA,QACED,cAAA,CAAA,QAAA,EAAA,EACE,GAAG,EAAE,SAAS,EACd,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,QAAQ,EACb,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,QAAQ,EAAA,eAAA,EACH,QAAQ,EAAA,aAAA,EACV,CAAC,CAAC,SAAS,EACxB,OAAO,EAAE,OAAO;;QAEhB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EAAA,QAAA,EAEnB,KAAK,EAAA,CACC;AAEb,CAAC,CAAC;;;;"}
1
+ {"version":3,"file":"ItemButton.cjs","sources":["../../../src/components/Combobox/ItemButton.tsx"],"sourcesContent":["import { type RefObject, memo } from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { Localizer } from '../../intl'\nimport { FaCirclePlusIcon } from '../Icon'\nimport { Text } from '../Text'\n\nimport type { ComboboxOption } from './types'\n\ntype Props = Omit<ComboboxOption<unknown>, 'item'> &\n Omit<ComboboxOption<unknown>['item'], 'data' | 'value'> & {\n activeRef: RefObject<HTMLButtonElement> | undefined\n }\n\nconst classNameGenerator = tv({\n base: [\n 'shr-block shr-min-w-full shr-cursor-pointer shr-border-none shr-px-1 shr-py-0.5 shr-text-left shr-text-base shr-leading-tight',\n 'aria-selected:shr-text-white',\n 'disabled:shr-cursor-not-allowed disabled:shr-text-disabled',\n 'data-[active=true]:shr-bg-white-darken data-[active=true]:aria-selected:shr-bg-main-darken',\n 'data-[active=false]:shr-bg-white data-[active=false]:aria-selected:shr-bg-main',\n ],\n variants: {\n new: {\n true: 'smarthr-ui-Combobox-addButton shr-flex shr-items-center',\n false: 'smarthr-ui-Combobox-selectButton',\n },\n },\n})\n\nconst CLASS_NAMES = {\n new: classNameGenerator({ new: true }),\n select: classNameGenerator({ new: false }),\n}\n\nexport const ItemButton = memo<Props>(({ id, label, disabled, selected, isNew, activeRef }) => (\n <button\n ref={activeRef}\n type=\"button\"\n role=\"option\"\n id={id}\n data-active={!!activeRef}\n aria-selected={isNew ? false : selected}\n disabled={isNew ? undefined : disabled}\n className={isNew ? CLASS_NAMES.new : CLASS_NAMES.select}\n >\n {isNew ? (\n <Text color=\"TEXT_LINK\" icon={<FaCirclePlusIcon color=\"TEXT_LINK\" />}>\n <Localizer\n id=\"smarthr-ui/Combobox/addItemButtonLabel\"\n defaultText=\"「{name}」を追加\"\n values={{ name: label }}\n />\n </Text>\n ) : (\n label\n )}\n </button>\n))\n"],"names":["tv","memo","_jsx","Text","FaCirclePlusIcon","Localizer"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAM,kBAAkB,GAAGA,QAAE,CAAC;AAC5B,IAAA,IAAI,EAAE;QACJ,+HAA+H;QAC/H,8BAA8B;QAC9B,4DAA4D;QAC5D,4FAA4F;QAC5F,gFAAgF;AACjF,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,GAAG,EAAE;AACH,YAAA,IAAI,EAAE,yDAAyD;AAC/D,YAAA,KAAK,EAAE,kCAAkC;AAC1C,SAAA;AACF,KAAA;AACF,CAAA,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB,GAAG,EAAE,kBAAkB,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;IACtC,MAAM,EAAE,kBAAkB,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;CAC3C;AAEM,MAAM,UAAU,GAAGC,UAAI,CAAQ,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MACxFC,cAAA,CAAA,QAAA,EAAA,EACE,GAAG,EAAE,SAAS,EACd,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,QAAQ,EACb,EAAE,EAAE,EAAE,EAAA,aAAA,EACO,CAAC,CAAC,SAAS,EAAA,eAAA,EACT,KAAK,GAAG,KAAK,GAAG,QAAQ,EACvC,QAAQ,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,EACtC,SAAS,EAAE,KAAK,GAAG,WAAW,CAAC,GAAG,GAAG,WAAW,CAAC,MAAM,EAAA,QAAA,EAEtD,KAAK,IACJA,cAAA,CAACC,yBAAI,IAAC,KAAK,EAAC,WAAW,EAAC,IAAI,EAAED,cAAA,CAACE,uCAAgB,IAAC,KAAK,EAAC,WAAW,EAAA,CAAG,EAAA,QAAA,EAClEF,cAAA,CAACG,wBAAS,EAAA,EACR,EAAE,EAAC,wCAAwC,EAC3C,WAAW,EAAC,sCAAa,EACzB,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAA,CACvB,EAAA,CACG,KAEP,KAAK,CACN,EAAA,CACM,CACV;;;;"}
@@ -1,11 +1,7 @@
1
1
  import { type RefObject } from 'react';
2
2
  import type { ComboboxOption } from './types';
3
- type Props<T> = {
4
- option: ComboboxOption<T>;
5
- onAdd?: (option: ComboboxOption<T>) => void;
6
- onSelect: (option: ComboboxOption<T>) => void;
7
- onMouseOver: (option: ComboboxOption<T>) => void;
3
+ type Props = Omit<ComboboxOption<unknown>, 'item'> & Omit<ComboboxOption<unknown>['item'], 'data' | 'value'> & {
8
4
  activeRef: RefObject<HTMLButtonElement> | undefined;
9
5
  };
10
- declare const Memoized: <T>({ option, onAdd, onSelect, onMouseOver, activeRef }: Props<T>) => import("react").JSX.Element;
11
- export { Memoized as ItemButton };
6
+ export declare const ItemButton: import("react").NamedExoticComponent<Props>;
7
+ export {};