smarthr-ui 21.2.0 → 21.3.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 +16 -0
- package/esm/components/AppNavi/appNaviHelper.d.ts +3 -3
- package/esm/components/BottomFixedArea/bottomFixedAreaHelper.d.ts +1 -1
- package/esm/components/Button/AnchorButton.d.ts +2 -2
- package/esm/components/Button/AnchorButton.js +6 -4
- package/esm/components/Button/AnchorButton.js.map +1 -1
- package/esm/components/Button/Button.d.ts +2 -2
- package/esm/components/Button/Button.js +6 -4
- package/esm/components/Button/Button.js.map +1 -1
- package/esm/components/Button/ButtonWrapper.d.ts +12 -4
- package/esm/components/Button/ButtonWrapper.js +3 -3
- package/esm/components/Button/ButtonWrapper.js.map +1 -1
- package/esm/components/Dropdown/Dropdown.js +5 -8
- package/esm/components/Dropdown/Dropdown.js.map +1 -1
- package/esm/components/Dropdown/DropdownButton/DropdownButton.d.ts +3 -2
- package/esm/components/Dropdown/DropdownButton/DropdownButton.js +7 -5
- package/esm/components/Dropdown/DropdownButton/DropdownButton.js.map +1 -1
- package/esm/components/Dropdown/DropdownButton/useClassNames.d.ts +5 -0
- package/esm/components/Dropdown/DropdownButton/useClassNames.js +12 -0
- package/esm/components/Dropdown/DropdownButton/useClassNames.js.map +1 -0
- package/esm/components/Dropdown/DropdownContentInner.js +1 -1
- package/esm/components/Dropdown/DropdownContentInner.js.map +1 -1
- package/esm/components/Dropdown/useKeyboardNavigation.d.ts +1 -1
- package/esm/components/Dropdown/useKeyboardNavigation.js +8 -3
- package/esm/components/Dropdown/useKeyboardNavigation.js.map +1 -1
- package/esm/components/Header/Header.d.ts +22 -0
- package/esm/components/Header/Header.js +64 -0
- package/esm/components/Header/Header.js.map +1 -0
- package/esm/components/Header/HeaderDropdownButton.d.ts +1320 -0
- package/esm/components/Header/HeaderDropdownButton.js +19 -0
- package/esm/components/Header/HeaderDropdownButton.js.map +1 -0
- package/esm/components/Header/HeaderLink.d.ts +273 -0
- package/esm/components/Header/HeaderLink.js +18 -0
- package/esm/components/Header/HeaderLink.js.map +1 -0
- package/esm/components/Header/index.d.ts +3 -0
- package/esm/components/Header/index.js +4 -0
- package/esm/components/Header/index.js.map +1 -0
- package/esm/components/Header/useClassNames.d.ts +6 -0
- package/esm/components/Header/useClassNames.js +13 -0
- package/esm/components/Header/useClassNames.js.map +1 -0
- package/esm/components/MessageScreen/MessageScreen.js +2 -5
- package/esm/components/MessageScreen/MessageScreen.js.map +1 -1
- package/esm/components/NotificationBar/NotificationBar.js +23 -19
- package/esm/components/NotificationBar/NotificationBar.js.map +1 -1
- package/esm/components/NotificationBar/useClassNames.d.ts +2 -0
- package/esm/components/NotificationBar/useClassNames.js +2 -0
- package/esm/components/NotificationBar/useClassNames.js.map +1 -1
- package/esm/components/Pagination/Pagination.js +2 -2
- package/esm/components/Pagination/Pagination.js.map +1 -1
- package/esm/components/Pagination/PaginationItem.d.ts +2 -2
- package/esm/components/SmartHRLogo/SmartHRLogo.d.ts +2 -2
- package/esm/components/SmartHRLogo/SmartHRLogo.js +25 -16
- package/esm/components/SmartHRLogo/SmartHRLogo.js.map +1 -1
- package/esm/components/TabBar/TabBar.js +2 -1
- package/esm/components/TabBar/TabBar.js.map +1 -1
- package/esm/hooks/useClassNameGenerator.d.ts +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/themes/createShadow.d.ts +3 -0
- package/esm/themes/createShadow.js +2 -0
- package/esm/themes/createShadow.js.map +1 -1
- package/lib/components/AppNavi/appNaviHelper.d.ts +3 -3
- package/lib/components/BottomFixedArea/bottomFixedAreaHelper.d.ts +1 -1
- package/lib/components/Button/AnchorButton.d.ts +2 -2
- package/lib/components/Button/AnchorButton.js +28 -7
- package/lib/components/Button/AnchorButton.js.map +1 -1
- package/lib/components/Button/Button.d.ts +2 -2
- package/lib/components/Button/Button.js +28 -7
- package/lib/components/Button/Button.js.map +1 -1
- package/lib/components/Button/ButtonWrapper.d.ts +12 -4
- package/lib/components/Button/ButtonWrapper.js +2 -2
- package/lib/components/Button/ButtonWrapper.js.map +1 -1
- package/lib/components/Dropdown/Dropdown.js +5 -8
- package/lib/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/components/Dropdown/DropdownButton/DropdownButton.d.ts +3 -2
- package/lib/components/Dropdown/DropdownButton/DropdownButton.js +7 -5
- package/lib/components/Dropdown/DropdownButton/DropdownButton.js.map +1 -1
- package/lib/components/Dropdown/DropdownButton/useClassNames.d.ts +5 -0
- package/lib/components/Dropdown/DropdownButton/useClassNames.js +16 -0
- package/lib/components/Dropdown/DropdownButton/useClassNames.js.map +1 -0
- package/lib/components/Dropdown/DropdownContentInner.js +1 -1
- package/lib/components/Dropdown/DropdownContentInner.js.map +1 -1
- package/lib/components/Dropdown/useKeyboardNavigation.d.ts +1 -1
- package/lib/components/Dropdown/useKeyboardNavigation.js +8 -3
- package/lib/components/Dropdown/useKeyboardNavigation.js.map +1 -1
- package/lib/components/Header/Header.d.ts +22 -0
- package/lib/components/Header/Header.js +91 -0
- package/lib/components/Header/Header.js.map +1 -0
- package/lib/components/Header/HeaderDropdownButton.d.ts +1320 -0
- package/lib/components/Header/HeaderDropdownButton.js +45 -0
- package/lib/components/Header/HeaderDropdownButton.js.map +1 -0
- package/lib/components/Header/HeaderLink.d.ts +273 -0
- package/lib/components/Header/HeaderLink.js +44 -0
- package/lib/components/Header/HeaderLink.js.map +1 -0
- package/lib/components/Header/index.d.ts +3 -0
- package/lib/components/Header/index.js +20 -0
- package/lib/components/Header/index.js.map +1 -0
- package/lib/components/Header/useClassNames.d.ts +6 -0
- package/lib/components/Header/useClassNames.js +17 -0
- package/lib/components/Header/useClassNames.js.map +1 -0
- package/lib/components/MessageScreen/MessageScreen.js +2 -5
- package/lib/components/MessageScreen/MessageScreen.js.map +1 -1
- package/lib/components/NotificationBar/NotificationBar.js +22 -18
- package/lib/components/NotificationBar/NotificationBar.js.map +1 -1
- package/lib/components/NotificationBar/useClassNames.d.ts +2 -0
- package/lib/components/NotificationBar/useClassNames.js +2 -0
- package/lib/components/NotificationBar/useClassNames.js.map +1 -1
- package/lib/components/Pagination/Pagination.js +2 -2
- package/lib/components/Pagination/Pagination.js.map +1 -1
- package/lib/components/Pagination/PaginationItem.d.ts +2 -2
- package/lib/components/SmartHRLogo/SmartHRLogo.d.ts +2 -2
- package/lib/components/SmartHRLogo/SmartHRLogo.js +24 -15
- package/lib/components/SmartHRLogo/SmartHRLogo.js.map +1 -1
- package/lib/components/TabBar/TabBar.js +2 -1
- package/lib/components/TabBar/TabBar.js.map +1 -1
- package/lib/hooks/useClassNameGenerator.d.ts +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +6 -2
- package/lib/index.js.map +1 -1
- package/lib/themes/createShadow.d.ts +3 -0
- package/lib/themes/createShadow.js +2 -0
- package/lib/themes/createShadow.js.map +1 -1
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
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
|
+
## [21.3.0](https://github.com/kufu/smarthr-ui/compare/v21.2.0...v21.3.0) (2022-06-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* Header を追加|SHRUI-346 ([#2536](https://github.com/kufu/smarthr-ui/issues/2536)) ([3266007](https://github.com/kufu/smarthr-ui/commit/326600773b2c793388827ed862fcec9e209865b2))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* `NotificationBar` の右寄せ部分にエスケープハッチを追加 (SHRUI-555) ([#2469](https://github.com/kufu/smarthr-ui/issues/2469)) ([239c6e4](https://github.com/kufu/smarthr-ui/commit/239c6e494ba52cbc7b53c28fbc470339b8502729))
|
|
16
|
+
* apply forwardRef to Button and AnchorButton ([#2540](https://github.com/kufu/smarthr-ui/issues/2540)) ([4378f51](https://github.com/kufu/smarthr-ui/commit/4378f51342fba32a35ca09ac513cd9417a165402))
|
|
17
|
+
* set Button default type to 'button' ([#2542](https://github.com/kufu/smarthr-ui/issues/2542)) ([fa94faf](https://github.com/kufu/smarthr-ui/commit/fa94faf7686200bb22638a7ba24d7b5e67744962))
|
|
18
|
+
* ドロップダウンのフォーカス制御の修正 ([#2535](https://github.com/kufu/smarthr-ui/issues/2535)) ([fe45084](https://github.com/kufu/smarthr-ui/commit/fe45084e71e1537eb4ae5da3dcab6c0c1e6acad6))
|
|
19
|
+
* フォーカスリングが見きれないように修正 (SHRUI-565) ([#2537](https://github.com/kufu/smarthr-ui/issues/2537)) ([9fb9dfd](https://github.com/kufu/smarthr-ui/commit/9fb9dfd42932f64f939383eab666ced5e3e1af66))
|
|
20
|
+
|
|
5
21
|
## [21.2.0](https://github.com/kufu/smarthr-ui/compare/v21.1.0...v21.2.0) (2022-05-30)
|
|
6
22
|
|
|
7
23
|
|
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { Theme } from '../../hooks/useTheme';
|
|
3
3
|
import { ComponentProps as IconProps } from '../Icon';
|
|
4
4
|
export declare const getIconComponent: (theme: Theme, options?: {
|
|
5
|
-
icon?: React.ComponentType<IconProps
|
|
6
|
-
current?: boolean
|
|
7
|
-
}
|
|
5
|
+
icon?: React.ComponentType<IconProps>;
|
|
6
|
+
current?: boolean;
|
|
7
|
+
}) => JSX.Element | null;
|
|
8
8
|
export declare type ItemStyleProps = {
|
|
9
9
|
themes: Theme;
|
|
10
10
|
isActive?: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Primary, Secondary } from './BottomFixedArea';
|
|
2
|
-
export declare const validateElement: (primary?: Primary
|
|
2
|
+
export declare const validateElement: (primary?: Primary, secondary?: Secondary) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnchorHTMLAttributes
|
|
1
|
+
import React, { AnchorHTMLAttributes } from 'react';
|
|
2
2
|
import { BaseProps } from './types';
|
|
3
3
|
declare type ElementProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof BaseProps>;
|
|
4
|
-
export declare const AnchorButton:
|
|
4
|
+
export declare const AnchorButton: React.ForwardRefExoticComponent<BaseProps & ElementProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
5
5
|
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
2
2
|
import { useClassNames } from './useClassNames';
|
|
3
3
|
import { ButtonWrapper } from './ButtonWrapper';
|
|
4
4
|
import { ButtonInner } from './ButtonInner';
|
|
5
|
-
export const AnchorButton = ({ size = 'default', square = false, prefix, suffix, wide = false, variant = 'secondary', className = '', children, ...props }) => {
|
|
5
|
+
export const AnchorButton = forwardRef(({ size = 'default', square = false, prefix, suffix, wide = false, variant = 'secondary', className = '', children, ...props }, ref) => {
|
|
6
|
+
const anchorRef = useRef(null);
|
|
7
|
+
useImperativeHandle(ref, () => anchorRef.current);
|
|
6
8
|
const classNames = useClassNames().anchorButton;
|
|
7
|
-
return (React.createElement(ButtonWrapper, { ...props, size: size, square: square, wide: wide, variant: variant, className: `${className} ${classNames.wrapper}`, isAnchor: true },
|
|
9
|
+
return (React.createElement(ButtonWrapper, { ...props, size: size, square: square, wide: wide, variant: variant, className: `${className} ${classNames.wrapper}`, isAnchor: true, anchorRef: anchorRef },
|
|
8
10
|
React.createElement(ButtonInner, { prefix: prefix, suffix: suffix }, children)));
|
|
9
|
-
};
|
|
11
|
+
});
|
|
10
12
|
//# sourceMappingURL=AnchorButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnchorButton.js","sourceRoot":"","sources":["../../../src/components/Button/AnchorButton.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AnchorButton.js","sourceRoot":"","sources":["../../../src/components/Button/AnchorButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAwB,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAG5F,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAI3C,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CACpC,CACE,EACE,IAAI,GAAG,SAAS,EAChB,MAAM,GAAG,KAAK,EACd,MAAM,EACN,MAAM,EACN,IAAI,GAAG,KAAK,EACZ,OAAO,GAAG,WAAW,EACrB,SAAS,GAAG,EAAE,EACd,QAAQ,EACR,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAA;IACjD,mBAAmB,CACjB,GAAG,EACH,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CACxB,CAAA;IACD,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC,YAAY,CAAA;IAE/C,OAAO,CACL,oBAAC,aAAa,OACR,KAAK,EACT,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,GAAG,SAAS,IAAI,UAAU,CAAC,OAAO,EAAE,EAC/C,QAAQ,QACR,SAAS,EAAE,SAAS;QAEpB,oBAAC,WAAW,IAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IACxC,QAAQ,CACG,CACA,CACjB,CAAA;AACH,CAAC,CACF,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes
|
|
1
|
+
import React, { ButtonHTMLAttributes } from 'react';
|
|
2
2
|
import { BaseProps } from './types';
|
|
3
3
|
declare type ElementProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, keyof BaseProps>;
|
|
4
|
-
export declare const Button:
|
|
4
|
+
export declare const Button: React.ForwardRefExoticComponent<BaseProps & ElementProps & React.RefAttributes<HTMLButtonElement>>;
|
|
5
5
|
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
2
2
|
import { useClassNames } from './useClassNames';
|
|
3
3
|
import { ButtonWrapper } from './ButtonWrapper';
|
|
4
4
|
import { ButtonInner } from './ButtonInner';
|
|
5
|
-
export const Button = ({ size = 'default', square = false, prefix, suffix, wide = false, variant = 'secondary', className = '', children, ...props }) => {
|
|
5
|
+
export const Button = forwardRef(({ type = 'button', size = 'default', square = false, prefix, suffix, wide = false, variant = 'secondary', className = '', children, ...props }, ref) => {
|
|
6
|
+
const buttonRef = useRef(null);
|
|
7
|
+
useImperativeHandle(ref, () => buttonRef.current);
|
|
6
8
|
const classNames = useClassNames().button;
|
|
7
|
-
return (React.createElement(ButtonWrapper, { ...props, size: size, square: square, wide: wide, variant: variant, className: `${className} ${classNames.wrapper}
|
|
9
|
+
return (React.createElement(ButtonWrapper, { ...props, type: type, size: size, square: square, wide: wide, variant: variant, className: `${className} ${classNames.wrapper}`, buttonRef: buttonRef },
|
|
8
10
|
React.createElement(ButtonInner, { prefix: prefix, suffix: suffix }, children)));
|
|
9
|
-
};
|
|
11
|
+
});
|
|
10
12
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAwB,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAG5F,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAI3C,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAC9B,CACE,EACE,IAAI,GAAG,QAAQ,EACf,IAAI,GAAG,SAAS,EAChB,MAAM,GAAG,KAAK,EACd,MAAM,EACN,MAAM,EACN,IAAI,GAAG,KAAK,EACZ,OAAO,GAAG,WAAW,EACrB,SAAS,GAAG,EAAE,EACd,QAAQ,EACR,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAA;IACjD,mBAAmB,CACjB,GAAG,EACH,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CACxB,CAAA;IACD,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC,MAAM,CAAA;IAEzC,OAAO,CACL,oBAAC,aAAa,OACR,KAAK,EACT,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,GAAG,SAAS,IAAI,UAAU,CAAC,OAAO,EAAE,EAC/C,SAAS,EAAE,SAAS;QAEpB,oBAAC,WAAW,IAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IACxC,QAAQ,CACG,CACA,CACjB,CAAA;AACH,CAAC,CACF,CAAA"}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode, RefObject } from 'react';
|
|
2
2
|
import { Variant } from './types';
|
|
3
|
-
declare type
|
|
3
|
+
declare type BaseProps = {
|
|
4
4
|
size: 'default' | 's';
|
|
5
5
|
square: boolean;
|
|
6
6
|
wide: boolean;
|
|
7
7
|
variant: Variant;
|
|
8
8
|
className: string;
|
|
9
9
|
children: ReactNode;
|
|
10
|
-
isAnchor?: boolean;
|
|
11
10
|
};
|
|
12
|
-
|
|
11
|
+
declare type ButtonProps = BaseProps & {
|
|
12
|
+
isAnchor?: never;
|
|
13
|
+
buttonRef?: RefObject<HTMLButtonElement>;
|
|
14
|
+
};
|
|
15
|
+
declare type AnchorProps = BaseProps & {
|
|
16
|
+
isAnchor: true;
|
|
17
|
+
anchorRef?: RefObject<HTMLAnchorElement>;
|
|
18
|
+
};
|
|
19
|
+
declare type Props = (ButtonProps & Omit<ButtonHTMLAttributes<HTMLButtonElement>, keyof ButtonProps>) | (AnchorProps & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof AnchorProps>);
|
|
20
|
+
export declare function ButtonWrapper({ size, square, className, ...props }: Props): JSX.Element;
|
|
13
21
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { useMemo, } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { useTheme } from '../../hooks/useTheme';
|
|
4
|
-
export function ButtonWrapper({ size, square, className,
|
|
4
|
+
export function ButtonWrapper({ size, square, className, ...props }) {
|
|
5
5
|
const theme = useTheme();
|
|
6
6
|
const buttonClassName = useMemo(() => `${size} ${className} ${square ? 'square' : ''}`, [className, size, square]);
|
|
7
|
-
return isAnchor ? (React.createElement(Anchor, { ...props, className: buttonClassName, themes: theme })) : (React.createElement(Button, { ...props, className: buttonClassName, themes: theme }));
|
|
7
|
+
return props.isAnchor ? (React.createElement(Anchor, { ...props, className: buttonClassName, ref: props.anchorRef, themes: theme })) : (React.createElement(Button, { ...props, className: buttonClassName, ref: props.buttonRef, themes: theme }));
|
|
8
8
|
}
|
|
9
9
|
const baseStyles = css(({ wide, themes }) => {
|
|
10
10
|
const { border, fontSize, leading, radius, shadow, spacingByChar } = themes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonWrapper.js","sourceRoot":"","sources":["../../../src/components/Button/ButtonWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ButtonWrapper.js","sourceRoot":"","sources":["../../../src/components/Button/ButtonWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAKZ,OAAO,GACR,MAAM,OAAO,CAAA;AACd,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAS,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AA2BtD,MAAM,UAAU,aAAa,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,EAAS;IACxE,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IACxB,MAAM,eAAe,GAAG,OAAO,CAC7B,GAAG,EAAE,CAAC,GAAG,IAAI,IAAI,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EACtD,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CAC1B,CAAA;IACD,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CACtB,oBAAC,MAAM,OAAK,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,GAAI,CACvF,CAAC,CAAC,CAAC,CACF,oBAAC,MAAM,OAAK,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,GAAI,CACvF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,GAAG,GAAG,CAAa,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;IACtD,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAA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
|
68
|
-
|
|
69
|
-
trigger.focus();
|
|
70
|
-
}
|
|
71
|
-
});
|
|
64
|
+
// return focus to the Trigger
|
|
65
|
+
const trigger = getFirstTabbable(triggerElementRef);
|
|
66
|
+
if (trigger) {
|
|
67
|
+
trigger.focus();
|
|
68
|
+
}
|
|
72
69
|
},
|
|
73
70
|
DropdownContentRoot,
|
|
74
71
|
contentId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../../src/components/Dropdown/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAIZ,aAAa,EACb,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,EAAQ,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAiBzC,MAAM,WAAW,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;AAE5D,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAsB;IAChE,MAAM,EAAE,KAAK;IACb,WAAW,EAAE,WAAW;IACxB,iBAAiB,EAAE,KAAK,CAAC,SAAS,EAAE;IACpC,cAAc,EAAE,IAAI;IACpB,cAAc,EAAE,GAAG,EAAE;QACnB,UAAU;IACZ,CAAC;IACD,aAAa,EAAE,GAAG,EAAE;QAClB,UAAU;IACZ,CAAC;IACD,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAI;IAC/B,SAAS,EAAE,EAAE;CACd,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAe,CAAC,EAAE,Q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
|
+
import { ComponentProps, HTMLAttributes, ReactElement, VFC } from 'react';
|
|
2
2
|
import { AnchorButton, Button } from '../../..';
|
|
3
3
|
import { BaseProps as ButtonProps } from '../../Button/types';
|
|
4
4
|
declare type Actions = ActionItem | ActionItem[];
|
|
@@ -15,5 +15,6 @@ declare type Props = {
|
|
|
15
15
|
/** 引き金となるボタンの `disabled` 属性の値 */
|
|
16
16
|
disabled?: boolean;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
declare type ElementProps = Omit<HTMLAttributes<HTMLElement>, keyof Props>;
|
|
19
|
+
export declare const DropdownButton: VFC<Props & ElementProps>;
|
|
19
20
|
export {};
|
|
@@ -2,15 +2,17 @@ import React, { useMemo } from 'react';
|
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { Button, Dropdown, DropdownContent, DropdownTrigger, FaCaretDownIcon, FaEllipsisHIcon, Stack, } from '../../..';
|
|
4
4
|
import { useTheme } from '../../../hooks/useTheme';
|
|
5
|
-
|
|
5
|
+
import { useClassNames } from './useClassNames';
|
|
6
|
+
export const DropdownButton = ({ label = 'その他の操作', children, triggerSize, onlyIconTrigger = false, disabled = false, className = '', ...props }) => {
|
|
6
7
|
const themes = useTheme();
|
|
8
|
+
const classNames = useClassNames();
|
|
7
9
|
const triggerLabel = useMemo(() => (onlyIconTrigger ? React.createElement(FaEllipsisHIcon, { visuallyHiddenText: label }) : label), [onlyIconTrigger, label]);
|
|
8
10
|
const triggerSuffix = useMemo(() => (onlyIconTrigger ? React.createElement(React.Fragment, null) : React.createElement(FaCaretDownIcon, { visuallyHiddenText: "\u5019\u88DC\u3092\u958B\u304F" })), [onlyIconTrigger]);
|
|
9
|
-
return (React.createElement(Dropdown,
|
|
10
|
-
React.createElement(DropdownTrigger,
|
|
11
|
-
React.createElement(Trigger, { suffix: triggerSuffix, size: triggerSize, disabled: disabled, square: onlyIconTrigger }, triggerLabel)),
|
|
11
|
+
return (React.createElement(Dropdown, { ...props },
|
|
12
|
+
React.createElement(DropdownTrigger, { className: `${classNames.wrapper}${className && ` ${className}`}` },
|
|
13
|
+
React.createElement(Trigger, { suffix: triggerSuffix, size: triggerSize, disabled: disabled, square: onlyIconTrigger, className: classNames.trigger }, triggerLabel)),
|
|
12
14
|
React.createElement(DropdownContent, null,
|
|
13
|
-
React.createElement(ActionList, { themes: themes }, React.Children.map(children, (item, i) => (React.createElement("li", { key: i }, actionItem(item))))))));
|
|
15
|
+
React.createElement(ActionList, { themes: themes, className: classNames.panel }, React.Children.map(children, (item, i) => (React.createElement("li", { key: i }, actionItem(item))))))));
|
|
14
16
|
};
|
|
15
17
|
const Trigger = styled(Button) `
|
|
16
18
|
&[aria-expanded='true'] .smarthr-ui-Icon {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownButton.js","sourceRoot":"","sources":["../../../../src/components/Dropdown/DropdownButton/DropdownButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"DropdownButton.js","sourceRoot":"","sources":["../../../../src/components/Dropdown/DropdownButton/DropdownButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAqD,OAAO,EAAE,MAAM,OAAO,CAAA;AACzF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAEL,MAAM,EACN,QAAQ,EACR,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,KAAK,GACN,MAAM,UAAU,CAAA;AACjB,OAAO,EAAS,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAsB/C,MAAM,CAAC,MAAM,cAAc,GAA8B,CAAC,EACxD,KAAK,GAAG,QAAQ,EAChB,QAAQ,EACR,WAAW,EACX,eAAe,GAAG,KAAK,EACvB,QAAQ,GAAG,KAAK,EAChB,SAAS,GAAG,EAAE,EACd,GAAG,KAAK,EACT,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AAG,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAmB;IAC3E,CAAC,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;;;qBAGrB,aAAa,CAAC,GAAG,CAAC;;;;;;;uBAOhB,aAAa,CAAC,GAAG,CAAC;;;GAGtC;CACF,CAAA;AACD,MAAM,UAAU,GAAG,CAAC,IAAkB,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useClassNameGenerator } from '../../../hooks/useClassNameGenerator';
|
|
3
|
+
import { DropdownButton } from './DropdownButton';
|
|
4
|
+
export function useClassNames() {
|
|
5
|
+
const generate = useClassNameGenerator(DropdownButton.displayName || 'DropdownButton');
|
|
6
|
+
return useMemo(() => ({
|
|
7
|
+
wrapper: generate(),
|
|
8
|
+
trigger: generate('trigger'),
|
|
9
|
+
panel: generate('panel'),
|
|
10
|
+
}), [generate]);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=useClassNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClassNames.js","sourceRoot":"","sources":["../../../../src/components/Dropdown/DropdownButton/useClassNames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,UAAU,aAAa;IAC3B,MAAM,QAAQ,GAAG,qBAAqB,CAAC,cAAc,CAAC,WAAW,IAAI,gBAAgB,CAAC,CAAA;IACtF,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,OAAO,EAAE,QAAQ,EAAE;QACnB,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC;QAC5B,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC;KACzB,CAAC,EACF,CAAC,QAAQ,CAAC,CACX,CAAA;AACH,CAAC"}
|
|
@@ -36,7 +36,7 @@ export const DropdownContentInner = ({ triggerRect, scrollable, children, classN
|
|
|
36
36
|
focusTargetRef.current?.focus();
|
|
37
37
|
}
|
|
38
38
|
}, [isActive]);
|
|
39
|
-
useKeyboardNavigation(wrapperRef);
|
|
39
|
+
useKeyboardNavigation(wrapperRef, focusTargetRef);
|
|
40
40
|
return (React.createElement(Wrapper, { ref: wrapperRef, contentBox: contentBox, className: `${className} ${isActive ? 'active' : ''}`, themes: theme },
|
|
41
41
|
React.createElement("div", { tabIndex: -1, ref: focusTargetRef }),
|
|
42
42
|
controllable ? (React.createElement(ControllableWrapper, { scrollable: scrollable, contentBox: contentBox }, children)) : (React.createElement(DropdownContentInnerContext.Provider, { value: { maxHeight: contentBox.maxHeight } },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownContentInner.js","sourceRoot":"","sources":["../../../src/components/Dropdown/DropdownContentInner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAO,aAAa,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACpF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAS,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAyB,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAc/D,MAAM,CAAC,MAAM,2BAA2B,GA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AAA;IAC/D,MAAM,UAAU,GACd,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,IAAI,QAAQ,CAAA;IACrF,MAAM,WAAW,GACf,UAAU,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,KAAK,QAAQ,CAAA;IAEvF,OAAO,GAAG,CAAA;;;iBAGG,MAAM,CAAC,YAAY;;aAEvB,UAAU,CAAC,GAAG;QACnB,UAAU,CAAC,IAAI,KAAK,SAAS;QAC/B,GAAG,CAAA;gBACO,UAAU,CAAC,IAAI;OACxB;QACC,UAAU,CAAC,KAAK,KAAK,SAAS;QAChC,GAAG,CAAA;iBACQ,UAAU,CAAC,KAAK;OAC1B;+BACwB,UAAU,MAAM,WAAW;;uBAEnC,MAAM,CAAC,CAAC;oBACX,MAAM,CAAC,MAAM;0BACP,KAAK,CAAC,KAAK;;;;;KAKhC,CAAA;AACH,CAAC;CACF,CAAA;AACD,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAGpC;IACE,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE;IAC/B,OAAO,GAAG,CAAA;;;QAGN,UAAU,CAAC,SAAS,IAAI,UAAU;QAClC,CAAC,CAAC;wBACc,UAAU,CAAC,SAAS;WACjC;QACH,CAAC,CAAC,EAAE;KACP,CAAA;AACH,CAAC;CACF,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
-
export declare function useKeyboardNavigation(wrapperRef: RefObject<HTMLDivElement>): void;
|
|
2
|
+
export declare function useKeyboardNavigation(wrapperRef: RefObject<HTMLDivElement>, dummyFocusRef: RefObject<HTMLElement>): void;
|
|
@@ -2,7 +2,7 @@ import { useCallback, useContext, useEffect } from 'react';
|
|
|
2
2
|
import { tabbable } from '../../libs/tabbable';
|
|
3
3
|
import { DropdownContext } from './Dropdown';
|
|
4
4
|
import { getFirstTabbable } from './dropdownHelper';
|
|
5
|
-
export function useKeyboardNavigation(wrapperRef) {
|
|
5
|
+
export function useKeyboardNavigation(wrapperRef, dummyFocusRef) {
|
|
6
6
|
const { triggerElementRef, rootTriggerRef, onClickCloser } = useContext(DropdownContext);
|
|
7
7
|
const handleKeyDown = useCallback((e) => {
|
|
8
8
|
if (e.key === 'Tab') {
|
|
@@ -30,7 +30,8 @@ export function useKeyboardNavigation(wrapperRef) {
|
|
|
30
30
|
firstTabbable.focus();
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
else if (e.shiftKey &&
|
|
33
|
+
else if (e.shiftKey &&
|
|
34
|
+
(e.target === firstTabbable || e.target === dummyFocusRef.current)) {
|
|
34
35
|
// focus the Trigger
|
|
35
36
|
e.preventDefault();
|
|
36
37
|
trigger.focus();
|
|
@@ -53,6 +54,10 @@ export function useKeyboardNavigation(wrapperRef) {
|
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
56
|
}
|
|
57
|
+
if (e.target && e.target === dummyFocusRef.current) {
|
|
58
|
+
onClickCloser();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
56
61
|
if (wrapperRef.current) {
|
|
57
62
|
const tabbablesInContent = tabbable(wrapperRef.current);
|
|
58
63
|
tabbablesInContent.some((inner) => {
|
|
@@ -65,7 +70,7 @@ export function useKeyboardNavigation(wrapperRef) {
|
|
|
65
70
|
});
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
|
-
}, [wrapperRef, triggerElementRef, rootTriggerRef, onClickCloser]);
|
|
73
|
+
}, [wrapperRef, triggerElementRef, rootTriggerRef, dummyFocusRef, onClickCloser]);
|
|
69
74
|
useEffect(() => {
|
|
70
75
|
window.addEventListener('keydown', handleKeyDown);
|
|
71
76
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeyboardNavigation.js","sourceRoot":"","sources":["../../../src/components/Dropdown/useKeyboardNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEnD,MAAM,UAAU,qBAAqB,
|
|
1
|
+
{"version":3,"file":"useKeyboardNavigation.js","sourceRoot":"","sources":["../../../src/components/Dropdown/useKeyboardNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEnD,MAAM,UAAU,qBAAqB,CACnC,UAAqC,EACrC,aAAqC;IAErC,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,UAAU,CAAC,eAAe,CAAC,CAAA;IAExF,MAAM,aAAa,GAAG,WAAW,CAC/B,CAAC,CAAgB,EAAE,EAAE;QACnB,IAAI,CAAC,CAAC,GAAG,KAAK,KAAK,EAAE;YACnB,IACE,CAAC,UAAU,CAAC,OAAO;gBACnB,CAAC,iBAAiB,CAAC,OAAO;gBAC1B,CAAC,cAAc;gBACf,CAAC,cAAc,CAAC,OAAO,EACvB;gBACA,OAAM;aACP;YACD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;YACvD,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE;gBACnC,OAAM;aACP;YACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,iB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AAO,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO,EAAE;oBACnC,wEAAwE;oBACxE,aAAa,EAAE,CAAA;oBACf,OAAM;iBACP;aACF;YAED,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC,OAAO,EAAE;gBAClD,aAAa,EAAE,CAAA;gBACf,OAAM;aACP;YAED,IAAI,UAAU,CAAC,OAAO,EAAE;gBACtB,MAAM,kBAAkB,GAAG,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;gBACvD,kBAAkB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;oBAChC,IAAI,KAAK,KAAK,CAAC,CAAC,MAAM,EAAE;wBACtB,4GAA4G;wBAC5G,aAAa,EAAE,CAAA;wBACf,OAAO,IAAI,CAAA;qBACZ;oBACD,OAAO,KAAK,CAAA;gBACd,CAAC,CAAC,CAAA;aACH;SACF;IACH,CAAC,EACD,CAAC,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,CAAC,CAC9E,CAAA;IACD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;QACjD,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;QACtD,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAA;AACrB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { HTMLAttributes, ReactElement } from 'react';
|
|
2
|
+
declare type Tenant = {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
declare type Props = {
|
|
7
|
+
/** ロゴ */
|
|
8
|
+
logo?: ReactElement;
|
|
9
|
+
/** ロゴリンク */
|
|
10
|
+
logoHref?: string;
|
|
11
|
+
/** テナント */
|
|
12
|
+
tenants?: string | Tenant[];
|
|
13
|
+
/** 現在のテナント ID */
|
|
14
|
+
currentTenantId?: string;
|
|
15
|
+
/** テナントが選択された時に発火するコールバック関数 */
|
|
16
|
+
onTenantSelect?: (id: string) => void;
|
|
17
|
+
/** 操作領域 */
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
};
|
|
20
|
+
declare type ElementProps = Omit<HTMLAttributes<HTMLElement>, keyof Props>;
|
|
21
|
+
export declare const Header: React.VFC<Props & ElementProps>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { useClassNames } from './useClassNames';
|
|
4
|
+
import { Cluster } from '../Layout';
|
|
5
|
+
import { SmartHRLogo } from '../SmartHRLogo';
|
|
6
|
+
import { Text } from '../Text';
|
|
7
|
+
import { HeaderDropdownButton } from './';
|
|
8
|
+
import { Button } from '../Button';
|
|
9
|
+
export const Header = ({ logo = React.createElement(SmartHRLogo, { height: "1.5em" }), logoHref = '/', tenants, currentTenantId, onTenantSelect, children, }) => {
|
|
10
|
+
const classNames = useClassNames();
|
|
11
|
+
const currentTenantName = useMemo(() => {
|
|
12
|
+
if (Array.isArray(tenants)) {
|
|
13
|
+
const current = tenants.find(({ id }) => id === currentTenantId);
|
|
14
|
+
return current ? current.name : tenants[0].name;
|
|
15
|
+
}
|
|
16
|
+
return tenants;
|
|
17
|
+
}, [currentTenantId, tenants]);
|
|
18
|
+
const tenantInfo = useMemo(() => Array.isArray(tenants) ? (React.createElement(HeaderDropdownButton, { label: currentTenantName }, tenants.map(({ id, name }) => (React.createElement(Button, { key: id, onClick: () => onTenantSelect && onTenantSelect(id) }, name))))) : (React.createElement(TenantName, null, currentTenantName)), [currentTenantName, onTenantSelect, tenants]);
|
|
19
|
+
return (React.createElement(Wrapper, { className: classNames.wrapper },
|
|
20
|
+
React.createElement(Cluster, { align: "center", gap: { column: 0.25, row: 0 } },
|
|
21
|
+
React.createElement(LogoLink, { href: logoHref, className: classNames.logo }, logo),
|
|
22
|
+
currentTenantName && (React.createElement(TenantInfo, { className: classNames.tenantInfo }, tenantInfo))),
|
|
23
|
+
React.createElement(Actions, { className: classNames.actions }, children)));
|
|
24
|
+
};
|
|
25
|
+
const Wrapper = styled(Cluster).attrs({
|
|
26
|
+
as: 'header',
|
|
27
|
+
justify: 'space-between',
|
|
28
|
+
gap: { column: 0.25, row: 0 },
|
|
29
|
+
}) `
|
|
30
|
+
${({ theme: { color, spacingByChar } }) => css `
|
|
31
|
+
background-color: ${color.BRAND};
|
|
32
|
+
padding-inline: ${spacingByChar(1.25)};
|
|
33
|
+
|
|
34
|
+
@media (max-width: 768px) {
|
|
35
|
+
padding-inline: ${spacingByChar(0.75)};
|
|
36
|
+
}
|
|
37
|
+
`}
|
|
38
|
+
`;
|
|
39
|
+
const LogoLink = styled.a `
|
|
40
|
+
${({ theme: { shadow, spacingByChar } }) => css `
|
|
41
|
+
/* ロゴが持つ padding 分だけ調整 */
|
|
42
|
+
margin-inline-start: ${spacingByChar(-0.75)};
|
|
43
|
+
|
|
44
|
+
&:focus-visible {
|
|
45
|
+
${shadow.focusIndicatorStyles}
|
|
46
|
+
}
|
|
47
|
+
`}
|
|
48
|
+
`;
|
|
49
|
+
const TenantInfo = styled.div `
|
|
50
|
+
margin-inline-start: auto;
|
|
51
|
+
`;
|
|
52
|
+
const TenantName = styled(Text).attrs({ color: 'TEXT_WHITE' }) `
|
|
53
|
+
${({ theme: { spacingByChar } }) => css `
|
|
54
|
+
padding-inline: ${spacingByChar(0.25)};
|
|
55
|
+
`}
|
|
56
|
+
`;
|
|
57
|
+
const Actions = styled(Cluster).attrs({
|
|
58
|
+
align: 'center',
|
|
59
|
+
justify: 'flex-end',
|
|
60
|
+
gap: { column: 0.5, row: 0.25 },
|
|
61
|
+
}) `
|
|
62
|
+
margin-inline-start: auto;
|
|
63
|
+
`;
|
|
64
|
+
//# sourceMappingURL=Header.js.map
|
|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