grommet 2.40.2 → 2.42.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.
- package/components/AccordionPanel/AccordionPanel.js +1 -7
- package/components/Box/Box.js +1 -1
- package/components/Box/StyledBox.js +1 -6
- package/components/Box/index.d.ts +1 -0
- package/components/Box/propTypes.js +1 -0
- package/components/Button/Button.js +1 -0
- package/components/Button/StyledButton.js +3 -2
- package/components/Button/StyledButtonKind.js +12 -6
- package/components/Calendar/Calendar.js +90 -56
- package/components/Calendar/StyledCalendar.js +89 -7
- package/components/Calendar/utils.js +16 -2
- package/components/Carousel/Carousel.js +1 -1
- package/components/Chart/Chart.js +3 -3
- package/components/CheckBox/CheckBox.js +3 -2
- package/components/CheckBoxGroup/CheckBoxGroup.js +1 -1
- package/components/Clock/Digital.js +1 -1
- package/components/Data/stories/Infinite.js +2 -2
- package/components/Data/stories/OnSelect.js +2 -2
- package/components/Data/stories/SpaceX.js +2 -2
- package/components/Data/stories/StarWars.js +1 -1
- package/components/DataChart/Detail.js +19 -4
- package/components/DataFilter/DataFilter.js +6 -1
- package/components/DataSort/DataSort.js +46 -14
- package/components/DataSort/stories/Simple.js +10 -1
- package/components/DataTable/Body.js +14 -8
- package/components/DataTable/GroupedBody.js +3 -3
- package/components/DataTable/buildState.js +5 -1
- package/components/DataTable/stories/SpaceX.js +2 -2
- package/components/DataTable/stories/SpaceXUngrouped.js +1 -1
- package/components/Drop/DropContainer.js +51 -3
- package/components/FileInput/index.d.ts +2 -3
- package/components/FocusedContainer.js +134 -17
- package/components/Grommet/Grommet.js +11 -5
- package/components/Layer/Layer.js +1 -1
- package/components/Layer/index.d.ts +2 -0
- package/components/List/List.js +18 -12
- package/components/MaskedInput/MaskedInput.js +3 -0
- package/components/Menu/Menu.js +3 -3
- package/components/Meter/Circle.js +2 -2
- package/components/Notification/Notification.js +18 -6
- package/components/Notification/index.d.ts +1 -0
- package/components/Notification/propTypes.js +1 -0
- package/components/Pagination/Pagination.js +4 -2
- package/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/components/Select/Select.js +29 -18
- package/components/Select/SelectContainer.js +41 -34
- package/components/Select/index.d.ts +1 -1
- package/components/Select/stories/ChildrenRender.js +7 -8
- package/components/Select/utils.js +13 -2
- package/components/SelectMultiple/SelectMultiple.js +18 -6
- package/components/SelectMultiple/SelectMultipleContainer.js +28 -2
- package/components/SelectMultiple/SelectMultipleValue.js +14 -1
- package/components/SkipLinks/index.d.ts +1 -0
- package/components/SkipLinks/propTypes.js +1 -0
- package/components/Tab/Tab.js +1 -1
- package/components/Tag/Tag.js +11 -7
- package/components/TextInput/TextInput.js +3 -0
- package/components/ToggleGroup/StyledToggleGroup.js +12 -5
- package/components/ToggleGroup/ToggleGroup.js +21 -10
- package/components/WorldMap/WorldMap.js +1 -1
- package/contexts/RootsContext.js +23 -5
- package/es6/components/AccordionPanel/AccordionPanel.js +2 -9
- package/es6/components/Box/Box.js +1 -1
- package/es6/components/Box/StyledBox.js +1 -6
- package/es6/components/Box/index.d.ts +1 -0
- package/es6/components/Box/propTypes.js +1 -0
- package/es6/components/Button/Button.js +1 -0
- package/es6/components/Button/StyledButton.js +4 -3
- package/es6/components/Button/StyledButtonKind.js +12 -6
- package/es6/components/Calendar/Calendar.js +89 -56
- package/es6/components/Calendar/StyledCalendar.js +90 -8
- package/es6/components/Calendar/utils.js +15 -1
- package/es6/components/Carousel/Carousel.js +1 -1
- package/es6/components/Chart/Chart.js +3 -3
- package/es6/components/CheckBox/CheckBox.js +3 -2
- package/es6/components/CheckBoxGroup/CheckBoxGroup.js +1 -1
- package/es6/components/Clock/Digital.js +1 -1
- package/es6/components/Data/stories/Infinite.js +2 -2
- package/es6/components/Data/stories/OnSelect.js +2 -2
- package/es6/components/Data/stories/SpaceX.js +2 -2
- package/es6/components/Data/stories/StarWars.js +1 -1
- package/es6/components/DataChart/Detail.js +20 -5
- package/es6/components/DataFilter/DataFilter.js +6 -1
- package/es6/components/DataSort/DataSort.js +46 -14
- package/es6/components/DataSort/stories/Simple.js +10 -1
- package/es6/components/DataTable/Body.js +14 -8
- package/es6/components/DataTable/GroupedBody.js +3 -3
- package/es6/components/DataTable/buildState.js +5 -1
- package/es6/components/DataTable/stories/SpaceX.js +2 -2
- package/es6/components/DataTable/stories/SpaceXUngrouped.js +1 -1
- package/es6/components/Drop/DropContainer.js +51 -3
- package/es6/components/FileInput/index.d.ts +2 -3
- package/es6/components/FocusedContainer.js +136 -19
- package/es6/components/Grommet/Grommet.js +12 -6
- package/es6/components/Layer/Layer.js +1 -1
- package/es6/components/Layer/index.d.ts +2 -0
- package/es6/components/List/List.js +18 -12
- package/es6/components/MaskedInput/MaskedInput.js +3 -0
- package/es6/components/Menu/Menu.js +3 -3
- package/es6/components/Meter/Circle.js +2 -2
- package/es6/components/Notification/Notification.js +18 -6
- package/es6/components/Notification/index.d.ts +1 -0
- package/es6/components/Notification/propTypes.js +1 -0
- package/es6/components/Pagination/Pagination.js +4 -2
- package/es6/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/es6/components/Select/Select.js +30 -19
- package/es6/components/Select/SelectContainer.js +41 -34
- package/es6/components/Select/index.d.ts +1 -1
- package/es6/components/Select/stories/ChildrenRender.js +7 -8
- package/es6/components/Select/utils.js +15 -3
- package/es6/components/SelectMultiple/SelectMultiple.js +18 -6
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +28 -2
- package/es6/components/SelectMultiple/SelectMultipleValue.js +14 -1
- package/es6/components/SkipLinks/index.d.ts +1 -0
- package/es6/components/SkipLinks/propTypes.js +1 -0
- package/es6/components/Tab/Tab.js +1 -1
- package/es6/components/Tag/Tag.js +11 -7
- package/es6/components/TextInput/TextInput.js +3 -0
- package/es6/components/ToggleGroup/StyledToggleGroup.js +12 -5
- package/es6/components/ToggleGroup/ToggleGroup.js +22 -11
- package/es6/components/WorldMap/WorldMap.js +1 -1
- package/es6/contexts/RootsContext.js +20 -3
- package/es6/themes/base.d.ts +205 -6
- package/es6/themes/base.js +166 -1
- package/es6/utils/DOM.js +2 -1
- package/es6/utils/background.js +1 -1
- package/es6/utils/index.js +2 -1
- package/es6/utils/styles.js +8 -0
- package/es6/utils/useId.js +16 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/package.json +40 -40
- package/themes/base.d.ts +205 -6
- package/themes/base.js +166 -1
- package/utils/DOM.js +2 -1
- package/utils/background.js +1 -1
- package/utils/index.js +6 -0
- package/utils/styles.js +9 -1
- package/utils/useId.js +19 -0
|
@@ -16,12 +16,6 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
16
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
17
17
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
18
18
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
19
|
-
// Ideally we should use `useId` from react but this is only available
|
|
20
|
-
// in React 18 and we want to keep compatibility with React 17 and 16.
|
|
21
|
-
function getUID() {
|
|
22
|
-
var timestamp = Date.now() + Math.random();
|
|
23
|
-
return "grommet-accordion-button-" + timestamp;
|
|
24
|
-
}
|
|
25
19
|
var AccordionPanel = exports.AccordionPanel = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
26
20
|
var children = _ref.children,
|
|
27
21
|
header = _ref.header,
|
|
@@ -33,7 +27,7 @@ var AccordionPanel = exports.AccordionPanel = /*#__PURE__*/(0, _react.forwardRef
|
|
|
33
27
|
_onFocus = _ref.onFocus,
|
|
34
28
|
_onBlur = _ref.onBlur,
|
|
35
29
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
36
|
-
var panelButtonId =
|
|
30
|
+
var panelButtonId = (0, _utils.useId)();
|
|
37
31
|
var _useThemeValue = (0, _useThemeValue2.useThemeValue)(),
|
|
38
32
|
theme = _useThemeValue.theme;
|
|
39
33
|
var _useContext = (0, _react.useContext)(_AccordionContext.AccordionContext),
|
package/components/Box/Box.js
CHANGED
|
@@ -116,7 +116,7 @@ var Box = exports.Box = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
|
|
|
116
116
|
if (firstIndex === undefined) {
|
|
117
117
|
firstIndex = index;
|
|
118
118
|
} else {
|
|
119
|
-
contents.push(
|
|
119
|
+
contents.push(/*#__PURE__*/_react["default"].createElement(_StyledBox.StyledBoxGap
|
|
120
120
|
// eslint-disable-next-line react/no-array-index-key
|
|
121
121
|
, _extends({
|
|
122
122
|
key: "gap-" + index,
|
|
@@ -38,11 +38,6 @@ var directionStyle = function directionStyle(direction, theme) {
|
|
|
38
38
|
}
|
|
39
39
|
return styles;
|
|
40
40
|
};
|
|
41
|
-
var elevationStyle = function elevationStyle(elevation) {
|
|
42
|
-
return (0, _styledComponents.css)(["box-shadow:", ";"], function (props) {
|
|
43
|
-
return props.theme.global.elevation[props.theme.dark ? 'dark' : 'light'][elevation];
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
41
|
var FLEX_MAP = (_FLEX_MAP = {}, _FLEX_MAP[true] = '1 1', _FLEX_MAP[false] = '0 0', _FLEX_MAP.grow = '1 0', _FLEX_MAP.shrink = '0 1', _FLEX_MAP);
|
|
47
42
|
var flexGrowShrinkProp = function flexGrowShrinkProp(flex) {
|
|
48
43
|
if (typeof flex === 'boolean' || typeof flex === 'string') {
|
|
@@ -205,7 +200,7 @@ var StyledBox = exports.StyledBox = _styledComponents["default"].div.withConfig(
|
|
|
205
200
|
}, function (props) {
|
|
206
201
|
return props.overflowProp && (0, _utils.overflowStyle)(props.overflowProp);
|
|
207
202
|
}, function (props) {
|
|
208
|
-
return props.elevationProp && elevationStyle(props.elevationProp);
|
|
203
|
+
return props.elevationProp && (0, _utils.elevationStyle)(props.elevationProp);
|
|
209
204
|
}, function (props) {
|
|
210
205
|
return props.gap && gapStyle(props.directionProp, props.gap, props.responsive, props.wrapProp, props.theme);
|
|
211
206
|
}, function (props) {
|
|
@@ -33,6 +33,7 @@ export interface BoxProps {
|
|
|
33
33
|
background?: BackgroundType;
|
|
34
34
|
basis?: BasisType;
|
|
35
35
|
border?: BorderType;
|
|
36
|
+
cssGap?: boolean;
|
|
36
37
|
direction?: DirectionType;
|
|
37
38
|
elevation?: ElevationType;
|
|
38
39
|
flex?: 'grow' | 'shrink' | boolean | { grow?: number; shrink?: number };
|
|
@@ -31,6 +31,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
31
31
|
background: _generalPropTypes.backgroundDoc,
|
|
32
32
|
basis: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge', 'xxlarge', 'full', '1/2', '1/3', '2/3', '1/4', '2/4', '3/4', 'auto']), _propTypes["default"].string]),
|
|
33
33
|
border: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].oneOf(['top', 'left', 'bottom', 'right', 'start', 'end', 'horizontal', 'vertical', 'all', 'between']), BORDER_SHAPE, _propTypes["default"].arrayOf(BORDER_SHAPE)]),
|
|
34
|
+
cssGap: _propTypes["default"].bool,
|
|
34
35
|
direction: _propTypes["default"].oneOf(['row', 'column', 'row-responsive', 'row-reverse', 'column-reverse']),
|
|
35
36
|
elevation: _generalPropTypes.elevationPropType,
|
|
36
37
|
flex: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['grow', 'shrink']), _propTypes["default"].bool, _propTypes["default"].shape({
|
|
@@ -346,6 +346,7 @@ var Button = exports.Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
346
346
|
}, first, second);
|
|
347
347
|
} else if (typeof children === 'function') {
|
|
348
348
|
contents = children({
|
|
349
|
+
active: active,
|
|
349
350
|
disabled: disabled,
|
|
350
351
|
hover: hover,
|
|
351
352
|
focus: focus
|
|
@@ -29,10 +29,11 @@ var padStyle = function padStyle(props) {
|
|
|
29
29
|
return (0, _styledComponents.css)(["", " ", ""], props.theme.button.padding.vertical, props.theme.button.padding.horizontal);
|
|
30
30
|
};
|
|
31
31
|
var basicStyle = function basicStyle(props) {
|
|
32
|
-
return (0, _styledComponents.css)(["border:", " solid ", ";border-radius:", ";color:", ";padding:", ";", ""], props.theme.button.border.width, (0, _utils.normalizeColor)(props.colorValue || props.theme.button.border.color || 'control', props.theme), radiusStyle(props), (0, _utils.normalizeColor)(props.theme.button.color || 'text', props.theme), padStyle(props), fontStyle(props));
|
|
32
|
+
return (0, _styledComponents.css)(["border:", " solid ", ";border-radius:", ";", " color:", ";padding:", ";", ""], props.theme.button.border.width, (0, _utils.normalizeColor)(props.colorValue || props.theme.button.border.color || 'control', props.theme), radiusStyle(props), props.theme.button.elevation && (0, _styles.elevationStyle)(props.theme.button.elevation), (0, _utils.normalizeColor)(props.theme.button.color || 'text', props.theme), padStyle(props), fontStyle(props));
|
|
33
33
|
};
|
|
34
34
|
var primaryStyle = function primaryStyle(props) {
|
|
35
|
-
|
|
35
|
+
var _props$theme$button$p, _props$theme$button$p2;
|
|
36
|
+
return (0, _styledComponents.css)(["", " border-radius:", ";", " ", ""], (0, _utils.backgroundStyle)((0, _utils.normalizeColor)(props.colorValue || props.theme.button.primary && props.theme.button.primary.color || 'control', props.theme), props.theme, props.theme.button.color), radiusStyle(props), ((_props$theme$button$p = props.theme.button.primary) == null ? void 0 : _props$theme$button$p.elevation) && (0, _styles.elevationStyle)((_props$theme$button$p2 = props.theme.button.primary) == null ? void 0 : _props$theme$button$p2.elevation), props.theme.button.primary && props.theme.button.primary.extend);
|
|
36
37
|
};
|
|
37
38
|
function getHoverColor(props) {
|
|
38
39
|
if (props.colorValue) {
|
|
@@ -77,9 +77,15 @@ var getPath = function getPath(theme, path) {
|
|
|
77
77
|
}
|
|
78
78
|
return obj;
|
|
79
79
|
};
|
|
80
|
-
var adjustPadStyle = function adjustPadStyle(pad, width) {
|
|
81
|
-
var
|
|
82
|
-
|
|
80
|
+
var adjustPadStyle = function adjustPadStyle(pad, width, theme) {
|
|
81
|
+
var _theme$button;
|
|
82
|
+
var intelligentPad = theme == null || (_theme$button = theme.button) == null ? void 0 : _theme$button.intelligentPad;
|
|
83
|
+
if (intelligentPad === true) {
|
|
84
|
+
var offset = (0, _utils.parseMetricToNum)(width);
|
|
85
|
+
return (0, _styledComponents.css)(["padding:", "px ", "px;"], Math.max((0, _utils.parseMetricToNum)(pad.vertical) - offset, 0), Math.max((0, _utils.parseMetricToNum)(pad.horizontal) - offset, 0));
|
|
86
|
+
}
|
|
87
|
+
// If intelligentPad is false return padding without adjustment
|
|
88
|
+
return (0, _styledComponents.css)(["padding:", " ", ";"], pad.vertical, pad.horizontal);
|
|
83
89
|
};
|
|
84
90
|
|
|
85
91
|
// build up CSS from basic to specific based on the supplied sub-object paths
|
|
@@ -108,7 +114,7 @@ var kindStyle = function kindStyle(_ref2) {
|
|
|
108
114
|
// Adjust padding from the button.size or just top button.padding
|
|
109
115
|
// to deal with the kind's border width. But don't override any
|
|
110
116
|
// padding in the kind itself for backward compatibility
|
|
111
|
-
styles.push(adjustPadStyle(pad, obj.border.width));
|
|
117
|
+
styles.push(adjustPadStyle(pad, obj.border.width, theme));
|
|
112
118
|
}
|
|
113
119
|
}
|
|
114
120
|
});
|
|
@@ -122,7 +128,7 @@ var kindStyle = function kindStyle(_ref2) {
|
|
|
122
128
|
// Adjust padding from the button.size or just top button.padding
|
|
123
129
|
// to deal with the kind's border width. But don't override any
|
|
124
130
|
// padding in the kind itself for backward compatibility
|
|
125
|
-
styles.push(adjustPadStyle(pad, obj.border.width));
|
|
131
|
+
styles.push(adjustPadStyle(pad, obj.border.width, theme));
|
|
126
132
|
}
|
|
127
133
|
}
|
|
128
134
|
}
|
|
@@ -135,7 +141,7 @@ var kindStyle = function kindStyle(_ref2) {
|
|
|
135
141
|
// Adjust padding from the button.size or just top button.padding
|
|
136
142
|
// to deal with the hover's border width. But don't override any
|
|
137
143
|
// padding in the hover or hover.kind itself for backward compatibility
|
|
138
|
-
adjPadStyles = adjustPadStyle(pad, obj.border.width);
|
|
144
|
+
adjPadStyles = adjustPadStyle(pad, obj.border.width, theme);
|
|
139
145
|
}
|
|
140
146
|
if (partStyles.length > 0 && !busy && !success) {
|
|
141
147
|
styles.push((0, _styledComponents.css)(["&:hover{", " ", "}"], partStyles, adjPadStyles));
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.getOutputFormat = exports.Calendar = void 0;
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
6
7
|
var _AnnounceContext = require("../../contexts/AnnounceContext");
|
|
7
8
|
var _MessageContext = require("../../contexts/MessageContext");
|
|
8
9
|
var _Box = require("../Box");
|
|
@@ -16,7 +17,9 @@ var _StyledCalendar = require("./StyledCalendar");
|
|
|
16
17
|
var _utils = require("./utils");
|
|
17
18
|
var _dates = require("../../utils/dates");
|
|
18
19
|
var _useThemeValue3 = require("../../utils/useThemeValue");
|
|
20
|
+
var _utils2 = require("../../utils");
|
|
19
21
|
var _excluded = ["activeDate", "animate", "bounds", "children", "date", "dates", "daysOfWeek", "disabled", "initialFocus", "fill", "firstDayOfWeek", "header", "locale", "messages", "onReference", "onSelect", "range", "reference", "showAdjacentDays", "size", "timestamp"];
|
|
22
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
20
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
21
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
22
25
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
@@ -154,12 +157,16 @@ var _getOutputFormat = exports.getOutputFormat = function getOutputFormat(dates)
|
|
|
154
157
|
return 'date timezone';
|
|
155
158
|
};
|
|
156
159
|
var millisecondsPerYear = 31557600000;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
|
|
161
|
+
// when caller opts in to day hover styling, apply all state styles
|
|
162
|
+
// on CalendarDay instead of active state on CalendarDayButton
|
|
163
|
+
var CalendarDayButton = (0, _styledComponents["default"])(_Button.Button).withConfig({
|
|
164
|
+
displayName: "Calendar__CalendarDayButton",
|
|
165
|
+
componentId: "sc-1chaf9i-0"
|
|
166
|
+
})(["", ""], function (props) {
|
|
167
|
+
var _props$theme$calendar;
|
|
168
|
+
return ((_props$theme$calendar = props.theme.calendar) == null || (_props$theme$calendar = _props$theme$calendar.day) == null || (_props$theme$calendar = _props$theme$calendar.hover) == null ? void 0 : _props$theme$calendar.background) && 'background: inherit;';
|
|
169
|
+
});
|
|
163
170
|
var CalendarDay = function CalendarDay(_ref) {
|
|
164
171
|
var children = _ref.children,
|
|
165
172
|
fill = _ref.fill,
|
|
@@ -167,30 +174,46 @@ var CalendarDay = function CalendarDay(_ref) {
|
|
|
167
174
|
isInRange = _ref.isInRange,
|
|
168
175
|
isSelected = _ref.isSelected,
|
|
169
176
|
otherMonth = _ref.otherMonth,
|
|
177
|
+
rangePosition = _ref.rangePosition,
|
|
170
178
|
_ref$buttonProps = _ref.buttonProps,
|
|
171
179
|
buttonProps = _ref$buttonProps === void 0 ? {} : _ref$buttonProps;
|
|
172
180
|
var _useThemeValue = (0, _useThemeValue3.useThemeValue)(),
|
|
173
181
|
passThemeFlag = _useThemeValue.passThemeFlag;
|
|
182
|
+
var usingKeyboard = (0, _utils2.useKeyboard)();
|
|
174
183
|
return /*#__PURE__*/_react["default"].createElement(_StyledCalendar.StyledDayContainer, {
|
|
175
184
|
role: "gridcell",
|
|
176
|
-
sizeProp: size,
|
|
177
|
-
fillContainer: fill
|
|
178
|
-
}, /*#__PURE__*/_react["default"].createElement(CalendarDayButton, _extends({
|
|
179
|
-
fill: fill
|
|
180
|
-
}, buttonProps), /*#__PURE__*/_react["default"].createElement(_StyledCalendar.StyledDay, _extends({
|
|
181
|
-
disabledProp: buttonProps.disabled,
|
|
182
185
|
inRange: isInRange,
|
|
183
|
-
otherMonth: otherMonth,
|
|
184
186
|
isSelected: isSelected,
|
|
187
|
+
rangePosition: rangePosition,
|
|
185
188
|
sizeProp: size,
|
|
186
189
|
fillContainer: fill
|
|
187
|
-
},
|
|
190
|
+
}, /*#__PURE__*/_react["default"].createElement(CalendarDayButton, _extends({
|
|
191
|
+
fill: fill,
|
|
192
|
+
tabIndex: -1,
|
|
193
|
+
plain: true
|
|
194
|
+
}, buttonProps), function (_ref2) {
|
|
195
|
+
var active = _ref2.active,
|
|
196
|
+
hover = _ref2.hover;
|
|
197
|
+
return /*#__PURE__*/_react["default"].createElement(_StyledCalendar.StyledDay
|
|
198
|
+
// only apply active styling when using keyboard
|
|
199
|
+
// otherwise apply hover styling
|
|
200
|
+
, _extends({
|
|
201
|
+
active: usingKeyboard ? active : undefined,
|
|
202
|
+
disabledProp: buttonProps.disabled,
|
|
203
|
+
hover: hover,
|
|
204
|
+
inRange: isInRange,
|
|
205
|
+
isSelected: isSelected,
|
|
206
|
+
otherMonth: otherMonth,
|
|
207
|
+
sizeProp: size,
|
|
208
|
+
fillContainer: fill
|
|
209
|
+
}, passThemeFlag), children);
|
|
210
|
+
}));
|
|
188
211
|
};
|
|
189
|
-
var CalendarCustomDay = function CalendarCustomDay(
|
|
190
|
-
var children =
|
|
191
|
-
fill =
|
|
192
|
-
size =
|
|
193
|
-
buttonProps =
|
|
212
|
+
var CalendarCustomDay = function CalendarCustomDay(_ref3) {
|
|
213
|
+
var children = _ref3.children,
|
|
214
|
+
fill = _ref3.fill,
|
|
215
|
+
size = _ref3.size,
|
|
216
|
+
buttonProps = _ref3.buttonProps;
|
|
194
217
|
if (!buttonProps) {
|
|
195
218
|
return /*#__PURE__*/_react["default"].createElement(_StyledCalendar.StyledDayContainer, {
|
|
196
219
|
role: "gridcell",
|
|
@@ -206,34 +229,34 @@ var CalendarCustomDay = function CalendarCustomDay(_ref2) {
|
|
|
206
229
|
fill: fill
|
|
207
230
|
}, buttonProps), children));
|
|
208
231
|
};
|
|
209
|
-
var Calendar = exports.Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
210
|
-
var activeDateProp =
|
|
211
|
-
|
|
212
|
-
animate =
|
|
213
|
-
boundsProp =
|
|
214
|
-
children =
|
|
215
|
-
dateProp =
|
|
216
|
-
datesProp =
|
|
217
|
-
daysOfWeek =
|
|
218
|
-
disabled =
|
|
219
|
-
initialFocus =
|
|
220
|
-
fill =
|
|
221
|
-
|
|
222
|
-
firstDayOfWeek =
|
|
223
|
-
header =
|
|
224
|
-
|
|
225
|
-
locale =
|
|
226
|
-
messages =
|
|
227
|
-
onReference =
|
|
228
|
-
onSelect =
|
|
229
|
-
range =
|
|
230
|
-
referenceProp =
|
|
231
|
-
|
|
232
|
-
showAdjacentDays =
|
|
233
|
-
|
|
234
|
-
size =
|
|
235
|
-
timestampProp =
|
|
236
|
-
rest = _objectWithoutPropertiesLoose(
|
|
232
|
+
var Calendar = exports.Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref4, ref) {
|
|
233
|
+
var activeDateProp = _ref4.activeDate,
|
|
234
|
+
_ref4$animate = _ref4.animate,
|
|
235
|
+
animate = _ref4$animate === void 0 ? true : _ref4$animate,
|
|
236
|
+
boundsProp = _ref4.bounds,
|
|
237
|
+
children = _ref4.children,
|
|
238
|
+
dateProp = _ref4.date,
|
|
239
|
+
datesProp = _ref4.dates,
|
|
240
|
+
daysOfWeek = _ref4.daysOfWeek,
|
|
241
|
+
disabled = _ref4.disabled,
|
|
242
|
+
initialFocus = _ref4.initialFocus,
|
|
243
|
+
fill = _ref4.fill,
|
|
244
|
+
_ref4$firstDayOfWeek = _ref4.firstDayOfWeek,
|
|
245
|
+
firstDayOfWeek = _ref4$firstDayOfWeek === void 0 ? 0 : _ref4$firstDayOfWeek,
|
|
246
|
+
header = _ref4.header,
|
|
247
|
+
_ref4$locale = _ref4.locale,
|
|
248
|
+
locale = _ref4$locale === void 0 ? 'en-US' : _ref4$locale,
|
|
249
|
+
messages = _ref4.messages,
|
|
250
|
+
onReference = _ref4.onReference,
|
|
251
|
+
onSelect = _ref4.onSelect,
|
|
252
|
+
range = _ref4.range,
|
|
253
|
+
referenceProp = _ref4.reference,
|
|
254
|
+
_ref4$showAdjacentDay = _ref4.showAdjacentDays,
|
|
255
|
+
showAdjacentDays = _ref4$showAdjacentDay === void 0 ? true : _ref4$showAdjacentDay,
|
|
256
|
+
_ref4$size = _ref4.size,
|
|
257
|
+
size = _ref4$size === void 0 ? 'medium' : _ref4$size,
|
|
258
|
+
timestampProp = _ref4.timestamp,
|
|
259
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded);
|
|
237
260
|
var _useThemeValue2 = (0, _useThemeValue3.useThemeValue)(),
|
|
238
261
|
theme = _useThemeValue2.theme,
|
|
239
262
|
passThemeFlag = _useThemeValue2.passThemeFlag;
|
|
@@ -576,7 +599,7 @@ var Calendar = exports.Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
|
576
599
|
var day = new Date(displayBounds[0]);
|
|
577
600
|
var days = [];
|
|
578
601
|
while (days.length < 7) {
|
|
579
|
-
days.push(
|
|
602
|
+
days.push(/*#__PURE__*/_react["default"].createElement(_StyledCalendar.StyledDayContainer, {
|
|
580
603
|
role: "gridcell",
|
|
581
604
|
key: days.length,
|
|
582
605
|
sizeProp: size,
|
|
@@ -602,7 +625,7 @@ var Calendar = exports.Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
|
602
625
|
var _loop = function _loop() {
|
|
603
626
|
if (day.getDay() === firstDayOfWeek) {
|
|
604
627
|
if (days) {
|
|
605
|
-
weeks.push(
|
|
628
|
+
weeks.push(/*#__PURE__*/_react["default"].createElement(_StyledCalendar.StyledWeek, {
|
|
606
629
|
role: "row",
|
|
607
630
|
key: day.getTime(),
|
|
608
631
|
fillContainer: fill
|
|
@@ -612,7 +635,7 @@ var Calendar = exports.Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
|
612
635
|
}
|
|
613
636
|
var otherMonth = day.getMonth() !== reference.getMonth();
|
|
614
637
|
if (!showAdjacentDays && otherMonth) {
|
|
615
|
-
days.push(
|
|
638
|
+
days.push(/*#__PURE__*/_react["default"].createElement(_StyledCalendar.StyledDayContainer, {
|
|
616
639
|
key: day.getTime(),
|
|
617
640
|
sizeProp: size,
|
|
618
641
|
fillContainer: fill
|
|
@@ -634,7 +657,7 @@ var Calendar = exports.Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
|
634
657
|
we know that all days in the array are from the next month. */
|
|
635
658
|
days.length < day.getDate()) {
|
|
636
659
|
blankWeek = true;
|
|
637
|
-
days.push(
|
|
660
|
+
days.push(/*#__PURE__*/_react["default"].createElement(_StyledCalendar.StyledDayContainer, {
|
|
638
661
|
key: day.getTime(),
|
|
639
662
|
sizeProp: size,
|
|
640
663
|
fillContainer: fill
|
|
@@ -647,18 +670,22 @@ var Calendar = exports.Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
|
647
670
|
// this.dayRefs[dateObject] = React.createRef();
|
|
648
671
|
var selected = false;
|
|
649
672
|
var inRange = false;
|
|
650
|
-
var
|
|
673
|
+
var rangePosition;
|
|
674
|
+
var _withinDates = (0, _utils.withinDates)(day, range ? normalizeRange(value, activeDate) : value),
|
|
675
|
+
selectedState = _withinDates[0];
|
|
651
676
|
if (selectedState === 2) {
|
|
652
677
|
selected = true;
|
|
678
|
+
var _withinDates2 = (0, _utils.withinDates)(day, range ? normalizeRange(value, activeDate) : value);
|
|
679
|
+
rangePosition = _withinDates2[1];
|
|
653
680
|
} else if (selectedState === 1) {
|
|
654
681
|
inRange = true;
|
|
655
682
|
}
|
|
656
|
-
var dayDisabled = (0, _utils.withinDates)(day, _normalizeInput(disabled)) || bounds && !(0, _utils.betweenDates)(day, _normalizeInput(bounds));
|
|
683
|
+
var dayDisabled = (0, _utils.withinDates)(day, _normalizeInput(disabled))[0] || bounds && !(0, _utils.betweenDates)(day, _normalizeInput(bounds));
|
|
657
684
|
if (!firstDayInMonth && !dayDisabled && day.getMonth() === reference.getMonth()) {
|
|
658
685
|
firstDayInMonth = dateObject;
|
|
659
686
|
}
|
|
660
687
|
if (!children) {
|
|
661
|
-
days.push(
|
|
688
|
+
days.push(/*#__PURE__*/_react["default"].createElement(CalendarDay, {
|
|
662
689
|
key: day.getTime(),
|
|
663
690
|
buttonProps: {
|
|
664
691
|
a11yTitle: day.toDateString(),
|
|
@@ -677,11 +704,12 @@ var Calendar = exports.Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
|
677
704
|
isInRange: inRange,
|
|
678
705
|
isSelected: selected,
|
|
679
706
|
otherMonth: day.getMonth() !== reference.getMonth(),
|
|
707
|
+
rangePosition: rangePosition,
|
|
680
708
|
size: size,
|
|
681
709
|
fill: fill
|
|
682
710
|
}, day.getDate()));
|
|
683
711
|
} else {
|
|
684
|
-
days.push(
|
|
712
|
+
days.push(/*#__PURE__*/_react["default"].createElement(CalendarCustomDay, {
|
|
685
713
|
key: day.getTime(),
|
|
686
714
|
buttonProps: onSelect ? {
|
|
687
715
|
a11yTitle: day.toDateString(),
|
|
@@ -712,7 +740,7 @@ var Calendar = exports.Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
|
712
740
|
while (day.getTime() < displayBounds[1].getTime()) {
|
|
713
741
|
_loop();
|
|
714
742
|
}
|
|
715
|
-
weeks.push(
|
|
743
|
+
weeks.push(/*#__PURE__*/_react["default"].createElement(_StyledCalendar.StyledWeek
|
|
716
744
|
// if a week contains only blank days, for screen reader accessibility
|
|
717
745
|
// we don't want to set role="row"
|
|
718
746
|
, {
|
|
@@ -761,6 +789,12 @@ var Calendar = exports.Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
|
761
789
|
onEnter: function onEnter() {
|
|
762
790
|
return active !== undefined ? _onClick(active) : undefined;
|
|
763
791
|
},
|
|
792
|
+
onSpace: function onSpace(event) {
|
|
793
|
+
event.preventDefault();
|
|
794
|
+
if (active !== undefined) {
|
|
795
|
+
_onClick(active);
|
|
796
|
+
}
|
|
797
|
+
},
|
|
764
798
|
onUp: function onUp(event) {
|
|
765
799
|
event.preventDefault();
|
|
766
800
|
event.stopPropagation(); // so the page doesn't scroll
|
|
@@ -4,6 +4,7 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.StyledWeeksContainer = exports.StyledWeeks = exports.StyledWeek = exports.StyledDayContainer = exports.StyledDay = exports.StyledCalendar = void 0;
|
|
5
5
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
6
6
|
var _utils = require("../../utils");
|
|
7
|
+
var _background = require("../../utils/background");
|
|
7
8
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
8
9
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
9
10
|
var sizeStyle = function sizeStyle(props) {
|
|
@@ -51,6 +52,21 @@ var slideStyle = function slideStyle(props) {
|
|
|
51
52
|
var weeksSizeStyle = function weeksSizeStyle() {
|
|
52
53
|
return (0, _styledComponents.css)(["display:flex;flex-direction:column;height:100%;"]);
|
|
53
54
|
};
|
|
55
|
+
|
|
56
|
+
// fallback to medium if no size-specific styles
|
|
57
|
+
var rangeRoundStyle = function rangeRoundStyle(props) {
|
|
58
|
+
var _props$theme$calendar5, _props$theme$calendar6;
|
|
59
|
+
var themeObj;
|
|
60
|
+
if (props.isSelected) {
|
|
61
|
+
var _props$theme$calendar, _props$theme$calendar2, _props$theme$calendar3, _props$theme$calendar4;
|
|
62
|
+
var rangeStart = ((_props$theme$calendar = props.theme.calendar) == null || (_props$theme$calendar = _props$theme$calendar[props.sizeProp]) == null || (_props$theme$calendar = _props$theme$calendar.range) == null || (_props$theme$calendar = _props$theme$calendar.start) == null ? void 0 : _props$theme$calendar.round) || ((_props$theme$calendar2 = props.theme.calendar) == null || (_props$theme$calendar2 = _props$theme$calendar2.medium) == null || (_props$theme$calendar2 = _props$theme$calendar2.range) == null || (_props$theme$calendar2 = _props$theme$calendar2.start) == null ? void 0 : _props$theme$calendar2.round);
|
|
63
|
+
var rangeEnd = ((_props$theme$calendar3 = props.theme.calendar) == null || (_props$theme$calendar3 = _props$theme$calendar3[props.sizeProp]) == null || (_props$theme$calendar3 = _props$theme$calendar3.range) == null || (_props$theme$calendar3 = _props$theme$calendar3.end) == null ? void 0 : _props$theme$calendar3.round) || ((_props$theme$calendar4 = props.theme.calendar) == null || (_props$theme$calendar4 = _props$theme$calendar4.medium) == null || (_props$theme$calendar4 = _props$theme$calendar4.range) == null || (_props$theme$calendar4 = _props$theme$calendar4.end) == null ? void 0 : _props$theme$calendar4.round);
|
|
64
|
+
if (props.rangePosition === 'start' && rangeStart) {
|
|
65
|
+
themeObj = rangeStart;
|
|
66
|
+
} else if (props.rangePosition === 'end' && rangeEnd) themeObj = rangeEnd;
|
|
67
|
+
} else themeObj = ((_props$theme$calendar5 = props.theme.calendar) == null || (_props$theme$calendar5 = _props$theme$calendar5[props.sizeProp]) == null || (_props$theme$calendar5 = _props$theme$calendar5.range) == null ? void 0 : _props$theme$calendar5.round) || ((_props$theme$calendar6 = props.theme.calendar) == null || (_props$theme$calendar6 = _props$theme$calendar6.medium) == null || (_props$theme$calendar6 = _props$theme$calendar6.range) == null ? void 0 : _props$theme$calendar6.round);
|
|
68
|
+
return themeObj && [(0, _utils.roundStyle)(themeObj, props.responsive, props.theme), 'overflow: hidden;'];
|
|
69
|
+
};
|
|
54
70
|
var StyledWeeks = exports.StyledWeeks = _styledComponents["default"].div.withConfig(_utils.styledComponentsConfig).withConfig({
|
|
55
71
|
displayName: "StyledCalendar__StyledWeeks",
|
|
56
72
|
componentId: "sc-1y4xhmp-2"
|
|
@@ -71,27 +87,93 @@ var StyledWeek = exports.StyledWeek = _styledComponents["default"].div.withConfi
|
|
|
71
87
|
var StyledDayContainer = exports.StyledDayContainer = _styledComponents["default"].div.withConfig(_utils.styledComponentsConfig).withConfig({
|
|
72
88
|
displayName: "StyledCalendar__StyledDayContainer",
|
|
73
89
|
componentId: "sc-1y4xhmp-4"
|
|
74
|
-
})(["flex:0 1 auto;", ""], function (props) {
|
|
90
|
+
})(["flex:0 1 auto;", " ", " ", ""], function (props) {
|
|
75
91
|
return props.fillContainer && 'width: 14.3%;';
|
|
92
|
+
}, function (props) {
|
|
93
|
+
var _props$theme$calendar7;
|
|
94
|
+
return (props.inRange || props.isSelected && props.rangePosition) && ((_props$theme$calendar7 = props.theme.calendar) == null || (_props$theme$calendar7 = _props$theme$calendar7.range) == null ? void 0 : _props$theme$calendar7.background) && (0, _utils.backgroundStyle)(props.theme.calendar.range.background, props.theme);
|
|
95
|
+
}, function (props) {
|
|
96
|
+
return rangeRoundStyle(props);
|
|
76
97
|
});
|
|
77
98
|
var daySizeStyle = function daySizeStyle(props) {
|
|
78
99
|
var data = props.theme.calendar[props.sizeProp];
|
|
79
100
|
return (0, _styledComponents.css)(["width:", ";height:", ";"], props.fillContainer ? '100%' : data.daySize, props.fillContainer ? '100%' : data.daySize);
|
|
80
101
|
};
|
|
102
|
+
var dayStyle = function dayStyle(props) {
|
|
103
|
+
var backgroundObj;
|
|
104
|
+
var colorObj;
|
|
105
|
+
if (props.isSelected) {
|
|
106
|
+
var _props$theme$calendar8, _props$theme$calendar9;
|
|
107
|
+
backgroundObj = ((_props$theme$calendar8 = props.theme.calendar.day) == null || (_props$theme$calendar8 = _props$theme$calendar8.selected) == null ? void 0 : _props$theme$calendar8.background) || 'control';
|
|
108
|
+
colorObj = (_props$theme$calendar9 = props.theme.calendar.day) == null || (_props$theme$calendar9 = _props$theme$calendar9.selected) == null ? void 0 : _props$theme$calendar9.color;
|
|
109
|
+
} else if (props.inRange) {
|
|
110
|
+
var _props$theme$calendar10, _props$theme$calendar11, _props$theme$calendar12, _props$theme$calendar13;
|
|
111
|
+
// for backwards compatability, only apply this if caller hasn't specified
|
|
112
|
+
// range specific rounding
|
|
113
|
+
// if they have, background will be applied to StyledDayContainer
|
|
114
|
+
backgroundObj = !((_props$theme$calendar10 = props.theme.calendar) != null && (_props$theme$calendar10 = _props$theme$calendar10[props.sizeProp]) != null && (_props$theme$calendar10 = _props$theme$calendar10.range) != null && _props$theme$calendar10.round) && !((_props$theme$calendar11 = props.theme.calendar) != null && (_props$theme$calendar11 = _props$theme$calendar11.medium.range) != null && _props$theme$calendar11.round) && (((_props$theme$calendar12 = props.theme.calendar.day) == null || (_props$theme$calendar12 = _props$theme$calendar12.inRange) == null ? void 0 : _props$theme$calendar12.background) || {
|
|
115
|
+
color: 'control',
|
|
116
|
+
opacity: 'weak'
|
|
117
|
+
});
|
|
118
|
+
colorObj = (_props$theme$calendar13 = props.theme.calendar.day) == null || (_props$theme$calendar13 = _props$theme$calendar13.inRange) == null ? void 0 : _props$theme$calendar13.color;
|
|
119
|
+
} else {
|
|
120
|
+
var _props$theme$calendar14, _props$theme$calendar15;
|
|
121
|
+
backgroundObj = (_props$theme$calendar14 = props.theme.calendar.day) == null ? void 0 : _props$theme$calendar14.background;
|
|
122
|
+
colorObj = (_props$theme$calendar15 = props.theme.calendar.day) == null ? void 0 : _props$theme$calendar15.color;
|
|
123
|
+
}
|
|
124
|
+
if (colorObj && !backgroundObj) return "color: " + (0, _utils.normalizeColor)(colorObj, props.theme) + ";";
|
|
125
|
+
return (0, _utils.backgroundStyle)(backgroundObj, props.theme, colorObj);
|
|
126
|
+
};
|
|
127
|
+
var dayHoverStyle = function dayHoverStyle(props) {
|
|
128
|
+
var backgroundObj;
|
|
129
|
+
var colorObj;
|
|
130
|
+
if (props.isSelected) {
|
|
131
|
+
var _props$theme$calendar16, _props$theme$calendar17;
|
|
132
|
+
backgroundObj = (_props$theme$calendar16 = props.theme.calendar.day) == null || (_props$theme$calendar16 = _props$theme$calendar16.selected) == null || (_props$theme$calendar16 = _props$theme$calendar16.hover) == null ? void 0 : _props$theme$calendar16.background;
|
|
133
|
+
colorObj = (_props$theme$calendar17 = props.theme.calendar.day) == null || (_props$theme$calendar17 = _props$theme$calendar17.selected) == null || (_props$theme$calendar17 = _props$theme$calendar17.hover) == null ? void 0 : _props$theme$calendar17.color;
|
|
134
|
+
} else if (props.inRange) {
|
|
135
|
+
var _props$theme$calendar18, _props$theme$calendar19;
|
|
136
|
+
backgroundObj = (_props$theme$calendar18 = props.theme.calendar.day) == null || (_props$theme$calendar18 = _props$theme$calendar18.inRange) == null || (_props$theme$calendar18 = _props$theme$calendar18.hover) == null ? void 0 : _props$theme$calendar18.background;
|
|
137
|
+
colorObj = (_props$theme$calendar19 = props.theme.calendar.day) == null || (_props$theme$calendar19 = _props$theme$calendar19.inRange) == null || (_props$theme$calendar19 = _props$theme$calendar19.hover) == null ? void 0 : _props$theme$calendar19.color;
|
|
138
|
+
} else {
|
|
139
|
+
var _props$theme$calendar20, _props$theme$calendar21;
|
|
140
|
+
backgroundObj = (_props$theme$calendar20 = props.theme.calendar.day) == null || (_props$theme$calendar20 = _props$theme$calendar20.hover) == null ? void 0 : _props$theme$calendar20.background;
|
|
141
|
+
colorObj = (_props$theme$calendar21 = props.theme.calendar.day) == null || (_props$theme$calendar21 = _props$theme$calendar21.hover) == null ? void 0 : _props$theme$calendar21.color;
|
|
142
|
+
}
|
|
143
|
+
if (colorObj && !backgroundObj) return "color: " + (0, _utils.normalizeColor)(colorObj, props.theme) + ";";
|
|
144
|
+
return (0, _utils.backgroundStyle)(backgroundObj, props.theme, colorObj);
|
|
145
|
+
};
|
|
146
|
+
var dayFontStyle = function dayFontStyle(props) {
|
|
147
|
+
var fontWeight;
|
|
148
|
+
if (props.isSelected) {
|
|
149
|
+
var _props$theme$calendar22;
|
|
150
|
+
fontWeight = (_props$theme$calendar22 = props.theme.calendar.day) == null || (_props$theme$calendar22 = _props$theme$calendar22.selected) == null || (_props$theme$calendar22 = _props$theme$calendar22.font) == null ? void 0 : _props$theme$calendar22.weight;
|
|
151
|
+
} else if (props.inRange) {
|
|
152
|
+
var _props$theme$calendar23;
|
|
153
|
+
fontWeight = (_props$theme$calendar23 = props.theme.calendar.day) == null || (_props$theme$calendar23 = _props$theme$calendar23.inRange) == null || (_props$theme$calendar23 = _props$theme$calendar23.font) == null ? void 0 : _props$theme$calendar23.weight;
|
|
154
|
+
}
|
|
155
|
+
return fontWeight && "font-weight: " + fontWeight + ";";
|
|
156
|
+
};
|
|
81
157
|
var StyledDay = exports.StyledDay = _styledComponents["default"].div.withConfig(_utils.styledComponentsConfig).withConfig({
|
|
82
158
|
displayName: "StyledCalendar__StyledDay",
|
|
83
159
|
componentId: "sc-1y4xhmp-5"
|
|
84
|
-
})(["display:flex;justify-content:center;align-items:center;", " ", " ", " ", " ", " ", ""], function (props) {
|
|
160
|
+
})(["display:flex;justify-content:center;align-items:center;", " ", " ", " ", " ", " ", " ", " ", " ", ""], function (props) {
|
|
85
161
|
return daySizeStyle(props);
|
|
86
162
|
}, function (props) {
|
|
87
|
-
return
|
|
88
|
-
color: 'control',
|
|
89
|
-
opacity: 'weak'
|
|
90
|
-
}, props.theme);
|
|
163
|
+
return dayStyle(props);
|
|
91
164
|
}, function (props) {
|
|
92
165
|
return props.otherMonth && 'opacity: 0.5;';
|
|
93
166
|
}, function (props) {
|
|
94
|
-
return props
|
|
167
|
+
return dayFontStyle(props);
|
|
168
|
+
}, function (props) {
|
|
169
|
+
var _props$theme$calendar24, _props$theme$calendar25;
|
|
170
|
+
// fallback to medium if no size-specific styles
|
|
171
|
+
var round = ((_props$theme$calendar24 = props.theme.calendar) == null || (_props$theme$calendar24 = _props$theme$calendar24[props.sizeProp]) == null || (_props$theme$calendar24 = _props$theme$calendar24.day) == null ? void 0 : _props$theme$calendar24.round) || ((_props$theme$calendar25 = props.theme.calendar) == null || (_props$theme$calendar25 = _props$theme$calendar25.medium) == null || (_props$theme$calendar25 = _props$theme$calendar25.day) == null ? void 0 : _props$theme$calendar25.round);
|
|
172
|
+
return round && (0, _utils.roundStyle)(round, props.responsive, props.theme);
|
|
173
|
+
}, function (props) {
|
|
174
|
+
return props.active && _background.activeStyle;
|
|
175
|
+
}, function (props) {
|
|
176
|
+
return props.hover && dayHoverStyle(props);
|
|
95
177
|
}, function (props) {
|
|
96
178
|
return (
|
|
97
179
|
// when theme uses kind Buttons, since we use children for Button,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.withinDates = exports.subtractMonths = exports.subtractDays = exports.startOfMonth = exports.sameDayOrBefore = exports.sameDayOrAfter = exports.sameDay = exports.handleOffset = exports.endOfMonth = exports.daysApart = exports.betweenDates = exports.addMonths = exports.addDays = void 0;
|
|
4
|
+
exports.withinDates = exports.subtractMonths = exports.subtractDays = exports.startOfMonth = exports.sameDayOrBefore = exports.sameDayOrAfter = exports.sameDay = exports.handleOffset = exports.getRangePosition = exports.endOfMonth = exports.daysApart = exports.betweenDates = exports.addMonths = exports.addDays = void 0;
|
|
5
5
|
// Utility functions for the Calendar.
|
|
6
6
|
// Just what's needed to avoid having to include a dependency like momentjs.
|
|
7
7
|
|
|
@@ -82,6 +82,18 @@ var betweenDates = exports.betweenDates = function betweenDates(date, dates) {
|
|
|
82
82
|
}
|
|
83
83
|
return result;
|
|
84
84
|
};
|
|
85
|
+
var getRangePosition = exports.getRangePosition = function getRangePosition(date, dates) {
|
|
86
|
+
var rangePosition;
|
|
87
|
+
if (dates) {
|
|
88
|
+
var _ref2 = Array.isArray(dates) ? dates.map(function (d) {
|
|
89
|
+
return d ? new Date(d) : undefined;
|
|
90
|
+
}) : [dates, undefined],
|
|
91
|
+
from = _ref2[0],
|
|
92
|
+
to = _ref2[1];
|
|
93
|
+
if (from && sameDay(date, from)) rangePosition = 'start';else if (to && sameDay(date, to)) rangePosition = 'end';
|
|
94
|
+
}
|
|
95
|
+
return rangePosition;
|
|
96
|
+
};
|
|
85
97
|
|
|
86
98
|
// withinDates takes an array of string dates or 2 element arrays and
|
|
87
99
|
// checks whether the supplied date matches any string or is between
|
|
@@ -89,6 +101,7 @@ var betweenDates = exports.betweenDates = function betweenDates(date, dates) {
|
|
|
89
101
|
// returns 2 if exact match, 1 if between, undefined otherwise
|
|
90
102
|
var withinDates = exports.withinDates = function withinDates(date, dates) {
|
|
91
103
|
var result;
|
|
104
|
+
var rangePosition;
|
|
92
105
|
if (dates) {
|
|
93
106
|
if (Array.isArray(dates)) {
|
|
94
107
|
dates.some(function (d) {
|
|
@@ -98,6 +111,7 @@ var withinDates = exports.withinDates = function withinDates(date, dates) {
|
|
|
98
111
|
}
|
|
99
112
|
} else {
|
|
100
113
|
result = betweenDates(date, d);
|
|
114
|
+
rangePosition = getRangePosition(date, d);
|
|
101
115
|
}
|
|
102
116
|
return result;
|
|
103
117
|
});
|
|
@@ -105,7 +119,7 @@ var withinDates = exports.withinDates = function withinDates(date, dates) {
|
|
|
105
119
|
result = 2;
|
|
106
120
|
}
|
|
107
121
|
}
|
|
108
|
-
return result;
|
|
122
|
+
return [result, rangePosition];
|
|
109
123
|
};
|
|
110
124
|
var handleOffset = exports.handleOffset = function handleOffset(date) {
|
|
111
125
|
var normalizedDate = new Date(date);
|
|
@@ -162,7 +162,7 @@ var Carousel = exports.Carousel = function Carousel(_ref) {
|
|
|
162
162
|
var iconColor = (0, _utils.normalizeColor)(theme.carousel.icons.color || 'control', theme);
|
|
163
163
|
var selectors = [];
|
|
164
164
|
var wrappedChildren = _react.Children.map(children, function (child, index) {
|
|
165
|
-
selectors.push(
|
|
165
|
+
selectors.push(/*#__PURE__*/_react["default"].createElement(_Button.Button, {
|
|
166
166
|
a11yTitle: format({
|
|
167
167
|
id: 'carousel.jump',
|
|
168
168
|
values: {
|
|
@@ -481,7 +481,7 @@ var Chart = exports.Chart = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
|
481
481
|
}).join('-');
|
|
482
482
|
var gradientId = uniqueGradientId + "-" + id + "-gradient";
|
|
483
483
|
var maskId = uniqueGradientId + "-" + id + "-mask";
|
|
484
|
-
defs.push(
|
|
484
|
+
defs.push(/*#__PURE__*/_react["default"].createElement("linearGradient", {
|
|
485
485
|
key: "gradientId",
|
|
486
486
|
id: gradientId,
|
|
487
487
|
x1: 0,
|
|
@@ -499,7 +499,7 @@ var Chart = exports.Chart = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
|
499
499
|
stopColor: (0, _utils.normalizeColor)(gradientColor, theme)
|
|
500
500
|
});
|
|
501
501
|
})));
|
|
502
|
-
defs.push(
|
|
502
|
+
defs.push(/*#__PURE__*/_react["default"].createElement("mask", {
|
|
503
503
|
key: "mask",
|
|
504
504
|
id: maskId
|
|
505
505
|
}, drawing));
|
|
@@ -558,7 +558,7 @@ var Chart = exports.Chart = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
|
558
558
|
strokeWidth: strokeWidth
|
|
559
559
|
});
|
|
560
560
|
}
|
|
561
|
-
defs.push(
|
|
561
|
+
defs.push(/*#__PURE__*/_react["default"].createElement("pattern", {
|
|
562
562
|
key: patternId,
|
|
563
563
|
id: patternId,
|
|
564
564
|
width: _double,
|