@bitrise/bitkit 12.92.0 → 12.93.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.92.0",
4
+ "version": "12.93.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -16,6 +16,8 @@ export type DateInputProps = Omit<InputProps, 'value' | 'onChange' | 'placeholde
16
16
  const DateInput = forwardRef<DateInputProps, 'div'>((props, ref) => {
17
17
  const { inputRef, onCalendarClick, onChange, value, ...rest } = props;
18
18
  const [isDatePickerVisible, setIsDatePickerVisible] = useState(false);
19
+ const [isFocused, setIsFocused] = useState(false);
20
+ const [isEmpty, setIsEmpty] = useState(true);
19
21
 
20
22
  const dateFormat = 'MM/dd/yyyy';
21
23
 
@@ -48,7 +50,7 @@ const DateInput = forwardRef<DateInputProps, 'div'>((props, ref) => {
48
50
  },
49
51
  },
50
52
  format: (date: Date | null) => (date ? DateTime.fromJSDate(date).toFormat(dateFormat) : ''),
51
- lazy: false,
53
+ lazy: !isFocused && isEmpty,
52
54
  mask: Date,
53
55
  parse: (str: string) => {
54
56
  try {
@@ -60,7 +62,10 @@ const DateInput = forwardRef<DateInputProps, 'div'>((props, ref) => {
60
62
  pattern: 'LL/dd/yyyy',
61
63
  },
62
64
  {
63
- onAccept: (val) => onChange?.(val),
65
+ onAccept: (val, maskRef) => {
66
+ onChange?.(val);
67
+ setIsEmpty(!maskRef.unmaskedValue);
68
+ },
64
69
  },
65
70
  );
66
71
 
@@ -89,6 +94,9 @@ const DateInput = forwardRef<DateInputProps, 'div'>((props, ref) => {
89
94
  {...rest}
90
95
  ref={ref}
91
96
  inputRef={innerRef}
97
+ onBlur={() => setIsFocused(false)}
98
+ onFocus={() => setIsFocused(true)}
99
+ placeholder={dateFormat.toLocaleLowerCase()}
92
100
  rightAddon={
93
101
  <IconButton
94
102
  _active={{ background: 'transparent' }}