@pingux/astro 2.2.0 → 2.3.0-alpha.1
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/cjs/components/Calendar/Calendar.js +202 -0
- package/lib/cjs/components/Calendar/Calendar.stories.js +192 -0
- package/lib/cjs/components/Calendar/Calendar.styles.js +74 -0
- package/lib/cjs/components/Calendar/Calendar.test.js +324 -0
- package/lib/cjs/components/Calendar/CalendarCell.js +125 -0
- package/lib/cjs/components/Calendar/CalendarGrid.js +77 -0
- package/lib/cjs/components/Calendar/index.js +14 -0
- package/lib/cjs/components/DatePicker/DateField.js +316 -0
- package/lib/cjs/components/DatePicker/DatePicker.js +195 -0
- package/lib/cjs/components/DatePicker/DatePicker.stories.js +205 -0
- package/lib/cjs/components/DatePicker/DatePicker.styles.js +60 -0
- package/lib/cjs/components/DatePicker/DatePicker.test.js +570 -0
- package/lib/cjs/components/DatePicker/DateSegment.js +71 -0
- package/lib/cjs/components/DatePicker/index.js +14 -0
- package/lib/cjs/components/IconButton/IconButton.styles.js +4 -0
- package/lib/cjs/components/TextField/TextField.js +6 -2
- package/lib/cjs/components/TextField/TextField.stories.js +13 -1
- package/lib/cjs/components/TooltipTrigger/Tooltip.js +4 -6
- package/lib/cjs/components/TooltipTrigger/Tooltip.styles.js +14 -18
- package/lib/cjs/hooks/useOverlayPanelState/useOverlayPanelState.test.js +2 -2
- package/lib/cjs/index.js +132 -59
- package/lib/cjs/styles/forms/index.js +2 -0
- package/lib/cjs/styles/variants/variants.js +4 -2
- package/lib/components/Calendar/Calendar.js +190 -0
- package/lib/components/Calendar/Calendar.stories.js +171 -0
- package/lib/components/Calendar/Calendar.styles.js +66 -0
- package/lib/components/Calendar/Calendar.test.js +321 -0
- package/lib/components/Calendar/CalendarCell.js +111 -0
- package/lib/components/Calendar/CalendarGrid.js +68 -0
- package/lib/components/Calendar/index.js +1 -0
- package/lib/components/DatePicker/DateField.js +303 -0
- package/lib/components/DatePicker/DatePicker.js +183 -0
- package/lib/components/DatePicker/DatePicker.stories.js +180 -0
- package/lib/components/DatePicker/DatePicker.styles.js +51 -0
- package/lib/components/DatePicker/DatePicker.test.js +563 -0
- package/lib/components/DatePicker/DateSegment.js +58 -0
- package/lib/components/DatePicker/index.js +1 -0
- package/lib/components/IconButton/IconButton.styles.js +4 -0
- package/lib/components/TextField/TextField.js +6 -2
- package/lib/components/TextField/TextField.stories.js +11 -0
- package/lib/components/TooltipTrigger/Tooltip.js +4 -6
- package/lib/components/TooltipTrigger/Tooltip.styles.js +14 -18
- package/lib/hooks/useOverlayPanelState/useOverlayPanelState.test.js +2 -2
- package/lib/index.js +8 -0
- package/lib/styles/forms/index.js +2 -0
- package/lib/styles/variants/variants.js +3 -1
- package/package.json +7 -1
- package/NOTICE.html +0 -12399
- /package/lib/cjs/{styles/variants/callout.js → components/Callout/Callout.styles.js} +0 -0
- /package/lib/{styles/variants/callout.js → components/Callout/Callout.styles.js} +0 -0
@@ -21,6 +21,8 @@ var _Accordion = _interopRequireDefault(require("../../components/AccordionGroup
|
|
21
21
|
var _Box = _interopRequireDefault(require("../../components/Box/Box.styles"));
|
22
22
|
var _Bracket = _interopRequireDefault(require("../../components/Bracket/Bracket.styles"));
|
23
23
|
var _Breadcrumb = _interopRequireDefault(require("../../components/Breadcrumbs/Breadcrumb.styles"));
|
24
|
+
var _Calendar = _interopRequireDefault(require("../../components/Calendar/Calendar.styles"));
|
25
|
+
var _Callout = _interopRequireDefault(require("../../components/Callout/Callout.styles"));
|
24
26
|
var _CodeView = _interopRequireDefault(require("../../components/CodeView/CodeView.styles"));
|
25
27
|
var _CollapsiblePanel = _interopRequireDefault(require("../../components/CollapsiblePanel/CollapsiblePanel.styles"));
|
26
28
|
var _CopyText = _interopRequireDefault(require("../../components/CopyText/CopyText.styles"));
|
@@ -48,7 +50,6 @@ var _Table = _interopRequireDefault(require("../../components/Table/Table.styles
|
|
48
50
|
var tab = _interopRequireWildcard(require("../../components/Tabs/Tabs.style"));
|
49
51
|
var _TimeZone = _interopRequireDefault(require("../../components/TimeZonePicker/TimeZone.styles"));
|
50
52
|
var _Tooltip = _interopRequireDefault(require("../../components/TooltipTrigger/Tooltip.styles"));
|
51
|
-
var _callout = _interopRequireDefault(require("./callout"));
|
52
53
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
53
54
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
54
55
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
@@ -59,7 +60,8 @@ var _default = _objectSpread({
|
|
59
60
|
box: _Box["default"],
|
60
61
|
bracket: _Bracket["default"],
|
61
62
|
breadcrumb: _Breadcrumb["default"],
|
62
|
-
|
63
|
+
calendar: _Calendar["default"],
|
64
|
+
callout: _Callout["default"],
|
63
65
|
codeView: _CodeView["default"],
|
64
66
|
collapsiblePanel: _CollapsiblePanel["default"],
|
65
67
|
copyText: _CopyText["default"],
|
@@ -0,0 +1,190 @@
|
|
1
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
11
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
14
|
+
import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
15
|
+
import { createCalendar, parseDate } from '@internationalized/date';
|
16
|
+
import { useCalendar } from '@react-aria/calendar';
|
17
|
+
import { useLocale } from '@react-aria/i18n';
|
18
|
+
import { VisuallyHidden } from '@react-aria/visually-hidden';
|
19
|
+
import { useCalendarState } from '@react-stately/calendar';
|
20
|
+
import ChevronDoubleLeftIcon from 'mdi-react/ChevronDoubleLeftIcon';
|
21
|
+
import ChevronDoubleRightIcon from 'mdi-react/ChevronDoubleRightIcon';
|
22
|
+
import ChevronLeftIcon from 'mdi-react/ChevronLeftIcon';
|
23
|
+
import ChevronRightIcon from 'mdi-react/ChevronRightIcon';
|
24
|
+
import PropTypes from 'prop-types';
|
25
|
+
import { Box, Button, Icon, IconButton, Text } from '../../index';
|
26
|
+
import CalendarGrid from './CalendarGrid';
|
27
|
+
|
28
|
+
/**
|
29
|
+
* A simple component to display a monthly grid for date selection.
|
30
|
+
* Utilizes [useCalendar, useCalendarGrid, useCalendarCell](https://react-spectrum.adobe.com/react-aria/useCalendar.html),
|
31
|
+
* from React Aria and [useCalendarState](https://react-spectrum.adobe.com/react-stately/useCalendarState.html)
|
32
|
+
* from React Stately.
|
33
|
+
*/
|
34
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
35
|
+
var Calendar = /*#__PURE__*/forwardRef(function (props, ref) {
|
36
|
+
var value = props.value,
|
37
|
+
defaultValue = props.defaultValue,
|
38
|
+
minValue = props.minValue,
|
39
|
+
maxValue = props.maxValue;
|
40
|
+
var _useLocale = useLocale(),
|
41
|
+
locale = _useLocale.locale;
|
42
|
+
var calenderRef = useRef();
|
43
|
+
|
44
|
+
// istanbul ignore next
|
45
|
+
useImperativeHandle(ref, function () {
|
46
|
+
return calenderRef.current;
|
47
|
+
});
|
48
|
+
var parsedDates = {
|
49
|
+
value: typeof value === 'string' && parseDate(value) || value,
|
50
|
+
defaultValue: typeof defaultValue === 'string' && parseDate(defaultValue) || defaultValue,
|
51
|
+
maxValue: typeof maxValue === 'string' && parseDate(maxValue) || maxValue,
|
52
|
+
minValue: typeof minValue === 'string' && parseDate(minValue) || minValue
|
53
|
+
};
|
54
|
+
var state = useCalendarState(_objectSpread(_objectSpread(_objectSpread({}, props), parsedDates), {}, {
|
55
|
+
locale: locale,
|
56
|
+
createCalendar: createCalendar
|
57
|
+
}));
|
58
|
+
var _useCalendar = useCalendar(_objectSpread(_objectSpread({}, props), parsedDates), state, calenderRef),
|
59
|
+
calendarProps = _useCalendar.calendarProps,
|
60
|
+
prevButtonProps = _useCalendar.prevButtonProps,
|
61
|
+
nextButtonProps = _useCalendar.nextButtonProps,
|
62
|
+
title = _useCalendar.title;
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Grabs the currently displayed date for yearly navigation.
|
66
|
+
*/
|
67
|
+
|
68
|
+
var _useState = useState(),
|
69
|
+
_useState2 = _slicedToArray(_useState, 2),
|
70
|
+
currentDate = _useState2[0],
|
71
|
+
setCurrentDate = _useState2[1];
|
72
|
+
var todayDate = useMemo(function () {
|
73
|
+
setCurrentDate(state.visibleRange.start);
|
74
|
+
}, [state.visibleRange.start]);
|
75
|
+
var nav = {
|
76
|
+
NEXT: 'next',
|
77
|
+
PREVIOUS: 'previous'
|
78
|
+
};
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Function handles the navigation to previous and next year
|
82
|
+
* based on the currently displayed date.
|
83
|
+
*/
|
84
|
+
|
85
|
+
var handleYearSelection = useCallback(function (navigation) {
|
86
|
+
var tempValue;
|
87
|
+
if (navigation === nav.PREVIOUS) {
|
88
|
+
tempValue = currentDate.subtract({
|
89
|
+
years: 1
|
90
|
+
});
|
91
|
+
} else if (navigation === nav.NEXT) {
|
92
|
+
tempValue = currentDate.add({
|
93
|
+
years: 1
|
94
|
+
});
|
95
|
+
}
|
96
|
+
state.setFocusedDate(tempValue);
|
97
|
+
setCurrentDate(tempValue);
|
98
|
+
}, [currentDate, state, todayDate]);
|
99
|
+
return ___EmotionJSX(Box, _extends({}, calendarProps, {
|
100
|
+
ref: calenderRef,
|
101
|
+
variant: "calendar.calendarContainer"
|
102
|
+
}), ___EmotionJSX(Box, {
|
103
|
+
className: "header",
|
104
|
+
isRow: true,
|
105
|
+
variant: "calendar.calendarHeader",
|
106
|
+
verticalAlign: "middle"
|
107
|
+
}, ___EmotionJSX(IconButton, {
|
108
|
+
onPress: function onPress() {
|
109
|
+
return handleYearSelection(nav.PREVIOUS);
|
110
|
+
},
|
111
|
+
mx: "sm",
|
112
|
+
isDisabled: prevButtonProps.isDisabled,
|
113
|
+
"aria-label": "previous year navigation"
|
114
|
+
}, ___EmotionJSX(Icon, {
|
115
|
+
icon: ChevronDoubleLeftIcon,
|
116
|
+
size: 18
|
117
|
+
})), ___EmotionJSX(IconButton, prevButtonProps, ___EmotionJSX(Icon, {
|
118
|
+
icon: ChevronLeftIcon,
|
119
|
+
size: 18
|
120
|
+
})), ___EmotionJSX(VisuallyHidden, null, ___EmotionJSX(Text, null, calendarProps['aria-label'])), ___EmotionJSX(Text, {
|
121
|
+
variant: "itemTitle",
|
122
|
+
role: "heading",
|
123
|
+
"aria-level": "3",
|
124
|
+
fontWeight: 3
|
125
|
+
}, title), ___EmotionJSX(IconButton, nextButtonProps, ___EmotionJSX(Icon, {
|
126
|
+
icon: ChevronRightIcon,
|
127
|
+
size: 18
|
128
|
+
})), ___EmotionJSX(IconButton, {
|
129
|
+
onPress: function onPress() {
|
130
|
+
return handleYearSelection(nav.NEXT);
|
131
|
+
},
|
132
|
+
mx: "sm",
|
133
|
+
isDisabled: nextButtonProps.isDisabled,
|
134
|
+
"aria-label": "next year navigation"
|
135
|
+
}, ___EmotionJSX(Icon, {
|
136
|
+
icon: ChevronDoubleRightIcon,
|
137
|
+
size: 18
|
138
|
+
}))), ___EmotionJSX(CalendarGrid, {
|
139
|
+
state: state
|
140
|
+
}), ___EmotionJSX(VisuallyHidden, null, ___EmotionJSX(Button, {
|
141
|
+
"aria-label": nextButtonProps['aria-label'],
|
142
|
+
isDisabled: nextButtonProps.isDisabled,
|
143
|
+
onPress: function onPress() {
|
144
|
+
return state.focusNextPage();
|
145
|
+
},
|
146
|
+
tabIndex: -1
|
147
|
+
})));
|
148
|
+
});
|
149
|
+
Calendar.propTypes = {
|
150
|
+
/** Prop to provide a custom default date (uncontrolled) */
|
151
|
+
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
152
|
+
/** Prop to provide a default date (controlled) */
|
153
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
154
|
+
/** custom week days for other calendars */
|
155
|
+
customWeekDays: PropTypes.arrayOf(PropTypes.string),
|
156
|
+
/** Whether the element should receive focus on render. */
|
157
|
+
hasAutoFocus: PropTypes.bool,
|
158
|
+
/** The element's unique identifier. */
|
159
|
+
id: PropTypes.string,
|
160
|
+
/**
|
161
|
+
* Callback that is called for each date of the calendar.
|
162
|
+
* If it returns true, then the date is unavailable.
|
163
|
+
*
|
164
|
+
* (date: DateValue) => boolean
|
165
|
+
*/
|
166
|
+
isDateUnavailable: PropTypes.func,
|
167
|
+
/** Whether the calendar is disabled. */
|
168
|
+
isDisabled: PropTypes.bool,
|
169
|
+
/** Whether the calendar dates are only focusable. */
|
170
|
+
isReadOnly: PropTypes.bool,
|
171
|
+
/** Whether user input is required on the input before form submission. */
|
172
|
+
isRequired: PropTypes.bool,
|
173
|
+
/** The maximum allowed date that a user may select. */
|
174
|
+
maxValue: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
175
|
+
/** The minimum allowed date that a user may select. */
|
176
|
+
minValue: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
177
|
+
/** Handler that is called when the element loses focus. */
|
178
|
+
onBlur: PropTypes.func,
|
179
|
+
/** Handler that is called when the element's selection state changes. */
|
180
|
+
onChange: PropTypes.func,
|
181
|
+
/** Handler that is called when the element receives focus. */
|
182
|
+
onFocus: PropTypes.func,
|
183
|
+
/** Handler that is called when the element's focus status changes. */
|
184
|
+
onFocusChange: PropTypes.func,
|
185
|
+
/** Handler that is called when a key is pressed. */
|
186
|
+
onKeyDown: PropTypes.func,
|
187
|
+
/** Handler that is called when a key is released. */
|
188
|
+
onKeyUp: PropTypes.func
|
189
|
+
};
|
190
|
+
export default Calendar;
|
@@ -0,0 +1,171 @@
|
|
1
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
10
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
11
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
12
|
+
import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/some";
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
15
|
+
import React, { useState } from 'react';
|
16
|
+
import { parseDate } from '@internationalized/date';
|
17
|
+
import { ariaAttributeBaseArgTypes } from '../../utils/docUtils/ariaAttributes';
|
18
|
+
import Calendar from './Calendar';
|
19
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
20
|
+
export default {
|
21
|
+
title: 'Components/Calendar',
|
22
|
+
component: Calendar,
|
23
|
+
parameters: {
|
24
|
+
actions: {
|
25
|
+
argTypesRegex: '^on.*'
|
26
|
+
},
|
27
|
+
docs: {
|
28
|
+
source: {
|
29
|
+
type: 'code'
|
30
|
+
}
|
31
|
+
}
|
32
|
+
},
|
33
|
+
argTypes: _objectSpread({
|
34
|
+
customWeekDays: {
|
35
|
+
control: {
|
36
|
+
type: 'array'
|
37
|
+
}
|
38
|
+
},
|
39
|
+
value: {
|
40
|
+
control: {
|
41
|
+
type: 'text'
|
42
|
+
}
|
43
|
+
},
|
44
|
+
defaultValue: {
|
45
|
+
control: {
|
46
|
+
type: 'text'
|
47
|
+
}
|
48
|
+
},
|
49
|
+
hasAutoFocus: {
|
50
|
+
control: {
|
51
|
+
type: 'boolean'
|
52
|
+
},
|
53
|
+
defaultValue: false
|
54
|
+
},
|
55
|
+
id: {
|
56
|
+
control: {
|
57
|
+
type: 'text'
|
58
|
+
}
|
59
|
+
},
|
60
|
+
isDisabled: {
|
61
|
+
control: {
|
62
|
+
type: 'boolean'
|
63
|
+
},
|
64
|
+
defaultValue: false
|
65
|
+
},
|
66
|
+
isReadOnly: {
|
67
|
+
control: {
|
68
|
+
type: 'boolean'
|
69
|
+
},
|
70
|
+
defaultValue: false
|
71
|
+
},
|
72
|
+
isRequired: {
|
73
|
+
control: {
|
74
|
+
type: 'boolean'
|
75
|
+
},
|
76
|
+
defaultValue: false
|
77
|
+
},
|
78
|
+
maxValue: {
|
79
|
+
control: {
|
80
|
+
type: 'text'
|
81
|
+
}
|
82
|
+
},
|
83
|
+
minValue: {
|
84
|
+
control: {
|
85
|
+
type: 'text'
|
86
|
+
}
|
87
|
+
},
|
88
|
+
onChange: {
|
89
|
+
control: {
|
90
|
+
type: 'func'
|
91
|
+
},
|
92
|
+
defaultValue: null,
|
93
|
+
action: 'change'
|
94
|
+
},
|
95
|
+
onFocusChange: {
|
96
|
+
control: {
|
97
|
+
type: 'func'
|
98
|
+
},
|
99
|
+
defaultValue: null,
|
100
|
+
action: 'focus change'
|
101
|
+
}
|
102
|
+
}, ariaAttributeBaseArgTypes)
|
103
|
+
};
|
104
|
+
export var Default = function Default(args) {
|
105
|
+
return ___EmotionJSX(Calendar, _extends({}, args, {
|
106
|
+
"aria-label": "calendar-default"
|
107
|
+
}));
|
108
|
+
};
|
109
|
+
export var DefaultValue = function DefaultValue(args) {
|
110
|
+
return ___EmotionJSX(Calendar, _extends({}, args, {
|
111
|
+
"aria-label": "calendar-with-default-value",
|
112
|
+
defaultValue: "2022-08-10"
|
113
|
+
}));
|
114
|
+
};
|
115
|
+
export var Controlled = function Controlled(args) {
|
116
|
+
var _useState = useState(null),
|
117
|
+
_useState2 = _slicedToArray(_useState, 2),
|
118
|
+
date = _useState2[0],
|
119
|
+
setDate = _useState2[1];
|
120
|
+
return ___EmotionJSX(Calendar, _extends({}, args, {
|
121
|
+
"aria-label": "calendar-component-controlled",
|
122
|
+
value: date,
|
123
|
+
onChange: setDate
|
124
|
+
}));
|
125
|
+
};
|
126
|
+
export var Disabled = function Disabled(args) {
|
127
|
+
return ___EmotionJSX(Calendar, _extends({}, args, {
|
128
|
+
"aria-label": "calendar-component-disabled",
|
129
|
+
isDisabled: true
|
130
|
+
}));
|
131
|
+
};
|
132
|
+
export var ReadOnly = function ReadOnly(args) {
|
133
|
+
return ___EmotionJSX(Calendar, _extends({}, args, {
|
134
|
+
"aria-label": "calendar-component-readonly",
|
135
|
+
isReadOnly: true
|
136
|
+
}));
|
137
|
+
};
|
138
|
+
export var UnavailableDates = function UnavailableDates(args) {
|
139
|
+
var unavailableRanges = [['2022-07-29', '2022-08-05'], ['2022-08-15', '2022-08-20'], ['2022-08-25', '2022-08-26']];
|
140
|
+
// This function is run against each date in the calendar
|
141
|
+
var isDateUnavailable = function isDateUnavailable(date) {
|
142
|
+
return _someInstanceProperty(unavailableRanges).call(unavailableRanges, function (interval) {
|
143
|
+
return date.compare(parseDate(interval[0])) >= 0 && date.compare(parseDate(interval[1])) <= 0;
|
144
|
+
});
|
145
|
+
};
|
146
|
+
return ___EmotionJSX(Calendar, _extends({}, args, {
|
147
|
+
"aria-label": "calendar-component-unavailable-dates",
|
148
|
+
defaultValue: "2022-08-10",
|
149
|
+
isDateUnavailable: isDateUnavailable
|
150
|
+
}));
|
151
|
+
};
|
152
|
+
export var MinimumDate = function MinimumDate(args) {
|
153
|
+
return ___EmotionJSX(Calendar, _extends({}, args, {
|
154
|
+
"aria-label": "calendar-component-min-date",
|
155
|
+
minValue: "2022-09-10",
|
156
|
+
defaultDate: "2022-09-14"
|
157
|
+
}));
|
158
|
+
};
|
159
|
+
export var MaximumDate = function MaximumDate(args) {
|
160
|
+
return ___EmotionJSX(Calendar, _extends({}, args, {
|
161
|
+
"aria-label": "calendar-component-max-date",
|
162
|
+
maxValue: "2022-10-10",
|
163
|
+
defaultValue: "2022-10-05"
|
164
|
+
}));
|
165
|
+
};
|
166
|
+
export var Autofocus = function Autofocus(args) {
|
167
|
+
return ___EmotionJSX(Calendar, _extends({}, args, {
|
168
|
+
"aria-label": "calendar-component",
|
169
|
+
hasAutoFocus: true
|
170
|
+
}));
|
171
|
+
};
|
@@ -0,0 +1,66 @@
|
|
1
|
+
var calendarBody = {
|
2
|
+
borderTop: '1px solid',
|
3
|
+
borderTopColor: 'neutral.80',
|
4
|
+
'& > tr:nth-of-type(odd) ': {
|
5
|
+
backgroundColor: 'white'
|
6
|
+
}
|
7
|
+
};
|
8
|
+
var calendarButton = {
|
9
|
+
py: 'sm',
|
10
|
+
fontSize: 'sm',
|
11
|
+
fontWeight: 1,
|
12
|
+
color: 'neutral.10',
|
13
|
+
lineHeight: '16px',
|
14
|
+
width: '40.5px',
|
15
|
+
height: '40px',
|
16
|
+
'&.is-hovered': {
|
17
|
+
bg: 'accent.99',
|
18
|
+
cursor: 'pointer'
|
19
|
+
},
|
20
|
+
'&.is-selected': {
|
21
|
+
bg: 'active',
|
22
|
+
color: 'white',
|
23
|
+
outline: 'none',
|
24
|
+
boxShadow: 'none'
|
25
|
+
},
|
26
|
+
'&.is-unavailable': {
|
27
|
+
backgroundColor: 'neutral.80'
|
28
|
+
},
|
29
|
+
'&:not(.is-outside-visible-range)&.is-extreme&:not(.is-completely-disabled)': {
|
30
|
+
backgroundColor: 'neutral.80',
|
31
|
+
color: 'neutral.10',
|
32
|
+
opacity: 1
|
33
|
+
}
|
34
|
+
};
|
35
|
+
var calendarCell = {
|
36
|
+
cursor: 'default',
|
37
|
+
textAlign: 'center',
|
38
|
+
position: 'relative',
|
39
|
+
color: '#333'
|
40
|
+
};
|
41
|
+
var columnHeader = {
|
42
|
+
fontSize: '13px',
|
43
|
+
fontWeight: 1,
|
44
|
+
width: '40px',
|
45
|
+
height: '16px',
|
46
|
+
mb: '12px'
|
47
|
+
};
|
48
|
+
var calendarContainer = {
|
49
|
+
boxShadow: 'standard',
|
50
|
+
textAlign: 'center',
|
51
|
+
maxWidth: '280px'
|
52
|
+
};
|
53
|
+
var calendarHeader = {
|
54
|
+
justifyContent: 'space-between',
|
55
|
+
mt: '10px',
|
56
|
+
mb: '17px',
|
57
|
+
alignItems: 'center'
|
58
|
+
};
|
59
|
+
export default {
|
60
|
+
calendarBody: calendarBody,
|
61
|
+
calendarButton: calendarButton,
|
62
|
+
calendarCell: calendarCell,
|
63
|
+
calendarContainer: calendarContainer,
|
64
|
+
calendarHeader: calendarHeader,
|
65
|
+
columnHeader: columnHeader
|
66
|
+
};
|