@bitrise/bitkit 10.6.0 → 10.9.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/package.json +17 -7
- package/src/Components/Dropdown/Dropdown.context.tsx +37 -0
- package/src/Components/Dropdown/Dropdown.stories.tsx +89 -0
- package/src/Components/Dropdown/Dropdown.test.tsx +431 -0
- package/src/Components/Dropdown/Dropdown.theme.ts +101 -0
- package/src/Components/Dropdown/Dropdown.tsx +306 -0
- package/src/Components/Dropdown/DropdownButton.tsx +27 -0
- package/src/Components/Dropdown/DropdownOption.tsx +83 -0
- package/src/Components/Dropdown/hooks/useAutoScroll.ts +61 -0
- package/src/Components/Dropdown/hooks/useFloatingDropdown.ts +92 -0
- package/src/Components/Dropdown/hooks/useSimpleSearch.tsx +52 -0
- package/src/Components/Dropdown/isNodeMatch.ts +39 -0
- package/src/Components/Icons/16x16/StepstatusNext.tsx +15 -0
- package/src/Components/Icons/16x16/index.ts +1 -0
- package/src/Components/Icons/24x24/StepstatusNext.tsx +15 -0
- package/src/Components/Icons/24x24/index.ts +1 -0
- package/src/Components/Input/Input.theme.ts +19 -0
- package/src/Components/Popover/PopoverArrow.tsx +7 -0
- package/src/index.ts +3 -0
- package/src/theme.ts +4 -0
- package/src/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Children, cloneElement, isValidElement, ReactNode, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { chakra } from '@chakra-ui/react';
|
|
3
|
+
import { useDropdownStyles } from '../Dropdown.context';
|
|
4
|
+
import isNodeMatch from '../isNodeMatch';
|
|
5
|
+
import { DropdownGroup } from '../DropdownOption';
|
|
6
|
+
|
|
7
|
+
const NoResultsFound = ({ children }: { children: ReactNode }) => {
|
|
8
|
+
const { item } = useDropdownStyles();
|
|
9
|
+
return <chakra.div __css={item}>{children}</chakra.div>;
|
|
10
|
+
};
|
|
11
|
+
function useSimpleSearch({
|
|
12
|
+
children,
|
|
13
|
+
onSearch,
|
|
14
|
+
isOpen,
|
|
15
|
+
}: {
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
onSearch?: () => void;
|
|
18
|
+
isOpen: boolean;
|
|
19
|
+
}) {
|
|
20
|
+
const [searchValue, setSearchValue] = useState('');
|
|
21
|
+
const searchOnChange = (newValue: string) => {
|
|
22
|
+
setSearchValue(newValue);
|
|
23
|
+
onSearch?.();
|
|
24
|
+
};
|
|
25
|
+
const options = useMemo(() => {
|
|
26
|
+
if (!searchValue) {
|
|
27
|
+
return children;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const transform = (node: ReactNode): ReactNode => {
|
|
31
|
+
if (isValidElement(node) && node.type === DropdownGroup) {
|
|
32
|
+
const groupChildren = Children.toArray(node.props.children).map(transform).filter(Boolean);
|
|
33
|
+
if (groupChildren.length === 0) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return cloneElement(node, {
|
|
37
|
+
...node.props,
|
|
38
|
+
children: groupChildren,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return isNodeMatch(node, searchValue) ? node : null;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const results = Children.toArray(children).map(transform).filter(Boolean);
|
|
45
|
+
|
|
46
|
+
return results.length ? results : <NoResultsFound>No results found for `{searchValue}`</NoResultsFound>;
|
|
47
|
+
}, [children, searchValue]);
|
|
48
|
+
useEffect(() => setSearchValue(''), [isOpen]);
|
|
49
|
+
|
|
50
|
+
return { children: options, searchValue, searchOnChange };
|
|
51
|
+
}
|
|
52
|
+
export { useSimpleSearch, NoResultsFound };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { JSXElementConstructor, ReactElement, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type SearchableElement = JSXElementConstructor<any> & { searchable: true };
|
|
4
|
+
export function isSearchable(
|
|
5
|
+
node: string | JSXElementConstructor<any> | SearchableElement,
|
|
6
|
+
): node is (x: any) => ReactElement {
|
|
7
|
+
return typeof node === 'function' && 'searchable' in node && node.searchable;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function isNodeMatch(node: ReactNode, filter: string): boolean {
|
|
11
|
+
if (typeof node === 'number' || typeof node === 'boolean' || typeof node === 'undefined' || node === null) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (typeof node === 'string') {
|
|
15
|
+
return node.toLowerCase().includes(filter.toLowerCase());
|
|
16
|
+
}
|
|
17
|
+
if (Array.isArray(node)) {
|
|
18
|
+
return node.some((child) => isNodeMatch(child, filter));
|
|
19
|
+
}
|
|
20
|
+
if ('children' in node) {
|
|
21
|
+
return isNodeMatch(node.children, filter);
|
|
22
|
+
}
|
|
23
|
+
if (React.isValidElement(node)) {
|
|
24
|
+
if (node.type === 'svg') {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const ctor = node.type;
|
|
28
|
+
if (isSearchable(ctor)) {
|
|
29
|
+
return isNodeMatch(ctor(node.props), filter);
|
|
30
|
+
}
|
|
31
|
+
return isNodeMatch(node.props.children, filter);
|
|
32
|
+
}
|
|
33
|
+
if (Symbol.iterator in node) {
|
|
34
|
+
return isNodeMatch(Array.from(node), filter);
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default isNodeMatch;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon, IconProps, forwardRef } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
const StepstatusNext = forwardRef<IconProps, 'svg'>((props, ref) => (
|
|
5
|
+
<Icon ref={ref} viewBox="0 0 16 16" {...props}>
|
|
6
|
+
<path
|
|
7
|
+
fillRule="evenodd"
|
|
8
|
+
clipRule="evenodd"
|
|
9
|
+
d="M12 1.07026C10.8233 0.389577 9.45715 0 8 0C3.58172 0 0 3.58172 0 8C0 12.4183 3.58172 16 8 16C12.4183 16 16 12.4183 16 8C16 5.97111 15.2447 4.11862 14 2.70835V3V4H13.3338C14.1707 5.11421 14.6667 6.49919 14.6667 8C14.6667 11.6819 11.6819 14.6667 8 14.6667L8 8L8 1.33333C9.50081 1.33333 10.8858 1.82926 12 2.66618V1.07026Z"
|
|
10
|
+
fill="currentColor"
|
|
11
|
+
/>
|
|
12
|
+
</Icon>
|
|
13
|
+
));
|
|
14
|
+
|
|
15
|
+
export default StepstatusNext;
|
|
@@ -158,6 +158,7 @@ export { default as StepsTuorqouise } from './StepsTuorqouise';
|
|
|
158
158
|
export { default as StepsViolet } from './StepsViolet';
|
|
159
159
|
export { default as StepsWhite } from './StepsWhite';
|
|
160
160
|
export { default as Steps } from './Steps';
|
|
161
|
+
export { default as StepstatusNext } from './StepstatusNext';
|
|
161
162
|
export { default as StepstatusSkip } from './StepstatusSkip';
|
|
162
163
|
export { default as StepstatusWarning } from './StepstatusWarning';
|
|
163
164
|
export { default as Stopwatch } from './Stopwatch';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon, IconProps, forwardRef } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
const StepstatusNext = forwardRef<IconProps, 'svg'>((props, ref) => (
|
|
5
|
+
<Icon ref={ref} viewBox="0 0 24 24" {...props}>
|
|
6
|
+
<path
|
|
7
|
+
fillRule="evenodd"
|
|
8
|
+
clipRule="evenodd"
|
|
9
|
+
d="M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12V0Zm2 21.8v2.034a11.966 11.966 0 0 0 6.276-3.144l-1.415-1.415A9.974 9.974 0 0 1 14 21.8Zm6.175-4.04 1.432 1.432A11.937 11.937 0 0 0 23.959 13H21.95a9.945 9.945 0 0 1-1.776 4.76ZM21.951 11a9.942 9.942 0 0 0-1.677-4.617l1.436-1.436A11.936 11.936 0 0 1 23.959 11H21.95Zm-1.552-7.57-1.414 1.414A9.977 9.977 0 0 0 14 2.2V.166a11.968 11.968 0 0 1 6.4 3.263Z"
|
|
10
|
+
fill="currentColor"
|
|
11
|
+
/>
|
|
12
|
+
</Icon>
|
|
13
|
+
));
|
|
14
|
+
|
|
15
|
+
export default StepstatusNext;
|
|
@@ -158,6 +158,7 @@ export { default as StepsTuorqouise } from './StepsTuorqouise';
|
|
|
158
158
|
export { default as StepsViolet } from './StepsViolet';
|
|
159
159
|
export { default as StepsWhite } from './StepsWhite';
|
|
160
160
|
export { default as Steps } from './Steps';
|
|
161
|
+
export { default as StepstatusNext } from './StepstatusNext';
|
|
161
162
|
export { default as StepstatusSkip } from './StepstatusSkip';
|
|
162
163
|
export { default as StepstatusWarning } from './StepstatusWarning';
|
|
163
164
|
export { default as Stopwatch } from './Stopwatch';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SystemStyleObject } from '@chakra-ui/react';
|
|
2
|
+
|
|
3
|
+
const InputTheme = {
|
|
4
|
+
baseStyle: {
|
|
5
|
+
field: <SystemStyleObject>{
|
|
6
|
+
height: '48',
|
|
7
|
+
borderRadius: '4',
|
|
8
|
+
borderStyle: 'solid',
|
|
9
|
+
borderWidth: '1px',
|
|
10
|
+
boxShadow: 'inner',
|
|
11
|
+
_focusVisible: {
|
|
12
|
+
boxShadow: 'outline',
|
|
13
|
+
outline: 'none',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default InputTheme;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PopoverArrowProps as ChakraPopoverArrowProps, PopoverArrow as ChakraPopoverArrow } from '@chakra-ui/react';
|
|
2
|
+
|
|
3
|
+
export type PopoverArrowProps = ChakraPopoverArrowProps;
|
|
4
|
+
|
|
5
|
+
const PopoverArrow = (props: PopoverArrowProps) => <ChakraPopoverArrow {...props} />;
|
|
6
|
+
|
|
7
|
+
export default PopoverArrow;
|
package/src/index.ts
CHANGED
|
@@ -106,6 +106,9 @@ export { default as PopoverTrigger } from './Components/Popover/PopoverTrigger';
|
|
|
106
106
|
export type { PopoverContentProps } from './Components/Popover/PopoverContent';
|
|
107
107
|
export { default as PopoverContent } from './Components/Popover/PopoverContent';
|
|
108
108
|
|
|
109
|
+
export type { PopoverArrowProps } from './Components/Popover/PopoverArrow';
|
|
110
|
+
export { default as PopoverArrow } from './Components/Popover/PopoverArrow';
|
|
111
|
+
|
|
109
112
|
export type { AvatarProps } from './Components/Avatar/Avatar';
|
|
110
113
|
export { default as Avatar } from './Components/Avatar/Avatar';
|
|
111
114
|
|
package/src/theme.ts
CHANGED
|
@@ -13,6 +13,8 @@ import List from './Components/List/List.theme';
|
|
|
13
13
|
import Menu from './Components/Menu/Menu.theme';
|
|
14
14
|
import Radio from './Components/Form/Radio/Radio.theme';
|
|
15
15
|
import Select from './Components/Select/Select.theme';
|
|
16
|
+
import Input from './Components/Input/Input.theme';
|
|
17
|
+
import Dropdown from './Components/Dropdown/Dropdown.theme';
|
|
16
18
|
import Tabs from './Components/Tabs/Tabs.theme';
|
|
17
19
|
import Text from './Components/Text/Text.theme';
|
|
18
20
|
import Alert from './Foundations/Themes/Alert.theme';
|
|
@@ -79,11 +81,13 @@ const theme = {
|
|
|
79
81
|
Modal: Dialog,
|
|
80
82
|
Radio,
|
|
81
83
|
Select,
|
|
84
|
+
Dropdown,
|
|
82
85
|
Tabs,
|
|
83
86
|
Text,
|
|
84
87
|
Tooltip,
|
|
85
88
|
Alert,
|
|
86
89
|
CloseButton,
|
|
90
|
+
Input,
|
|
87
91
|
Popover,
|
|
88
92
|
},
|
|
89
93
|
};
|