@bitrise/bitkit 12.82.0 → 12.83.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": "12.82.0",
4
+ "version": "12.83.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -1,13 +1,13 @@
1
1
  import { useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import { DateTime } from 'luxon';
3
3
  import FocusLock from 'react-focus-lock';
4
- import { PopoverAnchor } from '@chakra-ui/react';
5
4
  import { useObjectMemo } from '../../utils/utils';
6
5
  import Popover from '../Popover/Popover';
7
6
  import PopoverContent from '../Popover/PopoverContent';
8
7
  import Box from '../Box/Box';
9
8
  import useResponsive from '../../hooks/useResponsive';
10
9
  import Button from '../Button/Button';
10
+ import PopoverTrigger from '../Popover/PopoverTrigger';
11
11
  import DatePickerMonth from './DatePickerMonth';
12
12
  import { DatePickerContext } from './DatePicker.context';
13
13
  import DatePickerMonthSelector from './DatePickerMonthSelector';
@@ -183,7 +183,7 @@ const DatePicker = (props: DatePickerProps) => {
183
183
 
184
184
  return (
185
185
  <Popover modifiers={[]} isOpen={visible} onClose={onClose} isLazy lazyBehavior="unmount">
186
- <PopoverAnchor>{children}</PopoverAnchor>
186
+ <PopoverTrigger>{children}</PopoverTrigger>
187
187
  <PopoverContent aria-label="select date range">
188
188
  <FocusLock returnFocus>
189
189
  <DatePickerContext value={ctx}>
@@ -0,0 +1,50 @@
1
+ import { useState } from 'react';
2
+ import { forwardRef } from '@chakra-ui/react';
3
+ import DatePicker from '../../DatePicker/DatePicker';
4
+ import IconButton from '../../IconButton/IconButton';
5
+ import Input, { InputProps } from '../Input/Input';
6
+
7
+ export type DateInputProps = Omit<InputProps, 'value' | 'onChange' | 'placeholder'> & {
8
+ onCalendarClick?(): void;
9
+ value?: string;
10
+ onChange?(value: string): void;
11
+ };
12
+
13
+ const DateInput = forwardRef<DateInputProps, 'div'>((props, ref) => {
14
+ const { onCalendarClick, value, onChange, ...rest } = props;
15
+ const [isDatePickerVisible, setIsDatePickerVisible] = useState(false);
16
+
17
+ const rightButton = (
18
+ <IconButton
19
+ iconName="Calendar"
20
+ onClick={() => setIsDatePickerVisible(true)}
21
+ variant="tertiary"
22
+ aria-label="Show date picker"
23
+ _active={{ background: 'transparent' }}
24
+ _hover={{ background: 'transparent' }}
25
+ color="icon.tertiary"
26
+ />
27
+ );
28
+
29
+ return (
30
+ <DatePicker
31
+ variant="default"
32
+ onApply={(day) => onChange?.(day?.toLocaleString() || '')}
33
+ onClose={() => setIsDatePickerVisible(false)}
34
+ visible={isDatePickerVisible}
35
+ mode="day"
36
+ >
37
+ <Input
38
+ {...rest}
39
+ onChange={(e) => onChange?.(e.target.value)}
40
+ placeholder="dd/mm/yyyy"
41
+ ref={ref}
42
+ rightAddon={rightButton}
43
+ rightAddonPlacement="inside"
44
+ value={value}
45
+ />
46
+ </DatePicker>
47
+ );
48
+ });
49
+
50
+ export default DateInput;
package/src/index.ts CHANGED
@@ -330,3 +330,6 @@ export { default as ProgressIndicator } from './Components/ProgressIndicator/Pro
330
330
  export type { FilterProps } from './Components/Filter/Filter';
331
331
  export { default as Filter } from './Components/Filter/Filter';
332
332
  export * from './Components/Filter/Filter.types';
333
+
334
+ export type { DateInputProps } from './Components/Form/DateInput/DateInput';
335
+ export { default as DateInput } from './Components/Form/DateInput/DateInput';