smarthr-ui 22.0.0 → 22.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/components/Base/Base.d.ts +1 -6
- package/esm/components/Base/Base.js +10 -6
- package/esm/components/Base/Base.js.map +1 -1
- package/esm/components/Base/index.d.ts +1 -1
- package/esm/components/Base/index.js +1 -1
- package/esm/components/Base/index.js.map +1 -1
- package/esm/components/Button/ButtonWrapper.js +1 -1
- package/esm/components/Button/ButtonWrapper.js.map +1 -1
- package/esm/components/ComboBox/ComboBoxContext.d.ts +11 -0
- package/esm/components/ComboBox/ComboBoxContext.js +10 -0
- package/esm/components/ComboBox/ComboBoxContext.js.map +1 -0
- package/esm/components/ComboBox/ListBoxItem.d.ts +13 -0
- package/esm/components/ComboBox/ListBoxItem.js +88 -0
- package/esm/components/ComboBox/ListBoxItem.js.map +1 -0
- package/esm/components/ComboBox/MultiComboBox.js +133 -101
- package/esm/components/ComboBox/MultiComboBox.js.map +1 -1
- package/esm/components/ComboBox/MultiSelectedItem.d.ts +12 -5
- package/esm/components/ComboBox/MultiSelectedItem.js +81 -10
- package/esm/components/ComboBox/MultiSelectedItem.js.map +1 -1
- package/esm/components/ComboBox/MultiSelectedItemTooltip.d.ts +8 -0
- package/esm/components/ComboBox/MultiSelectedItemTooltip.js +6 -0
- package/esm/components/ComboBox/MultiSelectedItemTooltip.js.map +1 -0
- package/esm/components/ComboBox/SingleComboBox.js +84 -93
- package/esm/components/ComboBox/SingleComboBox.js.map +1 -1
- package/esm/components/ComboBox/types.d.ts +6 -0
- package/esm/components/ComboBox/useActiveOption.d.ts +9 -0
- package/esm/components/ComboBox/useActiveOption.js +53 -0
- package/esm/components/ComboBox/useActiveOption.js.map +1 -0
- package/esm/components/ComboBox/useClassNames.d.ts +23 -24
- package/esm/components/ComboBox/useClassNames.js +28 -27
- package/esm/components/ComboBox/useClassNames.js.map +1 -1
- package/esm/components/ComboBox/useFocusControl.d.ts +7 -0
- package/esm/components/ComboBox/useFocusControl.js +53 -0
- package/esm/components/ComboBox/useFocusControl.js.map +1 -0
- package/esm/components/ComboBox/useListBox.d.ts +9 -24
- package/esm/components/ComboBox/useListBox.js +109 -217
- package/esm/components/ComboBox/useListBox.js.map +1 -1
- package/esm/components/ComboBox/useOptions.d.ts +10 -0
- package/esm/components/ComboBox/useOptions.js +51 -0
- package/esm/components/ComboBox/useOptions.js.map +1 -0
- package/esm/components/ComboBox/usePartialRendering.d.ts +7 -0
- package/esm/components/ComboBox/usePartialRendering.js +47 -0
- package/esm/components/ComboBox/usePartialRendering.js.map +1 -0
- package/esm/components/Header/HeaderLink.d.ts +2 -2
- package/esm/components/Icon/WarningIcon.js +6 -4
- package/esm/components/Icon/WarningIcon.js.map +1 -1
- package/esm/components/Select/Select.d.ts +4 -2
- package/esm/components/Select/Select.js +69 -60
- package/esm/components/Select/Select.js.map +1 -1
- package/esm/components/Select/useClassNames.d.ts +1 -1
- package/esm/components/Select/useClassNames.js +2 -2
- package/esm/components/Select/useClassNames.js.map +1 -1
- package/esm/components/StatusLabel/StatusLabel.d.ts +1 -1
- package/esm/components/StatusLabel/StatusLabel.js +12 -0
- package/esm/components/StatusLabel/StatusLabel.js.map +1 -1
- package/esm/components/TextLink/TextLink.d.ts +2 -2
- package/esm/components/TextLink/TextLink.js +5 -5
- package/esm/components/TextLink/TextLink.js.map +1 -1
- package/esm/components/Textarea/Textarea.d.ts +6 -0
- package/esm/components/Textarea/Textarea.js +54 -37
- package/esm/components/Textarea/Textarea.js.map +1 -1
- package/esm/themes/createRadius.d.ts +4 -0
- package/esm/themes/createRadius.js +2 -0
- package/esm/themes/createRadius.js.map +1 -1
- package/lib/components/Base/Base.d.ts +1 -6
- package/lib/components/Base/Base.js +10 -6
- package/lib/components/Base/Base.js.map +1 -1
- package/lib/components/Base/index.d.ts +1 -1
- package/lib/components/Base/index.js +1 -2
- package/lib/components/Base/index.js.map +1 -1
- package/lib/components/Button/ButtonWrapper.js +1 -1
- package/lib/components/Button/ButtonWrapper.js.map +1 -1
- package/lib/components/ComboBox/ComboBoxContext.d.ts +11 -0
- package/lib/components/ComboBox/ComboBoxContext.js +13 -0
- package/lib/components/ComboBox/ComboBoxContext.js.map +1 -0
- package/lib/components/ComboBox/ListBoxItem.d.ts +13 -0
- package/lib/components/ComboBox/ListBoxItem.js +114 -0
- package/lib/components/ComboBox/ListBoxItem.js.map +1 -0
- package/lib/components/ComboBox/MultiComboBox.js +132 -100
- package/lib/components/ComboBox/MultiComboBox.js.map +1 -1
- package/lib/components/ComboBox/MultiSelectedItem.d.ts +12 -5
- package/lib/components/ComboBox/MultiSelectedItem.js +80 -9
- package/lib/components/ComboBox/MultiSelectedItem.js.map +1 -1
- package/lib/components/ComboBox/MultiSelectedItemTooltip.d.ts +8 -0
- package/lib/components/ComboBox/MultiSelectedItemTooltip.js +13 -0
- package/lib/components/ComboBox/MultiSelectedItemTooltip.js.map +1 -0
- package/lib/components/ComboBox/SingleComboBox.js +83 -92
- package/lib/components/ComboBox/SingleComboBox.js.map +1 -1
- package/lib/components/ComboBox/types.d.ts +6 -0
- package/lib/components/ComboBox/useActiveOption.d.ts +9 -0
- package/lib/components/ComboBox/useActiveOption.js +57 -0
- package/lib/components/ComboBox/useActiveOption.js.map +1 -0
- package/lib/components/ComboBox/useClassNames.d.ts +23 -24
- package/lib/components/ComboBox/useClassNames.js +31 -29
- package/lib/components/ComboBox/useClassNames.js.map +1 -1
- package/lib/components/ComboBox/useFocusControl.d.ts +7 -0
- package/lib/components/ComboBox/useFocusControl.js +57 -0
- package/lib/components/ComboBox/useFocusControl.js.map +1 -0
- package/lib/components/ComboBox/useListBox.d.ts +9 -24
- package/lib/components/ComboBox/useListBox.js +108 -216
- package/lib/components/ComboBox/useListBox.js.map +1 -1
- package/lib/components/ComboBox/useOptions.d.ts +10 -0
- package/lib/components/ComboBox/useOptions.js +55 -0
- package/lib/components/ComboBox/useOptions.js.map +1 -0
- package/lib/components/ComboBox/usePartialRendering.d.ts +7 -0
- package/lib/components/ComboBox/usePartialRendering.js +74 -0
- package/lib/components/ComboBox/usePartialRendering.js.map +1 -0
- package/lib/components/Header/HeaderLink.d.ts +2 -2
- package/lib/components/Icon/WarningIcon.js +6 -4
- package/lib/components/Icon/WarningIcon.js.map +1 -1
- package/lib/components/Select/Select.d.ts +4 -2
- package/lib/components/Select/Select.js +69 -60
- package/lib/components/Select/Select.js.map +1 -1
- package/lib/components/Select/useClassNames.d.ts +1 -1
- package/lib/components/Select/useClassNames.js +2 -2
- package/lib/components/Select/useClassNames.js.map +1 -1
- package/lib/components/StatusLabel/StatusLabel.d.ts +1 -1
- package/lib/components/StatusLabel/StatusLabel.js +12 -0
- package/lib/components/StatusLabel/StatusLabel.js.map +1 -1
- package/lib/components/TextLink/TextLink.d.ts +2 -2
- package/lib/components/TextLink/TextLink.js +4 -5
- package/lib/components/TextLink/TextLink.js.map +1 -1
- package/lib/components/Textarea/Textarea.d.ts +6 -0
- package/lib/components/Textarea/Textarea.js +53 -36
- package/lib/components/Textarea/Textarea.js.map +1 -1
- package/lib/themes/createRadius.d.ts +4 -0
- package/lib/themes/createRadius.js +2 -0
- package/lib/themes/createRadius.js.map +1 -1
- package/package.json +41 -37
- package/CHANGELOG.md +0 -1849
- package/esm/components/ComboBox/MultiSelectedItemInner.d.ts +0 -12
- package/esm/components/ComboBox/MultiSelectedItemInner.js +0 -78
- package/esm/components/ComboBox/MultiSelectedItemInner.js.map +0 -1
- package/lib/components/ComboBox/MultiSelectedItemInner.d.ts +0 -12
- package/lib/components/ComboBox/MultiSelectedItemInner.js +0 -105
- package/lib/components/ComboBox/MultiSelectedItemInner.js.map +0 -1
|
@@ -2,16 +2,11 @@ import React, { HTMLAttributes, ReactNode } from 'react';
|
|
|
2
2
|
declare type Props = {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
/** 角丸のサイズ */
|
|
5
|
-
radius?:
|
|
5
|
+
radius?: 's' | 'm';
|
|
6
6
|
/** レイヤの重なり方向の高さ(影の付き方に影響する) */
|
|
7
7
|
layer?: LayerKeys;
|
|
8
8
|
};
|
|
9
|
-
export declare type RadiusKeys = keyof typeof radiusMap;
|
|
10
9
|
export declare type LayerKeys = keyof typeof layerMap;
|
|
11
|
-
export declare const radiusMap: {
|
|
12
|
-
readonly s: "6px";
|
|
13
|
-
readonly m: "8px";
|
|
14
|
-
};
|
|
15
10
|
export declare const layerMap: {
|
|
16
11
|
readonly 0: "LAYER0";
|
|
17
12
|
readonly 1: "LAYER1";
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
1
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { useTheme } from '../../hooks/useTheme';
|
|
4
4
|
import { useClassNames } from './useClassNames';
|
|
5
|
-
export const radiusMap = {
|
|
6
|
-
s: '6px',
|
|
7
|
-
m: '8px',
|
|
8
|
-
};
|
|
9
5
|
export const layerMap = {
|
|
10
6
|
0: 'LAYER0',
|
|
11
7
|
1: 'LAYER1',
|
|
@@ -16,7 +12,15 @@ export const layerMap = {
|
|
|
16
12
|
export const Base = forwardRef(({ radius = 'm', layer = 1, className = '', ...props }, ref) => {
|
|
17
13
|
const themes = useTheme();
|
|
18
14
|
const classNames = useClassNames();
|
|
19
|
-
|
|
15
|
+
const $radius = useMemo(() => {
|
|
16
|
+
switch (radius) {
|
|
17
|
+
case 's':
|
|
18
|
+
return themes.radius.m;
|
|
19
|
+
case 'm':
|
|
20
|
+
return themes.radius.l;
|
|
21
|
+
}
|
|
22
|
+
}, [radius, themes.radius.l, themes.radius.m]);
|
|
23
|
+
return (React.createElement(Wrapper, { className: `${className} ${classNames.base.wrapper}`, themes: themes, "$radius": $radius, "$layer": layerMap[layer], ref: ref, ...props }));
|
|
20
24
|
});
|
|
21
25
|
const Wrapper = styled.div `
|
|
22
26
|
${({ themes: { color, shadow }, $radius, $layer }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Base.js","sourceRoot":"","sources":["../../../src/components/Base/Base.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA6B,UAAU,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Base.js","sourceRoot":"","sources":["../../../src/components/Base/Base.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA6B,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC7E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAS,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAY/C,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,QAAQ;CACH,CAAA;AAIV,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAC5B,CAAC,EAAE,MAAM,GAAG,GAAG,EAAE,KAAK,GAAG,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IAC7D,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAA;IACzB,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE;QAC3B,QAAQ,MAAM,EAAE;YACd,KAAK,GAAG;gBACN,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;YACxB,KAAK,GAAG;gBACN,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;SACzB;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAE9C,OAAO,CACL,oBAAC,OAAO,IACN,SAAS,EAAE,GAAG,SAAS,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,EACpD,MAAM,EAAE,MAAM,aACL,OAAO,YACR,QAAQ,CAAC,KAAK,CAAC,EACvB,GAAG,EAAE,GAAG,KACJ,KAAK,GACT,CACH,CAAA;AACH,CAAC,CACF,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAIxB;IACE,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;IACnD,OAAO,GAAG,CAAA;oBACM,MAAM,CAAC,MAAM,CAAC;uBACX,OAAO;0BACJ,KAAK,CAAC,KAAK;KAChC,CAAA;AACH,CAAC;CACF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -123,7 +123,7 @@ function variantStyles(variant, theme) {
|
|
|
123
123
|
`,
|
|
124
124
|
disabled: css `
|
|
125
125
|
border-color: ${color.disableColor(color.BORDER)};
|
|
126
|
-
background-color: ${color.
|
|
126
|
+
background-color: ${color.hoverColor(color.WHITE)};
|
|
127
127
|
color: ${color.TEXT_DISABLED};
|
|
128
128
|
`,
|
|
129
129
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonWrapper.js","sourceRoot":"","sources":["../../../src/components/Button/ButtonWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAKZ,OAAO,GACR,MAAM,OAAO,CA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AAQ,EAAE,GAAG,CAAA;0BACK,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC;;mBAEtC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC;SAC9C;aACF,CAAA;QACH,KAAK,MAAM;YACT,OAAO;gBACL,OAAO,EAAE,GAAG,CAAA;;mBAED,KAAK,CAAC,UAAU;SAC1B;gBACD,KAAK,EAAE,GAAG,CAAA;8BACY,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;SAClD;gBACD,QAAQ,EAAE,GAAG,CAAA;;mBAEF,KAAK,CAAC,aAAa;SAC7B;aACF,CAAA;KACJ;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type ComboBoxContextType = {
|
|
3
|
+
listBoxClassNames: {
|
|
4
|
+
dropdownList: string;
|
|
5
|
+
addButton: string;
|
|
6
|
+
selectButton: string;
|
|
7
|
+
noItems: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare const ComboBoxContext: import("react").Context<ComboBoxContextType>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComboBoxContext.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBoxContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAWrC,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAsB;IAChE,iBAAiB,EAAE;QACjB,YAAY,EAAE,EAAE;QAChB,SAAS,EAAE,EAAE;QACb,YAAY,EAAE,EAAE;QAChB,OAAO,EAAE,EAAE;KACZ;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { ComboBoxOption } from './types';
|
|
3
|
+
declare type Props<T> = {
|
|
4
|
+
option: ComboBoxOption<T>;
|
|
5
|
+
isActive: boolean;
|
|
6
|
+
onAdd: (option: ComboBoxOption<T>) => void;
|
|
7
|
+
onSelect: (option: ComboBoxOption<T>) => void;
|
|
8
|
+
onMouseOver: (option: ComboBoxOption<T>) => void;
|
|
9
|
+
activeRef: RefObject<HTMLButtonElement>;
|
|
10
|
+
};
|
|
11
|
+
declare function ListBoxItem<T>({ option, isActive, onAdd, onSelect, onMouseOver, activeRef }: Props<T>): JSX.Element;
|
|
12
|
+
declare const Memoized: typeof ListBoxItem;
|
|
13
|
+
export { Memoized as ListBoxItem };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { useCallback, useContext } from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { useTheme } from '../../hooks/useTheme';
|
|
4
|
+
import { FaPlusCircleIcon } from '../Icon';
|
|
5
|
+
import { ComboBoxContext } from './ComboBoxContext';
|
|
6
|
+
function ListBoxItem({ option, isActive, onAdd, onSelect, onMouseOver, activeRef }) {
|
|
7
|
+
const className = isActive ? 'active' : '';
|
|
8
|
+
const { item, selected, isNew } = option;
|
|
9
|
+
const { label, disabled } = item;
|
|
10
|
+
const handleAdd = useCallback(() => {
|
|
11
|
+
onAdd(option);
|
|
12
|
+
}, [onAdd, option]);
|
|
13
|
+
const handleSelect = useCallback(() => {
|
|
14
|
+
onSelect(option);
|
|
15
|
+
}, [onSelect, option]);
|
|
16
|
+
const handleMouseOver = useCallback(() => {
|
|
17
|
+
onMouseOver(option);
|
|
18
|
+
}, [onMouseOver, option]);
|
|
19
|
+
const theme = useTheme();
|
|
20
|
+
const { listBoxClassNames: classNames } = useContext(ComboBoxContext);
|
|
21
|
+
return isNew ? (React.createElement(AddButton, { key: option.id, themes: theme, onClick: handleAdd, onMouseOver: handleMouseOver, id: option.id, role: "option", className: `${className} ${classNames.addButton}`, ref: isActive ? activeRef : undefined },
|
|
22
|
+
React.createElement(AddIcon, { color: theme.color.TEXT_LINK, themes: theme }),
|
|
23
|
+
React.createElement(AddText, { themes: theme },
|
|
24
|
+
"\u300C",
|
|
25
|
+
label,
|
|
26
|
+
"\u300D\u3092\u8FFD\u52A0"))) : (React.createElement(SelectButton, { key: option.id, type: "button", themes: theme, disabled: disabled, onClick: handleSelect, onMouseOver: handleMouseOver, id: option.id, role: "option", className: `${className} ${classNames.selectButton}`, "aria-selected": selected, ref: isActive ? activeRef : undefined }, label));
|
|
27
|
+
}
|
|
28
|
+
const typedMemo = React.memo;
|
|
29
|
+
const Memoized = typedMemo(ListBoxItem);
|
|
30
|
+
export { Memoized as ListBoxItem };
|
|
31
|
+
const SelectButton = styled.button `
|
|
32
|
+
${({ themes }) => {
|
|
33
|
+
const { fontSize, leading, spacingByChar, color } = themes;
|
|
34
|
+
return css `
|
|
35
|
+
display: block;
|
|
36
|
+
min-width: 100%;
|
|
37
|
+
border: none;
|
|
38
|
+
padding: ${spacingByChar(0.5)} ${spacingByChar(1)};
|
|
39
|
+
background-color: ${color.WHITE};
|
|
40
|
+
font-size: ${fontSize.M};
|
|
41
|
+
line-height: ${leading.NONE};
|
|
42
|
+
text-align: left;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
|
|
45
|
+
&.active {
|
|
46
|
+
background-color: ${color.hoverColor(color.WHITE)};
|
|
47
|
+
color: inherit;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&[aria-selected='true'] {
|
|
51
|
+
background-color: ${color.MAIN};
|
|
52
|
+
color: ${color.TEXT_WHITE};
|
|
53
|
+
&.active {
|
|
54
|
+
background-color: ${color.hoverColor(color.MAIN)};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&[disabled] {
|
|
59
|
+
color: ${color.TEXT_DISABLED};
|
|
60
|
+
cursor: not-allowed;
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
}}
|
|
64
|
+
`;
|
|
65
|
+
const AddButton = styled(SelectButton) `
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
min-width: 100%;
|
|
69
|
+
`;
|
|
70
|
+
const AddIcon = styled(FaPlusCircleIcon) `
|
|
71
|
+
${({ themes }) => {
|
|
72
|
+
const { spacingByChar } = themes;
|
|
73
|
+
return css `
|
|
74
|
+
position: relative;
|
|
75
|
+
top: -1px;
|
|
76
|
+
margin-right: ${spacingByChar(0.25)};
|
|
77
|
+
`;
|
|
78
|
+
}}
|
|
79
|
+
`;
|
|
80
|
+
const AddText = styled.span `
|
|
81
|
+
${({ themes }) => {
|
|
82
|
+
const { color } = themes;
|
|
83
|
+
return css `
|
|
84
|
+
color: ${color.TEXT_LINK};
|
|
85
|
+
`;
|
|
86
|
+
}}
|
|
87
|
+
`;
|
|
88
|
+
//# sourceMappingURL=ListBoxItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListBoxItem.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ListBoxItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAa,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACjE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAS,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAWnD,SAAS,WAAW,CAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAY;IAC7F,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;IAC1C,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACxC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;IAEhC,MAAM,SAAS,GAAG,WAAW,CAA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G,CAAA;;;sBAGQ,aAAa,CAAC,IAAI,CAAC;KACpC,CAAA;AACH,CAAC;CACF,CAAA;AACD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAmB;IAC1C,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;IACf,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IAExB,OAAO,GAAG,CAAA;eACC,KAAK,CAAC,SAAS;KACzB,CAAA;AACH,CAAC;CACF,CAAA"}
|
|
@@ -2,59 +2,67 @@ import React, { useCallback, useLayoutEffect, useMemo, useRef, useState, } from
|
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { useTheme } from '../../hooks/useTheme';
|
|
4
4
|
import { useOuterClick } from '../../hooks/useOuterClick';
|
|
5
|
+
import { useId } from '../../hooks/useId';
|
|
5
6
|
import { hasParentElementByClassName } from './multiComboBoxHelper';
|
|
6
|
-
import {
|
|
7
|
+
import { useMultiComboBoxClassNames } from './useClassNames';
|
|
7
8
|
import { FaCaretDownIcon } from '../Icon';
|
|
8
|
-
import {
|
|
9
|
+
import { useOptions } from './useOptions';
|
|
10
|
+
import { useFocusControl } from './useFocusControl';
|
|
9
11
|
import { MultiSelectedItem } from './MultiSelectedItem';
|
|
10
|
-
import {
|
|
12
|
+
import { useListBox } from './useListBox';
|
|
13
|
+
import { ComboBoxContext } from './ComboBoxContext';
|
|
11
14
|
export function MultiComboBox({ items, selectedItems, name, disabled = false, error = false, creatable = false, placeholder = '', isLoading, selectedItemEllipsis, width = 'auto', inputValue: controlledInputValue, className = '', onChange, onChangeInput, onAdd, onDelete, onSelect, onChangeSelected, onFocus, onBlur, ...props }) {
|
|
12
15
|
const theme = useTheme();
|
|
13
|
-
const classNames =
|
|
16
|
+
const classNames = useMultiComboBoxClassNames();
|
|
14
17
|
const outerRef = useRef(null);
|
|
15
|
-
const inputRef = useRef(null);
|
|
16
18
|
const [isFocused, setIsFocused] = useState(false);
|
|
17
19
|
const isInputControlled = useMemo(() => controlledInputValue !== undefined, [controlledInputValue]);
|
|
18
20
|
const [uncontrolledInputValue, setUncontrolledInputValue] = useState('');
|
|
19
21
|
const inputValue = isInputControlled ? controlledInputValue : uncontrolledInputValue;
|
|
20
22
|
const [isComposing, setIsComposing] = useState(false);
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (!inputValue)
|
|
26
|
-
return true;
|
|
27
|
-
return convertMatchableString(label).includes(convertMatchableString(inputValue));
|
|
28
|
-
}), [inputValue, items, selectedLabels]);
|
|
29
|
-
const isDuplicate = items.some((item) => item.label === inputValue);
|
|
30
|
-
const hasSelectableExactMatch = filteredItems.some((item) => item.label === inputValue);
|
|
31
|
-
const { renderListBox, calculateDropdownRect, resetActiveOptionIndex, handleInputKeyDown, listBoxRef, aria, } = useListBox({
|
|
32
|
-
items: filteredItems,
|
|
23
|
+
const { options } = useOptions({
|
|
24
|
+
items,
|
|
25
|
+
selected: selectedItems,
|
|
26
|
+
creatable,
|
|
33
27
|
inputValue,
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
});
|
|
29
|
+
const handleDelete = useCallback((item) => {
|
|
30
|
+
onDelete && onDelete(item);
|
|
31
|
+
onChangeSelected &&
|
|
32
|
+
onChangeSelected(selectedItems.filter((selected) => selected.label !== item.label || selected.value !== item.value));
|
|
33
|
+
}, [onChangeSelected, onDelete, selectedItems]);
|
|
34
|
+
const handleSelect = useCallback((selected) => {
|
|
35
|
+
const matchedSelectedItem = selectedItems.find((item) => item.label === selected.label && item.value === selected.value);
|
|
36
|
+
if (matchedSelectedItem !== undefined) {
|
|
37
|
+
if (matchedSelectedItem.deletable !== false) {
|
|
38
|
+
handleDelete(selected);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
36
42
|
onSelect && onSelect(selected);
|
|
37
43
|
onChangeSelected && onChangeSelected(selectedItems.concat(selected));
|
|
38
|
-
}
|
|
44
|
+
}
|
|
45
|
+
}, [handleDelete, onChangeSelected, onSelect, selectedItems]);
|
|
46
|
+
const { renderListBox, activeOption, handleKeyDown: handleListBoxKeyDown, listBoxId, listBoxRef, } = useListBox({
|
|
47
|
+
options,
|
|
48
|
+
onAdd,
|
|
49
|
+
onSelect: handleSelect,
|
|
39
50
|
isExpanded: isFocused,
|
|
40
|
-
isAddable: creatable && !!inputValue && !isDuplicate,
|
|
41
|
-
isDuplicate: creatable && !!inputValue && isDuplicate && !hasSelectableExactMatch,
|
|
42
|
-
hasNoMatch: (!creatable && filteredItems.length === 0) ||
|
|
43
|
-
(creatable && filteredItems.length === 0 && !inputValue),
|
|
44
51
|
isLoading,
|
|
45
|
-
|
|
52
|
+
triggerRef: outerRef,
|
|
46
53
|
});
|
|
54
|
+
const { deletionButtonRefs, inputRef, focusPrevDeletionButton, focusNextDeletionButton, resetDeletionButtonFocus, } = useFocusControl(selectedItems.length);
|
|
47
55
|
const focus = useCallback(() => {
|
|
48
56
|
onFocus && onFocus();
|
|
49
57
|
setIsFocused(true);
|
|
50
|
-
|
|
51
|
-
}, [onFocus, resetActiveOptionIndex]);
|
|
58
|
+
}, [onFocus]);
|
|
52
59
|
const blur = useCallback(() => {
|
|
53
60
|
if (!isFocused)
|
|
54
61
|
return;
|
|
55
62
|
onBlur && onBlur();
|
|
56
63
|
setIsFocused(false);
|
|
57
|
-
|
|
64
|
+
resetDeletionButtonFocus();
|
|
65
|
+
}, [isFocused, onBlur, resetDeletionButtonFocus]);
|
|
58
66
|
const caretIconColor = useMemo(() => {
|
|
59
67
|
if (isFocused)
|
|
60
68
|
return theme.color.TEXT_BLACK;
|
|
@@ -62,9 +70,7 @@ export function MultiComboBox({ items, selectedItems, name, disabled = false, er
|
|
|
62
70
|
return theme.color.TEXT_DISABLED;
|
|
63
71
|
return theme.color.TEXT_GREY;
|
|
64
72
|
}, [disabled, isFocused, theme]);
|
|
65
|
-
useOuterClick([outerRef, listBoxRef],
|
|
66
|
-
blur();
|
|
67
|
-
}, [blur]));
|
|
73
|
+
useOuterClick([outerRef, listBoxRef], blur);
|
|
68
74
|
useLayoutEffect(() => {
|
|
69
75
|
if (!isInputControlled) {
|
|
70
76
|
setUncontrolledInputValue('');
|
|
@@ -72,35 +78,76 @@ export function MultiComboBox({ items, selectedItems, name, disabled = false, er
|
|
|
72
78
|
if (isFocused && inputRef.current) {
|
|
73
79
|
inputRef.current.focus();
|
|
74
80
|
}
|
|
75
|
-
}, [isFocused, isInputControlled, selectedItems]);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
calculateDropdownRect(outerRef.current);
|
|
81
|
+
}, [inputRef, isFocused, isInputControlled, selectedItems]);
|
|
82
|
+
const handleKeyDown = useCallback((e) => {
|
|
83
|
+
if (isComposing) {
|
|
84
|
+
return;
|
|
80
85
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}, onKeyDown: (e) => {
|
|
90
|
-
if (e.key === 'Escape' || e.key === 'Esc') {
|
|
91
|
-
e.stopPropagation();
|
|
92
|
-
blur();
|
|
86
|
+
else if (e.key === 'Escape' || e.key === 'Esc') {
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
blur();
|
|
89
|
+
}
|
|
90
|
+
else if (e.key === 'Tab') {
|
|
91
|
+
if (isFocused) {
|
|
92
|
+
// フォーカスがコンポーネントを抜けるように先に input をフォーカスしておく
|
|
93
|
+
inputRef.current?.focus();
|
|
93
94
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
blur();
|
|
96
|
+
}
|
|
97
|
+
else if (e.key === 'Left' || e.key === 'ArrowLeft') {
|
|
98
|
+
e.stopPropagation();
|
|
99
|
+
focusPrevDeletionButton();
|
|
100
|
+
}
|
|
101
|
+
else if (e.key === 'Right' || e.key === 'ArrowRight') {
|
|
102
|
+
e.stopPropagation();
|
|
103
|
+
focusNextDeletionButton();
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
e.stopPropagation();
|
|
107
|
+
inputRef.current?.focus();
|
|
108
|
+
resetDeletionButtonFocus();
|
|
109
|
+
}
|
|
110
|
+
handleListBoxKeyDown(e);
|
|
111
|
+
}, [
|
|
112
|
+
blur,
|
|
113
|
+
focusNextDeletionButton,
|
|
114
|
+
focusPrevDeletionButton,
|
|
115
|
+
handleListBoxKeyDown,
|
|
116
|
+
inputRef,
|
|
117
|
+
isComposing,
|
|
118
|
+
isFocused,
|
|
119
|
+
resetDeletionButtonFocus,
|
|
120
|
+
]);
|
|
121
|
+
const handleInputKeyDown = useCallback((e) => {
|
|
122
|
+
if (e.key === 'Down' || e.key === 'ArrowDown' || e.key === 'Up' || e.key === 'ArrowUp') {
|
|
123
|
+
// 上下キー入力はリストボックスの activeDescendant の移動に用いるため、input 内では作用させない
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
}
|
|
126
|
+
}, []);
|
|
127
|
+
const contextValue = useMemo(() => ({
|
|
128
|
+
listBoxClassNames: classNames.listBox,
|
|
129
|
+
}), [classNames.listBox]);
|
|
130
|
+
const wrapperClassNames = [
|
|
131
|
+
className,
|
|
132
|
+
isFocused && 'focused',
|
|
133
|
+
error && 'invalid',
|
|
134
|
+
disabled && 'disabled',
|
|
135
|
+
classNames.wrapper,
|
|
136
|
+
]
|
|
137
|
+
.filter((text) => text !== false && text !== '')
|
|
138
|
+
.join(' ');
|
|
139
|
+
const selectedListId = useId();
|
|
140
|
+
return (React.createElement(ComboBoxContext.Provider, { value: contextValue },
|
|
141
|
+
React.createElement(Container, { ...props, themes: theme, width: width, ref: outerRef, className: wrapperClassNames, onClick: (e) => {
|
|
142
|
+
if (!hasParentElementByClassName(e.target, classNames.deleteButton) &&
|
|
143
|
+
!disabled &&
|
|
144
|
+
!isFocused) {
|
|
145
|
+
focus();
|
|
146
|
+
}
|
|
147
|
+
}, onKeyDown: handleKeyDown, role: "group" },
|
|
148
|
+
React.createElement(InputArea, { themes: theme },
|
|
149
|
+
React.createElement(SelectedList, { id: selectedListId, "aria-label": "\u9078\u629E\u6E08\u307F\u30A2\u30A4\u30C6\u30E0", className: classNames.selectedList }, selectedItems.map((selectedItem, i) => (React.createElement("li", { key: `${selectedItem.label}-${selectedItem.value}` },
|
|
150
|
+
React.createElement(MultiSelectedItem, { item: selectedItem, disabled: disabled, onDelete: handleDelete, enableEllipsis: selectedItemEllipsis, buttonRef: deletionButtonRefs[i] }))))),
|
|
104
151
|
React.createElement(InputWrapper, { className: isFocused ? undefined : 'hidden' },
|
|
105
152
|
React.createElement(Input, { type: "text", name: name, value: inputValue, disabled: disabled, ref: inputRef, themes: theme, onChange: (e) => {
|
|
106
153
|
if (onChange)
|
|
@@ -111,24 +158,15 @@ export function MultiComboBox({ items, selectedItems, name, disabled = false, er
|
|
|
111
158
|
setUncontrolledInputValue(e.currentTarget.value);
|
|
112
159
|
}
|
|
113
160
|
}, onFocus: () => {
|
|
161
|
+
resetDeletionButtonFocus();
|
|
114
162
|
if (!isFocused) {
|
|
115
163
|
focus();
|
|
116
164
|
}
|
|
117
|
-
}, onCompositionStart: () => setIsComposing(true), onCompositionEnd: () => setIsComposing(false), onKeyDown:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
blur();
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
handleInputKeyDown(e);
|
|
126
|
-
}, autoComplete: "off", "aria-activedescendant": aria.activeDescendant, "aria-autocomplete": "list", "aria-controls": aria.listBoxId, className: classNames.input })),
|
|
127
|
-
selectedItems.length === 0 && placeholder && !isFocused && (React.createElement("li", null,
|
|
128
|
-
React.createElement(Placeholder, { themes: theme, className: classNames.placeholder }, placeholder))))),
|
|
129
|
-
React.createElement(Suffix, { themes: theme },
|
|
130
|
-
React.createElement(FaCaretDownIcon, { color: caretIconColor })),
|
|
131
|
-
renderListBox()));
|
|
165
|
+
}, onCompositionStart: () => setIsComposing(true), onCompositionEnd: () => setIsComposing(false), onKeyDown: handleInputKeyDown, autoComplete: "off", tabIndex: 0, role: "combobox", "aria-activedescendant": activeOption?.id, "aria-controls": `${listBoxId} ${selectedListId}`, "aria-haspopup": "listbox", "aria-expanded": isFocused, "aria-invalid": error || undefined, "aria-disabled": disabled, "aria-autocomplete": "list", className: classNames.input })),
|
|
166
|
+
selectedItems.length === 0 && placeholder && !isFocused && (React.createElement(Placeholder, { themes: theme, className: classNames.placeholder }, placeholder))),
|
|
167
|
+
React.createElement(Suffix, { themes: theme },
|
|
168
|
+
React.createElement(FaCaretDownIcon, { color: caretIconColor })),
|
|
169
|
+
renderListBox())));
|
|
132
170
|
}
|
|
133
171
|
const Container = styled.div `
|
|
134
172
|
${({ themes, width }) => {
|
|
@@ -144,15 +182,15 @@ const Container = styled.div `
|
|
|
144
182
|
background-color: ${color.WHITE};
|
|
145
183
|
cursor: text;
|
|
146
184
|
|
|
147
|
-
|
|
185
|
+
&.focused {
|
|
148
186
|
box-shadow: ${shadow.OUTLINE};
|
|
149
187
|
}
|
|
150
188
|
|
|
151
|
-
|
|
189
|
+
&.invalid {
|
|
152
190
|
border-color: ${color.DANGER};
|
|
153
191
|
}
|
|
154
192
|
|
|
155
|
-
|
|
193
|
+
&.disabled {
|
|
156
194
|
background-color: ${color.COLUMN};
|
|
157
195
|
cursor: not-allowed;
|
|
158
196
|
}
|
|
@@ -162,33 +200,24 @@ const Container = styled.div `
|
|
|
162
200
|
const InputArea = styled.div `
|
|
163
201
|
${({ themes: { spacingByChar } }) => css `
|
|
164
202
|
flex: 1;
|
|
165
|
-
|
|
203
|
+
display: flex;
|
|
204
|
+
flex-wrap: wrap;
|
|
205
|
+
gap: ${spacingByChar(0.5)};
|
|
206
|
+
min-height: calc(1em + ${spacingByChar(0.5)} * 2);
|
|
166
207
|
max-height: 300px;
|
|
167
|
-
|
|
208
|
+
margin: ${spacingByChar(0.25)} ${spacingByChar(0.5)};
|
|
209
|
+
overflow-y: auto;
|
|
168
210
|
`}
|
|
169
211
|
`;
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
flex-wrap: wrap;
|
|
178
|
-
margin: ${pxToRem(smallMargin - borderWidth)} 0 0;
|
|
179
|
-
padding: 0;
|
|
180
|
-
list-style: none;
|
|
181
|
-
|
|
182
|
-
> li {
|
|
183
|
-
min-height: 27px;
|
|
184
|
-
max-width: calc(100% - ${spacingByChar(0.5)});
|
|
185
|
-
margin-right: ${spacingByChar(0.5)};
|
|
186
|
-
margin-bottom: ${pxToRem(smallMargin - borderWidth)};
|
|
187
|
-
}
|
|
188
|
-
`;
|
|
189
|
-
}}
|
|
212
|
+
const SelectedList = styled.ul `
|
|
213
|
+
display: contents;
|
|
214
|
+
list-style: none;
|
|
215
|
+
li {
|
|
216
|
+
/** 選択済みアイテムのラベルの省略表示のために幅を計算させる */
|
|
217
|
+
min-width: 0;
|
|
218
|
+
}
|
|
190
219
|
`;
|
|
191
|
-
const InputWrapper = styled.
|
|
220
|
+
const InputWrapper = styled.div `
|
|
192
221
|
&.hidden {
|
|
193
222
|
position: absolute;
|
|
194
223
|
opacity: 0;
|
|
@@ -196,13 +225,16 @@ const InputWrapper = styled.li `
|
|
|
196
225
|
}
|
|
197
226
|
|
|
198
227
|
flex: 1;
|
|
228
|
+
display: flex;
|
|
229
|
+
align-items: center;
|
|
199
230
|
`;
|
|
200
231
|
const Input = styled.input `
|
|
201
232
|
${({ themes }) => {
|
|
202
|
-
const { fontSize } = themes;
|
|
233
|
+
const { fontSize, spacingByChar } = themes;
|
|
203
234
|
return css `
|
|
204
235
|
min-width: 80px;
|
|
205
236
|
width: 100%;
|
|
237
|
+
min-height: calc(1em + ${spacingByChar(0.5)} * 2);
|
|
206
238
|
border: none;
|
|
207
239
|
font-size: ${fontSize.M};
|
|
208
240
|
box-sizing: border-box;
|
|
@@ -218,9 +250,9 @@ const Placeholder = styled.p `
|
|
|
218
250
|
const { color, fontSize } = themes;
|
|
219
251
|
return css `
|
|
220
252
|
margin: 0;
|
|
253
|
+
align-self: center;
|
|
221
254
|
color: ${color.TEXT_GREY};
|
|
222
255
|
font-size: ${fontSize.M};
|
|
223
|
-
line-height: 25px;
|
|
224
256
|
`;
|
|
225
257
|
}}
|
|
226
258
|
`;
|