smarthr-ui 75.4.0 → 75.4.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/esm/_virtual/index.js +4 -4
- package/esm/_virtual/index2.js +4 -4
- package/esm/_virtual/index3.js +4 -4
- package/esm/components/Combobox/MultiCombobox/MultiCombobox.js +1 -1
- package/esm/components/Combobox/SingleCombobox/SingleCombobox.js +1 -1
- package/esm/components/Combobox/helper.js +1 -1
- package/esm/components/Combobox/useOptions.js +1 -1
- package/esm/components/Dialog/StepFormDialog/StepFormDialogContentInner.js +1 -1
- package/esm/components/Dialog/StepFormDialog/StepFormDialogContentInner.js.map +1 -1
- package/esm/components/Dropdown/DropdownMenuButton/DropdownMenuButton.js +1 -1
- package/esm/components/Dropdown/FilterDropdown/FilterDropdown.js +1 -1
- package/esm/components/FormControl/FormControl.js +1 -1
- package/esm/components/Tooltip/Tooltip.js +1 -1
- package/esm/libs/lodash.js +2 -2
- package/lib/components/Dialog/StepFormDialog/StepFormDialogContentInner.js +1 -1
- package/lib/components/Dialog/StepFormDialog/StepFormDialogContentInner.js.map +1 -1
- package/package.json +1 -1
package/esm/_virtual/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from './_commonjsHelpers.js';
|
|
2
|
-
import { __require as
|
|
2
|
+
import { __require as requireLodash_merge } from './../vendor/.pnpm/lodash.merge@4.6.2/vendor/lodash.merge/index.js';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var lodash_mergeExports = requireLodash_merge();
|
|
5
|
+
var _merge = /*@__PURE__*/getDefaultExportFromCjs(lodash_mergeExports);
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { _merge as default };
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/esm/_virtual/index2.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from './_commonjsHelpers.js';
|
|
2
|
-
import { __require as
|
|
2
|
+
import { __require as requireLodash_range } from './../vendor/.pnpm/lodash.range@3.2.0/vendor/lodash.range/index.js';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var lodash_rangeExports = requireLodash_range();
|
|
5
|
+
var _range = /*@__PURE__*/getDefaultExportFromCjs(lodash_rangeExports);
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { _range as default };
|
|
8
8
|
//# sourceMappingURL=index2.js.map
|
package/esm/_virtual/index3.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from './_commonjsHelpers.js';
|
|
2
|
-
import { __require as
|
|
2
|
+
import { __require as requireReactInnertext } from './../vendor/.pnpm/react-innertext@1.1.5_@types_react@18.3.23_react@19.1.1/vendor/react-innertext/index.js';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var reactInnertextExports = requireReactInnertext();
|
|
5
|
+
var innerText = /*@__PURE__*/getDefaultExportFromCjs(reactInnertextExports);
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { innerText as default };
|
|
8
8
|
//# sourceMappingURL=index3.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { memo, useMemo, useRef, useState, useCallback, useImperativeHandle, useEffect, useId } from 'react';
|
|
4
|
-
import innerText from '../../../_virtual/
|
|
4
|
+
import innerText from '../../../_virtual/index3.js';
|
|
5
5
|
import { tv as ce } from './../../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.17_ts-node@10.9.2_@swc_core@1.13.2_@types_node@20.19.9_typescript@5.8.3__/vendor/tailwind-variants/dist/index.js';
|
|
6
6
|
import { useOuterClick } from '../../../hooks/useOuterClick.js';
|
|
7
7
|
import '../../../intl/IntlProvider.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { useRef, useState, useImperativeHandle, useCallback, useMemo, useEffect } from 'react';
|
|
4
|
-
import innerText from '../../../_virtual/
|
|
4
|
+
import innerText from '../../../_virtual/index3.js';
|
|
5
5
|
import { tv as ce } from './../../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.17_ts-node@10.9.2_@swc_core@1.13.2_@types_node@20.19.9_typescript@5.8.3__/vendor/tailwind-variants/dist/index.js';
|
|
6
6
|
import { useClick } from '../../../hooks/useClick.js';
|
|
7
7
|
import { useDecorators } from '../../../hooks/useDecorators.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useId, useMemo } from 'react';
|
|
2
|
-
import innerText from '../../_virtual/
|
|
2
|
+
import innerText from '../../_virtual/index3.js';
|
|
3
3
|
import { areItemsEqual, convertMatchableString } from './helper.js';
|
|
4
4
|
|
|
5
5
|
const defaultIsItemSelected = (targetItem, selectedItems) => selectedItems.some((item) => areItemsEqual(item, targetItem));
|
|
@@ -86,7 +86,7 @@ const StepFormDialogContentInner = ({ children, title, titleId, subtitle, titleT
|
|
|
86
86
|
}), [localize]);
|
|
87
87
|
const decorated = useDecorators(decoratorDefaultTexts, decorators);
|
|
88
88
|
const actionText = activeStep === stepLength ? submitLabel : decorated.nextButtonLabel;
|
|
89
|
-
const stepText = `(${activeStep}/${stepLength}
|
|
89
|
+
const stepText = stepLength > 1 ? `(${activeStep}/${stepLength})` : '';
|
|
90
90
|
const calcedResponseStatus = useResponseStatus(responseStatus);
|
|
91
91
|
return (
|
|
92
92
|
// eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content, smarthr/a11y-prohibit-sectioning-content-in-form
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepFormDialogContentInner.js","sources":["../../../../src/components/Dialog/StepFormDialog/StepFormDialogContentInner.tsx"],"sourcesContent":["'use client'\n\nimport {\n type FC,\n type FormEvent,\n type PropsWithChildren,\n type ReactNode,\n useCallback,\n useContext,\n useMemo,\n} from 'react'\n\nimport { type DecoratorsType, useDecorators } from '../../../hooks/useDecorators'\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 { DialogHeader, type Props as DialogHeaderProps } from '../DialogHeader'\nimport { dialogContentInner } from '../dialogInnerStyle'\n\nimport { StepFormDialogContext, type StepItem } from './StepFormDialogProvider'\n\nexport type BaseProps = PropsWithChildren<\n DialogHeaderProps &\n DialogBodyProps & {\n /** アクションボタンのラベル */\n submitLabel: ReactNode\n /** アクションボタンのスタイル */\n actionTheme?: 'primary' | 'secondary' | 'danger'\n /**\n * アクションボタンをクリックした時に発火するコールバック関数\n * @param closeDialog ダイアログを閉じる関数\n * @param currentStep onSubmitが発火した時のステップ\n * @returns 次のステップに遷移する場合は次のステップ、遷移しない場合はundefined\n */\n onSubmit: (\n closeDialog: () => void,\n e: FormEvent<HTMLFormElement>,\n currentStep: StepItem,\n ) => StepItem | undefined\n /** アクションボタンを無効にするかどうか */\n actionDisabled?: boolean\n /** 閉じるボタンを無効にするかどうか */\n closeDisabled?: boolean\n /** コンポーネント内の文言を変更するための関数を設定 */\n decorators?: DecoratorsType<DecoratorKeyTypes>\n }\n>\n\nexport type StepFormDialogContentInnerProps = BaseProps & {\n firstStep: StepItem\n onClickClose: () => void\n responseStatus?: ResponseStatus\n /** ステップの総数 */\n stepLength: number\n onClickBack?: () => void\n}\n\ntype DecoratorKeyTypes = 'closeButtonLabel' | 'nextButtonLabel' | 'backButtonLabel'\n\nconst BUTTON_COLUMN_GAP = {\n row: 0.5,\n column: 1,\n} as const\n\nexport const StepFormDialogContentInner: FC<StepFormDialogContentInnerProps> = ({\n children,\n title,\n titleId,\n subtitle,\n titleTag,\n contentBgColor,\n contentPadding,\n submitLabel,\n actionTheme = 'primary',\n stepLength,\n firstStep,\n onSubmit,\n onClickClose,\n responseStatus,\n actionDisabled,\n closeDisabled,\n decorators,\n onClickBack,\n}) => {\n const { localize } = useIntl()\n const { currentStep, stepQueue, setCurrentStep, scrollerRef } = useContext(StepFormDialogContext)\n const activeStep = useMemo(() => currentStep?.stepNumber ?? 1, [currentStep])\n\n const handleCloseAction = useCallback(() => {\n onClickClose()\n setTimeout(() => {\n // HINT: ダイアログが閉じるtransitionが完了してから初期化をしている\n stepQueue.current = []\n setCurrentStep(firstStep)\n }, 300)\n }, [firstStep, stepQueue, setCurrentStep, onClickClose])\n\n const changeCurrentStep = useCallback(\n (step: Parameters<typeof setCurrentStep>[0]) => {\n setCurrentStep(step)\n\n // HINT: stepが切り替わるごとにbodyのscroll位置を先頭に戻す処理\n if (scrollerRef.current) {\n scrollerRef.current.scroll(0, 0)\n }\n },\n [setCurrentStep, scrollerRef],\n )\n\n const handleSubmitAction = useCallback(\n (e: FormEvent<HTMLFormElement>) => {\n e.preventDefault()\n // HINT: React Potals などで擬似的にformがネストしている場合など、stopPropagationを実行しないと\n // 親formが意図せずsubmitされてしまう場合がある\n e.stopPropagation()\n\n const next = onSubmit(handleCloseAction, e, currentStep)\n\n if (next) {\n stepQueue.current.push(currentStep)\n changeCurrentStep(next)\n }\n },\n [currentStep, stepQueue, onSubmit, handleCloseAction, changeCurrentStep],\n )\n const handleBackAction = useCallback(() => {\n onClickBack?.()\n\n changeCurrentStep(stepQueue.current.pop() ?? firstStep)\n }, [firstStep, stepQueue, onClickBack, changeCurrentStep])\n\n const classNames = 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 const decoratorDefaultTexts = useMemo(\n () => ({\n closeButtonLabel: localize({\n id: 'smarthr-ui/StepFormDialog/closeButtonLabel',\n defaultText: 'キャンセル',\n }),\n nextButtonLabel: localize({\n id: 'smarthr-ui/StepFormDialog/nextButtonLabel',\n defaultText: '次へ',\n }),\n backButtonLabel: localize({\n id: 'smarthr-ui/StepFormDialog/backButtonLabel',\n defaultText: '戻る',\n }),\n }),\n [localize],\n )\n\n const decorated = useDecorators<DecoratorKeyTypes>(decoratorDefaultTexts, decorators)\n const actionText = activeStep === stepLength ? submitLabel : decorated.nextButtonLabel\n const stepText = `(${activeStep}/${stepLength}
|
|
1
|
+
{"version":3,"file":"StepFormDialogContentInner.js","sources":["../../../../src/components/Dialog/StepFormDialog/StepFormDialogContentInner.tsx"],"sourcesContent":["'use client'\n\nimport {\n type FC,\n type FormEvent,\n type PropsWithChildren,\n type ReactNode,\n useCallback,\n useContext,\n useMemo,\n} from 'react'\n\nimport { type DecoratorsType, useDecorators } from '../../../hooks/useDecorators'\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 { DialogHeader, type Props as DialogHeaderProps } from '../DialogHeader'\nimport { dialogContentInner } from '../dialogInnerStyle'\n\nimport { StepFormDialogContext, type StepItem } from './StepFormDialogProvider'\n\nexport type BaseProps = PropsWithChildren<\n DialogHeaderProps &\n DialogBodyProps & {\n /** アクションボタンのラベル */\n submitLabel: ReactNode\n /** アクションボタンのスタイル */\n actionTheme?: 'primary' | 'secondary' | 'danger'\n /**\n * アクションボタンをクリックした時に発火するコールバック関数\n * @param closeDialog ダイアログを閉じる関数\n * @param currentStep onSubmitが発火した時のステップ\n * @returns 次のステップに遷移する場合は次のステップ、遷移しない場合はundefined\n */\n onSubmit: (\n closeDialog: () => void,\n e: FormEvent<HTMLFormElement>,\n currentStep: StepItem,\n ) => StepItem | undefined\n /** アクションボタンを無効にするかどうか */\n actionDisabled?: boolean\n /** 閉じるボタンを無効にするかどうか */\n closeDisabled?: boolean\n /** コンポーネント内の文言を変更するための関数を設定 */\n decorators?: DecoratorsType<DecoratorKeyTypes>\n }\n>\n\nexport type StepFormDialogContentInnerProps = BaseProps & {\n firstStep: StepItem\n onClickClose: () => void\n responseStatus?: ResponseStatus\n /** ステップの総数 */\n stepLength: number\n onClickBack?: () => void\n}\n\ntype DecoratorKeyTypes = 'closeButtonLabel' | 'nextButtonLabel' | 'backButtonLabel'\n\nconst BUTTON_COLUMN_GAP = {\n row: 0.5,\n column: 1,\n} as const\n\nexport const StepFormDialogContentInner: FC<StepFormDialogContentInnerProps> = ({\n children,\n title,\n titleId,\n subtitle,\n titleTag,\n contentBgColor,\n contentPadding,\n submitLabel,\n actionTheme = 'primary',\n stepLength,\n firstStep,\n onSubmit,\n onClickClose,\n responseStatus,\n actionDisabled,\n closeDisabled,\n decorators,\n onClickBack,\n}) => {\n const { localize } = useIntl()\n const { currentStep, stepQueue, setCurrentStep, scrollerRef } = useContext(StepFormDialogContext)\n const activeStep = useMemo(() => currentStep?.stepNumber ?? 1, [currentStep])\n\n const handleCloseAction = useCallback(() => {\n onClickClose()\n setTimeout(() => {\n // HINT: ダイアログが閉じるtransitionが完了してから初期化をしている\n stepQueue.current = []\n setCurrentStep(firstStep)\n }, 300)\n }, [firstStep, stepQueue, setCurrentStep, onClickClose])\n\n const changeCurrentStep = useCallback(\n (step: Parameters<typeof setCurrentStep>[0]) => {\n setCurrentStep(step)\n\n // HINT: stepが切り替わるごとにbodyのscroll位置を先頭に戻す処理\n if (scrollerRef.current) {\n scrollerRef.current.scroll(0, 0)\n }\n },\n [setCurrentStep, scrollerRef],\n )\n\n const handleSubmitAction = useCallback(\n (e: FormEvent<HTMLFormElement>) => {\n e.preventDefault()\n // HINT: React Potals などで擬似的にformがネストしている場合など、stopPropagationを実行しないと\n // 親formが意図せずsubmitされてしまう場合がある\n e.stopPropagation()\n\n const next = onSubmit(handleCloseAction, e, currentStep)\n\n if (next) {\n stepQueue.current.push(currentStep)\n changeCurrentStep(next)\n }\n },\n [currentStep, stepQueue, onSubmit, handleCloseAction, changeCurrentStep],\n )\n const handleBackAction = useCallback(() => {\n onClickBack?.()\n\n changeCurrentStep(stepQueue.current.pop() ?? firstStep)\n }, [firstStep, stepQueue, onClickBack, changeCurrentStep])\n\n const classNames = 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 const decoratorDefaultTexts = useMemo(\n () => ({\n closeButtonLabel: localize({\n id: 'smarthr-ui/StepFormDialog/closeButtonLabel',\n defaultText: 'キャンセル',\n }),\n nextButtonLabel: localize({\n id: 'smarthr-ui/StepFormDialog/nextButtonLabel',\n defaultText: '次へ',\n }),\n backButtonLabel: localize({\n id: 'smarthr-ui/StepFormDialog/backButtonLabel',\n defaultText: '戻る',\n }),\n }),\n [localize],\n )\n\n const decorated = useDecorators<DecoratorKeyTypes>(decoratorDefaultTexts, decorators)\n const actionText = activeStep === stepLength ? submitLabel : decorated.nextButtonLabel\n const stepText = stepLength > 1 ? `(${activeStep}/${stepLength})` : ''\n\n const calcedResponseStatus = useResponseStatus(responseStatus)\n\n return (\n // eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content, smarthr/a11y-prohibit-sectioning-content-in-form\n <Section>\n <form onSubmit={handleSubmitAction}>\n <div className={classNames.wrapper}>\n <DialogHeader\n title={subtitle ? title : `${title}${stepText}`}\n subtitle={subtitle ? `${subtitle}${stepText}` : undefined}\n titleTag={titleTag}\n titleId={titleId}\n />\n <DialogBody\n contentPadding={contentPadding}\n contentBgColor={contentBgColor}\n ref={scrollerRef}\n >\n {children}\n </DialogBody>\n <Stack gap={0.5} className={classNames.actionArea}>\n <Cluster justify=\"space-between\" gap={{ row: 0.5, column: 2 }}>\n {activeStep > 1 && (\n <Button\n onClick={handleBackAction}\n disabled={calcedResponseStatus.isProcessing}\n className=\"smarthr-ui-Dialog-backButton\"\n >\n {decorated.backButtonLabel}\n </Button>\n )}\n <Cluster gap={BUTTON_COLUMN_GAP} className={classNames.buttonArea}>\n <Button\n onClick={handleCloseAction}\n disabled={closeDisabled || calcedResponseStatus.isProcessing}\n className=\"smarthr-ui-Dialog-closeButton\"\n >\n {decorated.closeButtonLabel}\n </Button>\n <Button\n type=\"submit\"\n variant={actionTheme}\n disabled={actionDisabled}\n loading={calcedResponseStatus.isProcessing}\n className=\"smarthr-ui-Dialog-actionButton\"\n >\n {actionText}\n </Button>\n </Cluster>\n </Cluster>\n <DialogContentResponseStatusMessage\n responseStatus={calcedResponseStatus}\n className={classNames.message}\n />\n </Stack>\n </div>\n </form>\n </Section>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+DA;AACE;AACA;;;AAuBA;AACA;AACA;AAEA;AACE;;;AAGE;;;;AAKJ;;;AAKI;;;AAGF;AAIF;;;;;;;AAUM;;;AAGJ;AAGF;;;;AAMA;AACE;;;;;;;;AAUF;;AAGM;AACA;;;AAGA;AACA;;;AAGA;AACA;;AAEH;;AAKH;AACA;AAEA;;;;AA2DF;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { memo, useContext, useMemo, useRef, Children, isValidElement, Fragment, cloneElement } from 'react';
|
|
4
|
-
import innerText from '../../../_virtual/
|
|
4
|
+
import innerText from '../../../_virtual/index3.js';
|
|
5
5
|
import { tv as ce } from './../../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.17_ts-node@10.9.2_@swc_core@1.13.2_@types_node@20.19.9_typescript@5.8.3__/vendor/tailwind-variants/dist/index.js';
|
|
6
6
|
import { DropdownContext, Dropdown } from '../Dropdown.js';
|
|
7
7
|
import { DropdownTrigger } from '../DropdownTrigger.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
-
import innerText from '../../../_virtual/
|
|
4
|
+
import innerText from '../../../_virtual/index3.js';
|
|
5
5
|
import { tv as ce } from './../../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.17_ts-node@10.9.2_@swc_core@1.13.2_@types_node@20.19.9_typescript@5.8.3__/vendor/tailwind-variants/dist/index.js';
|
|
6
6
|
import { useDecorators } from '../../../hooks/useDecorators.js';
|
|
7
7
|
import { useResponseStatus } from '../../../hooks/useResponseStatus.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { memo, useMemo, useId, useRef, Fragment as Fragment$1, createElement, useEffect } from 'react';
|
|
3
3
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
4
|
-
import innerText from '../../_virtual/
|
|
4
|
+
import innerText from '../../_virtual/index3.js';
|
|
5
5
|
import { tv as ce } from './../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.17_ts-node@10.9.2_@swc_core@1.13.2_@types_node@20.19.9_typescript@5.8.3__/vendor/tailwind-variants/dist/index.js';
|
|
6
6
|
import { FaCircleExclamationIcon } from '../Icon/Icon.js';
|
|
7
7
|
import '../Icon/generateIcon.js';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { memo, useMemo, useState, useRef, useId, useSyncExternalStore, useCallback, cloneElement } from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
|
-
import innerText from '../../_virtual/
|
|
5
|
+
import innerText from '../../_virtual/index3.js';
|
|
6
6
|
import { tv as ce } from './../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.17_ts-node@10.9.2_@swc_core@1.13.2_@types_node@20.19.9_typescript@5.8.3__/vendor/tailwind-variants/dist/index.js';
|
|
7
7
|
import { useEnhancedEffect } from '../../hooks/useEnhancedEffect.js';
|
|
8
8
|
import { VisuallyHiddenText } from '../VisuallyHiddenText/VisuallyHiddenText.js';
|
package/esm/libs/lodash.js
CHANGED
|
@@ -78,7 +78,7 @@ const StepFormDialogContentInner = ({ children, title, titleId, subtitle, titleT
|
|
|
78
78
|
}), [localize]);
|
|
79
79
|
const decorated = (0, useDecorators_1.useDecorators)(decoratorDefaultTexts, decorators);
|
|
80
80
|
const actionText = activeStep === stepLength ? submitLabel : decorated.nextButtonLabel;
|
|
81
|
-
const stepText = `(${activeStep}/${stepLength}
|
|
81
|
+
const stepText = stepLength > 1 ? `(${activeStep}/${stepLength})` : '';
|
|
82
82
|
const calcedResponseStatus = (0, useResponseStatus_1.useResponseStatus)(responseStatus);
|
|
83
83
|
return (
|
|
84
84
|
// eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content, smarthr/a11y-prohibit-sectioning-content-in-form
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepFormDialogContentInner.js","sourceRoot":"","sources":["../../../../src/components/Dialog/StepFormDialog/StepFormDialogContentInner.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;AAEZ,iCAQc;AAEd,gEAAiF;AACjF,wEAAyF;AACzF,wCAAuC;AACvC,yCAAqC;AACrC,yCAA6C;AAC7C,+DAAiD;AACjD,8CAAyE;AACzE,8FAA0F;AAC1F,kDAA+E;AAC/E,0DAAwD;AAExD,qEAA+E;AAwC/E,MAAM,iBAAiB,GAAG;IACxB,GAAG,EAAE,GAAG;IACR,MAAM,EAAE,CAAC;CACD,CAAA;AAEH,MAAM,0BAA0B,GAAwC,CAAC,EAC9E,QAAQ,EACR,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,cAAc,EACd,WAAW,EACX,WAAW,G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C,8BAA8B,YAEvC,SAAS,CAAC,eAAe,GACnB,CACV,EACD,wBAAC,gBAAO,IAAC,GAAG,EAAE,iBAAiB,EAAE,SAAS,EAAE,UAAU,CAAC,UAAU,aAC/D,uBAAC,eAAM,IACL,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,aAAa,IAAI,oBAAoB,CAAC,YAAY,EAC5D,SAAS,EAAC,+BAA+B,YAExC,SAAS,CAAC,gBAAgB,GACpB,EACT,uBAAC,eAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,oBAAoB,CAAC,YAAY,EAC1C,SAAS,EAAC,gCAAgC,YAEzC,UAAU,GACJ,IACD,IACF,EACV,uBAAC,uEAAkC,IACjC,cAAc,EAAE,oBAAoB,EACpC,SAAS,EAAE,UAAU,CAAC,OAAO,GAC7B,IACI,IACJ,GACD,GACC,CACX,CAAA;AACH,CAAC,CAAA;AA/JY,QAAA,0BAA0B,8BA+JtC","sourcesContent":["'use client'\n\nimport {\n type FC,\n type FormEvent,\n type PropsWithChildren,\n type ReactNode,\n useCallback,\n useContext,\n useMemo,\n} from 'react'\n\nimport { type DecoratorsType, useDecorators } from '../../../hooks/useDecorators'\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 { DialogHeader, type Props as DialogHeaderProps } from '../DialogHeader'\nimport { dialogContentInner } from '../dialogInnerStyle'\n\nimport { StepFormDialogContext, type StepItem } from './StepFormDialogProvider'\n\nexport type BaseProps = PropsWithChildren<\n DialogHeaderProps &\n DialogBodyProps & {\n /** アクションボタンのラベル */\n submitLabel: ReactNode\n /** アクションボタンのスタイル */\n actionTheme?: 'primary' | 'secondary' | 'danger'\n /**\n * アクションボタンをクリックした時に発火するコールバック関数\n * @param closeDialog ダイアログを閉じる関数\n * @param currentStep onSubmitが発火した時のステップ\n * @returns 次のステップに遷移する場合は次のステップ、遷移しない場合はundefined\n */\n onSubmit: (\n closeDialog: () => void,\n e: FormEvent<HTMLFormElement>,\n currentStep: StepItem,\n ) => StepItem | undefined\n /** アクションボタンを無効にするかどうか */\n actionDisabled?: boolean\n /** 閉じるボタンを無効にするかどうか */\n closeDisabled?: boolean\n /** コンポーネント内の文言を変更するための関数を設定 */\n decorators?: DecoratorsType<DecoratorKeyTypes>\n }\n>\n\nexport type StepFormDialogContentInnerProps = BaseProps & {\n firstStep: StepItem\n onClickClose: () => void\n responseStatus?: ResponseStatus\n /** ステップの総数 */\n stepLength: number\n onClickBack?: () => void\n}\n\ntype DecoratorKeyTypes = 'closeButtonLabel' | 'nextButtonLabel' | 'backButtonLabel'\n\nconst BUTTON_COLUMN_GAP = {\n row: 0.5,\n column: 1,\n} as const\n\nexport const StepFormDialogContentInner: FC<StepFormDialogContentInnerProps> = ({\n children,\n title,\n titleId,\n subtitle,\n titleTag,\n contentBgColor,\n contentPadding,\n submitLabel,\n actionTheme = 'primary',\n stepLength,\n firstStep,\n onSubmit,\n onClickClose,\n responseStatus,\n actionDisabled,\n closeDisabled,\n decorators,\n onClickBack,\n}) => {\n const { localize } = useIntl()\n const { currentStep, stepQueue, setCurrentStep, scrollerRef } = useContext(StepFormDialogContext)\n const activeStep = useMemo(() => currentStep?.stepNumber ?? 1, [currentStep])\n\n const handleCloseAction = useCallback(() => {\n onClickClose()\n setTimeout(() => {\n // HINT: ダイアログが閉じるtransitionが完了してから初期化をしている\n stepQueue.current = []\n setCurrentStep(firstStep)\n }, 300)\n }, [firstStep, stepQueue, setCurrentStep, onClickClose])\n\n const changeCurrentStep = useCallback(\n (step: Parameters<typeof setCurrentStep>[0]) => {\n setCurrentStep(step)\n\n // HINT: stepが切り替わるごとにbodyのscroll位置を先頭に戻す処理\n if (scrollerRef.current) {\n scrollerRef.current.scroll(0, 0)\n }\n },\n [setCurrentStep, scrollerRef],\n )\n\n const handleSubmitAction = useCallback(\n (e: FormEvent<HTMLFormElement>) => {\n e.preventDefault()\n // HINT: React Potals などで擬似的にformがネストしている場合など、stopPropagationを実行しないと\n // 親formが意図せずsubmitされてしまう場合がある\n e.stopPropagation()\n\n const next = onSubmit(handleCloseAction, e, currentStep)\n\n if (next) {\n stepQueue.current.push(currentStep)\n changeCurrentStep(next)\n }\n },\n [currentStep, stepQueue, onSubmit, handleCloseAction, changeCurrentStep],\n )\n const handleBackAction = useCallback(() => {\n onClickBack?.()\n\n changeCurrentStep(stepQueue.current.pop() ?? firstStep)\n }, [firstStep, stepQueue, onClickBack, changeCurrentStep])\n\n const classNames = 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 const decoratorDefaultTexts = useMemo(\n () => ({\n closeButtonLabel: localize({\n id: 'smarthr-ui/StepFormDialog/closeButtonLabel',\n defaultText: 'キャンセル',\n }),\n nextButtonLabel: localize({\n id: 'smarthr-ui/StepFormDialog/nextButtonLabel',\n defaultText: '次へ',\n }),\n backButtonLabel: localize({\n id: 'smarthr-ui/StepFormDialog/backButtonLabel',\n defaultText: '戻る',\n }),\n }),\n [localize],\n )\n\n const decorated = useDecorators<DecoratorKeyTypes>(decoratorDefaultTexts, decorators)\n const actionText = activeStep === stepLength ? submitLabel : decorated.nextButtonLabel\n const stepText = `(${activeStep}/${stepLength})`\n\n const calcedResponseStatus = useResponseStatus(responseStatus)\n\n return (\n // eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content, smarthr/a11y-prohibit-sectioning-content-in-form\n <Section>\n <form onSubmit={handleSubmitAction}>\n <div className={classNames.wrapper}>\n <DialogHeader\n title={subtitle ? title : `${title}${stepText}`}\n subtitle={subtitle ? `${subtitle}${stepText}` : undefined}\n titleTag={titleTag}\n titleId={titleId}\n />\n <DialogBody\n contentPadding={contentPadding}\n contentBgColor={contentBgColor}\n ref={scrollerRef}\n >\n {children}\n </DialogBody>\n <Stack gap={0.5} className={classNames.actionArea}>\n <Cluster justify=\"space-between\" gap={{ row: 0.5, column: 2 }}>\n {activeStep > 1 && (\n <Button\n onClick={handleBackAction}\n disabled={calcedResponseStatus.isProcessing}\n className=\"smarthr-ui-Dialog-backButton\"\n >\n {decorated.backButtonLabel}\n </Button>\n )}\n <Cluster gap={BUTTON_COLUMN_GAP} className={classNames.buttonArea}>\n <Button\n onClick={handleCloseAction}\n disabled={closeDisabled || calcedResponseStatus.isProcessing}\n className=\"smarthr-ui-Dialog-closeButton\"\n >\n {decorated.closeButtonLabel}\n </Button>\n <Button\n type=\"submit\"\n variant={actionTheme}\n disabled={actionDisabled}\n loading={calcedResponseStatus.isProcessing}\n className=\"smarthr-ui-Dialog-actionButton\"\n >\n {actionText}\n </Button>\n </Cluster>\n </Cluster>\n <DialogContentResponseStatusMessage\n responseStatus={calcedResponseStatus}\n className={classNames.message}\n />\n </Stack>\n </div>\n </form>\n </Section>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"StepFormDialogContentInner.js","sourceRoot":"","sources":["../../../../src/components/Dialog/StepFormDialog/StepFormDialogContentInner.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;AAEZ,iCAQc;AAEd,gEAAiF;AACjF,wEAAyF;AACzF,wCAAuC;AACvC,yCAAqC;AACrC,yCAA6C;AAC7C,+DAAiD;AACjD,8CAAyE;AACzE,8FAA0F;AAC1F,kDAA+E;AAC/E,0DAAwD;AAExD,qEAA+E;AAwC/E,MAAM,iBAAiB,GAAG;IACxB,GAAG,EAAE,GAAG;IACR,MAAM,EAAE,CAAC;CACD,CAAA;AAEH,MAAM,0BAA0B,GAAwC,CAAC,EAC9E,QAAQ,EACR,KAAK,EACL,OAAO,EACP,QAAQ,EACR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CAAC,IAAI,CACjB,uBAAC,eAAM,IACL,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,oBAAoB,CAAC,YAAY,EAC3C,SAAS,EAAC,8BAA8B,YAEvC,SAAS,CAAC,eAAe,GACnB,CACV,EACD,wBAAC,gBAAO,IAAC,GAAG,EAAE,iBAAiB,EAAE,SAAS,EAAE,UAAU,CAAC,UAAU,aAC/D,uBAAC,eAAM,IACL,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,aAAa,IAAI,oBAAoB,CAAC,YAAY,EAC5D,SAAS,EAAC,+BAA+B,YAExC,SAAS,CAAC,gBAAgB,GACpB,EACT,uBAAC,eAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,oBAAoB,CAAC,YAAY,EAC1C,SAAS,EAAC,gCAAgC,YAEzC,UAAU,GACJ,IACD,IACF,EACV,uBAAC,uEAAkC,IACjC,cAAc,EAAE,oBAAoB,EACpC,SAAS,EAAE,UAAU,CAAC,OAAO,GAC7B,IACI,IACJ,GACD,GACC,CACX,CAAA;AACH,CAAC,CAAA;AA/JY,QAAA,0BAA0B,8BA+JtC","sourcesContent":["'use client'\n\nimport {\n type FC,\n type FormEvent,\n type PropsWithChildren,\n type ReactNode,\n useCallback,\n useContext,\n useMemo,\n} from 'react'\n\nimport { type DecoratorsType, useDecorators } from '../../../hooks/useDecorators'\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 { DialogHeader, type Props as DialogHeaderProps } from '../DialogHeader'\nimport { dialogContentInner } from '../dialogInnerStyle'\n\nimport { StepFormDialogContext, type StepItem } from './StepFormDialogProvider'\n\nexport type BaseProps = PropsWithChildren<\n DialogHeaderProps &\n DialogBodyProps & {\n /** アクションボタンのラベル */\n submitLabel: ReactNode\n /** アクションボタンのスタイル */\n actionTheme?: 'primary' | 'secondary' | 'danger'\n /**\n * アクションボタンをクリックした時に発火するコールバック関数\n * @param closeDialog ダイアログを閉じる関数\n * @param currentStep onSubmitが発火した時のステップ\n * @returns 次のステップに遷移する場合は次のステップ、遷移しない場合はundefined\n */\n onSubmit: (\n closeDialog: () => void,\n e: FormEvent<HTMLFormElement>,\n currentStep: StepItem,\n ) => StepItem | undefined\n /** アクションボタンを無効にするかどうか */\n actionDisabled?: boolean\n /** 閉じるボタンを無効にするかどうか */\n closeDisabled?: boolean\n /** コンポーネント内の文言を変更するための関数を設定 */\n decorators?: DecoratorsType<DecoratorKeyTypes>\n }\n>\n\nexport type StepFormDialogContentInnerProps = BaseProps & {\n firstStep: StepItem\n onClickClose: () => void\n responseStatus?: ResponseStatus\n /** ステップの総数 */\n stepLength: number\n onClickBack?: () => void\n}\n\ntype DecoratorKeyTypes = 'closeButtonLabel' | 'nextButtonLabel' | 'backButtonLabel'\n\nconst BUTTON_COLUMN_GAP = {\n row: 0.5,\n column: 1,\n} as const\n\nexport const StepFormDialogContentInner: FC<StepFormDialogContentInnerProps> = ({\n children,\n title,\n titleId,\n subtitle,\n titleTag,\n contentBgColor,\n contentPadding,\n submitLabel,\n actionTheme = 'primary',\n stepLength,\n firstStep,\n onSubmit,\n onClickClose,\n responseStatus,\n actionDisabled,\n closeDisabled,\n decorators,\n onClickBack,\n}) => {\n const { localize } = useIntl()\n const { currentStep, stepQueue, setCurrentStep, scrollerRef } = useContext(StepFormDialogContext)\n const activeStep = useMemo(() => currentStep?.stepNumber ?? 1, [currentStep])\n\n const handleCloseAction = useCallback(() => {\n onClickClose()\n setTimeout(() => {\n // HINT: ダイアログが閉じるtransitionが完了してから初期化をしている\n stepQueue.current = []\n setCurrentStep(firstStep)\n }, 300)\n }, [firstStep, stepQueue, setCurrentStep, onClickClose])\n\n const changeCurrentStep = useCallback(\n (step: Parameters<typeof setCurrentStep>[0]) => {\n setCurrentStep(step)\n\n // HINT: stepが切り替わるごとにbodyのscroll位置を先頭に戻す処理\n if (scrollerRef.current) {\n scrollerRef.current.scroll(0, 0)\n }\n },\n [setCurrentStep, scrollerRef],\n )\n\n const handleSubmitAction = useCallback(\n (e: FormEvent<HTMLFormElement>) => {\n e.preventDefault()\n // HINT: React Potals などで擬似的にformがネストしている場合など、stopPropagationを実行しないと\n // 親formが意図せずsubmitされてしまう場合がある\n e.stopPropagation()\n\n const next = onSubmit(handleCloseAction, e, currentStep)\n\n if (next) {\n stepQueue.current.push(currentStep)\n changeCurrentStep(next)\n }\n },\n [currentStep, stepQueue, onSubmit, handleCloseAction, changeCurrentStep],\n )\n const handleBackAction = useCallback(() => {\n onClickBack?.()\n\n changeCurrentStep(stepQueue.current.pop() ?? firstStep)\n }, [firstStep, stepQueue, onClickBack, changeCurrentStep])\n\n const classNames = 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 const decoratorDefaultTexts = useMemo(\n () => ({\n closeButtonLabel: localize({\n id: 'smarthr-ui/StepFormDialog/closeButtonLabel',\n defaultText: 'キャンセル',\n }),\n nextButtonLabel: localize({\n id: 'smarthr-ui/StepFormDialog/nextButtonLabel',\n defaultText: '次へ',\n }),\n backButtonLabel: localize({\n id: 'smarthr-ui/StepFormDialog/backButtonLabel',\n defaultText: '戻る',\n }),\n }),\n [localize],\n )\n\n const decorated = useDecorators<DecoratorKeyTypes>(decoratorDefaultTexts, decorators)\n const actionText = activeStep === stepLength ? submitLabel : decorated.nextButtonLabel\n const stepText = stepLength > 1 ? `(${activeStep}/${stepLength})` : ''\n\n const calcedResponseStatus = useResponseStatus(responseStatus)\n\n return (\n // eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content, smarthr/a11y-prohibit-sectioning-content-in-form\n <Section>\n <form onSubmit={handleSubmitAction}>\n <div className={classNames.wrapper}>\n <DialogHeader\n title={subtitle ? title : `${title}${stepText}`}\n subtitle={subtitle ? `${subtitle}${stepText}` : undefined}\n titleTag={titleTag}\n titleId={titleId}\n />\n <DialogBody\n contentPadding={contentPadding}\n contentBgColor={contentBgColor}\n ref={scrollerRef}\n >\n {children}\n </DialogBody>\n <Stack gap={0.5} className={classNames.actionArea}>\n <Cluster justify=\"space-between\" gap={{ row: 0.5, column: 2 }}>\n {activeStep > 1 && (\n <Button\n onClick={handleBackAction}\n disabled={calcedResponseStatus.isProcessing}\n className=\"smarthr-ui-Dialog-backButton\"\n >\n {decorated.backButtonLabel}\n </Button>\n )}\n <Cluster gap={BUTTON_COLUMN_GAP} className={classNames.buttonArea}>\n <Button\n onClick={handleCloseAction}\n disabled={closeDisabled || calcedResponseStatus.isProcessing}\n className=\"smarthr-ui-Dialog-closeButton\"\n >\n {decorated.closeButtonLabel}\n </Button>\n <Button\n type=\"submit\"\n variant={actionTheme}\n disabled={actionDisabled}\n loading={calcedResponseStatus.isProcessing}\n className=\"smarthr-ui-Dialog-actionButton\"\n >\n {actionText}\n </Button>\n </Cluster>\n </Cluster>\n <DialogContentResponseStatusMessage\n responseStatus={calcedResponseStatus}\n className={classNames.message}\n />\n </Stack>\n </div>\n </form>\n </Section>\n )\n}\n"]}
|