smarthr-ui 94.0.0 → 95.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/AppHeader/components/mobile/MenuDialog.cjs +2 -2
- package/lib/components/AppHeader/components/mobile/MenuDialog.js +2 -2
- package/lib/components/AppHeader/components/mobile/UserInfo.cjs +2 -2
- package/lib/components/AppHeader/components/mobile/UserInfo.js +2 -2
- package/lib/components/Button/DisabledReason.cjs +1 -0
- package/lib/components/Button/DisabledReason.cjs.map +1 -1
- package/lib/components/Button/DisabledReason.js +1 -0
- package/lib/components/Button/DisabledReason.js.map +1 -1
- package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.cjs +1 -0
- package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.cjs.map +1 -1
- package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.js +1 -0
- package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.js.map +1 -1
- package/lib/components/Dialog/ControlledActionDialog/ActionDialogContentInner.cjs +9 -13
- package/lib/components/Dialog/ControlledActionDialog/ActionDialogContentInner.cjs.map +1 -1
- package/lib/components/Dialog/ControlledActionDialog/ActionDialogContentInner.d.ts +19 -11
- package/lib/components/Dialog/ControlledActionDialog/ActionDialogContentInner.js +9 -13
- package/lib/components/Dialog/ControlledActionDialog/ActionDialogContentInner.js.map +1 -1
- package/lib/components/Dialog/ControlledActionDialog/ControlledActionDialog.cjs +6 -2
- package/lib/components/Dialog/ControlledActionDialog/ControlledActionDialog.cjs.map +1 -1
- package/lib/components/Dialog/ControlledActionDialog/ControlledActionDialog.d.ts +5 -1
- package/lib/components/Dialog/ControlledActionDialog/ControlledActionDialog.js +6 -2
- package/lib/components/Dialog/ControlledActionDialog/ControlledActionDialog.js.map +1 -1
- package/lib/components/Dialog/ControlledFormDialog/ControlledFormDialog.cjs +6 -2
- package/lib/components/Dialog/ControlledFormDialog/ControlledFormDialog.cjs.map +1 -1
- package/lib/components/Dialog/ControlledFormDialog/ControlledFormDialog.d.ts +5 -1
- package/lib/components/Dialog/ControlledFormDialog/ControlledFormDialog.js +6 -2
- package/lib/components/Dialog/ControlledFormDialog/ControlledFormDialog.js.map +1 -1
- package/lib/components/Dialog/ControlledFormDialog/FormDialogContentInner.cjs +8 -12
- package/lib/components/Dialog/ControlledFormDialog/FormDialogContentInner.cjs.map +1 -1
- package/lib/components/Dialog/ControlledFormDialog/FormDialogContentInner.d.ts +19 -11
- package/lib/components/Dialog/ControlledFormDialog/FormDialogContentInner.js +8 -12
- package/lib/components/Dialog/ControlledFormDialog/FormDialogContentInner.js.map +1 -1
- package/lib/components/Dialog/ControlledMessageDialog/ControlledMessageDialog.cjs +2 -2
- package/lib/components/Dialog/ControlledMessageDialog/ControlledMessageDialog.cjs.map +1 -1
- package/lib/components/Dialog/ControlledMessageDialog/ControlledMessageDialog.js +2 -2
- package/lib/components/Dialog/ControlledMessageDialog/ControlledMessageDialog.js.map +1 -1
- package/lib/components/Dialog/ControlledMessageDialog/MessageDialogContentInner.cjs +7 -11
- package/lib/components/Dialog/ControlledMessageDialog/MessageDialogContentInner.cjs.map +1 -1
- package/lib/components/Dialog/ControlledMessageDialog/MessageDialogContentInner.d.ts +2 -3
- package/lib/components/Dialog/ControlledMessageDialog/MessageDialogContentInner.js +7 -11
- package/lib/components/Dialog/ControlledMessageDialog/MessageDialogContentInner.js.map +1 -1
- package/lib/components/Dialog/index.cjs +10 -10
- package/lib/components/Dialog/index.d.ts +1 -1
- package/lib/components/Dialog/index.js +5 -5
- package/lib/components/DropZone/DropZone.cjs +2 -3
- package/lib/components/DropZone/DropZone.cjs.map +1 -1
- package/lib/components/DropZone/DropZone.js +2 -3
- package/lib/components/DropZone/DropZone.js.map +1 -1
- package/lib/components/Dropdown/DropdownTrigger.cjs +1 -0
- package/lib/components/Dropdown/DropdownTrigger.cjs.map +1 -1
- package/lib/components/Dropdown/DropdownTrigger.js +1 -0
- package/lib/components/Dropdown/DropdownTrigger.js.map +1 -1
- package/lib/components/Header/AppLauncher/AppLauncher.cjs +7 -10
- package/lib/components/Header/AppLauncher/AppLauncher.cjs.map +1 -1
- package/lib/components/Header/AppLauncher/AppLauncher.d.ts +2 -4
- package/lib/components/Header/AppLauncher/AppLauncher.js +7 -10
- package/lib/components/Header/AppLauncher/AppLauncher.js.map +1 -1
- package/lib/components/Header/Header.cjs +1 -9
- package/lib/components/Header/Header.cjs.map +1 -1
- package/lib/components/Header/Header.js +1 -9
- package/lib/components/Header/Header.js.map +1 -1
- package/lib/components/Header/LanguageSwitcher/LanguageSwitcher.cjs +5 -14
- package/lib/components/Header/LanguageSwitcher/LanguageSwitcher.cjs.map +1 -1
- package/lib/components/Header/LanguageSwitcher/LanguageSwitcher.d.ts +0 -7
- package/lib/components/Header/LanguageSwitcher/LanguageSwitcher.js +5 -14
- package/lib/components/Header/LanguageSwitcher/LanguageSwitcher.js.map +1 -1
- package/lib/components/Input/InputWithTooltip/InputWithTooltip.cjs +1 -0
- package/lib/components/Input/InputWithTooltip/InputWithTooltip.cjs.map +1 -1
- package/lib/components/Input/InputWithTooltip/InputWithTooltip.js +1 -0
- package/lib/components/Input/InputWithTooltip/InputWithTooltip.js.map +1 -1
- package/lib/components/InputFile/InputFileMultiplyAppendable.cjs +5 -9
- package/lib/components/InputFile/InputFileMultiplyAppendable.cjs.map +1 -1
- package/lib/components/InputFile/InputFileMultiplyAppendable.js +5 -9
- package/lib/components/InputFile/InputFileMultiplyAppendable.js.map +1 -1
- package/lib/components/InputFile/InputFileNative.cjs +5 -9
- package/lib/components/InputFile/InputFileNative.cjs.map +1 -1
- package/lib/components/InputFile/InputFileNative.js +5 -9
- package/lib/components/InputFile/InputFileNative.js.map +1 -1
- package/lib/components/InputFile/types.d.ts +0 -4
- package/lib/components/LineClamp/LineClamp.cjs +1 -0
- package/lib/components/LineClamp/LineClamp.cjs.map +1 -1
- package/lib/components/LineClamp/LineClamp.js +1 -0
- package/lib/components/LineClamp/LineClamp.js.map +1 -1
- package/lib/components/SegmentedControl/SegmentedControl.cjs +12 -3
- package/lib/components/SegmentedControl/SegmentedControl.cjs.map +1 -1
- package/lib/components/SegmentedControl/SegmentedControl.js +12 -3
- package/lib/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/lib/components/SideNav/SideNav.cjs +1 -1
- package/lib/components/SideNav/SideNav.cjs.map +1 -1
- package/lib/components/SideNav/SideNav.js +1 -1
- package/lib/components/SideNav/SideNav.js.map +1 -1
- package/lib/components/SideNav/SideNavItemButton.cjs +11 -2
- package/lib/components/SideNav/SideNavItemButton.cjs.map +1 -1
- package/lib/components/SideNav/SideNavItemButton.js +11 -2
- package/lib/components/SideNav/SideNavItemButton.js.map +1 -1
- package/lib/components/TabBar/TabItem.cjs +1 -0
- package/lib/components/TabBar/TabItem.cjs.map +1 -1
- package/lib/components/TabBar/TabItem.js +1 -0
- package/lib/components/TabBar/TabItem.js.map +1 -1
- package/lib/components/Table/ThCheckbox.cjs +3 -2
- package/lib/components/Table/ThCheckbox.cjs.map +1 -1
- package/lib/components/Table/ThCheckbox.js +3 -2
- package/lib/components/Table/ThCheckbox.js.map +1 -1
- package/lib/components/{Balloon/Balloon.cjs → Tooltip/ControlledTooltip.cjs} +3 -3
- package/lib/components/Tooltip/ControlledTooltip.cjs.map +1 -0
- package/lib/components/{Balloon/Balloon.d.ts → Tooltip/ControlledTooltip.d.ts} +1 -1
- package/lib/components/{Balloon/Balloon.js → Tooltip/ControlledTooltip.js} +3 -3
- package/lib/components/Tooltip/ControlledTooltip.js.map +1 -0
- package/lib/components/Tooltip/TooltipPortal.cjs +2 -2
- package/lib/components/Tooltip/TooltipPortal.cjs.map +1 -1
- package/lib/components/Tooltip/TooltipPortal.js +2 -2
- package/lib/components/Tooltip/TooltipPortal.js.map +1 -1
- package/lib/components/Tooltip/index.cjs +2 -0
- package/lib/components/Tooltip/index.cjs.map +1 -1
- package/lib/components/Tooltip/index.d.ts +1 -0
- package/lib/components/Tooltip/index.js +1 -0
- package/lib/components/Tooltip/index.js.map +1 -1
- package/lib/index.cjs +16 -14
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +7 -2
- package/lib/index.js +8 -8
- package/lib/intl/index.cjs +1 -0
- package/lib/intl/index.cjs.map +1 -1
- package/lib/intl/index.d.ts +1 -1
- package/lib/intl/index.js +1 -1
- package/lib/intl/localeMap.cjs +1 -1
- package/lib/intl/localeMap.cjs.map +1 -1
- package/lib/intl/localeMap.js +1 -1
- package/lib/intl/localeMap.js.map +1 -1
- package/lib/intl/locales/en_us.cjs +17 -17
- package/lib/intl/locales/en_us.cjs.map +1 -1
- package/lib/intl/locales/en_us.d.ts +17 -17
- package/lib/intl/locales/en_us.js +17 -17
- package/lib/intl/locales/en_us.js.map +1 -1
- package/lib/intl/locales/index.d.ts +52 -52
- package/lib/intl/locales/ja_easy.cjs +8 -8
- package/lib/intl/locales/ja_easy.cjs.map +1 -1
- package/lib/intl/locales/ja_easy.d.ts +8 -8
- package/lib/intl/locales/ja_easy.js +8 -8
- package/lib/intl/locales/ja_easy.js.map +1 -1
- package/lib/intl/locales/ko_kr.cjs +4 -4
- package/lib/intl/locales/ko_kr.cjs.map +1 -1
- package/lib/intl/locales/ko_kr.d.ts +4 -4
- package/lib/intl/locales/ko_kr.js +4 -4
- package/lib/intl/locales/ko_kr.js.map +1 -1
- package/lib/intl/locales/vi_vn.cjs +15 -15
- package/lib/intl/locales/vi_vn.cjs.map +1 -1
- package/lib/intl/locales/vi_vn.d.ts +15 -15
- package/lib/intl/locales/vi_vn.js +15 -15
- package/lib/intl/locales/vi_vn.js.map +1 -1
- package/lib/intl/locales/zh_hans_cn.cjs +4 -4
- package/lib/intl/locales/zh_hans_cn.cjs.map +1 -1
- package/lib/intl/locales/zh_hans_cn.d.ts +4 -4
- package/lib/intl/locales/zh_hans_cn.js +4 -4
- package/lib/intl/locales/zh_hans_cn.js.map +1 -1
- package/lib/intl/locales/zh_hant_tw.cjs +4 -4
- package/lib/intl/locales/zh_hant_tw.cjs.map +1 -1
- package/lib/intl/locales/zh_hant_tw.d.ts +4 -4
- package/lib/intl/locales/zh_hant_tw.js +4 -4
- package/lib/intl/locales/zh_hant_tw.js.map +1 -1
- package/metadata.json +1 -1
- package/package.json +6 -6
- package/smarthr-ui.css +151 -10
- package/lib/components/Balloon/Balloon.cjs.map +0 -1
- package/lib/components/Balloon/Balloon.js.map +0 -1
- package/lib/components/Balloon/index.cjs +0 -8
- package/lib/components/Balloon/index.cjs.map +0 -1
- package/lib/components/Balloon/index.d.ts +0 -1
- package/lib/components/Balloon/index.js +0 -2
- package/lib/components/Balloon/index.js.map +0 -1
|
@@ -14,8 +14,6 @@ require('../../../Button/UnstyledButton.cjs');
|
|
|
14
14
|
require('../../../Dialog/DialogContentInner.cjs');
|
|
15
15
|
require('react-dom');
|
|
16
16
|
require('../../../Dialog/ControlledMessageDialog/MessageDialogContentInner.cjs');
|
|
17
|
-
require('../../../Dialog/ControlledActionDialog/ActionDialogContentInner.cjs');
|
|
18
|
-
require('../../../Dialog/ControlledFormDialog/FormDialogContentInner.cjs');
|
|
19
17
|
require('../../../Layout/Stack/Stack.cjs');
|
|
20
18
|
var components_Layout_Cluster_Cluster = require('../../../Layout/Cluster/Cluster.cjs');
|
|
21
19
|
require('../../../Layout/Reel/Reel.cjs');
|
|
@@ -30,6 +28,8 @@ require('../../../Dialog/DialogContentResponseStatusMessage.cjs');
|
|
|
30
28
|
require('../../../Dialog/DialogHeading.cjs');
|
|
31
29
|
require('../../../Dialog/dialogInnerStyle.cjs');
|
|
32
30
|
require('../../../Dialog/ControlledStepFormDialog/StepFormDialogProvider.cjs');
|
|
31
|
+
require('../../../Dialog/ControlledFormDialog/FormDialogContentInner.cjs');
|
|
32
|
+
require('../../../Dialog/ControlledActionDialog/ActionDialogContentInner.cjs');
|
|
33
33
|
require('../../../Dialog/DialogWrapper.cjs');
|
|
34
34
|
require('../../../Dialog/DialogContent.cjs');
|
|
35
35
|
require('../../../Dialog/ModelessDialog/ModelessDialog.cjs');
|
|
@@ -12,8 +12,6 @@ import '../../../Button/UnstyledButton.js';
|
|
|
12
12
|
import '../../../Dialog/DialogContentInner.js';
|
|
13
13
|
import 'react-dom';
|
|
14
14
|
import '../../../Dialog/ControlledMessageDialog/MessageDialogContentInner.js';
|
|
15
|
-
import '../../../Dialog/ControlledActionDialog/ActionDialogContentInner.js';
|
|
16
|
-
import '../../../Dialog/ControlledFormDialog/FormDialogContentInner.js';
|
|
17
15
|
import '../../../Layout/Stack/Stack.js';
|
|
18
16
|
import { Cluster } from '../../../Layout/Cluster/Cluster.js';
|
|
19
17
|
import '../../../Layout/Reel/Reel.js';
|
|
@@ -28,6 +26,8 @@ import '../../../Dialog/DialogContentResponseStatusMessage.js';
|
|
|
28
26
|
import '../../../Dialog/DialogHeading.js';
|
|
29
27
|
import '../../../Dialog/dialogInnerStyle.js';
|
|
30
28
|
import '../../../Dialog/ControlledStepFormDialog/StepFormDialogProvider.js';
|
|
29
|
+
import '../../../Dialog/ControlledFormDialog/FormDialogContentInner.js';
|
|
30
|
+
import '../../../Dialog/ControlledActionDialog/ActionDialogContentInner.js';
|
|
31
31
|
import '../../../Dialog/DialogWrapper.js';
|
|
32
32
|
import '../../../Dialog/DialogContent.js';
|
|
33
33
|
import '../../../Dialog/ModelessDialog/ModelessDialog.js';
|
|
@@ -15,8 +15,6 @@ var components_Dialog_Dialog = require('../../../Dialog/Dialog.cjs');
|
|
|
15
15
|
require('../../../Dialog/DialogContentInner.cjs');
|
|
16
16
|
require('react-dom');
|
|
17
17
|
require('../../../Dialog/ControlledMessageDialog/MessageDialogContentInner.cjs');
|
|
18
|
-
require('../../../Dialog/ControlledActionDialog/ActionDialogContentInner.cjs');
|
|
19
|
-
require('../../../Dialog/ControlledFormDialog/FormDialogContentInner.cjs');
|
|
20
18
|
require('../../../Layout/Stack/Stack.cjs');
|
|
21
19
|
require('../../../Layout/Cluster/Cluster.cjs');
|
|
22
20
|
require('../../../Layout/Reel/Reel.cjs');
|
|
@@ -31,6 +29,8 @@ require('../../../Dialog/DialogContentResponseStatusMessage.cjs');
|
|
|
31
29
|
require('../../../Dialog/DialogHeading.cjs');
|
|
32
30
|
require('../../../Dialog/dialogInnerStyle.cjs');
|
|
33
31
|
require('../../../Dialog/ControlledStepFormDialog/StepFormDialogProvider.cjs');
|
|
32
|
+
require('../../../Dialog/ControlledFormDialog/FormDialogContentInner.cjs');
|
|
33
|
+
require('../../../Dialog/ControlledActionDialog/ActionDialogContentInner.cjs');
|
|
34
34
|
require('../../../Dialog/DialogWrapper.cjs');
|
|
35
35
|
require('../../../Dialog/DialogContent.cjs');
|
|
36
36
|
require('../../../Dialog/ModelessDialog/ModelessDialog.cjs');
|
|
@@ -13,8 +13,6 @@ import { Dialog } from '../../../Dialog/Dialog.js';
|
|
|
13
13
|
import '../../../Dialog/DialogContentInner.js';
|
|
14
14
|
import 'react-dom';
|
|
15
15
|
import '../../../Dialog/ControlledMessageDialog/MessageDialogContentInner.js';
|
|
16
|
-
import '../../../Dialog/ControlledActionDialog/ActionDialogContentInner.js';
|
|
17
|
-
import '../../../Dialog/ControlledFormDialog/FormDialogContentInner.js';
|
|
18
16
|
import '../../../Layout/Stack/Stack.js';
|
|
19
17
|
import '../../../Layout/Cluster/Cluster.js';
|
|
20
18
|
import '../../../Layout/Reel/Reel.js';
|
|
@@ -29,6 +27,8 @@ import '../../../Dialog/DialogContentResponseStatusMessage.js';
|
|
|
29
27
|
import '../../../Dialog/DialogHeading.js';
|
|
30
28
|
import '../../../Dialog/dialogInnerStyle.js';
|
|
31
29
|
import '../../../Dialog/ControlledStepFormDialog/StepFormDialogProvider.js';
|
|
30
|
+
import '../../../Dialog/ControlledFormDialog/FormDialogContentInner.js';
|
|
31
|
+
import '../../../Dialog/ControlledActionDialog/ActionDialogContentInner.js';
|
|
32
32
|
import '../../../Dialog/DialogWrapper.js';
|
|
33
33
|
import '../../../Dialog/DialogContent.js';
|
|
34
34
|
import '../../../Dialog/ModelessDialog/ModelessDialog.js';
|
|
@@ -6,6 +6,7 @@ var index = require('./../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.
|
|
|
6
6
|
var components_Icon_FaIcon = require('../Icon/FaIcon.cjs');
|
|
7
7
|
require('../Icon/generateIcon.cjs');
|
|
8
8
|
require('../Icon/OpenInNewTabIcon.cjs');
|
|
9
|
+
require('../Tooltip/ControlledTooltip.cjs');
|
|
9
10
|
var components_Tooltip_Tooltip = require('../Tooltip/Tooltip.cjs');
|
|
10
11
|
|
|
11
12
|
const classNameGenerator = index.tv({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisabledReason.cjs","sources":["../../../src/components/Button/DisabledReason.tsx"],"sourcesContent":["import { type FC, type FunctionComponent, type JSX, type ReactNode, memo, useMemo } from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { FaCircleInfoIcon } from '../Icon'\nimport { Tooltip } from '../Tooltip'\n\ntype Props = {\n button: JSX.Element\n disabledReason: {\n icon?: FunctionComponent\n message: ReactNode\n }\n}\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: ['smarthr-ui-Button-disabledWrapper', 'shr-inline-flex shr-items-center shr-gap-0.25'],\n tooltip: [\n 'shr-overflow-y-visible',\n /* Tooltip との距離を変えずに反応範囲を広げるために negative space を使う */\n '[&_.smarthr-ui-Icon]:-shr-m-0.25',\n '[&_.smarthr-ui-Icon]:shr-box-content',\n '[&_.smarthr-ui-Icon]:shr-p-0.25',\n '[&_.smarthr-ui-Icon]:shr-text-grey',\n ],\n },\n})\n\nexport const DisabledReason: FC<Props> = ({ button, disabledReason }) => {\n const classNames = useMemo(() => {\n const { wrapper, tooltip } = classNameGenerator()\n\n return {\n wrapper: wrapper(),\n tooltip: tooltip(),\n }\n }, [])\n\n return (\n <div className={classNames.wrapper}>\n {button}\n <TooltipIcon\n icon={disabledReason.icon}\n message={disabledReason.message}\n className={classNames.tooltip}\n />\n </div>\n )\n}\n\nconst TooltipIcon = memo<{\n icon?: FunctionComponent\n message: ReactNode\n className: string\n}>(({ icon, message, className }) => {\n const DisabledReasonIcon = icon ?? FaCircleInfoIcon\n\n return (\n <Tooltip message={message} triggerType=\"icon\" className={className}>\n <DisabledReasonIcon />\n </Tooltip>\n )\n})\n"],"names":["tv","useMemo","_jsxs","_jsx","memo","FaCircleInfoIcon","Tooltip"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DisabledReason.cjs","sources":["../../../src/components/Button/DisabledReason.tsx"],"sourcesContent":["import { type FC, type FunctionComponent, type JSX, type ReactNode, memo, useMemo } from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { FaCircleInfoIcon } from '../Icon'\nimport { Tooltip } from '../Tooltip'\n\ntype Props = {\n button: JSX.Element\n disabledReason: {\n icon?: FunctionComponent\n message: ReactNode\n }\n}\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: ['smarthr-ui-Button-disabledWrapper', 'shr-inline-flex shr-items-center shr-gap-0.25'],\n tooltip: [\n 'shr-overflow-y-visible',\n /* Tooltip との距離を変えずに反応範囲を広げるために negative space を使う */\n '[&_.smarthr-ui-Icon]:-shr-m-0.25',\n '[&_.smarthr-ui-Icon]:shr-box-content',\n '[&_.smarthr-ui-Icon]:shr-p-0.25',\n '[&_.smarthr-ui-Icon]:shr-text-grey',\n ],\n },\n})\n\nexport const DisabledReason: FC<Props> = ({ button, disabledReason }) => {\n const classNames = useMemo(() => {\n const { wrapper, tooltip } = classNameGenerator()\n\n return {\n wrapper: wrapper(),\n tooltip: tooltip(),\n }\n }, [])\n\n return (\n <div className={classNames.wrapper}>\n {button}\n <TooltipIcon\n icon={disabledReason.icon}\n message={disabledReason.message}\n className={classNames.tooltip}\n />\n </div>\n )\n}\n\nconst TooltipIcon = memo<{\n icon?: FunctionComponent\n message: ReactNode\n className: string\n}>(({ icon, message, className }) => {\n const DisabledReasonIcon = icon ?? FaCircleInfoIcon\n\n return (\n <Tooltip message={message} triggerType=\"icon\" className={className}>\n <DisabledReasonIcon />\n </Tooltip>\n )\n})\n"],"names":["tv","useMem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
|
@@ -4,6 +4,7 @@ import { tv as ce } from './../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindc
|
|
|
4
4
|
import { FaCircleInfoIcon } from '../Icon/FaIcon.js';
|
|
5
5
|
import '../Icon/generateIcon.js';
|
|
6
6
|
import '../Icon/OpenInNewTabIcon.js';
|
|
7
|
+
import '../Tooltip/ControlledTooltip.js';
|
|
7
8
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
8
9
|
|
|
9
10
|
const classNameGenerator = ce({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisabledReason.js","sources":["../../../src/components/Button/DisabledReason.tsx"],"sourcesContent":["import { type FC, type FunctionComponent, type JSX, type ReactNode, memo, useMemo } from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { FaCircleInfoIcon } from '../Icon'\nimport { Tooltip } from '../Tooltip'\n\ntype Props = {\n button: JSX.Element\n disabledReason: {\n icon?: FunctionComponent\n message: ReactNode\n }\n}\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: ['smarthr-ui-Button-disabledWrapper', 'shr-inline-flex shr-items-center shr-gap-0.25'],\n tooltip: [\n 'shr-overflow-y-visible',\n /* Tooltip との距離を変えずに反応範囲を広げるために negative space を使う */\n '[&_.smarthr-ui-Icon]:-shr-m-0.25',\n '[&_.smarthr-ui-Icon]:shr-box-content',\n '[&_.smarthr-ui-Icon]:shr-p-0.25',\n '[&_.smarthr-ui-Icon]:shr-text-grey',\n ],\n },\n})\n\nexport const DisabledReason: FC<Props> = ({ button, disabledReason }) => {\n const classNames = useMemo(() => {\n const { wrapper, tooltip } = classNameGenerator()\n\n return {\n wrapper: wrapper(),\n tooltip: tooltip(),\n }\n }, [])\n\n return (\n <div className={classNames.wrapper}>\n {button}\n <TooltipIcon\n icon={disabledReason.icon}\n message={disabledReason.message}\n className={classNames.tooltip}\n />\n </div>\n )\n}\n\nconst TooltipIcon = memo<{\n icon?: FunctionComponent\n message: ReactNode\n className: string\n}>(({ icon, message, className }) => {\n const DisabledReasonIcon = icon ?? FaCircleInfoIcon\n\n return (\n <Tooltip message={message} triggerType=\"icon\" className={className}>\n <DisabledReasonIcon />\n </Tooltip>\n )\n})\n"],"names":["tv","_jsxs","_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DisabledReason.js","sources":["../../../src/components/Button/DisabledReason.tsx"],"sourcesContent":["import { type FC, type FunctionComponent, type JSX, type ReactNode, memo, useMemo } from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { FaCircleInfoIcon } from '../Icon'\nimport { Tooltip } from '../Tooltip'\n\ntype Props = {\n button: JSX.Element\n disabledReason: {\n icon?: FunctionComponent\n message: ReactNode\n }\n}\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: ['smarthr-ui-Button-disabledWrapper', 'shr-inline-flex shr-items-center shr-gap-0.25'],\n tooltip: [\n 'shr-overflow-y-visible',\n /* Tooltip との距離を変えずに反応範囲を広げるために negative space を使う */\n '[&_.smarthr-ui-Icon]:-shr-m-0.25',\n '[&_.smarthr-ui-Icon]:shr-box-content',\n '[&_.smarthr-ui-Icon]:shr-p-0.25',\n '[&_.smarthr-ui-Icon]:shr-text-grey',\n ],\n },\n})\n\nexport const DisabledReason: FC<Props> = ({ button, disabledReason }) => {\n const classNames = useMemo(() => {\n const { wrapper, tooltip } = classNameGenerator()\n\n return {\n wrapper: wrapper(),\n tooltip: tooltip(),\n }\n }, [])\n\n return (\n <div className={classNames.wrapper}>\n {button}\n <TooltipIcon\n icon={disabledReason.icon}\n message={disabledReason.message}\n className={classNames.tooltip}\n />\n </div>\n )\n}\n\nconst TooltipIcon = memo<{\n icon?: FunctionComponent\n message: ReactNode\n className: string\n}>(({ icon, message, className }) => {\n const DisabledReasonIcon = icon ?? FaCircleInfoIcon\n\n return (\n <Tooltip message={message} triggerType=\"icon\" className={className}>\n <DisabledReasonIcon />\n </Tooltip>\n )\n})\n"],"names":["tv","_jsxs","_jsx"],"mappings":";;;;;;;;;AAcA,MAAM,kB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aIcon = require('../../Icon/FaIcon.cjs');
|
|
16
16
|
require('../../Icon/generateIcon.cjs');
|
|
17
17
|
require('../../Icon/OpenInNewTabIcon.cjs');
|
|
18
|
+
require('../../Tooltip/ControlledTooltip.cjs');
|
|
18
19
|
var components_Tooltip_Tooltip = require('../../Tooltip/Tooltip.cjs');
|
|
19
20
|
var components_VisuallyHiddenText_VisuallyHiddenText = require('../../VisuallyHiddenText/VisuallyHiddenText.cjs');
|
|
20
21
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelectedItem.cjs","sources":["../../../../src/components/Combobox/MultiCombobox/MultiSelectedItem.tsx"],"sourcesContent":["import {\n type KeyboardEvent,\n type PropsWithChildren,\n type RefObject,\n memo,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { useIntl } from '../../../intl'\nimport { UnstyledButton } from '../../Button'\nimport { Chip } from '../../Chip'\nimport { FaCircleXmarkIcon } from '../../Icon'\nimport { Tooltip } from '../../Tooltip'\nimport { VisuallyHiddenText } from '../../VisuallyHiddenText'\n\nimport type { ComboboxItem } from '../types'\n\nexport type Props<T> = {\n item: ComboboxItem<T> & { deletable?: boolean }\n disabled: boolean\n onDelete: (item: ComboboxItem<T>) => void\n enableEllipsis?: boolean\n buttonRef: RefObject<HTMLButtonElement>\n}\n\nconst classNameGenerator = tv({\n slots: {\n wrapper:\n 'smarthr-ui-MultiCombobox-selectedItem shr-flex shr-items-center shr-gap-0.75 shr-leading-normal [&]:shr-rounded-em',\n itemLabel: 'smarthr-ui-MultiCombobox-selectedItemLabel',\n deleteButton: [\n 'smarthr-ui-MultiCombobox-deleteButton',\n 'shr-relative',\n 'shr-group/deleteButton',\n 'shr-shrink shr-rounded-full shr-leading-[0] shr-text-black',\n 'focus-visible:shr-outline-none',\n ],\n deleteButtonIcon:\n 'group-focus-visible/deleteButton:shr-focus-indicator--outer group-focus-visible/deleteButton:shr-rounded-full',\n },\n variants: {\n enableEllipsis: {\n true: {\n itemLabel: 'shr-overflow-hidden shr-overflow-ellipsis shr-whitespace-nowrap',\n },\n },\n disabled: {\n true: {\n deleteButton: 'shr-cursor-not-allowed',\n },\n false: {},\n },\n },\n})\n\nexport function MultiSelectedItem<T>({\n item,\n disabled,\n onDelete,\n enableEllipsis,\n buttonRef,\n}: Props<T>) {\n const [needsTooltip, setNeedsTooltip] = useState(false)\n const { deletable = true } = item\n const idPrefix = useId()\n const labelId = `${idPrefix}-item-label`\n const destroySuffixTextId = `${idPrefix}-item-destroy-button-suffix`\n\n const classNames = useMemo(() => {\n const { wrapper, itemLabel, deleteButton, deleteButtonIcon } = classNameGenerator()\n\n return {\n wrapper: wrapper(),\n itemLabel: itemLabel({ enableEllipsis }),\n deleteButton: deleteButton({ disabled }),\n deleteButtonIcon: deleteButtonIcon(),\n }\n }, [disabled, enableEllipsis])\n\n const body = (\n <Chip disabled={disabled} className={classNames.wrapper}>\n <ItemLabel id={labelId} className={classNames.itemLabel} setNeedsTooltip={setNeedsTooltip}>\n {item.label}\n </ItemLabel>\n\n {deletable && (\n <DestroyButton\n labelId={labelId}\n suffixTextId={destroySuffixTextId}\n item={item}\n onDelete={onDelete}\n disabled={disabled}\n buttonRef={buttonRef}\n className={classNames.deleteButton}\n iconStyle={classNames.deleteButtonIcon}\n />\n )}\n </Chip>\n )\n\n if (needsTooltip) {\n return <Tooltip message={item.label}>{body}</Tooltip>\n }\n\n return body\n}\n\nconst ItemLabel = memo<\n PropsWithChildren<{\n id: string\n enableEllipsis?: boolean\n setNeedsTooltip: (flg: boolean) => void\n className: string\n }>\n>(({ children, id, enableEllipsis, setNeedsTooltip, className }) => {\n const labelRef = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (enableEllipsis && labelRef.current) {\n const elem = labelRef.current\n\n setNeedsTooltip(elem.offsetWidth < elem.scrollWidth)\n }\n }, [enableEllipsis, setNeedsTooltip])\n\n return (\n <span ref={labelRef} id={id} className={className}>\n {children}\n </span>\n )\n})\n\nconst typedMemo: <T>(c: T) => T = memo\nconst EXEC_DESTROY_KEY = /^(Enter|Backspace| )$/\n\nconst BaseDestroyButton = <T,>({\n labelId,\n suffixTextId,\n item,\n onDelete,\n disabled,\n buttonRef,\n className,\n iconStyle,\n}: Pick<Props<T>, 'item' | 'onDelete' | 'disabled' | 'buttonRef'> & {\n labelId: string\n suffixTextId: string\n className: string\n iconStyle: string\n}) => {\n const { localize } = useIntl()\n const onClick = useCallback(() => {\n onDelete(item)\n }, [item, onDelete])\n const onKeyDown = useCallback(\n (e: KeyboardEvent<HTMLButtonElement>) => {\n if (EXEC_DESTROY_KEY.test(e.key)) {\n e.stopPropagation()\n\n // HINT: イベントの伝播が止まる関係でonClickに設定したonDeleteは実行されない\n // このタイミングで明示的に削除処理を実行する\n onClick()\n }\n },\n [onClick],\n )\n\n const destroyButtonIconAltSuffix = useMemo(\n () =>\n localize({\n id: 'smarthr-ui/MultiCombobox/destroyButtonIconAltSuffix',\n defaultText: 'を削除',\n }),\n [localize],\n )\n\n return (\n <UnstyledButton\n ref={buttonRef}\n disabled={disabled}\n tabIndex={-1}\n aria-labelledby={`${labelId} ${suffixTextId}`}\n onClick={onClick}\n onKeyDown={onKeyDown}\n className={className}\n >\n <VisuallyHiddenText id={suffixTextId}>{destroyButtonIconAltSuffix}</VisuallyHiddenText>\n <FaCircleXmarkIcon color={disabled ? 'TEXT_DISABLED' : 'inherit'} className={iconStyle} />\n </UnstyledButton>\n )\n}\nconst DestroyButton = typedMemo(BaseDestroyButton)\n"],"names":["tv","useState","useId","useMemo","_jsxs","Chip","_jsx","Tooltip","memo","useRef","useEffect","useIntl","useCallback","UnstyledButton","VisuallyHiddenText","FaCircleXmarkIcon"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MultiSelectedItem.cjs","sources":["../../../../src/components/Combobox/MultiCombobox/MultiSelectedItem.tsx"],"sourcesContent":["import {\n type KeyboardEvent,\n type PropsWithChildren,\n type RefObject,\n memo,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { useIntl } from '../../../intl'\nimport { UnstyledButton } from '../../Button'\nimport { Chip } from '../../Chip'\nimport { FaCircleXmarkIcon } from '../../Icon'\nimport { Tooltip } from '../../Tooltip'\nimport { VisuallyHiddenText } from '../../VisuallyHiddenText'\n\nimport type { ComboboxItem } from '../types'\n\nexport type Props<T> = {\n item: ComboboxItem<T> & { deletable?: boolean }\n disabled: boolean\n onDelete: (item: ComboboxItem<T>) => void\n enableEllipsis?: boolean\n buttonRef: RefObject<HTMLButtonElement>\n}\n\nconst classNameGenerator = tv({\n slots: {\n wrapper:\n 'smarthr-ui-MultiCombobox-selectedItem shr-flex shr-items-center shr-gap-0.75 shr-leading-normal [&]:shr-rounded-em',\n itemLabel: 'smarthr-ui-MultiCombobox-selectedItemLabel',\n deleteButton: [\n 'smarthr-ui-MultiCombobox-deleteButton',\n 'shr-relative',\n 'shr-group/deleteButton',\n 'shr-shrink shr-rounded-full shr-leading-[0] shr-text-black',\n 'focus-visible:shr-outline-none',\n ],\n deleteButtonIcon:\n 'group-focus-visible/deleteButton:shr-focus-indicator--outer group-focus-visible/deleteButton:shr-rounded-full',\n },\n variants: {\n enableEllipsis: {\n true: {\n itemLabel: 'shr-overflow-hidden shr-overflow-ellipsis shr-whitespace-nowrap',\n },\n },\n disabled: {\n true: {\n deleteButton: 'shr-cursor-not-allowed',\n },\n false: {},\n },\n },\n})\n\nexport function MultiSelectedItem<T>({\n item,\n disabled,\n onDelete,\n enableEllipsis,\n buttonRef,\n}: Props<T>) {\n const [needsTooltip, setNeedsTooltip] = useState(false)\n const { deletable = true } = item\n const idPrefix = useId()\n const labelId = `${idPrefix}-item-label`\n const destroySuffixTextId = `${idPrefix}-item-destroy-button-suffix`\n\n const classNames = useMemo(() => {\n const { wrapper, itemLabel, deleteButton, deleteButtonIcon } = classNameGenerator()\n\n return {\n wrapper: wrapper(),\n itemLabel: itemLabel({ enableEllipsis }),\n deleteButton: deleteButton({ disabled }),\n deleteButtonIcon: deleteButtonIcon(),\n }\n }, [disabled, enableEllipsis])\n\n const body = (\n <Chip disabled={disabled} className={classNames.wrapper}>\n <ItemLabel id={labelId} className={classNames.itemLabel} setNeedsTooltip={setNeedsTooltip}>\n {item.label}\n </ItemLabel>\n\n {deletable && (\n <DestroyButton\n labelId={labelId}\n suffixTextId={destroySuffixTextId}\n item={item}\n onDelete={onDelete}\n disabled={disabled}\n buttonRef={buttonRef}\n className={classNames.deleteButton}\n iconStyle={classNames.deleteButtonIcon}\n />\n )}\n </Chip>\n )\n\n if (needsTooltip) {\n return <Tooltip message={item.label}>{body}</Tooltip>\n }\n\n return body\n}\n\nconst ItemLabel = memo<\n PropsWithChildren<{\n id: string\n enableEllipsis?: boolean\n setNeedsTooltip: (flg: boolean) => void\n className: string\n }>\n>(({ children, id, enableEllipsis, setNeedsTooltip, className }) => {\n const labelRef = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (enableEllipsis && labelRef.current) {\n const elem = labelRef.current\n\n setNeedsTooltip(elem.offsetWidth < elem.scrollWidth)\n }\n }, [enableEllipsis, setNeedsTooltip])\n\n return (\n <span ref={labelRef} id={id} className={className}>\n {children}\n </span>\n )\n})\n\nconst typedMemo: <T>(c: T) => T = memo\nconst EXEC_DESTROY_KEY = /^(Enter|Backspace| )$/\n\nconst BaseDestroyButton = <T,>({\n labelId,\n suffixTextId,\n item,\n onDelete,\n disabled,\n buttonRef,\n className,\n iconStyle,\n}: Pick<Props<T>, 'item' | 'onDelete' | 'disabled' | 'buttonRef'> & {\n labelId: string\n suffixTextId: string\n className: string\n iconStyle: string\n}) => {\n const { localize } = useIntl()\n const onClick = useCallback(() => {\n onDelete(item)\n }, [item, onDelete])\n const onKeyDown = useCallback(\n (e: KeyboardEvent<HTMLButtonElement>) => {\n if (EXEC_DESTROY_KEY.test(e.key)) {\n e.stopPropagation()\n\n // HINT: イベントの伝播が止まる関係でonClickに設定したonDeleteは実行されない\n // このタイミングで明示的に削除処理を実行する\n onClick()\n }\n },\n [onClick],\n )\n\n const destroyButtonIconAltSuffix = useMemo(\n () =>\n localize({\n id: 'smarthr-ui/MultiCombobox/destroyButtonIconAltSuffix',\n defaultText: 'を削除',\n }),\n [localize],\n )\n\n return (\n <UnstyledButton\n ref={buttonRef}\n disabled={disabled}\n tabIndex={-1}\n aria-labelledby={`${labelId} ${suffixTextId}`}\n onClick={onClick}\n onKeyDown={onKeyDown}\n className={className}\n >\n <VisuallyHiddenText id={suffixTextId}>{destroyButtonIconAltSuffix}</VisuallyHiddenText>\n <FaCircleXmarkIcon color={disabled ? 'TEXT_DISABLED' : 'inherit'} className={iconStyle} />\n </UnstyledButton>\n )\n}\nconst DestroyButton = typedMemo(BaseDestroyButton)\n"],"names":["tv","useState","useId","useMemo","_jsxs","Chip","_jsx","Tooltip","memo","useRef","useEffect","useIntl","useCallback","UnstyledButton","VisuallyHiddenText","FaCircleXmarkIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,kBAAkB,GAAGA,QAAE,CAAC;AAC5B,IAAA,KAAK,EAAE;AACL,QAAA,OAAO,EACL,oHAAoH;AACtH,QAAA,SAAS,EAAE,4CAA4C;AACvD,QAAA,YAAY,EAAE;YACZ,uCAAuC;YACvC,cAAc;YACd,wBAAwB;YACxB,4DAA4D;YAC5D,gCAAgC;AACjC,SAAA;AACD,QAAA,gBAAgB,EACd,+GAA+G;AAClH,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,cAAc,EAAE;AACd,YAAA,IAAI,EAAE;AACJ,gBAAA,SAAS,EAAE,iEAAiE;AAC7E,aAAA;AACF,SAAA;AACD,QAAA,QAAQ,EAAE;AACR,YAAA,IAAI,EAAE;AACJ,gBAAA,YAAY,EAAE,wBAAwB;AACvC,aAAA;AACD,YAAA,KAAK,EAAE,EAAE;AACV,SAAA;AACF,KAAA;AACF,CAAA,CAAC;AAEI,SAAU,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AI,CAAC;AAChB,IAAA,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACpB,IAAA,MAAM,SAAS,GAAGA,iBAAW,CAC3B,CAAC,CAAmC,KAAI;QACtC,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;YAChC,CAAC,CAAC,eAAe,EAAE;;;AAInB,YAAA,OAAO,EAAE;QACX;AACF,IAAA,CAAC,EACD,CAAC,OAAO,CAAC,CACV;IAED,MAAM,0BAA0B,GAAGT,aAAO,CACxC,MACE,QAAQ,CAAC;AACP,QAAA,EAAE,EAAE,qDAAqD;AACzD,QAAA,WAAW,EAAE,KAAK;AACnB,KAAA,CAAC,EACJ,CAAC,QAAQ,CAAC,CACX;AAED,IAAA,QACEC,eAAA,CAACS,+CAAc,EAAA,EACb,GAAG,EAAE,SAAS,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,EAAE,EAAA,iBAAA,EACK,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,YAAY,EAAE,EAC7C,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EAAA,QAAA,EAAA,CAEpBP,cAAA,CAACQ,mEAAkB,EAAA,EAAC,EAAE,EAAE,YAAY,EAAA,QAAA,EAAG,0BAA0B,EAAA,CAAsB,EACvFR,cAAA,CAACS,wCAAiB,IAAC,KAAK,EAAE,QAAQ,GAAG,eAAe,GAAG,SAAS,EAAE,SAAS,EAAE,SAAS,EAAA,CAAI,CAAA,EAAA,CAC3E;AAErB,CAAC;AACD,MAAM,aAAa,GAAG,SAAS,CAAC,iBAAiB,CAAC;;;;"}
|
|
@@ -13,6 +13,7 @@ import { Chip } from '../../Chip/Chip.js';
|
|
|
13
13
|
import { FaCircleXmarkIcon } from '../../Icon/FaIcon.js';
|
|
14
14
|
import '../../Icon/generateIcon.js';
|
|
15
15
|
import '../../Icon/OpenInNewTabIcon.js';
|
|
16
|
+
import '../../Tooltip/ControlledTooltip.js';
|
|
16
17
|
import { Tooltip } from '../../Tooltip/Tooltip.js';
|
|
17
18
|
import { VisuallyHiddenText } from '../../VisuallyHiddenText/VisuallyHiddenText.js';
|
|
18
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelectedItem.js","sources":["../../../../src/components/Combobox/MultiCombobox/MultiSelectedItem.tsx"],"sourcesContent":["import {\n type KeyboardEvent,\n type PropsWithChildren,\n type RefObject,\n memo,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { useIntl } from '../../../intl'\nimport { UnstyledButton } from '../../Button'\nimport { Chip } from '../../Chip'\nimport { FaCircleXmarkIcon } from '../../Icon'\nimport { Tooltip } from '../../Tooltip'\nimport { VisuallyHiddenText } from '../../VisuallyHiddenText'\n\nimport type { ComboboxItem } from '../types'\n\nexport type Props<T> = {\n item: ComboboxItem<T> & { deletable?: boolean }\n disabled: boolean\n onDelete: (item: ComboboxItem<T>) => void\n enableEllipsis?: boolean\n buttonRef: RefObject<HTMLButtonElement>\n}\n\nconst classNameGenerator = tv({\n slots: {\n wrapper:\n 'smarthr-ui-MultiCombobox-selectedItem shr-flex shr-items-center shr-gap-0.75 shr-leading-normal [&]:shr-rounded-em',\n itemLabel: 'smarthr-ui-MultiCombobox-selectedItemLabel',\n deleteButton: [\n 'smarthr-ui-MultiCombobox-deleteButton',\n 'shr-relative',\n 'shr-group/deleteButton',\n 'shr-shrink shr-rounded-full shr-leading-[0] shr-text-black',\n 'focus-visible:shr-outline-none',\n ],\n deleteButtonIcon:\n 'group-focus-visible/deleteButton:shr-focus-indicator--outer group-focus-visible/deleteButton:shr-rounded-full',\n },\n variants: {\n enableEllipsis: {\n true: {\n itemLabel: 'shr-overflow-hidden shr-overflow-ellipsis shr-whitespace-nowrap',\n },\n },\n disabled: {\n true: {\n deleteButton: 'shr-cursor-not-allowed',\n },\n false: {},\n },\n },\n})\n\nexport function MultiSelectedItem<T>({\n item,\n disabled,\n onDelete,\n enableEllipsis,\n buttonRef,\n}: Props<T>) {\n const [needsTooltip, setNeedsTooltip] = useState(false)\n const { deletable = true } = item\n const idPrefix = useId()\n const labelId = `${idPrefix}-item-label`\n const destroySuffixTextId = `${idPrefix}-item-destroy-button-suffix`\n\n const classNames = useMemo(() => {\n const { wrapper, itemLabel, deleteButton, deleteButtonIcon } = classNameGenerator()\n\n return {\n wrapper: wrapper(),\n itemLabel: itemLabel({ enableEllipsis }),\n deleteButton: deleteButton({ disabled }),\n deleteButtonIcon: deleteButtonIcon(),\n }\n }, [disabled, enableEllipsis])\n\n const body = (\n <Chip disabled={disabled} className={classNames.wrapper}>\n <ItemLabel id={labelId} className={classNames.itemLabel} setNeedsTooltip={setNeedsTooltip}>\n {item.label}\n </ItemLabel>\n\n {deletable && (\n <DestroyButton\n labelId={labelId}\n suffixTextId={destroySuffixTextId}\n item={item}\n onDelete={onDelete}\n disabled={disabled}\n buttonRef={buttonRef}\n className={classNames.deleteButton}\n iconStyle={classNames.deleteButtonIcon}\n />\n )}\n </Chip>\n )\n\n if (needsTooltip) {\n return <Tooltip message={item.label}>{body}</Tooltip>\n }\n\n return body\n}\n\nconst ItemLabel = memo<\n PropsWithChildren<{\n id: string\n enableEllipsis?: boolean\n setNeedsTooltip: (flg: boolean) => void\n className: string\n }>\n>(({ children, id, enableEllipsis, setNeedsTooltip, className }) => {\n const labelRef = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (enableEllipsis && labelRef.current) {\n const elem = labelRef.current\n\n setNeedsTooltip(elem.offsetWidth < elem.scrollWidth)\n }\n }, [enableEllipsis, setNeedsTooltip])\n\n return (\n <span ref={labelRef} id={id} className={className}>\n {children}\n </span>\n )\n})\n\nconst typedMemo: <T>(c: T) => T = memo\nconst EXEC_DESTROY_KEY = /^(Enter|Backspace| )$/\n\nconst BaseDestroyButton = <T,>({\n labelId,\n suffixTextId,\n item,\n onDelete,\n disabled,\n buttonRef,\n className,\n iconStyle,\n}: Pick<Props<T>, 'item' | 'onDelete' | 'disabled' | 'buttonRef'> & {\n labelId: string\n suffixTextId: string\n className: string\n iconStyle: string\n}) => {\n const { localize } = useIntl()\n const onClick = useCallback(() => {\n onDelete(item)\n }, [item, onDelete])\n const onKeyDown = useCallback(\n (e: KeyboardEvent<HTMLButtonElement>) => {\n if (EXEC_DESTROY_KEY.test(e.key)) {\n e.stopPropagation()\n\n // HINT: イベントの伝播が止まる関係でonClickに設定したonDeleteは実行されない\n // このタイミングで明示的に削除処理を実行する\n onClick()\n }\n },\n [onClick],\n )\n\n const destroyButtonIconAltSuffix = useMemo(\n () =>\n localize({\n id: 'smarthr-ui/MultiCombobox/destroyButtonIconAltSuffix',\n defaultText: 'を削除',\n }),\n [localize],\n )\n\n return (\n <UnstyledButton\n ref={buttonRef}\n disabled={disabled}\n tabIndex={-1}\n aria-labelledby={`${labelId} ${suffixTextId}`}\n onClick={onClick}\n onKeyDown={onKeyDown}\n className={className}\n >\n <VisuallyHiddenText id={suffixTextId}>{destroyButtonIconAltSuffix}</VisuallyHiddenText>\n <FaCircleXmarkIcon color={disabled ? 'TEXT_DISABLED' : 'inherit'} className={iconStyle} />\n </UnstyledButton>\n )\n}\nconst DestroyButton = typedMemo(BaseDestroyButton)\n"],"names":["tv","_jsxs","_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MultiSelectedItem.js","sources":["../../../../src/components/Combobox/MultiCombobox/MultiSelectedItem.tsx"],"sourcesContent":["import {\n type KeyboardEvent,\n type PropsWithChildren,\n type RefObject,\n memo,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { useIntl } from '../../../intl'\nimport { UnstyledButton } from '../../Button'\nimport { Chip } from '../../Chip'\nimport { FaCircleXmarkIcon } from '../../Icon'\nimport { Tooltip } from '../../Tooltip'\nimport { VisuallyHiddenText } from '../../VisuallyHiddenText'\n\nimport type { ComboboxItem } from '../types'\n\nexport type Props<T> = {\n item: ComboboxItem<T> & { deletable?: boolean }\n disabled: boolean\n onDelete: (item: ComboboxItem<T>) => void\n enableEllipsis?: boolean\n buttonRef: RefObject<HTMLButtonElement>\n}\n\nconst classNameGenerator = tv({\n slots: {\n wrapper:\n 'smarthr-ui-MultiCombobox-selectedItem shr-flex shr-items-center shr-gap-0.75 shr-leading-normal [&]:shr-rounded-em',\n itemLabel: 'smarthr-ui-MultiCombobox-selectedItemLabel',\n deleteButton: [\n 'smarthr-ui-MultiCombobox-deleteButton',\n 'shr-relative',\n 'shr-group/deleteButton',\n 'shr-shrink shr-rounded-full shr-leading-[0] shr-text-black',\n 'focus-visible:shr-outline-none',\n ],\n deleteButtonIcon:\n 'group-focus-visible/deleteButton:shr-focus-indicator--outer group-focus-visible/deleteButton:shr-rounded-full',\n },\n variants: {\n enableEllipsis: {\n true: {\n itemLabel: 'shr-overflow-hidden shr-overflow-ellipsis shr-whitespace-nowrap',\n },\n },\n disabled: {\n true: {\n deleteButton: 'shr-cursor-not-allowed',\n },\n false: {},\n },\n },\n})\n\nexport function MultiSelectedItem<T>({\n item,\n disabled,\n onDelete,\n enableEllipsis,\n buttonRef,\n}: Props<T>) {\n const [needsTooltip, setNeedsTooltip] = useState(false)\n const { deletable = true } = item\n const idPrefix = useId()\n const labelId = `${idPrefix}-item-label`\n const destroySuffixTextId = `${idPrefix}-item-destroy-button-suffix`\n\n const classNames = useMemo(() => {\n const { wrapper, itemLabel, deleteButton, deleteButtonIcon } = classNameGenerator()\n\n return {\n wrapper: wrapper(),\n itemLabel: itemLabel({ enableEllipsis }),\n deleteButton: deleteButton({ disabled }),\n deleteButtonIcon: deleteButtonIcon(),\n }\n }, [disabled, enableEllipsis])\n\n const body = (\n <Chip disabled={disabled} className={classNames.wrapper}>\n <ItemLabel id={labelId} className={classNames.itemLabel} setNeedsTooltip={setNeedsTooltip}>\n {item.label}\n </ItemLabel>\n\n {deletable && (\n <DestroyButton\n labelId={labelId}\n suffixTextId={destroySuffixTextId}\n item={item}\n onDelete={onDelete}\n disabled={disabled}\n buttonRef={buttonRef}\n className={classNames.deleteButton}\n iconStyle={classNames.deleteButtonIcon}\n />\n )}\n </Chip>\n )\n\n if (needsTooltip) {\n return <Tooltip message={item.label}>{body}</Tooltip>\n }\n\n return body\n}\n\nconst ItemLabel = memo<\n PropsWithChildren<{\n id: string\n enableEllipsis?: boolean\n setNeedsTooltip: (flg: boolean) => void\n className: string\n }>\n>(({ children, id, enableEllipsis, setNeedsTooltip, className }) => {\n const labelRef = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (enableEllipsis && labelRef.current) {\n const elem = labelRef.current\n\n setNeedsTooltip(elem.offsetWidth < elem.scrollWidth)\n }\n }, [enableEllipsis, setNeedsTooltip])\n\n return (\n <span ref={labelRef} id={id} className={className}>\n {children}\n </span>\n )\n})\n\nconst typedMemo: <T>(c: T) => T = memo\nconst EXEC_DESTROY_KEY = /^(Enter|Backspace| )$/\n\nconst BaseDestroyButton = <T,>({\n labelId,\n suffixTextId,\n item,\n onDelete,\n disabled,\n buttonRef,\n className,\n iconStyle,\n}: Pick<Props<T>, 'item' | 'onDelete' | 'disabled' | 'buttonRef'> & {\n labelId: string\n suffixTextId: string\n className: string\n iconStyle: string\n}) => {\n const { localize } = useIntl()\n const onClick = useCallback(() => {\n onDelete(item)\n }, [item, onDelete])\n const onKeyDown = useCallback(\n (e: KeyboardEvent<HTMLButtonElement>) => {\n if (EXEC_DESTROY_KEY.test(e.key)) {\n e.stopPropagation()\n\n // HINT: イベントの伝播が止まる関係でonClickに設定したonDeleteは実行されない\n // このタイミングで明示的に削除処理を実行する\n onClick()\n }\n },\n [onClick],\n )\n\n const destroyButtonIconAltSuffix = useMemo(\n () =>\n localize({\n id: 'smarthr-ui/MultiCombobox/destroyButtonIconAltSuffix',\n defaultText: 'を削除',\n }),\n [localize],\n )\n\n return (\n <UnstyledButton\n ref={buttonRef}\n disabled={disabled}\n tabIndex={-1}\n aria-labelledby={`${labelId} ${suffixTextId}`}\n onClick={onClick}\n onKeyDown={onKeyDown}\n className={className}\n >\n <VisuallyHiddenText id={suffixTextId}>{destroyButtonIconAltSuffix}</VisuallyHiddenText>\n <FaCircleXmarkIcon color={disabled ? 'TEXT_DISABLED' : 'inherit'} className={iconStyle} />\n </UnstyledButton>\n )\n}\nconst DestroyButton = typedMemo(BaseDestroyButton)\n"],"names":["tv","_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,MAAM,kBAAkB,GAAGA,EAAE,CAAC;AAC5B,IAAA,KAAK,EAAE;AACL,QAAA,OAAO,EACL,oHAAoH;AACtH,QAAA,SAAS,EAAE,4CAA4C;AACvD,QAAA,YAAY,EAAE;YACZ,uCAAuC;YACvC,cAAc;YACd,wBAAwB;YACxB,4DAA4D;YAC5D,gCAAgC;AACjC,SAAA;AACD,QAAA,gBAAgB,EACd,+GAA+G;AAClH,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,cAAc,EAAE;AACd,YAAA,IAAI,EAAE;AACJ,gBAAA,SAAS,EAAE,iEAAiE;AAC7E,aAAA;AACF,SAAA;AACD,QAAA,QAAQ,EAAE;AACR,YAAA,IAAI,EAAE;AACJ,gBAAA,YAAY,EAAE,wBAAwB;AACvC,aAAA;AACD,YAAA,KAAK,EAAE,EAAE;AACV,SAAA;AACF,KAAA;AACF,CAAA,CAAC;AAEI,SAAU,iBAAiB,CAAI,EACnC,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,SAAS,GACA,EAAA;IACT,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACvD,IAAA,MAAM,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,IAAI;AACjC,IAAA,MAAM,QAAQ,GAAG,KAAK,EAAE;AACxB,IAAA,MAAM,OAAO,GAAG,CAAA,EAAG,QAAQ,aAAa;AACxC,IAAA,MAA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E,QAAQ,CAAC;AACP,QAAA,EAAE,EAAE,qDAAqD;AACzD,QAAA,WAAW,EAAE,KAAK;AACnB,KAAA,CAAC,EACJ,CAAC,QAAQ,CAAC,CACX;AAED,IAAA,QACED,IAAA,CAAC,cAAc,EAAA,EACb,GAAG,EAAE,SAAS,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,EAAE,EAAA,iBAAA,EACK,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,YAAY,EAAE,EAC7C,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EAAA,QAAA,EAAA,CAEpBC,GAAA,CAAC,kBAAkB,EAAA,EAAC,EAAE,EAAE,YAAY,EAAA,QAAA,EAAG,0BAA0B,EAAA,CAAsB,EACvFA,GAAA,CAAC,iBAAiB,IAAC,KAAK,EAAE,QAAQ,GAAG,eAAe,GAAG,SAAS,EAAE,SAAS,EAAE,SAAS,EAAA,CAAI,CAAA,EAAA,CAC3E;AAErB,CAAC;AACD,MAAM,aAAa,GAAG,SAAS,CAAC,iBAAiB,CAAC;;;;"}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var hooks_useDecorators = require('../../../hooks/useDecorators.cjs');
|
|
7
6
|
var hooks_useResponseStatus = require('../../../hooks/useResponseStatus.cjs');
|
|
8
7
|
require('../../../intl/IntlProvider.cjs');
|
|
9
8
|
var intl_useIntl = require('../../../intl/useIntl.cjs');
|
|
@@ -28,7 +27,7 @@ var components_Dialog_DialogHeading = require('../DialogHeading.cjs');
|
|
|
28
27
|
var components_Dialog_dialogInnerStyle = require('../dialogInnerStyle.cjs');
|
|
29
28
|
|
|
30
29
|
const ACTION_AREA_CLUSTER_GAP = { row: 0.5, column: 1 };
|
|
31
|
-
const ActionDialogContentInner = ({ children, heading, contentBgColor, contentPadding,
|
|
30
|
+
const ActionDialogContentInner = ({ children, heading, contentBgColor, contentPadding, actionButton, onClickAction, onClickClose, responseStatus, closeButton, subActionArea, }) => {
|
|
32
31
|
const calcedResponseStatus = hooks_useResponseStatus.useResponseStatus(responseStatus);
|
|
33
32
|
const styles = React.useMemo(() => {
|
|
34
33
|
const { wrapper, actionArea, buttonArea, message } = components_Dialog_dialogInnerStyle.dialogContentInner();
|
|
@@ -39,25 +38,22 @@ const ActionDialogContentInner = ({ children, heading, contentBgColor, contentPa
|
|
|
39
38
|
message: message(),
|
|
40
39
|
};
|
|
41
40
|
}, []);
|
|
42
|
-
return (jsxRuntime.jsxs(components_SectioningContent_SectioningContent.Section, { className: styles.wrapper, children: [jsxRuntime.jsx(components_Dialog_DialogHeading.DialogHeading, { ...heading }), jsxRuntime.jsx(components_Dialog_DialogBody.DialogBody, { contentPadding: contentPadding, contentBgColor: contentBgColor, children: children }), jsxRuntime.jsxs(components_Layout_Stack_Stack.Stack, { gap: 0.5, className: styles.actionArea, children: [jsxRuntime.jsxs(components_Layout_Cluster_Cluster.Cluster, { justify: "space-between", children: [subActionArea, jsxRuntime.jsx(ActionAreaCluster, { onClickClose: onClickClose, onClickAction: onClickAction,
|
|
41
|
+
return (jsxRuntime.jsxs(components_SectioningContent_SectioningContent.Section, { className: styles.wrapper, children: [jsxRuntime.jsx(components_Dialog_DialogHeading.DialogHeading, { ...heading }), jsxRuntime.jsx(components_Dialog_DialogBody.DialogBody, { contentPadding: contentPadding, contentBgColor: contentBgColor, children: children }), jsxRuntime.jsxs(components_Layout_Stack_Stack.Stack, { gap: 0.5, className: styles.actionArea, children: [jsxRuntime.jsxs(components_Layout_Cluster_Cluster.Cluster, { justify: "space-between", children: [subActionArea, jsxRuntime.jsx(ActionAreaCluster, { onClickClose: onClickClose, onClickAction: onClickAction, closeButton: closeButton, actionButton: actionButton, loading: calcedResponseStatus.isProcessing, className: styles.buttonArea })] }), jsxRuntime.jsx(components_Dialog_DialogContentResponseStatusMessage.DialogContentResponseStatusMessage, { responseStatus: calcedResponseStatus, className: styles.message })] })] }));
|
|
43
42
|
};
|
|
44
|
-
const ActionAreaCluster = React.memo(({ onClickClose, onClickAction,
|
|
43
|
+
const ActionAreaCluster = React.memo(({ onClickClose, onClickAction, closeButton, actionButton, loading, className }) => {
|
|
45
44
|
const handleClickAction = React.useCallback((e) => {
|
|
46
45
|
onClickAction(e, { close: onClickClose });
|
|
47
46
|
}, [onClickAction, onClickClose]);
|
|
48
|
-
return (jsxRuntime.jsxs(components_Layout_Cluster_Cluster.Cluster, { gap: ACTION_AREA_CLUSTER_GAP, className: className, children: [jsxRuntime.jsx(CloseButton, { onClick: onClickClose, disabled:
|
|
47
|
+
return (jsxRuntime.jsxs(components_Layout_Cluster_Cluster.Cluster, { gap: ACTION_AREA_CLUSTER_GAP, className: className, children: [jsxRuntime.jsx(CloseButton, { onClick: onClickClose, disabled: closeButton.disabled || loading, text: closeButton.text }), jsxRuntime.jsx(ActionButton, { variant: actionButton.theme, disabled: actionButton.disabled, loading: loading, onClick: handleClickAction, children: actionButton.text })] }));
|
|
49
48
|
});
|
|
50
49
|
const ActionButton = React.memo(({ variant = 'primary', disabled, loading, onClick, children }) => (jsxRuntime.jsx(components_Button_Button.Button, { type: "submit", variant: variant, disabled: disabled, loading: loading, onClick: onClick, className: "smarthr-ui-Dialog-actionButton", children: children })));
|
|
51
|
-
const CloseButton = React.memo(({ onClick, disabled,
|
|
50
|
+
const CloseButton = React.memo(({ onClick, disabled, text }) => {
|
|
52
51
|
const { localize } = intl_useIntl.useIntl();
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
defaultText: 'キャンセル',
|
|
57
|
-
}),
|
|
52
|
+
const defaultText = React.useMemo(() => localize({
|
|
53
|
+
id: 'smarthr-ui/ActionDialog/closeButtonLabel',
|
|
54
|
+
defaultText: 'キャンセル',
|
|
58
55
|
}), [localize]);
|
|
59
|
-
|
|
60
|
-
return (jsxRuntime.jsx(components_Button_Button.Button, { onClick: onClick, disabled: disabled, className: "smarthr-ui-Dialog-closeButton", children: decorated.closeButtonLabel }));
|
|
56
|
+
return (jsxRuntime.jsx(components_Button_Button.Button, { onClick: onClick, disabled: disabled, className: "smarthr-ui-Dialog-closeButton", children: text ?? defaultText }));
|
|
61
57
|
});
|
|
62
58
|
|
|
63
59
|
exports.ActionDialogContentInner = ActionDialogContentInner;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionDialogContentInner.cjs","sources":["../../../../src/components/Dialog/ControlledActionDialog/ActionDialogContentInner.tsx"],"sourcesContent":["'use client'\n\nimport {\n type FC,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n memo,\n useCallback,\n useMemo,\n} from 'react'\n\nimport { type
|
|
1
|
+
{"version":3,"file":"ActionDialogContentInner.cjs","sources":["../../../../src/components/Dialog/ControlledActionDialog/ActionDialogContentInner.tsx"],"sourcesContent":["'use client'\n\nimport {\n type FC,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n memo,\n useCallback,\n useMemo,\n} from 'react'\n\nimport { type ResponseStatus, useResponseStatus } from '../../../hooks/useResponseStatus'\nimport { useIntl } from '../../../intl'\nimport { Button } from '../../Button'\nimport { Cluster, Stack } from '../../Layout'\nimport { Section } from '../../SectioningContent'\nimport { DialogBody, type Props as DialogBodyProps } from '../DialogBody'\nimport { DialogContentResponseStatusMessage } from '../DialogContentResponseStatusMessage'\nimport { DialogHeading, type Props as DialogHeadingProps } from '../DialogHeading'\nimport { dialogContentInner } from '../dialogInnerStyle'\n\nexport type ActionDialogHelpers = {\n close: () => void\n}\n\ntype ObjectActionButtonType = {\n /** アクションボタンのラベル */\n text: ReactNode\n /** アクションボタンのスタイル */\n theme?: 'primary' | 'secondary' | 'danger'\n /** アクションボタンを無効にするかどうか */\n disabled?: boolean\n}\n\ntype ObjectCloseButtonType = {\n /** 閉じるボタンのラベル */\n text: ReactNode\n /** 閉じるボタンを無効にするかどうか */\n disabled?: boolean\n}\n\nexport type AbstractProps = PropsWithChildren<\n DialogBodyProps & {\n /** ダイアログタイトル */\n heading: DialogHeadingProps\n /** アクションボタン */\n actionButton: ObjectActionButtonType\n /**\n * アクションボタンをクリックした時に発火するコールバック関数\n * @param e マウスイベント\n * @param helpers ダイアログ操作のためのヘルパー関数\n */\n onClickAction: (e: MouseEvent<Element>, helpers: ActionDialogHelpers) => void\n /** 閉じるボタン */\n closeButton: ObjectCloseButtonType\n /** ダイアログフッターの左端操作領域 */\n subActionArea?: ReactNode\n }\n>\n\nexport type ActionDialogContentInnerProps = AbstractProps & {\n onClickClose: () => void\n responseStatus?: ResponseStatus\n}\n\nconst ACTION_AREA_CLUSTER_GAP = { row: 0.5, column: 1 } as const\n\nexport const ActionDialogContentInner: FC<ActionDialogContentInnerProps> = ({\n children,\n heading,\n contentBgColor,\n contentPadding,\n actionButton,\n onClickAction,\n onClickClose,\n responseStatus,\n closeButton,\n subActionArea,\n}) => {\n const calcedResponseStatus = useResponseStatus(responseStatus)\n\n const styles = useMemo(() => {\n const { wrapper, actionArea, buttonArea, message } = dialogContentInner()\n\n return {\n wrapper: wrapper(),\n actionArea: actionArea(),\n buttonArea: buttonArea(),\n message: message(),\n }\n }, [])\n\n return (\n <Section className={styles.wrapper}>\n <DialogHeading {...heading} />\n <DialogBody contentPadding={contentPadding} contentBgColor={contentBgColor}>\n {children}\n </DialogBody>\n <Stack gap={0.5} className={styles.actionArea}>\n <Cluster justify=\"space-between\">\n {subActionArea}\n <ActionAreaCluster\n onClickClose={onClickClose}\n onClickAction={onClickAction}\n closeButton={closeButton}\n actionButton={actionButton}\n loading={calcedResponseStatus.isProcessing}\n className={styles.buttonArea}\n />\n </Cluster>\n <DialogContentResponseStatusMessage\n responseStatus={calcedResponseStatus}\n className={styles.message}\n />\n </Stack>\n </Section>\n )\n}\n\nconst ActionAreaCluster = memo<\n Pick<ActionDialogContentInnerProps, 'onClickClose' | 'onClickAction'> & {\n actionButton: ObjectActionButtonType\n closeButton: ObjectCloseButtonType\n loading: boolean\n className: string\n }\n>(({ onClickClose, onClickAction, closeButton, actionButton, loading, className }) => {\n const handleClickAction = useCallback(\n (e: MouseEvent<Element>) => {\n onClickAction(e, { close: onClickClose })\n },\n [onClickAction, onClickClose],\n )\n\n return (\n <Cluster gap={ACTION_AREA_CLUSTER_GAP} className={className}>\n <CloseButton\n onClick={onClickClose}\n disabled={closeButton.disabled || loading}\n text={closeButton.text}\n />\n <ActionButton\n variant={actionButton.theme}\n disabled={actionButton.disabled}\n loading={loading}\n onClick={handleClickAction}\n >\n {actionButton.text}\n </ActionButton>\n </Cluster>\n )\n})\n\nconst ActionButton = memo<\n PropsWithChildren<{\n variant: ObjectActionButtonType['theme']\n disabled: ObjectActionButtonType['disabled']\n loading: boolean\n onClick: (e: MouseEvent<HTMLButtonElement>) => void\n }>\n>(({ variant = 'primary', disabled, loading, onClick, children }) => (\n <Button\n type=\"submit\"\n variant={variant}\n disabled={disabled}\n loading={loading}\n onClick={onClick}\n className=\"smarthr-ui-Dialog-actionButton\"\n >\n {children}\n </Button>\n))\n\nconst CloseButton = memo<{\n onClick: ActionDialogContentInnerProps['onClickClose']\n disabled: boolean\n text: ReactNode\n}>(({ onClick, disabled, text }) => {\n const { localize } = useIntl()\n\n const defaultText = useMemo(\n () =>\n localize({\n id: 'smarthr-ui/ActionDialog/closeButtonLabel',\n defaultText: 'キャンセル',\n }),\n [localize],\n )\n\n return (\n <Button onClick={onClick} disabled={disabled} className=\"smarthr-ui-Dialog-closeButton\">\n {text ?? defaultText}\n </Button>\n )\n})\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA;AAEO;AAYL;AAEA;AACE;;;;;;;;;AAmCJ;AAEA;AAQE;;AAGE;AAIF;AAiBF;AAEA;AAoBA;AAKE;;AAKM;AACA;AACD;;AASP;;"}
|
|
@@ -1,35 +1,43 @@
|
|
|
1
1
|
import { type FC, type MouseEvent, type PropsWithChildren, type ReactNode } from 'react';
|
|
2
|
-
import { type DecoratorsType } from '../../../hooks/useDecorators';
|
|
3
2
|
import { type ResponseStatus } from '../../../hooks/useResponseStatus';
|
|
4
3
|
import { type Props as DialogBodyProps } from '../DialogBody';
|
|
5
4
|
import { type Props as DialogHeadingProps } from '../DialogHeading';
|
|
6
5
|
export type ActionDialogHelpers = {
|
|
7
6
|
close: () => void;
|
|
8
7
|
};
|
|
8
|
+
type ObjectActionButtonType = {
|
|
9
|
+
/** アクションボタンのラベル */
|
|
10
|
+
text: ReactNode;
|
|
11
|
+
/** アクションボタンのスタイル */
|
|
12
|
+
theme?: 'primary' | 'secondary' | 'danger';
|
|
13
|
+
/** アクションボタンを無効にするかどうか */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type ObjectCloseButtonType = {
|
|
17
|
+
/** 閉じるボタンのラベル */
|
|
18
|
+
text: ReactNode;
|
|
19
|
+
/** 閉じるボタンを無効にするかどうか */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
};
|
|
9
22
|
export type AbstractProps = PropsWithChildren<DialogBodyProps & {
|
|
10
23
|
/** ダイアログタイトル */
|
|
11
24
|
heading: DialogHeadingProps;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
/** アクションボタンのスタイル */
|
|
15
|
-
actionTheme?: 'primary' | 'secondary' | 'danger';
|
|
25
|
+
/** アクションボタン */
|
|
26
|
+
actionButton: ObjectActionButtonType;
|
|
16
27
|
/**
|
|
17
28
|
* アクションボタンをクリックした時に発火するコールバック関数
|
|
18
29
|
* @param e マウスイベント
|
|
19
30
|
* @param helpers ダイアログ操作のためのヘルパー関数
|
|
20
31
|
*/
|
|
21
32
|
onClickAction: (e: MouseEvent<Element>, helpers: ActionDialogHelpers) => void;
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
/** 閉じるボタンを無効にするかどうか */
|
|
25
|
-
closeDisabled?: boolean;
|
|
33
|
+
/** 閉じるボタン */
|
|
34
|
+
closeButton: ObjectCloseButtonType;
|
|
26
35
|
/** ダイアログフッターの左端操作領域 */
|
|
27
36
|
subActionArea?: ReactNode;
|
|
28
|
-
/** コンポーネント内の文言を変更するための関数を設定 */
|
|
29
|
-
decorators?: DecoratorsType<'closeButtonLabel'>;
|
|
30
37
|
}>;
|
|
31
38
|
export type ActionDialogContentInnerProps = AbstractProps & {
|
|
32
39
|
onClickClose: () => void;
|
|
33
40
|
responseStatus?: ResponseStatus;
|
|
34
41
|
};
|
|
35
42
|
export declare const ActionDialogContentInner: FC<ActionDialogContentInnerProps>;
|
|
43
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { memo, useCallback, useMemo } from 'react';
|
|
4
|
-
import { useDecorators } from '../../../hooks/useDecorators.js';
|
|
5
4
|
import { useResponseStatus } from '../../../hooks/useResponseStatus.js';
|
|
6
5
|
import '../../../intl/IntlProvider.js';
|
|
7
6
|
import { useIntl } from '../../../intl/useIntl.js';
|
|
@@ -26,7 +25,7 @@ import { DialogHeading } from '../DialogHeading.js';
|
|
|
26
25
|
import { dialogContentInner } from '../dialogInnerStyle.js';
|
|
27
26
|
|
|
28
27
|
const ACTION_AREA_CLUSTER_GAP = { row: 0.5, column: 1 };
|
|
29
|
-
const ActionDialogContentInner = ({ children, heading, contentBgColor, contentPadding,
|
|
28
|
+
const ActionDialogContentInner = ({ children, heading, contentBgColor, contentPadding, actionButton, onClickAction, onClickClose, responseStatus, closeButton, subActionArea, }) => {
|
|
30
29
|
const calcedResponseStatus = useResponseStatus(responseStatus);
|
|
31
30
|
const styles = useMemo(() => {
|
|
32
31
|
const { wrapper, actionArea, buttonArea, message } = dialogContentInner();
|
|
@@ -37,25 +36,22 @@ const ActionDialogContentInner = ({ children, heading, contentBgColor, contentPa
|
|
|
37
36
|
message: message(),
|
|
38
37
|
};
|
|
39
38
|
}, []);
|
|
40
|
-
return (jsxs(Section, { className: styles.wrapper, children: [jsx(DialogHeading, { ...heading }), jsx(DialogBody, { contentPadding: contentPadding, contentBgColor: contentBgColor, children: children }), jsxs(Stack, { gap: 0.5, className: styles.actionArea, children: [jsxs(Cluster, { justify: "space-between", children: [subActionArea, jsx(ActionAreaCluster, { onClickClose: onClickClose, onClickAction: onClickAction,
|
|
39
|
+
return (jsxs(Section, { className: styles.wrapper, children: [jsx(DialogHeading, { ...heading }), jsx(DialogBody, { contentPadding: contentPadding, contentBgColor: contentBgColor, children: children }), jsxs(Stack, { gap: 0.5, className: styles.actionArea, children: [jsxs(Cluster, { justify: "space-between", children: [subActionArea, jsx(ActionAreaCluster, { onClickClose: onClickClose, onClickAction: onClickAction, closeButton: closeButton, actionButton: actionButton, loading: calcedResponseStatus.isProcessing, className: styles.buttonArea })] }), jsx(DialogContentResponseStatusMessage, { responseStatus: calcedResponseStatus, className: styles.message })] })] }));
|
|
41
40
|
};
|
|
42
|
-
const ActionAreaCluster = memo(({ onClickClose, onClickAction,
|
|
41
|
+
const ActionAreaCluster = memo(({ onClickClose, onClickAction, closeButton, actionButton, loading, className }) => {
|
|
43
42
|
const handleClickAction = useCallback((e) => {
|
|
44
43
|
onClickAction(e, { close: onClickClose });
|
|
45
44
|
}, [onClickAction, onClickClose]);
|
|
46
|
-
return (jsxs(Cluster, { gap: ACTION_AREA_CLUSTER_GAP, className: className, children: [jsx(CloseButton, { onClick: onClickClose, disabled:
|
|
45
|
+
return (jsxs(Cluster, { gap: ACTION_AREA_CLUSTER_GAP, className: className, children: [jsx(CloseButton, { onClick: onClickClose, disabled: closeButton.disabled || loading, text: closeButton.text }), jsx(ActionButton, { variant: actionButton.theme, disabled: actionButton.disabled, loading: loading, onClick: handleClickAction, children: actionButton.text })] }));
|
|
47
46
|
});
|
|
48
47
|
const ActionButton = memo(({ variant = 'primary', disabled, loading, onClick, children }) => (jsx(Button, { type: "submit", variant: variant, disabled: disabled, loading: loading, onClick: onClick, className: "smarthr-ui-Dialog-actionButton", children: children })));
|
|
49
|
-
const CloseButton = memo(({ onClick, disabled,
|
|
48
|
+
const CloseButton = memo(({ onClick, disabled, text }) => {
|
|
50
49
|
const { localize } = useIntl();
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
defaultText: 'キャンセル',
|
|
55
|
-
}),
|
|
50
|
+
const defaultText = useMemo(() => localize({
|
|
51
|
+
id: 'smarthr-ui/ActionDialog/closeButtonLabel',
|
|
52
|
+
defaultText: 'キャンセル',
|
|
56
53
|
}), [localize]);
|
|
57
|
-
|
|
58
|
-
return (jsx(Button, { onClick: onClick, disabled: disabled, className: "smarthr-ui-Dialog-closeButton", children: decorated.closeButtonLabel }));
|
|
54
|
+
return (jsx(Button, { onClick: onClick, disabled: disabled, className: "smarthr-ui-Dialog-closeButton", children: text ?? defaultText }));
|
|
59
55
|
});
|
|
60
56
|
|
|
61
57
|
export { ActionDialogContentInner };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionDialogContentInner.js","sources":["../../../../src/components/Dialog/ControlledActionDialog/ActionDialogContentInner.tsx"],"sourcesContent":["'use client'\n\nimport {\n type FC,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n memo,\n useCallback,\n useMemo,\n} from 'react'\n\nimport { type
|
|
1
|
+
{"version":3,"file":"ActionDialogContentInner.js","sources":["../../../../src/components/Dialog/ControlledActionDialog/ActionDialogContentInner.tsx"],"sourcesContent":["'use client'\n\nimport {\n type FC,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n memo,\n useCallback,\n useMemo,\n} from 'react'\n\nimport { type ResponseStatus, useResponseStatus } from '../../../hooks/useResponseStatus'\nimport { useIntl } from '../../../intl'\nimport { Button } from '../../Button'\nimport { Cluster, Stack } from '../../Layout'\nimport { Section } from '../../SectioningContent'\nimport { DialogBody, type Props as DialogBodyProps } from '../DialogBody'\nimport { DialogContentResponseStatusMessage } from '../DialogContentResponseStatusMessage'\nimport { DialogHeading, type Props as DialogHeadingProps } from '../DialogHeading'\nimport { dialogContentInner } from '../dialogInnerStyle'\n\nexport type ActionDialogHelpers = {\n close: () => void\n}\n\ntype ObjectActionButtonType = {\n /** アクションボタンのラベル */\n text: ReactNode\n /** アクションボタンのスタイル */\n theme?: 'primary' | 'secondary' | 'danger'\n /** アクションボタンを無効にするかどうか */\n disabled?: boolean\n}\n\ntype ObjectCloseButtonType = {\n /** 閉じるボタンのラベル */\n text: ReactNode\n /** 閉じるボタンを無効にするかどうか */\n disabled?: boolean\n}\n\nexport type AbstractProps = PropsWithChildren<\n DialogBodyProps & {\n /** ダイアログタイトル */\n heading: DialogHeadingProps\n /** アクションボタン */\n actionButton: ObjectActionButtonType\n /**\n * アクションボタンをクリックした時に発火するコールバック関数\n * @param e マウスイベント\n * @param helpers ダイアログ操作のためのヘルパー関数\n */\n onClickAction: (e: MouseEvent<Element>, helpers: ActionDialogHelpers) => void\n /** 閉じるボタン */\n closeButton: ObjectCloseButtonType\n /** ダイアログフッターの左端操作領域 */\n subActionArea?: ReactNode\n }\n>\n\nexport type ActionDialogContentInnerProps = AbstractProps & {\n onClickClose: () => void\n responseStatus?: ResponseStatus\n}\n\nconst ACTION_AREA_CLUSTER_GAP = { row: 0.5, column: 1 } as const\n\nexport const ActionDialogContentInner: FC<ActionDialogContentInnerProps> = ({\n children,\n heading,\n contentBgColor,\n contentPadding,\n actionButton,\n onClickAction,\n onClickClose,\n responseStatus,\n closeButton,\n subActionArea,\n}) => {\n const calcedResponseStatus = useResponseStatus(responseStatus)\n\n const styles = useMemo(() => {\n const { wrapper, actionArea, buttonArea, message } = dialogContentInner()\n\n return {\n wrapper: wrapper(),\n actionArea: actionArea(),\n buttonArea: buttonArea(),\n message: message(),\n }\n }, [])\n\n return (\n <Section className={styles.wrapper}>\n <DialogHeading {...heading} />\n <DialogBody contentPadding={contentPadding} contentBgColor={contentBgColor}>\n {children}\n </DialogBody>\n <Stack gap={0.5} className={styles.actionArea}>\n <Cluster justify=\"space-between\">\n {subActionArea}\n <ActionAreaCluster\n onClickClose={onClickClose}\n onClickAction={onClickAction}\n closeButton={closeButton}\n actionButton={actionButton}\n loading={calcedResponseStatus.isProcessing}\n className={styles.buttonArea}\n />\n </Cluster>\n <DialogContentResponseStatusMessage\n responseStatus={calcedResponseStatus}\n className={styles.message}\n />\n </Stack>\n </Section>\n )\n}\n\nconst ActionAreaCluster = memo<\n Pick<ActionDialogContentInnerProps, 'onClickClose' | 'onClickAction'> & {\n actionButton: ObjectActionButtonType\n closeButton: ObjectCloseButtonType\n loading: boolean\n className: string\n }\n>(({ onClickClose, onClickAction, closeButton, actionButton, loading, className }) => {\n const handleClickAction = useCallback(\n (e: MouseEvent<Element>) => {\n onClickAction(e, { close: onClickClose })\n },\n [onClickAction, onClickClose],\n )\n\n return (\n <Cluster gap={ACTION_AREA_CLUSTER_GAP} className={className}>\n <CloseButton\n onClick={onClickClose}\n disabled={closeButton.disabled || loading}\n text={closeButton.text}\n />\n <ActionButton\n variant={actionButton.theme}\n disabled={actionButton.disabled}\n loading={loading}\n onClick={handleClickAction}\n >\n {actionButton.text}\n </ActionButton>\n </Cluster>\n )\n})\n\nconst ActionButton = memo<\n PropsWithChildren<{\n variant: ObjectActionButtonType['theme']\n disabled: ObjectActionButtonType['disabled']\n loading: boolean\n onClick: (e: MouseEvent<HTMLButtonElement>) => void\n }>\n>(({ variant = 'primary', disabled, loading, onClick, children }) => (\n <Button\n type=\"submit\"\n variant={variant}\n disabled={disabled}\n loading={loading}\n onClick={onClick}\n className=\"smarthr-ui-Dialog-actionButton\"\n >\n {children}\n </Button>\n))\n\nconst CloseButton = memo<{\n onClick: ActionDialogContentInnerProps['onClickClose']\n disabled: boolean\n text: ReactNode\n}>(({ onClick, disabled, text }) => {\n const { localize } = useIntl()\n\n const defaultText = useMemo(\n () =>\n localize({\n id: 'smarthr-ui/ActionDialog/closeButtonLabel',\n defaultText: 'キャンセル',\n }),\n [localize],\n )\n\n return (\n <Button onClick={onClick} disabled={disabled} className=\"smarthr-ui-Dialog-closeButton\">\n {text ?? defaultText}\n </Button>\n )\n})\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA;AAEO;AAYL;AAEA;AACE;;;;;;;;;AAmCJ;AAEA;AAQE;;AAGE;AAIF;AAiBF;AAEA;AAoBA;AAKE;;AAKM;AACA;AACD;;AASP;;"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var React = require('react');
|
|
6
|
+
var hooks_useObjectAttributes = require('../../../hooks/useObjectAttributes.cjs');
|
|
6
7
|
var components_Dialog_DialogContentInner = require('../DialogContentInner.cjs');
|
|
7
8
|
var components_Dialog_useDialogPortal = require('../useDialogPortal.cjs');
|
|
8
9
|
var components_Dialog_useObjectHeading = require('../useObjectHeading.cjs');
|
|
@@ -11,9 +12,12 @@ var components_Dialog_ControlledActionDialog_ActionDialogContentInner = require(
|
|
|
11
12
|
const headingObjectConverter = (text) => ({
|
|
12
13
|
text,
|
|
13
14
|
});
|
|
14
|
-
const
|
|
15
|
+
const buttonObjectConverter = (text) => ({ text });
|
|
16
|
+
const ControlledActionDialog = ({ children, heading: orgHeading, contentBgColor, contentPadding, actionButton: orgActionButton, onClickAction, onClickClose, onPressEscape = onClickClose, responseStatus, closeButton: orgCloseButton, subActionArea, className, portalParent, id, isOpen, ...rest }) => {
|
|
15
17
|
const { createPortal } = components_Dialog_useDialogPortal.useDialogPortal(portalParent, id);
|
|
16
18
|
const heading = components_Dialog_useObjectHeading.useObjectHeading(orgHeading, headingObjectConverter);
|
|
19
|
+
const actionButton = hooks_useObjectAttributes.useObjectAttributes(orgActionButton, buttonObjectConverter);
|
|
20
|
+
const closeButton = hooks_useObjectAttributes.useObjectAttributes(orgCloseButton, buttonObjectConverter);
|
|
17
21
|
const actualOnClickClose = React.useCallback(() => {
|
|
18
22
|
if (isOpen) {
|
|
19
23
|
onClickClose();
|
|
@@ -24,7 +28,7 @@ const ControlledActionDialog = ({ children, heading: orgHeading, contentBgColor,
|
|
|
24
28
|
onClickAction(e, helpers);
|
|
25
29
|
}
|
|
26
30
|
}, [isOpen, onClickAction]);
|
|
27
|
-
return createPortal(jsxRuntime.jsx(components_Dialog_DialogContentInner.DialogContentInner, { ...rest, isOpen: isOpen, ariaLabelledby: heading.id, className: className, onPressEscape:
|
|
31
|
+
return createPortal(jsxRuntime.jsx(components_Dialog_DialogContentInner.DialogContentInner, { ...rest, isOpen: isOpen, ariaLabelledby: heading.id, className: className, onPressEscape: closeButton.disabled ? undefined : onPressEscape, children: jsxRuntime.jsx(components_Dialog_ControlledActionDialog_ActionDialogContentInner.ActionDialogContentInner, { heading: heading, contentBgColor: contentBgColor, contentPadding: contentPadding, actionButton: actionButton, closeButton: closeButton, onClickClose: actualOnClickClose, onClickAction: actualOnClickAction, subActionArea: subActionArea, responseStatus: responseStatus, children: children }) }));
|
|
28
32
|
};
|
|
29
33
|
|
|
30
34
|
exports.ControlledActionDialog = ControlledActionDialog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledActionDialog.cjs","sources":["../../../../src/components/Dialog/ControlledActionDialog/ControlledActionDialog.tsx"],"sourcesContent":["'use client'\n\nimport { type ComponentProps, type FC, type ReactNode, useCallback } from 'react'\n\nimport { DialogContentInner } from '../DialogContentInner'\nimport { useDialogPortal } from '../useDialogPortal'\nimport { useObjectHeading } from '../useObjectHeading'\n\nimport {\n ActionDialogContentInner,\n type ActionDialogContentInnerProps,\n type ActionDialogHelpers,\n} from './ActionDialogContentInner'\n\nimport type { DialogProps } from '../types'\n\ntype ObjectHeadingType = Omit<ActionDialogContentInnerProps['heading'], 'id'>\ntype HeadingType = ReactNode | ObjectHeadingType\n\ntype AbstractProps = Omit
|
|
1
|
+
{"version":3,"file":"ControlledActionDialog.cjs","sources":["../../../../src/components/Dialog/ControlledActionDialog/ControlledActionDialog.tsx"],"sourcesContent":["'use client'\n\nimport { type ComponentProps, type FC, type ReactNode, useCallback } from 'react'\n\nimport { useObjectAttributes } from '../../../hooks/useObjectAttributes'\nimport { DialogContentInner } from '../DialogContentInner'\nimport { useDialogPortal } from '../useDialogPortal'\nimport { useObjectHeading } from '../useObjectHeading'\n\nimport {\n ActionDialogContentInner,\n type ActionDialogContentInnerProps,\n type ActionDialogHelpers,\n} from './ActionDialogContentInner'\n\nimport type { DialogProps } from '../types'\n\ntype ObjectHeadingType = Omit<ActionDialogContentInnerProps['heading'], 'id'>\ntype HeadingType = ReactNode | ObjectHeadingType\ntype ObjectActionButtonType = ActionDialogContentInnerProps['actionButton']\ntype ObjectCloseButtonType = ActionDialogContentInnerProps['closeButton']\n\ntype AbstractProps = Omit<\n ActionDialogContentInnerProps,\n 'heading' | 'actionButton' | 'closeButton'\n> &\n DialogProps & {\n heading: HeadingType\n actionButton: ReactNode | ObjectActionButtonType\n closeButton?: ReactNode | ObjectCloseButtonType\n }\ntype Props = AbstractProps & Omit<ComponentProps<'div'>, keyof AbstractProps>\n\nconst headingObjectConverter = (text: ReactNode) => ({\n text,\n})\nconst buttonObjectConverter = (text: ReactNode) => ({ text })\n\nexport const ControlledActionDialog: FC<Props> = ({\n children,\n heading: orgHeading,\n contentBgColor,\n contentPadding,\n actionButton: orgActionButton,\n onClickAction,\n onClickClose,\n onPressEscape = onClickClose,\n responseStatus,\n closeButton: orgCloseButton,\n subActionArea,\n className,\n portalParent,\n id,\n isOpen,\n ...rest\n}) => {\n const { createPortal } = useDialogPortal(portalParent, id)\n const heading = useObjectHeading<HeadingType, ObjectHeadingType>(\n orgHeading,\n headingObjectConverter,\n )\n const actionButton = useObjectAttributes<\n ReactNode | ObjectActionButtonType,\n ObjectActionButtonType\n >(orgActionButton, buttonObjectConverter)\n const closeButton = useObjectAttributes<ReactNode | ObjectCloseButtonType, ObjectCloseButtonType>(\n orgCloseButton,\n buttonObjectConverter,\n )\n\n const actualOnClickClose = useCallback(() => {\n if (isOpen) {\n onClickClose()\n }\n }, [isOpen, onClickClose])\n\n const actualOnClickAction = useCallback(\n (e: React.MouseEvent<Element>, helpers: ActionDialogHelpers) => {\n if (isOpen) {\n onClickAction(e, helpers)\n }\n },\n [isOpen, onClickAction],\n )\n\n return createPortal(\n <DialogContentInner\n {...rest}\n isOpen={isOpen}\n ariaLabelledby={heading.id}\n className={className}\n onPressEscape={closeButton.disabled ? undefined : onPressEscape}\n >\n <ActionDialogContentInner\n heading={heading}\n contentBgColor={contentBgColor}\n contentPadding={contentPadding}\n actionButton={actionButton}\n closeButton={closeButton}\n onClickClose={actualOnClickClose}\n onClickAction={actualOnClickAction}\n subActionArea={subActionArea}\n responseStatus={responseStatus}\n >\n {children}\n </ActionDialogContentInner>\n </DialogContentInner>,\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAiCA;;AAEC;AACD;;;;;;AAkCE;;AAEI;;AAEJ;;;AAKM;;AAEJ;AAIF;AAuBF;;"}
|
|
@@ -3,8 +3,12 @@ import { type ActionDialogContentInnerProps } from './ActionDialogContentInner';
|
|
|
3
3
|
import type { DialogProps } from '../types';
|
|
4
4
|
type ObjectHeadingType = Omit<ActionDialogContentInnerProps['heading'], 'id'>;
|
|
5
5
|
type HeadingType = ReactNode | ObjectHeadingType;
|
|
6
|
-
type
|
|
6
|
+
type ObjectActionButtonType = ActionDialogContentInnerProps['actionButton'];
|
|
7
|
+
type ObjectCloseButtonType = ActionDialogContentInnerProps['closeButton'];
|
|
8
|
+
type AbstractProps = Omit<ActionDialogContentInnerProps, 'heading' | 'actionButton' | 'closeButton'> & DialogProps & {
|
|
7
9
|
heading: HeadingType;
|
|
10
|
+
actionButton: ReactNode | ObjectActionButtonType;
|
|
11
|
+
closeButton?: ReactNode | ObjectCloseButtonType;
|
|
8
12
|
};
|
|
9
13
|
type Props = AbstractProps & Omit<ComponentProps<'div'>, keyof AbstractProps>;
|
|
10
14
|
export declare const ControlledActionDialog: FC<Props>;
|