@codecademy/gamut 68.6.2 → 68.6.3-alpha.57e1cd.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.
|
@@ -103,7 +103,8 @@ export const DatePicker = props => {
|
|
|
103
103
|
width: "fit-content",
|
|
104
104
|
children: mode === 'range' ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
105
105
|
children: [/*#__PURE__*/_jsx(DatePickerInput, {
|
|
106
|
-
|
|
106
|
+
description: props.startDateDescription,
|
|
107
|
+
name: "datePickerInput",
|
|
107
108
|
rangePart: "start",
|
|
108
109
|
size: inputSize
|
|
109
110
|
}), /*#__PURE__*/_jsx(Box, {
|
|
@@ -111,11 +112,13 @@ export const DatePicker = props => {
|
|
|
111
112
|
mt: 32,
|
|
112
113
|
children: isRtl ? /*#__PURE__*/_jsx(MiniArrowLeftIcon, {}) : /*#__PURE__*/_jsx(MiniArrowRightIcon, {})
|
|
113
114
|
}), /*#__PURE__*/_jsx(DatePickerInput, {
|
|
114
|
-
|
|
115
|
+
description: props.endDateDescription,
|
|
116
|
+
name: "datePickerInput",
|
|
115
117
|
rangePart: "end",
|
|
116
118
|
size: inputSize
|
|
117
119
|
})]
|
|
118
120
|
}) : /*#__PURE__*/_jsx(DatePickerInput, {
|
|
121
|
+
description: props.description,
|
|
119
122
|
size: inputSize
|
|
120
123
|
})
|
|
121
124
|
}), /*#__PURE__*/_jsx(PopoverContainer, {
|
|
@@ -126,6 +126,7 @@ export const CalendarBody = ({
|
|
|
126
126
|
children: /*#__PURE__*/_jsx("tr", {
|
|
127
127
|
children: weekdayLabels.map((label, i) => /*#__PURE__*/_jsx(TableHeader, {
|
|
128
128
|
abbr: weekdayFullNames[i],
|
|
129
|
+
"aria-label": weekdayFullNames[i],
|
|
129
130
|
scope: "col",
|
|
130
131
|
children: label
|
|
131
132
|
}, label))
|
|
@@ -2,8 +2,12 @@ import type { InputWrapperProps } from '../../Form/inputs/Input';
|
|
|
2
2
|
export type DatePickerInputProps = Omit<InputWrapperProps, 'className' | 'type' | 'icon' | 'value' | 'onChange' | 'color'> & {
|
|
3
3
|
/** In range mode: which part of the range this input edits. Omit for single-date or combined display. */
|
|
4
4
|
rangePart?: 'start' | 'end';
|
|
5
|
+
/** Description to display between the label and the input. */
|
|
6
|
+
description?: string;
|
|
5
7
|
};
|
|
6
8
|
export declare const DatePickerInput: import("react").ForwardRefExoticComponent<Omit<InputWrapperProps, "color" | "className" | "onChange" | "type" | "icon" | "value"> & {
|
|
7
9
|
/** In range mode: which part of the range this input edits. Omit for single-date or combined display. */
|
|
8
10
|
rangePart?: "start" | "end";
|
|
11
|
+
/** Description to display between the label and the input. */
|
|
12
|
+
description?: string;
|
|
9
13
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MiniCalendarIcon } from '@codecademy/gamut-icons';
|
|
2
2
|
import { forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { FlexBox } from '../../Box';
|
|
4
|
+
import { IconButton } from '../../Button';
|
|
4
5
|
import { FormGroup } from '../../Form/elements/FormGroup';
|
|
5
6
|
import { isSameDay } from '../DatePickerCalendar/Calendar/utils/dateGrid';
|
|
6
7
|
import { handleDateSelectRange } from '../DatePickerCalendar/utils/dateSelect';
|
|
@@ -19,6 +20,7 @@ export const DatePickerInput = /*#__PURE__*/forwardRef(({
|
|
|
19
20
|
name,
|
|
20
21
|
rangePart,
|
|
21
22
|
size = 'base',
|
|
23
|
+
description,
|
|
22
24
|
...rest
|
|
23
25
|
}, ref) => {
|
|
24
26
|
const context = useDatePicker();
|
|
@@ -144,7 +146,8 @@ export const DatePickerInput = /*#__PURE__*/forwardRef(({
|
|
|
144
146
|
focusCalendar();
|
|
145
147
|
}, [isCalendarOpen, openCalendar, focusCalendar]);
|
|
146
148
|
return /*#__PURE__*/_jsx(FormGroup, {
|
|
147
|
-
|
|
149
|
+
description: description,
|
|
150
|
+
id: inputId,
|
|
148
151
|
isSoloField: true,
|
|
149
152
|
label: label ?? defaultLabel,
|
|
150
153
|
mb: 0,
|
|
@@ -152,7 +155,7 @@ export const DatePickerInput = /*#__PURE__*/forwardRef(({
|
|
|
152
155
|
spacing: "tight",
|
|
153
156
|
width: "fit-content",
|
|
154
157
|
children: /*#__PURE__*/_jsxs(SegmentedShell, {
|
|
155
|
-
|
|
158
|
+
"aria-labelledby": inputId,
|
|
156
159
|
inputSize: size,
|
|
157
160
|
ref: shellRef,
|
|
158
161
|
role: "group",
|
|
@@ -199,16 +202,10 @@ export const DatePickerInput = /*#__PURE__*/forwardRef(({
|
|
|
199
202
|
tabIndex: -1,
|
|
200
203
|
type: "hidden",
|
|
201
204
|
value: hiddenValue
|
|
202
|
-
}), /*#__PURE__*/_jsx(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
pr: 8,
|
|
207
|
-
role: "presentation",
|
|
208
|
-
children: /*#__PURE__*/_jsx(MiniCalendarIcon, {
|
|
209
|
-
"aria-hidden": true,
|
|
210
|
-
size: 16
|
|
211
|
-
})
|
|
205
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
|
206
|
+
icon: MiniCalendarIcon,
|
|
207
|
+
size: "small",
|
|
208
|
+
tip: "Open calendar"
|
|
212
209
|
})]
|
|
213
210
|
})
|
|
214
211
|
});
|
|
@@ -92,6 +92,8 @@ export interface DatePickerSingleProps extends DatePickerBaseProps<'single'> {
|
|
|
92
92
|
* ```
|
|
93
93
|
*/
|
|
94
94
|
onSelected: (date: Date | null) => void;
|
|
95
|
+
/** Description to display between the label and the input. */
|
|
96
|
+
description?: string;
|
|
95
97
|
}
|
|
96
98
|
export interface DatePickerRangeProps extends DatePickerBaseProps<'range'> {
|
|
97
99
|
/** Controlled start date. Pass `null` to not have a default start date. Pass a `Date` to have a default start date.
|
|
@@ -159,6 +161,10 @@ export interface DatePickerRangeProps extends DatePickerBaseProps<'range'> {
|
|
|
159
161
|
* ```
|
|
160
162
|
*/
|
|
161
163
|
onEndSelected: (date: Date | null) => void;
|
|
164
|
+
/** Description to display between the label and the start date input. */
|
|
165
|
+
startDateDescription?: string;
|
|
166
|
+
/** Description to display between the label and the end date input. */
|
|
167
|
+
endDateDescription?: string;
|
|
162
168
|
}
|
|
163
169
|
export type DatePickerProps = DatePickerSingleProps | DatePickerRangeProps;
|
|
164
170
|
export {};
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/gamut",
|
|
3
3
|
"description": "Styleguide & Component library for Codecademy",
|
|
4
|
-
"version": "68.6.
|
|
4
|
+
"version": "68.6.3-alpha.57e1cd.0",
|
|
5
5
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@codecademy/gamut-icons": "9.57.
|
|
8
|
-
"@codecademy/gamut-illustrations": "0.58.
|
|
9
|
-
"@codecademy/gamut-patterns": "0.10.
|
|
10
|
-
"@codecademy/gamut-styles": "18.0.0",
|
|
11
|
-
"@codecademy/variance": "0.26.
|
|
7
|
+
"@codecademy/gamut-icons": "9.57.6-alpha.57e1cd.0",
|
|
8
|
+
"@codecademy/gamut-illustrations": "0.58.12-alpha.57e1cd.0",
|
|
9
|
+
"@codecademy/gamut-patterns": "0.10.31-alpha.57e1cd.0",
|
|
10
|
+
"@codecademy/gamut-styles": "18.0.1-alpha.57e1cd.0",
|
|
11
|
+
"@codecademy/variance": "0.26.2-alpha.57e1cd.0",
|
|
12
12
|
"@formatjs/intl-locale": "5.3.1",
|
|
13
13
|
"@react-aria/interactions": "3.25.0",
|
|
14
14
|
"@types/marked": "^4.0.8",
|