@bitrise/bitkit 10.13.0-alpha-table-new.1 → 10.14.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "10.13.0-alpha-table-new.1",
4
+ "version": "10.14.0",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -133,3 +133,22 @@ export const WithIcon = () => {
133
133
  </Dropdown>
134
134
  );
135
135
  };
136
+ export const WithCustomLabel = () => {
137
+ const [value, setValue] = useState('custom');
138
+
139
+ return (
140
+ <Dropdown
141
+ iconName="Calendar"
142
+ value={value}
143
+ onChange={(event) => setValue(event.target.value as string)}
144
+ formLabel={value === 'custom' ? '18 Aug - 19 Aug' : value}
145
+ search={false}
146
+ >
147
+ <DropdownOption value="Last 30 days">Last 30 days</DropdownOption>
148
+ <DropdownOption value="Last 40 days">Last 45 days</DropdownOption>
149
+ <DropdownOption value="Last 50 days">Last 60 days</DropdownOption>
150
+ <DropdownOption value="Last 90 days">Last 90 days</DropdownOption>
151
+ <DropdownOption value="custom">Custom</DropdownOption>
152
+ </Dropdown>
153
+ );
154
+ };
@@ -549,4 +549,29 @@ describe('Dropdown', () => {
549
549
  });
550
550
  });
551
551
  });
552
+
553
+ describe('label', () => {
554
+ it('renders label associated with the selected option', async () => {
555
+ render(
556
+ <Dropdown defaultValue="Test option 2">
557
+ <DropdownOption value="Test option 1">Test option 1</DropdownOption>
558
+ <DropdownOption value="Test option 2">Test option 2</DropdownOption>
559
+ </Dropdown>,
560
+ );
561
+
562
+ const button = await screen.findByRole('combobox');
563
+ expect(button).toHaveTextContent('Test option 2');
564
+ });
565
+
566
+ it('renders custom label if provided', async () => {
567
+ render(
568
+ <Dropdown formLabel="Custom label">
569
+ <DropdownOption>Test option</DropdownOption>
570
+ </Dropdown>,
571
+ );
572
+
573
+ const button = await screen.findByRole('combobox');
574
+ expect(button).toHaveTextContent('Custom label');
575
+ });
576
+ });
552
577
  });
@@ -102,6 +102,7 @@ export interface DropdownProps<T> extends ChakraProps {
102
102
  search?: ReactNode;
103
103
  children?: ReactNode;
104
104
  iconName?: TypeIconName;
105
+ formLabel?: string;
105
106
  }
106
107
 
107
108
  function useOptionListWithIndexes({ children }: { children: ReactNode }) {
@@ -266,7 +267,18 @@ function useDropdown<T>({
266
267
 
267
268
  const Dropdown = forwardRef<DropdownInstance<string | null>, DropdownProps<string | null>>(
268
269
  (
269
- { dropdownMaxHeight, dropdownMinHeight, readOnly, onBlur, placeholder, name, search, size = 'medium', ...props },
270
+ {
271
+ dropdownMaxHeight,
272
+ dropdownMinHeight,
273
+ readOnly,
274
+ onBlur,
275
+ placeholder,
276
+ name,
277
+ search,
278
+ size = 'medium',
279
+ formLabel: customFormLabel,
280
+ ...props
281
+ },
270
282
  ref,
271
283
  ) => {
272
284
  const optionsRef = useRef(null);
@@ -316,7 +328,7 @@ const Dropdown = forwardRef<DropdownInstance<string | null>, DropdownProps<strin
316
328
  {...props}
317
329
  placeholder={placeholder}
318
330
  size={size}
319
- formLabel={formLabel}
331
+ formLabel={customFormLabel ?? formLabel}
320
332
  blurHandler={blurHandler}
321
333
  readOnly={readOnly}
322
334
  />
@@ -0,0 +1,36 @@
1
+ import { Story, ComponentMeta } from '@storybook/react';
2
+ import { useDisclosure } from '@chakra-ui/react';
3
+ import Button from '../Button/Button';
4
+ import LightBox, { LightBoxProps } from './LightBox';
5
+
6
+ export default {
7
+ title: 'Components/LightBox',
8
+ component: LightBox,
9
+ } as ComponentMeta<typeof LightBox>;
10
+
11
+ export const WithProps: Story<LightBoxProps> = ({ ...props }: LightBoxProps) => {
12
+ const { isOpen, onClose, onOpen } = useDisclosure();
13
+
14
+ const getContent = () => {
15
+ return (
16
+ <iframe
17
+ id="ytplayer"
18
+ title="Intro to Bitrise"
19
+ width="100%"
20
+ height="500"
21
+ src="https://www.youtube.com/embed/JrCn9xWQ7IM"
22
+ frameBorder="0"
23
+ allowFullScreen
24
+ />
25
+ );
26
+ };
27
+
28
+ return (
29
+ <>
30
+ <Button onClick={onOpen}>Open LightBox</Button>
31
+ <LightBox padding="0" {...props} isOpen={isOpen} onClose={onClose}>
32
+ {getContent()}
33
+ </LightBox>
34
+ </>
35
+ );
36
+ };
@@ -0,0 +1,22 @@
1
+ import { Modal, ModalOverlay, ModalContent, usePrefersReducedMotion, HTMLChakraProps } from '@chakra-ui/react';
2
+
3
+ export interface LightBoxProps extends Omit<HTMLChakraProps<'section'>, 'scrollBehavior'> {
4
+ dataTestid?: string;
5
+ isOpen: boolean;
6
+ onClose(): void;
7
+ }
8
+
9
+ const LightBox = ({ children, dataTestid, isOpen, onClose, ...rest }: LightBoxProps) => {
10
+ const prefersReducedMotion = usePrefersReducedMotion();
11
+
12
+ return (
13
+ <Modal isOpen={isOpen} motionPreset={prefersReducedMotion ? 'none' : 'scale'} onClose={onClose}>
14
+ <ModalOverlay />
15
+ <ModalContent borderRadius="0" data-testid={dataTestid} {...rest}>
16
+ {children}
17
+ </ModalContent>
18
+ </Modal>
19
+ );
20
+ };
21
+
22
+ export default LightBox;
package/src/index.ts CHANGED
@@ -160,26 +160,5 @@ export { default as Accordion } from './Components/Accordion/Accordion';
160
160
  export type { AccordionItemProps } from './Components/Accordion/AccordionItem';
161
161
  export { default as AccordionItem } from './Components/Accordion/AccordionItem';
162
162
 
163
- export type { TableProps } from './Components/Table/Table';
164
- export { default as Table } from './Components/Table/Table';
165
-
166
- export type { TableCaptionProps } from './Components/Table/TableCaption';
167
- export { default as TableCaption } from './Components/Table/TableCaption';
168
-
169
- export type { TableContainerProps } from './Components/Table/TableContainer';
170
- export { default as TableContainer } from './Components/Table/TableContainer';
171
-
172
- export type { TableBodyProps } from './Components/Table/Tbody';
173
- export { default as Tbody } from './Components/Table/Tbody';
174
-
175
- export type { TableCellProps } from './Components/Table/Td';
176
- export { default as Td } from './Components/Table/Td';
177
-
178
- export type { TableColumnHeaderProps } from './Components/Table/Th';
179
- export { default as Th } from './Components/Table/Th';
180
-
181
- export type { TableHeadProps } from './Components/Table/Thead';
182
- export { default as Thead } from './Components/Table/Thead';
183
-
184
- export type { TableRowProps } from './Components/Table/Tr';
185
- export { default as Tr } from './Components/Table/Tr';
163
+ export type { LightBoxProps } from './Components/LightBox/LightBox';
164
+ export { default as LightBox } from './Components/LightBox/LightBox';
package/src/old.ts CHANGED
@@ -72,27 +72,27 @@ export { default as SkeletonBox } from './Old/Skeleton/SkeletonBox';
72
72
  export type { Props as Status500Props } from './Old/Status/Status500';
73
73
  export { default as Status500 } from './Old/Status/Status500';
74
74
 
75
- export type { Props as OldTableProps } from './Old/Table/Table';
76
- export { default as OldTable } from './Old/Table/Table';
75
+ export type { Props as TableProps } from './Old/Table/Table';
76
+ export { default as Table } from './Old/Table/Table';
77
77
 
78
- export type { Props as OldTableBodyProps } from './Old/Table/TableBody';
79
- export { default as OldTableBody } from './Old/Table/TableBody';
78
+ export type { Props as TableBodyProps } from './Old/Table/TableBody';
79
+ export { default as TableBody } from './Old/Table/TableBody';
80
80
 
81
- export type { Props as OldTableCellProps } from './Old/Table/TableCell';
82
- export { default as OldTableCell } from './Old/Table/TableCell';
81
+ export type { Props as TableCellProps } from './Old/Table/TableCell';
82
+ export { default as TableCell } from './Old/Table/TableCell';
83
83
 
84
- export type { Props as OldTableHeaderProps } from './Old/Table/TableHeader';
85
- export { default as OldTableHeader } from './Old/Table/TableHeader';
84
+ export type { Props as TableHeaderProps } from './Old/Table/TableHeader';
85
+ export { default as TableHeader } from './Old/Table/TableHeader';
86
86
 
87
- export type { Props as OldTableHeaderCellProps } from './Old/Table/TableHeaderCell';
87
+ export type { Props as TableHeaderCellProps } from './Old/Table/TableHeaderCell';
88
88
  export type { TypeTableSort } from './Old/Table/TableHeaderCell';
89
- export { default as OldTableHeaderCell } from './Old/Table/TableHeaderCell';
89
+ export { default as TableHeaderCell } from './Old/Table/TableHeaderCell';
90
90
 
91
- export type { Props as OldTableHeaderRowProps } from './Old/Table/TableHeaderRow';
92
- export { default as OldTableHeaderRow } from './Old/Table/TableHeaderRow';
91
+ export type { Props as TableHeaderRowProps } from './Old/Table/TableHeaderRow';
92
+ export { default as TableHeaderRow } from './Old/Table/TableHeaderRow';
93
93
 
94
- export type { Props as OldTableRowProps } from './Old/Table/TableRow';
95
- export { default as OldTableRow } from './Old/Table/TableRow';
94
+ export type { Props as TableRowProps } from './Old/Table/TableRow';
95
+ export { default as TableRow } from './Old/Table/TableRow';
96
96
 
97
97
  export type { Props as TextareaProps } from './Old/Textarea/Textarea';
98
98
  export { default as Textarea } from './Old/Textarea/Textarea';
package/src/theme.ts CHANGED
@@ -18,7 +18,6 @@ import Input from './Components/Input/Input.theme';
18
18
  import Dropdown from './Components/Dropdown/Dropdown.theme';
19
19
  import Tabs from './Components/Tabs/Tabs.theme';
20
20
  import Text from './Components/Text/Text.theme';
21
- import Table from './Components/Table/Table.theme';
22
21
  import Alert from './Foundations/Themes/Alert.theme';
23
22
  import Tooltip from './Components/Tooltip/Tooltip.theme';
24
23
  import CloseButton from './Components/CloseButton/CloseButton.theme';
@@ -77,7 +76,6 @@ const theme = {
77
76
  Checkbox,
78
77
  ColorButton,
79
78
  Divider,
80
- Dropdown,
81
79
  EmptyState,
82
80
  Link,
83
81
  List,
@@ -85,7 +83,7 @@ const theme = {
85
83
  Modal: Dialog,
86
84
  Radio,
87
85
  Select,
88
- Table,
86
+ Dropdown,
89
87
  Tabs,
90
88
  Text,
91
89
  Tooltip,