smarthr-ui 99.3.1 → 99.3.2

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 (189) hide show
  1. package/lib/_virtual/index.cjs +2 -2
  2. package/lib/_virtual/index.js +2 -2
  3. package/lib/_virtual/index2.cjs +2 -2
  4. package/lib/_virtual/index2.js +2 -2
  5. package/lib/components/Combobox/ItemButton.cjs +11 -2
  6. package/lib/components/Combobox/ItemButton.cjs.map +1 -1
  7. package/lib/components/Combobox/ItemButton.js +11 -2
  8. package/lib/components/Combobox/ItemButton.js.map +1 -1
  9. package/lib/components/Combobox/MultiCombobox/MultiCombobox.cjs +1 -1
  10. package/lib/components/Combobox/MultiCombobox/MultiCombobox.cjs.map +1 -1
  11. package/lib/components/Combobox/MultiCombobox/MultiCombobox.js +1 -1
  12. package/lib/components/Combobox/MultiCombobox/MultiCombobox.js.map +1 -1
  13. package/lib/components/Combobox/SingleCombobox/SingleCombobox.cjs +1 -1
  14. package/lib/components/Combobox/SingleCombobox/SingleCombobox.cjs.map +1 -1
  15. package/lib/components/Combobox/SingleCombobox/SingleCombobox.js +1 -1
  16. package/lib/components/Combobox/SingleCombobox/SingleCombobox.js.map +1 -1
  17. package/lib/components/DatePicker/DatePicker.cjs +1 -1
  18. package/lib/components/DatePicker/DatePicker.cjs.map +1 -1
  19. package/lib/components/DatePicker/DatePicker.js +1 -1
  20. package/lib/components/DatePicker/DatePicker.js.map +1 -1
  21. package/lib/components/Dialog/FocusTrap.cjs +8 -8
  22. package/lib/components/Dialog/FocusTrap.cjs.map +1 -1
  23. package/lib/components/Dialog/FocusTrap.js +9 -9
  24. package/lib/components/Dialog/FocusTrap.js.map +1 -1
  25. package/lib/components/Dialog/ModelessDialog/ModelessDialog.cjs +2 -1
  26. package/lib/components/Dialog/ModelessDialog/ModelessDialog.cjs.map +1 -1
  27. package/lib/components/Dialog/ModelessDialog/ModelessDialog.js +2 -1
  28. package/lib/components/Dialog/ModelessDialog/ModelessDialog.js.map +1 -1
  29. package/lib/components/Input/CurrencyInput/CurrencyInput.cjs +2 -2
  30. package/lib/components/Input/CurrencyInput/CurrencyInput.cjs.map +1 -1
  31. package/lib/components/Input/CurrencyInput/CurrencyInput.js +2 -2
  32. package/lib/components/Input/CurrencyInput/CurrencyInput.js.map +1 -1
  33. package/lib/components/Input/Input.cjs +14 -16
  34. package/lib/components/Input/Input.cjs.map +1 -1
  35. package/lib/components/Input/Input.js +14 -16
  36. package/lib/components/Input/Input.js.map +1 -1
  37. package/lib/components/InputFile/InputFileMultiplyAppendable.cjs +8 -7
  38. package/lib/components/InputFile/InputFileMultiplyAppendable.cjs.map +1 -1
  39. package/lib/components/InputFile/InputFileMultiplyAppendable.js +8 -7
  40. package/lib/components/InputFile/InputFileMultiplyAppendable.js.map +1 -1
  41. package/lib/components/InputFile/InputFileNative.cjs +6 -5
  42. package/lib/components/InputFile/InputFileNative.cjs.map +1 -1
  43. package/lib/components/InputFile/InputFileNative.js +6 -5
  44. package/lib/components/InputFile/InputFileNative.js.map +1 -1
  45. package/lib/components/Layout/Container/Container.cjs.map +1 -1
  46. package/lib/components/Layout/Container/Container.js.map +1 -1
  47. package/lib/components/Pagination/Pagination.cjs +3 -2
  48. package/lib/components/Pagination/Pagination.cjs.map +1 -1
  49. package/lib/components/Pagination/Pagination.js +2 -1
  50. package/lib/components/Pagination/Pagination.js.map +1 -1
  51. package/lib/components/Panel/Groupbox/Groupbox.cjs +1 -0
  52. package/lib/components/Panel/Groupbox/Groupbox.cjs.map +1 -1
  53. package/lib/components/Panel/Groupbox/Groupbox.js +1 -0
  54. package/lib/components/Panel/Groupbox/Groupbox.js.map +1 -1
  55. package/lib/components/Select/Select.cjs +12 -14
  56. package/lib/components/Select/Select.cjs.map +1 -1
  57. package/lib/components/Select/Select.js +12 -14
  58. package/lib/components/Select/Select.js.map +1 -1
  59. package/lib/components/Table/TableScroller.cjs +13 -15
  60. package/lib/components/Table/TableScroller.cjs.map +1 -1
  61. package/lib/components/Table/TableScroller.js +14 -16
  62. package/lib/components/Table/TableScroller.js.map +1 -1
  63. package/lib/components/Textarea/Textarea.cjs +18 -12
  64. package/lib/components/Textarea/Textarea.cjs.map +1 -1
  65. package/lib/components/Textarea/Textarea.js +19 -13
  66. package/lib/components/Textarea/Textarea.js.map +1 -1
  67. package/lib/components/Tooltip/TooltipPortal.cjs +1 -0
  68. package/lib/components/Tooltip/TooltipPortal.cjs.map +1 -1
  69. package/lib/components/Tooltip/TooltipPortal.js +1 -0
  70. package/lib/components/Tooltip/TooltipPortal.js.map +1 -1
  71. package/lib/hooks/useClick.cjs +7 -4
  72. package/lib/hooks/useClick.cjs.map +1 -1
  73. package/lib/hooks/useClick.js +7 -4
  74. package/lib/hooks/useClick.js.map +1 -1
  75. package/lib/hooks/useOuterClick.cjs +5 -6
  76. package/lib/hooks/useOuterClick.cjs.map +1 -1
  77. package/lib/hooks/useOuterClick.js +6 -7
  78. package/lib/hooks/useOuterClick.js.map +1 -1
  79. package/lib/hooks/usePortal.cjs +24 -17
  80. package/lib/hooks/usePortal.cjs.map +1 -1
  81. package/lib/hooks/usePortal.d.ts +1 -1
  82. package/lib/hooks/usePortal.js +25 -18
  83. package/lib/hooks/usePortal.js.map +1 -1
  84. package/lib/hooks/useResponseStatus.cjs +20 -23
  85. package/lib/hooks/useResponseStatus.cjs.map +1 -1
  86. package/lib/hooks/useResponseStatus.js +20 -23
  87. package/lib/hooks/useResponseStatus.js.map +1 -1
  88. package/lib/intl/locales/en_us.json.cjs +1 -0
  89. package/lib/intl/locales/en_us.json.cjs.map +1 -1
  90. package/lib/intl/locales/en_us.json.js +1 -0
  91. package/lib/intl/locales/en_us.json.js.map +1 -1
  92. package/lib/intl/locales/id_id.json.cjs +0 -8
  93. package/lib/intl/locales/id_id.json.cjs.map +1 -1
  94. package/lib/intl/locales/id_id.json.js +0 -8
  95. package/lib/intl/locales/id_id.json.js.map +1 -1
  96. package/lib/intl/locales/index.d.ts +6 -16
  97. package/lib/intl/locales/ja_easy.json.cjs +1 -0
  98. package/lib/intl/locales/ja_easy.json.cjs.map +1 -1
  99. package/lib/intl/locales/ja_easy.json.js +1 -0
  100. package/lib/intl/locales/ja_easy.json.js.map +1 -1
  101. package/lib/intl/locales/ko_kr.json.cjs +1 -0
  102. package/lib/intl/locales/ko_kr.json.cjs.map +1 -1
  103. package/lib/intl/locales/ko_kr.json.js +1 -0
  104. package/lib/intl/locales/ko_kr.json.js.map +1 -1
  105. package/lib/intl/locales/pt_br.json.cjs +0 -8
  106. package/lib/intl/locales/pt_br.json.cjs.map +1 -1
  107. package/lib/intl/locales/pt_br.json.js +0 -8
  108. package/lib/intl/locales/pt_br.json.js.map +1 -1
  109. package/lib/intl/locales/vi_vn.json.cjs +1 -0
  110. package/lib/intl/locales/vi_vn.json.cjs.map +1 -1
  111. package/lib/intl/locales/vi_vn.json.js +1 -0
  112. package/lib/intl/locales/vi_vn.json.js.map +1 -1
  113. package/lib/intl/locales/zh_hans_cn.json.cjs +1 -0
  114. package/lib/intl/locales/zh_hans_cn.json.cjs.map +1 -1
  115. package/lib/intl/locales/zh_hans_cn.json.js +1 -0
  116. package/lib/intl/locales/zh_hans_cn.json.js.map +1 -1
  117. package/lib/intl/locales/zh_hant_tw.json.cjs +1 -0
  118. package/lib/intl/locales/zh_hant_tw.json.cjs.map +1 -1
  119. package/lib/intl/locales/zh_hant_tw.json.js +1 -0
  120. package/lib/intl/locales/zh_hant_tw.json.js.map +1 -1
  121. package/lib/intl/useDateFormat.cjs +1 -2
  122. package/lib/intl/useDateFormat.cjs.map +1 -1
  123. package/lib/intl/useDateFormat.js +1 -2
  124. package/lib/intl/useDateFormat.js.map +1 -1
  125. package/lib/intl/useIntl.cjs +2 -4
  126. package/lib/intl/useIntl.cjs.map +1 -1
  127. package/lib/intl/useIntl.js +2 -4
  128. package/lib/intl/useIntl.js.map +1 -1
  129. package/lib/libs/debounce.cjs +10 -2
  130. package/lib/libs/debounce.cjs.map +1 -1
  131. package/lib/libs/debounce.d.ts +4 -2
  132. package/lib/libs/debounce.js +10 -2
  133. package/lib/libs/debounce.js.map +1 -1
  134. package/lib/libs/lodash.cjs +3 -4
  135. package/lib/libs/lodash.cjs.map +1 -1
  136. package/lib/libs/lodash.d.ts +2 -11
  137. package/lib/libs/lodash.js +2 -7
  138. package/lib/libs/lodash.js.map +1 -1
  139. package/lib/libs/map.cjs +1 -5
  140. package/lib/libs/map.cjs.map +1 -1
  141. package/lib/libs/map.js +1 -5
  142. package/lib/libs/map.js.map +1 -1
  143. package/lib/themes/createBackgroundColor.cjs +3 -2
  144. package/lib/themes/createBackgroundColor.cjs.map +1 -1
  145. package/lib/themes/createBackgroundColor.js +2 -1
  146. package/lib/themes/createBackgroundColor.js.map +1 -1
  147. package/lib/themes/createBorder.cjs +3 -2
  148. package/lib/themes/createBorder.cjs.map +1 -1
  149. package/lib/themes/createBorder.js +2 -1
  150. package/lib/themes/createBorder.js.map +1 -1
  151. package/lib/themes/createBreakpoint.cjs +3 -2
  152. package/lib/themes/createBreakpoint.cjs.map +1 -1
  153. package/lib/themes/createBreakpoint.js +2 -1
  154. package/lib/themes/createBreakpoint.js.map +1 -1
  155. package/lib/themes/createColor.cjs +3 -2
  156. package/lib/themes/createColor.cjs.map +1 -1
  157. package/lib/themes/createColor.js +2 -1
  158. package/lib/themes/createColor.js.map +1 -1
  159. package/lib/themes/createFontSize.cjs +3 -2
  160. package/lib/themes/createFontSize.cjs.map +1 -1
  161. package/lib/themes/createFontSize.js +2 -1
  162. package/lib/themes/createFontSize.js.map +1 -1
  163. package/lib/themes/createInteraction.cjs +3 -2
  164. package/lib/themes/createInteraction.cjs.map +1 -1
  165. package/lib/themes/createInteraction.js +2 -1
  166. package/lib/themes/createInteraction.js.map +1 -1
  167. package/lib/themes/createLeading.cjs +3 -2
  168. package/lib/themes/createLeading.cjs.map +1 -1
  169. package/lib/themes/createLeading.js +2 -1
  170. package/lib/themes/createLeading.js.map +1 -1
  171. package/lib/themes/createRadius.cjs +3 -2
  172. package/lib/themes/createRadius.cjs.map +1 -1
  173. package/lib/themes/createRadius.js +2 -1
  174. package/lib/themes/createRadius.js.map +1 -1
  175. package/lib/themes/createShadow/createShadow.cjs +3 -2
  176. package/lib/themes/createShadow/createShadow.cjs.map +1 -1
  177. package/lib/themes/createShadow/createShadow.js +2 -1
  178. package/lib/themes/createShadow/createShadow.js.map +1 -1
  179. package/lib/themes/createTextColor.cjs +3 -2
  180. package/lib/themes/createTextColor.cjs.map +1 -1
  181. package/lib/themes/createTextColor.js +2 -1
  182. package/lib/themes/createTextColor.js.map +1 -1
  183. package/lib/themes/createZIndex.cjs +3 -2
  184. package/lib/themes/createZIndex.cjs.map +1 -1
  185. package/lib/themes/createZIndex.js +2 -1
  186. package/lib/themes/createZIndex.js.map +1 -1
  187. package/metadata.json +1 -1
  188. package/package.json +1 -1
  189. package/smarthr-ui.css +27 -7
@@ -64,6 +64,7 @@ var vi = {
64
64
  "smarthr-ui/InputFile/download": "Tải xuống",
65
65
  "smarthr-ui/InputFile/previewLabel": "Mở xem trước {fileName}",
66
66
  "smarthr-ui/InputFile/downloadLabel": "Tải xuống {fileName}",
67
+ "smarthr-ui/InputFile/closePreview": "Đóng",
67
68
  "smarthr-ui/LanguageSwitcher/checkIconAlt": "Đang chọn",
68
69
  "smarthr-ui/Loader/alt": "Đang xử lý",
69
70
  "smarthr-ui/MessageDialog/closeButtonLabel": "Đóng",
@@ -1 +1 @@
1
- {"version":3,"file":"vi_vn.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"vi_vn.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -66,6 +66,7 @@ var zhCn = {
66
66
  "smarthr-ui/InputFile/download": "下载",
67
67
  "smarthr-ui/InputFile/previewLabel": "预览 {fileName}",
68
68
  "smarthr-ui/InputFile/downloadLabel": "下载 {fileName}",
69
+ "smarthr-ui/InputFile/closePreview": "关闭",
69
70
  "smarthr-ui/LanguageSwitcher/checkIconAlt": "已选择",
70
71
  "smarthr-ui/Loader/alt": "处理中",
71
72
  "smarthr-ui/MessageDialog/closeButtonLabel": "关闭",
@@ -1 +1 @@
1
- {"version":3,"file":"zh_hans_cn.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"zh_hans_cn.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -64,6 +64,7 @@ var zhCn = {
64
64
  "smarthr-ui/InputFile/download": "下载",
65
65
  "smarthr-ui/InputFile/previewLabel": "预览 {fileName}",
66
66
  "smarthr-ui/InputFile/downloadLabel": "下载 {fileName}",
67
+ "smarthr-ui/InputFile/closePreview": "关闭",
67
68
  "smarthr-ui/LanguageSwitcher/checkIconAlt": "已选择",
68
69
  "smarthr-ui/Loader/alt": "处理中",
69
70
  "smarthr-ui/MessageDialog/closeButtonLabel": "关闭",
@@ -1 +1 @@
1
- {"version":3,"file":"zh_hans_cn.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"zh_hans_cn.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -66,6 +66,7 @@ var zhTw = {
66
66
  "smarthr-ui/InputFile/download": "下載",
67
67
  "smarthr-ui/InputFile/previewLabel": "開啟{fileName}的預覽",
68
68
  "smarthr-ui/InputFile/downloadLabel": "下載{fileName}",
69
+ "smarthr-ui/InputFile/closePreview": "關閉",
69
70
  "smarthr-ui/LanguageSwitcher/checkIconAlt": "已選擇",
70
71
  "smarthr-ui/Loader/alt": "處理中",
71
72
  "smarthr-ui/MessageDialog/closeButtonLabel": "關閉",
@@ -1 +1 @@
1
- {"version":3,"file":"zh_hant_tw.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"zh_hant_tw.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -64,6 +64,7 @@ var zhTw = {
64
64
  "smarthr-ui/InputFile/download": "下載",
65
65
  "smarthr-ui/InputFile/previewLabel": "開啟{fileName}的預覽",
66
66
  "smarthr-ui/InputFile/downloadLabel": "下載{fileName}",
67
+ "smarthr-ui/InputFile/closePreview": "關閉",
67
68
  "smarthr-ui/LanguageSwitcher/checkIconAlt": "已選擇",
68
69
  "smarthr-ui/Loader/alt": "處理中",
69
70
  "smarthr-ui/MessageDialog/closeButtonLabel": "關閉",
@@ -1 +1 @@
1
- {"version":3,"file":"zh_hant_tw.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"zh_hant_tw.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -142,7 +142,7 @@ const applyCapitalization = (text, shouldCapitalize) => shouldCapitalize ? text.
142
142
  */
143
143
  const useDateFormat = () => {
144
144
  const intl = reactIntl.useIntl();
145
- const functions = React.useMemo(() => {
145
+ return React.useMemo(() => {
146
146
  const locale = isValidLocale(intl.locale) ? intl.locale : 'ja';
147
147
  const formatDate = ({ date, parts = ['year', 'month', 'day'], options, }) => {
148
148
  const { disableSlashInJa = false, capitalizeFirstLetter = false, year, month, day, weekday, ...rest } = options || {};
@@ -201,7 +201,6 @@ const useDateFormat = () => {
201
201
  getWeekStartDay: () => DATE_FORMATS[locale].weekStartDay,
202
202
  };
203
203
  }, [intl]);
204
- return functions;
205
204
  };
206
205
 
207
206
  exports.useDateFormat = useDateFormat;
@@ -1 +1 @@
1
- {"version":3,"file":"useDateFormat.cjs","sources":["../../src/intl/useDateFormat.ts"],"sourcesContent":["'use client'\n\nimport { useMemo } from 'react'\nimport { useIntl as useReactIntl } from 'react-intl'\n\nimport { locales } from './locales'\n\ntype DatePart = 'year' | 'month' | 'day' | 'weekday'\n\ntype TimePart = 'hour' | 'minute' | 'second'\n\nexport type FormatDateProps = {\n /**\n * フォーマット対象の日付\n */\n date: Date\n\n /**\n * 表示する日付のパーツ。指定しない場合は全て表示\n */\n parts?: readonly [DatePart, ...DatePart[]]\n\n /**\n * フォーマットオプション\n */\n options?: Omit<Intl.DateTimeFormatOptions, 'dateStyle' | 'timeStyle'> & {\n /**\n * 日本語ロケールでスラッシュを無効化し、月を長形式で表示する\n * @example\n * // 通常: \"2025/01\"\n * // disableSlashInJa: true の場合: \"2025年1月\"\n */\n disableSlashInJa?: boolean\n\n /**\n * 最初の文字を大文字化する\n * @example\n * // 通常: \"seg.\" (pt)\n * // capitalizeFirstLetter: true の場合: \"Seg.\" (pt)\n */\n capitalizeFirstLetter?: boolean\n }\n}\n\nexport type FormatTimeProps = {\n /**\n * フォーマット対象の日付\n */\n date: Date\n\n /**\n * 表示する時刻のパーツ。指定しない場合は ['hour', 'minute'] がデフォルト\n */\n parts?: readonly [TimePart, ...TimePart[]]\n\n /**\n * フォーマットオプション\n */\n options?: Omit<Intl.DateTimeFormatOptions, 'dateStyle' | 'timeStyle'>\n}\n\nexport type FormatTimestampProps = {\n /**\n * フォーマット対象の日付\n */\n date: Date\n\n /**\n * 表示する時刻のパーツ。指定しない場合は ['hour', 'minute'] がデフォルト\n */\n timeParts?: readonly [TimePart, ...TimePart[]]\n}\n\n/**\n * useDateFormatフックの戻り値の型定義\n */\nexport type UseDateFormatReturn = {\n /**\n * 日付をロケールに応じた形式でフォーマットする関数\n * @param props - フォーマットのオプション\n * @param props.date - フォーマット対象の日付\n * @param props.parts - 表示する日付のパーツ。デフォルトは ['year', 'month', 'day', 'weekday']\n * @param props.options - フォーマットオプション\n * @param props.options.disableSlashInJa - 日本語ロケールでスラッシュを無効化し、月を長形式で表示する\n * @param props.options.capitalizeFirstLetter - 最初の文字を大文字化する\n * @returns フォーマットされた日付文字列\n * @example\n * // 基本的な使用法(ロケールのデフォルト形式:曜日なし)\n * formatDate({ date: new Date() }) // \"2024/01/15\" (ja)\n *\n * // 日付を曜日ありで表示\n * formatDate({ date: new Date(), parts: ['year', 'month', 'day', 'weekday'] }) // \"2024/01/15(水)\" (ja)\n *\n * // 特定のフィールドのみ表示\n * formatDate({ date: new Date(), parts: ['year', 'month'] }) // \"2024/01\" (ja)\n * formatDate({ date: new Date(), parts: ['weekday'] }) // \"月\" (ja)\n *\n * // 日本語でスラッシュを無効化(月を長形式で表示)\n * formatDate({ date: new Date(), parts: ['year', 'month'], options: { disableSlashInJa: true } }) // \"2024年1月\" (ja)\n *\n * // 最初の文字を大文字化\n * formatDate({ date: new Date(), parts: ['weekday'], options: { capitalizeFirstLetter: true } }) // \"Seg.\" (pt)(指定しなければ \"seg.\")\n */\n formatDate(props: FormatDateProps): string\n\n /**\n * 時刻をロケールに応じた形式でフォーマットする関数\n * @param props - フォーマットのオプション\n * @param props.date - フォーマット対象の日付\n * @param props.parts - 表示する時刻のパーツ。デフォルトは ['hour', 'minute']\n * @param props.options - フォーマットオプション\n * @returns フォーマットされた時刻文字列\n * @example\n * // 基本的な使用法(ロケールのデフォルト形式)\n * formatTime({ date: new Date() }) // \"10:30\" (ja)\n *\n * // 秒を含めて表示\n * formatTime({ date: new Date(), parts: ['hour', 'minute', 'second'] }) // \"10:30:45\" (ja)\n *\n * // 時のみ表示\n * formatTime({ date: new Date(), parts: ['hour'] }) // \"10\" (ja)\n *\n * // 12時間形式で表示\n * formatTime({ date: new Date(), options: { hour12: true } }) // \"午前10:30\" (ja)\n */\n formatTime(props: FormatTimeProps): string\n\n /**\n * タイムスタンプ(日付+時刻)をフォーマットする関数\n * 日付はスラッシュ形式、時刻は24時間形式で表示されます\n * @param props - フォーマットのオプション\n * @param props.date - フォーマット対象の日付\n * @param props.timeParts - 表示する時刻のパーツ。デフォルトは ['hour', 'minute']\n * @returns フォーマットされたタイムスタンプ文字列\n * @example\n * // 基本的な使用法\n * formatTimestamp({ date: new Date() }) // \"2024/01/15 10:30\" (ja)\n *\n * // 秒を含めて表示\n * formatTimestamp({ date: new Date(), timeParts: ['hour', 'minute', 'second'] }) // \"2024/01/15 10:30:45\" (ja)\n */\n formatTimestamp(props: FormatTimestampProps): string\n\n /**\n * 現在のロケールに基づいて週の開始日を決定する関数\n * Intl.Locale.prototype.getWeekInfo()の動作を再現\n * getWeekInfo()を使わない理由は、Firefoxでは動作しないため\n *\n * @returns 週の開始日(0 = 日曜日, 1 = 月曜日, ..., 6 = 土曜日)\n */\n getWeekStartDay: () => number\n}\n\nconst WEEK_START_DAYS = {\n SUNDAY: 0,\n MONDAY: 1,\n TUESDAY: 2,\n WEDNESDAY: 3,\n THURSDAY: 4,\n FRIDAY: 5,\n SATURDAY: 6,\n} as const\n\nconst DATE_FORMATS: Record<\n keyof typeof locales,\n Intl.DateTimeFormatOptions & { weekStartDay: number }\n> = {\n // localeがja, ja-easyの場合、フォーマットを YYYY/MM/DD 形式にする\n // 曜日が含まれている場合は括弧を追加する\n // 参考: https://smarthr.design/products/contents/idiomatic-usage/count/#h2-3\n ja: {\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'ja-easy': {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'en-us': {\n year: 'numeric',\n month: 'short',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'id-id': {\n year: 'numeric',\n month: 'short',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.MONDAY,\n },\n ko: {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n pt: {\n year: 'numeric',\n month: 'short',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.MONDAY,\n },\n vi: {\n year: 'numeric',\n month: 'long',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.MONDAY,\n },\n 'zh-cn': {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'zh-tw': {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n} as const\n\n/**\n * 各ロケールの括弧設定マップ\n * ロケールに応じて適切な括弧スタイル(半角/全角)と配置を定義\n */\nconst WEEKDAY_FORMATS: Record<keyof typeof locales, { replacer: (base: string) => string }> = {\n ja: { replacer: (base) => base.replace(/(.+?)\\(([月火水木金土日])\\)$/, '$1($2)') },\n 'ja-easy': { replacer: (base) => base.replace(/(.+?)\\(([月火水木金土日])\\)$/, '$1($2)') },\n 'en-us': { replacer: (base) => base.replace(/^([A-Za-z]{3}), (.+)$/, '$2 ($1)') },\n 'id-id': { replacer: (base) => base.replace(/^([A-Za-z]{3}), (.+)$/, '$2 ($1)') },\n ko: {\n replacer: (base) => base.replace(/\\s{2,}/g, ' ').replace(/([월화수목금토일])$/, '($1)'),\n },\n pt: { replacer: (base) => base.replace(/^([A-Za-z]{3}\\.), (.+)$/, '$2 ($1)') },\n vi: { replacer: (base) => base.replace(/^(\\S+ \\d+), (.+)$/, '$2 ($1)') },\n 'zh-cn': { replacer: (base) => base.replace(/(.+?)\\s*([周][一二三四五六日])$/, '$1($2)') },\n 'zh-tw': { replacer: (base) => base.replace(/(.+?)\\s*([週][一二三四五六日])$/, '$1($2)') },\n} as const\n\nconst COMMON_TIME_FORMAT: Intl.DateTimeFormatOptions = {\n hour: '2-digit',\n minute: '2-digit',\n hour12: false,\n}\n\nconst TIME_FORMATS: Record<keyof typeof locales, Intl.DateTimeFormatOptions> = {\n ja: COMMON_TIME_FORMAT,\n 'ja-easy': COMMON_TIME_FORMAT,\n 'en-us': {\n ...COMMON_TIME_FORMAT,\n hour: 'numeric',\n hour12: true,\n },\n 'id-id': COMMON_TIME_FORMAT,\n ko: COMMON_TIME_FORMAT,\n pt: COMMON_TIME_FORMAT,\n vi: COMMON_TIME_FORMAT,\n 'zh-cn': COMMON_TIME_FORMAT,\n 'zh-tw': COMMON_TIME_FORMAT,\n} as const\n\nconst isValidLocale = (locale: string): locale is keyof typeof locales => locale in locales\n\nconst applyCapitalization = (text: string, shouldCapitalize: boolean) =>\n shouldCapitalize ? text.charAt(0).toUpperCase() + text.slice(1) : text\n\n/**\n * 日付・時刻フォーマット機能を提供するフック\n *\n * @returns {UseDateFormatReturn} 日付・時刻フォーマットに関連する関数とプロパティを含むオブジェクト\n * @example\n * // 基本的な使用法(日付のフォーマット)\n * const Component = () => {\n * const { formatDate } = useDateFormat()\n * return <span>{formatDate({ date: new Date(2024, 1 - 1, 15) })}</span> // \"2024/01/15\" (ja)\n * }\n *\n * @example\n * // 時刻のフォーマット\n * const Component = () => {\n * const { formatTime } = useDateFormat()\n * return <span>{formatTime({ date: new Date(2024, 1 - 1, 15, 10, 30, 0) })}</span> // \"10:30\" (ja)\n * }\n *\n * @example\n * // 週の開始日の取得\n * const Component = () => {\n * const { getWeekStartDay } = useDateFormat()\n * return <div>週の開始日: {getWeekStartDay()}</div>\n * }\n */\nexport const useDateFormat = (): UseDateFormatReturn => {\n const intl = useReactIntl()\n\n const functions = useMemo(() => {\n const locale = isValidLocale(intl.locale) ? intl.locale : 'ja'\n\n const formatDate = ({\n date,\n parts = ['year', 'month', 'day'],\n options,\n }: FormatDateProps): string => {\n const {\n disableSlashInJa = false,\n capitalizeFirstLetter = false,\n year,\n month,\n day,\n weekday,\n ...rest\n } = options || {}\n\n // パーツの存在を事前に計算\n const hasPart = parts.reduce(\n (prev, part) => {\n prev[part] = true\n return prev\n },\n { year: false, month: false, day: false, weekday: false } as {\n year: boolean\n month: boolean\n day: boolean\n weekday: boolean\n },\n )\n\n // ロケールのデフォルト形式を取得\n const isJaKanjiFormat = disableSlashInJa && locale === 'ja'\n const defaultFormats = DATE_FORMATS[locale]\n\n // local が 'ja' で漢字表記の場合はゼロ埋めをしないようにする\n const defaultMonth = isJaKanjiFormat ? 'long' : defaultFormats.month\n const defaultDay = isJaKanjiFormat ? 'numeric' : defaultFormats.day\n\n const actualFormatOptions: Intl.DateTimeFormatOptions = {\n ...rest,\n year: year ?? (hasPart.year ? defaultFormats.year : undefined),\n month: month ?? (hasPart.month ? defaultMonth : undefined),\n day: day ?? (hasPart.day ? defaultDay : undefined),\n weekday: weekday ?? (hasPart.weekday ? defaultFormats.weekday : undefined),\n }\n\n const formattedDate = intl.formatDate(date, actualFormatOptions)\n\n // 曜日をロケールに応じてフォーマットする\n let formattedResult = formattedDate\n const config = WEEKDAY_FORMATS[locale]\n // 曜日が含まれており、かつ曜日のみの表示でない場合は括弧を追加\n // 例: \"2025/01/01(水)\" → 括弧あり, \"水\" → 括弧なし\n if (config && hasPart.weekday && (parts.length !== 1 || parts[0] !== 'weekday')) {\n formattedResult = config.replacer(formattedDate)\n }\n\n return applyCapitalization(formattedResult, capitalizeFirstLetter)\n }\n\n const formatTime = ({ date, parts = ['hour', 'minute'], options }: FormatTimeProps): string => {\n const formatOptions = options || {}\n\n const hasPart = parts.reduce(\n (prev, part) => {\n prev[part] = true\n return prev\n },\n { hour: false, minute: false, second: false } as {\n hour: boolean\n minute: boolean\n second: boolean\n },\n )\n\n const actualFormatOptions: Intl.DateTimeFormatOptions = {\n ...formatOptions,\n hour: formatOptions.hour ?? (hasPart.hour ? TIME_FORMATS[locale].hour : undefined),\n minute: formatOptions.minute ?? (hasPart.minute ? TIME_FORMATS[locale].minute : undefined),\n second: formatOptions.second ?? (hasPart.second ? '2-digit' : undefined),\n hour12: formatOptions.hour12 ?? TIME_FORMATS[locale].hour12,\n }\n\n return intl.formatDate(date, actualFormatOptions)\n }\n\n return {\n formatDate,\n formatTime,\n formatTimestamp: ({ date, timeParts = ['hour', 'minute'] }: FormatTimestampProps): string => {\n const formattedDate = formatDate({ date, parts: ['year', 'month', 'day'] })\n const formattedTime = formatTime({ date, parts: timeParts })\n return `${formattedDate} ${formattedTime}`\n },\n getWeekStartDay: (): number => DATE_FORMATS[locale].weekStartDay,\n }\n }, [intl])\n\n return functions\n}\n"],"names":[],"mappings":";;;;;;;AAyJA;AACE;AACA;AAQF;;;;AAOE;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;;AAGH;;;AAGG;AACH;AACE;AACA;AACA;AACA;AACA;;AAEC;AACD;AACA;AACA;AACA;;AAGF;AACE;AACA;AACA;;AAGF;AACE;AACA;AACA;AACE;AACA;AACA;AACD;AACD;AACA;AACA;AACA;AACA;AACA;;AAGF;AAEA;AAGA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACI;AACL;AAEA;AACE;AAEA;;;;AAkBM;AACA;AACF;;AAUF;AACA;;AAGA;AACA;AAEA;AACE;AACA;AACA;AACA;AACA;;;;;AAOF;;;;AAIE;;AAGF;AACF;AAEA;AACE;;AAII;AACA;AACF;AAQF;AACE;;;AAGA;;;;AAKJ;;;;AAKE;AACE;AACA;AACA;;;;AAIN;AAEA;AACF;;"}
1
+ {"version":3,"file":"useDateFormat.cjs","sources":["../../src/intl/useDateFormat.ts"],"sourcesContent":["'use client'\n\nimport { useMemo } from 'react'\nimport { useIntl as useReactIntl } from 'react-intl'\n\nimport { locales } from './locales'\n\ntype DatePart = 'year' | 'month' | 'day' | 'weekday'\n\ntype TimePart = 'hour' | 'minute' | 'second'\n\nexport type FormatDateProps = {\n /**\n * フォーマット対象の日付\n */\n date: Date\n\n /**\n * 表示する日付のパーツ。指定しない場合は全て表示\n */\n parts?: readonly [DatePart, ...DatePart[]]\n\n /**\n * フォーマットオプション\n */\n options?: Omit<Intl.DateTimeFormatOptions, 'dateStyle' | 'timeStyle'> & {\n /**\n * 日本語ロケールでスラッシュを無効化し、月を長形式で表示する\n * @example\n * // 通常: \"2025/01\"\n * // disableSlashInJa: true の場合: \"2025年1月\"\n */\n disableSlashInJa?: boolean\n\n /**\n * 最初の文字を大文字化する\n * @example\n * // 通常: \"seg.\" (pt)\n * // capitalizeFirstLetter: true の場合: \"Seg.\" (pt)\n */\n capitalizeFirstLetter?: boolean\n }\n}\n\nexport type FormatTimeProps = {\n /**\n * フォーマット対象の日付\n */\n date: Date\n\n /**\n * 表示する時刻のパーツ。指定しない場合は ['hour', 'minute'] がデフォルト\n */\n parts?: readonly [TimePart, ...TimePart[]]\n\n /**\n * フォーマットオプション\n */\n options?: Omit<Intl.DateTimeFormatOptions, 'dateStyle' | 'timeStyle'>\n}\n\nexport type FormatTimestampProps = {\n /**\n * フォーマット対象の日付\n */\n date: Date\n\n /**\n * 表示する時刻のパーツ。指定しない場合は ['hour', 'minute'] がデフォルト\n */\n timeParts?: readonly [TimePart, ...TimePart[]]\n}\n\n/**\n * useDateFormatフックの戻り値の型定義\n */\nexport type UseDateFormatReturn = {\n /**\n * 日付をロケールに応じた形式でフォーマットする関数\n * @param props - フォーマットのオプション\n * @param props.date - フォーマット対象の日付\n * @param props.parts - 表示する日付のパーツ。デフォルトは ['year', 'month', 'day', 'weekday']\n * @param props.options - フォーマットオプション\n * @param props.options.disableSlashInJa - 日本語ロケールでスラッシュを無効化し、月を長形式で表示する\n * @param props.options.capitalizeFirstLetter - 最初の文字を大文字化する\n * @returns フォーマットされた日付文字列\n * @example\n * // 基本的な使用法(ロケールのデフォルト形式:曜日なし)\n * formatDate({ date: new Date() }) // \"2024/01/15\" (ja)\n *\n * // 日付を曜日ありで表示\n * formatDate({ date: new Date(), parts: ['year', 'month', 'day', 'weekday'] }) // \"2024/01/15(水)\" (ja)\n *\n * // 特定のフィールドのみ表示\n * formatDate({ date: new Date(), parts: ['year', 'month'] }) // \"2024/01\" (ja)\n * formatDate({ date: new Date(), parts: ['weekday'] }) // \"月\" (ja)\n *\n * // 日本語でスラッシュを無効化(月を長形式で表示)\n * formatDate({ date: new Date(), parts: ['year', 'month'], options: { disableSlashInJa: true } }) // \"2024年1月\" (ja)\n *\n * // 最初の文字を大文字化\n * formatDate({ date: new Date(), parts: ['weekday'], options: { capitalizeFirstLetter: true } }) // \"Seg.\" (pt)(指定しなければ \"seg.\")\n */\n formatDate(props: FormatDateProps): string\n\n /**\n * 時刻をロケールに応じた形式でフォーマットする関数\n * @param props - フォーマットのオプション\n * @param props.date - フォーマット対象の日付\n * @param props.parts - 表示する時刻のパーツ。デフォルトは ['hour', 'minute']\n * @param props.options - フォーマットオプション\n * @returns フォーマットされた時刻文字列\n * @example\n * // 基本的な使用法(ロケールのデフォルト形式)\n * formatTime({ date: new Date() }) // \"10:30\" (ja)\n *\n * // 秒を含めて表示\n * formatTime({ date: new Date(), parts: ['hour', 'minute', 'second'] }) // \"10:30:45\" (ja)\n *\n * // 時のみ表示\n * formatTime({ date: new Date(), parts: ['hour'] }) // \"10\" (ja)\n *\n * // 12時間形式で表示\n * formatTime({ date: new Date(), options: { hour12: true } }) // \"午前10:30\" (ja)\n */\n formatTime(props: FormatTimeProps): string\n\n /**\n * タイムスタンプ(日付+時刻)をフォーマットする関数\n * 日付はスラッシュ形式、時刻は24時間形式で表示されます\n * @param props - フォーマットのオプション\n * @param props.date - フォーマット対象の日付\n * @param props.timeParts - 表示する時刻のパーツ。デフォルトは ['hour', 'minute']\n * @returns フォーマットされたタイムスタンプ文字列\n * @example\n * // 基本的な使用法\n * formatTimestamp({ date: new Date() }) // \"2024/01/15 10:30\" (ja)\n *\n * // 秒を含めて表示\n * formatTimestamp({ date: new Date(), timeParts: ['hour', 'minute', 'second'] }) // \"2024/01/15 10:30:45\" (ja)\n */\n formatTimestamp(props: FormatTimestampProps): string\n\n /**\n * 現在のロケールに基づいて週の開始日を決定する関数\n * Intl.Locale.prototype.getWeekInfo()の動作を再現\n * getWeekInfo()を使わない理由は、Firefoxでは動作しないため\n *\n * @returns 週の開始日(0 = 日曜日, 1 = 月曜日, ..., 6 = 土曜日)\n */\n getWeekStartDay: () => number\n}\n\nconst WEEK_START_DAYS = {\n SUNDAY: 0,\n MONDAY: 1,\n TUESDAY: 2,\n WEDNESDAY: 3,\n THURSDAY: 4,\n FRIDAY: 5,\n SATURDAY: 6,\n} as const\n\nconst DATE_FORMATS: Record<\n keyof typeof locales,\n Intl.DateTimeFormatOptions & { weekStartDay: number }\n> = {\n // localeがja, ja-easyの場合、フォーマットを YYYY/MM/DD 形式にする\n // 曜日が含まれている場合は括弧を追加する\n // 参考: https://smarthr.design/products/contents/idiomatic-usage/count/#h2-3\n ja: {\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'ja-easy': {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'en-us': {\n year: 'numeric',\n month: 'short',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'id-id': {\n year: 'numeric',\n month: 'short',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.MONDAY,\n },\n ko: {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n pt: {\n year: 'numeric',\n month: 'short',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.MONDAY,\n },\n vi: {\n year: 'numeric',\n month: 'long',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.MONDAY,\n },\n 'zh-cn': {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'zh-tw': {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n} as const\n\n/**\n * 各ロケールの括弧設定マップ\n * ロケールに応じて適切な括弧スタイル(半角/全角)と配置を定義\n */\nconst WEEKDAY_FORMATS: Record<keyof typeof locales, { replacer: (base: string) => string }> = {\n ja: { replacer: (base) => base.replace(/(.+?)\\(([月火水木金土日])\\)$/, '$1($2)') },\n 'ja-easy': { replacer: (base) => base.replace(/(.+?)\\(([月火水木金土日])\\)$/, '$1($2)') },\n 'en-us': { replacer: (base) => base.replace(/^([A-Za-z]{3}), (.+)$/, '$2 ($1)') },\n 'id-id': { replacer: (base) => base.replace(/^([A-Za-z]{3}), (.+)$/, '$2 ($1)') },\n ko: {\n replacer: (base) => base.replace(/\\s{2,}/g, ' ').replace(/([월화수목금토일])$/, '($1)'),\n },\n pt: { replacer: (base) => base.replace(/^([A-Za-z]{3}\\.), (.+)$/, '$2 ($1)') },\n vi: { replacer: (base) => base.replace(/^(\\S+ \\d+), (.+)$/, '$2 ($1)') },\n 'zh-cn': { replacer: (base) => base.replace(/(.+?)\\s*([周][一二三四五六日])$/, '$1($2)') },\n 'zh-tw': { replacer: (base) => base.replace(/(.+?)\\s*([週][一二三四五六日])$/, '$1($2)') },\n} as const\n\nconst COMMON_TIME_FORMAT: Intl.DateTimeFormatOptions = {\n hour: '2-digit',\n minute: '2-digit',\n hour12: false,\n}\n\nconst TIME_FORMATS: Record<keyof typeof locales, Intl.DateTimeFormatOptions> = {\n ja: COMMON_TIME_FORMAT,\n 'ja-easy': COMMON_TIME_FORMAT,\n 'en-us': {\n ...COMMON_TIME_FORMAT,\n hour: 'numeric',\n hour12: true,\n },\n 'id-id': COMMON_TIME_FORMAT,\n ko: COMMON_TIME_FORMAT,\n pt: COMMON_TIME_FORMAT,\n vi: COMMON_TIME_FORMAT,\n 'zh-cn': COMMON_TIME_FORMAT,\n 'zh-tw': COMMON_TIME_FORMAT,\n} as const\n\nconst isValidLocale = (locale: string): locale is keyof typeof locales => locale in locales\n\nconst applyCapitalization = (text: string, shouldCapitalize: boolean) =>\n shouldCapitalize ? text.charAt(0).toUpperCase() + text.slice(1) : text\n\n/**\n * 日付・時刻フォーマット機能を提供するフック\n *\n * @returns {UseDateFormatReturn} 日付・時刻フォーマットに関連する関数とプロパティを含むオブジェクト\n * @example\n * // 基本的な使用法(日付のフォーマット)\n * const Component = () => {\n * const { formatDate } = useDateFormat()\n * return <span>{formatDate({ date: new Date(2024, 1 - 1, 15) })}</span> // \"2024/01/15\" (ja)\n * }\n *\n * @example\n * // 時刻のフォーマット\n * const Component = () => {\n * const { formatTime } = useDateFormat()\n * return <span>{formatTime({ date: new Date(2024, 1 - 1, 15, 10, 30, 0) })}</span> // \"10:30\" (ja)\n * }\n *\n * @example\n * // 週の開始日の取得\n * const Component = () => {\n * const { getWeekStartDay } = useDateFormat()\n * return <div>週の開始日: {getWeekStartDay()}</div>\n * }\n */\nexport const useDateFormat = (): UseDateFormatReturn => {\n const intl = useReactIntl()\n\n return useMemo(() => {\n const locale = isValidLocale(intl.locale) ? intl.locale : 'ja'\n\n const formatDate = ({\n date,\n parts = ['year', 'month', 'day'],\n options,\n }: FormatDateProps): string => {\n const {\n disableSlashInJa = false,\n capitalizeFirstLetter = false,\n year,\n month,\n day,\n weekday,\n ...rest\n } = options || {}\n\n // パーツの存在を事前に計算\n const hasPart = parts.reduce(\n (prev, part) => {\n prev[part] = true\n return prev\n },\n { year: false, month: false, day: false, weekday: false } as {\n year: boolean\n month: boolean\n day: boolean\n weekday: boolean\n },\n )\n\n // ロケールのデフォルト形式を取得\n const isJaKanjiFormat = disableSlashInJa && locale === 'ja'\n const defaultFormats = DATE_FORMATS[locale]\n\n // local が 'ja' で漢字表記の場合はゼロ埋めをしないようにする\n const defaultMonth = isJaKanjiFormat ? 'long' : defaultFormats.month\n const defaultDay = isJaKanjiFormat ? 'numeric' : defaultFormats.day\n\n const actualFormatOptions: Intl.DateTimeFormatOptions = {\n ...rest,\n year: year ?? (hasPart.year ? defaultFormats.year : undefined),\n month: month ?? (hasPart.month ? defaultMonth : undefined),\n day: day ?? (hasPart.day ? defaultDay : undefined),\n weekday: weekday ?? (hasPart.weekday ? defaultFormats.weekday : undefined),\n }\n\n const formattedDate = intl.formatDate(date, actualFormatOptions)\n\n // 曜日をロケールに応じてフォーマットする\n let formattedResult = formattedDate\n const config = WEEKDAY_FORMATS[locale]\n // 曜日が含まれており、かつ曜日のみの表示でない場合は括弧を追加\n // 例: \"2025/01/01(水)\" → 括弧あり, \"水\" → 括弧なし\n if (config && hasPart.weekday && (parts.length !== 1 || parts[0] !== 'weekday')) {\n formattedResult = config.replacer(formattedDate)\n }\n\n return applyCapitalization(formattedResult, capitalizeFirstLetter)\n }\n\n const formatTime = ({ date, parts = ['hour', 'minute'], options }: FormatTimeProps): string => {\n const formatOptions = options || {}\n\n const hasPart = parts.reduce(\n (prev, part) => {\n prev[part] = true\n return prev\n },\n { hour: false, minute: false, second: false } as {\n hour: boolean\n minute: boolean\n second: boolean\n },\n )\n\n const actualFormatOptions: Intl.DateTimeFormatOptions = {\n ...formatOptions,\n hour: formatOptions.hour ?? (hasPart.hour ? TIME_FORMATS[locale].hour : undefined),\n minute: formatOptions.minute ?? (hasPart.minute ? TIME_FORMATS[locale].minute : undefined),\n second: formatOptions.second ?? (hasPart.second ? '2-digit' : undefined),\n hour12: formatOptions.hour12 ?? TIME_FORMATS[locale].hour12,\n }\n\n return intl.formatDate(date, actualFormatOptions)\n }\n\n return {\n formatDate,\n formatTime,\n formatTimestamp: ({ date, timeParts = ['hour', 'minute'] }: FormatTimestampProps): string => {\n const formattedDate = formatDate({ date, parts: ['year', 'month', 'day'] })\n const formattedTime = formatTime({ date, parts: timeParts })\n return `${formattedDate} ${formattedTime}`\n },\n getWeekStartDay: (): number => DATE_FORMATS[locale].weekStartDay,\n }\n }, [intl])\n}\n"],"names":[],"mappings":";;;;;;;AAyJA;AACE;AACA;AAQF;;;;AAOE;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;;AAGH;;;AAGG;AACH;AACE;AACA;AACA;AACA;AACA;;AAEC;AACD;AACA;AACA;AACA;;AAGF;AACE;AACA;AACA;;AAGF;AACE;AACA;AACA;AACE;AACA;AACA;AACD;AACD;AACA;AACA;AACA;AACA;AACA;;AAGF;AAEA;AAGA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACI;AACL;;AAGE;AAEA;;;;AAkBM;AACA;AACF;;AAUF;AACA;;AAGA;AACA;AAEA;AACE;AACA;AACA;AACA;AACA;;;;;AAOF;;;;AAIE;;AAGF;AACF;AAEA;AACE;;AAII;AACA;AACF;AAQF;AACE;;;AAGA;;;;AAKJ;;;;AAKE;AACE;AACA;AACA;;;;AAIN;AACF;;"}
@@ -140,7 +140,7 @@ const applyCapitalization = (text, shouldCapitalize) => shouldCapitalize ? text.
140
140
  */
141
141
  const useDateFormat = () => {
142
142
  const intl = useIntl();
143
- const functions = useMemo(() => {
143
+ return useMemo(() => {
144
144
  const locale = isValidLocale(intl.locale) ? intl.locale : 'ja';
145
145
  const formatDate = ({ date, parts = ['year', 'month', 'day'], options, }) => {
146
146
  const { disableSlashInJa = false, capitalizeFirstLetter = false, year, month, day, weekday, ...rest } = options || {};
@@ -199,7 +199,6 @@ const useDateFormat = () => {
199
199
  getWeekStartDay: () => DATE_FORMATS[locale].weekStartDay,
200
200
  };
201
201
  }, [intl]);
202
- return functions;
203
202
  };
204
203
 
205
204
  export { useDateFormat };
@@ -1 +1 @@
1
- {"version":3,"file":"useDateFormat.js","sources":["../../src/intl/useDateFormat.ts"],"sourcesContent":["'use client'\n\nimport { useMemo } from 'react'\nimport { useIntl as useReactIntl } from 'react-intl'\n\nimport { locales } from './locales'\n\ntype DatePart = 'year' | 'month' | 'day' | 'weekday'\n\ntype TimePart = 'hour' | 'minute' | 'second'\n\nexport type FormatDateProps = {\n /**\n * フォーマット対象の日付\n */\n date: Date\n\n /**\n * 表示する日付のパーツ。指定しない場合は全て表示\n */\n parts?: readonly [DatePart, ...DatePart[]]\n\n /**\n * フォーマットオプション\n */\n options?: Omit<Intl.DateTimeFormatOptions, 'dateStyle' | 'timeStyle'> & {\n /**\n * 日本語ロケールでスラッシュを無効化し、月を長形式で表示する\n * @example\n * // 通常: \"2025/01\"\n * // disableSlashInJa: true の場合: \"2025年1月\"\n */\n disableSlashInJa?: boolean\n\n /**\n * 最初の文字を大文字化する\n * @example\n * // 通常: \"seg.\" (pt)\n * // capitalizeFirstLetter: true の場合: \"Seg.\" (pt)\n */\n capitalizeFirstLetter?: boolean\n }\n}\n\nexport type FormatTimeProps = {\n /**\n * フォーマット対象の日付\n */\n date: Date\n\n /**\n * 表示する時刻のパーツ。指定しない場合は ['hour', 'minute'] がデフォルト\n */\n parts?: readonly [TimePart, ...TimePart[]]\n\n /**\n * フォーマットオプション\n */\n options?: Omit<Intl.DateTimeFormatOptions, 'dateStyle' | 'timeStyle'>\n}\n\nexport type FormatTimestampProps = {\n /**\n * フォーマット対象の日付\n */\n date: Date\n\n /**\n * 表示する時刻のパーツ。指定しない場合は ['hour', 'minute'] がデフォルト\n */\n timeParts?: readonly [TimePart, ...TimePart[]]\n}\n\n/**\n * useDateFormatフックの戻り値の型定義\n */\nexport type UseDateFormatReturn = {\n /**\n * 日付をロケールに応じた形式でフォーマットする関数\n * @param props - フォーマットのオプション\n * @param props.date - フォーマット対象の日付\n * @param props.parts - 表示する日付のパーツ。デフォルトは ['year', 'month', 'day', 'weekday']\n * @param props.options - フォーマットオプション\n * @param props.options.disableSlashInJa - 日本語ロケールでスラッシュを無効化し、月を長形式で表示する\n * @param props.options.capitalizeFirstLetter - 最初の文字を大文字化する\n * @returns フォーマットされた日付文字列\n * @example\n * // 基本的な使用法(ロケールのデフォルト形式:曜日なし)\n * formatDate({ date: new Date() }) // \"2024/01/15\" (ja)\n *\n * // 日付を曜日ありで表示\n * formatDate({ date: new Date(), parts: ['year', 'month', 'day', 'weekday'] }) // \"2024/01/15(水)\" (ja)\n *\n * // 特定のフィールドのみ表示\n * formatDate({ date: new Date(), parts: ['year', 'month'] }) // \"2024/01\" (ja)\n * formatDate({ date: new Date(), parts: ['weekday'] }) // \"月\" (ja)\n *\n * // 日本語でスラッシュを無効化(月を長形式で表示)\n * formatDate({ date: new Date(), parts: ['year', 'month'], options: { disableSlashInJa: true } }) // \"2024年1月\" (ja)\n *\n * // 最初の文字を大文字化\n * formatDate({ date: new Date(), parts: ['weekday'], options: { capitalizeFirstLetter: true } }) // \"Seg.\" (pt)(指定しなければ \"seg.\")\n */\n formatDate(props: FormatDateProps): string\n\n /**\n * 時刻をロケールに応じた形式でフォーマットする関数\n * @param props - フォーマットのオプション\n * @param props.date - フォーマット対象の日付\n * @param props.parts - 表示する時刻のパーツ。デフォルトは ['hour', 'minute']\n * @param props.options - フォーマットオプション\n * @returns フォーマットされた時刻文字列\n * @example\n * // 基本的な使用法(ロケールのデフォルト形式)\n * formatTime({ date: new Date() }) // \"10:30\" (ja)\n *\n * // 秒を含めて表示\n * formatTime({ date: new Date(), parts: ['hour', 'minute', 'second'] }) // \"10:30:45\" (ja)\n *\n * // 時のみ表示\n * formatTime({ date: new Date(), parts: ['hour'] }) // \"10\" (ja)\n *\n * // 12時間形式で表示\n * formatTime({ date: new Date(), options: { hour12: true } }) // \"午前10:30\" (ja)\n */\n formatTime(props: FormatTimeProps): string\n\n /**\n * タイムスタンプ(日付+時刻)をフォーマットする関数\n * 日付はスラッシュ形式、時刻は24時間形式で表示されます\n * @param props - フォーマットのオプション\n * @param props.date - フォーマット対象の日付\n * @param props.timeParts - 表示する時刻のパーツ。デフォルトは ['hour', 'minute']\n * @returns フォーマットされたタイムスタンプ文字列\n * @example\n * // 基本的な使用法\n * formatTimestamp({ date: new Date() }) // \"2024/01/15 10:30\" (ja)\n *\n * // 秒を含めて表示\n * formatTimestamp({ date: new Date(), timeParts: ['hour', 'minute', 'second'] }) // \"2024/01/15 10:30:45\" (ja)\n */\n formatTimestamp(props: FormatTimestampProps): string\n\n /**\n * 現在のロケールに基づいて週の開始日を決定する関数\n * Intl.Locale.prototype.getWeekInfo()の動作を再現\n * getWeekInfo()を使わない理由は、Firefoxでは動作しないため\n *\n * @returns 週の開始日(0 = 日曜日, 1 = 月曜日, ..., 6 = 土曜日)\n */\n getWeekStartDay: () => number\n}\n\nconst WEEK_START_DAYS = {\n SUNDAY: 0,\n MONDAY: 1,\n TUESDAY: 2,\n WEDNESDAY: 3,\n THURSDAY: 4,\n FRIDAY: 5,\n SATURDAY: 6,\n} as const\n\nconst DATE_FORMATS: Record<\n keyof typeof locales,\n Intl.DateTimeFormatOptions & { weekStartDay: number }\n> = {\n // localeがja, ja-easyの場合、フォーマットを YYYY/MM/DD 形式にする\n // 曜日が含まれている場合は括弧を追加する\n // 参考: https://smarthr.design/products/contents/idiomatic-usage/count/#h2-3\n ja: {\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'ja-easy': {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'en-us': {\n year: 'numeric',\n month: 'short',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'id-id': {\n year: 'numeric',\n month: 'short',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.MONDAY,\n },\n ko: {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n pt: {\n year: 'numeric',\n month: 'short',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.MONDAY,\n },\n vi: {\n year: 'numeric',\n month: 'long',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.MONDAY,\n },\n 'zh-cn': {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'zh-tw': {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n} as const\n\n/**\n * 各ロケールの括弧設定マップ\n * ロケールに応じて適切な括弧スタイル(半角/全角)と配置を定義\n */\nconst WEEKDAY_FORMATS: Record<keyof typeof locales, { replacer: (base: string) => string }> = {\n ja: { replacer: (base) => base.replace(/(.+?)\\(([月火水木金土日])\\)$/, '$1($2)') },\n 'ja-easy': { replacer: (base) => base.replace(/(.+?)\\(([月火水木金土日])\\)$/, '$1($2)') },\n 'en-us': { replacer: (base) => base.replace(/^([A-Za-z]{3}), (.+)$/, '$2 ($1)') },\n 'id-id': { replacer: (base) => base.replace(/^([A-Za-z]{3}), (.+)$/, '$2 ($1)') },\n ko: {\n replacer: (base) => base.replace(/\\s{2,}/g, ' ').replace(/([월화수목금토일])$/, '($1)'),\n },\n pt: { replacer: (base) => base.replace(/^([A-Za-z]{3}\\.), (.+)$/, '$2 ($1)') },\n vi: { replacer: (base) => base.replace(/^(\\S+ \\d+), (.+)$/, '$2 ($1)') },\n 'zh-cn': { replacer: (base) => base.replace(/(.+?)\\s*([周][一二三四五六日])$/, '$1($2)') },\n 'zh-tw': { replacer: (base) => base.replace(/(.+?)\\s*([週][一二三四五六日])$/, '$1($2)') },\n} as const\n\nconst COMMON_TIME_FORMAT: Intl.DateTimeFormatOptions = {\n hour: '2-digit',\n minute: '2-digit',\n hour12: false,\n}\n\nconst TIME_FORMATS: Record<keyof typeof locales, Intl.DateTimeFormatOptions> = {\n ja: COMMON_TIME_FORMAT,\n 'ja-easy': COMMON_TIME_FORMAT,\n 'en-us': {\n ...COMMON_TIME_FORMAT,\n hour: 'numeric',\n hour12: true,\n },\n 'id-id': COMMON_TIME_FORMAT,\n ko: COMMON_TIME_FORMAT,\n pt: COMMON_TIME_FORMAT,\n vi: COMMON_TIME_FORMAT,\n 'zh-cn': COMMON_TIME_FORMAT,\n 'zh-tw': COMMON_TIME_FORMAT,\n} as const\n\nconst isValidLocale = (locale: string): locale is keyof typeof locales => locale in locales\n\nconst applyCapitalization = (text: string, shouldCapitalize: boolean) =>\n shouldCapitalize ? text.charAt(0).toUpperCase() + text.slice(1) : text\n\n/**\n * 日付・時刻フォーマット機能を提供するフック\n *\n * @returns {UseDateFormatReturn} 日付・時刻フォーマットに関連する関数とプロパティを含むオブジェクト\n * @example\n * // 基本的な使用法(日付のフォーマット)\n * const Component = () => {\n * const { formatDate } = useDateFormat()\n * return <span>{formatDate({ date: new Date(2024, 1 - 1, 15) })}</span> // \"2024/01/15\" (ja)\n * }\n *\n * @example\n * // 時刻のフォーマット\n * const Component = () => {\n * const { formatTime } = useDateFormat()\n * return <span>{formatTime({ date: new Date(2024, 1 - 1, 15, 10, 30, 0) })}</span> // \"10:30\" (ja)\n * }\n *\n * @example\n * // 週の開始日の取得\n * const Component = () => {\n * const { getWeekStartDay } = useDateFormat()\n * return <div>週の開始日: {getWeekStartDay()}</div>\n * }\n */\nexport const useDateFormat = (): UseDateFormatReturn => {\n const intl = useReactIntl()\n\n const functions = useMemo(() => {\n const locale = isValidLocale(intl.locale) ? intl.locale : 'ja'\n\n const formatDate = ({\n date,\n parts = ['year', 'month', 'day'],\n options,\n }: FormatDateProps): string => {\n const {\n disableSlashInJa = false,\n capitalizeFirstLetter = false,\n year,\n month,\n day,\n weekday,\n ...rest\n } = options || {}\n\n // パーツの存在を事前に計算\n const hasPart = parts.reduce(\n (prev, part) => {\n prev[part] = true\n return prev\n },\n { year: false, month: false, day: false, weekday: false } as {\n year: boolean\n month: boolean\n day: boolean\n weekday: boolean\n },\n )\n\n // ロケールのデフォルト形式を取得\n const isJaKanjiFormat = disableSlashInJa && locale === 'ja'\n const defaultFormats = DATE_FORMATS[locale]\n\n // local が 'ja' で漢字表記の場合はゼロ埋めをしないようにする\n const defaultMonth = isJaKanjiFormat ? 'long' : defaultFormats.month\n const defaultDay = isJaKanjiFormat ? 'numeric' : defaultFormats.day\n\n const actualFormatOptions: Intl.DateTimeFormatOptions = {\n ...rest,\n year: year ?? (hasPart.year ? defaultFormats.year : undefined),\n month: month ?? (hasPart.month ? defaultMonth : undefined),\n day: day ?? (hasPart.day ? defaultDay : undefined),\n weekday: weekday ?? (hasPart.weekday ? defaultFormats.weekday : undefined),\n }\n\n const formattedDate = intl.formatDate(date, actualFormatOptions)\n\n // 曜日をロケールに応じてフォーマットする\n let formattedResult = formattedDate\n const config = WEEKDAY_FORMATS[locale]\n // 曜日が含まれており、かつ曜日のみの表示でない場合は括弧を追加\n // 例: \"2025/01/01(水)\" → 括弧あり, \"水\" → 括弧なし\n if (config && hasPart.weekday && (parts.length !== 1 || parts[0] !== 'weekday')) {\n formattedResult = config.replacer(formattedDate)\n }\n\n return applyCapitalization(formattedResult, capitalizeFirstLetter)\n }\n\n const formatTime = ({ date, parts = ['hour', 'minute'], options }: FormatTimeProps): string => {\n const formatOptions = options || {}\n\n const hasPart = parts.reduce(\n (prev, part) => {\n prev[part] = true\n return prev\n },\n { hour: false, minute: false, second: false } as {\n hour: boolean\n minute: boolean\n second: boolean\n },\n )\n\n const actualFormatOptions: Intl.DateTimeFormatOptions = {\n ...formatOptions,\n hour: formatOptions.hour ?? (hasPart.hour ? TIME_FORMATS[locale].hour : undefined),\n minute: formatOptions.minute ?? (hasPart.minute ? TIME_FORMATS[locale].minute : undefined),\n second: formatOptions.second ?? (hasPart.second ? '2-digit' : undefined),\n hour12: formatOptions.hour12 ?? TIME_FORMATS[locale].hour12,\n }\n\n return intl.formatDate(date, actualFormatOptions)\n }\n\n return {\n formatDate,\n formatTime,\n formatTimestamp: ({ date, timeParts = ['hour', 'minute'] }: FormatTimestampProps): string => {\n const formattedDate = formatDate({ date, parts: ['year', 'month', 'day'] })\n const formattedTime = formatTime({ date, parts: timeParts })\n return `${formattedDate} ${formattedTime}`\n },\n getWeekStartDay: (): number => DATE_FORMATS[locale].weekStartDay,\n }\n }, [intl])\n\n return functions\n}\n"],"names":[],"mappings":";;;;;AAyJA;AACE;AACA;AAQF;;;;AAOE;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;;AAGH;;;AAGG;AACH;AACE;AACA;AACA;AACA;AACA;;AAEC;AACD;AACA;AACA;AACA;;AAGF;AACE;AACA;AACA;;AAGF;AACE;AACA;AACA;AACE;AACA;AACA;AACD;AACD;AACA;AACA;AACA;AACA;AACA;;AAGF;AAEA;AAGA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACI;AACL;AAEA;AACE;AAEA;;;;AAkBM;AACA;AACF;;AAUF;AACA;;AAGA;AACA;AAEA;AACE;AACA;AACA;AACA;AACA;;;;;AAOF;;;;AAIE;;AAGF;AACF;AAEA;AACE;;AAII;AACA;AACF;AAQF;AACE;;;AAGA;;;;AAKJ;;;;AAKE;AACE;AACA;AACA;;;;AAIN;AAEA;AACF;;"}
1
+ {"version":3,"file":"useDateFormat.js","sources":["../../src/intl/useDateFormat.ts"],"sourcesContent":["'use client'\n\nimport { useMemo } from 'react'\nimport { useIntl as useReactIntl } from 'react-intl'\n\nimport { locales } from './locales'\n\ntype DatePart = 'year' | 'month' | 'day' | 'weekday'\n\ntype TimePart = 'hour' | 'minute' | 'second'\n\nexport type FormatDateProps = {\n /**\n * フォーマット対象の日付\n */\n date: Date\n\n /**\n * 表示する日付のパーツ。指定しない場合は全て表示\n */\n parts?: readonly [DatePart, ...DatePart[]]\n\n /**\n * フォーマットオプション\n */\n options?: Omit<Intl.DateTimeFormatOptions, 'dateStyle' | 'timeStyle'> & {\n /**\n * 日本語ロケールでスラッシュを無効化し、月を長形式で表示する\n * @example\n * // 通常: \"2025/01\"\n * // disableSlashInJa: true の場合: \"2025年1月\"\n */\n disableSlashInJa?: boolean\n\n /**\n * 最初の文字を大文字化する\n * @example\n * // 通常: \"seg.\" (pt)\n * // capitalizeFirstLetter: true の場合: \"Seg.\" (pt)\n */\n capitalizeFirstLetter?: boolean\n }\n}\n\nexport type FormatTimeProps = {\n /**\n * フォーマット対象の日付\n */\n date: Date\n\n /**\n * 表示する時刻のパーツ。指定しない場合は ['hour', 'minute'] がデフォルト\n */\n parts?: readonly [TimePart, ...TimePart[]]\n\n /**\n * フォーマットオプション\n */\n options?: Omit<Intl.DateTimeFormatOptions, 'dateStyle' | 'timeStyle'>\n}\n\nexport type FormatTimestampProps = {\n /**\n * フォーマット対象の日付\n */\n date: Date\n\n /**\n * 表示する時刻のパーツ。指定しない場合は ['hour', 'minute'] がデフォルト\n */\n timeParts?: readonly [TimePart, ...TimePart[]]\n}\n\n/**\n * useDateFormatフックの戻り値の型定義\n */\nexport type UseDateFormatReturn = {\n /**\n * 日付をロケールに応じた形式でフォーマットする関数\n * @param props - フォーマットのオプション\n * @param props.date - フォーマット対象の日付\n * @param props.parts - 表示する日付のパーツ。デフォルトは ['year', 'month', 'day', 'weekday']\n * @param props.options - フォーマットオプション\n * @param props.options.disableSlashInJa - 日本語ロケールでスラッシュを無効化し、月を長形式で表示する\n * @param props.options.capitalizeFirstLetter - 最初の文字を大文字化する\n * @returns フォーマットされた日付文字列\n * @example\n * // 基本的な使用法(ロケールのデフォルト形式:曜日なし)\n * formatDate({ date: new Date() }) // \"2024/01/15\" (ja)\n *\n * // 日付を曜日ありで表示\n * formatDate({ date: new Date(), parts: ['year', 'month', 'day', 'weekday'] }) // \"2024/01/15(水)\" (ja)\n *\n * // 特定のフィールドのみ表示\n * formatDate({ date: new Date(), parts: ['year', 'month'] }) // \"2024/01\" (ja)\n * formatDate({ date: new Date(), parts: ['weekday'] }) // \"月\" (ja)\n *\n * // 日本語でスラッシュを無効化(月を長形式で表示)\n * formatDate({ date: new Date(), parts: ['year', 'month'], options: { disableSlashInJa: true } }) // \"2024年1月\" (ja)\n *\n * // 最初の文字を大文字化\n * formatDate({ date: new Date(), parts: ['weekday'], options: { capitalizeFirstLetter: true } }) // \"Seg.\" (pt)(指定しなければ \"seg.\")\n */\n formatDate(props: FormatDateProps): string\n\n /**\n * 時刻をロケールに応じた形式でフォーマットする関数\n * @param props - フォーマットのオプション\n * @param props.date - フォーマット対象の日付\n * @param props.parts - 表示する時刻のパーツ。デフォルトは ['hour', 'minute']\n * @param props.options - フォーマットオプション\n * @returns フォーマットされた時刻文字列\n * @example\n * // 基本的な使用法(ロケールのデフォルト形式)\n * formatTime({ date: new Date() }) // \"10:30\" (ja)\n *\n * // 秒を含めて表示\n * formatTime({ date: new Date(), parts: ['hour', 'minute', 'second'] }) // \"10:30:45\" (ja)\n *\n * // 時のみ表示\n * formatTime({ date: new Date(), parts: ['hour'] }) // \"10\" (ja)\n *\n * // 12時間形式で表示\n * formatTime({ date: new Date(), options: { hour12: true } }) // \"午前10:30\" (ja)\n */\n formatTime(props: FormatTimeProps): string\n\n /**\n * タイムスタンプ(日付+時刻)をフォーマットする関数\n * 日付はスラッシュ形式、時刻は24時間形式で表示されます\n * @param props - フォーマットのオプション\n * @param props.date - フォーマット対象の日付\n * @param props.timeParts - 表示する時刻のパーツ。デフォルトは ['hour', 'minute']\n * @returns フォーマットされたタイムスタンプ文字列\n * @example\n * // 基本的な使用法\n * formatTimestamp({ date: new Date() }) // \"2024/01/15 10:30\" (ja)\n *\n * // 秒を含めて表示\n * formatTimestamp({ date: new Date(), timeParts: ['hour', 'minute', 'second'] }) // \"2024/01/15 10:30:45\" (ja)\n */\n formatTimestamp(props: FormatTimestampProps): string\n\n /**\n * 現在のロケールに基づいて週の開始日を決定する関数\n * Intl.Locale.prototype.getWeekInfo()の動作を再現\n * getWeekInfo()を使わない理由は、Firefoxでは動作しないため\n *\n * @returns 週の開始日(0 = 日曜日, 1 = 月曜日, ..., 6 = 土曜日)\n */\n getWeekStartDay: () => number\n}\n\nconst WEEK_START_DAYS = {\n SUNDAY: 0,\n MONDAY: 1,\n TUESDAY: 2,\n WEDNESDAY: 3,\n THURSDAY: 4,\n FRIDAY: 5,\n SATURDAY: 6,\n} as const\n\nconst DATE_FORMATS: Record<\n keyof typeof locales,\n Intl.DateTimeFormatOptions & { weekStartDay: number }\n> = {\n // localeがja, ja-easyの場合、フォーマットを YYYY/MM/DD 形式にする\n // 曜日が含まれている場合は括弧を追加する\n // 参考: https://smarthr.design/products/contents/idiomatic-usage/count/#h2-3\n ja: {\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'ja-easy': {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'en-us': {\n year: 'numeric',\n month: 'short',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'id-id': {\n year: 'numeric',\n month: 'short',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.MONDAY,\n },\n ko: {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n pt: {\n year: 'numeric',\n month: 'short',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.MONDAY,\n },\n vi: {\n year: 'numeric',\n month: 'long',\n day: '2-digit',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.MONDAY,\n },\n 'zh-cn': {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n 'zh-tw': {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'short',\n weekStartDay: WEEK_START_DAYS.SUNDAY,\n },\n} as const\n\n/**\n * 各ロケールの括弧設定マップ\n * ロケールに応じて適切な括弧スタイル(半角/全角)と配置を定義\n */\nconst WEEKDAY_FORMATS: Record<keyof typeof locales, { replacer: (base: string) => string }> = {\n ja: { replacer: (base) => base.replace(/(.+?)\\(([月火水木金土日])\\)$/, '$1($2)') },\n 'ja-easy': { replacer: (base) => base.replace(/(.+?)\\(([月火水木金土日])\\)$/, '$1($2)') },\n 'en-us': { replacer: (base) => base.replace(/^([A-Za-z]{3}), (.+)$/, '$2 ($1)') },\n 'id-id': { replacer: (base) => base.replace(/^([A-Za-z]{3}), (.+)$/, '$2 ($1)') },\n ko: {\n replacer: (base) => base.replace(/\\s{2,}/g, ' ').replace(/([월화수목금토일])$/, '($1)'),\n },\n pt: { replacer: (base) => base.replace(/^([A-Za-z]{3}\\.), (.+)$/, '$2 ($1)') },\n vi: { replacer: (base) => base.replace(/^(\\S+ \\d+), (.+)$/, '$2 ($1)') },\n 'zh-cn': { replacer: (base) => base.replace(/(.+?)\\s*([周][一二三四五六日])$/, '$1($2)') },\n 'zh-tw': { replacer: (base) => base.replace(/(.+?)\\s*([週][一二三四五六日])$/, '$1($2)') },\n} as const\n\nconst COMMON_TIME_FORMAT: Intl.DateTimeFormatOptions = {\n hour: '2-digit',\n minute: '2-digit',\n hour12: false,\n}\n\nconst TIME_FORMATS: Record<keyof typeof locales, Intl.DateTimeFormatOptions> = {\n ja: COMMON_TIME_FORMAT,\n 'ja-easy': COMMON_TIME_FORMAT,\n 'en-us': {\n ...COMMON_TIME_FORMAT,\n hour: 'numeric',\n hour12: true,\n },\n 'id-id': COMMON_TIME_FORMAT,\n ko: COMMON_TIME_FORMAT,\n pt: COMMON_TIME_FORMAT,\n vi: COMMON_TIME_FORMAT,\n 'zh-cn': COMMON_TIME_FORMAT,\n 'zh-tw': COMMON_TIME_FORMAT,\n} as const\n\nconst isValidLocale = (locale: string): locale is keyof typeof locales => locale in locales\n\nconst applyCapitalization = (text: string, shouldCapitalize: boolean) =>\n shouldCapitalize ? text.charAt(0).toUpperCase() + text.slice(1) : text\n\n/**\n * 日付・時刻フォーマット機能を提供するフック\n *\n * @returns {UseDateFormatReturn} 日付・時刻フォーマットに関連する関数とプロパティを含むオブジェクト\n * @example\n * // 基本的な使用法(日付のフォーマット)\n * const Component = () => {\n * const { formatDate } = useDateFormat()\n * return <span>{formatDate({ date: new Date(2024, 1 - 1, 15) })}</span> // \"2024/01/15\" (ja)\n * }\n *\n * @example\n * // 時刻のフォーマット\n * const Component = () => {\n * const { formatTime } = useDateFormat()\n * return <span>{formatTime({ date: new Date(2024, 1 - 1, 15, 10, 30, 0) })}</span> // \"10:30\" (ja)\n * }\n *\n * @example\n * // 週の開始日の取得\n * const Component = () => {\n * const { getWeekStartDay } = useDateFormat()\n * return <div>週の開始日: {getWeekStartDay()}</div>\n * }\n */\nexport const useDateFormat = (): UseDateFormatReturn => {\n const intl = useReactIntl()\n\n return useMemo(() => {\n const locale = isValidLocale(intl.locale) ? intl.locale : 'ja'\n\n const formatDate = ({\n date,\n parts = ['year', 'month', 'day'],\n options,\n }: FormatDateProps): string => {\n const {\n disableSlashInJa = false,\n capitalizeFirstLetter = false,\n year,\n month,\n day,\n weekday,\n ...rest\n } = options || {}\n\n // パーツの存在を事前に計算\n const hasPart = parts.reduce(\n (prev, part) => {\n prev[part] = true\n return prev\n },\n { year: false, month: false, day: false, weekday: false } as {\n year: boolean\n month: boolean\n day: boolean\n weekday: boolean\n },\n )\n\n // ロケールのデフォルト形式を取得\n const isJaKanjiFormat = disableSlashInJa && locale === 'ja'\n const defaultFormats = DATE_FORMATS[locale]\n\n // local が 'ja' で漢字表記の場合はゼロ埋めをしないようにする\n const defaultMonth = isJaKanjiFormat ? 'long' : defaultFormats.month\n const defaultDay = isJaKanjiFormat ? 'numeric' : defaultFormats.day\n\n const actualFormatOptions: Intl.DateTimeFormatOptions = {\n ...rest,\n year: year ?? (hasPart.year ? defaultFormats.year : undefined),\n month: month ?? (hasPart.month ? defaultMonth : undefined),\n day: day ?? (hasPart.day ? defaultDay : undefined),\n weekday: weekday ?? (hasPart.weekday ? defaultFormats.weekday : undefined),\n }\n\n const formattedDate = intl.formatDate(date, actualFormatOptions)\n\n // 曜日をロケールに応じてフォーマットする\n let formattedResult = formattedDate\n const config = WEEKDAY_FORMATS[locale]\n // 曜日が含まれており、かつ曜日のみの表示でない場合は括弧を追加\n // 例: \"2025/01/01(水)\" → 括弧あり, \"水\" → 括弧なし\n if (config && hasPart.weekday && (parts.length !== 1 || parts[0] !== 'weekday')) {\n formattedResult = config.replacer(formattedDate)\n }\n\n return applyCapitalization(formattedResult, capitalizeFirstLetter)\n }\n\n const formatTime = ({ date, parts = ['hour', 'minute'], options }: FormatTimeProps): string => {\n const formatOptions = options || {}\n\n const hasPart = parts.reduce(\n (prev, part) => {\n prev[part] = true\n return prev\n },\n { hour: false, minute: false, second: false } as {\n hour: boolean\n minute: boolean\n second: boolean\n },\n )\n\n const actualFormatOptions: Intl.DateTimeFormatOptions = {\n ...formatOptions,\n hour: formatOptions.hour ?? (hasPart.hour ? TIME_FORMATS[locale].hour : undefined),\n minute: formatOptions.minute ?? (hasPart.minute ? TIME_FORMATS[locale].minute : undefined),\n second: formatOptions.second ?? (hasPart.second ? '2-digit' : undefined),\n hour12: formatOptions.hour12 ?? TIME_FORMATS[locale].hour12,\n }\n\n return intl.formatDate(date, actualFormatOptions)\n }\n\n return {\n formatDate,\n formatTime,\n formatTimestamp: ({ date, timeParts = ['hour', 'minute'] }: FormatTimestampProps): string => {\n const formattedDate = formatDate({ date, parts: ['year', 'month', 'day'] })\n const formattedTime = formatTime({ date, parts: timeParts })\n return `${formattedDate} ${formattedTime}`\n },\n getWeekStartDay: (): number => DATE_FORMATS[locale].weekStartDay,\n }\n }, [intl])\n}\n"],"names":[],"mappings":";;;;;AAyJA;AACE;AACA;AAQF;;;;AAOE;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;AACD;AACE;AACA;AACA;AACA;;AAED;;AAGH;;;AAGG;AACH;AACE;AACA;AACA;AACA;AACA;;AAEC;AACD;AACA;AACA;AACA;;AAGF;AACE;AACA;AACA;;AAGF;AACE;AACA;AACA;AACE;AACA;AACA;AACD;AACD;AACA;AACA;AACA;AACA;AACA;;AAGF;AAEA;AAGA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACI;AACL;;AAGE;AAEA;;;;AAkBM;AACA;AACF;;AAUF;AACA;;AAGA;AACA;AAEA;AACE;AACA;AACA;AACA;AACA;;;;;AAOF;;;;AAIE;;AAGF;AACF;AAEA;AACE;;AAII;AACA;AACF;AAQF;AACE;;;AAGA;;;;AAKJ;;;;AAKE;AACE;AACA;AACA;;;;AAIN;AACF;;"}
@@ -27,15 +27,14 @@ const isValidLocale = (locale) => locale in intl_locales_index.locales;
27
27
  */
28
28
  const useIntl = () => {
29
29
  const intl = reactIntl.useIntl();
30
- const result = React.useMemo(() => ({
30
+ return React.useMemo(() => ({
31
31
  localize: (descriptor, values, opts) => intl.formatMessage({ ...descriptor, defaultMessage: descriptor.defaultText }, values, opts),
32
32
  locale: isValidLocale(intl.locale) ? intl.locale : 'ja',
33
33
  }), [intl]);
34
- return result;
35
34
  };
36
35
  const useLocalize = (props) => {
37
36
  const { localize } = useIntl();
38
- const localized = React.useMemo(() => {
37
+ return React.useMemo(() => {
39
38
  const result = {};
40
39
  for (const i in props) {
41
40
  result[i] = localize(props[i]);
@@ -45,7 +44,6 @@ const useLocalize = (props) => {
45
44
  // 依存配列からは意図的に排除している
46
45
  // eslint-disable-next-line react-hooks/exhaustive-deps
47
46
  }, [localize]);
48
- return localized;
49
47
  };
50
48
 
51
49
  exports.useIntl = useIntl;
@@ -1 +1 @@
1
- {"version":3,"file":"useIntl.cjs","sources":["../../src/intl/useIntl.ts"],"sourcesContent":["'use client'\n\nimport { useMemo } from 'react'\nimport {\n type PrimitiveType,\n type MessageDescriptor as ReactIntlMessageDescriptor,\n useIntl as useReactIntl,\n} from 'react-intl'\n\nimport { locales, type typedJa } from './locales'\n\nimport type { FormatXMLElementFn, Options as IntlMessageFormatOptions } from 'intl-messageformat'\n\ntype Messages = Record<keyof typeof typedJa, string>\n\ntype MessageDescriptor<T extends keyof Messages> = Omit<ReactIntlMessageDescriptor, 'id'> & {\n id: T\n defaultText: (typeof typedJa)[T]\n}\n\n/**\n * useIntlフックの戻り値の型定義\n */\nexport type UseIntlReturn = {\n /** メッセージのローカライズ関数 */\n localize: <T extends keyof Messages>(\n descriptor: MessageDescriptor<T>,\n values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,\n opts?: IntlMessageFormatOptions,\n ) => string\n /** 現在のロケール */\n locale: keyof typeof locales\n}\n\ntype LocalizeProps = Parameters<UseIntlReturn['localize']>[0]\n\nconst isValidLocale = (locale: string): locale is keyof typeof locales => locale in locales\n\n/**\n * メッセージローカライズ機能を提供するフック\n * react-intlをベースにした国際化機能を提供します\n *\n * @returns {UseIntlReturn} ローカライズに関連する関数とプロパティを含むオブジェクト\n * @example\n * // 基本的な使用法(メッセージのローカライズ)\n * const Component = () => {\n * const { localize } = useIntl()\n * return <span>{localize({ id: 'smarthr-ui/common/language', defaultText: '日本語' })}</span>\n * }\n *\n * @example\n * // 現在のロケールの取得\n * const Component = () => {\n * const { locale } = useIntl()\n * return <div>現在のロケール: {locale}</div>\n * }\n */\nexport const useIntl = (): UseIntlReturn => {\n const intl = useReactIntl()\n\n const result = useMemo(\n () => ({\n localize: <T extends keyof Messages>(\n descriptor: MessageDescriptor<T>,\n values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,\n opts?: IntlMessageFormatOptions,\n ): string =>\n intl.formatMessage({ ...descriptor, defaultMessage: descriptor.defaultText }, values, opts),\n locale: isValidLocale(intl.locale) ? intl.locale : 'ja',\n }),\n [intl],\n )\n\n return result\n}\n\nexport const useLocalize = <T extends { [key: string]: LocalizeProps }>(\n props: T,\n): { [K in keyof T]: string } => {\n const { localize } = useIntl()\n\n const localized = useMemo(() => {\n const result = {} as { [K in keyof T]: string }\n\n for (const i in props) {\n result[i] = localize(props[i])\n }\n\n return result\n // HINT: 利用方法としてpropsはliteral objectになる\n // 依存配列からは意図的に排除している\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [localize])\n\n return localized\n}\n"],"names":[],"mappings":";;;;;;;AAoCA;AAEA;;;;;;;;;;;;;;;;;;AAkBG;AACI;AACL;AAEA;AAEI;AAMA;AACD;AAIH;AACF;AAEO;AAGL;AAEA;;AAGE;;;AAIA;;;;AAIF;AAEA;AACF;;;"}
1
+ {"version":3,"file":"useIntl.cjs","sources":["../../src/intl/useIntl.ts"],"sourcesContent":["'use client'\n\nimport { useMemo } from 'react'\nimport {\n type PrimitiveType,\n type MessageDescriptor as ReactIntlMessageDescriptor,\n useIntl as useReactIntl,\n} from 'react-intl'\n\nimport { locales, type typedJa } from './locales'\n\nimport type { FormatXMLElementFn, Options as IntlMessageFormatOptions } from 'intl-messageformat'\n\ntype Messages = Record<keyof typeof typedJa, string>\n\ntype MessageDescriptor<T extends keyof Messages> = Omit<ReactIntlMessageDescriptor, 'id'> & {\n id: T\n defaultText: (typeof typedJa)[T]\n}\n\n/**\n * useIntlフックの戻り値の型定義\n */\nexport type UseIntlReturn = {\n /** メッセージのローカライズ関数 */\n localize: <T extends keyof Messages>(\n descriptor: MessageDescriptor<T>,\n values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,\n opts?: IntlMessageFormatOptions,\n ) => string\n /** 現在のロケール */\n locale: keyof typeof locales\n}\n\ntype LocalizeProps = Parameters<UseIntlReturn['localize']>[0]\n\nconst isValidLocale = (locale: string): locale is keyof typeof locales => locale in locales\n\n/**\n * メッセージローカライズ機能を提供するフック\n * react-intlをベースにした国際化機能を提供します\n *\n * @returns {UseIntlReturn} ローカライズに関連する関数とプロパティを含むオブジェクト\n * @example\n * // 基本的な使用法(メッセージのローカライズ)\n * const Component = () => {\n * const { localize } = useIntl()\n * return <span>{localize({ id: 'smarthr-ui/common/language', defaultText: '日本語' })}</span>\n * }\n *\n * @example\n * // 現在のロケールの取得\n * const Component = () => {\n * const { locale } = useIntl()\n * return <div>現在のロケール: {locale}</div>\n * }\n */\nexport const useIntl = (): UseIntlReturn => {\n const intl = useReactIntl()\n\n return useMemo(\n () => ({\n localize: <T extends keyof Messages>(\n descriptor: MessageDescriptor<T>,\n values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,\n opts?: IntlMessageFormatOptions,\n ): string =>\n intl.formatMessage({ ...descriptor, defaultMessage: descriptor.defaultText }, values, opts),\n locale: isValidLocale(intl.locale) ? intl.locale : 'ja',\n }),\n [intl],\n )\n}\n\nexport const useLocalize = <T extends { [key: string]: LocalizeProps }>(\n props: T,\n): { [K in keyof T]: string } => {\n const { localize } = useIntl()\n\n return useMemo(() => {\n const result = {} as { [K in keyof T]: string }\n\n for (const i in props) {\n result[i] = localize(props[i])\n }\n\n return result\n // HINT: 利用方法としてpropsはliteral objectになる\n // 依存配列からは意図的に排除している\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [localize])\n}\n"],"names":[],"mappings":";;;;;;;AAoCA;AAEA;;;;;;;;;;;;;;;;;;AAkBG;AACI;AACL;AAEA;AAEI;AAMA;AACD;AAGL;AAEO;AAGL;;;AAKE;;;AAIA;;;;AAIF;AACF;;;"}
@@ -25,15 +25,14 @@ const isValidLocale = (locale) => locale in locales;
25
25
  */
26
26
  const useIntl = () => {
27
27
  const intl = useIntl$1();
28
- const result = useMemo(() => ({
28
+ return useMemo(() => ({
29
29
  localize: (descriptor, values, opts) => intl.formatMessage({ ...descriptor, defaultMessage: descriptor.defaultText }, values, opts),
30
30
  locale: isValidLocale(intl.locale) ? intl.locale : 'ja',
31
31
  }), [intl]);
32
- return result;
33
32
  };
34
33
  const useLocalize = (props) => {
35
34
  const { localize } = useIntl();
36
- const localized = useMemo(() => {
35
+ return useMemo(() => {
37
36
  const result = {};
38
37
  for (const i in props) {
39
38
  result[i] = localize(props[i]);
@@ -43,7 +42,6 @@ const useLocalize = (props) => {
43
42
  // 依存配列からは意図的に排除している
44
43
  // eslint-disable-next-line react-hooks/exhaustive-deps
45
44
  }, [localize]);
46
- return localized;
47
45
  };
48
46
 
49
47
  export { useIntl, useLocalize };
@@ -1 +1 @@
1
- {"version":3,"file":"useIntl.js","sources":["../../src/intl/useIntl.ts"],"sourcesContent":["'use client'\n\nimport { useMemo } from 'react'\nimport {\n type PrimitiveType,\n type MessageDescriptor as ReactIntlMessageDescriptor,\n useIntl as useReactIntl,\n} from 'react-intl'\n\nimport { locales, type typedJa } from './locales'\n\nimport type { FormatXMLElementFn, Options as IntlMessageFormatOptions } from 'intl-messageformat'\n\ntype Messages = Record<keyof typeof typedJa, string>\n\ntype MessageDescriptor<T extends keyof Messages> = Omit<ReactIntlMessageDescriptor, 'id'> & {\n id: T\n defaultText: (typeof typedJa)[T]\n}\n\n/**\n * useIntlフックの戻り値の型定義\n */\nexport type UseIntlReturn = {\n /** メッセージのローカライズ関数 */\n localize: <T extends keyof Messages>(\n descriptor: MessageDescriptor<T>,\n values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,\n opts?: IntlMessageFormatOptions,\n ) => string\n /** 現在のロケール */\n locale: keyof typeof locales\n}\n\ntype LocalizeProps = Parameters<UseIntlReturn['localize']>[0]\n\nconst isValidLocale = (locale: string): locale is keyof typeof locales => locale in locales\n\n/**\n * メッセージローカライズ機能を提供するフック\n * react-intlをベースにした国際化機能を提供します\n *\n * @returns {UseIntlReturn} ローカライズに関連する関数とプロパティを含むオブジェクト\n * @example\n * // 基本的な使用法(メッセージのローカライズ)\n * const Component = () => {\n * const { localize } = useIntl()\n * return <span>{localize({ id: 'smarthr-ui/common/language', defaultText: '日本語' })}</span>\n * }\n *\n * @example\n * // 現在のロケールの取得\n * const Component = () => {\n * const { locale } = useIntl()\n * return <div>現在のロケール: {locale}</div>\n * }\n */\nexport const useIntl = (): UseIntlReturn => {\n const intl = useReactIntl()\n\n const result = useMemo(\n () => ({\n localize: <T extends keyof Messages>(\n descriptor: MessageDescriptor<T>,\n values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,\n opts?: IntlMessageFormatOptions,\n ): string =>\n intl.formatMessage({ ...descriptor, defaultMessage: descriptor.defaultText }, values, opts),\n locale: isValidLocale(intl.locale) ? intl.locale : 'ja',\n }),\n [intl],\n )\n\n return result\n}\n\nexport const useLocalize = <T extends { [key: string]: LocalizeProps }>(\n props: T,\n): { [K in keyof T]: string } => {\n const { localize } = useIntl()\n\n const localized = useMemo(() => {\n const result = {} as { [K in keyof T]: string }\n\n for (const i in props) {\n result[i] = localize(props[i])\n }\n\n return result\n // HINT: 利用方法としてpropsはliteral objectになる\n // 依存配列からは意図的に排除している\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [localize])\n\n return localized\n}\n"],"names":[],"mappings":";;;;;AAoCA;AAEA;;;;;;;;;;;;;;;;;;AAkBG;AACI;AACL;AAEA;AAEI;AAMA;AACD;AAIH;AACF;AAEO;AAGL;AAEA;;AAGE;;;AAIA;;;;AAIF;AAEA;AACF;;"}
1
+ {"version":3,"file":"useIntl.js","sources":["../../src/intl/useIntl.ts"],"sourcesContent":["'use client'\n\nimport { useMemo } from 'react'\nimport {\n type PrimitiveType,\n type MessageDescriptor as ReactIntlMessageDescriptor,\n useIntl as useReactIntl,\n} from 'react-intl'\n\nimport { locales, type typedJa } from './locales'\n\nimport type { FormatXMLElementFn, Options as IntlMessageFormatOptions } from 'intl-messageformat'\n\ntype Messages = Record<keyof typeof typedJa, string>\n\ntype MessageDescriptor<T extends keyof Messages> = Omit<ReactIntlMessageDescriptor, 'id'> & {\n id: T\n defaultText: (typeof typedJa)[T]\n}\n\n/**\n * useIntlフックの戻り値の型定義\n */\nexport type UseIntlReturn = {\n /** メッセージのローカライズ関数 */\n localize: <T extends keyof Messages>(\n descriptor: MessageDescriptor<T>,\n values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,\n opts?: IntlMessageFormatOptions,\n ) => string\n /** 現在のロケール */\n locale: keyof typeof locales\n}\n\ntype LocalizeProps = Parameters<UseIntlReturn['localize']>[0]\n\nconst isValidLocale = (locale: string): locale is keyof typeof locales => locale in locales\n\n/**\n * メッセージローカライズ機能を提供するフック\n * react-intlをベースにした国際化機能を提供します\n *\n * @returns {UseIntlReturn} ローカライズに関連する関数とプロパティを含むオブジェクト\n * @example\n * // 基本的な使用法(メッセージのローカライズ)\n * const Component = () => {\n * const { localize } = useIntl()\n * return <span>{localize({ id: 'smarthr-ui/common/language', defaultText: '日本語' })}</span>\n * }\n *\n * @example\n * // 現在のロケールの取得\n * const Component = () => {\n * const { locale } = useIntl()\n * return <div>現在のロケール: {locale}</div>\n * }\n */\nexport const useIntl = (): UseIntlReturn => {\n const intl = useReactIntl()\n\n return useMemo(\n () => ({\n localize: <T extends keyof Messages>(\n descriptor: MessageDescriptor<T>,\n values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,\n opts?: IntlMessageFormatOptions,\n ): string =>\n intl.formatMessage({ ...descriptor, defaultMessage: descriptor.defaultText }, values, opts),\n locale: isValidLocale(intl.locale) ? intl.locale : 'ja',\n }),\n [intl],\n )\n}\n\nexport const useLocalize = <T extends { [key: string]: LocalizeProps }>(\n props: T,\n): { [K in keyof T]: string } => {\n const { localize } = useIntl()\n\n return useMemo(() => {\n const result = {} as { [K in keyof T]: string }\n\n for (const i in props) {\n result[i] = localize(props[i])\n }\n\n return result\n // HINT: 利用方法としてpropsはliteral objectになる\n // 依存配列からは意図的に排除している\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [localize])\n}\n"],"names":[],"mappings":";;;;;AAoCA;AAEA;;;;;;;;;;;;;;;;;;AAkBG;AACI;AACL;AAEA;AAEI;AAMA;AACD;AAGL;AAEO;AAGL;;;AAKE;;;AAIA;;;;AAIF;AACF;;"}
@@ -6,21 +6,29 @@
6
6
  *
7
7
  * @param {T} func - 実行する関数
8
8
  * @param {number} wait - デバウンスの待機時間(ミリ秒)
9
- * @returns {(...rest: Parameters<T>) => void} デバウンスされた関数
9
+ * @returns {((...rest: Parameters<T>) => void) & { cancel: () => void }} デバウンスされた関数
10
10
  *
11
11
  * @example
12
12
  * const debouncedFunction = debounce(() => console.log('Called!'), 200);
13
13
  */
14
14
  const debounce = (func, wait) => {
15
15
  let timeoutId = null;
16
- return function (...timeoutRest) {
16
+ const debouncedFunction = function (...timeoutRest) {
17
17
  if (timeoutId !== null) {
18
18
  clearTimeout(timeoutId);
19
19
  }
20
20
  timeoutId = setTimeout(() => {
21
+ timeoutId = null;
21
22
  func(...timeoutRest);
22
23
  }, wait);
23
24
  };
25
+ debouncedFunction.cancel = () => {
26
+ if (timeoutId !== null) {
27
+ clearTimeout(timeoutId);
28
+ timeoutId = null;
29
+ }
30
+ };
31
+ return debouncedFunction;
24
32
  };
25
33
 
26
34
  exports.debounce = debounce;
@@ -1 +1 @@
1
- {"version":3,"file":"debounce.cjs","sources":["../../src/libs/debounce.ts"],"sourcesContent":["/**\n * 関数の呼び出しを指定された待機時間 (wait) だけ遅延させるデバウンス関数。\n * 直前に同じ関数が呼び出された場合、タイマーをリセットして再び遅延させます。\n *\n * @param {T} func - 実行する関数\n * @param {number} wait - デバウンスの待機時間(ミリ秒)\n * @returns {(...rest: Parameters<T>) => void} デバウンスされた関数\n *\n * @example\n * const debouncedFunction = debounce(() => console.log('Called!'), 200);\n */\nexport const debounce = <T extends (...rest: any[]) => void>(\n func: T,\n wait: number,\n): ((...rest: Parameters<T>) => void) => {\n let timeoutId: ReturnType<typeof setTimeout> | null = null\n\n return function (...timeoutRest: Parameters<T>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId)\n }\n timeoutId = setTimeout(() => {\n func(...timeoutRest)\n }, wait)\n }\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;AAUG;MACU,QAAQ,GAAG,CACtB,IAAO,EACP,IAAY,KAC0B;IACtC,IAAI,SAAS,GAAyC,IAAI;IAE1D,OAAO,UAAU,GAAG,WAA0B,EAAA;AAC5C,QAAA,IAAI,SAAS,KAAK,IAAI,EAAE;YACtB,YAAY,CAAC,SAAS,CAAC;QACzB;AACA,QAAA,SAAS,GAAG,UAAU,CAAC,MAAK;AAC1B,YAAA,IAAI,CAAC,GAAG,WAAW,CAAC;QACtB,CAAC,EAAE,IAAI,CAAC;AACV,IAAA,CAAC;AACH;;;;"}
1
+ {"version":3,"file":"debounce.cjs","sources":["../../src/libs/debounce.ts"],"sourcesContent":["/**\n * 関数の呼び出しを指定された待機時間 (wait) だけ遅延させるデバウンス関数。\n * 直前に同じ関数が呼び出された場合、タイマーをリセットして再び遅延させます。\n *\n * @param {T} func - 実行する関数\n * @param {number} wait - デバウンスの待機時間(ミリ秒)\n * @returns {((...rest: Parameters<T>) => void) & { cancel: () => void }} デバウンスされた関数\n *\n * @example\n * const debouncedFunction = debounce(() => console.log('Called!'), 200);\n */\nexport const debounce = <T extends (...rest: any[]) => void>(\n func: T,\n wait: number,\n): ((...rest: Parameters<T>) => void) & { cancel: () => void } => {\n let timeoutId: ReturnType<typeof setTimeout> | null = null\n\n const debouncedFunction = function (...timeoutRest: Parameters<T>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId)\n }\n timeoutId = setTimeout(() => {\n timeoutId = null\n func(...timeoutRest)\n }, wait)\n }\n\n debouncedFunction.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId)\n timeoutId = null\n }\n }\n\n return debouncedFunction\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;AAUG;MACU,QAAQ,GAAG,CACtB,IAAO,EACP,IAAY,KACmD;IAC/D,IAAI,SAAS,GAAyC,IAAI;AAE1D,IAAA,MAAM,iBAAiB,GAAG,UAAU,GAAG,WAA0B,EAAA;AAC/D,QAAA,IAAI,SAAS,KAAK,IAAI,EAAE;YACtB,YAAY,CAAC,SAAS,CAAC;QACzB;AACA,QAAA,SAAS,GAAG,UAAU,CAAC,MAAK;YAC1B,SAAS,GAAG,IAAI;AAChB,YAAA,IAAI,CAAC,GAAG,WAAW,CAAC;QACtB,CAAC,EAAE,IAAI,CAAC;AACV,IAAA,CAAC;AAED,IAAA,iBAAiB,CAAC,MAAM,GAAG,MAAK;AAC9B,QAAA,IAAI,SAAS,KAAK,IAAI,EAAE;YACtB,YAAY,CAAC,SAAS,CAAC;YACvB,SAAS,GAAG,IAAI;QAClB;AACF,IAAA,CAAC;AAED,IAAA,OAAO,iBAAiB;AAC1B;;;;"}
@@ -4,9 +4,11 @@
4
4
  *
5
5
  * @param {T} func - 実行する関数
6
6
  * @param {number} wait - デバウンスの待機時間(ミリ秒)
7
- * @returns {(...rest: Parameters<T>) => void} デバウンスされた関数
7
+ * @returns {((...rest: Parameters<T>) => void) & { cancel: () => void }} デバウンスされた関数
8
8
  *
9
9
  * @example
10
10
  * const debouncedFunction = debounce(() => console.log('Called!'), 200);
11
11
  */
12
- export declare const debounce: <T extends (...rest: any[]) => void>(func: T, wait: number) => ((...rest: Parameters<T>) => void);
12
+ export declare const debounce: <T extends (...rest: any[]) => void>(func: T, wait: number) => ((...rest: Parameters<T>) => void) & {
13
+ cancel: () => void;
14
+ };
@@ -4,21 +4,29 @@
4
4
  *
5
5
  * @param {T} func - 実行する関数
6
6
  * @param {number} wait - デバウンスの待機時間(ミリ秒)
7
- * @returns {(...rest: Parameters<T>) => void} デバウンスされた関数
7
+ * @returns {((...rest: Parameters<T>) => void) & { cancel: () => void }} デバウンスされた関数
8
8
  *
9
9
  * @example
10
10
  * const debouncedFunction = debounce(() => console.log('Called!'), 200);
11
11
  */
12
12
  const debounce = (func, wait) => {
13
13
  let timeoutId = null;
14
- return function (...timeoutRest) {
14
+ const debouncedFunction = function (...timeoutRest) {
15
15
  if (timeoutId !== null) {
16
16
  clearTimeout(timeoutId);
17
17
  }
18
18
  timeoutId = setTimeout(() => {
19
+ timeoutId = null;
19
20
  func(...timeoutRest);
20
21
  }, wait);
21
22
  };
23
+ debouncedFunction.cancel = () => {
24
+ if (timeoutId !== null) {
25
+ clearTimeout(timeoutId);
26
+ timeoutId = null;
27
+ }
28
+ };
29
+ return debouncedFunction;
22
30
  };
23
31
 
24
32
  export { debounce };
@@ -1 +1 @@
1
- {"version":3,"file":"debounce.js","sources":["../../src/libs/debounce.ts"],"sourcesContent":["/**\n * 関数の呼び出しを指定された待機時間 (wait) だけ遅延させるデバウンス関数。\n * 直前に同じ関数が呼び出された場合、タイマーをリセットして再び遅延させます。\n *\n * @param {T} func - 実行する関数\n * @param {number} wait - デバウンスの待機時間(ミリ秒)\n * @returns {(...rest: Parameters<T>) => void} デバウンスされた関数\n *\n * @example\n * const debouncedFunction = debounce(() => console.log('Called!'), 200);\n */\nexport const debounce = <T extends (...rest: any[]) => void>(\n func: T,\n wait: number,\n): ((...rest: Parameters<T>) => void) => {\n let timeoutId: ReturnType<typeof setTimeout> | null = null\n\n return function (...timeoutRest: Parameters<T>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId)\n }\n timeoutId = setTimeout(() => {\n func(...timeoutRest)\n }, wait)\n }\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;AAUG;MACU,QAAQ,GAAG,CACtB,IAAO,EACP,IAAY,KAC0B;IACtC,IAAI,SAAS,GAAyC,IAAI;IAE1D,OAAO,UAAU,GAAG,WAA0B,EAAA;AAC5C,QAAA,IAAI,SAAS,KAAK,IAAI,EAAE;YACtB,YAAY,CAAC,SAAS,CAAC;QACzB;AACA,QAAA,SAAS,GAAG,UAAU,CAAC,MAAK;AAC1B,YAAA,IAAI,CAAC,GAAG,WAAW,CAAC;QACtB,CAAC,EAAE,IAAI,CAAC;AACV,IAAA,CAAC;AACH;;;;"}
1
+ {"version":3,"file":"debounce.js","sources":["../../src/libs/debounce.ts"],"sourcesContent":["/**\n * 関数の呼び出しを指定された待機時間 (wait) だけ遅延させるデバウンス関数。\n * 直前に同じ関数が呼び出された場合、タイマーをリセットして再び遅延させます。\n *\n * @param {T} func - 実行する関数\n * @param {number} wait - デバウンスの待機時間(ミリ秒)\n * @returns {((...rest: Parameters<T>) => void) & { cancel: () => void }} デバウンスされた関数\n *\n * @example\n * const debouncedFunction = debounce(() => console.log('Called!'), 200);\n */\nexport const debounce = <T extends (...rest: any[]) => void>(\n func: T,\n wait: number,\n): ((...rest: Parameters<T>) => void) & { cancel: () => void } => {\n let timeoutId: ReturnType<typeof setTimeout> | null = null\n\n const debouncedFunction = function (...timeoutRest: Parameters<T>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId)\n }\n timeoutId = setTimeout(() => {\n timeoutId = null\n func(...timeoutRest)\n }, wait)\n }\n\n debouncedFunction.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId)\n timeoutId = null\n }\n }\n\n return debouncedFunction\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;AAUG;MACU,QAAQ,GAAG,CACtB,IAAO,EACP,IAAY,KACmD;IAC/D,IAAI,SAAS,GAAyC,IAAI;AAE1D,IAAA,MAAM,iBAAiB,GAAG,UAAU,GAAG,WAA0B,EAAA;AAC/D,QAAA,IAAI,SAAS,KAAK,IAAI,EAAE;YACtB,YAAY,CAAC,SAAS,CAAC;QACzB;AACA,QAAA,SAAS,GAAG,UAAU,CAAC,MAAK;YAC1B,SAAS,GAAG,IAAI;AAChB,YAAA,IAAI,CAAC,GAAG,WAAW,CAAC;QACtB,CAAC,EAAE,IAAI,CAAC;AACV,IAAA,CAAC;AAED,IAAA,iBAAiB,CAAC,MAAM,GAAG,MAAK;AAC9B,QAAA,IAAI,SAAS,KAAK,IAAI,EAAE;YACtB,YAAY,CAAC,SAAS,CAAC;YACvB,SAAS,GAAG,IAAI;QAClB;AACF,IAAA,CAAC;AAED,IAAA,OAAO,iBAAiB;AAC1B;;;;"}
@@ -3,9 +3,8 @@
3
3
  var index = require('../_virtual/index.cjs');
4
4
  var index$1 = require('../_virtual/index2.cjs');
5
5
 
6
- const merge = index;
7
- const range = index$1;
8
6
 
9
- exports.merge = merge;
10
- exports.range = range;
7
+
8
+ exports.merge = index;
9
+ exports.range = index$1;
11
10
  //# sourceMappingURL=lodash.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"lodash.cjs","sources":["../../src/libs/lodash.ts"],"sourcesContent":["import _merge from 'lodash.merge'\nimport _range from 'lodash.range'\n\nexport const merge = _merge\nexport const range = _range\n"],"names":["_merge","_range"],"mappings":";;;;;AAGO,MAAM,KAAK,GAAGA;AACd,MAAM,KAAK,GAAGC;;;;;"}
1
+ {"version":3,"file":"lodash.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -1,11 +1,2 @@
1
- export declare const merge: {
2
- <TObject, TSource>(object: TObject, source: TSource): TObject & TSource;
3
- <TObject, TSource1, TSource2>(object: TObject, source1: TSource1, source2: TSource2): TObject & TSource1 & TSource2;
4
- <TObject, TSource1, TSource2, TSource3>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3): TObject & TSource1 & TSource2 & TSource3;
5
- <TObject, TSource1, TSource2, TSource3, TSource4>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4): TObject & TSource1 & TSource2 & TSource3 & TSource4;
6
- (object: any, ...otherArgs: any[]): any;
7
- };
8
- export declare const range: {
9
- (start: number, end?: number, step?: number): number[];
10
- (end: number, index: string | number, guard: object): number[];
11
- };
1
+ export { default as merge } from 'lodash.merge';
2
+ export { default as range } from 'lodash.range';
@@ -1,8 +1,3 @@
1
- import _merge from '../_virtual/index.js';
2
- import _range from '../_virtual/index2.js';
3
-
4
- const merge = _merge;
5
- const range = _range;
6
-
7
- export { merge, range };
1
+ export { default as merge } from '../_virtual/index.js';
2
+ export { default as range } from '../_virtual/index2.js';
8
3
  //# sourceMappingURL=lodash.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lodash.js","sources":["../../src/libs/lodash.ts"],"sourcesContent":["import _merge from 'lodash.merge'\nimport _range from 'lodash.range'\n\nexport const merge = _merge\nexport const range = _range\n"],"names":[],"mappings":";;;AAGO,MAAM,KAAK,GAAG;AACd,MAAM,KAAK,GAAG;;;;"}
1
+ {"version":3,"file":"lodash.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
package/lib/libs/map.cjs CHANGED
@@ -2,11 +2,7 @@
2
2
 
3
3
  const getIsInclude = (map, key) => !!map.get(key);
4
4
  const mapToKeyArray = (map) => Array.from(map.keys());
5
- const flatArrayToMap = (array) => {
6
- const map = new Map();
7
- array.forEach((item) => map.set(item, item));
8
- return map;
9
- };
5
+ const flatArrayToMap = (array) => new Map(array.map((item) => [item, item]));
10
6
 
11
7
  exports.flatArrayToMap = flatArrayToMap;
12
8
  exports.getIsInclude = getIsInclude;
@@ -1 +1 @@
1
- {"version":3,"file":"map.cjs","sources":["../../src/libs/map.ts"],"sourcesContent":["export const getIsInclude = <K, V>(map: Map<K, V>, key: K) => !!map.get(key)\n\nexport const mapToKeyArray = <K, V>(map: Map<K, V>) => Array.from(map.keys())\n\nexport const flatArrayToMap = <T>(array: T[]) => {\n const map = new Map<T, T>()\n array.forEach((item) => map.set(item, item))\n return map\n}\n"],"names":[],"mappings":";;AAAO,MAAM,YAAY,GAAG,CAAO,GAAc,EAAE,GAAM,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG;AAEpE,MAAM,aAAa,GAAG,CAAO,GAAc,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;AAErE,MAAM,cAAc,GAAG,CAAI,KAAU,KAAI;AAC9C,IAAA,MAAM,GAAG,GAAG,IAAI,GAAG,EAAQ;AAC3B,IAAA,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5C,IAAA,OAAO,GAAG;AACZ;;;;;;"}
1
+ {"version":3,"file":"map.cjs","sources":["../../src/libs/map.ts"],"sourcesContent":["export const getIsInclude = <K, V>(map: Map<K, V>, key: K) => !!map.get(key)\n\nexport const mapToKeyArray = <K, V>(map: Map<K, V>) => Array.from(map.keys())\n\nexport const flatArrayToMap = <T>(array: T[]) => new Map(array.map((item): [T, T] => [item, item]))\n"],"names":[],"mappings":";;AAAO,MAAM,YAAY,GAAG,CAAO,GAAc,EAAE,GAAM,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG;AAEpE,MAAM,aAAa,GAAG,CAAO,GAAc,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;AAErE,MAAM,cAAc,GAAG,CAAI,KAAU,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;;;;;;"}
package/lib/libs/map.js CHANGED
@@ -1,10 +1,6 @@
1
1
  const getIsInclude = (map, key) => !!map.get(key);
2
2
  const mapToKeyArray = (map) => Array.from(map.keys());
3
- const flatArrayToMap = (array) => {
4
- const map = new Map();
5
- array.forEach((item) => map.set(item, item));
6
- return map;
7
- };
3
+ const flatArrayToMap = (array) => new Map(array.map((item) => [item, item]));
8
4
 
9
5
  export { flatArrayToMap, getIsInclude, mapToKeyArray };
10
6
  //# sourceMappingURL=map.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"map.js","sources":["../../src/libs/map.ts"],"sourcesContent":["export const getIsInclude = <K, V>(map: Map<K, V>, key: K) => !!map.get(key)\n\nexport const mapToKeyArray = <K, V>(map: Map<K, V>) => Array.from(map.keys())\n\nexport const flatArrayToMap = <T>(array: T[]) => {\n const map = new Map<T, T>()\n array.forEach((item) => map.set(item, item))\n return map\n}\n"],"names":[],"mappings":"AAAO,MAAM,YAAY,GAAG,CAAO,GAAc,EAAE,GAAM,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG;AAEpE,MAAM,aAAa,GAAG,CAAO,GAAc,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;AAErE,MAAM,cAAc,GAAG,CAAI,KAAU,KAAI;AAC9C,IAAA,MAAM,GAAG,GAAG,IAAI,GAAG,EAAQ;AAC3B,IAAA,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5C,IAAA,OAAO,GAAG;AACZ;;;;"}
1
+ {"version":3,"file":"map.js","sources":["../../src/libs/map.ts"],"sourcesContent":["export const getIsInclude = <K, V>(map: Map<K, V>, key: K) => !!map.get(key)\n\nexport const mapToKeyArray = <K, V>(map: Map<K, V>) => Array.from(map.keys())\n\nexport const flatArrayToMap = <T>(array: T[]) => new Map(array.map((item): [T, T] => [item, item]))\n"],"names":[],"mappings":"AAAO,MAAM,YAAY,GAAG,CAAO,GAAc,EAAE,GAAM,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG;AAEpE,MAAM,aAAa,GAAG,CAAO,GAAc,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;AAErE,MAAM,cAAc,GAAG,CAAI,KAAU,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;;;;"}
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var polished_esm = require('./../vendor/.pnpm/polished@4.3.1/vendor/polished/dist/polished.esm.cjs');
4
- var libs_lodash = require('../libs/lodash.cjs');
4
+ var index = require('../_virtual/index.cjs');
5
+ require('../_virtual/index2.cjs');
5
6
  var themes_createColor = require('./createColor.cjs');
6
7
 
7
8
  const defaultBackgroundColor = {
@@ -39,7 +40,7 @@ const createBackgroundColor = (userColor) => {
39
40
  return defaultBackgroundColor;
40
41
  }
41
42
  // userColorでマージされた色パレットを取得し、背景色を再生成
42
- const color = libs_lodash.merge(themes_createColor.defaultColor, userColor);
43
+ const color = index(themes_createColor.defaultColor, userColor);
43
44
  return {
44
45
  black: color.GREY_100,
45
46
  white: color.WHITE,