smarthr-ui 20.1.2 → 20.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/esm/components/Dialog/ActionDialog.d.ts +2 -2
- package/esm/components/Dialog/ActionDialog.js +6 -13
- package/esm/components/Dialog/ActionDialog.js.map +1 -1
- package/esm/components/Dialog/Dialog.d.ts +2 -2
- package/esm/components/Dialog/Dialog.js +5 -12
- package/esm/components/Dialog/Dialog.js.map +1 -1
- package/esm/components/Dialog/DialogWrapper.js +5 -11
- package/esm/components/Dialog/DialogWrapper.js.map +1 -1
- package/esm/components/Dialog/MessageDialog.d.ts +2 -2
- package/esm/components/Dialog/MessageDialog.js +6 -13
- package/esm/components/Dialog/MessageDialog.js.map +1 -1
- package/esm/components/Dialog/ModelessDialog.d.ts +2 -2
- package/esm/components/Dialog/ModelessDialog.js +36 -43
- package/esm/components/Dialog/ModelessDialog.js.map +1 -1
- package/esm/components/Dialog/useDialogPortal.d.ts +7 -0
- package/esm/components/Dialog/useDialogPortal.js +32 -0
- package/esm/components/Dialog/useDialogPortal.js.map +1 -0
- package/esm/components/InformationPanel/InformationPanel.d.ts +3 -3
- package/lib/components/Dialog/ActionDialog.d.ts +2 -2
- package/lib/components/Dialog/ActionDialog.js +5 -12
- package/lib/components/Dialog/ActionDialog.js.map +1 -1
- package/lib/components/Dialog/Dialog.d.ts +2 -2
- package/lib/components/Dialog/Dialog.js +7 -34
- package/lib/components/Dialog/Dialog.js.map +1 -1
- package/lib/components/Dialog/DialogWrapper.js +4 -10
- package/lib/components/Dialog/DialogWrapper.js.map +1 -1
- package/lib/components/Dialog/MessageDialog.d.ts +2 -2
- package/lib/components/Dialog/MessageDialog.js +5 -12
- package/lib/components/Dialog/MessageDialog.js.map +1 -1
- package/lib/components/Dialog/ModelessDialog.d.ts +2 -2
- package/lib/components/Dialog/ModelessDialog.js +36 -43
- package/lib/components/Dialog/ModelessDialog.js.map +1 -1
- package/lib/components/Dialog/useDialogPortal.d.ts +7 -0
- package/lib/components/Dialog/useDialogPortal.js +36 -0
- package/lib/components/Dialog/useDialogPortal.js.map +1 -0
- package/lib/components/InformationPanel/InformationPanel.d.ts +3 -3
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [20.2.0](https://github.com/kufu/smarthr-ui/compare/v20.1.2...v20.2.0) (2022-04-12)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* string to ReactNode ([#2400](https://github.com/kufu/smarthr-ui/issues/2400)) ([200947d](https://github.com/kufu/smarthr-ui/commit/200947dd4483e6171c61c35c1753763d3828a12f))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* ダイアログのポータルが DOM に追加される前に子のライフサイクルが開始されないように修正 ([#2403](https://github.com/kufu/smarthr-ui/issues/2403)) ([062a564](https://github.com/kufu/smarthr-ui/commit/062a5645cbebccf25f0de7ef4e1113e764379066))
|
|
16
|
+
|
|
5
17
|
### [20.1.2](https://github.com/kufu/smarthr-ui/compare/v20.1.1...v20.1.2) (2022-04-06)
|
|
6
18
|
|
|
7
19
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
1
|
+
import React, { HTMLAttributes, RefObject } from 'react';
|
|
2
2
|
import { DialogContentInnerProps } from './DialogContentInner';
|
|
3
3
|
import { ActionDialogContentInnerProps } from './ActionDialogContentInner';
|
|
4
4
|
declare type Props = Omit<ActionDialogContentInnerProps, 'titleId'> & {
|
|
5
5
|
onClickClose: () => void;
|
|
6
|
-
portalParent?: HTMLElement
|
|
6
|
+
portalParent?: HTMLElement | RefObject<HTMLElement>;
|
|
7
7
|
} & Pick<DialogContentInnerProps, 'isOpen' | 'onClickOverlay' | 'onPressEscape' | 'width' | 'top' | 'right' | 'bottom' | 'left' | 'id'>;
|
|
8
8
|
declare type ElementProps = Omit<HTMLAttributes<HTMLDivElement>, keyof Props>;
|
|
9
9
|
export declare const ActionDialog: React.VFC<Props & ElementProps>;
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import React, { useCallback
|
|
2
|
-
import { createPortal } from 'react-dom';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
3
2
|
import { useId } from '../../hooks/useId';
|
|
3
|
+
import { useDialogPortal } from './useDialogPortal';
|
|
4
4
|
import { DialogContentInner } from './DialogContentInner';
|
|
5
5
|
import { ActionDialogContentInner } from './ActionDialogContentInner';
|
|
6
6
|
export const ActionDialog = ({ children, title, subtitle, closeText, actionText, actionTheme, onClickAction, onClickClose, responseMessage, actionDisabled = false, closeDisabled, className = '', portalParent, ...props }) => {
|
|
7
|
-
const
|
|
7
|
+
const { Portal } = useDialogPortal(portalParent);
|
|
8
8
|
const titleId = useId();
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
// SSR を考慮し、useEffect 内で初期値 document.body を指定
|
|
11
|
-
const pp = portalParent || document.body;
|
|
12
|
-
pp.appendChild(portalContainer);
|
|
13
|
-
return () => {
|
|
14
|
-
pp.removeChild(portalContainer);
|
|
15
|
-
};
|
|
16
|
-
}, [portalContainer, portalParent]);
|
|
17
9
|
const handleClickClose = useCallback(() => {
|
|
18
10
|
if (!props.isOpen) {
|
|
19
11
|
return;
|
|
@@ -26,7 +18,8 @@ export const ActionDialog = ({ children, title, subtitle, closeText, actionText,
|
|
|
26
18
|
}
|
|
27
19
|
onClickAction(onClickClose);
|
|
28
20
|
}, [onClickAction, onClickClose, props.isOpen]);
|
|
29
|
-
return
|
|
30
|
-
React.createElement(
|
|
21
|
+
return (React.createElement(Portal, null,
|
|
22
|
+
React.createElement(DialogContentInner, { ariaLabelledby: titleId, className: className, ...props },
|
|
23
|
+
React.createElement(ActionDialogContentInner, { title: title, titleId: titleId, subtitle: subtitle, closeText: closeText, actionText: actionText, actionTheme: actionTheme, actionDisabled: actionDisabled, closeDisabled: closeDisabled, onClickClose: handleClickClose, onClickAction: handleClickAction, responseMessage: responseMessage }, children))));
|
|
31
24
|
};
|
|
32
25
|
//# sourceMappingURL=ActionDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/ActionDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ActionDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/ActionDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA6B,WAAW,EAAE,MAAM,OAAO,CAAA;AAErE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAA2B,MAAM,sBAAsB,CAAA;AAClF,OAAO,EAAE,wBAAwB,EAAiC,MAAM,4BAA4B,CAAA;AAmBpG,MAAM,CAAC,MAAM,YAAY,GAAoC,CAAC,EAC5D,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,SAAS,EACT,UAAU,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,cAAc,GAAG,KAAK,EACtB,aAAa,EACb,SAAS,GAAG,EAAE,EACd,YAAY,EACZ,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC,YAAY,CAAC,CAAA;IAChD,MAAM,OAAO,GAAG,KAAK,EAAE,CAAA;IAEvB,MAAM,gBAAgB,GAAG,WAAW,CAAC,GAAG,EAAE;QACxC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACjB,OAAM;SACP;QACD,YAAY,EAAE,CAAA;IAChB,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAEhC,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,EAAE;QACzC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACjB,OAAM;SACP;QACD,aAAa,CAAC,YAAY,CAAC,CAAA;IAC7B,CAAC,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAE/C,OAAO,CACL,oBAAC,MAAM;QACL,oBAAC,kBAAkB,IAAC,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,KAAM,KAAK;YAC1E,oBAAC,wBAAwB,IACvB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,gBAAgB,EAC9B,aAAa,EAAE,iBAAiB,EAChC,eAAe,EAAE,eAAe,IAE/B,QAAQ,CACgB,CACR,CACd,CACV,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
1
|
+
import React, { HTMLAttributes, RefObject } from 'react';
|
|
2
2
|
import { DialogContentInnerProps } from './DialogContentInner';
|
|
3
3
|
declare type Props = DialogContentInnerProps & {
|
|
4
|
-
portalParent?: HTMLElement
|
|
4
|
+
portalParent?: HTMLElement | RefObject<HTMLElement>;
|
|
5
5
|
};
|
|
6
6
|
declare type ElementProps = Omit<HTMLAttributes<HTMLDivElement>, keyof Props>;
|
|
7
7
|
export declare const Dialog: React.VFC<Props & ElementProps>;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useDialogPortal } from './useDialogPortal';
|
|
3
3
|
import { DialogContentInner } from './DialogContentInner';
|
|
4
4
|
export const Dialog = ({ children, className = '', portalParent, ...props }) => {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const pp = portalParent || document.body;
|
|
9
|
-
pp.appendChild(portalContainer);
|
|
10
|
-
return () => {
|
|
11
|
-
pp.removeChild(portalContainer);
|
|
12
|
-
};
|
|
13
|
-
}, [portalContainer, portalParent]);
|
|
14
|
-
return createPortal(React.createElement(DialogContentInner, { className: className, ...props }, children), portalContainer);
|
|
5
|
+
const { Portal } = useDialogPortal(portalParent);
|
|
6
|
+
return (React.createElement(Portal, null,
|
|
7
|
+
React.createElement(DialogContentInner, { className: className, ...props }, children)));
|
|
15
8
|
};
|
|
16
9
|
//# sourceMappingURL=Dialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAA;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAA2B,MAAM,sBAAsB,CAAA;AAKlF,MAAM,CAAC,MAAM,MAAM,GAAoC,CAAC,EACtD,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,YAAY,EACZ,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC,YAAY,CAAC,CAAA;IAEhD,OAAO,CACL,oBAAC,MAAM;QACL,oBAAC,kBAAkB,IAAC,SAAS,EAAE,SAAS,KAAM,KAAK,IAChD,QAAQ,CACU,CACd,CACV,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { createContext,
|
|
2
|
-
import {
|
|
1
|
+
import React, { createContext, useMemo, useState } from 'react';
|
|
2
|
+
import { useDialogPortal } from './useDialogPortal';
|
|
3
3
|
export const DialogContext = createContext({
|
|
4
4
|
onClickTrigger: () => {
|
|
5
5
|
/* noop */
|
|
@@ -12,17 +12,11 @@ export const DialogContext = createContext({
|
|
|
12
12
|
});
|
|
13
13
|
export const DialogWrapper = ({ children }) => {
|
|
14
14
|
const [active, setActive] = useState(false);
|
|
15
|
-
const
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
document.body.appendChild(element);
|
|
18
|
-
return () => {
|
|
19
|
-
document.body.removeChild(element);
|
|
20
|
-
};
|
|
21
|
-
}, [element]);
|
|
15
|
+
const { Portal } = useDialogPortal();
|
|
22
16
|
// This is the root container of a dialog content located in outside the DOM tree
|
|
23
17
|
const DialogContentRoot = useMemo(() => (props) => {
|
|
24
|
-
return
|
|
25
|
-
}, [
|
|
18
|
+
return React.createElement(Portal, null, props.children);
|
|
19
|
+
}, [Portal]);
|
|
26
20
|
// set the displayName explicit for DevTools
|
|
27
21
|
DialogContentRoot.displayName = 'DialogContentRoot';
|
|
28
22
|
return (React.createElement(DialogContext.Provider, { value: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogWrapper.js","sourceRoot":"","sources":["../../../src/components/Dialog/DialogWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"DialogWrapper.js","sourceRoot":"","sources":["../../../src/components/Dialog/DialogWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AASnD,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAoB;IAC5D,cAAc,EAAE,GAAG,EAAE;QACnB,UAAU;IACZ,CAAC;IACD,YAAY,EAAE,GAAG,EAAE;QACjB,UAAU;IACZ,CAAC;IACD,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI;IAC7B,MAAM,EAAE,KAAK;CACd,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,aAAa,GAA8C,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IACvF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,EAAE,CAAA;IAEpC,iFAAiF;IACjF,MAAM,iBAAiB,GAAG,OAAO,CAC/B,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE;QACd,OAAO,oBAAC,MAAM,QAAE,KAAK,CAAC,QAAQ,CAAU,CAAA;IAC1C,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAA;IACD,4CAA4C;IAC5C,iBAAiB,CAAC,WAAW,GAAG,mBAAmB,CAAA;IAEnD,OAAO,CACL,oBAAC,aAAa,CAAC,QAAQ,IACrB,KAAK,EAAE;YACL,cAAc,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;YACrC,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;YACpC,iBAAiB;YACjB,MAAM;SACP,IAEA,QAAQ,CACc,CAC1B,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
1
|
+
import React, { HTMLAttributes, RefObject } from 'react';
|
|
2
2
|
import { DialogContentInnerProps } from './DialogContentInner';
|
|
3
3
|
import { MessageDialogContentInnerProps } from './MessageDialogContentInner';
|
|
4
4
|
declare type Props = MessageDialogContentInnerProps & Pick<DialogContentInnerProps, 'isOpen' | 'onClickOverlay' | 'onPressEscape' | 'width' | 'top' | 'right' | 'bottom' | 'left' | 'id'> & {
|
|
5
|
-
portalParent?: HTMLElement
|
|
5
|
+
portalParent?: HTMLElement | RefObject<HTMLElement>;
|
|
6
6
|
};
|
|
7
7
|
declare type ElementProps = Omit<HTMLAttributes<HTMLDivElement>, keyof Props>;
|
|
8
8
|
export declare const MessageDialog: React.VFC<Props & ElementProps>;
|
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
import React, { useCallback
|
|
2
|
-
import {
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useDialogPortal } from './useDialogPortal';
|
|
3
3
|
import { DialogContentInner } from './DialogContentInner';
|
|
4
4
|
import { MessageDialogContentInner, } from './MessageDialogContentInner';
|
|
5
5
|
export const MessageDialog = ({ title, subtitle, description, closeText, onClickClose, className = '', portalParent, ...props }) => {
|
|
6
|
-
const
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
// SSR を考慮し、useEffect 内で初期値 document.body を指定
|
|
9
|
-
const pp = portalParent || document.body;
|
|
10
|
-
pp.appendChild(portalContainer);
|
|
11
|
-
return () => {
|
|
12
|
-
pp.removeChild(portalContainer);
|
|
13
|
-
};
|
|
14
|
-
}, [portalContainer, portalParent]);
|
|
6
|
+
const { Portal } = useDialogPortal(portalParent);
|
|
15
7
|
const handleClickClose = useCallback(() => {
|
|
16
8
|
if (!props.isOpen) {
|
|
17
9
|
return;
|
|
18
10
|
}
|
|
19
11
|
onClickClose();
|
|
20
12
|
}, [onClickClose, props.isOpen]);
|
|
21
|
-
return
|
|
22
|
-
React.createElement(
|
|
13
|
+
return (React.createElement(Portal, null,
|
|
14
|
+
React.createElement(DialogContentInner, { ariaLabel: subtitle ? `${subtitle} ${title}` : title, className: className, ...props },
|
|
15
|
+
React.createElement(MessageDialogContentInner, { title: title, subtitle: subtitle, description: description, closeText: closeText, onClickClose: handleClickClose }))));
|
|
23
16
|
};
|
|
24
17
|
//# sourceMappingURL=MessageDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/MessageDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"MessageDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/MessageDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA6B,WAAW,EAAE,MAAM,OAAO,CAAA;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAA2B,MAAM,sBAAsB,CAAA;AAClF,OAAO,EACL,yBAAyB,GAE1B,MAAM,6BAA6B,CAAA;AAiBpC,MAAM,CAAC,MAAM,aAAa,GAAoC,CAAC,EAC7D,KAAK,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,YAAY,EACZ,SAAS,GAAG,EAAE,EACd,YAAY,EACZ,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC,YAAY,CAAC,CAAA;IAChD,MAAM,gBAAgB,GAAG,WAAW,CAAC,GAAG,EAAE;QACxC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACjB,OAAM;SACP;QACD,YAAY,EAAE,CAAA;IAChB,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAEhC,OAAO,CACL,oBAAC,MAAM;QACL,oBAAC,kBAAkB,IACjB,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,EACpD,SAAS,EAAE,SAAS,KAChB,KAAK;YAET,oBAAC,yBAAyB,IACxB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,gBAAgB,GAC9B,CACiB,CACd,CACV,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { MouseEvent, ReactNode } from 'react';
|
|
1
|
+
import React, { MouseEvent, ReactNode, RefObject } from 'react';
|
|
2
2
|
import { BaseElementProps } from '../Base';
|
|
3
3
|
declare type Props = {
|
|
4
4
|
/**
|
|
@@ -52,7 +52,7 @@ declare type Props = {
|
|
|
52
52
|
/**
|
|
53
53
|
* ポータルの container となる DOM 要素を追加する親要素
|
|
54
54
|
*/
|
|
55
|
-
portalParent?: HTMLElement
|
|
55
|
+
portalParent?: HTMLElement | RefObject<HTMLElement>;
|
|
56
56
|
};
|
|
57
57
|
export declare const ModelessDialog: React.VFC<Props & BaseElementProps>;
|
|
58
58
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState, } from 'react';
|
|
2
|
-
import { createPortal } from 'react-dom';
|
|
3
2
|
import styled, { css } from 'styled-components';
|
|
4
3
|
import Draggable from 'react-draggable';
|
|
5
4
|
import { useTheme } from '../../hooks/useTheme';
|
|
@@ -8,10 +7,11 @@ import { useHandleEscape } from '../../hooks/useHandleEscape';
|
|
|
8
7
|
import { Base } from '../Base';
|
|
9
8
|
import { SecondaryButton } from '../Button';
|
|
10
9
|
import { FaGripHorizontalIcon, FaTimesIcon } from '../Icon';
|
|
10
|
+
import { useDialogPortal } from './useDialogPortal';
|
|
11
11
|
import { DialogOverlap } from './DialogOverlap';
|
|
12
12
|
import { useClassNames } from './useClassNames';
|
|
13
13
|
export const ModelessDialog = ({ header, children, footer, isOpen, onClickClose, onPressEscape, width, height, top, left, right, bottom, portalParent, className = '', ...props }) => {
|
|
14
|
-
const
|
|
14
|
+
const { Portal, isReady } = useDialogPortal(portalParent);
|
|
15
15
|
const wrapperRef = useRef(null);
|
|
16
16
|
const focusTargetRef = useRef(null);
|
|
17
17
|
const [wrapperPosition, setWrapperPosition] = useState(undefined);
|
|
@@ -21,14 +21,6 @@ export const ModelessDialog = ({ header, children, footer, isOpen, onClickClose,
|
|
|
21
21
|
y: 0,
|
|
22
22
|
});
|
|
23
23
|
const theme = useTheme();
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
// SSR を考慮し、useEffect 内で初期値 document.body を指定
|
|
26
|
-
const pp = portalParent || document.body;
|
|
27
|
-
pp.appendChild(portalContainer);
|
|
28
|
-
return () => {
|
|
29
|
-
pp.removeChild(portalContainer);
|
|
30
|
-
};
|
|
31
|
-
}, [portalContainer, portalParent]);
|
|
32
24
|
useEffect(() => {
|
|
33
25
|
if (wrapperRef.current instanceof Element) {
|
|
34
26
|
setWrapperPosition(wrapperRef.current.getBoundingClientRect());
|
|
@@ -40,14 +32,14 @@ export const ModelessDialog = ({ header, children, footer, isOpen, onClickClose,
|
|
|
40
32
|
}
|
|
41
33
|
}, [isOpen, onPressEscape]));
|
|
42
34
|
useLayoutEffect(() => {
|
|
43
|
-
if (isOpen) {
|
|
35
|
+
if (isOpen && isReady) {
|
|
44
36
|
setPosition({ x: 0, y: 0 });
|
|
45
37
|
focusTargetRef.current?.focus();
|
|
46
38
|
}
|
|
47
|
-
}, [isOpen]);
|
|
39
|
+
}, [isOpen, isReady]);
|
|
48
40
|
useEffect(() => {
|
|
49
41
|
// 中央寄せの座標計算を行う
|
|
50
|
-
if (!wrapperRef.current || !isOpen) {
|
|
42
|
+
if (!wrapperRef.current || !isOpen || !isReady) {
|
|
51
43
|
return;
|
|
52
44
|
}
|
|
53
45
|
const isXCenter = left === undefined && right === undefined;
|
|
@@ -59,7 +51,7 @@ export const ModelessDialog = ({ header, children, footer, isOpen, onClickClose,
|
|
|
59
51
|
left: isXCenter ? window.innerWidth / 2 - rect.width / 2 : undefined,
|
|
60
52
|
});
|
|
61
53
|
}
|
|
62
|
-
}, [bottom, isOpen, left, right, top]);
|
|
54
|
+
}, [bottom, isOpen, isReady, left, right, top]);
|
|
63
55
|
const handleArrowKey = useCallback((e) => {
|
|
64
56
|
if (!isOpen || document.activeElement !== e.currentTarget) {
|
|
65
57
|
return;
|
|
@@ -98,36 +90,37 @@ export const ModelessDialog = ({ header, children, footer, isOpen, onClickClose,
|
|
|
98
90
|
}, [isOpen]);
|
|
99
91
|
const labelId = useId();
|
|
100
92
|
const classNames = useClassNames().modelessDialog;
|
|
101
|
-
return
|
|
102
|
-
React.createElement(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
React.createElement(
|
|
120
|
-
|
|
121
|
-
React.createElement(
|
|
122
|
-
|
|
123
|
-
|
|
93
|
+
return (React.createElement(Portal, null,
|
|
94
|
+
React.createElement(DialogOverlap, { isOpen: isOpen },
|
|
95
|
+
React.createElement(Draggable, { handle: `.${classNames.handle}`, onStart: (_, data) => setPosition({ x: data.x, y: data.y }), onDrag: (_, data) => {
|
|
96
|
+
setPosition((prev) => {
|
|
97
|
+
return {
|
|
98
|
+
x: prev.x + data.deltaX,
|
|
99
|
+
y: prev.y + data.deltaY,
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
}, position: position },
|
|
103
|
+
React.createElement(Layout, { className: `${className} ${classNames.wrapper}`, style: {
|
|
104
|
+
top: centering.top !== undefined ? centering.top : top,
|
|
105
|
+
left: centering.left !== undefined ? centering.left : left,
|
|
106
|
+
right,
|
|
107
|
+
bottom,
|
|
108
|
+
width,
|
|
109
|
+
height,
|
|
110
|
+
}, ref: wrapperRef, role: "dialog", "aria-labelledby": labelId, ...props },
|
|
111
|
+
React.createElement(Box, { isWidthAuto: width === undefined, left: left, right: right, themes: theme, className: classNames.box },
|
|
112
|
+
React.createElement("div", { tabIndex: -1, ref: focusTargetRef }),
|
|
113
|
+
React.createElement(Header, { className: classNames.header, themes: theme },
|
|
114
|
+
React.createElement(Title, { id: labelId, themes: theme }, header),
|
|
115
|
+
React.createElement(DialogHandler, { className: classNames.handle, themes: theme, tabIndex: 0, role: "slider", "aria-label": "\u30C0\u30A4\u30A2\u30ED\u30B0\u306E\u4F4D\u7F6E", "aria-valuetext": wrapperPosition &&
|
|
116
|
+
`上から${Math.trunc(wrapperPosition.top)}px、
|
|
124
117
|
左から${Math.trunc(wrapperPosition.left)}px`, onKeyDown: handleArrowKey },
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
118
|
+
React.createElement(FaGripHorizontalIcon, null)),
|
|
119
|
+
React.createElement(CloseButtonLayout, null,
|
|
120
|
+
React.createElement(SecondaryButton, { type: "button", size: "s", square: true, onClick: onClickClose, className: classNames.closeButton },
|
|
121
|
+
React.createElement(FaTimesIcon, { visuallyHiddenText: "\u9589\u3058\u308B" })))),
|
|
122
|
+
React.createElement(Content, { className: classNames.content }, children),
|
|
123
|
+
footer && (React.createElement(Footer, { className: classNames.footer, themes: theme }, footer))))))));
|
|
131
124
|
};
|
|
132
125
|
const Layout = styled.div `
|
|
133
126
|
position: fixed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelessDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/ModelessDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ModelessDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/ModelessDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAIZ,WAAW,EACX,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,SAAS,MAAM,iBAAiB,CAAA;AAEvC,OAAO,EAAS,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,eAAe,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GAAG,MAAM,CAAC,GAAG,CAAmB;IAC/C,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;;;;;;;+BAOnB,MAAM,CAAC,CAAC;8BACT,MAAM,CAAC,CAAC;;;;;;;eAOvB,KAAK,CAAC,SAAS;;;;eAIf,KAAK,CAAC,SAAS;;oBAEV,MAAM,CAAC,OAAO;;GAE/B;CACF,CAAA;AAED,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;CAKnC,CAAA;AACD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAGzB,CAAA;AACD,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAmB;IACxC,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;kBACjB,MAAM,CAAC,SAAS;GAC/B;CACF,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
export function useDialogPortal(parent) {
|
|
4
|
+
const portalContainer = useRef(document.createElement('div')).current;
|
|
5
|
+
const [isReady, setIsReady] = useState(false);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const parentElement = parent != null && 'current' in parent ? parent.current : parent;
|
|
8
|
+
// SSR を考慮し、useEffect 内で初期値 document.body を指定
|
|
9
|
+
const actualParent = parentElement || document.body;
|
|
10
|
+
// 前状態のクリンナップと同ループで処理しないようにタイミングを遅らせる
|
|
11
|
+
setTimeout(() => {
|
|
12
|
+
actualParent.appendChild(portalContainer);
|
|
13
|
+
setIsReady(true);
|
|
14
|
+
});
|
|
15
|
+
return () => {
|
|
16
|
+
setIsReady(false);
|
|
17
|
+
actualParent.removeChild(portalContainer);
|
|
18
|
+
};
|
|
19
|
+
}, [portalContainer, parent]);
|
|
20
|
+
const Portal = useCallback(({ children }) => {
|
|
21
|
+
if (!isReady) {
|
|
22
|
+
// コンテナの append が完了するまでは子のライフサイクルを開始させない
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return createPortal(children, portalContainer);
|
|
26
|
+
}, [isReady, portalContainer]);
|
|
27
|
+
return {
|
|
28
|
+
Portal,
|
|
29
|
+
isReady,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=useDialogPortal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDialogPortal.js","sourceRoot":"","sources":["../../../src/components/Dialog/useDialogPortal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,UAAU,eAAe,CAAC,MAA6C;IAC3E,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAA;IACrE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAE7C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAa,GAAG,MAAM,IAAI,IAAI,IAAI,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAA;QACrF,6CAA6C;QAC7C,MAAM,YAAY,GAAG,aAAa,IAAI,QAAQ,CAAC,IAAI,CAAA;QACnD,qCAAqC;QACrC,UAAU,CAAC,GAAG,EAAE;YACd,YAAY,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;YACzC,UAAU,CAAC,IAAI,CAAC,CAAA;QAClB,CAAC,CAAC,CAAA;QACF,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,KAAK,CAAC,CAAA;YACjB,YAAY,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC3C,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAA;IAE7B,MAAM,MAAM,GAAiC,WAAW,CACtD,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;QACf,IAAI,CAAC,OAAO,EAAE;YACZ,wCAAwC;YACxC,OAAO,IAAI,CAAA;SACZ;QACD,OAAO,YAAY,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAA;IAChD,CAAC,EACD,CAAC,OAAO,EAAE,eAAe,CAAC,CAC3B,CAAA;IAED,OAAO;QACL,MAAM;QACN,OAAO;KACR,CAAA;AACH,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { BaseElementProps } from '../Base';
|
|
|
3
3
|
import { HeadingTagTypes } from '../Heading';
|
|
4
4
|
declare type Props = {
|
|
5
5
|
/** パネルのタイトル */
|
|
6
|
-
title:
|
|
6
|
+
title: React.ReactNode;
|
|
7
7
|
/** タイトル部分の HTML タグ */
|
|
8
8
|
titleTag?: HeadingTagTypes;
|
|
9
9
|
/** 表示する情報のタイプ */
|
|
@@ -11,9 +11,9 @@ declare type Props = {
|
|
|
11
11
|
/** `true` のとき、開閉ボタンを表示する */
|
|
12
12
|
togglable?: boolean;
|
|
13
13
|
/** 開くボタンのラベル */
|
|
14
|
-
openButtonLabel?:
|
|
14
|
+
openButtonLabel?: React.ReactNode;
|
|
15
15
|
/** 閉じるボタンのラベル */
|
|
16
|
-
closeButtonLabel?:
|
|
16
|
+
closeButtonLabel?: React.ReactNode;
|
|
17
17
|
/** パネルの開閉の状態 */
|
|
18
18
|
active?: boolean;
|
|
19
19
|
/** コンポーネントに適用するクラス名 */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
1
|
+
import React, { HTMLAttributes, RefObject } from 'react';
|
|
2
2
|
import { DialogContentInnerProps } from './DialogContentInner';
|
|
3
3
|
import { ActionDialogContentInnerProps } from './ActionDialogContentInner';
|
|
4
4
|
declare type Props = Omit<ActionDialogContentInnerProps, 'titleId'> & {
|
|
5
5
|
onClickClose: () => void;
|
|
6
|
-
portalParent?: HTMLElement
|
|
6
|
+
portalParent?: HTMLElement | RefObject<HTMLElement>;
|
|
7
7
|
} & Pick<DialogContentInnerProps, 'isOpen' | 'onClickOverlay' | 'onPressEscape' | 'width' | 'top' | 'right' | 'bottom' | 'left' | 'id'>;
|
|
8
8
|
declare type ElementProps = Omit<HTMLAttributes<HTMLDivElement>, keyof Props>;
|
|
9
9
|
export declare const ActionDialog: React.VFC<Props & ElementProps>;
|
|
@@ -25,21 +25,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.ActionDialog = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
|
-
const react_dom_1 = require("react-dom");
|
|
29
28
|
const useId_1 = require("../../hooks/useId");
|
|
29
|
+
const useDialogPortal_1 = require("./useDialogPortal");
|
|
30
30
|
const DialogContentInner_1 = require("./DialogContentInner");
|
|
31
31
|
const ActionDialogContentInner_1 = require("./ActionDialogContentInner");
|
|
32
32
|
const ActionDialog = ({ children, title, subtitle, closeText, actionText, actionTheme, onClickAction, onClickClose, responseMessage, actionDisabled = false, closeDisabled, className = '', portalParent, ...props }) => {
|
|
33
|
-
const
|
|
33
|
+
const { Portal } = (0, useDialogPortal_1.useDialogPortal)(portalParent);
|
|
34
34
|
const titleId = (0, useId_1.useId)();
|
|
35
|
-
(0, react_1.useEffect)(() => {
|
|
36
|
-
// SSR を考慮し、useEffect 内で初期値 document.body を指定
|
|
37
|
-
const pp = portalParent || document.body;
|
|
38
|
-
pp.appendChild(portalContainer);
|
|
39
|
-
return () => {
|
|
40
|
-
pp.removeChild(portalContainer);
|
|
41
|
-
};
|
|
42
|
-
}, [portalContainer, portalParent]);
|
|
43
35
|
const handleClickClose = (0, react_1.useCallback)(() => {
|
|
44
36
|
if (!props.isOpen) {
|
|
45
37
|
return;
|
|
@@ -52,8 +44,9 @@ const ActionDialog = ({ children, title, subtitle, closeText, actionText, action
|
|
|
52
44
|
}
|
|
53
45
|
onClickAction(onClickClose);
|
|
54
46
|
}, [onClickAction, onClickClose, props.isOpen]);
|
|
55
|
-
return (
|
|
56
|
-
react_1.default.createElement(
|
|
47
|
+
return (react_1.default.createElement(Portal, null,
|
|
48
|
+
react_1.default.createElement(DialogContentInner_1.DialogContentInner, { ariaLabelledby: titleId, className: className, ...props },
|
|
49
|
+
react_1.default.createElement(ActionDialogContentInner_1.ActionDialogContentInner, { title: title, titleId: titleId, subtitle: subtitle, closeText: closeText, actionText: actionText, actionTheme: actionTheme, actionDisabled: actionDisabled, closeDisabled: closeDisabled, onClickClose: handleClickClose, onClickAction: handleClickAction, responseMessage: responseMessage }, children))));
|
|
57
50
|
};
|
|
58
51
|
exports.ActionDialog = ActionDialog;
|
|
59
52
|
//# sourceMappingURL=ActionDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/ActionDialog.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"ActionDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/ActionDialog.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqE;AAErE,6CAAyC;AACzC,uDAAmD;AACnD,6DAAkF;AAClF,yEAAoG;AAmB7F,MAAM,YAAY,GAAoC,CAAC,EAC5D,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,SAAS,EACT,UAAU,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,cAAc,GAAG,KAAK,EACtB,aAAa,EACb,SAAS,GAAG,EAAE,EACd,YAAY,EACZ,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,iCAAe,EAAC,YAAY,CAAC,CAAA;IAChD,MAAM,OAAO,GAAG,IAAA,aAAK,GAAE,CAAA;IAEvB,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QACxC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACjB,OAAM;SACP;QACD,YAAY,EAAE,CAAA;IAChB,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAEhC,MAAM,iBAAiB,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QACzC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACjB,OAAM;SACP;QACD,aAAa,CAAC,YAAY,CAAC,CAAA;IAC7B,CAAC,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAE/C,OAAO,CACL,8BAAC,MAAM;QACL,8BAAC,uCAAkB,IAAC,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,KAAM,KAAK;YAC1E,8BAAC,mDAAwB,IACvB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,gBAAgB,EAC9B,aAAa,EAAE,iBAAiB,EAChC,eAAe,EAAE,eAAe,IAE/B,QAAQ,CACgB,CACR,CACd,CACV,CAAA;AACH,CAAC,CAAA;AAtDY,QAAA,YAAY,gBAsDxB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
1
|
+
import React, { HTMLAttributes, RefObject } from 'react';
|
|
2
2
|
import { DialogContentInnerProps } from './DialogContentInner';
|
|
3
3
|
declare type Props = DialogContentInnerProps & {
|
|
4
|
-
portalParent?: HTMLElement
|
|
4
|
+
portalParent?: HTMLElement | RefObject<HTMLElement>;
|
|
5
5
|
};
|
|
6
6
|
declare type ElementProps = Omit<HTMLAttributes<HTMLDivElement>, keyof Props>;
|
|
7
7
|
export declare const Dialog: React.VFC<Props & ElementProps>;
|
|
@@ -1,43 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.Dialog = void 0;
|
|
27
|
-
const react_1 =
|
|
28
|
-
const
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const useDialogPortal_1 = require("./useDialogPortal");
|
|
29
9
|
const DialogContentInner_1 = require("./DialogContentInner");
|
|
30
10
|
const Dialog = ({ children, className = '', portalParent, ...props }) => {
|
|
31
|
-
const
|
|
32
|
-
(
|
|
33
|
-
|
|
34
|
-
const pp = portalParent || document.body;
|
|
35
|
-
pp.appendChild(portalContainer);
|
|
36
|
-
return () => {
|
|
37
|
-
pp.removeChild(portalContainer);
|
|
38
|
-
};
|
|
39
|
-
}, [portalContainer, portalParent]);
|
|
40
|
-
return (0, react_dom_1.createPortal)(react_1.default.createElement(DialogContentInner_1.DialogContentInner, { className: className, ...props }, children), portalContainer);
|
|
11
|
+
const { Portal } = (0, useDialogPortal_1.useDialogPortal)(portalParent);
|
|
12
|
+
return (react_1.default.createElement(Portal, null,
|
|
13
|
+
react_1.default.createElement(DialogContentInner_1.DialogContentInner, { className: className, ...props }, children)));
|
|
41
14
|
};
|
|
42
15
|
exports.Dialog = Dialog;
|
|
43
16
|
//# sourceMappingURL=Dialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAwD;AAExD,uDAAmD;AACnD,6DAAkF;AAK3E,MAAM,MAAM,GAAoC,CAAC,EACtD,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,YAAY,EACZ,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,iCAAe,EAAC,YAAY,CAAC,CAAA;IAEhD,OAAO,CACL,8BAAC,MAAM;QACL,8BAAC,uCAAkB,IAAC,SAAS,EAAE,SAAS,KAAM,KAAK,IAChD,QAAQ,CACU,CACd,CACV,CAAA;AACH,CAAC,CAAA;AAfY,QAAA,MAAM,UAelB"}
|
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.DialogWrapper = exports.DialogContext = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
|
-
const
|
|
28
|
+
const useDialogPortal_1 = require("./useDialogPortal");
|
|
29
29
|
exports.DialogContext = (0, react_1.createContext)({
|
|
30
30
|
onClickTrigger: () => {
|
|
31
31
|
/* noop */
|
|
@@ -38,17 +38,11 @@ exports.DialogContext = (0, react_1.createContext)({
|
|
|
38
38
|
});
|
|
39
39
|
const DialogWrapper = ({ children }) => {
|
|
40
40
|
const [active, setActive] = (0, react_1.useState)(false);
|
|
41
|
-
const
|
|
42
|
-
(0, react_1.useEffect)(() => {
|
|
43
|
-
document.body.appendChild(element);
|
|
44
|
-
return () => {
|
|
45
|
-
document.body.removeChild(element);
|
|
46
|
-
};
|
|
47
|
-
}, [element]);
|
|
41
|
+
const { Portal } = (0, useDialogPortal_1.useDialogPortal)();
|
|
48
42
|
// This is the root container of a dialog content located in outside the DOM tree
|
|
49
43
|
const DialogContentRoot = (0, react_1.useMemo)(() => (props) => {
|
|
50
|
-
return (
|
|
51
|
-
}, [
|
|
44
|
+
return react_1.default.createElement(Portal, null, props.children);
|
|
45
|
+
}, [Portal]);
|
|
52
46
|
// set the displayName explicit for DevTools
|
|
53
47
|
DialogContentRoot.displayName = 'DialogContentRoot';
|
|
54
48
|
return (react_1.default.createElement(exports.DialogContext.Provider, { value: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogWrapper.js","sourceRoot":"","sources":["../../../src/components/Dialog/DialogWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"DialogWrapper.js","sourceRoot":"","sources":["../../../src/components/Dialog/DialogWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA+D;AAE/D,uDAAmD;AAStC,QAAA,aAAa,GAAG,IAAA,qBAAa,EAAoB;IAC5D,cAAc,EAAE,GAAG,EAAE;QACnB,UAAU;IACZ,CAAC;IACD,YAAY,EAAE,GAAG,EAAE;QACjB,UAAU;IACZ,CAAC;IACD,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI;IAC7B,MAAM,EAAE,KAAK;CACd,CAAC,CAAA;AAEK,MAAM,aAAa,GAA8C,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IACvF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,iCAAe,GAAE,CAAA;IAEpC,iFAAiF;IACjF,MAAM,iBAAiB,GAAG,IAAA,eAAO,EAC/B,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE;QACd,OAAO,8BAAC,MAAM,QAAE,KAAK,CAAC,QAAQ,CAAU,CAAA;IAC1C,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAA;IACD,4CAA4C;IAC5C,iBAAiB,CAAC,WAAW,GAAG,mBAAmB,CAAA;IAEnD,OAAO,CACL,8BAAC,qBAAa,CAAC,QAAQ,IACrB,KAAK,EAAE;YACL,cAAc,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;YACrC,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;YACpC,iBAAiB;YACjB,MAAM;SACP,IAEA,QAAQ,CACc,CAC1B,CAAA;AACH,CAAC,CAAA;AA1BY,QAAA,aAAa,iBA0BzB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
1
|
+
import React, { HTMLAttributes, RefObject } from 'react';
|
|
2
2
|
import { DialogContentInnerProps } from './DialogContentInner';
|
|
3
3
|
import { MessageDialogContentInnerProps } from './MessageDialogContentInner';
|
|
4
4
|
declare type Props = MessageDialogContentInnerProps & Pick<DialogContentInnerProps, 'isOpen' | 'onClickOverlay' | 'onPressEscape' | 'width' | 'top' | 'right' | 'bottom' | 'left' | 'id'> & {
|
|
5
|
-
portalParent?: HTMLElement
|
|
5
|
+
portalParent?: HTMLElement | RefObject<HTMLElement>;
|
|
6
6
|
};
|
|
7
7
|
declare type ElementProps = Omit<HTMLAttributes<HTMLDivElement>, keyof Props>;
|
|
8
8
|
export declare const MessageDialog: React.VFC<Props & ElementProps>;
|
|
@@ -25,27 +25,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.MessageDialog = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
|
-
const
|
|
28
|
+
const useDialogPortal_1 = require("./useDialogPortal");
|
|
29
29
|
const DialogContentInner_1 = require("./DialogContentInner");
|
|
30
30
|
const MessageDialogContentInner_1 = require("./MessageDialogContentInner");
|
|
31
31
|
const MessageDialog = ({ title, subtitle, description, closeText, onClickClose, className = '', portalParent, ...props }) => {
|
|
32
|
-
const
|
|
33
|
-
(0, react_1.useEffect)(() => {
|
|
34
|
-
// SSR を考慮し、useEffect 内で初期値 document.body を指定
|
|
35
|
-
const pp = portalParent || document.body;
|
|
36
|
-
pp.appendChild(portalContainer);
|
|
37
|
-
return () => {
|
|
38
|
-
pp.removeChild(portalContainer);
|
|
39
|
-
};
|
|
40
|
-
}, [portalContainer, portalParent]);
|
|
32
|
+
const { Portal } = (0, useDialogPortal_1.useDialogPortal)(portalParent);
|
|
41
33
|
const handleClickClose = (0, react_1.useCallback)(() => {
|
|
42
34
|
if (!props.isOpen) {
|
|
43
35
|
return;
|
|
44
36
|
}
|
|
45
37
|
onClickClose();
|
|
46
38
|
}, [onClickClose, props.isOpen]);
|
|
47
|
-
return (
|
|
48
|
-
react_1.default.createElement(
|
|
39
|
+
return (react_1.default.createElement(Portal, null,
|
|
40
|
+
react_1.default.createElement(DialogContentInner_1.DialogContentInner, { ariaLabel: subtitle ? `${subtitle} ${title}` : title, className: className, ...props },
|
|
41
|
+
react_1.default.createElement(MessageDialogContentInner_1.MessageDialogContentInner, { title: title, subtitle: subtitle, description: description, closeText: closeText, onClickClose: handleClickClose }))));
|
|
49
42
|
};
|
|
50
43
|
exports.MessageDialog = MessageDialog;
|
|
51
44
|
//# sourceMappingURL=MessageDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/MessageDialog.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"MessageDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/MessageDialog.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqE;AAErE,uDAAmD;AACnD,6DAAkF;AAClF,2EAGoC;AAiB7B,MAAM,aAAa,GAAoC,CAAC,EAC7D,KAAK,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,YAAY,EACZ,SAAS,GAAG,EAAE,EACd,YAAY,EACZ,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,iCAAe,EAAC,YAAY,CAAC,CAAA;IAChD,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QACxC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACjB,OAAM;SACP;QACD,YAAY,EAAE,CAAA;IAChB,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAEhC,OAAO,CACL,8BAAC,MAAM;QACL,8BAAC,uCAAkB,IACjB,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,EACpD,SAAS,EAAE,SAAS,KAChB,KAAK;YAET,8BAAC,qDAAyB,IACxB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,gBAAgB,GAC9B,CACiB,CACd,CACV,CAAA;AACH,CAAC,CAAA;AAnCY,QAAA,aAAa,iBAmCzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { MouseEvent, ReactNode } from 'react';
|
|
1
|
+
import React, { MouseEvent, ReactNode, RefObject } from 'react';
|
|
2
2
|
import { BaseElementProps } from '../Base';
|
|
3
3
|
declare type Props = {
|
|
4
4
|
/**
|
|
@@ -52,7 +52,7 @@ declare type Props = {
|
|
|
52
52
|
/**
|
|
53
53
|
* ポータルの container となる DOM 要素を追加する親要素
|
|
54
54
|
*/
|
|
55
|
-
portalParent?: HTMLElement
|
|
55
|
+
portalParent?: HTMLElement | RefObject<HTMLElement>;
|
|
56
56
|
};
|
|
57
57
|
export declare const ModelessDialog: React.VFC<Props & BaseElementProps>;
|
|
58
58
|
export {};
|
|
@@ -28,7 +28,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ModelessDialog = void 0;
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
|
-
const react_dom_1 = require("react-dom");
|
|
32
31
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
33
32
|
const react_draggable_1 = __importDefault(require("react-draggable"));
|
|
34
33
|
const useTheme_1 = require("../../hooks/useTheme");
|
|
@@ -37,10 +36,11 @@ const useHandleEscape_1 = require("../../hooks/useHandleEscape");
|
|
|
37
36
|
const Base_1 = require("../Base");
|
|
38
37
|
const Button_1 = require("../Button");
|
|
39
38
|
const Icon_1 = require("../Icon");
|
|
39
|
+
const useDialogPortal_1 = require("./useDialogPortal");
|
|
40
40
|
const DialogOverlap_1 = require("./DialogOverlap");
|
|
41
41
|
const useClassNames_1 = require("./useClassNames");
|
|
42
42
|
const ModelessDialog = ({ header, children, footer, isOpen, onClickClose, onPressEscape, width, height, top, left, right, bottom, portalParent, className = '', ...props }) => {
|
|
43
|
-
const
|
|
43
|
+
const { Portal, isReady } = (0, useDialogPortal_1.useDialogPortal)(portalParent);
|
|
44
44
|
const wrapperRef = (0, react_1.useRef)(null);
|
|
45
45
|
const focusTargetRef = (0, react_1.useRef)(null);
|
|
46
46
|
const [wrapperPosition, setWrapperPosition] = (0, react_1.useState)(undefined);
|
|
@@ -50,14 +50,6 @@ const ModelessDialog = ({ header, children, footer, isOpen, onClickClose, onPres
|
|
|
50
50
|
y: 0,
|
|
51
51
|
});
|
|
52
52
|
const theme = (0, useTheme_1.useTheme)();
|
|
53
|
-
(0, react_1.useEffect)(() => {
|
|
54
|
-
// SSR を考慮し、useEffect 内で初期値 document.body を指定
|
|
55
|
-
const pp = portalParent || document.body;
|
|
56
|
-
pp.appendChild(portalContainer);
|
|
57
|
-
return () => {
|
|
58
|
-
pp.removeChild(portalContainer);
|
|
59
|
-
};
|
|
60
|
-
}, [portalContainer, portalParent]);
|
|
61
53
|
(0, react_1.useEffect)(() => {
|
|
62
54
|
if (wrapperRef.current instanceof Element) {
|
|
63
55
|
setWrapperPosition(wrapperRef.current.getBoundingClientRect());
|
|
@@ -69,14 +61,14 @@ const ModelessDialog = ({ header, children, footer, isOpen, onClickClose, onPres
|
|
|
69
61
|
}
|
|
70
62
|
}, [isOpen, onPressEscape]));
|
|
71
63
|
(0, react_1.useLayoutEffect)(() => {
|
|
72
|
-
if (isOpen) {
|
|
64
|
+
if (isOpen && isReady) {
|
|
73
65
|
setPosition({ x: 0, y: 0 });
|
|
74
66
|
focusTargetRef.current?.focus();
|
|
75
67
|
}
|
|
76
|
-
}, [isOpen]);
|
|
68
|
+
}, [isOpen, isReady]);
|
|
77
69
|
(0, react_1.useEffect)(() => {
|
|
78
70
|
// 中央寄せの座標計算を行う
|
|
79
|
-
if (!wrapperRef.current || !isOpen) {
|
|
71
|
+
if (!wrapperRef.current || !isOpen || !isReady) {
|
|
80
72
|
return;
|
|
81
73
|
}
|
|
82
74
|
const isXCenter = left === undefined && right === undefined;
|
|
@@ -88,7 +80,7 @@ const ModelessDialog = ({ header, children, footer, isOpen, onClickClose, onPres
|
|
|
88
80
|
left: isXCenter ? window.innerWidth / 2 - rect.width / 2 : undefined,
|
|
89
81
|
});
|
|
90
82
|
}
|
|
91
|
-
}, [bottom, isOpen, left, right, top]);
|
|
83
|
+
}, [bottom, isOpen, isReady, left, right, top]);
|
|
92
84
|
const handleArrowKey = (0, react_1.useCallback)((e) => {
|
|
93
85
|
if (!isOpen || document.activeElement !== e.currentTarget) {
|
|
94
86
|
return;
|
|
@@ -127,36 +119,37 @@ const ModelessDialog = ({ header, children, footer, isOpen, onClickClose, onPres
|
|
|
127
119
|
}, [isOpen]);
|
|
128
120
|
const labelId = (0, useId_1.useId)();
|
|
129
121
|
const classNames = (0, useClassNames_1.useClassNames)().modelessDialog;
|
|
130
|
-
return (
|
|
131
|
-
react_1.default.createElement(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
react_1.default.createElement(
|
|
149
|
-
|
|
150
|
-
react_1.default.createElement(
|
|
151
|
-
|
|
152
|
-
|
|
122
|
+
return (react_1.default.createElement(Portal, null,
|
|
123
|
+
react_1.default.createElement(DialogOverlap_1.DialogOverlap, { isOpen: isOpen },
|
|
124
|
+
react_1.default.createElement(react_draggable_1.default, { handle: `.${classNames.handle}`, onStart: (_, data) => setPosition({ x: data.x, y: data.y }), onDrag: (_, data) => {
|
|
125
|
+
setPosition((prev) => {
|
|
126
|
+
return {
|
|
127
|
+
x: prev.x + data.deltaX,
|
|
128
|
+
y: prev.y + data.deltaY,
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
}, position: position },
|
|
132
|
+
react_1.default.createElement(Layout, { className: `${className} ${classNames.wrapper}`, style: {
|
|
133
|
+
top: centering.top !== undefined ? centering.top : top,
|
|
134
|
+
left: centering.left !== undefined ? centering.left : left,
|
|
135
|
+
right,
|
|
136
|
+
bottom,
|
|
137
|
+
width,
|
|
138
|
+
height,
|
|
139
|
+
}, ref: wrapperRef, role: "dialog", "aria-labelledby": labelId, ...props },
|
|
140
|
+
react_1.default.createElement(Box, { isWidthAuto: width === undefined, left: left, right: right, themes: theme, className: classNames.box },
|
|
141
|
+
react_1.default.createElement("div", { tabIndex: -1, ref: focusTargetRef }),
|
|
142
|
+
react_1.default.createElement(Header, { className: classNames.header, themes: theme },
|
|
143
|
+
react_1.default.createElement(Title, { id: labelId, themes: theme }, header),
|
|
144
|
+
react_1.default.createElement(DialogHandler, { className: classNames.handle, themes: theme, tabIndex: 0, role: "slider", "aria-label": "\u30C0\u30A4\u30A2\u30ED\u30B0\u306E\u4F4D\u7F6E", "aria-valuetext": wrapperPosition &&
|
|
145
|
+
`上から${Math.trunc(wrapperPosition.top)}px、
|
|
153
146
|
左から${Math.trunc(wrapperPosition.left)}px`, onKeyDown: handleArrowKey },
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
147
|
+
react_1.default.createElement(Icon_1.FaGripHorizontalIcon, null)),
|
|
148
|
+
react_1.default.createElement(CloseButtonLayout, null,
|
|
149
|
+
react_1.default.createElement(Button_1.SecondaryButton, { type: "button", size: "s", square: true, onClick: onClickClose, className: classNames.closeButton },
|
|
150
|
+
react_1.default.createElement(Icon_1.FaTimesIcon, { visuallyHiddenText: "\u9589\u3058\u308B" })))),
|
|
151
|
+
react_1.default.createElement(Content, { className: classNames.content }, children),
|
|
152
|
+
footer && (react_1.default.createElement(Footer, { className: classNames.footer, themes: theme }, footer))))))));
|
|
160
153
|
};
|
|
161
154
|
exports.ModelessDialog = ModelessDialog;
|
|
162
155
|
const Layout = styled_components_1.default.div `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelessDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/ModelessDialog.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"ModelessDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/ModelessDialog.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CASc;AACd,uEAA+C;AAC/C,sEAAuC;AAEvC,mDAAsD;AACtD,6CAAyC;AACzC,iEAA6D;AAC7D,kCAAgD;AAChD,sCAA2C;AAC3C,kCAA2D;AAC3D,uDAAmD;AACnD,mDAA+C;AAC/C,mDAA+C;AAyDxC,MAAM,cAAc,GAAwC,CAAC,EAClE,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,YAAY,EACZ,aAAa,EACb,KAAK,EACL,MAAM,EACN,GAAG,EACH,IAAI,EACJ,KAAK,EACL,MAAM,EACN,YAAY,EACZ,SAAS,GAAG,EAAE,EACd,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,iCAAe,EAAC,YAAY,CAAC,CAAA;IACzD,MAAM,UAAU,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAA;IAC/C,MAAM,cAAc,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAA;IACnD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAsB,SAAS,CAAC,CAAA;IACtF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAGvC,EAAE,CAAC,CAAA;IACN,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAA2B;QACjE,CAA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GAAG,CAAC;qBACjB,aAAa,CAAC,CAAC,CAAC;qBAChB,MAAM,CAAC,SAAS;;GAElC;CACF,CAAA;AACD,MAAM,KAAK,GAAG,2BAAM,CAAC,GAAG,CAAmB;IACvC,CAAC,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,EAAE,CAAC,IAAA,uBAAG,EAAA;cAC5B,aAAa,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;GACnE;CACF,CAAA;AAED,MAAM,aAAa,GAAG,2BAAM,CAAC,GAAG,CAAmB;IAC/C,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,IAAA,uBAAG,EAAA;;;;;;;+BAOnB,MAAM,CAAC,CAAC;8BACT,MAAM,CAAC,CAAC;;;;;;;eAOvB,KAAK,CAAC,SAAS;;;;eAIf,KAAK,CAAC,SAAS;;oBAEV,MAAM,CAAC,OAAO;;GAE/B;CACF,CAAA;AAED,MAAM,iBAAiB,GAAG,2BAAM,CAAC,GAAG,CAAA;;;;;CAKnC,CAAA;AACD,MAAM,OAAO,GAAG,2BAAM,CAAC,GAAG,CAAA;;;CAGzB,CAAA;AACD,MAAM,MAAM,GAAG,2BAAM,CAAC,GAAG,CAAmB;IACxC,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,IAAA,uBAAG,EAAA;kBACjB,MAAM,CAAC,SAAS;GAC/B;CACF,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDialogPortal = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_dom_1 = require("react-dom");
|
|
6
|
+
function useDialogPortal(parent) {
|
|
7
|
+
const portalContainer = (0, react_1.useRef)(document.createElement('div')).current;
|
|
8
|
+
const [isReady, setIsReady] = (0, react_1.useState)(false);
|
|
9
|
+
(0, react_1.useEffect)(() => {
|
|
10
|
+
const parentElement = parent != null && 'current' in parent ? parent.current : parent;
|
|
11
|
+
// SSR を考慮し、useEffect 内で初期値 document.body を指定
|
|
12
|
+
const actualParent = parentElement || document.body;
|
|
13
|
+
// 前状態のクリンナップと同ループで処理しないようにタイミングを遅らせる
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
actualParent.appendChild(portalContainer);
|
|
16
|
+
setIsReady(true);
|
|
17
|
+
});
|
|
18
|
+
return () => {
|
|
19
|
+
setIsReady(false);
|
|
20
|
+
actualParent.removeChild(portalContainer);
|
|
21
|
+
};
|
|
22
|
+
}, [portalContainer, parent]);
|
|
23
|
+
const Portal = (0, react_1.useCallback)(({ children }) => {
|
|
24
|
+
if (!isReady) {
|
|
25
|
+
// コンテナの append が完了するまでは子のライフサイクルを開始させない
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return (0, react_dom_1.createPortal)(children, portalContainer);
|
|
29
|
+
}, [isReady, portalContainer]);
|
|
30
|
+
return {
|
|
31
|
+
Portal,
|
|
32
|
+
isReady,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.useDialogPortal = useDialogPortal;
|
|
36
|
+
//# sourceMappingURL=useDialogPortal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDialogPortal.js","sourceRoot":"","sources":["../../../src/components/Dialog/useDialogPortal.tsx"],"names":[],"mappings":";;;AAAA,iCAA2F;AAC3F,yCAAwC;AAExC,SAAgB,eAAe,CAAC,MAA6C;IAC3E,MAAM,eAAe,GAAG,IAAA,cAAM,EAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAA;IACrE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IAE7C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,aAAa,GAAG,MAAM,IAAI,IAAI,IAAI,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAA;QACrF,6CAA6C;QAC7C,MAAM,YAAY,GAAG,aAAa,IAAI,QAAQ,CAAC,IAAI,CAAA;QACnD,qCAAqC;QACrC,UAAU,CAAC,GAAG,EAAE;YACd,YAAY,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;YACzC,UAAU,CAAC,IAAI,CAAC,CAAA;QAClB,CAAC,CAAC,CAAA;QACF,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,KAAK,CAAC,CAAA;YACjB,YAAY,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;QAC3C,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAA;IAE7B,MAAM,MAAM,GAAiC,IAAA,mBAAW,EACtD,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;QACf,IAAI,CAAC,OAAO,EAAE;YACZ,wCAAwC;YACxC,OAAO,IAAI,CAAA;SACZ;QACD,OAAO,IAAA,wBAAY,EAAC,QAAQ,EAAE,eAAe,CAAC,CAAA;IAChD,CAAC,EACD,CAAC,OAAO,EAAE,eAAe,CAAC,CAC3B,CAAA;IAED,OAAO;QACL,MAAM;QACN,OAAO;KACR,CAAA;AACH,CAAC;AAlCD,0CAkCC"}
|
|
@@ -3,7 +3,7 @@ import { BaseElementProps } from '../Base';
|
|
|
3
3
|
import { HeadingTagTypes } from '../Heading';
|
|
4
4
|
declare type Props = {
|
|
5
5
|
/** パネルのタイトル */
|
|
6
|
-
title:
|
|
6
|
+
title: React.ReactNode;
|
|
7
7
|
/** タイトル部分の HTML タグ */
|
|
8
8
|
titleTag?: HeadingTagTypes;
|
|
9
9
|
/** 表示する情報のタイプ */
|
|
@@ -11,9 +11,9 @@ declare type Props = {
|
|
|
11
11
|
/** `true` のとき、開閉ボタンを表示する */
|
|
12
12
|
togglable?: boolean;
|
|
13
13
|
/** 開くボタンのラベル */
|
|
14
|
-
openButtonLabel?:
|
|
14
|
+
openButtonLabel?: React.ReactNode;
|
|
15
15
|
/** 閉じるボタンのラベル */
|
|
16
|
-
closeButtonLabel?:
|
|
16
|
+
closeButtonLabel?: React.ReactNode;
|
|
17
17
|
/** パネルの開閉の状態 */
|
|
18
18
|
active?: boolean;
|
|
19
19
|
/** コンポーネントに適用するクラス名 */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smarthr-ui",
|
|
3
3
|
"description": "SmartHR ui components built with React.",
|
|
4
|
-
"version": "20.
|
|
4
|
+
"version": "20.2.0",
|
|
5
5
|
"author": "SmartHR-UI Team",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"dayjs": "^1.11.0",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"react-transition-group": "^4.4.2"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@babel/core": "^7.17.
|
|
16
|
+
"@babel/core": "^7.17.9",
|
|
17
17
|
"@commitlint/cli": "^16.2.3",
|
|
18
18
|
"@commitlint/config-conventional": "^16.2.1",
|
|
19
19
|
"@storybook/addon-a11y": "^6.4.19",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"@storybook/cli": "^6.4.19",
|
|
23
23
|
"@storybook/react": "^6.4.19",
|
|
24
24
|
"@storybook/theming": "^6.4.19",
|
|
25
|
-
"@swc/core": "^1.2.
|
|
25
|
+
"@swc/core": "^1.2.165",
|
|
26
26
|
"@swc/jest": "^0.2.20",
|
|
27
27
|
"@types/jest": "^27.4.1",
|
|
28
28
|
"@types/lodash.merge": "^4.6.6",
|
|
29
29
|
"@types/lodash.range": "^3.2.6",
|
|
30
30
|
"@types/node": "^14.18.10",
|
|
31
|
-
"@types/react": "^17.0.
|
|
32
|
-
"@types/react-dom": "^17.0.
|
|
31
|
+
"@types/react": "^17.0.44",
|
|
32
|
+
"@types/react-dom": "^17.0.15",
|
|
33
33
|
"@types/react-test-renderer": "^17.0.1",
|
|
34
34
|
"@types/react-transition-group": "^4.4.4",
|
|
35
|
-
"@types/styled-components": "^5.1.
|
|
35
|
+
"@types/styled-components": "^5.1.25",
|
|
36
36
|
"babel-loader": "^8.2.4",
|
|
37
37
|
"ecma-version-validator-webpack-plugin": "^1.2.1",
|
|
38
38
|
"eslint": "^8.12.0",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"npm-run-all": "^4.1.5",
|
|
48
48
|
"postcss-jsx": "^0.36.4",
|
|
49
49
|
"postcss-syntax": "^0.36.2",
|
|
50
|
-
"prettier": "^2.6.
|
|
50
|
+
"prettier": "^2.6.2",
|
|
51
51
|
"prettier-config-smarthr": "^1.0.0",
|
|
52
|
-
"puppeteer": "^13.5.
|
|
52
|
+
"puppeteer": "^13.5.2",
|
|
53
53
|
"react": "^17.0.2",
|
|
54
54
|
"react-dom": "^17.0.2",
|
|
55
55
|
"react-test-renderer": "^17.0.2",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"reg-suit": "^0.11.1",
|
|
60
60
|
"standard-version": "^9.3.2",
|
|
61
61
|
"storybook-readme": "^5.0.9",
|
|
62
|
-
"storycap": "^3.1.
|
|
62
|
+
"storycap": "^3.1.7",
|
|
63
63
|
"styled-components": "^5.3.5",
|
|
64
64
|
"styled-reset": "^4.3.4",
|
|
65
65
|
"stylelint": "^14.6.1",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"minimist": "1.2.6",
|
|
148
148
|
"react": "^17.0.2",
|
|
149
149
|
"react-dom": "^17.0.2",
|
|
150
|
-
"@types/react": "^17.0.
|
|
150
|
+
"@types/react": "^17.0.44",
|
|
151
151
|
"@babel/helper-compilation-targets": "^7.17.7"
|
|
152
152
|
}
|
|
153
153
|
}
|