@react-spectrum/datepicker 3.1.2 → 3.3.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/dist/main.css +1 -1
- package/dist/main.js +42 -32
- package/dist/main.js.map +1 -1
- package/dist/module.js +43 -33
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/DateField.tsx +4 -2
- package/src/DatePicker.tsx +4 -3
- package/src/DateRangePicker.tsx +4 -3
- package/src/Input.tsx +22 -16
- package/src/TimeField.tsx +4 -2
- package/src/styles.css +3 -3
package/src/Input.tsx
CHANGED
|
@@ -14,10 +14,10 @@ import Alert from '@spectrum-icons/ui/AlertMedium';
|
|
|
14
14
|
import Checkmark from '@spectrum-icons/ui/CheckmarkMedium';
|
|
15
15
|
import {classNames, useValueEffect} from '@react-spectrum/utils';
|
|
16
16
|
import datepickerStyles from './styles.css';
|
|
17
|
-
import {
|
|
18
|
-
import {mergeRefs, useEvent, useLayoutEffect, useResizeObserver} from '@react-aria/utils';
|
|
17
|
+
import {mergeProps, mergeRefs, useEvent, useLayoutEffect, useResizeObserver} from '@react-aria/utils';
|
|
19
18
|
import React, {useCallback, useRef} from 'react';
|
|
20
19
|
import textfieldStyles from '@adobe/spectrum-css-temp/components/textfield/vars.css';
|
|
20
|
+
import {useFocusRing} from '@react-aria/focus';
|
|
21
21
|
|
|
22
22
|
function Input(props, ref) {
|
|
23
23
|
let inputRef = useRef(null);
|
|
@@ -29,7 +29,8 @@ function Input(props, ref) {
|
|
|
29
29
|
children,
|
|
30
30
|
fieldProps,
|
|
31
31
|
className,
|
|
32
|
-
style
|
|
32
|
+
style,
|
|
33
|
+
disableFocusRing
|
|
33
34
|
} = props;
|
|
34
35
|
|
|
35
36
|
// Reserve padding for the error icon when the width of the input is unconstrained.
|
|
@@ -77,14 +78,20 @@ function Input(props, ref) {
|
|
|
77
78
|
// parent element.
|
|
78
79
|
useEvent(useRef(typeof window !== 'undefined' ? window : null), 'resize', onResize);
|
|
79
80
|
|
|
80
|
-
let
|
|
81
|
+
let {focusProps, isFocusVisible, isFocused} = useFocusRing({
|
|
82
|
+
isTextInput: true,
|
|
83
|
+
within: true
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
let isInvalid = validationState === 'invalid' && !isDisabled;
|
|
81
87
|
let textfieldClass = classNames(
|
|
82
88
|
textfieldStyles,
|
|
83
89
|
'spectrum-Textfield',
|
|
84
90
|
{
|
|
85
91
|
'spectrum-Textfield--invalid': isInvalid,
|
|
86
|
-
'spectrum-Textfield--valid': validationState === 'valid',
|
|
87
|
-
'spectrum-Textfield--quiet': isQuiet
|
|
92
|
+
'spectrum-Textfield--valid': validationState === 'valid' && !isDisabled,
|
|
93
|
+
'spectrum-Textfield--quiet': isQuiet,
|
|
94
|
+
'focus-ring': isFocusVisible && !disableFocusRing
|
|
88
95
|
},
|
|
89
96
|
classNames(datepickerStyles, 'react-spectrum-Datepicker-field'),
|
|
90
97
|
className
|
|
@@ -95,7 +102,8 @@ function Input(props, ref) {
|
|
|
95
102
|
'spectrum-Textfield-input',
|
|
96
103
|
{
|
|
97
104
|
'is-disabled': isDisabled,
|
|
98
|
-
'is-invalid': isInvalid
|
|
105
|
+
'is-invalid': isInvalid,
|
|
106
|
+
'is-focused': isFocused
|
|
99
107
|
},
|
|
100
108
|
reservePadding && classNames(datepickerStyles, 'react-spectrum-Datepicker-input'),
|
|
101
109
|
inputClassName
|
|
@@ -107,21 +115,19 @@ function Input(props, ref) {
|
|
|
107
115
|
);
|
|
108
116
|
|
|
109
117
|
let validationIcon = null;
|
|
110
|
-
if (validationState === 'invalid') {
|
|
118
|
+
if (validationState === 'invalid' && !isDisabled) {
|
|
111
119
|
validationIcon = <Alert data-testid="invalid-icon" UNSAFE_className={iconClass} />;
|
|
112
|
-
} else if (validationState === 'valid') {
|
|
120
|
+
} else if (validationState === 'valid' && !isDisabled) {
|
|
113
121
|
validationIcon = <Checkmark data-testid="valid-icon" UNSAFE_className={iconClass} />;
|
|
114
122
|
}
|
|
115
123
|
|
|
116
124
|
return (
|
|
117
|
-
<div role="presentation" {...fieldProps} className={textfieldClass} style={style}>
|
|
118
|
-
<
|
|
119
|
-
<div role="presentation" className={
|
|
120
|
-
|
|
121
|
-
{children}
|
|
122
|
-
</div>
|
|
125
|
+
<div role="presentation" {...mergeProps(fieldProps, focusProps)} className={textfieldClass} style={style}>
|
|
126
|
+
<div role="presentation" className={inputClass}>
|
|
127
|
+
<div role="presentation" className={classNames(datepickerStyles, 'react-spectrum-Datepicker-inputContents')} ref={mergeRefs(ref, inputRef)}>
|
|
128
|
+
{children}
|
|
123
129
|
</div>
|
|
124
|
-
</
|
|
130
|
+
</div>
|
|
125
131
|
{validationIcon}
|
|
126
132
|
</div>
|
|
127
133
|
);
|
package/src/TimeField.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import datepickerStyles from './styles.css';
|
|
|
16
16
|
import {Field} from '@react-spectrum/label';
|
|
17
17
|
import {FocusableRef} from '@react-types/shared';
|
|
18
18
|
import {Input} from './Input';
|
|
19
|
-
import React, {ReactElement} from 'react';
|
|
19
|
+
import React, {ReactElement, useRef} from 'react';
|
|
20
20
|
import {SpectrumTimeFieldProps, TimeValue} from '@react-types/datepicker';
|
|
21
21
|
import {useFocusManagerRef} from './utils';
|
|
22
22
|
import {useLocale} from '@react-aria/i18n';
|
|
@@ -41,7 +41,8 @@ function TimeField<T extends TimeValue>(props: SpectrumTimeFieldProps<T>, ref: F
|
|
|
41
41
|
locale
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
let
|
|
44
|
+
let inputRef = useRef(null);
|
|
45
|
+
let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useTimeField(props, state, inputRef);
|
|
45
46
|
|
|
46
47
|
return (
|
|
47
48
|
<Field
|
|
@@ -54,6 +55,7 @@ function TimeField<T extends TimeValue>(props: SpectrumTimeFieldProps<T>, ref: F
|
|
|
54
55
|
validationState={state.validationState}
|
|
55
56
|
UNSAFE_className={classNames(datepickerStyles, 'react-spectrum-TimeField-fieldWrapper')}>
|
|
56
57
|
<Input
|
|
58
|
+
ref={inputRef}
|
|
57
59
|
fieldProps={fieldProps}
|
|
58
60
|
isDisabled={isDisabled}
|
|
59
61
|
isQuiet={isQuiet}
|
package/src/styles.css
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
/* specificity war with .spectrum-Field--positionSide etc. */
|
|
41
41
|
.react-spectrum-DateField.react-spectrum-DateField.react-spectrum-DateField.react-spectrum-DateField {
|
|
42
|
-
min-width: var(--spectrum-global-dimension-size-2000)
|
|
42
|
+
min-width: var(--spectrum-global-dimension-size-2000);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
.react-spectrum-TimeField.react-spectrum-TimeField.react-spectrum-TimeField.react-spectrum-TimeField {
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
border: none;
|
|
94
94
|
background: none;
|
|
95
95
|
padding: 0 2px;
|
|
96
|
-
border-radius:
|
|
96
|
+
border-radius: var(--spectrum-alias-border-radius-small);
|
|
97
97
|
font-variant-numeric: tabular-nums;
|
|
98
98
|
text-align: end;
|
|
99
99
|
box-sizing: content-box;
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
.react-spectrum-DatePicker-cell:focus {
|
|
138
|
-
background-color: var(--spectrum-
|
|
138
|
+
background-color: var(--spectrum-accent-background-color-default);
|
|
139
139
|
color: white;
|
|
140
140
|
caret-color: transparent;
|
|
141
141
|
outline: none;
|