@primer/components 0.0.0-2021101163942 → 0.0.0-2021101165346

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @primer/components
2
2
 
3
- ## 0.0.0-2021101163942
3
+ ## 0.0.0-2021101165346
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -211,7 +211,8 @@ const DatePickerAnchor = /*#__PURE__*/_react.default.forwardRef(({
211
211
  ref: ref
212
212
  }, /*#__PURE__*/_react.default.createElement(DatePickerAnchorButton, {
213
213
  onClick: clickHandler,
214
- onKeyPress: keyPressHandler
214
+ onKeyPress: keyPressHandler,
215
+ "aria-label": formattedDate
215
216
  }, iconPlacement === 'start' && calendarIcon(), anchorVariant !== 'icon-only' && /*#__PURE__*/_react.default.createElement(_Text.default, {
216
217
  sx: {
217
218
  overflow: 'hidden',
@@ -24,7 +24,8 @@ const DatePickerOverlay = ({
24
24
  const {
25
25
  dialogOpen,
26
26
  onClose: onDatePickerClose,
27
- setDialogOpen
27
+ setDialogOpen,
28
+ currentViewingDate
28
29
  } = (0, _useDatePicker.default)();
29
30
 
30
31
  const onOverlayClose = async gesture => {
@@ -38,7 +39,11 @@ const DatePickerOverlay = ({
38
39
 
39
40
  return /*#__PURE__*/_react.default.createElement(_AnchoredOverlay.AnchoredOverlay, _extends({
40
41
  onClose: onOverlayClose
41
- }, rest), /*#__PURE__*/_react.default.createElement(_DatePickerPanel.DatePickerPanel, null));
42
+ }, rest, {
43
+ "aria-modal": "true",
44
+ "aria-labelledby": `${currentViewingDate.getMonth()} ${currentViewingDate.getFullYear()}`,
45
+ "aria-live": "polite"
46
+ }), /*#__PURE__*/_react.default.createElement(_DatePickerPanel.DatePickerPanel, null));
42
47
  };
43
48
 
44
49
  exports.DatePickerOverlay = DatePickerOverlay;
@@ -106,21 +106,23 @@ const DatePickerPanel = () => {
106
106
  variant: "small",
107
107
  side: "left",
108
108
  onClick: previousMonth,
109
- disabled: previousDisabled
109
+ disabled: previousDisabled,
110
+ "aria-label": "Previous Month",
111
+ "aria-live": "polite"
110
112
  }, /*#__PURE__*/_react.default.createElement(_StyledOcticon.default, {
111
113
  icon: _octiconsReact.ChevronLeftIcon,
112
114
  color: "fg.muted"
113
115
  })), /*#__PURE__*/_react.default.createElement(_Month.Month, {
114
- month: currentViewingDate.getMonth(),
115
- year: currentViewingDate.getFullYear()
116
+ date: currentViewingDate
116
117
  }), configuration.view === '2-month' && multiMonthSupport && /*#__PURE__*/_react.default.createElement(_Month.Month, {
117
- month: (0, _dateFns.addMonths)(currentViewingDate, 1).getMonth(),
118
- year: (0, _dateFns.addMonths)(currentViewingDate, 1).getFullYear()
118
+ date: (0, _dateFns.addMonths)(currentViewingDate, 1)
119
119
  }), /*#__PURE__*/_react.default.createElement(ArrowButton, {
120
120
  variant: "small",
121
121
  side: "right",
122
122
  onClick: nextMonth,
123
- disabled: nextDisabled
123
+ disabled: nextDisabled,
124
+ "aria-label": "Next Month",
125
+ "aria-live": "polite"
124
126
  }, /*#__PURE__*/_react.default.createElement(_StyledOcticon.default, {
125
127
  icon: _octiconsReact.ChevronRightIcon,
126
128
  color: "fg.muted"
@@ -129,13 +131,19 @@ const DatePickerPanel = () => {
129
131
  sx: {
130
132
  mr: 1
131
133
  },
132
- onClick: () => revertValue()
134
+ onClick: () => revertValue(),
135
+ "aria-label": "Reset Selection",
136
+ "aria-live": "polite"
133
137
  }, "Reset"), /*#__PURE__*/_react.default.createElement(_Button.default, {
134
138
  variant: "small",
135
- onClick: () => goToMonth(new Date())
139
+ onClick: () => goToMonth(new Date()),
140
+ "aria-label": "Go to Today",
141
+ "aria-live": "polite"
136
142
  }, "Today")), configuration.confirmation && /*#__PURE__*/_react.default.createElement(_Button.ButtonPrimary, {
137
143
  variant: "small",
138
- onClick: () => saveValue()
144
+ onClick: () => saveValue(),
145
+ "aria-label": "Apply Selection",
146
+ "aria-live": "polite"
139
147
  }, "Apply")));
140
148
  };
141
149
 
@@ -3,7 +3,6 @@ import { FontSizeProps } from 'styled-system';
3
3
  import { SystemCommonProps, SystemLayoutProps } from '../constants';
4
4
  import { SxProp } from '../sx';
5
5
  export interface MonthProps extends FontSizeProps, SystemCommonProps, SxProp, SystemLayoutProps {
6
- month: number;
7
- year: number;
6
+ date: Date;
8
7
  }
9
8
  export declare const Month: React.FC<MonthProps>;
@@ -50,18 +50,17 @@ const WeekdayHeader = (0, _styledComponents.default)(_Text.default).withConfig({
50
50
  })(["color:", ";font-family:", ";font-size:", ";justify-self:center;padding:", " 0 ", ";"], (0, _constants.get)('colors.fg.subtle'), (0, _constants.get)('fonts.mono'), (0, _constants.get)('fontSizes.0'), (0, _constants.get)('space.3'), (0, _constants.get)('space.2'));
51
51
 
52
52
  const Month = ({
53
- month,
54
- year
53
+ date
55
54
  }) => {
56
55
  const {
57
56
  configuration
58
57
  } = (0, _useDatePicker.default)();
59
58
  const [selectedDay, setSelectedDay] = (0, _react.useState)(null);
60
- const getTitle = (0, _react.useMemo)(() => `${(0, _dateFns.format)(new Date(year, month), 'MMMM yyyy')}`, [month, year]);
59
+ const getTitle = (0, _react.useMemo)(() => `${(0, _dateFns.format)(new Date(date), 'MMMM yyyy')}`, [date]);
61
60
  const weekdayHeaders = (0, _react.useMemo)(() => {
62
61
  var _configuration$weekSt;
63
62
 
64
- const now = new Date(year, month);
63
+ const now = new Date(date);
65
64
  const weekOptions = {
66
65
  weekStartsOn: weekdayEnum[(_configuration$weekSt = configuration.weekStartsOn) !== null && _configuration$weekSt !== void 0 ? _configuration$weekSt : 'Sunday']
67
66
  };
@@ -71,17 +70,17 @@ const Month = ({
71
70
  }).map(d => /*#__PURE__*/_react.default.createElement(WeekdayHeader, {
72
71
  key: `weekday-${d}-header`
73
72
  }, (0, _dateFns.format)(d, 'EEEEEE')));
74
- }, [configuration.weekStartsOn, month, year]);
73
+ }, [configuration.weekStartsOn, date]);
75
74
 
76
- const dayAction = date => {
77
- setSelectedDay(date);
75
+ const dayAction = day => {
76
+ setSelectedDay(day);
78
77
  };
79
78
 
80
79
  const dayComponents = (0, _react.useMemo)(() => {
81
80
  var _configuration$weekSt2, _configuration$weekSt3;
82
81
 
83
82
  const components = [];
84
- const firstDay = new Date(year, month, 1);
83
+ const firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
85
84
  const preBlanks = (firstDay.getDay() + (7 - weekdayEnum[(_configuration$weekSt2 = configuration.weekStartsOn) !== null && _configuration$weekSt2 !== void 0 ? _configuration$weekSt2 : 'Sunday'])) % 7;
86
85
 
87
86
  for (let i = 0; i < preBlanks; i++) {
@@ -91,11 +90,11 @@ const Month = ({
91
90
  }
92
91
 
93
92
  for (let i = 1; i <= (0, _dateFns.getDaysInMonth)(firstDay); i++) {
94
- const date = new Date(year, month, i);
93
+ const day = new Date(date.getFullYear(), date.getMonth(), i);
95
94
  components.push( /*#__PURE__*/_react.default.createElement(_Day.Day, {
96
- key: `day-component-${date.toString()}`,
97
- date: date,
98
- selected: selectedDay ? (0, _dateFns.isEqual)(date, selectedDay) : false,
95
+ key: `day-component-${day.toString()}`,
96
+ date: day,
97
+ selected: selectedDay ? (0, _dateFns.isEqual)(day, selectedDay) : false,
99
98
  onAction: dayAction
100
99
  }));
101
100
  }
@@ -110,9 +109,10 @@ const Month = ({
110
109
  }
111
110
 
112
111
  return components;
113
- }, [configuration.weekStartsOn, month, selectedDay, year]);
112
+ }, [configuration.weekStartsOn, date, selectedDay]);
114
113
  return /*#__PURE__*/_react.default.createElement(MonthComponent, {
115
- role: "grid"
114
+ role: "grid",
115
+ "aria-labelledby": `${date.getMonth()}`
116
116
  }, /*#__PURE__*/_react.default.createElement(MonthTitle, {
117
117
  "aria-live": "polite"
118
118
  }, getTitle), weekdayHeaders, dayComponents);
@@ -197,7 +197,7 @@ const defaultConfiguration = {
197
197
  confirmUnsavedClose: false,
198
198
  disableWeekends: false,
199
199
  iconPlacement: 'start',
200
- placeholder: 'Select a Date...',
200
+ placeholder: 'Choose Date...',
201
201
  showInputPrompt: false,
202
202
  variant: 'single',
203
203
  view: '2-month',
@@ -186,7 +186,8 @@ export const DatePickerAnchor = /*#__PURE__*/React.forwardRef(({
186
186
  ref: ref
187
187
  }, /*#__PURE__*/React.createElement(DatePickerAnchorButton, {
188
188
  onClick: clickHandler,
189
- onKeyPress: keyPressHandler
189
+ onKeyPress: keyPressHandler,
190
+ "aria-label": formattedDate
190
191
  }, iconPlacement === 'start' && calendarIcon(), anchorVariant !== 'icon-only' && /*#__PURE__*/React.createElement(Text, {
191
192
  sx: {
192
193
  overflow: 'hidden',
@@ -11,7 +11,8 @@ export const DatePickerOverlay = ({
11
11
  const {
12
12
  dialogOpen,
13
13
  onClose: onDatePickerClose,
14
- setDialogOpen
14
+ setDialogOpen,
15
+ currentViewingDate
15
16
  } = useDatePicker();
16
17
 
17
18
  const onOverlayClose = async gesture => {
@@ -25,6 +26,10 @@ export const DatePickerOverlay = ({
25
26
 
26
27
  return /*#__PURE__*/React.createElement(AnchoredOverlay, _extends({
27
28
  onClose: onOverlayClose
28
- }, rest), /*#__PURE__*/React.createElement(DatePickerPanel, null));
29
+ }, rest, {
30
+ "aria-modal": "true",
31
+ "aria-labelledby": `${currentViewingDate.getMonth()} ${currentViewingDate.getFullYear()}`,
32
+ "aria-live": "polite"
33
+ }), /*#__PURE__*/React.createElement(DatePickerPanel, null));
29
34
  };
30
35
  DatePickerOverlay.displayName = "DatePickerOverlay";
@@ -81,21 +81,23 @@ export const DatePickerPanel = () => {
81
81
  variant: "small",
82
82
  side: "left",
83
83
  onClick: previousMonth,
84
- disabled: previousDisabled
84
+ disabled: previousDisabled,
85
+ "aria-label": "Previous Month",
86
+ "aria-live": "polite"
85
87
  }, /*#__PURE__*/React.createElement(StyledOcticon, {
86
88
  icon: ChevronLeftIcon,
87
89
  color: "fg.muted"
88
90
  })), /*#__PURE__*/React.createElement(Month, {
89
- month: currentViewingDate.getMonth(),
90
- year: currentViewingDate.getFullYear()
91
+ date: currentViewingDate
91
92
  }), configuration.view === '2-month' && multiMonthSupport && /*#__PURE__*/React.createElement(Month, {
92
- month: addMonths(currentViewingDate, 1).getMonth(),
93
- year: addMonths(currentViewingDate, 1).getFullYear()
93
+ date: addMonths(currentViewingDate, 1)
94
94
  }), /*#__PURE__*/React.createElement(ArrowButton, {
95
95
  variant: "small",
96
96
  side: "right",
97
97
  onClick: nextMonth,
98
- disabled: nextDisabled
98
+ disabled: nextDisabled,
99
+ "aria-label": "Next Month",
100
+ "aria-live": "polite"
99
101
  }, /*#__PURE__*/React.createElement(StyledOcticon, {
100
102
  icon: ChevronRightIcon,
101
103
  color: "fg.muted"
@@ -104,13 +106,19 @@ export const DatePickerPanel = () => {
104
106
  sx: {
105
107
  mr: 1
106
108
  },
107
- onClick: () => revertValue()
109
+ onClick: () => revertValue(),
110
+ "aria-label": "Reset Selection",
111
+ "aria-live": "polite"
108
112
  }, "Reset"), /*#__PURE__*/React.createElement(Button, {
109
113
  variant: "small",
110
- onClick: () => goToMonth(new Date())
114
+ onClick: () => goToMonth(new Date()),
115
+ "aria-label": "Go to Today",
116
+ "aria-live": "polite"
111
117
  }, "Today")), configuration.confirmation && /*#__PURE__*/React.createElement(ButtonPrimary, {
112
118
  variant: "small",
113
- onClick: () => saveValue()
119
+ onClick: () => saveValue(),
120
+ "aria-label": "Apply Selection",
121
+ "aria-live": "polite"
114
122
  }, "Apply")));
115
123
  };
116
124
  DatePickerPanel.displayName = "DatePickerPanel";
@@ -3,7 +3,6 @@ import { FontSizeProps } from 'styled-system';
3
3
  import { SystemCommonProps, SystemLayoutProps } from '../constants';
4
4
  import { SxProp } from '../sx';
5
5
  export interface MonthProps extends FontSizeProps, SystemCommonProps, SxProp, SystemLayoutProps {
6
- month: number;
7
- year: number;
6
+ date: Date;
8
7
  }
9
8
  export declare const Month: React.FC<MonthProps>;
@@ -28,18 +28,17 @@ const WeekdayHeader = styled(Text).withConfig({
28
28
  componentId: "l6j7o0-2"
29
29
  })(["color:", ";font-family:", ";font-size:", ";justify-self:center;padding:", " 0 ", ";"], get('colors.fg.subtle'), get('fonts.mono'), get('fontSizes.0'), get('space.3'), get('space.2'));
30
30
  export const Month = ({
31
- month,
32
- year
31
+ date
33
32
  }) => {
34
33
  const {
35
34
  configuration
36
35
  } = useDatePicker();
37
36
  const [selectedDay, setSelectedDay] = useState(null);
38
- const getTitle = useMemo(() => `${format(new Date(year, month), 'MMMM yyyy')}`, [month, year]);
37
+ const getTitle = useMemo(() => `${format(new Date(date), 'MMMM yyyy')}`, [date]);
39
38
  const weekdayHeaders = useMemo(() => {
40
39
  var _configuration$weekSt;
41
40
 
42
- const now = new Date(year, month);
41
+ const now = new Date(date);
43
42
  const weekOptions = {
44
43
  weekStartsOn: weekdayEnum[(_configuration$weekSt = configuration.weekStartsOn) !== null && _configuration$weekSt !== void 0 ? _configuration$weekSt : 'Sunday']
45
44
  };
@@ -49,17 +48,17 @@ export const Month = ({
49
48
  }).map(d => /*#__PURE__*/React.createElement(WeekdayHeader, {
50
49
  key: `weekday-${d}-header`
51
50
  }, format(d, 'EEEEEE')));
52
- }, [configuration.weekStartsOn, month, year]);
51
+ }, [configuration.weekStartsOn, date]);
53
52
 
54
- const dayAction = date => {
55
- setSelectedDay(date);
53
+ const dayAction = day => {
54
+ setSelectedDay(day);
56
55
  };
57
56
 
58
57
  const dayComponents = useMemo(() => {
59
58
  var _configuration$weekSt2, _configuration$weekSt3;
60
59
 
61
60
  const components = [];
62
- const firstDay = new Date(year, month, 1);
61
+ const firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
63
62
  const preBlanks = (firstDay.getDay() + (7 - weekdayEnum[(_configuration$weekSt2 = configuration.weekStartsOn) !== null && _configuration$weekSt2 !== void 0 ? _configuration$weekSt2 : 'Sunday'])) % 7;
64
63
 
65
64
  for (let i = 0; i < preBlanks; i++) {
@@ -69,11 +68,11 @@ export const Month = ({
69
68
  }
70
69
 
71
70
  for (let i = 1; i <= getDaysInMonth(firstDay); i++) {
72
- const date = new Date(year, month, i);
71
+ const day = new Date(date.getFullYear(), date.getMonth(), i);
73
72
  components.push( /*#__PURE__*/React.createElement(Day, {
74
- key: `day-component-${date.toString()}`,
75
- date: date,
76
- selected: selectedDay ? isEqual(date, selectedDay) : false,
73
+ key: `day-component-${day.toString()}`,
74
+ date: day,
75
+ selected: selectedDay ? isEqual(day, selectedDay) : false,
77
76
  onAction: dayAction
78
77
  }));
79
78
  }
@@ -88,9 +87,10 @@ export const Month = ({
88
87
  }
89
88
 
90
89
  return components;
91
- }, [configuration.weekStartsOn, month, selectedDay, year]);
90
+ }, [configuration.weekStartsOn, date, selectedDay]);
92
91
  return /*#__PURE__*/React.createElement(MonthComponent, {
93
- role: "grid"
92
+ role: "grid",
93
+ "aria-labelledby": `${date.getMonth()}`
94
94
  }, /*#__PURE__*/React.createElement(MonthTitle, {
95
95
  "aria-live": "polite"
96
96
  }, getTitle), weekdayHeaders, dayComponents);
@@ -169,7 +169,7 @@ const defaultConfiguration = {
169
169
  confirmUnsavedClose: false,
170
170
  disableWeekends: false,
171
171
  iconPlacement: 'start',
172
- placeholder: 'Select a Date...',
172
+ placeholder: 'Choose Date...',
173
173
  showInputPrompt: false,
174
174
  variant: 'single',
175
175
  view: '2-month',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/components",
3
- "version": "0.0.0-2021101163942",
3
+ "version": "0.0.0-2021101165346",
4
4
  "description": "Primer react components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",