@guardian/stand 0.0.31 → 0.0.32
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/components/date-picker/DatePicker.cjs +166 -0
- package/dist/components/date-picker/DatePicker.js +126 -0
- package/dist/components/date-picker/styles.cjs +199 -0
- package/dist/components/date-picker/styles.js +187 -0
- package/dist/components/form/types.cjs +2 -1
- package/dist/components/form/types.js +3 -2
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.js +7 -1
- package/dist/date-picker.cjs +9 -0
- package/dist/date-picker.js +2 -0
- package/dist/index.cjs +2 -0
- package/dist/index.js +1 -0
- package/dist/styleD/build/css/component/datePicker.css +120 -0
- package/dist/styleD/build/css/component/templateComponent.css +8 -0
- package/dist/styleD/build/typescript/component/datePicker.cjs +185 -0
- package/dist/styleD/build/typescript/component/datePicker.js +183 -0
- package/dist/types/components/date-picker/DatePicker.d.ts +2 -0
- package/dist/types/components/date-picker/sandbox.d.ts +2 -0
- package/dist/types/components/date-picker/styles.d.ts +11 -0
- package/dist/types/components/date-picker/types.d.ts +21 -0
- package/dist/types/components/form/types.d.ts +1 -1
- package/dist/types/date-picker.d.ts +21 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/styleD/build/typescript/component/datePicker.d.ts +185 -0
- package/dist/types/styleD/build/typescript/component/templateComponent.d.ts +10 -0
- package/dist/types/templates/component/TemplateComponent.d.ts +2 -0
- package/dist/types/templates/component/sandbox.d.ts +5 -0
- package/dist/types/templates/component/styles.d.ts +7 -0
- package/dist/types/templates/component/types.d.ts +5 -0
- package/package.json +17 -2
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var reactAriaComponents = require('react-aria-components');
|
|
6
|
+
var mergeDeep = require('../../util/mergeDeep.cjs');
|
|
7
|
+
var Form = require('../form/Form.cjs');
|
|
8
|
+
var Icon = require('../icon/Icon.cjs');
|
|
9
|
+
var styles = require('./styles.cjs');
|
|
10
|
+
|
|
11
|
+
const MONTHS = [
|
|
12
|
+
"January",
|
|
13
|
+
"February",
|
|
14
|
+
"March",
|
|
15
|
+
"April",
|
|
16
|
+
"May",
|
|
17
|
+
"June",
|
|
18
|
+
"July",
|
|
19
|
+
"August",
|
|
20
|
+
"September",
|
|
21
|
+
"October",
|
|
22
|
+
"November",
|
|
23
|
+
"December"
|
|
24
|
+
];
|
|
25
|
+
const SEGMENT_PLACEHOLDERS = {
|
|
26
|
+
day: "DD",
|
|
27
|
+
month: "MMMM",
|
|
28
|
+
year: "YYYY"
|
|
29
|
+
};
|
|
30
|
+
const CLEAR_BUFFER_DELAY_MS = 1e3;
|
|
31
|
+
const MonthTextInputContext = React.createContext(true);
|
|
32
|
+
function DateSegment(props) {
|
|
33
|
+
const useMonthTextInput = React.useContext(MonthTextInputContext);
|
|
34
|
+
const state = React.useContext(reactAriaComponents.DateFieldStateContext);
|
|
35
|
+
const stateRef = React.useRef(state);
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
stateRef.current = state;
|
|
38
|
+
});
|
|
39
|
+
const bufferRef = React.useRef("");
|
|
40
|
+
const clearTimerRef = React.useRef(null);
|
|
41
|
+
const segmentRef = React.useRef(null);
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
if (!useMonthTextInput || props.segment.type !== "month") {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const el = segmentRef.current;
|
|
47
|
+
if (!el) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const handleKeyDown = (e) => {
|
|
51
|
+
const currentState = stateRef.current;
|
|
52
|
+
if (!currentState || !/^[a-zA-Z]$/.test(e.key)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
if (clearTimerRef.current) {
|
|
58
|
+
clearTimeout(clearTimerRef.current);
|
|
59
|
+
}
|
|
60
|
+
bufferRef.current += e.key.toLowerCase();
|
|
61
|
+
const match = MONTHS.findIndex(
|
|
62
|
+
(m) => m.toLowerCase().startsWith(bufferRef.current)
|
|
63
|
+
);
|
|
64
|
+
if (match !== -1) {
|
|
65
|
+
currentState.setSegment("month", match + 1);
|
|
66
|
+
const uniqueMatch = MONTHS.filter((m) => m.toLowerCase().startsWith(bufferRef.current)).length === 1;
|
|
67
|
+
if (uniqueMatch) {
|
|
68
|
+
bufferRef.current = "";
|
|
69
|
+
if (clearTimerRef.current) {
|
|
70
|
+
clearTimeout(clearTimerRef.current);
|
|
71
|
+
}
|
|
72
|
+
const yearSegment = el.parentElement?.querySelector('[data-type="year"]');
|
|
73
|
+
yearSegment?.focus();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
clearTimerRef.current = setTimeout(() => {
|
|
77
|
+
bufferRef.current = "";
|
|
78
|
+
}, CLEAR_BUFFER_DELAY_MS);
|
|
79
|
+
};
|
|
80
|
+
el.addEventListener("keydown", handleKeyDown, true);
|
|
81
|
+
return () => {
|
|
82
|
+
el.removeEventListener("keydown", handleKeyDown, true);
|
|
83
|
+
if (clearTimerRef.current) {
|
|
84
|
+
clearTimeout(clearTimerRef.current);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}, [props.segment.type, useMonthTextInput]);
|
|
88
|
+
if (useMonthTextInput && props.segment.type === "literal") {
|
|
89
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: " " });
|
|
90
|
+
}
|
|
91
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.DateSegment, { ...props, ref: segmentRef, children: (renderProps) => {
|
|
92
|
+
if (useMonthTextInput && renderProps.type === "month" && renderProps.value != null) {
|
|
93
|
+
return MONTHS[renderProps.value - 1];
|
|
94
|
+
}
|
|
95
|
+
if (useMonthTextInput && renderProps.isPlaceholder && renderProps.type in SEGMENT_PLACEHOLDERS) {
|
|
96
|
+
return SEGMENT_PLACEHOLDERS[renderProps.type];
|
|
97
|
+
}
|
|
98
|
+
return renderProps.text;
|
|
99
|
+
} });
|
|
100
|
+
}
|
|
101
|
+
function DateInput(props) {
|
|
102
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.DateInput, { ...props });
|
|
103
|
+
}
|
|
104
|
+
function CalendarCell(props) {
|
|
105
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.CalendarCell, { ...props });
|
|
106
|
+
}
|
|
107
|
+
function CalendarGrid(props) {
|
|
108
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.CalendarGrid, { ...props });
|
|
109
|
+
}
|
|
110
|
+
function Calendar({ theme = {}, ...props }) {
|
|
111
|
+
const mergedTheme = mergeDeep.mergeDeep(styles.defaultDatePickerTheme, theme);
|
|
112
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactAriaComponents.Calendar, { ...props, children: [
|
|
113
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { css: styles.calendarHeaderStyles(mergedTheme), children: [
|
|
114
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Button, { slot: "previous", "aria-label": "Previous Month", children: /* @__PURE__ */ jsxRuntime.jsx(Icon.Icon, { symbol: "chevron_left", size: "lg" }) }),
|
|
115
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Heading, {}),
|
|
116
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Button, { slot: "next", "aria-label": "Next Month", children: /* @__PURE__ */ jsxRuntime.jsx(Icon.Icon, { symbol: "chevron_right", size: "lg" }) })
|
|
117
|
+
] }),
|
|
118
|
+
/* @__PURE__ */ jsxRuntime.jsx(CalendarGrid, { css: styles.calendarGridStyles(mergedTheme), children: (date) => /* @__PURE__ */ jsxRuntime.jsx(CalendarCell, { css: styles.calendarCellStyles(mergedTheme), date }) })
|
|
119
|
+
] });
|
|
120
|
+
}
|
|
121
|
+
function DatePicker({
|
|
122
|
+
isInvalid,
|
|
123
|
+
locale = "en-GB",
|
|
124
|
+
useMonthTextInput = true,
|
|
125
|
+
theme = {},
|
|
126
|
+
...props
|
|
127
|
+
}) {
|
|
128
|
+
const mergedTheme = mergeDeep.mergeDeep(styles.defaultDatePickerTheme, theme);
|
|
129
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
130
|
+
Form.FormInputContainer,
|
|
131
|
+
{
|
|
132
|
+
as: reactAriaComponents.DatePicker,
|
|
133
|
+
isInvalid,
|
|
134
|
+
firstDayOfWeek: "mon",
|
|
135
|
+
shouldForceLeadingZeros: true,
|
|
136
|
+
...props,
|
|
137
|
+
size: "md",
|
|
138
|
+
granularity: "day",
|
|
139
|
+
hideTimeZone: true,
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactAriaComponents.Group, { css: styles.datePickerStyles(mergedTheme), children: [
|
|
142
|
+
/* @__PURE__ */ jsxRuntime.jsx(MonthTextInputContext.Provider, { value: useMonthTextInput, children: /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.I18nProvider, { locale, children: /* @__PURE__ */ jsxRuntime.jsx(DateInput, { children: (segment) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
143
|
+
DateSegment,
|
|
144
|
+
{
|
|
145
|
+
css: styles.dateSegmentStyles(mergedTheme),
|
|
146
|
+
segment
|
|
147
|
+
}
|
|
148
|
+
) }) }) }),
|
|
149
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Button, { "aria-label": "Open Date Picker", children: /* @__PURE__ */ jsxRuntime.jsx(Icon.Icon, { symbol: "calendar_month", size: "lg" }) })
|
|
150
|
+
] }),
|
|
151
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
152
|
+
reactAriaComponents.Popover,
|
|
153
|
+
{
|
|
154
|
+
css: styles.datePickerPopoverStyles(mergedTheme),
|
|
155
|
+
offset: mergedTheme.popover.shared.offset,
|
|
156
|
+
containerPadding: mergedTheme.popover.shared.containerPadding,
|
|
157
|
+
shouldFlip: false,
|
|
158
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Calendar, { theme: mergedTheme })
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
exports.DatePicker = DatePicker;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import { createContext, useContext, useRef, useEffect } from 'react';
|
|
3
|
+
import { DatePicker as DatePicker$1, Group, I18nProvider, Button, Popover, DateInput as DateInput$1, DateFieldStateContext, DateSegment as DateSegment$1, Calendar as Calendar$1, Heading, CalendarGrid as CalendarGrid$1, CalendarCell as CalendarCell$1 } from 'react-aria-components';
|
|
4
|
+
import { mergeDeep } from '../../util/mergeDeep.js';
|
|
5
|
+
import { FormInputContainer } from '../form/Form.js';
|
|
6
|
+
import { Icon } from '../icon/Icon.js';
|
|
7
|
+
import { dateSegmentStyles, datePickerStyles, datePickerPopoverStyles, defaultDatePickerTheme, calendarHeaderStyles, calendarCellStyles, calendarGridStyles } from './styles.js';
|
|
8
|
+
|
|
9
|
+
const MONTHS = [
|
|
10
|
+
"January",
|
|
11
|
+
"February",
|
|
12
|
+
"March",
|
|
13
|
+
"April",
|
|
14
|
+
"May",
|
|
15
|
+
"June",
|
|
16
|
+
"July",
|
|
17
|
+
"August",
|
|
18
|
+
"September",
|
|
19
|
+
"October",
|
|
20
|
+
"November",
|
|
21
|
+
"December"
|
|
22
|
+
];
|
|
23
|
+
const SEGMENT_PLACEHOLDERS = {
|
|
24
|
+
day: "DD",
|
|
25
|
+
month: "MMMM",
|
|
26
|
+
year: "YYYY"
|
|
27
|
+
};
|
|
28
|
+
const CLEAR_BUFFER_DELAY_MS = 1e3;
|
|
29
|
+
const MonthTextInputContext = createContext(true);
|
|
30
|
+
function DateSegment(props) {
|
|
31
|
+
const useMonthTextInput = useContext(MonthTextInputContext);
|
|
32
|
+
const state = useContext(DateFieldStateContext);
|
|
33
|
+
const stateRef = useRef(state);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
stateRef.current = state;
|
|
36
|
+
});
|
|
37
|
+
const bufferRef = useRef("");
|
|
38
|
+
const clearTimerRef = useRef(null);
|
|
39
|
+
const segmentRef = useRef(null);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!useMonthTextInput || props.segment.type !== "month") {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const el = segmentRef.current;
|
|
45
|
+
if (!el) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const handleKeyDown = (e) => {
|
|
49
|
+
const currentState = stateRef.current;
|
|
50
|
+
if (!currentState || !/^[a-zA-Z]$/.test(e.key)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
e.stopPropagation();
|
|
55
|
+
if (clearTimerRef.current) {
|
|
56
|
+
clearTimeout(clearTimerRef.current);
|
|
57
|
+
}
|
|
58
|
+
bufferRef.current += e.key.toLowerCase();
|
|
59
|
+
const match = MONTHS.findIndex((m) => m.toLowerCase().startsWith(bufferRef.current));
|
|
60
|
+
if (match !== -1) {
|
|
61
|
+
currentState.setSegment("month", match + 1);
|
|
62
|
+
const uniqueMatch = MONTHS.filter((m) => m.toLowerCase().startsWith(bufferRef.current)).length === 1;
|
|
63
|
+
if (uniqueMatch) {
|
|
64
|
+
bufferRef.current = "";
|
|
65
|
+
if (clearTimerRef.current) {
|
|
66
|
+
clearTimeout(clearTimerRef.current);
|
|
67
|
+
}
|
|
68
|
+
const yearSegment = el.parentElement?.querySelector('[data-type="year"]');
|
|
69
|
+
yearSegment?.focus();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
clearTimerRef.current = setTimeout(() => {
|
|
73
|
+
bufferRef.current = "";
|
|
74
|
+
}, CLEAR_BUFFER_DELAY_MS);
|
|
75
|
+
};
|
|
76
|
+
el.addEventListener("keydown", handleKeyDown, true);
|
|
77
|
+
return () => {
|
|
78
|
+
el.removeEventListener("keydown", handleKeyDown, true);
|
|
79
|
+
if (clearTimerRef.current) {
|
|
80
|
+
clearTimeout(clearTimerRef.current);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}, [props.segment.type, useMonthTextInput]);
|
|
84
|
+
if (useMonthTextInput && props.segment.type === "literal") {
|
|
85
|
+
return jsx("span", { "aria-hidden": "true", children: " " });
|
|
86
|
+
}
|
|
87
|
+
return jsx(DateSegment$1, { ...props, ref: segmentRef, children: (renderProps) => {
|
|
88
|
+
if (useMonthTextInput && renderProps.type === "month" && renderProps.value != null) {
|
|
89
|
+
return MONTHS[renderProps.value - 1];
|
|
90
|
+
}
|
|
91
|
+
if (useMonthTextInput && renderProps.isPlaceholder && renderProps.type in SEGMENT_PLACEHOLDERS) {
|
|
92
|
+
return SEGMENT_PLACEHOLDERS[renderProps.type];
|
|
93
|
+
}
|
|
94
|
+
return renderProps.text;
|
|
95
|
+
} });
|
|
96
|
+
}
|
|
97
|
+
function DateInput(props) {
|
|
98
|
+
return jsx(DateInput$1, { ...props });
|
|
99
|
+
}
|
|
100
|
+
function CalendarCell(props) {
|
|
101
|
+
return jsx(CalendarCell$1, { ...props });
|
|
102
|
+
}
|
|
103
|
+
function CalendarGrid(props) {
|
|
104
|
+
return jsx(CalendarGrid$1, { ...props });
|
|
105
|
+
}
|
|
106
|
+
function Calendar({ theme = {}, ...props }) {
|
|
107
|
+
const mergedTheme = mergeDeep(defaultDatePickerTheme, theme);
|
|
108
|
+
return jsxs(Calendar$1, { ...props, children: [jsxs("header", { css: calendarHeaderStyles(mergedTheme), children: [jsx(Button, { slot: "previous", "aria-label": "Previous Month", children: jsx(Icon, { symbol: "chevron_left", size: "lg" }) }), jsx(Heading, {}), jsx(Button, { slot: "next", "aria-label": "Next Month", children: jsx(Icon, { symbol: "chevron_right", size: "lg" }) })] }), jsx(CalendarGrid, { css: calendarGridStyles(mergedTheme), children: (date) => jsx(CalendarCell, { css: calendarCellStyles(mergedTheme), date }) })] });
|
|
109
|
+
}
|
|
110
|
+
function DatePicker({ isInvalid, locale = "en-GB", useMonthTextInput = true, theme = {}, ...props }) {
|
|
111
|
+
const mergedTheme = mergeDeep(defaultDatePickerTheme, theme);
|
|
112
|
+
return jsxs(FormInputContainer, {
|
|
113
|
+
as: DatePicker$1,
|
|
114
|
+
isInvalid,
|
|
115
|
+
// set default values for specific props that shouldn't depend on users locale, and should only be explicitly overridden if needed
|
|
116
|
+
firstDayOfWeek: "mon",
|
|
117
|
+
shouldForceLeadingZeros: true,
|
|
118
|
+
...props,
|
|
119
|
+
size: "md",
|
|
120
|
+
granularity: "day",
|
|
121
|
+
hideTimeZone: true,
|
|
122
|
+
children: [jsxs(Group, { css: datePickerStyles(mergedTheme), children: [jsx(MonthTextInputContext.Provider, { value: useMonthTextInput, children: jsx(I18nProvider, { locale, children: jsx(DateInput, { children: (segment) => jsx(DateSegment, { css: dateSegmentStyles(mergedTheme), segment }) }) }) }), jsx(Button, { "aria-label": "Open Date Picker", children: jsx(Icon, { symbol: "calendar_month", size: "lg" }) })] }), jsx(Popover, { css: datePickerPopoverStyles(mergedTheme), offset: mergedTheme.popover.shared.offset, containerPadding: mergedTheme.popover.shared.containerPadding, shouldFlip: false, children: jsx(Calendar, { theme: mergedTheme }) })]
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { DatePicker };
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('@emotion/react');
|
|
4
|
+
var datePicker = require('../../styleD/build/typescript/component/datePicker.cjs');
|
|
5
|
+
var typography = require('../../styleD/utils/semantic/typography.cjs');
|
|
6
|
+
|
|
7
|
+
const defaultDatePickerTheme = datePicker.componentDatePicker;
|
|
8
|
+
const datePickerStyles = (theme) => {
|
|
9
|
+
return react.css`
|
|
10
|
+
display: ${theme.picker.shared.display};
|
|
11
|
+
width: ${theme.picker.shared.width};
|
|
12
|
+
justify-content: ${theme.picker.shared.justifyContent};
|
|
13
|
+
align-items: ${theme.picker.shared.alignItems};
|
|
14
|
+
height: ${theme.picker.shared.height};
|
|
15
|
+
border-radius: ${theme.picker.shared.borderRadius};
|
|
16
|
+
border: ${theme.picker.shared.border};
|
|
17
|
+
background-color: ${theme.picker.shared.backgroundColor};
|
|
18
|
+
gap: ${theme.picker.shared.gap};
|
|
19
|
+
padding-left: ${theme.picker.shared.padding.left};
|
|
20
|
+
padding-right: ${theme.picker.shared.padding.right};
|
|
21
|
+
padding-top: ${theme.picker.shared.padding.top};
|
|
22
|
+
padding-bottom: ${theme.picker.shared.padding.bottom};
|
|
23
|
+
|
|
24
|
+
button {
|
|
25
|
+
flex: ${theme.picker.shared.button.flex};
|
|
26
|
+
background-color: ${theme.picker.shared.button.backgroundColor};
|
|
27
|
+
border: ${theme.picker.shared.button.border};
|
|
28
|
+
padding-left: ${theme.picker.shared.button.padding.left};
|
|
29
|
+
padding-right: ${theme.picker.shared.button.padding.right};
|
|
30
|
+
padding-top: ${theme.picker.shared.button.padding.top};
|
|
31
|
+
padding-bottom: ${theme.picker.shared.button.padding.bottom};
|
|
32
|
+
margin-left: ${theme.picker.shared.button.margin.left};
|
|
33
|
+
margin-right: ${theme.picker.shared.button.margin.right};
|
|
34
|
+
margin-top: ${theme.picker.shared.button.margin.top};
|
|
35
|
+
margin-bottom: ${theme.picker.shared.button.margin.bottom};
|
|
36
|
+
display: ${theme.picker.shared.button.display};
|
|
37
|
+
align-items: ${theme.picker.shared.button.alignItems};
|
|
38
|
+
justify-content: ${theme.picker.shared.button.justifyContent};
|
|
39
|
+
color: ${theme.picker.shared.button.color};
|
|
40
|
+
cursor: ${theme.picker.shared.button.cursor};
|
|
41
|
+
|
|
42
|
+
&[data-disabled] {
|
|
43
|
+
cursor: ${theme.picker.shared.button.disabled.cursor};
|
|
44
|
+
color: ${theme.picker.shared.button.disabled.color};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&[data-focus-visible] {
|
|
48
|
+
outline: ${theme.picker.shared.focusVisible.outline};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&[data-invalid] {
|
|
53
|
+
border: ${theme.picker.shared.invalid.border};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&[data-disabled] {
|
|
57
|
+
cursor: ${theme.picker.shared.disabled.cursor};
|
|
58
|
+
color: ${theme.picker.shared.disabled.color};
|
|
59
|
+
background-color: ${theme.picker.shared.disabled.backgroundColor};
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
};
|
|
63
|
+
const dateSegmentStyles = (theme) => {
|
|
64
|
+
return react.css`
|
|
65
|
+
&[data-placeholder] {
|
|
66
|
+
color: ${theme.segment.shared.placeholder.color};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&[data-focus-visible],
|
|
70
|
+
&[data-focused] {
|
|
71
|
+
outline: ${theme.segment.shared.placeholder.focusVisible.outline};
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
};
|
|
75
|
+
const datePickerPopoverStyles = (theme) => {
|
|
76
|
+
return react.css`
|
|
77
|
+
background-color: ${theme.popover.shared.backgroundColor};
|
|
78
|
+
padding: ${theme.popover.shared.padding.top}
|
|
79
|
+
${theme.popover.shared.padding.right}
|
|
80
|
+
${theme.popover.shared.padding.bottom}
|
|
81
|
+
${theme.popover.shared.padding.left};
|
|
82
|
+
box-shadow: ${theme.popover.shared.boxShadow};
|
|
83
|
+
`;
|
|
84
|
+
};
|
|
85
|
+
const calendarHeaderStyles = (theme) => {
|
|
86
|
+
return react.css`
|
|
87
|
+
display: ${theme.calendar.header.shared.display};
|
|
88
|
+
align-items: ${theme.calendar.header.shared.alignItems};
|
|
89
|
+
justify-content: ${theme.calendar.header.shared.justifyContent};
|
|
90
|
+
${typography.convertTypographyToEmotionStringStyle(
|
|
91
|
+
theme.calendar.header.shared.typography
|
|
92
|
+
)}
|
|
93
|
+
|
|
94
|
+
button {
|
|
95
|
+
background-color: ${theme.calendar.header.shared.button.backgroundColor};
|
|
96
|
+
border: ${theme.calendar.header.shared.button.border};
|
|
97
|
+
padding: ${theme.calendar.header.shared.button.padding.top}
|
|
98
|
+
${theme.calendar.header.shared.button.padding.right}
|
|
99
|
+
${theme.calendar.header.shared.button.padding.bottom}
|
|
100
|
+
${theme.calendar.header.shared.button.padding.left};
|
|
101
|
+
margin: ${theme.calendar.header.shared.button.margin.top}
|
|
102
|
+
${theme.calendar.header.shared.button.margin.right}
|
|
103
|
+
${theme.calendar.header.shared.button.margin.bottom}
|
|
104
|
+
${theme.calendar.header.shared.button.margin.left};
|
|
105
|
+
display: ${theme.calendar.header.shared.button.display};
|
|
106
|
+
align-items: ${theme.calendar.header.shared.button.alignItems};
|
|
107
|
+
justify-content: ${theme.calendar.header.shared.button.justifyContent};
|
|
108
|
+
color: ${theme.calendar.header.shared.button.color};
|
|
109
|
+
cursor: ${theme.calendar.header.shared.button.cursor};
|
|
110
|
+
width: ${theme.calendar.header.shared.button.width};
|
|
111
|
+
height: ${theme.calendar.header.shared.button.height};
|
|
112
|
+
aspect-ratio: ${theme.calendar.header.shared.button.aspectRatio};
|
|
113
|
+
|
|
114
|
+
&[data-hovered] {
|
|
115
|
+
background-color: ${theme.calendar.header.shared.button.hovered.backgroundColor};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&[data-pressed] {
|
|
119
|
+
background-color: ${theme.calendar.header.shared.button.pressed.backgroundColor};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&[data-selected] {
|
|
123
|
+
background-color: ${theme.calendar.header.shared.button.selected.backgroundColor};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&[data-focus-visible] {
|
|
127
|
+
outline: ${theme.calendar.header.shared.button.focusVisible.outline};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&[data-disabled] {
|
|
131
|
+
cursor: ${theme.calendar.header.shared.button.disabled.cursor};
|
|
132
|
+
color: ${theme.calendar.header.shared.button.disabled.color};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
};
|
|
137
|
+
const calendarGridStyles = (theme) => {
|
|
138
|
+
return react.css`
|
|
139
|
+
${typography.convertTypographyToEmotionStringStyle(
|
|
140
|
+
theme.calendar.grid.shared.typography
|
|
141
|
+
)}
|
|
142
|
+
|
|
143
|
+
border-collapse: ${theme.calendar.grid.shared.borderCollapse};
|
|
144
|
+
border-spacing: ${theme.calendar.grid.shared.borderSpacing};
|
|
145
|
+
|
|
146
|
+
th {
|
|
147
|
+
width: ${theme.calendar.grid.shared.th.width};
|
|
148
|
+
height: ${theme.calendar.grid.shared.th.height};
|
|
149
|
+
vertical-align: ${theme.calendar.grid.shared.th.verticalAlign};
|
|
150
|
+
}
|
|
151
|
+
`;
|
|
152
|
+
};
|
|
153
|
+
const calendarCellStyles = (theme) => {
|
|
154
|
+
return react.css`
|
|
155
|
+
width: ${theme.calendar.cell.shared.width};
|
|
156
|
+
aspect-ratio: ${theme.calendar.cell.shared.aspectRatio};
|
|
157
|
+
display: ${theme.calendar.cell.shared.display};
|
|
158
|
+
align-items: ${theme.calendar.cell.shared.alignItems};
|
|
159
|
+
justify-content: ${theme.calendar.cell.shared.justifyContent};
|
|
160
|
+
cursor: ${theme.calendar.cell.shared.cursor};
|
|
161
|
+
|
|
162
|
+
&[data-outside-month] {
|
|
163
|
+
display: ${theme.calendar.cell.shared.outsideMonth.display};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
&[data-hovered] {
|
|
167
|
+
background-color: ${theme.calendar.cell.shared.hovered.backgroundColor};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
&[data-pressed] {
|
|
171
|
+
background-color: ${theme.calendar.cell.shared.pressed.backgroundColor};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
&[data-selected] {
|
|
175
|
+
background-color: ${theme.calendar.cell.shared.selected.backgroundColor};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
&[data-focus-visible] {
|
|
179
|
+
outline: ${theme.calendar.cell.shared.focusVisible.outline};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
&[data-today] {
|
|
183
|
+
/* TODO: design for indicating today's date, not yet in figma */
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
&[data-disabled] {
|
|
187
|
+
cursor: ${theme.calendar.cell.shared.disabled.cursor};
|
|
188
|
+
color: ${theme.calendar.cell.shared.disabled.color};
|
|
189
|
+
}
|
|
190
|
+
`;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
exports.calendarCellStyles = calendarCellStyles;
|
|
194
|
+
exports.calendarGridStyles = calendarGridStyles;
|
|
195
|
+
exports.calendarHeaderStyles = calendarHeaderStyles;
|
|
196
|
+
exports.datePickerPopoverStyles = datePickerPopoverStyles;
|
|
197
|
+
exports.datePickerStyles = datePickerStyles;
|
|
198
|
+
exports.dateSegmentStyles = dateSegmentStyles;
|
|
199
|
+
exports.defaultDatePickerTheme = defaultDatePickerTheme;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { componentDatePicker } from '../../styleD/build/typescript/component/datePicker.js';
|
|
3
|
+
import { convertTypographyToEmotionStringStyle } from '../../styleD/utils/semantic/typography.js';
|
|
4
|
+
|
|
5
|
+
const defaultDatePickerTheme = componentDatePicker;
|
|
6
|
+
const datePickerStyles = (theme) => {
|
|
7
|
+
return css`
|
|
8
|
+
display: ${theme.picker.shared.display};
|
|
9
|
+
width: ${theme.picker.shared.width};
|
|
10
|
+
justify-content: ${theme.picker.shared.justifyContent};
|
|
11
|
+
align-items: ${theme.picker.shared.alignItems};
|
|
12
|
+
height: ${theme.picker.shared.height};
|
|
13
|
+
border-radius: ${theme.picker.shared.borderRadius};
|
|
14
|
+
border: ${theme.picker.shared.border};
|
|
15
|
+
background-color: ${theme.picker.shared.backgroundColor};
|
|
16
|
+
gap: ${theme.picker.shared.gap};
|
|
17
|
+
padding-left: ${theme.picker.shared.padding.left};
|
|
18
|
+
padding-right: ${theme.picker.shared.padding.right};
|
|
19
|
+
padding-top: ${theme.picker.shared.padding.top};
|
|
20
|
+
padding-bottom: ${theme.picker.shared.padding.bottom};
|
|
21
|
+
|
|
22
|
+
button {
|
|
23
|
+
flex: ${theme.picker.shared.button.flex};
|
|
24
|
+
background-color: ${theme.picker.shared.button.backgroundColor};
|
|
25
|
+
border: ${theme.picker.shared.button.border};
|
|
26
|
+
padding-left: ${theme.picker.shared.button.padding.left};
|
|
27
|
+
padding-right: ${theme.picker.shared.button.padding.right};
|
|
28
|
+
padding-top: ${theme.picker.shared.button.padding.top};
|
|
29
|
+
padding-bottom: ${theme.picker.shared.button.padding.bottom};
|
|
30
|
+
margin-left: ${theme.picker.shared.button.margin.left};
|
|
31
|
+
margin-right: ${theme.picker.shared.button.margin.right};
|
|
32
|
+
margin-top: ${theme.picker.shared.button.margin.top};
|
|
33
|
+
margin-bottom: ${theme.picker.shared.button.margin.bottom};
|
|
34
|
+
display: ${theme.picker.shared.button.display};
|
|
35
|
+
align-items: ${theme.picker.shared.button.alignItems};
|
|
36
|
+
justify-content: ${theme.picker.shared.button.justifyContent};
|
|
37
|
+
color: ${theme.picker.shared.button.color};
|
|
38
|
+
cursor: ${theme.picker.shared.button.cursor};
|
|
39
|
+
|
|
40
|
+
&[data-disabled] {
|
|
41
|
+
cursor: ${theme.picker.shared.button.disabled.cursor};
|
|
42
|
+
color: ${theme.picker.shared.button.disabled.color};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&[data-focus-visible] {
|
|
46
|
+
outline: ${theme.picker.shared.focusVisible.outline};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&[data-invalid] {
|
|
51
|
+
border: ${theme.picker.shared.invalid.border};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&[data-disabled] {
|
|
55
|
+
cursor: ${theme.picker.shared.disabled.cursor};
|
|
56
|
+
color: ${theme.picker.shared.disabled.color};
|
|
57
|
+
background-color: ${theme.picker.shared.disabled.backgroundColor};
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
};
|
|
61
|
+
const dateSegmentStyles = (theme) => {
|
|
62
|
+
return css`
|
|
63
|
+
&[data-placeholder] {
|
|
64
|
+
color: ${theme.segment.shared.placeholder.color};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&[data-focus-visible],
|
|
68
|
+
&[data-focused] {
|
|
69
|
+
outline: ${theme.segment.shared.placeholder.focusVisible.outline};
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
};
|
|
73
|
+
const datePickerPopoverStyles = (theme) => {
|
|
74
|
+
return css`
|
|
75
|
+
background-color: ${theme.popover.shared.backgroundColor};
|
|
76
|
+
padding: ${theme.popover.shared.padding.top}
|
|
77
|
+
${theme.popover.shared.padding.right}
|
|
78
|
+
${theme.popover.shared.padding.bottom}
|
|
79
|
+
${theme.popover.shared.padding.left};
|
|
80
|
+
box-shadow: ${theme.popover.shared.boxShadow};
|
|
81
|
+
`;
|
|
82
|
+
};
|
|
83
|
+
const calendarHeaderStyles = (theme) => {
|
|
84
|
+
return css`
|
|
85
|
+
display: ${theme.calendar.header.shared.display};
|
|
86
|
+
align-items: ${theme.calendar.header.shared.alignItems};
|
|
87
|
+
justify-content: ${theme.calendar.header.shared.justifyContent};
|
|
88
|
+
${convertTypographyToEmotionStringStyle(theme.calendar.header.shared.typography)}
|
|
89
|
+
|
|
90
|
+
button {
|
|
91
|
+
background-color: ${theme.calendar.header.shared.button.backgroundColor};
|
|
92
|
+
border: ${theme.calendar.header.shared.button.border};
|
|
93
|
+
padding: ${theme.calendar.header.shared.button.padding.top}
|
|
94
|
+
${theme.calendar.header.shared.button.padding.right}
|
|
95
|
+
${theme.calendar.header.shared.button.padding.bottom}
|
|
96
|
+
${theme.calendar.header.shared.button.padding.left};
|
|
97
|
+
margin: ${theme.calendar.header.shared.button.margin.top}
|
|
98
|
+
${theme.calendar.header.shared.button.margin.right}
|
|
99
|
+
${theme.calendar.header.shared.button.margin.bottom}
|
|
100
|
+
${theme.calendar.header.shared.button.margin.left};
|
|
101
|
+
display: ${theme.calendar.header.shared.button.display};
|
|
102
|
+
align-items: ${theme.calendar.header.shared.button.alignItems};
|
|
103
|
+
justify-content: ${theme.calendar.header.shared.button.justifyContent};
|
|
104
|
+
color: ${theme.calendar.header.shared.button.color};
|
|
105
|
+
cursor: ${theme.calendar.header.shared.button.cursor};
|
|
106
|
+
width: ${theme.calendar.header.shared.button.width};
|
|
107
|
+
height: ${theme.calendar.header.shared.button.height};
|
|
108
|
+
aspect-ratio: ${theme.calendar.header.shared.button.aspectRatio};
|
|
109
|
+
|
|
110
|
+
&[data-hovered] {
|
|
111
|
+
background-color: ${theme.calendar.header.shared.button.hovered.backgroundColor};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&[data-pressed] {
|
|
115
|
+
background-color: ${theme.calendar.header.shared.button.pressed.backgroundColor};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&[data-selected] {
|
|
119
|
+
background-color: ${theme.calendar.header.shared.button.selected.backgroundColor};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&[data-focus-visible] {
|
|
123
|
+
outline: ${theme.calendar.header.shared.button.focusVisible.outline};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&[data-disabled] {
|
|
127
|
+
cursor: ${theme.calendar.header.shared.button.disabled.cursor};
|
|
128
|
+
color: ${theme.calendar.header.shared.button.disabled.color};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
`;
|
|
132
|
+
};
|
|
133
|
+
const calendarGridStyles = (theme) => {
|
|
134
|
+
return css`
|
|
135
|
+
${convertTypographyToEmotionStringStyle(theme.calendar.grid.shared.typography)}
|
|
136
|
+
|
|
137
|
+
border-collapse: ${theme.calendar.grid.shared.borderCollapse};
|
|
138
|
+
border-spacing: ${theme.calendar.grid.shared.borderSpacing};
|
|
139
|
+
|
|
140
|
+
th {
|
|
141
|
+
width: ${theme.calendar.grid.shared.th.width};
|
|
142
|
+
height: ${theme.calendar.grid.shared.th.height};
|
|
143
|
+
vertical-align: ${theme.calendar.grid.shared.th.verticalAlign};
|
|
144
|
+
}
|
|
145
|
+
`;
|
|
146
|
+
};
|
|
147
|
+
const calendarCellStyles = (theme) => {
|
|
148
|
+
return css`
|
|
149
|
+
width: ${theme.calendar.cell.shared.width};
|
|
150
|
+
aspect-ratio: ${theme.calendar.cell.shared.aspectRatio};
|
|
151
|
+
display: ${theme.calendar.cell.shared.display};
|
|
152
|
+
align-items: ${theme.calendar.cell.shared.alignItems};
|
|
153
|
+
justify-content: ${theme.calendar.cell.shared.justifyContent};
|
|
154
|
+
cursor: ${theme.calendar.cell.shared.cursor};
|
|
155
|
+
|
|
156
|
+
&[data-outside-month] {
|
|
157
|
+
display: ${theme.calendar.cell.shared.outsideMonth.display};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&[data-hovered] {
|
|
161
|
+
background-color: ${theme.calendar.cell.shared.hovered.backgroundColor};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&[data-pressed] {
|
|
165
|
+
background-color: ${theme.calendar.cell.shared.pressed.backgroundColor};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
&[data-selected] {
|
|
169
|
+
background-color: ${theme.calendar.cell.shared.selected.backgroundColor};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
&[data-focus-visible] {
|
|
173
|
+
outline: ${theme.calendar.cell.shared.focusVisible.outline};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&[data-today] {
|
|
177
|
+
/* TODO: design for indicating today's date, not yet in figma */
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
&[data-disabled] {
|
|
181
|
+
cursor: ${theme.calendar.cell.shared.disabled.cursor};
|
|
182
|
+
color: ${theme.calendar.cell.shared.disabled.color};
|
|
183
|
+
}
|
|
184
|
+
`;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export { calendarCellStyles, calendarGridStyles, calendarHeaderStyles, datePickerPopoverStyles, datePickerStyles, dateSegmentStyles, defaultDatePickerTheme };
|
|
@@ -6,7 +6,8 @@ const ALLOWED_FORM_CONTAINERS = [
|
|
|
6
6
|
reactAriaComponents.TextField,
|
|
7
7
|
reactAriaComponents.Select,
|
|
8
8
|
reactAriaComponents.RadioGroup,
|
|
9
|
-
reactAriaComponents.CheckboxGroup
|
|
9
|
+
reactAriaComponents.CheckboxGroup,
|
|
10
|
+
reactAriaComponents.DatePicker
|
|
10
11
|
];
|
|
11
12
|
|
|
12
13
|
exports.ALLOWED_FORM_CONTAINERS = ALLOWED_FORM_CONTAINERS;
|