@indico-data/design-system 3.0.8 → 3.0.10
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/lib/components/floatUI/FloatUI.d.ts +1 -1
- package/lib/components/floatUI/types.d.ts +1 -0
- package/lib/components/forms/date/datePicker/types.d.ts +7 -0
- package/lib/components/forms/date/iconTriggerDatePicker/IconTriggerDatePicker.d.ts +5 -0
- package/lib/components/forms/date/inputDatePicker/SingleInputDatePicker.d.ts +8 -0
- package/lib/components/forms/date/inputDateRangePicker/InputDateRangePicker.d.ts +10 -0
- package/lib/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.d.ts +10 -0
- package/lib/components/forms/input/Input.d.ts +1 -0
- package/lib/components/forms/textarea/Textarea.d.ts +1 -0
- package/lib/components/forms/timePicker/TimePicker.d.ts +7 -1
- package/lib/index.css +10 -0
- package/lib/index.d.ts +43 -2
- package/lib/index.esm.css +10 -0
- package/lib/index.esm.js +130 -124
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +130 -124
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/floatUI/FloatUI.tsx +2 -1
- package/src/components/floatUI/types.ts +1 -0
- package/src/components/forms/date/datePicker/DatePicker.tsx +11 -1
- package/src/components/forms/date/datePicker/styles/DatePicker.scss +10 -0
- package/src/components/forms/date/datePicker/types.ts +8 -0
- package/src/components/forms/date/iconTriggerDatePicker/IconTriggerDatePicker.stories.tsx +30 -0
- package/src/components/forms/date/iconTriggerDatePicker/IconTriggerDatePicker.tsx +15 -1
- package/src/components/forms/date/inputDatePicker/SingleInputDatePicker.stories.tsx +51 -0
- package/src/components/forms/date/inputDatePicker/SingleInputDatePicker.tsx +24 -2
- package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.stories.tsx +58 -0
- package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.tsx +31 -2
- package/src/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.stories.tsx +59 -0
- package/src/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.tsx +40 -5
- package/src/components/forms/input/Input.tsx +3 -0
- package/src/components/forms/textarea/Textarea.tsx +3 -0
- package/src/components/forms/timePicker/TimePicker.tsx +39 -1
- package/src/components/forms/timePicker/__tests__/TimePicker.test.tsx +4 -2
- package/src/storybook/formArgTypes.ts +14 -0
package/package.json
CHANGED
|
@@ -26,6 +26,7 @@ export function FloatUI({
|
|
|
26
26
|
isPortal = false,
|
|
27
27
|
portalOptions = {},
|
|
28
28
|
floatingOptions = defaultOptions,
|
|
29
|
+
className,
|
|
29
30
|
}: FloatUIProps) {
|
|
30
31
|
const [internalIsOpen, setInternalIsOpen] = useState(false);
|
|
31
32
|
|
|
@@ -71,7 +72,7 @@ export function FloatUI({
|
|
|
71
72
|
style={floatingStyles}
|
|
72
73
|
role="dialog"
|
|
73
74
|
aria-label={ariaLabel}
|
|
74
|
-
className=
|
|
75
|
+
className={`floatui-container ${className}`}
|
|
75
76
|
>
|
|
76
77
|
<div ref={floatUIContentRef} className="floatui-content">
|
|
77
78
|
{content}
|
|
@@ -34,6 +34,10 @@ export const DatePicker = (props: DatePickerProps) => {
|
|
|
34
34
|
onNextClick,
|
|
35
35
|
onPrevClick,
|
|
36
36
|
onDayClick,
|
|
37
|
+
isReadOnly,
|
|
38
|
+
ref,
|
|
39
|
+
timeTabIndex,
|
|
40
|
+
dateTabIndex,
|
|
37
41
|
...rest
|
|
38
42
|
} = props;
|
|
39
43
|
|
|
@@ -90,7 +94,13 @@ export const DatePicker = (props: DatePickerProps) => {
|
|
|
90
94
|
<p className="ma-0">Select Time</p>
|
|
91
95
|
</Col>
|
|
92
96
|
<Col>
|
|
93
|
-
<TimePicker
|
|
97
|
+
<TimePicker
|
|
98
|
+
ref={ref}
|
|
99
|
+
timeValue={timeValue ?? ''}
|
|
100
|
+
onTimeChange={handleTimeChange}
|
|
101
|
+
readonly={isReadOnly}
|
|
102
|
+
tabIndex={timeTabIndex}
|
|
103
|
+
/>
|
|
94
104
|
</Col>
|
|
95
105
|
</Row>
|
|
96
106
|
</div>
|
|
@@ -89,3 +89,13 @@
|
|
|
89
89
|
margin-bottom: var(--pf-margin-3);
|
|
90
90
|
width: 348px;
|
|
91
91
|
}
|
|
92
|
+
|
|
93
|
+
.time-validation-error {
|
|
94
|
+
background-color: var(--pf-tooltip-background-color);
|
|
95
|
+
color: var(--pf-tooltip-font-color);
|
|
96
|
+
padding: var(--pf-padding-2);
|
|
97
|
+
border-radius: var(--pf-rounded);
|
|
98
|
+
width: 200px;
|
|
99
|
+
box-shadow: var(--pf-dropshadow);
|
|
100
|
+
font-size: var(--pf-font-size-overline);
|
|
101
|
+
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from 'react-day-picker';
|
|
11
11
|
|
|
12
12
|
export interface DatePickerProps {
|
|
13
|
+
ref?: React.LegacyRef<HTMLInputElement>;
|
|
13
14
|
selected?: Date | DateRange | undefined;
|
|
14
15
|
onSelect?: OnSelectHandler<Date> | OnSelectHandler<DateRange>;
|
|
15
16
|
mode?: Mode;
|
|
@@ -37,6 +38,9 @@ export interface DatePickerProps {
|
|
|
37
38
|
onNextClick?: MonthChangeEventHandler;
|
|
38
39
|
onPrevClick?: MonthChangeEventHandler;
|
|
39
40
|
onDayClick?: DayEventHandler<React.MouseEvent>;
|
|
41
|
+
isReadOnly?: boolean;
|
|
42
|
+
timeTabIndex?: number;
|
|
43
|
+
dateTabIndex?: number;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
export interface CommonProps {
|
|
@@ -60,3 +64,7 @@ export interface CommonProps {
|
|
|
60
64
|
onPrevClick?: MonthChangeEventHandler;
|
|
61
65
|
onDayClick?: DayEventHandler<React.MouseEvent>;
|
|
62
66
|
}
|
|
67
|
+
|
|
68
|
+
export interface PortalOptions {
|
|
69
|
+
rootId?: string;
|
|
70
|
+
}
|
|
@@ -14,6 +14,36 @@ const meta: Meta<typeof IconTriggerDatePicker> = {
|
|
|
14
14
|
),
|
|
15
15
|
],
|
|
16
16
|
argTypes: {
|
|
17
|
+
isPortal: {
|
|
18
|
+
control: 'boolean',
|
|
19
|
+
description: 'Whether the date picker is a portal.',
|
|
20
|
+
table: {
|
|
21
|
+
category: 'Props',
|
|
22
|
+
type: {
|
|
23
|
+
summary: 'boolean',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
portalOptions: {
|
|
28
|
+
control: false,
|
|
29
|
+
description: 'The portal options for the date picker. Follows floating-ui options.',
|
|
30
|
+
table: {
|
|
31
|
+
category: 'Props',
|
|
32
|
+
type: {
|
|
33
|
+
summary: '{ rootId?: string }',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
floatingOptions: {
|
|
38
|
+
control: false,
|
|
39
|
+
description: 'The floating options for the date picker. Follows floating-ui options.',
|
|
40
|
+
table: {
|
|
41
|
+
category: 'Props',
|
|
42
|
+
type: {
|
|
43
|
+
summary: '{ placement?: Placement; middleware?: Middleware[] }',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
17
47
|
ariaLabel: {
|
|
18
48
|
control: 'text',
|
|
19
49
|
description: 'A label for assistive technologies.',
|
|
@@ -4,6 +4,8 @@ import { IconName, IconSizes } from '../../../icons/types';
|
|
|
4
4
|
import { FloatUI } from '../../../floatUI';
|
|
5
5
|
import { DatePicker } from '../datePicker/DatePicker';
|
|
6
6
|
import { Icon } from '../../../icons/Icon';
|
|
7
|
+
import { UseFloatingOptions } from '@floating-ui/react-dom';
|
|
8
|
+
import { PortalOptions } from '../datePicker/types';
|
|
7
9
|
interface Props {
|
|
8
10
|
mode?: Mode;
|
|
9
11
|
ariaLabel: string;
|
|
@@ -21,6 +23,9 @@ interface Props {
|
|
|
21
23
|
className?: string;
|
|
22
24
|
initialMonth?: Date;
|
|
23
25
|
'data-testid'?: string;
|
|
26
|
+
portalOptions?: PortalOptions;
|
|
27
|
+
isPortal?: boolean;
|
|
28
|
+
floatingOptions?: UseFloatingOptions;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
export const IconTriggerDatePicker = (props: Props) => {
|
|
@@ -40,6 +45,9 @@ export const IconTriggerDatePicker = (props: Props) => {
|
|
|
40
45
|
isOpen,
|
|
41
46
|
clearOnClose,
|
|
42
47
|
initialMonth,
|
|
48
|
+
portalOptions,
|
|
49
|
+
floatingOptions,
|
|
50
|
+
isPortal,
|
|
43
51
|
...rest
|
|
44
52
|
} = props;
|
|
45
53
|
|
|
@@ -61,7 +69,13 @@ export const IconTriggerDatePicker = (props: Props) => {
|
|
|
61
69
|
}, [isOpen, clearOnClose]);
|
|
62
70
|
|
|
63
71
|
return (
|
|
64
|
-
<FloatUI
|
|
72
|
+
<FloatUI
|
|
73
|
+
isOpen={isOpen}
|
|
74
|
+
ariaLabel={ariaLabel}
|
|
75
|
+
isPortal={isPortal}
|
|
76
|
+
portalOptions={portalOptions}
|
|
77
|
+
floatingOptions={floatingOptions}
|
|
78
|
+
>
|
|
65
79
|
<Icon
|
|
66
80
|
aria-label="Open date picker"
|
|
67
81
|
name={triggerIcon}
|
|
@@ -13,6 +13,57 @@ const meta: Meta<typeof SingleInputDatePicker> = {
|
|
|
13
13
|
),
|
|
14
14
|
],
|
|
15
15
|
argTypes: {
|
|
16
|
+
isPortal: {
|
|
17
|
+
control: 'boolean',
|
|
18
|
+
description: 'Whether the date picker is a portal.',
|
|
19
|
+
table: {
|
|
20
|
+
category: 'Props',
|
|
21
|
+
type: {
|
|
22
|
+
summary: 'boolean',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
portalOptions: {
|
|
27
|
+
control: false,
|
|
28
|
+
description: 'The portal options for the date picker. Follows floating-ui options.',
|
|
29
|
+
table: {
|
|
30
|
+
category: 'Props',
|
|
31
|
+
type: {
|
|
32
|
+
summary: '{ rootId?: string }',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
floatingOptions: {
|
|
37
|
+
control: false,
|
|
38
|
+
description: 'The floating options for the date picker. Follows floating-ui options.',
|
|
39
|
+
table: {
|
|
40
|
+
category: 'Props',
|
|
41
|
+
type: {
|
|
42
|
+
summary: '{ placement?: Placement; middleware?: Middleware[] }',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
tabIndex: {
|
|
47
|
+
control: 'number',
|
|
48
|
+
description: 'The tab index of the input field.',
|
|
49
|
+
table: {
|
|
50
|
+
category: 'Props',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
ref: {
|
|
54
|
+
control: false,
|
|
55
|
+
description: 'The ref of the input field.',
|
|
56
|
+
table: {
|
|
57
|
+
category: 'Props',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
isReadOnly: {
|
|
61
|
+
control: 'boolean',
|
|
62
|
+
description: 'Whether the date picker is read only.',
|
|
63
|
+
table: {
|
|
64
|
+
category: 'Props',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
16
67
|
hasHiddenLabel: {
|
|
17
68
|
control: 'boolean',
|
|
18
69
|
description: 'Whether the label is hidden.',
|
|
@@ -5,7 +5,8 @@ import { Input } from '../../input';
|
|
|
5
5
|
import type { IconName } from '../../../icons/types';
|
|
6
6
|
import { FloatUI } from '../../../floatUI';
|
|
7
7
|
import { formatDateAsString } from './helpers';
|
|
8
|
-
|
|
8
|
+
import { UseFloatingOptions } from '@floating-ui/react-dom';
|
|
9
|
+
import { PortalOptions } from '../datePicker/types';
|
|
9
10
|
export interface SingleInputDatePickerProps {
|
|
10
11
|
ariaLabel: string;
|
|
11
12
|
disableBeforeDate?: Date;
|
|
@@ -26,6 +27,12 @@ export interface SingleInputDatePickerProps {
|
|
|
26
27
|
errorMessage?: string | undefined;
|
|
27
28
|
hasHiddenLabel?: boolean;
|
|
28
29
|
'data-testid'?: string;
|
|
30
|
+
ref?: React.LegacyRef<HTMLInputElement>;
|
|
31
|
+
isReadOnly?: boolean;
|
|
32
|
+
tabIndex?: number;
|
|
33
|
+
portalOptions?: PortalOptions;
|
|
34
|
+
floatingOptions?: UseFloatingOptions;
|
|
35
|
+
isPortal?: boolean;
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
export function SingleInputDatePicker(props: SingleInputDatePickerProps) {
|
|
@@ -48,6 +55,12 @@ export function SingleInputDatePicker(props: SingleInputDatePickerProps) {
|
|
|
48
55
|
errorMessage,
|
|
49
56
|
onSelect,
|
|
50
57
|
hasHiddenLabel,
|
|
58
|
+
ref,
|
|
59
|
+
isReadOnly,
|
|
60
|
+
tabIndex,
|
|
61
|
+
portalOptions,
|
|
62
|
+
floatingOptions,
|
|
63
|
+
isPortal,
|
|
51
64
|
...rest
|
|
52
65
|
} = props;
|
|
53
66
|
|
|
@@ -93,7 +106,13 @@ export function SingleInputDatePicker(props: SingleInputDatePickerProps) {
|
|
|
93
106
|
}, [isOpen, clearOnClose]);
|
|
94
107
|
|
|
95
108
|
return (
|
|
96
|
-
<FloatUI
|
|
109
|
+
<FloatUI
|
|
110
|
+
isOpen={isOpen}
|
|
111
|
+
ariaLabel={ariaLabel}
|
|
112
|
+
isPortal={isPortal}
|
|
113
|
+
portalOptions={portalOptions}
|
|
114
|
+
floatingOptions={floatingOptions}
|
|
115
|
+
>
|
|
97
116
|
<Input
|
|
98
117
|
id={inputId}
|
|
99
118
|
value={localTextValue}
|
|
@@ -105,7 +124,10 @@ export function SingleInputDatePicker(props: SingleInputDatePickerProps) {
|
|
|
105
124
|
onChange={handleInputChange}
|
|
106
125
|
errorMessage={errorMessage}
|
|
107
126
|
label={'Single Date Picker'}
|
|
127
|
+
tabIndex={tabIndex}
|
|
108
128
|
name={'Date Picker'}
|
|
129
|
+
ref={ref}
|
|
130
|
+
readonly={isReadOnly}
|
|
109
131
|
/>
|
|
110
132
|
<DatePicker
|
|
111
133
|
captionLayout={captionLayout}
|
|
@@ -15,6 +15,64 @@ const meta: Meta<typeof InputDateRangePicker> = {
|
|
|
15
15
|
),
|
|
16
16
|
],
|
|
17
17
|
argTypes: {
|
|
18
|
+
isPortal: {
|
|
19
|
+
control: 'boolean',
|
|
20
|
+
description: 'Whether the date picker is a portal.',
|
|
21
|
+
table: {
|
|
22
|
+
category: 'Props',
|
|
23
|
+
type: {
|
|
24
|
+
summary: 'boolean',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
portalOptions: {
|
|
29
|
+
control: false,
|
|
30
|
+
description: 'The portal options for the date picker. Follows floating-ui options.',
|
|
31
|
+
table: {
|
|
32
|
+
category: 'Props',
|
|
33
|
+
type: {
|
|
34
|
+
summary: '{ rootId?: string }',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
floatingOptions: {
|
|
39
|
+
control: false,
|
|
40
|
+
description: 'The floating options for the date picker. Follows floating-ui options.',
|
|
41
|
+
table: {
|
|
42
|
+
category: 'Props',
|
|
43
|
+
type: {
|
|
44
|
+
summary: '{ placement?: Placement; middleware?: Middleware[] }',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
fromTabIndex: {
|
|
49
|
+
control: 'number',
|
|
50
|
+
description: 'The tab index of the from input field.',
|
|
51
|
+
table: {
|
|
52
|
+
category: 'Props',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
ref: {
|
|
56
|
+
control: false,
|
|
57
|
+
description: 'The ref of the input field.',
|
|
58
|
+
table: {
|
|
59
|
+
category: 'Props',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
isFromReadOnly: {
|
|
63
|
+
control: 'boolean',
|
|
64
|
+
description: 'Whether the from input is read only.',
|
|
65
|
+
table: {
|
|
66
|
+
category: 'Props',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
isToReadOnly: {
|
|
70
|
+
control: 'boolean',
|
|
71
|
+
description: 'Whether the to input is read only.',
|
|
72
|
+
table: {
|
|
73
|
+
category: 'Props',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
18
76
|
hasHiddenLabel: {
|
|
19
77
|
control: 'boolean',
|
|
20
78
|
description: 'Whether the label is hidden.',
|
|
@@ -8,7 +8,8 @@ import { FloatUI } from '../../../floatUI';
|
|
|
8
8
|
import { Col, Row } from '../../../grid';
|
|
9
9
|
import { formatDateAsString } from '../inputDatePicker/helpers';
|
|
10
10
|
import { Button } from '../../../button';
|
|
11
|
-
|
|
11
|
+
import { UseFloatingOptions } from '@floating-ui/react-dom';
|
|
12
|
+
import { PortalOptions } from '../datePicker/types';
|
|
12
13
|
interface InputDateRangePickerProps {
|
|
13
14
|
ariaLabel: string;
|
|
14
15
|
disableBeforeDate?: Date;
|
|
@@ -33,6 +34,14 @@ interface InputDateRangePickerProps {
|
|
|
33
34
|
closeOnSelect?: boolean;
|
|
34
35
|
clearOnClose?: boolean;
|
|
35
36
|
hasHiddenLabel?: boolean;
|
|
37
|
+
ref?: React.LegacyRef<HTMLInputElement>;
|
|
38
|
+
isFromReadOnly?: boolean;
|
|
39
|
+
isToReadOnly?: boolean;
|
|
40
|
+
toTabIndex?: number;
|
|
41
|
+
fromTabIndex?: number;
|
|
42
|
+
portalOptions?: PortalOptions;
|
|
43
|
+
floatingOptions?: UseFloatingOptions;
|
|
44
|
+
isPortal?: boolean;
|
|
36
45
|
}
|
|
37
46
|
|
|
38
47
|
export function InputDateRangePicker(props: InputDateRangePickerProps) {
|
|
@@ -59,6 +68,14 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
|
|
|
59
68
|
closeOnSelect,
|
|
60
69
|
clearOnClose,
|
|
61
70
|
hasHiddenLabel,
|
|
71
|
+
ref,
|
|
72
|
+
isFromReadOnly,
|
|
73
|
+
isToReadOnly,
|
|
74
|
+
toTabIndex,
|
|
75
|
+
fromTabIndex,
|
|
76
|
+
portalOptions,
|
|
77
|
+
floatingOptions,
|
|
78
|
+
isPortal,
|
|
62
79
|
...rest
|
|
63
80
|
} = props;
|
|
64
81
|
|
|
@@ -139,7 +156,13 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
|
|
|
139
156
|
};
|
|
140
157
|
|
|
141
158
|
return (
|
|
142
|
-
<FloatUI
|
|
159
|
+
<FloatUI
|
|
160
|
+
isOpen={isOpen}
|
|
161
|
+
setIsOpen={setIsOpen}
|
|
162
|
+
ariaLabel={ariaLabel}
|
|
163
|
+
portalOptions={portalOptions}
|
|
164
|
+
floatingOptions={floatingOptions}
|
|
165
|
+
>
|
|
143
166
|
<Row gutterWidth={gutterWidth}>
|
|
144
167
|
<Col>
|
|
145
168
|
<Input
|
|
@@ -154,6 +177,9 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
|
|
|
154
177
|
name={'From Date'}
|
|
155
178
|
data-testid="date-picker-from"
|
|
156
179
|
hasHiddenLabel={hasHiddenLabel}
|
|
180
|
+
ref={ref}
|
|
181
|
+
readonly={isFromReadOnly}
|
|
182
|
+
tabIndex={fromTabIndex}
|
|
157
183
|
/>
|
|
158
184
|
</Col>
|
|
159
185
|
<Col>
|
|
@@ -169,6 +195,9 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
|
|
|
169
195
|
name={'To Date'}
|
|
170
196
|
data-testid="date-picker-to"
|
|
171
197
|
hasHiddenLabel={hasHiddenLabel}
|
|
198
|
+
ref={ref}
|
|
199
|
+
readonly={isToReadOnly}
|
|
200
|
+
tabIndex={toTabIndex}
|
|
172
201
|
/>
|
|
173
202
|
</Col>
|
|
174
203
|
</Row>
|
|
@@ -20,6 +20,65 @@ const meta: Meta<typeof SingleInputDateTimePicker> = {
|
|
|
20
20
|
),
|
|
21
21
|
],
|
|
22
22
|
argTypes: {
|
|
23
|
+
isPortal: {
|
|
24
|
+
control: 'boolean',
|
|
25
|
+
description: 'Whether the date picker is a portal.',
|
|
26
|
+
table: {
|
|
27
|
+
category: 'Props',
|
|
28
|
+
type: {
|
|
29
|
+
summary: 'boolean',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
portalOptions: {
|
|
34
|
+
control: false,
|
|
35
|
+
description: 'The portal options for the date picker. Follows floating-ui options.',
|
|
36
|
+
table: {
|
|
37
|
+
category: 'Props',
|
|
38
|
+
type: {
|
|
39
|
+
summary: '{ rootId?: string }',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
floatingOptions: {
|
|
44
|
+
control: false,
|
|
45
|
+
description: 'The floating options for the date picker. Follows floating-ui options.',
|
|
46
|
+
table: {
|
|
47
|
+
category: 'Props',
|
|
48
|
+
type: {
|
|
49
|
+
summary: '{ placement?: Placement; middleware?: Middleware[] }',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
timeTabIndex: {
|
|
54
|
+
control: 'number',
|
|
55
|
+
description: 'The tab index of the time input field.',
|
|
56
|
+
table: {
|
|
57
|
+
category: 'Props',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
ref: {
|
|
61
|
+
control: false,
|
|
62
|
+
description: 'The ref of the input field.',
|
|
63
|
+
table: {
|
|
64
|
+
category: 'Props',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
timePickerRef: {
|
|
68
|
+
control: false,
|
|
69
|
+
description: 'The ref of the time picker input field.',
|
|
70
|
+
table: {
|
|
71
|
+
category: 'Props',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
isReadOnly: {
|
|
75
|
+
control: 'boolean',
|
|
76
|
+
description: 'Whether the date picker is read only.',
|
|
77
|
+
table: {
|
|
78
|
+
category: 'Props',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
|
|
23
82
|
hasHiddenLabel: {
|
|
24
83
|
control: 'boolean',
|
|
25
84
|
description: 'Whether the label is hidden.',
|
|
@@ -7,6 +7,8 @@ import { FloatUI } from '../../../floatUI';
|
|
|
7
7
|
import { formatDateAsString } from './helpers';
|
|
8
8
|
import { TimePicker } from '../../timePicker/TimePicker';
|
|
9
9
|
import { Row, Col } from '../../../grid';
|
|
10
|
+
import { UseFloatingOptions } from '@floating-ui/react-dom';
|
|
11
|
+
import { PortalOptions } from '../datePicker/types';
|
|
10
12
|
|
|
11
13
|
export interface SingleInputDateTimePickerProps {
|
|
12
14
|
ariaLabel: string;
|
|
@@ -30,6 +32,14 @@ export interface SingleInputDateTimePickerProps {
|
|
|
30
32
|
hasHiddenLabel?: boolean;
|
|
31
33
|
timeValue?: string;
|
|
32
34
|
onTimeChange?: (time: string) => void;
|
|
35
|
+
isReadOnly?: boolean;
|
|
36
|
+
ref?: React.LegacyRef<HTMLInputElement>;
|
|
37
|
+
timePickerRef?: React.LegacyRef<HTMLInputElement>;
|
|
38
|
+
dateTabIndex?: number;
|
|
39
|
+
timeTabIndex?: number;
|
|
40
|
+
portalOptions?: PortalOptions;
|
|
41
|
+
floatingOptions?: UseFloatingOptions;
|
|
42
|
+
isPortal?: boolean;
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps) {
|
|
@@ -54,6 +64,14 @@ export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps)
|
|
|
54
64
|
timeValue,
|
|
55
65
|
onTimeChange,
|
|
56
66
|
hasHiddenLabel,
|
|
67
|
+
isReadOnly,
|
|
68
|
+
timePickerRef,
|
|
69
|
+
dateTabIndex,
|
|
70
|
+
timeTabIndex,
|
|
71
|
+
ref,
|
|
72
|
+
portalOptions,
|
|
73
|
+
floatingOptions,
|
|
74
|
+
isPortal,
|
|
57
75
|
...rest
|
|
58
76
|
} = props;
|
|
59
77
|
|
|
@@ -103,14 +121,24 @@ export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps)
|
|
|
103
121
|
};
|
|
104
122
|
|
|
105
123
|
return (
|
|
106
|
-
<Row>
|
|
107
|
-
<Col>
|
|
108
|
-
<FloatUI
|
|
124
|
+
<Row className="date-time-picker-row">
|
|
125
|
+
<Col className="date-picker-col">
|
|
126
|
+
<FloatUI
|
|
127
|
+
className="date-picker-float-ui"
|
|
128
|
+
isOpen={isOpen}
|
|
129
|
+
ariaLabel={ariaLabel}
|
|
130
|
+
isPortal={isPortal}
|
|
131
|
+
portalOptions={portalOptions}
|
|
132
|
+
floatingOptions={floatingOptions}
|
|
133
|
+
>
|
|
109
134
|
<Input
|
|
135
|
+
ref={ref}
|
|
136
|
+
className={`date-picker-input`}
|
|
110
137
|
id={inputId}
|
|
111
138
|
value={localTextValue}
|
|
112
139
|
placeholder={inputPlaceholder}
|
|
113
|
-
isDisabled={isDisabled}
|
|
140
|
+
isDisabled={isReadOnly || isDisabled}
|
|
141
|
+
readonly={isReadOnly}
|
|
114
142
|
iconName={inputIconName}
|
|
115
143
|
isClearable={isClearable}
|
|
116
144
|
onChange={handleInputChange}
|
|
@@ -118,6 +146,7 @@ export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps)
|
|
|
118
146
|
hasHiddenLabel={hasHiddenLabel}
|
|
119
147
|
label={'Single Date Picker'}
|
|
120
148
|
name={`${id}-date-picker`}
|
|
149
|
+
tabIndex={dateTabIndex}
|
|
121
150
|
/>
|
|
122
151
|
<DatePicker
|
|
123
152
|
captionLayout={captionLayout}
|
|
@@ -126,16 +155,22 @@ export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps)
|
|
|
126
155
|
onSelect={handleDayPickerSelect}
|
|
127
156
|
month={localMonth}
|
|
128
157
|
onMonthChange={setLocalMonth}
|
|
158
|
+
isReadOnly={isReadOnly}
|
|
129
159
|
{...rest}
|
|
130
160
|
/>
|
|
131
161
|
</FloatUI>
|
|
132
162
|
</Col>
|
|
133
|
-
<Col xs="content">
|
|
163
|
+
<Col xs="content" className="time-picker-col">
|
|
134
164
|
<TimePicker
|
|
165
|
+
ref={timePickerRef}
|
|
166
|
+
className={`time-picker-input`}
|
|
135
167
|
timeValue={timeValue}
|
|
136
168
|
name={`${id}-time-picker`}
|
|
137
169
|
hasHiddenLabel
|
|
138
170
|
onTimeChange={handleTimeChange}
|
|
171
|
+
isReadOnly={isReadOnly}
|
|
172
|
+
isDisabled={isDisabled}
|
|
173
|
+
tabIndex={timeTabIndex}
|
|
139
174
|
/>
|
|
140
175
|
</Col>
|
|
141
176
|
</Row>
|
|
@@ -22,6 +22,7 @@ export interface BaseInputProps {
|
|
|
22
22
|
isClearable?: boolean;
|
|
23
23
|
className?: string;
|
|
24
24
|
defaultValue?: string;
|
|
25
|
+
tabIndex?: number;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
export interface InputProps extends BaseInputProps, LabelProps {}
|
|
@@ -40,6 +41,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
40
41
|
helpText,
|
|
41
42
|
maxLength,
|
|
42
43
|
iconName,
|
|
44
|
+
tabIndex,
|
|
43
45
|
onChange,
|
|
44
46
|
onBlur,
|
|
45
47
|
onKeyDown,
|
|
@@ -71,6 +73,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
71
73
|
)}
|
|
72
74
|
<input
|
|
73
75
|
ref={ref}
|
|
76
|
+
tabIndex={tabIndex}
|
|
74
77
|
id={id}
|
|
75
78
|
data-testid={`form-input-${name}`}
|
|
76
79
|
name={name}
|
|
@@ -21,6 +21,7 @@ export interface TextareaProps extends LabelProps {
|
|
|
21
21
|
maxLength?: number;
|
|
22
22
|
autofocus?: boolean;
|
|
23
23
|
defaultValue?: string;
|
|
24
|
+
tabIndex?: number;
|
|
24
25
|
}
|
|
25
26
|
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
26
27
|
(
|
|
@@ -44,6 +45,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
44
45
|
maxLength,
|
|
45
46
|
autofocus,
|
|
46
47
|
defaultValue,
|
|
48
|
+
tabIndex,
|
|
47
49
|
...rest
|
|
48
50
|
},
|
|
49
51
|
ref,
|
|
@@ -76,6 +78,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
76
78
|
aria-required={isRequired}
|
|
77
79
|
value={value}
|
|
78
80
|
defaultValue={defaultValue}
|
|
81
|
+
tabIndex={tabIndex}
|
|
79
82
|
{...rest}
|
|
80
83
|
/>
|
|
81
84
|
</div>
|