@bitrise/bitkit 8.2.0 → 8.5.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.d.ts +19 -0
  3. package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.d.ts.map +1 -0
  4. package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.js +39 -0
  5. package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.js.map +1 -0
  6. package/lib/cjs/Dropdown/Dropdown.d.ts +9 -4
  7. package/lib/cjs/Dropdown/Dropdown.d.ts.map +1 -1
  8. package/lib/cjs/Dropdown/Dropdown.js +6 -4
  9. package/lib/cjs/Dropdown/Dropdown.js.map +1 -1
  10. package/lib/cjs/Dropdown/DropdownMenu.css +37 -0
  11. package/lib/cjs/Dropdown/DropdownMenuItemGroup.d.ts +8 -0
  12. package/lib/cjs/Dropdown/DropdownMenuItemGroup.d.ts.map +1 -0
  13. package/lib/cjs/Dropdown/DropdownMenuItemGroup.js +46 -0
  14. package/lib/cjs/Dropdown/DropdownMenuItemGroup.js.map +1 -0
  15. package/lib/cjs/Toggle/Toggle.js +1 -1
  16. package/lib/cjs/Toggle/Toggle.js.map +1 -1
  17. package/lib/cjs/index.d.ts +2 -0
  18. package/lib/cjs/index.d.ts.map +1 -1
  19. package/lib/cjs/index.js +4 -0
  20. package/lib/cjs/index.js.map +1 -1
  21. package/lib/cjs/tsconfig.tsbuildinfo +42 -5
  22. package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.d.ts +19 -0
  23. package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.d.ts.map +1 -0
  24. package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.js +12 -0
  25. package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.js.map +1 -0
  26. package/lib/esn/Dropdown/Dropdown.d.ts +9 -4
  27. package/lib/esn/Dropdown/Dropdown.d.ts.map +1 -1
  28. package/lib/esn/Dropdown/Dropdown.js +3 -1
  29. package/lib/esn/Dropdown/Dropdown.js.map +1 -1
  30. package/lib/esn/Dropdown/DropdownMenu.css +37 -0
  31. package/lib/esn/Dropdown/DropdownMenuItemGroup.d.ts +8 -0
  32. package/lib/esn/Dropdown/DropdownMenuItemGroup.d.ts.map +1 -0
  33. package/lib/esn/Dropdown/DropdownMenuItemGroup.js +9 -0
  34. package/lib/esn/Dropdown/DropdownMenuItemGroup.js.map +1 -0
  35. package/lib/esn/Toggle/Toggle.js +1 -1
  36. package/lib/esn/Toggle/Toggle.js.map +1 -1
  37. package/lib/esn/index.d.ts +2 -0
  38. package/lib/esn/index.d.ts.map +1 -1
  39. package/lib/esn/index.js +2 -0
  40. package/lib/esn/index.js.map +1 -1
  41. package/lib/esn/tsconfig.tsbuildinfo +42 -5
  42. package/package.json +1 -1
  43. package/site/components/Documentation/Components/SectionButtons.tsx +37 -0
  44. package/site/components/Documentation/Components/SectionDropdowns.tsx +71 -0
  45. package/site/components/Documentation/Documentation.tsx +1 -0
  46. package/src/ButtonWithDropdown/ButtonWithDropdown.tsx +79 -0
  47. package/src/Dropdown/Dropdown.tsx +27 -11
  48. package/src/Dropdown/DropdownMenu.css +30 -0
  49. package/src/Dropdown/DropdownMenuItemGroup.tsx +22 -0
  50. package/src/Toggle/Toggle.tsx +1 -1
  51. package/src/index.ts +2 -0
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import DropdownButton, { Props as DropdownButtonProps } from './DropdownButton';
3
3
  import DropdownMenu from './DropdownMenu';
4
4
  import DropdownMenuItem from './DropdownMenuItem';
5
+ import DropdownMenuItemGroup from './DropdownMenuItemGroup';
5
6
  import Placement from '../Placement/Placement';
6
7
  import PlacementManager from '../Placement/PlacementManager';
7
8
  import PlacementReference from '../Placement/PlacementReference';
@@ -11,15 +12,21 @@ const { useState } = React;
11
12
 
12
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
14
  type DropdownValue = any;
15
+ interface Option {
16
+ text: string;
17
+ value: DropdownValue;
18
+ }
19
+
20
+ interface OptionGroup {
21
+ text: string;
22
+ options: DropdownValue[];
23
+ }
14
24
 
15
25
  export interface Props extends DropdownButtonProps {
16
26
  /** Handler for the value that is selected */
17
27
  onChange?: (value: DropdownValue) => void;
18
28
  /** Array of options that can be selected */
19
- options: {
20
- text: string;
21
- value: DropdownValue;
22
- }[];
29
+ options: (Option | OptionGroup)[];
23
30
  /** Selected value from the options */
24
31
  selected?: DropdownValue;
25
32
  maxHeight?: string;
@@ -41,6 +48,14 @@ const Dropdown: React.FunctionComponent<Props> = (props: Props) => {
41
48
  handleToggleVisible();
42
49
  };
43
50
 
51
+ const renderOption = (({ text, value }: Option) => (
52
+ <DropdownMenuItem
53
+ onClick={ () => handleChange(value) }
54
+ selected={ selected === value }>
55
+ { text }
56
+ </DropdownMenuItem>
57
+ ));
58
+
44
59
  return (
45
60
  <PlacementManager>
46
61
  <PlacementReference>
@@ -59,13 +74,14 @@ const Dropdown: React.FunctionComponent<Props> = (props: Props) => {
59
74
  <Placement onClose={ handleToggleVisible } visible={ visible }>
60
75
  { ({ width }) => (
61
76
  <DropdownMenu maxHeight={ maxHeight } width={ width }>
62
- { options.map(({ text, value }) => (
63
- <DropdownMenuItem
64
- key={ text }
65
- onClick={ () => handleChange(value) }
66
- selected={ selected === value }>
67
- { text }
68
- </DropdownMenuItem>
77
+ { options.map((option) => (
78
+ <React.Fragment key={ option.text }>
79
+ { 'options' in option ? (
80
+ <DropdownMenuItemGroup text={ option.text }>
81
+ { option.options.map(groupOption => <React.Fragment key={ groupOption.value }>{ renderOption(groupOption) }</React.Fragment>) }
82
+ </DropdownMenuItemGroup>
83
+ ) : renderOption(option) }
84
+ </React.Fragment>
69
85
  )) }
70
86
  </DropdownMenu>
71
87
  ) }
@@ -4,14 +4,44 @@
4
4
  word-break: break-word;
5
5
  }
6
6
 
7
+ .DropdownMenu__group-text {
8
+ display: flex;
9
+ align-items: center;
10
+ padding: var(--size--x3) var(--size--x4);
11
+ text-transform: uppercase;
12
+ gap: var(--size--x4);
13
+ }
14
+
15
+ .DropdownMenu__group-text::after {
16
+ content: '';
17
+ flex: 1;
18
+ /* stylelint-disable-next-line unit-blacklist */
19
+ height: 1px;
20
+ background-color: var(--color-gray--3);
21
+ }
22
+
7
23
  .DropdownMenu__item {
8
24
  padding: var(--size--x3) var(--size--x8) var(--size--x3) var(--size--x1);
25
+ border: 0;
26
+ background: transparent;
27
+ color: inherit;
28
+ text-align: left;
29
+ line-height: inherit;
9
30
  cursor: pointer;
10
31
  transition-property: background-color, color;
11
32
  transition-duration: var(--transition-duration--base);
12
33
  transition-timing-function: var(--transition-timing-function);
13
34
  }
14
35
 
36
+ .DropdownMenu__group .DropdownMenu__item {
37
+ padding-left: var(--size--x4);
38
+ }
39
+
40
+ .DropdownMenu__item[disabled] {
41
+ color: var(--color-gray--5);
42
+ pointer-events: none;
43
+ }
44
+
15
45
  .DropdownMenu__item:hover {
16
46
  background-color: var(--color-grape--1);
17
47
  color: var(--color-grape--3);
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ import classnames from 'classnames';
3
+ import Flex, { Props as FlexProps } from '../Flex/Flex';
4
+ import Text from '../Text/Text';
5
+
6
+ export interface Props extends FlexProps {
7
+ text: string;
8
+ }
9
+
10
+ const DropdownMenuItemGroup: React.FunctionComponent<Props> = ({
11
+ text,
12
+ children,
13
+ className,
14
+ ...rest
15
+ }: Props) => (
16
+ <Flex className={ classnames('DropdownMenu__group', className) } { ...rest }>
17
+ <Text className="DropdownMenu__group-text" size="2" textColor="gray-6">{ text }</Text>
18
+ { children }
19
+ </Flex>
20
+ );
21
+
22
+ export default DropdownMenuItemGroup;
@@ -45,7 +45,7 @@ const Toggle: React.FunctionComponent<Props> = (props: Props) => {
45
45
  </Flex>
46
46
 
47
47
  { children && (
48
- <Flex>
48
+ <Flex minWidth="0px" shrink>
49
49
  { children }
50
50
  </Flex>
51
51
  ) }
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@ export { default as Base, Props as BaseProps, TypeColors, TypeSizes } from './Ba
23
23
  export { default as Bounds, Props as BoundsProps } from './Bounds/Bounds';
24
24
  export { default as Button, Props as ButtonProps } from './Button/Button';
25
25
  export { default as Buttons, Props as ButtonsProps } from './Button/Buttons';
26
+ export { default as ButtonWithDropdown, Props as ButtonWithDropdownProps } from './ButtonWithDropdown/ButtonWithDropdown';
26
27
  export { default as Card, Props as CardProps } from './Card/Card';
27
28
  export { default as CardButton, Props as CardButtonProps } from './Card/CardButton';
28
29
  export { default as CardContent, Props as CardContentProps } from './Card/CardContent';
@@ -37,6 +38,7 @@ export { default as DropdownButton, Props as DropdownButtonProps } from './Dropd
37
38
  export { default as DropdownMenus, Props as DropdownMenusProps } from './Dropdown/DropdownMenus';
38
39
  export { default as DropdownMenu, Props as DropdownMenuProps } from './Dropdown/DropdownMenu';
39
40
  export { default as DropdownMenuItem, Props as DropdownMenuItemProps } from './Dropdown/DropdownMenuItem';
41
+ export { default as DropdownMenuItemGroup, Props as DropdownMenuItemGroupProps } from './Dropdown/DropdownMenuItemGroup';
40
42
  export { default as Expand, Props as ExpandProps } from './Expand/Expand';
41
43
  export { default as ExternalLink, Props as ExternalLinkProps } from './ExternalLink/ExternalLink';
42
44
  export { default as Flex, Props as FlexProps } from './Flex/Flex';